pandorga 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (376) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +77 -0
  3. data/DESIGN.md +1434 -0
  4. data/LICENSE +21 -0
  5. data/README.md +81 -0
  6. data/_data/themes/dark.yml +97 -0
  7. data/_data/themes/light.yml +120 -0
  8. data/_data/themes/shared.yml +37 -0
  9. data/_data/translations.yml +85 -0
  10. data/_includes/chord-tab.html +38 -0
  11. data/_includes/content-runtime/00-config.html +22 -0
  12. data/_includes/content-runtime/10-utils.html +176 -0
  13. data/_includes/content-runtime/20-markdown.html +264 -0
  14. data/_includes/content-runtime/25-code-blocks.html +315 -0
  15. data/_includes/content-runtime/30-includes-bib.html +190 -0
  16. data/_includes/content-runtime/30-includes-xcite.html +122 -0
  17. data/_includes/content-runtime/30-includes.html +365 -0
  18. data/_includes/content-runtime/40-listing.html +225 -0
  19. data/_includes/content-runtime/41-listing-helpers.html +71 -0
  20. data/_includes/content-runtime/42-listing-filter.html +208 -0
  21. data/_includes/content-runtime/43-blocks.html +379 -0
  22. data/_includes/content-runtime/50-detail.html +861 -0
  23. data/_includes/content-runtime/55-toc.html +176 -0
  24. data/_includes/content-runtime/60-fragments.html +567 -0
  25. data/_includes/content-runtime/90-bootstrap.html +76 -0
  26. data/_includes/cut-in.html +10 -0
  27. data/_includes/cv/cv-box.html +18 -0
  28. data/_includes/dict-card.html +24 -0
  29. data/_includes/figure.html +36 -0
  30. data/_includes/home/band-index.html +43 -0
  31. data/_includes/home/band-listing.html +49 -0
  32. data/_includes/mathjax.html +10 -0
  33. data/_includes/ongoing-product.html +1 -0
  34. data/_includes/page/content-runtime.html +20 -0
  35. data/_includes/page/date_evolution.html +19 -0
  36. data/_includes/page/figure-lightbox.html +102 -0
  37. data/_includes/page/formatted_date.html +15 -0
  38. data/_includes/page/hero-default.html +18 -0
  39. data/_includes/page/listing-runtime-attrs.html +8 -0
  40. data/_includes/page/mermaid.html +101 -0
  41. data/_includes/page/network-graph.html +1253 -0
  42. data/_includes/page/page-header.html +41 -0
  43. data/_includes/page/professional-connections.html +2 -0
  44. data/_includes/page/site-footer.html +101 -0
  45. data/_includes/page/timeline-section.html +868 -0
  46. data/_includes/plotly.html +22 -0
  47. data/_includes/theme/dev-reexport.html +100 -0
  48. data/_includes/theme/favicons.html +4 -0
  49. data/_includes/theme/font-loader.html +55 -0
  50. data/_includes/theme/shell-theme-boot.html +115 -0
  51. data/_includes/theme/site-logo.html +6 -0
  52. data/_includes/theme/tailwind-theme-colors.json.liquid +65 -0
  53. data/_includes/theme/tailwind-theme-fonts.json.liquid +6 -0
  54. data/_includes/theme/theme-context.liquid +20 -0
  55. data/_includes/theme/theme-toggle.html +94 -0
  56. data/_includes/theme/theme-vars-block.liquid +161 -0
  57. data/_includes/theme/theme-vars.html +16 -0
  58. data/_includes/transcription.html +80 -0
  59. data/_includes/tweet.html +22 -0
  60. data/_includes/video.html +11 -0
  61. data/_includes/xcite.html +3 -0
  62. data/_includes/youtube-short.html +26 -0
  63. data/_includes/youtube.html +12 -0
  64. data/_layouts/article.html +27 -0
  65. data/_layouts/articles.html +534 -0
  66. data/_layouts/bibliography.html +417 -0
  67. data/_layouts/blog.html +544 -0
  68. data/_layouts/cv.html +393 -0
  69. data/_layouts/home.html +319 -0
  70. data/_layouts/network.html +9 -0
  71. data/_layouts/pandorga/articles.html +4 -0
  72. data/_layouts/pandorga/bibliography.html +4 -0
  73. data/_layouts/pandorga/blog.html +4 -0
  74. data/_layouts/pandorga/cv.html +4 -0
  75. data/_layouts/pandorga/media.html +4 -0
  76. data/_layouts/pandorga/network.html +4 -0
  77. data/_layouts/pandorga/portfolio.html +4 -0
  78. data/_layouts/post.html +7 -0
  79. data/_layouts/product.html +5 -0
  80. data/_layouts/project.html +27 -0
  81. data/_layouts/projects.html +534 -0
  82. data/_layouts/resources.html +387 -0
  83. data/_layouts/shell.html +203 -0
  84. data/_layouts/text.html +246 -0
  85. data/_plugins/bibliography_artifact.rb +57 -0
  86. data/_plugins/content_backend.rb +37 -0
  87. data/_plugins/content_collections.rb +51 -0
  88. data/_plugins/content_detail_paths.rb +58 -0
  89. data/_plugins/content_headers.rb +73 -0
  90. data/_plugins/content_keys.rb +310 -0
  91. data/_plugins/content_local_serve.rb +168 -0
  92. data/_plugins/content_site_adapter.rb +159 -0
  93. data/_plugins/content_validators_hook.rb +20 -0
  94. data/_plugins/content_writing_index.rb +52 -0
  95. data/_plugins/content_writing_paths.rb +55 -0
  96. data/_plugins/force_utf8_encoding.rb +13 -0
  97. data/_plugins/git_chronology.rb +211 -0
  98. data/_plugins/git_metadata.rb +43 -0
  99. data/_plugins/job_sections.rb +25 -0
  100. data/_plugins/lib/content_validators.rb +27 -0
  101. data/_plugins/lib/resource_validator.rb +56 -0
  102. data/_plugins/lib/tag_validator.rb +153 -0
  103. data/_plugins/lib/text_excerpt.rb +56 -0
  104. data/_plugins/lib/writing_entry.rb +107 -0
  105. data/_plugins/local_detail_rewrites.rb +194 -0
  106. data/_plugins/timeline.rb +507 -0
  107. data/_plugins/writing_slug_limits.rb +70 -0
  108. data/assets/css/article.css +1330 -0
  109. data/assets/css/base.css +1432 -0
  110. data/assets/css/cv.css +13 -0
  111. data/assets/css/global-link.css +94 -0
  112. data/assets/css/ledger/bibliography.css +307 -0
  113. data/assets/css/ledger/chrome.css +118 -0
  114. data/assets/css/ledger/cv.css +836 -0
  115. data/assets/css/ledger/detail.css +1270 -0
  116. data/assets/css/ledger/footer.css +298 -0
  117. data/assets/css/ledger/home.css +1490 -0
  118. data/assets/css/ledger/network.css +106 -0
  119. data/assets/css/ledger/projects.css +716 -0
  120. data/assets/css/ledger/rascunhos.css +379 -0
  121. data/assets/css/ledger/sources.css +327 -0
  122. data/assets/css/ledger/writing.css +754 -0
  123. data/assets/tailwind-play.js +15 -0
  124. data/examples/full/Gemfile +7 -0
  125. data/examples/full/_config.yml +92 -0
  126. data/examples/full/_redirects +3 -0
  127. data/examples/full/content/collections/articles/2026-01-01-welcome.md +9 -0
  128. data/examples/full/content/collections/data/contacts.yml +3 -0
  129. data/examples/full/content/collections/data/education.yml +4 -0
  130. data/examples/full/content/collections/jobs/research-fellow.md +12 -0
  131. data/examples/full/content/collections/posts/2026-01-02-note.md +9 -0
  132. data/examples/full/content/collections/products/ledger-tool.md +6 -0
  133. data/examples/full/content/collections/projects/demo-kit.md +10 -0
  134. data/examples/full/content/collections/resources/style-guide.md +7 -0
  135. data/examples/full/content/pages/cv/summary.md +1 -0
  136. data/examples/full/content/pages/headers.yml +20 -0
  137. data/examples/full/index.html +4 -0
  138. data/examples/minimal/Gemfile +7 -0
  139. data/examples/minimal/_config.yml +47 -0
  140. data/examples/minimal/_redirects +3 -0
  141. data/examples/minimal/content/collections/articles/2026-01-01-hello.md +10 -0
  142. data/examples/minimal/content/collections/articles/2026-01-02-second.md +9 -0
  143. data/examples/minimal/content/pages/headers.yml +6 -0
  144. data/examples/minimal/index.html +4 -0
  145. data/exe/pandorga +7 -0
  146. data/functions/api/studio/[[path]].js +562 -0
  147. data/functions/api/studio/_lib/auth.js +131 -0
  148. data/functions/api/studio/_lib/blocks.js +156 -0
  149. data/functions/api/studio/_lib/gemini.js +62 -0
  150. data/functions/api/studio/_lib/github.js +278 -0
  151. data/functions/api/studio/_lib/guidelines.js +143 -0
  152. data/functions/api/studio/_lib/paths.js +76 -0
  153. data/functions/api/studio/_lib/prompts.js +165 -0
  154. data/functions/api/studio/_lib/rate-limit.js +40 -0
  155. data/functions/api/studio/_lib/rewrite.js +136 -0
  156. data/functions/api/studio/_lib/sanitize.js +143 -0
  157. data/lib/pandorga/cli.rb +66 -0
  158. data/lib/pandorga/commands/doctor.rb +66 -0
  159. data/lib/pandorga/commands/export.rb +30 -0
  160. data/lib/pandorga/commands/install_functions.rb +41 -0
  161. data/lib/pandorga/commands/new.rb +113 -0
  162. data/lib/pandorga/commands/publish.rb +53 -0
  163. data/lib/pandorga/commands/serve.rb +34 -0
  164. data/lib/pandorga/commands/studio_schema.rb +309 -0
  165. data/lib/pandorga/jekyll/generator.rb +74 -0
  166. data/lib/pandorga/jekyll/plugins/bibliography_artifact.rb +57 -0
  167. data/lib/pandorga/jekyll/plugins/content_backend.rb +37 -0
  168. data/lib/pandorga/jekyll/plugins/content_collections.rb +51 -0
  169. data/lib/pandorga/jekyll/plugins/content_detail_paths.rb +58 -0
  170. data/lib/pandorga/jekyll/plugins/content_headers.rb +73 -0
  171. data/lib/pandorga/jekyll/plugins/content_keys.rb +310 -0
  172. data/lib/pandorga/jekyll/plugins/content_local_serve.rb +168 -0
  173. data/lib/pandorga/jekyll/plugins/content_site_adapter.rb +159 -0
  174. data/lib/pandorga/jekyll/plugins/content_validators_hook.rb +20 -0
  175. data/lib/pandorga/jekyll/plugins/content_writing_index.rb +52 -0
  176. data/lib/pandorga/jekyll/plugins/content_writing_paths.rb +55 -0
  177. data/lib/pandorga/jekyll/plugins/force_utf8_encoding.rb +13 -0
  178. data/lib/pandorga/jekyll/plugins/git_chronology.rb +211 -0
  179. data/lib/pandorga/jekyll/plugins/git_metadata.rb +43 -0
  180. data/lib/pandorga/jekyll/plugins/job_sections.rb +25 -0
  181. data/lib/pandorga/jekyll/plugins/lib/content_validators.rb +27 -0
  182. data/lib/pandorga/jekyll/plugins/lib/resource_validator.rb +56 -0
  183. data/lib/pandorga/jekyll/plugins/lib/tag_validator.rb +153 -0
  184. data/lib/pandorga/jekyll/plugins/lib/text_excerpt.rb +56 -0
  185. data/lib/pandorga/jekyll/plugins/lib/writing_entry.rb +107 -0
  186. data/lib/pandorga/jekyll/plugins/local_detail_rewrites.rb +194 -0
  187. data/lib/pandorga/jekyll/plugins/timeline.rb +507 -0
  188. data/lib/pandorga/jekyll/plugins/writing_slug_limits.rb +70 -0
  189. data/lib/pandorga/jekyll.rb +15 -0
  190. data/lib/pandorga/object_store_env.rb +51 -0
  191. data/lib/pandorga/registry/schema.yml +115 -0
  192. data/lib/pandorga/registry.rb +279 -0
  193. data/lib/pandorga/version.rb +5 -0
  194. data/lib/pandorga.rb +19 -0
  195. data/scripts/cdn-allowlist.json +19 -0
  196. data/scripts/content/backfill-content-keys.rb +99 -0
  197. data/scripts/content/band_art.rb +362 -0
  198. data/scripts/content/export-content-json.rb +741 -0
  199. data/scripts/content/flatten-ansi-capture.mjs +153 -0
  200. data/scripts/content/hero_portraits.rb +28 -0
  201. data/scripts/content/publish-content-to-object-store.sh +78 -0
  202. data/scripts/content/publish-content-to-r2.sh +5 -0
  203. data/scripts/content/sync-content-json-to-r2.rb +167 -0
  204. data/scripts/content/sync-content-redirects.rb +12 -0
  205. data/scripts/generate-configuration-doc.rb +127 -0
  206. data/scripts/lib/content_license.rb +50 -0
  207. data/scripts/lib/content_storage_config.rb +70 -0
  208. data/scripts/lib/normalize-display-math.mjs +52 -0
  209. data/scripts/lib/r2_json_sync.rb +76 -0
  210. data/scripts/lib/withdrawn_public_objects.rb +23 -0
  211. data/scripts/lib/writing_index_contract.rb +61 -0
  212. data/scripts/pdf/md-to-pdf.mjs +1400 -0
  213. data/scripts/pdf/md-to-pdf.sh +27 -0
  214. data/scripts/test/fixtures/dual-template/_config.yml +32 -0
  215. data/scripts/test/fixtures/dual-template/index.html +4 -0
  216. data/scripts/test/render-parity/article-note.json +5 -0
  217. data/scripts/test/render-parity/blockquote.json +5 -0
  218. data/scripts/test/render-parity/blocks/ansi-basic.json +7 -0
  219. data/scripts/test/render-parity/blocks/ansi-bold-is-bright.json +7 -0
  220. data/scripts/test/render-parity/blocks/ansi-drops-cursor-moves.json +7 -0
  221. data/scripts/test/render-parity/blocks/ansi-escapes-markup.json +7 -0
  222. data/scripts/test/render-parity/blocks/ansi-extended-colour.json +7 -0
  223. data/scripts/test/render-parity/blocks/ansi-real-control-byte.json +7 -0
  224. data/scripts/test/render-parity/blocks/archive-card-date-once.json +19 -0
  225. data/scripts/test/render-parity/blocks/archive-card-empty-foot.json +7 -0
  226. data/scripts/test/render-parity/blocks/archive-card-footer-dates.json +22 -0
  227. data/scripts/test/render-parity/blocks/archive-card-meta-parts.json +26 -0
  228. data/scripts/test/render-parity/blocks/archive-card.json +32 -0
  229. data/scripts/test/render-parity/blocks/cta-link.json +13 -0
  230. data/scripts/test/render-parity/blocks/lang-pill-pt.json +8 -0
  231. data/scripts/test/render-parity/blocks/lang-pill.json +8 -0
  232. data/scripts/test/render-parity/blocks/ledger-row-meta-parts.json +29 -0
  233. data/scripts/test/render-parity/blocks/ledger-row.json +35 -0
  234. data/scripts/test/render-parity/blocks/meta-strip.json +27 -0
  235. data/scripts/test/render-parity/blocks/poster-media-image.json +8 -0
  236. data/scripts/test/render-parity/blocks/poster-media-video.json +9 -0
  237. data/scripts/test/render-parity/blocks/section-banner.json +13 -0
  238. data/scripts/test/render-parity/blocks/system-card-custom-meta.json +22 -0
  239. data/scripts/test/render-parity/blocks/system-card.json +48 -0
  240. data/scripts/test/render-parity/blocks/tag-chips-links.json +12 -0
  241. data/scripts/test/render-parity/blocks/tag-chips.json +9 -0
  242. data/scripts/test/render-parity/cut-in-blank-line.json +9 -0
  243. data/scripts/test/render-parity/cut-in-right.json +9 -0
  244. data/scripts/test/render-parity/cut-in.json +8 -0
  245. data/scripts/test/render-parity/figure.json +5 -0
  246. data/scripts/test/render-parity/load-runtime.mjs +337 -0
  247. data/scripts/test/render-parity/ongoing-product.json +5 -0
  248. data/scripts/test/render-parity/plotly.json +5 -0
  249. data/scripts/test/render-parity/poem.json +5 -0
  250. data/scripts/test/render-parity/run-absent-field-checks.mjs +232 -0
  251. data/scripts/test/render-parity/run-block-fixture.mjs +86 -0
  252. data/scripts/test/render-parity/run-detail-parity-checks.mjs +123 -0
  253. data/scripts/test/render-parity/run-field-flow-checks.mjs +227 -0
  254. data/scripts/test/render-parity/run-fixture.mjs +159 -0
  255. data/scripts/test/render-parity/selectors.mjs +43 -0
  256. data/scripts/test/render-parity/video.json +5 -0
  257. data/scripts/test/render-parity/youtube-short.json +10 -0
  258. data/scripts/test/render-parity/youtube.json +8 -0
  259. data/scripts/test/test-absent-field-absent-element.rb +43 -0
  260. data/scripts/test/test-cdn-pins.rb +44 -0
  261. data/scripts/test/test-cloudflare-watch-paths-doc.rb +31 -0
  262. data/scripts/test/test-configuration-doc.rb +36 -0
  263. data/scripts/test/test-content-detail-urls.rb +346 -0
  264. data/scripts/test/test-content-keys.rb +110 -0
  265. data/scripts/test/test-content-license.rb +45 -0
  266. data/scripts/test/test-content-render-parity.rb +38 -0
  267. data/scripts/test/test-content-validators.rb +12 -0
  268. data/scripts/test/test-css-structure.rb +72 -0
  269. data/scripts/test/test-cv-export-contract.rb +158 -0
  270. data/scripts/test/test-detail-render-parity.rb +40 -0
  271. data/scripts/test/test-dev-reexport.rb +122 -0
  272. data/scripts/test/test-doctor.rb +39 -0
  273. data/scripts/test/test-dual-template-instances.rb +87 -0
  274. data/scripts/test/test-dual-template-runtime.rb +167 -0
  275. data/scripts/test/test-examples-build.rb +60 -0
  276. data/scripts/test/test-export-content-json-incremental.rb +138 -0
  277. data/scripts/test/test-export.rb +53 -0
  278. data/scripts/test/test-exported-fields-reach-the-view.rb +60 -0
  279. data/scripts/test/test-form-control-theming.rb +143 -0
  280. data/scripts/test/test-git-chronology.rb +414 -0
  281. data/scripts/test/test-hero-portraits.mjs +97 -0
  282. data/scripts/test/test-hero-portraits.rb +162 -0
  283. data/scripts/test/test-home-band-art.rb +135 -0
  284. data/scripts/test/test-install-functions.rb +39 -0
  285. data/scripts/test/test-language-export.rb +79 -0
  286. data/scripts/test/test-listing-filter-contract.rb +119 -0
  287. data/scripts/test/test-math-row-breaks.mjs +79 -0
  288. data/scripts/test/test-math-row-breaks.rb +18 -0
  289. data/scripts/test/test-new.rb +113 -0
  290. data/scripts/test/test-no-personal-data.rb +85 -0
  291. data/scripts/test/test-public-cv-export.rb +164 -0
  292. data/scripts/test/test-r2-config-consistency.rb +57 -0
  293. data/scripts/test/test-r2-json-sync.rb +193 -0
  294. data/scripts/test/test-registry-home.rb +34 -0
  295. data/scripts/test/test-runtime-js-syntax.rb +64 -0
  296. data/scripts/test/test-slim-writing-index.rb +126 -0
  297. data/scripts/test/test-studio-api-contract.rb +99 -0
  298. data/scripts/test/test-studio-content-files.rb +79 -0
  299. data/scripts/test/test-studio-liquid-roundtrip.mjs +179 -0
  300. data/scripts/test/test-studio-rate-limit.mjs +70 -0
  301. data/scripts/test/test-studio-rewrite-api-contract.rb +59 -0
  302. data/scripts/test/test-studio-rewrite-sanitize.mjs +210 -0
  303. data/scripts/test/test-studio-schema-composition.rb +126 -0
  304. data/scripts/test/test-studio-slug-config.rb +167 -0
  305. data/scripts/test/test-template-packages.rb +51 -0
  306. data/scripts/test/test-text-excerpt.rb +51 -0
  307. data/scripts/test/test-unwrap-media-src.mjs +39 -0
  308. data/scripts/test/test-unwrap-media-src.rb +19 -0
  309. data/scripts/test/test-withdrawn-content-export.rb +69 -0
  310. data/scripts/test/test-writing-index-export-slugs.rb +84 -0
  311. data/scripts/test/test-writing-slug-limits.rb +61 -0
  312. data/scripts/test/test-xcite-chronology.rb +106 -0
  313. data/scripts/validate.sh +74 -0
  314. data/scripts/visual/build-cv-pages-json.js +33 -0
  315. data/scripts/visual/build-site-pages-json.js +94 -0
  316. data/scripts/visual/publish-visual-inspection-to-r2.sh +42 -0
  317. data/scripts/visual/take-screenshots.js +88 -0
  318. data/scripts/visual/visual-inspection-pages.json +113 -0
  319. data/studio/assets/index-B_j0pMD5.css +1 -0
  320. data/studio/assets/index-Ch4YEv9g.js +285 -0
  321. data/studio/index.html +27 -0
  322. data/studio/schema.yml +869 -0
  323. data/studio-app/README.md +27 -0
  324. data/studio-app/index.html +26 -0
  325. data/studio-app/package-lock.json +2499 -0
  326. data/studio-app/package.json +26 -0
  327. data/studio-app/skills-lock.json +47 -0
  328. data/studio-app/src/api/client.js +71 -0
  329. data/studio-app/src/editor/body-editor.js +70 -0
  330. data/studio-app/src/editor/liquid-core.js +382 -0
  331. data/studio-app/src/editor/liquid.js +77 -0
  332. data/studio-app/src/lib/document.js +207 -0
  333. data/studio-app/src/lib/list-controls.js +317 -0
  334. data/studio-app/src/lib/schema.js +66 -0
  335. data/studio-app/src/lib/yaml-doc.js +100 -0
  336. data/studio-app/src/main.js +3693 -0
  337. data/studio-app/src/media/browser.js +578 -0
  338. data/studio-app/src/preview/render.js +430 -0
  339. data/studio-app/src/styles/studio.css +2826 -0
  340. data/studio-app/vite.config.js +25 -0
  341. data/templates/articles/README.md +40 -0
  342. data/templates/articles/fixtures/article.md +9 -0
  343. data/templates/articles/screenshots/README.md +6 -0
  344. data/templates/articles/studio.yml +73 -0
  345. data/templates/articles/template.yml +21 -0
  346. data/templates/bibliography/README.md +41 -0
  347. data/templates/bibliography/fixtures/references.json +9 -0
  348. data/templates/bibliography/screenshots/README.md +6 -0
  349. data/templates/bibliography/studio.yml +66 -0
  350. data/templates/bibliography/template.yml +18 -0
  351. data/templates/blog/README.md +38 -0
  352. data/templates/blog/fixtures/post.md +9 -0
  353. data/templates/blog/screenshots/README.md +6 -0
  354. data/templates/blog/studio.yml +69 -0
  355. data/templates/blog/template.yml +20 -0
  356. data/templates/cv/README.md +34 -0
  357. data/templates/cv/fixtures/job.md +12 -0
  358. data/templates/cv/screenshots/README.md +6 -0
  359. data/templates/cv/studio.yml +200 -0
  360. data/templates/cv/template.yml +25 -0
  361. data/templates/media/README.md +38 -0
  362. data/templates/media/fixtures/resource.md +7 -0
  363. data/templates/media/screenshots/README.md +6 -0
  364. data/templates/media/studio.yml +58 -0
  365. data/templates/media/template.yml +17 -0
  366. data/templates/network/README.md +34 -0
  367. data/templates/network/fixtures/sources.json +3 -0
  368. data/templates/network/screenshots/README.md +6 -0
  369. data/templates/network/studio.yml +28 -0
  370. data/templates/network/template.yml +10 -0
  371. data/templates/portfolio/README.md +39 -0
  372. data/templates/portfolio/fixtures/project.md +10 -0
  373. data/templates/portfolio/screenshots/README.md +6 -0
  374. data/templates/portfolio/studio.yml +89 -0
  375. data/templates/portfolio/template.yml +18 -0
  376. metadata +505 -0
@@ -0,0 +1,285 @@
1
+ var yg=Object.defineProperty;var bg=(t,e,n)=>e in t?yg(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var ce=(t,e,n)=>bg(t,typeof e!="symbol"?e+"":e,n);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(i){if(i.ep)return;i.ep=!0;const s=n(i);fetch(i.href,s)}})();const kg="modulepreload",xg=function(t){return"/studio/"+t},yc={},Sg=function(e,n,r){let i=Promise.resolve();if(n&&n.length>0){let o=function(c){return Promise.all(c.map(u=>Promise.resolve(u).then(d=>({status:"fulfilled",value:d}),d=>({status:"rejected",reason:d}))))};document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),a=(l==null?void 0:l.nonce)||(l==null?void 0:l.getAttribute("nonce"));i=o(n.map(c=>{if(c=xg(c),c in yc)return;yc[c]=!0;const u=c.endsWith(".css"),d=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${d}`))return;const p=document.createElement("link");if(p.rel=u?"stylesheet":kg,u||(p.as="script"),p.crossOrigin="",p.href=c,a&&p.setAttribute("nonce",a),document.head.appendChild(p),u)return new Promise((h,g)=>{p.addEventListener("load",h),p.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${c}`)))})}))}function s(o){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=o,window.dispatchEvent(l),!l.defaultPrevented)throw o}return i.then(o=>{for(const l of o||[])l.status==="rejected"&&s(l.reason);return e().catch(s)})};function wg(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Pe={},Pi={},Wt={},bc;function fi(){if(bc)return Wt;bc=1;function t(o){return typeof o>"u"||o===null}function e(o){return typeof o=="object"&&o!==null}function n(o){return Array.isArray(o)?o:t(o)?[]:[o]}function r(o,l){if(l){const a=Object.keys(l);for(let c=0,u=a.length;c<u;c+=1){const d=a[c];o[d]=l[d]}}return o}function i(o,l){let a="";for(let c=0;c<l;c+=1)a+=o;return a}function s(o){return o===0&&Number.NEGATIVE_INFINITY===1/o}return Wt.isNothing=t,Wt.isObject=e,Wt.toArray=n,Wt.repeat=i,Wt.isNegativeZero=s,Wt.extend=r,Wt}var Ro,kc;function pi(){if(kc)return Ro;kc=1;function t(n,r){let i="";const s=n.reason||"(unknown reason)";return n.mark?(n.mark.name&&(i+='in "'+n.mark.name+'" '),i+="("+(n.mark.line+1)+":"+(n.mark.column+1)+")",!r&&n.mark.snippet&&(i+=`
2
+
3
+ `+n.mark.snippet),s+" "+i):s}function e(n,r){Error.call(this),this.name="YAMLException",this.reason=n,this.mark=r,this.message=t(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e.prototype.toString=function(r){return this.name+": "+t(this,r)},Ro=e,Ro}var Do,xc;function Cg(){if(xc)return Do;xc=1;const t=fi();function e(i,s,o,l,a){let c="",u="";const d=Math.floor(a/2)-1;return l-s>d&&(c=" ... ",s=l-d+c.length),o-l>d&&(u=" ...",o=l+d-u.length),{str:c+i.slice(s,o).replace(/\t/g,"→")+u,pos:l-s+c.length}}function n(i,s){return t.repeat(" ",s-i.length)+i}function r(i,s){if(s=Object.create(s||null),!i.buffer)return null;s.maxLength||(s.maxLength=79),typeof s.indent!="number"&&(s.indent=1),typeof s.linesBefore!="number"&&(s.linesBefore=3),typeof s.linesAfter!="number"&&(s.linesAfter=2);const o=/\r?\n|\r|\0/g,l=[0],a=[];let c,u=-1;for(;c=o.exec(i.buffer);)a.push(c.index),l.push(c.index+c[0].length),i.position<=c.index&&u<0&&(u=l.length-2);u<0&&(u=l.length-1);let d="";const p=Math.min(i.line+s.linesAfter,a.length).toString().length,h=s.maxLength-(s.indent+p+3);for(let b=1;b<=s.linesBefore&&!(u-b<0);b++){const x=e(i.buffer,l[u-b],a[u-b],i.position-(l[u]-l[u-b]),h);d=t.repeat(" ",s.indent)+n((i.line-b+1).toString(),p)+" | "+x.str+`
4
+ `+d}const g=e(i.buffer,l[u],a[u],i.position,h);d+=t.repeat(" ",s.indent)+n((i.line+1).toString(),p)+" | "+g.str+`
5
+ `,d+=t.repeat("-",s.indent+p+3+g.pos)+`^
6
+ `;for(let b=1;b<=s.linesAfter&&!(u+b>=a.length);b++){const x=e(i.buffer,l[u+b],a[u+b],i.position-(l[u]-l[u+b]),h);d+=t.repeat(" ",s.indent)+n((i.line+b+1).toString(),p)+" | "+x.str+`
7
+ `}return d.replace(/\n$/,"")}return Do=r,Do}var Po,Sc;function qe(){if(Sc)return Po;Sc=1;const t=pi(),e=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],n=["scalar","sequence","mapping"];function r(s){const o={};return s!==null&&Object.keys(s).forEach(function(l){s[l].forEach(function(a){o[String(a)]=l})}),o}function i(s,o){if(o=o||{},Object.keys(o).forEach(function(l){if(e.indexOf(l)===-1)throw new t('Unknown option "'+l+'" is met in definition of "'+s+'" YAML type.')}),this.options=o,this.tag=s,this.kind=o.kind||null,this.resolve=o.resolve||function(){return!0},this.construct=o.construct||function(l){return l},this.instanceOf=o.instanceOf||null,this.predicate=o.predicate||null,this.represent=o.represent||null,this.representName=o.representName||null,this.defaultStyle=o.defaultStyle||null,this.multi=o.multi||!1,this.styleAliases=r(o.styleAliases||null),n.indexOf(this.kind)===-1)throw new t('Unknown kind "'+this.kind+'" is specified for "'+s+'" YAML type.')}return Po=i,Po}var $o,wc;function rf(){if(wc)return $o;wc=1;const t=pi(),e=qe();function n(s,o){const l=[];return s[o].forEach(function(a){let c=l.length;l.forEach(function(u,d){u.tag===a.tag&&u.kind===a.kind&&u.multi===a.multi&&(c=d)}),l[c]=a}),l}function r(){const s={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function o(l){l.multi?(s.multi[l.kind].push(l),s.multi.fallback.push(l)):s[l.kind][l.tag]=s.fallback[l.tag]=l}for(let l=0,a=arguments.length;l<a;l+=1)arguments[l].forEach(o);return s}function i(s){return this.extend(s)}return i.prototype.extend=function(o){let l=[],a=[];if(o instanceof e)a.push(o);else if(Array.isArray(o))a=a.concat(o);else if(o&&(Array.isArray(o.implicit)||Array.isArray(o.explicit)))o.implicit&&(l=l.concat(o.implicit)),o.explicit&&(a=a.concat(o.explicit));else throw new t("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");l.forEach(function(u){if(!(u instanceof e))throw new t("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(u.loadKind&&u.loadKind!=="scalar")throw new t("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(u.multi)throw new t("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")}),a.forEach(function(u){if(!(u instanceof e))throw new t("Specified list of YAML types (or a single Type object) contains a non-Type object.")});const c=Object.create(i.prototype);return c.implicit=(this.implicit||[]).concat(l),c.explicit=(this.explicit||[]).concat(a),c.compiledImplicit=n(c,"implicit"),c.compiledExplicit=n(c,"explicit"),c.compiledTypeMap=r(c.compiledImplicit,c.compiledExplicit),c},$o=i,$o}var Bo,Cc;function sf(){if(Cc)return Bo;Cc=1;const t=qe();return Bo=new t("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}}),Bo}var _o,vc;function of(){if(vc)return _o;vc=1;const t=qe();return _o=new t("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}}),_o}var zo,Mc;function lf(){if(Mc)return zo;Mc=1;const t=qe();return zo=new t("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}}),zo}var Fo,Tc;function af(){if(Tc)return Fo;Tc=1;const t=rf();return Fo=new t({explicit:[sf(),of(),lf()]}),Fo}var Ho,Ac;function cf(){if(Ac)return Ho;Ac=1;const t=qe();function e(i){if(i===null)return!0;const s=i.length;return s===1&&i==="~"||s===4&&(i==="null"||i==="Null"||i==="NULL")}function n(){return null}function r(i){return i===null}return Ho=new t("tag:yaml.org,2002:null",{kind:"scalar",resolve:e,construct:n,predicate:r,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"}),Ho}var jo,Ec;function uf(){if(Ec)return jo;Ec=1;const t=qe();function e(i){if(i===null)return!1;const s=i.length;return s===4&&(i==="true"||i==="True"||i==="TRUE")||s===5&&(i==="false"||i==="False"||i==="FALSE")}function n(i){return i==="true"||i==="True"||i==="TRUE"}function r(i){return Object.prototype.toString.call(i)==="[object Boolean]"}return jo=new t("tag:yaml.org,2002:bool",{kind:"scalar",resolve:e,construct:n,predicate:r,represent:{lowercase:function(i){return i?"true":"false"},uppercase:function(i){return i?"TRUE":"FALSE"},camelcase:function(i){return i?"True":"False"}},defaultStyle:"lowercase"}),jo}var Vo,Nc;function df(){if(Nc)return Vo;Nc=1;const t=fi(),e=qe();function n(c){return c>=48&&c<=57||c>=65&&c<=70||c>=97&&c<=102}function r(c){return c>=48&&c<=55}function i(c){return c>=48&&c<=57}function s(c){if(c===null)return!1;const u=c.length;let d=0,p=!1;if(!u)return!1;let h=c[d];if((h==="-"||h==="+")&&(h=c[++d]),h==="0"){if(d+1===u)return!0;if(h=c[++d],h==="b"){for(d++;d<u;d++){if(h=c[d],h!=="0"&&h!=="1")return!1;p=!0}return p&&isFinite(o(c))}if(h==="x"){for(d++;d<u;d++){if(!n(c.charCodeAt(d)))return!1;p=!0}return p&&isFinite(o(c))}if(h==="o"){for(d++;d<u;d++){if(!r(c.charCodeAt(d)))return!1;p=!0}return p&&isFinite(o(c))}}for(;d<u;d++){if(!i(c.charCodeAt(d)))return!1;p=!0}return p?isFinite(o(c)):!1}function o(c){let u=c,d=1,p=u[0];if((p==="-"||p==="+")&&(p==="-"&&(d=-1),u=u.slice(1),p=u[0]),u==="0")return 0;if(p==="0"){if(u[1]==="b")return d*parseInt(u.slice(2),2);if(u[1]==="x")return d*parseInt(u.slice(2),16);if(u[1]==="o")return d*parseInt(u.slice(2),8)}return d*parseInt(u,10)}function l(c){return o(c)}function a(c){return Object.prototype.toString.call(c)==="[object Number]"&&c%1===0&&!t.isNegativeZero(c)}return Vo=new e("tag:yaml.org,2002:int",{kind:"scalar",resolve:s,construct:l,predicate:a,represent:{binary:function(c){return c>=0?"0b"+c.toString(2):"-0b"+c.toString(2).slice(1)},octal:function(c){return c>=0?"0o"+c.toString(8):"-0o"+c.toString(8).slice(1)},decimal:function(c){return c.toString(10)},hexadecimal:function(c){return c>=0?"0x"+c.toString(16).toUpperCase():"-0x"+c.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),Vo}var Uo,Oc;function ff(){if(Oc)return Uo;Oc=1;const t=fi(),e=qe(),n=new RegExp("^(?:[-+]?(?:[0-9]+)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),r=new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function i(c){return c===null||!n.test(c)?!1:isFinite(parseFloat(c,10))?!0:r.test(c)}function s(c){let u=c.toLowerCase();const d=u[0]==="-"?-1:1;return"+-".indexOf(u[0])>=0&&(u=u.slice(1)),u===".inf"?d===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:u===".nan"?NaN:d*parseFloat(u,10)}const o=/^[-+]?[0-9]+e/;function l(c,u){if(isNaN(c))switch(u){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===c)switch(u){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===c)switch(u){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(t.isNegativeZero(c))return"-0.0";const d=c.toString(10);return o.test(d)?d.replace("e",".e"):d}function a(c){return Object.prototype.toString.call(c)==="[object Number]"&&(c%1!==0||t.isNegativeZero(c))}return Uo=new e("tag:yaml.org,2002:float",{kind:"scalar",resolve:i,construct:s,predicate:a,represent:l,defaultStyle:"lowercase"}),Uo}var qo,Lc;function pf(){return Lc||(Lc=1,qo=af().extend({implicit:[cf(),uf(),df(),ff()]})),qo}var Wo,Ic;function hf(){return Ic||(Ic=1,Wo=pf()),Wo}var Ko,Rc;function mf(){if(Rc)return Ko;Rc=1;const t=qe(),e=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),n=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function r(o){return o===null?!1:e.exec(o)!==null||n.exec(o)!==null}function i(o){let l=0,a=null,c=e.exec(o);if(c===null&&(c=n.exec(o)),c===null)throw new Error("Date resolve error");const u=+c[1],d=+c[2]-1,p=+c[3];if(!c[4])return new Date(Date.UTC(u,d,p));const h=+c[4],g=+c[5],b=+c[6];if(c[7]){for(l=c[7].slice(0,3);l.length<3;)l+="0";l=+l}if(c[9]){const w=+c[10],A=+(c[11]||0);a=(w*60+A)*6e4,c[9]==="-"&&(a=-a)}const x=new Date(Date.UTC(u,d,p,h,g,b,l));return a&&x.setTime(x.getTime()-a),x}function s(o){return o.toISOString()}return Ko=new t("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:r,construct:i,instanceOf:Date,represent:s}),Ko}var Yo,Dc;function gf(){if(Dc)return Yo;Dc=1;const t=qe();function e(n){return n==="<<"||n===null}return Yo=new t("tag:yaml.org,2002:merge",{kind:"scalar",resolve:e}),Yo}var Go,Pc;function yf(){if(Pc)return Go;Pc=1;const t=qe(),e=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
8
+ \r`;function n(o){if(o===null)return!1;let l=0;const a=o.length,c=e;for(let u=0;u<a;u++){const d=c.indexOf(o.charAt(u));if(!(d>64)){if(d<0)return!1;l+=6}}return l%8===0}function r(o){const l=o.replace(/[\r\n=]/g,""),a=l.length,c=e;let u=0;const d=[];for(let h=0;h<a;h++)h%4===0&&h&&(d.push(u>>16&255),d.push(u>>8&255),d.push(u&255)),u=u<<6|c.indexOf(l.charAt(h));const p=a%4*6;return p===0?(d.push(u>>16&255),d.push(u>>8&255),d.push(u&255)):p===18?(d.push(u>>10&255),d.push(u>>2&255)):p===12&&d.push(u>>4&255),new Uint8Array(d)}function i(o){let l="",a=0;const c=o.length,u=e;for(let p=0;p<c;p++)p%3===0&&p&&(l+=u[a>>18&63],l+=u[a>>12&63],l+=u[a>>6&63],l+=u[a&63]),a=(a<<8)+o[p];const d=c%3;return d===0?(l+=u[a>>18&63],l+=u[a>>12&63],l+=u[a>>6&63],l+=u[a&63]):d===2?(l+=u[a>>10&63],l+=u[a>>4&63],l+=u[a<<2&63],l+=u[64]):d===1&&(l+=u[a>>2&63],l+=u[a<<4&63],l+=u[64],l+=u[64]),l}function s(o){return Object.prototype.toString.call(o)==="[object Uint8Array]"}return Go=new t("tag:yaml.org,2002:binary",{kind:"scalar",resolve:n,construct:r,predicate:s,represent:i}),Go}var Jo,$c;function bf(){if($c)return Jo;$c=1;const t=qe(),e=Object.prototype.hasOwnProperty,n=Object.prototype.toString;function r(s){if(s===null)return!0;const o={},l=s;for(let a=0,c=l.length;a<c;a+=1){const u=l[a];let d=!1;if(n.call(u)!=="[object Object]")return!1;let p;for(p in u)if(e.call(u,p))if(!d)d=!0;else return!1;if(!d||e.call(o,p))return!1;Object.defineProperty(o,p,{value:!0})}return!0}function i(s){return s!==null?s:[]}return Jo=new t("tag:yaml.org,2002:omap",{kind:"sequence",resolve:r,construct:i}),Jo}var Xo,Bc;function kf(){if(Bc)return Xo;Bc=1;const t=qe(),e=Object.prototype.toString;function n(i){if(i===null)return!0;const s=i,o=new Array(s.length);for(let l=0,a=s.length;l<a;l+=1){const c=s[l];if(e.call(c)!=="[object Object]")return!1;const u=Object.keys(c);if(u.length!==1)return!1;o[l]=[u[0],c[u[0]]]}return!0}function r(i){if(i===null)return[];const s=i,o=new Array(s.length);for(let l=0,a=s.length;l<a;l+=1){const c=s[l],u=Object.keys(c);o[l]=[u[0],c[u[0]]]}return o}return Xo=new t("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:n,construct:r}),Xo}var Zo,_c;function xf(){if(_c)return Zo;_c=1;const t=qe(),e=Object.prototype.hasOwnProperty;function n(i){if(i===null)return!0;const s=i;for(const o in s)if(e.call(s,o)&&s[o]!==null)return!1;return!0}function r(i){return i!==null?i:{}}return Zo=new t("tag:yaml.org,2002:set",{kind:"mapping",resolve:n,construct:r}),Zo}var Qo,zc;function Sa(){return zc||(zc=1,Qo=hf().extend({implicit:[mf(),gf()],explicit:[yf(),bf(),kf(),xf()]})),Qo}var Fc;function vg(){if(Fc)return Pi;Fc=1;const t=fi(),e=pi(),n=Cg(),r=Sa(),i=Object.prototype.hasOwnProperty,s=1,o=2,l=3,a=4,c=1,u=2,d=3,p=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,h=/[\x85\u2028\u2029]/,g=/[,\[\]{}]/,b=/^(?:!|!!|![0-9A-Za-z-]+!)$/,x=/^(?:!|[^,\[\]{}])(?:%[0-9a-f]{2}|[0-9a-z\-#;/?:@&=+$,_.!~*'()\[\]])*$/i;function w(f){return Object.prototype.toString.call(f)}function A(f){return f===10||f===13}function R(f){return f===9||f===32}function O(f){return f===9||f===32||f===10||f===13}function Y(f){return f===44||f===91||f===93||f===123||f===125}function ee(f){if(f>=48&&f<=57)return f-48;const S=f|32;return S>=97&&S<=102?S-97+10:-1}function H(f){return f===120?2:f===117?4:f===85?8:0}function Q(f){return f>=48&&f<=57?f-48:-1}function te(f){switch(f){case 48:return"\0";case 97:return"\x07";case 98:return"\b";case 116:return" ";case 9:return" ";case 110:return`
9
+ `;case 118:return"\v";case 102:return"\f";case 114:return"\r";case 101:return"\x1B";case 32:return" ";case 34:return'"';case 47:return"/";case 92:return"\\";case 78:return"…";case 95:return" ";case 76:return"\u2028";case 80:return"\u2029";default:return""}}function ye(f){return f<=65535?String.fromCharCode(f):String.fromCharCode((f-65536>>10)+55296,(f-65536&1023)+56320)}function Me(f,S,E){S==="__proto__"?Object.defineProperty(f,S,{configurable:!0,enumerable:!0,writable:!0,value:E}):f[S]=E}const et=new Array(256),Ee=new Array(256);for(let f=0;f<256;f++)et[f]=te(f)?1:0,Ee[f]=te(f);function le(f,S){this.input=f,this.filename=S.filename||null,this.schema=S.schema||r,this.onWarning=S.onWarning||null,this.legacy=S.legacy||!1,this.json=S.json||!1,this.listener=S.listener||null,this.maxDepth=typeof S.maxDepth=="number"?S.maxDepth:100,this.maxTotalMergeKeys=typeof S.maxTotalMergeKeys=="number"?S.maxTotalMergeKeys:1e4,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=f.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.depth=0,this.totalMergeKeys=0,this.firstTabInLine=-1,this.documents=[],this.anchorMapTransactions=[]}function De(f,S){const E={name:f.filename,buffer:f.input.slice(0,-1),position:f.position,line:f.line,column:f.position-f.lineStart};return E.snippet=n(E),new e(S,E)}function z(f,S){throw De(f,S)}function Fn(f,S){f.onWarning&&f.onWarning.call(null,De(f,S))}function St(f,S,E){const N=f.anchorMapTransactions;if(N.length!==0){const M=N[N.length-1];i.call(M,S)||(M[S]={existed:i.call(f.anchorMap,S),value:f.anchorMap[S]})}f.anchorMap[S]=E}function Ao(f){f.anchorMapTransactions.push(Object.create(null))}function yn(f){const S=f.anchorMapTransactions.pop(),E=f.anchorMapTransactions;if(E.length===0)return;const N=E[E.length-1],M=Object.keys(S);for(let y=0,C=M.length;y<C;y+=1){const v=M[y];i.call(N,v)||(N[v]=S[v])}}function Eo(f){const S=f.anchorMapTransactions.pop(),E=Object.keys(S);for(let N=E.length-1;N>=0;N-=1){const M=S[E[N]];M.existed?f.anchorMap[E[N]]=M.value:delete f.anchorMap[E[N]]}}function gr(f){return{position:f.position,line:f.line,lineStart:f.lineStart,lineIndent:f.lineIndent,firstTabInLine:f.firstTabInLine,tag:f.tag,anchor:f.anchor,kind:f.kind,result:f.result}}function Hn(f,S){f.position=S.position,f.line=S.line,f.lineStart=S.lineStart,f.lineIndent=S.lineIndent,f.firstTabInLine=S.firstTabInLine,f.tag=S.tag,f.anchor=S.anchor,f.kind=S.kind,f.result=S.result}const Ti={YAML:function(S,E,N){S.version!==null&&z(S,"duplication of %YAML directive"),N.length!==1&&z(S,"YAML directive accepts exactly one argument");const M=/^([0-9]+)\.([0-9]+)$/.exec(N[0]);M===null&&z(S,"ill-formed argument of the YAML directive");const y=parseInt(M[1],10),C=parseInt(M[2],10);y!==1&&z(S,"unacceptable YAML version of the document"),S.version=N[0],S.checkLineBreaks=C<2,C!==1&&C!==2&&Fn(S,"unsupported YAML version of the document")},TAG:function(S,E,N){let M;N.length!==2&&z(S,"TAG directive accepts exactly two arguments");const y=N[0];M=N[1],b.test(y)||z(S,"ill-formed tag handle (first argument) of the TAG directive"),i.call(S.tagMap,y)&&z(S,'there is a previously declared suffix for "'+y+'" tag handle'),x.test(M)||z(S,"ill-formed tag prefix (second argument) of the TAG directive");try{M=decodeURIComponent(M)}catch{z(S,"tag prefix is malformed: "+M)}S.tagMap[y]=M}};function Ge(f,S,E,N){if(S<E){const M=f.input.slice(S,E);if(N)for(let y=0,C=M.length;y<C;y+=1){const v=M.charCodeAt(y);v===9||v>=32&&v<=1114111||z(f,"expected valid JSON character")}else p.test(M)&&z(f,"the stream contains non-printable characters");f.result+=M}}function jt(f){f.totalMergeKeys++,f.maxTotalMergeKeys!==-1&&f.totalMergeKeys>f.maxTotalMergeKeys&&z(f,"merge keys exceeded maxTotalMergeKeys ("+f.maxTotalMergeKeys+")")}function yr(f,S,E,N){t.isObject(E)||z(f,"cannot merge mappings; the provided source object is unacceptable"),jt(f);const M=Object.keys(E);for(let y=0,C=M.length;y<C;y+=1){const v=M[y];jt(f),i.call(S,v)||(Me(S,v,E[v]),N[v]=!0)}}function wt(f,S,E,N,M,y,C,v,L){if(Array.isArray(M)){M=Array.prototype.slice.call(M);for(let D=0,P=M.length;D<P;D+=1)Array.isArray(M[D])&&z(f,"nested arrays are not supported inside keys"),typeof M=="object"&&w(M[D])==="[object Object]"&&(M[D]="[object Object]")}if(typeof M=="object"&&w(M)==="[object Object]"&&(M="[object Object]"),M=String(M),S===null&&(S={}),N==="tag:yaml.org,2002:merge")if(Array.isArray(y)){y.length>100&&z(f,"abnormal merge sequence size");for(let D=0,P=y.length;D<P;D+=1)yr(f,S,y[D],E)}else yr(f,S,y,E);else!f.json&&!i.call(E,M)&&i.call(S,M)&&(f.line=C||f.line,f.lineStart=v||f.lineStart,f.position=L||f.position,z(f,"duplicated mapping key")),Me(S,M,y),delete E[M];return S}function br(f){const S=f.input.charCodeAt(f.position);S===10?f.position++:S===13?(f.position++,f.input.charCodeAt(f.position)===10&&f.position++):z(f,"a line break is expected"),f.line+=1,f.lineStart=f.position,f.firstTabInLine=-1}function pe(f,S,E){let N=0,M=f.input.charCodeAt(f.position);for(;M!==0;){for(;R(M);)M===9&&f.firstTabInLine===-1&&(f.firstTabInLine=f.position),M=f.input.charCodeAt(++f.position);if(S&&M===35)do M=f.input.charCodeAt(++f.position);while(M!==10&&M!==13&&M!==0);if(A(M))for(br(f),M=f.input.charCodeAt(f.position),N++,f.lineIndent=0;M===32;)f.lineIndent++,M=f.input.charCodeAt(++f.position);else break}return E!==-1&&N!==0&&f.lineIndent<E&&Fn(f,"deficient indentation"),N}function ut(f){let S=f.position,E=f.input.charCodeAt(S);return!!((E===45||E===46)&&E===f.input.charCodeAt(S+1)&&E===f.input.charCodeAt(S+2)&&(S+=3,E=f.input.charCodeAt(S),E===0||O(E)))}function jn(f,S){S===1?f.result+=" ":S>1&&(f.result+=t.repeat(`
10
+ `,S-1))}function Ai(f,S,E){let N,M,y,C,v,L;const D=f.kind,P=f.result;let T=f.input.charCodeAt(f.position);if(O(T)||Y(T)||T===35||T===38||T===42||T===33||T===124||T===62||T===39||T===34||T===37||T===64||T===96)return!1;if(T===63||T===45){const B=f.input.charCodeAt(f.position+1);if(O(B)||E&&Y(B))return!1}for(f.kind="scalar",f.result="",N=M=f.position,y=!1;T!==0;){if(T===58){const B=f.input.charCodeAt(f.position+1);if(O(B)||E&&Y(B))break}else if(T===35){const B=f.input.charCodeAt(f.position-1);if(O(B))break}else{if(f.position===f.lineStart&&ut(f)||E&&Y(T))break;if(A(T))if(C=f.line,v=f.lineStart,L=f.lineIndent,pe(f,!1,-1),f.lineIndent>=S){y=!0,T=f.input.charCodeAt(f.position);continue}else{f.position=M,f.line=C,f.lineStart=v,f.lineIndent=L;break}}y&&(Ge(f,N,M,!1),jn(f,f.line-C),N=M=f.position,y=!1),R(T)||(M=f.position+1),T=f.input.charCodeAt(++f.position)}return Ge(f,N,M,!1),f.result?!0:(f.kind=D,f.result=P,!1)}function kr(f,S){let E,N,M=f.input.charCodeAt(f.position);if(M!==39)return!1;for(f.kind="scalar",f.result="",f.position++,E=N=f.position;(M=f.input.charCodeAt(f.position))!==0;)if(M===39)if(Ge(f,E,f.position,!0),M=f.input.charCodeAt(++f.position),M===39)E=f.position,f.position++,N=f.position;else return!0;else A(M)?(Ge(f,E,N,!0),jn(f,pe(f,!1,S)),E=N=f.position):f.position===f.lineStart&&ut(f)?z(f,"unexpected end of the document within a single quoted scalar"):(f.position++,R(M)||(N=f.position));z(f,"unexpected end of the stream within a single quoted scalar")}function Ei(f,S){let E,N,M,y=f.input.charCodeAt(f.position);if(y!==34)return!1;for(f.kind="scalar",f.result="",f.position++,E=N=f.position;(y=f.input.charCodeAt(f.position))!==0;){if(y===34)return Ge(f,E,f.position,!0),f.position++,!0;if(y===92){if(Ge(f,E,f.position,!0),y=f.input.charCodeAt(++f.position),A(y))pe(f,!1,S);else if(y<256&&et[y])f.result+=Ee[y],f.position++;else if((M=H(y))>0){let C=M,v=0;for(;C>0;C--)y=f.input.charCodeAt(++f.position),(M=ee(y))>=0?v=(v<<4)+M:z(f,"expected hexadecimal character");f.result+=ye(v),f.position++}else z(f,"unknown escape sequence");E=N=f.position}else A(y)?(Ge(f,E,N,!0),jn(f,pe(f,!1,S)),E=N=f.position):f.position===f.lineStart&&ut(f)?z(f,"unexpected end of the document within a double quoted scalar"):(f.position++,R(y)||(N=f.position))}z(f,"unexpected end of the stream within a double quoted scalar")}function Ni(f,S){let E=!0,N,M,y;const C=f.tag;let v;const L=f.anchor;let D,P,T,B;const F=Object.create(null);let W,K,G,X=f.input.charCodeAt(f.position);if(X===91)D=93,B=!1,v=[];else if(X===123)D=125,B=!0,v={};else return!1;for(f.anchor!==null&&St(f,f.anchor,v),X=f.input.charCodeAt(++f.position);X!==0;){if(pe(f,!0,S),X=f.input.charCodeAt(f.position),X===D)return f.position++,f.tag=C,f.anchor=L,f.kind=B?"mapping":"sequence",f.result=v,!0;if(E?X===44&&z(f,"expected the node content, but found ','"):z(f,"missed comma between flow collection entries"),K=W=G=null,P=T=!1,X===63){const qt=f.input.charCodeAt(f.position+1);O(qt)&&(P=T=!0,f.position++,pe(f,!0,S))}N=f.line,M=f.lineStart,y=f.position,Ut(f,S,s,!1,!0),K=f.tag,W=f.result,pe(f,!0,S),X=f.input.charCodeAt(f.position),(T||f.line===N)&&X===58&&(P=!0,X=f.input.charCodeAt(++f.position),pe(f,!0,S),Ut(f,S,s,!1,!0),G=f.result),B?wt(f,v,F,K,W,G,N,M,y):P?v.push(wt(f,null,F,K,W,G,N,M,y)):v.push(W),pe(f,!0,S),X=f.input.charCodeAt(f.position),X===44?(E=!0,X=f.input.charCodeAt(++f.position)):E=!1}z(f,"unexpected end of the stream within a flow collection")}function Vt(f,S){let E,N=c,M=!1,y=!1,C=S,v=0,L=!1,D,P=f.input.charCodeAt(f.position);if(P===124)E=!1;else if(P===62)E=!0;else return!1;for(f.kind="scalar",f.result="";P!==0;)if(P=f.input.charCodeAt(++f.position),P===43||P===45)c===N?N=P===43?d:u:z(f,"repeat of a chomping mode identifier");else if((D=Q(P))>=0)D===0?z(f,"bad explicit indentation width of a block scalar; it cannot be less than one"):y?z(f,"repeat of an indentation width identifier"):(C=S+D-1,y=!0);else break;if(R(P)){do P=f.input.charCodeAt(++f.position);while(R(P));if(P===35)do P=f.input.charCodeAt(++f.position);while(!A(P)&&P!==0)}for(;P!==0;){for(br(f),f.lineIndent=0,P=f.input.charCodeAt(f.position);(!y||f.lineIndent<C)&&P===32;)f.lineIndent++,P=f.input.charCodeAt(++f.position);if(!y&&f.lineIndent>C&&(C=f.lineIndent),A(P)){v++;continue}if(!y&&C===0&&z(f,"missing indentation for block scalar"),f.lineIndent<C){N===d?f.result+=t.repeat(`
11
+ `,M?1+v:v):N===c&&M&&(f.result+=`
12
+ `);break}E?R(P)?(L=!0,f.result+=t.repeat(`
13
+ `,M?1+v:v)):L?(L=!1,f.result+=t.repeat(`
14
+ `,v+1)):v===0?M&&(f.result+=" "):f.result+=t.repeat(`
15
+ `,v):f.result+=t.repeat(`
16
+ `,M?1+v:v),M=!0,y=!0,v=0;const T=f.position;for(;!A(P)&&P!==0;)P=f.input.charCodeAt(++f.position);Ge(f,T,f.position,!1)}return!0}function Oi(f,S){const E=f.tag,N=f.anchor,M=[];let y=!1;if(f.firstTabInLine!==-1)return!1;f.anchor!==null&&St(f,f.anchor,M);let C=f.input.charCodeAt(f.position);for(;C!==0&&(f.firstTabInLine!==-1&&(f.position=f.firstTabInLine,z(f,"tab characters must not be used in indentation")),C===45);){const v=f.input.charCodeAt(f.position+1);if(!O(v))break;if(y=!0,f.position++,pe(f,!0,-1)&&f.lineIndent<=S){M.push(null),C=f.input.charCodeAt(f.position);continue}const L=f.line;if(Ut(f,S,l,!1,!0),M.push(f.result),pe(f,!0,-1),C=f.input.charCodeAt(f.position),(f.line===L||f.lineIndent>S)&&C!==0)z(f,"bad indentation of a sequence entry");else if(f.lineIndent<S)break}return y?(f.tag=E,f.anchor=N,f.kind="sequence",f.result=M,!0):!1}function Li(f,S,E){let N,M,y,C;const v=f.tag,L=f.anchor,D={},P=Object.create(null);let T=null,B=null,F=null,W=!1,K=!1;if(f.firstTabInLine!==-1)return!1;f.anchor!==null&&St(f,f.anchor,D);let G=f.input.charCodeAt(f.position);for(;G!==0;){!W&&f.firstTabInLine!==-1&&(f.position=f.firstTabInLine,z(f,"tab characters must not be used in indentation"));const X=f.input.charCodeAt(f.position+1),qt=f.line;if((G===63||G===58)&&O(X))G===63?(W&&(wt(f,D,P,T,B,null,M,y,C),T=B=F=null),K=!0,W=!0,N=!0):W?(W=!1,N=!0):z(f,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"),f.position+=1,G=X;else{if(M=f.line,y=f.lineStart,C=f.position,!Ut(f,E,o,!1,!0))break;if(f.line===qt){for(G=f.input.charCodeAt(f.position);R(G);)G=f.input.charCodeAt(++f.position);if(G===58)G=f.input.charCodeAt(++f.position),O(G)||z(f,"a whitespace character is expected after the key-value separator within a block mapping"),W&&(wt(f,D,P,T,B,null,M,y,C),T=B=F=null),K=!0,W=!1,N=!1,T=f.tag,B=f.result;else if(K)z(f,"can not read an implicit mapping pair; a colon is missed");else return f.tag=v,f.anchor=L,!0}else if(K)z(f,"can not read a block mapping entry; a multiline key may not be an implicit key");else return f.tag=v,f.anchor=L,!0}if((f.line===qt||f.lineIndent>S)&&(W&&(M=f.line,y=f.lineStart,C=f.position),Ut(f,S,a,!0,N)&&(W?B=f.result:F=f.result),W||(wt(f,D,P,T,B,F,M,y,C),T=B=F=null),pe(f,!0,-1),G=f.input.charCodeAt(f.position)),(f.line===qt||f.lineIndent>S)&&G!==0)z(f,"bad indentation of a mapping entry");else if(f.lineIndent<S)break}return W&&wt(f,D,P,T,B,null,M,y,C),K&&(f.tag=v,f.anchor=L,f.kind="mapping",f.result=D),K}function Ii(f){let S=!1,E=!1,N,M,y=f.input.charCodeAt(f.position);if(y!==33)return!1;f.tag!==null&&z(f,"duplication of a tag property"),y=f.input.charCodeAt(++f.position),y===60?(S=!0,y=f.input.charCodeAt(++f.position)):y===33?(E=!0,N="!!",y=f.input.charCodeAt(++f.position)):N="!";let C=f.position;if(S){do y=f.input.charCodeAt(++f.position);while(y!==0&&y!==62);f.position<f.length?(M=f.input.slice(C,f.position),y=f.input.charCodeAt(++f.position)):z(f,"unexpected end of the stream within a verbatim tag")}else{for(;y!==0&&!O(y);)y===33&&(E?z(f,"tag suffix cannot contain exclamation marks"):(N=f.input.slice(C-1,f.position+1),b.test(N)||z(f,"named tag handle cannot contain such characters"),E=!0,C=f.position+1)),y=f.input.charCodeAt(++f.position);M=f.input.slice(C,f.position),g.test(M)&&z(f,"tag suffix cannot contain flow indicator characters")}M&&!x.test(M)&&z(f,"tag name cannot contain such characters: "+M);try{M=decodeURIComponent(M)}catch{z(f,"tag name is malformed: "+M)}return S?f.tag=M:i.call(f.tagMap,N)?f.tag=f.tagMap[N]+M:N==="!"?f.tag="!"+M:N==="!!"?f.tag="tag:yaml.org,2002:"+M:z(f,'undeclared tag handle "'+N+'"'),!0}function Ri(f){let S=f.input.charCodeAt(f.position);if(S!==38)return!1;f.anchor!==null&&z(f,"duplication of an anchor property"),S=f.input.charCodeAt(++f.position);const E=f.position;for(;S!==0&&!O(S)&&!Y(S);)S=f.input.charCodeAt(++f.position);return f.position===E&&z(f,"name of an anchor node must contain at least one character"),f.anchor=f.input.slice(E,f.position),!0}function No(f){let S=f.input.charCodeAt(f.position);if(S!==42)return!1;S=f.input.charCodeAt(++f.position);const E=f.position;for(;S!==0&&!O(S)&&!Y(S);)S=f.input.charCodeAt(++f.position);f.position===E&&z(f,"name of an alias node must contain at least one character");const N=f.input.slice(E,f.position);return i.call(f.anchorMap,N)||z(f,'unidentified alias "'+N+'"'),f.result=f.anchorMap[N],pe(f,!0,-1),!0}function Di(f,S,E,N){const M=gr(f);return Ao(f),Hn(f,S),f.tag=null,f.anchor=null,f.kind=null,f.result=null,Li(f,E,N)&&f.kind==="mapping"?(yn(f),!0):(Eo(f),Hn(f,M),!1)}function Ut(f,S,E,N,M){let y,C,v=1,L=!1,D=!1,P=null,T,B,F;f.depth>=f.maxDepth&&z(f,"nesting exceeded maxDepth ("+f.maxDepth+")"),f.depth+=1,f.listener!==null&&f.listener("open",f),f.tag=null,f.anchor=null,f.kind=null,f.result=null;const W=y=C=a===E||l===E;if(N&&pe(f,!0,-1)&&(L=!0,f.lineIndent>S?v=1:f.lineIndent===S?v=0:f.lineIndent<S&&(v=-1)),v===1)for(;;){const K=f.input.charCodeAt(f.position),G=gr(f);if(L&&(K===33&&f.tag!==null||K===38&&f.anchor!==null)||!Ii(f)&&!Ri(f))break;P===null&&(P=G),pe(f,!0,-1)?(L=!0,C=W,f.lineIndent>S?v=1:f.lineIndent===S?v=0:f.lineIndent<S&&(v=-1)):C=!1}if(C&&(C=L||M),v===1||a===E)if(s===E||o===E?B=S:B=S+1,F=f.position-f.lineStart,v===1)if(C&&(Oi(f,F)||Li(f,F,B))||Ni(f,B))D=!0;else{const K=f.input.charCodeAt(f.position);P!==null&&W&&!C&&K!==124&&K!==62&&Di(f,P,P.position-P.lineStart,B)||y&&Vt(f,B)||kr(f,B)||Ei(f,B)?D=!0:No(f)?(D=!0,(f.tag!==null||f.anchor!==null)&&z(f,"alias node should not have any properties")):Ai(f,B,s===E)&&(D=!0,f.tag===null&&(f.tag="?")),f.anchor!==null&&St(f,f.anchor,f.result)}else v===0&&(D=C&&Oi(f,F));if(f.tag===null)f.anchor!==null&&St(f,f.anchor,f.result);else if(f.tag==="?"){f.result!==null&&f.kind!=="scalar"&&z(f,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+f.kind+'"');for(let K=0,G=f.implicitTypes.length;K<G;K+=1)if(T=f.implicitTypes[K],T.resolve(f.result)){f.result=T.construct(f.result),f.tag=T.tag,f.anchor!==null&&St(f,f.anchor,f.result);break}}else if(f.tag!=="!"){if(i.call(f.typeMap[f.kind||"fallback"],f.tag))T=f.typeMap[f.kind||"fallback"][f.tag];else{T=null;const K=f.typeMap.multi[f.kind||"fallback"];for(let G=0,X=K.length;G<X;G+=1)if(f.tag.slice(0,K[G].tag.length)===K[G].tag){T=K[G];break}}T||z(f,"unknown tag !<"+f.tag+">"),f.result!==null&&T.kind!==f.kind&&z(f,"unacceptable node kind for !<"+f.tag+'> tag; it should be "'+T.kind+'", not "'+f.kind+'"'),T.resolve(f.result,f.tag)?(f.result=T.construct(f.result,f.tag),f.anchor!==null&&St(f,f.anchor,f.result)):z(f,"cannot resolve a node with !<"+f.tag+"> explicit tag")}return f.listener!==null&&f.listener("close",f),f.depth-=1,f.tag!==null||f.anchor!==null||D}function Oo(f){const S=f.position;let E=!1,N;for(f.version=null,f.checkLineBreaks=f.legacy,f.tagMap=Object.create(null),f.anchorMap=Object.create(null);(N=f.input.charCodeAt(f.position))!==0&&(pe(f,!0,-1),N=f.input.charCodeAt(f.position),!(f.lineIndent>0||N!==37));){E=!0,N=f.input.charCodeAt(++f.position);let M=f.position;for(;N!==0&&!O(N);)N=f.input.charCodeAt(++f.position);const y=f.input.slice(M,f.position),C=[];for(y.length<1&&z(f,"directive name must not be less than one character in length");N!==0;){for(;R(N);)N=f.input.charCodeAt(++f.position);if(N===35){do N=f.input.charCodeAt(++f.position);while(N!==0&&!A(N));break}if(A(N))break;for(M=f.position;N!==0&&!O(N);)N=f.input.charCodeAt(++f.position);C.push(f.input.slice(M,f.position))}N!==0&&br(f),i.call(Ti,y)?Ti[y](f,y,C):Fn(f,'unknown document directive "'+y+'"')}if(pe(f,!0,-1),f.lineIndent===0&&f.input.charCodeAt(f.position)===45&&f.input.charCodeAt(f.position+1)===45&&f.input.charCodeAt(f.position+2)===45?(f.position+=3,pe(f,!0,-1)):E&&z(f,"directives end mark is expected"),Ut(f,f.lineIndent-1,a,!1,!0),pe(f,!0,-1),f.checkLineBreaks&&h.test(f.input.slice(S,f.position))&&Fn(f,"non-ASCII line breaks are interpreted as content"),f.documents.push(f.result),f.position===f.lineStart&&ut(f)){f.input.charCodeAt(f.position)===46&&(f.position+=3,pe(f,!0,-1));return}f.position<f.length-1&&z(f,"end of the stream or a document separator is expected")}function xr(f,S){f=String(f),S=S||{},f.length!==0&&(f.charCodeAt(f.length-1)!==10&&f.charCodeAt(f.length-1)!==13&&(f+=`
17
+ `),f.charCodeAt(0)===65279&&(f=f.slice(1)));const E=new le(f,S),N=f.indexOf("\0");for(N!==-1&&(E.position=N,z(E,"null byte is not allowed in input")),E.input+="\0";E.input.charCodeAt(E.position)===32;)E.lineIndent+=1,E.position+=1;for(;E.position<E.length-1;)Oo(E);return E.documents}function Lo(f,S,E){S!==null&&typeof S=="object"&&typeof E>"u"&&(E=S,S=null);const N=xr(f,E);if(typeof S!="function")return N;for(let M=0,y=N.length;M<y;M+=1)S(N[M])}function Io(f,S){const E=xr(f,S);if(E.length!==0){if(E.length===1)return E[0];throw new e("expected a single document in the stream, but found more")}}return Pi.loadAll=Lo,Pi.load=Io,Pi}var el={},Hc;function Mg(){if(Hc)return el;Hc=1;const t=fi(),e=pi(),n=Sa(),r=Object.prototype.toString,i=Object.prototype.hasOwnProperty,s=65279,o=9,l=10,a=13,c=32,u=33,d=34,p=35,h=37,g=38,b=39,x=42,w=44,A=45,R=58,O=61,Y=62,ee=63,H=64,Q=91,te=93,ye=96,Me=123,et=124,Ee=125,le={};le[0]="\\0",le[7]="\\a",le[8]="\\b",le[9]="\\t",le[10]="\\n",le[11]="\\v",le[12]="\\f",le[13]="\\r",le[27]="\\e",le[34]='\\"',le[92]="\\\\",le[133]="\\N",le[160]="\\_",le[8232]="\\L",le[8233]="\\P";const De=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],z=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function Fn(y,C){if(C===null)return{};const v={},L=Object.keys(C);for(let D=0,P=L.length;D<P;D+=1){let T=L[D],B=String(C[T]);T.slice(0,2)==="!!"&&(T="tag:yaml.org,2002:"+T.slice(2));const F=y.compiledTypeMap.fallback[T];F&&i.call(F.styleAliases,B)&&(B=F.styleAliases[B]),v[T]=B}return v}function St(y){let C,v;const L=y.toString(16).toUpperCase();if(y<=255)C="x",v=2;else if(y<=65535)C="u",v=4;else if(y<=4294967295)C="U",v=8;else throw new e("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+C+t.repeat("0",v-L.length)+L}const Ao=1,yn=2;function Eo(y){this.schema=y.schema||n,this.indent=Math.max(1,y.indent||2),this.noArrayIndent=y.noArrayIndent||!1,this.skipInvalid=y.skipInvalid||!1,this.flowLevel=t.isNothing(y.flowLevel)?-1:y.flowLevel,this.styleMap=Fn(this.schema,y.styles||null),this.sortKeys=y.sortKeys||!1,this.lineWidth=y.lineWidth||80,this.noRefs=y.noRefs||!1,this.noCompatMode=y.noCompatMode||!1,this.condenseFlow=y.condenseFlow||!1,this.quotingType=y.quotingType==='"'?yn:Ao,this.forceQuotes=y.forceQuotes||!1,this.replacer=typeof y.replacer=="function"?y.replacer:null,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result="",this.duplicates=[],this.usedDuplicates=null}function gr(y,C){const v=t.repeat(" ",C);let L=0,D="";const P=y.length;for(;L<P;){let T;const B=y.indexOf(`
18
+ `,L);B===-1?(T=y.slice(L),L=P):(T=y.slice(L,B+1),L=B+1),T.length&&T!==`
19
+ `&&(D+=v),D+=T}return D}function Hn(y,C){return`
20
+ `+t.repeat(" ",y.indent*C)}function Ti(y,C){for(let v=0,L=y.implicitTypes.length;v<L;v+=1)if(y.implicitTypes[v].resolve(C))return!0;return!1}function Ge(y){return y===c||y===o}function jt(y){return y>=32&&y<=126||y>=161&&y<=55295&&y!==8232&&y!==8233||y>=57344&&y<=65533&&y!==s||y>=65536&&y<=1114111}function yr(y){return jt(y)&&y!==s&&y!==a&&y!==l}function wt(y,C,v){const L=yr(y),D=L&&!Ge(y);return(v?L:L&&y!==w&&y!==Q&&y!==te&&y!==Me&&y!==Ee)&&y!==p&&!(C===R&&!D)||yr(C)&&!Ge(C)&&y===p||C===R&&D}function br(y){return jt(y)&&y!==s&&!Ge(y)&&y!==A&&y!==ee&&y!==R&&y!==w&&y!==Q&&y!==te&&y!==Me&&y!==Ee&&y!==p&&y!==g&&y!==x&&y!==u&&y!==et&&y!==O&&y!==Y&&y!==b&&y!==d&&y!==h&&y!==H&&y!==ye}function pe(y){return!Ge(y)&&y!==R}function ut(y,C){const v=y.charCodeAt(C);let L;return v>=55296&&v<=56319&&C+1<y.length&&(L=y.charCodeAt(C+1),L>=56320&&L<=57343)?(v-55296)*1024+L-56320+65536:v}function jn(y){return/^\n* /.test(y)}const Ai=1,kr=2,Ei=3,Ni=4,Vt=5;function Oi(y,C,v,L,D,P,T,B){let F,W=0,K=null,G=!1,X=!1;const qt=L!==-1;let Sr=-1,wr=br(ut(y,0))&&pe(ut(y,y.length-1));if(C||T)for(F=0;F<y.length;W>=65536?F+=2:F++){if(W=ut(y,F),!jt(W))return Vt;wr=wr&&wt(W,K,B),K=W}else{for(F=0;F<y.length;W>=65536?F+=2:F++){if(W=ut(y,F),W===l)G=!0,qt&&(X=X||F-Sr-1>L&&y[Sr+1]!==" ",Sr=F);else if(!jt(W))return Vt;wr=wr&&wt(W,K,B),K=W}X=X||qt&&F-Sr-1>L&&y[Sr+1]!==" "}return!G&&!X?wr&&!T&&!D(y)?Ai:P===yn?Vt:kr:v>9&&jn(y)?Vt:T?P===yn?Vt:kr:X?Ni:Ei}function Li(y,C,v,L,D){y.dump=(function(){if(C.length===0)return y.quotingType===yn?'""':"''";if(!y.noCompatMode&&(De.indexOf(C)!==-1||z.test(C)))return y.quotingType===yn?'"'+C+'"':"'"+C+"'";const P=y.indent*Math.max(1,v),T=y.lineWidth===-1?-1:Math.max(Math.min(y.lineWidth,40),y.lineWidth-P),B=L||y.flowLevel>-1&&v>=y.flowLevel;function F(W){return Ti(y,W)}switch(Oi(C,B,y.indent,T,F,y.quotingType,y.forceQuotes&&!L,D)){case Ai:return C;case kr:return"'"+C.replace(/'/g,"''")+"'";case Ei:return"|"+Ii(C,y.indent)+Ri(gr(C,P));case Ni:return">"+Ii(C,y.indent)+Ri(gr(No(C,T),P));case Vt:return'"'+Ut(C)+'"';default:throw new e("impossible error: invalid scalar style")}})()}function Ii(y,C){const v=jn(y)?String(C):"",L=y[y.length-1]===`
21
+ `,P=L&&(y[y.length-2]===`
22
+ `||y===`
23
+ `)?"+":L?"":"-";return v+P+`
24
+ `}function Ri(y){return y[y.length-1]===`
25
+ `?y.slice(0,-1):y}function No(y,C){const v=/(\n+)([^\n]*)/g;let L=(function(){let B=y.indexOf(`
26
+ `);return B=B!==-1?B:y.length,v.lastIndex=B,Di(y.slice(0,B),C)})(),D=y[0]===`
27
+ `||y[0]===" ",P,T;for(;T=v.exec(y);){const B=T[1],F=T[2];P=F[0]===" ",L+=B+(!D&&!P&&F!==""?`
28
+ `:"")+Di(F,C),D=P}return L}function Di(y,C){if(y===""||y[0]===" ")return y;const v=/ [^ ]/g;let L,D=0,P,T=0,B=0,F="";for(;L=v.exec(y);)B=L.index,B-D>C&&(P=T>D?T:B,F+=`
29
+ `+y.slice(D,P),D=P+1),T=B;return F+=`
30
+ `,y.length-D>C&&T>D?F+=y.slice(D,T)+`
31
+ `+y.slice(T+1):F+=y.slice(D),F.slice(1)}function Ut(y){let C="",v=0;for(let L=0;L<y.length;v>=65536?L+=2:L++){v=ut(y,L);const D=le[v];!D&&jt(v)?(C+=y[L],v>=65536&&(C+=y[L+1])):C+=D||St(v)}return C}function Oo(y,C,v){let L="";const D=y.tag;for(let P=0,T=v.length;P<T;P+=1){let B=v[P];y.replacer&&(B=y.replacer.call(v,String(P),B)),(S(y,C,B,!1,!1)||typeof B>"u"&&S(y,C,null,!1,!1))&&(L!==""&&(L+=","+(y.condenseFlow?"":" ")),L+=y.dump)}y.tag=D,y.dump="["+L+"]"}function xr(y,C,v,L){let D="";const P=y.tag;for(let T=0,B=v.length;T<B;T+=1){let F=v[T];y.replacer&&(F=y.replacer.call(v,String(T),F)),(S(y,C+1,F,!0,!0,!1,!0)||typeof F>"u"&&S(y,C+1,null,!0,!0,!1,!0))&&((!L||D!=="")&&(D+=Hn(y,C)),y.dump&&l===y.dump.charCodeAt(0)?D+="-":D+="- ",D+=y.dump)}y.tag=P,y.dump=D||"[]"}function Lo(y,C,v){let L="";const D=y.tag,P=Object.keys(v);for(let T=0,B=P.length;T<B;T+=1){let F="";L!==""&&(F+=", "),y.condenseFlow&&(F+='"');const W=P[T];let K=v[W];y.replacer&&(K=y.replacer.call(v,W,K)),S(y,C,W,!1,!1)&&(y.dump.length>1024&&(F+="? "),F+=y.dump+(y.condenseFlow?'"':"")+":"+(y.condenseFlow?"":" "),S(y,C,K,!1,!1)&&(F+=y.dump,L+=F))}y.tag=D,y.dump="{"+L+"}"}function Io(y,C,v,L){let D="";const P=y.tag,T=Object.keys(v);if(y.sortKeys===!0)T.sort();else if(typeof y.sortKeys=="function")T.sort(y.sortKeys);else if(y.sortKeys)throw new e("sortKeys must be a boolean or a function");for(let B=0,F=T.length;B<F;B+=1){let W="";(!L||D!=="")&&(W+=Hn(y,C));const K=T[B];let G=v[K];if(y.replacer&&(G=y.replacer.call(v,K,G)),!S(y,C+1,K,!0,!0,!0))continue;const X=y.tag!==null&&y.tag!=="?"||y.dump&&y.dump.length>1024;X&&(y.dump&&l===y.dump.charCodeAt(0)?W+="?":W+="? "),W+=y.dump,X&&(W+=Hn(y,C)),S(y,C+1,G,!0,X)&&(y.dump&&l===y.dump.charCodeAt(0)?W+=":":W+=": ",W+=y.dump,D+=W)}y.tag=P,y.dump=D||"{}"}function f(y,C,v){const L=v?y.explicitTypes:y.implicitTypes;for(let D=0,P=L.length;D<P;D+=1){const T=L[D];if((T.instanceOf||T.predicate)&&(!T.instanceOf||typeof C=="object"&&C instanceof T.instanceOf)&&(!T.predicate||T.predicate(C))){if(v?T.multi&&T.representName?y.tag=T.representName(C):y.tag=T.tag:y.tag="?",T.represent){const B=y.styleMap[T.tag]||T.defaultStyle;let F;if(r.call(T.represent)==="[object Function]")F=T.represent(C,B);else if(i.call(T.represent,B))F=T.represent[B](C,B);else throw new e("!<"+T.tag+'> tag resolver accepts not "'+B+'" style');y.dump=F}return!0}}return!1}function S(y,C,v,L,D,P,T){y.tag=null,y.dump=v,f(y,v,!1)||f(y,v,!0);const B=r.call(y.dump),F=L;L&&(L=y.flowLevel<0||y.flowLevel>C);const W=B==="[object Object]"||B==="[object Array]";let K,G;if(W&&(K=y.duplicates.indexOf(v),G=K!==-1),(y.tag!==null&&y.tag!=="?"||G||y.indent!==2&&C>0)&&(D=!1),G&&y.usedDuplicates[K])y.dump="*ref_"+K;else{if(W&&G&&!y.usedDuplicates[K]&&(y.usedDuplicates[K]=!0),B==="[object Object]")L&&Object.keys(y.dump).length!==0?(Io(y,C,y.dump,D),G&&(y.dump="&ref_"+K+y.dump)):(Lo(y,C,y.dump),G&&(y.dump="&ref_"+K+" "+y.dump));else if(B==="[object Array]")L&&y.dump.length!==0?(y.noArrayIndent&&!T&&C>0?xr(y,C-1,y.dump,D):xr(y,C,y.dump,D),G&&(y.dump="&ref_"+K+y.dump)):(Oo(y,C,y.dump),G&&(y.dump="&ref_"+K+" "+y.dump));else if(B==="[object String]")y.tag!=="?"&&Li(y,y.dump,C,P,F);else{if(B==="[object Undefined]")return!1;if(y.skipInvalid)return!1;throw new e("unacceptable kind of an object to dump "+B)}if(y.tag!==null&&y.tag!=="?"){let X=encodeURI(y.tag[0]==="!"?y.tag.slice(1):y.tag).replace(/!/g,"%21");y.tag[0]==="!"?X="!"+X:X.slice(0,18)==="tag:yaml.org,2002:"?X="!!"+X.slice(18):X="!<"+X+">",y.dump=X+" "+y.dump}}return!0}function E(y,C){const v=[],L=[];N(y,v,L);const D=L.length;for(let P=0;P<D;P+=1)C.duplicates.push(v[L[P]]);C.usedDuplicates=new Array(D)}function N(y,C,v){if(y!==null&&typeof y=="object"){const L=C.indexOf(y);if(L!==-1)v.indexOf(L)===-1&&v.push(L);else if(C.push(y),Array.isArray(y))for(let D=0,P=y.length;D<P;D+=1)N(y[D],C,v);else{const D=Object.keys(y);for(let P=0,T=D.length;P<T;P+=1)N(y[D[P]],C,v)}}}function M(y,C){C=C||{};const v=new Eo(C);v.noRefs||E(y,v);let L=y;return v.replacer&&(L=v.replacer.call({"":L},"",L)),S(v,0,L,!0,!0)?v.dump+`
32
+ `:""}return el.dump=M,el}var jc;function Tg(){if(jc)return Pe;jc=1;const t=vg(),e=Mg();function n(r,i){return function(){throw new Error("Function yaml."+r+" is removed in js-yaml 4. Use yaml."+i+" instead, which is now safe by default.")}}return Pe.Type=qe(),Pe.Schema=rf(),Pe.FAILSAFE_SCHEMA=af(),Pe.JSON_SCHEMA=pf(),Pe.CORE_SCHEMA=hf(),Pe.DEFAULT_SCHEMA=Sa(),Pe.load=t.load,Pe.loadAll=t.loadAll,Pe.dump=e.dump,Pe.YAMLException=pi(),Pe.types={binary:yf(),float:ff(),map:lf(),null:cf(),pairs:kf(),set:xf(),timestamp:mf(),bool:uf(),int:df(),merge:gf(),omap:bf(),seq:of(),str:sf()},Pe.safeLoad=n("safeLoad","load"),Pe.safeLoadAll=n("safeLoadAll","loadAll"),Pe.safeDump=n("safeDump","dump"),Pe}var Ag=Tg();const un=wg(Ag),{Type:WM,Schema:KM,FAILSAFE_SCHEMA:YM,JSON_SCHEMA:GM,CORE_SCHEMA:JM,DEFAULT_SCHEMA:XM,load:ZM,loadAll:QM,dump:eT,YAMLException:tT,types:nT,safeLoad:rT,safeLoadAll:iT,safeDump:sT}=un;async function Eg(){for(const t of["/studio/schema.yml","./schema.yml"])try{const e=await fetch(t,{cache:"no-store"});if(e.ok){const n=await e.text();return Ng(un.load(n))}}catch{}throw new Error("Could not load studio/schema.yml")}function Ng(t){const e=[],n=[];function r(i,s){for(const o of i||[])if(!(!o||typeof o!="object")){if(o.type==="group")e.push({name:o.name,label:o.label||o.name}),r(o.items,o.label||o.name);else if(o.type==="collection"||o.type==="file"){const l=o.view||{};n.push({name:o.name,label:o.label||o.name,group:s||"Content",type:o.type,path:o.path,format:o.format||"yaml-frontmatter",filename:o.filename,root_key:o.root_key||null,description:o.description||"",list:!!o.list,fields:o.fields||[],view:l,listMetaFields:Array.isArray(l.list_meta_fields)?l.list_meta_fields.map(String):null,operations:o.operations||{delete:!1}})}}}return r(t==null?void 0:t.content,null),{media:(t==null?void 0:t.media)||{},groups:e,collections:n,raw:t}}function Sf(t){const e=String((t==null?void 0:t.name)||"");return(t==null?void 0:t.component)==="markdown_body"||e==="body"||e.startsWith("body_")||e==="description"&&(t==null?void 0:t.component)==="markdown_body"}let wf=async()=>null;function Og(t){wf=t}async function dt(t,e={}){const n=await wf(),r={Accept:"application/json",...e.headers||{}};n&&(r.Authorization=`Bearer ${n}`),e.body&&!r["Content-Type"]&&(r["Content-Type"]="application/json");const i=await fetch(`/api/studio/${t.replace(/^\//,"")}`,{...e,headers:r}),s=await i.text();let o=null;try{o=s?JSON.parse(s):null}catch{o={raw:s}}if(!i.ok){const l=String((o==null?void 0:o.message)||(o==null?void 0:o.error)||`HTTP ${i.status}`),a=new Error(l);throw a.status=i.status,a.code=(o==null?void 0:o.error)||"",a.data=o,a}return o}const kt={session:()=>dt("session"),tree:t=>dt(`tree?path=${encodeURIComponent(t)}`),getFile:t=>dt(`file?path=${encodeURIComponent(t)}`),putFile:({path:t,content:e,message:n,sha:r})=>dt("file",{method:"PUT",body:JSON.stringify({path:t,content:e,message:n,sha:r})}),listMedia:t=>dt(`media?path=${encodeURIComponent(t||"content/media")}`),uploadMedia:({path:t,content_base64:e,message:n})=>dt("media",{method:"POST",body:JSON.stringify({path:t,content_base64:e,message:n})}),createMediaFolder:({path:t,message:e})=>dt("media/folder",{method:"POST",body:JSON.stringify({path:t,message:e})}),searchXcite:t=>dt(`search/xcite?q=${encodeURIComponent(t||"")}`),searchCite:t=>dt(`search/cite?q=${encodeURIComponent(t||"")}`),rewrite:t=>dt("rewrite",{method:"POST",body:JSON.stringify(t)})};function Cf(t){const e=String(t||"");if(!e.startsWith("---"))return{fmLines:[],fm:{},body:e,hasFm:!1};const n=e.indexOf(`
33
+ ---`,3);if(n<0)return{fmLines:[],fm:{},body:e,hasFm:!1};const r=e.slice(4,n).replace(/^\r?\n/,""),i=e.slice(n+4),s=/^\r?\n\r?\n/.test(i),o=i.replace(/^(?:\r?\n)+/,""),l=r.split(/\r?\n/),a=vf(r);return{fmLines:l,fm:a,body:o,hasFm:!0,rawFm:r,blankAfterFm:s}}function vf(t){try{const n=un.load(t,{schema:un.JSON_SCHEMA});if(n&&typeof n=="object"&&!Array.isArray(n))return n}catch{}const e={};for(const n of String(t||"").split(/\r?\n/)){const r=n.match(/^([A-Za-z0-9_]+):\s*(.*)$/);if(!r)continue;let i=r[2];i==="true"?i=!0:i==="false"?i=!1:(i.startsWith('"')&&i.endsWith('"')||i.startsWith("'")&&i.endsWith("'"))&&(i=i.slice(1,-1)),e[r[1]]=i}return e}function Vc(t){if(t===!0||t===!1||typeof t=="number")return String(t);if(t==null)return'""';const e=String(t);return e===""?'""':/^(true|false|null|yes|no|~)$/i.test(e)||/[:#&*!|>%@`]/.test(e)||/^[\s\-?]|:\s|\s$/.test(e)||/[\n"']/.test(e)?JSON.stringify(e):e}function Qr(t){return!!(t===""||t==null||Array.isArray(t)&&t.length===0)}function Ll(t,e){return JSON.stringify(t)===JSON.stringify(e)}function Lg(t){const e=String(t||"").replace(/\r\n/g,`
34
+ `).replace(/\n$/,"").split(`
35
+ `),n=[];let r=0;for(;r<e.length;){if(e[r].trim()===""){r++;continue}const i=e[r].match(/^([A-Za-z0-9_]+):\s*(.*)$/);if(!i){r++;continue}const s=r;for(r++;r<e.length;){const o=e[r];if(o===""){const l=e[r+1];if(l==null||/^[A-Za-z0-9_]+:\s*/.test(l))break;r++;continue}if(/^\s/.test(o)){r++;continue}break}n.push({key:i[1],lines:e.slice(s,r)})}return n}function Il(t,e){return Array.isArray(e)&&e.every(n=>n==null||typeof n!="object")?[`${t}:`,...e.map(n=>` - ${Vc(n)}`)]:e&&typeof e=="object"?un.dump({[t]:e},{schema:un.JSON_SCHEMA,lineWidth:-1,noRefs:!0}).replace(/\n$/,"").split(`
36
+ `):[`${t}: ${Vc(e)}`]}function Ig(t,e){const n={...t};for(const[i,s]of Object.entries(e||{}))Qr(s)?Qr(t[i])||delete n[i]:n[i]=s;const r=new Set([...Object.keys(t),...Object.keys(n)]);for(const i of r)if(!Ll(t[i],n[i]))return!0;return!1}function Rg(t,e){const n=vf(t),r={...n};for(const[u,d]of Object.entries(e||{}))Qr(d)?Qr(n[u])||delete r[u]:r[u]=d;const i=Object.keys(n),s=Object.keys(r);if(i.length===s.length&&s.every(u=>Ll(n[u],r[u])))return String(t||"").replace(/\n$/,"");const l=Lg(t),a=new Set,c=[];for(const u of l)Object.prototype.hasOwnProperty.call(r,u.key)&&(a.add(u.key),Ll(n[u.key],r[u.key])?c.push(...u.lines):c.push(...Il(u.key,r[u.key])));for(const[u,d]of Object.entries(r))a.has(u)||c.push(...Il(u,d));return c.join(`
37
+ `)}function Dg(t,{fields:e,body:n,format:r}){if(r==="raw"||r==="yaml")return n.endsWith(`
38
+ `)?n:n+`
39
+ `;const i=Cf(t),{rawFm:s,hasFm:o,blankAfterFm:l}=i,a=String(n||"").replace(/^(?:\r?\n)+/,"");if(o&&!Ig(i.fm,e)&&a===String(i.body||"").replace(/^(?:\r?\n)+/,""))return t;const c=["---"];if(o){const h=Rg(s,e);h&&c.push(h)}else for(const[h,g]of Object.entries(e||{}))Qr(g)||c.push(...Il(h,g));c.push("---");const u=String(n||"").replace(/^(?:\r?\n)+/,""),d=u.endsWith(`
40
+ `)?u:u+`
41
+ `,p=l?`
42
+
43
+ `:`
44
+ `;return c.join(`
45
+ `)+p+d}var Uc=Object.defineProperty,Pg=(t,e)=>{let n={};for(var r in t)Uc(n,r,{get:t[r],enumerable:!0});return Uc(n,Symbol.toStringTag,{value:"Module"}),n};function Ne(t){this.content=t}Ne.prototype={constructor:Ne,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?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,i=r.find(t),s=r.content.slice();return i==-1?s.push(n||t,e):(s[i+1]=e,n&&(s[i]=n)),new Ne(s)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new Ne(n)},addToStart:function(t,e){return new Ne([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new Ne(n)},addBefore:function(t,e,n){var r=this.remove(e),i=r.content.slice(),s=r.find(t);return i.splice(s==-1?i.length:s,0,e,n),new Ne(i)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return t=Ne.from(t),t.size?new Ne(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=Ne.from(t),t.size?new Ne(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=Ne.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},toObject:function(){var t={};return this.forEach(function(e,n){t[e]=n}),t},get size(){return this.content.length>>1}};Ne.from=function(t){if(t instanceof Ne)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new Ne(e)};function Mf(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let i=t.child(r),s=e.child(r);if(i==s){n+=i.nodeSize;continue}if(!i.sameMarkup(s))return n;if(i.isText&&i.text!=s.text){let o=i.text,l=s.text,a=0;for(;o[a]==l[a];a++)n++;return a&&a<o.length&&a<l.length&&Ef(o.charCodeAt(a-1))&&Af(o.charCodeAt(a))&&n--,n}if(i.content.size||s.content.size){let o=Mf(i.content,s.content,n+1);if(o!=null)return o}n+=i.nodeSize}}function Tf(t,e,n,r){for(let i=t.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:n,b:r};let o=t.child(--i),l=e.child(--s),a=o.nodeSize;if(o==l){n-=a,r-=a;continue}if(!o.sameMarkup(l))return{a:n,b:r};if(o.isText&&o.text!=l.text){let c=o.text,u=l.text,d=c.length,p=u.length;for(;d>0&&p>0&&c[d-1]==u[p-1];)d--,p--,n--,r--;return d&&p&&d<c.length&&Ef(c.charCodeAt(d-1))&&Af(c.charCodeAt(d))&&(n++,r++),{a:n,b:r}}if(o.content.size||l.content.size){let c=Tf(o.content,l.content,n-1,r-1);if(c)return c}n-=a,r-=a}}function Af(t){return t>=56320&&t<57344}function Ef(t){return t>=55296&&t<56320}class I{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,i=0,s){for(let o=0,l=0;l<n;o++){let a=this.content[o],c=l+a.nodeSize;if(c>e&&r(a,i+l,s||null,o)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,n-u),r,i+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,i){let s="",o=!0;return this.nodesBetween(e,n,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,n-a):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(o?o=!1:s+=r),s+=c},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,i=this.content.slice(),s=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),s=1);s<e.content.length;s++)i.push(e.content[s]);return new I(i,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],i=0;if(n>e)for(let s=0,o=0;o<n;s++){let l=this.content[s],a=o+l.nodeSize;a>e&&((o<e||a>n)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,n-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,n-o-1))),r.push(l),i+=l.nodeSize),o=a}return new I(r,i)}cutByIndex(e,n){return e==n?I.empty:e==0&&n==this.content.length?this:new I(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let i=this.content.slice(),s=this.size+n.nodeSize-r.nodeSize;return i[e]=n,new I(i,s)}addToStart(e){return new I([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new I(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let i=this.content[n];e(i,r,n),r+=i.nodeSize}}findDiffStart(e,n=0){return Mf(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return Tf(this,e,n,r)}findIndex(e){if(e==0)return $i(0,e);if(e==this.size)return $i(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let i=this.child(n),s=r+i.nodeSize;if(s>=e)return s==e?$i(n+1,s):$i(n,r);r=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return I.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return I.fromArray(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return I.empty;let n,r=0;for(let i=0;i<e.length;i++){let s=e[i];r+=s.nodeSize,i&&s.isText&&e[i-1].sameMarkup(s)?(n||(n=e.slice(0,i)),n[n.length-1]=s.withText(n[n.length-1].text+s.text)):n&&n.push(s)}return new I(n||e,r)}static from(e){if(!e)return I.empty;if(e instanceof I)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new I([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}I.empty=new I([],0);const tl={index:0,offset:0};function $i(t,e){return tl.index=t,tl.offset=e,tl}function ss(t,e){if(t===e)return!0;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!ss(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!ss(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let ue=class Rl{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let i=0;i<e.length;i++){let s=e[i];if(this.eq(s))return e;if(this.type.excludes(s.type))n||(n=e.slice(0,i));else{if(s.type.excludes(this.type))return e;!r&&s.type.rank>this.type.rank&&(n||(n=e.slice(0,i)),n.push(this),r=!0),n&&n.push(s)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&ss(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);return r.create(n.attrs)}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(n[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return Rl.none;if(e instanceof Rl)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}};ue.none=[];class ei extends Error{}class _{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=Of(this.content,e+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new _(r,this.openStart,this.openEnd)}removeBetween(e,n){return new _(Nf(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return _.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new _(I.fromJSON(e,n.content),r,i)}static maxOpen(e,n=!0){let r=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(n||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(n||!s.type.spec.isolating);s=s.lastChild)i++;return new _(e,r,i)}}_.empty=new _(I.empty,0,0);function Nf(t,e,n){let{index:r,offset:i}=t.findIndex(e),s=t.maybeChild(r),{index:o,offset:l}=t.findIndex(n);if(i==e||s.isText){if(l!=n&&!t.child(o).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(r,s.copy(Nf(s.content,e-i-1,n-i-1)))}function Of(t,e,n,r,i,s){let{index:o,offset:l}=t.findIndex(e),a=t.maybeChild(o);if(l==e||a.isText)return s&&r<=0&&i<=0&&!s.canReplace(o,o,n)?null:t.cut(0,e).append(n).append(t.cut(e));let c=Of(a.content,e-l-1,n,o==0?r-1:0,o==t.childCount-1?i-1:0,a);return c&&t.replaceChild(o,a.copy(c))}function $g(t,e,n){if(n.openStart>t.depth)throw new ei("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new ei("Inconsistent open depths");return Lf(t,e,n,0)}function Lf(t,e,n,r){let i=t.index(r),s=t.node(r);if(i==e.index(r)&&r<t.depth-n.openStart){let o=Lf(t,e,n,r+1);return s.copy(s.content.replaceChild(i,o))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let o=t.parent,l=o.content;return An(o,l.cut(0,t.parentOffset).append(n.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=Bg(n,t);return An(s,Rf(t,o,l,e,r))}else return An(s,ls(t,e,r))}function If(t,e){if(!e.type.compatibleContent(t.type))throw new ei("Cannot join "+e.type.name+" onto "+t.type.name)}function Dl(t,e,n){let r=t.node(n);return If(r,e.node(n)),r}function Tn(t,e){let n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function Br(t,e,n,r){let i=(e||t).node(n),s=0,o=e?e.index(n):i.childCount;t&&(s=t.index(n),t.depth>n?s++:t.textOffset&&(Tn(t.nodeAfter,r),s++));for(let l=s;l<o;l++)Tn(i.child(l),r);e&&e.depth==n&&e.textOffset&&Tn(e.nodeBefore,r)}function An(t,e){if(!t.type.validContent(e))throw new ei("Invalid content for node "+t.type.name);return t.copy(e)}function Rf(t,e,n,r,i){let s=t.depth>i&&Dl(t,e,i+1),o=r.depth>i&&Dl(n,r,i+1),l=[];return Br(null,t,i,l),s&&o&&e.index(i)==n.index(i)?(If(s,o),Tn(An(s,Rf(t,e,n,r,i+1)),l)):(s&&Tn(An(s,ls(t,e,i+1)),l),Br(e,n,i,l),o&&Tn(An(o,ls(n,r,i+1)),l)),Br(r,null,i,l),new I(l)}function ls(t,e,n){let r=[];if(Br(null,t,n,r),t.depth>n){let i=Dl(t,e,n+1);Tn(An(i,ls(t,e,n+1)),r)}return Br(e,null,n,r),new I(r)}function Bg(t,e){let n=e.depth-t.openStart,i=e.node(n).copy(t.content);for(let s=n-1;s>=0;s--)i=e.node(s).copy(I.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class ti{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(n);return r?e.child(n).cut(r):i}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],i=n==0?0:this.path[n*3-1]+1;for(let s=0;s<e;s++)i+=r.child(s).nodeSize;return i}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return ue.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),i=e.maybeChild(n);if(!r){let l=r;r=i,i=l}let s=r.marks;for(var o=0;o<s.length;o++)s[o].type.spec.inclusive===!1&&(!i||!s[o].isInSet(i.marks))&&(s=s[o--].removeFromSet(s));return s}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,i=e.parent.maybeChild(e.index());for(var s=0;s<r.length;s++)r[s].type.spec.inclusive===!1&&(!i||!r[s].isInSet(i.marks))&&(r=r[s--].removeFromSet(r));return r}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new as(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],i=0,s=n;for(let o=e;;){let{index:l,offset:a}=o.content.findIndex(s),c=s-a;if(r.push(o,l,i+a),!c||(o=o.child(l),o.isText))break;s=c-1,i+=a+1}return new ti(n,r,s)}static resolveCached(e,n){let r=qc.get(e);if(r)for(let s=0;s<r.elts.length;s++){let o=r.elts[s];if(o.pos==n)return o}else qc.set(e,r=new _g);let i=r.elts[r.i]=ti.resolve(e,n);return r.i=(r.i+1)%zg,i}}class _g{constructor(){this.elts=[],this.i=0}}const zg=12,qc=new WeakMap;class as{constructor(e,n,r){this.$from=e,this.$to=n,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const Fg=Object.create(null);let En=class Pl{constructor(e,n,r,i=ue.none){this.type=e,this.attrs=n,this.marks=i,this.content=r||I.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,n,r,i=0){this.content.nodesBetween(e,n,r,i,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,n,r,i){return this.content.textBetween(e,n,r,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,n,r){return this.type==e&&ss(this.attrs,n||e.defaultAttrs||Fg)&&ue.sameSet(this.marks,r||ue.none)}copy(e=null){return e==this.content?this:new Pl(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new Pl(this.type,this.attrs,this.content,e)}cut(e,n=this.content.size){return e==0&&n==this.content.size?this:this.copy(this.content.cut(e,n))}slice(e,n=this.content.size,r=!1){if(e==n)return _.empty;let i=this.resolve(e),s=this.resolve(n),o=r?0:i.sharedDepth(n),l=i.start(o),c=i.node(o).content.cut(i.pos-l,s.pos-l);return new _(c,i.depth-o,s.depth-o)}replace(e,n,r){return $g(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:i}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(i==e||n.isText)return n;e-=i+1}}childAfter(e){let{index:n,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(n),index:n,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:n,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(n),index:n,offset:r};let i=this.content.child(n-1);return{node:i,index:n-1,offset:r-i.nodeSize}}resolve(e){return ti.resolveCached(this,e)}resolveNoCache(e){return ti.resolve(this,e)}rangeHasMark(e,n,r){let i=!1;return n>e&&this.nodesBetween(e,n,s=>(r.isInSet(s.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Df(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=I.empty,i=0,s=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,i,s),l=o&&o.matchFragment(this.content,n);if(!l||!l.validEnd)return!1;for(let a=i;a<s;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,n,r,i){if(i&&!this.type.allowsMarks(i))return!1;let s=this.contentMatchAt(e).matchType(r),o=s&&s.matchFragment(this.content,n);return o?o.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),Wc(this.type.attrs,this.attrs,"node",this.type.name);let e=ue.none;for(let n=0;n<this.marks.length;n++){let r=this.marks[n];Wc(r.type.attrs,r.attrs,"mark",r.type.name),e=r.addToSet(e)}if(!ue.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let i=I.fromJSON(e,n.content);return e.nodeType(n.type).create(n.attrs,i,r)}};En.prototype.text=void 0;class cs extends En{constructor(e,n,r,i){if(super(e,n,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Df(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new cs(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new cs(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function Df(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}function Wc(t,e,n,r){for(let i in e)if(!(i in t))throw new RangeError(`Unsupported attribute ${i} for ${n} of type ${r}`);for(let i in t)t[i].validate&&t[i].validate(e[i])}class Ln{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new Hg(e,n);if(r.next==null)return Ln.empty;let i=Pf(r);r.next&&r.err("Unexpected trailing text");let s=Yg(Kg(i));return Gg(s,r),s}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,r=e.childCount){let i=this;for(let s=n;i&&s<r;s++)i=i.matchType(e.child(s).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let i=[this];function s(o,l){let a=o.matchFragment(e,r);if(a&&(!n||a.validEnd))return I.from(l.map(c=>c.createAndFill()));for(let c=0;c<o.next.length;c++){let{type:u,next:d}=o.next[c];if(!(u.isText||u.hasRequiredAttrs())&&i.indexOf(d)==-1){i.push(d);let p=s(d,l.concat(u));if(p)return p}}return null}return s(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),s=i.match;if(s.matchType(e)){let o=[];for(let l=i;l.type;l=l.via)o.push(l.type);return o.reverse()}for(let o=0;o<s.next.length;o++){let{type:l,next:a}=s.next[o];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in n)&&(!i.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:i}),n[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&n(r.next[i].next)}return n(this),e.map((r,i)=>{let s=i+(r.validEnd?"*":" ")+" ";for(let o=0;o<r.next.length;o++)s+=(o?", ":"")+r.next[o].type.name+"->"+e.indexOf(r.next[o].next);return s}).join(`
46
+ `)}}Ln.empty=new Ln(!0);class Hg{constructor(e,n){this.string=e,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function Pf(t){let e=[];do e.push(jg(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function jg(t){let e=[];do e.push(Vg(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Vg(t){let e=Wg(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=Ug(t,e);else break;return e}function Kc(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function Ug(t,e){let n=Kc(t),r=n;return t.eat(",")&&(t.next!="}"?r=Kc(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function qg(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let i=[];for(let s in n){let o=n[s];o.isInGroup(e)&&i.push(o)}return i.length==0&&t.err("No node type or group '"+e+"' found"),i}function Wg(t){if(t.eat("(")){let e=Pf(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=qg(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err("Mixing inline and block content"),{type:"name",value:n}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function Kg(t){let e=[[]];return i(s(t,0),n()),e;function n(){return e.push([])-1}function r(o,l,a){let c={term:a,to:l};return e[o].push(c),c}function i(o,l){o.forEach(a=>a.to=l)}function s(o,l){if(o.type=="choice")return o.exprs.reduce((a,c)=>a.concat(s(c,l)),[]);if(o.type=="seq")for(let a=0;;a++){let c=s(o.exprs[a],l);if(a==o.exprs.length-1)return c;i(c,l=n())}else if(o.type=="star"){let a=n();return r(l,a),i(s(o.expr,a),a),[r(a)]}else if(o.type=="plus"){let a=n();return i(s(o.expr,l),a),i(s(o.expr,a),a),[r(a)]}else{if(o.type=="opt")return[r(l)].concat(s(o.expr,l));if(o.type=="range"){let a=l;for(let c=0;c<o.min;c++){let u=n();i(s(o.expr,a),u),a=u}if(o.max==-1)i(s(o.expr,a),a);else for(let c=o.min;c<o.max;c++){let u=n();r(a,u),i(s(o.expr,a),u),a=u}return[r(a)]}else{if(o.type=="name")return[r(l,void 0,o.value)];throw new Error("Unknown expr type")}}}}function $f(t,e){return e-t}function Yc(t,e){let n=[];return r(e),n.sort($f);function r(i){let s=t[i];if(s.length==1&&!s[0].term)return r(s[0].to);n.push(i);for(let o=0;o<s.length;o++){let{term:l,to:a}=s[o];!l&&n.indexOf(a)==-1&&r(a)}}}function Yg(t){let e=Object.create(null);return n(Yc(t,0));function n(r){let i=[];r.forEach(o=>{t[o].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let u=0;u<i.length;u++)i[u][0]==l&&(c=i[u][1]);Yc(t,a).forEach(u=>{c||i.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let s=e[r.join(",")]=new Ln(r.indexOf(t.length-1)>-1);for(let o=0;o<i.length;o++){let l=i[o][1].sort($f);s.next.push({type:i[o][0],next:e[l.join(",")]||n(l)})}return s}}function Gg(t,e){for(let n=0,r=[t];n<r.length;n++){let i=r[n],s=!i.validEnd,o=[];for(let l=0;l<i.next.length;l++){let{type:a,next:c}=i.next[l];o.push(a.name),s&&!(a.isText||a.hasRequiredAttrs())&&(s=!1),r.indexOf(c)==-1&&r.push(c)}s&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Bf(t){let e=Object.create(null);for(let n in t){let r=t[n];if(!r.hasDefault)return null;e[n]=r.default}return e}function _f(t,e){let n=Object.create(null);for(let r in t){let i=t[r],s=e&&e[r];if(s===void 0)if(i.hasDefault)s=i.default;else throw new RangeError("No value supplied for attribute "+r);else i.validate&&i.validate(s);n[r]=s}return n}function zf(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new Xg(t,r,e[r]);return n}let Gc=class Ff{constructor(e,n,r){this.name=e,this.schema=n,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=zf(e,r.attrs),this.defaultAttrs=Bf(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Ln.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:_f(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new En(this,this.computeAttrs(e),I.from(n),ue.setFrom(r))}createChecked(e=null,n,r){return n=I.from(n),this.checkContent(n),new En(this,this.computeAttrs(e),n,ue.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=I.from(n),n.size){let o=this.contentMatch.fillBefore(n);if(!o)return null;n=o.append(n)}let i=this.contentMatch.matchFragment(n),s=i&&i.fillBefore(I.empty,!0);return s?new En(this,e,n.append(s),ue.setFrom(r)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;n<e.length;n++)if(!this.allowsMarkType(e[n].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let n;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?n&&n.push(e[r]):n||(n=e.slice(0,r));return n?n.length?n:ue.none:e}static compile(e,n){let r=Object.create(null);e.forEach((s,o)=>r[s]=new Ff(s,n,o));let i=n.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let s in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function Jg(t,e,n){let r=n.split("|");return i=>{let s=i===null?"null":typeof i;if(r.indexOf(s)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${s}`)}}class Xg{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?Jg(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class no{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=zf(e,i.attrs),this.excluded=null;let s=Bf(this.attrs);this.instance=s?new ue(this,s):null}create(e=null){return!e&&this.instance?this.instance:new ue(this,_f(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((s,o)=>r[s]=new no(s,i++,n,o)),r}removeFromSet(e){for(var n=0;n<e.length;n++)e[n].type==this&&(e=e.slice(0,n).concat(e.slice(n+1)),n--);return e}isInSet(e){for(let n=0;n<e.length;n++)if(e[n].type==this)return e[n]}excludes(e){return this.excluded.indexOf(e)>-1}}class Hf{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let i in e)n[i]=e[i];n.nodes=Ne.from(e.nodes),n.marks=Ne.from(e.marks||{}),this.nodes=Gc.compile(this.spec.nodes,this),this.marks=no.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let s=this.nodes[i],o=s.spec.content||"",l=s.spec.marks;if(s.contentMatch=r[o]||(r[o]=Ln.parse(o,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!s.isInline||!s.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=s}s.markSet=l=="_"?null:l?Jc(this,l.split(" ")):l==""||!s.inlineContent?[]:null}for(let i in this.marks){let s=this.marks[i],o=s.spec.excludes;s.excluded=o==null?[s]:o==""?[]:Jc(this,o.split(" "))}this.nodeFromJSON=i=>En.fromJSON(this,i),this.markFromJSON=i=>ue.fromJSON(this,i),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Gc){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,r,i)}text(e,n){let r=this.nodes.text;return new cs(r,r.defaultAttrs,e,ue.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}}function Jc(t,e){let n=[];for(let r=0;r<e.length;r++){let i=e[r],s=t.marks[i],o=s;if(s)n.push(s);else for(let l in t.marks){let a=t.marks[l];(i=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(i)>-1)&&n.push(o=a)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function Zg(t){return t.tag!=null}function Qg(t){return t.style!=null}class nn{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(i=>{if(Zg(i))this.tags.push(i);else if(Qg(i)){let s=/[^=]*/.exec(i.style)[0];r.indexOf(s)<0&&r.push(s),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let s=e.nodes[i.node];return s.contentMatch.matchType(s)})}parse(e,n={}){let r=new Zc(this,n,!1);return r.addAll(e,ue.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new Zc(this,n,!0);return r.addAll(e,ue.none,n.from,n.to),_.maxOpen(r.finish())}matchTag(e,n,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let s=this.tags[i];if(ny(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||n.matchesContext(s.context))){if(s.getAttrs){let o=s.getAttrs(e);if(o===!1)continue;s.attrs=o||void 0}return s}}}matchStyle(e,n,r,i){for(let s=i?this.styles.indexOf(i)+1:0;s<this.styles.length;s++){let o=this.styles[s],l=o.style;if(!(l.indexOf(e)!=0||o.context&&!r.matchesContext(o.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=n))){if(o.getAttrs){let a=o.getAttrs(n);if(a===!1)continue;o.attrs=a||void 0}return o}}}static schemaRules(e){let n=[];function r(i){let s=i.priority==null?50:i.priority,o=0;for(;o<n.length;o++){let l=n[o];if((l.priority==null?50:l.priority)<s)break}n.splice(o,0,i)}for(let i in e.marks){let s=e.marks[i].spec.parseDOM;s&&s.forEach(o=>{r(o=Qc(o)),o.mark||o.ignore||o.clearMark||(o.mark=i)})}for(let i in e.nodes){let s=e.nodes[i].spec.parseDOM;s&&s.forEach(o=>{r(o=Qc(o)),o.node||o.ignore||o.mark||(o.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new nn(e,nn.schemaRules(e)))}}const jf={address:!0,article:!0,aside:!0,blockquote:!0,body:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},ey={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Vf={ol:!0,ul:!0},ni=1,$l=2,_r=4;function Xc(t,e,n){return e!=null?(e?ni:0)|(e==="full"?$l:0):t&&t.whitespace=="pre"?ni|$l:n&~_r}class Bi{constructor(e,n,r,i,s,o){this.type=e,this.attrs=n,this.marks=r,this.solid=i,this.options=o,this.content=[],this.activeMarks=ue.none,this.match=s||(o&_r?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(I.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&ni)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let s=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-i[0].length))}}let n=I.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(I.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!jf.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Zc{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=n.topNode,s,o=Xc(null,n.preserveWhitespace,0)|(r?_r:0);i?s=new Bi(i.type,i.attrs,ue.none,!0,n.topMatch||i.type.contentMatch,o):r?s=new Bi(null,null,ue.none,!0,null,o):s=new Bi(e.schema.topNodeType,null,ue.none,!0,null,o),this.nodes=[s],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,i=this.top,s=i.options&$l?"full":this.localPreserveWS||(i.options&ni)>0,{schema:o}=this.parser;if(s==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(s)if(s==="full")r=r.replace(/\r\n?/g,`
47
+ `);else if(o.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(o.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let a=0;a<l.length;a++)a&&this.insertNode(o.linebreakReplacement.create(),n,!0),l[a]&&this.insertNode(o.text(l[a]),n,!/\S/.test(l[a]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let l=i.content[i.content.length-1],a=e.previousSibling;(!l||a&&a.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(r=r.slice(1))}r&&this.insertNode(o.text(r),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){let i=this.localPreserveWS,s=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),l;Vf.hasOwnProperty(o)&&this.parser.normalizeLists&&ty(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:ey.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,n);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let c,u=this.needsBlock;if(jf.hasOwnProperty(o))s.content.length&&s.content[0].isInline&&this.open&&(this.open--,s=this.top),c=!0,s.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let d=a&&a.skip?n:this.readStyles(e,n);d&&this.addAll(e,d),c&&this.sync(s),this.needsBlock=u}else{let c=this.readStyles(e,n);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=i}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
48
+ `),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let s=this.parser.matchedStyles[i],o=r.getPropertyValue(s);if(o)for(let l=void 0;;){let a=this.parser.matchStyle(s,o,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?n=n.filter(c=>!a.clearMark(c)):n=n.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return n}addElementByRule(e,n,r,i){let s,o;if(n.node)if(o=this.parser.schema.nodes[n.node],o.isLeaf)this.insertNode(o.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(o,n.attrs||null,r,n.preserveWhitespace);a&&(s=!0,r=a)}else{let a=this.parser.schema.marks[n.mark];r=r.concat(a.create(n.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(i)this.addElement(e,r,i);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof n.contentElement=="string"?a=e.querySelector(n.contentElement):typeof n.contentElement=="function"?a=n.contentElement(e):n.contentElement&&(a=n.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}s&&this.sync(l)&&this.open--}addAll(e,n,r,i){let s=r||0;for(let o=r?e.childNodes[r]:e.firstChild,l=i==null?null:e.childNodes[i];o!=l;o=o.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(o,n);this.findAtPoint(e,s)}findPlace(e,n,r){let i,s;for(let o=this.open,l=0;o>=0;o--){let a=this.nodes[o],c=a.findWrapping(e);if(c&&(!i||i.length>c.length+l)&&(i=c,s=a,!c.length))break;if(a.solid){if(r)break;l+=2}}if(!i)return null;this.sync(s);for(let o=0;o<i.length;o++)n=this.enterInner(i[o],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let s=this.textblockFromContext();s&&(n=this.enterInner(s,null,n))}let i=this.findPlace(e,n,r);if(i){this.closeExtra();let s=this.top;s.match&&(s.match=s.match.matchType(e.type));let o=ue.none;for(let l of i.concat(e.marks))(s.type?s.type.allowsMarkType(l.type):eu(l.type,e.type))&&(o=l.addToSet(o));return s.content.push(e.mark(o)),!0}return!1}enter(e,n,r,i){let s=this.findPlace(e.create(n),r,!1);return s&&(s=this.enterInner(e,n,r,!0,i)),s}enterInner(e,n,r,i=!1,s){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let l=Xc(e,s,o.options);o.options&_r&&o.content.length==0&&(l|=_r);let a=ue.none;return r=r.filter(c=>(o.type?o.type.allowsMarkType(c.type):eu(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new Bi(e,n,a,i,null,l)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=ni)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&n.compareDocumentPosition(this.find[i].node)&(r?2:4)&&(this.find[i].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),s=-(r?r.depth+1:0)+(i?0:1),o=(l,a)=>{for(;l>=0;l--){let c=n[l];if(c==""){if(l==n.length-1||l==0)continue;for(;a>=s;a--)if(o(l-1,a))return!0;return!1}else{let u=a>0||a==0&&i?this.nodes[a].type:r&&a>=s?r.node(a-s).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;a--}}return!0};return o(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function ty(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Vf.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function ny(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function Qc(t){let e={};for(let n in t)e[n]=t[n];return e}function eu(t,e){let n=e.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(t))continue;let s=[],o=l=>{s.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:u}=l.edge(a);if(c==e||s.indexOf(u)<0&&o(u))return!0}};if(o(i.contentMatch))return!0}}class Bn{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=_i(n).createDocumentFragment());let i=r,s=[];return e.forEach(o=>{if(s.length||o.marks.length){let l=0,a=0;for(;l<s.length&&a<o.marks.length;){let c=o.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(s[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<s.length;)i=s.pop()[1];for(;a<o.marks.length;){let c=o.marks[a++],u=this.serializeMark(c,o.isInline,n);u&&(s.push([c,i]),i.appendChild(u.dom),i=u.contentDOM||u.dom)}}i.appendChild(this.serializeNodeInner(o,n))}),r}serializeNodeInner(e,n){if(e.isText)return _i(n).createTextNode(e.text);let{dom:r,contentDOM:i}=Xi(_i(n),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,i)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let i=e.marks.length-1;i>=0;i--){let s=this.serializeMark(e.marks[i],e.isInline,n);s&&((s.contentDOM||s.dom).appendChild(r),r=s.dom)}return r}serializeMark(e,n,r={}){let i=this.marks[e.type.name];return i&&Xi(_i(r),i(e,n),null,e.attrs)}static renderSpec(e,n,r=null,i){return typeof n=="string"?{dom:e.createTextNode(n)}:Xi(e,n,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Bn(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=tu(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return tu(e.marks)}}function tu(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function _i(t){return t.document||window.document}const nu=new WeakMap;function ry(t){let e=nu.get(t);return e===void 0&&nu.set(t,e=iy(t)),e}function iy(t){let e=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let i=0;i<r.length;i++)n(r[i]);else for(let i in r)n(r[i])}return n(t),e}function Xi(t,e,n,r){if(e.nodeType==1)return{dom:e};if(e.dom&&e.dom.nodeType==1)return e;let i=e[0],s;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(s=ry(r))&&s.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=i.indexOf(" ");o>0&&(n=i.slice(0,o),i=i.slice(o+1));let l,a=n?t.createElementNS(n,i):t.createElement(i),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let d in c)if(c[d]!=null){let p=d.indexOf(" ");p>0?a.setAttributeNS(d.slice(0,p),d.slice(p+1),c[d]):d=="style"&&a.style?a.style.cssText=c[d]:a.setAttribute(d,c[d])}}for(let d=u;d<e.length;d++){let p=e[d];if(p===0){if(d<e.length-1||d>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else if(typeof p=="string")a.appendChild(t.createTextNode(p));else{let{dom:h,contentDOM:g}=Xi(t,p,n,r);if(a.appendChild(h),g){if(l)throw new RangeError("Multiple content holes");l=g}}}return{dom:a,contentDOM:l}}const Uf=65535,qf=Math.pow(2,16);function sy(t,e){return t+e*qf}function ru(t){return t&Uf}function oy(t){return(t-(t&Uf))/qf}const Wf=1,Kf=2,Zi=4,Yf=8;class Bl{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&Yf)>0}get deletedBefore(){return(this.delInfo&(Wf|Zi))>0}get deletedAfter(){return(this.delInfo&(Kf|Zi))>0}get deletedAcross(){return(this.delInfo&Zi)>0}}class Je{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Je.empty)return Je.empty}recover(e){let n=0,r=ru(e);if(!this.inverted)for(let i=0;i<r;i++)n+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[r*3]+n+oy(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let i=0,s=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?i:0);if(a>e)break;let c=this.ranges[l+s],u=this.ranges[l+o],d=a+c;if(e<=d){let p=c?e==a?-1:e==d?1:n:n,h=a+i+(p<0?0:u);if(r)return h;let g=e==(n<0?a:d)?null:sy(l/3,e-a),b=0;return c&&(b|=e==a?Kf:e==d?Wf:Zi,(n<0?e!=a:e!=d)&&(b|=Yf)),new Bl(h,b,g)}i+=u-c}return r?e+i:new Bl(e+i,0,null)}touches(e,n){let r=0,i=ru(n),s=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+s],u=a+c;if(e<=u&&l==i*3)return!0;r+=this.ranges[l+o]-c}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,s=0;i<this.ranges.length;i+=3){let o=this.ranges[i],l=o-(this.inverted?s:0),a=o+(this.inverted?0:s),c=this.ranges[i+n],u=this.ranges[i+r];e(l,l+c,a,a+u),s+=u-c}}invert(){return new Je(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Je.empty:new Je(e<0?[0,-e,0]:[0,0,e])}}Je.empty=new Je([]);class ri{constructor(e,n,r=0,i=e?e.length:0){this.mirror=n,this.from=r,this.to=i,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new ri(this._maps,this.mirror,e,n)}appendMap(e,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(e){for(let n=0,r=this._maps.length;n<e._maps.length;n++){let i=e.getMirror(n);this.appendMap(e._maps[n],i!=null&&i<n?r+i:void 0)}}getMirror(e){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==e)return this.mirror[n+(n%2?-1:1)]}}setMirror(e,n){this.mirror||(this.mirror=[]),this.mirror.push(e,n)}appendMappingInverted(e){for(let n=e.maps.length-1,r=this._maps.length+e._maps.length;n>=0;n--){let i=e.getMirror(n);this.appendMap(e._maps[n].invert(),i!=null&&i>n?r-i-1:void 0)}}invert(){let e=new ri;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let i=0;for(let s=this.from;s<this.to;s++){let o=this._maps[s],l=o.mapResult(e,n);if(l.recover!=null){let a=this.getMirror(s);if(a!=null&&a>s&&a<this.to){s=a,e=this._maps[a].recover(l.recover);continue}}i|=l.delInfo,e=l.pos}return r?e:new Bl(e,i,null)}}const nl=Object.create(null);class ze{getMap(){return Je.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=nl[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in nl)throw new RangeError("Duplicate use of step JSON ID "+e);return nl[e]=n,n.prototype.jsonID=e,n}}class ke{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new ke(e,null)}static fail(e){return new ke(null,e)}static fromReplace(e,n,r,i){try{return ke.ok(e.replace(n,r,i))}catch(s){if(s instanceof ei)return ke.fail(s.message);throw s}}}function wa(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let s=t.child(i);s.content.size&&(s=s.copy(wa(s.content,e,s))),s.isInline&&(s=e(s,n,i)),r.push(s)}return I.fromArray(r)}class en extends ze{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),i=r.node(r.sharedDepth(this.to)),s=new _(wa(n.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),i),n.openStart,n.openEnd);return ke.fromReplace(e,this.from,this.to,s)}invert(){return new at(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new en(n.pos,r.pos,this.mark)}merge(e){return e instanceof en&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new en(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new en(n.from,n.to,e.markFromJSON(n.mark))}}ze.jsonID("addMark",en);class at extends ze{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new _(wa(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return ke.fromReplace(e,this.from,this.to,r)}invert(){return new en(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new at(n.pos,r.pos,this.mark)}merge(e){return e instanceof at&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new at(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new at(n.from,n.to,e.markFromJSON(n.mark))}}ze.jsonID("removeMark",at);class tn extends ze{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return ke.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return ke.fromReplace(e,this.pos,this.pos+1,new _(I.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let i=0;i<n.marks.length;i++)if(!n.marks[i].isInSet(r))return new tn(this.pos,n.marks[i]);return new tn(this.pos,this.mark)}}return new In(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new tn(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new tn(n.pos,e.markFromJSON(n.mark))}}ze.jsonID("addNodeMark",tn);class In extends ze{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return ke.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return ke.fromReplace(e,this.pos,this.pos+1,new _(I.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new tn(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new In(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new In(n.pos,e.markFromJSON(n.mark))}}ze.jsonID("removeNodeMark",In);class me extends ze{constructor(e,n,r,i=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=i}apply(e){return this.structure&&_l(e,this.from,this.to)?ke.fail("Structure replace would overwrite content"):ke.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Je([this.from,this.to-this.from,this.slice.size])}invert(e){return new me(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.to,-1),r=this.from==this.to&&me.MAP_BIAS<0?n:e.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new me(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(e){if(!(e instanceof me)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?_.empty:new _(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new me(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?_.empty:new _(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new me(e.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new me(n.from,n.to,_.fromJSON(e,n.slice),!!n.structure)}}me.MAP_BIAS=1;ze.jsonID("replace",me);class Te extends ze{constructor(e,n,r,i,s,o,l=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=i,this.slice=s,this.insert=o,this.structure=l}apply(e){if(this.structure&&(_l(e,this.from,this.gapFrom)||_l(e,this.gapTo,this.to)))return ke.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return ke.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?ke.fromReplace(e,this.from,this.to,r):ke.fail("Content does not fit in gap")}getMap(){return new Je([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new Te(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||s>r.pos?null:new Te(n.pos,r.pos,i,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Te(n.from,n.to,n.gapFrom,n.gapTo,_.fromJSON(e,n.slice),n.insert,!!n.structure)}}ze.jsonID("replaceAround",Te);function _l(t,e,n){let r=t.resolve(e),i=n-e,s=r.depth;for(;i>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,i--;if(i>0){let o=r.node(s).maybeChild(r.indexAfter(s));for(;i>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,i--}}return!1}function ly(t,e,n,r){let i=[],s=[],o,l;t.doc.nodesBetween(e,n,(a,c,u)=>{if(!a.isInline)return;let d=a.marks;if(!r.isInSet(d)&&u.type.allowsMarkType(r.type)){let p=Math.max(c,e),h=Math.min(c+a.nodeSize,n),g=r.addToSet(d);for(let b=0;b<d.length;b++)d[b].isInSet(g)||(o&&o.to==p&&o.mark.eq(d[b])?o.to=h:i.push(o=new at(p,h,d[b])));l&&l.to==p?l.to=h:s.push(l=new en(p,h,r))}}),i.forEach(a=>t.step(a)),s.forEach(a=>t.step(a))}function ay(t,e,n,r){let i=[],s=0;t.doc.nodesBetween(e,n,(o,l)=>{if(!o.isInline)return;s++;let a=null;if(r instanceof no){let c=o.marks,u;for(;u=r.isInSet(c);)(a||(a=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(o.marks)&&(a=[r]):a=o.marks;if(a&&a.length){let c=Math.min(l+o.nodeSize,n);for(let u=0;u<a.length;u++){let d=a[u],p;for(let h=0;h<i.length;h++){let g=i[h];g.step==s-1&&d.eq(i[h].style)&&(p=g)}p?(p.to=c,p.step=s):i.push({style:d,from:Math.max(l,e),to:c,step:s})}}}),i.forEach(o=>t.step(new at(o.from,o.to,o.style)))}function Ca(t,e,n,r=n.contentMatch,i=!0){let s=t.doc.nodeAt(e),o=[],l=e+1;for(let a=0;a<s.childCount;a++){let c=s.child(a),u=l+c.nodeSize,d=r.matchType(c.type);if(!d)o.push(new me(l,u,_.empty));else{r=d;for(let p=0;p<c.marks.length;p++)n.allowsMarkType(c.marks[p].type)||t.step(new at(l,u,c.marks[p]));if(i&&c.isText&&n.whitespace!="pre"){let p,h=/\r?\n|\r/g,g;for(;p=h.exec(c.text);)g||(g=new _(I.from(n.schema.text(" ",n.allowedMarks(c.marks))),0,0)),o.push(new me(l+p.index,l+p.index+p[0].length,g))}}l=u}if(!r.validEnd){let a=r.fillBefore(I.empty,!0);t.replace(l,l,new _(a,0,0))}for(let a=o.length-1;a>=0;a--)t.step(o[a])}function cy(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function pr(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,i=0,s=0;;--r){let o=t.$from.node(r),l=t.$from.index(r)+i,a=t.$to.indexAfter(r)-s;if(r<t.depth&&o.canReplace(l,a,n))return r;if(r==0||o.type.spec.isolating||!cy(o,l,a))break;l&&(i=1),a<o.childCount&&(s=1)}return null}function uy(t,e,n){let{$from:r,$to:i,depth:s}=e,o=r.before(s+1),l=i.after(s+1),a=o,c=l,u=I.empty,d=0;for(let g=s,b=!1;g>n;g--)b||r.index(g)>0?(b=!0,u=I.from(r.node(g).copy(u)),d++):a--;let p=I.empty,h=0;for(let g=s,b=!1;g>n;g--)b||i.after(g+1)<i.end(g)?(b=!0,p=I.from(i.node(g).copy(p)),h++):c++;t.step(new Te(a,c,o,l,new _(u.append(p),d,h),u.size-d,!0))}function va(t,e,n=null,r=t){let i=dy(t,e),s=i&&fy(r,e);return s?i.map(iu).concat({type:e,attrs:n}).concat(s.map(iu)):null}function iu(t){return{type:t,attrs:null}}function dy(t,e){let{parent:n,startIndex:r,endIndex:i}=t,s=n.contentMatchAt(r).findWrapping(e);if(!s)return null;let o=s.length?s[0]:e;return n.canReplaceWith(r,i,o)?s:null}function fy(t,e){let{parent:n,startIndex:r,endIndex:i}=t,s=n.child(r),o=e.contentMatch.findWrapping(s.type);if(!o)return null;let a=(o.length?o[o.length-1]:e).contentMatch;for(let c=r;a&&c<i;c++)a=a.matchType(n.child(c).type);return!a||!a.validEnd?null:o}function py(t,e,n){let r=I.empty;for(let o=n.length-1;o>=0;o--){if(r.size){let l=n[o].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=I.from(n[o].type.create(n[o].attrs,r))}let i=e.start,s=e.end;t.step(new Te(i,s,i,s,new _(r,0,0),n.length,!0))}function hy(t,e,n,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=t.steps.length;t.doc.nodesBetween(e,n,(o,l)=>{let a=typeof i=="function"?i(o):i;if(o.isTextblock&&!o.hasMarkup(r,a)&&my(t.doc,t.mapping.slice(s).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let h=r.whitespace=="pre",g=!!r.contentMatch.matchType(r.schema.linebreakReplacement);h&&!g?c=!1:!h&&g&&(c=!0)}c===!1&&Jf(t,o,l,s),Ca(t,t.mapping.slice(s).map(l,1),r,void 0,c===null);let u=t.mapping.slice(s),d=u.map(l,1),p=u.map(l+o.nodeSize,1);return t.step(new Te(d,p,d+1,p-1,new _(I.from(r.create(a,null,o.marks)),0,0),1,!0)),c===!0&&Gf(t,o,l,s),!1}})}function Gf(t,e,n,r){e.forEach((i,s)=>{if(i.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(i.text);){let a=t.mapping.slice(r).map(n+1+s+o.index);t.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Jf(t,e,n,r){e.forEach((i,s)=>{if(i.type==i.type.schema.linebreakReplacement){let o=t.mapping.slice(r).map(n+1+s);t.replaceWith(o,o+1,e.type.schema.text(`
49
+ `))}})}function my(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function gy(t,e,n,r,i){let s=t.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");n||(n=s.type);let o=n.create(r,null,i||s.marks);if(s.isLeaf)return t.replaceWith(e,e+s.nodeSize,o);if(!n.validContent(s.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new Te(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new _(I.from(o),0,0),1,!0))}function Pt(t,e,n=1,r){let i=t.resolve(e),s=i.depth-n,o=r&&r[r.length-1]||i.parent;if(s<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let c=i.depth-1,u=n-2;c>s;c--,u--){let d=i.node(c),p=i.index(c);if(d.type.spec.isolating)return!1;let h=d.content.cutByIndex(p,d.childCount),g=r&&r[u+1];g&&(h=h.replaceChild(0,g.type.create(g.attrs)));let b=r&&r[u]||d;if(!d.canReplace(p+1,d.childCount)||!b.type.validContent(h))return!1}let l=i.indexAfter(s),a=r&&r[0];return i.node(s).canReplaceWith(l,l,a?a.type:i.node(s+1).type)}function yy(t,e,n=1,r){let i=t.doc.resolve(e),s=I.empty,o=I.empty;for(let l=i.depth,a=i.depth-n,c=n-1;l>a;l--,c--){s=I.from(i.node(l).copy(s));let u=r&&r[c];o=I.from(u?u.type.create(u.attrs,o):i.node(l).copy(o))}t.step(new me(e,e,new _(s.append(o),n,n),!0))}function hn(t,e){let n=t.resolve(e),r=n.index();return Xf(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function by(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let i=0;i<e.childCount;i++){let s=e.child(i),o=s.type==r?t.type.schema.nodes.text:s.type;if(n=n.matchType(o),!n||!t.type.allowsMarks(s.marks))return!1}return n.validEnd}function Xf(t,e){return!!(t&&e&&!t.isLeaf&&by(t,e))}function ro(t,e,n=-1){let r=t.resolve(e);for(let i=r.depth;;i--){let s,o,l=r.index(i);if(i==r.depth?(s=r.nodeBefore,o=r.nodeAfter):n>0?(s=r.node(i+1),l++,o=r.node(i).maybeChild(l)):(s=r.node(i).maybeChild(l-1),o=r.node(i+1)),s&&!s.isTextblock&&Xf(s,o)&&r.node(i).canReplace(l,l+1))return e;if(i==0)break;e=n<0?r.before(i):r.after(i)}}function ky(t,e,n){let r=null,{linebreakReplacement:i}=t.doc.type.schema,s=t.doc.resolve(e-n),o=s.node().type;if(i&&o.inlineContent){let u=o.whitespace=="pre",d=!!o.contentMatch.matchType(i);u&&!d?r=!1:!u&&d&&(r=!0)}let l=t.steps.length;if(r===!1){let u=t.doc.resolve(e+n);Jf(t,u.node(),u.before(),l)}o.inlineContent&&Ca(t,e+n-1,o,s.node().contentMatchAt(s.index()),r==null);let a=t.mapping.slice(l),c=a.map(e-n);if(t.step(new me(c,a.map(e+n,-1),_.empty,!0)),r===!0){let u=t.doc.resolve(c);Gf(t,u.node(),u.before(),t.steps.length)}return t}function xy(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let s=r.index(i);if(r.node(i).canReplaceWith(s,s,n))return r.before(i+1);if(s>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let s=r.indexAfter(i);if(r.node(i).canReplaceWith(s,s,n))return r.after(i+1);if(s<r.node(i).childCount)return null}return null}function Zf(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let i=n.content;for(let s=0;s<n.openStart;s++)i=i.firstChild.content;for(let s=1;s<=(n.openStart==0&&n.size?2:1);s++)for(let o=r.depth;o>=0;o--){let l=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,a=r.index(o)+(l>0?1:0),c=r.node(o),u=!1;if(s==1)u=c.canReplace(a,a,i);else{let d=c.contentMatchAt(a).findWrapping(i.firstChild.type);u=d&&c.canReplaceWith(a,a,d[0])}if(u)return l==0?r.pos:l<0?r.before(o+1):r.after(o+1)}return null}function io(t,e,n=e,r=_.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),s=t.resolve(n);return Qf(i,s,r)?new me(e,n,r):new Sy(i,s,r).fit()}function Qf(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class Sy{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=I.empty;for(let i=0;i<=e.depth;i++){let s=e.node(i);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=I.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let s=this.placed,o=r.depth,l=i.depth;for(;o&&l&&s.childCount==1;)s=s.firstChild.content,o--,l--;let a=new _(s,o,l);return e>-1?new Te(r.pos,e,this.$to.pos,this.$to.end(),a,n):a.size||r.pos!=this.$to.pos?new me(r.pos,i.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<e;r++){let s=n.firstChild;if(n.childCount>1&&(i=0),s.type.spec.isolating&&i<=r){e=r;break}n=s.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let i,s=null;r?(s=su(this.unplaced.content,r-1).firstChild,i=s.content):i=this.unplaced.content;let o=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],u,d=null;if(n==1&&(o?c.matchType(o.type)||(d=c.fillBefore(I.from(o),!1)):s&&a.compatibleContent(s.type)))return{sliceDepth:r,frontierDepth:l,parent:s,inject:d};if(n==2&&o&&(u=c.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:l,parent:s,wrap:u};if(s&&c.matchType(s.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced;return ou(e,-1)<=n?!1:(this.unplaced.size>1&&ou(e,1)>r&&r++,this.unplaced=new _(e,n+1,r),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=su(e,n);if(i.childCount<=1&&n>0){let s=e.size-n<=n+i.size;this.unplaced=new _(Lr(e,n-1,1),n-1,s?n-1:r)}else this.unplaced=new _(Lr(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:i,wrap:s}){for(;this.depth>n;)this.closeFrontierNode();if(s)for(let b=0;b<s.length;b++)this.openFrontierNode(s[b]);let o=this.unplaced,l=r?r.content:o.content,a=o.openStart-e,c=0,u=[],{match:d,type:p}=this.frontier[n];if(i){for(let b=0;b<i.childCount;b++)u.push(i.child(b));d=d.matchFragment(i)}let h=l.size+e-(o.content.size-o.openEnd);for(;c<l.childCount;){let b=l.child(c),x=d.matchType(b.type);if(!x)break;c++,(c>1||a==0||b.content.size)&&(d=x,u.push(ep(b.mark(p.allowedMarks(b.marks)),c==1?a:0,c==l.childCount?h:-1)))}let g=c==l.childCount;g||(h=-1),this.placed=Ir(this.placed,n,I.from(u)),this.frontier[n].match=d,g&&h<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let b=0,x=l;b<h;b++){let w=x.lastChild;this.frontier.push({type:w.type,match:w.contentMatchAt(w.childCount)}),x=w.content}this.unplaced=g?e==0?_.empty:new _(Lr(o.content,e-1,1),e-1,h<0?o.openEnd:e-1):new _(Lr(o.content,e,c),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!rl(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.depth==this.depth)return-1;let{depth:r}=this.$to,i=this.$to.after(r);for(;r>1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:i}=this.frontier[n],s=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),o=rl(e,n,i,r,s);if(o){for(let l=n-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],u=rl(e,l,c,a,!0);if(!u||u.childCount)continue e}return{depth:n,fit:o,move:s?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=Ir(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let i=e.node(r),s=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,s)}return e}openFrontierNode(e,n=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=Ir(this.placed,this.depth,I.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(I.empty,!0);n.childCount&&(this.placed=Ir(this.placed,this.frontier.length,n))}}function Lr(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Lr(t.firstChild.content,e-1,n)))}function Ir(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Ir(t.lastChild.content,e-1,n)))}function su(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function ep(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,ep(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(I.empty,!0)))),t.copy(r)}function rl(t,e,n,r,i){let s=t.node(e),o=i?t.indexAfter(e):t.index(e);if(o==s.childCount&&!n.compatibleContent(s.type))return null;let l=r.fillBefore(s.content,!0,o);return l&&!wy(n,s.content,o)?l:null}function wy(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function Cy(t){return t.spec.defining||t.spec.definingForContent}function ou(t,e){for(let n=0;;n++){let r=e<0?t.firstChild:t.lastChild;if(!r||r.isAtom)return n;t=r.content}}function vy(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let i=t.doc.resolve(e),s=t.doc.resolve(n);if(Qf(i,s,r))return t.step(new me(e,n,r));let o=np(i,s);o[o.length-1]==0&&o.pop();let l=-(i.depth+1);o.unshift(l);for(let p=i.depth,h=i.pos-1;p>0;p--,h--){let g=i.node(p).type.spec;if(g.defining||g.definingAsContext||g.isolating)break;o.indexOf(p)>-1?l=p:i.before(p)==h&&o.splice(1,0,-p)}let a=o.indexOf(l),c=[],u=r.openStart;for(let p=r.content,h=0;;h++){let g=p.firstChild;if(c.push(g),h==r.openStart)break;p=g.content}for(let p=u-1;p>=0;p--){let h=c[p],g=Cy(h.type);if(g&&!h.sameMarkup(i.node(Math.abs(l)-1)))u=p;else if(g||!h.type.isTextblock)break}for(let p=r.openStart;p>=0;p--){let h=(p+u+1)%(r.openStart+1),g=c[h];if(g)for(let b=0;b<o.length;b++){let x=o[(b+a)%o.length],w=!0;x<0&&(w=!1,x=-x);let A=i.node(x-1),R=i.index(x-1);if(A.canReplaceWith(R,R,g.type,g.marks))return t.replace(i.before(x),w?s.after(x):n,new _(tp(r.content,0,r.openStart,h),h,r.openEnd))}}let d=t.steps.length;for(let p=o.length-1;p>=0&&(t.replace(e,n,r),!(t.steps.length>d));p--){let h=o[p];h<0||(e=i.before(h),n=s.after(h))}}function tp(t,e,n,r,i){if(e<n){let s=t.firstChild;t=t.replaceChild(0,s.copy(tp(s.content,e+1,n,r,s)))}if(e>r){let s=i.contentMatchAt(0),o=s.fillBefore(t).append(t);t=o.append(s.matchFragment(o).fillBefore(I.empty,!0))}return t}function My(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=xy(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new _(I.from(r),0,0))}function Ty(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n);if(r.parent.isTextblock&&i.parent.isTextblock&&r.start()!=i.start()&&r.parentOffset==0&&i.parentOffset==0){let o=r.sharedDepth(n),l=!1;for(let a=r.depth;a>o;a--)r.node(a).type.spec.isolating&&(l=!0);for(let a=i.depth;a>o;a--)i.node(a).type.spec.isolating&&(l=!0);if(!l){for(let a=r.depth;a>0&&e==r.start(a);a--)e=r.before(a);for(let a=i.depth;a>0&&n==i.start(a);a--)n=i.before(a);r=t.doc.resolve(e),i=t.doc.resolve(n)}}let s=np(r,i);for(let o=0;o<s.length;o++){let l=s[o],a=o==s.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return t.delete(r.start(l),i.end(l));if(l>0&&(a||r.node(l-1).canReplace(r.index(l-1),i.indexAfter(l-1))))return t.delete(r.before(l),i.after(l))}for(let o=1;o<=r.depth&&o<=i.depth;o++)if(e-r.start(o)==r.depth-o&&n>r.end(o)&&i.end(o)-n!=i.depth-o&&r.start(o-1)==i.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),i.index(o-1)))return t.delete(r.before(o),n);t.delete(e,n)}function np(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let i=r;i>=0;i--){let s=t.start(i);if(s<t.pos-(t.depth-i)||e.end(i)>e.pos+(e.depth-i)||t.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(s==e.start(i)||i==t.depth&&i==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==s-1)&&n.push(i)}return n}class Qn extends ze{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return ke.fail("No node at attribute step's position");let r=Object.create(null);for(let s in n.attrs)r[s]=n.attrs[s];r[this.attr]=this.value;let i=n.type.create(r,null,n.marks);return ke.fromReplace(e,this.pos,this.pos+1,new _(I.from(i),0,n.isLeaf?0:1))}getMap(){return Je.empty}invert(e){return new Qn(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Qn(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Qn(n.pos,n.attr,n.value)}}ze.jsonID("attr",Qn);class ii extends ze{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let i in e.attrs)n[i]=e.attrs[i];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return ke.ok(r)}getMap(){return Je.empty}invert(e){return new ii(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new ii(n.attr,n.value)}}ze.jsonID("docAttr",ii);let rr=class extends Error{};rr=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};rr.prototype=Object.create(Error.prototype);rr.prototype.constructor=rr;rr.prototype.name="TransformError";class rp{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new ri}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new rr(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,n=-1e9;for(let r=0;r<this.mapping.maps.length;r++){let i=this.mapping.maps[r];r&&(e=i.map(e,1),n=i.map(n,-1)),i.forEach((s,o,l,a)=>{e=Math.min(e,l),n=Math.max(n,a)})}return e==1e9?null:{from:e,to:n}}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=_.empty){let i=io(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new _(I.from(r),0,0))}delete(e,n){return this.replace(e,n,_.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return vy(this,e,n,r),this}replaceRangeWith(e,n,r){return My(this,e,n,r),this}deleteRange(e,n){return Ty(this,e,n),this}lift(e,n){return uy(this,e,n),this}join(e,n=1){return ky(this,e,n),this}wrap(e,n){return py(this,e,n),this}setBlockType(e,n=e,r,i=null){return hy(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return gy(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new Qn(e,n,r)),this}setDocAttribute(e,n){return this.step(new ii(e,n)),this}addNodeMark(e,n){return this.step(new tn(e,n)),this}removeNodeMark(e,n){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n instanceof ue)n.isInSet(r.marks)&&this.step(new In(e,n));else{let i=r.marks,s,o=[];for(;s=n.isInSet(i);)o.push(new In(e,s)),i=s.removeFromSet(i);for(let l=o.length-1;l>=0;l--)this.step(o[l])}return this}split(e,n=1,r){return yy(this,e,n,r),this}addMark(e,n,r){return ly(this,e,n,r),this}removeMark(e,n,r){return ay(this,e,n,r),this}clearIncompatible(e,n,r){return Ca(this,e,n,r),this}}const il=Object.create(null);class J{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new Ay(e.min(n),e.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let n=0;n<e.length;n++)if(e[n].$from.pos!=e[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,n=_.empty){let r=n.content.lastChild,i=null;for(let l=0;l<n.openEnd;l++)i=r,r=r.lastChild;let s=e.steps.length,o=this.ranges;for(let l=0;l<o.length;l++){let{$from:a,$to:c}=o[l],u=e.mapping.slice(s);e.replaceRange(u.map(a.pos),u.map(c.pos),l?_.empty:n),l==0&&cu(e,s,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){let{$from:o,$to:l}=i[s],a=e.mapping.slice(r),c=a.map(o.pos),u=a.map(l.pos);s?e.deleteRange(c,u):(e.replaceRangeWith(c,u,n),cu(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let i=e.parent.inlineContent?new q(e):Yn(e.node(0),e.parent,e.pos,e.index(),n,r);if(i)return i;for(let s=e.depth-1;s>=0;s--){let o=n<0?Yn(e.node(0),e.node(s),e.before(s+1),e.index(s),n,r):Yn(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,n,r);if(o)return o}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new Xe(e.node(0))}static atStart(e){return Yn(e,e,0,0,1)||new Xe(e)}static atEnd(e){return Yn(e,e,e.content.size,e.childCount,-1)||new Xe(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=il[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in il)throw new RangeError("Duplicate use of selection JSON ID "+e);return il[e]=n,n.prototype.jsonID=e,n}getBookmark(){return q.between(this.$anchor,this.$head).getBookmark()}}J.prototype.visible=!0;class Ay{constructor(e,n){this.$from=e,this.$to=n}}let lu=!1;function au(t){!lu&&!t.parent.inlineContent&&(lu=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class q extends J{constructor(e,n=e){au(e),au(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return J.near(r);let i=e.resolve(n.map(this.anchor));return new q(i.parent.inlineContent?i:r,r)}replace(e,n=_.empty){if(super.replace(e,n),n==_.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof q&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new so(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new q(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let i=e.resolve(n);return new this(i,r==n?i:e.resolve(r))}static between(e,n,r){let i=e.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let s=J.findFrom(n,r,!0)||J.findFrom(n,-r,!0);if(s)n=s.$head;else return J.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(J.findFrom(e,-r,!0)||J.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=i<0&&(e=n))),new q(e,n)}}J.jsonID("text",q);class so{constructor(e,n){this.anchor=e,this.head=n}map(e){return new so(e.map(this.anchor),e.map(this.head))}resolve(e){return q.between(e.resolve(this.anchor),e.resolve(this.head))}}class U extends J{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:i}=n.mapResult(this.anchor),s=e.resolve(i);return r?J.near(s):new U(s)}content(){return new _(I.from(this.node),0,0)}eq(e){return e instanceof U&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Ma(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new U(e.resolve(n.anchor))}static create(e,n){return new U(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}U.prototype.visible=!1;J.jsonID("node",U);class Ma{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new so(r,r):new Ma(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&U.isSelectable(r)?new U(n):J.near(n)}}class Xe extends J{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=_.empty){if(n==_.empty){e.delete(0,e.doc.content.size);let r=J.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new Xe(e)}map(e){return new Xe(e)}eq(e){return e instanceof Xe}getBookmark(){return Ey}}J.jsonID("all",Xe);const Ey={map(){return this},resolve(t){return new Xe(t)}};function Yn(t,e,n,r,i,s=!1){if(e.inlineContent)return q.create(t,n);for(let o=r-(i>0?0:1);i>0?o<e.childCount:o>=0;o+=i){let l=e.child(o);if(l.isAtom){if(!s&&U.isSelectable(l))return U.create(t,n-(i<0?l.nodeSize:0))}else{let a=Yn(t,l,n+i,i<0?l.childCount:0,i,s);if(a)return a}n+=l.nodeSize*i}return null}function cu(t,e,n){let r=t.steps.length-1;if(r<e)return;let i=t.steps[r];if(!(i instanceof me||i instanceof Te))return;let s=t.mapping.maps[r],o;s.forEach((l,a,c,u)=>{o==null&&(o=u)}),t.setSelection(J.near(t.doc.resolve(o),n))}const uu=1,zi=2,du=4;class Ny extends rp{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|uu)&~zi,this.storedMarks=null,this}get selectionSet(){return(this.updated&uu)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=zi,this}ensureMarks(e){return ue.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&zi)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~zi,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||ue.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let i=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let s=this.storedMarks;if(!s){let o=this.doc.resolve(n);s=r==n?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,i.text(e,s)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(J.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=du,this}get scrolledIntoView(){return(this.updated&du)>0}}function fu(t,e){return!e||!t?t:t.bind(e)}class Rr{constructor(e,n,r){this.name=e,this.init=fu(n.init,r),this.apply=fu(n.apply,r)}}const Oy=[new Rr("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Rr("selection",{init(t,e){return t.selection||J.atStart(e.doc)},apply(t){return t.selection}}),new Rr("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Rr("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class sl{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Oy.slice(),n&&n.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Rr(r.key,r.spec.state,r))})}}class Ot{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=n){let i=this.config.plugins[r];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],r=this.applyInner(e),i=null;for(;;){let s=!1;for(let o=0;o<this.config.plugins.length;o++){let l=this.config.plugins[o];if(l.spec.appendTransaction){let a=i?i[o].n:0,c=i?i[o].state:this,u=a<n.length&&l.spec.appendTransaction.call(l,a?n.slice(a):n,c,r);if(u&&r.filterTransaction(u,o)){if(u.setMeta("appendedTransaction",e),!i){i=[];for(let d=0;d<this.config.plugins.length;d++)i.push(d<o?{state:r,n:n.length}:{state:this,n:0})}n.push(u),r=r.applyInner(u),s=!0}i&&(i[o]={state:r,n:n.length})}}if(!s)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new Ot(this.config),r=this.config.fields;for(let i=0;i<r.length;i++){let s=r[i];n[s.name]=s.apply(e,this[s.name],this,n)}return n}get tr(){return new Ny(this)}static create(e){let n=new sl(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new Ot(n);for(let i=0;i<n.fields.length;i++)r[n.fields[i].name]=n.fields[i].init(e,r);return r}reconfigure(e){let n=new sl(this.schema,e.plugins),r=n.fields,i=new Ot(n);for(let s=0;s<r.length;s++){let o=r[s].name;i[o]=this.hasOwnProperty(o)?this[o]:r[s].init(e,i)}return i}toJSON(e){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],s=i.spec.state;s&&s.toJSON&&(n[r]=s.toJSON.call(i,this[i.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new sl(e.schema,e.plugins),s=new Ot(i);return i.fields.forEach(o=>{if(o.name=="doc")s.doc=En.fromJSON(e.schema,n.doc);else if(o.name=="selection")s.selection=J.fromJSON(s.doc,n.selection);else if(o.name=="storedMarks")n.storedMarks&&(s.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==o.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(n,l)){s[o.name]=c.fromJSON.call(a,e,n[l],s);return}}s[o.name]=o.init(e,s)}}),s}}function ip(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=ip(i,e,{})),n[r]=i}return n}class fe{constructor(e){this.spec=e,this.props={},e.props&&ip(e.props,this,this.props),this.key=e.key?e.key.key:sp("plugin")}getState(e){return e[this.key]}}const ol=Object.create(null);function sp(t){return t in ol?t+"$"+ ++ol[t]:(ol[t]=0,t+"$")}class xe{constructor(e="key"){this.key=sp(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const op=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function lp(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const ap=(t,e,n)=>{let r=lp(t,n);if(!r)return!1;let i=Ta(r);if(!i){let o=r.blockRange(),l=o&&pr(o);return l==null?!1:(e&&e(t.tr.lift(o,l).scrollIntoView()),!0)}let s=i.nodeBefore;if(yp(t,i,e,-1))return!0;if(r.parent.content.size==0&&(ir(s,"end")||U.isSelectable(s)))for(let o=r.depth;;o--){let l=io(t.doc,r.before(o),r.after(o),_.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=t.tr.step(l);a.setSelection(ir(s,"end")?J.findFrom(a.doc.resolve(a.mapping.map(i.pos,-1)),-1):U.create(a.doc,i.pos-s.nodeSize)),e(a.scrollIntoView())}return!0}if(o==1||r.node(o-1).childCount>1)break}return s.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView()),!0):!1},Ly=(t,e,n)=>{let r=lp(t,n);if(!r)return!1;let i=Ta(r);return i?cp(t,i,e):!1},Iy=(t,e,n)=>{let r=dp(t,n);if(!r)return!1;let i=Aa(r);return i?cp(t,i,e):!1};function cp(t,e,n){let r=e.nodeBefore,i=r,s=e.pos-1;for(;!i.isTextblock;s--){if(i.type.spec.isolating)return!1;let u=i.lastChild;if(!u)return!1;i=u}let o=e.nodeAfter,l=o,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let u=l.firstChild;if(!u)return!1;l=u}let c=io(t.doc,s,a,_.empty);if(!c||c.from!=s||c instanceof me&&c.slice.size>=a-s)return!1;if(n){let u=t.tr.step(c);u.setSelection(q.create(u.doc,s)),n(u.scrollIntoView())}return!0}function ir(t,e,n=!1){for(let r=t;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}const up=(t,e,n)=>{let{$head:r,empty:i}=t.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;s=Ta(r)}let o=s&&s.nodeBefore;return!o||!U.isSelectable(o)?!1:(e&&e(t.tr.setSelection(U.create(t.doc,s.pos-o.nodeSize)).scrollIntoView()),!0)};function Ta(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 dp(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const fp=(t,e,n)=>{let r=dp(t,n);if(!r)return!1;let i=Aa(r);if(!i)return!1;let s=i.nodeAfter;if(yp(t,i,e,1))return!0;if(r.parent.content.size==0&&(ir(s,"start")||U.isSelectable(s))){let o=io(t.doc,r.before(),r.after(),_.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=t.tr.step(o);l.setSelection(ir(s,"start")?J.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):U.create(l.doc,l.mapping.map(i.pos))),e(l.scrollIntoView())}return!0}}return s.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos,i.pos+s.nodeSize).scrollIntoView()),!0):!1},pp=(t,e,n)=>{let{$head:r,empty:i}=t.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;s=Aa(r)}let o=s&&s.nodeAfter;return!o||!U.isSelectable(o)?!1:(e&&e(t.tr.setSelection(U.create(t.doc,s.pos)).scrollIntoView()),!0)};function Aa(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let n=t.node(e);if(t.index(e)+1<n.childCount)return t.doc.resolve(t.after(e+1));if(n.type.spec.isolating)break}return null}const Ry=(t,e)=>{let n=t.selection,r=n instanceof U,i;if(r){if(n.node.isTextblock||!hn(t.doc,n.from))return!1;i=n.from}else if(i=ro(t.doc,n.from,-1),i==null)return!1;if(e){let s=t.tr.join(i);r&&s.setSelection(U.create(s.doc,i-t.doc.resolve(i).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},Dy=(t,e)=>{let n=t.selection,r;if(n instanceof U){if(n.node.isTextblock||!hn(t.doc,n.to))return!1;r=n.to}else if(r=ro(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},Py=(t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),s=i&&pr(i);return s==null?!1:(e&&e(t.tr.lift(i,s).scrollIntoView()),!0)},hp=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
50
+ `).scrollIntoView()),!0)};function Ea(t){for(let e=0;e<t.edgeCount;e++){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}const $y=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),s=n.indexAfter(-1),o=Ea(i.contentMatchAt(s));if(!o||!i.canReplaceWith(s,s,o))return!1;if(e){let l=n.after(),a=t.tr.replaceWith(l,l,o.createAndFill());a.setSelection(J.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},mp=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof Xe||r.parent.inlineContent||i.parent.inlineContent)return!1;let s=Ea(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let o=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,l=t.tr.insert(o,s.createAndFill());l.setSelection(q.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},gp=(t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let s=n.before();if(Pt(t.doc,s))return e&&e(t.tr.split(s).scrollIntoView()),!0}let r=n.blockRange(),i=r&&pr(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)};function By(t){return(e,n)=>{if(e.selection instanceof U&&e.selection.node.isBlock){let{$from:h}=e.selection;return!h.parentOffset||!Pt(e.doc,h.pos)?!1:(n&&n(e.tr.split(h.pos).scrollIntoView()),!0)}if(!e.selection.$from.depth)return!1;let r=e.tr;!e.selection.empty&&(e.selection instanceof q||e.selection instanceof Xe)&&r.deleteSelection();let{$from:i}=r.selection,s=r.steps.length,o=[],l,a,c=!1,u=!1;for(let h=i.depth;;h--)if(i.node(h).isBlock){c=i.end(h)==i.pos+(i.depth-h),u=i.start(h)==i.pos-(i.depth-h),a=Ea(i.node(h-1).contentMatchAt(i.indexAfter(h-1))),o.unshift(c&&a?{type:a}:null),l=h;break}else{if(h==1)return!1;o.unshift(null)}let d=i.pos,p=Pt(r.doc,d,o.length,o);if(p||(o[0]=a?{type:a}:null,p=Pt(r.doc,d,o.length,o)),!p)return!1;if(r.split(d,o.length,o),!c&&u&&i.node(l).type!=a){let h=r.mapping.slice(s),g=h.map(i.before(l)),b=r.doc.resolve(g);a&&i.node(l-1).canReplaceWith(b.index(),b.index()+1,a)&&r.setNodeMarkup(h.map(i.before(l)),a)}return n&&n(r.scrollIntoView()),!0}}const _y=By(),zy=(t,e)=>{let{$from:n,to:r}=t.selection,i,s=n.sharedDepth(r);return s==0?!1:(i=n.before(s),e&&e(t.tr.setSelection(U.create(t.doc,i))),!0)};function Fy(t,e,n){let r=e.nodeBefore,i=e.nodeAfter,s=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(s-1,s)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(i.isTextblock||hn(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function yp(t,e,n,r){let i=e.nodeBefore,s=e.nodeAfter,o,l,a=i.type.spec.isolating||s.type.spec.isolating;if(!a&&Fy(t,e,n))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(o=(l=i.contentMatchAt(i.childCount)).findWrapping(s.type))&&l.matchType(o[0]||s.type).validEnd){if(n){let h=e.pos+s.nodeSize,g=I.empty;for(let w=o.length-1;w>=0;w--)g=I.from(o[w].create(null,g));g=I.from(i.copy(g));let b=t.tr.step(new Te(e.pos-1,h,e.pos,h,new _(g,1,0),o.length,!0)),x=b.doc.resolve(h+2*o.length);x.nodeAfter&&x.nodeAfter.type==i.type&&hn(b.doc,x.pos)&&b.join(x.pos),n(b.scrollIntoView())}return!0}let u=s.type.spec.isolating||r>0&&a?null:J.findFrom(e,1),d=u&&u.$from.blockRange(u.$to),p=d&&pr(d);if(p!=null&&p>=e.depth)return n&&n(t.tr.lift(d,p).scrollIntoView()),!0;if(c&&ir(s,"start",!0)&&ir(i,"end")){let h=i,g=[];for(;g.push(h),!h.isTextblock;)h=h.lastChild;let b=s,x=1;for(;!b.isTextblock;b=b.firstChild)x++;if(h.canReplace(h.childCount,h.childCount,b.content)){if(n){let w=I.empty;for(let R=g.length-1;R>=0;R--)w=I.from(g[R].copy(w));let A=t.tr.step(new Te(e.pos-g.length,e.pos+s.nodeSize,e.pos+x,e.pos+s.nodeSize-x,new _(w,g.length,0),0,!0));n(A.scrollIntoView())}return!0}}return!1}function bp(t){return function(e,n){let r=e.selection,i=t<0?r.$from:r.$to,s=i.depth;for(;i.node(s).isInline;){if(!s)return!1;s--}return i.node(s).isTextblock?(n&&n(e.tr.setSelection(q.create(e.doc,t<0?i.start(s):i.end(s)))),!0):!1}}const Hy=bp(-1),jy=bp(1);function Vy(t,e=null){return function(n,r){let{$from:i,$to:s}=n.selection,o=i.blockRange(s),l=o&&va(o,t,e);return l?(r&&r(n.tr.wrap(o,l).scrollIntoView()),!0):!1}}function pu(t,e=null){return function(n,r){let i=!1;for(let s=0;s<n.selection.ranges.length&&!i;s++){let{$from:{pos:o},$to:{pos:l}}=n.selection.ranges[s];n.doc.nodesBetween(o,l,(a,c)=>{if(i)return!1;if(!(!a.isTextblock||a.hasMarkup(t,e)))if(a.type==t)i=!0;else{let u=n.doc.resolve(c),d=u.index();i=u.parent.canReplaceWith(d,d+1,t)}})}if(!i)return!1;if(r){let s=n.tr;for(let o=0;o<n.selection.ranges.length;o++){let{$from:{pos:l},$to:{pos:a}}=n.selection.ranges[o];s.setBlockType(l,a,t,e)}r(s.scrollIntoView())}return!0}}function Na(...t){return function(e,n,r){for(let i=0;i<t.length;i++)if(t[i](e,n,r))return!0;return!1}}Na(op,ap,up);Na(op,fp,pp);Na(hp,mp,gp,_y);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function Uy(t,e=null){return function(n,r){let{$from:i,$to:s}=n.selection,o=i.blockRange(s);if(!o)return!1;let l=r?n.tr:null;return qy(l,o,t,e)?(r&&r(l.scrollIntoView()),!0):!1}}function qy(t,e,n,r=null){let i=!1,s=e,o=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=o.resolve(e.start-2);s=new as(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new as(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let l=va(s,n,r,e);return l?(t&&Wy(t,e,l,i,n),!0):!1}function Wy(t,e,n,r,i){let s=I.empty;for(let u=n.length-1;u>=0;u--)s=I.from(n[u].type.create(n[u].attrs,s));t.step(new Te(e.start-(r?2:0),e.end,e.start,e.end,new _(s,0,0),n.length,!0));let o=0;for(let u=0;u<n.length;u++)n[u].type==i&&(o=u+1);let l=n.length-o,a=e.start+n.length-(r?2:0),c=e.parent;for(let u=e.startIndex,d=e.endIndex,p=!0;u<d;u++,p=!1)!p&&Pt(t.doc,a,l)&&(t.split(a,l),a+=2*l),a+=c.child(u).nodeSize;return t}function Ky(t){return function(e,n){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,o=>o.childCount>0&&o.firstChild.type==t);return s?n?r.node(s.depth-1).type==t?Yy(e,n,t,s):Gy(e,n,s):!0:!1}}function Yy(t,e,n,r){let i=t.tr,s=r.end,o=r.$to.end(r.depth);s<o&&(i.step(new Te(s-1,o,s,o,new _(I.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new as(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth));const l=pr(r);if(l==null)return!1;i.lift(r,l);let a=i.doc.resolve(i.mapping.map(s,-1)-1);return hn(i.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&i.join(a.pos),e(i.scrollIntoView()),!0}function Gy(t,e,n){let r=t.tr,i=n.parent;for(let h=n.end,g=n.endIndex-1,b=n.startIndex;g>b;g--)h-=i.child(g).nodeSize,r.delete(h-1,h+1);let s=r.doc.resolve(n.start),o=s.nodeAfter;if(r.mapping.map(n.end)!=n.start+s.nodeAfter.nodeSize)return!1;let l=n.startIndex==0,a=n.endIndex==i.childCount,c=s.node(-1),u=s.index(-1);if(!c.canReplace(u+(l?0:1),u+1,o.content.append(a?I.empty:I.from(i))))return!1;let d=s.pos,p=d+o.nodeSize;return r.step(new Te(d-(l?1:0),p+(a?1:0),d+1,p-1,new _((l?I.empty:I.from(i.copy(I.empty))).append(a?I.empty:I.from(i.copy(I.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function Jy(t){return function(e,n){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,c=>c.childCount>0&&c.firstChild.type==t);if(!s)return!1;let o=s.startIndex;if(o==0)return!1;let l=s.parent,a=l.child(o-1);if(a.type!=t)return!1;if(n){let c=a.lastChild&&a.lastChild.type==l.type,u=I.from(c?t.create():null),d=new _(I.from(t.create(null,I.from(l.type.create(null,u)))),c?3:1,0),p=s.start,h=s.end;n(e.tr.step(new Te(p-(c?3:1),h,p,h,d,1,!0)).scrollIntoView())}return!0}}const Oe=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},sr=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let zl=null;const Et=function(t,e,n){let r=zl||(zl=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},Xy=function(){zl=null},Rn=function(t,e,n,r){return n&&(hu(t,e,n,r,-1)||hu(t,e,n,r,1))},Zy=/^(img|br|input|textarea|hr)$/i;function hu(t,e,n,r,i){for(var s;;){if(t==n&&e==r)return!0;if(e==(i<0?0:Be(t))){let o=t.parentNode;if(!o||!V(o)||hi(t)||Zy.test(t.nodeName)||t.contentEditable=="false")return!1;e=Oe(t)+(i<0?0:1),t=o}else if(V(t)){let o=t.childNodes[e+(i<0?-1:0)];if(V(o)&&o.contentEditable=="false")if(!((s=o.pmViewDesc)===null||s===void 0)&&s.ignoreForSelection)e+=i;else return!1;else t=o,e=i<0?Be(t):0}else return!1}}function Be(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function V(t){return t.nodeType==1}function we(t){return t.nodeType==3}function Dn(t,e){return e?t.contains(V(e)?e:e.parentNode):!1}function Qy(t,e){for(;;){if(we(t)&&e)return t;if(V(t)&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1],e=Be(t)}else if(t.parentNode&&!hi(t))e=Oe(t),t=t.parentNode;else return null}}function eb(t,e){for(;;){if(we(t)&&e<t.nodeValue.length)return t;if(V(t)&&e<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[e],e=0}else if(t.parentNode&&!hi(t))e=Oe(t)+1,t=t.parentNode;else return null}}function tb(t,e,n){for(let r=e==0,i=e==Be(t);r||i;){if(t==n)return!0;let s=Oe(t);if(t=t.parentNode,!t)return!1;r=r&&s==0,i=i&&s==Be(t)}}function hi(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const oo=function(t){return t.focusNode&&Rn(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function xn(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function nb(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function rb(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(Be(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(Be(r.startContainer),r.startOffset)}}}const xt=typeof navigator<"u"?navigator:null,mu=typeof document<"u"?document:null,mn=xt&&xt.userAgent||"",Fl=/Edge\/(\d+)/.exec(mn),kp=/MSIE \d/.exec(mn),Hl=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(mn),Ke=!!(kp||Hl||Fl),rn=kp?document.documentMode:Hl?+Hl[1]:Fl?+Fl[1]:0,Ze=!Ke&&/gecko\/(\d+)/i.test(mn);Ze&&+(/Firefox\/(\d+)/.exec(mn)||[0,0])[1];const jl=!Ke&&/Chrome\/(\d+)/.exec(mn),Re=!!jl,xp=jl?+jl[1]:0,_e=!Ke&&!!xt&&/Apple Computer/.test(xt.vendor),or=_e&&(/Mobile\/\w+/.test(mn)||!!xt&&xt.maxTouchPoints>2),it=or||(xt?/Mac/.test(xt.platform):!1),Sp=xt?/Win/.test(xt.platform):!1,Lt=/Android \d/.test(mn),lo=!!mu&&"webkitFontSmoothing"in mu.documentElement.style,ib=lo?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function sb(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function Ct(t,e){return typeof t=="number"?t:t[e]}function ob(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function gu(t,e,n){if(!Vl(e)&&e.left==0)return;let r=t.someProp("scrollThreshold")||0,i=t.someProp("scrollMargin")||5,s=t.dom.ownerDocument;for(let o=n||t.dom;o;){if(!V(o)){o=sr(o);continue}let l=o==s.body,a=l?sb(s):ob(o),c=0,u=0;if(e.top<a.top+Ct(r,"top")?u=-(a.top-e.top+Ct(i,"top")):e.bottom>a.bottom-Ct(r,"bottom")&&(u=e.bottom-e.top>a.bottom-a.top?e.top+Ct(i,"top")-a.top:e.bottom-a.bottom+Ct(i,"bottom")),e.left<a.left+Ct(r,"left")?c=-(a.left-e.left+Ct(i,"left")):e.right>a.right-Ct(r,"right")&&(c=e.right-a.right+Ct(i,"right")),c||u)if(l)s.defaultView.scrollBy(c,u);else{let p=o.scrollLeft,h=o.scrollTop;u&&(o.scrollTop+=u),c&&(o.scrollLeft+=c);let g=o.scrollLeft-p,b=o.scrollTop-h;e={left:e.left-g,top:e.top-b,right:e.right-g,bottom:e.bottom-b}}let d=l?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(d))break;o=d=="absolute"?o.offsetParent:sr(o)}}function lb(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,i;for(let s=(e.left+e.right)/2,o=n+1;o<Math.min(innerHeight,e.bottom);o+=5){let l=t.root.elementFromPoint(s,o);if(!l||l==t.dom||!t.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=n-20){r=l,i=a.top;break}}return{refDOM:r,refTop:i,stack:wp(t.dom)}}function wp(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=sr(r));return e}function ab({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;Cp(n,r==0?0:r-e)}function Cp(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:i,left:s}=t[n];r.scrollTop!=i+e&&(r.scrollTop=i+e),r.scrollLeft!=s&&(r.scrollLeft=s)}}let Vn=null;function cb(t){if(t.setActive)return t.setActive();if(Vn)return t.focus(Vn);let e=wp(t);t.focus(Vn==null?{get preventScroll(){return Vn={preventScroll:!0},!0}}:void 0),Vn||(Vn=!1,Cp(e,0))}function vp(t,e){let n,r=2e8,i,s=0,o=e.top,l=e.top,a,c;for(let u=t.firstChild,d=0;u;u=u.nextSibling,d++){let p;if(V(u))p=u.getClientRects();else if(we(u))p=Et(u).getClientRects();else continue;for(let h=0;h<p.length;h++){let g=p[h];if(g.top<=o&&g.bottom>=l){o=Math.max(g.bottom,o),l=Math.min(g.top,l);let b=g.left>e.left?g.left-e.left:g.right<e.left?e.left-g.right:0;if(b<r){n=u,r=b,i=b&&we(n)?{left:g.right<e.left?g.right:g.left,top:e.top}:e,V(u)&&b&&(s=d+(e.left>=(g.left+g.right)/2?1:0));continue}}else g.top>e.top&&!a&&g.left<=e.left&&g.right>=e.left&&(a=u,c={left:Math.max(g.left,Math.min(g.right,e.left)),top:g.top});!n&&(e.left>=g.right&&e.top>=g.top||e.left>=g.left&&e.top>=g.bottom)&&(s=d+1)}}return!n&&a&&(n=a,i=c,r=0),n&&we(n)?ub(n,i):!n||r?{node:t,offset:s}:vp(n,i)}function ub(t,e){let n=t.nodeValue.length,r=document.createRange(),i;for(let s=0;s<n;s++){r.setEnd(t,s+1),r.setStart(t,s);let o=Yt(r,1);if(o.top!=o.bottom&&Oa(e,o)){i={node:t,offset:s+(e.left>=(o.left+o.right)/2?1:0)};break}}return r.detach(),i||{node:t,offset:0}}function Oa(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function db(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function fb(t,e,n){let{node:r,offset:i}=vp(e,n),s=-1;if(V(r)&&!r.firstChild){let o=r.getBoundingClientRect();s=o.left!=o.right&&n.left>(o.left+o.right)/2?1:-1}return t.docView.posFromDOM(r,i,s)}function pb(t,e,n,r){let i=-1;for(let s=e,o=!1;s!=t.dom;){let l=t.docView.nearestDesc(s,!0),a;if(!l)return null;if(V(l.dom)&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!o&&a.left>r.left||a.top>r.top?i=l.posBefore:(!o&&a.right<r.left||a.bottom<r.top)&&(i=l.posAfter),o=!0),!l.contentDOM&&i<0&&!l.node.isText))return(l.node.isBlock?r.top<(a.top+a.bottom)/2:r.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;s=l.dom.parentNode}return i>-1?i:t.docView.posFromDOM(e,n,-1)}function Mp(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),s=i;;){let o=t.childNodes[s];if(V(o)){let l=o.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(Oa(e,c))return Mp(o,e,c)}}if((s=(s+1)%r)==i)break}return t}function hb(t,e){let n=t.dom.ownerDocument,r,i=0,s=rb(n,e.left,e.top);s&&({node:r,offset:i}=s);let o=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),l;if(!o||!t.dom.contains(o)){let c=t.dom.getBoundingClientRect();if(!Oa(e,c)||(o=Mp(t.dom,e,c),!o))return null}if(_e)for(let c=o;r&&c;c=sr(c))c.draggable&&(r=void 0);if(o=db(o,e),r){if(Ze&&V(r)&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let u=r.childNodes[i],d;u.nodeName=="IMG"&&(d=u.getBoundingClientRect()).right<=e.left&&d.bottom>e.top&&i++}let c;lo&&i&&V(r)&&V(c=r.childNodes[i-1])&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&i--,r==t.dom&&i==r.childNodes.length-1&&V(r.lastChild)&&e.top>r.lastChild.getBoundingClientRect().bottom?l=t.state.doc.content.size:(i==0||!V(r)||r.childNodes[i-1].nodeName!="BR")&&(l=pb(t,r,i,e))}l==null&&(l=fb(t,o,e));let a=t.docView.nearestDesc(o,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Vl(t){return t.top<t.bottom||t.left<t.right}function Yt(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(Vl(r))return r}return Array.prototype.find.call(n,Vl)||t.getBoundingClientRect()}const mb=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Tp(t,e,n){let{node:r,offset:i,atom:s}=t.docView.domFromPos(e,n<0?-1:1),o=lo||Ze;if(we(r))if(o&&(mb.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let a=Yt(Et(r,i,i),n);if(Ze&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let c=Yt(Et(r,i-1,i-1),-1);if(c.top==a.top){let u=Yt(Et(r,i,i+1),-1);if(u.top!=a.top)return Cr(u,u.left<c.left)}}return a}else{let a=i,c=i,u=n<0?1:-1;return n<0&&!i?(c++,u=-1):n>=0&&i==r.nodeValue.length?(a--,u=1):n<0?a--:c++,Cr(Yt(Et(r,a,c),u),u<0)}if(!t.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&i&&(n<0||i==Be(r))){let a=r.childNodes[i-1];if(V(a))return ll(a.getBoundingClientRect(),!1)}if(s==null&&i<Be(r)){let a=r.childNodes[i];if(V(a))return ll(a.getBoundingClientRect(),!0)}return ll(r.getBoundingClientRect(),n>=0)}if(s==null&&i&&(n<0||i==Be(r))){let a=r.childNodes[i-1],c=we(a)?Et(a,Be(a)-(o?0:1)):V(a)&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return Cr(Yt(c,1),!1)}if(s==null&&i<Be(r)){let a=r.childNodes[i];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?we(a)?Et(a,0,o?0:1):V(a)?a:null:null;if(c)return Cr(Yt(c,-1),!0)}return Cr(Yt(we(r)?Et(r):r,-n),n>=0)}function Cr(t,e){if(t.width==0)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function ll(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function Ap(t,e,n){let r=t.state,i=t.root.activeElement;r!=e&&t.updateState(e),i!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),i!=t.dom&&i&&i.focus()}}function gb(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return Ap(t,e,()=>{let{node:s}=t.docView.domFromPos(i.pos,n=="up"?-1:1);for(;;){let l=t.docView.nearestDesc(s,!0);if(!l)break;if(l.node.isBlock){s=l.contentDOM||l.dom;break}s=l.dom.parentNode}let o=Tp(t,i.pos,1);for(let l=s.firstChild;l;l=l.nextSibling){let a;if(V(l))a=l.getClientRects();else if(we(l))a=Et(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let u=a[c];if(u.bottom>u.top+1&&(n=="up"?o.top-u.top>(u.bottom-o.top)*2:u.bottom-o.bottom>(o.bottom-u.top)*2))return!1}}return!0})}const yb=/[\u0590-\u08ac]/;function bb(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,s=!i,o=i==r.parent.content.size,l=t.domSelection();return l?!yb.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?s:o:Ap(t,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:u,anchorOffset:d}=t.domSelectionRange(),p=l.caretBidiLevel;l.modify("move",n,"character");let h=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:g,focusOffset:b}=t.domSelectionRange(),x=g&&!Dn(h,g)||a==g&&c==b;try{l.collapse(u,d),a&&(a!=u||c!=d)&&l.extend&&l.extend(a,c)}catch{}return p!=null&&(l.caretBidiLevel=p),x}):r.pos==r.start()||r.pos==r.end()}let yu=null,bu=null,ku=!1;function kb(t,e,n){return yu==e&&bu==n?ku:(yu=e,bu=n,ku=n=="up"||n=="down"?gb(t,e,n):bb(t,e,n))}const st=0,xu=1,Sn=2,ct=3;class mi{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=st,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(e){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;n<this.children.length;n++)e+=this.children[n].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let n=0,r=this.posAtStart;;n++){let i=this.children[n];if(i==e)return r;r+=i.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,n,r){if(this.contentDOM&&Dn(this.contentDOM,e))if(r<0){let s,o;if(e==this.contentDOM)s=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.previousSibling}for(;s&&!((o=s.pmViewDesc)&&o.parent==this);)s=s.previousSibling;return s?this.posBeforeChild(o)+o.size:this.posAtStart}else{let s,o;if(e==this.contentDOM)s=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.nextSibling}for(;s&&!((o=s.pmViewDesc)&&o.parent==this);)s=s.nextSibling;return s?this.posBeforeChild(o):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=n>Oe(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=!!(e.compareDocumentPosition(this.contentDOM)&4);else if(this.dom.firstChild){if(n==0)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!1;break}if(s.previousSibling)break}if(i==null&&n==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!0;break}if(s.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,i=e;i;i=i.parentNode){let s=this.getDesc(i),o;if(s&&(!n||s.node))if(r&&(o=s.nodeDOM)&&!(V(o)?Dn(o,e):o==e))r=!1;else return s}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let i=e;i;i=i.parentNode){let s=this.getDesc(i);if(s)return s.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let i=this.children[n],s=r+i.size;if(r==e&&s!=r){for(;!i.border&&i.children.length;)for(let o=0;o<i.children.length;o++){let l=i.children[o];if(l.size){i=l;break}}return i}if(e<s)return i.descAt(e-r-i.border);r=s}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,i=0;for(let s=0;r<this.children.length;r++){let o=this.children[r],l=s+o.size;if(l>e){i=e-s;break}s=l}if(i)return this.children[r].domFromPos(i-this.children[r].border,n);for(;r>0;r--){let s=this.children[r-1];if(s.size||!(s instanceof Np||s instanceof Ep&&s.side>=0))break}if(n<=0){let s,o=!0;for(;s=r?this.children[r-1]:null,!(!s||s.dom.parentNode==this.contentDOM);r--,o=!1);return s&&n&&o&&!s.border&&!s.domAtom?s.domFromPos(s.size,n):{node:this.contentDOM,offset:s?Oe(s.dom)+1:0}}else{let s,o=!0;for(;s=r<this.children.length?this.children[r]:null,!(!s||s.dom.parentNode==this.contentDOM);r++,o=!1);return s&&o&&!s.border&&!s.domAtom?s.domFromPos(0,n):{node:this.contentDOM,offset:s?Oe(s.dom):this.contentDOM.childNodes.length}}}parseRange(e,n,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let i=-1,s=-1;for(let o=r,l=0;;l++){let a=this.children[l],c=o+a.size;if(i==-1&&e<=c){let u=o+a.border;if(e>=u&&n<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,n,u);e=o;for(let d=l;d>0;d--){let p=this.children[d-1];if(p.size&&p.dom.parentNode==this.contentDOM&&!p.emptyChildAt(1)){i=Oe(p.dom)+1;break}e-=p.size}i==-1&&(i=0)}if(i>-1&&(c>n||l==this.children.length-1)){n=c;for(let u=l+1;u<this.children.length;u++){let d=this.children[u];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(-1)){s=Oe(d.dom);break}n+=d.size}s==-1&&(s=this.contentDOM.childNodes.length);break}o=c}return{node:this.contentDOM,from:e,to:n,fromOffset:i,toOffset:s}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[e<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(e)}domAfterPos(e){let{node:n,offset:r}=this.domFromPos(e,0);if(!V(n)||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]}setSelection(e,n,r,i=!1){let s=Math.min(e,n),o=Math.max(e,n);for(let h=0,g=0;h<this.children.length;h++){let b=this.children[h],x=g+b.size;if(s>g&&o<x)return b.setSelection(e-g-b.border,n-g-b.border,r,i);g=x}let l=this.domFromPos(e,e?-1:1),a=n==e?l:this.domFromPos(n,n?-1:1),c=r.root.getSelection(),u=r.domSelectionRange(),d=!1;if((Ze||_e)&&e==n){let{node:h,offset:g}=l;if(we(h)){if(d=!!(g&&h.nodeValue[g-1]==`
51
+ `),d&&g==h.nodeValue.length)for(let b=h,x;b;b=b.parentNode){if(x=b.nextSibling){x.nodeName=="BR"&&(l=a={node:x.parentNode,offset:Oe(x)+1});break}let w=b.pmViewDesc;if(w&&w.node&&w.node.isBlock)break}}else{let b=h.childNodes[g-1];d=b&&(b.nodeName=="BR"||b.contentEditable=="false")}}if(Ze&&u.focusNode&&u.focusNode!=a.node&&V(u.focusNode)){let h=u.focusNode.childNodes[u.focusOffset];h&&h.contentEditable=="false"&&(i=!0)}if(!(i||d&&_e)&&Rn(l.node,l.offset,u.anchorNode,u.anchorOffset)&&Rn(a.node,a.offset,u.focusNode,u.focusOffset))return;let p=!1;if((c.extend||e==n)&&!(d&&Ze)){c.collapse(l.node,l.offset);try{e!=n&&c.extend(a.node,a.offset),p=!0}catch{}}if(!p){if(e>n){let g=l;l=a,a=g}let h=document.createRange();h.setEnd(a.node,a.offset),h.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,i=0;i<this.children.length;i++){let s=this.children[i],o=r+s.size;if(r==o?e<=o&&n>=r:e<o&&n>r){let l=r+s.border,a=o-s.border;if(e>=l&&n<=a){this.dirty=e==r||n==o?Sn:xu,e==l&&n==a&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=ct:s.markDirty(e-l,n-l);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?Sn:ct}r=o}this.dirty=Sn}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?Sn:xu;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class Ep extends mi{constructor(e,n,r,i){let s,o=n.type.toDOM;if(typeof o=="function"&&(o=o(r,()=>{if(!s)return i;if(s.parent)return s.parent.posBeforeChild(s)})),!n.type.spec.raw){let l=V(o)?o:document.createElement("span");l!=o&&l.appendChild(o),l.hasAttribute("contenteditable")||(l.contentEditable="false"),l.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=n,this.widget=n,s=this}matchesWidget(e){return this.dirty==st&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class xb extends mi{constructor(e,n,r,i){super(e,[],n,null),this.textDOM=r,this.text=i}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class sn extends mi{constructor(e,n,r,i,s){super(e,[],r,i),this.mark=n,this.spec=s}static create(e,n,r,i){let s=i.nodeViews[n.type.name],o=s&&s(n,i,r);return(!o||!o.dom)&&(o=Bn.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new sn(e,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&ct||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=ct&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=st){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=st}}slice(e,n,r){let i=sn.create(this.parent,this.mark,!0,r),s=this.children,o=this.size;n<o&&(s=ql(s,n,o,r)),e>0&&(s=ql(s,0,e,r));for(let l=0;l<s.length;l++)s[l].parent=i;return i.children=s,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class on extends mi{constructor(e,n,r,i,s,o,l){super(e,[],s,o),this.node=n,this.outerDeco=r,this.innerDeco=i,this.nodeDOM=l}static create(e,n,r,i,s,o){let l=s.nodeViews[n.type.name],a,c=l&&l(n,s,()=>{if(!a)return o;if(a.parent)return a.parent.posBeforeChild(a)},r,i),u=c&&c.dom,d=c&&c.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(!we(u))throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:d}=Bn.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!d&&!n.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),n.type.spec.draggable&&(u.draggable=!0));let p=u;return u=Ip(u,r,n),c?a=new Sb(e,n,r,i,u,d||null,p,c):n.isText?new ao(e,n,r,i,u,p):new on(e,n,r,i,u,d||null,p)}parseRule(e){if(this.node.type.spec.reparseInView)return null;let n={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(n.preserveWhitespace="full"),!this.contentDOM)n.getContent=()=>this.node.content;else if(!this.contentLost)n.contentElement=this.contentDOM;else{for(let r=this.children.length-1;r>=0;r--){let i=this.children[r];if(this.dom.contains(i.dom.parentNode)){n.contentElement=i.dom.parentNode;break}}if(!n.contentElement){let r=e&&e.find(i=>V(i)&&e.indexOf(i.parentNode)<0&&this.dom.contains(i));r?n.contentElement=r:n.getContent=()=>I.empty}}return n}matchesNode(e,n,r){return this.dirty==st&&e.eq(this.node)&&us(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,i=n,s=e.composing?this.localCompositionInfo(e,n):null,o=s&&s.pos>-1?s:null,l=s&&s.pos<0,a=new Cb(this,o&&o.node,e),c=this.node.inlineContent,u=c&&this.node.isBlock;Tb(this.node,this.innerDeco,(d,p,h)=>{d.spec.marks?a.syncToMarks(d.spec.marks,r,e,p):d.type.side>=0&&!h&&a.syncToMarks(p==this.node.childCount?ue.none:this.node.child(p).marks,r,e,p),a.placeWidget(d,e,i)},(d,p,h,g)=>{a.syncToMarks(d.marks,r,e,g),u&&d.isAtom&&!d.isText&&a.addHackNode("IMG",a.top);let b;a.findNodeMatch(d,p,h,g)||l&&e.state.selection.from>i&&e.state.selection.to<i+d.nodeSize&&(b=a.findIndexWithChild(s.node))>-1&&a.updateNodeAt(d,p,h,b,e)||a.updateNextNode(d,p,h,e,g,i)||a.addNode(d,p,h,e,i),i+=d.nodeSize,c&&(u=d.isAtom&&!d.isText)}),a.syncToMarks([],r,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==Sn)&&(o&&this.protectLocalComposition(e,o),Op(this.contentDOM,this.children,e),or&&Ab(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof q)||r<n||i>n+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let o=s.nodeValue,l=Eb(this.node.content,o,r-n,i-n);return l<0?null:{node:s,pos:l,text:o}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:i}){if(this.getDesc(n))return;let s=n;for(;s.parentNode!=this.contentDOM;s=s.parentNode){for(;s.previousSibling;)s.parentNode.removeChild(s.previousSibling);for(;s.nextSibling;)s.parentNode.removeChild(s.nextSibling);s.pmViewDesc&&(s.pmViewDesc=void 0)}let o=new xb(this,s,n,i);e.input.compositionNodes.push(o),this.children=ql(this.children,r,r+i.length,e,o)}update(e,n,r,i){return this.dirty==ct||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,i),!0)}updateInner(e,n,r,i){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=st}updateOuterDeco(e){if(us(e,this.outerDeco))return;let n=!V(this.nodeDOM),r=this.dom;this.dom=Lp(this.dom,this.nodeDOM,Ul(this.outerDeco,this.node,n),Ul(e,this.node,n)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){V(this.nodeDOM)&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){V(this.nodeDOM)&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function Su(t,e,n,r,i){Ip(r,e,t);let s=new on(void 0,t,e,n,r,r,r);return s.contentDOM&&s.updateChildren(i,0),s}class ao extends on{constructor(e,n,r,i,s,o){super(e,n,r,i,s,null,o)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,i){return this.dirty==ct||this.dirty!=st&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=st||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=st,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let i=this.node.cut(e,n),s=document.createTextNode(i.text);return new ao(this.parent,i,this.outerDeco,this.innerDeco,s,s)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=ct)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Np extends mi{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==st&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Sb extends on{constructor(e,n,r,i,s,o,l,a){super(e,n,r,i,s,o,l),this.spec=a}update(e,n,r,i){if(this.dirty==ct)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let s=this.spec.update(e,n,r);return s&&this.updateInner(e,n,r,i),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,i){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function Op(t,e,n){let r=t.firstChild,i=!1;for(let s=0;s<e.length;s++){let o=e[s],l=o.dom;if(l.parentNode==t){for(;l!=r;)r=wu(r),i=!0;r=r.nextSibling}else i=!0,t.insertBefore(l,r);if(o instanceof sn){let a=r?r.previousSibling:t.lastChild;Op(o.contentDOM,o.children,n),r=a?a.nextSibling:t.firstChild}}for(;r;)r=wu(r),i=!0;i&&n.trackWrites==t&&(n.trackWrites=null)}const zr=function(t){t&&(this.nodeName=t)};zr.prototype=Object.create(null);const wn=[new zr];function Ul(t,e,n){if(t.length==0)return wn;let r=n?wn[0]:new zr,i=[r];for(let s=0;s<t.length;s++){let o=t[s].type.attrs;if(o){o.nodeName&&i.push(r=new zr(o.nodeName));for(let l in o){let a=o[l];a!=null&&(n&&i.length==1&&i.push(r=new zr(e.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+a:l=="style"?r.style=(r.style?r.style+";":"")+a:l!="nodeName"&&(r[l]=a))}}}return i}function Lp(t,e,n,r){if(n==wn&&r==wn)return e;let i=e;for(let s=0;s<r.length;s++){let o=r[s],l=n[s];if(s){let a;l&&l.nodeName==o.nodeName&&i!=t&&(a=i.parentNode)&&a.nodeName.toLowerCase()==o.nodeName||(a=document.createElement(o.nodeName),a.pmIsDeco=!0,a.appendChild(i),l=wn[0]),i=a}wb(i,l||wn[0],o)}return i}function wb(t,e,n){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in n)&&t.removeAttribute(r);for(let r in n)r!="class"&&r!="style"&&r!="nodeName"&&n[r]!=e[r]&&t.setAttribute(r,n[r]);if(e.class!=n.class){let r=e.class?e.class.split(" ").filter(Boolean):[],i=n.class?n.class.split(" ").filter(Boolean):[];for(let s=0;s<r.length;s++)i.indexOf(r[s])==-1&&t.classList.remove(r[s]);for(let s=0;s<i.length;s++)r.indexOf(i[s])==-1&&t.classList.add(i[s]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=r.exec(e.style);)t.style.removeProperty(i[1])}n.style&&(t.style.cssText+=n.style)}}function Ip(t,e,n){return Lp(t,t,wn,Ul(e,n,!V(t)))}function us(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].type.eq(e[n].type))return!1;return!0}function wu(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class Cb{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=vb(e.node.content,e)}destroyBetween(e,n){if(e!=n){for(let r=e;r<n;r++)this.top.children[r].destroy();this.top.children.splice(e,n-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,n,r,i){let s=0,o=this.stack.length>>1,l=Math.min(o,e.length);for(;s<l&&(s==o-1?this.top:this.stack[s+1<<1]).matchesMark(e[s])&&e[s].type.spec.spanning!==!1;)s++;for(;s<o;)this.destroyRest(),this.top.dirty=st,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<e.length;){this.stack.push(this.top,this.index+1);let a=-1,c=this.top.children.length;i<this.preMatch.index&&(c=Math.min(this.index+3,c));for(let u=this.index;u<c;u++){let d=this.top.children[u];if(d.matchesMark(e[o])&&!this.isLocked(d.dom)){a=u;break}}if(a<0&&this.index<this.top.children.length){let u=this.top.children[this.index];u instanceof sn&&u.dirty!=ct&&u.mark.type==e[o].type&&u.spec.update&&!this.isLocked(u.dom)&&u.spec.update(e[o])&&(u.mark=e[o],a=this.index,this.changed=!0)}if(a>-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{let u=sn.create(this.top,e[o],n,r);this.top.children.splice(this.index,0,u),this.top=u,this.changed=!0}this.index=0,o++}}findNodeMatch(e,n,r,i){let s=-1,o;if(i>=this.preMatch.index&&(o=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&o.matchesNode(e,n,r))s=this.top.children.indexOf(o,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,n,r)&&!this.preMatch.matched.has(c)){s=l;break}}return s<0?!1:(this.destroyBetween(this.index,s),this.index++,!0)}updateNodeAt(e,n,r,i,s){let o=this.top.children[i];return o.dirty==ct&&o.dom==o.contentDOM&&(o.dirty=Sn),o.update(e,n,r,s)?(this.destroyBetween(this.index,i),this.index++,!0):!1}findIndexWithChild(e){for(;;){let n=e.parentNode;if(!n)return-1;if(n==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let i=this.index;i<this.top.children.length;i++)if(this.top.children[i]==r)return i}return-1}e=n}}updateNextNode(e,n,r,i,s,o){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof on){let c=this.preMatch.matched.get(a);if(c!=null&&c!=s)return!1;let u=a.dom,d,p=this.isLocked(u)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=ct&&us(n,a.outerDeco));if(!p&&a.update(e,n,r,i))return this.destroyBetween(this.index,l),a.dom!=u&&(this.changed=!0),this.index++,!0;if(!p&&(d=this.recreateWrapper(a,e,n,r,i,o)))return this.destroyBetween(this.index,l),this.top.children[this.index]=d,d.contentDOM&&(d.dirty=Sn,d.updateChildren(i,o+1),d.dirty=st),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,i,s,o){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!us(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let l=on.create(this.top,n,r,i,s,o);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,n,r,i,s){let o=on.create(this.top,e,n,r,i,s);o.contentDOM&&o.updateChildren(i,s+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,n,r){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(i&&i.matchesWidget(e)&&(e==i.widget||!i.widget.type.toDOM.parentNode))this.index++;else{let s=new Ep(this.top,e,n,r);this.top.children.splice(this.index++,0,s),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof sn;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof ao)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((_e||Re)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",n),this.addHackNode("BR",this.top))}addHackNode(e,n){if(n==this.top&&this.index<n.children.length&&n.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let i=new Np(this.top,[],r,null);n!=this.top?n.children.push(i):n.children.splice(this.index++,0,i),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||V(e)&&e.contains(this.lock.parentNode))}}function vb(t,e){let n=e,r=n.children.length,i=t.childCount,s=new Map,o=[];e:for(;i>0;){let l;for(;;)if(r){let c=n.children[r-1];if(c instanceof sn)n=c,r=c.children.length;else{l=c,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let a=l.node;if(a){if(a!=t.child(i-1))break;--i,s.set(l,i),o.push(l)}}return{index:i,matched:s,matches:o.reverse()}}function Mb(t,e){return t.type.side-e.type.side}function Tb(t,e,n,r){let i=e.locals(t),s=0;if(i.length==0){for(let c=0;c<t.childCount;c++){let u=t.child(c);r(u,i,e.forChild(s,u),c),s+=u.nodeSize}return}let o=0,l=[],a=null;for(let c=0;;){let u,d;for(;o<i.length&&i[o].to==s;){let x=i[o++];x.widget&&(u?(d||(d=[u])).push(x):u=x)}if(u)if(d){d.sort(Mb);for(let x=0;x<d.length;x++)n(d[x],c,!!a)}else n(u,c,!!a);let p,h;if(a)h=-1,p=a,a=null;else if(c<t.childCount)h=c,p=t.child(c++);else break;for(let x=0;x<l.length;x++)l[x].to<=s&&l.splice(x--,1);for(;o<i.length&&i[o].from<=s&&i[o].to>s;)l.push(i[o++]);let g=s+p.nodeSize;if(p.isText){let x=g;o<i.length&&i[o].from<x&&(x=i[o].from);for(let w=0;w<l.length;w++)l[w].to<x&&(x=l[w].to);x<g&&(a=p.cut(x-s),p=p.cut(0,x-s),g=x,h=-1)}else for(;o<i.length&&i[o].to<g;)o++;let b=p.isInline&&!p.isLeaf?l.filter(x=>!x.inline):l.slice();r(p,b,e.forChild(s,p),h),s=g}}function Ab(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 Eb(t,e,n,r){for(let i=0,s=0;i<t.childCount&&s<=r;){let o=t.child(i++),l=s;if(s+=o.nodeSize,!o.isText)continue;let a=o.text;for(;i<t.childCount;){let c=t.child(i++);if(s+=c.nodeSize,!c.isText)break;a+=c.text}if(s>=n){if(s>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l<r?a.lastIndexOf(e,r-l-1):-1;if(c>=0&&c+e.length+l>=n)return l+c;if(n==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function ql(t,e,n,r,i){let s=[];for(let o=0,l=0;o<t.length;o++){let a=t[o],c=l,u=l+=a.size;c>=n||u<=e?s.push(a):(c<e&&s.push(a.slice(0,e-c,r)),i&&(s.push(i),i=void 0),u>n&&s.push(a.slice(n-c,a.size,r)))}return s}function La(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let i=t.docView.nearestDesc(n.focusNode),s=i&&i.size==0,o=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let l=r.resolve(o),a,c;if(oo(n)){for(a=o;i&&!i.node;)i=i.parent;if(i&&i.node.isAtom&&U.isSelectable(i.node)&&i.parent&&!(i.node.isInline&&tb(n.focusNode,n.focusOffset,i.dom))){let d=i.posBefore;c=new U(o==d?l:r.resolve(d))}else if(Ze&&e=="key"&&o>t.state.selection.to&&V(n.focusNode)&&n.focusOffset==n.focusNode.childNodes.length&&i&&i.posAtStart>t.state.selection.to)for(let d=n.focusNode;;d=d.parentNode){if(getComputedStyle(d).overflow!="visible"){c=J.findFrom(r.resolve(i.posAtStart),1);break}if(d==i.dom||d.nextSibling||!d.parentNode||!V(d.parentNode))break}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let d=o,p=o;for(let h=0;h<n.rangeCount;h++){let g=n.getRangeAt(h);d=Math.min(d,t.docView.posFromDOM(g.startContainer,g.startOffset,1)),p=Math.max(p,t.docView.posFromDOM(g.endContainer,g.endOffset,-1))}if(d<0)return null;[a,o]=p==t.state.selection.anchor?[p,d]:[d,p],l=r.resolve(o)}else a=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(a<0)return null}let u=r.resolve(a);if(!c){let d=e=="pointer"||t.state.selection.head<l.pos&&!s?1:-1;c=Ia(t,u,l,d)}return c}function Rp(t){return t.editable?t.hasFocus():Pp(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function $t(t,e=!1){let n=t.state.selection;if(Dp(t,n),!Rp(t))return;let r=t.input.mouseDown;if(!e&&Re&&r){let i=t.domSelectionRange(),s=t.domObserver.currentSelection;if(i.anchorNode&&s.anchorNode&&Rn(i.anchorNode,i.anchorOffset,s.anchorNode,s.anchorOffset)&&r.delaySelUpdate()){t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)Ob(t);else{let{anchor:i,head:s}=n,o,l;Cu&&!(n instanceof q)&&(n.$from.parent.inlineContent||(o=vu(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(l=vu(t,n.to))),t.docView.setSelection(i,s,t,e),Cu&&(o&&Mu(o),l&&Mu(l)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Nb(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}const Cu=_e||Re&&xp<63;function vu(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),i=r<n.childNodes.length?n.childNodes[r]:null,s=r?n.childNodes[r-1]:null;if(_e&&i&&i.contentEditable=="false")return al(i);if((!i||i.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(i)return al(i);if(s)return al(s)}}function al(t){return t.contentEditable="true",_e&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function Mu(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function Nb(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),r=n.anchorNode,i=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=i)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!Rp(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function Ob(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,Oe(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&Ke&&rn<=11&&(n.disabled=!0,n.disabled=!1)}function Dp(t,e){if(e instanceof U){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(Tu(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else Tu(t)}function Tu(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Ia(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||q.between(e,n,r)}function Au(t){return t.editable&&!t.hasFocus()?!1:Pp(t)}function Pp(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return Dn(t.dom,e.anchorNode)&&(t.editable||Dn(t.dom,e.focusNode))}catch{return!1}}function Lb(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Rn(e.node,e.offset,n.anchorNode,n.anchorOffset)}function Wl(t,e){let{$anchor:n,$head:r}=t.selection,i=e>0?n.max(r):n.min(r),s=i.parent.inlineContent?i.depth?t.doc.resolve(e>0?i.after():i.before()):null:i;return s&&J.findFrom(s,e)}function Gt(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function Eu(t,e,n){let r=t.state.selection;if(r instanceof q)if(n.indexOf("s")>-1){let{$head:i}=r,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let o=t.state.doc.resolve(i.pos+s.nodeSize*(e<0?-1:1));return Gt(t,new q(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=Wl(t.state,e);return i&&i instanceof U?Gt(t,i):!1}else if(!(it&&n.indexOf("m")>-1)){let i=r.$head,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,o;if(!s||s.isText)return!1;let l=e<0?i.pos-s.nodeSize:i.pos;return s.isAtom||(o=t.docView.descAt(l))&&!o.contentDOM?U.isSelectable(s)?Gt(t,new U(e<0?t.state.doc.resolve(i.pos-s.nodeSize):i)):Gt(t,new q(t.state.doc.resolve(e<0?l:l+s.nodeSize))):!1}}else return!1;else{if(r instanceof U&&r.node.isInline)return Gt(t,new q(e>0?r.$to:r.$from));{let i=Wl(t.state,e);return i?Gt(t,i):!1}}}function Fr(t,e){let n=t.pmViewDesc;return n?n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR"):V(t)&&t.contentEditable=="false"}function Un(t,e){return e<0?Ib(t):Rb(t)}function Ib(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,s,o=!1;for(Ze&&V(n)&&r<Be(n)&&Fr(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(!V(n))break;let l=n.childNodes[r-1];if(Fr(l,-1))i=n,s=--r;else if(we(l))n=l,r=n.nodeValue.length;else break}else{if($p(n))break;{let l=n.previousSibling;for(;l&&Fr(l,-1);)i=n.parentNode,s=Oe(l),l=l.previousSibling;if(l)n=l,r=Be(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?Kl(t,n,r):i&&Kl(t,i,s)}function Rb(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=Be(n),s,o;for(;;)if(r<i){if(!V(n))break;let l=n.childNodes[r];if(Fr(l,1))s=n,o=++r;else break}else{if($p(n))break;{let l=n.nextSibling;for(;l&&Fr(l,1);)s=l.parentNode,o=Oe(l)+1,l=l.nextSibling;if(l)n=l,r=0,i=Be(n);else{if(n=n.parentNode,n==t.dom)break;r=i=0}}}s&&Kl(t,s,o)}function $p(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function Db(t,e){for(;t&&e==t.childNodes.length&&!hi(t);)e=Oe(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let n=t.childNodes[e];if(we(n))return n;if(V(n)&&n.contentEditable=="false")break;t=n,e=0}}function Pb(t,e){for(;t&&!e&&!hi(t);)e=Oe(t),t=t.parentNode;for(;t&&e;){let n=t.childNodes[e-1];if(we(n))return n;if(V(n)&&n.contentEditable=="false")break;t=n,e=t.childNodes.length}}function Kl(t,e,n){if(!we(e)){let s,o;(o=Db(e,n))?(e=o,n=0):(s=Pb(e,n))&&(e=s,n=s.nodeValue.length)}let r=t.domSelection();if(!r)return;if(oo(r)){let s=document.createRange();s.setEnd(e,n),s.setStart(e,n),r.removeAllRanges(),r.addRange(s)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:i}=t;setTimeout(()=>{t.state==i&&$t(t)},50)}function Nu(t,e){let n=t.state.doc.resolve(e);if(!(Re||Sp)&&n.parent.inlineContent){let i=t.coordsAtPos(e);if(e>n.start()){let s=t.coordsAtPos(e-1),o=(s.top+s.bottom)/2;if(o>i.top&&o<i.bottom&&Math.abs(s.left-i.left)>1)return s.left<i.left?"ltr":"rtl"}if(e<n.end()){let s=t.coordsAtPos(e+1),o=(s.top+s.bottom)/2;if(o>i.top&&o<i.bottom&&Math.abs(s.left-i.left)>1)return s.left>i.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function Ou(t,e,n){let r=t.state.selection;if(r instanceof q&&!r.empty||n.indexOf("s")>-1||it&&n.indexOf("m")>-1)return!1;let{$from:i,$to:s}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=Wl(t.state,e);if(o&&o instanceof U)return Gt(t,o)}if(!i.parent.inlineContent){let o=e<0?i:s,l=r instanceof Xe?J.near(o,e):J.findFrom(o,e);return l?Gt(t,l):!1}return!1}function Lu(t,e){if(!(t.state.selection instanceof q))return!0;let{$head:n,$anchor:r,empty:i}=t.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(s&&!s.isText){let o=t.state.tr;return e<0?o.delete(n.pos-s.nodeSize,n.pos):o.delete(n.pos,n.pos+s.nodeSize),t.dispatch(o),!0}return!1}function Iu(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function $b(t){if(!_e||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&V(e)&&n==0&&e.firstChild&&V(e.firstChild)&&e.firstChild.contentEditable=="false"){let r=e.firstChild;Iu(t,r,"true"),setTimeout(()=>Iu(t,r,"false"),20)}return!1}function Bb(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function _b(t,e){let n=e.keyCode,r=Bb(e);if(n==8||it&&n==72&&r=="c")return Lu(t,-1)||Un(t,-1);if(n==46&&!e.shiftKey||it&&n==68&&r=="c")return Lu(t,1)||Un(t,1);if(n==13||n==27)return!0;if(n==37||it&&n==66&&r=="c"){let i=n==37?Nu(t,t.state.selection.from)=="ltr"?-1:1:-1;return Eu(t,i,r)||Un(t,i)}else if(n==39||it&&n==70&&r=="c"){let i=n==39?Nu(t,t.state.selection.from)=="ltr"?1:-1:1;return Eu(t,i,r)||Un(t,i)}else{if(n==38||it&&n==80&&r=="c")return Ou(t,-1,r)||Un(t,-1);if(n==40||it&&n==78&&r=="c")return $b(t)||Ou(t,1,r)||Un(t,1);if(r==(it?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function Ra(t,e){t.someProp("transformCopied",h=>{e=h(e,t)});let n=[],{content:r,openStart:i,openEnd:s}=e;for(;i>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,s--;let h=r.firstChild;n.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let o=t.someProp("clipboardSerializer")||Bn.fromSchema(t.state.schema),l=jp(),a=l.createElement("div");a.appendChild(o.serializeFragment(r,{document:l}));let c=a.firstChild,u,d=0;for(;c&&V(c)&&(u=Hp[c.nodeName.toLowerCase()]);){for(let h=u.length-1;h>=0;h--){let g=l.createElement(u[h]);for(;a.firstChild;)g.appendChild(a.firstChild);a.appendChild(g),d++}c=a.firstChild}c&&V(c)&&c.setAttribute("data-pm-slice",`${i} ${s}${d?` -${d}`:""} ${JSON.stringify(n)}`);let p=t.someProp("clipboardTextSerializer",h=>h(e,t))||e.content.textBetween(0,e.content.size,`
52
+
53
+ `);return{dom:a,text:p,slice:e}}function Bp(t,e,n,r,i){let s=i.parent.type.spec.code,o,l;if(!n&&!e)return null;let a=!!e&&(r||s||!n);if(a){if(t.someProp("transformPastedText",p=>{e=p(e,s||r,t)}),s)return l=new _(I.from(t.state.schema.text(e.replace(/\r\n?/g,`
54
+ `))),0,0),t.someProp("transformPasted",p=>{l=p(l,t,!0)}),l;let d=t.someProp("clipboardTextParser",p=>p(e,i,r,t));if(d)l=d;else{let p=i.marks(),{schema:h}=t.state,g=Bn.fromSchema(h);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(b=>{let x=o.appendChild(document.createElement("p"));b&&x.appendChild(g.serializeNode(h.text(b,p)))})}}else t.someProp("transformPastedHTML",d=>{n=d(n,t)}),o=jb(n),lo&&Vb(o);let c=o&&o.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let d=+u[3];d>0;d--){let p=o.firstChild;for(;p&&!V(p);)p=p.nextSibling;if(!p)break;o=p}if(l||(l=(t.someProp("clipboardParser")||t.someProp("domParser")||nn.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||u),context:i,ruleFromNode(p){return p.nodeName=="BR"&&!p.nextSibling&&p.parentNode&&!zb.test(p.parentNode.nodeName)?{ignore:!0}:null}})),u)l=Ub(Ru(l,+u[1],+u[2]),u[4]);else if(l=_.maxOpen(Fb(l.content,i),!0),l.openStart||l.openEnd){let d=0,p=0;for(let h=l.content.firstChild;d<l.openStart&&!h.type.spec.isolating;d++,h=h.firstChild);for(let h=l.content.lastChild;p<l.openEnd&&!h.type.spec.isolating;p++,h=h.lastChild);l=Ru(l,d,p)}return t.someProp("transformPasted",d=>{l=d(l,t,a)}),l}const zb=/^(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 Fb(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let i=e.node(n).contentMatchAt(e.index(n)),s,o=[];if(t.forEach(l=>{if(!o)return;let a=i.findWrapping(l.type),c;if(!a)return o=null;if(c=o.length&&s.length&&zp(a,s,l,o[o.length-1],0))o[o.length-1]=c;else{o.length&&(o[o.length-1]=Fp(o[o.length-1],s.length));let u=_p(l,a);o.push(u),i=i.matchType(u.type),s=a}}),o)return I.from(o)}return t}function _p(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,I.from(t));return t}function zp(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let s=zp(t,e,n,r.lastChild,i+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(i==t.length-1?n.type:t[i+1]))return r.copy(r.content.append(I.from(_p(n,t,i+1))))}}function Fp(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,Fp(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(I.empty,!0);return t.copy(n.append(r))}function Yl(t,e,n,r,i,s){let o=e<0?t.firstChild:t.lastChild,l=o.content;return t.childCount>1&&(s=0),i<r-1&&(l=Yl(l,e,n,r,i+1,s)),i>=n&&(l=e<0?o.contentMatchAt(0).fillBefore(l,s<=i).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(I.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(l))}function Ru(t,e,n){return e<t.openStart&&(t=new _(Yl(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new _(Yl(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const Hp={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};function jp(){return document.implementation.createHTMLDocument("title")}let vr=null;function Hb(t){let e=window.trustedTypes;if(!e)return t;if(!vr){if(vr=e.defaultPolicy)try{return vr.createHTML(t)}catch{}vr=e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})}return vr.createHTML(t)}function jb(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=jp(),r=n.body,i=/<([a-z][^>\s]+)/i.exec(t),s;if((s=i&&Hp[i[1].toLowerCase()])&&(t=s.map(o=>"<"+o+">").join("")+t+s.map(o=>"</"+o+">").reverse().join("")),r.innerHTML=Hb(t),s)for(let o=0;o<s.length;o++)r=r.querySelector(s[o])||r;for(let o=0;o<n.styleSheets.length;o++){let l=n.styleSheets[o];for(let a=0;a<l.rules.length;a++){let c=l.rules[a];if(c instanceof CSSStyleRule){let u=r.querySelectorAll(c.selectorText);for(let d=0;d<u.length;d++)u[d].style.cssText+=c.style.cssText}}}return r}function Vb(t){let e=t.querySelectorAll(Re?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let r=e[n];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}function Ub(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return t}let{content:i,openStart:s,openEnd:o}=t;for(let l=r.length-2;l>=0;l-=2){let a=n.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;try{i=I.from(a.create(r[l+1],i))}catch{break}s++,o++}return new _(i,s,o)}const Ve={},Ue={},qb={touchstart:!0,touchmove:!0};class Wb{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function Kb(t){for(let e in Ve){let n=Ve[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{Gb(t,r)&&!Da(t,r)&&(t.editable||!(r.type in Ue))&&n(t,r)},qb[e]?{passive:!0}:void 0)}_e&&t.dom.addEventListener("input",()=>null),Gl(t)}function It(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function Yb(t){t.input.mouseDown&&t.input.mouseDown.done(),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 Gl(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>Da(t,r))})}function Da(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function Gb(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function Jb(t,e){!Da(t,e)&&Ve[e.type]&&(t.editable||!(e.type in Ue))&&Ve[e.type](t,e)}Ue.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!Wp(t)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Lt&&Re&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),or&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",i=>i(t,xn(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||_b(t,n)?n.preventDefault():It(t,"key")};Ue.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Ue.keypress=(t,e)=>{let n=e;if(Wp(t)||!n.charCode||n.ctrlKey&&!n.altKey||it&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof q)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(n.charCode),s=()=>t.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!t.someProp("handleTextInput",o=>o(t,r.$from.pos,r.$to.pos,i,s))&&t.dispatch(s()),n.preventDefault()}};function gi(t){return{left:t.clientX,top:t.clientY}}function Xb(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function Pa(t,e,n,r,i){if(r==-1)return!1;let s=t.state.doc.resolve(r);for(let o=s.depth+1;o>0;o--)if(t.someProp(e,l=>o>s.depth?l(t,n,s.nodeAfter,s.before(o),i,!0):l(t,n,s.node(o),s.before(o),i,!1)))return!0;return!1}function yi(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);r.setMeta("pointer",!0),t.dispatch(r)}function Zb(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&U.isSelectable(r)?(yi(t,new U(n)),!0):!1}function Qb(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof U&&(r=n.node);let s=t.state.doc.resolve(e);for(let o=s.depth+1;o>0;o--){let l=o>s.depth?s.nodeAfter:s.node(o);if(U.isSelectable(l)){r&&n.$from.depth>0&&o>=n.$from.depth&&s.before(n.$from.depth+1)==n.$from.pos?i=s.before(n.$from.depth):i=s.before(o);break}}return i!=null?(yi(t,U.create(t.state.doc,i)),!0):!1}function e0(t,e,n,r,i){return Pa(t,"handleClickOn",e,n,r)||t.someProp("handleClick",s=>s(t,e,r))||(i?Qb(t,n):Zb(t,n))}function t0(t,e,n,r){return Pa(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function n0(t,e,n,r){return Pa(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||r0(t,n,r)}function r0(t,e,n){if(n.button!=0)return!1;let r=Vp(t,e,!0),i=t.state.doc;return r?(yi(t,r),r instanceof q&&i.eq(t.state.doc)&&(t.input.mouseDown=new s0(t,r)),!0):!1}function Vp(t,e,n){let r=t.state.doc;if(e==-1)return r.inlineContent?q.create(r,0,r.content.size):null;let i=r.resolve(e);for(let s=i.depth+1;s>0;s--){let o=s>i.depth?i.nodeAfter:i.node(s),l=i.before(s);if(o.inlineContent)return q.create(r,l+1,l+1+o.content.size);if(n&&U.isSelectable(o))return U.create(r,l)}return null}function $a(t){return ds(t)}const Up=it?"metaKey":"ctrlKey";Ve.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=$a(t),i=Date.now(),s="singleClick";i-t.input.lastClick.time<500&&Xb(n,t.input.lastClick)&&!n[Up]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?s="doubleClick":t.input.lastClick.type=="doubleClick"&&(s="tripleClick")),t.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:s,button:n.button},t.input.mouseDown&&t.input.mouseDown.done();let o=t.posAtCoords(gi(n));o&&(s=="singleClick"?t.input.mouseDown=new i0(t,o,n,!!r):(s=="doubleClick"?t0:n0)(t,o.pos,o.inside,n)?n.preventDefault():It(t,"pointer"))};class qp{constructor(e){this.view=e,this.mightDrag=null,e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this))}up(e){this.done()}move(e){e.buttons==0&&this.done()}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null)}delaySelUpdate(){return!1}}class i0 extends qp{constructor(e,n,r,i){super(e),this.pos=n,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.startDoc=e.state.doc,this.selectNode=!!r[Up],this.allowDefault=r.shiftKey;let s,o;if(n.inside>-1)s=e.state.doc.nodeAt(n.inside),o=n.inside;else{let u=e.state.doc.resolve(n.pos);s=u.parent,o=u.depth?u.before():0}const l=i?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&V(a.nodeDOM)?a.nodeDOM:null;let{selection:c}=e.state;r.button==0&&(s.type.spec.draggable&&s.type.spec.selectable!==!1||c instanceof U&&c.from<=o&&c.to>o)&&(this.mightDrag={node:s,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Ze&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),It(e,"pointer")}done(){super.done(),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>{this.view.isDestroyed||$t(this.view)})}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(gi(e))),this.updateAllowDefault(e),this.allowDefault||!n?It(this.view,"pointer"):e0(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||_e&&this.mightDrag&&!this.mightDrag.node.isAtom||Re&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(yi(this.view,J.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):It(this.view,"pointer")}move(e){this.updateAllowDefault(e),It(this.view,"pointer"),super.move(e)}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}delaySelUpdate(){return this.allowDefault?(this.delayedSelectionSync=!0,!0):!1}}class s0 extends qp{constructor(e,n){super(e),this.startSelection=n,this.startDoc=e.state.doc}move(e){if(e.buttons==0||this.view.isDestroyed||!this.view.state.doc.eq(this.startDoc)){this.done();return}e.preventDefault(),It(this.view,"pointer");let n=this.view.posAtCoords(gi(e)),r=n&&Vp(this.view,n.inside,!1);if(!r)return;let{doc:i}=this.view.state,s=this.startSelection,[o,l]=r.from<s.from?[s.to,r.from]:[s.from,r.to];yi(this.view,q.create(i,o,l))}}Ve.touchstart=t=>{t.input.lastTouch=Date.now(),$a(t),It(t,"pointer")};Ve.touchmove=t=>{t.input.lastTouch=Date.now(),It(t,"pointer")};Ve.contextmenu=t=>$a(t);function Wp(t,e){return t.composing?!0:_e&&Math.abs(Date.now()-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const o0=Lt?5e3:-1;Ue.compositionstart=Ue.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof q&&e.selection.empty&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||Re&&Sp&&l0(t)))t.markCursor=t.state.storedMarks||n.marks(),ds(t,!0),t.markCursor=null;else if(ds(t,!e.selection.empty),Ze&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let i=r.focusNode,s=r.focusOffset;i&&V(i)&&s!=0;){let o=s<0?i.lastChild:i.childNodes[s-1];if(!o)break;if(we(o)){let l=t.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else i=o,s=-1}}t.input.composing=!0}Kp(t,o0)};function l0(t){let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(!e||!V(e)||n>=e.childNodes.length)return!1;let r=e.childNodes[n];return V(r)&&r.contentEditable=="false"}Ue.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Date.now(),t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.badSafariComposition?t.domObserver.forceFlush():t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,Kp(t,20))};function Kp(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>ds(t),e))}function Yp(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Date.now());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function a0(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=Qy(e.focusNode,e.focusOffset),r=eb(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let i=r.pmViewDesc,s=t.domObserver.lastChangedTextNode;if(n==s||r==s)return s;if(!i||!i.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let o=n.pmViewDesc;if(!(!o||!o.isText(n.nodeValue)))return r}}return n||r}function ds(t,e=!1){if(!(Lt&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),Yp(t),e||t.docView&&t.docView.dirty){let n=La(t),r=t.state.selection;return n&&!n.eq(r)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function c0(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const si=Ke&&rn<15||or&&ib<604;Ve.copy=Ue.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let s=si?null:n.clipboardData,o=r.content(),{dom:l,text:a}=Ra(t,o);s?(n.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):c0(t,l),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function u0(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function d0(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?oi(t,r.value,null,i,e):oi(t,r.textContent,r.innerHTML,i,e)},50)}function oi(t,e,n,r,i){let s=Bp(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",a=>a(t,i,s||_.empty)))return!0;if(!s)return!1;let o=u0(s),l=o?t.state.tr.replaceSelectionWith(o,r):t.state.tr.replaceSelection(s);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Gp(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}Ue.paste=(t,e)=>{let n=e;if(t.composing&&!Lt)return;let r=si?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&oi(t,Gp(r),r.getData("text/html"),i,n)?n.preventDefault():d0(t,n)};class Jp{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const f0=it?"altKey":"ctrlKey";function Xp(t,e){let n;return t.someProp("dragCopies",r=>{n=n||r(e)}),n!=null?!n:!e[f0]}Ve.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=t.state.selection,s=i.empty?null:t.posAtCoords(gi(n)),o;if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof U?i.to-1:i.to))){if(r&&r.mightDrag)o=U.create(t.state.doc,r.mightDrag.pos);else if(n.target&&V(n.target)){let d=t.docView.nearestDesc(n.target,!0);d&&d.node.type.spec.draggable&&d!=t.docView&&(o=U.create(t.state.doc,d.posBefore))}}let l=(o||t.state.selection).content(),{dom:a,text:c,slice:u}=Ra(t,l);(!n.dataTransfer.files.length||!Re||xp>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(si?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",si||n.dataTransfer.setData("text/plain",c),t.dragging=new Jp(u,Xp(t,n),o)};Ve.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Ue.dragover=Ue.dragenter=(t,e)=>e.preventDefault();Ue.drop=(t,e)=>{try{p0(t,e,t.dragging)}finally{t.dragging=null}};function p0(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(gi(e));if(!r)return;let i=t.state.doc.resolve(r.pos),s=n&&n.slice;s?t.someProp("transformPasted",h=>{s=h(s,t,!1)}):s=Bp(t,Gp(e.dataTransfer),si?null:e.dataTransfer.getData("text/html"),!1,i);let o=!!(n&&Xp(t,e));if(t.someProp("handleDrop",h=>h(t,e,s||_.empty,o))){e.preventDefault();return}if(!s)return;e.preventDefault();let l=s?Zf(t.state.doc,i.pos,s):i.pos;l==null&&(l=i.pos);let a=t.state.tr;if(o){let{node:h}=n;h?h.replace(a):a.deleteSelection()}let c=a.mapping.map(l),u=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,d=a.doc;if(u?a.replaceRangeWith(c,c,s.content.firstChild):a.replaceRange(c,c,s),a.doc.eq(d))return;let p=a.doc.resolve(c);if(u&&U.isSelectable(s.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(s.content.firstChild))a.setSelection(new U(p));else{let h=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((g,b,x,w)=>h=w),a.setSelection(Ia(t,p,a.doc.resolve(h)))}t.focus(),t.dispatch(a.setMeta("uiEvent","drop"))}Ve.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&$t(t)},20))};Ve.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};Ve.beforeinput=(t,e)=>{if(Lt&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",s=>s(t,xn(8,"Backspace")))))return;let{$cursor:i}=t.state.selection;i&&i.pos>0&&t.dispatch(t.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let t in Ue)Ve[t]=Ue[t];function li(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}class fs{constructor(e,n){this.toDOM=e,this.spec=n||Nn,this.side=this.spec.side||0}map(e,n,r,i){let{pos:s,deleted:o}=e.mapResult(n.from+i,this.side<0?-1:1);return o?null:new He(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof fs&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&li(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class ln{constructor(e,n){this.attrs=e,this.spec=n||Nn}map(e,n,r,i){let s=e.map(n.from+i,this.spec.inclusiveStart?-1:1)-r,o=e.map(n.to+i,this.spec.inclusiveEnd?1:-1)-r;return s>=o?null:new He(s,o,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof ln&&li(this.attrs,e.attrs)&&li(this.spec,e.spec)}static is(e){return e.type instanceof ln}destroy(){}}class Ba{constructor(e,n){this.attrs=e,this.spec=n||Nn}map(e,n,r,i){let s=e.mapResult(n.from+i,1);if(s.deleted)return null;let o=e.mapResult(n.to+i,-1);return o.deleted||o.pos<=s.pos?null:new He(s.pos-r,o.pos-r,this)}valid(e,n){let{index:r,offset:i}=e.content.findIndex(n.from),s;return i==n.from&&!(s=e.child(r)).isText&&i+s.nodeSize==n.to}eq(e){return this==e||e instanceof Ba&&li(this.attrs,e.attrs)&&li(this.spec,e.spec)}destroy(){}}class He{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new He(e,n,this.type)}eq(e,n=0){return this.type.eq(e.type)&&this.from+n==e.from&&this.to+n==e.to}map(e,n,r){return this.type.map(e,this,n,r)}static widget(e,n,r){return new He(e,e,new fs(n,r))}static inline(e,n,r,i){return new He(e,n,new ln(r,i))}static node(e,n,r,i){return new He(e,n,new Ba(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof ln}get widget(){return this.type instanceof fs}}const Gn=[],Nn={};class ne{constructor(e,n){this.local=e.length?e:Gn,this.children=n.length?n:Gn}static create(e,n){return n.length?ps(n,e,0,Nn):$e}find(e,n,r){let i=[];return this.findInner(e??0,n??1e9,i,0,r),i}findInner(e,n,r,i,s){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=n&&l.to>=e&&(!s||s(l.spec))&&r.push(l.copy(l.from+i,l.to+i))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<n&&this.children[o+1]>e){let l=this.children[o]+1;this.children[o+2].findInner(e-l,n-l,r,i+l,s)}}map(e,n,r){return this==$e||e.maps.length==0?this:this.mapInner(e,n,0,0,r||Nn)}mapInner(e,n,r,i,s){let o;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,i);a&&a.type.valid(n,a)?(o||(o=[])).push(a):s.onRemove&&s.onRemove(this.local[l].spec)}return this.children.length?h0(this.children,o||[],e,n,r,i,s):o?new ne(o.sort(On),Gn):$e}add(e,n){return n.length?this==$e?ne.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let i,s=0;e.forEach((l,a)=>{let c=a+r,u;if(u=Qp(n,l,c)){for(i||(i=this.children.slice());s<i.length&&i[s]<a;)s+=3;i[s]==a?i[s+2]=i[s+2].addInner(l,u,c+1):i.splice(s,0,a,a+l.nodeSize,ps(u,l,c+1,Nn)),s+=3}});let o=Zp(s?eh(n):n,-r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new ne(o.length?this.local.concat(o).sort(On):this.local,i||this.children)}remove(e){return e.length==0||this==$e?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,i=this.local;for(let s=0;s<r.length;s+=3){let o,l=r[s]+n,a=r[s+1]+n;for(let u=0,d;u<e.length;u++)(d=e[u])&&d.from>l&&d.to<a&&(e[u]=null,(o||(o=[])).push(d));if(!o)continue;r==this.children&&(r=this.children.slice());let c=r[s+2].removeInner(o,l+1);c!=$e?r[s+2]=c:(r.splice(s,3),s-=3)}if(i.length){for(let s=0,o;s<e.length;s++)if(o=e[s])for(let l=0;l<i.length;l++)i[l].eq(o,n)&&(i==this.local&&(i=this.local.slice()),i.splice(l--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new ne(i,r):$e}forChild(e,n){if(this==$e)return this;if(n.isLeaf)return ne.empty;let r,i;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let s=e+1,o=s+n.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<o&&a.to>s&&a.type instanceof ln){let c=Math.max(s,a.from)-s,u=Math.min(o,a.to)-s;c<u&&(i||(i=[])).push(a.copy(c,u))}}if(i){let l=new ne(i.sort(On),Gn);return r?new Qt([l,r]):l}return r||$e}eq(e){if(this==e)return!0;if(!(e instanceof ne)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(e.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=e.children[n]||this.children[n+1]!=e.children[n+1]||!this.children[n+2].eq(e.children[n+2]))return!1;return!0}locals(e){return _a(this.localsInner(e))}localsInner(e){if(this==$e)return Gn;if(e.inlineContent||!this.local.some(ln.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof ln||n.push(this.local[r]);return n}forEachSet(e){e(this)}}ne.empty=new ne([],[]);ne.removeOverlap=_a;const $e=ne.empty;class Qt{constructor(e){this.members=e}map(e,n){const r=this.members.map(i=>i.map(e,n,Nn));return Qt.from(r)}forChild(e,n){if(n.isLeaf)return ne.empty;let r=[];for(let i=0;i<this.members.length;i++){let s=this.members[i].forChild(e,n);s!=$e&&(s instanceof Qt?r=r.concat(s.members):r.push(s))}return Qt.from(r)}eq(e){if(!(e instanceof Qt)||e.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(e.members[n]))return!1;return!0}locals(e){let n,r=!0;for(let i=0;i<this.members.length;i++){let s=this.members[i].localsInner(e);if(s.length)if(!n)n=s;else{r&&(n=n.slice(),r=!1);for(let o=0;o<s.length;o++)n.push(s[o])}}return n?_a(r?n:n.sort(On)):Gn}static from(e){switch(e.length){case 0:return $e;case 1:return e[0];default:return new Qt(e.every(n=>n instanceof ne)?e:e.reduce((n,r)=>n.concat(r instanceof ne?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function h0(t,e,n,r,i,s,o){let l=t.slice();for(let c=0,u=s;c<n.maps.length;c++){let d=0;n.maps[c].forEach((p,h,g,b)=>{let x=b-g-(h-p);for(let w=0;w<l.length;w+=3){let A=l[w+1];if(A<0||p>A+u-d)continue;let R=l[w]+u-d;h>=R?l[w+1]=p<=R?-2:-1:p>=u&&x&&(l[w]+=x,l[w+1]+=x)}d+=x}),u=n.maps[c].map(u,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let u=n.map(t[c]+s),d=u-i;if(d<0||d>=r.content.size){a=!0;continue}let p=n.map(t[c+1]+s,-1),h=p-i,{index:g,offset:b}=r.content.findIndex(d),x=r.maybeChild(g);if(x&&b==d&&b+x.nodeSize==h){let w=l[c+2].mapInner(n,x,u+1,t[c]+s+1,o);w!=$e?(l[c]=d,l[c+1]=h,l[c+2]=w):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=m0(l,t,e,n,i,s,o),u=ps(c,r,0,o);e=u.local;for(let d=0;d<l.length;d+=3)l[d+1]<0&&(l.splice(d,3),d-=3);for(let d=0,p=0;d<u.children.length;d+=3){let h=u.children[d];for(;p<l.length&&l[p]<h;)p+=3;l.splice(p,0,u.children[d],u.children[d+1],u.children[d+2])}}return new ne(e.sort(On),l)}function Zp(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let i=t[r];n.push(new He(i.from+e,i.to+e,i.type))}return n}function m0(t,e,n,r,i,s,o){function l(a,c){for(let u=0;u<a.local.length;u++){let d=a.local[u].map(r,i,c);d?n.push(d):o.onRemove&&o.onRemove(a.local[u].spec)}for(let u=0;u<a.children.length;u+=3)l(a.children[u+2],a.children[u]+c+1)}for(let a=0;a<t.length;a+=3)t[a+1]==-1&&l(t[a+2],e[a]+s+1);return n}function Qp(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,i=null;for(let s=0,o;s<t.length;s++)(o=t[s])&&o.from>n&&o.to<r&&((i||(i=[])).push(o),t[s]=null);return i}function eh(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function ps(t,e,n,r){let i=[],s=!1;e.forEach((l,a)=>{let c=Qp(t,l,a+n);if(c){s=!0;let u=ps(c,l,n+a+1,r);u!=$e&&i.push(a,a+l.nodeSize,u)}});let o=Zp(s?eh(t):t,-n).sort(On);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||(r.onRemove&&r.onRemove(o[l].spec),o.splice(l--,1));return o.length||i.length?new ne(o,i):$e}function On(t,e){return t.from-e.from||t.to-e.to}function _a(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let i=n+1;i<e.length;i++){let s=e[i];if(s.from==r.from){s.to!=r.to&&(e==t&&(e=t.slice()),e[i]=s.copy(s.from,r.to),Du(e,i+1,s.copy(r.to,s.to)));continue}else{s.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,s.from),Du(e,i,r.copy(s.from,r.to)));break}}}return e}function Du(t,e,n){for(;e<t.length&&On(n,t[e])>0;)e++;t.splice(e,0,n)}function cl(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=$e&&e.push(r)}),t.cursorWrapper&&e.push(ne.create(t.state.doc,[t.cursorWrapper.deco])),Qt.from(e)}const g0={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},y0=Ke&&rn<=11;class b0{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class k0{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new b0,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;i<r.length;i++)this.queue.push(r[i]);Ke&&rn<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():_e&&e.composing&&r.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),y0&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,g0)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let n=0;n<e.length;n++)this.queue.push(e[n]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(Au(this.view)){if(this.suppressingSelectionUpdates)return $t(this.view);if(Ke&&rn<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Rn(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,r;for(let s=e.focusNode;s;s=sr(s))n.add(s);for(let s=e.anchorNode;s;s=sr(s))if(n.has(s)){r=s;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:we(r)?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&Au(e)&&!this.ignoreSelectionChange(r),s=-1,o=-1,l=!1,a=[];if(e.editable)for(let u=0;u<n.length;u++){let d=this.registerMutation(n[u],a);d&&(s=s<0?d.from:Math.min(d.from,s),o=o<0?d.to:Math.max(d.to,o),d.typeOver&&(l=!0))}if(a.some(u=>u.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46||Re&&(e.composing||e.input.compositionEndedAt>Date.now()-50)&&n.some(u=>u.type=="childList"&&u.removedNodes.length))){for(let u of a)if(u.nodeName=="BR"&&u.parentNode){let d=u.nextSibling;for(;d&&V(d);){if(d.contentEditable=="false"){u.parentNode.removeChild(u);break}d=d.firstChild}}}else if(Ze&&a.length){let u=a.filter(d=>d.nodeName=="BR");if(u.length==2){let[d,p]=u;d.parentNode&&d.parentNode.parentNode==p.parentNode?p.remove():d.remove()}else{let{focusNode:d}=this.currentSelection;for(let p of u){let h=p.parentNode;h&&h.nodeName=="LI"&&(!d||w0(e,d)!=h)&&p.remove()}}}let c=null;s<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&oo(r)&&(c=La(e))&&c.eq(J.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,$t(e),this.currentSelection.set(r),e.scrollToSelection()):(s>-1||i)&&(s>-1&&(e.docView.markDirty(s,o),x0(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,C0(e,a)),this.handleDOMChange(s,o,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||$t(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let u=0;u<e.addedNodes.length;u++){let d=e.addedNodes[u];n.push(d),we(d)&&(this.lastChangedTextNode=d)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let i=e.previousSibling,s=e.nextSibling;if(Ke&&rn<=11&&e.addedNodes.length)for(let u=0;u<e.addedNodes.length;u++){let{previousSibling:d,nextSibling:p}=e.addedNodes[u];(!d||Array.prototype.indexOf.call(e.addedNodes,d)<0)&&(i=d),(!p||Array.prototype.indexOf.call(e.addedNodes,p)<0)&&(s=p)}let o=i&&i.parentNode==e.target?Oe(i)+1:0,l=r.localPosFromDOM(e.target,o,-1),a=s&&s.parentNode==e.target?Oe(s):e.target.childNodes.length,c=r.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let Pu=new WeakMap,$u=!1;function x0(t){if(!Pu.has(t)&&(Pu.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=Ze,$u)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."),$u=!0}}function Bu(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,s=e.endOffset,o=t.domAtPos(t.state.selection.anchor);return Rn(o.node,o.offset,i,s)&&([n,r,i,s]=[i,s,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:s}}function S0(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return Bu(t,i)}let n;function r(i){i.preventDefault(),i.stopImmediatePropagation(),n=i.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",r,!0),n?Bu(t,n):null}function w0(t,e){for(let n=e.parentNode;n&&n!=t.dom;n=n.parentNode){let r=t.docView.nearestDesc(n,!0);if(r&&r.node.isBlock)return n}return null}function C0(t,e){var n;let{focusNode:r,focusOffset:i}=t.domSelectionRange();for(let s of e)if(((n=s.parentNode)===null||n===void 0?void 0:n.nodeName)=="TR"){let o=s.nextSibling;for(;o&&o.nodeName!="TD"&&o.nodeName!="TH";)o=o.nextSibling;if(o){let l=o;for(;;){let a=l.firstChild;if(!a||!V(a)||a.contentEditable=="false"||/^(BR|IMG)$/.test(a.nodeName))break;l=a}l.insertBefore(s,l.firstChild),r==s&&t.domSelection().collapse(s,i)}else s.parentNode.removeChild(s)}}function v0(t,e,n,r){let{node:i,fromOffset:s,toOffset:o,from:l,to:a}=t.docView.parseRange(e,n),c=t.domSelectionRange(),u,d=c.anchorNode;if(d&&Dn(t.dom,d)&&(u=[{node:d,offset:c.anchorOffset}],oo(c)||u.push({node:c.focusNode,offset:c.focusOffset})),Re&&t.input.lastKeyCode===8)for(let w=o;w>s;w--){let A=i.childNodes[w-1],R=A.pmViewDesc;if(A.nodeName=="BR"&&!R){o=w;break}if(!R||R.size)break}let p=t.state.doc,h=t.someProp("domParser")||nn.fromSchema(t.state.schema),g=p.resolve(l),b=null,x=h.parse(i,{topNode:g.parent,topMatch:g.parent.contentMatchAt(g.index()),topOpen:!0,from:s,to:o,preserveWhitespace:g.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:M0(r),context:g});if(u&&u[0].pos!=null){let w=u[0].pos,A=u[1]&&u[1].pos;A==null&&(A=w),b={anchor:w+l,head:A+l}}return{doc:x,sel:b,from:l,to:a}}const M0=t=>e=>{let n=e.pmViewDesc;if(n)return n.parseRule(t);if(e.nodeName=="BR"&&e.parentNode){if(_e&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let r=document.createElement("div");return r.appendChild(document.createElement("li")),{skip:r}}else if(e.parentNode.lastChild==e||_e&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName=="IMG"&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null},T0=/^(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 A0(t,e,n,r,i){let s=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let H=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,Q=La(t,H);if(Q&&!t.state.selection.eq(Q)){if(Re&&Lt&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",ye=>ye(t,xn(13,"Enter"))))return;let te=t.state.tr.setSelection(Q);H=="pointer"?te.setMeta("pointer",!0):H=="key"&&te.scrollIntoView(),s&&te.setMeta("composition",s),t.dispatch(te)}return}let o=t.state.doc.resolve(e),l=o.sharedDepth(n);e=o.before(l+1),n=t.state.doc.resolve(n).after(l+1);let a=t.state.selection,c=v0(t,e,n,i),u=t.state.doc,d=u.slice(c.from,c.to),p,h;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(p=t.state.selection.to,h="end"):(p=t.state.selection.from,h="start"),t.input.lastKeyCode=null;let g=L0(d.content,c.doc.content,c.from,p,h);if(g&&t.input.domChangeCount++,(or&&t.input.lastIOSEnter>Date.now()-225||Lt)&&i.some(H=>V(H)&&!T0.test(H.nodeName))&&(!g||g.endA>=g.endB)&&t.someProp("handleKeyDown",H=>H(t,xn(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!g)if(r&&a instanceof q&&!a.empty&&a.$head.sameParent(a.$anchor)&&!t.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))g={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let H=_u(t,t.state.doc,c.sel);if(H&&!H.eq(t.state.selection)){let Q=t.state.tr.setSelection(H);s&&Q.setMeta("composition",s),t.dispatch(Q)}}return}t.state.selection.from<t.state.selection.to&&g.start==g.endB&&t.state.selection instanceof q&&(g.start>t.state.selection.from&&g.start<=t.state.selection.from+2&&t.state.selection.from>=c.from?g.start=t.state.selection.from:g.endA<t.state.selection.to&&g.endA>=t.state.selection.to-2&&t.state.selection.to<=c.to&&(g.endB+=t.state.selection.to-g.endA,g.endA=t.state.selection.to)),Ke&&rn<=11&&g.endB==g.start+1&&g.endA==g.start&&g.start>c.from&&c.doc.textBetween(g.start-c.from-1,g.start-c.from+1)=="  "&&(g.start--,g.endA--,g.endB--);let b=c.doc.resolveNoCache(g.start-c.from),x=c.doc.resolveNoCache(g.endB-c.from),w=u.resolve(g.start),A=b.sameParent(x)&&b.parent.inlineContent&&w.end()>=g.endA;if((or&&t.input.lastIOSEnter>Date.now()-225&&(!A||i.some(H=>H.nodeName=="DIV"||H.nodeName=="P"))||!A&&O0(c.doc,b.pos,x.pos))&&t.someProp("handleKeyDown",H=>H(t,xn(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>g.start&&N0(u,g.start,g.endA,b,x)&&t.someProp("handleKeyDown",H=>H(t,xn(8,"Backspace")))){Lt&&Re&&t.domObserver.suppressSelectionUpdates();return}Re&&g.endB==g.start&&(t.input.lastChromeDelete=Date.now()),Lt&&!A&&b.start()!=x.start()&&x.parentOffset==0&&b.depth==x.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==g.endA&&(g.endB-=2,x=c.doc.resolveNoCache(g.endB-c.from),setTimeout(()=>{t.someProp("handleKeyDown",function(H){return H(t,xn(13,"Enter"))})},20));let R=g.start,O=g.endA,Y=H=>{let Q=H||t.state.tr.replace(R,O,c.doc.slice(g.start-c.from,g.endB-c.from));if(c.sel){let te=_u(t,Q.doc,c.sel);te&&!(Re&&t.composing&&te.empty&&(g.start!=g.endB||t.input.lastChromeDelete<Date.now()-100)&&(te.head==R||te.head==Q.mapping.map(O)-1)||Ke&&te.empty&&te.head==R)&&Q.setSelection(te)}return s&&Q.setMeta("composition",s),Q.scrollIntoView()},ee;if(A)if(b.pos==x.pos){Ke&&rn<=11&&b.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>$t(t),20));let H=Y(t.state.tr.delete(R,O)),Q=u.resolve(g.start).marksAcross(u.resolve(g.endA));Q&&H.ensureMarks(Q),t.dispatch(H)}else if(g.endA==g.endB&&(ee=E0(b.parent.content.cut(b.parentOffset,x.parentOffset),w.parent.content.cut(w.parentOffset,g.endA-w.start())))){let H=Y(t.state.tr);ee.type=="add"?H.addMark(R,O,ee.mark):H.removeMark(R,O,ee.mark),t.dispatch(H)}else if(b.parent.child(b.index()).isText&&b.index()==x.index()-(x.textOffset?0:1)){let H=b.parent.textBetween(b.parentOffset,x.parentOffset),Q=()=>Y(t.state.tr.insertText(H,R,O));t.someProp("handleTextInput",te=>te(t,R,O,H,Q))||t.dispatch(Q())}else t.dispatch(Y());else t.dispatch(Y())}function _u(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:Ia(t,e.resolve(n.anchor),e.resolve(n.head))}function E0(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,i=n,s=r,o,l,a;for(let u=0;u<r.length;u++)i=r[u].removeFromSet(i);for(let u=0;u<n.length;u++)s=n[u].removeFromSet(s);if(i.length==1&&s.length==0)l=i[0],o="add",a=u=>u.mark(l.addToSet(u.marks));else if(i.length==0&&s.length==1)l=s[0],o="remove",a=u=>u.mark(l.removeFromSet(u.marks));else return null;let c=[];for(let u=0;u<e.childCount;u++)c.push(a(e.child(u)));if(I.from(c).eq(t))return{mark:l,type:o}}function N0(t,e,n,r,i){if(n-e<=i.pos-r.pos||ul(r,!0,!1)<i.pos)return!1;let s=t.resolve(e);if(!r.parent.isTextblock){let l=s.nodeAfter;return l!=null&&n==e+l.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let o=t.resolve(ul(s,!0,!0));return!o.parent.isTextblock||o.pos>n||ul(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function O0(t,e,n){let r=0,i=0;return t.nodesBetween(e,n,(s,o)=>{s.isTextblock&&o>=e&&o<n?r++:(s.isText?/\S/.test(s.text.slice(Math.max(0,e-o),Math.min(s.nodeSize,n-o))):s.isLeaf)&&i++}),i==0&&r==1}function ul(t,e,n){let r=t.depth,i=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,i++,e=!1;if(n){let s=t.node(r).maybeChild(t.indexAfter(r));for(;s&&!s.isLeaf;)s=s.firstChild,i++}return i}function L0(t,e,n,r,i){let s=t.findDiffStart(e,n),o=n+t.size,l=n+e.size;if(s==null)return null;let{a,b:c}=t.findDiffEnd(e,o,l);if(i=="end"){let u=Math.max(0,s-Math.min(a,c));r-=a+u-s}if(a<s&&o<l){let u=r<=s&&r>=a?s-r:0;s-=u,c=s+(c-a),a=s}else if(c<s){let u=r<=s&&r>=c?s-r:0;s-=u,a=s+(a-c),c=s}return{start:s,endA:a,endB:c}}class th{constructor(e,n){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new Wb,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(Vu),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=Hu(this),Fu(this),this.nodeViews=ju(this),this.docView=Su(this.state.doc,zu(this),cl(this),this.dom,this),this.domObserver=new k0(this,(r,i,s,o)=>A0(this,r,i,s,o)),this.domObserver.start(),Kb(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let n in e)this._props[n]=e[n];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Gl(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Vu),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let i=this.state,s=!1,o=!1;e.storedMarks&&this.composing&&(Yp(this),o=!0),this.state=e;let l=i.plugins!=e.plugins||this._props.plugins!=n.plugins;if(l||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let h=ju(this);R0(h,this.nodeViews)&&(this.nodeViews=h,s=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&Gl(this),this.editable=Hu(this),Fu(this);let a=cl(this),c=zu(this),u=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",d=s||!this.docView.matchesNode(e.doc,c,a);(d||!e.selection.eq(i.selection))&&(o=!0);let p=u=="preserve"&&o&&this.dom.style.overflowAnchor==null&&lb(this);if(o){this.domObserver.stop();let h=d&&(Ke||Re)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&I0(i.selection,e.selection);if(d){let b=Re?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=a0(this)),(s||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Su(e.doc,c,a,this.dom,this)),b&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(h=!0)}let g=this.input.mouseDown;h||!(g&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Lb(this)&&g.delaySelUpdate())?$t(this,h):(Dp(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():p&&ab(p)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!Dn(this.dom,e))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof U){let n=this.docView.domAfterPos(this.state.selection.from);V(n)&&gu(this,n.getBoundingClientRect(),e)}else gu(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n<this.directPlugins.length;n++){let r=this.directPlugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let n=0;n<this.state.plugins.length;n++){let r=this.state.plugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let n=0;n<this.pluginViews.length;n++){let r=this.pluginViews[n];r.update&&r.update(this,e)}}updateDraggedNode(e,n){let r=e.node,i=-1;if(r.from<this.state.doc.content.size&&this.state.doc.nodeAt(r.from)==r.node)i=r.from;else{let s=r.from+(this.state.doc.content.size-n.doc.content.size);(s>0&&s<this.state.doc.content.size&&this.state.doc.nodeAt(s))==r.node&&(i=s)}this.dragging=new Jp(e.slice,e.move,i<0?void 0:U.create(this.state.doc,i))}someProp(e,n){let r=this._props&&this._props[e],i;if(r!=null&&(i=n?n(r):r))return i;for(let o=0;o<this.directPlugins.length;o++){let l=this.directPlugins[o].props[e];if(l!=null&&(i=n?n(l):l))return i}let s=this.state.plugins;if(s)for(let o=0;o<s.length;o++){let l=s[o].props[e];if(l!=null&&(i=n?n(l):l))return i}}hasFocus(){if(Ke){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&cb(this.dom),$t(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let n=this.dom.parentNode;n;n=n.parentNode)if(n.nodeType==9||n.nodeType==11&&n.host)return n.getSelection||(Object.getPrototypeOf(n).getSelection=()=>n.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return hb(this,e)}coordsAtPos(e,n=1){return Tp(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,r=-1){let i=this.docView.posFromDOM(e,n,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,n){return kb(this,n||this.state,e)}pasteHTML(e,n){return oi(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return oi(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return Ra(this,e)}destroy(){this.docView&&(Yb(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],cl(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Xy())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Jb(this,e)}domSelectionRange(){let e=this.dom.isConnected!==!1&&this.domSelection();return e?_e&&this.root.nodeType===11&&nb(this.dom.ownerDocument)==this.dom&&S0(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}th.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function zu(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(t.state)),n)for(let r in n)r=="class"?e.class+=" "+n[r]:r=="style"?e.style=(e.style?e.style+";":"")+n[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(n[r]))}),e.translate||(e.translate="no"),[He.node(0,t.state.doc.content.size,e)]}function Fu(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:He.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function Hu(t){return!t.someProp("editable",e=>e(t.state)===!1)}function I0(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}function ju(t){let e=Object.create(null);function n(r){for(let i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function R0(t,e){let n=0,r=0;for(let i in t){if(t[i]!=e[i])return!0;n++}for(let i in e)r++;return n!=r}function Vu(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")}var dn={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:"'"},hs={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},D0=typeof navigator<"u"&&/Mac/.test(navigator.platform),P0=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Le=0;Le<10;Le++)dn[48+Le]=dn[96+Le]=String(Le);for(var Le=1;Le<=24;Le++)dn[Le+111]="F"+Le;for(var Le=65;Le<=90;Le++)dn[Le]=String.fromCharCode(Le+32),hs[Le]=String.fromCharCode(Le);for(var dl in dn)hs.hasOwnProperty(dl)||(hs[dl]=dn[dl]);function $0(t){var e=D0&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||P0&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?hs:dn)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}const B0=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),_0=typeof navigator<"u"&&/Win/.test(navigator.platform);function z0(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,i,s,o;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))i=!0;else if(/^s(hift)?$/i.test(a))s=!0;else if(/^mod$/i.test(a))B0?o=!0:i=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(n="Alt-"+n),i&&(n="Ctrl-"+n),o&&(n="Meta-"+n),s&&(n="Shift-"+n),n}function F0(t){let e=Object.create(null);for(let n in t)e[z0(n)]=t[n];return e}function fl(t,e,n=!0){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n&&e.shiftKey&&(t="Shift-"+t),t}function H0(t){return new fe({props:{handleKeyDown:nh(t)}})}function nh(t){let e=F0(t);return function(n,r){let i=$0(r),s,o=e[fl(i,r)];if(o&&o(n.state,n.dispatch,n))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let l=e[fl(i,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(_0&&r.ctrlKey&&r.altKey)&&(s=dn[r.keyCode])&&s!=i){let l=e[fl(s,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var ms=200,Ae=function(){};Ae.prototype.append=function(e){return e.length?(e=Ae.from(e),!this.length&&e||e.length<ms&&this.leafAppend(e)||this.length<ms&&e.leafPrepend(this)||this.appendInner(e)):this};Ae.prototype.prepend=function(e){return e.length?Ae.from(e).append(this):this};Ae.prototype.appendInner=function(e){return new j0(this,e)};Ae.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?Ae.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};Ae.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};Ae.prototype.forEach=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(e,n,r,0):this.forEachInvertedInner(e,n,r,0)};Ae.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(s,o){return i.push(e(s,o))},n,r),i};Ae.from=function(e){return e instanceof Ae?e:e&&e.length?new rh(e):Ae.empty};var rh=(function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,s){return i==0&&s==this.length?this:new e(this.values.slice(i,s))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,s,o,l){for(var a=s;a<o;a++)if(i(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(i,s,o,l){for(var a=s-1;a>=o;a--)if(i(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=ms)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=ms)return new e(i.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e})(Ae);Ae.empty=new rh([]);var j0=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,i,s,o){var l=this.left.length;if(i<l&&this.left.forEachInner(r,i,Math.min(s,l),o)===!1||s>l&&this.right.forEachInner(r,Math.max(i-l,0),Math.min(this.length,s)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,s,o){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(r,i-l,Math.max(s,l)-l,o+l)===!1||s<l&&this.left.forEachInvertedInner(r,Math.min(i,l),s,o)===!1)return!1},e.prototype.sliceInner=function(r,i){if(r==0&&i==this.length)return this;var s=this.left.length;return i<=s?this.left.slice(r,i):r>=s?this.right.slice(r-s,i-s):this.left.slice(r,s).append(this.right.slice(0,i-s))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(Ae);const V0=500;class lt{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,s;n&&(i=this.remapping(r,this.items.length),s=i.maps.length);let o=e.tr,l,a,c=[],u=[];return this.items.forEach((d,p)=>{if(!d.step){i||(i=this.remapping(r,p+1),s=i.maps.length),s--,u.push(d);return}if(i){u.push(new ht(d.map));let h=d.step.map(i.slice(s)),g;h&&o.maybeStep(h).doc&&(g=o.mapping.maps[o.mapping.maps.length-1],c.push(new ht(g,void 0,void 0,c.length+u.length))),s--,g&&i.appendMap(g,s)}else o.maybeStep(d.step);if(d.selection)return l=i?d.selection.map(i.slice(s)):d.selection,a=new lt(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:o,selection:l}}addTransform(e,n,r,i){let s=[],o=this.eventCount,l=this.items,a=!i&&l.length?l.get(l.length-1):null;for(let u=0;u<e.steps.length;u++){let d=e.steps[u].invert(e.docs[u]),p=new ht(e.mapping.maps[u],d,n),h;(h=a&&a.merge(p))&&(p=h,u?s.pop():l=l.slice(0,l.length-1)),s.push(p),n&&(o++,n=void 0),i||(a=p)}let c=o-r.depth;return c>q0&&(l=U0(l,c),o-=c),new lt(l.append(s),o)}remapping(e,n){let r=new ri;return this.items.forEach((i,s)=>{let o=i.mirrorOffset!=null&&s-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,o)},e,n),r}addMaps(e){return this.eventCount==0?this:new lt(this.items.append(e.map(n=>new ht(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;n=Math.min(this.items.length,n);let r=[],i=this.items.length-n,s=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(p=>{p.selection&&l--},i);let a=n;this.items.forEach(p=>{let h=s.getMirror(--a);if(h==null)return;o=Math.min(o,h);let g=s.maps[h];if(p.step){let b=e.steps[h].invert(e.docs[h]),x=p.selection&&p.selection.map(s.slice(a+1,h));x&&l++,r.push(new ht(g,b,x))}else r.push(new ht(g))},i);let c=[];for(let p=n;p<o;p++)c.push(new ht(s.maps[p]));let u=this.items.slice(0,i).append(c).append(r),d=new lt(u,l);return d.emptyItemCount()>V0&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,i=[],s=0;return this.items.forEach((o,l)=>{if(l>=e)i.push(o),o.selection&&s++;else if(o.step){let a=o.step.map(n.slice(r)),c=a&&a.getMap();if(r--,c&&n.appendMap(c,r),a){let u=o.selection&&o.selection.map(n.slice(r));u&&s++;let d=new ht(c.invert(),a,u),p,h=i.length-1;(p=i.length&&i[h].merge(d))?i[h]=p:i.push(d)}}else o.map&&r--},this.items.length,0),new lt(Ae.from(i.reverse()),s)}}lt.empty=new lt(Ae.empty,0);function U0(t,e){let n;return t.forEach((r,i)=>{if(r.selection&&e--==0)return n=i,!1}),t.slice(n)}class ht{constructor(e,n,r,i){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new ht(n.getMap().invert(),n,this.selection)}}}class Jt{constructor(e,n,r,i,s){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=s}}const q0=20;function W0(t,e,n,r){let i=n.getMeta(an),s;if(i)return i.historyState;n.getMeta(ih)&&(t=new Jt(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(an))return o.getMeta(an).redo?new Jt(t.done.addTransform(n,void 0,r,Qi(e)),t.undone,Uu(n.mapping.maps),t.prevTime,t.prevComposition):new Jt(t.done,t.undone.addTransform(n,void 0,r,Qi(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let l=n.getMeta("composition"),a=t.prevTime==0||!o&&t.prevComposition!=l&&(t.prevTime<(n.time||0)-r.newGroupDelay||!K0(n,t.prevRanges)),c=o?pl(t.prevRanges,n.mapping):Uu(n.mapping.maps);return new Jt(t.done.addTransform(n,a?e.selection.getBookmark():void 0,r,Qi(e)),lt.empty,c,n.time,l??t.prevComposition)}else return(s=n.getMeta("rebased"))?new Jt(t.done.rebased(n,s),t.undone.rebased(n,s),pl(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Jt(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),pl(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function K0(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,i)=>{for(let s=0;s<e.length;s+=2)r<=e[s+1]&&i>=e[s]&&(n=!0)}),n}function Uu(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,i,s,o)=>e.push(s,o));return e}function pl(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let i=e.map(t[r],1),s=e.map(t[r+1],-1);i<=s&&n.push(i,s)}return n}function Y0(t,e,n){let r=Qi(e),i=an.get(e).spec.config,s=(n?t.undone:t.done).popEvent(e,r);if(!s)return null;let o=s.selection.resolve(s.transform.doc),l=(n?t.done:t.undone).addTransform(s.transform,e.selection.getBookmark(),i,r),a=new Jt(n?l:s.remaining,n?s.remaining:l,null,0,-1);return s.transform.setSelection(o).setMeta(an,{redo:n,historyState:a})}let hl=!1,qu=null;function Qi(t){let e=t.plugins;if(qu!=e){hl=!1,qu=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){hl=!0;break}}return hl}function G0(t){return t.setMeta(ih,!0)}const an=new xe("history"),ih=new xe("closeHistory");function J0(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new fe({key:an,state:{init(){return new Jt(lt.empty,lt.empty,null,0,-1)},apply(e,n,r){return W0(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,i=r=="historyUndo"?oh:r=="historyRedo"?lh:null;return!i||!e.editable?!1:(n.preventDefault(),i(e.state,e.dispatch))}}}})}function sh(t,e){return(n,r)=>{let i=an.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return!1;if(r){let s=Y0(i,n,t);s&&r(e?s.scrollIntoView():s)}return!0}}const oh=sh(!1,!0),lh=sh(!0,!0);function X0(t){return t.getMeta(an)!=null}function co(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:i}=n,{storedMarks:s}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return s},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,s=n.storedMarks,n}}}var er=class ah{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:e,editor:n,state:r}=this,{view:i}=n,{tr:s}=r,o=this.buildProps(s);return Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...u)=>{const d=a(...u)(o);return!s.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(s),d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,n=!0){const{rawCommands:r,editor:i,state:s}=this,{view:o}=i,l=[],a=!!e,c=e||s.tr,u=()=>(!a&&n&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&o.dispatch(c),l.every(p=>p===!0)),d={...Object.fromEntries(Object.entries(r).map(([p,h])=>[p,(...b)=>{const x=this.buildProps(c,n),w=h(...b)(x);return l.push(w),d}])),run:u};return d}static createFakeChain(){const e=new Proxy({},{get:(n,r)=>{if(r!=="then")return r==="run"?()=>!1:()=>e}});return e}createCan(e){const{rawCommands:n,state:r}=this,i=!1,s=e||r.tr,o=this.buildProps(s,i);return{...Object.fromEntries(Object.entries(n).map(([l,a])=>[l,(...c)=>a(...c)({...o,dispatch:void 0})])),chain:()=>this.createChain(s,i)}}static createFallbackCan(){const e=ah.createFakeChain();return new Proxy({chain:()=>e},{get:(n,r)=>{if(r!=="then")return r==="chain"?n.chain:()=>!1}})}buildProps(e,n=!0){const{rawCommands:r,editor:i,state:s}=this,{view:o}=i,l={tr:e,editor:i,view:o,state:co({state:s,transaction:e}),dispatch:n?()=>{}:void 0,chain:()=>this.createChain(e,n),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(r).map(([a,c])=>[a,(...u)=>c(...u)(l)]))}};return l}};const Z0=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{if(!t.isDestroyed){var n;e.dom.blur(),(n=window)===null||n===void 0||(n=n.getSelection())===null||n===void 0||n.removeAllRanges()}}),!0),Q0=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),ek=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:i}=r;return n&&i.forEach(({$from:s,$to:o})=>{t.doc.nodesBetween(s.pos,o.pos,(l,a)=>{if(l.type.isText)return;const{doc:c,mapping:u}=e,d=c.resolve(u.map(a)),p=c.resolve(u.map(a+l.nodeSize)),h=d.blockRange(p);if(!h)return;const g=pr(h);if(l.type.isTextblock){const{defaultType:b}=d.parent.contentMatchAt(d.index());e.setNodeMarkup(h.start,b)}(g||g===0)&&e.lift(h,g)})}),!0},tk=t=>e=>t(e),nk=()=>({state:t,dispatch:e})=>mp(t,e),rk=(t,e)=>({editor:n,tr:r})=>{const{state:i}=n,s=i.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const o=r.mapping.map(e);return r.insert(o,s.content),r.setSelection(new q(r.doc.resolve(Math.max(o-1,0)))),!0},ik=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const i=t.selection.$anchor;for(let s=i.depth;s>0;s-=1)if(i.node(s).type===r.type){if(e){const o=i.before(s),l=i.after(s);t.delete(o,l).scrollIntoView()}return!0}return!1};function Ce(t,e){if(typeof t=="string"){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}const sk=t=>({tr:e,state:n,dispatch:r})=>{const i=Ce(t,n.schema),s=e.selection.$anchor;for(let o=s.depth;o>0;o-=1)if(s.node(o).type===i){if(r){const l=s.before(o),a=s.after(o);e.delete(l,a).scrollIntoView()}return!0}return!1},ok=t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},lk=t=>t.content?/^text(\*|\+)/.test(t.content):!1,Wu=(t,e,n)=>{if(!t.parent.isInline||n==="left"&&t.pos>t.start()||n==="right"&&t.pos<t.end())return t.pos;const r=e.nodes[t.parent.type.name].spec;return lk(r)?n==="left"?t.start()-1:t.end()+1:t.pos},ak=(t,e,n)=>({from:Wu(t,n,"left"),to:Wu(e,n,"right")}),ck=()=>({state:t,dispatch:e})=>{if(t.selection.empty)return!1;if(e){const n=t.tr,{ranges:r}=t.selection,i=n.steps.length;r.forEach(s=>{const o=n.mapping.slice(i),l=n.doc.resolve(o.map(s.$from.pos)),a=n.doc.resolve(o.map(s.$to.pos)),{from:c,to:u}=ak(l,a,t.schema);n.deleteRange(c,u)}),n.selection.empty||n.setSelection(q.near(n.doc.resolve(n.selection.from))),n.scrollIntoView(),e(n)}return!0},uk=()=>({commands:t})=>t.keyboardShortcut("Enter"),dk=()=>({state:t,dispatch:e})=>$y(t,e);function za(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function gs(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>n.strict?e[i]===t[i]:za(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function ch(t,e,n={}){return t.find(r=>r.type===e&&gs(Object.fromEntries(Object.keys(n).map(i=>[i,r.attrs[i]])),n))}function Ku(t,e,n={}){return!!ch(t,e,n)}function Fa(t,e,n){if(!t||!e)return;let r=t.parent.childAfter(t.parentOffset);if((!r.node||!r.node.marks.some(a=>a.type===e))&&(r=t.parent.childBefore(t.parentOffset)),!r.node||!r.node.marks.some(a=>a.type===e))return;if(!n){const a=r.node.marks.find(c=>c.type===e);a&&(n=a.attrs)}if(!ch([...r.node.marks],e,n))return;let i=r.index,s=t.start()+r.offset,o=i+1,l=s+r.node.nodeSize;for(;i>0&&Ku([...t.parent.child(i-1).marks],e,n);)i-=1,s-=t.parent.child(i).nodeSize;for(;o<t.parent.childCount&&Ku([...t.parent.child(o).marks],e,n);)l+=t.parent.child(o).nodeSize,o+=1;return{from:s,to:l}}function Ft(t,e){if(typeof t=="string"){if(!e.marks[t])throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`);return e.marks[t]}return t}const fk=(t,e)=>({tr:n,state:r,dispatch:i})=>{const s=Ft(t,r.schema),{doc:o,selection:l}=n,{$from:a,from:c,to:u}=l;if(i){const d=Fa(a,s,e);if(d&&d.from<=c&&d.to>=u){const p=q.create(o,d.from,d.to);n.setSelection(p)}}return!0},pk=t=>e=>{const n=typeof t=="function"?t(e):t;for(let r=0;r<n.length;r+=1)if(n[r](e))return!0;return!1};function uh(t){return t instanceof q}function Cn(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function Jl(t,e=null){if(!e)return null;const n=J.atStart(t),r=J.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const i=n.from,s=r.to;return e==="all"?q.create(t,Cn(0,i,s),Cn(t.content.size,i,s)):q.create(t,Cn(e,i,s),Cn(e,i,s))}function Yu(){return["Android"].includes(navigator.platform)||/android/i.test(navigator.userAgent)}function ys(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function hk(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}const mk=(t=null,e={})=>({editor:n,view:r,tr:i,dispatch:s})=>{e={scrollIntoView:!0,...e};const o=()=>{(ys()||Yu())&&r.dom.focus(),hk()&&!ys()&&!Yu()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e!=null&&e.scrollIntoView&&n.commands.scrollIntoView())})};try{if(r.hasFocus()&&t===null||t===!1)return!0}catch{return!1}if(s&&t===null&&!uh(n.state.selection))return o(),!0;const l=Jl(i.doc,t)||n.state.selection,a=n.state.selection.eq(l);return s&&(a||i.setSelection(l),a&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},gk=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),yk=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),dh=t=>{const e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){const r=e[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?t.removeChild(r):r.nodeType===1&&dh(r)}return t};function Fi(t){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`<body>${t}</body>`,n=new window.DOMParser().parseFromString(e,"text/html").body;return dh(n)}function fh(t){return typeof(t==null?void 0:t.nodesBetween)=="function"}function lr(t,e,n){if(fh(t))return t;const r=typeof t=="object"&&t!==null;n={slice:!0,parseOptions:{},...n};const i=typeof t=="string";if(r)try{if(Array.isArray(t)&&t.length>0)return I.fromArray(t.map(o=>e.nodeFromJSON(o)));const s=e.nodeFromJSON(t);return n.errorOnInvalidContent&&s.check(),s}catch(s){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:s});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",s),lr("",e,n)}if(i){if(n.errorOnInvalidContent){let o=!1,l="";const a=new Hf({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(o=!0,l=typeof c=="string"?c:c.outerHTML,null)}]}})});if(n.slice?nn.fromSchema(a).parseSlice(Fi(t),n.parseOptions):nn.fromSchema(a).parse(Fi(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const s=nn.fromSchema(e);return n.slice?s.parseSlice(Fi(t),n.parseOptions).content:s.parse(Fi(t),n.parseOptions)}return lr("",e,n)}function ph(t){return!("type"in t)}function hh(t,e,n){const r=t.steps.length-1;if(r<e)return;const i=t.steps[r];if(!(i instanceof me||i instanceof Te))return;const s=t.mapping.maps[r];let o=0;s.forEach((l,a,c,u)=>{o===0&&(o=u)}),t.setSelection(J.near(t.doc.resolve(o),n))}const bk=(t,e,n)=>({tr:r,dispatch:i,editor:s})=>{if(i){n={parseOptions:s.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let l;const a=x=>{s.emit("contentError",{editor:s,error:x,disableCollaboration:()=>{"collaboration"in s.storage&&typeof s.storage.collaboration=="object"&&s.storage.collaboration&&(s.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!s.options.enableContentCheck&&s.options.emitContentError)try{lr(e,s.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(x){a(x)}try{var o;l=lr(e,s.schema,{parseOptions:c,errorOnInvalidContent:(o=n.errorOnInvalidContent)!==null&&o!==void 0?o:s.options.enableContentCheck})}catch(x){return a(x),!1}let{from:u,to:d}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},p=!0,h=!0;const g=ph(l)?l.content:[l];if(g.forEach(x=>{x.check(),p=p?x.isText&&x.marks.length===0:!1,h=h?x.isBlock:!1}),u===d&&h){const{parent:x}=r.doc.resolve(u);x.isTextblock&&!x.type.spec.code&&!x.childCount&&(u-=1,d+=1)}let b;if(p)Array.isArray(e)?b=e.map(x=>x.text||"").join(""):fh(e)?b=g.map(x=>{var w;return(w=x.text)!==null&&w!==void 0?w:""}).join(""):typeof e=="object"&&e&&e.text?b=e.text:b=e,r.insertText(b,u,d);else{b=I.from(g);const x=r.doc.resolve(u),w=x.node(),A=x.parentOffset===0,R=w.isText||w.isTextblock,O=w.content.size>0;A&&R&&O&&h&&(u=Math.max(0,u-1)),r.replaceWith(u,d,g)}n.updateSelection&&hh(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:u,text:b}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:u,text:b})}return!0};function mh(t){for(let e=0;e<t.edgeCount;e+=1){const{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}const kk=(t={})=>({tr:e,dispatch:n,editor:r})=>{const{pos:i,attrs:s,content:o,updateSelection:l=!0}=t;let a;typeof i=="number"?a=e.doc.resolve(i):i?a=i:a=e.selection.$from;const c=mh(a.parent.contentMatchAt(a.index()));if(!c)return!1;const u=Object.keys(c.spec.attrs||{}),d=s?Object.fromEntries(Object.entries(s).filter(([h])=>u.includes(h))):{};let p;if(o){const h=lr(o,r.schema);p=c.createAndFill(d,h)}else p=c.createAndFill(d);return p?(n&&(e.insert(a.pos,p),l&&hh(e,e.steps.length-1,-1)),!0):!1},xk=()=>({state:t,dispatch:e})=>Ry(t,e),Sk=()=>({state:t,dispatch:e})=>Dy(t,e),wk=()=>({state:t,dispatch:e})=>ap(t,e),Ck=()=>({state:t,dispatch:e})=>fp(t,e),gh=(t,e)=>{const n=t.resolve(e),r=n.nodeBefore,i=n.nodeAfter;return!r||!i?!1:!r.type.spec.isolating&&!i.type.spec.isolating},vk=()=>({state:t,dispatch:e,tr:n})=>{try{const r=ro(t.doc,t.selection.$from.pos,-1);return r==null||!gh(t.doc,r)?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},Mk=()=>({state:t,dispatch:e,tr:n})=>{try{const r=ro(t.doc,t.selection.$from.pos,1);return r==null||!gh(t.doc,r)?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},Tk=()=>({state:t,dispatch:e})=>Ly(t,e),Ak=()=>({state:t,dispatch:e})=>Iy(t,e);function yh(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function Ek(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,i,s,o;for(let l=0;l<e.length-1;l+=1){const a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))i=!0;else if(/^s(hift)?$/i.test(a))s=!0;else if(/^mod$/i.test(a))ys()||yh()?o=!0:i=!0;else throw new Error(`Unrecognized modifier name: ${a}`)}return r&&(n=`Alt-${n}`),i&&(n=`Ctrl-${n}`),o&&(n=`Meta-${n}`),s&&(n=`Shift-${n}`),n}const Nk=t=>({editor:e,view:n,tr:r,dispatch:i})=>{const s=Ek(t).split(/-(?!$)/),o=s.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),l=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.includes("Shift"),bubbles:!0,cancelable:!0}),a=e.captureTransaction(()=>{n.someProp("handleKeyDown",c=>c(n,l))});return a==null||a.steps.forEach(c=>{const u=c.map(r.mapping);u&&i&&r.maybeStep(u)}),!0};function _t(t,e,n={}){const{from:r,to:i,empty:s}=t.selection,o=e?Ce(e,t.schema):null,l=[];t.doc.nodesBetween(r,i,(u,d)=>{if(u.isText)return;const p=Math.max(r,d),h=Math.min(i,d+u.nodeSize);l.push({node:u,from:p,to:h})});const a=i-r,c=l.filter(u=>o?o.name===u.node.type.name:!0).filter(u=>gs(u.node.attrs,n,{strict:!1}));return s?!!c.length:c.reduce((u,d)=>u+d.to-d.from,0)>=a}const Ok=(t,e={})=>({state:n,dispatch:r})=>_t(n,Ce(t,n.schema),e)?Py(n,r):!1,Lk=()=>({state:t,dispatch:e})=>gp(t,e),Ik=t=>({state:e,dispatch:n})=>{const r=Ce(t,e.schema);return Ky(r)(e,n)},Rk=()=>({state:t,dispatch:e})=>hp(t,e);function uo(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function Gu(t,e){const n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((r,i)=>(n.includes(i)||(r[i]=t[i]),r),{})}const Dk=(t,e)=>({tr:n,state:r,dispatch:i})=>{let s=null,o=null;const l=uo(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(s=Ce(t,r.schema)),l==="mark"&&(o=Ft(t,r.schema));let a=!1;return n.selection.ranges.forEach(c=>{r.doc.nodesBetween(c.$from.pos,c.$to.pos,(u,d)=>{s&&s===u.type&&(a=!0,i&&n.setNodeMarkup(d,void 0,Gu(u.attrs,e))),o&&u.marks.length&&u.marks.forEach(p=>{o===p.type&&(a=!0,i&&n.addMark(d,d+u.nodeSize,o.create(Gu(p.attrs,e))))})})}),a},Pk=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),$k=()=>({tr:t,dispatch:e})=>{if(e){const n=new Xe(t.doc);t.setSelection(n)}return!0},Bk=()=>({state:t,dispatch:e})=>up(t,e),_k=()=>({state:t,dispatch:e})=>pp(t,e),zk=()=>({state:t,dispatch:e})=>zy(t,e),Fk=()=>({state:t,dispatch:e})=>jy(t,e),Hk=()=>({state:t,dispatch:e})=>Hy(t,e);function Xl(t,e,n={},r={}){return lr(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}const jk=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:i,tr:s,dispatch:o,commands:l})=>{const{doc:a}=s;if(r.preserveWhitespace!=="full"){const c=Xl(t,i.schema,r,{errorOnInvalidContent:e??i.options.enableContentCheck});if(o){const u=ph(c)?c.content:[c];s.replaceWith(0,a.content.size,u).setMeta("preventUpdate",!n)}return!0}return o&&s.setMeta("preventUpdate",!n),l.insertContentAt({from:0,to:a.content.size},t,{parseOptions:r,errorOnInvalidContent:e??i.options.enableContentCheck})};function bh(t,e){const n=Ft(e,t.schema),{from:r,to:i,empty:s}=t.selection,o=[];s?(t.storedMarks&&o.push(...t.storedMarks),o.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,i,a=>{o.push(...a.marks)});const l=o.find(a=>a.type.name===n.name);return l?{...l.attrs}:{}}function kh(t,e){const n=new rp(t);return e.forEach(r=>{r.steps.forEach(i=>{n.step(i)})}),n}function Vk(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(i,s)=>{n(i)&&r.push({node:i,pos:s})}),r}function Uk(t,e){for(let n=t.depth;n>0;n-=1){const r=t.node(n);if(e(r))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:r}}}function fo(t){return e=>Uk(e.$from,t)}function j(t,e,n){return t.config[e]===void 0&&t.parent?j(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?j(t.parent,e,n):null}):t.config[e]}function Ha(t){return t.map(e=>{const n=j(e,"addExtensions",{name:e.name,options:e.options,storage:e.storage});return n?[e,...Ha(n())]:e}).flat(10)}function ja(t,e){const n=Bn.fromSchema(e).serializeFragment(t),r=document.implementation.createHTMLDocument().createElement("div");return r.appendChild(n),r.innerHTML}function Zl(t){return typeof t=="function"}function re(t,e=void 0,...n){return Zl(t)?e?t.bind(e)(...n):t(...n):t}function qk(t={}){return Object.keys(t).length===0&&t.constructor===Object}function ar(t){return{baseExtensions:t.filter(e=>e.type==="extension"),nodeExtensions:t.filter(e=>e.type==="node"),markExtensions:t.filter(e=>e.type==="mark")}}function xh(t){const e=[],{nodeExtensions:n,markExtensions:r}=ar(t),i=[...n,...r],s={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},o=n.filter(c=>c.name!=="text").map(c=>c.name),l=r.map(c=>c.name),a=[...o,...l];return t.forEach(c=>{const u=j(c,"addGlobalAttributes",{name:c.name,options:c.options,storage:c.storage,extensions:i});u&&u().forEach(d=>{let p;Array.isArray(d.types)?p=d.types:d.types==="*"?p=a:d.types==="nodes"?p=o:d.types==="marks"?p=l:p=[],p.forEach(h=>{Object.entries(d.attributes).forEach(([g,b])=>{e.push({type:h,name:g,attribute:{...s,...b}})})})})}),i.forEach(c=>{const u=j(c,"addAttributes",{name:c.name,options:c.options,storage:c.storage});if(!u)return;const d=u();Object.entries(d).forEach(([p,h])=>{const g={...s,...h};typeof(g==null?void 0:g.default)=="function"&&(g.default=g.default()),g!=null&&g.isRequired&&(g==null?void 0:g.default)===void 0&&delete g.default,e.push({type:c.name,name:p,attribute:g})})}),e}function Wk(t){const e=[];let n="",r=!1,i=!1,s=0;const o=t.length;for(let l=0;l<o;l+=1){const a=t[l];if(a==="'"&&!i){r=!r,n+=a;continue}if(a==='"'&&!r){i=!i,n+=a;continue}if(!r&&!i){if(a==="("){s+=1,n+=a;continue}if(a===")"&&s>0){s-=1,n+=a;continue}if(a===";"&&s===0){e.push(n),n="";continue}}n+=a}return n&&e.push(n),e}function Ju(t){const e=[],n=Wk(t||""),r=n.length;for(let i=0;i<r;i+=1){const s=n[i],o=s.indexOf(":");if(o===-1)continue;const l=s.slice(0,o).trim(),a=s.slice(o+1).trim();l&&a&&e.push([l,a])}return e}function be(...t){return t.filter(e=>!!e).reduce((e,n)=>{const r={...e};return Object.entries(n).forEach(([i,s])=>{if(i==="__proto__"){Object.defineProperty(r,i,{configurable:!0,enumerable:!0,value:s,writable:!0});return}if(!r[i]){r[i]=s;return}if(i==="class"){const o=s?String(s).split(" "):[],l=r[i]?r[i].split(" "):[],a=o.filter(c=>!l.includes(c));r[i]=[...l,...a].join(" ")}else if(i==="style"){const o=new Map([...Ju(r[i]),...Ju(s)]);r[i]=Array.from(o.entries()).map(([l,a])=>`${l}: ${a}`).join("; ")}else r[i]=s}),r},{})}function ai(t,e){return e.filter(n=>n.type===t.type.name).filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(t.attrs)||{}:{[n.name]:t.attrs[n.name]}).reduce((n,r)=>be(n,r),{})}function Kk(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function Xu(t,e){return"style"in t?t:{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;const i=e.reduce((s,o)=>{const l=o.attribute.parseHTML?o.attribute.parseHTML(n):Kk(n.getAttribute(o.name));return l==null?s:{...s,[o.name]:l}},{});return{...r,...i}}}}function Zu(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&qk(n)?!1:n!=null))}function Qu(t){var e,n;const r={};return!(!(t==null||(e=t.attribute)===null||e===void 0)&&e.isRequired)&&"default"in((t==null?void 0:t.attribute)||{})&&(r.default=t.attribute.default),(t==null||(n=t.attribute)===null||n===void 0?void 0:n.validate)!==void 0&&(r.validate=t.attribute.validate),[t.name,r]}function Yk(t,e){var n;const r=xh(t),{nodeExtensions:i,markExtensions:s}=ar(t),o=(n=i.find(c=>j(c,"topNode")))===null||n===void 0?void 0:n.name,l=Object.fromEntries(i.map(c=>{const u=r.filter(x=>x.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:e},p=Zu({...t.reduce((x,w)=>{const A=j(w,"extendNodeSchema",d);return{...x,...A?A(c):{}}},{}),content:re(j(c,"content",d)),marks:re(j(c,"marks",d)),group:re(j(c,"group",d)),inline:re(j(c,"inline",d)),atom:re(j(c,"atom",d)),selectable:re(j(c,"selectable",d)),draggable:re(j(c,"draggable",d)),code:re(j(c,"code",d)),whitespace:re(j(c,"whitespace",d)),linebreakReplacement:re(j(c,"linebreakReplacement",d)),defining:re(j(c,"defining",d)),isolating:re(j(c,"isolating",d)),attrs:Object.fromEntries(u.map(Qu))}),h=re(j(c,"parseHTML",d));h&&(p.parseDOM=h.map(x=>Xu(x,u)));const g=j(c,"renderHTML",d);g&&(p.toDOM=x=>g({node:x,HTMLAttributes:ai(x,u)}));const b=j(c,"renderText",d);return b&&(p.toText=b),[c.name,p]})),a=Object.fromEntries(s.map(c=>{const u=r.filter(b=>b.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:e},p=Zu({...t.reduce((b,x)=>{const w=j(x,"extendMarkSchema",d);return{...b,...w?w(c):{}}},{}),inclusive:re(j(c,"inclusive",d)),excludes:re(j(c,"excludes",d)),group:re(j(c,"group",d)),spanning:re(j(c,"spanning",d)),code:re(j(c,"code",d)),attrs:Object.fromEntries(u.map(Qu))}),h=re(j(c,"parseHTML",d));h&&(p.parseDOM=h.map(b=>Xu(b,u)));const g=j(c,"renderHTML",d);return g&&(p.toDOM=b=>g({mark:b,HTMLAttributes:ai(b,u)})),[c.name,p]}));return new Hf({topNode:o,nodes:l,marks:a})}function Gk(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function Hr(t){return t.sort((n,r)=>{const i=j(n,"priority")||100,s=j(r,"priority")||100;return i>s?-1:i<s?1:0})}function Sh(t){const e=Hr(Ha(t)),n=Gk(e.map(r=>r.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(r=>`'${r}'`).join(", ")}]. This can lead to issues.`),e}function wh(t,e,n){const{from:r,to:i}=e,{blockSeparator:s=`
55
+
56
+ `,textSerializers:o={}}=n||{};let l="";return t.nodesBetween(r,i,(a,c,u,d)=>{a.isBlock&&c>r&&(l+=s);const p=o==null?void 0:o[a.type.name];if(p)return u&&(l+=p({node:a,pos:c,parent:u,index:d,range:e})),!1;if(a.isText){var h;l+=a==null||(h=a.text)===null||h===void 0?void 0:h.slice(Math.max(r,c)-c,i-c)}}),l}function Jk(t,e){return wh(t,{from:0,to:t.content.size},e)}function Ch(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function Xk(t,e){const n=Ce(e,t.schema),{from:r,to:i}=t.selection,s=[];t.doc.nodesBetween(r,i,l=>{s.push(l)});const o=s.reverse().find(l=>l.type.name===n.name);return o?{...o.attrs}:{}}function vh(t,e){const n=uo(typeof e=="string"?e:e.name,t.schema);return n==="node"?Xk(t,e):n==="mark"?bh(t,e):{}}function Zk(t,e=JSON.stringify){const n={};return t.filter(r=>{const i=e(r);return Object.prototype.hasOwnProperty.call(n,i)?!1:n[i]=!0})}function Qk(t){const e=Zk(t);return e.length===1?e:e.filter((n,r)=>!e.filter((i,s)=>s!==r).some(i=>n.oldRange.from>=i.oldRange.from&&n.oldRange.to<=i.oldRange.to&&n.newRange.from>=i.newRange.from&&n.newRange.to<=i.newRange.to))}function po(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((i,s)=>{const o=[];if(i.ranges.length)i.forEach((l,a)=>{o.push({from:l,to:a})});else{const{from:l,to:a}=n[s];if(l===void 0||a===void 0)return;o.push({from:l,to:a})}o.forEach(({from:l,to:a})=>{const c=e.slice(s).map(l,-1),u=e.slice(s).map(a),d=e.invert().map(c,-1),p=e.invert().map(u);r.push({oldRange:{from:d,to:p},newRange:{from:c,to:u}})})}),Qk(r)}function ho(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(i=>{const s=Fa(n.resolve(t),i.type);s&&r.push({mark:i,...s})}):n.nodesBetween(t,e,(i,s)=>{!i||(i==null?void 0:i.nodeSize)===void 0||r.push(...i.marks.map(o=>({from:s,to:s+i.nodeSize,mark:o})))}),r}const ex=(t,e,n,r=20)=>{const i=t.doc.resolve(n);let s=r,o=null;for(;s>0&&o===null;){const l=i.node(s);(l==null?void 0:l.type.name)===e?o=l:s-=1}return[o,s]},tx=t=>{const e=t.depth-1;if(e<0)return null;const n=t.index(e);return n===0?null:t.node(e).child(n-1)};function qn(t,e){return e.nodes[t]||e.marks[t]||null}function es(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const i=t.find(s=>s.type===e&&s.name===r);return i?i.attribute.keepOnSplit:!1}))}const nx=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(i,s,o,l)=>{var a,c;const u=((a=(c=i.type.spec).toText)===null||a===void 0?void 0:a.call(c,{node:i,pos:s,parent:o,index:l}))||i.textContent||"%leaf%";n+=i.isAtom&&!i.isText?u:u.slice(0,Math.max(0,r-s))}),n};function Ql(t,e,n={}){const{empty:r,ranges:i}=t.selection,s=e?Ft(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(u=>s?s.name===u.type.name:!0).find(u=>gs(u.attrs,n,{strict:!1}));let o=0;const l=[];if(i.forEach(({$from:u,$to:d})=>{const p=u.pos,h=d.pos;t.doc.nodesBetween(p,h,(g,b)=>{if(s&&g.inlineContent&&!g.type.allowsMarkType(s))return!1;if(!g.isText&&!g.marks.length)return;const x=Math.max(p,b),w=Math.min(h,b+g.nodeSize),A=w-x;o+=A,l.push(...g.marks.map(R=>({mark:R,from:x,to:w})))})}),o===0)return!1;const a=l.filter(u=>s?s.name===u.mark.type.name:!0).filter(u=>gs(u.mark.attrs,n,{strict:!1})).reduce((u,d)=>u+d.to-d.from,0),c=l.filter(u=>s?u.mark.type!==s&&u.mark.type.excludes(s):!0).reduce((u,d)=>u+d.to-d.from,0);return(a>0?a+c:a)>=o}function rx(t,e,n={}){if(!e)return _t(t,null,n)||Ql(t,null,n);const r=uo(e,t.schema);return r==="node"?_t(t,e,n):r==="mark"?Ql(t,e,n):!1}const ix=(t,e)=>{const{$from:n,$to:r,$anchor:i}=t.selection;if(e){const s=fo(l=>l.type.name===e)(t.selection);if(!s)return!1;const o=t.doc.resolve(s.pos+1);return i.pos+1===o.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},sx=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function ed(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function ml(t,e){const{nodeExtensions:n}=ar(e),r=n.find(s=>s.name===t);if(!r)return!1;const i=re(j(r,"group",{name:r.name,options:r.options,storage:r.storage}));return typeof i!="string"?!1:i.split(" ").includes("list")}function bi(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){if(n){if(t.type.name==="hardBreak")return!0;if(t.isText){var r;return!/\S/.test((r=t.text)!==null&&r!==void 0?r:"")}}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let i=!0;return t.content.forEach(s=>{i!==!1&&(bi(s,{ignoreWhitespace:n,checkChildren:e})||(i=!1))}),i}return!1}function Mh(t){return t instanceof U}var Th=class Ah{constructor(e){this.position=e}static fromJSON(e){return new Ah(e.position)}toJSON(){return{position:this.position}}};function ox(t,e){const n=e.mapping.mapResult(t.position);return{position:new Th(n.pos),mapResult:n}}function lx(t){return new Th(t)}function ax(t,e,n){const{selection:r}=e;let i=null;if(uh(r)&&(i=r.$cursor),i){var s;const l=(s=t.storedMarks)!==null&&s!==void 0?s:i.marks();return i.parent.type.allowsMarkType(n)&&(!!n.isInSet(l)||!l.some(a=>a.type.excludes(n)))}const{ranges:o}=r;return o.some(({$from:l,$to:a})=>{let c=l.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(l.pos,a.pos,(u,d,p)=>{if(c)return!1;if(u.isInline){const h=!p||p.type.allowsMarkType(n),g=!!n.isInSet(u.marks)||!u.marks.some(b=>b.type.excludes(n));c=h&&g}return!c}),c})}const cx=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:s}=n,{empty:o,ranges:l}=s,a=Ft(t,r.schema);if(i)if(o){const c=bh(r,a);n.addStoredMark(a.create({...c,...e}))}else l.forEach(c=>{const u=c.$from.pos,d=c.$to.pos;r.doc.nodesBetween(u,d,(p,h)=>{const g=Math.max(h,u),b=Math.min(h+p.nodeSize,d);p.marks.find(x=>x.type===a)?p.marks.forEach(x=>{a===x.type&&n.addMark(g,b,a.create({...x.attrs,...e}))}):n.addMark(g,b,a.create(e))})});return ax(r,n,a)},ux=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),dx=(t,e={})=>({state:n,dispatch:r,chain:i})=>{const s=Ce(t,n.schema);let o;return n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),s.isTextblock?i().command(({commands:l})=>pu(s,{...o,...e})(n)?!0:l.clearNodes()).command(({state:l})=>pu(s,{...o,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},fx=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,i=Cn(t,0,r.content.size),s=U.create(r,i);e.setSelection(s)}return!0},px=(t,e)=>({tr:n,state:r,dispatch:i})=>{const{selection:s}=r;let o,l;return typeof e=="number"?(o=e,l=e):e&&"from"in e&&"to"in e?(o=e.from,l=e.to):(o=s.from,l=s.to),i&&n.doc.nodesBetween(o,l,(a,c)=>{a.isText||n.setNodeMarkup(c,void 0,{...a.attrs,dir:t})}),!0},hx=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:i,to:s}=typeof t=="number"?{from:t,to:t}:t,o=q.atStart(r).from,l=q.atEnd(r).to,a=Cn(i,o,l),c=Cn(s,o,l),u=q.create(r,a,c);e.setSelection(u)}return!0},mx=t=>({state:e,dispatch:n})=>{const r=Ce(t,e.schema);return Jy(r)(e,n)};function td(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const r=n.filter(i=>e==null?void 0:e.includes(i.type.name));t.tr.ensureMarks(r)}}const gx=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:i})=>{const{selection:s,doc:o}=e,{$from:l,$to:a}=s,c=i.extensionManager.attributes,u=es(c,l.node().type.name,l.node().attrs);if(s instanceof U&&s.node.isBlock)return!l.parentOffset||!Pt(o,l.pos)?!1:(r&&(t&&td(n,i.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const d=a.parentOffset===a.parent.content.size,p=l.depth===0?void 0:mh(l.node(-1).contentMatchAt(l.indexAfter(-1)));let h=d&&p?[{type:p,attrs:u}]:void 0;const g=s instanceof q&&!s.empty?Ot.create({doc:e.doc,selection:s}).tr.deleteSelection():null,b=g?g.doc:e.doc,x=g?g.mapping.map(l.pos):l.pos;let w=Pt(b,x,1,h);if(!h&&!w&&Pt(b,x,1,p?[{type:p}]:void 0)&&(w=!0,h=p?[{type:p,attrs:u}]:void 0),r){if(w){const A=e.steps.length;if(s instanceof q&&e.deleteSelection(),e.split(e.mapping.slice(A).map(l.pos),1,h),p&&!d&&!l.parentOffset&&l.parent.type!==p){const R=e.mapping.slice(A).map(l.before()),O=e.doc.resolve(R);l.node(-1).canReplaceWith(O.index(),O.index()+1,p)&&e.setNodeMarkup(e.mapping.slice(A).map(l.before()),p)}}t&&td(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return w},yx=(t,e={})=>({tr:n,state:r,dispatch:i,editor:s})=>{const o=Ce(t,r.schema),{$from:l,$to:a}=r.selection,c=r.selection.node;if(c&&c.isBlock||l.depth<2||!l.sameParent(a))return!1;const u=l.node(-1);if(u.type!==o)return!1;const d=s.extensionManager.attributes;if(l.parent.content.size===0&&l.node(-1).childCount===l.indexAfter(-1)){if(l.depth===2||l.node(-3).type!==o||l.index(-2)!==l.node(-2).childCount-1)return!1;if(i){var p;let O=I.empty;const Y=l.index(-1)?1:l.index(-2)?2:3;for(let Me=l.depth-Y;Me>=l.depth-3;Me-=1)O=I.from(l.node(Me).copy(O));const ee=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,H={...es(d,l.node().type.name,l.node().attrs),...e},Q=((p=o.contentMatch.defaultType)===null||p===void 0?void 0:p.createAndFill(H))||void 0;O=O.append(I.from(o.createAndFill(null,Q)||void 0));const te=l.before(l.depth-(Y-1));n.replace(te,l.after(-ee),new _(O,4-Y,0));let ye=-1;n.doc.nodesBetween(te,n.doc.content.size,(Me,et)=>{if(ye>-1)return!1;Me.isTextblock&&Me.content.size===0&&(ye=et+1)}),ye>-1&&n.setSelection(q.near(n.doc.resolve(ye))),n.scrollIntoView()}return!0}const h=a.pos===l.end()?u.contentMatchAt(0).defaultType:null,g={...es(d,u.type.name,u.attrs),...e},b={...es(d,l.node().type.name,l.node().attrs),...e},x=l.parentOffset===0&&l.index(-1)===0,w=l.before(-1);n.delete(l.pos,a.pos);const A=x?u.attrs:g,R=h?[{type:o,attrs:A},{type:h,attrs:b}]:[{type:o,attrs:A}];if(!Pt(n.doc,l.pos,2))return!1;if(i){const{selection:O,storedMarks:Y}=r,{splittableMarks:ee}=s.extensionManager,H=Y||O.$to.parentOffset&&O.$from.marks();if(n.split(l.pos,2,R).scrollIntoView(),x&&n.setNodeMarkup(w,void 0,g),!H||!i)return!0;const Q=H.filter(te=>ee.includes(te.type.name));n.ensureMarks(Q)}return!0};function nd(t){return!t||t==="1"?null:t}function Eh(t,e){return nd(t)===nd(e)}const gl=(t,e)=>{const n=fo(s=>s.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;const i=t.doc.nodeAt(r);return!(n.node.type===(i==null?void 0:i.type)&&hn(t.doc,n.pos))||!Eh(n.node.attrs.type,i==null?void 0:i.attrs.type)||t.join(n.pos),!0},yl=(t,e)=>{const n=fo(s=>s.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;const i=t.doc.nodeAt(r);return!(n.node.type===(i==null?void 0:i.type)&&hn(t.doc,r))||!Eh(n.node.attrs.type,i==null?void 0:i.attrs.type)||t.join(r),!0};function bx(t){const e=t.doc,n=e.firstChild;if(!n)return null;const r=e.resolve(1),i=e.resolve(n.nodeSize-1);return q.between(r,i)}const kx=(t,e,n,r={})=>({editor:i,tr:s,state:o,dispatch:l,chain:a,commands:c,can:u})=>{const{extensions:d,splittableMarks:p}=i.extensionManager,h=Ce(t,o.schema),g=Ce(e,o.schema),{selection:b,storedMarks:x}=o,{$from:w,$to:A}=b,R=w.blockRange(A),O=x||b.$to.parentOffset&&b.$from.marks();if(!R)return!1;const Y=fo(Ee=>ml(Ee.type.name,d))(b),ee=b.from===0&&b.to===o.doc.content.size,H=o.doc.content.content,Q=H.length===1?H[0]:null,te=ee&&Q&&ml(Q.type.name,d)?{node:Q,pos:0}:null,ye=Y??te,Me=!!Y&&R.depth>=1&&R.depth-Y.depth<=1,et=!!te;if((Me||et)&&ye){if(ye.node.type===h)return ee&&et?a().command(({tr:Ee,dispatch:le})=>{const De=bx(Ee);return De?(Ee.setSelection(De),le&&le(Ee),!0):!1}).liftListItem(g).run():c.liftListItem(g);if(ml(ye.node.type.name,d)&&h.validContent(ye.node.content))return a().command(()=>(s.setNodeMarkup(ye.pos,h),!0)).command(()=>gl(s,h)).command(()=>yl(s,h)).run()}return!n||!O||!l?a().command(()=>u().wrapInList(h,r)?!0:c.clearNodes()).wrapInList(h,r).command(()=>gl(s,h)).command(()=>yl(s,h)).run():a().command(()=>{const Ee=u().wrapInList(h,r),le=O.filter(De=>p.includes(De.type.name));return s.ensureMarks(le),Ee?!0:c.clearNodes()}).wrapInList(h,r).command(()=>gl(s,h)).command(()=>yl(s,h)).run()},xx=(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:s=!1}=n,o=Ft(t,r.schema);return Ql(r,o,e)?i.unsetMark(o,{extendEmptyMarkRange:s}):i.setMark(o,e)},Sx=(t,e,n={})=>({state:r,commands:i})=>{const s=Ce(t,r.schema),o=Ce(e,r.schema),l=_t(r,s,n);let a;return r.selection.$anchor.sameParent(r.selection.$head)&&(a=r.selection.$anchor.parent.attrs),l?i.setNode(o,a):i.setNode(s,{...a,...n})},wx=(t,e={})=>({state:n,commands:r})=>{const i=Ce(t,n.schema);return _t(n,i,e)?r.lift(i):r.wrapIn(i,e)},Cx=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const i=n[r];let s;if(i.spec.isInputRules&&(s=i.getState(t))){if(e){const o=t.tr,l=s.transform;for(let a=l.steps.length-1;a>=0;a-=1)o.step(l.steps[a].invert(l.docs[a]));if(s.text){const a=o.doc.resolve(s.from).marks();o.replaceWith(s.from,s.to,t.schema.text(s.text,a))}else o.delete(s.from,s.to)}return!0}}return!1},vx=(t={})=>({tr:e,dispatch:n,editor:r})=>{const{ignoreClearable:i=!1}=t,{selection:s}=e,{empty:o,ranges:l}=s;if(o)return!0;const{nonClearableMarks:a}=r.extensionManager;if(n){const c=Object.values(r.schema.marks).filter(u=>i||!a.includes(u.name));l.forEach(u=>{for(const d of c)e.removeMark(u.$from.pos,u.$to.pos,d)})}return!0},Mx=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{extendEmptyMarkRange:s=!1}=e,{selection:o}=n,l=Ft(t,r.schema),{$from:a,empty:c,ranges:u}=o;if(!i)return!0;if(c&&s){var d;let{from:p,to:h}=o;const g=Fa(a,l,(d=a.marks().find(b=>b.type===l))===null||d===void 0?void 0:d.attrs);g&&(p=g.from,h=g.to),n.removeMark(p,h,l)}else u.forEach(p=>{n.removeMark(p.$from.pos,p.$to.pos,l)});return n.removeStoredMark(l),!0},Tx=t=>({tr:e,state:n,dispatch:r})=>{const{selection:i}=n;let s,o;return typeof t=="number"?(s=t,o=t):t&&"from"in t&&"to"in t?(s=t.from,o=t.to):(s=i.from,o=i.to),r&&e.doc.nodesBetween(s,o,(l,a)=>{if(l.isText)return;const c={...l.attrs};delete c.dir,e.setNodeMarkup(a,void 0,c)}),!0},Ax=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let s=null,o=null;const l=uo(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(s=Ce(t,r.schema)),l==="mark"&&(o=Ft(t,r.schema));let a=!1;return n.selection.ranges.forEach(c=>{const u=c.$from.pos,d=c.$to.pos;let p,h,g,b;n.selection.empty?r.doc.nodesBetween(u,d,(x,w)=>{s&&s===x.type&&(a=!0,g=Math.max(w,u),b=Math.min(w+x.nodeSize,d),p=w,h=x)}):r.doc.nodesBetween(u,d,(x,w)=>{w<u&&s&&s===x.type&&(a=!0,g=Math.max(w,u),b=Math.min(w+x.nodeSize,d),p=w,h=x),w>=u&&w<=d&&(s&&s===x.type&&(a=!0,i&&n.setNodeMarkup(w,void 0,{...x.attrs,...e})),o&&x.marks.length&&x.marks.forEach(A=>{if(o===A.type&&(a=!0,i)){const R=Math.max(w,u),O=Math.min(w+x.nodeSize,d);n.addMark(R,O,o.create({...A.attrs,...e}))}}))}),h&&(p!==void 0&&i&&n.setNodeMarkup(p,void 0,{...h.attrs,...e}),o&&h.marks.length&&h.marks.forEach(x=>{o===x.type&&i&&n.addMark(g,b,o.create({...x.attrs,...e}))}))}),a},Jn=new xe("__tiptap_decorations__"),Ex=t=>({tr:e,dispatch:n})=>(n&&e.setMeta(Jn,{type:"force",name:t}),!0),Nx=(t,e={})=>({state:n,dispatch:r})=>{const i=Ce(t,n.schema);return Vy(i,e)(n,r)},Ox=(t,e={})=>({state:n,dispatch:r})=>{const i=Ce(t,n.schema);return Uy(i,e)(n,r)};var Lx=Pg({blur:()=>Z0,clearContent:()=>Q0,clearNodes:()=>ek,command:()=>tk,createParagraphNear:()=>nk,cut:()=>rk,deleteCurrentNode:()=>ik,deleteNode:()=>sk,deleteRange:()=>ok,deleteSelection:()=>ck,enter:()=>uk,exitCode:()=>dk,extendMarkRange:()=>fk,first:()=>pk,focus:()=>mk,forEach:()=>gk,insertContent:()=>yk,insertContentAt:()=>bk,insertDefaultBlock:()=>kk,joinBackward:()=>wk,joinDown:()=>Sk,joinForward:()=>Ck,joinItemBackward:()=>vk,joinItemForward:()=>Mk,joinTextblockBackward:()=>Tk,joinTextblockForward:()=>Ak,joinUp:()=>xk,keyboardShortcut:()=>Nk,lift:()=>Ok,liftEmptyBlock:()=>Lk,liftListItem:()=>Ik,newlineInCode:()=>Rk,resetAttributes:()=>Dk,scrollIntoView:()=>Pk,selectAll:()=>$k,selectNodeBackward:()=>Bk,selectNodeForward:()=>_k,selectParentNode:()=>zk,selectTextblockEnd:()=>Fk,selectTextblockStart:()=>Hk,setContent:()=>jk,setMark:()=>cx,setMeta:()=>ux,setNode:()=>dx,setNodeSelection:()=>fx,setTextDirection:()=>px,setTextSelection:()=>hx,sinkListItem:()=>mx,splitBlock:()=>gx,splitListItem:()=>yx,toggleList:()=>kx,toggleMark:()=>xx,toggleNode:()=>Sx,toggleWrap:()=>wx,undoInputRule:()=>Cx,unsetAllMarks:()=>vx,unsetMark:()=>Mx,unsetTextDirection:()=>Tx,updateAttributes:()=>Ax,updateDecorations:()=>Ex,wrapIn:()=>Nx,wrapInList:()=>Ox});const Mr=new WeakMap;function Ix(t,e){var n;Mr.set(t,((n=Mr.get(t))!==null&&n!==void 0?n:0)+1);try{return e()}finally{var r;const i=((r=Mr.get(t))!==null&&r!==void 0?r:1)-1;i>0?Mr.set(t,i):Mr.delete(t)}}var Rx=class{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){const n=this.callbacks[t];return n&&n.forEach(r=>r.apply(this,e)),this}off(t,e){const n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter(r=>r!==e):delete this.callbacks[t]),this}once(t,e){const n=(...r)=>{this.off(t,n),e.apply(this,r)};return this.on(t,n)}removeAllListeners(){this.callbacks={}}};function Dx(t){return t.kind==="widget"}function Nh(t,e){const n=[],r=new Set;for(const i of t)i.kind==="widget"&&Dx(i)&&r.add(i.key),n.push(i.toPMDecoration(e));return{decorations:n,widgetKeys:r}}function Px(t,e,n){const{decorations:r,widgetKeys:i}=Nh(e,n);return{set:ne.create(t,r),widgetKeys:i}}function Oh({position:t,from:e,to:n,docSize:r}){return t<e?!1:t<n?!0:t===n&&n===r}function $x({decorations:t,from:e,to:n,docSize:r,extensionName:i,warnedExtensions:s}){return t.filter(o=>Oh({position:o.anchor,from:e,to:n,docSize:r})?!0:(o.anchor===n||s.has(i)||(s.add(i),console.warn(`[tiptap warn]: Extension "${i}" returned a decoration outside the requested range [${e}, ${n}). It was ignored.`)),!1))}function Bx(t){var e;const n=(e=t.spec)===null||e===void 0?void 0:e.key;return typeof n=="string"?n:void 0}function Lh(t){return t.jsonID==="attr"}function _x(t){let e=!1;if(t.getMap().forEach(()=>{e=!0}),e||Lh(t))return!0;const n=t;return typeof n.from=="number"&&typeof n.to=="number"}function zx(t,e){let n=null,r=0,i=0;for(let s=0;s<t.childCount&&!(i>e.to);s+=1){const o=i+t.child(s).nodeSize;o>=e.from&&(n===null&&(n=i),r=o),i=o}return n===null?null:{from:n,to:r}}function Fx(t,e){if(t.steps.some(s=>!_x(s)))return{type:"full"};const n=po(t).map(({newRange:s})=>s);t.steps.forEach((s,o)=>{if(!Lh(s))return;const l=t.mapping.slice(o);n.push({from:l.map(s.pos,-1),to:l.map(s.pos+1)})});const r=[];for(const s of n){const o=zx(e,s);o&&r.push(o)}r.sort((s,o)=>s.from-o.from);const i=[];for(const s of r){const o=i[i.length-1];o&&s.from<=o.to?o.to=Math.max(o.to,s.to):i.push({...s})}return{type:"ranges",ranges:i}}function Ih(t,e,n,r){return t.map(e,n,{onRemove:i=>{const s=i==null?void 0:i.key;typeof s=="string"&&r.delete(s)}})}function Hx(t,e,n){var r,i;const s=(r=e.decorationSetsByExtension[t])!==null&&r!==void 0?r:ne.empty,o=new Set((i=e.widgetKeysByExtension[t])!==null&&i!==void 0?i:[]);return{set:Ih(s,n.mapping,n.doc,o),widgetKeys:o}}function rd(t,e){const n=Object.values(e).flatMap(r=>r.find());return ne.create(t,n)}function id(t){const e=new Set;for(const n of Object.values(t))for(const r of n)e.add(r);return e}function jx(t,e){var n;switch((n=e.update)!==null&&n!==void 0?n:"document"){case"document":if(e.createInRange)throw new Error(`[tiptap error]: Extension "${t}" provides createInRange() but does not use the "changedRanges" decoration update strategy.`);return;case"changedRanges":if(!e.createInRange)throw new Error(`[tiptap error]: Extension "${t}" uses the "changedRanges" decoration update strategy but does not provide createInRange().`);return;case"manual":if(e.createInRange)throw new Error(`[tiptap error]: Extension "${t}" uses the "manual" decoration update strategy, which is not compatible with createInRange(). createInRange() requires the "changedRanges" strategy.`);if(e.shouldUpdate)throw new Error(`[tiptap error]: Extension "${t}" cannot combine the "manual" decoration update strategy with shouldUpdate().`);return;default:throw new Error(`[tiptap error]: Extension "${t}" uses an unknown decoration update strategy. Expected "document", "changedRanges", or "manual".`)}}function Vx(t,e,n){return n?!0:t.update==="manual"?!1:t.shouldUpdate?t.shouldUpdate(e):e.tr.docChanged}const Ux=new Set;var qx=class{constructor(t){this.warnedWidgetKeys=new Set,this.warnedOutOfRangeExtensions=new Set,this.handleBeforeTransaction=({nextState:e})=>{const n=Jn.getState(e);n&&this.warnDuplicateWidgetKeys(n)},this.editor=t.editor,this.entries=this.resolveEntries(t.entries),this.entries.forEach(({name:e,spec:n})=>jx(e,n)),this.plugin=this.entries.length>0?this.createPlugin():null,this.editor.on("beforeTransaction",this.handleBeforeTransaction)}destroy(){this.editor.off("beforeTransaction",this.handleBeforeTransaction)}liveWidgetKeys(){var t,e;return(t=(e=Jn.getState(this.editor.state))===null||e===void 0?void 0:e.widgetKeys)!==null&&t!==void 0?t:Ux}get mountedView(){return this.editor.isDestroyed?null:this.editor.view}resolveEntries(t){const e=[];for(const{name:n,addDecorations:r}of t){const i=r();i&&e.push({name:n,spec:i})}return e}createPlugin(){const{editor:t,entries:e}=this;return new fe({key:Jn,state:{init:(n,r)=>{const i={},s={};for(const{name:l,spec:a}of e){const{set:c,widgetKeys:u}=this.buildFullSet(l,a,r);i[l]=c,s[l]=u}const o={decorationSetsByExtension:i,widgetKeysByExtension:s,mergedDecorationSet:this.buildMergedSet(r.doc,i),widgetKeys:id(s)};return this.warnDuplicateWidgetKeys(o),o},apply:(n,r,i,s)=>{const o=n.getMeta(Jn),l=(o==null?void 0:o.type)==="force"&&!o.name,a=(o==null?void 0:o.type)==="force"?o.name:void 0,c={},u={},d=new Set;return Ix(t,()=>{for(const{name:p,spec:h}of e){const g=l||a===p;if(Vx(h,{editor:t,tr:n,oldState:i,newState:s},g))if(h.update==="changedRanges"&&n.docChanged&&!g){const b=this.applyChangedRangesRecompute(p,h,r,n,s);c[p]=b.set,u[p]=b.widgetKeys,d.add(p)}else{const{set:b,widgetKeys:x}=this.buildFullSet(p,h,s);c[p]=b,u[p]=x,d.add(p)}else{const b=Hx(p,r,n);c[p]=b.set,u[p]=b.widgetKeys}}}),d.size===0&&!n.docChanged?r:{decorationSetsByExtension:c,widgetKeysByExtension:u,mergedDecorationSet:this.mergeAfterApply({entries:e,previous:r,tr:n,decorationSetsByExtension:c,recomputedNames:d}),widgetKeys:id(u)}}},props:{decorations(n){var r,i;return(r=(i=Jn.getState(n))===null||i===void 0?void 0:i.mergedDecorationSet)!==null&&r!==void 0?r:ne.empty}}})}applyChangedRangesRecompute(t,e,n,r,i){const s=Fx(r,i.doc);return s.type==="full"?this.buildFullSet(t,e,i):this.rebuildRanges(t,e,n,r,i,s.ranges)}rebuildRanges(t,e,n,r,i,s){var o,l;const a=(o=n.decorationSetsByExtension[t])!==null&&o!==void 0?o:ne.empty,c=new Set((l=n.widgetKeysByExtension[t])!==null&&l!==void 0?l:[]);let u=Ih(a,r.mapping,r.doc,c);const d=i.doc.content.size;for(const{from:p,to:h}of s){const g=u.find(p,h).filter(w=>Oh({position:w.from,from:p,to:h,docSize:d}));for(const w of g){const A=Bx(w);A&&c.delete(A)}u=u.remove(g);const{decorations:b,widgetKeys:x}=Nh($x({decorations:this.runCreate(t,"createInRange",()=>e.createInRange({editor:this.editor,state:i,view:this.mountedView,from:p,to:h})),from:p,to:h,docSize:d,extensionName:t,warnedExtensions:this.warnedOutOfRangeExtensions}),t);u=u.add(i.doc,b);for(const w of x)c.add(w)}return{set:u,widgetKeys:c}}buildFullSet(t,e,n){const r=this.runCreate(t,"create",()=>e.create({editor:this.editor,state:n,view:this.mountedView}));return Px(n.doc,r,t)}runCreate(t,e,n){try{return n()}catch(r){return console.error(`[tiptap error]: Extension "${t}" threw in \`addDecorations().${e}()\`. Its decorations were dropped for this update.`,r),[]}}warnDuplicateWidgetKeys(t){}buildMergedSet(t,e){const n=Object.keys(e);return n.length===1?e[n[0]]:rd(t,e)}mergeAfterApply({entries:t,previous:e,tr:n,decorationSetsByExtension:r,recomputedNames:i}){return t.length===1?r[t[0].name]:i.size===0?e.mergedDecorationSet.map(n.mapping,n.doc):rd(n.doc,r)}};function Wx(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof U){const s=r.index();return r.parent.canReplaceWith(s,s+1,e)}let i=r.depth;for(;i>=0;){const s=r.index(i);if(r.node(i).contentMatchAt(s).matchType(e))return!0;i-=1}return!1}function Kx(t,e,n){const r=document.querySelector("style[data-tiptap-style]");if(r!==null)return r;const i=document.createElement("style");return e&&i.setAttribute("nonce",e),i.setAttribute("data-tiptap-style",""),i.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(i),i}function ki(t,e){const n=t.getAttribute("style");if(!n)return null;const r=n.split(";").map(s=>s.trim()).filter(Boolean),i=e.toLowerCase();for(let s=r.length-1;s>=0;s-=1){const o=r[s],l=o.indexOf(":");if(l!==-1&&o.slice(0,l).trim().toLowerCase()===i)return o.slice(l+1).trim()}return null}function Yx(t){return typeof t=="number"}function Gx(t){return Object.prototype.toString.call(t).slice(8,-1)}function Hi(t){return Gx(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function xi(t){return typeof t=="string"&&t.trim().length>0&&!/[;{}]/.test(t)}function sd(t,e,n){const r=t.split(`
57
+ `),i=[];let s="",o=0;const l=e.baseIndentSize||2;for(;o<r.length;){const u=r[o],d=u.match(e.itemPattern);if(!d){if(i.length>0)break;if(u.trim()===""){o+=1,s=`${s}${u}
58
+ `;continue}else return}const p=e.extractItemData(d),{indentLevel:h,mainContent:g}=p;s=`${s}${u}
59
+ `;const b=[g];for(o+=1;o<r.length;){var a;const R=r[o];if(R.trim()===""){var c;const O=r.slice(o+1).findIndex(Y=>Y.trim()!=="");if(O===-1)break;if((((c=r[o+1+O].match(/^(\s*)/))===null||c===void 0||(c=c[1])===null||c===void 0?void 0:c.length)||0)>h){b.push(R),s=`${s}${R}
60
+ `,o+=1;continue}else break}if((((a=R.match(/^(\s*)/))===null||a===void 0||(a=a[1])===null||a===void 0?void 0:a.length)||0)>h)b.push(R),s=`${s}${R}
61
+ `,o+=1;else break}let x;const w=b.slice(1);if(w.length>0){const R=w.map(O=>O.slice(h+l)).join(`
62
+ `);R.trim()&&(e.customNestedParser?x=e.customNestedParser(R):x=n.blockTokens(R))}const A=e.createToken(p,x);i.push(A)}if(i.length!==0)return{items:i,raw:s}}const od=4;function ld(t){let e=0;for(const n of t)e=n===" "?e+od-e%od:e+1;return e}function Rh(t,e,n,r,i){if(!t||!Array.isArray(t.content))return"";const s=typeof n=="function"?n(r):n,[o,...l]=t.content;let a=`${s}${e.renderChildren([o])}`;return l&&l.length>0&&l.forEach((c,u)=>{var d,p;const h=(d=(p=e.renderChild)===null||p===void 0?void 0:p.call(e,c,u+1))!==null&&d!==void 0?d:e.renderChildren([c]);if(h!=null){const g=x=>{if(!(i!=null&&i.alignNestedToPrefix))return e.indent(x);const w=e.indent(""),A=ld(s);return(ld(w)>=A?w:" ".repeat(A))+x},b=h.split(`
63
+ `).map(x=>g(x||"")).join(`
64
+ `);a+=c.type==="paragraph"?`
65
+
66
+ ${b}`:`
67
+ ${b}`}}),a}function Dh(t,e){const n={...t};return Hi(t)&&Hi(e)&&Object.keys(e).forEach(r=>{Hi(e[r])&&Hi(t[r])?n[r]=Dh(t[r],e[r]):n[r]=e[r]}),n}function Jx(t,e,n={}){const{state:r}=e,{doc:i,tr:s}=r,o=t;i.descendants((l,a)=>{const c=s.mapping.map(a),u=s.mapping.map(a)+l.nodeSize;let d=null;if(l.marks.forEach(h=>{if(h!==o)return!1;d=h}),!d)return;let p=!1;if(Object.keys(n).forEach(h=>{n[h]!==d.attrs[h]&&(p=!0)}),p){const h=t.type.create({...t.attrs,...n});s.removeMark(c,u,t.type),s.addMark(c,u,h)}}),s.docChanged&&e.view.dispatch(s)}var Si=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!==null&&e!==void 0?e:!0}};const Xx=(t,e)=>{if(za(e))return e.exec(t);const n=e(t);if(!n)return null;const r=[n.text];return r.index=n.index,r.input=t,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r};function Zx(t){const{editor:e,from:n,to:r,text:i,insertText:s}=t;if(!s)return{inputTransaction:null,tr:e.view.state.tr};const o=e.view.state.tr.insertText(i,n,r);return{inputTransaction:o,tr:Ot.create({doc:o.doc,selection:o.selection,storedMarks:o.storedMarks}).tr}}function Qx(t){const{editor:e,from:n,to:r,text:i,rule:s,match:o,plugin:l,insertText:a}=t,{view:c}=e,{inputTransaction:u,tr:d}=Zx({editor:e,from:n,to:r,text:i,insertText:a}),p=u?n+i.length:r,h=co({state:c.state,transaction:d}),g={from:n-(o[0].length-i.length),to:p},{commands:b,chain:x,can:w}=new er({editor:e,state:h});return s.handler({state:h,range:g,match:o,commands:b,chain:x,can:w})===null||!d.steps.length?!1:(u&&(c.dispatch(u),!c.state.doc.eq(u.doc))||(G0(d),d.setMeta("inputRule",!0),s.undoable&&d.setMeta(l,{transform:d,from:n,to:p,text:i}),c.dispatch(d)),!0)}function eS(t,e,n){const r=e[0].length-n.length;if(r<=0)return!0;const i=t.parentOffset-r;return i>=0&&t.parent.textBetween(i,t.parentOffset)===e[0].slice(0,r)}function ji(t){var e;const{editor:n,from:r,to:i,text:s,rules:o,plugin:l,insertText:a}=t,{view:c}=n;if(c.composing)return!1;const u=c.state.doc.resolve(r);if(u.parent.type.spec.code||!((e=u.nodeBefore||u.nodeAfter)===null||e===void 0)&&e.marks.find(p=>p.type.spec.code))return!1;const d=nx(u)+s;for(const p of o){const h=Xx(d,p.find);if(!(!h||!eS(u,h,s))&&Qx({editor:n,from:r,to:i,text:s,rule:p,match:h,plugin:l,insertText:a}))return!0}return!1}function tS(t){const{editor:e,rules:n}=t,r=new fe({state:{init(){return null},apply(i,s,o){const l=i.getMeta(r);if(l)return l;const a=i.getMeta("applyInputRules");return a&&setTimeout(()=>{let{text:c}=a;typeof c=="string"?c=c:c=ja(I.from(c),o.schema);const{from:u}=a,d=u+c.length;ji({editor:e,from:u,to:d,text:c,rules:n,plugin:r})}),i.selectionSet||i.docChanged?null:s}},props:{handleTextInput(i,s,o,l){return ji({editor:e,from:s,to:o,text:l,rules:n,plugin:r,insertText:!0})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:s}=i.state.selection;s&&ji({editor:e,from:s.pos,to:s.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(i,s){if(s.key!=="Enter")return!1;const{$cursor:o}=i.state.selection;return o?ji({editor:e,from:o.pos,to:o.pos,text:`
68
+ `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}var Va=class{constructor(t={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...t},this.name=this.config.name}get options(){return{...re(j(this,"addOptions",{name:this.name}))}}get storage(){return{...re(j(this,"addStorage",{name:this.name,options:this.options}))}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>Dh(this.options,t)});return e.name=this.name,e.parent=this.parent,this.child=null,e}extend(t={}){const e=new this.constructor({...this.config,...t});return e.parent=this,this.child=e,e.name="name"in t?t.name:e.parent.name,e}},gn=class Ph extends Va{constructor(...e){super(...e),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new Ph(n)}static handleExit({editor:e,mark:n}){const{tr:r}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){const s=i.marks();if(!s.find(l=>(l==null?void 0:l.type.name)===n.name))return!1;const o=s.find(l=>(l==null?void 0:l.type.name)===n.name);return o&&r.removeStoredMark(o),r.insertText(" ",i.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},$h=class{constructor(t){this.find=t.find,this.handler=t.handler}};const nS=(t,e,n)=>{if(za(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.map(i=>{const s=[i.text];return s.index=i.index,s.input=t,s.data=i.data,i.replaceWith&&(i.text.includes(i.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),s.push(i.replaceWith)),s}):[]};function rS(t){const{editor:e,state:n,from:r,to:i,rule:s,pasteEvent:o,dropEvent:l}=t,{commands:a,chain:c,can:u}=new er({editor:e,state:n}),d=[];return n.doc.nodesBetween(r,i,(p,h)=>{var g,b,x,w;if(!((g=p.type)===null||g===void 0||(g=g.spec)===null||g===void 0)&&g.code||!(p.isText||p.isTextblock||p.isInline))return;const A=(b=(x=(w=p.content)===null||w===void 0?void 0:w.size)!==null&&x!==void 0?x:p.nodeSize)!==null&&b!==void 0?b:0,R=Math.max(r,h),O=Math.min(i,h+A);if(R>=O)return;const Y=p.isText?p.text||"":p.textBetween(R-h,O-h,void 0,"");nS(Y,s.find,o).forEach(ee=>{if(ee.index===void 0)return;const H=R+ee.index+1,Q=H+ee[0].length,te={from:n.tr.mapping.map(H),to:n.tr.mapping.map(Q)},ye=s.handler({state:n,range:te,match:ee,commands:a,chain:c,can:u,pasteEvent:o,dropEvent:l});d.push(ye)})}),d.every(p=>p!==null)}let Wn=null;const iS=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)===null||e===void 0||e.setData("text/html",t),n};function sS(t){const{editor:e,rules:n}=t;let r=null,i=!1,s=!1,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}const a=({state:c,from:u,to:d,rule:p,pasteEvt:h})=>{const g=c.tr,b=co({state:c,transaction:g});if(!(!rS({editor:e,state:b,from:Math.max(u-1,0),to:d.b-1,rule:p,pasteEvent:h,dropEvent:l})||!g.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,g}};return e.on("destroy",()=>{Wn===e&&(Wn=null)}),n.map(c=>new fe({view(u){const d=h=>{var g;r=!((g=u.dom.parentElement)===null||g===void 0)&&g.contains(h.target)?u.dom.parentElement:null,r&&(Wn=e)},p=()=>{Wn&&(Wn=null)};return window.addEventListener("dragstart",d),window.addEventListener("dragend",p),{destroy(){window.removeEventListener("dragstart",d),window.removeEventListener("dragend",p)}}},props:{handleDOMEvents:{drop:(u,d)=>{if(s=r===u.dom.parentElement,l=d,!s){const p=Wn;p!=null&&p.isEditable&&setTimeout(()=>{if(p.isDestroyed)return;const h=p.state.selection;h&&p.commands.deleteRange({from:h.from,to:h.to})},10)}return!1},paste:(u,d)=>{var p;const h=(p=d.clipboardData)===null||p===void 0?void 0:p.getData("text/html");return o=d,i=!!(h!=null&&h.includes("data-pm-slice")),!1}}},appendTransaction:(u,d,p)=>{const h=u[0],g=h.getMeta("uiEvent")==="paste"&&!i,b=h.getMeta("uiEvent")==="drop"&&!s,x=h.getMeta("applyPasteRules"),w=!!x;if(!g&&!b&&!w)return;if(w){let{text:O}=x;typeof O=="string"?O=O:O=ja(I.from(O),p.schema);const{from:Y}=x,ee=Y+O.length,H=iS(O);return a({rule:c,state:p,from:Y,to:{b:ee},pasteEvt:H})}const A=d.doc.content.findDiffStart(p.doc.content),R=d.doc.content.findDiffEnd(p.doc.content);if(!(!Yx(A)||!R||A===R.b))return a({rule:c,state:p,from:A,to:R,pasteEvt:o})}}))}var mo=class{constructor(t,e){this.splittableMarks=[],this.nonClearableMarks=[],this.decorationManager=null,this.editor=e,this.baseExtensions=t,this.extensions=Sh(t),this.schema=Yk(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((t,e)=>{const n=j(e,"addCommands",{name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:qn(e.name,this.schema)});return n?{...t,...n()}:t},{})}get plugins(){const{editor:t}=this,e=Hr([...this.extensions].reverse()).flatMap(r=>{const i={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:qn(r.name,this.schema)},s=[],o=j(r,"addKeyboardShortcuts",i);let l={};if(r.type==="mark"&&j(r,"exitable",i)&&(l.ArrowRight=()=>gn.handleExit({editor:t,mark:r})),o){const p=Object.fromEntries(Object.entries(o()).map(([h,g])=>[h,()=>g({editor:t})]));l={...l,...p}}const a=H0(l);s.push(a);const c=j(r,"addInputRules",i);if(ed(r,t.options.enableInputRules)&&c){const p=c();if(p&&p.length){const h=tS({editor:t,rules:p}),g=Array.isArray(h)?h:[h];s.push(...g)}}const u=j(r,"addPasteRules",i);if(ed(r,t.options.enablePasteRules)&&u){const p=u();if(p&&p.length){const h=sS({editor:t,rules:p});s.push(...h)}}const d=j(r,"addProseMirrorPlugins",i);if(d){const p=d();s.push(...p)}return s}),n=this.createDecorationPlugin();return n&&e.push(n),e}createDecorationPlugin(){var t;const{editor:e}=this;(t=this.decorationManager)===null||t===void 0||t.destroy();const n=[];return this.extensions.forEach(r=>{const i=j(r,"addDecorations",{name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:e,type:qn(r.name,this.schema)});i&&n.push({name:r.name,addDecorations:i})}),this.decorationManager=new qx({editor:e,entries:n}),this.decorationManager.plugin}get attributes(){return xh(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=ar(this.extensions);return Object.fromEntries(e.filter(n=>!!j(n,"addNodeView")).map(n=>{const r=this.attributes.filter(l=>l.type===n.name),i=j(n,"addNodeView",{name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Ce(n.name,this.schema)});if(!i)return[];const s=i();if(!s)return[];const o=(l,a,c,u,d)=>{const p=ai(l,r);return s({node:l,view:a,getPos:c,decorations:u,innerDecorations:d,editor:t,extension:n,HTMLAttributes:p})};return[n.name,o]}))}dispatchTransaction(t){const{editor:e}=this;return Hr([...this.extensions].reverse()).reduceRight((n,r)=>{const i={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:e,type:qn(r.name,this.schema)},s=j(r,"dispatchTransaction",i);return s?o=>{s.call(i,{transaction:o,next:n})}:n},t)}transformPastedHTML(t){const{editor:e}=this;return Hr([...this.extensions]).reduce((n,r)=>{const i={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:e,type:qn(r.name,this.schema)},s=j(r,"transformPastedHTML",i);return s?(o,l)=>{const a=n(o,l);return s.call(i,a)}:n},t||(n=>n))}get markViews(){const{editor:t}=this,{markExtensions:e}=ar(this.extensions);return Object.fromEntries(e.filter(n=>!!j(n,"addMarkView")).map(n=>{const r=this.attributes.filter(o=>o.type===n.name),i=j(n,"addMarkView",{name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Ft(n.name,this.schema)});if(!i)return[];const s=(o,l,a)=>{const c=ai(o,r);return i()({mark:o,view:l,inline:a,editor:t,extension:n,HTMLAttributes:c,updateAttributes:u=>{Jx(o,t,u)}})};return[n.name,s]}))}destroy(){var t;(t=this.decorationManager)===null||t===void 0||t.destroy(),this.extensions.forEach(e=>{let n=e;for(;n.parent;){const r=n.parent;r.child===n&&(r.child=null),n=r}}),this.extensions=[],this.baseExtensions=[],this.decorationManager=null,this.schema=null,this.editor=null}setupExtensions(){const t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(e=>[e.name,e.storage])),t.forEach(e=>{const n={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:qn(e.name,this.schema)};if(e.type==="mark"){var r,i;(!((r=re(j(e,"keepOnSplit",n)))!==null&&r!==void 0)||r)&&this.splittableMarks.push(e.name),!((i=re(j(e,"clearable",n)))!==null&&i!==void 0)||i||this.nonClearableMarks.push(e.name)}const s=j(e,"onBeforeCreate",n),o=j(e,"onCreate",n),l=j(e,"onUpdate",n),a=j(e,"onSelectionUpdate",n),c=j(e,"onTransaction",n),u=j(e,"onFocus",n),d=j(e,"onBlur",n),p=j(e,"onDestroy",n);s&&this.editor.on("beforeCreate",s),o&&this.editor.on("create",o),l&&this.editor.on("update",l),a&&this.editor.on("selectionUpdate",a),c&&this.editor.on("transaction",c),u&&this.editor.on("focus",u),d&&this.editor.on("blur",d),p&&this.editor.on("destroy",p)})}};mo.resolve=Sh;mo.sort=Hr;mo.flatten=Ha;var ae=class Bh extends Va{constructor(...e){super(...e),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new Bh(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};const oS=ae.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new fe({key:new xe("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:i}=e,s=Ch(n),{blockSeparator:o}=this.options,l={...o!==void 0?{blockSeparator:o}:{},textSerializers:s};return[...i.ranges].sort((a,c)=>a.$from.pos-c.$from.pos).map(({$from:a,$to:c})=>wh(r,{from:a.pos,to:c.pos},l)).join(o??`
69
+
70
+ `)}}})]}}),lS=ae.create({name:"commands",addCommands(){return{...Lx}}}),aS=ae.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r;const i=()=>{var s,o,l;if((s=(o=this.editor.options.coreExtensionOptions)===null||o===void 0||(o=o.delete)===null||o===void 0||(l=o.filterTransaction)===null||l===void 0?void 0:l.call(o,t))!==null&&s!==void 0?s:t.getMeta("y-sync$"))return;const a=kh(t.before,[t,...e]);po(a).forEach(u=>{a.mapping.mapResult(u.oldRange.from).deletedAfter&&a.mapping.mapResult(u.oldRange.to).deletedBefore&&a.before.nodesBetween(u.oldRange.from,u.oldRange.to,(d,p)=>{const h=p+d.nodeSize-2,g=u.oldRange.from<=p&&h<=u.oldRange.to;this.editor.emit("delete",{type:"node",node:d,from:p,to:h,newFrom:a.mapping.map(p),newTo:a.mapping.map(h),deletedRange:u.oldRange,newRange:u.newRange,partial:!g,editor:this.editor,transaction:t,combinedTransform:a})})});const c=a.mapping;a.steps.forEach((u,d)=>{if(u instanceof at){var p,h;const g=c.slice(d).map(u.from,-1),b=c.slice(d).map(u.to),x=c.invert().map(g,-1),w=c.invert().map(b),A=g>0?(p=a.doc.nodeAt(g-1))===null||p===void 0?void 0:p.marks.some(O=>O.eq(u.mark)):!1,R=(h=a.doc.nodeAt(b))===null||h===void 0?void 0:h.marks.some(O=>O.eq(u.mark));this.editor.emit("delete",{type:"mark",mark:u.mark,from:u.from,to:u.to,deletedRange:{from:x,to:w},newRange:{from:g,to:b},partial:!!(R||A),editor:this.editor,transaction:t,combinedTransform:a})}})};!((n=(r=this.editor.options.coreExtensionOptions)===null||r===void 0||(r=r.delete)===null||r===void 0?void 0:r.async)!==null&&n!==void 0)||n?setTimeout(i,0):i()}}),cS=ae.create({name:"drop",addProseMirrorPlugins(){return[new fe({key:new xe("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),uS=ae.create({name:"editable",addProseMirrorPlugins(){return[new fe({key:new xe("editable"),props:{editable:()=>this.editor.options.editable}})]}}),dS=new xe("focusEvents"),fS=ae.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new fe({key:dS,props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;const r=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,n)=>{t.isFocused=!1;const r=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),pS=ae.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:l})=>{const{selection:a,doc:c}=l,{empty:u,$anchor:d}=a,{pos:p,parent:h}=d,g=d.parent.isTextblock&&p>0?l.doc.resolve(p-1):d,b=g.parent.type.spec.isolating,x=d.pos-d.parentOffset,w=b&&g.parent.childCount===1?x===d.pos:J.atStart(c).from===p;return!u||!h.type.isTextblock||h.textContent.length||!w||w&&d.parent.type.name==="paragraph"?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},i={...r},s={...r,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return ys()||yh()?s:i},addProseMirrorPlugins(){return[new fe({key:new xe("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(h=>h.getMeta("composition")))return;const r=t.some(h=>h.docChanged)&&!e.doc.eq(n.doc),i=t.some(h=>h.getMeta("preventClearDocument"));if(!r||i)return;const{empty:s,from:o,to:l}=e.selection,a=J.atStart(e.doc).from,c=J.atEnd(e.doc).to;if(s||!(o===a&&l===c)||!bi(n.doc))return;const u=n.tr,d=co({state:n,transaction:u}),{commands:p}=new er({editor:this.editor,state:d});if(p.clearNodes(),!!u.steps.length)return u}})]}}),hS=ae.create({name:"paste",addProseMirrorPlugins(){return[new fe({key:new xe("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),mS=ae.create({name:"tabindex",addOptions(){return{value:void 0}},addProseMirrorPlugins(){return[new fe({key:new xe("tabindex"),props:{attributes:()=>{var t;return!this.editor.isEditable&&this.options.value===void 0?{}:{tabindex:(t=this.options.value)!==null&&t!==void 0?t:"0"}}}})]}}),gS=ae.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=ar(this.extensions);return[{types:t.filter(e=>e.name!=="text").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{const n=e.getAttribute("dir");return n&&(n==="ltr"||n==="rtl"||n==="auto")?n:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new fe({key:new xe("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}});let ad=!1;function yS(t){if(ad)return;ad=!0;let e;try{e=me.fromJSON(t,{from:0,to:0}).slice.content}catch{return}e instanceof I||console.warn("[tiptap warn]: prosemirror-model is loaded more than once. Wrapping and splitting nodes will fail. Deduplicate it in your lock file, or alias it to a single copy in your bundler.")}var bS=class Dr{get name(){return this.node.type.name}constructor(e,n,r=!1,i=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=n,this.currentNode=i}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!==null&&e!==void 0?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let n=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}n=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:n,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(e);return new Dr(n,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new Dr(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new Dr(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,r)=>{const i=n.isBlock&&!n.isTextblock,s=n.isAtom&&!n.isText,o=n.isInline,l=this.pos+r+(s?0:1);if(l<0||l>this.resolvedPos.doc.nodeSize-2)return;const a=this.resolvedPos.doc.resolve(l);if(!i&&!o&&a.depth<=this.depth)return;const c=new Dr(a,this.editor,i,i||o?n:null);i&&(c.actualDepth=this.depth+1),e.push(c)}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,n={}){let r=null,i=this.parent;for(;i&&!r;){if(i.node.type.name===e)if(Object.keys(n).length>0){const s=i.node.attrs,o=Object.keys(n);for(let l=0;l<o.length;l+=1){const a=o[l];if(s[a]!==n[a])break}}else r=i;i=i.parent}return r}querySelector(e,n={}){return this.querySelectorAll(e,n,!0)[0]||null}querySelectorAll(e,n={},r=!1){let i=[];if(!this.children||this.children.length===0)return i;const s=Object.keys(n);return this.children.forEach(o=>{r&&i.length>0||(o.node.type.name===e&&s.every(l=>n[l]===o.node.attrs[l])&&i.push(o),!(r&&i.length>0)&&(i=i.concat(o.querySelectorAll(e,n,r))))}),i}setAttribute(e){const{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}};const kS=`.ProseMirror {
71
+ position: relative;
72
+ }
73
+
74
+ .ProseMirror {
75
+ word-wrap: break-word;
76
+ white-space: pre-wrap;
77
+ white-space: break-spaces;
78
+ -webkit-font-variant-ligatures: none;
79
+ font-variant-ligatures: none;
80
+ font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
81
+ }
82
+
83
+ .ProseMirror [contenteditable="false"] {
84
+ white-space: normal;
85
+ }
86
+
87
+ .ProseMirror [contenteditable="false"] [contenteditable="true"] {
88
+ white-space: pre-wrap;
89
+ }
90
+
91
+ .ProseMirror pre {
92
+ white-space: pre-wrap;
93
+ }
94
+
95
+ img.ProseMirror-separator {
96
+ display: inline !important;
97
+ border: none !important;
98
+ margin: 0 !important;
99
+ width: 0 !important;
100
+ height: 0 !important;
101
+ }
102
+
103
+ .ProseMirror-gapcursor {
104
+ display: none;
105
+ pointer-events: none;
106
+ position: absolute;
107
+ margin: 0;
108
+ }
109
+
110
+ .ProseMirror-gapcursor:after {
111
+ content: "";
112
+ display: block;
113
+ position: absolute;
114
+ top: -2px;
115
+ width: 20px;
116
+ border-top: 1px solid black;
117
+ animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
118
+ }
119
+
120
+ @keyframes ProseMirror-cursor-blink {
121
+ to {
122
+ visibility: hidden;
123
+ }
124
+ }
125
+
126
+ .ProseMirror-hideselection *::selection {
127
+ background: transparent;
128
+ }
129
+
130
+ .ProseMirror-hideselection *::-moz-selection {
131
+ background: transparent;
132
+ }
133
+
134
+ .ProseMirror-hideselection * {
135
+ caret-color: transparent;
136
+ }
137
+
138
+ .ProseMirror-focused .ProseMirror-gapcursor {
139
+ display: block;
140
+ }`;var xS=class extends Rx{constructor(t={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.destroyed=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.hasWarnedStaleDecorationRead=!1,this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:n})=>{throw n},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:ox,createMappablePosition:lx},this.setOptions(t),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:n,slice:r,moved:i})=>this.options.onDrop(n,r,i)),this.on("paste",({event:n,slice:r})=>this.options.onPaste(n,r)),this.on("delete",this.options.onDelete);const e=this.createDoc();if(!this.editorState){const n=Jl(e,this.options.autofocus);this.editorState=Ot.create({doc:e,schema:this.schema,selection:n||void 0})}yS(this.schema),this.options.element&&this.mount(this.options.element)}mount(t){if(typeof document>"u")throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(t),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){this.editorState=this.editorView.state;const t=this.editorView.dom;t!=null&&t.editor&&delete t.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove=="function"?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(t){console.warn("Failed to remove CSS element:",t)}this.css=null,this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager?this.commandManager.chain():er.createFakeChain()}can(){return this.commandManager?this.commandManager.can():er.createFallbackCan()}injectCSS(){this.options.injectCSS&&typeof document<"u"&&(this.css=Kx(kS,this.options.injectNonce))}setOptions(t={}){this.options={...this.options,...t},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps({...this.options.editorProps,attributes:this.getEditorViewAttributes()}),this.view.updateState(this.state))}setEditable(t,e=!0){this.setOptions({editable:t}),e&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:t=>{this.editorState=t},dispatch:t=>{this.dispatchTransaction(t)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(t,e)=>{if(this.editorView)return this.editorView[e];if(e==="state")return this.editorState;if(e in t)return Reflect.get(t,e);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${e}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(t,e){const n=Zl(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(t){if(this.isDestroyed)return;const e=this.state.plugins;let n=e;if([].concat(t).forEach(i=>{const s=typeof i=="string"?`${i}$`:i.key;n=n.filter(o=>!o.key.startsWith(s))}),e.length===n.length)return;const r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var t,e;const n=[...this.options.enableCoreExtensions?[uS,oS.configure({blockSeparator:(t=this.options.coreExtensionOptions)===null||t===void 0||(t=t.clipboardTextSerializer)===null||t===void 0?void 0:t.blockSeparator}),lS,fS,pS,mS.configure({value:(e=this.options.coreExtensionOptions)===null||e===void 0||(e=e.tabindex)===null||e===void 0?void 0:e.value}),cS,hS,aS,gS.configure({direction:this.options.textDirection})].filter(r=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[r.name]!==!1:!0):[],...this.options.extensions].filter(r=>["extension","node","mark"].includes(r==null?void 0:r.type));this.extensionManager=new mo(n,this)}createCommandManager(){this.commandManager=new er({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=Xl(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(e.message))throw e;const n=Xl(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1});return this.editorState=Ot.create({doc:n,schema:this.schema,selection:Jl(n,this.options.autofocus)||void 0}),this.emit("contentError",{editor:this,error:e,disableCollaboration:()=>{"collaboration"in this.storage&&typeof this.storage.collaboration=="object"&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(r=>r.name!=="collaboration"),this.createExtensionManager()}}),this.editorState.doc}return t}getEditorViewAttributes(){var t;const e=(t=this.options.editorProps)===null||t===void 0?void 0:t.attributes;return Zl(e)?n=>({role:"textbox",...e(n)}):{role:"textbox",...e}}createView(t){const{editorProps:e,enableExtensionDispatchTransaction:n}=this.options,r=e.dispatchTransaction||this.dispatchTransaction.bind(this),i=n?this.extensionManager.dispatchTransaction(r):r,s=e.transformPastedHTML,o=this.extensionManager.transformPastedHTML(s);this.editorView=new th(t,{...e,attributes:this.getEditorViewAttributes(),dispatchTransaction:i,transformPastedHTML:o,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const l=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(l),this.prependClass(),this.injectCSS();const a=this.view.dom;a.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=t;return}t.steps.forEach(c=>{var u;return(u=this.capturedTransaction)===null||u===void 0?void 0:u.step(c)});return}const{state:e,transactions:n}=this.state.applyTransaction(t),r=!this.state.selection.eq(e.selection),i=n.includes(t),s=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),!i)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t,appendedTransactions:n.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:t});const o=n.findLast(c=>c.getMeta("focus")||c.getMeta("blur")),l=o==null?void 0:o.getMeta("focus"),a=o==null?void 0:o.getMeta("blur");l&&this.emit("focus",{editor:this,event:l.event,transaction:o}),a&&this.emit("blur",{editor:this,event:a.event,transaction:o}),!(t.getMeta("preventUpdate")||!n.some(c=>c.docChanged)||s.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return vh(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return rx(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return ja(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
141
+
142
+ `,textSerializers:n={}}=t||{};return Jk(this.state.doc,{blockSeparator:e,textSerializers:{...Ch(this.schema),...n}})}get isEmpty(){return bi(this.state.doc)}destroy(){this.destroyed||(this.destroyed=!0,this.emit("destroy"),this.unmount(),this.removeAllListeners(),this.extensionManager.destroy(),this.extensionManager=null,this.schema=null,this.commandManager=null,this.extensionStorage={})}get isDestroyed(){var t,e;return(t=(e=this.editorView)===null||e===void 0?void 0:e.isDestroyed)!==null&&t!==void 0?t:!0}$node(t,e){var n;return((n=this.$doc)===null||n===void 0?void 0:n.querySelector(t,e))||null}$nodes(t,e){var n;return((n=this.$doc)===null||n===void 0?void 0:n.querySelectorAll(t,e))||null}$pos(t){const e=this.state.doc.resolve(t),n=t>0&&e.nodeAfter&&!e.nodeAfter.isText&&e.nodeAfter.isAtom?e.nodeAfter:null;return new bS(e,this,!1,n)}get $doc(){return this.$pos(0)}};function Pn(t){return new Si({find:t.find,handler:({state:e,range:n,match:r})=>{const i=re(t.getAttributes,void 0,r);if(i===!1||i===null)return null;const{tr:s}=e,o=r[r.length-1],l=r[0];if(o){const a=l.search(/\S/),c=n.from+l.indexOf(o),u=c+o.length;if(ho(n.from,n.to,e.doc).filter(p=>p.mark.type.excluded.find(h=>h===t.type&&h!==p.mark.type)).filter(p=>p.to>c).length)return null;u<n.to&&s.delete(u,n.to),c>n.from&&s.delete(n.from+a,c);const d=n.from+a+o.length;s.addMark(n.from+a,d,t.type.create(i||{})),s.removeStoredMark(t.type)}},undoable:t.undoable})}function SS(t){return new Si({find:t.find,handler:({state:e,range:n,match:r})=>{const i=re(t.getAttributes,void 0,r)||{},{tr:s}=e,o=n.from;let l=n.to;const a=t.type.create(i);if(r[1]){let c=o+r[0].lastIndexOf(r[1]);c>l?c=l:l=c+r[1].length;const u=r[0][r[0].length-1];s.insertText(u,o+r[0].length-1),s.replaceWith(c,l,a)}else if(r[0]){const c=t.type.isInline?o:o-1;s.insert(c,t.type.create(i)).delete(s.mapping.map(o),s.mapping.map(l))}s.scrollIntoView()},undoable:t.undoable})}function ea(t){return new Si({find:t.find,handler:({state:e,range:n,match:r})=>{const i=e.doc.resolve(n.from),s=re(t.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,s)},undoable:t.undoable})}function cr(t){return new Si({find:t.find,handler:({state:e,range:n,match:r,chain:i})=>{const s=re(t.getAttributes,void 0,r)||{},o=e.tr.delete(n.from,n.to),l=o.doc.resolve(n.from).blockRange(),a=l&&va(l,t.type,s);if(!a)return null;if(o.wrap(l,a),t.keepMarks&&t.editor){const{selection:u,storedMarks:d}=e,{splittableMarks:p}=t.editor.extensionManager,h=d||u.$to.parentOffset&&u.$from.marks();if(h){const g=h.filter(b=>p.includes(b.type.name));o.ensureMarks(g)}}if(t.keepAttributes){const u=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(u,s).run()}const c=o.doc.resolve(n.from-1).nodeBefore;c&&c.type===t.type&&hn(o.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,c))&&o.join(n.from-1)},undoable:t.undoable})}var Ye=class _h extends Va{constructor(...e){super(...e),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new _h(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function fn(t){return new $h({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:i})=>{const s=re(t.getAttributes,void 0,r,i);if(s===!1||s===null)return null;const{tr:o}=e,l=r[r.length-1],a=r[0];let c=n.to;if(l){const u=a.search(/\S/),d=n.from+a.indexOf(l),p=d+l.length;if(ho(n.from,n.to,e.doc).filter(h=>h.mark.type.excluded.find(g=>g===t.type&&g!==h.mark.type)).filter(h=>h.to>d).length)return null;p<n.to&&o.delete(p,n.to),d>n.from&&o.delete(n.from+u,d),c=n.from+u+l.length,o.addMark(n.from+u,c,t.type.create(s||{})),r.index!==void 0&&r.input!==void 0&&r.index+r[0].length>=r.input.length||o.removeStoredMark(t.type)}}})}const zh=new WeakSet,Fh=new WeakSet;function bn(t){const e=t;return zh.add(e),e}function ta(t){return Array.isArray(t)&&zh.has(t)}function Hh(t){return t.flatMap(e=>e==null?[]:Array.isArray(e)&&Fh.has(e)&&!ta(e)?Hh(e):[e])}function wS(t,e){if(t==="slot")return 0;if(t instanceof Function){const i=t(e);return Array.isArray(i)&&!ta(i)&&!Fh.has(i)?bn(i):i}const{children:n,...r}=e??{};if(t==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");if(Array.isArray(n)){if(ta(n))return bn([t,r,n]);if(n.length===0)return bn([t,r]);const i=Hh(n);return i.length===0?bn([t,r]):bn([t,r,...i])}return n!=null?bn([t,r,n]):bn([t,r])}const bs=(t,e)=>wS(t,e),CS=(t,e)=>{var n;const{state:r}=t,{selection:i}=r;if(!i.empty)return!1;const{$from:s}=i;if(s.parentOffset!==0)return!1;const o=s.depth-1;if(o<0)return!1;const l=s.node(o),a=s.index(o);if(a===0)return!1;if(l.type===e)return t.commands.lift(e.name);const c=l.child(a-1);if(c.type!==e||!(!((n=c.lastChild)===null||n===void 0)&&n.isTextblock))return!1;const u=s.before()-1-1;return t.commands.command(({tr:d,dispatch:p})=>{if(!p)return!0;const h=s.parent.content,g=new _(h,0,0);return d.replace(u,s.after(),g),d.setSelection(q.create(d.doc,u+h.size)),d.scrollIntoView(),p(d),!0})},vS=/^\s*>\s$/,MS=Ye.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return bs("blockquote",{...be(this.options.HTMLAttributes,t),children:bs("slot",{})})},parseMarkdown:(t,e)=>{var n;const r=(n=e.parseBlockChildren)!==null&&n!==void 0?n:e.parseChildren;return e.createNode("blockquote",void 0,r(t.tokens||[]))},renderMarkdown:(t,e)=>{if(!t.content)return"";const n=">",r=[];return t.content.forEach((i,s)=>{var o,l;const a=((o=(l=e.renderChild)===null||l===void 0?void 0:l.call(e,i,s))!==null&&o!==void 0?o:e.renderChildren([i])).split(`
143
+ `).map(c=>c.trim()===""?n:`${n} ${c}`);r.push(a.join(`
144
+ `))}),r.join(`
145
+ ${n}
146
+ `)},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote(),Backspace:()=>CS(this.editor,this.type)}},addInputRules(){return[cr({find:vS,type:this.type})]}}),TS=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,AS=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,ES=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,NS=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,OS=gn.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return bs("strong",{...be(this.options.HTMLAttributes,t),children:bs("slot",{})})},markdownTokenName:"strong",parseMarkdown:(t,e)=>e.applyMark("bold",e.parseInline(t.tokens||[])),markdownOptions:{htmlReopen:{open:"<strong>",close:"</strong>"}},renderMarkdown:(t,e)=>`**${e.renderChildren(t)}**`,addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[Pn({find:TS,type:this.type}),Pn({find:ES,type:this.type})]},addPasteRules(){return[fn({find:AS,type:this.type}),fn({find:NS,type:this.type})]}}),LS=t=>{const e=/`([^`]+)`(?!`)$/.exec(t);return!e||e.index>0&&t[e.index-1]==="`"?null:{index:e.index,text:e[0],replaceWith:e[1]}},IS=t=>{const e=/`([^`]+)`(?!`)/g,n=[];let r;for(;(r=e.exec(t))!==null;)r.index>0&&t[r.index-1]==="`"||n.push({index:r.index,text:r[0],replaceWith:r[1]});return n};function RS(t){const e=new Set((t.match(/`+/g)||[]).map(r=>r.length));let n=1;for(;e.has(n);)n+=1;return n}const DS=gn.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",be(this.options.HTMLAttributes,t),0]},markdownTokenName:"codespan",parseMarkdown:(t,e)=>e.applyMark("code",[{type:"text",text:t.text||""}]),renderMarkdown:(t,e,n)=>{var r;if(!t.content)return"";const i=typeof(n==null||(r=n.meta)===null||r===void 0?void 0:r.markText)=="string"?n.meta.markText:"",s="`".repeat(RS(i)),o=i.startsWith("`")||i.endsWith("`")?" ":"";return`${s}${o}${e.renderChildren(t.content)}${o}${s}`},addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[Pn({find:LS,type:this.type})]},addPasteRules(){return[fn({find:IS,type:this.type})]}}),bl=4,PS=/^```([a-z]+)?[\s\n]$/,$S=/^~~~([a-z]+)?[\s\n]$/,BS=Ye.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,exitOnArrowUp:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:bl,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;const{languageClassPrefix:n}=this.options;if(!n)return null;const r=[...((e=t.firstElementChild)===null||e===void 0?void 0:e.classList)||[]].filter(i=>i.startsWith(n)).map(i=>i.replace(n,""))[0];return r||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",be(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(t,e)=>{var n,r;return((n=t.raw)===null||n===void 0?void 0:n.startsWith("```"))===!1&&((r=t.raw)===null||r===void 0?void 0:r.startsWith("~~~"))===!1&&t.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:t.lang||null},t.text?[e.createTextNode(t.text)]:[])},renderMarkdown:(t,e)=>{var n;let r="";const i=((n=t.attrs)===null||n===void 0?void 0:n.language)||"";return t.content?r=[`\`\`\`${i}`,e.renderChildren(t.content),"```"].join(`
147
+ `):r=`\`\`\`${i}
148
+
149
+ \`\`\``,r},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!==null&&e!==void 0?e:bl,{state:r}=t,{selection:i}=r,{$from:s,empty:o}=i;if(s.parent.type!==this.type)return!1;const l=" ".repeat(n);return o?t.commands.insertContent(l):t.commands.command(({tr:a})=>{const{from:c,to:u}=i,d=r.doc.textBetween(c,u,`
150
+ `,`
151
+ `).split(`
152
+ `).map(p=>l+p).join(`
153
+ `);return a.replaceWith(c,u,r.schema.text(d)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!==null&&e!==void 0?e:bl,{state:r}=t,{selection:i}=r,{$from:s,empty:o}=i;return s.parent.type!==this.type?!1:o?t.commands.command(({tr:l})=>{var a;const{pos:c}=s,u=s.start(),d=s.end(),p=r.doc.textBetween(u,d,`
154
+ `,`
155
+ `).split(`
156
+ `);let h=0,g=0;const b=c-u;for(let R=0;R<p.length;R+=1){if(g+p[R].length>=b){h=R;break}g+=p[R].length+1}const x=((a=p[h].match(/^ */))===null||a===void 0?void 0:a[0])||"",w=Math.min(x.length,n);if(w===0)return!0;let A=u;for(let R=0;R<h;R+=1)A+=p[R].length+1;return l.delete(A,A+w),c-A<=w&&l.setSelection(q.create(l.doc,A)),!0}):t.commands.command(({tr:l})=>{const{from:a,to:c}=i,u=r.doc.textBetween(a,c,`
157
+ `,`
158
+ `).split(`
159
+ `).map(d=>{var p;const h=((p=d.match(/^ */))===null||p===void 0?void 0:p[0])||"",g=Math.min(h.length,n);return d.slice(g)}).join(`
160
+ `);return l.replaceWith(a,c,r.schema.text(u)),!0})},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type)return!1;const s=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(`
161
+
162
+ `);return!s||!o?!1:t.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowUp:({editor:t})=>{if(!this.options.exitOnArrowUp)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type||r.parentOffset!==0)return!1;const s=r.before();return s>0?!1:t.commands.insertDefaultBlock({pos:s})},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:r}=e,{$from:i,empty:s}=n;if(!s||i.parent.type!==this.type||i.parentOffset!==i.parent.nodeSize-2)return!1;const o=i.after();return o===void 0?!1:r.nodeAt(o)?t.commands.command(({tr:l})=>(l.setSelection(J.near(r.resolve(o))),!0)):t.commands.exitCode()}}},addInputRules(){return[ea({find:PS,type:this.type,getAttributes:t=>({language:t[1]})}),ea({find:$S,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new fe({key:new xe("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),i=r?JSON.parse(r):void 0,s=i==null?void 0:i.mode;if(!n||!s)return!1;const{tr:o,schema:l}=t.state,a=l.text(n.replace(/\r\n?/g,`
163
+ `));return o.replaceSelectionWith(this.type.create({language:s},a)),o.selection.$from.parent.type!==this.type&&o.setSelection(q.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),t.dispatch(o),!0}}})]}}),_S=Ye.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
164
+
165
+ `):""}),zS=Ye.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",be(this.options.HTMLAttributes,t)]},renderText(){return`
166
+ `},renderMarkdown:()=>`
167
+ `,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:i,storedMarks:s}=n;if(i.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:l}=r.extensionManager,a=s||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:u})=>{if(u&&a&&o){const d=a.filter(p=>l.includes(p.type.name));c.ensureMarks(d)}return!0}).scrollIntoView().run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),FS=Ye.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,be(this.options.HTMLAttributes,e),0]},parseMarkdown:(t,e)=>e.createNode("heading",{level:t.depth||1},e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>{var n;const r=!((n=t.attrs)===null||n===void 0)&&n.level?parseInt(t.attrs.level,10):1,i="#".repeat(r);return t.content?`${i} ${e.renderChildren(t.content)}`:""},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>ea({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),HS=Ye.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",be(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!Wx(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,i=t();return Mh(n)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:s,tr:o,dispatch:l})=>{if(l){const{$to:a}=o.selection,c=a.end();if(a.nodeAfter)a.nodeAfter.isTextblock?o.setSelection(q.create(o.doc,a.pos+1)):a.nodeAfter.isBlock?o.setSelection(U.create(o.doc,a.pos)):o.setSelection(q.create(o.doc,a.pos));else{const u=s.schema.nodes[this.options.nextNodeType]||a.parent.type.contentMatch.defaultType,d=u==null?void 0:u.create();d&&(o.insert(c,d),o.setSelection(q.create(o.doc,c+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[SS({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),jS=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,VS=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,US=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,qS=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,WS=gn.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",be(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(t,e)=>e.applyMark("italic",e.parseInline(t.tokens||[])),markdownOptions:{htmlReopen:{open:"<em>",close:"</em>"}},renderMarkdown:(t,e)=>`*${e.renderChildren(t)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Pn({find:jS,type:this.type}),Pn({find:US,type:this.type})]},addPasteRules(){return[fn({find:VS,type:this.type}),fn({find:qS,type:this.type})]}}),KS="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",YS="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2",na="numeric",ra="ascii",ia="alpha",jr="asciinumeric",Pr="alphanumeric",sa="domain",jh="emoji",GS="scheme",JS="slashscheme",kl="whitespace";function XS(t,e){return t in e||(e[t]=[]),e[t]}function vn(t,e,n){e[na]&&(e[jr]=!0,e[Pr]=!0),e[ra]&&(e[jr]=!0,e[ia]=!0),e[jr]&&(e[Pr]=!0),e[ia]&&(e[Pr]=!0),e[Pr]&&(e[sa]=!0),e[jh]&&(e[sa]=!0);for(const r in e){const i=XS(r,n);i.indexOf(t)<0&&i.push(t)}}function ZS(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function We(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}We.groups={};We.prototype={accepts(){return!!this.t},go(t){const e=this,n=e.j[t];if(n)return n;for(let r=0;r<e.jr.length;r++){const i=e.jr[r][0],s=e.jr[r][1];if(s&&i.test(t))return s}return e.jd},has(t,e=!1){return e?t in this.j:!!this.go(t)},ta(t,e,n,r){for(let i=0;i<t.length;i++)this.tt(t[i],e,n,r)},tr(t,e,n,r){r=r||We.groups;let i;return e&&e.j?i=e:(i=new We(e),n&&r&&vn(e,n,r)),this.jr.push([t,i]),i},ts(t,e,n,r){let i=this;const s=t.length;if(!s)return i;for(let o=0;o<s-1;o++)i=i.tt(t[o]);return i.tt(t[s-1],e,n,r)},tt(t,e,n,r){r=r||We.groups;const i=this;if(e&&e.j)return i.j[t]=e,e;const s=e;let o,l=i.go(t);if(l?(o=new We,Object.assign(o.j,l.j),o.jr.push.apply(o.jr,l.jr),o.jd=l.jd,o.t=l.t):o=new We,s){if(r)if(o.t&&typeof o.t=="string"){const a=Object.assign(ZS(o.t,r),n);vn(s,a,r)}else n&&vn(s,n,r);o.t=s}return i.j[t]=o,o}};const Z=(t,e,n,r,i)=>t.ta(e,n,r,i),he=(t,e,n,r,i)=>t.tr(e,n,r,i),cd=(t,e,n,r,i)=>t.ts(e,n,r,i),$=(t,e,n,r,i)=>t.tt(e,n,r,i),At="WORD",oa="UWORD",Vh="ASCIINUMERICAL",Uh="ALPHANUMERICAL",ci="LOCALHOST",la="TLD",aa="UTLD",ts="SCHEME",Xn="SLASH_SCHEME",Ua="NUM",ca="WS",qa="NL",Vr="OPENBRACE",Ur="CLOSEBRACE",ks="OPENBRACKET",xs="CLOSEBRACKET",Ss="OPENPAREN",ws="CLOSEPAREN",Cs="OPENANGLEBRACKET",vs="CLOSEANGLEBRACKET",Ms="FULLWIDTHLEFTPAREN",Ts="FULLWIDTHRIGHTPAREN",As="LEFTCORNERBRACKET",Es="RIGHTCORNERBRACKET",Ns="LEFTWHITECORNERBRACKET",Os="RIGHTWHITECORNERBRACKET",Ls="FULLWIDTHLESSTHAN",Is="FULLWIDTHGREATERTHAN",Rs="AMPERSAND",Ds="APOSTROPHE",Ps="ASTERISK",Xt="AT",$s="BACKSLASH",Bs="BACKTICK",_s="CARET",Mn="COLON",Wa="COMMA",zs="DOLLAR",mt="DOT",Fs="EQUALS",Ka="EXCLAMATION",rt="HYPHEN",qr="PERCENT",Hs="PIPE",js="PLUS",Vs="POUND",Wr="QUERY",Ya="QUOTE",qh="FULLWIDTHMIDDLEDOT",Ga="SEMI",gt="SLASH",Kr="TILDE",Us="UNDERSCORE",Wh="EMOJI",qs="SYM";var Kh=Object.freeze({__proto__:null,ALPHANUMERICAL:Uh,AMPERSAND:Rs,APOSTROPHE:Ds,ASCIINUMERICAL:Vh,ASTERISK:Ps,AT:Xt,BACKSLASH:$s,BACKTICK:Bs,CARET:_s,CLOSEANGLEBRACKET:vs,CLOSEBRACE:Ur,CLOSEBRACKET:xs,CLOSEPAREN:ws,COLON:Mn,COMMA:Wa,DOLLAR:zs,DOT:mt,EMOJI:Wh,EQUALS:Fs,EXCLAMATION:Ka,FULLWIDTHGREATERTHAN:Is,FULLWIDTHLEFTPAREN:Ms,FULLWIDTHLESSTHAN:Ls,FULLWIDTHMIDDLEDOT:qh,FULLWIDTHRIGHTPAREN:Ts,HYPHEN:rt,LEFTCORNERBRACKET:As,LEFTWHITECORNERBRACKET:Ns,LOCALHOST:ci,NL:qa,NUM:Ua,OPENANGLEBRACKET:Cs,OPENBRACE:Vr,OPENBRACKET:ks,OPENPAREN:Ss,PERCENT:qr,PIPE:Hs,PLUS:js,POUND:Vs,QUERY:Wr,QUOTE:Ya,RIGHTCORNERBRACKET:Es,RIGHTWHITECORNERBRACKET:Os,SCHEME:ts,SEMI:Ga,SLASH:gt,SLASH_SCHEME:Xn,SYM:qs,TILDE:Kr,TLD:la,UNDERSCORE:Us,UTLD:aa,UWORD:oa,WORD:At,WS:ca});const vt=/[a-z]/,Tr=new RegExp("\\p{L}","u"),xl=new RegExp("\\p{Emoji}","u"),Mt=/\d/,Sl=/\s/,ud="\r",wl=`
168
+ `,QS="️",e1="‍",Cl="";let Vi=null,Ui=null;function t1(t=[]){const e={};We.groups=e;const n=new We;Vi==null&&(Vi=dd(KS)),Ui==null&&(Ui=dd(YS)),$(n,"'",Ds),$(n,"{",Vr),$(n,"}",Ur),$(n,"[",ks),$(n,"]",xs),$(n,"(",Ss),$(n,")",ws),$(n,"<",Cs),$(n,">",vs),$(n,"(",Ms),$(n,")",Ts),$(n,"「",As),$(n,"」",Es),$(n,"『",Ns),$(n,"』",Os),$(n,"<",Ls),$(n,">",Is),$(n,"&",Rs),$(n,"*",Ps),$(n,"@",Xt),$(n,"`",Bs),$(n,"^",_s),$(n,":",Mn),$(n,",",Wa),$(n,"$",zs),$(n,".",mt),$(n,"=",Fs),$(n,"!",Ka),$(n,"-",rt),$(n,"%",qr),$(n,"|",Hs),$(n,"+",js),$(n,"#",Vs),$(n,"?",Wr),$(n,'"',Ya),$(n,"/",gt),$(n,";",Ga),$(n,"~",Kr),$(n,"_",Us),$(n,"\\",$s),$(n,"・",qh);const r=he(n,Mt,Ua,{[na]:!0});he(r,Mt,r);const i=he(r,vt,Vh,{[jr]:!0}),s=he(r,Tr,Uh,{[Pr]:!0}),o=he(n,vt,At,{[ra]:!0});he(o,Mt,i),he(o,vt,o),he(i,Mt,i),he(i,vt,i);const l=he(n,Tr,oa,{[ia]:!0});he(l,vt),he(l,Mt,s),he(l,Tr,l),he(s,Mt,s),he(s,vt),he(s,Tr,s);const a=$(n,wl,qa,{[kl]:!0}),c=$(n,ud,ca,{[kl]:!0}),u=he(n,Sl,ca,{[kl]:!0});$(n,Cl,u),$(c,wl,a),$(c,Cl,u),he(c,Sl,u),$(u,ud),$(u,wl),he(u,Sl,u),$(u,Cl,u);const d=he(n,xl,Wh,{[jh]:!0});$(d,"#"),he(d,xl,d),$(d,QS,d);const p=$(d,e1);$(p,"#"),he(p,xl,d);const h=[[vt,o],[Mt,i]],g=[[vt,null],[Tr,l],[Mt,s]];for(let b=0;b<Vi.length;b++)Kt(n,Vi[b],la,At,h);for(let b=0;b<Ui.length;b++)Kt(n,Ui[b],aa,oa,g);vn(la,{tld:!0,ascii:!0},e),vn(aa,{utld:!0,alpha:!0},e),Kt(n,"file",ts,At,h),Kt(n,"mailto",ts,At,h),Kt(n,"http",Xn,At,h),Kt(n,"https",Xn,At,h),Kt(n,"ftp",Xn,At,h),Kt(n,"ftps",Xn,At,h),vn(ts,{scheme:!0,ascii:!0},e),vn(Xn,{slashscheme:!0,ascii:!0},e),t=t.sort((b,x)=>b[0]>x[0]?1:-1);for(let b=0;b<t.length;b++){const x=t[b][0],A=t[b][1]?{[GS]:!0}:{[JS]:!0};x.indexOf("-")>=0?A[sa]=!0:vt.test(x)?Mt.test(x)?A[jr]=!0:A[ra]=!0:A[na]=!0,cd(n,x,x,A)}return cd(n,"localhost",ci,{ascii:!0}),n.jd=new We(qs),{start:n,tokens:Object.assign({groups:e},Kh)}}function Yh(t,e){const n=n1(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=n.length,i=[];let s=0,o=0;for(;o<r;){let l=t,a=null,c=0,u=null,d=-1,p=-1;for(;o<r&&(a=l.go(n[o]));)l=a,l.accepts()?(d=0,p=0,u=l):d>=0&&(d+=n[o].length,p++),c+=n[o].length,s+=n[o].length,o++;s-=d,o-=p,c-=d,i.push({t:u.t,v:e.slice(s-c,s),s:s-c,e:s})}return i}function n1(t){const e=[],n=t.length;let r=0;for(;r<n;){let i=t.charCodeAt(r),s,o=i<55296||i>56319||r+1===n||(s=t.charCodeAt(r+1))<56320||s>57343?t[r]:t.slice(r,r+2);e.push(o),r+=o.length}return e}function Kt(t,e,n,r,i){let s;const o=e.length;for(let l=0;l<o-1;l++){const a=e[l];t.j[a]?s=t.j[a]:(s=new We(r),s.jr=i.slice(),t.j[a]=s),t=s}return s=new We(n),s.jr=i.slice(),t.j[e[o-1]]=s,s}function dd(t){const e=[],n=[];let r=0,i="0123456789";for(;r<t.length;){let s=0;for(;i.indexOf(t[r+s])>=0;)s++;if(s>0){e.push(n.join(""));for(let o=parseInt(t.substring(r,r+s),10);o>0;o--)n.pop();r+=s}else n.push(t[r]),r++}return e}const ui={defaultProtocol:"http",events:null,format:fd,formatHref:fd,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Ja(t,e=null){let n=Object.assign({},ui);t&&(n=Object.assign(n,t instanceof Ja?t.o:t));const r=n.ignoreTags,i=[];for(let s=0;s<r.length;s++)i.push(r[s].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=i}Ja.prototype={o:ui,ignoreTags:[],defaultRender(t){return t},check(t){return this.get("validate",t.toString(),t)},get(t,e,n){const r=e!=null;let i=this.o[t];return i&&(typeof i=="object"?(i=n.t in i?i[n.t]:ui[t],typeof i=="function"&&r&&(i=i(e,n))):typeof i=="function"&&r&&(i=i(e,n.t,n)),i)},getObj(t,e,n){let r=this.o[t];return typeof r=="function"&&e!=null&&(r=r(e,n.t,n)),r},render(t){const e=t.render(this);return(this.get("render",null,t)||this.defaultRender)(e,t.t,t)}};function fd(t){return t}function Gh(t,e){this.t="token",this.v=t,this.tk=e}Gh.prototype={isLink:!1,toString(){return this.v},toHref(t){return this.toString()},toFormattedString(t){const e=this.toString(),n=t.get("truncate",e,this),r=t.get("format",e,this);return n&&r.length>n?r.substring(0,n)+"…":r},toFormattedHref(t){return t.get("formatHref",this.toHref(t.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(t=ui.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const e=this,n=this.toHref(t.get("defaultProtocol")),r=t.get("formatHref",n,this),i=t.get("tagName",n,e),s=this.toFormattedString(t),o={},l=t.get("className",n,e),a=t.get("target",n,e),c=t.get("rel",n,e),u=t.getObj("attributes",n,e),d=t.getObj("events",n,e);return o.href=r,l&&(o.class=l),a&&(o.target=a),c&&(o.rel=c),u&&Object.assign(o,u),{tagName:i,attributes:o,content:s,eventListeners:d}}};function go(t,e){class n extends Gh{constructor(i,s){super(i,s),this.t=t}}for(const r in e)n.prototype[r]=e[r];return n.t=t,n}const r1=go("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),pd=go("text"),i1=go("nl"),qi=go("url",{isLink:!0,toHref(t=ui.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==ci&&t[1].t===Mn}}),tt=t=>new We(t);function s1({groups:t}){const e=t.domain.concat([Rs,Ps,Xt,$s,Bs,_s,zs,Fs,rt,Ua,qr,Hs,js,Vs,gt,qs,Kr,Us]),n=[Ds,Mn,Wa,mt,Ka,qr,Wr,Ya,Ga,Cs,vs,Vr,Ur,xs,ks,Ss,ws,Ms,Ts,As,Es,Ns,Os,Ls,Is],r=[Rs,Ds,Ps,$s,Bs,_s,zs,Fs,rt,Vr,Ur,qr,Hs,js,Vs,Wr,gt,qs,Kr,Us],i=tt(),s=$(i,Kr);Z(s,r,s),Z(s,t.domain,s);const o=tt(),l=tt(),a=tt();Z(i,t.domain,o),Z(i,t.scheme,l),Z(i,t.slashscheme,a),Z(o,r,s),Z(o,t.domain,o);const c=$(o,Xt);$(s,Xt,c),$(l,Xt,c),$(a,Xt,c);const u=$(s,mt);Z(u,r,s),Z(u,t.domain,s);const d=tt();Z(c,t.domain,d),Z(d,t.domain,d);const p=$(d,mt);Z(p,t.domain,d);const h=tt(r1);Z(p,t.tld,h),Z(p,t.utld,h),$(c,ci,h);const g=$(d,rt);$(g,rt,g),Z(g,t.domain,d),Z(h,t.domain,d),$(h,mt,p),$(h,rt,g);const b=$(o,rt),x=$(o,mt);$(b,rt,b),Z(b,t.domain,o),Z(x,r,s),Z(x,t.domain,o);const w=tt(qi);Z(x,t.tld,w),Z(x,t.utld,w),Z(w,t.domain,o),Z(w,r,s),$(w,mt,x),$(w,rt,b),$(w,Xt,c);const A=$(w,Mn),R=tt(qi);Z(A,t.numeric,R);const O=tt(qi),Y=tt();Z(O,e,O),Z(O,n,Y),Z(Y,e,O),Z(Y,n,Y),$(w,gt,O),$(R,gt,O);const ee=$(l,Mn),H=$(a,Mn),Q=$(H,gt),te=$(Q,gt);Z(l,t.domain,o),$(l,mt,x),$(l,rt,b),Z(a,t.domain,o),$(a,mt,x),$(a,rt,b),Z(ee,t.domain,O),$(ee,gt,O),$(ee,Wr,O),Z(te,t.domain,O),Z(te,e,O),$(te,gt,O);const ye=[[Vr,Ur],[ks,xs],[Ss,ws],[Cs,vs],[Ms,Ts],[As,Es],[Ns,Os],[Ls,Is]];for(let Me=0;Me<ye.length;Me++){const[et,Ee]=ye[Me],le=$(O,et);$(Y,et,le);const De=tt(qi);Z(le,e,De);const z=tt();Z(le,n,z),$(le,Ee,O),Z(De,e,De),Z(De,n,z),Z(z,e,De),Z(z,n,z),$(De,Ee,O),$(z,Ee,O)}return $(i,ci,w),$(i,qa,i1),{start:i,tokens:Kh}}function o1(t,e,n){let r=n.length,i=0,s=[],o=[];for(;i<r;){let l=t,a=null,c=null,u=0,d=null,p=-1;for(;i<r&&!(a=l.go(n[i].t));)o.push(n[i++]);for(;i<r&&(c=a||l.go(n[i].t));)a=null,l=c,l.accepts()?(p=0,d=l):p>=0&&p++,i++,u++;if(p<0)i-=u,i<r&&(o.push(n[i]),i++);else{o.length>0&&(s.push(vl(pd,e,o)),o=[]),i-=p,u-=p;const h=d.t,g=n.slice(i-u,i);s.push(vl(h,e,g))}}return o.length>0&&s.push(vl(pd,e,o)),s}function vl(t,e,n){const r=n[0].s,i=n[n.length-1].e,s=e.slice(r,i);return new t(s,n)}const l1=typeof console<"u"&&console&&console.warn||(()=>{}),a1="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",de={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function c1(){return We.groups={},de.scanner=null,de.parser=null,de.tokenQueue=[],de.pluginQueue=[],de.customSchemes=[],de.initialized=!1,de}function hd(t,e=!1){if(de.initialized&&l1(`linkifyjs: already initialized - will not register custom scheme "${t}" ${a1}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format.
169
+ 1. Must only contain digits, lowercase ASCII letters or "-"
170
+ 2. Cannot start or end with "-"
171
+ 3. "-" cannot repeat`);de.customSchemes.push([t,e])}function u1(){de.scanner=t1(de.customSchemes);for(let t=0;t<de.tokenQueue.length;t++)de.tokenQueue[t][1]({scanner:de.scanner});de.parser=s1(de.scanner.tokens);for(let t=0;t<de.pluginQueue.length;t++)de.pluginQueue[t][1]({scanner:de.scanner,parser:de.parser});return de.initialized=!0,de}function Xa(t){return de.initialized||u1(),o1(de.parser.start,t,Yh(de.scanner.start,t))}Xa.scan=Yh;function Jh(t,e=null,n=null){if(e&&typeof e=="object"){if(n)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);n=e,e=null}const r=new Ja(n),i=Xa(t),s=[];for(let o=0;o<i.length;o++){const l=i[o];l.isLink&&(!e||l.t===e)&&r.check(l)&&s.push(l.toFormattedObject(r))}return s}const yo="[\0-   ᠎ -\u2029  ]",d1=new RegExp(yo),f1=new RegExp(`${yo}$`),p1=new RegExp(`${yo}+$`),h1=new RegExp(yo,"g");function m1(t,e,n){var r,i;const s=t.doc.resolve(e.to);if(!(!((r=s.nodeBefore)===null||r===void 0)&&r.isText))return;const o=(i=t.doc.textBetween(e.from,e.to,"","").match(p1))===null||i===void 0?void 0:i[0];if(!o)return;const l=e.to-o.length,a=ho(l,e.to,t.doc).filter(d=>d.mark.type===n);if(!a.length)return;const{nodeAfter:c}=s;if(c&&a.some(d=>d.mark.isInSet(c.marks)))return;const u=t.storedMarks;t.removeMark(l,e.to,n),t.setStoredMarks(u),t.selection.empty&&t.selection.from===e.to&&t.removeStoredMark(n)}function g1(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function y1(t){return new fe({key:new xe("autolink"),appendTransaction:(e,n,r)=>{const i=e.some(a=>a.docChanged)&&!n.doc.eq(r.doc),s=e.some(a=>a.getMeta("preventAutolink"));if(!i||s)return;const{tr:o}=r,l=kh(n.doc,[...e]);if(!e.some(X0)){const a=[];l.steps.forEach((c,u)=>{if(!(c instanceof me)||!c.slice.size)return;const d=l.mapping.slice(u+1),p=d.map(c.from,1),h=d.map(c.from+c.slice.size,-1);p<h&&a.push({from:p,to:h})}),a.sort((c,u)=>u.to-c.to),a.forEach(c=>m1(o,c,t.type))}if(po(l).forEach(({newRange:a})=>{const c=Vk(r.doc,a,p=>p.isTextblock);let u,d;if(c.length>1)u=c[0],d=r.doc.textBetween(u.pos,u.pos+u.node.nodeSize,void 0," ");else if(c.length){const p=r.doc.textBetween(a.from,a.to," "," ");if(!f1.test(p))return;u=c[0],d=r.doc.textBetween(u.pos,a.to,void 0," ")}if(u&&d){const p=d.split(d1).filter(Boolean);if(p.length<=0)return!1;const h=p[p.length-1],g=u.pos+d.lastIndexOf(h);if(!h)return!1;const b=Xa(h).map(x=>x.toObject(t.defaultProtocol));if(!g1(b))return!1;b.filter(x=>x.isLink).map(x=>({...x,from:g+x.start+1,to:g+x.end+1})).filter(x=>r.schema.marks.code?!r.doc.rangeHasMark(x.from,x.to,r.schema.marks.code):!0).filter(x=>t.validate(x.value)).filter(x=>t.shouldAutoLink(x.value)).forEach(x=>{ho(x.from,x.to,r.doc).some(w=>w.mark.type===t.type)||o.addMark(x.from,x.to,t.type.create({href:x.href}))})}}),!!o.steps.length)return o}})}function b1(t){return new fe({key:new xe("handleClickLink"),props:{handleClick:(e,n,r)=>{if(r.button!==0||!e.editable)return!1;let i=null;if(r.target instanceof HTMLAnchorElement)i=r.target;else{const a=r.target;if(!a)return!1;const c=t.editor.view.dom;i=a.closest("a"),i&&!c.contains(i)&&(i=null)}if(!i)return!1;let s=!1;if(t.enableClickSelection&&(s=t.editor.commands.extendMarkRange(t.type.name)),t.openOnClick){var o,l;const a=vh(e.state,t.type.name),c=(o=i.href)!==null&&o!==void 0?o:a.href,u=(l=i.target)!==null&&l!==void 0?l:a.target;c&&(window.open(c,u),s=!0)}return s}}})}const k1=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)$/,x1=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)/g;function Xh(t,e){let n=0;for(let r=e-1;r>=0&&t[r]==="\\";r-=1)n+=1;return n%2===1}function S1(t,e){let n=0,r=0;for(;r<e;){if(t[r]!=="`"){r+=1;continue}if(n===0&&Xh(t,r)){r+=1;continue}let i=0;for(;r<e&&t[r]==="`";)i+=1,r+=1;n===0?n=i:i===n&&(n=0)}return n>0}function Zh(t,e,n){var r,i;const[,s,o]=e;return(e.index?t[e.index-1]:void 0)==="!"||Xh(t,(r=e.index)!==null&&r!==void 0?r:0)||S1(t,(i=e.index)!==null&&i!==void 0?i:0)?!1:!!s.trim()&&n(o)}function Qh(t){var e,n;const[r,i,s,,o,l,a]=t,c=(e=o??l)!==null&&e!==void 0?e:a;return{index:(n=t.index)!==null&&n!==void 0?n:0,text:r,replaceWith:i,data:{href:s,title:c||null,markdown:!0}}}function w1(t,e){return t.index<e.index+e.text.length&&e.index<t.index+t.text.length}function em(t){var e,n,r;return{href:(e=t.data)===null||e===void 0?void 0:e.href,title:(n=(r=t.data)===null||r===void 0?void 0:r.title)!==null&&n!==void 0?n:null}}function C1(t){const e=Pn({find:n=>{const r=k1.exec(n);return!r||!Zh(n,r,t.isAllowedHref)?null:Qh(r)},type:t.type,getAttributes:em});return new Si({find:e.find,handler:n=>{const r=e.handler(n);return r!==null&&n.state.tr.steps.length&&n.state.tr.setMeta("preventAutolink",!0),r}})}function v1(t){const e=fn({find:n=>{var r,i;const s=[];for(const l of n.matchAll(x1))Zh(n,l,t.isAllowedHref)&&s.push(Qh(l));const o=((r=(i=t.findPlainUrls)===null||i===void 0?void 0:i.call(t,n))!==null&&r!==void 0?r:[]).filter(l=>!s.some(a=>w1(a,l)));return[...s,...o]},type:t.type,getAttributes:em});return new $h({find:e.find,handler:n=>{var r;const i=e.handler(n);return i!==null&&n.state.tr.steps.length&&(!((r=n.match.data)===null||r===void 0)&&r.markdown)&&n.state.tr.setMeta("preventAutolink",!0),i}})}function M1(t){return new fe({key:new xe("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{shouldAutoLink:i}=t,{state:s}=e,{selection:o}=s,{empty:l}=o;if(l)return!1;let a="";r.content.forEach(u=>{a+=u.textContent});const c=Jh(a,{defaultProtocol:t.defaultProtocol}).find(u=>u.isLink&&u.value===a);return!a||!c||i!==void 0&&!i(c.value)?!1:t.editor.commands.setMark(t.type,{href:c.href})}}})}function Tt(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const i=typeof r=="string"?r:r.scheme;i&&n.push(i)}),!t||t.replace(h1,"").match(new RegExp(`^(?:(?:${n.map(r=>r.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")).join("|")}):|[^a-z]|[a-z0-9+.\\-]+(?:[^a-z+.\\-:]|$))`,"i"))}const tm=gn.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(t=>{if(typeof t=="string"){hd(t);return}hd(t.scheme,t.optionalSlashes)})},onDestroy(){c1()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,markdownLinks:!1,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(t,e)=>!!Tt(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>{const e=/^[a-z][a-z0-9+.-]*:\/\//i.test(t),n=/^[a-z][a-z0-9+.-]*:/i.test(t);if(e||n&&!t.includes("@"))return!0;const r=(t.includes("@")?t.split("@").pop():t).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(r)||!/\./.test(r))}}},addAttributes(){var t,e,n;return{href:{default:null,parseHTML(r){return r.getAttribute("href")}},target:{default:(t=this.options.HTMLAttributes.target)!==null&&t!==void 0?t:null},rel:{default:(e=this.options.HTMLAttributes.rel)!==null&&e!==void 0?e:null},class:{default:(n=this.options.HTMLAttributes.class)!==null&&n!==void 0?n:null},title:{default:null}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{const e=t.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:n=>!!Tt(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:e=>!!Tt(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",be(this.options.HTMLAttributes,t),0]:["a",be(this.options.HTMLAttributes,{...t,href:""}),0]},markdownTokenName:"link",parseMarkdown:(t,e)=>e.applyMark("link",e.parseInline(t.tokens||[]),{href:t.href,title:t.title||null}),renderMarkdown:(t,e)=>{var n,r,i,s;const o=(n=(r=t.attrs)===null||r===void 0?void 0:r.href)!==null&&n!==void 0?n:"",l=(i=(s=t.attrs)===null||s===void 0?void 0:s.title)!==null&&i!==void 0?i:"",a=e.renderChildren(t);return l?`[${a}](${o} "${l}")`:`[${a}](${o})`},addCommands(){return{setLink:t=>({chain:e})=>{const{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!Tt(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,t).setMeta("preventAutolink",!0).run():!1},toggleLink:t=>({chain:e})=>{const{href:n}=t||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:r=>!!Tt(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addInputRules(){return this.options.markdownLinks?[C1({type:this.type,isAllowedHref:t=>this.options.isAllowedUri(t,{defaultValidate:e=>!!Tt(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})})]:[]},addPasteRules(){const t=e=>{const n=[];if(e){const{protocols:r,defaultProtocol:i}=this.options;Jh(e).filter(s=>s.isLink&&this.options.isAllowedUri(s.value,{defaultValidate:o=>!!Tt(o,r),protocols:r,defaultProtocol:i})).forEach(s=>{this.options.shouldAutoLink(s.value)&&n.push({text:s.value,data:{href:s.href},index:s.start})})}return n};return this.options.markdownLinks?[v1({type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:n=>!!Tt(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol}),findPlainUrls:t})]:[fn({find:t,type:this.type,getAttributes:e=>{var n;return{href:(n=e.data)===null||n===void 0?void 0:n.href}}})]},addProseMirrorPlugins(){const t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(y1({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!Tt(i,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),t.push(b1({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(M1({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}});var T1=tm;const A1="listItem",md="textStyle",gd=/^\s*([-+*])\s$/,nm=Ye.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:t}){return["ul",be(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>t.type!=="list"||t.ordered?[]:{type:"bulletList",content:t.items?e.parseChildren(t.items):[]},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
172
+ `):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(A1,this.editor.getAttributes(md)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=cr({find:gd,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=cr({find:gd,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(md),editor:this.editor})),[t]}}),E1=(t,e,n)=>{const{selection:r}=t;if(!r.empty)return null;const{$from:i}=r;if(!i.parent.isTextblock||i.parentOffset!==i.parent.content.size)return null;let s=-1;for(let h=i.depth;h>0;h-=1)if(i.node(h).type.name===e){s=h;break}if(s<0)return null;const o=i.node(s),l=i.index(s);if(l+1>=o.childCount)return null;const a=o.child(l+1);if(!n.includes(a.type.name))return null;const c=t.schema.nodes[e];let u=!1;if(a.forEach(h=>{h.type===c&&h.childCount>1&&(u=!0)}),!u)return null;const d=t.doc.resolve(i.after()).nodeAfter;if(!d||!n.includes(d.type.name))return null;const p=[];return d.forEach(h=>{p.push(h)}),p.length===0?null:{listItemDepth:s,nestedList:d,nestedListPos:i.after(),insertPos:i.after(s),items:p}},N1=(t,e,n,r)=>{const i=E1(t,n,r);if(!i)return!1;const{selection:s}=t,{nestedList:o,nestedListPos:l,insertPos:a,items:c}=i,u=t.tr;u.delete(l,l+o.nodeSize);const d=u.mapping.map(a);return u.insert(d,I.from(c)),u.setSelection(s.map(u.doc,u.mapping)),e&&e(u),!0},O1=(t,e,n)=>N1(t.state,t.view.dispatch,e,n),rm=(t,e)=>ae.create({name:`${t}BranchingDeleteKeymap`,priority:101,addKeyboardShortcuts(){const n=()=>O1(this.editor,t,e);return{Delete:n,"Mod-Delete":n}}}),im=[[1e3,"m"],[900,"cm"],[500,"d"],[400,"cd"],[100,"c"],[90,"xc"],[50,"l"],[40,"xl"],[10,"x"],[9,"ix"],[5,"v"],[4,"iv"],[1,"i"]],Wi="abcdefghijklmnopqrstuvwxyz",sm=String.raw`\d+|[ivxlcdmIVXLCDM]+|${"[a-zA-Z]{1,2}"}`;function bo(t){let e=t,n="";for(const[r,i]of im)for(;e>=r;)n+=i,e-=r;return n}function Za(t){return bo(t).toUpperCase()}function om(t){const e=t.toLowerCase();let n=0,r=0;for(;n<e.length;){let i=!1;for(const[s,o]of im)if(e.startsWith(o,n)){r+=s,n+=o.length,i=!0;break}if(!i)return 0}return r}function L1(t){if(!/^[ivxlcdmIVXLCDM]+$/.test(t))return!1;const e=om(t);return e<=0?!1:(t===t.toLowerCase()?bo(e):Za(e))===t}function I1(t){const e=t.toLowerCase();if(e.length===1)return e.charCodeAt(0)-97+1;if(e.length===2){const n=e.charCodeAt(0)-97,r=e.charCodeAt(1)-97;return(n+1)*26+r+1}return 0}function Ws(t){if(t<=26)return Wi[t-1];const e=Math.floor((t-1)/26)-1,n=(t-1)%26;return e<0?Wi[n]:Wi[e]+Wi[n]}function ko(t){if(!(!t||/^\d+$/.test(t))){if(L1(t))return t===t.toLowerCase()?"i":"I";if(/^[a-z]{1,2}$/.test(t))return"a";if(/^[A-Z]{1,2}$/.test(t))return"A"}}function Qa(t){if(/^\d+$/.test(t))return parseInt(t,10);const e=ko(t);if(e==="i"||e==="I")return om(t);if(e==="a"||e==="A"){const r=I1(t);return r>0?r:1}const n=parseInt(t,10);return Number.isNaN(n)?1:n}function R1(t,e){if(t==="numeric")return String(e);switch(t){case"a":return Ws(e);case"A":return Ws(e).toUpperCase();case"i":return bo(e);case"I":return Za(e);default:return String(e)}}function D1(t){var e;if(t.length===0)return!1;const n=(e=ko(t[0]))!==null&&e!==void 0?e:"numeric",r=Qa(t[0]);if(r<1)return!1;for(let i=0;i<t.length;i++){const s=R1(n,r+i);if(t[i]!==s)return!1}return!0}function P1(t){return{type:ko(t),start:Qa(t)}}function $1(t){const{type:e,start:n}=P1(t),r={};return e&&(r.type=e),n!==1&&(r.start=n),r}function B1(t,e,n=". "){const r=e+1;if(!t||t==="1")return`${r}${n}`;switch(t){case"a":return`${Ws(r)}${n}`;case"A":return`${Ws(r).toUpperCase()}${n}`;case"i":return`${bo(r)}${n}`;case"I":return`${Za(r)}${n}`;default:return`${r}${n}`}}function _1(t){var e,n;const r=(e=t.tokens)===null||e===void 0?void 0:e[0];return!!(t.text&&((n=t.tokens)===null||n===void 0?void 0:n.length)===1&&(r==null?void 0:r.type)==="list"&&r.ordered&&r.raw===t.text)}function z1(t,e){return e.tokenizeInline?e.parseInline(e.tokenizeInline(t)):e.parseInline([{type:"text",raw:t,text:t}])}const lm=Ye.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",be(this.options.HTMLAttributes,t),0]},markdownTokenName:"list_item",parseMarkdown:(t,e)=>{var n;if(t.type!=="list_item")return[];const r=(n=e.parseBlockChildren)!==null&&n!==void 0?n:e.parseChildren;let i=[];if(t.tokens&&t.tokens.length>0){if(_1(t))return{type:"listItem",content:[{type:"paragraph",content:z1(t.text||"",e)}]};if(t.tokens.some(s=>s.type==="paragraph"))i=r(t.tokens);else{const s=t.tokens[0];if(s&&s.type==="text"&&s.tokens&&s.tokens.length>0){if(i=[{type:"paragraph",content:e.parseInline(s.tokens)}],t.tokens.length>1){const o=r(t.tokens.slice(1));i.push(...o)}}else i=r(t.tokens)}}return i.length===0&&(i=[{type:"paragraph",content:[]}]),{type:"listItem",content:i}},renderMarkdown:(t,e,n)=>Rh(t,e,r=>{if(r.parentType==="bulletList")return"- ";if(r.parentType==="orderedList"){var i,s;const o=((i=r.meta)===null||i===void 0||(i=i.parentAttrs)===null||i===void 0?void 0:i.start)||1;return B1((s=r.meta)===null||s===void 0||(s=s.parentAttrs)===null||s===void 0?void 0:s.type,o-1+(r.index||0),". ")}return"- "},n,{alignNestedToPrefix:(n==null?void 0:n.parentType)==="orderedList"}),addExtensions(){return[rm(this.name,[this.options.bulletListTypeName,this.options.orderedListTypeName])]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),ec=(t,e)=>{const{$from:n}=e.selection,r=Ce(t,e.schema);let i=null,s=n.depth,o=n.pos,l=null;for(;s>0&&l===null;)i=n.node(s),i.type===r?l=s:(s-=1,o-=1);return l===null?null:{$pos:e.doc.resolve(o),depth:l}},am=(t,e)=>{const n=ec(t,e);if(!n)return!1;const[,r]=ex(e,t,n.$pos.pos+4);return r},F1=(t,e,n)=>{const{$anchor:r}=t.selection,i=Math.max(0,r.pos-2),s=t.doc.resolve(i).node();return!(!s||!n.includes(s.type.name))},yd=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!_t(t.state,e)&&F1(t.state,e,n)){const{$anchor:s}=t.state.selection,o=t.state.doc.resolve(s.before()-1),l=[];o.node().descendants((u,d)=>{u.type.name===e&&l.push({node:u,pos:d})});const a=l.at(-1);if(!a)return!1;const c=t.state.doc.resolve(o.start()+a.pos+1);return t.chain().cut({from:s.start()-1,to:s.end()+1},c.end()).joinForward().run()}if(!_t(t.state,e)||!sx(t.state))return!1;const{$from:r}=t.state.selection,i=r.depth-1;return r.node(i).type!==t.schema.nodes[e]||r.index(i)!==0?!1:t.chain().liftListItem(e).run()},H1=(t,e)=>{const n=am(t,e),r=ec(t,e);return!r||!n?!1:n>r.depth},j1=(t,e)=>{const n=am(t,e),r=ec(t,e);return!r||!n?!1:n<r.depth},bd=(t,e)=>{if(!_t(t.state,e)||!ix(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:i}=n;return!n.empty&&r.sameParent(i)?!1:H1(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():j1(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},V1=(t,e,n)=>{const{state:r}=t,{selection:i}=r;if(!i.empty)return!1;const{$from:s}=i;if(s.parentOffset!==0||!s.parent.isTextblock||_t(r,e))return!1;const o=tx(s);if(!o||!n.includes(o.type.name))return!1;const l=o.lastChild;if(!l||l.type.name!==e)return!1;const a=s.parent;if(!l.canReplace(l.childCount,l.childCount,I.from(a)))return!1;const c=s.before(),u=s.after(),d=c-2;return t.commands.command(({tr:p,dispatch:h})=>(h&&(p.delete(c,u).insert(d,I.from(a)),p.setSelection(q.create(p.doc,d+1)),p.scrollIntoView()),!0))},cm=ae.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&bd(t,n)&&(e=!0)}),e},"Mod-Delete":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&bd(t,n)&&(e=!0)}),e},Backspace:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&yd(t,n,r)&&(e=!0)}),e},"Mod-Backspace":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&yd(t,n,r)&&(e=!0)}),e},Tab:({editor:t})=>{for(const{itemName:e,wrapperNames:n}of this.options.listTypes)if(t.state.schema.nodes[e]!==void 0&&V1(t,e,n))return!0;return!1}}}}),Ks=new RegExp(`^(\\s*)(${sm})([.)])\\s+(.*)$`),U1=/^\s/,Zn={heading:/^#{1,6}(?:\s|$)/,bulletItem:/^[-+*]\s+/,codeFence:/^(?:```|~~~)/,blockMath:/^\$\$/,thematicBreak:/^(?:(?:-[ \t]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})$/};function q1(t){return Ks.test(t.trimStart())}function W1(t){const e=t.trimStart();return Zn.bulletItem.test(e)||q1(e)||Zn.heading.test(e)||Zn.thematicBreak.test(e)&&!e.startsWith("-")||/^>\s?/.test(e)||Zn.codeFence.test(e)||Zn.blockMath.test(e)}function K1(t){return Object.values(Zn).some(e=>e.test(t))}function Y1(t){const e=[],n=[];let r=!1;return t.forEach(i=>{if(r){n.push(i);return}if(i.trim()===""){r=!0,n.push(i);return}if(e.length>0&&W1(i)){r=!0,n.push(i);return}e.push(i)}),{paragraphLines:e,blockLines:n}}function kd(t){const e=[];let n=0,r=0;for(;n<t.length;){const i=t[n],s=i.match(Ks);if(!s)break;const[,o,l,a,c]=s,u=o.length,d=parseInt(l,10),p=isNaN(d)?ko(l):void 0,h=isNaN(d)?Qa(l):d,g=[c];let b=n+1;const x=[i];let w=!1;for(;b<t.length;){const A=t[b];if(A.match(Ks))break;if(A.trim()==="")x.push(A),g.push(""),w=!0,b+=1;else if(A.match(U1)){const R=A.length-A.trimStart().length,O=u+l.length+1;x.push(A),g.push(A.slice(Math.min(R,O))),b+=1}else{if(w||K1(A))break;x.push(A),g.push(A),b+=1}}e.push({indent:u,number:h,type:p,content:g.join(`
173
+ `).trim(),contentLines:g,raw:x.join(`
174
+ `)}),r=b,n=b}return[e,r]}const G1=new RegExp(`^(${sm})([.)])\\s+(.+)$`);function J1(t){const e=t.split(`
175
+ `).filter(r=>r.trim().length>0);if(e.length===0)return null;const n=[];for(const r of e){const i=r.trim().match(G1);if(!i)return null;n.push({marker:i[1],content:i[3]})}return D1(n.map(r=>r.marker))?{type:"orderedList",attrs:$1(n[0].marker),content:n.map(r=>({type:"listItem",content:[{type:"paragraph",content:[{type:"text",text:r.content}]}]}))}:null}function um(t,e,n){const r=[];let i=0;for(;i<t.length;){const s=t[i];if(s.indent===e){const{paragraphLines:o,blockLines:l}=Y1(s.contentLines),a=o.join(`
176
+ `).trim(),c=[];a&&c.push({type:"paragraph",raw:a,tokens:n.inlineTokens(a)});const u=l.join(`
177
+ `).trim();if(u){const h=n.blockTokens(u);c.push(...h)}let d=i+1;const p=[];for(;d<t.length&&t[d].indent>e;)p.push(t[d]),d+=1;if(p.length>0){const h=um(p,Math.min(...p.map(g=>g.indent)),n);c.push({type:"list",ordered:!0,start:p[0].number,typeMarker:p[0].type,items:h,raw:p.map(g=>g.raw).join(`
178
+ `)})}r.push({type:"list_item",raw:s.raw,tokens:c}),i=d}else i+=1}return r}function X1(t,e){return t.map(n=>{if(n.type!=="list_item")return e.parseChildren([n])[0];const r=[];return n.tokens&&n.tokens.length>0&&n.tokens.forEach(i=>{if(i.type==="paragraph"||i.type==="list"||i.type==="blockquote"||i.type==="code")r.push(...e.parseChildren([i]));else if(i.type==="text"&&i.tokens){const s=e.parseChildren([i]);r.push({type:"paragraph",content:s})}else{const s=e.parseChildren([i]);s.length>0&&r.push(...s)}}),{type:"listItem",content:r}})}const Z1=64;function xd(t,e){const n=[];let r=0;for(;n.length<e;){const i=t.indexOf(`
179
+ `,r);if(i===-1)return n.push(t.slice(r)),n;n.push(t.slice(r,i)),r=i+1}return n}function Q1(t){const e=t.indexOf(`
180
+ `),n=e===-1?t:t.slice(0,e);if(!Ks.test(n))return[[],0,[]];let r=Z1,i=xd(t,r),s=kd(i);for(;s[1]===i.length&&i.length===r;)r*=2,i=xd(t,r),s=kd(i);return[s[0],s[1],i]}const ew="listItem",Sd="textStyle",wd=/^(\d+)\.\s$/;function Cd(t){const e=t.match(/list-style-type\s*:\s*([^;]+)/i);if(!e)return null;switch(e[1].trim().toLowerCase()){case"upper-roman":return"I";case"lower-roman":return"i";case"upper-alpha":case"upper-latin":return"A";case"lower-alpha":case"lower-latin":return"a";default:return null}}const dm=Ye.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>{const e=t.getAttribute("type");if(e)return e;const n=t.getAttribute("style");if(n){const i=Cd(n);if(i)return i}const r=t.querySelector("li");if(r){const i=r.getAttribute("style");if(i){const s=Cd(i);if(s)return s}}return null}}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:e,type:n,...r}=t,i=be(this.options.HTMLAttributes,r);return e!==1&&(i.start=e),n&&n!=="1"&&(i.type=n),["ol",i,0]},markdownTokenName:"list",parseMarkdown:(t,e)=>{if(t.type!=="list"||!t.ordered)return[];const n=t.start||1,r=t.typeMarker,i=t.items?X1(t.items,e):[],s={};return n!==1&&(s.start=n),r&&(s.type=r),Object.keys(s).length>0?{type:"orderedList",attrs:s,content:i}:{type:"orderedList",content:i}},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
181
+ `):"",markdownTokenizer:{name:"orderedList",level:"block",start:()=>-1,tokenize:(t,e,n)=>{var r,i;const[s,o,l]=Q1(t);if(s.length===0)return;const a=um(s,s[0].indent,n);if(a.length!==0)return{type:"list",ordered:!0,start:((r=s[0])===null||r===void 0?void 0:r.number)||1,typeMarker:(i=s[0])===null||i===void 0?void 0:i.type,items:a,raw:l.slice(0,o).join(`
182
+ `)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(ew,this.editor.getAttributes(Sd)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addProseMirrorPlugins(){return[new fe({props:{handlePaste:(t,e)=>{var n,r;const i=(n=e.clipboardData)===null||n===void 0?void 0:n.getData("text/html");if(i!=null&&i.trim())return!1;const s=(r=e.clipboardData)===null||r===void 0?void 0:r.getData("text/plain");if(!s)return!1;const o=J1(s);if(!o)return!1;try{const l=t.state.schema.nodeFromJSON(o),a=t.state.tr.replaceSelectionWith(l);return t.dispatch(a),!0}catch{return!1}}}})]},addInputRules(){const t=(n,r)=>(!r.attrs.type||r.attrs.type==="1")&&r.childCount+r.attrs.start===+n[1];let e=cr({find:wd,type:this.type,getAttributes:n=>({start:+n[1]}),joinPredicate:t});return(this.options.keepMarks||this.options.keepAttributes)&&(e=cr({find:wd,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:n=>({start:+n[1],...this.editor.getAttributes(Sd)}),joinPredicate:t,editor:this.editor})),[e]}}),tw=/^\s*(\[([( |x])?\])\s$/,nw="position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0",rw=(t,e,n)=>{var r;return(n==null||(r=n.checkboxLabel)===null||r===void 0?void 0:r.call(n,t,e))||`Task item checkbox for ${t.textContent||"empty task item"}`},iw=Ye.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:t=>{const e=t.getAttribute("data-checked");return e===""||e==="true"},renderHTML:t=>({"data-checked":t.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51,contentElement:t=>{var e;return(e=t.querySelector("div"))!==null&&e!==void 0?e:t}}]},renderHTML({node:t,HTMLAttributes:e}){return["li",be(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(t,e)=>{const n=[];if(t.tokens&&t.tokens.length>0?n.push(e.createNode("paragraph",{},e.parseInline(t.tokens))):t.text?n.push(e.createNode("paragraph",{},[e.createNode("text",{text:t.text})])):n.push(e.createNode("paragraph",{},[])),t.nestedTokens&&t.nestedTokens.length>0){const r=e.parseChildren(t.nestedTokens);n.push(...r)}return e.createNode("taskItem",{checked:t.checked||!1},n)},renderMarkdown:(t,e)=>{var n;const r=`- [${!((n=t.attrs)===null||n===void 0)&&n.checked?"x":" "}] `;return Rh(t,e,r)},addExtensions(){return this.options.nested?[rm(this.name,[this.options.taskListTypeName])]:[]},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{const i=document.createElement("li"),s=document.createElement("label"),o=document.createElement("span"),l=document.createElement("input"),a=document.createElement("div");o.style.cssText=nw;const c=d=>{const p=rw(d,d.attrs.checked,this.options.a11y);l.setAttribute("aria-label",p),o.textContent=p};c(t),s.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",d=>d.preventDefault()),l.addEventListener("change",d=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}const{checked:p}=d.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:h})=>{const g=n();if(typeof g!="number")return!1;const b=h.doc.nodeAt(g);return h.setNodeMarkup(g,void 0,{...b==null?void 0:b.attrs,checked:p}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,p)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([d,p])=>{i.setAttribute(d,p)}),i.dataset.checked=t.attrs.checked,l.checked=t.attrs.checked,s.append(l,o),i.append(s,a),Object.entries(e).forEach(([d,p])=>{i.setAttribute(d,p)});let u=new Set(Object.keys(e));return{dom:i,contentDOM:a,update:d=>{if(d.type!==this.type)return!1;i.dataset.checked=d.attrs.checked,l.checked=d.attrs.checked,c(d);const p=r.extensionManager.attributes,h=ai(d,p),g=new Set(Object.keys(h)),b=this.options.HTMLAttributes;return u.forEach(x=>{g.has(x)||(x in b?i.setAttribute(x,b[x]):i.removeAttribute(x))}),Object.entries(h).forEach(([x,w])=>{w==null?x in b?i.setAttribute(x,b[x]):i.removeAttribute(x):i.setAttribute(x,w)}),u=g,!0}}}},addInputRules(){return[cr({find:tw,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),sw=Ye.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:t}){return["ul",be(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},parseMarkdown:(t,e)=>e.createNode("taskList",{},e.parseChildren(t.items||[])),renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
183
+ `):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const n=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))===null||e===void 0?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){const r=s=>{const o=sd(s,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:l=>({indentLevel:l[1].length,mainContent:l[4],checked:l[3].toLowerCase()==="x"}),createToken:(l,a)=>({type:"taskItem",raw:"",mainContent:l.mainContent,indentLevel:l.indentLevel,checked:l.checked,text:l.mainContent,tokens:n.inlineTokens(l.mainContent),nestedTokens:a}),customNestedParser:r},n);if(o){const l={type:"taskList",raw:o.raw,items:o.items},a=s.slice(o.raw.length);return a.trim()?[l,...n.blockTokens(a)]:[l]}return n.blockTokens(s)},i=sd(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:s=>({indentLevel:s[1].length,mainContent:s[4],checked:s[3].toLowerCase()==="x"}),createToken:(s,o)=>({type:"taskItem",raw:"",mainContent:s.mainContent,indentLevel:s.indentLevel,checked:s.checked,text:s.mainContent,tokens:n.inlineTokens(s.mainContent),nestedTokens:o}),customNestedParser:r},n);if(i)return{type:"taskList",raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});ae.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(nm.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(lm.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(cm.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(dm.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(iw.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(sw.configure(this.options.taskList)),t}});const Ki="&nbsp;",Ml=" ",ow=Ye.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",be(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{const n=t.tokens||[];if(n.length===1&&n[0].type==="image")return e.parseChildren([n[0]]);const r=e.parseInline(n);return n.length===1&&n[0].type==="text"&&(n[0].raw===Ki||n[0].text===Ki||n[0].raw===Ml||n[0].text===Ml)&&r.length===1&&r[0].type==="text"&&(r[0].text===Ki||r[0].text===Ml)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,r)},renderMarkdown:(t,e,n)=>{if(!t)return"";const r=Array.isArray(t.content)?t.content:[];if(r.length===0){var i,s;const o=Array.isArray(n==null||(i=n.previousNode)===null||i===void 0?void 0:i.content)?n.previousNode.content:[];return(n==null||(s=n.previousNode)===null||s===void 0?void 0:s.type)==="paragraph"&&o.length===0?Ki:""}return e.renderChildren(r)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),lw=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,aw=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,cw=gn.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",be(this.options.HTMLAttributes,t),0]},markdownTokenName:"del",parseMarkdown:(t,e)=>e.applyMark("strike",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`~~${e.renderChildren(t)}~~`,addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Pn({find:lw,type:this.type})]},addPasteRules(){return[fn({find:aw,type:this.type})]}}),uw=Ye.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),dw=gn.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",be(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`++${e.renderChildren(t)}++`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.indexOf("++")},tokenize(t,e,n){const r=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!r)return;const i=r[2].trim();return{type:"underline",raw:r[0],text:i,tokens:n.inlineTokens(i)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function fw(t={}){return new fe({view(e){return new pw(e,t)}})}class pw{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let s=o=>{this[i](o)};return e.dom.addEventListener(i,s),{name:i,handler:s}})}destroy(){this.setCursor(null),this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){if(this.cursorPos!=null&&n.doc!=e.state.doc)if(this.lastDragEvent){let r=this.computeTarget(this.lastDragEvent);r==this.cursorPos?this.updateOverlay():this.setCursor(r)}else this.updateOverlay()}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r,i=this.editorView.dom,s=i.getBoundingClientRect(),o=s.width/i.offsetWidth,l=s.height/i.offsetHeight;if(n){let d=e.nodeBefore,p=e.nodeAfter;if(d||p){let h=this.editorView.nodeDOM(this.cursorPos-(d?d.nodeSize:0));if(h){let g=h.getBoundingClientRect(),b=d?g.bottom:g.top;d&&p&&(b=(b+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let x=this.width/2*l;r={left:g.left,right:g.right,top:b-x,bottom:b+x}}}}if(!r){let d=this.editorView.coordsAtPos(this.cursorPos),p=this.width/2*o;r={left:d.left-p,right:d.left+p,top:d.top,bottom:d.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let c,u;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,u=-pageYOffset;else{let d=a.getBoundingClientRect(),p=d.width/a.offsetWidth,h=d.height/a.offsetHeight;c=d.left-a.scrollLeft*p,u=d.top-a.scrollTop*h}this.element.style.left=(r.left-c)/o+"px",this.element.style.top=(r.top-u)/l+"px",this.element.style.width=(r.right-r.left)/o+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}computeTarget(e){let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),i=r&&r.type.spec.disableDropCursor,s=typeof i=="function"?i(this.editorView,n,e):i;if(!n||s)return null;let o=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=Zf(this.editorView.state.doc,o,this.editorView.dragging.slice);l!=null&&(o=l)}return o}dragover(e){if(!this.editorView.editable)return;this.lastDragEvent=e;let n=this.computeTarget(e);n!=null&&(this.setCursor(n),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class ge extends J{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return ge.valid(r)?new ge(r):J.near(r)}content(){return _.empty}eq(e){return e instanceof ge&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new ge(e.resolve(n.pos))}getBookmark(){return new tc(this.anchor)}static valid(e){let n=e.parent;if(n.inlineContent||!hw(e)||!mw(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let i=n.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&ge.valid(e))return e;let i=e.pos,s=null;for(let o=e.depth;;o--){let l=e.node(o);if(n>0?e.indexAfter(o)<l.childCount:e.index(o)>0){s=l.child(n>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;i+=n;let a=e.doc.resolve(i);if(ge.valid(a))return a}for(;;){let o=n>0?s.firstChild:s.lastChild;if(!o){if(s.isAtom&&!s.isText&&!U.isSelectable(s)){e=e.doc.resolve(i+s.nodeSize*n),r=!1;continue e}break}s=o,i+=n;let l=e.doc.resolve(i);if(ge.valid(l))return l}return null}}}ge.prototype.visible=!1;ge.findFrom=ge.findGapCursorFrom;J.jsonID("gapcursor",ge);class tc{constructor(e){this.pos=e}map(e){return new tc(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return ge.valid(n)?new ge(n):J.near(n)}}function fm(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function hw(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(n-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||fm(i.type))return!0;if(i.inlineContent)return!1}}return!0}function mw(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(n);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||fm(i.type))return!0;if(i.inlineContent)return!1}}return!0}function gw(){return new fe({props:{decorations:xw,createSelectionBetween(t,e,n){return e.pos==n.pos&&ge.valid(n)?new ge(n):null},handleClick:bw,handleKeyDown:yw,handleDOMEvents:{beforeinput:kw}}})}const yw=nh({ArrowLeft:Yi("horiz",-1),ArrowRight:Yi("horiz",1),ArrowUp:Yi("vert",-1),ArrowDown:Yi("vert",1)});function Yi(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,s){let o=r.selection,l=e>0?o.$to:o.$from,a=o.empty;if(o instanceof q){if(!s.endOfTextblock(n)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=ge.findGapCursorFrom(l,e,a);return c?(i&&i(r.tr.setSelection(new ge(c))),!0):!1}}function bw(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!ge.valid(r))return!1;let i=t.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&U.isSelectable(t.state.doc.nodeAt(i.inside))?!1:(t.dispatch(t.state.tr.setSelection(new ge(r))),!0)}function kw(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof ge))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let i=I.empty;for(let o=r.length-1;o>=0;o--)i=I.from(r[o].createAndFill(null,i));let s=t.state.tr.replace(n.pos,n.pos,new _(i,0,0));return s.setSelection(q.near(s.doc.resolve(n.pos+1))),t.dispatch(s),!1}function xw(t){if(!(t.selection instanceof ge))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",ne.create(t.doc,[He.widget(t.selection.head,e,{key:"gapcursor"})])}ae.create({name:"characterCount",addOptions(){return{limit:null,autoTrim:!0,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{const e=(t==null?void 0:t.node)||this.editor.state.doc;if(((t==null?void 0:t.mode)||this.options.mode)==="textSize"){const n=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(n)}return e.nodeSize},this.storage.words=t=>{const e=(t==null?void 0:t.node)||this.editor.state.doc,n=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=!1;return[new fe({key:new xe("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;const i=this.options.limit,s=this.options.autoTrim;if(i==null||i===0||s===!1){t=!0;return}const o=this.storage.characters({node:r.doc});if(o>i){const l=o-i,a=0,c=l;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);const u=r.tr.deleteRange(a,c);return t=!0,u}t=!0},filterTransaction:(e,n)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const i=this.storage.characters({node:n.doc}),s=this.storage.characters({node:e.doc});if(s<=r||i>r&&s>r&&s<=i)return!0;if(i>r&&s>r&&s>i||!e.getMeta("paste"))return!1;const o=e.selection.$head.pos,l=o-(s-r),a=o;return e.deleteRange(l,a),!(this.storage.characters({node:e.doc})>r)}})]}});const Sw=ae.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[fw(this.options)]}});ae.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new fe({key:new xe("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:i}=e,s=[];if(!n||!r)return ne.create(t,[]);let o=0;this.options.mode==="deepest"&&t.descendants((a,c)=>{if(!a.isText){if(!(i>=c&&i<=c+a.nodeSize-1))return!1;o+=1}});let l=0;return t.descendants((a,c)=>{if(a.isText||!(i>=c&&i<=c+a.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&o-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";s.push(He.node(c,c+a.nodeSize,{class:this.options.className}))}),ne.create(t,s)}}})]}});const ww=ae.create({name:"gapCursor",addProseMirrorPlugins(){return[gw()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=re(j(t,"allowGapCursor",n)))!==null&&e!==void 0?e:null}}}),pm="placeholder",vd=new xe("tiptap__placeholder");function hm(t){const{editor:e,placeholder:n,dataAttribute:r,pos:i,node:s,isEmptyDoc:o,hasAnchor:l,classes:{emptyNode:a,emptyEditor:c}}=t,u=[a];return o&&u.push(c),He.node(i,i+s.nodeSize,{class:u.join(" "),[r]:typeof n=="function"?n({editor:e,node:s,pos:i,hasAnchor:l}):n})}function mm(t,e){return typeof t=="function"?t(e):t}function gm({editor:t,options:e,dataAttribute:n,doc:r,selection:i,from:s,to:o}){const{anchor:l}=i,a=[],c=t.isEmpty;return r.nodesBetween(s,o,(u,d)=>{const p=l>=d&&l<=d+u.nodeSize,h=!u.isLeaf&&bi(u);return u.type.isTextblock&&(p||!e.showOnlyCurrent)&&h&&a.push(hm({editor:t,isEmptyDoc:c,dataAttribute:n,hasAnchor:p,placeholder:e.placeholder,classes:{emptyEditor:e.emptyEditorClass,emptyNode:mm(e.emptyNodeClass,{editor:t,node:u,pos:d,hasAnchor:p})},node:u,pos:d})),e.includeChildren}),a}function ym({editor:t,options:e,dataAttribute:n,doc:r,selection:i}){if(!(t.isEditable||!e.showOnlyWhenEditable))return null;const{anchor:s}=i,o=[],l=t.isEmpty;if(e.showOnlyCurrent&&!e.includeChildren){const a=r.resolve(s),c=a.depth>0?a.node(1):a.nodeAfter,u=a.depth>0?a.before(1):s;if(c&&c.type.isTextblock&&bi(c)){const d=s>=u&&s<=u+c.nodeSize;o.push(hm({editor:t,isEmptyDoc:l,dataAttribute:n,hasAnchor:d,placeholder:e.placeholder,classes:{emptyEditor:e.emptyEditorClass,emptyNode:mm(e.emptyNodeClass,{editor:t,node:c,pos:u,hasAnchor:d})},node:c,pos:u}))}}else o.push(...gm({editor:t,options:e,dataAttribute:n,doc:r,selection:i,from:0,to:r.content.size}));return ne.create(r,o)}function Yr(t,e){const n=t.resolve(e);if(n.depth===0){var r;const s=(r=n.nodeAfter)!==null&&r!==void 0?r:n.nodeBefore;if(!s)return{from:e,to:e};const o=n.nodeAfter?e:e-s.nodeSize;return{from:o,to:o+s.nodeSize}}const i=n.before(1);return{from:i,to:i+n.node(1).nodeSize}}function Gr(t,e){return{from:Math.max(0,e.from-1),to:Math.min(t.content.size,e.to-1)}}function Cw(t,e,n){const r=[];return t.forEach((i,s)=>{const o=s,l=o+i.nodeSize,a=o+1,c=l+1;a<n&&c>e&&r.push({from:o,to:l})}),r}function vw(t){if(t.length===0)return[];const e=[...t].sort((r,i)=>r.from-i.from),n=[{...e[0]}];for(let r=1;r<e.length;r+=1){const i=n[n.length-1],s=e[r];s.from<=i.to?i.to=Math.max(i.to,s.to):n.push({...s})}return n}function Mw(t,e){const n=Cw(t,e.from,e.to);return n.push(Gr(t,Yr(t,e.from))),e.to>e.from?n.push(Gr(t,Yr(t,Math.min(e.to,t.content.size+1)-1))):e.from<t.content.size+1&&n.push(Gr(t,Yr(t,Math.min(e.from+1,t.content.size)))),n}function Tw(t,e,n){const r=[];if(t.docChanged){const i=po(t);for(const s of i)r.push(...Mw(n.doc,s.newRange))}return t.selectionSet&&(r.push(Gr(n.doc,Yr(n.doc,t.mapping.map(e.selection.anchor)))),r.push(Gr(n.doc,Yr(n.doc,n.selection.anchor)))),vw(r)}function Aw(t,e,n){const r=Math.max(0,Math.min(t,n.content.size));return{from:r,to:Math.max(r,Math.min(e,n.content.size))}}function Ew({decorations:t,ranges:e,editor:n,options:r,dataAttribute:i,doc:s,selection:o}){let l=t;for(const a of e){const{from:c,to:u}=Aw(a.from,a.to,s),d=l.find(c,u).filter(h=>h.from>=c&&h.to<=u);d.length&&(l=l.remove(d));const p=gm({editor:n,options:r,dataAttribute:i,doc:s,selection:o,from:c,to:u});p.length&&(l=l.add(s,p))}return l}function Nw({editor:t,options:e,dataAttribute:n}){return{init(r,i){const s=ym({editor:t,options:e,dataAttribute:n,doc:i.doc,selection:i.selection});return s??ne.empty},apply(r,i,s,o){return!r.docChanged&&!r.selectionSet?i:Ew({decorations:i.map(r.mapping,r.doc),ranges:Tw(r,s,o),editor:t,options:e,dataAttribute:n,doc:o.doc,selection:o.selection})}}}function Ow(t){return t.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}function Lw({editor:t,options:e}){const n=e.dataAttribute?`data-${Ow(e.dataAttribute)}`:`data-${pm}`,r=e.showOnlyCurrent&&!e.includeChildren;return new fe({key:vd,...r?{}:{state:Nw({editor:t,options:e,dataAttribute:n})},props:{decorations:r?({doc:i,selection:s})=>ym({editor:t,options:e,dataAttribute:n,doc:i,selection:s}):i=>{var s;return e.showOnlyWhenEditable&&!t.isEditable?ne.empty:(s=vd.getState(i))!==null&&s!==void 0?s:ne.empty}}})}const Iw=ae.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:pm,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[Lw({editor:this.editor,options:this.options})]}});function ua(t,e){return!t.selection.empty&&!Mh(t.selection)&&e.isEditable}function Rw(t,e){return ua(t,e)&&!e.isFocused&&!e.view.dragging}function Dw(){var t;(t=window.getSelection())===null||t===void 0||t.removeAllRanges()}function Pw(t){t.focus()}ae.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new fe({key:new xe("selection"),props:{decorations(n){return Rw(n,t)?ne.create(n.doc,[He.inline(n.selection.from,n.selection.to,{class:e.className})]):null},handleDOMEvents:{blur(n){return ua(n.state,t)&&Dw(),!1},focus(n){return ua(n.state,t)&&requestAnimationFrame(()=>{!t.isDestroyed&&n.hasFocus()&&Pw(n)}),!1}}}})]}});function Md({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||(e==null?void 0:e.type)===t}const $w=ae.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new xe(this.name),n=this.options.node||((t=this.editor.schema.topNodeType.contentMatch.defaultType)===null||t===void 0?void 0:t.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,i])=>i).filter(i=>(this.options.notAfter||[]).concat(n).includes(i.name));return[new fe({key:e,appendTransaction:(i,s,o)=>{const{doc:l,tr:a,schema:c}=o,u=e.getState(o),d=l.content.size,p=c.nodes[n];if(!i.some(h=>h.getMeta("skipTrailingNode"))&&u)return a.insert(d,p.create())},state:{init:(i,s)=>{const o=s.tr.doc.lastChild;return!Md({node:o,types:r})},apply:(i,s)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return s;const o=i.doc.lastChild;return!Md({node:o,types:r})}}})]}}),Bw=ae.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>oh(t,e),redo:()=>({state:t,dispatch:e})=>lh(t,e)}},addProseMirrorPlugins(){return[J0(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),_w=ae.create({name:"starterKit",addExtensions(){const t=[];if(this.options.bold!==!1&&t.push(OS.configure(this.options.bold)),this.options.blockquote!==!1&&t.push(MS.configure(this.options.blockquote)),this.options.bulletList!==!1&&t.push(nm.configure(this.options.bulletList)),this.options.code!==!1&&t.push(DS.configure(this.options.code)),this.options.codeBlock!==!1&&t.push(BS.configure(this.options.codeBlock)),this.options.document!==!1&&t.push(_S.configure(this.options.document)),this.options.dropcursor!==!1&&t.push(Sw.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&t.push(ww.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&t.push(zS.configure(this.options.hardBreak)),this.options.heading!==!1&&t.push(FS.configure(this.options.heading)),this.options.undoRedo!==!1&&t.push(Bw.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&t.push(HS.configure(this.options.horizontalRule)),this.options.italic!==!1&&t.push(WS.configure(this.options.italic)),this.options.listItem!==!1&&t.push(lm.configure(this.options.listItem)),this.options.listKeymap!==!1){var e;t.push(cm.configure((e=this.options)===null||e===void 0?void 0:e.listKeymap))}if(this.options.link!==!1){var n;t.push(tm.configure((n=this.options)===null||n===void 0?void 0:n.link))}if(this.options.orderedList!==!1&&t.push(dm.configure(this.options.orderedList)),this.options.paragraph!==!1&&t.push(ow.configure(this.options.paragraph)),this.options.strike!==!1&&t.push(cw.configure(this.options.strike)),this.options.text!==!1&&t.push(uw.configure(this.options.text)),this.options.underline!==!1){var r;t.push(dw.configure((r=this.options)===null||r===void 0?void 0:r.underline))}if(this.options.trailingNode!==!1){var i;t.push($w.configure((i=this.options)===null||i===void 0?void 0:i.trailingNode))}return t}});var zw=_w,Fw=Iw;const Hw=20,bm=(t,e=0)=>{const n=[];return!t.children.length||e>Hw||Array.from(t.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...bm(r,e+1))}),n},jw=t=>{if(!t.children.length)return;const e=bm(t);e&&e.forEach(n=>{var r;const i=n.getAttribute("style"),s=(r=n.parentElement)===null||r===void 0||(r=r.closest("span"))===null||r===void 0?void 0:r.getAttribute("style");n.setAttribute("style",`${s};${i}`)})},km=gn.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&jw(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",be(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleTextStyle:t=>({commands:e})=>e.toggleMark(this.name,t),removeEmptyTextStyle:()=>({tr:t})=>{const{selection:e}=t;return t.doc.nodesBetween(e.from,e.to,(n,r)=>{if(!n.isInline)return!0;n.marks.filter(i=>i.type===this.type).some(i=>Object.values(i.attrs).some(s=>!!s))||t.removeMark(r,r+n.nodeSize,this.type)}),!0}}}}),Vw=ae.create({name:"backgroundColor",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:t=>{var e;const n=(e=ki(t,"background-color"))!==null&&e!==void 0?e:t.style.backgroundColor;return n==null?void 0:n.replace(/['"]+/g,"")},renderHTML:t=>xi(t.backgroundColor)?{style:`background-color: ${t.backgroundColor}`}:{}}}}]},addCommands(){return{setBackgroundColor:t=>({chain:e})=>e().setMark("textStyle",{backgroundColor:t}).run(),unsetBackgroundColor:()=>({chain:t})=>t().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()}}}),xm=ae.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var e;const n=(e=ki(t,"color"))!==null&&e!==void 0?e:t.style.color;return n==null?void 0:n.replace(/['"]+/g,"")},renderHTML:t=>xi(t.color)?{style:`color: ${t.color}`}:{}}}}]},addCommands(){return{setColor:t=>({chain:e})=>e().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),Uw=ae.create({name:"fontFamily",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:t=>{var e;return(e=ki(t,"font-family"))!==null&&e!==void 0?e:t.style.fontFamily},renderHTML:t=>xi(t.fontFamily)?{style:`font-family: ${t.fontFamily}`}:{}}}}]},addCommands(){return{setFontFamily:t=>({chain:e})=>e().setMark("textStyle",{fontFamily:t}).run(),unsetFontFamily:()=>({chain:t})=>t().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()}}}),qw=ae.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:t=>{var e;return(e=ki(t,"font-size"))!==null&&e!==void 0?e:t.style.fontSize},renderHTML:t=>xi(t.fontSize)?{style:`font-size: ${t.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:t=>({chain:e})=>e().setMark("textStyle",{fontSize:t}).run(),unsetFontSize:()=>({chain:t})=>t().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),Ww=ae.create({name:"lineHeight",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:t=>{var e;return(e=ki(t,"line-height"))!==null&&e!==void 0?e:t.style.lineHeight},renderHTML:t=>xi(t.lineHeight)?{style:`line-height: ${t.lineHeight}`}:{}}}}]},addCommands(){return{setLineHeight:t=>({chain:e})=>e().setMark("textStyle",{lineHeight:t}).run(),unsetLineHeight:()=>({chain:t})=>t().setMark("textStyle",{lineHeight:null}).removeEmptyTextStyle().run()}}});ae.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(Vw.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(xm.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(Uw.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(qw.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(Ww.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(km.configure(this.options.textStyle)),t}});const ur=[{name:"figure",include:"figure.html",label:"Figure",fields:["src","alt","caption","source","width"]},{name:"cutIn",include:"cut-in.html",label:"Cut-in",fields:["src","alt","side"]},{name:"youtube",include:"youtube.html",label:"YouTube",fields:["id","caption","width"]},{name:"youtubeShort",include:"youtube-short.html",label:"YouTube Short",fields:["src","src2"]},{name:"video",include:"video.html",label:"Video",fields:["src","caption","width"]},{name:"plotly",include:"plotly.html",label:"Plotly",fields:["src","caption","width","height","source","alt"]},{name:"xcite",include:"xcite.html",label:"Xcite",fields:["key"],inline:!0},{name:"cite",include:"cite.html",label:"Cite",fields:["key"],inline:!0},{name:"articleNote",include:"article-note",label:"Article note",fields:["body"],blockBody:!0},{name:"poem",include:"poem",label:"Poem",fields:["body"],blockBody:!0}];function Kw(t,e){if(t.blockBody){const r=e.body||"";return`{% include ${t.include} markdown="1" %}
184
+ ${r}
185
+ {% endinclude %}`}const n=t.fields.filter(r=>e[r]!=null&&String(e[r]).length).map(r=>`${r}="${String(e[r]).replace(/"/g,"&quot;")}"`);return n.length?`{% include ${t.include} ${n.join(" ")} %}`:`{% include ${t.include} %}`}function Sm(t){const e={};return String(t||"").replace(/([\w-]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/g,(n,r,i,s)=>(e[r]=i??s,"")),e}const wm=/\{%-?\s*include\s+([\w.-]+)\s*((?:(?!%\})[\s\S])*?)\s*-?%\}/g;function Ys(t){return ur.find(e=>e.include===t)}function Yw(t){const e=String(t||"").trim();if(!e.startsWith("{%"))return null;const n=e.match(/^\{%-?\s*include\s+([\w.-]+)\b[^%]*?-?%\}\s*([\s\S]*?)\s*\{%-?\s*endinclude\s*-?%\}$/);if(n){const s=Ys(n[1]);return s!=null&&s.blockBody?{type:s.name,attrs:{body:n[2].replace(/^\n|\n$/g,""),raw:e}}:null}const r=e.match(/^\{%-?\s*include\s+([\w.-]+)\s*((?:(?!%\})[\s\S])*?)\s*-?%\}$/);if(!r)return null;const i=Ys(r[1]);return!i||i.inline||i.blockBody?null:nc(i,r[2],r[0])}function nc(t,e,n){return{type:t.name,attrs:{...Sm(e),raw:n}}}function Gw(t,e){const n=e==null?void 0:e.raw;if(typeof n!="string"||!n)return!1;if(t.blockBody){const i=e.body==null?"":String(e.body);return n.includes(i)}const r=Sm(n);for(const i of t.fields){const s=e[i]==null?"":String(e[i]),o=r[i]==null?"":String(r[i]);if(s!==o)return!1}return!0}function Cm(t,e){return Gw(t,e)?e.raw:Kw(t,e)}function Td(t){const e=String(t||""),n=[],r=new RegExp(wm.source,"g");let i=0,s;for(;s=r.exec(e);){s.index>i&&n.push({type:"text",text:e.slice(i,s.index)});const o=Ys(s[1]);o!=null&&o.inline?n.push(nc(o,s[2],s[0])):n.push({type:"text",text:s[0]}),i=s.index+s[0].length}return i<e.length&&n.push({type:"text",text:e.slice(i)}),n.filter(o=>o.type!=="text"||o.text!=="")}function vm(t){return String(t||"").replace(/^\n+|\n+$/g,"")}function Ad(t,e){const n=vm(e);if(!n)return;const r=n.match(/^(#{1,6})\s+([\s\S]*)$/);if(r&&!n.includes(`
186
+ `)&&n.trim()===n){t.push({type:"heading",attrs:{level:r[1].length},content:Td(r[2])});return}t.push({type:"paragraph",content:Td(n)})}function Jw(t,e){const n=vm(e);if(!n)return;const r=Yw(n);if(r){t.push(r);return}const i=new RegExp(wm.source,"g"),s=[];let o=0,l,a=!1;for(;l=i.exec(n);){const c=Ys(l[1]);c&&!c.inline&&!c.blockBody&&(a=!0,s.push({kind:"text",text:n.slice(o,l.index)}),s.push({kind:"block",node:nc(c,l[2],l[0])}),o=l.index+l[0].length)}if(!a){Ad(t,n);return}s.push({kind:"text",text:n.slice(o)});for(const c of s)c.kind==="block"?t.push(c.node):c.text.trim()&&Ad(t,c.text)}function Xw(t,e){const n=/```([^\n`]*)\n([\s\S]*?)```/g;let r=0,i;const s=String(e||"");for(;i=n.exec(s);){i.index>r&&Ed(t,s.slice(r,i.index));const o=String(i[1]||"").trim(),l=String(i[2]||"").replace(/\n$/,"");t.push({type:"codeBlock",attrs:{language:o||null},content:l?[{type:"text",text:l}]:[]}),r=i.index+i[0].length}r<s.length&&Ed(t,s.slice(r))}function Ed(t,e){const n=String(e||"").split(/\n{2,}/);for(const r of n)Jw(t,r)}function da(t){const e=[];return Xw(e,t),e.length||e.push({type:"paragraph"}),{type:"doc",content:e}}function Nd(t){return(t||[]).map(e=>{var r,i;if(e.type==="text"){let s=e.text||"";const o=e.marks||[];for(const l of o)l.type==="bold"&&(s=`**${s}**`),l.type==="italic"&&(s=`*${s}*`),l.type==="strike"&&(s=`~~${s}~~`),l.type==="code"&&(s=`\`${s}\``),l.type==="link"&&(s=`[${s}](${((r=l.attrs)==null?void 0:r.href)||""})`),l.type==="textStyle"&&((i=l.attrs)!=null&&i.color)&&(s=`<span style="color:${l.attrs.color}">${s}</span>`);return s}if(e.type==="hardBreak")return`
187
+ `;const n=ur.find(s=>s.name===e.type);return n?Cm(n,e.attrs||{}):""}).join("")}function $r(t){return(t||[]).map(e=>{var r,i;const n=ur.find(s=>s.name===e.type);if(n){const s=Cm(n,e.attrs||{});return s.endsWith(`
188
+ `)?`${s}
189
+ `:`${s}
190
+
191
+ `}switch(e.type){case"paragraph":return`${Nd(e.content||[])}
192
+
193
+ `;case"heading":{const s=((r=e.attrs)==null?void 0:r.level)||1;return`${"#".repeat(s)} ${Nd(e.content||[])}
194
+
195
+ `}case"blockquote":return $r(e.content||[]).split(`
196
+ `).map(s=>s?`> ${s}`:">").join(`
197
+ `)+`
198
+
199
+ `;case"bulletList":return(e.content||[]).map(s=>`- ${$r(s.content||[]).trim()}`).join(`
200
+ `)+`
201
+
202
+ `;case"orderedList":return(e.content||[]).map((s,o)=>`${o+1}. ${$r(s.content||[]).trim()}`).join(`
203
+ `)+`
204
+
205
+ `;case"codeBlock":return"```"+(((i=e.attrs)==null?void 0:i.language)||"")+`
206
+ `+(e.content||[]).map(o=>o.text||"").join("")+"\n```\n\n";case"horizontalRule":return`---
207
+
208
+ `;default:return e.content?$r(e.content):""}}).join("")}function Mm(t){return $r(t).trim()+`
209
+ `}function Zw(t){const e=da(t);return Mm(e.content||[])}function Qw(t){return Ye.create({name:t.name,group:t.inline?"inline":"block",inline:!!t.inline,atom:!0,selectable:!0,draggable:!0,addAttributes(){const e={};for(const n of t.fields)e[n]={default:""};return e.raw={default:""},e},parseHTML(){return[{tag:`div[data-liquid="${t.name}"]`}]},renderHTML({HTMLAttributes:e}){const n=t.fields.map(i=>e[i]).filter(Boolean).slice(0,2).join(" | "),r=t.inline?"span":"div";return[r,be(e,{"data-liquid":t.name,class:t.inline?"liquid-block liquid-block--inline":"liquid-block","data-include":t.include}),["strong",{},t.label],[r==="span"?"span":"div",{},n||"(empty)"]]},addCommands(){return{[`insert${t.name.charAt(0).toUpperCase()}${t.name.slice(1)}`]:(e={})=>({commands:n})=>n.insertContent({type:t.name,attrs:e})}}})}function Od(t){const e=t.getJSON();return Mm(e.content||[])}function eC(t,{content:e="",onUpdate:n}={}){const r=ur.map(Qw),i=new xS({element:t,extensions:[zw.configure({heading:{levels:[1,2,3,4]}}),km,xm,T1.configure({autolink:!1,linkOnPaste:!1,openOnClick:!1}),Fw.configure({placeholder:"Write… Use Insert for Liquid blocks."}),...r],content:da(e),onUpdate:({editor:s})=>{n&&n(Od(s))}});return{editor:i,getMarkdown:()=>Od(i),setMarkdown:s=>{i.commands.setContent(da(s))},destroy:()=>i.destroy(),insertInclude:(s,o={})=>{const l=ur.find(a=>a.name===s);l&&i.commands.insertContent({type:l.name,attrs:o})},transformSelectionCase:s=>{const{from:o,to:l,empty:a}=i.state.selection;if(a)return;const c=i.state.doc.textBetween(o,l,"");let u=c;if(s==="lower")u=c.toLocaleLowerCase();else if(s==="upper")u=c.toLocaleUpperCase();else if(s==="title")u=c.replace(/\S+/g,d=>{const p=[...d][0]||"",h=[...d].slice(1).join("");return p.toLocaleUpperCase()+h.toLocaleLowerCase()});else return;i.chain().focus().insertContentAt({from:o,to:l},u).run()}}}function rc(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var _n=rc();function Tm(t){_n=t}var Jr={exec:()=>null};function se(t,e=""){let n=typeof t=="string"?t:t.source;const r={replace:(i,s)=>{let o=typeof s=="string"?s:s.source;return o=o.replace(je.caret,"$1"),n=n.replace(i,o),r},getRegex:()=>new RegExp(n,e)};return r}var je={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}#`),htmlBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}<(?:[a-z].*>|!--)`,"i")},tC=/^(?:[ \t]*(?:\n|$))+/,nC=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,rC=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,wi=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,iC=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,ic=/(?:[*+-]|\d{1,9}[.)])/,Am=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Em=se(Am).replace(/bull/g,ic).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),sC=se(Am).replace(/bull/g,ic).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),sc=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,oC=/^[^\n]+/,oc=/(?!\s*\])(?:\\.|[^\[\]\\])+/,lC=se(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",oc).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),aC=se(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,ic).getRegex(),xo="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",lc=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,cC=se("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",lc).replace("tag",xo).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Nm=se(sc).replace("hr",wi).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",xo).getRegex(),uC=se(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Nm).getRegex(),ac={blockquote:uC,code:nC,def:lC,fences:rC,heading:iC,hr:wi,html:cC,lheading:Em,list:aC,newline:tC,paragraph:Nm,table:Jr,text:oC},Ld=se("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",wi).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",xo).getRegex(),dC={...ac,lheading:sC,table:Ld,paragraph:se(sc).replace("hr",wi).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Ld).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",xo).getRegex()},fC={...ac,html:se(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",lc).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Jr,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:se(sc).replace("hr",wi).replace("heading",` *#{1,6} *[^
210
+ ]`).replace("lheading",Em).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},pC=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,hC=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Om=/^( {2,}|\\)\n(?!\s*$)/,mC=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,So=/[\p{P}\p{S}]/u,cc=/[\s\p{P}\p{S}]/u,Lm=/[^\s\p{P}\p{S}]/u,gC=se(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,cc).getRegex(),Im=/(?!~)[\p{P}\p{S}]/u,yC=/(?!~)[\s\p{P}\p{S}]/u,bC=/(?:[^\s\p{P}\p{S}]|~)/u,kC=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,Rm=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,xC=se(Rm,"u").replace(/punct/g,So).getRegex(),SC=se(Rm,"u").replace(/punct/g,Im).getRegex(),Dm="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",wC=se(Dm,"gu").replace(/notPunctSpace/g,Lm).replace(/punctSpace/g,cc).replace(/punct/g,So).getRegex(),CC=se(Dm,"gu").replace(/notPunctSpace/g,bC).replace(/punctSpace/g,yC).replace(/punct/g,Im).getRegex(),vC=se("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Lm).replace(/punctSpace/g,cc).replace(/punct/g,So).getRegex(),MC=se(/\\(punct)/,"gu").replace(/punct/g,So).getRegex(),TC=se(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),AC=se(lc).replace("(?:-->|$)","-->").getRegex(),EC=se("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",AC).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Gs=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,NC=se(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",Gs).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Pm=se(/^!?\[(label)\]\[(ref)\]/).replace("label",Gs).replace("ref",oc).getRegex(),$m=se(/^!?\[(ref)\](?:\[\])?/).replace("ref",oc).getRegex(),OC=se("reflink|nolink(?!\\()","g").replace("reflink",Pm).replace("nolink",$m).getRegex(),uc={_backpedal:Jr,anyPunctuation:MC,autolink:TC,blockSkip:kC,br:Om,code:hC,del:Jr,emStrongLDelim:xC,emStrongRDelimAst:wC,emStrongRDelimUnd:vC,escape:pC,link:NC,nolink:$m,punctuation:gC,reflink:Pm,reflinkSearch:OC,tag:EC,text:mC,url:Jr},LC={...uc,link:se(/^!?\[(label)\]\((.*?)\)/).replace("label",Gs).getRegex(),reflink:se(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Gs).getRegex()},fa={...uc,emStrongRDelimAst:CC,emStrongLDelim:SC,url:se(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},IC={...fa,br:se(Om).replace("{2,}","*").getRegex(),text:se(fa.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Gi={normal:ac,gfm:dC,pedantic:fC},Ar={normal:uc,gfm:fa,breaks:IC,pedantic:LC},RC={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Id=t=>RC[t];function pt(t,e){if(e){if(je.escapeTest.test(t))return t.replace(je.escapeReplace,Id)}else if(je.escapeTestNoEncode.test(t))return t.replace(je.escapeReplaceNoEncode,Id);return t}function Rd(t){try{t=encodeURI(t).replace(je.percentDecode,"%")}catch{return null}return t}function Dd(t,e){var s;const n=t.replace(je.findPipe,(o,l,a)=>{let c=!1,u=l;for(;--u>=0&&a[u]==="\\";)c=!c;return c?"|":" |"}),r=n.split(je.splitPipe);let i=0;if(r[0].trim()||r.shift(),r.length>0&&!((s=r.at(-1))!=null&&s.trim())&&r.pop(),e)if(r.length>e)r.splice(e);else for(;r.length<e;)r.push("");for(;i<r.length;i++)r[i]=r[i].trim().replace(je.slashPipe,"|");return r}function Er(t,e,n){const r=t.length;if(r===0)return"";let i=0;for(;i<r&&t.charAt(r-i-1)===e;)i++;return t.slice(0,r-i)}function DC(t,e){if(t.indexOf(e[1])===-1)return-1;let n=0;for(let r=0;r<t.length;r++)if(t[r]==="\\")r++;else if(t[r]===e[0])n++;else if(t[r]===e[1]&&(n--,n<0))return r;return n>0?-2:-1}function Pd(t,e,n,r,i){const s=e.href,o=e.title||null,l=t[1].replace(i.other.outputLinkReplace,"$1");r.state.inLink=!0;const a={type:t[0].charAt(0)==="!"?"image":"link",raw:n,href:s,title:o,text:l,tokens:r.inlineTokens(l)};return r.state.inLink=!1,a}function PC(t,e,n){const r=t.match(n.other.indentCodeCompensation);if(r===null)return e;const i=r[1];return e.split(`
211
+ `).map(s=>{const o=s.match(n.other.beginningSpace);if(o===null)return s;const[l]=o;return l.length>=i.length?s.slice(i.length):s}).join(`
212
+ `)}var Js=class{constructor(t){ce(this,"options");ce(this,"rules");ce(this,"lexer");this.options=t||_n}space(t){const e=this.rules.block.newline.exec(t);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(t){const e=this.rules.block.code.exec(t);if(e){const n=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?n:Er(n,`
213
+ `)}}}fences(t){const e=this.rules.block.fences.exec(t);if(e){const n=e[0],r=PC(n,e[3]||"",this.rules);return{type:"code",raw:n,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:r}}}heading(t){const e=this.rules.block.heading.exec(t);if(e){let n=e[2].trim();if(this.rules.other.endingHash.test(n)){const r=Er(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:e[0],depth:e[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(t){const e=this.rules.block.hr.exec(t);if(e)return{type:"hr",raw:Er(e[0],`
214
+ `)}}blockquote(t){const e=this.rules.block.blockquote.exec(t);if(e){let n=Er(e[0],`
215
+ `).split(`
216
+ `),r="",i="";const s=[];for(;n.length>0;){let o=!1;const l=[];let a;for(a=0;a<n.length;a++)if(this.rules.other.blockquoteStart.test(n[a]))l.push(n[a]),o=!0;else if(!o)l.push(n[a]);else break;n=n.slice(a);const c=l.join(`
217
+ `),u=c.replace(this.rules.other.blockquoteSetextReplace,`
218
+ $1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
219
+ ${c}`:c,i=i?`${i}
220
+ ${u}`:u;const d=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(u,s,!0),this.lexer.state.top=d,n.length===0)break;const p=s.at(-1);if((p==null?void 0:p.type)==="code")break;if((p==null?void 0:p.type)==="blockquote"){const h=p,g=h.raw+`
221
+ `+n.join(`
222
+ `),b=this.blockquote(g);s[s.length-1]=b,r=r.substring(0,r.length-h.raw.length)+b.raw,i=i.substring(0,i.length-h.text.length)+b.text;break}else if((p==null?void 0:p.type)==="list"){const h=p,g=h.raw+`
223
+ `+n.join(`
224
+ `),b=this.list(g);s[s.length-1]=b,r=r.substring(0,r.length-p.raw.length)+b.raw,i=i.substring(0,i.length-h.raw.length)+b.raw,n=g.substring(s.at(-1).raw.length).split(`
225
+ `);continue}}return{type:"blockquote",raw:r,tokens:s,text:i}}}list(t){let e=this.rules.block.list.exec(t);if(e){let n=e[1].trim();const r=n.length>1,i={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");const s=this.rules.other.listItemRegex(n);let o=!1;for(;t;){let a=!1,c="",u="";if(!(e=s.exec(t))||this.rules.block.hr.test(t))break;c=e[0],t=t.substring(c.length);let d=e[2].split(`
226
+ `,1)[0].replace(this.rules.other.listReplaceTabs,w=>" ".repeat(3*w.length)),p=t.split(`
227
+ `,1)[0],h=!d.trim(),g=0;if(this.options.pedantic?(g=2,u=d.trimStart()):h?g=e[1].length+1:(g=e[2].search(this.rules.other.nonSpaceChar),g=g>4?1:g,u=d.slice(g),g+=e[1].length),h&&this.rules.other.blankLine.test(p)&&(c+=p+`
228
+ `,t=t.substring(p.length+1),a=!0),!a){const w=this.rules.other.nextBulletRegex(g),A=this.rules.other.hrRegex(g),R=this.rules.other.fencesBeginRegex(g),O=this.rules.other.headingBeginRegex(g),Y=this.rules.other.htmlBeginRegex(g);for(;t;){const ee=t.split(`
229
+ `,1)[0];let H;if(p=ee,this.options.pedantic?(p=p.replace(this.rules.other.listReplaceNesting," "),H=p):H=p.replace(this.rules.other.tabCharGlobal," "),R.test(p)||O.test(p)||Y.test(p)||w.test(p)||A.test(p))break;if(H.search(this.rules.other.nonSpaceChar)>=g||!p.trim())u+=`
230
+ `+H.slice(g);else{if(h||d.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||R.test(d)||O.test(d)||A.test(d))break;u+=`
231
+ `+p}!h&&!p.trim()&&(h=!0),c+=ee+`
232
+ `,t=t.substring(ee.length+1),d=H.slice(g)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(c)&&(o=!0));let b=null,x;this.options.gfm&&(b=this.rules.other.listIsTask.exec(u),b&&(x=b[0]!=="[ ] ",u=u.replace(this.rules.other.listReplaceTask,""))),i.items.push({type:"list_item",raw:c,task:!!b,checked:x,loose:!1,text:u,tokens:[]}),i.raw+=c}const l=i.items.at(-1);if(l)l.raw=l.raw.trimEnd(),l.text=l.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let a=0;a<i.items.length;a++)if(this.lexer.state.top=!1,i.items[a].tokens=this.lexer.blockTokens(i.items[a].text,[]),!i.loose){const c=i.items[a].tokens.filter(d=>d.type==="space"),u=c.length>0&&c.some(d=>this.rules.other.anyLine.test(d.raw));i.loose=u}if(i.loose)for(let a=0;a<i.items.length;a++)i.items[a].loose=!0;return i}}html(t){const e=this.rules.block.html.exec(t);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(t){const e=this.rules.block.def.exec(t);if(e){const n=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:n,raw:e[0],href:r,title:i}}}table(t){var o;const e=this.rules.block.table.exec(t);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;const n=Dd(e[1]),r=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=(o=e[3])!=null&&o.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
233
+ `):[],s={type:"table",raw:e[0],header:[],align:[],rows:[]};if(n.length===r.length){for(const l of r)this.rules.other.tableAlignRight.test(l)?s.align.push("right"):this.rules.other.tableAlignCenter.test(l)?s.align.push("center"):this.rules.other.tableAlignLeft.test(l)?s.align.push("left"):s.align.push(null);for(let l=0;l<n.length;l++)s.header.push({text:n[l],tokens:this.lexer.inline(n[l]),header:!0,align:s.align[l]});for(const l of i)s.rows.push(Dd(l,s.header.length).map((a,c)=>({text:a,tokens:this.lexer.inline(a),header:!1,align:s.align[c]})));return s}}lheading(t){const e=this.rules.block.lheading.exec(t);if(e)return{type:"heading",raw:e[0],depth:e[2].charAt(0)==="="?1:2,text:e[1],tokens:this.lexer.inline(e[1])}}paragraph(t){const e=this.rules.block.paragraph.exec(t);if(e){const n=e[1].charAt(e[1].length-1)===`
234
+ `?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:n,tokens:this.lexer.inline(n)}}}text(t){const e=this.rules.block.text.exec(t);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(t){const e=this.rules.inline.escape.exec(t);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(t){const e=this.rules.inline.tag.exec(t);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(t){const e=this.rules.inline.link.exec(t);if(e){const n=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;const s=Er(n.slice(0,-1),"\\");if((n.length-s.length)%2===0)return}else{const s=DC(e[2],"()");if(s===-2)return;if(s>-1){const l=(e[0].indexOf("!")===0?5:4)+e[1].length+s;e[2]=e[2].substring(0,s),e[0]=e[0].substring(0,l).trim(),e[3]=""}}let r=e[2],i="";if(this.options.pedantic){const s=this.rules.other.pedanticHrefTitle.exec(r);s&&(r=s[1],i=s[3])}else i=e[3]?e[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?r=r.slice(1):r=r.slice(1,-1)),Pd(e,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(t,e){let n;if((n=this.rules.inline.reflink.exec(t))||(n=this.rules.inline.nolink.exec(t))){const r=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=e[r.toLowerCase()];if(!i){const s=n[0].charAt(0);return{type:"text",raw:s,text:s}}return Pd(n,i,n[0],this.lexer,this.rules)}}emStrong(t,e,n=""){let r=this.rules.inline.emStrongLDelim.exec(t);if(!r||r[3]&&n.match(this.rules.other.unicodeAlphaNumeric))return;if(!(r[1]||r[2]||"")||!n||this.rules.inline.punctuation.exec(n)){const s=[...r[0]].length-1;let o,l,a=s,c=0;const u=r[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(u.lastIndex=0,e=e.slice(-1*t.length+s);(r=u.exec(e))!=null;){if(o=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!o)continue;if(l=[...o].length,r[3]||r[4]){a+=l;continue}else if((r[5]||r[6])&&s%3&&!((s+l)%3)){c+=l;continue}if(a-=l,a>0)continue;l=Math.min(l,l+a+c);const d=[...r[0]][0].length,p=t.slice(0,s+r.index+d+l);if(Math.min(s,l)%2){const g=p.slice(1,-1);return{type:"em",raw:p,text:g,tokens:this.lexer.inlineTokens(g)}}const h=p.slice(2,-2);return{type:"strong",raw:p,text:h,tokens:this.lexer.inlineTokens(h)}}}}codespan(t){const e=this.rules.inline.code.exec(t);if(e){let n=e[2].replace(this.rules.other.newLineCharGlobal," ");const r=this.rules.other.nonSpaceChar.test(n),i=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return r&&i&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:e[0],text:n}}}br(t){const e=this.rules.inline.br.exec(t);if(e)return{type:"br",raw:e[0]}}del(t){const e=this.rules.inline.del.exec(t);if(e)return{type:"del",raw:e[0],text:e[2],tokens:this.lexer.inlineTokens(e[2])}}autolink(t){const e=this.rules.inline.autolink.exec(t);if(e){let n,r;return e[2]==="@"?(n=e[1],r="mailto:"+n):(n=e[1],r=n),{type:"link",raw:e[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}url(t){var n;let e;if(e=this.rules.inline.url.exec(t)){let r,i;if(e[2]==="@")r=e[0],i="mailto:"+r;else{let s;do s=e[0],e[0]=((n=this.rules.inline._backpedal.exec(e[0]))==null?void 0:n[0])??"";while(s!==e[0]);r=e[0],e[1]==="www."?i="http://"+e[0]:i=e[0]}return{type:"link",raw:e[0],text:r,href:i,tokens:[{type:"text",raw:r,text:r}]}}}inlineText(t){const e=this.rules.inline.text.exec(t);if(e){const n=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:n}}}},Rt=class pa{constructor(e){ce(this,"tokens");ce(this,"options");ce(this,"state");ce(this,"tokenizer");ce(this,"inlineQueue");this.tokens=[],this.tokens.links=Object.create(null),this.options=e||_n,this.options.tokenizer=this.options.tokenizer||new Js,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const n={other:je,block:Gi.normal,inline:Ar.normal};this.options.pedantic?(n.block=Gi.pedantic,n.inline=Ar.pedantic):this.options.gfm&&(n.block=Gi.gfm,this.options.breaks?n.inline=Ar.breaks:n.inline=Ar.gfm),this.tokenizer.rules=n}static get rules(){return{block:Gi,inline:Ar}}static lex(e,n){return new pa(n).lex(e)}static lexInline(e,n){return new pa(n).inlineTokens(e)}lex(e){e=e.replace(je.carriageReturn,`
235
+ `),this.blockTokens(e,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){const r=this.inlineQueue[n];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,n=[],r=!1){var i,s,o;for(this.options.pedantic&&(e=e.replace(je.tabCharGlobal," ").replace(je.spaceLine,""));e;){let l;if((s=(i=this.options.extensions)==null?void 0:i.block)!=null&&s.some(c=>(l=c.call({lexer:this},e,n))?(e=e.substring(l.raw.length),n.push(l),!0):!1))continue;if(l=this.tokenizer.space(e)){e=e.substring(l.raw.length);const c=n.at(-1);l.raw.length===1&&c!==void 0?c.raw+=`
236
+ `:n.push(l);continue}if(l=this.tokenizer.code(e)){e=e.substring(l.raw.length);const c=n.at(-1);(c==null?void 0:c.type)==="paragraph"||(c==null?void 0:c.type)==="text"?(c.raw+=`
237
+ `+l.raw,c.text+=`
238
+ `+l.text,this.inlineQueue.at(-1).src=c.text):n.push(l);continue}if(l=this.tokenizer.fences(e)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.heading(e)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.hr(e)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.blockquote(e)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.list(e)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.html(e)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.def(e)){e=e.substring(l.raw.length);const c=n.at(-1);(c==null?void 0:c.type)==="paragraph"||(c==null?void 0:c.type)==="text"?(c.raw+=`
239
+ `+l.raw,c.text+=`
240
+ `+l.raw,this.inlineQueue.at(-1).src=c.text):this.tokens.links[l.tag]||(this.tokens.links[l.tag]={href:l.href,title:l.title});continue}if(l=this.tokenizer.table(e)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.lheading(e)){e=e.substring(l.raw.length),n.push(l);continue}let a=e;if((o=this.options.extensions)!=null&&o.startBlock){let c=1/0;const u=e.slice(1);let d;this.options.extensions.startBlock.forEach(p=>{d=p.call({lexer:this},u),typeof d=="number"&&d>=0&&(c=Math.min(c,d))}),c<1/0&&c>=0&&(a=e.substring(0,c+1))}if(this.state.top&&(l=this.tokenizer.paragraph(a))){const c=n.at(-1);r&&(c==null?void 0:c.type)==="paragraph"?(c.raw+=`
241
+ `+l.raw,c.text+=`
242
+ `+l.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=c.text):n.push(l),r=a.length!==e.length,e=e.substring(l.raw.length);continue}if(l=this.tokenizer.text(e)){e=e.substring(l.raw.length);const c=n.at(-1);(c==null?void 0:c.type)==="text"?(c.raw+=`
243
+ `+l.raw,c.text+=`
244
+ `+l.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=c.text):n.push(l);continue}if(e){const c="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(c);break}else throw new Error(c)}}return this.state.top=!0,n}inline(e,n=[]){return this.inlineQueue.push({src:e,tokens:n}),n}inlineTokens(e,n=[]){var l,a,c;let r=e,i=null;if(this.tokens.links){const u=Object.keys(this.tokens.links);if(u.length>0)for(;(i=this.tokenizer.rules.inline.reflinkSearch.exec(r))!=null;)u.includes(i[0].slice(i[0].lastIndexOf("[")+1,-1))&&(r=r.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(i=this.tokenizer.rules.inline.anyPunctuation.exec(r))!=null;)r=r.slice(0,i.index)+"++"+r.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;(i=this.tokenizer.rules.inline.blockSkip.exec(r))!=null;)r=r.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);let s=!1,o="";for(;e;){s||(o=""),s=!1;let u;if((a=(l=this.options.extensions)==null?void 0:l.inline)!=null&&a.some(p=>(u=p.call({lexer:this},e,n))?(e=e.substring(u.raw.length),n.push(u),!0):!1))continue;if(u=this.tokenizer.escape(e)){e=e.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.tag(e)){e=e.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.link(e)){e=e.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(u.raw.length);const p=n.at(-1);u.type==="text"&&(p==null?void 0:p.type)==="text"?(p.raw+=u.raw,p.text+=u.text):n.push(u);continue}if(u=this.tokenizer.emStrong(e,r,o)){e=e.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.codespan(e)){e=e.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.br(e)){e=e.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.del(e)){e=e.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.autolink(e)){e=e.substring(u.raw.length),n.push(u);continue}if(!this.state.inLink&&(u=this.tokenizer.url(e))){e=e.substring(u.raw.length),n.push(u);continue}let d=e;if((c=this.options.extensions)!=null&&c.startInline){let p=1/0;const h=e.slice(1);let g;this.options.extensions.startInline.forEach(b=>{g=b.call({lexer:this},h),typeof g=="number"&&g>=0&&(p=Math.min(p,g))}),p<1/0&&p>=0&&(d=e.substring(0,p+1))}if(u=this.tokenizer.inlineText(d)){e=e.substring(u.raw.length),u.raw.slice(-1)!=="_"&&(o=u.raw.slice(-1)),s=!0;const p=n.at(-1);(p==null?void 0:p.type)==="text"?(p.raw+=u.raw,p.text+=u.text):n.push(u);continue}if(e){const p="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(p);break}else throw new Error(p)}}return n}},Xs=class{constructor(t){ce(this,"options");ce(this,"parser");this.options=t||_n}space(t){return""}code({text:t,lang:e,escaped:n}){var s;const r=(s=(e||"").match(je.notSpaceStart))==null?void 0:s[0],i=t.replace(je.endingNewline,"")+`
245
+ `;return r?'<pre><code class="language-'+pt(r)+'">'+(n?i:pt(i,!0))+`</code></pre>
246
+ `:"<pre><code>"+(n?i:pt(i,!0))+`</code></pre>
247
+ `}blockquote({tokens:t}){return`<blockquote>
248
+ ${this.parser.parse(t)}</blockquote>
249
+ `}html({text:t}){return t}heading({tokens:t,depth:e}){return`<h${e}>${this.parser.parseInline(t)}</h${e}>
250
+ `}hr(t){return`<hr>
251
+ `}list(t){const e=t.ordered,n=t.start;let r="";for(let o=0;o<t.items.length;o++){const l=t.items[o];r+=this.listitem(l)}const i=e?"ol":"ul",s=e&&n!==1?' start="'+n+'"':"";return"<"+i+s+`>
252
+ `+r+"</"+i+`>
253
+ `}listitem(t){var n;let e="";if(t.task){const r=this.checkbox({checked:!!t.checked});t.loose?((n=t.tokens[0])==null?void 0:n.type)==="paragraph"?(t.tokens[0].text=r+" "+t.tokens[0].text,t.tokens[0].tokens&&t.tokens[0].tokens.length>0&&t.tokens[0].tokens[0].type==="text"&&(t.tokens[0].tokens[0].text=r+" "+pt(t.tokens[0].tokens[0].text),t.tokens[0].tokens[0].escaped=!0)):t.tokens.unshift({type:"text",raw:r+" ",text:r+" ",escaped:!0}):e+=r+" "}return e+=this.parser.parse(t.tokens,!!t.loose),`<li>${e}</li>
254
+ `}checkbox({checked:t}){return"<input "+(t?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph({tokens:t}){return`<p>${this.parser.parseInline(t)}</p>
255
+ `}table(t){let e="",n="";for(let i=0;i<t.header.length;i++)n+=this.tablecell(t.header[i]);e+=this.tablerow({text:n});let r="";for(let i=0;i<t.rows.length;i++){const s=t.rows[i];n="";for(let o=0;o<s.length;o++)n+=this.tablecell(s[o]);r+=this.tablerow({text:n})}return r&&(r=`<tbody>${r}</tbody>`),`<table>
256
+ <thead>
257
+ `+e+`</thead>
258
+ `+r+`</table>
259
+ `}tablerow({text:t}){return`<tr>
260
+ ${t}</tr>
261
+ `}tablecell(t){const e=this.parser.parseInline(t.tokens),n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`</${n}>
262
+ `}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${pt(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:e,tokens:n}){const r=this.parser.parseInline(n),i=Rd(t);if(i===null)return r;t=i;let s='<a href="'+t+'"';return e&&(s+=' title="'+pt(e)+'"'),s+=">"+r+"</a>",s}image({href:t,title:e,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));const i=Rd(t);if(i===null)return pt(n);t=i;let s=`<img src="${t}" alt="${n}"`;return e&&(s+=` title="${pt(e)}"`),s+=">",s}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:pt(t.text)}},dc=class{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}},Dt=class ha{constructor(e){ce(this,"options");ce(this,"renderer");ce(this,"textRenderer");this.options=e||_n,this.options.renderer=this.options.renderer||new Xs,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new dc}static parse(e,n){return new ha(n).parse(e)}static parseInline(e,n){return new ha(n).parseInline(e)}parse(e,n=!0){var i,s;let r="";for(let o=0;o<e.length;o++){const l=e[o];if((s=(i=this.options.extensions)==null?void 0:i.renderers)!=null&&s[l.type]){const c=l,u=this.options.extensions.renderers[c.type].call({parser:this},c);if(u!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(c.type)){r+=u||"";continue}}const a=l;switch(a.type){case"space":{r+=this.renderer.space(a);continue}case"hr":{r+=this.renderer.hr(a);continue}case"heading":{r+=this.renderer.heading(a);continue}case"code":{r+=this.renderer.code(a);continue}case"table":{r+=this.renderer.table(a);continue}case"blockquote":{r+=this.renderer.blockquote(a);continue}case"list":{r+=this.renderer.list(a);continue}case"html":{r+=this.renderer.html(a);continue}case"paragraph":{r+=this.renderer.paragraph(a);continue}case"text":{let c=a,u=this.renderer.text(c);for(;o+1<e.length&&e[o+1].type==="text";)c=e[++o],u+=`
263
+ `+this.renderer.text(c);n?r+=this.renderer.paragraph({type:"paragraph",raw:u,text:u,tokens:[{type:"text",raw:u,text:u,escaped:!0}]}):r+=u;continue}default:{const c='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return r}parseInline(e,n=this.renderer){var i,s;let r="";for(let o=0;o<e.length;o++){const l=e[o];if((s=(i=this.options.extensions)==null?void 0:i.renderers)!=null&&s[l.type]){const c=this.options.extensions.renderers[l.type].call({parser:this},l);if(c!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(l.type)){r+=c||"";continue}}const a=l;switch(a.type){case"escape":{r+=n.text(a);break}case"html":{r+=n.html(a);break}case"link":{r+=n.link(a);break}case"image":{r+=n.image(a);break}case"strong":{r+=n.strong(a);break}case"em":{r+=n.em(a);break}case"codespan":{r+=n.codespan(a);break}case"br":{r+=n.br(a);break}case"del":{r+=n.del(a);break}case"text":{r+=n.text(a);break}default:{const c='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return r}},Ol,ns=(Ol=class{constructor(t){ce(this,"options");ce(this,"block");this.options=t||_n}preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}provideLexer(){return this.block?Rt.lex:Rt.lexInline}provideParser(){return this.block?Dt.parse:Dt.parseInline}},ce(Ol,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"])),Ol),$C=class{constructor(...t){ce(this,"defaults",rc());ce(this,"options",this.setOptions);ce(this,"parse",this.parseMarkdown(!0));ce(this,"parseInline",this.parseMarkdown(!1));ce(this,"Parser",Dt);ce(this,"Renderer",Xs);ce(this,"TextRenderer",dc);ce(this,"Lexer",Rt);ce(this,"Tokenizer",Js);ce(this,"Hooks",ns);this.use(...t)}walkTokens(t,e){var r,i;let n=[];for(const s of t)switch(n=n.concat(e.call(this,s)),s.type){case"table":{const o=s;for(const l of o.header)n=n.concat(this.walkTokens(l.tokens,e));for(const l of o.rows)for(const a of l)n=n.concat(this.walkTokens(a.tokens,e));break}case"list":{const o=s;n=n.concat(this.walkTokens(o.items,e));break}default:{const o=s;(i=(r=this.defaults.extensions)==null?void 0:r.childTokens)!=null&&i[o.type]?this.defaults.extensions.childTokens[o.type].forEach(l=>{const a=o[l].flat(1/0);n=n.concat(this.walkTokens(a,e))}):o.tokens&&(n=n.concat(this.walkTokens(o.tokens,e)))}}return n}use(...t){const e=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(n=>{const r={...n};if(r.async=this.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){const s=e.renderers[i.name];s?e.renderers[i.name]=function(...o){let l=i.renderer.apply(this,o);return l===!1&&(l=s.apply(this,o)),l}:e.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const s=e[i.level];s?s.unshift(i.tokenizer):e[i.level]=[i.tokenizer],i.start&&(i.level==="block"?e.startBlock?e.startBlock.push(i.start):e.startBlock=[i.start]:i.level==="inline"&&(e.startInline?e.startInline.push(i.start):e.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(e.childTokens[i.name]=i.childTokens)}),r.extensions=e),n.renderer){const i=this.defaults.renderer||new Xs(this.defaults);for(const s in n.renderer){if(!(s in i))throw new Error(`renderer '${s}' does not exist`);if(["options","parser"].includes(s))continue;const o=s,l=n.renderer[o],a=i[o];i[o]=(...c)=>{let u=l.apply(i,c);return u===!1&&(u=a.apply(i,c)),u||""}}r.renderer=i}if(n.tokenizer){const i=this.defaults.tokenizer||new Js(this.defaults);for(const s in n.tokenizer){if(!(s in i))throw new Error(`tokenizer '${s}' does not exist`);if(["options","rules","lexer"].includes(s))continue;const o=s,l=n.tokenizer[o],a=i[o];i[o]=(...c)=>{let u=l.apply(i,c);return u===!1&&(u=a.apply(i,c)),u}}r.tokenizer=i}if(n.hooks){const i=this.defaults.hooks||new ns;for(const s in n.hooks){if(!(s in i))throw new Error(`hook '${s}' does not exist`);if(["options","block"].includes(s))continue;const o=s,l=n.hooks[o],a=i[o];ns.passThroughHooks.has(s)?i[o]=c=>{if(this.defaults.async)return Promise.resolve(l.call(i,c)).then(d=>a.call(i,d));const u=l.call(i,c);return a.call(i,u)}:i[o]=(...c)=>{let u=l.apply(i,c);return u===!1&&(u=a.apply(i,c)),u}}r.hooks=i}if(n.walkTokens){const i=this.defaults.walkTokens,s=n.walkTokens;r.walkTokens=function(o){let l=[];return l.push(s.call(this,o)),i&&(l=l.concat(i.call(this,o))),l}}this.defaults={...this.defaults,...r}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return Rt.lex(t,e??this.defaults)}parser(t,e){return Dt.parse(t,e??this.defaults)}parseMarkdown(t){return(n,r)=>{const i={...r},s={...this.defaults,...i},o=this.onError(!!s.silent,!!s.async);if(this.defaults.async===!0&&i.async===!1)return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof n>"u"||n===null)return o(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));s.hooks&&(s.hooks.options=s,s.hooks.block=t);const l=s.hooks?s.hooks.provideLexer():t?Rt.lex:Rt.lexInline,a=s.hooks?s.hooks.provideParser():t?Dt.parse:Dt.parseInline;if(s.async)return Promise.resolve(s.hooks?s.hooks.preprocess(n):n).then(c=>l(c,s)).then(c=>s.hooks?s.hooks.processAllTokens(c):c).then(c=>s.walkTokens?Promise.all(this.walkTokens(c,s.walkTokens)).then(()=>c):c).then(c=>a(c,s)).then(c=>s.hooks?s.hooks.postprocess(c):c).catch(o);try{s.hooks&&(n=s.hooks.preprocess(n));let c=l(n,s);s.hooks&&(c=s.hooks.processAllTokens(c)),s.walkTokens&&this.walkTokens(c,s.walkTokens);let u=a(c,s);return s.hooks&&(u=s.hooks.postprocess(u)),u}catch(c){return o(c)}}}onError(t,e){return n=>{if(n.message+=`
264
+ Please report this to https://github.com/markedjs/marked.`,t){const r="<p>An error occurred:</p><pre>"+pt(n.message+"",!0)+"</pre>";return e?Promise.resolve(r):r}if(e)return Promise.reject(n);throw n}}},$n=new $C;function ie(t,e){return $n.parse(t,e)}ie.options=ie.setOptions=function(t){return $n.setOptions(t),ie.defaults=$n.defaults,Tm(ie.defaults),ie};ie.getDefaults=rc;ie.defaults=_n;ie.use=function(...t){return $n.use(...t),ie.defaults=$n.defaults,Tm(ie.defaults),ie};ie.walkTokens=function(t,e){return $n.walkTokens(t,e)};ie.parseInline=$n.parseInline;ie.Parser=Dt;ie.parser=Dt.parse;ie.Renderer=Xs;ie.TextRenderer=dc;ie.Lexer=Rt;ie.lexer=Rt.lex;ie.Tokenizer=Js;ie.Hooks=ns;ie.parse=ie;ie.options;ie.setOptions;ie.use;ie.walkTokens;ie.parseInline;Dt.parse;Rt.lex;function Ie(t){return String(t??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function Se(t){return String(t??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function hr(t){const e=String(t??"").trim();if(!e)return"";const n=e.match(/^\[([^\]]*)\]\(([^)\s]+)\)\s*$/);return n?String(n[2]||"").trim():e}function Bm(t,e="100"){let n=String(t==null||t===""?e:t).trim();return n||(n=e),n=n.replace(/%$/,""),`max-width:${Ie(n)}%;`}function BC(t){const e={};let n=String(t||"");return n=n.replace(/([\w-]+)\s*=\s*(?:"([\s\S]*?)"|'([\s\S]*?)')/g,(r,i,s,o)=>(e[i]=s??o,"")),n.replace(/([\w-]+)\s*=\s*([^\s%]+)/g,(r,i,s)=>(i in e||(e[i]=s),"")),e}function _C(t){const e=hr(t.src);if(!e)return"";const n=Bm(t.width),r=t.caption||"";return[`<figure class="my-8 mx-auto text-center w-full" style="display:block;${n}">`,`<img class="figure-lightbox-trigger" src="${Ie(e)}" alt="${Ie(t.alt||r)}" loading="lazy">`,r?`<figcaption class="mt-3">${Se(r)}</figcaption>`:"","</figure>"].join("")}function zC(t){const e=hr(t.src);if(!e)return"";const n=t.side==="right"?" article-cut-in--right":"";return`<figure class="article-cut-in-plate${n}"><img class="article-cut-in${n}" src="${Ie(e)}" alt="${Ie(t.alt||"")}" width="120" loading="lazy"></figure>`}function _m(t){const e=hr(t);if(!e)return"";const n=e.split(/[?#]/)[0],r=n.split(/[/\\]/).filter(Boolean);return r[r.length-1]||n}function ma(t){const e=hr(t);if(!e)return"";const n=e.match(/(?:youtube\.com\/(?:embed\/|shorts\/|watch\?v=)|youtu\.be\/)([A-Za-z0-9_-]{6,})/);return n?n[1]:(/^[A-Za-z0-9_-]{6,}$/.test(e),e)}function tr(t,{width:e,height:n,aspect:r,caption:i}={}){const s=String(t||"").trim()||"Embed",o=[Bm(e)];n?o.push(`min-height:${Ie(String(n))}px`):r?o.push(`aspect-ratio:${Ie(r)}`):o.push("min-height:12rem");const l=[`<figure class="studio-embed-placeholder" style="display:block;margin:1.5rem auto;text-align:center;${o.join("")}">`,`<div class="studio-embed-placeholder__box" role="img" aria-label="${Ie(s)}">`,`<code class="studio-embed-placeholder__label">${Se(s)}</code>`,"</div>"];return i&&l.push(`<figcaption>${Se(i)}</figcaption>`),l.push("</figure>"),l.join("")}function FC(t){const e=ma(t.id||t.src);return e?tr(`YouTube video: ${e}`,{width:t.width,aspect:"16 / 9",caption:t.caption}):""}function HC(t){const e=ma(t.src||t.id);if(!e)return"";const n=ma(t.src2||t.id2);return n?[tr(`YouTube short: ${e}`,{width:"45",aspect:"9 / 16"}),tr(`YouTube short: ${n}`,{width:"45",aspect:"9 / 16"})].join(""):tr(`YouTube short: ${e}`,{width:t.width||"45",aspect:"9 / 16"})}function jC(t){const e=hr(t.src);if(!e)return"";const n=_m(e)||e;return tr(`Video: ${n}`,{width:t.width,aspect:"16 / 9",caption:t.caption})}function VC(t){const e=hr(t.src);if(!e)return"";const n=_m(e)||e;return tr(`Plotly: ${n}`,{width:t.width,height:t.height||"480",caption:t.caption})}function zm(t,{kind:e,key:n,variant:r,display:i}={}){const s=String(t||"").trim()||"?",o=["studio-ref-pill"];r&&o.push(`studio-ref-pill--${r}`),i&&o.push("studio-ref-pill--display");const l=[`class="${o.join(" ")}"`];return e&&(l.push(`data-cite-check="${Ie(e)}"`),l.push(`data-key="${Ie(String(n||"").trim())}"`)),r==="latex"&&l.push('title="LaTeX (MathJax not available in Studio preview)"'),`<span ${l.join(" ")}>${Se(s)}</span>`}function fc(t,e){const n=String(e||"").trim();return zm(n||"?",{kind:t,key:n})}function UC(t){return fc("xcite",t.key)}function qC(t){return fc("cite",t.key)}function WC(t){return Se(String(t||"").trim()).replace(/\r\n|\r|\n/g,"<br>")}function KC(t){const e=String(t.lemma||"").trim();if(!e)return"";const n=String(t.locale||"").trim().toLowerCase(),r=String(t.meta||"").trim(),i=String(t.country||r||n).trim(),s=String(t.note||"").trim(),o=String(t.source||"").trim(),l=String(t.url||"").trim(),a=String(t.accessed||"").trim(),c=String(t.cite_extra||"").trim(),u=String(t.link_label||l).trim(),d=[`<article class="sov-card${n?` sov-card--${Ie(n)}`:""}" role="listitem">`,'<div class="sov-card__head">'];if(n&&d.push(`<span class="sov-card__flag" title="${Ie(i)}"><span class="fi fi-${Ie(n)}" role="img" aria-label="${Ie(i)}"></span></span>`),r&&d.push(`<span class="sov-card__meta">${Se(r)}</span>`),d.push("</div>"),d.push(`<p class="sov-card__lemma">${Se(e)}</p>`),t.def&&d.push(`<div class="sov-card__def">${WC(t.def)}</div>`),s&&d.push(`<p class="sov-card__note">${s}</p>`),o){let p=`${Se(o)}, s.v. &ldquo;${Se(e)},&rdquo;`;l&&(p+=` <a href="${Ie(l)}">${Se(u)}</a>`),a&&(p+=`, accessed ${Se(a)}`),p+=".",c&&(p+=` ${Se(c)}`),d.push(`<p class="sov-card__cite">${p}</p>`)}return d.push("</article>"),d.join("")}function YC(t){return String(t||"").replace(/(?:<article\b[^>]*\bsov-card\b[\s\S]*?<\/article>\s*){2,}/g,e=>/\bsov-grid\b/.test(e)?e:`<div class="sov-grid" role="list">${e.trim()}</div>
265
+ `)}function GC(t){const e=String(t.body||"").trim();if(!e)return"";const n=String(t.handle||"").trim().replace(/^@/,""),r=String(t.icon||"chat").trim()||"chat",i=String(t.url||"").trim(),s=String(t.date||"").trim(),o=String(t.note||"").trim(),l=String(t.name||"").trim(),a=i.replace(/^https?:\/\//,""),c=['<article class="sov-tweet article-tweet">','<div class="sov-tweet__head article-tweet__head">',`<span class="sov-tweet__avatar article-tweet__avatar" aria-hidden="true"><span class="material-symbols-outlined">${Se(r)}</span></span>`,'<span class="sov-tweet__id article-tweet__id">'];if(l&&c.push(`<span class="sov-tweet__name article-tweet__name">${Se(l)}</span>`),n&&c.push(`<span class="sov-tweet__handle article-tweet__handle">@${Se(n)}</span>`),c.push("</span></div>"),c.push(`<p class="sov-tweet__body article-tweet__body">${e}</p>`),i||s){let u="";i&&(u+=`<a href="${Ie(i)}">${Se(a)}</a>`),i&&s&&(u+=" | "),s&&(u+=Se(s)),c.push(`<p class="sov-tweet__cite article-tweet__cite">${u}</p>`)}return o&&c.push(`<p class="sov-tweet__note article-tweet__note">${o}</p>`),c.push("</article>"),c.join("")}function $d(t){const e=String(t||"").trim();if(!e)return'<div class="article-note"></div>';let n="";try{n=ie.parse(e,{gfm:!0,breaks:!1})}catch{n=`<p>${Se(e)}</p>`}return`<div class="article-note">${n}</div>`}function JC(t,e){return zm(String(t||"").trim(),{variant:"latex",display:!!e})}function Bd(t){return String(t||"").replace(/\\\s/g,"\\\\ ")}function XC(t){const e=[];let n=String(t||"");const r=(i,s)=>{const o=e.length;return e.push({display:i,math:s}),`MATH${o}`};return n=n.replace(/\$\$([\s\S]+?)\$\$/g,(i,s)=>r(!0,Bd(s))),n=n.replace(/\\\[([\s\S]+?)\\\]/g,(i,s)=>r(!0,Bd(s))),n=n.replace(/\\\(([\s\S]+?)\\\)/g,(i,s)=>r(!1,s)),n=n.replace(/(^|[^\\$])\$(?!\$)([^$\n]+?)\$(?!\$)/g,(i,s,o)=>s+r(!1,o)),{text:n,store:e}}function ZC(t,e){return String(t||"").replace(/\uE000MATH(\d+)\uE001/g,(n,r)=>{const i=e[Number(r)];return i?JC(i.math,i.display):""})}const QC={"figure.html":_C,"cut-in.html":zC,"youtube.html":FC,"youtube-short.html":HC,"video.html":jC,"plotly.html":VC,"xcite.html":UC,"cite.html":qC,"dict-card.html":KC,"tweet.html":GC};function ev(t){let e=String(t||"");return e=e.replace(/\{%-?\s*include\s+article-note(?:\.html)?\b(?:(?!%\})[\s\S])*?-?%\}\s*([\s\S]*?)\s*\{%-?\s*endinclude\s*-?%\}/gi,(n,r)=>$d(r)),e=e.replace(/<div\s+([^>]*\barticle-note\b[^>]*)>([\s\S]*?)<\/div>/gi,(n,r,i)=>$d(i)),e=e.replace(/\{%-?\s*cite\s+([^\s%]+)[\s\S]*?-?%\}/g,(n,r)=>fc("cite",r)),e=e.replace(/\{%-?\s*include\s+([\w.-]+)\s*((?:(?!%\})[\s\S])*?)\s*-?%\}/g,(n,r,i)=>{const s=QC[r];return s?s(BC(i)):`<div class="studio-unknown-include" data-include="${Ie(r)}"></div>`}),e}function tv(t){const e=XC(String(t||"")),n=ev(e.text);let r;try{r=ie.parse(n,{gfm:!0,breaks:!1})}catch{r=`<p>${Se(n)}</p>`}return YC(ZC(r,e.store))}function kn(t,e,n=1){return String(t||"").localeCompare(String(e||""),void 0,{sensitivity:"base",numeric:!0})*n}function _d(t,e,n=1){const r=String(t||""),i=String(e||"");return!r&&!i?0:r?i?r.localeCompare(i)*n:-1:1}const Zs=[{id:"date-desc",label:"Date | newest first",compare:(t,e)=>_d(t.date,e.date,-1)||kn(t.title||t.name,e.title||e.name)},{id:"date-asc",label:"Date | oldest first",compare:(t,e)=>_d(t.date,e.date,1)||kn(t.title||t.name,e.title||e.name)},{id:"title-asc",label:"Title | A–Z",compare:(t,e)=>kn(t.title||t.name,e.title||e.name,1)},{id:"title-desc",label:"Title | Z–A",compare:(t,e)=>kn(t.title||t.name,e.title||e.name,-1)},{id:"path-asc",label:"Path | A–Z",compare:(t,e)=>kn(t.path||t.name,e.path||e.name,1)},{id:"path-desc",label:"Path | Z–A",compare:(t,e)=>kn(t.path||t.name,e.path||e.name,-1)},{id:"key-asc",label:"Key | A–Z",compare:(t,e)=>kn(t.key||t.name,e.key||e.name,1)}],Qs="date-desc",eo=[{id:"10",label:"10",size:10},{id:"20",label:"20",size:20},{id:"30",label:"30",size:30},{id:"all",label:"ALL",size:null}],to="10",Fm="studio-list-sort:",Hm="studio-list-page-size:";function nv(t){return Zs.find(e=>e.id===t)||Zs[0]}function rv(t){return eo.find(e=>e.id===t)||eo[0]}function Ci(t){const e=t==null?void 0:t.tags;return Array.isArray(e)?e.map(n=>String(n??"").trim()).filter(Boolean):typeof e=="string"&&e.trim()?[e.trim()]:[]}function iv(t,e){const n=String(e||"").trim().toLowerCase();return n?t.filter(r=>[r.title,r.name,r.key,r.path,r.date,Ci(r).join(" ")].filter(Boolean).join(`
266
+ `).toLowerCase().includes(n)):t.slice()}function sv(t,e){const n=String(e||"").trim().toLowerCase();return n?t.filter(r=>Ci(r).some(i=>i.toLowerCase()===n)):t.slice()}function ov(t){const e=new Map;for(const n of t||[])for(const r of Ci(n)){const i=r.toLowerCase();e.has(i)||e.set(i,r)}return[...e.values()].sort((n,r)=>n.localeCompare(r,void 0,{sensitivity:"base"}))}function lv(t,{query:e="",sortId:n=Qs,tag:r=""}={}){const i=sv(iv(t,e),r),s=nv(n);return i.sort((o,l)=>s.compare(o,l))}function av(t,{pageSizeId:e=to,page:n=1}={}){const r=rv(e),i=t.length,s=r.size;if(s==null||s<=0)return{items:t.slice(),page:1,pageCount:1,pageSize:null,total:i,from:i?1:0,to:i};const o=Math.max(1,Math.ceil(i/s)),l=Math.min(Math.max(1,Number(n)||1),o),a=(l-1)*s,c=t.slice(a,a+s);return{items:c,page:l,pageCount:o,pageSize:s,total:i,from:i?a+1:0,to:a+c.length}}function cv(t,e=Qs){try{const n=localStorage.getItem(Fm+t);if(n&&Zs.some(r=>r.id===n))return n}catch{}return e}function uv(t,e){try{localStorage.setItem(Fm+t,e)}catch{}}function dv(t,e=to){try{const n=localStorage.getItem(Hm+t);if(n&&eo.some(r=>r.id===n))return n}catch{}return e}function fv(t,e){try{localStorage.setItem(Hm+t,e)}catch{}}const zd={posts:["date"],articles:["date"],resources:["category","type","language"],bibliography:["key"],products:["company","start_date","end_date"],projects:["status","start_date","end_date"],jobs:["company","engagement","start","end"]},pv=new Set(["name","filename"]);function hv(t){const e=String(t||"").split("/").filter(Boolean);return e.length?e[e.length-1]:""}function mv(t,e){if(t==="path")return String(e.path||"").split("/").filter(Boolean).join(" | ")||"";const n=e==null?void 0:e[t];return n==null?"":Array.isArray(n)?n.map(r=>String(r??"").trim()).filter(Boolean).join(", "):String(n).trim()}function gv(t){if(Array.isArray(t==null?void 0:t.listMetaFields)&&t.listMetaFields.length)return t.listMetaFields.map(String);const e=t==null?void 0:t.name;return e&&zd[e]?zd[e].slice():[]}function yv(t,e){const n=Array.isArray(e)?e.map(String):gv(e),r=[];for(const s of n){if(pv.has(s))continue;const o=mv(s,t);o&&r.push(o)}const i=String((t==null?void 0:t.name)||"").trim()||hv(t==null?void 0:t.path);return i&&r[r.length-1]!==i&&r.push(i),r.join(" | ")}const bv={lineWidth:100,noRefs:!0,sortKeys:!1};function mr(t){return!t||t.format!=="yaml"?null:t.list?"list":t.root_key||(t.fields||[]).length?"map":"source"}function Bt(t){const e=un.dump(t??null,bv);return e.endsWith(`
267
+ `)?e:e+`
268
+ `}function Xr(t){try{return un.load(t)}catch(e){const n=new Error((e==null?void 0:e.message)||"Invalid YAML");throw n.cause=e,n}}function jm(t){const e={};for(const n of t||[])!(n!=null&&n.name)||n.hidden||(Object.prototype.hasOwnProperty.call(n,"default")?e[n.name]=kv(n.default):n.list?e[n.name]=[]:n.type==="boolean"?e[n.name]=!1:e[n.name]="");return e}function kv(t){if(t==null||typeof t!="object")return t;try{return structuredClone(t)}catch{return JSON.parse(JSON.stringify(t))}}function dr(t,e){if(!t||typeof t!="object"||Array.isArray(t))return t;const n=new Set((e||[]).map(i=>i.name).filter(Boolean)),r={...t};for(const i of Object.keys(r)){if(!n.has(i))continue;const s=r[i];(s===""||s==null||Array.isArray(s)&&s.length===0)&&delete r[i]}return r}function Vm(t){return Array.isArray(t)?t.map(e=>e&&typeof e=="object"&&!Array.isArray(e)?{...e}:{}):[]}function nr(t){return t&&typeof t=="object"&&!Array.isArray(t)?{...t}:{}}const bt="content/media",Fd=25*1024*1024,xv=/\.(png|jpe?g|gif|webp|svg|avif|bmp|ico)$/i,Sv=/\.(mp4|webm|mov|m4v)$/i,wv=/\.html?$/i,Um=/^[A-Za-z0-9][A-Za-z0-9._-]*$/;function Cv(t){var n;const e=String(((n=t==null?void 0:t.media)==null?void 0:n.input)||bt).replace(/\/+$/,"");return e===bt||e.startsWith(`${bt}/`),bt}function wo(t){const e=String(t||"");return e.startsWith("content/media")?e.replace(/^content/,"")||"/media":""}function qm(t){return xv.test(String(t||""))}function Wm(t){return Sv.test(String(t||""))}function Km(t){return wv.test(String(t||""))}function Ym(t){return qm(t)?"image":Wm(t)?"video":Km(t)?"html":null}function Gm(t){const e=Number(t)||0;return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function vv(t){const e=String(t||"").split(/[/\\]/).pop().trim();if(!e)return null;const n=e.replace(/\s+/g,"-").replace(/[^A-Za-z0-9._-]/g,"");return Um.test(n)?n:null}function Mv(t){const e=String(t||"").trim().replace(/\s+/g,"-").replace(/[^A-Za-z0-9._-]/g,"");return!Um.test(e)||e===".gitkeep"?null:e}function Tv(t){return new Promise((e,n)=>{const r=new FileReader;r.onload=()=>{const i=String(r.result||""),s=i.indexOf(",");e(s>=0?i.slice(s+1):i)},r.onerror=()=>n(r.error||new Error("read_failed")),r.readAsDataURL(t)})}function Av(t,e=bt){const r=String(t).split("/").filter(Boolean),i=e.split("/").filter(Boolean),s=[];let o="";for(let l=0;l<r.length;l++){o=o?`${o}/${r[l]}`:r[l];const a=l===i.length-1&&o===e;!(l>=i.length-1)&&!a||s.push({label:a||o===e?"media":r[l],path:o})}return s.length||s.push({label:"media",path:e}),s}function Ev(t){const{api:e,state:n,el:r,materialIcon:i,resolveMediaUrl:s,render:o,captureError:l,clearError:a,goHome:c}=t,u=n.mediaPath||bt,d=n.mediaItems||[],p=Av(u),h=r("nav",{className:"media-breadcrumb","aria-label":"Media path"});p.forEach((A,R)=>{R>0&&h.append(r("span",{className:"media-breadcrumb-sep",text:"/"})),R===p.length-1?h.append(r("span",{className:"media-breadcrumb-current",text:A.label})):h.append(r("button",{className:"media-breadcrumb-link",type:"button",text:A.label,onClick:()=>void vi(A.path,t)}))});const g=r("input",{type:"file",className:"media-file-input",multiple:"multiple",accept:"image/*,video/*,.html,.svg,.pdf",hidden:!0,onChange:async A=>{const R=Array.from(A.target.files||[]);A.target.value="",R.length&&await Rv(R,t)}}),b=r("div",{className:"media-toolbar"},[r("button",{className:"btn btn-nav",type:"button",title:"Back to Studio map",onClick:()=>c()},[i("chevron_left","btn-nav-icon"),r("span",{text:"Studio map"})]),r("span",{className:"spacer"}),r("button",{className:"btn",type:"button",text:"New folder",disabled:!!n.mediaBusy,onClick:()=>void Iv(t)}),r("button",{className:"btn btn-primary",type:"button",text:n.mediaBusy?"Working…":"Upload",disabled:!!n.mediaBusy,onClick:()=>g.click()}),g]),x=r("p",{className:"media-hint",text:"Click an image, video, or HTML file to preview it. Copy the public path into includes (e.g. /media/images/…). Deletes stay in GitHub/IDE."});let w;if(n.mediaLoading)w=r("p",{className:"loading-msg",text:"Loading media…"});else if(!d.length)w=r("p",{className:"empty-msg",text:"This folder is empty. Upload a file or create a subfolder."});else{const A=d.map(R=>Nv(R,t));w=r("div",{className:"media-grid",role:"list"},A)}return r("div",{className:"pane media-pane"},[r("header",{className:"media-header"},[r("h1",{className:"media-title",text:"Media"}),h,x]),b,w])}function Nv(t,e){const{el:n,materialIcon:r,resolveMediaUrl:i,state:s}=e,o=t.type==="dir",l=o?null:Ym(t.name),a=t.public_path||(o?null:wo(t.path)),c=!o&&qm(t.name)&&a?i(a):"";let u;if(o)u=n("span",{className:"media-thumb media-thumb--folder"},[r("folder","media-thumb-icon")]);else if(c){const g=n("img",{className:"media-thumb-img",src:c,alt:"",loading:"lazy",referrerpolicy:"no-referrer"});g.addEventListener("error",()=>{g.replaceWith(n("span",{className:"media-thumb media-thumb--file"},[r("image","media-thumb-icon")]))}),u=n("span",{className:"media-thumb media-thumb--image"},[g])}else Wm(t.name)?u=n("span",{className:"media-thumb media-thumb--file"},[r("movie","media-thumb-icon")]):Km(t.name)?u=n("span",{className:"media-thumb media-thumb--file"},[r("html","media-thumb-icon")]):u=n("span",{className:"media-thumb media-thumb--file"},[r("draft","media-thumb-icon")]);const d=[];!o&&t.size&&d.push(Gm(t.size)),a&&d.push(a);const p=o?()=>void vi(t.path,e):l?g=>Lv(t,g.currentTarget,e):()=>void Hd(a,e),h=o?`Open ${t.name}`:l?`Preview ${t.name}`:`Copy ${a}`;return n("div",{className:"media-row"+(o?" media-row--dir":""),role:"listitem"},[n("button",{className:"media-row-main"+(l?" media-row-main--preview":""),type:"button",title:h,disabled:!!s.mediaBusy,onClick:p},[u,n("span",{className:"media-row-body"},[n("span",{className:"media-row-name",text:t.name}),n("span",{className:"media-row-meta",text:d.join(" · ")||(o?"Folder":"")})])]),!o&&a?n("button",{className:"btn media-copy-btn",type:"button",text:"Copy path",title:a,disabled:!!s.mediaBusy,onClick:()=>void Hd(a,e)}):null].filter(Boolean))}let yt=null,ga=null;function Ov(t,e){if(yt)return yt;const n=t("img",{className:"figure-lightbox-img",alt:""}),r=t("video",{className:"figure-lightbox-video",controls:!0,playsinline:!0}),i=t("iframe",{className:"figure-lightbox-frame",title:"Media preview"}),s=t("p",{className:"figure-lightbox-caption"});n.hidden=!0,r.hidden=!0,i.hidden=!0,s.hidden=!0,r.controls=!0;const o=t("button",{type:"button",className:"figure-lightbox-close","data-lightbox-close":"true","aria-label":"Close",onClick:a=>{a.preventDefault(),Tl()}},[e("close")]),l=t("div",{id:"figure-lightbox",className:"figure-lightbox",role:"dialog","aria-modal":"true","aria-label":"Media preview","aria-hidden":"true"},[t("div",{className:"figure-lightbox-backdrop","data-lightbox-close":"true",tabindex:"-1",onClick:()=>Tl()}),t("div",{className:"figure-lightbox-panel"},[o,n,r,i,s])]);return l.hidden=!0,document.body.append(l),document.addEventListener("keydown",a=>{!yt||yt.root.hidden||a.key==="Escape"&&(a.preventDefault(),Tl())}),yt={root:l,img:n,video:r,frame:i,caption:s,closeBtn:o},yt}function Jm(t){t.img.removeAttribute("src"),t.img.alt="",t.img.hidden=!0,t.video.pause(),t.video.removeAttribute("src"),t.video.load(),t.video.hidden=!0,t.frame.removeAttribute("src"),t.frame.hidden=!0,t.caption.textContent="",t.caption.hidden=!0}function Xm(t,e){t.root.hidden=!e,t.root.setAttribute("aria-hidden",String(!e)),document.documentElement.classList.toggle("figure-lightbox-open",e),document.body.classList.toggle("figure-lightbox-open",e)}function Tl(){if(!yt||yt.root.hidden)return;Jm(yt),Xm(yt,!1);const t=ga;if(ga=null,t&&typeof t.focus=="function")try{t.focus()}catch{}}function Lv(t,e,n){const{el:r,materialIcon:i,resolveMediaUrl:s}=n,o=Ym(t.name),l=t.public_path||wo(t.path),a=l?s(l):"";if(!o||!a)return;const c=Ov(r,i);ga=e||null,Jm(c),o==="image"?(c.img.hidden=!1,c.img.referrerPolicy="no-referrer",c.img.alt=t.name||"",c.img.src=a):o==="video"?(c.video.hidden=!1,c.video.referrerPolicy="no-referrer",c.video.src=a):(c.frame.hidden=!1,c.frame.title=t.name||"HTML preview",c.frame.src=a),c.caption.textContent=t.name||"",c.caption.hidden=!t.name,Xm(c,!0),c.closeBtn.focus()}async function Hd(t,e){const{state:n,render:r,captureError:i,clearError:s}=e;if(t){s();try{await navigator.clipboard.writeText(t),n.status=`Copied ${t}`}catch(o){i(o),n.status=t}r()}}async function vi(t,e){const{api:n,state:r,render:i,captureError:s,clearError:o}=e;o(),r.mediaPath=t||bt,r.mediaLoading=!0,r.mediaBusy=!1,r.status=`Loading ${r.mediaPath}…`,i();try{const l=await n.listMedia(r.mediaPath);r.mediaItems=l.items||[],r.mediaPath=l.path||r.mediaPath,r.mediaLoading=!1;const a=r.mediaItems.filter(u=>u.type==="dir").length,c=r.mediaItems.filter(u=>u.type==="file").length;r.status=`${a} folders · ${c} files`}catch(l){r.mediaItems=[],r.mediaLoading=!1,s(l)}i()}async function Iv(t){const{api:e,state:n,render:r,captureError:i,clearError:s}=t,o=window.prompt("New folder name (letters, numbers, .-_)");if(o==null)return;const l=Mv(o);if(!l){n.error="Invalid folder name",n.status="",r();return}const a=`${n.mediaPath||bt}/${l}`;s(),n.mediaBusy=!0,n.status=`Creating ${l}…`,r();try{await e.createMediaFolder({path:a,message:`studio: mkdir ${a}`}),n.mediaBusy=!1,n.status=`Created ${wo(a)||a}`,await vi(n.mediaPath,t)}catch(c){n.mediaBusy=!1,i(c),r()}}async function Rv(t,e){const{api:n,state:r,render:i,captureError:s,clearError:o}=e;o();const l=r.mediaPath||bt;let a=0;r.mediaBusy=!0;for(const c of t){const u=vv(c.name);if(!u){r.error=`Skipped invalid name: ${c.name}`;continue}if(c.size>Fd){r.error=`${u} exceeds ${Gm(Fd)} (GitHub Contents API soft limit in Studio)`;continue}r.status=`Uploading ${u}…`,i();try{const d=await Tv(c),p=`${l}/${u}`,h=await n.uploadMedia({path:p,content_base64:d,message:`studio: upload ${p}`});a+=1,r.status=`Uploaded ${h.public_path||wo(p)}`}catch(d){s(d),r.mediaBusy=!1,i();return}}r.mediaBusy=!1,a&&(r.status=a===1?r.status:`Uploaded ${a} files`),await vi(l,e)}const Dv="pk_test_c291bmQtc3F1aXJyZWwtNDgzMC5jbGVyay5hY2NvdW50cy5kZXYk",Zt="/studio/",jd="",Zm={forceRedirectUrl:Zt,fallbackRedirectUrl:Zt,signInForceRedirectUrl:Zt,signInFallbackRedirectUrl:Zt,signUpForceRedirectUrl:Zt,signUpFallbackRedirectUrl:Zt};function Pv(t){const e=String(t).replace(/^pk_(test|live)_/,"");if(!e)return"";try{const n="=".repeat((4-e.length%4)%4),r=(e+n).replace(/-/g,"+").replace(/_/g,"/");return atob(r).replace(/\$$/,"").trim()}catch{return""}}function Vd(t,e={}){return new Promise((n,r)=>{const i=document.querySelector(`script[src="${t}"]`);if(i){if(i.dataset.loaded==="1")return n();i.addEventListener("load",()=>n(),{once:!0}),i.addEventListener("error",()=>r(new Error(`Failed to load ${t}`)),{once:!0});return}const s=document.createElement("script");s.src=t,s.async=!0,s.defer=!0,s.crossOrigin="anonymous";for(const[o,l]of Object.entries(e))if(o==="dataset"&&l&&typeof l=="object")for(const[a,c]of Object.entries(l))s.dataset[a]=c;else l!=null&&s.setAttribute(o,l);s.onload=()=>{s.dataset.loaded="1",n()},s.onerror=()=>r(new Error(`Failed to load ${t}`)),document.head.appendChild(s)})}async function $v(t){if(window.Clerk&&typeof window.Clerk.load=="function"&&window.__internal_ClerkUICtor)return window.Clerk;const e="".replace(/^https?:\/\//,"").replace(/\/$/,"")||Pv(t);if(!e)throw new Error("Cannot resolve Clerk Frontend API host from publishable key");const n=`https://${e}/npm`;await Vd(`${n}/@clerk/ui@1/dist/ui.browser.js`),await Vd(`${n}/@clerk/clerk-js@6/dist/clerk.browser.js`,{dataset:{clerkPublishableKey:t}});for(let r=0;r<80;r++){if(window.Clerk&&typeof window.Clerk.load=="function"&&window.__internal_ClerkUICtor)return window.Clerk;await new Promise(s=>setTimeout(s,25))}throw new Error("Clerk / ClerkUI global missing after script load")}async function Bv(){const t=await $v(Dv);return await t.load({clerkUICtor:window.__internal_ClerkUICtor,...Zm}),Og(async()=>t.session?t.session.getToken():null),t}const ot=document.getElementById("app"),m={schema:null,session:null,collection:null,items:[],file:null,sha:null,fields:{},body:"",yamlDoc:null,yamlList:null,yamlUiMode:"structured",bodyMode:"visual",lastEditorMode:"visual",baseline:null,dirty:!1,saving:!1,status:"",error:"",errorCode:"",errorDetail:"",listLoading:!1,fileLoading:!1,previewHtml:"",bodyEditor:null,insertMenuOpen:!1,aiProofHint:"",aiProofBusy:!1,aiProofSelection:null,navOpenGroups:new Set,navMenuOpen:!1,listQueryByCollection:Object.create(null),listSortByCollection:Object.create(null),listPageSizeByCollection:Object.create(null),listPageByCollection:Object.create(null),listTagByCollection:Object.create(null),navCountByCollection:Object.create(null),treeCacheByCollection:Object.create(null),treePrefetchGen:0,frontMatterOpen:null,mediaOpen:!1,mediaPath:"content/media",mediaItems:[],mediaLoading:!1,mediaBusy:!1},_v={figure:"image",cutIn:"transition_push",youtube:"smart_display",youtubeShort:"mobile_screen_share",video:"videocam",plotly:"analytics",xcite:"format_quote",cite:"bookmark",articleNote:"sticky_note_2",poem:"history_edu"},ya={Writing:"edit_note",References:"menu_book",Portfolio:"work",Media:"photo_library",Pages:"description","CV Summary":"badge",Presentation:"campaign",Profile:"person"},zv=[{label:"Default",value:""},{label:"Primary",value:"var(--primary)"},{label:"Secondary",value:"var(--secondary)"},{label:"Tertiary",value:"var(--tertiary)"},{label:"Muted",value:"var(--on-surface-variant)"},{label:"Error",value:"var(--error)"}],Fv={Writing:"Articles and Portuguese rascunhos",References:"Source cards and bibliography entries",Portfolio:"Products, projects, and CV jobs",Media:"Upload and browse content/media — cite /media/… in includes",Pages:"Listing page headers and furniture copy","CV Summary":"Public and PDF CV summary variants",Presentation:"Home catch phrase and CV side notes",Profile:"Contacts, education, languages, and skills"};function Mi(t){return String(t||"").split("/").filter(Boolean).join(" | ")}function Qm(t){return Fv[t]||`Browse ${t} collections`}function eg(t){return"nav-group-"+String(t).toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function tg(t){const e=ng(t.description);if(e)return e;const n=Mi(t.path)||t.name;return t.type==="file"?`Open ${t.label} | ${n}`:`List entries in ${t.label} | ${n}`}function ng(t){let e=String(t||"").trim();if(!e)return"";const n=[/\s*The filename uses Key as YYYY-MM-DD-key[^.]*\./gi,/\s*Also the filename stem:[^.]*\./gi,/\s*Also the filename:[^.]*\./gi,/\s*Must match the YYYY-MM-DD in the filename[^.]*\./gi,/\s*;?\s*must match the YYYY-MM-DD in the filename\./gi,/\s*The Updated date is read from Git, never set here\./gi,/\s*ASCII kebab-case\./gi,/\s*\(44 characters total for the key segment is a good ceiling\)\.?/gi,/Metadata-first forms[^.]*\./gi,/TipTap with Liquid blocks[^.]*\./gi,/preview via content-runtime contract\.?/gi,/Paste Liquid \{%\s*include\s*%\} markers[^.]*\./gi,/Do not use rich-text:[^.]*\./gi,/its Editor mode rewrites URLs inside includes\.?/gi,/Markdown source \(code editor\)\.?/gi];for(const r of n)e=e.replace(r,"");return e=e.replace(/\s{2,}/g," ").replace(/\s+\./g,".").trim(),/filename|YYYY-MM-DD-key|content-runtime|autolink|TipTap/i.test(e)?"":e}function Ud(t){return ng(t==null?void 0:t.description)}function zn(t){var i,s;const e=String((t==null?void 0:t.message)||t||"Request failed"),n=[];t!=null&&t.status&&n.push(`HTTP ${t.status}`);const r=(i=t==null?void 0:t.data)==null?void 0:i.detail;if(r)n.push(String(r));else if(t!=null&&t.data&&typeof t.data=="object")try{n.push(JSON.stringify(t.data,null,2))}catch{}else t!=null&&t.stack&&!String(t.stack).includes(e)&&n.push(String(t.stack).split(`
269
+ `).slice(0,6).join(`
270
+ `));m.error=e,m.errorCode=String((t==null?void 0:t.code)||((s=t==null?void 0:t.data)==null?void 0:s.error)||""),m.errorDetail=n.join(`
271
+ `).trim(),m.status=""}function zt(){m.error="",m.errorCode="",m.errorDetail=""}function Hv(){var t;return m.mediaOpen?"Media":(t=m.collection)!=null&&t.label?m.collection.label:"Home"}function pc(){m.navMenuOpen=!1}function hc(){var t,e;Ht(),m.collection=null,m.file=null,m.baseline=null,m.items=[],m.yamlDoc=null,m.yamlList=null,m.listLoading=!1,m.fileLoading=!1,m.dirty=!1,m.insertMenuOpen=!1,m.mediaOpen=!1,m.mediaItems=[],m.mediaLoading=!1,m.mediaBusy=!1,pc(),zt(),m.status=((t=m.session)==null?void 0:t.email)||((e=m.session)==null?void 0:e.userId)||"",oe(),lg()}function rg(){return{api:kt,state:m,el:k,materialIcon:Qe,resolveMediaUrl:ag,render:()=>oe(),captureError:zn,clearError:zt,goHome:hc}}async function ig(t){Ht(),m.collection=null,m.file=null,m.baseline=null,m.items=[],m.insertMenuOpen=!1,m.dirty=!1,m.mediaOpen=!0,m.navOpenGroups.add("Media"),pc();const e=Cv(m.schema);await vi(e,rg())}function Qe(t,e=""){return k("span",{className:"material-symbols-outlined"+(e?` ${e}`:""),text:t,"aria-hidden":"true"})}function Co({size:t=40,label:e=""}={}){return k("span",{className:"studio-mark",...e?{role:"img","aria-label":e}:{"aria-hidden":"true"},html:`<svg class="studio-mark-svg" viewBox="0 0 32 32" width="${t}" height="${t}" focusable="false"><polygon class="studio-mark-primary" points="16,1 24,5 13,14 2,17 2,9"/><polygon class="studio-mark-secondary" points="24,5 30,9 30,23 22,28 19,18 13,14"/><polygon class="studio-mark-tertiary" points="2,17 13,14 19,18 22,28 16,31 2,23"/><polygon class="studio-mark-frame" points="16,1 30,9 30,23 16,31 2,23 2,9"/></svg>`})}function qd(t){const e=t.title||t.name||"Entry",n=Mi(t.path);return n?`Open ${e} | ${n}`:`Open ${e}`}function jv(){var e;const t=(e=m.collection)==null?void 0:e.name;return t&&m.listQueryByCollection[t]||""}function Vv(){var n;const t=(n=m.collection)==null?void 0:n.name;if(!t)return Qs;if(m.listSortByCollection[t])return m.listSortByCollection[t];const e=cv(t,Qs);return m.listSortByCollection[t]=e,e}function Uv(t){var n;const e=(n=m.collection)==null?void 0:n.name;e&&(m.listSortByCollection[e]=t,uv(e,t),vo())}function qv(){var n;const t=(n=m.collection)==null?void 0:n.name;if(!t)return to;if(m.listPageSizeByCollection[t])return m.listPageSizeByCollection[t];const e=dv(t,to);return m.listPageSizeByCollection[t]=e,e}function Wv(t){var n;const e=(n=m.collection)==null?void 0:n.name;e&&(m.listPageSizeByCollection[e]=t,fv(e,t),vo())}function Wd(){var e;const t=(e=m.collection)==null?void 0:e.name;return t?Math.max(1,Number(m.listPageByCollection[t])||1):1}function Al(t){var n;const e=(n=m.collection)==null?void 0:n.name;e&&(m.listPageByCollection[e]=Math.max(1,Number(t)||1))}function vo(){var e;const t=(e=m.collection)==null?void 0:e.name;t&&(m.listPageByCollection[t]=1)}function Kv(){var e;const t=(e=m.collection)==null?void 0:e.name;return t&&m.listTagByCollection[t]||""}function Kd(t){var n;const e=(n=m.collection)==null?void 0:n.name;e&&(m.listTagByCollection[e]=String(t||""),vo())}function sg(t,e){t!=null&&t.name&&(m.navCountByCollection[t.name]=Math.max(0,Number(e)||0))}function og(t,e){if(!(t!=null&&t.name))return;const n=Array.isArray(e)?e:[];m.treeCacheByCollection[t.name]={items:n},sg(t,n.length)}function Yv(t){if(!(t!=null&&t.name))return null;const e=m.treeCacheByCollection[t.name];return e?e.items:null}function Gv(t){if(!t){m.treeCacheByCollection=Object.create(null);return}delete m.treeCacheByCollection[t]}function Jv(t=m.schema){return((t==null?void 0:t.collections)||[]).filter(e=>e&&e.type!=="file"&&e.path)}function Xv(t){return[...t].sort((e,n)=>{const r=e.group==="Writing"?0:1,i=n.group==="Writing"?0:1;return r!==i?r-i:String(e.label||e.name).localeCompare(String(n.label||n.name))})}function lg(){const t=++m.treePrefetchGen,e=()=>{Zv(t)};typeof requestIdleCallback=="function"?requestIdleCallback(e,{timeout:2500}):setTimeout(e,400)}async function Zv(t){const e=Xv(Jv()).filter(n=>!m.treeCacheByCollection[n.name]);for(const n of e){if(t!==m.treePrefetchGen)return;try{const r=await kt.tree(n.path);if(t!==m.treePrefetchGen)return;m.treeCacheByCollection[n.name]||(og(n,r.items||[]),m.file||oe())}catch{}await new Promise(r=>setTimeout(r,60))}}function ag(t){const e=String(t||"").trim();return e?/^https?:\/\//i.test(e)?e:e.startsWith("/media/")?`${jd.replace(/\/$/,"")}${e}`:e.startsWith("media/")?`${jd.replace(/\/$/,"")}/${e}`:(e.startsWith("/"),e):""}function Yd(){return k("span",{className:"ledger-thumb placeholder",title:"No thumbnail","aria-label":"No thumbnail"},[k("span",{className:"material-symbols-outlined",text:"web_asset_off","aria-hidden":"true"})])}function Gd(t){const e=ag(t.thumbnail);if(!e)return Yd();const n=k("img",{className:"ledger-thumb",src:e,alt:"",loading:"lazy",referrerpolicy:"no-referrer"});return n.addEventListener("error",()=>{n.replaceWith(Yd())}),n}function ve(t,e=document){return e.querySelector(t)}function k(t,e={},n=[]){const r=document.createElement(t);for(const[i,s]of Object.entries(e))i==="className"?r.className=s:i==="text"?r.textContent=s:i==="html"?r.innerHTML=s:i==="htmlFor"?r.htmlFor=s:i.startsWith("on")&&typeof s=="function"?r.addEventListener(i.slice(2).toLowerCase(),s):i==="checked"||i==="selected"||i==="disabled"||i==="multiple"||i==="open"?r[i]=!!s:s===!1||s==null||(s===!0?r.setAttribute(i,""):r.setAttribute(i,s));for(const i of[].concat(n))i==null||i===!1||r.append(i.nodeType?i:document.createTextNode(String(i)));return r}function ba(t){document.documentElement.setAttribute("data-theme",t),localStorage.setItem("studio-theme",t)}function Qv(){const t=localStorage.getItem("studio-theme");t?ba(t):window.matchMedia("(prefers-color-scheme: dark)").matches&&ba("dark")}function cg(t){var r,i;if(!t||t.dev||!t.user)return"";const e=(r=t.user.primaryEmailAddress)==null?void 0:r.emailAddress;return e||((i=(t.user.emailAddresses||[])[0])==null?void 0:i.emailAddress)||""}function di(t){if(t&&!t.dev&&t.user){eM(t,m.error||"Studio API session failed while you are signed in.");return}ot.innerHTML="";const e=k("div",{className:"auth-gate"},[k("div",{className:"studio-brand"},[Co({size:32,label:"Studio"}),k("strong",{text:"Studio"})]),k("h1",{text:"Sign in to edit"}),k("p",{text:"Studio is for site admins only. Anyone may register; access is granted after review."}),k("div",{id:"clerk-sign-in"})]);ot.append(e),t&&!t.dev?t.mountSignIn(ve("#clerk-sign-in"),{...Zm}):ve("#clerk-sign-in").append(k("p",{className:"status-pill",text:"No VITE_CLERK_PUBLISHABLE_KEY — using API bypass if enabled."}),k("button",{className:"btn btn-primary",text:"Continue",onClick:()=>is(t)}))}function eM(t,e){ot.innerHTML="";const n=k("div",{className:"auth-gate"},[k("div",{className:"studio-brand"},[Co({size:32,label:"Studio"}),k("strong",{text:"Studio"})]),k("h1",{text:"Studio API unavailable"}),k("p",{className:"status-pill error",text:e}),k("p",{text:"You are signed in with Clerk, but /api/studio/session did not succeed. Local jekyll serve has no Pages Functions — use a Pages preview, wrangler pages dev, or STUDIO_DEV_BYPASS against a running Function."}),k("button",{className:"btn",type:"button",text:"Sign out",onClick:async()=>{if(t&&!t.dev&&t.signOut){await t.signOut({redirectUrl:Zt});return}di(t)}})]);ot.append(n)}function tM(t,e){const n=e||cg(t)||"the address you used to register";ot.innerHTML="";const r=k("p",{className:"pending-copy"});r.append(document.createTextNode("Thank you for your registration. Your profile is being transferred to the site administration to be reviewed as a potential contributor. You will be contacted via "));const i=document.createElement("strong");i.textContent=n,r.append(i),r.append(document.createTextNode("."));const s=k("div",{className:"auth-gate auth-gate--pending"},[k("div",{className:"studio-brand"},[Co({size:32,label:"Studio"}),k("strong",{text:"Studio"})]),k("h1",{text:"Registration received"}),r,k("p",{className:"pending-signoff",text:"Have a nice one! ✍️"}),k("button",{className:"btn",type:"button",text:"Sign out",onClick:async()=>{if(t&&!t.dev&&t.signOut){await t.signOut({redirectUrl:Zt});return}di(t)}})]);ot.append(s)}function ug(t){const e=new Map;for(const n of t.collections)e.has(n.group)||e.set(n.group,[]),e.get(n.group).push(n);return e}function Jd(){const t="Media",e=m.navOpenGroups.has(t),n=k("div",{className:"studio-nav-group-items",id:eg(t),role:"region","aria-label":t});e||(n.hidden=!0),n.append(k("button",{className:"nav-item",type:"button",text:"Library",title:"Browse and upload under content/media","aria-current":m.mediaOpen?"page":null,onClick:()=>ig()}));const r=k("button",{className:"studio-nav-group-toggle",type:"button",title:Qm(t),"aria-expanded":e?"true":"false","aria-controls":n.id,onClick:()=>{m.navOpenGroups.has(t)?m.navOpenGroups.delete(t):m.navOpenGroups.add(t),oe()}},[k("span",{className:"material-symbols-outlined",text:e?"expand_more":"chevron_right","aria-hidden":"true"}),k("span",{className:"nav-group-label",text:t})]);return k("div",{className:"studio-nav-group"},[r,n])}function nM(){if(!m.error||!m.file&&!m.mediaOpen)return null;const t=[];if(m.errorCode==="conflict"&&m.file){const e=m.file;t.push(k("button",{className:"btn",type:"button",text:"Reload from GitHub",title:"Replace this screen with the file currently on GitHub",onClick:()=>gc(e)}))}return t.push(k("button",{className:"btn",type:"button",text:"Dismiss",onClick:()=>{zt(),oe()}})),k("div",{className:"studio-error-banner",role:"alert"},[k("p",{className:"studio-error-message",text:m.error}),k("div",{className:"studio-error-actions"},t)])}function oe(){var a,c,u;ot.innerHTML="";const t=ug(m.schema),e=!!m.navMenuOpen,n=k("button",{className:"studio-brand studio-brand-home",type:"button",title:"Studio home","aria-current":!m.collection&&!m.mediaOpen?"page":null,onClick:()=>hc()},[Co({size:40}),k("span",{className:"studio-brand-copy"},[k("span",{className:"studio-brand-name",text:"Studio"})])]),r=k("button",{className:"studio-nav-menu-toggle",type:"button",title:e?"Close collections menu":"Open collections menu","aria-expanded":e?"true":"false","aria-controls":"studio-nav-panel",onClick:()=>{m.navMenuOpen=!m.navMenuOpen,oe()}},[k("span",{className:"studio-nav-menu-label",text:Hv()}),k("span",{className:"material-symbols-outlined",text:e?"expand_less":"expand_more","aria-hidden":"true"})]),i=k("div",{className:"studio-nav-panel",id:"studio-nav-panel"});for(const[d,p]of t){const h=m.navOpenGroups.has(d),g=k("div",{className:"studio-nav-group-items",id:eg(d),role:"region","aria-label":d});h||(g.hidden=!0);for(const x of p){const w=m.navCountByCollection[x.name],A=[k("span",{className:"nav-item-label",text:x.label})];w!=null&&A.push(k("span",{className:"nav-item-count",text:String(w)})),g.append(k("button",{className:"nav-item",type:"button",title:tg(x),"aria-current":((a=m.collection)==null?void 0:a.name)===x.name?"page":null,onClick:()=>mg(x)},A))}const b=k("button",{className:"studio-nav-group-toggle",type:"button",title:Qm(d),"aria-expanded":h?"true":"false","aria-controls":g.id,onClick:()=>{m.navOpenGroups.has(d)?m.navOpenGroups.delete(d):m.navOpenGroups.add(d),oe()}},[k("span",{className:"material-symbols-outlined",text:h?"expand_more":"chevron_right","aria-hidden":"true"}),k("span",{className:"nav-group-label",text:d})]);i.append(k("div",{className:"studio-nav-group"},[b,g])),(d==="Portfolio"||d==="References"&&!t.has("Portfolio"))&&i.append(Jd())}!t.has("Portfolio")&&!t.has("References")&&i.append(Jd());const s=k("nav",{className:"studio-nav"+(e?" is-open":""),"aria-label":"Collections"},[k("div",{className:"studio-nav-bar"},[n,r]),i]),o=k("div",{className:"studio-toolbar"},[k("span",{className:"status-pill"+(m.error?" error":""),text:m.error?"Error":m.status||((c=m.session)==null?void 0:c.email)||((u=m.session)==null?void 0:u.userId)||"",title:m.error||m.errorDetail||m.status||""}),k("span",{className:"spacer"}),k("button",{className:"btn",type:"button",text:document.documentElement.getAttribute("data-theme")==="dark"?"Dark":"Light",title:"Toggle light / dark theme","data-studio-action":"theme",onClick:d=>{const h=document.documentElement.getAttribute("data-theme")==="dark"?"light":"dark";ba(h),d.currentTarget.textContent=h==="dark"?"Dark":"Light";const g=ve("#preview-frame");g&&pg(g)}}),k("button",{className:"btn",type:"button",text:"Discard",title:"Revert all edits to the last loaded or saved version","data-studio-action":"discard",disabled:!m.file||!m.dirty||!m.baseline,onClick:()=>jM()}),k("button",{className:"btn btn-primary",type:"button",text:m.saving?"Saving…":m.dirty?"Save":"Saved",title:m.saving?"Saving this draft":m.dirty?"Commit this draft":"No edits to commit yet","data-studio-action":"save",disabled:m.saving||!m.file||!m.dirty,onClick:()=>VM()})]),l=k("div",{className:"studio-main"},[o,nM(),rM(),k("div",{className:"studio-body"+(m.file?"":" list-only"),id:"studio-body"})]);ot.append(k("div",{className:"studio-shell"},[s,l])),Nt()}function rM(){var e,n;const t=[k("span",{className:"studio-crumb",text:"Studio"})];if(m.mediaOpen&&!m.collection)t.push(k("span",{className:"studio-crumb-sep","aria-hidden":"true",text:"/"}),k("span",{className:"studio-crumb is-current",text:"Media"}));else if(m.collection){const r=m.collection.group||"Content",i=m.collection.label||m.collection.name;if(t.push(k("span",{className:"studio-crumb-sep","aria-hidden":"true",text:"/"}),k("span",{className:"studio-crumb",text:r}),k("span",{className:"studio-crumb-sep","aria-hidden":"true",text:"/"}),k("span",{className:"studio-crumb"+(m.file?"":" is-current"),text:i})),m.file){const s=((e=m.fields)==null?void 0:e.title)||((n=m.fields)==null?void 0:n.key)||String(m.file).split("/").pop()||"Entry";t.push(k("span",{className:"studio-crumb-sep","aria-hidden":"true",text:"/"}),k("span",{className:"studio-crumb is-current",text:s}))}}else t.push(k("span",{className:"studio-crumb-sep","aria-hidden":"true",text:"/"}),k("span",{className:"studio-crumb is-current",text:"Map"}));return k("nav",{className:"studio-breadcrumb","aria-label":"Location"},t)}function Fe(){m.dirty=!0,xa(),TM()}function mc(){var t;return!m.file||fr()||m.aiProofBusy?!1:!!String(((t=m.fields)==null?void 0:t.language)||"").trim()}function ka(){const t=m.aiProofBusy,e=mc()&&!t;for(const n of["correct","refine"]){const r=document.querySelector(`[data-studio-action='${n}']`);if(!r)continue;r.disabled=!e;const i=r.querySelector(".editor-ai-proof-label");i&&(t?i.textContent="Working…":i.textContent=n==="refine"?"Refine":"Correct")}}function Zr(){m.insertMenuOpen=!1;const t=ve("#insert-menu");t&&(t.hidden=!0);for(const e of document.querySelectorAll(".editor-insert-btn[aria-haspopup='menu']"))e.setAttribute("aria-expanded","false")}function rs(t){m.aiProofHint=t;const e=ve("#ai-proof-hint");e&&(e.textContent=t,e.hidden=!t),clearTimeout(m._aiProofHintTimer),t&&(m._aiProofHintTimer=setTimeout(()=>{m.aiProofHint="";const n=ve("#ai-proof-hint");n&&(n.textContent="",n.hidden=!0)},3200))}function dg(){var t;if(m.bodyMode==="source"){const e=ve("#body-source");if(!e)return null;const n=e.selectionStart,r=e.selectionEnd;if(!Number.isInteger(n)||!Number.isInteger(r)||n===r)return null;cn();const i=m.body||"";return{kind:"source",start:n,end:r,text:i.slice(n,r)}}if(m.bodyMode==="visual"&&((t=m.bodyEditor)!=null&&t.editor)){const e=m.bodyEditor.editor,{from:n,to:r,empty:i}=e.state.selection;if(i||n===r)return null;const s=e.state.doc.textBetween(n,r,`
272
+
273
+ `);return String(s).trim()?{kind:"visual",from:n,to:r,text:s}:null}return null}function Xd(t,e){const n=Array.isArray(e)?[...e]:[];n.sort((i,s)=>(s.start||0)-(i.start||0));let r=t;for(const i of n){const s=Number(i.start),o=Number(i.end);if(!Number.isInteger(s)||!Number.isInteger(o)||o<s)continue;const l=String(i.original??""),a=String(i.replacement??"");r.slice(s,o)===l&&(r=r.slice(0,s)+a+r.slice(o))}return r}function iM(t,e){var n;if(t.kind==="source"){const r=m.body||"";m.body=r.slice(0,t.start)+e+r.slice(t.end);const i=ve("#body-source");if(i){i.value=m.body;const s=t.start+e.length;i.focus(),i.setSelectionRange(s,s)}Fe(),pn();return}t.kind==="visual"&&((n=m.bodyEditor)!=null&&n.editor)&&(m.bodyEditor.editor.chain().focus().insertContentAt({from:t.from,to:t.to},e).run(),cn(),Fe(),pn())}function sM(){var n;const t=m.aiProofSelection||dg();if(m.aiProofSelection=null,t)return t;cn();const e=m.body||"";if(!String(e).trim())return null;if(m.bodyMode==="source")return{kind:"source",start:0,end:e.length,text:e,wholeBody:!0};if(m.bodyMode==="visual"&&((n=m.bodyEditor)!=null&&n.editor)){const r=m.bodyEditor.editor,i=0,s=r.state.doc.content.size;return{kind:"visual",from:i,to:s,text:e,wholeBody:!0}}return null}async function oM(t){var l,a;if(Zr(),rs(""),!mc()){rs("Set language in front matter before AI Proof."),xa();return}const e=sM();if(!e){rs("Body is empty.");return}cn();const n=String(m.fields.language||"").trim(),r=m.body||"";let i=null;t==="refine"&&e.kind==="source"&&!e.wholeBody&&(i={before:r.slice(Math.max(0,e.start-2e3),e.start),after:r.slice(e.end,Math.min(r.length,e.end+2e3))});const s=e.kind==="source"?{start:e.start,end:e.end}:{start:0,end:e.text.length},o=e.wholeBody?"body":"selection";m.aiProofBusy=!0,m.status=t==="refine"?`Refining ${o}…`:`Correcting ${o}…`,ka();try{const c=await kt.rewrite({mode:t,path:m.file,language:n,text:e.text,selection:s,context:i}),u=Array.isArray(c.patches)?c.patches:[],d=c.stats||{};if(!u.length){Number(d.proposed)>0?m.status=`No safe changes to apply (${d.proposed} proposed, all dropped).`:m.status=`No changes proposed for the ${o}.`;return}let p;if(e.kind==="visual"&&e.wholeBody){if(p=Xd(r,u),p===r){m.status=`No changes proposed for the ${o}.`;return}m.body=p,(a=(l=m.bodyEditor)==null?void 0:l.setMarkdown)==null||a.call(l,p),Fe(),pn()}else{if(p=Xd(e.text,u),p===e.text){m.status=`No changes proposed for the ${o}.`;return}iM(e,p)}const h=Number(d.dropped)>0?`, ${d.dropped} dropped`:"";m.status=t==="refine"?`Refined ${o} (${u.length}${h}).`:`Corrected ${o} (${u.length}${h}).`}catch(c){zn(c);const u=m.error;m.error=u?`AI Proof failed. ${u}`:"AI Proof failed."}finally{m.aiProofBusy=!1,ka(),xa()}}function xa(){const t=document.querySelector("[data-studio-action='save']"),e=document.querySelector("[data-studio-action='discard']");t&&(t.disabled=m.saving||!m.file||!m.dirty,t.textContent=m.saving?"Saving…":m.dirty?"Save":"Saved",t.title=m.saving?"Saving this draft":m.dirty?"Commit this draft":"No edits to commit yet"),e&&(e.disabled=!m.file||!m.dirty||!m.baseline),ka()}function Nt(){const t=ve("#studio-body");if(!t)return;t.innerHTML="";const e=m.file&&!fr()?` view-${m.bodyMode}`:"";if(t.className="studio-body"+(m.file?"":" list-only")+e,m.fileLoading){t.append(k("div",{className:"pane"},[k("p",{className:"loading-msg",text:"Loading content…"})]));return}if(!m.collection){if(m.mediaOpen){t.append(Ev(rg()));return}t.append(hM());return}if(!m.file){t.append(mM());return}if(fr()){t.append(pM(),tf()),pn();return}t.append(vM(),tf()),DM(),pn()}function fr(t=m.collection){return(t==null?void 0:t.format)==="yaml"}function lM(){const t=m.collection,e=mr(t);try{if(e==="list")m.body=Bt(m.yamlList||[]);else if(e==="map")if(t.root_key){const n=m.yamlDoc&&typeof m.yamlDoc=="object"?{...m.yamlDoc}:{};n[t.root_key]=dr({...m.fields},t.fields),m.body=Bt(n)}else m.body=Bt(dr({...m.fields},t.fields))}catch(n){zn(n)}}function aM(){const t=m.collection,e=mr(t);zt();try{const n=Xr(m.body);if(e==="list")m.yamlList=Vm(n),m.fields={};else if(e==="map"){if(t.root_key){const r=nr(n);m.yamlDoc=r,m.fields=nr(r[t.root_key])}else m.yamlDoc=null,m.fields=nr(n);m.yamlList=null}return!0}catch(n){return zn(n),m.status="Invalid YAML — fix source before switching",!1}}function Zd(t){if(t===m.yamlUiMode)return;if(t==="source"){lM(),m.yamlUiMode="source",oe();return}const e=ve("#yaml-source");if(e&&(m.body=e.value),!aM()){oe();return}m.yamlUiMode="structured",oe()}function cM(t){const e=m.yamlUiMode==="structured"&&t!=="source";return t==="list"||t==="map"?k("div",{className:"editor-chrome yaml-chrome"},[k("div",{className:"editor-mode-tabs",role:"tablist","aria-label":"YAML editor mode"},[k("button",{className:"editor-mode-tab",type:"button",role:"tab",text:"Fields",title:"Structured field editors","aria-selected":e?"true":"false",onClick:()=>Zd("structured")}),k("button",{className:"editor-mode-tab",type:"button",role:"tab",text:"YAML",title:"Raw YAML source","aria-selected":e?"false":"true",onClick:()=>Zd("source")})]),k("p",{className:"yaml-chrome-hint",text:t==="list"?"List of entries in one YAML file. Reorder, add, or remove items.":"Structured YAML fields — not a Markdown article body."})]):k("div",{className:"editor-chrome yaml-chrome"},[k("p",{className:"yaml-chrome-hint",text:"Free-form YAML — edit the source directly."})])}function uM(){const t=m.collection,e=Mo(t),n=Array.isArray(m.yamlList)?m.yamlList:[],r=k("div",{className:"yaml-list",id:"yaml-list"});return n.forEach((i,s)=>{(!i||typeof i!="object"||Array.isArray(i))&&(n[s]={});const o=n[s],l=k("div",{className:"yaml-list-item"}),a=e[0],c=a?o[a.name]||`${t.label} ${s+1}`:`${t.label} ${s+1}`;l.append(k("div",{className:"yaml-list-item-head"},[k("span",{className:"yaml-list-item-index",text:String(c)}),k("div",{className:"yaml-list-item-actions"},[k("button",{className:"btn yaml-list-btn",type:"button",text:"↑",title:"Move up",disabled:s===0,onClick:()=>{if(s===0)return;const d=[...n];[d[s-1],d[s]]=[d[s],d[s-1]],m.yamlList=d,Fe(),oe()}}),k("button",{className:"btn yaml-list-btn",type:"button",text:"↓",title:"Move down",disabled:s===n.length-1,onClick:()=>{if(s>=n.length-1)return;const d=[...n];[d[s],d[s+1]]=[d[s+1],d[s]],m.yamlList=d,Fe(),oe()}}),k("button",{className:"btn yaml-list-btn",type:"button",text:"Remove",onClick:()=>{m.yamlList=n.filter((d,p)=>p!==s),Fe(),oe()}})])]));const u=k("div",{className:"form-grid yaml-list-item-fields"});for(const d of e)u.append(To(d,{target:o,idPrefix:`yml-${s}-`,onChange:()=>{Fe()}}));l.append(u),r.append(l)}),r.append(k("button",{className:"btn btn-primary",type:"button",text:"Add item",onClick:()=>{m.yamlList=[...m.yamlList||[],jm(e)],Fe(),oe()}})),n.length||r.prepend(k("p",{className:"yaml-empty",text:"No items yet. Add one to start this list."})),r}function dM(){const t=k("div",{className:"form-grid",id:"yaml-form"});for(const e of Mo(m.collection))t.append(To(e));return t}function fM(){return k("div",{className:"field yaml-source-stack"},[k("label",{className:"field-heading",text:"YAML source"}),k("textarea",{id:"yaml-source",className:"yaml-source editor-surface",text:m.body,"aria-label":"YAML source",spellcheck:"false",onInput:t=>{m.body=t.target.value,Fe(),pn()}})])}function pM(){const t=m.collection,e=mr(t)||"source",n=m.yamlUiMode==="structured"&&(e==="list"||e==="map"),r=t.type==="file"?"Map":"List",i=k("div",{className:"yaml-editor-body"});return n&&e==="list"?i.append(uM()):n&&e==="map"?i.append(dM()):i.append(fM()),k("div",{className:"pane pane-editor pane-yaml"},[k("button",{className:"btn btn-nav",type:"button",title:`Back to ${r}`,onClick:()=>{if(Ht(),t.type==="file"){hc();return}m.file=null,m.baseline=null,m.dirty=!1,m.insertMenuOpen=!1,oe()}},[Qe("chevron_left","btn-nav-icon"),k("span",{text:r})]),k("header",{className:"yaml-editor-header"},[k("h1",{className:"yaml-editor-title",text:t.label}),k("p",{className:"yaml-editor-path",text:Mi(m.file||t.path)})]),cM(e),i])}function hM(){const t=ug(m.schema),e=[];for(const[s,o]of t){const l=o.map(a=>k("button",{className:"studio-map-card",type:"button",title:tg(a),onClick:()=>{m.navOpenGroups.add(s),mg(a)}},[Qe(a.type==="file"?"draft":ya[s]||"folder_open","studio-map-card-icon"),k("span",{className:"studio-map-card-body"},[k("span",{className:"studio-map-card-title",text:a.label}),k("span",{className:"studio-map-card-meta",text:Mi(a.path)||a.name})])]));e.push(k("section",{className:"studio-map-group"},[k("div",{className:"studio-map-group-head"},[Qe(ya[s]||"folder","studio-map-group-icon"),k("h2",{className:"studio-map-group-label",text:s})]),k("div",{className:"studio-map-grid"},l)])),(s==="Portfolio"||s==="References"&&!t.has("Portfolio"))&&e.push(Qd())}!t.has("Portfolio")&&!t.has("References")&&e.push(Qd());const n=Math.ceil(e.length/2),r=e.slice(0,n),i=e.slice(n);return k("div",{className:"pane studio-map"},[k("span",{className:"studio-shard studio-shard--lead","aria-hidden":"true"}),k("span",{className:"studio-shard studio-shard--beta studio-shard--trail","aria-hidden":"true"}),k("header",{className:"studio-map-header"},[k("p",{className:"studio-map-kicker",text:"Studio"}),k("h1",{text:"Studio map"}),k("p",{className:"studio-map-lede",text:"Pick a collection, page, or the media library. Groups match the left navigation."})]),k("div",{className:"studio-map-board",role:"navigation","aria-label":"Collections map"},[k("div",{className:"studio-map-col"},r),i.length?k("div",{className:"studio-map-col"},i):null])])}function Qd(){return k("section",{className:"studio-map-group"},[k("div",{className:"studio-map-group-head"},[Qe(ya.Media,"studio-map-group-icon"),k("h2",{className:"studio-map-group-label",text:"Media"})]),k("div",{className:"studio-map-grid"},[k("button",{className:"studio-map-card",type:"button",title:"Browse and upload under content/media",onClick:()=>ig()},[Qe("photo_library","studio-map-card-icon"),k("span",{className:"studio-map-card-body"},[k("span",{className:"studio-map-card-title",text:"Library"}),k("span",{className:"studio-map-card-meta",text:Mi("content/media")})])])])])}function mM(){const t=jv(),e=Vv(),n=qv(),r=Kv(),i=FM(),s=lv(m.items,{query:t,sortId:e,tag:i?r:""}),o=av(s,{pageSizeId:n,page:Wd()});o.page!==Wd()&&Al(o.page);const l=o.items,a=CM(m.collection,{entryCount:m.listLoading?null:m.items.length});if(m.listLoading)return k("div",{className:"pane"},[a,k("p",{className:"loading-msg",text:"Loading content…"})]);if(m.error&&!m.items.length)return k("div",{className:"pane"},[a,k("div",{className:"list-error"},[k("p",{className:"list-error-title",text:"Could not load entries."}),k("p",{className:"list-error-message",text:m.error}),m.errorDetail?k("pre",{className:"list-error-detail",text:m.errorDetail}):null])]);const c=l.map(O=>kM(O,i)),u=k("input",{className:"list-search-input",type:"search",value:t,placeholder:"Search title, key, path…","aria-label":"Search entries",title:"Filter this list by title, key, filename, or path",onInput:O=>{var H;const Y=(H=m.collection)==null?void 0:H.name;if(!Y)return;m.listQueryByCollection[Y]=O.target.value,vo(),Nt();const ee=ve("#list-search-input");if(ee){ee.focus();const Q=ee.value.length;ee.setSelectionRange(Q,Q)}}});u.id="list-search-input";const d=k("select",{className:"list-sort-select","aria-label":"Sort entries",title:"Sort entries in this collection",onChange:O=>{Uv(O.target.value),Nt()}});for(const O of Zs)d.append(k("option",{value:O.id,text:O.label,selected:O.id===e}));const p=k("select",{className:"list-page-size-select","aria-label":"Entries per page",title:"How many entries to show per page",onChange:O=>{Wv(O.target.value),Nt()}});for(const O of eo)p.append(k("option",{value:O.id,text:O.label,selected:O.id===n}));const h=k("div",{className:"list-controls"},[u,k("label",{className:"list-sort-label"},[k("span",{className:"list-sort-caption",text:"Sort"}),d]),k("label",{className:"list-sort-label"},[k("span",{className:"list-sort-caption",text:"Show"}),p])]),g=i?gM(m.items,r):null;let b=null;s.length||(m.error?b=k("div",{className:"list-error"},[k("p",{className:"list-error-title",text:"Could not load entries."}),k("p",{className:"list-error-message",text:m.error}),m.errorDetail?k("pre",{className:"list-error-detail",text:m.errorDetail}):null]):m.items.length===0?b=k("p",{className:"list-empty",text:"No entries in this collection."}):b=k("p",{className:"list-empty",text:r?"No entries match this tag filter.":"No entries match this search."}));const w=o.pageSize!=null&&o.pageCount>1&&s.length>0?k("div",{className:"list-pager",role:"navigation","aria-label":"List pages"},[k("button",{className:"btn list-pager-btn",type:"button",text:"Prev",title:"Previous page",disabled:o.page<=1,onClick:()=>{o.page<=1||(Al(o.page-1),Nt())}}),k("span",{className:"list-pager-status",text:`Page ${o.page} of ${o.pageCount}`}),k("button",{className:"btn list-pager-btn",type:"button",text:"Next",title:"Next page",disabled:o.page>=o.pageCount,onClick:()=>{o.page>=o.pageCount||(Al(o.page+1),Nt())}})]):null;let A="";if(m.items.length>0){const O=t||r;if(!s.length)A=O?`0 of ${m.items.length}`:"";else if(o.pageSize==null)A=O?`${s.length} of ${m.items.length}`:"";else{const Y=`${o.from}–${o.to} of ${s.length}`;A=O?`${Y} (filtered from ${m.items.length})`:Y}}const R=i?k("div",{className:"ledger-columns","aria-hidden":"true"},[k("span",{className:"ledger-col-thumb"}),k("span",{className:"ledger-col-manuscript",text:"Manuscript"}),k("span",{className:"ledger-col-taxonomy",text:"Taxonomy"}),k("span",{className:"ledger-col-ops",text:"Operations"})]):null;return k("div",{className:"pane"},[a,h,g,A?k("p",{className:"list-count",text:A}):null,R,k("div",{className:"ledger-list"},c.length?c:[b]),w])}function gM(t,e){const n=ov(t);if(!n.length)return null;const r=[k("button",{className:"list-tag-chip"+(e?"":" is-active"),type:"button",text:`All (${t.length})`,"aria-pressed":e?"false":"true",onClick:()=>{Kd(""),Nt()}})];for(const i of n){const s=t.filter(l=>Ci(l).some(a=>a.toLowerCase()===i.toLowerCase())).length;if(!s)continue;const o=e.toLowerCase()===i.toLowerCase();r.push(k("button",{className:"list-tag-chip"+(o?" is-active":""),type:"button",text:`${i} (${s})`,"aria-pressed":o?"true":"false",onClick:()=>{Kd(o?"":i),Nt()}}))}return k("div",{className:"list-tag-filters",role:"group","aria-label":"Filter by tag"},r)}function yM(t){const e=String((t==null?void 0:t.language)||"").trim();return e?k("span",{className:"ledger-lang",text:e.toUpperCase(),title:`Language: ${e}`}):null}function bM(t){const e=Ci(t);return e.length?k("div",{className:"ledger-taxonomy"},e.map(n=>k("span",{className:"ledger-tag",text:n}))):null}function kM(t,e){const n=yv(t,m.collection),r=()=>gc(t.path);if(!e){const a=k("div",{className:"ledger-copy"},[k("div",{className:"ledger-title",text:t.title||t.name}),n?k("div",{className:"ledger-meta",text:n}):null]);return k("button",{className:"ledger-row",type:"button",title:qd(t),onClick:r},[Gd(t),a])}const i=k("div",{className:"ledger-title-row"},[hg(t),k("div",{className:"ledger-title",text:t.title||t.name})]),s=k("div",{className:"ledger-copy"},[i,n?k("div",{className:"ledger-meta",text:n}):null]),o=bM(t)||k("div",{className:"ledger-taxonomy"}),l=k("div",{className:"ledger-ops","aria-hidden":"true"},[k("span",{className:"ledger-ops-edit",text:"Edit"}),Qe("chevron_right","ledger-ops-icon")]);return k("div",{className:"ledger-row ledger-row--writing",role:"button",tabindex:"0",title:qd(t),onClick:r,onKeydown:a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),r())}},[Gd(t),s,o,l])}function Mo(t){return(t.fields||[]).filter(e=>!e.hidden&&!Sf(e)&&e.name!=="layout")}function xM(t){const e=(t.fields||[]).filter(n=>Sf(n));return e.length?e:t.format==="raw"&&!t.root_key?[{name:"body",label:"Content",component:"markdown_body"}]:[]}function ef(t,e){return((t==null?void 0:t.fields)||[]).some(n=>n.name===e)}function SM(t){return t==null?!1:Array.isArray(t)?t.length>0:typeof t=="boolean"?!0:String(t).trim()!==""}function wM(){var t;if(m.frontMatterOpen!=null)return!!m.frontMatterOpen;if(m.dirty)return!0;for(const e of Mo(m.collection))if(e.required&&!SM((t=m.fields)==null?void 0:t[e.name]))return!0;return!1}function CM(t,{entryCount:e=null}={}){const n=(t==null?void 0:t.group)||"Content",r=(t==null?void 0:t.label)||(t==null?void 0:t.name)||"Index",i=[k("h1",{className:"list-pane-title",text:r})];return e!=null&&e>=0&&i.push(k("span",{className:"list-pane-count",text:e===1?"1 entry":`${e} entries`})),k("header",{className:"list-register"},[k("p",{className:"list-register-kicker"},[k("span",{className:"list-register-mark","aria-hidden":"true"}),k("span",{text:`Register // ${n}`}),k("span",{className:"list-register-sep","aria-hidden":"true",text:"/"}),k("span",{text:`${r} index`})]),k("div",{className:"list-register-title-row"},i)])}function vM(){const t=Mo(m.collection),e=xM(m.collection),n=k("div",{className:"form-grid",id:"meta-form"});for(const a of t)n.append(To(a));const r=wM(),i=t.length>0?k("details",{className:"front-matter",open:r,onToggle:a=>{m.frontMatterOpen=!!a.target.open}},[k("summary",{className:"front-matter-summary"},[k("span",{className:"front-matter-summary-label",text:"Front-matter"}),k("span",{className:"front-matter-summary-hint",text:r?"Collapse":"Expand"})]),n]):null,s=k("div",{className:"field body-editor-stack",id:"body-wrap"});if(e.length){const a=e[0],c=m.bodyMode,d=c==="visual"||c==="preview",p=c==="source",h=k("div",{id:"tiptap-host",className:"tiptap editor-surface"});d||(h.hidden=!0);const g=k("textarea",{id:"body-source",className:"body-source editor-surface",text:m.body,"aria-label":"Markdown source",onInput:b=>{m.body=b.target.value,Fe(),pn()}});if(p||(g.hidden=!0),s.append(k("label",{text:a.label||"Body"}),AM(c),k("div",{className:"editor-pane-fill"},[h,g])),e.length>1)for(const b of e.slice(1))s.append(k("label",{text:b.label||b.name,style:"margin-top:1rem"}),k("textarea",{"data-extra-body":b.name,text:m.fields[b.name]||"",onInput:x=>{m.fields[b.name]=x.target.value,Fe()}}))}const o=e.length>0?MM(m.body):null,l=[];if(ef(m.collection,"published")&&l.push(hg(m.fields)),!ef(m.collection,"language")){const a=yM(m.fields);a&&l.push(a)}return k("div",{className:"pane pane-editor"},[k("div",{className:"editor-mast"},[k("div",{className:"editor-mast-lead"},[k("button",{className:"btn btn-back",type:"button",title:"Back to collection list","aria-label":"Back to collection list",onClick:()=>{Ht(),m.file=null,m.baseline=null,m.dirty=!1,m.insertMenuOpen=!1,m.frontMatterOpen=null,oe()}},[Qe("chevron_left","btn-nav-icon")]),l.length?k("div",{className:"editor-mast-pills"},l):null])]),i,s,o])}function fg(t){const e=String(t||""),n=e.length,r=e.trim(),i=r?r.split(/\s+/).filter(Boolean).length:0,s=r?r.split(/\n\s*\n/).filter(o=>o.trim()).length:0;return{chars:n,words:i,paras:s}}function MM(t){const{chars:e,words:n,paras:r}=fg(t);return k("div",{className:"editor-body-stats",id:"editor-body-stats"},[k("span",{text:`Chars: ${e}`}),k("span",{className:"editor-body-stats-sep","aria-hidden":"true",text:"·"}),k("span",{text:`Words: ${n}`}),k("span",{className:"editor-body-stats-sep","aria-hidden":"true",text:"·"}),k("span",{text:`Paras: ${r}`})])}function TM(){const t=ve("#editor-body-stats");if(!t)return;const{chars:e,words:n,paras:r}=fg(m.body);t.replaceChildren(k("span",{text:`Chars: ${e}`}),k("span",{className:"editor-body-stats-sep","aria-hidden":"true",text:"·"}),k("span",{text:`Words: ${n}`}),k("span",{className:"editor-body-stats-sep","aria-hidden":"true",text:"·"}),k("span",{text:`Paras: ${r}`}))}function AM(t){const e=t==="visual",n=t==="source",r=t==="preview",i=k("div",{className:"editor-mode-tabs",role:"tablist","aria-label":"Editor mode"},[k("button",{className:"editor-mode-tab",type:"button",role:"tab",text:"Visual",title:"Rich text with Liquid blocks","aria-selected":e?"true":"false",onClick:()=>{e||(cn(),m.bodyMode="visual",m.lastEditorMode="visual",Zr(),oe())}}),k("button",{className:"editor-mode-tab",type:"button",role:"tab",text:"Source",title:"Edit raw Markdown source","aria-selected":n?"true":"false",onClick:()=>{n||(cn(),m.bodyMode="source",m.lastEditorMode="source",Zr(),oe())}}),k("button",{className:"editor-mode-tab editor-mode-tab--preview",type:"button",role:"tab",text:"Preview",title:"Rendered side preview (small screens)","aria-selected":r?"true":"false",onClick:()=>{r||(cn(),(m.bodyMode==="visual"||m.bodyMode==="source")&&(m.lastEditorMode=m.bodyMode),m.bodyMode="preview",Zr(),oe())}})]),s=k("div",{className:"editor-chrome-row"},[i,k("div",{className:"editor-chrome-actions"},[e||n?OM():null,e?NM():null])]);return k("div",{className:"editor-chrome"},[s,k("p",{id:"ai-proof-hint",className:"ai-proof-hint",text:m.aiProofHint||"",hidden:!m.aiProofHint,"aria-live":"polite"}),e?LM():null])}function EM(t){const e={};if(t.name==="figure")e.src=prompt("Image URL (HTTPS or /media/…)")||"",e.caption=prompt("Caption")||"";else if(t.name==="youtube")e.id=prompt("YouTube id")||"";else if(t.name==="xcite"||t.name==="cite")e.key=prompt("Key")||"";else for(const n of t.fields){const r=prompt(n);r&&(e[n]=r)}return e}function NM(){const t=k("div",{className:"editor-insert-menu",id:"insert-menu",role:"menu"});m.insertMenuOpen||(t.hidden=!0);for(const e of ur.filter(n=>!n.blockBody))t.append(k("button",{className:"editor-insert-item",type:"button",role:"menuitem",title:e.label,onClick:()=>{const n=EM(e);Zr(),m.bodyEditor?m.bodyEditor.insertInclude(e.name,n):Nt()}},[Qe(_v[e.name]||"add","editor-insert-icon"),k("span",{text:e.label})]));return k("div",{className:"editor-insert"},[k("button",{className:"btn editor-insert-btn",type:"button","aria-haspopup":"menu","aria-expanded":m.insertMenuOpen?"true":"false",title:"Insert a Liquid include block",onClick:e=>{e.stopPropagation();const n=!m.insertMenuOpen;m.insertMenuOpen=n;const r=ve("#insert-menu"),i=e.currentTarget;r&&(r.hidden=!n),i.setAttribute("aria-expanded",n?"true":"false")}},[Qe("add"),k("span",{text:"Insert"}),Qe("expand_more","editor-insert-caret")]),t])}function OM(){return k("div",{className:"editor-ai-proof"},[{action:"correct",label:"Correct",icon:"check",title:"Spelling, grammar, idiom, and punctuation (selection or full body)"},{action:"refine",label:"Refine",icon:"edit",title:"Clarity and flow (selection or full body), using writing guidelines"}].map(e=>k("button",{className:"btn editor-insert-btn",type:"button",title:e.title,"data-studio-action":e.action,disabled:!mc()||m.aiProofBusy,onMouseDown:n=>{n.preventDefault(),m.aiProofSelection=dg()},onClick:()=>{rs(""),oM(e.action)}},[Qe(e.icon),k("span",{className:"editor-ai-proof-label",text:m.aiProofBusy?"Working…":e.label})])))}function ft(){var t,e;return(e=(t=m.bodyEditor)==null?void 0:t.editor)==null?void 0:e.chain().focus()}function nt(t){return k("button",{className:"editor-toolbar-btn",type:"button",title:t.title,"aria-label":t.title,onClick:t.onClick},[t.icon?Qe(t.icon):null,t.text?k("span",{text:t.text}):null])}function El(){return k("span",{className:"editor-toolbar-sep","aria-hidden":"true"})}function LM(){const t=k("select",{className:"editor-toolbar-select",title:"Text color","aria-label":"Text color",onChange:e=>{const n=ft();if(!n)return;const r=e.target.value;r?n.setColor(r).run():n.unsetColor().run()}});for(const e of zv)t.append(k("option",{value:e.value,text:e.label}));return k("div",{className:"editor-format-toolbar",role:"toolbar","aria-label":"Formatting"},[nt({title:"Paragraph",icon:"notes",onClick:()=>{var e;return(e=ft())==null?void 0:e.setParagraph().run()}}),nt({title:"Heading 1",text:"H1",onClick:()=>{var e;return(e=ft())==null?void 0:e.toggleHeading({level:1}).run()}}),nt({title:"Heading 2",text:"H2",onClick:()=>{var e;return(e=ft())==null?void 0:e.toggleHeading({level:2}).run()}}),nt({title:"Heading 3",text:"H3",onClick:()=>{var e;return(e=ft())==null?void 0:e.toggleHeading({level:3}).run()}}),nt({title:"Heading 4",text:"H4",onClick:()=>{var e;return(e=ft())==null?void 0:e.toggleHeading({level:4}).run()}}),nt({title:"Blockquote",icon:"format_quote",onClick:()=>{var e;return(e=ft())==null?void 0:e.toggleBlockquote().run()}}),El(),nt({title:"Bold",icon:"format_bold",onClick:()=>{var e;return(e=ft())==null?void 0:e.toggleBold().run()}}),nt({title:"Italic",icon:"format_italic",onClick:()=>{var e;return(e=ft())==null?void 0:e.toggleItalic().run()}}),nt({title:"Strikethrough",icon:"format_strikethrough",onClick:()=>{var e;return(e=ft())==null?void 0:e.toggleStrike().run()}}),El(),t,El(),nt({title:"Lowercase",text:"aa",onClick:()=>{var e;return(e=m.bodyEditor)==null?void 0:e.transformSelectionCase("lower")}}),nt({title:"Uppercase",text:"AA",onClick:()=>{var e;return(e=m.bodyEditor)==null?void 0:e.transformSelectionCase("upper")}}),nt({title:"Title case",text:"Aa",onClick:()=>{var e;return(e=m.bodyEditor)==null?void 0:e.transformSelectionCase("title")}})])}function IM(t,e){return t===!0||t==="true"?!0:t===!1||t==="false"?!1:e===!0||e==="true"}function To(t,e={}){var a;const n=t.name,r=e.target||m.fields,i=e.onChange||(()=>{Fe()}),s=r[n]??t.default??"",o=k("div",{className:"field"+(n==="title"?" field--title":"")}),l=`field-${e.idPrefix||""}${n}`;if(o.append(k("label",{className:"field-heading",text:t.label||n,htmlFor:l})),t.type==="boolean"){const c=Object.prototype.hasOwnProperty.call(r,n)?r[n]:t.default,u=IM(c,t.default),d=k("input",{id:l,type:"checkbox",className:"field-checkbox",checked:u,onChange:h=>{r[n]=!!h.target.checked,i()}}),p=Ud(t);return o.classList.add("field--boolean"),o.append(k("label",{className:"field-check-row",htmlFor:l},[d,k("span",{className:"field-check-text",text:p||"On"})])),o}if(t.type==="select"&&((a=t.options)!=null&&a.values)){const c=!!t.options.multiple,u=k("select",{id:l,multiple:c,onChange:d=>{c?r[n]=[...d.target.selectedOptions].map(p=>p.value):r[n]=d.target.value,i()}});for(const d of t.options.values){const p=typeof d=="object"?d.value:d,h=c?String(s).includes(p)||Array.isArray(s)&&s.includes(p):String(s)===String(p);u.append(k("option",{value:p,text:p,selected:h}))}o.append(u)}else if(t.type==="object"&&t.list)Array.isArray(r[n])||(r[n]=Array.isArray(s)?s:[]),o.append(RM(t,r[n],{onChange:c=>{r[n]=c,Fe(),oe()},idPrefix:`${e.idPrefix||""}${n}-`}));else if(t.list&&(t.type==="string"||!t.type)){const c=Array.isArray(s)?s.join(`
274
+ `):String(s||"");o.append(k("textarea",{id:l,text:c,placeholder:"One item per line",onInput:u=>{r[n]=u.target.value.split(`
275
+ `).map(d=>d.trim()).filter(Boolean),i()}}))}else t.type==="text"||t.type==="image"?o.append(k(t.type==="text"?"textarea":"input",{id:l,type:t.type==="image"?"url":void 0,value:s,text:t.type==="text"?s:void 0,placeholder:t.type==="image"?"https://… or /media/images/…":void 0,onInput:c=>{r[n]=c.target.value,i()}})):o.append(k("input",{id:l,type:t.type==="number"?"number":t.type==="date"?"date":"text",value:s,onInput:c=>{r[n]=c.target.value,i()}}));if(t.description){const c=Ud(t);c&&o.append(k("p",{className:"hint",text:c}))}return o}function RM(t,e,{onChange:n,idPrefix:r}){const i=Array.isArray(e)?e:[],s=k("div",{className:"yaml-object-list"}),o=l=>{n(l,{structural:!0})};return i.forEach((l,a)=>{(!l||typeof l!="object"||Array.isArray(l))&&(i[a]={});const c=i[a],u=k("div",{className:"yaml-list-item"});u.append(k("div",{className:"yaml-list-item-head"},[k("span",{className:"yaml-list-item-index",text:`${t.label||t.name} ${a+1}`}),k("div",{className:"yaml-list-item-actions"},[k("button",{className:"btn yaml-list-btn",type:"button",text:"↑",title:"Move up",disabled:a===0,onClick:()=>{if(a===0)return;const p=[...i];[p[a-1],p[a]]=[p[a],p[a-1]],o(p)}}),k("button",{className:"btn yaml-list-btn",type:"button",text:"↓",title:"Move down",disabled:a===i.length-1,onClick:()=>{if(a>=i.length-1)return;const p=[...i];[p[a],p[a+1]]=[p[a+1],p[a]],o(p)}}),k("button",{className:"btn yaml-list-btn",type:"button",text:"Remove",onClick:()=>{o(i.filter((p,h)=>h!==a))}})])]));const d=k("div",{className:"form-grid yaml-list-item-fields"});for(const p of t.fields||[])p.hidden||d.append(To(p,{target:c,idPrefix:`${r}${a}-`,onChange:()=>{Fe()}}));u.append(d),s.append(u)}),s.append(k("button",{className:"btn",type:"button",text:`Add ${t.label||"item"}`,onClick:()=>{o([...i,jm(t.fields||[])])}})),s}function tf(){const t=typeof window<"u"&&window.innerWidth?`${Math.round(window.innerWidth)}px`:"",e=[k("span",{className:"preview-pane-label",text:"Preview"})];return t&&e.push(k("span",{className:"preview-pane-sep","aria-hidden":"true",text:"·"}),k("span",{className:"preview-pane-meta",text:`Viewport ${t}`})),k("div",{className:"pane pane-preview"},[k("div",{className:"preview-pane-head"},e),k("div",{className:"preview-folio"},[k("div",{className:"preview-frame",id:"preview-frame",html:m.previewHtml})])])}function DM(){const t=ve("#tiptap-host");if(!t)return;if(Ht(),m.bodyMode==="source"){t.hidden=!0;return}t.hidden=!1;const e=(m.bodyMode==="preview"&&m.lastEditorMode==="source",m.body);m.bodyEditor=eC(t,{content:e,onUpdate:n=>{m.body=n,Fe(),pn()}})}function cn(){var r;let t=null;m.bodyEditor&&m.bodyMode!=="source"&&(t=m.bodyEditor.getMarkdown());const e=ve("#body-source");if(e&&m.bodyMode==="source"&&(t=e.value),t==null)return;const n=(r=m.baseline)==null?void 0:r.body;if(typeof n=="string"&&t===Zw(n)){m.body=n;return}m.body=t}function Ht(){m.bodyEditor&&(m.bodyEditor.destroy(),m.bodyEditor=null)}const Nr=new Map,Kn=new Map,PM=1e3;async function $M(t,e){const n=String(e||"").trim();if(!n)return!1;try{const r=t==="xcite"?await kt.searchXcite(n):await kt.searchCite(n),i=(r==null?void 0:r.results)||[],s=n.toLowerCase();return i.some(o=>String(o.key||"").trim().toLowerCase()===s)}catch{return!1}}function Ji(t,e){t.classList.remove("studio-ref-pill--ok","studio-ref-pill--missing"),e==="ok"?t.classList.add("studio-ref-pill--ok"):e==="missing"&&t.classList.add("studio-ref-pill--missing")}function BM(t){if(!t)return;const e=new Set,n=new Map;for(const r of t.querySelectorAll("[data-cite-check]")){const i=r.getAttribute("data-cite-check")||"cite",s=String(r.getAttribute("data-key")||"").trim(),o=`${i}:${s}`;if(e.add(o),n.has(o)||n.set(o,[]),n.get(o).push(r),!s){Ji(r,"missing");continue}const l=Kn.get(o);l==="ok"||l==="missing"?Ji(r,l):Ji(r,null)}for(const r of[...Kn.keys()])if(!e.has(r)){Kn.delete(r);const i=Nr.get(r);i&&clearTimeout(i),Nr.delete(r)}for(const[r,i]of n){const s=r.slice(r.indexOf(":")+1),o=r.startsWith("xcite:")?"xcite":"cite";s&&(Kn.get(r)==="ok"||Kn.get(r)==="missing"||Nr.has(r)||Nr.set(r,setTimeout(async()=>{Nr.delete(r);const a=await $M(o,s)?"ok":"missing";Kn.set(r,a);const c=ve("#preview-frame");if(c)for(const u of c.querySelectorAll(`[data-cite-check="${o}"][data-key="${CSS.escape(s)}"]`))Ji(u,a)},PM)))}}function pn(){const t=ve("#preview-frame");if(fr()?m.previewHtml=_M():m.previewHtml=tv(m.body||""),t){const e=t.scrollTop,n=t.scrollLeft;t.innerHTML=m.previewHtml,t.scrollTop=e,t.scrollLeft=n,fr()||(BM(t),Promise.resolve(pg(t)).then(()=>{ve("#preview-frame")===t&&(t.scrollTop=e,t.scrollLeft=n)}))}}function nf(t){return String(t??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function _M(){const t=m.collection,e=mr(t);let n="";try{if(m.yamlUiMode==="source"||e==="source")n=m.body||"";else if(e==="list")n=Bt(m.yamlList||[]);else if(e==="map"&&t.root_key){const r=m.yamlDoc&&typeof m.yamlDoc=="object"?{...m.yamlDoc}:{};r[t.root_key]=dr({...m.fields},t.fields),n=Bt(r)}else e==="map"?n=Bt(dr({...m.fields},t.fields)):n=m.body||""}catch(r){return`<p class="yaml-preview-error">${nf(r.message||r)}</p>`}return`<pre class="yaml-preview-pre">${nf(n)}</pre>`}let Or=null;function zM(){return window.mermaid?Promise.resolve(window.mermaid):Or||(Or=Sg(()=>import("https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.esm.min.mjs"),[]).then(t=>{const e=t.default;return window.mermaid=e,e.initialize({startOnLoad:!1,theme:document.documentElement.getAttribute("data-theme")==="dark"?"dark":"default",securityLevel:"strict"}),e}).catch(t=>{throw Or=null,t}),Or)}function Nl(t,e){const n=t.dataset.mermaidSource||t.textContent||"";t.dataset.mermaidSource=n,t.className="studio-mermaid-fallback",t.removeAttribute("data-processed");const r=e?`Mermaid: ${e}
276
+
277
+ `:`Mermaid (unrendered)
278
+
279
+ `;t.innerHTML="";const i=document.createElement("pre");i.className="studio-mermaid-fallback__pre",i.textContent=r+n,t.append(i)}async function pg(t){if(!t)return;const e=[];if(t.querySelectorAll("pre code.language-mermaid").forEach(r=>{const i=r.textContent||"",s=document.createElement("div");s.className="mermaid studio-mermaid",s.dataset.mermaidSource=i,s.textContent=i;const o=r.closest("pre");o?o.replaceWith(s):r.replaceWith(s),e.push(s)}),t.querySelectorAll(".mermaid[data-mermaid-source], .studio-mermaid-fallback[data-mermaid-source]").forEach(r=>{e.includes(r)||e.push(r)}),!e.length)return;let n;try{n=await zM()}catch(r){for(const i of e)Nl(i,(r==null?void 0:r.message)||"failed to load Mermaid");return}n.initialize({startOnLoad:!1,theme:document.documentElement.getAttribute("data-theme")==="dark"?"dark":"default",securityLevel:"strict"});for(const r of e){const i=r.dataset.mermaidSource||"";r.className="mermaid studio-mermaid",r.removeAttribute("data-processed"),r.innerHTML="",r.textContent=i}try{await n.run({nodes:e})}catch(r){for(const i of e)i.querySelector("svg")||Nl(i,(r==null?void 0:r.message)||"render failed")}for(const r of e)r.classList.contains("studio-mermaid-fallback")||r.querySelector("svg")||Nl(r,"render produced no diagram")}function FM(t=m.collection){const e=t==null?void 0:t.name;return e==="articles"||e==="posts"}function HM(t){const e=t==null?void 0:t.published;return!(e===!1||e==="false")}function hg(t){const e=HM(t);return k("span",{className:"ledger-status "+(e?"ledger-status--published":"ledger-status--draft"),text:e?"Published":"Draft",title:e?"Published (exported)":"Draft (excluded from export)"})}async function mg(t){Ht(),m.mediaOpen=!1,m.mediaItems=[],m.collection=t,m.file=null,m.baseline=null,m.frontMatterOpen=null,m.items=[],m.insertMenuOpen=!1,pc(),zt(),m.listLoading=t.type!=="file",m.fileLoading=t.type==="file",m.status=`Loading ${t.label}…`,oe();try{if(t.type==="file"){await gc(t.path);return}const e=Yv(t);if(e){m.items=e,sg(t,e.length),m.listLoading=!1,m.status="",oe();return}const n=await kt.tree(t.path);m.items=n.items||[],og(t,m.items),m.listLoading=!1,m.status=""}catch(e){m.items=[],m.listLoading=!1,zn(e)}oe()}async function gc(t){Ht(),m.insertMenuOpen=!1,m.fileLoading=!0,m.file=null,m.baseline=null,m.frontMatterOpen=null,m.status=`Opening ${t}…`,zt(),m.yamlDoc=null,m.yamlList=null,oe();try{const e=await kt.getFile(t);m.file=t,m.sha=e.sha;const n=Cf(e.content),r=m.collection;if(r.format==="yaml"){m.body=e.content;const i=mr(r);if(i==="list"){const s=Xr(e.content);m.yamlList=Vm(s),m.fields={},m.yamlDoc=null,m.yamlUiMode="structured"}else if(i==="map"){if(r.root_key){const s=nr(Xr(e.content));m.yamlDoc=s,m.fields=nr(s[r.root_key])}else m.yamlDoc=null,m.fields=nr(Xr(e.content));m.yamlList=null,m.yamlUiMode="structured"}else m.fields={},m.yamlList=null,m.yamlUiMode="source"}else r.format==="raw"?(m.body=e.content,m.fields={}):(m.fields={...n.fm},m.body=n.body);m.dirty=!1,m.fileLoading=!1,m.listLoading=!1,m.status=t,gg()}catch(e){m.fileLoading=!1,m.listLoading=!1,m.baseline=null,zn(e)}oe()}function gg(){m.baseline={fields:structuredClone(m.fields||{}),body:m.body,yamlDoc:m.yamlDoc?structuredClone(m.yamlDoc):null,yamlList:m.yamlList?structuredClone(m.yamlList):null,yamlUiMode:m.yamlUiMode,sha:m.sha}}function jM(){if(!m.file||!m.baseline)return;const t=m.baseline;Ht(),m.fields=structuredClone(t.fields||{}),m.body=t.body,m.yamlDoc=t.yamlDoc?structuredClone(t.yamlDoc):null,m.yamlList=t.yamlList?structuredClone(t.yamlList):null,m.yamlUiMode=t.yamlUiMode||"structured",m.sha=t.sha,m.dirty=!1,m.insertMenuOpen=!1,m.bodyMode==="preview"||m.bodyMode!=="visual"&&m.bodyMode!=="source"&&(m.bodyMode=m.lastEditorMode||"visual"),zt(),m.status=`Reverted ${m.file}`,oe()}async function VM(){var t;if(!(!m.file||m.saving)){if(cn(),fr()){const e=ve("#yaml-source");e&&(m.body=e.value)}m.saving=!0,m.status="Saving…",zt(),oe();try{let e;const n=m.collection;if(n.format==="raw")e=m.body;else if(n.format==="yaml"){const i=mr(n);if(m.yamlUiMode==="source"||i==="source")Xr(m.body),e=m.body.endsWith(`
280
+ `)?m.body:m.body+`
281
+ `;else if(i==="list")e=Bt(m.yamlList||[]);else if(i==="map"&&n.root_key){const o=m.yamlDoc&&typeof m.yamlDoc=="object"?{...m.yamlDoc}:{};o[n.root_key]=dr({...m.fields},n.fields),e=Bt(o)}else i==="map"?e=Bt(dr({...m.fields},n.fields)):e=m.body.endsWith(`
282
+ `)?m.body:m.body+`
283
+ `}else{const i=(await kt.getFile(m.file)).content,s={...m.fields};e=Dg(i,{fields:s,body:m.body,format:n.format})}e.endsWith(`
284
+ `)||(e+=`
285
+ `);const r=await kt.putFile({path:m.file,content:e,sha:m.sha,message:`studio: update ${m.file}`});m.sha=((t=r.content)==null?void 0:t.sha)||m.sha,m.dirty=!1,zt(),m.status=`Saved ${m.file}`,gg(),n!=null&&n.name&&Gv(n.name)}catch(e){zn(e)}finally{m.saving=!1,oe()}}}async function is(t){var e,n;try{m.session=await kt.session()}catch(r){if((((e=r==null?void 0:r.data)==null?void 0:e.error)||"")==="not_allowlisted"){tM(t,((n=r==null?void 0:r.data)==null?void 0:n.email)||cg(t));return}m.error=`Session failed: ${r.message}`,di(t),m.error&&ot.append(k("p",{className:"status-pill error",text:m.error}));return}try{m.schema=await Eg()}catch(r){m.error=String(r.message||r),ot.innerHTML="",ot.append(k("p",{className:"auth-gate status-pill error",text:m.error}));return}oe(),lg(),t&&!t.dev&&t.addListener&&t.addListener(({user:r})=>{r||(Ht(),di(t))})}async function UM(){Qv();const t=await Bv();if(t.dev){await is(t);return}t.user?await is(t):(di(t),t.addListener(async({user:e})=>{e&&await is(t)}))}UM().catch(t=>{ot.textContent=String(t.stack||t)});