decocms 4.76.45 → 4.76.46

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 (244) hide show
  1. package/dist/client/assets/{AlertCircle-B947WyJr.js → AlertCircle-BbShH-mX.js} +1 -1
  2. package/dist/client/assets/{AreaChart-BfsmrOXE.js → AreaChart-BTQfN5_9.js} +1 -1
  3. package/dist/client/assets/{ArrowUp-Bs_6P4Iu.js → ArrowUp-TCW_LpqH.js} +1 -1
  4. package/dist/client/assets/{ArrowUpRight-BxZoQJWz.js → ArrowUpRight-B_xjfr4-.js} +1 -1
  5. package/dist/client/assets/{Check-CcnPQW8L.js → Check-BXsPMsW3.js} +1 -1
  6. package/dist/client/assets/{CheckCircle-BU0_-3Q5.js → CheckCircle-D-ON-tXU.js} +1 -1
  7. package/dist/client/assets/{ChevronDown-HIcxNu9L.js → ChevronDown-FK1i2cda.js} +1 -1
  8. package/dist/client/assets/{ChevronRight-C5hCj-BJ.js → ChevronRight-BxKb2X6d.js} +1 -1
  9. package/dist/client/assets/{ChevronUp-zg_HGLWR.js → ChevronUp-DTyu_jE1.js} +1 -1
  10. package/dist/client/assets/{Circle-Bsy8_p9X.js → Circle-D7nNX4K5.js} +1 -1
  11. package/dist/client/assets/{Copy01-CEOVwp8a.js → Copy01-2dybe4kl.js} +1 -1
  12. package/dist/client/assets/{DotsVertical-BlOzCsHI.js → DotsVertical-Db1xcJ5E.js} +1 -1
  13. package/dist/client/assets/{Eye-CDNr9lij.js → Eye-DwR7I4w3.js} +1 -1
  14. package/dist/client/assets/{FilterLines-CY9-eI6Z.js → FilterLines-BBDKngQj.js} +1 -1
  15. package/dist/client/assets/{Flag01-C5CmZtnc.js → Flag01-CN8uzrjo.js} +1 -1
  16. package/dist/client/assets/{Globe01-C0_GSmts.js → Globe01-CV3En2Ls.js} +1 -1
  17. package/dist/client/assets/{Globe04-blrjzALH.js → Globe04-2jfLT1ix.js} +1 -1
  18. package/dist/client/assets/{HardDrive-DDCNtQf8.js → HardDrive-DQUZ995D.js} +1 -1
  19. package/dist/client/assets/{Key01-DhaQwTr9.js → Key01-B9g2V4mx.js} +1 -1
  20. package/dist/client/assets/{LayoutLeft-CDGSUvFB.js → LayoutLeft-DwC5oXY5.js} +1 -1
  21. package/dist/client/assets/{LinkExternal01-wH6B14C5.js → LinkExternal01-BKC76Dzs.js} +1 -1
  22. package/dist/client/assets/{List-CT_BXxlG.js → List-BPL4htEO.js} +1 -1
  23. package/dist/client/assets/{Monitor01-CGFN5sGg.js → Monitor01-BYOux0H1.js} +1 -1
  24. package/dist/client/assets/{Package-Dl0Lfmce.js → Package-PtO_PF68.js} +1 -1
  25. package/dist/client/assets/{Palette-B0Atethk.js → Palette-Cn6kTx3k.js} +1 -1
  26. package/dist/client/assets/{Play-Dz4heBw1.js → Play-C4HbyMxP.js} +1 -1
  27. package/dist/client/assets/{Plus-DkxBw62L.js → Plus-DNC7p-U2.js} +1 -1
  28. package/dist/client/assets/{SearchLg-BxBwkXRA.js → SearchLg-CpecLFUh.js} +1 -1
  29. package/dist/client/assets/{SearchMd-Ck8RI60i.js → SearchMd-Dk-rbKyG.js} +1 -1
  30. package/dist/client/assets/{Settings02-OSetn6ea.js → Settings02-4V30Z_Rc.js} +1 -1
  31. package/dist/client/assets/{Shield01-Dq-HMUMk.js → Shield01-BZrNopeX.js} +1 -1
  32. package/dist/client/assets/{Star01-BlQBW3oI.js → Star01-BtQO-sK-.js} +1 -1
  33. package/dist/client/assets/{Stars01-COr-0k43.js → Stars01-BBOKRt9A.js} +1 -1
  34. package/dist/client/assets/{Stars02-Uz2mjN30.js → Stars02-C2-XCx99.js} +1 -1
  35. package/dist/client/assets/{Sun-NMZSBMue.js → Sun-Bz_6qC2T.js} +1 -1
  36. package/dist/client/assets/{SwitchHorizontal01-aHLJ4VFM.js → SwitchHorizontal01-CWpf3QaM.js} +1 -1
  37. package/dist/client/assets/{Tool01-DPdDFdYA.js → Tool01-BnKQYdvQ.js} +1 -1
  38. package/dist/client/assets/{Tool02-CIj3JzdV.js → Tool02-Cw7OTXRR.js} +1 -1
  39. package/dist/client/assets/{Trash01-ZIY4ACli.js → Trash01-MAA-0WrD.js} +1 -1
  40. package/dist/client/assets/{TrendUp01-DqQByDKq.js → TrendUp01-D1gYLQXN.js} +1 -1
  41. package/dist/client/assets/{Upload01-D1HGy3QV.js → Upload01-BRQNHgaC.js} +1 -1
  42. package/dist/client/assets/{User01-B2aITRRg.js → User01-BiYiS115.js} +1 -1
  43. package/dist/client/assets/{UserPlus01-CoO5zvRr.js → UserPlus01-BMGOb45G.js} +1 -1
  44. package/dist/client/assets/{Users01-HqZawgTe.js → Users01-6LcUxn7A.js} +1 -1
  45. package/dist/client/assets/{Users03-C7WKxyUR.js → Users03-DylWGm6J.js} +1 -1
  46. package/dist/client/assets/{X-Dmet8wMD.js → X-kenEAaZ9.js} +1 -1
  47. package/dist/client/assets/{XCircle-BKwKlF9U.js → XCircle-9dpOIFAc.js} +1 -1
  48. package/dist/client/assets/{XClose-iezakeMo.js → XClose-DoiZPoY5.js} +1 -1
  49. package/dist/client/assets/{Zap-CfXP7HDl.js → Zap-CeDPBsJ6.js} +1 -1
  50. package/dist/client/assets/{ZapSquare-ChZlLfh_.js → ZapSquare-MC8D7_xS.js} +1 -1
  51. package/dist/client/assets/{ZoomOut-9DZqfrOE.js → ZoomOut-B1jg4SEk.js} +1 -1
  52. package/dist/client/assets/{access-gate-w5g_NZJz.js → access-gate-Bln9BeuQ.js} +1 -1
  53. package/dist/client/assets/{add-section-modal-EZt3P0Xz.js → add-section-modal-DkiLZGEQ.js} +1 -1
  54. package/dist/client/assets/{agent-icon-3oSe4h7A.js → agent-icon-Dza5MsGA.js} +1 -1
  55. package/dist/client/assets/{agents-list--g3RXbon.js → agents-list-g0IUCCUo.js} +1 -1
  56. package/dist/client/assets/{ai-providers-xzs6ey-5.js → ai-providers-DuHN0bmh.js} +1 -1
  57. package/dist/client/assets/{alert-BYCTaSqx.js → alert-B-UWhstv.js} +1 -1
  58. package/dist/client/assets/{alert-dialog-DFA_nrL8.js → alert-dialog-BjTVg8xn.js} +1 -1
  59. package/dist/client/assets/{app-editor-C2t8oVQ9.js → app-editor-Bscg6MLt.js} +1 -1
  60. package/dist/client/assets/{auth-CYtv0_rL.js → auth-Cp5Nl1YE.js} +1 -1
  61. package/dist/client/assets/{auth-catchall-DYzFRFT-.js → auth-catchall-DwA_5hbC.js} +1 -1
  62. package/dist/client/assets/auth-entry-CTtPCGlY.js +1 -0
  63. package/dist/client/assets/{auth-split-layout-hlCmxHcd.js → auth-split-layout-CEkXnkBm.js} +1 -1
  64. package/dist/client/assets/{authenticate-and-persist-oauth-CRs0CnsY.js → authenticate-and-persist-oauth-CDxWfL-T.js} +1 -1
  65. package/dist/client/assets/{automation-list-row-DjYgTsuk.js → automation-list-row-7kEmkB7q.js} +1 -1
  66. package/dist/client/assets/automation-runs-C0I8E70_.js +188 -0
  67. package/dist/client/assets/automations-npp4-wog.js +1 -0
  68. package/dist/client/assets/{autosend-DpuAJlz4.js → autosend-Dm4TPbtR.js} +1 -1
  69. package/dist/client/assets/{avatar-DGZ13TB0.js → avatar-CMoEgv7B.js} +1 -1
  70. package/dist/client/assets/{badge-BmdcYP2l.js → badge-CwPxytOX.js} +1 -1
  71. package/dist/client/assets/{block-document-gXgzA-JT.js → block-document-Bg92o2kB.js} +1 -1
  72. package/dist/client/assets/{brand-context-D5LAfjNE.js → brand-context-0YBrBmm2.js} +1 -1
  73. package/dist/client/assets/{buckets-BaIxp0Ei.js → buckets--uxzFU68.js} +1 -1
  74. package/dist/client/assets/{bulk-category-panel-Dku6xKUm.js → bulk-category-panel-BQ6atbz2.js} +1 -1
  75. package/dist/client/assets/{calendar-CpBuBa24.js → calendar-Dua-hLr7.js} +1 -1
  76. package/dist/client/assets/{capability-load-error-CKORpXPj.js → capability-load-error-_-AXIBNu.js} +1 -1
  77. package/dist/client/assets/{card-COkVnQnP.js → card-R9H6yV5R.js} +1 -1
  78. package/dist/client/assets/{category-editor-CkzYWT7p.js → category-editor-DUhtv1t8.js} +1 -1
  79. package/dist/client/assets/{chat-context-DVVCYt3e.js → chat-context-DgsCr8vG.js} +1 -1
  80. package/dist/client/assets/{checkbox-BCHArcau.js → checkbox-4jHm8Kl-.js} +1 -1
  81. package/dist/client/assets/{cli-auth-success-CgPoi_vX.js → cli-auth-success-Plw7Ca04.js} +1 -1
  82. package/dist/client/assets/{collection-detail-DonuJ1ea.js → collection-detail-otD7V02n.js} +1 -1
  83. package/dist/client/assets/{collection-display-button-DX-E5s8i.js → collection-display-button-OKhH37ny.js} +1 -1
  84. package/dist/client/assets/{collection-search-BwRybpDA.js → collection-search-C1JdTb5c.js} +1 -1
  85. package/dist/client/assets/{collection-table-wrapper-Cm_vq1an.js → collection-table-wrapper-9iS-DtyJ.js} +1 -1
  86. package/dist/client/assets/{collection-tabs-CGlZLNZG.js → collection-tabs-CdYYgrXQ.js} +1 -1
  87. package/dist/client/assets/{command-DYuWdmIc.js → command-Dsyt006B.js} +1 -1
  88. package/dist/client/assets/{commerce-onboarding-oXX0RjMQ.js → commerce-onboarding-C-CK5zeh.js} +1 -1
  89. package/dist/client/assets/{companions-core-BN8wLX0q.js → companions-core-Ds2SlsrP.js} +1 -1
  90. package/dist/client/assets/{connect-desktop-dialog-nlx1v20u.js → connect-desktop-dialog-D8ch3MEx.js} +1 -1
  91. package/dist/client/assets/{connection-card-B2p6WHp7.js → connection-card-BCEFn0dL.js} +1 -1
  92. package/dist/client/assets/{connection-detail-DNd225oV.js → connection-detail-NNVrmVmx.js} +1 -1
  93. package/dist/client/assets/{connection-form-helpers-CTe9zYBl.js → connection-form-helpers-B1D0Q0Zd.js} +1 -1
  94. package/dist/client/assets/{connections-B2k7UMz9.js → connections-oNhvnbq9.js} +1 -1
  95. package/dist/client/assets/{decopilot-sse-pool-yvpwgZWV.js → decopilot-sse-pool--LPnPAkT.js} +1 -1
  96. package/dist/client/assets/{dialog-CvMUMR16.js → dialog-kxSQ9Z0G.js} +1 -1
  97. package/dist/client/assets/{domain-settings-rz9NZ9fx.js → domain-settings-CB0jXNY4.js} +1 -1
  98. package/dist/client/assets/{drawer-CQuJuOwU.js → drawer-CqByw-jx.js} +1 -1
  99. package/dist/client/assets/{dropdown-menu-C_qDMDJc.js → dropdown-menu-CG_v90J8.js} +1 -1
  100. package/dist/client/assets/{empty-state-DFI2pRsv.js → empty-state-Dq384oJQ.js} +1 -1
  101. package/dist/client/assets/{extract-connection-data-BFt9JrM6.js → extract-connection-data-CvoL7SnC.js} +1 -1
  102. package/dist/client/assets/file-explorer-kXrDqi0x.js +2 -0
  103. package/dist/client/assets/{file-type-icon-DSufmAQ5.js → file-type-icon-OYkohFDc.js} +1 -1
  104. package/dist/client/assets/{files-C_2xnvjf.js → files-O-jNlZiC.js} +1 -1
  105. package/dist/client/assets/{form-Bo-8Ln1U.js → form-BqeLZw8U.js} +1 -1
  106. package/dist/client/assets/{general-YPYBXJRf.js → general-DqDIaDnw.js} +1 -1
  107. package/dist/client/assets/{github-repo-picker-DfirfuAT.js → github-repo-picker-DPH6oiQm.js} +1 -1
  108. package/dist/client/assets/{hooks-DOkARyS2.js → hooks-BjONhkvU.js} +1 -1
  109. package/dist/client/assets/{index-r5DmdNN7.js → index--fBes_wM.js} +1 -1
  110. package/dist/client/assets/{index-DwqZiRTX.js → index-7cmgkF_X.js} +28 -28
  111. package/dist/client/assets/{index-Oe3PDrxX.js → index-8vjYP3uS.js} +1 -1
  112. package/dist/client/assets/index-BGD06Ifk.js +8 -0
  113. package/dist/client/assets/{index-Ci3NpEBH.js → index-BLTu__Gg.js} +2 -2
  114. package/dist/client/assets/{index-CFF-0dHO.js → index-BM9m0MG6.js} +1 -1
  115. package/dist/client/assets/{index-YA1G0WAf.js → index-BZKz9MXL.js} +1 -1
  116. package/dist/client/assets/index-C1ZoeWCR.js +173 -0
  117. package/dist/client/assets/{index-BPVYWTbD.js → index-CqSXg_h8.js} +1 -1
  118. package/dist/client/assets/{index-CwVaTFWi.js → index-DCeG-s8Z.js} +1 -1
  119. package/dist/client/assets/{index-CS4EwFaR.js → index-DWnxopJb.js} +1 -1
  120. package/dist/client/assets/index-DcaN6oWP.js +1 -0
  121. package/dist/client/assets/{index-BALkJ2dx.js → index-DeV6aDLj.js} +1 -1
  122. package/dist/client/assets/{index-B5cMFR-y.js → index-DlsutDII.js} +3 -3
  123. package/dist/client/assets/{index-redirect-CIUk-Gax.js → index-redirect-DY5rWC9W.js} +1 -1
  124. package/dist/client/assets/{input-BsEx9qgh.js → input-Rw_ct7cN.js} +1 -1
  125. package/dist/client/assets/{integration-icon-BjKZxHyL.js → integration-icon-j5V6Rzm9.js} +1 -1
  126. package/dist/client/assets/{invite-member-dialog-DfAJpHso.js → invite-member-dialog-BDJqia7w.js} +1 -1
  127. package/dist/client/assets/{label-itDnpE7k.js → label-DDLNvJQY.js} +1 -1
  128. package/dist/client/assets/{layout-BeTn9gVm.js → layout-rb7oFUzG.js} +1 -1
  129. package/dist/client/assets/{login-BrNTuDDo.js → login-BE37marJ.js} +1 -1
  130. package/dist/client/assets/{mcp-oauth-DTAyDU2Q.js → mcp-oauth-DNjr4vj5.js} +1 -1
  131. package/dist/client/assets/{members-DyvIH1z_.js → members-CYB89vAT.js} +1 -1
  132. package/dist/client/assets/{monaco-editor-D_6PkZ4D.js → monaco-editor-DPbPbFFi.js} +1 -1
  133. package/dist/client/assets/{monitoring-stats-row-qpSnjSHX.js → monitoring-stats-row-CfIvAiIb.js} +1 -1
  134. package/dist/client/assets/multi-select-CdSgWG0G.js +1 -0
  135. package/dist/client/assets/{oauth-callback-Bx2hE0re.js → oauth-callback-Clt2chuB.js} +1 -1
  136. package/dist/client/assets/{oauth-callback-ai-provider-CxI3pM83.js → oauth-callback-ai-provider-kvy_Ve9Q.js} +1 -1
  137. package/dist/client/assets/onboarding-DJtX40eT.js +1 -0
  138. package/dist/client/assets/{org-install-B8UtLZNk.js → org-install-YdmA9pwU.js} +1 -1
  139. package/dist/client/assets/{org-layout-DLChqlHX.js → org-layout-Cfu3MGrn.js} +1 -1
  140. package/dist/client/assets/{organization-choice-BJmZA_ql.js → organization-choice-DZJIDjkJ.js} +1 -1
  141. package/dist/client/assets/{orgs-B_8qYm3m.js → orgs-CPjLJEw1.js} +1 -1
  142. package/dist/client/assets/{page-seo-form-ZcfqdJ3r.js → page-seo-form-DTJjOqOy.js} +1 -1
  143. package/dist/client/assets/page-seo-sheet-Dh6-jskU.js +1 -0
  144. package/dist/client/assets/{popover-DktOaoCj.js → popover-vUXXfUBc.js} +1 -1
  145. package/dist/client/assets/post-editor-D-LBglk6.js +1 -0
  146. package/dist/client/assets/{primitives-B3tg18Ev.js → primitives-BmrXhyFZ.js} +1 -1
  147. package/dist/client/assets/{profile-Cm9T7Soa.js → profile-CbQV6Byw.js} +1 -1
  148. package/dist/client/assets/project-app-view-11N4RGfj.js +1 -0
  149. package/dist/client/assets/record-editor-D-PnxGFM.js +1 -0
  150. package/dist/client/assets/redirect-editor-DtcSfkYS.js +1 -0
  151. package/dist/client/assets/registry-CopB5Gj5.js +2 -0
  152. package/dist/client/assets/{registry-layout-IoatJ7vG.js → registry-layout-DOpccjDe.js} +1 -1
  153. package/dist/client/assets/{reports-_wvCcLC_.js → reports-CmHQ81Pn.js} +1 -1
  154. package/dist/client/assets/{require-capability-DQnQYS51.js → require-capability-Dgv4ZomJ.js} +1 -1
  155. package/dist/client/assets/{required-auth-layout-PXLv9yf-.js → required-auth-layout-DEOqamE2.js} +1 -1
  156. package/dist/client/assets/{reset-password-DalzN_iF.js → reset-password-CWTfWC5h.js} +1 -1
  157. package/dist/client/assets/{roles-D6U_2d-V.js → roles-wkuYTB_S.js} +1 -1
  158. package/dist/client/assets/{search-input-DwylCsr-.js → search-input-Bjb6CtBl.js} +1 -1
  159. package/dist/client/assets/{secrets-YNk1kWRi.js → secrets-Di7mGwRX.js} +1 -1
  160. package/dist/client/assets/{sections-editor-DYDZI5jr.js → sections-editor-CxY-amhz.js} +1 -1
  161. package/dist/client/assets/{select-CkNw5vmE.js → select-ll87QfGd.js} +1 -1
  162. package/dist/client/assets/{select-model-DJy9oKx6.js → select-model-xsRbpwr8.js} +1 -1
  163. package/dist/client/assets/{self-tool-result-1X-Z7ZyX.js → self-tool-result-DPZt14Vy.js} +1 -1
  164. package/dist/client/assets/{seo-editor-Cn3g21qw.js → seo-editor-Bx_vZzjl.js} +1 -1
  165. package/dist/client/assets/settings-layout-BJWT8yEM.js +1 -0
  166. package/dist/client/assets/{settings-section-M1O3ge8Z.js → settings-section-BPXGeyMz.js} +1 -1
  167. package/dist/client/assets/{shell-controls-CVfU7qci.js → shell-controls-D-TopT5a.js} +1 -1
  168. package/dist/client/assets/{shell-layout-DoAVrerK.js → shell-layout-DWQz87Pa.js} +1 -1
  169. package/dist/client/assets/{sidebar-BQFslZSt.js → sidebar-Dju9sgvp.js} +1 -1
  170. package/dist/client/assets/{skeleton-CKbIkp-i.js → skeleton-CdoG2zLE.js} +1 -1
  171. package/dist/client/assets/{sso-Cw5YEeWo.js → sso-CmByVx0d.js} +1 -1
  172. package/dist/client/assets/{store-BtFkKlkI.js → store-BLa7VKhN.js} +1 -1
  173. package/dist/client/assets/store-registry-BMkGX-xs.js +2 -0
  174. package/dist/client/assets/{studio-tools-C0FSNSO6.js → studio-tools-D2YN6d8l.js} +1 -1
  175. package/dist/client/assets/{switch-BOKpfG2a.js → switch-xWUsjG4Q.js} +1 -1
  176. package/dist/client/assets/{table-B88p_wsC.js → table-DhhEQ0mO.js} +1 -1
  177. package/dist/client/assets/{tabs-DDA7IPHD.js → tabs-g6MtT8J3.js} +1 -1
  178. package/dist/client/assets/{textarea-D9ia054b.js → textarea-Bjk6bxvA.js} +1 -1
  179. package/dist/client/assets/{toggle-group-CisLBmfi.js → toggle-group-CnVszF4a.js} +1 -1
  180. package/dist/client/assets/{toolbar-lHwKVbcz.js → toolbar-Cu9Rhq6w.js} +1 -1
  181. package/dist/client/assets/{toolbar-icon-button-BdhEbL8g.js → toolbar-icon-button-BbNgXfao.js} +1 -1
  182. package/dist/client/assets/{tooltip-Cm1Uo3tj.js → tooltip-vH0hT_S_.js} +1 -1
  183. package/dist/client/assets/{use-ai-providers-BSTSxr9f.js → use-ai-providers-sqQoB_M0.js} +1 -1
  184. package/dist/client/assets/{use-automations-z-3-_HVg.js → use-automations-CGN75f-I.js} +1 -1
  185. package/dist/client/assets/{use-autosave-DOzBKdWx.js → use-autosave-CkPLD6B4.js} +1 -1
  186. package/dist/client/assets/{use-capability-H0m9y9gf.js → use-capability-_dbRY3q9.js} +1 -1
  187. package/dist/client/assets/{use-clock-tick-DVjyQSN6.js → use-clock-tick-BWb_U2Xo.js} +1 -1
  188. package/dist/client/assets/{use-collections-IkbkyTPy.js → use-collections-B8ZAMyMV.js} +1 -1
  189. package/dist/client/assets/{use-connection-BjfpYHE7.js → use-connection-SJTKeTV8.js} +1 -1
  190. package/dist/client/assets/{use-copy-BhCEUwuV.js → use-copy-BLjfFW8C.js} +1 -1
  191. package/dist/client/assets/{use-create-virtual-mcp-N2ZbWygG.js → use-create-virtual-mcp-0lZOsba5.js} +1 -1
  192. package/dist/client/assets/{use-debounced-autosave-DRL2Q2vw.js → use-debounced-autosave-CojpJ2Z2.js} +1 -1
  193. package/dist/client/assets/{use-debounced-value-DYEvOfgl.js → use-debounced-value-Djv7lm81.js} +1 -1
  194. package/dist/client/assets/{use-deco-credits-CAb1KNIs.js → use-deco-credits-C9en5xKK.js} +1 -1
  195. package/dist/client/assets/{use-decopilot-events-CssQ7XMz.js → use-decopilot-events-D7uiMNY1.js} +1 -1
  196. package/dist/client/assets/{use-delete-connection-CJ6X4D3N.js → use-delete-connection-L8_mYjFV.js} +1 -1
  197. package/dist/client/assets/{use-deployment-admin-DxlBCcMw.js → use-deployment-admin-kF9Z8x8H.js} +1 -1
  198. package/dist/client/assets/{use-file-configs-DniTn_7W.js → use-file-configs-Cf-WdLXO.js} +1 -1
  199. package/dist/client/assets/{use-infinite-scroll-BzjM30U0.js → use-infinite-scroll-BcCvsdjd.js} +1 -1
  200. package/dist/client/assets/{use-join-requests-DH0ZVoBc.js → use-join-requests-CnwVYkrj.js} +1 -1
  201. package/dist/client/assets/{use-mcp-auth-status-B-vnUxNV.js → use-mcp-auth-status-DcCkteNo.js} +1 -1
  202. package/dist/client/assets/{use-mcp-client-lixd0gAV.js → use-mcp-client-C6JIQ2mv.js} +1 -1
  203. package/dist/client/assets/{use-mcp-tools-Cv_rmBI5.js → use-mcp-tools-BtiniEuA.js} +1 -1
  204. package/dist/client/assets/{use-members-XsfnxDj6.js → use-members-C4v7iGly.js} +1 -1
  205. package/dist/client/assets/{use-mobile-BYgIZfXj.js → use-mobile-BrmE87Sd.js} +1 -1
  206. package/dist/client/assets/{use-navigate-to-agent-BAQepcY9.js → use-navigate-to-agent-Ily6aQHi.js} +1 -1
  207. package/dist/client/assets/{use-org-auth-client-DNG8tLX7.js → use-org-auth-client-BS08LyYo.js} +1 -1
  208. package/dist/client/assets/{use-org-sso-CymoIsv4.js → use-org-sso-CWPP-CGh.js} +1 -1
  209. package/dist/client/assets/{use-organization-roles-pkqdjnMJ.js → use-organization-roles-C-1IxgQu.js} +1 -1
  210. package/dist/client/assets/{use-organization-settings-DxC5BT5e.js → use-organization-settings-DJM4Zmu-.js} +1 -1
  211. package/dist/client/assets/{use-registry-connections-DzCHf8MS.js → use-registry-connections-BqqId9V-.js} +1 -1
  212. package/dist/client/assets/{use-secrets-j9NqCesQ.js → use-secrets-0cKpwB02.js} +1 -1
  213. package/dist/client/assets/{use-status-sounds-C-YKbG5N.js → use-status-sounds-BQrsykBc.js} +1 -1
  214. package/dist/client/assets/{use-view-mode-C6YHDmgm.js → use-view-mode-t_ypwSCC.js} +1 -1
  215. package/dist/client/assets/{use-virtual-mcp-DUjw2r9s.js → use-virtual-mcp-D06GSrBg.js} +1 -1
  216. package/dist/client/assets/useInfiniteQuery-uVPnN3Ll.js +1 -0
  217. package/dist/client/assets/{useRouterState-Cqq6ONsl.js → useRouterState-D-A1Ld7s.js} +1 -1
  218. package/dist/client/assets/useSuspenseInfiniteQuery-DCwOcpeP.js +1 -0
  219. package/dist/client/assets/{users-BlkgmN4u.js → users-B1ypwcEd.js} +1 -1
  220. package/dist/client/assets/variant-calendar-D36Cj1MF.js +1 -0
  221. package/dist/client/assets/{view-mode-toggle-CKsyyD3I.js → view-mode-toggle-BE2XSMM1.js} +1 -1
  222. package/dist/client/index.html +1 -1
  223. package/dist/server/cli.js +1 -1
  224. package/dist/server/server.js +1 -1
  225. package/package.json +1 -1
  226. package/dist/client/assets/auth-entry-DA-DPJTf.js +0 -1
  227. package/dist/client/assets/automation-runs-Db6yr9QX.js +0 -188
  228. package/dist/client/assets/automations-DTXTPNDC.js +0 -1
  229. package/dist/client/assets/file-explorer-CSMp40V7.js +0 -2
  230. package/dist/client/assets/index-BBdtoWBk.js +0 -173
  231. package/dist/client/assets/index-C-wKLEZ2.js +0 -8
  232. package/dist/client/assets/index-CpDqKOXJ.js +0 -1
  233. package/dist/client/assets/onboarding-BX2PevDl.js +0 -1
  234. package/dist/client/assets/page-seo-sheet-DmyH2nwh.js +0 -1
  235. package/dist/client/assets/post-editor-Dy_-iCsZ.js +0 -1
  236. package/dist/client/assets/project-app-view-DHGMtUxb.js +0 -1
  237. package/dist/client/assets/record-editor-225seTN8.js +0 -1
  238. package/dist/client/assets/redirect-editor-BWUzCv5f.js +0 -1
  239. package/dist/client/assets/registry-3lo6s_j5.js +0 -2
  240. package/dist/client/assets/settings-layout-B2pZI8PO.js +0 -1
  241. package/dist/client/assets/store-registry-CRAi8gqB.js +0 -2
  242. package/dist/client/assets/useInfiniteQuery-Bx9w5_18.js +0 -1
  243. package/dist/client/assets/useSuspenseInfiniteQuery-DDY3jNH9.js +0 -1
  244. package/dist/client/assets/variant-calendar-DQDzXWUH.js +0 -1
@@ -0,0 +1,188 @@
1
+ import{r as E,c as _,J as Kh,j as p,B as un,I as ra,H as Jh,M as Gh,bJ as Kc,bK as Xh,at as Yh,aM as dn,bL as Qh,l as ee,p as Zh,aR as ep,aO as Ut,aV as tp,aU as _t,ba as Nr,aS as kn,bM as Jc,aQ as Gc,C as Ct,n as np,d as rp,K as Qe,t as Xo,m as Mr,b as Vn,E as Xc,aL as Yc,bN as Bi,aT as sp,bO as Qt}from"./index-DlsutDII.js";import{e as op}from"./select-ll87QfGd.js";import{u as Qc}from"./useInfiniteQuery-uVPnN3Ll.js";import{a as Zc,u as ip}from"./use-connection-SJTKeTV8.js";import{c as lp,u as Fi}from"./use-mcp-client-C6JIQ2mv.js";import{u as ap}from"./use-virtual-mcp-D06GSrBg.js";import{b as cp,i as up,a as dp,S as fp}from"./constants-D_FQAPnt.js";import{C as hp}from"./card-R9H6yV5R.js";import{o as eu,m as tu,p as Hi,q as Vi}from"./sidebar-Dju9sgvp.js";import{c as nu,d as ru,a as Ks,e as Je,b as su,T as Ge}from"./table-DhhEQ0mO.js";import{E as Yo}from"./empty-state-Dq384oJQ.js";import{u as Wi}from"./use-infinite-scroll-BcCvsdjd.js";import{u as pp}from"./use-members-C4v7iGly.js";import{u as ou,S as Rn}from"./use-clock-tick-BWb_U2Xo.js";import{e as mp}from"./use-automations-CGN75f-I.js";import{u as iu}from"./studio-tools-D2YN6d8l.js";import{u as gp}from"./useSuspenseInfiniteQuery-DCwOcpeP.js";import{A as lu}from"./avatar-CMoEgv7B.js";import{t as Zr}from"./ChevronDown-FK1i2cda.js";import{n as Qo}from"./ChevronUp-DTyu_jE1.js";import{t as xp,a as au,n as Ui}from"./Tool02-Cw7OTXRR.js";import{e as yp,U as bp,u as kp,ap as Sp,aa as vp,af as wp,j as Cp,an as cu,aq as Tp,ar as Np,A as uu,as as ut,at as Mp,au as Ep,av as Ap}from"./agent-icon-Dza5MsGA.js";import{t as Js}from"./Stars01-BBOKRt9A.js";import{i as du,b as Or}from"./XCircle-9dpOIFAc.js";import{i as qi}from"./Check-BXsPMsW3.js";import{i as sa}from"./ChevronRight-BxKb2X6d.js";import{a as fu}from"./Copy01-2dybe4kl.js";import{b as Ht,t as Ki,c as oa}from"./format-time-BnbuEtat.js";import{u as hu}from"./use-copy-BLjfFW8C.js";import{T as fn,a as hn,b as pn}from"./tooltip-vH0hT_S_.js";import{M as Ji,I as pu,F as jp}from"./file-type-icon-OYkohFDc.js";import{c as Ip}from"./monaco-editor-DPbPbFFi.js";import{g as mu,M as Op}from"./index-DWnxopJb.js";import{S as Rp,h as Wn,m as Dp,c as Gi,d as Pp,b as Lp}from"./chat-context-DgsCr8vG.js";import{c as _p,r as $p,g as zp,R as Bp}from"./hooks-BjONhkvU.js";import{f as Fp,n as Hp,o as Vp}from"./tab-id-BijBBRwE.js";import{i as gu}from"./AlertCircle-BbShH-mX.js";import{s as Wp}from"./Eye-DwR7I4w3.js";import{s as es,t as xu}from"./Star01-BtQO-sK-.js";import{s as Up}from"./XClose-DoiZPoY5.js";import{n as Zo}from"./ZapSquare-MC8D7_xS.js";import{n as yu,i as qp}from"./Globe01-CV3En2Ls.js";import{d as Kp,c as Jp,a as Rr}from"./Tool01-BnKQYdvQ.js";import{i as ia,a as Gp}from"./ZoomOut-B1jg4SEk.js";import{i as nr}from"./Monitor01-BYOux0H1.js";import{i as Xp}from"./SearchMd-Dk-rbKyG.js";import{i as Yp}from"./Upload01-BRQNHgaC.js";import{u as Qp,a as Zp}from"./shell-layout-DWQz87Pa.js";import{n as bu}from"./LinkExternal01-BKC76Dzs.js";import{I as qt}from"./integration-icon-j5V6Rzm9.js";import{i as em}from"./ArrowUpRight-B_xjfr4-.js";import{a as Xi}from"./Users03-DylWGm6J.js";import{a as dt}from"./Palette-Cn6kTx3k.js";import{c as ku}from"./use-navigate-to-agent-Ily6aQHi.js";import{a as tm}from"./Stars02-C2-XCx99.js";import{g as nm}from"./AreaChart-BTQfN5_9.js";import{a as rm,D as sm,c as om,d as im,e as lm}from"./dialog-kxSQ9Z0G.js";import{a as am,F as cm,b as um,c as dm,d as fm,f as hm}from"./form-BqeLZw8U.js";import{I as pm}from"./input-Rw_ct7cN.js";import{i as mm}from"./UserPlus01-BMGOb45G.js";const gm={openrouter:n=>{const e=n?.openrouter;return typeof e=="object"&&e!==null&&"usage"in e&&typeof e.usage=="object"&&e.usage!==null&&"cost"in e.usage&&typeof e.usage.cost=="number"?e.usage.cost:null}};function Su(n){if(!n?.providerMetadata)return 0;for(const e of Object.values(gm)){const t=e(n.providerMetadata);if(t!==null)return t}return 0}function vu(){return{inputTokens:0,outputTokens:0,reasoningTokens:0,totalTokens:0,cost:0,cacheReadTokens:0,cacheWriteTokens:0}}function wu(n,e){if(!e)return n;const t=e.inputTokenDetails?.cacheReadTokens??e.cachedInputTokens??0,r=e.inputTokenDetails?.cacheWriteTokens??0;return{inputTokens:n.inputTokens+(e.inputTokens??0),outputTokens:n.outputTokens+(e.outputTokens??0),reasoningTokens:n.reasoningTokens+(e.reasoningTokens??0),totalTokens:n.totalTokens+(e.totalTokens??0),cost:n.cost+Su(e),cacheReadTokens:n.cacheReadTokens+t,cacheWriteTokens:n.cacheWriteTokens+r}}function qC(n){return n.reduce((e,t)=>wu(e,t.metadata?.usage),vu())}const xm={damping:.7,stiffness:.05,mass:1.25},ym=70,bm=1e3/60,km=350;let Gs=!1;globalThis.document?.addEventListener("mousedown",()=>{Gs=!0});globalThis.document?.addEventListener("mouseup",()=>{Gs=!1});globalThis.document?.addEventListener("click",()=>{Gs=!1});const Sm=(n={})=>{const[e,t]=E.useState(!1),[r,s]=E.useState(n.initial!==!1),[o,i]=E.useState(!1),l=E.useRef(null);l.current=n;const a=E.useCallback(()=>{if(!Gs)return!1;const b=window.getSelection();if(!b||!b.rangeCount)return!1;const k=b.getRangeAt(0);return k.commonAncestorContainer.contains(x.current)||x.current?.contains(k.commonAncestorContainer)},[]),c=E.useCallback(b=>{d.isAtBottom=b,s(b)},[]),u=E.useCallback(b=>{d.escapedFromLock=b,t(b)},[]),d=E.useMemo(()=>{let b;return{escapedFromLock:e,isAtBottom:r,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return x.current?.scrollTop??0},set scrollTop(k){if(x.current){const{scrollBehavior:S}=getComputedStyle(x.current);S!=="auto"&&(x.current.style.scrollBehavior="auto"),x.current.scrollTop=k,d.ignoreScrollToTop=x.current.scrollTop,S!=="auto"&&(x.current.style.scrollBehavior=S)}},get targetScrollTop(){return!x.current||!y.current?0:x.current.scrollHeight-1-x.current.clientHeight},get calculatedTargetScrollTop(){if(!x.current||!y.current)return 0;const{targetScrollTop:k}=this;if(!n.targetScrollTop)return k;if(b?.targetScrollTop===k)return b.calculatedScrollTop;const S=Math.max(Math.min(n.targetScrollTop(k,{scrollElement:x.current,contentElement:y.current}),k),0);return b={targetScrollTop:k,calculatedScrollTop:S},requestAnimationFrame(()=>{b=void 0}),S},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=ym}}},[]),f=E.useCallback((b={})=>{typeof b=="string"&&(b={animation:b}),b.preserveScrollPosition||c(!0);const k=Date.now()+(Number(b.wait)||0),S=bo(l.current,b.animation),{ignoreEscapes:v=!1}=b;let w,C=d.calculatedTargetScrollTop;b.duration instanceof Promise?b.duration.finally(()=>{w=Date.now()}):w=k+(b.duration??0);const T=async()=>{const N=new Promise(requestAnimationFrame).then(()=>{if(!d.isAtBottom)return d.animation=void 0,!1;const{scrollTop:M}=d,j=performance.now(),R=(j-(d.lastTick??j))/bm;if(d.animation||(d.animation={behavior:S,promise:N,ignoreEscapes:v}),d.animation.behavior===S&&(d.lastTick=j),a()||k>Date.now())return T();if(M<Math.min(C,d.calculatedTargetScrollTop)){if(d.animation?.behavior===S){if(S==="instant")return d.scrollTop=d.calculatedTargetScrollTop,T();d.velocity=(S.damping*d.velocity+S.stiffness*d.scrollDifference)/S.mass,d.accumulated+=d.velocity*R,d.scrollTop+=d.accumulated,d.scrollTop!==M&&(d.accumulated=0)}return T()}return w>Date.now()?(C=d.calculatedTargetScrollTop,T()):(d.animation=void 0,d.scrollTop<d.calculatedTargetScrollTop?f({animation:bo(l.current,l.current.resize),ignoreEscapes:v,duration:Math.max(0,w-Date.now())||void 0}):d.isAtBottom)});return N.then(M=>(requestAnimationFrame(()=>{d.animation||(d.lastTick=void 0,d.velocity=0)}),M))};return b.wait!==!0&&(d.animation=void 0),d.animation?.behavior===S?d.animation.promise:T()},[c,a,d]),h=E.useCallback(()=>{u(!0),c(!1)},[u,c]),m=E.useCallback(({target:b})=>{if(b!==x.current)return;const{scrollTop:k,ignoreScrollToTop:S}=d;let{lastScrollTop:v=k}=d;d.lastScrollTop=k,d.ignoreScrollToTop=void 0,S&&S>k&&(v=S),i(d.isNearBottom),setTimeout(()=>{if(d.resizeDifference||k===S)return;if(a()){u(!0),c(!1);return}const w=k>v,C=k<v;if(d.animation?.ignoreEscapes){d.scrollTop=v;return}C&&(u(!0),c(!1)),w&&u(!1),!d.escapedFromLock&&d.isNearBottom&&c(!0)},1)},[u,c,a,d]),g=E.useCallback(({target:b,deltaY:k})=>{let S=b;for(;!["scroll","auto"].includes(getComputedStyle(S).overflow);){if(!S.parentElement)return;S=S.parentElement}S===x.current&&k<0&&x.current.scrollHeight>x.current.clientHeight&&!d.animation?.ignoreEscapes&&(u(!0),c(!1))},[u,c,d]),x=la(b=>{x.current?.removeEventListener("scroll",m),x.current?.removeEventListener("wheel",g),b?.addEventListener("scroll",m,{passive:!0}),b?.addEventListener("wheel",g,{passive:!0})},[]),y=la(b=>{if(d.resizeObserver?.disconnect(),d.resizeObserver=void 0,!b)return;let k;d.resizeObserver=new ResizeObserver(([S])=>{const{height:v}=S.contentRect,w=v-(k??v);if(d.resizeDifference=w,d.scrollTop>d.targetScrollTop&&(d.scrollTop=d.targetScrollTop),i(d.isNearBottom),w>=0){const C=bo(l.current,k?l.current.resize:l.current.initial);f({animation:C,wait:!0,preserveScrollPosition:!0,duration:C==="instant"?void 0:km})}else d.isNearBottom&&(u(!1),c(!0));k=v,requestAnimationFrame(()=>{setTimeout(()=>{d.resizeDifference===w&&(d.resizeDifference=0)},1)})}),d.resizeObserver?.observe(b)},[]);return{contentRef:y,scrollRef:x,scrollToBottom:f,stopScroll:h,isAtBottom:r||o,isNearBottom:o,escapedFromLock:e,state:d}};function la(n,e){const t=E.useCallback(r=>(t.current=r,n(r)),e);return t}const yo=new Map;function bo(...n){const e={...xm};let t=!1;for(const s of n){if(s==="instant"){t=!0;continue}typeof s=="object"&&(t=!1,e.damping=s.damping??e.damping,e.stiffness=s.stiffness??e.stiffness,e.mass=s.mass??e.mass)}const r=JSON.stringify(e);return yo.has(r)||yo.set(r,Object.freeze(e)),t?"instant":yo.get(r)}function vm(n){return n.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function Yi(n){if(n&&typeof n=="object"&&"gatewayClientId"in n&&typeof n.gatewayClientId=="string")return n.gatewayClientId}function Qi(n,e){if(!e)return n;const t=`${vm(e)}_`;return n.startsWith(t)?n.slice(t.length):n}function wm(n,e){return Qi(n,e).replace(/[_-]/g," ").toLowerCase()}function Cm(n){const e={};for(const t of n?.arguments??[])e[t.name]=t.required?ra().min(1,"Required"):ra();return Jh(e)}function Tm(n,e){const t={};for(const r of n.arguments??[])t[r.name]=e?.[r.name]??"";return t}function Nm(n){const e=_.c(67),{prompt:t,setPrompt:r,onSubmit:s,defaultValues:o}=n,i=E.useId();let l,a;if(e[0]!==t){const L=Cm(t);a=Gh,l=Kh(L),e[0]=t,e[1]=l,e[2]=a}else l=e[1],a=e[2];let c;e[3]!==o||e[4]!==t?(c=t?Tm(t,o):{},e[3]=o,e[4]=t,e[5]=c):c=e[5];let u;e[6]!==l||e[7]!==c?(u={resolver:l,defaultValues:c,mode:"onChange"},e[6]=l,e[7]=c,e[8]=u):u=e[8];const d=a(u);let f;e[9]!==t?.arguments?(f=t?.arguments??[],e[9]=t?.arguments,e[10]=f):f=e[10];const h=f;let m;e[11]!==d||e[12]!==s||e[13]!==r?(m=async L=>{await s(L),r(null),d.reset()},e[11]=d,e[12]=s,e[13]=r,e[14]=m):m=e[14];const g=m;let x;e[15]!==d||e[16]!==r?(x=L=>{L||(d.reset(),r(null))},e[15]=d,e[16]=r,e[17]=x):x=e[17];const y=x;if(!t)return null;let b;e[18]!==t._meta||e[19]!==t.name||e[20]!==t.title?(b=t.title||wm(t.name,Yi(t._meta)),e[18]=t._meta,e[19]=t.name,e[20]=t.title,e[21]=b):b=e[21];let k;e[22]!==b?(k=p.jsx(rm,{children:p.jsx("span",{className:"capitalize",children:b})}),e[22]=b,e[23]=k):k=e[23];let S;e[24]!==t.description?(S=t.description&&p.jsx("p",{className:"text-sm text-muted-foreground",children:t.description}),e[24]=t.description,e[25]=S):S=e[25];let v;e[26]!==S||e[27]!==k?(v=p.jsxs(sm,{children:[k,S]}),e[26]=S,e[27]=k,e[28]=v):v=e[28];let w;e[29]!==d||e[30]!==g?(w=L=>{L.stopPropagation(),d.handleSubmit(g)(L)},e[29]=d,e[30]=g,e[31]=w):w=e[31];let C;if(e[32]!==h||e[33]!==d.control||e[34]!==d.formState.isSubmitting){let L;e[36]!==d.control||e[37]!==d.formState.isSubmitting?(L=z=>p.jsx(cm,{control:d.control,name:z.name,render:F=>{const{field:U}=F;return p.jsxs(um,{children:[p.jsxs(dm,{className:"text-xs",children:[z.name,z.required?null:p.jsxs("span",{className:"text-muted-foreground font-normal",children:[" ","(optional)"]})]}),p.jsx(fm,{children:p.jsx(pm,{...U,value:U.value??"",required:z.required,placeholder:z.description??"",className:"h-9",disabled:d.formState.isSubmitting})}),p.jsx(hm,{})]})}},z.name),e[36]=d.control,e[37]=d.formState.isSubmitting,e[38]=L):L=e[38],C=h.map(L),e[32]=h,e[33]=d.control,e[34]=d.formState.isSubmitting,e[35]=C}else C=e[35];let T;e[39]!==y?(T=()=>y(!1),e[39]=y,e[40]=T):T=e[40];let N;e[41]!==d.formState.isSubmitting||e[42]!==T?(N=p.jsx(un,{type:"button",variant:"ghost",onClick:T,disabled:d.formState.isSubmitting,children:"Cancel"}),e[41]=d.formState.isSubmitting,e[42]=T,e[43]=N):N=e[43];let M;e[44]!==d.formState.isSubmitting?(M=d.formState.isSubmitting?p.jsxs("span",{className:"flex items-center gap-2",children:[p.jsx(Rp,{size:"xs"}),"Loading..."]}):"Use prompt",e[44]=d.formState.isSubmitting,e[45]=M):M=e[45];let j;e[46]!==d.formState.isSubmitting||e[47]!==i||e[48]!==M?(j=p.jsx(un,{type:"submit",form:i,disabled:d.formState.isSubmitting,children:M}),e[46]=d.formState.isSubmitting,e[47]=i,e[48]=M,e[49]=j):j=e[49];let R;e[50]!==N||e[51]!==j?(R=p.jsxs(om,{children:[N,j]}),e[50]=N,e[51]=j,e[52]=R):R=e[52];let A;e[53]!==i||e[54]!==w||e[55]!==C||e[56]!==R?(A=p.jsxs("form",{id:i,className:"space-y-4 py-4",autoComplete:"off",onSubmit:w,children:[C,R]}),e[53]=i,e[54]=w,e[55]=C,e[56]=R,e[57]=A):A=e[57];let D;e[58]!==d||e[59]!==A?(D=p.jsx(am,{...d,children:A}),e[58]=d,e[59]=A,e[60]=D):D=e[60];let I;e[61]!==v||e[62]!==D?(I=p.jsxs(im,{className:"sm:max-w-lg max-h-[80vh] overflow-y-auto",children:[v,D]}),e[61]=v,e[62]=D,e[63]=I):I=e[63];let $;return e[64]!==y||e[65]!==I?($=p.jsx(lm,{open:!0,onOpenChange:y,children:I}),e[64]=y,e[65]=I,e[66]=$):$=e[66],$}function Cu(n){return n?n.replace(/[_-]/g," ").toLowerCase().split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "):""}function ot(n,e){return n==="output-error"||n==="output-denied"?"error":n==="approval-requested"?"approval":n==="input-streaming"||n==="input-available"||n==="output-available"&&e===!0?"loading":"idle"}function Un(n){if(n==null||typeof n!="object")return;const e=n;if(e.structuredContent&&typeof e.structuredContent=="object")return e.structuredContent;if(Array.isArray(e.content)){const t=e.content[0];if(t?.type==="text"&&typeof t.text=="string")try{return JSON.parse(t.text)}catch{return}return}return n}function Ne(n){this.content=n}Ne.prototype={constructor:Ne,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var r=t&&t!=n?this.remove(t):this,s=r.find(n),o=r.content.slice();return s==-1?o.push(t||n,e):(o[s+1]=e,t&&(o[s]=t)),new Ne(o)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new Ne(t)},addToStart:function(n,e){return new Ne([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new Ne(t)},addBefore:function(n,e,t){var r=this.remove(e),s=r.content.slice(),o=r.find(n);return s.splice(o==-1?s.length:o,0,e,t),new Ne(s)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=Ne.from(n),n.size?new Ne(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=Ne.from(n),n.size?new Ne(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=Ne.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}};Ne.from=function(n){if(n instanceof Ne)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new Ne(e)};function Tu(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let s=n.child(r),o=e.child(r);if(s==o){t+=s.nodeSize;continue}if(!s.sameMarkup(o))return t;if(s.isText&&s.text!=o.text){for(let i=0;s.text[i]==o.text[i];i++)t++;return t}if(s.content.size||o.content.size){let i=Tu(s.content,o.content,t+1);if(i!=null)return i}t+=s.nodeSize}}function Nu(n,e,t,r){for(let s=n.childCount,o=e.childCount;;){if(s==0||o==0)return s==o?null:{a:t,b:r};let i=n.child(--s),l=e.child(--o),a=i.nodeSize;if(i==l){t-=a,r-=a;continue}if(!i.sameMarkup(l))return{a:t,b:r};if(i.isText&&i.text!=l.text){let c=0,u=Math.min(i.text.length,l.text.length);for(;c<u&&i.text[i.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,r--;return{a:t,b:r}}if(i.content.size||l.content.size){let c=Nu(i.content,l.content,t-1,r-1);if(c)return c}t-=a,r-=a}}class O{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,s=0,o){for(let i=0,l=0;l<t;i++){let a=this.content[i],c=l+a.nodeSize;if(c>e&&r(a,s+l,o||null,i)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,t-u),r,s+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,s){let o="",i=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?s?typeof s=="function"?s(l):s:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(i?i=!1:o+=r),o+=c},0),o}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,s=this.content.slice(),o=0;for(t.isText&&t.sameMarkup(r)&&(s[s.length-1]=t.withText(t.text+r.text),o=1);o<e.content.length;o++)s.push(e.content[o]);return new O(s,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],s=0;if(t>e)for(let o=0,i=0;i<t;o++){let l=this.content[o],a=i+l.nodeSize;a>e&&((i<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-i),Math.min(l.text.length,t-i)):l=l.cut(Math.max(0,e-i-1),Math.min(l.content.size,t-i-1))),r.push(l),s+=l.nodeSize),i=a}return new O(r,s)}cutByIndex(e,t){return e==t?O.empty:e==0&&t==this.content.length?this:new O(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let s=this.content.slice(),o=this.size+t.nodeSize-r.nodeSize;return s[e]=t,new O(s,o)}addToStart(e){return new O([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new O(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let s=this.content[t];e(s,r,t),r+=s.nodeSize}}findDiffStart(e,t=0){return Tu(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return Nu(this,e,t,r)}findIndex(e){if(e==0)return Dr(0,e);if(e==this.size)return Dr(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,r=0;;t++){let s=this.child(t),o=r+s.nodeSize;if(o>=e)return o==e?Dr(t+1,o):Dr(t,r);r=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return O.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new O(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return O.empty;let t,r=0;for(let s=0;s<e.length;s++){let o=e[s];r+=o.nodeSize,s&&o.isText&&e[s-1].sameMarkup(o)?(t||(t=e.slice(0,s)),t[t.length-1]=o.withText(t[t.length-1].text+o.text)):t&&t.push(o)}return new O(t||e,r)}static from(e){if(!e)return O.empty;if(e instanceof O)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new O([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}O.empty=new O([],0);const ko={index:0,offset:0};function Dr(n,e){return ko.index=n,ko.offset=e,ko}function ts(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!ts(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!ts(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}let le=class ei{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let s=0;s<e.length;s++){let o=e[s];if(this.eq(o))return e;if(this.type.excludes(o.type))t||(t=e.slice(0,s));else{if(o.type.excludes(this.type))return e;!r&&o.type.rank>this.type.rank&&(t||(t=e.slice(0,s)),t.push(this),r=!0),t&&t.push(o)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&ts(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);let s=r.create(t.attrs);return r.checkAttrs(s.attrs),s}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return ei.none;if(e instanceof ei)return[e];let t=e.slice();return t.sort((r,s)=>r.type.rank-s.type.rank),t}};le.none=[];class ns extends Error{}class B{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=Eu(this.content,e+this.openStart,t);return r&&new B(r,this.openStart,this.openEnd)}removeBetween(e,t){return new B(Mu(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return B.empty;let r=t.openStart||0,s=t.openEnd||0;if(typeof r!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new B(O.fromJSON(e,t.content),r,s)}static maxOpen(e,t=!0){let r=0,s=0;for(let o=e.firstChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.firstChild)r++;for(let o=e.lastChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.lastChild)s++;return new B(e,r,s)}}B.empty=new B(O.empty,0,0);function Mu(n,e,t){let{index:r,offset:s}=n.findIndex(e),o=n.maybeChild(r),{index:i,offset:l}=n.findIndex(t);if(s==e||o.isText){if(l!=t&&!n.child(i).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=i)throw new RangeError("Removing non-flat range");return n.replaceChild(r,o.copy(Mu(o.content,e-s-1,t-s-1)))}function Eu(n,e,t,r){let{index:s,offset:o}=n.findIndex(e),i=n.maybeChild(s);if(o==e||i.isText)return r&&!r.canReplace(s,s,t)?null:n.cut(0,e).append(t).append(n.cut(e));let l=Eu(i.content,e-o-1,t,i);return l&&n.replaceChild(s,i.copy(l))}function Mm(n,e,t){if(t.openStart>n.depth)throw new ns("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new ns("Inconsistent open depths");return Au(n,e,t,0)}function Au(n,e,t,r){let s=n.index(r),o=n.node(r);if(s==e.index(r)&&r<n.depth-t.openStart){let i=Au(n,e,t,r+1);return o.copy(o.content.replaceChild(s,i))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let i=n.parent,l=i.content;return on(i,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:i,end:l}=Em(t,n);return on(o,Iu(n,i,l,e,r))}else return on(o,rs(n,e,r))}function ju(n,e){if(!e.type.compatibleContent(n.type))throw new ns("Cannot join "+e.type.name+" onto "+n.type.name)}function ti(n,e,t){let r=n.node(t);return ju(r,e.node(t)),r}function sn(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function rr(n,e,t,r){let s=(e||n).node(t),o=0,i=e?e.index(t):s.childCount;n&&(o=n.index(t),n.depth>t?o++:n.textOffset&&(sn(n.nodeAfter,r),o++));for(let l=o;l<i;l++)sn(s.child(l),r);e&&e.depth==t&&e.textOffset&&sn(e.nodeBefore,r)}function on(n,e){return n.type.checkContent(e),n.copy(e)}function Iu(n,e,t,r,s){let o=n.depth>s&&ti(n,e,s+1),i=r.depth>s&&ti(t,r,s+1),l=[];return rr(null,n,s,l),o&&i&&e.index(s)==t.index(s)?(ju(o,i),sn(on(o,Iu(n,e,t,r,s+1)),l)):(o&&sn(on(o,rs(n,e,s+1)),l),rr(e,t,s,l),i&&sn(on(i,rs(t,r,s+1)),l)),rr(r,null,s,l),new O(l)}function rs(n,e,t){let r=[];if(rr(null,n,t,r),n.depth>t){let s=ti(n,e,t+1);sn(on(s,rs(n,e,t+1)),r)}return rr(e,null,t,r),new O(r)}function Em(n,e){let t=e.depth-n.openStart,s=e.node(t).copy(n.content);for(let o=t-1;o>=0;o--)s=e.node(o).copy(O.from(s));return{start:s.resolveNoCache(n.openStart+t),end:s.resolveNoCache(s.content.size-n.openEnd-t)}}class pr{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],s=e.child(t);return r?e.child(t).cut(r):s}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],s=t==0?0:this.path[t*3-1]+1;for(let o=0;o<e;o++)s+=r.child(o).nodeSize;return s}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return le.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),s=e.maybeChild(t);if(!r){let l=r;r=s,s=l}let o=r.marks;for(var i=0;i<o.length;i++)o[i].type.spec.inclusive===!1&&(!s||!o[i].isInSet(s.marks))&&(o=o[i--].removeFromSet(o));return o}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.marks,s=e.parent.maybeChild(e.index());for(var o=0;o<r.length;o++)r[o].type.spec.inclusive===!1&&(!s||!r[o].isInSet(s.marks))&&(r=r[o--].removeFromSet(r));return r}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new ss(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],s=0,o=t;for(let i=e;;){let{index:l,offset:a}=i.content.findIndex(o),c=o-a;if(r.push(i,l,s+a),!c||(i=i.child(l),i.isText))break;o=c-1,s+=a+1}return new pr(t,r,o)}static resolveCached(e,t){let r=aa.get(e);if(r)for(let o=0;o<r.elts.length;o++){let i=r.elts[o];if(i.pos==t)return i}else aa.set(e,r=new Am);let s=r.elts[r.i]=pr.resolve(e,t);return r.i=(r.i+1)%jm,s}}class Am{constructor(){this.elts=[],this.i=0}}const jm=12,aa=new WeakMap;class ss{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const Im=Object.create(null);class st{constructor(e,t,r,s=le.none){this.type=e,this.attrs=t,this.marks=s,this.content=r||O.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,r,s=0){this.content.nodesBetween(e,t,r,s,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,r,s){return this.content.textBetween(e,t,r,s)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,r){return this.type==e&&ts(this.attrs,t||e.defaultAttrs||Im)&&le.sameSet(this.marks,r||le.none)}copy(e=null){return e==this.content?this:new st(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new st(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,r=!1){if(e==t)return B.empty;let s=this.resolve(e),o=this.resolve(t),i=r?0:s.sharedDepth(t),l=s.start(i),c=s.node(i).content.cut(s.pos-l,o.pos-l);return new B(c,s.depth-i,o.depth-i)}replace(e,t,r){return Mm(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:s}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(s==e||t.isText)return t;e-=s+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let s=this.content.child(t-1);return{node:s,index:t-1,offset:r-s.nodeSize}}resolve(e){return pr.resolveCached(this,e)}resolveNoCache(e){return pr.resolve(this,e)}rangeHasMark(e,t,r){let s=!1;return t>e&&this.nodesBetween(e,t,o=>(r.isInSet(o.marks)&&(s=!0),!s)),s}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Ou(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=O.empty,s=0,o=r.childCount){let i=this.contentMatchAt(e).matchFragment(r,s,o),l=i&&i.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=s;a<o;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,t,r,s){if(s&&!this.type.allowsMarks(s))return!1;let o=this.contentMatchAt(e).matchType(r),i=o&&o.matchFragment(this.content,t);return i?i.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=le.none;for(let t=0;t<this.marks.length;t++){let r=this.marks[t];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!le.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let s=O.fromJSON(e,t.content),o=e.nodeType(t.type).create(t.attrs,s,r);return o.type.checkAttrs(o.attrs),o}}st.prototype.text=void 0;class is extends st{constructor(e,t,r,s){if(super(e,t,null,s),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Ou(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new is(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new is(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function Ou(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class mn{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new Om(e,t);if(r.next==null)return mn.empty;let s=Ru(r);r.next&&r.err("Unexpected trailing text");let o=zm($m(s));return Bm(o,r),o}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,r=e.childCount){let s=this;for(let o=t;s&&o<r;o++)s=s.matchType(e.child(o).type);return s}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let s=[this];function o(i,l){let a=i.matchFragment(e,r);if(a&&(!t||a.validEnd))return O.from(l.map(c=>c.createAndFill()));for(let c=0;c<i.next.length;c++){let{type:u,next:d}=i.next[c];if(!(u.isText||u.hasRequiredAttrs())&&s.indexOf(d)==-1){s.push(d);let f=o(d,l.concat(u));if(f)return f}}return null}return o(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let s=r.shift(),o=s.match;if(o.matchType(e)){let i=[];for(let l=s;l.type;l=l.via)i.push(l.type);return i.reverse()}for(let i=0;i<o.next.length;i++){let{type:l,next:a}=o.next[i];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!s.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:s}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let s=0;s<r.next.length;s++)e.indexOf(r.next[s].next)==-1&&t(r.next[s].next)}return t(this),e.map((r,s)=>{let o=s+(r.validEnd?"*":" ")+" ";for(let i=0;i<r.next.length;i++)o+=(i?", ":"")+r.next[i].type.name+"->"+e.indexOf(r.next[i].next);return o}).join(`
2
+ `)}}mn.empty=new mn(!0);class Om{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function Ru(n){let e=[];do e.push(Rm(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Rm(n){let e=[];do e.push(Dm(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Dm(n){let e=_m(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=Pm(n,e);else break;return e}function ca(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function Pm(n,e){let t=ca(n),r=t;return n.eat(",")&&(n.next!="}"?r=ca(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function Lm(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let s=[];for(let o in t){let i=t[o];i.isInGroup(e)&&s.push(i)}return s.length==0&&n.err("No node type or group '"+e+"' found"),s}function _m(n){if(n.eat("(")){let e=Ru(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=Lm(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function $m(n){let e=[[]];return s(o(n,0),t()),e;function t(){return e.push([])-1}function r(i,l,a){let c={term:a,to:l};return e[i].push(c),c}function s(i,l){i.forEach(a=>a.to=l)}function o(i,l){if(i.type=="choice")return i.exprs.reduce((a,c)=>a.concat(o(c,l)),[]);if(i.type=="seq")for(let a=0;;a++){let c=o(i.exprs[a],l);if(a==i.exprs.length-1)return c;s(c,l=t())}else if(i.type=="star"){let a=t();return r(l,a),s(o(i.expr,a),a),[r(a)]}else if(i.type=="plus"){let a=t();return s(o(i.expr,l),a),s(o(i.expr,a),a),[r(a)]}else{if(i.type=="opt")return[r(l)].concat(o(i.expr,l));if(i.type=="range"){let a=l;for(let c=0;c<i.min;c++){let u=t();s(o(i.expr,a),u),a=u}if(i.max==-1)s(o(i.expr,a),a);else for(let c=i.min;c<i.max;c++){let u=t();r(a,u),s(o(i.expr,a),u),a=u}return[r(a)]}else{if(i.type=="name")return[r(l,void 0,i.value)];throw new Error("Unknown expr type")}}}}function Du(n,e){return e-n}function ua(n,e){let t=[];return r(e),t.sort(Du);function r(s){let o=n[s];if(o.length==1&&!o[0].term)return r(o[0].to);t.push(s);for(let i=0;i<o.length;i++){let{term:l,to:a}=o[i];!l&&t.indexOf(a)==-1&&r(a)}}}function zm(n){let e=Object.create(null);return t(ua(n,0));function t(r){let s=[];r.forEach(i=>{n[i].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let u=0;u<s.length;u++)s[u][0]==l&&(c=s[u][1]);ua(n,a).forEach(u=>{c||s.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let o=e[r.join(",")]=new mn(r.indexOf(n.length-1)>-1);for(let i=0;i<s.length;i++){let l=s[i][1].sort(Du);o.next.push({type:s[i][0],next:e[l.join(",")]||t(l)})}return o}}function Bm(n,e){for(let t=0,r=[n];t<r.length;t++){let s=r[t],o=!s.validEnd,i=[];for(let l=0;l<s.next.length;l++){let{type:a,next:c}=s.next[l];i.push(a.name),o&&!(a.isText||a.hasRequiredAttrs())&&(o=!1),r.indexOf(c)==-1&&r.push(c)}o&&e.err("Only non-generatable nodes ("+i.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Pu(n){let e=Object.create(null);for(let t in n){let r=n[t];if(!r.hasDefault)return null;e[t]=r.default}return e}function Lu(n,e){let t=Object.create(null);for(let r in n){let s=e&&e[r];if(s===void 0){let o=n[r];if(o.hasDefault)s=o.default;else throw new RangeError("No value supplied for attribute "+r)}t[r]=s}return t}function _u(n,e,t,r){for(let s in e)if(!(s in n))throw new RangeError(`Unsupported attribute ${s} for ${t} of type ${s}`);for(let s in n){let o=n[s];o.validate&&o.validate(e[s])}}function $u(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new Hm(n,r,e[r]);return t}let da=class zu{constructor(e,t,r){this.name=e,this.schema=t,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=$u(e,r.attrs),this.defaultAttrs=Pu(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==mn.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:Lu(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new st(this,this.computeAttrs(e),O.from(t),le.setFrom(r))}createChecked(e=null,t,r){return t=O.from(t),this.checkContent(t),new st(this,this.computeAttrs(e),t,le.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=O.from(t),t.size){let i=this.contentMatch.fillBefore(t);if(!i)return null;t=i.append(t)}let s=this.contentMatch.matchFragment(t),o=s&&s.fillBefore(O.empty,!0);return o?new st(this,e,t.append(o),le.setFrom(r)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){_u(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?t&&t.push(e[r]):t||(t=e.slice(0,r));return t?t.length?t:le.none:e}static compile(e,t){let r=Object.create(null);e.forEach((o,i)=>r[o]=new zu(o,t,i));let s=t.spec.topNode||"doc";if(!r[s])throw new RangeError("Schema is missing its top node type ('"+s+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let o in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function Fm(n,e,t){let r=t.split("|");return s=>{let o=s===null?"null":typeof s;if(r.indexOf(o)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${o}`)}}class Hm{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?Fm(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class Xs{constructor(e,t,r,s){this.name=e,this.rank=t,this.schema=r,this.spec=s,this.attrs=$u(e,s.attrs),this.excluded=null;let o=Pu(this.attrs);this.instance=o?new le(this,o):null}create(e=null){return!e&&this.instance?this.instance:new le(this,Lu(this.attrs,e))}static compile(e,t){let r=Object.create(null),s=0;return e.forEach((o,i)=>r[o]=new Xs(o,s++,t,i)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){_u(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Bu{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let s in e)t[s]=e[s];t.nodes=Ne.from(e.nodes),t.marks=Ne.from(e.marks||{}),this.nodes=da.compile(this.spec.nodes,this),this.marks=Xs.compile(this.spec.marks,this);let r=Object.create(null);for(let s in this.nodes){if(s in this.marks)throw new RangeError(s+" can not be both a node and a mark");let o=this.nodes[s],i=o.spec.content||"",l=o.spec.marks;if(o.contentMatch=r[i]||(r[i]=mn.parse(i,this.nodes)),o.inlineContent=o.contentMatch.inlineContent,o.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!o.isInline||!o.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=o}o.markSet=l=="_"?null:l?fa(this,l.split(" ")):l==""||!o.inlineContent?[]:null}for(let s in this.marks){let o=this.marks[s],i=o.spec.excludes;o.excluded=i==null?[o]:i==""?[]:fa(this,i.split(" "))}this.nodeFromJSON=s=>st.fromJSON(this,s),this.markFromJSON=s=>le.fromJSON(this,s),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,s){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof da){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,r,s)}text(e,t){let r=this.nodes.text;return new is(r,r.defaultAttrs,e,le.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function fa(n,e){let t=[];for(let r=0;r<e.length;r++){let s=e[r],o=n.marks[s],i=o;if(o)t.push(o);else for(let l in n.marks){let a=n.marks[l];(s=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(s)>-1)&&t.push(i=a)}if(!i)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function Vm(n){return n.tag!=null}function Wm(n){return n.style!=null}class $t{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(s=>{if(Vm(s))this.tags.push(s);else if(Wm(s)){let o=/[^=]*/.exec(s.style)[0];r.indexOf(o)<0&&r.push(o),this.styles.push(s)}}),this.normalizeLists=!this.tags.some(s=>{if(!/^(ul|ol)\b/.test(s.tag)||!s.node)return!1;let o=e.nodes[s.node];return o.contentMatch.matchType(o)})}parse(e,t={}){let r=new pa(this,t,!1);return r.addAll(e,le.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new pa(this,t,!0);return r.addAll(e,le.none,t.from,t.to),B.maxOpen(r.finish())}matchTag(e,t,r){for(let s=r?this.tags.indexOf(r)+1:0;s<this.tags.length;s++){let o=this.tags[s];if(Km(e,o.tag)&&(o.namespace===void 0||e.namespaceURI==o.namespace)&&(!o.context||t.matchesContext(o.context))){if(o.getAttrs){let i=o.getAttrs(e);if(i===!1)continue;o.attrs=i||void 0}return o}}}matchStyle(e,t,r,s){for(let o=s?this.styles.indexOf(s)+1:0;o<this.styles.length;o++){let i=this.styles[o],l=i.style;if(!(l.indexOf(e)!=0||i.context&&!r.matchesContext(i.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(i.getAttrs){let a=i.getAttrs(t);if(a===!1)continue;i.attrs=a||void 0}return i}}}static schemaRules(e){let t=[];function r(s){let o=s.priority==null?50:s.priority,i=0;for(;i<t.length;i++){let l=t[i];if((l.priority==null?50:l.priority)<o)break}t.splice(i,0,s)}for(let s in e.marks){let o=e.marks[s].spec.parseDOM;o&&o.forEach(i=>{r(i=ma(i)),i.mark||i.ignore||i.clearMark||(i.mark=s)})}for(let s in e.nodes){let o=e.nodes[s].spec.parseDOM;o&&o.forEach(i=>{r(i=ma(i)),i.node||i.ignore||i.mark||(i.node=s)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new $t(e,$t.schemaRules(e)))}}const Fu={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},Um={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Hu={ol:!0,ul:!0},mr=1,ni=2,sr=4;function ha(n,e,t){return e!=null?(e?mr:0)|(e==="full"?ni:0):n&&n.whitespace=="pre"?mr|ni:t&~sr}class Pr{constructor(e,t,r,s,o,i){this.type=e,this.attrs=t,this.marks=r,this.solid=s,this.options=i,this.content=[],this.activeMarks=le.none,this.match=o||(i&sr?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(O.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,s;return(s=r.findWrapping(e.type))?(this.match=r,s):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&mr)){let r=this.content[this.content.length-1],s;if(r&&r.isText&&(s=/[ \t\r\n\u000c]+$/.exec(r.text))){let o=r;r.text.length==s[0].length?this.content.pop():this.content[this.content.length-1]=o.withText(o.text.slice(0,o.text.length-s[0].length))}}let t=O.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(O.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Fu.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class pa{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let s=t.topNode,o,i=ha(null,t.preserveWhitespace,0)|(r?sr:0);s?o=new Pr(s.type,s.attrs,le.none,!0,t.topMatch||s.type.contentMatch,i):r?o=new Pr(null,null,le.none,!0,null,i):o=new Pr(e.schema.topNodeType,null,le.none,!0,null,i),this.nodes=[o],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let r=e.nodeValue,s=this.top,o=s.options&ni?"full":this.localPreserveWS||(s.options&mr)>0,{schema:i}=this.parser;if(o==="full"||s.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(o)if(o==="full")r=r.replace(/\r\n?/g,`
3
+ `);else if(i.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(i.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let a=0;a<l.length;a++)a&&this.insertNode(i.linebreakReplacement.create(),t,!0),l[a]&&this.insertNode(i.text(l[a]),t,!/\S/.test(l[a]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let l=s.content[s.content.length-1],a=e.previousSibling;(!l||a&&a.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(r=r.slice(1))}r&&this.insertNode(i.text(r),t,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,t,r){let s=this.localPreserveWS,o=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let i=e.nodeName.toLowerCase(),l;Hu.hasOwnProperty(i)&&this.parser.normalizeLists&&qm(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:Um.hasOwnProperty(i))this.findInside(e),this.ignoreFallback(e,t);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let c,u=this.needsBlock;if(Fu.hasOwnProperty(i))o.content.length&&o.content[0].isInline&&this.open&&(this.open--,o=this.top),c=!0,o.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let d=a&&a.skip?t:this.readStyles(e,t);d&&this.addAll(e,d),c&&this.sync(o),this.needsBlock=u}else{let c=this.readStyles(e,t);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=s}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
4
+ `),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let r=e.style;if(r&&r.length)for(let s=0;s<this.parser.matchedStyles.length;s++){let o=this.parser.matchedStyles[s],i=r.getPropertyValue(o);if(i)for(let l=void 0;;){let a=this.parser.matchStyle(o,i,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?t=t.filter(c=>!a.clearMark(c)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,r,s){let o,i;if(t.node)if(i=this.parser.schema.nodes[t.node],i.isLeaf)this.insertNode(i.create(t.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(i,t.attrs||null,r,t.preserveWhitespace);a&&(o=!0,r=a)}else{let a=this.parser.schema.marks[t.mark];r=r.concat(a.create(t.attrs))}let l=this.top;if(i&&i.isLeaf)this.findInside(e);else if(s)this.addElement(e,r,s);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}o&&this.sync(l)&&this.open--}addAll(e,t,r,s){let o=r||0;for(let i=r?e.childNodes[r]:e.firstChild,l=s==null?null:e.childNodes[s];i!=l;i=i.nextSibling,++o)this.findAtPoint(e,o),this.addDOM(i,t);this.findAtPoint(e,o)}findPlace(e,t,r){let s,o;for(let i=this.open,l=0;i>=0;i--){let a=this.nodes[i],c=a.findWrapping(e);if(c&&(!s||s.length>c.length+l)&&(s=c,o=a,!c.length))break;if(a.solid){if(r)break;l+=2}}if(!s)return null;this.sync(o);for(let i=0;i<s.length;i++)t=this.enterInner(s[i],null,t,!1);return t}insertNode(e,t,r){if(e.isInline&&this.needsBlock&&!this.top.type){let o=this.textblockFromContext();o&&(t=this.enterInner(o,null,t))}let s=this.findPlace(e,t,r);if(s){this.closeExtra();let o=this.top;o.match&&(o.match=o.match.matchType(e.type));let i=le.none;for(let l of s.concat(e.marks))(o.type?o.type.allowsMarkType(l.type):ga(l.type,e.type))&&(i=l.addToSet(i));return o.content.push(e.mark(i)),!0}return!1}enter(e,t,r,s){let o=this.findPlace(e.create(t),r,!1);return o&&(o=this.enterInner(e,t,r,!0,s)),o}enterInner(e,t,r,s=!1,o){this.closeExtra();let i=this.top;i.match=i.match&&i.match.matchType(e);let l=ha(e,o,i.options);i.options&sr&&i.content.length==0&&(l|=sr);let a=le.none;return r=r.filter(c=>(i.type?i.type.allowsMarkType(c.type):ga(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new Pr(e,t,a,s,null,l)),this.open++,r}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=mr)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let s=r.length-1;s>=0;s--)e+=r[s].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==t&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,r){if(e!=t&&this.find)for(let s=0;s<this.find.length;s++)this.find[s].pos==null&&e.nodeType==1&&e.contains(this.find[s].node)&&t.compareDocumentPosition(this.find[s].node)&(r?2:4)&&(this.find[s].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),r=this.options.context,s=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),o=-(r?r.depth+1:0)+(s?0:1),i=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=o;a--)if(i(l-1,a))return!0;return!1}else{let u=a>0||a==0&&s?this.nodes[a].type:r&&a>=o?r.node(a-o).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;a--}}return!0};return i(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}}function qm(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Hu.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function Km(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function ma(n){let e={};for(let t in n)e[t]=n[t];return e}function ga(n,e){let t=e.schema.nodes;for(let r in t){let s=t[r];if(!s.allowsMarkType(n))continue;let o=[],i=l=>{o.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:u}=l.edge(a);if(c==e||o.indexOf(u)<0&&i(u))return!0}};if(i(s.contentMatch))return!0}}class Sn{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=So(t).createDocumentFragment());let s=r,o=[];return e.forEach(i=>{if(o.length||i.marks.length){let l=0,a=0;for(;l<o.length&&a<i.marks.length;){let c=i.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(o[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<o.length;)s=o.pop()[1];for(;a<i.marks.length;){let c=i.marks[a++],u=this.serializeMark(c,i.isInline,t);u&&(o.push([c,s]),s.appendChild(u.dom),s=u.contentDOM||u.dom)}}s.appendChild(this.serializeNodeInner(i,t))}),r}serializeNodeInner(e,t){let{dom:r,contentDOM:s}=Jr(So(t),this.nodes[e.type.name](e),null,e.attrs);if(s){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,s)}return r}serializeNode(e,t={}){let r=this.serializeNodeInner(e,t);for(let s=e.marks.length-1;s>=0;s--){let o=this.serializeMark(e.marks[s],e.isInline,t);o&&((o.contentDOM||o.dom).appendChild(r),r=o.dom)}return r}serializeMark(e,t,r={}){let s=this.marks[e.type.name];return s&&Jr(So(r),s(e,t),null,e.attrs)}static renderSpec(e,t,r=null,s){return Jr(e,t,r,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Sn(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=xa(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return xa(e.marks)}}function xa(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function So(n){return n.document||window.document}const ya=new WeakMap;function Jm(n){let e=ya.get(n);return e===void 0&&ya.set(n,e=Gm(n)),e}function Gm(n){let e=null;function t(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let s=0;s<r.length;s++)t(r[s]);else for(let s in r)t(r[s])}return t(n),e}function Jr(n,e,t,r){if(typeof e=="string")return{dom:n.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let s=e[0],o;if(typeof s!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(o=Jm(r))&&o.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let i=s.indexOf(" ");i>0&&(t=s.slice(0,i),s=s.slice(i+1));let l,a=t?n.createElementNS(t,s):n.createElement(s),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let d in c)if(c[d]!=null){let f=d.indexOf(" ");f>0?a.setAttributeNS(d.slice(0,f),d.slice(f+1),c[d]):d=="style"&&a.style?a.style.cssText=c[d]:a.setAttribute(d,c[d])}}for(let d=u;d<e.length;d++){let f=e[d];if(f===0){if(d<e.length-1||d>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:h,contentDOM:m}=Jr(n,f,t,r);if(a.appendChild(h),m){if(l)throw new RangeError("Multiple content holes");l=m}}}return{dom:a,contentDOM:l}}const Vu=65535,Wu=Math.pow(2,16);function Xm(n,e){return n+e*Wu}function ba(n){return n&Vu}function Ym(n){return(n-(n&Vu))/Wu}const Uu=1,qu=2,Gr=4,Ku=8;class ri{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&Ku)>0}get deletedBefore(){return(this.delInfo&(Uu|Gr))>0}get deletedAfter(){return(this.delInfo&(qu|Gr))>0}get deletedAcross(){return(this.delInfo&Gr)>0}}class We{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&We.empty)return We.empty}recover(e){let t=0,r=ba(e);if(!this.inverted)for(let s=0;s<r;s++)t+=this.ranges[s*3+2]-this.ranges[s*3+1];return this.ranges[r*3]+t+Ym(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let s=0,o=this.inverted?2:1,i=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?s:0);if(a>e)break;let c=this.ranges[l+o],u=this.ranges[l+i],d=a+c;if(e<=d){let f=c?e==a?-1:e==d?1:t:t,h=a+s+(f<0?0:u);if(r)return h;let m=e==(t<0?a:d)?null:Xm(l/3,e-a),g=e==a?qu:e==d?Uu:Gr;return(t<0?e!=a:e!=d)&&(g|=Ku),new ri(h,g,m)}s+=u-c}return r?e+s:new ri(e+s,0,null)}touches(e,t){let r=0,s=ba(t),o=this.inverted?2:1,i=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+o],u=a+c;if(e<=u&&l==s*3)return!0;r+=this.ranges[l+i]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let s=0,o=0;s<this.ranges.length;s+=3){let i=this.ranges[s],l=i-(this.inverted?o:0),a=i+(this.inverted?0:o),c=this.ranges[s+t],u=this.ranges[s+r];e(l,l+c,a,a+u),o+=u-c}}invert(){return new We(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?We.empty:new We(e<0?[0,-e,0]:[0,0,e])}}We.empty=new We([]);class gr{constructor(e,t,r=0,s=e?e.length:0){this.mirror=t,this.from=r,this.to=s,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new gr(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,r=this._maps.length;t<e._maps.length;t++){let s=e.getMirror(t);this.appendMap(e._maps[t],s!=null&&s<t?r+s:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,r=this._maps.length+e._maps.length;t>=0;t--){let s=e.getMirror(t);this.appendMap(e._maps[t].invert(),s!=null&&s>t?r-s-1:void 0)}}invert(){let e=new gr;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,r){let s=0;for(let o=this.from;o<this.to;o++){let i=this._maps[o],l=i.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(o);if(a!=null&&a>o&&a<this.to){o=a,e=this._maps[a].recover(l.recover);continue}}s|=l.delInfo,e=l.pos}return r?e:new ri(e,s,null)}}const vo=Object.create(null);class Re{getMap(){return We.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=vo[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in vo)throw new RangeError("Duplicate use of step JSON ID "+e);return vo[e]=t,t.prototype.jsonID=e,t}}class be{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new be(e,null)}static fail(e){return new be(null,e)}static fromReplace(e,t,r,s){try{return be.ok(e.replace(t,r,s))}catch(o){if(o instanceof ns)return be.fail(o.message);throw o}}}function Zi(n,e,t){let r=[];for(let s=0;s<n.childCount;s++){let o=n.child(s);o.content.size&&(o=o.copy(Zi(o.content,e,o))),o.isInline&&(o=e(o,t,s)),r.push(o)}return O.fromArray(r)}class Dt extends Re{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),s=r.node(r.sharedDepth(this.to)),o=new B(Zi(t.content,(i,l)=>!i.isAtom||!l.type.allowsMarkType(this.mark.type)?i:i.mark(this.mark.addToSet(i.marks)),s),t.openStart,t.openEnd);return be.fromReplace(e,this.from,this.to,o)}invert(){return new rt(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new Dt(t.pos,r.pos,this.mark)}merge(e){return e instanceof Dt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Dt(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Dt(t.from,t.to,e.markFromJSON(t.mark))}}Re.jsonID("addMark",Dt);class rt extends Re{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new B(Zi(t.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),t.openStart,t.openEnd);return be.fromReplace(e,this.from,this.to,r)}invert(){return new Dt(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new rt(t.pos,r.pos,this.mark)}merge(e){return e instanceof rt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new rt(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new rt(t.from,t.to,e.markFromJSON(t.mark))}}Re.jsonID("removeMark",rt);class Pt extends Re{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return be.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return be.fromReplace(e,this.pos,this.pos+1,new B(O.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let s=0;s<t.marks.length;s++)if(!t.marks[s].isInSet(r))return new Pt(this.pos,t.marks[s]);return new Pt(this.pos,this.mark)}}return new gn(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Pt(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Pt(t.pos,e.markFromJSON(t.mark))}}Re.jsonID("addNodeMark",Pt);class gn extends Re{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return be.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return be.fromReplace(e,this.pos,this.pos+1,new B(O.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Pt(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new gn(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new gn(t.pos,e.markFromJSON(t.mark))}}Re.jsonID("removeNodeMark",gn);class ye extends Re{constructor(e,t,r,s=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=s}apply(e){return this.structure&&si(e,this.from,this.to)?be.fail("Structure replace would overwrite content"):be.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new We([this.from,this.to-this.from,this.slice.size])}invert(e){return new ye(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.to,-1),r=this.from==this.to&&ye.MAP_BIAS<0?t:e.mapResult(this.from,1);return r.deletedAcross&&t.deletedAcross?null:new ye(r.pos,Math.max(r.pos,t.pos),this.slice,this.structure)}merge(e){if(!(e instanceof ye)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?B.empty:new B(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new ye(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?B.empty:new B(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new ye(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new ye(t.from,t.to,B.fromJSON(e,t.slice),!!t.structure)}}ye.MAP_BIAS=1;Re.jsonID("replace",ye);class we extends Re{constructor(e,t,r,s,o,i,l=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=s,this.slice=o,this.insert=i,this.structure=l}apply(e){if(this.structure&&(si(e,this.from,this.gapFrom)||si(e,this.gapTo,this.to)))return be.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return be.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?be.fromReplace(e,this.from,this.to,r):be.fail("Content does not fit in gap")}getMap(){return new We([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new we(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),s=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),o=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||s<t.pos||o>r.pos?null:new we(t.pos,r.pos,s,o,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new we(t.from,t.to,t.gapFrom,t.gapTo,B.fromJSON(e,t.slice),t.insert,!!t.structure)}}Re.jsonID("replaceAround",we);function si(n,e,t){let r=n.resolve(e),s=t-e,o=r.depth;for(;s>0&&o>0&&r.indexAfter(o)==r.node(o).childCount;)o--,s--;if(s>0){let i=r.node(o).maybeChild(r.indexAfter(o));for(;s>0;){if(!i||i.isLeaf)return!0;i=i.firstChild,s--}}return!1}function Qm(n,e,t,r){let s=[],o=[],i,l;n.doc.nodesBetween(e,t,(a,c,u)=>{if(!a.isInline)return;let d=a.marks;if(!r.isInSet(d)&&u.type.allowsMarkType(r.type)){let f=Math.max(c,e),h=Math.min(c+a.nodeSize,t),m=r.addToSet(d);for(let g=0;g<d.length;g++)d[g].isInSet(m)||(i&&i.to==f&&i.mark.eq(d[g])?i.to=h:s.push(i=new rt(f,h,d[g])));l&&l.to==f?l.to=h:o.push(l=new Dt(f,h,r))}}),s.forEach(a=>n.step(a)),o.forEach(a=>n.step(a))}function Zm(n,e,t,r){let s=[],o=0;n.doc.nodesBetween(e,t,(i,l)=>{if(!i.isInline)return;o++;let a=null;if(r instanceof Xs){let c=i.marks,u;for(;u=r.isInSet(c);)(a||(a=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(i.marks)&&(a=[r]):a=i.marks;if(a&&a.length){let c=Math.min(l+i.nodeSize,t);for(let u=0;u<a.length;u++){let d=a[u],f;for(let h=0;h<s.length;h++){let m=s[h];m.step==o-1&&d.eq(s[h].style)&&(f=m)}f?(f.to=c,f.step=o):s.push({style:d,from:Math.max(l,e),to:c,step:o})}}}),s.forEach(i=>n.step(new rt(i.from,i.to,i.style)))}function el(n,e,t,r=t.contentMatch,s=!0){let o=n.doc.nodeAt(e),i=[],l=e+1;for(let a=0;a<o.childCount;a++){let c=o.child(a),u=l+c.nodeSize,d=r.matchType(c.type);if(!d)i.push(new ye(l,u,B.empty));else{r=d;for(let f=0;f<c.marks.length;f++)t.allowsMarkType(c.marks[f].type)||n.step(new rt(l,u,c.marks[f]));if(s&&c.isText&&t.whitespace!="pre"){let f,h=/\r?\n|\r/g,m;for(;f=h.exec(c.text);)m||(m=new B(O.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),i.push(new ye(l+f.index,l+f.index+f[0].length,m))}}l=u}if(!r.validEnd){let a=r.fillBefore(O.empty,!0);n.replace(l,l,new B(a,0,0))}for(let a=i.length-1;a>=0;a--)n.step(i[a])}function eg(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function qn(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth,s=0,o=0;;--r){let i=n.$from.node(r),l=n.$from.index(r)+s,a=n.$to.indexAfter(r)-o;if(r<n.depth&&i.canReplace(l,a,t))return r;if(r==0||i.type.spec.isolating||!eg(i,l,a))break;l&&(s=1),a<i.childCount&&(o=1)}return null}function tg(n,e,t){let{$from:r,$to:s,depth:o}=e,i=r.before(o+1),l=s.after(o+1),a=i,c=l,u=O.empty,d=0;for(let m=o,g=!1;m>t;m--)g||r.index(m)>0?(g=!0,u=O.from(r.node(m).copy(u)),d++):a--;let f=O.empty,h=0;for(let m=o,g=!1;m>t;m--)g||s.after(m+1)<s.end(m)?(g=!0,f=O.from(s.node(m).copy(f)),h++):c++;n.step(new we(a,c,i,l,new B(u.append(f),d,h),u.size-d,!0))}function tl(n,e,t=null,r=n){let s=ng(n,e),o=s&&rg(r,e);return o?s.map(ka).concat({type:e,attrs:t}).concat(o.map(ka)):null}function ka(n){return{type:n,attrs:null}}function ng(n,e){let{parent:t,startIndex:r,endIndex:s}=n,o=t.contentMatchAt(r).findWrapping(e);if(!o)return null;let i=o.length?o[0]:e;return t.canReplaceWith(r,s,i)?o:null}function rg(n,e){let{parent:t,startIndex:r,endIndex:s}=n,o=t.child(r),i=e.contentMatch.findWrapping(o.type);if(!i)return null;let a=(i.length?i[i.length-1]:e).contentMatch;for(let c=r;a&&c<s;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:i}function sg(n,e,t){let r=O.empty;for(let i=t.length-1;i>=0;i--){if(r.size){let l=t[i].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=O.from(t[i].type.create(t[i].attrs,r))}let s=e.start,o=e.end;n.step(new we(s,o,s,o,new B(r,0,0),t.length,!0))}function og(n,e,t,r,s){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=n.steps.length;n.doc.nodesBetween(e,t,(i,l)=>{let a=typeof s=="function"?s(i):s;if(i.isTextblock&&!i.hasMarkup(r,a)&&ig(n.doc,n.mapping.slice(o).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let h=r.whitespace=="pre",m=!!r.contentMatch.matchType(r.schema.linebreakReplacement);h&&!m?c=!1:!h&&m&&(c=!0)}c===!1&&Gu(n,i,l,o),el(n,n.mapping.slice(o).map(l,1),r,void 0,c===null);let u=n.mapping.slice(o),d=u.map(l,1),f=u.map(l+i.nodeSize,1);return n.step(new we(d,f,d+1,f-1,new B(O.from(r.create(a,null,i.marks)),0,0),1,!0)),c===!0&&Ju(n,i,l,o),!1}})}function Ju(n,e,t,r){e.forEach((s,o)=>{if(s.isText){let i,l=/\r?\n|\r/g;for(;i=l.exec(s.text);){let a=n.mapping.slice(r).map(t+1+o+i.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Gu(n,e,t,r){e.forEach((s,o)=>{if(s.type==s.type.schema.linebreakReplacement){let i=n.mapping.slice(r).map(t+1+o);n.replaceWith(i,i+1,e.type.schema.text(`
5
+ `))}})}function ig(n,e,t){let r=n.resolve(e),s=r.index();return r.parent.canReplaceWith(s,s+1,t)}function lg(n,e,t,r,s){let o=n.doc.nodeAt(e);if(!o)throw new RangeError("No node at given position");t||(t=o.type);let i=t.create(r,null,s||o.marks);if(o.isLeaf)return n.replaceWith(e,e+o.nodeSize,i);if(!t.validContent(o.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new we(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new B(O.from(i),0,0),1,!0))}function vt(n,e,t=1,r){let s=n.resolve(e),o=s.depth-t,i=r&&r[r.length-1]||s.parent;if(o<0||s.parent.type.spec.isolating||!s.parent.canReplace(s.index(),s.parent.childCount)||!i.type.validContent(s.parent.content.cutByIndex(s.index(),s.parent.childCount)))return!1;for(let c=s.depth-1,u=t-2;c>o;c--,u--){let d=s.node(c),f=s.index(c);if(d.type.spec.isolating)return!1;let h=d.content.cutByIndex(f,d.childCount),m=r&&r[u+1];m&&(h=h.replaceChild(0,m.type.create(m.attrs)));let g=r&&r[u]||d;if(!d.canReplace(f+1,d.childCount)||!g.type.validContent(h))return!1}let l=s.indexAfter(o),a=r&&r[0];return s.node(o).canReplaceWith(l,l,a?a.type:s.node(o+1).type)}function ag(n,e,t=1,r){let s=n.doc.resolve(e),o=O.empty,i=O.empty;for(let l=s.depth,a=s.depth-t,c=t-1;l>a;l--,c--){o=O.from(s.node(l).copy(o));let u=r&&r[c];i=O.from(u?u.type.create(u.attrs,i):s.node(l).copy(i))}n.step(new ye(e,e,new B(o.append(i),t,t),!0))}function Kt(n,e){let t=n.resolve(e),r=t.index();return Xu(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function cg(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:r}=n.type.schema;for(let s=0;s<e.childCount;s++){let o=e.child(s),i=o.type==r?n.type.schema.nodes.text:o.type;if(t=t.matchType(i),!t||!n.type.allowsMarks(o.marks))return!1}return t.validEnd}function Xu(n,e){return!!(n&&e&&!n.isLeaf&&cg(n,e))}function Ys(n,e,t=-1){let r=n.resolve(e);for(let s=r.depth;;s--){let o,i,l=r.index(s);if(s==r.depth?(o=r.nodeBefore,i=r.nodeAfter):t>0?(o=r.node(s+1),l++,i=r.node(s).maybeChild(l)):(o=r.node(s).maybeChild(l-1),i=r.node(s+1)),o&&!o.isTextblock&&Xu(o,i)&&r.node(s).canReplace(l,l+1))return e;if(s==0)break;e=t<0?r.before(s):r.after(s)}}function ug(n,e,t){let r=null,{linebreakReplacement:s}=n.doc.type.schema,o=n.doc.resolve(e-t),i=o.node().type;if(s&&i.inlineContent){let u=i.whitespace=="pre",d=!!i.contentMatch.matchType(s);u&&!d?r=!1:!u&&d&&(r=!0)}let l=n.steps.length;if(r===!1){let u=n.doc.resolve(e+t);Gu(n,u.node(),u.before(),l)}i.inlineContent&&el(n,e+t-1,i,o.node().contentMatchAt(o.index()),r==null);let a=n.mapping.slice(l),c=a.map(e-t);if(n.step(new ye(c,a.map(e+t,-1),B.empty,!0)),r===!0){let u=n.doc.resolve(c);Ju(n,u.node(),u.before(),n.steps.length)}return n}function dg(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let s=r.depth-1;s>=0;s--){let o=r.index(s);if(r.node(s).canReplaceWith(o,o,t))return r.before(s+1);if(o>0)return null}if(r.parentOffset==r.parent.content.size)for(let s=r.depth-1;s>=0;s--){let o=r.indexAfter(s);if(r.node(s).canReplaceWith(o,o,t))return r.after(s+1);if(o<r.node(s).childCount)return null}return null}function Yu(n,e,t){let r=n.resolve(e);if(!t.content.size)return e;let s=t.content;for(let o=0;o<t.openStart;o++)s=s.firstChild.content;for(let o=1;o<=(t.openStart==0&&t.size?2:1);o++)for(let i=r.depth;i>=0;i--){let l=i==r.depth?0:r.pos<=(r.start(i+1)+r.end(i+1))/2?-1:1,a=r.index(i)+(l>0?1:0),c=r.node(i),u=!1;if(o==1)u=c.canReplace(a,a,s);else{let d=c.contentMatchAt(a).findWrapping(s.firstChild.type);u=d&&c.canReplaceWith(a,a,d[0])}if(u)return l==0?r.pos:l<0?r.before(i+1):r.after(i+1)}return null}function Qs(n,e,t=e,r=B.empty){if(e==t&&!r.size)return null;let s=n.resolve(e),o=n.resolve(t);return Qu(s,o,r)?new ye(e,t,r):new fg(s,o,r).fit()}function Qu(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class fg{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=O.empty;for(let s=0;s<=e.depth;s++){let o=e.node(s);this.frontier.push({type:o.type,match:o.contentMatchAt(e.indexAfter(s))})}for(let s=e.depth;s>0;s--)this.placed=O.from(e.node(s).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,s=this.close(e<0?this.$to:r.doc.resolve(e));if(!s)return null;let o=this.placed,i=r.depth,l=s.depth;for(;i&&l&&o.childCount==1;)o=o.firstChild.content,i--,l--;let a=new B(o,i,l);return e>-1?new we(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new ye(r.pos,s.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,s=this.unplaced.openEnd;r<e;r++){let o=t.firstChild;if(t.childCount>1&&(s=0),o.type.spec.isolating&&s<=r){e=r;break}t=o.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let s,o=null;r?(o=wo(this.unplaced.content,r-1).firstChild,s=o.content):s=this.unplaced.content;let i=s.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],u,d=null;if(t==1&&(i?c.matchType(i.type)||(d=c.fillBefore(O.from(i),!1)):o&&a.compatibleContent(o.type)))return{sliceDepth:r,frontierDepth:l,parent:o,inject:d};if(t==2&&i&&(u=c.findWrapping(i.type)))return{sliceDepth:r,frontierDepth:l,parent:o,wrap:u};if(o&&c.matchType(o.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,s=wo(e,t);return!s.childCount||s.firstChild.isLeaf?!1:(this.unplaced=new B(e,t+1,Math.max(r,s.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,s=wo(e,t);if(s.childCount<=1&&t>0){let o=e.size-t<=t+s.size;this.unplaced=new B(Yn(e,t-1,1),t-1,o?t-1:r)}else this.unplaced=new B(Yn(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:s,wrap:o}){for(;this.depth>t;)this.closeFrontierNode();if(o)for(let g=0;g<o.length;g++)this.openFrontierNode(o[g]);let i=this.unplaced,l=r?r.content:i.content,a=i.openStart-e,c=0,u=[],{match:d,type:f}=this.frontier[t];if(s){for(let g=0;g<s.childCount;g++)u.push(s.child(g));d=d.matchFragment(s)}let h=l.size+e-(i.content.size-i.openEnd);for(;c<l.childCount;){let g=l.child(c),x=d.matchType(g.type);if(!x)break;c++,(c>1||a==0||g.content.size)&&(d=x,u.push(Zu(g.mark(f.allowedMarks(g.marks)),c==1?a:0,c==l.childCount?h:-1)))}let m=c==l.childCount;m||(h=-1),this.placed=Qn(this.placed,t,O.from(u)),this.frontier[t].match=d,m&&h<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let g=0,x=l;g<h;g++){let y=x.lastChild;this.frontier.push({type:y.type,match:y.contentMatchAt(y.childCount)}),x=y.content}this.unplaced=m?e==0?B.empty:new B(Yn(i.content,e-1,1),e-1,h<0?i.openEnd:e-1):new B(Yn(i.content,e,c),i.openStart,i.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!Co(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:r}=this.$to,s=this.$to.after(r);for(;r>1&&s==this.$to.end(--r);)++s;return s}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:s}=this.frontier[t],o=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),i=Co(e,t,s,r,o);if(i){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],u=Co(e,l,c,a,!0);if(!u||u.childCount)continue e}return{depth:t,fit:i,move:o?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Qn(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let s=e.node(r),o=s.type.contentMatch.fillBefore(s.content,!0,e.index(r));this.openFrontierNode(s.type,s.attrs,o)}return e}openFrontierNode(e,t=null,r){let s=this.frontier[this.depth];s.match=s.match.matchType(e),this.placed=Qn(this.placed,this.depth,O.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(O.empty,!0);t.childCount&&(this.placed=Qn(this.placed,this.frontier.length,t))}}function Yn(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Yn(n.firstChild.content,e-1,t)))}function Qn(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Qn(n.lastChild.content,e-1,t)))}function wo(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function Zu(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,Zu(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(O.empty,!0)))),n.copy(r)}function Co(n,e,t,r,s){let o=n.node(e),i=s?n.indexAfter(e):n.index(e);if(i==o.childCount&&!t.compatibleContent(o.type))return null;let l=r.fillBefore(o.content,!0,i);return l&&!hg(t,o.content,i)?l:null}function hg(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function pg(n){return n.spec.defining||n.spec.definingForContent}function mg(n,e,t,r){if(!r.size)return n.deleteRange(e,t);let s=n.doc.resolve(e),o=n.doc.resolve(t);if(Qu(s,o,r))return n.step(new ye(e,t,r));let i=td(s,o);i[i.length-1]==0&&i.pop();let l=-(s.depth+1);i.unshift(l);for(let f=s.depth,h=s.pos-1;f>0;f--,h--){let m=s.node(f).type.spec;if(m.defining||m.definingAsContext||m.isolating)break;i.indexOf(f)>-1?l=f:s.before(f)==h&&i.splice(1,0,-f)}let a=i.indexOf(l),c=[],u=r.openStart;for(let f=r.content,h=0;;h++){let m=f.firstChild;if(c.push(m),h==r.openStart)break;f=m.content}for(let f=u-1;f>=0;f--){let h=c[f],m=pg(h.type);if(m&&!h.sameMarkup(s.node(Math.abs(l)-1)))u=f;else if(m||!h.type.isTextblock)break}for(let f=r.openStart;f>=0;f--){let h=(f+u+1)%(r.openStart+1),m=c[h];if(m)for(let g=0;g<i.length;g++){let x=i[(g+a)%i.length],y=!0;x<0&&(y=!1,x=-x);let b=s.node(x-1),k=s.index(x-1);if(b.canReplaceWith(k,k,m.type,m.marks))return n.replace(s.before(x),y?o.after(x):t,new B(ed(r.content,0,r.openStart,h),h,r.openEnd))}}let d=n.steps.length;for(let f=i.length-1;f>=0&&(n.replace(e,t,r),!(n.steps.length>d));f--){let h=i[f];h<0||(e=s.before(h),t=o.after(h))}}function ed(n,e,t,r,s){if(e<t){let o=n.firstChild;n=n.replaceChild(0,o.copy(ed(o.content,e+1,t,r,o)))}if(e>r){let o=s.contentMatchAt(0),i=o.fillBefore(n).append(n);n=i.append(o.matchFragment(i).fillBefore(O.empty,!0))}return n}function gg(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let s=dg(n.doc,e,r.type);s!=null&&(e=t=s)}n.replaceRange(e,t,new B(O.from(r),0,0))}function xg(n,e,t){let r=n.doc.resolve(e),s=n.doc.resolve(t);if(r.parent.isTextblock&&s.parent.isTextblock&&r.start()!=s.start()&&r.parentOffset==0&&s.parentOffset==0){let i=r.sharedDepth(t),l=!1;for(let a=r.depth;a>i;a--)r.node(a).type.spec.isolating&&(l=!0);for(let a=s.depth;a>i;a--)s.node(a).type.spec.isolating&&(l=!0);if(!l){for(let a=r.depth;a>0&&e==r.start(a);a--)e=r.before(a);for(let a=s.depth;a>0&&t==s.start(a);a--)t=s.before(a);r=n.doc.resolve(e),s=n.doc.resolve(t)}}let o=td(r,s);for(let i=0;i<o.length;i++){let l=o[i],a=i==o.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return n.delete(r.start(l),s.end(l));if(l>0&&(a||r.node(l-1).canReplace(r.index(l-1),s.indexAfter(l-1))))return n.delete(r.before(l),s.after(l))}for(let i=1;i<=r.depth&&i<=s.depth;i++)if(e-r.start(i)==r.depth-i&&t>r.end(i)&&s.end(i)-t!=s.depth-i&&r.start(i-1)==s.start(i-1)&&r.node(i-1).canReplace(r.index(i-1),s.index(i-1)))return n.delete(r.before(i),t);n.delete(e,t)}function td(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let s=r;s>=0;s--){let o=n.start(s);if(o<n.pos-(n.depth-s)||e.end(s)>e.pos+(e.depth-s)||n.node(s).type.spec.isolating||e.node(s).type.spec.isolating)break;(o==e.start(s)||s==n.depth&&s==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&s&&e.start(s-1)==o-1)&&t.push(s)}return t}class In extends Re{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return be.fail("No node at attribute step's position");let r=Object.create(null);for(let o in t.attrs)r[o]=t.attrs[o];r[this.attr]=this.value;let s=t.type.create(r,null,t.marks);return be.fromReplace(e,this.pos,this.pos+1,new B(O.from(s),0,t.isLeaf?0:1))}getMap(){return We.empty}invert(e){return new In(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new In(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new In(t.pos,t.attr,t.value)}}Re.jsonID("attr",In);class xr extends Re{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let s in e.attrs)t[s]=e.attrs[s];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return be.ok(r)}getMap(){return We.empty}invert(e){return new xr(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new xr(t.attr,t.value)}}Re.jsonID("docAttr",xr);let Dn=class extends Error{};Dn=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};Dn.prototype=Object.create(Error.prototype);Dn.prototype.constructor=Dn;Dn.prototype.name="TransformError";class nd{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new gr}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Dn(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let r=0;r<this.mapping.maps.length;r++){let s=this.mapping.maps[r];r&&(e=s.map(e,1),t=s.map(t,-1)),s.forEach((o,i,l,a)=>{e=Math.min(e,l),t=Math.max(t,a)})}return e==1e9?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,r=B.empty){let s=Qs(this.doc,e,t,r);return s&&this.step(s),this}replaceWith(e,t,r){return this.replace(e,t,new B(O.from(r),0,0))}delete(e,t){return this.replace(e,t,B.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return mg(this,e,t,r),this}replaceRangeWith(e,t,r){return gg(this,e,t,r),this}deleteRange(e,t){return xg(this,e,t),this}lift(e,t){return tg(this,e,t),this}join(e,t=1){return ug(this,e,t),this}wrap(e,t){return sg(this,e,t),this}setBlockType(e,t=e,r,s=null){return og(this,e,t,r,s),this}setNodeMarkup(e,t,r=null,s){return lg(this,e,t,r,s),this}setNodeAttribute(e,t,r){return this.step(new In(e,t,r)),this}setDocAttribute(e,t){return this.step(new xr(e,t)),this}addNodeMark(e,t){return this.step(new Pt(e,t)),this}removeNodeMark(e,t){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t instanceof le)t.isInSet(r.marks)&&this.step(new gn(e,t));else{let s=r.marks,o,i=[];for(;o=t.isInSet(s);)i.push(new gn(e,o)),s=o.removeFromSet(s);for(let l=i.length-1;l>=0;l--)this.step(i[l])}return this}split(e,t=1,r){return ag(this,e,t,r),this}addMark(e,t,r){return Qm(this,e,t,r),this}removeMark(e,t,r){return Zm(this,e,t,r),this}clearIncompatible(e,t,r){return el(this,e,t,r),this}}const To=Object.create(null);class X{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new yg(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=B.empty){let r=t.content.lastChild,s=null;for(let l=0;l<t.openEnd;l++)s=r,r=r.lastChild;let o=e.steps.length,i=this.ranges;for(let l=0;l<i.length;l++){let{$from:a,$to:c}=i[l],u=e.mapping.slice(o);e.replaceRange(u.map(a.pos),u.map(c.pos),l?B.empty:t),l==0&&wa(e,o,(r?r.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(e,t){let r=e.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){let{$from:i,$to:l}=s[o],a=e.mapping.slice(r),c=a.map(i.pos),u=a.map(l.pos);o?e.deleteRange(c,u):(e.replaceRangeWith(c,u,t),wa(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let s=e.parent.inlineContent?new q(e):Nn(e.node(0),e.parent,e.pos,e.index(),t,r);if(s)return s;for(let o=e.depth-1;o>=0;o--){let i=t<0?Nn(e.node(0),e.node(o),e.before(o+1),e.index(o),t,r):Nn(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,t,r);if(i)return i}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new Ue(e.node(0))}static atStart(e){return Nn(e,e,0,0,1)||new Ue(e)}static atEnd(e){return Nn(e,e,e.content.size,e.childCount,-1)||new Ue(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=To[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in To)throw new RangeError("Duplicate use of selection JSON ID "+e);return To[e]=t,t.prototype.jsonID=e,t}getBookmark(){return q.between(this.$anchor,this.$head).getBookmark()}}X.prototype.visible=!0;class yg{constructor(e,t){this.$from=e,this.$to=t}}let Sa=!1;function va(n){!Sa&&!n.parent.inlineContent&&(Sa=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class q extends X{constructor(e,t=e){va(e),va(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return X.near(r);let s=e.resolve(t.map(this.anchor));return new q(s.parent.inlineContent?s:r,r)}replace(e,t=B.empty){if(super.replace(e,t),t==B.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof q&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Zs(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new q(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let s=e.resolve(t);return new this(s,r==t?s:e.resolve(r))}static between(e,t,r){let s=e.pos-t.pos;if((!r||s)&&(r=s>=0?1:-1),!t.parent.inlineContent){let o=X.findFrom(t,r,!0)||X.findFrom(t,-r,!0);if(o)t=o.$head;else return X.near(t,r)}return e.parent.inlineContent||(s==0?e=t:(e=(X.findFrom(e,-r,!0)||X.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=s<0&&(e=t))),new q(e,t)}}X.jsonID("text",q);class Zs{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Zs(e.map(this.anchor),e.map(this.head))}resolve(e){return q.between(e.resolve(this.anchor),e.resolve(this.head))}}class V extends X{constructor(e){let t=e.nodeAfter,r=e.node(0).resolve(e.pos+t.nodeSize);super(e,r),this.node=t}map(e,t){let{deleted:r,pos:s}=t.mapResult(this.anchor),o=e.resolve(s);return r?X.near(o):new V(o)}content(){return new B(O.from(this.node),0,0)}eq(e){return e instanceof V&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new nl(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new V(e.resolve(t.anchor))}static create(e,t){return new V(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}V.prototype.visible=!1;X.jsonID("node",V);class nl{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new Zs(r,r):new nl(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&V.isSelectable(r)?new V(t):X.near(t)}}class Ue extends X{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=B.empty){if(t==B.empty){e.delete(0,e.doc.content.size);let r=X.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new Ue(e)}map(e){return new Ue(e)}eq(e){return e instanceof Ue}getBookmark(){return bg}}X.jsonID("all",Ue);const bg={map(){return this},resolve(n){return new Ue(n)}};function Nn(n,e,t,r,s,o=!1){if(e.inlineContent)return q.create(n,t);for(let i=r-(s>0?0:1);s>0?i<e.childCount:i>=0;i+=s){let l=e.child(i);if(l.isAtom){if(!o&&V.isSelectable(l))return V.create(n,t-(s<0?l.nodeSize:0))}else{let a=Nn(n,l,t+s,s<0?l.childCount:0,s,o);if(a)return a}t+=l.nodeSize*s}return null}function wa(n,e,t){let r=n.steps.length-1;if(r<e)return;let s=n.steps[r];if(!(s instanceof ye||s instanceof we))return;let o=n.mapping.maps[r],i;o.forEach((l,a,c,u)=>{i==null&&(i=u)}),n.setSelection(X.near(n.doc.resolve(i),t))}const Ca=1,Lr=2,Ta=4;class kg extends nd{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|Ca)&~Lr,this.storedMarks=null,this}get selectionSet(){return(this.updated&Ca)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Lr,this}ensureMarks(e){return le.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&Lr)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~Lr,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||le.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let s=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(s.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),!e)return this.deleteRange(t,r);let o=this.storedMarks;if(!o){let i=this.doc.resolve(t);o=r==t?i.marks():i.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,s.text(e,o)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(X.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=Ta,this}get scrolledIntoView(){return(this.updated&Ta)>0}}function Na(n,e){return!e||!n?n:n.bind(e)}class Zn{constructor(e,t,r){this.name=e,this.init=Na(t.init,r),this.apply=Na(t.apply,r)}}const Sg=[new Zn("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Zn("selection",{init(n,e){return n.selection||X.atStart(e.doc)},apply(n){return n.selection}}),new Zn("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new Zn("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class No{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Sg.slice(),t&&t.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Zn(r.key,r.spec.state,r))})}}class jn{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=t){let s=this.config.plugins[r];if(s.spec.filterTransaction&&!s.spec.filterTransaction.call(s,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],r=this.applyInner(e),s=null;for(;;){let o=!1;for(let i=0;i<this.config.plugins.length;i++){let l=this.config.plugins[i];if(l.spec.appendTransaction){let a=s?s[i].n:0,c=s?s[i].state:this,u=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,c,r);if(u&&r.filterTransaction(u,i)){if(u.setMeta("appendedTransaction",e),!s){s=[];for(let d=0;d<this.config.plugins.length;d++)s.push(d<i?{state:r,n:t.length}:{state:this,n:0})}t.push(u),r=r.applyInner(u),o=!0}s&&(s[i]={state:r,n:t.length})}}if(!o)return{state:r,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new jn(this.config),r=this.config.fields;for(let s=0;s<r.length;s++){let o=r[s];t[o.name]=o.apply(e,this[o.name],this,t)}return t}get tr(){return new kg(this)}static create(e){let t=new No(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new jn(t);for(let s=0;s<t.fields.length;s++)r[t.fields[s].name]=t.fields[s].init(e,r);return r}reconfigure(e){let t=new No(this.schema,e.plugins),r=t.fields,s=new jn(t);for(let o=0;o<r.length;o++){let i=r[o].name;s[i]=this.hasOwnProperty(i)?this[i]:r[o].init(e,s)}return s}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let s=e[r],o=s.spec.state;o&&o.toJSON&&(t[r]=o.toJSON.call(s,this[s.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let s=new No(e.schema,e.plugins),o=new jn(s);return s.fields.forEach(i=>{if(i.name=="doc")o.doc=st.fromJSON(e.schema,t.doc);else if(i.name=="selection")o.selection=X.fromJSON(o.doc,t.selection);else if(i.name=="storedMarks")t.storedMarks&&(o.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==i.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){o[i.name]=c.fromJSON.call(a,e,t[l],o);return}}o[i.name]=i.init(e,o)}}),o}}function rd(n,e,t){for(let r in n){let s=n[r];s instanceof Function?s=s.bind(e):r=="handleDOMEvents"&&(s=rd(s,e,{})),t[r]=s}return t}class fe{constructor(e){this.spec=e,this.props={},e.props&&rd(e.props,this,this.props),this.key=e.key?e.key.key:sd("plugin")}getState(e){return e[this.key]}}const Mo=Object.create(null);function sd(n){return n in Mo?n+"$"+ ++Mo[n]:(Mo[n]=0,n+"$")}class ve{constructor(e="key"){this.key=sd(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const rl=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function od(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const id=(n,e,t)=>{let r=od(n,t);if(!r)return!1;let s=sl(r);if(!s){let i=r.blockRange(),l=i&&qn(i);return l==null?!1:(e&&e(n.tr.lift(i,l).scrollIntoView()),!0)}let o=s.nodeBefore;if(md(n,s,e,-1))return!0;if(r.parent.content.size==0&&(Pn(o,"end")||V.isSelectable(o)))for(let i=r.depth;;i--){let l=Qs(n.doc,r.before(i),r.after(i),B.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=n.tr.step(l);a.setSelection(Pn(o,"end")?X.findFrom(a.doc.resolve(a.mapping.map(s.pos,-1)),-1):V.create(a.doc,s.pos-o.nodeSize)),e(a.scrollIntoView())}return!0}if(i==1||r.node(i-1).childCount>1)break}return o.isAtom&&s.depth==r.depth-1?(e&&e(n.tr.delete(s.pos-o.nodeSize,s.pos).scrollIntoView()),!0):!1},vg=(n,e,t)=>{let r=od(n,t);if(!r)return!1;let s=sl(r);return s?ld(n,s,e):!1},wg=(n,e,t)=>{let r=cd(n,t);if(!r)return!1;let s=ol(r);return s?ld(n,s,e):!1};function ld(n,e,t){let r=e.nodeBefore,s=r,o=e.pos-1;for(;!s.isTextblock;o--){if(s.type.spec.isolating)return!1;let u=s.lastChild;if(!u)return!1;s=u}let i=e.nodeAfter,l=i,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let u=l.firstChild;if(!u)return!1;l=u}let c=Qs(n.doc,o,a,B.empty);if(!c||c.from!=o||c instanceof ye&&c.slice.size>=a-o)return!1;if(t){let u=n.tr.step(c);u.setSelection(q.create(u.doc,o)),t(u.scrollIntoView())}return!0}function Pn(n,e,t=!1){for(let r=n;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(t&&r.childCount!=1)return!1}return!1}const ad=(n,e,t)=>{let{$head:r,empty:s}=n.selection,o=r;if(!s)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;o=sl(r)}let i=o&&o.nodeBefore;return!i||!V.isSelectable(i)?!1:(e&&e(n.tr.setSelection(V.create(n.doc,o.pos-i.nodeSize)).scrollIntoView()),!0)};function sl(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function cd(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const ud=(n,e,t)=>{let r=cd(n,t);if(!r)return!1;let s=ol(r);if(!s)return!1;let o=s.nodeAfter;if(md(n,s,e,1))return!0;if(r.parent.content.size==0&&(Pn(o,"start")||V.isSelectable(o))){let i=Qs(n.doc,r.before(),r.after(),B.empty);if(i&&i.slice.size<i.to-i.from){if(e){let l=n.tr.step(i);l.setSelection(Pn(o,"start")?X.findFrom(l.doc.resolve(l.mapping.map(s.pos)),1):V.create(l.doc,l.mapping.map(s.pos))),e(l.scrollIntoView())}return!0}}return o.isAtom&&s.depth==r.depth-1?(e&&e(n.tr.delete(s.pos,s.pos+o.nodeSize).scrollIntoView()),!0):!1},dd=(n,e,t)=>{let{$head:r,empty:s}=n.selection,o=r;if(!s)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset<r.parent.content.size)return!1;o=ol(r)}let i=o&&o.nodeAfter;return!i||!V.isSelectable(i)?!1:(e&&e(n.tr.setSelection(V.create(n.doc,o.pos)).scrollIntoView()),!0)};function ol(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){let t=n.node(e);if(n.index(e)+1<t.childCount)return n.doc.resolve(n.after(e+1));if(t.type.spec.isolating)break}return null}const Cg=(n,e)=>{let t=n.selection,r=t instanceof V,s;if(r){if(t.node.isTextblock||!Kt(n.doc,t.from))return!1;s=t.from}else if(s=Ys(n.doc,t.from,-1),s==null)return!1;if(e){let o=n.tr.join(s);r&&o.setSelection(V.create(o.doc,s-n.doc.resolve(s).nodeBefore.nodeSize)),e(o.scrollIntoView())}return!0},Tg=(n,e)=>{let t=n.selection,r;if(t instanceof V){if(t.node.isTextblock||!Kt(n.doc,t.to))return!1;r=t.to}else if(r=Ys(n.doc,t.to,1),r==null)return!1;return e&&e(n.tr.join(r).scrollIntoView()),!0},Ng=(n,e)=>{let{$from:t,$to:r}=n.selection,s=t.blockRange(r),o=s&&qn(s);return o==null?!1:(e&&e(n.tr.lift(s,o).scrollIntoView()),!0)},fd=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(`
6
+ `).scrollIntoView()),!0)};function il(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}const Mg=(n,e)=>{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let s=t.node(-1),o=t.indexAfter(-1),i=il(s.contentMatchAt(o));if(!i||!s.canReplaceWith(o,o,i))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,i.createAndFill());a.setSelection(X.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},hd=(n,e)=>{let t=n.selection,{$from:r,$to:s}=t;if(t instanceof Ue||r.parent.inlineContent||s.parent.inlineContent)return!1;let o=il(s.parent.contentMatchAt(s.indexAfter()));if(!o||!o.isTextblock)return!1;if(e){let i=(!r.parentOffset&&s.index()<s.parent.childCount?r:s).pos,l=n.tr.insert(i,o.createAndFill());l.setSelection(q.create(l.doc,i+1)),e(l.scrollIntoView())}return!0},pd=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let o=t.before();if(vt(n.doc,o))return e&&e(n.tr.split(o).scrollIntoView()),!0}let r=t.blockRange(),s=r&&qn(r);return s==null?!1:(e&&e(n.tr.lift(r,s).scrollIntoView()),!0)};function Eg(n){return(e,t)=>{let{$from:r,$to:s}=e.selection;if(e.selection instanceof V&&e.selection.node.isBlock)return!r.parentOffset||!vt(e.doc,r.pos)?!1:(t&&t(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let o=[],i,l,a=!1,c=!1;for(let h=r.depth;;h--)if(r.node(h).isBlock){a=r.end(h)==r.pos+(r.depth-h),c=r.start(h)==r.pos-(r.depth-h),l=il(r.node(h-1).contentMatchAt(r.indexAfter(h-1))),o.unshift(a&&l?{type:l}:null),i=h;break}else{if(h==1)return!1;o.unshift(null)}let u=e.tr;(e.selection instanceof q||e.selection instanceof Ue)&&u.deleteSelection();let d=u.mapping.map(r.pos),f=vt(u.doc,d,o.length,o);if(f||(o[0]=l?{type:l}:null,f=vt(u.doc,d,o.length,o)),!f)return!1;if(u.split(d,o.length,o),!a&&c&&r.node(i).type!=l){let h=u.mapping.map(r.before(i)),m=u.doc.resolve(h);l&&r.node(i-1).canReplaceWith(m.index(),m.index()+1,l)&&u.setNodeMarkup(u.mapping.map(r.before(i)),l)}return t&&t(u.scrollIntoView()),!0}}const Ag=Eg(),jg=(n,e)=>{let{$from:t,to:r}=n.selection,s,o=t.sharedDepth(r);return o==0?!1:(s=t.before(o),e&&e(n.tr.setSelection(V.create(n.doc,s))),!0)};function Ig(n,e,t){let r=e.nodeBefore,s=e.nodeAfter,o=e.index();return!r||!s||!r.type.compatibleContent(s.type)?!1:!r.content.size&&e.parent.canReplace(o-1,o)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(o,o+1)||!(s.isTextblock||Kt(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function md(n,e,t,r){let s=e.nodeBefore,o=e.nodeAfter,i,l,a=s.type.spec.isolating||o.type.spec.isolating;if(!a&&Ig(n,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(i=(l=s.contentMatchAt(s.childCount)).findWrapping(o.type))&&l.matchType(i[0]||o.type).validEnd){if(t){let h=e.pos+o.nodeSize,m=O.empty;for(let y=i.length-1;y>=0;y--)m=O.from(i[y].create(null,m));m=O.from(s.copy(m));let g=n.tr.step(new we(e.pos-1,h,e.pos,h,new B(m,1,0),i.length,!0)),x=g.doc.resolve(h+2*i.length);x.nodeAfter&&x.nodeAfter.type==s.type&&Kt(g.doc,x.pos)&&g.join(x.pos),t(g.scrollIntoView())}return!0}let u=o.type.spec.isolating||r>0&&a?null:X.findFrom(e,1),d=u&&u.$from.blockRange(u.$to),f=d&&qn(d);if(f!=null&&f>=e.depth)return t&&t(n.tr.lift(d,f).scrollIntoView()),!0;if(c&&Pn(o,"start",!0)&&Pn(s,"end")){let h=s,m=[];for(;m.push(h),!h.isTextblock;)h=h.lastChild;let g=o,x=1;for(;!g.isTextblock;g=g.firstChild)x++;if(h.canReplace(h.childCount,h.childCount,g.content)){if(t){let y=O.empty;for(let k=m.length-1;k>=0;k--)y=O.from(m[k].copy(y));let b=n.tr.step(new we(e.pos-m.length,e.pos+o.nodeSize,e.pos+x,e.pos+o.nodeSize-x,new B(y,m.length,0),0,!0));t(b.scrollIntoView())}return!0}}return!1}function gd(n){return function(e,t){let r=e.selection,s=n<0?r.$from:r.$to,o=s.depth;for(;s.node(o).isInline;){if(!o)return!1;o--}return s.node(o).isTextblock?(t&&t(e.tr.setSelection(q.create(e.doc,n<0?s.start(o):s.end(o)))),!0):!1}}const Og=gd(-1),Rg=gd(1);function Dg(n,e=null){return function(t,r){let{$from:s,$to:o}=t.selection,i=s.blockRange(o),l=i&&tl(i,n,e);return l?(r&&r(t.tr.wrap(i,l).scrollIntoView()),!0):!1}}function Ma(n,e=null){return function(t,r){let s=!1;for(let o=0;o<t.selection.ranges.length&&!s;o++){let{$from:{pos:i},$to:{pos:l}}=t.selection.ranges[o];t.doc.nodesBetween(i,l,(a,c)=>{if(s)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)s=!0;else{let u=t.doc.resolve(c),d=u.index();s=u.parent.canReplaceWith(d,d+1,n)}})}if(!s)return!1;if(r){let o=t.tr;for(let i=0;i<t.selection.ranges.length;i++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[i];o.setBlockType(l,a,n,e)}r(o.scrollIntoView())}return!0}}function ll(...n){return function(e,t,r){for(let s=0;s<n.length;s++)if(n[s](e,t,r))return!0;return!1}}ll(rl,id,ad);ll(rl,ud,dd);ll(fd,hd,pd,Ag);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function Pg(n,e=null){return function(t,r){let{$from:s,$to:o}=t.selection,i=s.blockRange(o);if(!i)return!1;let l=r?t.tr:null;return Lg(l,i,n,e)?(r&&r(l.scrollIntoView()),!0):!1}}function Lg(n,e,t,r=null){let s=!1,o=e,i=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(t)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=i.resolve(e.start-2);o=new ss(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new ss(e.$from,i.resolve(e.$to.end(e.depth)),e.depth)),s=!0}let l=tl(o,t,r,e);return l?(n&&_g(n,e,l,s,t),!0):!1}function _g(n,e,t,r,s){let o=O.empty;for(let u=t.length-1;u>=0;u--)o=O.from(t[u].type.create(t[u].attrs,o));n.step(new we(e.start-(r?2:0),e.end,e.start,e.end,new B(o,0,0),t.length,!0));let i=0;for(let u=0;u<t.length;u++)t[u].type==s&&(i=u+1);let l=t.length-i,a=e.start+t.length-(r?2:0),c=e.parent;for(let u=e.startIndex,d=e.endIndex,f=!0;u<d;u++,f=!1)!f&&vt(n.doc,a,l)&&(n.split(a,l),a+=2*l),a+=c.child(u).nodeSize;return n}function $g(n){return function(e,t){let{$from:r,$to:s}=e.selection,o=r.blockRange(s,i=>i.childCount>0&&i.firstChild.type==n);return o?t?r.node(o.depth-1).type==n?zg(e,t,n,o):Bg(e,t,o):!0:!1}}function zg(n,e,t,r){let s=n.tr,o=r.end,i=r.$to.end(r.depth);o<i&&(s.step(new we(o-1,i,o,i,new B(O.from(t.create(null,r.parent.copy())),1,0),1,!0)),r=new ss(s.doc.resolve(r.$from.pos),s.doc.resolve(i),r.depth));const l=qn(r);if(l==null)return!1;s.lift(r,l);let a=s.doc.resolve(s.mapping.map(o,-1)-1);return Kt(s.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&s.join(a.pos),e(s.scrollIntoView()),!0}function Bg(n,e,t){let r=n.tr,s=t.parent;for(let h=t.end,m=t.endIndex-1,g=t.startIndex;m>g;m--)h-=s.child(m).nodeSize,r.delete(h-1,h+1);let o=r.doc.resolve(t.start),i=o.nodeAfter;if(r.mapping.map(t.end)!=t.start+o.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==s.childCount,c=o.node(-1),u=o.index(-1);if(!c.canReplace(u+(l?0:1),u+1,i.content.append(a?O.empty:O.from(s))))return!1;let d=o.pos,f=d+i.nodeSize;return r.step(new we(d-(l?1:0),f+(a?1:0),d+1,f-1,new B((l?O.empty:O.from(s.copy(O.empty))).append(a?O.empty:O.from(s.copy(O.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function Fg(n){return function(e,t){let{$from:r,$to:s}=e.selection,o=r.blockRange(s,c=>c.childCount>0&&c.firstChild.type==n);if(!o)return!1;let i=o.startIndex;if(i==0)return!1;let l=o.parent,a=l.child(i-1);if(a.type!=n)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,u=O.from(c?n.create():null),d=new B(O.from(n.create(null,O.from(l.type.create(null,u)))),c?3:1,0),f=o.start,h=o.end;t(e.tr.step(new we(f-(c?3:1),h,f,h,d,1,!0)).scrollIntoView())}return!0}}const Me=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},Ln=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let oi=null;const kt=function(n,e,t){let r=oi||(oi=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},Hg=function(){oi=null},xn=function(n,e,t,r){return t&&(Ea(n,e,t,r,-1)||Ea(n,e,t,r,1))},Vg=/^(img|br|input|textarea|hr)$/i;function Ea(n,e,t,r,s){for(var o;;){if(n==t&&e==r)return!0;if(e==(s<0?0:Ye(n))){let i=n.parentNode;if(!i||i.nodeType!=1||Er(n)||Vg.test(n.nodeName)||n.contentEditable=="false")return!1;e=Me(n)+(s<0?0:1),n=i}else if(n.nodeType==1){let i=n.childNodes[e+(s<0?-1:0)];if(i.nodeType==1&&i.contentEditable=="false")if(!((o=i.pmViewDesc)===null||o===void 0)&&o.ignoreForSelection)e+=s;else return!1;else n=i,e=s<0?Ye(n):0}else return!1}}function Ye(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Wg(n,e){for(;;){if(n.nodeType==3&&e)return n;if(n.nodeType==1&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=Ye(n)}else if(n.parentNode&&!Er(n))e=Me(n),n=n.parentNode;else return null}}function Ug(n,e){for(;;){if(n.nodeType==3&&e<n.nodeValue.length)return n;if(n.nodeType==1&&e<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[e],e=0}else if(n.parentNode&&!Er(n))e=Me(n)+1,n=n.parentNode;else return null}}function qg(n,e,t){for(let r=e==0,s=e==Ye(n);r||s;){if(n==t)return!0;let o=Me(n);if(n=n.parentNode,!n)return!1;r=r&&o==0,s=s&&o==Ye(n)}}function Er(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const eo=function(n){return n.focusNode&&xn(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function Zt(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function Kg(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Jg(n,e,t){if(n.caretPositionFromPoint)try{let r=n.caretPositionFromPoint(e,t);if(r)return{node:r.offsetNode,offset:Math.min(Ye(r.offsetNode),r.offset)}}catch{}if(n.caretRangeFromPoint){let r=n.caretRangeFromPoint(e,t);if(r)return{node:r.startContainer,offset:Math.min(Ye(r.startContainer),r.startOffset)}}}const ft=typeof navigator<"u"?navigator:null,Aa=typeof document<"u"?document:null,Jt=ft&&ft.userAgent||"",ii=/Edge\/(\d+)/.exec(Jt),xd=/MSIE \d/.exec(Jt),li=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Jt),ze=!!(xd||li||ii),zt=xd?document.documentMode:li?+li[1]:ii?+ii[1]:0,Ze=!ze&&/gecko\/(\d+)/i.test(Jt);Ze&&+(/Firefox\/(\d+)/.exec(Jt)||[0,0])[1];const ai=!ze&&/Chrome\/(\d+)/.exec(Jt),Ae=!!ai,yd=ai?+ai[1]:0,Oe=!ze&&!!ft&&/Apple Computer/.test(ft.vendor),_n=Oe&&(/Mobile\/\w+/.test(Jt)||!!ft&&ft.maxTouchPoints>2),Xe=_n||(ft?/Mac/.test(ft.platform):!1),bd=ft?/Win/.test(ft.platform):!1,St=/Android \d/.test(Jt),Ar=!!Aa&&"webkitFontSmoothing"in Aa.documentElement.style,Gg=Ar?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Xg(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function gt(n,e){return typeof n=="number"?n:n[e]}function Yg(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,r=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*r}}function ja(n,e,t){let r=n.someProp("scrollThreshold")||0,s=n.someProp("scrollMargin")||5,o=n.dom.ownerDocument;for(let i=t||n.dom;i;){if(i.nodeType!=1){i=Ln(i);continue}let l=i,a=l==o.body,c=a?Xg(o):Yg(l),u=0,d=0;if(e.top<c.top+gt(r,"top")?d=-(c.top-e.top+gt(s,"top")):e.bottom>c.bottom-gt(r,"bottom")&&(d=e.bottom-e.top>c.bottom-c.top?e.top+gt(s,"top")-c.top:e.bottom-c.bottom+gt(s,"bottom")),e.left<c.left+gt(r,"left")?u=-(c.left-e.left+gt(s,"left")):e.right>c.right-gt(r,"right")&&(u=e.right-c.right+gt(s,"right")),u||d)if(a)o.defaultView.scrollBy(u,d);else{let h=l.scrollLeft,m=l.scrollTop;d&&(l.scrollTop+=d),u&&(l.scrollLeft+=u);let g=l.scrollLeft-h,x=l.scrollTop-m;e={left:e.left-g,top:e.top-x,right:e.right-g,bottom:e.bottom-x}}let f=a?"fixed":getComputedStyle(i).position;if(/^(fixed|sticky)$/.test(f))break;i=f=="absolute"?i.offsetParent:Ln(i)}}function Qg(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,s;for(let o=(e.left+e.right)/2,i=t+1;i<Math.min(innerHeight,e.bottom);i+=5){let l=n.root.elementFromPoint(o,i);if(!l||l==n.dom||!n.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=t-20){r=l,s=a.top;break}}return{refDOM:r,refTop:s,stack:kd(n.dom)}}function kd(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=Ln(r));return e}function Zg({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;Sd(t,r==0?0:r-e)}function Sd(n,e){for(let t=0;t<n.length;t++){let{dom:r,top:s,left:o}=n[t];r.scrollTop!=s+e&&(r.scrollTop=s+e),r.scrollLeft!=o&&(r.scrollLeft=o)}}let Cn=null;function e1(n){if(n.setActive)return n.setActive();if(Cn)return n.focus(Cn);let e=kd(n);n.focus(Cn==null?{get preventScroll(){return Cn={preventScroll:!0},!0}}:void 0),Cn||(Cn=!1,Sd(e,0))}function vd(n,e){let t,r=2e8,s,o=0,i=e.top,l=e.top,a,c;for(let u=n.firstChild,d=0;u;u=u.nextSibling,d++){let f;if(u.nodeType==1)f=u.getClientRects();else if(u.nodeType==3)f=kt(u).getClientRects();else continue;for(let h=0;h<f.length;h++){let m=f[h];if(m.top<=i&&m.bottom>=l){i=Math.max(m.bottom,i),l=Math.min(m.top,l);let g=m.left>e.left?m.left-e.left:m.right<e.left?e.left-m.right:0;if(g<r){t=u,r=g,s=g&&t.nodeType==3?{left:m.right<e.left?m.right:m.left,top:e.top}:e,u.nodeType==1&&g&&(o=d+(e.left>=(m.left+m.right)/2?1:0));continue}}else m.top>e.top&&!a&&m.left<=e.left&&m.right>=e.left&&(a=u,c={left:Math.max(m.left,Math.min(m.right,e.left)),top:m.top});!t&&(e.left>=m.right&&e.top>=m.top||e.left>=m.left&&e.top>=m.bottom)&&(o=d+1)}}return!t&&a&&(t=a,s=c,r=0),t&&t.nodeType==3?t1(t,s):!t||r&&t.nodeType==1?{node:n,offset:o}:vd(t,s)}function t1(n,e){let t=n.nodeValue.length,r=document.createRange(),s;for(let o=0;o<t;o++){r.setEnd(n,o+1),r.setStart(n,o);let i=Et(r,1);if(i.top!=i.bottom&&al(e,i)){s={node:n,offset:o+(e.left>=(i.left+i.right)/2?1:0)};break}}return r.detach(),s||{node:n,offset:0}}function al(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function n1(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function r1(n,e,t){let{node:r,offset:s}=vd(e,t),o=-1;if(r.nodeType==1&&!r.firstChild){let i=r.getBoundingClientRect();o=i.left!=i.right&&t.left>(i.left+i.right)/2?1:-1}return n.docView.posFromDOM(r,s,o)}function s1(n,e,t,r){let s=-1;for(let o=e,i=!1;o!=n.dom;){let l=n.docView.nearestDesc(o,!0),a;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!i&&a.left>r.left||a.top>r.top?s=l.posBefore:(!i&&a.right<r.left||a.bottom<r.top)&&(s=l.posAfter),i=!0),!l.contentDOM&&s<0&&!l.node.isText))return(l.node.isBlock?r.top<(a.top+a.bottom)/2:r.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;o=l.dom.parentNode}return s>-1?s:n.docView.posFromDOM(e,t,-1)}function wd(n,e,t){let r=n.childNodes.length;if(r&&t.top<t.bottom)for(let s=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-t.top)/(t.bottom-t.top))-2)),o=s;;){let i=n.childNodes[o];if(i.nodeType==1){let l=i.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(al(e,c))return wd(i,e,c)}}if((o=(o+1)%r)==s)break}return n}function o1(n,e){let t=n.dom.ownerDocument,r,s=0,o=Jg(t,e.left,e.top);o&&({node:r,offset:s}=o);let i=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),l;if(!i||!n.dom.contains(i.nodeType!=1?i.parentNode:i)){let c=n.dom.getBoundingClientRect();if(!al(e,c)||(i=wd(n.dom,e,c),!i))return null}if(Oe)for(let c=i;r&&c;c=Ln(c))c.draggable&&(r=void 0);if(i=n1(i,e),r){if(Ze&&r.nodeType==1&&(s=Math.min(s,r.childNodes.length),s<r.childNodes.length)){let u=r.childNodes[s],d;u.nodeName=="IMG"&&(d=u.getBoundingClientRect()).right<=e.left&&d.bottom>e.top&&s++}let c;Ar&&s&&r.nodeType==1&&(c=r.childNodes[s-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&s--,r==n.dom&&s==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(s==0||r.nodeType!=1||r.childNodes[s-1].nodeName!="BR")&&(l=s1(n,r,s,e))}l==null&&(l=r1(n,i,e));let a=n.docView.nearestDesc(i,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Ia(n){return n.top<n.bottom||n.left<n.right}function Et(n,e){let t=n.getClientRects();if(t.length){let r=t[e<0?0:t.length-1];if(Ia(r))return r}return Array.prototype.find.call(t,Ia)||n.getBoundingClientRect()}const i1=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Cd(n,e,t){let{node:r,offset:s,atom:o}=n.docView.domFromPos(e,t<0?-1:1),i=Ar||Ze;if(r.nodeType==3)if(i&&(i1.test(r.nodeValue)||(t<0?!s:s==r.nodeValue.length))){let a=Et(kt(r,s,s),t);if(Ze&&s&&/\s/.test(r.nodeValue[s-1])&&s<r.nodeValue.length){let c=Et(kt(r,s-1,s-1),-1);if(c.top==a.top){let u=Et(kt(r,s,s+1),-1);if(u.top!=a.top)return Kn(u,u.left<c.left)}}return a}else{let a=s,c=s,u=t<0?1:-1;return t<0&&!s?(c++,u=-1):t>=0&&s==r.nodeValue.length?(a--,u=1):t<0?a--:c++,Kn(Et(kt(r,a,c),u),u<0)}if(!n.state.doc.resolve(e-(o||0)).parent.inlineContent){if(o==null&&s&&(t<0||s==Ye(r))){let a=r.childNodes[s-1];if(a.nodeType==1)return Eo(a.getBoundingClientRect(),!1)}if(o==null&&s<Ye(r)){let a=r.childNodes[s];if(a.nodeType==1)return Eo(a.getBoundingClientRect(),!0)}return Eo(r.getBoundingClientRect(),t>=0)}if(o==null&&s&&(t<0||s==Ye(r))){let a=r.childNodes[s-1],c=a.nodeType==3?kt(a,Ye(a)-(i?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return Kn(Et(c,1),!1)}if(o==null&&s<Ye(r)){let a=r.childNodes[s];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?kt(a,0,i?0:1):a.nodeType==1?a:null:null;if(c)return Kn(Et(c,-1),!0)}return Kn(Et(r.nodeType==3?kt(r):r,-t),t>=0)}function Kn(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function Eo(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function Td(n,e,t){let r=n.state,s=n.root.activeElement;r!=e&&n.updateState(e),s!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),s!=n.dom&&s&&s.focus()}}function l1(n,e,t){let r=e.selection,s=t=="up"?r.$from:r.$to;return Td(n,e,()=>{let{node:o}=n.docView.domFromPos(s.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(o,!0);if(!l)break;if(l.node.isBlock){o=l.contentDOM||l.dom;break}o=l.dom.parentNode}let i=Cd(n,s.pos,1);for(let l=o.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=kt(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let u=a[c];if(u.bottom>u.top+1&&(t=="up"?i.top-u.top>(u.bottom-i.top)*2:u.bottom-i.bottom>(i.bottom-u.top)*2))return!1}}return!0})}const a1=/[\u0590-\u08ac]/;function c1(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let s=r.parentOffset,o=!s,i=s==r.parent.content.size,l=n.domSelection();return l?!a1.test(r.parent.textContent)||!l.modify?t=="left"||t=="backward"?o:i:Td(n,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:u,anchorOffset:d}=n.domSelectionRange(),f=l.caretBidiLevel;l.modify("move",t,"character");let h=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:m,focusOffset:g}=n.domSelectionRange(),x=m&&!h.contains(m.nodeType==1?m:m.parentNode)||a==m&&c==g;try{l.collapse(u,d),a&&(a!=u||c!=d)&&l.extend&&l.extend(a,c)}catch{}return f!=null&&(l.caretBidiLevel=f),x}):r.pos==r.start()||r.pos==r.end()}let Oa=null,Ra=null,Da=!1;function u1(n,e,t){return Oa==e&&Ra==t?Da:(Oa=e,Ra=t,Da=t=="up"||t=="down"?l1(n,e,t):c1(n,e,t))}const et=0,Pa=1,en=2,ht=3;class jr{constructor(e,t,r,s){this.parent=e,this.children=t,this.dom=r,this.contentDOM=s,this.dirty=et,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,r=this.posAtStart;;t++){let s=this.children[t];if(s==e)return r;r+=s.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let o,i;if(e==this.contentDOM)o=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.previousSibling}for(;o&&!((i=o.pmViewDesc)&&i.parent==this);)o=o.previousSibling;return o?this.posBeforeChild(i)+i.size:this.posAtStart}else{let o,i;if(e==this.contentDOM)o=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.nextSibling}for(;o&&!((i=o.pmViewDesc)&&i.parent==this);)o=o.nextSibling;return o?this.posBeforeChild(i):this.posAtEnd}let s;if(e==this.dom&&this.contentDOM)s=t>Me(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))s=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let o=e;;o=o.parentNode){if(o==this.dom){s=!1;break}if(o.previousSibling)break}if(s==null&&t==e.childNodes.length)for(let o=e;;o=o.parentNode){if(o==this.dom){s=!0;break}if(o.nextSibling)break}}return s??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,s=e;s;s=s.parentNode){let o=this.getDesc(s),i;if(o&&(!t||o.node))if(r&&(i=o.nodeDOM)&&!(i.nodeType==1?i.contains(e.nodeType==1?e:e.parentNode):i==e))r=!1;else return o}}getDesc(e){let t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let s=e;s;s=s.parentNode){let o=this.getDesc(s);if(o)return o.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;t<this.children.length;t++){let s=this.children[t],o=r+s.size;if(r==e&&o!=r){for(;!s.border&&s.children.length;)for(let i=0;i<s.children.length;i++){let l=s.children[i];if(l.size){s=l;break}}return s}if(e<o)return s.descAt(e-r-s.border);r=o}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,s=0;for(let o=0;r<this.children.length;r++){let i=this.children[r],l=o+i.size;if(l>e||i instanceof Md){s=e-o;break}o=l}if(s)return this.children[r].domFromPos(s-this.children[r].border,t);for(let o;r&&!(o=this.children[r-1]).size&&o instanceof Nd&&o.side>=0;r--);if(t<=0){let o,i=!0;for(;o=r?this.children[r-1]:null,!(!o||o.dom.parentNode==this.contentDOM);r--,i=!1);return o&&t&&i&&!o.border&&!o.domAtom?o.domFromPos(o.size,t):{node:this.contentDOM,offset:o?Me(o.dom)+1:0}}else{let o,i=!0;for(;o=r<this.children.length?this.children[r]:null,!(!o||o.dom.parentNode==this.contentDOM);r++,i=!1);return o&&i&&!o.border&&!o.domAtom?o.domFromPos(0,t):{node:this.contentDOM,offset:o?Me(o.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let s=-1,o=-1;for(let i=r,l=0;;l++){let a=this.children[l],c=i+a.size;if(s==-1&&e<=c){let u=i+a.border;if(e>=u&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,u);e=i;for(let d=l;d>0;d--){let f=this.children[d-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){s=Me(f.dom)+1;break}e-=f.size}s==-1&&(s=0)}if(s>-1&&(c>t||l==this.children.length-1)){t=c;for(let u=l+1;u<this.children.length;u++){let d=this.children[u];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(-1)){o=Me(d.dom);break}t+=d.size}o==-1&&(o=this.contentDOM.childNodes.length);break}i=c}return{node:this.contentDOM,from:e,to:t,fromOffset:s,toOffset:o}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:r}=this.domFromPos(e,0);if(t.nodeType!=1||r==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[r]}setSelection(e,t,r,s=!1){let o=Math.min(e,t),i=Math.max(e,t);for(let h=0,m=0;h<this.children.length;h++){let g=this.children[h],x=m+g.size;if(o>m&&i<x)return g.setSelection(e-m-g.border,t-m-g.border,r,s);m=x}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),c=r.root.getSelection(),u=r.domSelectionRange(),d=!1;if((Ze||Oe)&&e==t){let{node:h,offset:m}=l;if(h.nodeType==3){if(d=!!(m&&h.nodeValue[m-1]==`
7
+ `),d&&m==h.nodeValue.length)for(let g=h,x;g;g=g.parentNode){if(x=g.nextSibling){x.nodeName=="BR"&&(l=a={node:x.parentNode,offset:Me(x)+1});break}let y=g.pmViewDesc;if(y&&y.node&&y.node.isBlock)break}}else{let g=h.childNodes[m-1];d=g&&(g.nodeName=="BR"||g.contentEditable=="false")}}if(Ze&&u.focusNode&&u.focusNode!=a.node&&u.focusNode.nodeType==1){let h=u.focusNode.childNodes[u.focusOffset];h&&h.contentEditable=="false"&&(s=!0)}if(!(s||d&&Oe)&&xn(l.node,l.offset,u.anchorNode,u.anchorOffset)&&xn(a.node,a.offset,u.focusNode,u.focusOffset))return;let f=!1;if((c.extend||e==t)&&!(d&&Ze)){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),f=!0}catch{}}if(!f){if(e>t){let m=l;l=a,a=m}let h=document.createRange();h.setEnd(a.node,a.offset),h.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let r=0,s=0;s<this.children.length;s++){let o=this.children[s],i=r+o.size;if(r==i?e<=i&&t>=r:e<i&&t>r){let l=r+o.border,a=i-o.border;if(e>=l&&t<=a){this.dirty=e==r||t==i?en:Pa,e==l&&t==a&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=ht:o.markDirty(e-l,t-l);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?en:ht}r=i}this.dirty=en}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?en:Pa;t.dirty<r&&(t.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class Nd extends jr{constructor(e,t,r,s){let o,i=t.type.toDOM;if(typeof i=="function"&&(i=i(r,()=>{if(!o)return s;if(o.parent)return o.parent.posBeforeChild(o)})),!t.type.spec.raw){if(i.nodeType!=1){let l=document.createElement("span");l.appendChild(i),i=l}i.contentEditable="false",i.classList.add("ProseMirror-widget")}super(e,[],i,null),this.widget=t,this.widget=t,o=this}matchesWidget(e){return this.dirty==et&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class d1 extends jr{constructor(e,t,r,s){super(e,[],t,null),this.textDOM=r,this.text=s}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class yn extends jr{constructor(e,t,r,s,o){super(e,[],r,s),this.mark=t,this.spec=o}static create(e,t,r,s){let o=s.nodeViews[t.type.name],i=o&&o(t,s,r);return(!i||!i.dom)&&(i=Sn.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new yn(e,t,i.dom,i.contentDOM||i.dom,i)}parseRule(){return this.dirty&ht||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=ht&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=et){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=et}}slice(e,t,r){let s=yn.create(this.parent,this.mark,!0,r),o=this.children,i=this.size;t<i&&(o=ui(o,t,i,r)),e>0&&(o=ui(o,0,e,r));for(let l=0;l<o.length;l++)o[l].parent=s;return s.children=o,s}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class Bt extends jr{constructor(e,t,r,s,o,i,l,a,c){super(e,[],o,i),this.node=t,this.outerDeco=r,this.innerDeco=s,this.nodeDOM=l}static create(e,t,r,s,o,i){let l=o.nodeViews[t.type.name],a,c=l&&l(t,o,()=>{if(!a)return i;if(a.parent)return a.parent.posBeforeChild(a)},r,s),u=c&&c.dom,d=c&&c.contentDOM;if(t.isText){if(!u)u=document.createTextNode(t.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:d}=Sn.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!d&&!t.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),t.type.spec.draggable&&(u.draggable=!0));let f=u;return u=jd(u,r,t),c?a=new f1(e,t,r,s,u,d||null,f,c,o,i+1):t.isText?new to(e,t,r,s,u,f,o):new Bt(e,t,r,s,u,d||null,f,o,i+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let r=this.children[t];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>O.empty)}return e}matchesNode(e,t,r){return this.dirty==et&&e.eq(this.node)&&ls(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,s=t,o=e.composing?this.localCompositionInfo(e,t):null,i=o&&o.pos>-1?o:null,l=o&&o.pos<0,a=new p1(this,i&&i.node,e);x1(this.node,this.innerDeco,(c,u,d)=>{c.spec.marks?a.syncToMarks(c.spec.marks,r,e,u):c.type.side>=0&&!d&&a.syncToMarks(u==this.node.childCount?le.none:this.node.child(u).marks,r,e,u),a.placeWidget(c,e,s)},(c,u,d,f)=>{a.syncToMarks(c.marks,r,e,f);let h;a.findNodeMatch(c,u,d,f)||l&&e.state.selection.from>s&&e.state.selection.to<s+c.nodeSize&&(h=a.findIndexWithChild(o.node))>-1&&a.updateNodeAt(c,u,d,h,e)||a.updateNextNode(c,u,d,e,f,s)||a.addNode(c,u,d,e,s),s+=c.nodeSize}),a.syncToMarks([],r,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==en)&&(i&&this.protectLocalComposition(e,i),Ed(this.contentDOM,this.children,e),_n&&y1(this.dom))}localCompositionInfo(e,t){let{from:r,to:s}=e.state.selection;if(!(e.state.selection instanceof q)||r<t||s>t+this.node.content.size)return null;let o=e.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let i=o.nodeValue,l=b1(this.node.content,i,r-t,s-t);return l<0?null:{node:o,pos:l,text:i}}else return{node:o,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:s}){if(this.getDesc(t))return;let o=t;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let i=new d1(this,o,t,s);e.input.compositionNodes.push(i),this.children=ui(this.children,r,r+s.length,e,i)}update(e,t,r,s){return this.dirty==ht||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,s),!0)}updateInner(e,t,r,s){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(s,this.posAtStart),this.dirty=et}updateOuterDeco(e){if(ls(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Ad(this.dom,this.nodeDOM,ci(this.outerDeco,this.node,t),ci(e,this.node,t)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function La(n,e,t,r,s){jd(r,e,n);let o=new Bt(void 0,n,e,t,r,r,r,s,0);return o.contentDOM&&o.updateChildren(s,0),o}class to extends Bt{constructor(e,t,r,s,o,i,l){super(e,t,r,s,o,null,i,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,s){return this.dirty==ht||this.dirty!=et&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=et||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,s.trackWrites==this.nodeDOM&&(s.trackWrites=null)),this.node=e,this.dirty=et,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,r){let s=this.node.cut(e,t),o=document.createTextNode(s.text);return new to(this.parent,s,this.outerDeco,this.innerDeco,o,o,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=ht)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Md extends jr{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==et&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class f1 extends Bt{constructor(e,t,r,s,o,i,l,a,c,u){super(e,t,r,s,o,i,l,c,u),this.spec=a}update(e,t,r,s){if(this.dirty==ht)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let o=this.spec.update(e,t,r);return o&&this.updateInner(e,t,r,s),o}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,s)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,r,s){this.spec.setSelection?this.spec.setSelection(e,t,r.root):super.setSelection(e,t,r,s)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function Ed(n,e,t){let r=n.firstChild,s=!1;for(let o=0;o<e.length;o++){let i=e[o],l=i.dom;if(l.parentNode==n){for(;l!=r;)r=_a(r),s=!0;r=r.nextSibling}else s=!0,n.insertBefore(l,r);if(i instanceof yn){let a=r?r.previousSibling:n.lastChild;Ed(i.contentDOM,i.children,t),r=a?a.nextSibling:n.firstChild}}for(;r;)r=_a(r),s=!0;s&&t.trackWrites==n&&(t.trackWrites=null)}const or=function(n){n&&(this.nodeName=n)};or.prototype=Object.create(null);const tn=[new or];function ci(n,e,t){if(n.length==0)return tn;let r=t?tn[0]:new or,s=[r];for(let o=0;o<n.length;o++){let i=n[o].type.attrs;if(i){i.nodeName&&s.push(r=new or(i.nodeName));for(let l in i){let a=i[l];a!=null&&(t&&s.length==1&&s.push(r=new or(e.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+a:l=="style"?r.style=(r.style?r.style+";":"")+a:l!="nodeName"&&(r[l]=a))}}}return s}function Ad(n,e,t,r){if(t==tn&&r==tn)return e;let s=e;for(let o=0;o<r.length;o++){let i=r[o],l=t[o];if(o){let a;l&&l.nodeName==i.nodeName&&s!=n&&(a=s.parentNode)&&a.nodeName.toLowerCase()==i.nodeName||(a=document.createElement(i.nodeName),a.pmIsDeco=!0,a.appendChild(s),l=tn[0]),s=a}h1(s,l||tn[0],i)}return s}function h1(n,e,t){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in t)&&n.removeAttribute(r);for(let r in t)r!="class"&&r!="style"&&r!="nodeName"&&t[r]!=e[r]&&n.setAttribute(r,t[r]);if(e.class!=t.class){let r=e.class?e.class.split(" ").filter(Boolean):[],s=t.class?t.class.split(" ").filter(Boolean):[];for(let o=0;o<r.length;o++)s.indexOf(r[o])==-1&&n.classList.remove(r[o]);for(let o=0;o<s.length;o++)r.indexOf(s[o])==-1&&n.classList.add(s[o]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,s;for(;s=r.exec(e.style);)n.style.removeProperty(s[1])}t.style&&(n.style.cssText+=t.style)}}function jd(n,e,t){return Ad(n,n,tn,ci(e,t,n.nodeType!=1))}function ls(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].type.eq(e[t].type))return!1;return!0}function _a(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class p1{constructor(e,t,r){this.lock=t,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=m1(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let r=e;r<t;r++)this.top.children[r].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,r,s){let o=0,i=this.stack.length>>1,l=Math.min(i,e.length);for(;o<l&&(o==i-1?this.top:this.stack[o+1<<1]).matchesMark(e[o])&&e[o].type.spec.spanning!==!1;)o++;for(;o<i;)this.destroyRest(),this.top.dirty=et,this.index=this.stack.pop(),this.top=this.stack.pop(),i--;for(;i<e.length;){this.stack.push(this.top,this.index+1);let a=-1,c=this.top.children.length;s<this.preMatch.index&&(c=Math.min(this.index+3,c));for(let u=this.index;u<c;u++){let d=this.top.children[u];if(d.matchesMark(e[i])&&!this.isLocked(d.dom)){a=u;break}}if(a>-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{let u=yn.create(this.top,e[i],t,r);this.top.children.splice(this.index,0,u),this.top=u,this.changed=!0}this.index=0,i++}}findNodeMatch(e,t,r,s){let o=-1,i;if(s>=this.preMatch.index&&(i=this.preMatch.matches[s-this.preMatch.index]).parent==this.top&&i.matchesNode(e,t,r))o=this.top.children.indexOf(i,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,t,r)&&!this.preMatch.matched.has(c)){o=l;break}}return o<0?!1:(this.destroyBetween(this.index,o),this.index++,!0)}updateNodeAt(e,t,r,s,o){let i=this.top.children[s];return i.dirty==ht&&i.dom==i.contentDOM&&(i.dirty=en),i.update(e,t,r,o)?(this.destroyBetween(this.index,s),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let s=this.index;s<this.top.children.length;s++)if(this.top.children[s]==r)return s}return-1}e=t}}updateNextNode(e,t,r,s,o,i){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof Bt){let c=this.preMatch.matched.get(a);if(c!=null&&c!=o)return!1;let u=a.dom,d,f=this.isLocked(u)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=ht&&ls(t,a.outerDeco));if(!f&&a.update(e,t,r,s))return this.destroyBetween(this.index,l),a.dom!=u&&(this.changed=!0),this.index++,!0;if(!f&&(d=this.recreateWrapper(a,e,t,r,s,i)))return this.destroyBetween(this.index,l),this.top.children[this.index]=d,d.contentDOM&&(d.dirty=en,d.updateChildren(s,i+1),d.dirty=et),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,r,s,o,i){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!ls(r,e.outerDeco)||!s.eq(e.innerDeco))return null;let l=Bt.create(this.top,t,r,s,o,i);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,t,r,s,o){let i=Bt.create(this.top,e,t,r,s,o);i.contentDOM&&i.updateChildren(s,o+1),this.top.children.splice(this.index++,0,i),this.changed=!0}placeWidget(e,t,r){let s=this.index<this.top.children.length?this.top.children[this.index]:null;if(s&&s.matchesWidget(e)&&(e==s.widget||!s.widget.type.toDOM.parentNode))this.index++;else{let o=new Nd(this.top,e,t,r);this.top.children.splice(this.index++,0,o),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof yn;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof to)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Oe||Ae)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let s=new Md(this.top,[],r,null);t!=this.top?t.children.push(s):t.children.splice(this.index++,0,s),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function m1(n,e){let t=e,r=t.children.length,s=n.childCount,o=new Map,i=[];e:for(;s>0;){let l;for(;;)if(r){let c=t.children[r-1];if(c instanceof yn)t=c,r=c.children.length;else{l=c,r--;break}}else{if(t==e)break e;r=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=n.child(s-1))break;--s,o.set(l,s),i.push(l)}}return{index:s,matched:o,matches:i.reverse()}}function g1(n,e){return n.type.side-e.type.side}function x1(n,e,t,r){let s=e.locals(n),o=0;if(s.length==0){for(let c=0;c<n.childCount;c++){let u=n.child(c);r(u,s,e.forChild(o,u),c),o+=u.nodeSize}return}let i=0,l=[],a=null;for(let c=0;;){let u,d;for(;i<s.length&&s[i].to==o;){let x=s[i++];x.widget&&(u?(d||(d=[u])).push(x):u=x)}if(u)if(d){d.sort(g1);for(let x=0;x<d.length;x++)t(d[x],c,!!a)}else t(u,c,!!a);let f,h;if(a)h=-1,f=a,a=null;else if(c<n.childCount)h=c,f=n.child(c++);else break;for(let x=0;x<l.length;x++)l[x].to<=o&&l.splice(x--,1);for(;i<s.length&&s[i].from<=o&&s[i].to>o;)l.push(s[i++]);let m=o+f.nodeSize;if(f.isText){let x=m;i<s.length&&s[i].from<x&&(x=s[i].from);for(let y=0;y<l.length;y++)l[y].to<x&&(x=l[y].to);x<m&&(a=f.cut(x-o),f=f.cut(0,x-o),m=x,h=-1)}else for(;i<s.length&&s[i].to<m;)i++;let g=f.isInline&&!f.isLeaf?l.filter(x=>!x.inline):l.slice();r(f,g,e.forChild(o,f),h),o=m}}function y1(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function b1(n,e,t,r){for(let s=0,o=0;s<n.childCount&&o<=r;){let i=n.child(s++),l=o;if(o+=i.nodeSize,!i.isText)continue;let a=i.text;for(;s<n.childCount;){let c=n.child(s++);if(o+=c.nodeSize,!c.isText)break;a+=c.text}if(o>=t){if(o>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l<r?a.lastIndexOf(e,r-l-1):-1;if(c>=0&&c+e.length+l>=t)return l+c;if(t==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function ui(n,e,t,r,s){let o=[];for(let i=0,l=0;i<n.length;i++){let a=n[i],c=l,u=l+=a.size;c>=t||u<=e?o.push(a):(c<e&&o.push(a.slice(0,e-c,r)),s&&(o.push(s),s=void 0),u>t&&o.push(a.slice(t-c,a.size,r)))}return o}function cl(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let s=n.docView.nearestDesc(t.focusNode),o=s&&s.size==0,i=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(i<0)return null;let l=r.resolve(i),a,c;if(eo(t)){for(a=i;s&&!s.node;)s=s.parent;let d=s.node;if(s&&d.isAtom&&V.isSelectable(d)&&s.parent&&!(d.isInline&&qg(t.focusNode,t.focusOffset,s.dom))){let f=s.posBefore;c=new V(i==f?l:r.resolve(f))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let d=i,f=i;for(let h=0;h<t.rangeCount;h++){let m=t.getRangeAt(h);d=Math.min(d,n.docView.posFromDOM(m.startContainer,m.startOffset,1)),f=Math.max(f,n.docView.posFromDOM(m.endContainer,m.endOffset,-1))}if(d<0)return null;[a,i]=f==n.state.selection.anchor?[f,d]:[d,f],l=r.resolve(i)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let u=r.resolve(a);if(!c){let d=e=="pointer"||n.state.selection.head<l.pos&&!o?1:-1;c=ul(n,u,l,d)}return c}function Id(n){return n.editable?n.hasFocus():Rd(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function wt(n,e=!1){let t=n.state.selection;if(Od(n,t),!!Id(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&Ae){let r=n.domSelectionRange(),s=n.domObserver.currentSelection;if(r.anchorNode&&s.anchorNode&&xn(r.anchorNode,r.anchorOffset,s.anchorNode,s.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)S1(n);else{let{anchor:r,head:s}=t,o,i;$a&&!(t instanceof q)&&(t.$from.parent.inlineContent||(o=za(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(i=za(n,t.to))),n.docView.setSelection(r,s,n,e),$a&&(o&&Ba(o),i&&Ba(i)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&k1(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const $a=Oe||Ae&&yd<63;function za(n,e){let{node:t,offset:r}=n.docView.domFromPos(e,0),s=r<t.childNodes.length?t.childNodes[r]:null,o=r?t.childNodes[r-1]:null;if(Oe&&s&&s.contentEditable=="false")return Ao(s);if((!s||s.contentEditable=="false")&&(!o||o.contentEditable=="false")){if(s)return Ao(s);if(o)return Ao(o)}}function Ao(n){return n.contentEditable="true",Oe&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function Ba(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function k1(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),r=t.anchorNode,s=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=r||t.anchorOffset!=s)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!Id(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function S1(n){let e=n.domSelection();if(!e)return;let t=n.cursorWrapper.dom,r=t.nodeName=="IMG";r?e.collapse(t.parentNode,Me(t)+1):e.collapse(t,0),!r&&!n.state.selection.visible&&ze&&zt<=11&&(t.disabled=!0,t.disabled=!1)}function Od(n,e){if(e instanceof V){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(Fa(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else Fa(n)}function Fa(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function ul(n,e,t,r){return n.someProp("createSelectionBetween",s=>s(n,e,t))||q.between(e,t,r)}function Ha(n){return n.editable&&!n.hasFocus()?!1:Rd(n)}function Rd(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function v1(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return xn(e.node,e.offset,t.anchorNode,t.anchorOffset)}function di(n,e){let{$anchor:t,$head:r}=n.selection,s=e>0?t.max(r):t.min(r),o=s.parent.inlineContent?s.depth?n.doc.resolve(e>0?s.after():s.before()):null:s;return o&&X.findFrom(o,e)}function At(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function Va(n,e,t){let r=n.state.selection;if(r instanceof q)if(t.indexOf("s")>-1){let{$head:s}=r,o=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let i=n.state.doc.resolve(s.pos+o.nodeSize*(e<0?-1:1));return At(n,new q(r.$anchor,i))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let s=di(n.state,e);return s&&s instanceof V?At(n,s):!1}else if(!(Xe&&t.indexOf("m")>-1)){let s=r.$head,o=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter,i;if(!o||o.isText)return!1;let l=e<0?s.pos-o.nodeSize:s.pos;return o.isAtom||(i=n.docView.descAt(l))&&!i.contentDOM?V.isSelectable(o)?At(n,new V(e<0?n.state.doc.resolve(s.pos-o.nodeSize):s)):Ar?At(n,new q(n.state.doc.resolve(e<0?l:l+o.nodeSize))):!1:!1}}else return!1;else{if(r instanceof V&&r.node.isInline)return At(n,new q(e>0?r.$to:r.$from));{let s=di(n.state,e);return s?At(n,s):!1}}}function as(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function ir(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function Tn(n,e){return e<0?w1(n):C1(n)}function w1(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let s,o,i=!1;for(Ze&&t.nodeType==1&&r<as(t)&&ir(t.childNodes[r],-1)&&(i=!0);;)if(r>0){if(t.nodeType!=1)break;{let l=t.childNodes[r-1];if(ir(l,-1))s=t,o=--r;else if(l.nodeType==3)t=l,r=t.nodeValue.length;else break}}else{if(Dd(t))break;{let l=t.previousSibling;for(;l&&ir(l,-1);)s=t.parentNode,o=Me(l),l=l.previousSibling;if(l)t=l,r=as(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}i?fi(n,t,r):s&&fi(n,s,o)}function C1(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let s=as(t),o,i;for(;;)if(r<s){if(t.nodeType!=1)break;let l=t.childNodes[r];if(ir(l,1))o=t,i=++r;else break}else{if(Dd(t))break;{let l=t.nextSibling;for(;l&&ir(l,1);)o=l.parentNode,i=Me(l)+1,l=l.nextSibling;if(l)t=l,r=0,s=as(t);else{if(t=t.parentNode,t==n.dom)break;r=s=0}}}o&&fi(n,o,i)}function Dd(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function T1(n,e){for(;n&&e==n.childNodes.length&&!Er(n);)e=Me(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=0}}function N1(n,e){for(;n&&!e&&!Er(n);)e=Me(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function fi(n,e,t){if(e.nodeType!=3){let o,i;(i=T1(e,t))?(e=i,t=0):(o=N1(e,t))&&(e=o,t=o.nodeValue.length)}let r=n.domSelection();if(!r)return;if(eo(r)){let o=document.createRange();o.setEnd(e,t),o.setStart(e,t),r.removeAllRanges(),r.addRange(o)}else r.extend&&r.extend(e,t);n.domObserver.setCurSelection();let{state:s}=n;setTimeout(()=>{n.state==s&&wt(n)},50)}function Wa(n,e){let t=n.state.doc.resolve(e);if(!(Ae||bd)&&t.parent.inlineContent){let s=n.coordsAtPos(e);if(e>t.start()){let o=n.coordsAtPos(e-1),i=(o.top+o.bottom)/2;if(i>s.top&&i<s.bottom&&Math.abs(o.left-s.left)>1)return o.left<s.left?"ltr":"rtl"}if(e<t.end()){let o=n.coordsAtPos(e+1),i=(o.top+o.bottom)/2;if(i>s.top&&i<s.bottom&&Math.abs(o.left-s.left)>1)return o.left>s.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function Ua(n,e,t){let r=n.state.selection;if(r instanceof q&&!r.empty||t.indexOf("s")>-1||Xe&&t.indexOf("m")>-1)return!1;let{$from:s,$to:o}=r;if(!s.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let i=di(n.state,e);if(i&&i instanceof V)return At(n,i)}if(!s.parent.inlineContent){let i=e<0?s:o,l=r instanceof Ue?X.near(i,e):X.findFrom(i,e);return l?At(n,l):!1}return!1}function qa(n,e){if(!(n.state.selection instanceof q))return!0;let{$head:t,$anchor:r,empty:s}=n.state.selection;if(!t.sameParent(r))return!0;if(!s)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let o=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(o&&!o.isText){let i=n.state.tr;return e<0?i.delete(t.pos-o.nodeSize,t.pos):i.delete(t.pos,t.pos+o.nodeSize),n.dispatch(i),!0}return!1}function Ka(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function M1(n){if(!Oe||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;Ka(n,r,"true"),setTimeout(()=>Ka(n,r,"false"),20)}return!1}function E1(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function A1(n,e){let t=e.keyCode,r=E1(e);if(t==8||Xe&&t==72&&r=="c")return qa(n,-1)||Tn(n,-1);if(t==46&&!e.shiftKey||Xe&&t==68&&r=="c")return qa(n,1)||Tn(n,1);if(t==13||t==27)return!0;if(t==37||Xe&&t==66&&r=="c"){let s=t==37?Wa(n,n.state.selection.from)=="ltr"?-1:1:-1;return Va(n,s,r)||Tn(n,s)}else if(t==39||Xe&&t==70&&r=="c"){let s=t==39?Wa(n,n.state.selection.from)=="ltr"?1:-1:1;return Va(n,s,r)||Tn(n,s)}else{if(t==38||Xe&&t==80&&r=="c")return Ua(n,-1,r)||Tn(n,-1);if(t==40||Xe&&t==78&&r=="c")return M1(n)||Ua(n,1,r)||Tn(n,1);if(r==(Xe?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function dl(n,e){n.someProp("transformCopied",h=>{e=h(e,n)});let t=[],{content:r,openStart:s,openEnd:o}=e;for(;s>1&&o>1&&r.childCount==1&&r.firstChild.childCount==1;){s--,o--;let h=r.firstChild;t.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let i=n.someProp("clipboardSerializer")||Sn.fromSchema(n.state.schema),l=Bd(),a=l.createElement("div");a.appendChild(i.serializeFragment(r,{document:l}));let c=a.firstChild,u,d=0;for(;c&&c.nodeType==1&&(u=zd[c.nodeName.toLowerCase()]);){for(let h=u.length-1;h>=0;h--){let m=l.createElement(u[h]);for(;a.firstChild;)m.appendChild(a.firstChild);a.appendChild(m),d++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${s} ${o}${d?` -${d}`:""} ${JSON.stringify(t)}`);let f=n.someProp("clipboardTextSerializer",h=>h(e,n))||e.content.textBetween(0,e.content.size,`
8
+
9
+ `);return{dom:a,text:f,slice:e}}function Pd(n,e,t,r,s){let o=s.parent.type.spec.code,i,l;if(!t&&!e)return null;let a=!!e&&(r||o||!t);if(a){if(n.someProp("transformPastedText",f=>{e=f(e,o||r,n)}),o)return l=new B(O.from(n.state.schema.text(e.replace(/\r\n?/g,`
10
+ `))),0,0),n.someProp("transformPasted",f=>{l=f(l,n,!0)}),l;let d=n.someProp("clipboardTextParser",f=>f(e,s,r,n));if(d)l=d;else{let f=s.marks(),{schema:h}=n.state,m=Sn.fromSchema(h);i=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(g=>{let x=i.appendChild(document.createElement("p"));g&&x.appendChild(m.serializeNode(h.text(g,f)))})}}else n.someProp("transformPastedHTML",d=>{t=d(t,n)}),i=R1(t),Ar&&D1(i);let c=i&&i.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let d=+u[3];d>0;d--){let f=i.firstChild;for(;f&&f.nodeType!=1;)f=f.nextSibling;if(!f)break;i=f}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||$t.fromSchema(n.state.schema)).parseSlice(i,{preserveWhitespace:!!(a||u),context:s,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!j1.test(f.parentNode.nodeName)?{ignore:!0}:null}})),u)l=P1(Ja(l,+u[1],+u[2]),u[4]);else if(l=B.maxOpen(I1(l.content,s),!0),l.openStart||l.openEnd){let d=0,f=0;for(let h=l.content.firstChild;d<l.openStart&&!h.type.spec.isolating;d++,h=h.firstChild);for(let h=l.content.lastChild;f<l.openEnd&&!h.type.spec.isolating;f++,h=h.lastChild);l=Ja(l,d,f)}return n.someProp("transformPasted",d=>{l=d(l,n,a)}),l}const j1=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function I1(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let s=e.node(t).contentMatchAt(e.index(t)),o,i=[];if(n.forEach(l=>{if(!i)return;let a=s.findWrapping(l.type),c;if(!a)return i=null;if(c=i.length&&o.length&&_d(a,o,l,i[i.length-1],0))i[i.length-1]=c;else{i.length&&(i[i.length-1]=$d(i[i.length-1],o.length));let u=Ld(l,a);i.push(u),s=s.matchType(u.type),o=a}}),i)return O.from(i)}return n}function Ld(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,O.from(n));return n}function _d(n,e,t,r,s){if(s<n.length&&s<e.length&&n[s]==e[s]){let o=_d(n,e,t,r.lastChild,s+1);if(o)return r.copy(r.content.replaceChild(r.childCount-1,o));if(r.contentMatchAt(r.childCount).matchType(s==n.length-1?t.type:n[s+1]))return r.copy(r.content.append(O.from(Ld(t,n,s+1))))}}function $d(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,$d(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(O.empty,!0);return n.copy(t.append(r))}function hi(n,e,t,r,s,o){let i=e<0?n.firstChild:n.lastChild,l=i.content;return n.childCount>1&&(o=0),s<r-1&&(l=hi(l,e,t,r,s+1,o)),s>=t&&(l=e<0?i.contentMatchAt(0).fillBefore(l,o<=s).append(l):l.append(i.contentMatchAt(i.childCount).fillBefore(O.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,i.copy(l))}function Ja(n,e,t){return e<n.openStart&&(n=new B(hi(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new B(hi(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const zd={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let Ga=null;function Bd(){return Ga||(Ga=document.implementation.createHTMLDocument("title"))}let jo=null;function O1(n){let e=window.trustedTypes;return e?(jo||(jo=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),jo.createHTML(n)):n}function R1(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Bd().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),s;if((s=r&&zd[r[1].toLowerCase()])&&(n=s.map(o=>"<"+o+">").join("")+n+s.map(o=>"</"+o+">").reverse().join("")),t.innerHTML=O1(n),s)for(let o=0;o<s.length;o++)t=t.querySelector(s[o])||t;return t}function D1(n){let e=n.querySelectorAll(Ae?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let r=e[t];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function P1(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:s,openStart:o,openEnd:i}=n;for(let l=r.length-2;l>=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;s=O.from(a.create(r[l+1],s)),o++,i++}return new B(s,o,i)}const Pe={},Le={},L1={touchstart:!0,touchmove:!0};class _1{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function $1(n){for(let e in Pe){let t=Pe[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{B1(n,r)&&!fl(n,r)&&(n.editable||!(r.type in Le))&&t(n,r)},L1[e]?{passive:!0}:void 0)}Oe&&n.dom.addEventListener("input",()=>null),pi(n)}function Lt(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function z1(n){n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function pi(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>fl(n,r))})}function fl(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function B1(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function F1(n,e){!fl(n,e)&&Pe[e.type]&&(n.editable||!(e.type in Le))&&Pe[e.type](n,e)}Le.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!Hd(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(St&&Ae&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),_n&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",s=>s(n,Zt(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||A1(n,t)?t.preventDefault():Lt(n,"key")};Le.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};Le.keypress=(n,e)=>{let t=e;if(Hd(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||Xe&&t.metaKey)return;if(n.someProp("handleKeyPress",s=>s(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof q)||!r.$from.sameParent(r.$to)){let s=String.fromCharCode(t.charCode),o=()=>n.state.tr.insertText(s).scrollIntoView();!/[\r\n]/.test(s)&&!n.someProp("handleTextInput",i=>i(n,r.$from.pos,r.$to.pos,s,o))&&n.dispatch(o()),t.preventDefault()}};function no(n){return{left:n.clientX,top:n.clientY}}function H1(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function hl(n,e,t,r,s){if(r==-1)return!1;let o=n.state.doc.resolve(r);for(let i=o.depth+1;i>0;i--)if(n.someProp(e,l=>i>o.depth?l(n,t,o.nodeAfter,o.before(i),s,!0):l(n,t,o.node(i),o.before(i),s,!1)))return!0;return!1}function On(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);r.setMeta("pointer",!0),n.dispatch(r)}function V1(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&V.isSelectable(r)?(On(n,new V(t)),!0):!1}function W1(n,e){if(e==-1)return!1;let t=n.state.selection,r,s;t instanceof V&&(r=t.node);let o=n.state.doc.resolve(e);for(let i=o.depth+1;i>0;i--){let l=i>o.depth?o.nodeAfter:o.node(i);if(V.isSelectable(l)){r&&t.$from.depth>0&&i>=t.$from.depth&&o.before(t.$from.depth+1)==t.$from.pos?s=o.before(t.$from.depth):s=o.before(i);break}}return s!=null?(On(n,V.create(n.state.doc,s)),!0):!1}function U1(n,e,t,r,s){return hl(n,"handleClickOn",e,t,r)||n.someProp("handleClick",o=>o(n,e,r))||(s?W1(n,t):V1(n,t))}function q1(n,e,t,r){return hl(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",s=>s(n,e,r))}function K1(n,e,t,r){return hl(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",s=>s(n,e,r))||J1(n,t,r)}function J1(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(On(n,q.create(r,0,r.content.size)),!0):!1;let s=r.resolve(e);for(let o=s.depth+1;o>0;o--){let i=o>s.depth?s.nodeAfter:s.node(o),l=s.before(o);if(i.inlineContent)On(n,q.create(r,l+1,l+1+i.content.size));else if(V.isSelectable(i))On(n,V.create(r,l));else continue;return!0}}function pl(n){return cs(n)}const Fd=Xe?"metaKey":"ctrlKey";Pe.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=pl(n),s=Date.now(),o="singleClick";s-n.input.lastClick.time<500&&H1(t,n.input.lastClick)&&!t[Fd]&&n.input.lastClick.button==t.button&&(n.input.lastClick.type=="singleClick"?o="doubleClick":n.input.lastClick.type=="doubleClick"&&(o="tripleClick")),n.input.lastClick={time:s,x:t.clientX,y:t.clientY,type:o,button:t.button};let i=n.posAtCoords(no(t));i&&(o=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new G1(n,i,t,!!r)):(o=="doubleClick"?q1:K1)(n,i.pos,i.inside,t)?t.preventDefault():Lt(n,"pointer"))};class G1{constructor(e,t,r,s){this.view=e,this.pos=t,this.event=r,this.flushed=s,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[Fd],this.allowDefault=r.shiftKey;let o,i;if(t.inside>-1)o=e.state.doc.nodeAt(t.inside),i=t.inside;else{let u=e.state.doc.resolve(t.pos);o=u.parent,i=u.depth?u.before():0}const l=s?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.nodeDOM.nodeType==1?a.nodeDOM:null;let{selection:c}=e.state;r.button==0&&(o.type.spec.draggable&&o.type.spec.selectable!==!1||c instanceof V&&c.from<=i&&c.to>i)&&(this.mightDrag={node:o,pos:i,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Ze&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),Lt(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>wt(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(no(e))),this.updateAllowDefault(e),this.allowDefault||!t?Lt(this.view,"pointer"):U1(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Oe&&this.mightDrag&&!this.mightDrag.node.isAtom||Ae&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(On(this.view,X.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):Lt(this.view,"pointer")}move(e){this.updateAllowDefault(e),Lt(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}Pe.touchstart=n=>{n.input.lastTouch=Date.now(),pl(n),Lt(n,"pointer")};Pe.touchmove=n=>{n.input.lastTouch=Date.now(),Lt(n,"pointer")};Pe.contextmenu=n=>pl(n);function Hd(n,e){return n.composing?!0:Oe&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const X1=St?5e3:-1;Le.compositionstart=Le.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof q&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||Ae&&bd&&Y1(n)))n.markCursor=n.state.storedMarks||t.marks(),cs(n,!0),n.markCursor=null;else if(cs(n,!e.selection.empty),Ze&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let s=r.focusNode,o=r.focusOffset;s&&s.nodeType==1&&o!=0;){let i=o<0?s.lastChild:s.childNodes[o-1];if(!i)break;if(i.nodeType==3){let l=n.domSelection();l&&l.collapse(i,i.nodeValue.length);break}else s=i,o=-1}}n.input.composing=!0}Vd(n,X1)};function Y1(n){let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(!e||e.nodeType!=1||t>=e.childNodes.length)return!1;let r=e.childNodes[t];return r.nodeType==1&&r.contentEditable=="false"}Le.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.badSafariComposition?n.domObserver.forceFlush():n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,Vd(n,20))};function Vd(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>cs(n),e))}function Wd(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Z1());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function Q1(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=Wg(e.focusNode,e.focusOffset),r=Ug(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let s=r.pmViewDesc,o=n.domObserver.lastChangedTextNode;if(t==o||r==o)return o;if(!s||!s.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let i=t.pmViewDesc;if(!(!i||!i.isText(t.nodeValue)))return r}}return t||r}function Z1(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function cs(n,e=!1){if(!(St&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Wd(n),e||n.docView&&n.docView.dirty){let t=cl(n),r=n.state.selection;return t&&!t.eq(r)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function ex(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),s=document.createRange();s.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(s),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const yr=ze&&zt<15||_n&&Gg<604;Pe.copy=Le.cut=(n,e)=>{let t=e,r=n.state.selection,s=t.type=="cut";if(r.empty)return;let o=yr?null:t.clipboardData,i=r.content(),{dom:l,text:a}=dl(n,i);o?(t.preventDefault(),o.clearData(),o.setData("text/html",l.innerHTML),o.setData("text/plain",a)):ex(n,l),s&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function tx(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function nx(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let s=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?br(n,r.value,null,s,e):br(n,r.textContent,r.innerHTML,s,e)},50)}function br(n,e,t,r,s){let o=Pd(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,s,o||B.empty)))return!0;if(!o)return!1;let i=tx(o),l=i?n.state.tr.replaceSelectionWith(i,r):n.state.tr.replaceSelection(o);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Ud(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}Le.paste=(n,e)=>{let t=e;if(n.composing&&!St)return;let r=yr?null:t.clipboardData,s=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&br(n,Ud(r),r.getData("text/html"),s,t)?t.preventDefault():nx(n,t)};class qd{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}}const rx=Xe?"altKey":"ctrlKey";function Kd(n,e){let t;return n.someProp("dragCopies",r=>{t=t||r(e)}),t!=null?!t:!e[rx]}Pe.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let s=n.state.selection,o=s.empty?null:n.posAtCoords(no(t)),i;if(!(o&&o.pos>=s.from&&o.pos<=(s instanceof V?s.to-1:s.to))){if(r&&r.mightDrag)i=V.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let d=n.docView.nearestDesc(t.target,!0);d&&d.node.type.spec.draggable&&d!=n.docView&&(i=V.create(n.state.doc,d.posBefore))}}let l=(i||n.state.selection).content(),{dom:a,text:c,slice:u}=dl(n,l);(!t.dataTransfer.files.length||!Ae||yd>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(yr?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",yr||t.dataTransfer.setData("text/plain",c),n.dragging=new qd(u,Kd(n,t),i)};Pe.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};Le.dragover=Le.dragenter=(n,e)=>e.preventDefault();Le.drop=(n,e)=>{try{sx(n,e,n.dragging)}finally{n.dragging=null}};function sx(n,e,t){if(!e.dataTransfer)return;let r=n.posAtCoords(no(e));if(!r)return;let s=n.state.doc.resolve(r.pos),o=t&&t.slice;o?n.someProp("transformPasted",h=>{o=h(o,n,!1)}):o=Pd(n,Ud(e.dataTransfer),yr?null:e.dataTransfer.getData("text/html"),!1,s);let i=!!(t&&Kd(n,e));if(n.someProp("handleDrop",h=>h(n,e,o||B.empty,i))){e.preventDefault();return}if(!o)return;e.preventDefault();let l=o?Yu(n.state.doc,s.pos,o):s.pos;l==null&&(l=s.pos);let a=n.state.tr;if(i){let{node:h}=t;h?h.replace(a):a.deleteSelection()}let c=a.mapping.map(l),u=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,d=a.doc;if(u?a.replaceRangeWith(c,c,o.content.firstChild):a.replaceRange(c,c,o),a.doc.eq(d))return;let f=a.doc.resolve(c);if(u&&V.isSelectable(o.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(o.content.firstChild))a.setSelection(new V(f));else{let h=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((m,g,x,y)=>h=y),a.setSelection(ul(n,f,a.doc.resolve(h)))}n.focus(),n.dispatch(a.setMeta("uiEvent","drop"))}Pe.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&wt(n)},20))};Pe.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)};Pe.beforeinput=(n,e)=>{if(Ae&&St&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",o=>o(n,Zt(8,"Backspace")))))return;let{$cursor:s}=n.state.selection;s&&s.pos>0&&n.dispatch(n.state.tr.delete(s.pos-1,s.pos).scrollIntoView())},50)}};for(let n in Le)Pe[n]=Le[n];function kr(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}class us{constructor(e,t){this.toDOM=e,this.spec=t||ln,this.side=this.spec.side||0}map(e,t,r,s){let{pos:o,deleted:i}=e.mapResult(t.from+s,this.side<0?-1:1);return i?null:new De(o-r,o-r,this)}valid(){return!0}eq(e){return this==e||e instanceof us&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&kr(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Ft{constructor(e,t){this.attrs=e,this.spec=t||ln}map(e,t,r,s){let o=e.map(t.from+s,this.spec.inclusiveStart?-1:1)-r,i=e.map(t.to+s,this.spec.inclusiveEnd?1:-1)-r;return o>=i?null:new De(o,i,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof Ft&&kr(this.attrs,e.attrs)&&kr(this.spec,e.spec)}static is(e){return e.type instanceof Ft}destroy(){}}class ml{constructor(e,t){this.attrs=e,this.spec=t||ln}map(e,t,r,s){let o=e.mapResult(t.from+s,1);if(o.deleted)return null;let i=e.mapResult(t.to+s,-1);return i.deleted||i.pos<=o.pos?null:new De(o.pos-r,i.pos-r,this)}valid(e,t){let{index:r,offset:s}=e.content.findIndex(t.from),o;return s==t.from&&!(o=e.child(r)).isText&&s+o.nodeSize==t.to}eq(e){return this==e||e instanceof ml&&kr(this.attrs,e.attrs)&&kr(this.spec,e.spec)}destroy(){}}class De{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new De(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new De(e,e,new us(t,r))}static inline(e,t,r,s){return new De(e,t,new Ft(r,s))}static node(e,t,r,s){return new De(e,t,new ml(r,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof Ft}get widget(){return this.type instanceof us}}const Mn=[],ln={};class de{constructor(e,t){this.local=e.length?e:Mn,this.children=t.length?t:Mn}static create(e,t){return t.length?ds(t,e,0,ln):je}find(e,t,r){let s=[];return this.findInner(e??0,t??1e9,s,0,r),s}findInner(e,t,r,s,o){for(let i=0;i<this.local.length;i++){let l=this.local[i];l.from<=t&&l.to>=e&&(!o||o(l.spec))&&r.push(l.copy(l.from+s,l.to+s))}for(let i=0;i<this.children.length;i+=3)if(this.children[i]<t&&this.children[i+1]>e){let l=this.children[i]+1;this.children[i+2].findInner(e-l,t-l,r,s+l,o)}}map(e,t,r){return this==je||e.maps.length==0?this:this.mapInner(e,t,0,0,r||ln)}mapInner(e,t,r,s,o){let i;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,s);a&&a.type.valid(t,a)?(i||(i=[])).push(a):o.onRemove&&o.onRemove(this.local[l].spec)}return this.children.length?ox(this.children,i||[],e,t,r,s,o):i?new de(i.sort(an),Mn):je}add(e,t){return t.length?this==je?de.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let s,o=0;e.forEach((l,a)=>{let c=a+r,u;if(u=Gd(t,l,c)){for(s||(s=this.children.slice());o<s.length&&s[o]<a;)o+=3;s[o]==a?s[o+2]=s[o+2].addInner(l,u,c+1):s.splice(o,0,a,a+l.nodeSize,ds(u,l,c+1,ln)),o+=3}});let i=Jd(o?Xd(t):t,-r);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||i.splice(l--,1);return new de(i.length?this.local.concat(i).sort(an):this.local,s||this.children)}remove(e){return e.length==0||this==je?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,s=this.local;for(let o=0;o<r.length;o+=3){let i,l=r[o]+t,a=r[o+1]+t;for(let u=0,d;u<e.length;u++)(d=e[u])&&d.from>l&&d.to<a&&(e[u]=null,(i||(i=[])).push(d));if(!i)continue;r==this.children&&(r=this.children.slice());let c=r[o+2].removeInner(i,l+1);c!=je?r[o+2]=c:(r.splice(o,3),o-=3)}if(s.length){for(let o=0,i;o<e.length;o++)if(i=e[o])for(let l=0;l<s.length;l++)s[l].eq(i,t)&&(s==this.local&&(s=this.local.slice()),s.splice(l--,1))}return r==this.children&&s==this.local?this:s.length||r.length?new de(s,r):je}forChild(e,t){if(this==je)return this;if(t.isLeaf)return de.empty;let r,s;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let o=e+1,i=o+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<i&&a.to>o&&a.type instanceof Ft){let c=Math.max(o,a.from)-o,u=Math.min(i,a.to)-o;c<u&&(s||(s=[])).push(a.copy(c,u))}}if(s){let l=new de(s.sort(an),Mn);return r?new Ot([l,r]):l}return r||je}eq(e){if(this==e)return!0;if(!(e instanceof de)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return gl(this.localsInner(e))}localsInner(e){if(this==je)return Mn;if(e.inlineContent||!this.local.some(Ft.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Ft||t.push(this.local[r]);return t}forEachSet(e){e(this)}}de.empty=new de([],[]);de.removeOverlap=gl;const je=de.empty;class Ot{constructor(e){this.members=e}map(e,t){const r=this.members.map(s=>s.map(e,t,ln));return Ot.from(r)}forChild(e,t){if(t.isLeaf)return de.empty;let r=[];for(let s=0;s<this.members.length;s++){let o=this.members[s].forChild(e,t);o!=je&&(o instanceof Ot?r=r.concat(o.members):r.push(o))}return Ot.from(r)}eq(e){if(!(e instanceof Ot)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,r=!0;for(let s=0;s<this.members.length;s++){let o=this.members[s].localsInner(e);if(o.length)if(!t)t=o;else{r&&(t=t.slice(),r=!1);for(let i=0;i<o.length;i++)t.push(o[i])}}return t?gl(r?t:t.sort(an)):Mn}static from(e){switch(e.length){case 0:return je;case 1:return e[0];default:return new Ot(e.every(t=>t instanceof de)?e:e.reduce((t,r)=>t.concat(r instanceof de?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function ox(n,e,t,r,s,o,i){let l=n.slice();for(let c=0,u=o;c<t.maps.length;c++){let d=0;t.maps[c].forEach((f,h,m,g)=>{let x=g-m-(h-f);for(let y=0;y<l.length;y+=3){let b=l[y+1];if(b<0||f>b+u-d)continue;let k=l[y]+u-d;h>=k?l[y+1]=f<=k?-2:-1:f>=u&&x&&(l[y]+=x,l[y+1]+=x)}d+=x}),u=t.maps[c].map(u,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let u=t.map(n[c]+o),d=u-s;if(d<0||d>=r.content.size){a=!0;continue}let f=t.map(n[c+1]+o,-1),h=f-s,{index:m,offset:g}=r.content.findIndex(d),x=r.maybeChild(m);if(x&&g==d&&g+x.nodeSize==h){let y=l[c+2].mapInner(t,x,u+1,n[c]+o+1,i);y!=je?(l[c]=d,l[c+1]=h,l[c+2]=y):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=ix(l,n,e,t,s,o,i),u=ds(c,r,0,i);e=u.local;for(let d=0;d<l.length;d+=3)l[d+1]<0&&(l.splice(d,3),d-=3);for(let d=0,f=0;d<u.children.length;d+=3){let h=u.children[d];for(;f<l.length&&l[f]<h;)f+=3;l.splice(f,0,u.children[d],u.children[d+1],u.children[d+2])}}return new de(e.sort(an),l)}function Jd(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let s=n[r];t.push(new De(s.from+e,s.to+e,s.type))}return t}function ix(n,e,t,r,s,o,i){function l(a,c){for(let u=0;u<a.local.length;u++){let d=a.local[u].map(r,s,c);d?t.push(d):i.onRemove&&i.onRemove(a.local[u].spec)}for(let u=0;u<a.children.length;u+=3)l(a.children[u+2],a.children[u]+c+1)}for(let a=0;a<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+o+1);return t}function Gd(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,s=null;for(let o=0,i;o<n.length;o++)(i=n[o])&&i.from>t&&i.to<r&&((s||(s=[])).push(i),n[o]=null);return s}function Xd(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function ds(n,e,t,r){let s=[],o=!1;e.forEach((l,a)=>{let c=Gd(n,l,a+t);if(c){o=!0;let u=ds(c,l,t+a+1,r);u!=je&&s.push(a,a+l.nodeSize,u)}});let i=Jd(o?Xd(n):n,-t).sort(an);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||(r.onRemove&&r.onRemove(i[l].spec),i.splice(l--,1));return i.length||s.length?new de(i,s):je}function an(n,e){return n.from-e.from||n.to-e.to}function gl(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let s=t+1;s<e.length;s++){let o=e[s];if(o.from==r.from){o.to!=r.to&&(e==n&&(e=n.slice()),e[s]=o.copy(o.from,r.to),Xa(e,s+1,o.copy(r.to,o.to)));continue}else{o.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,o.from),Xa(e,s,r.copy(o.from,r.to)));break}}}return e}function Xa(n,e,t){for(;e<n.length&&an(t,n[e])>0;)e++;n.splice(e,0,t)}function Io(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=je&&e.push(r)}),n.cursorWrapper&&e.push(de.create(n.state.doc,[n.cursorWrapper.deco])),Ot.from(e)}const lx={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},ax=ze&&zt<=11;class cx{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class ux{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new cx,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let s=0;s<r.length;s++)this.queue.push(r[s]);ze&&zt<=11&&r.some(s=>s.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():Oe&&e.composing&&r.some(s=>s.type=="childList"&&s.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),ax&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,lx)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(Ha(this.view)){if(this.suppressingSelectionUpdates)return wt(this.view);if(ze&&zt<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&xn(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,r;for(let o=e.focusNode;o;o=Ln(o))t.add(o);for(let o=e.anchorNode;o;o=Ln(o))if(t.has(o)){r=o;break}let s=r&&this.view.docView.nearestDesc(r);if(s&&s.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let r=e.domSelectionRange(),s=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&Ha(e)&&!this.ignoreSelectionChange(r),o=-1,i=-1,l=!1,a=[];if(e.editable)for(let u=0;u<t.length;u++){let d=this.registerMutation(t[u],a);d&&(o=o<0?d.from:Math.min(d.from,o),i=i<0?d.to:Math.max(d.to,i),d.typeOver&&(l=!0))}if(a.some(u=>u.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let u of a)if(u.nodeName=="BR"&&u.parentNode){let d=u.nextSibling;for(;d&&d.nodeType==1;){if(d.contentEditable=="false"){u.parentNode.removeChild(u);break}d=d.firstChild}}}else if(Ze&&a.length){let u=a.filter(d=>d.nodeName=="BR");if(u.length==2){let[d,f]=u;d.parentNode&&d.parentNode.parentNode==f.parentNode?f.remove():d.remove()}else{let{focusNode:d}=this.currentSelection;for(let f of u){let h=f.parentNode;h&&h.nodeName=="LI"&&(!d||hx(e,d)!=h)&&f.remove()}}}let c=null;o<0&&s&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&eo(r)&&(c=cl(e))&&c.eq(X.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,wt(e),this.currentSelection.set(r),e.scrollToSelection()):(o>-1||s)&&(o>-1&&(e.docView.markDirty(o,i),dx(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,px(e,a)),this.handleDOMChange(o,i,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||wt(e),this.currentSelection.set(r))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let u=0;u<e.addedNodes.length;u++){let d=e.addedNodes[u];t.push(d),d.nodeType==3&&(this.lastChangedTextNode=d)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let s=e.previousSibling,o=e.nextSibling;if(ze&&zt<=11&&e.addedNodes.length)for(let u=0;u<e.addedNodes.length;u++){let{previousSibling:d,nextSibling:f}=e.addedNodes[u];(!d||Array.prototype.indexOf.call(e.addedNodes,d)<0)&&(s=d),(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(o=f)}let i=s&&s.parentNode==e.target?Me(s)+1:0,l=r.localPosFromDOM(e.target,i,-1),a=o&&o.parentNode==e.target?Me(o):e.target.childNodes.length,c=r.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let Ya=new WeakMap,Qa=!1;function dx(n){if(!Ya.has(n)&&(Ya.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=Ze,Qa)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),Qa=!0}}function Za(n,e){let t=e.startContainer,r=e.startOffset,s=e.endContainer,o=e.endOffset,i=n.domAtPos(n.state.selection.anchor);return xn(i.node,i.offset,s,o)&&([t,r,s,o]=[s,o,t,r]),{anchorNode:t,anchorOffset:r,focusNode:s,focusOffset:o}}function fx(n,e){if(e.getComposedRanges){let s=e.getComposedRanges(n.root)[0];if(s)return Za(n,s)}let t;function r(s){s.preventDefault(),s.stopImmediatePropagation(),t=s.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",r,!0),t?Za(n,t):null}function hx(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let r=n.docView.nearestDesc(t,!0);if(r&&r.node.isBlock)return t}return null}function px(n,e){var t;let{focusNode:r,focusOffset:s}=n.domSelectionRange();for(let o of e)if(((t=o.parentNode)===null||t===void 0?void 0:t.nodeName)=="TR"){let i=o.nextSibling;for(;i&&i.nodeName!="TD"&&i.nodeName!="TH";)i=i.nextSibling;if(i){let l=i;for(;;){let a=l.firstChild;if(!a||a.nodeType!=1||a.contentEditable=="false"||/^(BR|IMG)$/.test(a.nodeName))break;l=a}l.insertBefore(o,l.firstChild),r==o&&n.domSelection().collapse(o,s)}else o.parentNode.removeChild(o)}}function mx(n,e,t){let{node:r,fromOffset:s,toOffset:o,from:i,to:l}=n.docView.parseRange(e,t),a=n.domSelectionRange(),c,u=a.anchorNode;if(u&&n.dom.contains(u.nodeType==1?u:u.parentNode)&&(c=[{node:u,offset:a.anchorOffset}],eo(a)||c.push({node:a.focusNode,offset:a.focusOffset})),Ae&&n.input.lastKeyCode===8)for(let x=o;x>s;x--){let y=r.childNodes[x-1],b=y.pmViewDesc;if(y.nodeName=="BR"&&!b){o=x;break}if(!b||b.size)break}let d=n.state.doc,f=n.someProp("domParser")||$t.fromSchema(n.state.schema),h=d.resolve(i),m=null,g=f.parse(r,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:s,to:o,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:gx,context:h});if(c&&c[0].pos!=null){let x=c[0].pos,y=c[1]&&c[1].pos;y==null&&(y=x),m={anchor:x+i,head:y+i}}return{doc:g,sel:m,from:i,to:l}}function gx(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(Oe&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(n.parentNode.lastChild==n||Oe&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}const xx=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function yx(n,e,t,r,s){let o=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let C=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,T=cl(n,C);if(T&&!n.state.selection.eq(T)){if(Ae&&St&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",M=>M(n,Zt(13,"Enter"))))return;let N=n.state.tr.setSelection(T);C=="pointer"?N.setMeta("pointer",!0):C=="key"&&N.scrollIntoView(),o&&N.setMeta("composition",o),n.dispatch(N)}return}let i=n.state.doc.resolve(e),l=i.sharedDepth(t);e=i.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,c=mx(n,e,t),u=n.state.doc,d=u.slice(c.from,c.to),f,h;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(f=n.state.selection.to,h="end"):(f=n.state.selection.from,h="start"),n.input.lastKeyCode=null;let m=Sx(d.content,c.doc.content,c.from,f,h);if(m&&n.input.domChangeCount++,(_n&&n.input.lastIOSEnter>Date.now()-225||St)&&s.some(C=>C.nodeType==1&&!xx.test(C.nodeName))&&(!m||m.endA>=m.endB)&&n.someProp("handleKeyDown",C=>C(n,Zt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!m)if(r&&a instanceof q&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))m={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let C=ec(n,n.state.doc,c.sel);if(C&&!C.eq(n.state.selection)){let T=n.state.tr.setSelection(C);o&&T.setMeta("composition",o),n.dispatch(T)}}return}n.state.selection.from<n.state.selection.to&&m.start==m.endB&&n.state.selection instanceof q&&(m.start>n.state.selection.from&&m.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?m.start=n.state.selection.from:m.endA<n.state.selection.to&&m.endA>=n.state.selection.to-2&&n.state.selection.to<=c.to&&(m.endB+=n.state.selection.to-m.endA,m.endA=n.state.selection.to)),ze&&zt<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>c.from&&c.doc.textBetween(m.start-c.from-1,m.start-c.from+1)=="  "&&(m.start--,m.endA--,m.endB--);let g=c.doc.resolveNoCache(m.start-c.from),x=c.doc.resolveNoCache(m.endB-c.from),y=u.resolve(m.start),b=g.sameParent(x)&&g.parent.inlineContent&&y.end()>=m.endA;if((_n&&n.input.lastIOSEnter>Date.now()-225&&(!b||s.some(C=>C.nodeName=="DIV"||C.nodeName=="P"))||!b&&g.pos<c.doc.content.size&&(!g.sameParent(x)||!g.parent.inlineContent)&&g.pos<x.pos&&!/\S/.test(c.doc.textBetween(g.pos,x.pos,"","")))&&n.someProp("handleKeyDown",C=>C(n,Zt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>m.start&&kx(u,m.start,m.endA,g,x)&&n.someProp("handleKeyDown",C=>C(n,Zt(8,"Backspace")))){St&&Ae&&n.domObserver.suppressSelectionUpdates();return}Ae&&m.endB==m.start&&(n.input.lastChromeDelete=Date.now()),St&&!b&&g.start()!=x.start()&&x.parentOffset==0&&g.depth==x.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==m.endA&&(m.endB-=2,x=c.doc.resolveNoCache(m.endB-c.from),setTimeout(()=>{n.someProp("handleKeyDown",function(C){return C(n,Zt(13,"Enter"))})},20));let k=m.start,S=m.endA,v=C=>{let T=C||n.state.tr.replace(k,S,c.doc.slice(m.start-c.from,m.endB-c.from));if(c.sel){let N=ec(n,T.doc,c.sel);N&&!(Ae&&n.composing&&N.empty&&(m.start!=m.endB||n.input.lastChromeDelete<Date.now()-100)&&(N.head==k||N.head==T.mapping.map(S)-1)||ze&&N.empty&&N.head==k)&&T.setSelection(N)}return o&&T.setMeta("composition",o),T.scrollIntoView()},w;if(b)if(g.pos==x.pos){ze&&zt<=11&&g.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>wt(n),20));let C=v(n.state.tr.delete(k,S)),T=u.resolve(m.start).marksAcross(u.resolve(m.endA));T&&C.ensureMarks(T),n.dispatch(C)}else if(m.endA==m.endB&&(w=bx(g.parent.content.cut(g.parentOffset,x.parentOffset),y.parent.content.cut(y.parentOffset,m.endA-y.start())))){let C=v(n.state.tr);w.type=="add"?C.addMark(k,S,w.mark):C.removeMark(k,S,w.mark),n.dispatch(C)}else if(g.parent.child(g.index()).isText&&g.index()==x.index()-(x.textOffset?0:1)){let C=g.parent.textBetween(g.parentOffset,x.parentOffset),T=()=>v(n.state.tr.insertText(C,k,S));n.someProp("handleTextInput",N=>N(n,k,S,C,T))||n.dispatch(T())}else n.dispatch(v());else n.dispatch(v())}function ec(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:ul(n,e.resolve(t.anchor),e.resolve(t.head))}function bx(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,s=t,o=r,i,l,a;for(let u=0;u<r.length;u++)s=r[u].removeFromSet(s);for(let u=0;u<t.length;u++)o=t[u].removeFromSet(o);if(s.length==1&&o.length==0)l=s[0],i="add",a=u=>u.mark(l.addToSet(u.marks));else if(s.length==0&&o.length==1)l=o[0],i="remove",a=u=>u.mark(l.removeFromSet(u.marks));else return null;let c=[];for(let u=0;u<e.childCount;u++)c.push(a(e.child(u)));if(O.from(c).eq(n))return{mark:l,type:i}}function kx(n,e,t,r,s){if(t-e<=s.pos-r.pos||Oo(r,!0,!1)<s.pos)return!1;let o=n.resolve(e);if(!r.parent.isTextblock){let l=o.nodeAfter;return l!=null&&t==e+l.nodeSize}if(o.parentOffset<o.parent.content.size||!o.parent.isTextblock)return!1;let i=n.resolve(Oo(o,!0,!0));return!i.parent.isTextblock||i.pos>t||Oo(i,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(i.parent.content)}function Oo(n,e,t){let r=n.depth,s=e?n.end():n.pos;for(;r>0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,s++,e=!1;if(t){let o=n.node(r).maybeChild(n.indexAfter(r));for(;o&&!o.isLeaf;)o=o.firstChild,s++}return s}function Sx(n,e,t,r,s){let o=n.findDiffStart(e,t);if(o==null)return null;let{a:i,b:l}=n.findDiffEnd(e,t+n.size,t+e.size);if(s=="end"){let a=Math.max(0,o-Math.min(i,l));r-=i+a-o}if(i<o&&n.size<e.size){let a=r<=o&&r>=i?o-r:0;o-=a,o&&o<e.size&&tc(e.textBetween(o-1,o+1))&&(o+=a?1:-1),l=o+(l-i),i=o}else if(l<o){let a=r<=o&&r>=l?o-r:0;o-=a,o&&o<n.size&&tc(n.textBetween(o-1,o+1))&&(o+=a?1:-1),i=o+(i-l),l=o}return{start:o,endA:i,endB:l}}function tc(n){if(n.length!=2)return!1;let e=n.charCodeAt(0),t=n.charCodeAt(1);return e>=56320&&e<=57343&&t>=55296&&t<=56319}class Yd{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new _1,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(ic),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=sc(this),rc(this),this.nodeViews=oc(this),this.docView=La(this.state.doc,nc(this),Io(this),this.dom,this),this.domObserver=new ux(this,(r,s,o,i)=>yx(this,r,s,o,i)),this.domObserver.start(),$1(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&pi(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(ic),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let s=this.state,o=!1,i=!1;e.storedMarks&&this.composing&&(Wd(this),i=!0),this.state=e;let l=s.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let h=oc(this);wx(h,this.nodeViews)&&(this.nodeViews=h,o=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&pi(this),this.editable=sc(this),rc(this);let a=Io(this),c=nc(this),u=s.plugins!=e.plugins&&!s.doc.eq(e.doc)?"reset":e.scrollToSelection>s.scrollToSelection?"to selection":"preserve",d=o||!this.docView.matchesNode(e.doc,c,a);(d||!e.selection.eq(s.selection))&&(i=!0);let f=u=="preserve"&&i&&this.dom.style.overflowAnchor==null&&Qg(this);if(i){this.domObserver.stop();let h=d&&(ze||Ae)&&!this.composing&&!s.selection.empty&&!e.selection.empty&&vx(s.selection,e.selection);if(d){let m=Ae?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Q1(this)),(o||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=La(e.doc,c,a,this.dom,this)),m&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(h=!0)}h||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&v1(this))?wt(this,h):(Od(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(s),!((r=this.dragging)===null||r===void 0)&&r.node&&!s.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,s),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():f&&Zg(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof V){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&ja(this,t.getBoundingClientRect(),e)}else ja(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let r=this.directPlugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let r=this.state.plugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let r=this.pluginViews[t];r.update&&r.update(this,e)}}updateDraggedNode(e,t){let r=e.node,s=-1;if(r.from<this.state.doc.content.size&&this.state.doc.nodeAt(r.from)==r.node)s=r.from;else{let o=r.from+(this.state.doc.content.size-t.doc.content.size);(o>0&&o<this.state.doc.content.size&&this.state.doc.nodeAt(o))==r.node&&(s=o)}this.dragging=new qd(e.slice,e.move,s<0?void 0:V.create(this.state.doc,s))}someProp(e,t){let r=this._props&&this._props[e],s;if(r!=null&&(s=t?t(r):r))return s;for(let i=0;i<this.directPlugins.length;i++){let l=this.directPlugins[i].props[e];if(l!=null&&(s=t?t(l):l))return s}let o=this.state.plugins;if(o)for(let i=0;i<o.length;i++){let l=o[i].props[e];if(l!=null&&(s=t?t(l):l))return s}}hasFocus(){if(ze){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&e1(this.dom),wt(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return o1(this,e)}coordsAtPos(e,t=1){return Cd(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,r=-1){let s=this.docView.posFromDOM(e,t,r);if(s==null)throw new RangeError("DOM position not inside the editor");return s}endOfTextblock(e,t){return u1(this,t||this.state,e)}pasteHTML(e,t){return br(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return br(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return dl(this,e)}destroy(){this.docView&&(z1(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Io(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Hg())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return F1(this,e)}domSelectionRange(){let e=this.domSelection();return e?Oe&&this.root.nodeType===11&&Kg(this.dom.ownerDocument)==this.dom&&fx(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}Yd.prototype.dispatch=function(n){let e=this._props.dispatchTransaction;e?e.call(this,n):this.updateState(this.state.apply(n))};function nc(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[De.node(0,n.state.doc.content.size,e)]}function rc(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:De.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function sc(n){return!n.someProp("editable",e=>e(n.state)===!1)}function vx(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function oc(n){let e=Object.create(null);function t(r){for(let s in r)Object.prototype.hasOwnProperty.call(e,s)||(e[s]=r[s])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function wx(n,e){let t=0,r=0;for(let s in n){if(n[s]!=e[s])return!0;t++}for(let s in e)r++;return t!=r}function ic(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var Vt={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},fs={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Cx=typeof navigator<"u"&&/Mac/.test(navigator.platform),Tx=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Ee=0;Ee<10;Ee++)Vt[48+Ee]=Vt[96+Ee]=String(Ee);for(var Ee=1;Ee<=24;Ee++)Vt[Ee+111]="F"+Ee;for(var Ee=65;Ee<=90;Ee++)Vt[Ee]=String.fromCharCode(Ee+32),fs[Ee]=String.fromCharCode(Ee);for(var Ro in Vt)fs.hasOwnProperty(Ro)||(fs[Ro]=Vt[Ro]);function Nx(n){var e=Cx&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||Tx&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?fs:Vt)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}const Mx=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Ex=typeof navigator<"u"&&/Win/.test(navigator.platform);function Ax(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,s,o,i;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))i=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))s=!0;else if(/^s(hift)?$/i.test(a))o=!0;else if(/^mod$/i.test(a))Mx?i=!0:s=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(t="Alt-"+t),s&&(t="Ctrl-"+t),i&&(t="Meta-"+t),o&&(t="Shift-"+t),t}function jx(n){let e=Object.create(null);for(let t in n)e[Ax(t)]=n[t];return e}function Do(n,e,t=!0){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t&&e.shiftKey&&(n="Shift-"+n),n}function Ix(n){return new fe({props:{handleKeyDown:Qd(n)}})}function Qd(n){let e=jx(n);return function(t,r){let s=Nx(r),o,i=e[Do(s,r)];if(i&&i(t.state,t.dispatch,t))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let l=e[Do(s,r,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(Ex&&r.ctrlKey&&r.altKey)&&(o=Vt[r.keyCode])&&o!=s){let l=e[Do(o,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}var Ox=Object.defineProperty,xl=(n,e)=>{for(var t in e)Ox(n,t,{get:e[t],enumerable:!0})};function ro(n){const{state:e,transaction:t}=n;let{selection:r}=t,{doc:s}=t,{storedMarks:o}=t;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return o},get selection(){return r},get doc(){return s},get tr(){return r=t.selection,s=t.doc,o=t.storedMarks,t}}}var so=class{constructor(n){this.editor=n.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=n.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:n,editor:e,state:t}=this,{view:r}=e,{tr:s}=t,o=this.buildProps(s);return Object.fromEntries(Object.entries(n).map(([i,l])=>[i,(...c)=>{const u=l(...c)(o);return!s.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(s),u}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(n,e=!0){const{rawCommands:t,editor:r,state:s}=this,{view:o}=r,i=[],l=!!n,a=n||s.tr,c=()=>(!l&&e&&!a.getMeta("preventDispatch")&&!this.hasCustomState&&o.dispatch(a),i.every(d=>d===!0)),u={...Object.fromEntries(Object.entries(t).map(([d,f])=>[d,(...m)=>{const g=this.buildProps(a,e),x=f(...m)(g);return i.push(x),u}])),run:c};return u}createCan(n){const{rawCommands:e,state:t}=this,r=!1,s=n||t.tr,o=this.buildProps(s,r);return{...Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...c)=>a(...c)({...o,dispatch:void 0})])),chain:()=>this.createChain(s,r)}}buildProps(n,e=!0){const{rawCommands:t,editor:r,state:s}=this,{view:o}=r,i={tr:n,editor:r,view:o,state:ro({state:s,transaction:n}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(n,e),can:()=>this.createCan(n),get commands(){return Object.fromEntries(Object.entries(t).map(([l,a])=>[l,(...c)=>a(...c)(i)]))}};return i}},Zd={};xl(Zd,{blur:()=>Rx,clearContent:()=>Dx,clearNodes:()=>Px,command:()=>Lx,createParagraphNear:()=>_x,cut:()=>$x,deleteCurrentNode:()=>zx,deleteNode:()=>Bx,deleteRange:()=>Fx,deleteSelection:()=>Hx,enter:()=>Vx,exitCode:()=>Wx,extendMarkRange:()=>Ux,first:()=>qx,focus:()=>Jx,forEach:()=>Gx,insertContent:()=>Xx,insertContentAt:()=>Zx,joinBackward:()=>n0,joinDown:()=>t0,joinForward:()=>r0,joinItemBackward:()=>s0,joinItemForward:()=>o0,joinTextblockBackward:()=>i0,joinTextblockForward:()=>l0,joinUp:()=>e0,keyboardShortcut:()=>c0,lift:()=>u0,liftEmptyBlock:()=>d0,liftListItem:()=>f0,newlineInCode:()=>h0,resetAttributes:()=>p0,scrollIntoView:()=>m0,selectAll:()=>g0,selectNodeBackward:()=>x0,selectNodeForward:()=>y0,selectParentNode:()=>b0,selectTextblockEnd:()=>k0,selectTextblockStart:()=>S0,setContent:()=>v0,setMark:()=>V0,setMeta:()=>W0,setNode:()=>U0,setNodeSelection:()=>q0,setTextDirection:()=>K0,setTextSelection:()=>J0,sinkListItem:()=>G0,splitBlock:()=>X0,splitListItem:()=>Y0,toggleList:()=>Q0,toggleMark:()=>Z0,toggleNode:()=>ey,toggleWrap:()=>ty,undoInputRule:()=>ny,unsetAllMarks:()=>ry,unsetMark:()=>sy,unsetTextDirection:()=>oy,updateAttributes:()=>iy,wrapIn:()=>ly,wrapInList:()=>ay});var Rx=()=>({editor:n,view:e})=>(requestAnimationFrame(()=>{var t;n.isDestroyed||(e.dom.blur(),(t=window?.getSelection())==null||t.removeAllRanges())}),!0),Dx=(n=!0)=>({commands:e})=>e.setContent("",{emitUpdate:n}),Px=()=>({state:n,tr:e,dispatch:t})=>{const{selection:r}=e,{ranges:s}=r;return t&&s.forEach(({$from:o,$to:i})=>{n.doc.nodesBetween(o.pos,i.pos,(l,a)=>{if(l.type.isText)return;const{doc:c,mapping:u}=e,d=c.resolve(u.map(a)),f=c.resolve(u.map(a+l.nodeSize)),h=d.blockRange(f);if(!h)return;const m=qn(h);if(l.type.isTextblock){const{defaultType:g}=d.parent.contentMatchAt(d.index());e.setNodeMarkup(h.start,g)}(m||m===0)&&e.lift(h,m)})}),!0},Lx=n=>e=>n(e),_x=()=>({state:n,dispatch:e})=>hd(n,e),$x=(n,e)=>({editor:t,tr:r})=>{const{state:s}=t,o=s.doc.slice(n.from,n.to);r.deleteRange(n.from,n.to);const i=r.mapping.map(e);return r.insert(i,o.content),r.setSelection(new q(r.doc.resolve(Math.max(i-1,0)))),!0},zx=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,r=t.$anchor.node();if(r.content.size>0)return!1;const s=n.selection.$anchor;for(let o=s.depth;o>0;o-=1)if(s.node(o).type===r.type){if(e){const l=s.before(o),a=s.after(o);n.delete(l,a).scrollIntoView()}return!0}return!1};function ke(n,e){if(typeof n=="string"){if(!e.nodes[n])throw Error(`There is no node type named '${n}'. Maybe you forgot to add the extension?`);return e.nodes[n]}return n}var Bx=n=>({tr:e,state:t,dispatch:r})=>{const s=ke(n,t.schema),o=e.selection.$anchor;for(let i=o.depth;i>0;i-=1)if(o.node(i).type===s){if(r){const a=o.before(i),c=o.after(i);e.delete(a,c).scrollIntoView()}return!0}return!1},Fx=n=>({tr:e,dispatch:t})=>{const{from:r,to:s}=n;return t&&e.delete(r,s),!0},Hx=()=>({state:n,dispatch:e})=>rl(n,e),Vx=()=>({commands:n})=>n.keyboardShortcut("Enter"),Wx=()=>({state:n,dispatch:e})=>Mg(n,e);function yl(n){return Object.prototype.toString.call(n)==="[object RegExp]"}function hs(n,e,t={strict:!0}){const r=Object.keys(e);return r.length?r.every(s=>t.strict?e[s]===n[s]:yl(e[s])?e[s].test(n[s]):e[s]===n[s]):!0}function ef(n,e,t={}){return n.find(r=>r.type===e&&hs(Object.fromEntries(Object.keys(t).map(s=>[s,r.attrs[s]])),t))}function lc(n,e,t={}){return!!ef(n,e,t)}function bl(n,e,t){var r;if(!n||!e)return;let s=n.parent.childAfter(n.parentOffset);if((!s.node||!s.node.marks.some(u=>u.type===e))&&(s=n.parent.childBefore(n.parentOffset)),!s.node||!s.node.marks.some(u=>u.type===e)||(t=t||((r=s.node.marks[0])==null?void 0:r.attrs),!ef([...s.node.marks],e,t)))return;let i=s.index,l=n.start()+s.offset,a=i+1,c=l+s.node.nodeSize;for(;i>0&&lc([...n.parent.child(i-1).marks],e,t);)i-=1,l-=n.parent.child(i).nodeSize;for(;a<n.parent.childCount&&lc([...n.parent.child(a).marks],e,t);)c+=n.parent.child(a).nodeSize,a+=1;return{from:l,to:c}}function Tt(n,e){if(typeof n=="string"){if(!e.marks[n])throw Error(`There is no mark type named '${n}'. Maybe you forgot to add the extension?`);return e.marks[n]}return n}var Ux=(n,e={})=>({tr:t,state:r,dispatch:s})=>{const o=Tt(n,r.schema),{doc:i,selection:l}=t,{$from:a,from:c,to:u}=l;if(s){const d=bl(a,o,e);if(d&&d.from<=c&&d.to>=u){const f=q.create(i,d.from,d.to);t.setSelection(f)}}return!0},qx=n=>e=>{const t=typeof n=="function"?n(e):n;for(let r=0;r<t.length;r+=1)if(t[r](e))return!0;return!1};function tf(n){return n instanceof q}function nn(n=0,e=0,t=0){return Math.min(Math.max(n,e),t)}function nf(n,e=null){if(!e)return null;const t=X.atStart(n),r=X.atEnd(n);if(e==="start"||e===!0)return t;if(e==="end")return r;const s=t.from,o=r.to;return e==="all"?q.create(n,nn(0,s,o),nn(n.content.size,s,o)):q.create(n,nn(e,s,o),nn(e,s,o))}function mi(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function Sr(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function Kx(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var Jx=(n=null,e={})=>({editor:t,view:r,tr:s,dispatch:o})=>{e={scrollIntoView:!0,...e};const i=()=>{(Sr()||mi())&&r.dom.focus(),Kx()&&!Sr()&&!mi()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{t.isDestroyed||(r.focus(),e?.scrollIntoView&&t.commands.scrollIntoView())})};try{if(r.hasFocus()&&n===null||n===!1)return!0}catch{return!1}if(o&&n===null&&!tf(t.state.selection))return i(),!0;const l=nf(s.doc,n)||t.state.selection,a=t.state.selection.eq(l);return o&&(a||s.setSelection(l),a&&s.storedMarks&&s.setStoredMarks(s.storedMarks),i()),!0},Gx=(n,e)=>t=>n.every((r,s)=>e(r,{...t,index:s})),Xx=(n,e)=>({tr:t,commands:r})=>r.insertContentAt({from:t.selection.from,to:t.selection.to},n,e),rf=n=>{const e=n.childNodes;for(let t=e.length-1;t>=0;t-=1){const r=e[t];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?n.removeChild(r):r.nodeType===1&&rf(r)}return n};function _r(n){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`<body>${n}</body>`,t=new window.DOMParser().parseFromString(e,"text/html").body;return rf(t)}function vr(n,e,t){if(n instanceof st||n instanceof O)return n;t={slice:!0,parseOptions:{},...t};const r=typeof n=="object"&&n!==null,s=typeof n=="string";if(r)try{if(Array.isArray(n)&&n.length>0)return O.fromArray(n.map(l=>e.nodeFromJSON(l)));const i=e.nodeFromJSON(n);return t.errorOnInvalidContent&&i.check(),i}catch(o){if(t.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:o});return console.warn("[tiptap warn]: Invalid content.","Passed value:",n,"Error:",o),vr("",e,t)}if(s){if(t.errorOnInvalidContent){let i=!1,l="";const a=new Bu({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(i=!0,l=typeof c=="string"?c:c.outerHTML,null)}]}})});if(t.slice?$t.fromSchema(a).parseSlice(_r(n),t.parseOptions):$t.fromSchema(a).parse(_r(n),t.parseOptions),t.errorOnInvalidContent&&i)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const o=$t.fromSchema(e);return t.slice?o.parseSlice(_r(n),t.parseOptions).content:o.parse(_r(n),t.parseOptions)}return vr("",e,t)}function Yx(n,e,t){const r=n.steps.length-1;if(r<e)return;const s=n.steps[r];if(!(s instanceof ye||s instanceof we))return;const o=n.mapping.maps[r];let i=0;o.forEach((l,a,c,u)=>{i===0&&(i=u)}),n.setSelection(X.near(n.doc.resolve(i),t))}var Qx=n=>!("type"in n),Zx=(n,e,t)=>({tr:r,dispatch:s,editor:o})=>{var i;if(s){t={parseOptions:o.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...t};let l;const a=x=>{o.emit("contentError",{editor:o,error:x,disableCollaboration:()=>{"collaboration"in o.storage&&typeof o.storage.collaboration=="object"&&o.storage.collaboration&&(o.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...t.parseOptions};if(!t.errorOnInvalidContent&&!o.options.enableContentCheck&&o.options.emitContentError)try{vr(e,o.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(x){a(x)}try{l=vr(e,o.schema,{parseOptions:c,errorOnInvalidContent:(i=t.errorOnInvalidContent)!=null?i:o.options.enableContentCheck})}catch(x){return a(x),!1}let{from:u,to:d}=typeof n=="number"?{from:n,to:n}:{from:n.from,to:n.to},f=!0,h=!0;if((Qx(l)?l:[l]).forEach(x=>{x.check(),f=f?x.isText&&x.marks.length===0:!1,h=h?x.isBlock:!1}),u===d&&h){const{parent:x}=r.doc.resolve(u);x.isTextblock&&!x.type.spec.code&&!x.childCount&&(u-=1,d+=1)}let g;if(f){if(Array.isArray(e))g=e.map(x=>x.text||"").join("");else if(e instanceof O){let x="";e.forEach(y=>{y.text&&(x+=y.text)}),g=x}else typeof e=="object"&&e&&e.text?g=e.text:g=e;r.insertText(g,u,d)}else{g=l;const x=r.doc.resolve(u),y=x.node(),b=x.parentOffset===0,k=y.isText||y.isTextblock,S=y.content.size>0;b&&k&&S&&(u=Math.max(0,u-1)),r.replaceWith(u,d,g)}t.updateSelection&&Yx(r,r.steps.length-1,-1),t.applyInputRules&&r.setMeta("applyInputRules",{from:u,text:g}),t.applyPasteRules&&r.setMeta("applyPasteRules",{from:u,text:g})}return!0},e0=()=>({state:n,dispatch:e})=>Cg(n,e),t0=()=>({state:n,dispatch:e})=>Tg(n,e),n0=()=>({state:n,dispatch:e})=>id(n,e),r0=()=>({state:n,dispatch:e})=>ud(n,e),s0=()=>({state:n,dispatch:e,tr:t})=>{try{const r=Ys(n.doc,n.selection.$from.pos,-1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},o0=()=>({state:n,dispatch:e,tr:t})=>{try{const r=Ys(n.doc,n.selection.$from.pos,1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},i0=()=>({state:n,dispatch:e})=>vg(n,e),l0=()=>({state:n,dispatch:e})=>wg(n,e);function sf(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function a0(n){const e=n.split(/-(?!$)/);let t=e[e.length-1];t==="Space"&&(t=" ");let r,s,o,i;for(let l=0;l<e.length-1;l+=1){const a=e[l];if(/^(cmd|meta|m)$/i.test(a))i=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))s=!0;else if(/^s(hift)?$/i.test(a))o=!0;else if(/^mod$/i.test(a))Sr()||sf()?i=!0:s=!0;else throw new Error(`Unrecognized modifier name: ${a}`)}return r&&(t=`Alt-${t}`),s&&(t=`Ctrl-${t}`),i&&(t=`Meta-${t}`),o&&(t=`Shift-${t}`),t}var c0=n=>({editor:e,view:t,tr:r,dispatch:s})=>{const o=a0(n).split(/-(?!$)/),i=o.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),l=new KeyboardEvent("keydown",{key:i==="Space"?" ":i,altKey:o.includes("Alt"),ctrlKey:o.includes("Ctrl"),metaKey:o.includes("Meta"),shiftKey:o.includes("Shift"),bubbles:!0,cancelable:!0}),a=e.captureTransaction(()=>{t.someProp("handleKeyDown",c=>c(t,l))});return a?.steps.forEach(c=>{const u=c.map(r.mapping);u&&s&&r.maybeStep(u)}),!0};function Wt(n,e,t={}){const{from:r,to:s,empty:o}=n.selection,i=e?ke(e,n.schema):null,l=[];n.doc.nodesBetween(r,s,(d,f)=>{if(d.isText)return;const h=Math.max(r,f),m=Math.min(s,f+d.nodeSize);l.push({node:d,from:h,to:m})});const a=s-r,c=l.filter(d=>i?i.name===d.node.type.name:!0).filter(d=>hs(d.node.attrs,t,{strict:!1}));return o?!!c.length:c.reduce((d,f)=>d+f.to-f.from,0)>=a}var u0=(n,e={})=>({state:t,dispatch:r})=>{const s=ke(n,t.schema);return Wt(t,s,e)?Ng(t,r):!1},d0=()=>({state:n,dispatch:e})=>pd(n,e),f0=n=>({state:e,dispatch:t})=>{const r=ke(n,e.schema);return $g(r)(e,t)},h0=()=>({state:n,dispatch:e})=>fd(n,e);function oo(n,e){return e.nodes[n]?"node":e.marks[n]?"mark":null}function ac(n,e){const t=typeof e=="string"?[e]:e;return Object.keys(n).reduce((r,s)=>(t.includes(s)||(r[s]=n[s]),r),{})}var p0=(n,e)=>({tr:t,state:r,dispatch:s})=>{let o=null,i=null;const l=oo(typeof n=="string"?n:n.name,r.schema);if(!l)return!1;l==="node"&&(o=ke(n,r.schema)),l==="mark"&&(i=Tt(n,r.schema));let a=!1;return t.selection.ranges.forEach(c=>{r.doc.nodesBetween(c.$from.pos,c.$to.pos,(u,d)=>{o&&o===u.type&&(a=!0,s&&t.setNodeMarkup(d,void 0,ac(u.attrs,e))),i&&u.marks.length&&u.marks.forEach(f=>{i===f.type&&(a=!0,s&&t.addMark(d,d+u.nodeSize,i.create(ac(f.attrs,e))))})})}),a},m0=()=>({tr:n,dispatch:e})=>(e&&n.scrollIntoView(),!0),g0=()=>({tr:n,dispatch:e})=>{if(e){const t=new Ue(n.doc);n.setSelection(t)}return!0},x0=()=>({state:n,dispatch:e})=>ad(n,e),y0=()=>({state:n,dispatch:e})=>dd(n,e),b0=()=>({state:n,dispatch:e})=>jg(n,e),k0=()=>({state:n,dispatch:e})=>Rg(n,e),S0=()=>({state:n,dispatch:e})=>Og(n,e);function gi(n,e,t={},r={}){return vr(n,e,{slice:!1,parseOptions:t,errorOnInvalidContent:r.errorOnInvalidContent})}var v0=(n,{errorOnInvalidContent:e,emitUpdate:t=!0,parseOptions:r={}}={})=>({editor:s,tr:o,dispatch:i,commands:l})=>{const{doc:a}=o;if(r.preserveWhitespace!=="full"){const c=gi(n,s.schema,r,{errorOnInvalidContent:e??s.options.enableContentCheck});return i&&o.replaceWith(0,a.content.size,c).setMeta("preventUpdate",!t),!0}return i&&o.setMeta("preventUpdate",!t),l.insertContentAt({from:0,to:a.content.size},n,{parseOptions:r,errorOnInvalidContent:e??s.options.enableContentCheck})};function of(n,e){const t=Tt(e,n.schema),{from:r,to:s,empty:o}=n.selection,i=[];o?(n.storedMarks&&i.push(...n.storedMarks),i.push(...n.selection.$head.marks())):n.doc.nodesBetween(r,s,a=>{i.push(...a.marks)});const l=i.find(a=>a.type.name===t.name);return l?{...l.attrs}:{}}function lf(n,e){const t=new nd(n);return e.forEach(r=>{r.steps.forEach(s=>{t.step(s)})}),t}function w0(n){for(let e=0;e<n.edgeCount;e+=1){const{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}function C0(n,e,t){const r=[];return n.nodesBetween(e.from,e.to,(s,o)=>{t(s)&&r.push({node:s,pos:o})}),r}function T0(n,e){for(let t=n.depth;t>0;t-=1){const r=n.node(t);if(e(r))return{pos:t>0?n.before(t):0,start:n.start(t),depth:t,node:r}}}function io(n){return e=>T0(e.$from,n)}function H(n,e,t){return n.config[e]===void 0&&n.parent?H(n.parent,e,t):typeof n.config[e]=="function"?n.config[e].bind({...t,parent:n.parent?H(n.parent,e,t):null}):n.config[e]}function kl(n){return n.map(e=>{const t={name:e.name,options:e.options,storage:e.storage},r=H(e,"addExtensions",t);return r?[e,...kl(r())]:e}).flat(10)}function Sl(n,e){const t=Sn.fromSchema(e).serializeFragment(n),s=document.implementation.createHTMLDocument().createElement("div");return s.appendChild(t),s.innerHTML}function af(n){return typeof n=="function"}function oe(n,e=void 0,...t){return af(n)?e?n.bind(e)(...t):n(...t):n}function N0(n={}){return Object.keys(n).length===0&&n.constructor===Object}function $n(n){const e=n.filter(s=>s.type==="extension"),t=n.filter(s=>s.type==="node"),r=n.filter(s=>s.type==="mark");return{baseExtensions:e,nodeExtensions:t,markExtensions:r}}function cf(n){const e=[],{nodeExtensions:t,markExtensions:r}=$n(n),s=[...t,...r],o={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},i=t.filter(c=>c.name!=="text").map(c=>c.name),l=r.map(c=>c.name),a=[...i,...l];return n.forEach(c=>{const u={name:c.name,options:c.options,storage:c.storage,extensions:s},d=H(c,"addGlobalAttributes",u);if(!d)return;d().forEach(h=>{let m;Array.isArray(h.types)?m=h.types:h.types==="*"?m=a:h.types==="nodes"?m=i:h.types==="marks"?m=l:m=[],m.forEach(g=>{Object.entries(h.attributes).forEach(([x,y])=>{e.push({type:g,name:x,attribute:{...o,...y}})})})})}),s.forEach(c=>{const u={name:c.name,options:c.options,storage:c.storage},d=H(c,"addAttributes",u);if(!d)return;const f=d();Object.entries(f).forEach(([h,m])=>{const g={...o,...m};typeof g?.default=="function"&&(g.default=g.default()),g?.isRequired&&g?.default===void 0&&delete g.default,e.push({type:c.name,name:h,attribute:g})})}),e}function M0(n){const e=[];let t="",r=!1,s=!1,o=0;const i=n.length;for(let l=0;l<i;l+=1){const a=n[l];if(a==="'"&&!s){r=!r,t+=a;continue}if(a==='"'&&!r){s=!s,t+=a;continue}if(!r&&!s){if(a==="("){o+=1,t+=a;continue}if(a===")"&&o>0){o-=1,t+=a;continue}if(a===";"&&o===0){e.push(t),t="";continue}}t+=a}return t&&e.push(t),e}function cc(n){const e=[],t=M0(n||""),r=t.length;for(let s=0;s<r;s+=1){const o=t[s],i=o.indexOf(":");if(i===-1)continue;const l=o.slice(0,i).trim(),a=o.slice(i+1).trim();l&&a&&e.push([l,a])}return e}function Se(...n){return n.filter(e=>!!e).reduce((e,t)=>{const r={...e};return Object.entries(t).forEach(([s,o])=>{if(!r[s]){r[s]=o;return}if(s==="class"){const l=o?String(o).split(" "):[],a=r[s]?r[s].split(" "):[],c=l.filter(u=>!a.includes(u));r[s]=[...a,...c].join(" ")}else if(s==="style"){const l=new Map([...cc(r[s]),...cc(o)]);r[s]=Array.from(l.entries()).map(([a,c])=>`${a}: ${c}`).join("; ")}else r[s]=o}),r},{})}function zn(n,e){return e.filter(t=>t.type===n.type.name).filter(t=>t.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(n.attrs)||{}:{[t.name]:n.attrs[t.name]}).reduce((t,r)=>Se(t,r),{})}function E0(n){return typeof n!="string"?n:n.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(n):n==="true"?!0:n==="false"?!1:n}function uc(n,e){return"style"in n?n:{...n,getAttrs:t=>{const r=n.getAttrs?n.getAttrs(t):n.attrs;if(r===!1)return!1;const s=e.reduce((o,i)=>{const l=i.attribute.parseHTML?i.attribute.parseHTML(t):E0(t.getAttribute(i.name));return l==null?o:{...o,[i.name]:l}},{});return{...r,...s}}}}function dc(n){return Object.fromEntries(Object.entries(n).filter(([e,t])=>e==="attrs"&&N0(t)?!1:t!=null))}function fc(n){var e,t;const r={};return!((e=n?.attribute)!=null&&e.isRequired)&&"default"in(n?.attribute||{})&&(r.default=n.attribute.default),((t=n?.attribute)==null?void 0:t.validate)!==void 0&&(r.validate=n.attribute.validate),[n.name,r]}function A0(n,e){var t;const r=cf(n),{nodeExtensions:s,markExtensions:o}=$n(n),i=(t=s.find(c=>H(c,"topNode")))==null?void 0:t.name,l=Object.fromEntries(s.map(c=>{const u=r.filter(y=>y.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:e},f=n.reduce((y,b)=>{const k=H(b,"extendNodeSchema",d);return{...y,...k?k(c):{}}},{}),h=dc({...f,content:oe(H(c,"content",d)),marks:oe(H(c,"marks",d)),group:oe(H(c,"group",d)),inline:oe(H(c,"inline",d)),atom:oe(H(c,"atom",d)),selectable:oe(H(c,"selectable",d)),draggable:oe(H(c,"draggable",d)),code:oe(H(c,"code",d)),whitespace:oe(H(c,"whitespace",d)),linebreakReplacement:oe(H(c,"linebreakReplacement",d)),defining:oe(H(c,"defining",d)),isolating:oe(H(c,"isolating",d)),attrs:Object.fromEntries(u.map(fc))}),m=oe(H(c,"parseHTML",d));m&&(h.parseDOM=m.map(y=>uc(y,u)));const g=H(c,"renderHTML",d);g&&(h.toDOM=y=>g({node:y,HTMLAttributes:zn(y,u)}));const x=H(c,"renderText",d);return x&&(h.toText=x),[c.name,h]})),a=Object.fromEntries(o.map(c=>{const u=r.filter(x=>x.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:e},f=n.reduce((x,y)=>{const b=H(y,"extendMarkSchema",d);return{...x,...b?b(c):{}}},{}),h=dc({...f,inclusive:oe(H(c,"inclusive",d)),excludes:oe(H(c,"excludes",d)),group:oe(H(c,"group",d)),spanning:oe(H(c,"spanning",d)),code:oe(H(c,"code",d)),attrs:Object.fromEntries(u.map(fc))}),m=oe(H(c,"parseHTML",d));m&&(h.parseDOM=m.map(x=>uc(x,u)));const g=H(c,"renderHTML",d);return g&&(h.toDOM=x=>g({mark:x,HTMLAttributes:zn(x,u)})),[c.name,h]}));return new Bu({topNode:i,nodes:l,marks:a})}function j0(n){const e=n.filter((t,r)=>n.indexOf(t)!==r);return Array.from(new Set(e))}function lr(n){return n.sort((t,r)=>{const s=H(t,"priority")||100,o=H(r,"priority")||100;return s>o?-1:s<o?1:0})}function uf(n){const e=lr(kl(n)),t=j0(e.map(r=>r.name));return t.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${t.map(r=>`'${r}'`).join(", ")}]. This can lead to issues.`),e}function df(n,e,t){const{from:r,to:s}=e,{blockSeparator:o=`
11
+
12
+ `,textSerializers:i={}}=t||{};let l="";return n.nodesBetween(r,s,(a,c,u,d)=>{var f;a.isBlock&&c>r&&(l+=o);const h=i?.[a.type.name];if(h)return u&&(l+=h({node:a,pos:c,parent:u,index:d,range:e})),!1;a.isText&&(l+=(f=a?.text)==null?void 0:f.slice(Math.max(r,c)-c,s-c))}),l}function I0(n,e){const t={from:0,to:n.content.size};return df(n,t,e)}function ff(n){return Object.fromEntries(Object.entries(n.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}function O0(n,e){const t=ke(e,n.schema),{from:r,to:s}=n.selection,o=[];n.doc.nodesBetween(r,s,l=>{o.push(l)});const i=o.reverse().find(l=>l.type.name===t.name);return i?{...i.attrs}:{}}function hf(n,e){const t=oo(typeof e=="string"?e:e.name,n.schema);return t==="node"?O0(n,e):t==="mark"?of(n,e):{}}function R0(n,e=JSON.stringify){const t={};return n.filter(r=>{const s=e(r);return Object.prototype.hasOwnProperty.call(t,s)?!1:t[s]=!0})}function D0(n){const e=R0(n);return e.length===1?e:e.filter((t,r)=>!e.filter((o,i)=>i!==r).some(o=>t.oldRange.from>=o.oldRange.from&&t.oldRange.to<=o.oldRange.to&&t.newRange.from>=o.newRange.from&&t.newRange.to<=o.newRange.to))}function pf(n){const{mapping:e,steps:t}=n,r=[];return e.maps.forEach((s,o)=>{const i=[];if(s.ranges.length)s.forEach((l,a)=>{i.push({from:l,to:a})});else{const{from:l,to:a}=t[o];if(l===void 0||a===void 0)return;i.push({from:l,to:a})}i.forEach(({from:l,to:a})=>{const c=e.slice(o).map(l,-1),u=e.slice(o).map(a),d=e.invert().map(c,-1),f=e.invert().map(u);r.push({oldRange:{from:d,to:f},newRange:{from:c,to:u}})})}),D0(r)}function vl(n,e,t){const r=[];return n===e?t.resolve(n).marks().forEach(s=>{const o=t.resolve(n),i=bl(o,s.type);i&&r.push({mark:s,...i})}):t.nodesBetween(n,e,(s,o)=>{!s||s?.nodeSize===void 0||r.push(...s.marks.map(i=>({from:o,to:o+s.nodeSize,mark:i})))}),r}var P0=(n,e,t,r=20)=>{const s=n.doc.resolve(t);let o=r,i=null;for(;o>0&&i===null;){const l=s.node(o);l?.type.name===e?i=l:o-=1}return[i,o]};function Jn(n,e){return e.nodes[n]||e.marks[n]||null}function Xr(n,e,t){return Object.fromEntries(Object.entries(t).filter(([r])=>{const s=n.find(o=>o.type===e&&o.name===r);return s?s.attribute.keepOnSplit:!1}))}var L0=(n,e=500)=>{let t="";const r=n.parentOffset;return n.parent.nodesBetween(Math.max(0,r-e),r,(s,o,i,l)=>{var a,c;const u=((c=(a=s.type.spec).toText)==null?void 0:c.call(a,{node:s,pos:o,parent:i,index:l}))||s.textContent||"%leaf%";t+=s.isAtom&&!s.isText?u:u.slice(0,Math.max(0,r-o))}),t};function xi(n,e,t={}){const{empty:r,ranges:s}=n.selection,o=e?Tt(e,n.schema):null;if(r)return!!(n.storedMarks||n.selection.$from.marks()).filter(d=>o?o.name===d.type.name:!0).find(d=>hs(d.attrs,t,{strict:!1}));let i=0;const l=[];if(s.forEach(({$from:d,$to:f})=>{const h=d.pos,m=f.pos;n.doc.nodesBetween(h,m,(g,x)=>{if(o&&g.inlineContent&&!g.type.allowsMarkType(o))return!1;if(!g.isText&&!g.marks.length)return;const y=Math.max(h,x),b=Math.min(m,x+g.nodeSize),k=b-y;i+=k,l.push(...g.marks.map(S=>({mark:S,from:y,to:b})))})}),i===0)return!1;const a=l.filter(d=>o?o.name===d.mark.type.name:!0).filter(d=>hs(d.mark.attrs,t,{strict:!1})).reduce((d,f)=>d+f.to-f.from,0),c=l.filter(d=>o?d.mark.type!==o&&d.mark.type.excludes(o):!0).reduce((d,f)=>d+f.to-f.from,0);return(a>0?a+c:a)>=i}function _0(n,e,t={}){if(!e)return Wt(n,null,t)||xi(n,null,t);const r=oo(e,n.schema);return r==="node"?Wt(n,e,t):r==="mark"?xi(n,e,t):!1}var $0=(n,e)=>{const{$from:t,$to:r,$anchor:s}=n.selection;if(e){const o=io(l=>l.type.name===e)(n.selection);if(!o)return!1;const i=n.doc.resolve(o.pos+1);return s.pos+1===i.end()}return!(r.parentOffset<r.parent.nodeSize-2||t.pos!==r.pos)},z0=n=>{const{$from:e,$to:t}=n.selection;return!(e.parentOffset>0||e.pos!==t.pos)};function hc(n,e){return Array.isArray(e)?e.some(t=>(typeof t=="string"?t:t.name)===n.name):e}function pc(n,e){const{nodeExtensions:t}=$n(e),r=t.find(i=>i.name===n);if(!r)return!1;const s={name:r.name,options:r.options,storage:r.storage},o=oe(H(r,"group",s));return typeof o!="string"?!1:o.split(" ").includes("list")}function lo(n,{checkChildren:e=!0,ignoreWhitespace:t=!1}={}){var r;if(t){if(n.type.name==="hardBreak")return!0;if(n.isText)return/^\s*$/m.test((r=n.text)!=null?r:"")}if(n.isText)return!n.text;if(n.isAtom||n.isLeaf)return!1;if(n.content.childCount===0)return!0;if(e){let s=!0;return n.content.forEach(o=>{s!==!1&&(lo(o,{ignoreWhitespace:t,checkChildren:e})||(s=!1))}),s}return!1}function mf(n){return n instanceof V}var gf=class xf{constructor(e){this.position=e}static fromJSON(e){return new xf(e.position)}toJSON(){return{position:this.position}}};function B0(n,e){const t=e.mapping.mapResult(n.position);return{position:new gf(t.pos),mapResult:t}}function F0(n){return new gf(n)}function H0(n,e,t){var r;const{selection:s}=e;let o=null;if(tf(s)&&(o=s.$cursor),o){const l=(r=n.storedMarks)!=null?r:o.marks();return o.parent.type.allowsMarkType(t)&&(!!t.isInSet(l)||!l.some(c=>c.type.excludes(t)))}const{ranges:i}=s;return i.some(({$from:l,$to:a})=>{let c=l.depth===0?n.doc.inlineContent&&n.doc.type.allowsMarkType(t):!1;return n.doc.nodesBetween(l.pos,a.pos,(u,d,f)=>{if(c)return!1;if(u.isInline){const h=!f||f.type.allowsMarkType(t),m=!!t.isInSet(u.marks)||!u.marks.some(g=>g.type.excludes(t));c=h&&m}return!c}),c})}var V0=(n,e={})=>({tr:t,state:r,dispatch:s})=>{const{selection:o}=t,{empty:i,ranges:l}=o,a=Tt(n,r.schema);if(s)if(i){const c=of(r,a);t.addStoredMark(a.create({...c,...e}))}else l.forEach(c=>{const u=c.$from.pos,d=c.$to.pos;r.doc.nodesBetween(u,d,(f,h)=>{const m=Math.max(h,u),g=Math.min(h+f.nodeSize,d);f.marks.find(y=>y.type===a)?f.marks.forEach(y=>{a===y.type&&t.addMark(m,g,a.create({...y.attrs,...e}))}):t.addMark(m,g,a.create(e))})});return H0(r,t,a)},W0=(n,e)=>({tr:t})=>(t.setMeta(n,e),!0),U0=(n,e={})=>({state:t,dispatch:r,chain:s})=>{const o=ke(n,t.schema);let i;return t.selection.$anchor.sameParent(t.selection.$head)&&(i=t.selection.$anchor.parent.attrs),o.isTextblock?s().command(({commands:l})=>Ma(o,{...i,...e})(t)?!0:l.clearNodes()).command(({state:l})=>Ma(o,{...i,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},q0=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,s=nn(n,0,r.content.size),o=V.create(r,s);e.setSelection(o)}return!0},K0=(n,e)=>({tr:t,state:r,dispatch:s})=>{const{selection:o}=r;let i,l;return typeof e=="number"?(i=e,l=e):e&&"from"in e&&"to"in e?(i=e.from,l=e.to):(i=o.from,l=o.to),s&&t.doc.nodesBetween(i,l,(a,c)=>{a.isText||t.setNodeMarkup(c,void 0,{...a.attrs,dir:n})}),!0},J0=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,{from:s,to:o}=typeof n=="number"?{from:n,to:n}:n,i=q.atStart(r).from,l=q.atEnd(r).to,a=nn(s,i,l),c=nn(o,i,l),u=q.create(r,a,c);e.setSelection(u)}return!0},G0=n=>({state:e,dispatch:t})=>{const r=ke(n,e.schema);return Fg(r)(e,t)};function mc(n,e){const t=n.storedMarks||n.selection.$to.parentOffset&&n.selection.$from.marks();if(t){const r=t.filter(s=>e?.includes(s.type.name));n.tr.ensureMarks(r)}}var X0=({keepMarks:n=!0}={})=>({tr:e,state:t,dispatch:r,editor:s})=>{const{selection:o,doc:i}=e,{$from:l,$to:a}=o,c=s.extensionManager.attributes,u=Xr(c,l.node().type.name,l.node().attrs);if(o instanceof V&&o.node.isBlock)return!l.parentOffset||!vt(i,l.pos)?!1:(r&&(n&&mc(t,s.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const d=a.parentOffset===a.parent.content.size,f=l.depth===0?void 0:w0(l.node(-1).contentMatchAt(l.indexAfter(-1)));let h=d&&f?[{type:f,attrs:u}]:void 0,m=vt(e.doc,e.mapping.map(l.pos),1,h);if(!h&&!m&&vt(e.doc,e.mapping.map(l.pos),1,f?[{type:f}]:void 0)&&(m=!0,h=f?[{type:f,attrs:u}]:void 0),r){if(m&&(o instanceof q&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,h),f&&!d&&!l.parentOffset&&l.parent.type!==f)){const g=e.mapping.map(l.before()),x=e.doc.resolve(g);l.node(-1).canReplaceWith(x.index(),x.index()+1,f)&&e.setNodeMarkup(e.mapping.map(l.before()),f)}n&&mc(t,s.extensionManager.splittableMarks),e.scrollIntoView()}return m},Y0=(n,e={})=>({tr:t,state:r,dispatch:s,editor:o})=>{var i;const l=ke(n,r.schema),{$from:a,$to:c}=r.selection,u=r.selection.node;if(u&&u.isBlock||a.depth<2||!a.sameParent(c))return!1;const d=a.node(-1);if(d.type!==l)return!1;const f=o.extensionManager.attributes;if(a.parent.content.size===0&&a.node(-1).childCount===a.indexAfter(-1)){if(a.depth===2||a.node(-3).type!==l||a.index(-2)!==a.node(-2).childCount-1)return!1;if(s){let y=O.empty;const b=a.index(-1)?1:a.index(-2)?2:3;for(let T=a.depth-b;T>=a.depth-3;T-=1)y=O.from(a.node(T).copy(y));const k=a.indexAfter(-1)<a.node(-2).childCount?1:a.indexAfter(-2)<a.node(-3).childCount?2:3,S={...Xr(f,a.node().type.name,a.node().attrs),...e},v=((i=l.contentMatch.defaultType)==null?void 0:i.createAndFill(S))||void 0;y=y.append(O.from(l.createAndFill(null,v)||void 0));const w=a.before(a.depth-(b-1));t.replace(w,a.after(-k),new B(y,4-b,0));let C=-1;t.doc.nodesBetween(w,t.doc.content.size,(T,N)=>{if(C>-1)return!1;T.isTextblock&&T.content.size===0&&(C=N+1)}),C>-1&&t.setSelection(q.near(t.doc.resolve(C))),t.scrollIntoView()}return!0}const h=c.pos===a.end()?d.contentMatchAt(0).defaultType:null,m={...Xr(f,d.type.name,d.attrs),...e},g={...Xr(f,a.node().type.name,a.node().attrs),...e};t.delete(a.pos,c.pos);const x=h?[{type:l,attrs:m},{type:h,attrs:g}]:[{type:l,attrs:m}];if(!vt(t.doc,a.pos,2))return!1;if(s){const{selection:y,storedMarks:b}=r,{splittableMarks:k}=o.extensionManager,S=b||y.$to.parentOffset&&y.$from.marks();if(t.split(a.pos,2,x).scrollIntoView(),!S||!s)return!0;const v=S.filter(w=>k.includes(w.type.name));t.ensureMarks(v)}return!0},Po=(n,e)=>{const t=io(i=>i.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(Math.max(0,t.pos-1)).before(t.depth);if(r===void 0)return!0;const s=n.doc.nodeAt(r);return t.node.type===s?.type&&Kt(n.doc,t.pos)&&n.join(t.pos),!0},Lo=(n,e)=>{const t=io(i=>i.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(t.start).after(t.depth);if(r===void 0)return!0;const s=n.doc.nodeAt(r);return t.node.type===s?.type&&Kt(n.doc,r)&&n.join(r),!0},Q0=(n,e,t,r={})=>({editor:s,tr:o,state:i,dispatch:l,chain:a,commands:c,can:u})=>{const{extensions:d,splittableMarks:f}=s.extensionManager,h=ke(n,i.schema),m=ke(e,i.schema),{selection:g,storedMarks:x}=i,{$from:y,$to:b}=g,k=y.blockRange(b),S=x||g.$to.parentOffset&&g.$from.marks();if(!k)return!1;const v=io(w=>pc(w.type.name,d))(g);if(k.depth>=1&&v&&k.depth-v.depth<=1){if(v.node.type===h)return c.liftListItem(m);if(pc(v.node.type.name,d)&&h.validContent(v.node.content)&&l)return a().command(()=>(o.setNodeMarkup(v.pos,h),!0)).command(()=>Po(o,h)).command(()=>Lo(o,h)).run()}return!t||!S||!l?a().command(()=>u().wrapInList(h,r)?!0:c.clearNodes()).wrapInList(h,r).command(()=>Po(o,h)).command(()=>Lo(o,h)).run():a().command(()=>{const w=u().wrapInList(h,r),C=S.filter(T=>f.includes(T.type.name));return o.ensureMarks(C),w?!0:c.clearNodes()}).wrapInList(h,r).command(()=>Po(o,h)).command(()=>Lo(o,h)).run()},Z0=(n,e={},t={})=>({state:r,commands:s})=>{const{extendEmptyMarkRange:o=!1}=t,i=Tt(n,r.schema);return xi(r,i,e)?s.unsetMark(i,{extendEmptyMarkRange:o}):s.setMark(i,e)},ey=(n,e,t={})=>({state:r,commands:s})=>{const o=ke(n,r.schema),i=ke(e,r.schema),l=Wt(r,o,t);let a;return r.selection.$anchor.sameParent(r.selection.$head)&&(a=r.selection.$anchor.parent.attrs),l?s.setNode(i,a):s.setNode(o,{...a,...t})},ty=(n,e={})=>({state:t,commands:r})=>{const s=ke(n,t.schema);return Wt(t,s,e)?r.lift(s):r.wrapIn(s,e)},ny=()=>({state:n,dispatch:e})=>{const t=n.plugins;for(let r=0;r<t.length;r+=1){const s=t[r];let o;if(s.spec.isInputRules&&(o=s.getState(n))){if(e){const i=n.tr,l=o.transform;for(let a=l.steps.length-1;a>=0;a-=1)i.step(l.steps[a].invert(l.docs[a]));if(o.text){const a=i.doc.resolve(o.from).marks();i.replaceWith(o.from,o.to,n.schema.text(o.text,a))}else i.delete(o.from,o.to)}return!0}}return!1},ry=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,{empty:r,ranges:s}=t;return r||e&&s.forEach(o=>{n.removeMark(o.$from.pos,o.$to.pos)}),!0},sy=(n,e={})=>({tr:t,state:r,dispatch:s})=>{var o;const{extendEmptyMarkRange:i=!1}=e,{selection:l}=t,a=Tt(n,r.schema),{$from:c,empty:u,ranges:d}=l;if(!s)return!0;if(u&&i){let{from:f,to:h}=l;const m=(o=c.marks().find(x=>x.type===a))==null?void 0:o.attrs,g=bl(c,a,m);g&&(f=g.from,h=g.to),t.removeMark(f,h,a)}else d.forEach(f=>{t.removeMark(f.$from.pos,f.$to.pos,a)});return t.removeStoredMark(a),!0},oy=n=>({tr:e,state:t,dispatch:r})=>{const{selection:s}=t;let o,i;return typeof n=="number"?(o=n,i=n):n&&"from"in n&&"to"in n?(o=n.from,i=n.to):(o=s.from,i=s.to),r&&e.doc.nodesBetween(o,i,(l,a)=>{if(l.isText)return;const c={...l.attrs};delete c.dir,e.setNodeMarkup(a,void 0,c)}),!0},iy=(n,e={})=>({tr:t,state:r,dispatch:s})=>{let o=null,i=null;const l=oo(typeof n=="string"?n:n.name,r.schema);if(!l)return!1;l==="node"&&(o=ke(n,r.schema)),l==="mark"&&(i=Tt(n,r.schema));let a=!1;return t.selection.ranges.forEach(c=>{const u=c.$from.pos,d=c.$to.pos;let f,h,m,g;t.selection.empty?r.doc.nodesBetween(u,d,(x,y)=>{o&&o===x.type&&(a=!0,m=Math.max(y,u),g=Math.min(y+x.nodeSize,d),f=y,h=x)}):r.doc.nodesBetween(u,d,(x,y)=>{y<u&&o&&o===x.type&&(a=!0,m=Math.max(y,u),g=Math.min(y+x.nodeSize,d),f=y,h=x),y>=u&&y<=d&&(o&&o===x.type&&(a=!0,s&&t.setNodeMarkup(y,void 0,{...x.attrs,...e})),i&&x.marks.length&&x.marks.forEach(b=>{if(i===b.type&&(a=!0,s)){const k=Math.max(y,u),S=Math.min(y+x.nodeSize,d);t.addMark(k,S,i.create({...b.attrs,...e}))}}))}),h&&(f!==void 0&&s&&t.setNodeMarkup(f,void 0,{...h.attrs,...e}),i&&h.marks.length&&h.marks.forEach(x=>{i===x.type&&s&&t.addMark(m,g,i.create({...x.attrs,...e}))}))}),a},ly=(n,e={})=>({state:t,dispatch:r})=>{const s=ke(n,t.schema);return Dg(s,e)(t,r)},ay=(n,e={})=>({state:t,dispatch:r})=>{const s=ke(n,t.schema);return Pg(s,e)(t,r)},cy=class{constructor(){this.callbacks={}}on(n,e){return this.callbacks[n]||(this.callbacks[n]=[]),this.callbacks[n].push(e),this}emit(n,...e){const t=this.callbacks[n];return t&&t.forEach(r=>r.apply(this,e)),this}off(n,e){const t=this.callbacks[n];return t&&(e?this.callbacks[n]=t.filter(r=>r!==e):delete this.callbacks[n]),this}once(n,e){const t=(...r)=>{this.off(n,t),e.apply(this,r)};return this.on(n,t)}removeAllListeners(){this.callbacks={}}},ao=class{constructor(n){var e;this.find=n.find,this.handler=n.handler,this.undoable=(e=n.undoable)!=null?e:!0}},uy=(n,e)=>{if(yl(e))return e.exec(n);const t=e(n);if(!t)return null;const r=[t.text];return r.index=t.index,r.input=n,r.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(t.replaceWith)),r};function $r(n){var e;const{editor:t,from:r,to:s,text:o,rules:i,plugin:l}=n,{view:a}=t;if(a.composing)return!1;const c=a.state.doc.resolve(r);if(c.parent.type.spec.code||(e=c.nodeBefore||c.nodeAfter)!=null&&e.marks.find(f=>f.type.spec.code))return!1;let u=!1;const d=L0(c)+o;return i.forEach(f=>{if(u)return;const h=uy(d,f.find);if(!h)return;const m=a.state.tr,g=ro({state:a.state,transaction:m}),x={from:r-(h[0].length-o.length),to:s},{commands:y,chain:b,can:k}=new so({editor:t,state:g});f.handler({state:g,range:x,match:h,commands:y,chain:b,can:k})===null||!m.steps.length||(f.undoable&&m.setMeta(l,{transform:m,from:r,to:s,text:o}),a.dispatch(m),u=!0)}),u}function dy(n){const{editor:e,rules:t}=n,r=new fe({state:{init(){return null},apply(s,o,i){const l=s.getMeta(r);if(l)return l;const a=s.getMeta("applyInputRules");return a&&setTimeout(()=>{let{text:u}=a;typeof u=="string"?u=u:u=Sl(O.from(u),i.schema);const{from:d}=a,f=d+u.length;$r({editor:e,from:d,to:f,text:u,rules:t,plugin:r})}),s.selectionSet||s.docChanged?null:o}},props:{handleTextInput(s,o,i,l){return $r({editor:e,from:o,to:i,text:l,rules:t,plugin:r})},handleDOMEvents:{compositionend:s=>(setTimeout(()=>{const{$cursor:o}=s.state.selection;o&&$r({editor:e,from:o.pos,to:o.pos,text:"",rules:t,plugin:r})}),!1)},handleKeyDown(s,o){if(o.key!=="Enter")return!1;const{$cursor:i}=s.state.selection;return i?$r({editor:e,from:i.pos,to:i.pos,text:`
13
+ `,rules:t,plugin:r}):!1}},isInputRules:!0});return r}function fy(n){return Object.prototype.toString.call(n).slice(8,-1)}function zr(n){return fy(n)!=="Object"?!1:n.constructor===Object&&Object.getPrototypeOf(n)===Object.prototype}function yf(n,e){const t={...n};return zr(n)&&zr(e)&&Object.keys(e).forEach(r=>{zr(e[r])&&zr(n[r])?t[r]=yf(n[r],e[r]):t[r]=e[r]}),t}var wl=class{constructor(n={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...n},this.name=this.config.name}get options(){return{...oe(H(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...oe(H(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(n={}){const e=this.extend({...this.config,addOptions:()=>yf(this.options,n)});return e.name=this.name,e.parent=this.parent,e}extend(n={}){const e=new this.constructor({...this.config,...n});return e.parent=this,this.child=e,e.name="name"in n?n.name:e.parent.name,e}},vn=class bf extends wl{constructor(){super(...arguments),this.type="mark"}static create(e={}){const t=typeof e=="function"?e():e;return new bf(t)}static handleExit({editor:e,mark:t}){const{tr:r}=e.state,s=e.state.selection.$from;if(s.pos===s.end()){const i=s.marks();if(!!!i.find(c=>c?.type.name===t.name))return!1;const a=i.find(c=>c?.type.name===t.name);return a&&r.removeStoredMark(a),r.insertText(" ",s.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}};function hy(n){return typeof n=="number"}var py=class{constructor(n){this.find=n.find,this.handler=n.handler}},my=(n,e,t)=>{if(yl(e))return[...n.matchAll(e)];const r=e(n,t);return r?r.map(s=>{const o=[s.text];return o.index=s.index,o.input=n,o.data=s.data,s.replaceWith&&(s.text.includes(s.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),o.push(s.replaceWith)),o}):[]};function gy(n){const{editor:e,state:t,from:r,to:s,rule:o,pasteEvent:i,dropEvent:l}=n,{commands:a,chain:c,can:u}=new so({editor:e,state:t}),d=[];return t.doc.nodesBetween(r,s,(h,m)=>{var g,x,y,b,k;if((x=(g=h.type)==null?void 0:g.spec)!=null&&x.code||!(h.isText||h.isTextblock||h.isInline))return;const S=(k=(b=(y=h.content)==null?void 0:y.size)!=null?b:h.nodeSize)!=null?k:0,v=Math.max(r,m),w=Math.min(s,m+S);if(v>=w)return;const C=h.isText?h.text||"":h.textBetween(v-m,w-m,void 0,"");my(C,o.find,i).forEach(N=>{if(N.index===void 0)return;const M=v+N.index+1,j=M+N[0].length,R={from:t.tr.mapping.map(M),to:t.tr.mapping.map(j)},A=o.handler({state:t,range:R,match:N,commands:a,chain:c,can:u,pasteEvent:i,dropEvent:l});d.push(A)})}),d.every(h=>h!==null)}var Br=null,xy=n=>{var e;const t=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=t.clipboardData)==null||e.setData("text/html",n),t};function yy(n){const{editor:e,rules:t}=n;let r=null,s=!1,o=!1,i=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}const a=({state:u,from:d,to:f,rule:h,pasteEvt:m})=>{const g=u.tr,x=ro({state:u,transaction:g});if(!(!gy({editor:e,state:x,from:Math.max(d-1,0),to:f.b-1,rule:h,pasteEvent:m,dropEvent:l})||!g.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return i=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,g}};return t.map(u=>new fe({view(d){const f=m=>{var g;r=(g=d.dom.parentElement)!=null&&g.contains(m.target)?d.dom.parentElement:null,r&&(Br=e)},h=()=>{Br&&(Br=null)};return window.addEventListener("dragstart",f),window.addEventListener("dragend",h),{destroy(){window.removeEventListener("dragstart",f),window.removeEventListener("dragend",h)}}},props:{handleDOMEvents:{drop:(d,f)=>{if(o=r===d.dom.parentElement,l=f,!o){const h=Br;h?.isEditable&&setTimeout(()=>{const m=h.state.selection;m&&h.commands.deleteRange({from:m.from,to:m.to})},10)}return!1},paste:(d,f)=>{var h;const m=(h=f.clipboardData)==null?void 0:h.getData("text/html");return i=f,s=!!m?.includes("data-pm-slice"),!1}}},appendTransaction:(d,f,h)=>{const m=d[0],g=m.getMeta("uiEvent")==="paste"&&!s,x=m.getMeta("uiEvent")==="drop"&&!o,y=m.getMeta("applyPasteRules"),b=!!y;if(!g&&!x&&!b)return;if(b){let{text:v}=y;typeof v=="string"?v=v:v=Sl(O.from(v),h.schema);const{from:w}=y,C=w+v.length,T=xy(v);return a({rule:u,state:h,from:w,to:{b:C},pasteEvt:T})}const k=f.doc.content.findDiffStart(h.doc.content),S=f.doc.content.findDiffEnd(h.doc.content);if(!(!hy(k)||!S||k===S.b))return a({rule:u,state:h,from:k,to:S,pasteEvt:i})}}))}var co=class{constructor(n,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=n,this.extensions=uf(n),this.schema=A0(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((n,e)=>{const t={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Jn(e.name,this.schema)},r=H(e,"addCommands",t);return r?{...n,...r()}:n},{})}get plugins(){const{editor:n}=this;return lr([...this.extensions].reverse()).flatMap(r=>{const s={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:n,type:Jn(r.name,this.schema)},o=[],i=H(r,"addKeyboardShortcuts",s);let l={};if(r.type==="mark"&&H(r,"exitable",s)&&(l.ArrowRight=()=>vn.handleExit({editor:n,mark:r})),i){const f=Object.fromEntries(Object.entries(i()).map(([h,m])=>[h,()=>m({editor:n})]));l={...l,...f}}const a=Ix(l);o.push(a);const c=H(r,"addInputRules",s);if(hc(r,n.options.enableInputRules)&&c){const f=c();if(f&&f.length){const h=dy({editor:n,rules:f}),m=Array.isArray(h)?h:[h];o.push(...m)}}const u=H(r,"addPasteRules",s);if(hc(r,n.options.enablePasteRules)&&u){const f=u();if(f&&f.length){const h=yy({editor:n,rules:f});o.push(...h)}}const d=H(r,"addProseMirrorPlugins",s);if(d){const f=d();o.push(...f)}return o})}get attributes(){return cf(this.extensions)}get nodeViews(){const{editor:n}=this,{nodeExtensions:e}=$n(this.extensions);return Object.fromEntries(e.filter(t=>!!H(t,"addNodeView")).map(t=>{const r=this.attributes.filter(a=>a.type===t.name),s={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:n,type:ke(t.name,this.schema)},o=H(t,"addNodeView",s);if(!o)return[];const i=o();if(!i)return[];const l=(a,c,u,d,f)=>{const h=zn(a,r);return i({node:a,view:c,getPos:u,decorations:d,innerDecorations:f,editor:n,extension:t,HTMLAttributes:h})};return[t.name,l]}))}dispatchTransaction(n){const{editor:e}=this;return lr([...this.extensions].reverse()).reduceRight((r,s)=>{const o={name:s.name,options:s.options,storage:this.editor.extensionStorage[s.name],editor:e,type:Jn(s.name,this.schema)},i=H(s,"dispatchTransaction",o);return i?l=>{i.call(o,{transaction:l,next:r})}:r},n)}transformPastedHTML(n){const{editor:e}=this;return lr([...this.extensions]).reduce((r,s)=>{const o={name:s.name,options:s.options,storage:this.editor.extensionStorage[s.name],editor:e,type:Jn(s.name,this.schema)},i=H(s,"transformPastedHTML",o);return i?(l,a)=>{const c=r(l,a);return i.call(o,c)}:r},n||(r=>r))}get markViews(){const{editor:n}=this,{markExtensions:e}=$n(this.extensions);return Object.fromEntries(e.filter(t=>!!H(t,"addMarkView")).map(t=>{const r=this.attributes.filter(l=>l.type===t.name),s={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:n,type:Tt(t.name,this.schema)},o=H(t,"addMarkView",s);if(!o)return[];const i=(l,a,c)=>{const u=zn(l,r);return o()({mark:l,view:a,inline:c,editor:n,extension:t,HTMLAttributes:u,updateAttributes:d=>{Oy(l,n,d)}})};return[t.name,i]}))}setupExtensions(){const n=this.extensions;this.editor.extensionStorage=Object.fromEntries(n.map(e=>[e.name,e.storage])),n.forEach(e=>{var t;const r={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Jn(e.name,this.schema)};e.type==="mark"&&((t=oe(H(e,"keepOnSplit",r)))==null||t)&&this.splittableMarks.push(e.name);const s=H(e,"onBeforeCreate",r),o=H(e,"onCreate",r),i=H(e,"onUpdate",r),l=H(e,"onSelectionUpdate",r),a=H(e,"onTransaction",r),c=H(e,"onFocus",r),u=H(e,"onBlur",r),d=H(e,"onDestroy",r);s&&this.editor.on("beforeCreate",s),o&&this.editor.on("create",o),i&&this.editor.on("update",i),l&&this.editor.on("selectionUpdate",l),a&&this.editor.on("transaction",a),c&&this.editor.on("focus",c),u&&this.editor.on("blur",u),d&&this.editor.on("destroy",d)})}};co.resolve=uf;co.sort=lr;co.flatten=kl;var by={};xl(by,{ClipboardTextSerializer:()=>Sf,Commands:()=>vf,Delete:()=>wf,Drop:()=>Cf,Editable:()=>Tf,FocusEvents:()=>Mf,Keymap:()=>Ef,Paste:()=>Af,Tabindex:()=>jf,TextDirection:()=>If,focusEventsPluginKey:()=>Nf});var xe=class kf extends wl{constructor(){super(...arguments),this.type="extension"}static create(e={}){const t=typeof e=="function"?e():e;return new kf(t)}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}},Sf=xe.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new fe({key:new ve("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:n}=this,{state:e,schema:t}=n,{doc:r,selection:s}=e,{ranges:o}=s,i=Math.min(...o.map(u=>u.$from.pos)),l=Math.max(...o.map(u=>u.$to.pos)),a=ff(t);return df(r,{from:i,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:a})}}})]}}),vf=xe.create({name:"commands",addCommands(){return{...Zd}}}),wf=xe.create({name:"delete",onUpdate({transaction:n,appendedTransactions:e}){var t,r,s;const o=()=>{var i,l,a,c;if((c=(a=(l=(i=this.editor.options.coreExtensionOptions)==null?void 0:i.delete)==null?void 0:l.filterTransaction)==null?void 0:a.call(l,n))!=null?c:n.getMeta("y-sync$"))return;const u=lf(n.before,[n,...e]);pf(u).forEach(h=>{u.mapping.mapResult(h.oldRange.from).deletedAfter&&u.mapping.mapResult(h.oldRange.to).deletedBefore&&u.before.nodesBetween(h.oldRange.from,h.oldRange.to,(m,g)=>{const x=g+m.nodeSize-2,y=h.oldRange.from<=g&&x<=h.oldRange.to;this.editor.emit("delete",{type:"node",node:m,from:g,to:x,newFrom:u.mapping.map(g),newTo:u.mapping.map(x),deletedRange:h.oldRange,newRange:h.newRange,partial:!y,editor:this.editor,transaction:n,combinedTransform:u})})});const f=u.mapping;u.steps.forEach((h,m)=>{var g,x;if(h instanceof rt){const y=f.slice(m).map(h.from,-1),b=f.slice(m).map(h.to),k=f.invert().map(y,-1),S=f.invert().map(b),v=(g=u.doc.nodeAt(y-1))==null?void 0:g.marks.some(C=>C.eq(h.mark)),w=(x=u.doc.nodeAt(b))==null?void 0:x.marks.some(C=>C.eq(h.mark));this.editor.emit("delete",{type:"mark",mark:h.mark,from:h.from,to:h.to,deletedRange:{from:k,to:S},newRange:{from:y,to:b},partial:!!(w||v),editor:this.editor,transaction:n,combinedTransform:u})}})};(s=(r=(t=this.editor.options.coreExtensionOptions)==null?void 0:t.delete)==null?void 0:r.async)==null||s?setTimeout(o,0):o()}}),Cf=xe.create({name:"drop",addProseMirrorPlugins(){return[new fe({key:new ve("tiptapDrop"),props:{handleDrop:(n,e,t,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:t,moved:r})}}})]}}),Tf=xe.create({name:"editable",addProseMirrorPlugins(){return[new fe({key:new ve("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Nf=new ve("focusEvents"),Mf=xe.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:n}=this;return[new fe({key:Nf,props:{handleDOMEvents:{focus:(e,t)=>{n.isFocused=!0;const r=n.state.tr.setMeta("focus",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,t)=>{n.isFocused=!1;const r=n.state.tr.setMeta("blur",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),Ef=xe.create({name:"keymap",addKeyboardShortcuts(){const n=()=>this.editor.commands.first(({commands:i})=>[()=>i.undoInputRule(),()=>i.command(({tr:l})=>{const{selection:a,doc:c}=l,{empty:u,$anchor:d}=a,{pos:f,parent:h}=d,m=d.parent.isTextblock&&f>0?l.doc.resolve(f-1):d,g=m.parent.type.spec.isolating,x=d.pos-d.parentOffset,y=g&&m.parent.childCount===1?x===d.pos:X.atStart(c).from===f;return!u||!h.type.isTextblock||h.textContent.length||!y||y&&d.parent.type.name==="paragraph"?!1:i.clearNodes()}),()=>i.deleteSelection(),()=>i.joinBackward(),()=>i.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:i})=>[()=>i.deleteSelection(),()=>i.deleteCurrentNode(),()=>i.joinForward(),()=>i.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:i})=>[()=>i.newlineInCode(),()=>i.createParagraphNear(),()=>i.liftEmptyBlock(),()=>i.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:n,"Mod-Backspace":n,"Shift-Backspace":n,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},s={...r},o={...r,"Ctrl-h":n,"Alt-Backspace":n,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Sr()||sf()?o:s},addProseMirrorPlugins(){return[new fe({key:new ve("clearDocument"),appendTransaction:(n,e,t)=>{if(n.some(g=>g.getMeta("composition")))return;const r=n.some(g=>g.docChanged)&&!e.doc.eq(t.doc),s=n.some(g=>g.getMeta("preventClearDocument"));if(!r||s)return;const{empty:o,from:i,to:l}=e.selection,a=X.atStart(e.doc).from,c=X.atEnd(e.doc).to;if(o||!(i===a&&l===c)||!lo(t.doc))return;const f=t.tr,h=ro({state:t,transaction:f}),{commands:m}=new so({editor:this.editor,state:h});if(m.clearNodes(),!!f.steps.length)return f}})]}}),Af=xe.create({name:"paste",addProseMirrorPlugins(){return[new fe({key:new ve("tiptapPaste"),props:{handlePaste:(n,e,t)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:t})}}})]}}),jf=xe.create({name:"tabindex",addProseMirrorPlugins(){return[new fe({key:new ve("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),If=xe.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:n}=$n(this.extensions);return[{types:n.filter(e=>e.name!=="text").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{const t=e.getAttribute("dir");return t&&(t==="ltr"||t==="rtl"||t==="auto")?t:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new fe({key:new ve("textDirection"),props:{attributes:()=>{const n=this.options.direction;return n?{dir:n}:{}}}})]}}),ky=class er{constructor(e,t,r=!1,s=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=t,this.currentNode=s}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!=null?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}t=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:t,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),t=this.resolvedPos.doc.resolve(e);return new er(t,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new er(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new er(e,this.editor)}get children(){const e=[];return this.node.content.forEach((t,r)=>{const s=t.isBlock&&!t.isTextblock,o=t.isAtom&&!t.isText,i=t.isInline,l=this.pos+r+(o?0:1);if(l<0||l>this.resolvedPos.doc.nodeSize-2)return;const a=this.resolvedPos.doc.resolve(l);if(!s&&!i&&a.depth<=this.depth)return;const c=new er(a,this.editor,s,s||i?t:null);s&&(c.actualDepth=this.depth+1),e.push(c)}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,t={}){let r=null,s=this.parent;for(;s&&!r;){if(s.node.type.name===e)if(Object.keys(t).length>0){const o=s.node.attrs,i=Object.keys(t);for(let l=0;l<i.length;l+=1){const a=i[l];if(o[a]!==t[a])break}}else r=s;s=s.parent}return r}querySelector(e,t={}){return this.querySelectorAll(e,t,!0)[0]||null}querySelectorAll(e,t={},r=!1){let s=[];if(!this.children||this.children.length===0)return s;const o=Object.keys(t);return this.children.forEach(i=>{r&&s.length>0||(i.node.type.name===e&&o.every(a=>t[a]===i.node.attrs[a])&&s.push(i),!(r&&s.length>0)&&(s=s.concat(i.querySelectorAll(e,t,r))))}),s}setAttribute(e){const{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}},Sy=`.ProseMirror {
14
+ position: relative;
15
+ }
16
+
17
+ .ProseMirror {
18
+ word-wrap: break-word;
19
+ white-space: pre-wrap;
20
+ white-space: break-spaces;
21
+ -webkit-font-variant-ligatures: none;
22
+ font-variant-ligatures: none;
23
+ font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
24
+ }
25
+
26
+ .ProseMirror [contenteditable="false"] {
27
+ white-space: normal;
28
+ }
29
+
30
+ .ProseMirror [contenteditable="false"] [contenteditable="true"] {
31
+ white-space: pre-wrap;
32
+ }
33
+
34
+ .ProseMirror pre {
35
+ white-space: pre-wrap;
36
+ }
37
+
38
+ img.ProseMirror-separator {
39
+ display: inline !important;
40
+ border: none !important;
41
+ margin: 0 !important;
42
+ width: 0 !important;
43
+ height: 0 !important;
44
+ }
45
+
46
+ .ProseMirror-gapcursor {
47
+ display: none;
48
+ pointer-events: none;
49
+ position: absolute;
50
+ margin: 0;
51
+ }
52
+
53
+ .ProseMirror-gapcursor:after {
54
+ content: "";
55
+ display: block;
56
+ position: absolute;
57
+ top: -2px;
58
+ width: 20px;
59
+ border-top: 1px solid black;
60
+ animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
61
+ }
62
+
63
+ @keyframes ProseMirror-cursor-blink {
64
+ to {
65
+ visibility: hidden;
66
+ }
67
+ }
68
+
69
+ .ProseMirror-hideselection *::selection {
70
+ background: transparent;
71
+ }
72
+
73
+ .ProseMirror-hideselection *::-moz-selection {
74
+ background: transparent;
75
+ }
76
+
77
+ .ProseMirror-hideselection * {
78
+ caret-color: transparent;
79
+ }
80
+
81
+ .ProseMirror-focused .ProseMirror-gapcursor {
82
+ display: block;
83
+ }`;function vy(n,e,t){const r=document.querySelector("style[data-tiptap-style]");if(r!==null)return r;const s=document.createElement("style");return e&&s.setAttribute("nonce",e),s.setAttribute("data-tiptap-style",""),s.innerHTML=n,document.getElementsByTagName("head")[0].appendChild(s),s}var wy=class extends cy{constructor(n={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:r})=>{throw r},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:B0,createMappablePosition:F0},this.setOptions(n),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:r,slice:s,moved:o})=>this.options.onDrop(r,s,o)),this.on("paste",({event:r,slice:s})=>this.options.onPaste(r,s)),this.on("delete",this.options.onDelete);const e=this.createDoc(),t=nf(e,this.options.autofocus);this.editorState=jn.create({doc:e,schema:this.schema,selection:t||void 0}),this.options.element&&this.mount(this.options.element)}mount(n){if(typeof document>"u")throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(n),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){const n=this.editorView.dom;n?.editor&&delete n.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove=="function"?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(n){console.warn("Failed to remove CSS element:",n)}this.css=null,this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&typeof document<"u"&&(this.css=vy(Sy,this.options.injectNonce))}setOptions(n={}){this.options={...this.options,...n},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(n,e=!0){this.setOptions({editable:n}),e&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:n=>{this.editorState=n},dispatch:n=>{this.dispatchTransaction(n)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(n,e)=>{if(this.editorView)return this.editorView[e];if(e==="state")return this.editorState;if(e in n)return Reflect.get(n,e);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${e}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(n,e){const t=af(e)?e(n,[...this.state.plugins]):[...this.state.plugins,n],r=this.state.reconfigure({plugins:t});return this.view.updateState(r),r}unregisterPlugin(n){if(this.isDestroyed)return;const e=this.state.plugins;let t=e;if([].concat(n).forEach(s=>{const o=typeof s=="string"?`${s}$`:s.key;t=t.filter(i=>!i.key.startsWith(o))}),e.length===t.length)return;const r=this.state.reconfigure({plugins:t});return this.view.updateState(r),r}createExtensionManager(){var n,e;const r=[...this.options.enableCoreExtensions?[Tf,Sf.configure({blockSeparator:(e=(n=this.options.coreExtensionOptions)==null?void 0:n.clipboardTextSerializer)==null?void 0:e.blockSeparator}),vf,Mf,Ef,jf,Cf,Af,wf,If.configure({direction:this.options.textDirection})].filter(s=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[s.name]!==!1:!0):[],...this.options.extensions].filter(s=>["extension","node","mark"].includes(s?.type));this.extensionManager=new co(r,this)}createCommandManager(){this.commandManager=new so({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let n;try{n=gi(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(e.message))throw e;this.emit("contentError",{editor:this,error:e,disableCollaboration:()=>{"collaboration"in this.storage&&typeof this.storage.collaboration=="object"&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(t=>t.name!=="collaboration"),this.createExtensionManager()}}),n=gi(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return n}createView(n){const{editorProps:e,enableExtensionDispatchTransaction:t}=this.options,r=e.dispatchTransaction||this.dispatchTransaction.bind(this),s=t?this.extensionManager.dispatchTransaction(r):r,o=e.transformPastedHTML,i=this.extensionManager.transformPastedHTML(o);this.editorView=new Yd(n,{...e,attributes:{role:"textbox",...e?.attributes},dispatchTransaction:s,transformPastedHTML:i,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const l=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(l),this.prependClass(),this.injectCSS();const a=this.view.dom;a.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(n){this.isCapturingTransaction=!0,n(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(n){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=n;return}n.steps.forEach(c=>{var u;return(u=this.capturedTransaction)==null?void 0:u.step(c)});return}const{state:e,transactions:t}=this.state.applyTransaction(n),r=!this.state.selection.eq(e.selection),s=t.includes(n),o=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:n,nextState:e}),!s)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:n,appendedTransactions:t.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:n});const i=t.findLast(c=>c.getMeta("focus")||c.getMeta("blur")),l=i?.getMeta("focus"),a=i?.getMeta("blur");l&&this.emit("focus",{editor:this,event:l.event,transaction:i}),a&&this.emit("blur",{editor:this,event:a.event,transaction:i}),!(n.getMeta("preventUpdate")||!t.some(c=>c.docChanged)||o.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:n,appendedTransactions:t.slice(1)})}getAttributes(n){return hf(this.state,n)}isActive(n,e){const t=typeof n=="string"?n:null,r=typeof n=="string"?e:n;return _0(this.state,t,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Sl(this.state.doc.content,this.schema)}getText(n){const{blockSeparator:e=`
84
+
85
+ `,textSerializers:t={}}=n||{};return I0(this.state.doc,{blockSeparator:e,textSerializers:{...ff(this.schema),...t}})}get isEmpty(){return lo(this.state.doc)}destroy(){this.emit("destroy"),this.unmount(),this.removeAllListeners()}get isDestroyed(){var n,e;return(e=(n=this.editorView)==null?void 0:n.isDestroyed)!=null?e:!0}$node(n,e){var t;return((t=this.$doc)==null?void 0:t.querySelector(n,e))||null}$nodes(n,e){var t;return((t=this.$doc)==null?void 0:t.querySelectorAll(n,e))||null}$pos(n){const e=this.state.doc.resolve(n);return new ky(e,this)}get $doc(){return this.$pos(0)}};function Bn(n){return new ao({find:n.find,handler:({state:e,range:t,match:r})=>{const s=oe(n.getAttributes,void 0,r);if(s===!1||s===null)return null;const{tr:o}=e,i=r[r.length-1],l=r[0];if(i){const a=l.search(/\S/),c=t.from+l.indexOf(i),u=c+i.length;if(vl(t.from,t.to,e.doc).filter(h=>h.mark.type.excluded.find(g=>g===n.type&&g!==h.mark.type)).filter(h=>h.to>c).length)return null;u<t.to&&o.delete(u,t.to),c>t.from&&o.delete(t.from+a,c);const f=t.from+a+i.length;o.addMark(t.from+a,f,n.type.create(s||{})),o.removeStoredMark(n.type)}},undoable:n.undoable})}function Cy(n){return new ao({find:n.find,handler:({state:e,range:t,match:r})=>{const s=oe(n.getAttributes,void 0,r)||{},{tr:o}=e,i=t.from;let l=t.to;const a=n.type.create(s);if(r[1]){const c=r[0].lastIndexOf(r[1]);let u=i+c;u>l?u=l:l=u+r[1].length;const d=r[0][r[0].length-1];o.insertText(d,i+r[0].length-1),o.replaceWith(u,l,a)}else if(r[0]){const c=n.type.isInline?i:i-1;o.insert(c,n.type.create(s)).delete(o.mapping.map(i),o.mapping.map(l))}o.scrollIntoView()},undoable:n.undoable})}function yi(n){return new ao({find:n.find,handler:({state:e,range:t,match:r})=>{const s=e.doc.resolve(t.from),o=oe(n.getAttributes,void 0,r)||{};if(!s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),n.type))return null;e.tr.delete(t.from,t.to).setBlockType(t.from,t.from,n.type,o)},undoable:n.undoable})}function Fn(n){return new ao({find:n.find,handler:({state:e,range:t,match:r,chain:s})=>{const o=oe(n.getAttributes,void 0,r)||{},i=e.tr.delete(t.from,t.to),a=i.doc.resolve(t.from).blockRange(),c=a&&tl(a,n.type,o);if(!c)return null;if(i.wrap(a,c),n.keepMarks&&n.editor){const{selection:d,storedMarks:f}=e,{splittableMarks:h}=n.editor.extensionManager,m=f||d.$to.parentOffset&&d.$from.marks();if(m){const g=m.filter(x=>h.includes(x.type.name));i.ensureMarks(g)}}if(n.keepAttributes){const d=n.type.name==="bulletList"||n.type.name==="orderedList"?"listItem":"taskList";s().updateAttributes(d,o).run()}const u=i.doc.resolve(t.from-1).nodeBefore;u&&u.type===n.type&&Kt(i.doc,t.from-1)&&(!n.joinPredicate||n.joinPredicate(r,u))&&i.join(t.from-1)},undoable:n.undoable})}function Ty(n,e){const{selection:t}=n,{$from:r}=t;if(t instanceof V){const o=r.index();return r.parent.canReplaceWith(o,o+1,e)}let s=r.depth;for(;s>=0;){const o=r.index(s);if(r.node(s).contentMatchAt(o).matchType(e))return!0;s-=1}return!1}function KC(n){return n.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}var Ny={};xl(Ny,{createAtomBlockMarkdownSpec:()=>My,createBlockMarkdownSpec:()=>Ey,createInlineMarkdownSpec:()=>Iy,parseAttributes:()=>Cl,parseIndentedBlocks:()=>bi,renderNestedMarkdownContent:()=>Nl,serializeAttributes:()=>Tl});function Cl(n){if(!n?.trim())return{};const e={},t=[],r=n.replace(/["']([^"']*)["']/g,c=>(t.push(c),`__QUOTED_${t.length-1}__`)),s=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(s){const c=s.map(u=>u.trim().slice(1));e.class=c.join(" ")}const o=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);o&&(e.id=o[1]);const i=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(i)).forEach(([,c,u])=>{var d;const f=parseInt(((d=u.match(/__QUOTED_(\d+)__/))==null?void 0:d[1])||"0",10),h=t[f];h&&(e[c]=h.slice(1,-1))});const a=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return a&&a.split(/\s+/).filter(Boolean).forEach(u=>{u.match(/^[a-zA-Z][\w-]*$/)&&(e[u]=!0)}),e}function Tl(n){if(!n||Object.keys(n).length===0)return"";const e=[];return n.class&&String(n.class).split(/\s+/).filter(Boolean).forEach(r=>e.push(`.${r}`)),n.id&&e.push(`#${n.id}`),Object.entries(n).forEach(([t,r])=>{t==="class"||t==="id"||(r===!0?e.push(t):r!==!1&&r!=null&&e.push(`${t}="${String(r)}"`))}),e.join(" ")}function My(n){const{nodeName:e,name:t,parseAttributes:r=Cl,serializeAttributes:s=Tl,defaultAttributes:o={},requiredAttributes:i=[],allowedAttributes:l}=n,a=t||e,c=u=>{if(!l)return u;const d={};return l.forEach(f=>{f in u&&(d[f]=u[f])}),d};return{parseMarkdown:(u,d)=>{const f={...o,...u.attributes};return d.createNode(e,f,[])},markdownTokenizer:{name:e,level:"block",start(u){var d;const f=new RegExp(`^:::${a}(?:\\s|$)`,"m"),h=(d=u.match(f))==null?void 0:d.index;return h!==void 0?h:-1},tokenize(u,d,f){const h=new RegExp(`^:::${a}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),m=u.match(h);if(!m)return;const g=m[1]||"",x=r(g);if(!i.find(b=>!(b in x)))return{type:e,raw:m[0],attributes:x}}},renderMarkdown:u=>{const d=c(u.attrs||{}),f=s(d),h=f?` {${f}}`:"";return`:::${a}${h} :::`}}}function Ey(n){const{nodeName:e,name:t,getContent:r,parseAttributes:s=Cl,serializeAttributes:o=Tl,defaultAttributes:i={},content:l="block",allowedAttributes:a}=n,c=t||e,u=d=>{if(!a)return d;const f={};return a.forEach(h=>{h in d&&(f[h]=d[h])}),f};return{parseMarkdown:(d,f)=>{let h;if(r){const g=r(d);h=typeof g=="string"?[{type:"text",text:g}]:g}else l==="block"?h=f.parseChildren(d.tokens||[]):h=f.parseInline(d.tokens||[]);const m={...i,...d.attributes};return f.createNode(e,m,h)},markdownTokenizer:{name:e,level:"block",start(d){var f;const h=new RegExp(`^:::${c}`,"m"),m=(f=d.match(h))==null?void 0:f.index;return m!==void 0?m:-1},tokenize(d,f,h){var m;const g=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),x=d.match(g);if(!x)return;const[y,b=""]=x,k=s(b);let S=1;const v=y.length;let w="";const C=/^:::([\w-]*)(\s.*)?/gm,T=d.slice(v);for(C.lastIndex=0;;){const N=C.exec(T);if(N===null)break;const M=N.index,j=N[1];if(!((m=N[2])!=null&&m.endsWith(":::"))){if(j)S+=1;else if(S-=1,S===0){const R=T.slice(0,M);w=R.trim();const A=d.slice(0,v+M+N[0].length);let D=[];if(w)if(l==="block")for(D=h.blockTokens(R),D.forEach(I=>{I.text&&(!I.tokens||I.tokens.length===0)&&(I.tokens=h.inlineTokens(I.text))});D.length>0;){const I=D[D.length-1];if(I.type==="paragraph"&&(!I.text||I.text.trim()===""))D.pop();else break}else D=h.inlineTokens(w);return{type:e,raw:A,attributes:k,content:w,tokens:D}}}}}},renderMarkdown:(d,f)=>{const h=u(d.attrs||{}),m=o(h),g=m?` {${m}}`:"",x=f.renderChildren(d.content||[],`
86
+
87
+ `);return`:::${c}${g}
88
+
89
+ ${x}
90
+
91
+ :::`}}}function Ay(n){if(!n.trim())return{};const e={},t=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=t.exec(n);for(;r!==null;){const[,s,o,i]=r;e[s]=o||i,r=t.exec(n)}return e}function jy(n){return Object.entries(n).filter(([,e])=>e!=null).map(([e,t])=>`${e}="${t}"`).join(" ")}function Iy(n){const{nodeName:e,name:t,getContent:r,parseAttributes:s=Ay,serializeAttributes:o=jy,defaultAttributes:i={},selfClosing:l=!1,allowedAttributes:a}=n,c=t||e,u=f=>{if(!a)return f;const h={};return a.forEach(m=>{const g=typeof m=="string"?m:m.name,x=typeof m=="string"?void 0:m.skipIfDefault;if(g in f){const y=f[g];if(x!==void 0&&y===x)return;h[g]=y}}),h},d=c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(f,h)=>{const m={...i,...f.attributes};if(l)return h.createNode(e,m);const g=r?r(f):f.content||"";return g?h.createNode(e,m,[h.createTextNode(g)]):h.createNode(e,m,[])},markdownTokenizer:{name:e,level:"inline",start(f){const h=l?new RegExp(`\\[${d}\\s*[^\\]]*\\]`):new RegExp(`\\[${d}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${d}\\]`),m=f.match(h),g=m?.index;return g!==void 0?g:-1},tokenize(f,h,m){const g=l?new RegExp(`^\\[${d}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${d}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${d}\\]`),x=f.match(g);if(!x)return;let y="",b="";if(l){const[,S]=x;b=S}else{const[,S,v]=x;b=S,y=v||""}const k=s(b.trim());return{type:e,raw:x[0],content:y.trim(),attributes:k}}},renderMarkdown:f=>{let h="";r?h=r(f):f.content&&f.content.length>0&&(h=f.content.filter(y=>y.type==="text").map(y=>y.text).join(""));const m=u(f.attrs||{}),g=o(m),x=g?` ${g}`:"";return l?`[${c}${x}]`:`[${c}${x}]${h}[/${c}]`}}}function bi(n,e,t){var r,s,o,i;const l=n.split(`
92
+ `),a=[];let c="",u=0;const d=e.baseIndentSize||2;for(;u<l.length;){const f=l[u],h=f.match(e.itemPattern);if(!h){if(a.length>0)break;if(f.trim()===""){u+=1,c=`${c}${f}
93
+ `;continue}else return}const m=e.extractItemData(h),{indentLevel:g,mainContent:x}=m;c=`${c}${f}
94
+ `;const y=[x];for(u+=1;u<l.length;){const v=l[u];if(v.trim()===""){const C=l.slice(u+1).findIndex(M=>M.trim()!=="");if(C===-1)break;if((((s=(r=l[u+1+C].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:s.length)||0)>g){y.push(v),c=`${c}${v}
95
+ `,u+=1;continue}else break}if((((i=(o=v.match(/^(\s*)/))==null?void 0:o[1])==null?void 0:i.length)||0)>g)y.push(v),c=`${c}${v}
96
+ `,u+=1;else break}let b;const k=y.slice(1);if(k.length>0){const v=k.map(w=>w.slice(g+d)).join(`
97
+ `);v.trim()&&(e.customNestedParser?b=e.customNestedParser(v):b=t.blockTokens(v))}const S=e.createToken(m,b);a.push(S)}if(a.length!==0)return{items:a,raw:c}}function Nl(n,e,t,r){if(!n||!Array.isArray(n.content))return"";const s=typeof t=="function"?t(r):t,[o,...i]=n.content,l=e.renderChildren([o]);let a=`${s}${l}`;return i&&i.length>0&&i.forEach((c,u)=>{var d,f;const h=(f=(d=e.renderChild)==null?void 0:d.call(e,c,u+1))!=null?f:e.renderChildren([c]);if(h!=null){const m=h.split(`
98
+ `).map(g=>g?e.indent(g):e.indent("")).join(`
99
+ `);a+=c.type==="paragraph"?`
100
+
101
+ ${m}`:`
102
+ ${m}`}}),a}function Oy(n,e,t={}){const{state:r}=e,{doc:s,tr:o}=r,i=n;s.descendants((l,a)=>{const c=o.mapping.map(a),u=o.mapping.map(a)+l.nodeSize;let d=null;if(l.marks.forEach(h=>{if(h!==i)return!1;d=h}),!d)return;let f=!1;if(Object.keys(t).forEach(h=>{t[h]!==d.attrs[h]&&(f=!0)}),f){const h=n.type.create({...n.attrs,...t});o.removeMark(c,u,n.type),o.addMark(c,u,h)}}),o.docChanged&&e.view.dispatch(o)}var _e=class Of extends wl{constructor(){super(...arguments),this.type="node"}static create(e={}){const t=typeof e=="function"?e():e;return new Of(t)}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}},Ry=class{constructor(n,e,t){this.isDragging=!1,this.component=n,this.editor=e.editor,this.options={stopEvent:null,ignoreMutation:null,...t},this.extension=e.extension,this.node=e.node,this.decorations=e.decorations,this.innerDecorations=e.innerDecorations,this.view=e.view,this.HTMLAttributes=e.HTMLAttributes,this.getPos=e.getPos,this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(n){var e,t,r,s,o,i,l;const{view:a}=this.editor,c=n.target,u=c.nodeType===3?(e=c.parentElement)==null?void 0:e.closest("[data-drag-handle]"):c.closest("[data-drag-handle]");if(!this.dom||(t=this.contentDOM)!=null&&t.contains(c)||!u)return;let d=0,f=0;if(this.dom!==u){const b=this.dom.getBoundingClientRect(),k=u.getBoundingClientRect(),S=(s=n.offsetX)!=null?s:(r=n.nativeEvent)==null?void 0:r.offsetX,v=(i=n.offsetY)!=null?i:(o=n.nativeEvent)==null?void 0:o.offsetY;d=k.x-b.x+S,f=k.y-b.y+v}const h=this.dom.cloneNode(!0);try{const b=this.dom.getBoundingClientRect();h.style.width=`${Math.round(b.width)}px`,h.style.height=`${Math.round(b.height)}px`,h.style.boxSizing="border-box",h.style.pointerEvents="none"}catch{}let m=null;try{m=document.createElement("div"),m.style.position="absolute",m.style.top="-9999px",m.style.left="-9999px",m.style.pointerEvents="none",m.appendChild(h),document.body.appendChild(m),(l=n.dataTransfer)==null||l.setDragImage(h,d,f)}finally{m&&setTimeout(()=>{try{m?.remove()}catch{}},0)}const g=this.getPos();if(typeof g!="number")return;const x=V.create(a.state.doc,g),y=a.state.tr.setSelection(x);a.dispatch(y)}stopEvent(n){var e;if(!this.dom)return!1;if(typeof this.options.stopEvent=="function")return this.options.stopEvent({event:n});const t=n.target;if(!(this.dom.contains(t)&&!((e=this.contentDOM)!=null&&e.contains(t))))return!1;const s=n.type.startsWith("drag"),o=n.type==="drop";if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(t.tagName)||t.isContentEditable)&&!o&&!s)return!0;const{isEditable:l}=this.editor,{isDragging:a}=this,c=!!this.node.type.spec.draggable,u=V.isSelectable(this.node),d=n.type==="copy",f=n.type==="paste",h=n.type==="cut",m=n.type==="mousedown";if(!c&&u&&s&&n.target===this.dom&&n.preventDefault(),c&&s&&!a&&n.target===this.dom)return n.preventDefault(),!1;if(c&&l&&!a&&m){const g=t.closest("[data-drag-handle]");g&&(this.dom===g||this.dom.contains(g))&&(this.isDragging=!0,document.addEventListener("dragend",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("drop",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("mouseup",()=>{this.isDragging=!1},{once:!0}))}return!(a||o||d||f||h||m&&u)}ignoreMutation(n){return!this.dom||!this.contentDOM?!0:typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:n}):this.node.isLeaf||this.node.isAtom?!0:n.type==="selection"||this.dom.contains(n.target)&&n.type==="childList"&&(Sr()||mi())&&this.editor.isFocused&&[...Array.from(n.addedNodes),...Array.from(n.removedNodes)].every(t=>t.isContentEditable)?!1:this.contentDOM===n.target&&n.type==="attributes"?!0:!this.contentDOM.contains(n.target)}updateAttributes(n){this.editor.commands.command(({tr:e})=>{const t=this.getPos();return typeof t!="number"?!1:(e.setNodeMarkup(t,void 0,{...this.node.attrs,...n}),!0)})}deleteNode(){const n=this.getPos();if(typeof n!="number")return;const e=n+this.node.nodeSize;this.editor.commands.deleteRange({from:n,to:e})}};function bn(n){return new py({find:n.find,handler:({state:e,range:t,match:r,pasteEvent:s})=>{const o=oe(n.getAttributes,void 0,r,s);if(o===!1||o===null)return null;const{tr:i}=e,l=r[r.length-1],a=r[0];let c=t.to;if(l){const u=a.search(/\S/),d=t.from+a.indexOf(l),f=d+l.length;if(vl(t.from,t.to,e.doc).filter(m=>m.mark.type.excluded.find(x=>x===n.type&&x!==m.mark.type)).filter(m=>m.to>d).length)return null;f<t.to&&i.delete(f,t.to),d>t.from&&i.delete(t.from+u,d),c=t.from+u+l.length,i.addMark(t.from+u,c,n.type.create(o||{})),i.removeStoredMark(n.type)}}})}const{getOwnPropertyNames:Dy,getOwnPropertySymbols:Py}=Object,{hasOwnProperty:Ly}=Object.prototype;function _o(n,e){return function(r,s,o){return n(r,s,o)&&e(r,s,o)}}function Fr(n){return function(t,r,s){if(!t||!r||typeof t!="object"||typeof r!="object")return n(t,r,s);const{cache:o}=s,i=o.get(t),l=o.get(r);if(i&&l)return i===r&&l===t;o.set(t,r),o.set(r,t);const a=n(t,r,s);return o.delete(t),o.delete(r),a}}function _y(n){return n?.[Symbol.toStringTag]}function gc(n){return Dy(n).concat(Py(n))}const $y=Object.hasOwn||((n,e)=>Ly.call(n,e));function wn(n,e){return n===e||!n&&!e&&n!==n&&e!==e}const zy="__v",By="__o",Fy="_owner",{getOwnPropertyDescriptor:xc,keys:yc}=Object;function Hy(n,e){return n.byteLength===e.byteLength&&ps(new Uint8Array(n),new Uint8Array(e))}function Vy(n,e,t){let r=n.length;if(e.length!==r)return!1;for(;r-- >0;)if(!t.equals(n[r],e[r],r,r,n,e,t))return!1;return!0}function Wy(n,e){return n.byteLength===e.byteLength&&ps(new Uint8Array(n.buffer,n.byteOffset,n.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function Uy(n,e){return wn(n.getTime(),e.getTime())}function qy(n,e){return n.name===e.name&&n.message===e.message&&n.cause===e.cause&&n.stack===e.stack}function Ky(n,e){return n===e}function bc(n,e,t){const r=n.size;if(r!==e.size)return!1;if(!r)return!0;const s=new Array(r),o=n.entries();let i,l,a=0;for(;(i=o.next())&&!i.done;){const c=e.entries();let u=!1,d=0;for(;(l=c.next())&&!l.done;){if(s[d]){d++;continue}const f=i.value,h=l.value;if(t.equals(f[0],h[0],a,d,n,e,t)&&t.equals(f[1],h[1],f[0],h[0],n,e,t)){u=s[d]=!0;break}d++}if(!u)return!1;a++}return!0}const Jy=wn;function Gy(n,e,t){const r=yc(n);let s=r.length;if(yc(e).length!==s)return!1;for(;s-- >0;)if(!Rf(n,e,t,r[s]))return!1;return!0}function Gn(n,e,t){const r=gc(n);let s=r.length;if(gc(e).length!==s)return!1;let o,i,l;for(;s-- >0;)if(o=r[s],!Rf(n,e,t,o)||(i=xc(n,o),l=xc(e,o),(i||l)&&(!i||!l||i.configurable!==l.configurable||i.enumerable!==l.enumerable||i.writable!==l.writable)))return!1;return!0}function Xy(n,e){return wn(n.valueOf(),e.valueOf())}function Yy(n,e){return n.source===e.source&&n.flags===e.flags}function kc(n,e,t){const r=n.size;if(r!==e.size)return!1;if(!r)return!0;const s=new Array(r),o=n.values();let i,l;for(;(i=o.next())&&!i.done;){const a=e.values();let c=!1,u=0;for(;(l=a.next())&&!l.done;){if(!s[u]&&t.equals(i.value,l.value,i.value,l.value,n,e,t)){c=s[u]=!0;break}u++}if(!c)return!1}return!0}function ps(n,e){let t=n.byteLength;if(e.byteLength!==t||n.byteOffset!==e.byteOffset)return!1;for(;t-- >0;)if(n[t]!==e[t])return!1;return!0}function Qy(n,e){return n.hostname===e.hostname&&n.pathname===e.pathname&&n.protocol===e.protocol&&n.port===e.port&&n.hash===e.hash&&n.username===e.username&&n.password===e.password}function Rf(n,e,t,r){return(r===Fy||r===By||r===zy)&&(n.$$typeof||e.$$typeof)?!0:$y(e,r)&&t.equals(n[r],e[r],r,r,n,e,t)}const Zy="[object ArrayBuffer]",eb="[object Arguments]",tb="[object Boolean]",nb="[object DataView]",rb="[object Date]",sb="[object Error]",ob="[object Map]",ib="[object Number]",lb="[object Object]",ab="[object RegExp]",cb="[object Set]",ub="[object String]",db={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float16Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0,"[object BigInt64Array]":!0,"[object BigUint64Array]":!0},fb="[object URL]",hb=Object.prototype.toString;function pb({areArrayBuffersEqual:n,areArraysEqual:e,areDataViewsEqual:t,areDatesEqual:r,areErrorsEqual:s,areFunctionsEqual:o,areMapsEqual:i,areNumbersEqual:l,areObjectsEqual:a,arePrimitiveWrappersEqual:c,areRegExpsEqual:u,areSetsEqual:d,areTypedArraysEqual:f,areUrlsEqual:h,unknownTagComparators:m}){return function(x,y,b){if(x===y)return!0;if(x==null||y==null)return!1;const k=typeof x;if(k!==typeof y)return!1;if(k!=="object")return k==="number"?l(x,y,b):k==="function"?o(x,y,b):!1;const S=x.constructor;if(S!==y.constructor)return!1;if(S===Object)return a(x,y,b);if(Array.isArray(x))return e(x,y,b);if(S===Date)return r(x,y,b);if(S===RegExp)return u(x,y,b);if(S===Map)return i(x,y,b);if(S===Set)return d(x,y,b);const v=hb.call(x);if(v===rb)return r(x,y,b);if(v===ab)return u(x,y,b);if(v===ob)return i(x,y,b);if(v===cb)return d(x,y,b);if(v===lb)return typeof x.then!="function"&&typeof y.then!="function"&&a(x,y,b);if(v===fb)return h(x,y,b);if(v===sb)return s(x,y,b);if(v===eb)return a(x,y,b);if(db[v])return f(x,y,b);if(v===Zy)return n(x,y,b);if(v===nb)return t(x,y,b);if(v===tb||v===ib||v===ub)return c(x,y,b);if(m){let w=m[v];if(!w){const C=_y(x);C&&(w=m[C])}if(w)return w(x,y,b)}return!1}}function mb({circular:n,createCustomConfig:e,strict:t}){let r={areArrayBuffersEqual:Hy,areArraysEqual:t?Gn:Vy,areDataViewsEqual:Wy,areDatesEqual:Uy,areErrorsEqual:qy,areFunctionsEqual:Ky,areMapsEqual:t?_o(bc,Gn):bc,areNumbersEqual:Jy,areObjectsEqual:t?Gn:Gy,arePrimitiveWrappersEqual:Xy,areRegExpsEqual:Yy,areSetsEqual:t?_o(kc,Gn):kc,areTypedArraysEqual:t?_o(ps,Gn):ps,areUrlsEqual:Qy,unknownTagComparators:void 0};if(e&&(r=Object.assign({},r,e(r))),n){const s=Fr(r.areArraysEqual),o=Fr(r.areMapsEqual),i=Fr(r.areObjectsEqual),l=Fr(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:s,areMapsEqual:o,areObjectsEqual:i,areSetsEqual:l})}return r}function gb(n){return function(e,t,r,s,o,i,l){return n(e,t,l)}}function xb({circular:n,comparator:e,createState:t,equals:r,strict:s}){if(t)return function(l,a){const{cache:c=n?new WeakMap:void 0,meta:u}=t();return e(l,a,{cache:c,equals:r,meta:u,strict:s})};if(n)return function(l,a){return e(l,a,{cache:new WeakMap,equals:r,meta:void 0,strict:s})};const o={cache:void 0,equals:r,meta:void 0,strict:s};return function(l,a){return e(l,a,o)}}const yb=Gt();Gt({strict:!0});Gt({circular:!0});Gt({circular:!0,strict:!0});Gt({createInternalComparator:()=>wn});Gt({strict:!0,createInternalComparator:()=>wn});Gt({circular:!0,createInternalComparator:()=>wn});Gt({circular:!0,createInternalComparator:()=>wn,strict:!0});function Gt(n={}){const{circular:e=!1,createInternalComparator:t,createState:r,strict:s=!1}=n,o=mb(n),i=pb(o),l=t?t(i):gb(i);return xb({circular:e,comparator:i,createState:r,equals:l,strict:s})}var bb=(...n)=>e=>{n.forEach(t=>{typeof t=="function"?t(e):t&&(t.current=e)})},kb=({contentComponent:n})=>{const e=Kc.useSyncExternalStore(n.subscribe,n.getSnapshot,n.getServerSnapshot);return p.jsx(p.Fragment,{children:Object.values(e)})};function Sb(){const n=new Set;let e={};return{subscribe(t){return n.add(t),()=>{n.delete(t)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(t,r){e={...e,[t]:Qh.createPortal(r.reactElement,r.element,t)},n.forEach(s=>s())},removeRenderer(t){const r={...e};delete r[t],e=r,n.forEach(s=>s())}}}var vb=class extends dn.Component{constructor(n){var e;super(n),this.editorContentRef=dn.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!((e=n.editor)!=null&&e.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){var n;const e=this.props.editor;if(e&&!e.isDestroyed&&((n=e.view.dom)!=null&&n.parentNode)){if(e.contentComponent)return;const t=this.editorContentRef.current;t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t}),e.contentComponent=Sb(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=e.contentComponent.subscribe(()=>{this.setState(r=>r.hasContentComponentInitialized?r:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),e.createNodeViews(),this.initialized=!0}}componentWillUnmount(){var n;const e=this.props.editor;if(e){this.initialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),e.contentComponent=null;try{if(!((n=e.view.dom)!=null&&n.parentNode))return;const t=document.createElement("div");t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t})}catch{}}}render(){const{editor:n,innerRef:e,...t}=this.props;return p.jsxs(p.Fragment,{children:[p.jsx("div",{ref:bb(e,this.editorContentRef),...t}),n?.contentComponent&&p.jsx(kb,{contentComponent:n.contentComponent})]})}},wb=E.forwardRef((n,e)=>{const t=dn.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[n.editor]);return dn.createElement(vb,{key:t,innerRef:e,...n})}),Df=dn.memo(wb),Cb=typeof window<"u"?E.useLayoutEffect:E.useEffect,Tb=class{constructor(n){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=n,this.lastSnapshot={editor:n,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(n){return this.subscribers.add(n),()=>{this.subscribers.delete(n)}}watch(n){if(this.editor=n,this.editor){const e=()=>{this.transactionNumber+=1,this.subscribers.forEach(r=>r())},t=this.editor;return t.on("transaction",e),()=>{t.off("transaction",e)}}}};function Nb(n){var e;const[t]=E.useState(()=>new Tb(n.editor)),r=Xh.useSyncExternalStoreWithSelector(t.subscribe,t.getSnapshot,t.getServerSnapshot,n.selector,(e=n.equalityFn)!=null?e:yb);return Cb(()=>t.watch(n.editor),[n.editor,t]),E.useDebugValue(r),r}var Mb=!1,ki=typeof window>"u",Eb=ki||!!(typeof window<"u"&&window.next),Ab=class Pf{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(t=>t())}getInitialEditor(){return this.options.current.immediatelyRender===void 0?ki||Eb?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var s,o;return(o=(s=this.options.current).onBeforeCreate)==null?void 0:o.call(s,...r)},onBlur:(...r)=>{var s,o;return(o=(s=this.options.current).onBlur)==null?void 0:o.call(s,...r)},onCreate:(...r)=>{var s,o;return(o=(s=this.options.current).onCreate)==null?void 0:o.call(s,...r)},onDestroy:(...r)=>{var s,o;return(o=(s=this.options.current).onDestroy)==null?void 0:o.call(s,...r)},onFocus:(...r)=>{var s,o;return(o=(s=this.options.current).onFocus)==null?void 0:o.call(s,...r)},onSelectionUpdate:(...r)=>{var s,o;return(o=(s=this.options.current).onSelectionUpdate)==null?void 0:o.call(s,...r)},onTransaction:(...r)=>{var s,o;return(o=(s=this.options.current).onTransaction)==null?void 0:o.call(s,...r)},onUpdate:(...r)=>{var s,o;return(o=(s=this.options.current).onUpdate)==null?void 0:o.call(s,...r)},onContentError:(...r)=>{var s,o;return(o=(s=this.options.current).onContentError)==null?void 0:o.call(s,...r)},onDrop:(...r)=>{var s,o;return(o=(s=this.options.current).onDrop)==null?void 0:o.call(s,...r)},onPaste:(...r)=>{var s,o;return(o=(s=this.options.current).onPaste)==null?void 0:o.call(s,...r)},onDelete:(...r)=>{var s,o;return(o=(s=this.options.current).onDelete)==null?void 0:o.call(s,...r)}};return new wy(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,t){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&t.extensions?e.extensions.length!==t.extensions.length?!1:e.extensions.every((s,o)=>{var i;return s===((i=t.extensions)==null?void 0:i[o])}):e[r]===t[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?Pf.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(e),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((r,s)=>r===e[s]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,t=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){t&&t.setOptions(this.options.current);return}t&&!t.isDestroyed&&(t.destroy(),this.instanceId===e&&this.setEditor(null))},1)}};function jb(n={},e=[]){const t=E.useRef(n);t.current=n;const[r]=E.useState(()=>new Ab(t)),s=Kc.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return E.useDebugValue(s),E.useEffect(r.onRender(e)),Nb({editor:s,selector:({transactionNumber:o})=>n.shouldRerenderOnTransaction===!1||n.shouldRerenderOnTransaction===void 0?null:n.immediatelyRender&&o===0?0:o+1}),s}var Ml=E.createContext({editor:null});Ml.Consumer;var JC=()=>E.useContext(Ml),Lf=E.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),Ib=()=>E.useContext(Lf),_f=dn.forwardRef((n,e)=>{const{onDragStart:t}=Ib(),r=n.as||"div";return p.jsx(r,{...n,ref:e,"data-node-view-wrapper":"",onDragStart:t,style:{whiteSpace:"normal",...n.style}})});function Sc(n){return!!(typeof n=="function"&&n.prototype&&n.prototype.isReactComponent)}function vc(n){return!!(typeof n=="object"&&n.$$typeof&&(n.$$typeof.toString()==="Symbol(react.forward_ref)"||n.$$typeof.description==="react.forward_ref"))}function Ob(n){return!!(typeof n=="object"&&n.$$typeof&&(n.$$typeof.toString()==="Symbol(react.memo)"||n.$$typeof.description==="react.memo"))}function Rb(n){if(Sc(n)||vc(n))return!0;if(Ob(n)){const e=n.type;if(e)return Sc(e)||vc(e)}return!1}function Db(){try{if(E.version)return parseInt(E.version.split(".")[0],10)>=19}catch{}return!1}var Pb=class{constructor(n,{editor:e,props:t={},as:r="div",className:s=""}){this.ref=null,this.destroyed=!1,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=n,this.editor=e,this.props=t,this.element=document.createElement(r),this.element.classList.add("react-renderer"),s&&this.element.classList.add(...s.split(" ")),this.editor.isInitialized?Yh.flushSync(()=>{this.render()}):queueMicrotask(()=>{this.destroyed||this.render()})}render(){var n;if(this.destroyed)return;const e=this.component,t=this.props,r=this.editor,s=Db(),o=Rb(e),i={...t};i.ref&&!(s||o)&&delete i.ref,!i.ref&&(s||o)&&(i.ref=l=>{this.ref=l}),this.reactElement=p.jsx(e,{...i}),(n=r?.contentComponent)==null||n.setRenderer(this.id,this)}updateProps(n={}){this.destroyed||(this.props={...this.props,...n},this.render())}destroy(){var n;this.destroyed=!0;const e=this.editor;(n=e?.contentComponent)==null||n.removeRenderer(this.id);try{this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}catch{}}updateAttributes(n){Object.keys(n).forEach(e=>{this.element.setAttribute(e,n[e])})}};dn.createContext({markViewContentRef:()=>{}});var Lb=class extends Ry{constructor(n,e,t){if(super(n,e,t),this.selectionRafId=null,this.cachedExtensionWithSyncedStorage=null,!this.node.isLeaf){this.options.contentDOMElementTag?this.contentDOMElement=document.createElement(this.options.contentDOMElementTag):this.contentDOMElement=document.createElement(this.node.isInline?"span":"div"),this.contentDOMElement.dataset.nodeViewContentReact="",this.contentDOMElement.dataset.nodeViewWrapper="",this.contentDOMElement.style.whiteSpace="inherit";const r=this.dom.querySelector("[data-node-view-content]");if(!r)return;r.appendChild(this.contentDOMElement)}}get extensionWithSyncedStorage(){if(!this.cachedExtensionWithSyncedStorage){const n=this.editor,e=this.extension;this.cachedExtensionWithSyncedStorage=new Proxy(e,{get(t,r,s){var o;return r==="storage"?(o=n.storage[e.name])!=null?o:{}:Reflect.get(t,r,s)}})}return this.cachedExtensionWithSyncedStorage}mount(){const n={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extensionWithSyncedStorage,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(a={})=>this.updateAttributes(a),deleteNode:()=>this.deleteNode(),ref:E.createRef()};if(!this.component.displayName){const a=c=>c.charAt(0).toUpperCase()+c.substring(1);this.component.displayName=a(this.extension.name)}const r={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:a=>{a&&this.contentDOMElement&&a.firstChild!==this.contentDOMElement&&(a.hasAttribute("data-node-view-wrapper")&&a.removeAttribute("data-node-view-wrapper"),a.appendChild(this.contentDOMElement))}},s=this.component,o=E.memo(a=>p.jsx(Lf.Provider,{value:r,children:E.createElement(s,a)}));o.displayName="ReactNodeView";let i=this.node.isInline?"span":"div";this.options.as&&(i=this.options.as);const{className:l=""}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new Pb(o,{editor:this.editor,props:n,as:i,className:`node-${this.node.type.name} ${l}`.trim()}),this.editor.on("selectionUpdate",this.handleSelectionUpdate),this.updateElementAttributes()}get dom(){var n;if(this.renderer.element.firstElementChild&&!((n=this.renderer.element.firstElementChild)!=null&&n.hasAttribute("data-node-view-wrapper")))throw Error("Please use the NodeViewWrapper component for your node view.");return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}handleSelectionUpdate(){this.selectionRafId&&(cancelAnimationFrame(this.selectionRafId),this.selectionRafId=null),this.selectionRafId=requestAnimationFrame(()=>{this.selectionRafId=null;const{from:n,to:e}=this.editor.state.selection,t=this.getPos();if(typeof t=="number")if(n<=t&&e>=t+this.node.nodeSize){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}})}update(n,e,t){const r=s=>{this.renderer.updateProps(s),typeof this.options.attrs=="function"&&this.updateElementAttributes()};if(n.type!==this.node.type)return!1;if(typeof this.options.update=="function"){const s=this.node,o=this.decorations,i=this.innerDecorations;return this.node=n,this.decorations=e,this.innerDecorations=t,this.options.update({oldNode:s,oldDecorations:o,newNode:n,newDecorations:e,oldInnerDecorations:i,innerDecorations:t,updateProps:()=>r({node:n,decorations:e,innerDecorations:t,extension:this.extensionWithSyncedStorage})})}return n===this.node&&this.decorations===e&&this.innerDecorations===t||(this.node=n,this.decorations=e,this.innerDecorations=t,r({node:n,decorations:e,innerDecorations:t,extension:this.extensionWithSyncedStorage})),!0}selectNode(){this.renderer.updateProps({selected:!0}),this.renderer.element.classList.add("ProseMirror-selectednode")}deselectNode(){this.renderer.updateProps({selected:!1}),this.renderer.element.classList.remove("ProseMirror-selectednode")}destroy(){this.renderer.destroy(),this.editor.off("selectionUpdate",this.handleSelectionUpdate),this.contentDOMElement=null,this.selectionRafId&&(cancelAnimationFrame(this.selectionRafId),this.selectionRafId=null)}updateElementAttributes(){if(this.options.attrs){let n={};if(typeof this.options.attrs=="function"){const e=this.editor.extensionManager.attributes,t=zn(this.node,e);n=this.options.attrs({node:this.node,HTMLAttributes:t})}else n=this.options.attrs;this.renderer.updateAttributes(n)}}};function $f(n,e){return t=>t.editor.contentComponent?new Lb(n,t,e):{}}var El=E.createContext({get editor(){throw new Error("useTiptap must be used within a <Tiptap> provider")}});El.displayName="TiptapContext";var _b=()=>E.useContext(El);function zf({editor:n,instance:e,children:t}){const r=n??e;if(!r)throw new Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");const s=E.useMemo(()=>({editor:r}),[r]),o=E.useMemo(()=>({editor:r}),[r]);return p.jsx(Ml.Provider,{value:o,children:p.jsx(El.Provider,{value:s,children:t})})}zf.displayName="Tiptap";function Bf({...n}){const{editor:e}=_b();return p.jsx(Df,{editor:e,...n})}Bf.displayName="Tiptap.Content";Object.assign(zf,{Content:Bf});function $b(n){return n.storage.mention}function GC(n,e,t){n.chain().focus().insertContentAt(e,[Ff(t),{type:"text",text:" "}]).run()}function Ff(n){return{type:"mention",attrs:n}}function zb(n){const e=_.c(19),{node:t,selected:r,view:s,editor:o,getPos:i}=n,{name:l,char:a,kind:c,id:u,args:d}=t.attrs,f=r&&s.editable,h=a==="@",m=s.editable&&a==="/"&&(c==="prompt"||c==null);let g;e[0]!==d||e[1]!==o||e[2]!==i||e[3]!==u||e[4]!==m||e[5]!==l?(g=T=>{if(!m)return;const M=$b(o)?.onEditChip;if(!M||typeof i!="function")return;const j=i();typeof j=="number"&&(T.preventDefault(),T.stopPropagation(),M({promptId:u,promptName:l,args:d??{},pos:j}))},e[0]=d,e[1]=o,e[2]=i,e[3]=u,e[4]=m,e[5]=l,e[6]=g):g=e[6];const x=g,y=m?"cursor-pointer":"cursor-default",b=h?"bg-violet-100 text-violet-700 dark:bg-violet-900/30 dark:text-violet-400":"bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-300",k=f&&"outline-2 outline-blue-300 outline-offset-0",S=m&&"hover:brightness-95";let v;e[7]!==y||e[8]!==b||e[9]!==k||e[10]!==S?(v=ee("px-1 py-1 rounded","inline-flex items-center gap-1",y,"select-none","text-xs font-light",b,k,S,"capitalize"),e[7]=y,e[8]=b,e[9]=k,e[10]=S,e[11]=v):v=e[11];let w;e[12]!==l?(w=l?Cu(l):"",e[12]=l,e[13]=w):w=e[13];let C;return e[14]!==a||e[15]!==x||e[16]!==v||e[17]!==w?(C=p.jsxs(_f,{onClick:x,className:v,children:[a,w]}),e[14]=a,e[15]=x,e[16]=v,e[17]=w,e[18]=C):C=e[18],C}const Bb=_e.create({name:"mention",group:"inline",inline:!0,atom:!0,addStorage(){return{onEditChip:null}},addAttributes(){return{id:{default:null,parseHTML:n=>n.getAttribute("data-id")||null,renderHTML:n=>n.id?{"data-id":n.id}:{}},name:{default:null,parseHTML:n=>n.getAttribute("data-name")||null,renderHTML:n=>n.name?{"data-name":n.name}:{}},char:{default:"/",parseHTML:n=>n.getAttribute("data-char")||"/",renderHTML:n=>n.char?{"data-char":n.char}:{}},metadata:{default:null,parseHTML:n=>{try{return JSON.parse(n.getAttribute("data-metadata")||"null")}catch{return null}},renderHTML:n=>n.metadata?{"data-metadata":JSON.stringify(n.metadata)}:{}},kind:{default:null,parseHTML:n=>n.getAttribute("data-kind")||null,renderHTML:n=>n.kind?{"data-kind":n.kind}:{}},args:{default:null,parseHTML:n=>{try{return JSON.parse(n.getAttribute("data-args")||"null")}catch{return null}},renderHTML:n=>n.args?{"data-args":JSON.stringify(n.args)}:{}}}},parseHTML(){return[{tag:'span[data-type="mention"]'}]},renderHTML({node:n,HTMLAttributes:e}){const t={"data-type":"mention"};return n.attrs.id&&(t["data-id"]=n.attrs.id),n.attrs.name&&(t["data-name"]=n.attrs.name),n.attrs.char&&(t["data-char"]=n.attrs.char),n.attrs.metadata&&(t["data-metadata"]=JSON.stringify(n.attrs.metadata)),n.attrs.kind&&(t["data-kind"]=n.attrs.kind),n.attrs.args&&(t["data-args"]=JSON.stringify(n.attrs.args)),["span",{...e,...t}]},renderText({node:n}){const e=n.attrs.char??"@",t=n.attrs.name??"";return`${e}${t}`},addNodeView(){return $f(zb)}}),Fb=/^mcp__[a-zA-Z0-9_-]+__/;function Hf(n){return n.replace(Fb,"")}function uo(n){const e=_.c(18),{id:t,part:r,copyable:s,extraActions:o,alwaysShowActions:i,animate:l}=n,a=s===void 0?!1:s,c=i===void 0?!1:i,u=l===void 0?!1:l,{handleCopy:d}=hu(),[f,h]=E.useState(!1);let m;e[0]!==d||e[1]!==t||e[2]!==r.text?(m=async()=>{Zh("chat_message_copied",{message_id:t,chars:r.text.length}),await d(r.text),h(!0),setTimeout(()=>h(!1),2e3)},e[0]=d,e[1]=t,e[2]=r.text,e[3]=m):m=e[3];const g=m,x=a&&o,y=x||o;let b;e[4]!==u||e[5]!==t||e[6]!==r.text?(b=p.jsx(Ji,{id:t,text:r.text,animate:u}),e[4]=u,e[5]=t,e[6]=r.text,e[7]=b):b=e[7];let k;e[8]!==c||e[9]!==o||e[10]!==g||e[11]!==f||e[12]!==y||e[13]!==x?(k=y&&p.jsxs("div",{className:ee("flex w-full items-center gap-2 text-sm text-muted-foreground transition-all duration-200 mt-1 py-1",c?"opacity-100":"opacity-0 pointer-events-none group-hover/part:opacity-100 group-hover/part:pointer-events-auto"),children:[o,x&&o&&p.jsx("span",{className:"text-muted-foreground/40 select-none",children:"·"}),x&&p.jsx("button",{type:"button",onClick:g,className:"text-muted-foreground [@media(hover:hover)]:hover:text-foreground transition-colors active:scale-[0.97]","aria-label":"Copy message",children:f?p.jsx(qi,{className:"size-4"}):p.jsx(fu,{className:"size-4"})})]}),e[8]=c,e[9]=o,e[10]=g,e[11]=f,e[12]=y,e[13]=x,e[14]=k):k=e[14];let S;return e[15]!==b||e[16]!==k?(S=p.jsxs("div",{className:"group/part relative",children:[b,k]}),e[15]=b,e[16]=k,e[17]=S):S=e[17],S}function XC(n,e,t){n.chain().focus().insertContentAt(e,[Hb(t),{type:"text",text:" "}]).run()}function Hb(n){return{type:"file",attrs:n}}function Vb(n){const e=_.c(17),{node:t,selected:r,view:s}=n,{name:o,mimeType:i,data:l}=t.attrs,a=r&&s.editable;let c;e[0]!==i?(c=i.startsWith("image/"),e[0]=i,e[1]=c):c=e[1];const u=c,d=a&&"outline-2 outline-blue-300 outline-offset-0";let f;e[2]!==d?(f=ee("px-1 py-1 rounded","inline-flex items-center gap-1","cursor-default select-none","text-xs font-light","bg-muted text-muted-foreground",d),e[2]=d,e[3]=f):f=e[3];let h;e[4]!==o?(h=p.jsx(fn,{asChild:!0,children:p.jsx("span",{children:o})}),e[4]=o,e[5]=h):h=e[5];let m;e[6]!==l||e[7]!==u||e[8]!==i||e[9]!==o?(m=p.jsx(hn,{side:"top",className:"max-w-sm p-1.5",children:u?p.jsx("img",{src:`data:${i};base64,${l}`,alt:o,className:"max-w-full max-h-64 object-contain rounded"}):p.jsxs("div",{className:"text-xs",children:[p.jsx("div",{className:"font-medium",children:o}),p.jsx("div",{className:"text-muted-foreground mt-1",children:i})]})}),e[6]=l,e[7]=u,e[8]=i,e[9]=o,e[10]=m):m=e[10];let g;e[11]!==h||e[12]!==m?(g=p.jsxs(pn,{children:[h,m]}),e[11]=h,e[12]=m,e[13]=g):g=e[13];let x;return e[14]!==f||e[15]!==g?(x=p.jsx(_f,{className:f,children:g}),e[14]=f,e[15]=g,e[16]=x):x=e[16],x}const Wb=_e.create({name:"file",group:"inline",inline:!0,atom:!0,addAttributes(){return{id:{default:null,parseHTML:n=>n.getAttribute("data-id")||null,renderHTML:n=>n.id?{"data-id":n.id}:{}},name:{default:null,parseHTML:n=>n.getAttribute("data-name")||null,renderHTML:n=>n.name?{"data-name":n.name}:{}},mimeType:{default:null,parseHTML:n=>n.getAttribute("data-mime-type")||null,renderHTML:n=>n.mimeType?{"data-mime-type":n.mimeType}:{}},size:{default:0,parseHTML:n=>{const e=n.getAttribute("data-size");return e?Number.parseInt(e,10):0},renderHTML:n=>n.size?{"data-size":String(n.size)}:{}},data:{default:null,parseHTML:n=>n.getAttribute("data-data")||null,renderHTML:n=>n.data?{"data-data":n.data}:{}}}},parseHTML(){return[{tag:'span[data-type="file"]'}]},renderHTML({node:n,HTMLAttributes:e}){const t={"data-type":"file"};return n.attrs.id&&(t["data-id"]=n.attrs.id),n.attrs.name&&(t["data-name"]=n.attrs.name),n.attrs.mimeType&&(t["data-mime-type"]=n.attrs.mimeType),n.attrs.size&&(t["data-size"]=String(n.attrs.size)),n.attrs.data&&(t["data-data"]=n.attrs.data),["span",{...e,...t}]},renderText({node:n}){return`[${n.attrs.name??""}]`},addNodeView(){return $f(Vb)}});function Ub(n={}){return new fe({view(e){return new qb(e,n)}})}class qb{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(s=>{let o=i=>{this[s](i)};return e.dom.addEventListener(s,o),{name:s,handler:o}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,r,s=this.editorView.dom,o=s.getBoundingClientRect(),i=o.width/s.offsetWidth,l=o.height/s.offsetHeight;if(t){let d=e.nodeBefore,f=e.nodeAfter;if(d||f){let h=this.editorView.nodeDOM(this.cursorPos-(d?d.nodeSize:0));if(h){let m=h.getBoundingClientRect(),g=d?m.bottom:m.top;d&&f&&(g=(g+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let x=this.width/2*l;r={left:m.left,right:m.right,top:g-x,bottom:g+x}}}}if(!r){let d=this.editorView.coordsAtPos(this.cursorPos),f=this.width/2*i;r={left:d.left-f,right:d.left+f,top:d.top,bottom:d.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let c,u;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,u=-pageYOffset;else{let d=a.getBoundingClientRect(),f=d.width/a.offsetWidth,h=d.height/a.offsetHeight;c=d.left-a.scrollLeft*f,u=d.top-a.scrollTop*h}this.element.style.left=(r.left-c)/i+"px",this.element.style.top=(r.top-u)/l+"px",this.element.style.width=(r.right-r.left)/i+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),s=r&&r.type.spec.disableDropCursor,o=typeof s=="function"?s(this.editorView,t,e):s;if(t&&!o){let i=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=Yu(this.editorView.state.doc,i,this.editorView.dragging.slice);l!=null&&(i=l)}this.setCursor(i),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class me extends X{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return me.valid(r)?new me(r):X.near(r)}content(){return B.empty}eq(e){return e instanceof me&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new me(e.resolve(t.pos))}getBookmark(){return new Al(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!Kb(e)||!Jb(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let s=t.contentMatchAt(e.index()).defaultType;return s&&s.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&me.valid(e))return e;let s=e.pos,o=null;for(let i=e.depth;;i--){let l=e.node(i);if(t>0?e.indexAfter(i)<l.childCount:e.index(i)>0){o=l.child(t>0?e.indexAfter(i):e.index(i)-1);break}else if(i==0)return null;s+=t;let a=e.doc.resolve(s);if(me.valid(a))return a}for(;;){let i=t>0?o.firstChild:o.lastChild;if(!i){if(o.isAtom&&!o.isText&&!V.isSelectable(o)){e=e.doc.resolve(s+o.nodeSize*t),r=!1;continue e}break}o=i,s+=t;let l=e.doc.resolve(s);if(me.valid(l))return l}return null}}}me.prototype.visible=!1;me.findFrom=me.findGapCursorFrom;X.jsonID("gapcursor",me);class Al{constructor(e){this.pos=e}map(e){return new Al(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return me.valid(t)?new me(t):X.near(t)}}function Vf(n){return n.isAtom||n.spec.isolating||n.spec.createGapCursor}function Kb(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(t-1);;s=s.lastChild){if(s.childCount==0&&!s.inlineContent||Vf(s.type))return!0;if(s.inlineContent)return!1}}return!0}function Jb(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(t);;s=s.firstChild){if(s.childCount==0&&!s.inlineContent||Vf(s.type))return!0;if(s.inlineContent)return!1}}return!0}function Gb(){return new fe({props:{decorations:Zb,createSelectionBetween(n,e,t){return e.pos==t.pos&&me.valid(t)?new me(t):null},handleClick:Yb,handleKeyDown:Xb,handleDOMEvents:{beforeinput:Qb}}})}const Xb=Qd({ArrowLeft:Hr("horiz",-1),ArrowRight:Hr("horiz",1),ArrowUp:Hr("vert",-1),ArrowDown:Hr("vert",1)});function Hr(n,e){const t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,s,o){let i=r.selection,l=e>0?i.$to:i.$from,a=i.empty;if(i instanceof q){if(!o.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=me.findGapCursorFrom(l,e,a);return c?(s&&s(r.tr.setSelection(new me(c))),!0):!1}}function Yb(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!me.valid(r))return!1;let s=n.posAtCoords({left:t.clientX,top:t.clientY});return s&&s.inside>-1&&V.isSelectable(n.state.doc.nodeAt(s.inside))?!1:(n.dispatch(n.state.tr.setSelection(new me(r))),!0)}function Qb(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof me))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let s=O.empty;for(let i=r.length-1;i>=0;i--)s=O.from(r[i].createAndFill(null,s));let o=n.state.tr.replace(t.pos,t.pos,new B(s,0,0));return o.setSelection(q.near(o.doc.resolve(t.pos+1))),n.dispatch(o),!1}function Zb(n){if(!(n.selection instanceof me))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",de.create(n.doc,[De.widget(n.selection.head,e,{key:"gapcursor"})])}var ms=200,Ce=function(){};Ce.prototype.append=function(e){return e.length?(e=Ce.from(e),!this.length&&e||e.length<ms&&this.leafAppend(e)||this.length<ms&&e.leafPrepend(this)||this.appendInner(e)):this};Ce.prototype.prepend=function(e){return e.length?Ce.from(e).append(this):this};Ce.prototype.appendInner=function(e){return new ek(this,e)};Ce.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?Ce.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};Ce.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};Ce.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)};Ce.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var s=[];return this.forEach(function(o,i){return s.push(e(o,i))},t,r),s};Ce.from=function(e){return e instanceof Ce?e:e&&e.length?new Wf(e):Ce.empty};var Wf=(function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(s,o){return s==0&&o==this.length?this:new e(this.values.slice(s,o))},e.prototype.getInner=function(s){return this.values[s]},e.prototype.forEachInner=function(s,o,i,l){for(var a=o;a<i;a++)if(s(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(s,o,i,l){for(var a=o-1;a>=i;a--)if(s(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=ms)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=ms)return new e(s.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e})(Ce);Ce.empty=new Wf([]);var ek=(function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,s,o,i){var l=this.left.length;if(s<l&&this.left.forEachInner(r,s,Math.min(o,l),i)===!1||o>l&&this.right.forEachInner(r,Math.max(s-l,0),Math.min(this.length,o)-l,i+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,s,o,i){var l=this.left.length;if(s>l&&this.right.forEachInvertedInner(r,s-l,Math.max(o,l)-l,i+l)===!1||o<l&&this.left.forEachInvertedInner(r,Math.min(s,l),o,i)===!1)return!1},e.prototype.sliceInner=function(r,s){if(r==0&&s==this.length)return this;var o=this.left.length;return s<=o?this.left.slice(r,s):r>=o?this.right.slice(r-o,s-o):this.left.slice(r,o).append(this.right.slice(0,s-o))},e.prototype.leafAppend=function(r){var s=this.right.leafAppend(r);if(s)return new e(this.left,s)},e.prototype.leafPrepend=function(r){var s=this.left.leafPrepend(r);if(s)return new e(s,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(Ce);const tk=500;class nt{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let s,o;t&&(s=this.remapping(r,this.items.length),o=s.maps.length);let i=e.tr,l,a,c=[],u=[];return this.items.forEach((d,f)=>{if(!d.step){s||(s=this.remapping(r,f+1),o=s.maps.length),o--,u.push(d);return}if(s){u.push(new lt(d.map));let h=d.step.map(s.slice(o)),m;h&&i.maybeStep(h).doc&&(m=i.mapping.maps[i.mapping.maps.length-1],c.push(new lt(m,void 0,void 0,c.length+u.length))),o--,m&&s.appendMap(m,o)}else i.maybeStep(d.step);if(d.selection)return l=s?d.selection.map(s.slice(o)):d.selection,a=new nt(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:i,selection:l}}addTransform(e,t,r,s){let o=[],i=this.eventCount,l=this.items,a=!s&&l.length?l.get(l.length-1):null;for(let u=0;u<e.steps.length;u++){let d=e.steps[u].invert(e.docs[u]),f=new lt(e.mapping.maps[u],d,t),h;(h=a&&a.merge(f))&&(f=h,u?o.pop():l=l.slice(0,l.length-1)),o.push(f),t&&(i++,t=void 0),s||(a=f)}let c=i-r.depth;return c>rk&&(l=nk(l,c),i-=c),new nt(l.append(o),i)}remapping(e,t){let r=new gr;return this.items.forEach((s,o)=>{let i=s.mirrorOffset!=null&&o-s.mirrorOffset>=e?r.maps.length-s.mirrorOffset:void 0;r.appendMap(s.map,i)},e,t),r}addMaps(e){return this.eventCount==0?this:new nt(this.items.append(e.map(t=>new lt(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],s=Math.max(0,this.items.length-t),o=e.mapping,i=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},s);let a=t;this.items.forEach(f=>{let h=o.getMirror(--a);if(h==null)return;i=Math.min(i,h);let m=o.maps[h];if(f.step){let g=e.steps[h].invert(e.docs[h]),x=f.selection&&f.selection.map(o.slice(a+1,h));x&&l++,r.push(new lt(m,g,x))}else r.push(new lt(m))},s);let c=[];for(let f=t;f<i;f++)c.push(new lt(o.maps[f]));let u=this.items.slice(0,s).append(c).append(r),d=new nt(u,l);return d.emptyItemCount()>tk&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,s=[],o=0;return this.items.forEach((i,l)=>{if(l>=e)s.push(i),i.selection&&o++;else if(i.step){let a=i.step.map(t.slice(r)),c=a&&a.getMap();if(r--,c&&t.appendMap(c,r),a){let u=i.selection&&i.selection.map(t.slice(r));u&&o++;let d=new lt(c.invert(),a,u),f,h=s.length-1;(f=s.length&&s[h].merge(d))?s[h]=f:s.push(d)}}else i.map&&r--},this.items.length,0),new nt(Ce.from(s.reverse()),o)}}nt.empty=new nt(Ce.empty,0);function nk(n,e){let t;return n.forEach((r,s)=>{if(r.selection&&e--==0)return t=s,!1}),n.slice(t)}class lt{constructor(e,t,r,s){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=s}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new lt(t.getMap().invert(),t,this.selection)}}}class jt{constructor(e,t,r,s,o){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=s,this.prevComposition=o}}const rk=20;function sk(n,e,t,r){let s=t.getMeta(cn),o;if(s)return s.historyState;t.getMeta(lk)&&(n=new jt(n.done,n.undone,null,0,-1));let i=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(i&&i.getMeta(cn))return i.getMeta(cn).redo?new jt(n.done.addTransform(t,void 0,r,Yr(e)),n.undone,wc(t.mapping.maps),n.prevTime,n.prevComposition):new jt(n.done,n.undone.addTransform(t,void 0,r,Yr(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(i&&i.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!i&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-r.newGroupDelay||!ok(t,n.prevRanges)),c=i?$o(n.prevRanges,t.mapping):wc(t.mapping.maps);return new jt(n.done.addTransform(t,a?e.selection.getBookmark():void 0,r,Yr(e)),nt.empty,c,t.time,l??n.prevComposition)}else return(o=t.getMeta("rebased"))?new jt(n.done.rebased(t,o),n.undone.rebased(t,o),$o(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new jt(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),$o(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function ok(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,s)=>{for(let o=0;o<e.length;o+=2)r<=e[o+1]&&s>=e[o]&&(t=!0)}),t}function wc(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,s,o,i)=>e.push(o,i));return e}function $o(n,e){if(!n)return null;let t=[];for(let r=0;r<n.length;r+=2){let s=e.map(n[r],1),o=e.map(n[r+1],-1);s<=o&&t.push(s,o)}return t}function ik(n,e,t){let r=Yr(e),s=cn.get(e).spec.config,o=(t?n.undone:n.done).popEvent(e,r);if(!o)return null;let i=o.selection.resolve(o.transform.doc),l=(t?n.done:n.undone).addTransform(o.transform,e.selection.getBookmark(),s,r),a=new jt(t?l:o.remaining,t?o.remaining:l,null,0,-1);return o.transform.setSelection(i).setMeta(cn,{redo:t,historyState:a})}let zo=!1,Cc=null;function Yr(n){let e=n.plugins;if(Cc!=e){zo=!1,Cc=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){zo=!0;break}}return zo}const cn=new ve("history"),lk=new ve("closeHistory");function ak(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new fe({key:cn,state:{init(){return new jt(nt.empty,nt.empty,null,0,-1)},apply(e,t,r){return sk(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,s=r=="historyUndo"?qf:r=="historyRedo"?Kf:null;return!s||!e.editable?!1:(t.preventDefault(),s(e.state,e.dispatch))}}}})}function Uf(n,e){return(t,r)=>{let s=cn.getState(t);if(!s||(n?s.undone:s.done).eventCount==0)return!1;if(r){let o=ik(s,t,n);o&&r(e?o.scrollIntoView():o)}return!0}}const qf=Uf(!1,!0),Kf=Uf(!0,!0);xe.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:n=>n.length,wordCounter:n=>n.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=n=>{const e=n?.node||this.editor.state.doc;if((n?.mode||this.options.mode)==="textSize"){const r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=n=>{const e=n?.node||this.editor.state.doc,t=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(t)}},addProseMirrorPlugins(){let n=!1;return[new fe({key:new ve("characterCount"),appendTransaction:(e,t,r)=>{if(n)return;const s=this.options.limit;if(s==null||s===0){n=!0;return}const o=this.storage.characters({node:r.doc});if(o>s){const i=o-s,l=0,a=i;console.warn(`[CharacterCount] Initial content exceeded limit of ${s} characters. Content was automatically trimmed.`);const c=r.tr.deleteRange(l,a);return n=!0,c}n=!0},filterTransaction:(e,t)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const s=this.storage.characters({node:t.doc}),o=this.storage.characters({node:e.doc});if(o<=r||s>r&&o>r&&o<=s)return!0;if(s>r&&o>r&&o>s||!e.getMeta("paste"))return!1;const l=e.selection.$head.pos,a=o-r,c=l-a,u=l;return e.deleteRange(c,u),!(this.storage.characters({node:e.doc})>r)}})]}});var ck=xe.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[Ub(this.options)]}});xe.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new fe({key:new ve("focus"),props:{decorations:({doc:n,selection:e})=>{const{isEditable:t,isFocused:r}=this.editor,{anchor:s}=e,o=[];if(!t||!r)return de.create(n,[]);let i=0;this.options.mode==="deepest"&&n.descendants((a,c)=>{if(a.isText)return;if(!(s>=c&&s<=c+a.nodeSize-1))return!1;i+=1});let l=0;return n.descendants((a,c)=>{if(a.isText||!(s>=c&&s<=c+a.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&i-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";o.push(De.node(c,c+a.nodeSize,{class:this.options.className}))}),de.create(n,o)}}})]}});var uk=xe.create({name:"gapCursor",addProseMirrorPlugins(){return[Gb()]},extendNodeSchema(n){var e;const t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=oe(H(n,"allowGapCursor",t)))!=null?e:null}}}),Tc="placeholder";function dk(n){return n.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}var YC=xe.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:Tc,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){const n=this.options.dataAttribute?`data-${dk(this.options.dataAttribute)}`:`data-${Tc}`;return[new fe({key:new ve("placeholder"),props:{decorations:({doc:e,selection:t})=>{const r=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:s}=t,o=[];if(!r)return null;const i=this.editor.isEmpty;return e.descendants((l,a)=>{const c=s>=a&&s<=a+l.nodeSize,u=!l.isLeaf&&lo(l);if((c||!this.options.showOnlyCurrent)&&u){const d=[this.options.emptyNodeClass];i&&d.push(this.options.emptyEditorClass);const f=De.node(a,a+l.nodeSize,{class:d.join(" "),[n]:typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:l,pos:a,hasAnchor:c}):this.options.placeholder});o.push(f)}return this.options.includeChildren}),de.create(e,o)}}})]}});xe.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:n,options:e}=this;return[new fe({key:new ve("selection"),props:{decorations(t){return t.selection.empty||n.isFocused||!n.isEditable||mf(t.selection)||n.view.dragging?null:de.create(t.doc,[De.inline(t.selection.from,t.selection.to,{class:e.className})])}}})]}});function Nc({types:n,node:e}){return e&&Array.isArray(n)&&n.includes(e.type)||e?.type===n}var fk=xe.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var n;const e=new ve(this.name),t=this.options.node||((n=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:n.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,s])=>s).filter(s=>(this.options.notAfter||[]).concat(t).includes(s.name));return[new fe({key:e,appendTransaction:(s,o,i)=>{const{doc:l,tr:a,schema:c}=i,u=e.getState(i),d=l.content.size,f=c.nodes[t];if(u)return a.insert(d,f.create())},state:{init:(s,o)=>{const i=o.tr.doc.lastChild;return!Nc({node:i,types:r})},apply:(s,o)=>{if(!s.docChanged||s.getMeta("__uniqueIDTransaction"))return o;const i=s.doc.lastChild;return!Nc({node:i,types:r})}}})]}}),hk=xe.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>qf(n,e),redo:()=>({state:n,dispatch:e})=>Kf(n,e)}},addProseMirrorPlugins(){return[ak(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),gs=(n,e)=>{if(n==="slot")return 0;if(n instanceof Function)return n(e);const{children:t,...r}=e??{};if(n==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[n,r,t]},pk=/^\s*>\s$/,mk=_e.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:n}){return gs("blockquote",{...Se(this.options.HTMLAttributes,n),children:gs("slot",{})})},parseMarkdown:(n,e)=>{var t;const r=(t=e.parseBlockChildren)!=null?t:e.parseChildren;return e.createNode("blockquote",void 0,r(n.tokens||[]))},renderMarkdown:(n,e)=>{if(!n.content)return"";const t=">",r=[];return n.content.forEach((s,o)=>{var i,l;const u=((l=(i=e.renderChild)==null?void 0:i.call(e,s,o))!=null?l:e.renderChildren([s])).split(`
103
+ `).map(d=>d.trim()===""?t:`${t} ${d}`);r.push(u.join(`
104
+ `))}),r.join(`
105
+ ${t}
106
+ `)},addCommands(){return{setBlockquote:()=>({commands:n})=>n.wrapIn(this.name),toggleBlockquote:()=>({commands:n})=>n.toggleWrap(this.name),unsetBlockquote:()=>({commands:n})=>n.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[Fn({find:pk,type:this.type})]}}),gk=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,xk=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,yk=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,bk=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,kk=vn.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:n=>n.type.name===this.name},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&null}]},renderHTML({HTMLAttributes:n}){return gs("strong",{...Se(this.options.HTMLAttributes,n),children:gs("slot",{})})},markdownTokenName:"strong",parseMarkdown:(n,e)=>e.applyMark("bold",e.parseInline(n.tokens||[])),renderMarkdown:(n,e)=>`**${e.renderChildren(n)}**`,addCommands(){return{setBold:()=>({commands:n})=>n.setMark(this.name),toggleBold:()=>({commands:n})=>n.toggleMark(this.name),unsetBold:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[Bn({find:gk,type:this.type}),Bn({find:yk,type:this.type})]},addPasteRules(){return[bn({find:xk,type:this.type}),bn({find:bk,type:this.type})]}}),Sk=/(^|[^`])`([^`]+)`(?!`)$/,vk=/(^|[^`])`([^`]+)`(?!`)/g,wk=vn.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:n}){return["code",Se(this.options.HTMLAttributes,n),0]},markdownTokenName:"codespan",parseMarkdown:(n,e)=>e.applyMark("code",[{type:"text",text:n.text||""}]),renderMarkdown:(n,e)=>n.content?`\`${e.renderChildren(n.content)}\``:"",addCommands(){return{setCode:()=>({commands:n})=>n.setMark(this.name),toggleCode:()=>({commands:n})=>n.toggleMark(this.name),unsetCode:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[Bn({find:Sk,type:this.type})]},addPasteRules(){return[bn({find:vk,type:this.type})]}}),Bo=4,Ck=/^```([a-z]+)?[\s\n]$/,Tk=/^~~~([a-z]+)?[\s\n]$/,Nk=_e.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:Bo,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:n=>{var e;const{languageClassPrefix:t}=this.options;if(!t)return null;const o=[...((e=n.firstElementChild)==null?void 0:e.classList)||[]].filter(i=>i.startsWith(t)).map(i=>i.replace(t,""))[0];return o||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:n,HTMLAttributes:e}){return["pre",Se(this.options.HTMLAttributes,e),["code",{class:n.attrs.language?this.options.languageClassPrefix+n.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(n,e)=>{var t,r;return((t=n.raw)==null?void 0:t.startsWith("```"))===!1&&((r=n.raw)==null?void 0:r.startsWith("~~~"))===!1&&n.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:n.lang||null},n.text?[e.createTextNode(n.text)]:[])},renderMarkdown:(n,e)=>{var t;let r="";const s=((t=n.attrs)==null?void 0:t.language)||"";return n.content?r=[`\`\`\`${s}`,e.renderChildren(n.content),"```"].join(`
107
+ `):r=`\`\`\`${s}
108
+
109
+ \`\`\``,r},addCommands(){return{setCodeBlock:n=>({commands:e})=>e.setNode(this.name,n),toggleCodeBlock:n=>({commands:e})=>e.toggleNode(this.name,"paragraph",n)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:n,$anchor:e}=this.editor.state.selection,t=e.pos===1;return!n||e.parent.type.name!==this.name?!1:t||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:n})=>{var e;if(!this.options.enableTabIndentation)return!1;const t=(e=this.options.tabSize)!=null?e:Bo,{state:r}=n,{selection:s}=r,{$from:o,empty:i}=s;if(o.parent.type!==this.type)return!1;const l=" ".repeat(t);return i?n.commands.insertContent(l):n.commands.command(({tr:a})=>{const{from:c,to:u}=s,h=r.doc.textBetween(c,u,`
110
+ `,`
111
+ `).split(`
112
+ `).map(m=>l+m).join(`
113
+ `);return a.replaceWith(c,u,r.schema.text(h)),!0})},"Shift-Tab":({editor:n})=>{var e;if(!this.options.enableTabIndentation)return!1;const t=(e=this.options.tabSize)!=null?e:Bo,{state:r}=n,{selection:s}=r,{$from:o,empty:i}=s;return o.parent.type!==this.type?!1:i?n.commands.command(({tr:l})=>{var a;const{pos:c}=o,u=o.start(),d=o.end(),h=r.doc.textBetween(u,d,`
114
+ `,`
115
+ `).split(`
116
+ `);let m=0,g=0;const x=c-u;for(let w=0;w<h.length;w+=1){if(g+h[w].length>=x){m=w;break}g+=h[w].length+1}const b=((a=h[m].match(/^ */))==null?void 0:a[0])||"",k=Math.min(b.length,t);if(k===0)return!0;let S=u;for(let w=0;w<m;w+=1)S+=h[w].length+1;return l.delete(S,S+k),c-S<=k&&l.setSelection(q.create(l.doc,S)),!0}):n.commands.command(({tr:l})=>{const{from:a,to:c}=s,f=r.doc.textBetween(a,c,`
117
+ `,`
118
+ `).split(`
119
+ `).map(h=>{var m;const g=((m=h.match(/^ */))==null?void 0:m[0])||"",x=Math.min(g.length,t);return h.slice(x)}).join(`
120
+ `);return l.replaceWith(a,c,r.schema.text(f)),!0})},Enter:({editor:n})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=n,{selection:t}=e,{$from:r,empty:s}=t;if(!s||r.parent.type!==this.type)return!1;const o=r.parentOffset===r.parent.nodeSize-2,i=r.parent.textContent.endsWith(`
121
+
122
+ `);return!o||!i?!1:n.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:n})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=n,{selection:t,doc:r}=e,{$from:s,empty:o}=t;if(!o||s.parent.type!==this.type||!(s.parentOffset===s.parent.nodeSize-2))return!1;const l=s.after();return l===void 0?!1:r.nodeAt(l)?n.commands.command(({tr:c})=>(c.setSelection(X.near(r.resolve(l))),!0)):n.commands.exitCode()}}},addInputRules(){return[yi({find:Ck,type:this.type,getAttributes:n=>({language:n[1]})}),yi({find:Tk,type:this.type,getAttributes:n=>({language:n[1]})})]},addProseMirrorPlugins(){return[new fe({key:new ve("codeBlockVSCodeHandler"),props:{handlePaste:(n,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const t=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),s=r?JSON.parse(r):void 0,o=s?.mode;if(!t||!o)return!1;const{tr:i,schema:l}=n.state,a=l.text(t.replace(/\r\n?/g,`
123
+ `));return i.replaceSelectionWith(this.type.create({language:o},a)),i.selection.$from.parent.type!==this.type&&i.setSelection(q.near(i.doc.resolve(Math.max(0,i.selection.from-2)))),i.setMeta("paste",!0),n.dispatch(i),!0}}})]}}),Mk=_e.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,`
124
+
125
+ `):""}),Ek=_e.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:n}){return["br",Se(this.options.HTMLAttributes,n)]},renderText(){return`
126
+ `},renderMarkdown:()=>`
127
+ `,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:n,chain:e,state:t,editor:r})=>n.first([()=>n.exitCode(),()=>n.command(()=>{const{selection:s,storedMarks:o}=t;if(s.$from.parent.type.spec.isolating)return!1;const{keepMarks:i}=this.options,{splittableMarks:l}=r.extensionManager,a=o||s.$to.parentOffset&&s.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:u})=>{if(u&&a&&i){const d=a.filter(f=>l.includes(f.type.name));c.ensureMarks(d)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),Ak=_e.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(n=>({tag:`h${n}`,attrs:{level:n}}))},renderHTML({node:n,HTMLAttributes:e}){return[`h${this.options.levels.includes(n.attrs.level)?n.attrs.level:this.options.levels[0]}`,Se(this.options.HTMLAttributes,e),0]},parseMarkdown:(n,e)=>e.createNode("heading",{level:n.depth||1},e.parseInline(n.tokens||[])),renderMarkdown:(n,e)=>{var t;const r=(t=n.attrs)!=null&&t.level?parseInt(n.attrs.level,10):1,s="#".repeat(r);return n.content?`${s} ${e.renderChildren(n.content)}`:""},addCommands(){return{setHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.setNode(this.name,n):!1,toggleHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.toggleNode(this.name,"paragraph",n):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((n,e)=>({...n,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(n=>yi({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}}),jk=_e.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:n}){return["hr",Se(this.options.HTMLAttributes,n)]},markdownTokenName:"hr",parseMarkdown:(n,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:n,state:e})=>{if(!Ty(e,e.schema.nodes[this.name]))return!1;const{selection:t}=e,{$to:r}=t,s=n();return mf(t)?s.insertContentAt(r.pos,{type:this.name}):s.insertContent({type:this.name}),s.command(({state:o,tr:i,dispatch:l})=>{if(l){const{$to:a}=i.selection,c=a.end();if(a.nodeAfter)a.nodeAfter.isTextblock?i.setSelection(q.create(i.doc,a.pos+1)):a.nodeAfter.isBlock?i.setSelection(V.create(i.doc,a.pos)):i.setSelection(q.create(i.doc,a.pos));else{const u=o.schema.nodes[this.options.nextNodeType]||a.parent.type.contentMatch.defaultType,d=u?.create();d&&(i.insert(c,d),i.setSelection(q.create(i.doc,c+1)))}i.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Cy({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),Ik=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Ok=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Rk=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,Dk=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Pk=vn.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:n=>n.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:n=>n.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:n}){return["em",Se(this.options.HTMLAttributes,n),0]},addCommands(){return{setItalic:()=>({commands:n})=>n.setMark(this.name),toggleItalic:()=>({commands:n})=>n.toggleMark(this.name),unsetItalic:()=>({commands:n})=>n.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(n,e)=>e.applyMark("italic",e.parseInline(n.tokens||[])),renderMarkdown:(n,e)=>`*${e.renderChildren(n)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Bn({find:Ik,type:this.type}),Bn({find:Rk,type:this.type})]},addPasteRules(){return[bn({find:Ok,type:this.type}),bn({find:Dk,type:this.type})]}});const Lk="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",_k="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2",Si="numeric",vi="ascii",wi="alpha",ar="asciinumeric",tr="alphanumeric",Ci="domain",Jf="emoji",$k="scheme",zk="slashscheme",Fo="whitespace";function Bk(n,e){return n in e||(e[n]=[]),e[n]}function rn(n,e,t){e[Si]&&(e[ar]=!0,e[tr]=!0),e[vi]&&(e[ar]=!0,e[wi]=!0),e[ar]&&(e[tr]=!0),e[wi]&&(e[tr]=!0),e[tr]&&(e[Ci]=!0),e[Jf]&&(e[Ci]=!0);for(const r in e){const s=Bk(r,t);s.indexOf(n)<0&&s.push(n)}}function Fk(n,e){const t={};for(const r in e)e[r].indexOf(n)>=0&&(t[r]=!0);return t}function $e(n=null){this.j={},this.jr=[],this.jd=null,this.t=n}$e.groups={};$e.prototype={accepts(){return!!this.t},go(n){const e=this,t=e.j[n];if(t)return t;for(let r=0;r<e.jr.length;r++){const s=e.jr[r][0],o=e.jr[r][1];if(o&&s.test(n))return o}return e.jd},has(n,e=!1){return e?n in this.j:!!this.go(n)},ta(n,e,t,r){for(let s=0;s<n.length;s++)this.tt(n[s],e,t,r)},tr(n,e,t,r){r=r||$e.groups;let s;return e&&e.j?s=e:(s=new $e(e),t&&r&&rn(e,t,r)),this.jr.push([n,s]),s},ts(n,e,t,r){let s=this;const o=n.length;if(!o)return s;for(let i=0;i<o-1;i++)s=s.tt(n[i]);return s.tt(n[o-1],e,t,r)},tt(n,e,t,r){r=r||$e.groups;const s=this;if(e&&e.j)return s.j[n]=e,e;const o=e;let i,l=s.go(n);if(l?(i=new $e,Object.assign(i.j,l.j),i.jr.push.apply(i.jr,l.jr),i.jd=l.jd,i.t=l.t):i=new $e,o){if(r)if(i.t&&typeof i.t=="string"){const a=Object.assign(Fk(i.t,r),t);rn(o,a,r)}else t&&rn(o,t,r);i.t=o}return s.j[n]=i,i}};const G=(n,e,t,r,s)=>n.ta(e,t,r,s),pe=(n,e,t,r,s)=>n.tr(e,t,r,s),Mc=(n,e,t,r,s)=>n.ts(e,t,r,s),P=(n,e,t,r,s)=>n.tt(e,t,r,s),bt="WORD",Ti="UWORD",Gf="ASCIINUMERICAL",Xf="ALPHANUMERICAL",wr="LOCALHOST",Ni="TLD",Mi="UTLD",Qr="SCHEME",En="SLASH_SCHEME",jl="NUM",Ei="WS",Il="NL",cr="OPENBRACE",ur="CLOSEBRACE",xs="OPENBRACKET",ys="CLOSEBRACKET",bs="OPENPAREN",ks="CLOSEPAREN",Ss="OPENANGLEBRACKET",vs="CLOSEANGLEBRACKET",ws="FULLWIDTHLEFTPAREN",Cs="FULLWIDTHRIGHTPAREN",Ts="LEFTCORNERBRACKET",Ns="RIGHTCORNERBRACKET",Ms="LEFTWHITECORNERBRACKET",Es="RIGHTWHITECORNERBRACKET",As="FULLWIDTHLESSTHAN",js="FULLWIDTHGREATERTHAN",Is="AMPERSAND",Os="APOSTROPHE",Rs="ASTERISK",It="AT",Ds="BACKSLASH",Ps="BACKTICK",Ls="CARET",Rt="COLON",Ol="COMMA",_s="DOLLAR",at="DOT",$s="EQUALS",Rl="EXCLAMATION",Ke="HYPHEN",dr="PERCENT",zs="PIPE",Bs="PLUS",Fs="POUND",fr="QUERY",Dl="QUOTE",Yf="FULLWIDTHMIDDLEDOT",Pl="SEMI",ct="SLASH",hr="TILDE",Hs="UNDERSCORE",Qf="EMOJI",Vs="SYM";var Zf=Object.freeze({__proto__:null,ALPHANUMERICAL:Xf,AMPERSAND:Is,APOSTROPHE:Os,ASCIINUMERICAL:Gf,ASTERISK:Rs,AT:It,BACKSLASH:Ds,BACKTICK:Ps,CARET:Ls,CLOSEANGLEBRACKET:vs,CLOSEBRACE:ur,CLOSEBRACKET:ys,CLOSEPAREN:ks,COLON:Rt,COMMA:Ol,DOLLAR:_s,DOT:at,EMOJI:Qf,EQUALS:$s,EXCLAMATION:Rl,FULLWIDTHGREATERTHAN:js,FULLWIDTHLEFTPAREN:ws,FULLWIDTHLESSTHAN:As,FULLWIDTHMIDDLEDOT:Yf,FULLWIDTHRIGHTPAREN:Cs,HYPHEN:Ke,LEFTCORNERBRACKET:Ts,LEFTWHITECORNERBRACKET:Ms,LOCALHOST:wr,NL:Il,NUM:jl,OPENANGLEBRACKET:Ss,OPENBRACE:cr,OPENBRACKET:xs,OPENPAREN:bs,PERCENT:dr,PIPE:zs,PLUS:Bs,POUND:Fs,QUERY:fr,QUOTE:Dl,RIGHTCORNERBRACKET:Ns,RIGHTWHITECORNERBRACKET:Es,SCHEME:Qr,SEMI:Pl,SLASH:ct,SLASH_SCHEME:En,SYM:Vs,TILDE:hr,TLD:Ni,UNDERSCORE:Hs,UTLD:Mi,UWORD:Ti,WORD:bt,WS:Ei});const xt=/[a-z]/,Xn=new RegExp("\\p{L}","u"),Ho=new RegExp("\\p{Emoji}","u"),yt=/\d/,Vo=/\s/,Ec="\r",Wo=`
128
+ `,Hk="️",Vk="‍",Uo="";let Vr=null,Wr=null;function Wk(n=[]){const e={};$e.groups=e;const t=new $e;Vr==null&&(Vr=Ac(Lk)),Wr==null&&(Wr=Ac(_k)),P(t,"'",Os),P(t,"{",cr),P(t,"}",ur),P(t,"[",xs),P(t,"]",ys),P(t,"(",bs),P(t,")",ks),P(t,"<",Ss),P(t,">",vs),P(t,"(",ws),P(t,")",Cs),P(t,"「",Ts),P(t,"」",Ns),P(t,"『",Ms),P(t,"』",Es),P(t,"<",As),P(t,">",js),P(t,"&",Is),P(t,"*",Rs),P(t,"@",It),P(t,"`",Ps),P(t,"^",Ls),P(t,":",Rt),P(t,",",Ol),P(t,"$",_s),P(t,".",at),P(t,"=",$s),P(t,"!",Rl),P(t,"-",Ke),P(t,"%",dr),P(t,"|",zs),P(t,"+",Bs),P(t,"#",Fs),P(t,"?",fr),P(t,'"',Dl),P(t,"/",ct),P(t,";",Pl),P(t,"~",hr),P(t,"_",Hs),P(t,"\\",Ds),P(t,"・",Yf);const r=pe(t,yt,jl,{[Si]:!0});pe(r,yt,r);const s=pe(r,xt,Gf,{[ar]:!0}),o=pe(r,Xn,Xf,{[tr]:!0}),i=pe(t,xt,bt,{[vi]:!0});pe(i,yt,s),pe(i,xt,i),pe(s,yt,s),pe(s,xt,s);const l=pe(t,Xn,Ti,{[wi]:!0});pe(l,xt),pe(l,yt,o),pe(l,Xn,l),pe(o,yt,o),pe(o,xt),pe(o,Xn,o);const a=P(t,Wo,Il,{[Fo]:!0}),c=P(t,Ec,Ei,{[Fo]:!0}),u=pe(t,Vo,Ei,{[Fo]:!0});P(t,Uo,u),P(c,Wo,a),P(c,Uo,u),pe(c,Vo,u),P(u,Ec),P(u,Wo),pe(u,Vo,u),P(u,Uo,u);const d=pe(t,Ho,Qf,{[Jf]:!0});P(d,"#"),pe(d,Ho,d),P(d,Hk,d);const f=P(d,Vk);P(f,"#"),pe(f,Ho,d);const h=[[xt,i],[yt,s]],m=[[xt,null],[Xn,l],[yt,o]];for(let g=0;g<Vr.length;g++)Mt(t,Vr[g],Ni,bt,h);for(let g=0;g<Wr.length;g++)Mt(t,Wr[g],Mi,Ti,m);rn(Ni,{tld:!0,ascii:!0},e),rn(Mi,{utld:!0,alpha:!0},e),Mt(t,"file",Qr,bt,h),Mt(t,"mailto",Qr,bt,h),Mt(t,"http",En,bt,h),Mt(t,"https",En,bt,h),Mt(t,"ftp",En,bt,h),Mt(t,"ftps",En,bt,h),rn(Qr,{scheme:!0,ascii:!0},e),rn(En,{slashscheme:!0,ascii:!0},e),n=n.sort((g,x)=>g[0]>x[0]?1:-1);for(let g=0;g<n.length;g++){const x=n[g][0],b=n[g][1]?{[$k]:!0}:{[zk]:!0};x.indexOf("-")>=0?b[Ci]=!0:xt.test(x)?yt.test(x)?b[ar]=!0:b[vi]=!0:b[Si]=!0,Mc(t,x,x,b)}return Mc(t,"localhost",wr,{ascii:!0}),t.jd=new $e(Vs),{start:t,tokens:Object.assign({groups:e},Zf)}}function eh(n,e){const t=Uk(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=t.length,s=[];let o=0,i=0;for(;i<r;){let l=n,a=null,c=0,u=null,d=-1,f=-1;for(;i<r&&(a=l.go(t[i]));)l=a,l.accepts()?(d=0,f=0,u=l):d>=0&&(d+=t[i].length,f++),c+=t[i].length,o+=t[i].length,i++;o-=d,i-=f,c-=d,s.push({t:u.t,v:e.slice(o-c,o),s:o-c,e:o})}return s}function Uk(n){const e=[],t=n.length;let r=0;for(;r<t;){let s=n.charCodeAt(r),o,i=s<55296||s>56319||r+1===t||(o=n.charCodeAt(r+1))<56320||o>57343?n[r]:n.slice(r,r+2);e.push(i),r+=i.length}return e}function Mt(n,e,t,r,s){let o;const i=e.length;for(let l=0;l<i-1;l++){const a=e[l];n.j[a]?o=n.j[a]:(o=new $e(r),o.jr=s.slice(),n.j[a]=o),n=o}return o=new $e(t),o.jr=s.slice(),n.j[e[i-1]]=o,o}function Ac(n){const e=[],t=[];let r=0,s="0123456789";for(;r<n.length;){let o=0;for(;s.indexOf(n[r+o])>=0;)o++;if(o>0){e.push(t.join(""));for(let i=parseInt(n.substring(r,r+o),10);i>0;i--)t.pop();r+=o}else t.push(n[r]),r++}return e}const Cr={defaultProtocol:"http",events:null,format:jc,formatHref:jc,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Ll(n,e=null){let t=Object.assign({},Cr);n&&(t=Object.assign(t,n instanceof Ll?n.o:n));const r=t.ignoreTags,s=[];for(let o=0;o<r.length;o++)s.push(r[o].toUpperCase());this.o=t,e&&(this.defaultRender=e),this.ignoreTags=s}Ll.prototype={o:Cr,ignoreTags:[],defaultRender(n){return n},check(n){return this.get("validate",n.toString(),n)},get(n,e,t){const r=e!=null;let s=this.o[n];return s&&(typeof s=="object"?(s=t.t in s?s[t.t]:Cr[n],typeof s=="function"&&r&&(s=s(e,t))):typeof s=="function"&&r&&(s=s(e,t.t,t)),s)},getObj(n,e,t){let r=this.o[n];return typeof r=="function"&&e!=null&&(r=r(e,t.t,t)),r},render(n){const e=n.render(this);return(this.get("render",null,n)||this.defaultRender)(e,n.t,n)}};function jc(n){return n}function th(n,e){this.t="token",this.v=n,this.tk=e}th.prototype={isLink:!1,toString(){return this.v},toHref(n){return this.toString()},toFormattedString(n){const e=this.toString(),t=n.get("truncate",e,this),r=n.get("format",e,this);return t&&r.length>t?r.substring(0,t)+"…":r},toFormattedHref(n){return n.get("formatHref",this.toHref(n.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(n=Cr.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(n),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(n){return{type:this.t,value:this.toFormattedString(n),isLink:this.isLink,href:this.toFormattedHref(n),start:this.startIndex(),end:this.endIndex()}},validate(n){return n.get("validate",this.toString(),this)},render(n){const e=this,t=this.toHref(n.get("defaultProtocol")),r=n.get("formatHref",t,this),s=n.get("tagName",t,e),o=this.toFormattedString(n),i={},l=n.get("className",t,e),a=n.get("target",t,e),c=n.get("rel",t,e),u=n.getObj("attributes",t,e),d=n.getObj("events",t,e);return i.href=r,l&&(i.class=l),a&&(i.target=a),c&&(i.rel=c),u&&Object.assign(i,u),{tagName:s,attributes:i,content:o,eventListeners:d}}};function fo(n,e){class t extends th{constructor(s,o){super(s,o),this.t=n}}for(const r in e)t.prototype[r]=e[r];return t.t=n,t}const Ic=fo("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),Oc=fo("text"),qk=fo("nl"),Ur=fo("url",{isLink:!0,toHref(n=Cr.defaultProtocol){return this.hasProtocol()?this.v:`${n}://${this.v}`},hasProtocol(){const n=this.tk;return n.length>=2&&n[0].t!==wr&&n[1].t===Rt}}),qe=n=>new $e(n);function Kk({groups:n}){const e=n.domain.concat([Is,Rs,It,Ds,Ps,Ls,_s,$s,Ke,jl,dr,zs,Bs,Fs,ct,Vs,hr,Hs]),t=[Os,Rt,Ol,at,Rl,dr,fr,Dl,Pl,Ss,vs,cr,ur,ys,xs,bs,ks,ws,Cs,Ts,Ns,Ms,Es,As,js],r=[Is,Os,Rs,Ds,Ps,Ls,_s,$s,Ke,cr,ur,dr,zs,Bs,Fs,fr,ct,Vs,hr,Hs],s=qe(),o=P(s,hr);G(o,r,o),G(o,n.domain,o);const i=qe(),l=qe(),a=qe();G(s,n.domain,i),G(s,n.scheme,l),G(s,n.slashscheme,a),G(i,r,o),G(i,n.domain,i);const c=P(i,It);P(o,It,c),P(l,It,c),P(a,It,c);const u=P(o,at);G(u,r,o),G(u,n.domain,o);const d=qe();G(c,n.domain,d),G(d,n.domain,d);const f=P(d,at);G(f,n.domain,d);const h=qe(Ic);G(f,n.tld,h),G(f,n.utld,h),P(c,wr,h);const m=P(d,Ke);P(m,Ke,m),G(m,n.domain,d),G(h,n.domain,d),P(h,at,f),P(h,Ke,m);const g=P(h,Rt);G(g,n.numeric,Ic);const x=P(i,Ke),y=P(i,at);P(x,Ke,x),G(x,n.domain,i),G(y,r,o),G(y,n.domain,i);const b=qe(Ur);G(y,n.tld,b),G(y,n.utld,b),G(b,n.domain,i),G(b,r,o),P(b,at,y),P(b,Ke,x),P(b,It,c);const k=P(b,Rt),S=qe(Ur);G(k,n.numeric,S);const v=qe(Ur),w=qe();G(v,e,v),G(v,t,w),G(w,e,v),G(w,t,w),P(b,ct,v),P(S,ct,v);const C=P(l,Rt),T=P(a,Rt),N=P(T,ct),M=P(N,ct);G(l,n.domain,i),P(l,at,y),P(l,Ke,x),G(a,n.domain,i),P(a,at,y),P(a,Ke,x),G(C,n.domain,v),P(C,ct,v),P(C,fr,v),G(M,n.domain,v),G(M,e,v),P(M,ct,v);const j=[[cr,ur],[xs,ys],[bs,ks],[Ss,vs],[ws,Cs],[Ts,Ns],[Ms,Es],[As,js]];for(let R=0;R<j.length;R++){const[A,D]=j[R],I=P(v,A);P(w,A,I),P(I,D,v);const $=qe(Ur);G(I,e,$);const L=qe();G(I,t),G($,e,$),G($,t,L),G(L,e,$),G(L,t,L),P($,D,v),P(L,D,v)}return P(s,wr,b),P(s,Il,qk),{start:s,tokens:Zf}}function Jk(n,e,t){let r=t.length,s=0,o=[],i=[];for(;s<r;){let l=n,a=null,c=null,u=0,d=null,f=-1;for(;s<r&&!(a=l.go(t[s].t));)i.push(t[s++]);for(;s<r&&(c=a||l.go(t[s].t));)a=null,l=c,l.accepts()?(f=0,d=l):f>=0&&f++,s++,u++;if(f<0)s-=u,s<r&&(i.push(t[s]),s++);else{i.length>0&&(o.push(qo(Oc,e,i)),i=[]),s-=f,u-=f;const h=d.t,m=t.slice(s-u,s);o.push(qo(h,e,m))}}return i.length>0&&o.push(qo(Oc,e,i)),o}function qo(n,e,t){const r=t[0].s,s=t[t.length-1].e,o=e.slice(r,s);return new n(o,t)}const Gk=typeof console<"u"&&console&&console.warn||(()=>{}),Xk="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",ce={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function Yk(){return $e.groups={},ce.scanner=null,ce.parser=null,ce.tokenQueue=[],ce.pluginQueue=[],ce.customSchemes=[],ce.initialized=!1,ce}function Rc(n,e=!1){if(ce.initialized&&Gk(`linkifyjs: already initialized - will not register custom scheme "${n}" ${Xk}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(n))throw new Error(`linkifyjs: incorrect scheme format.
129
+ 1. Must only contain digits, lowercase ASCII letters or "-"
130
+ 2. Cannot start or end with "-"
131
+ 3. "-" cannot repeat`);ce.customSchemes.push([n,e])}function Qk(){ce.scanner=Wk(ce.customSchemes);for(let n=0;n<ce.tokenQueue.length;n++)ce.tokenQueue[n][1]({scanner:ce.scanner});ce.parser=Kk(ce.scanner.tokens);for(let n=0;n<ce.pluginQueue.length;n++)ce.pluginQueue[n][1]({scanner:ce.scanner,parser:ce.parser});return ce.initialized=!0,ce}function _l(n){return ce.initialized||Qk(),Jk(ce.parser.start,n,eh(ce.scanner.start,n))}_l.scan=eh;function nh(n,e=null,t=null){if(e&&typeof e=="object"){if(t)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);t=e,e=null}const r=new Ll(t),s=_l(n),o=[];for(let i=0;i<s.length;i++){const l=s[i];l.isLink&&(!e||l.t===e)&&r.check(l)&&o.push(l.toFormattedObject(r))}return o}var $l="[\0-   ᠎ -\u2029  ]",Zk=new RegExp($l),eS=new RegExp(`${$l}$`),tS=new RegExp($l,"g");function nS(n){return n.length===1?n[0].isLink:n.length===3&&n[1].isLink?["()","[]"].includes(n[0].value+n[2].value):!1}function rS(n){return new fe({key:new ve("autolink"),appendTransaction:(e,t,r)=>{const s=e.some(c=>c.docChanged)&&!t.doc.eq(r.doc),o=e.some(c=>c.getMeta("preventAutolink"));if(!s||o)return;const{tr:i}=r,l=lf(t.doc,[...e]);if(pf(l).forEach(({newRange:c})=>{const u=C0(r.doc,c,h=>h.isTextblock);let d,f;if(u.length>1)d=u[0],f=r.doc.textBetween(d.pos,d.pos+d.node.nodeSize,void 0," ");else if(u.length){const h=r.doc.textBetween(c.from,c.to," "," ");if(!eS.test(h))return;d=u[0],f=r.doc.textBetween(d.pos,c.to,void 0," ")}if(d&&f){const h=f.split(Zk).filter(Boolean);if(h.length<=0)return!1;const m=h[h.length-1],g=d.pos+f.lastIndexOf(m);if(!m)return!1;const x=_l(m).map(y=>y.toObject(n.defaultProtocol));if(!nS(x))return!1;x.filter(y=>y.isLink).map(y=>({...y,from:g+y.start+1,to:g+y.end+1})).filter(y=>r.schema.marks.code?!r.doc.rangeHasMark(y.from,y.to,r.schema.marks.code):!0).filter(y=>n.validate(y.value)).filter(y=>n.shouldAutoLink(y.value)).forEach(y=>{vl(y.from,y.to,r.doc).some(b=>b.mark.type===n.type)||i.addMark(y.from,y.to,n.type.create({href:y.href}))})}}),!!i.steps.length)return i}})}function sS(n){return new fe({key:new ve("handleClickLink"),props:{handleClick:(e,t,r)=>{var s,o;if(r.button!==0||!e.editable)return!1;let i=null;if(r.target instanceof HTMLAnchorElement)i=r.target;else{const a=r.target;if(!a)return!1;const c=n.editor.view.dom;i=a.closest("a"),i&&!c.contains(i)&&(i=null)}if(!i)return!1;let l=!1;if(n.enableClickSelection&&(l=n.editor.commands.extendMarkRange(n.type.name)),n.openOnClick){const a=hf(e.state,n.type.name),c=(s=i.href)!=null?s:a.href,u=(o=i.target)!=null?o:a.target;c&&(window.open(c,u),l=!0)}return l}}})}function oS(n){return new fe({key:new ve("handlePasteLink"),props:{handlePaste:(e,t,r)=>{const{shouldAutoLink:s}=n,{state:o}=e,{selection:i}=o,{empty:l}=i;if(l)return!1;let a="";r.content.forEach(u=>{a+=u.textContent});const c=nh(a,{defaultProtocol:n.defaultProtocol}).find(u=>u.isLink&&u.value===a);return!a||!c||s!==void 0&&!s(c.value)?!1:n.editor.commands.setMark(n.type,{href:c.href})}}})}function Xt(n,e){const t=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const s=typeof r=="string"?r:r.scheme;s&&t.push(s)}),!n||n.replace(tS,"").match(new RegExp(`^(?:(?:${t.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var iS=vn.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(n=>{if(typeof n=="string"){Rc(n);return}Rc(n.scheme,n.optionalSlashes)})},onDestroy(){Yk()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(n,e)=>!!Xt(n,e.protocols),validate:n=>!!n,shouldAutoLink:n=>{const e=/^[a-z][a-z0-9+.-]*:\/\//i.test(n),t=/^[a-z][a-z0-9+.-]*:/i.test(n);if(e||t&&!n.includes("@"))return!0;const s=(n.includes("@")?n.split("@").pop():n).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(s)||!/\./.test(s))}}},addAttributes(){return{href:{default:null,parseHTML(n){return n.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class},title:{default:null}}},parseHTML(){return[{tag:"a[href]",getAttrs:n=>{const e=n.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:t=>!!Xt(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:n}){return this.options.isAllowedUri(n.href,{defaultValidate:e=>!!Xt(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Se(this.options.HTMLAttributes,n),0]:["a",Se(this.options.HTMLAttributes,{...n,href:""}),0]},markdownTokenName:"link",parseMarkdown:(n,e)=>e.applyMark("link",e.parseInline(n.tokens||[]),{href:n.href,title:n.title||null}),renderMarkdown:(n,e)=>{var t,r,s,o;const i=(r=(t=n.attrs)==null?void 0:t.href)!=null?r:"",l=(o=(s=n.attrs)==null?void 0:s.title)!=null?o:"",a=e.renderChildren(n);return l?`[${a}](${i} "${l}")`:`[${a}](${i})`},addCommands(){return{setLink:n=>({chain:e})=>{const{href:t}=n;return this.options.isAllowedUri(t,{defaultValidate:r=>!!Xt(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,n).setMeta("preventAutolink",!0).run():!1},toggleLink:n=>({chain:e})=>{const{href:t}=n||{};return t&&!this.options.isAllowedUri(t,{defaultValidate:r=>!!Xt(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,n,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:n})=>n().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[bn({find:n=>{const e=[];if(n){const{protocols:t,defaultProtocol:r}=this.options,s=nh(n).filter(o=>o.isLink&&this.options.isAllowedUri(o.value,{defaultValidate:i=>!!Xt(i,t),protocols:t,defaultProtocol:r}));s.length&&s.forEach(o=>{this.options.shouldAutoLink(o.value)&&e.push({text:o.value,data:{href:o.href},index:o.start})})}return e},type:this.type,getAttributes:n=>{var e;return{href:(e=n.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const n=[],{protocols:e,defaultProtocol:t}=this.options;return this.options.autolink&&n.push(rS({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:s=>!!Xt(s,e),protocols:e,defaultProtocol:t}),shouldAutoLink:this.options.shouldAutoLink})),n.push(sS({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&n.push(oS({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),n}}),lS=Object.defineProperty,aS=(n,e)=>{for(var t in e)lS(n,t,{get:e[t],enumerable:!0})},cS="listItem",Dc="textStyle",Pc=/^\s*([-+*])\s$/,rh=_e.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:n}){return["ul",Se(this.options.HTMLAttributes,n),0]},markdownTokenName:"list",parseMarkdown:(n,e)=>n.type!=="list"||n.ordered?[]:{type:"bulletList",content:n.items?e.parseChildren(n.items):[]},renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,`
132
+ `):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(cS,this.editor.getAttributes(Dc)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let n=Fn({find:Pc,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(n=Fn({find:Pc,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Dc),editor:this.editor})),[n]}}),sh=_e.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",Se(this.options.HTMLAttributes,n),0]},markdownTokenName:"list_item",parseMarkdown:(n,e)=>{var t;if(n.type!=="list_item")return[];const r=(t=e.parseBlockChildren)!=null?t:e.parseChildren;let s=[];if(n.tokens&&n.tokens.length>0)if(n.tokens.some(i=>i.type==="paragraph"))s=r(n.tokens);else{const i=n.tokens[0];if(i&&i.type==="text"&&i.tokens&&i.tokens.length>0){if(s=[{type:"paragraph",content:e.parseInline(i.tokens)}],n.tokens.length>1){const a=n.tokens.slice(1),c=r(a);s.push(...c)}}else s=r(n.tokens)}return s.length===0&&(s=[{type:"paragraph",content:[]}]),{type:"listItem",content:s}},renderMarkdown:(n,e,t)=>Nl(n,e,r=>{var s,o;return r.parentType==="bulletList"?"- ":r.parentType==="orderedList"?`${(((o=(s=r.meta)==null?void 0:s.parentAttrs)==null?void 0:o.start)||1)+r.index}. `:"- "},t),addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),uS={};aS(uS,{findListItemPos:()=>Ir,getNextListDepth:()=>zl,handleBackspace:()=>Ai,handleDelete:()=>ji,hasListBefore:()=>oh,hasListItemAfter:()=>dS,hasListItemBefore:()=>ih,listItemHasSubList:()=>lh,nextListIsDeeper:()=>ah,nextListIsHigher:()=>ch});var Ir=(n,e)=>{const{$from:t}=e.selection,r=ke(n,e.schema);let s=null,o=t.depth,i=t.pos,l=null;for(;o>0&&l===null;)s=t.node(o),s.type===r?l=o:(o-=1,i-=1);return l===null?null:{$pos:e.doc.resolve(i),depth:l}},zl=(n,e)=>{const t=Ir(n,e);if(!t)return!1;const[,r]=P0(e,n,t.$pos.pos+4);return r},oh=(n,e,t)=>{const{$anchor:r}=n.selection,s=Math.max(0,r.pos-2),o=n.doc.resolve(s).node();return!(!o||!t.includes(o.type.name))},ih=(n,e)=>{var t;const{$anchor:r}=e.selection,s=e.doc.resolve(r.pos-2);return!(s.index()===0||((t=s.nodeBefore)==null?void 0:t.type.name)!==n)},lh=(n,e,t)=>{if(!t)return!1;const r=ke(n,e.schema);let s=!1;return t.descendants(o=>{o.type===r&&(s=!0)}),s},Ai=(n,e,t)=>{if(n.commands.undoInputRule())return!0;if(n.state.selection.from!==n.state.selection.to)return!1;if(!Wt(n.state,e)&&oh(n.state,e,t)){const{$anchor:l}=n.state.selection,a=n.state.doc.resolve(l.before()-1),c=[];a.node().descendants((f,h)=>{f.type.name===e&&c.push({node:f,pos:h})});const u=c.at(-1);if(!u)return!1;const d=n.state.doc.resolve(a.start()+u.pos+1);return n.chain().cut({from:l.start()-1,to:l.end()+1},d.end()).joinForward().run()}if(!Wt(n.state,e)||!z0(n.state))return!1;const r=Ir(e,n.state);if(!r)return!1;const o=n.state.doc.resolve(r.$pos.pos-2).node(r.depth),i=lh(e,n.state,o);return ih(e,n.state)&&!i?n.commands.joinItemBackward():n.chain().liftListItem(e).run()},ah=(n,e)=>{const t=zl(n,e),r=Ir(n,e);return!r||!t?!1:t>r.depth},ch=(n,e)=>{const t=zl(n,e),r=Ir(n,e);return!r||!t?!1:t<r.depth},ji=(n,e)=>{if(!Wt(n.state,e)||!$0(n.state,e))return!1;const{selection:t}=n.state,{$from:r,$to:s}=t;return!t.empty&&r.sameParent(s)?!1:ah(e,n.state)?n.chain().focus(n.state.selection.from+4).lift(e).joinBackward().run():ch(e,n.state)?n.chain().joinForward().joinBackward().run():n.commands.joinItemForward()},dS=(n,e)=>{var t;const{$anchor:r}=e.selection,s=e.doc.resolve(r.pos-r.parentOffset-2);return!(s.index()===s.parent.childCount-1||((t=s.nodeAfter)==null?void 0:t.type.name)!==n)},uh=xe.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t})=>{n.state.schema.nodes[t]!==void 0&&ji(n,t)&&(e=!0)}),e},"Mod-Delete":({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t})=>{n.state.schema.nodes[t]!==void 0&&ji(n,t)&&(e=!0)}),e},Backspace:({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t,wrapperNames:r})=>{n.state.schema.nodes[t]!==void 0&&Ai(n,t,r)&&(e=!0)}),e},"Mod-Backspace":({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t,wrapperNames:r})=>{n.state.schema.nodes[t]!==void 0&&Ai(n,t,r)&&(e=!0)}),e}}}}),Lc=/^(\s*)(\d+)\.\s+(.*)$/,fS=/^\s/;function hS(n){const e=[];let t=0,r=0;for(;t<n.length;){const s=n[t],o=s.match(Lc);if(!o)break;const[,i,l,a]=o,c=i.length;let u=a,d=t+1;const f=[s];for(;d<n.length;){const h=n[d];if(h.match(Lc))break;if(h.trim()==="")f.push(h),u+=`
133
+ `,d+=1;else if(h.match(fS))f.push(h),u+=`
134
+ ${h.slice(c+2)}`,d+=1;else break}e.push({indent:c,number:parseInt(l,10),content:u.trim(),raw:f.join(`
135
+ `)}),r=d,t=d}return[e,r]}function dh(n,e,t){var r;const s=[];let o=0;for(;o<n.length;){const i=n[o];if(i.indent===e){const l=i.content.split(`
136
+ `),a=((r=l[0])==null?void 0:r.trim())||"",c=[];a&&c.push({type:"paragraph",raw:a,tokens:t.inlineTokens(a)});const u=l.slice(1).join(`
137
+ `).trim();if(u){const h=t.blockTokens(u);c.push(...h)}let d=o+1;const f=[];for(;d<n.length&&n[d].indent>e;)f.push(n[d]),d+=1;if(f.length>0){const h=Math.min(...f.map(g=>g.indent)),m=dh(f,h,t);c.push({type:"list",ordered:!0,start:f[0].number,items:m,raw:f.map(g=>g.raw).join(`
138
+ `)})}s.push({type:"list_item",raw:i.raw,tokens:c}),o=d}else o+=1}return s}function pS(n,e){return n.map(t=>{if(t.type!=="list_item")return e.parseChildren([t])[0];const r=[];return t.tokens&&t.tokens.length>0&&t.tokens.forEach(s=>{if(s.type==="paragraph"||s.type==="list"||s.type==="blockquote"||s.type==="code")r.push(...e.parseChildren([s]));else if(s.type==="text"&&s.tokens){const o=e.parseChildren([s]);r.push({type:"paragraph",content:o})}else{const o=e.parseChildren([s]);o.length>0&&r.push(...o)}}),{type:"listItem",content:r}})}var mS="listItem",_c="textStyle",$c=/^(\d+)\.\s$/,fh=_e.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:n=>n.hasAttribute("start")?parseInt(n.getAttribute("start")||"",10):1},type:{default:null,parseHTML:n=>n.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:n}){const{start:e,...t}=n;return e===1?["ol",Se(this.options.HTMLAttributes,t),0]:["ol",Se(this.options.HTMLAttributes,n),0]},markdownTokenName:"list",parseMarkdown:(n,e)=>{if(n.type!=="list"||!n.ordered)return[];const t=n.start||1,r=n.items?pS(n.items,e):[];return t!==1?{type:"orderedList",attrs:{start:t},content:r}:{type:"orderedList",content:r}},renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,`
139
+ `):"",markdownTokenizer:{name:"orderedList",level:"block",start:n=>{const e=n.match(/^(\s*)(\d+)\.\s+/),t=e?.index;return t!==void 0?t:-1},tokenize:(n,e,t)=>{var r;const s=n.split(`
140
+ `),[o,i]=hS(s);if(o.length===0)return;const l=dh(o,0,t);return l.length===0?void 0:{type:"list",ordered:!0,start:((r=o[0])==null?void 0:r.number)||1,items:l,raw:s.slice(0,i).join(`
141
+ `)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(mS,this.editor.getAttributes(_c)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let n=Fn({find:$c,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(n=Fn({find:$c,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(_c)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[n]}}),gS=/^\s*(\[([( |x])?\])\s$/,xS=_e.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:n=>{const e=n.getAttribute("data-checked");return e===""||e==="true"},renderHTML:n=>({"data-checked":n.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:n,HTMLAttributes:e}){return["li",Se(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:n.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(n,e)=>{const t=[];if(n.tokens&&n.tokens.length>0?t.push(e.createNode("paragraph",{},e.parseInline(n.tokens))):n.text?t.push(e.createNode("paragraph",{},[e.createNode("text",{text:n.text})])):t.push(e.createNode("paragraph",{},[])),n.nestedTokens&&n.nestedTokens.length>0){const r=e.parseChildren(n.nestedTokens);t.push(...r)}return e.createNode("taskItem",{checked:n.checked||!1},t)},renderMarkdown:(n,e)=>{var t;const s=`- [${(t=n.attrs)!=null&&t.checked?"x":" "}] `;return Nl(n,e,s)},addKeyboardShortcuts(){const n={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...n,Tab:()=>this.editor.commands.sinkListItem(this.name)}:n},addNodeView(){return({node:n,HTMLAttributes:e,getPos:t,editor:r})=>{const s=document.createElement("li"),o=document.createElement("label"),i=document.createElement("span"),l=document.createElement("input"),a=document.createElement("div"),c=d=>{var f,h;l.ariaLabel=((h=(f=this.options.a11y)==null?void 0:f.checkboxLabel)==null?void 0:h.call(f,d,l.checked))||`Task item checkbox for ${d.textContent||"empty task item"}`};c(n),o.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",d=>d.preventDefault()),l.addEventListener("change",d=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}const{checked:f}=d.target;r.isEditable&&typeof t=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:h})=>{const m=t();if(typeof m!="number")return!1;const g=h.doc.nodeAt(m);return h.setNodeMarkup(m,void 0,{...g?.attrs,checked:f}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(n,f)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([d,f])=>{s.setAttribute(d,f)}),s.dataset.checked=n.attrs.checked,l.checked=n.attrs.checked,o.append(l,i),s.append(o,a),Object.entries(e).forEach(([d,f])=>{s.setAttribute(d,f)});let u=new Set(Object.keys(e));return{dom:s,contentDOM:a,update:d=>{if(d.type!==this.type)return!1;s.dataset.checked=d.attrs.checked,l.checked=d.attrs.checked,c(d);const f=r.extensionManager.attributes,h=zn(d,f),m=new Set(Object.keys(h)),g=this.options.HTMLAttributes;return u.forEach(x=>{m.has(x)||(x in g?s.setAttribute(x,g[x]):s.removeAttribute(x))}),Object.entries(h).forEach(([x,y])=>{y==null?x in g?s.setAttribute(x,g[x]):s.removeAttribute(x):s.setAttribute(x,y)}),u=m,!0}}}},addInputRules(){return[Fn({find:gS,type:this.type,getAttributes:n=>({checked:n[n.length-1]==="x"})})]}}),yS=_e.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:n}){return["ul",Se(this.options.HTMLAttributes,n,{"data-type":this.name}),0]},parseMarkdown:(n,e)=>e.createNode("taskList",{},e.parseChildren(n.items||[])),renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,`
142
+ `):"",markdownTokenizer:{name:"taskList",level:"block",start(n){var e;const t=(e=n.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return t!==void 0?t:-1},tokenize(n,e,t){const r=o=>{const i=bi(o,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:l=>({indentLevel:l[1].length,mainContent:l[4],checked:l[3].toLowerCase()==="x"}),createToken:(l,a)=>({type:"taskItem",raw:"",mainContent:l.mainContent,indentLevel:l.indentLevel,checked:l.checked,text:l.mainContent,tokens:t.inlineTokens(l.mainContent),nestedTokens:a}),customNestedParser:r},t);return i?[{type:"taskList",raw:i.raw,items:i.items}]:t.blockTokens(o)},s=bi(n,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:o=>({indentLevel:o[1].length,mainContent:o[4],checked:o[3].toLowerCase()==="x"}),createToken:(o,i)=>({type:"taskItem",raw:"",mainContent:o.mainContent,indentLevel:o.indentLevel,checked:o.checked,text:o.mainContent,tokens:t.inlineTokens(o.mainContent),nestedTokens:i}),customNestedParser:r},t);if(s)return{type:"taskList",raw:s.raw,items:s.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:n})=>n.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});xe.create({name:"listKit",addExtensions(){const n=[];return this.options.bulletList!==!1&&n.push(rh.configure(this.options.bulletList)),this.options.listItem!==!1&&n.push(sh.configure(this.options.listItem)),this.options.listKeymap!==!1&&n.push(uh.configure(this.options.listKeymap)),this.options.orderedList!==!1&&n.push(fh.configure(this.options.orderedList)),this.options.taskItem!==!1&&n.push(xS.configure(this.options.taskItem)),this.options.taskList!==!1&&n.push(yS.configure(this.options.taskList)),n}});var zc="&nbsp;",bS=" ",kS=_e.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",Se(this.options.HTMLAttributes,n),0]},parseMarkdown:(n,e)=>{const t=n.tokens||[];if(t.length===1&&t[0].type==="image")return e.parseChildren([t[0]]);const r=e.parseInline(t);return r.length===1&&r[0].type==="text"&&(r[0].text===zc||r[0].text===bS)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,r)},renderMarkdown:(n,e,t)=>{var r,s;if(!n)return"";const o=Array.isArray(n.content)?n.content:[];if(o.length===0){const i=Array.isArray((r=t?.previousNode)==null?void 0:r.content)?t.previousNode.content:[];return((s=t?.previousNode)==null?void 0:s.type)==="paragraph"&&i.length===0?zc:""}return e.renderChildren(o)},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),SS=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,vS=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,wS=vn.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["s",Se(this.options.HTMLAttributes,n),0]},markdownTokenName:"del",parseMarkdown:(n,e)=>e.applyMark("strike",e.parseInline(n.tokens||[])),renderMarkdown:(n,e)=>`~~${e.renderChildren(n)}~~`,addCommands(){return{setStrike:()=>({commands:n})=>n.setMark(this.name),toggleStrike:()=>({commands:n})=>n.toggleMark(this.name),unsetStrike:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Bn({find:SS,type:this.type})]},addPasteRules(){return[bn({find:vS,type:this.type})]}}),CS=_e.create({name:"text",group:"inline",parseMarkdown:n=>({type:"text",text:n.text||""}),renderMarkdown:n=>n.text||""}),TS=vn.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["u",Se(this.options.HTMLAttributes,n),0]},parseMarkdown(n,e){return e.applyMark(this.name||"underline",e.parseInline(n.tokens||[]))},renderMarkdown(n,e){return`++${e.renderChildren(n)}++`},markdownTokenizer:{name:"underline",level:"inline",start(n){return n.indexOf("++")},tokenize(n,e,t){const s=/^(\+\+)([\s\S]+?)(\+\+)/.exec(n);if(!s)return;const o=s[2].trim();return{type:"underline",raw:s[0],text:o,tokens:t.inlineTokens(o)}}},addCommands(){return{setUnderline:()=>({commands:n})=>n.setMark(this.name),toggleUnderline:()=>({commands:n})=>n.toggleMark(this.name),unsetUnderline:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),NS=xe.create({name:"starterKit",addExtensions(){var n,e,t,r;const s=[];return this.options.bold!==!1&&s.push(kk.configure(this.options.bold)),this.options.blockquote!==!1&&s.push(mk.configure(this.options.blockquote)),this.options.bulletList!==!1&&s.push(rh.configure(this.options.bulletList)),this.options.code!==!1&&s.push(wk.configure(this.options.code)),this.options.codeBlock!==!1&&s.push(Nk.configure(this.options.codeBlock)),this.options.document!==!1&&s.push(Mk.configure(this.options.document)),this.options.dropcursor!==!1&&s.push(ck.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&s.push(uk.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&s.push(Ek.configure(this.options.hardBreak)),this.options.heading!==!1&&s.push(Ak.configure(this.options.heading)),this.options.undoRedo!==!1&&s.push(hk.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&s.push(jk.configure(this.options.horizontalRule)),this.options.italic!==!1&&s.push(Pk.configure(this.options.italic)),this.options.listItem!==!1&&s.push(sh.configure(this.options.listItem)),this.options.listKeymap!==!1&&s.push(uh.configure((n=this.options)==null?void 0:n.listKeymap)),this.options.link!==!1&&s.push(iS.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&s.push(fh.configure(this.options.orderedList)),this.options.paragraph!==!1&&s.push(kS.configure(this.options.paragraph)),this.options.strike!==!1&&s.push(wS.configure(this.options.strike)),this.options.text!==!1&&s.push(CS.configure(this.options.text)),this.options.underline!==!1&&s.push(TS.configure((t=this.options)==null?void 0:t.underline)),this.options.trailingNode!==!1&&s.push(fk.configure((r=this.options)==null?void 0:r.trailingNode)),s}}),MS=NS;const Yt=16,Ii=2.5,Oi=(Yt-Ii)/2,Ko=2*Math.PI*Oi;function hh(n){const e=_.c(31),{usage:t}=n;if(!t)return null;const{totalTokens:r,inputTokens:s,outputTokens:o,cost:i}=t;if(!r&&!s&&!o)return null;let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=p.jsx(yp,{size:12}),e[0]=l):l=e[0];let a;e[1]!==i||e[2]!==r?(a=i>0?`$${i.toFixed(4)}`:r.toLocaleString(),e[1]=i,e[2]=r,e[3]=a):a=e[3];let c;e[4]!==a?(c=p.jsx(fn,{asChild:!0,children:p.jsxs("span",{className:"inline-flex items-center text-muted-foreground [@media(hover:hover)]:hover:text-foreground pl-1 h-6 gap-1 whitespace-nowrap shrink-0 cursor-default",children:[l,p.jsx("span",{className:"text-sm font-mono tabular-nums",children:a})]})}),e[4]=a,e[5]=c):c=e[5];let u;e[6]===Symbol.for("react.memo_cache_sentinel")?(u=p.jsx("p",{className:"text-muted text-[10px] mb-1",children:"tokens"}),e[6]=u):u=e[6];let d;e[7]===Symbol.for("react.memo_cache_sentinel")?(d=p.jsx("span",{className:"text-muted",children:"in"}),e[7]=d):d=e[7];let f;e[8]!==s?(f=s.toLocaleString(),e[8]=s,e[9]=f):f=e[9];let h;e[10]!==f?(h=p.jsx("span",{className:"text-right tabular-nums",children:f}),e[10]=f,e[11]=h):h=e[11];let m;e[12]===Symbol.for("react.memo_cache_sentinel")?(m=p.jsx("span",{className:"text-muted",children:"out"}),e[12]=m):m=e[12];const g=o-(t.reasoningTokens??0);let x;e[13]!==g?(x=g.toLocaleString(),e[13]=g,e[14]=x):x=e[14];let y;e[15]!==x?(y=p.jsx("span",{className:"text-right tabular-nums",children:x}),e[15]=x,e[16]=y):y=e[16];let b;e[17]!==s||e[18]!==t.cacheReadTokens||e[19]!==t.cacheWriteTokens?(b=(t.cacheReadTokens>0||t.cacheWriteTokens>0)&&p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"text-muted",children:"cache hit"}),p.jsx("span",{className:"text-right tabular-nums",children:s>0?`${(t.cacheReadTokens/s*100).toFixed(0)}%`:"0%"})]}),e[17]=s,e[18]=t.cacheReadTokens,e[19]=t.cacheWriteTokens,e[20]=b):b=e[20];let k;e[21]!==i?(k=i>0&&p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"text-muted",children:"cost"}),p.jsxs("span",{className:"text-right tabular-nums",children:["$",i.toFixed(4)]})]}),e[21]=i,e[22]=k):k=e[22];let S;e[23]!==y||e[24]!==b||e[25]!==k||e[26]!==h?(S=p.jsxs(hn,{side:"top",className:"font-mono text-[11px]",children:[u,p.jsxs("div",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5",children:[d,h,m,y,b,k]})]}),e[23]=y,e[24]=b,e[25]=k,e[26]=h,e[27]=S):S=e[27];let v;return e[28]!==S||e[29]!==c?(v=p.jsxs(pn,{children:[c,S]}),e[28]=S,e[29]=c,e[30]=v):v=e[30],v}function ES(n){const e=_.c(19),{usage:t,duration:r}=n,s=r!=null&&r>0,o=t!=null&&(t.cost??0)>0,i=t!=null&&(t.totalTokens??0)>0;if(!s&&!o&&!i)return null;let l;e[0]!==r||e[1]!==s?(l=s?Ht(r/1e3):null,e[0]=r,e[1]=s,e[2]=l):l=e[2];const a=l;let c;e[3]!==r||e[4]!==a||e[5]!==t?(c=a&&p.jsxs(pn,{children:[p.jsx(fn,{asChild:!0,children:p.jsx("span",{className:"tabular-nums text-sm font-mono text-muted-foreground cursor-default [@media(hover:hover)]:hover:text-foreground transition-colors select-none",children:a})}),p.jsxs(hn,{side:"top",className:"font-mono text-[11px]",children:[p.jsx("p",{className:"opacity-60 text-[10px] mb-1",children:"thinking"}),p.jsx("span",{className:"tabular-nums",children:Ht(r/1e3)}),(t?.reasoningTokens??0)>0&&p.jsxs("span",{className:"ml-2 opacity-50",children:[t.reasoningTokens.toLocaleString()," tok"]})]})]}),e[3]=r,e[4]=a,e[5]=t,e[6]=c):c=e[6];let u;e[7]!==o||e[8]!==s||e[9]!==i?(u=s&&(o||i)&&p.jsx("span",{className:"text-muted-foreground/40 select-none",children:"·"}),e[7]=o,e[8]=s,e[9]=i,e[10]=u):u=e[10];let d;e[11]!==o||e[12]!==i||e[13]!==t?(d=(o||i)&&p.jsxs(pn,{children:[p.jsx(fn,{asChild:!0,children:p.jsx("span",{className:"tabular-nums text-sm font-mono text-muted-foreground cursor-default [@media(hover:hover)]:hover:text-foreground transition-colors select-none",children:o?`$${t.cost.toFixed(4)}`:`${t.totalTokens.toLocaleString()} tok`})}),p.jsxs(hn,{side:"top",className:"font-mono text-[11px]",children:[p.jsx("p",{className:"opacity-60 text-[10px] mb-1",children:"tokens"}),p.jsxs("div",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5",children:[p.jsx("span",{className:"opacity-60",children:"in"}),p.jsx("span",{className:"text-right tabular-nums",children:(t.inputTokens??0).toLocaleString()}),p.jsx("span",{className:"opacity-60",children:"out"}),p.jsx("span",{className:"text-right tabular-nums",children:((t.outputTokens??0)-(t?.reasoningTokens??0)).toLocaleString()}),(t?.reasoningTokens??0)>0&&p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"opacity-60",children:"think"}),p.jsx("span",{className:"text-right tabular-nums",children:t.reasoningTokens.toLocaleString()})]}),((t?.cacheReadTokens??0)>0||(t?.cacheWriteTokens??0)>0)&&p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"opacity-60",children:"cache hit"}),p.jsx("span",{className:"text-right tabular-nums",children:(t?.inputTokens??0)>0?`${((t?.cacheReadTokens??0)/t.inputTokens*100).toFixed(0)}%`:"0%"})]})]})]})]}),e[11]=o,e[12]=i,e[13]=t,e[14]=d):d=e[14];let f;return e[15]!==c||e[16]!==u||e[17]!==d?(f=p.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[c,u,d]}),e[15]=c,e[16]=u,e[17]=d,e[18]=f):f=e[18],f}function QC(n){const e=_.c(51),{usage:t,totalTokens:r,contextWindow:s,onOpenContextPanel:o}=n,i=Math.min(r/s*100,100),l=Ko-i/100*Ko,a=t?.cost??0,c=t?.inputTokens??0,u=t?.outputTokens??0;let d;e[0]!==i?(d=i.toFixed(0),e[0]=i,e[1]=d):d=e[1];let f;e[2]!==a?(f=a>0?`, $${a.toFixed(2)}`:"",e[2]=a,e[3]=f):f=e[3];const h=`Context usage: ${d}%${f}`,m=o?"cursor-pointer":"cursor-default";let g;e[4]!==m?(g=ee("flex items-center gap-1.5 text-muted-foreground hover:text-foreground h-6 px-1 shrink-0",m),e[4]=m,e[5]=g):g=e[5];let x;e[6]===Symbol.for("react.memo_cache_sentinel")?(x=p.jsx("circle",{cx:Yt/2,cy:Yt/2,r:Oi,fill:"none",stroke:"currentColor",strokeWidth:Ii,className:"opacity-15"}),e[6]=x):x=e[6];const y=i>90?"text-destructive":i>70?"text-warning":"text-muted-foreground";let b;e[7]!==y?(b=ee(y),e[7]=y,e[8]=b):b=e[8];let k;e[9]!==l||e[10]!==b?(k=p.jsxs("svg",{width:Yt,height:Yt,className:"-rotate-90",children:[x,p.jsx("circle",{cx:Yt/2,cy:Yt/2,r:Oi,fill:"none",stroke:"currentColor",strokeWidth:Ii,strokeDasharray:Ko,strokeDashoffset:l,strokeLinecap:"round",className:b})]}),e[9]=l,e[10]=b,e[11]=k):k=e[11];let S;e[12]!==i?(S=i.toFixed(0),e[12]=i,e[13]=S):S=e[13];let v;e[14]!==a?(v=a>0?` · $${a.toFixed(2)}`:"",e[14]=a,e[15]=v):v=e[15];let w;e[16]!==S||e[17]!==v?(w=p.jsxs("span",{className:"inline-block overflow-hidden whitespace-nowrap max-w-0 opacity-0 transition-[max-width,opacity] duration-200 ease-out @[320px]/chat-bottom:max-w-32 @[320px]/chat-bottom:opacity-100 text-[11px] font-mono tabular-nums",children:[S,"%",v]}),e[16]=S,e[17]=v,e[18]=w):w=e[18];let C;e[19]!==o||e[20]!==w||e[21]!==h||e[22]!==g||e[23]!==k?(C=p.jsx(fn,{asChild:!0,children:p.jsxs("button",{type:"button",onClick:o,"aria-label":h,className:g,children:[k,w]})}),e[19]=o,e[20]=w,e[21]=h,e[22]=g,e[23]=k,e[24]=C):C=e[24];let T;e[25]===Symbol.for("react.memo_cache_sentinel")?(T=p.jsx("span",{className:"text-muted",children:"context"}),e[25]=T):T=e[25];let N;e[26]!==r?(N=r.toLocaleString(),e[26]=r,e[27]=N):N=e[27];let M;e[28]!==s?(M=s.toLocaleString(),e[28]=s,e[29]=M):M=e[29];let j;e[30]!==i?(j=i.toFixed(1),e[30]=i,e[31]=j):j=e[31];let R;e[32]!==N||e[33]!==M||e[34]!==j?(R=p.jsxs("span",{className:"text-right tabular-nums",children:[N," / ",M," (",j,"%)"]}),e[32]=N,e[33]=M,e[34]=j,e[35]=R):R=e[35];let A;e[36]!==a||e[37]!==c||e[38]!==u?(A=a>0&&p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"text-muted",children:"cost"}),p.jsxs("span",{className:"text-right tabular-nums",children:["$",a.toFixed(4)]}),p.jsx("span",{className:"text-muted",children:"in"}),p.jsx("span",{className:"text-right tabular-nums",children:c.toLocaleString()}),p.jsx("span",{className:"text-muted",children:"out"}),p.jsx("span",{className:"text-right tabular-nums",children:u.toLocaleString()})]}),e[36]=a,e[37]=c,e[38]=u,e[39]=A):A=e[39];let D;e[40]!==c||e[41]!==t?.cacheReadTokens||e[42]!==t?.cacheWriteTokens?(D=((t?.cacheReadTokens??0)>0||(t?.cacheWriteTokens??0)>0)&&p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"text-muted",children:"cache hit"}),p.jsx("span",{className:"text-right tabular-nums",children:c>0?`${((t?.cacheReadTokens??0)/c*100).toFixed(0)}%`:"0%"})]}),e[40]=c,e[41]=t?.cacheReadTokens,e[42]=t?.cacheWriteTokens,e[43]=D):D=e[43];let I;e[44]!==R||e[45]!==A||e[46]!==D?(I=p.jsx(hn,{side:"top",className:"font-mono text-[11px]",children:p.jsxs("div",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5",children:[T,R,A,D]})}),e[44]=R,e[45]=A,e[46]=D,e[47]=I):I=e[47];let $;return e[48]!==C||e[49]!==I?($=p.jsxs(pn,{children:[C,I]}),e[48]=C,e[49]=I,e[50]=$):$=e[50],$}var ho="Collapsible",[AS,ZC]=Gc(ho),[jS,Bl]=AS(ho),ph=E.forwardRef((n,e)=>{const{__scopeCollapsible:t,open:r,defaultOpen:s,disabled:o,onOpenChange:i,...l}=n,[a,c]=ep({prop:r,defaultProp:s??!1,onChange:i,caller:ho});return p.jsx(jS,{scope:t,disabled:o,contentId:tp(),open:a,onOpenToggle:E.useCallback(()=>c(u=>!u),[c]),children:p.jsx(Ut.div,{"data-state":Wl(a),"data-disabled":o?"":void 0,...l,ref:e})})});ph.displayName=ho;var mh="CollapsibleTrigger",Fl=E.forwardRef((n,e)=>{const{__scopeCollapsible:t,...r}=n,s=Bl(mh,t);return p.jsx(Ut.button,{type:"button","aria-controls":s.contentId,"aria-expanded":s.open||!1,"data-state":Wl(s.open),"data-disabled":s.disabled?"":void 0,disabled:s.disabled,...r,ref:e,onClick:_t(n.onClick,s.onOpenToggle)})});Fl.displayName=mh;var Hl="CollapsibleContent",Vl=E.forwardRef((n,e)=>{const{forceMount:t,...r}=n,s=Bl(Hl,n.__scopeCollapsible);return p.jsx(Nr,{present:t||s.open,children:({present:o})=>p.jsx(IS,{...r,ref:e,present:o})})});Vl.displayName=Hl;var IS=E.forwardRef((n,e)=>{const{__scopeCollapsible:t,present:r,children:s,...o}=n,i=Bl(Hl,t),[l,a]=E.useState(r),c=E.useRef(null),u=kn(e,c),d=E.useRef(0),f=d.current,h=E.useRef(0),m=h.current,g=i.open||l,x=E.useRef(g),y=E.useRef(void 0);return E.useEffect(()=>{const b=requestAnimationFrame(()=>x.current=!1);return()=>cancelAnimationFrame(b)},[]),Jc(()=>{const b=c.current;if(b){y.current=y.current||{transitionDuration:b.style.transitionDuration,animationName:b.style.animationName},b.style.transitionDuration="0s",b.style.animationName="none";const k=b.getBoundingClientRect();d.current=k.height,h.current=k.width,x.current||(b.style.transitionDuration=y.current.transitionDuration,b.style.animationName=y.current.animationName),a(r)}},[i.open,r]),p.jsx(Ut.div,{"data-state":Wl(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!g,...o,ref:u,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":m?`${m}px`:void 0,...n.style},children:g&&s})});function Wl(n){return n?"open":"closed"}var OS=ph,eT=Fl,tT=Vl;function RS(n){const e=_.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let r;return e[2]!==t?(r=p.jsx(OS,{"data-slot":"collapsible",...t}),e[2]=t,e[3]=r):r=e[3],r}function DS(n){const e=_.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let r;return e[2]!==t?(r=p.jsx(Fl,{"data-slot":"collapsible-trigger",...t}),e[2]=t,e[3]=r):r=e[3],r}function PS(n){const e=_.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let r;return e[2]!==t?(r=p.jsx(Vl,{"data-slot":"collapsible-content",...t}),e[2]=t,e[3]=r):r=e[3],r}function Z({icon:n,title:e,usage:t,latency:r,summary:s,state:o,detail:i,detailVariant:l="code",forceOpen:a,variant:c="default",trailing:u,iconDestructive:d,alwaysChevron:f,defaultOpen:h,children:m}){const[g,x]=E.useState(h??!1),{handleCopy:y,copied:b}=hu(),k=o==="loading",S=o==="error",w=!!(i&&i.trim())||!!m,C=c==="subtask",T=(a??!1)||g,N=Sm({initial:k?"instant":!1}),M=p.jsxs(RS,{open:T,onOpenChange:a?void 0:x,className:"min-w-0",children:[p.jsxs(DS,{disabled:!w,className:ee("group/tool flex items-center gap-2 w-full py-2.5 text-left transition-colors",w&&"[@media(hover:hover)]:hover:bg-accent/30",!w&&"cursor-default",k&&"shimmer"),"aria-disabled":!w,children:[p.jsx("div",{className:"relative shrink-0 size-4 flex items-center justify-center",children:f?p.jsx(sa,{className:ee("size-4 text-foreground/60 transition-transform duration-200 ease-in-out",T&&"rotate-90")}):p.jsxs(p.Fragment,{children:[p.jsx("div",{className:ee("absolute inset-0 flex items-center justify-center [&>svg]:size-4 transition-opacity duration-150",d?"[&>svg]:text-destructive/70":S?"[&>svg]:text-warning/70":"[&>svg]:text-muted-foreground/75",w&&(T?"opacity-0":"[@media(hover:hover)]:group-hover/tool:opacity-0")),children:n}),w&&p.jsx("div",{className:ee("absolute inset-0 flex items-center justify-center transition-opacity duration-150",T?"opacity-100":"opacity-0 [@media(hover:hover)]:group-hover/tool:opacity-100"),children:p.jsx(sa,{className:ee("size-4 text-foreground/60 transition-transform duration-200 ease-in-out",T&&"rotate-90")})})]})}),p.jsx("span",{className:ee("shrink-0 text-[14px] font-normal",S?"text-warning/80":"text-foreground"),children:e}),s?p.jsx("span",{className:"min-w-0 flex-1 truncate",children:p.jsx("span",{className:"text-[12px] text-muted-foreground/60 bg-muted/50 rounded-[3px] px-1 py-px leading-none",children:s})}):p.jsx("div",{className:"flex-1"}),u&&p.jsx("div",{className:"shrink-0 flex items-center gap-1 [&_svg]:size-3.5 [&_svg]:text-muted-foreground/50",children:u}),p.jsx(hh,{usage:t})]}),w&&p.jsx(PS,{className:"data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden",children:m||(l==="prose"?p.jsx("div",{className:"mt-1 mb-1",children:p.jsx("div",{ref:N.scrollRef,className:"max-h-[150px] overflow-y-auto rounded-md bg-muted/30 px-3 py-2",children:p.jsx("p",{ref:N.contentRef,className:"text-xs text-muted-foreground/70 whitespace-pre-wrap leading-relaxed wrap-break-word",children:i})})}):p.jsx("div",{className:"ml-[20px] pl-3 border-l border-border/30 mt-0.5 pb-1",children:p.jsx("div",{ref:N.scrollRef,className:"flex flex-col max-h-48 overflow-y-auto",children:p.jsxs("div",{ref:N.contentRef,className:"flex items-start justify-between gap-2",children:[p.jsx("div",{className:"flex-1 min-w-0 overflow-hidden",children:p.jsx("pre",{className:"text-xs font-mono text-muted-foreground/70 whitespace-pre-wrap wrap-break-word",children:i})}),p.jsx("button",{type:"button",onClick:()=>y(i),className:"shrink-0 p-1.5 rounded-md text-muted-foreground/50 [@media(hover:hover)]:hover:text-foreground [@media(hover:hover)]:hover:bg-accent/50 transition-colors active:scale-[0.97]","aria-label":"Copy",children:b?p.jsx(qi,{className:"size-3.5"}):p.jsx(fu,{className:"size-3.5"})})]})})}))})]});return C?p.jsx("div",{className:"pl-4 border-l border-border/40 ml-1.5",children:M}):M}function Ie(n){const e=_.c(4),{latency:t}=n;if(t==null||t<=0)return null;let r;e[0]!==t?(r=Ht(t),e[0]=t,e[1]=r):r=e[1];let s;return e[2]!==r?(s=p.jsx("span",{className:"text-[11px] font-mono tabular-nums text-muted-foreground",children:r}),e[2]=r,e[3]=s):s=e[3],s}const gh=4;function xh(n){const e=_.c(5),{count:t,noun:r,onClick:s}=n;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=p.jsx(du,{className:"size-4 transition-transform group-hover:translate-x-0.5","aria-hidden":"true"}),e[0]=o):o=e[0];let i;return e[1]!==t||e[2]!==r||e[3]!==s?(i=p.jsxs("button",{type:"button",onClick:s,className:"group flex w-full items-center justify-center gap-1.5 rounded-lg border border-border bg-card px-3 py-2.5 text-sm text-muted-foreground transition-colors hover:bg-muted hover:text-foreground cursor-pointer",children:["See all ",t," ",r,o]}),e[1]=t,e[2]=r,e[3]=s,e[4]=i):i=e[4],i}function yh(n){const e=_.c(12),{message:t,className:r}=n,s=t.created_at??t.metadata?.created_at??null;let o,i,l,a;if(e[0]!==r||e[1]!==s){a=Symbol.for("react.early_return_sentinel");e:{const u=Ki(s);if(u===null){a=null;break e}const d=new Date(u);o=d.toLocaleString(),e[6]!==r?(i=ee("text-[11px] text-muted-foreground/60 select-none",r),e[6]=r,e[7]=i):i=e[7],l=d.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"})}e[0]=r,e[1]=s,e[2]=o,e[3]=i,e[4]=l,e[5]=a}else o=e[2],i=e[3],l=e[4],a=e[5];if(a!==Symbol.for("react.early_return_sentinel"))return a;let c;return e[8]!==o||e[9]!==i||e[10]!==l?(c=p.jsx("span",{title:o,className:i,children:l}),e[8]=o,e[9]=i,e[10]=l,e[11]=c):c=e[11],c}function LS(n){const e=_.c(24),{org:t}=Ct(),r=np(),s=_p(),o=iu();let i;e[0]!==o||e[1]!==n?(i=async g=>{if(!n)throw new Error("useTaskExpandedTools: no task in context");const y=(await o.call("COLLECTION_THREADS_GET",{id:n})).item?.metadata??{},k=(y.expanded_tools??[]).filter(v=>v.toolName!==g.toolName);k.push({...g,expandedAt:new Date().toISOString()});const S={...y,expanded_tools:k};return await o.call("COLLECTION_THREADS_UPDATE",{id:n,data:{metadata:S}}),k},e[0]=o,e[1]=n,e[2]=i):i=e[2];let l,a,c;e[3]!==t||e[4]!==r||e[5]!==n?(l=async g=>{const x=Qe.ensureTask(t.id,n??"");await r.cancelQueries({queryKey:x});const y=r.getQueryData(x),k=(y?.metadata?.expanded_tools??[]).filter(S=>S.toolName!==g.toolName);return k.push({...g,expandedAt:new Date().toISOString()}),r.setQueryData(x,S=>S&&{...S,metadata:{...S.metadata??{},expanded_tools:k}}),{previous:y}},a=()=>{r.invalidateQueries({queryKey:Qe.ensureTask(t.id,n??"")})},c=(g,x,y)=>{const b=Qe.ensureTask(t.id,n??"");y?.previous===void 0?r.removeQueries({queryKey:b,exact:!0}):r.setQueryData(b,y.previous),Xo.error(g instanceof Error?g.message:"Failed to expand tool")},e[3]=t,e[4]=r,e[5]=n,e[6]=l,e[7]=a,e[8]=c):(l=e[6],a=e[7],c=e[8]);let u;e[9]!==i||e[10]!==l||e[11]!==a||e[12]!==c?(u={mutationFn:i,onMutate:l,onSuccess:a,onError:c},e[9]=i,e[10]=l,e[11]=a,e[12]=c,e[13]=u):u=e[13];const d=rp(u);let f;e[14]!==s||e[15]!==d||e[16]!==t||e[17]!==r||e[18]!==n?(f=g=>{if(!n||!s)return;const x=Qe.ensureTask(t.id,n),y=r.getQueryData(x),k=(y?.metadata?.expanded_tools??[]).filter(v=>v.toolName!==g.toolName);k.push({...g,expandedAt:new Date().toISOString()});const S={...y?.metadata??{},expanded_tools:k};r.setQueryData(x,v=>v&&{...v,metadata:S}),s.patchThread({id:n,metadata:S}),d.mutate(g)},e[14]=s,e[15]=d,e[16]=t,e[17]=r,e[18]=n,e[19]=f):f=e[19];const h=f;let m;return e[20]!==h||e[21]!==d.isPending||e[22]!==d.mutate?(m={addOrReplace:d.mutate,addOrReplaceEager:h,isPending:d.isPending},e[20]=h,e[21]=d.isPending,e[22]=d.mutate,e[23]=m):m=e[23],m}function _S(n){if(n<1024)return`${n} B`;if(n<1024*1024){const t=n/1024;return t<10?`${t.toFixed(1)} KB`:`${Math.round(t)} KB`}const e=n/(1024*1024);return e<10?`${e.toFixed(1)} MB`:`${Math.round(e)} MB`}function $S(n,e,t,r){const{data:s,isLoading:o}=Mr({queryKey:Qe.toolDefinitionLookup(e,t,n),queryFn:async()=>{if(!n||!e)return null;const i=await lp({connectionId:e,orgId:t,orgSlug:r});try{const{tools:l}=await i.listTools(),a=Hf(n);return l.find(c=>c.name===a)??null}finally{await i.close().catch(()=>{})}},enabled:!!n&&!!e,staleTime:6e4,gcTime:3e5,retry:!1});return{toolDef:s??void 0,isLoading:o}}const zS={read:{icon:ia,label:"Read File"},write:{icon:Jp,label:"Write File"},edit:{icon:Cp,label:"Edit File"},grep:{icon:Xp,label:"Search Content"},glob:{icon:Gp,label:"Find Files"},bash:{icon:wp,label:"Run Command"},read_tool_output:{icon:ia,label:"Read Tool Output"},read_resource:{icon:vp,label:"Read Resource"},read_prompt:{icon:Zo,label:"Read Prompt"},skill:{icon:Zo,label:"Load Skill"},enable_tool:{icon:Kp,label:"Enable Tool"},open_in_agent:{icon:Sp,label:"Open in Agent"},sandbox:{icon:kp,label:"Run Code"},copy_to_sandbox:{icon:yu,label:"Load File"},share_with_user:{icon:Yp,label:"Share with User"},take_screenshot:{icon:nr,label:"Take Screenshot"},scrape_url:{icon:es,label:"Scrape URL"},inspect_page:{icon:bp,label:"Inspect Page"}},BS="bash-sleep-start:";function FS(n){const e=BS+n;try{const t=sessionStorage.getItem(e);if(t!==null){const s=Number.parseInt(t,10);if(Number.isFinite(s))return s}const r=Date.now();return sessionStorage.setItem(e,String(r)),r}catch{return Date.now()}}function HS(n,e){const t=_.c(2);let r;t[0]!==n?(r=()=>FS(n),t[0]=n,t[1]=r):r=t[1];const s=E.useState(r)[0];return e??s}function VS(n){const e=Math.ceil(n/1e3);if(e<60)return`${e}s`;const t=Math.floor(e/60),r=e%60;return r?`${t}m ${r}s`:`${t}m`}function WS(n){const e=_.c(4),{toolCallId:t,durationMs:r,anchorMs:s}=n;ou(1e3);const i=HS(t,s)+r-Date.now();let l;e[0]!==i?(l=i>0?`Waiting ${VS(i)}`:"Wrapping up…",e[0]=i,e[1]=l):l=e[1];let a;return e[2]!==l?(a=p.jsx("span",{className:"tabular-nums",children:l}),e[2]=l,e[3]=a):a=e[3],a}const US={s:1e3,m:6e4,h:36e5,d:864e5};function qS(n){const e=/(?:^|[\s;&|(])sleep((?:\s+[\d.]+[smhd]?)+)/g;let t=0,r=!1;for(const s of n.matchAll(e))for(const o of s[1].trim().split(/\s+/)){const i=/^([\d.]+)([smhd]?)$/.exec(o);if(!i)continue;const l=Number.parseFloat(i[1]);Number.isFinite(l)&&(t+=l*(US[i[2]||"s"]??1e3),r=!0)}return r?t:null}function po(n,e="An unknown error occurred"){return"errorText"in n&&typeof n.errorText=="string"?n.errorText:e}function An(n){if(n==null)return"";try{return JSON.stringify(n)}catch{return"[Non-serializable value]"}}function Ws(n){const e=An(n);if(e===""||e==="[Non-serializable value]")return e;try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}const KS=n=>n.type==="dynamic-tool"||n.type.startsWith("tool-");function JS(n){if(!n||typeof n!="object")return null;const e=n;if(!Array.isArray(e.parts))return null;const t=[];for(const r of e.parts)if(r.type==="text"&&typeof r.text=="string")t.push(r.text);else if(r.type==="reasoning")t.push(`## Reasoning
143
+ ${r.text}`);else if(r.type==="source-url")t.push(`## Source URL
144
+ ${r.url}`);else if(r.type==="source-document")t.push(`## Source Document
145
+ ${r.title}`);else if(r.type==="file")t.push(`## File
146
+ ${r.filename??r.url}`);else if(r.type!=="step-start"){if(KS(r)){const s=r.type.startsWith("tool-")?r.type.slice(5):r.toolName;if(r.state==="input-streaming")t.push(`## ${s}
147
+ Input streaming...`);else if(r.state==="input-available"){const o=An(r.input).slice(0,20);t.push(`## ${s}
148
+ ### Input
149
+ ${o||"[No input]"}...`)}else if(r.state==="approval-requested")t.push(`## ${s}
150
+ Approval requested...`);else if(r.state==="approval-responded")t.push(`## ${s}
151
+ Approval responded...`);else if(r.state==="output-available"){const o=An(r.input).slice(0,40),i=An(r.output).slice(0,40);t.push(r.output!=null?`## ${s}
152
+ Input: ${o||"[No input]"}...
153
+ Output: ${i||"[No output]"}...`:`## ${s}
154
+ Input: ${o||"[No input]"}...
155
+ Output: Tool responded with no output`)}else if(r.state==="output-error"){const o=An(r.input).slice(0,40);t.push(r.errorText?`## ${s}
156
+ Input: ${o||"[No input]"}...
157
+ Error: ${r.errorText}`:`## ${s}
158
+ Input: ${o||"[No input]"}...
159
+ Error: Tool responded with an error`)}else if(r.state==="output-denied"){const o=An(r.input).slice(0,40);t.push(`## ${s}
160
+ Input: ${o||"[No input]"}...
161
+ Output: Tool execution was denied`)}}}return t.length>0?t.join(`
162
+
163
+ `):null}function GS(n){const e=n&&typeof n=="object"&&"created_at"in n?n.created_at:void 0;return typeof e=="string"||e instanceof Date?Ki(e):null}function XS(n){const e=n&&typeof n=="object"&&"timeout"in n?n.timeout:void 0;return Math.min(typeof e=="number"?e:3e4,12e4)}function qr(n){const e=_.c(7),{icon:t,label:r}=n;let s;e[0]!==t?(s=p.jsx(fn,{asChild:!0,children:p.jsx("span",{className:"flex items-center",children:t})}),e[0]=t,e[1]=s):s=e[1];let o;e[2]!==r?(o=p.jsx(hn,{side:"top",children:r}),e[2]=r,e[3]=o):o=e[3];let i;return e[4]!==s||e[5]!==o?(i=p.jsxs(pn,{children:[s,o]}),e[4]=s,e[5]=o,e[6]=i):i=e[6],i}function YS(n){const e=_.c(15),{annotations:t,toolMeta:r}=n;let s;e[0]!==r?(s=mu(r),e[0]=r,e[1]=s):s=e[1];const o=!!s;if(!t&&!o)return null;let i;e[2]!==o?(i=o&&p.jsx(qr,{icon:p.jsx(cu,{}),label:"Interactive"}),e[2]=o,e[3]=i):i=e[3];let l;e[4]!==t?.readOnlyHint?(l=t?.readOnlyHint&&p.jsx(qr,{icon:p.jsx(Wp,{}),label:"Read-only — no side effects"}),e[4]=t?.readOnlyHint,e[5]=l):l=e[5];let a;e[6]!==t?.destructiveHint?(a=t?.destructiveHint&&p.jsx(qr,{icon:p.jsx(gu,{}),label:"May modify or delete data"}),e[6]=t?.destructiveHint,e[7]=a):a=e[7];let c;e[8]!==t?.openWorldHint?(c=t?.openWorldHint&&p.jsx(qr,{icon:p.jsx(es,{}),label:"Reaches outside this system"}),e[8]=t?.openWorldHint,e[9]=c):c=e[9];let u;return e[10]!==i||e[11]!==l||e[12]!==a||e[13]!==c?(u=p.jsxs(p.Fragment,{children:[i,l,a,c]}),e[10]=i,e[11]=l,e[12]=a,e[13]=c,e[14]=u):u=e[14],u}function QS(n){return n<1?`${Math.round(n*1e3)}ms`:n<10?`${n.toFixed(1)}s`:`${Math.round(n)}s`}function ZS(n){const e=_.c(13),{latency:t,outputBytes:r}=n,s=typeof t=="number"&&t>0,o=typeof r=="number"&&r>=0;if(!s&&!o)return null;let i;e[0]!==s||e[1]!==t?(i=s&&p.jsx("span",{children:QS(t)}),e[0]=s,e[1]=t,e[2]=i):i=e[2];let l;e[3]!==o||e[4]!==s?(l=s&&o&&p.jsx("span",{className:"text-muted-foreground/30",children:"·"}),e[3]=o,e[4]=s,e[5]=l):l=e[5];let a;e[6]!==o||e[7]!==r?(a=o&&p.jsx("span",{children:_S(r)}),e[6]=o,e[7]=r,e[8]=a):a=e[8];let c;return e[9]!==i||e[10]!==l||e[11]!==a?(c=p.jsxs("span",{className:"inline-flex items-center gap-1.5 text-[11px] font-mono tabular-nums text-muted-foreground/60 px-1 leading-none",children:[i,l,a]}),e[9]=i,e[10]=l,e[11]=a,e[12]=c):c=e[12],c}function e2(n,e,t){switch(n){case"input-streaming":case"input-available":return"Preparing...";case"approval-requested":return"Waiting for your approval";case"output-denied":return"Cancelled";case"output-error":return t??"Failed";case"output-available":{if(e==null)return"Done";if(typeof e=="string"){const r=e.trim();return r.length>100?r.slice(0,100)+"…":r}if(typeof e=="object"){for(const r of Object.keys(e)){const s=e[r];if(typeof s=="string"&&s.trim()){const o=s.trim();return o.length>100?o.slice(0,100)+"…":o}}return""}return String(e).slice(0,100)}default:return""}}function Bc(n){const e=_.c(74),{part:t,annotations:r,latency:s,outputBytes:o,isLastMessage:i,toolMeta:l}=n,a="toolName"in t&&typeof t.toolName=="string"?t.toolName:t.type==="dynamic-tool"?"Dynamic Tool":t.type.replace("tool-","")||"Tool",c=Hf(a),u=Wn(),d=Dp(),{org:f}=Ct(),{openSidePanel:h}=Qp(),m=Gi()?.taskId??null,{addOrReplaceEager:g}=LS(m),x=Vn(),y=l&&typeof l=="object"&&l!==null&&"connectionId"in l&&l.connectionId!=null&&l.connectionId!==""?String(l.connectionId):d?.selectedVirtualMcp?.id??null,{toolDef:b}=$S(y?a:null,y,f.id,f.slug),k=b?._meta??l,S=Yi(k),v=Qi(c,S),w=zS[v],C=b?.title??w?.label??Cu(v);let T;e[0]!==k?(T=mu(k),e[0]=k,e[1]=T):T=e[1];const N=T,M=!!N&&t.state==="output-available",j=y?`${y}:${a}`:null,R=!!r?.destructiveHint,A=M&&!!y&&!R&&!!m;let D;e[2]!==g||e[3]!==y||e[4]!==x||e[5]!==t||e[6]!==a?(D=()=>{if(!y)return;const J="input"in t&&t.input&&typeof t.input=="object"?t.input:{};g({toolName:a,appId:y,args:J}),x({to:".",search:ie=>({...ie,main:Fp(y,a)}),replace:!0})},e[2]=g,e[3]=y,e[4]=x,e[5]=t,e[6]=a,e[7]=D):D=e[7];const I=D;let $;e[8]!==A||e[9]!==I?($=J=>J==="fullscreen"&&A?(I(),"fullscreen"):"inline",e[8]=A,e[9]=I,e[10]=$):$=e[10];const L=$;let z;e[11]!==u||e[12]!==h?(z=J=>{const ie=Ip(J.content);ie.content.length>0&&(h("chat"),u?.sendMessage(ie))},e[11]=u,e[12]=h,e[13]=z):z=e[13];const F=z,U=t.state==="approval-requested"&&i===!1,Y=t.state==="output-denied"||U,K=t.state==="output-available"&&typeof t.output=="object"&&t.output!=null&&"isError"in t.output&&t.output.isError===!0;let Q;e[14]!==t.state?(Q=ot(t.state),e[14]=t.state,e[15]=Q):Q=e[15];const ne=Q,re=U||ne==="approval"?"idle":K?"error":ne;let se,ae;if(e[16]!==re||e[17]!==K||e[18]!==U||e[19]!==t||e[20]!==v){se=t.state==="output-error"?po(t):void 0;const J=v==="bash"&&re==="loading"&&t.input&&typeof t.input=="object"&&typeof t.input.command=="string"?t.input.command:null;let ie;e[23]!==J?(ie=J!==null?qS(J):null,e[23]=J,e[24]=ie):ie=e[24];const ue=ie;let it;e[25]!==t.input||e[26]!==ue?(it=ue!==null?Math.min(ue,XS(t.input)):null,e[25]=t.input,e[26]=ue,e[27]=it):it=e[27];const na=it,qh="toolCallId"in t?t.toolCallId:"";ae=na!==null?p.jsx(WS,{toolCallId:qh,durationMs:na,anchorMs:GS(t)}):U?"Cancelled":K?"Failed":e2(t.state,t.output,se),e[16]=re,e[17]=K,e[18]=U,e[19]=t,e[20]=v,e[21]=se,e[22]=ae}else se=e[21],ae=e[22];const Te=ae;let W="";t.input!==void 0&&(W=`# Input
164
+ `+Ws(t.input)),t.state==="output-error"?(W&&(W=W+`
165
+
166
+ `),W=W+(`# Error
167
+ `+(se??""))):t.output!==void 0&&!M&&(W&&(W=W+`
168
+
169
+ `),W=W+(`# Output
170
+ `+Ws(t.output)));let te;e:{if(Y){let ue;e[28]===Symbol.for("react.memo_cache_sentinel")?(ue=p.jsx(Up,{}),e[28]=ue):ue=e[28],te=ue;break e}if(M){let ue;e[29]===Symbol.for("react.memo_cache_sentinel")?(ue=p.jsx(cu,{className:"size-4 text-muted-foreground"}),e[29]=ue):ue=e[29],te=ue;break e}const J=w?.icon;if(J){let ue;e[30]!==J?(ue=p.jsx(J,{className:"size-4 text-muted-foreground"}),e[30]=J,e[31]=ue):ue=e[31],te=ue;break e}let ie;e[32]===Symbol.for("react.memo_cache_sentinel")?(ie=p.jsx(Tp,{className:"size-4 text-muted-foreground"}),e[32]=ie):ie=e[32],te=ie}let he;e[33]!==r||e[34]!==l?(he=p.jsx(YS,{annotations:r,toolMeta:l}),e[33]=r,e[34]=l,e[35]=he):he=e[35];let ge;e[36]!==s||e[37]!==o?(ge=p.jsx(ZS,{latency:s,outputBytes:o}),e[36]=s,e[37]=o,e[38]=ge):ge=e[38];let Be;e[39]!==he||e[40]!==ge?(Be=p.jsxs(p.Fragment,{children:[he,ge]}),e[39]=he,e[40]=ge,e[41]=Be):Be=e[41];const Nt=W||null;let Fe;e[42]!==re||e[43]!==C||e[44]!==Y||e[45]!==s||e[46]!==Te||e[47]!==Be||e[48]!==Nt||e[49]!==te?(Fe=p.jsx(Z,{icon:te,iconDestructive:Y,trailing:Be,title:C,latency:s,summary:Te,state:re,detail:Nt}),e[42]=re,e[43]=C,e[44]=Y,e[45]=s,e[46]=Te,e[47]=Be,e[48]=Nt,e[49]=te,e[50]=Fe):Fe=e[50];let He;e[51]!==A||e[52]!==I?(He=A&&p.jsx("div",{className:"flex justify-end mt-1.5 mb-1",children:p.jsxs("button",{type:"button",onClick:I,className:"flex items-center gap-1.5 px-2 py-1 text-xs text-muted-foreground rounded-md [@media(hover:hover)]:hover:bg-accent/50 [@media(hover:hover)]:hover:text-foreground transition-colors",children:[p.jsx(Np,{className:"size-3.5"}),"Open in panel"]})}),e[51]=A,e[52]=I,e[53]=He):He=e[53];let Ve;e[54]!==A||e[55]!==d||e[56]!==y||e[57]!==C||e[58]!==F||e[59]!==L||e[60]!==M||e[61]!==k||e[62]!==f.id||e[63]!==f.slug||e[64]!==t.input||e[65]!==t.output||e[66]!==j||e[67]!==v||e[68]!==N?(Ve=M&&N&&y&&f?.id&&p.jsx(p.Fragment,{children:p.jsx(Xc,{fallback:J=>{const{resetError:ie}=J;return p.jsxs("div",{className:"mt-2 flex items-center gap-2 px-3 py-2.5 border border-dashed border-destructive/30 bg-destructive/5 rounded-lg",children:[p.jsx(gu,{size:16,className:"shrink-0 text-destructive"}),p.jsxs("span",{className:"flex-1 text-xs text-destructive font-medium",children:["Failed to load"," ",p.jsx("span",{className:"font-mono",children:C})," app"]}),p.jsxs(un,{size:"sm",variant:"outline",className:"h-7 text-xs gap-1.5 shrink-0",onClick:ie,children:[p.jsx(Yc,{className:"size-3.5"}),"Retry"]})]})},children:p.jsx(E.Suspense,{fallback:p.jsx("div",{className:"mt-2 flex items-center justify-center h-12 border border-border/75 rounded-lg overflow-hidden p-3",children:p.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[p.jsx("div",{className:"size-4 border-2 border-current border-t-transparent rounded-full animate-spin"}),p.jsx("span",{className:"text-sm",children:"Loading app..."})]})}),children:p.jsx(r2,{uiResourceUri:N,connectionId:y,orgId:f.id,orgSlug:f.slug,toolName:v,toolInput:t.input,toolResult:t.output,toolMeta:k,onMessage:F,onUpdateModelContext:j&&d?J=>d.setAppContext(j,J):void 0,onTeardown:j&&d?()=>d.clearAppContext(j):void 0,onRequestDisplayMode:A?L:void 0})})})}),e[54]=A,e[55]=d,e[56]=y,e[57]=C,e[58]=F,e[59]=L,e[60]=M,e[61]=k,e[62]=f.id,e[63]=f.slug,e[64]=t.input,e[65]=t.output,e[66]=j,e[67]=v,e[68]=N,e[69]=Ve):Ve=e[69];let mt;return e[70]!==Fe||e[71]!==He||e[72]!==Ve?(mt=p.jsxs("div",{children:[Fe,He,Ve]}),e[70]=Fe,e[71]=He,e[72]=Ve,e[73]=mt):mt=e[73],mt}function bh(n){return typeof n=="object"&&n!=null&&"type"in n&&n.type==="mcpToolCall"}function t2(n){if(n!=null)return bh(n)?n.arguments??void 0:n}function n2(n){if(n==null)return;if(bh(n)&&n.result!=null)return n.result;if(typeof n=="object"&&"content"in n&&Array.isArray(n.content)){const t=n.content;if(t.length>0&&typeof t[0]=="object"&&t[0]!=null&&"type"in t[0])return n}const e=typeof n=="string"?n:JSON.stringify(n);return{structuredContent:typeof n=="object"&&!Array.isArray(n)?n:void 0,content:[{type:"text",text:e}]}}function r2(n){const e=_.c(27),{uiResourceUri:t,connectionId:r,orgId:s,orgSlug:o,toolName:i,toolInput:l,toolResult:a,toolMeta:c,onMessage:u,onUpdateModelContext:d,onTeardown:f,onRequestDisplayMode:h}=n;let m;e[0]!==r||e[1]!==s||e[2]!==o?(m={connectionId:r,orgId:s,orgSlug:o},e[0]=r,e[1]=s,e[2]=o,e[3]=m):m=e[3];const g=Fi(m);let x;e[4]===Symbol.for("react.memo_cache_sentinel")?(x={type:"object"},e[4]=x):x=e[4];let y;e[5]!==c?(y=c!=null&&{_meta:c},e[5]=c,e[6]=y):y=e[6];let b;e[7]!==y||e[8]!==i?(b={name:i,inputSchema:x,...y},e[7]=y,e[8]=i,e[9]=b):b=e[9];const k=b;let S;e[10]!==k?(S={tool:k},e[10]=k,e[11]=S):S=e[11];let v;e[12]!==l?(v=t2(l),e[12]=l,e[13]=v):v=e[13];let w;e[14]!==a?(w=n2(a),e[14]=a,e[15]=w):w=e[15];let C;return e[16]!==g||e[17]!==u||e[18]!==h||e[19]!==f||e[20]!==d||e[21]!==s||e[22]!==S||e[23]!==v||e[24]!==w||e[25]!==t?(C=p.jsx("div",{className:"mt-2 border border-border/75 rounded-lg overflow-hidden p-3",children:p.jsx(Op,{resourceURI:t,orgId:s,toolInfo:S,toolInput:v,toolResult:w,client:g,onMessage:u,onUpdateModelContext:d,onTeardown:f,onRequestDisplayMode:h})}),e[16]=g,e[17]=u,e[18]=h,e[19]=f,e[20]=d,e[21]=s,e[22]=S,e[23]=v,e[24]=w,e[25]=t,e[26]=C):C=e[26],C}const Fc="mesh-storage://";function mo(n){return n.startsWith(Fc)?n.slice(Fc.length):null}function kh(n,e){const t=mo(n);return t!==null?`/api/${e}/files/${t}`:n}function s2(n){if(!n?.usage)return null;const e=n.usage.inputTokens??0,t=n.usage.outputTokens??0,r=e+t;return r?{inputTokens:e,outputTokens:t,reasoningTokens:0,totalTokens:r,cost:0,cacheReadTokens:0,cacheWriteTokens:0}:null}function o2(n){const e=_.c(13),{uri:t,orgSlug:r}=n;let s;e[0]!==r||e[1]!==t?(s=kh(t,r),e[0]=r,e[1]=t,e[2]=s):s=e[2];const o=s;let i;e[3]!==t?(i=mo(t)!==null?t.slice(t.lastIndexOf("/")+1):"reference",e[3]=t,e[4]=i):i=e[4];const l=i;let a;e[5]!==l?(a=p.jsx(fn,{asChild:!0,children:p.jsx("span",{className:"inline-flex items-center gap-1 px-1 py-0.5 rounded bg-muted text-muted-foreground text-xs cursor-default select-none",children:l})}),e[5]=l,e[6]=a):a=e[6];let c;e[7]!==l||e[8]!==o?(c=p.jsx(hn,{side:"top",className:"max-w-sm p-1.5",children:p.jsx("img",{src:o,alt:l,className:"max-w-full max-h-64 object-contain rounded"})}),e[7]=l,e[8]=o,e[9]=c):c=e[9];let u;return e[10]!==a||e[11]!==c?(u=p.jsxs(pn,{children:[a,c]}),e[10]=a,e[11]=c,e[12]=u):u=e[12],u}function i2(n){const e=_.c(76),{part:t,latency:r}=n,s=Bi();let o;e[0]!==t.state?(o=ot(t.state),e[0]=t.state,e[1]=o):o=e[1];const i=o,l=t.input,a=t.output,c=a?.images;let u;e[2]!==a?(u=s2(a),e[2]=a,e[3]=u):u=e[3];const d=u,f=a?.model;let h,m,g,x,y,b,k,S,v,w,C,T;if(e[4]!==c||e[5]!==l||e[6]!==r||e[7]!==f||e[8]!==s||e[9]!==t||e[10]!==a||e[11]!==i||e[12]!==d){y=Symbol.for("react.early_return_sentinel");e:{const D=Array.isArray(l?.referenceImages)?l.referenceImages.filter(l2):void 0;let I;e[25]!==r?(I=r!=null&&r>0?p.jsx("span",{className:"text-[11px] font-mono tabular-nums text-muted-foreground/60",children:Ht(r)}):null,e[25]=r,e[26]=I):I=e[26];const $=I;if(i==="loading"){let L;e[27]===Symbol.for("react.memo_cache_sentinel")?(L=p.jsx(Rr,{size:14}),e[27]=L):L=e[27];let z;e[28]!==l?(z=l?.prompt?`"${l.prompt.slice(0,80)}…"`:void 0,e[28]=l,e[29]=z):z=e[29];let F;e[30]!==z?(F=p.jsx(Z,{icon:L,title:"Generating image",summary:z,state:"loading"}),e[30]=z,e[31]=F):F=e[31],y=F;break e}if(a?.background){let L;e[32]===Symbol.for("react.memo_cache_sentinel")?(L=p.jsx(Rr,{size:14}),e[32]=L):L=e[32];let z;e[33]!==l?(z=l?.prompt?`"${l.prompt.slice(0,80)}…"`:void 0,e[33]=l,e[34]=z):z=e[34];let F;e[35]!==z?(F=p.jsx(Z,{icon:L,title:"Image queued — generating in the background",summary:z,state:"idle"}),e[35]=z,e[36]=F):F=e[36],y=F;break e}if(i==="error"||!c||c.length===0){let L;e[37]!==t||e[38]!==i?(L=i==="error"?po(t):void 0,e[37]=t,e[38]=i,e[39]=L):L=e[39];const z=L;let F="";l!==void 0&&(F=`# Input
171
+ `+Ws(l)),z?(F&&(F=F+`
172
+
173
+ `),F=F+(`# Error
174
+ `+z)):a!==void 0&&(F&&(F=F+`
175
+
176
+ `),F=F+(`# Output
177
+ `+Ws(a)));let U;e[40]===Symbol.for("react.memo_cache_sentinel")?(U=p.jsx(Rr,{size:14}),e[40]=U):U=e[40];const Y=i==="error"?"Failed":"No images generated",K=i==="error"?"error":"idle",Q=F||null;let ne;e[41]!==$||e[42]!==Y||e[43]!==K||e[44]!==Q||e[45]!==d?(ne=p.jsx(Z,{icon:U,title:"Image generation",summary:Y,state:K,usage:d,trailing:$,detail:Q}),e[41]=$,e[42]=Y,e[43]=K,e[44]=Q,e[45]=d,e[46]=ne):ne=e[46],y=ne;break e}x="flex flex-col gap-2",h=Z,e[47]===Symbol.for("react.memo_cache_sentinel")?(v=p.jsx(Rr,{size:14,className:"text-pink-500"}),e[47]=v):v=e[47],w="Generated image",C=f,T="idle",m=d,g=$,b="flex flex-col gap-1 pb-2 pl-6",e[48]!==l?(k=l?.prompt&&p.jsx("p",{className:"text-xs text-muted-foreground/70 whitespace-pre-wrap wrap-break-word",children:l.prompt}),e[48]=l,e[49]=k):k=e[49],S=D&&D.length>0&&p.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[p.jsx("span",{className:"text-[11px] text-muted-foreground/50",children:"references:"}),D.map((L,z)=>{const F=L.uri??L.url;return p.jsx(o2,{uri:F,orgSlug:s.slug},z)})]})}e[4]=c,e[5]=l,e[6]=r,e[7]=f,e[8]=s,e[9]=t,e[10]=a,e[11]=i,e[12]=d,e[13]=h,e[14]=m,e[15]=g,e[16]=x,e[17]=y,e[18]=b,e[19]=k,e[20]=S,e[21]=v,e[22]=w,e[23]=C,e[24]=T}else h=e[13],m=e[14],g=e[15],x=e[16],y=e[17],b=e[18],k=e[19],S=e[20],v=e[21],w=e[22],C=e[23],T=e[24];if(y!==Symbol.for("react.early_return_sentinel"))return y;let N;e[50]!==b||e[51]!==k||e[52]!==S?(N=p.jsxs("div",{className:b,children:[k,S]}),e[50]=b,e[51]=k,e[52]=S,e[53]=N):N=e[53];let M;e[54]!==h||e[55]!==m||e[56]!==g||e[57]!==N||e[58]!==v||e[59]!==w||e[60]!==C||e[61]!==T?(M=p.jsx(h,{icon:v,title:w,summary:C,state:T,usage:m,trailing:g,children:N}),e[54]=h,e[55]=m,e[56]=g,e[57]=N,e[58]=v,e[59]=w,e[60]=C,e[61]=T,e[62]=M):M=e[62];let j;if(e[63]!==c||e[64]!==l?.prompt||e[65]!==s){let D;e[67]!==l?.prompt||e[68]!==s?(D=(I,$)=>{const L=I.uri??I.url;if(!L)return null;const z=kh(L,s.slug);return p.jsx(pu,{src:z,alt:l?.prompt??"Generated image",children:p.jsx("img",{src:z,alt:l?.prompt??"Generated image",className:"max-w-sm max-h-80 object-contain rounded-lg border border-border hover:border-foreground/20 transition-colors"})},$)},e[67]=l?.prompt,e[68]=s,e[69]=D):D=e[69],j=c.map(D),e[63]=c,e[64]=l?.prompt,e[65]=s,e[66]=j}else j=e[66];let R;e[70]!==j?(R=p.jsx("div",{className:"flex flex-wrap gap-2",children:j}),e[70]=j,e[71]=R):R=e[71];let A;return e[72]!==x||e[73]!==M||e[74]!==R?(A=p.jsxs("div",{className:x,children:[M,R]}),e[72]=x,e[73]=M,e[74]=R,e[75]=A):A=e[75],A}function l2(n){return n.uri??n.url}function a2(n,e){const t=mo(n);return t!==null?`/api/${e}/files/${t}`:n}function c2(n){const e=_.c(26),{part:t,latency:r}=n,s=Bi(),o=ot(t.state),i=t.input,l=t.output,a=l?.image?.uri,c=l?.url??i?.url;let u;e[0]!==r?(u=r!=null&&r>0?p.jsx("span",{className:"text-[11px] font-mono tabular-nums text-muted-foreground/60",children:Ht(r)}):null,e[0]=r,e[1]=u):u=e[1];const d=u;if(o==="loading"){let v;e[2]===Symbol.for("react.memo_cache_sentinel")?(v=p.jsx(nr,{size:14}),e[2]=v):v=e[2];let w;return e[3]!==c?(w=p.jsx(Z,{icon:v,title:"Taking screenshot",summary:c,state:"loading"}),e[3]=c,e[4]=w):w=e[4],w}if(o==="error"||l?.success===!1||!a){let v;e[5]===Symbol.for("react.memo_cache_sentinel")?(v=p.jsx(nr,{size:14}),e[5]=v):v=e[5];const w=l?.error??"Failed";let C;return e[6]!==d||e[7]!==w?(C=p.jsx(Z,{icon:v,title:"Take screenshot",summary:w,state:"error",trailing:d}),e[6]=d,e[7]=w,e[8]=C):C=e[8],C}let f;e[9]!==s.slug||e[10]!==a?(f=a2(a,s.slug),e[9]=s.slug,e[10]=a,e[11]=f):f=e[11];const h=f;let m;e[12]===Symbol.for("react.memo_cache_sentinel")?(m=p.jsx(nr,{size:14,className:"text-blue-500"}),e[12]=m):m=e[12];let g;e[13]!==d||e[14]!==c?(g=p.jsx(Z,{icon:m,title:"Screenshot",summary:c,state:"idle",trailing:d}),e[13]=d,e[14]=c,e[15]=g):g=e[15];const x=c??"Screenshot",y=c??"Screenshot";let b;e[16]!==h||e[17]!==y?(b=p.jsx("img",{src:h,alt:y,className:"max-w-sm max-h-80 object-contain rounded-lg border border-border hover:border-foreground/20 transition-colors"}),e[16]=h,e[17]=y,e[18]=b):b=e[18];let k;e[19]!==h||e[20]!==x||e[21]!==b?(k=p.jsx("div",{className:"flex flex-wrap gap-2",children:p.jsx(pu,{src:h,alt:x,children:b})}),e[19]=h,e[20]=x,e[21]=b,e[22]=k):k=e[22];let S;return e[23]!==g||e[24]!==k?(S=p.jsxs("div",{className:"flex flex-col gap-2",children:[g,k]}),e[23]=g,e[24]=k,e[25]=S):S=e[25],S}function u2(n,e){const t=mo(n);return t!==null?`/api/${e}/files/${t}`:n}function d2(n){if(!n?.usage)return null;const e=n.usage.inputTokens??0,t=n.usage.outputTokens??0,r=e+t;if(!r)return null;const s={providerMetadata:n.usage.providerMetadata};return{inputTokens:e,outputTokens:t,reasoningTokens:0,totalTokens:r,cost:Su(s),cacheReadTokens:0,cacheWriteTokens:0}}function f2(n){try{return new URL(n).hostname.replace(/^www\./,"")}catch{return n}}function h2(n){try{return`${new URL(n).origin}/favicon.ico`}catch{return""}}function p2(n){const e=_.c(16),{citation:t,index:r}=n;let s;e[0]!==t.url?(s=f2(t.url),e[0]=t.url,e[1]=s):s=e[1];const o=s;let i;e[2]!==t.url?(i=h2(t.url),e[2]=t.url,e[3]=i):i=e[3];const l=i,a=t.title||o;let c;e[4]!==l?(c=p.jsx("img",{src:l,alt:"",className:"size-3.5 rounded-sm shrink-0",onError:m2}),e[4]=l,e[5]=c):c=e[5];let u;e[6]!==a?(u=p.jsx("span",{className:"truncate max-w-[180px]",children:a}),e[6]=a,e[7]=u):u=e[7];const d=r+1;let f;e[8]!==d?(f=p.jsxs("span",{className:"text-[10px] text-muted-foreground/50 tabular-nums shrink-0",children:["[",d,"]"]}),e[8]=d,e[9]=f):f=e[9];let h;e[10]===Symbol.for("react.memo_cache_sentinel")?(h=p.jsx(bu,{size:10,className:"shrink-0 opacity-0 group-hover/src:opacity-100 transition-opacity"}),e[10]=h):h=e[10];let m;return e[11]!==t.url||e[12]!==c||e[13]!==u||e[14]!==f?(m=p.jsxs("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:"group/src inline-flex items-center gap-1.5 rounded-md border border-border/50 bg-muted/30 px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted/60 hover:border-border hover:text-foreground",children:[c,u,f,h]}),e[11]=t.url,e[12]=c,e[13]=u,e[14]=f,e[15]=m):m=e[15],m}function m2(n){n.target.style.display="none"}function g2(n,e){return n.replace(/\[(\d+)\]/g,(t,r)=>{const s=parseInt(r,10)-1,o=e[s];return o?`[\\[${r}\\]](${o.url})`:t})}const Jo=5;function x2(n){const e=_.c(12),{citations:t}=n,[r,s]=E.useState(!1),o=t.length>Jo;let i;e[0]!==t||e[1]!==r?(i=r?t:t.slice(0,Jo),e[0]=t,e[1]=r,e[2]=i):i=e[2];const l=i;let a;e[3]!==l?(a=l.map(b2),e[3]=l,e[4]=a):a=e[4];let c;e[5]!==t.length||e[6]!==r||e[7]!==o?(c=o&&p.jsx("button",{type:"button",onClick:()=>s(y2),className:"inline-flex items-center rounded-md border border-border/50 bg-muted/30 px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted/60 hover:border-border hover:text-foreground",children:r?"show less":`+${t.length-Jo} more`}),e[5]=t.length,e[6]=r,e[7]=o,e[8]=c):c=e[8];let u;return e[9]!==a||e[10]!==c?(u=p.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[a,c]}),e[9]=a,e[10]=c,e[11]=u):u=e[11],u}function y2(n){return!n}function b2(n,e){return p.jsx(p2,{citation:n,index:e},n.url)}function k2(n){const e=_.c(51),{part:t,latency:r,streamingText:s}=n,o=Bi();let i;e[0]!==t.state?(i=ot(t.state),e[0]=t.state,e[1]=i):i=e[1];const l=i,a=t.input,c=t.output;let u,d,f;e[2]!==o||e[3]!==c?(u=c?.uri?u2(c.uri,o.slug):void 0,f=Mr,d=Qe.webSearchBlob(u??""),e[2]=o,e[3]=c,e[4]=u,e[5]=d,e[6]=f):(u=e[4],d=e[5],f=e[6]);let h;e[7]!==u?(h=async()=>{const K=await fetch(u);if(!K.ok)throw new Error(`Failed to fetch: ${K.status}`);return K.text()},e[7]=u,e[8]=h):h=e[8];const m=!!u;let g;e[9]!==d||e[10]!==h||e[11]!==m?(g={queryKey:d,queryFn:h,enabled:m,staleTime:1/0},e[9]=d,e[10]=h,e[11]=m,e[12]=g):g=e[12];const{data:x}=f(g),y=l==="loading",b=l!=="loading"&&l!=="error",k=c?.citations;let S;e[13]!==c?(S=d2(c),e[13]=c,e[14]=S):S=e[14];const v=S,w=c?.content??x??s;let C;e[15]!==k||e[16]!==w?(C=w&&k?.length?g2(w,k):w,e[15]=k,e[16]=w,e[17]=C):C=e[17];const T=C;let N;e[18]!==r?(N=r!=null&&r>0?p.jsx("span",{className:"text-[11px] font-mono tabular-nums text-muted-foreground/60",children:Ht(r)}):null,e[18]=r,e[19]=N):N=e[19];const M=N;if(l==="error"){let K;e[20]===Symbol.for("react.memo_cache_sentinel")?(K=p.jsx(es,{size:14}),e[20]=K):K=e[20];let Q;return e[21]!==M||e[22]!==v?(Q=p.jsx(Z,{icon:K,title:"Web search",summary:"Failed",state:"error",usage:v,trailing:M}),e[21]=M,e[22]=v,e[23]=Q):Q=e[23],Q}const j=y?"animate-pulse":"text-blue-500";let R;e[24]!==j?(R=ee(j),e[24]=j,e[25]=R):R=e[25];let A;e[26]!==R?(A=p.jsx(es,{size:14,className:R}),e[26]=R,e[27]=A):A=e[27];const D=y?"Researching...":"Web search";let I;e[28]!==a||e[29]!==b||e[30]!==c?.model?(I=b?c?.model??a?.query?.slice(0,60):a?.query?`"${a.query.slice(0,80)}"`:void 0,e[28]=a,e[29]=b,e[30]=c?.model,e[31]=I):I=e[31];const $=y?"loading":"idle";let L;e[32]!==a?(L=a?.query&&p.jsx("p",{className:"text-xs text-muted-foreground/70 whitespace-pre-wrap wrap-break-word",children:a.query}),e[32]=a,e[33]=L):L=e[33];let z;e[34]!==T||e[35]!==t.toolCallId?(z=T?p.jsx("div",{className:"max-h-96 overflow-y-auto overflow-x-hidden rounded-lg border border-border/40 bg-muted/20 px-4 py-3 min-w-0",children:p.jsx("div",{className:"prose prose-sm prose-neutral dark:prose-invert max-w-none text-[13px] leading-relaxed break-words",children:p.jsx(Ji,{id:t.toolCallId,text:T})})}):p.jsx("div",{className:"rounded-lg border border-border/40 bg-muted/20 px-4 py-3",children:p.jsxs("div",{className:"space-y-2 animate-pulse",children:[p.jsx("div",{className:"h-3 rounded bg-muted-foreground/10 w-3/4"}),p.jsx("div",{className:"h-3 rounded bg-muted-foreground/10 w-1/2"})]})}),e[34]=T,e[35]=t.toolCallId,e[36]=z):z=e[36];let F;e[37]!==k?(F=k&&k.length>0&&p.jsx(x2,{citations:k}),e[37]=k,e[38]=F):F=e[38];let U;e[39]!==L||e[40]!==z||e[41]!==F?(U=p.jsxs("div",{className:"pl-6 pb-3 flex flex-col gap-1 min-w-0",children:[L,z,F]}),e[39]=L,e[40]=z,e[41]=F,e[42]=U):U=e[42];let Y;return e[43]!==M||e[44]!==A||e[45]!==D||e[46]!==I||e[47]!==$||e[48]!==U||e[49]!==v?(Y=p.jsx(Z,{icon:A,title:D,summary:I,state:$,usage:v,trailing:M,defaultOpen:!0,children:U}),e[43]=M,e[44]=A,e[45]=D,e[46]=I,e[47]=$,e[48]=U,e[49]=v,e[50]=Y):Y=e[50],Y}function S2(n){const e=_.c(14),{part:t}=n;if(!t.state.startsWith("output-"))return null;let r;e[0]!==t.input?.prompt?(r=t.input?.prompt?.trim()||"Question",e[0]=t.input?.prompt,e[1]=r):r=e[1];const s=r,o=t.state==="output-error"||t.state==="output-denied",i=t.state==="output-denied";let l;e[2]!==i||e[3]!==t?(l=i?"Skipped":t.state==="output-error"?po(t)??"Error":t.output?.response??"",e[2]=i,e[3]=t,e[4]=l):l=e[4];const a=l;let c;e[5]===Symbol.for("react.memo_cache_sentinel")?(c=p.jsx(xp,{className:"size-4 text-muted-foreground/50 shrink-0 mt-0.5"}),e[5]=c):c=e[5];let u;e[6]!==s?(u=p.jsxs("div",{className:"flex items-start gap-2",children:[c,p.jsx("span",{className:"text-[14px] text-muted-foreground leading-snug",children:s})]}),e[6]=s,e[7]=u):u=e[7];let d;e[8]!==a||e[9]!==o?(d=a&&p.jsx("div",{className:"ml-6 pl-2 border-l border-border/50",children:p.jsx("span",{className:ee("text-[14px] leading-snug",o?"text-muted-foreground/50 italic":"text-foreground/70"),children:a})}),e[8]=a,e[9]=o,e[10]=d):d=e[10];let f;return e[11]!==u||e[12]!==d?(f=p.jsxs("div",{className:"my-1.5 flex flex-col gap-1",children:[u,d]}),e[11]=u,e[12]=d,e[13]=f):f=e[13],f}const Sh=E.createContext(new Map);function nT(n){const e=_.c(5),{messages:t,children:r}=n;let s;if(e[0]!==t){s=new Map;for(const i of t){const l=i.metadata?.subtaskJobId;if(!l)continue;const a=s.get(l);a?a.push(i):s.set(l,[i])}e[0]=t,e[1]=s}else s=e[1];let o;return e[2]!==s||e[3]!==r?(o=p.jsx(Sh.Provider,{value:s,children:r}),e[2]=s,e[3]=r,e[4]=o):o=e[4],o}function v2(n){const e=_.c(3),t=E.useContext(Sh);let r;return e[0]!==n||e[1]!==t?(r=n?t.get(n)??[]:[],e[0]=n,e[1]=t,e[2]=r):r=e[2],r}function w2(n){return new ReadableStream({async start(e){const t=n.getReader(),r=new TextDecoder;let s="";try{for(;;){const{done:o,value:i}=await t.read();if(o)break;s+=r.decode(i,{stream:!0});let l;for(;(l=s.indexOf(`
178
+
179
+ `))!==-1;){const a=s.slice(0,l);s=s.slice(l+2);const c=a.split(`
180
+ `).filter(u=>u.startsWith("data:")).map(u=>u.slice(5).trim()).join(`
181
+ `);if(c)try{e.enqueue(JSON.parse(c))}catch{}}}}finally{t.releaseLock(),e.close()}}})}function C2(n){const{orgSlug:e,threadId:t,jobId:r,enabled:s}=n,[o,i]=E.useState([]),[l,a]=E.useState(!1);return E.useEffect(()=>{if(!s||!r)return;const c=new AbortController;return i([]),a(!0),(async()=>{try{const u=await fetch(`/api/${encodeURIComponent(e)}/decopilot/threads/${encodeURIComponent(t)}/jobs/${encodeURIComponent(r)}/stream`,{headers:{accept:"text/event-stream"},credentials:"include",signal:c.signal});if(!u.ok||!u.body)return;for await(const d of $p({stream:zp(w2(u.body),void 0)})){if(c.signal.aborted)return;i([d])}}catch{}finally{c.signal.aborted||a(!1)}})(),()=>c.abort()},[s,r,t,e]),{messages:o,streaming:l}}function T2(n){if(n&&typeof n=="object"&&!Array.isArray(n)){const e=n;if(typeof e.text=="string"||typeof e.error=="string"||typeof e.finishReason=="string"){if(typeof e.error=="string"&&e.error.length>0)return`Subtask failed: ${e.error}`;const r=typeof e.text=="string"?e.text.trim():"",s=e.finishReason==="length";return r?(s?`[Subtask hit step limit — partial result below; consider narrowing the task.]
182
+
183
+ `:"")+r:s?"[Subtask hit step limit before producing a final report. The subagent did work but ran out of steps. Narrow the task or increase the budget.]":"Subtask completed (no output)."}}return JS(n)}function vh(n){return!!n&&typeof n=="object"&&n.background===!0}function wh({part:n,subtaskMeta:e}){const t=n.state==="input-streaming"||n.state==="input-available",r=n.state==="output-available"&&n.preliminary===!0,s=n.state==="output-available"&&!n.preliminary,o=n.state==="output-error",i=ot(n.state,"preliminary"in n?n.preliminary:!1),l=i==="approval"?"idle":i,a=t?"Starting subtask...":r?"Subtask running...":s?"Subtask completed":o?"Subtask failed":"Subtask",c=n.input?.prompt??"",u=n.state==="approval-requested"?"Awaiting approval...":c.length>120?c.slice(0,120)+"…":c;return{fallbackTitle:a,summary:u,usage:e?.usage,state:l}}function Ul(n){const e=_.c(45),{icon:t,title:r,summary:s,state:o,usage:i,onOpenChange:l,children:a}=n,[c,u]=E.useState(!1);let d;e[0]!==l?(d=z=>{u(z),l?.(z)},e[0]=l,e[1]=d):d=e[1];const f=d,h=o==="loading",m=o==="error";let g;e[2]!==f?(g=()=>f(!0),e[2]=f,e[3]=g):g=e[3];const x=h&&"shimmer";let y;e[4]!==x?(y=ee("group/tool flex items-center gap-2 w-full py-2.5 text-left rounded-md transition-colors","[@media(hover:hover)]:hover:bg-accent/30",x),e[4]=x,e[5]=y):y=e[5];const b=m?"[&>svg]:text-warning/70":"[&>svg]:text-muted-foreground/75";let k;e[6]!==b?(k=ee("relative shrink-0 size-4 flex items-center justify-center [&>svg]:size-4",b),e[6]=b,e[7]=k):k=e[7];let S;e[8]!==t||e[9]!==k?(S=p.jsx("div",{className:k,children:t}),e[8]=t,e[9]=k,e[10]=S):S=e[10];const v=m?"text-warning/80":"text-foreground";let w;e[11]!==v?(w=ee("shrink-0 text-[14px] font-normal",v),e[11]=v,e[12]=w):w=e[12];let C;e[13]!==w||e[14]!==r?(C=p.jsx("span",{className:w,children:r}),e[13]=w,e[14]=r,e[15]=C):C=e[15];let T;e[16]!==s?(T=s?p.jsx("span",{className:"min-w-0 flex-1 truncate",children:p.jsx("span",{className:"text-[12px] text-muted-foreground/60 bg-muted/50 rounded-[3px] px-1 py-px leading-none",children:s})}):p.jsx("div",{className:"flex-1"}),e[16]=s,e[17]=T):T=e[17];let N;e[18]===Symbol.for("react.memo_cache_sentinel")?(N=p.jsx(em,{className:"size-3.5 shrink-0 text-muted-foreground/40 opacity-0 transition-opacity [@media(hover:hover)]:group-hover/tool:opacity-100"}),e[18]=N):N=e[18];let M;e[19]!==i?(M=p.jsx(hh,{usage:i}),e[19]=i,e[20]=M):M=e[20];let j;e[21]!==C||e[22]!==T||e[23]!==M||e[24]!==g||e[25]!==y||e[26]!==S?(j=p.jsxs("button",{type:"button",onClick:g,className:y,children:[S,C,T,N,M]}),e[21]=C,e[22]=T,e[23]=M,e[24]=g,e[25]=y,e[26]=S,e[27]=j):j=e[27];let R;e[28]!==t?(R=p.jsx("span",{className:"flex items-center [&>svg]:size-4 [&>svg]:text-muted-foreground/75",children:t}),e[28]=t,e[29]=R):R=e[29];let A;e[30]!==R||e[31]!==r?(A=p.jsx(eu,{className:"px-4 py-3 border-b border-border shrink-0",children:p.jsxs(tu,{className:"flex items-center gap-2 text-sm font-medium",children:[R,r]})}),e[30]=R,e[31]=r,e[32]=A):A=e[32];let D;e[33]!==a?(D=p.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto px-4 py-4",children:a}),e[33]=a,e[34]=D):D=e[34];let I;e[35]!==A||e[36]!==D?(I=p.jsxs(Hi,{side:"right",className:"w-full sm:max-w-2xl flex flex-col p-0 gap-0",children:[A,D]}),e[35]=A,e[36]=D,e[37]=I):I=e[37];let $;e[38]!==c||e[39]!==f||e[40]!==I?($=p.jsx(Vi,{open:c,onOpenChange:f,children:I}),e[38]=c,e[39]=f,e[40]=I,e[41]=$):$=e[41];let L;return e[42]!==j||e[43]!==$?(L=p.jsxs(p.Fragment,{children:[j,$]}),e[42]=j,e[43]=$,e[44]=L):L=e[44],L}function Ch(n){const e=_.c(9),{part:t}=n,r=t.state==="output-error",s=t.input?.prompt??"No prompt provided";let o;if(e[0]!==r||e[1]!==t||e[2]!==s){const i=r?po(t):T2(t.output)??"";let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=p.jsx("h3",{className:"text-xs font-medium text-muted-foreground/70 mb-1.5",children:"Task"}),e[4]=l):l=e[4];let a;e[5]!==s?(a=p.jsxs("section",{children:[l,p.jsx("p",{className:"text-[13px] text-foreground/90 whitespace-pre-wrap wrap-break-word",children:s})]}),e[5]=s,e[6]=a):a=e[6];const c=r?"Error":"Result";let u;e[7]!==c?(u=p.jsx("h3",{className:"text-xs font-medium text-muted-foreground/70 mb-1.5",children:c}),e[7]=c,e[8]=u):u=e[8],o=p.jsxs("div",{className:"flex flex-col gap-4",children:[a,p.jsxs("section",{children:[u,i.trim()?p.jsx(Ji,{id:`${t.toolCallId}-result`,text:i}):p.jsx("p",{className:"text-[13px] text-muted-foreground/60 italic",children:"Running…"})]})]}),e[0]=r,e[1]=t,e[2]=s,e[3]=o}else o=e[3];return o}const Go=600;function N2(n){const e=_.c(12),{part:t}=n,r=t.type??"";let s;e[0]!==t.toolName||e[1]!==r?(s=r==="dynamic-tool"?t.toolName??"tool":r.slice(5),e[0]=t.toolName,e[1]=r,e[2]=s):s=e[2];const o=s;let i;if(e[3]!==t.input){const f=t.input!=null?JSON.stringify(t.input):"";i=f.length>80?`${f.slice(0,80)}…`:f||void 0,e[3]=t.input,e[4]=i}else i=e[4];const l=i;let a;if(e[5]!==t.input){const f=t.input!=null?JSON.stringify(t.input,null,2):null;a=f&&f.length>Go?`${f.slice(0,Go)}
184
+ … (${f.length-Go} more characters)`:f,e[5]=t.input,e[6]=a}else a=e[6];const c=a;let u;e[7]===Symbol.for("react.memo_cache_sentinel")?(u=p.jsx(au,{}),e[7]=u):u=e[7];let d;return e[8]!==c||e[9]!==o||e[10]!==l?(d=p.jsx(Z,{icon:u,title:o,summary:l,state:"idle",detail:c,detailVariant:"code"}),e[8]=c,e[9]=o,e[10]=l,e[11]=d):d=e[11],d}function M2(n){const e=_.c(12),{jobId:t,prompt:r,items:s,streaming:o}=n;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=p.jsx("h3",{className:"text-xs font-medium text-muted-foreground/70 mb-1.5",children:"Task"}),e[0]=i):i=e[0];let l;e[1]!==r?(l=p.jsxs("section",{children:[i,p.jsx("p",{className:"text-[13px] text-foreground/90 whitespace-pre-wrap wrap-break-word",children:r})]}),e[1]=r,e[2]=l):l=e[2];let a;e[3]!==s||e[4]!==t||e[5]!==o?(a=s.length===0?p.jsx("p",{className:"text-[13px] text-muted-foreground/60 italic py-1",children:"Running in the background…"}):s.map((d,f)=>{const h=d,m=h.type??"";return m==="text"?h.text?.trim()?p.jsx(uo,{id:`${t}-sub-${f}`,part:d,animate:o},`${t}-sub-${f}`):null:m==="dynamic-tool"||m.startsWith("tool-")&&m!=="tool-todo_write"&&m!=="tool-update_interests"?p.jsx(N2,{part:h},`${t}-sub-${f}`):null}),e[3]=s,e[4]=t,e[5]=o,e[6]=a):a=e[6];let c;e[7]!==a?(c=p.jsx("section",{className:"flex flex-col gap-3 sm:gap-2",children:a}),e[7]=a,e[8]=c):c=e[8];let u;return e[9]!==l||e[10]!==c?(u=p.jsxs("div",{className:"flex flex-col gap-4",children:[l,c]}),e[9]=l,e[10]=c,e[11]=u):u=e[11],u}function Th(n){const e=_.c(21),{part:t}=n,r=t.output?.jobId,{taskId:s}=Pp(),{org:o}=Ct(),[i,l]=E.useState(!1),a=v2(r);let c;e[0]!==r||e[1]!==i||e[2]!==o.slug||e[3]!==s?(c={orgSlug:o.slug,threadId:s,jobId:r,enabled:i},e[0]=r,e[1]=i,e[2]=o.slug,e[3]=s,e[4]=c):c=e[4];const u=C2(c);let d;e[5]!==u.messages?(d=u.messages.flatMap(A2),e[5]=u.messages,e[6]=d):d=e[6];const f=d;let h;e[7]!==a?(h=a.flatMap(E2),e[7]=a,e[8]=h):h=e[8];const m=h,g=f.length>0?f:m,x=t.input?.prompt??"No prompt provided";let y;e[9]!==x?(y=x.length>120?`${x.slice(0,120)}…`:x,e[9]=x,e[10]=y):y=e[10];const b=y,k=a.length===0;let S;e[11]===Symbol.for("react.memo_cache_sentinel")?(S=p.jsx(qt,{icon:void 0,name:"Subtask",size:"2xs",className:"rounded-xs",fallbackIcon:p.jsx(Xi,{})}),e[11]=S):S=e[11];const v=k?"loading":"idle",w=u.streaming||k;let C;e[12]!==g||e[13]!==r||e[14]!==x||e[15]!==w?(C=p.jsx(M2,{jobId:r,prompt:x,items:g,streaming:w}),e[12]=g,e[13]=r,e[14]=x,e[15]=w,e[16]=C):C=e[16];let T;return e[17]!==b||e[18]!==v||e[19]!==C?(T=p.jsx(Ul,{icon:S,title:"Subtask",summary:b,state:v,onOpenChange:l,children:C}),e[17]=b,e[18]=v,e[19]=C,e[20]=T):T=e[20],T}function E2(n){return n.parts??[]}function A2(n){return n.parts??[]}function j2(n){const e=_.c(13);if(vh(n.part.output)){let u;return e[0]!==n?(u=p.jsx(Th,{...n}),e[0]=n,e[1]=u):u=e[1],u}let t;e[2]!==n?(t=wh(n),e[2]=n,e[3]=t):t=e[3];const{fallbackTitle:r,summary:s,usage:o,state:i}=t;let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=p.jsx(qt,{icon:void 0,name:"Subtask",size:"2xs",className:"rounded-xs",fallbackIcon:p.jsx(Xi,{})}),e[4]=l):l=e[4];let a;e[5]!==n.part?(a=p.jsx(Ch,{part:n.part}),e[5]=n.part,e[6]=a):a=e[6];let c;return e[7]!==r||e[8]!==i||e[9]!==s||e[10]!==a||e[11]!==o?(c=p.jsx(Ul,{icon:l,title:r,summary:s,state:i,usage:o,children:a}),e[7]=r,e[8]=i,e[9]=s,e[10]=a,e[11]=o,e[12]=c):c=e[12],c}function I2(n){const e=_.c(17),t=Zc(n.part.input?.agent_id);if(vh(n.part.output)){let g;return e[0]!==n?(g=p.jsx(Th,{...n}),e[0]=n,e[1]=g):g=e[1],g}let r;e[2]!==n?(r=wh(n),e[2]=n,e[3]=r):r=e[3];const{fallbackTitle:s,summary:o,usage:i,state:l}=r,a=t?.icon,c=t?.title??"Subtask";let u;e[4]===Symbol.for("react.memo_cache_sentinel")?(u=p.jsx(Xi,{}),e[4]=u):u=e[4];let d;e[5]!==a||e[6]!==c?(d=p.jsx(qt,{icon:a,name:c,size:"2xs",className:"rounded-xs",fallbackIcon:u}),e[5]=a,e[6]=c,e[7]=d):d=e[7];const f=t?.title??s;let h;e[8]!==n.part?(h=p.jsx(Ch,{part:n.part}),e[8]=n.part,e[9]=h):h=e[9];let m;return e[10]!==l||e[11]!==o||e[12]!==d||e[13]!==f||e[14]!==h||e[15]!==i?(m=p.jsx(Ul,{icon:d,title:f,summary:o,state:l,usage:i,children:h}),e[10]=l,e[11]=o,e[12]=d,e[13]=f,e[14]=h,e[15]=i,e[16]=m):m=e[16],m}function O2(n){const e=_.c(16),{part:t}=n;if(!t.state.startsWith("output-"))return null;const r=t.input?.plan??"",o=t.output?.approved===!0;let i,l;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=p.jsx(Zo,{className:"size-4 text-purple-500 shrink-0"}),l=p.jsx("span",{className:"text-[14px] font-medium text-foreground/80",children:"Implementation Plan"}),e[0]=i,e[1]=l):(i=e[0],l=e[1]);let a;e[2]!==o?(a=o&&p.jsxs("span",{className:"flex items-center gap-1 text-xs text-success bg-success/10 px-1.5 py-0.5 rounded-md",children:[p.jsx(qi,{size:12}),"Approved"]}),e[2]=o,e[3]=a):a=e[3];let c;e[4]!==o||e[5]!==t.state?(c=!o&&t.state==="output-available"&&p.jsx("span",{className:"text-xs text-muted-foreground/70 italic",children:"Rejected"}),e[4]=o,e[5]=t.state,e[6]=c):c=e[6];let u;e[7]!==a||e[8]!==c?(u=p.jsxs("div",{className:"flex items-center gap-2",children:[i,l,a,c]}),e[7]=a,e[8]=c,e[9]=u):u=e[9];let d;e[10]===Symbol.for("react.memo_cache_sentinel")?(d=p.jsx("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground transition-colors",children:"View plan"}),e[10]=d):d=e[10];let f;e[11]!==r?(f=p.jsxs("details",{className:"ml-6",children:[d,p.jsx("div",{className:"mt-1 pl-2 border-l-2 border-purple-500/30 prose prose-sm max-w-none text-sm",children:p.jsx(uo,{id:"plan-content",part:{type:"text",text:r}})})]}),e[11]=r,e[12]=f):f=e[12];let h;return e[13]!==u||e[14]!==f?(h=p.jsxs("div",{className:"my-1.5 flex flex-col gap-1",children:[u,f]}),e[13]=u,e[14]=f,e[15]=h):h=e[15],h}const ql={primary:"Primary",secondary:"Secondary",accent:"Accent",background:"Background",foreground:"Foreground"};function R2(n){return n.startsWith("http")?n:`https://${n}`}function Hc(n){const e=_.c(2),{children:t}=n;let r;return e[0]!==t?(r=p.jsx("span",{className:"text-sm font-medium text-foreground",children:t}),e[0]=t,e[1]=r):r=e[1],r}function D2(n){const e=_.c(12),{name:t,value:r}=n;let s;e[0]!==r?(s=p.jsx("span",{className:"size-7 shrink-0 rounded-md border border-border",style:{backgroundColor:r},"aria-hidden":!0}),e[0]=r,e[1]=s):s=e[1];let o;e[2]!==t?(o=p.jsx("span",{className:"text-sm text-foreground",children:t}),e[2]=t,e[3]=o):o=e[3];let i;e[4]!==r?(i=p.jsx("span",{className:"text-xs font-mono tabular-nums text-muted-foreground",children:r}),e[4]=r,e[5]=i):i=e[5];let l;e[6]!==o||e[7]!==i?(l=p.jsxs("div",{className:"flex flex-col leading-tight min-w-0",children:[o,i]}),e[6]=o,e[7]=i,e[8]=l):l=e[8];let a;return e[9]!==s||e[10]!==l?(a=p.jsxs("div",{className:"flex items-center gap-2.5",children:[s,l]}),e[9]=s,e[10]=l,e[11]=a):a=e[11],a}function P2(n){const e=_.c(15),{role:t,family:r}=n;let s;e[0]!==r?(s=p.jsx("span",{className:"text-2xl font-medium leading-none text-foreground shrink-0",style:{fontFamily:r},"aria-hidden":!0,children:"Aa"}),e[0]=r,e[1]=s):s=e[1];let o;e[2]!==t?(o=p.jsx("span",{className:"text-xs text-muted-foreground",children:t}),e[2]=t,e[3]=o):o=e[3];let i;e[4]!==r?(i={fontFamily:r},e[4]=r,e[5]=i):i=e[5];let l;e[6]!==r||e[7]!==i?(l=p.jsx("span",{className:"text-sm text-foreground",style:i,children:r}),e[6]=r,e[7]=i,e[8]=l):l=e[8];let a;e[9]!==o||e[10]!==l?(a=p.jsxs("div",{className:"flex flex-col leading-tight",children:[o,l]}),e[9]=o,e[10]=l,e[11]=a):a=e[11];let c;return e[12]!==s||e[13]!==a?(c=p.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-border bg-muted px-4 py-3",children:[s,a]}),e[12]=s,e[13]=a,e[14]=c):c=e[14],c}function L2(n){const e=_.c(3),{logo:t,favicon:r,name:s}=n,o=t??r;if(!o)return null;const i=s?`${s} logo`:"";let l;return e[0]!==o||e[1]!==i?(l=p.jsx("img",{src:o,alt:i,className:"size-16 shrink-0 rounded-lg border border-border bg-background object-contain p-2",onError:_2}),e[0]=o,e[1]=i,e[2]=l):l=e[2],l}function _2(n){n.target.style.display="none"}function Nh(n){const e=_.c(4),{colors:t}=n;let r;e[0]!==t?(r=Object.entries(t).filter(z2),e[0]=t,e[1]=r):r=e[1];const s=r;if(s.length===0)return null;let o;return e[2]!==s?(o=p.jsx("div",{className:"flex h-1.5",children:s.map($2)}),e[2]=s,e[3]=o):o=e[3],o}function $2(n){const[e,t]=n;return p.jsx("span",{className:"flex-1",style:{backgroundColor:t},title:`${ql[e]}: ${t}`,"aria-hidden":!0},e)}function z2(n){const[,e]=n;return typeof e=="string"&&e.trim().length>0}function Mh(n){const e=_.c(36),{logo:t,favicon:r,name:s,domain:o,overview:i,colors:l,fonts:a,showDefaultBadge:c,isDefault:u}=n;let d;e[0]!==l?(d=l?Object.entries(l).filter(V2):[],e[0]=l,e[1]=d):d=e[1];const f=d;let h;e[2]!==a?(h=a?Object.entries(a).filter(H2):[],e[2]=a,e[3]=h):h=e[3];const m=h;let g;e[4]!==l?(g=l&&p.jsx(Nh,{colors:l}),e[4]=l,e[5]=g):g=e[5];let x;e[6]!==r||e[7]!==t||e[8]!==s?(x=p.jsx(L2,{logo:t,favicon:r,name:s}),e[6]=r,e[7]=t,e[8]=s,e[9]=x):x=e[9];let y;e[10]!==u||e[11]!==s||e[12]!==c?(y=s&&p.jsxs("span",{className:"inline-flex items-center gap-2 text-lg font-semibold text-foreground truncate",children:[s,c&&u&&p.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-muted px-2 py-0.5 text-xs font-medium text-muted-foreground",children:[p.jsx(xu,{className:"size-3 text-amber-500"}),"default"]})]}),e[10]=u,e[11]=s,e[12]=c,e[13]=y):y=e[13];let b;e[14]!==o?(b=o&&p.jsxs("a",{href:R2(o),target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[o,p.jsx(bu,{className:"size-3 shrink-0"})]}),e[14]=o,e[15]=b):b=e[15];let k;e[16]!==y||e[17]!==b?(k=p.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[y,b]}),e[16]=y,e[17]=b,e[18]=k):k=e[18];let S;e[19]!==x||e[20]!==k?(S=p.jsxs("div",{className:"flex items-center gap-4",children:[x,k]}),e[19]=x,e[20]=k,e[21]=S):S=e[21];let v;e[22]!==i?(v=i&&p.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:i}),e[22]=i,e[23]=v):v=e[23];let w;e[24]!==f?(w=f.length>0&&p.jsxs("div",{className:"flex flex-col gap-3",children:[p.jsx(Hc,{children:"Colors"}),p.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-x-4 gap-y-3",children:f.map(F2)})]}),e[24]=f,e[25]=w):w=e[25];let C;e[26]!==m?(C=m.length>0&&p.jsxs("div",{className:"flex flex-col gap-3",children:[p.jsx(Hc,{children:"Typography"}),p.jsx("div",{className:"flex flex-wrap gap-2.5",children:m.map(B2)})]}),e[26]=m,e[27]=C):C=e[27];let T;e[28]!==w||e[29]!==C||e[30]!==S||e[31]!==v?(T=p.jsxs("div",{className:"p-5 flex flex-col gap-6",children:[S,v,w,C]}),e[28]=w,e[29]=C,e[30]=S,e[31]=v,e[32]=T):T=e[32];let N;return e[33]!==T||e[34]!==g?(N=p.jsxs("div",{className:"mt-2 rounded-lg overflow-hidden border border-border",children:[g,T]}),e[33]=T,e[34]=g,e[35]=N):N=e[35],N}function B2(n){const[e,t]=n;return p.jsx(P2,{role:e,family:t},e)}function F2(n){const[e,t]=n;return p.jsx(D2,{name:ql[e],value:t},e)}function H2(n){const[,e]=n;return typeof e=="string"&&e.trim().length>0}function V2(n){const[,e]=n;return typeof e=="string"&&e.trim().length>0}function W2(n){const e=_.c(29),{part:t,latency:r}=n,s=ot(t.state);let o;e[0]!==t.output?(o=Un(t.output),e[0]=t.output,e[1]=o):o=e[1];const i=o,l=s==="loading",a=s==="error"||i&&i.success===!1;if(l){const C=t.input;let T;e[2]===Symbol.for("react.memo_cache_sentinel")?(T=p.jsx(dt,{className:"animate-pulse"}),e[2]=T):T=e[2];const N=C?.domain?`from ${C.domain}`:void 0;let M;return e[3]!==N?(M=p.jsx(Z,{icon:T,title:"Extracting brand",summary:N,state:"loading",defaultOpen:!0}),e[3]=N,e[4]=M):M=e[4],M}if(a){let C;e[5]===Symbol.for("react.memo_cache_sentinel")?(C=p.jsx(dt,{}),e[5]=C):C=e[5];const T=i?.error??"Unknown error";let N;e[6]!==r?(N=r!=null&&r>0?p.jsx(Ie,{latency:r}):void 0,e[6]=r,e[7]=N):N=e[7];let M;return e[8]!==T||e[9]!==N?(M=p.jsx(Z,{icon:C,title:"Brand extraction failed",summary:T,state:"error",trailing:N}),e[8]=T,e[9]=N,e[10]=M):M=e[10],M}let c;e[11]===Symbol.for("react.memo_cache_sentinel")?(c=p.jsx(dt,{className:"text-fuchsia-500"}),e[11]=c):c=e[11];const u=i?.name?`Brand set: ${i.name}`:"Brand context set",d=i?.domain;let f;e[12]!==r?(f=r!=null&&r>0?p.jsx(Ie,{latency:r}):void 0,e[12]=r,e[13]=f):f=e[13];let h;e[14]!==u||e[15]!==d||e[16]!==f?(h=p.jsx(Z,{icon:c,title:u,summary:d,state:"idle",trailing:f}),e[14]=u,e[15]=d,e[16]=f,e[17]=h):h=e[17];const m=i?.logo,g=i?.favicon,x=i?.name,y=i?.domain,b=i?.overview,k=i?.colors,S=i?.fonts;let v;e[18]!==y||e[19]!==b||e[20]!==k||e[21]!==S||e[22]!==m||e[23]!==g||e[24]!==x?(v=p.jsx(Mh,{logo:m,favicon:g,name:x,domain:y,overview:b,colors:k,fonts:S}),e[18]=y,e[19]=b,e[20]=k,e[21]=S,e[22]=m,e[23]=g,e[24]=x,e[25]=v):v=e[25];let w;return e[26]!==v||e[27]!==h?(w=p.jsxs(p.Fragment,{children:[h,v]}),e[26]=v,e[27]=h,e[28]=w):w=e[28],w}function U2(n){const e=_.c(27),{part:t,latency:r}=n,s=ot(t.state);let o;e[0]!==t.output?(o=Un(t.output),e[0]=t.output,e[1]=o):o=e[1];const i=o,l=s==="loading",a=s==="error"||i&&i.success===!1;if(l){let g;return e[2]===Symbol.for("react.memo_cache_sentinel")?(g=p.jsx(Z,{icon:p.jsx(dt,{className:"animate-pulse"}),title:"Loading brand",state:"loading"}),e[2]=g):g=e[2],g}if(a||!i){let g;e[3]===Symbol.for("react.memo_cache_sentinel")?(g=p.jsx(dt,{}),e[3]=g):g=e[3];let x;e[4]!==r?(x=r!=null&&r>0?p.jsx(Ie,{latency:r}):void 0,e[4]=r,e[5]=x):x=e[5];let y;return e[6]!==x?(y=p.jsx(Z,{icon:g,title:"Couldn't load brand",state:"error",trailing:x}),e[6]=x,e[7]=y):y=e[7],y}let c;e[8]===Symbol.for("react.memo_cache_sentinel")?(c=p.jsx(dt,{className:"text-fuchsia-500"}),e[8]=c):c=e[8];const u=i.name?`Brand · ${i.name}`:"Brand";let d;e[9]!==r?(d=r!=null&&r>0?p.jsx(Ie,{latency:r}):void 0,e[9]=r,e[10]=d):d=e[10];let f;e[11]!==i.domain||e[12]!==u||e[13]!==d?(f=p.jsx(Z,{icon:c,title:u,summary:i.domain,state:"idle",trailing:d}),e[11]=i.domain,e[12]=u,e[13]=d,e[14]=f):f=e[14];let h;e[15]!==i.colors||e[16]!==i.domain||e[17]!==i.favicon||e[18]!==i.fonts||e[19]!==i.isDefault||e[20]!==i.logo||e[21]!==i.name||e[22]!==i.overview?(h=p.jsx(Mh,{logo:i.logo,favicon:i.favicon,name:i.name,domain:i.domain,overview:i.overview,colors:i.colors,fonts:i.fonts,showDefaultBadge:!0,isDefault:i.isDefault}),e[15]=i.colors,e[16]=i.domain,e[17]=i.favicon,e[18]=i.fonts,e[19]=i.isDefault,e[20]=i.logo,e[21]=i.name,e[22]=i.overview,e[23]=h):h=e[23];let m;return e[24]!==f||e[25]!==h?(m=p.jsxs(p.Fragment,{children:[f,h]}),e[24]=f,e[25]=h,e[26]=m):m=e[26],m}function q2(n){const e=_.c(32),{part:t,latency:r}=n;let s;e[0]!==t.state?(s=ot(t.state),e[0]=t.state,e[1]=s):s=e[1];const o=s;let i,l,a,c;if(e[2]!==r||e[3]!==t.output||e[4]!==o){c=Symbol.for("react.early_return_sentinel");e:{const f=Un(t.output),h=Array.isArray(f?.items)?f.items:[],m=o==="loading",g=o==="error";if(m){let k;e[9]===Symbol.for("react.memo_cache_sentinel")?(k=p.jsx(Z,{icon:p.jsx(dt,{className:"animate-pulse"}),title:"Loading brands",state:"loading"}),e[9]=k):k=e[9],c=k;break e}if(g){let k;e[10]===Symbol.for("react.memo_cache_sentinel")?(k=p.jsx(dt,{}),e[10]=k):k=e[10];let S;e[11]!==r?(S=r!=null&&r>0?p.jsx(Ie,{latency:r}):void 0,e[11]=r,e[12]=S):S=e[12];let v;e[13]!==S?(v=p.jsx(Z,{icon:k,title:"Couldn't load brands",state:"error",trailing:S}),e[13]=S,e[14]=v):v=e[14],c=v;break e}if(h.length===0){let k;e[15]===Symbol.for("react.memo_cache_sentinel")?(k=p.jsx(dt,{}),e[15]=k):k=e[15];let S;e[16]!==r?(S=r!=null&&r>0?p.jsx(Ie,{latency:r}):void 0,e[16]=r,e[17]=S):S=e[17];let v;e[18]!==S?(v=p.jsx(Z,{icon:k,title:"No brands yet",summary:"The organization hasn't set up any brand context.",state:"idle",trailing:S}),e[18]=S,e[19]=v):v=e[19],c=v;break e}let x;e[20]===Symbol.for("react.memo_cache_sentinel")?(x=p.jsx(dt,{className:"text-fuchsia-500"}),e[20]=x):x=e[20];const y=h.length===1?"1 brand":`${h.length} brands`;let b;e[21]!==r?(b=r!=null&&r>0?p.jsx(Ie,{latency:r}):void 0,e[21]=r,e[22]=b):b=e[22],e[23]!==y||e[24]!==b?(a=p.jsx(Z,{icon:x,title:y,state:"idle",trailing:b}),e[23]=y,e[24]=b,e[25]=a):a=e[25],i="mt-2 flex flex-col gap-1.5",l=h.map(K2)}e[2]=r,e[3]=t.output,e[4]=o,e[5]=i,e[6]=l,e[7]=a,e[8]=c}else i=e[5],l=e[6],a=e[7],c=e[8];if(c!==Symbol.for("react.early_return_sentinel"))return c;let u;e[26]!==i||e[27]!==l?(u=p.jsx("div",{className:i,children:l}),e[26]=i,e[27]=l,e[28]=u):u=e[28];let d;return e[29]!==a||e[30]!==u?(d=p.jsxs(p.Fragment,{children:[a,u]}),e[29]=a,e[30]=u,e[31]=d):d=e[31],d}function K2(n){const e=n.colors?Object.entries(n.colors).filter(X2):[];return p.jsxs("div",{className:"rounded-lg border border-border overflow-hidden",children:[n.colors&&p.jsx(Nh,{colors:n.colors}),p.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5",children:[(n.logo||n.favicon)&&p.jsx("img",{src:n.logo??n.favicon??void 0,alt:"",className:"size-8 shrink-0 rounded-md border border-border bg-background object-contain p-0.5",onError:G2}),p.jsxs("div",{className:"flex flex-col leading-tight min-w-0 flex-1",children:[p.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs font-medium text-foreground truncate",children:[n.name??"Untitled",n.isDefault&&p.jsx(xu,{className:"size-3 text-amber-500 shrink-0"})]}),n.domain&&p.jsx("span",{className:"text-[11px] text-muted-foreground truncate",children:n.domain})]}),e.length>0&&p.jsx("div",{className:"flex items-center gap-0.5 shrink-0",children:e.slice(0,5).map(J2)})]})]},n.id??`${n.name}-${n.domain}`)}function J2(n){const[e,t]=n;return p.jsx("span",{className:"size-3 rounded-full border border-border",style:{backgroundColor:t},title:`${ql[e]}: ${t}`,"aria-hidden":!0},e)}function G2(n){n.target.style.display="none"}function X2(n){const[,e]=n;return typeof e=="string"&&e.trim().length>0}function Ri(n){const e=_.c(4),{connection_id:t,iconSize:r}=n,s=r===void 0?"xs":r,o=Zc(t);if(!o)return null;let i;return e[0]!==o.icon||e[1]!==o.title||e[2]!==s?(i=p.jsx("div",{className:"shrink-0 bg-background ring-1 ring-background rounded-lg",children:p.jsx(qt,{icon:o.icon,name:o.title,size:s})}),e[0]=o.icon,e[1]=o.title,e[2]=s,e[3]=i):i=e[3],i}Ri.Fallback=function({iconSize:e="xs"}){const t=e==="sm"?"size-6":"size-5";return p.jsx("div",{className:"shrink-0 bg-background ring-1 ring-background rounded-lg",children:p.jsx("div",{className:ee(t,"rounded bg-muted animate-pulse")})})};function Tr(n){const e=_.c(18),{connectionIds:t,maxVisibleIcons:r,iconSize:s,className:o}=n,i=r===void 0?2:r,l=s===void 0?"xs":s;if(t.length===0)return null;let a,c,u;if(e[0]!==o||e[1]!==t||e[2]!==l||e[3]!==i){const h=t.slice(0,i);a=t.length-i,e[7]!==o?(c=ee("flex items-center justify-end -space-x-2",o),e[7]=o,e[8]=c):c=e[8];let m;e[9]!==l?(m=g=>p.jsx(E.Suspense,{fallback:p.jsx(Ri.Fallback,{iconSize:l}),children:p.jsx(Ri,{connection_id:g,iconSize:l})},g),e[9]=l,e[10]=m):m=e[10],u=h.map(m),e[0]=o,e[1]=t,e[2]=l,e[3]=i,e[4]=a,e[5]=c,e[6]=u}else a=e[4],c=e[5],u=e[6];let d;e[11]!==l||e[12]!==a?(d=a>0&&p.jsx("div",{className:ee("shrink-0 bg-background ring-1 ring-background border border-border rounded-lg flex items-center justify-center",l==="sm"?"size-8":"size-6"),children:p.jsxs("span",{className:ee(l==="sm"?"text-sm":"text-xs","font-medium text-muted-foreground"),"aria-label":`and ${a} more`,children:["+",a]})}),e[11]=l,e[12]=a,e[13]=d):d=e[13];let f;return e[14]!==c||e[15]!==u||e[16]!==d?(f=p.jsxs("div",{className:c,children:[u,d]}),e[14]=c,e[15]=u,e[16]=d,e[17]=f):f=e[17],f}Tr.Fallback=function({maxVisibleIcons:e=2,totalCount:t,iconSize:r="xs"}){const s=r==="sm"?"size-6":"size-5",o=r==="sm"?"size-8":"size-6",i=t!==void 0&&t>e;return p.jsxs("div",{className:"flex items-center -space-x-2",children:[Array.from({length:e}).map((l,a)=>p.jsx("div",{className:"shrink-0 bg-background ring-1 ring-background rounded-lg",children:p.jsx("div",{className:ee(s,"rounded bg-muted animate-pulse")})},a)),i&&p.jsx("div",{className:ee("shrink-0 bg-background ring-1 ring-background border border-border rounded-lg flex items-center justify-center",o),children:p.jsx("div",{className:ee(r==="sm"?"h-3.5 w-5":"h-3 w-4","rounded bg-muted animate-pulse")})})]})};const Y2="This document certifies that the bearer agent has been granted authorized access to the tools and capabilities described herein. The agent is permitted to operate within the scope defined by its instructions and shall act in accordance with the constraints set forth by the issuing organization. This credential remains valid for the duration of the agent's active status. Unauthorized modification of this agent's permissions or scope is prohibited. The issuing authority reserves the right to revoke access at any time. All actions performed by this agent are subject to audit and review by the organization administrator. ",Vc=typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia("(prefers-reduced-motion: reduce)"):null;function Q2(n){const e=_.c(64),{part:t,latency:r}=n,s=ku(),o=ot(t.state),i=E.useRef(null),l=E.useRef(null),a=E.useRef(null),c=E.useRef(null),u=E.useRef(null);let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{Vc?.matches||(u.current=i.current?.getBoundingClientRect()??null,i.current&&(i.current.style.willChange="transform"))},e[0]=d):d=e[0];const f=d;let h;e[1]===Symbol.for("react.memo_cache_sentinel")?(h=W=>{if(Vc?.matches)return;const te=u.current,he=i.current;if(!te||!he)return;const ge=(W.clientX-te.left)/te.width*100,Be=(W.clientY-te.top)/te.height*100;he.style.transform=`perspective(800px) rotateY(${(ge-50)*.05}deg) rotateX(${(Be-50)*-.05}deg)`,l.current&&(l.current.style.opacity="1",l.current.style.transform=`translate(${(ge-50)*.15}px, ${(Be-50)*.15}px)`),a.current&&(a.current.style.opacity="0.45"),c.current&&(c.current.style.opacity="0.45")},e[1]=h):h=e[1];const m=h;let g;e[2]===Symbol.for("react.memo_cache_sentinel")?(g=()=>{const W=i.current;W&&(W.style.transform="none",W.style.willChange="auto"),l.current&&(l.current.style.opacity="0.4",l.current.style.transform="translate(0, 0)"),a.current&&(a.current.style.opacity="0.3"),c.current&&(c.current.style.opacity="0.3"),u.current=null},e[2]=g):g=e[2];const x=g;if(o==="loading"){let W;return e[3]===Symbol.for("react.memo_cache_sentinel")?(W=p.jsx(Z,{icon:p.jsx(ut,{className:"animate-pulse"}),title:"Creating agent",state:"loading",defaultOpen:!0}),e[3]=W):W=e[3],W}if(o==="approval"){let W;return e[4]===Symbol.for("react.memo_cache_sentinel")?(W=p.jsx(Z,{icon:p.jsx(ut,{}),title:"Create agent",state:"idle"}),e[4]=W):W=e[4],W}if(o==="error"){let W;e[5]===Symbol.for("react.memo_cache_sentinel")?(W=p.jsx(ut,{}),e[5]=W):W=e[5];const te=t.state==="output-denied"?"Agent creation cancelled":"Couldn't create agent";let he;e[6]!==r?(he=p.jsx(Ie,{latency:r}),e[6]=r,e[7]=he):he=e[7];let ge;return e[8]!==te||e[9]!==he?(ge=p.jsx(Z,{icon:W,title:te,state:"error",trailing:he}),e[8]=te,e[9]=he,e[10]=ge):ge=e[10],ge}let y,b,k;if(e[11]!==r||e[12]!==t.output){k=Symbol.for("react.early_return_sentinel");e:{if(y=Un(t.output)?.item,!y?.id||!y?.title){let W;e[16]===Symbol.for("react.memo_cache_sentinel")?(W=p.jsx(ut,{}),e[16]=W):W=e[16];let te;e[17]!==r?(te=p.jsx(Z,{icon:W,title:"Agent created",state:"idle",trailing:p.jsx(Ie,{latency:r})}),e[17]=r,e[18]=te):te=e[18],k=te;break e}b=(y.connections??[]).map(Z2)}e[11]=r,e[12]=t.output,e[13]=y,e[14]=b,e[15]=k}else y=e[13],b=e[14],k=e[15];if(k!==Symbol.for("react.early_return_sentinel"))return k;const S=b;let v;e[19]===Symbol.for("react.memo_cache_sentinel")?(v=p.jsx(ut,{className:"text-success"}),e[19]=v):v=e[19];const w=`Agent created: ${y.title}`;let C;e[20]!==r?(C=p.jsx(Ie,{latency:r}),e[20]=r,e[21]=C):C=e[21];let T;e[22]!==w||e[23]!==C?(T=p.jsx(Z,{icon:v,title:w,state:"idle",trailing:C}),e[22]=w,e[23]=C,e[24]=T):T=e[24];let N;e[25]===Symbol.for("react.memo_cache_sentinel")?(N={transition:"transform 0.3s ease-out"},e[25]=N):N=e[25];let M;e[26]===Symbol.for("react.memo_cache_sentinel")?(M=p.jsx("div",{ref:l,className:"pointer-events-none absolute inset-[-20%] z-[1] select-none rounded-lg",style:{background:"linear-gradient(135deg, hsla(280, 60%, 80%, 0.35) 0%, transparent 35%), linear-gradient(315deg, hsla(190, 70%, 80%, 0.35) 0%, transparent 35%), linear-gradient(225deg, hsla(140, 55%, 80%, 0.3) 0%, transparent 30%), linear-gradient(45deg, hsla(320, 55%, 82%, 0.3) 0%, transparent 30%)",opacity:.4,transition:"opacity 0.3s ease, transform 0.3s ease-out"},"aria-hidden":"true"}),e[26]=M):M=e[26];let j;e[27]===Symbol.for("react.memo_cache_sentinel")?(j={textAlign:"justify",wordBreak:"break-all"},e[27]=j):j=e[27];let R,A;e[28]===Symbol.for("react.memo_cache_sentinel")?(R=p.jsx("p",{className:"pointer-events-none absolute inset-0 z-[1] select-none overflow-hidden text-[6px] font-light leading-[1.5] tracking-[0.06px] text-background opacity-50 mix-blend-overlay",style:j,"aria-hidden":"true",children:Y2.repeat(6)}),A=p.jsx("img",{src:"/stamp.svg",alt:"",className:"pointer-events-none absolute -right-10 -top-10 size-[140px] opacity-50 select-none","aria-hidden":"true"}),e[28]=R,e[29]=A):(R=e[28],A=e[29]);let D;e[30]===Symbol.for("react.memo_cache_sentinel")?(D=p.jsx("img",{ref:a,src:"/left-guilloche.png",alt:"",className:"pointer-events-none absolute inset-y-0 left-0 h-full w-auto select-none z-[1] mix-blend-overlay",style:{opacity:.3,transition:"opacity 0.3s ease"},"aria-hidden":"true"}),e[30]=D):D=e[30];let I;e[31]===Symbol.for("react.memo_cache_sentinel")?(I=p.jsx("img",{ref:c,src:"/right-guilloche.png",alt:"",className:"pointer-events-none absolute inset-y-0 right-0 h-full w-auto select-none z-[1] mix-blend-overlay",style:{opacity:.3,transition:"opacity 0.3s ease"},"aria-hidden":"true"}),e[31]=I):I=e[31];let $;e[32]!==y.icon||e[33]!==y.title?($=p.jsx(uu,{icon:y.icon,name:y.title,size:"md"}),e[32]=y.icon,e[33]=y.title,e[34]=$):$=e[34];let L;e[35]!==y.title?(L=p.jsx("div",{className:"flex-1 min-w-0",children:p.jsx("h3",{className:"text-sm font-medium text-foreground truncate",children:y.title})}),e[35]=y.title,e[36]=L):L=e[36];let z;e[37]!==$||e[38]!==L?(z=p.jsxs("div",{className:"flex items-center gap-2.5 p-2",children:[$,L]}),e[37]=$,e[38]=L,e[39]=z):z=e[39];let F;e[40]!==y.description?(F=y.description&&p.jsx("div",{className:"px-2 pt-1 pr-16",children:p.jsx("p",{className:"text-sm leading-snug text-muted-foreground line-clamp-2",children:y.description})}),e[40]=y.description,e[41]=F):F=e[41];let U;e[42]!==z||e[43]!==F?(U=p.jsxs("div",{className:"relative",children:[z,F]}),e[42]=z,e[43]=F,e[44]=U):U=e[44];let Y;e[45]!==S?(Y=S.length>0&&p.jsx(E.Suspense,{fallback:p.jsx(Tr.Fallback,{iconSize:"xs",maxVisibleIcons:3,totalCount:S.length}),children:p.jsx(Tr,{connectionIds:S,iconSize:"xs",maxVisibleIcons:3,className:"flex items-center justify-start -space-x-1"})}),e[45]=S,e[46]=Y):Y=e[46];let K;e[47]!==Y?(K=p.jsx("div",{className:"flex-1 min-w-0",children:Y}),e[47]=Y,e[48]=K):K=e[48];let Q;e[49]!==y.id||e[50]!==s?(Q=()=>s(y.id),e[49]=y.id,e[50]=s,e[51]=Q):Q=e[51];const ne=`See agent: ${y.title}`;let re;e[52]!==Q||e[53]!==ne?(re=p.jsx("div",{className:"flex items-center gap-2 shrink-0",children:p.jsx(un,{size:"sm",className:"h-7",onClick:Q,"aria-label":ne,children:"See agent"})}),e[52]=Q,e[53]=ne,e[54]=re):re=e[54];let se;e[55]!==K||e[56]!==re?(se=p.jsxs("div",{className:"relative z-[3] flex items-center gap-2.5 px-2 pt-6 pb-1",children:[K,re]}),e[55]=K,e[56]=re,e[57]=se):se=e[57];let ae;e[58]!==U||e[59]!==se?(ae=p.jsx("div",{className:"mt-2 overflow-hidden rounded-xl border-[0.5px] border-border bg-card p-2.5",children:p.jsxs("div",{ref:i,className:"relative overflow-hidden rounded-lg bg-accent/25 p-2",style:N,onMouseEnter:f,onMouseMove:m,onMouseLeave:x,children:[M,R,A,D,I,U,se]})}),e[58]=U,e[59]=se,e[60]=ae):ae=e[60];let Te;return e[61]!==ae||e[62]!==T?(Te=p.jsxs(p.Fragment,{children:[T,ae]}),e[61]=ae,e[62]=T,e[63]=Te):Te=e[63],Te}function Z2(n){return n.connection_id}function ev(n){const e=_.c(24),{agent:t}=n,r=ku();if(!t.id)return null;let s;e[0]!==t.connections?(s=t.connections??[],e[0]=t.connections,e[1]=s):s=e[1];let o;e[2]!==s?(o=s.map(tv),e[2]=s,e[3]=o):o=e[3];const i=o;let l;e[4]!==t.id||e[5]!==r?(l=()=>r(t.id),e[4]=t.id,e[5]=r,e[6]=l):l=e[6];let a;e[7]!==t.icon||e[8]!==t.title?(a=p.jsx(uu,{icon:t.icon,name:t.title,size:"sm"}),e[7]=t.icon,e[8]=t.title,e[9]=a):a=e[9];let c;e[10]!==t.title?(c=p.jsx("span",{className:"truncate text-sm font-medium text-foreground",children:t.title}),e[10]=t.title,e[11]=c):c=e[11];let u;e[12]!==t.description?(u=t.description&&p.jsx("span",{className:"truncate text-xs text-muted-foreground",children:t.description}),e[12]=t.description,e[13]=u):u=e[13];let d;e[14]!==c||e[15]!==u?(d=p.jsxs("div",{className:"flex min-w-0 flex-1 flex-col leading-tight",children:[c,u]}),e[14]=c,e[15]=u,e[16]=d):d=e[16];let f;e[17]!==i?(f=i.length>0&&p.jsx(E.Suspense,{fallback:p.jsx(Tr.Fallback,{iconSize:"xs",maxVisibleIcons:3,totalCount:i.length}),children:p.jsx(Tr,{connectionIds:i,iconSize:"xs",maxVisibleIcons:3})}),e[17]=i,e[18]=f):f=e[18];let h;return e[19]!==l||e[20]!==a||e[21]!==d||e[22]!==f?(h=p.jsxs("button",{type:"button",onClick:l,className:"group flex w-full items-center gap-3 rounded-lg border border-border bg-card px-3 py-2.5 text-left transition-colors hover:bg-muted cursor-pointer",children:[a,d,f]}),e[19]=l,e[20]=a,e[21]=d,e[22]=f,e[23]=h):h=e[23],h}function tv(n){return n.connection_id}function nv(n){const e=_.c(41),{part:t,latency:r}=n,s=Vn(),{org:o}=Ct();let i;e[0]!==t.state?(i=ot(t.state),e[0]=t.state,e[1]=i):i=e[1];const l=i;let a,c,u,d,f,h;if(e[2]!==r||e[3]!==t.output||e[4]!==t.state||e[5]!==l){h=Symbol.for("react.early_return_sentinel");e:{const y=Un(t.output);if(c=Array.isArray(y?.items)?y.items:[],l==="loading"){let w;e[12]===Symbol.for("react.memo_cache_sentinel")?(w=p.jsx(Z,{icon:p.jsx(ut,{className:"animate-pulse"}),title:"Loading agents",state:"loading"}),e[12]=w):w=e[12],h=w;break e}if(l==="approval"){let w;e[13]===Symbol.for("react.memo_cache_sentinel")?(w=p.jsx(Z,{icon:p.jsx(ut,{}),title:"List agents",state:"idle"}),e[13]=w):w=e[13],h=w;break e}if(l==="error"){let w;e[14]===Symbol.for("react.memo_cache_sentinel")?(w=p.jsx(ut,{}),e[14]=w):w=e[14];const C=t.state==="output-denied"?"Agent list unavailable":"Couldn't load agents";let T;e[15]!==r?(T=p.jsx(Ie,{latency:r}),e[15]=r,e[16]=T):T=e[16];let N;e[17]!==C||e[18]!==T?(N=p.jsx(Z,{icon:w,title:C,state:"error",trailing:T}),e[17]=C,e[18]=T,e[19]=N):N=e[19],h=N;break e}if(c.length===0){let w;e[20]===Symbol.for("react.memo_cache_sentinel")?(w=p.jsx(ut,{}),e[20]=w):w=e[20];let C;e[21]!==r?(C=p.jsx(Z,{icon:w,title:"No agents yet",summary:"This organization hasn't created any agents.",state:"idle",trailing:p.jsx(Ie,{latency:r})}),e[21]=r,e[22]=C):C=e[22],h=C;break e}const b=c.slice(0,gh);a=c.length-b.length;let k;e[23]===Symbol.for("react.memo_cache_sentinel")?(k=p.jsx(ut,{className:"text-success"}),e[23]=k):k=e[23];const S=c.length===1?"1 agent":`${c.length} agents`;let v;e[24]!==r?(v=p.jsx(Ie,{latency:r}),e[24]=r,e[25]=v):v=e[25],e[26]!==S||e[27]!==v?(f=p.jsx(Z,{icon:k,title:S,state:"idle",trailing:v}),e[26]=S,e[27]=v,e[28]=f):f=e[28],u="mt-2 flex flex-col gap-1.5",d=b.map(rv)}e[2]=r,e[3]=t.output,e[4]=t.state,e[5]=l,e[6]=a,e[7]=c,e[8]=u,e[9]=d,e[10]=f,e[11]=h}else a=e[6],c=e[7],u=e[8],d=e[9],f=e[10],h=e[11];if(h!==Symbol.for("react.early_return_sentinel"))return h;let m;e[29]!==a||e[30]!==c||e[31]!==s||e[32]!==o?(m=a>0&&p.jsx(xh,{count:c.length,noun:"agents",onClick:()=>s({to:"/$org/settings/agents",params:{org:o.slug}})}),e[29]=a,e[30]=c,e[31]=s,e[32]=o,e[33]=m):m=e[33];let g;e[34]!==u||e[35]!==d||e[36]!==m?(g=p.jsxs("div",{className:u,children:[d,m]}),e[34]=u,e[35]=d,e[36]=m,e[37]=g):g=e[37];let x;return e[38]!==f||e[39]!==g?(x=p.jsxs(p.Fragment,{children:[f,g]}),e[38]=f,e[39]=g,e[40]=x):x=e[40],x}function rv(n){return p.jsx(ev,{agent:n},n.id)}const sv={active:"bg-success",inactive:"bg-muted-foreground",error:"bg-destructive"};function ov(n){const e=_.c(27),{connection:t}=n,r=Vn(),{org:s}=Ct(),o=t.slug,i=t.description||t.app_name,l=!o||void 0;let a;e[0]!==r||e[1]!==s||e[2]!==o?(a=()=>o&&r({to:"/$org/settings/connections/$appSlug",params:{org:s.slug,appSlug:o}}),e[0]=r,e[1]=s,e[2]=o,e[3]=a):a=e[3];let c;e[4]!==t.icon||e[5]!==t.title?(c=p.jsx(qt,{icon:t.icon,name:t.title,size:"sm"}),e[4]=t.icon,e[5]=t.title,e[6]=c):c=e[6];let u;e[7]!==t.title?(u=p.jsx("span",{className:"truncate text-sm font-medium text-foreground",children:t.title}),e[7]=t.title,e[8]=u):u=e[8];let d;e[9]!==i?(d=i&&p.jsx("span",{className:"truncate text-xs text-muted-foreground",children:i}),e[9]=i,e[10]=d):d=e[10];let f;e[11]!==u||e[12]!==d?(f=p.jsxs("div",{className:"flex min-w-0 flex-1 flex-col leading-tight",children:[u,d]}),e[11]=u,e[12]=d,e[13]=f):f=e[13];const h=sv[t.status]??"bg-muted-foreground";let m;e[14]!==h?(m=ee("size-2 shrink-0 rounded-full",h),e[14]=h,e[15]=m):m=e[15];let g;e[16]!==m?(g=p.jsx("span",{className:m,"aria-hidden":"true"}),e[16]=m,e[17]=g):g=e[17];let x;e[18]!==t.status?(x=p.jsx("span",{className:"sr-only",children:t.status}),e[18]=t.status,e[19]=x):x=e[19];let y;return e[20]!==l||e[21]!==x||e[22]!==a||e[23]!==c||e[24]!==f||e[25]!==g?(y=p.jsxs("button",{type:"button","aria-disabled":l,onClick:a,className:"group flex w-full items-center gap-3 rounded-lg border border-border bg-card px-3 py-2.5 text-left transition-colors hover:bg-muted cursor-pointer aria-disabled:cursor-default aria-disabled:hover:bg-card",children:[c,f,g,x]}),e[20]=l,e[21]=x,e[22]=a,e[23]=c,e[24]=f,e[25]=g,e[26]=y):y=e[26],y}function iv(n){const e=_.c(40),{part:t,latency:r}=n,s=Vn(),{org:o}=Ct();let i;e[0]!==t.state?(i=ot(t.state),e[0]=t.state,e[1]=i):i=e[1];const l=i;let a,c,u,d,f,h;if(e[2]!==r||e[3]!==t.output||e[4]!==t.state||e[5]!==l){h=Symbol.for("react.early_return_sentinel");e:{const y=Un(t.output);if(c=(Array.isArray(y?.items)?y.items:[]).filter(av),l==="loading"||l==="approval"){let w;e[12]===Symbol.for("react.memo_cache_sentinel")?(w=p.jsx(Z,{icon:p.jsx(Or,{className:"animate-pulse"}),title:"Loading connections",state:"loading"}),e[12]=w):w=e[12],h=w;break e}if(l==="error"){let w;e[13]===Symbol.for("react.memo_cache_sentinel")?(w=p.jsx(Or,{}),e[13]=w):w=e[13];const C=t.state==="output-denied"?"Connection list unavailable":"Couldn't load connections";let T;e[14]!==r?(T=p.jsx(Ie,{latency:r}),e[14]=r,e[15]=T):T=e[15];let N;e[16]!==C||e[17]!==T?(N=p.jsx(Z,{icon:w,title:C,state:"error",trailing:T}),e[16]=C,e[17]=T,e[18]=N):N=e[18],h=N;break e}if(c.length===0){let w;e[19]===Symbol.for("react.memo_cache_sentinel")?(w=p.jsx(Or,{}),e[19]=w):w=e[19];let C;e[20]!==r?(C=p.jsx(Z,{icon:w,title:"No connections yet",summary:"This organization hasn't connected any MCPs.",state:"idle",trailing:p.jsx(Ie,{latency:r})}),e[20]=r,e[21]=C):C=e[21],h=C;break e}const b=c.slice(0,gh);a=c.length-b.length;let k;e[22]===Symbol.for("react.memo_cache_sentinel")?(k=p.jsx(Or,{className:"text-success"}),e[22]=k):k=e[22];const S=c.length===1?"1 connection":`${c.length} connections`;let v;e[23]!==r?(v=p.jsx(Ie,{latency:r}),e[23]=r,e[24]=v):v=e[24],e[25]!==S||e[26]!==v?(f=p.jsx(Z,{icon:k,title:S,state:"idle",trailing:v}),e[25]=S,e[26]=v,e[27]=f):f=e[27],u="mt-2 flex flex-col gap-1.5",d=b.map(lv)}e[2]=r,e[3]=t.output,e[4]=t.state,e[5]=l,e[6]=a,e[7]=c,e[8]=u,e[9]=d,e[10]=f,e[11]=h}else a=e[6],c=e[7],u=e[8],d=e[9],f=e[10],h=e[11];if(h!==Symbol.for("react.early_return_sentinel"))return h;let m;e[28]!==a||e[29]!==c||e[30]!==s||e[31]!==o?(m=a>0&&p.jsx(xh,{count:c.length,noun:"connections",onClick:()=>s({to:"/$org/settings/connections",params:{org:o.slug}})}),e[28]=a,e[29]=c,e[30]=s,e[31]=o,e[32]=m):m=e[32];let g;e[33]!==u||e[34]!==d||e[35]!==m?(g=p.jsxs("div",{className:u,children:[d,m]}),e[33]=u,e[34]=d,e[35]=m,e[36]=g):g=e[36];let x;return e[37]!==f||e[38]!==g?(x=p.jsxs(p.Fragment,{children:[f,g]}),e[37]=f,e[38]=g,e[39]=x):x=e[39],x}function lv(n){return p.jsx(ov,{connection:n},n.id)}function av(n){return n.connection_type!=="VIRTUAL"}function cv(){const n=_.c(37),e=Gi(),{sendMessage:t,isStreaming:r,messages:s}=Lp(),{org:o}=Ct(),i=e?.virtualMcpId,{prompts:l}=Zp(o.slug),a=i??null;let c;n[0]!==o.id||n[1]!==o.slug||n[2]!==a?(c={connectionId:a,orgId:o.id,orgSlug:o.slug},n[0]=o.id,n[1]=o.slug,n[2]=a,n[3]=c):c=n[3];const u=Fi(c),[d,f]=E.useState(null);if(!i||r||!cp(i)||!s.some(uv))return null;let m;if(n[4]!==l||n[5]!==i){let A;n[7]!==i?(A=D=>D.agentId===i&&D.promptName,n[7]=i,n[8]=A):A=n[8],m=l.find(A),n[4]=l,n[5]=i,n[6]=m}else m=n[6];const g=m;if(!g)return null;let x;n[9]!==u||n[10]!==t?(x=async(A,D)=>{if(!u){Xo.error("MCP client not available");return}try{const I=await nm(u,A.name,D);await t({type:"doc",content:[{type:"paragraph",content:[Ff({id:A.name,name:Qi(A.name,Yi(A._meta)),metadata:I.messages,char:"/",kind:"prompt",args:D}),{type:"text",text:" "}]}]})}catch(I){console.error("[next-action-chip] failed",I),Xo.error("Failed to load prompt. Please try again.")}},n[9]=u,n[10]=t,n[11]=x):x=n[11];const y=x;let b;n[12]!==g._meta||n[13]!==g.arguments||n[14]!==g.description||n[15]!==g.promptName||n[16]!==g.title||n[17]!==y?(b=()=>{const A={name:g.promptName,title:g.title,description:g.description,arguments:g.arguments,_meta:g._meta};if(A.arguments&&A.arguments.length>0){f(A);return}y(A)},n[12]=g._meta,n[13]=g.arguments,n[14]=g.description,n[15]=g.promptName,n[16]=g.title,n[17]=y,n[18]=b):b=n[18];const k=b;let S,v;n[19]===Symbol.for("react.memo_cache_sentinel")?(S=p.jsx(tm,{size:12,className:"shrink-0 text-purple-500"}),v=p.jsx("span",{className:"font-medium text-foreground/80",children:"Next:"}),n[19]=S,n[20]=v):(S=n[19],v=n[20]);let w;n[21]!==g.title?(w=p.jsx("span",{className:"truncate",children:g.title}),n[21]=g.title,n[22]=w):w=n[22];let C;n[23]===Symbol.for("react.memo_cache_sentinel")?(C=p.jsx(du,{size:12,className:"shrink-0 transition-transform duration-150 group-hover:translate-x-0.5"}),n[23]=C):C=n[23];let T;n[24]!==k||n[25]!==w?(T=p.jsxs("button",{type:"button",onClick:k,className:"group mt-3 flex items-center gap-2 self-start rounded-full border border-border bg-background px-3 py-1.5 text-xs text-muted-foreground transition-colors hover:border-border hover:bg-accent/40 hover:text-foreground",children:[S,v,w,C]}),n[24]=k,n[25]=w,n[26]=T):T=n[26];let N;n[27]===Symbol.for("react.memo_cache_sentinel")?(N=A=>f(A),n[27]=N):N=n[27];let M;n[28]!==d||n[29]!==y?(M=async A=>{const D=d;f(null),D&&await y(D,A)},n[28]=d,n[29]=y,n[30]=M):M=n[30];let j;n[31]!==d||n[32]!==M?(j=p.jsx(Nm,{prompt:d,setPrompt:N,onSubmit:M}),n[31]=d,n[32]=M,n[33]=j):j=n[33];let R;return n[34]!==j||n[35]!==T?(R=p.jsxs(p.Fragment,{children:[T,j]}),n[34]=j,n[35]=T,n[36]=R):R=n[36],R}function uv(n){return n.role==="user"||n.parts.some(dv)}function dv(n){return n.type==="tool-user_ask"&&n.state==="output-available"}function fv(n){const e=new Map;for(let t=n.length-1;t>=0;t--){const r=n[t]?.parts;if(r)for(const s of r){const o=s;if(o.type!=="data-deck-updated")continue;const i=o.data;if(!i?.path)continue;const l=`deck:${i.path}`;e.has(l)||e.set(l,{tabId:Hp(i.path),label:i.name||i.path,kind:i.kind==="page"?"page":"deck"})}}return Array.from(e.values())}function hv(){const n=_.c(9),e=Vn(),t=Wn()?.messages??[],r=fv(t);if(r.length===0)return null;const s=r.some(mv),o=r.some(pv),i=s?o?"Slides & pages in this chat":"Slides in this chat":"Pages in this chat",l="flex flex-col gap-1.5 py-2";let a;n[0]!==i?(a=p.jsx("div",{className:"text-[12px] text-muted-foreground/70 uppercase tracking-wide",children:i}),n[0]=i,n[1]=a):a=n[1];const c="flex flex-wrap gap-2";let u;n[2]!==e?(u=m=>p.jsxs("button",{type:"button",onClick:()=>e({to:".",search:g=>({...g,main:m.tabId}),replace:!0}),className:"inline-flex items-center gap-2 px-3 py-1.5 rounded-lg border border-border bg-muted/30 hover:bg-muted/60 text-[13px] transition-colors",children:[m.kind==="deck"?p.jsx(nr,{className:"size-3.5 shrink-0 text-muted-foreground"}):p.jsx(qp,{className:"size-3.5 shrink-0 text-muted-foreground"}),p.jsx("span",{className:"font-medium text-foreground",children:m.label})]},m.tabId),n[2]=e,n[3]=u):u=n[3];const d=r.map(u);let f;n[4]!==d?(f=p.jsx("div",{className:c,children:d}),n[4]=d,n[5]=f):f=n[5];let h;return n[6]!==a||n[7]!==f?(h=p.jsxs("div",{className:l,children:[a,f]}),n[6]=a,n[7]=f,n[8]=h):h=n[8],h}function pv(n){return n.kind==="page"}function mv(n){return n.kind==="deck"}async function gv(n,e){const t=await fetch(`/api/${e}/threads/${encodeURIComponent(n)}/outputs`,{credentials:"include"});if(!t.ok)throw new Error(`Failed to fetch thread outputs: ${t.status}`);return(await t.json()).objects??[]}function rT(){const n=_.c(2),e=Wn()?.messages??[];let t;return n[0]!==e?(t=e.some(xv),n[0]=e,n[1]=t):t=n[1],t}function xv(n){return n.parts?.some(yv)}function yv(n){const e=n;return(e.type==="tool-share_with_user"||e.type==="tool-bash"||e.type==="tool-write")&&e.state==="output-available"}function bv(n,e){const t=_.c(9),{org:r}=Ct();let s;t[0]!==n?(s=Qe.threadOutputs(n??""),t[0]=n,t[1]=s):s=t[1];let o;t[2]!==r||t[3]!==n?(o=()=>gv(n??"",r.slug),t[2]=r,t[3]=n,t[4]=o):o=t[4];const i=!!n&&(e?.enabled??!0);let l;return t[5]!==s||t[6]!==o||t[7]!==i?(l={queryKey:s,queryFn:o,enabled:i,staleTime:0},t[5]=s,t[6]=o,t[7]=i,t[8]=l):l=t[8],Mr(l)}function kv(n){const e=_.c(20),{file:t}=n,r=Vn();let s;e[0]!==t.key||e[1]!==r?(s=()=>r({to:".",search:h=>({...h,main:Vp(t.key)}),replace:!0}),e[0]=t.key,e[1]=r,e[2]=s):s=e[2];const o=s;let i;e[3]!==t.filename?(i=p.jsx(jp,{filename:t.filename,className:"h-5 w-4 shrink-0"}),e[3]=t.filename,e[4]=i):i=e[4];let l;e[5]!==t.filename||e[6]!==o?(l=p.jsx("button",{type:"button",onClick:o,className:"min-w-0 flex-1 truncate text-left text-[13px] font-medium text-foreground hover:underline",title:t.filename,children:t.filename}),e[5]=t.filename,e[6]=o,e[7]=l):l=e[7];const a=`Download ${t.filename}`;let c;e[8]===Symbol.for("react.memo_cache_sentinel")?(c=p.jsx(yu,{className:"size-3.5"}),e[8]=c):c=e[8];let u;e[9]!==t.downloadUrl||e[10]!==t.filename||e[11]!==a?(u=p.jsx("a",{href:t.downloadUrl,download:t.filename,className:"hidden shrink-0 text-muted-foreground hover:text-foreground group-hover:block",title:"Download","aria-label":a,children:c}),e[9]=t.downloadUrl,e[10]=t.filename,e[11]=a,e[12]=u):u=e[12];let d;e[13]!==o?(d=p.jsx(un,{variant:"outline",size:"sm",className:"h-7 shrink-0 px-2.5 text-xs",onClick:o,children:"Open"}),e[13]=o,e[14]=d):d=e[14];let f;return e[15]!==i||e[16]!==l||e[17]!==u||e[18]!==d?(f=p.jsxs("div",{className:"group flex items-center gap-2 rounded-lg border border-border bg-background px-3 py-2",children:[i,l,u,d]}),e[15]=i,e[16]=l,e[17]=u,e[18]=d,e[19]=f):f=e[19],f}function Wc(n){return n.split("/").pop()??n}const Sv=/(^|\/)output\//;function vv(n){const e=new Set;for(const t of n.parts??[]){const r=t;if(r.state==="output-available"){if(r.type==="tool-share_with_user"){const s=r.output?.filename??r.input?.name??(r.input?.source?Wc(r.input.source):null);s&&e.add(s)}else if(r.type==="tool-write"){const s=r.input?.path;s&&Sv.test(s)&&e.add(Wc(s))}}}return e}function wv(n){const e=_.c(4),{threadId:t,message:r}=n,s=vv(r),o=s.size>0;let i;e[0]!==o?(i={enabled:o},e[0]=o,e[1]=i):i=e[1];const{data:l}=bv(t,i);if(s.size===0)return null;const a=(l??[]).filter(f=>s.has(f.filename));if(a.length===0)return null;const c="flex flex-col gap-1.5 py-2",u=a.map(Cv);let d;return e[2]!==u?(d=p.jsx("div",{className:c,children:u}),e[2]=u,e[3]=d):d=e[3],d}function Cv(n){return p.jsx(kv,{file:n},n.key)}function Tv(n){return n.type==="reasoning"}function Nv(n){const e=[],t=new Set,r=new Map,s=new Map,o=new Map;if(n){let l=null;for(let a=0;a<n.parts.length;a++){const c=n.parts[a];if(Tv(c)){l||(l={parts:[],startIndex:a},e.push(l)),l.parts.push(c),t.add(a);continue}if(l=null,c.type==="data-tool-metadata"&&"id"in c&&"data"in c){const u=c.data,d={};u.annotations&&(d.annotations=u.annotations),typeof u.latencyMs=="number"&&Number.isFinite(u.latencyMs)&&(d.latencySeconds=u.latencyMs/1e3),typeof u.outputBytes=="number"&&Number.isFinite(u.outputBytes)&&u.outputBytes>=0&&(d.outputBytes=u.outputBytes),u._meta&&typeof u._meta=="object"&&(d._meta=u._meta),r.set(c.id,d);continue}if(c.type==="data-tool-subtask-metadata"&&"id"in c){s.set(c.id,c.data);continue}if(c.type==="data-web-search"&&"id"in c&&"data"in c){const u=c.id,d=c.data;o.set(u,d.text??"");continue}}}const i=[];if(n)for(let l=0;l<n.parts.length;l++){const a=n.parts[l];if(a.type!=="step-start"){if(t.has(l)){const c=e.find(u=>u.startIndex===l);c&&i.push({kind:"reasoning-group",group:c});continue}a.type.startsWith("data-")||i.push({kind:"part",index:l})}}return{reasoningGroups:e,renderOrder:i,dataParts:{toolMetadata:r,toolSubtaskMetadata:s,webSearchStreaming:o}}}function Di(n){const e=_.c(9),{since:t}=n;let r;e[0]!==t?(r=()=>oa(t,Date.now()),e[0]=t,e[1]=r):r=e[1];const[s,o]=E.useState(r);let i,l;e[2]!==t?(i=()=>{const d=setInterval(()=>o(oa(t,Date.now())),100);return()=>clearInterval(d)},l=[t],e[2]=t,e[3]=i,e[4]=l):(i=e[3],l=e[4]),E.useEffect(i,l);const a=s/1e3;let c;e[5]!==a?(c=Ht(a),e[5]=a,e[6]=c):c=e[6];let u;return e[7]!==c?(u=p.jsx("span",{className:"tabular-nums text-sm font-mono text-muted-foreground/50",children:c}),e[7]=c,e[8]=u):u=e[8],u}const Eh=[{delay:0},{delay:100},{delay:200},{delay:100},{delay:200},{delay:200},{delay:300},{delay:300},{delay:400}];function Mv(){const n=_.c(5),[e]=E.useState(Ev);let t;n[0]===Symbol.for("react.memo_cache_sentinel")?(t={gridTemplateColumns:"repeat(3, 3px)",gap:"1.5px",width:"fit-content"},n[0]=t):t=n[0];let r;n[1]!==e?(r=Eh.map((o,i)=>{const{delay:l}=o;return p.jsx("div",{className:"rounded-[1px]",style:{width:3,height:3,"--cell-color":e[i],animation:"grid-ripple 1s ease infinite",animationDelay:`${l}ms`}},i)}),n[1]=e,n[2]=r):r=n[2];let s;return n[3]!==r?(s=p.jsx("div",{className:"grid",style:t,children:r}),n[3]=r,n[4]=s):s=n[4],s}function Ev(){const n=`var(--chart-${Math.ceil(Math.random()*5)})`;return Eh.map(()=>Math.random()<.6?"color-mix(in srgb, var(--muted-foreground) 25%, transparent)":n)}const Av={planning:{icon:p.jsx(Ep,{className:"text-muted-foreground shrink-0 animate-pulse",size:14}),label:"Planning next moves",detail:"Deciding how to approach the request"},thinking:{icon:p.jsx(Js,{className:"text-muted-foreground shrink-0 animate-pulse",size:14}),label:"Thinking",detail:"Working through the next response"}},jv=1200;function Pi(n){const e=_.c(9),{icon:t,title:r,summary:s,detail:o,state:i,detailVariant:l,latency:a,trailing:c}=n,u=l===void 0?"prose":l;let d;return e[0]!==o||e[1]!==u||e[2]!==t||e[3]!==a||e[4]!==i||e[5]!==s||e[6]!==r||e[7]!==c?(d=p.jsx(Z,{icon:t,title:r,summary:s,detail:o,state:i,detailVariant:u,latency:a,trailing:c}),e[0]=o,e[1]=u,e[2]=t,e[3]=a,e[4]=i,e[5]=s,e[6]=r,e[7]=c,e[8]=d):d=e[8],d}function Iv(n){const e=_.c(17),{startedAt:t}=n,r=Wn()?.runStatusStage??null,[s,o]=E.useState("planning");let i,l;if(e[0]!==r?(i=()=>{if(r!==null)return;const f=setTimeout(()=>{o("thinking")},jv);return()=>{clearTimeout(f)}},l=[r],e[0]=r,e[1]=i,e[2]=l):(i=e[1],l=e[2]),E.useEffect(i,l),r!==null){const f=Bp[r];let h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h=p.jsx(Js,{className:"size-4"}),e[3]=h):h=e[3];const m=`${f.label}...`;let g;e[4]!==t?(g=t!==null&&p.jsx(Di,{since:t}),e[4]=t,e[5]=g):g=e[5];let x;return e[6]!==f.detail||e[7]!==m||e[8]!==g?(x=p.jsx(Pi,{icon:h,title:m,summary:f.detail,state:"loading",trailing:g}),e[6]=f.detail,e[7]=m,e[8]=g,e[9]=x):x=e[9],x}const a=Av[s],c=`${a.label}...`;let u;e[10]!==t?(u=t!==null&&p.jsx(Di,{since:t}),e[10]=t,e[11]=u):u=e[11];let d;return e[12]!==a.detail||e[13]!==a.icon||e[14]!==c||e[15]!==u?(d=p.jsx(Pi,{icon:a.icon,title:c,summary:a.detail,state:"loading",trailing:u}),e[12]=a.detail,e[13]=a.icon,e[14]=c,e[15]=u,e[16]=d):d=e[16],d}function Ov(n){const e=_.c(3),{startedAt:t}=n;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=p.jsx(Mv,{}),e[0]=r):r=e[0];let s;return e[1]!==t?(s=p.jsxs("div",{className:"flex items-center gap-2.5 mt-1 pb-1 text-muted-foreground/40 select-none",children:[r,p.jsx(Di,{since:t})]}),e[1]=t,e[2]=s):s=e[2],s}const Rv=2e4;function Dv(n){const e=_.c(8),{startedAt:t}=n;ou(1e3);const r=Wn(),o=(t!==null?Date.now()-t:0)>=Rv;let i;e[0]!==t?(i=p.jsx(Iv,{startedAt:t}),e[0]=t,e[1]=i):i=e[1];let l;e[2]!==o||e[3]!==r?(l=o&&r?.stop&&p.jsxs("div",{className:"flex items-center gap-2 pb-1 text-[13px] text-muted-foreground/60",children:[p.jsx("span",{children:"This is taking longer than usual."}),p.jsx("button",{type:"button",onClick:()=>r.stop(),className:"text-muted-foreground hover:text-foreground underline underline-offset-2",children:"Cancel"})]}),e[2]=o,e[3]=r,e[4]=l):l=e[4];let a;return e[5]!==i||e[6]!==l?(a=p.jsxs("div",{className:"flex flex-col gap-0.5",children:[i,l]}),e[5]=i,e[6]=l,e[7]=a):a=e[7],a}function Pv(n){const e=_.c(20),{duration:t,parts:r,isStreaming:s}=n;let o;e[0]!==r?(o=r.every($v),e[0]=r,e[1]=o):o=e[1];const i=o;let l;e[2]!==t?(l=t&&t/1e3>1?`Thought for ${Ht(t/1e3)}`:"Thought",e[2]=t,e[3]=l):l=e[3];const a=l;let c;if(e[4]!==i||e[5]!==s||e[6]!==r){const k=r.map(_v).join(`
185
+ `).trim().split(`
186
+ `).filter(Boolean),S=s?k[k.length-1]??"":k[0]??"";c=!i&&S?S.length>100?S.slice(0,100)+"…":S:void 0,e[4]=i,e[5]=s,e[6]=r,e[7]=c}else c=e[7];const u=c;let d;if(e[8]!==i||e[9]!==r){const b=r.map(Lv).join(`
187
+
188
+ `);d=!i&&b.trim()?b:null,e[8]=i,e[9]=r,e[10]=d}else d=e[10];const f=d,h=!s&&t!=null?t/1e3:void 0;let m;e[11]!==s?(m=s?p.jsx(Js,{className:"size-4"}):p.jsx(Mp,{className:"size-4"}),e[11]=s,e[12]=m):m=e[12];const g=s?"Thinking...":a,x=s?"loading":"idle";let y;return e[13]!==f||e[14]!==h||e[15]!==u||e[16]!==m||e[17]!==g||e[18]!==x?(y=p.jsx(Pi,{icon:m,title:g,summary:u,detail:f,state:x,detailVariant:"prose",latency:h}),e[13]=f,e[14]=h,e[15]=u,e[16]=m,e[17]=g,e[18]=x,e[19]=y):y=e[19],y}function Lv(n){return n.text??""}function _v(n){return n.text??""}function $v(n){return n.text?.includes("REDACTED")}const zv=3;function Bv(n,e){let t=-1;for(let r=n.length-1;r>=0;r--){const s=n[r];if(s.kind==="part"&&e[s.index]?.type==="text"){t=r;break}}return t===-1?{collapsed:[],tail:n}:{collapsed:n.slice(0,t),tail:n.slice(t)}}function Fv(n,e){let t=0,r=0;for(const s of n)if(s.kind==="reasoning-group")r++;else{const o=e[s.index]?.type;o==="text"?r++:(o==="dynamic-tool"||o?.startsWith("tool-"))&&o!=="tool-todo_write"&&o!=="tool-update_interests"&&t++}return{toolCalls:t,messages:r}}function Hv(n){const e=_.c(8),{toolCalls:t,messages:r}=n;let s;e[0]!==r||e[1]!==t?(s=t>0&&p.jsxs(p.Fragment,{children:[p.jsx(au,{className:"size-3.5 shrink-0"}),p.jsxs("span",{children:[t," tool call",t===1?"":"s",r>0?",":""]})]}),e[0]=r,e[1]=t,e[2]=s):s=e[2];let o;e[3]!==r?(o=r>0&&p.jsxs(p.Fragment,{children:[p.jsx(Ap,{className:"size-3.5 shrink-0"}),p.jsxs("span",{children:[r," message",r===1?"":"s"]})]}),e[3]=r,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=p.jsxs("span",{className:"flex items-center gap-1.5 text-muted-foreground",children:[s,o]}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Vv(n){const e=_.c(28),{items:t,message:r,reasoningGroups:s,isReasoningActive:o,totalDuration:i,dataParts:l,isLoading:a,isLast:c}=n;let u;e[0]!==t||e[1]!==r.parts?(u=Fv(t,r.parts),e[0]=t,e[1]=r.parts,e[2]=u):u=e[2];const{toolCalls:d,messages:f}=u;if(d===0&&f===0)return null;let h;e[3]!==f||e[4]!==d?(h=p.jsx(Hv,{toolCalls:d,messages:f}),e[3]=f,e[4]=d,e[5]=h):h=e[5];let m;if(e[6]!==l||e[7]!==c||e[8]!==a||e[9]!==o||e[10]!==t||e[11]!==r||e[12]!==s||e[13]!==i){let y;e[15]!==l||e[16]!==c||e[17]!==a||e[18]!==o||e[19]!==r||e[20]!==s||e[21]!==i?(y=(b,k)=>Ah({item:b,renderIndex:k,message:r,reasoningGroups:s,isReasoningActive:o,totalDuration:i,dataParts:l,isLoading:a,isLast:c,isLastVisiblePart:!1}),e[15]=l,e[16]=c,e[17]=a,e[18]=o,e[19]=r,e[20]=s,e[21]=i,e[22]=y):y=e[22],m=t.map(y),e[6]=l,e[7]=c,e[8]=a,e[9]=o,e[10]=t,e[11]=r,e[12]=s,e[13]=i,e[14]=m}else m=e[14];let g;e[23]!==m?(g=p.jsx("div",{className:"flex flex-col gap-3 sm:gap-2 pt-1",children:m}),e[23]=m,e[24]=g):g=e[24];let x;return e[25]!==h||e[26]!==g?(x=p.jsx(Z,{icon:null,alwaysChevron:!0,title:h,state:"idle",children:g}),e[25]=h,e[26]=g,e[27]=x):x=e[27],x}function Ah({item:n,renderIndex:e,message:t,reasoningGroups:r,isReasoningActive:s,totalDuration:o,dataParts:i,isLoading:l,isLast:a,isLastVisiblePart:c,renderOrder:u}){if(n.kind==="reasoning-group"){const{group:m}=n,g=m===r[r.length-1],x=s&&g;if(!m.parts.some(k=>k.text?.trim())&&!x)return null;const b=r.length===1?o:null;return p.jsx(Pv,{duration:b,parts:m.parts,isStreaming:x},`${t.id}-reasoning-${m.startIndex}`)}const d=t.parts[n.index],f=c||(u?u.findLastIndex(m=>m.kind==="part")===e:!1),h=f?wu(vu(),t.metadata?.usage):null;return p.jsx(Wv,{part:d,id:t.id,usageStats:f&&p.jsx(ES,{usage:h,duration:o}),dataParts:i,isLoading:l,isLastMessage:a},`${t.id}-${n.index}`)}function Wv(n){const e=_.c(121),{part:t,id:r,usageStats:s,dataParts:o,isLoading:i,isLastMessage:l}=n;let a;e[0]!==o.toolMetadata?(a=f=>o.toolMetadata.get(f),e[0]=o.toolMetadata,e[1]=a):a=e[1];const c=a;let u;e[2]!==o.toolSubtaskMetadata?(u=f=>o.toolSubtaskMetadata.get(f),e[2]=o.toolSubtaskMetadata,e[3]=u):u=e[3];const d=u;switch(t.type){case"dynamic-tool":{let f;e[4]!==c||e[5]!==t.toolCallId?(f=c(t.toolCallId)?.annotations,e[4]=c,e[5]=t.toolCallId,e[6]=f):f=e[6];let h;e[7]!==c||e[8]!==t.toolCallId?(h=c(t.toolCallId)?.latencySeconds,e[7]=c,e[8]=t.toolCallId,e[9]=h):h=e[9];let m;e[10]!==c||e[11]!==t.toolCallId?(m=c(t.toolCallId)?.outputBytes,e[10]=c,e[11]=t.toolCallId,e[12]=m):m=e[12];let g;e[13]!==c||e[14]!==t.toolCallId?(g=c(t.toolCallId)?._meta,e[13]=c,e[14]=t.toolCallId,e[15]=g):g=e[15];let x;return e[16]!==l||e[17]!==t||e[18]!==f||e[19]!==h||e[20]!==m||e[21]!==g?(x=p.jsx(Bc,{part:t,annotations:f,latency:h,outputBytes:m,isLastMessage:l,toolMeta:g}),e[16]=l,e[17]=t,e[18]=f,e[19]=h,e[20]=m,e[21]=g,e[22]=x):x=e[22],x}case"tool-todo_write":return null;case"tool-update_interests":return null;case"tool-user_ask":{let f;e[23]!==c||e[24]!==t.toolCallId?(f=c(t.toolCallId)?.latencySeconds,e[23]=c,e[24]=t.toolCallId,e[25]=f):f=e[25];let h;return e[26]!==t||e[27]!==f?(h=p.jsx(S2,{part:t,latency:f}),e[26]=t,e[27]=f,e[28]=h):h=e[28],h}case"tool-propose_plan":{let f;return e[29]!==t?(f=p.jsx(O2,{part:t}),e[29]=t,e[30]=f):f=e[30],f}case"tool-generate_image":{let f;e[31]!==c||e[32]!==t.toolCallId?(f=c(t.toolCallId)?.latencySeconds,e[31]=c,e[32]=t.toolCallId,e[33]=f):f=e[33];let h;return e[34]!==t||e[35]!==f?(h=p.jsx(i2,{part:t,latency:f}),e[34]=t,e[35]=f,e[36]=h):h=e[36],h}case"tool-take_screenshot":{let f;e[37]!==c||e[38]!==t.toolCallId?(f=c(t.toolCallId)?.latencySeconds,e[37]=c,e[38]=t.toolCallId,e[39]=f):f=e[39];let h;return e[40]!==t||e[41]!==f?(h=p.jsx(c2,{part:t,latency:f}),e[40]=t,e[41]=f,e[42]=h):h=e[42],h}case"tool-web_search":case"tool-deep_research":{let f;e[43]!==c||e[44]!==t.toolCallId?(f=c(t.toolCallId)?.latencySeconds,e[43]=c,e[44]=t.toolCallId,e[45]=f):f=e[45];let h;e[46]!==o.webSearchStreaming||e[47]!==t.toolCallId?(h=o.webSearchStreaming.get(t.toolCallId),e[46]=o.webSearchStreaming,e[47]=t.toolCallId,e[48]=h):h=e[48];let m;return e[49]!==t||e[50]!==f||e[51]!==h?(m=p.jsx(k2,{part:t,latency:f,streamingText:h}),e[49]=t,e[50]=f,e[51]=h,e[52]=m):m=e[52],m}case"tool-subtask":{let f;e[53]!==d||e[54]!==t.toolCallId?(f=d(t.toolCallId),e[53]=d,e[54]=t.toolCallId,e[55]=f):f=e[55];let h;e[56]!==c||e[57]!==t.toolCallId?(h=c(t.toolCallId)?.annotations,e[56]=c,e[57]=t.toolCallId,e[58]=h):h=e[58];let m;e[59]!==c||e[60]!==t.toolCallId?(m=c(t.toolCallId)?.latencySeconds,e[59]=c,e[60]=t.toolCallId,e[61]=m):m=e[61];let g;e[62]!==t||e[63]!==f||e[64]!==h||e[65]!==m?(g={part:t,subtaskMeta:f,annotations:h,latency:m},e[62]=t,e[63]=f,e[64]=h,e[65]=m,e[66]=g):g=e[66];const x=g;let y;return e[67]!==x?(y=p.jsx(E.Suspense,{fallback:p.jsx(j2,{...x}),children:p.jsx(I2,{...x})}),e[67]=x,e[68]=y):y=e[68],y}case"text":{const f=!!s&&!i,h=i&&l;let m;return e[69]!==r||e[70]!==t||e[71]!==f||e[72]!==h||e[73]!==s?(m=p.jsx(uo,{id:r,part:t,extraActions:s,copyable:!0,alwaysShowActions:f,animate:h}),e[69]=r,e[70]=t,e[71]=f,e[72]=h,e[73]=s,e[74]=m):m=e[74],m}case"reasoning":return null;case"step-start":case"file":case"source-url":case"source-document":return null;case"data-tool-metadata":case"data-tool-subtask-metadata":case"data-generate-image":case"data-web-search":return null;default:{const f=t;if(f.type==="tool-brand_context_setup"||f.type==="tool-BRAND_CONTEXT_EXTRACT"){let h;e[75]!==f.toolCallId||e[76]!==c?(h=c(f.toolCallId)?.latencySeconds,e[75]=f.toolCallId,e[76]=c,e[77]=h):h=e[77];let m;return e[78]!==f||e[79]!==h?(m=p.jsx(W2,{part:f,latency:h}),e[78]=f,e[79]=h,e[80]=m):m=e[80],m}if(f.type==="tool-BRAND_CONTEXT_GET"){let h;e[81]!==f.toolCallId||e[82]!==c?(h=c(f.toolCallId)?.latencySeconds,e[81]=f.toolCallId,e[82]=c,e[83]=h):h=e[83];let m;return e[84]!==f||e[85]!==h?(m=p.jsx(U2,{part:f,latency:h}),e[84]=f,e[85]=h,e[86]=m):m=e[86],m}if(f.type==="tool-BRAND_CONTEXT_LIST"){let h;e[87]!==f.toolCallId||e[88]!==c?(h=c(f.toolCallId)?.latencySeconds,e[87]=f.toolCallId,e[88]=c,e[89]=h):h=e[89];let m;return e[90]!==f||e[91]!==h?(m=p.jsx(q2,{part:f,latency:h}),e[90]=f,e[91]=h,e[92]=m):m=e[92],m}if(f.type==="tool-COLLECTION_VIRTUAL_MCP_CREATE"){let h;e[93]!==f.toolCallId||e[94]!==c?(h=c(f.toolCallId)?.latencySeconds,e[93]=f.toolCallId,e[94]=c,e[95]=h):h=e[95];let m;return e[96]!==f||e[97]!==h?(m=p.jsx(Q2,{part:f,latency:h}),e[96]=f,e[97]=h,e[98]=m):m=e[98],m}if(f.type==="tool-COLLECTION_VIRTUAL_MCP_LIST"){let h;e[99]!==f.toolCallId||e[100]!==c?(h=c(f.toolCallId)?.latencySeconds,e[99]=f.toolCallId,e[100]=c,e[101]=h):h=e[101];let m;return e[102]!==f||e[103]!==h?(m=p.jsx(nv,{part:f,latency:h}),e[102]=f,e[103]=h,e[104]=m):m=e[104],m}if(f.type==="tool-COLLECTION_CONNECTIONS_LIST"){let h;e[105]!==f.toolCallId||e[106]!==c?(h=c(f.toolCallId)?.latencySeconds,e[105]=f.toolCallId,e[106]=c,e[107]=h):h=e[107];let m;return e[108]!==f||e[109]!==h?(m=p.jsx(iv,{part:f,latency:h}),e[108]=f,e[109]=h,e[110]=m):m=e[110],m}if(f.type.startsWith("tool-")){const h=f.toolCallId;let m;e[111]!==o.toolMetadata||e[112]!==h?(m=o.toolMetadata.get(h),e[111]=o.toolMetadata,e[112]=h,e[113]=m):m=e[113];const g=m,x=g?.annotations,y=g?.latencySeconds,b=g?.outputBytes,k=g?._meta;let S;return e[114]!==f||e[115]!==l||e[116]!==x||e[117]!==y||e[118]!==b||e[119]!==k?(S=p.jsx(Bc,{part:f,annotations:x,latency:y,outputBytes:b,isLastMessage:l,toolMeta:k}),e[114]=f,e[115]=l,e[116]=x,e[117]=y,e[118]=b,e[119]=k,e[120]=S):S=e[120],S}if(f.type.startsWith("data-"))return null;throw new Error(`Unknown part type: ${f.type}`)}}}function Uv(n){const e=_.c(2),{isRunInProgress:t}=n;if(t){let s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(s=p.jsx("div",{className:"flex items-center gap-1.5 py-2 opacity-60",children:p.jsxs("span",{className:"flex items-center gap-1.5",children:[p.jsx(Js,{className:"text-muted-foreground shrink-0 animate-pulse",size:14}),p.jsx("span",{className:"text-[14px] text-muted-foreground shimmer",children:"Resuming task..."})]})}),e[0]=s):s=e[0],s}let r;return e[1]===Symbol.for("react.memo_cache_sentinel")?(r=p.jsx("div",{className:"text-[14px] text-muted-foreground/60 py-2",children:"No response was generated"}),e[1]=r):r=e[1],r}function qv(n){const e=_.c(7),{className:t,children:r}=n;let s;e[0]!==t?(s=ee("w-full min-w-0 group relative flex items-start gap-4 px-4 z-20 text-foreground flex-row",t),e[0]=t,e[1]=s):s=e[1];let o;e[2]!==r?(o=p.jsx("div",{className:"flex flex-col min-w-0 w-full items-start",children:p.jsx("div",{className:"w-full min-w-0 not-only:rounded-2xl text-[14px] wrap-break-word overflow-wrap-anywhere bg-transparent",children:r})}),e[2]=r,e[3]=o):o=e[3];let i;return e[4]!==s||e[5]!==o?(i=p.jsx("div",{className:s,children:o}),e[4]=s,e[5]=o,e[6]=i):i=e[6],i}function Kv(n){const e=_.c(31),{message:t,turnStartedAt:r,status:s,className:o,isLast:i}=n,l=i===void 0?!1:i,{isRunInProgress:a}=Wn()??{},c=a===void 0?!1:a,u=Gi()?.taskId??null,d=s==="streaming",h=d||s==="submitted";let m;e[0]!==r?(m=Ki(r),e[0]=r,e[1]=m):m=e[1];const g=m;let x;e[2]!==h?(x=()=>h?Date.now():null,e[2]=h,e[3]=x):x=e[3];const[y,b]=E.useState(x),[k,S]=E.useState(h);k!==h&&(S(h),b(h?Date.now():null));const v=g??y,{reasoningGroups:w,renderOrder:C,dataParts:T}=Nv(t),N=t!==null&&C.length>0,M=t&&t.parts.length>0?t.parts[t.parts.length-1]:null,j=d&&M?.type==="reasoning";let R;if(e[4]!==t){const F=t?.metadata?.reasoning_start_at?new Date(t.metadata.reasoning_start_at):null,U=t?.metadata?.reasoning_end_at?new Date(t.metadata.reasoning_end_at):new Date;R=F!==null?U.getTime()-F.getTime():null,e[4]=t,e[5]=R}else R=e[5];const A=R;let D;e[6]!==l||e[7]!==t?(D=!l||!t||!t.parts.some(Gv),e[6]=l,e[7]=t,e[8]=D):D=e[8];const I=D;let $;e[9]!==N||e[10]!==h||e[11]!==I||e[12]!==t||e[13]!==C?($=!h&&N&&I&&(()=>{let F=0;for(const U of C)if(U.kind==="part"){const Y=t.parts[U.index]?.type;(Y==="dynamic-tool"||Y?.startsWith("tool-"))&&F++}return F>=zv})(),e[9]=N,e[10]=h,e[11]=I,e[12]=t,e[13]=C,e[14]=$):$=e[14];const L=$;let z;if(e[15]!==o||e[16]!==T||e[17]!==N||e[18]!==l||e[19]!==h||e[20]!==j||e[21]!==c||e[22]!==I||e[23]!==t||e[24]!==w||e[25]!==C||e[26]!==L||e[27]!==v||e[28]!==u||e[29]!==A){const{collapsed:F,tail:U}=L?Bv(C,t.parts):{collapsed:[],tail:C};z=p.jsx(qv,{className:o,children:N?p.jsxs("div",{className:"flex flex-col gap-3 sm:gap-2",children:[t.metadata?.resumedFromBackground&&p.jsxs("div",{className:"flex items-center gap-1.5 text-[12px] text-muted-foreground/60 select-none",children:[p.jsx(Yc,{className:"size-3 shrink-0"}),p.jsx("span",{children:"Resumed — background task completed"})]}),F.length>0&&p.jsx(Vv,{items:F,message:t,reasoningGroups:w,isReasoningActive:j,totalDuration:A,dataParts:T,isLoading:h,isLast:l}),U.map((Y,K)=>{const Q=F.length+K,ne=U.findLastIndex(Jv)===K;return Ah({item:Y,renderIndex:Q,message:t,reasoningGroups:w,isReasoningActive:j,totalDuration:A,dataParts:T,isLoading:h,isLast:l,isLastVisiblePart:ne,renderOrder:C})}),u&&p.jsx(wv,{threadId:u,message:t}),l&&h&&v!==null&&p.jsx(Ov,{startedAt:v}),l&&!h&&u&&p.jsxs(p.Fragment,{children:[p.jsx(hv,{}),I&&p.jsx(cv,{})]}),!h&&p.jsx(yh,{message:t})]}):h?p.jsx(Dv,{startedAt:v}):p.jsx(Uv,{isRunInProgress:l&&c})}),e[15]=o,e[16]=T,e[17]=N,e[18]=l,e[19]=h,e[20]=j,e[21]=c,e[22]=I,e[23]=t,e[24]=w,e[25]=C,e[26]=L,e[27]=v,e[28]=u,e[29]=A,e[30]=z}else z=e[30];return z}function Jv(n){return n.kind==="part"}function Gv(n){const e=n.type;if(e!=="dynamic-tool"&&!e?.startsWith("tool-"))return!1;const t=n.state;return t==="input-streaming"||t==="input-available"||t==="approval-requested"}function Xv(n){const e=_.c(21),{event:t}=n,[r,s]=E.useState(!1);let o;e[0]!==t.data?(o=JSON.stringify(t.data,null,2),e[0]=t.data,e[1]=o):o=e[1];const i=o;let l;e[2]===Symbol.for("react.memo_cache_sentinel")?(l=()=>s(Yv),e[2]=l):l=e[2];let a,c;e[3]===Symbol.for("react.memo_cache_sentinel")?(a=p.jsx(mm,{className:"size-4 shrink-0 text-muted-foreground"}),c=p.jsx("span",{className:"font-medium",children:"Triggered by event"}),e[3]=a,e[4]=c):(a=e[3],c=e[4]);let u;e[5]!==t.type?(u=p.jsx("span",{className:"min-w-0 truncate text-muted-foreground",children:t.type}),e[5]=t.type,e[6]=u):u=e[6];const d=r&&"rotate-180";let f;e[7]!==d?(f=ee("ml-auto size-4 shrink-0 text-muted-foreground transition-transform",d),e[7]=d,e[8]=f):f=e[8];let h;e[9]!==f?(h=p.jsx(Zr,{className:f}),e[9]=f,e[10]=h):h=e[10];let m;e[11]!==u||e[12]!==h?(m=p.jsxs("button",{type:"button",onClick:l,className:"flex w-full items-center gap-2 px-3 py-2 text-sm cursor-pointer",children:[a,c,u,h]}),e[11]=u,e[12]=h,e[13]=m):m=e[13];let g;e[14]!==t.source||e[15]!==r||e[16]!==i?(g=r&&p.jsxs("div",{className:"border-t border-border/60 px-3 py-2",children:[p.jsx("div",{className:"mb-2 text-xs text-muted-foreground",children:t.source}),p.jsx("pre",{className:"overflow-auto whitespace-pre-wrap break-words text-xs text-foreground",children:i})]}),e[14]=t.source,e[15]=r,e[16]=i,e[17]=g):g=e[17];let x;return e[18]!==g||e[19]!==m?(x=p.jsxs("div",{className:"rounded-lg border border-border/60 bg-background overflow-hidden text-left",children:[m,g]}),e[18]=g,e[19]=m,e[20]=x):x=e[20],x}function Yv(n){return!n}const Qv=[MS.configure({heading:!1,blockquote:!1,codeBlock:!1,horizontalRule:!1}),Bb,Wb];function Zv(n){const e=_.c(5),{tiptapDoc:t}=n;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={attributes:{class:"prose prose-sm max-w-none focus:outline-none"}},e[0]=r):r=e[0];let s;e[1]!==t?(s={extensions:Qv,content:t,editable:!1,editorProps:r},e[1]=t,e[2]=s):s=e[2];const o=jb(s);if(!o)return null;let i;return e[3]!==o?(i=p.jsx(Df,{editor:o,className:"[&_.ProseMirror]:outline-none [&_.ProseMirror]:cursor-text"}),e[3]=o,e[4]=i):i=e[4],i}function ew(n){const e=_.c(38),{message:t,className:r,onScrollToPair:s}=n,{id:o,parts:i,metadata:l}=t,[a,c]=E.useState(!1),[u,d]=E.useState(!1),f=E.useRef(!1);let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=I=>{I&&!f.current&&(f.current=!0,d(I.scrollHeight>I.clientHeight))},e[0]=h):h=e[0];const m=h;if(!i||i.length===0)return null;let g;e[1]!==s?(g=()=>{c(!0),s?.()},e[1]=s,e[2]=g):g=e[2];const x=g,y=l?.tiptapDoc;let b;e[3]!==r?(b=ee("message-block w-full min-w-0 relative flex items-start gap-4 px-2.5 text-foreground flex-row-reverse",r),e[3]=r,e[4]=b):b=e[4];let k,S;e[5]===Symbol.for("react.memo_cache_sentinel")?(k=()=>c(!0),S=()=>c(!1),e[5]=k,e[6]=S):(k=e[5],S=e[6]);let v;e[7]===Symbol.for("react.memo_cache_sentinel")?(v=p.jsx("div",{className:"absolute inset-0 bg-muted/75 rounded-lg pointer-events-none"}),e[7]=v):v=e[7];let w;e[8]!==a||e[9]!==u?(w=ee("z-10 px-4 py-2 flex-1 transition-[max-height,opacity] duration-300 ease-out",a?"max-h-[50vh] overflow-auto opacity-100":ee("max-h-[84px] overflow-hidden opacity-99",u&&"mask-b-from-1%")),e[8]=a,e[9]=u,e[10]=w):w=e[10];let C;if(e[11]!==o||e[12]!==i){let I;e[14]!==o?(I=($,L)=>$.type==="data-trigger-event"?p.jsx(Xv,{event:$.data},`${o}-${L}`):null,e[14]=o,e[15]=I):I=e[15],C=i.map(I),e[11]=o,e[12]=i,e[13]=C}else C=e[13];let T;e[16]!==y||e[17]!==o||e[18]!==l||e[19]!==i?(T=y?p.jsx(Zv,{tiptapDoc:l.tiptapDoc}):i.map((I,$)=>I.type==="text"?i[$-1]?.type==="data-trigger-event"?null:p.jsx(uo,{id:o,part:I},`${o}-${$}`):null),e[16]=y,e[17]=o,e[18]=l,e[19]=i,e[20]=T):T=e[20];let N;e[21]!==C||e[22]!==T?(N=p.jsxs("div",{className:"flex flex-col gap-2",children:[C,T]}),e[21]=C,e[22]=T,e[23]=N):N=e[23];let M;e[24]!==N||e[25]!==w?(M=p.jsx("div",{ref:m,className:w,children:N}),e[24]=N,e[25]=w,e[26]=M):M=e[26];let j;e[27]!==x||e[28]!==M?(j=p.jsxs("div",{tabIndex:0,onClick:x,onFocus:k,onBlur:S,className:"w-full border border-border/60 min-w-0 shadow-xs rounded-lg text-[14px] wrap-break-word overflow-wrap-anywhere bg-background cursor-pointer transition-colors relative flex outline-none",children:[v,M]}),e[27]=x,e[28]=M,e[29]=j):j=e[29];let R;e[30]!==t?(R=p.jsx(yh,{message:t,className:"mt-1 mr-1 self-end"}),e[30]=t,e[31]=R):R=e[31];let A;e[32]!==j||e[33]!==R?(A=p.jsxs("div",{className:"w-full min-w-0 flex flex-col",children:[j,R]}),e[32]=j,e[33]=R,e[34]=A):A=e[34];let D;return e[35]!==A||e[36]!==b?(D=p.jsx(p.Fragment,{children:p.jsx("div",{className:b,children:A})}),e[35]=A,e[36]=b,e[37]=D):D=e[37],D}function tw(n){const e=[],t=n.filter(r=>r.role!=="system"&&!r.metadata?.internal&&!r.metadata?.subtaskJobId);for(let r=0;r<t.length;r++){const s=t[r];if(s)if(s.role==="user"){const o=t[r+1];o&&o.role==="assistant"?(e.push({user:s,assistant:o}),r++):e.push({user:s,assistant:null})}else s.role==="assistant"&&e.push({user:null,assistant:s})}return e}function nw(n){const e=_.c(19),{pair:t,isLastPair:r,status:s}=n,o=E.useRef(null),i=E.useRef(!1);let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{o.current&&o.current.scrollIntoView({behavior:"smooth",block:"start"})},e[0]=l):l=e[0];const a=l;let c;e[1]!==r||e[2]!==t.assistant?.metadata?.resumedFromBackground||e[3]!==s?(c=y=>{if(o.current=y,!r||!y||i.current||(i.current=!0,t.assistant?.metadata?.resumedFromBackground))return;if(s==="submitted"||s==="streaming"){y.scrollIntoView({behavior:"smooth",block:"start"});return}const b=y.closest("[data-chat-scroller]");b?b.scrollTop=b.scrollHeight:y.scrollIntoView({behavior:"instant",block:"start"})},e[1]=r,e[2]=t.assistant?.metadata?.resumedFromBackground,e[3]=s,e[4]=c):c=e[4];const u=c,d=!t.user&&"pt-8 sm:pt-6";let f;e[5]!==d?(f=ee("flex flex-col pb-2 sm:pb-2",d),e[5]=d,e[6]=f):f=e[6];let h;e[7]!==t.user?(h=t.user&&p.jsxs(p.Fragment,{children:[p.jsx("div",{className:"sticky top-0 z-50 w-full h-4 bg-background"}),p.jsx("div",{className:"sticky mb-8 sm:mb-6 top-4 z-50",children:p.jsx(ew,{message:t.user,onScrollToPair:a})})]}),e[7]=t.user,e[8]=h):h=e[8];const m=t.user?.created_at??null;let g;e[9]!==r||e[10]!==t.assistant||e[11]!==s||e[12]!==m?(g=p.jsx(Kv,{message:t.assistant,turnStartedAt:m,status:s,isLast:r}),e[9]=r,e[10]=t.assistant,e[11]=s,e[12]=m,e[13]=g):g=e[13];let x;return e[14]!==u||e[15]!==f||e[16]!==h||e[17]!==g?(x=p.jsxs("div",{ref:u,className:f,children:[h,g]}),e[14]=u,e[15]=f,e[16]=h,e[17]=g,e[18]=x):x=e[18],x}function rw(n,e){return E.useReducer((t,r)=>e[t][r]??t,n)}var Kl="ScrollArea",[jh]=Gc(Kl),[sw,tt]=jh(Kl),Ih=E.forwardRef((n,e)=>{const{__scopeScrollArea:t,type:r="hover",dir:s,scrollHideDelay:o=600,...i}=n,[l,a]=E.useState(null),[c,u]=E.useState(null),[d,f]=E.useState(null),[h,m]=E.useState(null),[g,x]=E.useState(null),[y,b]=E.useState(0),[k,S]=E.useState(0),[v,w]=E.useState(!1),[C,T]=E.useState(!1),N=kn(e,j=>a(j)),M=sp(s);return p.jsx(sw,{scope:t,type:r,dir:M,scrollHideDelay:o,scrollArea:l,viewport:c,onViewportChange:u,content:d,onContentChange:f,scrollbarX:h,onScrollbarXChange:m,scrollbarXEnabled:v,onScrollbarXEnabledChange:w,scrollbarY:g,onScrollbarYChange:x,scrollbarYEnabled:C,onScrollbarYEnabledChange:T,onCornerWidthChange:b,onCornerHeightChange:S,children:p.jsx(Ut.div,{dir:M,...i,ref:N,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":k+"px",...n.style}})})});Ih.displayName=Kl;var Oh="ScrollAreaViewport",Rh=E.forwardRef((n,e)=>{const{__scopeScrollArea:t,children:r,nonce:s,...o}=n,i=tt(Oh,t),l=E.useRef(null),a=kn(e,l,i.onViewportChange);return p.jsxs(p.Fragment,{children:[p.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:s}),p.jsx(Ut.div,{"data-radix-scroll-area-viewport":"",...o,ref:a,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...n.style},children:p.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});Rh.displayName=Oh;var pt="ScrollAreaScrollbar",Dh=E.forwardRef((n,e)=>{const{forceMount:t,...r}=n,s=tt(pt,n.__scopeScrollArea),{onScrollbarXEnabledChange:o,onScrollbarYEnabledChange:i}=s,l=n.orientation==="horizontal";return E.useEffect(()=>(l?o(!0):i(!0),()=>{l?o(!1):i(!1)}),[l,o,i]),s.type==="hover"?p.jsx(ow,{...r,ref:e,forceMount:t}):s.type==="scroll"?p.jsx(iw,{...r,ref:e,forceMount:t}):s.type==="auto"?p.jsx(Ph,{...r,ref:e,forceMount:t}):s.type==="always"?p.jsx(Jl,{...r,ref:e}):null});Dh.displayName=pt;var ow=E.forwardRef((n,e)=>{const{forceMount:t,...r}=n,s=tt(pt,n.__scopeScrollArea),[o,i]=E.useState(!1);return E.useEffect(()=>{const l=s.scrollArea;let a=0;if(l){const c=()=>{window.clearTimeout(a),i(!0)},u=()=>{a=window.setTimeout(()=>i(!1),s.scrollHideDelay)};return l.addEventListener("pointerenter",c),l.addEventListener("pointerleave",u),()=>{window.clearTimeout(a),l.removeEventListener("pointerenter",c),l.removeEventListener("pointerleave",u)}}},[s.scrollArea,s.scrollHideDelay]),p.jsx(Nr,{present:t||o,children:p.jsx(Ph,{"data-state":o?"visible":"hidden",...r,ref:e})})}),iw=E.forwardRef((n,e)=>{const{forceMount:t,...r}=n,s=tt(pt,n.__scopeScrollArea),o=n.orientation==="horizontal",i=xo(()=>a("SCROLL_END"),100),[l,a]=rw("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return E.useEffect(()=>{if(l==="idle"){const c=window.setTimeout(()=>a("HIDE"),s.scrollHideDelay);return()=>window.clearTimeout(c)}},[l,s.scrollHideDelay,a]),E.useEffect(()=>{const c=s.viewport,u=o?"scrollLeft":"scrollTop";if(c){let d=c[u];const f=()=>{const h=c[u];d!==h&&(a("SCROLL"),i()),d=h};return c.addEventListener("scroll",f),()=>c.removeEventListener("scroll",f)}},[s.viewport,o,a,i]),p.jsx(Nr,{present:t||l!=="hidden",children:p.jsx(Jl,{"data-state":l==="hidden"?"hidden":"visible",...r,ref:e,onPointerEnter:_t(n.onPointerEnter,()=>a("POINTER_ENTER")),onPointerLeave:_t(n.onPointerLeave,()=>a("POINTER_LEAVE"))})})}),Ph=E.forwardRef((n,e)=>{const t=tt(pt,n.__scopeScrollArea),{forceMount:r,...s}=n,[o,i]=E.useState(!1),l=n.orientation==="horizontal",a=xo(()=>{if(t.viewport){const c=t.viewport.offsetWidth<t.viewport.scrollWidth,u=t.viewport.offsetHeight<t.viewport.scrollHeight;i(l?c:u)}},10);return Hn(t.viewport,a),Hn(t.content,a),p.jsx(Nr,{present:r||o,children:p.jsx(Jl,{"data-state":o?"visible":"hidden",...s,ref:e})})}),Jl=E.forwardRef((n,e)=>{const{orientation:t="vertical",...r}=n,s=tt(pt,n.__scopeScrollArea),o=E.useRef(null),i=E.useRef(0),[l,a]=E.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),c=Bh(l.viewport,l.content),u={...r,sizes:l,onSizesChange:a,hasThumb:c>0&&c<1,onThumbChange:f=>o.current=f,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:f=>i.current=f};function d(f,h){return fw(f,i.current,l,h)}return t==="horizontal"?p.jsx(lw,{...u,ref:e,onThumbPositionChange:()=>{if(s.viewport&&o.current){const f=s.viewport.scrollLeft,h=Uc(f,l,s.dir);o.current.style.transform=`translate3d(${h}px, 0, 0)`}},onWheelScroll:f=>{s.viewport&&(s.viewport.scrollLeft=f)},onDragScroll:f=>{s.viewport&&(s.viewport.scrollLeft=d(f,s.dir))}}):t==="vertical"?p.jsx(aw,{...u,ref:e,onThumbPositionChange:()=>{if(s.viewport&&o.current){const f=s.viewport.scrollTop,h=Uc(f,l);o.current.style.transform=`translate3d(0, ${h}px, 0)`}},onWheelScroll:f=>{s.viewport&&(s.viewport.scrollTop=f)},onDragScroll:f=>{s.viewport&&(s.viewport.scrollTop=d(f))}}):null}),lw=E.forwardRef((n,e)=>{const{sizes:t,onSizesChange:r,...s}=n,o=tt(pt,n.__scopeScrollArea),[i,l]=E.useState(),a=E.useRef(null),c=kn(e,a,o.onScrollbarXChange);return E.useEffect(()=>{a.current&&l(getComputedStyle(a.current))},[a]),p.jsx(_h,{"data-orientation":"horizontal",...s,ref:c,sizes:t,style:{bottom:0,left:o.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:o.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":go(t)+"px",...n.style},onThumbPointerDown:u=>n.onThumbPointerDown(u.x),onDragScroll:u=>n.onDragScroll(u.x),onWheelScroll:(u,d)=>{if(o.viewport){const f=o.viewport.scrollLeft+u.deltaX;n.onWheelScroll(f),Hh(f,d)&&u.preventDefault()}},onResize:()=>{a.current&&o.viewport&&i&&r({content:o.viewport.scrollWidth,viewport:o.viewport.offsetWidth,scrollbar:{size:a.current.clientWidth,paddingStart:qs(i.paddingLeft),paddingEnd:qs(i.paddingRight)}})}})}),aw=E.forwardRef((n,e)=>{const{sizes:t,onSizesChange:r,...s}=n,o=tt(pt,n.__scopeScrollArea),[i,l]=E.useState(),a=E.useRef(null),c=kn(e,a,o.onScrollbarYChange);return E.useEffect(()=>{a.current&&l(getComputedStyle(a.current))},[a]),p.jsx(_h,{"data-orientation":"vertical",...s,ref:c,sizes:t,style:{top:0,right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":go(t)+"px",...n.style},onThumbPointerDown:u=>n.onThumbPointerDown(u.y),onDragScroll:u=>n.onDragScroll(u.y),onWheelScroll:(u,d)=>{if(o.viewport){const f=o.viewport.scrollTop+u.deltaY;n.onWheelScroll(f),Hh(f,d)&&u.preventDefault()}},onResize:()=>{a.current&&o.viewport&&i&&r({content:o.viewport.scrollHeight,viewport:o.viewport.offsetHeight,scrollbar:{size:a.current.clientHeight,paddingStart:qs(i.paddingTop),paddingEnd:qs(i.paddingBottom)}})}})}),[cw,Lh]=jh(pt),_h=E.forwardRef((n,e)=>{const{__scopeScrollArea:t,sizes:r,hasThumb:s,onThumbChange:o,onThumbPointerUp:i,onThumbPointerDown:l,onThumbPositionChange:a,onDragScroll:c,onWheelScroll:u,onResize:d,...f}=n,h=tt(pt,t),[m,g]=E.useState(null),x=kn(e,N=>g(N)),y=E.useRef(null),b=E.useRef(""),k=h.viewport,S=r.content-r.viewport,v=Qt(u),w=Qt(a),C=xo(d,10);function T(N){if(y.current){const M=N.clientX-y.current.left,j=N.clientY-y.current.top;c({x:M,y:j})}}return E.useEffect(()=>{const N=M=>{const j=M.target;m?.contains(j)&&v(M,S)};return document.addEventListener("wheel",N,{passive:!1}),()=>document.removeEventListener("wheel",N,{passive:!1})},[k,m,S,v]),E.useEffect(w,[r,w]),Hn(m,C),Hn(h.content,C),p.jsx(cw,{scope:t,scrollbar:m,hasThumb:s,onThumbChange:Qt(o),onThumbPointerUp:Qt(i),onThumbPositionChange:w,onThumbPointerDown:Qt(l),children:p.jsx(Ut.div,{...f,ref:x,style:{position:"absolute",...f.style},onPointerDown:_t(n.onPointerDown,N=>{N.button===0&&(N.target.setPointerCapture(N.pointerId),y.current=m.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",h.viewport&&(h.viewport.style.scrollBehavior="auto"),T(N))}),onPointerMove:_t(n.onPointerMove,T),onPointerUp:_t(n.onPointerUp,N=>{const M=N.target;M.hasPointerCapture(N.pointerId)&&M.releasePointerCapture(N.pointerId),document.body.style.webkitUserSelect=b.current,h.viewport&&(h.viewport.style.scrollBehavior=""),y.current=null})})})}),Us="ScrollAreaThumb",$h=E.forwardRef((n,e)=>{const{forceMount:t,...r}=n,s=Lh(Us,n.__scopeScrollArea);return p.jsx(Nr,{present:t||s.hasThumb,children:p.jsx(uw,{ref:e,...r})})}),uw=E.forwardRef((n,e)=>{const{__scopeScrollArea:t,style:r,...s}=n,o=tt(Us,t),i=Lh(Us,t),{onThumbPositionChange:l}=i,a=kn(e,d=>i.onThumbChange(d)),c=E.useRef(void 0),u=xo(()=>{c.current&&(c.current(),c.current=void 0)},100);return E.useEffect(()=>{const d=o.viewport;if(d){const f=()=>{if(u(),!c.current){const h=hw(d,l);c.current=h,l()}};return l(),d.addEventListener("scroll",f),()=>d.removeEventListener("scroll",f)}},[o.viewport,u,l]),p.jsx(Ut.div,{"data-state":i.hasThumb?"visible":"hidden",...s,ref:a,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:_t(n.onPointerDownCapture,d=>{const h=d.target.getBoundingClientRect(),m=d.clientX-h.left,g=d.clientY-h.top;i.onThumbPointerDown({x:m,y:g})}),onPointerUp:_t(n.onPointerUp,i.onThumbPointerUp)})});$h.displayName=Us;var Gl="ScrollAreaCorner",zh=E.forwardRef((n,e)=>{const t=tt(Gl,n.__scopeScrollArea),r=!!(t.scrollbarX&&t.scrollbarY);return t.type!=="scroll"&&r?p.jsx(dw,{...n,ref:e}):null});zh.displayName=Gl;var dw=E.forwardRef((n,e)=>{const{__scopeScrollArea:t,...r}=n,s=tt(Gl,t),[o,i]=E.useState(0),[l,a]=E.useState(0),c=!!(o&&l);return Hn(s.scrollbarX,()=>{const u=s.scrollbarX?.offsetHeight||0;s.onCornerHeightChange(u),a(u)}),Hn(s.scrollbarY,()=>{const u=s.scrollbarY?.offsetWidth||0;s.onCornerWidthChange(u),i(u)}),c?p.jsx(Ut.div,{...r,ref:e,style:{width:o,height:l,position:"absolute",right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:0,...n.style}}):null});function qs(n){return n?parseInt(n,10):0}function Bh(n,e){const t=n/e;return isNaN(t)?0:t}function go(n){const e=Bh(n.viewport,n.content),t=n.scrollbar.paddingStart+n.scrollbar.paddingEnd,r=(n.scrollbar.size-t)*e;return Math.max(r,18)}function fw(n,e,t,r="ltr"){const s=go(t),o=s/2,i=e||o,l=s-i,a=t.scrollbar.paddingStart+i,c=t.scrollbar.size-t.scrollbar.paddingEnd-l,u=t.content-t.viewport,d=r==="ltr"?[0,u]:[u*-1,0];return Fh([a,c],d)(n)}function Uc(n,e,t="ltr"){const r=go(e),s=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,o=e.scrollbar.size-s,i=e.content-e.viewport,l=o-r,a=t==="ltr"?[0,i]:[i*-1,0],c=op(n,a);return Fh([0,i],[0,l])(c)}function Fh(n,e){return t=>{if(n[0]===n[1]||e[0]===e[1])return e[0];const r=(e[1]-e[0])/(n[1]-n[0]);return e[0]+r*(t-n[0])}}function Hh(n,e){return n>0&&n<e}var hw=(n,e=()=>{})=>{let t={left:n.scrollLeft,top:n.scrollTop},r=0;return(function s(){const o={left:n.scrollLeft,top:n.scrollTop},i=t.left!==o.left,l=t.top!==o.top;(i||l)&&e(),t=o,r=window.requestAnimationFrame(s)})(),()=>window.cancelAnimationFrame(r)};function xo(n,e){const t=Qt(n),r=E.useRef(0);return E.useEffect(()=>()=>window.clearTimeout(r.current),[]),E.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(t,e)},[t,e])}function Hn(n,e){const t=Qt(e);Jc(()=>{let r=0;if(n){const s=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(t)});return s.observe(n),()=>{window.cancelAnimationFrame(r),s.unobserve(n)}}},[n,t])}var pw=Ih,mw=Rh,gw=zh;function sT(n){const e=_.c(17);let t,r,s,o;e[0]!==n?({className:r,children:t,hideScrollbar:o,...s}=n,e[0]=n,e[1]=t,e[2]=r,e[3]=s,e[4]=o):(t=e[1],r=e[2],s=e[3],o=e[4]);const i=o===void 0?!1:o;let l;e[5]!==r?(l=ee("relative h-full w-full",r),e[5]=r,e[6]=l):l=e[6];let a;e[7]!==t?(a=p.jsx(mw,{"data-slot":"scroll-area-viewport",className:"h-full w-full overflow-auto rounded-[inherit] outline-none transition-[color,box-shadow] focus-visible:ring-[2px] focus-visible:ring-ring/20",children:p.jsx("div",{className:"flex min-w-0 flex-col",children:t})}),e[7]=t,e[8]=a):a=e[8];let c;e[9]!==i?(c=p.jsx(xw,{hideScrollbar:i}),e[9]=i,e[10]=c):c=e[10];let u;e[11]===Symbol.for("react.memo_cache_sentinel")?(u=p.jsx(gw,{}),e[11]=u):u=e[11];let d;return e[12]!==s||e[13]!==l||e[14]!==a||e[15]!==c?(d=p.jsxs(pw,{"data-slot":"scroll-area",className:l,...s,children:[a,c,u]}),e[12]=s,e[13]=l,e[14]=a,e[15]=c,e[16]=d):d=e[16],d}function xw(n){const e=_.c(15);let t,r,s,o;e[0]!==n?({className:t,orientation:s,hideScrollbar:o,...r}=n,e[0]=n,e[1]=t,e[2]=r,e[3]=s,e[4]=o):(t=e[1],r=e[2],s=e[3],o=e[4]);const i=s===void 0?"vertical":s,l=o===void 0?!1:o,a=i==="vertical"&&"h-full w-2.5 border-l border-l-transparent",c=i==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent",u=l&&"hidden";let d;e[5]!==t||e[6]!==a||e[7]!==c||e[8]!==u?(d=ee("select-none touch-none p-px transition-colors",a,c,u,t),e[5]=t,e[6]=a,e[7]=c,e[8]=u,e[9]=d):d=e[9];let f;e[10]===Symbol.for("react.memo_cache_sentinel")?(f=p.jsx($h,{"data-slot":"scroll-area-thumb",className:"relative flex-1 rounded-full bg-border"}),e[10]=f):f=e[10];let h;return e[11]!==i||e[12]!==r||e[13]!==d?(h=p.jsx(Dh,{"data-slot":"scroll-area-scrollbar",orientation:i,className:d,...r,children:f}),e[11]=i,e[12]=r,e[13]=d,e[14]=h):h=e[14],h}const Vh=[{ms:6e4,label:"1m"},{ms:12e4,label:"2m"},{ms:3e5,label:"5m"},{ms:6e5,label:"10m"},{ms:9e5,label:"15m"},{ms:18e5,label:"30m"},{ms:36e5,label:"1h"},{ms:72e5,label:"2h"},{ms:216e5,label:"6h"},{ms:432e5,label:"12h"},{ms:864e5,label:"1d"},{ms:6048e5,label:"7d"}],yw=40;function oT(n){const t=(n.endDate.getTime()-n.startDate.getTime())/yw;return Vh.find(s=>s.ms>=t)?.label??"1d"}function Xl(n){const e=Vh.find(o=>o.label===n);if(e)return e.ms;const t=/^(\d+)([mhd])$/.exec(n);if(!t)return 6e4;const r=parseInt(t[1],10),s=t[2];return s==="h"?r*36e5:s==="d"?r*864e5:r*6e4}function bw(n,e){const t=new Date(n);return Xl(e)>=864e5?t.toLocaleDateString([],{month:"short",day:"numeric"}):t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function qc(n,e){const t=Xl(e);return new Date(Math.floor(n.getTime()/t)*t)}function kw(n){return n>=1e4?`${(n/1e3).toFixed(1)}s`:`${Math.round(n)}ms`}function Yl(n){return Number.isFinite(n)?n>=1e6?`${(n/1e6).toFixed(1)}M`:n>=1e3?`${(n/1e3).toFixed(1)}K`:Math.round(n).toLocaleString():"0"}function Ql(n){return Number.isFinite(n)?`$${n.toFixed(n<1?4:2)}`:"$0.00"}function iT(n,e,t){const r=Xl(t),s=qc(e.startDate,t).getTime(),o=e.endDate.getTime(),i=new Map(n.map(a=>[qc(new Date(a.timestamp),t).getTime(),a])),l=[];for(let a=s;a<=o;a+=r){const c=i.get(a),u=new Date(a).toISOString();l.push({t:u,ts:a,label:bw(u,t),calls:c?.calls??0,errors:c?.errors??0,errorRate:c?.errorRate??0,avg:c?.avg??0,p50:c?.p50??0,p95:c?.p95??0,inputTokens:c?.inputTokens??0,outputTokens:c?.outputTokens??0,totalTokens:c?.totalTokens??0,costUsd:c?.costUsd??0})}return l}function lT(n,e){return e==="requests"?n.calls:e==="errors"?n.errorRate:n.avgDurationMs}function aT(n,e){return e==="requests"?n.calls.toLocaleString():e==="errors"?`${n.errorRate.toFixed(1)}%`:kw(n.avgDurationMs)}function Zl(n){return(n.run_config??{}).agent?.id??(n.virtual_mcp_id||null)}function ea(n,e,t,r){if(!n)return r;const s=e.find(i=>i.id===n)??t?.find(i=>i.id===n);if(s?.title)return s.title;const o=up(n);return o?dp(o).title??r:n}function ta(n,e,t){return n?(e.find(s=>s.id===n)??t?.find(s=>s.id===n))?.icon??null:null}function Wh(n){return n?.data?.members??[]}function Li(n){const e=_.c(33),{thread:t,connections:r,virtualMcps:s,selectedIndex:o,total:i,onPrev:l,onNext:a}=n;let c,u;if(e[0]!==r||e[1]!==t||e[2]!==s){const j=Zl(t);c=ea(j,s,r,""),u=ta(j,s,r),e[0]=r,e[1]=t,e[2]=s,e[3]=c,e[4]=u}else c=e[3],u=e[4];const d=u,f=c||t.title;let h;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=p.jsx(Ui,{}),e[5]=h):h=e[5];let m;e[6]!==d||e[7]!==f?(m=p.jsx(qt,{icon:d,name:f,size:"sm",fallbackIcon:h,className:"shadow-sm shrink-0 rounded-md"}),e[6]=d,e[7]=f,e[8]=m):m=e[8];let g;e[9]!==t.title?(g=p.jsx(tu,{className:"text-sm leading-snug truncate",children:t.title}),e[9]=t.title,e[10]=g):g=e[10];let x;e[11]!==c?(x=c&&p.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 truncate",children:c}),e[11]=c,e[12]=x):x=e[12];let y;e[13]!==g||e[14]!==x?(y=p.jsxs("div",{className:"min-w-0",children:[g,x]}),e[13]=g,e[14]=x,e[15]=y):y=e[15];let b;e[16]!==m||e[17]!==y?(b=p.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[m,y]}),e[16]=m,e[17]=y,e[18]=b):b=e[18];const k=o===0;let S;e[19]===Symbol.for("react.memo_cache_sentinel")?(S=p.jsx(Qo,{size:14}),e[19]=S):S=e[19];let v;e[20]!==l||e[21]!==k?(v=p.jsx(un,{size:"icon",variant:"ghost",onClick:l,disabled:k,className:"h-7 w-7 text-muted-foreground","aria-label":"Previous chat",children:S}),e[20]=l,e[21]=k,e[22]=v):v=e[22];const w=o===i-1;let C;e[23]===Symbol.for("react.memo_cache_sentinel")?(C=p.jsx(Zr,{size:14}),e[23]=C):C=e[23];let T;e[24]!==a||e[25]!==w?(T=p.jsx(un,{size:"icon",variant:"ghost",onClick:a,disabled:w,className:"h-7 w-7 text-muted-foreground","aria-label":"Next chat",children:C}),e[24]=a,e[25]=w,e[26]=T):T=e[26];let N;e[27]!==v||e[28]!==T?(N=p.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[v,T]}),e[27]=v,e[28]=T,e[29]=N):N=e[29];let M;return e[30]!==N||e[31]!==b?(M=p.jsx(eu,{className:"px-5 md:px-6 pt-6 pb-5 border-b border-border shrink-0",children:p.jsxs("div",{className:"flex items-start justify-between gap-3 pr-8",children:[b,N]})}),e[30]=N,e[31]=b,e[32]=M):M=e[32],M}function Sw(n){const e=_.c(48),{thread:t,connections:r,virtualMcps:s,members:o}=n;let i,l;if(e[0]!==r||e[1]!==t||e[2]!==s){const I=Zl(t);i=ea(I,s,r,""),l=ta(I,s,r),e[0]=r,e[1]=t,e[2]=s,e[3]=i,e[4]=l}else i=e[3],l=e[4];const a=l;let c;if(e[5]!==o||e[6]!==t.created_by){const I=Wh(o);let $;e[8]!==t.created_by?($=L=>L.userId===t.created_by,e[8]=t.created_by,e[9]=$):$=e[9],c=I.find($),e[5]=o,e[6]=t.created_by,e[7]=c}else c=e[7];const u=c;let d;e[10]!==u?.user.email||e[11]!==u?.user.name||e[12]!==t.created_by?(d=u?.user.name??u?.user.email??t.created_by?.substring(0,8)??"—",e[10]=u?.user.email,e[11]=u?.user.name,e[12]=t.created_by,e[13]=d):d=e[13];const f=d,h=u?.user.image??void 0;let m;e[14]!==t.created_at?(m=new Date(t.created_at).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"}),e[14]=t.created_at,e[15]=m):m=e[15];const g=m,x=Rn[t.status]??Rn.completed,y=x.icon;let b;e[16]===Symbol.for("react.memo_cache_sentinel")?(b=p.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"Status"}),e[16]=b):b=e[16];let k;e[17]!==y||e[18]!==x.iconClassName?(k=p.jsx(y,{size:13,className:x.iconClassName}),e[17]=y,e[18]=x.iconClassName,e[19]=k):k=e[19];let S;e[20]!==x.labelColor?(S=ee("text-sm",x.labelColor),e[20]=x.labelColor,e[21]=S):S=e[21];let v;e[22]!==x.label||e[23]!==S?(v=p.jsx("span",{className:S,children:x.label}),e[22]=x.label,e[23]=S,e[24]=v):v=e[24];let w;e[25]!==k||e[26]!==v?(w=p.jsxs("div",{children:[b,p.jsxs("div",{className:"flex items-center gap-1.5",children:[k,v]})]}),e[25]=k,e[26]=v,e[27]=w):w=e[27];let C;e[28]===Symbol.for("react.memo_cache_sentinel")?(C=p.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"Date"}),e[28]=C):C=e[28];let T;e[29]!==g?(T=p.jsxs("div",{children:[C,p.jsx("div",{className:"text-sm text-foreground",children:g})]}),e[29]=g,e[30]=T):T=e[30];let N;e[31]===Symbol.for("react.memo_cache_sentinel")?(N=p.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"User"}),e[31]=N):N=e[31];let M;e[32]!==h||e[33]!==f?(M=p.jsx(lu,{url:h,fallback:f,shape:"circle",size:"2xs",className:"shrink-0"}),e[32]=h,e[33]=f,e[34]=M):M=e[34];let j;e[35]!==f?(j=p.jsx("span",{className:"text-sm text-foreground",children:f}),e[35]=f,e[36]=j):j=e[36];let R;e[37]!==M||e[38]!==j?(R=p.jsxs("div",{children:[N,p.jsxs("div",{className:"flex items-center gap-2",children:[M,j]})]}),e[37]=M,e[38]=j,e[39]=R):R=e[39];let A;e[40]!==a||e[41]!==i?(A=i&&p.jsxs("div",{children:[p.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"Agent"}),p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(qt,{icon:a,name:i,size:"xs",fallbackIcon:p.jsx(Ui,{}),className:"shrink-0 size-5! min-w-5! rounded-md"}),p.jsx("span",{className:"text-sm text-foreground",children:i})]})]}),e[40]=a,e[41]=i,e[42]=A):A=e[42];let D;return e[43]!==T||e[44]!==R||e[45]!==A||e[46]!==w?(D=p.jsxs("div",{className:"px-5 md:px-6 py-5 border-b border-border grid grid-cols-1 md:grid-cols-2 gap-x-6 gap-y-4 text-sm",children:[w,T,R,A]}),e[43]=T,e[44]=R,e[45]=A,e[46]=w,e[47]=D):D=e[47],D}function vw(n){const e=_.c(72),{thread:t,usage:r,members:s,connections:o,virtualMcps:i,onClick:l,lastRowRef:a}=n;let c,u;if(e[0]!==o||e[1]!==t||e[2]!==i){const se=Zl(t);c=ea(se,i,o,"—"),u=ta(se,i,o),e[0]=o,e[1]=t,e[2]=i,e[3]=c,e[4]=u}else c=e[3],u=e[4];const d=u;let f;if(e[5]!==s||e[6]!==t.created_by){const se=Wh(s);let ae;e[8]!==t.created_by?(ae=Te=>Te.userId===t.created_by,e[8]=t.created_by,e[9]=ae):ae=e[9],f=se.find(ae),e[5]=s,e[6]=t.created_by,e[7]=f}else f=e[7];const h=f;let m;e[10]!==h?.user.email||e[11]!==h?.user.name||e[12]!==t.created_by?(m=h?.user.name??h?.user.email??t.created_by?.substring(0,8)??"—",e[10]=h?.user.email,e[11]=h?.user.name,e[12]=t.created_by,e[13]=m):m=e[13];const g=m,x=h?.user.image??void 0;let y,b;if(e[14]!==t.created_at){const se=new Date(t.created_at);y=se.toLocaleDateString("en-US",{month:"short",day:"numeric"}),b=se.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"}),e[14]=t.created_at,e[15]=y,e[16]=b}else y=e[15],b=e[16];const k=b,S=Rn[t.status]??Rn.completed,v=S.icon;let w;e[17]!==t.title?(w=p.jsx(Ge,{className:"min-w-0 pr-2 pl-4 md:pr-4",children:p.jsx("div",{className:"font-medium text-foreground truncate",children:t.title})}),e[17]=t.title,e[18]=w):w=e[18];let C;e[19]===Symbol.for("react.memo_cache_sentinel")?(C=p.jsx(Ui,{}),e[19]=C):C=e[19];let T;e[20]!==d||e[21]!==c?(T=p.jsx(qt,{icon:d,name:c,size:"xs",fallbackIcon:C,className:"shrink-0 size-5! min-w-5! rounded-md"}),e[20]=d,e[21]=c,e[22]=T):T=e[22];let N;e[23]!==c?(N=p.jsx("span",{className:"truncate",children:c}),e[23]=c,e[24]=N):N=e[24];let M;e[25]!==T||e[26]!==N?(M=p.jsx(Ge,{className:"w-36 px-3 text-muted-foreground",children:p.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[T,N]})}),e[25]=T,e[26]=N,e[27]=M):M=e[27];let j;e[28]!==x||e[29]!==g?(j=p.jsx(lu,{url:x,fallback:g,shape:"circle",size:"2xs",className:"shrink-0"}),e[28]=x,e[29]=g,e[30]=j):j=e[30];let R;e[31]!==g?(R=p.jsx("span",{className:"truncate",children:g}),e[31]=g,e[32]=R):R=e[32];let A;e[33]!==j||e[34]!==R?(A=p.jsx(Ge,{className:"w-28 px-3 text-muted-foreground",children:p.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[j,R]})}),e[33]=j,e[34]=R,e[35]=A):A=e[35];let D;e[36]!==v||e[37]!==S.iconClassName?(D=p.jsx(v,{size:14,className:S.iconClassName}),e[36]=v,e[37]=S.iconClassName,e[38]=D):D=e[38];let I;e[39]!==S.labelColor?(I=ee("text-sm",S.labelColor),e[39]=S.labelColor,e[40]=I):I=e[40];let $;e[41]!==S.label||e[42]!==I?($=p.jsx("span",{className:I,children:S.label}),e[41]=S.label,e[42]=I,e[43]=$):$=e[43];let L;e[44]!==D||e[45]!==$?(L=p.jsx(Ge,{className:"w-24 px-3",children:p.jsxs("div",{className:"flex items-center gap-1.5",children:[D,$]})}),e[44]=D,e[45]=$,e[46]=L):L=e[46];let z;e[47]!==r?(z=r?Yl(r.totalTokens):"—",e[47]=r,e[48]=z):z=e[48];let F;e[49]!==z?(F=p.jsx(Ge,{className:"w-24 px-3 text-right tabular-nums text-muted-foreground",children:z}),e[49]=z,e[50]=F):F=e[50];let U;e[51]!==r?(U=r&&r.costUsd>0?Ql(r.costUsd):"—",e[51]=r,e[52]=U):U=e[52];let Y;e[53]!==U?(Y=p.jsx(Ge,{className:"w-24 px-3 text-right tabular-nums text-muted-foreground",children:U}),e[53]=U,e[54]=Y):Y=e[54];let K;e[55]!==y?(K=p.jsx("div",{children:y}),e[55]=y,e[56]=K):K=e[56];let Q;e[57]!==k?(Q=p.jsx("div",{className:"text-xs text-muted-foreground/60",children:k}),e[57]=k,e[58]=Q):Q=e[58];let ne;e[59]!==K||e[60]!==Q?(ne=p.jsxs(Ge,{className:"w-32 px-3 pr-5 text-muted-foreground",children:[K,Q]}),e[59]=K,e[60]=Q,e[61]=ne):ne=e[61];let re;return e[62]!==a||e[63]!==l||e[64]!==A||e[65]!==L||e[66]!==F||e[67]!==Y||e[68]!==ne||e[69]!==w||e[70]!==M?(re=p.jsxs(Ks,{ref:a,className:"h-14 md:h-16 cursor-pointer hover:bg-muted/40 transition-colors border-b-0",onClick:l,children:[w,M,A,L,F,Y,ne]}),e[62]=a,e[63]=l,e[64]=A,e[65]=L,e[66]=F,e[67]=Y,e[68]=ne,e[69]=w,e[70]=M,e[71]=re):re=e[71],re}const _i=100;function ww(n){const e=_.c(37),{client:t,locator:r,thread:s,connections:o,virtualMcps:i,members:l,selectedIndex:a,total:c,onPrev:u,onNext:d}=n;let f;e[0]!==r||e[1]!==s.id?(f=Qe.threadMessages(r,s.id),e[0]=r,e[1]=s.id,e[2]=f):f=e[2];let h;e[3]!==t||e[4]!==s.id?(h=async R=>{const{pageParam:A}=R,D=A===void 0?0:A;if(!t)throw new Error("MCP client is not available");const I=await t.callTool({name:"COLLECTION_THREAD_MESSAGES_LIST",arguments:{thread_id:s.id,limit:_i,offset:D}});return I.structuredContent??I},e[3]=t,e[4]=s.id,e[5]=h):h=e[5];let m;e[6]!==f||e[7]!==h?(m={queryKey:f,queryFn:h,initialPageParam:0,getNextPageParam:Nw,staleTime:6e4},e[6]=f,e[7]=h,e[8]=m):m=e[8];const{data:g,fetchNextPage:x,hasNextPage:y,isFetchingNextPage:b}=gp(m);let k;e[9]!==g.pages?(k=g.pages.flatMap(Tw).filter(Cw),e[9]=g.pages,e[10]=k):k=e[10];const S=k,v=tw(S);let w;e[11]!==x||e[12]!==y||e[13]!==b?(w=()=>{y&&!b&&x()},e[11]=x,e[12]=y,e[13]=b,e[14]=w):w=e[14];const C=Wi(w,y??!1,b);let T;e[15]!==o||e[16]!==d||e[17]!==u||e[18]!==a||e[19]!==s||e[20]!==c||e[21]!==i?(T=p.jsx(Li,{thread:s,connections:o,virtualMcps:i,selectedIndex:a,total:c,onPrev:u,onNext:d}),e[15]=o,e[16]=d,e[17]=u,e[18]=a,e[19]=s,e[20]=c,e[21]=i,e[22]=T):T=e[22];let N;e[23]!==o||e[24]!==l||e[25]!==s||e[26]!==i?(N=p.jsx(Sw,{thread:s,connections:o,virtualMcps:i,members:l}),e[23]=o,e[24]=l,e[25]=s,e[26]=i,e[27]=N):N=e[27];let M;e[28]!==b||e[29]!==C||e[30]!==v||e[31]!==S.length?(M=S.length===0?p.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"No messages in this chat"}):p.jsx("div",{className:"flex-1 overflow-y-auto min-h-0",children:p.jsxs("div",{className:"flex flex-col min-w-0 max-w-2xl mx-auto w-full",children:[v.map((R,A)=>p.jsx("div",{ref:A===v.length-1?C:void 0,children:p.jsx(nw,{pair:R,isLastPair:A===v.length-1,status:"ready"})},`pair-${R.user?.id??R.assistant?.id}`)),b&&p.jsx("div",{className:"py-4 text-center text-xs text-muted-foreground",children:"Loading more\\u2026"})]})}),e[28]=b,e[29]=C,e[30]=v,e[31]=S.length,e[32]=M):M=e[32];let j;return e[33]!==T||e[34]!==N||e[35]!==M?(j=p.jsxs(p.Fragment,{children:[T,N,M]}),e[33]=T,e[34]=N,e[35]=M,e[36]=j):j=e[36],j}function Cw(n){return n.role==="user"||n.role==="assistant"}function Tw(n){return n.items??[]}function Nw(n,e){const t=n,r=e;if(!((t?.items?.length??0)<_i))return r.length*_i}function Uh(n){const e=_.c(39),{thread:t,client:r,locator:s,connections:o,virtualMcps:i,members:l,selectedIndex:a,total:c,onPrev:u,onNext:d}=n;let f;e[0]!==o||e[1]!==d||e[2]!==u||e[3]!==a||e[4]!==t||e[5]!==c||e[6]!==i?(f=p.jsx(Li,{thread:t,connections:o,virtualMcps:i,selectedIndex:a,total:c,onPrev:u,onNext:d}),e[0]=o,e[1]=d,e[2]=u,e[3]=a,e[4]=t,e[5]=c,e[6]=i,e[7]=f):f=e[7];let h;e[8]===Symbol.for("react.memo_cache_sentinel")?(h=p.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Failed to load messages"}),e[8]=h):h=e[8];let m;e[9]!==f?(m=p.jsxs(p.Fragment,{children:[f,h]}),e[9]=f,e[10]=m):m=e[10];let g;e[11]!==o||e[12]!==d||e[13]!==u||e[14]!==a||e[15]!==t||e[16]!==c||e[17]!==i?(g=p.jsx(Li,{thread:t,connections:o,virtualMcps:i,selectedIndex:a,total:c,onPrev:u,onNext:d}),e[11]=o,e[12]=d,e[13]=u,e[14]=a,e[15]=t,e[16]=c,e[17]=i,e[18]=g):g=e[18];let x;e[19]===Symbol.for("react.memo_cache_sentinel")?(x=p.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Loading conversation\\u2026"}),e[19]=x):x=e[19];let y;e[20]!==g?(y=p.jsxs(p.Fragment,{children:[g,x]}),e[20]=g,e[21]=y):y=e[21];let b;e[22]!==r||e[23]!==o||e[24]!==s||e[25]!==l||e[26]!==d||e[27]!==u||e[28]!==a||e[29]!==t||e[30]!==c||e[31]!==i?(b=p.jsx(ww,{client:r,locator:s,thread:t,connections:o,virtualMcps:i,members:l,selectedIndex:a,total:c,onPrev:u,onNext:d}),e[22]=r,e[23]=o,e[24]=s,e[25]=l,e[26]=d,e[27]=u,e[28]=a,e[29]=t,e[30]=c,e[31]=i,e[32]=b):b=e[32];let k;e[33]!==y||e[34]!==b?(k=p.jsx(E.Suspense,{fallback:y,children:b}),e[33]=y,e[34]=b,e[35]=k):k=e[35];let S;return e[36]!==m||e[37]!==k?(S=p.jsx(Xc,{fallback:m,children:k}),e[36]=m,e[37]=k,e[38]=S):S=e[38],S}const $i=50;function cT(n){const e=_.c(29),{client:t,locator:r,membersData:s,allConnections:o,allVirtualMcps:i,dateRange:l,searchQuery:a,filterAgentIds:c,filterUserIds:u,filterStatus:d}=n,[f,h]=E.useState(null),m=l.startDate.toISOString(),g=l.endDate.toISOString(),x=JSON.stringify({startDate:m,endDate:g,search:a,agentIds:c,userIds:u,status:d}),{data:y,fetchNextPage:b,hasNextPage:k,isFetchingNextPage:S,isLoading:v}=Qc({queryKey:Qe.threadsInfinite(r,x),queryFn:async J=>{const{pageParam:ie}=J,ue=ie===void 0?0:ie;if(!t)throw new Error("MCP client is not available");const it=await t.callTool({name:"COLLECTION_THREADS_LIST",arguments:{limit:$i,offset:ue,startDate:m,endDate:g,...a?{search:a}:{},...c&&c.length>0?{agentId:c[0]}:{},...u&&u.length>0?{userId:u[0]}:{},...d&&d!=="all"?{status:d}:{}}});return it.structuredContent??it},initialPageParam:0,getNextPageParam:Ow,staleTime:3e4}),w=(y?.pages??[]).flatMap(Iw),C=w.map(jw),{data:T}=Mr({queryKey:Qe.monitoringThreadUsage(r,JSON.stringify({ids:C,startDate:m,endDate:g})),queryFn:async()=>{if(!t)throw new Error("MCP client is not available");const J=await t.callTool({name:"MONITORING_THREAD_USAGE",arguments:{threadIds:C,startDate:m,endDate:g}});return J.structuredContent??J},enabled:!!t&&C.length>0,staleTime:3e4}),N=new Map((T?.items??[]).map(Aw)),[M,j]=E.useState(null),[R,A]=E.useState("desc");let D;e[0]!==M?(D=J=>{M===J?A(Ew):(j(J),A("desc"))},e[0]=M,e[1]=D):D=e[1];const I=D,$=J=>{const ie=N.get(J);return ie?M==="cost"?ie.costUsd:ie.totalTokens:0},L=M?[...w].sort((J,ie)=>{const ue=$(J.id),it=$(ie.id);return R==="desc"?it-ue:ue-it}):w,z=f!==null?L[f]??null:null;let F;e[2]!==b||e[3]!==k||e[4]!==S?(F=()=>{k&&!S&&b()},e[2]=b,e[3]=k,e[4]=S,e[5]=F):F=e[5];const Y=Wi(F,k??!1,S),K=!!a||(c?.length??0)>0||(u?.length??0)>0||d&&d!=="all";let Q;e[6]===Symbol.for("react.memo_cache_sentinel")?(Q=()=>h(Mw),e[6]=Q):Q=e[6];const ne=Q,re=()=>h(J=>J!==null&&J<L.length-1?J+1:J),se="flex-1 flex flex-col overflow-auto min-w-0",ae="mx-auto w-full max-w-[1200px] px-4 md:px-10 flex flex-col flex-1 min-h-0",Te="flex-1 flex flex-col min-w-0",W="flex-1 min-w-0 pt-1",te="min-w-0",he=v?p.jsx("div",{className:"flex flex-1 items-center justify-center py-20",children:p.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading\\u2026"})}):w.length===0?p.jsx("div",{className:"flex flex-1 items-center justify-center py-20",children:p.jsx(Yo,{title:K?"No matching chats":"No chats in this time range",description:K?"Try adjusting your filters or search query.":"Try expanding the time range to see older chats."})}):p.jsxs(p.Fragment,{children:[p.jsxs(nu,{className:"w-full border-collapse",children:[p.jsx(ru,{className:"border-b-0 z-20",children:p.jsxs(Ks,{className:"h-9 hover:bg-transparent border-b border-border",children:[p.jsx(Je,{className:"pl-4 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide",children:"Title"}),p.jsx(Je,{className:"w-36 px-3 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide",children:"Agent"}),p.jsx(Je,{className:"w-28 px-3 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide",children:"User"}),p.jsx(Je,{className:"w-24 px-3 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide",children:"Status"}),p.jsx(Je,{className:"w-24 px-3 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide text-right",children:p.jsxs("button",{type:"button",onClick:()=>I("tokens"),className:"inline-flex items-center gap-1 ml-auto hover:text-foreground transition-colors uppercase",children:["Tokens",M==="tokens"&&(R==="desc"?p.jsx(Zr,{size:12}):p.jsx(Qo,{size:12}))]})}),p.jsx(Je,{className:"w-24 px-3 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide text-right",children:p.jsxs("button",{type:"button",onClick:()=>I("cost"),className:"inline-flex items-center gap-1 ml-auto hover:text-foreground transition-colors uppercase",children:["Cost",M==="cost"&&(R==="desc"?p.jsx(Zr,{size:12}):p.jsx(Qo,{size:12}))]})}),p.jsx(Je,{className:"w-32 px-3 pr-5 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide",children:"Date"})]})}),p.jsx(su,{children:L.map((J,ie)=>p.jsx(vw,{thread:J,usage:N.get(J.id),members:s,connections:o,virtualMcps:i,onClick:()=>h(ie),lastRowRef:ie===L.length-1?Y:void 0},J.id))})]}),S&&p.jsx("div",{className:"py-4 text-center text-sm text-muted-foreground",children:"Loading more..."})]});let ge;e[7]!==he?(ge=p.jsx("div",{className:ae,children:p.jsx("div",{className:Te,children:p.jsx("div",{className:W,children:p.jsx("div",{className:te,children:he})})})}),e[7]=he,e[8]=ge):ge=e[8];const Be=f!==null;let Nt;e[9]===Symbol.for("react.memo_cache_sentinel")?(Nt=J=>{J||h(null)},e[9]=Nt):Nt=e[9];let Fe;e[10]!==o||e[11]!==i||e[12]!==t||e[13]!==L||e[14]!==re||e[15]!==ne||e[16]!==r||e[17]!==s||e[18]!==z||e[19]!==f?(Fe=z&&f!==null&&p.jsx(Uh,{thread:z,client:t,locator:r,connections:o,virtualMcps:i,members:s,selectedIndex:f,total:L.length,onPrev:ne,onNext:re}),e[10]=o,e[11]=i,e[12]=t,e[13]=L,e[14]=re,e[15]=ne,e[16]=r,e[17]=s,e[18]=z,e[19]=f,e[20]=Fe):Fe=e[20];let He;e[21]!==Fe?(He=p.jsx(Hi,{className:"sm:max-w-2xl flex flex-col p-0 gap-0",children:Fe}),e[21]=Fe,e[22]=He):He=e[22];let Ve;e[23]!==Be||e[24]!==He?(Ve=p.jsx(Vi,{open:Be,onOpenChange:Nt,children:He}),e[23]=Be,e[24]=He,e[25]=Ve):Ve=e[25];let mt;return e[26]!==ge||e[27]!==Ve?(mt=p.jsxs("div",{className:se,children:[ge,Ve]}),e[26]=ge,e[27]=Ve,e[28]=mt):mt=e[28],mt}function Mw(n){return n!==null&&n>0?n-1:n}function Ew(n){return n==="desc"?"asc":"desc"}function Aw(n){return[n.threadId,{calls:n.calls,inputTokens:n.inputTokens,outputTokens:n.outputTokens,totalTokens:n.totalTokens,costUsd:n.costUsd}]}function jw(n){return n.id}function Iw(n){return n.items??[]}function Ow(n,e){const t=n,r=e;if(!((t?.items?.length??0)<$i))return r.length*$i}const zi=50;function Kr(n){const e=_.c(10),{title:t,value:r,subtitle:s}=n;let o;e[0]!==t?(o=p.jsx("span",{className:"text-sm text-foreground/70",children:t}),e[0]=t,e[1]=o):o=e[1];let i;e[2]!==r?(i=p.jsx("span",{className:"text-3xl font-normal tabular-nums",children:r}),e[2]=r,e[3]=i):i=e[3];let l;e[4]!==s?(l=s&&p.jsx("span",{className:"text-xs text-muted-foreground",children:s}),e[4]=s,e[5]=l):l=e[5];let a;return e[6]!==o||e[7]!==i||e[8]!==l?(a=p.jsxs(hp,{className:"pt-4 px-4 pb-5 gap-1",children:[o,i,l]}),e[6]=o,e[7]=i,e[8]=l,e[9]=a):a=e[9],a}function Rw(n){const e=_.c(27),{automationId:t,range:r}=n,{data:s,isLoading:o}=mp(t,r),i=s?.runs,l=s?.usage;let a;e[0]!==i?(a=i&&i.total>0?`${Math.round(i.completed/i.total*100)}%`:"—",e[0]=i,e[1]=a):a=e[1];const c=a,u=l&&l.truncated?`last ${l.sampledRuns} runs`:void 0;let d;e[2]!==o||e[3]!==i?.total?(d=o?"…":i?.total.toLocaleString()??"0",e[2]=o,e[3]=i?.total,e[4]=d):d=e[4];const f=i?`${i.completed} ok · ${i.failed} failed${i.inProgress>0?` · ${i.inProgress} running`:""}`:void 0;let h;e[5]!==d||e[6]!==f?(h=p.jsx(Kr,{title:"Runs",value:d,subtitle:f}),e[5]=d,e[6]=f,e[7]=h):h=e[7];const m=o?"…":c;let g;e[8]!==m?(g=p.jsx(Kr,{title:"Success rate",value:m}),e[8]=m,e[9]=g):g=e[9];let x;e[10]!==o||e[11]!==l?.totalTokens?(x=o?"…":Yl(l?.totalTokens??0),e[10]=o,e[11]=l?.totalTokens,e[12]=x):x=e[12];let y;e[13]!==x||e[14]!==u?(y=p.jsx(Kr,{title:"Tokens",value:x,subtitle:u}),e[13]=x,e[14]=u,e[15]=y):y=e[15];let b;e[16]!==o||e[17]!==l?(b=o?"…":l&&l.costUsd>0?Ql(l.costUsd):"—",e[16]=o,e[17]=l,e[18]=b):b=e[18];let k;e[19]!==b||e[20]!==u?(k=p.jsx(Kr,{title:"Cost",value:b,subtitle:u}),e[19]=b,e[20]=u,e[21]=k):k=e[21];let S;return e[22]!==k||e[23]!==h||e[24]!==g||e[25]!==y?(S=p.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3",children:[h,g,y,k]}),e[22]=k,e[23]=h,e[24]=g,e[25]=y,e[26]=S):S=e[26],S}function Dw(n){const e=_.c(39),{run:t,usage:r,onClick:s,lastRowRef:o}=n;let i,l;if(e[0]!==t.created_at){const T=new Date(t.created_at);i=T.toLocaleDateString("en-US",{month:"short",day:"numeric"}),l=T.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"}),e[0]=t.created_at,e[1]=i,e[2]=l}else i=e[1],l=e[2];const a=l,c=Rn[t.status]??Rn.completed,u=c.icon;let d;e[3]!==t.title?(d=p.jsx(Ge,{className:"min-w-0 pr-2 pl-4 md:pr-4",children:p.jsx("div",{className:"font-medium text-foreground truncate",children:t.title})}),e[3]=t.title,e[4]=d):d=e[4];let f;e[5]!==u||e[6]!==c.iconClassName?(f=p.jsx(u,{size:14,className:c.iconClassName}),e[5]=u,e[6]=c.iconClassName,e[7]=f):f=e[7];let h;e[8]!==c.labelColor?(h=ee("text-sm",c.labelColor),e[8]=c.labelColor,e[9]=h):h=e[9];let m;e[10]!==c.label||e[11]!==h?(m=p.jsx("span",{className:h,children:c.label}),e[10]=c.label,e[11]=h,e[12]=m):m=e[12];let g;e[13]!==f||e[14]!==m?(g=p.jsx(Ge,{className:"w-28 px-3",children:p.jsxs("div",{className:"flex items-center gap-1.5",children:[f,m]})}),e[13]=f,e[14]=m,e[15]=g):g=e[15];let x;e[16]!==r?(x=r?Yl(r.totalTokens):"—",e[16]=r,e[17]=x):x=e[17];let y;e[18]!==x?(y=p.jsx(Ge,{className:"w-24 px-3 text-right tabular-nums text-muted-foreground",children:x}),e[18]=x,e[19]=y):y=e[19];let b;e[20]!==r?(b=r&&r.costUsd>0?Ql(r.costUsd):"—",e[20]=r,e[21]=b):b=e[21];let k;e[22]!==b?(k=p.jsx(Ge,{className:"w-24 px-3 text-right tabular-nums text-muted-foreground",children:b}),e[22]=b,e[23]=k):k=e[23];let S;e[24]!==i?(S=p.jsx("div",{children:i}),e[24]=i,e[25]=S):S=e[25];let v;e[26]!==a?(v=p.jsx("div",{className:"text-xs text-muted-foreground/60",children:a}),e[26]=a,e[27]=v):v=e[27];let w;e[28]!==S||e[29]!==v?(w=p.jsxs(Ge,{className:"w-32 px-3 pr-5 text-muted-foreground",children:[S,v]}),e[28]=S,e[29]=v,e[30]=w):w=e[30];let C;return e[31]!==o||e[32]!==s||e[33]!==k||e[34]!==w||e[35]!==d||e[36]!==g||e[37]!==y?(C=p.jsxs(Ks,{ref:o,className:"h-14 cursor-pointer hover:bg-muted/40 transition-colors border-b-0",onClick:s,children:[d,g,y,k,w]}),e[31]=o,e[32]=s,e[33]=k,e[34]=w,e[35]=d,e[36]=g,e[37]=y,e[38]=C):C=e[38],C}function uT(n){const e=_.c(48),{automationId:t,triggerIds:r,range:s}=n,{org:o,locator:i}=Ct();let l;e[0]!==o.id||e[1]!==o.slug?(l={connectionId:fp,orgId:o.id,orgSlug:o.slug},e[0]=o.id,e[1]=o.slug,e[2]=l):l=e[2];const a=Fi(l),c=iu(),u=ip(),d=ap(),{data:f}=pp(),[h,m]=E.useState(null),g=r.length>0;let x;e[3]!==t||e[4]!==o.id||e[5]!==r?(x=Qe.automationRuns(o.id,t,r),e[3]=t,e[4]=o.id,e[5]=r,e[6]=x):x=e[6];let y;e[7]!==c||e[8]!==r?(y=async W=>{const{pageParam:te}=W,he=te===void 0?0:te;return await c.call("COLLECTION_THREADS_LIST",{limit:zi,offset:he,where:{trigger_ids:r}})},e[7]=c,e[8]=r,e[9]=y):y=e[9];let b;e[10]!==g||e[11]!==x||e[12]!==y?(b={queryKey:x,queryFn:y,initialPageParam:0,getNextPageParam:zw,enabled:g,staleTime:3e4},e[10]=g,e[11]=x,e[12]=y,e[13]=b):b=e[13];const{data:k,fetchNextPage:S,hasNextPage:v,isFetchingNextPage:w,isLoading:C}=Qc(b),T=(k?.pages??[]).flatMap($w),N=T.map(_w),{data:M}=Mr({queryKey:Qe.monitoringThreadUsage(i,JSON.stringify({ids:N,...s})),queryFn:async()=>await c.call("MONITORING_THREAD_USAGE",{threadIds:N,...s.startDate?{startDate:s.startDate}:{},...s.endDate?{endDate:s.endDate}:{}}),enabled:N.length>0,staleTime:3e4});let j;e[14]!==M?.items?(j=new Map((M?.items??[]).map(Lw)),e[14]=M?.items,e[15]=j):j=e[15];const R=j;let A;e[16]!==S||e[17]!==v||e[18]!==w?(A=()=>{v&&!w&&S()},e[16]=S,e[17]=v,e[18]=w,e[19]=A):A=e[19];const D=Wi(A,v??!1,w),I=h!==null?T[h]??null:null;let $;e[20]===Symbol.for("react.memo_cache_sentinel")?($=()=>m(Pw),e[20]=$):$=e[20];const L=$,z=()=>m(W=>W!==null&&W<T.length-1?W+1:W),F="flex flex-col gap-5";let U;e[21]!==t||e[22]!==s?(U=p.jsx(Rw,{automationId:t,range:s}),e[21]=t,e[22]=s,e[23]=U):U=e[23];const Y=g?C?p.jsx("div",{className:"py-16 text-center text-sm text-muted-foreground",children:"Loading runs…"}):T.length===0?p.jsx("div",{className:"py-16",children:p.jsx(Yo,{title:"No runs yet",description:"This automation hasn't run yet. Trigger it or wait for a starter to fire."})}):p.jsxs(nu,{className:"w-full border-collapse",children:[p.jsx(ru,{className:"border-b-0",children:p.jsxs(Ks,{className:"h-9 hover:bg-transparent border-b border-border",children:[p.jsx(Je,{className:"pl-4 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide",children:"Run"}),p.jsx(Je,{className:"w-28 px-3 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide",children:"Status"}),p.jsx(Je,{className:"w-24 px-3 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide text-right",children:"Tokens"}),p.jsx(Je,{className:"w-24 px-3 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide text-right",children:"Cost"}),p.jsx(Je,{className:"w-32 px-3 pr-5 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide",children:"Started"})]})}),p.jsx(su,{children:T.map((W,te)=>p.jsx(Dw,{run:W,usage:R.get(W.id),onClick:()=>m(te),lastRowRef:te===T.length-1?D:void 0},W.id))})]}):p.jsx("div",{className:"py-16",children:p.jsx(Yo,{title:"No starters yet",description:"Add a starter (cron, event, or webhook) to start collecting runs."})});let K;e[24]!==w?(K=w&&p.jsx("div",{className:"py-4 text-center text-sm text-muted-foreground",children:"Loading more…"}),e[24]=w,e[25]=K):K=e[25];const Q=h!==null;let ne;e[26]===Symbol.for("react.memo_cache_sentinel")?(ne=W=>{W||m(null)},e[26]=ne):ne=e[26];let re;e[27]!==u||e[28]!==d||e[29]!==a||e[30]!==z||e[31]!==L||e[32]!==i||e[33]!==f||e[34]!==T||e[35]!==I||e[36]!==h?(re=I&&h!==null&&p.jsx(Uh,{thread:I,client:a,locator:i,connections:u,virtualMcps:d,members:f,selectedIndex:h,total:T.length,onPrev:L,onNext:z}),e[27]=u,e[28]=d,e[29]=a,e[30]=z,e[31]=L,e[32]=i,e[33]=f,e[34]=T,e[35]=I,e[36]=h,e[37]=re):re=e[37];let se;e[38]!==re?(se=p.jsx(Hi,{className:"sm:max-w-2xl flex flex-col p-0 gap-0",children:re}),e[38]=re,e[39]=se):se=e[39];let ae;e[40]!==Q||e[41]!==se?(ae=p.jsx(Vi,{open:Q,onOpenChange:ne,children:se}),e[40]=Q,e[41]=se,e[42]=ae):ae=e[42];let Te;return e[43]!==Y||e[44]!==K||e[45]!==ae||e[46]!==U?(Te=p.jsxs("div",{className:F,children:[U,Y,K,ae]}),e[43]=Y,e[44]=K,e[45]=ae,e[46]=U,e[47]=Te):Te=e[47],Te}function Pw(n){return n!==null&&n>0?n-1:n}function Lw(n){return[n.threadId,{calls:n.calls,inputTokens:n.inputTokens,outputTokens:n.outputTokens,totalTokens:n.totalTokens,costUsd:n.costUsd}]}function _w(n){return n.id}function $w(n){return n.items??[]}function zw(n,e){const t=n,r=e;if(!((t?.items?.length??0)<zi))return r.length*zi}export{cT as $,sT as A,ZC as B,tT as C,de as D,Ml as E,Wb as F,Mv as G,xe as H,RS as I,DS as J,PS as K,uT as L,uo as M,_S as N,kv as O,Nm as P,oT as Q,OS as R,QC as S,eT as T,iT as U,Yl as V,Ql as W,kw as X,aT as Y,lT as Z,Wh as _,Hf as a,ve as b,Ff as c,wm as d,fe as e,YC as f,Yi as g,De as h,XC as i,KC as j,GC as k,$b as l,JC as m,Bb as n,MS as o,Df as p,qC as q,tw as r,Qi as s,Cu as t,jb as u,Sm as v,nT as w,nw as x,rT as y,bv as z};