kritzel-stencil 0.0.172 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (403) hide show
  1. package/dist/cjs/app-globals-V2Kpy_OQ.js +0 -3
  2. package/dist/cjs/{default-line-tool.config-JuTDR6PF.js → default-line-tool.config-7eJND6Jb.js} +1516 -206
  3. package/dist/cjs/index-BeKMS-Zt.js +3280 -0
  4. package/dist/cjs/index.cjs.js +10 -7
  5. package/dist/cjs/kritzel-brush-style.cjs.entry.js +3 -4
  6. package/dist/cjs/kritzel-color_22.cjs.entry.js +103 -66
  7. package/dist/cjs/loader.cjs.js +2 -3
  8. package/dist/cjs/stencil.cjs.js +3 -4
  9. package/dist/collection/classes/core/core.class.js +0 -1
  10. package/dist/collection/classes/core/reviver.class.js +0 -1
  11. package/dist/collection/classes/core/store.class.js +0 -1
  12. package/dist/collection/classes/core/viewport.class.js +0 -1
  13. package/dist/collection/classes/core/workspace.class.js +0 -1
  14. package/dist/collection/classes/handlers/base.handler.js +0 -1
  15. package/dist/collection/classes/handlers/context-menu.handler.js +0 -1
  16. package/dist/collection/classes/handlers/hover.handler.js +0 -1
  17. package/dist/collection/classes/handlers/key.handler.js +0 -1
  18. package/dist/collection/classes/handlers/line-handle.handler.js +0 -1
  19. package/dist/collection/classes/handlers/move.handler.js +0 -1
  20. package/dist/collection/classes/handlers/resize.handler.js +0 -1
  21. package/dist/collection/classes/handlers/rotation.handler.js +0 -1
  22. package/dist/collection/classes/handlers/selection.handler.js +0 -1
  23. package/dist/collection/classes/managers/anchor.manager.js +0 -1
  24. package/dist/collection/classes/managers/cursor.manager.js +0 -1
  25. package/dist/collection/classes/objects/base-object.class.js +0 -1
  26. package/dist/collection/classes/objects/custom-element.class.js +0 -1
  27. package/dist/collection/classes/objects/group.class.js +0 -1
  28. package/dist/collection/classes/objects/image.class.js +0 -1
  29. package/dist/collection/classes/objects/line.class.js +0 -1
  30. package/dist/collection/classes/objects/path.class.js +0 -1
  31. package/dist/collection/classes/objects/selection-box.class.js +0 -1
  32. package/dist/collection/classes/objects/selection-group.class.js +0 -1
  33. package/dist/collection/classes/objects/shape.class.js +0 -1
  34. package/dist/collection/classes/objects/text.class.js +0 -1
  35. package/dist/collection/classes/providers/broadcast-sync-provider.class.js +0 -1
  36. package/dist/collection/classes/providers/hocuspocus-sync-provider.class.js +0 -1
  37. package/dist/collection/classes/providers/indexeddb-sync-provider.class.js +0 -1
  38. package/dist/collection/classes/providers/websocket-sync-provider.class.js +0 -1
  39. package/dist/collection/classes/registries/icon-registry.class.js +0 -1
  40. package/dist/collection/classes/registries/tool.registry.js +0 -1
  41. package/dist/collection/classes/structures/app-state-map.structure.js +0 -1
  42. package/dist/collection/classes/structures/object-map.structure.js +0 -1
  43. package/dist/collection/classes/structures/quadtree.structure.js +0 -1
  44. package/dist/collection/classes/tools/base-tool.class.js +0 -1
  45. package/dist/collection/classes/tools/brush-tool.class.js +0 -1
  46. package/dist/collection/classes/tools/eraser-tool.class.js +0 -1
  47. package/dist/collection/classes/tools/image-tool.class.js +0 -1
  48. package/dist/collection/classes/tools/line-tool.class.js +0 -1
  49. package/dist/collection/classes/tools/selection-tool.class.js +0 -1
  50. package/dist/collection/classes/tools/shape-tool.class.js +0 -1
  51. package/dist/collection/classes/tools/text-tool.class.js +0 -1
  52. package/dist/collection/collection-manifest.json +2 -2
  53. package/dist/collection/components/core/kritzel-cursor-trail/kritzel-cursor-trail.js +0 -1
  54. package/dist/collection/components/core/kritzel-editor/kritzel-editor.js +1 -2
  55. package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +3 -4
  56. package/dist/collection/components/shared/kritzel-brush-style/kritzel-brush-style.js +0 -1
  57. package/dist/collection/components/shared/kritzel-color/kritzel-color.js +0 -1
  58. package/dist/collection/components/shared/kritzel-color-palette/kritzel-color-palette.js +8 -3
  59. package/dist/collection/components/shared/kritzel-dropdown/kritzel-dropdown.css +8 -20
  60. package/dist/collection/components/shared/kritzel-dropdown/kritzel-dropdown.js +1 -2
  61. package/dist/collection/components/shared/kritzel-font/kritzel-font.js +0 -1
  62. package/dist/collection/components/shared/kritzel-font-family/kritzel-font-family.js +0 -1
  63. package/dist/collection/components/shared/kritzel-font-size/kritzel-font-size.js +8 -3
  64. package/dist/collection/components/shared/kritzel-icon/kritzel-icon.js +0 -1
  65. package/dist/collection/components/shared/kritzel-menu/kritzel-menu.js +0 -1
  66. package/dist/collection/components/shared/kritzel-menu-item/kritzel-menu-item.js +0 -1
  67. package/dist/collection/components/shared/kritzel-portal/kritzel-portal.js +0 -1
  68. package/dist/collection/components/shared/kritzel-split-button/kritzel-split-button.js +0 -1
  69. package/dist/collection/components/shared/kritzel-stroke-size/kritzel-stroke-size.js +0 -1
  70. package/dist/collection/components/shared/kritzel-tooltip/kritzel-tooltip.js +0 -1
  71. package/dist/collection/components/ui/kritzel-context-menu/kritzel-context-menu.js +0 -1
  72. package/dist/collection/components/ui/kritzel-control-brush-config/kritzel-control-brush-config.js +0 -1
  73. package/dist/collection/components/ui/kritzel-control-text-config/kritzel-control-text-config.js +1 -2
  74. package/dist/collection/components/ui/kritzel-controls/kritzel-controls.js +0 -1
  75. package/dist/collection/components/ui/kritzel-utility-panel/kritzel-utility-panel.js +0 -1
  76. package/dist/collection/components/ui/kritzel-workspace-manager/kritzel-workspace-manager.js +0 -1
  77. package/dist/collection/configs/default-brush-tool.config.js +0 -1
  78. package/dist/collection/configs/default-engine-config.js +0 -1
  79. package/dist/collection/configs/default-line-tool.config.js +0 -1
  80. package/dist/collection/configs/default-shape-tool.config.js +0 -1
  81. package/dist/collection/configs/default-sync.config.js +0 -1
  82. package/dist/collection/configs/default-text-tool.config.js +0 -1
  83. package/dist/collection/constants/core.constants.js +0 -1
  84. package/dist/collection/constants/engine.constants.js +0 -1
  85. package/dist/collection/enums/event-button.enum.js +0 -1
  86. package/dist/collection/enums/handle-type.enum.js +0 -1
  87. package/dist/collection/enums/shape-type.enum.js +0 -1
  88. package/dist/collection/helpers/class.helper.js +0 -1
  89. package/dist/collection/helpers/cursor.helper.js +0 -1
  90. package/dist/collection/helpers/devices.helper.js +0 -1
  91. package/dist/collection/helpers/event.helper.js +0 -1
  92. package/dist/collection/helpers/geometry.helper.js +0 -1
  93. package/dist/collection/helpers/html.helper.js +0 -1
  94. package/dist/collection/helpers/keyboard.helper.js +0 -1
  95. package/dist/collection/helpers/math.helper.js +0 -1
  96. package/dist/collection/helpers/object.helper.js +0 -1
  97. package/dist/collection/index.js +0 -1
  98. package/dist/collection/interfaces/anchor.interface.js +0 -1
  99. package/dist/collection/interfaces/arrow-head.interface.js +0 -1
  100. package/dist/collection/interfaces/bounding-box.interface.js +0 -1
  101. package/dist/collection/interfaces/clonable.interface.js +0 -1
  102. package/dist/collection/interfaces/context-menu-item.interface.js +0 -1
  103. package/dist/collection/interfaces/debug-info.interface.js +0 -1
  104. package/dist/collection/interfaces/engine-state.interface.js +0 -1
  105. package/dist/collection/interfaces/line-options.interface.js +0 -1
  106. package/dist/collection/interfaces/menu-item.interface.js +0 -1
  107. package/dist/collection/interfaces/object.interface.js +0 -1
  108. package/dist/collection/interfaces/path-options.interface.js +0 -1
  109. package/dist/collection/interfaces/point.interface.js +0 -1
  110. package/dist/collection/interfaces/polygon.interface.js +0 -1
  111. package/dist/collection/interfaces/selection-state.interface.js +0 -1
  112. package/dist/collection/interfaces/serializable.interface.js +0 -1
  113. package/dist/collection/interfaces/shortcut.interface.js +0 -1
  114. package/dist/collection/interfaces/sync-config.interface.js +0 -1
  115. package/dist/collection/interfaces/sync-provider.interface.js +0 -1
  116. package/dist/collection/interfaces/tool.interface.js +0 -1
  117. package/dist/collection/interfaces/toolbar-control.interface.js +0 -1
  118. package/dist/collection/interfaces/undo-state.interface.js +0 -1
  119. package/dist/collection/types/deep-readonly.type.js +0 -1
  120. package/dist/collection/types/state.types.js +0 -1
  121. package/dist/components/index.d.ts +1 -0
  122. package/dist/components/index.js +1 -1477
  123. package/dist/components/kritzel-brush-style.js +1 -67
  124. package/dist/components/kritzel-color-palette.js +1 -9
  125. package/dist/components/kritzel-color.js +1 -9
  126. package/dist/components/kritzel-context-menu.js +1 -9
  127. package/dist/components/kritzel-control-brush-config.js +1 -9
  128. package/dist/components/kritzel-control-text-config.js +1 -9
  129. package/dist/components/kritzel-controls.js +1 -9
  130. package/dist/components/kritzel-cursor-trail.js +1 -9
  131. package/dist/components/kritzel-dropdown.js +1 -9
  132. package/dist/components/kritzel-editor.js +1 -605
  133. package/dist/components/kritzel-engine.js +1 -9
  134. package/dist/components/kritzel-font-family.js +1 -9
  135. package/dist/components/kritzel-font-size.js +1 -9
  136. package/dist/components/kritzel-font.js +1 -9
  137. package/dist/components/kritzel-icon.js +1 -9
  138. package/dist/components/kritzel-menu-item.js +1 -9
  139. package/dist/components/kritzel-menu.js +1 -9
  140. package/dist/components/kritzel-portal.js +1 -9
  141. package/dist/components/kritzel-split-button.js +1 -9
  142. package/dist/components/kritzel-stroke-size.js +1 -9
  143. package/dist/components/kritzel-tooltip.js +1 -9
  144. package/dist/components/kritzel-utility-panel.js +1 -9
  145. package/dist/components/kritzel-workspace-manager.js +1 -9
  146. package/dist/components/p-1z-ds26_.js +1 -0
  147. package/dist/components/p-4FEa4ADy.js +1 -0
  148. package/dist/components/p-B0kd2rUI.js +1 -16
  149. package/dist/components/p-B7Fdo5QJ.js +1 -0
  150. package/dist/components/p-BXaWhpO2.js +1 -0
  151. package/dist/components/p-Bj_Og27M.js +1 -0
  152. package/dist/components/p-BtuXeItZ.js +1 -0
  153. package/dist/components/p-C-d2IH4v.js +1 -0
  154. package/dist/components/p-C3UriJh7.js +1 -0
  155. package/dist/components/p-C4krHoUl.js +1 -0
  156. package/dist/components/p-C6qB08BS.js +1 -68
  157. package/dist/components/p-CF5L2Gdl.js +1 -0
  158. package/dist/components/p-CXzfYQ_u.js +1 -0
  159. package/dist/components/p-CeKT_dTd.js +1 -0
  160. package/dist/components/p-Cp15toXH.js +1 -0
  161. package/dist/components/p-Cy77SpWt.js +1 -0
  162. package/dist/components/p-D1tfzpy8.js +1 -0
  163. package/dist/components/p-D3LRBk2t.js +9 -0
  164. package/dist/components/p-D5ZsALCP.js +1 -0
  165. package/dist/components/p-D8W6LE-c.js +1 -11
  166. package/dist/components/p-DB5s1NY4.js +1 -0
  167. package/dist/components/p-DTezr6w9.js +1 -0
  168. package/dist/components/p-Du1vxHy8.js +1 -0
  169. package/dist/components/p-IAqZFssU.js +1 -0
  170. package/dist/components/p-g0N9j_uT.js +1 -0
  171. package/dist/components/p-l10It7Nm.js +1 -30
  172. package/dist/components/p-n789Y3S-.js +1 -45
  173. package/dist/esm/app-globals-DQuL1Twl.js +0 -3
  174. package/dist/esm/{default-line-tool.config-CuBm2vpW.js → default-line-tool.config-CD5sTKH-.js} +1515 -205
  175. package/dist/esm/index-BqhmuUH2.js +3253 -0
  176. package/dist/esm/index.js +11 -8
  177. package/dist/esm/kritzel-brush-style.entry.js +3 -4
  178. package/dist/esm/kritzel-color_22.entry.js +103 -66
  179. package/dist/esm/loader.js +3 -4
  180. package/dist/esm/stencil.js +4 -5
  181. package/dist/stencil/index.esm.js +1 -2
  182. package/dist/stencil/p-09295079.entry.js +1 -0
  183. package/dist/stencil/p-381c0e9c.entry.js +9 -0
  184. package/dist/stencil/p-BqhmuUH2.js +2 -0
  185. package/dist/stencil/p-CD5sTKH-.js +1 -0
  186. package/dist/stencil/p-DQuL1Twl.js +1 -2
  187. package/dist/stencil/stencil.esm.js +1 -2
  188. package/dist/types/components/shared/kritzel-color-palette/kritzel-color-palette.d.ts +1 -0
  189. package/dist/types/components/shared/kritzel-font-size/kritzel-font-size.d.ts +1 -0
  190. package/dist/types/stencil-public-runtime.d.ts +57 -3
  191. package/package.json +6 -1
  192. package/dist/cjs/app-globals-V2Kpy_OQ.js.map +0 -1
  193. package/dist/cjs/default-line-tool.config-JuTDR6PF.js.map +0 -1
  194. package/dist/cjs/index-Cj__YTlG.js +0 -1650
  195. package/dist/cjs/index-Cj__YTlG.js.map +0 -1
  196. package/dist/cjs/index.cjs.js.map +0 -1
  197. package/dist/cjs/kritzel-brush-style.entry.cjs.js.map +0 -1
  198. package/dist/cjs/loader.cjs.js.map +0 -1
  199. package/dist/cjs/stencil.cjs.js.map +0 -1
  200. package/dist/collection/classes/core/core.class.js.map +0 -1
  201. package/dist/collection/classes/core/reviver.class.js.map +0 -1
  202. package/dist/collection/classes/core/store.class.js.map +0 -1
  203. package/dist/collection/classes/core/viewport.class.js.map +0 -1
  204. package/dist/collection/classes/core/workspace.class.js.map +0 -1
  205. package/dist/collection/classes/handlers/base.handler.js.map +0 -1
  206. package/dist/collection/classes/handlers/context-menu.handler.js.map +0 -1
  207. package/dist/collection/classes/handlers/hover.handler.js.map +0 -1
  208. package/dist/collection/classes/handlers/key.handler.js.map +0 -1
  209. package/dist/collection/classes/handlers/line-handle.handler.js.map +0 -1
  210. package/dist/collection/classes/handlers/move.handler.js.map +0 -1
  211. package/dist/collection/classes/handlers/resize.handler.js.map +0 -1
  212. package/dist/collection/classes/handlers/rotation.handler.js.map +0 -1
  213. package/dist/collection/classes/handlers/selection.handler.js.map +0 -1
  214. package/dist/collection/classes/managers/anchor.manager.js.map +0 -1
  215. package/dist/collection/classes/managers/cursor.manager.js.map +0 -1
  216. package/dist/collection/classes/objects/base-object.class.js.map +0 -1
  217. package/dist/collection/classes/objects/custom-element.class.js.map +0 -1
  218. package/dist/collection/classes/objects/group.class.js.map +0 -1
  219. package/dist/collection/classes/objects/image.class.js.map +0 -1
  220. package/dist/collection/classes/objects/line.class.js.map +0 -1
  221. package/dist/collection/classes/objects/path.class.js.map +0 -1
  222. package/dist/collection/classes/objects/selection-box.class.js.map +0 -1
  223. package/dist/collection/classes/objects/selection-group.class.js.map +0 -1
  224. package/dist/collection/classes/objects/shape.class.js.map +0 -1
  225. package/dist/collection/classes/objects/text.class.js.map +0 -1
  226. package/dist/collection/classes/providers/broadcast-sync-provider.class.js.map +0 -1
  227. package/dist/collection/classes/providers/hocuspocus-sync-provider.class.js.map +0 -1
  228. package/dist/collection/classes/providers/indexeddb-sync-provider.class.js.map +0 -1
  229. package/dist/collection/classes/providers/websocket-sync-provider.class.js.map +0 -1
  230. package/dist/collection/classes/registries/icon-registry.class.js.map +0 -1
  231. package/dist/collection/classes/registries/tool.registry.js.map +0 -1
  232. package/dist/collection/classes/structures/app-state-map.structure.js.map +0 -1
  233. package/dist/collection/classes/structures/object-map.structure.js.map +0 -1
  234. package/dist/collection/classes/structures/quadtree.structure.js.map +0 -1
  235. package/dist/collection/classes/tools/base-tool.class.js.map +0 -1
  236. package/dist/collection/classes/tools/brush-tool.class.js.map +0 -1
  237. package/dist/collection/classes/tools/eraser-tool.class.js.map +0 -1
  238. package/dist/collection/classes/tools/image-tool.class.js.map +0 -1
  239. package/dist/collection/classes/tools/line-tool.class.js.map +0 -1
  240. package/dist/collection/classes/tools/selection-tool.class.js.map +0 -1
  241. package/dist/collection/classes/tools/shape-tool.class.js.map +0 -1
  242. package/dist/collection/classes/tools/text-tool.class.js.map +0 -1
  243. package/dist/collection/components/core/kritzel-cursor-trail/kritzel-cursor-trail.js.map +0 -1
  244. package/dist/collection/components/core/kritzel-editor/kritzel-editor.js.map +0 -1
  245. package/dist/collection/components/core/kritzel-engine/kritzel-engine.js.map +0 -1
  246. package/dist/collection/components/shared/kritzel-brush-style/kritzel-brush-style.js.map +0 -1
  247. package/dist/collection/components/shared/kritzel-color/kritzel-color.js.map +0 -1
  248. package/dist/collection/components/shared/kritzel-color-palette/kritzel-color-palette.js.map +0 -1
  249. package/dist/collection/components/shared/kritzel-dropdown/kritzel-dropdown.js.map +0 -1
  250. package/dist/collection/components/shared/kritzel-font/kritzel-font.js.map +0 -1
  251. package/dist/collection/components/shared/kritzel-font-family/kritzel-font-family.js.map +0 -1
  252. package/dist/collection/components/shared/kritzel-font-size/kritzel-font-size.js.map +0 -1
  253. package/dist/collection/components/shared/kritzel-icon/kritzel-icon.js.map +0 -1
  254. package/dist/collection/components/shared/kritzel-menu/kritzel-menu.js.map +0 -1
  255. package/dist/collection/components/shared/kritzel-menu-item/kritzel-menu-item.js.map +0 -1
  256. package/dist/collection/components/shared/kritzel-portal/kritzel-portal.js.map +0 -1
  257. package/dist/collection/components/shared/kritzel-split-button/kritzel-split-button.js.map +0 -1
  258. package/dist/collection/components/shared/kritzel-stroke-size/kritzel-stroke-size.js.map +0 -1
  259. package/dist/collection/components/shared/kritzel-tooltip/kritzel-tooltip.js.map +0 -1
  260. package/dist/collection/components/ui/kritzel-context-menu/kritzel-context-menu.js.map +0 -1
  261. package/dist/collection/components/ui/kritzel-control-brush-config/kritzel-control-brush-config.js.map +0 -1
  262. package/dist/collection/components/ui/kritzel-control-text-config/kritzel-control-text-config.js.map +0 -1
  263. package/dist/collection/components/ui/kritzel-controls/kritzel-controls.js.map +0 -1
  264. package/dist/collection/components/ui/kritzel-utility-panel/kritzel-utility-panel.js.map +0 -1
  265. package/dist/collection/components/ui/kritzel-workspace-manager/kritzel-workspace-manager.js.map +0 -1
  266. package/dist/collection/configs/default-brush-tool.config.js.map +0 -1
  267. package/dist/collection/configs/default-engine-config.js.map +0 -1
  268. package/dist/collection/configs/default-line-tool.config.js.map +0 -1
  269. package/dist/collection/configs/default-shape-tool.config.js.map +0 -1
  270. package/dist/collection/configs/default-sync.config.js.map +0 -1
  271. package/dist/collection/configs/default-text-tool.config.js.map +0 -1
  272. package/dist/collection/constants/core.constants.js.map +0 -1
  273. package/dist/collection/constants/engine.constants.js.map +0 -1
  274. package/dist/collection/enums/event-button.enum.js.map +0 -1
  275. package/dist/collection/enums/handle-type.enum.js.map +0 -1
  276. package/dist/collection/enums/shape-type.enum.js.map +0 -1
  277. package/dist/collection/helpers/class.helper.js.map +0 -1
  278. package/dist/collection/helpers/cursor.helper.js.map +0 -1
  279. package/dist/collection/helpers/devices.helper.js.map +0 -1
  280. package/dist/collection/helpers/event.helper.js.map +0 -1
  281. package/dist/collection/helpers/geometry.helper.js.map +0 -1
  282. package/dist/collection/helpers/html.helper.js.map +0 -1
  283. package/dist/collection/helpers/keyboard.helper.js.map +0 -1
  284. package/dist/collection/helpers/math.helper.js.map +0 -1
  285. package/dist/collection/helpers/object.helper.js.map +0 -1
  286. package/dist/collection/index.js.map +0 -1
  287. package/dist/collection/interfaces/anchor.interface.js.map +0 -1
  288. package/dist/collection/interfaces/arrow-head.interface.js.map +0 -1
  289. package/dist/collection/interfaces/bounding-box.interface.js.map +0 -1
  290. package/dist/collection/interfaces/clonable.interface.js.map +0 -1
  291. package/dist/collection/interfaces/context-menu-item.interface.js.map +0 -1
  292. package/dist/collection/interfaces/debug-info.interface.js.map +0 -1
  293. package/dist/collection/interfaces/engine-state.interface.js.map +0 -1
  294. package/dist/collection/interfaces/line-options.interface.js.map +0 -1
  295. package/dist/collection/interfaces/menu-item.interface.js.map +0 -1
  296. package/dist/collection/interfaces/object.interface.js.map +0 -1
  297. package/dist/collection/interfaces/path-options.interface.js.map +0 -1
  298. package/dist/collection/interfaces/point.interface.js.map +0 -1
  299. package/dist/collection/interfaces/polygon.interface.js.map +0 -1
  300. package/dist/collection/interfaces/selection-state.interface.js.map +0 -1
  301. package/dist/collection/interfaces/serializable.interface.js.map +0 -1
  302. package/dist/collection/interfaces/shortcut.interface.js.map +0 -1
  303. package/dist/collection/interfaces/sync-config.interface.js.map +0 -1
  304. package/dist/collection/interfaces/sync-provider.interface.js.map +0 -1
  305. package/dist/collection/interfaces/tool.interface.js.map +0 -1
  306. package/dist/collection/interfaces/toolbar-control.interface.js.map +0 -1
  307. package/dist/collection/interfaces/undo-state.interface.js.map +0 -1
  308. package/dist/collection/types/deep-readonly.type.js.map +0 -1
  309. package/dist/collection/types/state.types.js.map +0 -1
  310. package/dist/components/index.js.map +0 -1
  311. package/dist/components/kritzel-brush-style.js.map +0 -1
  312. package/dist/components/kritzel-color-palette.js.map +0 -1
  313. package/dist/components/kritzel-color.js.map +0 -1
  314. package/dist/components/kritzel-context-menu.js.map +0 -1
  315. package/dist/components/kritzel-control-brush-config.js.map +0 -1
  316. package/dist/components/kritzel-control-text-config.js.map +0 -1
  317. package/dist/components/kritzel-controls.js.map +0 -1
  318. package/dist/components/kritzel-cursor-trail.js.map +0 -1
  319. package/dist/components/kritzel-dropdown.js.map +0 -1
  320. package/dist/components/kritzel-editor.js.map +0 -1
  321. package/dist/components/kritzel-engine.js.map +0 -1
  322. package/dist/components/kritzel-font-family.js.map +0 -1
  323. package/dist/components/kritzel-font-size.js.map +0 -1
  324. package/dist/components/kritzel-font.js.map +0 -1
  325. package/dist/components/kritzel-icon.js.map +0 -1
  326. package/dist/components/kritzel-menu-item.js.map +0 -1
  327. package/dist/components/kritzel-menu.js.map +0 -1
  328. package/dist/components/kritzel-portal.js.map +0 -1
  329. package/dist/components/kritzel-split-button.js.map +0 -1
  330. package/dist/components/kritzel-stroke-size.js.map +0 -1
  331. package/dist/components/kritzel-tooltip.js.map +0 -1
  332. package/dist/components/kritzel-utility-panel.js.map +0 -1
  333. package/dist/components/kritzel-workspace-manager.js.map +0 -1
  334. package/dist/components/p-B0kd2rUI.js.map +0 -1
  335. package/dist/components/p-B80ry-r4.js +0 -103
  336. package/dist/components/p-B80ry-r4.js.map +0 -1
  337. package/dist/components/p-BC5-_yPs.js +0 -75
  338. package/dist/components/p-BC5-_yPs.js.map +0 -1
  339. package/dist/components/p-BUsg2vtg.js +0 -14897
  340. package/dist/components/p-BUsg2vtg.js.map +0 -1
  341. package/dist/components/p-Bo-NQ68K.js +0 -132
  342. package/dist/components/p-Bo-NQ68K.js.map +0 -1
  343. package/dist/components/p-C6qB08BS.js.map +0 -1
  344. package/dist/components/p-C720oASC.js +0 -201
  345. package/dist/components/p-C720oASC.js.map +0 -1
  346. package/dist/components/p-C92UCXyc.js +0 -308
  347. package/dist/components/p-C92UCXyc.js.map +0 -1
  348. package/dist/components/p-CAxHKvww.js +0 -119
  349. package/dist/components/p-CAxHKvww.js.map +0 -1
  350. package/dist/components/p-CD9cCvhR.js +0 -272
  351. package/dist/components/p-CD9cCvhR.js.map +0 -1
  352. package/dist/components/p-CIlIrPRp.js +0 -83
  353. package/dist/components/p-CIlIrPRp.js.map +0 -1
  354. package/dist/components/p-CIts5Uma.js +0 -110
  355. package/dist/components/p-CIts5Uma.js.map +0 -1
  356. package/dist/components/p-Cdw55iW6.js +0 -281
  357. package/dist/components/p-Cdw55iW6.js.map +0 -1
  358. package/dist/components/p-CwkUrTy1.js +0 -1367
  359. package/dist/components/p-CwkUrTy1.js.map +0 -1
  360. package/dist/components/p-D8W6LE-c.js.map +0 -1
  361. package/dist/components/p-DI7JQMsC.js +0 -46
  362. package/dist/components/p-DI7JQMsC.js.map +0 -1
  363. package/dist/components/p-DmYjCy-z.js +0 -62
  364. package/dist/components/p-DmYjCy-z.js.map +0 -1
  365. package/dist/components/p-DoD6F7Y4.js +0 -157
  366. package/dist/components/p-DoD6F7Y4.js.map +0 -1
  367. package/dist/components/p-DyVWaSSc.js +0 -55
  368. package/dist/components/p-DyVWaSSc.js.map +0 -1
  369. package/dist/components/p-WLXyD_eY.js +0 -111
  370. package/dist/components/p-WLXyD_eY.js.map +0 -1
  371. package/dist/components/p-c7AGmG3p.js +0 -73
  372. package/dist/components/p-c7AGmG3p.js.map +0 -1
  373. package/dist/components/p-fm-bG_zL.js +0 -231
  374. package/dist/components/p-fm-bG_zL.js.map +0 -1
  375. package/dist/components/p-fqLbEfE0.js +0 -39586
  376. package/dist/components/p-fqLbEfE0.js.map +0 -1
  377. package/dist/components/p-l10It7Nm.js.map +0 -1
  378. package/dist/components/p-n789Y3S-.js.map +0 -1
  379. package/dist/components/p-qWf2T62p.js +0 -57
  380. package/dist/components/p-qWf2T62p.js.map +0 -1
  381. package/dist/components/p-vLN8eXFe.js +0 -106
  382. package/dist/components/p-vLN8eXFe.js.map +0 -1
  383. package/dist/esm/app-globals-DQuL1Twl.js.map +0 -1
  384. package/dist/esm/default-line-tool.config-CuBm2vpW.js.map +0 -1
  385. package/dist/esm/index-SGde3HXB.js +0 -1623
  386. package/dist/esm/index-SGde3HXB.js.map +0 -1
  387. package/dist/esm/index.js.map +0 -1
  388. package/dist/esm/kritzel-brush-style.entry.js.map +0 -1
  389. package/dist/esm/loader.js.map +0 -1
  390. package/dist/esm/stencil.js.map +0 -1
  391. package/dist/stencil/index.esm.js.map +0 -1
  392. package/dist/stencil/kritzel-brush-style.entry.esm.js.map +0 -1
  393. package/dist/stencil/loader.esm.js.map +0 -1
  394. package/dist/stencil/p-0a9b6696.entry.js +0 -2
  395. package/dist/stencil/p-0a9b6696.entry.js.map +0 -1
  396. package/dist/stencil/p-0fdce6ce.entry.js +0 -10
  397. package/dist/stencil/p-0fdce6ce.entry.js.map +0 -1
  398. package/dist/stencil/p-CuBm2vpW.js +0 -2
  399. package/dist/stencil/p-CuBm2vpW.js.map +0 -1
  400. package/dist/stencil/p-DQuL1Twl.js.map +0 -1
  401. package/dist/stencil/p-SGde3HXB.js +0 -3
  402. package/dist/stencil/p-SGde3HXB.js.map +0 -1
  403. package/dist/stencil/stencil.esm.js.map +0 -1
@@ -1,2 +0,0 @@
1
- class t{static registry={};static registerTool(t,e,i){const s=new e(i);s.name=t;this.registry[t]=s;return s}static getTool(t){const e=this.registry[t];if(!e){console.warn(`Unknown tool: ${t}`);return null}return e}}class e{static generateUUID(){return Math.random().toString(36).substr(2,9)}static isEmpty(t){if(t===null||t===undefined){return true}return Object?.keys(t).length===0&&t?.constructor===Object}}class i{static doPolygonsIntersect(t,e){const i=[t.bottomLeft,t.bottomRight,t.topRight,t.topLeft];const s=[e.bottomLeft,e.bottomRight,e.topRight,e.topLeft];for(const t of i){if(this.isPointInPolygon(t,s)){return true}}for(const t of s){if(this.isPointInPolygon(t,i)){return true}}for(let t=0;t<i.length;t++){const e=i[t];const n=i[(t+1)%i.length];for(let t=0;t<s.length;t++){const i=s[t];const r=s[(t+1)%s.length];if(this.intersectLines(e,n,i,r)){return true}}}return false}static isPointInPolygon(t,e){let i=false;for(let s=0,n=e.length-1;s<e.length;n=s++){const r=e[s].x,o=e[s].y;const h=e[n].x,l=e[n].y;const f=o>t.y!==l>t.y&&t.x<(h-r)*(t.y-o)/(l-o)+r;if(f)i=!i}return i}static intersectLines(t,e,i,s){const n=(e.x-t.x)*(s.y-i.y)-(e.y-t.y)*(s.x-i.x);if(n===0){return false}const r=((i.x-t.x)*(s.y-i.y)-(i.y-t.y)*(s.x-i.x))/n;const o=-((t.x-i.x)*(e.y-t.y)-(t.y-i.y)*(e.x-t.x))/n;return r>=0&&r<=1&&o>=0&&o<=1}static getLineIntersectionPoint(t,e,i,s){const n=(e.x-t.x)*(s.y-i.y)-(e.y-t.y)*(s.x-i.x);if(n===0){return null}const r=((i.x-t.x)*(s.y-i.y)-(i.y-t.y)*(s.x-i.x))/n;const o=-((t.x-i.x)*(e.y-t.y)-(t.y-i.y)*(e.x-t.x))/n;if(r>=0&&r<=1&&o>=0&&o<=1){return{x:t.x+r*(e.x-t.x),y:t.y+r*(e.y-t.y)}}return null}static getLinePolygonIntersection(t,e,i){const s=[i.topLeft,i.topRight,i.bottomRight,i.bottomLeft];let n=null;let r=Infinity;for(let i=0;i<s.length;i++){const o=s[i];const h=s[(i+1)%s.length];const l=this.getLineIntersectionPoint(t,e,o,h);if(l){const e=Math.sqrt(Math.pow(l.x-t.x,2)+Math.pow(l.y-t.y,2));if(e<r){r=e;n=l}}}return n}static getEllipsePolygonApproximation(t,e,i,s,n=32,r=0){const o=[];const h=Math.cos(r);const l=Math.sin(r);for(let r=0;r<n;r++){const f=2*Math.PI*r/n;const u=i*Math.cos(f);const c=s*Math.sin(f);const a=t+u*h-c*l;const d=e+u*l+c*h;o.push({x:a,y:d})}return o}static getLinePointsArrayIntersection(t,e,i){let s=null;let n=Infinity;for(let r=0;r<i.length;r++){const o=i[r];const h=i[(r+1)%i.length];const l=this.getLineIntersectionPoint(t,e,o,h);if(l){const e=Math.sqrt(Math.pow(l.x-t.x,2)+Math.pow(l.y-t.y,2));if(e<n){n=e;s=l}}}return s}static isPointInPolygonPoints(t,e){return this.isPointInPolygon(t,e)}}class s{__class__="KritzelBaseObject";_core;_elementRef;id;workspaceId;x;y;translateX;translateY;height;width;backgroundColor;borderColor;borderWidth=0;opacity=1;padding=0;scale;resizing=false;rotation=0;markedForRemoval=false;zIndex=0;isVisible=true;isSelected=false;isHovered=false;isMounted=false;isEditable=false;isInteractive=false;isDebugInfoVisible=false;get totalWidth(){return this.width+this.padding*2}get totalHeight(){return this.height+this.padding*2}set elementRef(t){this._elementRef=t}get elementRef(){return this._elementRef}get boundingBox(){return{x:this.translateX,y:this.translateY,z:this.scale,width:this.totalWidth/this.scale,height:this.totalHeight/this.scale}}get rotatedBoundingBox(){return{x:this.minXRotated,y:this.minYRotated,z:this.scale,width:this.maxXRotated-this.minXRotated,height:this.maxYRotated-this.minYRotated}}get rotatedPolygon(){const t=this.translateX+this.totalWidth/2/this.scale;const e=this.translateY+this.totalHeight/2/this.scale;const i=this.rotation;const s=this.totalWidth/this.scale;const n=this.totalHeight/this.scale;const r={topLeft:{x:this.translateX,y:this.translateY},topRight:{x:this.translateX+s,y:this.translateY},bottomRight:{x:this.translateX+s,y:this.translateY+n},bottomLeft:{x:this.translateX,y:this.translateY+n}};const o=Object.keys(r).reduce(((s,n)=>{const o=r[n];const h=Math.cos(i)*(o.x-t)-Math.sin(i)*(o.y-e)+t;const l=Math.sin(i)*(o.x-t)+Math.cos(i)*(o.y-e)+e;s[n]={x:h,y:l};return s}),{});return o}get minXRotated(){const t=[this.rotatedPolygon.topLeft.x,this.rotatedPolygon.topRight.x,this.rotatedPolygon.bottomRight.x,this.rotatedPolygon.bottomLeft.x];return Math.min(...t)}get minYRotated(){const t=[this.rotatedPolygon.topLeft.y,this.rotatedPolygon.topRight.y,this.rotatedPolygon.bottomRight.y,this.rotatedPolygon.bottomLeft.y];return Math.min(...t)}get maxXRotated(){const t=[this.rotatedPolygon.topLeft.x,this.rotatedPolygon.topRight.x,this.rotatedPolygon.bottomRight.x,this.rotatedPolygon.bottomLeft.x];return Math.max(...t)}get maxYRotated(){const t=[this.rotatedPolygon.topLeft.y,this.rotatedPolygon.topRight.y,this.rotatedPolygon.bottomRight.y,this.rotatedPolygon.bottomLeft.y];return Math.max(...t)}get transformationMatrix(){const t=1/this.scale;const e=this.translateX;const i=this.translateY;return`matrix(${t}, 0, 0, ${t}, ${e}, ${i})`}get rotationDegrees(){return this.rotation*(180/Math.PI)}get centerX(){return this.translateX+this.totalWidth/2/this.scale}get centerY(){return this.translateY+this.totalHeight/2/this.scale}constructor(){this.id=this.generateId()}static create(t){const e=new s;e._core=t;e.zIndex=t.store.currentZIndex;e.workspaceId=t.store.state.activeWorkspace.id;return e}mount(t){if(this.isMounted){return}this.elementRef=t;this.isMounted=true}generateId(){return e.generateUUID()}isInViewport(){const t=this._core.store.state.scale;const e=this.boundingBox.width*t;const i=this.boundingBox.height*t;if(e*i<.5){return false}const s={x:-this._core.store.state.translateX/this._core.store.state.scale,y:-this._core.store.state.translateY/this._core.store.state.scale,width:this._core.store.state.viewportWidth/this._core.store.state.scale,height:this._core.store.state.viewportHeight/this._core.store.state.scale};return this.rotatedBoundingBox.x<s.x+s.width&&this.rotatedBoundingBox.x+this.rotatedBoundingBox.width>s.x&&this.rotatedBoundingBox.y<s.y+s.height&&this.rotatedBoundingBox.y+this.rotatedBoundingBox.height>s.y}centerInViewport(){const{viewportWidth:t,viewportHeight:e,translateX:i,translateY:s,scale:n}=this._core.store.state;const{x:r,y:o,width:h,height:l}=this.rotatedBoundingBox;const f=r+h/2;const u=o+l/2;const c=(t/2-i)/n;const a=(e/2-s)/n;const d=c-f;const w=a-u;this.updatePosition(this.translateX+d,this.translateY+w)}update(){this._core.store.state.objects.update(this)}move(t,e,i,s){const n=(t-i)/this._core.store.state.scale;const r=(e-s)/this._core.store.state.scale;this.translateX+=n;this.translateY+=r;this._core.store.state.objects.update(this)}resize(t,e,i,s){if(i<=1||s<=1){return}this.width=i;this.height=s;this.translateX=t;this.translateY=e;this._core.store.state.objects.update(this);this._core.anchorManager.updateAnchorsForObject(this.id)}rotate(t){this.rotation=t;this._core.store.state.objects.update(this)}clone(){const t=Object.create(Object.getPrototypeOf(this));Object.assign(t,this);t.id=this.id;return t}copy(){const t=Object.create(Object.getPrototypeOf(this));Object.assign(t,this);t.id=this.generateId();t.isMounted=false;return t}serialize(){const{_core:t,_elementRef:e,element:i,totalWidth:s,totalHeight:n,...r}=this;const o=structuredClone(r);if(i&&typeof i==="object"&&"nodeType"in i&&i.nodeType===1){o.element=i.cloneNode(true)}return o}deserialize(t){Object.assign(this,t);return this}isClass(t){return this.__class__===t}edit(t){}hitTest(t,e){return true}hitTestPolygon(t){const e=this.rotatedPolygon;return i.doPolygonsIntersect(e,t)}updatePosition(t,e){this.translateX=t;this.translateY=e;this._core.store.state.objects.update(this)}}class n{static forceHideKeyboard(){if(document.activeElement instanceof HTMLElement){document.activeElement.blur()}}static enableInteractiveWidget(){const t=document.querySelector('meta[name="viewport"][content*="interactive-widget=resizes-content"]');if(t){let e=t.getAttribute("content");if(!e.includes("interactive-widget=resizes-content")){e+=", interactive-widget=resizes-content"}t.setAttribute("content",e)}}static disableInteractiveWidget(){const t=document.querySelector('meta[name="viewport"][content*="interactive-widget=resizes-content"]');if(t){let e=t.getAttribute("content");let i=e.replace(/\s*interactive-widget=resizes-content\s*[,;]?/g,"");i=i.replace(/,(\s*,)+/g,",").replace(/^,/,"").replace(/,$/,"").trim();t.setAttribute("content",i)}}static onKeyboardVisibleChanged(t){if("visualViewport"in window){const e=.75;const i=i=>{const s=i.target;const n=s.height*s.scale/window.screen.height<e;t(n)};window.visualViewport.addEventListener("resize",i);return()=>window.visualViewport.removeEventListener("resize",i)}else{console.warn("Listening for keyboard visibility changes is not reliably supported in this browser.");return()=>{}}}}class r{static isTouchDevice(){return window.matchMedia("(any-pointer: coarse)").matches}static isAndroid(){return/android/i.test(navigator.userAgent)}static isIOS(){return/iPad|iPhone|iPod/.test(navigator.userAgent)}static detectOS(){if(this.isIOS()){return"iOS"}else if(this.isAndroid()){return"Android"}else{return"Other"}}static isFirefox(){return/firefox/i.test(navigator.userAgent)}}function o(t){this.content=t}o.prototype={constructor:o,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?undefined:this.content[e+1]},update:function(t,e,i){var s=i&&i!=t?this.remove(i):this;var n=s.find(t),r=s.content.slice();if(n==-1){r.push(i||t,e)}else{r[n+1]=e;if(i)r[n]=i}return new o(r)},remove:function(t){var e=this.find(t);if(e==-1)return this;var i=this.content.slice();i.splice(e,2);return new o(i)},addToStart:function(t,e){return new o([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var i=this.remove(t).content.slice();i.push(t,e);return new o(i)},addBefore:function(t,e,i){var s=this.remove(e),n=s.content.slice();var r=s.find(t);n.splice(r==-1?n.length:r,0,e,i);return new o(n)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){t=o.from(t);if(!t.size)return this;return new o(t.content.concat(this.subtract(t).content))},append:function(t){t=o.from(t);if(!t.size)return this;return new o(this.subtract(t).content.concat(t.content))},subtract:function(t){var e=this;t=o.from(t);for(var i=0;i<t.content.length;i+=2)e=e.remove(t.content[i]);return e},toObject:function(){var t={};this.forEach((function(e,i){t[e]=i}));return t},get size(){return this.content.length>>1}};o.from=function(t){if(t instanceof o)return t;var e=[];if(t)for(var i in t)e.push(i,t[i]);return new o(e)};function h(t,e,i){for(let s=0;;s++){if(s==t.childCount||s==e.childCount)return t.childCount==e.childCount?null:i;let n=t.child(s),r=e.child(s);if(n==r){i+=n.nodeSize;continue}if(!n.sameMarkup(r))return i;if(n.isText&&n.text!=r.text){for(let t=0;n.text[t]==r.text[t];t++)i++;return i}if(n.content.size||r.content.size){let t=h(n.content,r.content,i+1);if(t!=null)return t}i+=n.nodeSize}}function l(t,e,i,s){for(let n=t.childCount,r=e.childCount;;){if(n==0||r==0)return n==r?null:{a:i,b:s};let o=t.child(--n),h=e.child(--r),f=o.nodeSize;if(o==h){i-=f;s-=f;continue}if(!o.sameMarkup(h))return{a:i,b:s};if(o.isText&&o.text!=h.text){let t=0,e=Math.min(o.text.length,h.text.length);while(t<e&&o.text[o.text.length-t-1]==h.text[h.text.length-t-1]){t++;i--;s--}return{a:i,b:s}}if(o.content.size||h.content.size){let t=l(o.content,h.content,i-1,s-1);if(t)return t}i-=f;s-=f}}class f{constructor(t,e){this.content=t;this.size=e||0;if(e==null)for(let e=0;e<t.length;e++)this.size+=t[e].nodeSize}nodesBetween(t,e,i,s=0,n){for(let r=0,o=0;o<e;r++){let h=this.content[r],l=o+h.nodeSize;if(l>t&&i(h,s+o,n||null,r)!==false&&h.content.size){let n=o+1;h.nodesBetween(Math.max(0,t-n),Math.min(h.content.size,e-n),i,s+n)}o=l}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,e,i,s){let n="",r=true;this.nodesBetween(t,e,((o,h)=>{let l=o.isText?o.text.slice(Math.max(t,h)-h,e-h):!o.isLeaf?"":s?typeof s==="function"?s(o):s:o.type.spec.leafText?o.type.spec.leafText(o):"";if(o.isBlock&&(o.isLeaf&&l||o.isTextblock)&&i){if(r)r=false;else n+=i}n+=l}),0);return n}append(t){if(!t.size)return this;if(!this.size)return t;let e=this.lastChild,i=t.firstChild,s=this.content.slice(),n=0;if(e.isText&&e.sameMarkup(i)){s[s.length-1]=e.withText(e.text+i.text);n=1}for(;n<t.content.length;n++)s.push(t.content[n]);return new f(s,this.size+t.size)}cut(t,e=this.size){if(t==0&&e==this.size)return this;let i=[],s=0;if(e>t)for(let n=0,r=0;r<e;n++){let o=this.content[n],h=r+o.nodeSize;if(h>t){if(r<t||h>e){if(o.isText)o=o.cut(Math.max(0,t-r),Math.min(o.text.length,e-r));else o=o.cut(Math.max(0,t-r-1),Math.min(o.content.size,e-r-1))}i.push(o);s+=o.nodeSize}r=h}return new f(i,s)}cutByIndex(t,e){if(t==e)return f.empty;if(t==0&&e==this.content.length)return this;return new f(this.content.slice(t,e))}replaceChild(t,e){let i=this.content[t];if(i==e)return this;let s=this.content.slice();let n=this.size+e.nodeSize-i.nodeSize;s[t]=e;return new f(s,n)}addToStart(t){return new f([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new f(this.content.concat(t),this.size+t.nodeSize)}eq(t){if(this.content.length!=t.content.length)return false;for(let e=0;e<this.content.length;e++)if(!this.content[e].eq(t.content[e]))return false;return true}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(t){let e=this.content[t];if(!e)throw new RangeError("Index "+t+" out of range for "+this);return e}maybeChild(t){return this.content[t]||null}forEach(t){for(let e=0,i=0;e<this.content.length;e++){let s=this.content[e];t(s,i,e);i+=s.nodeSize}}findDiffStart(t,e=0){return h(this,t,e)}findDiffEnd(t,e=this.size,i=t.size){return l(this,t,e,i)}findIndex(t){if(t==0)return c(0,t);if(t==this.size)return c(this.content.length,t);if(t>this.size||t<0)throw new RangeError(`Position ${t} outside of fragment (${this})`);for(let e=0,i=0;;e++){let s=this.child(e),n=i+s.nodeSize;if(n>=t){if(n==t)return c(e+1,n);return c(e,i)}i=n}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map((t=>t.toJSON())):null}static fromJSON(t,e){if(!e)return f.empty;if(!Array.isArray(e))throw new RangeError("Invalid input for Fragment.fromJSON");return new f(e.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return f.empty;let e,i=0;for(let s=0;s<t.length;s++){let n=t[s];i+=n.nodeSize;if(s&&n.isText&&t[s-1].sameMarkup(n)){if(!e)e=t.slice(0,s);e[e.length-1]=n.withText(e[e.length-1].text+n.text)}else if(e){e.push(n)}}return new f(e||t,i)}static from(t){if(!t)return f.empty;if(t instanceof f)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new f([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}f.empty=new f([],0);const u={index:0,offset:0};function c(t,e){u.index=t;u.offset=e;return u}function a(t,e){if(t===e)return true;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return false;let i=Array.isArray(t);if(Array.isArray(e)!=i)return false;if(i){if(t.length!=e.length)return false;for(let i=0;i<t.length;i++)if(!a(t[i],e[i]))return false}else{for(let i in t)if(!(i in e)||!a(t[i],e[i]))return false;for(let i in e)if(!(i in t))return false}return true}class d{constructor(t,e){this.type=t;this.attrs=e}addToSet(t){let e,i=false;for(let s=0;s<t.length;s++){let n=t[s];if(this.eq(n))return t;if(this.type.excludes(n.type)){if(!e)e=t.slice(0,s)}else if(n.type.excludes(this.type)){return t}else{if(!i&&n.type.rank>this.type.rank){if(!e)e=t.slice(0,s);e.push(this);i=true}if(e)e.push(n)}}if(!e)e=t.slice();if(!i)e.push(this);return e}removeFromSet(t){for(let e=0;e<t.length;e++)if(this.eq(t[e]))return t.slice(0,e).concat(t.slice(e+1));return t}isInSet(t){for(let e=0;e<t.length;e++)if(this.eq(t[e]))return true;return false}eq(t){return this==t||this.type==t.type&&a(this.attrs,t.attrs)}toJSON(){let t={type:this.type.name};for(let e in this.attrs){t.attrs=this.attrs;break}return t}static fromJSON(t,e){if(!e)throw new RangeError("Invalid input for Mark.fromJSON");let i=t.marks[e.type];if(!i)throw new RangeError(`There is no mark type ${e.type} in this schema`);let s=i.create(e.attrs);i.checkAttrs(s.attrs);return s}static sameSet(t,e){if(t==e)return true;if(t.length!=e.length)return false;for(let i=0;i<t.length;i++)if(!t[i].eq(e[i]))return false;return true}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return d.none;if(t instanceof d)return[t];let e=t.slice();e.sort(((t,e)=>t.type.rank-e.type.rank));return e}}d.none=[];class w extends Error{}class p{constructor(t,e,i){this.content=t;this.openStart=e;this.openEnd=i}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,e){let i=m(this.content,t+this.openStart,e);return i&&new p(i,this.openStart,this.openEnd)}removeBetween(t,e){return new p(g(this.content,t+this.openStart,e+this.openStart),this.openStart,this.openEnd)}eq(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let t={content:this.content.toJSON()};if(this.openStart>0)t.openStart=this.openStart;if(this.openEnd>0)t.openEnd=this.openEnd;return t}static fromJSON(t,e){if(!e)return p.empty;let i=e.openStart||0,s=e.openEnd||0;if(typeof i!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new p(f.fromJSON(t,e.content),i,s)}static maxOpen(t,e=true){let i=0,s=0;for(let s=t.firstChild;s&&!s.isLeaf&&(e||!s.type.spec.isolating);s=s.firstChild)i++;for(let i=t.lastChild;i&&!i.isLeaf&&(e||!i.type.spec.isolating);i=i.lastChild)s++;return new p(t,i,s)}}p.empty=new p(f.empty,0,0);function g(t,e,i){let{index:s,offset:n}=t.findIndex(e),r=t.maybeChild(s);let{index:o,offset:h}=t.findIndex(i);if(n==e||r.isText){if(h!=i&&!t.child(o).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(i))}if(s!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(s,r.copy(g(r.content,e-n-1,i-n-1)))}function m(t,e,i,s){let{index:n,offset:r}=t.findIndex(e),o=t.maybeChild(n);if(r==e||o.isText){if(s&&!s.canReplace(n,n,i))return null;return t.cut(0,e).append(i).append(t.cut(e))}let h=m(o.content,e-r-1,i,o);return h&&t.replaceChild(n,o.copy(h))}function y(t,e,i){if(i.openStart>t.depth)throw new w("Inserted content deeper than insertion position");if(t.depth-i.openStart!=e.depth-i.openEnd)throw new w("Inconsistent open depths");return v(t,e,i,0)}function v(t,e,i,s){let n=t.index(s),r=t.node(s);if(n==e.index(s)&&s<t.depth-i.openStart){let o=v(t,e,i,s+1);return r.copy(r.content.replaceChild(n,o))}else if(!i.content.size){return x(r,C(t,e,s))}else if(!i.openStart&&!i.openEnd&&t.depth==s&&e.depth==s){let s=t.parent,n=s.content;return x(s,n.cut(0,t.parentOffset).append(i.content).append(n.cut(e.parentOffset)))}else{let{start:n,end:o}=O(i,t);return x(r,S(t,n,o,e,s))}}function b(t,e){if(!e.type.compatibleContent(t.type))throw new w("Cannot join "+e.type.name+" onto "+t.type.name)}function M(t,e,i){let s=t.node(i);b(s,e.node(i));return s}function k(t,e){let i=e.length-1;if(i>=0&&t.isText&&t.sameMarkup(e[i]))e[i]=t.withText(e[i].text+t.text);else e.push(t)}function A(t,e,i,s){let n=(e||t).node(i);let r=0,o=e?e.index(i):n.childCount;if(t){r=t.index(i);if(t.depth>i){r++}else if(t.textOffset){k(t.nodeAfter,s);r++}}for(let t=r;t<o;t++)k(n.child(t),s);if(e&&e.depth==i&&e.textOffset)k(e.nodeBefore,s)}function x(t,e){t.type.checkContent(e);return t.copy(e)}function S(t,e,i,s,n){let r=t.depth>n&&M(t,e,n+1);let o=s.depth>n&&M(i,s,n+1);let h=[];A(null,t,n,h);if(r&&o&&e.index(n)==i.index(n)){b(r,o);k(x(r,S(t,e,i,s,n+1)),h)}else{if(r)k(x(r,C(t,e,n+1)),h);A(e,i,n,h);if(o)k(x(o,C(i,s,n+1)),h)}A(s,null,n,h);return new f(h)}function C(t,e,i){let s=[];A(null,t,i,s);if(t.depth>i){let n=M(t,e,i+1);k(x(n,C(t,e,i+1)),s)}A(e,null,i,s);return new f(s)}function O(t,e){let i=e.depth-t.openStart,s=e.node(i);let n=s.copy(t.content);for(let t=i-1;t>=0;t--)n=e.node(t).copy(f.from(n));return{start:n.resolveNoCache(t.openStart+i),end:n.resolveNoCache(n.content.size-t.openEnd-i)}}class E{constructor(t,e,i){this.pos=t;this.path=e;this.parentOffset=i;this.depth=e.length/3-1}resolveDepth(t){if(t==null)return this.depth;if(t<0)return this.depth+t;return t}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(t){return this.path[this.resolveDepth(t)*3]}index(t){return this.path[this.resolveDepth(t)*3+1]}indexAfter(t){t=this.resolveDepth(t);return this.index(t)+(t==this.depth&&!this.textOffset?0:1)}start(t){t=this.resolveDepth(t);return t==0?0:this.path[t*3-1]+1}end(t){t=this.resolveDepth(t);return this.start(t)+this.node(t).content.size}before(t){t=this.resolveDepth(t);if(!t)throw new RangeError("There is no position before the top-level node");return t==this.depth+1?this.pos:this.path[t*3-1]}after(t){t=this.resolveDepth(t);if(!t)throw new RangeError("There is no position after the top-level node");return t==this.depth+1?this.pos:this.path[t*3-1]+this.path[t*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let t=this.parent,e=this.index(this.depth);if(e==t.childCount)return null;let i=this.pos-this.path[this.path.length-1],s=t.child(e);return i?t.child(e).cut(i):s}get nodeBefore(){let t=this.index(this.depth);let e=this.pos-this.path[this.path.length-1];if(e)return this.parent.child(t).cut(0,e);return t==0?null:this.parent.child(t-1)}posAtIndex(t,e){e=this.resolveDepth(e);let i=this.path[e*3],s=e==0?0:this.path[e*3-1]+1;for(let e=0;e<t;e++)s+=i.child(e).nodeSize;return s}marks(){let t=this.parent,e=this.index();if(t.content.size==0)return d.none;if(this.textOffset)return t.child(e).marks;let i=t.maybeChild(e-1),s=t.maybeChild(e);if(!i){let t=i;i=s;s=t}let n=i.marks;for(var r=0;r<n.length;r++)if(n[r].type.spec.inclusive===false&&(!s||!n[r].isInSet(s.marks)))n=n[r--].removeFromSet(n);return n}marksAcross(t){let e=this.parent.maybeChild(this.index());if(!e||!e.isInline)return null;let i=e.marks,s=t.parent.maybeChild(t.index());for(var n=0;n<i.length;n++)if(i[n].type.spec.inclusive===false&&(!s||!i[n].isInSet(s.marks)))i=i[n--].removeFromSet(i);return i}sharedDepth(t){for(let e=this.depth;e>0;e--)if(this.start(e)<=t&&this.end(e)>=t)return e;return 0}blockRange(t=this,e){if(t.pos<this.pos)return t.blockRange(this);for(let i=this.depth-(this.parent.inlineContent||this.pos==t.pos?1:0);i>=0;i--)if(t.pos<=this.end(i)&&(!e||e(this.node(i))))return new P(this,t,i);return null}sameParent(t){return this.pos-this.parentOffset==t.pos-t.parentOffset}max(t){return t.pos>this.pos?t:this}min(t){return t.pos<this.pos?t:this}toString(){let t="";for(let e=1;e<=this.depth;e++)t+=(t?"/":"")+this.node(e).type.name+"_"+this.index(e-1);return t+":"+this.parentOffset}static resolve(t,e){if(!(e>=0&&e<=t.content.size))throw new RangeError("Position "+e+" out of range");let i=[];let s=0,n=e;for(let e=t;;){let{index:t,offset:r}=e.content.findIndex(n);let o=n-r;i.push(e,t,s+r);if(!o)break;e=e.child(t);if(e.isText)break;n=o-1;s+=r+1}return new E(e,i,n)}static resolveCached(t,e){let i=I.get(t);if(i){for(let t=0;t<i.elts.length;t++){let s=i.elts[t];if(s.pos==e)return s}}else{I.set(t,i=new T)}let s=i.elts[i.i]=E.resolve(t,e);i.i=(i.i+1)%D;return s}}class T{constructor(){this.elts=[];this.i=0}}const D=12,I=new WeakMap;class P{constructor(t,e,i){this.$from=t;this.$to=e;this.depth=i}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const R=Object.create(null);class ${constructor(t,e,i,s=d.none){this.type=t;this.attrs=e;this.marks=s;this.content=i||f.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(t){return this.content.child(t)}maybeChild(t){return this.content.maybeChild(t)}forEach(t){this.content.forEach(t)}nodesBetween(t,e,i,s=0){this.content.nodesBetween(t,e,i,s,this)}descendants(t){this.nodesBetween(0,this.content.size,t)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(t,e,i,s){return this.content.textBetween(t,e,i,s)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(t){return this==t||this.sameMarkup(t)&&this.content.eq(t.content)}sameMarkup(t){return this.hasMarkup(t.type,t.attrs,t.marks)}hasMarkup(t,e,i){return this.type==t&&a(this.attrs,e||t.defaultAttrs||R)&&d.sameSet(this.marks,i||d.none)}copy(t=null){if(t==this.content)return this;return new $(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new $(this.type,this.attrs,this.content,t)}cut(t,e=this.content.size){if(t==0&&e==this.content.size)return this;return this.copy(this.content.cut(t,e))}slice(t,e=this.content.size,i=false){if(t==e)return p.empty;let s=this.resolve(t),n=this.resolve(e);let r=i?0:s.sharedDepth(e);let o=s.start(r),h=s.node(r);let l=h.content.cut(s.pos-o,n.pos-o);return new p(l,s.depth-r,n.depth-r)}replace(t,e,i){return y(this.resolve(t),this.resolve(e),i)}nodeAt(t){for(let e=this;;){let{index:i,offset:s}=e.content.findIndex(t);e=e.maybeChild(i);if(!e)return null;if(s==t||e.isText)return e;t-=s+1}}childAfter(t){let{index:e,offset:i}=this.content.findIndex(t);return{node:this.content.maybeChild(e),index:e,offset:i}}childBefore(t){if(t==0)return{node:null,index:0,offset:0};let{index:e,offset:i}=this.content.findIndex(t);if(i<t)return{node:this.content.child(e),index:e,offset:i};let s=this.content.child(e-1);return{node:s,index:e-1,offset:i-s.nodeSize}}resolve(t){return E.resolveCached(this,t)}resolveNoCache(t){return E.resolve(this,t)}rangeHasMark(t,e,i){let s=false;if(e>t)this.nodesBetween(t,e,(t=>{if(i.isInSet(t.marks))s=true;return!s}));return s}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let t=this.type.name;if(this.content.size)t+="("+this.content.toStringInner()+")";return j(this.marks,t)}contentMatchAt(t){let e=this.type.contentMatch.matchFragment(this.content,0,t);if(!e)throw new Error("Called contentMatchAt on a node with invalid content");return e}canReplace(t,e,i=f.empty,s=0,n=i.childCount){let r=this.contentMatchAt(t).matchFragment(i,s,n);let o=r&&r.matchFragment(this.content,e);if(!o||!o.validEnd)return false;for(let t=s;t<n;t++)if(!this.type.allowsMarks(i.child(t).marks))return false;return true}canReplaceWith(t,e,i,s){if(s&&!this.type.allowsMarks(s))return false;let n=this.contentMatchAt(t).matchType(i);let r=n&&n.matchFragment(this.content,e);return r?r.validEnd:false}canAppend(t){if(t.content.size)return this.canReplace(this.childCount,this.childCount,t.content);else return this.type.compatibleContent(t.type)}check(){this.type.checkContent(this.content);this.type.checkAttrs(this.attrs);let t=d.none;for(let e=0;e<this.marks.length;e++){let i=this.marks[e];i.type.checkAttrs(i.attrs);t=i.addToSet(t)}if(!d.sameSet(t,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map((t=>t.type.name))}`);this.content.forEach((t=>t.check()))}toJSON(){let t={type:this.type.name};for(let e in this.attrs){t.attrs=this.attrs;break}if(this.content.size)t.content=this.content.toJSON();if(this.marks.length)t.marks=this.marks.map((t=>t.toJSON()));return t}static fromJSON(t,e){if(!e)throw new RangeError("Invalid input for Node.fromJSON");let i=undefined;if(e.marks){if(!Array.isArray(e.marks))throw new RangeError("Invalid mark data for Node.fromJSON");i=e.marks.map(t.markFromJSON)}if(e.type=="text"){if(typeof e.text!="string")throw new RangeError("Invalid text node in JSON");return t.text(e.text,i)}let s=f.fromJSON(t,e.content);let n=t.nodeType(e.type).create(e.attrs,s,i);n.type.checkAttrs(n.attrs);return n}}$.prototype.text=undefined;class U extends ${constructor(t,e,i,s){super(t,e,null,s);if(!i)throw new RangeError("Empty text nodes are not allowed");this.text=i}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);return j(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(t,e){return this.text.slice(t,e)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new U(this.type,this.attrs,this.text,t)}withText(t){if(t==this.text)return this;return new U(this.type,this.attrs,t,this.marks)}cut(t=0,e=this.text.length){if(t==0&&e==this.text.length)return this;return this.withText(this.text.slice(t,e))}eq(t){return this.sameMarkup(t)&&this.text==t.text}toJSON(){let t=super.toJSON();t.text=this.text;return t}}function j(t,e){for(let i=t.length-1;i>=0;i--)e=t[i].type.name+"("+e+")";return e}class B{constructor(t){this.validEnd=t;this.next=[];this.wrapCache=[]}static parse(t,e){let i=new F(t,e);if(i.next==null)return B.empty;let s=N(i);if(i.next)i.err("Unexpected trailing text");let n=Q(J(s));q(n,i);return n}matchType(t){for(let e=0;e<this.next.length;e++)if(this.next[e].type==t)return this.next[e].next;return null}matchFragment(t,e=0,i=t.childCount){let s=this;for(let n=e;s&&n<i;n++)s=s.matchType(t.child(n).type);return s}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let t=0;t<this.next.length;t++){let{type:e}=this.next[t];if(!(e.isText||e.hasRequiredAttrs()))return e}return null}compatible(t){for(let e=0;e<this.next.length;e++)for(let i=0;i<t.next.length;i++)if(this.next[e].type==t.next[i].type)return true;return false}fillBefore(t,e=false,i=0){let s=[this];function n(r,o){let h=r.matchFragment(t,i);if(h&&(!e||h.validEnd))return f.from(o.map((t=>t.createAndFill())));for(let t=0;t<r.next.length;t++){let{type:e,next:i}=r.next[t];if(!(e.isText||e.hasRequiredAttrs())&&s.indexOf(i)==-1){s.push(i);let t=n(i,o.concat(e));if(t)return t}}return null}return n(this,[])}findWrapping(t){for(let e=0;e<this.wrapCache.length;e+=2)if(this.wrapCache[e]==t)return this.wrapCache[e+1];let e=this.computeWrapping(t);this.wrapCache.push(t,e);return e}computeWrapping(t){let e=Object.create(null),i=[{match:this,type:null,via:null}];while(i.length){let s=i.shift(),n=s.match;if(n.matchType(t)){let t=[];for(let e=s;e.type;e=e.via)t.push(e.type);return t.reverse()}for(let t=0;t<n.next.length;t++){let{type:r,next:o}=n.next[t];if(!r.isLeaf&&!r.hasRequiredAttrs()&&!(r.name in e)&&(!s.type||o.validEnd)){i.push({match:r.contentMatch,type:r,via:s});e[r.name]=true}}}return null}get edgeCount(){return this.next.length}edge(t){if(t>=this.next.length)throw new RangeError(`There's no ${t}th edge in this content match`);return this.next[t]}toString(){let t=[];function e(i){t.push(i);for(let s=0;s<i.next.length;s++)if(t.indexOf(i.next[s].next)==-1)e(i.next[s].next)}e(this);return t.map(((e,i)=>{let s=i+(e.validEnd?"*":" ")+" ";for(let i=0;i<e.next.length;i++)s+=(i?", ":"")+e.next[i].type.name+"->"+t.indexOf(e.next[i].next);return s})).join("\n")}}B.empty=new B(true);class F{constructor(t,e){this.string=t;this.nodeTypes=e;this.inline=null;this.pos=0;this.tokens=t.split(/\s*(?=\b|\W|$)/);if(this.tokens[this.tokens.length-1]=="")this.tokens.pop();if(this.tokens[0]=="")this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(t){return this.next==t&&(this.pos++||true)}err(t){throw new SyntaxError(t+" (in content expression '"+this.string+"')")}}function N(t){let e=[];do{e.push(L(t))}while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function L(t){let e=[];do{e.push(_(t))}while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function _(t){let e=W(t);for(;;){if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=Y(t,e);else break}return e}function z(t){if(/\D/.test(t.next))t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);t.pos++;return e}function Y(t,e){let i=z(t),s=i;if(t.eat(",")){if(t.next!="}")s=z(t);else s=-1}if(!t.eat("}"))t.err("Unclosed braced range");return{type:"range",min:i,max:s,expr:e}}function X(t,e){let i=t.nodeTypes,s=i[e];if(s)return[s];let n=[];for(let t in i){let s=i[t];if(s.isInGroup(e))n.push(s)}if(n.length==0)t.err("No node type or group '"+e+"' found");return n}function W(t){if(t.eat("(")){let e=N(t);if(!t.eat(")"))t.err("Missing closing paren");return e}else if(!/\W/.test(t.next)){let e=X(t,t.next).map((e=>{if(t.inline==null)t.inline=e.isInline;else if(t.inline!=e.isInline)t.err("Mixing inline and block content");return{type:"name",value:e}}));t.pos++;return e.length==1?e[0]:{type:"choice",exprs:e}}else{t.err("Unexpected token '"+t.next+"'")}}function J(t){let e=[[]];n(r(t,0),i());return e;function i(){return e.push([])-1}function s(t,i,s){let n={term:s,to:i};e[t].push(n);return n}function n(t,e){t.forEach((t=>t.to=e))}function r(t,e){if(t.type=="choice"){return t.exprs.reduce(((t,i)=>t.concat(r(i,e))),[])}else if(t.type=="seq"){for(let s=0;;s++){let o=r(t.exprs[s],e);if(s==t.exprs.length-1)return o;n(o,e=i())}}else if(t.type=="star"){let o=i();s(e,o);n(r(t.expr,o),o);return[s(o)]}else if(t.type=="plus"){let o=i();n(r(t.expr,e),o);n(r(t.expr,o),o);return[s(o)]}else if(t.type=="opt"){return[s(e)].concat(r(t.expr,e))}else if(t.type=="range"){let o=e;for(let e=0;e<t.min;e++){let e=i();n(r(t.expr,o),e);o=e}if(t.max==-1){n(r(t.expr,o),o)}else{for(let e=t.min;e<t.max;e++){let e=i();s(o,e);n(r(t.expr,o),e);o=e}}return[s(o)]}else if(t.type=="name"){return[s(e,undefined,t.value)]}else{throw new Error("Unknown expr type")}}}function H(t,e){return e-t}function V(t,e){let i=[];s(e);return i.sort(H);function s(e){let n=t[e];if(n.length==1&&!n[0].term)return s(n[0].to);i.push(e);for(let t=0;t<n.length;t++){let{term:e,to:r}=n[t];if(!e&&i.indexOf(r)==-1)s(r)}}}function Q(t){let e=Object.create(null);return i(V(t,0));function i(s){let n=[];s.forEach((e=>{t[e].forEach((({term:e,to:i})=>{if(!e)return;let s;for(let t=0;t<n.length;t++)if(n[t][0]==e)s=n[t][1];V(t,i).forEach((t=>{if(!s)n.push([e,s=[]]);if(s.indexOf(t)==-1)s.push(t)}))}))}));let r=e[s.join(",")]=new B(s.indexOf(t.length-1)>-1);for(let t=0;t<n.length;t++){let s=n[t][1].sort(H);r.next.push({type:n[t][0],next:e[s.join(",")]||i(s)})}return r}}function q(t,e){for(let i=0,s=[t];i<s.length;i++){let t=s[i],n=!t.validEnd,r=[];for(let e=0;e<t.next.length;e++){let{type:i,next:o}=t.next[e];r.push(i.name);if(n&&!(i.isText||i.hasRequiredAttrs()))n=false;if(s.indexOf(o)==-1)s.push(o)}if(n)e.err("Only non-generatable nodes ("+r.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function K(t){let e=Object.create(null);for(let i in t){let s=t[i];if(!s.hasDefault)return null;e[i]=s.default}return e}function G(t,e){let i=Object.create(null);for(let s in t){let n=e&&e[s];if(n===undefined){let e=t[s];if(e.hasDefault)n=e.default;else throw new RangeError("No value supplied for attribute "+s)}i[s]=n}return i}function Z(t,e,i,s){for(let s in e)if(!(s in t))throw new RangeError(`Unsupported attribute ${s} for ${i} of type ${s}`);for(let i in t){let s=t[i];if(s.validate)s.validate(e[i])}}function tt(t,e){let i=Object.create(null);if(e)for(let s in e)i[s]=new st(t,s,e[s]);return i}let et=class t{constructor(t,e,i){this.name=t;this.schema=e;this.spec=i;this.markSet=null;this.groups=i.group?i.group.split(" "):[];this.attrs=tt(t,i.attrs);this.defaultAttrs=K(this.attrs);this.contentMatch=null;this.inlineContent=null;this.isBlock=!(i.inline||t=="text");this.isText=t=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==B.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(t){return this.groups.indexOf(t)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let t in this.attrs)if(this.attrs[t].isRequired)return true;return false}compatibleContent(t){return this==t||this.contentMatch.compatible(t.contentMatch)}computeAttrs(t){if(!t&&this.defaultAttrs)return this.defaultAttrs;else return G(this.attrs,t)}create(t=null,e,i){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new $(this,this.computeAttrs(t),f.from(e),d.setFrom(i))}createChecked(t=null,e,i){e=f.from(e);this.checkContent(e);return new $(this,this.computeAttrs(t),e,d.setFrom(i))}createAndFill(t=null,e,i){t=this.computeAttrs(t);e=f.from(e);if(e.size){let t=this.contentMatch.fillBefore(e);if(!t)return null;e=t.append(e)}let s=this.contentMatch.matchFragment(e);let n=s&&s.fillBefore(f.empty,true);if(!n)return null;return new $(this,t,e.append(n),d.setFrom(i))}validContent(t){let e=this.contentMatch.matchFragment(t);if(!e||!e.validEnd)return false;for(let e=0;e<t.childCount;e++)if(!this.allowsMarks(t.child(e).marks))return false;return true}checkContent(t){if(!this.validContent(t))throw new RangeError(`Invalid content for node ${this.name}: ${t.toString().slice(0,50)}`)}checkAttrs(t){Z(this.attrs,t,"node")}allowsMarkType(t){return this.markSet==null||this.markSet.indexOf(t)>-1}allowsMarks(t){if(this.markSet==null)return true;for(let e=0;e<t.length;e++)if(!this.allowsMarkType(t[e].type))return false;return true}allowedMarks(t){if(this.markSet==null)return t;let e;for(let i=0;i<t.length;i++){if(!this.allowsMarkType(t[i].type)){if(!e)e=t.slice(0,i)}else if(e){e.push(t[i])}}return!e?t:e.length?e:d.none}static compile(e,i){let s=Object.create(null);e.forEach(((e,n)=>s[e]=new t(e,i,n)));let n=i.spec.topNode||"doc";if(!s[n])throw new RangeError("Schema is missing its top node type ('"+n+"')");if(!s.text)throw new RangeError("Every schema needs a 'text' type");for(let t in s.text.attrs)throw new RangeError("The text node type should not have attributes");return s}};function it(t,e,i){let s=i.split("|");return i=>{let n=i===null?"null":typeof i;if(s.indexOf(n)<0)throw new RangeError(`Expected value of type ${s} for attribute ${e} on type ${t}, got ${n}`)}}class st{constructor(t,e,i){this.hasDefault=Object.prototype.hasOwnProperty.call(i,"default");this.default=i.default;this.validate=typeof i.validate=="string"?it(t,e,i.validate):i.validate}get isRequired(){return!this.hasDefault}}class nt{constructor(t,e,i,s){this.name=t;this.rank=e;this.schema=i;this.spec=s;this.attrs=tt(t,s.attrs);this.excluded=null;let n=K(this.attrs);this.instance=n?new d(this,n):null}create(t=null){if(!t&&this.instance)return this.instance;return new d(this,G(this.attrs,t))}static compile(t,e){let i=Object.create(null),s=0;t.forEach(((t,n)=>i[t]=new nt(t,s++,e,n)));return i}removeFromSet(t){for(var e=0;e<t.length;e++)if(t[e].type==this){t=t.slice(0,e).concat(t.slice(e+1));e--}return t}isInSet(t){for(let e=0;e<t.length;e++)if(t[e].type==this)return t[e]}checkAttrs(t){Z(this.attrs,t,"mark")}excludes(t){return this.excluded.indexOf(t)>-1}}class rt{constructor(t){this.linebreakReplacement=null;this.cached=Object.create(null);let e=this.spec={};for(let i in t)e[i]=t[i];e.nodes=o.from(t.nodes),e.marks=o.from(t.marks||{}),this.nodes=et.compile(this.spec.nodes,this);this.marks=nt.compile(this.spec.marks,this);let i=Object.create(null);for(let t in this.nodes){if(t in this.marks)throw new RangeError(t+" can not be both a node and a mark");let e=this.nodes[t],s=e.spec.content||"",n=e.spec.marks;e.contentMatch=i[s]||(i[s]=B.parse(s,this.nodes));e.inlineContent=e.contentMatch.inlineContent;if(e.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!e.isInline||!e.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=e}e.markSet=n=="_"?null:n?ot(this,n.split(" ")):n==""||!e.inlineContent?[]:null}for(let t in this.marks){let e=this.marks[t],i=e.spec.excludes;e.excluded=i==null?[e]:i==""?[]:ot(this,i.split(" "))}this.nodeFromJSON=t=>$.fromJSON(this,t);this.markFromJSON=t=>d.fromJSON(this,t);this.topNodeType=this.nodes[this.spec.topNode||"doc"];this.cached.wrappings=Object.create(null)}node(t,e=null,i,s){if(typeof t=="string")t=this.nodeType(t);else if(!(t instanceof et))throw new RangeError("Invalid node type: "+t);else if(t.schema!=this)throw new RangeError("Node type from different schema used ("+t.name+")");return t.createChecked(e,i,s)}text(t,e){let i=this.nodes.text;return new U(i,i.defaultAttrs,t,d.setFrom(e))}mark(t,e){if(typeof t=="string")t=this.marks[t];return t.create(e)}nodeType(t){let e=this.nodes[t];if(!e)throw new RangeError("Unknown node type: "+t);return e}}function ot(t,e){let i=[];for(let s=0;s<e.length;s++){let n=e[s],r=t.marks[n],o=r;if(r){i.push(r)}else{for(let e in t.marks){let s=t.marks[e];if(n=="_"||s.spec.group&&s.spec.group.split(" ").indexOf(n)>-1)i.push(o=s)}}if(!o)throw new SyntaxError("Unknown mark type: '"+e[s]+"'")}return i}function ht(t){return t.tag!=null}function lt(t){return t.style!=null}let ft=class t{constructor(t,e){this.schema=t;this.rules=e;this.tags=[];this.styles=[];let i=this.matchedStyles=[];e.forEach((t=>{if(ht(t)){this.tags.push(t)}else if(lt(t)){let e=/[^=]*/.exec(t.style)[0];if(i.indexOf(e)<0)i.push(e);this.styles.push(t)}}));this.normalizeLists=!this.tags.some((e=>{if(!/^(ul|ol)\b/.test(e.tag)||!e.node)return false;let i=t.nodes[e.node];return i.contentMatch.matchType(i)}))}parse(t,e={}){let i=new yt(this,e,false);i.addAll(t,d.none,e.from,e.to);return i.finish()}parseSlice(t,e={}){let i=new yt(this,e,true);i.addAll(t,d.none,e.from,e.to);return p.maxOpen(i.finish())}matchTag(t,e,i){for(let s=i?this.tags.indexOf(i)+1:0;s<this.tags.length;s++){let i=this.tags[s];if(bt(t,i.tag)&&(i.namespace===undefined||t.namespaceURI==i.namespace)&&(!i.context||e.matchesContext(i.context))){if(i.getAttrs){let e=i.getAttrs(t);if(e===false)continue;i.attrs=e||undefined}return i}}}matchStyle(t,e,i,s){for(let n=s?this.styles.indexOf(s)+1:0;n<this.styles.length;n++){let s=this.styles[n],r=s.style;if(r.indexOf(t)!=0||s.context&&!i.matchesContext(s.context)||r.length>t.length&&(r.charCodeAt(t.length)!=61||r.slice(t.length+1)!=e))continue;if(s.getAttrs){let t=s.getAttrs(e);if(t===false)continue;s.attrs=t||undefined}return s}}static schemaRules(t){let e=[];function i(t){let i=t.priority==null?50:t.priority,s=0;for(;s<e.length;s++){let t=e[s],n=t.priority==null?50:t.priority;if(n<i)break}e.splice(s,0,t)}for(let e in t.marks){let s=t.marks[e].spec.parseDOM;if(s)s.forEach((t=>{i(t=Mt(t));if(!(t.mark||t.ignore||t.clearMark))t.mark=e}))}for(let e in t.nodes){let s=t.nodes[e].spec.parseDOM;if(s)s.forEach((t=>{i(t=Mt(t));if(!(t.node||t.ignore||t.mark))t.node=e}))}return e}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new t(e,t.schemaRules(e)))}};const ut={address:true,article:true,aside:true,blockquote:true,canvas:true,dd:true,div:true,dl:true,fieldset:true,figcaption:true,figure:true,footer:true,form:true,h1:true,h2:true,h3:true,h4:true,h5:true,h6:true,header:true,hgroup:true,hr:true,li:true,noscript:true,ol:true,output:true,p:true,pre:true,section:true,table:true,tfoot:true,ul:true};const ct={head:true,noscript:true,object:true,script:true,style:true,title:true};const at={ol:true,ul:true};const dt=1,wt=2,pt=4;function gt(t,e,i){if(e!=null)return(e?dt:0)|(e==="full"?wt:0);return t&&t.whitespace=="pre"?dt|wt:i&-5}class mt{constructor(t,e,i,s,n,r){this.type=t;this.attrs=e;this.marks=i;this.solid=s;this.options=r;this.content=[];this.activeMarks=d.none;this.match=n||(r&pt?null:t.contentMatch)}findWrapping(t){if(!this.match){if(!this.type)return[];let e=this.type.contentMatch.fillBefore(f.from(t));if(e){this.match=this.type.contentMatch.matchFragment(e)}else{let e=this.type.contentMatch,i;if(i=e.findWrapping(t.type)){this.match=e;return i}else{return null}}}return this.match.findWrapping(t.type)}finish(t){if(!(this.options&dt)){let t=this.content[this.content.length-1],e;if(t&&t.isText&&(e=/[ \t\r\n\u000c]+$/.exec(t.text))){let i=t;if(t.text.length==e[0].length)this.content.pop();else this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-e[0].length))}}let e=f.from(this.content);if(!t&&this.match)e=e.append(this.match.fillBefore(f.empty,true));return this.type?this.type.create(this.attrs,e,this.marks):e}inlineContext(t){if(this.type)return this.type.inlineContent;if(this.content.length)return this.content[0].isInline;return t.parentNode&&!ut.hasOwnProperty(t.parentNode.nodeName.toLowerCase())}}class yt{constructor(t,e,i){this.parser=t;this.options=e;this.isOpen=i;this.open=0;this.localPreserveWS=false;let s=e.topNode,n;let r=gt(null,e.preserveWhitespace,0)|(i?pt:0);if(s)n=new mt(s.type,s.attrs,d.none,true,e.topMatch||s.type.contentMatch,r);else if(i)n=new mt(null,null,d.none,true,null,r);else n=new mt(t.schema.topNodeType,null,d.none,true,null,r);this.nodes=[n];this.find=e.findPositions;this.needsBlock=false}get top(){return this.nodes[this.open]}addDOM(t,e){if(t.nodeType==3)this.addTextNode(t,e);else if(t.nodeType==1)this.addElement(t,e)}addTextNode(t,e){let i=t.nodeValue;let s=this.top,n=s.options&wt?"full":this.localPreserveWS||(s.options&dt)>0;let{schema:r}=this.parser;if(n==="full"||s.inlineContext(t)||/[^ \t\r\n\u000c]/.test(i)){if(!n){i=i.replace(/[ \t\r\n\u000c]+/g," ");if(/^[ \t\r\n\u000c]/.test(i)&&this.open==this.nodes.length-1){let e=s.content[s.content.length-1];let n=t.previousSibling;if(!e||n&&n.nodeName=="BR"||e.isText&&/[ \t\r\n\u000c]$/.test(e.text))i=i.slice(1)}}else if(n==="full"){i=i.replace(/\r\n?/g,"\n")}else if(r.linebreakReplacement&&/[\r\n]/.test(i)&&this.top.findWrapping(r.linebreakReplacement.create())){let t=i.split(/\r?\n|\r/);for(let i=0;i<t.length;i++){if(i)this.insertNode(r.linebreakReplacement.create(),e,true);if(t[i])this.insertNode(r.text(t[i]),e,!/\S/.test(t[i]))}i=""}else{i=i.replace(/\r?\n|\r/g," ")}if(i)this.insertNode(r.text(i),e,!/\S/.test(i));this.findInText(t)}else{this.findInside(t)}}addElement(t,e,i){let s=this.localPreserveWS,n=this.top;if(t.tagName=="PRE"||/pre/.test(t.style&&t.style.whiteSpace))this.localPreserveWS=true;let r=t.nodeName.toLowerCase(),o;if(at.hasOwnProperty(r)&&this.parser.normalizeLists)vt(t);let h=this.options.ruleFromNode&&this.options.ruleFromNode(t)||(o=this.parser.matchTag(t,this,i));t:if(h?h.ignore:ct.hasOwnProperty(r)){this.findInside(t);this.ignoreFallback(t,e)}else if(!h||h.skip||h.closeParent){if(h&&h.closeParent)this.open=Math.max(0,this.open-1);else if(h&&h.skip.nodeType)t=h.skip;let i,s=this.needsBlock;if(ut.hasOwnProperty(r)){if(n.content.length&&n.content[0].isInline&&this.open){this.open--;n=this.top}i=true;if(!n.type)this.needsBlock=true}else if(!t.firstChild){this.leafFallback(t,e);break t}let o=h&&h.skip?e:this.readStyles(t,e);if(o)this.addAll(t,o);if(i)this.sync(n);this.needsBlock=s}else{let i=this.readStyles(t,e);if(i)this.addElementByRule(t,h,i,h.consuming===false?o:undefined)}this.localPreserveWS=s}leafFallback(t,e){if(t.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent)this.addTextNode(t.ownerDocument.createTextNode("\n"),e)}ignoreFallback(t,e){if(t.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent))this.findPlace(this.parser.schema.text("-"),e,true)}readStyles(t,e){let i=t.style;if(i&&i.length)for(let t=0;t<this.parser.matchedStyles.length;t++){let s=this.parser.matchedStyles[t],n=i.getPropertyValue(s);if(n)for(let t=undefined;;){let i=this.parser.matchStyle(s,n,this,t);if(!i)break;if(i.ignore)return null;if(i.clearMark)e=e.filter((t=>!i.clearMark(t)));else e=e.concat(this.parser.schema.marks[i.mark].create(i.attrs));if(i.consuming===false)t=i;else break}}return e}addElementByRule(t,e,i,s){let n,r;if(e.node){r=this.parser.schema.nodes[e.node];if(!r.isLeaf){let t=this.enter(r,e.attrs||null,i,e.preserveWhitespace);if(t){n=true;i=t}}else if(!this.insertNode(r.create(e.attrs),i,t.nodeName=="BR")){this.leafFallback(t,i)}}else{let t=this.parser.schema.marks[e.mark];i=i.concat(t.create(e.attrs))}let o=this.top;if(r&&r.isLeaf){this.findInside(t)}else if(s){this.addElement(t,i,s)}else if(e.getContent){this.findInside(t);e.getContent(t,this.parser.schema).forEach((t=>this.insertNode(t,i,false)))}else{let s=t;if(typeof e.contentElement=="string")s=t.querySelector(e.contentElement);else if(typeof e.contentElement=="function")s=e.contentElement(t);else if(e.contentElement)s=e.contentElement;this.findAround(t,s,true);this.addAll(s,i);this.findAround(t,s,false)}if(n&&this.sync(o))this.open--}addAll(t,e,i,s){let n=i||0;for(let r=i?t.childNodes[i]:t.firstChild,o=s==null?null:t.childNodes[s];r!=o;r=r.nextSibling,++n){this.findAtPoint(t,n);this.addDOM(r,e)}this.findAtPoint(t,n)}findPlace(t,e,i){let s,n;for(let e=this.open,r=0;e>=0;e--){let o=this.nodes[e];let h=o.findWrapping(t);if(h&&(!s||s.length>h.length+r)){s=h;n=o;if(!h.length)break}if(o.solid){if(i)break;r+=2}}if(!s)return null;this.sync(n);for(let t=0;t<s.length;t++)e=this.enterInner(s[t],null,e,false);return e}insertNode(t,e,i){if(t.isInline&&this.needsBlock&&!this.top.type){let t=this.textblockFromContext();if(t)e=this.enterInner(t,null,e)}let s=this.findPlace(t,e,i);if(s){this.closeExtra();let e=this.top;if(e.match)e.match=e.match.matchType(t.type);let i=d.none;for(let n of s.concat(t.marks))if(e.type?e.type.allowsMarkType(n.type):kt(n.type,t.type))i=n.addToSet(i);e.content.push(t.mark(i));return true}return false}enter(t,e,i,s){let n=this.findPlace(t.create(e),i,false);if(n)n=this.enterInner(t,e,i,true,s);return n}enterInner(t,e,i,s=false,n){this.closeExtra();let r=this.top;r.match=r.match&&r.match.matchType(t);let o=gt(t,n,r.options);if(r.options&pt&&r.content.length==0)o|=pt;let h=d.none;i=i.filter((e=>{if(r.type?r.type.allowsMarkType(e.type):kt(e.type,t)){h=e.addToSet(h);return false}return true}));this.nodes.push(new mt(t,e,h,s,null,o));this.open++;return i}closeExtra(t=false){let e=this.nodes.length-1;if(e>this.open){for(;e>this.open;e--)this.nodes[e-1].content.push(this.nodes[e].finish(t));this.nodes.length=this.open+1}}finish(){this.open=0;this.closeExtra(this.isOpen);return this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(t){for(let e=this.open;e>=0;e--){if(this.nodes[e]==t){this.open=e;return true}else if(this.localPreserveWS){this.nodes[e].options|=dt}}return false}get currentPos(){this.closeExtra();let t=0;for(let e=this.open;e>=0;e--){let i=this.nodes[e].content;for(let e=i.length-1;e>=0;e--)t+=i[e].nodeSize;if(e)t++}return t}findAtPoint(t,e){if(this.find)for(let i=0;i<this.find.length;i++){if(this.find[i].node==t&&this.find[i].offset==e)this.find[i].pos=this.currentPos}}findInside(t){if(this.find)for(let e=0;e<this.find.length;e++){if(this.find[e].pos==null&&t.nodeType==1&&t.contains(this.find[e].node))this.find[e].pos=this.currentPos}}findAround(t,e,i){if(t!=e&&this.find)for(let s=0;s<this.find.length;s++){if(this.find[s].pos==null&&t.nodeType==1&&t.contains(this.find[s].node)){let t=e.compareDocumentPosition(this.find[s].node);if(t&(i?2:4))this.find[s].pos=this.currentPos}}}findInText(t){if(this.find)for(let e=0;e<this.find.length;e++){if(this.find[e].node==t)this.find[e].pos=this.currentPos-(t.nodeValue.length-this.find[e].offset)}}matchesContext(t){if(t.indexOf("|")>-1)return t.split(/\s*\|\s*/).some(this.matchesContext,this);let e=t.split("/");let i=this.options.context;let s=!this.isOpen&&(!i||i.parent.type==this.nodes[0].type);let n=-(i?i.depth+1:0)+(s?0:1);let r=(t,o)=>{for(;t>=0;t--){let h=e[t];if(h==""){if(t==e.length-1||t==0)continue;for(;o>=n;o--)if(r(t-1,o))return true;return false}else{let t=o>0||o==0&&s?this.nodes[o].type:i&&o>=n?i.node(o-n).type:null;if(!t||t.name!=h&&!t.isInGroup(h))return false;o--}}return true};return r(e.length-1,this.open)}textblockFromContext(){let t=this.options.context;if(t)for(let e=t.depth;e>=0;e--){let i=t.node(e).contentMatchAt(t.indexAfter(e)).defaultType;if(i&&i.isTextblock&&i.defaultAttrs)return i}for(let t in this.parser.schema.nodes){let e=this.parser.schema.nodes[t];if(e.isTextblock&&e.defaultAttrs)return e}}}function vt(t){for(let e=t.firstChild,i=null;e;e=e.nextSibling){let t=e.nodeType==1?e.nodeName.toLowerCase():null;if(t&&at.hasOwnProperty(t)&&i){i.appendChild(e);e=i}else if(t=="li"){i=e}else if(t){i=null}}}function bt(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function Mt(t){let e={};for(let i in t)e[i]=t[i];return e}function kt(t,e){let i=e.schema.nodes;for(let s in i){let n=i[s];if(!n.allowsMarkType(t))continue;let r=[],o=t=>{r.push(t);for(let i=0;i<t.edgeCount;i++){let{type:s,next:n}=t.edge(i);if(s==e)return true;if(r.indexOf(n)<0&&o(n))return true}};if(o(n.contentMatch))return true}}class At{constructor(t,e){this.nodes=t;this.marks=e}serializeFragment(t,e={},i){if(!i)i=St(e).createDocumentFragment();let s=i,n=[];t.forEach((t=>{if(n.length||t.marks.length){let i=0,r=0;while(i<n.length&&r<t.marks.length){let e=t.marks[r];if(!this.marks[e.type.name]){r++;continue}if(!e.eq(n[i][0])||e.type.spec.spanning===false)break;i++;r++}while(i<n.length)s=n.pop()[1];while(r<t.marks.length){let i=t.marks[r++];let o=this.serializeMark(i,t.isInline,e);if(o){n.push([i,s]);s.appendChild(o.dom);s=o.contentDOM||o.dom}}}s.appendChild(this.serializeNodeInner(t,e))}));return i}serializeNodeInner(t,e){let{dom:i,contentDOM:s}=Tt(St(e),this.nodes[t.type.name](t),null,t.attrs);if(s){if(t.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(t.content,e,s)}return i}serializeNode(t,e={}){let i=this.serializeNodeInner(t,e);for(let s=t.marks.length-1;s>=0;s--){let n=this.serializeMark(t.marks[s],t.isInline,e);if(n){(n.contentDOM||n.dom).appendChild(i);i=n.dom}}return i}serializeMark(t,e,i={}){let s=this.marks[t.type.name];return s&&Tt(St(i),s(t,e),null,t.attrs)}static renderSpec(t,e,i=null,s){return Tt(t,e,i,s)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new At(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(t){let e=xt(t.nodes);if(!e.text)e.text=t=>t.text;return e}static marksFromSchema(t){return xt(t.marks)}}function xt(t){let e={};for(let i in t){let s=t[i].spec.toDOM;if(s)e[i]=s}return e}function St(t){return t.document||window.document}const Ct=new WeakMap;function Ot(t){let e=Ct.get(t);if(e===undefined)Ct.set(t,e=Et(t));return e}function Et(t){let e=null;function i(t){if(t&&typeof t=="object"){if(Array.isArray(t)){if(typeof t[0]=="string"){if(!e)e=[];e.push(t)}else{for(let e=0;e<t.length;e++)i(t[e])}}else{for(let e in t)i(t[e])}}}i(t);return e}function Tt(t,e,i,s){if(typeof e=="string")return{dom:t.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let n=e[0],r;if(typeof n!="string")throw new RangeError("Invalid array passed to renderSpec");if(s&&(r=Ot(s))&&r.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=n.indexOf(" ");if(o>0){i=n.slice(0,o);n=n.slice(o+1)}let h;let l=i?t.createElementNS(i,n):t.createElement(n);let f=e[1],u=1;if(f&&typeof f=="object"&&f.nodeType==null&&!Array.isArray(f)){u=2;for(let t in f)if(f[t]!=null){let e=t.indexOf(" ");if(e>0)l.setAttributeNS(t.slice(0,e),t.slice(e+1),f[t]);else if(t=="style"&&l.style)l.style.cssText=f[t];else l.setAttribute(t,f[t])}}for(let n=u;n<e.length;n++){let r=e[n];if(r===0){if(n<e.length-1||n>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else{let{dom:e,contentDOM:n}=Tt(t,r,i,s);l.appendChild(e);if(n){if(h)throw new RangeError("Multiple content holes");h=n}}}return{dom:l,contentDOM:h}}const Dt=65535;const It=Math.pow(2,16);function Pt(t,e){return t+e*It}function Rt(t){return t&Dt}function $t(t){return(t-(t&Dt))/It}const Ut=1,jt=2,Bt=4,Ft=8;class Nt{constructor(t,e,i){this.pos=t;this.delInfo=e;this.recover=i}get deleted(){return(this.delInfo&Ft)>0}get deletedBefore(){return(this.delInfo&(Ut|Bt))>0}get deletedAfter(){return(this.delInfo&(jt|Bt))>0}get deletedAcross(){return(this.delInfo&Bt)>0}}class Lt{constructor(t,e=false){this.ranges=t;this.inverted=e;if(!t.length&&Lt.empty)return Lt.empty}recover(t){let e=0,i=Rt(t);if(!this.inverted)for(let t=0;t<i;t++)e+=this.ranges[t*3+2]-this.ranges[t*3+1];return this.ranges[i*3]+e+$t(t)}mapResult(t,e=1){return this._map(t,e,false)}map(t,e=1){return this._map(t,e,true)}_map(t,e,i){let s=0,n=this.inverted?2:1,r=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let h=this.ranges[o]-(this.inverted?s:0);if(h>t)break;let l=this.ranges[o+n],f=this.ranges[o+r],u=h+l;if(t<=u){let n=!l?e:t==h?-1:t==u?1:e;let r=h+s+(n<0?0:f);if(i)return r;let c=t==(e<0?h:u)?null:Pt(o/3,t-h);let a=t==h?jt:t==u?Ut:Bt;if(e<0?t!=h:t!=u)a|=Ft;return new Nt(r,a,c)}s+=f-l}return i?t+s:new Nt(t+s,0,null)}touches(t,e){let i=0,s=Rt(e);let n=this.inverted?2:1,r=this.inverted?1:2;for(let e=0;e<this.ranges.length;e+=3){let o=this.ranges[e]-(this.inverted?i:0);if(o>t)break;let h=this.ranges[e+n],l=o+h;if(t<=l&&e==s*3)return true;i+=this.ranges[e+r]-h}return false}forEach(t){let e=this.inverted?2:1,i=this.inverted?1:2;for(let s=0,n=0;s<this.ranges.length;s+=3){let r=this.ranges[s],o=r-(this.inverted?n:0),h=r+(this.inverted?0:n);let l=this.ranges[s+e],f=this.ranges[s+i];t(o,o+l,h,h+f);n+=f-l}}invert(){return new Lt(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(t){return t==0?Lt.empty:new Lt(t<0?[0,-t,0]:[0,0,t])}}Lt.empty=new Lt([]);class _t{constructor(t,e,i=0,s=(t?t.length:0)){this.mirror=e;this.from=i;this.to=s;this._maps=t||[];this.ownData=!(t||e)}get maps(){return this._maps}slice(t=0,e=this.maps.length){return new _t(this._maps,this.mirror,t,e)}appendMap(t,e){if(!this.ownData){this._maps=this._maps.slice();this.mirror=this.mirror&&this.mirror.slice();this.ownData=true}this.to=this._maps.push(t);if(e!=null)this.setMirror(this._maps.length-1,e)}appendMapping(t){for(let e=0,i=this._maps.length;e<t._maps.length;e++){let s=t.getMirror(e);this.appendMap(t._maps[e],s!=null&&s<e?i+s:undefined)}}getMirror(t){if(this.mirror)for(let e=0;e<this.mirror.length;e++)if(this.mirror[e]==t)return this.mirror[e+(e%2?-1:1)]}setMirror(t,e){if(!this.mirror)this.mirror=[];this.mirror.push(t,e)}appendMappingInverted(t){for(let e=t.maps.length-1,i=this._maps.length+t._maps.length;e>=0;e--){let s=t.getMirror(e);this.appendMap(t._maps[e].invert(),s!=null&&s>e?i-s-1:undefined)}}invert(){let t=new _t;t.appendMappingInverted(this);return t}map(t,e=1){if(this.mirror)return this._map(t,e,true);for(let i=this.from;i<this.to;i++)t=this._maps[i].map(t,e);return t}mapResult(t,e=1){return this._map(t,e,false)}_map(t,e,i){let s=0;for(let i=this.from;i<this.to;i++){let n=this._maps[i],r=n.mapResult(t,e);if(r.recover!=null){let e=this.getMirror(i);if(e!=null&&e>i&&e<this.to){i=e;t=this._maps[e].recover(r.recover);continue}}s|=r.delInfo;t=r.pos}return i?t:new Nt(t,s,null)}}const zt=Object.create(null);class Yt{getMap(){return Lt.empty}merge(t){return null}static fromJSON(t,e){if(!e||!e.stepType)throw new RangeError("Invalid input for Step.fromJSON");let i=zt[e.stepType];if(!i)throw new RangeError(`No step type ${e.stepType} defined`);return i.fromJSON(t,e)}static jsonID(t,e){if(t in zt)throw new RangeError("Duplicate use of step JSON ID "+t);zt[t]=e;e.prototype.jsonID=t;return e}}class Xt{constructor(t,e){this.doc=t;this.failed=e}static ok(t){return new Xt(t,null)}static fail(t){return new Xt(null,t)}static fromReplace(t,e,i,s){try{return Xt.ok(t.replace(e,i,s))}catch(t){if(t instanceof w)return Xt.fail(t.message);throw t}}}function Wt(t,e,i){let s=[];for(let n=0;n<t.childCount;n++){let r=t.child(n);if(r.content.size)r=r.copy(Wt(r.content,e,r));if(r.isInline)r=e(r,i,n);s.push(r)}return f.fromArray(s)}class Jt extends Yt{constructor(t,e,i){super();this.from=t;this.to=e;this.mark=i}apply(t){let e=t.slice(this.from,this.to),i=t.resolve(this.from);let s=i.node(i.sharedDepth(this.to));let n=new p(Wt(e.content,((t,e)=>{if(!t.isAtom||!e.type.allowsMarkType(this.mark.type))return t;return t.mark(this.mark.addToSet(t.marks))}),s),e.openStart,e.openEnd);return Xt.fromReplace(t,this.from,this.to,n)}invert(){return new Ht(this.from,this.to,this.mark)}map(t){let e=t.mapResult(this.from,1),i=t.mapResult(this.to,-1);if(e.deleted&&i.deleted||e.pos>=i.pos)return null;return new Jt(e.pos,i.pos,this.mark)}merge(t){if(t instanceof Jt&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from)return new Jt(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark);return null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,e){if(typeof e.from!="number"||typeof e.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Jt(e.from,e.to,t.markFromJSON(e.mark))}}Yt.jsonID("addMark",Jt);class Ht extends Yt{constructor(t,e,i){super();this.from=t;this.to=e;this.mark=i}apply(t){let e=t.slice(this.from,this.to);let i=new p(Wt(e.content,(t=>t.mark(this.mark.removeFromSet(t.marks))),t),e.openStart,e.openEnd);return Xt.fromReplace(t,this.from,this.to,i)}invert(){return new Jt(this.from,this.to,this.mark)}map(t){let e=t.mapResult(this.from,1),i=t.mapResult(this.to,-1);if(e.deleted&&i.deleted||e.pos>=i.pos)return null;return new Ht(e.pos,i.pos,this.mark)}merge(t){if(t instanceof Ht&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from)return new Ht(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark);return null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,e){if(typeof e.from!="number"||typeof e.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Ht(e.from,e.to,t.markFromJSON(e.mark))}}Yt.jsonID("removeMark",Ht);class Vt extends Yt{constructor(t,e){super();this.pos=t;this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return Xt.fail("No node at mark step's position");let i=e.type.create(e.attrs,null,this.mark.addToSet(e.marks));return Xt.fromReplace(t,this.pos,this.pos+1,new p(f.from(i),0,e.isLeaf?0:1))}invert(t){let e=t.nodeAt(this.pos);if(e){let t=this.mark.addToSet(e.marks);if(t.length==e.marks.length){for(let i=0;i<e.marks.length;i++)if(!e.marks[i].isInSet(t))return new Vt(this.pos,e.marks[i]);return new Vt(this.pos,this.mark)}}return new Qt(this.pos,this.mark)}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new Vt(e.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,e){if(typeof e.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Vt(e.pos,t.markFromJSON(e.mark))}}Yt.jsonID("addNodeMark",Vt);class Qt extends Yt{constructor(t,e){super();this.pos=t;this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return Xt.fail("No node at mark step's position");let i=e.type.create(e.attrs,null,this.mark.removeFromSet(e.marks));return Xt.fromReplace(t,this.pos,this.pos+1,new p(f.from(i),0,e.isLeaf?0:1))}invert(t){let e=t.nodeAt(this.pos);if(!e||!this.mark.isInSet(e.marks))return this;return new Vt(this.pos,this.mark)}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new Qt(e.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,e){if(typeof e.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Qt(e.pos,t.markFromJSON(e.mark))}}Yt.jsonID("removeNodeMark",Qt);class qt extends Yt{constructor(t,e,i,s=false){super();this.from=t;this.to=e;this.slice=i;this.structure=s}apply(t){if(this.structure&&Gt(t,this.from,this.to))return Xt.fail("Structure replace would overwrite content");return Xt.fromReplace(t,this.from,this.to,this.slice)}getMap(){return new Lt([this.from,this.to-this.from,this.slice.size])}invert(t){return new qt(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let e=t.mapResult(this.from,1),i=t.mapResult(this.to,-1);if(e.deletedAcross&&i.deletedAcross)return null;return new qt(e.pos,Math.max(e.pos,i.pos),this.slice,this.structure)}merge(t){if(!(t instanceof qt)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let e=this.slice.size+t.slice.size==0?p.empty:new p(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new qt(this.from,this.to+(t.to-t.from),e,this.structure)}else if(t.to==this.from&&!this.slice.openStart&&!t.slice.openEnd){let e=this.slice.size+t.slice.size==0?p.empty:new p(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new qt(t.from,this.to,e,this.structure)}else{return null}}toJSON(){let t={stepType:"replace",from:this.from,to:this.to};if(this.slice.size)t.slice=this.slice.toJSON();if(this.structure)t.structure=true;return t}static fromJSON(t,e){if(typeof e.from!="number"||typeof e.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new qt(e.from,e.to,p.fromJSON(t,e.slice),!!e.structure)}}Yt.jsonID("replace",qt);class Kt extends Yt{constructor(t,e,i,s,n,r,o=false){super();this.from=t;this.to=e;this.gapFrom=i;this.gapTo=s;this.slice=n;this.insert=r;this.structure=o}apply(t){if(this.structure&&(Gt(t,this.from,this.gapFrom)||Gt(t,this.gapTo,this.to)))return Xt.fail("Structure gap-replace would overwrite content");let e=t.slice(this.gapFrom,this.gapTo);if(e.openStart||e.openEnd)return Xt.fail("Gap is not a flat range");let i=this.slice.insertAt(this.insert,e.content);if(!i)return Xt.fail("Content does not fit in gap");return Xt.fromReplace(t,this.from,this.to,i)}getMap(){return new Lt([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let e=this.gapTo-this.gapFrom;return new Kt(this.from,this.from+this.slice.size+e,this.from+this.insert,this.from+this.insert+e,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let e=t.mapResult(this.from,1),i=t.mapResult(this.to,-1);let s=this.from==this.gapFrom?e.pos:t.map(this.gapFrom,-1);let n=this.to==this.gapTo?i.pos:t.map(this.gapTo,1);if(e.deletedAcross&&i.deletedAcross||s<e.pos||n>i.pos)return null;return new Kt(e.pos,i.pos,s,n,this.slice,this.insert,this.structure)}toJSON(){let t={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};if(this.slice.size)t.slice=this.slice.toJSON();if(this.structure)t.structure=true;return t}static fromJSON(t,e){if(typeof e.from!="number"||typeof e.to!="number"||typeof e.gapFrom!="number"||typeof e.gapTo!="number"||typeof e.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Kt(e.from,e.to,e.gapFrom,e.gapTo,p.fromJSON(t,e.slice),e.insert,!!e.structure)}}Yt.jsonID("replaceAround",Kt);function Gt(t,e,i){let s=t.resolve(e),n=i-e,r=s.depth;while(n>0&&r>0&&s.indexAfter(r)==s.node(r).childCount){r--;n--}if(n>0){let t=s.node(r).maybeChild(s.indexAfter(r));while(n>0){if(!t||t.isLeaf)return true;t=t.firstChild;n--}}return false}function Zt(t,e,i,s){let n=[],r=[];let o,h;t.doc.nodesBetween(e,i,((t,l,f)=>{if(!t.isInline)return;let u=t.marks;if(!s.isInSet(u)&&f.type.allowsMarkType(s.type)){let f=Math.max(l,e),c=Math.min(l+t.nodeSize,i);let a=s.addToSet(u);for(let t=0;t<u.length;t++){if(!u[t].isInSet(a)){if(o&&o.to==f&&o.mark.eq(u[t]))o.to=c;else n.push(o=new Ht(f,c,u[t]))}}if(h&&h.to==f)h.to=c;else r.push(h=new Jt(f,c,s))}}));n.forEach((e=>t.step(e)));r.forEach((e=>t.step(e)))}function te(t,e,i,s){let n=[],r=0;t.doc.nodesBetween(e,i,((t,o)=>{if(!t.isInline)return;r++;let h=null;if(s instanceof nt){let e=t.marks,i;while(i=s.isInSet(e)){(h||(h=[])).push(i);e=i.removeFromSet(e)}}else if(s){if(s.isInSet(t.marks))h=[s]}else{h=t.marks}if(h&&h.length){let s=Math.min(o+t.nodeSize,i);for(let t=0;t<h.length;t++){let i=h[t],l;for(let t=0;t<n.length;t++){let e=n[t];if(e.step==r-1&&i.eq(n[t].style))l=e}if(l){l.to=s;l.step=r}else{n.push({style:i,from:Math.max(o,e),to:s,step:r})}}}}));n.forEach((e=>t.step(new Ht(e.from,e.to,e.style))))}function ee(t,e,i,s=i.contentMatch,n=true){let r=t.doc.nodeAt(e);let o=[],h=e+1;for(let e=0;e<r.childCount;e++){let l=r.child(e),u=h+l.nodeSize;let c=s.matchType(l.type);if(!c){o.push(new qt(h,u,p.empty))}else{s=c;for(let e=0;e<l.marks.length;e++)if(!i.allowsMarkType(l.marks[e].type))t.step(new Ht(h,u,l.marks[e]));if(n&&l.isText&&i.whitespace!="pre"){let t,e=/\r?\n|\r/g,s;while(t=e.exec(l.text)){if(!s)s=new p(f.from(i.schema.text(" ",i.allowedMarks(l.marks))),0,0);o.push(new qt(h+t.index,h+t.index+t[0].length,s))}}}h=u}if(!s.validEnd){let e=s.fillBefore(f.empty,true);t.replace(h,h,new p(e,0,0))}for(let e=o.length-1;e>=0;e--)t.step(o[e])}function ie(t,e,i){return(e==0||t.canReplace(e,t.childCount))&&(i==t.childCount||t.canReplace(0,i))}function se(t){let e=t.parent;let i=e.content.cutByIndex(t.startIndex,t.endIndex);for(let e=t.depth,s=0,n=0;;--e){let r=t.$from.node(e);let o=t.$from.index(e)+s,h=t.$to.indexAfter(e)-n;if(e<t.depth&&r.canReplace(o,h,i))return e;if(e==0||r.type.spec.isolating||!ie(r,o,h))break;if(o)s=1;if(h<r.childCount)n=1}return null}function ne(t,e,i){let{$from:s,$to:n,depth:r}=e;let o=s.before(r+1),h=n.after(r+1);let l=o,u=h;let c=f.empty,a=0;for(let t=r,e=false;t>i;t--)if(e||s.index(t)>0){e=true;c=f.from(s.node(t).copy(c));a++}else{l--}let d=f.empty,w=0;for(let t=r,e=false;t>i;t--)if(e||n.after(t+1)<n.end(t)){e=true;d=f.from(n.node(t).copy(d));w++}else{u++}t.step(new Kt(l,u,o,h,new p(c.append(d),a,w),c.size-a,true))}function re(t,e,i){let s=f.empty;for(let t=i.length-1;t>=0;t--){if(s.size){let e=i[t].type.contentMatch.matchFragment(s);if(!e||!e.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}s=f.from(i[t].type.create(i[t].attrs,s))}let n=e.start,r=e.end;t.step(new Kt(n,r,n,r,new p(s,0,0),i.length,true))}function oe(t,e,i,s,n){if(!s.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let r=t.steps.length;t.doc.nodesBetween(e,i,((e,i)=>{let o=typeof n=="function"?n(e):n;if(e.isTextblock&&!e.hasMarkup(s,o)&&fe(t.doc,t.mapping.slice(r).map(i),s)){let n=null;if(s.schema.linebreakReplacement){let t=s.whitespace=="pre",e=!!s.contentMatch.matchType(s.schema.linebreakReplacement);if(t&&!e)n=false;else if(!t&&e)n=true}if(n===false)le(t,e,i,r);ee(t,t.mapping.slice(r).map(i,1),s,undefined,n===null);let h=t.mapping.slice(r);let l=h.map(i,1),u=h.map(i+e.nodeSize,1);t.step(new Kt(l,u,l+1,u-1,new p(f.from(s.create(o,null,e.marks)),0,0),1,true));if(n===true)he(t,e,i,r);return false}}))}function he(t,e,i,s){e.forEach(((n,r)=>{if(n.isText){let o,h=/\r?\n|\r/g;while(o=h.exec(n.text)){let n=t.mapping.slice(s).map(i+1+r+o.index);t.replaceWith(n,n+1,e.type.schema.linebreakReplacement.create())}}}))}function le(t,e,i,s){e.forEach(((n,r)=>{if(n.type==n.type.schema.linebreakReplacement){let n=t.mapping.slice(s).map(i+1+r);t.replaceWith(n,n+1,e.type.schema.text("\n"))}}))}function fe(t,e,i){let s=t.resolve(e),n=s.index();return s.parent.canReplaceWith(n,n+1,i)}function ue(t,e,i,s,n){let r=t.doc.nodeAt(e);if(!r)throw new RangeError("No node at given position");if(!i)i=r.type;let o=i.create(s,null,n||r.marks);if(r.isLeaf)return t.replaceWith(e,e+r.nodeSize,o);if(!i.validContent(r.content))throw new RangeError("Invalid content for node type "+i.name);t.step(new Kt(e,e+r.nodeSize,e+1,e+r.nodeSize-1,new p(f.from(o),0,0),1,true))}function ce(t,e,i=1,s){let n=t.resolve(e),r=n.depth-i;let o=s&&s[s.length-1]||n.parent;if(r<0||n.parent.type.spec.isolating||!n.parent.canReplace(n.index(),n.parent.childCount)||!o.type.validContent(n.parent.content.cutByIndex(n.index(),n.parent.childCount)))return false;for(let t=n.depth-1,e=i-2;t>r;t--,e--){let i=n.node(t),r=n.index(t);if(i.type.spec.isolating)return false;let o=i.content.cutByIndex(r,i.childCount);let h=s&&s[e+1];if(h)o=o.replaceChild(0,h.type.create(h.attrs));let l=s&&s[e]||i;if(!i.canReplace(r+1,i.childCount)||!l.type.validContent(o))return false}let h=n.indexAfter(r);let l=s&&s[0];return n.node(r).canReplaceWith(h,h,l?l.type:n.node(r+1).type)}function ae(t,e,i=1,s){let n=t.doc.resolve(e),r=f.empty,o=f.empty;for(let t=n.depth,e=n.depth-i,h=i-1;t>e;t--,h--){r=f.from(n.node(t).copy(r));let e=s&&s[h];o=f.from(e?e.type.create(e.attrs,o):n.node(t).copy(o))}t.step(new qt(e,e,new p(r.append(o),i,i),true))}function de(t,e){let i=t.resolve(e),s=i.index();return pe(i.nodeBefore,i.nodeAfter)&&i.parent.canReplace(s,s+1)}function we(t,e){if(!e.content.size)t.type.compatibleContent(e.type);let i=t.contentMatchAt(t.childCount);let{linebreakReplacement:s}=t.type.schema;for(let n=0;n<e.childCount;n++){let r=e.child(n);let o=r.type==s?t.type.schema.nodes.text:r.type;i=i.matchType(o);if(!i)return false;if(!t.type.allowsMarks(r.marks))return false}return i.validEnd}function pe(t,e){return!!(t&&e&&!t.isLeaf&&we(t,e))}function ge(t,e,i){let s=null;let{linebreakReplacement:n}=t.doc.type.schema;let r=t.doc.resolve(e-i),o=r.node().type;if(n&&o.inlineContent){let t=o.whitespace=="pre";let e=!!o.contentMatch.matchType(n);if(t&&!e)s=false;else if(!t&&e)s=true}let h=t.steps.length;if(s===false){let s=t.doc.resolve(e+i);le(t,s.node(),s.before(),h)}if(o.inlineContent)ee(t,e+i-1,o,r.node().contentMatchAt(r.index()),s==null);let l=t.mapping.slice(h),f=l.map(e-i);t.step(new qt(f,l.map(e+i,-1),p.empty,true));if(s===true){let e=t.doc.resolve(f);he(t,e.node(),e.before(),t.steps.length)}return t}function me(t,e,i){let s=t.resolve(e);if(s.parent.canReplaceWith(s.index(),s.index(),i))return e;if(s.parentOffset==0)for(let t=s.depth-1;t>=0;t--){let e=s.index(t);if(s.node(t).canReplaceWith(e,e,i))return s.before(t+1);if(e>0)return null}if(s.parentOffset==s.parent.content.size)for(let t=s.depth-1;t>=0;t--){let e=s.indexAfter(t);if(s.node(t).canReplaceWith(e,e,i))return s.after(t+1);if(e<s.node(t).childCount)return null}return null}function ye(t,e,i){let s=t.resolve(e);if(!i.content.size)return e;let n=i.content;for(let t=0;t<i.openStart;t++)n=n.firstChild.content;for(let t=1;t<=(i.openStart==0&&i.size?2:1);t++){for(let e=s.depth;e>=0;e--){let i=e==s.depth?0:s.pos<=(s.start(e+1)+s.end(e+1))/2?-1:1;let r=s.index(e)+(i>0?1:0);let o=s.node(e),h=false;if(t==1){h=o.canReplace(r,r,n)}else{let t=o.contentMatchAt(r).findWrapping(n.firstChild.type);h=t&&o.canReplaceWith(r,r,t[0])}if(h)return i==0?s.pos:i<0?s.before(e+1):s.after(e+1)}}return null}function ve(t,e,i=e,s=p.empty){if(e==i&&!s.size)return null;let n=t.resolve(e),r=t.resolve(i);if(be(n,r,s))return new qt(e,i,s);return new Me(n,r,s).fit()}function be(t,e,i){return!i.openStart&&!i.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),i.content)}class Me{constructor(t,e,i){this.$from=t;this.$to=e;this.unplaced=i;this.frontier=[];this.placed=f.empty;for(let e=0;e<=t.depth;e++){let i=t.node(e);this.frontier.push({type:i.type,match:i.contentMatchAt(t.indexAfter(e))})}for(let e=t.depth;e>0;e--)this.placed=f.from(t.node(e).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){while(this.unplaced.size){let t=this.findFittable();if(t)this.placeNodes(t);else this.openMore()||this.dropNode()}let t=this.mustMoveInline(),e=this.placed.size-this.depth-this.$from.depth;let i=this.$from,s=this.close(t<0?this.$to:i.doc.resolve(t));if(!s)return null;let n=this.placed,r=i.depth,o=s.depth;while(r&&o&&n.childCount==1){n=n.firstChild.content;r--;o--}let h=new p(n,r,o);if(t>-1)return new Kt(i.pos,t,this.$to.pos,this.$to.end(),h,e);if(h.size||i.pos!=this.$to.pos)return new qt(i.pos,s.pos,h);return null}findFittable(){let t=this.unplaced.openStart;for(let e=this.unplaced.content,i=0,s=this.unplaced.openEnd;i<t;i++){let n=e.firstChild;if(e.childCount>1)s=0;if(n.type.spec.isolating&&s<=i){t=i;break}e=n.content}for(let e=1;e<=2;e++){for(let i=e==1?t:this.unplaced.openStart;i>=0;i--){let t,s=null;if(i){s=xe(this.unplaced.content,i-1).firstChild;t=s.content}else{t=this.unplaced.content}let n=t.firstChild;for(let t=this.depth;t>=0;t--){let{type:r,match:o}=this.frontier[t],h,l=null;if(e==1&&(n?o.matchType(n.type)||(l=o.fillBefore(f.from(n),false)):s&&r.compatibleContent(s.type)))return{sliceDepth:i,frontierDepth:t,parent:s,inject:l};else if(e==2&&n&&(h=o.findWrapping(n.type)))return{sliceDepth:i,frontierDepth:t,parent:s,wrap:h};if(s&&o.matchType(s.type))break}}}}openMore(){let{content:t,openStart:e,openEnd:i}=this.unplaced;let s=xe(t,e);if(!s.childCount||s.firstChild.isLeaf)return false;this.unplaced=new p(t,e+1,Math.max(i,s.size+e>=t.size-i?e+1:0));return true}dropNode(){let{content:t,openStart:e,openEnd:i}=this.unplaced;let s=xe(t,e);if(s.childCount<=1&&e>0){let n=t.size-e<=e+s.size;this.unplaced=new p(ke(t,e-1,1),e-1,n?e-1:i)}else{this.unplaced=new p(ke(t,e,1),e,i)}}placeNodes({sliceDepth:t,frontierDepth:e,parent:i,inject:s,wrap:n}){while(this.depth>e)this.closeFrontierNode();if(n)for(let t=0;t<n.length;t++)this.openFrontierNode(n[t]);let r=this.unplaced,o=i?i.content:r.content;let h=r.openStart-t;let l=0,u=[];let{match:c,type:a}=this.frontier[e];if(s){for(let t=0;t<s.childCount;t++)u.push(s.child(t));c=c.matchFragment(s)}let d=o.size+t-(r.content.size-r.openEnd);while(l<o.childCount){let t=o.child(l),e=c.matchType(t.type);if(!e)break;l++;if(l>1||h==0||t.content.size){c=e;u.push(Se(t.mark(a.allowedMarks(t.marks)),l==1?h:0,l==o.childCount?d:-1))}}let w=l==o.childCount;if(!w)d=-1;this.placed=Ae(this.placed,e,f.from(u));this.frontier[e].match=c;if(w&&d<0&&i&&i.type==this.frontier[this.depth].type&&this.frontier.length>1)this.closeFrontierNode();for(let t=0,e=o;t<d;t++){let t=e.lastChild;this.frontier.push({type:t.type,match:t.contentMatchAt(t.childCount)});e=t.content}this.unplaced=!w?new p(ke(r.content,t,l),r.openStart,r.openEnd):t==0?p.empty:new p(ke(r.content,t-1,1),t-1,d<0?r.openEnd:t-1)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let t=this.frontier[this.depth],e;if(!t.type.isTextblock||!Ce(this.$to,this.$to.depth,t.type,t.match,false)||this.$to.depth==this.depth&&(e=this.findCloseLevel(this.$to))&&e.depth==this.depth)return-1;let{depth:i}=this.$to,s=this.$to.after(i);while(i>1&&s==this.$to.end(--i))++s;return s}findCloseLevel(t){t:for(let e=Math.min(this.depth,t.depth);e>=0;e--){let{match:i,type:s}=this.frontier[e];let n=e<t.depth&&t.end(e+1)==t.pos+(t.depth-(e+1));let r=Ce(t,e,s,i,n);if(!r)continue;for(let i=e-1;i>=0;i--){let{match:e,type:s}=this.frontier[i];let n=Ce(t,i,s,e,true);if(!n||n.childCount)continue t}return{depth:e,fit:r,move:n?t.doc.resolve(t.after(e+1)):t}}}close(t){let e=this.findCloseLevel(t);if(!e)return null;while(this.depth>e.depth)this.closeFrontierNode();if(e.fit.childCount)this.placed=Ae(this.placed,e.depth,e.fit);t=e.move;for(let i=e.depth+1;i<=t.depth;i++){let e=t.node(i),s=e.type.contentMatch.fillBefore(e.content,true,t.index(i));this.openFrontierNode(e.type,e.attrs,s)}return t}openFrontierNode(t,e=null,i){let s=this.frontier[this.depth];s.match=s.match.matchType(t);this.placed=Ae(this.placed,this.depth,f.from(t.create(e,i)));this.frontier.push({type:t,match:t.contentMatch})}closeFrontierNode(){let t=this.frontier.pop();let e=t.match.fillBefore(f.empty,true);if(e.childCount)this.placed=Ae(this.placed,this.frontier.length,e)}}function ke(t,e,i){if(e==0)return t.cutByIndex(i,t.childCount);return t.replaceChild(0,t.firstChild.copy(ke(t.firstChild.content,e-1,i)))}function Ae(t,e,i){if(e==0)return t.append(i);return t.replaceChild(t.childCount-1,t.lastChild.copy(Ae(t.lastChild.content,e-1,i)))}function xe(t,e){for(let i=0;i<e;i++)t=t.firstChild.content;return t}function Se(t,e,i){if(e<=0)return t;let s=t.content;if(e>1)s=s.replaceChild(0,Se(s.firstChild,e-1,s.childCount==1?i-1:0));if(e>0){s=t.type.contentMatch.fillBefore(s).append(s);if(i<=0)s=s.append(t.type.contentMatch.matchFragment(s).fillBefore(f.empty,true))}return t.copy(s)}function Ce(t,e,i,s,n){let r=t.node(e),o=n?t.indexAfter(e):t.index(e);if(o==r.childCount&&!i.compatibleContent(r.type))return null;let h=s.fillBefore(r.content,true,o);return h&&!Oe(i,r.content,o)?h:null}function Oe(t,e,i){for(let s=i;s<e.childCount;s++)if(!t.allowsMarks(e.child(s).marks))return true;return false}function Ee(t){return t.spec.defining||t.spec.definingForContent}function Te(t,e,i,s){if(!s.size)return t.deleteRange(e,i);let n=t.doc.resolve(e),r=t.doc.resolve(i);if(be(n,r,s))return t.step(new qt(e,i,s));let o=Re(n,r);if(o[o.length-1]==0)o.pop();let h=-(n.depth+1);o.unshift(h);for(let t=n.depth,e=n.pos-1;t>0;t--,e--){let i=n.node(t).type.spec;if(i.defining||i.definingAsContext||i.isolating)break;if(o.indexOf(t)>-1)h=t;else if(n.before(t)==e)o.splice(1,0,-t)}let l=o.indexOf(h);let f=[],u=s.openStart;for(let t=s.content,e=0;;e++){let i=t.firstChild;f.push(i);if(e==s.openStart)break;t=i.content}for(let t=u-1;t>=0;t--){let e=f[t],i=Ee(e.type);if(i&&!e.sameMarkup(n.node(Math.abs(h)-1)))u=t;else if(i||!e.type.isTextblock)break}for(let e=s.openStart;e>=0;e--){let h=(e+u+1)%(s.openStart+1);let c=f[h];if(!c)continue;for(let e=0;e<o.length;e++){let f=o[(e+l)%o.length],u=true;if(f<0){u=false;f=-f}let a=n.node(f-1),d=n.index(f-1);if(a.canReplaceWith(d,d,c.type,c.marks))return t.replace(n.before(f),u?r.after(f):i,new p(De(s.content,0,s.openStart,h),h,s.openEnd))}}let c=t.steps.length;for(let h=o.length-1;h>=0;h--){t.replace(e,i,s);if(t.steps.length>c)break;let l=o[h];if(l<0)continue;e=n.before(l);i=r.after(l)}}function De(t,e,i,s,n){if(e<i){let n=t.firstChild;t=t.replaceChild(0,n.copy(De(n.content,e+1,i,s,n)))}if(e>s){let e=n.contentMatchAt(0);let i=e.fillBefore(t).append(t);t=i.append(e.matchFragment(i).fillBefore(f.empty,true))}return t}function Ie(t,e,i,s){if(!s.isInline&&e==i&&t.doc.resolve(e).parent.content.size){let n=me(t.doc,e,s.type);if(n!=null)e=i=n}t.replaceRange(e,i,new p(f.from(s),0,0))}function Pe(t,e,i){let s=t.doc.resolve(e),n=t.doc.resolve(i);let r=Re(s,n);for(let e=0;e<r.length;e++){let i=r[e],o=e==r.length-1;if(o&&i==0||s.node(i).type.contentMatch.validEnd)return t.delete(s.start(i),n.end(i));if(i>0&&(o||s.node(i-1).canReplace(s.index(i-1),n.indexAfter(i-1))))return t.delete(s.before(i),n.after(i))}for(let r=1;r<=s.depth&&r<=n.depth;r++){if(e-s.start(r)==s.depth-r&&i>s.end(r)&&n.end(r)-i!=n.depth-r&&s.start(r-1)==n.start(r-1)&&s.node(r-1).canReplace(s.index(r-1),n.index(r-1)))return t.delete(s.before(r),i)}t.delete(e,i)}function Re(t,e){let i=[],s=Math.min(t.depth,e.depth);for(let n=s;n>=0;n--){let s=t.start(n);if(s<t.pos-(t.depth-n)||e.end(n)>e.pos+(e.depth-n)||t.node(n).type.spec.isolating||e.node(n).type.spec.isolating)break;if(s==e.start(n)||n==t.depth&&n==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&n&&e.start(n-1)==s-1)i.push(n)}return i}class $e extends Yt{constructor(t,e,i){super();this.pos=t;this.attr=e;this.value=i}apply(t){let e=t.nodeAt(this.pos);if(!e)return Xt.fail("No node at attribute step's position");let i=Object.create(null);for(let t in e.attrs)i[t]=e.attrs[t];i[this.attr]=this.value;let s=e.type.create(i,null,e.marks);return Xt.fromReplace(t,this.pos,this.pos+1,new p(f.from(s),0,e.isLeaf?0:1))}getMap(){return Lt.empty}invert(t){return new $e(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new $e(e.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,e){if(typeof e.pos!="number"||typeof e.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new $e(e.pos,e.attr,e.value)}}Yt.jsonID("attr",$e);class Ue extends Yt{constructor(t,e){super();this.attr=t;this.value=e}apply(t){let e=Object.create(null);for(let i in t.attrs)e[i]=t.attrs[i];e[this.attr]=this.value;let i=t.type.create(e,t.content,t.marks);return Xt.ok(i)}getMap(){return Lt.empty}invert(t){return new Ue(this.attr,t.attrs[this.attr])}map(t){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(t,e){if(typeof e.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Ue(e.attr,e.value)}}Yt.jsonID("docAttr",Ue);let je=class extends Error{};je=function t(e){let i=Error.call(this,e);i.__proto__=t.prototype;return i};je.prototype=Object.create(Error.prototype);je.prototype.constructor=je;je.prototype.name="TransformError";class Be{constructor(t){this.doc=t;this.steps=[];this.docs=[];this.mapping=new _t}get before(){return this.docs.length?this.docs[0]:this.doc}step(t){let e=this.maybeStep(t);if(e.failed)throw new je(e.failed);return this}maybeStep(t){let e=t.apply(this.doc);if(!e.failed)this.addStep(t,e.doc);return e}get docChanged(){return this.steps.length>0}addStep(t,e){this.docs.push(this.doc);this.steps.push(t);this.mapping.appendMap(t.getMap());this.doc=e}replace(t,e=t,i=p.empty){let s=ve(this.doc,t,e,i);if(s)this.step(s);return this}replaceWith(t,e,i){return this.replace(t,e,new p(f.from(i),0,0))}delete(t,e){return this.replace(t,e,p.empty)}insert(t,e){return this.replaceWith(t,t,e)}replaceRange(t,e,i){Te(this,t,e,i);return this}replaceRangeWith(t,e,i){Ie(this,t,e,i);return this}deleteRange(t,e){Pe(this,t,e);return this}lift(t,e){ne(this,t,e);return this}join(t,e=1){ge(this,t,e);return this}wrap(t,e){re(this,t,e);return this}setBlockType(t,e=t,i,s=null){oe(this,t,e,i,s);return this}setNodeMarkup(t,e,i=null,s){ue(this,t,e,i,s);return this}setNodeAttribute(t,e,i){this.step(new $e(t,e,i));return this}setDocAttribute(t,e){this.step(new Ue(t,e));return this}addNodeMark(t,e){this.step(new Vt(t,e));return this}removeNodeMark(t,e){let i=this.doc.nodeAt(t);if(!i)throw new RangeError("No node at position "+t);if(e instanceof d){if(e.isInSet(i.marks))this.step(new Qt(t,e))}else{let s=i.marks,n,r=[];while(n=e.isInSet(s)){r.push(new Qt(t,n));s=n.removeFromSet(s)}for(let t=r.length-1;t>=0;t--)this.step(r[t])}return this}split(t,e=1,i){ae(this,t,e,i);return this}addMark(t,e,i){Zt(this,t,e,i);return this}removeMark(t,e,i){te(this,t,e,i);return this}clearIncompatible(t,e,i){ee(this,t,e,i);return this}}const Fe=Object.create(null);class Ne{constructor(t,e,i){this.$anchor=t;this.$head=e;this.ranges=i||[new Le(t.min(e),t.max(e))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let t=this.ranges;for(let e=0;e<t.length;e++)if(t[e].$from.pos!=t[e].$to.pos)return false;return true}content(){return this.$from.doc.slice(this.from,this.to,true)}replace(t,e=p.empty){let i=e.content.lastChild,s=null;for(let t=0;t<e.openEnd;t++){s=i;i=i.lastChild}let n=t.steps.length,r=this.ranges;for(let o=0;o<r.length;o++){let{$from:h,$to:l}=r[o],f=t.mapping.slice(n);t.replaceRange(f.map(h.pos),f.map(l.pos),o?p.empty:e);if(o==0)qe(t,n,(i?i.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(t,e){let i=t.steps.length,s=this.ranges;for(let n=0;n<s.length;n++){let{$from:r,$to:o}=s[n],h=t.mapping.slice(i);let l=h.map(r.pos),f=h.map(o.pos);if(n){t.deleteRange(l,f)}else{t.replaceRangeWith(l,f,e);qe(t,i,e.isInline?-1:1)}}}static findFrom(t,e,i=false){let s=t.parent.inlineContent?new Ye(t):Qe(t.node(0),t.parent,t.pos,t.index(),e,i);if(s)return s;for(let s=t.depth-1;s>=0;s--){let n=e<0?Qe(t.node(0),t.node(s),t.before(s+1),t.index(s),e,i):Qe(t.node(0),t.node(s),t.after(s+1),t.index(s)+1,e,i);if(n)return n}return null}static near(t,e=1){return this.findFrom(t,e)||this.findFrom(t,-e)||new He(t.node(0))}static atStart(t){return Qe(t,t,0,0,1)||new He(t)}static atEnd(t){return Qe(t,t,t.content.size,t.childCount,-1)||new He(t)}static fromJSON(t,e){if(!e||!e.type)throw new RangeError("Invalid input for Selection.fromJSON");let i=Fe[e.type];if(!i)throw new RangeError(`No selection type ${e.type} defined`);return i.fromJSON(t,e)}static jsonID(t,e){if(t in Fe)throw new RangeError("Duplicate use of selection JSON ID "+t);Fe[t]=e;e.prototype.jsonID=t;return e}getBookmark(){return Ye.between(this.$anchor,this.$head).getBookmark()}}Ne.prototype.visible=true;class Le{constructor(t,e){this.$from=t;this.$to=e}}let _e=false;function ze(t){if(!_e&&!t.parent.inlineContent){_e=true;console["warn"]("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")")}}class Ye extends Ne{constructor(t,e=t){ze(t);ze(e);super(t,e)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,e){let i=t.resolve(e.map(this.head));if(!i.parent.inlineContent)return Ne.near(i);let s=t.resolve(e.map(this.anchor));return new Ye(s.parent.inlineContent?s:i,i)}replace(t,e=p.empty){super.replace(t,e);if(e==p.empty){let e=this.$from.marksAcross(this.$to);if(e)t.ensureMarks(e)}}eq(t){return t instanceof Ye&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new Xe(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(t,e){if(typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new Ye(t.resolve(e.anchor),t.resolve(e.head))}static create(t,e,i=e){let s=t.resolve(e);return new this(s,i==e?s:t.resolve(i))}static between(t,e,i){let s=t.pos-e.pos;if(!i||s)i=s>=0?1:-1;if(!e.parent.inlineContent){let t=Ne.findFrom(e,i,true)||Ne.findFrom(e,-i,true);if(t)e=t.$head;else return Ne.near(e,i)}if(!t.parent.inlineContent){if(s==0){t=e}else{t=(Ne.findFrom(t,-i,true)||Ne.findFrom(t,i,true)).$anchor;if(t.pos<e.pos!=s<0)t=e}}return new Ye(t,e)}}Ne.jsonID("text",Ye);class Xe{constructor(t,e){this.anchor=t;this.head=e}map(t){return new Xe(t.map(this.anchor),t.map(this.head))}resolve(t){return Ye.between(t.resolve(this.anchor),t.resolve(this.head))}}class We extends Ne{constructor(t){let e=t.nodeAfter;let i=t.node(0).resolve(t.pos+e.nodeSize);super(t,i);this.node=e}map(t,e){let{deleted:i,pos:s}=e.mapResult(this.anchor);let n=t.resolve(s);if(i)return Ne.near(n);return new We(n)}content(){return new p(f.from(this.node),0,0)}eq(t){return t instanceof We&&t.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Je(this.anchor)}static fromJSON(t,e){if(typeof e.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new We(t.resolve(e.anchor))}static create(t,e){return new We(t.resolve(e))}static isSelectable(t){return!t.isText&&t.type.spec.selectable!==false}}We.prototype.visible=false;Ne.jsonID("node",We);class Je{constructor(t){this.anchor=t}map(t){let{deleted:e,pos:i}=t.mapResult(this.anchor);return e?new Xe(i,i):new Je(i)}resolve(t){let e=t.resolve(this.anchor),i=e.nodeAfter;if(i&&We.isSelectable(i))return new We(e);return Ne.near(e)}}class He extends Ne{constructor(t){super(t.resolve(0),t.resolve(t.content.size))}replace(t,e=p.empty){if(e==p.empty){t.delete(0,t.doc.content.size);let e=Ne.atStart(t.doc);if(!e.eq(t.selection))t.setSelection(e)}else{super.replace(t,e)}}toJSON(){return{type:"all"}}static fromJSON(t){return new He(t)}map(t){return new He(t)}eq(t){return t instanceof He}getBookmark(){return Ve}}Ne.jsonID("all",He);const Ve={map(){return this},resolve(t){return new He(t)}};function Qe(t,e,i,s,n,r=false){if(e.inlineContent)return Ye.create(t,i);for(let o=s-(n>0?0:1);n>0?o<e.childCount:o>=0;o+=n){let s=e.child(o);if(!s.isAtom){let e=Qe(t,s,i+n,n<0?s.childCount:0,n,r);if(e)return e}else if(!r&&We.isSelectable(s)){return We.create(t,i-(n<0?s.nodeSize:0))}i+=s.nodeSize*n}return null}function qe(t,e,i){let s=t.steps.length-1;if(s<e)return;let n=t.steps[s];if(!(n instanceof qt||n instanceof Kt))return;let r=t.mapping.maps[s],o;r.forEach(((t,e,i,s)=>{if(o==null)o=s}));t.setSelection(Ne.near(t.doc.resolve(o),i))}const Ke=1,Ge=2,Ze=4;let ti=class t extends Be{constructor(t){super(t.doc);this.curSelectionFor=0;this.updated=0;this.meta=Object.create(null);this.time=Date.now();this.curSelection=t.selection;this.storedMarks=t.storedMarks}get selection(){if(this.curSelectionFor<this.steps.length){this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor));this.curSelectionFor=this.steps.length}return this.curSelection}setSelection(t){if(t.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");this.curSelection=t;this.curSelectionFor=this.steps.length;this.updated=(this.updated|Ke)&-3;this.storedMarks=null;return this}get selectionSet(){return(this.updated&Ke)>0}setStoredMarks(t){this.storedMarks=t;this.updated|=Ge;return this}ensureMarks(t){if(!d.sameSet(this.storedMarks||this.selection.$from.marks(),t))this.setStoredMarks(t);return this}addStoredMark(t){return this.ensureMarks(t.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(t){return this.ensureMarks(t.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&Ge)>0}addStep(t,e){super.addStep(t,e);this.updated=this.updated&-3;this.storedMarks=null}setTime(t){this.time=t;return this}replaceSelection(t){this.selection.replace(this,t);return this}replaceSelectionWith(t,e=true){let i=this.selection;if(e)t=t.mark(this.storedMarks||(i.empty?i.$from.marks():i.$from.marksAcross(i.$to)||d.none));i.replaceWith(this,t);return this}deleteSelection(){this.selection.replace(this);return this}insertText(t,e,i){let s=this.doc.type.schema;if(e==null){if(!t)return this.deleteSelection();return this.replaceSelectionWith(s.text(t),true)}else{if(i==null)i=e;if(!t)return this.deleteRange(e,i);let n=this.storedMarks;if(!n){let t=this.doc.resolve(e);n=i==e?t.marks():t.marksAcross(this.doc.resolve(i))}this.replaceRangeWith(e,i,s.text(t,n));if(!this.selection.empty&&this.selection.to==e+t.length)this.setSelection(Ne.near(this.selection.$to));return this}}setMeta(t,e){this.meta[typeof t=="string"?t:t.key]=e;return this}getMeta(t){return this.meta[typeof t=="string"?t:t.key]}get isGeneric(){for(let t in this.meta)return false;return true}scrollIntoView(){this.updated|=Ze;return this}get scrolledIntoView(){return(this.updated&Ze)>0}};function ei(t,e){return!e||!t?t:t.bind(e)}class ii{constructor(t,e,i){this.name=t;this.init=ei(e.init,i);this.apply=ei(e.apply,i)}}const si=[new ii("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new ii("selection",{init(t,e){return t.selection||Ne.atStart(e.doc)},apply(t){return t.selection}}),new ii("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,i,s){return s.selection.$cursor?t.storedMarks:null}}),new ii("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class ni{constructor(t,e){this.schema=t;this.plugins=[];this.pluginsByKey=Object.create(null);this.fields=si.slice();if(e)e.forEach((t=>{if(this.pluginsByKey[t.key])throw new RangeError("Adding different instances of a keyed plugin ("+t.key+")");this.plugins.push(t);this.pluginsByKey[t.key]=t;if(t.spec.state)this.fields.push(new ii(t.key,t.spec.state,t))}))}}class ri{constructor(t){this.config=t}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(t){return this.applyTransaction(t).state}filterTransaction(t,e=-1){for(let i=0;i<this.config.plugins.length;i++)if(i!=e){let e=this.config.plugins[i];if(e.spec.filterTransaction&&!e.spec.filterTransaction.call(e,t,this))return false}return true}applyTransaction(t){if(!this.filterTransaction(t))return{state:this,transactions:[]};let e=[t],i=this.applyInner(t),s=null;for(;;){let n=false;for(let r=0;r<this.config.plugins.length;r++){let o=this.config.plugins[r];if(o.spec.appendTransaction){let h=s?s[r].n:0,l=s?s[r].state:this;let f=h<e.length&&o.spec.appendTransaction.call(o,h?e.slice(h):e,l,i);if(f&&i.filterTransaction(f,r)){f.setMeta("appendedTransaction",t);if(!s){s=[];for(let t=0;t<this.config.plugins.length;t++)s.push(t<r?{state:i,n:e.length}:{state:this,n:0})}e.push(f);i=i.applyInner(f);n=true}if(s)s[r]={state:i,n:e.length}}}if(!n)return{state:i,transactions:e}}}applyInner(t){if(!t.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let e=new ri(this.config),i=this.config.fields;for(let s=0;s<i.length;s++){let n=i[s];e[n.name]=n.apply(t,this[n.name],this,e)}return e}get tr(){return new ti(this)}static create(t){let e=new ni(t.doc?t.doc.type.schema:t.schema,t.plugins);let i=new ri(e);for(let s=0;s<e.fields.length;s++)i[e.fields[s].name]=e.fields[s].init(t,i);return i}reconfigure(t){let e=new ni(this.schema,t.plugins);let i=e.fields,s=new ri(e);for(let e=0;e<i.length;e++){let n=i[e].name;s[n]=this.hasOwnProperty(n)?this[n]:i[e].init(t,s)}return s}toJSON(t){let e={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks)e.storedMarks=this.storedMarks.map((t=>t.toJSON()));if(t&&typeof t=="object")for(let i in t){if(i=="doc"||i=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let s=t[i],n=s.spec.state;if(n&&n.toJSON)e[i]=n.toJSON.call(s,this[s.key])}return e}static fromJSON(t,e,i){if(!e)throw new RangeError("Invalid input for EditorState.fromJSON");if(!t.schema)throw new RangeError("Required config field 'schema' missing");let s=new ni(t.schema,t.plugins);let n=new ri(s);s.fields.forEach((s=>{if(s.name=="doc"){n.doc=$.fromJSON(t.schema,e.doc)}else if(s.name=="selection"){n.selection=Ne.fromJSON(n.doc,e.selection)}else if(s.name=="storedMarks"){if(e.storedMarks)n.storedMarks=e.storedMarks.map(t.schema.markFromJSON)}else{if(i)for(let r in i){let o=i[r],h=o.spec.state;if(o.key==s.name&&h&&h.fromJSON&&Object.prototype.hasOwnProperty.call(e,r)){n[s.name]=h.fromJSON.call(o,t,e[r],n);return}}n[s.name]=s.init(t,n)}}));return n}}function oi(t,e,i){for(let s in t){let n=t[s];if(n instanceof Function)n=n.bind(e);else if(s=="handleDOMEvents")n=oi(n,e,{});i[s]=n}return i}class hi{constructor(t){this.spec=t;this.props={};if(t.props)oi(t.props,this,this.props);this.key=t.key?t.key.key:fi("plugin")}getState(t){return t[this.key]}}const li=Object.create(null);function fi(t){if(t in li)return t+"$"+ ++li[t];li[t]=0;return t+"$"}const ui=function(t){for(var e=0;;e++){t=t.previousSibling;if(!t)return e}};const ci=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let ai=null;const di=function(t,e,i){let s=ai||(ai=document.createRange());s.setEnd(t,i==null?t.nodeValue.length:i);s.setStart(t,e||0);return s};const wi=function(){ai=null};const pi=function(t,e,i,s){return i&&(mi(t,e,i,s,-1)||mi(t,e,i,s,1))};const gi=/^(img|br|input|textarea|hr)$/i;function mi(t,e,i,s,n){var r;for(;;){if(t==i&&e==s)return true;if(e==(n<0?0:yi(t))){let i=t.parentNode;if(!i||i.nodeType!=1||ki(t)||gi.test(t.nodeName)||t.contentEditable=="false")return false;e=ui(t)+(n<0?0:1);t=i}else if(t.nodeType==1){let i=t.childNodes[e+(n<0?-1:0)];if(i.nodeType==1&&i.contentEditable=="false"){if((r=i.pmViewDesc)===null||r===void 0?void 0:r.ignoreForSelection)e+=n;else return false}else{t=i;e=n<0?yi(t):0}}else{return false}}}function yi(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function vi(t,e){for(;;){if(t.nodeType==3&&e)return t;if(t.nodeType==1&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1];e=yi(t)}else if(t.parentNode&&!ki(t)){e=ui(t);t=t.parentNode}else{return null}}}function bi(t,e){for(;;){if(t.nodeType==3&&e<t.nodeValue.length)return t;if(t.nodeType==1&&e<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[e];e=0}else if(t.parentNode&&!ki(t)){e=ui(t)+1;t=t.parentNode}else{return null}}}function Mi(t,e,i){for(let s=e==0,n=e==yi(t);s||n;){if(t==i)return true;let e=ui(t);t=t.parentNode;if(!t)return false;s=s&&e==0;n=n&&e==yi(t)}}function ki(t){let e;for(let i=t;i;i=i.parentNode)if(e=i.pmViewDesc)break;return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const Ai=function(t){return t.focusNode&&pi(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function xi(t,e){let i=document.createEvent("Event");i.initEvent("keydown",true,true);i.keyCode=t;i.key=i.code=e;return i}function Si(t){let e=t.activeElement;while(e&&e.shadowRoot)e=e.shadowRoot.activeElement;return e}function Ci(t,e,i){if(t.caretPositionFromPoint){try{let s=t.caretPositionFromPoint(e,i);if(s)return{node:s.offsetNode,offset:Math.min(yi(s.offsetNode),s.offset)}}catch(t){}}if(t.caretRangeFromPoint){let s=t.caretRangeFromPoint(e,i);if(s)return{node:s.startContainer,offset:Math.min(yi(s.startContainer),s.startOffset)}}}const Oi=typeof navigator!="undefined"?navigator:null;const Ei=typeof document!="undefined"?document:null;const Ti=Oi&&Oi.userAgent||"";const Di=/Edge\/(\d+)/.exec(Ti);const Ii=/MSIE \d/.exec(Ti);const Pi=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ti);const Ri=!!(Ii||Pi||Di);const $i=Ii?document.documentMode:Pi?+Pi[1]:Di?+Di[1]:0;const Ui=!Ri&&/gecko\/(\d+)/i.test(Ti);const ji=!Ri&&/Chrome\/(\d+)/.exec(Ti);const Bi=!!ji;const Fi=ji?+ji[1]:0;const Ni=!Ri&&!!Oi&&/Apple Computer/.test(Oi.vendor);const Li=Ni&&(/Mobile\/\w+/.test(Ti)||!!Oi&&Oi.maxTouchPoints>2);const _i=Li||(Oi?/Mac/.test(Oi.platform):false);const zi=Oi?/Win/.test(Oi.platform):false;const Yi=/Android \d/.test(Ti);const Xi=!!Ei&&"webkitFontSmoothing"in Ei.documentElement.style;const Wi=Xi?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Ji(t){let e=t.defaultView&&t.defaultView.visualViewport;if(e)return{left:0,right:e.width,top:0,bottom:e.height};return{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function Hi(t,e){return typeof t=="number"?t:t[e]}function Vi(t){let e=t.getBoundingClientRect();let i=e.width/t.offsetWidth||1;let s=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*i,top:e.top,bottom:e.top+t.clientHeight*s}}function Qi(t,e,i){let s=t.someProp("scrollThreshold")||0,n=t.someProp("scrollMargin")||5;let r=t.dom.ownerDocument;for(let o=i||t.dom;;){if(!o)break;if(o.nodeType!=1){o=ci(o);continue}let t=o;let i=t==r.body;let h=i?Ji(r):Vi(t);let l=0,f=0;if(e.top<h.top+Hi(s,"top"))f=-(h.top-e.top+Hi(n,"top"));else if(e.bottom>h.bottom-Hi(s,"bottom"))f=e.bottom-e.top>h.bottom-h.top?e.top+Hi(n,"top")-h.top:e.bottom-h.bottom+Hi(n,"bottom");if(e.left<h.left+Hi(s,"left"))l=-(h.left-e.left+Hi(n,"left"));else if(e.right>h.right-Hi(s,"right"))l=e.right-h.right+Hi(n,"right");if(l||f){if(i){r.defaultView.scrollBy(l,f)}else{let i=t.scrollLeft,s=t.scrollTop;if(f)t.scrollTop+=f;if(l)t.scrollLeft+=l;let n=t.scrollLeft-i,r=t.scrollTop-s;e={left:e.left-n,top:e.top-r,right:e.right-n,bottom:e.bottom-r}}}let u=i?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(u))break;o=u=="absolute"?o.offsetParent:ci(o)}}function qi(t){let e=t.dom.getBoundingClientRect(),i=Math.max(0,e.top);let s,n;for(let r=(e.left+e.right)/2,o=i+1;o<Math.min(innerHeight,e.bottom);o+=5){let e=t.root.elementFromPoint(r,o);if(!e||e==t.dom||!t.dom.contains(e))continue;let h=e.getBoundingClientRect();if(h.top>=i-20){s=e;n=h.top;break}}return{refDOM:s,refTop:n,stack:Ki(t.dom)}}function Ki(t){let e=[],i=t.ownerDocument;for(let s=t;s;s=ci(s)){e.push({dom:s,top:s.scrollTop,left:s.scrollLeft});if(t==i)break}return e}function Gi({refDOM:t,refTop:e,stack:i}){let s=t?t.getBoundingClientRect().top:0;Zi(i,s==0?0:s-e)}function Zi(t,e){for(let i=0;i<t.length;i++){let{dom:s,top:n,left:r}=t[i];if(s.scrollTop!=n+e)s.scrollTop=n+e;if(s.scrollLeft!=r)s.scrollLeft=r}}let ts=null;function es(t){if(t.setActive)return t.setActive();if(ts)return t.focus(ts);let e=Ki(t);t.focus(ts==null?{get preventScroll(){ts={preventScroll:true};return true}}:undefined);if(!ts){ts=false;Zi(e,0)}}function is(t,e){let i,s=2e8,n,r=0;let o=e.top,h=e.top;let l,f;for(let u=t.firstChild,c=0;u;u=u.nextSibling,c++){let t;if(u.nodeType==1)t=u.getClientRects();else if(u.nodeType==3)t=di(u).getClientRects();else continue;for(let a=0;a<t.length;a++){let d=t[a];if(d.top<=o&&d.bottom>=h){o=Math.max(d.bottom,o);h=Math.min(d.top,h);let t=d.left>e.left?d.left-e.left:d.right<e.left?e.left-d.right:0;if(t<s){i=u;s=t;n=t&&i.nodeType==3?{left:d.right<e.left?d.right:d.left,top:e.top}:e;if(u.nodeType==1&&t)r=c+(e.left>=(d.left+d.right)/2?1:0);continue}}else if(d.top>e.top&&!l&&d.left<=e.left&&d.right>=e.left){l=u;f={left:Math.max(d.left,Math.min(d.right,e.left)),top:d.top}}if(!i&&(e.left>=d.right&&e.top>=d.top||e.left>=d.left&&e.top>=d.bottom))r=c+1}}if(!i&&l){i=l;n=f;s=0}if(i&&i.nodeType==3)return ss(i,n);if(!i||s&&i.nodeType==1)return{node:t,offset:r};return is(i,n)}function ss(t,e){let i=t.nodeValue.length;let s=document.createRange();for(let n=0;n<i;n++){s.setEnd(t,n+1);s.setStart(t,n);let i=as(s,1);if(i.top==i.bottom)continue;if(ns(e,i))return{node:t,offset:n+(e.left>=(i.left+i.right)/2?1:0)}}return{node:t,offset:0}}function ns(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function rs(t,e){let i=t.parentNode;if(i&&/^li$/i.test(i.nodeName)&&e.left<t.getBoundingClientRect().left)return i;return t}function hs(t,e,i){let{node:s,offset:n}=is(e,i),r=-1;if(s.nodeType==1&&!s.firstChild){let t=s.getBoundingClientRect();r=t.left!=t.right&&i.left>(t.left+t.right)/2?1:-1}return t.docView.posFromDOM(s,n,r)}function ls(t,e,i,s){let n=-1;for(let i=e,r=false;;){if(i==t.dom)break;let e=t.docView.nearestDesc(i,true),o;if(!e)return null;if(e.dom.nodeType==1&&(e.node.isBlock&&e.parent||!e.contentDOM)&&((o=e.dom.getBoundingClientRect()).width||o.height)){if(e.node.isBlock&&e.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(e.dom.nodeName)){if(!r&&o.left>s.left||o.top>s.top)n=e.posBefore;else if(!r&&o.right<s.left||o.bottom<s.top)n=e.posAfter;r=true}if(!e.contentDOM&&n<0&&!e.node.isText){let t=e.node.isBlock?s.top<(o.top+o.bottom)/2:s.left<(o.left+o.right)/2;return t?e.posBefore:e.posAfter}}i=e.dom.parentNode}return n>-1?n:t.docView.posFromDOM(e,i,-1)}function fs(t,e,i){let s=t.childNodes.length;if(s&&i.top<i.bottom){for(let n=Math.max(0,Math.min(s-1,Math.floor(s*(e.top-i.top)/(i.bottom-i.top))-2)),r=n;;){let i=t.childNodes[r];if(i.nodeType==1){let t=i.getClientRects();for(let s=0;s<t.length;s++){let n=t[s];if(ns(e,n))return fs(i,e,n)}}if((r=(r+1)%s)==n)break}}return t}function us(t,e){let i=t.dom.ownerDocument,s,n=0;let r=Ci(i,e.left,e.top);if(r)({node:s,offset:n}=r);let o=(t.root.elementFromPoint?t.root:i).elementFromPoint(e.left,e.top);let h;if(!o||!t.dom.contains(o.nodeType!=1?o.parentNode:o)){let i=t.dom.getBoundingClientRect();if(!ns(e,i))return null;o=fs(t.dom,e,i);if(!o)return null}if(Ni){for(let t=o;s&&t;t=ci(t))if(t.draggable)s=undefined}o=rs(o,e);if(s){if(Ui&&s.nodeType==1){n=Math.min(n,s.childNodes.length);if(n<s.childNodes.length){let t=s.childNodes[n],i;if(t.nodeName=="IMG"&&(i=t.getBoundingClientRect()).right<=e.left&&i.bottom>e.top)n++}}let i;if(Xi&&n&&s.nodeType==1&&(i=s.childNodes[n-1]).nodeType==1&&i.contentEditable=="false"&&i.getBoundingClientRect().top>=e.top)n--;if(s==t.dom&&n==s.childNodes.length-1&&s.lastChild.nodeType==1&&e.top>s.lastChild.getBoundingClientRect().bottom)h=t.state.doc.content.size;else if(n==0||s.nodeType!=1||s.childNodes[n-1].nodeName!="BR")h=ls(t,s,n,e)}if(h==null)h=hs(t,o,e);let l=t.docView.nearestDesc(o,true);return{pos:h,inside:l?l.posAtStart-l.border:-1}}function cs(t){return t.top<t.bottom||t.left<t.right}function as(t,e){let i=t.getClientRects();if(i.length){let t=i[e<0?0:i.length-1];if(cs(t))return t}return Array.prototype.find.call(i,cs)||t.getBoundingClientRect()}const ds=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function ws(t,e,i){let{node:s,offset:n,atom:r}=t.docView.domFromPos(e,i<0?-1:1);let o=Xi||Ui;if(s.nodeType==3){if(o&&(ds.test(s.nodeValue)||(i<0?!n:n==s.nodeValue.length))){let t=as(di(s,n,n),i);if(Ui&&n&&/\s/.test(s.nodeValue[n-1])&&n<s.nodeValue.length){let e=as(di(s,n-1,n-1),-1);if(e.top==t.top){let i=as(di(s,n,n+1),-1);if(i.top!=t.top)return ps(i,i.left<e.left)}}return t}else{let t=n,e=n,r=i<0?1:-1;if(i<0&&!n){e++;r=-1}else if(i>=0&&n==s.nodeValue.length){t--;r=1}else if(i<0){t--}else{e++}return ps(as(di(s,t,e),r),r<0)}}let h=t.state.doc.resolve(e-(r||0));if(!h.parent.inlineContent){if(r==null&&n&&(i<0||n==yi(s))){let t=s.childNodes[n-1];if(t.nodeType==1)return gs(t.getBoundingClientRect(),false)}if(r==null&&n<yi(s)){let t=s.childNodes[n];if(t.nodeType==1)return gs(t.getBoundingClientRect(),true)}return gs(s.getBoundingClientRect(),i>=0)}if(r==null&&n&&(i<0||n==yi(s))){let t=s.childNodes[n-1];let e=t.nodeType==3?di(t,yi(t)-(o?0:1)):t.nodeType==1&&(t.nodeName!="BR"||!t.nextSibling)?t:null;if(e)return ps(as(e,1),false)}if(r==null&&n<yi(s)){let t=s.childNodes[n];while(t.pmViewDesc&&t.pmViewDesc.ignoreForCoords)t=t.nextSibling;let e=!t?null:t.nodeType==3?di(t,0,o?0:1):t.nodeType==1?t:null;if(e)return ps(as(e,-1),true)}return ps(as(s.nodeType==3?di(s):s,-i),i>=0)}function ps(t,e){if(t.width==0)return t;let i=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:i,right:i}}function gs(t,e){if(t.height==0)return t;let i=e?t.top:t.bottom;return{top:i,bottom:i,left:t.left,right:t.right}}function ms(t,e,i){let s=t.state,n=t.root.activeElement;if(s!=e)t.updateState(e);if(n!=t.dom)t.focus();try{return i()}finally{if(s!=e)t.updateState(s);if(n!=t.dom&&n)n.focus()}}function ys(t,e,i){let s=e.selection;let n=i=="up"?s.$from:s.$to;return ms(t,e,(()=>{let{node:e}=t.docView.domFromPos(n.pos,i=="up"?-1:1);for(;;){let i=t.docView.nearestDesc(e,true);if(!i)break;if(i.node.isBlock){e=i.contentDOM||i.dom;break}e=i.dom.parentNode}let s=ws(t,n.pos,1);for(let t=e.firstChild;t;t=t.nextSibling){let e;if(t.nodeType==1)e=t.getClientRects();else if(t.nodeType==3)e=di(t,0,t.nodeValue.length).getClientRects();else continue;for(let t=0;t<e.length;t++){let n=e[t];if(n.bottom>n.top+1&&(i=="up"?s.top-n.top>(n.bottom-s.top)*2:n.bottom-s.bottom>(s.bottom-n.top)*2))return false}}return true}))}const vs=/[\u0590-\u08ac]/;function bs(t,e,i){let{$head:s}=e.selection;if(!s.parent.isTextblock)return false;let n=s.parentOffset,r=!n,o=n==s.parent.content.size;let h=t.domSelection();if(!h)return s.pos==s.start()||s.pos==s.end();if(!vs.test(s.parent.textContent)||!h.modify)return i=="left"||i=="backward"?r:o;return ms(t,e,(()=>{let{focusNode:e,focusOffset:n,anchorNode:r,anchorOffset:o}=t.domSelectionRange();let l=h.caretBidiLevel;h.modify("move",i,"character");let f=s.depth?t.docView.domAfterPos(s.before()):t.dom;let{focusNode:u,focusOffset:c}=t.domSelectionRange();let a=u&&!f.contains(u.nodeType==1?u:u.parentNode)||e==u&&n==c;try{h.collapse(r,o);if(e&&(e!=r||n!=o)&&h.extend)h.extend(e,n)}catch(t){}if(l!=null)h.caretBidiLevel=l;return a}))}let Ms=null;let ks=null;let As=false;function xs(t,e,i){if(Ms==e&&ks==i)return As;Ms=e;ks=i;return As=i=="up"||i=="down"?ys(t,e,i):bs(t,e,i)}const Ss=0,Cs=1,Os=2,Es=3;class Ts{constructor(t,e,i,s){this.parent=t;this.children=e;this.dom=i;this.contentDOM=s;this.dirty=Ss;i.pmViewDesc=this}matchesWidget(t){return false}matchesMark(t){return false}matchesNode(t,e,i){return false}matchesHack(t){return false}parseRule(){return null}stopEvent(t){return false}get size(){let t=0;for(let e=0;e<this.children.length;e++)t+=this.children[e].size;return t}get border(){return 0}destroy(){this.parent=undefined;if(this.dom.pmViewDesc==this)this.dom.pmViewDesc=undefined;for(let t=0;t<this.children.length;t++)this.children[t].destroy()}posBeforeChild(t){for(let e=0,i=this.posAtStart;;e++){let s=this.children[e];if(s==t)return i;i+=s.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(t,e,i){if(this.contentDOM&&this.contentDOM.contains(t.nodeType==1?t:t.parentNode)){if(i<0){let i,s;if(t==this.contentDOM){i=t.childNodes[e-1]}else{while(t.parentNode!=this.contentDOM)t=t.parentNode;i=t.previousSibling}while(i&&!((s=i.pmViewDesc)&&s.parent==this))i=i.previousSibling;return i?this.posBeforeChild(s)+s.size:this.posAtStart}else{let i,s;if(t==this.contentDOM){i=t.childNodes[e]}else{while(t.parentNode!=this.contentDOM)t=t.parentNode;i=t.nextSibling}while(i&&!((s=i.pmViewDesc)&&s.parent==this))i=i.nextSibling;return i?this.posBeforeChild(s):this.posAtEnd}}let s;if(t==this.dom&&this.contentDOM){s=e>ui(this.contentDOM)}else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM)){s=t.compareDocumentPosition(this.contentDOM)&2}else if(this.dom.firstChild){if(e==0)for(let e=t;;e=e.parentNode){if(e==this.dom){s=false;break}if(e.previousSibling)break}if(s==null&&e==t.childNodes.length)for(let e=t;;e=e.parentNode){if(e==this.dom){s=true;break}if(e.nextSibling)break}}return(s==null?i>0:s)?this.posAtEnd:this.posAtStart}nearestDesc(t,e=false){for(let i=true,s=t;s;s=s.parentNode){let n=this.getDesc(s),r;if(n&&(!e||n.node)){if(i&&(r=n.nodeDOM)&&!(r.nodeType==1?r.contains(t.nodeType==1?t:t.parentNode):r==t))i=false;else return n}}}getDesc(t){let e=t.pmViewDesc;for(let t=e;t;t=t.parent)if(t==this)return e}posFromDOM(t,e,i){for(let s=t;s;s=s.parentNode){let n=this.getDesc(s);if(n)return n.localPosFromDOM(t,e,i)}return-1}descAt(t){for(let e=0,i=0;e<this.children.length;e++){let s=this.children[e],n=i+s.size;if(i==t&&n!=i){while(!s.border&&s.children.length){for(let t=0;t<s.children.length;t++){let e=s.children[t];if(e.size){s=e;break}}}return s}if(t<n)return s.descAt(t-i-s.border);i=n}}domFromPos(t,e){if(!this.contentDOM)return{node:this.dom,offset:0,atom:t+1};let i=0,s=0;for(let e=0;i<this.children.length;i++){let n=this.children[i],r=e+n.size;if(r>t||n instanceof js){s=t-e;break}e=r}if(s)return this.children[i].domFromPos(s-this.children[i].border,e);for(let t;i&&!(t=this.children[i-1]).size&&t instanceof Ds&&t.side>=0;i--){}if(e<=0){let t,s=true;for(;;i--,s=false){t=i?this.children[i-1]:null;if(!t||t.dom.parentNode==this.contentDOM)break}if(t&&e&&s&&!t.border&&!t.domAtom)return t.domFromPos(t.size,e);return{node:this.contentDOM,offset:t?ui(t.dom)+1:0}}else{let t,s=true;for(;;i++,s=false){t=i<this.children.length?this.children[i]:null;if(!t||t.dom.parentNode==this.contentDOM)break}if(t&&s&&!t.border&&!t.domAtom)return t.domFromPos(0,e);return{node:this.contentDOM,offset:t?ui(t.dom):this.contentDOM.childNodes.length}}}parseRange(t,e,i=0){if(this.children.length==0)return{node:this.contentDOM,from:t,to:e,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let s=-1,n=-1;for(let r=i,o=0;;o++){let i=this.children[o],h=r+i.size;if(s==-1&&t<=h){let n=r+i.border;if(t>=n&&e<=h-i.border&&i.node&&i.contentDOM&&this.contentDOM.contains(i.contentDOM))return i.parseRange(t,e,n);t=r;for(let e=o;e>0;e--){let i=this.children[e-1];if(i.size&&i.dom.parentNode==this.contentDOM&&!i.emptyChildAt(1)){s=ui(i.dom)+1;break}t-=i.size}if(s==-1)s=0}if(s>-1&&(h>e||o==this.children.length-1)){e=h;for(let t=o+1;t<this.children.length;t++){let i=this.children[t];if(i.size&&i.dom.parentNode==this.contentDOM&&!i.emptyChildAt(-1)){n=ui(i.dom);break}e+=i.size}if(n==-1)n=this.contentDOM.childNodes.length;break}r=h}return{node:this.contentDOM,from:t,to:e,fromOffset:s,toOffset:n}}emptyChildAt(t){if(this.border||!this.contentDOM||!this.children.length)return false;let e=this.children[t<0?0:this.children.length-1];return e.size==0||e.emptyChildAt(t)}domAfterPos(t){let{node:e,offset:i}=this.domFromPos(t,0);if(e.nodeType!=1||i==e.childNodes.length)throw new RangeError("No node after pos "+t);return e.childNodes[i]}setSelection(t,e,i,s=false){let n=Math.min(t,e),r=Math.max(t,e);for(let o=0,h=0;o<this.children.length;o++){let l=this.children[o],f=h+l.size;if(n>h&&r<f)return l.setSelection(t-h-l.border,e-h-l.border,i,s);h=f}let o=this.domFromPos(t,t?-1:1);let h=e==t?o:this.domFromPos(e,e?-1:1);let l=i.root.getSelection();let f=i.domSelectionRange();let u=false;if((Ui||Ni)&&t==e){let{node:t,offset:e}=o;if(t.nodeType==3){u=!!(e&&t.nodeValue[e-1]=="\n");if(u&&e==t.nodeValue.length){for(let e=t,i;e;e=e.parentNode){if(i=e.nextSibling){if(i.nodeName=="BR")o=h={node:i.parentNode,offset:ui(i)+1};break}let t=e.pmViewDesc;if(t&&t.node&&t.node.isBlock)break}}}else{let i=t.childNodes[e-1];u=i&&(i.nodeName=="BR"||i.contentEditable=="false")}}if(Ui&&f.focusNode&&f.focusNode!=h.node&&f.focusNode.nodeType==1){let t=f.focusNode.childNodes[f.focusOffset];if(t&&t.contentEditable=="false")s=true}if(!(s||u&&Ni)&&pi(o.node,o.offset,f.anchorNode,f.anchorOffset)&&pi(h.node,h.offset,f.focusNode,f.focusOffset))return;let c=false;if((l.extend||t==e)&&!(u&&Ui)){l.collapse(o.node,o.offset);try{if(t!=e)l.extend(h.node,h.offset);c=true}catch(t){}}if(!c){if(t>e){let t=o;o=h;h=t}let i=document.createRange();i.setEnd(h.node,h.offset);i.setStart(o.node,o.offset);l.removeAllRanges();l.addRange(i)}}ignoreMutation(t){return!this.contentDOM&&t.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(t,e){for(let i=0,s=0;s<this.children.length;s++){let n=this.children[s],r=i+n.size;if(i==r?t<=r&&e>=i:t<r&&e>i){let s=i+n.border,o=r-n.border;if(t>=s&&e<=o){this.dirty=t==i||e==r?Os:Cs;if(t==s&&e==o&&(n.contentLost||n.dom.parentNode!=this.contentDOM))n.dirty=Es;else n.markDirty(t-s,e-s);return}else{n.dirty=n.dom==n.contentDOM&&n.dom.parentNode==this.contentDOM&&!n.children.length?Os:Es}}i=r}this.dirty=Os}markParentsDirty(){let t=1;for(let e=this.parent;e;e=e.parent,t++){let i=t==1?Os:Cs;if(e.dirty<i)e.dirty=i}}get domAtom(){return false}get ignoreForCoords(){return false}get ignoreForSelection(){return false}isText(t){return false}}class Ds extends Ts{constructor(t,e,i,s){let n,r=e.type.toDOM;if(typeof r=="function")r=r(i,(()=>{if(!n)return s;if(n.parent)return n.parent.posBeforeChild(n)}));if(!e.type.spec.raw){if(r.nodeType!=1){let t=document.createElement("span");t.appendChild(r);r=t}r.contentEditable="false";r.classList.add("ProseMirror-widget")}super(t,[],r,null);this.widget=e;this.widget=e;n=this}matchesWidget(t){return this.dirty==Ss&&t.type.eq(this.widget.type)}parseRule(){return{ignore:true}}stopEvent(t){let e=this.widget.spec.stopEvent;return e?e(t):false}ignoreMutation(t){return t.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom);super.destroy()}get domAtom(){return true}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class Is extends Ts{constructor(t,e,i,s){super(t,[],e,null);this.textDOM=i;this.text=s}get size(){return this.text.length}localPosFromDOM(t,e){if(t!=this.textDOM)return this.posAtStart+(e?this.size:0);return this.posAtStart+e}domFromPos(t){return{node:this.textDOM,offset:t}}ignoreMutation(t){return t.type==="characterData"&&t.target.nodeValue==t.oldValue}}class Ps extends Ts{constructor(t,e,i,s,n){super(t,[],i,s);this.mark=e;this.spec=n}static create(t,e,i,s){let n=s.nodeViews[e.type.name];let r=n&&n(e,s,i);if(!r||!r.dom)r=At.renderSpec(document,e.type.spec.toDOM(e,i),null,e.attrs);return new Ps(t,e,r.dom,r.contentDOM||r.dom,r)}parseRule(){if(this.dirty&Es||this.mark.type.spec.reparseInView)return null;return{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(t){return this.dirty!=Es&&this.mark.eq(t)}markDirty(t,e){super.markDirty(t,e);if(this.dirty!=Ss){let t=this.parent;while(!t.node)t=t.parent;if(t.dirty<this.dirty)t.dirty=this.dirty;this.dirty=Ss}}slice(t,e,i){let s=Ps.create(this.parent,this.mark,true,i);let n=this.children,r=this.size;if(e<r)n=Zs(n,e,r,i);if(t>0)n=Zs(n,0,t,i);for(let t=0;t<n.length;t++)n[t].parent=s;s.children=n;return s}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}destroy(){if(this.spec.destroy)this.spec.destroy();super.destroy()}}class Rs extends Ts{constructor(t,e,i,s,n,r,o,h,l){super(t,[],n,r);this.node=e;this.outerDeco=i;this.innerDeco=s;this.nodeDOM=o}static create(t,e,i,s,n,r){let o=n.nodeViews[e.type.name],h;let l=o&&o(e,n,(()=>{if(!h)return r;if(h.parent)return h.parent.posBeforeChild(h)}),i,s);let f=l&&l.dom,u=l&&l.contentDOM;if(e.isText){if(!f)f=document.createTextNode(e.text);else if(f.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else if(!f){let t=At.renderSpec(document,e.type.spec.toDOM(e),null,e.attrs);({dom:f,contentDOM:u}=t)}if(!u&&!e.isText&&f.nodeName!="BR"){if(!f.hasAttribute("contenteditable"))f.contentEditable="false";if(e.type.spec.draggable)f.draggable=true}let c=f;f=Xs(f,i,e);if(l)return h=new Bs(t,e,i,s,f,u||null,c,l,n,r+1);else if(e.isText)return new Us(t,e,i,s,f,c,n);else return new Rs(t,e,i,s,f,u||null,c,n,r+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre")t.preserveWhitespace="full";if(!this.contentDOM){t.getContent=()=>this.node.content}else if(!this.contentLost){t.contentElement=this.contentDOM}else{for(let e=this.children.length-1;e>=0;e--){let i=this.children[e];if(this.dom.contains(i.dom.parentNode)){t.contentElement=i.dom.parentNode;break}}if(!t.contentElement)t.getContent=()=>f.empty}return t}matchesNode(t,e,i){return this.dirty==Ss&&t.eq(this.node)&&Ws(e,this.outerDeco)&&i.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(t,e){let i=this.node.inlineContent,s=e;let n=t.composing?this.localCompositionInfo(t,e):null;let r=n&&n.pos>-1?n:null;let o=n&&n.pos<0;let h=new Hs(this,r&&r.node,t);qs(this.node,this.innerDeco,((e,n,r)=>{if(e.spec.marks)h.syncToMarks(e.spec.marks,i,t);else if(e.type.side>=0&&!r)h.syncToMarks(n==this.node.childCount?d.none:this.node.child(n).marks,i,t);h.placeWidget(e,t,s)}),((e,r,l,f)=>{h.syncToMarks(e.marks,i,t);let u;if(h.findNodeMatch(e,r,l,f));else if(o&&t.state.selection.from>s&&t.state.selection.to<s+e.nodeSize&&(u=h.findIndexWithChild(n.node))>-1&&h.updateNodeAt(e,r,l,u,t));else if(h.updateNextNode(e,r,l,t,f,s));else{h.addNode(e,r,l,t,s)}s+=e.nodeSize}));h.syncToMarks([],i,t);if(this.node.isTextblock)h.addTextblockHacks();h.destroyRest();if(h.changed||this.dirty==Os){if(r)this.protectLocalComposition(t,r);Fs(this.contentDOM,this.children,t);if(Li)Ks(this.dom)}}localCompositionInfo(t,e){let{from:i,to:s}=t.state.selection;if(!(t.state.selection instanceof Ye)||i<e||s>e+this.node.content.size)return null;let n=t.input.compositionNode;if(!n||!this.dom.contains(n.parentNode))return null;if(this.node.inlineContent){let t=n.nodeValue;let r=Gs(this.node.content,t,i-e,s-e);return r<0?null:{node:n,pos:r,text:t}}else{return{node:n,pos:-1,text:""}}}protectLocalComposition(t,{node:e,pos:i,text:s}){if(this.getDesc(e))return;let n=e;for(;;n=n.parentNode){if(n.parentNode==this.contentDOM)break;while(n.previousSibling)n.parentNode.removeChild(n.previousSibling);while(n.nextSibling)n.parentNode.removeChild(n.nextSibling);if(n.pmViewDesc)n.pmViewDesc=undefined}let r=new Is(this,n,e,s);t.input.compositionNodes.push(r);this.children=Zs(this.children,i,i+s.length,t,r)}update(t,e,i,s){if(this.dirty==Es||!t.sameMarkup(this.node))return false;this.updateInner(t,e,i,s);return true}updateInner(t,e,i,s){this.updateOuterDeco(e);this.node=t;this.innerDeco=i;if(this.contentDOM)this.updateChildren(s,this.posAtStart);this.dirty=Ss}updateOuterDeco(t){if(Ws(t,this.outerDeco))return;let e=this.nodeDOM.nodeType!=1;let i=this.dom;this.dom=zs(this.dom,this.nodeDOM,_s(this.outerDeco,this.node,e),_s(t,this.node,e));if(this.dom!=i){i.pmViewDesc=undefined;this.dom.pmViewDesc=this}this.outerDeco=t}selectNode(){if(this.nodeDOM.nodeType==1){this.nodeDOM.classList.add("ProseMirror-selectednode");if(this.contentDOM||!this.node.type.spec.draggable)this.nodeDOM.draggable=true}}deselectNode(){if(this.nodeDOM.nodeType==1){this.nodeDOM.classList.remove("ProseMirror-selectednode");if(this.contentDOM||!this.node.type.spec.draggable)this.nodeDOM.removeAttribute("draggable")}}get domAtom(){return this.node.isAtom}}function $s(t,e,i,s,n){Xs(s,e,t);let r=new Rs(undefined,t,e,i,s,s,s,n,0);if(r.contentDOM)r.updateChildren(n,0);return r}class Us extends Rs{constructor(t,e,i,s,n,r,o){super(t,e,i,s,n,null,r,o,0)}parseRule(){let t=this.nodeDOM.parentNode;while(t&&t!=this.dom&&!t.pmIsDeco)t=t.parentNode;return{skip:t||true}}update(t,e,i,s){if(this.dirty==Es||this.dirty!=Ss&&!this.inParent()||!t.sameMarkup(this.node))return false;this.updateOuterDeco(e);if((this.dirty!=Ss||t.text!=this.node.text)&&t.text!=this.nodeDOM.nodeValue){this.nodeDOM.nodeValue=t.text;if(s.trackWrites==this.nodeDOM)s.trackWrites=null}this.node=t;this.dirty=Ss;return true}inParent(){let t=this.parent.contentDOM;for(let e=this.nodeDOM;e;e=e.parentNode)if(e==t)return true;return false}domFromPos(t){return{node:this.nodeDOM,offset:t}}localPosFromDOM(t,e,i){if(t==this.nodeDOM)return this.posAtStart+Math.min(e,this.node.text.length);return super.localPosFromDOM(t,e,i)}ignoreMutation(t){return t.type!="characterData"&&t.type!="selection"}slice(t,e,i){let s=this.node.cut(t,e),n=document.createTextNode(s.text);return new Us(this.parent,s,this.outerDeco,this.innerDeco,n,n,i)}markDirty(t,e){super.markDirty(t,e);if(this.dom!=this.nodeDOM&&(t==0||e==this.nodeDOM.nodeValue.length))this.dirty=Es}get domAtom(){return false}isText(t){return this.node.text==t}}class js extends Ts{parseRule(){return{ignore:true}}matchesHack(t){return this.dirty==Ss&&this.dom.nodeName==t}get domAtom(){return true}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Bs extends Rs{constructor(t,e,i,s,n,r,o,h,l,f){super(t,e,i,s,n,r,o,l,f);this.spec=h}update(t,e,i,s){if(this.dirty==Es)return false;if(this.spec.update&&(this.node.type==t.type||this.spec.multiType)){let n=this.spec.update(t,e,i);if(n)this.updateInner(t,e,i,s);return n}else if(!this.contentDOM&&!t.isLeaf){return false}else{return super.update(t,e,i,s)}}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(t,e,i,s){this.spec.setSelection?this.spec.setSelection(t,e,i.root):super.setSelection(t,e,i,s)}destroy(){if(this.spec.destroy)this.spec.destroy();super.destroy()}stopEvent(t){return this.spec.stopEvent?this.spec.stopEvent(t):false}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}}function Fs(t,e,i){let s=t.firstChild,n=false;for(let r=0;r<e.length;r++){let o=e[r],h=o.dom;if(h.parentNode==t){while(h!=s){s=Js(s);n=true}s=s.nextSibling}else{n=true;t.insertBefore(h,s)}if(o instanceof Ps){let e=s?s.previousSibling:t.lastChild;Fs(o.contentDOM,o.children,i);s=e?e.nextSibling:t.firstChild}}while(s){s=Js(s);n=true}if(n&&i.trackWrites==t)i.trackWrites=null}const Ns=function(t){if(t)this.nodeName=t};Ns.prototype=Object.create(null);const Ls=[new Ns];function _s(t,e,i){if(t.length==0)return Ls;let s=i?Ls[0]:new Ns,n=[s];for(let r=0;r<t.length;r++){let o=t[r].type.attrs;if(!o)continue;if(o.nodeName)n.push(s=new Ns(o.nodeName));for(let t in o){let r=o[t];if(r==null)continue;if(i&&n.length==1)n.push(s=new Ns(e.isInline?"span":"div"));if(t=="class")s.class=(s.class?s.class+" ":"")+r;else if(t=="style")s.style=(s.style?s.style+";":"")+r;else if(t!="nodeName")s[t]=r}}return n}function zs(t,e,i,s){if(i==Ls&&s==Ls)return e;let n=e;for(let e=0;e<s.length;e++){let r=s[e],o=i[e];if(e){let e;if(o&&o.nodeName==r.nodeName&&n!=t&&(e=n.parentNode)&&e.nodeName.toLowerCase()==r.nodeName){n=e}else{e=document.createElement(r.nodeName);e.pmIsDeco=true;e.appendChild(n);o=Ls[0];n=e}}Ys(n,o||Ls[0],r)}return n}function Ys(t,e,i){for(let s in e)if(s!="class"&&s!="style"&&s!="nodeName"&&!(s in i))t.removeAttribute(s);for(let s in i)if(s!="class"&&s!="style"&&s!="nodeName"&&i[s]!=e[s])t.setAttribute(s,i[s]);if(e.class!=i.class){let s=e.class?e.class.split(" ").filter(Boolean):[];let n=i.class?i.class.split(" ").filter(Boolean):[];for(let e=0;e<s.length;e++)if(n.indexOf(s[e])==-1)t.classList.remove(s[e]);for(let e=0;e<n.length;e++)if(s.indexOf(n[e])==-1)t.classList.add(n[e]);if(t.classList.length==0)t.removeAttribute("class")}if(e.style!=i.style){if(e.style){let i=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,s;while(s=i.exec(e.style))t.style.removeProperty(s[1])}if(i.style)t.style.cssText+=i.style}}function Xs(t,e,i){return zs(t,t,Ls,_s(e,i,t.nodeType!=1))}function Ws(t,e){if(t.length!=e.length)return false;for(let i=0;i<t.length;i++)if(!t[i].type.eq(e[i].type))return false;return true}function Js(t){let e=t.nextSibling;t.parentNode.removeChild(t);return e}class Hs{constructor(t,e,i){this.lock=e;this.view=i;this.index=0;this.stack=[];this.changed=false;this.top=t;this.preMatch=Vs(t.node.content,t)}destroyBetween(t,e){if(t==e)return;for(let i=t;i<e;i++)this.top.children[i].destroy();this.top.children.splice(t,e-t);this.changed=true}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(t,e,i){let s=0,n=this.stack.length>>1;let r=Math.min(n,t.length);while(s<r&&(s==n-1?this.top:this.stack[s+1<<1]).matchesMark(t[s])&&t[s].type.spec.spanning!==false)s++;while(s<n){this.destroyRest();this.top.dirty=Ss;this.index=this.stack.pop();this.top=this.stack.pop();n--}while(n<t.length){this.stack.push(this.top,this.index+1);let s=-1;for(let e=this.index;e<Math.min(this.index+3,this.top.children.length);e++){let i=this.top.children[e];if(i.matchesMark(t[n])&&!this.isLocked(i.dom)){s=e;break}}if(s>-1){if(s>this.index){this.changed=true;this.destroyBetween(this.index,s)}this.top=this.top.children[this.index]}else{let s=Ps.create(this.top,t[n],e,i);this.top.children.splice(this.index,0,s);this.top=s;this.changed=true}this.index=0;n++}}findNodeMatch(t,e,i,s){let n=-1,r;if(s>=this.preMatch.index&&(r=this.preMatch.matches[s-this.preMatch.index]).parent==this.top&&r.matchesNode(t,e,i)){n=this.top.children.indexOf(r,this.index)}else{for(let s=this.index,r=Math.min(this.top.children.length,s+5);s<r;s++){let r=this.top.children[s];if(r.matchesNode(t,e,i)&&!this.preMatch.matched.has(r)){n=s;break}}}if(n<0)return false;this.destroyBetween(this.index,n);this.index++;return true}updateNodeAt(t,e,i,s,n){let r=this.top.children[s];if(r.dirty==Es&&r.dom==r.contentDOM)r.dirty=Os;if(!r.update(t,e,i,n))return false;this.destroyBetween(this.index,s);this.index++;return true}findIndexWithChild(t){for(;;){let e=t.parentNode;if(!e)return-1;if(e==this.top.contentDOM){let e=t.pmViewDesc;if(e)for(let t=this.index;t<this.top.children.length;t++){if(this.top.children[t]==e)return t}return-1}t=e}}updateNextNode(t,e,i,s,n,r){for(let o=this.index;o<this.top.children.length;o++){let h=this.top.children[o];if(h instanceof Rs){let l=this.preMatch.matched.get(h);if(l!=null&&l!=n)return false;let f=h.dom,u;let c=this.isLocked(f)&&!(t.isText&&h.node&&h.node.isText&&h.nodeDOM.nodeValue==t.text&&h.dirty!=Es&&Ws(e,h.outerDeco));if(!c&&h.update(t,e,i,s)){this.destroyBetween(this.index,o);if(h.dom!=f)this.changed=true;this.index++;return true}else if(!c&&(u=this.recreateWrapper(h,t,e,i,s,r))){this.destroyBetween(this.index,o);this.top.children[this.index]=u;if(u.contentDOM){u.dirty=Os;u.updateChildren(s,r+1);u.dirty=Ss}this.changed=true;this.index++;return true}break}}return false}recreateWrapper(t,e,i,s,n,r){if(t.dirty||e.isAtom||!t.children.length||!t.node.content.eq(e.content)||!Ws(i,t.outerDeco)||!s.eq(t.innerDeco))return null;let o=Rs.create(this.top,e,i,s,n,r);if(o.contentDOM){o.children=t.children;t.children=[];for(let t of o.children)t.parent=o}t.destroy();return o}addNode(t,e,i,s,n){let r=Rs.create(this.top,t,e,i,s,n);if(r.contentDOM)r.updateChildren(s,n+1);this.top.children.splice(this.index++,0,r);this.changed=true}placeWidget(t,e,i){let s=this.index<this.top.children.length?this.top.children[this.index]:null;if(s&&s.matchesWidget(t)&&(t==s.widget||!s.widget.type.toDOM.parentNode)){this.index++}else{let s=new Ds(this.top,t,e,i);this.top.children.splice(this.index++,0,s);this.changed=true}}addTextblockHacks(){let t=this.top.children[this.index-1],e=this.top;while(t instanceof Ps){e=t;t=e.children[e.children.length-1]}if(!t||!(t instanceof Us)||/\n$/.test(t.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(t.node.text)){if((Ni||Bi)&&t&&t.dom.contentEditable=="false")this.addHackNode("IMG",e);this.addHackNode("BR",this.top)}}addHackNode(t,e){if(e==this.top&&this.index<e.children.length&&e.children[this.index].matchesHack(t)){this.index++}else{let i=document.createElement(t);if(t=="IMG"){i.className="ProseMirror-separator";i.alt=""}if(t=="BR")i.className="ProseMirror-trailingBreak";let s=new js(this.top,[],i,null);if(e!=this.top)e.children.push(s);else e.children.splice(this.index++,0,s);this.changed=true}}isLocked(t){return this.lock&&(t==this.lock||t.nodeType==1&&t.contains(this.lock.parentNode))}}function Vs(t,e){let i=e,s=i.children.length;let n=t.childCount,r=new Map,o=[];t:while(n>0){let h;for(;;){if(s){let t=i.children[s-1];if(t instanceof Ps){i=t;s=t.children.length}else{h=t;s--;break}}else if(i==e){break t}else{s=i.parent.children.indexOf(i);i=i.parent}}let l=h.node;if(!l)continue;if(l!=t.child(n-1))break;--n;r.set(h,n);o.push(h)}return{index:n,matched:r,matches:o.reverse()}}function Qs(t,e){return t.type.side-e.type.side}function qs(t,e,i,s){let n=e.locals(t),r=0;if(n.length==0){for(let i=0;i<t.childCount;i++){let o=t.child(i);s(o,n,e.forChild(r,o),i);r+=o.nodeSize}return}let o=0,h=[],l=null;for(let f=0;;){let u,c;while(o<n.length&&n[o].to==r){let t=n[o++];if(t.widget){if(!u)u=t;else(c||(c=[u])).push(t)}}if(u){if(c){c.sort(Qs);for(let t=0;t<c.length;t++)i(c[t],f,!!l)}else{i(u,f,!!l)}}let a,d;if(l){d=-1;a=l;l=null}else if(f<t.childCount){d=f;a=t.child(f++)}else{break}for(let t=0;t<h.length;t++)if(h[t].to<=r)h.splice(t--,1);while(o<n.length&&n[o].from<=r&&n[o].to>r)h.push(n[o++]);let w=r+a.nodeSize;if(a.isText){let t=w;if(o<n.length&&n[o].from<t)t=n[o].from;for(let e=0;e<h.length;e++)if(h[e].to<t)t=h[e].to;if(t<w){l=a.cut(t-r);a=a.cut(0,t-r);w=t;d=-1}}else{while(o<n.length&&n[o].to<w)o++}let p=a.isInline&&!a.isLeaf?h.filter((t=>!t.inline)):h.slice();s(a,p,e.forChild(r,a),d);r=w}}function Ks(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important";window.getComputedStyle(t).listStyle;t.style.cssText=e}}function Gs(t,e,i,s){for(let n=0,r=0;n<t.childCount&&r<=s;){let o=t.child(n++),h=r;r+=o.nodeSize;if(!o.isText)continue;let l=o.text;while(n<t.childCount){let e=t.child(n++);r+=e.nodeSize;if(!e.isText)break;l+=e.text}if(r>=i){if(r>=s&&l.slice(s-e.length-h,s-h)==e)return s-e.length;let t=h<s?l.lastIndexOf(e,s-h-1):-1;if(t>=0&&t+e.length+h>=i)return h+t;if(i==s&&l.length>=s+e.length-h&&l.slice(s-h,s-h+e.length)==e)return s}}return-1}function Zs(t,e,i,s,n){let r=[];for(let o=0,h=0;o<t.length;o++){let l=t[o],f=h,u=h+=l.size;if(f>=i||u<=e){r.push(l)}else{if(f<e)r.push(l.slice(0,e-f,s));if(n){r.push(n);n=undefined}if(u>i)r.push(l.slice(i-f,l.size,s))}}return r}function tn(t,e=null){let i=t.domSelectionRange(),s=t.state.doc;if(!i.focusNode)return null;let n=t.docView.nearestDesc(i.focusNode),r=n&&n.size==0;let o=t.docView.posFromDOM(i.focusNode,i.focusOffset,1);if(o<0)return null;let h=s.resolve(o),l,f;if(Ai(i)){l=o;while(n&&!n.node)n=n.parent;let t=n.node;if(n&&t.isAtom&&We.isSelectable(t)&&n.parent&&!(t.isInline&&Mi(i.focusNode,i.focusOffset,n.dom))){let t=n.posBefore;f=new We(o==t?h:s.resolve(t))}}else{if(i instanceof t.dom.ownerDocument.defaultView.Selection&&i.rangeCount>1){let e=o,n=o;for(let s=0;s<i.rangeCount;s++){let r=i.getRangeAt(s);e=Math.min(e,t.docView.posFromDOM(r.startContainer,r.startOffset,1));n=Math.max(n,t.docView.posFromDOM(r.endContainer,r.endOffset,-1))}if(e<0)return null;[l,o]=n==t.state.selection.anchor?[n,e]:[e,n];h=s.resolve(o)}else{l=t.docView.posFromDOM(i.anchorNode,i.anchorOffset,1)}if(l<0)return null}let u=s.resolve(l);if(!f){let i=e=="pointer"||t.state.selection.head<h.pos&&!r?1:-1;f=an(t,u,h,i)}return f}function en(t){return t.editable?t.hasFocus():wn(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function sn(t,e=false){let i=t.state.selection;un(t,i);if(!en(t))return;if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&Bi){let e=t.domSelectionRange(),i=t.domObserver.currentSelection;if(e.anchorNode&&i.anchorNode&&pi(e.anchorNode,e.anchorOffset,i.anchorNode,i.anchorOffset)){t.input.mouseDown.delayedSelectionSync=true;t.domObserver.setCurSelection();return}}t.domObserver.disconnectSelection();if(t.cursorWrapper){fn(t)}else{let{anchor:s,head:n}=i,r,o;if(nn&&!(i instanceof Ye)){if(!i.$from.parent.inlineContent)r=rn(t,i.from);if(!i.empty&&!i.$from.parent.inlineContent)o=rn(t,i.to)}t.docView.setSelection(s,n,t,e);if(nn){if(r)hn(r);if(o)hn(o)}if(i.visible){t.dom.classList.remove("ProseMirror-hideselection")}else{t.dom.classList.add("ProseMirror-hideselection");if("onselectionchange"in document)ln(t)}}t.domObserver.setCurSelection();t.domObserver.connectSelection()}const nn=Ni||Bi&&Fi<63;function rn(t,e){let{node:i,offset:s}=t.docView.domFromPos(e,0);let n=s<i.childNodes.length?i.childNodes[s]:null;let r=s?i.childNodes[s-1]:null;if(Ni&&n&&n.contentEditable=="false")return on(n);if((!n||n.contentEditable=="false")&&(!r||r.contentEditable=="false")){if(n)return on(n);else if(r)return on(r)}}function on(t){t.contentEditable="true";if(Ni&&t.draggable){t.draggable=false;t.wasDraggable=true}return t}function hn(t){t.contentEditable="false";if(t.wasDraggable){t.draggable=true;t.wasDraggable=null}}function ln(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let i=t.domSelectionRange();let s=i.anchorNode,n=i.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{if(i.anchorNode!=s||i.anchorOffset!=n){e.removeEventListener("selectionchange",t.input.hideSelectionGuard);setTimeout((()=>{if(!en(t)||t.state.selection.visible)t.dom.classList.remove("ProseMirror-hideselection")}),20)}})}function fn(t){let e=t.domSelection();if(!e)return;let i=t.cursorWrapper.dom,s=i.nodeName=="IMG";if(s)e.collapse(i.parentNode,ui(i)+1);else e.collapse(i,0);if(!s&&!t.state.selection.visible&&Ri&&$i<=11){i.disabled=true;i.disabled=false}}function un(t,e){if(e instanceof We){let i=t.docView.descAt(e.from);if(i!=t.lastSelectedViewDesc){cn(t);if(i)i.selectNode();t.lastSelectedViewDesc=i}}else{cn(t)}}function cn(t){if(t.lastSelectedViewDesc){if(t.lastSelectedViewDesc.parent)t.lastSelectedViewDesc.deselectNode();t.lastSelectedViewDesc=undefined}}function an(t,e,i,s){return t.someProp("createSelectionBetween",(s=>s(t,e,i)))||Ye.between(e,i,s)}function dn(t){if(t.editable&&!t.hasFocus())return false;return wn(t)}function wn(t){let e=t.domSelectionRange();if(!e.anchorNode)return false;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch(t){return false}}function pn(t){let e=t.docView.domFromPos(t.state.selection.anchor,0);let i=t.domSelectionRange();return pi(e.node,e.offset,i.anchorNode,i.anchorOffset)}function gn(t,e){let{$anchor:i,$head:s}=t.selection;let n=e>0?i.max(s):i.min(s);let r=!n.parent.inlineContent?n:n.depth?t.doc.resolve(e>0?n.after():n.before()):null;return r&&Ne.findFrom(r,e)}function mn(t,e){t.dispatch(t.state.tr.setSelection(e).scrollIntoView());return true}function yn(t,e,i){let s=t.state.selection;if(s instanceof Ye){if(i.indexOf("s")>-1){let{$head:i}=s,n=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!n||n.isText||!n.isLeaf)return false;let r=t.state.doc.resolve(i.pos+n.nodeSize*(e<0?-1:1));return mn(t,new Ye(s.$anchor,r))}else if(!s.empty){return false}else if(t.endOfTextblock(e>0?"forward":"backward")){let i=gn(t.state,e);if(i&&i instanceof We)return mn(t,i);return false}else if(!(_i&&i.indexOf("m")>-1)){let i=s.$head,n=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,r;if(!n||n.isText)return false;let o=e<0?i.pos-n.nodeSize:i.pos;if(!(n.isAtom||(r=t.docView.descAt(o))&&!r.contentDOM))return false;if(We.isSelectable(n)){return mn(t,new We(e<0?t.state.doc.resolve(i.pos-n.nodeSize):i))}else if(Xi){return mn(t,new Ye(t.state.doc.resolve(e<0?o:o+n.nodeSize)))}else{return false}}}else if(s instanceof We&&s.node.isInline){return mn(t,new Ye(e>0?s.$to:s.$from))}else{let i=gn(t.state,e);if(i)return mn(t,i);return false}}function vn(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function bn(t,e){let i=t.pmViewDesc;return i&&i.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function Mn(t,e){return e<0?kn(t):An(t)}function kn(t){let e=t.domSelectionRange();let i=e.focusNode,s=e.focusOffset;if(!i)return;let n,r,o=false;if(Ui&&i.nodeType==1&&s<vn(i)&&bn(i.childNodes[s],-1))o=true;for(;;){if(s>0){if(i.nodeType!=1){break}else{let t=i.childNodes[s-1];if(bn(t,-1)){n=i;r=--s}else if(t.nodeType==3){i=t;s=i.nodeValue.length}else break}}else if(xn(i)){break}else{let e=i.previousSibling;while(e&&bn(e,-1)){n=i.parentNode;r=ui(e);e=e.previousSibling}if(!e){i=i.parentNode;if(i==t.dom)break;s=0}else{i=e;s=vn(i)}}}if(o)On(t,i,s);else if(n)On(t,n,r)}function An(t){let e=t.domSelectionRange();let i=e.focusNode,s=e.focusOffset;if(!i)return;let n=vn(i);let r,o;for(;;){if(s<n){if(i.nodeType!=1)break;let t=i.childNodes[s];if(bn(t,1)){r=i;o=++s}else break}else if(xn(i)){break}else{let e=i.nextSibling;while(e&&bn(e,1)){r=e.parentNode;o=ui(e)+1;e=e.nextSibling}if(!e){i=i.parentNode;if(i==t.dom)break;s=n=0}else{i=e;s=0;n=vn(i)}}}if(r)On(t,r,o)}function xn(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function Sn(t,e){while(t&&e==t.childNodes.length&&!ki(t)){e=ui(t)+1;t=t.parentNode}while(t&&e<t.childNodes.length){let i=t.childNodes[e];if(i.nodeType==3)return i;if(i.nodeType==1&&i.contentEditable=="false")break;t=i;e=0}}function Cn(t,e){while(t&&!e&&!ki(t)){e=ui(t);t=t.parentNode}while(t&&e){let i=t.childNodes[e-1];if(i.nodeType==3)return i;if(i.nodeType==1&&i.contentEditable=="false")break;t=i;e=t.childNodes.length}}function On(t,e,i){if(e.nodeType!=3){let t,s;if(s=Sn(e,i)){e=s;i=0}else if(t=Cn(e,i)){e=t;i=t.nodeValue.length}}let s=t.domSelection();if(!s)return;if(Ai(s)){let t=document.createRange();t.setEnd(e,i);t.setStart(e,i);s.removeAllRanges();s.addRange(t)}else if(s.extend){s.extend(e,i)}t.domObserver.setCurSelection();let{state:n}=t;setTimeout((()=>{if(t.state==n)sn(t)}),50)}function En(t,e){let i=t.state.doc.resolve(e);if(!(Bi||zi)&&i.parent.inlineContent){let s=t.coordsAtPos(e);if(e>i.start()){let i=t.coordsAtPos(e-1);let n=(i.top+i.bottom)/2;if(n>s.top&&n<s.bottom&&Math.abs(i.left-s.left)>1)return i.left<s.left?"ltr":"rtl"}if(e<i.end()){let i=t.coordsAtPos(e+1);let n=(i.top+i.bottom)/2;if(n>s.top&&n<s.bottom&&Math.abs(i.left-s.left)>1)return i.left>s.left?"ltr":"rtl"}}let s=getComputedStyle(t.dom).direction;return s=="rtl"?"rtl":"ltr"}function Tn(t,e,i){let s=t.state.selection;if(s instanceof Ye&&!s.empty||i.indexOf("s")>-1)return false;if(_i&&i.indexOf("m")>-1)return false;let{$from:n,$to:r}=s;if(!n.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let i=gn(t.state,e);if(i&&i instanceof We)return mn(t,i)}if(!n.parent.inlineContent){let i=e<0?n:r;let o=s instanceof He?Ne.near(i,e):Ne.findFrom(i,e);return o?mn(t,o):false}return false}function Dn(t,e){if(!(t.state.selection instanceof Ye))return true;let{$head:i,$anchor:s,empty:n}=t.state.selection;if(!i.sameParent(s))return true;if(!n)return false;if(t.endOfTextblock(e>0?"forward":"backward"))return true;let r=!i.textOffset&&(e<0?i.nodeBefore:i.nodeAfter);if(r&&!r.isText){let s=t.state.tr;if(e<0)s.delete(i.pos-r.nodeSize,i.pos);else s.delete(i.pos,i.pos+r.nodeSize);t.dispatch(s);return true}return false}function In(t,e,i){t.domObserver.stop();e.contentEditable=i;t.domObserver.start()}function Pn(t){if(!Ni||t.state.selection.$head.parentOffset>0)return false;let{focusNode:e,focusOffset:i}=t.domSelectionRange();if(e&&e.nodeType==1&&i==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let i=e.firstChild;In(t,i,"true");setTimeout((()=>In(t,i,"false")),20)}return false}function Rn(t){let e="";if(t.ctrlKey)e+="c";if(t.metaKey)e+="m";if(t.altKey)e+="a";if(t.shiftKey)e+="s";return e}function $n(t,e){let i=e.keyCode,s=Rn(e);if(i==8||_i&&i==72&&s=="c"){return Dn(t,-1)||Mn(t,-1)}else if(i==46&&!e.shiftKey||_i&&i==68&&s=="c"){return Dn(t,1)||Mn(t,1)}else if(i==13||i==27){return true}else if(i==37||_i&&i==66&&s=="c"){let e=i==37?En(t,t.state.selection.from)=="ltr"?-1:1:-1;return yn(t,e,s)||Mn(t,e)}else if(i==39||_i&&i==70&&s=="c"){let e=i==39?En(t,t.state.selection.from)=="ltr"?1:-1:1;return yn(t,e,s)||Mn(t,e)}else if(i==38||_i&&i==80&&s=="c"){return Tn(t,-1,s)||Mn(t,-1)}else if(i==40||_i&&i==78&&s=="c"){return Pn(t)||Tn(t,1,s)||Mn(t,1)}else if(s==(_i?"m":"c")&&(i==66||i==73||i==89||i==90)){return true}return false}function Un(t,e){t.someProp("transformCopied",(i=>{e=i(e,t)}));let i=[],{content:s,openStart:n,openEnd:r}=e;while(n>1&&r>1&&s.childCount==1&&s.firstChild.childCount==1){n--;r--;let t=s.firstChild;i.push(t.type.name,t.attrs!=t.type.defaultAttrs?t.attrs:null);s=t.content}let o=t.someProp("clipboardSerializer")||At.fromSchema(t.state.schema);let h=Jn(),l=h.createElement("div");l.appendChild(o.serializeFragment(s,{document:h}));let f=l.firstChild,u,c=0;while(f&&f.nodeType==1&&(u=Xn[f.nodeName.toLowerCase()])){for(let t=u.length-1;t>=0;t--){let e=h.createElement(u[t]);while(l.firstChild)e.appendChild(l.firstChild);l.appendChild(e);c++}f=l.firstChild}if(f&&f.nodeType==1)f.setAttribute("data-pm-slice",`${n} ${r}${c?` -${c}`:""} ${JSON.stringify(i)}`);let a=t.someProp("clipboardTextSerializer",(i=>i(e,t)))||e.content.textBetween(0,e.content.size,"\n\n");return{dom:l,text:a,slice:e}}function jn(t,e,i,s,n){let r=n.parent.type.spec.code;let o,h;if(!i&&!e)return null;let l=!!e&&(s||r||!i);if(l){t.someProp("transformPastedText",(i=>{e=i(e,r||s,t)}));if(r){h=new p(f.from(t.state.schema.text(e.replace(/\r\n?/g,"\n"))),0,0);t.someProp("transformPasted",(e=>{h=e(h,t,true)}));return h}let i=t.someProp("clipboardTextParser",(i=>i(e,n,s,t)));if(i){h=i}else{let i=n.marks();let{schema:s}=t.state,r=At.fromSchema(s);o=document.createElement("div");e.split(/(?:\r\n?|\n)+/).forEach((t=>{let e=o.appendChild(document.createElement("p"));if(t)e.appendChild(r.serializeNode(s.text(t,i)))}))}}else{t.someProp("transformPastedHTML",(e=>{i=e(i,t)}));o=Qn(i);if(Xi)qn(o)}let u=o&&o.querySelector("[data-pm-slice]");let c=u&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(u.getAttribute("data-pm-slice")||"");if(c&&c[3])for(let t=+c[3];t>0;t--){let t=o.firstChild;while(t&&t.nodeType!=1)t=t.nextSibling;if(!t)break;o=t}if(!h){let e=t.someProp("clipboardParser")||t.someProp("domParser")||ft.fromSchema(t.state.schema);h=e.parseSlice(o,{preserveWhitespace:!!(l||c),context:n,ruleFromNode(t){if(t.nodeName=="BR"&&!t.nextSibling&&t.parentNode&&!Bn.test(t.parentNode.nodeName))return{ignore:true};return null}})}if(c){h=Kn(Yn(h,+c[1],+c[2]),c[4])}else{h=p.maxOpen(Fn(h.content,n),true);if(h.openStart||h.openEnd){let t=0,e=0;for(let e=h.content.firstChild;t<h.openStart&&!e.type.spec.isolating;t++,e=e.firstChild){}for(let t=h.content.lastChild;e<h.openEnd&&!t.type.spec.isolating;e++,t=t.lastChild){}h=Yn(h,t,e)}}t.someProp("transformPasted",(e=>{h=e(h,t,l)}));return h}const Bn=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function Fn(t,e){if(t.childCount<2)return t;for(let i=e.depth;i>=0;i--){let s=e.node(i);let n=s.contentMatchAt(e.index(i));let r,o=[];t.forEach((t=>{if(!o)return;let e=n.findWrapping(t.type),i;if(!e)return o=null;if(i=o.length&&r.length&&Ln(e,r,t,o[o.length-1],0)){o[o.length-1]=i}else{if(o.length)o[o.length-1]=_n(o[o.length-1],r.length);let i=Nn(t,e);o.push(i);n=n.matchType(i.type);r=e}}));if(o)return f.from(o)}return t}function Nn(t,e,i=0){for(let s=e.length-1;s>=i;s--)t=e[s].create(null,f.from(t));return t}function Ln(t,e,i,s,n){if(n<t.length&&n<e.length&&t[n]==e[n]){let r=Ln(t,e,i,s.lastChild,n+1);if(r)return s.copy(s.content.replaceChild(s.childCount-1,r));let o=s.contentMatchAt(s.childCount);if(o.matchType(n==t.length-1?i.type:t[n+1]))return s.copy(s.content.append(f.from(Nn(i,t,n+1))))}}function _n(t,e){if(e==0)return t;let i=t.content.replaceChild(t.childCount-1,_n(t.lastChild,e-1));let s=t.contentMatchAt(t.childCount).fillBefore(f.empty,true);return t.copy(i.append(s))}function zn(t,e,i,s,n,r){let o=e<0?t.firstChild:t.lastChild,h=o.content;if(t.childCount>1)r=0;if(n<s-1)h=zn(h,e,i,s,n+1,r);if(n>=i)h=e<0?o.contentMatchAt(0).fillBefore(h,r<=n).append(h):h.append(o.contentMatchAt(o.childCount).fillBefore(f.empty,true));return t.replaceChild(e<0?0:t.childCount-1,o.copy(h))}function Yn(t,e,i){if(e<t.openStart)t=new p(zn(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd);if(i<t.openEnd)t=new p(zn(t.content,1,i,t.openEnd,0,0),t.openStart,i);return t}const Xn={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let Wn=null;function Jn(){return Wn||(Wn=document.implementation.createHTMLDocument("title"))}let Hn=null;function Vn(t){let e=window.trustedTypes;if(!e)return t;if(!Hn)Hn=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t});return Hn.createHTML(t)}function Qn(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);if(e)t=t.slice(e[0].length);let i=Jn().createElement("div");let s=/<([a-z][^>\s]+)/i.exec(t),n;if(n=s&&Xn[s[1].toLowerCase()])t=n.map((t=>"<"+t+">")).join("")+t+n.map((t=>"</"+t+">")).reverse().join("");i.innerHTML=Vn(t);if(n)for(let t=0;t<n.length;t++)i=i.querySelector(n[t])||i;return i}function qn(t){let e=t.querySelectorAll(Bi?"span:not([class]):not([style])":"span.Apple-converted-space");for(let i=0;i<e.length;i++){let s=e[i];if(s.childNodes.length==1&&s.textContent==" "&&s.parentNode)s.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),s)}}function Kn(t,e){if(!t.size)return t;let i=t.content.firstChild.type.schema,s;try{s=JSON.parse(e)}catch(e){return t}let{content:n,openStart:r,openEnd:o}=t;for(let t=s.length-2;t>=0;t-=2){let e=i.nodes[s[t]];if(!e||e.hasRequiredAttrs())break;n=f.from(e.create(s[t+1],n));r++;o++}return new p(n,r,o)}const Gn={};const Zn={};const tr={touchstart:true,touchmove:true};class er{constructor(){this.shiftKey=false;this.mouseDown=null;this.lastKeyCode=null;this.lastKeyCodeTime=0;this.lastClick={time:0,x:0,y:0,type:"",button:0};this.lastSelectionOrigin=null;this.lastSelectionTime=0;this.lastIOSEnter=0;this.lastIOSEnterFallbackTimeout=-1;this.lastFocus=0;this.lastTouch=0;this.lastChromeDelete=0;this.composing=false;this.compositionNode=null;this.composingTimeout=-1;this.compositionNodes=[];this.compositionEndedAt=-2e8;this.compositionID=1;this.compositionPendingChanges=0;this.domChangeCount=0;this.eventHandlers=Object.create(null);this.hideSelectionGuard=null}}function ir(t){for(let e in Gn){let i=Gn[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=e=>{if(hr(t,e)&&!or(t,e)&&(t.editable||!(e.type in Zn)))i(t,e)},tr[e]?{passive:true}:undefined)}if(Ni)t.dom.addEventListener("input",(()=>null));rr(t)}function sr(t,e){t.input.lastSelectionOrigin=e;t.input.lastSelectionTime=Date.now()}function nr(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout);clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function rr(t){t.someProp("handleDOMEvents",(e=>{for(let i in e)if(!t.input.eventHandlers[i])t.dom.addEventListener(i,t.input.eventHandlers[i]=e=>or(t,e))}))}function or(t,e){return t.someProp("handleDOMEvents",(i=>{let s=i[e.type];return s?s(t,e)||e.defaultPrevented:false}))}function hr(t,e){if(!e.bubbles)return true;if(e.defaultPrevented)return false;for(let i=e.target;i!=t.dom;i=i.parentNode)if(!i||i.nodeType==11||i.pmViewDesc&&i.pmViewDesc.stopEvent(e))return false;return true}function lr(t,e){if(!or(t,e)&&Gn[e.type]&&(t.editable||!(e.type in Zn)))Gn[e.type](t,e)}Zn.keydown=(t,e)=>{let i=e;t.input.shiftKey=i.keyCode==16||i.shiftKey;if(kr(t,i))return;t.input.lastKeyCode=i.keyCode;t.input.lastKeyCodeTime=Date.now();if(Yi&&Bi&&i.keyCode==13)return;if(i.keyCode!=229)t.domObserver.forceFlush();if(Li&&i.keyCode==13&&!i.ctrlKey&&!i.altKey&&!i.metaKey){let e=Date.now();t.input.lastIOSEnter=e;t.input.lastIOSEnterFallbackTimeout=setTimeout((()=>{if(t.input.lastIOSEnter==e){t.someProp("handleKeyDown",(e=>e(t,xi(13,"Enter"))));t.input.lastIOSEnter=0}}),200)}else if(t.someProp("handleKeyDown",(e=>e(t,i)))||$n(t,i)){i.preventDefault()}else{sr(t,"key")}};Zn.keyup=(t,e)=>{if(e.keyCode==16)t.input.shiftKey=false};Zn.keypress=(t,e)=>{let i=e;if(kr(t,i)||!i.charCode||i.ctrlKey&&!i.altKey||_i&&i.metaKey)return;if(t.someProp("handleKeyPress",(e=>e(t,i)))){i.preventDefault();return}let s=t.state.selection;if(!(s instanceof Ye)||!s.$from.sameParent(s.$to)){let e=String.fromCharCode(i.charCode);let n=()=>t.state.tr.insertText(e).scrollIntoView();if(!/[\r\n]/.test(e)&&!t.someProp("handleTextInput",(i=>i(t,s.$from.pos,s.$to.pos,e,n))))t.dispatch(n());i.preventDefault()}};function fr(t){return{left:t.clientX,top:t.clientY}}function ur(t,e){let i=e.x-t.clientX,s=e.y-t.clientY;return i*i+s*s<100}function cr(t,e,i,s,n){if(s==-1)return false;let r=t.state.doc.resolve(s);for(let s=r.depth+1;s>0;s--){if(t.someProp(e,(e=>s>r.depth?e(t,i,r.nodeAfter,r.before(s),n,true):e(t,i,r.node(s),r.before(s),n,false))))return true}return false}function ar(t,e,i){if(!t.focused)t.focus();if(t.state.selection.eq(e))return;let s=t.state.tr.setSelection(e);s.setMeta("pointer",true);t.dispatch(s)}function dr(t,e){if(e==-1)return false;let i=t.state.doc.resolve(e),s=i.nodeAfter;if(s&&s.isAtom&&We.isSelectable(s)){ar(t,new We(i));return true}return false}function wr(t,e){if(e==-1)return false;let i=t.state.selection,s,n;if(i instanceof We)s=i.node;let r=t.state.doc.resolve(e);for(let t=r.depth+1;t>0;t--){let e=t>r.depth?r.nodeAfter:r.node(t);if(We.isSelectable(e)){if(s&&i.$from.depth>0&&t>=i.$from.depth&&r.before(i.$from.depth+1)==i.$from.pos)n=r.before(i.$from.depth);else n=r.before(t);break}}if(n!=null){ar(t,We.create(t.state.doc,n));return true}else{return false}}function pr(t,e,i,s,n){return cr(t,"handleClickOn",e,i,s)||t.someProp("handleClick",(i=>i(t,e,s)))||(n?wr(t,i):dr(t,i))}function gr(t,e,i,s){return cr(t,"handleDoubleClickOn",e,i,s)||t.someProp("handleDoubleClick",(i=>i(t,e,s)))}function mr(t,e,i,s){return cr(t,"handleTripleClickOn",e,i,s)||t.someProp("handleTripleClick",(i=>i(t,e,s)))||yr(t,i,s)}function yr(t,e,i){if(i.button!=0)return false;let s=t.state.doc;if(e==-1){if(s.inlineContent){ar(t,Ye.create(s,0,s.content.size));return true}return false}let n=s.resolve(e);for(let e=n.depth+1;e>0;e--){let i=e>n.depth?n.nodeAfter:n.node(e);let r=n.before(e);if(i.inlineContent)ar(t,Ye.create(s,r+1,r+1+i.content.size));else if(We.isSelectable(i))ar(t,We.create(s,r));else continue;return true}}function vr(t){return Er(t)}const br=_i?"metaKey":"ctrlKey";Gn.mousedown=(t,e)=>{let i=e;t.input.shiftKey=i.shiftKey;let s=vr(t);let n=Date.now(),r="singleClick";if(n-t.input.lastClick.time<500&&ur(i,t.input.lastClick)&&!i[br]&&t.input.lastClick.button==i.button){if(t.input.lastClick.type=="singleClick")r="doubleClick";else if(t.input.lastClick.type=="doubleClick")r="tripleClick"}t.input.lastClick={time:n,x:i.clientX,y:i.clientY,type:r,button:i.button};let o=t.posAtCoords(fr(i));if(!o)return;if(r=="singleClick"){if(t.input.mouseDown)t.input.mouseDown.done();t.input.mouseDown=new Mr(t,o,i,!!s)}else if((r=="doubleClick"?gr:mr)(t,o.pos,o.inside,i)){i.preventDefault()}else{sr(t,"pointer")}};class Mr{constructor(t,e,i,s){this.view=t;this.pos=e;this.event=i;this.flushed=s;this.delayedSelectionSync=false;this.mightDrag=null;this.startDoc=t.state.doc;this.selectNode=!!i[br];this.allowDefault=i.shiftKey;let n,r;if(e.inside>-1){n=t.state.doc.nodeAt(e.inside);r=e.inside}else{let i=t.state.doc.resolve(e.pos);n=i.parent;r=i.depth?i.before():0}const o=s?null:i.target;const h=o?t.docView.nearestDesc(o,true):null;this.target=h&&h.nodeDOM.nodeType==1?h.nodeDOM:null;let{selection:l}=t.state;if(i.button==0&&n.type.spec.draggable&&n.type.spec.selectable!==false||l instanceof We&&l.from<=r&&l.to>r)this.mightDrag={node:n,pos:r,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Ui&&!this.target.hasAttribute("contentEditable"))};if(this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)){this.view.domObserver.stop();if(this.mightDrag.addAttr)this.target.draggable=true;if(this.mightDrag.setUneditable)setTimeout((()=>{if(this.view.input.mouseDown==this)this.target.setAttribute("contentEditable","false")}),20);this.view.domObserver.start()}t.root.addEventListener("mouseup",this.up=this.up.bind(this));t.root.addEventListener("mousemove",this.move=this.move.bind(this));sr(t,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up);this.view.root.removeEventListener("mousemove",this.move);if(this.mightDrag&&this.target){this.view.domObserver.stop();if(this.mightDrag.addAttr)this.target.removeAttribute("draggable");if(this.mightDrag.setUneditable)this.target.removeAttribute("contentEditable");this.view.domObserver.start()}if(this.delayedSelectionSync)setTimeout((()=>sn(this.view)));this.view.input.mouseDown=null}up(t){this.done();if(!this.view.dom.contains(t.target))return;let e=this.pos;if(this.view.state.doc!=this.startDoc)e=this.view.posAtCoords(fr(t));this.updateAllowDefault(t);if(this.allowDefault||!e){sr(this.view,"pointer")}else if(pr(this.view,e.pos,e.inside,t,this.selectNode)){t.preventDefault()}else if(t.button==0&&(this.flushed||Ni&&this.mightDrag&&!this.mightDrag.node.isAtom||Bi&&!this.view.state.selection.visible&&Math.min(Math.abs(e.pos-this.view.state.selection.from),Math.abs(e.pos-this.view.state.selection.to))<=2)){ar(this.view,Ne.near(this.view.state.doc.resolve(e.pos)));t.preventDefault()}else{sr(this.view,"pointer")}}move(t){this.updateAllowDefault(t);sr(this.view,"pointer");if(t.buttons==0)this.done()}updateAllowDefault(t){if(!this.allowDefault&&(Math.abs(this.event.x-t.clientX)>4||Math.abs(this.event.y-t.clientY)>4))this.allowDefault=true}}Gn.touchstart=t=>{t.input.lastTouch=Date.now();vr(t);sr(t,"pointer")};Gn.touchmove=t=>{t.input.lastTouch=Date.now();sr(t,"pointer")};Gn.contextmenu=t=>vr(t);function kr(t,e){if(t.composing)return true;if(Ni&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500){t.input.compositionEndedAt=-2e8;return true}return false}const Ar=Yi?5e3:-1;Zn.compositionstart=Zn.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,i=e.selection.$to;if(e.selection instanceof Ye&&(e.storedMarks||!i.textOffset&&i.parentOffset&&i.nodeBefore.marks.some((t=>t.type.spec.inclusive===false)))){t.markCursor=t.state.storedMarks||i.marks();Er(t,true);t.markCursor=null}else{Er(t,!e.selection.empty);if(Ui&&e.selection.empty&&i.parentOffset&&!i.textOffset&&i.nodeBefore.marks.length){let e=t.domSelectionRange();for(let i=e.focusNode,s=e.focusOffset;i&&i.nodeType==1&&s!=0;){let e=s<0?i.lastChild:i.childNodes[s-1];if(!e)break;if(e.nodeType==3){let i=t.domSelection();if(i)i.collapse(e,e.nodeValue.length);break}else{i=e;s=-1}}}}t.input.composing=true}xr(t,Ar)};Zn.compositionend=(t,e)=>{if(t.composing){t.input.composing=false;t.input.compositionEndedAt=e.timeStamp;t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0;t.input.compositionNode=null;if(t.input.compositionPendingChanges)Promise.resolve().then((()=>t.domObserver.flush()));t.input.compositionID++;xr(t,20)}};function xr(t,e){clearTimeout(t.input.composingTimeout);if(e>-1)t.input.composingTimeout=setTimeout((()=>Er(t)),e)}function Sr(t){if(t.composing){t.input.composing=false;t.input.compositionEndedAt=Or()}while(t.input.compositionNodes.length>0)t.input.compositionNodes.pop().markParentsDirty()}function Cr(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let i=vi(e.focusNode,e.focusOffset);let s=bi(e.focusNode,e.focusOffset);if(i&&s&&i!=s){let e=s.pmViewDesc,n=t.domObserver.lastChangedTextNode;if(i==n||s==n)return n;if(!e||!e.isText(s.nodeValue)){return s}else if(t.input.compositionNode==s){let t=i.pmViewDesc;if(!(!t||!t.isText(i.nodeValue)))return s}}return i||s}function Or(){let t=document.createEvent("Event");t.initEvent("event",true,true);return t.timeStamp}function Er(t,e=false){if(Yi&&t.domObserver.flushingSoon>=0)return;t.domObserver.forceFlush();Sr(t);if(e||t.docView&&t.docView.dirty){let i=tn(t),s=t.state.selection;if(i&&!i.eq(s))t.dispatch(t.state.tr.setSelection(i));else if((t.markCursor||e)&&!s.$from.node(s.$from.sharedDepth(s.to)).inlineContent)t.dispatch(t.state.tr.deleteSelection());else t.updateState(t.state);return true}return false}function Tr(t,e){if(!t.dom.parentNode)return;let i=t.dom.parentNode.appendChild(document.createElement("div"));i.appendChild(e);i.style.cssText="position: fixed; left: -10000px; top: 10px";let s=getSelection(),n=document.createRange();n.selectNodeContents(e);t.dom.blur();s.removeAllRanges();s.addRange(n);setTimeout((()=>{if(i.parentNode)i.parentNode.removeChild(i);t.focus()}),50)}const Dr=Ri&&$i<15||Li&&Wi<604;Gn.copy=Zn.cut=(t,e)=>{let i=e;let s=t.state.selection,n=i.type=="cut";if(s.empty)return;let r=Dr?null:i.clipboardData;let o=s.content(),{dom:h,text:l}=Un(t,o);if(r){i.preventDefault();r.clearData();r.setData("text/html",h.innerHTML);r.setData("text/plain",l)}else{Tr(t,h)}if(n)t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Ir(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function Pr(t,e){if(!t.dom.parentNode)return;let i=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code;let s=t.dom.parentNode.appendChild(document.createElement(i?"textarea":"div"));if(!i)s.contentEditable="true";s.style.cssText="position: fixed; left: -10000px; top: 10px";s.focus();let n=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout((()=>{t.focus();if(s.parentNode)s.parentNode.removeChild(s);if(i)Rr(t,s.value,null,n,e);else Rr(t,s.textContent,s.innerHTML,n,e)}),50)}function Rr(t,e,i,s,n){let r=jn(t,e,i,s,t.state.selection.$from);if(t.someProp("handlePaste",(e=>e(t,n,r||p.empty))))return true;if(!r)return false;let o=Ir(r);let h=o?t.state.tr.replaceSelectionWith(o,s):t.state.tr.replaceSelection(r);t.dispatch(h.scrollIntoView().setMeta("paste",true).setMeta("uiEvent","paste"));return true}function $r(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let i=t.getData("text/uri-list");return i?i.replace(/\r?\n/g," "):""}Zn.paste=(t,e)=>{let i=e;if(t.composing&&!Yi)return;let s=Dr?null:i.clipboardData;let n=t.input.shiftKey&&t.input.lastKeyCode!=45;if(s&&Rr(t,$r(s),s.getData("text/html"),n,i))i.preventDefault();else Pr(t,i)};class Ur{constructor(t,e,i){this.slice=t;this.move=e;this.node=i}}const jr=_i?"altKey":"ctrlKey";function Br(t,e){let i=t.someProp("dragCopies",(t=>!t(e)));return i!=null?i:!e[jr]}Gn.dragstart=(t,e)=>{let i=e;let s=t.input.mouseDown;if(s)s.done();if(!i.dataTransfer)return;let n=t.state.selection;let r=n.empty?null:t.posAtCoords(fr(i));let o;if(r&&r.pos>=n.from&&r.pos<=(n instanceof We?n.to-1:n.to));else if(s&&s.mightDrag){o=We.create(t.state.doc,s.mightDrag.pos)}else if(i.target&&i.target.nodeType==1){let e=t.docView.nearestDesc(i.target,true);if(e&&e.node.type.spec.draggable&&e!=t.docView)o=We.create(t.state.doc,e.posBefore)}let h=(o||t.state.selection).content();let{dom:l,text:f,slice:u}=Un(t,h);if(!i.dataTransfer.files.length||!Bi||Fi>120)i.dataTransfer.clearData();i.dataTransfer.setData(Dr?"Text":"text/html",l.innerHTML);i.dataTransfer.effectAllowed="copyMove";if(!Dr)i.dataTransfer.setData("text/plain",f);t.dragging=new Ur(u,Br(t,i),o)};Gn.dragend=t=>{let e=t.dragging;window.setTimeout((()=>{if(t.dragging==e)t.dragging=null}),50)};Zn.dragover=Zn.dragenter=(t,e)=>e.preventDefault();Zn.drop=(t,e)=>{let i=e;let s=t.dragging;t.dragging=null;if(!i.dataTransfer)return;let n=t.posAtCoords(fr(i));if(!n)return;let r=t.state.doc.resolve(n.pos);let o=s&&s.slice;if(o){t.someProp("transformPasted",(e=>{o=e(o,t,false)}))}else{o=jn(t,$r(i.dataTransfer),Dr?null:i.dataTransfer.getData("text/html"),false,r)}let h=!!(s&&Br(t,i));if(t.someProp("handleDrop",(e=>e(t,i,o||p.empty,h)))){i.preventDefault();return}if(!o)return;i.preventDefault();let l=o?ye(t.state.doc,r.pos,o):r.pos;if(l==null)l=r.pos;let f=t.state.tr;if(h){let{node:t}=s;if(t)t.replace(f);else f.deleteSelection()}let u=f.mapping.map(l);let c=o.openStart==0&&o.openEnd==0&&o.content.childCount==1;let a=f.doc;if(c)f.replaceRangeWith(u,u,o.content.firstChild);else f.replaceRange(u,u,o);if(f.doc.eq(a))return;let d=f.doc.resolve(u);if(c&&We.isSelectable(o.content.firstChild)&&d.nodeAfter&&d.nodeAfter.sameMarkup(o.content.firstChild)){f.setSelection(new We(d))}else{let e=f.mapping.map(l);f.mapping.maps[f.mapping.maps.length-1].forEach(((t,i,s,n)=>e=n));f.setSelection(an(t,d,f.doc.resolve(e)))}t.focus();t.dispatch(f.setMeta("uiEvent","drop"))};Gn.focus=t=>{t.input.lastFocus=Date.now();if(!t.focused){t.domObserver.stop();t.dom.classList.add("ProseMirror-focused");t.domObserver.start();t.focused=true;setTimeout((()=>{if(t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange()))sn(t)}),20)}};Gn.blur=(t,e)=>{let i=e;if(t.focused){t.domObserver.stop();t.dom.classList.remove("ProseMirror-focused");t.domObserver.start();if(i.relatedTarget&&t.dom.contains(i.relatedTarget))t.domObserver.currentSelection.clear();t.focused=false}};Gn.beforeinput=(t,e)=>{let i=e;if(Bi&&Yi&&i.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:e}=t.input;setTimeout((()=>{if(t.input.domChangeCount!=e)return;t.dom.blur();t.focus();if(t.someProp("handleKeyDown",(e=>e(t,xi(8,"Backspace")))))return;let{$cursor:i}=t.state.selection;if(i&&i.pos>0)t.dispatch(t.state.tr.delete(i.pos-1,i.pos).scrollIntoView())}),50)}};for(let t in Zn)Gn[t]=Zn[t];function Fr(t,e){if(t==e)return true;for(let i in t)if(t[i]!==e[i])return false;for(let i in e)if(!(i in t))return false;return true}class Nr{constructor(t,e){this.toDOM=t;this.spec=e||Xr;this.side=this.spec.side||0}map(t,e,i,s){let{pos:n,deleted:r}=t.mapResult(e.from+s,this.side<0?-1:1);return r?null:new zr(n-i,n-i,this)}valid(){return true}eq(t){return this==t||t instanceof Nr&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&Fr(this.spec,t.spec))}destroy(t){if(this.spec.destroy)this.spec.destroy(t)}}class Lr{constructor(t,e){this.attrs=t;this.spec=e||Xr}map(t,e,i,s){let n=t.map(e.from+s,this.spec.inclusiveStart?-1:1)-i;let r=t.map(e.to+s,this.spec.inclusiveEnd?1:-1)-i;return n>=r?null:new zr(n,r,this)}valid(t,e){return e.from<e.to}eq(t){return this==t||t instanceof Lr&&Fr(this.attrs,t.attrs)&&Fr(this.spec,t.spec)}static is(t){return t.type instanceof Lr}destroy(){}}class _r{constructor(t,e){this.attrs=t;this.spec=e||Xr}map(t,e,i,s){let n=t.mapResult(e.from+s,1);if(n.deleted)return null;let r=t.mapResult(e.to+s,-1);if(r.deleted||r.pos<=n.pos)return null;return new zr(n.pos-i,r.pos-i,this)}valid(t,e){let{index:i,offset:s}=t.content.findIndex(e.from),n;return s==e.from&&!(n=t.child(i)).isText&&s+n.nodeSize==e.to}eq(t){return this==t||t instanceof _r&&Fr(this.attrs,t.attrs)&&Fr(this.spec,t.spec)}destroy(){}}class zr{constructor(t,e,i){this.from=t;this.to=e;this.type=i}copy(t,e){return new zr(t,e,this.type)}eq(t,e=0){return this.type.eq(t.type)&&this.from+e==t.from&&this.to+e==t.to}map(t,e,i){return this.type.map(t,this,e,i)}static widget(t,e,i){return new zr(t,t,new Nr(e,i))}static inline(t,e,i,s){return new zr(t,e,new Lr(i,s))}static node(t,e,i,s){return new zr(t,e,new _r(i,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof Lr}get widget(){return this.type instanceof Nr}}const Yr=[],Xr={};class Wr{constructor(t,e){this.local=t.length?t:Yr;this.children=e.length?e:Yr}static create(t,e){return e.length?Zr(e,t,0,Xr):Jr}find(t,e,i){let s=[];this.findInner(t==null?0:t,e==null?1e9:e,s,0,i);return s}findInner(t,e,i,s,n){for(let r=0;r<this.local.length;r++){let o=this.local[r];if(o.from<=e&&o.to>=t&&(!n||n(o.spec)))i.push(o.copy(o.from+s,o.to+s))}for(let r=0;r<this.children.length;r+=3){if(this.children[r]<e&&this.children[r+1]>t){let o=this.children[r]+1;this.children[r+2].findInner(t-o,e-o,i,s+o,n)}}}map(t,e,i){if(this==Jr||t.maps.length==0)return this;return this.mapInner(t,e,0,0,i||Xr)}mapInner(t,e,i,s,n){let r;for(let o=0;o<this.local.length;o++){let h=this.local[o].map(t,i,s);if(h&&h.type.valid(e,h))(r||(r=[])).push(h);else if(n.onRemove)n.onRemove(this.local[o].spec)}if(this.children.length)return Vr(this.children,r||[],t,e,i,s,n);else return r?new Wr(r.sort(to),Yr):Jr}add(t,e){if(!e.length)return this;if(this==Jr)return Wr.create(t,e);return this.addInner(t,e,0)}addInner(t,e,i){let s,n=0;t.forEach(((t,r)=>{let o=r+i,h;if(!(h=Kr(e,t,o)))return;if(!s)s=this.children.slice();while(n<s.length&&s[n]<r)n+=3;if(s[n]==r)s[n+2]=s[n+2].addInner(t,h,o+1);else s.splice(n,0,r,r+t.nodeSize,Zr(h,t,o+1,Xr));n+=3}));let r=Qr(n?Gr(e):e,-i);for(let e=0;e<r.length;e++)if(!r[e].type.valid(t,r[e]))r.splice(e--,1);return new Wr(r.length?this.local.concat(r).sort(to):this.local,s||this.children)}remove(t){if(t.length==0||this==Jr)return this;return this.removeInner(t,0)}removeInner(t,e){let i=this.children,s=this.local;for(let s=0;s<i.length;s+=3){let n;let r=i[s]+e,o=i[s+1]+e;for(let e=0,i;e<t.length;e++)if(i=t[e]){if(i.from>r&&i.to<o){t[e]=null;(n||(n=[])).push(i)}}if(!n)continue;if(i==this.children)i=this.children.slice();let h=i[s+2].removeInner(n,r+1);if(h!=Jr){i[s+2]=h}else{i.splice(s,3);s-=3}}if(s.length)for(let i=0,n;i<t.length;i++)if(n=t[i]){for(let t=0;t<s.length;t++)if(s[t].eq(n,e)){if(s==this.local)s=this.local.slice();s.splice(t--,1)}}if(i==this.children&&s==this.local)return this;return s.length||i.length?new Wr(s,i):Jr}forChild(t,e){if(this==Jr)return this;if(e.isLeaf)return Wr.empty;let i,s;for(let e=0;e<this.children.length;e+=3)if(this.children[e]>=t){if(this.children[e]==t)i=this.children[e+2];break}let n=t+1,r=n+e.content.size;for(let t=0;t<this.local.length;t++){let e=this.local[t];if(e.from<r&&e.to>n&&e.type instanceof Lr){let t=Math.max(n,e.from)-n,i=Math.min(r,e.to)-n;if(t<i)(s||(s=[])).push(e.copy(t,i))}}if(s){let t=new Wr(s.sort(to),Yr);return i?new Hr([t,i]):t}return i||Jr}eq(t){if(this==t)return true;if(!(t instanceof Wr)||this.local.length!=t.local.length||this.children.length!=t.children.length)return false;for(let e=0;e<this.local.length;e++)if(!this.local[e].eq(t.local[e]))return false;for(let e=0;e<this.children.length;e+=3)if(this.children[e]!=t.children[e]||this.children[e+1]!=t.children[e+1]||!this.children[e+2].eq(t.children[e+2]))return false;return true}locals(t){return eo(this.localsInner(t))}localsInner(t){if(this==Jr)return Yr;if(t.inlineContent||!this.local.some(Lr.is))return this.local;let e=[];for(let t=0;t<this.local.length;t++){if(!(this.local[t].type instanceof Lr))e.push(this.local[t])}return e}forEachSet(t){t(this)}}Wr.empty=new Wr([],[]);Wr.removeOverlap=eo;const Jr=Wr.empty;class Hr{constructor(t){this.members=t}map(t,e){const i=this.members.map((i=>i.map(t,e,Xr)));return Hr.from(i)}forChild(t,e){if(e.isLeaf)return Wr.empty;let i=[];for(let s=0;s<this.members.length;s++){let n=this.members[s].forChild(t,e);if(n==Jr)continue;if(n instanceof Hr)i=i.concat(n.members);else i.push(n)}return Hr.from(i)}eq(t){if(!(t instanceof Hr)||t.members.length!=this.members.length)return false;for(let e=0;e<this.members.length;e++)if(!this.members[e].eq(t.members[e]))return false;return true}locals(t){let e,i=true;for(let s=0;s<this.members.length;s++){let n=this.members[s].localsInner(t);if(!n.length)continue;if(!e){e=n}else{if(i){e=e.slice();i=false}for(let t=0;t<n.length;t++)e.push(n[t])}}return e?eo(i?e:e.sort(to)):Yr}static from(t){switch(t.length){case 0:return Jr;case 1:return t[0];default:return new Hr(t.every((t=>t instanceof Wr))?t:t.reduce(((t,e)=>t.concat(e instanceof Wr?e:e.members)),[]))}}forEachSet(t){for(let e=0;e<this.members.length;e++)this.members[e].forEachSet(t)}}function Vr(t,e,i,s,n,r,o){let h=t.slice();for(let t=0,e=r;t<i.maps.length;t++){let s=0;i.maps[t].forEach(((t,i,n,r)=>{let o=r-n-(i-t);for(let n=0;n<h.length;n+=3){let r=h[n+1];if(r<0||t>r+e-s)continue;let l=h[n]+e-s;if(i>=l){h[n+1]=t<=l?-2:-1}else if(t>=e&&o){h[n]+=o;h[n+1]+=o}}s+=o}));e=i.maps[t].map(e,-1)}let l=false;for(let e=0;e<h.length;e+=3)if(h[e+1]<0){if(h[e+1]==-2){l=true;h[e+1]=-1;continue}let f=i.map(t[e]+r),u=f-n;if(u<0||u>=s.content.size){l=true;continue}let c=i.map(t[e+1]+r,-1),a=c-n;let{index:d,offset:w}=s.content.findIndex(u);let p=s.maybeChild(d);if(p&&w==u&&w+p.nodeSize==a){let s=h[e+2].mapInner(i,p,f+1,t[e]+r+1,o);if(s!=Jr){h[e]=u;h[e+1]=a;h[e+2]=s}else{h[e+1]=-2;l=true}}else{l=true}}if(l){let l=qr(h,t,e,i,n,r,o);let f=Zr(l,s,0,o);e=f.local;for(let t=0;t<h.length;t+=3)if(h[t+1]<0){h.splice(t,3);t-=3}for(let t=0,e=0;t<f.children.length;t+=3){let i=f.children[t];while(e<h.length&&h[e]<i)e+=3;h.splice(e,0,f.children[t],f.children[t+1],f.children[t+2])}}return new Wr(e.sort(to),h)}function Qr(t,e){if(!e||!t.length)return t;let i=[];for(let s=0;s<t.length;s++){let n=t[s];i.push(new zr(n.from+e,n.to+e,n.type))}return i}function qr(t,e,i,s,n,r,o){function h(t,e){for(let r=0;r<t.local.length;r++){let h=t.local[r].map(s,n,e);if(h)i.push(h);else if(o.onRemove)o.onRemove(t.local[r].spec)}for(let i=0;i<t.children.length;i+=3)h(t.children[i+2],t.children[i]+e+1)}for(let i=0;i<t.length;i+=3)if(t[i+1]==-1)h(t[i+2],e[i]+r+1);return i}function Kr(t,e,i){if(e.isLeaf)return null;let s=i+e.nodeSize,n=null;for(let e=0,r;e<t.length;e++){if((r=t[e])&&r.from>i&&r.to<s){(n||(n=[])).push(r);t[e]=null}}return n}function Gr(t){let e=[];for(let i=0;i<t.length;i++)if(t[i]!=null)e.push(t[i]);return e}function Zr(t,e,i,s){let n=[],r=false;e.forEach(((e,o)=>{let h=Kr(t,e,o+i);if(h){r=true;let t=Zr(h,e,i+o+1,s);if(t!=Jr)n.push(o,o+e.nodeSize,t)}}));let o=Qr(r?Gr(t):t,-i).sort(to);for(let t=0;t<o.length;t++)if(!o[t].type.valid(e,o[t])){if(s.onRemove)s.onRemove(o[t].spec);o.splice(t--,1)}return o.length||n.length?new Wr(o,n):Jr}function to(t,e){return t.from-e.from||t.to-e.to}function eo(t){let e=t;for(let i=0;i<e.length-1;i++){let s=e[i];if(s.from!=s.to)for(let n=i+1;n<e.length;n++){let r=e[n];if(r.from==s.from){if(r.to!=s.to){if(e==t)e=t.slice();e[n]=r.copy(r.from,s.to);io(e,n+1,r.copy(s.to,r.to))}continue}else{if(r.from<s.to){if(e==t)e=t.slice();e[i]=s.copy(s.from,r.from);io(e,n,s.copy(r.from,s.to))}break}}}return e}function io(t,e,i){while(e<t.length&&to(i,t[e])>0)e++;t.splice(e,0,i)}function so(t){let e=[];t.someProp("decorations",(i=>{let s=i(t.state);if(s&&s!=Jr)e.push(s)}));if(t.cursorWrapper)e.push(Wr.create(t.state.doc,[t.cursorWrapper.deco]));return Hr.from(e)}const no={childList:true,characterData:true,characterDataOldValue:true,attributes:true,attributeOldValue:true,subtree:true};const ro=Ri&&$i<=11;class oo{constructor(){this.anchorNode=null;this.anchorOffset=0;this.focusNode=null;this.focusOffset=0}set(t){this.anchorNode=t.anchorNode;this.anchorOffset=t.anchorOffset;this.focusNode=t.focusNode;this.focusOffset=t.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(t){return t.anchorNode==this.anchorNode&&t.anchorOffset==this.anchorOffset&&t.focusNode==this.focusNode&&t.focusOffset==this.focusOffset}}class ho{constructor(t,e){this.view=t;this.handleDOMChange=e;this.queue=[];this.flushingSoon=-1;this.observer=null;this.currentSelection=new oo;this.onCharData=null;this.suppressingSelectionUpdates=false;this.lastChangedTextNode=null;this.observer=window.MutationObserver&&new window.MutationObserver((t=>{for(let e=0;e<t.length;e++)this.queue.push(t[e]);if(Ri&&$i<=11&&t.some((t=>t.type=="childList"&&t.removedNodes.length||t.type=="characterData"&&t.oldValue.length>t.target.nodeValue.length)))this.flushSoon();else this.flush()}));if(ro){this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue});this.flushSoon()}}this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){if(this.flushingSoon<0)this.flushingSoon=window.setTimeout((()=>{this.flushingSoon=-1;this.flush()}),20)}forceFlush(){if(this.flushingSoon>-1){window.clearTimeout(this.flushingSoon);this.flushingSoon=-1;this.flush()}}start(){if(this.observer){this.observer.takeRecords();this.observer.observe(this.view.dom,no)}if(this.onCharData)this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData);this.connectSelection()}stop(){if(this.observer){let t=this.observer.takeRecords();if(t.length){for(let e=0;e<t.length;e++)this.queue.push(t[e]);window.setTimeout((()=>this.flush()),20)}this.observer.disconnect()}if(this.onCharData)this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData);this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=true;setTimeout((()=>this.suppressingSelectionUpdates=false),50)}onSelectionChange(){if(!dn(this.view))return;if(this.suppressingSelectionUpdates)return sn(this.view);if(Ri&&$i<=11&&!this.view.state.selection.empty){let t=this.view.domSelectionRange();if(t.focusNode&&pi(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset))return this.flushSoon()}this.flush()}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(t){if(!t.focusNode)return true;let e=new Set,i;for(let i=t.focusNode;i;i=ci(i))e.add(i);for(let s=t.anchorNode;s;s=ci(s))if(e.has(s)){i=s;break}let s=i&&this.view.docView.nearestDesc(i);if(s&&s.ignoreMutation({type:"selection",target:i.nodeType==3?i.parentNode:i})){this.setCurSelection();return true}}pendingRecords(){if(this.observer)for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}flush(){let{view:t}=this;if(!t.docView||this.flushingSoon>-1)return;let e=this.pendingRecords();if(e.length)this.queue=[];let i=t.domSelectionRange();let s=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(i)&&dn(t)&&!this.ignoreSelectionChange(i);let n=-1,r=-1,o=false,h=[];if(t.editable){for(let t=0;t<e.length;t++){let i=this.registerMutation(e[t],h);if(i){n=n<0?i.from:Math.min(i.from,n);r=r<0?i.to:Math.max(i.to,r);if(i.typeOver)o=true}}}if(Ui&&h.length){let e=h.filter((t=>t.nodeName=="BR"));if(e.length==2){let[t,i]=e;if(t.parentNode&&t.parentNode.parentNode==i.parentNode)i.remove();else t.remove()}else{let{focusNode:i}=this.currentSelection;for(let s of e){let e=s.parentNode;if(e&&e.nodeName=="LI"&&(!i||wo(t,i)!=e))s.remove()}}}let l=null;if(n<0&&s&&t.input.lastFocus>Date.now()-200&&Math.max(t.input.lastTouch,t.input.lastClick.time)<Date.now()-300&&Ai(i)&&(l=tn(t))&&l.eq(Ne.near(t.state.doc.resolve(0),1))){t.input.lastFocus=0;sn(t);this.currentSelection.set(i);t.scrollToSelection()}else if(n>-1||s){if(n>-1){t.docView.markDirty(n,r);uo(t)}this.handleDOMChange(n,r,o,h);if(t.docView&&t.docView.dirty)t.updateState(t.state);else if(!this.currentSelection.eq(i))sn(t);this.currentSelection.set(i)}}registerMutation(t,e){if(e.indexOf(t.target)>-1)return null;let i=this.view.docView.nearestDesc(t.target);if(t.type=="attributes"&&(i==this.view.docView||t.attributeName=="contenteditable"||t.attributeName=="style"&&!t.oldValue&&!t.target.getAttribute("style")))return null;if(!i||i.ignoreMutation(t))return null;if(t.type=="childList"){for(let i=0;i<t.addedNodes.length;i++){let s=t.addedNodes[i];e.push(s);if(s.nodeType==3)this.lastChangedTextNode=s}if(i.contentDOM&&i.contentDOM!=i.dom&&!i.contentDOM.contains(t.target))return{from:i.posBefore,to:i.posAfter};let s=t.previousSibling,n=t.nextSibling;if(Ri&&$i<=11&&t.addedNodes.length){for(let e=0;e<t.addedNodes.length;e++){let{previousSibling:i,nextSibling:r}=t.addedNodes[e];if(!i||Array.prototype.indexOf.call(t.addedNodes,i)<0)s=i;if(!r||Array.prototype.indexOf.call(t.addedNodes,r)<0)n=r}}let r=s&&s.parentNode==t.target?ui(s)+1:0;let o=i.localPosFromDOM(t.target,r,-1);let h=n&&n.parentNode==t.target?ui(n):t.target.childNodes.length;let l=i.localPosFromDOM(t.target,h,1);return{from:o,to:l}}else if(t.type=="attributes"){return{from:i.posAtStart-i.border,to:i.posAtEnd+i.border}}else{this.lastChangedTextNode=t.target;return{from:i.posAtStart,to:i.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}}}}let lo=new WeakMap;let fo=false;function uo(t){if(lo.has(t))return;lo.set(t,null);if(["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1){t.requiresGeckoHackNode=Ui;if(fo)return;console["warn"]("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package.");fo=true}}function co(t,e){let i=e.startContainer,s=e.startOffset;let n=e.endContainer,r=e.endOffset;let o=t.domAtPos(t.state.selection.anchor);if(pi(o.node,o.offset,n,r))[i,s,n,r]=[n,r,i,s];return{anchorNode:i,anchorOffset:s,focusNode:n,focusOffset:r}}function ao(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return co(t,i)}let i;function s(t){t.preventDefault();t.stopImmediatePropagation();i=t.getTargetRanges()[0]}t.dom.addEventListener("beforeinput",s,true);document.execCommand("indent");t.dom.removeEventListener("beforeinput",s,true);return i?co(t,i):null}function wo(t,e){for(let i=e.parentNode;i&&i!=t.dom;i=i.parentNode){let e=t.docView.nearestDesc(i,true);if(e&&e.node.isBlock)return i}return null}function po(t,e,i){let{node:s,fromOffset:n,toOffset:r,from:o,to:h}=t.docView.parseRange(e,i);let l=t.domSelectionRange();let f;let u=l.anchorNode;if(u&&t.dom.contains(u.nodeType==1?u:u.parentNode)){f=[{node:u,offset:l.anchorOffset}];if(!Ai(l))f.push({node:l.focusNode,offset:l.focusOffset})}if(Bi&&t.input.lastKeyCode===8){for(let t=r;t>n;t--){let e=s.childNodes[t-1],i=e.pmViewDesc;if(e.nodeName=="BR"&&!i){r=t;break}if(!i||i.size)break}}let c=t.state.doc;let a=t.someProp("domParser")||ft.fromSchema(t.state.schema);let d=c.resolve(o);let w=null,p=a.parse(s,{topNode:d.parent,topMatch:d.parent.contentMatchAt(d.index()),topOpen:true,from:n,to:r,preserveWhitespace:d.parent.type.whitespace=="pre"?"full":true,findPositions:f,ruleFromNode:go,context:d});if(f&&f[0].pos!=null){let t=f[0].pos,e=f[1]&&f[1].pos;if(e==null)e=t;w={anchor:t+o,head:e+o}}return{doc:p,sel:w,from:o,to:h}}function go(t){let e=t.pmViewDesc;if(e){return e.parseRule()}else if(t.nodeName=="BR"&&t.parentNode){if(Ni&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let t=document.createElement("div");t.appendChild(document.createElement("li"));return{skip:t}}else if(t.parentNode.lastChild==t||Ni&&/^(tr|table)$/i.test(t.parentNode.nodeName)){return{ignore:true}}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder")){return{ignore:true}}return null}const mo=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function yo(t,e,i,s,n){let r=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);t.input.compositionPendingChanges=0;if(e<0){let e=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null;let i=tn(t,e);if(i&&!t.state.selection.eq(i)){if(Bi&&Yi&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",(e=>e(t,xi(13,"Enter")))))return;let s=t.state.tr.setSelection(i);if(e=="pointer")s.setMeta("pointer",true);else if(e=="key")s.scrollIntoView();if(r)s.setMeta("composition",r);t.dispatch(s)}return}let o=t.state.doc.resolve(e);let h=o.sharedDepth(i);e=o.before(h+1);i=t.state.doc.resolve(i).after(h+1);let l=t.state.selection;let f=po(t,e,i);let u=t.state.doc,c=u.slice(f.from,f.to);let a,d;if(t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime){a=t.state.selection.to;d="end"}else{a=t.state.selection.from;d="start"}t.input.lastKeyCode=null;let w=Ao(c.content,f.doc.content,f.from,a,d);if(w)t.input.domChangeCount++;if((Li&&t.input.lastIOSEnter>Date.now()-225||Yi)&&n.some((t=>t.nodeType==1&&!mo.test(t.nodeName)))&&(!w||w.endA>=w.endB)&&t.someProp("handleKeyDown",(e=>e(t,xi(13,"Enter"))))){t.input.lastIOSEnter=0;return}if(!w){if(s&&l instanceof Ye&&!l.empty&&l.$head.sameParent(l.$anchor)&&!t.composing&&!(f.sel&&f.sel.anchor!=f.sel.head)){w={start:l.from,endA:l.to,endB:l.to}}else{if(f.sel){let e=vo(t,t.state.doc,f.sel);if(e&&!e.eq(t.state.selection)){let i=t.state.tr.setSelection(e);if(r)i.setMeta("composition",r);t.dispatch(i)}}return}}if(t.state.selection.from<t.state.selection.to&&w.start==w.endB&&t.state.selection instanceof Ye){if(w.start>t.state.selection.from&&w.start<=t.state.selection.from+2&&t.state.selection.from>=f.from){w.start=t.state.selection.from}else if(w.endA<t.state.selection.to&&w.endA>=t.state.selection.to-2&&t.state.selection.to<=f.to){w.endB+=t.state.selection.to-w.endA;w.endA=t.state.selection.to}}if(Ri&&$i<=11&&w.endB==w.start+1&&w.endA==w.start&&w.start>f.from&&f.doc.textBetween(w.start-f.from-1,w.start-f.from+1)=="  "){w.start--;w.endA--;w.endB--}let p=f.doc.resolveNoCache(w.start-f.from);let g=f.doc.resolveNoCache(w.endB-f.from);let m=u.resolve(w.start);let y=p.sameParent(g)&&p.parent.inlineContent&&m.end()>=w.endA;if((Li&&t.input.lastIOSEnter>Date.now()-225&&(!y||n.some((t=>t.nodeName=="DIV"||t.nodeName=="P")))||!y&&p.pos<f.doc.content.size&&(!p.sameParent(g)||!p.parent.inlineContent)&&p.pos<g.pos&&!/\S/.test(f.doc.textBetween(p.pos,g.pos,"","")))&&t.someProp("handleKeyDown",(e=>e(t,xi(13,"Enter"))))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>w.start&&Mo(u,w.start,w.endA,p,g)&&t.someProp("handleKeyDown",(e=>e(t,xi(8,"Backspace"))))){if(Yi&&Bi)t.domObserver.suppressSelectionUpdates();return}if(Bi&&w.endB==w.start)t.input.lastChromeDelete=Date.now();if(Yi&&!y&&p.start()!=g.start()&&g.parentOffset==0&&p.depth==g.depth&&f.sel&&f.sel.anchor==f.sel.head&&f.sel.head==w.endA){w.endB-=2;g=f.doc.resolveNoCache(w.endB-f.from);setTimeout((()=>{t.someProp("handleKeyDown",(function(e){return e(t,xi(13,"Enter"))}))}),20)}let v=w.start,b=w.endA;let M=e=>{let i=e||t.state.tr.replace(v,b,f.doc.slice(w.start-f.from,w.endB-f.from));if(f.sel){let e=vo(t,i.doc,f.sel);if(e&&!(Bi&&t.composing&&e.empty&&(w.start!=w.endB||t.input.lastChromeDelete<Date.now()-100)&&(e.head==v||e.head==i.mapping.map(b)-1)||Ri&&e.empty&&e.head==v))i.setSelection(e)}if(r)i.setMeta("composition",r);return i.scrollIntoView()};let k;if(y){if(p.pos==g.pos){if(Ri&&$i<=11&&p.parentOffset==0){t.domObserver.suppressSelectionUpdates();setTimeout((()=>sn(t)),20)}let e=M(t.state.tr.delete(v,b));let i=u.resolve(w.start).marksAcross(u.resolve(w.endA));if(i)e.ensureMarks(i);t.dispatch(e)}else if(w.endA==w.endB&&(k=bo(p.parent.content.cut(p.parentOffset,g.parentOffset),m.parent.content.cut(m.parentOffset,w.endA-m.start())))){let e=M(t.state.tr);if(k.type=="add")e.addMark(v,b,k.mark);else e.removeMark(v,b,k.mark);t.dispatch(e)}else if(p.parent.child(p.index()).isText&&p.index()==g.index()-(g.textOffset?0:1)){let e=p.parent.textBetween(p.parentOffset,g.parentOffset);let i=()=>M(t.state.tr.insertText(e,v,b));if(!t.someProp("handleTextInput",(s=>s(t,v,b,e,i))))t.dispatch(i())}else{t.dispatch(M())}}else{t.dispatch(M())}}function vo(t,e,i){if(Math.max(i.anchor,i.head)>e.content.size)return null;return an(t,e.resolve(i.anchor),e.resolve(i.head))}function bo(t,e){let i=t.firstChild.marks,s=e.firstChild.marks;let n=i,r=s,o,h,l;for(let t=0;t<s.length;t++)n=s[t].removeFromSet(n);for(let t=0;t<i.length;t++)r=i[t].removeFromSet(r);if(n.length==1&&r.length==0){h=n[0];o="add";l=t=>t.mark(h.addToSet(t.marks))}else if(n.length==0&&r.length==1){h=r[0];o="remove";l=t=>t.mark(h.removeFromSet(t.marks))}else{return null}let u=[];for(let t=0;t<e.childCount;t++)u.push(l(e.child(t)));if(f.from(u).eq(t))return{mark:h,type:o}}function Mo(t,e,i,s,n){if(i-e<=n.pos-s.pos||ko(s,true,false)<n.pos)return false;let r=t.resolve(e);if(!s.parent.isTextblock){let t=r.nodeAfter;return t!=null&&i==e+t.nodeSize}if(r.parentOffset<r.parent.content.size||!r.parent.isTextblock)return false;let o=t.resolve(ko(r,true,true));if(!o.parent.isTextblock||o.pos>i||ko(o,true,false)<i)return false;return s.parent.content.cut(s.parentOffset).eq(o.parent.content)}function ko(t,e,i){let s=t.depth,n=e?t.end():t.pos;while(s>0&&(e||t.indexAfter(s)==t.node(s).childCount)){s--;n++;e=false}if(i){let e=t.node(s).maybeChild(t.indexAfter(s));while(e&&!e.isLeaf){e=e.firstChild;n++}}return n}function Ao(t,e,i,s,n){let r=t.findDiffStart(e,i);if(r==null)return null;let{a:o,b:h}=t.findDiffEnd(e,i+t.size,i+e.size);if(n=="end"){let t=Math.max(0,r-Math.min(o,h));s-=o+t-r}if(o<r&&t.size<e.size){let t=s<=r&&s>=o?r-s:0;r-=t;if(r&&r<e.size&&xo(e.textBetween(r-1,r+1)))r+=t?1:-1;h=r+(h-o);o=r}else if(h<r){let e=s<=r&&s>=h?r-s:0;r-=e;if(r&&r<t.size&&xo(t.textBetween(r-1,r+1)))r+=e?1:-1;o=r+(o-h);h=r}return{start:r,endA:o,endB:h}}function xo(t){if(t.length!=2)return false;let e=t.charCodeAt(0),i=t.charCodeAt(1);return e>=56320&&e<=57343&&i>=55296&&i<=56319}class So{constructor(t,e){this._root=null;this.focused=false;this.trackWrites=null;this.mounted=false;this.markCursor=null;this.cursorWrapper=null;this.lastSelectedViewDesc=undefined;this.input=new er;this.prevDirectPlugins=[];this.pluginViews=[];this.requiresGeckoHackNode=false;this.dragging=null;this._props=e;this.state=e.state;this.directPlugins=e.plugins||[];this.directPlugins.forEach(Po);this.dispatch=this.dispatch.bind(this);this.dom=t&&t.mount||document.createElement("div");if(t){if(t.appendChild)t.appendChild(this.dom);else if(typeof t=="function")t(this.dom);else if(t.mount)this.mounted=true}this.editable=Eo(this);Oo(this);this.nodeViews=Do(this);this.docView=$s(this.state.doc,Co(this),so(this),this.dom,this);this.domObserver=new ho(this,((t,e,i,s)=>yo(this,t,e,i,s)));this.domObserver.start();ir(this);this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let t=this._props;this._props={};for(let e in t)this._props[e]=t[e];this._props.state=this.state}return this._props}update(t){if(t.handleDOMEvents!=this._props.handleDOMEvents)rr(this);let e=this._props;this._props=t;if(t.plugins){t.plugins.forEach(Po);this.directPlugins=t.plugins}this.updateStateInner(t.state,e)}setProps(t){let e={};for(let t in this._props)e[t]=this._props[t];e.state=this.state;for(let i in t)e[i]=t[i];this.update(e)}updateState(t){this.updateStateInner(t,this._props)}updateStateInner(t,e){var i;let s=this.state,n=false,r=false;if(t.storedMarks&&this.composing){Sr(this);r=true}this.state=t;let o=s.plugins!=t.plugins||this._props.plugins!=e.plugins;if(o||this._props.plugins!=e.plugins||this._props.nodeViews!=e.nodeViews){let t=Do(this);if(Io(t,this.nodeViews)){this.nodeViews=t;n=true}}if(o||e.handleDOMEvents!=this._props.handleDOMEvents){rr(this)}this.editable=Eo(this);Oo(this);let h=so(this),l=Co(this);let f=s.plugins!=t.plugins&&!s.doc.eq(t.doc)?"reset":t.scrollToSelection>s.scrollToSelection?"to selection":"preserve";let u=n||!this.docView.matchesNode(t.doc,l,h);if(u||!t.selection.eq(s.selection))r=true;let c=f=="preserve"&&r&&this.dom.style.overflowAnchor==null&&qi(this);if(r){this.domObserver.stop();let e=u&&(Ri||Bi)&&!this.composing&&!s.selection.empty&&!t.selection.empty&&To(s.selection,t.selection);if(u){let i=Bi?this.trackWrites=this.domSelectionRange().focusNode:null;if(this.composing)this.input.compositionNode=Cr(this);if(n||!this.docView.update(t.doc,l,h,this)){this.docView.updateOuterDeco(l);this.docView.destroy();this.docView=$s(t.doc,l,h,this.dom,this)}if(i&&!this.trackWrites)e=true}if(e||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&pn(this))){sn(this,e)}else{un(this,t.selection);this.domObserver.setCurSelection()}this.domObserver.start()}this.updatePluginViews(s);if(((i=this.dragging)===null||i===void 0?void 0:i.node)&&!s.doc.eq(t.doc))this.updateDraggedNode(this.dragging,s);if(f=="reset"){this.dom.scrollTop=0}else if(f=="to selection"){this.scrollToSelection()}else if(c){Gi(c)}}scrollToSelection(){let t=this.domSelectionRange().focusNode;if(!t||!this.dom.contains(t.nodeType==1?t:t.parentNode));else if(this.someProp("handleScrollToSelection",(t=>t(this))));else if(this.state.selection instanceof We){let e=this.docView.domAfterPos(this.state.selection.from);if(e.nodeType==1)Qi(this,e.getBoundingClientRect(),t)}else{Qi(this,this.coordsAtPos(this.state.selection.head,1),t)}}destroyPluginViews(){let t;while(t=this.pluginViews.pop())if(t.destroy)t.destroy()}updatePluginViews(t){if(!t||t.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins;this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let e=this.directPlugins[t];if(e.spec.view)this.pluginViews.push(e.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let e=this.state.plugins[t];if(e.spec.view)this.pluginViews.push(e.spec.view(this))}}else{for(let e=0;e<this.pluginViews.length;e++){let i=this.pluginViews[e];if(i.update)i.update(this,t)}}}updateDraggedNode(t,e){let i=t.node,s=-1;if(this.state.doc.nodeAt(i.from)==i.node){s=i.from}else{let t=i.from+(this.state.doc.content.size-e.doc.content.size);let n=t>0&&this.state.doc.nodeAt(t);if(n==i.node)s=t}this.dragging=new Ur(t.slice,t.move,s<0?undefined:We.create(this.state.doc,s))}someProp(t,e){let i=this._props&&this._props[t],s;if(i!=null&&(s=e?e(i):i))return s;for(let i=0;i<this.directPlugins.length;i++){let n=this.directPlugins[i].props[t];if(n!=null&&(s=e?e(n):n))return s}let n=this.state.plugins;if(n)for(let i=0;i<n.length;i++){let r=n[i].props[t];if(r!=null&&(s=e?e(r):r))return s}}hasFocus(){if(Ri){let t=this.root.activeElement;if(t==this.dom)return true;if(!t||!this.dom.contains(t))return false;while(t&&this.dom!=t&&this.dom.contains(t)){if(t.contentEditable=="false")return false;t=t.parentElement}return true}return this.root.activeElement==this.dom}focus(){this.domObserver.stop();if(this.editable)es(this.dom);sn(this);this.domObserver.start()}get root(){let t=this._root;if(t==null)for(let t=this.dom.parentNode;t;t=t.parentNode){if(t.nodeType==9||t.nodeType==11&&t.host){if(!t.getSelection)Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection();return this._root=t}}return t||document}updateRoot(){this._root=null}posAtCoords(t){return us(this,t)}coordsAtPos(t,e=1){return ws(this,t,e)}domAtPos(t,e=0){return this.docView.domFromPos(t,e)}nodeDOM(t){let e=this.docView.descAt(t);return e?e.nodeDOM:null}posAtDOM(t,e,i=-1){let s=this.docView.posFromDOM(t,e,i);if(s==null)throw new RangeError("DOM position not inside the editor");return s}endOfTextblock(t,e){return xs(this,e||this.state,t)}pasteHTML(t,e){return Rr(this,"",t,false,e||new ClipboardEvent("paste"))}pasteText(t,e){return Rr(this,t,null,true,e||new ClipboardEvent("paste"))}serializeForClipboard(t){return Un(this,t)}destroy(){if(!this.docView)return;nr(this);this.destroyPluginViews();if(this.mounted){this.docView.update(this.state.doc,[],so(this),this);this.dom.textContent=""}else if(this.dom.parentNode){this.dom.parentNode.removeChild(this.dom)}this.docView.destroy();this.docView=null;wi()}get isDestroyed(){return this.docView==null}dispatchEvent(t){return lr(this,t)}domSelectionRange(){let t=this.domSelection();if(!t)return{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0};return Ni&&this.root.nodeType===11&&Si(this.dom.ownerDocument)==this.dom&&ao(this,t)||t}domSelection(){return this.root.getSelection()}}So.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;if(e)e.call(this,t);else this.updateState(this.state.apply(t))};function Co(t){let e=Object.create(null);e.class="ProseMirror";e.contenteditable=String(t.editable);t.someProp("attributes",(i=>{if(typeof i=="function")i=i(t.state);if(i)for(let t in i){if(t=="class")e.class+=" "+i[t];else if(t=="style")e.style=(e.style?e.style+";":"")+i[t];else if(!e[t]&&t!="contenteditable"&&t!="nodeName")e[t]=String(i[t])}}));if(!e.translate)e.translate="no";return[zr.node(0,t.state.doc.content.size,e)]}function Oo(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator";e.setAttribute("mark-placeholder","true");e.setAttribute("alt","");t.cursorWrapper={dom:e,deco:zr.widget(t.state.selection.from,e,{raw:true,marks:t.markCursor})}}else{t.cursorWrapper=null}}function Eo(t){return!t.someProp("editable",(e=>e(t.state)===false))}function To(t,e){let i=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(i)!=e.$anchor.start(i)}function Do(t){let e=Object.create(null);function i(t){for(let i in t)if(!Object.prototype.hasOwnProperty.call(e,i))e[i]=t[i]}t.someProp("nodeViews",i);t.someProp("markViews",i);return e}function Io(t,e){let i=0,s=0;for(let s in t){if(t[s]!=e[s])return true;i++}for(let t in e)s++;return i!=s}function Po(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}const Ro=["p",0],$o=["blockquote",0],Uo=["hr"],jo=["pre",["code",0]],Bo=["br"];const Fo={doc:{content:"block+"},paragraph:{content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM(){return Ro}},blockquote:{content:"block+",group:"block",defining:true,parseDOM:[{tag:"blockquote"}],toDOM(){return $o}},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM(){return Uo}},heading:{attrs:{level:{default:1,validate:"number"}},content:"inline*",group:"block",defining:true,parseDOM:[{tag:"h1",attrs:{level:1}},{tag:"h2",attrs:{level:2}},{tag:"h3",attrs:{level:3}},{tag:"h4",attrs:{level:4}},{tag:"h5",attrs:{level:5}},{tag:"h6",attrs:{level:6}}],toDOM(t){return["h"+t.attrs.level,0]}},code_block:{content:"text*",marks:"",group:"block",code:true,defining:true,parseDOM:[{tag:"pre",preserveWhitespace:"full"}],toDOM(){return jo}},text:{group:"inline"},image:{inline:true,attrs:{src:{validate:"string"},alt:{default:null,validate:"string|null"},title:{default:null,validate:"string|null"}},group:"inline",draggable:true,parseDOM:[{tag:"img[src]",getAttrs(t){return{src:t.getAttribute("src"),title:t.getAttribute("title"),alt:t.getAttribute("alt")}}}],toDOM(t){let{src:e,alt:i,title:s}=t.attrs;return["img",{src:e,alt:i,title:s}]}},hard_break:{inline:true,group:"inline",selectable:false,parseDOM:[{tag:"br"}],toDOM(){return Bo}}};const No=["em",0],Lo=["strong",0],_o=["code",0];const zo={link:{attrs:{href:{validate:"string"},title:{default:null,validate:"string|null"}},inclusive:false,parseDOM:[{tag:"a[href]",getAttrs(t){return{href:t.getAttribute("href"),title:t.getAttribute("title")}}}],toDOM(t){let{href:e,title:i}=t.attrs;return["a",{href:e,title:i},0]}},em:{parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style=italic"},{style:"font-style=normal",clearMark:t=>t.type.name=="em"}],toDOM(){return No}},strong:{parseDOM:[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name=="strong"},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}],toDOM(){return Lo}},code:{code:true,parseDOM:[{tag:"code"}],toDOM(){return _o}}};const Yo=new rt({nodes:Fo,marks:zo});const Xo=["ol",0],Wo=["ul",0],Jo=["li",0];const Ho={attrs:{order:{default:1,validate:"number"}},parseDOM:[{tag:"ol",getAttrs(t){return{order:t.hasAttribute("start")?+t.getAttribute("start"):1}}}],toDOM(t){return t.attrs.order==1?Xo:["ol",{start:t.attrs.order},0]}};const Vo={parseDOM:[{tag:"ul"}],toDOM(){return Wo}};const Qo={parseDOM:[{tag:"li"}],toDOM(){return Jo},defining:true};function qo(t,e){let i={};for(let e in t)i[e]=t[e];for(let t in e)i[t]=e[t];return i}function Ko(t,e,i){return t.append({ordered_list:qo(Ho,{content:"list_item+",group:i}),bullet_list:qo(Vo,{content:"list_item+",group:i}),list_item:qo(Qo,{content:e})})}var Go={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"};var Zo={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'};var th=typeof navigator!="undefined"&&/Mac/.test(navigator.platform);var eh=typeof navigator!="undefined"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var ih=0;ih<10;ih++)Go[48+ih]=Go[96+ih]=String(ih);for(var ih=1;ih<=24;ih++)Go[ih+111]="F"+ih;for(var ih=65;ih<=90;ih++){Go[ih]=String.fromCharCode(ih+32);Zo[ih]=String.fromCharCode(ih)}for(var sh in Go)if(!Zo.hasOwnProperty(sh))Zo[sh]=Go[sh];function nh(t){var e=th&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||eh&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified";var i=!e&&t.key||(t.shiftKey?Zo:Go)[t.keyCode]||t.key||"Unidentified";if(i=="Esc")i="Escape";if(i=="Del")i="Delete";if(i=="Left")i="ArrowLeft";if(i=="Up")i="ArrowUp";if(i=="Right")i="ArrowRight";if(i=="Down")i="ArrowDown";return i}const rh=typeof navigator!="undefined"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform);const oh=typeof navigator!="undefined"&&/Win/.test(navigator.platform);function hh(t){let e=t.split(/-(?!$)/),i=e[e.length-1];if(i=="Space")i=" ";let s,n,r,o;for(let t=0;t<e.length-1;t++){let i=e[t];if(/^(cmd|meta|m)$/i.test(i))o=true;else if(/^a(lt)?$/i.test(i))s=true;else if(/^(c|ctrl|control)$/i.test(i))n=true;else if(/^s(hift)?$/i.test(i))r=true;else if(/^mod$/i.test(i)){if(rh)o=true;else n=true}else throw new Error("Unrecognized modifier name: "+i)}if(s)i="Alt-"+i;if(n)i="Ctrl-"+i;if(o)i="Meta-"+i;if(r)i="Shift-"+i;return i}function lh(t){let e=Object.create(null);for(let i in t)e[hh(i)]=t[i];return e}function fh(t,e,i=true){if(e.altKey)t="Alt-"+t;if(e.ctrlKey)t="Ctrl-"+t;if(e.metaKey)t="Meta-"+t;if(i&&e.shiftKey)t="Shift-"+t;return t}function uh(t){return new hi({props:{handleKeyDown:ch(t)}})}function ch(t){let e=lh(t);return function(t,i){let s=nh(i),n,r=e[fh(s,i)];if(r&&r(t.state,t.dispatch,t))return true;if(s.length==1&&s!=" "){if(i.shiftKey){let n=e[fh(s,i,false)];if(n&&n(t.state,t.dispatch,t))return true}if((i.altKey||i.metaKey||i.ctrlKey)&&!(oh&&i.ctrlKey&&i.altKey)&&(n=Go[i.keyCode])&&n!=s){let s=e[fh(n,i)];if(s&&s(t.state,t.dispatch,t))return true}}return false}}const ah=(t,e)=>{if(t.selection.empty)return false;if(e)e(t.tr.deleteSelection().scrollIntoView());return true};function dh(t,e){let{$cursor:i}=t.selection;if(!i||(e?!e.endOfTextblock("backward",t):i.parentOffset>0))return null;return i}const wh=(t,e,i)=>{let s=dh(t,i);if(!s)return false;let n=mh(s);if(!n){let i=s.blockRange(),n=i&&se(i);if(n==null)return false;if(e)e(t.tr.lift(i,n).scrollIntoView());return true}let r=n.nodeBefore;if(Ih(t,n,e,-1))return true;if(s.parent.content.size==0&&(ph(r,"end")||We.isSelectable(r))){for(let i=s.depth;;i--){let o=ve(t.doc,s.before(i),s.after(i),p.empty);if(o&&o.slice.size<o.to-o.from){if(e){let i=t.tr.step(o);i.setSelection(ph(r,"end")?Ne.findFrom(i.doc.resolve(i.mapping.map(n.pos,-1)),-1):We.create(i.doc,n.pos-r.nodeSize));e(i.scrollIntoView())}return true}if(i==1||s.node(i-1).childCount>1)break}}if(r.isAtom&&n.depth==s.depth-1){if(e)e(t.tr.delete(n.pos-r.nodeSize,n.pos).scrollIntoView());return true}return false};function ph(t,e,i=false){for(let s=t;s;s=e=="start"?s.firstChild:s.lastChild){if(s.isTextblock)return true;if(i&&s.childCount!=1)return false}return false}const gh=(t,e,i)=>{let{$head:s,empty:n}=t.selection,r=s;if(!n)return false;if(s.parent.isTextblock){if(i?!i.endOfTextblock("backward",t):s.parentOffset>0)return false;r=mh(s)}let o=r&&r.nodeBefore;if(!o||!We.isSelectable(o))return false;if(e)e(t.tr.setSelection(We.create(t.doc,r.pos-o.nodeSize)).scrollIntoView());return true};function mh(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function yh(t,e){let{$cursor:i}=t.selection;if(!i||(e?!e.endOfTextblock("forward",t):i.parentOffset<i.parent.content.size))return null;return i}const vh=(t,e,i)=>{let s=yh(t,i);if(!s)return false;let n=Mh(s);if(!n)return false;let r=n.nodeAfter;if(Ih(t,n,e,1))return true;if(s.parent.content.size==0&&(ph(r,"start")||We.isSelectable(r))){let i=ve(t.doc,s.before(),s.after(),p.empty);if(i&&i.slice.size<i.to-i.from){if(e){let s=t.tr.step(i);s.setSelection(ph(r,"start")?Ne.findFrom(s.doc.resolve(s.mapping.map(n.pos)),1):We.create(s.doc,s.mapping.map(n.pos)));e(s.scrollIntoView())}return true}}if(r.isAtom&&n.depth==s.depth-1){if(e)e(t.tr.delete(n.pos,n.pos+r.nodeSize).scrollIntoView());return true}return false};const bh=(t,e,i)=>{let{$head:s,empty:n}=t.selection,r=s;if(!n)return false;if(s.parent.isTextblock){if(i?!i.endOfTextblock("forward",t):s.parentOffset<s.parent.content.size)return false;r=Mh(s)}let o=r&&r.nodeAfter;if(!o||!We.isSelectable(o))return false;if(e)e(t.tr.setSelection(We.create(t.doc,r.pos)).scrollIntoView());return true};function Mh(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let i=t.node(e);if(t.index(e)+1<i.childCount)return t.doc.resolve(t.after(e+1));if(i.type.spec.isolating)break}return null}const kh=(t,e)=>{let{$head:i,$anchor:s}=t.selection;if(!i.parent.type.spec.code||!i.sameParent(s))return false;if(e)e(t.tr.insertText("\n").scrollIntoView());return true};function Ah(t){for(let e=0;e<t.edgeCount;e++){let{type:i}=t.edge(e);if(i.isTextblock&&!i.hasRequiredAttrs())return i}return null}const xh=(t,e)=>{let{$head:i,$anchor:s}=t.selection;if(!i.parent.type.spec.code||!i.sameParent(s))return false;let n=i.node(-1),r=i.indexAfter(-1),o=Ah(n.contentMatchAt(r));if(!o||!n.canReplaceWith(r,r,o))return false;if(e){let s=i.after(),n=t.tr.replaceWith(s,s,o.createAndFill());n.setSelection(Ne.near(n.doc.resolve(s),1));e(n.scrollIntoView())}return true};const Sh=(t,e)=>{let i=t.selection,{$from:s,$to:n}=i;if(i instanceof He||s.parent.inlineContent||n.parent.inlineContent)return false;let r=Ah(n.parent.contentMatchAt(n.indexAfter()));if(!r||!r.isTextblock)return false;if(e){let i=(!s.parentOffset&&n.index()<n.parent.childCount?s:n).pos;let o=t.tr.insert(i,r.createAndFill());o.setSelection(Ye.create(o.doc,i+1));e(o.scrollIntoView())}return true};const Ch=(t,e)=>{let{$cursor:i}=t.selection;if(!i||i.parent.content.size)return false;if(i.depth>1&&i.after()!=i.end(-1)){let s=i.before();if(ce(t.doc,s)){if(e)e(t.tr.split(s).scrollIntoView());return true}}let s=i.blockRange(),n=s&&se(s);if(n==null)return false;if(e)e(t.tr.lift(s,n).scrollIntoView());return true};function Oh(t){return(t,e)=>{let{$from:i}=t.selection;if(t.selection instanceof We&&t.selection.node.isBlock){if(!i.parentOffset||!ce(t.doc,i.pos))return false;if(e)e(t.tr.split(i.pos).scrollIntoView());return true}if(!i.depth)return false;let s=[];let n,r,o=false,h=false;for(let t=i.depth;;t--){let e=i.node(t);if(e.isBlock){o=i.end(t)==i.pos+(i.depth-t);h=i.start(t)==i.pos-(i.depth-t);r=Ah(i.node(t-1).contentMatchAt(i.indexAfter(t-1)));s.unshift(o&&r?{type:r}:null);n=t;break}else{if(t==1)return false;s.unshift(null)}}let l=t.tr;if(t.selection instanceof Ye||t.selection instanceof He)l.deleteSelection();let f=l.mapping.map(i.pos);let u=ce(l.doc,f,s.length,s);if(!u){s[0]=r?{type:r}:null;u=ce(l.doc,f,s.length,s)}if(!u)return false;l.split(f,s.length,s);if(!o&&h&&i.node(n).type!=r){let t=l.mapping.map(i.before(n)),e=l.doc.resolve(t);if(r&&i.node(n-1).canReplaceWith(e.index(),e.index()+1,r))l.setNodeMarkup(l.mapping.map(i.before(n)),r)}if(e)e(l.scrollIntoView());return true}}const Eh=Oh();const Th=(t,e)=>{if(e)e(t.tr.setSelection(new He(t.doc)));return true};function Dh(t,e,i){let s=e.nodeBefore,n=e.nodeAfter,r=e.index();if(!s||!n||!s.type.compatibleContent(n.type))return false;if(!s.content.size&&e.parent.canReplace(r-1,r)){if(i)i(t.tr.delete(e.pos-s.nodeSize,e.pos).scrollIntoView());return true}if(!e.parent.canReplace(r,r+1)||!(n.isTextblock||de(t.doc,e.pos)))return false;if(i)i(t.tr.join(e.pos).scrollIntoView());return true}function Ih(t,e,i,s){let n=e.nodeBefore,r=e.nodeAfter,o,h;let l=n.type.spec.isolating||r.type.spec.isolating;if(!l&&Dh(t,e,i))return true;let u=!l&&e.parent.canReplace(e.index(),e.index()+1);if(u&&(o=(h=n.contentMatchAt(n.childCount)).findWrapping(r.type))&&h.matchType(o[0]||r.type).validEnd){if(i){let s=e.pos+r.nodeSize,h=f.empty;for(let t=o.length-1;t>=0;t--)h=f.from(o[t].create(null,h));h=f.from(n.copy(h));let l=t.tr.step(new Kt(e.pos-1,s,e.pos,s,new p(h,1,0),o.length,true));let u=l.doc.resolve(s+2*o.length);if(u.nodeAfter&&u.nodeAfter.type==n.type&&de(l.doc,u.pos))l.join(u.pos);i(l.scrollIntoView())}return true}let c=r.type.spec.isolating||s>0&&l?null:Ne.findFrom(e,1);let a=c&&c.$from.blockRange(c.$to),d=a&&se(a);if(d!=null&&d>=e.depth){if(i)i(t.tr.lift(a,d).scrollIntoView());return true}if(u&&ph(r,"start",true)&&ph(n,"end")){let s=n,o=[];for(;;){o.push(s);if(s.isTextblock)break;s=s.lastChild}let h=r,l=1;for(;!h.isTextblock;h=h.firstChild)l++;if(s.canReplace(s.childCount,s.childCount,h.content)){if(i){let s=f.empty;for(let t=o.length-1;t>=0;t--)s=f.from(o[t].copy(s));let n=t.tr.step(new Kt(e.pos-o.length,e.pos+r.nodeSize,e.pos+l,e.pos+r.nodeSize-l,new p(s,o.length,0),0,true));i(n.scrollIntoView())}return true}}return false}function Ph(t){return function(e,i){let s=e.selection,n=t<0?s.$from:s.$to;let r=n.depth;while(n.node(r).isInline){if(!r)return false;r--}if(!n.node(r).isTextblock)return false;if(i)i(e.tr.setSelection(Ye.create(e.doc,t<0?n.start(r):n.end(r))));return true}}const Rh=Ph(-1);const $h=Ph(1);function Uh(...t){return function(e,i,s){for(let n=0;n<t.length;n++)if(t[n](e,i,s))return true;return false}}let jh=Uh(ah,wh,gh);let Bh=Uh(ah,vh,bh);const Fh={Enter:Uh(kh,Sh,Ch,Eh),"Mod-Enter":xh,Backspace:jh,"Mod-Backspace":jh,"Shift-Backspace":jh,Delete:Bh,"Mod-Delete":Bh,"Mod-a":Th};const Nh={"Ctrl-h":Fh["Backspace"],"Alt-Backspace":Fh["Mod-Backspace"],"Ctrl-d":Fh["Delete"],"Ctrl-Alt-Backspace":Fh["Mod-Delete"],"Alt-Delete":Fh["Mod-Delete"],"Alt-d":Fh["Mod-Delete"],"Ctrl-a":Rh,"Ctrl-e":$h};for(let t in Fh)Nh[t]=Fh[t];const Lh=typeof navigator!="undefined"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os!="undefined"&&os.platform?os.platform()=="darwin":false;const _h=Lh?Nh:Fh;class zh extends s{__class__="KritzelText";fontFamily="Arial";fontSize=8;fontColor="#000000";initialWidth=1;initialHeight=1;scale=1;scaleFactor=1;isDebugInfoVisible=true;isEditable=true;isEditing=false;editor=null;content=null;_schema=new rt({nodes:Ko(Yo.spec.nodes,"paragraph block*","block"),marks:Yo.spec.marks});uneditedObject=null;rows=1;get isEmpty(){if(!this.editor){return true}const t=this.editor.state.doc;if(t.content.size===0){return true}const e=t.textContent.trim();return e.length===0}constructor(t){super();if(t){this.translateX=t.translateX||0;this.translateY=t.translateY||0;this.fontSize=t.fontSize||8;this.fontFamily=t.fontFamily||"Arial";this.fontColor=t.fontColor||"#000000";this.width=this.initialWidth/(this._core.store.state.scale<0?this._core.store.state.scale:1);this.height=this.fontSize*1.2/(this._core.store.state.scale<0?this._core.store.state.scale:1);this.scale=t.scale||1;this.scaleFactor=t.scaleX??1}}static create(t,e,i){const s=new zh;s._core=t;s.id=s.generateId();s.workspaceId=t.store.state.activeWorkspace.id;s.fontSize=e;s.fontFamily=i;s.translateX=0;s.translateY=0;s.width=s.initialWidth/(s._core.store.state.scale<0?s._core.store.state.scale:1);s.height=s.fontSize*1.2/(s._core.store.state.scale<0?s._core.store.state.scale:1);s.backgroundColor="transparent";s.initialWidth=s.width;s.initialHeight=s.height;s.scaleFactor=1;s.scale=s._core.store.state.scale;s.zIndex=t.store.currentZIndex;s.editor=s.createEditor();return s}mount(t){if(t===null||this.isInViewport()===false){return}if(this.isMounted&&this.elementRef===t&&this.editor.dom.parentElement===t){return}this.elementRef=t;this.elementRef.style.fontFamily=this.fontFamily;this.elementRef.style.fontSize=`${this.fontSize}pt`;this.elementRef.style.color=this.fontColor;this.elementRef.style.whiteSpace="pre-wrap";this.elementRef.style.wordWrap="break-word";this.elementRef.innerHTML="";this.elementRef.appendChild(this.editor.dom);this.isMounted=true;requestAnimationFrame((()=>this.adjustSizeOnInput()))}createEditor(){const t=this._schema.node("doc",null,[this._schema.node("paragraph")]);return new So(null,{state:ri.create({doc:t,plugins:[uh(_h)]}),editable:()=>false,dispatchTransaction:t=>{const e=this.editor.state.apply(t);this.editor.updateState(e);if(t.docChanged){this.content=e.doc.toJSON();this.adjustSizeOnInput();if(!t.getMeta("fromRemote")){this._core.store.state.objects.update(this,{temporary:true})}}}})}setContent(t){this.content=t;if(this.editor&&t){const e=this.editor.state.schema.nodeFromJSON(t);const i=this.editor.state.tr.replaceWith(0,this.editor.state.doc.content.size,e.content);i.setMeta("fromRemote",true);this.editor.dispatch(i)}}adjustSizeOnInput(){const t=this.elementRef;if(t&&this.isMounted&&t.scrollWidth>0){const e=this.totalWidth;const i=this.totalHeight;const s=t.scrollWidth;const n=t.scrollHeight;this.width=s*this.scaleFactor;this.height=n*this.scaleFactor;if(this.rotation!==0){const t=this.totalWidth;const s=this.totalHeight;const n=(t-e)/2/this.scale;const r=(s-i)/2/this.scale;if(n!==0||r!==0){const t=Math.cos(this.rotation);const e=Math.sin(this.rotation);const i=t*n-e*r;const s=e*n+t*r;this.translateX+=i-n;this.translateY+=s-r}}}}resize(t,e,i,s){if(i<=1||s<=1){return}const n=this.width/this.scaleFactor;const r=this.height/this.scaleFactor;const o=i/n;const h=s/r;this.scaleFactor=Math.min(o,h);this.width=n*this.scaleFactor;this.height=r*this.scaleFactor;this.translateX=t;this.translateY=e;this._core.store.state.objects.update(this)}focus(t){if(this.editor){const e=this.editor.state.doc;if(t.x&&t.y){const i=this.editor.posAtCoords({left:t.x,top:t.y});if(i){this.editor.dispatch(this.editor.state.tr.setSelection(Ye.create(e,i.pos)));this.editor.focus();if(r.isIOS()){this.scrollIntoViewOnIOS()}return}}const i=Math.max(1,e.content.size-1);this.editor.dispatch(this.editor.state.tr.setSelection(Ye.create(e,i)));this.editor.focus();if(r.isIOS()){this.scrollIntoViewOnIOS()}}}scrollIntoViewOnIOS(){setTimeout((()=>{if(this.editor&&this.editor.dom){this.editor.dom.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"})}}),300)}edit(e){n.disableInteractiveWidget();this.uneditedObject=this.clone();this._core.store.setState("activeTool",t.getTool("text"));this.editor.setProps({editable:()=>true});this.isEditing=true;this._core.rerender();this.adjustSizeOnInput();this.focus({x:e?.clientX,y:e?.clientY});n.enableInteractiveWidget()}save(){requestAnimationFrame((()=>this.adjustSizeOnInput()));this.content=this.editor.state.doc.toJSON();this.editor.setProps({editable:()=>false});this.editor.dom.blur();this.isEditing=false;this._core.store.state.objects.consolidateTemporaryItems();this._core.store.state.objects.update(this);this._core.engine.emitObjectsChange()}handlePointerDown(t){if(!this.isEditing){return}t.stopPropagation()}handlePointerMove(t){if(!this.isEditing){return}t.stopPropagation()}handlePointerUp(t){if(!this.isEditing){return}t.stopPropagation()}copy(){const t=super.copy();t.editor=t.createEditor();if(this.content){t.setContent(this.content)}return t}serialize(){const{_core:t,_elementRef:e,_schema:i,element:s,totalWidth:n,totalHeight:r,editor:o,uneditedObject:h,...l}=this;const f=structuredClone(l);if(s&&typeof s==="object"&&"nodeType"in s&&s.nodeType===1){f.element=s.cloneNode(true)}return f}deserialize(t){super.deserialize(t);if(t.content){this.setContent(t.content)}return this}}var Yh={};var Xh;function Wh(){if(Xh)return Yh;Xh=1;(function(t){var e=Object.defineProperty;var i=t=>e(t,"__esModule",{value:true});var s=(t,s)=>{i(t);for(var n in s)e(t,n,{get:s[n],enumerable:true})};s(t,{default:()=>E,getStroke:()=>O,getStrokeOutlinePoints:()=>S,getStrokePoints:()=>C});function n(t,e,i,s=t=>t){return t*s(.5-e*(.5-i))}function r(t){return[-t[0],-t[1]]}function o(t,e){return[t[0]+e[0],t[1]+e[1]]}function h(t,e){return[t[0]-e[0],t[1]-e[1]]}function l(t,e){return[t[0]*e,t[1]*e]}function f(t,e){return[t[0]/e,t[1]/e]}function u(t){return[t[1],-t[0]]}function c(t,e){return t[0]*e[0]+t[1]*e[1]}function a(t,e){return t[0]===e[0]&&t[1]===e[1]}function d(t){return Math.hypot(t[0],t[1])}function w(t){return t[0]*t[0]+t[1]*t[1]}function p(t,e){return w(h(t,e))}function g(t){return f(t,d(t))}function m(t,e){return Math.hypot(t[1]-e[1],t[0]-e[0])}function y(t,e,i){let s=Math.sin(i),n=Math.cos(i),r=t[0]-e[0],o=t[1]-e[1],h=r*n-o*s,l=r*s+o*n;return[h+e[0],l+e[1]]}function v(t,e,i){return o(t,l(h(e,t),i))}function b(t,e,i){return o(t,l(e,i))}var{min:M,PI:k}=Math,A=.275,x=k+1e-4;function S(t,e={}){let{size:i=16,smoothing:s=.5,thinning:f=.5,simulatePressure:a=true,easing:d=t=>t,start:w={},end:m={},last:k=false}=e,{cap:S=true,easing:C=t=>t*(2-t)}=w,{cap:O=true,easing:E=t=>--t*t*t+1}=m;if(t.length===0||i<=0)return[];let T=t[t.length-1].runningLength,D=w.taper===false?0:w.taper===true?Math.max(i,T):w.taper,I=m.taper===false?0:m.taper===true?Math.max(i,T):m.taper,P=Math.pow(i*s,2),R=[],$=[],U=t.slice(0,10).reduce(((t,e)=>{let s=e.pressure;if(a){let n=M(1,e.distance/i),r=M(1,1-n);s=M(1,t+(r-t)*(n*A))}return(t+s)/2}),t[0].pressure),j=n(i,f,t[t.length-1].pressure,d),B,F=t[0].vector,N=t[0].point,L=N,_=N,z=L,Y=false;for(let e=0;e<t.length;e++){let{pressure:s}=t[e],{point:r,vector:w,distance:g,runningLength:m}=t[e];if(e<t.length-1&&T-m<3)continue;if(f){if(a){let t=M(1,g/i),e=M(1,1-t);s=M(1,U+(e-U)*(t*A))}j=n(i,f,s,d)}else j=i/2;B===void 0&&(B=j);let b=m<D?C(m/D):1,k=T-m<I?E((T-m)/I):1;j=Math.max(.01,j*Math.min(b,k));let S=(e<t.length-1?t[e+1]:t[e]).vector,O=e<t.length-1?c(w,S):1,X=c(w,F)<0&&!Y,W=O!==null&&O<0;if(X||W){let t=l(u(F),j);for(let e=1/13,i=0;i<=1;i+=e)_=y(h(r,t),r,x*i),R.push(_),z=y(o(r,t),r,x*-i),$.push(z);N=_,L=z,W&&(Y=true);continue}if(Y=false,e===t.length-1){let t=l(u(w),j);R.push(h(r,t)),$.push(o(r,t));continue}let J=l(u(v(S,w,O)),j);_=h(r,J),(e<=1||p(N,_)>P)&&(R.push(_),N=_),z=o(r,J),(e<=1||p(L,z)>P)&&($.push(z),L=z),U=s,F=w}let X=t[0].point.slice(0,2),W=t.length>1?t[t.length-1].point.slice(0,2):o(t[0].point,[1,1]),J=[],H=[];if(t.length===1){if(!(D||I)||k){let t=b(X,g(u(h(X,W))),-(B||j)),e=[];for(let i=1/13,s=i;s<=1;s+=i)e.push(y(t,X,x*2*s));return e}}else{if(!(D||I&&t.length===1))if(S)for(let t=1/13,e=t;e<=1;e+=t){let t=y($[0],X,x*e);J.push(t)}else{let t=h(R[0],$[0]),e=l(t,.5),i=l(t,.51);J.push(h(X,e),h(X,i),o(X,i),o(X,e))}let e=u(r(t[t.length-1].vector));if(I||D&&t.length===1)H.push(W);else if(O){let t=b(W,e,j);for(let e=1/29,i=e;i<1;i+=e)H.push(y(t,W,x*3*i))}else H.push(o(W,l(e,j)),o(W,l(e,j*.99)),h(W,l(e,j*.99)),h(W,l(e,j)))}return R.concat(H,$.reverse(),J)}function C(t,e={}){var i;let{streamline:s=.5,size:n=16,last:r=false}=e;if(t.length===0)return[];let l=.15+(1-s)*.85,f=Array.isArray(t[0])?t:t.map((({x:t,y:e,pressure:i=.5})=>[t,e,i]));if(f.length===2){let t=f[1];f=f.slice(0,-1);for(let e=1;e<5;e++)f.push(v(f[0],t,e/4))}f.length===1&&(f=[...f,[...o(f[0],[1,1]),...f[0].slice(2)]]);let u=[{point:[f[0][0],f[0][1]],pressure:f[0][2]>=0?f[0][2]:.25,vector:[1,1],distance:0,runningLength:0}],c=false,d=0,w=u[0],p=f.length-1;for(let t=1;t<f.length;t++){let e=r&&t===p?f[t].slice(0,2):v(w.point,f[t],l);if(a(w.point,e))continue;let i=m(e,w.point);if(d+=i,t<p&&!c){if(d<n)continue;c=true}w={point:e,pressure:f[t][2]>=0?f[t][2]:.5,vector:g(h(w.point,e)),distance:i,runningLength:d},u.push(w)}return u[0].vector=((i=u[1])==null?void 0:i.vector)||[0,0],u}function O(t,e={}){return S(C(t,e),e)}var E=O})(Yh);return Yh}var Jh=Wh();class Hh{static average(t,e){return(t+e)/2}}class Vh extends s{__class__="KritzelPath";points;d;stroke="none";strokeWidth;lineSlack=.5;fill;x=0;y=0;height=0;width=0;scale=1;options;isVisible=true;isDebugInfoVisible=true;isCompleted=false;_adjustedPoints=null;get viewBox(){return`${this.x} ${this.y} ${this.width} ${this.height}`}constructor(t){super();this.options=t;this.points=t?.points??[];this.translateX=t?.translateX??0;this.translateY=t?.translateY??0;this.scale=t?.scale??1;this.strokeWidth=t?.strokeWidth??8;this.fill=t?.fill??"#000000";this.d=this.generateSvgPath();this.updateDimensions()}static create(t,e){const i=new Vh;i._core=t;i.id=i.generateId();i.workspaceId=t.store.state.activeWorkspace.id;i.options=e;i.points=e?.points??[];i.translateX=e?.translateX??0;i.translateY=e?.translateY??0;i.scale=e?.scale??1;i.strokeWidth=e?.strokeWidth??8;i.fill=e?.fill??"#000000";i.zIndex=t.store.currentZIndex;i.d=i.generateSvgPath();i.updateDimensions();return i}resize(t,e,i,s){if(i<=1||s<=1){return}const n=i/this.width;const r=s/this.height;this.width=i;this.height=s;this.points=this.points.map((([t,e])=>[t*n,e*r]));this.d=this.generateSvgPath();this.width=Math.max(...this.points.map((t=>t[0])))-Math.min(...this.points.map((t=>t[0])))+this.strokeWidth;this.height=Math.max(...this.points.map((t=>t[1])))-Math.min(...this.points.map((t=>t[1])))+this.strokeWidth;this.x=Math.min(...this.points.map((t=>t[0])))-this.strokeWidth/2;this.y=Math.min(...this.points.map((t=>t[1])))-this.strokeWidth/2;this.translateX=t;this.translateY=e;this._adjustedPoints=null;this._core.store.state.objects.update(this)}rotate(t){this.rotation=t;this._adjustedPoints=null;this._core.store.state.objects.update(this)}move(t,e,i,s){const n=(t-i)/this._core.store.state.scale;const r=(e-s)/this._core.store.state.scale;this.translateX+=n;this.translateY+=r;this._adjustedPoints=null;this._core.store.state.objects.update(this)}hitTest(t,e){const i=this.strokeWidth/this.scale/2;if(this._adjustedPoints===null){this._adjustedPoints=this.computeAdjustedPoints()}if(this._adjustedPoints.length===1){const s=this._adjustedPoints[0];const n=this.pointToLineSegmentDistance(t,e,s[0],s[1],s[0],s[1]);return n<=i}for(let s=0;s<this._adjustedPoints.length-1;s++){const n=this._adjustedPoints[s];const r=this._adjustedPoints[s+1];const o=this.pointToLineSegmentDistance(t,e,n[0],n[1],r[0],r[1]);if(o<=i){return true}}return false}hitTestPolygon(t){const e=this.strokeWidth/this.scale/2;if(this._adjustedPoints===null){this._adjustedPoints=this.computeAdjustedPoints()}const s=[{x:t.bottomLeft.x,y:t.bottomLeft.y},{x:t.bottomRight.x,y:t.bottomRight.y},{x:t.topRight.x,y:t.topRight.y},{x:t.topLeft.x,y:t.topLeft.y}];for(const[t,e]of this._adjustedPoints){if(i.isPointInPolygon({x:t,y:e},s)){return true}}for(const t of s){if(this.hitTest(t.x,t.y)){return true}}for(let t=0;t<this._adjustedPoints.length-1;t++){const e={x:this._adjustedPoints[t][0],y:this._adjustedPoints[t][1]};const n={x:this._adjustedPoints[t+1][0],y:this._adjustedPoints[t+1][1]};for(let t=0;t<s.length;t++){const r=s[t];const o=s[(t+1)%s.length];if(i.intersectLines(e,n,r,o)){return true}}}for(let t=0;t<this._adjustedPoints.length-1;t++){const i=this._adjustedPoints[t];const n=this._adjustedPoints[t+1];for(let t=0;t<s.length;t++){const r=s[t];const o=s[(t+1)%s.length];const h=this.pointToLineSegmentDistance(r.x,r.y,i[0],i[1],n[0],n[1]);const l=this.pointToLineSegmentDistance(o.x,o.y,i[0],i[1],n[0],n[1]);const f=this.pointToLineSegmentDistance(i[0],i[1],r.x,r.y,o.x,o.y);const u=this.pointToLineSegmentDistance(n[0],n[1],r.x,r.y,o.x,o.y);const c=Math.min(h,l,f,u);if(c<=e){return true}}}return false}updatePosition(t,e){this.translateX=t;this.translateY=e;this._adjustedPoints=null;this._core.store.state.objects.update(this)}computeAdjustedPoints(){if(!this.points?.length){return[]}const t=this.rotation;const e=Math.cos(t);const i=Math.sin(t);const s=this.points.map((t=>t[0]));const n=this.points.map((t=>t[1]));const r={x:(Math.min(...s)+Math.max(...s))/2,y:(Math.min(...n)+Math.max(...n))/2};const{x:o,y:h}=r;const l=this.points.map((([t,s])=>{const n=t-o;const r=s-h;return[o+n*e-r*i,h+n*i+r*e]}));return l.map((([t,e])=>[Math.abs(t-this.x)/this.scale+this.translateX,Math.abs(e-this.y)/this.scale+this.translateY]))}pointToLineSegmentDistance(t,e,i,s,n,r){const o=t-i;const h=e-s;const l=n-i;const f=r-s;const u=o*l+h*f;const c=l*l+f*f;let a=-1;if(c!==0){a=u/c}let d,w;if(a<0){d=i;w=s}else if(a>1){d=n;w=r}else{d=i+a*l;w=s+a*f}const p=t-d;const g=e-w;return Math.sqrt(p*p+g*g)}updateDimensions(){const t=this.points.map((([t,e])=>{const i=t*Math.cos(this.rotation)-e*Math.sin(this.rotation);const s=t*Math.sin(this.rotation)+e*Math.cos(this.rotation);return[i,s]}));const e=Math.min(...t.map((t=>t[0]-this.strokeWidth/2)));const i=Math.min(...t.map((t=>t[1]-this.strokeWidth/2)));const s=Math.max(...t.map((t=>t[0]+this.strokeWidth/2)));const n=Math.max(...t.map((t=>t[1]+this.strokeWidth/2)));this.width=s-e+this.lineSlack;this.height=n-i+this.lineSlack;this.x=e;this.y=i;this.translateX=(this.x+this.translateX)/this.scale;this.translateY=(this.y+this.translateY)/this.scale}generateSvgPath(){const t=this.getStrokeFromPoints(this.points,this.strokeWidth);return this.getSvgPathFromStroke(t)}getStrokeFromPoints(t,e){return Jh.getStroke(t,{size:e,thinning:.5,smoothing:.5,streamline:.5,easing:t=>t,simulatePressure:true,last:true,start:{cap:true,taper:0,easing:t=>t},end:{cap:true,taper:0,easing:t=>t}})}getSvgPathFromStroke(t,e=true){const i=t.length;if(i<4){return``}let s=t[0];let n=t[1];const r=t[2];let o=`M${s[0].toFixed(2)},${s[1].toFixed(2)} Q${n[0].toFixed(2)},${n[1].toFixed(2)} ${Hh.average(n[0],r[0]).toFixed(2)},${Hh.average(n[1],r[1]).toFixed(2)} T`;for(let e=2,r=i-1;e<r;e++){s=t[e];n=t[e+1];o+=`${Hh.average(s[0],n[0]).toFixed(2)},${Hh.average(s[1],n[1]).toFixed(2)} `}if(e){o+="Z"}return o}isLowRes(){if(!this._core){return false}const t=this._core.store.state.scale;const e=this.boundingBox.width*t;const i=this.boundingBox.height*t;return e*i<500}getClipPoint(t){const e=this.centerX;const i=this.centerY;const s=this.strokeWidth/this.scale/2;if(this._adjustedPoints===null){this._adjustedPoints=this.computeAdjustedPoints()}if(this._adjustedPoints.length<1){return null}const n=32;let r=true;for(let o=1;o<=n;o++){const h=o/n;const l=t.x+(e-t.x)*h;const f=t.y+(i-t.y)*h;let u=Infinity;if(this._adjustedPoints.length===1){const t=this._adjustedPoints[0];const e=l-t[0];const i=f-t[1];u=Math.sqrt(e*e+i*i)}else{for(let t=0;t<this._adjustedPoints.length-1;t++){const e=this._adjustedPoints[t];const i=this._adjustedPoints[t+1];const s=this.pointToLineSegmentDistance(l,f,e[0],e[1],i[0],i[1]);if(s<u){u=s}}}const c=u<=s;if(r&&c){let r=(o-1)/n;let l=h;for(let n=0;n<8;n++){const n=(r+l)/2;const o=t.x+(e-t.x)*n;const h=t.y+(i-t.y)*n;let f=Infinity;if(this._adjustedPoints.length===1){const t=this._adjustedPoints[0];const e=o-t[0];const i=h-t[1];f=Math.sqrt(e*e+i*i)}else{for(let t=0;t<this._adjustedPoints.length-1;t++){const e=this._adjustedPoints[t];const i=this._adjustedPoints[t+1];const s=this.pointToLineSegmentDistance(o,h,e[0],e[1],i[0],i[1]);if(s<f){f=s}}}if(f<=s){l=n}else{r=n}}const f=(r+l)/2;return{x:t.x+(e-t.x)*f,y:t.y+(i-t.y)*f}}r=!c}return null}}class Qh extends s{__class__="KritzelImage";src="";maxWidth=300;maxHeight=300;maxCompressionSize=300;isDebugInfoVisible=true;constructor(t){super();this.src=t?.src||"";this.x=t?.x||0;this.y=t?.y||0;this.translateX=t?.translateX||0;this.translateY=t?.translateY||0;this.scale=t?.scale||1}static create(t){const e=new Qh;e._core=t;e.id=e.generateId();e.workspaceId=t.store.state.activeWorkspace.id;e.x=0;e.y=0;e.translateX=0;e.translateY=0;e.scale=e._core.store.state.scale;e.zIndex=t.store.currentZIndex;return e}resize(t,e,i,s){if(i<=1||s<=1){return}const n=s/this.height;this.width=this.width*n;this.height=this.height*n;this.translateX=t;this.translateY=e;this._core.store.state.objects.update(this)}calculateScaledDimensions(t){let e=t.width;let i=t.height;if(t.width>this.maxWidth||t.height>this.maxHeight){const s=this.maxWidth/t.width;const n=this.maxHeight/t.height;const r=Math.min(s,n);e=t.width*r;i=t.height*r}return{scaledWidth:e,scaledHeight:i}}}class qh extends s{__class__="KritzelLine";startX;startY;endX;endY;controlX;controlY;stroke;strokeWidth;scale=1;options;startAnchor;endAnchor;arrows;isVisible=true;isDebugInfoVisible=true;isCompleted=false;_adjustedPoints=null;get d(){if(this.controlX!==undefined&&this.controlY!==undefined){return`M ${this.startX} ${this.startY} Q ${this.controlX} ${this.controlY} ${this.endX} ${this.endY}`}return`M ${this.startX} ${this.startY} L ${this.endX} ${this.endY}`}get viewBox(){return`${this.x} ${this.y} ${this.width} ${this.height}`}constructor(t){super();this.options=t;this.startX=t?.startX??0;this.startY=t?.startY??0;this.endX=t?.endX??0;this.endY=t?.endY??0;this.controlX=t?.controlX;this.controlY=t?.controlY;this.translateX=t?.translateX??0;this.translateY=t?.translateY??0;this.scale=t?.scale??1;this.strokeWidth=t?.strokeWidth??4;this.stroke=t?.stroke??"#000000";this.startAnchor=t?.startAnchor;this.endAnchor=t?.endAnchor;this.arrows=t?.arrows;this.updateDimensions()}static create(t,e){const i=new qh;i._core=t;i.id=i.generateId();i.workspaceId=t.store.state.activeWorkspace.id;i.options=e;i.startX=e?.startX??0;i.startY=e?.startY??0;i.endX=e?.endX??0;i.endY=e?.endY??0;i.controlX=e?.controlX;i.controlY=e?.controlY;i.translateX=e?.translateX??0;i.translateY=e?.translateY??0;i.scale=e?.scale??1;i.strokeWidth=e?.strokeWidth??4;i.stroke=e?.stroke??"#000000";i.startAnchor=e?.startAnchor;i.endAnchor=e?.endAnchor;i.arrows=e?.arrows;i.zIndex=t.store.currentZIndex;i.updateDimensions();return i}resize(t,e,i,s){if(i<=1||s<=1){return}const n=i/this.width;const r=s/this.height;this.startX=this.startX*n;this.startY=this.startY*r;this.endX=this.endX*n;this.endY=this.endY*r;if(this.controlX!==undefined&&this.controlY!==undefined){this.controlX=this.controlX*n;this.controlY=this.controlY*r}const{minX:o,minY:h,maxX:l,maxY:f}=this.calculateBoundingBox();this.width=l-o;this.height=f-h;this.x=o;this.y=h;this.translateX=t;this.translateY=e;this._adjustedPoints=null;this._core.store.state.objects.update(this);this._core.anchorManager.updateAnchorsForObject(this.id);if(this.startAnchor){this._core.anchorManager.updateAnchorsForObject(this.startAnchor.objectId)}if(this.endAnchor){this._core.anchorManager.updateAnchorsForObject(this.endAnchor.objectId)}}rotate(t){this.rotation=t;this._adjustedPoints=null;this._core.store.state.objects.update(this)}move(t,e,i,s){const n=(t-i)/this._core.store.state.scale;const r=(e-s)/this._core.store.state.scale;this.translateX+=n;this.translateY+=r;if(this.startAnchor){this._core.anchorManager.updateAnchorsForObject(this.startAnchor.objectId)}if(this.endAnchor){this._core.anchorManager.updateAnchorsForObject(this.endAnchor.objectId)}this._adjustedPoints=null;this._core.store.state.objects.update(this)}hitTest(t,e){const i=20;const s=Math.max(this.strokeWidth,i);const n=s/this.scale/2;if(this._adjustedPoints===null){this._adjustedPoints=this.computeAdjustedPoints()}if(this.controlX!==undefined&&this.controlY!==undefined){const i=this.pointToBezierDistance(t,e);return i<=n}const r=this._adjustedPoints[0];const o=this._adjustedPoints[1];const h=this.pointToLineSegmentDistance(t,e,r[0],r[1],o[0],o[1]);return h<=n}hitTestPolygon(t){const e=this.strokeWidth/this.scale/2;if(this._adjustedPoints===null){this._adjustedPoints=this.computeAdjustedPoints()}const s=[{x:t.bottomLeft.x,y:t.bottomLeft.y},{x:t.bottomRight.x,y:t.bottomRight.y},{x:t.topRight.x,y:t.topRight.y},{x:t.topLeft.x,y:t.topLeft.y}];for(const[t,e]of this._adjustedPoints){if(i.isPointInPolygon({x:t,y:e},s)){return true}}for(const t of s){if(this.hitTest(t.x,t.y)){return true}}if(this.controlX!==undefined&&this.controlY!==undefined){const t=this._adjustedPoints[0];const n=this._adjustedPoints[1];const r=this.computeAdjustedControlPoint();const o=20;for(let h=1;h<o;h++){const l=h/o;const f=1-l;const u=f*f*t[0]+2*f*l*r[0]+l*l*n[0];const c=f*f*t[1]+2*f*l*r[1]+l*l*n[1];if(i.isPointInPolygon({x:u,y:c},s)){return true}for(let t=0;t<s.length;t++){const i=s[t];const n=s[(t+1)%s.length];const r=this.pointToLineSegmentDistance(u,c,i.x,i.y,n.x,n.y);if(r<=e){return true}}}return false}const n={x:this._adjustedPoints[0][0],y:this._adjustedPoints[0][1]};const r={x:this._adjustedPoints[1][0],y:this._adjustedPoints[1][1]};for(let t=0;t<s.length;t++){const o=s[t];const h=s[(t+1)%s.length];if(i.intersectLines(n,r,o,h)){return true}const l=this.pointToLineSegmentDistance(o.x,o.y,n.x,n.y,r.x,r.y);const f=this.pointToLineSegmentDistance(h.x,h.y,n.x,n.y,r.x,r.y);const u=this.pointToLineSegmentDistance(n.x,n.y,o.x,o.y,h.x,h.y);const c=this.pointToLineSegmentDistance(r.x,r.y,o.x,o.y,h.x,h.y);const a=Math.min(l,f,u,c);if(a<=e){return true}}return false}updatePosition(t,e){this.translateX=t;this.translateY=e;this._adjustedPoints=null;this._core.store.state.objects.update(this)}updateEndpoint(t,e,i){if(t==="start"){this.startX=e;this.startY=i}else{this.endX=e;this.endY=i}const s=this.width;const n=this.height;const{minX:r,minY:o,maxX:h,maxY:l}=this.calculateBoundingBox();const f=r-this.x;const u=o-this.y;const c=h-r;const a=l-o;const d=c-s;const w=a-n;const p=d/2;const g=w/2;this.x=r;this.y=o;this.width=c;this.height=a;const m=Math.cos(this.rotation);const y=Math.sin(this.rotation);const v=f+p;const b=u+g;const M=v*m-b*y;const k=v*y+b*m;const A=M-p;const x=k-g;this.translateX+=A/this.scale;this.translateY+=x/this.scale;this._adjustedPoints=null;this._core.store.state.objects.update(this)}updateControlPoint(t,e){this.controlX=t;this.controlY=e;const i=this.width;const s=this.height;const{minX:n,minY:r,maxX:o,maxY:h}=this.calculateBoundingBox();const l=n-this.x;const f=r-this.y;const u=o-n;const c=h-r;const a=u-i;const d=c-s;const w=a/2;const p=d/2;this.x=n;this.y=r;this.width=u;this.height=c;const g=Math.cos(this.rotation);const m=Math.sin(this.rotation);const y=l+w;const v=f+p;const b=y*g-v*m;const M=y*m+v*g;const k=b-w;const A=M-p;this.translateX+=k/this.scale;this.translateY+=A/this.scale;this._adjustedPoints=null;this._core.store.state.objects.update(this)}computeAdjustedPoints(){const t=[[this.startX,this.startY],[this.endX,this.endY]];const e=this.rotation;const i=Math.cos(e);const s=Math.sin(e);const n=t.map((t=>t[0]));const r=t.map((t=>t[1]));const o={x:(Math.min(...n)+Math.max(...n))/2,y:(Math.min(...r)+Math.max(...r))/2};const{x:h,y:l}=o;const f=t.map((([t,e])=>{const n=t-h;const r=e-l;return[h+n*i-r*s,l+n*s+r*i]}));return f.map((([t,e])=>[(t-this.x)/this.scale+this.translateX,(e-this.y)/this.scale+this.translateY]))}pointToLineSegmentDistance(t,e,i,s,n,r){const o=t-i;const h=e-s;const l=n-i;const f=r-s;const u=o*l+h*f;const c=l*l+f*f;let a=-1;if(c!==0){a=u/c}let d,w;if(a<0){d=i;w=s}else if(a>1){d=n;w=r}else{d=i+a*l;w=s+a*f}const p=t-d;const g=e-w;return Math.sqrt(p*p+g*g)}pointToBezierDistance(t,e){if(this._adjustedPoints===null){this._adjustedPoints=this.computeAdjustedPoints()}const i=this._adjustedPoints[0];const s=this._adjustedPoints[1];const n=this.computeAdjustedControlPoint();let r=Infinity;const o=20;for(let h=0;h<=o;h++){const l=h/o;const f=1-l;const u=f*f*i[0]+2*f*l*n[0]+l*l*s[0];const c=f*f*i[1]+2*f*l*n[1]+l*l*s[1];const a=t-u;const d=e-c;const w=Math.sqrt(a*a+d*d);if(w<r){r=w}}return r}computeAdjustedControlPoint(){if(this.controlX===undefined||this.controlY===undefined){return[(this.startX+this.endX)/2,(this.startY+this.endY)/2]}const t=this.rotation;const e=Math.cos(t);const i=Math.sin(t);const s=[this.startX,this.endX];const n=[this.startY,this.endY];const r={x:(Math.min(...s)+Math.max(...s))/2,y:(Math.min(...n)+Math.max(...n))/2};const{x:o,y:h}=r;const l=this.controlX-o;const f=this.controlY-h;const u=o+l*e-f*i;const c=h+l*i+f*e;return[(u-this.x)/this.scale+this.translateX,(c-this.y)/this.scale+this.translateY]}get rotatedPolygon(){const t=this.padding;const{minX:e,minY:i,maxX:s,maxY:n}=qh.calculateBoundingBox(this.startX,this.startY,this.endX,this.endY,this.controlX,this.controlY,this.strokeWidth);const r=e-this.x+t;const o=i-this.y+t;const h=s-this.x+t;const l=n-this.y+t;const f={x:r,y:o};const u={x:h,y:o};const c={x:h,y:l};const a={x:r,y:l};const d=this.totalWidth/2;const w=this.totalHeight/2;const p=this.rotation;const g=Math.cos(p);const m=Math.sin(p);const y=t=>{const e=(t.x-d)*g-(t.y-w)*m+d;const i=(t.x-d)*m+(t.y-w)*g+w;return{x:e/this.scale+this.translateX,y:i/this.scale+this.translateY}};return{topLeft:y(f),topRight:y(u),bottomRight:y(c),bottomLeft:y(a)}}static calculateBoundingBox(t,e,i,s,n,r,o){let h=Math.min(t,i);let l=Math.min(e,s);let f=Math.max(t,i);let u=Math.max(e,s);if(n!==undefined&&r!==undefined){const o=t-2*n+i;if(o!==0){const e=(t-n)/o;if(e>0&&e<1){const s=(1-e)*(1-e)*t+2*(1-e)*e*n+e*e*i;h=Math.min(h,s);f=Math.max(f,s)}}const c=e-2*r+s;if(c!==0){const t=(e-r)/c;if(t>0&&t<1){const i=(1-t)*(1-t)*e+2*(1-t)*t*r+t*t*s;l=Math.min(l,i);u=Math.max(u,i)}}}const c=o/2;return{minX:h-c,minY:l-c,maxX:f+c,maxY:u+c}}calculateBoundingBox(){return qh.calculateBoundingBox(this.startX,this.startY,this.endX,this.endY,this.controlX,this.controlY,this.strokeWidth)}updateDimensions(){const{minX:t,minY:e,maxX:i,maxY:s}=this.calculateBoundingBox();this.width=i-t;this.height=s-e;this.x=t;this.y=e;this.translateX=(this.x+this.translateX)/this.scale;this.translateY=(this.y+this.translateY)/this.scale}get startMarkerId(){return`arrow-start-${this.id}`}get endMarkerId(){return`arrow-end-${this.id}`}getArrowSize(t){const e=t==="start"?this.arrows?.start:this.arrows?.end;return e?.size??this.strokeWidth*3}getArrowFill(t){const e=t==="start"?this.arrows?.start:this.arrows?.end;return e?.fill??this.stroke}getArrowPath(t="triangle"){switch(t){case"triangle":return"M 0 0 L 10 5 L 0 10 z";case"open":return"M 0 0 L 10 5 L 0 10";case"diamond":return"M 0 5 L 5 0 L 10 5 L 5 10 z";case"circle":return"M 5,0 A 5,5 0 1,1 5,10 A 5,5 0 1,1 5,0";default:return"M 0 0 L 10 5 L 0 10 z"}}get hasStartArrow(){return this.arrows?.start?.enabled===true}get hasEndArrow(){return this.arrows?.end?.enabled===true}}class Kh extends s{__class__="KritzelGroup";childIds=[];unchangedChildSnapshots=new Map;snapshotRotation=0;snapshotTranslateX=0;snapshotTranslateY=0;snapshotTotalWidth=0;snapshotTotalHeight=0;snapshotScale=1;get children(){return this.childIds.map((t=>{const e=this._core.store.state.objects.filter((e=>e.id===t));return e.length>0?e[0]:null})).filter((t=>t!==null))}get length(){return this.childIds.length}static create(t){const e=new Kh;e._core=t;e.id=e.generateId();e.workspaceId=t.store.state.activeWorkspace.id;e.scale=t.store.state.scale;e.zIndex=t.store.currentZIndex;return e}static createFromObjects(t,e){const i=Kh.create(t);e.forEach((t=>{i.childIds.push(t.id)}));i.refreshBoundingBox();i.captureChildSnapshots();return i}static findParentGroup(t,e){const i=t.store.state.objects.filter((t=>t.__class__==="KritzelGroup"));for(const t of i){if(t.childIds.includes(e)){return t}}return null}addChild(t){if(!this.childIds.includes(t.id)){this.childIds.push(t.id);this.refreshBoundingBox();this.captureChildSnapshots()}}removeChild(t){const e=this.childIds.indexOf(t);if(e!==-1){this.childIds.splice(e,1);this.refreshBoundingBox();this.captureChildSnapshots()}}ungroup(){return this.children}finalize(){this.refreshBoundingBox();this.captureChildSnapshots()}refreshBoundingBox(){if(this.children.length===0){this.width=0;this.height=0;this.translateX=0;this.translateY=0;return}if(this.children.length===1){const t=this.children[0];this.translateX=t.boundingBox.x;this.translateY=t.boundingBox.y;this.width=t.boundingBox.width*this.scale;this.height=t.boundingBox.height*this.scale;return}const t=this.rotation;const e=Math.cos(-t);const i=Math.sin(-t);let s=Infinity;let n=-Infinity;let r=Infinity;let o=-Infinity;this.children.forEach((t=>{const h=t.rotatedPolygon;const l=[h.topLeft,h.topRight,h.bottomRight,h.bottomLeft];l.forEach((t=>{const h=t.x*e-t.y*i;const l=t.x*i+t.y*e;if(h<s)s=h;if(h>n)n=h;if(l<r)r=l;if(l>o)o=l}))}));const h=n-s;const l=o-r;this.width=(h-this.padding)*this.scale;this.height=(l-this.padding)*this.scale;const f=(s+n)/2;const u=(r+o)/2;const c=Math.cos(t);const a=Math.sin(t);const d=f*c-u*a;const w=f*a+u*c;this.translateX=d-(this.width/this.scale+2*this.padding)/2;this.translateY=w-(this.height/this.scale+2*this.padding)/2}captureChildSnapshots(){this.unchangedChildSnapshots.clear();this.snapshotRotation=this.rotation;this.snapshotTranslateX=this.translateX;this.snapshotTranslateY=this.translateY;this.snapshotTotalWidth=this.totalWidth;this.snapshotTotalHeight=this.totalHeight;this.snapshotScale=this.scale||1;this.children.forEach((t=>{this.unchangedChildSnapshots.set(t.id,{id:t.id,translateX:t.translateX,translateY:t.translateY,rotation:t.rotation,width:t.width,height:t.height,totalWidth:t.totalWidth,totalHeight:t.totalHeight,scale:t.scale})}))}move(t,e,i,s){const n=(t-i)/this._core.store.state.scale;const r=(e-s)/this._core.store.state.scale;this.translateX+=n;this.translateY+=r;this._core.store.state.objects.transaction((()=>{this._core.store.state.objects.update(this);this.children.forEach((n=>{n.move(t,e,i,s);this._core.anchorManager.updateAnchorsForObject(n.id)}))}));this.unchangedChildSnapshots.forEach((t=>{t.translateX+=n;t.translateY+=r}))}resize(t,e,i,s){const n=i/this.width;const r=s/this.height;const o=this.translateX+this.totalWidth/2/this.scale;const h=this.translateY+this.totalHeight/2/this.scale;const l=i+this.padding*2;const f=s+this.padding*2;const u=t+l/2/this.scale;const c=e+f/2/this.scale;const a=this.rotation;const d=Math.cos(-a);const w=Math.sin(-a);const p=Math.cos(a);const g=Math.sin(a);this._core.store.state.objects.transaction((()=>{this.children.forEach((t=>{const e=t.translateX+t.totalWidth/2/t.scale;const i=t.translateY+t.totalHeight/2/t.scale;const s=e-o;const l=i-h;const f=s*d-l*w;const m=s*w+l*d;const y=f*n;const v=m*r;const b=y*p-v*g;const M=y*g+v*p;const k=u+b;const A=c+M;const x=t.rotation-a;const S=Math.cos(x);const C=Math.sin(x);const O=Math.sqrt(Math.pow(n*S,2)+Math.pow(r*C,2));const E=Math.sqrt(Math.pow(n*C,2)+Math.pow(r*S,2));const T=t.width*O;const D=t.height*E;const I=T+t.padding*2;const P=D+t.padding*2;const R=k-I/2/t.scale;const $=A-P/2/t.scale;t.resize(R,$,T,D);this._core.anchorManager.updateAnchorsForObject(t.id)}));this.refreshBoundingBox();this.captureChildSnapshots();this._core.store.state.objects.update(this)}))}rotate(t){this.rotation=t;const e=this.translateX+this.totalWidth/2/this.scale;const i=this.translateY+this.totalHeight/2/this.scale;const s=t-this.snapshotRotation;const n=Math.cos(s);const r=Math.sin(s);this._core.store.state.objects.transaction((()=>{this._core.store.state.objects.update(this);this.children.forEach((o=>{const h=this.unchangedChildSnapshots.get(o.id);if(!h)return;const l=this.getOffsetXToCenterFromSnapshot(h);const f=this.getOffsetYToCenterFromSnapshot(h);const u=n*l-r*f;const c=r*l+n*f;o.translateX=e+u-o.totalWidth/2/o.scale;o.translateY=i+c-o.totalHeight/2/o.scale;o.rotate(this.children.length===1?t:h.rotation+s)}))}))}getOffsetXToCenterFromSnapshot(t){const e=t.translateX+t.totalWidth/t.scale/2;const i=this.snapshotScale||this.scale||1;const s=this.snapshotTranslateX+this.snapshotTotalWidth/i/2;return e-s}getOffsetYToCenterFromSnapshot(t){const e=t.translateY+t.totalHeight/t.scale/2;const i=this.snapshotScale||this.scale||1;const s=this.snapshotTranslateY+this.snapshotTotalHeight/i/2;return e-s}hitTest(t,e){return this.children.some((i=>i.hitTest(t,e)))}hitTestPolygon(t){return this.children.some((e=>e.hitTestPolygon(t)))}copy(){const t=Kh.create(this._core);const e=[];this.children.sort(((t,e)=>t.zIndex-e.zIndex)).forEach((i=>{const s=i.copy();e.push(s);t.childIds.push(s.id)}));t._pendingChildren=e;t.rotation=this.rotation;t.translateX=this.translateX;t.translateY=this.translateY;t.width=this.width;t.height=this.height;return t}serialize(){const{_core:t,_elementRef:e,element:i,totalWidth:s,totalHeight:n,unchangedChildSnapshots:r,...o}=this;const h=structuredClone(o);h.unchangedChildSnapshots=Object.fromEntries(this.unchangedChildSnapshots);return h}deserialize(t){super.deserialize(t);if(t.unchangedChildSnapshots){this.unchangedChildSnapshots=new Map(Object.entries(t.unchangedChildSnapshots))}return this}update(){this._core.store.state.objects.update(this)}updateWorkspaceId(t){this.workspaceId=t;this.children.forEach((e=>{e.workspaceId=t;if(e instanceof Kh){e.updateWorkspaceId(t)}}))}}var Gh;(function(t){t[t["Left"]=0]="Left";t[t["Middle"]=1]="Middle";t[t["Right"]=2]="Right"})(Gh||(Gh={}));class Zh{static isRightClick(t){return t.button===Gh.Right}static isLeftClick(t){return t.button===Gh.Left}static isPointerEventOnContextMenu(t){const e=t.composedPath();const i=e.find((t=>t.classList&&t.classList.contains("context-menu")));return!!i}static onLongPress(t,e,i){if(t.pointerType!=="touch"){i?.();return()=>{}}const s=t.clientX;const n=t.clientY;const r=t.target;if(!r){i?.();return()=>{}}const o=400;const h=10;const l=setTimeout((()=>{d();e(t)}),o);const f=()=>{clearTimeout(l);d();i?.()};const u=t=>{if(Math.abs(t.clientX-s)>h||Math.abs(t.clientY-n)>h){f()}};const c=()=>{f()};const a=()=>{f()};const d=()=>{r.removeEventListener("pointermove",u);r.removeEventListener("pointerup",c);r.removeEventListener("pointercancel",a)};r.addEventListener("pointermove",u,{passive:true});r.addEventListener("pointerup",c,{once:true});r.addEventListener("pointercancel",a,{once:true});return f}}class tl{__class__=this.constructor.name;name="base-tool";_core;constructor(t){this._core=t}onActivate(){}onDeactivate(){}handlePointerDown(t){}handlePointerMove(t){}handlePointerUp(t){}handleWheel(t){}serialize(){return{__class__:this.__class__,name:this.name}}deserialize(t){Object.assign(this,t);return this}}class el extends tl{type="pen";color="#000000";size=6;palettes={pen:["#000000","#FFFFFF","#FF0000","#00FF00","#0000FF","#FFFF00","#FF00FF","#00FFFF","#808080","#C0C0C0","#800000","#008000","#000080","#800080"],highlighter:["#ffff00","#ffb347","#b4ffb4"]};_currentPathId=null;constructor(t){super(t)}handlePointerDown(t){if(t.cancelable){t.preventDefault()}if(t.pointerType==="mouse"){if(Zh.isLeftClick(t)){this._core.store.state.isDrawing=true;const e=t.clientX-this._core.store.offsetX;const i=t.clientY-this._core.store.offsetY;const s=Vh.create(this._core,{points:[[e,i]],translateX:-this._core.store.state.translateX,translateY:-this._core.store.state.translateY,scale:this._core.store.state.scale,fill:this.color,strokeWidth:this.size});s.isCompleted=false;this._currentPathId=s.id;this._core.store.state.objects.insert(s)}}if(t.pointerType==="touch"){const t=Array.from(this._core.store.state.pointers.values());if(t.length===1){const e=Math.round(t[0].clientX-this._core.store.offsetX);const i=Math.round(t[0].clientY-this._core.store.offsetY);this._core.store.state.isDrawing=true;const s=Vh.create(this._core,{points:[[e,i]],translateX:-this._core.store.state.translateX,translateY:-this._core.store.state.translateY,scale:this._core.store.state.scale,fill:this.color,strokeWidth:this.size});s.isCompleted=false;this._currentPathId=s.id;this._core.store.state.objects.insert(s)}}}handlePointerMove(t){if(t.cancelable){t.preventDefault()}if(t.pointerType==="mouse"){if(this._core.store.state.isDrawing&&this._currentPathId){const e=this._core.store.state.objects.filter((t=>t.id===this._currentPathId));const i=e.length>0?e[0]:null;if(i){const e=t.clientX-this._core.store.offsetX;const s=t.clientY-this._core.store.offsetY;const n=Vh.create(this._core,{points:[...i.points,[e,s]],translateX:-this._core.store.state.translateX,translateY:-this._core.store.state.translateY,scale:this._core.store.state.scale,fill:this.color,strokeWidth:this.size});n.id=i.id;n.workspaceId=i.workspaceId;n.zIndex=i.zIndex;n.isCompleted=false;this._core.store.state.objects.update(n)}}}if(t.pointerType==="touch"){const t=Array.from(this._core.store.state.pointers.values());if(t.length===1){if(this._currentPathId){const e=this._core.store.state.objects.filter((t=>t.id===this._currentPathId));const i=e.length>0?e[0]:null;if(i){const e=Math.round(t[0].clientX-this._core.store.offsetX);const s=Math.round(t[0].clientY-this._core.store.offsetY);const n=Vh.create(this._core,{points:[...i.points,[e,s]],translateX:-this._core.store.state.translateX,translateY:-this._core.store.state.translateY,scale:this._core.store.state.scale,fill:this.color,strokeWidth:this.size});n.id=i.id;n.workspaceId=i.workspaceId;n.zIndex=i.zIndex;n.isCompleted=false;this._core.store.state.objects.update(n)}}}}}handlePointerUp(t){if(t.cancelable){t.preventDefault()}if(t.pointerType==="mouse"){if(this._core.store.state.isDrawing){this._core.store.state.isDrawing=false;if(this._currentPathId){const t=this._core.store.state.objects.filter((t=>t.id===this._currentPathId));const e=t.length>0?t[0]:null;if(e){e.isCompleted=true;this._core.store.state.objects.update(e);this._core.engine.emitObjectsChange()}this._currentPathId=null}}}if(t.pointerType==="touch"){if(this._core.store.state.isDrawing){this._core.store.state.isDrawing=false;if(this._currentPathId){const t=this._core.store.state.objects.filter((t=>t.id===this._currentPathId));const e=t.length>0?t[0]:null;if(e){e.isCompleted=true;this._core.store.state.objects.update(e);this._core.engine.emitObjectsChange()}this._currentPathId=null}}}}}class il extends s{__class__="KritzelSelectionGroup";objectIds=[];unchangedObjectSnapshots=new Map;snapshotRotation=0;minX;maxX;minY;maxY;get objects(){return this.objectIds.map((t=>{const e=this._core.store.state.objects.filter((e=>e.id===t));return e.length>0?e[0]:null})).filter((t=>t!==null))}get length(){return this.objectIds.length}static create(t){const e=new il;e._core=t;e.id=e.generateId();e.workspaceId=t.store.state.activeWorkspace.id;e.scale=t.store.state.scale;e.zIndex=99999;return e}addOrRemove(t){const e=this.objectIds.findIndex((e=>e===t.id));if(e===-1){this.objectIds.push(t.id)}else{this.objectIds.splice(e,1)}this.captureUnchangedSnapshots();this.refreshObjectDimensions()}beginTransform(){this.refreshObjectDimensions();this.captureUnchangedSnapshots();this.objects.forEach((t=>{if(t instanceof Kh){t.finalize()}}))}deselectAllChildren(){this.objects.forEach((t=>t.isSelected=false))}updateWorkspaceId(t){this.workspaceId=t;this.objects.forEach((e=>e.workspaceId=t))}updateZIndices(t){this.objects.forEach(((e,i)=>{e.zIndex=t+i}))}updatePosition(t,e){this.objects.forEach((i=>{const s=i.translateX-this.translateX;const n=i.translateY-this.translateY;i.updatePosition(t+s,e+n)}));this.unchangedObjectSnapshots.forEach((i=>{const s=i.translateX-this.translateX;const n=i.translateY-this.translateY;i.translateX=t+s;i.translateY=e+n}));this.translateX=t;this.translateY=e;this._core.store.state.objects.update(this)}captureUnchangedSnapshots(){this.unchangedObjectSnapshots.clear();this.snapshotRotation=this.rotation;this.objects.forEach((t=>{this.unchangedObjectSnapshots.set(t.id,{id:t.id,translateX:t.translateX,translateY:t.translateY,rotation:t.rotation,width:t.width,height:t.height,totalWidth:t.totalWidth,totalHeight:t.totalHeight,scale:t.scale})}))}serialize(){const{_core:t,_elementRef:e,element:i,totalWidth:s,totalHeight:n,unchangedObjectSnapshots:r,...o}=this;const h=structuredClone(o);if(i&&typeof i==="object"&&"nodeType"in i&&i.nodeType===1){h.element=i.cloneNode(true)}h.unchangedObjectSnapshots=Object.fromEntries(this.unchangedObjectSnapshots);return h}deserialize(t){super.deserialize(t);if(t.unchangedObjectSnapshots){this.unchangedObjectSnapshots=new Map(Object.entries(t.unchangedObjectSnapshots))}return this}update(){this._core.store.state.objects.update(this)}move(t,e,i,s){const n=(t-i)/this._core.store.state.scale;const r=(e-s)/this._core.store.state.scale;this.translateX+=n;this.translateY+=r;this._core.store.state.objects.transaction((()=>{this._core.store.state.objects.update(this);this.objects.forEach((n=>{n.move(t,e,i,s);this._core.anchorManager.updateAnchorsForObject(n.id)}))}));this.unchangedObjectSnapshots.forEach((t=>{t.translateX+=n;t.translateY+=r}))}resize(t,e,i,s){const n=i/this.width;const r=s/this.height;const o=this.translateX+this.totalWidth/2/this.scale;const h=this.translateY+this.totalHeight/2/this.scale;const l=i+this.padding*2;const f=s+this.padding*2;const u=t+l/2/this.scale;const c=e+f/2/this.scale;const a=this.rotation;const d=Math.cos(-a);const w=Math.sin(-a);const p=Math.cos(a);const g=Math.sin(a);this._core.store.state.objects.transaction((()=>{this.objects.forEach((t=>{const e=t.translateX+t.totalWidth/2/t.scale;const i=t.translateY+t.totalHeight/2/t.scale;const s=e-o;const l=i-h;const f=s*d-l*w;const m=s*w+l*d;const y=f*n;const v=m*r;const b=y*p-v*g;const M=y*g+v*p;const k=u+b;const A=c+M;const x=t.rotation-a;const S=Math.cos(x);const C=Math.sin(x);const O=Math.sqrt(Math.pow(n*S,2)+Math.pow(r*C,2));const E=Math.sqrt(Math.pow(n*C,2)+Math.pow(r*S,2));const T=t.width*O;const D=t.height*E;const I=T+t.padding*2;const P=D+t.padding*2;const R=k-I/2/t.scale;const $=A-P/2/t.scale;t.resize(R,$,T,D);this._core.anchorManager.updateAnchorsForObject(t.id)}));this.refreshObjectDimensions();this.captureUnchangedSnapshots();this._core.store.state.objects.update(this)}))}rotate(t){this.rotation=t;const e=this.translateX+this.totalWidth/2/this.scale;const i=this.translateY+this.totalHeight/2/this.scale;const s=t-this.snapshotRotation;const n=Math.cos(s);const r=Math.sin(s);this._core.store.state.objects.transaction((()=>{this._core.store.state.objects.update(this);this.objects.forEach((o=>{const h=this.unchangedObjectSnapshots.get(o.id);if(!h)return;const l=this.getOffsetXToCenterFromSnapshot(h);const f=this.getOffsetYToCenterFromSnapshot(h);const u=n*l-r*f;const c=r*l+n*f;o.translateX=e+u-o.totalWidth/2/o.scale;o.translateY=i+c-o.totalHeight/2/o.scale;o.rotate(this.objects.length===1?t:h.rotation+s)}))}))}copy(){const t=il.create(this._core);this.objects.sort(((t,e)=>t.zIndex-e.zIndex)).forEach((e=>{const i=e.copy();t.addOrRemove(i)}));t.captureUnchangedSnapshots();if(this.objects.length===1){t.rotation=this.objects[0].rotation}return t}refreshObjectDimensions(){if(this.objects.length===1){const t=this.objects[0];this.minX=t.boundingBox.x/this.scale;this.maxX=t.boundingBox.x/this.scale+t.boundingBox.width;this.minY=t.boundingBox.y/this.scale;this.maxY=t.boundingBox.y/this.scale+t.boundingBox.height;this.translateX=(this.minX-this.padding)*this.scale;this.translateY=(this.minY-this.padding)*this.scale;this.width=(this.maxX-this.minX-this.padding)*this.scale;this.height=(this.maxY-this.minY-this.padding)*this.scale}else{const t=this.rotation;const e=Math.cos(-t);const i=Math.sin(-t);let s=Infinity;let n=-Infinity;let r=Infinity;let o=-Infinity;this.objects.forEach((t=>{const h=t.rotatedPolygon;const l=[h.topLeft,h.topRight,h.bottomRight,h.bottomLeft];l.forEach((t=>{const h=t.x*e-t.y*i;const l=t.x*i+t.y*e;if(h<s)s=h;if(h>n)n=h;if(l<r)r=l;if(l>o)o=l}))}));const h=n-s;const l=o-r;this.width=(h-this.padding)*this.scale;this.height=(l-this.padding)*this.scale;const f=(s+n)/2;const u=(r+o)/2;const c=Math.cos(t);const a=Math.sin(t);const d=f*c-u*a;const w=f*a+u*c;this.translateX=d-(this.width/this.scale+2*this.padding)/2;this.translateY=w-(this.height/this.scale+2*this.padding)/2}this._core.store.state.objects.update(this)}getOffsetXToCenterFromSnapshot(t){const e=t.translateX+t.totalWidth/t.scale/2;const i=this.translateX+this.totalWidth/this.scale/2;return e-i}getOffsetYToCenterFromSnapshot(t){const e=t.translateY+t.totalHeight/t.scale/2;const i=this.translateY+this.totalHeight/this.scale/2;return e-i}hitTest(t,e){const s=this.objects.length===1&&this.objects[0].__class__==="KritzelLine";if(s){return this.objects[0].hitTest(t,e)}const n=this.rotatedPolygon;const r=[n.topLeft,n.topRight,n.bottomRight,n.bottomLeft];if(i.isPointInPolygon({x:t,y:e},r)){return true}return this.objects.some((i=>i.hitTest(t,e)))}}class sl extends tl{color="#000000";size=4;palettes=["#000000","#FFFFFF","#FF0000","#00FF00","#0000FF","#FFFF00","#FF00FF","#00FFFF","#808080","#C0C0C0","#800000","#008000","#000080","#808000","#800080"];arrows;_startX=0;_startY=0;constructor(t){super(t)}handlePointerDown(t){if(t.cancelable){t.preventDefault()}if(t.pointerType==="mouse"){if(Zh.isLeftClick(t)){this._core.store.state.isDrawing=true;const e=t.clientX-this._core.store.offsetX;const i=t.clientY-this._core.store.offsetY;this._startX=e;this._startY=i;const s=qh.create(this._core,{startX:e,startY:i,endX:e,endY:i,translateX:-this._core.store.state.translateX,translateY:-this._core.store.state.translateY,scale:this._core.store.state.scale,stroke:this.color,strokeWidth:this.size,arrows:this.arrows});s.isCompleted=false;this._core.store.state.objects.insert(s)}}if(t.pointerType==="touch"){const t=Array.from(this._core.store.state.pointers.values());if(t.length===1){const e=Math.round(t[0].clientX-this._core.store.offsetX);const i=Math.round(t[0].clientY-this._core.store.offsetY);this._core.store.state.isDrawing=true;this._startX=e;this._startY=i;const s=qh.create(this._core,{startX:e,startY:i,endX:e,endY:i,translateX:-this._core.store.state.translateX,translateY:-this._core.store.state.translateY,scale:this._core.store.state.scale,stroke:this.color,strokeWidth:this.size,arrows:this.arrows});s.isCompleted=false;this._core.store.state.objects.insert(s)}}}handlePointerMove(t){if(t.cancelable){t.preventDefault()}if(t.pointerType==="mouse"){if(this._core.store.state.isDrawing){const e=this._core.store.currentLine;if(e){const i=t.clientX-this._core.store.offsetX;const s=t.clientY-this._core.store.offsetY;const n=qh.create(this._core,{startX:this._startX,startY:this._startY,endX:i,endY:s,translateX:-this._core.store.state.translateX,translateY:-this._core.store.state.translateY,scale:this._core.store.state.scale,stroke:this.color,strokeWidth:this.size,arrows:this.arrows});n.id=e.id;n.workspaceId=e.workspaceId;n.zIndex=e.zIndex;n.isCompleted=false;this._core.store.state.objects.update(n)}}}if(t.pointerType==="touch"){const t=Array.from(this._core.store.state.pointers.values());if(t.length===1){const e=this._core.store.currentLine;if(e){const i=Math.round(t[0].clientX-this._core.store.offsetX);const s=Math.round(t[0].clientY-this._core.store.offsetY);const n=qh.create(this._core,{startX:this._startX,startY:this._startY,endX:i,endY:s,translateX:-this._core.store.state.translateX,translateY:-this._core.store.state.translateY,scale:this._core.store.state.scale,stroke:this.color,strokeWidth:this.size,arrows:this.arrows});n.id=e.id;n.workspaceId=e.workspaceId;n.zIndex=e.zIndex;n.isCompleted=false;this._core.store.state.objects.update(n)}}}}handlePointerUp(t){if(t.cancelable){t.preventDefault()}if(t.pointerType==="mouse"){if(this._core.store.state.isDrawing){this._core.store.state.isDrawing=false;const t=this._core.store.currentLine;if(t){t.isCompleted=true;this._core.store.state.objects.update(t);this._core.engine.emitObjectsChange();this.selectLineAndSwitchTool(t)}}}if(t.pointerType==="touch"){if(this._core.store.state.isDrawing){this._core.store.state.isDrawing=false;const t=this._core.store.currentLine;if(t){t.isCompleted=true;this._core.store.state.objects.update(t);this._core.engine.emitObjectsChange();this.selectLineAndSwitchTool(t)}}}}selectLineAndSwitchTool(e){const i=il.create(this._core);i.addOrRemove(e);i.isSelected=true;i.rotation=e.rotation;this._core.addSelectionGroup(i);this._core.store.setState("activeTool",t.getTool("selection"));this._core.rerender()}}class nl extends tl{touchStartTimeout=null;constructor(t){super(t)}handlePointerDown(t){if(t.pointerType==="mouse"){if(Zh.isLeftClick(t)){this._core.store.state.isErasing=true}}if(t.pointerType==="touch"){this.touchStartTimeout=setTimeout((()=>{if(this._core.store.state.pointers.size===1&&!this._core.store.state.isScaling){this._core.store.state.isErasing=true}}),80)}}handlePointerMove(t){if(t.pointerType==="mouse"){if(this._core.store.state.isErasing){const e=this._core.getObjectsFromPointerEvent(t,".object");if(e.length===0)return;const i=this._core.store.state.pointerX;const s=this._core.store.state.pointerY;e.forEach((t=>{t.markedForRemoval=t.hitTest(i,s)}));this._core.rerender()}}if(t.pointerType==="touch"){if(this._core.store.state.pointers.size===1&&this._core.store.state.isErasing){const e=this._core.store.state.host?.shadowRoot;if(!e)return;const i=this._core.getObjectsFromPointerEvent(t,".object");if(i.length===0)return;const s=this._core.store.state.pointerX;const n=this._core.store.state.pointerY;i.forEach((t=>{t.markedForRemoval=t.hitTest(s,n)}));this._core.rerender()}}}handlePointerUp(t){if(t.pointerType==="mouse"){if(this._core.store.state.isErasing){const t=this._core.store.allObjects.filter((t=>t.markedForRemoval));t.forEach((t=>{t.markedForRemoval=false;this._core.removeObject(t)}));if(t.length>0){this._core.rerender()}this._core.store.state.isErasing=false;this._core.engine.emitObjectsChange()}}if(t.pointerType==="touch"){clearTimeout(this.touchStartTimeout);if(this._core.store.state.isErasing){const t=this._core.store.allObjects.filter((t=>t.markedForRemoval));t.forEach((t=>{t.markedForRemoval=false;this._core.removeObject(t)}));if(t.length>0){this._core.rerender()}this._core.store.state.isErasing=false;this._core.engine.emitObjectsChange()}}}}function rl(t,e){return e.forEach((function(e){e&&"string"!=typeof e&&!Array.isArray(e)&&Object.keys(e).forEach((function(i){if("default"!==i&&!(i in t)){var s=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,s.get?s:{enumerable:true,get:function(){return e[i]}})}}))})),Object.freeze(t)}function ol(t,e){return new Promise((function(i,s){let n;return hl(t).then((function(t){try{return n=t,i(new Blob([e.slice(0,2),n,e.slice(2)],{type:"image/jpeg"}))}catch(t){return s(t)}}),s)}))}const hl=t=>new Promise(((e,i)=>{const s=new FileReader;s.addEventListener("load",(({target:{result:t}})=>{const s=new DataView(t);let n=0;if(65496!==s.getUint16(n))return i("not a valid JPEG");for(n+=2;;){const r=s.getUint16(n);if(65498===r)break;const o=s.getUint16(n+2);if(65505===r&&1165519206===s.getUint32(n+4)){const r=n+10;let h;switch(s.getUint16(r)){case 18761:h=true;break;case 19789:h=false;break;default:return i("TIFF header contains invalid endian")}if(42!==s.getUint16(r+2,h))return i("TIFF header contains invalid version");const l=s.getUint32(r+4,h),f=r+l+2+12*s.getUint16(r+l,h);for(let t=r+l+2;t<f;t+=12){if(274==s.getUint16(t,h)){if(3!==s.getUint16(t+2,h))return i("Orientation data type is invalid");if(1!==s.getUint32(t+4,h))return i("Orientation data count is invalid");s.setUint16(t+8,1,h);break}}return e(t.slice(n,n+2+o))}n+=2+o}return e(new Blob)})),s.readAsArrayBuffer(t)}));var ll={},fl={get exports(){return ll},set exports(t){ll=t}};!function(t){var e,i,s={};fl.exports=s,s.parse=function(t,e){for(var i=s.bin.readUshort,n=s.bin.readUint,r=0,o={},h=new Uint8Array(t),l=h.length-4;101010256!=n(h,l);)l--;r=l;r+=4;var f=i(h,r+=4);i(h,r+=2);var u=n(h,r+=2),c=n(h,r+=4);r+=4,r=c;for(var a=0;a<f;a++){n(h,r),r+=4,r+=4,r+=4,n(h,r+=4);u=n(h,r+=4);var d=n(h,r+=4),w=i(h,r+=4),p=i(h,r+2),g=i(h,r+4);r+=6;var m=n(h,r+=8);r+=4,r+=w+p+g,s._readLocal(h,m,o,u,d,e)}return o},s._readLocal=function(t,e,i,n,r,o){var h=s.bin.readUshort,l=s.bin.readUint;l(t,e),h(t,e+=4),h(t,e+=2);var f=h(t,e+=2);l(t,e+=2),l(t,e+=4),e+=4;var u=h(t,e+=8),c=h(t,e+=2);e+=2;var a=s.bin.readUTF8(t,e,u);if(e+=u,e+=c,o)i[a]={size:r,csize:n};else{var d=new Uint8Array(t.buffer,e);if(0==f)i[a]=new Uint8Array(d.buffer.slice(e,e+n));else{if(8!=f)throw"unknown compression method: "+f;var w=new Uint8Array(r);s.inflateRaw(d,w),i[a]=w}}},s.inflateRaw=function(t,e){return s.F.inflate(t,e)},s.inflate=function(t,e){return s.inflateRaw(new Uint8Array(t.buffer,t.byteOffset+2,t.length-6),e)},s.deflate=function(t,e){null==e&&(e={level:6});var i=0,n=new Uint8Array(50+Math.floor(1.1*t.length));n[i]=120,n[i+1]=156,i+=2,i=s.F.deflateRaw(t,n,i,e.level);var r=s.adler(t,0,t.length);return n[i+0]=r>>>24&255,n[i+1]=r>>>16&255,n[i+2]=r>>>8&255,n[i+3]=r>>>0&255,new Uint8Array(n.buffer,0,i+4)},s.deflateRaw=function(t,e){null==e&&(e={level:6});var i=new Uint8Array(50+Math.floor(1.1*t.length)),n=s.F.deflateRaw(t,i,n,e.level);return new Uint8Array(i.buffer,0,n)},s.encode=function(t,e){null==e&&(e=false);var i=0,n=s.bin.writeUint,r=s.bin.writeUshort,o={};for(var h in t){var l=!s._noNeed(h)&&!e,f=t[h],u=s.crc.crc(f,0,f.length);o[h]={cpr:l,usize:f.length,crc:u,file:l?s.deflateRaw(f):f}}for(var h in o)i+=o[h].file.length+30+46+2*s.bin.sizeUTF8(h);i+=22;var c=new Uint8Array(i),a=0,d=[];for(var h in o){var w=o[h];d.push(a),a=s._writeHeader(c,a,h,w,0)}var p=0,g=a;for(var h in o){w=o[h];d.push(a),a=s._writeHeader(c,a,h,w,1,d[p++])}var m=a-g;return n(c,a,101010256),a+=4,r(c,a+=4,p),r(c,a+=2,p),n(c,a+=2,m),n(c,a+=4,g),a+=4,a+=2,c.buffer},s._noNeed=function(t){var e=t.split(".").pop().toLowerCase();return-1!="png,jpg,jpeg,zip".indexOf(e)},s._writeHeader=function(t,e,i,n,r,o){var h=s.bin.writeUint,l=s.bin.writeUshort,f=n.file;return h(t,e,0==r?67324752:33639248),e+=4,1==r&&(e+=2),l(t,e,20),l(t,e+=2,0),l(t,e+=2,n.cpr?8:0),h(t,e+=2,0),h(t,e+=4,n.crc),h(t,e+=4,f.length),h(t,e+=4,n.usize),l(t,e+=4,s.bin.sizeUTF8(i)),l(t,e+=2,0),e+=2,1==r&&(e+=2,e+=2,h(t,e+=6,o),e+=4),e+=s.bin.writeUTF8(t,e,i),0==r&&(t.set(f,e),e+=f.length),e},s.crc={table:function(){for(var t=new Uint32Array(256),e=0;e<256;e++){for(var i=e,s=0;s<8;s++)1&i?i=3988292384^i>>>1:i>>>=1;t[e]=i}return t}(),update:function(t,e,i,n){for(var r=0;r<n;r++)t=s.crc.table[255&(t^e[i+r])]^t>>>8;return t},crc:function(t,e,i){return 4294967295^s.crc.update(4294967295,t,e,i)}},s.adler=function(t,e,i){for(var s=1,n=0,r=e,o=e+i;r<o;){for(var h=Math.min(r+5552,o);r<h;)n+=s+=t[r++];s%=65521,n%=65521}return n<<16|s},s.bin={readUshort:function(t,e){return t[e]|t[e+1]<<8},writeUshort:function(t,e,i){t[e]=255&i,t[e+1]=i>>8&255},readUint:function(t,e){return 16777216*t[e+3]+(t[e+2]<<16|t[e+1]<<8|t[e])},writeUint:function(t,e,i){t[e]=255&i,t[e+1]=i>>8&255,t[e+2]=i>>16&255,t[e+3]=i>>24&255},readASCII:function(t,e,i){for(var s="",n=0;n<i;n++)s+=String.fromCharCode(t[e+n]);return s},writeASCII:function(t,e,i){for(var s=0;s<i.length;s++)t[e+s]=i.charCodeAt(s)},pad:function(t){return t.length<2?"0"+t:t},readUTF8:function(t,e,i){for(var n,r="",o=0;o<i;o++)r+="%"+s.bin.pad(t[e+o].toString(16));try{n=decodeURIComponent(r)}catch(n){return s.bin.readASCII(t,e,i)}return n},writeUTF8:function(t,e,i){for(var s=i.length,n=0,r=0;r<s;r++){var o=i.charCodeAt(r);if(0==(4294967168&o))t[e+n]=o,n++;else if(0==(4294965248&o))t[e+n]=192|o>>6,t[e+n+1]=128|o>>0&63,n+=2;else if(0==(4294901760&o))t[e+n]=224|o>>12,t[e+n+1]=128|o>>6&63,t[e+n+2]=128|o>>0&63,n+=3;else{if(0!=(4292870144&o))throw"e";t[e+n]=240|o>>18,t[e+n+1]=128|o>>12&63,t[e+n+2]=128|o>>6&63,t[e+n+3]=128|o>>0&63,n+=4}}return n},sizeUTF8:function(t){for(var e=t.length,i=0,s=0;s<e;s++){var n=t.charCodeAt(s);if(0==(4294967168&n))i++;else if(0==(4294965248&n))i+=2;else if(0==(4294901760&n))i+=3;else{if(0!=(4292870144&n))throw"e";i+=4}}return i}},s.F={},s.F.deflateRaw=function(t,e,i,n){var r=[[0,0,0,0,0],[4,4,8,4,0],[4,5,16,8,0],[4,6,16,16,0],[4,10,16,32,0],[8,16,32,32,0],[8,16,128,128,0],[8,32,128,256,0],[32,128,258,1024,1],[32,258,258,4096,1]][n],o=s.F.U,h=s.F._goodIndex;var l=s.F._putsE,f=0,u=i<<3,c=0,a=t.length;if(0==n){for(;f<a;){l(e,u,f+(x=Math.min(65535,a-f))==a?1:0),u=s.F._copyExact(t,f,x,e,u+8),f+=x}return u>>>3}var d=o.lits,w=o.strt,p=o.prev,g=0,m=0,y=0,v=0,b=0,M=0;for(a>2&&(w[M=s.F._hash(t,0)]=0),f=0;f<a;f++){if(b=M,f+1<a-2){M=s.F._hash(t,f+1);var k=f+1&32767;p[k]=w[M],w[M]=k}if(c<=f){(g>14e3||m>26697)&&a-f>100&&(c<f&&(d[g]=f-c,g+=2,c=f),u=s.F._writeBlock(f==a-1||c==a?1:0,d,g,v,t,y,f-y,e,u),g=m=v=0,y=f);var A=0;f<a-2&&(A=s.F._bestMatch(t,f,p,b,Math.min(r[2],a-f),r[3]));var x=A>>>16,S=65535&A;if(0!=A){S=65535&A;var C=h(x=A>>>16,o.of0);o.lhst[257+C]++;var O=h(S,o.df0);o.dhst[O]++,v+=o.exb[C]+o.dxb[O],d[g]=x<<23|f-c,d[g+1]=S<<16|C<<8|O,g+=2,c=f+x}else o.lhst[t[f]]++;m++}}for(y==f&&0!=t.length||(c<f&&(d[g]=f-c,g+=2,c=f),u=s.F._writeBlock(1,d,g,v,t,y,f-y,e,u),g=0,m=0,g=m=v=0,y=f);0!=(7&u);)u++;return u>>>3},s.F._bestMatch=function(t,e,i,n,r,o){var h=32767&e,l=i[h],f=h-l+32768&32767;if(l==h||n!=s.F._hash(t,e-f))return 0;for(var u=0,c=0,a=Math.min(32767,e);f<=a&&0!=--o&&l!=h;){if(0==u||t[e+u]==t[e+u-f]){var d=s.F._howLong(t,e,f);if(d>u){if(c=f,(u=d)>=r)break;f+2<d&&(d=f+2);for(var w=0,p=0;p<d-2;p++){var g=e-f+p+32768&32767,m=g-i[g]+32768&32767;m>w&&(w=m,l=g)}}}f+=(h=l)-(l=i[h])+32768&32767}return u<<16|c},s.F._howLong=function(t,e,i){if(t[e]!=t[e-i]||t[e+1]!=t[e+1-i]||t[e+2]!=t[e+2-i])return 0;var s=e,n=Math.min(t.length,e+258);for(e+=3;e<n&&t[e]==t[e-i];)e++;return e-s},s.F._hash=function(t,e){return(t[e]<<8|t[e+1])+(t[e+2]<<4)&65535},s.saved=0,s.F._writeBlock=function(t,e,i,n,r,o,h,l,f){var u,c,a,d,w,p,g,m,y,v=s.F.U,b=s.F._putsF,M=s.F._putsE;v.lhst[256]++,c=(u=s.F.getTrees())[0],a=u[1],d=u[2],w=u[3],p=u[4],g=u[5],m=u[6],y=u[7];var k=32+(0==(f+3&7)?0:8-(f+3&7))+(h<<3),A=n+s.F.contSize(v.fltree,v.lhst)+s.F.contSize(v.fdtree,v.dhst),x=n+s.F.contSize(v.ltree,v.lhst)+s.F.contSize(v.dtree,v.dhst);x+=14+3*g+s.F.contSize(v.itree,v.ihst)+(2*v.ihst[16]+3*v.ihst[17]+7*v.ihst[18]);for(var S=0;S<286;S++)v.lhst[S]=0;for(S=0;S<30;S++)v.dhst[S]=0;for(S=0;S<19;S++)v.ihst[S]=0;var C=k<A&&k<x?0:A<x?1:2;if(b(l,f,t),b(l,f+1,C),f+=3,0==C){for(;0!=(7&f);)f++;f=s.F._copyExact(r,o,h,l,f)}else{var O,E;if(1==C&&(O=v.fltree,E=v.fdtree),2==C){s.F.makeCodes(v.ltree,c),s.F.revCodes(v.ltree,c),s.F.makeCodes(v.dtree,a),s.F.revCodes(v.dtree,a),s.F.makeCodes(v.itree,d),s.F.revCodes(v.itree,d),O=v.ltree,E=v.dtree,M(l,f,w-257),M(l,f+=5,p-1),M(l,f+=5,g-4),f+=4;for(var T=0;T<g;T++)M(l,f+3*T,v.itree[1+(v.ordr[T]<<1)]);f+=3*g,f=s.F._codeTiny(m,v.itree,l,f),f=s.F._codeTiny(y,v.itree,l,f)}for(var D=o,I=0;I<i;I+=2){for(var P=e[I],R=P>>>23,$=D+(8388607&P);D<$;)f=s.F._writeLit(r[D++],O,l,f);if(0!=R){var U=e[I+1],j=U>>16,B=U>>8&255,F=255&U;M(l,f=s.F._writeLit(257+B,O,l,f),R-v.of0[B]),f+=v.exb[B],b(l,f=s.F._writeLit(F,E,l,f),j-v.df0[F]),f+=v.dxb[F],D+=R}}f=s.F._writeLit(256,O,l,f)}return f},s.F._copyExact=function(t,e,i,s,n){var r=n>>>3;return s[r]=i,s[r+1]=i>>>8,s[r+2]=255-s[r],s[r+3]=255-s[r+1],r+=4,s.set(new Uint8Array(t.buffer,e,i),r),n+(i+4<<3)},s.F.getTrees=function(){for(var t=s.F.U,e=s.F._hufTree(t.lhst,t.ltree,15),i=s.F._hufTree(t.dhst,t.dtree,15),n=[],r=s.F._lenCodes(t.ltree,n),o=[],h=s.F._lenCodes(t.dtree,o),l=0;l<n.length;l+=2)t.ihst[n[l]]++;for(l=0;l<o.length;l+=2)t.ihst[o[l]]++;for(var f=s.F._hufTree(t.ihst,t.itree,7),u=19;u>4&&0==t.itree[1+(t.ordr[u-1]<<1)];)u--;return[e,i,f,r,h,u,n,o]},s.F.getSecond=function(t){for(var e=[],i=0;i<t.length;i+=2)e.push(t[i+1]);return e},s.F.nonZero=function(t){for(var e="",i=0;i<t.length;i+=2)0!=t[i+1]&&(e+=(i>>1)+",");return e},s.F.contSize=function(t,e){for(var i=0,s=0;s<e.length;s++)i+=e[s]*t[1+(s<<1)];return i},s.F._codeTiny=function(t,e,i,n){for(var r=0;r<t.length;r+=2){var o=t[r],h=t[r+1];n=s.F._writeLit(o,e,i,n);var l=16==o?2:17==o?3:7;o>15&&(s.F._putsE(i,n,h,l),n+=l)}return n},s.F._lenCodes=function(t,e){for(var i=t.length;2!=i&&0==t[i-1];)i-=2;for(var s=0;s<i;s+=2){var n=t[s+1],r=s+3<i?t[s+3]:-1,o=s+5<i?t[s+5]:-1,h=0==s?-1:t[s-1];if(0==n&&r==n&&o==n){for(var l=s+5;l+2<i&&t[l+2]==n;)l+=2;(f=Math.min(l+1-s>>>1,138))<11?e.push(17,f-3):e.push(18,f-11),s+=2*f-2}else if(n==h&&r==n&&o==n){for(l=s+5;l+2<i&&t[l+2]==n;)l+=2;var f=Math.min(l+1-s>>>1,6);e.push(16,f-3),s+=2*f-2}else e.push(n,0)}return i>>>1},s.F._hufTree=function(t,e,i){var n=[],r=t.length,o=e.length,h=0;for(h=0;h<o;h+=2)e[h]=0,e[h+1]=0;for(h=0;h<r;h++)0!=t[h]&&n.push({lit:h,f:t[h]});var l=n.length,f=n.slice(0);if(0==l)return 0;if(1==l){var u=n[0].lit;f=0==u?1:0;return e[1+(u<<1)]=1,e[1+(f<<1)]=1,1}n.sort((function(t,e){return t.f-e.f}));var c=n[0],a=n[1],d=0,w=1,p=2;for(n[0]={lit:-1,f:c.f+a.f,l:c,r:a,d:0};w!=l-1;)c=d!=w&&(p==l||n[d].f<n[p].f)?n[d++]:n[p++],a=d!=w&&(p==l||n[d].f<n[p].f)?n[d++]:n[p++],n[w++]={lit:-1,f:c.f+a.f,l:c,r:a};var g=s.F.setDepth(n[w-1],0);for(g>i&&(s.F.restrictDepth(f,i,g),g=i),h=0;h<l;h++)e[1+(f[h].lit<<1)]=f[h].d;return g},s.F.setDepth=function(t,e){return-1!=t.lit?(t.d=e,e):Math.max(s.F.setDepth(t.l,e+1),s.F.setDepth(t.r,e+1))},s.F.restrictDepth=function(t,e,i){var s=0,n=1<<i-e,r=0;for(t.sort((function(t,e){return e.d==t.d?t.f-e.f:e.d-t.d})),s=0;s<t.length&&t[s].d>e;s++){var o=t[s].d;t[s].d=e,r+=n-(1<<i-o)}for(r>>>=i-e;r>0;){(o=t[s].d)<e?(t[s].d++,r-=1<<e-o-1):s++}for(;s>=0;s--)t[s].d==e&&r<0&&(t[s].d--,r++);0!=r&&console.log("debt left")},s.F._goodIndex=function(t,e){var i=0;return e[16|i]<=t&&(i|=16),e[8|i]<=t&&(i|=8),e[4|i]<=t&&(i|=4),e[2|i]<=t&&(i|=2),e[1|i]<=t&&(i|=1),i},s.F._writeLit=function(t,e,i,n){return s.F._putsF(i,n,e[t<<1]),n+e[1+(t<<1)]},s.F.inflate=function(t,e){var i=Uint8Array;if(3==t[0]&&0==t[1])return e||new i(0);var n=s.F,r=n._bitsF,o=n._bitsE,h=n._decodeTiny,l=n.makeCodes,f=n.codes2map,u=n._get17,c=n.U,a=null==e;a&&(e=new i(t.length>>>2<<3));for(var d,w,p=0,g=0,m=0,y=0,v=0,b=0,M=0,k=0,A=0;0==p;)if(p=r(t,A,1),g=r(t,A+1,2),A+=3,0!=g){if(a&&(e=s.F._check(e,k+(1<<17))),1==g&&(d=c.flmap,w=c.fdmap,b=511,M=31),2==g){m=o(t,A,5)+257,y=o(t,A+5,5)+1,v=o(t,A+10,4)+4,A+=14;for(var x=0;x<38;x+=2)c.itree[x]=0,c.itree[x+1]=0;var S=1;for(x=0;x<v;x++){var C=o(t,A+3*x,3);c.itree[1+(c.ordr[x]<<1)]=C,C>S&&(S=C)}A+=3*v,l(c.itree,S),f(c.itree,S,c.imap),d=c.lmap,w=c.dmap,A=h(c.imap,(1<<S)-1,m+y,t,A,c.ttree);var O=n._copyOut(c.ttree,0,m,c.ltree);b=(1<<O)-1;var E=n._copyOut(c.ttree,m,y,c.dtree);M=(1<<E)-1,l(c.ltree,O),f(c.ltree,O,d),l(c.dtree,E),f(c.dtree,E,w)}for(;;){var T=d[u(t,A)&b];A+=15&T;var D=T>>>4;if(D>>>8==0)e[k++]=D;else{if(256==D)break;var I=k+D-254;if(D>264){var P=c.ldef[D-257];I=k+(P>>>3)+o(t,A,7&P),A+=7&P}var R=w[u(t,A)&M];A+=15&R;var $=R>>>4,U=c.ddef[$],j=(U>>>4)+r(t,A,15&U);for(A+=15&U,a&&(e=s.F._check(e,k+(1<<17)));k<I;)e[k]=e[k++-j],e[k]=e[k++-j],e[k]=e[k++-j],e[k]=e[k++-j];k=I}}}else{0!=(7&A)&&(A+=8-(7&A));var B=4+(A>>>3),F=t[B-4]|t[B-3]<<8;a&&(e=s.F._check(e,k+F)),e.set(new i(t.buffer,t.byteOffset+B,F),k),A=B+F<<3,k+=F}return e.length==k?e:e.slice(0,k)},s.F._check=function(t,e){var i=t.length;if(e<=i)return t;var s=new Uint8Array(Math.max(i<<1,e));return s.set(t,0),s},s.F._decodeTiny=function(t,e,i,n,r,o){for(var h=s.F._bitsE,l=s.F._get17,f=0;f<i;){var u=t[l(n,r)&e];r+=15&u;var c=u>>>4;if(c<=15)o[f]=c,f++;else{var a=0,d=0;16==c?(d=3+h(n,r,2),r+=2,a=o[f-1]):17==c?(d=3+h(n,r,3),r+=3):18==c&&(d=11+h(n,r,7),r+=7);for(var w=f+d;f<w;)o[f]=a,f++}}return r},s.F._copyOut=function(t,e,i,s){for(var n=0,r=0,o=s.length>>>1;r<i;){var h=t[r+e];s[r<<1]=0,s[1+(r<<1)]=h,h>n&&(n=h),r++}for(;r<o;)s[r<<1]=0,s[1+(r<<1)]=0,r++;return n},s.F.makeCodes=function(t,e){for(var i,n,r,o,h=s.F.U,l=t.length,f=h.bl_count,u=0;u<=e;u++)f[u]=0;for(u=1;u<l;u+=2)f[t[u]]++;var c=h.next_code;for(i=0,f[0]=0,n=1;n<=e;n++)i=i+f[n-1]<<1,c[n]=i;for(r=0;r<l;r+=2)0!=(o=t[r+1])&&(t[r]=c[o],c[o]++)},s.F.codes2map=function(t,e,i){for(var n=t.length,r=s.F.U.rev15,o=0;o<n;o+=2)if(0!=t[o+1])for(var h=o>>1,l=t[o+1],f=h<<4|l,u=e-l,c=t[o]<<u,a=c+(1<<u);c!=a;){i[r[c]>>>15-e]=f,c++}},s.F.revCodes=function(t,e){for(var i=s.F.U.rev15,n=15-e,r=0;r<t.length;r+=2){var o=t[r]<<e-t[r+1];t[r]=i[o]>>>n}},s.F._putsE=function(t,e,i){i<<=7&e;var s=e>>>3;t[s]|=i,t[s+1]|=i>>>8},s.F._putsF=function(t,e,i){i<<=7&e;var s=e>>>3;t[s]|=i,t[s+1]|=i>>>8,t[s+2]|=i>>>16},s.F._bitsE=function(t,e,i){return(t[e>>>3]|t[1+(e>>>3)]<<8)>>>(7&e)&(1<<i)-1},s.F._bitsF=function(t,e,i){return(t[e>>>3]|t[1+(e>>>3)]<<8|t[2+(e>>>3)]<<16)>>>(7&e)&(1<<i)-1},s.F._get17=function(t,e){return(t[e>>>3]|t[1+(e>>>3)]<<8|t[2+(e>>>3)]<<16)>>>(7&e)},s.F._get25=function(t,e){return(t[e>>>3]|t[1+(e>>>3)]<<8|t[2+(e>>>3)]<<16|t[3+(e>>>3)]<<24)>>>(7&e)},s.F.U=(e=Uint16Array,i=Uint32Array,{next_code:new e(16),bl_count:new e(16),ordr:[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],of0:[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,999,999,999],exb:[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0],ldef:new e(32),df0:[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,65535,65535],dxb:[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0],ddef:new i(32),flmap:new e(512),fltree:[],fdmap:new e(32),fdtree:[],lmap:new e(32768),ltree:[],ttree:[],dmap:new e(32768),dtree:[],imap:new e(512),itree:[],rev15:new e(32768),lhst:new i(286),dhst:new i(30),ihst:new i(19),lits:new i(15e3),strt:new e(65536),prev:new e(32768)}),function(){for(var t=s.F.U,e=0;e<32768;e++){var i=e;i=(4278255360&(i=(4042322160&(i=(3435973836&(i=(2863311530&i)>>>1|(1431655765&i)<<1))>>>2|(858993459&i)<<2))>>>4|(252645135&i)<<4))>>>8|(16711935&i)<<8,t.rev15[e]=(i>>>16|i<<16)>>>17}function n(t,e,i){for(;0!=e--;)t.push(0,i)}for(e=0;e<32;e++)t.ldef[e]=t.of0[e]<<3|t.exb[e],t.ddef[e]=t.df0[e]<<4|t.dxb[e];n(t.fltree,144,8),n(t.fltree,112,9),n(t.fltree,24,7),n(t.fltree,8,8),s.F.makeCodes(t.fltree,9),s.F.codes2map(t.fltree,9,t.flmap),s.F.revCodes(t.fltree,9),n(t.fdtree,32,5),s.F.makeCodes(t.fdtree,5),s.F.codes2map(t.fdtree,5,t.fdmap),s.F.revCodes(t.fdtree,5),n(t.itree,19,0),n(t.ltree,286,0),n(t.dtree,30,0),n(t.ttree,320,0)}()}();var ul=rl({__proto__:null,default:ll},[ll]);const cl=function(){var t={nextZero(t,e){for(;0!=t[e];)e++;return e},readUshort:(t,e)=>t[e]<<8|t[e+1],writeUshort(t,e,i){t[e]=i>>8&255,t[e+1]=255&i},readUint:(t,e)=>16777216*t[e]+(t[e+1]<<16|t[e+2]<<8|t[e+3]),writeUint(t,e,i){t[e]=i>>24&255,t[e+1]=i>>16&255,t[e+2]=i>>8&255,t[e+3]=255&i},readASCII(t,e,i){let s="";for(let n=0;n<i;n++)s+=String.fromCharCode(t[e+n]);return s},writeASCII(t,e,i){for(let s=0;s<i.length;s++)t[e+s]=i.charCodeAt(s)},readBytes(t,e,i){const s=[];for(let n=0;n<i;n++)s.push(t[e+n]);return s},pad:t=>t.length<2?`0${t}`:t,readUTF8(e,i,s){let n,r="";for(let n=0;n<s;n++)r+=`%${t.pad(e[i+n].toString(16))}`;try{n=decodeURIComponent(r)}catch(n){return t.readASCII(e,i,s)}return n}};function e(e,i,s,n){const o=i*s,h=r(n),l=Math.ceil(i*h/8),f=new Uint8Array(4*o),u=new Uint32Array(f.buffer),{ctype:c}=n,{depth:a}=n,d=t.readUshort;if(6==c){const t=o<<2;if(8==a)for(var w=0;w<t;w+=4)f[w]=e[w],f[w+1]=e[w+1],f[w+2]=e[w+2],f[w+3]=e[w+3];if(16==a)for(w=0;w<t;w++)f[w]=e[w<<1]}else if(2==c){const t=n.tabs.tRNS;if(null==t){if(8==a)for(w=0;w<o;w++){var p=3*w;u[w]=255<<24|e[p+2]<<16|e[p+1]<<8|e[p]}if(16==a)for(w=0;w<o;w++){p=6*w;u[w]=255<<24|e[p+4]<<16|e[p+2]<<8|e[p]}}else{var g=t[0];const i=t[1],s=t[2];if(8==a)for(w=0;w<o;w++){var m=w<<2;p=3*w;u[w]=255<<24|e[p+2]<<16|e[p+1]<<8|e[p],e[p]==g&&e[p+1]==i&&e[p+2]==s&&(f[m+3]=0)}if(16==a)for(w=0;w<o;w++){m=w<<2,p=6*w;u[w]=255<<24|e[p+4]<<16|e[p+2]<<8|e[p],d(e,p)==g&&d(e,p+2)==i&&d(e,p+4)==s&&(f[m+3]=0)}}}else if(3==c){const t=n.tabs.PLTE,r=n.tabs.tRNS,h=r?r.length:0;if(1==a)for(var y=0;y<s;y++){var v=y*l,b=y*i;for(w=0;w<i;w++){m=b+w<<2;var M=3*(k=e[v+(w>>3)]>>7-((7&w)<<0)&1);f[m]=t[M],f[m+1]=t[M+1],f[m+2]=t[M+2],f[m+3]=k<h?r[k]:255}}if(2==a)for(y=0;y<s;y++)for(v=y*l,b=y*i,w=0;w<i;w++){m=b+w<<2,M=3*(k=e[v+(w>>2)]>>6-((3&w)<<1)&3);f[m]=t[M],f[m+1]=t[M+1],f[m+2]=t[M+2],f[m+3]=k<h?r[k]:255}if(4==a)for(y=0;y<s;y++)for(v=y*l,b=y*i,w=0;w<i;w++){m=b+w<<2,M=3*(k=e[v+(w>>1)]>>4-((1&w)<<2)&15);f[m]=t[M],f[m+1]=t[M+1],f[m+2]=t[M+2],f[m+3]=k<h?r[k]:255}if(8==a)for(w=0;w<o;w++){var k;m=w<<2,M=3*(k=e[w]);f[m]=t[M],f[m+1]=t[M+1],f[m+2]=t[M+2],f[m+3]=k<h?r[k]:255}}else if(4==c){if(8==a)for(w=0;w<o;w++){m=w<<2;var A=e[x=w<<1];f[m]=A,f[m+1]=A,f[m+2]=A,f[m+3]=e[x+1]}if(16==a)for(w=0;w<o;w++){var x;m=w<<2,A=e[x=w<<2];f[m]=A,f[m+1]=A,f[m+2]=A,f[m+3]=e[x+2]}}else if(0==c)for(g=n.tabs.tRNS?n.tabs.tRNS:-1,y=0;y<s;y++){const t=y*l,s=y*i;if(1==a)for(var S=0;S<i;S++){var C=(A=255*(e[t+(S>>>3)]>>>7-(7&S)&1))==255*g?0:255;u[s+S]=C<<24|A<<16|A<<8|A}else if(2==a)for(S=0;S<i;S++){C=(A=85*(e[t+(S>>>2)]>>>6-((3&S)<<1)&3))==85*g?0:255;u[s+S]=C<<24|A<<16|A<<8|A}else if(4==a)for(S=0;S<i;S++){C=(A=17*(e[t+(S>>>1)]>>>4-((1&S)<<2)&15))==17*g?0:255;u[s+S]=C<<24|A<<16|A<<8|A}else if(8==a)for(S=0;S<i;S++){C=(A=e[t+S])==g?0:255;u[s+S]=C<<24|A<<16|A<<8|A}else if(16==a)for(S=0;S<i;S++){A=e[t+(S<<1)],C=d(e,t+(S<<1))==g?0:255;u[s+S]=C<<24|A<<16|A<<8|A}}return f}function i(t,e,i,h){const l=r(t),f=Math.ceil(i*l/8),u=new Uint8Array((f+1+t.interlace)*h);return e=t.tabs.CgBI?n(e,u):s(e,u),0==t.interlace?e=o(e,t,0,i,h):1==t.interlace&&(e=function t(e,i){const s=i.width,n=i.height,h=r(i),l=h>>3,f=Math.ceil(s*h/8),u=new Uint8Array(n*f);let c=0;const a=[0,0,4,0,2,0,1],d=[0,4,0,2,0,1,0],w=[8,8,8,4,4,2,2],p=[8,8,4,4,2,2,1];let g=0;for(;g<7;){const t=w[g],r=p[g];let y=0,v=0,b=a[g];for(;b<n;)b+=t,v++;let M=d[g];for(;M<s;)M+=r,y++;const k=Math.ceil(y*h/8);o(e,i,c,y,v);let A=0,x=a[g];for(;x<n;){let i=d[g],n=c+A*k<<3;for(;i<s;){var m;if(1==h)m=(m=e[n>>3])>>7-(7&n)&1,u[x*f+(i>>3)]|=m<<7-((7&i)<<0);if(2==h)m=(m=e[n>>3])>>6-(7&n)&3,u[x*f+(i>>2)]|=m<<6-((3&i)<<1);if(4==h)m=(m=e[n>>3])>>4-(7&n)&15,u[x*f+(i>>1)]|=m<<4-((1&i)<<2);if(h>=8){const t=x*f+i*l;for(let i=0;i<l;i++)u[t+i]=e[(n>>3)+i]}n+=h,i+=r}A++,x+=t}y*v!=0&&(c+=v*(1+k)),g+=1}return u}(e,t)),e}function s(t,e){return n(new Uint8Array(t.buffer,2,t.length-6),e)}var n=function(){const t={H:{}};return t.H.N=function(e,i){const s=Uint8Array;let n,r,o=0,h=0,l=0,f=0,u=0,c=0,a=0,d=0,w=0;if(3==e[0]&&0==e[1])return i||new s(0);const p=t.H,g=p.b,m=p.e,y=p.R,v=p.n,b=p.A,M=p.Z,k=p.m,A=null==i;for(A&&(i=new s(e.length>>>2<<5));0==o;)if(o=g(e,w,1),h=g(e,w+1,2),w+=3,0!=h){if(A&&(i=t.H.W(i,d+(1<<17))),1==h&&(n=k.J,r=k.h,c=511,a=31),2==h){l=m(e,w,5)+257,f=m(e,w+5,5)+1,u=m(e,w+10,4)+4,w+=14;let t=1;for(var x=0;x<38;x+=2)k.Q[x]=0,k.Q[x+1]=0;for(x=0;x<u;x++){const i=m(e,w+3*x,3);k.Q[1+(k.X[x]<<1)]=i,i>t&&(t=i)}w+=3*u,v(k.Q,t),b(k.Q,t,k.u),n=k.w,r=k.d,w=y(k.u,(1<<t)-1,l+f,e,w,k.v);const i=p.V(k.v,0,l,k.C);c=(1<<i)-1;const s=p.V(k.v,l,f,k.D);a=(1<<s)-1,v(k.C,i),b(k.C,i,n),v(k.D,s),b(k.D,s,r)}for(;;){const t=n[M(e,w)&c];w+=15&t;const s=t>>>4;if(s>>>8==0)i[d++]=s;else{if(256==s)break;{let t=d+s-254;if(s>264){const i=k.q[s-257];t=d+(i>>>3)+m(e,w,7&i),w+=7&i}const n=r[M(e,w)&a];w+=15&n;const o=n>>>4,h=k.c[o],l=(h>>>4)+g(e,w,15&h);for(w+=15&h;d<t;)i[d]=i[d++-l],i[d]=i[d++-l],i[d]=i[d++-l],i[d]=i[d++-l];d=t}}}}else{0!=(7&w)&&(w+=8-(7&w));const n=4+(w>>>3),r=e[n-4]|e[n-3]<<8;A&&(i=t.H.W(i,d+r)),i.set(new s(e.buffer,e.byteOffset+n,r),d),w=n+r<<3,d+=r}return i.length==d?i:i.slice(0,d)},t.H.W=function(t,e){const i=t.length;if(e<=i)return t;const s=new Uint8Array(i<<1);return s.set(t,0),s},t.H.R=function(e,i,s,n,r,o){const h=t.H.e,l=t.H.Z;let f=0;for(;f<s;){const t=e[l(n,r)&i];r+=15&t;const s=t>>>4;if(s<=15)o[f]=s,f++;else{let t=0,e=0;16==s?(e=3+h(n,r,2),r+=2,t=o[f-1]):17==s?(e=3+h(n,r,3),r+=3):18==s&&(e=11+h(n,r,7),r+=7);const i=f+e;for(;f<i;)o[f]=t,f++}}return r},t.H.V=function(t,e,i,s){let n=0,r=0;const o=s.length>>>1;for(;r<i;){const i=t[r+e];s[r<<1]=0,s[1+(r<<1)]=i,i>n&&(n=i),r++}for(;r<o;)s[r<<1]=0,s[1+(r<<1)]=0,r++;return n},t.H.n=function(e,i){const s=t.H.m,n=e.length;let r,o,h;let l;const f=s.j;for(var u=0;u<=i;u++)f[u]=0;for(u=1;u<n;u+=2)f[e[u]]++;const c=s.K;for(r=0,f[0]=0,o=1;o<=i;o++)r=r+f[o-1]<<1,c[o]=r;for(h=0;h<n;h+=2)l=e[h+1],0!=l&&(e[h]=c[l],c[l]++)},t.H.A=function(e,i,s){const n=e.length,r=t.H.m.r;for(let t=0;t<n;t+=2)if(0!=e[t+1]){const n=t>>1,o=e[t+1],h=n<<4|o,l=i-o;let f=e[t]<<l;const u=f+(1<<l);for(;f!=u;){s[r[f]>>>15-i]=h,f++}}},t.H.l=function(e,i){const s=t.H.m.r,n=15-i;for(let t=0;t<e.length;t+=2){const r=e[t]<<i-e[t+1];e[t]=s[r]>>>n}},t.H.M=function(t,e,i){i<<=7&e;const s=e>>>3;t[s]|=i,t[s+1]|=i>>>8},t.H.I=function(t,e,i){i<<=7&e;const s=e>>>3;t[s]|=i,t[s+1]|=i>>>8,t[s+2]|=i>>>16},t.H.e=function(t,e,i){return(t[e>>>3]|t[1+(e>>>3)]<<8)>>>(7&e)&(1<<i)-1},t.H.b=function(t,e,i){return(t[e>>>3]|t[1+(e>>>3)]<<8|t[2+(e>>>3)]<<16)>>>(7&e)&(1<<i)-1},t.H.Z=function(t,e){return(t[e>>>3]|t[1+(e>>>3)]<<8|t[2+(e>>>3)]<<16)>>>(7&e)},t.H.i=function(t,e){return(t[e>>>3]|t[1+(e>>>3)]<<8|t[2+(e>>>3)]<<16|t[3+(e>>>3)]<<24)>>>(7&e)},t.H.m=function(){const t=Uint16Array,e=Uint32Array;return{K:new t(16),j:new t(16),X:[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],S:[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,999,999,999],T:[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0],q:new t(32),p:[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,65535,65535],z:[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0],c:new e(32),J:new t(512),_:[],h:new t(32),$:[],w:new t(32768),C:[],v:[],d:new t(32768),D:[],u:new t(512),Q:[],r:new t(32768),s:new e(286),Y:new e(30),a:new e(19),t:new e(15e3),k:new t(65536),g:new t(32768)}}(),function(){const e=t.H.m;for(var i=0;i<32768;i++){let t=i;t=(2863311530&t)>>>1|(1431655765&t)<<1,t=(3435973836&t)>>>2|(858993459&t)<<2,t=(4042322160&t)>>>4|(252645135&t)<<4,t=(4278255360&t)>>>8|(16711935&t)<<8,e.r[i]=(t>>>16|t<<16)>>>17}function s(t,e,i){for(;0!=e--;)t.push(0,i)}for(i=0;i<32;i++)e.q[i]=e.S[i]<<3|e.T[i],e.c[i]=e.p[i]<<4|e.z[i];s(e._,144,8),s(e._,112,9),s(e._,24,7),s(e._,8,8),t.H.n(e._,9),t.H.A(e._,9,e.J),t.H.l(e._,9),s(e.$,32,5),t.H.n(e.$,5),t.H.A(e.$,5,e.h),t.H.l(e.$,5),s(e.Q,19,0),s(e.C,286,0),s(e.D,30,0),s(e.v,320,0)}(),t.H.N}();function r(t){return[1,null,3,1,2,null,4][t.ctype]*t.depth}function o(t,e,i,s,n){let o=r(e);const l=Math.ceil(s*o/8);let f,u;o=Math.ceil(o/8);let c=t[i],a=0;if(c>1&&(t[i]=[0,0,1][c-2]),3==c)for(a=o;a<l;a++)t[a+1]=t[a+1]+(t[a+1-o]>>>1)&255;for(let e=0;e<n;e++)if(f=i+e*l,u=f+e+1,c=t[u-1],a=0,0==c)for(;a<l;a++)t[f+a]=t[u+a];else if(1==c){for(;a<o;a++)t[f+a]=t[u+a];for(;a<l;a++)t[f+a]=t[u+a]+t[f+a-o]}else if(2==c)for(;a<l;a++)t[f+a]=t[u+a]+t[f+a-l];else if(3==c){for(;a<o;a++)t[f+a]=t[u+a]+(t[f+a-l]>>>1);for(;a<l;a++)t[f+a]=t[u+a]+(t[f+a-l]+t[f+a-o]>>>1)}else{for(;a<o;a++)t[f+a]=t[u+a]+h(0,t[f+a-l],0);for(;a<l;a++)t[f+a]=t[u+a]+h(t[f+a-o],t[f+a-l],t[f+a-o-l])}return t}function h(t,e,i){const s=t+e-i,n=s-t,r=s-e,o=s-i;return n*n<=r*r&&n*n<=o*o?t:r*r<=o*o?e:i}function l(e,i,s){s.width=t.readUint(e,i),i+=4,s.height=t.readUint(e,i),i+=4,s.depth=e[i],i++,s.ctype=e[i],i++,s.compress=e[i],i++,s.filter=e[i],i++,s.interlace=e[i],i++}function f(t,e,i,s,n,r,o,h,l){const f=Math.min(e,n),u=Math.min(i,r);let c=0,a=0;for(let i=0;i<u;i++)for(let r=0;r<f;r++)if(o>=0&&h>=0?(c=i*e+r<<2,a=(h+i)*n+o+r<<2):(c=(-h+i)*e-o+r<<2,a=i*n+r<<2),0==l)s[a]=t[c],s[a+1]=t[c+1],s[a+2]=t[c+2],s[a+3]=t[c+3];else if(1==l){var d=t[c+3]*(1/255),w=t[c]*d,p=t[c+1]*d,g=t[c+2]*d,m=s[a+3]*(1/255),y=s[a]*m,v=s[a+1]*m,b=s[a+2]*m;const e=1-d,i=d+m*e,n=0==i?0:1/i;s[a+3]=255*i,s[a+0]=(w+y*e)*n,s[a+1]=(p+v*e)*n,s[a+2]=(g+b*e)*n}else if(2==l){d=t[c+3],w=t[c],p=t[c+1],g=t[c+2],m=s[a+3],y=s[a],v=s[a+1],b=s[a+2];d==m&&w==y&&p==v&&g==b?(s[a]=0,s[a+1]=0,s[a+2]=0,s[a+3]=0):(s[a]=w,s[a+1]=p,s[a+2]=g,s[a+3]=d)}else if(3==l){d=t[c+3],w=t[c],p=t[c+1],g=t[c+2],m=s[a+3],y=s[a],v=s[a+1],b=s[a+2];if(d==m&&w==y&&p==v&&g==b)continue;if(d<220&&m>20)return false}return true}return{decode:function e(r){const o=new Uint8Array(r);let h=8;const f=t,u=f.readUshort,c=f.readUint,a={tabs:{},frames:[]},d=new Uint8Array(o.length);let w,p=0,g=0;const m=[137,80,78,71,13,10,26,10];for(var y=0;y<8;y++)if(o[y]!=m[y])throw"The input is not a PNG file!";for(;h<o.length;){const t=f.readUint(o,h);h+=4;const e=f.readASCII(o,h,4);if(h+=4,"IHDR"==e)l(o,h,a);else if("iCCP"==e){for(var v=h;0!=o[v];)v++;f.readASCII(o,h,v-h);const i=o.slice(v+2,h+t);let r=null;try{r=s(i)}catch(t){r=n(i)}a.tabs[e]=r}else if("CgBI"==e)a.tabs[e]=o.slice(h,h+4);else if("IDAT"==e){for(y=0;y<t;y++)d[p+y]=o[h+y];p+=t}else if("acTL"==e)a.tabs[e]={num_frames:c(o,h),num_plays:c(o,h+4)},w=new Uint8Array(o.length);else if("fcTL"==e){if(0!=g)(S=a.frames[a.frames.length-1]).data=i(a,w.slice(0,g),S.rect.width,S.rect.height),g=0;const t={x:c(o,h+12),y:c(o,h+16),width:c(o,h+4),height:c(o,h+8)};let e=u(o,h+22);e=u(o,h+20)/(0==e?100:e);const s={rect:t,delay:Math.round(1e3*e),dispose:o[h+24],blend:o[h+25]};a.frames.push(s)}else if("fdAT"==e){for(y=0;y<t-4;y++)w[g+y]=o[h+y+4];g+=t-4}else if("pHYs"==e)a.tabs[e]=[f.readUint(o,h),f.readUint(o,h+4),o[h+8]];else if("cHRM"==e){a.tabs[e]=[];for(y=0;y<8;y++)a.tabs[e].push(f.readUint(o,h+4*y))}else if("tEXt"==e||"zTXt"==e){null==a.tabs[e]&&(a.tabs[e]={});var b=f.nextZero(o,h),M=f.readASCII(o,h,b-h),k=h+t-b-1;if("tEXt"==e)x=f.readASCII(o,b+1,k);else{var A=s(o.slice(b+2,b+2+k));x=f.readUTF8(A,0,A.length)}a.tabs[e][M]=x}else if("iTXt"==e){null==a.tabs[e]&&(a.tabs[e]={});b=0,v=h;b=f.nextZero(o,v);M=f.readASCII(o,v,b-v);const i=o[v=b+1];var x;v+=2,b=f.nextZero(o,v),f.readASCII(o,v,b-v),v=b+1,b=f.nextZero(o,v),f.readUTF8(o,v,b-v);k=t-((v=b+1)-h);if(0==i)x=f.readUTF8(o,v,k);else{A=s(o.slice(v,v+k));x=f.readUTF8(A,0,A.length)}a.tabs[e][M]=x}else if("PLTE"==e)a.tabs[e]=f.readBytes(o,h,t);else if("hIST"==e){const t=a.tabs.PLTE.length/3;a.tabs[e]=[];for(y=0;y<t;y++)a.tabs[e].push(u(o,h+2*y))}else if("tRNS"==e)3==a.ctype?a.tabs[e]=f.readBytes(o,h,t):0==a.ctype?a.tabs[e]=u(o,h):2==a.ctype&&(a.tabs[e]=[u(o,h),u(o,h+2),u(o,h+4)]);else if("gAMA"==e)a.tabs[e]=f.readUint(o,h)/1e5;else if("sRGB"==e)a.tabs[e]=o[h];else if("bKGD"==e)0==a.ctype||4==a.ctype?a.tabs[e]=[u(o,h)]:2==a.ctype||6==a.ctype?a.tabs[e]=[u(o,h),u(o,h+2),u(o,h+4)]:3==a.ctype&&(a.tabs[e]=o[h]);else if("IEND"==e)break;h+=t,f.readUint(o,h),h+=4}var S;return 0!=g&&((S=a.frames[a.frames.length-1]).data=i(a,w.slice(0,g),S.rect.width,S.rect.height)),a.data=i(a,d,a.width,a.height),delete a.compress,delete a.interlace,delete a.filter,a},toRGBA8:function t(i){const s=i.width,n=i.height;if(null==i.tabs.acTL)return[e(i.data,s,n,i).buffer];const r=[];null==i.frames[0].data&&(i.frames[0].data=i.data);const o=s*n*4,h=new Uint8Array(o),l=new Uint8Array(o),u=new Uint8Array(o);for(let t=0;t<i.frames.length;t++){const a=i.frames[t],d=a.rect.x,w=a.rect.y,p=a.rect.width,g=a.rect.height,m=e(a.data,p,g,i);if(0!=t)for(var c=0;c<o;c++)u[c]=h[c];if(0==a.blend?f(m,p,g,h,s,n,d,w,0):1==a.blend&&f(m,p,g,h,s,n,d,w,1),r.push(h.buffer.slice(0)),0==a.dispose);else if(1==a.dispose)f(l,p,g,h,s,n,d,w,0);else if(2==a.dispose)for(c=0;c<o;c++)h[c]=u[c]}return r},_paeth:h,_copyTile:f,_bin:t}}();!function(){const{_copyTile:t}=cl,{_bin:e}=cl,i=cl._paeth;var s={table:function(){const t=new Uint32Array(256);for(let e=0;e<256;e++){let i=e;for(let t=0;t<8;t++)1&i?i=3988292384^i>>>1:i>>>=1;t[e]=i}return t}(),update(t,e,i,n){for(let r=0;r<n;r++)t=s.table[255&(t^e[i+r])]^t>>>8;return t},crc:(t,e,i)=>4294967295^s.update(4294967295,t,e,i)};function n(t,e,i,s){e[i]+=t[0]*s>>4,e[i+1]+=t[1]*s>>4,e[i+2]+=t[2]*s>>4,e[i+3]+=t[3]*s>>4}function r(t){return Math.max(0,Math.min(255,t))}function o(t,e){const i=t[0]-e[0],s=t[1]-e[1],n=t[2]-e[2],r=t[3]-e[3];return i*i+s*s+n*n+r*r}function h(t,e,i,s,h,l,f){null==f&&(f=1);const u=s.length,c=[];for(var a=0;a<u;a++){const t=s[a];c.push([t>>>0&255,t>>>8&255,t>>>16&255,t>>>24&255])}for(a=0;a<u;a++){let t=4294967295;for(var d=0,w=0;w<u;w++){var p=o(c[a],c[w]);w!=a&&p<t&&(t=p,d=w)}}const g=new Uint32Array(h.buffer),m=new Int16Array(e*i*4),y=[0,8,2,10,12,4,14,6,3,11,1,9,15,7,13,5];for(a=0;a<y.length;a++)y[a]=255*((y[a]+.5)/16-.5);for(let h=0;h<i;h++)for(let b=0;b<e;b++){var v;a=4*(h*e+b);if(2!=f)v=[r(t[a]+m[a]),r(t[a+1]+m[a+1]),r(t[a+2]+m[a+2]),r(t[a+3]+m[a+3])];else{p=y[4*(3&h)+(3&b)];v=[r(t[a]+p),r(t[a+1]+p),r(t[a+2]+p),r(t[a+3]+p)]}d=0;let M=16777215;for(w=0;w<u;w++){const t=o(v,c[w]);t<M&&(M=t,d=w)}const k=c[d],A=[v[0]-k[0],v[1]-k[1],v[2]-k[2],v[3]-k[3]];1==f&&(b!=e-1&&n(A,m,a+4,7),h!=i-1&&(0!=b&&n(A,m,a+4*e-4,3),n(A,m,a+4*e,5),b!=e-1&&n(A,m,a+4*e+4,1))),l[a>>2]=d,g[a>>2]=s[d]}}function l(t,i,n,r,o){null==o&&(o={});const{crc:h}=s,l=e.writeUint,f=e.writeUshort,u=e.writeASCII;let c=8;const a=t.frames.length>1;let d,w=false,p=33+(a?20:0);if(null!=o.sRGB&&(p+=13),null!=o.pHYs&&(p+=21),null!=o.iCCP&&(d=pako.deflate(o.iCCP),p+=21+d.length+4),3==t.ctype){for(var g=t.plte.length,m=0;m<g;m++)t.plte[m]>>>24!=255&&(w=true);p+=8+3*g+4+(w?8+1*g+4:0)}for(var y=0;y<t.frames.length;y++){a&&(p+=38),p+=(k=t.frames[y]).cimg.length+12,0!=y&&(p+=4)}p+=12;const v=new Uint8Array(p),b=[137,80,78,71,13,10,26,10];for(m=0;m<8;m++)v[m]=b[m];if(l(v,c,13),c+=4,u(v,c,"IHDR"),c+=4,l(v,c,i),c+=4,l(v,c,n),c+=4,v[c]=t.depth,c++,v[c]=t.ctype,c++,v[c]=0,c++,v[c]=0,c++,v[c]=0,c++,l(v,c,h(v,c-17,17)),c+=4,null!=o.sRGB&&(l(v,c,1),c+=4,u(v,c,"sRGB"),c+=4,v[c]=o.sRGB,c++,l(v,c,h(v,c-5,5)),c+=4),null!=o.iCCP){const t=13+d.length;l(v,c,t),c+=4,u(v,c,"iCCP"),c+=4,u(v,c,"ICC profile"),c+=11,c+=2,v.set(d,c),c+=d.length,l(v,c,h(v,c-(t+4),t+4)),c+=4}if(null!=o.pHYs&&(l(v,c,9),c+=4,u(v,c,"pHYs"),c+=4,l(v,c,o.pHYs[0]),c+=4,l(v,c,o.pHYs[1]),c+=4,v[c]=o.pHYs[2],c++,l(v,c,h(v,c-13,13)),c+=4),a&&(l(v,c,8),c+=4,u(v,c,"acTL"),c+=4,l(v,c,t.frames.length),c+=4,l(v,c,null!=o.loop?o.loop:0),c+=4,l(v,c,h(v,c-12,12)),c+=4),3==t.ctype){l(v,c,3*(g=t.plte.length)),c+=4,u(v,c,"PLTE"),c+=4;for(m=0;m<g;m++){const e=3*m,i=t.plte[m],s=255&i,n=i>>>8&255,r=i>>>16&255;v[c+e+0]=s,v[c+e+1]=n,v[c+e+2]=r}if(c+=3*g,l(v,c,h(v,c-3*g-4,3*g+4)),c+=4,w){l(v,c,g),c+=4,u(v,c,"tRNS"),c+=4;for(m=0;m<g;m++)v[c+m]=t.plte[m]>>>24&255;c+=g,l(v,c,h(v,c-g-4,g+4)),c+=4}}let M=0;for(y=0;y<t.frames.length;y++){var k=t.frames[y];a&&(l(v,c,26),c+=4,u(v,c,"fcTL"),c+=4,l(v,c,M++),c+=4,l(v,c,k.rect.width),c+=4,l(v,c,k.rect.height),c+=4,l(v,c,k.rect.x),c+=4,l(v,c,k.rect.y),c+=4,f(v,c,r[y]),c+=2,f(v,c,1e3),c+=2,v[c]=k.dispose,c++,v[c]=k.blend,c++,l(v,c,h(v,c-30,30)),c+=4);const e=k.cimg;l(v,c,(g=e.length)+(0==y?0:4)),c+=4;const i=c;u(v,c,0==y?"IDAT":"fdAT"),c+=4,0!=y&&(l(v,c,M++),c+=4),v.set(e,c),c+=g,l(v,c,h(v,i,c-i)),c+=4}return l(v,c,0),c+=4,u(v,c,"IEND"),c+=4,l(v,c,h(v,c-4,4)),c+=4,v.buffer}function f(t,e,i){for(let s=0;s<t.frames.length;s++){const n=t.frames[s];const r=n.rect.height,o=new Uint8Array(r*n.bpl+r);n.cimg=d(n.img,r,n.bpp,n.bpl,o,e,i)}}function u(e,i,s,n,r){const o=r[0],l=r[1],f=r[2],u=r[3],d=r[4],w=r[5];let g=6,m=8,y=255;for(var v=0;v<e.length;v++){const t=new Uint8Array(e[v]);for(var b=t.length,M=0;M<b;M+=4)y&=t[M+3]}const k=255!=y,A=function e(i,s,n,r,o,h){const l=[];for(var f=0;f<i.length;f++){const e=new Uint8Array(i[f]),c=new Uint32Array(e.buffer);var u;let w=0,g=0,m=s,y=n,v=r?1:0;if(0!=f){const b=h||r||1==f||0!=l[f-2].dispose?1:2;let M=0,k=1e9;for(let t=0;t<b;t++){var d=new Uint8Array(i[f-1-t]);const e=new Uint32Array(i[f-1-t]);let r=s,h=n,l=-1,u=-1;for(let t=0;t<n;t++)for(let i=0;i<s;i++){c[p=t*s+i]!=e[p]&&(i<r&&(r=i),i>l&&(l=i),t<h&&(h=t),t>u&&(u=t))}-1==l&&(r=h=l=u=0),o&&(1==(1&r)&&r--,1==(1&h)&&h--);const a=(l-r+1)*(u-h+1);a<k&&(k=a,M=t,w=r,g=h,m=l-r+1,y=u-h+1)}d=new Uint8Array(i[f-1-M]);1==M&&(l[f-1].dispose=2),u=new Uint8Array(m*y*4),t(d,s,n,u,m,y,-w,-g,0),v=t(e,s,n,u,m,y,-w,-g,3)?1:0,1==v?a(e,s,n,u,{x:w,y:g,width:m,height:y}):t(e,s,n,u,m,y,-w,-g,0)}else u=e.slice(0);l.push({rect:{x:w,y:g,width:m,height:y},img:u,blend:v,dispose:0})}if(r)for(f=0;f<l.length;f++){if(1==(g=l[f]).blend)continue;const t=g.rect,e=l[f-1].rect,r=Math.min(t.x,e.x),h=Math.min(t.y,e.y),u={x:r,y:h,width:Math.max(t.x+t.width,e.x+e.width)-r,height:Math.max(t.y+t.height,e.y+e.height)-h};l[f-1].dispose=1,f-1!=0&&c(i,s,n,l,f-1,u,o),c(i,s,n,l,f,u,o)}let w=0;if(1!=i.length)for(var p=0;p<l.length;p++){var g;w+=(g=l[p]).rect.width*g.rect.height}return l}(e,i,s,o,l,f),x={},S=[],C=[];if(0!=n){const t=[];for(M=0;M<A.length;M++)t.push(A[M].img.buffer);const e=function t(e){let i=0;for(var s=0;s<e.length;s++)i+=e[s].byteLength;const n=new Uint8Array(i);let r=0;for(s=0;s<e.length;s++){const t=new Uint8Array(e[s]),i=t.length;for(let e=0;e<i;e+=4){let i=t[e],s=t[e+1],o=t[e+2];const h=t[e+3];0==h&&(i=s=o=0),n[r+e]=i,n[r+e+1]=s,n[r+e+2]=o,n[r+e+3]=h}r+=i}return n.buffer}(t),i=p(e,n);for(M=0;M<i.plte.length;M++)S.push(i.plte[M].est.rgba);let s=0;for(M=0;M<A.length;M++){const t=(E=A[M]).img.length;var O=new Uint8Array(i.inds.buffer,s>>2,t>>2);C.push(O);const e=new Uint8Array(i.abuf,s,t);w&&h(E.img,E.rect.width,E.rect.height,S,e,O),E.img.set(e),s+=t}}else for(v=0;v<A.length;v++){var E=A[v];const t=new Uint32Array(E.img.buffer);var T=E.rect.width;b=t.length,O=new Uint8Array(b);C.push(O);for(M=0;M<b;M++){const e=t[M];if(0!=M&&e==t[M-1])O[M]=O[M-1];else if(M>T&&e==t[M-T])O[M]=O[M-T];else{let t=x[e];if(null==t&&(x[e]=t=S.length,S.push(e),S.length>=300))break;O[M]=t}}}const D=S.length;D<=256&&0==d&&(m=D<=2?1:D<=4?2:D<=16?4:8,m=Math.max(m,u));for(v=0;v<A.length;v++){(E=A[v]).rect.x;T=E.rect.width;const t=E.rect.height;let e=E.img;let i=4*T,s=4;if(D<=256&&0==d){i=Math.ceil(m*T/8);var I=new Uint8Array(i*t);const n=C[v];for(let e=0;e<t;e++){M=e*i;const t=e*T;if(8==m)for(var P=0;P<T;P++)I[M+P]=n[t+P];else if(4==m)for(P=0;P<T;P++)I[M+(P>>1)]|=n[t+P]<<4-4*(1&P);else if(2==m)for(P=0;P<T;P++)I[M+(P>>2)]|=n[t+P]<<6-2*(3&P);else if(1==m)for(P=0;P<T;P++)I[M+(P>>3)]|=n[t+P]<<7-1*(7&P)}e=I,g=3,s=1}else if(0==k&&1==A.length){I=new Uint8Array(T*t*3);const n=T*t;for(M=0;M<n;M++){const t=3*M,i=4*M;I[t]=e[i],I[t+1]=e[i+1],I[t+2]=e[i+2]}e=I,g=2,s=3,i=3*T}E.img=e,E.bpl=i,E.bpp=s}return{ctype:g,depth:m,plte:S,frames:A}}function c(e,i,s,n,r,o,h){const l=Uint8Array,f=Uint32Array,u=new l(e[r-1]),c=new f(e[r-1]),d=r+1<e.length?new l(e[r+1]):null,w=new l(e[r]),p=new f(w.buffer);let g=i,m=s,y=-1,v=-1;for(let t=0;t<o.height;t++)for(let e=0;e<o.width;e++){const s=o.x+e,h=o.y+t,l=h*i+s,f=p[l];0==f||0==n[r-1].dispose&&c[l]==f&&(null==d||0!=d[4*l+3])||(s<g&&(g=s),s>y&&(y=s),h<m&&(m=h),h>v&&(v=h))}-1==y&&(g=m=y=v=0),h&&(1==(1&g)&&g--,1==(1&m)&&m--),o={x:g,y:m,width:y-g+1,height:v-m+1};const b=n[r];b.rect=o,b.blend=1,b.img=new Uint8Array(o.width*o.height*4),0==n[r-1].dispose?(t(u,i,s,b.img,o.width,o.height,-o.x,-o.y,0),a(w,i,s,b.img,o)):t(w,i,s,b.img,o.width,o.height,-o.x,-o.y,0)}function a(e,i,s,n,r){t(e,i,s,n,r.width,r.height,-r.x,-r.y,2)}function d(t,e,i,s,n,r,o){const h=[];let l,f=[0,1,2,3,4];-1!=r?f=[r]:(e*s>5e5||1==i)&&(f=[0]),o&&(l={level:0});const u=ul;for(var c=0;c<f.length;c++){for(let r=0;r<e;r++)w(n,t,r,s,i,f[c]);h.push(u.deflate(n,l))}let a,d=1e9;for(c=0;c<h.length;c++)h[c].length<d&&(a=c,d=h[c].length);return h[a]}function w(t,e,s,n,r,o){const h=s*n;let l=h+s;if(t[l]=o,l++,0==o)if(n<500)for(var f=0;f<n;f++)t[l+f]=e[h+f];else t.set(new Uint8Array(e.buffer,h,n),l);else if(1==o){for(f=0;f<r;f++)t[l+f]=e[h+f];for(f=r;f<n;f++)t[l+f]=e[h+f]-e[h+f-r]+256&255}else if(0==s){for(f=0;f<r;f++)t[l+f]=e[h+f];if(2==o)for(f=r;f<n;f++)t[l+f]=e[h+f];if(3==o)for(f=r;f<n;f++)t[l+f]=e[h+f]-(e[h+f-r]>>1)+256&255;if(4==o)for(f=r;f<n;f++)t[l+f]=e[h+f]-i(e[h+f-r],0,0)+256&255}else{if(2==o)for(f=0;f<n;f++)t[l+f]=e[h+f]+256-e[h+f-n]&255;if(3==o){for(f=0;f<r;f++)t[l+f]=e[h+f]+256-(e[h+f-n]>>1)&255;for(f=r;f<n;f++)t[l+f]=e[h+f]+256-(e[h+f-n]+e[h+f-r]>>1)&255}if(4==o){for(f=0;f<r;f++)t[l+f]=e[h+f]+256-i(0,e[h+f-n],0)&255;for(f=r;f<n;f++)t[l+f]=e[h+f]+256-i(e[h+f-r],e[h+f-n],e[h+f-r-n])&255}}}function p(t,e){const i=new Uint8Array(t),s=i.slice(0),n=new Uint32Array(s.buffer),r=g(s,e),o=r[0],h=r[1],l=i.length,f=new Uint8Array(l>>2);let u;if(i.length<2e7)for(var c=0;c<l;c+=4){u=m(o,a=i[c]*(1/255),d=i[c+1]*(1/255),w=i[c+2]*(1/255),p=i[c+3]*(1/255)),f[c>>2]=u.ind,n[c>>2]=u.est.rgba}else for(c=0;c<l;c+=4){var a=i[c]*(1/255),d=i[c+1]*(1/255),w=i[c+2]*(1/255),p=i[c+3]*(1/255);for(u=o;u.left;)u=y(u.est,a,d,w,p)<=0?u.left:u.right;f[c>>2]=u.ind,n[c>>2]=u.est.rgba}return{abuf:s.buffer,inds:f,plte:h}}function g(t,e,i){null==i&&(i=1e-4);const s=new Uint32Array(t.buffer),n={i0:0,i1:t.length,bst:null,est:null,tdst:0,left:null,right:null};n.bst=M(t,n.i0,n.i1),n.est=k(n.bst);const r=[n];for(;r.length<e;){let e=0,n=0;for(var o=0;o<r.length;o++)r[o].est.L>e&&(e=r[o].est.L,n=o);if(e<i)break;const h=r[n],l=v(t,s,h.i0,h.i1,h.est.e,h.est.eMq255);if(h.i0>=l||h.i1<=l){h.est.L=0;continue}const f={i0:h.i0,i1:l,bst:null,est:null,tdst:0,left:null,right:null};f.bst=M(t,f.i0,f.i1),f.est=k(f.bst);const u={i0:l,i1:h.i1,bst:null,est:null,tdst:0,left:null,right:null};u.bst={R:[],m:[],N:h.bst.N-f.bst.N};for(o=0;o<16;o++)u.bst.R[o]=h.bst.R[o]-f.bst.R[o];for(o=0;o<4;o++)u.bst.m[o]=h.bst.m[o]-f.bst.m[o];u.est=k(u.bst),h.left=f,h.right=u,r[n]=f,r.push(u)}r.sort(((t,e)=>e.bst.N-t.bst.N));for(o=0;o<r.length;o++)r[o].ind=o;return[n,r]}function m(t,e,i,s,n){if(null==t.left)return t.tdst=function t(e,i,s,n,r){const o=i-e[0],h=s-e[1],l=n-e[2],f=r-e[3];return o*o+h*h+l*l+f*f}(t.est.q,e,i,s,n),t;const r=y(t.est,e,i,s,n);let o=t.left,h=t.right;r>0&&(o=t.right,h=t.left);const l=m(o,e,i,s,n);if(l.tdst<=r*r)return l;const f=m(h,e,i,s,n);return f.tdst<l.tdst?f:l}function y(t,e,i,s,n){const{e:r}=t;return r[0]*e+r[1]*i+r[2]*s+r[3]*n-t.eMq}function v(t,e,i,s,n,r){for(s-=4;i<s;){for(;b(t,i,n)<=r;)i+=4;for(;b(t,s,n)>r;)s-=4;if(i>=s)break;const o=e[i>>2];e[i>>2]=e[s>>2],e[s>>2]=o,i+=4,s-=4}for(;b(t,i,n)>r;)i-=4;return i+4}function b(t,e,i){return t[e]*i[0]+t[e+1]*i[1]+t[e+2]*i[2]+t[e+3]*i[3]}function M(t,e,i){const s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],n=[0,0,0,0],r=i-e>>2;for(let r=e;r<i;r+=4){const e=t[r]*(1/255),i=t[r+1]*(1/255),o=t[r+2]*(1/255),h=t[r+3]*(1/255);n[0]+=e,n[1]+=i,n[2]+=o,n[3]+=h,s[0]+=e*e,s[1]+=e*i,s[2]+=e*o,s[3]+=e*h,s[5]+=i*i,s[6]+=i*o,s[7]+=i*h,s[10]+=o*o,s[11]+=o*h,s[15]+=h*h}return s[4]=s[1],s[8]=s[2],s[9]=s[6],s[12]=s[3],s[13]=s[7],s[14]=s[11],{R:s,m:n,N:r}}function k(t){const{R:e}=t,{m:i}=t,{N:s}=t,n=i[0],r=i[1],o=i[2],h=i[3],l=0==s?0:1/s,f=[e[0]-n*n*l,e[1]-n*r*l,e[2]-n*o*l,e[3]-n*h*l,e[4]-r*n*l,e[5]-r*r*l,e[6]-r*o*l,e[7]-r*h*l,e[8]-o*n*l,e[9]-o*r*l,e[10]-o*o*l,e[11]-o*h*l,e[12]-h*n*l,e[13]-h*r*l,e[14]-h*o*l,e[15]-h*h*l],u=f,c=A;let a=[Math.random(),Math.random(),Math.random(),Math.random()],d=0,w=0;if(0!=s)for(let t=0;t<16&&(a=c.multVec(u,a),w=Math.sqrt(c.dot(a,a)),a=c.sml(1/w,a),!(0!=t&&Math.abs(w-d)<1e-9));t++)d=w;const p=[n*l,r*l,o*l,h*l];return{Cov:f,q:p,e:a,L:d,eMq255:c.dot(c.sml(255,p),a),eMq:c.dot(a,p),rgba:(Math.round(255*p[3])<<24|Math.round(255*p[2])<<16|Math.round(255*p[1])<<8|Math.round(255*p[0])<<0)>>>0}}var A={multVec:(t,e)=>[t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3],t[4]*e[0]+t[5]*e[1]+t[6]*e[2]+t[7]*e[3],t[8]*e[0]+t[9]*e[1]+t[10]*e[2]+t[11]*e[3],t[12]*e[0]+t[13]*e[1]+t[14]*e[2]+t[15]*e[3]],dot:(t,e)=>t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3],sml:(t,e)=>[t*e[0],t*e[1],t*e[2],t*e[3]]};cl.encode=function t(e,i,s,n,r,o,h){null==n&&(n=0),null==h&&(h=false);const c=u(e,i,s,n,[false,false,false,0,h,false]);return f(c,-1),l(c,i,s,r,o)},cl.encodeLL=function t(e,i,s,n,r,o,h,u){const c={ctype:0+(1==n?0:2)+(0==r?0:4),depth:o,frames:[]},a=(n+r)*o,d=a*i;for(let t=0;t<e.length;t++)c.frames.push({rect:{x:0,y:0,width:i,height:s},img:new Uint8Array(e[t]),blend:0,dispose:1,bpp:Math.ceil(a/8),bpl:Math.ceil(d/8)});return f(c,0,true),l(c,i,s,h,u)},cl.encode.compress=u,cl.encode.dither=h,cl.quantize=p,cl.quantize.getKDtree=g,cl.quantize.getNearest=m}();const al={toArrayBuffer(t,e){const i=t.width,s=t.height,n=i<<2,r=t.getContext("2d").getImageData(0,0,i,s),o=new Uint32Array(r.data.buffer),h=(32*i+31)/32<<2,l=h*s,f=122+l,u=new ArrayBuffer(f),c=new DataView(u),a=1<<20;let d,w,p,g,m=a,y=0,v=0,b=0;function M(t){c.setUint16(v,t,true),v+=2}function k(t){c.setUint32(v,t,true),v+=4}function A(t){v+=t}M(19778),k(f),A(4),k(122),k(108),k(i),k(-s>>>0),M(1),M(32),k(3),k(l),k(2835),k(2835),A(8),k(16711680),k(65280),k(255),k(4278190080),k(1466527264),function t(){for(;y<s&&m>0;){for(g=122+y*h,d=0;d<n;)m--,w=o[b++],p=w>>>24,c.setUint32(g+d,w<<8|p),d+=4;y++}b<o.length?(m=a,setTimeout(t,al._dly)):e(u)}()},toBlob(t,e){this.toArrayBuffer(t,(t=>{e(new Blob([t],{type:"image/bmp"}))}))},_dly:9};var dl={CHROME:"CHROME",FIREFOX:"FIREFOX",DESKTOP_SAFARI:"DESKTOP_SAFARI",IE:"IE",IOS:"IOS",ETC:"ETC"},wl={[dl.CHROME]:16384,[dl.FIREFOX]:11180,[dl.DESKTOP_SAFARI]:16384,[dl.IE]:8192,[dl.IOS]:4096,[dl.ETC]:8192};const pl="undefined"!=typeof window,gl="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope,ml=pl&&window.cordova&&window.cordova.require&&window.cordova.require("cordova/modulemapper"),yl=(pl||gl)&&(ml&&ml.getOriginalSymbol(window,"File")||"undefined"!=typeof File&&File),vl=(pl||gl)&&(ml&&ml.getOriginalSymbol(window,"FileReader")||"undefined"!=typeof FileReader&&FileReader);function bl(t,e,i=Date.now()){return new Promise((s=>{const n=t.split(","),r=n[0].match(/:(.*?);/)[1],o=globalThis.atob(n[1]);let h=o.length;const l=new Uint8Array(h);for(;h--;)l[h]=o.charCodeAt(h);const f=new Blob([l],{type:r});f.name=e,f.lastModified=i,s(f)}))}function Ml(t){return new Promise(((e,i)=>{const s=new vl;s.onload=()=>e(s.result),s.onerror=t=>i(t),s.readAsDataURL(t)}))}function kl(t){return new Promise(((e,i)=>{const s=new Image;s.onload=()=>e(s),s.onerror=t=>i(t),s.src=t}))}function Al(){if(void 0!==Al.cachedResult)return Al.cachedResult;let t=dl.ETC;const{userAgent:e}=navigator;return/Chrom(e|ium)/i.test(e)?t=dl.CHROME:/iP(ad|od|hone)/i.test(e)&&/WebKit/i.test(e)?t=dl.IOS:/Safari/i.test(e)?t=dl.DESKTOP_SAFARI:/Firefox/i.test(e)?t=dl.FIREFOX:(/MSIE/i.test(e)||true==!!document.documentMode)&&(t=dl.IE),Al.cachedResult=t,Al.cachedResult}function xl(t,e){const i=Al(),s=wl[i];let n=t,r=e,o=n*r;const h=n>r?r/n:n/r;for(;o>s*s;){const t=(s+n)/2,e=(s+r)/2;t<e?(r=e,n=e*h):(r=t*h,n=t),o=n*r}return{width:n,height:r}}function Sl(t,e){let i,s;try{if(i=new OffscreenCanvas(t,e),s=i.getContext("2d"),null===s)throw new Error("getContext of OffscreenCanvas returns null")}catch(t){i=document.createElement("canvas"),s=i.getContext("2d")}return i.width=t,i.height=e,[i,s]}function Cl(t,e){const{width:i,height:s}=xl(t.width,t.height),[n,r]=Sl(i,s);return e&&/jpe?g/.test(e)&&(r.fillStyle="white",r.fillRect(0,0,n.width,n.height)),r.drawImage(t,0,0,n.width,n.height),n}function Ol(){return void 0!==Ol.cachedResult||(Ol.cachedResult=["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"undefined"!=typeof document&&"ontouchend"in document),Ol.cachedResult}function El(t,e={}){return new Promise((function(i,s){let n,r;var o=function(){try{return r=Cl(n,e.fileType||t.type),i([n,r])}catch(t){return s(t)}},h=function(e){try{var i=function(t){try{throw t}catch(t){return s(t)}};try{let e;return Ml(t).then((function(t){try{return e=t,kl(e).then((function(t){try{return n=t,function(){try{return o()}catch(t){return s(t)}}()}catch(t){return i(t)}}),i)}catch(t){return i(t)}}),i)}catch(t){i(t)}}catch(t){return s(t)}};try{if(Ol()||[dl.DESKTOP_SAFARI,dl.MOBILE_SAFARI].includes(Al()))throw new Error("Skip createImageBitmap on IOS and Safari");return createImageBitmap(t).then((function(t){try{return n=t,o()}catch(t){return h()}}),h)}catch(t){h()}}))}function Tl(t,e,i,s,n=1){return new Promise((function(r,o){let h;if("image/png"===e){let f,u,c;return f=t.getContext("2d"),({data:u}=f.getImageData(0,0,t.width,t.height)),c=cl.encode([u.buffer],t.width,t.height,4096*n),h=new Blob([c],{type:e}),h.name=i,h.lastModified=s,l.call(this)}{if("image/bmp"===e)return new Promise((e=>al.toBlob(t,e))).then(function(t){try{return h=t,h.name=i,h.lastModified=s,a.call(this)}catch(t){return o(t)}}.bind(this),o);{if("function"==typeof OffscreenCanvas&&t instanceof OffscreenCanvas)return t.convertToBlob({type:e,quality:n}).then(function(t){try{return h=t,h.name=i,h.lastModified=s,d.call(this)}catch(t){return o(t)}}.bind(this),o);{let w;return w=t.toDataURL(e,n),bl(w,i,s).then(function(t){try{return h=t,d.call(this)}catch(t){return o(t)}}.bind(this),o)}function d(){return a.call(this)}}function a(){return l.call(this)}}function l(){return r(h)}}))}function Dl(t){t.width=0,t.height=0}function Il(){return new Promise((function(t,e){let i,s,n,r;return void 0!==Il.cachedResult?t(Il.cachedResult):bl("data:image/jpeg;base64,/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAAAAAD/2wCEAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIAAEAAgMBEQACEQEDEQH/xABKAAEAAAAAAAAAAAAAAAAAAAALEAEAAAAAAAAAAAAAAAAAAAAAAQEAAAAAAAAAAAAAAAAAAAAAEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIRAxEAPwA/8H//2Q==","test.jpg",Date.now()).then((function(o){try{return i=o,El(i).then((function(o){try{return s=o[1],Tl(s,i.type,i.name,i.lastModified).then((function(i){try{return n=i,Dl(s),El(n).then((function(i){try{return r=i[0],Il.cachedResult=1===r.width&&2===r.height,t(Il.cachedResult)}catch(t){return e(t)}}),e)}catch(t){return e(t)}}),e)}catch(t){return e(t)}}),e)}catch(t){return e(t)}}),e)}))}function Pl(t){return new Promise(((e,i)=>{const s=new vl;s.onload=t=>{const i=new DataView(t.target.result);if(65496!=i.getUint16(0,false))return e(-2);const s=i.byteLength;let n=2;for(;n<s;){if(i.getUint16(n+2,false)<=8)return e(-1);const t=i.getUint16(n,false);if(n+=2,65505==t){if(1165519206!=i.getUint32(n+=2,false))return e(-1);const t=18761==i.getUint16(n+=6,false);n+=i.getUint32(n+4,t);const s=i.getUint16(n,t);n+=2;for(let r=0;r<s;r++)if(274==i.getUint16(n+12*r,t))return e(i.getUint16(n+12*r+8,t))}else{if(65280!=(65280&t))break;n+=i.getUint16(n,false)}}return e(-1)},s.onerror=t=>i(t),s.readAsArrayBuffer(t)}))}function Rl(t,e){const{width:i}=t,{height:s}=t,{maxWidthOrHeight:n}=e;let r,o=t;return isFinite(n)&&(i>n||s>n)&&([o,r]=Sl(i,s),i>s?(o.width=n,o.height=s/i*n):(o.width=i/s*n,o.height=n),r.drawImage(t,0,0,o.width,o.height),Dl(t)),o}function $l(t,e){const{width:i}=t,{height:s}=t,[n,r]=Sl(i,s);switch(e>4&&e<9?(n.width=s,n.height=i):(n.width=i,n.height=s),e){case 2:r.transform(-1,0,0,1,i,0);break;case 3:r.transform(-1,0,0,-1,i,s);break;case 4:r.transform(1,0,0,-1,0,s);break;case 5:r.transform(0,1,1,0,0,0);break;case 6:r.transform(0,1,-1,0,s,0);break;case 7:r.transform(0,-1,-1,0,s,i);break;case 8:r.transform(0,-1,1,0,0,i)}return r.drawImage(t,0,0,i,s),Dl(t),n}function Ul(t,e,i=0){return new Promise((function(s,n){let r,o,h,l,f,u,c,a,d,w,p,g,m,y,v,b,M,k,A,x;function S(t=5){if(e.signal&&e.signal.aborted)throw e.signal.reason;r+=t,e.onProgress(Math.min(r,100))}function C(t){if(e.signal&&e.signal.aborted)throw e.signal.reason;r=Math.min(Math.max(t,r),100),e.onProgress(r)}return r=i,o=e.maxIteration||10,h=1024*e.maxSizeMB*1024,S(),El(t,e).then(function(i){try{return[,l]=i,S(),f=Rl(l,e),S(),new Promise((function(i,s){var n;if(!(n=e.exifOrientation))return Pl(t).then(function(t){try{return n=t,r.call(this)}catch(t){return s(t)}}.bind(this),s);function r(){return i(n)}return r.call(this)})).then(function(i){try{return u=i,S(),Il().then(function(i){try{return c=i?f:$l(f,u),S(),a=e.initialQuality||1,d=e.fileType||t.type,Tl(c,d,t.name,t.lastModified,a).then(function(i){try{{if(w=i,S(),p=w.size>h,g=w.size>t.size,!p&&!g)return C(100),s(w);var r;function u(){if(o--&&(v>h||v>m)){let e,i;return e=x?.95*A.width:A.width,i=x?.95*A.height:A.height,[M,k]=Sl(e,i),k.drawImage(A,0,0,e,i),a*="image/png"===d?.85:.95,Tl(M,d,t.name,t.lastModified,a).then((function(t){try{return b=t,Dl(A),A=M,v=b.size,C(Math.min(99,Math.floor((y-v)/(y-h)*100))),u}catch(t){return n(t)}}),n)}return[1]}return m=t.size,y=w.size,v=y,A=c,x=!e.alwaysKeepResolution&&p,(r=function(t){for(;t;){if(t.then)return void t.then(r,n);try{if(t.pop){if(t.length)return t.pop()?O.call(this):t;t=u}else t=t.call(this)}catch(t){return n(t)}}}.bind(this))(u);function O(){return Dl(A),Dl(M),Dl(f),Dl(c),Dl(l),C(100),s(b)}}}catch(E){return n(E)}}.bind(this),n)}catch(t){return n(t)}}.bind(this),n)}catch(t){return n(t)}}.bind(this),n)}catch(t){return n(t)}}.bind(this),n)}))}const jl="\nlet scriptImported = false\nself.addEventListener('message', async (e) => {\n const { file, id, imageCompressionLibUrl, options } = e.data\n options.onProgress = (progress) => self.postMessage({ progress, id })\n try {\n if (!scriptImported) {\n // console.log('[worker] importScripts', imageCompressionLibUrl)\n self.importScripts(imageCompressionLibUrl)\n scriptImported = true\n }\n // console.log('[worker] self', self)\n const compressedFile = await imageCompression(file, options)\n self.postMessage({ file: compressedFile, id })\n } catch (e) {\n // console.error('[worker] error', e)\n self.postMessage({ error: e.message + '\\n' + e.stack, id })\n }\n})\n";let Bl;function Fl(t,e){return new Promise(((i,s)=>{Bl||(Bl=function t(e){const i=[];return i.push(e),URL.createObjectURL(new Blob(i))}(jl));const n=new Worker(Bl);n.addEventListener("message",(function t(r){if(e.signal&&e.signal.aborted)n.terminate();else if(void 0===r.data.progress){if(r.data.error)return s(new Error(r.data.error)),void n.terminate();i(r.data.file),n.terminate()}else e.onProgress(r.data.progress)})),n.addEventListener("error",s),e.signal&&e.signal.addEventListener("abort",(()=>{s(e.signal.reason),n.terminate()})),n.postMessage({file:t,imageCompressionLibUrl:e.libURL,options:{...e,onProgress:void 0,signal:void 0}})}))}function Nl(t,e){return new Promise((function(i,s){let n,r,o,h,l,f;if(n={...e},o=0,({onProgress:h}=n),n.maxSizeMB=n.maxSizeMB||Number.POSITIVE_INFINITY,l="boolean"!=typeof n.useWebWorker||n.useWebWorker,delete n.useWebWorker,n.onProgress=t=>{o=t,"function"==typeof h&&h(o)},!(t instanceof Blob||t instanceof yl))return s(new Error("The file given is not an instance of Blob or File"));if(!/^image/.test(t.type))return s(new Error("The file given is not an image"));if(f="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope,!l||"function"!=typeof Worker||f)return Ul(t,n).then(function(t){try{return r=t,a.call(this)}catch(t){return s(t)}}.bind(this),s);var u=function(){try{return a.call(this)}catch(t){return s(t)}}.bind(this),c=function(e){try{return Ul(t,n).then((function(t){try{return r=t,u()}catch(t){return s(t)}}),s)}catch(t){return s(t)}};try{return n.libURL=n.libURL||"https://cdn.jsdelivr.net/npm/browser-image-compression@2.0.2/dist/browser-image-compression.js",Fl(t,n).then((function(t){try{return r=t,u()}catch(t){return c()}}),c)}catch(t){c()}function a(){try{r.name=t.name,r.lastModified=t.lastModified}catch(t){}try{n.preserveExif&&"image/jpeg"===t.type&&(!n.fileType||n.fileType&&n.fileType===t.type)&&(r=ol(t,r))}catch(t){}return i(r)}}))}Nl.getDataUrlFromFile=Ml,Nl.getFilefromDataUrl=bl,Nl.loadImage=kl,Nl.drawImageInCanvas=Cl,Nl.drawFileInCanvas=El,Nl.canvasToFile=Tl,Nl.getExifOrientation=Pl,Nl.handleMaxWidthOrHeight=Rl,Nl.followExifOrientation=$l,Nl.cleanupCanvasMemory=Dl,Nl.isAutoOrientationInBrowser=Il,Nl.approximateBelowMaximumCanvasSizeOfBrowser=xl,Nl.copyExifWithoutOrientation=ol,Nl.getBrowserName=Al,Nl.version="2.0.2";class Ll extends tl{fileInput=null;maxCompressionSize=300;constructor(t){super(t);this.setupFileInput()}onActivate(){this.openFilePicker()}openFilePicker(){if(this._core.store.isDisabled){return}this.fileInput.click()}setupFileInput(){this.fileInput=document.createElement("input");this.fileInput.type="file";this.fileInput.accept="image/*";this.fileInput.style.display="none";this.fileInput.addEventListener("change",this.handleFileSelect.bind(this));this.fileInput.addEventListener("cancel",this.handleCancel.bind(this));document.body.appendChild(this.fileInput)}handleFileSelect(t){const e=t.target;if(e.files&&e.files[0]){const t=e.files[0];Nl(t,{maxWidthOrHeight:this.maxCompressionSize}).then((t=>{this.readFile(t)})).catch((t=>{console.error("Error during image compression or processing:",t);this.handleCancel()}))}else{console.info("File selection cancelled by user.");this.handleCancel()}if(e){e.value=""}}readFile(t){const e=new FileReader;e.onload=t=>{const e=new Image;e.src=t.target?.result;e.onload=()=>this.createKritzelImage(e)};e.readAsDataURL(t)}createKritzelImage(t){const e=Qh.create(this._core);const{scaledWidth:i,scaledHeight:s}=e.calculateScaledDimensions(t);e.src=t.src;e.width=i;e.height=s;e.zIndex=this._core.store.currentZIndex;e.centerInViewport();this.addImageToStore(e);return e}addImageToStore(e){this._core.addObject(e);this._core.store.setState("activeTool",t.getTool("selection"));this._core.selectObjects([e]);this._core.engine.emitObjectsChange()}handleCancel(){this._core.store.setState("activeTool",t.getTool("selection"))}}class _l extends tl{fontFamily="Arial";fontSize=16;fontColor="#000000";palette=["#000000","#FFFFFF","#FF0000","#00FF00","#0000FF","#FFFF00","#FF00FF","#00FFFF","#808080","#C0C0C0","#800000","#008000","#000080","#808000","#800080"];constructor(t){super(t)}handlePointerDown(e){if(e.cancelable){e.preventDefault()}if(e.pointerType==="mouse"){const i=e.composedPath().slice(1);const s=i.find((t=>t.classList&&t.classList.contains("object")));const n=this._core.findObjectById(s?.id);const r=this._core.store.activeText;if(r===null&&n instanceof zh){n.edit(e);return}if(r!==null&&n instanceof zh){r.save();n.edit(e);return}if(r!==null&&n instanceof zh===false){this._core.resetActiveText();this._core.store.setState("activeTool",t.getTool("selection"));return}if(Zh.isLeftClick(e)===false){return}const o=e.clientX-this._core.store.offsetX;const h=e.clientY-this._core.store.offsetY;const l=zh.create(this._core,this.fontSize,this.fontFamily);l.fontColor=this.fontColor;l.translateX=(o-this._core.store.state.translateX)/this._core.store.state.scale;l.translateY=(h-this._core.store.state.translateY)/this._core.store.state.scale;l.zIndex=this._core.store.currentZIndex;this._core.store.state.objects.insert(l);this._core.rerender();l.edit(e)}if(e.pointerType==="touch"){const i=Array.from(this._core.store.state.pointers.values());const s=e.composedPath().slice(1);const n=s.find((t=>t.classList&&t.classList.contains("object")));const r=this._core.findObjectById(n?.id);const o=this._core.store.activeText;if(o===null&&r instanceof zh){r.edit(e);return}if(o!==null&&r instanceof zh){o.save();r.edit(e);return}if(o!==null&&r instanceof zh===false){this._core.resetActiveText();this._core.store.setState("activeTool",t.getTool("selection"));return}if(i.length>1){return}const h=Math.round(i[0].clientX-this._core.store.offsetX);const l=Math.round(i[0].clientY-this._core.store.offsetY);const f=zh.create(this._core,this.fontSize,this.fontFamily);f.fontColor=this.fontColor;f.translateX=(h-this._core.store.state.translateX)/this._core.store.state.scale;f.translateY=(l-this._core.store.state.translateY)/this._core.store.state.scale;f.zIndex=this._core.store.currentZIndex;this._core.store.state.objects.insert(f);this._core.rerender();f.edit(e)}}handlePointerUp(t){if(t.cancelable){t.preventDefault()}this._core.store.activeText?.edit(t)}}class zl{static registry=new Map;static register(t,e){if(this.registry.has(t)){console.warn(`[IconRegistry] Icon "${t}" is already registered. It will be overwritten.`)}this.registry.set(t,e)}static get(t){return this.registry.get(t)}static registerIcons(t){for(const e in t){if(Object.prototype.hasOwnProperty.call(t,e)){this.register(e,t[e])}}}static has(t){return this.registry.has(t)}}zl.registerIcons({cursor:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z"/></svg>',pen:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"/></svg>',arrow:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><line x1="5" y1="19" x2="19" y2="5"/><path d="M15 5h4v4"/></svg>',highlighter:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-highlighter-icon lucide-highlighter"><path d="m9 11-6 6v3h9l3-3"/><path d="m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4"/></svg>',eraser:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21"/><path d="M22 21H7"/><path d="m5 11 9 9"/></svg>',type:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="4 7 4 4 20 4 20 7"/><line x1="9" x2="15" y1="20" y2="20"/><line x1="12" x2="12" y1="4" y2="20"/></svg>',shapes:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M8.3 10a.7.7 0 0 1-.626-1.079L11.4 3a.7.7 0 0 1 1.198-.043L16.3 8.9a.7.7 0 0 1-.572 1.1Z"/><rect x="3" y="14" width="7" height="7" rx="1"/><circle cx="17.5" cy="17.5" r="3.5"/></svg>',"shape-rectangle":'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2"/></svg>',"shape-ellipse":'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><ellipse cx="12" cy="12" rx="10" ry="8"/></svg>',"shape-triangle":'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M12 3L22 21H2L12 3Z"/></svg>',image:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect width="18" height="18" x="3" y="3" rx="2" ry="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"/></svg>',"chevron-down":'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="m6 9 6 6 6-6"/></svg>',"chevron-up":'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="m18 15-6-6-6 6"/></svg>',copy:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-copy-icon lucide-copy"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>',paste:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-clipboard-paste-icon lucide-clipboard-paste"><path d="M11 14h10"/><path d="M16 4h2a2 2 0 0 1 2 2v1.344"/><path d="m17 18 4-4-4-4"/><path d="M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113"/><rect x="8" y="2" width="8" height="4" rx="1"/></svg>',cut:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-scissors-icon lucide-scissors"><circle cx="6" cy="6" r="3"/><path d="M8.12 8.12 12 12"/><path d="M20 4 8.12 15.88"/><circle cx="6" cy="18" r="3"/><path d="M14.8 14.8 20 20"/></svg>',delete:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-trash2-icon lucide-trash-2"><path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/><line x1="10" x2="10" y1="11" y2="17"/><line x1="14" x2="14" y1="11" y2="17"/></svg>',"bring-to-front":'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-arrow-up-to-line-icon lucide-arrow-up-to-line"><path d="M5 3h14"/><path d="m18 13-6-6-6 6"/><path d="M12 7v14"/></svg>',"send-to-back":'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-arrow-down-to-line-icon lucide-arrow-down-to-line"><path d="M12 17V3"/><path d="m6 11 6 6 6-6"/><path d="M19 21H5"/></svg>',"select-all":'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-square-mouse-pointer-icon lucide-square-mouse-pointer"><path d="M12.034 12.681a.498.498 0 0 1 .647-.647l9 3.5a.5.5 0 0 1-.033.943l-3.444 1.068a1 1 0 0 0-.66.66l-1.067 3.443a.5.5 0 0 1-.943.033z"/><path d="M21 11V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h6"/></svg>',download:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-download-icon lucide-download"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" x2="12" y1="15" y2="3"/></svg>',undo:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-undo-icon lucide-undo"><path d="M3 7v6h6"/><path d="M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13"/></svg>',redo:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-redo-icon lucide-redo"><path d="M21 7v6h-6"/><path d="M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7"/></svg>',plus:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-plus-icon lucide-plus"><path d="M5 12h14"/><path d="M12 5v14"/></svg>',"ellipsis-vertical":'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-ellipsis-vertical-icon lucide-ellipsis-vertical"><circle cx="12" cy="12" r="1"/><circle cx="12" cy="5" r="1"/><circle cx="12" cy="19" r="1"/></svg>',x:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-x-icon lucide-x"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>',check:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-check-icon lucide-check"><path d="M20 6 9 17l-5-5"/></svg>',group:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-group-icon lucide-group"><path d="M3 7V5c0-1.1.9-2 2-2h2"/><path d="M17 3h2c1.1 0 2 .9 2 2v2"/><path d="M21 17v2c0 1.1-.9 2-2 2h-2"/><path d="M7 21H5c-1.1 0-2-.9-2-2v-2"/><rect width="7" height="5" x="7" y="7" rx="1"/><rect width="7" height="5" x="10" y="12" rx="1"/></svg>',ungroup:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-ungroup-icon lucide-ungroup"><rect width="8" height="6" x="5" y="4" rx="1"/><rect width="8" height="6" x="11" y="14" rx="1"/></svg>',"move-vertical":'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-move-vertical-icon lucide-move-vertical" version="1.1" id="svg3"> <defs id="defs3" /> <path d="M12 2v20" id="path1" /> <path style="fill:#ffffff;stroke-width:2.5;stroke-dasharray:none;stroke-linejoin:round;paint-order:stroke fill markers" d="m 11.735575,22.661865 c -0.09259,-0.02798 -0.204674,-0.07661 -0.249076,-0.108068 -0.04441,-0.03147 -1.167275,-0.979853 -2.4952713,-2.10755 -1.8557024,-1.57581 -2.4300904,-2.079639 -2.4817336,-2.17687 -0.086514,-0.162885 -0.089504,-0.422449 -0.00664,-0.576334 0.1483053,-0.275409 0.437667,-0.436207 0.7830634,-0.435147 0.3692925,0.0011 0.3517326,-0.01122 2.168748,1.525599 L 11.12348,20.194964 V 11.999996 3.8050256 L 9.4546663,5.2164943 C 7.6376509,6.7533118 7.6552109,6.7409594 7.2859184,6.7420935 6.6681409,6.7439906 6.253658,6.1955854 6.5159903,5.723396 6.5738626,5.6192278 7.1368766,5.1267427 9.0629381,3.4955044 11.738128,1.2298067 11.640395,1.3026868 12.00355,1.3026868 c 0.363154,0 0.265421,-0.07288 2.940611,2.1928176 1.926062,1.6312383 2.489076,2.1237234 2.546948,2.2278916 0.262332,0.4721894 -0.15215,1.0205946 -0.769928,1.0186975 -0.369293,-0.00114 -0.351733,0.011218 -2.168748,-1.5255992 L 12.88362,3.8050256 v 8.1949704 8.194968 l 1.668813,-1.411469 c 1.817015,-1.536817 1.799455,-1.524464 2.168748,-1.525599 0.617772,-0.0019 1.032269,0.546521 0.769928,1.018687 -0.103474,0.18623 -4.919006,4.273935 -5.130582,4.355136 -0.20796,0.07981 -0.425829,0.09033 -0.624952,0.03014 z" id="path4" /> </svg>',hand:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-hand-icon lucide-hand" version="1.1" id="svg4"> <defs id="defs4" /> <path d="M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2" id="path1" /> <path d="M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2" id="path2" /> <path d="M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8" id="path3" /> <path d="M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15" id="path4" /> <path style="fill:#ffffff;stroke-width:0.0423032" d="M 11.478261,21.222477 C 9.6854059,21.139331 8.3341788,20.647346 7.1297169,19.639159 6.9698298,19.505327 5.949644,18.508708 4.8626374,17.42445 3.0780314,15.644357 2.8775851,15.435367 2.7968392,15.270602 2.5896561,14.847836 2.616354,14.436649 2.8771894,14.033085 c 0.136522,-0.211226 0.3837159,-0.398688 0.6367632,-0.482897 0.1529977,-0.05091 0.2326803,-0.05992 0.4470908,-0.05054 0.2250407,0.0098 0.2876577,0.02439 0.4554568,0.105827 0.1747854,0.08483 0.2933718,0.192702 1.1675186,1.062064 0.7182021,0.714271 1.0062041,0.982633 1.0998825,1.024878 0.1680197,0.07577 0.4756439,0.07817 0.6368269,0.005 0.1370772,-0.06226 0.2976691,-0.220818 0.3691296,-0.364463 0.072561,-0.145855 0.071573,-0.543545 -0.00169,-0.681911 -0.028747,-0.05429 -0.2476439,-0.296131 -0.4864385,-0.537426 l -0.4341716,-0.438718 0.00753,-3.989014 0.00753,-3.9890137 0.089246,-0.1883791 c 0.244787,-0.516692 0.7711718,-0.809716 1.3059705,-0.7269981 0.3973687,0.061462 0.7569953,0.3284904 0.9363122,0.6952277 l 0.093853,0.1919473 0.014101,2.4958872 0.014101,2.4958877 0.067385,0.149123 c 0.1186861,0.262654 0.4140438,0.457222 0.6940724,0.457222 0.2764172,0 0.5690532,-0.187563 0.6965992,-0.446482 l 0.06486,-0.131661 0.0141,-3.4970626 0.0141,-3.4970623 0.08982,-0.1896121 C 11.096301,3.0422103 11.506844,2.7755634 12,2.7755634 c 0.493156,0 0.903699,0.2666469 1.122868,0.7293016 l 0.08982,0.1896121 0.0141,3.2432432 c 0.01405,3.2315947 0.01432,3.2437077 0.07397,3.3726737 0.124721,0.269649 0.355908,0.424566 0.661411,0.443206 0.237954,0.01452 0.429018,-0.0627 0.591626,-0.239109 0.223655,-0.242637 0.208338,-0.06565 0.224113,-2.5896966 l 0.0141,-2.2561693 0.09385,-0.1919473 c 0.179317,-0.3667373 0.538944,-0.6337662 0.936313,-0.6952277 0.609359,-0.09425 1.208067,0.3054956 1.370981,0.9153772 0.03013,0.1127929 0.03773,0.6662436 0.038,2.7657391 3.74e-4,2.9328416 -0.008,2.8034316 0.197044,3.0364016 0.234927,0.266892 0.603828,0.337117 0.920407,0.175213 0.181933,-0.09304 0.329759,-0.261686 0.376309,-0.4293 0.01848,-0.06654 0.02929,-0.683932 0.0295,-1.684364 1.78e-4,-0.8783075 0.01239,-1.6530128 0.02751,-1.745346 0.08579,-0.5238478 0.505382,-0.9420803 1.039546,-1.0361716 0.607538,-0.1070155 1.25615,0.3485846 1.385876,0.973471 0.02211,0.1064847 0.02843,1.1397236 0.02169,3.5455556 -0.0093,3.324725 -0.01078,3.403075 -0.07062,3.770606 -0.126399,0.776213 -0.328814,1.41352 -0.669031,2.106456 -0.36657,0.746612 -0.72118,1.250303 -1.297841,1.843464 -1.185731,1.21966 -2.604527,1.933174 -4.300822,2.162889 -0.38234,0.05178 -2.604621,0.0785 -3.412456,0.04104 z" id="path16" /> </svg>',"hand-grab":'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-hand-grab-icon lucide-hand-grab" version="1.1" id="svg5"> <defs id="defs5" /> <path d="M18 11.5V9a2 2 0 0 0-2-2a2 2 0 0 0-2 2v1.4" id="path1" /> <path d="M14 10V8a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2" id="path2" /> <path d="M10 9.9V9a2 2 0 0 0-2-2a2 2 0 0 0-2 2v5" id="path3" /> <path d="M6 14a2 2 0 0 0-2-2a2 2 0 0 0-2 2" id="path4" /> <path d="M18 11a2 2 0 1 1 4 0v3a8 8 0 0 1-8 8h-4a8 8 0 0 1-8-8 2 2 0 1 1 4 0" id="path5" /> <path style="fill:#ffffff;stroke-width:0.0423032" d="M 9.5887192,21.221364 C 8.0526856,21.128375 6.6533474,20.587008 5.4571093,19.622953 5.3019976,19.497947 5.0101058,19.225967 4.8084606,19.018552 4.2300382,18.423579 3.8474097,17.879011 3.4960953,17.150756 3.1017715,16.333345 2.9014937,15.633198 2.8052391,14.735605 c -0.097577,-0.909922 -0.019834,-1.263323 0.3569794,-1.622742 0.753018,-0.718257 1.9463784,-0.256949 2.0619296,0.797066 0.037839,0.345154 0.089701,0.477674 0.2472582,0.631806 0.2464521,0.241095 0.5958008,0.287445 0.9036474,0.119894 0.1478567,-0.08047 0.2303871,-0.16866 0.3266699,-0.349056 0.050118,-0.0939 0.05337,-0.2326 0.066784,-2.848413 L 6.7826087,8.7144536 6.8458627,8.559342 C 6.9736603,8.2459558 7.2463773,7.9734987 7.5581669,7.8477164 c 0.1253804,-0.050581 0.2118709,-0.062705 0.4512338,-0.063254 0.275392,-6.312e-4 0.3094658,0.00564 0.4867271,0.089609 0.264676,0.1253746 0.4771417,0.334346 0.6070085,0.5970252 l 0.1048543,0.212087 0.017338,0.7488899 c 0.019395,0.8377165 0.026343,0.8713745 0.2242006,1.0860245 0.1591067,0.172611 0.3522021,0.249908 0.5883018,0.235502 0.305503,-0.01864 0.53669,-0.173557 0.661411,-0.443206 0.05734,-0.123963 0.0605,-0.181852 0.07486,-1.3703236 0.01626,-1.3456629 0.0141,-1.3267758 0.182667,-1.5938092 0.257891,-0.4085268 0.77099,-0.6442307 1.228943,-0.5645435 0.471012,0.08196 0.850379,0.4102836 0.989676,0.8565175 0.04663,0.149383 0.0514,0.2860903 0.0514,1.4721724 0,0.8344844 0.01108,1.3591794 0.03064,1.4503554 0.04109,0.191585 0.179844,0.390224 0.342505,0.490321 0.27721,0.170587 0.693425,0.126085 0.92529,-0.09893 0.228986,-0.222224 0.234357,-0.25046 0.251582,-1.3227071 l 0.0152,-0.9463484 0.104855,-0.2120434 c 0.129872,-0.2626357 0.342372,-0.471626 0.607008,-0.5969817 0.177262,-0.083967 0.211335,-0.09024 0.486727,-0.089609 0.239363,5.486e-4 0.325854,0.012673 0.451234,0.063254 0.31179,0.1257823 0.584507,0.3982394 0.712304,0.7116256 0.0621,0.1522783 0.06351,0.1824139 0.07736,1.649824 0.01408,1.492435 0.0142,1.494914 0.07947,1.627432 0.0771,0.156535 0.2216,0.291061 0.395058,0.367789 0.09695,0.04289 0.169789,0.05275 0.325757,0.04411 0.230544,-0.01277 0.363779,-0.06826 0.506411,-0.21089 0.177062,-0.177061 0.198302,-0.25307 0.219359,-0.784959 0.02002,-0.505773 0.05012,-0.6549 0.175297,-0.868492 0.498409,-0.850471 1.728484,-0.8041941 2.173478,0.08177 0.131751,0.262312 0.134447,0.313526 0.122615,2.328965 -0.0104,1.771638 -0.01517,1.923481 -0.0714,2.273746 -0.123689,0.770512 -0.327108,1.411813 -0.668163,2.106456 -0.36657,0.746612 -0.72118,1.250303 -1.297841,1.843464 -1.180268,1.214041 -2.600612,1.930754 -4.287083,2.163284 -0.28697,0.03957 -0.685446,0.04782 -2.636536,0.05459 -1.26416,0.0044 -2.4698005,-0.0024 -2.6792012,-0.01507 z" id="path6" /> </svg>',"mouse-pointer":'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-mouse-pointer2-icon lucide-mouse-pointer-2" version="1.1" id="svg1"> <defs id="defs1" /> <path d="M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z" id="path1" /> <path style="fill:#ffffff;stroke-width:0.0972651;stroke-linejoin:round;paint-order:stroke fill markers" d="M 7.8509196,12.314844 C 6.127071,8.1920568 4.7235325,4.8125504 4.7319449,4.8048299 c 0.01847,-0.016951 15.4787861,6.0801241 15.4610371,6.0973581 -0.0069,0.0067 -1.32633,0.341226 -2.93219,0.743509 -1.858829,0.465652 -3.011462,0.772855 -3.172161,0.845453 -0.688426,0.310999 -1.245788,0.879167 -1.498145,1.527185 -0.06251,0.160512 -0.440389,1.529576 -0.839733,3.042364 -0.399346,1.512788 -0.734966,2.750433 -0.745822,2.750322 -0.01086,-1.09e-4 -1.430163,-3.373391 -3.1540114,-7.496177 z" id="path2" /> <path style="fill:#ffffff;stroke-width:0.0705053;stroke-linejoin:round;paint-order:stroke fill markers" d="M 10.777831,19.240865 C 9.3899089,15.977493 4.7567738,4.8648478 4.7760705,4.8455511 c 0.013084,-0.013084 4.7618079,1.8507077 10.7773965,4.2299406 4.467495,1.7669453 4.558837,1.8037523 4.533848,1.8269883 -0.01183,0.011 -0.96064,0.257045 -2.108467,0.546768 -3.445281,0.869623 -3.777157,0.960825 -4.075205,1.119907 -0.597122,0.31871 -1.103666,0.864485 -1.309236,1.410635 -0.09642,0.256167 -0.312339,1.032806 -0.943226,3.392713 -0.641066,2.39798 -0.629171,2.354884 -0.649929,2.354849 -0.0091,-1.5e-5 -0.10963,-0.218934 -0.223421,-0.486487 z" id="path6" /> </svg>',pointer:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-pointer-icon lucide-pointer" version="1.1" id="svg5"> <defs id="defs5" /> <path d="M22 14a8 8 0 0 1-8 8" id="path1" /> <path d="M18 11v-1a2 2 0 0 0-2-2a2 2 0 0 0-2 2" id="path2" /> <path d="M14 10V9a2 2 0 0 0-2-2a2 2 0 0 0-2 2v1" id="path3" /> <path d="M10 9.5V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v10" id="path4" /> <path d="M18 11a2 2 0 1 1 4 0v3a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15" id="path5" /> <path style="fill:#ffffff;stroke-width:0.0930233;stroke-linejoin:round;paint-order:stroke fill markers" d="M 11.2,21.203517 C 9.5092536,21.041493 8.4838422,20.667261 7.3116279,19.784423 7.1888372,19.691945 6.139155,18.670017 4.9790008,17.513473 2.5649891,15.106974 2.6562686,15.220427 2.6869266,14.664621 c 0.020277,-0.367608 0.1272548,-0.601802 0.3822766,-0.836873 0.2609241,-0.240511 0.4631523,-0.319555 0.8191689,-0.320185 0.509345,-9.02e-4 0.5815472,0.04845 1.7102825,1.168976 0.532833,0.528958 1.0223742,0.98871 1.0878697,1.021671 0.1699959,0.08555 0.4741793,0.07658 0.6733897,-0.01985 0.303161,-0.146758 0.4720469,-0.543298 0.3791811,-0.890307 -0.036373,-0.135913 -0.1250717,-0.246717 -0.506083,-0.632208 l -0.4619807,-0.467411 0.00983,-5.002356 0.00983,-5.0023561 0.080405,-0.1739784 C 6.9849846,3.2633288 7.2288893,3.0140593 7.4738043,2.8937849 7.6531903,2.8056908 7.7297209,2.7906977 8,2.7906977 c 0.2702791,0 0.3468097,0.014993 0.5261957,0.1030872 0.244915,0.1202744 0.4888197,0.3695439 0.6027014,0.6159576 0.079998,0.1730976 0.080499,0.1905559 0.09901,3.448397 0.020472,3.6031325 0.00418,3.3665775 0.2478407,3.5980265 0.2810043,0.266918 0.6822132,0.283308 1.0083162,0.04119 0.232339,-0.172501 0.25913,-0.280173 0.275933,-1.1089849 0.01456,-0.7180841 0.01869,-0.7520168 0.117805,-0.9674419 0.454637,-0.9881395 1.789759,-0.9881395 2.244396,0 0.09912,0.2154251 0.103248,0.2493578 0.117805,0.9674419 0.0168,0.8288119 0.04359,0.9364839 0.275933,1.1089849 0.326103,0.242117 0.727312,0.225727 1.008316,-0.04119 0.160426,-0.152384 0.218977,-0.294978 0.250819,-0.610832 C 14.845142,9.2502593 15.336916,8.7840275 16,8.7840275 c 0.478554,0 0.847992,0.2240614 1.082489,0.6565225 l 0.126813,0.2338686 0.01869,0.7813954 c 0.02069,0.865066 0.03258,0.913549 0.276595,1.127795 0.239244,0.210059 0.56665,0.239738 0.88018,0.07979 0.219744,-0.112104 0.324993,-0.301479 0.383515,-0.690054 0.06437,-0.427406 0.125794,-0.56694 0.357358,-0.811785 C 19.38604,9.8862229 19.614832,9.7882106 20,9.7869898 c 0.380153,-0.0012 0.636641,0.1145641 0.905451,0.4086842 0.318537,0.348531 0.317259,0.340596 0.332734,2.064791 0.02055,2.290001 -0.04576,2.983129 -0.383655,4.009983 -0.878739,2.670467 -3.284504,4.613238 -6.090273,4.918188 -0.322415,0.03504 -3.227312,0.04717 -3.564257,0.01488 z" id="path6" /> <path style="fill:#ffffff;stroke-width:0.0705053;stroke-linejoin:round;paint-order:stroke fill markers" d="m 11.942854,21.190957 c -1.015003,-0.01704 -1.131723,-0.02688 -1.806535,-0.1522 C 9.5352183,20.927122 8.8225664,20.681951 8.319624,20.413766 7.7570149,20.113766 7.3758537,19.827607 6.7836127,19.260598 5.774345,18.294328 3.1746828,15.68636 2.994305,15.459184 2.7288345,15.124838 2.6970674,15.049109 2.7026798,14.763988 c 0.00827,-0.420163 0.1162058,-0.679868 0.3844475,-0.925026 0.2382303,-0.217729 0.416008,-0.293073 0.7303102,-0.309513 0.5101451,-0.02668 0.6329728,0.04799 1.5378542,0.934977 0.8479274,0.831158 1.2429087,1.199656 1.342282,1.252283 0.11819,0.06259 0.4442817,0.06081 0.6122724,-0.0033 0.1482348,-0.05661 0.3410696,-0.248342 0.4107195,-0.408368 0.063024,-0.144802 0.06179,-0.498 -0.00216,-0.618376 C 7.6917315,14.63641 7.4736023,14.388937 7.2336742,14.136678 L 6.797441,13.678026 6.7970753,8.6903755 6.7967098,3.7027253 6.9021002,3.502167 C 7.0320375,3.2548956 7.2343175,3.0487286 7.4743519,2.9189189 c 0.1797064,-0.097185 0.1877434,-0.098707 0.5209477,-0.098707 0.3169743,0 0.349151,0.00524 0.5076381,0.082665 0.2190605,0.1070166 0.4871239,0.3748528 0.5931342,0.592632 l 0.081613,0.1676584 0.019992,1.3834579 c 0.010995,0.7609018 0.021403,2.0560783 0.023128,2.87817 0.00341,1.6233162 0.028863,2.2876938 0.093598,2.4426258 0.089047,0.213119 0.4255042,0.419889 0.683247,0.419889 0.1563141,0 0.3731941,-0.08265 0.5187231,-0.197689 0.205546,-0.162474 0.225694,-0.250142 0.256177,-1.1146856 C 10.79418,8.8613623 10.8052,8.7492253 10.85668,8.6186115 11.053264,8.1198873 11.50183,7.7978848 12,7.7978848 c 0.49817,0 0.946736,0.3220025 1.143315,0.8207259 0.05148,0.1306138 0.0625,0.2427508 0.08413,0.8563239 0.02897,0.8216044 0.05497,0.9507864 0.218548,1.0859664 0.341252,0.282005 0.756809,0.293493 1.057036,0.02922 0.169206,-0.148941 0.234219,-0.2921 0.288276,-0.6347773 0.103115,-0.6536616 0.472737,-1.0621772 1.030077,-1.1384664 0.547738,-0.074975 0.986339,0.1608863 1.276145,0.6862578 l 0.105758,0.1917223 7.68e-4,0.3699606 c 0.0011,0.553623 0.04553,1.179579 0.09141,1.289176 0.04428,0.105777 0.219161,0.276182 0.364423,0.355092 0.06913,0.03755 0.155512,0.05067 0.333059,0.05055 0.204058,-1.3e-4 0.260695,-0.01118 0.380729,-0.07426 0.239564,-0.12591 0.320531,-0.265583 0.407786,-0.703455 0.08382,-0.420648 0.125337,-0.527172 0.279883,-0.718174 0.321102,-0.3968443 0.77117,-0.5469022 1.259123,-0.4198065 0.21344,0.055594 0.39756,0.1739295 0.578279,0.3716645 0.286251,0.313205 0.299377,0.389392 0.324444,1.883099 0.02888,1.721047 -0.03379,2.808669 -0.20314,3.525265 -0.307591,1.301561 -0.970113,2.493177 -1.91312,3.440943 -1.060413,1.065767 -2.34115,1.742909 -3.849589,2.035329 -0.348478,0.06755 -0.462014,0.07524 -1.340342,0.09078 -0.527787,0.0093 -1.416154,0.0093 -1.974148,-6.4e-5 z" id="path7" /> </svg>'});class Yl{static _pointerCursor=null;static getPointerCursor(){if(!this._pointerCursor){this._pointerCursor=this.getCursor({iconName:"pointer"})}return this._pointerCursor}static getCursor(t){const e=t.iconName==="default"?"mouse-pointer":t.iconName;const i=zl.get(e);if(!i){console.warn(`Icon "${e}" not found in registry.`);return"auto"}const s=t.size||24;const n=t.rotation||0;const r=t.color||"black";const o=t.hotspot||(t.iconName==="default"?{x:4,y:4}:{x:s/2,y:s/2});let h=i.replace(/width="\d+"/,`width="${s}"`).replace(/height="\d+"/,`height="${s}"`).replace(/currentColor/g,r);const l=s/2;const f=`\n <svg xmlns="http://www.w3.org/2000/svg" width="${s}" height="${s}" viewBox="0 0 ${s} ${s}">\n <g transform="rotate(${n} ${l} ${l})">\n ${h}\n </g>\n </svg>\n `;const u=encodeURIComponent(f.replace(/\s+/g," ").trim()).replace(/'/g,"%27").replace(/"/g,"%22");const c=`data:image/svg+xml;charset=utf-8,${u}`;return`url('${c}') ${o.x} ${o.y}, auto`}}class Xl{_core;constructor(t){this._core=t}}const Wl=30;class Jl extends Xl{dragStartX;dragStartY;startX;startY;endX;endY;initialDragX=0;initialDragY=0;disconnectedLineIds=new Set;hasMoved=false;trackedPointerId=null;constructor(t){super(t)}reset(){this.dragStartX=0;this.dragStartY=0;this.startX=0;this.startY=0;this.endX=0;this.endY=0;this.initialDragX=0;this.initialDragY=0;this.disconnectedLineIds.clear();this.hasMoved=false;this.trackedPointerId=null}cancelPendingDrag(){this._core.store.state.isDragging=false;this.reset()}handlePointerDown(t){if(t.pointerType==="mouse"){if(Zh.isLeftClick(t)){const e=this._core.store.selectionGroup;if(e?.isSelected&&!this._core.store.state.isResizeHandleSelected&&!this._core.store.state.isRotationHandleSelected&&!this._core.store.state.isLineHandleSelected){const e=t.clientX-this._core.store.offsetX;const i=t.clientY-this._core.store.offsetY;this._core.store.state.isDragging=true;this.dragStartX=e;this.dragStartY=i;this.startX=this.dragStartX;this.startY=this.dragStartY;this.initialDragX=e;this.initialDragY=i;this.disconnectedLineIds.clear();this.trackedPointerId=t.pointerId}else{this.trackedPointerId=null}}else{this.trackedPointerId=null}}if(t.pointerType==="touch"){const e=Array.from(this._core.store.state.pointers.values());if(this._core.store.state.pointers.size===1){if(this._core.store.state.isScaling){this.trackedPointerId=null;return}const i=this._core.store.selectionGroup;if(i?.isSelected&&!this._core.store.state.isResizeHandleSelected&&!this._core.store.state.isRotationHandleSelected&&!this._core.store.state.isLineHandleSelected){const i=Math.round(e[0].clientX-this._core.store.offsetX);const s=Math.round(e[0].clientY-this._core.store.offsetY);this.dragStartX=i;this.dragStartY=s;this.startX=i;this.startY=s;this.initialDragX=i;this.initialDragY=s;this.disconnectedLineIds.clear();this.trackedPointerId=t.pointerId}else{this.trackedPointerId=null}}}}handlePointerMove(t){if(this.trackedPointerId===null||this.trackedPointerId!==t.pointerId){return}if(t.pointerType==="mouse"){const e=this._core.store.selectionGroup;if(this._core.store.state.isDragging&&e){const i=t.clientX-this._core.store.offsetX;const s=t.clientY-this._core.store.offsetY;this.endX=i;this.endY=s;const n=Math.abs(i-this.startX);const r=Math.abs(s-this.startY);const o=5;if(n>o||r>o){this.checkAndDisconnectAnchors(i,s);e.move(i,s,this.dragStartX,this.dragStartY);this.dragStartX=i;this.dragStartY=s;this.hasMoved=true}}}if(t.pointerType==="touch"){const t=Array.from(this._core.store.state.pointers.values());const e=this._core.store.selectionGroup;if(this._core.store.state.pointers.size===1&&e&&!this._core.store.state.isResizeHandleSelected&&!this._core.store.state.isRotationHandleSelected&&!this._core.store.state.isScaling){const i=Math.round(t[0].clientX-this._core.store.offsetX);const s=Math.round(t[0].clientY-this._core.store.offsetY);this._core.store.state.isDragging=true;this.endX=i;this.endY=s;const n=Math.abs(i-this.startX);const r=Math.abs(s-this.startY);const o=5;if(n>o||r>o){clearTimeout(this._core.store.state.longTouchTimeout);this.checkAndDisconnectAnchors(i,s);e.move(i,s,this.dragStartX,this.dragStartY);this.dragStartX=i;this.dragStartY=s;this.hasMoved=true}}}}handlePointerUp(t){if(this.trackedPointerId===null||this.trackedPointerId!==t.pointerId){return}if(t.pointerType==="mouse"){if(this._core.store.state.isDragging){this._core.store.state.isDragging=false;if(this.hasMoved){this._core.store.selectionGroup.update();this._core.engine.emitObjectsChange();this._core.store.state.hasObjectsChanged=true}}}if(t.pointerType==="touch"){if(this._core.store.state.isDragging){this._core.store.state.isDragging=false;if(this.hasMoved){this._core.store.selectionGroup.update();this._core.engine.emitObjectsChange();this._core.store.state.hasObjectsChanged=true}}}this.reset()}checkAndDisconnectAnchors(t,e){const i=t-this.initialDragX;const s=e-this.initialDragY;const n=Math.sqrt(i*i+s*s);if(n<Wl){return}const r=this._core.store.selectionGroup;if(!r){return}for(const t of r.objects){if(this.disconnectedLineIds.has(t.id)){continue}if(t instanceof qh){const e=t;const i=e.startAnchor||e.endAnchor;if(i){if(e.startAnchor){this._core.anchorManager.removeAnchor(e.id,"start")}if(e.endAnchor){this._core.anchorManager.removeAnchor(e.id,"end")}this.disconnectedLineIds.add(e.id);this._core.store.state.objects.update(e)}}}}}var Hl;(function(t){t["TopLeft"]="top-left";t["TopRight"]="top-right";t["BottomLeft"]="bottom-left";t["BottomRight"]="bottom-right"})(Hl||(Hl={}));class Vl extends Xl{initialMouseX=0;initialMouseY=0;initialSize={x:0,y:0,width:0,height:0};newSize={x:0,y:0,width:0,height:0};hasResized=false;constructor(t){super(t)}reset(){this.initialMouseX=0;this.initialMouseY=0;this.initialSize={x:0,y:0,width:0,height:0};this.newSize={x:0,y:0,width:0,height:0};this.hasResized=false}handlePointerDown(t){if(t.pointerType==="mouse"){if(Zh.isLeftClick(t)){const e=this._core.store.selectionGroup;if(e&&this._core.store.state.isResizeHandleSelected){const i=t.clientX-this._core.store.offsetX;const s=t.clientY-this._core.store.offsetY;this._core.store.state.isResizing=true;this.initialMouseX=i;this.initialMouseY=s;this.initialSize.width=e.width;this.initialSize.height=e.height;this.initialSize.x=e.translateX;this.initialSize.y=e.translateY}}}if(t.pointerType==="touch"){const t=Array.from(this._core.store.state.pointers.values());const e=t[0];if(!e){return}if(t.length===1){const t=this._core.store.selectionGroup;if(t&&this._core.store.state.isResizeHandleSelected){const i=Math.round(e.clientX-this._core.store.offsetX);const s=Math.round(e.clientY-this._core.store.offsetY);this._core.store.state.isResizing=true;this.initialMouseX=i;this.initialMouseY=s;this.initialSize.width=t.width;this.initialSize.height=t.height;this.initialSize.x=t.translateX;this.initialSize.y=t.translateY;clearTimeout(this._core.store.state.longTouchTimeout)}}}}handlePointerMove(t){if(t.pointerType==="mouse"){const e=this._core.store.selectionGroup;if(this._core.store.state.isResizing&&e){const i=t.clientX-this._core.store.offsetX;const s=t.clientY-this._core.store.offsetY;const n=i-this.initialMouseX;const r=s-this.initialMouseY;const o=Math.abs(n);const h=Math.abs(r);const l=5;if(o>l||h>l){this.hasResized=true}if(!this.hasResized){return}const f=e.rotation;const u=Math.sin(f);const c=Math.cos(f);const a=e.scale||1;const d=this._core.store.state.scale;const w=(n*c+r*u)/d;const p=(-n*u+r*c)/d;const g=this.initialSize.x+this.initialSize.width/a/2;const m=this.initialSize.y+this.initialSize.height/a/2;const y=g+n/d/2;const v=m+r/d/2;switch(this._core.store.state.resizeHandleType){case Hl.TopLeft:this.newSize.width=this.initialSize.width-w*a;this.newSize.height=this.initialSize.height-p*a;break;case Hl.TopRight:this.newSize.width=this.initialSize.width+w*a;this.newSize.height=this.initialSize.height-p*a;break;case Hl.BottomLeft:this.newSize.width=this.initialSize.width-w*a;this.newSize.height=this.initialSize.height+p*a;break;case Hl.BottomRight:this.newSize.width=this.initialSize.width+w*a;this.newSize.height=this.initialSize.height+p*a;break}this.newSize.x=y-this.newSize.width/a/2;this.newSize.y=v-this.newSize.height/a/2;e.resize(this.newSize.x,this.newSize.y,this.newSize.width,this.newSize.height)}}if(t.pointerType==="touch"){const t=Array.from(this._core.store.state.pointers.values());const e=t[0];if(!e){return}const i=this._core.store.selectionGroup;if(this._core.store.state.isResizing&&i){const t=Math.round(e.clientX-this._core.store.offsetX);const s=Math.round(e.clientY-this._core.store.offsetY);const n=t-this.initialMouseX;const r=s-this.initialMouseY;const o=Math.abs(n);const h=Math.abs(r);const l=5;if(o>l||h>l){clearTimeout(this._core.store.state.longTouchTimeout);this.hasResized=true}if(!this.hasResized){return}const f=i.rotation;const u=Math.sin(f);const c=Math.cos(f);const a=i.scale||1;const d=this._core.store.state.scale;const w=(n*c+r*u)/d;const p=(-n*u+r*c)/d;const g=this.initialSize.x+this.initialSize.width/a/2;const m=this.initialSize.y+this.initialSize.height/a/2;const y=g+n/d/2;const v=m+r/d/2;switch(this._core.store.state.resizeHandleType){case Hl.TopLeft:this.newSize.width=this.initialSize.width-w*a;this.newSize.height=this.initialSize.height-p*a;break;case Hl.TopRight:this.newSize.width=this.initialSize.width+w*a;this.newSize.height=this.initialSize.height-p*a;break;case Hl.BottomLeft:this.newSize.width=this.initialSize.width-w*a;this.newSize.height=this.initialSize.height+p*a;break;case Hl.BottomRight:this.newSize.width=this.initialSize.width+w*a;this.newSize.height=this.initialSize.height+p*a;break}this.newSize.x=y-this.newSize.width/a/2;this.newSize.y=v-this.newSize.height/a/2;i.resize(this.newSize.x,this.newSize.y,this.newSize.width,this.newSize.height)}}}handlePointerUp(t){if(t.pointerType==="mouse"){if(this._core.store.state.isResizing){this._core.store.state.isResizing=false;if(this.hasResized){this._core.store.selectionGroup.update();this._core.engine.emitObjectsChange();this._core.store.state.hasObjectsChanged=true}this.reset()}}if(t.pointerType==="touch"){if(this._core.store.state.isResizing){this._core.store.state.isResizing=false;if(this.hasResized){this._core.store.selectionGroup.update();this._core.engine.emitObjectsChange();this._core.store.state.hasObjectsChanged=true}this.reset();clearTimeout(this._core.store.state.longTouchTimeout)}}}}class Ql extends Xl{initialRotation=0;rotation=0;unchangedObjects=[];initialSelectionGroupRotation=0;constructor(t){super(t)}reset(){this.initialRotation=0;this.rotation=0;this.unchangedObjects=[]}handlePointerDown(t){if(t.pointerType==="mouse"){if(Zh.isLeftClick(t)){const e=this._core.store.selectionGroup;if(e&&this._core.store.state.isRotationHandleSelected){e.beginTransform();const i=t.clientX-this._core.store.offsetX;const s=t.clientY-this._core.store.offsetY;this._core.store.state.isRotating=true;const n=e.scale||1;const r=e.translateX+e.width/2/n;const o=e.translateY+e.height/2/n;const h=(i-this._core.store.state.translateX)/this._core.store.state.scale;const l=(s-this._core.store.state.translateY)/this._core.store.state.scale;this.initialSelectionGroupRotation=e.rotation;this.initialRotation=Math.atan2(o-l,r-h)-e.rotation;this.unchangedObjects=e.objects.map((t=>t.clone()))}}}if(t.pointerType==="touch"){const t=Array.from(this._core.store.state.pointers.values());const e=t[0];if(!e){return}if(t.length===1){const t=this._core.store.selectionGroup;if(t&&this._core.store.state.isRotationHandleSelected){t.beginTransform();const i=Math.round(e.clientX-this._core.store.offsetX);const s=Math.round(e.clientY-this._core.store.offsetY);this._core.store.state.isRotating=true;const n=t.scale||1;const r=t.translateX+t.width/2/n;const o=t.translateY+t.height/2/n;const h=(i-this._core.store.state.translateX)/this._core.store.state.scale;const l=(s-this._core.store.state.translateY)/this._core.store.state.scale;this.initialSelectionGroupRotation=t.rotation;this.initialRotation=Math.atan2(o-l,r-h)-t.rotation;this.unchangedObjects=t.objects.map((t=>t.clone()));clearTimeout(this._core.store.state.longTouchTimeout)}}}}handlePointerMove(t){if(t.pointerType==="mouse"){const e=this._core.store.selectionGroup;if(this._core.store.state.isRotating&&e){const i=t.clientX-this._core.store.offsetX;const s=t.clientY-this._core.store.offsetY;const n=e.scale||1;const r=e.translateX+e.width/2/n;const o=e.translateY+e.height/2/n;const h=(i-this._core.store.state.translateX)/this._core.store.state.scale;const l=(s-this._core.store.state.translateY)/this._core.store.state.scale;const f=Math.atan2(o-l,r-h);this.rotation=f-this.initialRotation;e.rotate(this.rotation)}}if(t.pointerType==="touch"){const t=Array.from(this._core.store.state.pointers.values());const e=t[0];if(!e){return}const i=this._core.store.selectionGroup;if(this._core.store.state.isRotating&&i){const t=Math.round(e.clientX-this._core.store.offsetX);const s=Math.round(e.clientY-this._core.store.offsetY);const n=i.scale||1;const r=i.translateX+i.width/2/n;const o=i.translateY+i.height/2/n;const h=(t-this._core.store.state.translateX)/this._core.store.state.scale;const l=(s-this._core.store.state.translateY)/this._core.store.state.scale;const f=Math.atan2(o-l,r-h);this.rotation=f-this.initialRotation;i.rotate(this.rotation);clearTimeout(this._core.store.state.longTouchTimeout)}}}handlePointerUp(t){if(t.pointerType==="mouse"){if(this._core.store.state.isRotating){this._core.store.selectionGroup.update();this._core.engine.emitObjectsChange();this._core.store.state.isRotating=false;this._core.store.state.hasObjectsChanged=true;this.reset()}}if(t.pointerType==="touch"){if(this._core.store.state.isRotating){this._core.store.selectionGroup.update();this._core.engine.emitObjectsChange();this._core.store.state.isRotating=false;this._core.store.state.hasObjectsChanged=true;this.reset();clearTimeout(this._core.store.state.longTouchTimeout)}}}}class ql extends s{__class__="KritzelSelectionBox";static create(t){const e=new ql;e._core=t;e.id=e.generateId();e.workspaceId=t.store.state.activeWorkspace.id;e.scale=t.store.state.scale;e.zIndex=99999;e.backgroundColor="var(--kritzel-selection-box-background-color, rgba(0, 122, 255, 0.2))";e.borderColor="var(--kritzel-selection-box-border-color, rgba(0, 122, 255, 0.5))";e.borderWidth=2;e.height=0;e.width=0;return e}}class Kl extends Xl{startX;startY;touchStartX=0;touchStartY=0;touchStartTimeout=null;get isSelectionClick(){const t=this._core.store.selectionBox;return t&&t.width===0&&t.height===0}get isSelectionDrag(){const t=this._core.store.selectionBox;return t&&(t.width>0||t.height>0)}constructor(t){super(t)}handlePointerDown(t){if(t.pointerType==="mouse"){if(Zh.isLeftClick(t)&&!this._core.store.selectionGroup){this.startMouseSelection(t)}}if(t.pointerType==="touch"){this.touchStartTimeout=setTimeout((()=>{if(this._core.store.state.pointers.size===1&&!this._core.store.state.isScaling&&!this._core.store.selectionGroup){this.startTouchSelection();this.updateTouchSelection()}}),80)}}handlePointerMove(t){if(t.pointerType==="mouse"){if(this._core.store.state.isSelecting){this.updateMouseSelection(t)}}if(t.pointerType==="touch"){const t=Array.from(this._core.store.state.pointers.values());const e=Math.round(t[0].clientX-this._core.store.offsetX);const i=Math.round(t[0].clientY-this._core.store.offsetY);const s=Math.abs(e-this.touchStartX);const n=Math.abs(i-this.touchStartY);const r=5;if((s>r||n>r)&&this._core.store.state.isSelecting){this.updateTouchSelection();clearTimeout(this._core.store.state.longTouchTimeout)}}}handlePointerUp(t){if(t.pointerType==="mouse"){if(Zh.isLeftClick(t)){const e=this._core.store.state.hasObjectsChanged;const i=this._core.store.selectionGroup;if(i?.objects.length===1&&e===false){i.objects[0].edit(t)}this._core.store.state.hasObjectsChanged=false;if(this._core.store.state.isSelecting){if(this.isSelectionClick){this.handleSelectionClick(t)}if(this.isSelectionDrag){this.updateMouseSelection(t);this.addSelectedObjectsToSelectionGroup();this.removeSelectionBox()}this._core.engine.emitObjectsChange()}}}if(t.pointerType==="touch"){clearTimeout(this.touchStartTimeout);const e=this._core.store.state.hasObjectsChanged;const i=this._core.store.selectionGroup;if(i?.objects.length===1&&e===false){i.objects[0].edit(t)}this._core.store.state.hasObjectsChanged=false;if(this._core.store.state.isSelecting){if(this.isSelectionClick){this.handleSelectionClick(t)}if(this.isSelectionDrag){this.updateTouchSelection();this.addSelectedObjectsToSelectionGroup();this.removeSelectionBox()}this._core.engine.emitObjectsChange();this._core.store.state.skipContextMenu=false}}}removeSelectionBox(){this._core.store.state.isSelecting=false;this._core.store.state.objects.remove((t=>t instanceof ql))}startMouseSelection(t){let e,i;e=t.clientX-this._core.store.offsetX;i=t.clientY-this._core.store.offsetY;const s=ql.create(this._core);this.startX=(e-this._core.store.state.translateX)/this._core.store.state.scale;this.startY=(i-this._core.store.state.translateY)/this._core.store.state.scale;s.translateX=this.startX;s.translateY=this.startY;this._core.store.state.isSelecting=true;this._core.store.state.objects.remove((t=>t instanceof ql||t instanceof il));this._core.store.state.objects.insert(s)}startTouchSelection(){const t=Array.from(this._core.store.state.pointers.values());const e=t[0];if(!e){return}let i,s;i=Math.round(e.clientX-this._core.store.offsetX);s=Math.round(e.clientY-this._core.store.offsetY);this.touchStartX=i;this.touchStartY=s;const n=ql.create(this._core);this.startX=(i-this._core.store.state.translateX)/this._core.store.state.scale;this.startY=(s-this._core.store.state.translateY)/this._core.store.state.scale;n.translateX=this.startX;n.translateY=this.startY;this._core.store.state.isSelecting=true;this._core.store.state.objects.remove((t=>t instanceof ql||t instanceof il));this._core.store.state.objects.insert(n)}updateMouseSelection(t){let e,i;e=t.clientX-this._core.store.offsetX;i=t.clientY-this._core.store.offsetY;const s=this._core.store.selectionBox;if(s){const t=(e-this._core.store.state.translateX)/s.scale;const n=(i-this._core.store.state.translateY)/s.scale;const r=Math.abs(t-this.startX)*s.scale;const o=Math.abs(n-this.startY)*s.scale;s.width=r;s.height=o;s.translateX=Math.min(t,this.startX);s.translateY=Math.min(n,this.startY);if(r>0||o>0){this.updateSelectedObjects()}else{this.clearSelectionPreview()}}}updateTouchSelection(){const t=Array.from(this._core.store.state.pointers.values());const e=t[0];if(!e){return}let i,s;i=Math.round(e.clientX-this._core.store.offsetX);s=Math.round(e.clientY-this._core.store.offsetY);const n=this._core.store.selectionBox;if(n){const t=(i-this._core.store.state.translateX)/n.scale;const e=(s-this._core.store.state.translateY)/n.scale;const r=Math.abs(t-this.startX)*n.scale;const o=Math.abs(e-this.startY)*n.scale;n.width=r;n.height=o;n.translateX=Math.min(t,this.startX);n.translateY=Math.min(e,this.startY);if(r>0||o>0){this.updateSelectedObjects()}else{this.clearSelectionPreview()}}}updateSelectedObjects(){const t=this._core.store.selectionBox;if(t){this._core.store.allObjects.filter((t=>!(t instanceof ql))).forEach((e=>e.isSelected=e.hitTestPolygon(t.rotatedPolygon)))}}handleSelectionClick(t){const e=this.getTopmostHitObject(t);this.clearSelectionPreview();this.addObjectToSelectionGroup(e);this.removeSelectionBox()}getTopmostHitObject(t){const e=this._core.store.state.pointerX;const i=this._core.store.state.pointerY;const s=this._core.getObjectsFromPointerEvent(t,".object");for(const t of s){if(t.hitTest(e,i)){return t}}return null}clearSelectionPreview(){this._core.store.allNonSelectionObjects.forEach((t=>{t.isSelected=false}))}addObjectToSelectionGroup(t){if(!t){return}const e=Kh.findParentGroup(this._core,t.id);const i=e||t;i.isSelected=false;const s=il.create(this._core);s.addOrRemove(i);s.isSelected=true;s.rotation=i.rotation;this._core.addSelectionGroup(s);this._core.rerender()}addSelectedObjectsToSelectionGroup(){const t=this._core.store.selectedObjects;if(t.length===0){return}const e=new Map;t.forEach((t=>{const i=Kh.findParentGroup(this._core,t.id);if(i){e.set(i.id,i)}else{e.set(t.id,t)}t.isSelected=false}));const i=il.create(this._core);e.forEach((t=>{i.addOrRemove(t)}));i.isSelected=true;if(i.length===1){i.rotation=i.objects[0].rotation}this._core.addSelectionGroup(i);this._core.rerender()}}class Gl extends Xl{constructor(t){super(t)}handlePointerMove(t){if(t.pointerType==="mouse"){const e=this._core.getObjectFromPointerEvent(t,".object");if(!e)return;const i=this._core.store.state.pointerX;const s=this._core.store.state.pointerY;e.isHovered=e.hitTest(i,s)}}}class Zl extends Xl{initialMouseX=0;initialMouseY=0;initialStartX=0;initialStartY=0;initialEndX=0;initialEndY=0;initialControlX;initialControlY;initialTranslateX=0;initialTranslateY=0;hasMoved=false;currentSnapTarget=null;constructor(t){super(t)}reset(){this.initialMouseX=0;this.initialMouseY=0;this.initialStartX=0;this.initialStartY=0;this.initialEndX=0;this.initialEndY=0;this.initialControlX=undefined;this.initialControlY=undefined;this.initialTranslateX=0;this.initialTranslateY=0;this.hasMoved=false;this.currentSnapTarget=null;this._core.anchorManager.clearSnapCandidate()}handlePointerDown(t){if(t.pointerType==="mouse"){if(Zh.isLeftClick(t)){this.startHandleDrag(t)}}if(t.pointerType==="touch"){const e=Array.from(this._core.store.state.pointers.values());if(e.length===1){this.startHandleDrag(t)}}}startHandleDrag(t){const e=this.getSelectedLine();if(!e||!this._core.store.state.isLineHandleSelected){return}const i=t.clientX-this._core.store.offsetX;const s=t.clientY-this._core.store.offsetY;this._core.store.state.isLineHandleDragging=true;this.initialMouseX=i;this.initialMouseY=s;this.initialStartX=e.startX;this.initialStartY=e.startY;this.initialEndX=e.endX;this.initialEndY=e.endY;this.initialControlX=e.controlX;this.initialControlY=e.controlY;this.initialTranslateX=e.translateX;this.initialTranslateY=e.translateY;const n=this._core.store.state.lineHandleType;if(n==="start"||n==="end"){this._core.anchorManager.removeAnchor(e.id,n)}clearTimeout(this._core.store.state.longTouchTimeout)}handlePointerMove(t){const e=this.getSelectedLine();if(!e||!this._core.store.state.isLineHandleDragging){return}const i=t.clientX-this._core.store.offsetX;const s=t.clientY-this._core.store.offsetY;const n=i-this.initialMouseX;const r=s-this.initialMouseY;const o=3;if(Math.abs(n)>o||Math.abs(r)>o){this.hasMoved=true}if(!this.hasMoved){return}const h=this._core.store.state.scale;const l=e.scale||1;const f=e.rotation;const u=n/h;const c=r/h;const a=Math.cos(-f);const d=Math.sin(-f);const w=(u*a-c*d)*l;const p=(u*d+c*a)*l;const g=this._core.store.state.lineHandleType;if(g==="start"){const t=(i-this._core.store.state.translateX)/h;const n=(s-this._core.store.state.translateY)/h;const r=e.endAnchor?.objectId;const o=this._core.anchorManager.findSnapTarget(t,n,e.id,r);this.currentSnapTarget=o;if(o){const t=this.worldToLineLocal(e,o.centerX,o.centerY);this.updateLineEndpoint(e,t.x,t.y,this.initialEndX,this.initialEndY);const i=this.lineLocalToWorld(e,this.initialEndX,this.initialEndY);const s=this._core.store.allNonSelectionObjects.find((t=>t.id===o.objectId));let n;let r;let h;if(s){const t=this._core.anchorManager.computeAnchorClipInfo(e,"start",s);if(t){n=t.worldX;r=t.worldY;h=t.t}}let l=undefined;if(e.controlX!==undefined&&e.controlY!==undefined){l=this.lineLocalToWorld(e,e.controlX,e.controlY)}this._core.anchorManager.setSnapCandidate({objectId:o.objectId,endpoint:"start",centerX:o.centerX,centerY:o.centerY,lineEndpointX:i.x,lineEndpointY:i.y,controlX:l?.x,controlY:l?.y,t:h,edgeX:n,edgeY:r,lineStroke:e.stroke,lineStrokeWidth:e.strokeWidth/e.scale,arrowOffset:e.hasStartArrow?e.getArrowSize("start")/e.scale:undefined,arrowStyle:e.hasStartArrow?e.arrows?.start?.style:undefined,arrowFill:e.hasStartArrow?e.getArrowFill("start"):undefined})}else{const t=this.initialStartX+w;const i=this.initialStartY+p;this.updateLineEndpoint(e,t,i,this.initialEndX,this.initialEndY);this._core.anchorManager.clearSnapCandidate()}}else if(g==="end"){const t=(i-this._core.store.state.translateX)/h;const n=(s-this._core.store.state.translateY)/h;const r=e.startAnchor?.objectId;const o=this._core.anchorManager.findSnapTarget(t,n,e.id,r);this.currentSnapTarget=o;if(o){const t=this.worldToLineLocal(e,o.centerX,o.centerY);this.updateLineEndpoint(e,this.initialStartX,this.initialStartY,t.x,t.y);const i=this.lineLocalToWorld(e,this.initialStartX,this.initialStartY);const s=this._core.store.allNonSelectionObjects.find((t=>t.id===o.objectId));let n;let r;let h;if(s){const t=this._core.anchorManager.computeAnchorClipInfo(e,"end",s);if(t){n=t.worldX;r=t.worldY;h=t.t}}let l=undefined;if(e.controlX!==undefined&&e.controlY!==undefined){l=this.lineLocalToWorld(e,e.controlX,e.controlY)}this._core.anchorManager.setSnapCandidate({objectId:o.objectId,endpoint:"end",centerX:o.centerX,centerY:o.centerY,lineEndpointX:i.x,lineEndpointY:i.y,controlX:l?.x,controlY:l?.y,t:h,edgeX:n,edgeY:r,lineStroke:e.stroke,lineStrokeWidth:e.strokeWidth/e.scale,arrowOffset:e.hasEndArrow?e.getArrowSize("end")/e.scale:undefined,arrowStyle:e.hasEndArrow?e.arrows?.end?.style:undefined,arrowFill:e.hasEndArrow?e.getArrowFill("end"):undefined})}else{const t=this.initialEndX+w;const i=this.initialEndY+p;this.updateLineEndpoint(e,this.initialStartX,this.initialStartY,t,i);this._core.anchorManager.clearSnapCandidate()}}else if(g==="center"){const t=this.initialControlX??(this.initialStartX+this.initialEndX)/2;const i=this.initialControlY??(this.initialStartY+this.initialEndY)/2;const s=t+w*2;const n=i+p*2;const r=e.startX;const o=e.startY;const h=e.endX;const l=e.endY;const f=s-r;const u=n-o;const c=h-r;const a=l-o;const d=f*c+u*a;const g=c*c+a*a;let m=-1;if(g!==0){m=d/g}let y,v;if(m<0){y=r;v=o}else if(m>1){y=h;v=l}else{y=r+m*c;v=o+m*a}const b=s-y;const M=n-v;const k=Math.sqrt(b*b+M*M);const A=15;if(k<A){e.updateControlPoint(undefined,undefined)}else{e.updateControlPoint(s,n)}}this._core.rerender()}worldToLineLocal(t,e,i){const s=(e-t.translateX)*t.scale;const n=(i-t.translateY)*t.scale;const r=t.totalWidth/2;const o=t.totalHeight/2;const h=Math.cos(-t.rotation);const l=Math.sin(-t.rotation);const f=(s-r)*h-(n-o)*l+r;const u=(s-r)*l+(n-o)*h+o;return{x:f+t.x,y:u+t.y}}lineLocalToWorld(t,e,i){const s=e-t.x;const n=i-t.y;const r=t.totalWidth/2;const o=t.totalHeight/2;const h=Math.cos(t.rotation);const l=Math.sin(t.rotation);const f=(s-r)*h-(n-o)*l+r;const u=(s-r)*l+(n-o)*h+o;return{x:f/t.scale+t.translateX,y:u/t.scale+t.translateY}}updateLineEndpoint(t,e,i,s,n){const{minX:r,minY:o,maxX:h,maxY:l}=qh.calculateBoundingBox(e,i,s,n,t.controlX,t.controlY,t.strokeWidth);const f=h-r;const u=l-o;const{minX:c,minY:a,maxX:d,maxY:w}=qh.calculateBoundingBox(this.initialStartX,this.initialStartY,this.initialEndX,this.initialEndY,this.initialControlX,this.initialControlY,t.strokeWidth);const p=d-c;const g=w-a;const m=r-c;const y=o-a;const v=m+(f-p)/2;const b=y+(u-g)/2;const M=t.rotation;const k=Math.cos(M);const A=Math.sin(M);const x=1/t.scale;const S=v*k-b*A;const C=v*A+b*k;const O=this.initialTranslateX+x*(p-f)/2+x*S;const E=this.initialTranslateY+x*(g-u)/2+x*C;t.startX=e;t.startY=i;t.endX=s;t.endY=n;t.x=r;t.y=o;t.width=f;t.height=u;t.translateX=O;t.translateY=E;t._adjustedPoints=null;this._core.store.state.objects.update(t)}handlePointerUp(t){if(this._core.store.state.isLineHandleDragging){const t=this.getSelectedLine();const e=this._core.store.state.lineHandleType;if(t&&this.hasMoved){if(this.currentSnapTarget&&(e==="start"||e==="end")){this._core.anchorManager.setAnchor(t.id,e,this.currentSnapTarget.objectId)}const i=this._core.store.selectionGroup;if(i){i.refreshObjectDimensions();i.update();this._core.engine.emitObjectsChange();this._core.store.state.hasObjectsChanged=true}}this._core.store.state.isLineHandleDragging=false;this.reset();this._core.rerender()}}getSelectedLine(){const t=this._core.store.selectionGroup;if(!t||t.objects.length!==1){return null}const e=t.objects[0];if(e instanceof qh){return e}return null}}class tf extends tl{selectionHandler;moveHandler;hoverHandler;resizeHandler;rotationHandler;lineHandleHandler;constructor(t){super(t);this.selectionHandler=new Kl(this._core);this.moveHandler=new Jl(this._core);this.hoverHandler=new Gl(this._core);this.resizeHandler=new Vl(this._core);this.rotationHandler=new Ql(this._core);this.lineHandleHandler=new Zl(this._core)}handlePointerDown(t){if(t.cancelable){t.preventDefault()}if(t.pointerType==="mouse"){if(Zh.isLeftClick(t)){this._core.store.state.isResizeHandleSelected=this.isHandleSelected(t);this._core.store.state.isRotationHandleSelected=this.isRotationHandleSelected(t);this._core.store.state.isLineHandleSelected=this.isLineHandleSelected(t);this._core.store.state.resizeHandleType=this.getHandleType(t);this._core.store.state.lineHandleType=this.getLineHandleType(t);const e=this.getSelectedObject(t);const i=this._core.store.selectionGroup;const s=e&&i&&e.id!==i.id;if((e===null||s)&&i&&!this._core.store.state.isResizeHandleSelected&&!this._core.store.state.isRotationHandleSelected&&!this._core.store.state.isLineHandleSelected){this._core.removeSelectionGroup();this._core.rerender()}if(e&&e.isSelected===false&&e?.objects.length===1&&e.objects[0].isInteractive){return}}this.lineHandleHandler.handlePointerDown(t);this.moveHandler.handlePointerDown(t);this.selectionHandler.handlePointerDown(t);this.resizeHandler.handlePointerDown(t);this.rotationHandler.handlePointerDown(t);this._core.rerender()}if(t.pointerType==="touch"){if(this._core.store.state.isScaling===true){return}if(this._core.store.state.pointers.size===1){this._core.store.state.isResizeHandleSelected=this.isHandleSelected(t);this._core.store.state.isRotationHandleSelected=this.isRotationHandleSelected(t);this._core.store.state.isLineHandleSelected=this.isLineHandleSelected(t);this._core.store.state.resizeHandleType=this.getHandleType(t);this._core.store.state.lineHandleType=this.getLineHandleType(t);const e=this.getSelectedObject(t);const i=this._core.store.selectionGroup;const s=e&&i&&e.id!==i.id;if(!i&&e){this._core.store.state.skipContextMenu=true}if((e===null||s)&&i&&!this._core.store.state.isResizeHandleSelected&&!this._core.store.state.isRotationHandleSelected&&!this._core.store.state.isLineHandleSelected){this._core.removeSelectionGroup();this._core.rerender()}}this.lineHandleHandler.handlePointerDown(t);this.rotationHandler.handlePointerDown(t);this.resizeHandler.handlePointerDown(t);this.moveHandler.handlePointerDown(t);this.selectionHandler.handlePointerDown(t);this._core.rerender()}}handlePointerMove(t){if(t.cancelable){t.preventDefault()}if(t.pointerType==="mouse"){this.lineHandleHandler.handlePointerMove(t);this.moveHandler.handlePointerMove(t);this.hoverHandler.handlePointerMove(t);this.selectionHandler.handlePointerMove(t);this.resizeHandler.handlePointerMove(t);this.rotationHandler.handlePointerMove(t);this._core.rerender()}if(t.pointerType==="touch"){if(this._core.store.state.isScaling===true){return}this.lineHandleHandler.handlePointerMove(t);this.rotationHandler.handlePointerMove(t);this.resizeHandler.handlePointerMove(t);this.moveHandler.handlePointerMove(t);this.selectionHandler.handlePointerMove(t);this._core.rerender()}}handlePointerUp(t){if(t.cancelable){t.preventDefault()}if(t.pointerType==="mouse"){this.lineHandleHandler.handlePointerUp(t);this.moveHandler.handlePointerUp(t);this.resizeHandler.handlePointerUp(t);this.rotationHandler.handlePointerUp(t);this.selectionHandler.handlePointerUp(t);this._core.rerender()}if(t.pointerType==="touch"){if(this._core.store.state.isScaling===true){return}this.lineHandleHandler.handlePointerUp(t);this.rotationHandler.handlePointerUp(t);this.resizeHandler.handlePointerUp(t);this.moveHandler.handlePointerUp(t);this.selectionHandler.handlePointerUp(t);this._core.rerender()}}getSelectedObject(t){const e=t.composedPath().slice(1);const i=e.find((t=>t.classList&&t.classList.contains("object")));const s=this._core.findObjectById(i?.id);if(!s){return null}const{x:n,y:r}=this._core.getCanvasPoint(t);if(!s.hitTest(n,r)){return null}if(s instanceof il){return s}else{const t=il.create(this._core);t.translateX=0;t.translateY=0;t.addOrRemove(s);return t}}getHandleType(t){const e=this._core.store.state.host?.shadowRoot;if(!e)return;const i=e.elementsFromPoint(t.clientX,t.clientY);const s=i.find((t=>t.classList.contains("resize-handle-overlay")));return s?.classList[1]}isHandleSelected(t){const e=this._core.store.state.host?.shadowRoot;if(!e)return false;const i=e.elementsFromPoint(t.clientX,t.clientY);return i.some((t=>t.classList.contains("resize-handle-overlay")))}isRotationHandleSelected(t){const e=this._core.store.state.host?.shadowRoot;if(!e)return false;const i=e.elementsFromPoint(t.clientX,t.clientY);return i.some((t=>t.classList.contains("rotation-handle-overlay")))}isLineHandleSelected(t){const e=this._core.store.state.host?.shadowRoot;if(!e)return false;const i=e.elementsFromPoint(t.clientX,t.clientY);return i.some((t=>t.classList.contains("selection-line-handle-overlay")))}getLineHandleType(t){const e=this._core.store.state.host?.shadowRoot;if(!e)return;const i=e.elementsFromPoint(t.clientX,t.clientY);const s=i.find((t=>t.classList.contains("selection-line-handle-overlay")));return s?.classList[1]}}const ef=()=>new Map;const sf=t=>{const e=ef();t.forEach(((t,i)=>{e.set(i,t)}));return e};const nf=(t,e,i)=>{let s=t.get(e);if(s===undefined){t.set(e,s=i())}return s};const rf=(t,e)=>{const i=[];for(const[s,n]of t){i.push(e(n,s))}return i};const of=(t,e)=>{for(const[i,s]of t){if(e(s,i)){return true}}return false};const hf=()=>new Set;const lf=t=>t[t.length-1];const ff=(t,e)=>{for(let i=0;i<e.length;i++){t.push(e[i])}};const uf=Array.from;const cf=(t,e)=>{for(let i=0;i<t.length;i++){if(e(t[i],i,t)){return true}}return false};const af=Array.isArray;class df{constructor(){this._observers=ef()}on(t,e){nf(this._observers,t,hf).add(e);return e}once(t,e){const i=(...s)=>{this.off(t,i);e(...s)};this.on(t,i)}off(t,e){const i=this._observers.get(t);if(i!==undefined){i.delete(e);if(i.size===0){this._observers.delete(t)}}}emit(t,e){return uf((this._observers.get(t)||ef()).values()).forEach((t=>t(...e)))}destroy(){this._observers=ef()}}let wf=class t{constructor(){this._observers=ef()}on(t,e){nf(this._observers,t,hf).add(e)}once(t,e){const i=(...s)=>{this.off(t,i);e(...s)};this.on(t,i)}off(t,e){const i=this._observers.get(t);if(i!==undefined){i.delete(e);if(i.size===0){this._observers.delete(t)}}}emit(t,e){return uf((this._observers.get(t)||ef()).values()).forEach((t=>t(...e)))}destroy(){this._observers=ef()}};const pf=Math.floor;const gf=Math.abs;const mf=(t,e)=>t<e?t:e;const yf=(t,e)=>t>e?t:e;const vf=Math.pow;const bf=t=>t!==0?t<0:1/t<0;const Mf=1;const kf=2;const Af=4;const xf=8;const Sf=32;const Cf=64;const Of=128;const Ef=31;const Tf=63;const Df=127;const If=2147483647;const Pf=Number.MAX_SAFE_INTEGER;const Rf=Number.isInteger||(t=>typeof t==="number"&&isFinite(t)&&pf(t)===t);const $f=String.fromCharCode;const Uf=t=>t.toLowerCase();const jf=/^\s*/g;const Bf=t=>t.replace(jf,"");const Ff=/([A-Z])/g;const Nf=(t,e)=>Bf(t.replace(Ff,(t=>`${e}${Uf(t)}`)));const Lf=t=>{const e=unescape(encodeURIComponent(t));const i=e.length;const s=new Uint8Array(i);for(let t=0;t<i;t++){s[t]=e.codePointAt(t)}return s};const _f=typeof TextEncoder!=="undefined"?new TextEncoder:null;const zf=t=>_f.encode(t);const Yf=_f?zf:Lf;let Xf=typeof TextDecoder==="undefined"?null:new TextDecoder("utf-8",{fatal:true,ignoreBOM:true});if(Xf&&Xf.decode(new Uint8Array).length===1){Xf=null}let Wf=class t{constructor(){this.cpos=0;this.cbuf=new Uint8Array(100);this.bufs=[]}};const Jf=()=>new Wf;const Hf=t=>{let e=t.cpos;for(let i=0;i<t.bufs.length;i++){e+=t.bufs[i].length}return e};const Vf=t=>{const e=new Uint8Array(Hf(t));let i=0;for(let s=0;s<t.bufs.length;s++){const n=t.bufs[s];e.set(n,i);i+=n.length}e.set(new Uint8Array(t.cbuf.buffer,0,t.cpos),i);return e};const Qf=(t,e)=>{const i=t.cbuf.length;if(i-t.cpos<e){t.bufs.push(new Uint8Array(t.cbuf.buffer,0,t.cpos));t.cbuf=new Uint8Array(yf(i,e)*2);t.cpos=0}};const qf=(t,e)=>{const i=t.cbuf.length;if(t.cpos===i){t.bufs.push(t.cbuf);t.cbuf=new Uint8Array(i*2);t.cpos=0}t.cbuf[t.cpos++]=e};const Kf=qf;const Gf=(t,e)=>{while(e>Df){qf(t,Of|Df&e);e=pf(e/128)}qf(t,Df&e)};const Zf=(t,e)=>{const i=bf(e);if(i){e=-e}qf(t,(e>Tf?Of:0)|(i?Cf:0)|Tf&e);e=pf(e/64);while(e>0){qf(t,(e>Df?Of:0)|Df&e);e=pf(e/128)}};const tu=new Uint8Array(3e4);const eu=tu.length/3;const iu=(t,e)=>{if(e.length<eu){const i=_f.encodeInto(e,tu).written||0;Gf(t,i);for(let e=0;e<i;e++){qf(t,tu[e])}}else{ou(t,Yf(e))}};const su=(t,e)=>{const i=unescape(encodeURIComponent(e));const s=i.length;Gf(t,s);for(let e=0;e<s;e++){qf(t,i.codePointAt(e))}};const nu=_f&&_f.encodeInto?iu:su;const ru=(t,e)=>{const i=t.cbuf.length;const s=t.cpos;const n=mf(i-s,e.length);const r=e.length-n;t.cbuf.set(e.subarray(0,n),s);t.cpos+=n;if(r>0){t.bufs.push(t.cbuf);t.cbuf=new Uint8Array(yf(i*2,r));t.cbuf.set(e.subarray(n));t.cpos=r}};const ou=(t,e)=>{Gf(t,e.byteLength);ru(t,e)};const hu=(t,e)=>{Qf(t,e);const i=new DataView(t.cbuf.buffer,t.cpos,e);t.cpos+=e;return i};const lu=(t,e)=>hu(t,4).setFloat32(0,e,false);const fu=(t,e)=>hu(t,8).setFloat64(0,e,false);const uu=(t,e)=>hu(t,8).setBigInt64(0,e,false);const cu=new DataView(new ArrayBuffer(4));const au=t=>{cu.setFloat32(0,t);return cu.getFloat32(0)===t};const du=(t,e)=>{switch(typeof e){case"string":qf(t,119);nu(t,e);break;case"number":if(Rf(e)&&gf(e)<=If){qf(t,125);Zf(t,e)}else if(au(e)){qf(t,124);lu(t,e)}else{qf(t,123);fu(t,e)}break;case"bigint":qf(t,122);uu(t,e);break;case"object":if(e===null){qf(t,126)}else if(af(e)){qf(t,117);Gf(t,e.length);for(let i=0;i<e.length;i++){du(t,e[i])}}else if(e instanceof Uint8Array){qf(t,116);ou(t,e)}else{qf(t,118);const i=Object.keys(e);Gf(t,i.length);for(let s=0;s<i.length;s++){const n=i[s];nu(t,n);du(t,e[n])}}break;case"boolean":qf(t,e?120:121);break;default:qf(t,127)}};class wu extends Wf{constructor(t){super();this.w=t;this.s=null;this.count=0}write(t){if(this.s===t){this.count++}else{if(this.count>0){Gf(this,this.count-1)}this.count=1;this.w(this,t);this.s=t}}}const pu=t=>{if(t.count>0){Zf(t.encoder,t.count===1?t.s:-t.s);if(t.count>1){Gf(t.encoder,t.count-2)}}};class gu{constructor(){this.encoder=new Wf;this.s=0;this.count=0}write(t){if(this.s===t){this.count++}else{pu(this);this.count=1;this.s=t}}toUint8Array(){pu(this);return Vf(this.encoder)}}const mu=t=>{if(t.count>0){const e=t.diff*2+(t.count===1?0:1);Zf(t.encoder,e);if(t.count>1){Gf(t.encoder,t.count-2)}}};class yu{constructor(){this.encoder=new Wf;this.s=0;this.count=0;this.diff=0}write(t){if(this.diff===t-this.s){this.s=t;this.count++}else{mu(this);this.count=1;this.diff=t-this.s;this.s=t}}toUint8Array(){mu(this);return Vf(this.encoder)}}class vu{constructor(){this.sarr=[];this.s="";this.lensE=new gu}write(t){this.s+=t;if(this.s.length>19){this.sarr.push(this.s);this.s=""}this.lensE.write(t.length)}toUint8Array(){const t=new Wf;this.sarr.push(this.s);this.s="";nu(t,this.sarr.join(""));ru(t,this.lensE.toUint8Array());return Vf(t)}}const bu=t=>new Error(t);const Mu=()=>{throw bu("Method unimplemented")};const ku=()=>{throw bu("Unexpected case")};const Au=bu("Unexpected end of array");const xu=bu("Integer out of Range");let Su=class t{constructor(t){this.arr=t;this.pos=0}};const Cu=t=>new Su(t);const Ou=t=>t.pos!==t.arr.length;const Eu=(t,e)=>{const i=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);t.pos+=e;return i};const Tu=t=>Eu(t,Iu(t));const Du=t=>t.arr[t.pos++];const Iu=t=>{let e=0;let i=1;const s=t.arr.length;while(t.pos<s){const s=t.arr[t.pos++];e=e+(s&Df)*i;i*=128;if(s<Of){return e}if(e>Pf){throw xu}}throw Au};const Pu=t=>{let e=t.arr[t.pos++];let i=e&Tf;let s=64;const n=(e&Cf)>0?-1:1;if((e&Of)===0){return n*i}const r=t.arr.length;while(t.pos<r){e=t.arr[t.pos++];i=i+(e&Df)*s;s*=128;if(e<Of){return n*i}if(i>Pf){throw xu}}throw Au};const Ru=t=>{let e=Iu(t);if(e===0){return""}else{let i=String.fromCodePoint(Du(t));if(--e<100){while(e--){i+=String.fromCodePoint(Du(t))}}else{while(e>0){const s=e<1e4?e:1e4;const n=t.arr.subarray(t.pos,t.pos+s);t.pos+=s;i+=String.fromCodePoint.apply(null,n);e-=s}}return decodeURIComponent(escape(i))}};const $u=t=>Xf.decode(Tu(t));const Uu=Xf?$u:Ru;const ju=(t,e)=>{const i=new DataView(t.arr.buffer,t.arr.byteOffset+t.pos,e);t.pos+=e;return i};const Bu=t=>ju(t,4).getFloat32(0,false);const Fu=t=>ju(t,8).getFloat64(0,false);const Nu=t=>ju(t,8).getBigInt64(0,false);const Lu=[t=>undefined,t=>null,Pu,Bu,Fu,Nu,t=>false,t=>true,Uu,t=>{const e=Iu(t);const i={};for(let s=0;s<e;s++){const e=Uu(t);i[e]=_u(t)}return i},t=>{const e=Iu(t);const i=[];for(let s=0;s<e;s++){i.push(_u(t))}return i},Tu];const _u=t=>Lu[127-Du(t)](t);class zu extends Su{constructor(t,e){super(t);this.reader=e;this.s=null;this.count=0}read(){if(this.count===0){this.s=this.reader(this);if(Ou(this)){this.count=Iu(this)+1}else{this.count=-1}}this.count--;return this.s}}class Yu extends Su{constructor(t){super(t);this.s=0;this.count=0}read(){if(this.count===0){this.s=Pu(this);const t=bf(this.s);this.count=1;if(t){this.s=-this.s;this.count=Iu(this)+2}}this.count--;return this.s}}class Xu extends Su{constructor(t){super(t);this.s=0;this.count=0;this.diff=0}read(){if(this.count===0){const t=Pu(this);const e=t&1;this.diff=pf(t/2);this.count=1;if(e){this.count=Iu(this)+2}}this.s+=this.diff;this.count--;return this.s}}class Wu{constructor(t){this.decoder=new Yu(t);this.str=Uu(this.decoder);this.spos=0}read(){const t=this.spos+this.decoder.read();const e=this.str.slice(this.spos,t);this.spos=t;return e}}const Ju=crypto.getRandomValues.bind(crypto);const Hu=()=>Ju(new Uint32Array(1))[0];const Vu=[1e7]+-1e3+-4e3+-8e3+-1e11;const Qu=()=>Vu.replace(/[018]/g,(t=>(t^Hu()&15>>t/4).toString(16)));const qu=Date.now;const Ku=t=>new Promise(t);Promise.all.bind(Promise);const Gu=t=>t===undefined?null:t;class Zu{constructor(){this.map=new Map}setItem(t,e){this.map.set(t,e)}getItem(t){return this.map.get(t)}}let tc=new Zu;let ec=true;try{if(typeof localStorage!=="undefined"&&localStorage){tc=localStorage;ec=false}}catch(ll){}const ic=tc;const sc=t=>ec||addEventListener("storage",t);const nc=t=>ec||removeEventListener("storage",t);const rc=Object.assign;const oc=Object.keys;const hc=(t,e)=>{for(const i in t){e(t[i],i)}};const lc=(t,e)=>{const i=[];for(const s in t){i.push(e(t[s],s))}return i};const fc=t=>oc(t).length;const uc=t=>oc(t).length;const cc=t=>{for(const e in t){return false}return true};const ac=(t,e)=>{for(const i in t){if(!e(t[i],i)){return false}}return true};const dc=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);const wc=(t,e)=>t===e||uc(t)===uc(e)&&ac(t,((t,i)=>(t!==undefined||dc(e,i))&&e[i]===t));const pc=Object.freeze;const gc=t=>{for(const e in t){const i=t[e];if(typeof i==="object"||typeof i==="function"){gc(t[e])}}return pc(t)};const mc=Symbol("Equality");const yc=(t,e,i=0)=>{try{for(;i<t.length;i++){t[i](...e)}}finally{if(i<t.length){yc(t,e,i+1)}}};const vc=t=>t;const bc=(t,e)=>{if(t===e){return true}if(t==null||e==null||t.constructor!==e.constructor){return false}if(t[mc]!=null){return t[mc](e)}switch(t.constructor){case ArrayBuffer:t=new Uint8Array(t);e=new Uint8Array(e);case Uint8Array:{if(t.byteLength!==e.byteLength){return false}for(let i=0;i<t.length;i++){if(t[i]!==e[i]){return false}}break}case Set:{if(t.size!==e.size){return false}for(const i of t){if(!e.has(i)){return false}}break}case Map:{if(t.size!==e.size){return false}for(const i of t.keys()){if(!e.has(i)||!bc(t.get(i),e.get(i))){return false}}break}case Object:if(fc(t)!==fc(e)){return false}for(const i in t){if(!dc(t,i)||!bc(t[i],e[i])){return false}}break;case Array:if(t.length!==e.length){return false}for(let i=0;i<t.length;i++){if(!bc(t[i],e[i])){return false}}break;default:return false}return true};const Mc=(t,e)=>e.includes(t);const kc=typeof process!=="undefined"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process!=="undefined"?process:0)==="[object process]";const Ac=typeof window!=="undefined"&&typeof document!=="undefined"&&!kc;let xc;const Sc=()=>{if(xc===undefined){if(kc){xc=ef();const t=process.argv;let e=null;for(let i=0;i<t.length;i++){const s=t[i];if(s[0]==="-"){if(e!==null){xc.set(e,"")}e=s}else{if(e!==null){xc.set(e,s);e=null}}}if(e!==null){xc.set(e,"")}}else if(typeof location==="object"){xc=ef();(location.search||"?").slice(1).split("&").forEach((t=>{if(t.length!==0){const[e,i]=t.split("=");xc.set(`--${Nf(e,"-")}`,i);xc.set(`-${Nf(e,"-")}`,i)}}))}else{xc=ef()}}return xc};const Cc=t=>Sc().has(t);const Oc=t=>kc?Gu(process.env[t.toUpperCase().replaceAll("-","_")]):Gu(ic.getItem(t));const Ec=t=>Cc("--"+t)||Oc(t)!==null;Ec("production");const Tc=kc&&Mc(process.env.FORCE_COLOR,["true","1","2"]);const Dc=Tc||!Cc("--no-colors")&&!Ec("no-color")&&(!kc||process.stdout.isTTY)&&(!kc||Cc("--color")||Oc("COLORTERM")!==null||(Oc("TERM")||"").includes("color"));const Ic=t=>new Uint8Array(t);const Pc=(t,e,i)=>new Uint8Array(t,e,i);const Rc=t=>new Uint8Array(t);const $c=t=>{let e="";for(let i=0;i<t.byteLength;i++){e+=$f(t[i])}return btoa(e)};const Uc=t=>Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("base64");const jc=t=>{const e=atob(t);const i=Ic(e.length);for(let t=0;t<e.length;t++){i[t]=e.charCodeAt(t)}return i};const Bc=t=>{const e=Buffer.from(t,"base64");return Pc(e.buffer,e.byteOffset,e.byteLength)};const Fc=Ac?$c:Uc;const Nc=Ac?jc:Bc;const Lc=t=>{const e=Ic(t.byteLength);e.set(t);return e};class _c{constructor(t,e){this.left=t;this.right=e}}const zc=(t,e)=>new _c(t,e);typeof DOMParser!=="undefined"?new DOMParser:null;const Yc=t=>rf(t,((t,e)=>`${e}:${t};`)).join("");const Xc=Symbol;const Wc=Xc();const Jc=Xc();const Hc=Xc();const Vc=Xc();const Qc=Xc();const qc=Xc();const Kc=Xc();const Gc=Xc();const Zc=Xc();const ta=t=>{if(t.length===1&&t[0]?.constructor===Function){t=t[0]()}const e=[];const i=[];let s=0;for(;s<t.length;s++){const i=t[s];if(i===undefined){break}else if(i.constructor===String||i.constructor===Number){e.push(i)}else if(i.constructor===Object){break}}if(s>0){i.push(e.join(""))}for(;s<t.length;s++){const e=t[s];if(!(e instanceof Symbol)){i.push(e)}}return i};const ea={[Wc]:zc("font-weight","bold"),[Jc]:zc("font-weight","normal"),[Hc]:zc("color","blue"),[Qc]:zc("color","green"),[Vc]:zc("color","grey"),[qc]:zc("color","red"),[Kc]:zc("color","purple"),[Gc]:zc("color","orange"),[Zc]:zc("color","black")};const ia=t=>{if(t.length===1&&t[0]?.constructor===Function){t=t[0]()}const e=[];const i=[];const s=ef();let n=[];let r=0;for(;r<t.length;r++){const n=t[r];const o=ea[n];if(o!==undefined){s.set(o.left,o.right)}else{if(n===undefined){break}if(n.constructor===String||n.constructor===Number){const t=Yc(s);if(r>0||t.length>0){e.push("%c"+n);i.push(t)}else{e.push(n)}}else{break}}}if(r>0){n=i;n.unshift(e.join(""))}for(;r<t.length;r++){const e=t[r];if(!(e instanceof Symbol)){n.push(e)}}return n};const sa=Dc?ia:ta;const na=(...t)=>{console.log(...sa(t));oa.forEach((e=>e.print(t)))};const ra=(...t)=>{console.warn(...sa(t));t.unshift(Gc);oa.forEach((e=>e.print(t)))};const oa=hf();const ha=t=>({[Symbol.iterator](){return this},next:t});const la=(t,e)=>ha((()=>{let i;do{i=t.next()}while(!i.done&&!e(i.value));return i}));const fa=(t,e)=>ha((()=>{const{done:i,value:s}=t.next();return{done:i,value:i?undefined:e(s)}}));class ua{constructor(t,e){this.clock=t;this.len=e}}class ca{constructor(){this.clients=new Map}}const aa=(t,e,i)=>e.clients.forEach(((e,s)=>{const n=t.doc.store.clients.get(s);if(n!=null){const s=n[n.length-1];const r=s.id.clock+s.length;for(let s=0,o=e[s];s<e.length&&o.clock<r;o=e[++s]){vd(t,n,o.clock,o.len,i)}}}));const da=(t,e)=>{let i=0;let s=t.length-1;while(i<=s){const n=pf((i+s)/2);const r=t[n];const o=r.clock;if(o<=e){if(e<o+r.len){return n}i=n+1}else{s=n-1}}return null};const wa=(t,e)=>{const i=t.clients.get(e.client);return i!==undefined&&da(i,e.clock)!==null};const pa=t=>{t.clients.forEach((t=>{t.sort(((t,e)=>t.clock-e.clock));let e,i;for(e=1,i=1;e<t.length;e++){const s=t[i-1];const n=t[e];if(s.clock+s.len>=n.clock){s.len=yf(s.len,n.clock+n.len-s.clock)}else{if(i<e){t[i]=n}i++}}t.length=i}))};const ga=t=>{const e=new ca;for(let i=0;i<t.length;i++){t[i].clients.forEach(((s,n)=>{if(!e.clients.has(n)){const r=s.slice();for(let e=i+1;e<t.length;e++){ff(r,t[e].clients.get(n)||[])}e.clients.set(n,r)}}))}pa(e);return e};const ma=(t,e,i,s)=>{nf(t.clients,e,(()=>[])).push(new ua(i,s))};const ya=()=>new ca;const va=t=>{const e=ya();t.clients.forEach(((t,i)=>{const s=[];for(let e=0;e<t.length;e++){const i=t[e];if(i.deleted){const n=i.id.clock;let r=i.length;if(e+1<t.length){for(let i=t[e+1];e+1<t.length&&i.deleted;i=t[++e+1]){r+=i.length}}s.push(new ua(n,r))}}if(s.length>0){e.clients.set(i,s)}}));return e};const ba=(t,e)=>{Gf(t.restEncoder,e.clients.size);uf(e.clients.entries()).sort(((t,e)=>e[0]-t[0])).forEach((([e,i])=>{t.resetDsCurVal();Gf(t.restEncoder,e);const s=i.length;Gf(t.restEncoder,s);for(let e=0;e<s;e++){const s=i[e];t.writeDsClock(s.clock);t.writeDsLen(s.len)}}))};const Ma=t=>{const e=new ca;const i=Iu(t.restDecoder);for(let s=0;s<i;s++){t.resetDsCurVal();const i=Iu(t.restDecoder);const s=Iu(t.restDecoder);if(s>0){const n=nf(e.clients,i,(()=>[]));for(let e=0;e<s;e++){n.push(new ua(t.readDsClock(),t.readDsLen()))}}}return e};const ka=(t,e,i)=>{const s=new ca;const n=Iu(t.restDecoder);for(let r=0;r<n;r++){t.resetDsCurVal();const n=Iu(t.restDecoder);const r=Iu(t.restDecoder);const o=i.clients.get(n)||[];const h=ud(i,n);for(let i=0;i<r;i++){const i=t.readDsClock();const r=i+t.readDsLen();if(i<h){if(h<r){ma(s,n,h,r-h)}let t=ad(o,i);let l=o[t];if(!l.deleted&&l.id.clock<i){o.splice(t+1,0,Up(e,l,i-l.id.clock));t++}while(t<o.length){l=o[t++];if(l.id.clock<r){if(!l.deleted){if(r<l.id.clock+l.length){o.splice(t,0,Up(e,l,r-l.id.clock))}l.delete(e)}}else{break}}}else{ma(s,n,i,r-i)}}}if(s.clients.size>0){const t=new Pa;Gf(t.restEncoder,0);ba(t,s);return t.toUint8Array()}return null};const Aa=Hu;class xa extends df{constructor({guid:t=Qu(),collectionid:e=null,gc:i=true,gcFilter:s=()=>true,meta:n=null,autoLoad:r=false,shouldLoad:o=true}={}){super();this.gc=i;this.gcFilter=s;this.clientID=Aa();this.guid=t;this.collectionid=e;this.share=new Map;this.store=new ld;this._transaction=null;this._transactionCleanups=[];this.subdocs=new Set;this._item=null;this.shouldLoad=o;this.autoLoad=r;this.meta=n;this.isLoaded=false;this.isSynced=false;this.isDestroyed=false;this.whenLoaded=Ku((t=>{this.on("load",(()=>{this.isLoaded=true;t(this)}))}));const h=()=>Ku((t=>{const e=i=>{if(i===undefined||i===true){this.off("sync",e);t()}};this.on("sync",e)}));this.on("sync",(t=>{if(t===false&&this.isSynced){this.whenSynced=h()}this.isSynced=t===undefined||t===true;if(this.isSynced&&!this.isLoaded){this.emit("load",[this])}}));this.whenSynced=h()}load(){const t=this._item;if(t!==null&&!this.shouldLoad){Od(t.parent.doc,(t=>{t.subdocsLoaded.add(this)}),null,true)}this.shouldLoad=true}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(uf(this.subdocs).map((t=>t.guid)))}transact(t,e=null){return Od(this,t,e)}get(t,e=sw){const i=nf(this.share,t,(()=>{const t=new e;t._integrate(this,null);return t}));const s=i.constructor;if(e!==sw&&s!==e){if(s===sw){const s=new e;s._map=i._map;i._map.forEach((t=>{for(;t!==null;t=t.left){t.parent=s}}));s._start=i._start;for(let t=s._start;t!==null;t=t.right){t.parent=s}s._length=i._length;this.share.set(t,s);s._integrate(this,null);return s}else{throw new Error(`Type with the name ${t} has already been defined with a different constructor`)}}return i}getArray(t=""){return this.get(t,Aw)}getText(t=""){return this.get(t,Xw)}getMap(t=""){return this.get(t,Cw)}getXmlElement(t=""){return this.get(t,Qw)}getXmlFragment(t=""){return this.get(t,Hw)}toJSON(){const t={};this.share.forEach(((e,i)=>{t[i]=e.toJSON()}));return t}destroy(){this.isDestroyed=true;uf(this.subdocs).forEach((t=>t.destroy()));const t=this._item;if(t!==null){this._item=null;const e=t.content;e.doc=new xa({guid:this.guid,...e.opts,shouldLoad:false});e.doc._item=t;Od(t.parent.doc,(i=>{const s=e.doc;if(!t.deleted){i.subdocsAdded.add(s)}i.subdocsRemoved.add(this)}),null,true)}this.emit("destroyed",[true]);this.emit("destroy",[this]);super.destroy()}}class Sa{constructor(t){this.restDecoder=t}resetDsCurVal(){}readDsClock(){return Iu(this.restDecoder)}readDsLen(){return Iu(this.restDecoder)}}class Ca extends Sa{readLeftID(){return sd(Iu(this.restDecoder),Iu(this.restDecoder))}readRightID(){return sd(Iu(this.restDecoder),Iu(this.restDecoder))}readClient(){return Iu(this.restDecoder)}readInfo(){return Du(this.restDecoder)}readString(){return Uu(this.restDecoder)}readParentInfo(){return Iu(this.restDecoder)===1}readTypeRef(){return Iu(this.restDecoder)}readLen(){return Iu(this.restDecoder)}readAny(){return _u(this.restDecoder)}readBuf(){return Lc(Tu(this.restDecoder))}readJSON(){return JSON.parse(Uu(this.restDecoder))}readKey(){return Uu(this.restDecoder)}}class Oa{constructor(t){this.dsCurrVal=0;this.restDecoder=t}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){this.dsCurrVal+=Iu(this.restDecoder);return this.dsCurrVal}readDsLen(){const t=Iu(this.restDecoder)+1;this.dsCurrVal+=t;return t}}class Ea extends Oa{constructor(t){super(t);this.keys=[];Iu(t);this.keyClockDecoder=new Xu(Tu(t));this.clientDecoder=new Yu(Tu(t));this.leftClockDecoder=new Xu(Tu(t));this.rightClockDecoder=new Xu(Tu(t));this.infoDecoder=new zu(Tu(t),Du);this.stringDecoder=new Wu(Tu(t));this.parentInfoDecoder=new zu(Tu(t),Du);this.typeRefDecoder=new Yu(Tu(t));this.lenDecoder=new Yu(Tu(t))}readLeftID(){return new ed(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new ed(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 _u(this.restDecoder)}readBuf(){return Tu(this.restDecoder)}readJSON(){return _u(this.restDecoder)}readKey(){const t=this.keyClockDecoder.read();if(t<this.keys.length){return this.keys[t]}else{const t=this.stringDecoder.read();this.keys.push(t);return t}}}class Ta{constructor(){this.restEncoder=Jf()}toUint8Array(){return Vf(this.restEncoder)}resetDsCurVal(){}writeDsClock(t){Gf(this.restEncoder,t)}writeDsLen(t){Gf(this.restEncoder,t)}}class Da extends Ta{writeLeftID(t){Gf(this.restEncoder,t.client);Gf(this.restEncoder,t.clock)}writeRightID(t){Gf(this.restEncoder,t.client);Gf(this.restEncoder,t.clock)}writeClient(t){Gf(this.restEncoder,t)}writeInfo(t){Kf(this.restEncoder,t)}writeString(t){nu(this.restEncoder,t)}writeParentInfo(t){Gf(this.restEncoder,t?1:0)}writeTypeRef(t){Gf(this.restEncoder,t)}writeLen(t){Gf(this.restEncoder,t)}writeAny(t){du(this.restEncoder,t)}writeBuf(t){ou(this.restEncoder,t)}writeJSON(t){nu(this.restEncoder,JSON.stringify(t))}writeKey(t){nu(this.restEncoder,t)}}class Ia{constructor(){this.restEncoder=Jf();this.dsCurrVal=0}toUint8Array(){return Vf(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(t){const e=t-this.dsCurrVal;this.dsCurrVal=t;Gf(this.restEncoder,e)}writeDsLen(t){if(t===0){ku()}Gf(this.restEncoder,t-1);this.dsCurrVal+=t}}class Pa extends Ia{constructor(){super();this.keyMap=new Map;this.keyClock=0;this.keyClockEncoder=new yu;this.clientEncoder=new gu;this.leftClockEncoder=new yu;this.rightClockEncoder=new yu;this.infoEncoder=new wu(Kf);this.stringEncoder=new vu;this.parentInfoEncoder=new wu(Kf);this.typeRefEncoder=new gu;this.lenEncoder=new gu}toUint8Array(){const t=Jf();Gf(t,0);ou(t,this.keyClockEncoder.toUint8Array());ou(t,this.clientEncoder.toUint8Array());ou(t,this.leftClockEncoder.toUint8Array());ou(t,this.rightClockEncoder.toUint8Array());ou(t,Vf(this.infoEncoder));ou(t,this.stringEncoder.toUint8Array());ou(t,Vf(this.parentInfoEncoder));ou(t,this.typeRefEncoder.toUint8Array());ou(t,this.lenEncoder.toUint8Array());ru(t,Vf(this.restEncoder));return Vf(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){du(this.restEncoder,t)}writeBuf(t){ou(this.restEncoder,t)}writeJSON(t){du(this.restEncoder,t)}writeKey(t){const e=this.keyMap.get(t);if(e===undefined){this.keyClockEncoder.write(this.keyClock++);this.stringEncoder.write(t)}else{this.keyClockEncoder.write(e)}}}const Ra=(t,e,i,s)=>{s=yf(s,e[0].id.clock);const n=ad(e,s);Gf(t.restEncoder,e.length-n);t.writeClient(i);Gf(t.restEncoder,s);const r=e[n];r.write(t,s-r.id.clock);for(let i=n+1;i<e.length;i++){e[i].write(t,0)}};const $a=(t,e,i)=>{const s=new Map;i.forEach(((t,i)=>{if(ud(e,i)>t){s.set(i,t)}}));fd(e).forEach(((t,e)=>{if(!i.has(e)){s.set(e,0)}}));Gf(t.restEncoder,s.size);uf(s.entries()).sort(((t,e)=>e[0]-t[0])).forEach((([i,s])=>{Ra(t,e.clients.get(i),i,s)}))};const Ua=(t,e)=>{const i=ef();const s=Iu(t.restDecoder);for(let n=0;n<s;n++){const s=Iu(t.restDecoder);const n=new Array(s);const r=t.readClient();let o=Iu(t.restDecoder);i.set(r,{i:0,refs:n});for(let i=0;i<s;i++){const s=t.readInfo();switch(Ef&s){case 0:{const e=t.readLen();n[i]=new np(sd(r,o),e);o+=e;break}case 10:{const e=Iu(t.restDecoder);n[i]=new zp(sd(r,o),e);o+=e;break}default:{const h=(s&(Cf|Of))===0;const l=new Fp(sd(r,o),null,(s&Of)===Of?t.readLeftID():null,null,(s&Cf)===Cf?t.readRightID():null,h?t.readParentInfo()?e.get(t.readString()):t.readLeftID():null,h&&(s&Sf)===Sf?t.readString():null,Np(t,s));n[i]=l;o+=l.length}}}}return i};const ja=(t,e,i)=>{const s=[];let n=uf(i.keys()).sort(((t,e)=>t-e));if(n.length===0){return null}const r=()=>{if(n.length===0){return null}let t=i.get(n[n.length-1]);while(t.refs.length===t.i){n.pop();if(n.length>0){t=i.get(n[n.length-1])}else{return null}}return t};let o=r();if(o===null){return null}const h=new ld;const l=new Map;const f=(t,e)=>{const i=l.get(t);if(i==null||i>e){l.set(t,e)}};let u=o.refs[o.i++];const c=new Map;const a=()=>{for(const t of s){const e=t.id.client;const s=i.get(e);if(s){s.i--;h.clients.set(e,s.refs.slice(s.i));i.delete(e);s.i=0;s.refs=[]}else{h.clients.set(e,[t])}n=n.filter((t=>t!==e))}s.length=0};while(true){if(u.constructor!==zp){const n=nf(c,u.id.client,(()=>ud(e,u.id.client)));const r=n-u.id.clock;if(r<0){s.push(u);f(u.id.client,u.id.clock-1);a()}else{const n=u.getMissing(t,e);if(n!==null){s.push(u);const t=i.get(n)||{refs:[],i:0};if(t.refs.length===t.i){f(n,ud(e,n));a()}else{u=t.refs[t.i++];continue}}else if(r===0||r<u.length){u.integrate(t,r);c.set(u.id.client,u.id.clock+u.length)}}}if(s.length>0){u=s.pop()}else if(o!==null&&o.i<o.refs.length){u=o.refs[o.i++]}else{o=r();if(o===null){break}else{u=o.refs[o.i++]}}}if(h.clients.size>0){const t=new Pa;$a(t,h,new Map);Gf(t.restEncoder,0);return{missing:l,update:t.toUint8Array()}}return null};const Ba=(t,e)=>$a(t,e.doc.store,e.beforeState);const Fa=(t,e,i,s=new Ea(t))=>Od(e,(t=>{t.local=false;let e=false;const i=t.doc;const n=i.store;const r=Ua(s,i);const o=ja(t,n,r);const h=n.pendingStructs;if(h){for(const[t,i]of h.missing){if(i<ud(n,t)){e=true;break}}if(o){for(const[t,e]of o.missing){const i=h.missing.get(t);if(i==null||i>e){h.missing.set(t,e)}}h.update=Bd([h.update,o.update])}}else{n.pendingStructs=o}const l=ka(s,t,n);if(n.pendingDs){const e=new Ea(Cu(n.pendingDs));Iu(e.restDecoder);const i=ka(e,t,n);if(l&&i){n.pendingDs=Bd([l,i])}else{n.pendingDs=l||i}}else{n.pendingDs=l}if(e){const e=n.pendingStructs.update;n.pendingStructs=null;Na(t.doc,e)}}),i,false);const Na=(t,e,i,s=Ea)=>{const n=Cu(e);Fa(n,t,i,new s(n))};const La=(t,e,i)=>Na(t,e,i,Ca);const _a=(t,e,i=new Map)=>{$a(t,e.store,i);ba(t,va(e.store))};const za=(t,e=new Uint8Array([0]),i=new Pa)=>{const s=Wa(e);_a(i,t,s);const n=[i.toUint8Array()];if(t.store.pendingDs){n.push(t.store.pendingDs)}if(t.store.pendingStructs){n.push(Fd(t.store.pendingStructs.update,e))}if(n.length>1){if(i.constructor===Da){return Ud(n.map(((t,e)=>e===0?t:Yd(t))))}else if(i.constructor===Pa){return Bd(n)}}return n[0]};const Ya=(t,e)=>za(t,e,new Da);const Xa=t=>{const e=new Map;const i=Iu(t.restDecoder);for(let s=0;s<i;s++){const i=Iu(t.restDecoder);const s=Iu(t.restDecoder);e.set(i,s)}return e};const Wa=t=>Xa(new Sa(Cu(t)));const Ja=(t,e)=>{Gf(t.restEncoder,e.size);uf(e.entries()).sort(((t,e)=>e[0]-t[0])).forEach((([e,i])=>{Gf(t.restEncoder,e);Gf(t.restEncoder,i)}));return t};const Ha=(t,e)=>Ja(t,fd(e.store));const Va=(t,e=new Ia)=>{if(t instanceof Map){Ja(e,t)}else{Ha(e,t)}return e.toUint8Array()};const Qa=t=>Va(t,new Ta);class qa{constructor(){this.l=[]}}const Ka=()=>new qa;const Ga=(t,e)=>t.l.push(e);const Za=(t,e)=>{const i=t.l;const s=i.length;t.l=i.filter((t=>e!==t));if(s===t.l.length){console.error("[yjs] Tried to remove event handler that doesn't exist.")}};const td=(t,e,i)=>yc(t.l,[e,i]);class ed{constructor(t,e){this.client=t;this.clock=e}}const id=(t,e)=>t===e||t!==null&&e!==null&&t.client===e.client&&t.clock===e.clock;const sd=(t,e)=>new ed(t,e);const nd=t=>{for(const[e,i]of t.doc.share.entries()){if(i===t){return e}}throw ku()};const rd=(t,e)=>{while(e!==null){if(e.parent===t){return true}e=e.parent._item}return false};const od=(t,e)=>e===undefined?!t.deleted:e.sv.has(t.id.client)&&(e.sv.get(t.id.client)||0)>t.id.clock&&!wa(e.ds,t.id);const hd=(t,e)=>{const i=nf(t.meta,hd,hf);const s=t.doc.store;if(!i.has(e)){e.sv.forEach(((e,i)=>{if(e<ud(s,i)){gd(t,sd(i,e))}}));aa(t,e.ds,(t=>{}));i.add(e)}};class ld{constructor(){this.clients=new Map;this.pendingStructs=null;this.pendingDs=null}}const fd=t=>{const e=new Map;t.clients.forEach(((t,i)=>{const s=t[t.length-1];e.set(i,s.id.clock+s.length)}));return e};const ud=(t,e)=>{const i=t.clients.get(e);if(i===undefined){return 0}const s=i[i.length-1];return s.id.clock+s.length};const cd=(t,e)=>{let i=t.clients.get(e.id.client);if(i===undefined){i=[];t.clients.set(e.id.client,i)}else{const t=i[i.length-1];if(t.id.clock+t.length!==e.id.clock){throw ku()}}i.push(e)};const ad=(t,e)=>{let i=0;let s=t.length-1;let n=t[s];let r=n.id.clock;if(r===e){return s}let o=pf(e/(r+n.length-1)*s);while(i<=s){n=t[o];r=n.id.clock;if(r<=e){if(e<r+n.length){return o}i=o+1}else{s=o-1}o=pf((i+s)/2)}throw ku()};const dd=(t,e)=>{const i=t.clients.get(e.client);return i[ad(i,e.clock)]};const wd=dd;const pd=(t,e,i)=>{const s=ad(e,i);const n=e[s];if(n.id.clock<i&&n instanceof Fp){e.splice(s+1,0,Up(t,n,i-n.id.clock));return s+1}return s};const gd=(t,e)=>{const i=t.doc.store.clients.get(e.client);return i[pd(t,i,e.clock)]};const md=(t,e,i)=>{const s=e.clients.get(i.client);const n=ad(s,i.clock);const r=s[n];if(i.clock!==r.id.clock+r.length-1&&r.constructor!==np){s.splice(n+1,0,Up(t,r,i.clock-r.id.clock+1))}return r};const yd=(t,e,i)=>{const s=t.clients.get(e.id.client);s[ad(s,e.id.clock)]=i};const vd=(t,e,i,s,n)=>{if(s===0){return}const r=i+s;let o=pd(t,e,i);let h;do{h=e[o++];if(r<h.id.clock+h.length){pd(t,e,r)}n(h)}while(o<e.length&&e[o].id.clock<r)};class bd{constructor(t,e,i){this.doc=t;this.deleteSet=new ca;this.beforeState=fd(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=i;this.subdocsAdded=new Set;this.subdocsRemoved=new Set;this.subdocsLoaded=new Set;this._needFormattingCleanup=false}}const Md=(t,e)=>{if(e.deleteSet.clients.size===0&&!of(e.afterState,((t,i)=>e.beforeState.get(i)!==t))){return false}pa(e.deleteSet);Ba(t,e);ba(t,e.deleteSet);return true};const kd=(t,e,i)=>{const s=e._item;if(s===null||s.id.clock<(t.beforeState.get(s.id.client)||0)&&!s.deleted){nf(t.changed,e,hf).add(i)}};const Ad=(t,e)=>{let i=t[e];let s=t[e-1];let n=e;for(;n>0;i=s,s=t[--n-1]){if(s.deleted===i.deleted&&s.constructor===i.constructor){if(s.mergeWith(i)){if(i instanceof Fp&&i.parentSub!==null&&i.parent._map.get(i.parentSub)===i){i.parent._map.set(i.parentSub,s)}continue}}break}const r=e-n;if(r){t.splice(e+1-r,r)}return r};const xd=(t,e,i)=>{for(const[s,n]of t.clients.entries()){const t=e.clients.get(s);for(let s=n.length-1;s>=0;s--){const r=n[s];const o=r.clock+r.len;for(let s=ad(t,r.clock),n=t[s];s<t.length&&n.id.clock<o;n=t[++s]){const n=t[s];if(r.clock+r.len<=n.id.clock){break}if(n instanceof Fp&&n.deleted&&!n.keep&&i(n)){n.gc(e,false)}}}}};const Sd=(t,e)=>{t.clients.forEach(((t,i)=>{const s=e.clients.get(i);for(let e=t.length-1;e>=0;e--){const i=t[e];const n=mf(s.length-1,1+ad(s,i.clock+i.len-1));for(let t=n,e=s[t];t>0&&e.id.clock>=i.clock;e=s[t]){t-=1+Ad(s,t)}}}))};const Cd=(t,e)=>{if(e<t.length){const i=t[e];const s=i.doc;const n=s.store;const r=i.deleteSet;const o=i._mergeStructs;try{pa(r);i.afterState=fd(i.doc.store);s.emit("beforeObserverCalls",[i,s]);const t=[];i.changed.forEach(((e,s)=>t.push((()=>{if(s._item===null||!s._item.deleted){s._callObserver(i,e)}}))));t.push((()=>{i.changedParentTypes.forEach(((t,e)=>{if(e._dEH.l.length>0&&(e._item===null||!e._item.deleted)){t=t.filter((t=>t.target._item===null||!t.target._item.deleted));t.forEach((t=>{t.currentTarget=e;t._path=null}));t.sort(((t,e)=>t.path.length-e.path.length));td(e._dEH,t,i)}}))}));t.push((()=>s.emit("afterTransaction",[i,s])));yc(t,[]);if(i._needFormattingCleanup){_w(i)}}finally{if(s.gc){xd(r,n,s.gcFilter)}Sd(r,n);i.afterState.forEach(((t,e)=>{const s=i.beforeState.get(e)||0;if(s!==t){const t=n.clients.get(e);const i=yf(ad(t,s),1);for(let e=t.length-1;e>=i;){e-=1+Ad(t,e)}}}));for(let t=o.length-1;t>=0;t--){const{client:e,clock:i}=o[t].id;const s=n.clients.get(e);const r=ad(s,i);if(r+1<s.length){if(Ad(s,r+1)>1){continue}}if(r>0){Ad(s,r)}}if(!i.local&&i.afterState.get(s.clientID)!==i.beforeState.get(s.clientID)){na(Gc,Wc,"[yjs] ",Jc,qc,"Changed the client-id because another client seems to be using it.");s.clientID=Aa()}s.emit("afterTransactionCleanup",[i,s]);if(s._observers.has("update")){const t=new Da;const e=Md(t,i);if(e){s.emit("update",[t.toUint8Array(),i.origin,s,i])}}if(s._observers.has("updateV2")){const t=new Pa;const e=Md(t,i);if(e){s.emit("updateV2",[t.toUint8Array(),i.origin,s,i])}}const{subdocsAdded:h,subdocsLoaded:l,subdocsRemoved:f}=i;if(h.size>0||f.size>0||l.size>0){h.forEach((t=>{t.clientID=s.clientID;if(t.collectionid==null){t.collectionid=s.collectionid}s.subdocs.add(t)}));f.forEach((t=>s.subdocs.delete(t)));s.emit("subdocs",[{loaded:l,added:h,removed:f},s,i]);f.forEach((t=>t.destroy()))}if(t.length<=e+1){s._transactionCleanups=[];s.emit("afterAllTransactions",[s,t])}else{Cd(t,e+1)}}}};const Od=(t,e,i=null,s=true)=>{const n=t._transactionCleanups;let r=false;let o=null;if(t._transaction===null){r=true;t._transaction=new bd(t,i,s);n.push(t._transaction);if(n.length===1){t.emit("beforeAllTransactions",[t])}t.emit("beforeTransaction",[t._transaction,t])}try{o=e(t._transaction)}finally{if(r){const e=t._transaction===n[0];t._transaction=null;if(e){Cd(n,0)}}}return o};class Ed{constructor(t,e){this.insertions=e;this.deletions=t;this.meta=new Map}}const Td=(t,e,i)=>{aa(t,i.deletions,(i=>{if(i instanceof Fp&&e.scope.some((e=>e===t.doc||rd(e,i)))){$p(i,false)}}))};const Dd=(t,e,i)=>{let s=null;const n=t.doc;const r=t.scope;Od(n,(i=>{while(e.length>0&&t.currStackItem===null){const s=n.store;const o=e.pop();const h=new Set;const l=[];let f=false;aa(i,o.insertions,(t=>{if(t instanceof Fp){if(t.redone!==null){let{item:e,diff:n}=Rp(s,t.id);if(n>0){e=gd(i,sd(e.id.client,e.id.clock+n))}t=e}if(!t.deleted&&r.some((e=>e===i.doc||rd(e,t)))){l.push(t)}}}));aa(i,o.deletions,(t=>{if(t instanceof Fp&&r.some((e=>e===i.doc||rd(e,t)))&&!wa(o.insertions,t.id)){h.add(t)}}));h.forEach((e=>{f=Bp(i,e,h,o.insertions,t.ignoreRemoteMapChanges,t)!==null||f}));for(let e=l.length-1;e>=0;e--){const s=l[e];if(t.deleteFilter(s)){s.delete(i);f=true}}t.currStackItem=f?o:null}i.changed.forEach(((t,e)=>{if(t.has(null)&&e._searchMarker){e._searchMarker.length=0}}));s=i}),t);const o=t.currStackItem;if(o!=null){const e=s.changedParentTypes;t.emit("stack-item-popped",[{stackItem:o,type:i,changedParentTypes:e,origin:t},t]);t.currStackItem=null}return o};class Id extends df{constructor(t,{captureTimeout:e=500,captureTransaction:i=t=>true,deleteFilter:s=()=>true,trackedOrigins:n=new Set([null]),ignoreRemoteMapChanges:r=false,doc:o=(af(t)?t[0].doc:t instanceof xa?t:t.doc)}={}){super();this.scope=[];this.doc=o;this.addToScope(t);this.deleteFilter=s;n.add(this);this.trackedOrigins=n;this.captureTransaction=i;this.undoStack=[];this.redoStack=[];this.undoing=false;this.redoing=false;this.currStackItem=null;this.lastChange=0;this.ignoreRemoteMapChanges=r;this.captureTimeout=e;this.afterTransactionHandler=t=>{if(!this.captureTransaction(t)||!this.scope.some((e=>t.changedParentTypes.has(e)||e===this.doc))||!this.trackedOrigins.has(t.origin)&&(!t.origin||!this.trackedOrigins.has(t.origin.constructor))){return}const e=this.undoing;const i=this.redoing;const s=e?this.redoStack:this.undoStack;if(e){this.stopCapturing()}else if(!i){this.clear(false,true)}const n=new ca;t.afterState.forEach(((e,i)=>{const s=t.beforeState.get(i)||0;const r=e-s;if(r>0){ma(n,i,s,r)}}));const r=qu();let o=false;if(this.lastChange>0&&r-this.lastChange<this.captureTimeout&&s.length>0&&!e&&!i){const e=s[s.length-1];e.deletions=ga([e.deletions,t.deleteSet]);e.insertions=ga([e.insertions,n])}else{s.push(new Ed(t.deleteSet,n));o=true}if(!e&&!i){this.lastChange=r}aa(t,t.deleteSet,(e=>{if(e instanceof Fp&&this.scope.some((i=>i===t.doc||rd(i,e)))){$p(e,true)}}));const h=[{stackItem:s[s.length-1],origin:t.origin,type:e?"redo":"undo",changedParentTypes:t.changedParentTypes},this];if(o){this.emit("stack-item-added",h)}else{this.emit("stack-item-updated",h)}};this.doc.on("afterTransaction",this.afterTransactionHandler);this.doc.on("destroy",(()=>{this.destroy()}))}addToScope(t){const e=new Set(this.scope);t=af(t)?t:[t];t.forEach((t=>{if(!e.has(t)){e.add(t);if(t instanceof sw?t.doc!==this.doc:t!==this.doc)ra("[yjs#509] Not same Y.Doc");this.scope.push(t)}}))}addTrackedOrigin(t){this.trackedOrigins.add(t)}removeTrackedOrigin(t){this.trackedOrigins.delete(t)}clear(t=true,e=true){if(t&&this.canUndo()||e&&this.canRedo()){this.doc.transact((i=>{if(t){this.undoStack.forEach((t=>Td(i,this,t)));this.undoStack=[]}if(e){this.redoStack.forEach((t=>Td(i,this,t)));this.redoStack=[]}this.emit("stack-cleared",[{undoStackCleared:t,redoStackCleared:e}])}))}}stopCapturing(){this.lastChange=0}undo(){this.undoing=true;let t;try{t=Dd(this,this.undoStack,"undo")}finally{this.undoing=false}return t}redo(){this.redoing=true;let t;try{t=Dd(this,this.redoStack,"redo")}finally{this.redoing=false}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*Pd(t){const e=Iu(t.restDecoder);for(let i=0;i<e;i++){const e=Iu(t.restDecoder);const i=t.readClient();let s=Iu(t.restDecoder);for(let n=0;n<e;n++){const e=t.readInfo();if(e===10){const e=Iu(t.restDecoder);yield new zp(sd(i,s),e);s+=e}else if((Ef&e)!==0){const n=(e&(Cf|Of))===0;const r=new Fp(sd(i,s),null,(e&Of)===Of?t.readLeftID():null,null,(e&Cf)===Cf?t.readRightID():null,n?t.readParentInfo()?t.readString():t.readLeftID():null,n&&(e&Sf)===Sf?t.readString():null,Np(t,e));yield r;s+=r.length}else{const e=t.readLen();yield new np(sd(i,s),e);s+=e}}}}class Rd{constructor(t,e){this.gen=Pd(t);this.curr=null;this.done=false;this.filterSkips=e;this.next()}next(){do{this.curr=this.gen.next().value||null}while(this.filterSkips&&this.curr!==null&&this.curr.constructor===zp);return this.curr}}class $d{constructor(t){this.currClient=0;this.startClock=0;this.written=0;this.encoder=t;this.clientStructs=[]}}const Ud=t=>Bd(t,Ca,Da);const jd=(t,e)=>{if(t.constructor===np){const{client:i,clock:s}=t.id;return new np(sd(i,s+e),t.length-e)}else if(t.constructor===zp){const{client:i,clock:s}=t.id;return new zp(sd(i,s+e),t.length-e)}else{const i=t;const{client:s,clock:n}=i.id;return new Fp(sd(s,n+e),null,sd(s,n+e-1),null,i.rightOrigin,i.parent,i.parentSub,i.content.splice(e))}};const Bd=(t,e=Ea,i=Pa)=>{if(t.length===1){return t[0]}const s=t.map((t=>new e(Cu(t))));let n=s.map((t=>new Rd(t,true)));let r=null;const o=new i;const h=new $d(o);while(true){n=n.filter((t=>t.curr!==null));n.sort(((t,e)=>{if(t.curr.id.client===e.curr.id.client){const i=t.curr.id.clock-e.curr.id.clock;if(i===0){return t.curr.constructor===e.curr.constructor?0:t.curr.constructor===zp?1:-1}else{return i}}else{return e.curr.id.client-t.curr.id.client}}));if(n.length===0){break}const t=n[0];const e=t.curr.id.client;if(r!==null){let i=t.curr;let s=false;while(i!==null&&i.id.clock+i.length<=r.struct.id.clock+r.struct.length&&i.id.client>=r.struct.id.client){i=t.next();s=true}if(i===null||i.id.client!==e||s&&i.id.clock>r.struct.id.clock+r.struct.length){continue}if(e!==r.struct.id.client){Ld(h,r.struct,r.offset);r={struct:i,offset:0};t.next()}else{if(r.struct.id.clock+r.struct.length<i.id.clock){if(r.struct.constructor===zp){r.struct.length=i.id.clock+i.length-r.struct.id.clock}else{Ld(h,r.struct,r.offset);const t=i.id.clock-r.struct.id.clock-r.struct.length;const s=new zp(sd(e,r.struct.id.clock+r.struct.length),t);r={struct:s,offset:0}}}else{const e=r.struct.id.clock+r.struct.length-i.id.clock;if(e>0){if(r.struct.constructor===zp){r.struct.length-=e}else{i=jd(i,e)}}if(!r.struct.mergeWith(i)){Ld(h,r.struct,r.offset);r={struct:i,offset:0};t.next()}}}}else{r={struct:t.curr,offset:0};t.next()}for(let i=t.curr;i!==null&&i.id.client===e&&i.id.clock===r.struct.id.clock+r.struct.length&&i.constructor!==zp;i=t.next()){Ld(h,r.struct,r.offset);r={struct:i,offset:0}}}if(r!==null){Ld(h,r.struct,r.offset);r=null}_d(h);const l=s.map((t=>Ma(t)));const f=ga(l);ba(o,f);return o.toUint8Array()};const Fd=(t,e,i=Ea,s=Pa)=>{const n=Wa(e);const r=new s;const o=new $d(r);const h=new i(Cu(t));const l=new Rd(h,false);while(l.curr){const t=l.curr;const e=t.id.client;const i=n.get(e)||0;if(l.curr.constructor===zp){l.next();continue}if(t.id.clock+t.length>i){Ld(o,t,yf(i-t.id.clock,0));l.next();while(l.curr&&l.curr.id.client===e){Ld(o,l.curr,0);l.next()}}else{while(l.curr&&l.curr.id.client===e&&l.curr.id.clock+l.curr.length<=i){l.next()}}}_d(o);const f=Ma(h);ba(r,f);return r.toUint8Array()};const Nd=t=>{if(t.written>0){t.clientStructs.push({written:t.written,restEncoder:Vf(t.encoder.restEncoder)});t.encoder.restEncoder=Jf();t.written=0}};const Ld=(t,e,i)=>{if(t.written>0&&t.currClient!==e.id.client){Nd(t)}if(t.written===0){t.currClient=e.id.client;t.encoder.writeClient(e.id.client);Gf(t.encoder.restEncoder,e.id.clock+i)}e.write(t.encoder,i);t.written++};const _d=t=>{Nd(t);const e=t.encoder.restEncoder;Gf(e,t.clientStructs.length);for(let i=0;i<t.clientStructs.length;i++){const s=t.clientStructs[i];Gf(e,s.written);ru(e,s.restEncoder)}};const zd=(t,e,i,s)=>{const n=new i(Cu(t));const r=new Rd(n,false);const o=new s;const h=new $d(o);for(let t=r.curr;t!==null;t=r.next()){Ld(h,e(t),0)}_d(h);const l=Ma(n);ba(o,l);return o.toUint8Array()};const Yd=t=>zd(t,vc,Ea,Da);const Xd="You must not compute changes after the event-handler fired.";class Wd{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=Jd(this.currentTarget,this.target))}deletes(t){return wa(this.transaction.deleteSet,t.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0){throw bu(Xd)}const t=new Map;const e=this.target;const i=this.transaction.changed.get(e);i.forEach((i=>{if(i!==null){const s=e._map.get(i);let n;let r;if(this.adds(s)){let t=s.left;while(t!==null&&this.adds(t)){t=t.left}if(this.deletes(s)){if(t!==null&&this.deletes(t)){n="delete";r=lf(t.content.getContent())}else{return}}else{if(t!==null&&this.deletes(t)){n="update";r=lf(t.content.getContent())}else{n="add";r=undefined}}}else{if(this.deletes(s)){n="delete";r=lf(s.content.getContent())}else{return}}t.set(i,{action:n,oldValue:r})}}));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 bu(Xd)}const e=this.target;const i=hf();const s=hf();const n=[];t={added:i,deleted:s,delta:n,keys:this.keys};const r=this.transaction.changed.get(e);if(r.has(null)){let t=null;const r=()=>{if(t){n.push(t)}};for(let n=e._start;n!==null;n=n.right){if(n.deleted){if(this.deletes(n)&&!this.adds(n)){if(t===null||t.delete===undefined){r();t={delete:0}}t.delete+=n.length;s.add(n)}}else{if(this.adds(n)){if(t===null||t.insert===undefined){r();t={insert:[]}}t.insert=t.insert.concat(n.content.getContent());i.add(n)}else{if(t===null||t.retain===undefined){r();t={retain:0}}t.retain+=n.length}}}if(t!==null&&t.retain===undefined){r()}}this._changes=t}return t}}const Jd=(t,e)=>{const i=[];while(e._item!==null&&e!==t){if(e._item.parentSub!==null){i.unshift(e._item.parentSub)}else{let t=0;let s=e._item.parent._start;while(s!==e._item&&s!==null){if(!s.deleted&&s.countable){t+=s.length}s=s.right}i.unshift(t)}e=e._item.parent}return i};const Hd=()=>{ra("Invalid access: Add Yjs type to a document before reading data.")};const Vd=80;let Qd=0;class qd{constructor(t,e){t.marker=true;this.p=t;this.index=e;this.timestamp=Qd++}}const Kd=t=>{t.timestamp=Qd++};const Gd=(t,e,i)=>{t.p.marker=false;t.p=e;e.marker=true;t.index=i;t.timestamp=Qd++};const Zd=(t,e,i)=>{if(t.length>=Vd){const s=t.reduce(((t,e)=>t.timestamp<e.timestamp?t:e));Gd(s,e,i);return s}else{const s=new qd(e,i);t.push(s);return s}};const tw=(t,e)=>{if(t._start===null||e===0||t._searchMarker===null){return null}const i=t._searchMarker.length===0?null:t._searchMarker.reduce(((t,i)=>gf(e-t.index)<gf(e-i.index)?t:i));let s=t._start;let n=0;if(i!==null){s=i.p;n=i.index;Kd(i)}while(s.right!==null&&n<e){if(!s.deleted&&s.countable){if(e<n+s.length){break}n+=s.length}s=s.right}while(s.left!==null&&n>e){s=s.left;if(!s.deleted&&s.countable){n-=s.length}}while(s.left!==null&&s.left.id.client===s.id.client&&s.left.id.clock+s.left.length===s.id.clock){s=s.left;if(!s.deleted&&s.countable){n-=s.length}}if(i!==null&&gf(i.index-n)<s.parent.length/Vd){Gd(i,s,n);return i}else{return Zd(t._searchMarker,s,n)}};const ew=(t,e,i)=>{for(let s=t.length-1;s>=0;s--){const n=t[s];if(i>0){let e=n.p;e.marker=false;while(e&&(e.deleted||!e.countable)){e=e.left;if(e&&!e.deleted&&e.countable){n.index-=e.length}}if(e===null||e.marker===true){t.splice(s,1);continue}n.p=e;e.marker=true}if(e<n.index||i>0&&e===n.index){n.index=yf(e,n.index+i)}}};const iw=(t,e,i)=>{const s=t;const n=e.changedParentTypes;while(true){nf(n,t,(()=>[])).push(i);if(t._item===null){break}t=t._item.parent}td(s._eH,i,e)};class sw{constructor(){this._item=null;this._map=new Map;this._start=null;this.doc=null;this._length=0;this._eH=Ka();this._dEH=Ka();this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(t,e){this.doc=t;this._item=e}_copy(){throw Mu()}clone(){throw Mu()}_write(t){}get _first(){let t=this._start;while(t!==null&&t.deleted){t=t.right}return t}_callObserver(t,e){if(!t.local&&this._searchMarker){this._searchMarker.length=0}}observe(t){Ga(this._eH,t)}observeDeep(t){Ga(this._dEH,t)}unobserve(t){Za(this._eH,t)}unobserveDeep(t){Za(this._dEH,t)}toJSON(){}}const nw=(t,e,i)=>{t.doc??Hd();if(e<0){e=t._length+e}if(i<0){i=t._length+i}let s=i-e;const n=[];let r=t._start;while(r!==null&&s>0){if(r.countable&&!r.deleted){const t=r.content.getContent();if(t.length<=e){e-=t.length}else{for(let i=e;i<t.length&&s>0;i++){n.push(t[i]);s--}e=0}}r=r.right}return n};const rw=t=>{t.doc??Hd();const e=[];let i=t._start;while(i!==null){if(i.countable&&!i.deleted){const t=i.content.getContent();for(let i=0;i<t.length;i++){e.push(t[i])}}i=i.right}return e};const ow=(t,e)=>{let i=0;let s=t._start;t.doc??Hd();while(s!==null){if(s.countable&&!s.deleted){const n=s.content.getContent();for(let s=0;s<n.length;s++){e(n[s],i++,t)}}s=s.right}};const hw=(t,e)=>{const i=[];ow(t,((s,n)=>{i.push(e(s,n,t))}));return i};const lw=t=>{let e=t._start;let i=null;let s=0;return{[Symbol.iterator](){return this},next:()=>{if(i===null){while(e!==null&&e.deleted){e=e.right}if(e===null){return{done:true,value:undefined}}i=e.content.getContent();s=0;e=e.right}const t=i[s++];if(i.length<=s){i=null}return{done:false,value:t}}}};const fw=(t,e)=>{t.doc??Hd();const i=tw(t,e);let s=t._start;if(i!==null){s=i.p;e-=i.index}for(;s!==null;s=s.right){if(!s.deleted&&s.countable){if(e<s.length){return s.content.getContent()[e]}e-=s.length}}};const uw=(t,e,i,s)=>{let n=i;const r=t.doc;const o=r.clientID;const h=r.store;const l=i===null?e._start:i.right;let f=[];const u=()=>{if(f.length>0){n=new Fp(sd(o,ud(h,o)),n,n&&n.lastId,l,l&&l.id,e,null,new vp(f));n.integrate(t,0);f=[]}};s.forEach((i=>{if(i===null){f.push(i)}else{switch(i.constructor){case Number:case Object:case Boolean:case Array:case String:f.push(i);break;default:u();switch(i.constructor){case Uint8Array:case ArrayBuffer:n=new Fp(sd(o,ud(h,o)),n,n&&n.lastId,l,l&&l.id,e,null,new rp(new Uint8Array(i)));n.integrate(t,0);break;case xa:n=new Fp(sd(o,ud(h,o)),n,n&&n.lastId,l,l&&l.id,e,null,new up(i));n.integrate(t,0);break;default:if(i instanceof sw){n=new Fp(sd(o,ud(h,o)),n,n&&n.lastId,l,l&&l.id,e,null,new Ip(i));n.integrate(t,0)}else{throw new Error("Unexpected content type in insert operation")}}}}}));u()};const cw=()=>bu("Length exceeded!");const aw=(t,e,i,s)=>{if(i>e._length){throw cw()}if(i===0){if(e._searchMarker){ew(e._searchMarker,i,s.length)}return uw(t,e,null,s)}const n=i;const r=tw(e,i);let o=e._start;if(r!==null){o=r.p;i-=r.index;if(i===0){o=o.prev;i+=o&&o.countable&&!o.deleted?o.length:0}}for(;o!==null;o=o.right){if(!o.deleted&&o.countable){if(i<=o.length){if(i<o.length){gd(t,sd(o.id.client,o.id.clock+i))}break}i-=o.length}}if(e._searchMarker){ew(e._searchMarker,n,s.length)}return uw(t,e,o,s)};const dw=(t,e,i)=>{const s=(e._searchMarker||[]).reduce(((t,e)=>e.index>t.index?e:t),{index:0,p:e._start});let n=s.p;if(n){while(n.right){n=n.right}}return uw(t,e,n,i)};const ww=(t,e,i,s)=>{if(s===0){return}const n=i;const r=s;const o=tw(e,i);let h=e._start;if(o!==null){h=o.p;i-=o.index}for(;h!==null&&i>0;h=h.right){if(!h.deleted&&h.countable){if(i<h.length){gd(t,sd(h.id.client,h.id.clock+i))}i-=h.length}}while(s>0&&h!==null){if(!h.deleted){if(s<h.length){gd(t,sd(h.id.client,h.id.clock+s))}h.delete(t);s-=h.length}h=h.right}if(s>0){throw cw()}if(e._searchMarker){ew(e._searchMarker,n,-r+s)}};const pw=(t,e,i)=>{const s=e._map.get(i);if(s!==undefined){s.delete(t)}};const gw=(t,e,i,s)=>{const n=e._map.get(i)||null;const r=t.doc;const o=r.clientID;let h;if(s==null){h=new vp([s])}else{switch(s.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:h=new vp([s]);break;case Uint8Array:h=new rp(s);break;case xa:h=new up(s);break;default:if(s instanceof sw){h=new Ip(s)}else{throw new Error("Unexpected content type")}}}new Fp(sd(o,ud(r.store,o)),n,n&&n.lastId,null,null,e,i,h).integrate(t,0)};const mw=(t,e)=>{t.doc??Hd();const i=t._map.get(e);return i!==undefined&&!i.deleted?i.content.getContent()[i.length-1]:undefined};const yw=t=>{const e={};t.doc??Hd();t._map.forEach(((t,i)=>{if(!t.deleted){e[i]=t.content.getContent()[t.length-1]}}));return e};const vw=(t,e)=>{t.doc??Hd();const i=t._map.get(e);return i!==undefined&&!i.deleted};const bw=(t,e)=>{const i={};t._map.forEach(((t,s)=>{let n=t;while(n!==null&&(!e.sv.has(n.id.client)||n.id.clock>=(e.sv.get(n.id.client)||0))){n=n.left}if(n!==null&&od(n,e)){i[s]=n.content.getContent()[n.length-1]}}));return i};const Mw=t=>{t.doc??Hd();return la(t._map.entries(),(t=>!t[1].deleted))};class kw extends Wd{}class Aw extends sw{constructor(){super();this._prelimContent=[];this._searchMarker=[]}static from(t){const e=new Aw;e.push(t);return e}_integrate(t,e){super._integrate(t,e);this.insert(0,this._prelimContent);this._prelimContent=null}_copy(){return new Aw}clone(){const t=new Aw;t.insert(0,this.toArray().map((t=>t instanceof sw?t.clone():t)));return t}get length(){this.doc??Hd();return this._length}_callObserver(t,e){super._callObserver(t,e);iw(this,t,new kw(this,t))}insert(t,e){if(this.doc!==null){Od(this.doc,(i=>{aw(i,this,t,e)}))}else{this._prelimContent.splice(t,0,...e)}}push(t){if(this.doc!==null){Od(this.doc,(e=>{dw(e,this,t)}))}else{this._prelimContent.push(...t)}}unshift(t){this.insert(0,t)}delete(t,e=1){if(this.doc!==null){Od(this.doc,(i=>{ww(i,this,t,e)}))}else{this._prelimContent.splice(t,e)}}get(t){return fw(this,t)}toArray(){return rw(this)}slice(t=0,e=this.length){return nw(this,t,e)}toJSON(){return this.map((t=>t instanceof sw?t.toJSON():t))}map(t){return hw(this,t)}forEach(t){ow(this,t)}[Symbol.iterator](){return lw(this)}_write(t){t.writeTypeRef(xp)}}const xw=t=>new Aw;class Sw extends Wd{constructor(t,e,i){super(t,e);this.keysChanged=i}}class Cw extends sw{constructor(t){super();this._prelimContent=null;if(t===undefined){this._prelimContent=new Map}else{this._prelimContent=new Map(t)}}_integrate(t,e){super._integrate(t,e);this._prelimContent.forEach(((t,e)=>{this.set(e,t)}));this._prelimContent=null}_copy(){return new Cw}clone(){const t=new Cw;this.forEach(((e,i)=>{t.set(i,e instanceof sw?e.clone():e)}));return t}_callObserver(t,e){iw(this,t,new Sw(this,t,e))}toJSON(){this.doc??Hd();const t={};this._map.forEach(((e,i)=>{if(!e.deleted){const s=e.content.getContent()[e.length-1];t[i]=s instanceof sw?s.toJSON():s}}));return t}get size(){return[...Mw(this)].length}keys(){return fa(Mw(this),(t=>t[0]))}values(){return fa(Mw(this),(t=>t[1].content.getContent()[t[1].length-1]))}entries(){return fa(Mw(this),(t=>[t[0],t[1].content.getContent()[t[1].length-1]]))}forEach(t){this.doc??Hd();this._map.forEach(((e,i)=>{if(!e.deleted){t(e.content.getContent()[e.length-1],i,this)}}))}[Symbol.iterator](){return this.entries()}delete(t){if(this.doc!==null){Od(this.doc,(e=>{pw(e,this,t)}))}else{this._prelimContent.delete(t)}}set(t,e){if(this.doc!==null){Od(this.doc,(i=>{gw(i,this,t,e)}))}else{this._prelimContent.set(t,e)}return e}get(t){return mw(this,t)}has(t){return vw(this,t)}clear(){if(this.doc!==null){Od(this.doc,(t=>{this.forEach((function(e,i,s){pw(t,s,i)}))}))}else{this._prelimContent.clear()}}_write(t){t.writeTypeRef(Sp)}}const Ow=t=>new Cw;const Ew=(t,e)=>t===e||typeof t==="object"&&typeof e==="object"&&t&&e&&wc(t,e);class Tw{constructor(t,e,i,s){this.left=t;this.right=e;this.index=i;this.currentAttributes=s}forward(){if(this.right===null){ku()}switch(this.right.content.constructor){case wp:if(!this.right.deleted){Rw(this.currentAttributes,this.right.content)}break;default:if(!this.right.deleted){this.index+=this.right.length}break}this.left=this.right;this.right=this.right.right}}const Dw=(t,e,i)=>{while(e.right!==null&&i>0){switch(e.right.content.constructor){case wp:if(!e.right.deleted){Rw(e.currentAttributes,e.right.content)}break;default:if(!e.right.deleted){if(i<e.right.length){gd(t,sd(e.right.id.client,e.right.id.clock+i))}e.index+=e.right.length;i-=e.right.length}break}e.left=e.right;e.right=e.right.right}return e};const Iw=(t,e,i,s)=>{const n=new Map;const r=s?tw(e,i):null;if(r){const e=new Tw(r.p.left,r.p,r.index,n);return Dw(t,e,i-r.index)}else{const s=new Tw(null,e._start,0,n);return Dw(t,s,i)}};const Pw=(t,e,i,s)=>{while(i.right!==null&&(i.right.deleted===true||i.right.content.constructor===wp&&Ew(s.get(i.right.content.key),i.right.content.value))){if(!i.right.deleted){s.delete(i.right.content.key)}i.forward()}const n=t.doc;const r=n.clientID;s.forEach(((s,o)=>{const h=i.left;const l=i.right;const f=new Fp(sd(r,ud(n.store,r)),h,h&&h.lastId,l,l&&l.id,e,null,new wp(o,s));f.integrate(t,0);i.right=f;i.forward()}))};const Rw=(t,e)=>{const{key:i,value:s}=e;if(s===null){t.delete(i)}else{t.set(i,s)}};const $w=(t,e)=>{while(true){if(t.right===null){break}else if(t.right.deleted||t.right.content.constructor===wp&&Ew(e[t.right.content.key]??null,t.right.content.value));else{break}t.forward()}};const Uw=(t,e,i,s)=>{const n=t.doc;const r=n.clientID;const o=new Map;for(const h in s){const l=s[h];const f=i.currentAttributes.get(h)??null;if(!Ew(f,l)){o.set(h,f);const{left:s,right:u}=i;i.right=new Fp(sd(r,ud(n.store,r)),s,s&&s.lastId,u,u&&u.id,e,null,new wp(h,l));i.right.integrate(t,0);i.forward()}}return o};const jw=(t,e,i,s,n)=>{i.currentAttributes.forEach(((t,e)=>{if(n[e]===undefined){n[e]=null}}));const r=t.doc;const o=r.clientID;$w(i,n);const h=Uw(t,e,i,n);const l=s.constructor===String?new Mp(s):s instanceof sw?new Ip(s):new ap(s);let{left:f,right:u,index:c}=i;if(e._searchMarker){ew(e._searchMarker,i.index,l.getLength())}u=new Fp(sd(o,ud(r.store,o)),f,f&&f.lastId,u,u&&u.id,e,null,l);u.integrate(t,0);i.right=u;i.index=c;i.forward();Pw(t,e,i,h)};const Bw=(t,e,i,s,n)=>{const r=t.doc;const o=r.clientID;$w(i,n);const h=Uw(t,e,i,n);t:while(i.right!==null&&(s>0||h.size>0&&(i.right.deleted||i.right.content.constructor===wp))){if(!i.right.deleted){switch(i.right.content.constructor){case wp:{const{key:e,value:r}=i.right.content;const o=n[e];if(o!==undefined){if(Ew(o,r)){h.delete(e)}else{if(s===0){break t}h.set(e,r)}i.right.delete(t)}else{i.currentAttributes.set(e,r)}break}default:if(s<i.right.length){gd(t,sd(i.right.id.client,i.right.id.clock+s))}s-=i.right.length;break}}i.forward()}if(s>0){let n="";for(;s>0;s--){n+="\n"}i.right=new Fp(sd(o,ud(r.store,o)),i.left,i.left&&i.left.lastId,i.right,i.right&&i.right.id,e,null,new Mp(n));i.right.integrate(t,0);i.forward()}Pw(t,e,i,h)};const Fw=(t,e,i,s,n)=>{let r=e;const o=ef();while(r&&(!r.countable||r.deleted)){if(!r.deleted&&r.content.constructor===wp){const t=r.content;o.set(t.key,t)}r=r.right}let h=0;let l=false;while(e!==r){if(i===e){l=true}if(!e.deleted){const i=e.content;switch(i.constructor){case wp:{const{key:r,value:f}=i;const u=s.get(r)??null;if(o.get(r)!==i||u===f){e.delete(t);h++;if(!l&&(n.get(r)??null)===f&&u!==f){if(u===null){n.delete(r)}else{n.set(r,u)}}}if(!l&&!e.deleted){Rw(n,i)}break}}}e=e.right}return h};const Nw=(t,e)=>{while(e&&e.right&&(e.right.deleted||!e.right.countable)){e=e.right}const i=new Set;while(e&&(e.deleted||!e.countable)){if(!e.deleted&&e.content.constructor===wp){const s=e.content.key;if(i.has(s)){e.delete(t)}else{i.add(s)}}e=e.left}};const Lw=t=>{let e=0;Od(t.doc,(i=>{let s=t._start;let n=t._start;let r=ef();const o=sf(r);while(n){if(n.deleted===false){switch(n.content.constructor){case wp:Rw(o,n.content);break;default:e+=Fw(i,s,n,r,o);r=sf(o);s=n;break}}n=n.right}}));return e};const _w=t=>{const e=new Set;const i=t.doc;for(const[s,n]of t.afterState.entries()){const r=t.beforeState.get(s)||0;if(n===r){continue}vd(t,i.store.clients.get(s),r,n,(t=>{if(!t.deleted&&t.content.constructor===wp&&t.constructor!==np){e.add(t.parent)}}))}Od(i,(i=>{aa(t,t.deleteSet,(t=>{if(t instanceof np||!t.parent._hasFormatting||e.has(t.parent)){return}const s=t.parent;if(t.content.constructor===wp){e.add(s)}else{Nw(i,t)}}));for(const t of e){Lw(t)}}))};const zw=(t,e,i)=>{const s=i;const n=sf(e.currentAttributes);const r=e.right;while(i>0&&e.right!==null){if(e.right.deleted===false){switch(e.right.content.constructor){case Ip:case ap:case Mp:if(i<e.right.length){gd(t,sd(e.right.id.client,e.right.id.clock+i))}i-=e.right.length;e.right.delete(t);break}}e.forward()}if(r){Fw(t,r,e.right,n,e.currentAttributes)}const o=(e.left||e.right).parent;if(o._searchMarker){ew(o._searchMarker,e.index,-s+i)}return e};class Yw extends Wd{constructor(t,e,i){super(t,e);this.childListChanged=false;this.keysChanged=new Set;i.forEach((t=>{if(t===null){this.childListChanged=true}else{this.keysChanged.add(t)}}))}get changes(){if(this._changes===null){const 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){const t=this.target.doc;const e=[];Od(t,(t=>{const i=new Map;const s=new Map;let n=this.target._start;let r=null;const o={};let h="";let l=0;let f=0;const u=()=>{if(r!==null){let t=null;switch(r){case"delete":if(f>0){t={delete:f}}f=0;break;case"insert":if(typeof h==="object"||h.length>0){t={insert:h};if(i.size>0){t.attributes={};i.forEach(((e,i)=>{if(e!==null){t.attributes[i]=e}}))}}h="";break;case"retain":if(l>0){t={retain:l};if(!cc(o)){t.attributes=rc({},o)}}l=0;break}if(t)e.push(t);r=null}};while(n!==null){switch(n.content.constructor){case Ip:case ap:if(this.adds(n)){if(!this.deletes(n)){u();r="insert";h=n.content.getContent()[0];u()}}else if(this.deletes(n)){if(r!=="delete"){u();r="delete"}f+=1}else if(!n.deleted){if(r!=="retain"){u();r="retain"}l+=1}break;case Mp:if(this.adds(n)){if(!this.deletes(n)){if(r!=="insert"){u();r="insert"}h+=n.content.str}}else if(this.deletes(n)){if(r!=="delete"){u();r="delete"}f+=n.length}else if(!n.deleted){if(r!=="retain"){u();r="retain"}l+=n.length}break;case wp:{const{key:e,value:h}=n.content;if(this.adds(n)){if(!this.deletes(n)){const l=i.get(e)??null;if(!Ew(l,h)){if(r==="retain"){u()}if(Ew(h,s.get(e)??null)){delete o[e]}else{o[e]=h}}else if(h!==null){n.delete(t)}}}else if(this.deletes(n)){s.set(e,h);const t=i.get(e)??null;if(!Ew(t,h)){if(r==="retain"){u()}o[e]=t}}else if(!n.deleted){s.set(e,h);const i=o[e];if(i!==undefined){if(!Ew(i,h)){if(r==="retain"){u()}if(h===null){delete o[e]}else{o[e]=h}}else if(i!==null){n.delete(t)}}}if(!n.deleted){if(r==="insert"){u()}Rw(i,n.content)}break}}n=n.right}u();while(e.length>0){const t=e[e.length-1];if(t.retain!==undefined&&t.attributes===undefined){e.pop()}else{break}}}));this._delta=e}return this._delta}}class Xw extends sw{constructor(t){super();this._pending=t!==undefined?[()=>this.insert(0,t)]:[];this._searchMarker=[];this._hasFormatting=false}get length(){this.doc??Hd();return this._length}_integrate(t,e){super._integrate(t,e);try{this._pending.forEach((t=>t()))}catch(t){console.error(t)}this._pending=null}_copy(){return new Xw}clone(){const t=new Xw;t.applyDelta(this.toDelta());return t}_callObserver(t,e){super._callObserver(t,e);const i=new Yw(this,t,e);iw(this,t,i);if(!t.local&&this._hasFormatting){t._needFormattingCleanup=true}}toString(){this.doc??Hd();let t="";let e=this._start;while(e!==null){if(!e.deleted&&e.countable&&e.content.constructor===Mp){t+=e.content.str}e=e.right}return t}toJSON(){return this.toString()}applyDelta(t,{sanitize:e=true}={}){if(this.doc!==null){Od(this.doc,(i=>{const s=new Tw(null,this._start,0,new Map);for(let n=0;n<t.length;n++){const r=t[n];if(r.insert!==undefined){const o=!e&&typeof r.insert==="string"&&n===t.length-1&&s.right===null&&r.insert.slice(-1)==="\n"?r.insert.slice(0,-1):r.insert;if(typeof o!=="string"||o.length>0){jw(i,this,s,o,r.attributes||{})}}else if(r.retain!==undefined){Bw(i,this,s,r.retain,r.attributes||{})}else if(r.delete!==undefined){zw(i,s,r.delete)}}}))}else{this._pending.push((()=>this.applyDelta(t)))}}toDelta(t,e,i){this.doc??Hd();const s=[];const n=new Map;const r=this.doc;let o="";let h=this._start;function l(){if(o.length>0){const t={};let e=false;n.forEach(((i,s)=>{e=true;t[s]=i}));const i={insert:o};if(e){i.attributes=t}s.push(i);o=""}}const f=()=>{while(h!==null){if(od(h,t)||e!==undefined&&od(h,e)){switch(h.content.constructor){case Mp:{const s=n.get("ychange");if(t!==undefined&&!od(h,t)){if(s===undefined||s.user!==h.id.client||s.type!=="removed"){l();n.set("ychange",i?i("removed",h.id):{type:"removed"})}}else if(e!==undefined&&!od(h,e)){if(s===undefined||s.user!==h.id.client||s.type!=="added"){l();n.set("ychange",i?i("added",h.id):{type:"added"})}}else if(s!==undefined){l();n.delete("ychange")}o+=h.content.str;break}case Ip:case ap:{l();const t={insert:h.content.getContent()[0]};if(n.size>0){const e={};t.attributes=e;n.forEach(((t,i)=>{e[i]=t}))}s.push(t);break}case wp:if(od(h,t)){l();Rw(n,h.content)}break}}h=h.right}l()};if(t||e){Od(r,(i=>{if(t){hd(i,t)}if(e){hd(i,e)}f()}),"cleanup")}else{f()}return s}insert(t,e,i){if(e.length<=0){return}const s=this.doc;if(s!==null){Od(s,(s=>{const n=Iw(s,this,t,!i);if(!i){i={};n.currentAttributes.forEach(((t,e)=>{i[e]=t}))}jw(s,this,n,e,i)}))}else{this._pending.push((()=>this.insert(t,e,i)))}}insertEmbed(t,e,i){const s=this.doc;if(s!==null){Od(s,(s=>{const n=Iw(s,this,t,!i);jw(s,this,n,e,i||{})}))}else{this._pending.push((()=>this.insertEmbed(t,e,i||{})))}}delete(t,e){if(e===0){return}const i=this.doc;if(i!==null){Od(i,(i=>{zw(i,Iw(i,this,t,true),e)}))}else{this._pending.push((()=>this.delete(t,e)))}}format(t,e,i){if(e===0){return}const s=this.doc;if(s!==null){Od(s,(s=>{const n=Iw(s,this,t,false);if(n.right===null){return}Bw(s,this,n,e,i)}))}else{this._pending.push((()=>this.format(t,e,i)))}}removeAttribute(t){if(this.doc!==null){Od(this.doc,(e=>{pw(e,this,t)}))}else{this._pending.push((()=>this.removeAttribute(t)))}}setAttribute(t,e){if(this.doc!==null){Od(this.doc,(i=>{gw(i,this,t,e)}))}else{this._pending.push((()=>this.setAttribute(t,e)))}}getAttribute(t){return mw(this,t)}getAttributes(){return yw(this)}_write(t){t.writeTypeRef(Cp)}}const Ww=t=>new Xw;class Jw{constructor(t,e=()=>true){this._filter=e;this._root=t;this._currentNode=t._start;this._firstCall=true;t.doc??Hd()}[Symbol.iterator](){return this}next(){let t=this._currentNode;let e=t&&t.content&&t.content.type;if(t!==null&&(!this._firstCall||t.deleted||!this._filter(e))){do{e=t.content.type;if(!t.deleted&&(e.constructor===Qw||e.constructor===Hw)&&e._start!==null){t=e._start}else{while(t!==null){const e=t.next;if(e!==null){t=e;break}else if(t.parent===this._root){t=null}else{t=t.parent._item}}}}while(t!==null&&(t.deleted||!this._filter(t.content.type)))}this._firstCall=false;if(t===null){return{value:undefined,done:true}}this._currentNode=t;return{value:t.content.type,done:false}}}class Hw extends sw{constructor(){super();this._prelimContent=[]}get firstChild(){const t=this._first;return t?t.content.getContent()[0]:null}_integrate(t,e){super._integrate(t,e);this.insert(0,this._prelimContent);this._prelimContent=null}_copy(){return new Hw}clone(){const t=new Hw;t.insert(0,this.toArray().map((t=>t instanceof sw?t.clone():t)));return t}get length(){this.doc??Hd();return this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(t){return new Jw(this,t)}querySelector(t){t=t.toUpperCase();const e=new Jw(this,(e=>e.nodeName&&e.nodeName.toUpperCase()===t));const i=e.next();if(i.done){return null}else{return i.value}}querySelectorAll(t){t=t.toUpperCase();return uf(new Jw(this,(e=>e.nodeName&&e.nodeName.toUpperCase()===t)))}_callObserver(t,e){iw(this,t,new Kw(this,e,t))}toString(){return hw(this,(t=>t.toString())).join("")}toJSON(){return this.toString()}toDOM(t=document,e={},i){const s=t.createDocumentFragment();if(i!==undefined){i._createAssociation(s,this)}ow(this,(n=>{s.insertBefore(n.toDOM(t,e,i),null)}));return s}insert(t,e){if(this.doc!==null){Od(this.doc,(i=>{aw(i,this,t,e)}))}else{this._prelimContent.splice(t,0,...e)}}insertAfter(t,e){if(this.doc!==null){Od(this.doc,(i=>{const s=t&&t instanceof sw?t._item:t;uw(i,this,s,e)}))}else{const i=this._prelimContent;const s=t===null?0:i.findIndex((e=>e===t))+1;if(s===0&&t!==null){throw bu("Reference item not found")}i.splice(s,0,...e)}}delete(t,e=1){if(this.doc!==null){Od(this.doc,(i=>{ww(i,this,t,e)}))}else{this._prelimContent.splice(t,e)}}toArray(){return rw(this)}push(t){this.insert(this.length,t)}unshift(t){this.insert(0,t)}get(t){return fw(this,t)}slice(t=0,e=this.length){return nw(this,t,e)}forEach(t){ow(this,t)}_write(t){t.writeTypeRef(Ep)}}const Vw=t=>new Hw;class Qw extends Hw{constructor(t="UNDEFINED"){super();this.nodeName=t;this._prelimAttrs=new Map}get nextSibling(){const t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){const t=this._item?this._item.prev:null;return t?t.content.type:null}_integrate(t,e){super._integrate(t,e);this._prelimAttrs.forEach(((t,e)=>{this.setAttribute(e,t)}));this._prelimAttrs=null}_copy(){return new Qw(this.nodeName)}clone(){const t=new Qw(this.nodeName);const e=this.getAttributes();hc(e,((e,i)=>{if(typeof e==="string"){t.setAttribute(i,e)}}));t.insert(0,this.toArray().map((t=>t instanceof sw?t.clone():t)));return t}toString(){const t=this.getAttributes();const e=[];const i=[];for(const e in t){i.push(e)}i.sort();const s=i.length;for(let n=0;n<s;n++){const s=i[n];e.push(s+'="'+t[s]+'"')}const n=this.nodeName.toLocaleLowerCase();const r=e.length>0?" "+e.join(" "):"";return`<${n}${r}>${super.toString()}</${n}>`}removeAttribute(t){if(this.doc!==null){Od(this.doc,(e=>{pw(e,this,t)}))}else{this._prelimAttrs.delete(t)}}setAttribute(t,e){if(this.doc!==null){Od(this.doc,(i=>{gw(i,this,t,e)}))}else{this._prelimAttrs.set(t,e)}}getAttribute(t){return mw(this,t)}hasAttribute(t){return vw(this,t)}getAttributes(t){return t?bw(this,t):yw(this)}toDOM(t=document,e={},i){const s=t.createElement(this.nodeName);const n=this.getAttributes();for(const t in n){const e=n[t];if(typeof e==="string"){s.setAttribute(t,e)}}ow(this,(n=>{s.appendChild(n.toDOM(t,e,i))}));if(i!==undefined){i._createAssociation(s,this)}return s}_write(t){t.writeTypeRef(Op);t.writeKey(this.nodeName)}}const qw=t=>new Qw(t.readKey());class Kw extends Wd{constructor(t,e,i){super(t,i);this.childListChanged=false;this.attributesChanged=new Set;e.forEach((t=>{if(t===null){this.childListChanged=true}else{this.attributesChanged.add(t)}}))}}class Gw extends Cw{constructor(t){super();this.hookName=t}_copy(){return new Gw(this.hookName)}clone(){const t=new Gw(this.hookName);this.forEach(((e,i)=>{t.set(i,e)}));return t}toDOM(t=document,e={},i){const s=e[this.hookName];let n;if(s!==undefined){n=s.createDom(this)}else{n=document.createElement(this.hookName)}n.setAttribute("data-yjs-hook",this.hookName);if(i!==undefined){i._createAssociation(n,this)}return n}_write(t){t.writeTypeRef(Tp);t.writeKey(this.hookName)}}const Zw=t=>new Gw(t.readKey());class tp extends Xw{get nextSibling(){const t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){const t=this._item?this._item.prev:null;return t?t.content.type:null}_copy(){return new tp}clone(){const t=new tp;t.applyDelta(this.toDelta());return t}toDOM(t=document,e,i){const s=t.createTextNode(this.toString());if(i!==undefined){i._createAssociation(s,this)}return s}toString(){return this.toDelta().map((t=>{const e=[];for(const i in t.attributes){const s=[];for(const e in t.attributes[i]){s.push({key:e,value:t.attributes[i][e]})}s.sort(((t,e)=>t.key<e.key?-1:1));e.push({nodeName:i,attrs:s})}e.sort(((t,e)=>t.nodeName<e.nodeName?-1:1));let i="";for(let t=0;t<e.length;t++){const s=e[t];i+=`<${s.nodeName}`;for(let t=0;t<s.attrs.length;t++){const e=s.attrs[t];i+=` ${e.key}="${e.value}"`}i+=">"}i+=t.insert;for(let t=e.length-1;t>=0;t--){i+=`</${e[t].nodeName}>`}return i})).join("")}toJSON(){return this.toString()}_write(t){t.writeTypeRef(Dp)}}const ep=t=>new tp;class ip{constructor(t,e){this.id=t;this.length=e}get deleted(){throw Mu()}mergeWith(t){return false}write(t,e,i){throw Mu()}integrate(t,e){throw Mu()}}const sp=0;class np extends ip{get deleted(){return true}delete(){}mergeWith(t){if(this.constructor!==t.constructor){return false}this.length+=t.length;return true}integrate(t,e){if(e>0){this.id.clock+=e;this.length-=e}cd(t.doc.store,this)}write(t,e){t.writeInfo(sp);t.writeLen(this.length-e)}getMissing(t,e){return null}}class rp{constructor(t){this.content=t}getLength(){return 1}getContent(){return[this.content]}isCountable(){return true}copy(){return new rp(this.content)}splice(t){throw Mu()}mergeWith(t){return false}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeBuf(this.content)}getRef(){return 3}}const op=t=>new rp(t.readBuf());class hp{constructor(t){this.len=t}getLength(){return this.len}getContent(){return[]}isCountable(){return false}copy(){return new hp(this.len)}splice(t){const e=new hp(this.len-t);this.len=t;return e}mergeWith(t){this.len+=t.len;return true}integrate(t,e){ma(t.deleteSet,e.id.client,e.id.clock,this.len);e.markDeleted()}delete(t){}gc(t){}write(t,e){t.writeLen(this.len-e)}getRef(){return 1}}const lp=t=>new hp(t.readLen());const fp=(t,e)=>new xa({guid:t,...e,shouldLoad:e.shouldLoad||e.autoLoad||false});class up{constructor(t){if(t._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=t;const e={};this.opts=e;if(!t.gc){e.gc=false}if(t.autoLoad){e.autoLoad=true}if(t.meta!==null){e.meta=t.meta}}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return true}copy(){return new up(fp(this.doc.guid,this.opts))}splice(t){throw Mu()}mergeWith(t){return false}integrate(t,e){this.doc._item=e;t.subdocsAdded.add(this.doc);if(this.doc.shouldLoad){t.subdocsLoaded.add(this.doc)}}delete(t){if(t.subdocsAdded.has(this.doc)){t.subdocsAdded.delete(this.doc)}else{t.subdocsRemoved.add(this.doc)}}gc(t){}write(t,e){t.writeString(this.doc.guid);t.writeAny(this.opts)}getRef(){return 9}}const cp=t=>new up(fp(t.readString(),t.readAny()));class ap{constructor(t){this.embed=t}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return true}copy(){return new ap(this.embed)}splice(t){throw Mu()}mergeWith(t){return false}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeJSON(this.embed)}getRef(){return 5}}const dp=t=>new ap(t.readJSON());class wp{constructor(t,e){this.key=t;this.value=e}getLength(){return 1}getContent(){return[]}isCountable(){return false}copy(){return new wp(this.key,this.value)}splice(t){throw Mu()}mergeWith(t){return false}integrate(t,e){const i=e.parent;i._searchMarker=null;i._hasFormatting=true}delete(t){}gc(t){}write(t,e){t.writeKey(this.key);t.writeJSON(this.value)}getRef(){return 6}}const pp=t=>new wp(t.readKey(),t.readJSON());class gp{constructor(t){this.arr=t}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return true}copy(){return new gp(this.arr)}splice(t){const e=new gp(this.arr.slice(t));this.arr=this.arr.slice(0,t);return e}mergeWith(t){this.arr=this.arr.concat(t.arr);return true}integrate(t,e){}delete(t){}gc(t){}write(t,e){const i=this.arr.length;t.writeLen(i-e);for(let s=e;s<i;s++){const e=this.arr[s];t.writeString(e===undefined?"undefined":JSON.stringify(e))}}getRef(){return 2}}const mp=t=>{const e=t.readLen();const i=[];for(let s=0;s<e;s++){const e=t.readString();if(e==="undefined"){i.push(undefined)}else{i.push(JSON.parse(e))}}return new gp(i)};const yp=Oc("node_env")==="development";class vp{constructor(t){this.arr=t;yp&&gc(t)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return true}copy(){return new vp(this.arr)}splice(t){const e=new vp(this.arr.slice(t));this.arr=this.arr.slice(0,t);return e}mergeWith(t){this.arr=this.arr.concat(t.arr);return true}integrate(t,e){}delete(t){}gc(t){}write(t,e){const i=this.arr.length;t.writeLen(i-e);for(let s=e;s<i;s++){const e=this.arr[s];t.writeAny(e)}}getRef(){return 8}}const bp=t=>{const e=t.readLen();const i=[];for(let s=0;s<e;s++){i.push(t.readAny())}return new vp(i)};class Mp{constructor(t){this.str=t}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return true}copy(){return new Mp(this.str)}splice(t){const e=new Mp(this.str.slice(t));this.str=this.str.slice(0,t);const i=this.str.charCodeAt(t-1);if(i>=55296&&i<=56319){this.str=this.str.slice(0,t-1)+"�";e.str="�"+e.str.slice(1)}return e}mergeWith(t){this.str+=t.str;return true}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeString(e===0?this.str:this.str.slice(e))}getRef(){return 4}}const kp=t=>new Mp(t.readString());const Ap=[xw,Ow,Ww,qw,Vw,Zw,ep];const xp=0;const Sp=1;const Cp=2;const Op=3;const Ep=4;const Tp=5;const Dp=6;class Ip{constructor(t){this.type=t}getLength(){return 1}getContent(){return[this.type]}isCountable(){return true}copy(){return new Ip(this.type._copy())}splice(t){throw Mu()}mergeWith(t){return false}integrate(t,e){this.type._integrate(t.doc,e)}delete(t){let e=this.type._start;while(e!==null){if(!e.deleted){e.delete(t)}else if(e.id.clock<(t.beforeState.get(e.id.client)||0)){t._mergeStructs.push(e)}e=e.right}this.type._map.forEach((e=>{if(!e.deleted){e.delete(t)}else if(e.id.clock<(t.beforeState.get(e.id.client)||0)){t._mergeStructs.push(e)}}));t.changed.delete(this.type)}gc(t){let e=this.type._start;while(e!==null){e.gc(t,true);e=e.right}this.type._start=null;this.type._map.forEach((e=>{while(e!==null){e.gc(t,true);e=e.left}}));this.type._map=new Map}write(t,e){this.type._write(t)}getRef(){return 7}}const Pp=t=>new Ip(Ap[t.readTypeRef()](t));const Rp=(t,e)=>{let i=e;let s=0;let n;do{if(s>0){i=sd(i.client,i.clock+s)}n=wd(t,i);s=i.clock-n.id.clock;i=n.redone}while(i!==null&&n instanceof Fp);return{item:n,diff:s}};const $p=(t,e)=>{while(t!==null&&t.keep!==e){t.keep=e;t=t.parent._item}};const Up=(t,e,i)=>{const{client:s,clock:n}=e.id;const r=new Fp(sd(s,n+i),e,sd(s,n+i-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(i));if(e.deleted){r.markDeleted()}if(e.keep){r.keep=true}if(e.redone!==null){r.redone=sd(e.redone.client,e.redone.clock+i)}e.right=r;if(r.right!==null){r.right.left=r}t._mergeStructs.push(r);if(r.parentSub!==null&&r.right===null){r.parent._map.set(r.parentSub,r)}e.length=i;return r};const jp=(t,e)=>cf(t,(t=>wa(t.deletions,e)));const Bp=(t,e,i,s,n,r)=>{const o=t.doc;const h=o.store;const l=o.clientID;const f=e.redone;if(f!==null){return gd(t,f)}let u=e.parent._item;let c=null;let a;if(u!==null&&u.deleted===true){if(u.redone===null&&(!i.has(u)||Bp(t,u,i,s,n,r)===null)){return null}while(u.redone!==null){u=gd(t,u.redone)}}const d=u===null?e.parent:u.content.type;if(e.parentSub===null){c=e.left;a=e;while(c!==null){let e=c;while(e!==null&&e.parent._item!==u){e=e.redone===null?null:gd(t,e.redone)}if(e!==null&&e.parent._item===u){c=e;break}c=c.left}while(a!==null){let e=a;while(e!==null&&e.parent._item!==u){e=e.redone===null?null:gd(t,e.redone)}if(e!==null&&e.parent._item===u){a=e;break}a=a.right}}else{a=null;if(e.right&&!n){c=e;while(c!==null&&c.right!==null&&(c.right.redone||wa(s,c.right.id)||jp(r.undoStack,c.right.id)||jp(r.redoStack,c.right.id))){c=c.right;while(c.redone)c=gd(t,c.redone)}if(c&&c.right!==null){return null}}else{c=d._map.get(e.parentSub)||null}}const w=ud(h,l);const p=sd(l,w);const g=new Fp(p,c,c&&c.lastId,a,a&&a.id,d,e.parentSub,e.content.copy());e.redone=p;$p(g,true);g.integrate(t,0);return g};class Fp extends ip{constructor(t,e,i,s,n,r,o,h){super(t,h.getLength());this.origin=i;this.left=e;this.right=s;this.rightOrigin=n;this.parent=r;this.parentSub=o;this.redone=null;this.content=h;this.info=this.content.isCountable()?kf:0}set marker(t){if((this.info&xf)>0!==t){this.info^=xf}}get marker(){return(this.info&xf)>0}get keep(){return(this.info&Mf)>0}set keep(t){if(this.keep!==t){this.info^=Mf}}get countable(){return(this.info&kf)>0}get deleted(){return(this.info&Af)>0}set deleted(t){if(this.deleted!==t){this.info^=Af}}markDeleted(){this.info|=Af}getMissing(t,e){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=ud(e,this.origin.client)){return this.origin.client}if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=ud(e,this.rightOrigin.client)){return this.rightOrigin.client}if(this.parent&&this.parent.constructor===ed&&this.id.client!==this.parent.client&&this.parent.clock>=ud(e,this.parent.client)){return this.parent.client}if(this.origin){this.left=md(t,e,this.origin);this.origin=this.left.lastId}if(this.rightOrigin){this.right=gd(t,this.rightOrigin);this.rightOrigin=this.right.id}if(this.left&&this.left.constructor===np||this.right&&this.right.constructor===np){this.parent=null}else if(!this.parent){if(this.left&&this.left.constructor===Fp){this.parent=this.left.parent;this.parentSub=this.left.parentSub}else if(this.right&&this.right.constructor===Fp){this.parent=this.right.parent;this.parentSub=this.right.parentSub}}else if(this.parent.constructor===ed){const t=wd(e,this.parent);if(t.constructor===np){this.parent=null}else{this.parent=t.content.type}}return null}integrate(t,e){if(e>0){this.id.clock+=e;this.left=md(t,t.doc.store,sd(this.id.client,this.id.clock-1));this.origin=this.left.lastId;this.content=this.content.splice(e);this.length-=e}if(this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let e=this.left;let i;if(e!==null){i=e.right}else if(this.parentSub!==null){i=this.parent._map.get(this.parentSub)||null;while(i!==null&&i.left!==null){i=i.left}}else{i=this.parent._start}const s=new Set;const n=new Set;while(i!==null&&i!==this.right){n.add(i);s.add(i);if(id(this.origin,i.origin)){if(i.id.client<this.id.client){e=i;s.clear()}else if(id(this.rightOrigin,i.rightOrigin)){break}}else if(i.origin!==null&&n.has(wd(t.doc.store,i.origin))){if(!s.has(wd(t.doc.store,i.origin))){e=i;s.clear()}}else{break}i=i.right}this.left=e}if(this.left!==null){const t=this.left.right;this.right=t;this.left.right=this}else{let t;if(this.parentSub!==null){t=this.parent._map.get(this.parentSub)||null;while(t!==null&&t.left!==null){t=t.left}}else{t=this.parent._start;this.parent._start=this}this.right=t}if(this.right!==null){this.right.left=this}else if(this.parentSub!==null){this.parent._map.set(this.parentSub,this);if(this.left!==null){this.left.delete(t)}}if(this.parentSub===null&&this.countable&&!this.deleted){this.parent._length+=this.length}cd(t.doc.store,this);this.content.integrate(t,this);kd(t,this.parent,this.parentSub);if(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null){this.delete(t)}}else{new np(this.id,this.length).integrate(t,0)}}get next(){let t=this.right;while(t!==null&&t.deleted){t=t.right}return t}get prev(){let t=this.left;while(t!==null&&t.deleted){t=t.left}return t}get lastId(){return this.length===1?this.id:sd(this.id.client,this.id.clock+this.length-1)}mergeWith(t){if(this.constructor===t.constructor&&id(t.origin,this.lastId)&&this.right===t&&id(this.rightOrigin,t.rightOrigin)&&this.id.client===t.id.client&&this.id.clock+this.length===t.id.clock&&this.deleted===t.deleted&&this.redone===null&&t.redone===null&&this.content.constructor===t.content.constructor&&this.content.mergeWith(t.content)){const e=this.parent._searchMarker;if(e){e.forEach((e=>{if(e.p===t){e.p=this;if(!this.deleted&&this.countable){e.index-=this.length}}}))}if(t.keep){this.keep=true}this.right=t.right;if(this.right!==null){this.right.left=this}this.length+=t.length;return true}return false}delete(t){if(!this.deleted){const e=this.parent;if(this.countable&&this.parentSub===null){e._length-=this.length}this.markDeleted();ma(t.deleteSet,this.id.client,this.id.clock,this.length);kd(t,e,this.parentSub);this.content.delete(t)}}gc(t,e){if(!this.deleted){throw ku()}this.content.gc(t);if(e){yd(t,this,new np(this.id,this.length))}else{this.content=new hp(this.length)}}write(t,e){const i=e>0?sd(this.id.client,this.id.clock+e-1):this.origin;const s=this.rightOrigin;const n=this.parentSub;const r=this.content.getRef()&Ef|(i===null?0:Of)|(s===null?0:Cf)|(n===null?0:Sf);t.writeInfo(r);if(i!==null){t.writeLeftID(i)}if(s!==null){t.writeRightID(s)}if(i===null&&s===null){const e=this.parent;if(e._item!==undefined){const i=e._item;if(i===null){const i=nd(e);t.writeParentInfo(true);t.writeString(i)}else{t.writeParentInfo(false);t.writeLeftID(i.id)}}else if(e.constructor===String){t.writeParentInfo(true);t.writeString(e)}else if(e.constructor===ed){t.writeParentInfo(false);t.writeLeftID(e)}else{ku()}if(n!==null){t.writeString(n)}}this.content.write(t,e)}}const Np=(t,e)=>Lp[e&Ef](t);const Lp=[()=>{ku()},lp,mp,op,kp,dp,pp,Pp,bp,cp,()=>{ku()}];const _p=10;class zp extends ip{get deleted(){return true}delete(){}mergeWith(t){if(this.constructor!==t.constructor){return false}this.length+=t.length;return true}integrate(t,e){ku()}write(t,e){t.writeInfo(_p);Gf(t.restEncoder,this.length-e)}getMissing(t,e){return null}}const Yp=typeof globalThis!=="undefined"?globalThis:typeof window!=="undefined"?window:typeof global!=="undefined"?global:{};const Xp="__ $YJS$ __";if(Yp[Xp]===true){console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438")}Yp[Xp]=true;const Wp=t=>Ku(((e,i)=>{t.onerror=t=>i(new Error(t.target.error));t.onsuccess=t=>e(t.target.result)}));const Jp=(t,e)=>Ku(((i,s)=>{const n=indexedDB.open(t);n.onupgradeneeded=t=>e(t.target.result);n.onerror=t=>s(bu(t.target.error));n.onsuccess=t=>{const e=t.target.result;e.onversionchange=()=>{e.close()};i(e)}}));const Hp=t=>Wp(indexedDB.deleteDatabase(t));const Vp=(t,e)=>e.forEach((e=>t.createObjectStore.apply(t,e)));const Qp=(t,e,i="readwrite")=>{const s=t.transaction(e,i);return e.map((t=>og(s,t)))};const qp=(t,e)=>Wp(t.count(e));const Kp=(t,e)=>Wp(t.get(e));const Gp=(t,e)=>Wp(t.delete(e));const Zp=(t,e,i)=>Wp(t.put(e,i));const tg=(t,e)=>Wp(t.add(e));const eg=(t,e,i)=>Wp(t.getAll(e,i));const ig=(t,e,i)=>{let s=null;return rg(t,e,(t=>{s=t;return false}),i).then((()=>s))};const sg=(t,e=null)=>ig(t,e,"prev");const ng=(t,e)=>Ku(((i,s)=>{t.onerror=s;t.onsuccess=async t=>{const s=t.target.result;if(s===null||await e(s)===false){return i()}s.continue()}}));const rg=(t,e,i,s="next")=>ng(t.openKeyCursor(e,s),(t=>i(t.key)));const og=(t,e)=>t.objectStore(e);const hg=(t,e)=>IDBKeyRange.upperBound(t,e);const lg=(t,e)=>IDBKeyRange.lowerBound(t,e);const fg="custom";const ug="updates";const cg=500;const ag=(t,e=()=>{},i=()=>{})=>{const[s]=Qp(t.db,[ug]);return eg(s,lg(t._dbref,false)).then((n=>{if(!t._destroyed){e(s);Od(t.doc,(()=>{n.forEach((e=>La(t.doc,e)))}),t,false);i(s)}})).then((()=>sg(s).then((e=>{t._dbref=e+1})))).then((()=>qp(s).then((e=>{t._dbsize=e})))).then((()=>s))};const dg=(t,e=true)=>ag(t).then((i=>{if(e||t._dbsize>=cg){tg(i,Ya(t.doc)).then((()=>Gp(i,hg(t._dbref,true)))).then((()=>qp(i).then((e=>{t._dbsize=e}))))}}));class wg extends wf{constructor(t,e){super();this.doc=e;this.name=t;this._dbref=0;this._dbsize=0;this._destroyed=false;this.db=null;this.synced=false;this._db=Jp(t,(t=>Vp(t,[["updates",{autoIncrement:true}],["custom"]])));this.whenSynced=Ku((t=>this.on("synced",(()=>t(this)))));this._db.then((t=>{this.db=t;const i=t=>tg(t,Ya(e));const s=()=>{if(this._destroyed)return this;this.synced=true;this.emit("synced",[this])};ag(this,i,s)}));this._storeTimeout=1e3;this._storeTimeoutId=null;this._storeUpdate=(t,e)=>{if(this.db&&e!==this){const[e]=Qp(this.db,[ug]);tg(e,t);if(++this._dbsize>=cg){if(this._storeTimeoutId!==null){clearTimeout(this._storeTimeoutId)}this._storeTimeoutId=setTimeout((()=>{dg(this,false);this._storeTimeoutId=null}),this._storeTimeout)}}};e.on("update",this._storeUpdate);this.destroy=this.destroy.bind(this);e.on("destroy",this.destroy)}destroy(){if(this._storeTimeoutId){clearTimeout(this._storeTimeoutId)}this.doc.off("update",this._storeUpdate);this.doc.off("destroy",this.destroy);this._destroyed=true;return this._db.then((t=>{t.close()}))}clearData(){return this.destroy().then((()=>{Hp(this.name)}))}get(t){return this._db.then((e=>{const[i]=Qp(e,[fg],"readonly");return Kp(i,t)}))}set(t,e){return this._db.then((i=>{const[s]=Qp(i,[fg]);return Zp(s,e,t)}))}del(t){return this._db.then((e=>{const[i]=Qp(e,[fg]);return Gp(i,t)}))}}class pg{provider;isConnected=false;constructor(t,e,i){const s=i?.name||t;this.provider=new wg(s,e);console.info(`IndexedDB Persistence initialized: ${s}`)}async connect(){if(this.isConnected){return}return new Promise((t=>{this.provider.on("synced",(()=>{this.isConnected=true;t()}))}))}disconnect(){this.isConnected=false}destroy(){if(this.provider){this.provider.destroy()}this.isConnected=false}}const gg=Math.floor;const mg=(t,e)=>t<e?t:e;const yg=(t,e)=>t>e?t:e;const vg=128;const bg=127;const Mg=Number.MAX_SAFE_INTEGER;const kg=t=>{const e=unescape(encodeURIComponent(t));const i=e.length;const s=new Uint8Array(i);for(let t=0;t<i;t++){s[t]=e.codePointAt(t)}return s};const Ag=typeof TextEncoder!=="undefined"?new TextEncoder:null;const xg=t=>Ag.encode(t);const Sg=Ag?xg:kg;let Cg=typeof TextDecoder==="undefined"?null:new TextDecoder("utf-8",{fatal:true,ignoreBOM:true});if(Cg&&Cg.decode(new Uint8Array).length===1){Cg=null}const Og=(t,e)=>{const i=t.cbuf.length;if(t.cpos===i){t.bufs.push(t.cbuf);t.cbuf=new Uint8Array(i*2);t.cpos=0}t.cbuf[t.cpos++]=e};const Eg=(t,e)=>{while(e>bg){Og(t,vg|bg&e);e=gg(e/128)}Og(t,bg&e)};const Tg=new Uint8Array(3e4);const Dg=Tg.length/3;const Ig=(t,e)=>{if(e.length<Dg){const i=Ag.encodeInto(e,Tg).written||0;Eg(t,i);for(let e=0;e<i;e++){Og(t,Tg[e])}}else{Ug(t,Sg(e))}};const Pg=(t,e)=>{const i=unescape(encodeURIComponent(e));const s=i.length;Eg(t,s);for(let e=0;e<s;e++){Og(t,i.codePointAt(e))}};const Rg=Ag&&Ag.encodeInto?Ig:Pg;const $g=(t,e)=>{const i=t.cbuf.length;const s=t.cpos;const n=mg(i-s,e.length);const r=e.length-n;t.cbuf.set(e.subarray(0,n),s);t.cpos+=n;if(r>0){t.bufs.push(t.cbuf);t.cbuf=new Uint8Array(yg(i*2,r));t.cbuf.set(e.subarray(n));t.cpos=r}};const Ug=(t,e)=>{Eg(t,e.byteLength);$g(t,e)};const jg=t=>new Error(t);const Bg=jg("Unexpected end of array");const Fg=jg("Integer out of Range");const Ng=(t,e)=>{const i=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);t.pos+=e;return i};const Lg=t=>Ng(t,zg(t));const _g=t=>t.arr[t.pos++];const zg=t=>{let e=0;let i=1;const s=t.arr.length;while(t.pos<s){const s=t.arr[t.pos++];e=e+(s&bg)*i;i*=128;if(s<vg){return e}if(e>Mg){throw Fg}}throw Bg};const Yg=t=>{let e=zg(t);if(e===0){return""}else{let i=String.fromCodePoint(_g(t));if(--e<100){while(e--){i+=String.fromCodePoint(_g(t))}}else{while(e>0){const s=e<1e4?e:1e4;const n=t.arr.subarray(t.pos,t.pos+s);t.pos+=s;i+=String.fromCodePoint.apply(null,n);e-=s}}return decodeURIComponent(escape(i))}};const Xg=t=>Cg.decode(Lg(t));const Wg=Cg?Xg:Yg;var Jg;(function(t){t[t["Token"]=0]="Token";t[t["PermissionDenied"]=1]="PermissionDenied";t[t["Authenticated"]=2]="Authenticated"})(Jg||(Jg={}));const Hg=(t,e)=>{Eg(t,Jg.Token);Rg(t,e)};const Vg=(t,e,i,s)=>{switch(zg(t)){case Jg.Token:{e();break}case Jg.PermissionDenied:{i(Wg(t));break}case Jg.Authenticated:{s(Wg(t));break}}};const Qg=t=>Array.from(t.entries()).map((([t,e])=>({clientId:t,...e})));var qg;(function(t){t[t["Connecting"]=0]="Connecting";t[t["Open"]=1]="Open";t[t["Closing"]=2]="Closing";t[t["Closed"]=3]="Closed"})(qg||(qg={}));function Kg(t){if(!t){t={}}return{delay:t.delay===undefined?200:t.delay,initialDelay:t.initialDelay===undefined?0:t.initialDelay,minDelay:t.minDelay===undefined?0:t.minDelay,maxDelay:t.maxDelay===undefined?0:t.maxDelay,factor:t.factor===undefined?0:t.factor,maxAttempts:t.maxAttempts===undefined?3:t.maxAttempts,timeout:t.timeout===undefined?0:t.timeout,jitter:t.jitter===true,initialJitter:t.initialJitter===true,handleError:t.handleError===undefined?null:t.handleError,handleTimeout:t.handleTimeout===undefined?null:t.handleTimeout,beforeAttempt:t.beforeAttempt===undefined?null:t.beforeAttempt,calculateDelay:t.calculateDelay===undefined?null:t.calculateDelay}}async function Gg(t){return new Promise((e=>setTimeout(e,t)))}function Zg(t,e){let i=e.delay;if(i===0){return 0}if(e.factor){i*=Math.pow(e.factor,t.attemptNum-1);if(e.maxDelay!==0){i=Math.min(i,e.maxDelay)}}if(e.jitter){const t=Math.ceil(e.minDelay);const s=Math.floor(i);i=Math.floor(Math.random()*(s-t+1))+t}return Math.round(i)}async function tm(t,e){const i=Kg(e);for(const t of["delay","initialDelay","minDelay","maxDelay","maxAttempts","timeout"]){const e=i[t];if(!Number.isInteger(e)||e<0){throw new Error(`Value for ${t} must be an integer greater than or equal to 0`)}}if(i.factor.constructor!==Number||i.factor<0){throw new Error(`Value for factor must be a number greater than or equal to 0`)}if(i.delay<i.minDelay){throw new Error(`delay cannot be less than minDelay (delay: ${i.delay}, minDelay: ${i.minDelay}`)}const s={attemptNum:0,attemptsRemaining:i.maxAttempts?i.maxAttempts:-1,aborted:false,abort(){s.aborted=true}};const n=i.calculateDelay||Zg;async function r(){if(i.beforeAttempt){i.beforeAttempt(s,i)}if(s.aborted){const t=new Error(`Attempt aborted`);t.code="ATTEMPT_ABORTED";throw t}const e=async t=>{if(i.handleError){await i.handleError(t,s,i)}if(s.aborted||s.attemptsRemaining===0){throw t}s.attemptNum++;const e=n(s,i);if(e){await Gg(e)}return r()};if(s.attemptsRemaining>0){s.attemptsRemaining--}if(i.timeout){return new Promise(((n,r)=>{const o=setTimeout((()=>{if(i.handleTimeout){try{n(i.handleTimeout(s,i))}catch(t){r(t)}}else{const t=new Error(`Retry timeout (attemptNum: ${s.attemptNum}, timeout: ${i.timeout})`);t.code="ATTEMPT_TIMEOUT";r(t)}}),i.timeout);t(s,i).then((t=>{clearTimeout(o);n(t)})).catch((t=>{clearTimeout(o);e(t).then(n).catch(r)}))}))}else{return t(s,i).catch(e)}}const o=i.calculateDelay?i.calculateDelay(s,i):i.initialDelay;if(o){await Gg(o)}if(s.attemptNum<1&&i.initialJitter){const t=n(s,i);if(t){await Gg(t)}}return r()}const em=Math.floor;const im=(t,e)=>t<e?t:e;const sm=(t,e)=>t>e?t:e;const nm=64;const rm=128;const om=63;const hm=127;const lm=Number.MAX_SAFE_INTEGER;const fm=()=>new Set;const um=Array.from;const cm=t=>{const e=unescape(encodeURIComponent(t));const i=e.length;const s=new Uint8Array(i);for(let t=0;t<i;t++){s[t]=e.codePointAt(t)}return s};const am=typeof TextEncoder!=="undefined"?new TextEncoder:null;const dm=t=>am.encode(t);const wm=am?dm:cm;let pm=typeof TextDecoder==="undefined"?null:new TextDecoder("utf-8",{fatal:true,ignoreBOM:true});if(pm&&pm.decode(new Uint8Array).length===1){pm=null}class gm{constructor(){this.cpos=0;this.cbuf=new Uint8Array(100);this.bufs=[]}}const mm=()=>new gm;const ym=t=>{let e=t.cpos;for(let i=0;i<t.bufs.length;i++){e+=t.bufs[i].length}return e};const vm=t=>{const e=new Uint8Array(ym(t));let i=0;for(let s=0;s<t.bufs.length;s++){const n=t.bufs[s];e.set(n,i);i+=n.length}e.set(new Uint8Array(t.cbuf.buffer,0,t.cpos),i);return e};const bm=(t,e)=>{const i=t.cbuf.length;if(t.cpos===i){t.bufs.push(t.cbuf);t.cbuf=new Uint8Array(i*2);t.cpos=0}t.cbuf[t.cpos++]=e};const Mm=(t,e)=>{while(e>hm){bm(t,rm|hm&e);e=em(e/128)}bm(t,hm&e)};const km=new Uint8Array(3e4);const Am=km.length/3;const xm=(t,e)=>{if(e.length<Am){const i=am.encodeInto(e,km).written||0;Mm(t,i);for(let e=0;e<i;e++){bm(t,km[e])}}else{Em(t,wm(e))}};const Sm=(t,e)=>{const i=unescape(encodeURIComponent(e));const s=i.length;Mm(t,s);for(let e=0;e<s;e++){bm(t,i.codePointAt(e))}};const Cm=am&&am.encodeInto?xm:Sm;const Om=(t,e)=>{const i=t.cbuf.length;const s=t.cpos;const n=im(i-s,e.length);const r=e.length-n;t.cbuf.set(e.subarray(0,n),s);t.cpos+=n;if(r>0){t.bufs.push(t.cbuf);t.cbuf=new Uint8Array(sm(i*2,r));t.cbuf.set(e.subarray(n));t.cpos=r}};const Em=(t,e)=>{Mm(t,e.byteLength);Om(t,e)};const Tm=t=>new Error(t);const Dm=Tm("Unexpected end of array");const Im=Tm("Integer out of Range");class Pm{constructor(t){this.arr=t;this.pos=0}}const Rm=t=>new Pm(t);const $m=(t,e)=>{const i=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);t.pos+=e;return i};const Um=t=>$m(t,Bm(t));const jm=t=>t.arr[t.pos++];const Bm=t=>{let e=0;let i=1;const s=t.arr.length;while(t.pos<s){const s=t.arr[t.pos++];e=e+(s&hm)*i;i*=128;if(s<rm){return e}if(e>lm){throw Im}}throw Dm};const Fm=t=>{let e=t.arr[t.pos++];let i=e&om;let s=64;const n=(e&nm)>0?-1:1;if((e&rm)===0){return n*i}const r=t.arr.length;while(t.pos<r){e=t.arr[t.pos++];i=i+(e&hm)*s;s*=128;if(e<rm){return n*i}if(i>lm){throw Im}}throw Dm};const Nm=t=>{let e=Bm(t);if(e===0){return""}else{let i=String.fromCodePoint(jm(t));if(--e<100){while(e--){i+=String.fromCodePoint(jm(t))}}else{while(e>0){const s=e<1e4?e:1e4;const n=t.arr.subarray(t.pos,t.pos+s);t.pos+=s;i+=String.fromCodePoint.apply(null,n);e-=s}}return decodeURIComponent(escape(i))}};const Lm=t=>pm.decode(Um(t));const _m=pm?Lm:Nm;const zm=t=>{const e=t.pos;const i=_m(t);t.pos=e;return i};const Ym=Date.now;const Xm=()=>new Map;const Wm=(t,e,i)=>{let s=t.get(e);if(s===undefined){t.set(e,s=i())}return s};class Jm{constructor(){this._observers=Xm()}on(t,e){Wm(this._observers,t,fm).add(e)}once(t,e){const i=(...s)=>{this.off(t,i);e(...s)};this.on(t,i)}off(t,e){const i=this._observers.get(t);if(i!==undefined){i.delete(e);if(i.size===0){this._observers.delete(t)}}}emit(t,e){return um((this._observers.get(t)||Xm()).values()).forEach((t=>t(...e)))}destroy(){this._observers=Xm()}}const Hm=Object.keys;const Vm=t=>Hm(t).length;const Qm=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);const qm=(t,e)=>t===e;const Km=(t,e)=>{if(t==null||e==null){return qm(t,e)}if(t.constructor!==e.constructor){return false}if(t===e){return true}switch(t.constructor){case ArrayBuffer:t=new Uint8Array(t);e=new Uint8Array(e);case Uint8Array:{if(t.byteLength!==e.byteLength){return false}for(let i=0;i<t.length;i++){if(t[i]!==e[i]){return false}}break}case Set:{if(t.size!==e.size){return false}for(const i of t){if(!e.has(i)){return false}}break}case Map:{if(t.size!==e.size){return false}for(const i of t.keys()){if(!e.has(i)||!Km(t.get(i),e.get(i))){return false}}break}case Object:if(Vm(t)!==Vm(e)){return false}for(const i in t){if(!Qm(t,i)||!Km(t[i],e[i])){return false}}break;case Array:if(t.length!==e.length){return false}for(let i=0;i<t.length;i++){if(!Km(t[i],e[i])){return false}}break;default:return false}return true};const Gm=3e4;class Zm extends Jm{constructor(t){super();this.doc=t;this.clientID=t.clientID;this.states=new Map;this.meta=new Map;this._checkInterval=setInterval((()=>{const t=Ym();if(this.getLocalState()!==null&&Gm/2<=t-this.meta.get(this.clientID).lastUpdated){this.setLocalState(this.getLocalState())}const e=[];this.meta.forEach(((i,s)=>{if(s!==this.clientID&&Gm<=t-i.lastUpdated&&this.states.has(s)){e.push(s)}}));if(e.length>0){ty(this,e,"timeout")}}),em(Gm/10));t.on("destroy",(()=>{this.destroy()}));this.setLocalState({})}destroy(){this.emit("destroy",[this]);this.setLocalState(null);super.destroy();clearInterval(this._checkInterval)}getLocalState(){return this.states.get(this.clientID)||null}setLocalState(t){const e=this.clientID;const i=this.meta.get(e);const s=i===undefined?0:i.clock+1;const n=this.states.get(e);if(t===null){this.states.delete(e)}else{this.states.set(e,t)}this.meta.set(e,{clock:s,lastUpdated:Ym()});const r=[];const o=[];const h=[];const l=[];if(t===null){l.push(e)}else if(n==null){if(t!=null){r.push(e)}}else{o.push(e);if(!Km(n,t)){h.push(e)}}if(r.length>0||h.length>0||l.length>0){this.emit("change",[{added:r,updated:h,removed:l},"local"])}this.emit("update",[{added:r,updated:o,removed:l},"local"])}setLocalStateField(t,e){const i=this.getLocalState();if(i!==null){this.setLocalState({...i,[t]:e})}}getStates(){return this.states}}const ty=(t,e,i)=>{const s=[];for(let i=0;i<e.length;i++){const n=e[i];if(t.states.has(n)){t.states.delete(n);if(n===t.clientID){const e=t.meta.get(n);t.meta.set(n,{clock:e.clock+1,lastUpdated:Ym()})}s.push(n)}}if(s.length>0){t.emit("change",[{added:[],updated:[],removed:s},i]);t.emit("update",[{added:[],updated:[],removed:s},i])}};const ey=(t,e,i=t.states)=>{const s=e.length;const n=mm();Mm(n,s);for(let r=0;r<s;r++){const s=e[r];const o=i.get(s)||null;const h=t.meta.get(s).clock;Mm(n,s);Mm(n,h);Cm(n,JSON.stringify(o))}return vm(n)};const iy=(t,e,i)=>{const s=Rm(e);const n=Ym();const r=[];const o=[];const h=[];const l=[];const f=Bm(s);for(let e=0;e<f;e++){const e=Bm(s);let i=Bm(s);const f=JSON.parse(_m(s));const u=t.meta.get(e);const c=t.states.get(e);const a=u===undefined?0:u.clock;if(a<i||a===i&&f===null&&t.states.has(e)){if(f===null){if(e===t.clientID&&t.getLocalState()!=null){i++}else{t.states.delete(e)}}else{t.states.set(e,f)}t.meta.set(e,{clock:i,lastUpdated:n});if(u===undefined&&f!==null){r.push(e)}else if(u!==undefined&&f===null){l.push(e)}else if(f!==null){if(!Km(f,c)){h.push(e)}o.push(e)}}}if(r.length>0||h.length>0||l.length>0){t.emit("change",[{added:r,updated:h,removed:l},i])}if(r.length>0||o.length>0||l.length>0){t.emit("update",[{added:r,updated:o,removed:l},i])}};class sy{constructor(){this.callbacks={}}on(t,e){if(!this.callbacks[t]){this.callbacks[t]=[]}this.callbacks[t].push(e);return this}emit(t,...e){const i=this.callbacks[t];if(i){i.forEach((t=>t.apply(this,e)))}return this}off(t,e){const i=this.callbacks[t];if(i){if(e){this.callbacks[t]=i.filter((t=>t!==e))}else{delete this.callbacks[t]}}return this}removeAllListeners(){this.callbacks={}}}class ny{constructor(t){this.data=t;this.encoder=mm();this.decoder=Rm(new Uint8Array(this.data))}peekVarString(){return zm(this.decoder)}readVarUint(){return Bm(this.decoder)}readVarString(){return _m(this.decoder)}readVarUint8Array(){return Um(this.decoder)}writeVarUint(t){return Mm(this.encoder,t)}writeVarString(t){return Cm(this.encoder,t)}writeVarUint8Array(t){return Em(this.encoder,t)}length(){return ym(this.encoder)}}var ry;(function(t){t[t["Sync"]=0]="Sync";t[t["Awareness"]=1]="Awareness";t[t["Auth"]=2]="Auth";t[t["QueryAwareness"]=3]="QueryAwareness";t[t["Stateless"]=5]="Stateless";t[t["CLOSE"]=7]="CLOSE";t[t["SyncStatus"]=8]="SyncStatus"})(ry||(ry={}));var oy;(function(t){t["Connecting"]="connecting";t["Connected"]="connected";t["Disconnected"]="disconnected"})(oy||(oy={}));class hy{constructor(){this.encoder=mm()}get(t){return t.encoder}toUint8Array(){return vm(this.encoder)}}class ly extends hy{constructor(){super(...arguments);this.type=ry.CLOSE;this.description="Ask the server to close the connection"}get(t){Cm(this.encoder,t.documentName);Mm(this.encoder,this.type);return this.encoder}}class fy extends sy{constructor(t){super();this.messageQueue=[];this.configuration={url:"",autoConnect:true,document:undefined,WebSocketPolyfill:undefined,messageReconnectTimeout:3e4,delay:1e3,initialDelay:0,factor:2,maxAttempts:0,minDelay:1e3,maxDelay:3e4,jitter:true,timeout:0,onOpen:()=>null,onConnect:()=>null,onMessage:()=>null,onOutgoingMessage:()=>null,onStatus:()=>null,onDisconnect:()=>null,onClose:()=>null,onDestroy:()=>null,onAwarenessUpdate:()=>null,onAwarenessChange:()=>null,handleTimeout:null,providerMap:new Map};this.webSocket=null;this.webSocketHandlers={};this.shouldConnect=true;this.status=oy.Disconnected;this.lastMessageReceived=0;this.identifier=0;this.intervals={connectionChecker:null};this.connectionAttempt=null;this.receivedOnOpenPayload=undefined;this.closeTries=0;this.setConfiguration(t);this.configuration.WebSocketPolyfill=t.WebSocketPolyfill?t.WebSocketPolyfill:WebSocket;this.on("open",this.configuration.onOpen);this.on("open",this.onOpen.bind(this));this.on("connect",this.configuration.onConnect);this.on("message",this.configuration.onMessage);this.on("outgoingMessage",this.configuration.onOutgoingMessage);this.on("status",this.configuration.onStatus);this.on("disconnect",this.configuration.onDisconnect);this.on("close",this.configuration.onClose);this.on("destroy",this.configuration.onDestroy);this.on("awarenessUpdate",this.configuration.onAwarenessUpdate);this.on("awarenessChange",this.configuration.onAwarenessChange);this.on("close",this.onClose.bind(this));this.on("message",this.onMessage.bind(this));this.intervals.connectionChecker=setInterval(this.checkConnection.bind(this),this.configuration.messageReconnectTimeout/10);if(this.shouldConnect){this.connect()}}async onOpen(t){this.status=oy.Connected;this.emit("status",{status:oy.Connected});this.cancelWebsocketRetry=undefined;this.receivedOnOpenPayload=t}attach(t){this.configuration.providerMap.set(t.configuration.name,t);if(this.status===oy.Disconnected&&this.shouldConnect){this.connect()}if(this.receivedOnOpenPayload&&this.status===oy.Connected){t.onOpen(this.receivedOnOpenPayload)}}detach(t){if(this.configuration.providerMap.has(t.configuration.name)){t.send(ly,{documentName:t.configuration.name});this.configuration.providerMap.delete(t.configuration.name)}}setConfiguration(t={}){this.configuration={...this.configuration,...t};if(!this.configuration.autoConnect){this.shouldConnect=false}}async connect(){if(this.status===oy.Connected){return}if(this.cancelWebsocketRetry){this.cancelWebsocketRetry();this.cancelWebsocketRetry=undefined}this.receivedOnOpenPayload=undefined;this.shouldConnect=true;const t=()=>{let t=false;const e=tm(this.createWebSocketConnection.bind(this),{delay:this.configuration.delay,initialDelay:this.configuration.initialDelay,factor:this.configuration.factor,maxAttempts:this.configuration.maxAttempts,minDelay:this.configuration.minDelay,maxDelay:this.configuration.maxDelay,jitter:this.configuration.jitter,timeout:this.configuration.timeout,handleTimeout:this.configuration.handleTimeout,beforeAttempt:e=>{if(!this.shouldConnect||t){e.abort()}}}).catch((t=>{if(t&&t.code!=="ATTEMPT_ABORTED"){throw t}}));return{retryPromise:e,cancelFunc:()=>{t=true}}};const{retryPromise:e,cancelFunc:i}=t();this.cancelWebsocketRetry=i;return e}attachWebSocketListeners(t,e){const{identifier:i}=t;const s=t=>this.emit("message",t);const n=t=>this.emit("close",{event:t});const r=t=>this.emit("open",t);const o=t=>{e(t)};this.webSocketHandlers[i]={message:s,close:n,open:r,error:o};const h=this.webSocketHandlers[t.identifier];Object.keys(h).forEach((e=>{t.addEventListener(e,h[e])}))}cleanupWebSocket(){if(!this.webSocket){return}const{identifier:t}=this.webSocket;const e=this.webSocketHandlers[t];Object.keys(e).forEach((i=>{var s;(s=this.webSocket)===null||s===void 0?void 0:s.removeEventListener(i,e[i]);delete this.webSocketHandlers[t]}));this.webSocket.close();this.webSocket=null}createWebSocketConnection(){return new Promise(((t,e)=>{if(this.webSocket){this.messageQueue=[];this.cleanupWebSocket()}this.lastMessageReceived=0;this.identifier+=1;const i=new this.configuration.WebSocketPolyfill(this.url);i.binaryType="arraybuffer";i.identifier=this.identifier;this.attachWebSocketListeners(i,e);this.webSocket=i;this.status=oy.Connecting;this.emit("status",{status:oy.Connecting});this.connectionAttempt={resolve:t,reject:e}}))}onMessage(t){var e;this.resolveConnectionAttempt();this.lastMessageReceived=Ym();const i=new ny(t.data);const s=i.peekVarString();(e=this.configuration.providerMap.get(s))===null||e===void 0?void 0:e.onMessage(t)}resolveConnectionAttempt(){if(this.connectionAttempt){this.connectionAttempt.resolve();this.connectionAttempt=null;this.status=oy.Connected;this.emit("status",{status:oy.Connected});this.emit("connect");this.messageQueue.forEach((t=>this.send(t)));this.messageQueue=[]}}stopConnectionAttempt(){this.connectionAttempt=null}rejectConnectionAttempt(){var t;(t=this.connectionAttempt)===null||t===void 0?void 0:t.reject();this.connectionAttempt=null}checkConnection(){var t;if(this.status!==oy.Connected){return}if(!this.lastMessageReceived){return}if(this.configuration.messageReconnectTimeout>=Ym()-this.lastMessageReceived){return}this.closeTries+=1;if(this.closeTries>2){this.onClose({event:{code:4408,reason:"forced"}});this.closeTries=0}else{(t=this.webSocket)===null||t===void 0?void 0:t.close();this.messageQueue=[]}}get serverUrl(){while(this.configuration.url[this.configuration.url.length-1]==="/"){return this.configuration.url.slice(0,this.configuration.url.length-1)}return this.configuration.url}get url(){return this.serverUrl}disconnect(){this.shouldConnect=false;if(this.webSocket===null){return}try{this.webSocket.close();this.messageQueue=[]}catch(t){console.error(t)}}send(t){var e;if(((e=this.webSocket)===null||e===void 0?void 0:e.readyState)===qg.Open){this.webSocket.send(t)}else{this.messageQueue.push(t)}}onClose({event:t}){this.closeTries=0;this.cleanupWebSocket();if(this.connectionAttempt){this.rejectConnectionAttempt()}this.status=oy.Disconnected;this.emit("status",{status:oy.Disconnected});this.emit("disconnect",{event:t});if(!this.cancelWebsocketRetry&&this.shouldConnect){setTimeout((()=>{this.connect()}),this.configuration.delay)}}destroy(){this.emit("destroy");clearInterval(this.intervals.connectionChecker);this.stopConnectionAttempt();this.disconnect();this.removeAllListeners();this.cleanupWebSocket()}}const uy=0;const cy=1;const ay=2;const dy=(t,e)=>{Mm(t,uy);const i=Qa(e);Em(t,i)};const wy=(t,e,i)=>{Mm(t,cy);Em(t,Ya(e,i))};const py=(t,e,i)=>wy(e,i,Um(t));const gy=(t,e,i)=>{try{La(e,Um(t),i)}catch(t){console.error("Caught error while handling a Yjs update",t)}};const my=(t,e)=>{Mm(t,ay);Em(t,e)};const yy=gy;const vy=(t,e,i,s)=>{const n=Bm(t);switch(n){case uy:py(t,e,i);break;case cy:gy(t,i,s);break;case ay:yy(t,i,s);break;default:throw new Error("Unknown message type")}return n};class by{constructor(t){this.message=t}apply(t,e){const{message:i}=this;const s=i.readVarUint();const n=i.length();switch(s){case ry.Sync:this.applySyncMessage(t,e);break;case ry.Awareness:this.applyAwarenessMessage(t);break;case ry.Auth:this.applyAuthMessage(t);break;case ry.QueryAwareness:this.applyQueryAwarenessMessage(t);break;case ry.Stateless:t.receiveStateless(_m(i.decoder));break;case ry.SyncStatus:this.applySyncStatusMessage(t,Fm(i.decoder)===1);break;case ry.CLOSE:const n={code:1e3,reason:_m(i.decoder),target:t.configuration.websocketProvider.webSocket,type:"close"};t.onClose();t.configuration.onClose({event:n});t.forwardClose(n);break;default:throw new Error(`Can’t apply message of unknown type: ${s}`)}if(i.length()>n+1){t.send(hy,{encoder:i.encoder})}}applySyncMessage(t,e){const{message:i}=this;i.writeVarUint(ry.Sync);const s=vy(i.decoder,i.encoder,t.document,t);if(e&&s===cy){t.synced=true}}applySyncStatusMessage(t,e){if(e){t.decrementUnsyncedChanges()}}applyAwarenessMessage(t){if(!t.awareness)return;const{message:e}=this;iy(t.awareness,e.readVarUint8Array(),t)}applyAuthMessage(t){const{message:e}=this;Vg(e.decoder,t.sendToken.bind(t),t.permissionDeniedHandler.bind(t),t.authenticatedHandler.bind(t))}applyQueryAwarenessMessage(t){if(!t.awareness)return;const{message:e}=this;e.writeVarUint(ry.Awareness);e.writeVarUint8Array(ey(t.awareness,Array.from(t.awareness.getStates().keys())))}}class My{constructor(t,e={}){this.message=new t;this.encoder=this.message.get(e)}create(){return vm(this.encoder)}send(t){t===null||t===void 0?void 0:t.send(this.create())}}class ky extends hy{constructor(){super(...arguments);this.type=ry.Auth;this.description="Authentication"}get(t){if(typeof t.token==="undefined"){throw new Error("The authentication message requires `token` as an argument.")}Cm(this.encoder,t.documentName);Mm(this.encoder,this.type);Hg(this.encoder,t.token);return this.encoder}}class Ay extends hy{constructor(){super(...arguments);this.type=ry.Awareness;this.description="Awareness states update"}get(t){if(typeof t.awareness==="undefined"){throw new Error("The awareness message requires awareness as an argument")}if(typeof t.clients==="undefined"){throw new Error("The awareness message requires clients as an argument")}Cm(this.encoder,t.documentName);Mm(this.encoder,this.type);let e;if(t.states===undefined){e=ey(t.awareness,t.clients)}else{e=ey(t.awareness,t.clients,t.states)}Em(this.encoder,e);return this.encoder}}class xy extends hy{constructor(){super(...arguments);this.type=ry.Stateless;this.description="A stateless message"}get(t){var e;Cm(this.encoder,t.documentName);Mm(this.encoder,this.type);Cm(this.encoder,(e=t.payload)!==null&&e!==void 0?e:"");return this.encoder}}class Sy extends hy{constructor(){super(...arguments);this.type=ry.Sync;this.description="First sync step"}get(t){if(typeof t.document==="undefined"){throw new Error("The sync step one message requires document as an argument")}Cm(this.encoder,t.documentName);Mm(this.encoder,this.type);dy(this.encoder,t.document);return this.encoder}}class Cy extends hy{constructor(){super(...arguments);this.type=ry.Sync;this.description="A document update"}get(t){Cm(this.encoder,t.documentName);Mm(this.encoder,this.type);my(this.encoder,t.update);return this.encoder}}class Oy extends Error{constructor(){super(...arguments);this.code=1001}}class Ey extends sy{constructor(t){var e,i,s;super();this.configuration={name:"",document:undefined,awareness:undefined,token:null,forceSyncInterval:false,onAuthenticated:()=>null,onAuthenticationFailed:()=>null,onOpen:()=>null,onConnect:()=>null,onMessage:()=>null,onOutgoingMessage:()=>null,onSynced:()=>null,onStatus:()=>null,onDisconnect:()=>null,onClose:()=>null,onDestroy:()=>null,onAwarenessUpdate:()=>null,onAwarenessChange:()=>null,onStateless:()=>null,onUnsyncedChanges:()=>null};this.isSynced=false;this.unsyncedChanges=0;this.isAuthenticated=false;this.authorizedScope=undefined;this.manageSocket=false;this._isAttached=false;this.intervals={forceSync:null};this.boundDocumentUpdateHandler=this.documentUpdateHandler.bind(this);this.boundAwarenessUpdateHandler=this.awarenessUpdateHandler.bind(this);this.boundPageHide=this.pageHide.bind(this);this.boundOnOpen=this.onOpen.bind(this);this.boundOnClose=this.onClose.bind(this);this.forwardConnect=()=>this.emit("connect");this.forwardStatus=t=>this.emit("status",t);this.forwardClose=t=>this.emit("close",t);this.forwardDisconnect=t=>this.emit("disconnect",t);this.forwardDestroy=()=>this.emit("destroy");this.setConfiguration(t);this.configuration.document=t.document?t.document:new xa;this.configuration.awareness=t.awareness!==undefined?t.awareness:new Zm(this.document);this.on("open",this.configuration.onOpen);this.on("message",this.configuration.onMessage);this.on("outgoingMessage",this.configuration.onOutgoingMessage);this.on("synced",this.configuration.onSynced);this.on("destroy",this.configuration.onDestroy);this.on("awarenessUpdate",this.configuration.onAwarenessUpdate);this.on("awarenessChange",this.configuration.onAwarenessChange);this.on("stateless",this.configuration.onStateless);this.on("unsyncedChanges",this.configuration.onUnsyncedChanges);this.on("authenticated",this.configuration.onAuthenticated);this.on("authenticationFailed",this.configuration.onAuthenticationFailed);(e=this.awareness)===null||e===void 0?void 0:e.on("update",(()=>{this.emit("awarenessUpdate",{states:Qg(this.awareness.getStates())})}));(i=this.awareness)===null||i===void 0?void 0:i.on("change",(()=>{this.emit("awarenessChange",{states:Qg(this.awareness.getStates())})}));this.document.on("update",this.boundDocumentUpdateHandler);(s=this.awareness)===null||s===void 0?void 0:s.on("update",this.boundAwarenessUpdateHandler);this.registerEventListeners();if(this.configuration.forceSyncInterval&&typeof this.configuration.forceSyncInterval==="number"){this.intervals.forceSync=setInterval(this.forceSync.bind(this),this.configuration.forceSyncInterval)}if(this.manageSocket){this.attach()}}setConfiguration(t={}){if(!t.websocketProvider){const e=t;this.manageSocket=true;this.configuration.websocketProvider=new fy({url:e.url})}this.configuration={...this.configuration,...t}}get document(){return this.configuration.document}get isAttached(){return this._isAttached}get awareness(){return this.configuration.awareness}get hasUnsyncedChanges(){return this.unsyncedChanges>0}resetUnsyncedChanges(){this.unsyncedChanges=1;this.emit("unsyncedChanges",{number:this.unsyncedChanges})}incrementUnsyncedChanges(){this.unsyncedChanges+=1;this.emit("unsyncedChanges",{number:this.unsyncedChanges})}decrementUnsyncedChanges(){if(this.unsyncedChanges>0){this.unsyncedChanges-=1}if(this.unsyncedChanges===0){this.synced=true}this.emit("unsyncedChanges",{number:this.unsyncedChanges})}forceSync(){this.resetUnsyncedChanges();this.send(Sy,{document:this.document,documentName:this.configuration.name})}pageHide(){if(this.awareness){ty(this.awareness,[this.document.clientID],"page hide")}}registerEventListeners(){if(typeof window==="undefined"||!("addEventListener"in window)){return}window.addEventListener("pagehide",this.boundPageHide)}sendStateless(t){this.send(xy,{documentName:this.configuration.name,payload:t})}async sendToken(){let t;try{t=await this.getToken()}catch(t){this.permissionDeniedHandler(`Failed to get token during sendToken(): ${t}`);return}this.send(ky,{token:t!==null&&t!==void 0?t:"",documentName:this.configuration.name})}documentUpdateHandler(t,e){if(e===this){return}this.incrementUnsyncedChanges();this.send(Cy,{update:t,documentName:this.configuration.name})}awarenessUpdateHandler({added:t,updated:e,removed:i},s){const n=t.concat(e).concat(i);this.send(Ay,{awareness:this.awareness,clients:n,documentName:this.configuration.name})}get synced(){return this.isSynced}set synced(t){if(this.isSynced===t){return}this.isSynced=t;if(t){this.emit("synced",{state:t})}}receiveStateless(t){this.emit("stateless",{payload:t})}async connect(){if(this.manageSocket){return this.configuration.websocketProvider.connect()}console.warn("HocuspocusProvider::connect() is deprecated and does not do anything. Please connect/disconnect on the websocketProvider, or attach/deattach providers.")}disconnect(){if(this.manageSocket){return this.configuration.websocketProvider.disconnect()}console.warn("HocuspocusProvider::disconnect() is deprecated and does not do anything. Please connect/disconnect on the websocketProvider, or attach/deattach providers.")}async onOpen(t){this.isAuthenticated=false;this.emit("open",{event:t});await this.sendToken();this.startSync()}async getToken(){if(typeof this.configuration.token==="function"){const t=await this.configuration.token();return t}return this.configuration.token}startSync(){this.resetUnsyncedChanges();this.send(Sy,{document:this.document,documentName:this.configuration.name});if(this.awareness&&this.awareness.getLocalState()!==null){this.send(Ay,{awareness:this.awareness,clients:[this.document.clientID],documentName:this.configuration.name})}}send(t,e){if(!this._isAttached)return;const i=new My(t,e);this.emit("outgoingMessage",{message:i.message});i.send(this.configuration.websocketProvider)}onMessage(t){const e=new ny(t.data);const i=e.readVarString();e.writeVarString(i);this.emit("message",{event:t,message:new ny(t.data)});new by(e).apply(this,true)}onClose(){this.isAuthenticated=false;this.synced=false;if(this.awareness){ty(this.awareness,Array.from(this.awareness.getStates().keys()).filter((t=>t!==this.document.clientID)),this)}}destroy(){this.emit("destroy");if(this.intervals.forceSync){clearInterval(this.intervals.forceSync)}if(this.awareness){ty(this.awareness,[this.document.clientID],"provider destroy");this.awareness.off("update",this.boundAwarenessUpdateHandler);this.awareness.destroy()}this.document.off("update",this.boundDocumentUpdateHandler);this.removeAllListeners();this.detach();if(this.manageSocket){this.configuration.websocketProvider.destroy()}if(typeof window==="undefined"||!("removeEventListener"in window)){return}window.removeEventListener("pagehide",this.boundPageHide)}detach(){this.configuration.websocketProvider.off("connect",this.configuration.onConnect);this.configuration.websocketProvider.off("connect",this.forwardConnect);this.configuration.websocketProvider.off("status",this.forwardStatus);this.configuration.websocketProvider.off("status",this.configuration.onStatus);this.configuration.websocketProvider.off("open",this.boundOnOpen);this.configuration.websocketProvider.off("close",this.boundOnClose);this.configuration.websocketProvider.off("close",this.configuration.onClose);this.configuration.websocketProvider.off("close",this.forwardClose);this.configuration.websocketProvider.off("disconnect",this.configuration.onDisconnect);this.configuration.websocketProvider.off("disconnect",this.forwardDisconnect);this.configuration.websocketProvider.off("destroy",this.configuration.onDestroy);this.configuration.websocketProvider.off("destroy",this.forwardDestroy);this.configuration.websocketProvider.detach(this);this._isAttached=false}attach(){if(this._isAttached)return;this.configuration.websocketProvider.on("connect",this.configuration.onConnect);this.configuration.websocketProvider.on("connect",this.forwardConnect);this.configuration.websocketProvider.on("status",this.configuration.onStatus);this.configuration.websocketProvider.on("status",this.forwardStatus);this.configuration.websocketProvider.on("open",this.boundOnOpen);this.configuration.websocketProvider.on("close",this.boundOnClose);this.configuration.websocketProvider.on("close",this.configuration.onClose);this.configuration.websocketProvider.on("close",this.forwardClose);this.configuration.websocketProvider.on("disconnect",this.configuration.onDisconnect);this.configuration.websocketProvider.on("disconnect",this.forwardDisconnect);this.configuration.websocketProvider.on("destroy",this.configuration.onDestroy);this.configuration.websocketProvider.on("destroy",this.forwardDestroy);this.configuration.websocketProvider.attach(this);this._isAttached=true}permissionDeniedHandler(t){this.emit("authenticationFailed",{reason:t});this.isAuthenticated=false}authenticatedHandler(t){this.isAuthenticated=true;this.authorizedScope=t;this.emit("authenticated",{scope:t})}setAwarenessField(t,e){if(!this.awareness){throw new Oy(`Cannot set awareness field "${t}" to ${JSON.stringify(e)}. You have disabled Awareness for this provider by explicitly passing awareness: null in the provider configuration.`)}this.awareness.setLocalStateField(t,e)}}class Ty{__class__="KritzelWorkspace";id;name;createdAt;updatedAt;viewport;_core;constructor(t,e,i={translateX:0,translateY:0,scale:1}){this.id=t;this.name=e;this.createdAt=new Date;this.updatedAt=new Date;this.viewport=i}static create(t,e){const i=new Ty(e.id,e.name,e.viewport);i._core=t;return i}addObject(t){this._core.engine.addObject(t)}serialize(){return{__class__:this.__class__,id:this.id,name:this.name,createdAt:this.createdAt.toISOString(),updatedAt:this.updatedAt.toISOString(),viewport:this.viewport}}deserialize(t){Object.assign(this,t);this.createdAt=new Date(t.createdAt);this.updatedAt=new Date(t.updatedAt);return this}}const Dy={providers:[pg]};class Iy{map;_ydoc=null;_workspacesMap=null;_providers=[];_core=null;_isReady=false;_onRemoteChangeCallback=null;get isReady(){return this._isReady}constructor(){this.map=new Map}onRemoteChange(t){this._onRemoteChangeCallback=t}async initialize(t,e){this._core=t;this._ydoc=new xa;this._workspacesMap=this._ydoc.getMap("workspaces");const i="kritzel-app-state";const s=e??Dy;for(const t of s.providers){let e;if(typeof t==="function"){e=new t(i,this._ydoc)}else{e=t.create(i,this._ydoc)}this._providers.push(e)}this._workspacesMap.observe((t=>{this.handleWorkspacesChange(t)}));await Promise.all(this._providers.map((t=>t.connect())));this._isReady=true;this.loadFromYjs()}handleWorkspacesChange(t){if(t.transaction.origin==="local"){this._core?.rerender();return}const e=Array.from(t.keysChanged);const i=[];const s=[];e.forEach((e=>{const n=t.changes.keys.get(e);if(n&&n.action==="delete"){s.push(e)}else{const t=this._workspacesMap.get(e);if(t){const e=this.reviveWorkspace(t);i.push(e)}}}));s.forEach((t=>{this.map.delete(t)}));i.forEach((t=>{this.map.set(t.id,t)}));if(this._core?.store){this._core.store.state.workspaces=this.allWorkspaces()}if(this._onRemoteChangeCallback){this._onRemoteChangeCallback()}this._core?.rerender()}reviveWorkspace(t){const e=new Ty(t.id,t.name,t.viewport);e._core=this._core;e.createdAt=new Date(t.createdAt);e.updatedAt=new Date(t.updatedAt);return e}transaction(t){if(this._ydoc){this._ydoc.transact(t,"local")}}loadFromYjs(){if(!this._workspacesMap){return}this.map.clear();this._workspacesMap.forEach(((t,e)=>{const i=this.reviveWorkspace(t);this.map.set(e,i)}))}reset(){this.map.clear();this._ydoc.transact((()=>{this._workspacesMap.clear()}),"local")}insert(t){if(!t.id){return false}this.map.set(t.id,t);if(this._workspacesMap){const e=t.serialize();this._ydoc.transact((()=>{this._workspacesMap.set(t.id,e)}),"local")}return true}update(t){if(!t.id||!this.map.has(t.id)){return false}this.map.set(t.id,t);if(this._workspacesMap){const e=t.serialize();this._ydoc.transact((()=>{this._workspacesMap.set(t.id,e)}),"local")}return true}remove(t){const e=Array.from(this.map.values()).find(t);if(!e){return false}this.map.delete(e.id);if(this._workspacesMap){this._ydoc.transact((()=>{this._workspacesMap.delete(e.id)}),"local")}return true}get(t){return this.map.get(t)}allWorkspaces(){return Array.from(this.map.values())}filter(t){return Array.from(this.map.values()).filter(t)}find(t){return Array.from(this.map.values()).find(t)}has(t){return this.map.has(t)}destroy(){this._providers.forEach((t=>t.disconnect()));this._providers=[];this.map.clear();this._workspacesMap=null;if(this._ydoc){this._ydoc.destroy();this._ydoc=null}this._isReady=false}}class Py{static isInstanceOf(t,e){return!!t&&t.__class__===e}}class Ry{_core;_anchorIndex=new Map;constructor(t){this._core=t}setAnchor(t,e,i){const s=this.getLineById(t);if(!s){return}if(e==="start"&&s.endAnchor?.objectId===i){return}if(e==="end"&&s.startAnchor?.objectId===i){return}this.removeAnchor(t,e);const n={objectId:i};if(e==="start"){s.startAnchor=n}else{s.endAnchor=n}this.addToIndex(i,t,e);this.snapEndpointToObject(s,e,i);this._core.store.state.objects.update(s)}removeAnchor(t,e){const i=this.getLineById(t);if(!i){return}const s=e==="start"?i.startAnchor:i.endAnchor;if(!s){return}this.removeFromIndex(s.objectId,t,e);if(e==="start"){i.startAnchor=undefined}else{i.endAnchor=undefined}}getAnchor(t,e){const i=this.getLineById(t);if(!i){return null}const s=e==="start"?i.startAnchor:i.endAnchor;return s??null}getLinesAnchoredTo(t){const e=this._anchorIndex.get(t);return e?Array.from(e):[]}updateAnchorsForObject(t){const e=this.getLinesAnchoredTo(t);if(e.length===0){return}const i=this.getObjectById(t);if(!i){return}for(const i of e){const e=this.getLineById(i.lineId);if(!e){continue}this.snapEndpointToObject(e,i.endpoint,t)}}snapEndpointToObject(t,e,i){const s=this.getObjectById(i);if(!s){return}const n=s.centerX;const r=s.centerY;const o=this.worldToLineLocal(t,n,r);t.updateEndpoint(e,o.x,o.y)}worldToLineLocal(t,e,i){const s=t.centerX;const n=t.centerY;const r=e-s;const o=i-n;const h=Math.cos(-t.rotation);const l=Math.sin(-t.rotation);const f=r*h-o*l;const u=r*l+o*h;const c=f+t.totalWidth/2/t.scale;const a=u+t.totalHeight/2/t.scale;const d=c*t.scale+t.x;const w=a*t.scale+t.y;return{x:d,y:w}}findSnapTarget(t,e,s,n){let r=null;let o=-Infinity;const h=this._core.store.allNonSelectionObjects;for(const l of h){if(l.id===s){continue}if(n&&l.id===n){continue}if(!this.isAnchorable(l)){continue}const h=l.rotatedPolygon;const f=[h.topLeft,h.topRight,h.bottomRight,h.bottomLeft];if(i.isPointInPolygon({x:t,y:e},f)){if(l.zIndex>o){o=l.zIndex;r={objectId:l.id,centerX:l.centerX,centerY:l.centerY}}}}return r}setSnapCandidate(t){this._core.store.state.snapCandidate=t;this._core.rerender()}getSnapCandidate(){return this._core.store.state.snapCandidate??null}clearSnapCandidate(){this._core.store.state.snapCandidate=null;this._core.rerender()}getAnchorLinesRenderData(){const t=this._core.store.selectionGroup;if(!t||t.objects.length!==1)return null;const e=t.objects[0];if(!Py.isInstanceOf(e,"KritzelLine"))return null;const i=e;const s=this.computeAnchorVisualization(i,"start");const n=this.computeAnchorVisualization(i,"end");if(!s&&!n)return null;const r=this._core.store.state.scale;const o=i.strokeWidth/i.scale;const h=`${2/r}`;const l=Math.max(o*2,4/r);const f=`${l} ${l}`;const u=8/r;return{lineStrokeWidth:o,indicatorStrokeWidth:h,dashArray:f,indicatorRadius:u,startAnchorViz:s,endAnchorViz:n}}getSnapIndicatorRenderData(){const t=this.getSnapCandidate();if(!t)return null;const e=this._core.store.state.scale;const i=8/e;const s=`${2/e}`;const n=t.lineStrokeWidth?`${t.lineStrokeWidth}`:`${4/e}`;const r=t.lineStrokeWidth||4/e;const o=Math.max(r*2,4/e);const h=`${o} ${o}`;const l=t.lineStroke||"#000000";let f=t.edgeX;let u=t.edgeY;let c;if(t.arrowOffset&&t.edgeX!==undefined&&t.edgeY!==undefined){const e=t.lineEndpointX-t.edgeX;const i=t.lineEndpointY-t.edgeY;const s=Math.sqrt(e*e+i*i);if(s>t.arrowOffset){f=t.edgeX+e/s*t.arrowOffset;u=t.edgeY+i/s*t.arrowOffset}const n=t.edgeX-t.lineEndpointX;const r=t.edgeY-t.lineEndpointY;const o=Math.sqrt(n*n+r*r);if(o>0){const e=n/o;const i=r/o;const s=-i;const h=e;const l=t.arrowOffset;const f=l;const u=t.edgeX;const a=t.edgeY;const d=u-e*l;const w=a-i*l;const p=d+s*f/2;const g=w+h*f/2;const m=d-s*f/2;const y=w-h*f/2;c=`${u},${a} ${p},${g} ${m},${y}`}}return{indicatorRadius:i,indicatorStrokeWidth:s,lineStrokeWidth:n,dashArray:h,lineStroke:l,centerX:t.centerX,centerY:t.centerY,lineEndpointX:t.lineEndpointX,lineEndpointY:t.lineEndpointY,edgeX:t.edgeX,edgeY:t.edgeY,arrowOffset:t.arrowOffset,arrowStyle:t.arrowStyle,arrowFill:t.arrowFill,solidLineEndX:f,solidLineEndY:u,arrowPoints:c,snapLinePath:(()=>{if(t.controlX!==undefined&&t.controlY!==undefined&&t.t!==undefined){const e=t.endpoint==="start"?1-t.t:t.t;if(e>=1)return undefined;const i=this.extractQuadraticSegment({x:t.lineEndpointX,y:t.lineEndpointY},{x:t.controlX,y:t.controlY},{x:t.centerX,y:t.centerY},e,1);return`M ${i.start.x} ${i.start.y} Q ${i.control.x} ${i.control.y} ${i.end.x} ${i.end.y}`}return undefined})()}}handleObjectDeleted(t){const e=this.getLinesAnchoredTo(t);for(const t of e){this.removeAnchor(t.lineId,t.endpoint);const e=this.getLineById(t.lineId);if(e){this._core.store.state.objects.update(e)}}this._anchorIndex.delete(t)}handleLineDeleted(t){const e=this.getLineById(t);if(!e){return}if(e.startAnchor){this.removeFromIndex(e.startAnchor.objectId,t,"start")}if(e.endAnchor){this.removeFromIndex(e.endAnchor.objectId,t,"end")}}rebuildIndex(){this._anchorIndex.clear();const t=this._core.store.allObjects;for(const e of t){if(e instanceof qh){if(e.startAnchor){this.addToIndex(e.startAnchor.objectId,e.id,"start")}if(e.endAnchor){this.addToIndex(e.endAnchor.objectId,e.id,"end")}}}}addToIndex(t,e,i){if(!this._anchorIndex.has(t)){this._anchorIndex.set(t,new Set)}const s=this._anchorIndex.get(t);for(const t of s){if(t.lineId===e&&t.endpoint===i){return}}s.add({lineId:e,endpoint:i})}removeFromIndex(t,e,i){const s=this._anchorIndex.get(t);if(!s){return}for(const t of s){if(t.lineId===e&&t.endpoint===i){s.delete(t);break}}if(s.size===0){this._anchorIndex.delete(t)}}getLineById(t){const e=this._core.store.state.objects.filter((e=>e.id===t));if(e.length===0){return null}const i=e[0];return i instanceof qh?i:null}getObjectById(t){const e=this._core.store.state.objects.filter((e=>e.id===t));return e.length>0?e[0]:null}findAnchorTarget(t,e){const i=e==="start"?t.startAnchor:t.endAnchor;if(!i){return null}return this._core.store.allNonSelectionObjects.find((t=>t.id===i.objectId))??null}computeAnchorVisualization(t,e){const i=e==="start"?t.startAnchor:t.endAnchor;if(!i)return null;const s=this.findAnchorTarget(t,e);if(!s)return null;const n=this.computeAnchorClipInfo(t,e,s);if(!n)return null;const r=s.centerX;const o=s.centerY;return{edgeX:n.worldX,edgeY:n.worldY,centerX:r,centerY:o,pathD:this.buildAnchorPath(t,e,n,s)??undefined}}computeClippedLinePath(t,e=false){const i=this.getSnapCandidate();const s=this._core.store.selectionGroup;const n=i&&s&&s.objects.length===1&&s.objects[0].id===t.id;if(!t.startAnchor&&!t.endAnchor&&!n){if(e){if(t.controlX!==undefined&&t.controlY!==undefined){return`M ${t.startX-t.x} ${t.startY-t.y} Q ${t.controlX-t.x} ${t.controlY-t.y} ${t.endX-t.x} ${t.endY-t.y}`}return`M ${t.startX-t.x} ${t.startY-t.y} L ${t.endX-t.x} ${t.endY-t.y}`}return t.d}const r=t.startAnchor?this.findAnchorTarget(t,"start"):null;const o=t.endAnchor?this.findAnchorTarget(t,"end"):null;let h=r?this.computeAnchorClipInfo(t,"start",r):null;let l=o?this.computeAnchorClipInfo(t,"end",o):null;if(n){if(i.edgeX!==undefined&&i.edgeY!==undefined){const e=this.lineWorldToLocal(t,i.edgeX,i.edgeY);const s={worldX:i.edgeX,worldY:i.edgeY,localX:e.x,localY:e.y,t:i.t};if(i.endpoint==="start"){h=s}else{l=s}}}const f=e?t.x:0;const u=e?t.y:0;if(t.controlX!==undefined&&t.controlY!==undefined){let e=h?.t??0;let i=l?.t??1;if(h&&t.hasStartArrow){const i=t.getArrowSize("start");const s=this.evaluateDerivativeSpeedAtT(t,e);if(s>0){e+=i/s}}if(l&&t.hasEndArrow){const e=t.getArrowSize("end");const s=this.evaluateDerivativeSpeedAtT(t,i);if(s>0){i-=e/s}}if(e<0)e=0;if(i>1)i=1;if(i<=e){const t=(e+i)/2;e=t;i=t}const s=this.extractQuadraticSegment({x:t.startX,y:t.startY},{x:t.controlX,y:t.controlY},{x:t.endX,y:t.endY},e,i);return`M ${s.start.x-f} ${s.start.y-u} Q ${s.control.x-f} ${s.control.y-u} ${s.end.x-f} ${s.end.y-u}`}let c=h?.localX??t.startX;let a=h?.localY??t.startY;let d=l?.localX??t.endX;let w=l?.localY??t.endY;if(h&&t.hasStartArrow){const e=t.getArrowSize("start");const i=d-c;const s=w-a;const n=Math.sqrt(i*i+s*s);if(n>e){c+=i/n*e;a+=s/n*e}}if(l&&t.hasEndArrow){const e=t.getArrowSize("end");const i=c-d;const s=a-w;const n=Math.sqrt(i*i+s*s);if(n>e){d+=i/n*e;w+=s/n*e}}return`M ${c-f} ${a-u} L ${d-f} ${w-u}`}computeAnchorClipInfo(t,e,i){if(t.controlX!==undefined&&t.controlY!==undefined){return this.computeCurvedClipInfo(t,e,i)}return this.computeStraightClipInfo(t,e,i)}computeStraightClipInfo(t,e,s){const n=e==="start"?this.lineLocalToWorld(t,t.endX,t.endY):this.lineLocalToWorld(t,t.startX,t.startY);const r=this.getPathClipPoint(s,n);if(r){const i=this.lineWorldToLocal(t,r.x,r.y);const s=Math.sqrt(Math.pow(t.endX-t.startX,2)+Math.pow(t.endY-t.startY,2));const n=Math.sqrt(Math.pow(i.x-t.startX,2)+Math.pow(i.y-t.startY,2));const o=s>0?n/s:e==="start"?0:1;return{localX:i.x,localY:i.y,worldX:r.x,worldY:r.y,t:o}}const o=this.getClipPolygonForObject(s);let h;if(o){h=i.getLinePointsArrayIntersection(n,{x:s.centerX,y:s.centerY},o)}else{h=i.getLinePolygonIntersection(n,{x:s.centerX,y:s.centerY},s.rotatedPolygon)}if(!h){return null}const l=this.lineWorldToLocal(t,h.x,h.y);const f=Math.sqrt(Math.pow(t.endX-t.startX,2)+Math.pow(t.endY-t.startY,2));const u=Math.sqrt(Math.pow(l.x-t.startX,2)+Math.pow(l.y-t.startY,2));const c=f>0?u/f:e==="start"?0:1;return{localX:l.x,localY:l.y,worldX:h.x,worldY:h.y,t:c}}computeCurvedClipInfo(t,e,s){if(Py.isInstanceOf(s,"KritzelPath")){const i=s;return this.findCurveExitPointForPath(t,e,i)}const n=this.getClipPolygonForObject(s);const r=n??this.getPolygonPoints(s.rotatedPolygon);const o=this.findCurveExitPoint(t,e,r);if(o){return o}const h=e==="start"?this.lineLocalToWorld(t,t.endX,t.endY):this.lineLocalToWorld(t,t.startX,t.startY);let l;if(n){l=i.getLinePointsArrayIntersection(h,{x:s.centerX,y:s.centerY},n)}else{l=i.getLinePolygonIntersection(h,{x:s.centerX,y:s.centerY},s.rotatedPolygon)}if(!l){return null}const f=this.lineWorldToLocal(t,l.x,l.y);const u=this.approximateParameterForWorldPoint(t,l);return{localX:f.x,localY:f.y,worldX:l.x,worldY:l.y,t:u}}findCurveExitPoint(t,e,s){const n=64;const r=e==="start"?0:1;const o=this.evaluateLineAtT(t,r);let h=i.isPointInPolygon({x:o.worldX,y:o.worldY},s);let l=r;for(let r=1;r<=n;r++){const o=e==="start"?r/n:1-r/n;const f=this.evaluateLineAtT(t,o);const u=i.isPointInPolygon({x:f.worldX,y:f.worldY},s);if(h&&!u){const e=this.refineCurveExitParameter(t,s,l,o);const i=this.evaluateLineAtT(t,e);return{localX:i.localX,localY:i.localY,worldX:i.worldX,worldY:i.worldY,t:e}}h=u;l=o}return null}findCurveExitPointForPath(t,e,i){const s=64;const n=e==="start"?0:1;const r=i.strokeWidth/i.scale/2;const o=this.getPathAdjustedPoints(i);if(o.length<1){return null}const h=this.evaluateLineAtT(t,n);let l=this.isPointInPathStroke(h.worldX,h.worldY,o,r);let f=n;for(let i=1;i<=s;i++){const n=e==="start"?i/s:1-i/s;const h=this.evaluateLineAtT(t,n);const u=this.isPointInPathStroke(h.worldX,h.worldY,o,r);if(l&&!u){const e=this.refineCurveExitParameterForPath(t,o,r,f,n);const i=this.evaluateLineAtT(t,e);return{localX:i.localX,localY:i.localY,worldX:i.worldX,worldY:i.worldY,t:e}}l=u;f=n}return null}refineCurveExitParameterForPath(t,e,i,s,n){let r=s;let o=n;for(let s=0;s<8;s++){const s=(r+o)/2;const n=this.evaluateLineAtT(t,s);const h=this.isPointInPathStroke(n.worldX,n.worldY,e,i);if(h){r=s}else{o=s}}return(r+o)/2}getPathAdjustedPoints(t){return this.computePathAdjustedPoints(t)}computePathAdjustedPoints(t){if(!t.points?.length){return[]}const e=t.rotation;const i=Math.cos(e);const s=Math.sin(e);const n=t.points.map((t=>t[0]));const r=t.points.map((t=>t[1]));const o={x:(Math.min(...n)+Math.max(...n))/2,y:(Math.min(...r)+Math.max(...r))/2};const{x:h,y:l}=o;const f=t.points.map((([t,e])=>{const n=t-h;const r=e-l;return[h+n*i-r*s,l+n*s+r*i]}));return f.map((([e,i])=>[Math.abs(e-t.x)/t.scale+t.translateX,Math.abs(i-t.y)/t.scale+t.translateY]))}isPointInPathStroke(t,e,i,s){if(i.length===1){const n=i[0];const r=t-n[0];const o=e-n[1];return Math.sqrt(r*r+o*o)<=s}for(let n=0;n<i.length-1;n++){const r=i[n];const o=i[n+1];const h=this.pointToSegmentDistance(t,e,r[0],r[1],o[0],o[1]);if(h<=s){return true}}return false}pointToSegmentDistance(t,e,i,s,n,r){const o=n-i;const h=r-s;const l=o*o+h*h;if(l===0){return Math.sqrt((t-i)*(t-i)+(e-s)*(e-s))}let f=((t-i)*o+(e-s)*h)/l;f=Math.max(0,Math.min(1,f));const u=i+f*o;const c=s+f*h;return Math.sqrt((t-u)*(t-u)+(e-c)*(e-c))}refineCurveExitParameter(t,e,s,n){let r=s;let o=n;for(let s=0;s<8;s++){const s=(r+o)/2;const n=this.evaluateLineAtT(t,s);const h=i.isPointInPolygon({x:n.worldX,y:n.worldY},e);if(h){r=s}else{o=s}}return(r+o)/2}approximateParameterForWorldPoint(t,e){const i=80;let s=0;let n=Infinity;for(let r=0;r<=i;r++){const o=r/i;const h=this.evaluateLineAtT(t,o);const l=Math.hypot(h.worldX-e.x,h.worldY-e.y);if(l<n){n=l;s=o}}return s}evaluateLineAtT(t,e){const i=Math.max(0,Math.min(1,e));let s;let n;if(t.controlX!==undefined&&t.controlY!==undefined){const e=1-i;s=e*e*t.startX+2*e*i*t.controlX+i*i*t.endX;n=e*e*t.startY+2*e*i*t.controlY+i*i*t.endY}else{s=t.startX+(t.endX-t.startX)*i;n=t.startY+(t.endY-t.startY)*i}const r=this.lineLocalToWorld(t,s,n);return{t:i,localX:s,localY:n,worldX:r.x,worldY:r.y}}evaluateDerivativeSpeedAtT(t,e){const i=Math.max(0,Math.min(1,e));if(t.controlX!==undefined&&t.controlY!==undefined){const e=t.startX;const s=t.startY;const n=t.controlX;const r=t.controlY;const o=t.endX;const h=t.endY;const l=2*(1-i)*(n-e)+2*i*(o-n);const f=2*(1-i)*(r-s)+2*i*(h-r);return Math.sqrt(l*l+f*f)}else{const e=t.endX-t.startX;const i=t.endY-t.startY;return Math.sqrt(e*e+i*i)}}extractQuadraticSegment(t,e,i,s,n){let r=Math.max(0,Math.min(1,s));let o=Math.max(0,Math.min(1,n));if(o<r){const t=r;r=o;o=t}let h={start:t,control:e,end:i};if(r>0){const t=this.splitQuadraticSegment(h,r);h=t.right;const e=1-r;o=e>0?(o-r)/e:1}if(o<1){const t=this.splitQuadraticSegment(h,o);h=t.left}return h}splitQuadraticSegment(t,e){const i=Math.max(0,Math.min(1,e));const s=t.start;const n=t.control;const r=t.end;const o=this.lerpPoint(s,n,i);const h=this.lerpPoint(n,r,i);const l=this.lerpPoint(o,h,i);return{left:{start:s,control:o,end:l},right:{start:l,control:h,end:r}}}lerpPoint(t,e,i){return{x:t.x+(e.x-t.x)*i,y:t.y+(e.y-t.y)*i}}buildAnchorPath(t,e,i,s){if(t.controlX===undefined||t.controlY===undefined||i.t===undefined){return`M ${i.worldX} ${i.worldY} L ${s.centerX} ${s.centerY}`}const n=e==="start"?0:i.t;const r=e==="start"?i.t:1;if(r<=n){return`M ${i.worldX} ${i.worldY} L ${s.centerX} ${s.centerY}`}const o=this.extractQuadraticSegment({x:t.startX,y:t.startY},{x:t.controlX,y:t.controlY},{x:t.endX,y:t.endY},n,r);const h=e==="start";return this.buildWorldQuadraticPath(t,o,h)}buildWorldQuadraticPath(t,e,i=false){const s=i?e.end:e.start;const n=i?e.start:e.end;const r=e.control;const o=this.lineLocalToWorld(t,s.x,s.y);const h=this.lineLocalToWorld(t,r.x,r.y);const l=this.lineLocalToWorld(t,n.x,n.y);return`M ${o.x} ${o.y} Q ${h.x} ${h.y} ${l.x} ${l.y}`}getPolygonPoints(t){return[t.topLeft,t.topRight,t.bottomRight,t.bottomLeft]}getClipPolygonForObject(t){if(Py.isInstanceOf(t,"KritzelShape")){const e=t;return e.getClipPolygon()}return null}getPathClipPoint(t,e){if(Py.isInstanceOf(t,"KritzelPath")){const i=t;return i.getClipPoint(e)}return null}lineLocalToWorld(t,e,i){const s=e-t.x;const n=i-t.y;const r=t.totalWidth/2;const o=t.totalHeight/2;const h=Math.cos(t.rotation);const l=Math.sin(t.rotation);const f=(s-r)*h-(n-o)*l+r;const u=(s-r)*l+(n-o)*h+o;return{x:f/t.scale+t.translateX,y:u/t.scale+t.translateY}}lineWorldToLocal(t,e,i){const s=(e-t.translateX)*t.scale;const n=(i-t.translateY)*t.scale;const r=t.totalWidth/2;const o=t.totalHeight/2;const h=Math.cos(-t.rotation);const l=Math.sin(-t.rotation);const f=(s-r)*h-(n-o)*l+r;const u=(s-r)*l+(n-o)*h+o;return{x:f+t.x,y:u+t.y}}isAnchorable(t){if(t instanceof ql||t instanceof il){return false}if(t instanceof qh){return false}return t.isVisible}}const $y={type:"pen",color:"#000000",size:16,palettes:{pen:["#000000","#ff5252","#ffbc00","#00c853","#0000FF","#d500f9","#fafafa","#a52714","#ee8100","#558b2f","#01579b","#8e24aa","#90a4ae","#ff4081","#ff6e40","#aeea00","#304ffe","#7c4dff","#cfd8dc","#f8bbd0","#ffccbc","#f0f4c3","#9fa8da","#d1c4e9"],highlighter:["#0000006e","#ff52526e","#ffbb006e","#00c8536e","#0000FF6e","#d500f96e","#fafafa6e","#a527146e","#ee81006e","#558b2f6e","#01579b6e","#8e24aa6e","#90a4ae6e","#ff40816e","#ff6e406e","#aeea006e","#304ffe6e","#7c4dff6e","#cfd8dc6e","#f8bbd06e","#ffccbc6e","#f0f4c36e","#9fa8da6e","#d1c4e96e"]}};const Uy={color:"#000000",size:8,fontFamily:"Arial",palette:["#000000","#ff5252","#ffbc00","#00c853","#0000FF","#d500f9","#fafafa","#a52714","#ee8100","#558b2f","#01579b","#8e24aa","#90a4ae","#ff4081","#ff6e40","#aeea00","#304ffe","#7c4dff","#cfd8dc","#f8bbd0","#ffccbc","#f0f4c3","#9fa8da","#d1c4e9"]};const jy={color:"#000000",size:4,palette:["#000000","#ff5252","#ffbc00","#00c853","#0000FF","#d500f9","#fafafa","#a52714","#ee8100","#558b2f","#01579b","#8e24aa","#90a4ae","#ff4081","#ff6e40","#aeea00","#304ffe","#7c4dff","#cfd8dc","#f8bbd0","#ffccbc","#f0f4c3","#b3e5fc","#e1bee7"],arrows:{end:{enabled:true,style:"triangle"}}};export{s as $,kc as A,mf as B,vf as C,fy as D,Vh as E,Qh as F,qh as G,Ey as H,Kh as I,el as J,zh as K,sl as L,nl as M,Ll as N,wf as O,_l as P,Yl as Q,tf as R,pg as S,Iy as T,Ty as U,Ry as V,$y as W,Uy as X,jy as Y,r as Z,Gh as _,ou as a,rt as a0,Yo as a1,Ko as a2,So as a3,ri as a4,uh as a5,Ye as a6,n as a7,t as a8,i as a9,_h as aa,tl as ab,Zh as ac,zl as ad,Xl as ae,ql as af,il as ag,xa as ah,Dy as ai,Id as aj,e as ak,Py as al,Tu as b,La as c,Qa as d,Ya as e,Jf as f,Cu as g,hf as h,Nc as i,Fc as j,Rc as k,nc as l,Uu as m,pf as n,sc as o,qu as p,bc as q,Iu as r,nf as s,Vf as t,nu as u,ic as v,Gf as w,lc as x,df as y,Hf as z};
2
- //# sourceMappingURL=p-CuBm2vpW.js.map