@panphora/clayjs 1.17.0 → 1.18.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (467) hide show
  1. package/dist/all.js +1 -1
  2. package/dist/clay-dom.js +1 -1
  3. package/dist/clay-events.js +1 -1
  4. package/dist/clay-internals.js +1 -1
  5. package/dist/clay-options.js +1 -1
  6. package/dist/clay-router.js +1 -1
  7. package/dist/clay-ui.js +1 -1
  8. package/dist/clay-utils.js +1 -1
  9. package/dist/clay.js +1 -1
  10. package/dist/clay.standalone.js +72474 -62090
  11. package/dist/m/attrs/{save-freeze-MYNVXREN.js → save-freeze-LWGF6XUN.js} +1 -1
  12. package/dist/m/c-2GRUM77Q.js +30 -0
  13. package/dist/m/c-2KIEGNC4.js +1 -0
  14. package/dist/m/{c-AMSNPOCX.js → c-2KL3BD52.js} +1 -1
  15. package/dist/m/c-2ZZBC45O.js +1 -0
  16. package/dist/m/c-372N6H3B.js +1 -0
  17. package/dist/m/{c-4WKFKEKF.js → c-3G2DGZUP.js} +1 -1
  18. package/dist/m/c-3LDGIBMN.js +1 -0
  19. package/dist/m/c-3O7OBDCM.js +1 -0
  20. package/dist/m/c-4ASQPRQL.js +1 -0
  21. package/dist/m/c-4TXNLX4K.js +6 -0
  22. package/dist/m/c-4YU3BR4D.js +6 -0
  23. package/dist/m/c-5734MF2P.js +1 -0
  24. package/dist/m/c-57XDY6HC.js +1 -0
  25. package/dist/m/{c-KAU6E43D.js → c-5B4YBZXC.js} +1 -1
  26. package/dist/m/c-5ONTYIUI.js +1 -0
  27. package/dist/m/c-5OOVFCJM.js +1 -0
  28. package/dist/m/{c-3XIRD4NU.js → c-5T6NZHNM.js} +1 -1
  29. package/dist/m/{c-74MGYWZF.js → c-5ZQV7KC4.js} +1 -1
  30. package/dist/m/{c-7OLLJPWP.js → c-6DB2OLRJ.js} +1 -1
  31. package/dist/m/c-6DNRCPNM.js +1 -0
  32. package/dist/m/c-6UGWFMQC.js +2 -0
  33. package/dist/m/c-7K4SCQB7.js +1 -0
  34. package/dist/m/c-7MG5RU63.js +1 -0
  35. package/dist/m/c-7PRJCA3E.js +1 -0
  36. package/dist/m/c-A6L3FMUS.js +1 -0
  37. package/dist/m/c-AMU3BPPR.js +4 -0
  38. package/dist/m/{c-Y5HBBIQ4.js → c-AMYEFA2E.js} +1 -1
  39. package/dist/m/c-AQYCG7QW.js +1 -0
  40. package/dist/m/c-ATKAOH23.js +1 -0
  41. package/dist/m/c-B5CS55WR.js +1 -0
  42. package/dist/m/c-B5UJQT7W.js +1 -0
  43. package/dist/m/c-B7J4K2AE.js +3 -0
  44. package/dist/m/c-BHZYSHW4.js +1 -0
  45. package/dist/m/{c-VHM5XQHK.js → c-BIJALSRD.js} +1 -1
  46. package/dist/m/c-BJ7YQ5QZ.js +1 -0
  47. package/dist/m/{c-KIPQJX4B.js → c-BRLCTNMC.js} +1 -1
  48. package/dist/m/{c-VE6ZMYMC.js → c-BUAYFEV5.js} +1 -1
  49. package/dist/m/c-C6IPRG34.js +1 -0
  50. package/dist/m/{c-KU3ZFADW.js → c-CAS3NND4.js} +1 -1
  51. package/dist/m/{c-PS5ARVWR.js → c-CCQ25GFY.js} +1 -1
  52. package/dist/m/c-CJFDLD43.js +1 -0
  53. package/dist/m/c-COPTL5WB.js +1 -0
  54. package/dist/m/c-D3E4WJ4M.js +166 -0
  55. package/dist/m/c-D5IKEKXW.js +7 -0
  56. package/dist/m/c-DHBRA6DL.js +1 -0
  57. package/dist/m/c-DKLS74XB.js +72 -0
  58. package/dist/m/c-DVYGFTSK.js +3 -0
  59. package/dist/m/c-E3ZXARWA.js +1 -0
  60. package/dist/m/c-EK63G3CG.js +1 -0
  61. package/dist/m/c-ERQSNR6K.js +13 -0
  62. package/dist/m/c-EVYAISP3.js +1 -0
  63. package/dist/m/c-EXKHPOVC.js +3 -0
  64. package/dist/m/{c-QJ4OM3G6.js → c-FWKHM4E7.js} +1 -1
  65. package/dist/m/{c-4Q2XTQ2N.js → c-GBKB5WDL.js} +1 -1
  66. package/dist/m/c-GNDL3TKB.js +1 -0
  67. package/dist/m/c-GRWMD6O5.js +1 -0
  68. package/dist/m/c-GRXHHFPO.js +1 -0
  69. package/dist/m/c-HG2C77BM.js +4 -0
  70. package/dist/m/c-HHGJBU4D.js +1 -0
  71. package/dist/m/c-HMV6P4RX.js +1 -0
  72. package/dist/m/c-HMYWIHFG.js +1 -0
  73. package/dist/m/c-HT2DKBV2.js +1 -0
  74. package/dist/m/c-I2SCCUEW.js +1 -0
  75. package/dist/m/{c-TJ6WOJL3.js → c-ICJYHABF.js} +2 -2
  76. package/dist/m/c-IMZCWYHR.js +7 -0
  77. package/dist/m/c-IVMD3FEM.js +1 -0
  78. package/dist/m/{c-WDC5GVKU.js → c-IVTRVENZ.js} +1 -1
  79. package/dist/m/c-JKZJIUIP.js +1 -0
  80. package/dist/m/{c-UDUUJPFZ.js → c-JNLX3RJB.js} +1 -1
  81. package/dist/m/c-K3ADYNLU.js +1 -0
  82. package/dist/m/c-KGHVFRR3.js +1 -0
  83. package/dist/m/{c-5QWQ7A5L.js → c-KJJPV77R.js} +1 -1
  84. package/dist/m/{c-CZUSOB7V.js → c-KNPDOMDY.js} +1 -1
  85. package/dist/m/{c-EZU56NQV.js → c-KP64LT2A.js} +2 -2
  86. package/dist/m/c-KQ7E3PYY.js +1 -0
  87. package/dist/m/c-L3F5ZLIV.js +1 -0
  88. package/dist/m/{c-3RUU4TPX.js → c-L42OLXWM.js} +3 -2
  89. package/dist/m/c-L5VFATT6.js +1 -0
  90. package/dist/m/c-L7JL5TL3.js +3 -0
  91. package/dist/m/c-LKSL4AUJ.js +1 -0
  92. package/dist/m/c-M6FNQCTQ.js +1 -0
  93. package/dist/m/c-MCOOHCSG.js +1 -0
  94. package/dist/m/c-MHI3GYKF.js +1 -0
  95. package/dist/m/c-MWXFLW4J.js +1 -0
  96. package/dist/m/{c-5RJFTLSF.js → c-NEL7HQW3.js} +1 -1
  97. package/dist/m/{c-DCXOXBF3.js → c-NQJRVJ56.js} +1 -1
  98. package/dist/m/c-NWX3MFT4.js +1 -0
  99. package/dist/m/{c-HPURYVZS.js → c-OJYM642Q.js} +1 -1
  100. package/dist/m/c-OKXI52N7.js +1 -0
  101. package/dist/m/{c-R3L7ZJGB.js → c-OPLUZR3A.js} +1 -1
  102. package/dist/m/{c-GSFIGKOP.js → c-OTMKN2OO.js} +1 -1
  103. package/dist/m/{c-6NC5I2TV.js → c-OYRZ7XG2.js} +1 -1
  104. package/dist/m/{c-EVCQ3BKA.js → c-P3OFYUMA.js} +1 -1
  105. package/dist/m/c-PLN76GF3.js +6 -0
  106. package/dist/m/c-PLP4JKFC.js +1 -0
  107. package/dist/m/c-Q26MME6N.js +1 -0
  108. package/dist/m/{c-S7H2DRCB.js → c-Q3XOWZEV.js} +1 -1
  109. package/dist/m/{c-FRLHSY7E.js → c-QIKT6SKM.js} +1 -1
  110. package/dist/m/c-QIXT3Q7C.js +28 -0
  111. package/dist/m/c-QO4HNGCQ.js +1 -0
  112. package/dist/m/{c-JU3NK25H.js → c-R27DWQKX.js} +1 -1
  113. package/dist/m/{c-RSMOODDU.js → c-R2XUODVY.js} +1 -1
  114. package/dist/m/{c-QNKREOL6.js → c-R7LBFMF5.js} +1 -1
  115. package/dist/m/c-RND3G2S2.js +1 -0
  116. package/dist/m/{c-Q622NS2Y.js → c-S2U6NJU4.js} +1 -1
  117. package/dist/m/c-SPZPGD3R.js +1 -0
  118. package/dist/m/c-SW4YEG2D.js +8 -0
  119. package/dist/m/c-T637T7SN.js +1 -0
  120. package/dist/m/c-TJAXGIRV.js +1 -0
  121. package/dist/m/{c-RYUXUUBX.js → c-TNEM3RNM.js} +1 -1
  122. package/dist/m/c-TTB5EK4S.js +32 -0
  123. package/dist/m/c-U7SHNWDH.js +1 -0
  124. package/dist/m/c-UDHIVLYH.js +20 -0
  125. package/dist/m/{c-BBVGTQG7.js → c-UGNV5MFB.js} +1 -1
  126. package/dist/m/{c-QICP2YR5.js → c-UORXLSD3.js} +1 -1
  127. package/dist/m/c-UPD33ZPE.js +1 -0
  128. package/dist/m/c-URSMSFCB.js +1 -0
  129. package/dist/m/c-UY4QX42B.js +1 -0
  130. package/dist/m/c-V44KWI2L.js +4 -0
  131. package/dist/m/c-VILENZTD.js +1 -0
  132. package/dist/m/{c-HDDEEL77.js → c-VJYEVRYK.js} +1 -1
  133. package/dist/m/{c-SMBZG5X4.js → c-VR2BJ4AN.js} +1 -1
  134. package/dist/m/c-W4JCVLAB.js +1 -0
  135. package/dist/m/c-W6DQSHXI.js +135 -0
  136. package/dist/m/c-WBGWGOM7.js +1 -0
  137. package/dist/m/{c-4L3BTFRK.js → c-WCXLG3MV.js} +1 -1
  138. package/dist/m/c-WGW764WX.js +1 -0
  139. package/dist/m/c-WMRJKQ2V.js +5 -0
  140. package/dist/m/c-WNTYKCDG.js +1 -0
  141. package/dist/m/c-WQWIRWO3.js +72 -0
  142. package/dist/m/c-X5LNHET5.js +1 -0
  143. package/dist/m/{c-I2ZATQCD.js → c-X5TSXZYJ.js} +2 -2
  144. package/dist/m/c-XGH4GS2T.js +1 -0
  145. package/dist/m/c-Y6F2FORL.js +1 -0
  146. package/dist/m/c-YBKHUAK7.js +10 -0
  147. package/dist/m/c-YBSS55KU.js +20 -0
  148. package/dist/m/c-YCLU4UNT.js +2 -0
  149. package/dist/m/c-YVZ2L7CE.js +1 -0
  150. package/dist/m/c-ZK4GIZH2.js +1 -0
  151. package/dist/m/c-ZRXJD4G6.js +1 -0
  152. package/dist/m/c-ZWBI4HYK.js +1 -0
  153. package/dist/m/core/{admin-attrs-QHOKPJ7W.js → admin-attrs-YY7T5FGU.js} +1 -1
  154. package/dist/m/core/autosave-S6OMNDCK.js +1 -0
  155. package/dist/m/core/conflict-notice-IWHMHH43.js +1 -0
  156. package/dist/m/core/{host-permission-FNXVEFNE.js → host-permission-6EVJGNPL.js} +1 -1
  157. package/dist/m/core/is-edit-mode-GCX6767E.js +1 -0
  158. package/dist/m/core/{persist-JFYRHMRJ.js → persist-UKXV5KLA.js} +1 -1
  159. package/dist/m/core/recovery-DRFZRJED.js +1 -0
  160. package/dist/m/core/save-LYY7K6U7.js +1 -0
  161. package/dist/m/core/save-core-MKRPSEEO.js +1 -0
  162. package/dist/m/core/snapshot-NU3YM6GR.js +1 -0
  163. package/dist/m/core/unsaved-warning-7QTKEN7Z.js +1 -0
  164. package/dist/m/internals/{index-PVXGPUDA.js → index-TGLQINN3.js} +1 -1
  165. package/dist/m/loader-3BBNZZGM.js +1 -0
  166. package/dist/m/manifest-26C55578.js +1 -0
  167. package/dist/m/manifest-edit-4396A009.js +1 -0
  168. package/dist/m/manifest.json +2111 -1573
  169. package/dist/m/page/{editor-NNJA4OKD.js → editor-6LRB3GE4.js} +123 -21
  170. package/dist/m/plugins/ai-edit-UTV7YO2I.js +6 -0
  171. package/dist/m/plugins/{cms-HP3LSTPN.js → cms-LRAOZHT7.js} +9 -9
  172. package/dist/m/plugins/{demo-RM5IR6AO.js → demo-OYO5GCAO.js} +1 -1
  173. package/dist/m/plugins/{derive-UAAA4V4S.js → derive-FRE5JJQE.js} +1 -1
  174. package/dist/m/plugins/indicator-4VDXWYTD.js +1 -0
  175. package/dist/m/plugins/live-AD4H6XSL.js +1 -0
  176. package/dist/m/plugins/menu-M5WW7DBF.js +1 -0
  177. package/dist/m/plugins/page-MD3T2ZX3.js +2 -0
  178. package/dist/m/plugins/page-view-PAWVZNFY.js +1 -0
  179. package/dist/m/plugins/{people-SGPJKANK.js → people-JCHVPF7P.js} +1 -1
  180. package/dist/m/plugins/quickcrop-BQ5YYFCH.js +26 -0
  181. package/dist/m/plugins/{richclay-NRQDSWX6.js → richclay-KLGETK77.js} +2 -2
  182. package/dist/m/plugins/sortable-4S6SQC3D.js +1 -0
  183. package/dist/m/plugins/source-TJXOIOYY.js +1 -0
  184. package/dist/m/plugins/undo-NLPGCJQY.js +1 -0
  185. package/dist/m/plugins/{unsent-HJFLQJ2O.js → unsent-OA4RGBUT.js} +1 -1
  186. package/dist/m/plugins/upgrade-HSUNDNJD.js +1 -0
  187. package/dist/m/plugins/{upload-WLYKK6TL.js → upload-NHGJXZK2.js} +1 -1
  188. package/dist/m/plugins/visitor-drafts-BW43DGY3.js +20 -0
  189. package/dist/m/plugins/visitor-drafts-owner-7ODQG7JX.js +1 -0
  190. package/dist/m/plugins/{wire-4N6GYAF6.js → wire-VBWXEXU2.js} +1 -1
  191. package/dist/m/reader-core-4W2KYEWQ.js +77 -0
  192. package/dist/m/route/route-62CHXL5B.js +1 -0
  193. package/dist/m/sync/live-sync-MO5DH33W.js +1 -0
  194. package/dist/m/ui/index-IVWN2QC4.js +1 -0
  195. package/dist/m/vendor/sap-core.vendor-RN4ZVY4X.js +6 -0
  196. package/dist/offline-manifest.json +1367 -930
  197. package/dist/page/themes/light-1.css +8 -7
  198. package/dist/server/core.cjs +1440 -288
  199. package/dist/server/offline-runtime.cjs +63 -63
  200. package/dist/server/offline-runtime.mjs +63 -63
  201. package/dist/server/page-compaction-worker.cjs +3710 -0
  202. package/dist/server/rooms.mjs +5 -0
  203. package/docs/guide.md +653 -101
  204. package/entries/sap.js +5 -5
  205. package/package.json +1 -1
  206. package/src/core/admin-contenteditable.js +5 -2
  207. package/src/core/admin-inputs.js +1 -0
  208. package/src/core/admin-onclick.js +2 -1
  209. package/src/core/conflict-notice-ui.js +4 -7
  210. package/src/core/download.js +2 -2
  211. package/src/core/host-meta.js +38 -0
  212. package/src/core/is-edit-mode.js +17 -1
  213. package/src/core/mode-key.js +125 -19
  214. package/src/core/mode-support.js +5 -0
  215. package/src/core/mode-transition.js +20 -6
  216. package/src/core/preserve-authored.js +4 -4
  217. package/src/core/recovery.js +121 -33
  218. package/src/core/save-accepted.js +33 -0
  219. package/src/core/save-core.js +106 -31
  220. package/src/core/save-job.js +108 -0
  221. package/src/core/save-prepare.js +53 -0
  222. package/src/core/save-size-notice.js +3 -1
  223. package/src/core/save-slices.js +15 -0
  224. package/src/core/save.js +557 -127
  225. package/src/core/serialize-steps.js +109 -0
  226. package/src/core/snapshot.js +170 -39
  227. package/src/core/source-map.js +83 -38
  228. package/src/core/stale-host-notice.js +1 -0
  229. package/src/core/upgrade-run.js +59 -8
  230. package/src/dom/active-element.js +5 -0
  231. package/src/lib/assets.js +1 -0
  232. package/src/lib/slice.js +65 -0
  233. package/src/lib/uimotion.js +774 -0
  234. package/src/lib/unsaved-state.js +2 -2
  235. package/src/live/fast-lane.js +10 -3
  236. package/src/live/local-lane.js +202 -11
  237. package/src/live/ops.js +16 -0
  238. package/src/live/page-compaction.js +162 -0
  239. package/src/live/server-lane.js +1 -0
  240. package/src/live/store.js +11 -3
  241. package/src/loader-logic.js +3 -1
  242. package/src/loader.js +14 -4
  243. package/src/page/adopt-boot.js +2 -1
  244. package/src/page/awareness.js +33 -2
  245. package/src/page/blocks.js +89 -27
  246. package/src/page/boot-pack.js +1 -1
  247. package/src/page/chart-tables.js +21 -3
  248. package/src/page/chart.js +406 -63
  249. package/src/page/checklist.js +10 -135
  250. package/src/page/checkpoint-proof.js +7 -1
  251. package/src/page/chrome.js +250 -51
  252. package/src/page/clipboard-shape.js +126 -0
  253. package/src/page/drag.js +33 -3
  254. package/src/page/editor.js +136 -25
  255. package/src/page/export-assets.js +357 -0
  256. package/src/page/export-html.js +209 -0
  257. package/src/page/export-markdown.js +361 -0
  258. package/src/page/features/checklist.js +428 -0
  259. package/src/page/features/export-html.js +189 -0
  260. package/src/page/features/export-markdown.js +169 -0
  261. package/src/page/features/import-markdown.js +349 -0
  262. package/src/page/features/media.js +61 -5
  263. package/src/page/features/registry.js +18 -0
  264. package/src/page/features/table.js +373 -83
  265. package/src/page/features/title-cover.js +331 -0
  266. package/src/page/features/title-icon.js +213 -0
  267. package/src/page/features/toc.js +87 -0
  268. package/src/page/format-command.js +25 -1
  269. package/src/page/format-gate.js +68 -18
  270. package/src/page/format-host.js +17 -0
  271. package/src/page/format-native-commands.js +21 -5
  272. package/src/page/image-actions.js +64 -0
  273. package/src/page/import-markdown.js +262 -0
  274. package/src/page/items.js +135 -17
  275. package/src/page/markdown.js +6 -2
  276. package/src/page/media.js +35 -119
  277. package/src/page/placeholder.js +14 -1
  278. package/src/page/projection.js +98 -10
  279. package/src/page/recover.js +10 -12
  280. package/src/page/recovery-ui.js +464 -0
  281. package/src/page/rich/chart.js +63 -7
  282. package/src/page/save-projection.js +28 -0
  283. package/src/page/save-states.js +13 -3
  284. package/src/page/schema.js +19 -3
  285. package/src/page/table-paste.js +3 -1
  286. package/src/page/table-style.js +4 -4
  287. package/src/page/table.js +44 -2
  288. package/src/page/themes/light-1.css +8 -7
  289. package/src/page/themes/light-1.source.css +8 -7
  290. package/src/page/toc-link.js +31 -0
  291. package/src/page/toc.js +5 -0
  292. package/src/page/view-hooks.js +38 -12
  293. package/src/page/view.js +13 -0
  294. package/src/page/ybind/binding.js +88 -5
  295. package/src/page/ybind/bridge.js +187 -20
  296. package/src/page/ybind/containment.js +162 -0
  297. package/src/page/ybind/doc.js +17 -9
  298. package/src/page/ybind/file-debt.js +63 -0
  299. package/src/page/ybind/layout.js +7 -2
  300. package/src/page/ybind/marks.js +1 -1
  301. package/src/page/ybind/moves.js +5 -4
  302. package/src/page/ybind/origins.js +106 -4
  303. package/src/page/ybind/parts.js +8 -1
  304. package/src/page/ybind/provider.js +113 -17
  305. package/src/page/ybind/recovery-proof.js +32 -9
  306. package/src/page/ybind/recovery-replay.js +558 -15
  307. package/src/page/ybind/recovery.js +174 -45
  308. package/src/page/ybind/table.js +67 -11
  309. package/src/page/ybind/walk-delta.js +258 -0
  310. package/src/page/ybind/walk.js +54 -29
  311. package/src/page/ybind/writer.js +1 -1
  312. package/src/plugins/ai-edit.js +13 -9
  313. package/src/plugins/indicator-chip.js +91 -0
  314. package/src/plugins/indicator.js +13 -80
  315. package/src/plugins/live.js +89 -14
  316. package/src/plugins/menu/actions.js +196 -0
  317. package/src/plugins/menu/people.js +279 -0
  318. package/src/plugins/menu/placement.js +121 -0
  319. package/src/plugins/menu/preferences.js +9 -0
  320. package/src/plugins/menu/seo.js +316 -397
  321. package/src/plugins/menu/style.js +171 -0
  322. package/src/plugins/menu/variants.js +296 -0
  323. package/src/plugins/menu.js +186 -183
  324. package/src/plugins/page-view.js +3 -2
  325. package/src/plugins/page.js +249 -44
  326. package/src/plugins/sortable.js +8 -1
  327. package/src/plugins/source.js +6 -0
  328. package/src/plugins/upgrade.js +51 -17
  329. package/src/plugins/upload-ui.js +12 -17
  330. package/src/plugins/visitor-drafts/bottom-ui.js +12 -4
  331. package/src/plugins/visitor-drafts/intro-style.js +7 -2
  332. package/src/plugins/visitor-drafts/intro.js +5 -3
  333. package/src/plugins/visitor-drafts/owner-chip.js +8 -12
  334. package/src/plugins/visitor-drafts/prompt.js +11 -9
  335. package/src/plugins/visitor-drafts/source.js +4 -3
  336. package/src/plugins/visitor-drafts/store.js +138 -9
  337. package/src/plugins/visitor-drafts/ui-memory.js +2 -2
  338. package/src/plugins/visitor-drafts-owner.js +4 -6
  339. package/src/plugins/visitor-drafts.js +5 -3
  340. package/src/recovery/store.js +1 -1
  341. package/src/route/route.js +4 -0
  342. package/src/server/rooms/index.js +5 -1
  343. package/src/server/rooms/live-data-rooms.js +302 -50
  344. package/src/server/rooms/page-compaction-worker.js +12 -0
  345. package/src/server/rooms/page-compactor.js +92 -0
  346. package/src/server/rooms/page-room-conformance.js +461 -0
  347. package/src/source/parse-steps.js +94 -0
  348. package/src/source/session.js +233 -57
  349. package/src/sync/editing-sender.js +12 -0
  350. package/src/sync/live-sync-edit.js +22 -2
  351. package/src/sync/live-sync.js +150 -23
  352. package/src/sync/page-relay.js +52 -0
  353. package/src/sync/presence-store.js +44 -4
  354. package/src/sync/presence.js +6 -3
  355. package/src/sync/saved-stream.js +11 -6
  356. package/src/ui/bevel-controls.js +1 -0
  357. package/src/ui/bevel-dialog.js +5 -2
  358. package/src/ui/editor-ui.js +77 -0
  359. package/src/ui/page-colour.js +281 -0
  360. package/src/ui/toast.js +16 -7
  361. package/src/vendor/hyper-html-api-upgrade.vendor.js +2 -2
  362. package/src/vendor/hyper-undo.vendor.js +1 -1
  363. package/src/vendor/hypercms.vendor.js +9 -9
  364. package/src/vendor/parse5.vendor.js +2 -2
  365. package/src/vendor/sap-core.vendor.js +5 -5
  366. package/dist/m/c-2SPVQSHC.js +0 -1
  367. package/dist/m/c-336SGU5W.js +0 -1
  368. package/dist/m/c-3H6BZDNJ.js +0 -6
  369. package/dist/m/c-4DFEJ2PO.js +0 -3
  370. package/dist/m/c-56QRZTZH.js +0 -1
  371. package/dist/m/c-5J4E7O4Y.js +0 -4
  372. package/dist/m/c-5LKDWQTL.js +0 -19
  373. package/dist/m/c-5V3MOVJT.js +0 -1
  374. package/dist/m/c-6AZOGAPE.js +0 -1
  375. package/dist/m/c-6CRUUXOX.js +0 -5
  376. package/dist/m/c-6HMB24EV.js +0 -1
  377. package/dist/m/c-6KEVEQ7L.js +0 -1
  378. package/dist/m/c-A3E3NIMC.js +0 -1
  379. package/dist/m/c-BQ6LOBEE.js +0 -1
  380. package/dist/m/c-BTDI4Y23.js +0 -1
  381. package/dist/m/c-CJ3A7ZKE.js +0 -1
  382. package/dist/m/c-CQHPGKX2.js +0 -1
  383. package/dist/m/c-DFS4XZJV.js +0 -2
  384. package/dist/m/c-DNENWY4O.js +0 -1
  385. package/dist/m/c-E4LIR5X5.js +0 -1
  386. package/dist/m/c-FDNHHZY5.js +0 -1
  387. package/dist/m/c-FROJUZMV.js +0 -1
  388. package/dist/m/c-G2JPKCTP.js +0 -1
  389. package/dist/m/c-GB6TU7WV.js +0 -1
  390. package/dist/m/c-GFJJEBTU.js +0 -1
  391. package/dist/m/c-GJAEGGXY.js +0 -1
  392. package/dist/m/c-GOWBDM6J.js +0 -1
  393. package/dist/m/c-HFKUVACH.js +0 -1
  394. package/dist/m/c-HHDFCNHV.js +0 -1
  395. package/dist/m/c-IEM4NTCS.js +0 -1
  396. package/dist/m/c-JDCX26UP.js +0 -25
  397. package/dist/m/c-KGVGROZT.js +0 -1
  398. package/dist/m/c-KQ6TYJAP.js +0 -135
  399. package/dist/m/c-LFPHCXY3.js +0 -1
  400. package/dist/m/c-LRPUO2MX.js +0 -1
  401. package/dist/m/c-LWLBHLVC.js +0 -3
  402. package/dist/m/c-M2L47S2X.js +0 -7
  403. package/dist/m/c-MFP2ZWD4.js +0 -1
  404. package/dist/m/c-MKSQ4Y57.js +0 -1
  405. package/dist/m/c-NUFFJVVJ.js +0 -1
  406. package/dist/m/c-NUHSPT5P.js +0 -1
  407. package/dist/m/c-O72HVYSA.js +0 -1
  408. package/dist/m/c-OIBUTDXI.js +0 -1
  409. package/dist/m/c-OW5QIGG3.js +0 -1
  410. package/dist/m/c-PGRCK73F.js +0 -1
  411. package/dist/m/c-Q7NQD65V.js +0 -1
  412. package/dist/m/c-QH63LQOS.js +0 -1
  413. package/dist/m/c-R7IWVINQ.js +0 -1
  414. package/dist/m/c-RM7J7BV2.js +0 -1
  415. package/dist/m/c-S4ZEH46B.js +0 -9
  416. package/dist/m/c-SDAXDM2D.js +0 -1
  417. package/dist/m/c-SMGU7RT3.js +0 -235
  418. package/dist/m/c-SPIORRYS.js +0 -1
  419. package/dist/m/c-SWLRT66R.js +0 -1
  420. package/dist/m/c-TCJTVAFN.js +0 -1
  421. package/dist/m/c-TQEMVJCS.js +0 -1
  422. package/dist/m/c-TYLXX4NF.js +0 -21
  423. package/dist/m/c-U62OB4BT.js +0 -1
  424. package/dist/m/c-U6YWUAR3.js +0 -8
  425. package/dist/m/c-UDCSU5G5.js +0 -2
  426. package/dist/m/c-VI5RMSVY.js +0 -1
  427. package/dist/m/c-VRZN56XY.js +0 -1
  428. package/dist/m/c-W5MCHEGA.js +0 -1
  429. package/dist/m/c-WNYBLIOZ.js +0 -1
  430. package/dist/m/c-WWXIDH4O.js +0 -28
  431. package/dist/m/c-XCNTK76U.js +0 -1
  432. package/dist/m/c-XMS6DPBR.js +0 -1
  433. package/dist/m/c-ZUCOKOHT.js +0 -1
  434. package/dist/m/c-ZVPVXTJF.js +0 -4
  435. package/dist/m/c-ZVRKXKM7.js +0 -1
  436. package/dist/m/core/autosave-HRYGUWV6.js +0 -1
  437. package/dist/m/core/conflict-notice-6MROJN2L.js +0 -1
  438. package/dist/m/core/is-edit-mode-KTWA3O5N.js +0 -1
  439. package/dist/m/core/recovery-FLTCC2OC.js +0 -1
  440. package/dist/m/core/save-HQZ4S667.js +0 -1
  441. package/dist/m/core/save-core-KGQWFUNH.js +0 -1
  442. package/dist/m/core/snapshot-EGQZNT45.js +0 -1
  443. package/dist/m/core/unsaved-warning-IDJLD66H.js +0 -1
  444. package/dist/m/loader-S4I7GKXR.js +0 -1
  445. package/dist/m/manifest-4C419D67.js +0 -1
  446. package/dist/m/manifest-edit-B077F288.js +0 -1
  447. package/dist/m/plugins/ai-edit-QN4PMMNL.js +0 -6
  448. package/dist/m/plugins/indicator-URDBBOQO.js +0 -1
  449. package/dist/m/plugins/live-HFWD4OIH.js +0 -1
  450. package/dist/m/plugins/menu-3HIEQSI6.js +0 -138
  451. package/dist/m/plugins/page-JOKB6XPR.js +0 -2
  452. package/dist/m/plugins/page-view-NXOJHNW6.js +0 -1
  453. package/dist/m/plugins/quickcrop-QNY3PKLD.js +0 -26
  454. package/dist/m/plugins/sortable-GWT4PWDV.js +0 -1
  455. package/dist/m/plugins/source-4ZRSAIYM.js +0 -1
  456. package/dist/m/plugins/undo-VDA5P7FH.js +0 -1
  457. package/dist/m/plugins/upgrade-W7FG5VFG.js +0 -1
  458. package/dist/m/plugins/visitor-drafts-LIDY7NH6.js +0 -21
  459. package/dist/m/plugins/visitor-drafts-owner-ZXCKBZE7.js +0 -1
  460. package/dist/m/reader-core-DXYCURFF.js +0 -68
  461. package/dist/m/route/route-KOCZSEGN.js +0 -1
  462. package/dist/m/sync/live-sync-J7VMYTKS.js +0 -1
  463. package/dist/m/ui/index-3JLVI27O.js +0 -1
  464. package/dist/m/vendor/sap-core.vendor-A7BMUYZT.js +0 -6
  465. /package/dist/m/{c-FILLTJA7.js → c-QTTJYJMA.js} +0 -0
  466. /package/dist/m/plugins/{quickcrop-QNY3PKLD.js.LEGAL.txt → quickcrop-BQ5YYFCH.js.LEGAL.txt} +0 -0
  467. /package/dist/m/plugins/{richclay-NRQDSWX6.js.LEGAL.txt → richclay-KLGETK77.js.LEGAL.txt} +0 -0
@@ -1,3 +0,0 @@
1
- import{D as Ve,E as Be,F as Se,G as te,H as xe,P as $t,R as Kt,S as _e,T as Nt,a as Ct,b as jt,c as Et,d as ot,e as Yt,f as st,g as Re,h as we,i as ve,j as Te,o as Oe,q as Mt,r as Ie,t as X,u as rt,v as ie,w as De,y as pe}from"./c-6CRUUXOX.js";import{$ as xt,_ as St,da as nt,ha as At,la as ce,m as G,x as It}from"./c-WWXIDH4O.js";import{a as be,b as Ot,c as W,d as Ne}from"./c-5V3MOVJT.js";var Je="page-origins",wn="page-undo-overlap-repair",Rt=(e,t)=>JSON.stringify(["span",e,t]),lt=(e,t)=>JSON.stringify(["alias",e,t]),Tt=(e,t)=>JSON.stringify(["boundary",e,t]),vn=["copy","removed","restore"],Dt=/^(?:0|[1-9]\d*)$/,fe=(e,t)=>`${e}.${t}`,_=e=>Number.isSafeInteger(e)&&e>=0,On=e=>Number.isSafeInteger(e)&&e>0,In=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Fe=e=>new Error(`Conflicting immutable origin record: ${e}`),Sn=e=>{if(typeof e!="string")return!1;let t=e.indexOf(".");if(t<1||t===e.length-1)return!1;let o=e.slice(0,t),s=e.slice(t+1);return Dt.test(o)&&Dt.test(s)&&_(Number(o))&&_(Number(s))},ct=e=>{if(!In(e))return null;for(let t of Object.keys(e))if(t!=="blockId"&&t!=="kind"&&t!=="recoveryOf")return null;return typeof e.blockId!="string"||!e.blockId||!vn.includes(e.kind)||e.recoveryOf!==void 0&&!Sn(e.recoveryOf)?null:e.recoveryOf===void 0?{blockId:e.blockId,kind:e.kind}:{blockId:e.blockId,kind:e.kind,recoveryOf:e.recoveryOf}},xn=(e,t)=>e.blockId===t.blockId&&e.kind===t.kind&&e.recoveryOf===t.recoveryOf,An=e=>{if(typeof e!="string"||e.charCodeAt(0)!==91)return null;let t;try{t=JSON.parse(e)}catch{return null}return!Array.isArray(t)||t.length!==3||t[0]!=="span"&&t[0]!=="alias"&&t[0]!=="boundary"?null:_(t[1])&&_(t[2])?t:null};function Ae(e){let t=new Map,o=new Map,s=new Map,c=(f,d)=>{let b=0,w=f.length;for(;b<w;){let I=b+w>>1;f[I].clock<d?b=I+1:w=I}return b},r=(f,d)=>{let b=An(f);if(!b)return;let[w,I,j]=b;if(w==="alias"){d&&_(d.sourceClient)&&_(d.sourceClock)?o.set(fe(I,j),{client:d.sourceClient,clock:d.sourceClock}):o.delete(fe(I,j));return}if(w==="boundary"){let S=ct(d);S?s.set(fe(I,j),S):s.delete(fe(I,j));return}let M=t.get(I)??[],R=c(M,j);M[R]?.clock===j&&M.splice(R,1),d&&On(d.length)&&_(d.sourceClient)&&_(d.sourceClock)&&M.splice(c(M,j),0,{client:I,clock:j,length:d.length,sourceClient:d.sourceClient,sourceClock:d.sourceClock}),M.length?t.set(I,M):t.delete(I)};for(let[f,d]of e)r(f,d);let a=f=>{for(let d of f.keysChanged)r(d,e.get(d))};e.observe(a);let m=f=>{let d=o.get(fe(f.client,f.clock));if(d)return{client:d.client,clock:d.clock};let b=t.get(f.client);if(!b)return{client:f.client,clock:f.clock};let w=0,I=b.length-1,j=-1;for(;w<=I;){let S=w+I>>1;b[S].clock<=f.clock?(j=S,w=S+1):I=S-1}if(j<0)return{client:f.client,clock:f.clock};let M=b[j],R=f.clock-M.clock;return R>=M.length?{client:f.client,clock:f.clock}:{client:M.sourceClient,clock:M.sourceClock+R}},v=f=>{if(!f||!_(f.client)||!_(f.clock))return null;let d=fe(f.client,f.clock),b=new Set;for(;!b.has(d);){b.add(d);let I=o.get(d);if(!I)break;d=fe(I.client,I.clock)}if(b.has(d)&&o.has(d))return null;let w=s.get(d);return w?{...w}:null},p=(f,d,b)=>{let w=Rt(f,d),I=e.get(w);if(I!==void 0&&(I.length!==b.length||I.sourceClient!==b.sourceClient||I.sourceClock!==b.sourceClock))throw Fe(w);let j=t.get(f)??[],M=c(j,d);for(let R of[j[M-1],j[M]])if(R&&R.clock!==d&&R.clock<d+b.length&&d<R.clock+R.length)throw Fe(w);I===void 0&&e.set(w,b)};return{origins:e,resolve:m,recordSpans:f=>{let d=[],b=()=>{if(!d.length)return;let w=d[0],I={length:d.length,sourceClient:w.source.client,sourceClock:w.source.clock};if(!_(I.sourceClock+I.length-1))throw new Error(`Unsafe origin span: ${Rt(w.dest.client,w.dest.clock)}`);p(w.dest.client,w.dest.clock,I),d.length=0};for(let w of f){if(!w?.dest||!w?.source)throw new Error("Invalid origin destination");let I=w.dest,j=w.source;if(!_(I.client)||!_(I.clock)||!_(j.client)||!_(j.clock))throw new Error("Invalid origin destination");let M=m(j),R=d[d.length-1];R&&R.dest.client===I.client&&R.dest.clock+1===I.clock&&R.source.client===M.client&&R.source.clock+1===M.clock?d.push({dest:I,source:M}):(b(),d.push({dest:I,source:M}))}b()},recordAlias:(f,d)=>{if(!f||!d||!_(f.client)||!_(f.clock)||!_(d.client)||!_(d.clock))throw new Error("Invalid origin destination");let b=m(d),w=lt(f.client,f.clock),I=e.get(w);if(I!==void 0&&(I.sourceClient!==b.client||I.sourceClock!==b.clock))throw Fe(w);I===void 0&&e.set(w,{sourceClient:b.client,sourceClock:b.clock})},recordBoundary:(f,d)=>{if(!f||!_(f.client)||!_(f.clock))throw new Error("Invalid origin destination");let b=ct(d);if(!b)throw new Error(`Invalid boundary record: ${Tt(f.client,f.clock)}`);let w=Tt(f.client,f.clock),I=e.get(w);if(I===void 0){e.set(w,b);return}let j=ct(I);if(!j||!xn(j,b))throw Fe(w)},boundaryOf:v,get size(){return e.size},dispose(){e.unobserve(a)}}}function ho(e,t,o){let s=[],c=0;for(let r=e._start;r&&c<o;r=r.right){if(r.deleted||!r.countable)continue;let a=c;if(c+=r.length,c<=t)continue;let m=Math.max(0,t-a),v=Math.min(r.length,o-a);for(let p=m;p<v;p++)s.push({client:r.id.client,clock:r.id.clock+p})}return s}var Cn=(e,t,o)=>e.some(s=>s.actor===t||s.client!==o.client||o.clock<s.clock||o.clock>=s.clock+s.length?!1:s.sv.some(([c,r])=>c===o.client&&r>o.clock)),jn=(e,t)=>{let o=0;for(let s=e._start;s;s=s.right)if(!(s.deleted||!s.countable)){if(s.id.client===t.client&&s.id.clock<=t.clock&&t.clock<s.id.clock+s.length)return o+t.clock-s.id.clock;o+=s.length}return null},En=(e,t)=>{let o=[];for(let c of t){let r=jn(e.flow,c);r!==null&&o.push(r)}o.sort((c,r)=>c-r);let s=[];for(let c of o){let r=s[s.length-1];r&&c<=r[1]?r[1]=Math.max(r[1],c+1):s.push([c,c+1])}for(let c=s.length-1;c>=0;c--){let[r,a]=s[c];a>r&&e.flow.delete(r,a-r)}};function mo(e,t,o=Ae(e.origins),s=()=>[]){let c=r=>{if(r.origin!==t||!t.currStackItem)return;let a=[],m=[],v=[],p=s(e.gone);Et(r,t.currStackItem.deletions,u=>{if(!(u instanceof De)||u.parent!==e.flow||!u.countable||!u.redone)return;let h=u.content instanceof X&&u.content.embed?.b!==void 0;for(let g=0;g<u.length;g++){let f={client:u.id.client,clock:u.id.clock+g},d=o.resolve(f),b={client:u.redone.client,clock:u.redone.clock+g},w=Oe(e.ydoc.store,b);for(;w instanceof De&&w.redone;)b={client:w.redone.client,clock:w.redone.clock+b.clock-w.id.clock},w=Oe(e.ydoc.store,b);if(!(!(w instanceof De)||w.deleted)&&!(b.clock<(r.beforeState.get(b.client)??0))){if(!h&&Cn(p,e.ydoc.clientID,f)){v.push(b);continue}(h?m:a).push({dest:b,source:d})}}}),(a.length||m.length)&&e.ydoc.transact(()=>{a.length&&o.recordSpans(a);for(let u of m)o.recordAlias(u.dest,u.source)},Je),v.length&&e.ydoc.transact(()=>En(e,v),wn)};return e.ydoc.on("beforeObserverCalls",c),()=>e.ydoc.off("beforeObserverCalls",c)}var at=e=>Ct(e),le=e=>jt(e),Ue=12*1024,Yn="page-recovery",Le=e=>be.exec(e)?.[1]??e;function So(e){return{v:1,g:0,y:{seed:at(we(e))}}}var L=class extends Error{constructor(t,o){super(o),this.name="YDecodeError",this.code=t}};function Mn(e){if(e?.v!==1||!e.y||typeof e.y!="object"||Array.isArray(e.y))throw new L("invalid-value","Expected a version 1 Yjs page value");let t=new Map,o=new Set;for(let[s,c]of Object.entries(e.y)){if(typeof c!="string")throw new L("invalid-update",`Invalid Yjs update: ${s}`);let r=be.exec(s);if(!r){o.add(s);continue}let a=Number(r[2]),m=Number(r[3]);if(!Number.isSafeInteger(a)||!Number.isSafeInteger(m)||m<1||a>=m)throw new L("invalid-update",`Invalid Yjs update part: ${s}`);let v=t.get(r[1])??{count:m,indices:new Set};if(v.count!==m||v.indices.has(a))throw new L("invalid-update",`Conflicting Yjs update parts: ${r[1]}`);v.indices.add(a),t.set(r[1],v)}for(let[s,c]of t){if(o.has(s))throw new L("invalid-update",`Conflicting Yjs update forms: ${s}`);if(c.indices.size!==c.count)throw new L("incomplete-update",`Incomplete Yjs update: ${s}`)}return W(e.y)}function Bt(e,{strict:t=!1}={}){let o=t?Mn(e):W(e.y),s=new st;try{for(let[c,r]of o){let a=t?r.replace(/[\t\n\f\r ]/g,""):r;if(t&&!Ot.test(a))throw new L("invalid-update",`Invalid base64 in Yjs update: ${c}`);Re(s,le(a),pe)}if(t&&(s.store.pendingStructs||s.store.pendingDs))throw new L("unresolved-update","Yjs page updates have missing prerequisites");return s}catch(c){throw s.destroy(),t&&!(c instanceof L)?new L("invalid-update",`Invalid Yjs page update: ${c.message}`):c}}var Vt=typeof TextEncoder=="function"?new TextEncoder:null,$n=e=>Vt?Vt.encode(e).length:e.length*2,Kn=(e,t)=>Yt(ot(e.store),ot(t.store)),Nn=(e,t)=>{if(e.size!==t.size)return!1;for(let[o,s]of e)if(t.get(o)!==s)return!1;return!0};function xo({store:e,ydoc:t,compact:o={},setTimer:s=setTimeout,clearTimer:c=clearTimeout,onStopped:r=()=>{},stats:a={applied:0,offered:0,compactions:0},journal:m=null}){let v=W(e.value.y),p=new Set,u=null,h=y=>{u||(u=y,r(y))},g=!v.some(([y])=>y[0]==="m"),f=0,d=t.clientID.toString(36),b=y=>`${y}${d}-${(f++).toString(36)}`,w=null,I=e.value.g,j=new Set,M=(y,k)=>{if(k.length<=Ue)return[[y,k]];let x=Math.ceil(k.length/Ue);return Array.from({length:x},(n,l)=>[`${y}.${l}.${x}`,k.slice(l*Ue,(l+1)*Ue)])},R=(y,k)=>{g=!0,p.add(y),j.add(y);let x=M(y,at(k));e.handle.update(n=>{for(let[l,i]of x)n.y[l]=i})};for(let[y]of v)p.add(y);let S=(y,k)=>{k!==pe&&k!==Je&&k!==Yn&&m?.local(y),!(u||k===pe||k===Je)&&R(b("u"),y)};t.on("updateV2",S);let E=(y,k)=>{if(u||p.has(y))return;g=!0,p.add(y),a.applied++;let x=le(k);Re(t,x,pe),m?.dependency(x)},V=!1,B=!1,q=(y,k)=>{V||=y,B||=k,!w&&(w=s(()=>{w=null,V&&oe(),H()},0))},ne=()=>{oe(),H()};function oe(){if(u)return!1;let y=e.value.y,k=new st;for(let[,O]of W(y))Re(k,le(O),pe);let x=Te(k),n=ve(Te(t)),l=ve(x);if(Nn(n,l)&&Kn(t,k))return k.destroy(),V=!1,B=!1,!1;let i=we(t,x);return k.destroy(),a.offered++,R(b("r"),i),V=!1,B=!1,!0}let Y={keys:32,room:3840*1024,...o},P=null,N=0,Ye=256,J=new Map,Me=y=>e.handle.update(k=>{for(let x of y)delete k.y[x]}),re=(y,k)=>Object.keys(y).filter(x=>k.has(Le(x))),de=(y,k)=>{let x=e.value.y??{};Me(k.filter(n=>n in x&&x[n]===y[n]))};function ee(){let y=e.authoritative.y??{},k=e.value.y??{};for(let i of j)i in k||j.delete(i);let x=P?[...P.parts.map(([i])=>i),...P.inputs.keys()]:[],n=new Set([...Object.keys(y),...j,...x]);for(let i of p)n.has(i)||p.delete(i);let l=new Map(W(y));for(let[i,O]of J)(!n.has(i)||l.get(i)!==O.value)&&J.delete(i)}function ge(y,k,x,n){let l=J.get(y);return l&&l.value!==k&&(J.delete(y),l=null),l||(J.size>=Ye&&J.delete(J.keys().next().value),l={value:k,folds:new Map},J.set(y,l)),l.folds.has(x)||l.folds.set(x,ft(n,le(k))),l.folds.get(x)}let $e=(y,k)=>{for(let[x,n]of k.held)if(y[x]!==void 0&&y[x]!==n)return!1;return!0},Qe=y=>{let k=le(y.merged);for(let[x,n]of y.inputs)if(n!==null&&!ge(x,n,y.key,k))return!1;return!0};function Ze(y){let k=P,x=Ne({v:1,y}).y,n=k.parts.filter(([l,i])=>y[l]===i&&x[l]===i);return n.length!==k.parts.length?e.pending.length?!1:(P=null,n.length&&de(y,n.map(([l])=>l)),N=W(y).length+Y.keys,ee(),!0):e.pending.length||!$e(y,k)||!Qe(k)?!1:(P=null,de(y,re(y,k.inputs)),ee(),!0)}function Ke(y,k,x){let n=k.filter(([$])=>$[0]==="m"),l=new Map(k),i=new Map(n),O=$=>{let F=i.get($);return typeof F=="string"&&i.set($,Ie([le(F)])),i.get($)},C=($,F,K)=>ge($,F,K,O(K)),A=new Set;for(let[$,F]of k)if(!(!x&&$[0]!=="m")){for(let[K]of n)if(!(K===$||A.has(K)||!C($,F,K))&&!($[0]==="m"&&$<K&&C(K,l.get(K),$))){A.add($);break}}return A.size?(de(y,re(y,A)),!0):!1}function H(){if(u||!g||e.value.g!==I)return!1;let y=e.authoritative.y;if(P)return Ze(y);let k=W(y),x=k.length>Math.max(Y.keys,N);if(!x&&k.filter(([K])=>K[0]==="m").length<2)return!1;if(Ke(y,k,x))return ee(),!0;if(!x)return!1;let n=at(Ie(k.map(([,K])=>le(K)))),l=b("m"),i=M(l,n),O={...e.value,y:{...e.value.y}};for(let[K,T]of i)O.y[K]=T;if($n(JSON.stringify(O))>Y.room)return N=k.length+Y.keys,!1;let C=Ne({v:1,y}).y,A=Object.keys(y).filter(K=>!(K in C)).map(Le).filter(K=>K[0]==="m"),$=new Map(k);for(let K of A)$.set(K,null);let F=new Map;for(let K of re(y,$))$.get(Le(K))!==null&&F.set(K,C[K]??y[K]);return P={key:l,parts:i,merged:n,inputs:$,held:F},p.add(l),e.handle.update(K=>{for(let[T,z]of i)K.y[T]=z}),a.compactions++,!0}let et=y=>{let k=new Set;for(let[,x]of W(y??{}))for(let n of ve(Mt(le(x))).keys())k.add(n);return k},ye=new Map(v),he=y=>{let k=et(y),x=[...ve(Te(t)).keys()];return!k.size||!x.length||x.some(n=>k.has(n))?!0:W(y??{}).some(([n,l])=>ye.get(n)===l)},me=e.onRebase(y=>{if(u)return;let k=y.source==="remote"&&y.frame?y.frame.ops:null,x=k&&k.every(n=>n.path[0]==="y"&&n.path.length===2&&!be.test(n.path[1]));if(!x&&y.cause!=="refused"&&!he(y.next.y)){h("lineage");return}if(x)for(let n of k)n.op==="set"&&E(n.path[1],n.value);else for(let[n,l]of W(y.next.y??{}))E(n,l);ee(),q(y.source!=="remote"||!k,y.source!=="remote")}),ke=e.onDelivery(y=>{if(y.phase!=="refused")return;if(y.code!=="too-large"||u){ee();return}h("too-large");let k=e.authoritative.y??{},x=Ne({v:1,y:k}).y,n=Object.keys(e.value.y??{}).filter(i=>!(i in k)),l=Object.keys(k).filter(i=>be.test(i)&&!(i in x)&&Le(i).slice(1).startsWith(`${d}-`));(n.length||l.length)&&Me([...n,...l]),ee()});return{known:p,stats:a,settle:ne,reconcile:oe,get reconcilePending(){return B},get stopped(){return u},_diagnostics:()=>({known:p.size,cover:J.size,fold:P?P.parts.length:0,generation:I}),compact:H,dispose(){me(),ke(),t.off("updateV2",S),w&&c(w)}}}var ut=class extends Error{constructor(t,o){super(o),this.name="PageProofError",this.code=t}},U=(e,t)=>{throw new ut(e,t)},_t=/^[0-9a-f]{64}$/,Ft=typeof TextEncoder=="function"?new TextEncoder:null,dt=e=>e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):null,Jt=e=>typeof e=="string"?e:JSON.stringify(e),Rn=e=>Array.isArray(e)?[...e]:e,Tn=e=>({v:e.v,g:e.g,y:{...e.y??{}}}),Dn=(e,t)=>e.length===t.length&&e.every((o,s)=>o===t[s]);function ft(e,t,o=null){let s=o?.mergeUpdatesV2??Ie,c=s([e]);return Dn(c,s([c,t]))}async function Pe(e){let t=await globalThis.crypto.subtle.digest("SHA-256",e);return[...new Uint8Array(t)].map(o=>o.toString(16).padStart(2,"0")).join("")}function Ut(e){let t;try{t=Bt(e,{strict:!0})}catch(o){U("invalid-state",`The accepted page state does not decode: ${o.message}`)}try{return we(t)}finally{t.destroy()}}var Vn=(e,t)=>!!(e&&t)&&!!(e.host&&e.documentId&&e.principalId)&&e.host===t.host&&e.documentId===t.documentId&&e.principalId===t.principalId,Bn=(e,t)=>!!(e&&t)&&typeof e.generation=="string"&&!!e.generation&&e.generation===t.generation;async function Yo({capture:e,records:t=[],accepted:o,article:s,state:c,receipt:r,saved:a=!0}={}){let m=[];for(let p of t){(!p||p.id===void 0||typeof p.revision!="number")&&U("invalid-record","A proof names each record by id and revision");let u=dt(p.update);(!u||!u.length)&&U("invalid-record","A proof needs the bytes each record owns"),m.push({id:Rn(p.id),revision:p.revision,update:u.slice(),context:p.context??null})}typeof s!="string"&&U("missing-article","A proof names the final outgoing article");let v=Ut(c);return{saved:a===!0,capture:e,accepted:o,article:s,state:Tn(c),stateDigest:await Pe(v),articleDigest:await Pe(Ft.encode(s)),receipt:r,records:m}}async function _n(e){(!e||typeof e!="object"||Array.isArray(e))&&U("missing-proof","A page checkpoint needs a proof"),e.saved!==!0&&U("not-saved","Only a save that succeeded under admission makes a proof"),(typeof e.capture!="string"||!e.capture)&&U("missing-capture","A proof belongs to the capture it saved");let t=e.receipt;(!t||typeof t.file!="string"||!t.file||typeof t.pageState!="string"||!t.pageState)&&U("missing-receipt","A proof names the persisted file and page-state pair");let o=e.accepted;(!o||!o.authority||!o.lineage||typeof o.lineage.generation!="string"||!o.lineage.generation)&&U("missing-identity","A proof names the authority and generation it was saved under"),typeof e.article!="string"&&U("missing-article","A proof names the final outgoing article"),Array.isArray(e.records)||U("missing-records","A proof names the records it covers"),(typeof e.stateDigest!="string"||!_t.test(e.stateDigest))&&U("missing-digest","A proof carries the accepted state digest"),(typeof e.articleDigest!="string"||!_t.test(e.articleDigest))&&U("missing-digest","A proof carries the final article digest");let s=Ut(e.state);await Pe(s)!==e.stateDigest&&U("state-digest-mismatch","The page state is not the one the proof was made over"),await Pe(Ft.encode(e.article))!==e.articleDigest&&U("article-digest-mismatch","The article is not the one the proof was made over");let c=new Map;for(let r of e.records){(!r||r.id===void 0||typeof r.revision!="number")&&U("invalid-record","A proof names each record by id and revision");let a=dt(r.update);(!a||!a.length)&&U("invalid-record","A proof needs the bytes each record owns"),c.set(Jt(r.id),r)}return{stateBytes:s,entries:c,accepted:o}}function Fn(e,t){let o=t.context;if(!o||!Vn(o.authority,e.accepted.authority)||!Bn(o.lineage,e.accepted.lineage))return!1;let s=dt(t.update);return!!s&&s.length>0&&ft(e.stateBytes,s)}async function Mo(e,t=[]){let o=await _n(e);return(t||[]).filter(s=>{if(!s||s.id===void 0||typeof s.revision!="number")return!1;let c=o.entries.get(Jt(s.id));return!!c&&c.revision===s.revision&&Fn(o,c)})}var Lt=Object.freeze({row:Object.freeze(["alive","pos"]),col:Object.freeze(["alive","name","kind","width","pos"])}),zt=["name","kind","width","pos"],Jn=new Set(["kind","width"]),ue=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),pt=e=>typeof e=="string"&&e.length>0&&!["__proto__","constructor","prototype"].includes(e),Ce=e=>{throw new L("unsupported-content",`Unsupported table field: ${e}`)},Gt=e=>e===null||typeof e!="object"?e:JSON.parse(JSON.stringify(e)),se=(e,t,o,s)=>JSON.stringify([e,t,o,s]);function Un(e){if(typeof e=="string")return!0;if(!ue(e)||Object.keys(e).sort().join(",")!=="c,m"||typeof e.c!="string"||!Array.isArray(e.m)||!e.m.every(Array.isArray))return!1;let t=At(e.m,e.c.length);return t?t.every((o,s)=>{if(typeof o!="string")return!1;if(o.startsWith("@"))return o===xt&&e.c[s]===St;try{return It(G,o),!0}catch{return!1}}):!1}var Ln=(e,t)=>e==="alive"?typeof t=="boolean":e==="width"?t===null||typeof t=="number"&&Number.isFinite(t)&&t>0:e==="kind"&&t===null||typeof t=="string";function Pt(e,t){if(Object.keys(e).length)return;let[o]=Object.keys(t).sort((s,c)=>{let r=t[s].pos??"",a=t[c].pos??"";return r!==a?r<a?-1:1:s<c?-1:s>c?1:0});o&&(e[o]=t[o])}function qt(e,t=null,o=null){let s=new Map,c=new Map,r=new Map;for(let[u,h]of e){let g;try{g=JSON.parse(u)}catch{Ce(u)}(!Array.isArray(g)||g.length!==4)&&Ce(u);let[f,d,b,w]=g;if((!pt(f)||!pt(b))&&Ce(u),d==="cell"?(!pt(w)||!Un(h))&&Ce(u):(!Object.hasOwn(Lt,d)||!Lt[d].includes(w)||!Ln(w,h))&&Ce(u),f!==t)continue;if(d==="cell"){let M=r.get(b)??new Map;M.set(w,h),r.set(b,M);continue}let I=d==="row"?s:c,j=I.get(b)??{};j[w]=h,I.set(b,j)}let a={...ue(o?.cols)?o.cols:{}},m={...ue(o?.rows)?o.rows:{}},v={},p={};for(let[u,h]of c){let g=ue(a[u])?{...a[u]}:{};Object.hasOwn(g,"pos")||(g.pos=""),Object.hasOwn(g,"name")||(g.name="");for(let f of zt)Object.hasOwn(h,f)&&(h[f]===null?delete g[f]:g[f]=h[f]);if(h.alive===!1||!Object.hasOwn(a,u)&&h.alive!==!0){h.alive===!1&&(v[u]=g),delete a[u];continue}a[u]=g}for(let u of new Set([...s.keys(),...r.keys()])){let h=s.get(u)??{},g={pos:"",cells:{},...ue(m[u])?m[u]:{}};Object.hasOwn(h,"pos")&&(g.pos=h.pos);let f=r.get(u);if(f&&(g.cells={...ue(g.cells)?g.cells:{},...Object.fromEntries([...f].map(([d,b])=>[d,Gt(b)]))}),h.alive===!1||!Object.hasOwn(m,u)&&h.alive!==!0){h.alive===!1&&(p[u]=g),delete m[u];continue}m[u]=g}return Pt(a,v),Pt(m,p),{cols:a,rows:m}}var ze=(e,t)=>e?.[t]??(Jn.has(t)?null:"");function Pn(e,t,o,s,c){let r=[],a=(g,f)=>t.has(g)?t.get(g):f,m=(g,f)=>r.push([g,Gt(f)]),v=s?.cols??{},p=c?.cols??{},u=s?.rows??{},h=c?.rows??{};for(let g of new Set([...Object.keys(v),...Object.keys(p)])){let f=v[g],d=p[g];if(!d){f&&m(se(e,"col",g,"alive"),!1);continue}(!f||a(se(e,"col",g,"alive"),!0)===!1)&&m(se(e,"col",g,"alive"),!0);for(let b of zt){let w=se(e,"col",g,b),I=f?ze(f,b):a(w,ze(o?.cols?.[g],b));ce(I)!==ce(ze(d,b))&&m(w,ze(d,b))}}for(let g of new Set([...Object.keys(u),...Object.keys(h)])){let f=u[g],d=h[g];if(!d){f&&m(se(e,"row",g,"alive"),!1);continue}(!f||a(se(e,"row",g,"alive"),!0)===!1)&&m(se(e,"row",g,"alive"),!0);let b=se(e,"row",g,"pos"),w=d.pos??"";a(b,o?.rows?.[g]?.pos??"")!==w&&m(b,w);let I=ue(d.cells)?d.cells:{};for(let j of Object.keys(p)){let M=se(e,"cell",g,j),R=I[j]??"",S=f&&v[j]?f.cells?.[j]??"":a(M,o?.rows?.[g]?.cells?.[j]??"");ce(S)!==ce(R)&&m(M,R)}}return r}function zn(e,t){let o=e.attrs.get(t);return{cols:o?.get("cols")??{},rows:o?.get("rows")??{}}}function Bo(e,t,o,s){let c=zn(e,t);for(let[r,a]of Pn(t,e.tableFields,c,o,s))e.tableFields.set(r,a)}var yt=Object.freeze({column:Object.freeze(["alive","name","pos"]),card:Object.freeze(["alive","title","owner","due","placement"])}),Ht={column:new Set(yt.column),card:new Set(yt.card)},Gn=[["column","columns"],["card","cards"]],ht=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Wt=e=>typeof e=="string"&&e.length>0&&!["__proto__","constructor","prototype"].includes(e),Ge=e=>{throw new L("unsupported-content",`Unsupported board field: ${e}`)},qn=e=>e===null||typeof e!="object"?e:JSON.parse(JSON.stringify(e)),gt=(e,t,o,s)=>JSON.stringify([e,t,o,s]);function Qt(e,t){let o=new Map;for(let[s,c]of e){let r;try{r=JSON.parse(s)}catch{Ge(s)}(!Array.isArray(r)||r.length!==4)&&Ge(s);let[a,m,v,p]=r;if((!Wt(a)||!Wt(v)||!Object.hasOwn(Ht,m)||!Ht[m].has(p))&&Ge(s),(p==="alive"?typeof c!="boolean":p==="placement"?!ht(c)||Object.keys(c).sort().join(",")!=="columnId,pos"||typeof c.columnId!="string"||typeof c.pos!="string":p==="owner"||p==="due"?c!==null&&typeof c!="string":typeof c!="string")&&Ge(s),a!==t)continue;let u=o.get(m)??new Map,h=u.get(v)??{};h[p]=c,u.set(v,h),o.set(m,u)}return o}var Zt=e=>({pos:e.pos??"",name:e.name??""}),en=e=>({pos:e.placement?.pos??"",col:e.placement?.columnId??"",title:e.title??"",...e.owner!=null?{owner:e.owner}:{},...e.due!=null?{due:e.due}:{}}),qe=(e,t,o,s)=>Object.fromEntries([...e.get(t)??[]].filter(([,c])=>c.alive!==!1===s).map(([c,r])=>[c,o(r)]));function tn(e,t=null){let o=Qt(e,t),s=qe(o,"column",Zt,!0),c=qe(o,"card",en,!0),r=nt(s),a=[...new Set(Object.values(c).map(v=>v.col))].filter(v=>!Object.hasOwn(s,v)).sort(),m=[...r,...a].flatMap(v=>nt(Object.fromEntries(Object.entries(c).filter(([,p])=>p.col===v))));return{columns:Object.fromEntries(r.map(v=>[v,s[v]])),cards:Object.fromEntries(m.map(v=>[v,c[v]]))}}function Uo(e,t){let o=Qt(e,t);return{columns:qe(o,"column",Zt,!1),cards:qe(o,"card",en,!1)}}var nn={name:"",pos:"",title:"",owner:null,due:null,placement:{columnId:"",pos:""}},Xt=(e,t,o)=>e==="card"&&o==="placement"?{columnId:t.col??"",pos:t.pos??""}:t[o]??nn[o];function Hn(e,t,o,s){let c=[];for(let[r,a]of Gn){let m=ht(o?.[a])?o[a]:{},v=ht(s?.[a])?s[a]:{};for(let p of new Set([...Object.keys(m),...Object.keys(v)])){let u=m[p],h=v[p];if(!h){u&&c.push([gt(e,r,p,"alive"),!1]);continue}u||c.push([gt(e,r,p,"alive"),!0]);for(let g of yt[r]){if(g==="alive")continue;let f=gt(e,r,p,g),d=Xt(r,h,g),b=u?Xt(r,u,g):t.has(f)?t.get(f):nn[g];ce(b)!==ce(d)&&c.push([f,qn(d)])}}}return c}function Lo(e,t,o,s){for(let[c,r]of Hn(t,e.boardFields,o,s))e.boardFields.set(c,r)}var on=e=>{let t=2166136261;for(let o=0;o<e.length;o++)t^=e.charCodeAt(o),t=Math.imul(t,16777619);return(t>>>0).toString(36)},Wn=(e,t)=>e.id.client===t.client&&t.clock>=e.id.clock&&t.clock<e.id.clock+e.length,Xn=e=>{if(typeof e!="string"||e.charCodeAt(0)!==91)return null;let t;try{t=JSON.parse(e)}catch{return null}return Array.isArray(t)&&t.length===2&&t[0]===He&&typeof t[1]=="string"?t[1]:null},Qn=e=>e.reduce((t,o)=>o.brk.client<t.brk.client||o.brk.client===t.brk.client&&o.brk.clock<t.brk.clock?o:t);function ln(e,t=null){let o=t?null:Ae(e.origins);try{return Zn(e,o??t)}finally{o&&o.dispose()}}function Zn(e,t){let o=e.ydoc.store,s=mt(e.gone),c=new Map,r=new Map;for(let n=e.flow._start;n;n=n.right){if(n.deleted||!(n.content instanceof X)||n.content.embed.b===void 0)continue;r.set(n.content.embed.b,(r.get(n.content.embed.b)??0)+1);let l=te(t.resolve(n.id)),i=c.get(l);(!i||n.id.client<i.id.client||n.id.client===i.id.client&&n.id.clock<i.id.clock)&&c.set(l,n)}let a=new Set(c.keys()),m=new Set,v=[],p=new Map;for(let n of e.origins.keys()){let l;try{l=JSON.parse(n)}catch{continue}if(!Array.isArray(l)||l.length!==3||l[0]!=="boundary"&&l[0]!=="alias")continue;let[,i,O]=l;if(!Number.isSafeInteger(i)||i<0||!Number.isSafeInteger(O)||O<0)continue;if(l[0]==="boundary"){let A=`${i}.${O}`,$=t.boundaryOf({client:i,clock:O});$&&$.kind==="copy"&&(s.copyActive.has(A)?$.recoveryOf&&m.add($.recoveryOf):a.has(A)&&v.push({key:sn(A),sourceKey:A,source:{client:i,clock:O},operationId:null,blockId:$.blockId,end:null,sv:[],legacy:!1,implicit:!0}))}(p.get(i)??p.set(i,new Set).get(i)).add(O)}let u=[],h=new Set(v.map(n=>n.key));for(let n of s.restores)for(let l of n.covers){let i=Xn(l);i===null||h.has(l)||!c.has(i)||(h.add(l),u.push({key:l,sourceKey:i,source:xe(i),operationId:null,blockId:c.get(i).content.embed.b,end:null,sv:[],legacy:!1,implicit:!0}))}let g=v.length||u.length?[...s.removals,...v,...u]:s.removals,f=new Map,d=new Map,b=new Map;for(let n of g){(b.get(n.sourceKey)??b.set(n.sourceKey,[]).get(n.sourceKey)).push(n);let i=null;if(n.implicit)i=c.get(n.sourceKey);else try{i=Oe(o,n.source)}catch{i=null}let O=te(t.resolve(n.source)),C=c.get(O);if((!i||i.deleted)&&C?.content.embed.b===n.blockId&&(i=C),!i)continue;if(n.legacy){!i.deleted&&i.content instanceof X&&i.content.embed.b===n.blockId&&te(t.resolve(i.id))===O&&f.set(i,{key:n.key,blockId:n.blockId,end:n.end?xe(n.end):null});continue}(d.get(i)??d.set(i,[]).get(i)).push(n)}let w=new Map,I=new Set(s.restores.map(n=>n.sourceKey)),j=(n,l)=>{let i=cn(l);if(i===null)return null;let O=t.boundaryOf({client:n.id.client,clock:n.id.clock});return O&&O.blockId===l&&O.recoveryOf===i?O:null},M=(n,l)=>{let i=j(n,l);return i&&i.kind==="restore"?i.recoveryOf:null},R=(n,l)=>{let i=j(n,l);return i&&i.kind==="copy"?i.recoveryOf:null},S=(n,l)=>{let i=M(n,l);return i!==null&&I.has(i)&&b.has(i)?i:null};for(let n of s.restores){let l=w.get(n.sourceKey)??w.set(n.sourceKey,new Set).get(n.sourceKey);for(let i of n.covers)l.add(i)}let E=new Map;for(let n=e.flow._start;n;n=n.right){if(n.deleted)continue;let l=n.content instanceof X?S(n,n.content.embed&&n.content.embed.b):null;if(l===null)continue;(E.get(l)??E.set(l,[]).get(l)).push(n)}let V=n=>{let l=b.get(n);if(!l||!l.length)return!1;let i=w.get(n);if(!i)return!1;for(let O of l)if(!i.has(O.key))return!1;return(E.get(n)?.length??0)>0||m.has(n)},B=[],q=[],ne=[],oe=[],Y=null,P="start",N=null,Ye=0,J={},Me=n=>{let l=e.attrs.get(n);return l&&l.get("t")||"paragraph"},re=n=>{n&&(Y&&!Y.atom?Y.runs.push({hole:n}):B.push({kind:"h",len:n,key:null}))},de=(n,l,i=!1)=>{let O=kt(n,b.get(n)??[],s),C=`recovered:${n}`,A=O?O.type:"paragraph",$=!Object.hasOwn(G.nodes,A);Y={kind:"b",id:C,baseId:C,brk:{client:l.id.client,clock:l.id.clock},implicit:!1,runs:[],len:1,atom:!$&&!G.nodes[A]?.isTextblock,opaque:$,recovered:!0,restored:!i,sourceKey:n,t:A,fields:O?O.attrs:null},B.push(Y),P=C},ee=(n,l,i)=>{Y={kind:"b",id:n,baseId:n,brk:l,implicit:i,runs:[],len:i?0:1,atom:!1,items:!i&&(r.get(n)??0)>1?[]:null},i?Y.t="paragraph":(Y.t=Me(n),Y.opaque=!Object.hasOwn(G.nodes,Y.t),Y.atom=!Y.opaque&&!G.nodes[Y.t]?.isTextblock),B.push(Y),P=n},ge=()=>{N&&(N.len&&(N.resume?N.resume.runs.push({hole:N.len}):B.push({kind:"h",len:N.len,key:N.active[0]?.key})),Y=N.resume,N=null)},$e=n=>{n.legacy&&n.text&&q.push({key:n.key,id:n.blockId,text:n.text,h:on(n.text)}),ne.push({key:n.key,sourceKey:n.sourceKey,blockId:n.blockId,end:n.end,sv:n.sv,at:n.at,live:n.live,items:n.items})},Qe=(n,l)=>Wn(n,l)?!0:Ke(n).some(i=>{if(!e.origins.has(lt(i.client,i.clock)))return!1;let O=t.resolve(i);return O.client===l.client&&O.clock===l.clock}),Ze=new Map([...p].map(([n,l])=>[n,[...l].sort((i,O)=>i-O)])),Ke=n=>{let l=Ze.get(n.id.client)??[],i=0,O=l.length;for(;i<O;){let A=i+O>>1;l[A]<n.id.clock?i=A+1:O=A}let C=[];for(let A=i;A<l.length&&l[A]<n.id.clock+n.length;A++)C.push({client:n.id.client,clock:l[A]});return C},H=[],et=n=>({blockId:n.blockId,end:n.end?xe(n.end):null,implicit:n.implicit===!0,sourceKey:n.sourceKey});for(let n=e.flow._start;n;n=n.right){let l=Ye;if(!n.deleted&&n.countable&&(Ye+=n.length),N||H.length){let A=!n.deleted&&n.content instanceof X?n.content.embed.b:void 0,$=A!==void 0&&M(n,A)===null,F=n.deleted?Ke(n).flatMap(T=>{let z=te(t.resolve(T)),tt=t.boundaryOf(T);return!tt||tt.kind!=="removed"||a.has(z)?[]:[{blockId:tt.blockId,sourceKey:z}]}):[],K=T=>T.end?Qe(n,T.end):T.implicit?$||F.some(z=>z.sourceKey!==T.sourceKey):$&&A!==T.blockId||F.some(z=>z.blockId!==T.blockId);if(N){let T=[];for(let z of N.active)K(z)?$e(z):T.push(z);N.active=T,T.length||ge()}for(let T=H.length-1;T>=0;T--)H[T].active=H[T].active.filter(z=>!K(z)),H[T].active.length||H.splice(T,1)}let i=d.get(n);if(i){if(!N&&V(i[0].sourceKey)){n.deleted||re(n.length),H.push({active:i.map(et),sourceKey:i[0].sourceKey,root:null});continue}!N&&n.deleted&&oe.push({client:n.id.client,clock:n.id.clock});for(let A of i){let $={legacy:!1,implicit:A.implicit===!0,key:A.key,sourceKey:A.sourceKey,blockId:A.blockId,end:A.end?xe(A.end):null,sv:A.sv,at:l,live:!n.deleted,items:[]};N?N.active.push($):N={active:[$],len:0,resume:Y}}n.deleted||(N.len+=n.length);continue}let O=f.get(n);if(O){if(!N&&V(O.key)){n.deleted||re(n.length),H.push({active:[{blockId:O.blockId,end:O.end}],sourceKey:O.key,root:null});continue}let A={legacy:!0,key:O.key,sourceKey:O.key,blockId:O.blockId,end:O.end,sv:[],at:l,live:!0,items:[],text:""};N?N.active.push(A):N={active:[A],len:0,resume:Y},N.len+=1;continue}if(n.deleted)continue;let C=n.content;if(C instanceof rt){C.value===null?delete J[C.key]:J[C.key]=C.value;continue}if(N){if(C instanceof ie||C instanceof X){let A=C instanceof ie?C.str:C.embed.b!==void 0?"\xB6":`
2
- `,$={...J};for(let F of N.active)F.legacy&&(F.text+=A),F.items.push({at:l,id:te(n.id),client:n.id.client,clock:n.id.clock,length:n.length,kind:C instanceof ie?"text":C.embed.b!==void 0?"marker":"br",text:C instanceof ie?C.str:null,blockId:C instanceof X&&C.embed.b!==void 0?C.embed.b:null,raw:$});N.len+=n.length}continue}if(C instanceof rt){C.value===null?delete J[C.key]:J[C.key]=C.value;continue}if(C instanceof X){let A=S(n,C.embed.b);if(A!==null){let K=H.find(T=>T.sourceKey===A&&!T.root);K&&!m.has(A)?(de(A,n),K.root=Y):re(n.length);continue}if(M(n,C.embed.b)!==null){re(n.length);continue}let $=R(n,C.embed.b);if($!==null){de($,n,!0);continue}let F=C.embed;F.b!==void 0?ee(F.b,{client:n.id.client,clock:n.id.clock},!1):((!Y||Y.atom)&&ee(`~${P}`,null,!0),Y.runs.push({br:!0}),Y.items&&Y.items.push({at:l,id:te(n.id),client:n.id.client,clock:n.id.clock,length:n.length,kind:"br",text:null,blockId:null,raw:{...J}}),Y.len+=1);continue}if(C instanceof ie){(!Y||Y.atom)&&ee(`~${P}`,null,!0);let A=_e(J,Y.t);Y.runs.push({text:C.str,marks:A,mk:Kt(A)}),Y.items&&Y.items.push({at:l,id:te(n.id),client:n.id.client,clock:n.id.clock,length:n.length,kind:"text",text:C.str,blockId:null,raw:{...J}}),Y.len+=C.str.length}}if(N){for(let n of N.active)$e(n);ge()}let ye=new Map;for(let n of B)n.kind!=="b"||n.implicit||(ye.get(n.baseId)??ye.set(n.baseId,[]).get(n.baseId)).push(n);let he=n=>n.runs.map(l=>l.br?`
3
- `:l.hole?"":l.text).join(""),me=new Map,ke=[];for(let[n,l]of ye){if(l.length<2)continue;let i=Qn(l);for(let O of l)if(O!==i&&(O.hide=!0,(me.get(n)??me.set(n,[]).get(n)).push(te(O.brk)),!(Se(O.runs,i.runs)&&O.t===i.t)&&he(O)&&(q.push({key:`d${O.brk.client}.${O.brk.clock}`,id:n,text:he(O),h:on(he(O)),copy:!0}),O.items?.length))){let C=te(t.resolve(O.brk)),A=rn(C);ke.push({key:A,sourceKey:C,source:{client:O.brk.client,clock:O.brk.clock},operationId:null,blockId:n,end:null,sv:[],legacy:!1,implicit:!0}),ne.push({key:A,sourceKey:C,blockId:n,end:null,sv:[],at:O.items[0].at,live:!0,items:O.items})}}let y=[],k=[],x=0;for(let n of B){if(n.kind==="h"){k.push({at:x,len:n.len});continue}if(n.hide){k.push({at:x,len:n.len+n.runs.reduce((i,O)=>i+(O.hole??0),0)});continue}y.push(n);let l=n.implicit?0:1;for(let i of n.runs)i.hole?k.push({at:x+l,len:i.hole}):l+=i.br?1:i.text.length;x+=n.len}return{visible:y,holes:k,orphans:q,tokens:x,copies:me,hidden:ne,removals:ke.length?[...g,...ke]:g,fences:oe}}var wt="remove",yn="restore",vt="copy-active",He="copy-lost",hn="attr",mn="text-delete",We=class extends Error{constructor(t){super(t),this.name="RecoveryError"}},D=e=>{throw new We(e)},ae=e=>Number.isSafeInteger(e)&&e>=0,eo=e=>Number.isSafeInteger(e)&&e>0,an=/^(?:0|[1-9]\d*)$/,kn=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Q=e=>e===null||typeof e!="object"?e:JSON.parse(JSON.stringify(e)),Ee=(e,t)=>e<t?-1:e>t?1:0,bn=e=>[...e].sort(Ee),fn=e=>`${e.client}.${e.clock}`,to=e=>JSON.stringify(["author",e]),cs=(e,t)=>JSON.stringify([wt,e,t]),is=(e,t)=>JSON.stringify([yn,e,t]),sn=e=>JSON.stringify([vt,e]),rn=e=>JSON.stringify([He,e]),ls=(e,t,o)=>JSON.stringify([mn,e,t,o]),as=(e,t)=>JSON.stringify([hn,e,t]);function Z(e){if(typeof e!="string")return null;let t=e.indexOf(".");if(t<1||t===e.length-1)return null;let o=e.slice(0,t),s=e.slice(t+1);if(!an.test(o)||!an.test(s))return null;let c=Number(o),r=Number(s);return ae(c)&&ae(r)?{client:c,clock:r}:null}var je=(e,t,o)=>{kn(e)||D(`Invalid gone record: ${o}`);for(let s of Object.keys(e))t.includes(s)||D(`Unsupported gone field ${s} in ${o}`)},un=(e,t)=>{Array.isArray(e)||D(`Invalid state vector in ${t}`);let o=[],s=-1;for(let c of e){(!Array.isArray(c)||c.length!==2)&&D(`Invalid state vector in ${t}`);let[r,a]=c;(!ae(r)||!ae(a)||r<=s)&&D(`Invalid state vector in ${t}`),s=r,o.push([r,a])}return o},no=e=>{if(typeof e!="string")return!1;if(e.charCodeAt(0)!==91)return Z(e)!==null;let t;try{t=JSON.parse(e)}catch{return!1}return!Array.isArray(t)||!Z(t[1])?!1:t[0]===wt?t.length===3&&typeof t[2]=="string"&&t[2]!=="":(t[0]===vt||t[0]===He)&&t.length===2},oo=(e,t,o)=>{if(t.charCodeAt(0)===91){let r=null;try{r=JSON.parse(t)}catch{D(`Malformed gone key: ${t}`)}if((!Array.isArray(r)||typeof r[0]!="string")&&D(`Malformed gone key: ${t}`),r[0]===wt){(r.length!==3||typeof r[2]!="string"||!r[2])&&D(`Malformed gone key: ${t}`);let a=Z(r[1]);a||D(`Malformed gone key: ${t}`),je(e,["blockId","end","sv"],t),(typeof e.blockId!="string"||!e.blockId)&&D(`Invalid removal record: ${t}`);let m=e.end??null;m!==null&&!Z(m)&&D(`Invalid removal record: ${t}`),o.removals.push({key:t,sourceKey:r[1],source:a,operationId:r[2],blockId:e.blockId,end:m,sv:un(e.sv,t),legacy:!1});return}if(r[0]===yn){(r.length!==3||typeof r[2]!="string"||!r[2])&&D(`Malformed gone key: ${t}`),Z(r[1])||D(`Malformed gone key: ${t}`),je(e,["covers","baseline"],t),(!Array.isArray(e.covers)||e.covers.some(m=>!no(m)))&&D(`Invalid restore record: ${t}`);let a=e.baseline??{};je(a,["type","attrs"],t),(typeof a.type!="string"||!kn(a.attrs))&&D(`Invalid restore record: ${t}`),o.restores.push({key:t,sourceKey:r[1],operationId:r[2],covers:bn(e.covers),baseline:{type:a.type,attrs:Q(a.attrs)}});return}if(r[0]===vt){(r.length!==2||!Z(r[1]))&&D(`Malformed gone key: ${t}`),e!==!0&&D(`Invalid copy-active record: ${t}`),o.copyActive.add(r[1]);return}if(r[0]===mn){(r.length!==4||!ae(r[1])||!ae(r[2])||typeof r[3]!="string"||!r[3])&&D(`Malformed gone key: ${t}`),je(e,["length","actor","sv"],t),(!eo(e.length)||!ae(r[2]+e.length-1))&&D(`Invalid text-delete record: ${t}`),ae(e.actor)||D(`Invalid text-delete record: ${t}`),o.textDeletes.push({key:t,client:r[1],clock:r[2],length:e.length,actor:e.actor,sv:un(e.sv,t)});return}if(r[0]===hn){(r.length!==3||!Z(r[1])||typeof r[2]!="string"||!r[2])&&D(`Malformed gone key: ${t}`),e===void 0&&D(`Invalid attribute override: ${t}`);let a=o.attrs.get(r[1])??new Map;a.set(r[2],Q(e)),o.attrs.set(r[1],a);return}D(`Unsupported gone record: ${t}`)}let s=Z(t);s||D(`Malformed gone key: ${t}`),je(e,["b","e"],t),(typeof e.b!="string"||!e.b)&&D(`Invalid gone record: ${t}`);let c=e.e??null;c!==null&&!Z(c)&&D(`Invalid gone record: ${t}`),o.removals.push({key:t,sourceKey:t,source:s,operationId:null,blockId:e.b,end:c,sv:[],legacy:!0})};function mt(e,{strict:t=!1}={}){let o={removals:[],restores:[],copyActive:new Set,attrs:new Map,textDeletes:[]};return e.forEach((s,c)=>{try{oo(s,c,o)}catch(r){if(t||!(r instanceof We))throw r}}),o}var bt=e=>{if(Array.isArray(e))return e.map(bt);if(e!==null&&typeof e=="object"){let t={};for(let o of Object.keys(e).sort())t[o]=bt(e[o]);return t}return e},so=e=>JSON.stringify(bt(e)),Xe=e=>G.nodes[e]??G.nodes.paragraph,ro=(e,t,o=null)=>{let s=e.attrs.get(t),c=o?.get("t"),r=s&&s.get("t")||"paragraph",a=typeof c=="string"&&G.nodes[c]?c:r,m=Xe(a),v={};for(let p of Ve(m))v[p]=Q(s&&s.has(p)?s.get(p):Be(m,p));if(a==="table"&&Object.assign(v,Q(qt(e.tableFields,t,{cols:v.cols,rows:v.rows}))),a==="board"&&Object.assign(v,Q(tn(e.boardFields,t))),o)for(let[p,u]of o)p!=="t"&&Object.hasOwn(v,p)&&(v[p]=Q(u));return{id:t,type:a,attrs:v}},co=e=>{let t={};if(!e)return t;for(let o of[...e.keys()].sort())t[o]=Q(e.get(o));return t},dn="recovered:",cn=e=>typeof e=="string"&&e.startsWith(dn)?e.slice(dn.length):null;function kt(e,t,o){let s=new Set(t.map(h=>h.key)),c=null;for(let h of o.restores){if(h.sourceKey!==e)continue;let g=h.covers.reduce((f,d)=>f+(s.has(d)?1:0),0);(!c||g>c.count||g===c.count&&Ee(h.key,c.restore.key)<0)&&(c={restore:h,count:g})}if(!c)return null;let r=o.attrs.get(e),a=r?.get("t"),m=G.nodes[c.restore.baseline.type]?c.restore.baseline.type:"paragraph",v=typeof a=="string"&&G.nodes[a]?a:m,p=Xe(v),u={};for(let h of Ve(p))r&&r.has(h)?u[h]=Q(r.get(h)):Object.hasOwn(c.restore.baseline.attrs,h)?u[h]=Q(c.restore.baseline.attrs[h]):u[h]=Q(Be(p,h));return{type:v,attrs:u,key:c.restore.key}}var io=e=>{let t={};for(let o of Object.keys(e).sort())t[o]=Q(e[o]);return t},lo=(e,t)=>t.some(o=>e.clock>=(o.get(e.client)??0)),ao=(e,t)=>{let o=e[e.length-1];if(o&&t<=o.end){t===o.end&&(o.end=t+1);return}e.push({start:t,end:t+1})},fo=e=>{let t=[];for(let o of[...e].sort(Ee))ao(t,o);return t},uo=(e,t)=>{let o=0,s=e.length-1;for(;o<=s;){let c=o+s>>1,r=e[c];if(t<r.start)s=c-1;else if(t>=r.end)o=c+1;else return!0}return!1},po=(e,t,o)=>{let s=Nt(t,e.length).physicalRanges(0,t.tokens),c=new Map,r=(p,u,h)=>{for(let g=u;g<h;g++){let f=o.resolve({client:p.id.client,clock:p.id.clock+g}),d=c.get(f.client);d?d.push(f.clock):c.set(f.client,[f.clock])}},a=0,m=0;for(let p=e._start;p&&m<s.length;p=p.right){if(p.deleted||!p.countable)continue;let u=a;a+=p.length;let h=p.content,g=h instanceof ie;if(!g&&!(h instanceof X)||!g&&h.embed.b!==void 0)continue;for(;m<s.length&&s[m][1]<=u;)m++;let f=m;for(;f<s.length&&s[f][0]<a&&(r(p,Math.max(u,s[f][0])-u,Math.min(a,s[f][1])-u),!(s[f][1]>=a));)f++;m=f}let v=new Map;for(let[p,u]of c)v.set(p,fo(u));return(p,u)=>{let h=v.get(p);return h?uo(h,u):!1}},pn=(e,t,o,s,c)=>{let r=e.resolve({client:t.client,clock:t.clock}),a=t.kind==="text"?$t(_e(t.raw,s)):{},m=!lo(t,o);return{client:t.client,clock:t.clock,length:t.length,sourceClient:r.client,sourceClock:r.clock,baseline:m,displaced:!m&&!c(r.client,r.clock),kind:t.kind,text:t.kind==="text"?t.text:null,marks:a,raw:io(t.raw)}},gn=(e,t)=>{let o=e[e.length-1];if(o&&o.kind===t.kind&&o.baseline===t.baseline&&o.displaced===t.displaced&&o.client===t.client&&o.clock+o.length===t.clock&&o.sourceClient===t.sourceClient&&o.sourceClock+o.length===t.sourceClock&&Se(o.marks,t.marks)&&Se(o.raw,t.raw)){o.length+=t.length,o.kind==="text"&&(o.text+=t.text);return}e.push(t)},go=(e,t)=>({id:fn(e),length:e.length,source:fn({client:e.sourceClient,clock:e.sourceClock}),baseline:e.baseline,displaced:e.displaced,kind:e.kind,...e.kind==="text"?{text:e.text}:{},marks:e.marks,raw:e.raw,author:t(e.sourceClient)});function yo(e,t,o,s,c,r,a,m){let v=(S,E,V=null)=>{let B=t.boundaryOf(E);if(!B||B.blockId!==S||!B.recoveryOf)return ro(e,S,V);let q=kt(B.recoveryOf,m.get(B.recoveryOf)??[],r),ne=typeof V?.get("t")=="string"&&G.nodes[V.get("t")]?V.get("t"):q?.type??"paragraph",oe={};for(let Y of Ve(Xe(ne)))oe[Y]=Q(V?.has(Y)?V.get(Y):q&&Object.hasOwn(q.attrs,Y)?q.attrs[Y]:Be(Xe(ne),Y));return{id:S,type:ne,attrs:oe}},p=S=>{let E=e.origins.get(to(S));return typeof E=="string"&&E?E:null},u=[...s].sort((S,E)=>Ee(S.key,E.key)),h=u[0].blockId,g=r.attrs.get(o),f=co(g),d=v(h,u[0].source,g),b=new Map(u.map(S=>[S.key,new Map(S.sv)])),w=new Map;for(let S of u){let E=c.get(S.key);if(!E)continue;let V=b.get(S.key);for(let B of E.items){let q=w.get(B.id);q?q.vectors.push(V):w.set(B.id,{item:B,vectors:[V]})}}let I=[...w.values()].sort((S,E)=>S.item.at-E.item.at),j=[{...d,author:p(t.resolve(u[0].source).client),runs:[]}],M=j[0];for(let S of I){let E=S.item;if(E.kind==="marker"){if(t.boundaryOf({client:E.client,clock:E.clock})?.kind==="restore"||!E.blockId||E.blockId===M.id)continue;M={...v(E.blockId,{client:E.client,clock:E.clock}),author:p(t.resolve({client:E.client,clock:E.clock}).client),runs:[]},j.push(M);continue}if(E.kind==="text")for(let V=0;V<E.length;V++)gn(M.runs,pn(t,{...E,clock:E.clock+V,length:1,text:E.text[V]},S.vectors,M.type,a));else gn(M.runs,pn(t,E,S.vectors,M.type,a))}let R={source:o,blockId:h,type:d.type,attrs:d.attrs,author:j[0].author,blocks:j.map(S=>({id:S.id,type:S.type,attrs:S.attrs,author:S.author,runs:S.runs.map(E=>go(E,p))})),removals:u.map(S=>({key:S.key,operationId:S.operationId,end:S.end,sv:S.sv})),restores:r.restores.filter(S=>S.covers.some(E=>u.some(V=>V.key===E))).sort((S,E)=>Ee(S.key,E.key)).map(S=>({key:S.key,covers:bn(S.covers)})),copyActive:r.copyActive.has(o),overrides:f,recoverable:j.some(S=>S.runs.some(E=>E.displaced))};return{...R,revision:so(R)}}function fs(e,t={}){let o=t.index??Ae(e.origins);try{let s=t.walked??ln(e,o),c=t.intents??mt(e.gone,{strict:t.strict===!0}),r=new Map;for(let h of s.hidden??[])r.set(h.key,h);let a=new Map;for(let h of s.removals??c.removals){let g=a.get(h.sourceKey);g?g.push(h):a.set(h.sourceKey,[h])}let m=null,v=(h,g)=>(m||(m=po(e.flow,s,o)),m(h,g)),p=new Map;for(let[h,g]of a)p.set(h,yo(e,o,h,g,r,c,v,a));let u=[...p.values()].sort((h,g)=>{let f=Z(h.source),d=Z(g.source);return f.client-d.client||f.clock-d.clock});return{sources:p,list:u,intents:c}}finally{t.index||o.dispose()}}export{Ae as a,ho as b,mo as c,ft as d,Pe as e,Ut as f,Yo as g,Mo as h,at as i,le as j,Ue as k,Yn as l,So as m,L as n,Bt as o,xo as p,qt as q,zn as r,Bo as s,gt as t,tn as u,Uo as v,Lo as w,We as x,fn as y,to as z,cs as A,is as B,sn as C,ls as D,as as E,Z as F,mt as G,so as H,dn as I,cn as J,kt as K,fs as L,ln as M};
@@ -1 +0,0 @@
1
- import{F as P,c as S,q as c,s as d,u as h,v as k}from"./c-TCJTVAFN.js";import"./c-GQ6F6IDK.js";import{b as f,d as y}from"./c-2SPVQSHC.js";import"./c-5VYOWDTI.js";import"./c-QJ4OM3G6.js";import"./c-MKSQ4Y57.js";import"./c-WYFDLITL.js";import"./c-UGHH4MB3.js";import"./c-ZWIOJGMT.js";import{j as l,m as w,n as D,o as x}from"./c-LWLBHLVC.js";import"./c-SDAXDM2D.js";import"./c-TQEMVJCS.js";import"./c-DCXOXBF3.js";import"./c-VRZN56XY.js";import"./c-IJUK2GPW.js";import"./c-OW5QIGG3.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-N7JPUPGC.js";import"./c-SPIORRYS.js";import"./c-XQXZAO7N.js";import"./c-S7LK4KUE.js";import"./c-VG5XIN4T.js";import"./c-2YYDMLNZ.js";import"./c-HA6INT6J.js";import"./c-DCFSEJZG.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var E=15e3,b=Symbol("the barrier deadline passed"),M=2,e=(n,t={})=>({ok:!1,code:n,...t});async function I(n,t){let s=null,u=new Promise(r=>{s=setTimeout(()=>r(b),Math.max(0,t-Date.now()))});try{return await Promise.race([Promise.resolve(n),u])}finally{clearTimeout(s)}}async function X({generation:n=d(),keepalive:t=!1,timeoutMs:s=E,operation:u=null}={}){let r=u?null:w("mode");if(!u&&!r)return e("busy");let i=Date.now()+s,p=h(n);try{for(let m=0;;m++){if(n!==d())return e("stale-document");if(Date.now()>=i)return e("timeout");let a=await I(y(),i);if(a===b)return e("timeout");if(!a.ok)return e("pending-input",{pending:a.pending});if(a.pending.length)return e("pending-input",{pending:a.pending});if(c())return e("conflict");if(l())return e("save-unknown");let o;try{o=await P({keepalive:t,timeoutMs:Math.max(0,i-Date.now()),permit:p})}catch(v){return v?.state==="conflict"?e("conflict"):v?.state==="blocked"?e("pending-input",{pending:f()}):l()?e("save-unknown"):Date.now()>=i?e("timeout"):e("save-failed")}if(o.state!=="clean"&&o.state!=="saved")return e("save-failed");if(c())return e("conflict");if(l())return e("save-unknown");let g=f();if(g.length)return e("pending-input",{pending:g});if(S()){if(m+1<M&&Date.now()<i)continue;return e("pending-input")}return{ok:!0,state:o.state,etag:o.etag??null}}}finally{k(p),r&&D(r)}}export{w as claimOperation,x as operationKind,D as releaseOperation,X as runSaveBarrier};
@@ -1,4 +0,0 @@
1
- import{A as zt,B as Vt,D as et,G as it,H as ct,I as z,a as N,aa as Rt,b as O,ba as lt,ca as qt,d as B,e as Y,ea as _t,f as Dt,fa as Kt,g as J,ga as Ht,j as C,k as Z,m as T,n as tt,p as $t,qa as jt,s as Bt,u as at,y as Lt,z as Pt}from"./c-WWXIDH4O.js";var fe=n=>n==="left"||n==="right"?n:null,{Plugin:xt,PluginKey:pe,TextSelection:I,NodeSelection:Ut,Selection:ot}=O,E=T.nodes,A=n=>n.type===E.list_item,S=n=>n.type===E.toggle,b=n=>n.attrs.parent??null,yt="page-step",R="page-move",At=n=>n&&(t=>n(Y.closeHistory(t).setMeta(yt,!0)));function y(n){let t=[],e=new Map,o=[];n.forEach((r,a)=>{let s=t.length,i=t[s-1],l=b(r),c=l!==null&&e.has(l)?e.get(l):-1,u=c;if(A(r)){for(i&&A(i.node)&&b(i.node)===l||(o=[]);o.length&&t[o[o.length-1]].node.attrs.indent>=r.attrs.indent;)o.pop();o.length&&(u=o[o.length-1]),o.push(s)}else o=[];let p=c>=0&&(t[c].hidden||!t[c].node.attrs.open);t.push({node:r,at:a,end:a+r.nodeSize,i:s,up:u,depth:c>=0?t[c].depth+1:0,hidden:p,subEnd:s}),S(r)&&r.attrs.id&&e.set(r.attrs.id,s)});for(let r=t.length-1;r>=0;r--){let a=t[r].up;a>=0&&t[r].subEnd>t[a].subEnd&&(t[a].subEnd=t[r].subEnd)}return t}var Hn=(n,t)=>({from:n[t].at,to:n[n[t].subEnd].end});function he(n,t=null){let e=new Map;t?.forEach(c=>{c.attrs.id&&e.set(c.attrs.id,b(c))}),n.forEach(c=>{c.attrs.id&&e.set(c.attrs.id,b(c))});let o=[];n.forEach((c,u)=>o.push({node:c,at:u}));let r=new Array(o.length).fill(null);for(let c=o.length-2;c>=0;c--){let u=b(o[c+1].node);r[c]=u!==b(o[c].node)?u:r[c+1]}let a=[],s=[null],i=null,l=[];return o.forEach(({node:c,at:u},p)=>{let d=b(c),f=new Set;for(;d!==null&&!s.includes(d)&&!f.has(d);)f.add(d),d=e.has(d)?e.get(d):null;s.includes(d)||(d=null);let m=r[p];s.indexOf(m)>s.indexOf(d)&&(d=m);let h=s.slice(0,s.indexOf(d)+1),x=c.attrs.indent;if(A(c)){let g=Number.isInteger(x)&&x>0?x:0,v=i&&A(i.node)&&i.parent===d;for(v||(l=[]);l.length&&l[l.length-1].orig>g;)l.pop();let D=0;if(l.length){let w=l[l.length-1];D=w.shift,w.orig===g&&l.pop()}x=Math.max(0,Math.min(g-D,v?i.indent+1:0)),l.push({orig:g,shift:g-x})}else l=[];(d!==b(c)||A(c)&&x!==c.attrs.indent)&&a.push({at:u,attrs:{...c.attrs,parent:d,...A(c)?{indent:x}:{}}}),i={node:c,parent:d,indent:x},s=S(c)&&c.attrs.id?[...h,c.attrs.id]:h}),a}function jn(){return new xt({appendTransaction(n,t,e){if(!n.some(a=>a.docChanged&&!a.getMeta(et)))return null;let o=he(e.doc,t.doc);if(!o.length)return null;let r=e.tr;for(let a of o)r.setNodeMarkup(a.at,null,a.attrs);return r}})}function rt(n,t,e){let o=n.resolve(t.from).index(0),r=Math.min(n.resolve(t.to).index(0),e.length-1);return r>o&&t.to<=e[r].at&&r--,[Math.min(o,e.length-1),r]}var Yt=rt;function L(n,t,e){let o=t;for(;n[o].up>=0&&e>n[n[o].up].subEnd;)o=n[o].up;let r=n[o].up,a=n[o].subEnd;for(;a<e;)a=n[a+1].subEnd;return{lo:o,hi:a,up:r}}var me=(n,t,e)=>{let o=n.resolve(Math.max(0,Math.min(t,n.content.size)));return o.depth===0?o.pos:e<0?o.before(1):o.after(1)},Ft=n=>({id:n.node.attrs.id,at:n.at,node:n.node}),pt=(n,t)=>t.id?n.node.attrs.id===t.id:n.at===t.at&&n.node.type===t.node.type&&n.node.content.eq(t.node.content);function ge(n,t,e){let o=[];for(let r=t;r<=e;r=n[r].subEnd+1)o.push(Ft(n[r]));return{roots:o,members:n.slice(t,e+1).map(Ft)}}function be(n,t){let e=t.roots.map(s=>n.findIndex(i=>pt(i,s))).filter(s=>s>=0);if(!e.length||e.some(s=>n[s].hidden))return null;let o=e[0],r=n[o].up,a=n[o].subEnd;for(let s of e.slice(1)){if(s!==a+1||n[s].up!==r)return null;a=n[s].subEnd}return n.slice(o,a+1).some(s=>!t.members.some(i=>pt(s,i)))?null:{lo:o,hi:a}}var ke=(n,t)=>{let e=o=>({...o,at:t.map(o.at,1)});return{roots:n.roots.map(e),members:n.members.map(e)}},k=class n extends ot{map(t,e){return this.getBookmark().map(e).resolve(t)}eq(t){return t instanceof n&&t.anchor===this.anchor&&t.head===this.head}toJSON(){return{type:"page-block",anchor:this.anchor,head:this.head}}static fromJSON(t,e){return new n(t.resolve(e.anchor),t.resolve(e.head))}getBookmark(){let{lo:t,hi:e}=this.span();return new ht(this.anchor,this.head,ge(y(this.$from.doc),t,e))}span(t=this.$from.doc){return{lo:t.resolve(this.from).index(0),hi:t.resolve(this.to).index(0)-1}}};k.prototype.visible=!1;ot.jsonID("page-block",k);var ht=class n{constructor(t,e,o){this.anchor=t,this.head=e,this.span=o}map(t){let e=this.anchor<=this.head;return new n(t.map(this.anchor,e?1:-1),t.map(this.head,e?-1:1),ke(this.span,t))}resolve(t){let e=y(t),o=be(e,this.span);if(!o){let s=e.find(i=>pt(i,this.span.roots[0]));return ot.near(t.resolve(s?.at??me(t,Math.min(this.anchor,this.head),-1)))}let r=e[o.lo].at,a=e[o.hi].end;return this.anchor<=this.head?new k(t.resolve(r),t.resolve(a)):new k(t.resolve(a),t.resolve(r))}},Jt=(n,t)=>{for(let e=t-1;e>=0;e--)if(n[e].up===n[t].up)return e;return-1};function G(n,t,e,o,r=()=>null){let a=r(n[t])||{},s="parent"in a?a.parent:b(n[t].node),i=null;for(let u=0;u<n.length&&n[u].end<=o;u++)u>=t&&u<=e||b(n[u].node)===s&&(i=n[u].node.attrs.id);let l=[],c={};for(let u=t;u<=e;u++){let p=n[u].node,d=r(n[u]);l.push(p.attrs.id),d&&"indent"in d&&d.indent!==p.attrs.indent&&(c[p.attrs.id]={indent:d.indent})}return{ids:l,afterId:i,parent:s,attrs:c}}function Zt(n,t,e,o,r,a=()=>null,s=n.selection){let i=t[e].at,l=t[o].end,c=l-i,u=[];for(let m=e;m<=o;m++){let h=t[m].node;u.push(h.type.create({...h.attrs,...a(t[m])||{},pos:null},h.content,h.marks))}let p=n.tr.delete(i,l),d=r>i?r-c:r;p.insert(d,u);let f=d-i;return s instanceof k?p.setSelection(new k(p.doc.resolve(s.anchor+f),p.doc.resolve(s.head+f))):s instanceof Ut?p.setSelection(Ut.create(p.doc,s.from+f)):p.setSelection(I.create(p.doc,s.anchor+f,s.head+f)),p.setMeta(R,G(t,e,o,r,a))}function mt(n,t,e){let o=n[e].node;if(S(o)){let a=o.attrs.id,s=b(o);return i=>b(i.node)===a?{parent:s}:null}let r=o.attrs.indent-n[t].node.attrs.indent;return a=>A(a.node)?{indent:a.node.attrs.indent+r}:null}var Gt=n=>(t,e)=>{e=At(e);let o=y(t.doc);if(!o.length)return!1;let[r,a]=rt(t.doc,t.selection,o),{lo:s,hi:i,up:l}=L(o,r,a),c,u=()=>null;if(n<0){let p=Jt(o,s);if(p>=0)c=o[p].at;else if(l>=0)c=o[l].at,u=mt(o,s,l);else return!0}else{let p=i+1;if(p<o.length&&o[p].up===l)c=o[o[p].subEnd].end;else if(l>=0)c=o[o[l].subEnd].end,u=mt(o,s,l);else return!0}return e&&e(Zt(t,o,s,i,c,u).scrollIntoView()),!0},xe=8,nt=(n,t)=>A(n.node)&&A(t.node)&&b(n.node)===b(t.node);function ye(n,t){t=At(t);let e=y(n.doc);if(!e.length)return!1;let[o,r]=rt(n.doc,n.selection,e),a=e[o];if(A(a.node)&&o>0&&nt(e[o-1],a)){if(a.node.attrs.indent>e[o-1].node.attrs.indent)return!0;for(let i=o;i<=Math.max(r,a.subEnd);i++)if(e[i].node.attrs.indent>=xe)return!0;if(t){let i=n.tr,l=r;for(let u=o;u<=l;u++)l=Math.max(l,e[u].subEnd);let c=o-1;for(let u=o;u<=l&&nt(e[u],a);u++)i.setNodeMarkup(e[u].at,null,{...e[u].node.attrs,indent:e[u].node.attrs.indent+1}),c=u;i.setMeta(R,G(e,o,c,e[o].at,u=>u.i>=o&&u.i<=c?{indent:u.node.attrs.indent+1}:null)),t(i)}return!0}let s=Jt(e,o);if(s<0||!S(e[s].node)||e[s].subEnd!==o-1)return!0;if(t){let{hi:i}=L(e,o,r),l=n.tr,c=b(a.node),u=e[s].node.attrs.id,p=[];for(let f=o;f<=i;f++)b(e[f].node)===c&&(l.setNodeMarkup(e[f].at,null,{...e[f].node.attrs,parent:u}),p.push(e[f].node.attrs.id));e[s].node.attrs.open||l.setNodeMarkup(e[s].at,null,{...e[s].node.attrs,open:!0});let d=G(e,o,i,e[o].at,f=>f.i>=o&&f.i<=i&&b(f.node)===c?{parent:u}:null);l.setMeta(R,{...d,ids:p,attrs:e[s].node.attrs.open?d.attrs:{...d.attrs,[u]:{open:!0}}}),t(l)}return!0}function St(n,t){t=At(t);let e=y(n.doc);if(!e.length)return!1;let[o,r]=rt(n.doc,n.selection,e),a=e[o];if(A(a.node)&&a.node.attrs.indent>0){if(t){let{lo:u,hi:p}=L(e,o,r),d=n.tr,f=new Set;for(let m=o;m<=r;){let h=e[m];if(A(h.node)&&h.node.attrs.indent>0)for(let x=m;x<=h.subEnd;x++)A(e[x].node)&&(d.setNodeMarkup(e[x].at,null,{...e[x].node.attrs,indent:e[x].node.attrs.indent-1}),f.add(x));m=h.subEnd+1}d.setMeta(R,G(e,u,p,e[u].at,m=>f.has(m.i)?{indent:m.node.attrs.indent-1}:null)),t(d)}return!0}if(b(a.node)===null)return!0;let{lo:i,hi:l}=L(e,o,r),c=e[i].up;for(;c>=0&&!S(e[c].node);)c=e[c].up;if(c<0)return!0;if(t){let u=mt(e,i,c),p=e[c].subEnd;if(l===p){let d=n.tr;for(let f=i;f<=l;f++){let m=u(e[f]);m&&d.setNodeMarkup(e[f].at,null,{...e[f].node.attrs,...m})}d.setMeta(R,G(e,i,l,e[i].at,u)),t(d)}else t(Zt(n,e,i,l,e[p].end,u).scrollIntoView())}return!0}function te(n){let t=n.tr;return n.selection.empty||t.deleteSelection(),t}function Ae(n,t){let{$from:e,$to:o,empty:r}=n.selection;if(e.depth!==1||!A(e.parent)||!e.sameParent(o))return!1;if(r&&e.parent.content.size===0){let m=e.parent;return m.attrs.indent>0?St(n,t):(t&&t(n.tr.setNodeMarkup(e.before(),E.paragraph,{id:m.attrs.id,pos:m.attrs.pos,parent:m.attrs.parent})),!0)}let a=te(n),s=a.selection.$from,i=s.parent,l=y(a.doc),c=s.index(0),u=s.parentOffset===0,p=s.parentOffset===i.content.size,d=l[c+1],f=p&&d&&nt(d,l[c])&&d.node.attrs.indent>i.attrs.indent;return u?(a.split(s.pos,1,[{type:E.list_item,attrs:i.attrs}]),a.setNodeMarkup(l[c].at,null,{...i.attrs,checked:!1})):a.split(s.pos,1,[{type:E.list_item,attrs:{...i.attrs,checked:!1,indent:i.attrs.indent+(f?1:0)}}]),t&&t(a.scrollIntoView()),!0}function Se(n,t){let{$from:e,$to:o}=n.selection;if(e.depth!==1||!S(e.parent)||!e.sameParent(o))return!1;let r=te(n),a=r.selection.$from,s=a.parent,i=y(r.doc),l=a.index(0),c=i[l],u=c.subEnd>l;if(s.content.size===0&&!u)return r.setNodeMarkup(c.at,E.paragraph,{id:s.attrs.id,pos:s.attrs.pos,parent:s.attrs.parent}),t&&t(r),!0;if(a.parentOffset===0&&s.content.size>0)return r.insert(c.at,E.paragraph.create({parent:b(s)})),t&&t(r.scrollIntoView()),!0;let p=s.content.cut(a.parentOffset);if(s.attrs.open)r.split(a.pos,1,[{type:E.paragraph,attrs:{parent:s.attrs.id}}]);else{let d=i[c.subEnd].end,f=r.steps.length;r.delete(a.pos,c.end-1);let m=r.mapping.slice(f).map(d);r.insert(m,E.toggle.create({parent:b(s),open:!1},p)),r.setSelection(I.create(r.doc,m+1))}return t&&t(r.scrollIntoView()),!0}function we(n,t){let{$from:e,empty:o}=n.selection;if(!o||e.depth!==1||e.parent.type!==E.paragraph||e.parent.content.size)return!1;let r=b(e.parent);if(r===null)return!1;let a=y(n.doc),s=e.index(0),i=a.findIndex(l=>l.node.attrs.id===r);if(i<0||a[i].subEnd!==s)return!1;if(t){let l=a[s].node.attrs.id,c=b(a[i].node),u=s>0?a[s-1].node:null,p=n.tr.setNodeMarkup(a[s].at,null,{...e.parent.attrs,parent:c});p.setMeta(R,{ids:[l],afterId:u?u.attrs.id:null,parent:b(u??a[s].node),attrs:{[l]:{parent:c}}}),t(p)}return!0}function Ee(n,t){let{$from:e,empty:o}=n.selection;if(!o||e.depth!==1||!e.parent.isTextblock||e.parent.type.spec.code)return!1;let r=e.parent;if(A(r)||S(r)||b(r)===null||e.parentOffset!==r.content.size)return!1;if(t){let a=n.tr.split(e.pos,1,[{type:E.paragraph,attrs:{parent:b(r)}}]);t(a.scrollIntoView())}return!0}function Me(n,t){let{$from:e,empty:o}=n.selection;if(!o||e.depth!==1||!A(e.parent)||e.parentOffset!==0)return!1;if(e.parent.attrs.indent>0)return St(n,t);let r=e.parent;return t&&t(n.tr.setNodeMarkup(e.before(),E.paragraph,{id:r.attrs.id,pos:r.attrs.pos,parent:r.attrs.parent})),!0}function Te(n,t){let{$from:e,empty:o}=n.selection;if(!o||e.depth!==1||!S(e.parent)||e.parentOffset!==0)return!1;let r=e.parent;return t&&t(n.tr.setNodeMarkup(e.before(),E.paragraph,{id:r.attrs.id,pos:r.attrs.pos,parent:r.attrs.parent})),!0}function wt(n,t){if(t<=0||!n[t-1].hidden)return-1;let e=t-1;for(;e>=0&&n[e].hidden;)e--;return e>=0&&S(n[e].node)&&n[e].subEnd>=t-1?e:-1}function Et(n,t,e,o){let r=n.tr,a=t[o],s=t[e].end-1;return r.delete(a.at,a.end),a.node.content.size&&r.insert(s,a.node.content),r.setSelection(I.create(r.doc,s))}function ve(n,t){let{$from:e,empty:o}=n.selection;if(!o||e.depth!==1||e.parentOffset!==0||!e.parent.isTextblock)return!1;let r=y(n.doc),a=e.index(0),s=wt(r,a);return s<0?!1:(t&&t(Et(n,r,s,a).scrollIntoView()),!0)}function Ie(n,t){let{$from:e,empty:o}=n.selection;if(!o||e.depth!==1||!S(e.parent)||e.parent.attrs.open||e.parentOffset!==e.parent.content.size)return!1;let r=y(n.doc),a=e.index(0),s=r[a].subEnd+1;return s===a+1?!1:(s>=r.length||!r[s].node.isTextblock||t&&t(Et(n,r,a,s).scrollIntoView()),!0)}function Ne(n,t){let{$from:e,empty:o}=n.selection;if(!o||e.depth!==1)return!1;let r=e.parent,a=e.index(0);if(!r.isTextblock||r.type.spec.code||S(r)||!r.content.size||e.parentOffset!==r.content.size||a+1>=n.doc.childCount||!S(n.doc.child(a+1)))return!1;if(t&&r.type!==E.paragraph)t(n.tr.setSelection(I.create(n.doc,e.after()+1)).scrollIntoView());else if(t){let s=e.before(),i=n.tr.insert(e.after()+1,r.content).delete(s,e.after());t(i.setSelection(I.create(i.doc,s+1+r.content.size)).scrollIntoView())}return!0}var ee=n=>(t,e)=>{let{$from:o,empty:r}=t.selection;if(!r||o.depth!==1||!o.parent.isTextblock)return!1;let a=o.parent,s=o.index(0);if(o.parentOffset!==(n<0?0:a.content.size))return!1;let i=y(t.doc),l=n<0?wt(i,s):-1,c=l>=0?l:s+n;if(c<0||c>=i.length)return!1;let u=i[c].node;if(!u.isTextblock||!a.type.spec.code&&!u.type.spec.code)return!1;if(!e)return!0;let p=t.tr,d=i[s],f=i[c],m=n<0?f.end-1:f.at+1;return!a.content.size&&!a.type.spec.code?p.delete(d.at,d.end).setSelection(I.create(p.doc,p.mapping.map(m))):!u.content.size&&!u.type.spec.code?p.delete(f.at,f.end):p.setSelection(I.create(p.doc,m)),e(p.scrollIntoView()),!0},Oe=ee(-1),Ce=ee(1);function De(n,t){let{$from:e,empty:o}=n.selection;if(!o||e.depth!==1||e.parentOffset!==0||!e.parent.isTextblock)return!1;let r=e.parent;if(A(r)||S(r)||b(r)===null)return!1;let a=e.index(0);return n.doc.child(a-1).attrs.id!==b(r)?!1:(t&&t(Et(n,y(n.doc),a-1,a).scrollIntoView()),!0)}function ne(n,t,e,o=y(n.doc)){let r=o[t];return n.tr.setNodeMarkup(r.at,null,{...r.node.attrs,open:e}).setMeta("addToHistory",!1)}function $e(n,t){let{$from:e}=n.selection;return e.depth!==1||!S(e.parent)?!1:(t&&t(ne(n,e.index(0),!e.parent.attrs.open)),!0)}function Be(n){let t=[];for(let e of n)!S(e.node)||e.hidden||e.node.attrs.open||e.subEnd===e.i||t.push({line:e.at+1,sumEnd:e.end-1,from:e.end,to:n[e.subEnd].end});return t}var gt=(n,t)=>t>n.from&&t<n.to;function bt(n,t,e,o){if(o>0){let r=e.to;for(;;){let a=ot.findFrom(n.resolve(r),1,!0);if(!a)break;let s=t.find(i=>gt(i,a.head));if(!s)return a.head;r=s.to}}return e.sumEnd}function Wt(n,t,e,o=-1,r=!1){if(!e.length)return null;let{anchor:a,head:s}=t;if(!(t instanceof I)){let c=e.find(u=>t.from>=u.from&&t.from<u.to);return c?I.create(n,c.sumEnd):null}let i=e.find(c=>gt(c,s));i&&(s=bt(n,e,i,o));let l=e.find(c=>gt(c,a));if(l&&(a=l.sumEnd),!r&&a!==s){let c=Math.min(a,s),u=Math.max(a,s),p=e.find(d=>(c>d.line||c===d.sumEnd)&&c<d.from&&u>=d.to);if(p){let d=c===p.sumEnd?bt(n,e,p,1):p.line;a<s?a=d:s=d}}return a===t.anchor&&s===t.head?null:I.create(n,a,s)}var Le=n=>{let t="";for(;n>0;)n--,t=String.fromCharCode(97+n%26)+t,n=Math.floor(n/26);return t},Pe=n=>[[1e3,"m"],[900,"cm"],[500,"d"],[400,"cd"],[100,"c"],[90,"xc"],[50,"l"],[40,"xl"],[10,"x"],[9,"ix"],[5,"v"],[4,"iv"],[1,"i"]].reduce((t,[e,o])=>{for(;n>=e;)t+=o,n-=e;return t},"");function ze(n){let t=new Map,e=[];return n.forEach((o,r)=>{if(!A(o.node)){e=[];return}r>0&&!nt(n[r-1],o)&&(e=[]);let a=o.node.attrs.indent;if(e.length=a+1,o.node.attrs.kind!=="ordered"){e[a]=0;return}e[a]=(e[a]||0)+1;let s=e[a];t.set(r,`${a%3===0?s:a%3===1?Le(s):Pe(s)}.`)}),t}var U=new pe("page-collapse"),Ve=["id","parent","indent","kind","open"];function Re(n,t){if(n.childCount!==t.childCount)return!1;for(let e=0;e<n.childCount;e++){let o=n.child(e),r=t.child(e);if(o!==r){if(o.type!==r.type)return!1;for(let a of Ve)if(o.attrs[a]!==r.attrs[a])return!1}}return!0}function Xt(n){let t=y(n);return{decos:qe(n,t),ranges:Be(t)}}function qe(n,t=y(n)){let{Decoration:e,DecorationSet:o}=B,r=ze(t),a=[];for(let s of t){let i={};s.hidden&&(i.class="page-hidden",i["aria-hidden"]="true"),s.depth&&(i.style=`--page-depth:${s.depth}`),r.has(s.i)&&(i["data-marker"]=r.get(s.i)),S(s.node)&&(i["aria-expanded"]=s.node.attrs.open?"true":"false"),Object.keys(i).length&&a.push(e.node(s.at,s.end,i)),S(s.node)&&!s.hidden&&a.push(e.widget(s.at+1,()=>_e(s.node),{side:-1,ignoreSelection:!0,key:`t:${s.node.attrs.id}:${s.node.attrs.open}`}))}return o.create(n,a)}function _e(n){let t=document.createElement("button");return t.type="button",t.className="page-toggle-button",t.contentEditable="false",t.setAttribute("aria-label",n.attrs.open?"Collapse":"Expand"),t.setAttribute("data-toggle",n.attrs.id||""),t}function Un(){let n=!1;return new xt({key:U,state:{init:(t,e)=>Xt(e.doc),apply(t,e,o,r){if(!t.docChanged)return e;if(!Re(o.doc,r.doc))return Xt(r.doc);let a=t.mapping;return{decos:e.decos.map(a,r.doc),ranges:e.ranges.map(s=>({line:a.map(s.line,-1),sumEnd:a.map(s.sumEnd),from:a.map(s.from),to:a.map(s.to,-1)}))}}},appendTransaction(t,e,o){if(!t.some(i=>i.docChanged||i.selectionSet))return null;let a=t.some(i=>i.selectionSet)&&o.selection.head>=e.selection.head?1:-1,s=Wt(o.doc,o.selection,U.getState(o).ranges,a,n);return s?o.tr.setSelection(s):null},props:{decorations:t=>U.getState(t).decos,handleDOMEvents:{mousedown:(t,e)=>{let o=e.target.closest?.(".page-toggle-button");if(o){e.preventDefault();let s=y(t.state.doc),i=s.findIndex(l=>l.node.attrs.id===o.dataset.toggle);return i>=0&&t.dispatch(ne(t.state,i,!s[i].node.attrs.open,s)),!0}n=!0;let r=t.dom.ownerDocument.defaultView,a=()=>{n=!1,r.removeEventListener("mouseup",a,!0);let s=Wt(t.state.doc,t.state.selection,U.getState(t.state).ranges,1,!1);s&&t.dispatch(t.state.tr.setSelection(s))};return r.addEventListener("mouseup",a,!0),!1}},handleKeyDown(t,e){let o={ArrowDown:1,ArrowRight:1,ArrowUp:-1,ArrowLeft:-1}[e.key];if(!o||e.altKey||e.metaKey||e.ctrlKey)return!1;let{head:r}=t.state.selection,s=e.key==="ArrowDown"||e.key==="ArrowUp"?o>0?"down":"up":o>0?"forward":"backward";if(!t.endOfTextblock(s))return!1;let i=y(t.state.doc),{ranges:l}=U.getState(t.state),u=t.state.doc.resolve(r).index(0),p=null;if(o>0){let f=l.find(m=>m.from===i[u].end);f&&(p=bt(t.state.doc,l,f,1))}else{let f=wt(i,u);f>=0&&(p=e.shiftKey?i[f].at+1:i[f].end-1)}if(p===null||p===r)return!1;let d=e.shiftKey?t.state.selection.anchor:p;return t.dispatch(t.state.tr.setSelection(I.create(t.state.doc,d,p)).scrollIntoView()),!0}}})}var Qt=/^([ \t]*)(?:([-*+•])|(\d+)[.)])[ \t]+(?:\[([ xX])\][ \t]+)?(.*)$/;function Ke(n){let t=n.replace(/\r\n?/g,`
2
- `).split(`
3
- `);if(!t.some(r=>Qt.test(r)))return null;let e=[],o=[];for(let r of t){if(!r.trim())continue;let a=Qt.exec(r);if(!a){e.length=0,o.push(E.paragraph.create(null,r.trim()?T.text(r.trim()):null));continue}let s=a[1].replace(/\t/g," ").length;for(;e.length&&e[e.length-1]>s;)e.pop();(!e.length||e[e.length-1]<s)&&e.push(s);let i=Math.min(e.length-1,o.length&&A(o[o.length-1])?o[o.length-1].attrs.indent+1:0),l=a[4]!==void 0?"check":a[3]!==void 0?"ordered":"bullet";o.push(E.list_item.create({kind:l,indent:i,checked:a[4]==="x"||a[4]==="X"},a[5]?T.text(a[5]):null))}return new N.Slice(N.Fragment.from(o),0,0)}var dt=new Set(["UL","OL"]),ut=new Set(["P","DIV","H1","H2","H3","H4","H5","H6","PRE","BLOCKQUOTE","UL","OL","LI","DETAILS","SUMMARY","TABLE","HR","FIGURE"]);function He(n){let t=n.querySelector(":scope > input[type=checkbox], :scope > p > input[type=checkbox], :scope > label > input[type=checkbox]");if(t)return{check:!0,checked:t.checked||t.hasAttribute("checked")};if(n.getAttribute("role")==="checkbox"||n.hasAttribute("aria-checked"))return{check:!0,checked:n.getAttribute("aria-checked")==="true"};if(n.hasAttribute("data-checked"))return{check:!0,checked:n.getAttribute("data-checked")==="true"};let o=n.className||"";return/\b(checked|task-list-item|to-do)\b/.test(o)||n.closest?.("ul.to-do-list, ul.contains-task-list")?{check:!0,checked:/\bchecked\b/.test(o)||!!n.querySelector(".checkbox-on")}:{check:!1,checked:!1}}function je(n){let t=(n.getAttribute("style")||"")+";"+(n.parentElement?.getAttribute("style")||""),e=/list-style-type\s*:\s*([a-z-]+)/i.exec(n.getAttribute("style")||"")?.[1];return e?/decimal|alpha|roman|latin|greek/.test(e)?"ordered":"bullet":n.parentElement?.tagName==="OL"?"ordered":"bullet"}function Ue(n,t=globalThis.document){let e=t.createElement("div");e.innerHTML=n;for(let d of e.querySelectorAll('b[style*="font-weight:normal"], b[style*="font-weight: normal"]'))d.replaceWith(...d.childNodes);let o=0,r=t.createElement("div"),a=d=>{let f=parseInt(d.getAttribute("aria-level"),10);if(f>0)return f-1;let m=-1;for(let h=d.parentElement;h&&h!==e;h=h.parentElement)dt.has(h.tagName)&&m++;return Math.max(0,m)},s=[];function i(d,f,m){let h=t.createElement("div"),{check:x,checked:g}=He(d);h.setAttribute("data-page-li",""),h.setAttribute("data-kind",x?"check":je(d)),h.setAttribute("data-checked",g?"true":"false"),h.dataset.depth=String(a(d)),f&&h.setAttribute("data-page-parent",f);let v=!0,D=[];for(let w of[...d.childNodes]){if(w.nodeType===1&&dt.has(w.tagName)){D.push(w);continue}if(!(w.nodeType===1&&w.tagName==="INPUT")){if(w.nodeType===1&&ut.has(w.tagName)){v||h.appendChild(t.createElement("br"));for(let P of[...w.childNodes])P.nodeType===1&&P.tagName==="INPUT"||h.appendChild(P);v=!1;continue}h.appendChild(w),(w.nodeType!==3||w.textContent.trim())&&(v=!1)}}m.appendChild(h),s.push(h);for(let w of D)l(w,f,m)}function l(d,f,m){let h=null,x=g=>{h||(h=t.createElement("p"),f&&h.setAttribute("data-page-parent",f),m.appendChild(h)),h.appendChild(g)};for(let g of[...d.childNodes])if(!(g.nodeType===1&&(g.tagName==="META"||g.tagName==="STYLE"))){if(g.nodeType===1&&g.tagName==="BR"){h=null;continue}if(g.nodeType!==1){g.nodeType===3&&(h||g.textContent.trim())&&x(g);continue}if(!ut.has(g.tagName)&&g.tagName!=="ASIDE"){x(g);continue}if(h=null,dt.has(g.tagName)){l(g,f,m);continue}if(g.tagName==="LI"){i(g,f,m);continue}if(g.tagName==="DETAILS"){let v=`paste-${++o}`,D=g.querySelector(":scope > summary"),w=t.createElement("div");w.setAttribute("data-page-toggle",v),g.hasAttribute("open")&&w.setAttribute("data-open","true"),f&&w.setAttribute("data-page-parent",f),D&&w.append(...D.childNodes),m.appendChild(w);for(let P of[...g.childNodes])if(P!==D){let Ct=t.createElement("div");Ct.appendChild(P),l(Ct,v,m)}continue}if(g.tagName==="DIV"&&!g.hasAttribute("data-page-li")&&[...g.children].some(v=>ut.has(v.tagName))){l(g,f,m);continue}f&&g.setAttribute("data-page-parent",f),m.appendChild(g)}}l(e,null,r);let c=s.length?Math.min(...s.map(d=>+d.dataset.depth)):0,u=null;for(let d of s){let f=+d.dataset.depth-c,m=u&&d.previousElementSibling===u?+u.getAttribute("data-indent")+1:0;d.setAttribute("data-indent",String(Math.min(f,m))),d.removeAttribute("data-depth"),u=d}let p=d=>{if(d.nodeType!==1||d.tagName==="IMG")return[d.cloneNode(!0)];let f=[],m=d.cloneNode(!1);for(let h of d.childNodes)for(let x of p(h))x.nodeType===1&&x.tagName==="IMG"?(m.hasChildNodes()&&f.push(m),f.push(x),m=d.cloneNode(!1)):m.appendChild(x);return(m.hasChildNodes()||!f.length)&&f.push(m),f};for(let d of[...r.children]){if(!d.matches("p, h1, h2, h3, h4, h5, h6, aside, div[data-page-li], div.page-li")||!d.querySelector("img"))continue;let f=p(d),m=d.getAttribute("data-page-parent");if(m)for(let h of f)h.setAttribute("data-page-parent",m);d.replaceWith(...f)}return r.innerHTML}var ft=(n,t=0)=>n!==null&&n!==""&&Number.isInteger(+n)&&+n>=t?+n:null,M=n=>n.getAttribute("data-page-parent")||null,Fe=$t([]).type,Ge=Object.create(T,{marks:{value:{...T.marks,[tt]:Fe}}}),oe=n=>{let t;try{t=jt(n)}catch{return null}return!t||typeof t.t!="string"||t.t==="opaque_block"||Object.hasOwn(qt,t.t)?null:t},We=n=>{let t=oe(n);return t?{raw:t,parent:M(n)}:!1},Xe=n=>{let t=oe(n);if(!t||typeof t.c!="string"||!t.c)return N.Fragment.empty;let e=zt(t.m,t.c.length);return N.Fragment.from(Vt(T,t.c,e,T.nodes.opaque_block))},Qe=n=>{try{return{entries:_t(n.getAttribute(lt))}}catch{return!1}},Ye=new N.DOMParser(Ge,[{tag:`div[${Rt}]`,node:"opaque_block",getAttrs:We,getContent:Xe},{tag:`span[${lt}]`,mark:tt,getAttrs:Qe},{tag:"div[data-page-li]",node:"list_item",getAttrs:n=>({kind:n.getAttribute("data-kind")||"bullet",indent:+n.getAttribute("data-indent")||0,checked:n.getAttribute("data-checked")==="true",parent:M(n)})},{tag:"div.page-li",node:"list_item",getAttrs:n=>({kind:n.getAttribute("data-kind")||"bullet",indent:+n.getAttribute("data-indent")||0,checked:n.getAttribute("data-checked")==="true",parent:M(n)})},{tag:"div[data-page-toggle]",node:"toggle",getAttrs:n=>({id:n.getAttribute("data-page-toggle"),open:n.getAttribute("data-open")==="true",parent:M(n)})},{tag:"div.page-toggle",node:"toggle",getAttrs:n=>({id:n.getAttribute("data-id"),open:n.getAttribute("data-open")==="true",parent:null})},{tag:"h1",node:"heading",getAttrs:n=>({level:1,parent:M(n)})},{tag:"h2",node:"heading",getAttrs:n=>({level:2,parent:M(n)})},{tag:"h3",node:"heading",getAttrs:n=>({level:3,parent:M(n)})},{tag:"h4",node:"heading",getAttrs:n=>({level:3,parent:M(n)})},{tag:"pre",node:"code_block",preserveWhitespace:"full",getAttrs:n=>({lang:n.getAttribute("data-lang")||"",parent:M(n)})},{tag:"hr",node:"divider",getAttrs:n=>({parent:M(n)})},{tag:"aside.page-callout",node:"callout",getAttrs:n=>({parent:M(n)})},{tag:'figure:not([data-type]), figure[data-type="image"]',node:"image",getAttrs:n=>{let t=n.querySelector("img"),e=Z(t?.getAttribute("src"));return e?{src:e,alt:t.getAttribute("alt")||"",caption:n.querySelector("figcaption")?.textContent||"",width:ft(n.getAttribute("data-width")??t.getAttribute("width"),1),align:fe(n.getAttribute("data-align")),parent:M(n)}:!1}},{tag:"img[src]",node:"image",getAttrs:n=>{let t=Z(n.getAttribute("src"));return t?{src:t,alt:n.getAttribute("alt")||"",width:ft(n.getAttribute("width"),1),parent:M(n)}:!1}},{tag:'div.page-file, div[data-type="file"]',node:"file",getAttrs:n=>{let t=C(n.getAttribute("data-src"));return t?{src:t,name:n.getAttribute("data-name")||"file",size:ft(n.getAttribute("data-size")),mime:n.getAttribute("data-mime")||null,parent:M(n)}:!1}},{tag:"p",node:"paragraph",getAttrs:n=>({parent:M(n)})},{tag:"br",node:"hard_break"},{tag:"strong",mark:"strong"},{tag:"b",mark:"strong",getAttrs:n=>/font-weight\s*:\s*(normal|[1-5]00)\b/.test(n.getAttribute("style")||"")?!1:null},{tag:"span",mark:"strong",getAttrs:n=>/font-weight\s*:\s*(bold|[6-9]00)\b/.test(n.getAttribute("style")||"")?null:!1},{tag:"em",mark:"em"},{tag:"i",mark:"em"},{tag:"span",mark:"em",getAttrs:n=>/font-style\s*:\s*italic/.test(n.getAttribute("style")||"")?null:!1},{tag:"s",mark:"strike"},{tag:"del",mark:"strike"},{tag:"code",mark:"code"},{tag:"a[href]",mark:"link",getAttrs:n=>{let t=C(n.getAttribute("href"));return t?{href:t}:!1}},{tag:"blockquote",node:"quote",getAttrs:n=>({parent:M(n)})},{tag:"u",mark:"underline"},{tag:"mark",mark:"highlight",getAttrs:n=>at("highlight",{color:n.getAttribute("data-color")})??!1},{tag:"span[data-color]",mark:"text_color",getAttrs:n=>at("text_color",{color:n.getAttribute("data-color")})??!1}]);function Je(n,t){let e=t.selection.$from,o=t.selection instanceof k,r=o?t.doc.child(t.selection.span().lo):e.depth>=1?e.node(1):null,a=r?b(r):null,s=r&&A(r)?r.attrs.indent:0,i=new Map;n.content.forEach(h=>{S(h)&&h.attrs.id&&i.set(h.attrs.id,z())});let l=[];n.content.forEach(h=>{if(!h.type.spec.group?.includes("block")){l.push(h);return}let x=b(h),g={...h.attrs,pos:null,id:S(h)?i.get(h.attrs.id)??null:null,parent:x!==null&&i.has(x)?i.get(x):a};A(h)&&(g.indent=h.attrs.indent+s),l.push(h.type.create(g,h.content,h.marks))});let c=!r||!(A(r)||S(r)),u=h=>h&&(A(h)||S(h)),p=c&&u(l[0])?0:n.openStart,d=l[l.length-1],f=new Set(i.values()),m=c&&(u(d)||d&&f.has(b(d)))?0:n.openEnd;return new N.Slice(N.Fragment.from(l),o?0:p,o?0:m)}var kt=class extends N.DOMSerializer{serializeFragment(t,e,o){let r=super.serializeFragment(t,e,o);if(!t.firstChild?.isBlock)return r;let a=[...r.childNodes];return t.forEach((s,i,l)=>{let c=a[l];!c||c.nodeType!==1||(b(s)!==null&&c.setAttribute("data-page-parent",b(s)),S(s)&&s.attrs.id&&c.setAttribute("data-page-toggle",s.attrs.id),s.type===E.image&&s.attrs.width&&c.setAttribute("data-width",String(s.attrs.width)))}),r}},re=N.DOMSerializer.fromSchema(T),Ze=n=>{let{t,...e}=n.attrs.raw??{},{c:o,m:r}=Lt(n.content);return o?{t,...e,c:o,...r.some(Boolean)?{m:Pt(r)}:{}}:{t,...e}},tn=n=>["div",{"data-type":"newer-format",...Kt(Ze(n))},0],en=n=>["span",Ht(n.attrs.entries),0],nn={...re.nodes,opaque_block:tn},on={...re.marks,[tt]:en},rn=new kt(nn,on);function sn(n,t,e){let{$from:o}=n.state.selection,r=o.depth>=1?o.node(1):null;if(!r||!S(r)||r.attrs.open||e.content.childCount<2)return!1;let a=n.state.tr.setNodeMarkup(o.before(1),null,{...r.attrs,open:!0}).replaceSelection(e);return n.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function an(n){let t=!1;return n?.content?.descendants(e=>t?!1:((e.type===E.quote||e.isText&&e.marks.some(o=>Bt.has(o.type.name)))&&(t=!0),!t)),t}function cn(n,t,e){let o=n.state.selection.from,r=n.state.selection.to,a=()=>{let s=e.content.textBetween(0,e.content.size,`
4
- `," ");return!n.isDestroyed&&s&&n.dispatch(n.state.tr.insertText(s,o,r)),!1};return import("./c-DFS4XZJV.js").then(({pasteFormats:s})=>s(n,e,o,r),a),!0}function Fn(){return new xt({props:{handlePaste(n,t,e){return an(e)?cn(n,t,e):sn(n,t,e)},clipboardSerializer:rn,transformPastedHTML:n=>Ue(n),clipboardParser:Ye,clipboardTextParser:(n,t,e)=>e?null:Ke(n),transformPasted:(n,t)=>Je(n,t.state)}})}var F=J.chainCommands(Me,Te,Oe,De,ve),V=J.chainCommands(Ie,Ne,Ce),Gn={Enter:J.chainCommands(Ae,Se,we,Ee),Backspace:F,"Shift-Backspace":F,"Mod-Backspace":F,"Alt-Backspace":F,"Ctrl-h":F,Delete:V,"Shift-Delete":V,"Mod-Delete":V,"Alt-Delete":V,"Ctrl-d":V,"Ctrl-Alt-Backspace":V,Tab:ye,"Shift-Tab":St,"Mod-Shift-ArrowUp":Gt(-1),"Mod-Shift-ArrowDown":Gt(1),"Mod-Enter":$e};function Qn(){return new O.Plugin({view(n){let t=n.dom.ownerDocument.createElement("div");return t.className="page-live",t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),n.dom.parentElement.appendChild(t),{destroy:()=>t.remove()}}})}function Mt(n,t){let e=n.dom.parentElement?.querySelector(".page-live");e&&(e.textContent="",e.textContent=t)}var se=new O.PluginKey("tableRect");var{Selection:ln,TextSelection:_,NodeSelection:dn,Plugin:un,PluginKey:fn}=O,W=T.nodes,K=n=>Y.closeHistory(n).setMeta(yt,!0);function X(n,t,e=t,o=y(n)){let{lo:r,hi:a}=L(o,Math.min(t,e),Math.max(t,e)),s=o[r].at,i=o[a].end;return t<=e?new k(n.resolve(s),n.resolve(i)):new k(n.resolve(i),n.resolve(s))}function pn(n,t=y(n.doc)){let[e,o]=Yt(n.doc,n.selection,t);return L(t,e,o)}var q=(n,t,e)=>{for(let o=t;o>=0&&o<n.length;o+=e)if(!n[o].hidden)return o;return-1};function hn(n,t){if(n.selection instanceof k)return!1;let e=Math.min(n.selection.$head.index(0),n.doc.childCount-1);return t&&t(n.tr.setSelection(X(n.doc,e))),!0}var ae=n=>(t,e)=>{let o=t.selection;if(!(o instanceof k))return!1;let r=y(t.doc),{lo:a,hi:s}=o.span(t.doc),i=n<0?q(r,a-1,-1):q(r,s+1,1);return i<0||e&&e(t.tr.setSelection(X(t.doc,i)).scrollIntoView()),!0};function vt(n,t,e,o){if(o<0)return t;let r=t;for(;n[r].subEnd<e;)r=n[r].subEnd+1;return r}function mn(n,t){for(let e=t-1;e>=0;e--)if(n[e].up===n[t].up)return e;return t}var ie=n=>(t,e)=>{let o=t.selection;if(!(o instanceof k))return!1;let r=y(t.doc),{lo:a,hi:s}=o.span(t.doc),i=o.anchor<=o.head,l=i?a:vt(r,a,s,1),c=i?vt(r,a,s,1):a;return n>0?i||a===s||c===l?c=q(r,(i?s:c)+1,1):c=q(r,r[c].subEnd+1,1):!i||c===l?c=q(r,(i?c:a)-1,-1):c=mn(r,c),c<0||e&&e(t.tr.setSelection(X(t.doc,l,c,r)).scrollIntoView()),!0};function st(n,t){let e=n.selection;if(!(e instanceof k))return!1;if(t){let o=n.tr.delete(e.from,e.to);o.doc.content.size===0&&o.insert(0,W.paragraph.create()),o.setSelection(ln.near(o.doc.resolve(Math.min(e.from,o.doc.content.size)),-1)),t(K(o).scrollIntoView())}return!0}function gn({columns:n={},cards:t={}}){let e=ct(n),o=new Map(e.map(s=>[s,z("c")])),r=it(null,null,e.length),a={};for(let s of new Set([...e,...Object.values(t).map(i=>i.col)])){let i=ct(Object.fromEntries(Object.entries(t).filter(([,c])=>c.col===s))),l=it(null,null,i.length);i.forEach((c,u)=>{a[z("k")]={...t[c],col:o.get(s)??s,pos:l[u]}})}return{columns:Object.fromEntries(e.map((s,i)=>[o.get(s),{...n[s],pos:r[i]}])),cards:a}}function bn(n,t){let e=y(n.doc);if(!e.length)return!1;let{lo:o,hi:r}=pn(n,e);if(t){let a=new Map;for(let p=o;p<=r;p++)e[p].node.type===W.toggle&&e[p].node.attrs.id&&a.set(e[p].node.attrs.id,z());let s=[];for(let p=o;p<=r;p++){let d=e[p].node,f=d.attrs.parent??null;s.push(d.type.create({...d.attrs,...d.type===W.board?gn(d.attrs):{},id:a.get(d.attrs.id)??null,pos:null,parent:a.get(f)??f},d.content,d.marks))}let i=e[r].end,l=i-e[o].at,c=n.tr.insert(i,s),u=n.selection;c.setSelection(u instanceof k?new k(c.doc.resolve(i),c.doc.resolve(i+l)):_.create(c.doc,u.anchor+l,u.head+l)),t(K(c).scrollIntoView())}return!0}var le=(n,t,e,o)=>{for(let r=e;r<=o;r++)if(t[r].node.isTextblock)return t[r].end-1;return-1};function ce(n,t){let e=n.selection;if(!(e instanceof k))return!1;let o=y(n.doc),{lo:r,hi:a}=e.span(n.doc);if(t){let s=le(n.doc,o,r,a);t(n.tr.setSelection(s>=0?_.create(n.doc,s):dn.create(n.doc,o[r].at)))}return!0}var kn=({$from:n,$to:t})=>{if(n.depth<2||t.depth<2)return null;let e=n.node(1);return e.type.name==="table"&&t.node(1)===e?{from:n.before(1),to:n.after(1)}:null};function xn(n,t){let e=n.selection,{$from:o,$to:r}=e,a=o.parent.isTextblock&&o.sameParent(r)&&!se.getState(n),s=a&&o.parentOffset===0&&r.parentOffset===r.parent.content.size;if(a&&!s&&o.parent.content.size)return t&&t(n.tr.setSelection(_.create(n.doc,o.start(),o.end()))),!0;let i=kn(e);return i&&!(e instanceof k&&e.from===i.from&&e.to===i.to)?(t&&t(n.tr.setSelection(new k(n.doc.resolve(i.from),n.doc.resolve(i.to)))),!0):(t&&t(n.tr.setSelection(new k(n.doc.resolve(0),n.doc.resolve(n.doc.content.size)))),!0)}var yn=(n,t)=>{let e=n.state,o=e.selection;if(!(o instanceof k))return!1;let r=y(e.doc),{lo:a,hi:s}=o.span(e.doc),i=le(e.doc,r,a,s),l=e.tr;if(i<0){let c=r[s].end;l.insert(c,W.paragraph.create({parent:r[a].node.attrs.parent??null})),l.setSelection(_.create(l.doc,c+1)),K(l)}else l.setSelection(_.create(l.doc,i));return l.insertText(t),n.dispatch(l.scrollIntoView()),!0},An=(n,t,e)=>{let o=n.selection;if(!(o instanceof _)||!e?.endOfTextblock("down"))return!1;let{$anchor:r,$head:a}=o;if(r.depth!==1||r.parent.type!==W.toggle||r.parent.attrs.open||r.index(0)!==a.index(0))return!1;let s=y(n.doc),i=r.index(0),l=q(s,s[i].subEnd+1,1);return l<0?!1:(t&&t(n.tr.setSelection(X(n.doc,i,l,s)).scrollIntoView()),!0)},Sn=n=>(t,e,o)=>t.selection instanceof k&&n(t,e,o),wn={Escape:(n,t)=>ce(n,t)||hn(n,t),Enter:Sn(ce),ArrowUp:ae(-1),ArrowDown:ae(1),"Shift-ArrowUp":ie(-1),"Shift-ArrowDown":(n,t,e)=>ie(1)(n,t)||An(n,t,e),Backspace:st,"Alt-Backspace":st,"Ctrl-h":st,Delete:st,"Mod-d":bn,"Mod-a":xn},Tt=new fn("page-blocksel"),En=n=>{let t=n.selection,{lo:e,hi:o}=t.span(n.doc);return y(n.doc).filter(r=>r.i>=e&&r.i<=o&&!r.hidden).length};function ao(){let n=Dt.keymap(wn);return new un({key:Tt,state:{init:()=>0,apply:(t,e,o,r)=>t.getMeta(et)&&o.selection instanceof k&&!(r.selection instanceof k)?e+1:e},props:{handleKeyDown:(t,e)=>n.props.handleKeyDown(t,e),handleTextInput:(t,e,o,r)=>yn(t,r),decorations(t){let e=t.selection;if(!(e instanceof k))return null;let o=[];return t.doc.nodesBetween(e.from,e.to,(r,a)=>(o.push(B.Decoration.node(a,a+r.nodeSize,{class:"page-block-selected"})),!1)),B.DecorationSet.create(t.doc,o)},createSelectionBetween(t,e,o){let r=t.state.selection;return r instanceof k&&e.pos===r.anchor&&o.pos===r.head?r:null},handleDOMEvents:{mousedown(t,e){let o=t.state.selection;if(!e.shiftKey||!(o instanceof k)||e.button!==0)return!1;let r=t.posAtCoords({left:e.clientX,top:e.clientY});if(!r)return!1;let a=y(t.state.doc),s=Math.min(t.state.doc.resolve(r.inside>=0?r.inside:r.pos).index(0),a.length-1),{lo:i,hi:l}=o.span(t.state.doc),c=o.anchor<=o.head?i:vt(a,i,l,1);return e.preventDefault(),t.dispatch(t.state.tr.setSelection(X(t.state.doc,c,s,a))),!0}}},view:()=>({update(t,e){let o=t.state.selection,r=e.selection;if(o instanceof k&&!o.eq(r)){let a=En(t.state);Mt(t,`${a} ${a===1?"block":"blocks"} selected`)}else r instanceof k&&!(o instanceof k)&&Mt(t,Tt.getState(t.state)!==Tt.getState(e)?"Block selection cleared because the document changed":"Selection cleared")}})})}var{Plugin:Mn,PluginKey:Tn,TextSelection:Q}=O,{Decoration:vn,DecorationSet:In}=B,j=T.marks.link,Nn=n=>/^(https?:\/\/|mailto:|tel:|www\.)\S+$/i.test(n.trim())&&C(n)!==null;function It(n,t){let e=n.resolve(t);if(!e.parent.inlineContent)return null;let o=j.isInSet((e.nodeAfter??e.nodeBefore)?.marks??[]);if(!o)return null;let r=[];e.parent.forEach((c,u)=>r.push({n:c,off:u}));let a=r.findIndex(({n:c,off:u})=>u<=e.parentOffset&&e.parentOffset<=u+c.nodeSize&&o.isInSet(c.marks));if(a<0)return null;let s=a,i=a;for(;s>0&&o.isInSet(r[s-1].n.marks);)s--;for(;i<r.length-1&&o.isInSet(r[i+1].n.marks);)i++;let l=e.start();return{from:l+r[s].off,to:l+r[i].off+r[i].n.nodeSize,href:o.attrs.href}}function de(n,t,e,o){let r=n.tr.removeMark(t,e,j);return o&&r.addMark(t,e,j.create({href:o})),K(r)}var $=new Tn("page-link"),Nt=new WeakMap,ue=n=>`<svg viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${n}</svg>`,On=ue('<path d="M9 3h4v4M13 3 7.5 8.5M11 9.5V13H3V5h3.5"/>'),Cn=ue('<path d="M4 4l8 8M12 4l-8 8"/>');function H(n,t,e,o={}){let r=n.createElement(t);e&&(r.className=e);for(let[a,s]of Object.entries(o))r.setAttribute(a,s);return r}function Dn(n,t,e){let o=null;return n.doc.nodesBetween(t,e,r=>{let a=j.isInSet(r.marks);a&&(o=a.attrs.href)}),o}var Ot=class{constructor(t){this.view=t,this.shell=t.dom.parentElement,this.doc=t.dom.ownerDocument,this.mode=null,this.range=null;let e=this.doc;this.dom=H(e,"div","page-link",{role:"dialog","aria-label":"Link",hidden:""}),this.input=H(e,"input","page-link-input",{type:"url","aria-label":"Link address",placeholder:"Paste or type a link",autocomplete:"off",spellcheck:"false"}),this.url=H(e,"a","page-link-url",{target:"_blank",rel:"noopener noreferrer"}),this.open=H(e,"a","page-link-btn",{"data-act":"open",target:"_blank",rel:"noopener noreferrer","aria-label":"Open link in a new tab",title:"Open in a new tab"}),this.open.innerHTML=On,this.edit=H(e,"button","page-link-btn",{type:"button","data-act":"edit"}),this.edit.textContent="Edit",this.remove=H(e,"button","page-link-btn",{type:"button","data-act":"remove","aria-label":"Remove link",title:"Remove link"}),this.remove.innerHTML=Cn,this.dom.append(this.input,this.url,this.open,this.edit,this.remove),this.shell.append(this.dom),Nt.set(t,this),this.dom.addEventListener("mousedown",o=>{o.target!==this.input&&o.preventDefault()}),this.edit.addEventListener("click",()=>this.openEdit()),this.remove.addEventListener("click",()=>this.apply("")),this.input.addEventListener("keydown",o=>{o.isComposing||o.keyCode===229||(o.key==="Enter"?(o.preventDefault(),this.apply(this.input.value)):o.key==="Escape"&&(o.preventDefault(),this.close()))}),this.onDocDown=o=>{this.mode==="edit"&&!this.dom.contains(o.target)&&this.close(!1)},this.doc.addEventListener("mousedown",this.onDocDown,!0)}openEdit(){let t=this.view.state,e=t.selection;if(!(e instanceof Q)||!e.$from.sameParent(e.$to)||!e.$from.parent.inlineContent||e.$from.parent.type.spec.code)return!1;let o=e.empty?It(t.doc,e.head):null;return this.range=o??{from:e.from,to:e.to,href:e.empty?null:Dn(t,e.from,e.to)},this.mode="edit",this.view.dispatch(t.tr.setMeta($,{from:this.range.from,to:this.range.to})),this.render(),this.input.value=this.range.href??"",this.input.removeAttribute("aria-invalid"),this.input.focus(),this.input.select(),!0}apply(t){let e=String(t).trim(),o=e?C(e):null;if(e&&!o){this.input.setAttribute("aria-invalid","true");return}let r=this.view.state,a=$.getState(r)??(this.mode==="view"?this.range:null);if(!a)return this.close();let s;if(a.from===a.to){if(!o)return this.close();s=r.tr.insert(a.from,T.text(e,[j.create({href:o})])),s.setSelection(Q.create(s.doc,a.from+e.length))}else s=de(r,a.from,a.to,o),s.setSelection(Q.create(s.doc,a.to));this.view.dispatch(K(s).setMeta($,null)),this.close()}close(t=!0){this.mode=null,this.range=null,$.getState(this.view.state)&&this.view.dispatch(this.view.state.tr.setMeta($,null)),this.dom.hidden=!0,this.dom.dataset.mode="",t&&this.view.focus(),this.update(this.view)}render(){let t=this.mode==="edit",e=C(this.range?.href);this.dom.dataset.mode=this.mode??"",this.input.hidden=!t,this.url.hidden=t,this.edit.hidden=t,this.open.hidden=!e,this.remove.hidden=!this.range?.href,e?(this.open.href=e,this.url.href=e,this.url.textContent=e.replace(/^https?:\/\//,"")):(this.open.removeAttribute("href"),this.url.removeAttribute("href"),this.url.textContent=""),this.dom.hidden=!1,this.place()}place(){let t=this.range;if(!t)return;let e=this.shell.getBoundingClientRect(),o=this.view.coordsAtPos(t.from),r=this.view.coordsAtPos(t.to,-1);this.dom.style.setProperty("--page-pop-x",`${Math.min(o.left,r.left)-e.left}px`),this.dom.style.setProperty("--page-pop-y",`${Math.max(o.bottom,r.bottom)-e.top+6}px`)}update(t){if(this.view=t,this.mode==="edit"){let r=$.getState(t.state);if(r)return this.range={...this.range,...r},this.place();this.mode=null,this.range=null,this.dom.hidden=!0,this.dom.dataset.mode="";return}let e=t.state.selection,o=e instanceof Q&&e.empty&&t.hasFocus()?It(t.state.doc,e.head):null;if(!o||e.head===o.from||e.head===o.to){this.mode=null,this.range=null,this.dom.hidden=!0,this.dom.dataset.mode="";return}this.mode="view",this.range=o,this.render()}destroy(){this.doc.removeEventListener("mousedown",this.onDocDown,!0),this.dom.remove(),Nt.delete(this.view)}},$n=n=>Nt.get(n)?.openEdit()??!1;function Bn(n,t){if(t.clipboardData?.files?.length)return!1;let e=t.clipboardData?.getData("text/plain")??"";if(!Nn(e))return!1;let o=n.state.selection;if(!(o instanceof Q)||!o.$from.sameParent(o.$to)||o.$from.parent.type.spec.code)return!1;let r=C(e),a=o.empty?n.state.tr.replaceSelectionWith(T.text(e.trim(),[j.create({href:r})]),!1):de(n.state,o.from,o.to,r);return n.dispatch(a.scrollIntoView().setMeta("uiEvent","paste")),!0}function po(){return new Mn({key:$,state:{init:()=>null,apply(n,t){let e=n.getMeta($);if(e!==void 0)return e;if(!t||!n.docChanged)return t;let o=n.mapping.mapResult(t.from,1),r=n.mapping.mapResult(t.to,t.from===t.to?1:-1);return o.deletedAcross||r.deletedAcross||t.from!==t.to&&o.pos>=r.pos?null:{from:o.pos,to:r.pos}}},view:n=>new Ot(n),props:{decorations(n){let t=$.getState(n);return t&&t.from<t.to?In.create(n.doc,[vn.inline(t.from,t.to,{class:"page-link-pending"})]):null},handleKeyDown(n,t){return(t.metaKey||t.ctrlKey)&&!t.altKey&&!t.shiftKey&&t.key.toLowerCase()==="k"?(t.preventDefault(),$n(n)||!0):!1},handlePaste:Bn,handleClick(n,t,e){if(!(e.metaKey||e.ctrlKey))return!1;let o=It(n.state.doc,t),r=C(o?.href);return r?(n.dom.ownerDocument.defaultView.open(r,"_blank","noopener,noreferrer"),!0):!1}}})}export{$n as a,po as b,Qn as c,Mt as d,yt as e,R as f,y as g,Hn as h,he as i,jn as j,L as k,ge as l,be as m,k as n,G as o,Zt as p,Gt as q,xe as r,ye as s,St as t,Un as u,Ye as v,rn as w,Fn as x,Gn as y,se as z,K as A,X as B,pn as C,st as D,bn as E,yn as F,ao as G};
@@ -1,19 +0,0 @@
1
- import{b as s}from"./c-BTDI4Y23.js";import{a as p}from"./c-2YYDMLNZ.js";import"./c-VHNSBD2M.js";var h=`html:has(> body > .clay-intro) { height: auto !important; overflow-y: auto !important; }
2
- body:has(> .clay-intro) { height: auto !important; overflow: visible !important; }
3
- .clay-intro {
4
- position: relative;
5
- display: block;
6
- }
7
- .clay-intro__close {
8
- position: absolute; top: 10px; right: 10px; z-index: 1;
9
- display: inline-flex; align-items: center; justify-content: center;
10
- width: 28px; height: 28px; min-height: 0; margin: 0; padding: 0;
11
- border: 0; border-radius: 4px; background: none; box-shadow: none;
12
- color: inherit; opacity: .55; cursor: pointer; line-height: 1;
13
- }
14
- .clay-intro .clay-intro__close:hover { opacity: 1; background: none; color: inherit; }
15
- .clay-intro__close:focus-visible { opacity: 1; outline: 2px solid currentColor; outline-offset: 2px; }
16
- .clay-intro__close svg { display: block; width: 12px; height: 12px; fill: currentColor; stroke: none; }
17
- @media (pointer: coarse) { .clay-intro__close { width: 44px; height: 44px; top: 4px; right: 4px; } }
18
- @media print { .clay-intro { display: none; } }
19
- `;var m={close:"Hide this introduction",label:t=>`About ${t}`},b="a[href], button, input, select, textarea, [tabindex]:not([tabindex='-1'])",g="textarea, select",x=["checkbox","radio","button","submit","reset","file"];function v(t){return t.isContentEditable||t.closest(g)?!0:t.tagName!=="INPUT"?!1:x.indexOf(t.type)<0}function w(){try{return new URLSearchParams(window.location.search).get("intro")==="1"}catch{return!1}}function _(){if(document.getElementById("clay-intro-style"))return;let t=document.createElement("style");t.id="clay-intro-style",t.setAttribute("clay","editor-ui"),t.textContent=h,document.head.appendChild(t)}function C(){let t=[...document.querySelectorAll(b)].find(o=>!o.disabled&&!v(o)&&!o.closest("[clay~='editor-ui']")&&(typeof o.checkVisibility!="function"||o.checkVisibility()));t?t.focus({preventScroll:!0}):document.body.focus({preventScroll:!0})}function k({memory:t,template:o,appName:c,hadDraft:e}){return!o||!o.content.textContent.trim()&&!o.content.querySelector("img, svg, video, canvas")||!w()&&(t.get().intro.done||e||p.servedHash||window.matchMedia&&window.matchMedia("print").matches)?null:E({memory:t,template:o,appName:c})}function E({memory:t,template:o,appName:c}){_();let e=document.createElement("section");e.className="clay-intro",e.setAttribute("clay","editor-ui"),e.setAttribute("sap-ignore",""),e.setAttribute("aria-label",m.label(c)),e.appendChild(o.content.cloneNode(!0));let i=document.createElement("button");i.type="button",i.className="clay-intro__close",i.setAttribute("aria-label",m.close),i.innerHTML='<svg width="12" height="12" viewBox="0 0 12 12" fill="currentColor" aria-hidden="true"><path d="M1.4 0 6 4.6 10.6 0 12 1.4 7.4 6 12 10.6 10.6 12 6 7.4 1.4 12 0 10.6 4.6 6 0 1.4z"/></svg>',e.appendChild(i);let a=!1,r=0;function d(n){if(a)return;a=!0,removeEventListener("scroll",u),r&&cancelAnimationFrame(r);let l=e.getBoundingClientRect().height,f=window.scrollY;if(t.get().intro.done=n,t.save(),e.remove(),n==="scrolled"){let y=/hidden|clip/.test(getComputedStyle(document.body).overflowY+getComputedStyle(document.documentElement).overflowY);window.scrollTo(0,y?0:Math.max(0,f-l))}s(),n!=="scrolled"&&C()}function u(){r||(r=requestAnimationFrame(()=>{r=0;let n=e.getBoundingClientRect().bottom,l=scrollY>0&&scrollY+innerHeight>=document.documentElement.scrollHeight-1;(n<1||l&&n<innerHeight)&&d("scrolled")}))}return e.addEventListener("click",n=>{if(n.target.closest(".clay-intro__close, [visitor-intro-dismiss]")){d("closed");return}n.target.closest("[visitor-intro-start]")&&(n.preventDefault(),window.scrollTo({top:window.scrollY+e.getBoundingClientRect().bottom,behavior:"smooth"}))}),document.body.prepend(e),s(),addEventListener("scroll",u,{passive:!0}),e}export{m as COPY,k as mountIntro};
@@ -1 +0,0 @@
1
- var u=/^(.+)\.(\d+)\.(\d+)$/,y=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}(?:==)?|[A-Za-z0-9+/]{3}=?)?$/,a=/^[A-Za-z0-9+/=\t\n\f\r ]*$/;function g(e){let s=[],r=new Map;for(let n of Object.keys(e).sort()){let t=u.exec(n);if(!t){s.push([n,e[n]]);continue}let o=r.get(t[1])??{n:Number(t[3]),got:[]};o.got[Number(t[2])]=e[n],r.set(t[1],o)}for(let[n,t]of r){let o=0;for(let i=0;i<t.n;i++)typeof t.got[i]=="string"&&o++;o===t.n&&s.push([n,t.got.join("")])}return s}function b(e){if(e?.v!==1||!e.y||typeof e.y!="object"||Array.isArray(e.y))return e;let s=new Map;for(let[n,t]of Object.entries(e.y)){let o=u.exec(n);if(!o)continue;let i=o[1],p=Number(o[2]),f=Number(o[3]),c=s.get(i)??{count:f,indices:new Set,keys:[],invalid:!1};(!Number.isSafeInteger(p)||!Number.isSafeInteger(f)||f<1||p>=f||c.count!==f||c.indices.has(p)||typeof t!="string"||!a.test(t))&&(c.invalid=!0),c.indices.add(p),c.keys.push(n),s.set(i,c)}let r=new Set;for(let[n,t]of s)if(!t.invalid&&!Object.hasOwn(e.y,n)&&t.indices.size<t.count)for(let o of t.keys)r.add(o);return r.size?{...e,y:Object.fromEntries(Object.entries(e.y).filter(([n])=>!r.has(n)))}:e}export{u as a,y as b,g as c,b as d};
@@ -1 +0,0 @@
1
- import{a,b,c,d,e,f,g,h,i,j}from"./c-VRZN56XY.js";import"./c-OW5QIGG3.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-N7JPUPGC.js";import"./c-HA6INT6J.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";export{d as hostMeta,c as hostMetaOrder,a as hostMetaOutcome,b as hostMetaPath,f as hostPageFormat,g as hostPageStateHref,e as hostSupports,h as hostVersions,j as querySaveOutcome,i as resetHostMeta};
@@ -1,5 +0,0 @@
1
- import{D as Vr,m as Ae,o as Nr,p as Lr,q as Rr,r as jr,s as Fr,u as Pr}from"./c-WWXIDH4O.js";var Ys=Object.defineProperty,Ks=(t,e,r)=>e in t?Ys(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,nr=(t,e,r)=>Ks(t,typeof e!="symbol"?e+"":e,r),V=()=>new Map,je=t=>{let e=V();return t.forEach((r,n)=>{e.set(n,r)}),e},tt=(t,e,r)=>{let n=t.get(e);return n===void 0&&t.set(e,n=r()),n},Hs=(t,e)=>{let r=[];for(let[n,s]of t)r.push(e(s,n));return r},Gs=(t,e)=>{for(let[r,n]of t)if(e(n,r))return!0;return!1},wt=()=>new Set,Oe=t=>t[t.length-1],qs=(t,e)=>{for(let r=0;r<e.length;r++)t.push(e[r])},Z=Array.from,sr=(t,e)=>{for(let r=0;r<t.length;r++)if(!e(t[r],r,t))return!1;return!0},ir=(t,e)=>{for(let r=0;r<t.length;r++)if(e(t[r],r,t))return!0;return!1},Xs=(t,e)=>{let r=new Array(t);for(let n=0;n<t;n++)r[n]=e(n,r);return r},mt=Array.isArray,pn=class{constructor(){this._observers=V()}on(t,e){return tt(this._observers,t,wt).add(e),e}once(t,e){let r=(...n)=>{this.off(t,r),e(...n)};this.on(t,r)}off(t,e){let r=this._observers.get(t);r!==void 0&&(r.delete(e),r.size===0&&this._observers.delete(t))}emit(t,e){return Z((this._observers.get(t)||V()).values()).forEach(r=>r(...e))}destroy(){this._observers=V()}},B=Math.floor,Gt=Math.abs,wn=(t,e)=>t<e?t:e,at=(t,e)=>t>e?t:e,bc=Number.isNaN,mn=t=>t!==0?t<0:1/t<0,ee=Number.MAX_SAFE_INTEGER,$r=Number.MIN_SAFE_INTEGER,_c=1<<31,Qs=Number.isInteger||(t=>typeof t=="number"&&isFinite(t)&&B(t)===t),Sc=Number.isNaN,vc=Number.parseInt,lr=String.fromCharCode,Ec=String.fromCodePoint,Cc=lr(65535),Zs=t=>t.toLowerCase(),ti=/^\s*/g,ei=t=>t.replace(ti,""),ri=/([A-Z])/g,Jr=(t,e)=>ei(t.replace(ri,r=>`${e}${Zs(r)}`)),ni=t=>{let e=unescape(encodeURIComponent(t)),r=e.length,n=new Uint8Array(r);for(let s=0;s<r;s++)n[s]=e.codePointAt(s);return n},It=typeof TextEncoder<"u"?new TextEncoder:null,si=t=>It.encode(t),ii=It?si:ni,Ot=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});Ot&&Ot.decode(new Uint8Array).length===1&&(Ot=null);var li=(t,e)=>Xs(e,()=>t).join(""),Pt=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},St=()=>new Pt,oi=t=>{let e=t.cpos;for(let r=0;r<t.bufs.length;r++)e+=t.bufs[r].length;return e},P=t=>{let e=new Uint8Array(oi(t)),r=0;for(let n=0;n<t.bufs.length;n++){let s=t.bufs[n];e.set(s,r),r+=s.length}return e.set(new Uint8Array(t.cbuf.buffer,0,t.cpos),r),e},ci=(t,e)=>{let r=t.cbuf.length;r-t.cpos<e&&(t.bufs.push(new Uint8Array(t.cbuf.buffer,0,t.cpos)),t.cbuf=new Uint8Array(at(r,e)*2),t.cpos=0)},D=(t,e)=>{let r=t.cbuf.length;t.cpos===r&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(r*2),t.cpos=0),t.cbuf[t.cpos++]=e},Mt=D,w=(t,e)=>{for(;e>127;)D(t,128|127&e),e=B(e/128);D(t,127&e)},de=(t,e)=>{let r=mn(e);for(r&&(e=-e),D(t,(e>63?128:0)|(r?64:0)|63&e),e=B(e/64);e>0;)D(t,(e>127?128:0)|127&e),e=B(e/128)},Fe=new Uint8Array(3e4),ai=Fe.length/3,hi=(t,e)=>{if(e.length<ai){let r=It.encodeInto(e,Fe).written||0;w(t,r);for(let n=0;n<r;n++)D(t,Fe[n])}else L(t,ii(e))},ui=(t,e)=>{let r=unescape(encodeURIComponent(e)),n=r.length;w(t,n);for(let s=0;s<n;s++)D(t,r.codePointAt(s))},st=It&&It.encodeInto?hi:ui,di=(t,e)=>Vt(t,P(e)),Vt=(t,e)=>{let r=t.cbuf.length,n=t.cpos,s=wn(r-n,e.length),i=e.length-s;t.cbuf.set(e.subarray(0,s),n),t.cpos+=s,i>0&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(at(r*2,i)),t.cbuf.set(e.subarray(s)),t.cpos=i)},L=(t,e)=>{w(t,e.byteLength),Vt(t,e)},or=(t,e)=>{ci(t,e);let r=new DataView(t.cbuf.buffer,t.cpos,e);return t.cpos+=e,r},gi=(t,e)=>or(t,4).setFloat32(0,e,!1),fi=(t,e)=>or(t,8).setFloat64(0,e,!1),pi=(t,e)=>or(t,8).setBigInt64(0,e,!1),zr=new DataView(new ArrayBuffer(4)),wi=t=>(zr.setFloat32(0,t),zr.getFloat32(0)===t),Ut=(t,e)=>{switch(typeof e){case"string":D(t,119),st(t,e);break;case"number":Qs(e)&&Gt(e)<=2147483647?(D(t,125),de(t,e)):wi(e)?(D(t,124),gi(t,e)):(D(t,123),fi(t,e));break;case"bigint":D(t,122),pi(t,e);break;case"object":if(e===null)D(t,126);else if(mt(e)){D(t,117),w(t,e.length);for(let r=0;r<e.length;r++)Ut(t,e[r])}else if(e instanceof Uint8Array)D(t,116),L(t,e);else{D(t,118);let r=Object.keys(e);w(t,r.length);for(let n=0;n<r.length;n++){let s=r[n];st(t,s),Ut(t,e[s])}}break;case"boolean":D(t,e?120:121);break;default:D(t,127)}},Br=class extends Pt{constructor(t){super(),this.w=t,this.s=null,this.count=0}write(t){this.s===t?this.count++:(this.count>0&&w(this,this.count-1),this.count=1,this.w(this,t),this.s=t)}},Wr=t=>{t.count>0&&(de(t.encoder,t.count===1?t.s:-t.s),t.count>1&&w(t.encoder,t.count-2))},qt=class{constructor(){this.encoder=new Pt,this.s=0,this.count=0}write(t){this.s===t?this.count++:(Wr(this),this.count=1,this.s=t)}toUint8Array(){return Wr(this),P(this.encoder)}},Yr=t=>{if(t.count>0){let e=t.diff*2+(t.count===1?0:1);de(t.encoder,e),t.count>1&&w(t.encoder,t.count-2)}},Ie=class{constructor(){this.encoder=new Pt,this.s=0,this.count=0,this.diff=0}write(t){this.diff===t-this.s?(this.s=t,this.count++):(Yr(this),this.count=1,this.diff=t-this.s,this.s=t)}toUint8Array(){return Yr(this),P(this.encoder)}},mi=class{constructor(){this.sarr=[],this.s="",this.lensE=new qt}write(t){this.s+=t,this.s.length>19&&(this.sarr.push(this.s),this.s=""),this.lensE.write(t.length)}toUint8Array(){let t=new Pt;return this.sarr.push(this.s),this.s="",st(t,this.sarr.join("")),Vt(t,this.lensE.toUint8Array()),P(t)}},W=t=>new Error(t),$=()=>{throw W("Method unimplemented")},T=()=>{throw W("Unexpected case")},ge=W("Unexpected end of array"),kn=W("Integer out of Range"),ki=(t,e,r)=>{if(e<0||r<0||e+r>t.length)throw ge;return new Uint8Array(t.buffer,t.byteOffset+e,r)},yi=(t,e,r)=>{if(e<0||r<0||e+r>t.length)throw ge;return new DataView(t.buffer,t.byteOffset+e,r)},fe=class{constructor(t){this.arr=t,this.pos=0}},et=t=>new fe(t),yn=t=>t.pos!==t.arr.length,bi=(t,e)=>{let r=ki(t.arr,t.pos,e);return t.pos+=e,r},R=t=>bi(t,k(t)),kt=t=>t.arr[t.pos++],k=t=>{let e=0,r=1,n=t.arr.length;for(;t.pos<n;){let s=t.arr[t.pos++];if(e=e+(s&127)*r,r*=128,s<128)return e;if(e>ee)throw kn}throw ge},pe=t=>{let e=t.arr[t.pos++],r=e&63,n=64,s=(e&64)>0?-1:1;if((e&128)===0)return s*r;let i=t.arr.length;for(;t.pos<i;){if(e=t.arr[t.pos++],r=r+(e&127)*n,n*=128,e<128)return s*r;if(r>ee)throw kn}throw ge},_i=t=>{let e=k(t);if(e===0)return"";{let r=String.fromCodePoint(kt(t));if(--e<100)for(;e--;)r+=String.fromCodePoint(kt(t));else for(;e>0;){let n=e<1e4?e:1e4,s=t.arr.subarray(t.pos,t.pos+n);t.pos+=n,r+=String.fromCodePoint.apply(null,s),e-=n}return decodeURIComponent(escape(r))}},Si=t=>Ot.decode(R(t)),it=Ot?Si:_i,cr=(t,e)=>{let r=yi(t.arr,t.pos,e);return t.pos+=e,r},vi=t=>cr(t,4).getFloat32(0,!1),Ei=t=>cr(t,8).getFloat64(0,!1),Ci=t=>cr(t,8).getBigInt64(0,!1),Di=[t=>{},t=>null,pe,vi,Ei,Ci,t=>!1,t=>!0,it,t=>{let e=k(t),r={};for(let n=0;n<e;n++){let s=it(t);r[s]=Tt(t)}return r},t=>{let e=k(t),r=[];for(let n=0;n<e;n++)r.push(Tt(t));return r},R],Tt=t=>Di[127-kt(t)](t),Kr=class extends fe{constructor(t,e){super(t),this.reader=e,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),yn(this)?this.count=k(this)+1:this.count=-1),this.count--,this.s}},Xt=class extends fe{constructor(t){super(t),this.s=0,this.count=0}read(){if(this.count===0){this.s=pe(this);let t=mn(this.s);this.count=1,t&&(this.s=-this.s,this.count=k(this)+2)}return this.count--,this.s}},Me=class extends fe{constructor(t){super(t),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let t=pe(this),e=t&1;this.diff=B(t/2),this.count=1,e&&(this.count=k(this)+2)}return this.s+=this.diff,this.count--,this.s}},xi=class{constructor(t){this.decoder=new Xt(t),this.str=it(this.decoder),this.spos=0}read(){let t=this.spos+this.decoder.read(),e=this.str.slice(this.spos,t);return this.spos=t,e}},Dc=crypto.subtle,Ai=crypto.getRandomValues.bind(crypto),bn=()=>Ai(new Uint32Array(1))[0],Oi="10000000-1000-4000-8000"+-1e11,Ii=()=>Oi.replace(/[018]/g,t=>(t^bn()&15>>t/4).toString(16)),_n=Date.now,Hr=t=>new Promise(t),xc=Promise.all.bind(Promise),Gr=t=>t===void 0?null:t,Mi=class{constructor(){this.map=new Map}setItem(t,e){this.map.set(t,e)}getItem(t){return this.map.get(t)}},Sn=new Mi,Ui=!0;try{typeof localStorage<"u"&&localStorage&&(Sn=localStorage,Ui=!1)}catch{}var Ti=Sn,Nt=Symbol("Equality"),vn=(t,e)=>t===e||!!t?.[Nt]?.(e)||!1,Ni=t=>typeof t=="object",Li=Object.assign,Ri=Object.keys,ji=(t,e)=>{for(let r in t)e(t[r],r)},re=t=>Ri(t).length,Fi=t=>{for(let e in t)return!1;return!0},$t=(t,e)=>{for(let r in t)if(!e(t[r],r))return!1;return!0},ar=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),Pi=(t,e)=>t===e||re(t)===re(e)&&$t(t,(r,n)=>(r!==void 0||ar(e,n))&&vn(e[n],r)),Vi=Object.freeze,En=t=>{for(let e in t){let r=t[e];(typeof r=="object"||typeof r=="function")&&En(t[e])}return Vi(t)},hr=(t,e,r=0)=>{try{for(;r<t.length;r++)t[r](...e)}finally{r<t.length&&hr(t,e,r+1)}},$i=t=>t,Qt=(t,e)=>{if(t===e)return!0;if(t==null||e==null||t.constructor!==e.constructor&&(t.constructor||Object)!==(e.constructor||Object))return!1;if(t[Nt]!=null)return t[Nt](e);switch(t.constructor){case ArrayBuffer:t=new Uint8Array(t),e=new Uint8Array(e);case Uint8Array:{if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.length;r++)if(t[r]!==e[r])return!1;break}case Set:{if(t.size!==e.size)return!1;for(let r of t)if(!e.has(r))return!1;break}case Map:{if(t.size!==e.size)return!1;for(let r of t.keys())if(!e.has(r)||!Qt(t.get(r),e.get(r)))return!1;break}case void 0:case Object:if(re(t)!==re(e))return!1;for(let r in t)if(!ar(t,r)||!Qt(t[r],e[r]))return!1;break;case Array:if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(!Qt(t[r],e[r]))return!1;break;default:return!1}return!0},Ji=(t,e)=>e.includes(t),yt=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]",Cn=typeof window<"u"&&typeof document<"u"&&!yt,Ac=typeof navigator<"u"?/Mac/.test(navigator.platform):!1,z,zi=[],Bi=()=>{if(z===void 0)if(yt){z=V();let t=process.argv,e=null;for(let r=0;r<t.length;r++){let n=t[r];n[0]==="-"?(e!==null&&z.set(e,""),e=n):e!==null?(z.set(e,n),e=null):zi.push(n)}e!==null&&z.set(e,"")}else typeof location=="object"?(z=V(),(location.search||"?").slice(1).split("&").forEach(t=>{if(t.length!==0){let[e,r]=t.split("=");z.set(`--${Jr(e,"-")}`,r),z.set(`-${Jr(e,"-")}`,r)}})):z=V();return z},Pe=t=>Bi().has(t),ne=t=>Gr(yt?process.env[t.toUpperCase().replaceAll("-","_")]:Ti.getItem(t)),Dn=t=>Pe("--"+t)||ne(t)!==null,Wi=Dn("production"),Yi=yt&&Ji(process.env.FORCE_COLOR,["true","1","2"]),Ki=Yi||!Pe("--no-colors")&&!Dn("no-color")&&(!yt||process.stdout.isTTY)&&(!yt||Pe("--color")||ne("COLORTERM")!==null||(ne("TERM")||"").includes("color")),xn=t=>new Uint8Array(t),Hi=t=>{let e="";for(let r=0;r<t.byteLength;r++)e+=lr(t[r]);return btoa(e)},Gi=t=>Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("base64"),qi=t=>{let e=atob(t),r=xn(e.length);for(let n=0;n<e.length;n++)r[n]=e.charCodeAt(n);return r},Xi=t=>new Uint8Array(Buffer.from(t,"base64")),Oc=Cn?Hi:Gi,Ic=Cn?qi:Xi,Qi=t=>{let e=xn(t.byteLength);return e.set(t),e},Zi=class{constructor(t,e){this.left=t,this.right=e}},G=(t,e)=>new Zi(t,e),qr=t=>t.next()>=.5,Ue=(t,e,r)=>B(t.next()*(r+1-e)+e),An=(t,e,r)=>B(t.next()*(r+1-e)+e),ur=(t,e,r)=>An(t,e,r),tl=t=>lr(ur(t,97,122)),el=(t,e=0,r=20)=>{let n=ur(t,e,r),s="";for(let i=0;i<n;i++)s+=tl(t);return s},Te=(t,e)=>e[ur(t,0,e.length-1)],rl=Symbol("0schema"),nl=class{constructor(){this._rerrs=[]}extend(t,e,r,n=null){this._rerrs.push({path:t,expected:e,has:r,message:n})}toString(){let t=[];for(let e=this._rerrs.length-1;e>0;e--){let r=this._rerrs[e];t.push(li(" ",(this._rerrs.length-e)*2)+`${r.path!=null?`[${r.path}] `:""}${r.has} doesn't match ${r.expected}. ${r.message}`)}return t.join(`
2
- `)}},Ve=(t,e)=>t===e?!0:t==null||e==null||t.constructor!==e.constructor?!1:t[Nt]?vn(t,e):mt(t)?sr(t,r=>ir(e,n=>Ve(r,n))):Ni(t)?$t(t,(r,n)=>Ve(r,e[n])):!1,M=class{extends(t){let[e,r]=[this.shape,t.shape];return this.constructor._dilutes&&([r,e]=[e,r]),Ve(e,r)}equals(t){return this.constructor===t.constructor&&Qt(this.shape,t.shape)}[rl](){return!0}[Nt](t){return this.equals(t)}validate(t){return this.check(t)}check(t,e){$()}get nullable(){return vt(this,be)}get optional(){return new Mn(this)}cast(t){return Xr(t,this),t}expect(t){return Xr(t,this),t}};nr(M,"_dilutes",!1);var dr=class extends M{constructor(t,e){super(),this.shape=t,this._c=e}check(t,e=void 0){let r=t?.constructor===this.shape&&(this._c==null||this._c(t));return!r&&e?.extend(null,this.shape.name,t?.constructor.name,t?.constructor!==this.shape?"Constructor match failed":"Check failed"),r}},C=(t,e=null)=>new dr(t,e),Mc=C(dr),gr=class extends M{constructor(t){super(),this.shape=t}check(t,e){let r=this.shape(t);return!r&&e?.extend(null,"custom prop",t?.constructor.name,"failed to check custom prop"),r}},A=t=>new gr(t),Uc=C(gr),we=class extends M{constructor(t){super(),this.shape=t}check(t,e){let r=this.shape.some(n=>n===t);return!r&&e?.extend(null,this.shape.join(" | "),t.toString()),r}},me=(...t)=>new we(t),On=C(we),sl=RegExp.escape||(t=>t.replace(/[().|&,$^[\]]/g,e=>"\\"+e)),In=t=>{if(bt.check(t))return[sl(t)];if(On.check(t))return t.shape.map(e=>e+"");if(Bn.check(t))return["[+-]?\\d+.?\\d*"];if(Wn.check(t))return[".*"];if(se.check(t))return t.shape.map(In).flat(1);T()},il=class extends M{constructor(t){super(),this.shape=t,this._r=new RegExp("^"+t.map(In).map(e=>`(${e.join("|")})`).join("")+"$")}check(t,e){let r=this._r.exec(t)!=null;return!r&&e?.extend(null,this._r.toString(),t.toString(),"String doesn't match string template."),r}},Tc=C(il),ll=Symbol("optional"),Mn=class extends M{constructor(t){super(),this.shape=t}check(t,e){let r=t===void 0||this.shape.check(t);return!r&&e?.extend(null,"undefined (optional)","()"),r}get[ll](){return!0}},ol=C(Mn),Un=class extends M{check(t,e){return e?.extend(null,"never",typeof t),!1}},Nc=new Un,Lc=C(Un),Tn=class Nn extends M{constructor(e,r=!1){super(),this.shape=e,this._isPartial=r}get partial(){return new Nn(this.shape,!0)}check(e,r){return e==null?(r?.extend(null,"object","null"),!1):$t(this.shape,(n,s)=>{let i=this._isPartial&&!ar(e,s)||n.check(e[s],r);return!i&&r?.extend(s.toString(),n.toString(),typeof e[s],"Object property does not match"),i})}};nr(Tn,"_dilutes",!0);var Ln=Tn,cl=t=>new Ln(t),al=C(Ln),hl=A(t=>t!=null&&(t.constructor===Object||t.constructor==null)),Rn=class extends M{constructor(t,e){super(),this.shape={keys:t,values:e}}check(t,e){return t!=null&&$t(t,(r,n)=>{let s=this.shape.keys.check(n,e);return!s&&e?.extend(n+"","Record",typeof t,s?"Key doesn't match schema":"Value doesn't match value"),s&&this.shape.values.check(r,e)})}},jn=(t,e)=>new Rn(t,e),ul=C(Rn),Fn=class extends M{constructor(t){super(),this.shape=t}check(t,e){return t!=null&&$t(this.shape,(r,n)=>{let s=r.check(t[n],e);return!s&&e?.extend(n.toString(),"Tuple",typeof r),s})}},dl=(...t)=>new Fn(t),Rc=C(Fn),Pn=class extends M{constructor(t){super(),this.shape=t.length===1?t[0]:new ke(t)}check(t,e){let r=mt(t)&&sr(t,n=>this.shape.check(n));return!r&&e?.extend(null,"Array",""),r}},Vn=(...t)=>new Pn(t),gl=C(Pn),fl=A(t=>mt(t)),$n=class extends M{constructor(t,e){super(),this.shape=t,this._c=e}check(t,e){let r=t instanceof this.shape&&(this._c==null||this._c(t));return!r&&e?.extend(null,this.shape.name,t?.constructor.name),r}},pl=(t,e=null)=>new $n(t,e),jc=C($n),wl=pl(M),ml=class extends M{constructor(t){super(),this.len=t.length-1,this.args=dl(...t.slice(-1)),this.res=t[this.len]}check(t,e){let r=t.constructor===Function&&t.length<=this.len;return!r&&e?.extend(null,"function",typeof t),r}},kl=C(ml),yl=A(t=>typeof t=="function"),bl=class extends M{constructor(t){super(),this.shape=t}check(t,e){let r=sr(this.shape,n=>n.check(t,e));return!r&&e?.extend(null,"Intersectinon",typeof t),r}},Fc=C(bl,t=>t.shape.length>0),ke=class extends M{constructor(t){super(),this.shape=t}check(t,e){let r=ir(this.shape,n=>n.check(t,e));return e?.extend(null,"Union",typeof t),r}};nr(ke,"_dilutes",!0);var vt=(...t)=>t.findIndex(e=>se.check(e))>=0?vt(...t.map(e=>Lt(e)).map(e=>se.check(e)?e.shape:[e]).flat(1)):t.length===1?t[0]:new ke(t),se=C(ke),Jn=()=>!0,ie=A(Jn),_l=C(gr,t=>t.shape===Jn),fr=A(t=>typeof t=="bigint"),Sl=A(t=>t===fr),zn=A(t=>typeof t=="symbol"),Pc=A(t=>t===zn),gt=A(t=>typeof t=="number"),Bn=A(t=>t===gt),bt=A(t=>typeof t=="string"),Wn=A(t=>t===bt),ye=A(t=>typeof t=="boolean"),vl=A(t=>t===ye),Yn=me(void 0),Vc=C(we,t=>t.shape.length===1&&t.shape[0]===void 0),$c=me(void 0),be=me(null),El=C(we,t=>t.shape.length===1&&t.shape[0]===null),Jc=C(Uint8Array),zc=C(dr,t=>t.shape===Uint8Array),Cl=vt(gt,bt,be,Yn,fr,ye,zn),Bc=(()=>{let t=Vn(ie),e=jn(bt,ie),r=vt(gt,bt,be,ye,t,e);return t.shape=r,e.shape.values=r,r})(),Lt=t=>{if(wl.check(t))return t;if(hl.check(t)){let e={};for(let r in t)e[r]=Lt(t[r]);return cl(e)}else{if(fl.check(t))return vt(...t.map(Lt));if(Cl.check(t))return me(t);if(yl.check(t))return C(t)}T()},Xr=Wi?()=>{}:(t,e)=>{let r=new nl;if(!e.check(t,r))throw W(`Expected value to be of type ${e.constructor.name}.
3
- ${r.toString()}`)},Dl=class{constructor(t){this.patterns=[],this.$state=t}if(t,e){return this.patterns.push({if:Lt(t),h:e}),this}else(t){return this.if(ie,t)}done(){return(t,e)=>{for(let r=0;r<this.patterns.length;r++){let n=this.patterns[r];if(n.if.check(t))return n.h(t,e)}throw W("Unhandled pattern")}}},xl=t=>new Dl(t),Kn=xl(ie).if(Bn,(t,e)=>Ue(e,$r,ee)).if(Wn,(t,e)=>el(e)).if(vl,(t,e)=>qr(e)).if(Sl,(t,e)=>BigInt(Ue(e,$r,ee))).if(se,(t,e)=>ut(e,Te(e,t.shape))).if(al,(t,e)=>{let r={};for(let n in t.shape){let s=t.shape[n];if(ol.check(s)){if(qr(e))continue;s=s.shape}r[n]=Kn(s,e)}return r}).if(gl,(t,e)=>{let r=[],n=An(e,0,42);for(let s=0;s<n;s++)r.push(ut(e,t.shape));return r}).if(On,(t,e)=>Te(e,t.shape)).if(El,(t,e)=>null).if(kl,(t,e)=>{let r=ut(e,t.res);return()=>r}).if(_l,(t,e)=>ut(e,Te(e,[gt,bt,be,Yn,fr,ye,Vn(gt),jn(vt("a","b","c"),gt)]))).if(ul,(t,e)=>{let r={},n=Ue(e,0,3);for(let s=0;s<n;s++){let i=ut(e,t.shape.keys),l=ut(e,t.shape.values);r[i]=l}return r}).done(),ut=(t,e)=>Kn(Lt(e),t),ht=typeof document<"u"?document:{},Wc=A(t=>t.nodeType===Ul),Yc=typeof DOMParser<"u"?new DOMParser:null,Kc=A(t=>t.nodeType===Ol),Hc=A(t=>t.nodeType===Il),Al=t=>Hs(t,(e,r)=>`${r}:${e};`).join(""),Ol=ht.ELEMENT_NODE,Il=ht.TEXT_NODE,Gc=ht.CDATA_SECTION_NODE,qc=ht.COMMENT_NODE,Ml=ht.DOCUMENT_NODE,Xc=ht.DOCUMENT_TYPE_NODE,Ul=ht.DOCUMENT_FRAGMENT_NODE,Qc=A(t=>t.nodeType===Ml),q=Symbol,Hn=q(),Gn=q(),Tl=q(),Nl=q(),Ll=q(),qn=q(),Rl=q(),pr=q(),jl=q(),Fl=t=>{t.length===1&&t[0]?.constructor===Function&&(t=t[0]());let e=[],r=[],n=0;for(;n<t.length;n++){let s=t[n];if(s===void 0)break;if(s.constructor===String||s.constructor===Number)e.push(s);else if(s.constructor===Object)break}for(n>0&&r.push(e.join(""));n<t.length;n++){let s=t[n];s instanceof Symbol||r.push(s)}return r},Zc=_n(),Pl={[Hn]:G("font-weight","bold"),[Gn]:G("font-weight","normal"),[Tl]:G("color","blue"),[Ll]:G("color","green"),[Nl]:G("color","grey"),[qn]:G("color","red"),[Rl]:G("color","purple"),[pr]:G("color","orange"),[jl]:G("color","black")},Vl=t=>{t.length===1&&t[0]?.constructor===Function&&(t=t[0]());let e=[],r=[],n=V(),s=[],i=0;for(;i<t.length;i++){let l=t[i],o=Pl[l];if(o!==void 0)n.set(o.left,o.right);else{if(l===void 0)break;if(l.constructor===String||l.constructor===Number){let c=Al(n);i>0||c.length>0?(e.push("%c"+l),r.push(c)):e.push(l)}else break}}for(i>0&&(s=r,s.unshift(e.join("")));i<t.length;i++){let l=t[i];l instanceof Symbol||s.push(l)}return s},Xn=Ki?Vl:Fl,$l=(...t)=>{console.log(...Xn(t)),Zn.forEach(e=>e.print(t))},Qn=(...t)=>{console.warn(...Xn(t)),t.unshift(pr),Zn.forEach(e=>e.print(t))},Zn=wt(),ts=t=>({[Symbol.iterator](){return this},next:t}),Jl=(t,e)=>ts(()=>{let r;do r=t.next();while(!r.done&&!e(r.value));return r}),Ne=(t,e)=>ts(()=>{let{done:r,value:n}=t.next();return{done:r,value:r?void 0:e(n)}});var wr=class{constructor(t,e){this.clock=t,this.len=e}},Et=class{constructor(){this.clients=new Map}},_t=(t,e,r)=>e.clients.forEach((n,s)=>{let i=t.doc.store.clients.get(s);if(i!=null){let l=i[i.length-1],o=l.id.clock+l.length;for(let c=0,u=n[c];c<n.length&&u.clock<o;u=n[++c])gs(t,i,u.clock,u.len,r)}}),zl=(t,e)=>{let r=0,n=t.length-1;for(;r<=n;){let s=B((r+n)/2),i=t[s],l=i.clock;if(l<=e){if(e<l+i.len)return s;r=s+1}else n=s-1}return null},Jt=(t,e)=>{let r=t.clients.get(e.client);return r!==void 0&&zl(r,e.clock)!==null},mr=t=>{t.clients.forEach(e=>{e.sort((s,i)=>s.clock-i.clock);let r,n;for(r=1,n=1;r<e.length;r++){let s=e[n-1],i=e[r];s.clock+s.len>=i.clock?s.len=at(s.len,i.clock+i.len-s.clock):(n<r&&(e[n]=i),n++)}e.length=n})},$e=t=>{let e=new Et;for(let r=0;r<t.length;r++)t[r].clients.forEach((n,s)=>{if(!e.clients.has(s)){let i=n.slice();for(let l=r+1;l<t.length;l++)qs(i,t[l].clients.get(s)||[]);e.clients.set(s,i)}});return mr(e),e},Rt=(t,e,r,n)=>{tt(t.clients,e,()=>[]).push(new wr(r,n))},es=()=>new Et,Bl=t=>{let e=es();return t.clients.forEach((r,n)=>{let s=[];for(let i=0;i<r.length;i++){let l=r[i];if(l.deleted){let o=l.id.clock,c=l.length;if(i+1<r.length)for(let u=r[i+1];i+1<r.length&&u.deleted;u=r[++i+1])c+=u.length;s.push(new wr(o,c))}}s.length>0&&e.clients.set(n,s)}),e},Ct=(t,e)=>{w(t.restEncoder,e.clients.size),Z(e.clients.entries()).sort((r,n)=>n[0]-r[0]).forEach(([r,n])=>{t.resetDsCurVal(),w(t.restEncoder,r);let s=n.length;w(t.restEncoder,s);for(let i=0;i<s;i++){let l=n[i];t.writeDsClock(l.clock),t.writeDsLen(l.len)}})},kr=t=>{let e=new Et,r=k(t.restDecoder);for(let n=0;n<r;n++){t.resetDsCurVal();let s=k(t.restDecoder),i=k(t.restDecoder);if(i>0){let l=tt(e.clients,s,()=>[]);for(let o=0;o<i;o++)l.push(new wr(t.readDsClock(),t.readDsLen()))}}return e},Qr=(t,e,r)=>{let n=new Et,s=k(t.restDecoder);for(let i=0;i<s;i++){t.resetDsCurVal();let l=k(t.restDecoder),o=k(t.restDecoder),c=r.clients.get(l)||[],u=E(r,l);for(let a=0;a<o;a++){let h=t.readDsClock(),d=h+t.readDsLen();if(h<u){u<d&&Rt(n,l,u,d-u);let g=Y(c,h),f=c[g];for(!f.deleted&&f.id.clock<h&&(c.splice(g+1,0,ue(e,f,h-f.id.clock)),g++);g<c.length&&(f=c[g++],f.id.clock<d);)f.deleted||(d<f.id.clock+f.length&&c.splice(g,0,ue(e,f,d-f.id.clock)),f.delete(e))}else Rt(n,l,h,d-h)}}if(n.clients.size>0){let i=new ot;return w(i.restEncoder,0),Ct(i,n),i.toUint8Array()}return null},ta=(t,e)=>{if(t.clients.size!==e.clients.size)return!1;for(let[r,n]of t.clients.entries()){let s=e.clients.get(r);if(s===void 0||n.length!==s.length)return!1;for(let i=0;i<n.length;i++){let l=n[i],o=s[i];if(l.clock!==o.clock||l.len!==o.len)return!1}}return!0},rs=bn,Dt=class ns extends pn{constructor({guid:e=Ii(),collectionid:r=null,gc:n=!0,gcFilter:s=()=>!0,meta:i=null,autoLoad:l=!1,shouldLoad:o=!0}={}){super(),this.gc=n,this.gcFilter=s,this.clientID=rs(),this.guid=e,this.collectionid=r,this.share=new Map,this.store=new us,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=o,this.autoLoad=l,this.meta=i,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=Hr(u=>{this.on("load",()=>{this.isLoaded=!0,u(this)})});let c=()=>Hr(u=>{let a=h=>{(h===void 0||h===!0)&&(this.off("sync",a),u())};this.on("sync",a)});this.on("sync",u=>{u===!1&&this.isSynced&&(this.whenSynced=c()),this.isSynced=u===void 0||u===!0,this.isSynced&&!this.isLoaded&&this.emit("load",[this])}),this.whenSynced=c()}load(){let e=this._item;e!==null&&!this.shouldLoad&&_(e.parent.doc,r=>{r.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(Z(this.subdocs).map(e=>e.guid))}transact(e,r=null){return _(this,e,r)}get(e,r=x){let n=tt(this.share,e,()=>{let i=new r;return i._integrate(this,null),i}),s=n.constructor;if(r!==x&&s!==r)if(s===x){let i=new r;i._map=n._map,n._map.forEach(l=>{for(;l!==null;l=l.left)l.parent=i}),i._start=n._start;for(let l=i._start;l!==null;l=l.right)l.parent=i;return i._length=n._length,this.share.set(e,i),i._integrate(this,null),i}else throw new Error(`Type with the name ${e} has already been defined with a different constructor`);return n}getArray(e=""){return this.get(e,xs)}getText(e=""){return this.get(e,xr)}getMap(e=""){return this.get(e,Dr)}getXmlElement(e=""){return this.get(e,Ar)}getXmlFragment(e=""){return this.get(e,xe)}toJSON(){let e={};return this.share.forEach((r,n)=>{e[n]=r.toJSON()}),e}destroy(){this.isDestroyed=!0,Z(this.subdocs).forEach(r=>r.destroy());let e=this._item;if(e!==null){this._item=null;let r=e.content;r.doc=new ns({guid:this.guid,...r.opts,shouldLoad:!1}),r.doc._item=e,_(e.parent.doc,n=>{let s=r.doc;e.deleted||n.subdocsAdded.add(s),n.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}},ss=class{constructor(t){this.restDecoder=t}resetDsCurVal(){}readDsClock(){return k(this.restDecoder)}readDsLen(){return k(this.restDecoder)}},Wl=class extends ss{readLeftID(){return y(k(this.restDecoder),k(this.restDecoder))}readRightID(){return y(k(this.restDecoder),k(this.restDecoder))}readClient(){return k(this.restDecoder)}readInfo(){return kt(this.restDecoder)}readString(){return it(this.restDecoder)}readParentInfo(){return k(this.restDecoder)===1}readTypeRef(){return k(this.restDecoder)}readLen(){return k(this.restDecoder)}readAny(){return Tt(this.restDecoder)}readBuf(){return Qi(R(this.restDecoder))}readJSON(){return JSON.parse(it(this.restDecoder))}readKey(){return it(this.restDecoder)}},Yl=class{constructor(t){this.dsCurrVal=0,this.restDecoder=t}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=k(this.restDecoder),this.dsCurrVal}readDsLen(){let t=k(this.restDecoder)+1;return this.dsCurrVal+=t,t}},lt=class extends Yl{constructor(t){super(t),this.keys=[],k(t),this.keyClockDecoder=new Me(R(t)),this.clientDecoder=new Xt(R(t)),this.leftClockDecoder=new Me(R(t)),this.rightClockDecoder=new Me(R(t)),this.infoDecoder=new Kr(R(t),kt),this.stringDecoder=new xi(R(t)),this.parentInfoDecoder=new Kr(R(t),kt),this.typeRefDecoder=new Xt(R(t)),this.lenDecoder=new Xt(R(t))}readLeftID(){return new ft(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new ft(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return Tt(this.restDecoder)}readBuf(){return R(this.restDecoder)}readJSON(){return Tt(this.restDecoder)}readKey(){let t=this.keyClockDecoder.read();if(t<this.keys.length)return this.keys[t];{let e=this.stringDecoder.read();return this.keys.push(e),e}}},is=class{constructor(){this.restEncoder=St()}toUint8Array(){return P(this.restEncoder)}resetDsCurVal(){}writeDsClock(t){w(this.restEncoder,t)}writeDsLen(t){w(this.restEncoder,t)}},_e=class extends is{writeLeftID(t){w(this.restEncoder,t.client),w(this.restEncoder,t.clock)}writeRightID(t){w(this.restEncoder,t.client),w(this.restEncoder,t.clock)}writeClient(t){w(this.restEncoder,t)}writeInfo(t){Mt(this.restEncoder,t)}writeString(t){st(this.restEncoder,t)}writeParentInfo(t){w(this.restEncoder,t?1:0)}writeTypeRef(t){w(this.restEncoder,t)}writeLen(t){w(this.restEncoder,t)}writeAny(t){Ut(this.restEncoder,t)}writeBuf(t){L(this.restEncoder,t)}writeJSON(t){st(this.restEncoder,JSON.stringify(t))}writeKey(t){st(this.restEncoder,t)}},yr=class{constructor(){this.restEncoder=St(),this.dsCurrVal=0}toUint8Array(){return P(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(t){let e=t-this.dsCurrVal;this.dsCurrVal=t,w(this.restEncoder,e)}writeDsLen(t){t===0&&T(),w(this.restEncoder,t-1),this.dsCurrVal+=t}},ot=class extends yr{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new Ie,this.clientEncoder=new qt,this.leftClockEncoder=new Ie,this.rightClockEncoder=new Ie,this.infoEncoder=new Br(Mt),this.stringEncoder=new mi,this.parentInfoEncoder=new Br(Mt),this.typeRefEncoder=new qt,this.lenEncoder=new qt}toUint8Array(){let t=St();return w(t,0),L(t,this.keyClockEncoder.toUint8Array()),L(t,this.clientEncoder.toUint8Array()),L(t,this.leftClockEncoder.toUint8Array()),L(t,this.rightClockEncoder.toUint8Array()),L(t,P(this.infoEncoder)),L(t,this.stringEncoder.toUint8Array()),L(t,P(this.parentInfoEncoder)),L(t,this.typeRefEncoder.toUint8Array()),L(t,this.lenEncoder.toUint8Array()),Vt(t,P(this.restEncoder)),P(t)}writeLeftID(t){this.clientEncoder.write(t.client),this.leftClockEncoder.write(t.clock)}writeRightID(t){this.clientEncoder.write(t.client),this.rightClockEncoder.write(t.clock)}writeClient(t){this.clientEncoder.write(t)}writeInfo(t){this.infoEncoder.write(t)}writeString(t){this.stringEncoder.write(t)}writeParentInfo(t){this.parentInfoEncoder.write(t?1:0)}writeTypeRef(t){this.typeRefEncoder.write(t)}writeLen(t){this.lenEncoder.write(t)}writeAny(t){Ut(this.restEncoder,t)}writeBuf(t){L(this.restEncoder,t)}writeJSON(t){Ut(this.restEncoder,t)}writeKey(t){let e=this.keyMap.get(t);e===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(t)):this.keyClockEncoder.write(e)}},Kl=(t,e,r,n)=>{n=at(n,e[0].id.clock);let s=Y(e,n);w(t.restEncoder,e.length-s),t.writeClient(r),w(t.restEncoder,n);let i=e[s];i.write(t,n-i.id.clock);for(let l=s+1;l<e.length;l++)e[l].write(t,0)},br=(t,e,r)=>{let n=new Map;r.forEach((s,i)=>{E(e,i)>s&&n.set(i,s)}),Se(e).forEach((s,i)=>{r.has(i)||n.set(i,0)}),w(t.restEncoder,n.size),Z(n.entries()).sort((s,i)=>i[0]-s[0]).forEach(([s,i])=>{Kl(t,e.clients.get(s),s,i)})},Hl=(t,e)=>{let r=V(),n=k(t.restDecoder);for(let s=0;s<n;s++){let i=k(t.restDecoder),l=new Array(i),o=t.readClient(),c=k(t.restDecoder);r.set(o,{i:0,refs:l});for(let u=0;u<i;u++){let a=t.readInfo();switch(31&a){case 0:{let h=t.readLen();l[u]=new F(y(o,c),h),c+=h;break}case 10:{let h=k(t.restDecoder);l[u]=new j(y(o,c),h),c+=h;break}default:{let h=(a&192)===0,d=new S(y(o,c),null,(a&128)===128?t.readLeftID():null,null,(a&64)===64?t.readRightID():null,h?t.readParentInfo()?e.get(t.readString()):t.readLeftID():null,h&&(a&32)===32?t.readString():null,Vs(t,a));l[u]=d,c+=d.length}}}}return r},Gl=(t,e,r)=>{let n=[],s=Z(r.keys()).sort((g,f)=>g-f);if(s.length===0)return null;let i=()=>{if(s.length===0)return null;let g=r.get(s[s.length-1]);for(;g.refs.length===g.i;)if(s.pop(),s.length>0)g=r.get(s[s.length-1]);else return null;return g},l=i();if(l===null)return null;let o=new us,c=new Map,u=(g,f)=>{let m=c.get(g);(m==null||m>f)&&c.set(g,f)},a=l.refs[l.i++],h=new Map,d=()=>{for(let g of n){let f=g.id.client,m=r.get(f);m?(m.i--,o.clients.set(f,m.refs.slice(m.i)),r.delete(f),m.i=0,m.refs=[]):o.clients.set(f,[g]),s=s.filter(N=>N!==f)}n.length=0};for(;;){if(a.constructor!==j){let g=tt(h,a.id.client,()=>E(e,a.id.client))-a.id.clock;if(g<0)n.push(a),u(a.id.client,a.id.clock-1),d();else{let f=a.getMissing(t,e);if(f!==null){n.push(a);let m=r.get(f)||{refs:[],i:0};if(m.refs.length===m.i)u(f,E(e,f)),d();else{a=m.refs[m.i++];continue}}else(g===0||g<a.length)&&(a.integrate(t,g),h.set(a.id.client,a.id.clock+a.length))}}if(n.length>0)a=n.pop();else if(l!==null&&l.i<l.refs.length)a=l.refs[l.i++];else{if(l=i(),l===null)break;a=l.refs[l.i++]}}if(o.clients.size>0){let g=new ot;return br(g,o,new Map),w(g.restEncoder,0),{missing:c,update:g.toUint8Array()}}return null},ql=(t,e)=>br(t,e.doc.store,e.beforeState),Xl=(t,e,r,n=new lt(t))=>_(e,s=>{s.local=!1;let i=!1,l=s.doc,o=l.store,c=Hl(n,l),u=Gl(s,o,c),a=o.pendingStructs;if(a){for(let[d,g]of a.missing)if(g<E(o,d)){i=!0;break}if(u){for(let[d,g]of u.missing){let f=a.missing.get(d);(f==null||f>g)&&a.missing.set(d,g)}a.update=oe([a.update,u.update])}}else o.pendingStructs=u;let h=Qr(n,s,o);if(o.pendingDs){let d=new lt(et(o.pendingDs));k(d.restDecoder);let g=Qr(d,s,o);h&&g?o.pendingDs=oe([h,g]):o.pendingDs=h||g}else o.pendingDs=h;if(i){let d=o.pendingStructs.update;o.pendingStructs=null,Ql(s.doc,d)}},r,!1);var Ql=(t,e,r,n=lt)=>{let s=et(e);Xl(s,t,r,new n(s))};var Zl=(t,e,r=new Map)=>{br(t,e.store,r),Ct(t,Bl(e.store))},ea=(t,e=new Uint8Array([0]),r=new ot)=>{let n=ls(e);Zl(r,t,n);let s=[r.toUint8Array()];if(t.store.pendingDs&&s.push(t.store.pendingDs),t.store.pendingStructs&&s.push(_o(t.store.pendingStructs.update,e)),s.length>1){if(r.constructor===_e)return yo(s.map((i,l)=>l===0?i:vo(i)));if(r.constructor===ot)return oe(s)}return s[0]};var to=t=>{let e=new Map,r=k(t.restDecoder);for(let n=0;n<r;n++){let s=k(t.restDecoder),i=k(t.restDecoder);e.set(s,i)}return e},ls=t=>to(new ss(et(t))),os=(t,e)=>(w(t.restEncoder,e.size),Z(e.entries()).sort((r,n)=>n[0]-r[0]).forEach(([r,n])=>{w(t.restEncoder,r),w(t.restEncoder,n)}),t),eo=(t,e)=>os(t,Se(e.store)),ro=(t,e=new yr)=>(t instanceof Map?os(e,t):eo(e,t),e.toUint8Array()),ra=t=>ro(t,new is),no=class{constructor(){this.l=[]}},Zr=()=>new no,tn=(t,e)=>t.l.push(e),en=(t,e)=>{let r=t.l,n=r.length;t.l=r.filter(s=>e!==s),n===t.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},cs=(t,e,r)=>hr(t.l,[e,r]),ft=class{constructor(t,e){this.client=t,this.clock=e}},Wt=(t,e)=>t===e||t!==null&&e!==null&&t.client===e.client&&t.clock===e.clock,y=(t,e)=>new ft(t,e),rn=(t,e)=>{w(t,e.client),w(t,e.clock)},nn=t=>y(k(t),k(t)),as=t=>{for(let[e,r]of t.doc.share.entries())if(r===t)return e;throw T()},le=(t,e)=>{for(;e!==null;){if(e.parent===t)return!0;e=e.parent._item}return!1};var hs=class{constructor(t,e,r,n=0){this.type=t,this.tname=e,this.item=r,this.assoc=n}};var so=class{constructor(t,e,r=0){this.type=t,this.index=e,this.assoc=r}},io=(t,e,r=0)=>new so(t,e,r),Yt=(t,e,r)=>{let n=null,s=null;return t._item===null?s=as(t):n=y(t._item.id.client,t._item.id.clock),new hs(n,s,e,r)},na=(t,e,r=0)=>{let n=t._start;if(r<0){if(e===0)return Yt(t,null,r);e--}for(;n!==null;){if(!n.deleted&&n.countable){if(n.length>e)return Yt(t,y(n.id.client,n.id.clock+e),r);e-=n.length}if(n.right===null&&r<0)return Yt(t,n.lastId,r);n=n.right}return Yt(t,null,r)},lo=(t,e)=>{let{type:r,tname:n,item:s,assoc:i}=e;if(s!==null)w(t,0),rn(t,s);else if(n!==null)Mt(t,1),st(t,n);else if(r!==null)Mt(t,2),rn(t,r);else throw T();return de(t,i),t},sa=t=>{let e=St();return lo(e,t),P(e)},oo=t=>{let e=null,r=null,n=null;switch(k(t)){case 0:n=nn(t);break;case 1:r=it(t);break;case 2:e=nn(t)}let s=yn(t)?pe(t):0;return new hs(e,r,n,s)},ia=t=>oo(et(t)),co=(t,e)=>{let r=pt(t,e),n=e.clock-r.id.clock;return{item:r,diff:n}},la=(t,e,r=!0)=>{let n=e.store,s=t.item,i=t.type,l=t.tname,o=t.assoc,c=null,u=0;if(s!==null){if(E(n,s.client)<=s.clock)return null;let a=r?er(n,s):co(n,s),h=a.item;if(!(h instanceof S))return null;if(c=h.parent,c._item===null||!c._item.deleted){u=h.deleted||!h.countable?0:a.diff+(o>=0?0:1);let d=h.left;for(;d!==null;)!d.deleted&&d.countable&&(u+=d.length),d=d.left}}else{if(l!==null)c=e.get(l);else if(i!==null){if(E(n,i.client)<=i.clock)return null;let{item:a}=r?er(n,i):{item:pt(n,i)};if(a instanceof S&&a.content instanceof rt)c=a.content.type;else return null}else throw T();o>=0?u=c._length:u=0}return io(c,u,t.assoc)};var ao=class{constructor(t,e){this.ds=t,this.sv=e}};var ho=(t,e)=>new ao(t,e),oa=ho(es(),new Map);var dt=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&(e.sv.get(t.id.client)||0)>t.id.clock&&!Jt(e.ds,t.id),Je=(t,e)=>{let r=tt(t.meta,Je,wt),n=t.doc.store;r.has(e)||(e.sv.forEach((s,i)=>{s<E(n,i)&&U(t,y(i,s))}),_t(t,e.ds,s=>{}),r.add(e))};var us=class{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}},Se=t=>{let e=new Map;return t.clients.forEach((r,n)=>{let s=r[r.length-1];e.set(n,s.id.clock+s.length)}),e},E=(t,e)=>{let r=t.clients.get(e);if(r===void 0)return 0;let n=r[r.length-1];return n.id.clock+n.length},ds=(t,e)=>{let r=t.clients.get(e.id.client);if(r===void 0)r=[],t.clients.set(e.id.client,r);else{let n=r[r.length-1];if(n.id.clock+n.length!==e.id.clock)throw T()}r.push(e)},Y=(t,e)=>{let r=0,n=t.length-1,s=t[n],i=s.id.clock;if(i===e)return n;let l=B(e/(i+s.length-1)*n);for(;r<=n;){if(s=t[l],i=s.id.clock,i<=e){if(e<i+s.length)return l;r=l+1}else n=l-1;l=B((r+n)/2)}throw T()},uo=(t,e)=>{let r=t.clients.get(e.client);return r[Y(r,e.clock)]},pt=uo,ze=(t,e,r)=>{let n=Y(e,r),s=e[n];return s.id.clock<r&&s instanceof S?(e.splice(n+1,0,ue(t,s,r-s.id.clock)),n+1):n},U=(t,e)=>{let r=t.doc.store.clients.get(e.client);return r[ze(t,r,e.clock)]},sn=(t,e,r)=>{let n=e.clients.get(r.client),s=Y(n,r.clock),i=n[s];return r.clock!==i.id.clock+i.length-1&&i.constructor!==F&&n.splice(s+1,0,ue(t,i,r.clock-i.id.clock+1)),i},go=(t,e,r)=>{let n=t.clients.get(e.id.client);n[Y(n,e.id.clock)]=r},gs=(t,e,r,n,s)=>{if(n===0)return;let i=r+n,l=ze(t,e,r),o;do o=e[l++],i<o.id.clock+o.length&&ze(t,e,i),s(o);while(l<e.length&&e[l].id.clock<i)},fo=class{constructor(t,e,r){this.doc=t,this.deleteSet=new Et,this.beforeState=Se(t.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=e,this.meta=new Map,this.local=r,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}},ln=(t,e)=>e.deleteSet.clients.size===0&&!Gs(e.afterState,(r,n)=>e.beforeState.get(n)!==r)?!1:(mr(e.deleteSet),ql(t,e),Ct(t,e.deleteSet),!0),on=(t,e,r)=>{let n=e._item;(n===null||n.id.clock<(t.beforeState.get(n.id.client)||0)&&!n.deleted)&&tt(t.changed,e,wt).add(r)},Zt=(t,e)=>{let r=t[e],n=t[e-1],s=e;for(;s>0;r=n,n=t[--s-1]){if(n.deleted===r.deleted&&n.constructor===r.constructor&&n.mergeWith(r)){r instanceof S&&r.parentSub!==null&&r.parent._map.get(r.parentSub)===r&&r.parent._map.set(r.parentSub,n);continue}break}let i=e-s;return i&&t.splice(e+1-i,i),i},po=(t,e,r)=>{for(let[n,s]of t.clients.entries()){let i=e.clients.get(n);for(let l=s.length-1;l>=0;l--){let o=s[l],c=o.clock+o.len;for(let u=Y(i,o.clock),a=i[u];u<i.length&&a.id.clock<c;a=i[++u]){let h=i[u];if(o.clock+o.len<=h.id.clock)break;h instanceof S&&h.deleted&&!h.keep&&r(h)&&h.gc(e,!1)}}}},wo=(t,e)=>{t.clients.forEach((r,n)=>{let s=e.clients.get(n);for(let i=r.length-1;i>=0;i--){let l=r[i],o=wn(s.length-1,1+Y(s,l.clock+l.len-1));for(let c=o,u=s[c];c>0&&u.id.clock>=l.clock;u=s[c])c-=1+Zt(s,c)}})};var fs=(t,e)=>{if(e<t.length){let r=t[e],n=r.doc,s=n.store,i=r.deleteSet,l=r._mergeStructs;try{mr(i),r.afterState=Se(r.doc.store),n.emit("beforeObserverCalls",[r,n]);let o=[];r.changed.forEach((c,u)=>o.push(()=>{(u._item===null||!u._item.deleted)&&u._callObserver(r,c)})),o.push(()=>{r.changedParentTypes.forEach((c,u)=>{u._dEH.l.length>0&&(u._item===null||!u._item.deleted)&&(c=c.filter(a=>a.target._item===null||!a.target._item.deleted),c.forEach(a=>{a.currentTarget=u,a._path=null}),c.sort((a,h)=>a.path.length-h.path.length),cs(u._dEH,c,r))})}),o.push(()=>n.emit("afterTransaction",[r,n])),hr(o,[]),r._needFormattingCleanup&&jo(r)}finally{n.gc&&po(i,s,n.gcFilter),wo(i,s),r.afterState.forEach((a,h)=>{let d=r.beforeState.get(h)||0;if(d!==a){let g=s.clients.get(h),f=at(Y(g,d),1);for(let m=g.length-1;m>=f;)m-=1+Zt(g,m)}});for(let a=l.length-1;a>=0;a--){let{client:h,clock:d}=l[a].id,g=s.clients.get(h),f=Y(g,d);f+1<g.length&&Zt(g,f+1)>1||f>0&&Zt(g,f)}if(!r.local&&r.afterState.get(n.clientID)!==r.beforeState.get(n.clientID)&&($l(pr,Hn,"[yjs] ",Gn,qn,"Changed the client-id because another client seems to be using it."),n.clientID=rs()),n.emit("afterTransactionCleanup",[r,n]),n._observers.has("update")){let a=new _e;ln(a,r)&&n.emit("update",[a.toUint8Array(),r.origin,n,r])}if(n._observers.has("updateV2")){let a=new ot;ln(a,r)&&n.emit("updateV2",[a.toUint8Array(),r.origin,n,r])}let{subdocsAdded:o,subdocsLoaded:c,subdocsRemoved:u}=r;(o.size>0||u.size>0||c.size>0)&&(o.forEach(a=>{a.clientID=n.clientID,a.collectionid==null&&(a.collectionid=n.collectionid),n.subdocs.add(a)}),u.forEach(a=>n.subdocs.delete(a)),n.emit("subdocs",[{loaded:c,added:o,removed:u},n,r]),u.forEach(a=>a.destroy())),t.length<=e+1?(n._transactionCleanups=[],n.emit("afterAllTransactions",[n,t])):fs(t,e+1)}}},_=(t,e,r=null,n=!0)=>{let s=t._transactionCleanups,i=!1,l=null;t._transaction===null&&(i=!0,t._transaction=new fo(t,r,n),s.push(t._transaction),s.length===1&&t.emit("beforeAllTransactions",[t]),t.emit("beforeTransaction",[t._transaction,t]));try{l=e(t._transaction)}finally{if(i){let o=t._transaction===s[0];t._transaction=null,o&&fs(s,0)}}return l},mo=class{constructor(t,e){this.insertions=e,this.deletions=t,this.meta=new Map}},cn=(t,e,r)=>{_t(t,r.deletions,n=>{n instanceof S&&e.scope.some(s=>s===t.doc||le(s,n))&&Ur(n,!1)})},an=(t,e,r)=>{let n=null,s=t.doc,i=t.scope;_(s,o=>{for(;e.length>0&&t.currStackItem===null;){let c=s.store,u=e.pop(),a=new Set,h=[],d=!1;_t(o,u.insertions,g=>{if(g instanceof S){if(g.redone!==null){let{item:f,diff:m}=er(c,g.id);m>0&&(f=U(o,y(f.id.client,f.id.clock+m))),g=f}!g.deleted&&i.some(f=>f===o.doc||le(f,g))&&h.push(g)}}),_t(o,u.deletions,g=>{g instanceof S&&i.some(f=>f===o.doc||le(f,g))&&!Jt(u.insertions,g.id)&&a.add(g)}),a.forEach(g=>{d=Ps(o,g,a,u.insertions,t.ignoreRemoteMapChanges,t)!==null||d});for(let g=h.length-1;g>=0;g--){let f=h[g];t.deleteFilter(f)&&(f.delete(o),d=!0)}t.currStackItem=d?u:null}o.changed.forEach((c,u)=>{c.has(null)&&u._searchMarker&&(u._searchMarker.length=0)}),n=o},t);let l=t.currStackItem;if(l!=null){let o=n.changedParentTypes;t.emit("stack-item-popped",[{stackItem:l,type:r,changedParentTypes:o,origin:t},t]),t.currStackItem=null}return l},ca=class extends pn{constructor(t,{captureTimeout:e=500,captureTransaction:r=o=>!0,deleteFilter:n=()=>!0,trackedOrigins:s=new Set([null]),ignoreRemoteMapChanges:i=!1,doc:l=mt(t)?t[0].doc:t instanceof Dt?t:t.doc}={}){super(),this.scope=[],this.doc=l,this.addToScope(t),this.deleteFilter=n,s.add(this),this.trackedOrigins=s,this.captureTransaction=r,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=i,this.captureTimeout=e,this.afterTransactionHandler=o=>{if(!this.captureTransaction(o)||!this.scope.some(m=>o.changedParentTypes.has(m)||m===this.doc)||!this.trackedOrigins.has(o.origin)&&(!o.origin||!this.trackedOrigins.has(o.origin.constructor)))return;let c=this.undoing,u=this.redoing,a=c?this.redoStack:this.undoStack;c?this.stopCapturing():u||this.clear(!1,!0);let h=new Et;o.afterState.forEach((m,N)=>{let v=o.beforeState.get(N)||0,Bt=m-v;Bt>0&&Rt(h,N,v,Bt)});let d=_n(),g=!1;if(this.lastChange>0&&d-this.lastChange<this.captureTimeout&&a.length>0&&!c&&!u){let m=a[a.length-1];m.deletions=$e([m.deletions,o.deleteSet]),m.insertions=$e([m.insertions,h])}else a.push(new mo(o.deleteSet,h)),g=!0;!c&&!u&&(this.lastChange=d),_t(o,o.deleteSet,m=>{m instanceof S&&this.scope.some(N=>N===o.doc||le(N,m))&&Ur(m,!0)});let f=[{stackItem:a[a.length-1],origin:o.origin,type:c?"redo":"undo",changedParentTypes:o.changedParentTypes},this];g?this.emit("stack-item-added",f):this.emit("stack-item-updated",f)},this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",()=>{this.destroy()})}addToScope(t){let e=new Set(this.scope);t=mt(t)?t:[t],t.forEach(r=>{e.has(r)||(e.add(r),(r instanceof x?r.doc!==this.doc:r!==this.doc)&&Qn("[yjs#509] Not same Y.Doc"),this.scope.push(r))})}addTrackedOrigin(t){this.trackedOrigins.add(t)}removeTrackedOrigin(t){this.trackedOrigins.delete(t)}clear(t=!0,e=!0){(t&&this.canUndo()||e&&this.canRedo())&&this.doc.transact(r=>{t&&(this.undoStack.forEach(n=>cn(r,this,n)),this.undoStack=[]),e&&(this.redoStack.forEach(n=>cn(r,this,n)),this.redoStack=[]),this.emit("stack-cleared",[{undoStackCleared:t,redoStackCleared:e}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let t;try{t=an(this,this.undoStack,"undo")}finally{this.undoing=!1}return t}redo(){this.redoing=!0;let t;try{t=an(this,this.redoStack,"redo")}finally{this.redoing=!1}return t}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off("afterTransaction",this.afterTransactionHandler),super.destroy()}};function*ko(t){let e=k(t.restDecoder);for(let r=0;r<e;r++){let n=k(t.restDecoder),s=t.readClient(),i=k(t.restDecoder);for(let l=0;l<n;l++){let o=t.readInfo();if(o===10){let c=k(t.restDecoder);yield new j(y(s,i),c),i+=c}else if((31&o)!==0){let c=(o&192)===0,u=new S(y(s,i),null,(o&128)===128?t.readLeftID():null,null,(o&64)===64?t.readRightID():null,c?t.readParentInfo()?t.readString():t.readLeftID():null,c&&(o&32)===32?t.readString():null,Vs(t,o));yield u,i+=u.length}else{let c=t.readLen();yield new F(y(s,i),c),i+=c}}}}var ve=class{constructor(t,e){this.gen=ko(t),this.curr=null,this.done=!1,this.filterSkips=e,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===j);return this.curr}};var _r=class{constructor(t){this.currClient=0,this.startClock=0,this.written=0,this.encoder=t,this.clientStructs=[]}},yo=t=>oe(t,Wl,_e),aa=(t,e=yr,r=lt)=>{let n=new e,s=new ve(new r(et(t)),!1),i=s.curr;if(i!==null){let l=0,o=i.id.client,c=i.id.clock!==0,u=c?0:i.id.clock+i.length;for(;i!==null;i=s.next())o!==i.id.client&&(u!==0&&(l++,w(n.restEncoder,o),w(n.restEncoder,u)),o=i.id.client,u=0,c=i.id.clock!==0),i.constructor===j&&(c=!0),c||(u=i.id.clock+i.length);u!==0&&(l++,w(n.restEncoder,o),w(n.restEncoder,u));let a=St();return w(a,l),di(a,n.restEncoder),n.restEncoder=a,n.toUint8Array()}else return w(n.restEncoder,0),n.toUint8Array()};var bo=(t,e)=>{if(t.constructor===F){let{client:r,clock:n}=t.id;return new F(y(r,n+e),t.length-e)}else if(t.constructor===j){let{client:r,clock:n}=t.id;return new j(y(r,n+e),t.length-e)}else{let r=t,{client:n,clock:s}=r.id;return new S(y(n,s+e),null,y(n,s+e-1),null,r.rightOrigin,r.parent,r.parentSub,r.content.splice(e))}},oe=(t,e=lt,r=ot)=>{if(t.length===1)return t[0];let n=t.map(a=>new e(et(a))),s=n.map(a=>new ve(a,!0)),i=null,l=new r,o=new _r(l);for(;s=s.filter(a=>a.curr!==null),s.sort((a,h)=>{if(a.curr.id.client===h.curr.id.client){let d=a.curr.id.clock-h.curr.id.clock;return d===0?a.curr.constructor===h.curr.constructor?0:a.curr.constructor===j?1:-1:d}else return h.curr.id.client-a.curr.id.client}),s.length!==0;){let a=s[0],h=a.curr.id.client;if(i!==null){let d=a.curr,g=!1;for(;d!==null&&d.id.clock+d.length<=i.struct.id.clock+i.struct.length&&d.id.client>=i.struct.id.client;)d=a.next(),g=!0;if(d===null||d.id.client!==h||g&&d.id.clock>i.struct.id.clock+i.struct.length)continue;if(h!==i.struct.id.client)X(o,i.struct,i.offset),i={struct:d,offset:0},a.next();else if(i.struct.id.clock+i.struct.length<d.id.clock)if(i.struct.constructor===j)i.struct.length=d.id.clock+d.length-i.struct.id.clock;else{X(o,i.struct,i.offset);let f=d.id.clock-i.struct.id.clock-i.struct.length;i={struct:new j(y(h,i.struct.id.clock+i.struct.length),f),offset:0}}else{let f=i.struct.id.clock+i.struct.length-d.id.clock;f>0&&(i.struct.constructor===j?i.struct.length-=f:d=bo(d,f)),i.struct.mergeWith(d)||(X(o,i.struct,i.offset),i={struct:d,offset:0},a.next())}}else i={struct:a.curr,offset:0},a.next();for(let d=a.curr;d!==null&&d.id.client===h&&d.id.clock===i.struct.id.clock+i.struct.length&&d.constructor!==j;d=a.next())X(o,i.struct,i.offset),i={struct:d,offset:0}}i!==null&&(X(o,i.struct,i.offset),i=null),Sr(o);let c=n.map(a=>kr(a)),u=$e(c);return Ct(l,u),l.toUint8Array()},_o=(t,e,r=lt,n=ot)=>{let s=ls(e),i=new n,l=new _r(i),o=new r(et(t)),c=new ve(o,!1);for(;c.curr;){let a=c.curr,h=a.id.client,d=s.get(h)||0;if(c.curr.constructor===j){c.next();continue}if(a.id.clock+a.length>d)for(X(l,a,at(d-a.id.clock,0)),c.next();c.curr&&c.curr.id.client===h;)X(l,c.curr,0),c.next();else for(;c.curr&&c.curr.id.client===h&&c.curr.id.clock+c.curr.length<=d;)c.next()}Sr(l);let u=kr(o);return Ct(i,u),i.toUint8Array()};var ps=t=>{t.written>0&&(t.clientStructs.push({written:t.written,restEncoder:P(t.encoder.restEncoder)}),t.encoder.restEncoder=St(),t.written=0)},X=(t,e,r)=>{t.written>0&&t.currClient!==e.id.client&&ps(t),t.written===0&&(t.currClient=e.id.client,t.encoder.writeClient(e.id.client),w(t.encoder.restEncoder,e.id.clock+r)),e.write(t.encoder,r),t.written++},Sr=t=>{ps(t);let e=t.encoder.restEncoder;w(e,t.clientStructs.length);for(let r=0;r<t.clientStructs.length;r++){let n=t.clientStructs[r];w(e,n.written),Vt(e,n.restEncoder)}},So=(t,e,r,n)=>{let s=new r(et(t)),i=new ve(s,!1),l=new n,o=new _r(l);for(let u=i.curr;u!==null;u=i.next())X(o,e(u),0);Sr(o);let c=kr(s);return Ct(l,c),l.toUint8Array()};var vo=t=>So(t,$i,lt,_e),hn="You must not compute changes after the event-handler fired.",Ee=class{constructor(t,e){this.target=t,this.currentTarget=t,this.transaction=e,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=Eo(this.currentTarget,this.target))}deletes(t){return Jt(this.transaction.deleteSet,t.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw W(hn);let t=new Map,e=this.target;this.transaction.changed.get(e).forEach(r=>{if(r!==null){let n=e._map.get(r),s,i;if(this.adds(n)){let l=n.left;for(;l!==null&&this.adds(l);)l=l.left;if(this.deletes(n))if(l!==null&&this.deletes(l))s="delete",i=Oe(l.content.getContent());else return;else l!==null&&this.deletes(l)?(s="update",i=Oe(l.content.getContent())):(s="add",i=void 0)}else if(this.deletes(n))s="delete",i=Oe(n.content.getContent());else return;t.set(r,{action:s,oldValue:i})}}),this._keys=t}return this._keys}get delta(){return this.changes.delta}adds(t){return t.id.clock>=(this.transaction.beforeState.get(t.id.client)||0)}get changes(){let t=this._changes;if(t===null){if(this.transaction.doc._transactionCleanups.length===0)throw W(hn);let e=this.target,r=wt(),n=wt(),s=[];if(t={added:r,deleted:n,delta:s,keys:this.keys},this.transaction.changed.get(e).has(null)){let i=null,l=()=>{i&&s.push(i)};for(let o=e._start;o!==null;o=o.right)o.deleted?this.deletes(o)&&!this.adds(o)&&((i===null||i.delete===void 0)&&(l(),i={delete:0}),i.delete+=o.length,n.add(o)):this.adds(o)?((i===null||i.insert===void 0)&&(l(),i={insert:[]}),i.insert=i.insert.concat(o.content.getContent()),r.add(o)):((i===null||i.retain===void 0)&&(l(),i={retain:0}),i.retain+=o.length);i!==null&&i.retain===void 0&&l()}this._changes=t}return t}},Eo=(t,e)=>{let r=[];for(;e._item!==null&&e!==t;){if(e._item.parentSub!==null)r.unshift(e._item.parentSub);else{let n=0,s=e._item.parent._start;for(;s!==e._item&&s!==null;)!s.deleted&&s.countable&&(n+=s.length),s=s.right;r.unshift(n)}e=e._item.parent}return r},I=()=>{Qn("Invalid access: Add Yjs type to a document before reading data.")},ws=80,vr=0,Co=class{constructor(t,e){t.marker=!0,this.p=t,this.index=e,this.timestamp=vr++}},Do=t=>{t.timestamp=vr++},ms=(t,e,r)=>{t.p.marker=!1,t.p=e,e.marker=!0,t.index=r,t.timestamp=vr++},xo=(t,e,r)=>{if(t.length>=ws){let n=t.reduce((s,i)=>s.timestamp<i.timestamp?s:i);return ms(n,e,r),n}else{let n=new Co(e,r);return t.push(n),n}},Ce=(t,e)=>{if(t._start===null||e===0||t._searchMarker===null)return null;let r=t._searchMarker.length===0?null:t._searchMarker.reduce((i,l)=>Gt(e-i.index)<Gt(e-l.index)?i:l),n=t._start,s=0;for(r!==null&&(n=r.p,s=r.index,Do(r));n.right!==null&&s<e;){if(!n.deleted&&n.countable){if(e<s+n.length)break;s+=n.length}n=n.right}for(;n.left!==null&&s>e;)n=n.left,!n.deleted&&n.countable&&(s-=n.length);for(;n.left!==null&&n.left.id.client===n.id.client&&n.left.id.clock+n.left.length===n.id.clock;)n=n.left,!n.deleted&&n.countable&&(s-=n.length);return r!==null&&Gt(r.index-s)<n.parent.length/ws?(ms(r,n,s),r):xo(t._searchMarker,n,s)},jt=(t,e,r)=>{for(let n=t.length-1;n>=0;n--){let s=t[n];if(r>0){let i=s.p;for(i.marker=!1;i&&(i.deleted||!i.countable);)i=i.left,i&&!i.deleted&&i.countable&&(s.index-=i.length);if(i===null||i.marker===!0){t.splice(n,1);continue}s.p=i,i.marker=!0}(e<s.index||r>0&&e===s.index)&&(s.index=at(e,s.index+r))}};var De=(t,e,r)=>{let n=t,s=e.changedParentTypes;for(;tt(s,t,()=>[]).push(r),t._item!==null;)t=t._item.parent;cs(n._eH,r,e)},x=class{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=Zr(),this._dEH=Zr(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(t,e){this.doc=t,this._item=e}_copy(){throw $()}clone(){throw $()}_write(t){}get _first(){let t=this._start;for(;t!==null&&t.deleted;)t=t.right;return t}_callObserver(t,e){!t.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(t){tn(this._eH,t)}observeDeep(t){tn(this._dEH,t)}unobserve(t){en(this._eH,t)}unobserveDeep(t){en(this._dEH,t)}toJSON(){}},ks=(t,e,r)=>{t.doc??I(),e<0&&(e=t._length+e),r<0&&(r=t._length+r);let n=r-e,s=[],i=t._start;for(;i!==null&&n>0;){if(i.countable&&!i.deleted){let l=i.content.getContent();if(l.length<=e)e-=l.length;else{for(let o=e;o<l.length&&n>0;o++)s.push(l[o]),n--;e=0}}i=i.right}return s},ys=t=>{t.doc??I();let e=[],r=t._start;for(;r!==null;){if(r.countable&&!r.deleted){let n=r.content.getContent();for(let s=0;s<n.length;s++)e.push(n[s])}r=r.right}return e};var Ft=(t,e)=>{let r=0,n=t._start;for(t.doc??I();n!==null;){if(n.countable&&!n.deleted){let s=n.content.getContent();for(let i=0;i<s.length;i++)e(s[i],r++,t)}n=n.right}},bs=(t,e)=>{let r=[];return Ft(t,(n,s)=>{r.push(e(n,s,t))}),r},Ao=t=>{let e=t._start,r=null,n=0;return{[Symbol.iterator](){return this},next:()=>{if(r===null){for(;e!==null&&e.deleted;)e=e.right;if(e===null)return{done:!0,value:void 0};r=e.content.getContent(),n=0,e=e.right}let s=r[n++];return r.length<=n&&(r=null),{done:!1,value:s}}}},_s=(t,e)=>{t.doc??I();let r=Ce(t,e),n=t._start;for(r!==null&&(n=r.p,e-=r.index);n!==null;n=n.right)if(!n.deleted&&n.countable){if(e<n.length)return n.content.getContent()[e];e-=n.length}},ce=(t,e,r,n)=>{let s=r,i=t.doc,l=i.clientID,o=i.store,c=r===null?e._start:r.right,u=[],a=()=>{u.length>0&&(s=new S(y(l,E(o,l)),s,s&&s.lastId,c,c&&c.id,e,null,new he(u)),s.integrate(t,0),u=[])};n.forEach(h=>{if(h===null)u.push(h);else switch(h.constructor){case Number:case Object:case Boolean:case Array:case String:u.push(h);break;default:switch(a(),h.constructor){case Uint8Array:case ArrayBuffer:s=new S(y(l,E(o,l)),s,s&&s.lastId,c,c&&c.id,e,null,new Ir(new Uint8Array(h))),s.integrate(t,0);break;case Dt:s=new S(y(l,E(o,l)),s,s&&s.lastId,c,c&&c.id,e,null,new Mr(h)),s.integrate(t,0);break;default:if(h instanceof x)s=new S(y(l,E(o,l)),s,s&&s.lastId,c,c&&c.id,e,null,new rt(h)),s.integrate(t,0);else throw new Error("Unexpected content type in insert operation")}}}),a()},Ss=()=>W("Length exceeded!"),vs=(t,e,r,n)=>{if(r>e._length)throw Ss();if(r===0)return e._searchMarker&&jt(e._searchMarker,r,n.length),ce(t,e,null,n);let s=r,i=Ce(e,r),l=e._start;for(i!==null&&(l=i.p,r-=i.index,r===0&&(l=l.prev,r+=l&&l.countable&&!l.deleted?l.length:0));l!==null;l=l.right)if(!l.deleted&&l.countable){if(r<=l.length){r<l.length&&U(t,y(l.id.client,l.id.clock+r));break}r-=l.length}return e._searchMarker&&jt(e._searchMarker,s,n.length),ce(t,e,l,n)},Oo=(t,e,r)=>{let n=(e._searchMarker||[]).reduce((s,i)=>i.index>s.index?i:s,{index:0,p:e._start}).p;if(n)for(;n.right;)n=n.right;return ce(t,e,n,r)},Es=(t,e,r,n)=>{if(n===0)return;let s=r,i=n,l=Ce(e,r),o=e._start;for(l!==null&&(o=l.p,r-=l.index);o!==null&&r>0;o=o.right)!o.deleted&&o.countable&&(r<o.length&&U(t,y(o.id.client,o.id.clock+r)),r-=o.length);for(;n>0&&o!==null;)o.deleted||(n<o.length&&U(t,y(o.id.client,o.id.clock+n)),o.delete(t),n-=o.length),o=o.right;if(n>0)throw Ss();e._searchMarker&&jt(e._searchMarker,s,-i+n)},ae=(t,e,r)=>{let n=e._map.get(r);n!==void 0&&n.delete(t)},Er=(t,e,r,n)=>{let s=e._map.get(r)||null,i=t.doc,l=i.clientID,o;if(n==null)o=new he([n]);else switch(n.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:o=new he([n]);break;case Uint8Array:o=new Ir(n);break;case Dt:o=new Mr(n);break;default:if(n instanceof x)o=new rt(n);else throw new Error("Unexpected content type")}new S(y(l,E(i.store,l)),s,s&&s.lastId,null,null,e,r,o).integrate(t,0)},Cr=(t,e)=>{t.doc??I();let r=t._map.get(e);return r!==void 0&&!r.deleted?r.content.getContent()[r.length-1]:void 0},Cs=t=>{let e={};return t.doc??I(),t._map.forEach((r,n)=>{r.deleted||(e[n]=r.content.getContent()[r.length-1])}),e},Ds=(t,e)=>{t.doc??I();let r=t._map.get(e);return r!==void 0&&!r.deleted};var Io=(t,e)=>{let r={};return t._map.forEach((n,s)=>{let i=n;for(;i!==null&&(!e.sv.has(i.id.client)||i.id.clock>=(e.sv.get(i.id.client)||0));)i=i.left;i!==null&&dt(i,e)&&(r[s]=i.content.getContent()[i.length-1])}),r},Kt=t=>(t.doc??I(),Jl(t._map.entries(),e=>!e[1].deleted)),Mo=class extends Ee{},xs=class te extends x{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){let r=new te;return r.push(e),r}_integrate(e,r){super._integrate(e,r),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new te}clone(){let e=new te;return e.insert(0,this.toArray().map(r=>r instanceof x?r.clone():r)),e}get length(){return this.doc??I(),this._length}_callObserver(e,r){super._callObserver(e,r),De(this,e,new Mo(this,e))}insert(e,r){this.doc!==null?_(this.doc,n=>{vs(n,this,e,r)}):this._prelimContent.splice(e,0,...r)}push(e){this.doc!==null?_(this.doc,r=>{Oo(r,this,e)}):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,r=1){this.doc!==null?_(this.doc,n=>{Es(n,this,e,r)}):this._prelimContent.splice(e,r)}get(e){return _s(this,e)}toArray(){return ys(this)}slice(e=0,r=this.length){return ks(this,e,r)}toJSON(){return this.map(e=>e instanceof x?e.toJSON():e)}map(e){return bs(this,e)}forEach(e){Ft(this,e)}[Symbol.iterator](){return Ao(this)}_write(e){e.writeTypeRef(ic)}},Uo=t=>new xs,To=class extends Ee{constructor(t,e,r){super(t,e),this.keysChanged=r}},Dr=class Be extends x{constructor(e){super(),this._prelimContent=null,e===void 0?this._prelimContent=new Map:this._prelimContent=new Map(e)}_integrate(e,r){super._integrate(e,r),this._prelimContent.forEach((n,s)=>{this.set(s,n)}),this._prelimContent=null}_copy(){return new Be}clone(){let e=new Be;return this.forEach((r,n)=>{e.set(n,r instanceof x?r.clone():r)}),e}_callObserver(e,r){De(this,e,new To(this,e,r))}toJSON(){this.doc??I();let e={};return this._map.forEach((r,n)=>{if(!r.deleted){let s=r.content.getContent()[r.length-1];e[n]=s instanceof x?s.toJSON():s}}),e}get size(){return[...Kt(this)].length}keys(){return Ne(Kt(this),e=>e[0])}values(){return Ne(Kt(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return Ne(Kt(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??I(),this._map.forEach((r,n)=>{r.deleted||e(r.content.getContent()[r.length-1],n,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc!==null?_(this.doc,r=>{ae(r,this,e)}):this._prelimContent.delete(e)}set(e,r){return this.doc!==null?_(this.doc,n=>{Er(n,this,e,r)}):this._prelimContent.set(e,r),r}get(e){return Cr(this,e)}has(e){return Ds(this,e)}clear(){this.doc!==null?_(this.doc,e=>{this.forEach(function(r,n,s){ae(e,s,n)})}):this._prelimContent.clear()}_write(e){e.writeTypeRef(lc)}},No=t=>new Dr,Q=(t,e)=>t===e||typeof t=="object"&&typeof e=="object"&&t&&e&&Pi(t,e),We=class{constructor(t,e,r,n){this.left=t,this.right=e,this.index=r,this.currentAttributes=n}forward(){this.right===null&&T(),this.right.content.constructor===O?this.right.deleted||xt(this.currentAttributes,this.right.content):this.right.deleted||(this.index+=this.right.length),this.left=this.right,this.right=this.right.right}},un=(t,e,r)=>{for(;e.right!==null&&r>0;)e.right.content.constructor===O?e.right.deleted||xt(e.currentAttributes,e.right.content):e.right.deleted||(r<e.right.length&&U(t,y(e.right.id.client,e.right.id.clock+r)),e.index+=e.right.length,r-=e.right.length),e.left=e.right,e.right=e.right.right;return e},Ht=(t,e,r,n)=>{let s=new Map,i=n?Ce(e,r):null;if(i){let l=new We(i.p.left,i.p,i.index,s);return un(t,l,r-i.index)}else{let l=new We(null,e._start,0,s);return un(t,l,r)}},As=(t,e,r,n)=>{for(;r.right!==null&&(r.right.deleted===!0||r.right.content.constructor===O&&Q(n.get(r.right.content.key),r.right.content.value));)r.right.deleted||n.delete(r.right.content.key),r.forward();let s=t.doc,i=s.clientID;n.forEach((l,o)=>{let c=r.left,u=r.right,a=new S(y(i,E(s.store,i)),c,c&&c.lastId,u,u&&u.id,e,null,new O(o,l));a.integrate(t,0),r.right=a,r.forward()})},xt=(t,e)=>{let{key:r,value:n}=e;n===null?t.delete(r):t.set(r,n)},Os=(t,e)=>{for(;t.right!==null&&(t.right.deleted||t.right.content.constructor===O&&Q(e[t.right.content.key]??null,t.right.content.value));)t.forward()},Is=(t,e,r,n)=>{let s=t.doc,i=s.clientID,l=new Map;for(let o in n){let c=n[o],u=r.currentAttributes.get(o)??null;if(!Q(u,c)){l.set(o,u);let{left:a,right:h}=r;r.right=new S(y(i,E(s.store,i)),a,a&&a.lastId,h,h&&h.id,e,null,new O(o,c)),r.right.integrate(t,0),r.forward()}}return l},Le=(t,e,r,n,s)=>{r.currentAttributes.forEach((d,g)=>{s[g]===void 0&&(s[g]=null)});let i=t.doc,l=i.clientID;Os(r,s);let o=Is(t,e,r,s),c=n.constructor===String?new ct(n):n instanceof x?new rt(n):new zt(n),{left:u,right:a,index:h}=r;e._searchMarker&&jt(e._searchMarker,r.index,c.getLength()),a=new S(y(l,E(i.store,l)),u,u&&u.lastId,a,a&&a.id,e,null,c),a.integrate(t,0),r.right=a,r.index=h,r.forward(),As(t,e,r,o)},dn=(t,e,r,n,s)=>{let i=t.doc,l=i.clientID;Os(r,s);let o=Is(t,e,r,s);t:for(;r.right!==null&&(n>0||o.size>0&&(r.right.deleted||r.right.content.constructor===O));){if(!r.right.deleted)switch(r.right.content.constructor){case O:{let{key:c,value:u}=r.right.content,a=s[c];if(a!==void 0){if(Q(a,u))o.delete(c);else{if(n===0)break t;o.set(c,u)}r.right.delete(t)}else r.currentAttributes.set(c,u);break}default:n<r.right.length&&U(t,y(r.right.id.client,r.right.id.clock+n)),n-=r.right.length;break}r.forward()}if(n>0){let c="";for(;n>0;n--)c+=`
4
- `;r.right=new S(y(l,E(i.store,l)),r.left,r.left&&r.left.lastId,r.right,r.right&&r.right.id,e,null,new ct(c)),r.right.integrate(t,0),r.forward()}As(t,e,r,o)},Ms=(t,e,r,n,s)=>{let i=e,l=V();for(;i&&(!i.countable||i.deleted);){if(!i.deleted&&i.content.constructor===O){let u=i.content;l.set(u.key,u)}i=i.right}let o=0,c=!1;for(;e!==i;){if(r===e&&(c=!0),!e.deleted){let u=e.content;if(u.constructor===O){let{key:a,value:h}=u,d=n.get(a)??null;(l.get(a)!==u||d===h)&&(e.delete(t),o++,!c&&(s.get(a)??null)===h&&d!==h&&(d===null?s.delete(a):s.set(a,d))),!c&&!e.deleted&&xt(s,u)}}e=e.right}return o},Lo=(t,e)=>{for(;e&&e.right&&(e.right.deleted||!e.right.countable);)e=e.right;let r=new Set;for(;e&&(e.deleted||!e.countable);){if(!e.deleted&&e.content.constructor===O){let n=e.content.key;r.has(n)?e.delete(t):r.add(n)}e=e.left}},Ro=t=>{let e=0;return _(t.doc,r=>{let n=t._start,s=t._start,i=V(),l=je(i);for(;s;)s.deleted===!1&&(s.content.constructor===O?xt(l,s.content):(e+=Ms(r,n,s,i,l),i=je(l),n=s)),s=s.right}),e},jo=t=>{let e=new Set,r=t.doc;for(let[n,s]of t.afterState.entries()){let i=t.beforeState.get(n)||0;s!==i&&gs(t,r.store.clients.get(n),i,s,l=>{!l.deleted&&l.content.constructor===O&&l.constructor!==F&&e.add(l.parent)})}_(r,n=>{_t(t,t.deleteSet,s=>{if(s instanceof F||!s.parent._hasFormatting||e.has(s.parent))return;let i=s.parent;s.content.constructor===O?e.add(i):Lo(n,s)});for(let s of e)Ro(s)})},gn=(t,e,r)=>{let n=r,s=je(e.currentAttributes),i=e.right;for(;r>0&&e.right!==null;){if(e.right.deleted===!1)switch(e.right.content.constructor){case rt:case zt:case ct:r<e.right.length&&U(t,y(e.right.id.client,e.right.id.clock+r)),r-=e.right.length,e.right.delete(t);break}e.forward()}i&&Ms(t,i,e.right,s,e.currentAttributes);let l=(e.left||e.right).parent;return l._searchMarker&&jt(l._searchMarker,e.index,-n+r),e},Fo=class extends Ee{constructor(t,e,r){super(t,e),this.childListChanged=!1,this.keysChanged=new Set,r.forEach(n=>{n===null?this.childListChanged=!0:this.keysChanged.add(n)})}get changes(){if(this._changes===null){let t={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=t}return this._changes}get delta(){if(this._delta===null){let t=this.target.doc,e=[];_(t,r=>{let n=new Map,s=new Map,i=this.target._start,l=null,o={},c="",u=0,a=0,h=()=>{if(l!==null){let d=null;switch(l){case"delete":a>0&&(d={delete:a}),a=0;break;case"insert":(typeof c=="object"||c.length>0)&&(d={insert:c},n.size>0&&(d.attributes={},n.forEach((g,f)=>{g!==null&&(d.attributes[f]=g)}))),c="";break;case"retain":u>0&&(d={retain:u},Fi(o)||(d.attributes=Li({},o))),u=0;break}d&&e.push(d),l=null}};for(;i!==null;){switch(i.content.constructor){case rt:case zt:this.adds(i)?this.deletes(i)||(h(),l="insert",c=i.content.getContent()[0],h()):this.deletes(i)?(l!=="delete"&&(h(),l="delete"),a+=1):i.deleted||(l!=="retain"&&(h(),l="retain"),u+=1);break;case ct:this.adds(i)?this.deletes(i)||(l!=="insert"&&(h(),l="insert"),c+=i.content.str):this.deletes(i)?(l!=="delete"&&(h(),l="delete"),a+=i.length):i.deleted||(l!=="retain"&&(h(),l="retain"),u+=i.length);break;case O:{let{key:d,value:g}=i.content;if(this.adds(i)){if(!this.deletes(i)){let f=n.get(d)??null;Q(f,g)?g!==null&&i.delete(r):(l==="retain"&&h(),Q(g,s.get(d)??null)?delete o[d]:o[d]=g)}}else if(this.deletes(i)){s.set(d,g);let f=n.get(d)??null;Q(f,g)||(l==="retain"&&h(),o[d]=f)}else if(!i.deleted){s.set(d,g);let f=o[d];f!==void 0&&(Q(f,g)?f!==null&&i.delete(r):(l==="retain"&&h(),g===null?delete o[d]:o[d]=g))}i.deleted||(l==="insert"&&h(),xt(n,i.content));break}}i=i.right}for(h();e.length>0;){let d=e[e.length-1];if(d.retain!==void 0&&d.attributes===void 0)e.pop();else break}}),this._delta=e}return this._delta}},xr=class Ye extends x{constructor(e){super(),this._pending=e!==void 0?[()=>this.insert(0,e)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??I(),this._length}_integrate(e,r){super._integrate(e,r);try{this._pending.forEach(n=>n())}catch(n){console.error(n)}this._pending=null}_copy(){return new Ye}clone(){let e=new Ye;return e.applyDelta(this.toDelta()),e}_callObserver(e,r){super._callObserver(e,r);let n=new Fo(this,e,r);De(this,e,n),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??I();let e="",r=this._start;for(;r!==null;)!r.deleted&&r.countable&&r.content.constructor===ct&&(e+=r.content.str),r=r.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:r=!0}={}){this.doc!==null?_(this.doc,n=>{let s=new We(null,this._start,0,new Map);for(let i=0;i<e.length;i++){let l=e[i];if(l.insert!==void 0){let o=!r&&typeof l.insert=="string"&&i===e.length-1&&s.right===null&&l.insert.slice(-1)===`
5
- `?l.insert.slice(0,-1):l.insert;(typeof o!="string"||o.length>0)&&Le(n,this,s,o,l.attributes||{})}else l.retain!==void 0?dn(n,this,s,l.retain,l.attributes||{}):l.delete!==void 0&&gn(n,s,l.delete)}}):this._pending.push(()=>this.applyDelta(e))}toDelta(e,r,n){this.doc??I();let s=[],i=new Map,l=this.doc,o="",c=this._start;function u(){if(o.length>0){let h={},d=!1;i.forEach((f,m)=>{d=!0,h[m]=f});let g={insert:o};d&&(g.attributes=h),s.push(g),o=""}}let a=()=>{for(;c!==null;){if(dt(c,e)||r!==void 0&&dt(c,r))switch(c.content.constructor){case ct:{let h=i.get("ychange");e!==void 0&&!dt(c,e)?(h===void 0||h.user!==c.id.client||h.type!=="removed")&&(u(),i.set("ychange",n?n("removed",c.id):{type:"removed"})):r!==void 0&&!dt(c,r)?(h===void 0||h.user!==c.id.client||h.type!=="added")&&(u(),i.set("ychange",n?n("added",c.id):{type:"added"})):h!==void 0&&(u(),i.delete("ychange")),o+=c.content.str;break}case rt:case zt:{u();let h={insert:c.content.getContent()[0]};if(i.size>0){let d={};h.attributes=d,i.forEach((g,f)=>{d[f]=g})}s.push(h);break}case O:dt(c,e)&&(u(),xt(i,c.content));break}c=c.right}u()};return e||r?_(l,h=>{e&&Je(h,e),r&&Je(h,r),a()},"cleanup"):a(),s}insert(e,r,n){if(r.length<=0)return;let s=this.doc;s!==null?_(s,i=>{let l=Ht(i,this,e,!n);n||(n={},l.currentAttributes.forEach((o,c)=>{n[c]=o})),Le(i,this,l,r,n)}):this._pending.push(()=>this.insert(e,r,n))}insertEmbed(e,r,n){let s=this.doc;s!==null?_(s,i=>{let l=Ht(i,this,e,!n);Le(i,this,l,r,n||{})}):this._pending.push(()=>this.insertEmbed(e,r,n||{}))}delete(e,r){if(r===0)return;let n=this.doc;n!==null?_(n,s=>{gn(s,Ht(s,this,e,!0),r)}):this._pending.push(()=>this.delete(e,r))}format(e,r,n){if(r===0)return;let s=this.doc;s!==null?_(s,i=>{let l=Ht(i,this,e,!1);l.right!==null&&dn(i,this,l,r,n)}):this._pending.push(()=>this.format(e,r,n))}removeAttribute(e){this.doc!==null?_(this.doc,r=>{ae(r,this,e)}):this._pending.push(()=>this.removeAttribute(e))}setAttribute(e,r){this.doc!==null?_(this.doc,n=>{Er(n,this,e,r)}):this._pending.push(()=>this.setAttribute(e,r))}getAttribute(e){return Cr(this,e)}getAttributes(){return Cs(this)}_write(e){e.writeTypeRef(oc)}},Po=t=>new xr,Re=class{constructor(t,e=()=>!0){this._filter=e,this._root=t,this._currentNode=t._start,this._firstCall=!0,t.doc??I()}[Symbol.iterator](){return this}next(){let t=this._currentNode,e=t&&t.content&&t.content.type;if(t!==null&&(!this._firstCall||t.deleted||!this._filter(e)))do if(e=t.content.type,!t.deleted&&(e.constructor===Ar||e.constructor===xe)&&e._start!==null)t=e._start;else for(;t!==null;){let r=t.next;if(r!==null){t=r;break}else t.parent===this._root?t=null:t=t.parent._item}while(t!==null&&(t.deleted||!this._filter(t.content.type)));return this._firstCall=!1,t===null?{value:void 0,done:!0}:(this._currentNode=t,{value:t.content.type,done:!1})}},xe=class Ke extends x{constructor(){super(),this._prelimContent=[]}get firstChild(){let e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,r){super._integrate(e,r),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new Ke}clone(){let e=new Ke;return e.insert(0,this.toArray().map(r=>r instanceof x?r.clone():r)),e}get length(){return this.doc??I(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new Re(this,e)}querySelector(e){e=e.toUpperCase();let r=new Re(this,n=>n.nodeName&&n.nodeName.toUpperCase()===e).next();return r.done?null:r.value}querySelectorAll(e){return e=e.toUpperCase(),Z(new Re(this,r=>r.nodeName&&r.nodeName.toUpperCase()===e))}_callObserver(e,r){De(this,e,new Jo(this,r,e))}toString(){return bs(this,e=>e.toString()).join("")}toJSON(){return this.toString()}toDOM(e=document,r={},n){let s=e.createDocumentFragment();return n!==void 0&&n._createAssociation(s,this),Ft(this,i=>{s.insertBefore(i.toDOM(e,r,n),null)}),s}insert(e,r){this.doc!==null?_(this.doc,n=>{vs(n,this,e,r)}):this._prelimContent.splice(e,0,...r)}insertAfter(e,r){if(this.doc!==null)_(this.doc,n=>{let s=e&&e instanceof x?e._item:e;ce(n,this,s,r)});else{let n=this._prelimContent,s=e===null?0:n.findIndex(i=>i===e)+1;if(s===0&&e!==null)throw W("Reference item not found");n.splice(s,0,...r)}}delete(e,r=1){this.doc!==null?_(this.doc,n=>{Es(n,this,e,r)}):this._prelimContent.splice(e,r)}toArray(){return ys(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return _s(this,e)}slice(e=0,r=this.length){return ks(this,e,r)}forEach(e){Ft(this,e)}_write(e){e.writeTypeRef(ac)}},Vo=t=>new xe,Ar=class He extends xe{constructor(e="UNDEFINED"){super(),this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,r){super._integrate(e,r),this._prelimAttrs.forEach((n,s)=>{this.setAttribute(s,n)}),this._prelimAttrs=null}_copy(){return new He(this.nodeName)}clone(){let e=new He(this.nodeName),r=this.getAttributes();return ji(r,(n,s)=>{typeof n=="string"&&e.setAttribute(s,n)}),e.insert(0,this.toArray().map(n=>n instanceof x?n.clone():n)),e}toString(){let e=this.getAttributes(),r=[],n=[];for(let o in e)n.push(o);n.sort();let s=n.length;for(let o=0;o<s;o++){let c=n[o];r.push(c+'="'+e[c]+'"')}let i=this.nodeName.toLocaleLowerCase(),l=r.length>0?" "+r.join(" "):"";return`<${i}${l}>${super.toString()}</${i}>`}removeAttribute(e){this.doc!==null?_(this.doc,r=>{ae(r,this,e)}):this._prelimAttrs.delete(e)}setAttribute(e,r){this.doc!==null?_(this.doc,n=>{Er(n,this,e,r)}):this._prelimAttrs.set(e,r)}getAttribute(e){return Cr(this,e)}hasAttribute(e){return Ds(this,e)}getAttributes(e){return e?Io(this,e):Cs(this)}toDOM(e=document,r={},n){let s=e.createElement(this.nodeName),i=this.getAttributes();for(let l in i){let o=i[l];typeof o=="string"&&s.setAttribute(l,o)}return Ft(this,l=>{s.appendChild(l.toDOM(e,r,n))}),n!==void 0&&n._createAssociation(s,this),s}_write(e){e.writeTypeRef(cc),e.writeKey(this.nodeName)}},$o=t=>new Ar(t.readKey()),Jo=class extends Ee{constructor(t,e,r){super(t,r),this.childListChanged=!1,this.attributesChanged=new Set,e.forEach(n=>{n===null?this.childListChanged=!0:this.attributesChanged.add(n)})}},zo=class Ge extends Dr{constructor(e){super(),this.hookName=e}_copy(){return new Ge(this.hookName)}clone(){let e=new Ge(this.hookName);return this.forEach((r,n)=>{e.set(n,r)}),e}toDOM(e=document,r={},n){let s=r[this.hookName],i;return s!==void 0?i=s.createDom(this):i=document.createElement(this.hookName),i.setAttribute("data-yjs-hook",this.hookName),n!==void 0&&n._createAssociation(i,this),i}_write(e){e.writeTypeRef(hc),e.writeKey(this.hookName)}},Bo=t=>new zo(t.readKey()),Wo=class qe extends xr{get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new qe}clone(){let e=new qe;return e.applyDelta(this.toDelta()),e}toDOM(e=document,r,n){let s=e.createTextNode(this.toString());return n!==void 0&&n._createAssociation(s,this),s}toString(){return this.toDelta().map(e=>{let r=[];for(let s in e.attributes){let i=[];for(let l in e.attributes[s])i.push({key:l,value:e.attributes[s][l]});i.sort((l,o)=>l.key<o.key?-1:1),r.push({nodeName:s,attrs:i})}r.sort((s,i)=>s.nodeName<i.nodeName?-1:1);let n="";for(let s=0;s<r.length;s++){let i=r[s];n+=`<${i.nodeName}`;for(let l=0;l<i.attrs.length;l++){let o=i.attrs[l];n+=` ${o.key}="${o.value}"`}n+=">"}n+=e.insert;for(let s=r.length-1;s>=0;s--)n+=`</${r[s].nodeName}>`;return n}).join("")}toJSON(){return this.toString()}_write(e){e.writeTypeRef(uc)}},Yo=t=>new Wo,Or=class{constructor(t,e){this.id=t,this.length=e}get deleted(){throw $()}mergeWith(t){return!1}write(t,e,r){throw $()}integrate(t,e){throw $()}},Ko=0,F=class extends Or{get deleted(){return!0}delete(){}mergeWith(t){return this.constructor!==t.constructor?!1:(this.length+=t.length,!0)}integrate(t,e){e>0&&(this.id.clock+=e,this.length-=e),ds(t.doc.store,this)}write(t,e){t.writeInfo(Ko),t.writeLen(this.length-e)}getMissing(t,e){return null}},Ir=class Us{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new Us(this.content)}splice(e){throw $()}mergeWith(e){return!1}integrate(e,r){}delete(e){}gc(e){}write(e,r){e.writeBuf(this.content)}getRef(){return 3}},Ho=t=>new Ir(t.readBuf()),Ts=class Xe{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new Xe(this.len)}splice(e){let r=new Xe(this.len-e);return this.len=e,r}mergeWith(e){return this.len+=e.len,!0}integrate(e,r){Rt(e.deleteSet,r.id.client,r.id.clock,this.len),r.markDeleted()}delete(e){}gc(e){}write(e,r){e.writeLen(this.len-r)}getRef(){return 1}},Go=t=>new Ts(t.readLen()),Ns=(t,e)=>new Dt({guid:t,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1}),Mr=class Ls{constructor(e){e._item&&console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid."),this.doc=e;let r={};this.opts=r,e.gc||(r.gc=!1),e.autoLoad&&(r.autoLoad=!0),e.meta!==null&&(r.meta=e.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new Ls(Ns(this.doc.guid,this.opts))}splice(e){throw $()}mergeWith(e){return!1}integrate(e,r){this.doc._item=r,e.subdocsAdded.add(this.doc),this.doc.shouldLoad&&e.subdocsLoaded.add(this.doc)}delete(e){e.subdocsAdded.has(this.doc)?e.subdocsAdded.delete(this.doc):e.subdocsRemoved.add(this.doc)}gc(e){}write(e,r){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}},qo=t=>new Mr(Ns(t.readString(),t.readAny())),zt=class Rs{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new Rs(this.embed)}splice(e){throw $()}mergeWith(e){return!1}integrate(e,r){}delete(e){}gc(e){}write(e,r){e.writeJSON(this.embed)}getRef(){return 5}},Xo=t=>new zt(t.readJSON()),O=class js{constructor(e,r){this.key=e,this.value=r}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new js(this.key,this.value)}splice(e){throw $()}mergeWith(e){return!1}integrate(e,r){let n=r.parent;n._searchMarker=null,n._hasFormatting=!0}delete(e){}gc(e){}write(e,r){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}},Qo=t=>new O(t.readKey(),t.readJSON()),Zo=class Qe{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Qe(this.arr)}splice(e){let r=new Qe(this.arr.slice(e));return this.arr=this.arr.slice(0,e),r}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,r){}delete(e){}gc(e){}write(e,r){let n=this.arr.length;e.writeLen(n-r);for(let s=r;s<n;s++){let i=this.arr[s];e.writeString(i===void 0?"undefined":JSON.stringify(i))}}getRef(){return 2}},tc=t=>{let e=t.readLen(),r=[];for(let n=0;n<e;n++){let s=t.readString();s==="undefined"?r.push(void 0):r.push(JSON.parse(s))}return new Zo(r)},ec=ne("node_env")==="development",he=class Ze{constructor(e){this.arr=e,ec&&En(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Ze(this.arr)}splice(e){let r=new Ze(this.arr.slice(e));return this.arr=this.arr.slice(0,e),r}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,r){}delete(e){}gc(e){}write(e,r){let n=this.arr.length;e.writeLen(n-r);for(let s=r;s<n;s++){let i=this.arr[s];e.writeAny(i)}}getRef(){return 8}},rc=t=>{let e=t.readLen(),r=[];for(let n=0;n<e;n++)r.push(t.readAny());return new he(r)},ct=class tr{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new tr(this.str)}splice(e){let r=new tr(this.str.slice(e));this.str=this.str.slice(0,e);let n=this.str.charCodeAt(e-1);return n>=55296&&n<=56319&&(this.str=this.str.slice(0,e-1)+"\uFFFD",r.str="\uFFFD"+r.str.slice(1)),r}mergeWith(e){return this.str+=e.str,!0}integrate(e,r){}delete(e){}gc(e){}write(e,r){e.writeString(r===0?this.str:this.str.slice(r))}getRef(){return 4}},nc=t=>new ct(t.readString()),sc=[Uo,No,Po,$o,Vo,Bo,Yo],ic=0,lc=1,oc=2,cc=3,ac=4,hc=5,uc=6,rt=class Fs{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new Fs(this.type._copy())}splice(e){throw $()}mergeWith(e){return!1}integrate(e,r){this.type._integrate(e.doc,r)}delete(e){let r=this.type._start;for(;r!==null;)r.deleted?r.id.clock<(e.beforeState.get(r.id.client)||0)&&e._mergeStructs.push(r):r.delete(e),r=r.right;this.type._map.forEach(n=>{n.deleted?n.id.clock<(e.beforeState.get(n.id.client)||0)&&e._mergeStructs.push(n):n.delete(e)}),e.changed.delete(this.type)}gc(e){let r=this.type._start;for(;r!==null;)r.gc(e,!0),r=r.right;this.type._start=null,this.type._map.forEach(n=>{for(;n!==null;)n.gc(e,!0),n=n.left}),this.type._map=new Map}write(e,r){this.type._write(e)}getRef(){return 7}},dc=t=>new rt(sc[t.readTypeRef()](t)),er=(t,e)=>{let r=e,n=0,s;do n>0&&(r=y(r.client,r.clock+n)),s=pt(t,r),n=r.clock-s.id.clock,r=s.redone;while(r!==null&&s instanceof S);return{item:s,diff:n}},Ur=(t,e)=>{for(;t!==null&&t.keep!==e;)t.keep=e,t=t.parent._item},ue=(t,e,r)=>{let{client:n,clock:s}=e.id,i=new S(y(n,s+r),e,y(n,s+r-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(r));return e.deleted&&i.markDeleted(),e.keep&&(i.keep=!0),e.redone!==null&&(i.redone=y(e.redone.client,e.redone.clock+r)),e.right=i,i.right!==null&&(i.right.left=i),t._mergeStructs.push(i),i.parentSub!==null&&i.right===null&&i.parent._map.set(i.parentSub,i),e.length=r,i},fn=(t,e)=>ir(t,r=>Jt(r.deletions,e)),Ps=(t,e,r,n,s,i)=>{let l=t.doc,o=l.store,c=l.clientID,u=e.redone;if(u!==null)return U(t,u);let a=e.parent._item,h=null,d;if(a!==null&&a.deleted===!0){if(a.redone===null&&(!r.has(a)||Ps(t,a,r,n,s,i)===null))return null;for(;a.redone!==null;)a=U(t,a.redone)}let g=a===null?e.parent:a.content.type;if(e.parentSub===null){for(h=e.left,d=e;h!==null;){let v=h;for(;v!==null&&v.parent._item!==a;)v=v.redone===null?null:U(t,v.redone);if(v!==null&&v.parent._item===a){h=v;break}h=h.left}for(;d!==null;){let v=d;for(;v!==null&&v.parent._item!==a;)v=v.redone===null?null:U(t,v.redone);if(v!==null&&v.parent._item===a){d=v;break}d=d.right}}else if(d=null,e.right&&!s){for(h=e;h!==null&&h.right!==null&&(h.right.redone||Jt(n,h.right.id)||fn(i.undoStack,h.right.id)||fn(i.redoStack,h.right.id));)for(h=h.right;h.redone;)h=U(t,h.redone);if(h&&h.right!==null)return null}else h=g._map.get(e.parentSub)||null;let f=E(o,c),m=y(c,f),N=new S(m,h,h&&h.lastId,d,d&&d.id,g,e.parentSub,e.content.copy());return e.redone=m,Ur(N,!0),N.integrate(t,0),N},S=class rr extends Or{constructor(e,r,n,s,i,l,o,c){super(e,c.getLength()),this.origin=n,this.left=r,this.right=s,this.rightOrigin=i,this.parent=l,this.parentSub=o,this.redone=null,this.content=c,this.info=this.content.isCountable()?2:0}set marker(e){(this.info&8)>0!==e&&(this.info^=8)}get marker(){return(this.info&8)>0}get keep(){return(this.info&1)>0}set keep(e){this.keep!==e&&(this.info^=1)}get countable(){return(this.info&2)>0}get deleted(){return(this.info&4)>0}set deleted(e){this.deleted!==e&&(this.info^=4)}markDeleted(){this.info|=4}getMissing(e,r){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=E(r,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=E(r,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===ft&&this.id.client!==this.parent.client&&this.parent.clock>=E(r,this.parent.client))return this.parent.client;if(this.origin&&(this.left=sn(e,r,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=U(e,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===F||this.right&&this.right.constructor===F)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===rr?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===rr&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===ft){let n=pt(r,this.parent);n.constructor===F?this.parent=null:this.parent=n.content.type}return null}integrate(e,r){if(r>0&&(this.id.clock+=r,this.left=sn(e,e.doc.store,y(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(r),this.length-=r),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let n=this.left,s;if(n!==null)s=n.right;else if(this.parentSub!==null)for(s=this.parent._map.get(this.parentSub)||null;s!==null&&s.left!==null;)s=s.left;else s=this.parent._start;let i=new Set,l=new Set;for(;s!==null&&s!==this.right;){if(l.add(s),i.add(s),Wt(this.origin,s.origin)){if(s.id.client<this.id.client)n=s,i.clear();else if(Wt(this.rightOrigin,s.rightOrigin))break}else if(s.origin!==null&&l.has(pt(e.doc.store,s.origin)))i.has(pt(e.doc.store,s.origin))||(n=s,i.clear());else break;s=s.right}this.left=n}if(this.left!==null){let n=this.left.right;this.right=n,this.left.right=this}else{let n;if(this.parentSub!==null)for(n=this.parent._map.get(this.parentSub)||null;n!==null&&n.left!==null;)n=n.left;else n=this.parent._start,this.parent._start=this;this.right=n}this.right!==null?this.right.left=this:this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(e)),this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),ds(e.doc.store,this),this.content.integrate(e,this),on(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new F(this.id,this.length).integrate(e,0)}get next(){let e=this.right;for(;e!==null&&e.deleted;)e=e.right;return e}get prev(){let e=this.left;for(;e!==null&&e.deleted;)e=e.left;return e}get lastId(){return this.length===1?this.id:y(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&Wt(e.origin,this.lastId)&&this.right===e&&Wt(this.rightOrigin,e.rightOrigin)&&this.id.client===e.id.client&&this.id.clock+this.length===e.id.clock&&this.deleted===e.deleted&&this.redone===null&&e.redone===null&&this.content.constructor===e.content.constructor&&this.content.mergeWith(e.content)){let r=this.parent._searchMarker;return r&&r.forEach(n=>{n.p===e&&(n.p=this,!this.deleted&&this.countable&&(n.index-=this.length))}),e.keep&&(this.keep=!0),this.right=e.right,this.right!==null&&(this.right.left=this),this.length+=e.length,!0}return!1}delete(e){if(!this.deleted){let r=this.parent;this.countable&&this.parentSub===null&&(r._length-=this.length),this.markDeleted(),Rt(e.deleteSet,this.id.client,this.id.clock,this.length),on(e,r,this.parentSub),this.content.delete(e)}}gc(e,r){if(!this.deleted)throw T();this.content.gc(e),r?go(e,this,new F(this.id,this.length)):this.content=new Ts(this.length)}write(e,r){let n=r>0?y(this.id.client,this.id.clock+r-1):this.origin,s=this.rightOrigin,i=this.parentSub,l=this.content.getRef()&31|(n===null?0:128)|(s===null?0:64)|(i===null?0:32);if(e.writeInfo(l),n!==null&&e.writeLeftID(n),s!==null&&e.writeRightID(s),n===null&&s===null){let o=this.parent;if(o._item!==void 0){let c=o._item;if(c===null){let u=as(o);e.writeParentInfo(!0),e.writeString(u)}else e.writeParentInfo(!1),e.writeLeftID(c.id)}else o.constructor===String?(e.writeParentInfo(!0),e.writeString(o)):o.constructor===ft?(e.writeParentInfo(!1),e.writeLeftID(o)):T();i!==null&&e.writeString(i)}this.content.write(e,r)}},Vs=(t,e)=>gc[e&31](t),gc=[()=>{T()},Go,tc,Ho,nc,Xo,Qo,dc,rc,qo,()=>{T()}],fc=10,j=class extends Or{get deleted(){return!0}delete(){}mergeWith(t){return this.constructor!==t.constructor?!1:(this.length+=t.length,!0)}integrate(t,e){T()}write(t,e){t.writeInfo(fc),w(t.restEncoder,this.length-e)}getMissing(t,e){return null}},$s=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},Js="__ $YJS$ __";$s[Js]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");$s[Js]=!0;var yh="page-local",bh="page-net",_h="page-seed",Sh=Vr,vh=Symbol("page-history"),Eh=Object.freeze(["flow","attrs","gone","boardFields","tableFields","origins"]),wc=new Set(["id","pos"]),Ch=t=>[...Object.keys(t.spec.attrs||{}).filter(e=>!wc.has(e)),...t.name==="table"?["rows"]:[]],Dh=(t,e)=>t.name==="table"&&e==="rows"?{}:t.spec.attrs[e].default,xh=(t,e)=>JSON.stringify(t)===JSON.stringify(e),Ah=t=>`${t.client}.${t.clock}`,Oh=t=>{let e=t.indexOf(".");return{client:+t.slice(0,e),clock:+t.slice(e+1)}},Ih=t=>t>=55296&&t<=56319,Mh=t=>t>=56320&&t<=57343,mc=0,Uh=t=>`${t.ydoc.clientID.toString(36)}-${(mc++).toString(36)}`,kc=0,Th=t=>`b${t.ydoc.clientID.toString(36)}${(kc++).toString(36)}`;function Nh(t=new Dt){return{ydoc:t,flow:t.getText("flow"),attrs:t.getMap("attrs"),gone:t.getMap("gone"),boardFields:t.getMap("boardFields"),tableFields:t.getMap("tableFields"),origins:t.getMap("origins")}}var yc=t=>t.split("!")[0].split("~")[0],zs=t=>t.includes("!"),Ph=t=>{let e={};for(let r of t)e[r.type.name]=r.attrs&&Object.keys(r.attrs).length?{...r.attrs}:!0;return e},Vh=t=>{let e={};for(let r of t){if(Nr(r)){for(let[n,s]of Object.entries(Rr(r.attrs.entries)))e[n]=JSON.parse(JSON.stringify(s));continue}e[r.type.name]=r.attrs&&Object.keys(r.attrs).length?{...r.attrs}:!0}return e},$h=t=>t.map(e=>e.type.name+(e.attrs&&Object.keys(e.attrs).length?JSON.stringify(e.attrs):"")).sort().join("|");function Jh(t,e){if(e==="code_block")return[];let r=new Map,n=new Set;for(let l of Object.keys(t))zs(l)&&t[l]&&n.add(l.split("!")[0]);for(let l of Object.keys(t).sort()){let o=t[l];o==null||zs(l)||n.has(l)||r.set(yc(l),o)}let s=[],i=null;for(let[l,o]of r)Ae.marks[l]&&(!Fr.has(l)||Pr(l,o))?s.push(Ae.marks[l].create(o===!0?null:o)):(i??={})[l]=o;if(i){let l=jr(i);l.length&&s.push(Lr(l))}return s}var nt=t=>Number.isSafeInteger(t)&&t>=0,J=t=>{throw new RangeError(t)},Bs=t=>(t!=="before"&&t!=="after"&&J(`Unknown affinity: ${t}`),t),Ws=(t,e,r)=>{let n=0,s=t.length;for(;n<s;){let i=n+s>>1;e(t[i])<=r?n=i+1:s=i}return n};function Bh(t,e){(!t||typeof t!="object"||!nt(t.tokens))&&J("A projection map needs a walk result with a token count"),nt(e)||J("A projection map needs a nonnegative physical length");let r=t.holes===void 0?[]:t.holes;Array.isArray(r)||J("A projection map needs the walk holes");let n=[],s=[],i=[0],l=0,o=0,c=-1,u=p=>{n.push({logicalStart:l,logicalLength:p,physicalStart:o,physicalLength:p,kind:"visible"}),l+=p,o+=p},a=p=>{let b=s[s.length-1];b&&b.at===l?(b.length+=p,b.end+=p,n[n.length-1].physicalLength+=p,i[i.length-1]+=p):(s.push({at:l,start:o,end:o+p,length:p}),n.push({logicalStart:l,logicalLength:0,physicalStart:o,physicalLength:p,kind:"hidden"}),i.push(i[i.length-1]+p)),o+=p};for(let p of r)(!p||typeof p!="object"||!nt(p.at)||!nt(p.len))&&J("Malformed walk hole"),p.at<c&&J("Walk holes are out of order"),p.at>t.tokens&&J("A walk hole sits past the logical length"),c=p.at,p.at>l&&u(p.at-l),p.len&&a(p.len);l<t.tokens&&u(t.tokens-l),o!==e&&J("Walk holes do not account for the physical length");let h=p=>Ws(s,b=>b.at,p),d=p=>Ws(s,b=>b.end,p),g=p=>p+i[h(p)],f=p=>{let b=s[h(p)-1];return b&&b.at===p?b:null},m=p=>{let b=s[d(p)];return b&&b.start<=p?b:null},N=(p,b)=>{let K=Bs(b);(!nt(p)||p>t.tokens)&&J(`Logical position ${p} is outside the map`);let H=f(p);return H?K==="before"?H.start:H.end:g(p)},v=(p,b)=>{Bs(b),(!nt(p)||p>e)&&J(`Physical position ${p} is outside the flow`);let K=m(p);return K?K.at:p-i[d(p)]},Bt=(p,b)=>{(!nt(p)||!nt(b)||p>t.tokens||b>t.tokens)&&J(`Logical range ${p}..${b} is outside the map`);let K=[];if(b<=p)return K;let H=g(p);for(let At of s)if(!(At.at<=p)){if(At.at>b)break;At.start>H&&K.push([H,At.start]),H=At.end}let Tr=g(b);return Tr>H&&K.push([H,Tr]),K};return{segments:n,logicalLength:t.tokens,physicalLength:e,toPhysical:N,toLogical:v,physicalRanges:Bt}}export{Oc as a,Ic as b,_t as c,Bl as d,ta as e,Dt as f,Ql as g,ea as h,ls as i,ra as j,na as k,sa as l,ia as m,la as n,pt as o,ca as p,aa as q,oe as r,Dr as s,zt as t,O as u,ct as v,S as w,yh as x,bh as y,_h as z,Sh as A,vh as B,Eh as C,Ch as D,Dh as E,xh as F,Ah as G,Oh as H,Ih as I,Mh as J,Uh as K,Th as L,Nh as M,yc as N,zs as O,Ph as P,Vh as Q,$h as R,Jh as S,Bh as T};
@@ -1 +0,0 @@
1
- import{e as b,f as c,g as d,h as e,i as f,j as g,k as h,l as i,m as j,n as k,o as l,p as m,q as n}from"./c-OIBUTDXI.js";import{a}from"./c-4JZDZFF6.js";import"./c-VAK7SG37.js";import"./c-NUHP2XDB.js";import"./c-VHNSBD2M.js";export{b as RUNTIME_ONLY,g as bevelBox,d as bevelButton,f as bevelCornerClose,e as bevelIconButton,m as bevelInput,i as bevelSurface,k as bevelText,j as bevelWell,a as pageScheme,l as paintInput,c as protectIcon,h as restyleBox,n as setShown};
@@ -1 +0,0 @@
1
- import{A as b,d as h,g as L}from"./c-5J4E7O4Y.js";import{I as x,b as z,d as T,l as B,m as P}from"./c-WWXIDH4O.js";var C=new WeakMap;var{Plugin:Y,PluginKey:H}=z,{Decoration:_,DecorationSet:K}=T,E=P.nodes,f=new H("page-media"),A=1.5*1024*1024,ce=new Set(["timeout","network","error","bad-response"]),m=new WeakMap,M=(e,o)=>{let a=e.resolve(Math.max(0,Math.min(o,e.content.size)));return a.depth===0?a.pos:a.after(1)};function D(e,o){let a=L(e.doc),r=a[Math.min(o,a.length-1)],t=r.node.type===E.paragraph&&r.node.content.size===0;return{hostId:r.node.attrs.id,at:t?r.at:a[r.subEnd].end,parent:r.node.attrs.parent??null,replaceId:t?r.node.attrs.id:null}}var W={init:()=>({items:[],placed:{},picker:null}),apply(e,o){let{items:a,placed:r,picker:t}=o;if(e.docChanged&&(a=a.map(n=>({...n,pos:M(e.doc,e.mapping.map(n.pos,-1))}))),t&&e.docChanged&&(t={...t,place:{...t.place,at:M(e.doc,e.mapping.map(t.place.at,-1))}},t.remove)){let n=e.mapping.map(t.remove.from,1),c=e.mapping.map(t.remove.to,-1);t=n<=c&&e.doc.textBetween(n,c)===t.remove.text?{...t,remove:{...t.remove,from:n,to:c}}:null}let s=e.getMeta(f);if(s?.picker!==void 0&&(t=s.picker),s?.add&&(a=[...a,...s.add]),s?.update&&(a=a.map(n=>n.id===s.update.id?{...n,...s.update}:n)),s?.placed){let{id:n,at:c,size:d,blockId:p}=s.placed,l=o.items.find(i=>i.id===n);a=a.filter(i=>i.id!==n).map(i=>l&&i.pos===c&&i.group===l.group&&i.order>l.order?{...i,pos:i.pos+d}:i),l&&(r={...r,[l.group]:[...r[l.group]||[],p]})}s?.remove&&(a=a.filter(n=>n.id!==s.remove));for(let n of Object.keys(r))a.some(c=>c.group===n)||(r={...r},delete r[n]);return{items:a,placed:r,picker:t}}};function O(e,o,a){if(!o)return;let r=null,t=null;e.doc.forEach((s,n)=>{s.attrs.id===o&&r&&a.includes(r.attrs.id)&&(t={n:s,off:n}),r=s}),t&&t.n.type===E.paragraph&&t.n.content.size===0&&e.delete(t.off,t.off+t.n.nodeSize)}function j(e,o,a){let{items:r,placed:t}=f.getState(e),s=r.find(l=>l.id===o);if(!s)return null;let n=M(e.doc,s.pos),c=x(),d=(s.kind==="image"?E.image:E.file).create({...a,id:c,pos:null,parent:s.parent}),p=e.tr.insert(n,d);return r.some(l=>l.group===s.group&&l.id!==o)||O(p,s.replaceId,[...t[s.group]||[],c]),b(p).setMeta(f,{placed:{id:o,at:n,size:d.nodeSize,blockId:c}})}function F(e,o){let{items:a,placed:r}=f.getState(e),t=a.find(n=>n.id===o);if(!t)return null;let s=e.tr;return a.some(n=>n.group===t.group&&n.id!==o)||O(s,t.replaceId,r[t.group]||[]),s.docChanged&&b(s),s.setMeta(f,{remove:o})}function R(e,o,a=D(e.state,e.state.selection.$head.index(0))){if(o=[...o].filter(Boolean),!o.length)return!1;let r=x("g"),t=o.map((s,n)=>{let c=/^image\//.test(s.type||"")?"image":"file";return{id:x("u"),pos:a.at,group:r,order:n,file:s,kind:c,name:s.name||(c==="image"?"image":"file"),parent:a.parent,replaceId:a.replaceId,state:"uploading",percent:0,preview:c==="image"&&globalThis.URL?.createObjectURL?URL.createObjectURL(s):null}});e.dispatch(e.state.tr.setMeta(f,{add:t}));for(let s of t)V(e,s);return h(e,o.length===1?`Uploading ${t[0].name}`:`Uploading ${o.length} files`),!0}var g=(e,o)=>f.getState(e.state).items.find(a=>a.id===o),y=(e,o,a)=>e.dispatch(e.state.tr.setMeta(f,{update:{id:o,...a}})),X=e=>new Promise((o,a)=>{let r=new FileReader;r.onload=()=>o(r.result),r.onerror=()=>a(r.error),r.readAsDataURL(e)}),N=(e,o)=>e.kind==="image"?{src:o,alt:"",caption:""}:{src:o,name:e.name,size:e.file.size??null,mime:e.file.type||null};function $(e,o,a){e.preview&&URL.revokeObjectURL?.(e.preview),a&&o.dispatch(a)}async function V(e,o){let a=m.get(e),r=new AbortController;a.aborts.set(o.id,r);let t=-5,s=({percent:d})=>{d-t<5&&d!==100||(t=d,m.has(e)&&g(e,o.id)&&y(e,o.id,{percent:d}))},n;try{n=await a.upload(o.file,{onProgress:s,signal:r.signal})}catch{n={code:"network",msg:"Upload failed"}}if(a.aborts.delete(o.id),!m.has(e)||!g(e,o.id))return;if(n?.ok){let d=B(n.uploads?.[0]?.url);if(d){$(o,e,j(e.state,o.id,N(o,d))),h(e,`${o.name} added`);return}n={code:"bad-response",msg:"The upload returned an invalid address"}}if((!n||typeof n!="object")&&(n={code:"bad-response",msg:"The upload returned an invalid response"}),n.code==="aborted")return $(o,e,F(e.state,o.id));if(n.code==="unsupported"){let d=/^image\/(png|jpeg|gif|webp)$/i.test(o.file.type)&&o.file.size<=A,p=d?"This host doesn't store files. You can keep this image inside the document, which makes the document larger.":o.kind==="image"&&o.file.size>A?"This host doesn't store files, and this image is over 1.5 MB, too large to keep inside the document.":"This host doesn't store files.";y(e,o.id,{state:d?"embed-choice":"error",code:n.code,message:p}),h(e,`${o.name}: ${p}`);return}let c=n.code==="timeout"?"The upload timed out. It may have arrived; trying again is safe.":n.msg||"Upload failed";y(e,o.id,{state:"error",code:n.code,message:c}),h(e,`${o.name}: ${c}`)}async function q(e,o){let a=g(e,o);if(!a||a.state!=="embed-choice")return;let r=await X(a.file);!m.has(e)||!g(e,o)||($(a,e,j(e.state,o,N(a,r))),h(e,"Saved inside the document"))}function G(e,o){g(e,o)&&(y(e,o,{state:"uploading",percent:0,code:null,message:null}),V(e,g(e,o)))}function J(e,o){let a=m.get(e),r=a?.aborts.get(o),t=g(e,o);t&&$(t,e,F(e.state,o)),a?.aborts.delete(o),r?.abort()}var Q=e=>e.replace(/<(meta|style|img)\b[^>]*>/gi,"").replace(/<[^>]+>/g,"").trim()!=="";function de({upload:e,features:o=null}){let a=null,r=t=>{!o||o.has("media")||!m.has(t)||o.ensure("media").catch(()=>{})};return new Y({key:f,state:W,view(t){a=t;let n=t.dom.ownerDocument.createElement("input");n.type="file",n.multiple=!0,n.hidden=!0,n.className="page-file-input",t.dom.parentElement.append(n),m.set(t,{upload:e,aborts:new Map,input:n}),n.addEventListener("change",()=>{let d=[...n.files??[]],p=f.getState(t.state).picker;if(t.dispatch(t.state.tr.setMeta(f,{picker:null})),d.length&&p){let{remove:l}=p;l&&t.state.doc.textBetween(l.from,l.to)===l.text&&t.dispatch(b(t.state.tr.delete(l.from,l.to)));let i=U(t.state.doc,p.place.hostId);(!p.place.hostId||i>=0)&&(R(t,d,i>=0?D(t.state,i):p.place),r(t))}n.value="",t.focus()}),n.addEventListener("cancel",()=>t.dispatch(t.state.tr.setMeta(f,{picker:null})));let c=d=>{let p=d.target.closest?.(".page-upload-btn");if(!p)return;d.preventDefault();let l=p.dataset.upload;p.dataset.act==="retry"?G(t,l):p.dataset.act==="embed"?q(t,l):J(t,l)};return t.dom.addEventListener("click",c),{destroy(){t.dom.removeEventListener("click",c),a===t&&(a=null);let d=m.get(t);m.delete(t);for(let p of f.getState(t.state).items)p.preview&&URL.revokeObjectURL?.(p.preview);for(let p of d.aborts.values())p.abort();n.remove()}}},props:{decorations(t){let{items:s}=f.getState(t),n=a?C.get(a):null;return!s.length||!n?null:K.create(t.doc,s.map(c=>_.widget(M(t.doc,c.pos),d=>n(d.dom.ownerDocument,c),{side:-1e3+c.order,key:`${c.id}:${c.state}:${c.percent}`,stopEvent:()=>!0,ignoreSelection:!0})))},handlePaste(t,s){let n=s.clipboardData,c=[...n?.files??[]];if(!c.length||t.state.selection.$from.parent.type.spec.code||Q(n.getData("text/html")||""))return!1;let d=D(t.state,t.state.selection.$head.index(0));return s.preventDefault(),R(t,c,d),r(t),!0},handleDrop(t,s,n,c){let d=[...s.dataTransfer?.files??[]];if(c||!d.length)return!1;let p=t.posAtCoords({left:s.clientX,top:s.clientY});if(!p)return!1;let l=L(t.state.doc),i=Math.min(t.state.doc.resolve(p.pos).index(0),l.length-1),u=t.nodeDOM(l[i].at)?.getBoundingClientRect?.(),S=u&&s.clientY<u.top+u.height/2;s.preventDefault();let k={at:S?l[i].at:l[l[i].subEnd].end,parent:l[i].node.attrs.parent??null,replaceId:null};return R(t,d,k),r(t),!0}}})}function le(e,o,a=D(e.state,e.state.selection.$head.index(0)),r=null){let t=m.get(e);if(!t)return!1;let s={place:a,remove:r&&{...r,text:e.state.doc.textBetween(r.from,r.to)}};return e.dispatch(e.state.tr.setMeta(f,{picker:s})),t.input.accept=o,t.input.click(),!0}var U=(e,o)=>{let a=-1;return e.forEach((r,t,s)=>{r.attrs.id===o&&(a=s)}),a};function Z(e,o,a){let r=e.state,t=U(r.doc,o);if(t<0)return!1;let s=0;for(let c=0;c<t;c++)s+=r.doc.child(c).nodeSize;let n=r.doc.child(t);return e.dispatch(b(r.tr.setNodeMarkup(s,null,{...n.attrs,...a}))),!0}function pe(e,o){let a=U(e.state.doc,o);if(a<0)return!1;let r=e.dom.parentElement,t=r.ownerDocument,s=0;for(let u=0;u<a;u++)s+=e.state.doc.child(u).nodeSize;let n=t.createElement("div");n.className="page-link",n.dataset.mode="alt";let c=t.createElement("input");c.className="page-link-input",c.type="text",c.value=e.state.doc.child(a).attrs.alt||"",c.placeholder="Describe the image",c.setAttribute("aria-label","Alt text"),n.append(c);let d=e.nodeDOM(s)?.getBoundingClientRect?.(),p=r.getBoundingClientRect();d&&(n.style.setProperty("--page-pop-x",`${d.left-p.left}px`),n.style.setProperty("--page-pop-y",`${d.bottom-p.top+6}px`)),r.append(n);let l=!1,i=(u,S=!0)=>{if(l)return;l=!0;let k=c.value.trim();n.remove();let I=U(e.state.doc,o);u&&I>=0&&k!==e.state.doc.child(I).attrs.alt&&Z(e,o,{alt:k}),S&&e.focus()};return c.addEventListener("keydown",u=>{u.key==="Enter"?(u.preventDefault(),i(!0)):u.key==="Escape"&&(u.preventDefault(),u.stopPropagation(),i(!1))}),c.addEventListener("blur",()=>i(!0,!1)),c.focus(),!0}export{C as a,ce as b,D as c,de as d,le as e,Z as f,pe as g};
@@ -1 +0,0 @@
1
- import{d as t,e as o}from"./c-W5MCHEGA.js";import"./c-3H6BZDNJ.js";import"./c-4DFEJ2PO.js";import"./c-6CRUUXOX.js";import{e}from"./c-336SGU5W.js";import"./c-6KEVEQ7L.js";import"./c-5J4E7O4Y.js";import"./c-WWXIDH4O.js";import"./c-4L3BTFRK.js";import"./c-5V3MOVJT.js";import"./c-VHNSBD2M.js";function c({view:r=null}={}){let a=r?e(r,{update:o}):()=>{};return{id:"chart",nodeViews:{chart:(i,n,d)=>new t(i,n,d)},dispose(){a()}}}export{c as createFeature};
@@ -1 +0,0 @@
1
- import{c as A}from"./c-KBS3UV6B.js";import{l as b}from"./c-3H6BZDNJ.js";import"./c-4DFEJ2PO.js";import"./c-6CRUUXOX.js";import"./c-336SGU5W.js";import"./c-6KEVEQ7L.js";import{A as x}from"./c-5J4E7O4Y.js";import{b as h}from"./c-WWXIDH4O.js";import"./c-4L3BTFRK.js";import"./c-5V3MOVJT.js";import"./c-VHNSBD2M.js";function S(o){let s=String(o??""),n=typeof Intl<"u"&&typeof Intl.Segmenter=="function"?new Intl.Segmenter("en",{granularity:"grapheme"}):null;return n?[...n.segment(s)].map(a=>a.segment):[...s]}var I=o=>S(o).length===1&&!/^\s*$/.test(String(o??""));function L(o){let s=[];for(let[n,a]of Object.entries(o??{}))for(let u of Array.isArray(a)?a:[]){let[f,m,d=""]=u??[];typeof f!="string"||typeof m!="string"||s.push({id:`${n}:${m}`,char:f,name:`${f} ${m}`,keywords:`${m} ${d}`})}return s}var P=(o,s)=>{let n=String(s??"").trim().toLowerCase();return n?o.filter(a=>a.char===n||a.keywords.toLowerCase().includes(n)):o};function T(o=()=>import("./c-SZGYW5HT.js")){let s=null;return()=>(s??=Promise.resolve().then(()=>o()).then(n=>L(n.EMOJI)).catch(n=>{throw s=null,n}),s)}function w({view:o=null,load:s=()=>import("./c-SZGYW5HT.js")}={}){if(!o)return{run:()=>({ok:!1,code:"not-editing"}),dispose(){}};let n=o.dom.ownerDocument,a=T(s),u=null;function f(t){let e=o.state,r=e.selection;if(r.from!==t.from||r.to!==t.to||t.from<0||t.to>e.doc.content.size)return null;let c=e.doc.resolve(t.from),i=e.doc.resolve(t.to);return!c.parent.isTextblock||c.parent!==i.parent?null:{from:t.from,to:t.to}}function m(t){try{let e=o.dom.parentElement?.getBoundingClientRect?.()??{left:0,top:0},r=o.coordsAtPos(t.from);return{x:Math.max(8,r.left-e.left),y:r.bottom+6-e.top}}catch{return null}}function d(t){let e=t.picker.activeId();e?o.dom.setAttribute("aria-activedescendant",e):o.dom.getAttribute("aria-activedescendant")?.startsWith(t.picker.el.id)&&o.dom.removeAttribute("aria-activedescendant")}function l(){let t=u;if(t){u=null;for(let[e,r,c,i]of t.listen)e.removeEventListener(r,c,i);o.dom.getAttribute("aria-activedescendant")?.startsWith(`${t.picker.el.id}-`)&&o.dom.removeAttribute("aria-activedescendant"),t.picker.destroy()}}function j(t,e){let r=o.state.tr.insertText(e,t.from,t.to);return r.setSelection(h.TextSelection.create(r.doc,t.from+e.length)),o.dispatch(x(r)),o.focus(),{ok:!0,emoji:e}}function p(t){let e=u;if(!e)return{ok:!1,code:"not-editing"};let r=e.picker.personAt(t),c=f(e);return!r||c===null||!I(r.char)?(l(),r?c===null?{ok:!1,code:"stale-target"}:{ok:!1,code:"invalid-emoji"}:{ok:!1,code:"no-emoji"}):(l(),j(c,r.char))}function E(t){let e=u;if(!e||b(t,o))return;let r=()=>{t.preventDefault(),t.stopPropagation()};t.key==="ArrowDown"||t.key==="ArrowUp"?(r(),e.picker.move(t.key==="ArrowDown"?1:-1),d(e)):t.key==="Enter"?(r(),p(e.picker.index())):(t.key==="Escape"||t.key==="Tab")&&(r(),l())}async function $(t={}){l();let e={from:o.state.selection.from,to:o.state.selection.to,picker:null,listen:[]};e.picker=A({document:n,label:"Insert an emoji",empty:"No emoji found",onPick:i=>p(i)}),u=e;let r=(i,k,g,y)=>{i.addEventListener(k,g,y),e.listen.push([i,k,g,y])};r(n,"keydown",i=>E(i),!0),r(o.dom,"input",()=>l()),r(n,"mousedown",i=>{e.picker.el.contains(i.target)||l()},!0),(o.dom.parentElement??n.body).appendChild(e.picker.el);let c;try{c=await a()}catch(i){return l(),{ok:!1,code:"unavailable",error:i}}return u!==e?{ok:!1,code:"not-editing"}:f(e)===null?(l(),{ok:!1,code:"stale-target"}):(e.picker.show(P(c,t?.query),m(e)),d(e),{ok:!0,picker:!0})}return{async run(t){return $(t)},dispose(){l()}}}export{w as createFeature,L as emojiEntries,T as emojiLibrary,P as filterEmoji,S as graphemes,I as isEmojiText};
@@ -1 +0,0 @@
1
- var m="clay:bottom-ui-changed";function d(){document.dispatchEvent(new CustomEvent(m))}function l(n,o){let t=window.innerHeight,i=0,u=document.elementsFromPoint?document.elementsFromPoint(n,t-3):[];for(let h of u)for(let e=h;e&&e!==document.body&&e!==document.documentElement&&!o(e);e=e.parentElement){let c=getComputedStyle(e).position;if(c==="fixed"||c==="sticky"){let r=Math.ceil(t-e.getBoundingClientRect().top);r<t/3&&(i=Math.max(i,r));break}}return i}function s(n){let o=document.querySelector("#hcp:not([hidden])");if(!o)return 0;let t=o.getBoundingClientRect();return!t.width||!t.height||t.right<=n.left||t.left>=n.right?0:Math.ceil(window.innerHeight-t.top)}export{m as a,d as b,l as c,s as d};
@@ -1 +0,0 @@
1
- import{a as l}from"./c-74MGYWZF.js";import{f as n}from"./c-GFJJEBTU.js";import{b as h,c as a}from"./c-BWFVSBDF.js";import"./c-N326R2JD.js";import{b as E,g as T}from"./c-NUFFJVVJ.js";import{b as p}from"./c-RYUXUUBX.js";import{b as w}from"./c-HHDFCNHV.js";import"./c-XCNTK76U.js";import"./c-VKEDWYDF.js";import{A as y,B as k,J as g,L as v,P as b,q as d,r as f,x as m}from"./c-TCJTVAFN.js";import"./c-GQ6F6IDK.js";import"./c-2SPVQSHC.js";import"./c-5VYOWDTI.js";import"./c-QJ4OM3G6.js";import"./c-MKSQ4Y57.js";import"./c-WYFDLITL.js";import"./c-UGHH4MB3.js";import"./c-ZWIOJGMT.js";import"./c-LWLBHLVC.js";import"./c-SDAXDM2D.js";import"./c-TQEMVJCS.js";import"./c-DCXOXBF3.js";import"./c-VRZN56XY.js";import"./c-IJUK2GPW.js";import"./c-OW5QIGG3.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-N7JPUPGC.js";import"./c-SPIORRYS.js";import"./c-XQXZAO7N.js";import"./c-S7LK4KUE.js";import"./c-VG5XIN4T.js";import"./c-2YYDMLNZ.js";import"./c-HA6INT6J.js";import"./c-DCFSEJZG.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var x=250,A=2e3,u=["focusin","focusout","selectionchange","clay:sync-applied","clay:workspace-background","clay:workspace-foreground"],S=s=>n.setGeneric(s),o=class{constructor({send:t=S,now:i=()=>Date.now()}){this.send=t,this.now=i,this.others=!1,this.background=!1,this.sent=null,this.lastAt=-1/0,this.timer=null,this.poked=null,this.inflight=!1,this.retry=null,this.stopped=!1,this._onEvent=e=>{e.type==="clay:workspace-background"&&(this.background=!0),e.type==="clay:workspace-foreground"&&(this.background=!1),this.poke()}}start(){this.stopped=!1;for(let t of u)document.addEventListener(t,this._onEvent)}stop(){this.stopped=!0;for(let t of u)document.removeEventListener(t,this._onEvent);clearTimeout(this.timer),clearTimeout(this.poked),clearTimeout(this.retry),this.timer=null,this.poked=null,this.retry=null}roster(t){let e=(t&&Array.isArray(t.people)?t.people:[]).some(r=>r&&r.you!==!0);e!==this.others&&(this.others=e,this.schedule())}reconnected(){this.sent=null,this.schedule()}wanted(){return!this.others||this.background?null:a(h(document.activeElement))}poke(){this.poked===null&&(this.poked=setTimeout(()=>{this.poked=null,this.schedule()},0))}schedule(){if(this.stopped||this.timer!==null||this.inflight||this.wanted()===this.sent)return;let t=Math.max(0,this.lastAt+x-this.now());this.timer=setTimeout(()=>{this.timer=null,this.flush()},t)}flush(){if(this.inflight)return;let t=this.wanted();if(t===this.sent)return;this.sent=t,this.lastAt=this.now(),this.inflight=!0;let i=e=>{if(this.inflight=!1,!this.stopped){if(e)clearTimeout(this.retry),this.retry=null;else if(this.sent===t){this.sent=void 0,this.retry===null&&(this.retry=setTimeout(()=>{this.retry=null,this.schedule()},A));return}this.schedule()}};Promise.resolve(this.send(t)).then(e=>i(!!e),()=>i(!1))}};function I(s){let t=()=>(n.setGeneric(null),n.releaseTarget(),s.lane==="live"&&s._morphInFlight?{ok:!1,code:"pending-input"}:{ok:!0}),i=()=>s.stop();return{id:"clay:sync",order:50,async prepare(e){if(await l(),e?.initial)return{quiesce:t,dispose:i};let r=!1;return{quiesce:t,enable(){let c=s.currentFile;s.stop(),s.start(c,{lane:"live"}),r=!0},dispose:()=>{r&&s.stop()}}}}}export{o as EditingSender,g as baselineSettled,f as conflictResolvedBySync,T as enableAdminInputs,p as enableAdminResources,w as enableContentEditable,E as enableOnClick,y as getLastSavedBytes,d as isSaveConflicted,b as savePageThrottled,v as schedulePaintHeal,k as setLastSavedBaselines,m as setUnsavedChanges,I as syncParticipant};
@@ -1 +0,0 @@
1
- import"./c-SWLRT66R.js";import{a as c,c as o,e as n,g as i}from"./c-SDAXDM2D.js";import"./c-TQEMVJCS.js";import{f as a}from"./c-VRZN56XY.js";import"./c-OW5QIGG3.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-N7JPUPGC.js";import"./c-HA6INT6J.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var u="page-format-activation-failed";function d(){let e=document.querySelector(`meta[name="${c}"]`);return e?n(e.outerHTML):0}var p=async e=>(await import("./core/save-HQZ4S667.js")).savePageForce(()=>{},e);function g({save:e=p,supported:s=()=>a().then(r=>r===1)}={}){return{read(){return{floor:Math.max(i(),d()),revision:null}},capabilities(){return[]},supported:s,async activate({floor:r=1}={}){let t;try{t=await e({pageFormatFloor:r})}catch(m){return{accepted:!1,code:m?.code??u}}return t?.ok?{accepted:!0,revision:null,receipt:t.receipt??t.etag??null}:t?.code===o?{accepted:!1,code:o}:{accepted:!1,code:t?.code??u}}}}export{g as createFormatHost};