@panphora/clayjs 1.23.0 → 1.24.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.
- package/dist/all.js +1 -1
- package/dist/blockeditor/themes/light-1.css +431 -0
- package/dist/clay-dom.js +1 -1
- package/dist/clay-events.js +1 -1
- package/dist/clay-internals.js +1 -1
- package/dist/clay-options.js +1 -1
- package/dist/clay-router.js +1 -1
- package/dist/clay-ui.js +1 -1
- package/dist/clay-utils.js +1 -1
- package/dist/clay.js +1 -1
- package/dist/clay.standalone.js +30285 -26613
- package/dist/m/c-277QP5ET.js +1 -0
- package/dist/m/c-2BLVA6IN.js +5 -0
- package/dist/m/c-2OJMOUPC.js +1 -0
- package/dist/m/c-2PVGJFI5.js +1 -0
- package/dist/m/{c-AYVGD6A6.js → c-3UW5EJ77.js} +1 -1
- package/dist/m/{c-T5NK2TVY.js → c-42ZNV7LI.js} +1 -1
- package/dist/m/{c-3TLG3OLG.js → c-46LJAZZJ.js} +1 -1
- package/dist/m/c-47IBJGPQ.js +1 -0
- package/dist/m/c-5FXEKU4Y.js +1 -0
- package/dist/m/c-5KXDKC5G.js +1 -0
- package/dist/m/{c-EUGJVHDD.js → c-5RZNFTWD.js} +1 -1
- package/dist/m/c-65LJU2H2.js +72 -0
- package/dist/m/{c-NQJRVJ56.js → c-6IJEVE6B.js} +1 -1
- package/dist/m/{c-NW54NHKE.js → c-6LEYVQJK.js} +1 -1
- package/dist/m/{c-GSRLXYWL.js → c-6Q6RGFBF.js} +1 -1
- package/dist/m/c-6RGEQNVV.js +1 -0
- package/dist/m/c-7CM4GMTS.js +6 -0
- package/dist/m/c-7NCWENHV.js +1 -0
- package/dist/m/c-7V6MGMX2.js +1 -0
- package/dist/m/{c-LKSL4AUJ.js → c-7WZSUTYP.js} +1 -1
- package/dist/m/c-A4L7APIU.js +1 -0
- package/dist/m/c-APGHGDZM.js +1 -0
- package/dist/m/c-AT7GLQGV.js +34 -0
- package/dist/m/{c-ZRXJD4G6.js → c-B7GOFGQR.js} +1 -1
- package/dist/m/{c-KDXIJEEF.js → c-BGN7RCTJ.js} +1 -1
- package/dist/m/c-BKM46LUJ.js +1 -0
- package/dist/m/c-BOMQIQ3V.js +1 -0
- package/dist/m/{c-62HZW5DH.js → c-C5AKJVRH.js} +1 -1
- package/dist/m/{c-BXYSDKAN.js → c-CJ7QYEWI.js} +1 -1
- package/dist/m/c-CTGRDT6E.js +1 -0
- package/dist/m/c-CV4T65JE.js +6 -0
- package/dist/m/c-CVSWLX3X.js +1 -0
- package/dist/m/c-CZHTXGJS.js +1 -0
- package/dist/m/c-D7NT5S4F.js +1 -0
- package/dist/m/c-DD26VXAP.js +1 -0
- package/dist/m/{c-ANNFZFLN.js → c-DDS23EY6.js} +1 -1
- package/dist/m/{c-ALDVFPWL.js → c-DFKBGSN2.js} +1 -1
- package/dist/m/c-DIKR7H57.js +147 -0
- package/dist/m/c-DXPOFLEJ.js +1 -0
- package/dist/m/c-EDE45NM7.js +1 -0
- package/dist/m/c-EILLN2H2.js +1 -0
- package/dist/m/c-EODTTNVA.js +1 -0
- package/dist/m/{c-G6COVIZB.js → c-ESK4S67I.js} +1 -1
- package/dist/m/c-FDWR3FL7.js +1 -0
- package/dist/m/{c-WQZTI5P2.js → c-FEC6LGFF.js} +1 -1
- package/dist/m/c-FLEIU6CG.js +1 -0
- package/dist/m/c-FQAQRXGK.js +1 -0
- package/dist/m/{c-W4JCVLAB.js → c-FSQXFG5T.js} +1 -1
- package/dist/m/c-FVPNX2GO.js +135 -0
- package/dist/m/c-FYDKYW6E.js +1 -0
- package/dist/m/c-GNI7WHKF.js +32 -0
- package/dist/m/c-GO635CRU.js +3 -0
- package/dist/m/c-H3FNLBHN.js +2 -0
- package/dist/m/c-HDVH3MVC.js +72 -0
- package/dist/m/c-HIX5H5L7.js +1 -0
- package/dist/m/c-HKSLOVU4.js +1 -0
- package/dist/m/{c-SGRIYOAJ.js → c-HL6BLJNA.js} +1 -1
- package/dist/m/c-HTLYXCUH.js +1 -0
- package/dist/m/{c-QIR5CAKM.js → c-IUL7PU4P.js} +1 -1
- package/dist/m/c-IXO7EI2Q.js +1 -0
- package/dist/m/{c-W5E5P2TZ.js → c-JQF2EUCG.js} +1 -1
- package/dist/m/{c-NEL7HQW3.js → c-JWDCQL6J.js} +1 -1
- package/dist/m/c-KQKKIVLW.js +20 -0
- package/dist/m/c-LATNQ6Q5.js +1 -0
- package/dist/m/c-LD6UVV5R.js +1 -0
- package/dist/m/c-LS7IVQVW.js +1 -0
- package/dist/m/{c-JCOQVZYS.js → c-LSVN3OLG.js} +1 -1
- package/dist/m/{c-JDZDF2QM.js → c-LTSPHVAK.js} +1 -1
- package/dist/m/c-MFOSMAVM.js +3 -0
- package/dist/m/c-MJ7GVE46.js +1 -0
- package/dist/m/c-MP6S4AZU.js +6 -0
- package/dist/m/c-MQKSKQHG.js +2 -0
- package/dist/m/{c-UHUNXWKN.js → c-MQYEDF3Q.js} +1 -1
- package/dist/m/{c-IHUWUKIU.js → c-MR75YPRT.js} +1 -1
- package/dist/m/c-ND3Q2G2I.js +1 -0
- package/dist/m/c-NEQRFC4O.js +1 -0
- package/dist/m/{c-5FKRZNJV.js → c-NFQFV7OP.js} +1 -1
- package/dist/m/c-NHXOBD6A.js +1 -0
- package/dist/m/{c-QIKT6SKM.js → c-NICICT4P.js} +1 -1
- package/dist/m/c-NQAPWM7O.js +1 -0
- package/dist/m/{c-QUGCKMWF.js → c-NVU3DORS.js} +1 -1
- package/dist/m/{c-LWIDDWAR.js → c-OCYG4NBQ.js} +22 -22
- package/dist/m/c-OH2FPYSY.js +19 -0
- package/dist/m/c-OYHI67B6.js +1 -0
- package/dist/m/{c-R2XUODVY.js → c-OYW5MFPZ.js} +1 -1
- package/dist/m/{c-5B4YBZXC.js → c-P2HKMJAW.js} +1 -1
- package/dist/m/{c-TSBVMWAH.js → c-PCNJETUA.js} +1 -1
- package/dist/m/c-PDBNCJCT.js +1 -0
- package/dist/m/c-PGSBXHUE.js +1 -0
- package/dist/m/{c-5TIZ2I64.js → c-PYG2NGWU.js} +1 -1
- package/dist/m/c-Q26XHBLQ.js +1 -0
- package/dist/m/c-Q6BG3ZLO.js +1 -0
- package/dist/m/c-QENKN7QI.js +1 -0
- package/dist/m/c-QQFHEODI.js +1 -0
- package/dist/m/c-QTEUO2K6.js +1 -0
- package/dist/m/c-R23UHMXG.js +1 -0
- package/dist/m/c-RETTCOWO.js +10 -0
- package/dist/m/c-SE3SIY7Y.js +7 -0
- package/dist/m/{c-XX75FFNL.js → c-SGGGCIVD.js} +1 -1
- package/dist/m/c-SGH3UTF3.js +1 -0
- package/dist/m/c-SIM7Z3U7.js +1 -0
- package/dist/m/{c-X5LNHET5.js → c-SKMIR5HQ.js} +1 -1
- package/dist/m/{c-R27DWQKX.js → c-STRI73GQ.js} +1 -1
- package/dist/m/c-SUXHUL7U.js +1 -0
- package/dist/m/c-SXGEWPFC.js +10 -0
- package/dist/m/c-SXNSSHPP.js +1 -0
- package/dist/m/c-T3P3AXEW.js +1 -0
- package/dist/m/{c-PXLTUYZC.js → c-TFLRT5JX.js} +1 -1
- package/dist/m/{c-YCLU4UNT.js → c-TGIMBAWE.js} +1 -1
- package/dist/m/c-TGSHHFO6.js +1 -0
- package/dist/m/c-U4NTUVDZ.js +1 -0
- package/dist/m/c-UOOIF2AL.js +1 -0
- package/dist/m/{c-6TYGD5AB.js → c-UOUUI265.js} +1 -1
- package/dist/m/c-V2U3F4QX.js +1 -0
- package/dist/m/c-V2V5FKXX.js +1 -0
- package/dist/m/c-VBXRXTVS.js +26 -0
- package/dist/m/c-VHSMPITY.js +1 -0
- package/dist/m/c-VPXCXBDT.js +1 -0
- package/dist/m/c-WCG6AKA7.js +1 -0
- package/dist/m/c-WNOLMHI2.js +1 -0
- package/dist/m/{c-CRPIDGXC.js → c-X6MOYATI.js} +1 -1
- package/dist/m/{c-FQGHR32O.js → c-X75G43SZ.js} +1 -1
- package/dist/m/c-XB6EAIAR.js +13 -0
- package/dist/m/c-XMIDHEKF.js +1 -0
- package/dist/m/c-XUZMRQ7O.js +4 -0
- package/dist/m/{c-2Z22FCFK.js → c-XW5TIYYB.js} +1 -1
- package/dist/m/c-YDW4VCHP.js +1 -0
- package/dist/m/{c-QGAPG7OM.js → c-YLHTD3KX.js} +1 -1
- package/dist/m/c-YNIEIPBS.js +1 -0
- package/dist/m/c-Z4G2UK6T.js +4 -0
- package/dist/m/c-Z6MROEQ4.js +1 -0
- package/dist/m/c-ZFO5RW6G.js +2 -0
- package/dist/m/c-ZGCO4J3H.js +8 -0
- package/dist/m/c-ZKKAF4UT.js +3 -0
- package/dist/m/c-ZRGEN6QQ.js +4 -0
- package/dist/m/core/{admin-attrs-U7IJNYBG.js → admin-attrs-ONRWVXPK.js} +1 -1
- package/dist/m/core/{autosave-F5YQCKVL.js → autosave-TBKAAAFB.js} +1 -1
- package/dist/m/core/conflict-notice-FOEE6I7E.js +1 -0
- package/dist/m/core/draft-mode-4MCL3LYI.js +1 -0
- package/dist/m/core/{host-permission-6EVJGNPL.js → host-permission-X4BENZEU.js} +1 -1
- package/dist/m/core/{is-edit-mode-GCX6767E.js → is-edit-mode-FFHCQ5DR.js} +1 -1
- package/dist/m/core/{persist-CJXIL7D4.js → persist-6ILUR34S.js} +1 -1
- package/dist/m/core/{recovery-DRFZRJED.js → recovery-APWADU4K.js} +1 -1
- package/dist/m/core/save-6HT2LABE.js +1 -0
- package/dist/m/core/save-core-EVMNZQ4V.js +1 -0
- package/dist/m/core/site-edits-G4BOZMV4.js +1 -0
- package/dist/m/core/{unsaved-warning-HNQVTA2D.js → unsaved-warning-ITZDIZ2I.js} +1 -1
- package/dist/m/internals/{index-NRPNDTSA.js → index-HS3CQDFW.js} +1 -1
- package/dist/m/loader-GLLVDUZA.js +1 -0
- package/dist/m/manifest-50FF1C45.js +1 -0
- package/dist/m/manifest-edit-BE1A621D.js +1 -0
- package/dist/m/manifest.json +2072 -1811
- package/dist/m/page/editor-KAZDJNND.js +307 -0
- package/dist/m/plugins/ai-edit-LABECCSN.js +6 -0
- package/dist/m/plugins/{cms-H7DTMUQX.js → cms-T2HLI7JG.js} +16 -16
- package/dist/m/plugins/{demo-42BSYQ7T.js → demo-T7B4RIKL.js} +1 -1
- package/dist/m/plugins/{derive-QVI3LI3A.js → derive-6LPJOCAV.js} +1 -1
- package/dist/m/plugins/indicator-J4ABFARX.js +1 -0
- package/dist/m/plugins/{live-DCUBKXY4.js → live-PGBIEMGB.js} +1 -1
- package/dist/m/plugins/menu-YZL3X2AJ.js +1 -0
- package/dist/m/plugins/page-WOCNX2IN.js +2 -0
- package/dist/m/plugins/page-view-SJODOOGE.js +1 -0
- package/dist/m/plugins/{people-5XRNRP5U.js → people-C4TCWFOQ.js} +1 -1
- package/dist/m/plugins/{quickcrop-WWF5I422.js → quickcrop-X5MRIBAP.js} +2 -2
- package/dist/m/plugins/richclay-Y2NV44NA.js +549 -0
- package/dist/m/plugins/sortable-XCHQG65Z.js +1 -0
- package/dist/m/plugins/{source-6BKMK4PO.js → source-YK7MO23W.js} +1 -1
- package/dist/m/plugins/{undo-3JEYK5QY.js → undo-VLRBQNPN.js} +1 -1
- package/dist/m/plugins/upgrade-NNTJBSK2.js +1 -0
- package/dist/m/plugins/{upload-TTCQRIM5.js → upload-ZKKJV76X.js} +1 -1
- package/dist/m/plugins/visitor-drafts-RTZNONHT.js +20 -0
- package/dist/m/plugins/{visitor-drafts-owner-Z5B2OQBR.js → visitor-drafts-owner-LHUHFU3L.js} +1 -1
- package/dist/m/plugins/{visitor-menu-4LQMKLPP.js → visitor-menu-FY4KM2SW.js} +1 -1
- package/dist/m/plugins/wire-M2NR354P.js +1 -0
- package/dist/m/{reader-core-POFQCKRV.js → reader-core-T2S3JC4E.js} +2 -2
- package/dist/m/sync/live-sync-Z64YREWQ.js +1 -0
- package/dist/m/ui/index-MGTWOW2C.js +1 -0
- package/dist/m/vendor/{sap-core.vendor-OA5SKL7Q.js → sap-core.vendor-QAEPMETX.js} +1 -1
- package/dist/offline-manifest.json +1250 -1082
- package/dist/server/core.cjs +132 -109
- package/dist/server/page-compaction-worker.cjs +5 -5
- package/dist/server/rooms.mjs +3 -1
- package/docs/guide.md +89 -44
- package/entries/clay-data.js +1 -1
- package/entries/sap.js +1 -1
- package/package.json +5 -3
- package/src/blockeditor/themes/content.css +70 -0
- package/src/blockeditor/themes/light-1.css +431 -0
- package/src/blockeditor/themes/light-1.source.css +270 -0
- package/src/blockeditor/themes/light-2.css +211 -0
- package/src/blockeditor/themes/light-3.css +130 -0
- package/src/blockeditor/themes/light-4.css +299 -0
- package/src/core/conflict-notice.js +28 -0
- package/src/core/draft-mode.js +6 -0
- package/src/core/host-meta.js +6 -6
- package/src/core/is-edit-mode.js +9 -3
- package/src/core/mode-support.js +3 -0
- package/src/core/mode-switch.js +4 -4
- package/src/core/mode-transition.js +3 -1
- package/src/core/page-format-wire.js +1 -1
- package/src/core/page-format.js +8 -8
- package/src/core/save-accepted.js +6 -7
- package/src/core/save-core.js +52 -23
- package/src/core/save-failure-notice.js +37 -0
- package/src/core/save-feedback.js +6 -0
- package/src/core/save-replace.js +1 -1
- package/src/core/save-size.js +2 -2
- package/src/core/save.js +78 -15
- package/src/core/site-edits.js +166 -0
- package/src/core/unsaved-warning.js +2 -2
- package/src/core/upgrade-run.js +4 -4
- package/src/lib/ai-comment.js +23 -0
- package/src/lib/effect.js +8 -0
- package/src/lib/idb-error-code.js +20 -0
- package/src/live/fast-lane.js +10 -10
- package/src/live/local-lane.js +10 -10
- package/src/live/page-compaction.js +8 -8
- package/src/live/server-lane.js +1 -1
- package/src/loader-logic.js +48 -18
- package/src/loader.js +11 -6
- package/src/page/adopt-boot.js +1 -1
- package/src/page/adopt.js +2 -2
- package/src/page/ai-area.js +182 -0
- package/src/page/ai-preview.js +80 -0
- package/src/page/ai-surface.js +257 -0
- package/src/page/ai-tool.js +308 -145
- package/src/page/announce.js +2 -2
- package/src/page/awareness.js +18 -18
- package/src/page/blocks.js +35 -34
- package/src/page/blocksel.js +2 -2
- package/src/page/board-drag.js +11 -11
- package/src/page/board-face.js +1 -1
- package/src/page/board-panel.js +26 -26
- package/src/page/board-style.js +127 -127
- package/src/page/board-view.js +48 -48
- package/src/page/chart.js +29 -29
- package/src/page/checkpoint-proof.js +19 -19
- package/src/page/chrome.js +74 -65
- package/src/page/clipboard-shape.js +1 -1
- package/src/page/csv-import.js +4 -4
- package/src/page/drag.js +5 -5
- package/src/page/editor.js +301 -296
- package/src/page/export-html.js +8 -8
- package/src/page/features/checklist.js +36 -36
- package/src/page/features/export-html.js +19 -19
- package/src/page/features/export-markdown.js +10 -10
- package/src/page/features/import-markdown.js +13 -13
- package/src/page/features/media.js +50 -50
- package/src/page/features/table.js +17 -17
- package/src/page/features/title-cover.js +17 -17
- package/src/page/features/title-icon.js +7 -7
- package/src/page/features/toc.js +1 -1
- package/src/page/features/tool.js +42 -18
- package/src/page/format-command.js +4 -4
- package/src/page/format-gate.js +6 -6
- package/src/page/format-host.js +6 -6
- package/src/page/format-level.js +3 -3
- package/src/page/format-native-commands.js +2 -2
- package/src/page/highlight-slot.js +1 -1
- package/src/page/highlight.js +4 -4
- package/src/page/history-intent.js +2 -2
- package/src/page/image-actions.js +4 -4
- package/src/page/link.js +10 -10
- package/src/page/media.js +3 -3
- package/src/page/mention-picker.js +7 -7
- package/src/page/merge.js +1 -1
- package/src/page/placeholder.js +3 -3
- package/src/page/projection.js +11 -11
- package/src/page/reader-patch.js +2 -2
- package/src/page/recover.js +26 -26
- package/src/page/recovery-ui.js +28 -28
- package/src/page/rich/chart.js +1 -1
- package/src/page/rich/page-tool.js +21 -6
- package/src/page/rich/tool-runtime.js +3 -2
- package/src/page/save-projection.js +2 -2
- package/src/page/save-states.js +9 -9
- package/src/page/schema.js +9 -9
- package/src/page/table-style.js +21 -21
- package/src/page/toc-link.js +1 -1
- package/src/page/tool-capability.js +8 -3
- package/src/page/tool-transport.js +52 -0
- package/src/page/tool-views.js +4 -0
- package/src/page/tools.js +6 -1
- package/src/page/view.js +6 -6
- package/src/page/ybind/binding.js +1 -1
- package/src/page/ybind/conversion.js +1 -1
- package/src/page/ybind/layout.js +4 -4
- package/src/page/ybind/migrate.js +1 -1
- package/src/page/ybind/origins.js +2 -2
- package/src/page/ybind/provider.js +2 -2
- package/src/page/ybind/recovery-proof.js +3 -3
- package/src/page/ybind/recovery-replay.js +2 -2
- package/src/plugins/ai-edit/picker.js +235 -0
- package/src/plugins/ai-edit.js +220 -34
- package/src/plugins/indicator-chip.js +39 -34
- package/src/plugins/indicator.js +13 -4
- package/src/plugins/live.js +21 -13
- package/src/plugins/menu/actions.js +89 -17
- package/src/plugins/menu/seo.js +32 -6
- package/src/plugins/menu/shell-style.js +26 -7
- package/src/plugins/menu/shell.js +12 -7
- package/src/plugins/menu/variants.js +6 -10
- package/src/plugins/menu/visitor.js +44 -34
- package/src/plugins/menu.js +3 -2
- package/src/plugins/page-view.js +2 -2
- package/src/plugins/page.js +257 -98
- package/src/plugins/sortable.js +7 -0
- package/src/plugins/upgrade.js +2 -1
- package/src/plugins/visitor-drafts/commit.js +303 -0
- package/src/plugins/visitor-drafts/idb.js +221 -0
- package/src/plugins/visitor-drafts/intro-style.js +1 -1
- package/src/plugins/visitor-drafts/intro.js +8 -25
- package/src/plugins/visitor-drafts/prompt.js +30 -4
- package/src/plugins/visitor-drafts/session.js +345 -0
- package/src/plugins/visitor-drafts/store.js +351 -32
- package/src/plugins/visitor-drafts.js +158 -27
- package/src/server/checkpoint/index.js +8 -8
- package/src/server/rooms/index.js +2 -2
- package/src/server/rooms/live-data-rooms.js +35 -35
- package/src/server/rooms/live-page-history.js +2 -2
- package/src/server/rooms/page-admission.js +34 -6
- package/src/server/rooms/page-conversion.js +1 -1
- package/src/server/rooms/page-lineage.js +4 -4
- package/src/server/rooms/page-rebase.js +4 -4
- package/src/server/rooms/page-room-conformance.js +14 -14
- package/src/server/rooms/page-state.js +2 -2
- package/src/server/rooms/page-write-admission.js +7 -7
- package/src/server/rooms/page-write-guard.js +3 -3
- package/src/sync/data-guard-notice.js +265 -0
- package/src/sync/live-sync.js +54 -11
- package/src/sync/page-relay.js +4 -4
- package/src/sync/presence-store.js +1 -1
- package/src/sync/presence-target.js +3 -3
- package/src/sync/presence.js +1 -1
- package/src/sync/stream.js +54 -13
- package/src/sync/wire-profile.js +8 -3
- package/src/ui/bevel.js +1 -1
- package/src/ui/index.js +9 -10
- package/src/ui/skins/cms.js +1 -1
- package/src/ui/skins/quickcrop.js +1 -1
- package/src/ui/skins/richclay.js +2 -2
- package/src/ui/toast-lazy.js +12 -3
- package/src/ui/toast.js +9 -3
- package/src/vendor/hyper-html-api-data.vendor.js +1 -1
- package/src/vendor/hyper-html-api-upgrade.vendor.js +2 -2
- package/src/vendor/hypercms.vendor.js +16 -16
- package/src/vendor/richclay.vendor.js +48 -20
- package/src/vendor/sap-core.vendor.js +1 -1
- package/tool-generation/context.md +44 -0
- package/tool-generation/system.md +23 -0
- package/dist/m/c-24PMUJIV.js +0 -2
- package/dist/m/c-2AYVYEI4.js +0 -1
- package/dist/m/c-2AZDZWCK.js +0 -1
- package/dist/m/c-2L6O5PDS.js +0 -6
- package/dist/m/c-2RYOGUQM.js +0 -2
- package/dist/m/c-2ZVOEU4M.js +0 -1
- package/dist/m/c-37NAONZA.js +0 -1
- package/dist/m/c-3GJ4SDE2.js +0 -1
- package/dist/m/c-3O7OBDCM.js +0 -1
- package/dist/m/c-5OJ7YF2N.js +0 -1
- package/dist/m/c-5WMXEKFH.js +0 -135
- package/dist/m/c-6RDOKLN7.js +0 -1
- package/dist/m/c-A4IP6MBC.js +0 -1
- package/dist/m/c-A6L3FMUS.js +0 -1
- package/dist/m/c-ATKAOH23.js +0 -1
- package/dist/m/c-B6O7AJYG.js +0 -32
- package/dist/m/c-BCGWJYXW.js +0 -1
- package/dist/m/c-BGKAT2FL.js +0 -7
- package/dist/m/c-BYTKL6UX.js +0 -1
- package/dist/m/c-DHBRA6DL.js +0 -1
- package/dist/m/c-DTMZ3ZHI.js +0 -1
- package/dist/m/c-E3ZXARWA.js +0 -1
- package/dist/m/c-EK63G3CG.js +0 -1
- package/dist/m/c-ELYIIYRS.js +0 -1
- package/dist/m/c-EXKHPOVC.js +0 -3
- package/dist/m/c-FCSZ3DC5.js +0 -20
- package/dist/m/c-FTWGYI5E.js +0 -1
- package/dist/m/c-G4PWUDD5.js +0 -1
- package/dist/m/c-GBKB5WDL.js +0 -2
- package/dist/m/c-GBTVCJXC.js +0 -1
- package/dist/m/c-GC2HICFJ.js +0 -1
- package/dist/m/c-GRWMD6O5.js +0 -1
- package/dist/m/c-HCNWJE4A.js +0 -4
- package/dist/m/c-HG2C77BM.js +0 -4
- package/dist/m/c-JGHEACGK.js +0 -1
- package/dist/m/c-JGLX6TBK.js +0 -1
- package/dist/m/c-JNRKHYWO.js +0 -1
- package/dist/m/c-KBS3UV6B.js +0 -1
- package/dist/m/c-KQ7E3PYY.js +0 -1
- package/dist/m/c-L3F5ZLIV.js +0 -1
- package/dist/m/c-L4KMT7FO.js +0 -6
- package/dist/m/c-L5VFATT6.js +0 -1
- package/dist/m/c-LCYPMULG.js +0 -1
- package/dist/m/c-LIGQYZ7M.js +0 -6
- package/dist/m/c-LKIWEPAV.js +0 -1
- package/dist/m/c-MPSKIU2I.js +0 -1
- package/dist/m/c-N7JPUPGC.js +0 -1
- package/dist/m/c-NK33MMYF.js +0 -1
- package/dist/m/c-NQLWOHLH.js +0 -10
- package/dist/m/c-NTHUTABN.js +0 -1
- package/dist/m/c-NWX3MFT4.js +0 -1
- package/dist/m/c-OKXI52N7.js +0 -1
- package/dist/m/c-OPONJ2UK.js +0 -128
- package/dist/m/c-OWQWOGYI.js +0 -1
- package/dist/m/c-P6Q2ZTFQ.js +0 -1
- package/dist/m/c-QEN6HZCA.js +0 -1
- package/dist/m/c-QIXT3Q7C.js +0 -28
- package/dist/m/c-QM5LXRDT.js +0 -9
- package/dist/m/c-QYYUVLVG.js +0 -1
- package/dist/m/c-RQRMPZXD.js +0 -1
- package/dist/m/c-SBCBXKOZ.js +0 -26
- package/dist/m/c-SKF5HL4I.js +0 -4
- package/dist/m/c-SRPC3VBE.js +0 -1
- package/dist/m/c-TANBH7FI.js +0 -1
- package/dist/m/c-THGQQDYY.js +0 -1
- package/dist/m/c-UD5JZTDL.js +0 -1
- package/dist/m/c-UDGEFWNU.js +0 -1
- package/dist/m/c-UGNV5MFB.js +0 -1
- package/dist/m/c-VIRFF5HG.js +0 -8
- package/dist/m/c-VJYEVRYK.js +0 -1
- package/dist/m/c-VQCEOGKH.js +0 -13
- package/dist/m/c-VYJ7O4RI.js +0 -34
- package/dist/m/c-W7IPVCAA.js +0 -1
- package/dist/m/c-WBGWGOM7.js +0 -1
- package/dist/m/c-WJ5DRBHT.js +0 -72
- package/dist/m/c-X5WC4PX5.js +0 -1
- package/dist/m/c-XCFQEWW6.js +0 -3
- package/dist/m/c-XGH4GS2T.js +0 -1
- package/dist/m/c-XLQ3BDMM.js +0 -1
- package/dist/m/c-ZQXNHZZT.js +0 -72
- package/dist/m/core/conflict-notice-42H4ASLA.js +0 -1
- package/dist/m/core/draft-mode-WSQAT67S.js +0 -1
- package/dist/m/core/save-ESPSQPLV.js +0 -1
- package/dist/m/core/save-core-6SQHOR6W.js +0 -1
- package/dist/m/loader-FBDE2UAB.js +0 -1
- package/dist/m/manifest-1D2F5CA5.js +0 -1
- package/dist/m/manifest-edit-F7CC5CFD.js +0 -1
- package/dist/m/page/editor-OSKOW6RS.js +0 -304
- package/dist/m/plugins/ai-edit-VV4QTINH.js +0 -6
- package/dist/m/plugins/indicator-WVPGMOZ7.js +0 -1
- package/dist/m/plugins/menu-Q4MFFQ6E.js +0 -1
- package/dist/m/plugins/page-OAWUJQEL.js +0 -2
- package/dist/m/plugins/page-view-DZ26ZDDQ.js +0 -1
- package/dist/m/plugins/richclay-PGOOJ4OK.js +0 -517
- package/dist/m/plugins/sortable-266HY6TR.js +0 -1
- package/dist/m/plugins/upgrade-BNZVFHMZ.js +0 -1
- package/dist/m/plugins/visitor-drafts-2AUYKAIJ.js +0 -20
- package/dist/m/plugins/wire-W2EV36KZ.js +0 -1
- package/dist/m/sync/live-sync-XGUPHI3I.js +0 -1
- package/dist/m/ui/index-VGYAKAKI.js +0 -1
- package/dist/page/themes/light-1.css +0 -431
- package/src/page/themes/content.css +0 -70
- package/src/page/themes/light-1.css +0 -431
- package/src/page/themes/light-1.source.css +0 -270
- package/src/page/themes/light-2.css +0 -211
- package/src/page/themes/light-3.css +0 -130
- package/src/page/themes/light-4.css +0 -299
- /package/dist/m/{c-FILLTJA7.js → c-QTTJYJMA.js} +0 -0
- /package/dist/m/plugins/{quickcrop-WWF5I422.js.LEGAL.txt → quickcrop-X5MRIBAP.js.LEGAL.txt} +0 -0
- /package/dist/m/plugins/{richclay-PGOOJ4OK.js.LEGAL.txt → richclay-Y2NV44NA.js.LEGAL.txt} +0 -0
package/dist/m/c-QIXT3Q7C.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
var Ra=Object.defineProperty,mt=(t,e)=>{for(var n in e)Ra(t,n,{get:e[n],enumerable:!0})},gt={};mt(gt,{ContentMatch:()=>ae,DOMParser:()=>Bo,DOMSerializer:()=>He,Fragment:()=>b,Mark:()=>E,MarkType:()=>Po,Node:()=>$t,NodeRange:()=>Ls,NodeType:()=>mo,ReplaceError:()=>le,ResolvedPos:()=>ho,Schema:()=>Za,Slice:()=>x});function W(t){this.content=t}W.prototype={constructor:W,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 o=n&&n!=t?this.remove(n):this,i=o.find(t),s=o.content.slice();return i==-1?s.push(n||t,e):(s[i+1]=e,n&&(s[i]=n)),new W(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 W(n)},addToStart:function(t,e){return new W([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new W(n)},addBefore:function(t,e,n){var o=this.remove(e),i=o.content.slice(),s=o.find(t);return i.splice(s==-1?i.length:s,0,e,n),new W(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=W.from(t),t.size?new W(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=W.from(t),t.size?new W(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=W.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}};W.from=function(t){if(t instanceof W)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new W(e)};var Ai=W;function $s(t,e,n){for(let o=0;;o++){if(o==t.childCount||o==e.childCount)return t.childCount==e.childCount?null:n;let i=t.child(o),s=e.child(o);if(i==s){n+=i.nodeSize;continue}if(!i.sameMarkup(s))return n;if(i.isText&&i.text!=s.text){let r=i.text,l=s.text,a=0;for(;r[a]==l[a];a++)n++;return a&&a<r.length&&a<l.length&&Ps(r.charCodeAt(a-1))&&Rs(r.charCodeAt(a))&&n--,n}if(i.content.size||s.content.size){let r=$s(i.content,s.content,n+1);if(r!=null)return r}n+=i.nodeSize}}function Is(t,e,n,o){for(let i=t.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:n,b:o};let r=t.child(--i),l=e.child(--s),a=r.nodeSize;if(r==l){n-=a,o-=a;continue}if(!r.sameMarkup(l))return{a:n,b:o};if(r.isText&&r.text!=l.text){let h=r.text,c=l.text,d=h.length,p=c.length;for(;d>0&&p>0&&h[d-1]==c[p-1];)d--,p--,n--,o--;return d&&p&&d<h.length&&Ps(h.charCodeAt(d-1))&&Rs(h.charCodeAt(d))&&(n++,o++),{a:n,b:o}}if(r.content.size||l.content.size){let h=Is(r.content,l.content,n-1,o-1);if(h)return h}n-=a,o-=a}}function Rs(t){return t>=56320&&t<57344}function Ps(t){return t>=55296&&t<56320}var b=class _{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let o=0;o<e.length;o++)this.size+=e[o].nodeSize}nodesBetween(e,n,o,i=0,s){for(let r=0,l=0;l<n;r++){let a=this.content[r],h=l+a.nodeSize;if(h>e&&o(a,i+l,s||null,r)!==!1&&a.content.size){let c=l+1;a.nodesBetween(Math.max(0,e-c),Math.min(a.content.size,n-c),o,i+c)}l=h}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,o,i){let s="",r=!0;return this.nodesBetween(e,n,(l,a)=>{let h=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&&h||l.isTextblock)&&o&&(r?r=!1:s+=o),s+=h},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,o=e.firstChild,i=this.content.slice(),s=0;for(n.isText&&n.sameMarkup(o)&&(i[i.length-1]=n.withText(n.text+o.text),s=1);s<e.content.length;s++)i.push(e.content[s]);return new _(i,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let o=[],i=0;if(n>e)for(let s=0,r=0;r<n;s++){let l=this.content[s],a=r+l.nodeSize;a>e&&((r<e||a>n)&&(l.isText?l=l.cut(Math.max(0,e-r),Math.min(l.text.length,n-r)):l=l.cut(Math.max(0,e-r-1),Math.min(l.content.size,n-r-1))),o.push(l),i+=l.nodeSize),r=a}return new _(o,i)}cutByIndex(e,n){return e==n?_.empty:e==0&&n==this.content.length?this:new _(this.content.slice(e,n))}replaceChild(e,n){let o=this.content[e];if(o==n)return this;let i=this.content.slice(),s=this.size+n.nodeSize-o.nodeSize;return i[e]=n,new _(i,s)}addToStart(e){return new _([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new _(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,o=0;n<this.content.length;n++){let i=this.content[n];e(i,o,n),o+=i.nodeSize}}findDiffStart(e,n=0){return $s(this,e,n)}findDiffEnd(e,n=this.size,o=e.size){return Is(this,e,n,o)}findIndex(e){if(e==0)return pn(0,e);if(e==this.size)return pn(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,o=0;;n++){let i=this.child(n),s=o+i.nodeSize;if(s>=e)return s==e?pn(n+1,s):pn(n,o);o=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 _.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return _.fromArray(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return _.empty;let n,o=0;for(let i=0;i<e.length;i++){let s=e[i];o+=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 _(n||e,o)}static from(e){if(!e)return _.empty;if(e instanceof _)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new _([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}};b.empty=new b([],0);var Gn={index:0,offset:0};function pn(t,e){return Gn.index=t,Gn.offset=e,Gn}function On(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 o=0;o<t.length;o++)if(!On(t[o],e[o]))return!1}else{for(let o in t)if(!(o in e)||!On(t[o],e[o]))return!1;for(let o in e)if(!(o in t))return!1}return!0}var E=class ao{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,o=!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;!o&&s.type.rank>this.type.rank&&(n||(n=e.slice(0,i)),n.push(this),o=!0),n&&n.push(s)}}return n||(n=e.slice()),o||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&&On(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 o=e.marks[n.type];if(!o)throw new RangeError(`There is no mark type ${n.type} in this schema`);return o.create(n.attrs)}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let o=0;o<e.length;o++)if(!e[o].eq(n[o]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return ao.none;if(e instanceof ao)return[e];let n=e.slice();return n.sort((o,i)=>o.type.rank-i.type.rank),n}};E.none=[];var le=class extends Error{},x=class te{constructor(e,n,o){this.content=e,this.openStart=n,this.openEnd=o}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let o=zs(this.content,e+this.openStart,n,this.openStart+1,this.openEnd+1);return o&&new te(o,this.openStart,this.openEnd)}removeBetween(e,n){return new te(Bs(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 te.empty;let o=n.openStart||0,i=n.openEnd||0;if(typeof o!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new te(b.fromJSON(e,n.content),o,i)}static maxOpen(e,n=!0){let o=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(n||!s.type.spec.isolating);s=s.firstChild)o++;for(let s=e.lastChild;s&&!s.isLeaf&&(n||!s.type.spec.isolating);s=s.lastChild)i++;return new te(e,o,i)}};x.empty=new x(b.empty,0,0);function Bs(t,e,n){let{index:o,offset:i}=t.findIndex(e),s=t.maybeChild(o),{index:r,offset:l}=t.findIndex(n);if(i==e||s.isText){if(l!=n&&!t.child(r).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(o!=r)throw new RangeError("Removing non-flat range");return t.replaceChild(o,s.copy(Bs(s.content,e-i-1,n-i-1)))}function zs(t,e,n,o,i,s){let{index:r,offset:l}=t.findIndex(e),a=t.maybeChild(r);if(l==e||a.isText)return s&&o<=0&&i<=0&&!s.canReplace(r,r,n)?null:t.cut(0,e).append(n).append(t.cut(e));let h=zs(a.content,e-l-1,n,r==0?o-1:0,r==t.childCount-1?i-1:0,a);return h&&t.replaceChild(r,a.copy(h))}function Pa(t,e,n){if(n.openStart>t.depth)throw new le("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new le("Inconsistent open depths");return Fs(t,e,n,0)}function Fs(t,e,n,o){let i=t.index(o),s=t.node(o);if(i==e.index(o)&&o<t.depth-n.openStart){let r=Fs(t,e,n,o+1);return s.copy(s.content.replaceChild(i,r))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==o&&e.depth==o){let r=t.parent,l=r.content;return Wt(r,l.cut(0,t.parentOffset).append(n.content).append(l.cut(e.parentOffset)))}else{let{start:r,end:l}=Ba(n,t);return Wt(s,js(t,r,l,e,o))}else return Wt(s,Mn(t,e,o))}function Vs(t,e){if(!e.type.compatibleContent(t.type))throw new le("Cannot join "+e.type.name+" onto "+t.type.name)}function co(t,e,n){let o=t.node(n);return Vs(o,e.node(n)),o}function qt(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 $e(t,e,n,o){let i=(e||t).node(n),s=0,r=e?e.index(n):i.childCount;t&&(s=t.index(n),t.depth>n?s++:t.textOffset&&(qt(t.nodeAfter,o),s++));for(let l=s;l<r;l++)qt(i.child(l),o);e&&e.depth==n&&e.textOffset&&qt(e.nodeBefore,o)}function Wt(t,e){if(!t.type.validContent(e))throw new le("Invalid content for node "+t.type.name);return t.copy(e)}function js(t,e,n,o,i){let s=t.depth>i&&co(t,e,i+1),r=o.depth>i&&co(n,o,i+1),l=[];return $e(null,t,i,l),s&&r&&e.index(i)==n.index(i)?(Vs(s,r),qt(Wt(s,js(t,e,n,o,i+1)),l)):(s&&qt(Wt(s,Mn(t,e,i+1)),l),$e(e,n,i,l),r&&qt(Wt(r,Mn(n,o,i+1)),l)),$e(o,null,i,l),new b(l)}function Mn(t,e,n){let o=[];if($e(null,t,n,o),t.depth>n){let i=co(t,e,n+1);qt(Wt(i,Mn(t,e,n+1)),o)}return $e(e,null,n,o),new b(o)}function Ba(t,e){let n=e.depth-t.openStart,o=e.node(n).copy(t.content);for(let i=n-1;i>=0;i--)o=e.node(i).copy(b.from(o));return{start:o.resolveNoCache(t.openStart+n),end:o.resolveNoCache(o.content.size-t.openEnd-n)}}var ho=class po{constructor(e,n,o){this.pos=e,this.path=n,this.parentOffset=o,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 o=this.pos-this.path[this.path.length-1],i=e.child(n);return o?e.child(n).cut(o):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 o=this.path[n*3],i=n==0?0:this.path[n*3-1]+1;for(let s=0;s<e;s++)i+=o.child(s).nodeSize;return i}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return E.none;if(this.textOffset)return e.child(n).marks;let o=e.maybeChild(n-1),i=e.maybeChild(n);if(!o){let l=o;o=i,i=l}let s=o.marks;for(var r=0;r<s.length;r++)s[r].type.spec.inclusive===!1&&(!i||!s[r].isInSet(i.marks))&&(s=s[r--].removeFromSet(s));return s}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let o=n.marks,i=e.parent.maybeChild(e.index());for(var s=0;s<o.length;s++)o[s].type.spec.inclusive===!1&&(!i||!o[s].isInSet(i.marks))&&(o=o[s--].removeFromSet(o));return o}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 o=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);o>=0;o--)if(e.pos<=this.end(o)&&(!n||n(this.node(o))))return new Ls(this,e,o);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 o=[],i=0,s=n;for(let r=e;;){let{index:l,offset:a}=r.content.findIndex(s),h=s-a;if(o.push(r,l,i+a),!h||(r=r.child(l),r.isText))break;s=h-1,i+=a+1}return new po(n,o,s)}static resolveCached(e,n){let o=Di.get(e);if(o)for(let s=0;s<o.elts.length;s++){let r=o.elts[s];if(r.pos==n)return r}else Di.set(e,o=new za);let i=o.elts[o.i]=po.resolve(e,n);return o.i=(o.i+1)%Fa,i}},za=class{constructor(){this.elts=[],this.i=0}},Fa=12,Di=new WeakMap,Ls=class{constructor(t,e,n){this.$from=t,this.$to=e,this.depth=n}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)}},Va=Object.create(null),$t=class uo{constructor(e,n,o,i=E.none){this.type=e,this.attrs=n,this.marks=i,this.content=o||b.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,o,i=0){this.content.nodesBetween(e,n,o,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,o,i){return this.content.textBetween(e,n,o,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,o){return this.type==e&&On(this.attrs,n||e.defaultAttrs||Va)&&E.sameSet(this.marks,o||E.none)}copy(e=null){return e==this.content?this:new uo(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new uo(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,o=!1){if(e==n)return x.empty;let i=this.resolve(e),s=this.resolve(n),r=o?0:i.sharedDepth(n),l=i.start(r),a=i.node(r).content.cut(i.pos-l,s.pos-l);return new x(a,i.depth-r,s.depth-r)}replace(e,n,o){return Pa(this.resolve(e),this.resolve(n),o)}nodeAt(e){for(let n=this;;){let{index:o,offset:i}=n.content.findIndex(e);if(n=n.maybeChild(o),!n)return null;if(i==e||n.isText)return n;e-=i+1}}childAfter(e){let{index:n,offset:o}=this.content.findIndex(e);return{node:this.content.maybeChild(n),index:n,offset:o}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:n,offset:o}=this.content.findIndex(e);if(o<e)return{node:this.content.child(n),index:n,offset:o};let i=this.content.child(n-1);return{node:i,index:n-1,offset:o-i.nodeSize}}resolve(e){return ho.resolveCached(this,e)}resolveNoCache(e){return ho.resolve(this,e)}rangeHasMark(e,n,o){let i=!1;return n>e&&this.nodesBetween(e,n,s=>(o.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()+")"),Js(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,o=b.empty,i=0,s=o.childCount){let r=this.contentMatchAt(e).matchFragment(o,i,s),l=r&&r.matchFragment(this.content,n);if(!l||!l.validEnd)return!1;for(let a=i;a<s;a++)if(!this.type.allowsMarks(o.child(a).marks))return!1;return!0}canReplaceWith(e,n,o,i){if(i&&!this.type.allowsMarks(i))return!1;let s=this.contentMatchAt(e).matchType(o),r=s&&s.matchFragment(this.content,n);return r?r.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),Ei(this.type.attrs,this.attrs,"node",this.type.name);let e=E.none;for(let n=0;n<this.marks.length;n++){let o=this.marks[n];Ei(o.type.attrs,o.attrs,"mark",o.type.name),e=o.addToSet(e)}if(!E.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 o;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");o=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,o)}let i=b.fromJSON(e,n.content);return e.nodeType(n.type).create(n.attrs,i,o)}};$t.prototype.text=void 0;var ja=class fo extends $t{constructor(e,n,o,i){if(super(e,n,null,i),!o)throw new RangeError("Empty text nodes are not allowed");this.text=o}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Js(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 fo(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new fo(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 Js(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}function Ei(t,e,n,o){for(let i in e)if(!(i in t))throw new RangeError(`Unsupported attribute ${i} for ${n} of type ${o}`);for(let i in t)t[i].validate&&t[i].validate(e[i])}var ae=class qs{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let o=new La(e,n);if(o.next==null)return qs.empty;let i=Ws(o);o.next&&o.err("Unexpected trailing text");let s=Ga(Ua(i));return Ya(s,o),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,o=e.childCount){let i=this;for(let s=n;i&&s<o;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 o=0;o<e.next.length;o++)if(this.next[n].type==e.next[o].type)return!0;return!1}fillBefore(e,n=!1,o=0){let i=[this];function s(r,l){let a=r.matchFragment(e,o);if(a&&(!n||a.validEnd))return b.from(l.map(h=>h.createAndFill()));for(let h=0;h<r.next.length;h++){let{type:c,next:d}=r.next[h];if(!(c.isText||c.hasRequiredAttrs())&&i.indexOf(d)==-1){i.push(d);let p=s(d,l.concat(c));if(p)return p}}return null}return s(this,[])}findWrapping(e){for(let o=0;o<this.wrapCache.length;o+=2)if(this.wrapCache[o]==e)return this.wrapCache[o+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),o=[{match:this,type:null,via:null}];for(;o.length;){let i=o.shift(),s=i.match;if(s.matchType(e)){let r=[];for(let l=i;l.type;l=l.via)r.push(l.type);return r.reverse()}for(let r=0;r<s.next.length;r++){let{type:l,next:a}=s.next[r];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in n)&&(!i.type||a.validEnd)&&(o.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(o){e.push(o);for(let i=0;i<o.next.length;i++)e.indexOf(o.next[i].next)==-1&&n(o.next[i].next)}return n(this),e.map((o,i)=>{let s=i+(o.validEnd?"*":" ")+" ";for(let r=0;r<o.next.length;r++)s+=(r?", ":"")+o.next[r].type.name+"->"+e.indexOf(o.next[r].next);return s}).join(`
|
|
2
|
-
`)}};ae.empty=new ae(!0);var La=class{constructor(t,e){this.string=t,this.nodeTypes=e,this.inline=null,this.pos=0,this.tokens=t.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(t){return this.next==t&&(this.pos++||!0)}err(t){throw new SyntaxError(t+" (in content expression '"+this.string+"')")}};function Ws(t){let e=[];do e.push(Ja(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Ja(t){let e=[];do e.push(qa(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function qa(t){let e=Ha(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=Wa(t,e);else break;return e}function Ti(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function Wa(t,e){let n=Ti(t),o=n;return t.eat(",")&&(t.next!="}"?o=Ti(t):o=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:o,expr:e}}function Ka(t,e){let n=t.nodeTypes,o=n[e];if(o)return[o];let i=[];for(let s in n){let r=n[s];r.isInGroup(e)&&i.push(r)}return i.length==0&&t.err("No node type or group '"+e+"' found"),i}function Ha(t){if(t.eat("(")){let e=Ws(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=Ka(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 Ua(t){let e=[[]];return i(s(t,0),n()),e;function n(){return e.push([])-1}function o(r,l,a){let h={term:a,to:l};return e[r].push(h),h}function i(r,l){r.forEach(a=>a.to=l)}function s(r,l){if(r.type=="choice")return r.exprs.reduce((a,h)=>a.concat(s(h,l)),[]);if(r.type=="seq")for(let a=0;;a++){let h=s(r.exprs[a],l);if(a==r.exprs.length-1)return h;i(h,l=n())}else if(r.type=="star"){let a=n();return o(l,a),i(s(r.expr,a),a),[o(a)]}else if(r.type=="plus"){let a=n();return i(s(r.expr,l),a),i(s(r.expr,a),a),[o(a)]}else{if(r.type=="opt")return[o(l)].concat(s(r.expr,l));if(r.type=="range"){let a=l;for(let h=0;h<r.min;h++){let c=n();i(s(r.expr,a),c),a=c}if(r.max==-1)i(s(r.expr,a),a);else for(let h=r.min;h<r.max;h++){let c=n();o(a,c),i(s(r.expr,a),c),a=c}return[o(a)]}else{if(r.type=="name")return[o(l,void 0,r.value)];throw new Error("Unknown expr type")}}}}function Ks(t,e){return e-t}function $i(t,e){let n=[];return o(e),n.sort(Ks);function o(i){let s=t[i];if(s.length==1&&!s[0].term)return o(s[0].to);n.push(i);for(let r=0;r<s.length;r++){let{term:l,to:a}=s[r];!l&&n.indexOf(a)==-1&&o(a)}}}function Ga(t){let e=Object.create(null);return n($i(t,0));function n(o){let i=[];o.forEach(r=>{t[r].forEach(({term:l,to:a})=>{if(!l)return;let h;for(let c=0;c<i.length;c++)i[c][0]==l&&(h=i[c][1]);$i(t,a).forEach(c=>{h||i.push([l,h=[]]),h.indexOf(c)==-1&&h.push(c)})})});let s=e[o.join(",")]=new ae(o.indexOf(t.length-1)>-1);for(let r=0;r<i.length;r++){let l=i[r][1].sort(Ks);s.next.push({type:i[r][0],next:e[l.join(",")]||n(l)})}return s}}function Ya(t,e){for(let n=0,o=[t];n<o.length;n++){let i=o[n],s=!i.validEnd,r=[];for(let l=0;l<i.next.length;l++){let{type:a,next:h}=i.next[l];r.push(a.name),s&&!(a.isText||a.hasRequiredAttrs())&&(s=!1),o.indexOf(h)==-1&&o.push(h)}s&&e.err("Only non-generatable nodes ("+r.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Hs(t){let e=Object.create(null);for(let n in t){let o=t[n];if(!o.hasDefault)return null;e[n]=o.default}return e}function Us(t,e){let n=Object.create(null);for(let o in t){let i=t[o],s=e&&e[o];if(s===void 0)if(i.hasDefault)s=i.default;else throw new RangeError("No value supplied for attribute "+o);else i.validate&&i.validate(s);n[o]=s}return n}function Gs(t,e){let n=Object.create(null);if(e)for(let o in e)n[o]=new Qa(t,o,e[o]);return n}var mo=class Ys{constructor(e,n,o){this.name=e,this.schema=n,this.spec=o,this.markSet=null,this.groups=o.group?o.group.split(" "):[],this.attrs=Gs(e,o.attrs),this.defaultAttrs=Hs(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(o.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==ae.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:Us(this.attrs,e)}create(e=null,n,o){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new $t(this,this.computeAttrs(e),b.from(n),E.setFrom(o))}createChecked(e=null,n,o){return n=b.from(n),this.checkContent(n),new $t(this,this.computeAttrs(e),n,E.setFrom(o))}createAndFill(e=null,n,o){if(e=this.computeAttrs(e),n=b.from(n),n.size){let r=this.contentMatch.fillBefore(n);if(!r)return null;n=r.append(n)}let i=this.contentMatch.matchFragment(n),s=i&&i.fillBefore(b.empty,!0);return s?new $t(this,e,n.append(s),E.setFrom(o)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let o=0;o<e.childCount;o++)if(!this.allowsMarks(e.child(o).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 o=0;o<e.length;o++)this.allowsMarkType(e[o].type)?n&&n.push(e[o]):n||(n=e.slice(0,o));return n?n.length?n:E.none:e}static compile(e,n){let o=Object.create(null);e.forEach((s,r)=>o[s]=new Ys(s,n,r));let i=n.spec.topNode||"doc";if(!o[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!o.text)throw new RangeError("Every schema needs a 'text' type");for(let s in o.text.attrs)throw new RangeError("The text node type should not have attributes");return o}};function _a(t,e,n){let o=n.split("|");return i=>{let s=i===null?"null":typeof i;if(o.indexOf(s)<0)throw new RangeError(`Expected value of type ${o} for attribute ${e} on type ${t}, got ${s}`)}}var Qa=class{constructor(t,e,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate=typeof n.validate=="string"?_a(t,e,n.validate):n.validate}get isRequired(){return!this.hasDefault}},Po=class _s{constructor(e,n,o,i){this.name=e,this.rank=n,this.schema=o,this.spec=i,this.attrs=Gs(e,i.attrs),this.excluded=null;let s=Hs(this.attrs);this.instance=s?new E(this,s):null}create(e=null){return!e&&this.instance?this.instance:new E(this,Us(this.attrs,e))}static compile(e,n){let o=Object.create(null),i=0;return e.forEach((s,r)=>o[s]=new _s(s,i++,n,r)),o}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}},Za=class{constructor(t){this.linebreakReplacement=null,this.cached=Object.create(null);let e=this.spec={};for(let o in t)e[o]=t[o];e.nodes=Ai.from(t.nodes),e.marks=Ai.from(t.marks||{}),this.nodes=mo.compile(this.spec.nodes,this),this.marks=Po.compile(this.spec.marks,this);let n=Object.create(null);for(let o in this.nodes){if(o in this.marks)throw new RangeError(o+" can not be both a node and a mark");let i=this.nodes[o],s=i.spec.content||"",r=i.spec.marks;if(i.contentMatch=n[s]||(n[s]=ae.parse(s,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!i.isInline||!i.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=i}i.markSet=r=="_"?null:r?Ii(this,r.split(" ")):r==""||!i.inlineContent?[]:null}for(let o in this.marks){let i=this.marks[o],s=i.spec.excludes;i.excluded=s==null?[i]:s==""?[]:Ii(this,s.split(" "))}this.nodeFromJSON=o=>$t.fromJSON(this,o),this.markFromJSON=o=>E.fromJSON(this,o),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(t,e=null,n,o){if(typeof t=="string")t=this.nodeType(t);else if(t instanceof mo){if(t.schema!=this)throw new RangeError("Node type from different schema used ("+t.name+")")}else throw new RangeError("Invalid node type: "+t);return t.createChecked(e,n,o)}text(t,e){let n=this.nodes.text;return new ja(n,n.defaultAttrs,t,E.setFrom(e))}mark(t,e){return typeof t=="string"&&(t=this.marks[t]),t.create(e)}nodeType(t){let e=this.nodes[t];if(!e)throw new RangeError("Unknown node type: "+t);return e}};function Ii(t,e){let n=[];for(let o=0;o<e.length;o++){let i=e[o],s=t.marks[i],r=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(r=a)}if(!r)throw new SyntaxError("Unknown mark type: '"+e[o]+"'")}return n}function Xa(t){return t.tag!=null}function tc(t){return t.style!=null}var Bo=class go{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let o=this.matchedStyles=[];n.forEach(i=>{if(Xa(i))this.tags.push(i);else if(tc(i)){let s=/[^=]*/.exec(i.style)[0];o.indexOf(s)<0&&o.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 o=new Pi(this,n,!1);return o.addAll(e,E.none,n.from,n.to),o.finish()}parseSlice(e,n={}){let o=new Pi(this,n,!0);return o.addAll(e,E.none,n.from,n.to),x.maxOpen(o.finish())}matchTag(e,n,o){for(let i=o?this.tags.indexOf(o)+1:0;i<this.tags.length;i++){let s=this.tags[i];if(oc(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||n.matchesContext(s.context))){if(s.getAttrs){let r=s.getAttrs(e);if(r===!1)continue;s.attrs=r||void 0}return s}}}matchStyle(e,n,o,i){for(let s=i?this.styles.indexOf(i)+1:0;s<this.styles.length;s++){let r=this.styles[s],l=r.style;if(!(l.indexOf(e)!=0||r.context&&!o.matchesContext(r.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=n))){if(r.getAttrs){let a=r.getAttrs(n);if(a===!1)continue;r.attrs=a||void 0}return r}}}static schemaRules(e){let n=[];function o(i){let s=i.priority==null?50:i.priority,r=0;for(;r<n.length;r++){let l=n[r];if((l.priority==null?50:l.priority)<s)break}n.splice(r,0,i)}for(let i in e.marks){let s=e.marks[i].spec.parseDOM;s&&s.forEach(r=>{o(r=Bi(r)),r.mark||r.ignore||r.clearMark||(r.mark=i)})}for(let i in e.nodes){let s=e.nodes[i].spec.parseDOM;s&&s.forEach(r=>{o(r=Bi(r)),r.node||r.ignore||r.mark||(r.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new go(e,go.schemaRules(e)))}},Qs={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},ec={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Zs={ol:!0,ul:!0},Ve=1,yo=2,Ie=4;function Ri(t,e,n){return e!=null?(e?Ve:0)|(e==="full"?yo:0):t&&t.whitespace=="pre"?Ve|yo:n&~Ie}var un=class{constructor(t,e,n,o,i,s){this.type=t,this.attrs=e,this.marks=n,this.solid=o,this.options=s,this.content=[],this.activeMarks=E.none,this.match=i||(s&Ie?null:t.contentMatch)}findWrapping(t){if(!this.match){if(!this.type)return[];let e=this.type.contentMatch.fillBefore(b.from(t));if(e)this.match=this.type.contentMatch.matchFragment(e);else{let n=this.type.contentMatch,o;return(o=n.findWrapping(t.type))?(this.match=n,o):null}}return this.match.findWrapping(t.type)}finish(t){if(!(this.options&Ve)){let n=this.content[this.content.length-1],o;if(n&&n.isText&&(o=/[ \t\r\n\u000c]+$/.exec(n.text))){let i=n;n.text.length==o[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-o[0].length))}}let e=b.from(this.content);return!t&&this.match&&(e=e.append(this.match.fillBefore(b.empty,!0))),this.type?this.type.create(this.attrs,e,this.marks):e}inlineContext(t){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:t.parentNode&&!Qs.hasOwnProperty(t.parentNode.nodeName.toLowerCase())}},Pi=class{constructor(t,e,n){this.parser=t,this.options=e,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let o=e.topNode,i,s=Ri(null,e.preserveWhitespace,0)|(n?Ie:0);o?i=new un(o.type,o.attrs,E.none,!0,e.topMatch||o.type.contentMatch,s):n?i=new un(null,null,E.none,!0,null,s):i=new un(t.schema.topNodeType,null,E.none,!0,null,s),this.nodes=[i],this.find=e.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(t,e){t.nodeType==3?this.addTextNode(t,e):t.nodeType==1&&this.addElement(t,e)}addTextNode(t,e){let n=t.nodeValue,o=this.top,i=o.options&yo?"full":this.localPreserveWS||(o.options&Ve)>0,{schema:s}=this.parser;if(i==="full"||o.inlineContext(t)||/[^ \t\r\n\u000c]/.test(n)){if(i)if(i==="full")n=n.replace(/\r\n?/g,`
|
|
3
|
-
`);else if(s.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(s.linebreakReplacement.create())){let r=n.split(/\r?\n|\r/);for(let l=0;l<r.length;l++)l&&this.insertNode(s.linebreakReplacement.create(),e,!0),r[l]&&this.insertNode(s.text(r[l]),e,!/\S/.test(r[l]));n=""}else n=n.replace(/\r?\n|\r/g," ");else if(n=n.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let r=o.content[o.content.length-1],l=t.previousSibling;(!r||l&&l.nodeName=="BR"||r.isText&&/[ \t\r\n\u000c]$/.test(r.text))&&(n=n.slice(1))}n&&this.insertNode(s.text(n),e,!/\S/.test(n)),this.findInText(t)}else this.findInside(t)}addElement(t,e,n){let o=this.localPreserveWS,i=this.top;(t.tagName=="PRE"||/pre/.test(t.style&&t.style.whiteSpace))&&(this.localPreserveWS=!0);let s=t.nodeName.toLowerCase(),r;Zs.hasOwnProperty(s)&&this.parser.normalizeLists&&nc(t);let l=this.options.ruleFromNode&&this.options.ruleFromNode(t)||(r=this.parser.matchTag(t,this,n));t:if(l?l.ignore:ec.hasOwnProperty(s))this.findInside(t),this.ignoreFallback(t,e);else if(!l||l.skip||l.closeParent){l&&l.closeParent?this.open=Math.max(0,this.open-1):l&&l.skip.nodeType&&(t=l.skip);let a,h=this.needsBlock;if(Qs.hasOwnProperty(s))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),a=!0,i.type||(this.needsBlock=!0);else if(!t.firstChild){this.leafFallback(t,e);break t}let c=l&&l.skip?e:this.readStyles(t,e);c&&this.addAll(t,c),a&&this.sync(i),this.needsBlock=h}else{let a=this.readStyles(t,e);a&&this.addElementByRule(t,l,a,l.consuming===!1?r:void 0)}this.localPreserveWS=o}leafFallback(t,e){t.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(t.ownerDocument.createTextNode(`
|
|
4
|
-
`),e)}ignoreFallback(t,e){t.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),e,!0)}readStyles(t,e){let n=t.style;if(n&&n.length)for(let o=0;o<this.parser.matchedStyles.length;o++){let i=this.parser.matchedStyles[o],s=n.getPropertyValue(i);if(s)for(let r=void 0;;){let l=this.parser.matchStyle(i,s,this,r);if(!l)break;if(l.ignore)return null;if(l.clearMark?e=e.filter(a=>!l.clearMark(a)):e=e.concat(this.parser.schema.marks[l.mark].create(l.attrs)),l.consuming===!1)r=l;else break}}return e}addElementByRule(t,e,n,o){let i,s;if(e.node)if(s=this.parser.schema.nodes[e.node],s.isLeaf)this.insertNode(s.create(e.attrs),n,t.nodeName=="BR")||this.leafFallback(t,n);else{let l=this.enter(s,e.attrs||null,n,e.preserveWhitespace);l&&(i=!0,n=l)}else{let l=this.parser.schema.marks[e.mark];n=n.concat(l.create(e.attrs))}let r=this.top;if(s&&s.isLeaf)this.findInside(t);else if(o)this.addElement(t,n,o);else if(e.getContent)this.findInside(t),e.getContent(t,this.parser.schema).forEach(l=>this.insertNode(l,n,!1));else{let l=t;typeof e.contentElement=="string"?l=t.querySelector(e.contentElement):typeof e.contentElement=="function"?l=e.contentElement(t):e.contentElement&&(l=e.contentElement),this.findAround(t,l,!0),this.addAll(l,n),this.findAround(t,l,!1)}i&&this.sync(r)&&this.open--}addAll(t,e,n,o){let i=n||0;for(let s=n?t.childNodes[n]:t.firstChild,r=o==null?null:t.childNodes[o];s!=r;s=s.nextSibling,++i)this.findAtPoint(t,i),this.addDOM(s,e);this.findAtPoint(t,i)}findPlace(t,e,n){let o,i;for(let s=this.open,r=0;s>=0;s--){let l=this.nodes[s],a=l.findWrapping(t);if(a&&(!o||o.length>a.length+r)&&(o=a,i=l,!a.length))break;if(l.solid){if(n)break;r+=2}}if(!o)return null;this.sync(i);for(let s=0;s<o.length;s++)e=this.enterInner(o[s],null,e,!1);return e}insertNode(t,e,n){if(t.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(e=this.enterInner(i,null,e))}let o=this.findPlace(t,e,n);if(o){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(t.type));let s=E.none;for(let r of o.concat(t.marks))(i.type?i.type.allowsMarkType(r.type):zi(r.type,t.type))&&(s=r.addToSet(s));return i.content.push(t.mark(s)),!0}return!1}enter(t,e,n,o){let i=this.findPlace(t.create(e),n,!1);return i&&(i=this.enterInner(t,e,n,!0,o)),i}enterInner(t,e,n,o=!1,i){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(t);let r=Ri(t,i,s.options);s.options&Ie&&s.content.length==0&&(r|=Ie);let l=E.none;return n=n.filter(a=>(s.type?s.type.allowsMarkType(a.type):zi(a.type,t))?(l=a.addToSet(l),!1):!0),this.nodes.push(new un(t,e,l,o,null,r)),this.open++,n}closeExtra(t=!1){let e=this.nodes.length-1;if(e>this.open){for(;e>this.open;e--)this.nodes[e-1].content.push(this.nodes[e].finish(t));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(t){for(let e=this.open;e>=0;e--){if(this.nodes[e]==t)return this.open=e,!0;this.localPreserveWS&&(this.nodes[e].options|=Ve)}return!1}get currentPos(){this.closeExtra();let t=0;for(let e=this.open;e>=0;e--){let n=this.nodes[e].content;for(let o=n.length-1;o>=0;o--)t+=n[o].nodeSize;e&&t++}return t}findAtPoint(t,e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==t&&this.find[n].offset==e&&(this.find[n].pos=this.currentPos)}findInside(t){if(this.find)for(let e=0;e<this.find.length;e++)this.find[e].pos==null&&t.nodeType==1&&t.contains(this.find[e].node)&&(this.find[e].pos=this.currentPos)}findAround(t,e,n){if(t!=e&&this.find)for(let o=0;o<this.find.length;o++)this.find[o].pos==null&&t.nodeType==1&&t.contains(this.find[o].node)&&e.compareDocumentPosition(this.find[o].node)&(n?2:4)&&(this.find[o].pos=this.currentPos)}findInText(t){if(this.find)for(let e=0;e<this.find.length;e++)this.find[e].node==t&&(this.find[e].pos=this.currentPos-(t.nodeValue.length-this.find[e].offset))}matchesContext(t){if(t.indexOf("|")>-1)return t.split(/\s*\|\s*/).some(this.matchesContext,this);let e=t.split("/"),n=this.options.context,o=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),i=-(n?n.depth+1:0)+(o?0:1),s=(r,l)=>{for(;r>=0;r--){let a=e[r];if(a==""){if(r==e.length-1||r==0)continue;for(;l>=i;l--)if(s(r-1,l))return!0;return!1}else{let h=l>0||l==0&&o?this.nodes[l].type:n&&l>=i?n.node(l-i).type:null;if(!h||h.name!=a&&!h.isInGroup(a))return!1;l--}}return!0};return s(e.length-1,this.open)}textblockFromContext(){let t=this.options.context;if(t)for(let e=t.depth;e>=0;e--){let n=t.node(e).contentMatchAt(t.indexAfter(e)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let n=this.parser.schema.nodes[e];if(n.isTextblock&&n.defaultAttrs)return n}}};function nc(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let o=e.nodeType==1?e.nodeName.toLowerCase():null;o&&Zs.hasOwnProperty(o)&&n?(n.appendChild(e),e=n):o=="li"?n=e:o&&(n=null)}}function oc(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function Bi(t){let e={};for(let n in t)e[n]=t[n];return e}function zi(t,e){let n=e.schema.nodes;for(let o in n){let i=n[o];if(!i.allowsMarkType(t))continue;let s=[],r=l=>{s.push(l);for(let a=0;a<l.edgeCount;a++){let{type:h,next:c}=l.edge(a);if(h==e||s.indexOf(c)<0&&r(c))return!0}};if(r(i.contentMatch))return!0}}var He=class Xs{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},o){o||(o=fn(n).createDocumentFragment());let i=o,s=[];return e.forEach(r=>{if(s.length||r.marks.length){let l=0,a=0;for(;l<s.length&&a<r.marks.length;){let h=r.marks[a];if(!this.marks[h.type.name]){a++;continue}if(!h.eq(s[l][0])||h.type.spec.spanning===!1)break;l++,a++}for(;l<s.length;)i=s.pop()[1];for(;a<r.marks.length;){let h=r.marks[a++],c=this.serializeMark(h,r.isInline,n);c&&(s.push([h,i]),i.appendChild(c.dom),i=c.contentDOM||c.dom)}}i.appendChild(this.serializeNodeInner(r,n))}),o}serializeNodeInner(e,n){if(e.isText)return fn(n).createTextNode(e.text);let{dom:o,contentDOM:i}=wn(fn(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 o}serializeNode(e,n={}){let o=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(o),o=s.dom)}return o}serializeMark(e,n,o={}){let i=this.marks[e.type.name];return i&&wn(fn(o),i(e,n),null,e.attrs)}static renderSpec(e,n,o=null,i){return typeof n=="string"?{dom:e.createTextNode(n)}:wn(e,n,o,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Xs(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=Fi(e.nodes);return n.text||(n.text=o=>o.text),n}static marksFromSchema(e){return Fi(e.marks)}};function Fi(t){let e={};for(let n in t){let o=t[n].spec.toDOM;o&&(e[n]=o)}return e}function fn(t){return t.document||window.document}var Vi=new WeakMap;function ic(t){let e=Vi.get(t);return e===void 0&&Vi.set(t,e=sc(t)),e}function sc(t){let e=null;function n(o){if(o&&typeof o=="object")if(Array.isArray(o))if(typeof o[0]=="string")e||(e=[]),e.push(o);else for(let i=0;i<o.length;i++)n(o[i]);else for(let i in o)n(o[i])}return n(t),e}function wn(t,e,n,o){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(o&&(s=ic(o))&&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 r=i.indexOf(" ");r>0&&(n=i.slice(0,r),i=i.slice(r+1));let l,a=n?t.createElementNS(n,i):t.createElement(i),h=e[1],c=1;if(h&&typeof h=="object"&&h.nodeType==null&&!Array.isArray(h)){c=2;for(let d in h)if(h[d]!=null){let p=d.indexOf(" ");p>0?a.setAttributeNS(d.slice(0,p),d.slice(p+1),h[d]):d=="style"&&a.style?a.style.cssText=h[d]:a.setAttribute(d,h[d])}}for(let d=c;d<e.length;d++){let p=e[d];if(p===0){if(d<e.length-1||d>c)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:f,contentDOM:u}=wn(t,p,n,o);if(a.appendChild(f),u){if(l)throw new RangeError("Multiple content holes");l=u}}}return{dom:a,contentDOM:l}}var zo={};mt(zo,{AllSelection:()=>dt,EditorState:()=>Ec,NodeSelection:()=>O,Plugin:()=>fe,PluginKey:()=>Ho,Selection:()=>N,SelectionRange:()=>Nn,TextSelection:()=>A,Transaction:()=>yr});var pe={};mt(pe,{AddMarkStep:()=>$n,AddNodeMarkStep:()=>In,AttrStep:()=>Wo,DocAttrStep:()=>Ko,MapResult:()=>Cn,Mapping:()=>Fo,RemoveMarkStep:()=>ue,RemoveNodeMarkStep:()=>je,ReplaceAroundStep:()=>ut,ReplaceStep:()=>st,Step:()=>J,StepMap:()=>Rt,StepResult:()=>U,Transform:()=>ur,TransformError:()=>Ut,canJoin:()=>_t,canSplit:()=>Re,dropPoint:()=>qo,findWrapping:()=>Lo,insertPoint:()=>ar,joinPoint:()=>Jo,liftTarget:()=>Ue,replaceStep:()=>Ge});var tr=65535,er=Math.pow(2,16);function rc(t,e){return t+e*er}function ji(t){return t&tr}function lc(t){return(t-(t&tr))/er}var nr=1,or=2,vn=4,ir=8,Cn=class{constructor(t,e,n){this.pos=t,this.delInfo=e,this.recover=n}get deleted(){return(this.delInfo&ir)>0}get deletedBefore(){return(this.delInfo&(nr|vn))>0}get deletedAfter(){return(this.delInfo&(or|vn))>0}get deletedAcross(){return(this.delInfo&vn)>0}},Rt=class ee{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&ee.empty)return ee.empty}recover(e){let n=0,o=ji(e);if(!this.inverted)for(let i=0;i<o;i++)n+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[o*3]+n+lc(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,o){let i=0,s=this.inverted?2:1,r=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 h=this.ranges[l+s],c=this.ranges[l+r],d=a+h;if(e<=d){let p=h?e==a?-1:e==d?1:n:n,f=a+i+(p<0?0:c);if(o)return f;let u=e==(n<0?a:d)?null:rc(l/3,e-a),m=0;return h&&(m|=e==a?or:e==d?nr:vn,(n<0?e!=a:e!=d)&&(m|=ir)),new Cn(f,m,u)}i+=c-h}return o?e+i:new Cn(e+i,0,null)}touches(e,n){let o=0,i=ji(n),s=this.inverted?2:1,r=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?o:0);if(a>e)break;let h=this.ranges[l+s],c=a+h;if(e<=c&&l==i*3)return!0;o+=this.ranges[l+r]-h}return!1}forEach(e){let n=this.inverted?2:1,o=this.inverted?1:2;for(let i=0,s=0;i<this.ranges.length;i+=3){let r=this.ranges[i],l=r-(this.inverted?s:0),a=r+(this.inverted?0:s),h=this.ranges[i+n],c=this.ranges[i+o];e(l,l+h,a,a+c),s+=c-h}}invert(){return new ee(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?ee.empty:new ee(e<0?[0,-e,0]:[0,0,e])}};Rt.empty=new Rt([]);var Fo=class wo{constructor(e,n,o=0,i=e?e.length:0){this.mirror=n,this.from=o,this.to=i,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new wo(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,o=this._maps.length;n<e._maps.length;n++){let i=e.getMirror(n);this.appendMap(e._maps[n],i!=null&&i<n?o+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,o=this._maps.length+e._maps.length;n>=0;n--){let i=e.getMirror(n);this.appendMap(e._maps[n].invert(),i!=null&&i>n?o-i-1:void 0)}}invert(){let e=new wo;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let o=this.from;o<this.to;o++)e=this._maps[o].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,o){let i=0;for(let s=this.from;s<this.to;s++){let r=this._maps[s],l=r.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 o?e:new Cn(e,i,null)}},Yn=Object.create(null),J=class{getMap(){return Rt.empty}merge(t){return null}static fromJSON(t,e){if(!e||!e.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=Yn[e.stepType];if(!n)throw new RangeError(`No step type ${e.stepType} defined`);return n.fromJSON(t,e)}static jsonID(t,e){if(t in Yn)throw new RangeError("Duplicate use of step JSON ID "+t);return Yn[t]=e,e.prototype.jsonID=t,e}},U=class xe{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new xe(e,null)}static fail(e){return new xe(null,e)}static fromReplace(e,n,o,i){try{return xe.ok(e.replace(n,o,i))}catch(s){if(s instanceof le)return xe.fail(s.message);throw s}}};function Vo(t,e,n){let o=[];for(let i=0;i<t.childCount;i++){let s=t.child(i);s.content.size&&(s=s.copy(Vo(s.content,e,s))),s.isInline&&(s=e(s,n,i)),o.push(s)}return b.fromArray(o)}var $n=class ke extends J{constructor(e,n,o){super(),this.from=e,this.to=n,this.mark=o}apply(e){let n=e.slice(this.from,this.to),o=e.resolve(this.from),i=o.node(o.sharedDepth(this.to)),s=new x(Vo(n.content,(r,l)=>!r.isAtom||!l.type.allowsMarkType(this.mark.type)?r:r.mark(this.mark.addToSet(r.marks)),i),n.openStart,n.openEnd);return U.fromReplace(e,this.from,this.to,s)}invert(){return new ue(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),o=e.mapResult(this.to,-1);return n.deleted&&o.deleted||n.pos>=o.pos?null:new ke(n.pos,o.pos,this.mark)}merge(e){return e instanceof ke&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ke(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 ke(n.from,n.to,e.markFromJSON(n.mark))}};J.jsonID("addMark",$n);var ue=class Se extends J{constructor(e,n,o){super(),this.from=e,this.to=n,this.mark=o}apply(e){let n=e.slice(this.from,this.to),o=new x(Vo(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return U.fromReplace(e,this.from,this.to,o)}invert(){return new $n(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),o=e.mapResult(this.to,-1);return n.deleted&&o.deleted||n.pos>=o.pos?null:new Se(n.pos,o.pos,this.mark)}merge(e){return e instanceof Se&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Se(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 Se(n.from,n.to,e.markFromJSON(n.mark))}};J.jsonID("removeMark",ue);var In=class Oe extends J{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return U.fail("No node at mark step's position");let o=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return U.fromReplace(e,this.pos,this.pos+1,new x(b.from(o),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let o=this.mark.addToSet(n.marks);if(o.length==n.marks.length){for(let i=0;i<n.marks.length;i++)if(!n.marks[i].isInSet(o))return new Oe(this.pos,n.marks[i]);return new Oe(this.pos,this.mark)}}return new je(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Oe(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 Oe(n.pos,e.markFromJSON(n.mark))}};J.jsonID("addNodeMark",In);var je=class vo extends J{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return U.fail("No node at mark step's position");let o=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return U.fromReplace(e,this.pos,this.pos+1,new x(b.from(o),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new In(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new vo(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 vo(n.pos,e.markFromJSON(n.mark))}};J.jsonID("removeNodeMark",je);var st=class Ct extends J{constructor(e,n,o,i=!1){super(),this.from=e,this.to=n,this.slice=o,this.structure=i}apply(e){return this.structure&&bo(e,this.from,this.to)?U.fail("Structure replace would overwrite content"):U.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Rt([this.from,this.to-this.from,this.slice.size])}invert(e){return new Ct(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.to,-1),o=this.from==this.to&&Ct.MAP_BIAS<0?n:e.mapResult(this.from,1);return o.deletedAcross&&n.deletedAcross?null:new Ct(o.pos,Math.max(o.pos,n.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Ct)||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?x.empty:new x(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Ct(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?x.empty:new x(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Ct(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 Ct(n.from,n.to,x.fromJSON(e,n.slice),!!n.structure)}};st.MAP_BIAS=1;J.jsonID("replace",st);var ut=class bn extends J{constructor(e,n,o,i,s,r,l=!1){super(),this.from=e,this.to=n,this.gapFrom=o,this.gapTo=i,this.slice=s,this.insert=r,this.structure=l}apply(e){if(this.structure&&(bo(e,this.from,this.gapFrom)||bo(e,this.gapTo,this.to)))return U.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return U.fail("Gap is not a flat range");let o=this.slice.insertAt(this.insert,n.content);return o?U.fromReplace(e,this.from,this.to,o):U.fail("Content does not fit in gap")}getMap(){return new Rt([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 bn(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),o=e.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?o.pos:e.map(this.gapTo,1);return n.deletedAcross&&o.deletedAcross||i<n.pos||s>o.pos?null:new bn(n.pos,o.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 bn(n.from,n.to,n.gapFrom,n.gapTo,x.fromJSON(e,n.slice),n.insert,!!n.structure)}};J.jsonID("replaceAround",ut);function bo(t,e,n){let o=t.resolve(e),i=n-e,s=o.depth;for(;i>0&&s>0&&o.indexAfter(s)==o.node(s).childCount;)s--,i--;if(i>0){let r=o.node(s).maybeChild(o.indexAfter(s));for(;i>0;){if(!r||r.isLeaf)return!0;r=r.firstChild,i--}}return!1}function ac(t,e,n,o){let i=[],s=[],r,l;t.doc.nodesBetween(e,n,(a,h,c)=>{if(!a.isInline)return;let d=a.marks;if(!o.isInSet(d)&&c.type.allowsMarkType(o.type)){let p=Math.max(h,e),f=Math.min(h+a.nodeSize,n),u=o.addToSet(d);for(let m=0;m<d.length;m++)d[m].isInSet(u)||(r&&r.to==p&&r.mark.eq(d[m])?r.to=f:i.push(r=new ue(p,f,d[m])));l&&l.to==p?l.to=f:s.push(l=new $n(p,f,o))}}),i.forEach(a=>t.step(a)),s.forEach(a=>t.step(a))}function cc(t,e,n,o){let i=[],s=0;t.doc.nodesBetween(e,n,(r,l)=>{if(!r.isInline)return;s++;let a=null;if(o instanceof Po){let h=r.marks,c;for(;c=o.isInSet(h);)(a||(a=[])).push(c),h=c.removeFromSet(h)}else o?o.isInSet(r.marks)&&(a=[o]):a=r.marks;if(a&&a.length){let h=Math.min(l+r.nodeSize,n);for(let c=0;c<a.length;c++){let d=a[c],p;for(let f=0;f<i.length;f++){let u=i[f];u.step==s-1&&d.eq(i[f].style)&&(p=u)}p?(p.to=h,p.step=s):i.push({style:d,from:Math.max(l,e),to:h,step:s})}}}),i.forEach(r=>t.step(new ue(r.from,r.to,r.style)))}function jo(t,e,n,o=n.contentMatch,i=!0){let s=t.doc.nodeAt(e),r=[],l=e+1;for(let a=0;a<s.childCount;a++){let h=s.child(a),c=l+h.nodeSize,d=o.matchType(h.type);if(!d)r.push(new st(l,c,x.empty));else{o=d;for(let p=0;p<h.marks.length;p++)n.allowsMarkType(h.marks[p].type)||t.step(new ue(l,c,h.marks[p]));if(i&&h.isText&&n.whitespace!="pre"){let p,f=/\r?\n|\r/g,u;for(;p=f.exec(h.text);)u||(u=new x(b.from(n.schema.text(" ",n.allowedMarks(h.marks))),0,0)),r.push(new st(l+p.index,l+p.index+p[0].length,u))}}l=c}if(!o.validEnd){let a=o.fillBefore(b.empty,!0);t.replace(l,l,new x(a,0,0))}for(let a=r.length-1;a>=0;a--)t.step(r[a])}function hc(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function Ue(t){let e=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let n=t.depth,o=0,i=0;;--n){let s=t.$from.node(n),r=t.$from.index(n)+o,l=t.$to.indexAfter(n)-i;if(n<t.depth&&s.canReplace(r,l,e))return n;if(n==0||s.type.spec.isolating||!hc(s,r,l))break;r&&(o=1),l<s.childCount&&(i=1)}return null}function dc(t,e,n){let{$from:o,$to:i,depth:s}=e,r=o.before(s+1),l=i.after(s+1),a=r,h=l,c=b.empty,d=0;for(let u=s,m=!1;u>n;u--)m||o.index(u)>0?(m=!0,c=b.from(o.node(u).copy(c)),d++):a--;let p=b.empty,f=0;for(let u=s,m=!1;u>n;u--)m||i.after(u+1)<i.end(u)?(m=!0,p=b.from(i.node(u).copy(p)),f++):h++;t.step(new ut(a,h,r,l,new x(c.append(p),d,f),c.size-d,!0))}function Lo(t,e,n=null,o=t){let i=pc(t,e),s=i&&uc(o,e);return s?i.map(Li).concat({type:e,attrs:n}).concat(s.map(Li)):null}function Li(t){return{type:t,attrs:null}}function pc(t,e){let{parent:n,startIndex:o,endIndex:i}=t,s=n.contentMatchAt(o).findWrapping(e);if(!s)return null;let r=s.length?s[0]:e;return n.canReplaceWith(o,i,r)?s:null}function uc(t,e){let{parent:n,startIndex:o,endIndex:i}=t,s=n.child(o),r=e.contentMatch.findWrapping(s.type);if(!r)return null;let l=(r.length?r[r.length-1]:e).contentMatch;for(let a=o;l&&a<i;a++)l=l.matchType(n.child(a).type);return!l||!l.validEnd?null:r}function fc(t,e,n){let o=b.empty;for(let r=n.length-1;r>=0;r--){if(o.size){let l=n[r].type.contentMatch.matchFragment(o);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}o=b.from(n[r].type.create(n[r].attrs,o))}let i=e.start,s=e.end;t.step(new ut(i,s,i,s,new x(o,0,0),n.length,!0))}function mc(t,e,n,o,i){if(!o.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=t.steps.length;t.doc.nodesBetween(e,n,(r,l)=>{let a=typeof i=="function"?i(r):i;if(r.isTextblock&&!r.hasMarkup(o,a)&&gc(t.doc,t.mapping.slice(s).map(l),o)){let h=null;if(o.schema.linebreakReplacement){let f=o.whitespace=="pre",u=!!o.contentMatch.matchType(o.schema.linebreakReplacement);f&&!u?h=!1:!f&&u&&(h=!0)}h===!1&&rr(t,r,l,s),jo(t,t.mapping.slice(s).map(l,1),o,void 0,h===null);let c=t.mapping.slice(s),d=c.map(l,1),p=c.map(l+r.nodeSize,1);return t.step(new ut(d,p,d+1,p-1,new x(b.from(o.create(a,null,r.marks)),0,0),1,!0)),h===!0&&sr(t,r,l,s),!1}})}function sr(t,e,n,o){e.forEach((i,s)=>{if(i.isText){let r,l=/\r?\n|\r/g;for(;r=l.exec(i.text);){let a=t.mapping.slice(o).map(n+1+s+r.index);t.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function rr(t,e,n,o){e.forEach((i,s)=>{if(i.type==i.type.schema.linebreakReplacement){let r=t.mapping.slice(o).map(n+1+s);t.replaceWith(r,r+1,e.type.schema.text(`
|
|
5
|
-
`))}})}function gc(t,e,n){let o=t.resolve(e),i=o.index();return o.parent.canReplaceWith(i,i+1,n)}function yc(t,e,n,o,i){let s=t.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");n||(n=s.type);let r=n.create(o,null,i||s.marks);if(s.isLeaf)return t.replaceWith(e,e+s.nodeSize,r);if(!n.validContent(s.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new ut(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new x(b.from(r),0,0),1,!0))}function Re(t,e,n=1,o){let i=t.resolve(e),s=i.depth-n,r=o&&o[o.length-1]||i.parent;if(s<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!r.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let h=i.depth-1,c=n-2;h>s;h--,c--){let d=i.node(h),p=i.index(h);if(d.type.spec.isolating)return!1;let f=d.content.cutByIndex(p,d.childCount),u=o&&o[c+1];u&&(f=f.replaceChild(0,u.type.create(u.attrs)));let m=o&&o[c]||d;if(!d.canReplace(p+1,d.childCount)||!m.type.validContent(f))return!1}let l=i.indexAfter(s),a=o&&o[0];return i.node(s).canReplaceWith(l,l,a?a.type:i.node(s+1).type)}function wc(t,e,n=1,o){let i=t.doc.resolve(e),s=b.empty,r=b.empty;for(let l=i.depth,a=i.depth-n,h=n-1;l>a;l--,h--){s=b.from(i.node(l).copy(s));let c=o&&o[h];r=b.from(c?c.type.create(c.attrs,r):i.node(l).copy(r))}t.step(new st(e,e,new x(s.append(r),n,n),!0))}function _t(t,e){let n=t.resolve(e),o=n.index();return lr(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(o,o+1)}function vc(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:o}=t.type.schema;for(let i=0;i<e.childCount;i++){let s=e.child(i),r=s.type==o?t.type.schema.nodes.text:s.type;if(n=n.matchType(r),!n||!t.type.allowsMarks(s.marks))return!1}return n.validEnd}function lr(t,e){return!!(t&&e&&!t.isLeaf&&vc(t,e))}function Jo(t,e,n=-1){let o=t.resolve(e);for(let i=o.depth;;i--){let s,r,l=o.index(i);if(i==o.depth?(s=o.nodeBefore,r=o.nodeAfter):n>0?(s=o.node(i+1),l++,r=o.node(i).maybeChild(l)):(s=o.node(i).maybeChild(l-1),r=o.node(i+1)),s&&!s.isTextblock&&lr(s,r)&&o.node(i).canReplace(l,l+1))return e;if(i==0)break;e=n<0?o.before(i):o.after(i)}}function bc(t,e,n){let o=null,{linebreakReplacement:i}=t.doc.type.schema,s=t.doc.resolve(e-n),r=s.node().type;if(i&&r.inlineContent){let c=r.whitespace=="pre",d=!!r.contentMatch.matchType(i);c&&!d?o=!1:!c&&d&&(o=!0)}let l=t.steps.length;if(o===!1){let c=t.doc.resolve(e+n);rr(t,c.node(),c.before(),l)}r.inlineContent&&jo(t,e+n-1,r,s.node().contentMatchAt(s.index()),o==null);let a=t.mapping.slice(l),h=a.map(e-n);if(t.step(new st(h,a.map(e+n,-1),x.empty,!0)),o===!0){let c=t.doc.resolve(h);sr(t,c.node(),c.before(),t.steps.length)}return t}function ar(t,e,n){let o=t.resolve(e);if(o.parent.canReplaceWith(o.index(),o.index(),n))return e;if(o.parentOffset==0)for(let i=o.depth-1;i>=0;i--){let s=o.index(i);if(o.node(i).canReplaceWith(s,s,n))return o.before(i+1);if(s>0)return null}if(o.parentOffset==o.parent.content.size)for(let i=o.depth-1;i>=0;i--){let s=o.indexAfter(i);if(o.node(i).canReplaceWith(s,s,n))return o.after(i+1);if(s<o.node(i).childCount)return null}return null}function qo(t,e,n){let o=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 r=o.depth;r>=0;r--){let l=r==o.depth?0:o.pos<=(o.start(r+1)+o.end(r+1))/2?-1:1,a=o.index(r)+(l>0?1:0),h=o.node(r),c=!1;if(s==1)c=h.canReplace(a,a,i);else{let d=h.contentMatchAt(a).findWrapping(i.firstChild.type);c=d&&h.canReplaceWith(a,a,d[0])}if(c)return l==0?o.pos:l<0?o.before(r+1):o.after(r+1)}return null}function Ge(t,e,n=e,o=x.empty){if(e==n&&!o.size)return null;let i=t.resolve(e),s=t.resolve(n);return cr(i,s,o)?new st(e,n,o):new xc(i,s,o).fit()}function cr(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}var xc=class{constructor(t,e,n){this.$from=t,this.$to=e,this.unplaced=n,this.frontier=[],this.placed=b.empty;for(let o=0;o<=t.depth;o++){let i=t.node(o);this.frontier.push({type:i.type,match:i.contentMatchAt(t.indexAfter(o))})}for(let o=t.depth;o>0;o--)this.placed=b.from(t.node(o).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let a=this.findFittable();a?this.placeNodes(a):this.openMore()||this.dropNode()}let t=this.mustMoveInline(),e=this.placed.size-this.depth-this.$from.depth,n=this.$from,o=this.close(t<0?this.$to:n.doc.resolve(t));if(!o)return null;let i=this.placed,s=n.depth,r=o.depth;for(;s&&r&&i.childCount==1;)i=i.firstChild.content,s--,r--;let l=new x(i,s,r);return t>-1?new ut(n.pos,t,this.$to.pos,this.$to.end(),l,e):l.size||n.pos!=this.$to.pos?new st(n.pos,o.pos,l):null}findFittable(){let t=this.unplaced.openStart;for(let e=this.unplaced.content,n=0,o=this.unplaced.openEnd;n<t;n++){let i=e.firstChild;if(e.childCount>1&&(o=0),i.type.spec.isolating&&o<=n){t=n;break}e=i.content}for(let e=1;e<=2;e++)for(let n=e==1?t:this.unplaced.openStart;n>=0;n--){let o,i=null;n?(i=Ji(this.unplaced.content,n-1).firstChild,o=i.content):o=this.unplaced.content;let s=o.firstChild;for(let r=this.depth;r>=0;r--){let{type:l,match:a}=this.frontier[r],h,c=null;if(e==1&&(s?a.matchType(s.type)||(c=a.fillBefore(b.from(s),!1)):i&&l.compatibleContent(i.type)))return{sliceDepth:n,frontierDepth:r,parent:i,inject:c};if(e==2&&s&&(h=a.findWrapping(s.type)))return{sliceDepth:n,frontierDepth:r,parent:i,wrap:h};if(i&&a.matchType(i.type))break}}}openMore(){let{content:t,openStart:e,openEnd:n}=this.unplaced;return qi(t,-1)<=e?!1:(this.unplaced.size>1&&qi(t,1)>n&&n++,this.unplaced=new x(t,e+1,n),!0)}dropNode(){let{content:t,openStart:e,openEnd:n}=this.unplaced,o=Ji(t,e);if(o.childCount<=1&&e>0){let i=t.size-e<=e+o.size;this.unplaced=new x(Me(t,e-1,1),e-1,i?e-1:n)}else this.unplaced=new x(Me(t,e,1),e,n)}placeNodes({sliceDepth:t,frontierDepth:e,parent:n,inject:o,wrap:i}){for(;this.depth>e;)this.closeFrontierNode();if(i)for(let u=0;u<i.length;u++)this.openFrontierNode(i[u]);let s=this.unplaced,r=n?n.content:s.content,l=s.openStart-t,a=0,h=[],{match:c,type:d}=this.frontier[e];if(o){for(let u=0;u<o.childCount;u++)h.push(o.child(u));c=c.matchFragment(o)}let p=r.size+t-(s.content.size-s.openEnd);for(;a<r.childCount;){let u=r.child(a),m=c.matchType(u.type);if(!m)break;a++,(a>1||l==0||u.content.size)&&(c=m,h.push(hr(u.mark(d.allowedMarks(u.marks)),a==1?l:0,a==r.childCount?p:-1)))}let f=a==r.childCount;f||(p=-1),this.placed=Ce(this.placed,e,b.from(h)),this.frontier[e].match=c,f&&p<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let u=0,m=r;u<p;u++){let g=m.lastChild;this.frontier.push({type:g.type,match:g.contentMatchAt(g.childCount)}),m=g.content}this.unplaced=f?t==0?x.empty:new x(Me(s.content,t-1,1),t-1,p<0?s.openEnd:t-1):new x(Me(s.content,t,a),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let t=this.frontier[this.depth],e;if(!t.type.isTextblock||!_n(this.$to,this.$to.depth,t.type,t.match,!1)||this.$to.depth==this.depth&&(e=this.findCloseLevel(this.$to))&&e.depth==this.depth)return-1;let{depth:n}=this.$to,o=this.$to.after(n);for(;n>1&&o==this.$to.end(--n);)++o;return o}findCloseLevel(t){t:for(let e=Math.min(this.depth,t.depth);e>=0;e--){let{match:n,type:o}=this.frontier[e],i=e<t.depth&&t.end(e+1)==t.pos+(t.depth-(e+1)),s=_n(t,e,o,n,i);if(s){for(let r=e-1;r>=0;r--){let{match:l,type:a}=this.frontier[r],h=_n(t,r,a,l,!0);if(!h||h.childCount)continue t}return{depth:e,fit:s,move:i?t.doc.resolve(t.after(e+1)):t}}}}close(t){let e=this.findCloseLevel(t);if(!e)return null;for(;this.depth>e.depth;)this.closeFrontierNode();e.fit.childCount&&(this.placed=Ce(this.placed,e.depth,e.fit)),t=e.move;for(let n=e.depth+1;n<=t.depth;n++){let o=t.node(n),i=o.type.contentMatch.fillBefore(o.content,!0,t.index(n));this.openFrontierNode(o.type,o.attrs,i)}return t}openFrontierNode(t,e=null,n){let o=this.frontier[this.depth];o.match=o.match.matchType(t),this.placed=Ce(this.placed,this.depth,b.from(t.create(e,n))),this.frontier.push({type:t,match:t.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(b.empty,!0);t.childCount&&(this.placed=Ce(this.placed,this.frontier.length,t))}};function Me(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Me(t.firstChild.content,e-1,n)))}function Ce(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Ce(t.lastChild.content,e-1,n)))}function Ji(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function hr(t,e,n){if(e<=0)return t;let o=t.content;return e>1&&(o=o.replaceChild(0,hr(o.firstChild,e-1,o.childCount==1?n-1:0))),e>0&&(o=t.type.contentMatch.fillBefore(o).append(o),n<=0&&(o=o.append(t.type.contentMatch.matchFragment(o).fillBefore(b.empty,!0)))),t.copy(o)}function _n(t,e,n,o,i){let s=t.node(e),r=i?t.indexAfter(e):t.index(e);if(r==s.childCount&&!n.compatibleContent(s.type))return null;let l=o.fillBefore(s.content,!0,r);return l&&!kc(n,s.content,r)?l:null}function kc(t,e,n){for(let o=n;o<e.childCount;o++)if(!t.allowsMarks(e.child(o).marks))return!0;return!1}function Sc(t){return t.spec.defining||t.spec.definingForContent}function qi(t,e){for(let n=0;;n++){let o=e<0?t.firstChild:t.lastChild;if(!o||o.isAtom)return n;t=o.content}}function Oc(t,e,n,o){if(!o.size)return t.deleteRange(e,n);let i=t.doc.resolve(e),s=t.doc.resolve(n);if(cr(i,s,o))return t.step(new st(e,n,o));let r=pr(i,s);r[r.length-1]==0&&r.pop();let l=-(i.depth+1);r.unshift(l);for(let p=i.depth,f=i.pos-1;p>0;p--,f--){let u=i.node(p).type.spec;if(u.defining||u.definingAsContext||u.isolating)break;r.indexOf(p)>-1?l=p:i.before(p)==f&&r.splice(1,0,-p)}let a=r.indexOf(l),h=[],c=o.openStart;for(let p=o.content,f=0;;f++){let u=p.firstChild;if(h.push(u),f==o.openStart)break;p=u.content}for(let p=c-1;p>=0;p--){let f=h[p],u=Sc(f.type);if(u&&!f.sameMarkup(i.node(Math.abs(l)-1)))c=p;else if(u||!f.type.isTextblock)break}for(let p=o.openStart;p>=0;p--){let f=(p+c+1)%(o.openStart+1),u=h[f];if(u)for(let m=0;m<r.length;m++){let g=r[(m+a)%r.length],v=!0;g<0&&(v=!1,g=-g);let y=i.node(g-1),w=i.index(g-1);if(y.canReplaceWith(w,w,u.type,u.marks))return t.replace(i.before(g),v?s.after(g):n,new x(dr(o.content,0,o.openStart,f),f,o.openEnd))}}let d=t.steps.length;for(let p=r.length-1;p>=0&&(t.replace(e,n,o),!(t.steps.length>d));p--){let f=r[p];f<0||(e=i.before(f),n=s.after(f))}}function dr(t,e,n,o,i){if(e<n){let s=t.firstChild;t=t.replaceChild(0,s.copy(dr(s.content,e+1,n,o,s)))}if(e>o){let s=i.contentMatchAt(0),r=s.fillBefore(t).append(t);t=r.append(s.matchFragment(r).fillBefore(b.empty,!0))}return t}function Mc(t,e,n,o){if(!o.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=ar(t.doc,e,o.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new x(b.from(o),0,0))}function Cc(t,e,n){let o=t.doc.resolve(e),i=t.doc.resolve(n);if(o.parent.isTextblock&&i.parent.isTextblock&&o.start()!=i.start()&&o.parentOffset==0&&i.parentOffset==0){let r=o.sharedDepth(n),l=!1;for(let a=o.depth;a>r;a--)o.node(a).type.spec.isolating&&(l=!0);for(let a=i.depth;a>r;a--)i.node(a).type.spec.isolating&&(l=!0);if(!l){for(let a=o.depth;a>0&&e==o.start(a);a--)e=o.before(a);for(let a=i.depth;a>0&&n==i.start(a);a--)n=i.before(a);o=t.doc.resolve(e),i=t.doc.resolve(n)}}let s=pr(o,i);for(let r=0;r<s.length;r++){let l=s[r],a=r==s.length-1;if(a&&l==0||o.node(l).type.contentMatch.validEnd)return t.delete(o.start(l),i.end(l));if(l>0&&(a||o.node(l-1).canReplace(o.index(l-1),i.indexAfter(l-1))))return t.delete(o.before(l),i.after(l))}for(let r=1;r<=o.depth&&r<=i.depth;r++)if(e-o.start(r)==o.depth-r&&n>o.end(r)&&i.end(r)-n!=i.depth-r&&o.start(r-1)==i.start(r-1)&&o.node(r-1).canReplace(o.index(r-1),i.index(r-1)))return t.delete(o.before(r),n);t.delete(e,n)}function pr(t,e){let n=[],o=Math.min(t.depth,e.depth);for(let i=o;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}var Wo=class xn extends J{constructor(e,n,o){super(),this.pos=e,this.attr=n,this.value=o}apply(e){let n=e.nodeAt(this.pos);if(!n)return U.fail("No node at attribute step's position");let o=Object.create(null);for(let s in n.attrs)o[s]=n.attrs[s];o[this.attr]=this.value;let i=n.type.create(o,null,n.marks);return U.fromReplace(e,this.pos,this.pos+1,new x(b.from(i),0,n.isLeaf?0:1))}getMap(){return Rt.empty}invert(e){return new xn(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 xn(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 xn(n.pos,n.attr,n.value)}};J.jsonID("attr",Wo);var Ko=class xo extends J{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 o=e.type.create(n,e.content,e.marks);return U.ok(o)}getMap(){return Rt.empty}invert(e){return new xo(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 xo(n.attr,n.value)}};J.jsonID("docAttr",Ko);var Ut=class extends Error{};Ut=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};Ut.prototype=Object.create(Error.prototype);Ut.prototype.constructor=Ut;Ut.prototype.name="TransformError";var ur=class{constructor(t){this.doc=t,this.steps=[],this.docs=[],this.mapping=new Fo}get before(){return this.docs.length?this.docs[0]:this.doc}step(t){let e=this.maybeStep(t);if(e.failed)throw new Ut(e.failed);return this}maybeStep(t){let e=t.apply(this.doc);return e.failed||this.addStep(t,e.doc),e}get docChanged(){return this.steps.length>0}changedRange(){let t=1e9,e=-1e9;for(let n=0;n<this.mapping.maps.length;n++){let o=this.mapping.maps[n];n&&(t=o.map(t,1),e=o.map(e,-1)),o.forEach((i,s,r,l)=>{t=Math.min(t,r),e=Math.max(e,l)})}return t==1e9?null:{from:t,to:e}}addStep(t,e){this.docs.push(this.doc),this.steps.push(t),this.mapping.appendMap(t.getMap()),this.doc=e}replace(t,e=t,n=x.empty){let o=Ge(this.doc,t,e,n);return o&&this.step(o),this}replaceWith(t,e,n){return this.replace(t,e,new x(b.from(n),0,0))}delete(t,e){return this.replace(t,e,x.empty)}insert(t,e){return this.replaceWith(t,t,e)}replaceRange(t,e,n){return Oc(this,t,e,n),this}replaceRangeWith(t,e,n){return Mc(this,t,e,n),this}deleteRange(t,e){return Cc(this,t,e),this}lift(t,e){return dc(this,t,e),this}join(t,e=1){return bc(this,t,e),this}wrap(t,e){return fc(this,t,e),this}setBlockType(t,e=t,n,o=null){return mc(this,t,e,n,o),this}setNodeMarkup(t,e,n=null,o){return yc(this,t,e,n,o),this}setNodeAttribute(t,e,n){return this.step(new Wo(t,e,n)),this}setDocAttribute(t,e){return this.step(new Ko(t,e)),this}addNodeMark(t,e){return this.step(new In(t,e)),this}removeNodeMark(t,e){let n=this.doc.nodeAt(t);if(!n)throw new RangeError("No node at position "+t);if(e instanceof E)e.isInSet(n.marks)&&this.step(new je(t,e));else{let o=n.marks,i,s=[];for(;i=e.isInSet(o);)s.push(new je(t,i)),o=i.removeFromSet(o);for(let r=s.length-1;r>=0;r--)this.step(s[r])}return this}split(t,e=1,n){return wc(this,t,e,n),this}addMark(t,e,n){return ac(this,t,e,n),this}removeMark(t,e,n){return cc(this,t,e,n),this}clearIncompatible(t,e,n){return jo(this,t,e,n),this}},Qn=Object.create(null),N=class{constructor(t,e,n){this.$anchor=t,this.$head=e,this.ranges=n||[new Nn(t.min(e),t.max(e))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let t=this.ranges;for(let e=0;e<t.length;e++)if(t[e].$from.pos!=t[e].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(t,e=x.empty){let n=e.content.lastChild,o=null;for(let r=0;r<e.openEnd;r++)o=n,n=n.lastChild;let i=t.steps.length,s=this.ranges;for(let r=0;r<s.length;r++){let{$from:l,$to:a}=s[r],h=t.mapping.slice(i);t.replaceRange(h.map(l.pos),h.map(a.pos),r?x.empty:e),r==0&&Hi(t,i,(n?n.isInline:o&&o.isTextblock)?-1:1)}}replaceWith(t,e){let n=t.steps.length,o=this.ranges;for(let i=0;i<o.length;i++){let{$from:s,$to:r}=o[i],l=t.mapping.slice(n),a=l.map(s.pos),h=l.map(r.pos);i?t.deleteRange(a,h):(t.replaceRangeWith(a,h,e),Hi(t,n,e.isInline?-1:1))}}static findFrom(t,e,n=!1){let o=t.parent.inlineContent?new A(t):ne(t.node(0),t.parent,t.pos,t.index(),e,n);if(o)return o;for(let i=t.depth-1;i>=0;i--){let s=e<0?ne(t.node(0),t.node(i),t.before(i+1),t.index(i),e,n):ne(t.node(0),t.node(i),t.after(i+1),t.index(i)+1,e,n);if(s)return s}return null}static near(t,e=1){return this.findFrom(t,e)||this.findFrom(t,-e)||new dt(t.node(0))}static atStart(t){return ne(t,t,0,0,1)||new dt(t)}static atEnd(t){return ne(t,t,t.content.size,t.childCount,-1)||new dt(t)}static fromJSON(t,e){if(!e||!e.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=Qn[e.type];if(!n)throw new RangeError(`No selection type ${e.type} defined`);return n.fromJSON(t,e)}static jsonID(t,e){if(t in Qn)throw new RangeError("Duplicate use of selection JSON ID "+t);return Qn[t]=e,e.prototype.jsonID=t,e}getBookmark(){return A.between(this.$anchor,this.$head).getBookmark()}};N.prototype.visible=!0;var Nn=class{constructor(t,e){this.$from=t,this.$to=e}},Wi=!1;function Ki(t){!Wi&&!t.parent.inlineContent&&(Wi=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}var A=class Ne extends N{constructor(e,n=e){Ki(e),Ki(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let o=e.resolve(n.map(this.head));if(!o.parent.inlineContent)return N.near(o);let i=e.resolve(n.map(this.anchor));return new Ne(i.parent.inlineContent?i:o,o)}replace(e,n=x.empty){if(super.replace(e,n),n==x.empty){let o=this.$from.marksAcross(this.$to);o&&e.ensureMarks(o)}}eq(e){return e instanceof Ne&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new fr(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 Ne(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,o=n){let i=e.resolve(n);return new this(i,o==n?i:e.resolve(o))}static between(e,n,o){let i=e.pos-n.pos;if((!o||i)&&(o=i>=0?1:-1),!n.parent.inlineContent){let s=N.findFrom(n,o,!0)||N.findFrom(n,-o,!0);if(s)n=s.$head;else return N.near(n,o)}return e.parent.inlineContent||(i==0?e=n:(e=(N.findFrom(e,-o,!0)||N.findFrom(e,o,!0)).$anchor,e.pos<n.pos!=i<0&&(e=n))),new Ne(e,n)}};N.jsonID("text",A);var fr=class mr{constructor(e,n){this.anchor=e,this.head=n}map(e){return new mr(e.map(this.anchor),e.map(this.head))}resolve(e){return A.between(e.resolve(this.anchor),e.resolve(this.head))}},O=class Ae extends N{constructor(e){let n=e.nodeAfter,o=e.node(0).resolve(e.pos+n.nodeSize);super(e,o),this.node=n}map(e,n){let{deleted:o,pos:i}=n.mapResult(this.anchor),s=e.resolve(i);return o?N.near(s):new Ae(s)}content(){return new x(b.from(this.node),0,0)}eq(e){return e instanceof Ae&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Nc(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Ae(e.resolve(n.anchor))}static create(e,n){return new Ae(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}};O.prototype.visible=!1;N.jsonID("node",O);var Nc=class gr{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:o}=e.mapResult(this.anchor);return n?new fr(o,o):new gr(o)}resolve(e){let n=e.resolve(this.anchor),o=n.nodeAfter;return o&&O.isSelectable(o)?new O(n):N.near(n)}},dt=class kn extends N{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=x.empty){if(n==x.empty){e.delete(0,e.doc.content.size);let o=N.atStart(e.doc);o.eq(e.selection)||e.setSelection(o)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new kn(e)}map(e){return new kn(e)}eq(e){return e instanceof kn}getBookmark(){return Ac}};N.jsonID("all",dt);var Ac={map(){return this},resolve(t){return new dt(t)}};function ne(t,e,n,o,i,s=!1){if(e.inlineContent)return A.create(t,n);for(let r=o-(i>0?0:1);i>0?r<e.childCount:r>=0;r+=i){let l=e.child(r);if(l.isAtom){if(!s&&O.isSelectable(l))return O.create(t,n-(i<0?l.nodeSize:0))}else{let a=ne(t,l,n+i,i<0?l.childCount:0,i,s);if(a)return a}n+=l.nodeSize*i}return null}function Hi(t,e,n){let o=t.steps.length-1;if(o<e)return;let i=t.steps[o];if(!(i instanceof st||i instanceof ut))return;let s=t.mapping.maps[o],r;s.forEach((l,a,h,c)=>{r==null&&(r=c)}),t.setSelection(N.near(t.doc.resolve(r),n))}var Ui=1,mn=2,Gi=4,yr=class extends ur{constructor(t){super(t.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=t.selection,this.storedMarks=t.storedMarks}get selection(){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(t){if(t.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=t,this.curSelectionFor=this.steps.length,this.updated=(this.updated|Ui)&~mn,this.storedMarks=null,this}get selectionSet(){return(this.updated&Ui)>0}setStoredMarks(t){return this.storedMarks=t,this.updated|=mn,this}ensureMarks(t){return E.sameSet(this.storedMarks||this.selection.$from.marks(),t)||this.setStoredMarks(t),this}addStoredMark(t){return this.ensureMarks(t.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(t){return this.ensureMarks(t.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&mn)>0}addStep(t,e){super.addStep(t,e),this.updated=this.updated&~mn,this.storedMarks=null}setTime(t){return this.time=t,this}replaceSelection(t){return this.selection.replace(this,t),this}replaceSelectionWith(t,e=!0){let n=this.selection;return e&&(t=t.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||E.none))),n.replaceWith(this,t),this}deleteSelection(){return this.selection.replace(this),this}insertText(t,e,n){let o=this.doc.type.schema;if(e==null)return t?this.replaceSelectionWith(o.text(t),!0):this.deleteSelection();{if(n==null&&(n=e),!t)return this.deleteRange(e,n);let i=this.storedMarks;if(!i){let s=this.doc.resolve(e);i=n==e?s.marks():s.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(e,n,o.text(t,i)),!this.selection.empty&&this.selection.to==e+t.length&&this.setSelection(N.near(this.selection.$to)),this}}setMeta(t,e){return this.meta[typeof t=="string"?t:t.key]=e,this}getMeta(t){return this.meta[typeof t=="string"?t:t.key]}get isGeneric(){for(let t in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=Gi,this}get scrolledIntoView(){return(this.updated&Gi)>0}};function Yi(t,e){return!e||!t?t:t.bind(e)}var De=class{constructor(t,e,n){this.name=t,this.init=Yi(e.init,n),this.apply=Yi(e.apply,n)}},Dc=[new De("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new De("selection",{init(t,e){return t.selection||N.atStart(e.doc)},apply(t){return t.selection}}),new De("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,o){return o.selection.$cursor?t.storedMarks:null}}),new De("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})],Zn=class{constructor(t,e){this.schema=t,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Dc.slice(),e&&e.forEach(n=>{if(this.pluginsByKey[n.key])throw new RangeError("Adding different instances of a keyed plugin ("+n.key+")");this.plugins.push(n),this.pluginsByKey[n.key]=n,n.spec.state&&this.fields.push(new De(n.key,n.spec.state,n))})}},Ec=class Ee{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 o=0;o<this.config.plugins.length;o++)if(o!=n){let i=this.config.plugins[o];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],o=this.applyInner(e),i=null;for(;;){let s=!1;for(let r=0;r<this.config.plugins.length;r++){let l=this.config.plugins[r];if(l.spec.appendTransaction){let a=i?i[r].n:0,h=i?i[r].state:this,c=a<n.length&&l.spec.appendTransaction.call(l,a?n.slice(a):n,h,o);if(c&&o.filterTransaction(c,r)){if(c.setMeta("appendedTransaction",e),!i){i=[];for(let d=0;d<this.config.plugins.length;d++)i.push(d<r?{state:o,n:n.length}:{state:this,n:0})}n.push(c),o=o.applyInner(c),s=!0}i&&(i[r]={state:o,n:n.length})}}if(!s)return{state:o,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new Ee(this.config),o=this.config.fields;for(let i=0;i<o.length;i++){let s=o[i];n[s.name]=s.apply(e,this[s.name],this,n)}return n}get tr(){return new yr(this)}static create(e){let n=new Zn(e.doc?e.doc.type.schema:e.schema,e.plugins),o=new Ee(n);for(let i=0;i<n.fields.length;i++)o[n.fields[i].name]=n.fields[i].init(e,o);return o}reconfigure(e){let n=new Zn(this.schema,e.plugins),o=n.fields,i=new Ee(n);for(let s=0;s<o.length;s++){let r=o[s].name;i[r]=this.hasOwnProperty(r)?this[r]:o[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(o=>o.toJSON())),e&&typeof e=="object")for(let o in e){if(o=="doc"||o=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[o],s=i.spec.state;s&&s.toJSON&&(n[o]=s.toJSON.call(i,this[i.key]))}return n}static fromJSON(e,n,o){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new Zn(e.schema,e.plugins),s=new Ee(i);return i.fields.forEach(r=>{if(r.name=="doc")s.doc=$t.fromJSON(e.schema,n.doc);else if(r.name=="selection")s.selection=N.fromJSON(s.doc,n.selection);else if(r.name=="storedMarks")n.storedMarks&&(s.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(o)for(let l in o){let a=o[l],h=a.spec.state;if(a.key==r.name&&h&&h.fromJSON&&Object.prototype.hasOwnProperty.call(n,l)){s[r.name]=h.fromJSON.call(a,e,n[l],s);return}}s[r.name]=r.init(e,s)}}),s}};function wr(t,e,n){for(let o in t){let i=t[o];i instanceof Function?i=i.bind(e):o=="handleDOMEvents"&&(i=wr(i,e,{})),n[o]=i}return n}var fe=class{constructor(t){this.spec=t,this.props={},t.props&&wr(t.props,this,this.props),this.key=t.key?t.key.key:vr("plugin")}getState(t){return t[this.key]}},Xn=Object.create(null);function vr(t){return t in Xn?t+"$"+ ++Xn[t]:(Xn[t]=0,t+"$")}var Ho=class{constructor(t="key"){this.key=vr(t)}get(t){return t.config.pluginsByKey[this.key]}getState(t){return t[this.key]}},Tc={};mt(Tc,{Decoration:()=>zt,DecorationSet:()=>it,EditorView:()=>ll,__endComposition:()=>md,__parseFromClipboard:()=>fd});var V=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},ce=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e},ko=null,vt=function(t,e,n){let o=ko||(ko=document.createRange());return o.setEnd(t,n??t.nodeValue.length),o.setStart(t,e||0),o},$c=function(){ko=null},Gt=function(t,e,n,o){return n&&(_i(t,e,n,o,-1)||_i(t,e,n,o,1))},Ic=/^(img|br|input|textarea|hr)$/i;function _i(t,e,n,o,i){for(var s;;){if(t==n&&e==o)return!0;if(e==(i<0?0:H(t))){let r=t.parentNode;if(!r||!k(r)||Ye(t)||Ic.test(t.nodeName)||t.contentEditable=="false")return!1;e=V(t)+(i<0?0:1),t=r}else if(k(t)){let r=t.childNodes[e+(i<0?-1:0)];if(k(r)&&r.contentEditable=="false")if(!((s=r.pmViewDesc)===null||s===void 0)&&s.ignoreForSelection)e+=i;else return!1;else t=r,e=i<0?H(t):0}else return!1}}function H(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function k(t){return t.nodeType==1}function B(t){return t.nodeType==3}function Yt(t,e){return e?t.contains(k(e)?e:e.parentNode):!1}function Rc(t,e){for(;;){if(B(t)&&e)return t;if(k(t)&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1],e=H(t)}else if(t.parentNode&&!Ye(t))e=V(t),t=t.parentNode;else return null}}function Pc(t,e){for(;;){if(B(t)&&e<t.nodeValue.length)return t;if(k(t)&&e<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[e],e=0}else if(t.parentNode&&!Ye(t))e=V(t)+1,t=t.parentNode;else return null}}function Bc(t,e,n){for(let o=e==0,i=e==H(t);o||i;){if(t==n)return!0;let s=V(t);if(t=t.parentNode,!t)return!1;o=o&&s==0,i=i&&s==H(t)}}function Ye(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)}var Rn=function(t){return t.focusNode&&Gt(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function jt(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function zc(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Fc(t,e,n){if(t.caretPositionFromPoint)try{let o=t.caretPositionFromPoint(e,n);if(o)return{node:o.offsetNode,offset:Math.min(H(o.offsetNode),o.offset)}}catch{}if(t.caretRangeFromPoint){let o=t.caretRangeFromPoint(e,n);if(o)return{node:o.startContainer,offset:Math.min(H(o.startContainer),o.startOffset)}}}var ft=typeof navigator<"u"?navigator:null,Qi=typeof document<"u"?document:null,Bt=ft&&ft.userAgent||"",So=/Edge\/(\d+)/.exec(Bt),br=/MSIE \d/.exec(Bt),Oo=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Bt),tt=!!(br||Oo||So),It=br?document.documentMode:Oo?+Oo[1]:So?+So[1]:0,et=!tt&&/gecko\/(\d+)/i.test(Bt);et&&+(/Firefox\/(\d+)/.exec(Bt)||[0,0])[1];var Mo=!tt&&/Chrome\/(\d+)/.exec(Bt),j=!!Mo,xr=Mo?+Mo[1]:0,G=!tt&&!!ft&&/Apple Computer/.test(ft.vendor),he=G&&(/Mobile\/\w+/.test(Bt)||!!ft&&ft.maxTouchPoints>2),nt=he||(ft?/Mac/.test(ft.platform):!1),kr=ft?/Win/.test(ft.platform):!1,bt=/Android \d/.test(Bt),Pn=!!Qi&&"webkitFontSmoothing"in Qi.documentElement.style,Vc=Pn?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function jc(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 wt(t,e){return typeof t=="number"?t:t[e]}function Lc(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,o=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*o}}function Zi(t,e,n){if(!Co(e)&&e.left==0)return;let o=t.someProp("scrollThreshold")||0,i=t.someProp("scrollMargin")||5,s=t.dom.ownerDocument;for(let r=n||t.dom;r;){if(!k(r)){r=ce(r);continue}let l=r==s.body,a=l?jc(s):Lc(r),h=0,c=0;if(e.top<a.top+wt(o,"top")?c=-(a.top-e.top+wt(i,"top")):e.bottom>a.bottom-wt(o,"bottom")&&(c=e.bottom-e.top>a.bottom-a.top?e.top+wt(i,"top")-a.top:e.bottom-a.bottom+wt(i,"bottom")),e.left<a.left+wt(o,"left")?h=-(a.left-e.left+wt(i,"left")):e.right>a.right-wt(o,"right")&&(h=e.right-a.right+wt(i,"right")),h||c)if(l)s.defaultView.scrollBy(h,c);else{let p=r.scrollLeft,f=r.scrollTop;c&&(r.scrollTop+=c),h&&(r.scrollLeft+=h);let u=r.scrollLeft-p,m=r.scrollTop-f;e={left:e.left-u,top:e.top-m,right:e.right-u,bottom:e.bottom-m}}let d=l?"fixed":getComputedStyle(r).position;if(/^(fixed|sticky)$/.test(d))break;r=d=="absolute"?r.offsetParent:ce(r)}}function Jc(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),o,i;for(let s=(e.left+e.right)/2,r=n+1;r<Math.min(innerHeight,e.bottom);r+=5){let l=t.root.elementFromPoint(s,r);if(!l||l==t.dom||!t.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=n-20){o=l,i=a.top;break}}return{refDOM:o,refTop:i,stack:Sr(t.dom)}}function Sr(t){let e=[],n=t.ownerDocument;for(let o=t;o&&(e.push({dom:o,top:o.scrollTop,left:o.scrollLeft}),t!=n);o=ce(o));return e}function qc({refDOM:t,refTop:e,stack:n}){let o=t?t.getBoundingClientRect().top:0;Or(n,o==0?0:o-e)}function Or(t,e){for(let n=0;n<t.length;n++){let{dom:o,top:i,left:s}=t[n];o.scrollTop!=i+e&&(o.scrollTop=i+e),o.scrollLeft!=s&&(o.scrollLeft=s)}}var Zt=null;function Wc(t){if(t.setActive)return t.setActive();if(Zt)return t.focus(Zt);let e=Sr(t);t.focus(Zt==null?{get preventScroll(){return Zt={preventScroll:!0},!0}}:void 0),Zt||(Zt=!1,Or(e,0))}function Mr(t,e){let n,o=2e8,i,s=0,r=e.top,l=e.top,a,h;for(let c=t.firstChild,d=0;c;c=c.nextSibling,d++){let p;if(k(c))p=c.getClientRects();else if(B(c))p=vt(c).getClientRects();else continue;for(let f=0;f<p.length;f++){let u=p[f];if(u.top<=r&&u.bottom>=l){r=Math.max(u.bottom,r),l=Math.min(u.top,l);let m=u.left>e.left?u.left-e.left:u.right<e.left?e.left-u.right:0;if(m<o){n=c,o=m,i=m&&B(n)?{left:u.right<e.left?u.right:u.left,top:e.top}:e,k(c)&&m&&(s=d+(e.left>=(u.left+u.right)/2?1:0));continue}}else u.top>e.top&&!a&&u.left<=e.left&&u.right>=e.left&&(a=c,h={left:Math.max(u.left,Math.min(u.right,e.left)),top:u.top});!n&&(e.left>=u.right&&e.top>=u.top||e.left>=u.left&&e.top>=u.bottom)&&(s=d+1)}}return!n&&a&&(n=a,i=h,o=0),n&&B(n)?Kc(n,i):!n||o?{node:t,offset:s}:Mr(n,i)}function Kc(t,e){let n=t.nodeValue.length,o=document.createRange(),i;for(let s=0;s<n;s++){o.setEnd(t,s+1),o.setStart(t,s);let r=Nt(o,1);if(r.top!=r.bottom&&Uo(e,r)){i={node:t,offset:s+(e.left>=(r.left+r.right)/2?1:0)};break}}return o.detach(),i||{node:t,offset:0}}function Uo(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function Hc(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function Uc(t,e,n){let{node:o,offset:i}=Mr(e,n),s=-1;if(k(o)&&!o.firstChild){let r=o.getBoundingClientRect();s=r.left!=r.right&&n.left>(r.left+r.right)/2?1:-1}return t.docView.posFromDOM(o,i,s)}function Gc(t,e,n,o){let i=-1;for(let s=e,r=!1;s!=t.dom;){let l=t.docView.nearestDesc(s,!0),a;if(!l)return null;if(k(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)&&(!r&&a.left>o.left||a.top>o.top?i=l.posBefore:(!r&&a.right<o.left||a.bottom<o.top)&&(i=l.posAfter),r=!0),!l.contentDOM&&i<0&&!l.node.isText))return(l.node.isBlock?o.top<(a.top+a.bottom)/2:o.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 Cr(t,e,n){let o=t.childNodes.length;if(o&&n.top<n.bottom)for(let i=Math.max(0,Math.min(o-1,Math.floor(o*(e.top-n.top)/(n.bottom-n.top))-2)),s=i;;){let r=t.childNodes[s];if(k(r)){let l=r.getClientRects();for(let a=0;a<l.length;a++){let h=l[a];if(Uo(e,h))return Cr(r,e,h)}}if((s=(s+1)%o)==i)break}return t}function Yc(t,e){let n=t.dom.ownerDocument,o,i=0,s=Fc(n,e.left,e.top);s&&({node:o,offset:i}=s);let r=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),l;if(!r||!t.dom.contains(r)){let h=t.dom.getBoundingClientRect();if(!Uo(e,h)||(r=Cr(t.dom,e,h),!r))return null}if(G)for(let h=r;o&&h;h=ce(h))h.draggable&&(o=void 0);if(r=Hc(r,e),o){if(et&&k(o)&&(i=Math.min(i,o.childNodes.length),i<o.childNodes.length)){let c=o.childNodes[i],d;c.nodeName=="IMG"&&(d=c.getBoundingClientRect()).right<=e.left&&d.bottom>e.top&&i++}let h;Pn&&i&&k(o)&&k(h=o.childNodes[i-1])&&h.contentEditable=="false"&&h.getBoundingClientRect().top>=e.top&&i--,o==t.dom&&i==o.childNodes.length-1&&k(o.lastChild)&&e.top>o.lastChild.getBoundingClientRect().bottom?l=t.state.doc.content.size:(i==0||!k(o)||o.childNodes[i-1].nodeName!="BR")&&(l=Gc(t,o,i,e))}l==null&&(l=Uc(t,r,e));let a=t.docView.nearestDesc(r,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Co(t){return t.top<t.bottom||t.left<t.right}function Nt(t,e){let n=t.getClientRects();if(n.length){let o=n[e<0?0:n.length-1];if(Co(o))return o}return Array.prototype.find.call(n,Co)||t.getBoundingClientRect()}var _c=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Nr(t,e,n){let{node:o,offset:i,atom:s}=t.docView.domFromPos(e,n<0?-1:1),r=Pn||et;if(B(o))if(r&&(_c.test(o.nodeValue)||(n<0?!i:i==o.nodeValue.length))){let l=Nt(vt(o,i,i),n);if(et&&i&&/\s/.test(o.nodeValue[i-1])&&i<o.nodeValue.length){let a=Nt(vt(o,i-1,i-1),-1);if(a.top==l.top){let h=Nt(vt(o,i,i+1),-1);if(h.top!=l.top)return ve(h,h.left<a.left)}}return l}else{let l=i,a=i,h=n<0?1:-1;return n<0&&!i?(a++,h=-1):n>=0&&i==o.nodeValue.length?(l--,h=1):n<0?l--:a++,ve(Nt(vt(o,l,a),h),h<0)}if(!t.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&i&&(n<0||i==H(o))){let l=o.childNodes[i-1];if(k(l))return to(l.getBoundingClientRect(),!1)}if(s==null&&i<H(o)){let l=o.childNodes[i];if(k(l))return to(l.getBoundingClientRect(),!0)}return to(o.getBoundingClientRect(),n>=0)}if(s==null&&i&&(n<0||i==H(o))){let l=o.childNodes[i-1],a=B(l)?vt(l,H(l)-(r?0:1)):k(l)&&(l.nodeName!="BR"||!l.nextSibling)?l:null;if(a)return ve(Nt(a,1),!1)}if(s==null&&i<H(o)){let l=o.childNodes[i];for(;l.pmViewDesc&&l.pmViewDesc.ignoreForCoords;)l=l.nextSibling;let a=l?B(l)?vt(l,0,r?0:1):k(l)?l:null:null;if(a)return ve(Nt(a,-1),!0)}return ve(Nt(B(o)?vt(o):o,-n),n>=0)}function ve(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 to(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 Ar(t,e,n){let o=t.state,i=t.root.activeElement;o!=e&&t.updateState(e),i!=t.dom&&t.focus();try{return n()}finally{o!=e&&t.updateState(o),i!=t.dom&&i&&i.focus()}}function Qc(t,e,n){let o=e.selection,i=n=="up"?o.$from:o.$to;return Ar(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 r=Nr(t,i.pos,1);for(let l=s.firstChild;l;l=l.nextSibling){let a;if(k(l))a=l.getClientRects();else if(B(l))a=vt(l,0,l.nodeValue.length).getClientRects();else continue;for(let h=0;h<a.length;h++){let c=a[h];if(c.bottom>c.top+1&&(n=="up"?r.top-c.top>(c.bottom-r.top)*2:c.bottom-r.bottom>(r.bottom-c.top)*2))return!1}}return!0})}var Zc=/[\u0590-\u08ac]/;function Xc(t,e,n){let{$head:o}=e.selection;if(!o.parent.isTextblock)return!1;let i=o.parentOffset,s=!i,r=i==o.parent.content.size,l=t.domSelection();return l?!Zc.test(o.parent.textContent)||!l.modify?n=="left"||n=="backward"?s:r:Ar(t,e,()=>{let{focusNode:a,focusOffset:h,anchorNode:c,anchorOffset:d}=t.domSelectionRange(),p=l.caretBidiLevel;l.modify("move",n,"character");let f=o.depth?t.docView.domAfterPos(o.before()):t.dom,{focusNode:u,focusOffset:m}=t.domSelectionRange(),g=u&&!Yt(f,u)||a==u&&h==m;try{l.collapse(c,d),a&&(a!=c||h!=d)&&l.extend&&l.extend(a,h)}catch{}return p!=null&&(l.caretBidiLevel=p),g}):o.pos==o.start()||o.pos==o.end()}var Xi=null,ts=null,es=!1;function th(t,e,n){return Xi==e&&ts==n?es:(Xi=e,ts=n,es=n=="up"||n=="down"?Qc(t,e,n):Xc(t,e,n))}var ot=0,ns=1,Lt=2,at=3,_e=class{constructor(t,e,n,o){this.parent=t,this.children=e,this.dom=n,this.contentDOM=o,this.dirty=ot,n.pmViewDesc=this}matchesWidget(t){return!1}matchesMark(t){return!1}matchesNode(t,e,n){return!1}matchesHack(t){return!1}parseRule(t){return null}stopEvent(t){return!1}get size(){let t=0;for(let e=0;e<this.children.length;e++)t+=this.children[e].size;return t}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let t=0;t<this.children.length;t++)this.children[t].destroy()}posBeforeChild(t){for(let e=0,n=this.posAtStart;;e++){let o=this.children[e];if(o==t)return n;n+=o.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(t,e,n){if(this.contentDOM&&Yt(this.contentDOM,t))if(n<0){let i,s;if(t==this.contentDOM)i=t.childNodes[e-1];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;i=t.previousSibling}for(;i&&!((s=i.pmViewDesc)&&s.parent==this);)i=i.previousSibling;return i?this.posBeforeChild(s)+s.size:this.posAtStart}else{let i,s;if(t==this.contentDOM)i=t.childNodes[e];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;i=t.nextSibling}for(;i&&!((s=i.pmViewDesc)&&s.parent==this);)i=i.nextSibling;return i?this.posBeforeChild(s):this.posAtEnd}let o;if(t==this.dom&&this.contentDOM)o=e>V(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))o=!!(t.compareDocumentPosition(this.contentDOM)&4);else if(this.dom.firstChild){if(e==0)for(let i=t;;i=i.parentNode){if(i==this.dom){o=!1;break}if(i.previousSibling)break}if(o==null&&e==t.childNodes.length)for(let i=t;;i=i.parentNode){if(i==this.dom){o=!0;break}if(i.nextSibling)break}}return o??n>0?this.posAtEnd:this.posAtStart}nearestDesc(t,e=!1){for(let n=!0,o=t;o;o=o.parentNode){let i=this.getDesc(o),s;if(i&&(!e||i.node))if(n&&(s=i.nodeDOM)&&!(k(s)?Yt(s,t):s==t))n=!1;else return i}}getDesc(t){let e=t.pmViewDesc;for(let n=e;n;n=n.parent)if(n==this)return e}posFromDOM(t,e,n){for(let o=t;o;o=o.parentNode){let i=this.getDesc(o);if(i)return i.localPosFromDOM(t,e,n)}return-1}descAt(t){for(let e=0,n=0;e<this.children.length;e++){let o=this.children[e],i=n+o.size;if(n==t&&i!=n){for(;!o.border&&o.children.length;)for(let s=0;s<o.children.length;s++){let r=o.children[s];if(r.size){o=r;break}}return o}if(t<i)return o.descAt(t-n-o.border);n=i}}domFromPos(t,e){if(!this.contentDOM)return{node:this.dom,offset:0,atom:t+1};let n=0,o=0;for(let i=0;n<this.children.length;n++){let s=this.children[n],r=i+s.size;if(r>t){o=t-i;break}i=r}if(o)return this.children[n].domFromPos(o-this.children[n].border,e);for(;n>0;n--){let i=this.children[n-1];if(i.size||!(i instanceof Ir||i instanceof Dr&&i.side>=0))break}if(e<=0){let i,s=!0;for(;i=n?this.children[n-1]:null,!(!i||i.dom.parentNode==this.contentDOM);n--,s=!1);return i&&e&&s&&!i.border&&!i.domAtom?i.domFromPos(i.size,e):{node:this.contentDOM,offset:i?V(i.dom)+1:0}}else{let i,s=!0;for(;i=n<this.children.length?this.children[n]:null,!(!i||i.dom.parentNode==this.contentDOM);n++,s=!1);return i&&s&&!i.border&&!i.domAtom?i.domFromPos(0,e):{node:this.contentDOM,offset:i?V(i.dom):this.contentDOM.childNodes.length}}}parseRange(t,e,n=0){if(this.children.length==0)return{node:this.contentDOM,from:t,to:e,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let o=-1,i=-1;for(let s=n,r=0;;r++){let l=this.children[r],a=s+l.size;if(o==-1&&t<=a){let h=s+l.border;if(t>=h&&e<=a-l.border&&l.node&&l.contentDOM&&this.contentDOM.contains(l.contentDOM))return l.parseRange(t,e,h);t=s;for(let c=r;c>0;c--){let d=this.children[c-1];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(1)){o=V(d.dom)+1;break}t-=d.size}o==-1&&(o=0)}if(o>-1&&(a>e||r==this.children.length-1)){e=a;for(let h=r+1;h<this.children.length;h++){let c=this.children[h];if(c.size&&c.dom.parentNode==this.contentDOM&&!c.emptyChildAt(-1)){i=V(c.dom);break}e+=c.size}i==-1&&(i=this.contentDOM.childNodes.length);break}s=a}return{node:this.contentDOM,from:t,to:e,fromOffset:o,toOffset:i}}emptyChildAt(t){if(this.border||!this.contentDOM||!this.children.length)return!1;let e=this.children[t<0?0:this.children.length-1];return e.size==0||e.emptyChildAt(t)}domAfterPos(t){let{node:e,offset:n}=this.domFromPos(t,0);if(!k(e)||n==e.childNodes.length)throw new RangeError("No node after pos "+t);return e.childNodes[n]}setSelection(t,e,n,o=!1){let i=Math.min(t,e),s=Math.max(t,e);for(let p=0,f=0;p<this.children.length;p++){let u=this.children[p],m=f+u.size;if(i>f&&s<m)return u.setSelection(t-f-u.border,e-f-u.border,n,o);f=m}let r=this.domFromPos(t,t?-1:1),l=e==t?r:this.domFromPos(e,e?-1:1),a=n.root.getSelection(),h=n.domSelectionRange(),c=!1;if((et||G)&&t==e){let{node:p,offset:f}=r;if(B(p)){if(c=!!(f&&p.nodeValue[f-1]==`
|
|
6
|
-
`),c&&f==p.nodeValue.length)for(let u=p,m;u;u=u.parentNode){if(m=u.nextSibling){m.nodeName=="BR"&&(r=l={node:m.parentNode,offset:V(m)+1});break}let g=u.pmViewDesc;if(g&&g.node&&g.node.isBlock)break}}else{let u=p.childNodes[f-1];c=u&&(u.nodeName=="BR"||u.contentEditable=="false")}}if(et&&h.focusNode&&h.focusNode!=l.node&&k(h.focusNode)){let p=h.focusNode.childNodes[h.focusOffset];p&&p.contentEditable=="false"&&(o=!0)}if(!(o||c&&G)&&Gt(r.node,r.offset,h.anchorNode,h.anchorOffset)&&Gt(l.node,l.offset,h.focusNode,h.focusOffset))return;let d=!1;if((a.extend||t==e)&&!(c&&et)){a.collapse(r.node,r.offset);try{t!=e&&a.extend(l.node,l.offset),d=!0}catch{}}if(!d){if(t>e){let f=r;r=l,l=f}let p=document.createRange();p.setEnd(l.node,l.offset),p.setStart(r.node,r.offset),a.removeAllRanges(),a.addRange(p)}}ignoreMutation(t){return!this.contentDOM&&t.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(t,e){for(let n=0,o=0;o<this.children.length;o++){let i=this.children[o],s=n+i.size;if(n==s?t<=s&&e>=n:t<s&&e>n){let r=n+i.border,l=s-i.border;if(t>=r&&e<=l){this.dirty=t==n||e==s?Lt:ns,t==r&&e==l&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=at:i.markDirty(t-r,e-r);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?Lt:at}n=s}this.dirty=Lt}markParentsDirty(){let t=1;for(let e=this.parent;e;e=e.parent,t++){let n=t==1?Lt:ns;e.dirty<n&&(e.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(t){return!1}},Dr=class extends _e{constructor(t,e,n,o){let i,s=e.type.toDOM;if(typeof s=="function"&&(s=s(n,()=>{if(!i)return o;if(i.parent)return i.parent.posBeforeChild(i)})),!e.type.spec.raw){let r=k(s)?s:document.createElement("span");r!=s&&r.appendChild(s),r.hasAttribute("contenteditable")||(r.contentEditable="false"),r.classList.add("ProseMirror-widget")}super(t,[],s,null),this.widget=e,this.widget=e,i=this}matchesWidget(t){return this.dirty==ot&&t.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(t){let e=this.widget.spec.stopEvent;return e?e(t):!1}ignoreMutation(t){return t.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}},eh=class extends _e{constructor(t,e,n,o){super(t,[],e,null),this.textDOM=n,this.text=o}get size(){return this.text.length}localPosFromDOM(t,e){return t!=this.textDOM?this.posAtStart+(e?this.size:0):this.posAtStart+e}domFromPos(t){return{node:this.textDOM,offset:t}}ignoreMutation(t){return t.type==="characterData"&&t.target.nodeValue==t.oldValue}},Pe=class No extends _e{constructor(e,n,o,i,s){super(e,[],o,i),this.mark=n,this.spec=s}static create(e,n,o,i){let s=i.nodeViews[n.type.name],r=s&&s(n,i,o);return(!r||!r.dom)&&(r=He.renderSpec(document,n.type.spec.toDOM(n,o),null,n.attrs)),new No(e,n,r.dom,r.contentDOM||r.dom,r)}parseRule(){return this.dirty&at||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=at&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=ot){let o=this.parent;for(;!o.node;)o=o.parent;o.dirty<this.dirty&&(o.dirty=this.dirty),this.dirty=ot}}slice(e,n,o){let i=No.create(this.parent,this.mark,!0,o),s=this.children,r=this.size;n<r&&(s=Do(s,n,r,o)),e>0&&(s=Do(s,0,e,o));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()}},re=class Er extends _e{constructor(e,n,o,i,s,r,l){super(e,[],s,r),this.node=n,this.outerDeco=o,this.innerDeco=i,this.nodeDOM=l}static create(e,n,o,i,s,r){let l=s.nodeViews[n.type.name],a,h=l&&l(n,s,()=>{if(!a)return r;if(a.parent)return a.parent.posBeforeChild(a)},o,i),c=h&&h.dom,d=h&&h.contentDOM;if(n.isText){if(!c)c=document.createTextNode(n.text);else if(!B(c))throw new RangeError("Text must be rendered as a DOM text node")}else c||({dom:c,contentDOM:d}=He.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!d&&!n.isText&&c.nodeName!="BR"&&(c.hasAttribute("contenteditable")||(c.contentEditable="false"),n.type.spec.draggable&&(c.draggable=!0));let p=c;return c=Br(c,o,n),h?a=new nh(e,n,o,i,c,d||null,p,h):n.isText?new Tr(e,n,o,i,c,p):new Er(e,n,o,i,c,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 o=this.children.length-1;o>=0;o--){let i=this.children[o];if(this.dom.contains(i.dom.parentNode)){n.contentElement=i.dom.parentNode;break}}if(!n.contentElement){let o=e&&e.find(i=>k(i)&&e.indexOf(i.parentNode)<0&&this.dom.contains(i));o?n.contentElement=o:n.getContent=()=>b.empty}}return n}matchesNode(e,n,o){return this.dirty==ot&&e.eq(this.node)&&An(n,this.outerDeco)&&o.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let o=this.node.inlineContent,i=n,s=e.composing?this.localCompositionInfo(e,n):null,r=s&&s.pos>-1?s:null,l=s&&s.pos<0,a=new ih(this,r&&r.node,e),h=this.node.inlineContent,c=h&&this.node.isBlock;lh(this.node,this.innerDeco,(d,p,f)=>{d.spec.marks?a.syncToMarks(d.spec.marks,o,e,p):d.type.side>=0&&!f&&a.syncToMarks(p==this.node.childCount?E.none:this.node.child(p).marks,o,e,p),a.placeWidget(d,e,i)},(d,p,f,u)=>{a.syncToMarks(d.marks,o,e,u),c&&d.isAtom&&!d.isText&&a.addHackNode("IMG",a.top);let m;a.findNodeMatch(d,p,f,u)||l&&e.state.selection.from>i&&e.state.selection.to<i+d.nodeSize&&(m=a.findIndexWithChild(s.node))>-1&&a.updateNodeAt(d,p,f,m,e)||a.updateNextNode(d,p,f,e,u,i)||a.addNode(d,p,f,e,i),i+=d.nodeSize,h&&(c=d.isAtom&&!d.isText)}),a.syncToMarks([],o,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==Lt)&&(r&&this.protectLocalComposition(e,r),Rr(this.contentDOM,this.children,e),he&&ah(this.dom))}localCompositionInfo(e,n){let{from:o,to:i}=e.state.selection;if(!(e.state.selection instanceof A)||o<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 r=s.nodeValue,l=ch(this.node.content,r,o-n,i-n);return l<0?null:{node:s,pos:l,text:r}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:o,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 r=new eh(this,s,n,i);e.input.compositionNodes.push(r),this.children=Do(this.children,o,o+i.length,e,r)}update(e,n,o,i){return this.dirty==at||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,o,i),!0)}updateInner(e,n,o,i){this.updateOuterDeco(n),this.node=e,this.innerDeco=o,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=ot}updateOuterDeco(e){if(An(e,this.outerDeco))return;let n=!k(this.nodeDOM),o=this.dom;this.dom=Pr(this.dom,this.nodeDOM,Ao(this.outerDeco,this.node,n),Ao(e,this.node,n)),this.dom!=o&&(o.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){k(this.nodeDOM)&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){k(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 is(t,e,n,o,i){Br(o,e,t);let s=new re(void 0,t,e,n,o,o,o);return s.contentDOM&&s.updateChildren(i,0),s}var Tr=class $r extends re{constructor(e,n,o,i,s,r){super(e,n,o,i,s,null,r)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,o,i){return this.dirty==at||this.dirty!=ot&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=ot||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=ot,!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,o){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,o)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,o){let i=this.node.cut(e,n),s=document.createTextNode(i.text);return new $r(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=at)}get domAtom(){return!1}isText(e){return this.node.text==e}},Ir=class extends _e{parseRule(){return{ignore:!0}}matchesHack(t){return this.dirty==ot&&this.dom.nodeName==t}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}},nh=class extends re{constructor(t,e,n,o,i,s,r,l){super(t,e,n,o,i,s,r),this.spec=l}update(t,e,n,o){if(this.dirty==at)return!1;if(this.spec.update&&(this.node.type==t.type||this.spec.multiType)){let i=this.spec.update(t,e,n);return i&&this.updateInner(t,e,n,o),i}else return!this.contentDOM&&!t.isLeaf?!1:super.update(t,e,n,o)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(t,e,n,o){this.spec.setSelection?this.spec.setSelection(t,e,n.root):super.setSelection(t,e,n,o)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(t){return this.spec.stopEvent?this.spec.stopEvent(t):!1}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}};function Rr(t,e,n){let o=t.firstChild,i=!1;for(let s=0;s<e.length;s++){let r=e[s],l=r.dom;if(l.parentNode==t){for(;l!=o;)o=ss(o),i=!0;o=o.nextSibling}else i=!0,t.insertBefore(l,o);if(r instanceof Pe){let a=o?o.previousSibling:t.lastChild;Rr(r.contentDOM,r.children,n),o=a?a.nextSibling:t.firstChild}}for(;o;)o=ss(o),i=!0;i&&n.trackWrites==t&&(n.trackWrites=null)}var Be=function(t){t&&(this.nodeName=t)};Be.prototype=Object.create(null);var Jt=[new Be];function Ao(t,e,n){if(t.length==0)return Jt;let o=n?Jt[0]:new Be,i=[o];for(let s=0;s<t.length;s++){let r=t[s].type.attrs;if(r){r.nodeName&&i.push(o=new Be(r.nodeName));for(let l in r){let a=r[l];a!=null&&(n&&i.length==1&&i.push(o=new Be(e.isInline?"span":"div")),l=="class"?o.class=(o.class?o.class+" ":"")+a:l=="style"?o.style=(o.style?o.style+";":"")+a:l!="nodeName"&&(o[l]=a))}}}return i}function Pr(t,e,n,o){if(n==Jt&&o==Jt)return e;let i=e;for(let s=0;s<o.length;s++){let r=o[s],l=n[s];if(s){let a;l&&l.nodeName==r.nodeName&&i!=t&&(a=i.parentNode)&&a.nodeName.toLowerCase()==r.nodeName||(a=document.createElement(r.nodeName),a.pmIsDeco=!0,a.appendChild(i),l=Jt[0]),i=a}oh(i,l||Jt[0],r)}return i}function oh(t,e,n){for(let o in e)o!="class"&&o!="style"&&o!="nodeName"&&!(o in n)&&t.removeAttribute(o);for(let o in n)o!="class"&&o!="style"&&o!="nodeName"&&n[o]!=e[o]&&t.setAttribute(o,n[o]);if(e.class!=n.class){let o=e.class?e.class.split(" ").filter(Boolean):[],i=n.class?n.class.split(" ").filter(Boolean):[];for(let s=0;s<o.length;s++)i.indexOf(o[s])==-1&&t.classList.remove(o[s]);for(let s=0;s<i.length;s++)o.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 o=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=o.exec(e.style);)t.style.removeProperty(i[1])}n.style&&(t.style.cssText+=n.style)}}function Br(t,e,n){return Pr(t,t,Jt,Ao(e,n,!k(t)))}function An(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 ss(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}var ih=class{constructor(t,e,n){this.lock=e,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=t,this.preMatch=sh(t.node.content,t)}destroyBetween(t,e){if(t!=e){for(let n=t;n<e;n++)this.top.children[n].destroy();this.top.children.splice(t,e-t),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(t,e,n,o){let i=0,s=this.stack.length>>1,r=Math.min(s,t.length);for(;i<r&&(i==s-1?this.top:this.stack[i+1<<1]).matchesMark(t[i])&&t[i].type.spec.spanning!==!1;)i++;for(;i<s;)this.destroyRest(),this.top.dirty=ot,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<t.length;){this.stack.push(this.top,this.index+1);let l=-1,a=this.top.children.length;o<this.preMatch.index&&(a=Math.min(this.index+3,a));for(let h=this.index;h<a;h++){let c=this.top.children[h];if(c.matchesMark(t[s])&&!this.isLocked(c.dom)){l=h;break}}if(l<0&&this.index<this.top.children.length){let h=this.top.children[this.index];h instanceof Pe&&h.dirty!=at&&h.mark.type==t[s].type&&h.spec.update&&!this.isLocked(h.dom)&&h.spec.update(t[s])&&(h.mark=t[s],l=this.index,this.changed=!0)}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let h=Pe.create(this.top,t[s],e,n);this.top.children.splice(this.index,0,h),this.top=h,this.changed=!0}this.index=0,s++}}findNodeMatch(t,e,n,o){let i=-1,s;if(o>=this.preMatch.index&&(s=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&s.matchesNode(t,e,n))i=this.top.children.indexOf(s,this.index);else for(let r=this.index,l=Math.min(this.top.children.length,r+5);r<l;r++){let a=this.top.children[r];if(a.matchesNode(t,e,n)&&!this.preMatch.matched.has(a)){i=r;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(t,e,n,o,i){let s=this.top.children[o];return s.dirty==at&&s.dom==s.contentDOM&&(s.dirty=Lt),s.update(t,e,n,i)?(this.destroyBetween(this.index,o),this.index++,!0):!1}findIndexWithChild(t){for(;;){let e=t.parentNode;if(!e)return-1;if(e==this.top.contentDOM){let n=t.pmViewDesc;if(n){for(let o=this.index;o<this.top.children.length;o++)if(this.top.children[o]==n)return o}return-1}t=e}}updateNextNode(t,e,n,o,i,s){for(let r=this.index;r<this.top.children.length;r++){let l=this.top.children[r];if(l instanceof re){let a=this.preMatch.matched.get(l);if(a!=null&&a!=i)return!1;let h=l.dom,c,d=this.isLocked(h)&&!(t.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==t.text&&l.dirty!=at&&An(e,l.outerDeco));if(!d&&l.update(t,e,n,o))return this.destroyBetween(this.index,r),l.dom!=h&&(this.changed=!0),this.index++,!0;if(!d&&(c=this.recreateWrapper(l,t,e,n,o,s)))return this.destroyBetween(this.index,r),this.top.children[this.index]=c,c.contentDOM&&(c.dirty=Lt,c.updateChildren(o,s+1),c.dirty=ot),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(t,e,n,o,i,s){if(t.dirty||e.isAtom||!t.children.length||!t.node.content.eq(e.content)||!An(n,t.outerDeco)||!o.eq(t.innerDeco))return null;let r=re.create(this.top,e,n,o,i,s);if(r.contentDOM){r.children=t.children,t.children=[];for(let l of r.children)l.parent=r}return t.destroy(),r}addNode(t,e,n,o,i){let s=re.create(this.top,t,e,n,o,i);s.contentDOM&&s.updateChildren(o,i+1),this.top.children.splice(this.index++,0,s),this.changed=!0}placeWidget(t,e,n){let o=this.index<this.top.children.length?this.top.children[this.index]:null;if(o&&o.matchesWidget(t)&&(t==o.widget||!o.widget.type.toDOM.parentNode))this.index++;else{let i=new Dr(this.top,t,e,n);this.top.children.splice(this.index++,0,i),this.changed=!0}}addTextblockHacks(){let t=this.top.children[this.index-1],e=this.top;for(;t instanceof Pe;)e=t,t=e.children[e.children.length-1];(!t||!(t instanceof Tr)||/\n$/.test(t.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(t.node.text))&&((G||j)&&t&&t.dom.contentEditable=="false"&&this.addHackNode("IMG",e),this.addHackNode("BR",this.top))}addHackNode(t,e){if(e==this.top&&this.index<e.children.length&&e.children[this.index].matchesHack(t))this.index++;else{let n=document.createElement(t);t=="IMG"&&(n.className="ProseMirror-separator",n.alt=""),t=="BR"&&(n.className="ProseMirror-trailingBreak");let o=new Ir(this.top,[],n,null);e!=this.top?e.children.push(o):e.children.splice(this.index++,0,o),this.changed=!0}}isLocked(t){return this.lock&&(t==this.lock||k(t)&&t.contains(this.lock.parentNode))}};function sh(t,e){let n=e,o=n.children.length,i=t.childCount,s=new Map,r=[];t:for(;i>0;){let l;for(;;)if(o){let h=n.children[o-1];if(h instanceof Pe)n=h,o=h.children.length;else{l=h,o--;break}}else{if(n==e)break t;o=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),r.push(l)}}return{index:i,matched:s,matches:r.reverse()}}function rh(t,e){return t.type.side-e.type.side}function lh(t,e,n,o){let i=e.locals(t),s=0;if(i.length==0){for(let h=0;h<t.childCount;h++){let c=t.child(h);o(c,i,e.forChild(s,c),h),s+=c.nodeSize}return}let r=0,l=[],a=null;for(let h=0;;){let c,d;for(;r<i.length&&i[r].to==s;){let g=i[r++];g.widget&&(c?(d||(d=[c])).push(g):c=g)}if(c)if(d){d.sort(rh);for(let g=0;g<d.length;g++)n(d[g],h,!!a)}else n(c,h,!!a);let p,f;if(a)f=-1,p=a,a=null;else if(h<t.childCount)f=h,p=t.child(h++);else break;for(let g=0;g<l.length;g++)l[g].to<=s&&l.splice(g--,1);for(;r<i.length&&i[r].from<=s&&i[r].to>s;)l.push(i[r++]);let u=s+p.nodeSize;if(p.isText){let g=u;r<i.length&&i[r].from<g&&(g=i[r].from);for(let v=0;v<l.length;v++)l[v].to<g&&(g=l[v].to);g<u&&(a=p.cut(g-s),p=p.cut(0,g-s),u=g,f=-1)}else for(;r<i.length&&i[r].to<u;)r++;let m=p.isInline&&!p.isLeaf?l.filter(g=>!g.inline):l.slice();o(p,m,e.forChild(s,p),f),s=u}}function ah(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 ch(t,e,n,o){for(let i=0,s=0;i<t.childCount&&s<=o;){let r=t.child(i++),l=s;if(s+=r.nodeSize,!r.isText)continue;let a=r.text;for(;i<t.childCount;){let h=t.child(i++);if(s+=h.nodeSize,!h.isText)break;a+=h.text}if(s>=n){if(s>=o&&a.slice(o-e.length-l,o-l)==e)return o-e.length;let h=l<o?a.lastIndexOf(e,o-l-1):-1;if(h>=0&&h+e.length+l>=n)return l+h;if(n==o&&a.length>=o+e.length-l&&a.slice(o-l,o-l+e.length)==e)return o}}return-1}function Do(t,e,n,o,i){let s=[];for(let r=0,l=0;r<t.length;r++){let a=t[r],h=l,c=l+=a.size;h>=n||c<=e?s.push(a):(h<e&&s.push(a.slice(0,e-h,o)),i&&(s.push(i),i=void 0),c>n&&s.push(a.slice(n-h,a.size,o)))}return s}function Go(t,e=null){let n=t.domSelectionRange(),o=t.state.doc;if(!n.focusNode)return null;let i=t.docView.nearestDesc(n.focusNode),s=i&&i.size==0,r=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(r<0)return null;let l=o.resolve(r),a,h;if(Rn(n)){for(a=r;i&&!i.node;)i=i.parent;if(i&&i.node.isAtom&&O.isSelectable(i.node)&&i.parent&&!(i.node.isInline&&Bc(n.focusNode,n.focusOffset,i.dom))){let d=i.posBefore;h=new O(r==d?l:o.resolve(d))}else if(et&&e=="key"&&r>t.state.selection.to&&k(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"){h=N.findFrom(o.resolve(i.posAtStart),1);break}if(d==i.dom||d.nextSibling||!d.parentNode||!k(d.parentNode))break}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let d=r,p=r;for(let f=0;f<n.rangeCount;f++){let u=n.getRangeAt(f);d=Math.min(d,t.docView.posFromDOM(u.startContainer,u.startOffset,1)),p=Math.max(p,t.docView.posFromDOM(u.endContainer,u.endOffset,-1))}if(d<0)return null;[a,r]=p==t.state.selection.anchor?[p,d]:[d,p],l=o.resolve(r)}else a=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(a<0)return null}let c=o.resolve(a);if(!h){let d=e=="pointer"||t.state.selection.head<l.pos&&!s?1:-1;h=Yo(t,c,l,d)}return h}function zr(t){return t.editable?t.hasFocus():Vr(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function kt(t,e=!1){let n=t.state.selection;if(Fr(t,n),!zr(t))return;let o=t.input.mouseDown;if(!e&&j&&o){let i=t.domSelectionRange(),s=t.domObserver.currentSelection;if(i.anchorNode&&s.anchorNode&&Gt(i.anchorNode,i.anchorOffset,s.anchorNode,s.anchorOffset)&&o.delaySelUpdate()){t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)dh(t);else{let{anchor:i,head:s}=n,r,l;rs&&!(n instanceof A)&&(n.$from.parent.inlineContent||(r=ls(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(l=ls(t,n.to))),t.docView.setSelection(i,s,t,e),rs&&(r&&as(r),l&&as(l)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&hh(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}var rs=G||j&&xr<63;function ls(t,e){let{node:n,offset:o}=t.docView.domFromPos(e,0),i=o<n.childNodes.length?n.childNodes[o]:null,s=o?n.childNodes[o-1]:null;if(G&&i&&i.contentEditable=="false")return eo(i);if((!i||i.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(i)return eo(i);if(s)return eo(s)}}function eo(t){return t.contentEditable="true",G&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function as(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function hh(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),o=n.anchorNode,i=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=o||n.anchorOffset!=i)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!zr(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function dh(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,o=n.nodeName=="IMG";o?e.collapse(n.parentNode,V(n)+1):e.collapse(n,0),!o&&!t.state.selection.visible&&tt&&It<=11&&(n.disabled=!0,n.disabled=!1)}function Fr(t,e){if(e instanceof O){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(cs(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else cs(t)}function cs(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Yo(t,e,n,o){return t.someProp("createSelectionBetween",i=>i(t,e,n))||A.between(e,n,o)}function hs(t){return t.editable&&!t.hasFocus()?!1:Vr(t)}function Vr(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return Yt(t.dom,e.anchorNode)&&(t.editable||Yt(t.dom,e.focusNode))}catch{return!1}}function ph(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Gt(e.node,e.offset,n.anchorNode,n.anchorOffset)}function Eo(t,e){let{$anchor:n,$head:o}=t.selection,i=e>0?n.max(o):n.min(o),s=i.parent.inlineContent?i.depth?t.doc.resolve(e>0?i.after():i.before()):null:i;return s&&N.findFrom(s,e)}function Et(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function ds(t,e,n){let o=t.state.selection;if(o instanceof A)if(n.indexOf("s")>-1){let{$head:i}=o,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let r=t.state.doc.resolve(i.pos+s.nodeSize*(e<0?-1:1));return Et(t,new A(o.$anchor,r))}else if(o.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=Eo(t.state,e);return i&&i instanceof O?Et(t,i):!1}else if(!(nt&&n.indexOf("m")>-1)){let i=o.$head,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,r;if(!s||s.isText)return!1;let l=e<0?i.pos-s.nodeSize:i.pos;return s.isAtom||(r=t.docView.descAt(l))&&!r.contentDOM?O.isSelectable(s)?Et(t,new O(e<0?t.state.doc.resolve(i.pos-s.nodeSize):i)):Et(t,new A(t.state.doc.resolve(e<0?l:l+s.nodeSize))):!1}}else return!1;else{if(o instanceof O&&o.node.isInline)return Et(t,new A(e>0?o.$to:o.$from));{let i=Eo(t.state,e);return i?Et(t,i):!1}}}function ze(t,e){let n=t.pmViewDesc;return n?n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR"):k(t)&&t.contentEditable=="false"}function Xt(t,e){return e<0?uh(t):fh(t)}function uh(t){let e=t.domSelectionRange(),n=e.focusNode,o=e.focusOffset;if(!n)return;let i,s,r=!1;for(et&&k(n)&&o<H(n)&&ze(n.childNodes[o],-1)&&(r=!0);;)if(o>0){if(!k(n))break;let l=n.childNodes[o-1];if(ze(l,-1))i=n,s=--o;else if(B(l))n=l,o=n.nodeValue.length;else break}else{if(jr(n))break;{let l=n.previousSibling;for(;l&&ze(l,-1);)i=n.parentNode,s=V(l),l=l.previousSibling;if(l)n=l,o=H(n);else{if(n=n.parentNode,n==t.dom)break;o=0}}}r?To(t,n,o):i&&To(t,i,s)}function fh(t){let e=t.domSelectionRange(),n=e.focusNode,o=e.focusOffset;if(!n)return;let i=H(n),s,r;for(;;)if(o<i){if(!k(n))break;let l=n.childNodes[o];if(ze(l,1))s=n,r=++o;else break}else{if(jr(n))break;{let l=n.nextSibling;for(;l&&ze(l,1);)s=l.parentNode,r=V(l)+1,l=l.nextSibling;if(l)n=l,o=0,i=H(n);else{if(n=n.parentNode,n==t.dom)break;o=i=0}}}s&&To(t,s,r)}function jr(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function mh(t,e){for(;t&&e==t.childNodes.length&&!Ye(t);)e=V(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let n=t.childNodes[e];if(B(n))return n;if(k(n)&&n.contentEditable=="false")break;t=n,e=0}}function gh(t,e){for(;t&&!e&&!Ye(t);)e=V(t),t=t.parentNode;for(;t&&e;){let n=t.childNodes[e-1];if(B(n))return n;if(k(n)&&n.contentEditable=="false")break;t=n,e=t.childNodes.length}}function To(t,e,n){if(!B(e)){let s,r;(r=mh(e,n))?(e=r,n=0):(s=gh(e,n))&&(e=s,n=s.nodeValue.length)}let o=t.domSelection();if(!o)return;if(Rn(o)){let s=document.createRange();s.setEnd(e,n),s.setStart(e,n),o.removeAllRanges(),o.addRange(s)}else o.extend&&o.extend(e,n);t.domObserver.setCurSelection();let{state:i}=t;setTimeout(()=>{t.state==i&&kt(t)},50)}function ps(t,e){let n=t.state.doc.resolve(e);if(!(j||kr)&&n.parent.inlineContent){let o=t.coordsAtPos(e);if(e>n.start()){let i=t.coordsAtPos(e-1),s=(i.top+i.bottom)/2;if(s>o.top&&s<o.bottom&&Math.abs(i.left-o.left)>1)return i.left<o.left?"ltr":"rtl"}if(e<n.end()){let i=t.coordsAtPos(e+1),s=(i.top+i.bottom)/2;if(s>o.top&&s<o.bottom&&Math.abs(i.left-o.left)>1)return i.left>o.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function us(t,e,n){let o=t.state.selection;if(o instanceof A&&!o.empty||n.indexOf("s")>-1||nt&&n.indexOf("m")>-1)return!1;let{$from:i,$to:s}=o;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let r=Eo(t.state,e);if(r&&r instanceof O)return Et(t,r)}if(!i.parent.inlineContent){let r=e<0?i:s,l=o instanceof dt?N.near(r,e):N.findFrom(r,e);return l?Et(t,l):!1}return!1}function fs(t,e){if(!(t.state.selection instanceof A))return!0;let{$head:n,$anchor:o,empty:i}=t.state.selection;if(!n.sameParent(o))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 r=t.state.tr;return e<0?r.delete(n.pos-s.nodeSize,n.pos):r.delete(n.pos,n.pos+s.nodeSize),t.dispatch(r),!0}return!1}function ms(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function yh(t){if(!G||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&k(e)&&n==0&&e.firstChild&&k(e.firstChild)&&e.firstChild.contentEditable=="false"){let o=e.firstChild;ms(t,o,"true"),setTimeout(()=>ms(t,o,"false"),20)}return!1}function wh(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function vh(t,e){let n=e.keyCode,o=wh(e);if(n==8||nt&&n==72&&o=="c")return fs(t,-1)||Xt(t,-1);if(n==46&&!e.shiftKey||nt&&n==68&&o=="c")return fs(t,1)||Xt(t,1);if(n==13||n==27)return!0;if(n==37||nt&&n==66&&o=="c"){let i=n==37?ps(t,t.state.selection.from)=="ltr"?-1:1:-1;return ds(t,i,o)||Xt(t,i)}else if(n==39||nt&&n==70&&o=="c"){let i=n==39?ps(t,t.state.selection.from)=="ltr"?1:-1:1;return ds(t,i,o)||Xt(t,i)}else{if(n==38||nt&&n==80&&o=="c")return us(t,-1,o)||Xt(t,-1);if(n==40||nt&&n==78&&o=="c")return yh(t)||us(t,1,o)||Xt(t,1);if(o==(nt?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function _o(t,e){t.someProp("transformCopied",f=>{e=f(e,t)});let n=[],{content:o,openStart:i,openEnd:s}=e;for(;i>1&&s>1&&o.childCount==1&&o.firstChild.childCount==1;){i--,s--;let f=o.firstChild;n.push(f.type.name,f.attrs!=f.type.defaultAttrs?f.attrs:null),o=f.content}let r=t.someProp("clipboardSerializer")||He.fromSchema(t.state.schema),l=Kr(),a=l.createElement("div");a.appendChild(r.serializeFragment(o,{document:l}));let h=a.firstChild,c,d=0;for(;h&&k(h)&&(c=Wr[h.nodeName.toLowerCase()]);){for(let f=c.length-1;f>=0;f--){let u=l.createElement(c[f]);for(;a.firstChild;)u.appendChild(a.firstChild);a.appendChild(u),d++}h=a.firstChild}h&&k(h)&&h.setAttribute("data-pm-slice",`${i} ${s}${d?` -${d}`:""} ${JSON.stringify(n)}`);let p=t.someProp("clipboardTextSerializer",f=>f(e,t))||e.content.textBetween(0,e.content.size,`
|
|
7
|
-
|
|
8
|
-
`);return{dom:a,text:p,slice:e}}function Qo(t,e,n,o,i){let s=i.parent.type.spec.code,r,l;if(!n&&!e)return null;let a=!!e&&(o||s||!n);if(a){if(t.someProp("transformPastedText",p=>{e=p(e,s||o,t)}),s)return l=new x(b.from(t.state.schema.text(e.replace(/\r\n?/g,`
|
|
9
|
-
`))),0,0),t.someProp("transformPasted",p=>{l=p(l,t,!0)}),l;let d=t.someProp("clipboardTextParser",p=>p(e,i,o,t));if(d)l=d;else{let p=i.marks(),{schema:f}=t.state,u=He.fromSchema(f);r=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=r.appendChild(document.createElement("p"));m&&g.appendChild(u.serializeNode(f.text(m,p)))})}}else t.someProp("transformPastedHTML",d=>{n=d(n,t)}),r=Sh(n),Pn&&Oh(r);let h=r&&r.querySelector("[data-pm-slice]"),c=h&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(h.getAttribute("data-pm-slice")||"");if(c&&c[3])for(let d=+c[3];d>0;d--){let p=r.firstChild;for(;p&&!k(p);)p=p.nextSibling;if(!p)break;r=p}if(l||(l=(t.someProp("clipboardParser")||t.someProp("domParser")||Bo.fromSchema(t.state.schema)).parseSlice(r,{preserveWhitespace:!!(a||c),context:i,ruleFromNode(d){return d.nodeName=="BR"&&!d.nextSibling&&d.parentNode&&!bh.test(d.parentNode.nodeName)?{ignore:!0}:null}})),c)l=Mh(gs(l,+c[1],+c[2]),c[4]);else if(l=x.maxOpen(xh(l.content,i),!0),l.openStart||l.openEnd){let d=0,p=0;for(let f=l.content.firstChild;d<l.openStart&&!f.type.spec.isolating;d++,f=f.firstChild);for(let f=l.content.lastChild;p<l.openEnd&&!f.type.spec.isolating;p++,f=f.lastChild);l=gs(l,d,p)}return t.someProp("transformPasted",d=>{l=d(l,t,a)}),l}var bh=/^(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 xh(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let o=e.node(n).contentMatchAt(e.index(n)),i,s=[];if(t.forEach(r=>{if(!s)return;let l=o.findWrapping(r.type),a;if(!l)return s=null;if(a=s.length&&i.length&&Jr(l,i,r,s[s.length-1],0))s[s.length-1]=a;else{s.length&&(s[s.length-1]=qr(s[s.length-1],i.length));let h=Lr(r,l);s.push(h),o=o.matchType(h.type),i=l}}),s)return b.from(s)}return t}function Lr(t,e,n=0){for(let o=e.length-1;o>=n;o--)t=e[o].create(null,b.from(t));return t}function Jr(t,e,n,o,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let s=Jr(t,e,n,o.lastChild,i+1);if(s)return o.copy(o.content.replaceChild(o.childCount-1,s));if(o.contentMatchAt(o.childCount).matchType(i==t.length-1?n.type:t[i+1]))return o.copy(o.content.append(b.from(Lr(n,t,i+1))))}}function qr(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,qr(t.lastChild,e-1)),o=t.contentMatchAt(t.childCount).fillBefore(b.empty,!0);return t.copy(n.append(o))}function $o(t,e,n,o,i,s){let r=e<0?t.firstChild:t.lastChild,l=r.content;return t.childCount>1&&(s=0),i<o-1&&(l=$o(l,e,n,o,i+1,s)),i>=n&&(l=e<0?r.contentMatchAt(0).fillBefore(l,s<=i).append(l):l.append(r.contentMatchAt(r.childCount).fillBefore(b.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,r.copy(l))}function gs(t,e,n){return e<t.openStart&&(t=new x($o(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new x($o(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}var Wr={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 Kr(){return document.implementation.createHTMLDocument("title")}var be=null;function kh(t){let e=window.trustedTypes;if(!e)return t;if(!be){if(be=e.defaultPolicy)try{return be.createHTML(t)}catch{}be=e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})}return be.createHTML(t)}function Sh(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=Kr(),o=n.body,i=/<([a-z][^>\s]+)/i.exec(t),s;if((s=i&&Wr[i[1].toLowerCase()])&&(t=s.map(r=>"<"+r+">").join("")+t+s.map(r=>"</"+r+">").reverse().join("")),o.innerHTML=kh(t),s)for(let r=0;r<s.length;r++)o=o.querySelector(s[r])||o;for(let r=0;r<n.styleSheets.length;r++){let l=n.styleSheets[r];for(let a=0;a<l.rules.length;a++){let h=l.rules[a];if(h instanceof CSSStyleRule){let c=o.querySelectorAll(h.selectorText);for(let d=0;d<c.length;d++)c[d].style.cssText+=h.style.cssText}}}return o}function Oh(t){let e=t.querySelectorAll(j?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let o=e[n];o.childNodes.length==1&&o.textContent=="\xA0"&&o.parentNode&&o.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),o)}}function Mh(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,o;try{o=JSON.parse(e)}catch{return t}let{content:i,openStart:s,openEnd:r}=t;for(let l=o.length-2;l>=0;l-=2){let a=n.nodes[o[l]];if(!a||a.hasRequiredAttrs())break;try{i=b.from(a.create(o[l+1],i))}catch{break}s++,r++}return new x(i,s,r)}var Q={},Z={},Ch={touchstart:!0,touchmove:!0},Nh=class{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 Ah(t){for(let e in Q){let n=Q[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=o=>{Eh(t,o)&&!Zo(t,o)&&(t.editable||!(o.type in Z))&&n(t,o)},Ch[e]?{passive:!0}:void 0)}G&&t.dom.addEventListener("input",()=>null),Io(t)}function xt(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function Dh(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 Io(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=o=>Zo(t,o))})}function Zo(t,e){return t.someProp("handleDOMEvents",n=>{let o=n[e.type];return o?o(t,e)||e.defaultPrevented:!1})}function Eh(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 Th(t,e){!Zo(t,e)&&Q[e.type]&&(t.editable||!(e.type in Z))&&Q[e.type](t,e)}Z.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!Yr(t)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(bt&&j&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),he&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let o=Date.now();t.input.lastIOSEnter=o,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==o&&(t.someProp("handleKeyDown",i=>i(t,jt(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",o=>o(t,n))||vh(t,n)?n.preventDefault():xt(t,"key")};Z.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Z.keypress=(t,e)=>{let n=e;if(Yr(t)||!n.charCode||n.ctrlKey&&!n.altKey||nt&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let o=t.state.selection;if(!(o instanceof A)||!o.$from.sameParent(o.$to)){let i=String.fromCharCode(n.charCode),s=()=>t.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!t.someProp("handleTextInput",r=>r(t,o.$from.pos,o.$to.pos,i,s))&&t.dispatch(s()),n.preventDefault()}};function Qe(t){return{left:t.clientX,top:t.clientY}}function $h(t,e){let n=e.x-t.clientX,o=e.y-t.clientY;return n*n+o*o<100}function Xo(t,e,n,o,i){if(o==-1)return!1;let s=t.state.doc.resolve(o);for(let r=s.depth+1;r>0;r--)if(t.someProp(e,l=>r>s.depth?l(t,n,s.nodeAfter,s.before(r),i,!0):l(t,n,s.node(r),s.before(r),i,!1)))return!0;return!1}function Ze(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let o=t.state.tr.setSelection(e);o.setMeta("pointer",!0),t.dispatch(o)}function Ih(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),o=n.nodeAfter;return o&&o.isAtom&&O.isSelectable(o)?(Ze(t,new O(n)),!0):!1}function Rh(t,e){if(e==-1)return!1;let n=t.state.selection,o,i;n instanceof O&&(o=n.node);let s=t.state.doc.resolve(e);for(let r=s.depth+1;r>0;r--){let l=r>s.depth?s.nodeAfter:s.node(r);if(O.isSelectable(l)){o&&n.$from.depth>0&&r>=n.$from.depth&&s.before(n.$from.depth+1)==n.$from.pos?i=s.before(n.$from.depth):i=s.before(r);break}}return i!=null?(Ze(t,O.create(t.state.doc,i)),!0):!1}function Ph(t,e,n,o,i){return Xo(t,"handleClickOn",e,n,o)||t.someProp("handleClick",s=>s(t,e,o))||(i?Rh(t,n):Ih(t,n))}function Bh(t,e,n,o){return Xo(t,"handleDoubleClickOn",e,n,o)||t.someProp("handleDoubleClick",i=>i(t,e,o))}function zh(t,e,n,o){return Xo(t,"handleTripleClickOn",e,n,o)||t.someProp("handleTripleClick",i=>i(t,e,o))||Fh(t,n,o)}function Fh(t,e,n){if(n.button!=0)return!1;let o=Hr(t,e,!0),i=t.state.doc;return o?(Ze(t,o),o instanceof A&&i.eq(t.state.doc)&&(t.input.mouseDown=new jh(t,o)),!0):!1}function Hr(t,e,n){let o=t.state.doc;if(e==-1)return o.inlineContent?A.create(o,0,o.content.size):null;let i=o.resolve(e);for(let s=i.depth+1;s>0;s--){let r=s>i.depth?i.nodeAfter:i.node(s),l=i.before(s);if(r.inlineContent)return A.create(o,l+1,l+1+r.content.size);if(n&&O.isSelectable(r))return O.create(o,l)}return null}function ti(t){return Le(t)}var Ur=nt?"metaKey":"ctrlKey";Q.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let o=ti(t),i=Date.now(),s="singleClick";i-t.input.lastClick.time<500&&$h(n,t.input.lastClick)&&!n[Ur]&&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 r=t.posAtCoords(Qe(n));r&&(s=="singleClick"?t.input.mouseDown=new Vh(t,r,n,!!o):(s=="doubleClick"?Bh:zh)(t,r.pos,r.inside,n)?n.preventDefault():xt(t,"pointer"))};var Gr=class{constructor(t){this.view=t,this.mightDrag=null,t.root.addEventListener("mouseup",this.up=this.up.bind(this)),t.root.addEventListener("mousemove",this.move=this.move.bind(this))}up(t){this.done()}move(t){t.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}},Vh=class extends Gr{constructor(t,e,n,o){super(t),this.pos=e,this.event=n,this.flushed=o,this.delayedSelectionSync=!1,this.startDoc=t.state.doc,this.selectNode=!!n[Ur],this.allowDefault=n.shiftKey;let i,s;if(e.inside>-1)i=t.state.doc.nodeAt(e.inside),s=e.inside;else{let h=t.state.doc.resolve(e.pos);i=h.parent,s=h.depth?h.before():0}let r=o?null:n.target,l=r?t.docView.nearestDesc(r,!0):null;this.target=l&&k(l.nodeDOM)?l.nodeDOM:null;let{selection:a}=t.state;n.button==0&&(i.type.spec.draggable&&i.type.spec.selectable!==!1||a instanceof O&&a.from<=s&&a.to>s)&&(this.mightDrag={node:i,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&et&&!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()),xt(t,"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||kt(this.view)})}up(t){if(this.done(),!this.view.dom.contains(t.target))return;let e=this.pos;this.view.state.doc!=this.startDoc&&(e=this.view.posAtCoords(Qe(t))),this.updateAllowDefault(t),this.allowDefault||!e?xt(this.view,"pointer"):Ph(this.view,e.pos,e.inside,t,this.selectNode)?t.preventDefault():t.button==0&&(this.flushed||G&&this.mightDrag&&!this.mightDrag.node.isAtom||j&&!this.view.state.selection.visible&&Math.min(Math.abs(e.pos-this.view.state.selection.from),Math.abs(e.pos-this.view.state.selection.to))<=2)?(Ze(this.view,N.near(this.view.state.doc.resolve(e.pos))),t.preventDefault()):xt(this.view,"pointer")}move(t){this.updateAllowDefault(t),xt(this.view,"pointer"),super.move(t)}updateAllowDefault(t){!this.allowDefault&&(Math.abs(this.event.x-t.clientX)>4||Math.abs(this.event.y-t.clientY)>4)&&(this.allowDefault=!0)}delaySelUpdate(){return this.allowDefault?(this.delayedSelectionSync=!0,!0):!1}},jh=class extends Gr{constructor(t,e){super(t),this.startSelection=e,this.startDoc=t.state.doc}move(t){if(t.buttons==0||this.view.isDestroyed||!this.view.state.doc.eq(this.startDoc)){this.done();return}t.preventDefault(),xt(this.view,"pointer");let e=this.view.posAtCoords(Qe(t)),n=e&&Hr(this.view,e.inside,!1);if(!n)return;let{doc:o}=this.view.state,i=this.startSelection,[s,r]=n.from<i.from?[i.to,n.from]:[i.from,n.to];Ze(this.view,A.create(o,s,r))}};Q.touchstart=t=>{t.input.lastTouch=Date.now(),ti(t),xt(t,"pointer")};Q.touchmove=t=>{t.input.lastTouch=Date.now(),xt(t,"pointer")};Q.contextmenu=t=>ti(t);function Yr(t,e){return t.composing?!0:G&&Math.abs(Date.now()-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}var Lh=bt?5e3:-1;Z.compositionstart=Z.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof A&&e.selection.empty&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(o=>o.type.spec.inclusive===!1)||j&&kr&&Jh(t)))t.markCursor=t.state.storedMarks||n.marks(),Le(t,!0),t.markCursor=null;else if(Le(t,!e.selection.empty),et&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let o=t.domSelectionRange();for(let i=o.focusNode,s=o.focusOffset;i&&k(i)&&s!=0;){let r=s<0?i.lastChild:i.childNodes[s-1];if(!r)break;if(B(r)){let l=t.domSelection();l&&l.collapse(r,r.nodeValue.length);break}else i=r,s=-1}}t.input.composing=!0}_r(t,Lh)};function Jh(t){let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(!e||!k(e)||n>=e.childNodes.length)return!1;let o=e.childNodes[n];return k(o)&&o.contentEditable=="false"}Z.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++,_r(t,20))};function _r(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>Le(t),e))}function Qr(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Date.now());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function qh(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=Rc(e.focusNode,e.focusOffset),o=Pc(e.focusNode,e.focusOffset);if(n&&o&&n!=o){let i=o.pmViewDesc,s=t.domObserver.lastChangedTextNode;if(n==s||o==s)return s;if(!i||!i.isText(o.nodeValue))return o;if(t.input.compositionNode==o){let r=n.pmViewDesc;if(!(!r||!r.isText(n.nodeValue)))return o}}return n||o}function Le(t,e=!1){if(!(bt&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),Qr(t),e||t.docView&&t.docView.dirty){let n=Go(t),o=t.state.selection;return n&&!n.eq(o)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!o.$from.node(o.$from.sharedDepth(o.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function Wh(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 o=getSelection(),i=document.createRange();i.selectNodeContents(e),t.dom.blur(),o.removeAllRanges(),o.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}var Je=tt&&It<15||he&&Vc<604;Q.copy=Z.cut=(t,e)=>{let n=e,o=t.state.selection,i=n.type=="cut";if(o.empty)return;let s=Je?null:n.clipboardData,r=o.content(),{dom:l,text:a}=_o(t,r);s?(n.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):Wh(t,l),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Kh(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function Hh(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,o=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(o.contentEditable="true"),o.style.cssText="position: fixed; left: -10000px; top: 10px",o.focus();let i=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),o.parentNode&&o.parentNode.removeChild(o),n?qe(t,o.value,null,i,e):qe(t,o.textContent,o.innerHTML,i,e)},50)}function qe(t,e,n,o,i){let s=Qo(t,e,n,o,t.state.selection.$from);if(t.someProp("handlePaste",a=>a(t,i,s||x.empty)))return!0;if(!s)return!1;let r=Kh(s),l=r?t.state.tr.replaceSelectionWith(r,o):t.state.tr.replaceSelection(s);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Zr(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," "):""}Z.paste=(t,e)=>{let n=e;if(t.composing&&!bt)return;let o=Je?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;o&&qe(t,Zr(o),o.getData("text/html"),i,n)?n.preventDefault():Hh(t,n)};var Xr=class{constructor(t,e,n){this.slice=t,this.move=e,this.node=n}},Uh=nt?"altKey":"ctrlKey";function tl(t,e){let n;return t.someProp("dragCopies",o=>{n=n||o(e)}),n!=null?!n:!e[Uh]}Q.dragstart=(t,e)=>{let n=e,o=t.input.mouseDown;if(o&&o.done(),!n.dataTransfer)return;let i=t.state.selection,s=i.empty?null:t.posAtCoords(Qe(n)),r;if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof O?i.to-1:i.to))){if(o&&o.mightDrag)r=O.create(t.state.doc,o.mightDrag.pos);else if(n.target&&k(n.target)){let d=t.docView.nearestDesc(n.target,!0);d&&d.node.type.spec.draggable&&d!=t.docView&&(r=O.create(t.state.doc,d.posBefore))}}let l=(r||t.state.selection).content(),{dom:a,text:h,slice:c}=_o(t,l);(!n.dataTransfer.files.length||!j||xr>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Je?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",Je||n.dataTransfer.setData("text/plain",h),t.dragging=new Xr(c,tl(t,n),r)};Q.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Z.dragover=Z.dragenter=(t,e)=>e.preventDefault();Z.drop=(t,e)=>{try{Gh(t,e,t.dragging)}finally{t.dragging=null}};function Gh(t,e,n){if(!e.dataTransfer)return;let o=t.posAtCoords(Qe(e));if(!o)return;let i=t.state.doc.resolve(o.pos),s=n&&n.slice;s?t.someProp("transformPasted",f=>{s=f(s,t,!1)}):s=Qo(t,Zr(e.dataTransfer),Je?null:e.dataTransfer.getData("text/html"),!1,i);let r=!!(n&&tl(t,e));if(t.someProp("handleDrop",f=>f(t,e,s||x.empty,r))){e.preventDefault();return}if(!s)return;e.preventDefault();let l=s?qo(t.state.doc,i.pos,s):i.pos;l==null&&(l=i.pos);let a=t.state.tr;if(r){let{node:f}=n;f?f.replace(a):a.deleteSelection()}let h=a.mapping.map(l),c=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,d=a.doc;if(c?a.replaceRangeWith(h,h,s.content.firstChild):a.replaceRange(h,h,s),a.doc.eq(d))return;let p=a.doc.resolve(h);if(c&&O.isSelectable(s.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(s.content.firstChild))a.setSelection(new O(p));else{let f=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((u,m,g,v)=>f=v),a.setSelection(Yo(t,p,a.doc.resolve(f)))}t.focus(),t.dispatch(a.setMeta("uiEvent","drop"))}Q.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())&&kt(t)},20))};Q.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)};Q.beforeinput=(t,e)=>{if(bt&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:n}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=n||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",i=>i(t,jt(8,"Backspace")))))return;let{$cursor:o}=t.state.selection;o&&o.pos>0&&t.dispatch(t.state.tr.delete(o.pos-1,o.pos).scrollIntoView())},50)}};for(let t in Z)Q[t]=Z[t];function We(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}var ys=class el{constructor(e,n){this.toDOM=e,this.spec=n||Kt,this.side=this.spec.side||0}map(e,n,o,i){let{pos:s,deleted:r}=e.mapResult(n.from+i,this.side<0?-1:1);return r?null:new zt(s-o,s-o,this)}valid(){return!0}eq(e){return this==e||e instanceof el&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&We(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},Fe=class Ro{constructor(e,n){this.attrs=e,this.spec=n||Kt}map(e,n,o,i){let s=e.map(n.from+i,this.spec.inclusiveStart?-1:1)-o,r=e.map(n.to+i,this.spec.inclusiveEnd?1:-1)-o;return s>=r?null:new zt(s,r,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof Ro&&We(this.attrs,e.attrs)&&We(this.spec,e.spec)}static is(e){return e.type instanceof Ro}destroy(){}},Yh=class nl{constructor(e,n){this.attrs=e,this.spec=n||Kt}map(e,n,o,i){let s=e.mapResult(n.from+i,1);if(s.deleted)return null;let r=e.mapResult(n.to+i,-1);return r.deleted||r.pos<=s.pos?null:new zt(s.pos-o,r.pos-o,this)}valid(e,n){let{index:o,offset:i}=e.content.findIndex(n.from),s;return i==n.from&&!(s=e.child(o)).isText&&i+s.nodeSize==n.to}eq(e){return this==e||e instanceof nl&&We(this.attrs,e.attrs)&&We(this.spec,e.spec)}destroy(){}},zt=class Te{constructor(e,n,o){this.from=e,this.to=n,this.type=o}copy(e,n){return new Te(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,o){return this.type.map(e,this,n,o)}static widget(e,n,o){return new Te(e,e,new ys(n,o))}static inline(e,n,o,i){return new Te(e,n,new Fe(o,i))}static node(e,n,o,i){return new Te(e,n,new Yh(o,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Fe}get widget(){return this.type instanceof ys}},oe=[],Kt={},it=class At{constructor(e,n){this.local=e.length?e:oe,this.children=n.length?n:oe}static create(e,n){return n.length?Dn(n,e,0,Kt):K}find(e,n,o){let i=[];return this.findInner(e??0,n??1e9,i,0,o),i}findInner(e,n,o,i,s){for(let r=0;r<this.local.length;r++){let l=this.local[r];l.from<=n&&l.to>=e&&(!s||s(l.spec))&&o.push(l.copy(l.from+i,l.to+i))}for(let r=0;r<this.children.length;r+=3)if(this.children[r]<n&&this.children[r+1]>e){let l=this.children[r]+1;this.children[r+2].findInner(e-l,n-l,o,i+l,s)}}map(e,n,o){return this==K||e.maps.length==0?this:this.mapInner(e,n,0,0,o||Kt)}mapInner(e,n,o,i,s){let r;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,o,i);a&&a.type.valid(n,a)?(r||(r=[])).push(a):s.onRemove&&s.onRemove(this.local[l].spec)}return this.children.length?_h(this.children,r||[],e,n,o,i,s):r?new At(r.sort(Ht),oe):K}add(e,n){return n.length?this==K?At.create(e,n):this.addInner(e,n,0):this}addInner(e,n,o){let i,s=0;e.forEach((l,a)=>{let h=a+o,c;if(c=sl(n,l,h)){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,c,h+1):i.splice(s,0,a,a+l.nodeSize,Dn(c,l,h+1,Kt)),s+=3}});let r=il(s?rl(n):n,-o);for(let l=0;l<r.length;l++)r[l].type.valid(e,r[l])||r.splice(l--,1);return new At(r.length?this.local.concat(r).sort(Ht):this.local,i||this.children)}remove(e){return e.length==0||this==K?this:this.removeInner(e,0)}removeInner(e,n){let o=this.children,i=this.local;for(let s=0;s<o.length;s+=3){let r,l=o[s]+n,a=o[s+1]+n;for(let c=0,d;c<e.length;c++)(d=e[c])&&d.from>l&&d.to<a&&(e[c]=null,(r||(r=[])).push(d));if(!r)continue;o==this.children&&(o=this.children.slice());let h=o[s+2].removeInner(r,l+1);h!=K?o[s+2]=h:(o.splice(s,3),s-=3)}if(i.length){for(let s=0,r;s<e.length;s++)if(r=e[s])for(let l=0;l<i.length;l++)i[l].eq(r,n)&&(i==this.local&&(i=this.local.slice()),i.splice(l--,1))}return o==this.children&&i==this.local?this:i.length||o.length?new At(i,o):K}forChild(e,n){if(this==K)return this;if(n.isLeaf)return At.empty;let o,i;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(o=this.children[l+2]);break}let s=e+1,r=s+n.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<r&&a.to>s&&a.type instanceof Fe){let h=Math.max(s,a.from)-s,c=Math.min(r,a.to)-s;h<c&&(i||(i=[])).push(a.copy(h,c))}}if(i){let l=new At(i.sort(Ht),oe);return o?new ol([l,o]):l}return o||K}eq(e){if(this==e)return!0;if(!(e instanceof At)||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 ei(this.localsInner(e))}localsInner(e){if(this==K)return oe;if(e.inlineContent||!this.local.some(Fe.is))return this.local;let n=[];for(let o=0;o<this.local.length;o++)this.local[o].type instanceof Fe||n.push(this.local[o]);return n}forEachSet(e){e(this)}};it.empty=new it([],[]);it.removeOverlap=ei;var K=it.empty,ol=class ie{constructor(e){this.members=e}map(e,n){let o=this.members.map(i=>i.map(e,n,Kt));return ie.from(o)}forChild(e,n){if(n.isLeaf)return it.empty;let o=[];for(let i=0;i<this.members.length;i++){let s=this.members[i].forChild(e,n);s!=K&&(s instanceof ie?o=o.concat(s.members):o.push(s))}return ie.from(o)}eq(e){if(!(e instanceof ie)||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,o=!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{o&&(n=n.slice(),o=!1);for(let r=0;r<s.length;r++)n.push(s[r])}}return n?ei(o?n:n.sort(Ht)):oe}static from(e){switch(e.length){case 0:return K;case 1:return e[0];default:return new ie(e.every(n=>n instanceof it)?e:e.reduce((n,o)=>n.concat(o instanceof it?o:o.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}};function _h(t,e,n,o,i,s,r){let l=t.slice();for(let h=0,c=s;h<n.maps.length;h++){let d=0;n.maps[h].forEach((p,f,u,m)=>{let g=m-u-(f-p);for(let v=0;v<l.length;v+=3){let y=l[v+1];if(y<0||p>y+c-d)continue;let w=l[v]+c-d;f>=w?l[v+1]=p<=w?-2:-1:p>=c&&g&&(l[v]+=g,l[v+1]+=g)}d+=g}),c=n.maps[h].map(c,-1)}let a=!1;for(let h=0;h<l.length;h+=3)if(l[h+1]<0){if(l[h+1]==-2){a=!0,l[h+1]=-1;continue}let c=n.map(t[h]+s),d=c-i;if(d<0||d>=o.content.size){a=!0;continue}let p=n.map(t[h+1]+s,-1),f=p-i,{index:u,offset:m}=o.content.findIndex(d),g=o.maybeChild(u);if(g&&m==d&&m+g.nodeSize==f){let v=l[h+2].mapInner(n,g,c+1,t[h]+s+1,r);v!=K?(l[h]=d,l[h+1]=f,l[h+2]=v):(l[h+1]=-2,a=!0)}else a=!0}if(a){let h=Qh(l,t,e,n,i,s,r),c=Dn(h,o,0,r);e=c.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<c.children.length;d+=3){let f=c.children[d];for(;p<l.length&&l[p]<f;)p+=3;l.splice(p,0,c.children[d],c.children[d+1],c.children[d+2])}}return new it(e.sort(Ht),l)}function il(t,e){if(!e||!t.length)return t;let n=[];for(let o=0;o<t.length;o++){let i=t[o];n.push(new zt(i.from+e,i.to+e,i.type))}return n}function Qh(t,e,n,o,i,s,r){function l(a,h){for(let c=0;c<a.local.length;c++){let d=a.local[c].map(o,i,h);d?n.push(d):r.onRemove&&r.onRemove(a.local[c].spec)}for(let c=0;c<a.children.length;c+=3)l(a.children[c+2],a.children[c]+h+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 sl(t,e,n){if(e.isLeaf)return null;let o=n+e.nodeSize,i=null;for(let s=0,r;s<t.length;s++)(r=t[s])&&r.from>n&&r.to<o&&((i||(i=[])).push(r),t[s]=null);return i}function rl(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function Dn(t,e,n,o){let i=[],s=!1;e.forEach((l,a)=>{let h=sl(t,l,a+n);if(h){s=!0;let c=Dn(h,l,n+a+1,o);c!=K&&i.push(a,a+l.nodeSize,c)}});let r=il(s?rl(t):t,-n).sort(Ht);for(let l=0;l<r.length;l++)r[l].type.valid(e,r[l])||(o.onRemove&&o.onRemove(r[l].spec),r.splice(l--,1));return r.length||i.length?new it(r,i):K}function Ht(t,e){return t.from-e.from||t.to-e.to}function ei(t){let e=t;for(let n=0;n<e.length-1;n++){let o=e[n];if(o.from!=o.to)for(let i=n+1;i<e.length;i++){let s=e[i];if(s.from==o.from){s.to!=o.to&&(e==t&&(e=t.slice()),e[i]=s.copy(s.from,o.to),ws(e,i+1,s.copy(o.to,s.to)));continue}else{s.from<o.to&&(e==t&&(e=t.slice()),e[n]=o.copy(o.from,s.from),ws(e,i,o.copy(s.from,o.to)));break}}}return e}function ws(t,e,n){for(;e<t.length&&Ht(n,t[e])>0;)e++;t.splice(e,0,n)}function no(t){let e=[];return t.someProp("decorations",n=>{let o=n(t.state);o&&o!=K&&e.push(o)}),t.cursorWrapper&&e.push(it.create(t.state.doc,[t.cursorWrapper.deco])),ol.from(e)}var Zh={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Xh=tt&&It<=11,td=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(t){this.anchorNode=t.anchorNode,this.anchorOffset=t.anchorOffset,this.focusNode=t.focusNode,this.focusOffset=t.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(t){return t.anchorNode==this.anchorNode&&t.anchorOffset==this.anchorOffset&&t.focusNode==this.focusNode&&t.focusOffset==this.focusOffset}},ed=class{constructor(t,e){this.view=t,this.handleDOMChange=e,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new td,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(n=>{for(let o=0;o<n.length;o++)this.queue.push(n[o]);tt&&It<=11&&n.some(o=>o.type=="childList"&&o.removedNodes.length||o.type=="characterData"&&o.oldValue.length>o.target.nodeValue.length)?this.flushSoon():G&&t.composing&&n.some(o=>o.type=="childList"&&o.target.nodeName=="TR")?(t.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),Xh&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.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,Zh)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let t=this.observer.takeRecords();if(t.length){for(let e=0;e<t.length;e++)this.queue.push(t[e]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}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(hs(this.view)){if(this.suppressingSelectionUpdates)return kt(this.view);if(tt&&It<=11&&!this.view.state.selection.empty){let t=this.view.domSelectionRange();if(t.focusNode&&Gt(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(t){if(!t.focusNode)return!0;let e=new Set,n;for(let i=t.focusNode;i;i=ce(i))e.add(i);for(let i=t.anchorNode;i;i=ce(i))if(e.has(i)){n=i;break}let o=n&&this.view.docView.nearestDesc(n);if(o&&o.ignoreMutation({type:"selection",target:B(n)?n.parentNode:n}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}flush(){let{view:t}=this;if(!t.docView||this.flushingSoon>-1)return;let e=this.pendingRecords();e.length&&(this.queue=[]);let n=t.domSelectionRange(),o=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&hs(t)&&!this.ignoreSelectionChange(n),i=-1,s=-1,r=!1,l=[];if(t.editable)for(let h=0;h<e.length;h++){let c=this.registerMutation(e[h],l);c&&(i=i<0?c.from:Math.min(c.from,i),s=s<0?c.to:Math.max(c.to,s),c.typeOver&&(r=!0))}if(l.some(h=>h.nodeName=="BR")&&(t.input.lastKeyCode==8||t.input.lastKeyCode==46||j&&(t.composing||t.input.compositionEndedAt>Date.now()-50)&&e.some(h=>h.type=="childList"&&h.removedNodes.length))){for(let h of l)if(h.nodeName=="BR"&&h.parentNode){let c=h.nextSibling;for(;c&&k(c);){if(c.contentEditable=="false"){h.parentNode.removeChild(h);break}c=c.firstChild}}}else if(et&&l.length){let h=l.filter(c=>c.nodeName=="BR");if(h.length==2){let[c,d]=h;c.parentNode&&c.parentNode.parentNode==d.parentNode?d.remove():c.remove()}else{let{focusNode:c}=this.currentSelection;for(let d of h){let p=d.parentNode;p&&p.nodeName=="LI"&&(!c||id(t,c)!=p)&&d.remove()}}}let a=null;i<0&&o&&t.input.lastFocus>Date.now()-200&&Math.max(t.input.lastTouch,t.input.lastClick.time)<Date.now()-300&&Rn(n)&&(a=Go(t))&&a.eq(N.near(t.state.doc.resolve(0),1))?(t.input.lastFocus=0,kt(t),this.currentSelection.set(n),t.scrollToSelection()):(i>-1||o)&&(i>-1&&(t.docView.markDirty(i,s),nd(t)),t.input.badSafariComposition&&(t.input.badSafariComposition=!1,sd(t,l)),this.handleDOMChange(i,s,r,l),t.docView&&t.docView.dirty?t.updateState(t.state):this.currentSelection.eq(n)||kt(t),this.currentSelection.set(n))}registerMutation(t,e){if(e.indexOf(t.target)>-1)return null;let n=this.view.docView.nearestDesc(t.target);if(t.type=="attributes"&&(n==this.view.docView||t.attributeName=="contenteditable"||t.attributeName=="style"&&!t.oldValue&&!t.target.getAttribute("style"))||!n||n.ignoreMutation(t))return null;if(t.type=="childList"){for(let h=0;h<t.addedNodes.length;h++){let c=t.addedNodes[h];e.push(c),B(c)&&(this.lastChangedTextNode=c)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(t.target))return{from:n.posBefore,to:n.posAfter};let o=t.previousSibling,i=t.nextSibling;if(tt&&It<=11&&t.addedNodes.length)for(let h=0;h<t.addedNodes.length;h++){let{previousSibling:c,nextSibling:d}=t.addedNodes[h];(!c||Array.prototype.indexOf.call(t.addedNodes,c)<0)&&(o=c),(!d||Array.prototype.indexOf.call(t.addedNodes,d)<0)&&(i=d)}let s=o&&o.parentNode==t.target?V(o)+1:0,r=n.localPosFromDOM(t.target,s,-1),l=i&&i.parentNode==t.target?V(i):t.target.childNodes.length,a=n.localPosFromDOM(t.target,l,1);return{from:r,to:a}}else return t.type=="attributes"?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:(this.lastChangedTextNode=t.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:t.target.nodeValue==t.oldValue})}},vs=new WeakMap,bs=!1;function nd(t){if(!vs.has(t)&&(vs.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=et,bs)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."),bs=!0}}function xs(t,e){let n=e.startContainer,o=e.startOffset,i=e.endContainer,s=e.endOffset,r=t.domAtPos(t.state.selection.anchor);return Gt(r.node,r.offset,i,s)&&([n,o,i,s]=[i,s,n,o]),{anchorNode:n,anchorOffset:o,focusNode:i,focusOffset:s}}function od(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return xs(t,i)}let n;function o(i){i.preventDefault(),i.stopImmediatePropagation(),n=i.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",o,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",o,!0),n?xs(t,n):null}function id(t,e){for(let n=e.parentNode;n&&n!=t.dom;n=n.parentNode){let o=t.docView.nearestDesc(n,!0);if(o&&o.node.isBlock)return n}return null}function sd(t,e){var n;let{focusNode:o,focusOffset:i}=t.domSelectionRange();for(let s of e)if(((n=s.parentNode)===null||n===void 0?void 0:n.nodeName)=="TR"){let r=s.nextSibling;for(;r&&r.nodeName!="TD"&&r.nodeName!="TH";)r=r.nextSibling;if(r){let l=r;for(;;){let a=l.firstChild;if(!a||!k(a)||a.contentEditable=="false"||/^(BR|IMG)$/.test(a.nodeName))break;l=a}l.insertBefore(s,l.firstChild),o==s&&t.domSelection().collapse(s,i)}else s.parentNode.removeChild(s)}}function rd(t,e,n,o){let{node:i,fromOffset:s,toOffset:r,from:l,to:a}=t.docView.parseRange(e,n),h=t.domSelectionRange(),c,d=h.anchorNode;if(d&&Yt(t.dom,d)&&(c=[{node:d,offset:h.anchorOffset}],Rn(h)||c.push({node:h.focusNode,offset:h.focusOffset})),j&&t.input.lastKeyCode===8)for(let v=r;v>s;v--){let y=i.childNodes[v-1],w=y.pmViewDesc;if(y.nodeName=="BR"&&!w){r=v;break}if(!w||w.size)break}let p=t.state.doc,f=t.someProp("domParser")||Bo.fromSchema(t.state.schema),u=p.resolve(l),m=null,g=f.parse(i,{topNode:u.parent,topMatch:u.parent.contentMatchAt(u.index()),topOpen:!0,from:s,to:r,preserveWhitespace:u.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:ld(o),context:u});if(c&&c[0].pos!=null){let v=c[0].pos,y=c[1]&&c[1].pos;y==null&&(y=v),m={anchor:v+l,head:y+l}}return{doc:g,sel:m,from:l,to:a}}var ld=t=>e=>{let n=e.pmViewDesc;if(n)return n.parseRule(t);if(e.nodeName=="BR"&&e.parentNode){if(G&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let o=document.createElement("div");return o.appendChild(document.createElement("li")),{skip:o}}else if(e.parentNode.lastChild==e||G&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName=="IMG"&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null},ad=/^(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 cd(t,e,n,o,i){let s=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let M=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,D=Go(t,M);if(D&&!t.state.selection.eq(D)){if(j&&bt&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",Ia=>Ia(t,jt(13,"Enter"))))return;let z=t.state.tr.setSelection(D);M=="pointer"?z.setMeta("pointer",!0):M=="key"&&z.scrollIntoView(),s&&z.setMeta("composition",s),t.dispatch(z)}return}let r=t.state.doc.resolve(e),l=r.sharedDepth(n);e=r.before(l+1),n=t.state.doc.resolve(n).after(l+1);let a=t.state.selection,h=rd(t,e,n,i),c=t.state.doc,d=c.slice(h.from,h.to),p,f;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(p=t.state.selection.to,f="end"):(p=t.state.selection.from,f="start"),t.input.lastKeyCode=null;let u=ud(d.content,h.doc.content,h.from,p,f);if(u&&t.input.domChangeCount++,(he&&t.input.lastIOSEnter>Date.now()-225||bt)&&i.some(M=>k(M)&&!ad.test(M.nodeName))&&(!u||u.endA>=u.endB)&&t.someProp("handleKeyDown",M=>M(t,jt(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!u)if(o&&a instanceof A&&!a.empty&&a.$head.sameParent(a.$anchor)&&!t.composing&&!(h.sel&&h.sel.anchor!=h.sel.head))u={start:a.from,endA:a.to,endB:a.to};else{if(h.sel){let M=ks(t,t.state.doc,h.sel);if(M&&!M.eq(t.state.selection)){let D=t.state.tr.setSelection(M);s&&D.setMeta("composition",s),t.dispatch(D)}}return}t.state.selection.from<t.state.selection.to&&u.start==u.endB&&t.state.selection instanceof A&&(u.start>t.state.selection.from&&u.start<=t.state.selection.from+2&&t.state.selection.from>=h.from?u.start=t.state.selection.from:u.endA<t.state.selection.to&&u.endA>=t.state.selection.to-2&&t.state.selection.to<=h.to&&(u.endB+=t.state.selection.to-u.endA,u.endA=t.state.selection.to)),tt&&It<=11&&u.endB==u.start+1&&u.endA==u.start&&u.start>h.from&&h.doc.textBetween(u.start-h.from-1,u.start-h.from+1)==" \xA0"&&(u.start--,u.endA--,u.endB--);let m=h.doc.resolveNoCache(u.start-h.from),g=h.doc.resolveNoCache(u.endB-h.from),v=c.resolve(u.start),y=m.sameParent(g)&&m.parent.inlineContent&&v.end()>=u.endA;if((he&&t.input.lastIOSEnter>Date.now()-225&&(!y||i.some(M=>M.nodeName=="DIV"||M.nodeName=="P"))||!y&&pd(h.doc,m.pos,g.pos))&&t.someProp("handleKeyDown",M=>M(t,jt(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>u.start&&dd(c,u.start,u.endA,m,g)&&t.someProp("handleKeyDown",M=>M(t,jt(8,"Backspace")))){bt&&j&&t.domObserver.suppressSelectionUpdates();return}j&&u.endB==u.start&&(t.input.lastChromeDelete=Date.now()),bt&&!y&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&h.sel&&h.sel.anchor==h.sel.head&&h.sel.head==u.endA&&(u.endB-=2,g=h.doc.resolveNoCache(u.endB-h.from),setTimeout(()=>{t.someProp("handleKeyDown",function(M){return M(t,jt(13,"Enter"))})},20));let w=u.start,S=u.endA,$=M=>{let D=M||t.state.tr.replace(w,S,h.doc.slice(u.start-h.from,u.endB-h.from));if(h.sel){let z=ks(t,D.doc,h.sel);z&&!(j&&t.composing&&z.empty&&(u.start!=u.endB||t.input.lastChromeDelete<Date.now()-100)&&(z.head==w||z.head==D.mapping.map(S)-1)||tt&&z.empty&&z.head==w)&&D.setSelection(z)}return s&&D.setMeta("composition",s),D.scrollIntoView()},Y;if(y)if(m.pos==g.pos){tt&&It<=11&&m.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>kt(t),20));let M=$(t.state.tr.delete(w,S)),D=c.resolve(u.start).marksAcross(c.resolve(u.endA));D&&M.ensureMarks(D),t.dispatch(M)}else if(u.endA==u.endB&&(Y=hd(m.parent.content.cut(m.parentOffset,g.parentOffset),v.parent.content.cut(v.parentOffset,u.endA-v.start())))){let M=$(t.state.tr);Y.type=="add"?M.addMark(w,S,Y.mark):M.removeMark(w,S,Y.mark),t.dispatch(M)}else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let M=m.parent.textBetween(m.parentOffset,g.parentOffset),D=()=>$(t.state.tr.insertText(M,w,S));t.someProp("handleTextInput",z=>z(t,w,S,M,D))||t.dispatch(D())}else t.dispatch($());else t.dispatch($())}function ks(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:Yo(t,e.resolve(n.anchor),e.resolve(n.head))}function hd(t,e){let n=t.firstChild.marks,o=e.firstChild.marks,i=n,s=o,r,l,a;for(let c=0;c<o.length;c++)i=o[c].removeFromSet(i);for(let c=0;c<n.length;c++)s=n[c].removeFromSet(s);if(i.length==1&&s.length==0)l=i[0],r="add",a=c=>c.mark(l.addToSet(c.marks));else if(i.length==0&&s.length==1)l=s[0],r="remove",a=c=>c.mark(l.removeFromSet(c.marks));else return null;let h=[];for(let c=0;c<e.childCount;c++)h.push(a(e.child(c)));if(b.from(h).eq(t))return{mark:l,type:r}}function dd(t,e,n,o,i){if(n-e<=i.pos-o.pos||oo(o,!0,!1)<i.pos)return!1;let s=t.resolve(e);if(!o.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 r=t.resolve(oo(s,!0,!0));return!r.parent.isTextblock||r.pos>n||oo(r,!0,!1)<n?!1:o.parent.content.cut(o.parentOffset).eq(r.parent.content)}function pd(t,e,n){let o=0,i=0;return t.nodesBetween(e,n,(s,r)=>{s.isTextblock&&r>=e&&r<n?o++:(s.isText?/\S/.test(s.text.slice(Math.max(0,e-r),Math.min(s.nodeSize,n-r))):s.isLeaf)&&i++}),i==0&&o==1}function oo(t,e,n){let o=t.depth,i=e?t.end():t.pos;for(;o>0&&(e||t.indexAfter(o)==t.node(o).childCount);)o--,i++,e=!1;if(n){let s=t.node(o).maybeChild(t.indexAfter(o));for(;s&&!s.isLeaf;)s=s.firstChild,i++}return i}function ud(t,e,n,o,i){let s=t.findDiffStart(e,n),r=n+t.size,l=n+e.size;if(s==null)return null;let{a,b:h}=t.findDiffEnd(e,r,l);if(i=="end"){let c=Math.max(0,s-Math.min(a,h));o-=a+c-s}if(a<s&&r<l){let c=o<=s&&o>=a?s-o:0;s-=c,h=s+(h-a),a=s}else if(h<s){let c=o<=s&&o>=h?s-o:0;s-=c,a=s+(a-h),h=s}return{start:s,endA:a,endB:h}}var fd=Qo,md=Le,ll=class{constructor(t,e){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 Nh,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=e,this.state=e.state,this.directPlugins=e.plugins||[],this.directPlugins.forEach(Ns),this.dispatch=this.dispatch.bind(this),this.dom=t&&t.mount||document.createElement("div"),t&&(t.appendChild?t.appendChild(this.dom):typeof t=="function"?t(this.dom):t.mount&&(this.mounted=!0)),this.editable=Ms(this),Os(this),this.nodeViews=Cs(this),this.docView=is(this.state.doc,Ss(this),no(this),this.dom,this),this.domObserver=new ed(this,(n,o,i,s)=>cd(this,n,o,i,s)),this.domObserver.start(),Ah(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let t=this._props;this._props={};for(let e in t)this._props[e]=t[e];this._props.state=this.state}return this._props}update(t){t.handleDOMEvents!=this._props.handleDOMEvents&&Io(this);let e=this._props;this._props=t,t.plugins&&(t.plugins.forEach(Ns),this.directPlugins=t.plugins),this.updateStateInner(t.state,e)}setProps(t){let e={};for(let n in this._props)e[n]=this._props[n];e.state=this.state;for(let n in t)e[n]=t[n];this.update(e)}updateState(t){this.updateStateInner(t,this._props)}updateStateInner(t,e){var n;let o=this.state,i=!1,s=!1;t.storedMarks&&this.composing&&(Qr(this),s=!0),this.state=t;let r=o.plugins!=t.plugins||this._props.plugins!=e.plugins;if(r||this._props.plugins!=e.plugins||this._props.nodeViews!=e.nodeViews){let p=Cs(this);yd(p,this.nodeViews)&&(this.nodeViews=p,i=!0)}(r||e.handleDOMEvents!=this._props.handleDOMEvents)&&Io(this),this.editable=Ms(this),Os(this);let l=no(this),a=Ss(this),h=o.plugins!=t.plugins&&!o.doc.eq(t.doc)?"reset":t.scrollToSelection>o.scrollToSelection?"to selection":"preserve",c=i||!this.docView.matchesNode(t.doc,a,l);(c||!t.selection.eq(o.selection))&&(s=!0);let d=h=="preserve"&&s&&this.dom.style.overflowAnchor==null&&Jc(this);if(s){this.domObserver.stop();let p=c&&(tt||j)&&!this.composing&&!o.selection.empty&&!t.selection.empty&&gd(o.selection,t.selection);if(c){let u=j?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=qh(this)),(i||!this.docView.update(t.doc,a,l,this))&&(this.docView.updateOuterDeco(a),this.docView.destroy(),this.docView=is(t.doc,a,l,this.dom,this)),u&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(p=!0)}let f=this.input.mouseDown;p||!(f&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&ph(this)&&f.delaySelUpdate())?kt(this,p):(Fr(this,t.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(o),!((n=this.dragging)===null||n===void 0)&&n.node&&!o.doc.eq(t.doc)&&this.updateDraggedNode(this.dragging,o),h=="reset"?this.dom.scrollTop=0:h=="to selection"?this.scrollToSelection():d&&qc(d)}scrollToSelection(){let t=this.domSelectionRange().focusNode;if(!(!t||!Yt(this.dom,t))&&!this.someProp("handleScrollToSelection",e=>e(this)))if(this.state.selection instanceof O){let e=this.docView.domAfterPos(this.state.selection.from);k(e)&&Zi(this,e.getBoundingClientRect(),t)}else Zi(this,this.coordsAtPos(this.state.selection.head,1),t)}destroyPluginViews(){let t;for(;t=this.pluginViews.pop();)t.destroy&&t.destroy()}updatePluginViews(t){if(!t||t.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let e=0;e<this.directPlugins.length;e++){let n=this.directPlugins[e];n.spec.view&&this.pluginViews.push(n.spec.view(this))}for(let e=0;e<this.state.plugins.length;e++){let n=this.state.plugins[e];n.spec.view&&this.pluginViews.push(n.spec.view(this))}}else for(let e=0;e<this.pluginViews.length;e++){let n=this.pluginViews[e];n.update&&n.update(this,t)}}updateDraggedNode(t,e){let n=t.node,o=-1;if(n.from<this.state.doc.content.size&&this.state.doc.nodeAt(n.from)==n.node)o=n.from;else{let i=n.from+(this.state.doc.content.size-e.doc.content.size);(i>0&&i<this.state.doc.content.size&&this.state.doc.nodeAt(i))==n.node&&(o=i)}this.dragging=new Xr(t.slice,t.move,o<0?void 0:O.create(this.state.doc,o))}someProp(t,e){let n=this._props&&this._props[t],o;if(n!=null&&(o=e?e(n):n))return o;for(let s=0;s<this.directPlugins.length;s++){let r=this.directPlugins[s].props[t];if(r!=null&&(o=e?e(r):r))return o}let i=this.state.plugins;if(i)for(let s=0;s<i.length;s++){let r=i[s].props[t];if(r!=null&&(o=e?e(r):r))return o}}hasFocus(){if(tt){let t=this.root.activeElement;if(t==this.dom)return!0;if(!t||!this.dom.contains(t))return!1;for(;t&&this.dom!=t&&this.dom.contains(t);){if(t.contentEditable=="false")return!1;t=t.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&Wc(this.dom),kt(this),this.domObserver.start()}get root(){let t=this._root;if(t==null){for(let e=this.dom.parentNode;e;e=e.parentNode)if(e.nodeType==9||e.nodeType==11&&e.host)return e.getSelection||(Object.getPrototypeOf(e).getSelection=()=>e.ownerDocument.getSelection()),this._root=e}return t||document}updateRoot(){this._root=null}posAtCoords(t){return Yc(this,t)}coordsAtPos(t,e=1){return Nr(this,t,e)}domAtPos(t,e=0){return this.docView.domFromPos(t,e)}nodeDOM(t){let e=this.docView.descAt(t);return e?e.nodeDOM:null}posAtDOM(t,e,n=-1){let o=this.docView.posFromDOM(t,e,n);if(o==null)throw new RangeError("DOM position not inside the editor");return o}endOfTextblock(t,e){return th(this,e||this.state,t)}pasteHTML(t,e){return qe(this,"",t,!1,e||new ClipboardEvent("paste"))}pasteText(t,e){return qe(this,t,null,!0,e||new ClipboardEvent("paste"))}serializeForClipboard(t){return _o(this,t)}destroy(){this.docView&&(Dh(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],no(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,$c())}get isDestroyed(){return this.docView==null}dispatchEvent(t){return Th(this,t)}domSelectionRange(){let t=this.dom.isConnected!==!1&&this.domSelection();return t?G&&this.root.nodeType===11&&zc(this.dom.ownerDocument)==this.dom&&od(this,t)||t:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};ll.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function Ss(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 o in n)o=="class"?e.class+=" "+n[o]:o=="style"?e.style=(e.style?e.style+";":"")+n[o]:!e[o]&&o!="contenteditable"&&o!="nodeName"&&(e[o]=String(n[o]))}),e.translate||(e.translate="no"),[zt.node(0,t.state.doc.content.size,e)]}function Os(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:zt.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function Ms(t){return!t.someProp("editable",e=>e(t.state)===!1)}function gd(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 Cs(t){let e=Object.create(null);function n(o){for(let i in o)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=o[i])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function yd(t,e){let n=0,o=0;for(let i in t){if(t[i]!=e[i])return!0;n++}for(let i in e)o++;return n!=o}function Ns(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 wd={};mt(wd,{closeHistory:()=>Cd,history:()=>Nd,isHistoryTransaction:()=>$d,redo:()=>ul,redoDepth:()=>Td,redoNoScroll:()=>Dd,undo:()=>pl,undoDepth:()=>Ed,undoNoScroll:()=>Ad});var En=200,L=function(){};L.prototype.append=function(t){return t.length?(t=L.from(t),!this.length&&t||t.length<En&&this.leafAppend(t)||this.length<En&&t.leafPrepend(this)||this.appendInner(t)):this};L.prototype.prepend=function(t){return t.length?L.from(t).append(this):this};L.prototype.appendInner=function(t){return new vd(this,t)};L.prototype.slice=function(t,e){return t===void 0&&(t=0),e===void 0&&(e=this.length),t>=e?L.empty:this.sliceInner(Math.max(0,t),Math.min(this.length,e))};L.prototype.get=function(t){if(!(t<0||t>=this.length))return this.getInner(t)};L.prototype.forEach=function(t,e,n){e===void 0&&(e=0),n===void 0&&(n=this.length),e<=n?this.forEachInner(t,e,n,0):this.forEachInvertedInner(t,e,n,0)};L.prototype.map=function(t,e,n){e===void 0&&(e=0),n===void 0&&(n=this.length);var o=[];return this.forEach(function(i,s){return o.push(t(i,s))},e,n),o};L.from=function(t){return t instanceof L?t:t&&t.length?new al(t):L.empty};var al=(function(t){function e(o){t.call(this),this.values=o}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(o,i){return o==0&&i==this.length?this:new e(this.values.slice(o,i))},e.prototype.getInner=function(o){return this.values[o]},e.prototype.forEachInner=function(o,i,s,r){for(var l=i;l<s;l++)if(o(this.values[l],r+l)===!1)return!1},e.prototype.forEachInvertedInner=function(o,i,s,r){for(var l=i-1;l>=s;l--)if(o(this.values[l],r+l)===!1)return!1},e.prototype.leafAppend=function(o){if(this.length+o.length<=En)return new e(this.values.concat(o.flatten()))},e.prototype.leafPrepend=function(o){if(this.length+o.length<=En)return new e(o.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e})(L);L.empty=new al([]);var vd=(function(t){function e(n,o){t.call(this),this.left=n,this.right=o,this.length=n.length+o.length,this.depth=Math.max(n.depth,o.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(n){return n<this.left.length?this.left.get(n):this.right.get(n-this.left.length)},e.prototype.forEachInner=function(n,o,i,s){var r=this.left.length;if(o<r&&this.left.forEachInner(n,o,Math.min(i,r),s)===!1||i>r&&this.right.forEachInner(n,Math.max(o-r,0),Math.min(this.length,i)-r,s+r)===!1)return!1},e.prototype.forEachInvertedInner=function(n,o,i,s){var r=this.left.length;if(o>r&&this.right.forEachInvertedInner(n,o-r,Math.max(i,r)-r,s+r)===!1||i<r&&this.left.forEachInvertedInner(n,Math.min(o,r),i,s)===!1)return!1},e.prototype.sliceInner=function(n,o){if(n==0&&o==this.length)return this;var i=this.left.length;return o<=i?this.left.slice(n,o):n>=i?this.right.slice(n-i,o-i):this.left.slice(n,i).append(this.right.slice(0,o-i))},e.prototype.leafAppend=function(n){var o=this.right.leafAppend(n);if(o)return new e(this.left,o)},e.prototype.leafPrepend=function(n){var o=this.left.leafPrepend(n);if(o)return new e(o,this.right)},e.prototype.appendInner=function(n){return this.left.depth>=Math.max(this.right.depth,n.depth)+1?new e(this.left,new e(this.right,n)):new e(this,n)},e})(L),cl=L,bd=500,Ke=class se{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let o=this.items.length;for(;;o--)if(this.items.get(o-1).selection){--o;break}let i,s;n&&(i=this.remapping(o,this.items.length),s=i.maps.length);let r=e.tr,l,a,h=[],c=[];return this.items.forEach((d,p)=>{if(!d.step){i||(i=this.remapping(o,p+1),s=i.maps.length),s--,c.push(d);return}if(i){c.push(new Mt(d.map));let f=d.step.map(i.slice(s)),u;f&&r.maybeStep(f).doc&&(u=r.mapping.maps[r.mapping.maps.length-1],h.push(new Mt(u,void 0,void 0,h.length+c.length))),s--,u&&i.appendMap(u,s)}else r.maybeStep(d.step);if(d.selection)return l=i?d.selection.map(i.slice(s)):d.selection,a=new se(this.items.slice(0,o).append(c.reverse().concat(h)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:r,selection:l}}addTransform(e,n,o,i){let s=[],r=this.eventCount,l=this.items,a=!i&&l.length?l.get(l.length-1):null;for(let c=0;c<e.steps.length;c++){let d=e.steps[c].invert(e.docs[c]),p=new Mt(e.mapping.maps[c],d,n),f;(f=a&&a.merge(p))&&(p=f,c?s.pop():l=l.slice(0,l.length-1)),s.push(p),n&&(r++,n=void 0),i||(a=p)}let h=r-o.depth;return h>kd&&(l=xd(l,h),r-=h),new se(l.append(s),r)}remapping(e,n){let o=new Fo;return this.items.forEach((i,s)=>{let r=i.mirrorOffset!=null&&s-i.mirrorOffset>=e?o.maps.length-i.mirrorOffset:void 0;o.appendMap(i.map,r)},e,n),o}addMaps(e){return this.eventCount==0?this:new se(this.items.append(e.map(n=>new Mt(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;n=Math.min(this.items.length,n);let o=[],i=this.items.length-n,s=e.mapping,r=e.steps.length,l=this.eventCount;this.items.forEach(p=>{p.selection&&l--},i);let a=n;this.items.forEach(p=>{let f=s.getMirror(--a);if(f==null)return;r=Math.min(r,f);let u=s.maps[f];if(p.step){let m=e.steps[f].invert(e.docs[f]),g=p.selection&&p.selection.map(s.slice(a+1,f));g&&l++,o.push(new Mt(u,m,g))}else o.push(new Mt(u))},i);let h=[];for(let p=n;p<r;p++)h.push(new Mt(s.maps[p]));let c=this.items.slice(0,i).append(h).append(o),d=new se(c,l);return d.emptyItemCount()>bd&&(d=d.compress(this.items.length-o.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),o=n.maps.length,i=[],s=0;return this.items.forEach((r,l)=>{if(l>=e)i.push(r),r.selection&&s++;else if(r.step){let a=r.step.map(n.slice(o)),h=a&&a.getMap();if(o--,h&&n.appendMap(h,o),a){let c=r.selection&&r.selection.map(n.slice(o));c&&s++;let d=new Mt(h.invert(),a,c),p,f=i.length-1;(p=i.length&&i[f].merge(d))?i[f]=p:i.push(d)}}else r.map&&o--},this.items.length,0),new se(cl.from(i.reverse()),s)}};Ke.empty=new Ke(cl.empty,0);function xd(t,e){let n;return t.forEach((o,i)=>{if(o.selection&&e--==0)return n=i,!1}),t.slice(n)}var Mt=class hl{constructor(e,n,o,i){this.map=e,this.step=n,this.selection=o,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new hl(n.getMap().invert(),n,this.selection)}}},Tt=class{constructor(t,e,n,o,i){this.done=t,this.undone=e,this.prevRanges=n,this.prevTime=o,this.prevComposition=i}},kd=20;function Sd(t,e,n,o){let i=n.getMeta(pt),s;if(i)return i.historyState;n.getMeta(dl)&&(t=new Tt(t.done,t.undone,null,0,-1));let r=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(r&&r.getMeta(pt))return r.getMeta(pt).redo?new Tt(t.done.addTransform(n,void 0,o,Sn(e)),t.undone,As(n.mapping.maps),t.prevTime,t.prevComposition):new Tt(t.done,t.undone.addTransform(n,void 0,o,Sn(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(r&&r.getMeta("addToHistory")===!1)){let l=n.getMeta("composition"),a=t.prevTime==0||!r&&t.prevComposition!=l&&(t.prevTime<(n.time||0)-o.newGroupDelay||!Od(n,t.prevRanges)),h=r?io(t.prevRanges,n.mapping):As(n.mapping.maps);return new Tt(t.done.addTransform(n,a?e.selection.getBookmark():void 0,o,Sn(e)),Ke.empty,h,n.time,l??t.prevComposition)}else return(s=n.getMeta("rebased"))?new Tt(t.done.rebased(n,s),t.undone.rebased(n,s),io(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Tt(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),io(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function Od(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((o,i)=>{for(let s=0;s<e.length;s+=2)o<=e[s+1]&&i>=e[s]&&(n=!0)}),n}function As(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((o,i,s,r)=>e.push(s,r));return e}function io(t,e){if(!t)return null;let n=[];for(let o=0;o<t.length;o+=2){let i=e.map(t[o],1),s=e.map(t[o+1],-1);i<=s&&n.push(i,s)}return n}function Md(t,e,n){let o=Sn(e),i=pt.get(e).spec.config,s=(n?t.undone:t.done).popEvent(e,o);if(!s)return null;let r=s.selection.resolve(s.transform.doc),l=(n?t.done:t.undone).addTransform(s.transform,e.selection.getBookmark(),i,o),a=new Tt(n?l:s.remaining,n?s.remaining:l,null,0,-1);return s.transform.setSelection(r).setMeta(pt,{redo:n,historyState:a})}var so=!1,Ds=null;function Sn(t){let e=t.plugins;if(Ds!=e){so=!1,Ds=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){so=!0;break}}return so}function Cd(t){return t.setMeta(dl,!0)}var pt=new Ho("history"),dl=new Ho("closeHistory");function Nd(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new fe({key:pt,state:{init(){return new Tt(Ke.empty,Ke.empty,null,0,-1)},apply(e,n,o){return Sd(n,o,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let o=n.inputType,i=o=="historyUndo"?pl:o=="historyRedo"?ul:null;return!i||!e.editable?!1:(n.preventDefault(),i(e.state,e.dispatch))}}}})}function Bn(t,e){return(n,o)=>{let i=pt.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return!1;if(o){let s=Md(i,n,t);s&&o(e?s.scrollIntoView():s)}return!0}}var pl=Bn(!1,!0),ul=Bn(!0,!0),Ad=Bn(!1,!1),Dd=Bn(!0,!1);function Ed(t){let e=pt.getState(t);return e?e.done.eventCount:0}function Td(t){let e=pt.getState(t);return e?e.undone.eventCount:0}function $d(t){return t.getMeta(pt)!=null}var Id={};mt(Id,{keydownHandler:()=>ni,keymap:()=>Ld});var Pt={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:"'"},Tn={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Rd=typeof navigator<"u"&&/Mac/.test(navigator.platform),Pd=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(I=0;I<10;I++)Pt[48+I]=Pt[96+I]=String(I);var I;for(I=1;I<=24;I++)Pt[I+111]="F"+I;var I;for(I=65;I<=90;I++)Pt[I]=String.fromCharCode(I+32),Tn[I]=String.fromCharCode(I);var I;for(gn in Pt)Tn.hasOwnProperty(gn)||(Tn[gn]=Pt[gn]);var gn;function Bd(t){var e=Rd&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||Pd&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Tn:Pt)[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}var zd=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Fd=typeof navigator<"u"&&/Win/.test(navigator.platform);function Vd(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let o,i,s,r;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))r=!0;else if(/^a(lt)?$/i.test(a))o=!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))zd?r=!0:i=!0;else throw new Error("Unrecognized modifier name: "+a)}return o&&(n="Alt-"+n),i&&(n="Ctrl-"+n),r&&(n="Meta-"+n),s&&(n="Shift-"+n),n}function jd(t){let e=Object.create(null);for(let n in t)e[Vd(n)]=t[n];return e}function ro(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 Ld(t){return new fe({props:{handleKeyDown:ni(t)}})}function ni(t){let e=jd(t);return function(n,o){let i=Bd(o),s,r=e[ro(i,o)];if(r&&r(n.state,n.dispatch,n))return!0;if(i.length==1&&i!=" "){if(o.shiftKey){let l=e[ro(i,o,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((o.altKey||o.metaKey||o.ctrlKey)&&!(Fd&&o.ctrlKey&&o.altKey)&&(s=Pt[o.keyCode])&&s!=i){let l=e[ro(s,o)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var Jd={};mt(Jd,{autoJoin:()=>op,baseKeymap:()=>sp,chainCommands:()=>zn,createParagraphNear:()=>Sl,deleteSelection:()=>oi,exitCode:()=>kl,joinBackward:()=>ml,joinDown:()=>Hd,joinForward:()=>vl,joinTextblockBackward:()=>qd,joinTextblockForward:()=>Wd,joinUp:()=>Kd,lift:()=>Ud,liftEmptyBlock:()=>Ol,macBaseKeymap:()=>ai,newlineInCode:()=>xl,pcBaseKeymap:()=>ht,selectAll:()=>Cl,selectNodeBackward:()=>yl,selectNodeForward:()=>bl,selectParentNode:()=>Yd,selectTextblockEnd:()=>El,selectTextblockStart:()=>Dl,setBlockType:()=>Zd,splitBlock:()=>li,splitBlockAs:()=>Ml,splitBlockKeepMarks:()=>Gd,toggleMark:()=>ep,wrapIn:()=>Qd});var oi=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function fl(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}var ml=(t,e,n)=>{let o=fl(t,n);if(!o)return!1;let i=ii(o);if(!i){let r=o.blockRange(),l=r&&Ue(r);return l==null?!1:(e&&e(t.tr.lift(r,l).scrollIntoView()),!0)}let s=i.nodeBefore;if(Nl(t,i,e,-1))return!0;if(o.parent.content.size==0&&(de(s,"end")||O.isSelectable(s)))for(let r=o.depth;;r--){let l=Ge(t.doc,o.before(r),o.after(r),x.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=t.tr.step(l);a.setSelection(de(s,"end")?N.findFrom(a.doc.resolve(a.mapping.map(i.pos,-1)),-1):O.create(a.doc,i.pos-s.nodeSize)),e(a.scrollIntoView())}return!0}if(r==1||o.node(r-1).childCount>1)break}return s.isAtom&&i.depth==o.depth-1?(e&&e(t.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView()),!0):!1},qd=(t,e,n)=>{let o=fl(t,n);if(!o)return!1;let i=ii(o);return i?gl(t,i,e):!1},Wd=(t,e,n)=>{let o=wl(t,n);if(!o)return!1;let i=si(o);return i?gl(t,i,e):!1};function gl(t,e,n){let o=e.nodeBefore,i=o,s=e.pos-1;for(;!i.isTextblock;s--){if(i.type.spec.isolating)return!1;let c=i.lastChild;if(!c)return!1;i=c}let r=e.nodeAfter,l=r,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let c=l.firstChild;if(!c)return!1;l=c}let h=Ge(t.doc,s,a,x.empty);if(!h||h.from!=s||h instanceof st&&h.slice.size>=a-s)return!1;if(n){let c=t.tr.step(h);c.setSelection(A.create(c.doc,s)),n(c.scrollIntoView())}return!0}function de(t,e,n=!1){for(let o=t;o;o=e=="start"?o.firstChild:o.lastChild){if(o.isTextblock)return!0;if(n&&o.childCount!=1)return!1}return!1}var yl=(t,e,n)=>{let{$head:o,empty:i}=t.selection,s=o;if(!i)return!1;if(o.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):o.parentOffset>0)return!1;s=ii(o)}let r=s&&s.nodeBefore;return!r||!O.isSelectable(r)?!1:(e&&e(t.tr.setSelection(O.create(t.doc,s.pos-r.nodeSize)).scrollIntoView()),!0)};function ii(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 wl(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}var vl=(t,e,n)=>{let o=wl(t,n);if(!o)return!1;let i=si(o);if(!i)return!1;let s=i.nodeAfter;if(Nl(t,i,e,1))return!0;if(o.parent.content.size==0&&(de(s,"start")||O.isSelectable(s))){let r=Ge(t.doc,o.before(),o.after(),x.empty);if(r&&r.slice.size<r.to-r.from){if(e){let l=t.tr.step(r);l.setSelection(de(s,"start")?N.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):O.create(l.doc,l.mapping.map(i.pos))),e(l.scrollIntoView())}return!0}}return s.isAtom&&i.depth==o.depth-1?(e&&e(t.tr.delete(i.pos,i.pos+s.nodeSize).scrollIntoView()),!0):!1},bl=(t,e,n)=>{let{$head:o,empty:i}=t.selection,s=o;if(!i)return!1;if(o.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):o.parentOffset<o.parent.content.size)return!1;s=si(o)}let r=s&&s.nodeAfter;return!r||!O.isSelectable(r)?!1:(e&&e(t.tr.setSelection(O.create(t.doc,s.pos)).scrollIntoView()),!0)};function si(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}var Kd=(t,e)=>{let n=t.selection,o=n instanceof O,i;if(o){if(n.node.isTextblock||!_t(t.doc,n.from))return!1;i=n.from}else if(i=Jo(t.doc,n.from,-1),i==null)return!1;if(e){let s=t.tr.join(i);o&&s.setSelection(O.create(s.doc,i-t.doc.resolve(i).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},Hd=(t,e)=>{let n=t.selection,o;if(n instanceof O){if(n.node.isTextblock||!_t(t.doc,n.to))return!1;o=n.to}else if(o=Jo(t.doc,n.to,1),o==null)return!1;return e&&e(t.tr.join(o).scrollIntoView()),!0},Ud=(t,e)=>{let{$from:n,$to:o}=t.selection,i=n.blockRange(o),s=i&&Ue(i);return s==null?!1:(e&&e(t.tr.lift(i,s).scrollIntoView()),!0)},xl=(t,e)=>{let{$head:n,$anchor:o}=t.selection;return!n.parent.type.spec.code||!n.sameParent(o)?!1:(e&&e(t.tr.insertText(`
|
|
10
|
-
`).scrollIntoView()),!0)};function ri(t){for(let e=0;e<t.edgeCount;e++){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}var kl=(t,e)=>{let{$head:n,$anchor:o}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(o))return!1;let i=n.node(-1),s=n.indexAfter(-1),r=ri(i.contentMatchAt(s));if(!r||!i.canReplaceWith(s,s,r))return!1;if(e){let l=n.after(),a=t.tr.replaceWith(l,l,r.createAndFill());a.setSelection(N.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Sl=(t,e)=>{let n=t.selection,{$from:o,$to:i}=n;if(n instanceof dt||o.parent.inlineContent||i.parent.inlineContent)return!1;let s=ri(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let r=(!o.parentOffset&&i.index()<i.parent.childCount?o:i).pos,l=t.tr.insert(r,s.createAndFill());l.setSelection(A.create(l.doc,r+1)),e(l.scrollIntoView())}return!0},Ol=(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(Re(t.doc,s))return e&&e(t.tr.split(s).scrollIntoView()),!0}let o=n.blockRange(),i=o&&Ue(o);return i==null?!1:(e&&e(t.tr.lift(o,i).scrollIntoView()),!0)};function Ml(t){return(e,n)=>{if(e.selection instanceof O&&e.selection.node.isBlock){let{$from:f}=e.selection;return!f.parentOffset||!Re(e.doc,f.pos)?!1:(n&&n(e.tr.split(f.pos).scrollIntoView()),!0)}if(!e.selection.$from.depth)return!1;let o=e.tr;!e.selection.empty&&(e.selection instanceof A||e.selection instanceof dt)&&o.deleteSelection();let{$from:i}=o.selection,s=o.steps.length,r=[],l,a,h=!1,c=!1;for(let f=i.depth;;f--)if(i.node(f).isBlock){h=i.end(f)==i.pos+(i.depth-f),c=i.start(f)==i.pos-(i.depth-f),a=ri(i.node(f-1).contentMatchAt(i.indexAfter(f-1)));let u=t&&t(i.parent,h,i);r.unshift(u||(h&&a?{type:a}:null)),l=f;break}else{if(f==1)return!1;r.unshift(null)}let d=i.pos,p=Re(o.doc,d,r.length,r);if(p||(r[0]=a?{type:a}:null,p=Re(o.doc,d,r.length,r)),!p)return!1;if(o.split(d,r.length,r),!h&&c&&i.node(l).type!=a){let f=o.mapping.slice(s),u=f.map(i.before(l)),m=o.doc.resolve(u);a&&i.node(l-1).canReplaceWith(m.index(),m.index()+1,a)&&o.setNodeMarkup(f.map(i.before(l)),a)}return n&&n(o.scrollIntoView()),!0}}var li=Ml(),Gd=(t,e)=>li(t,e&&(n=>{let o=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();o&&n.ensureMarks(o),e(n)})),Yd=(t,e)=>{let{$from:n,to:o}=t.selection,i,s=n.sharedDepth(o);return s==0?!1:(i=n.before(s),e&&e(t.tr.setSelection(O.create(t.doc,i))),!0)},Cl=(t,e)=>(e&&e(t.tr.setSelection(new dt(t.doc))),!0);function _d(t,e,n){let o=e.nodeBefore,i=e.nodeAfter,s=e.index();return!o||!i||!o.type.compatibleContent(i.type)?!1:!o.content.size&&e.parent.canReplace(s-1,s)?(n&&n(t.tr.delete(e.pos-o.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(i.isTextblock||_t(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function Nl(t,e,n,o){let i=e.nodeBefore,s=e.nodeAfter,r,l,a=i.type.spec.isolating||s.type.spec.isolating;if(!a&&_d(t,e,n))return!0;let h=!a&&e.parent.canReplace(e.index(),e.index()+1);if(h&&(r=(l=i.contentMatchAt(i.childCount)).findWrapping(s.type))&&l.matchType(r[0]||s.type).validEnd){if(n){let f=e.pos+s.nodeSize,u=b.empty;for(let v=r.length-1;v>=0;v--)u=b.from(r[v].create(null,u));u=b.from(i.copy(u));let m=t.tr.step(new ut(e.pos-1,f,e.pos,f,new x(u,1,0),r.length,!0)),g=m.doc.resolve(f+2*r.length);g.nodeAfter&&g.nodeAfter.type==i.type&&_t(m.doc,g.pos)&&m.join(g.pos),n(m.scrollIntoView())}return!0}let c=s.type.spec.isolating||o>0&&a?null:N.findFrom(e,1),d=c&&c.$from.blockRange(c.$to),p=d&&Ue(d);if(p!=null&&p>=e.depth)return n&&n(t.tr.lift(d,p).scrollIntoView()),!0;if(h&&de(s,"start",!0)&&de(i,"end")){let f=i,u=[];for(;u.push(f),!f.isTextblock;)f=f.lastChild;let m=s,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(f.canReplace(f.childCount,f.childCount,m.content)){if(n){let v=b.empty;for(let w=u.length-1;w>=0;w--)v=b.from(u[w].copy(v));let y=t.tr.step(new ut(e.pos-u.length,e.pos+s.nodeSize,e.pos+g,e.pos+s.nodeSize-g,new x(v,u.length,0),0,!0));n(y.scrollIntoView())}return!0}}return!1}function Al(t){return function(e,n){let o=e.selection,i=t<0?o.$from:o.$to,s=i.depth;for(;i.node(s).isInline;){if(!s)return!1;s--}return i.node(s).isTextblock?(n&&n(e.tr.setSelection(A.create(e.doc,t<0?i.start(s):i.end(s)))),!0):!1}}var Dl=Al(-1),El=Al(1);function Qd(t,e=null){return function(n,o){let{$from:i,$to:s}=n.selection,r=i.blockRange(s),l=r&&Lo(r,t,e);return l?(o&&o(n.tr.wrap(r,l).scrollIntoView()),!0):!1}}function Zd(t,e=null){return function(n,o){let i=!1;for(let s=0;s<n.selection.ranges.length&&!i;s++){let{$from:{pos:r},$to:{pos:l}}=n.selection.ranges[s];n.doc.nodesBetween(r,l,(a,h)=>{if(i)return!1;if(!(!a.isTextblock||a.hasMarkup(t,e)))if(a.type==t)i=!0;else{let c=n.doc.resolve(h),d=c.index();i=c.parent.canReplaceWith(d,d+1,t)}})}if(!i)return!1;if(o){let s=n.tr;for(let r=0;r<n.selection.ranges.length;r++){let{$from:{pos:l},$to:{pos:a}}=n.selection.ranges[r];s.setBlockType(l,a,t,e)}o(s.scrollIntoView())}return!0}}function Xd(t,e,n,o){for(let i=0;i<e.length;i++){let{$from:s,$to:r}=e[i],l=s.depth==0?t.inlineContent&&t.type.allowsMarkType(n):!1;if(t.nodesBetween(s.pos,r.pos,(a,h)=>{if(l||!o&&a.isAtom&&a.isInline&&h>=s.pos&&h+a.nodeSize<=r.pos)return!1;l=a.inlineContent&&a.type.allowsMarkType(n)}),l)return!0}return!1}function tp(t){let e=[];for(let n=0;n<t.length;n++){let{$from:o,$to:i}=t[n];o.doc.nodesBetween(o.pos,i.pos,(s,r)=>{if(s.isAtom&&s.content.size&&s.isInline&&r>=o.pos&&r+s.nodeSize<=i.pos)return r+1>o.pos&&e.push(new Nn(o,o.doc.resolve(r+1))),o=o.doc.resolve(r+1+s.content.size),!1}),o.pos<i.pos&&e.push(new Nn(o,i))}return e}function ep(t,e=null,n){let o=(n&&n.removeWhenPresent)!==!1,i=(n&&n.enterInlineAtoms)!==!1,s=!(n&&n.includeWhitespace);return function(r,l){let{empty:a,$cursor:h,ranges:c}=r.selection;if(a&&!h||!Xd(r.doc,c,t,i))return!1;if(l)if(h)t.isInSet(r.storedMarks||h.marks())?l(r.tr.removeStoredMark(t)):l(r.tr.addStoredMark(t.create(e)));else{let d,p=r.tr;i||(c=tp(c)),o?d=!c.some(f=>r.doc.rangeHasMark(f.$from.pos,f.$to.pos,t)):d=!c.every(f=>{let u=!1;return p.doc.nodesBetween(f.$from.pos,f.$to.pos,(m,g,v)=>{if(u)return!1;u=!t.isInSet(m.marks)&&!!v&&v.type.allowsMarkType(t)&&!(m.isText&&/^\s*$/.test(m.textBetween(Math.max(0,f.$from.pos-g),Math.min(m.nodeSize,f.$to.pos-g))))}),!u});for(let f=0;f<c.length;f++){let{$from:u,$to:m}=c[f];if(!d)p.removeMark(u.pos,m.pos,t);else{let g=u.pos,v=m.pos,y=u.nodeAfter,w=m.nodeBefore,S=s&&y&&y.isText?/^\s*/.exec(y.text)[0].length:0,$=s&&w&&w.isText?/\s*$/.exec(w.text)[0].length:0;g+S<v&&(g+=S,v-=$),p.addMark(g,v,t.create(e))}}l(p.scrollIntoView())}return!0}}function np(t,e){return n=>{if(!n.isGeneric)return t(n);let o=[];for(let s=0;s<n.mapping.maps.length;s++){let r=n.mapping.maps[s];for(let l=0;l<o.length;l++)o[l]=r.map(o[l]);r.forEach((l,a,h,c)=>o.push(h,c))}let i=[];for(let s=0;s<o.length;s+=2){let r=o[s],l=o[s+1],a=n.doc.resolve(r),h=a.sharedDepth(l),c=a.node(h);for(let d=a.indexAfter(h),p=a.after(h+1);p<=l;++d){let f=c.maybeChild(d);if(!f)break;if(d&&i.indexOf(p)==-1){let u=c.child(d-1);u.type==f.type&&e(u,f)&&i.push(p)}p+=f.nodeSize}}i.sort((s,r)=>s-r);for(let s=i.length-1;s>=0;s--)_t(n.doc,i[s])&&n.join(i[s]);t(n)}}function op(t,e){let n=Array.isArray(e)?o=>e.indexOf(o.type.name)>-1:e;return(o,i,s)=>t(o,i&&np(i,n),s)}function zn(...t){return function(e,n,o){for(let i=0;i<t.length;i++)if(t[i](e,n,o))return!0;return!1}}var lo=zn(oi,ml,yl),Es=zn(oi,vl,bl),ht={Enter:zn(xl,Sl,Ol,li),"Mod-Enter":kl,Backspace:lo,"Mod-Backspace":lo,"Shift-Backspace":lo,Delete:Es,"Mod-Delete":Es,"Mod-a":Cl},ai={"Ctrl-h":ht.Backspace,"Alt-Backspace":ht["Mod-Backspace"],"Ctrl-d":ht.Delete,"Ctrl-Alt-Backspace":ht["Mod-Delete"],"Alt-Delete":ht["Mod-Delete"],"Alt-d":ht["Mod-Delete"],"Ctrl-a":Dl,"Ctrl-e":El};for(let t in ht)ai[t]=ht[t];var ip=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1,sp=ip?ai:ht,rp={};mt(rp,{InputRule:()=>St,closeDoubleQuote:()=>$l,closeSingleQuote:()=>Rl,ellipsis:()=>pp,emDash:()=>dp,inputRules:()=>cp,openDoubleQuote:()=>Tl,openSingleQuote:()=>Il,smartQuotes:()=>up,textblockTypeInputRule:()=>mp,undoInputRule:()=>hp,wrappingInputRule:()=>fp});var St=class{constructor(t,e,n={}){this.match=t,this.match=t,this.handler=typeof e=="string"?lp(e):e,this.undoable=n.undoable!==!1,this.inCode=n.inCode||!1,this.inCodeMark=n.inCodeMark!==!1}};function lp(t){return function(e,n,o,i){let s=t;if(n[1]){let r=n[0].lastIndexOf(n[1]);s+=n[0].slice(r+n[1].length),o+=r;let l=o-i;l>0&&(s=n[0].slice(r-l,r)+s,o=i)}return e.tr.insertText(s,o,i)}}var ap=500;function cp({rules:t}){let e=new fe({state:{init(){return null},apply(n,o){return n.getMeta(this)||(n.selectionSet||n.docChanged?null:o)}},props:{handleTextInput(n,o,i,s){return Ts(n,o,i,s,t,e)},handleDOMEvents:{compositionend:n=>{setTimeout(()=>{let{$cursor:o}=n.state.selection;o&&Ts(n,o.pos,o.pos,"",t,e)})}}},isInputRules:!0});return e}function Ts(t,e,n,o,i,s){if(t.composing)return!1;let r=t.state,l=r.doc.resolve(e),a=l.parent.textBetween(Math.max(0,l.parentOffset-ap),l.parentOffset,null,"\uFFFC")+o;for(let h=0;h<i.length;h++){let c=i[h];if(!c.inCodeMark&&l.marks().some(u=>u.type.spec.code))continue;if(l.parent.type.spec.code){if(!c.inCode)continue}else if(c.inCode==="only")continue;let d=c.match.exec(a);if(!d||d[0].length<o.length)continue;let p=e-(d[0].length-o.length);if(!c.inCodeMark){let u=!1;if(r.doc.nodesBetween(p,l.pos,m=>{m.isInline&&m.marks.some(g=>g.type.spec.code)&&(u=!0)}),u)continue}let f=c.handler(r,d,p,n);if(f)return c.undoable&&f.setMeta(s,{transform:f,from:e,to:n,text:o}),t.dispatch(f),!0}return!1}var hp=(t,e)=>{let n=t.plugins;for(let o=0;o<n.length;o++){let i=n[o],s;if(i.spec.isInputRules&&(s=i.getState(t))){if(e){let r=t.tr,l=s.transform;for(let a=l.steps.length-1;a>=0;a--)r.step(l.steps[a].invert(l.docs[a]));if(s.text){let a=r.doc.resolve(s.from).marks();r.replaceWith(s.from,s.to,t.schema.text(s.text,a))}else r.delete(s.from,s.to);e(r)}return!0}}return!1},dp=new St(/--$/,"\u2014",{inCodeMark:!1}),pp=new St(/\.\.\.$/,"\u2026",{inCodeMark:!1}),Tl=new St(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"\u201C",{inCodeMark:!1}),$l=new St(/"$/,"\u201D",{inCodeMark:!1}),Il=new St(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"\u2018",{inCodeMark:!1}),Rl=new St(/'$/,"\u2019",{inCodeMark:!1}),up=[Tl,$l,Il,Rl];function fp(t,e,n=null,o){return new St(t,(i,s,r,l)=>{let a=n instanceof Function?n(s):n,h=i.tr.delete(r,l),c=h.doc.resolve(r),d=c.blockRange(),p=d&&Lo(d,e,a);if(!p)return null;h.wrap(d,p);let f=h.doc.resolve(r-1).nodeBefore;return f&&f.type==e&&_t(h.doc,r-1)&&(!o||o(s,f))&&h.join(r-1),h})}function mp(t,e,n=null){return new St(t,(o,i,s,r)=>{let l=o.doc.resolve(s),a=n instanceof Function?n(i):n;return l.node(-1).canReplaceWith(l.index(-1),l.indexAfter(-1),e)?o.tr.delete(s,r).setBlockType(s,s,e,a):null})}var gp={};mt(gp,{dropCursor:()=>yp});function yp(t={}){return new fe({view(e){return new wp(e,t)}})}var wp=class{constructor(t,e){var n;this.editorView=t,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,this.width=(n=e.width)!==null&&n!==void 0?n:1,this.color=e.color===!1?void 0:e.color||"black",this.class=e.class,this.handlers=["dragover","dragend","drop","dragleave"].map(o=>{let i=s=>{this[o](s)};return t.dom.addEventListener(o,i),{name:o,handler:i}})}destroy(){this.setCursor(null),this.handlers.forEach(({name:t,handler:e})=>this.editorView.dom.removeEventListener(t,e))}update(t,e){if(this.cursorPos!=null&&e.doc!=t.state.doc)if(this.lastDragEvent){let n=this.computeTarget(this.lastDragEvent);n==this.cursorPos?this.updateOverlay():this.setCursor(n)}else this.updateOverlay()}setCursor(t){t!=this.cursorPos&&(this.cursorPos=t,t==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let t=this.editorView.state.doc.resolve(this.cursorPos),e=!t.parent.inlineContent,n,o=this.editorView.dom,i=o.getBoundingClientRect(),s=i.width/o.offsetWidth,r=i.height/o.offsetHeight;if(e){let c=t.nodeBefore,d=t.nodeAfter;if(c||d){let p=this.editorView.nodeDOM(this.cursorPos-(c?c.nodeSize:0));if(p){let f=p.getBoundingClientRect(),u=c?f.bottom:f.top;c&&d&&(u=(u+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let m=this.width/2*r;n={left:f.left,right:f.right,top:u-m,bottom:u+m}}}}if(!n){let c=this.editorView.coordsAtPos(this.cursorPos),d=this.width/2*s;n={left:c.left-d,right:c.left+d,top:c.top,bottom:c.bottom}}let l=this.editorView.dom.offsetParent;this.element||(this.element=l.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",e),this.element.classList.toggle("prosemirror-dropcursor-inline",!e);let a,h;if(!l||l==document.body&&getComputedStyle(l).position=="static")a=-pageXOffset,h=-pageYOffset;else{let c=l.getBoundingClientRect(),d=c.width/l.offsetWidth,p=c.height/l.offsetHeight;a=c.left-l.scrollLeft*d,h=c.top-l.scrollTop*p}this.element.style.left=(n.left-a)/s+"px",this.element.style.top=(n.top-h)/r+"px",this.element.style.width=(n.right-n.left)/s+"px",this.element.style.height=(n.bottom-n.top)/r+"px"}scheduleRemoval(t){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),t)}computeTarget(t){let e=this.editorView.posAtCoords({left:t.clientX,top:t.clientY}),n=e&&e.inside>=0&&this.editorView.state.doc.nodeAt(e.inside),o=n&&n.type.spec.disableDropCursor,i=typeof o=="function"?o(this.editorView,e,t):o;if(!e||i)return null;let s=e.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let r=qo(this.editorView.state.doc,s,this.editorView.dragging.slice);r!=null&&(s=r)}return s}dragover(t){if(!this.editorView.editable)return;this.lastDragEvent=t;let e=this.computeTarget(t);e!=null&&(this.setCursor(e),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(t){this.editorView.dom.contains(t.relatedTarget)||this.setCursor(null)}},vp={};mt(vp,{GapCursor:()=>X,gapCursor:()=>Sp});var X=class Dt extends N{constructor(e){super(e,e)}map(e,n){let o=e.resolve(n.map(this.head));return Dt.valid(o)?new Dt(o):N.near(o)}content(){return x.empty}eq(e){return e instanceof Dt&&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 Dt(e.resolve(n.pos))}getBookmark(){return new bp(this.anchor)}static valid(e){let n=e.parent;if(n.inlineContent||!xp(e)||!kp(e))return!1;let o=n.type.spec.allowGapCursor;if(o!=null)return o;let i=n.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,n,o=!1){t:for(;;){if(!o&&Dt.valid(e))return e;let i=e.pos,s=null;for(let r=e.depth;;r--){let l=e.node(r);if(n>0?e.indexAfter(r)<l.childCount:e.index(r)>0){s=l.child(n>0?e.indexAfter(r):e.index(r)-1);break}else if(r==0)return null;i+=n;let a=e.doc.resolve(i);if(Dt.valid(a))return a}for(;;){let r=n>0?s.firstChild:s.lastChild;if(!r){if(s.isAtom&&!s.isText&&!O.isSelectable(s)){e=e.doc.resolve(i+s.nodeSize*n),o=!1;continue t}break}s=r,i+=n;let l=e.doc.resolve(i);if(Dt.valid(l))return l}return null}}};X.prototype.visible=!1;X.findFrom=X.findGapCursorFrom;N.jsonID("gapcursor",X);var bp=class Pl{constructor(e){this.pos=e}map(e){return new Pl(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return X.valid(n)?new X(n):N.near(n)}};function Bl(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function xp(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),o=t.node(e);if(n==0){if(o.type.spec.isolating)return!0;continue}for(let i=o.child(n-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||Bl(i.type))return!0;if(i.inlineContent)return!1}}return!0}function kp(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),o=t.node(e);if(n==o.childCount){if(o.type.spec.isolating)return!0;continue}for(let i=o.child(n);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||Bl(i.type))return!0;if(i.inlineContent)return!1}}return!0}function Sp(){return new fe({props:{decorations:Np,createSelectionBetween(t,e,n){return e.pos==n.pos&&X.valid(n)?new X(n):null},handleClick:Mp,handleKeyDown:Op,handleDOMEvents:{beforeinput:Cp}}})}var Op=ni({ArrowLeft:yn("horiz",-1),ArrowRight:yn("horiz",1),ArrowUp:yn("vert",-1),ArrowDown:yn("vert",1)});function yn(t,e){let n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(o,i,s){let r=o.selection,l=e>0?r.$to:r.$from,a=r.empty;if(r instanceof A){if(!s.endOfTextblock(n)||l.depth==0)return!1;a=!1,l=o.doc.resolve(e>0?l.after():l.before())}let h=X.findGapCursorFrom(l,e,a);return h?(i&&i(o.tr.setSelection(new X(h))),!0):!1}}function Mp(t,e,n){if(!t||!t.editable)return!1;let o=t.state.doc.resolve(e);if(!X.valid(o))return!1;let i=t.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&O.isSelectable(t.state.doc.nodeAt(i.inside))?!1:(t.dispatch(t.state.tr.setSelection(new X(o))),!0)}function Cp(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof X))return!1;let{$from:n}=t.state.selection,o=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!o)return!1;let i=b.empty;for(let r=o.length-1;r>=0;r--)i=b.from(o[r].createAndFill(null,i));let s=t.state.tr.replace(n.pos,n.pos,new x(i,0,0));return s.setSelection(A.near(s.doc.resolve(n.pos+1))),t.dispatch(s),!1}function Np(t){if(!(t.selection instanceof X))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",it.create(t.doc,[zt.widget(t.selection.head,e,{key:"gapcursor"})])}var Ap=/^(https?:|mailto:|tel:)/i;function Fn(t){let e=String(t??"").trim().replace(/[\u0000-\u001f\u007f]/g,"");return e?e.startsWith("#")||e.startsWith("/")&&!e.startsWith("//")||Ap.test(e)?e:/^[a-z][a-z0-9+.-]*:/i.test(e)?null:/^(\/\/)?[\w-]+(\.[\w-]+)+(:\d+)?([/?#]\S*)?$/.test(e)?`https://${e.replace(/^\/\//,"")}`:/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)?`mailto:${e}`:null:null}var ci=t=>t&&/^data:image\/(png|jpeg|gif|webp);/i.test(t)&&t.length<=21e5?t:Fn(t);function hi(t){if(typeof t!="string")return null;let e=Fn(t);return e&&/^(https?:|\/(?!\/))/i.test(e)?e:null}var q={id:{default:null},pos:{default:null},parent:{default:null}},F=(t,e={})=>({"data-id":t.attrs.id,...e}),di=new gt.Schema({nodes:{doc:{content:"block+"},paragraph:{group:"block",content:"inline*",attrs:q,toDOM:t=>["p",F(t),0]},heading:{group:"block",content:"inline*",defining:!0,attrs:{...q,level:{default:2},pageIcon:{default:null},pageCoverSrc:{default:null},pageCoverAlt:{default:""},pageCoverX:{default:50},pageCoverY:{default:50}},toDOM:t=>[`h${t.attrs.level}`,F(t),0]},list_item:{group:"block",content:"inline*",attrs:{...q,kind:{default:"bullet"},indent:{default:0},checked:{default:!1},owner:{default:null},due:{default:null}},toDOM:t=>["div",F(t,{class:"page-li","data-kind":t.attrs.kind,"data-indent":String(t.attrs.indent),"data-checked":t.attrs.checked?"true":"false"}),0]},quote:{group:"block",content:"inline*",attrs:q,toDOM:t=>["blockquote",F(t),0]},callout:{group:"block",content:"inline*",attrs:q,toDOM:t=>["aside",F(t,{class:"page-callout"}),0]},code_block:{group:"block",content:"text*",marks:"",code:!0,defining:!0,attrs:{...q,lang:{default:""}},toDOM:t=>["pre",F(t,{"data-lang":t.attrs.lang}),["code",0]]},toggle:{group:"block",content:"inline*",attrs:{...q,open:{default:!1},level:{default:null}},toDOM:t=>["div",F(t,{class:"page-toggle","data-open":t.attrs.open?"true":"false",...t.attrs.level?{"data-level":String(t.attrs.level)}:{}}),0]},divider:{group:"block",atom:!0,attrs:q,toDOM:t=>["hr",F(t)]},toc:{group:"block",atom:!0,attrs:{...q,maxLevel:{default:null}},toDOM:t=>["div",F(t,{class:"page-toc","data-type":"toc",...t.attrs.maxLevel?{"data-max-level":String(t.attrs.maxLevel)}:{}})]},image:{group:"block",atom:!0,draggable:!0,attrs:{...q,src:{default:""},alt:{default:""},caption:{default:""},width:{default:null},align:{default:null}},toDOM:t=>["figure",F(t,{"data-type":"image",...t.attrs.width?{"data-width":String(t.attrs.width)}:{},...t.attrs.align?{"data-align":t.attrs.align}:{}}),["img",{src:t.attrs.src,alt:t.attrs.alt}],["figcaption",t.attrs.caption]]},file:{group:"block",atom:!0,attrs:{...q,src:{default:""},name:{default:""},size:{default:null},mime:{default:null}},toDOM:t=>["div",F(t,{class:"page-file","data-type":"file","data-src":hi(t.attrs.src)??"","data-name":t.attrs.name,"data-size":t.attrs.size==null?"":String(t.attrs.size),"data-mime":t.attrs.mime??""}),["a",{href:hi(t.attrs.src),target:"_blank",rel:"noopener noreferrer"},t.attrs.name||"file"]]},table:{group:"block",content:"table_row+",isolating:!0,attrs:{...q,cols:{default:{}},sort:{default:null}},toDOM:t=>["table",F(t),["tbody",0]]},table_row:{content:"table_cell+",attrs:{id:{default:null},pos:{default:null}},toDOM:t=>["tr",F(t),0]},table_cell:{content:"inline*",isolating:!0,attrs:{col:{default:null}},toDOM:t=>["td",{"data-col":t.attrs.col},0]},chart:{group:"block",atom:!0,attrs:{...q,source:{default:null},kind:{default:"line"},x:{default:null},series:{default:[]},title:{default:""},highlight:{default:null}},toDOM:t=>["figure",F(t,{"data-type":"chart"})]},board:{group:"block",atom:!0,attrs:{...q,columns:{default:{}},cards:{default:{}}},toDOM:t=>["section",F(t,{"data-type":"board"})]},tool:{group:"block",atom:!0,attrs:{...q,artifact:{default:null},rev:{default:null},state:{default:{}}},toDOM:t=>["section",F(t,{"data-type":"tool"})]},preserved:{group:"block",atom:!0,attrs:{...q,html:{default:""}},toDOM:t=>["div",F(t,{"data-type":"preserved"})]},opaque_block:{group:"block",content:"inline*",atom:!0,isolating:!0,selectable:!0,attrs:{...q,raw:{default:null}},toDOM:t=>["div",F(t,{"data-type":"newer-format","data-format":String(t.attrs.raw?.t??""),contenteditable:"false"}),["span",{class:"page-newer-format"},`Newer format: ${String(t.attrs.raw?.t??"")}`],["span",{class:"page-newer-format-text"},t.textContent]]},text:{group:"inline"},hard_break:{group:"inline",inline:!0,selectable:!1,toDOM:()=>["br"]}},marks:{strong:{toDOM:()=>["strong",0]},em:{toDOM:()=>["em",0]},strike:{toDOM:()=>["s",0]},code:{toDOM:()=>["code",0]},link:{attrs:{href:{}},inclusive:!1,toDOM:t=>["a",{href:Fn(t.attrs.href)},0]},mention:{attrs:{id:{}},inclusive:!1,excludes:"mention date link",toDOM:t=>["span",{"data-page-mention":t.attrs.id},0]},date:{attrs:{date:{}},inclusive:!1,excludes:"mention date link",toDOM:t=>["time",{datetime:t.attrs.date,"data-page-date":""},0]},underline:{toDOM:()=>["u",0]},text_color:{attrs:{color:{}},toDOM:t=>["span",{"data-color":t.attrs.color},0]},highlight:{attrs:{color:{}},toDOM:t=>["mark",{"data-color":t.attrs.color},0]}}});var Df=new Set(["underline","text_color","highlight"]),Dp=["gray","brown","orange","yellow","green","blue","purple","pink","red"],Ep=new Set(Dp);function Xe(t,e){let n=e!==null&&typeof e=="object"&&!Array.isArray(e);if(t==="underline")return n&&Object.keys(e).length===0?{}:null;if(t==="text_color"||t==="highlight"){let o=n?Object.keys(e):[];return o.length===1&&o[0]==="color"&&Ep.has(e.color)?{color:e.color}:null}return null}function Ef(t,e){let{$from:n,$to:o,empty:i}=t.selection;if(i)return n.parent.type.allowsMarkType(e);let s=!1;return t.doc.nodesBetween(n.pos,o.pos,(r,l,a)=>{!s&&r.isText&&a?.type.allowsMarkType(e)&&(s=!0)}),s}var Tp='@{"type":"hard_break"}';function Ot(t){if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);if(t===null||typeof t!="object"||typeof t.c!="string")return"";let e=[];for(let o of Array.isArray(t.m)?t.m:[])if(!Array.isArray(o))e.push(o);else for(let i=0;i<o[0]&&e.length<t.c.length;i++)e.push(o[1]);let n="";for(let o=0;o<t.c.length;o++)n+=t.c[o]==="\uFFFC"&&e[o]===Tp?`
|
|
11
|
-
`:t.c[o];return n}var Ll="opaque_marks",Qt="clay_opaque_code",Jl="x",ql=/^[A-Za-z_][A-Za-z0-9_-]{0,63}$/,zl=32,Fl=1e4,$p=/[A-Za-z]/,tn=t=>t!==null&&typeof t=="object"&&!Array.isArray(t),pi=t=>t===null||typeof t!="object"?t:JSON.parse(JSON.stringify(t));function Vn(t){let e=0,n=(o,i)=>{if(i>zl)throw new RangeError(`page: inline JSON is deeper than ${zl}`);if(!(o===null||typeof o!="object")){if(Array.isArray(o)){for(let s of o)n(s,i+1);return}for(let s of Object.keys(o)){if(++e>Fl)throw new RangeError(`page: inline JSON has more than ${Fl} keys`);n(o[s],i+1)}}};return n(t,1),t}function Ip(t,e){let n=0,o=!1;for(;e<t.length;e++){let i=t[e];if(o)i==="\\"?e++:i==='"'&&(o=!1);else if(i==='"')o=!0;else if(i==="[")n++;else if(i==="]"&&--n===0)return e+1}throw new SyntaxError(`page: unterminated attrs in mark key ${t}`)}var Vl=t=>new SyntaxError(`page: malformed mark key ${t}`);function en(t){if(typeof t!="string")throw new TypeError("page: a mark key is not a string");let e=[];for(let n=0;n<t.length;){let o=t[n];if(!$p.test(o))throw Vl(t);let i=n+1,s=null;if(t[i]==="["&&(i=Ip(t,i),s=Vn(JSON.parse(t.slice(n+1,i))),!Array.isArray(s)))throw Vl(t);if(o!==Jl)e.push({code:o,attrs:s,token:t.slice(n,i)});else{if(!s||s.length!==2||typeof s[0]!="string"||!ql.test(s[0])||!tn(s[1]))throw new SyntaxError(`page: the named mark in ${t} is not [name, attrs]`);if(s[0]===Qt)throw new SyntaxError(`page: ${Qt} is reserved`);e.push({name:s[0],attrs:pi(s[1])})}n=i}return e}var Rp=(t,e)=>{if(t.name!==e.name)return t.name<e.name?-1:1;let n=JSON.stringify(t.attrs),o=JSON.stringify(e.attrs);return n===o?0:n<o?-1:1};function me(t){let e=[],n=[],o=new Set;for(let i of t)if(i.name===void 0){if(o.has(i.token))throw new TypeError(`page: duplicate mark descriptor ${i.token}`);o.add(i.token),n.push(i.token)}else{let s=JSON.stringify([i.name,i.attrs]);if(o.has(s))throw new TypeError(`page: duplicate mark descriptor ${s}`);o.add(s),e.push({name:i.name,attrs:pi(i.attrs)})}return e.sort(Rp),n.length?[...e,{tokens:n}]:e}function Ft(t){if(!Array.isArray(t))throw new TypeError("page: opaque entries are not a list");let e=[];for(let n of t){if(!tn(n))throw new TypeError("page: an opaque entry is not an object");if(n.tokens!==void 0){if(Object.keys(n).length!==1||!Array.isArray(n.tokens))throw new TypeError("page: an opaque entry is not { tokens: [...] }");for(let o of n.tokens){let i=en(o);if(i.length!==1||i[0].name!==void 0)throw new SyntaxError(`page: malformed mark token ${o}`);e.push(i[0])}}else{if(Object.keys(n).length!==2||typeof n.name!="string"||!ql.test(n.name)||!tn(n.attrs))throw new TypeError("page: an opaque entry is not { name, attrs }");if(n.name===Qt)throw new SyntaxError(`page: ${Qt} is reserved`);e.push({name:n.name,attrs:Vn(n.attrs)})}}return me(e)}function nn(t){let e="";for(let n of Ft(t))n.tokens?e+=n.tokens.join(""):e+=Jl+JSON.stringify([n.name,n.attrs]);return e}var Pp=(()=>{let t=new gt.MarkType(Ll,Object.keys(di.marks).length,di,{attrs:{entries:{default:[]}},inclusive:!1,excludes:"",toDOM:()=>["span",0]});return t.excluded=[],t})(),Wl=t=>t.type.name===Ll,Kl=t=>Pp.create({entries:Ft(t)});function Pf(t){let e=Object.create(null);for(let n of Ft(t))n.tokens?e[Qt]={tokens:[...n.tokens]}:e[n.name]=pi(n.attrs);return e}var Bp=t=>t.split("!")[0].split("~")[0],jl=t=>t.includes("!");function Bf(t){let e=new Set;for(let o of Object.keys(t))jl(o)&&t[o]&&e.add(o.split("!")[0]);let n=[];for(let[o,i]of Object.entries(t)){if(i==null||jl(o)||e.has(o))continue;let s=Bp(o);if(s===Qt){if(!tn(i)||Object.keys(i).length!==1||!Array.isArray(i.tokens))throw new TypeError(`page: ${Qt} is not { tokens: [...] }`);n.push({tokens:i.tokens})}else n.push({name:s,attrs:tn(i)?i:{}})}return Ft(n)}var ui="\uFFFC",Gl={strong:"b",em:"i",strike:"s",code:"c",link:"a"},Yl=new Set(["underline","text_color","highlight"]),zp=Object.fromEntries(Object.entries(Gl).map(([t,e])=>[e,t]));function Fp(t){let e="",n=[];for(let o of t){if(Wl(o)){e+=nn(o.attrs.entries);continue}let i=Gl[o.type.name];if(!i){let r=Xe(o.type.name,o.attrs);if(!r&&Yl.has(o.type.name))throw new TypeError(`page: the mark ${o.type.name} has no key code`);n.push({name:o.type.name,attrs:r??o.attrs});continue}e+=i;let s=Object.keys(o.type.attrs);s.length&&(e+=JSON.stringify(s.map(r=>o.attrs[r])))}return n.length?e+nn(n):e}var Hl=new WeakMap;function Vp(t,e){if(!e)return gt.Mark.none;let n=Hl.get(t);n||Hl.set(t,n=new Map);let o=n.get(e);if(o)return o;o=[];let i=[];for(let s of en(e)){if(s.code===void 0){let h=Xe(s.name,s.attrs),c=t.marks[s.name];h?o=c.create(h).addToSet(o):c&&!Yl.has(s.name)&&Object.keys(s.attrs??{}).every(d=>Object.hasOwn(c.attrs,d))?o=c.create(s.attrs).addToSet(o):i.push(s);continue}let r=zp[s.code];if(!r){i.push(s);continue}let l=t.marks[r];if(!l)throw new TypeError(`page: unknown mark code ${s.code} in ${e}`);let a=s.attrs?Object.fromEntries(Object.keys(l.attrs).map((h,c)=>[h,s.attrs[c]])):null;o=l.create(a).addToSet(o)}return i.length&&(o=Kl(me(i)).addToSet(o)),n.set(e,o),o}function fi(t){let e="",n=[];return t.forEach(o=>{if(o.isText){let i=Fp(o.marks);e+=o.text;for(let s=0;s<o.text.length;s++)n.push(i)}else e+=ui,n.push("@"+JSON.stringify(o.toJSON()))}),{c:e,m:n}}function _l(t){let e=[];for(let n of t){let o=e[e.length-1];o&&o[1]===n?o[0]++:e.push([1,n])}return e}var jp=t=>Array.isArray(t)&&Array.isArray(t[0]);function mi(t,e){if(!jp(t))return t;let n=[];for(let o of t){if(!Array.isArray(o)||!Number.isInteger(o[0])||o[0]<1||typeof o[1]!="string"||n.length+o[0]>e)return null;for(let i=0;i<o[0];i++)n.push(o[1])}return n.length===e?n:null}var Lp=t=>t>=55296&&t<=56319,Ul=t=>t&&t[0]!=="@"?t:"";function gi(t,e,n,o=null){let i=[],s=r=>o?r.filter(l=>o.allowsMarkType(l.type)):r;for(let r=0;r<e.length;){let l=n&&n[r]||"";if(e[r]===ui&&l[0]==="@"){i.push(gt.Node.fromJSON(t,JSON.parse(l.slice(1)))),r++;continue}let a=Ul(l),h=r+1;for(;h<e.length&&!(e[h]===ui&&(n&&n[h]||"")[0]==="@")&&Ul(n&&n[h]||"")===a;)h++;h<e.length&&Lp(e.charCodeAt(h-1))&&h++,i.push(t.text(e.slice(r,h),s(Vp(t,a)))),r=h}return i}var Jp="clay-page-remote",on="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",qp=/^[0-9A-Za-z]*[1-9A-Za-z]$/,sn=t=>typeof t=="string"&&qp.test(t);function yi(t,e){if(e!==null){let i=0;for(;(t[i]||"0")===e[i];)i++;if(i>0)return e.slice(0,i)+yi(t.slice(i),e.slice(i))}let n=t?on.indexOf(t[0]):0,o=e!==null?on.indexOf(e[0]):on.length;return o-n>1?on[Math.round((n+o)/2)]:e!==null&&e.length>1?e.slice(0,1):on[n]+yi(t.slice(1),null)}function Ql(t=null,e=null){if(t!==null&&!sn(t))throw new TypeError(`page: invalid order key ${t}`);if(e!==null&&!sn(e))throw new TypeError(`page: invalid order key ${e}`);if(t!==null&&e!==null&&t>=e)throw new RangeError(`page: order key ${t} is not before ${e}`);return yi(t??"",e)}function ge(t,e,n){if(n<=0)return[];if(n===1)return[Ql(t,e)];let o=Ql(t,e),i=Math.floor(n/2);return[...ge(t,o,i),o,...ge(o,e,n-i-1)]}function wi(t){return Object.keys(t).sort((e,n)=>{let o=t[e].pos??"",i=t[n].pos??"";return o!==i?o<i?-1:1:e<n?-1:e>n?1:0})}function Wp(t="b"){let e=new Uint8Array(4);return globalThis.crypto.getRandomValues(e),`${t}-${Date.now().toString(36)}${Array.from(e,n=>(n%36).toString(36)).join("")}`}var Kp=new Set(["id","pos"]),Hp=(t,e)=>JSON.stringify(t)===JSON.stringify(e),Up=t=>t===null||typeof t!="object"?t:JSON.parse(JSON.stringify(t));function Gp(t){let e={};for(let[n,o]of Object.entries(t.type.spec.attrs||{}))Kp.has(n)||Hp(t.attrs[n],o.default)||(e[n]=Up(t.attrs[n]));return e}function Yp(t){let{c:e,m:n}=fi(t.content);return n.some(Boolean)?{c:e,m:_l(n)}:e}function _p(t,e){if(e!==null&&typeof e=="object"&&typeof e.c=="string"){let o=mi(e.m,e.c.length);if(o)return gi(t,e.c,o,t.nodes.table_cell)}let n=Ot(e);return n?t.text(n):null}function Qp(t){let e={t:t.type.name,pos:t.attrs.pos,...Gp(t)};if(t.type.name==="table"){let n={};t.forEach(o=>{let i={};o.forEach(s=>{i[s.attrs.col]=Yp(s)}),n[o.attrs.id]={pos:o.attrs.pos,cells:i}}),e.rows=n}else if(t.type.spec.content){let{c:n,m:o}=fi(t.content);e.c=n,o.some(Boolean)&&(e.m=o)}return e}function Kf(t){let e={};return t.forEach(n=>{e[n.attrs.id]=Qp(n)}),e}function Zp(t,e,n){let{t:o,pos:i,c:s,m:r,w:l,rows:a,...h}=n;if(o==="table"){let p=wi(h.cols||{}),{table_row:f,table_cell:u}=t.nodes,m=wi(a||{}).map(g=>f.createChecked({id:g,pos:a[g].pos},p.map(v=>u.createChecked({col:v},_p(t,a[g].cells?.[v])))));return t.nodes.table.createChecked({...h,id:e,pos:i},m)}let c=t.nodes[o];if(!c)throw new RangeError(`page: unknown block type ${o}`);let d=typeof s=="string"?gi(t,s,mi(r,s.length),c):Array.isArray(s)&&s.length?gt.Fragment.fromJSON(t,s):null;return c.create({...h,id:e,pos:i},d)}function Hf(t,e){let n=wi(e).map(o=>Zp(t,o,e[o]));return n.length?t.nodes.doc.create(null,n):t.nodes.doc.createAndFill()}function Xp(t){let e=[],n=[],o=new Array(t.length).fill(-1);t.forEach((s,r)=>{if(s===null)return;let l=0,a=e.length;for(;l<a;){let h=l+a>>1;e[h]<s?l=h+1:a=h}l>0&&(o[r]=n[l-1]),e[l]=s,n[l]=r});let i=new Set;for(let s=n[e.length-1]??-1;s>=0;s=o[s])i.add(s);return i}function Zl(t,e){let n=new Map;t.forEach(({id:r,rank:l=0},a)=>{r&&(!n.has(r)||l>(t[n.get(r)].rank??0))&&n.set(r,a)});let o=t.map(({id:r},l)=>!r||n.get(r)!==l),i=Xp(t.map(({pos:r},l)=>!o[l]&&sn(r)?r:null)),s=t.map(()=>null);for(let r=0;r<t.length;){if(i.has(r)){r++;continue}let l=r;for(;l<t.length&&!i.has(l);)l++;let a=r>0?t[r-1].pos:null,h=l<t.length?t[l].pos:null,c=ge(a,h,l-r);for(let d=r;d<l;d++)s[d]={id:o[d]?Wp(e):t[d].id,pos:c[d-r]};r=l}return s}function tu(t){for(let e=0;e<t.steps.length;e++){let n=t.steps[e];if(n instanceof pe.ReplaceStep){if(n.slice.openStart||n.slice.openEnd)return!1;for(let s=0;s<n.slice.content.childCount;s++)if(!n.slice.content.child(s).isInline)return!1}else if(!(n instanceof pe.AddMarkStep||n instanceof pe.RemoveMarkStep))return!1;let o=t.docs[e].resolve(n.from),i=t.docs[e].resolve(n.to);if(o.depth!==1||i.depth!==1||o.index(0)!==i.index(0)||!o.parent.isTextblock)return!1}return!0}function Uf(){let t=new WeakSet,e=n=>{let o=new Set,i=null,s=!0;return n.forEach(r=>{if((!r.attrs.id||o.has(r.attrs.id)||!sn(r.attrs.pos)||i!==null&&i>=r.attrs.pos)&&(s=!1),o.add(r.attrs.id),i=r.attrs.pos,r.type.name!=="table")return;let l=new Set,a=null;r.forEach(h=>{(!h.attrs.id||l.has(h.attrs.id)||!sn(h.attrs.pos)||a!==null&&a>=h.attrs.pos)&&(s=!1),l.add(h.attrs.id),a=h.attrs.pos})}),s};return new zo.Plugin({state:{init(n,o){return e(o.doc)&&t.add(o.doc),null},apply(){return null}},appendTransaction(n,o,i){if(t.has(o.doc)&&n.every(tu))return t.add(i.doc),null;if(!n.some(f=>f.docChanged&&!f.getMeta(Jp)))return t.has(o.doc)&&e(i.doc)&&t.add(i.doc),null;let s=i.tr,r=(f,u,m)=>{m&&s.setNodeMarkup(u,null,{...f.attrs,...m})},l=new pe.Mapping;for(let f of n)l.appendMapping(f.mapping);let a=new Map,h=(f,u)=>{if(!f.attrs.id)return;let m=l.mapResult(u,1);a.set(f.attrs.id,{node:f,at:m.deleted?null:m.pos})};o.doc.forEach((f,u)=>{h(f,u),f.type.name==="table"&&f.forEach((m,g)=>h(m,u+1+g))});let c=(f,u)=>{let m=a.get(f.attrs.id);return m?(m.node.content.eq(f.content)?2:0)+(m.at===u?1:0):0},d=f=>f.map(({node:u,at:m})=>({...u.attrs,rank:c(u,m)})),p=[];i.doc.forEach((f,u)=>p.push({node:f,at:u})),Zl(d(p),"b").forEach((f,u)=>r(p[u].node,p[u].at,f));for(let{node:f,at:u}of p){if(f.type.name!=="table")continue;let m=[];f.forEach((g,v)=>m.push({node:g,at:u+1+v})),Zl(d(m),"r").forEach((g,v)=>r(m[v].node,m[v].at,g))}return s.docChanged||t.add(i.doc),s.docChanged?s:null}})}var vi=class extends Error{constructor(e,n){super(`CSV ${e} at line ${n}`),this.name="CsvError",this.code=e,this.line=n}};function eu(t){let e=new Map([[",",0],[";",0],[" ",0]]),n=!1;for(let o=0;o<t.length;o++){let i=t[o];if(i==='"')n&&t[o+1]==='"'?o++:n=!n;else{if(!n&&(i==="\r"||i===`
|
|
12
|
-
`))break;!n&&e.has(i)&&e.set(i,e.get(i)+1)}}return[...e].sort((o,i)=>i[1]-o[1])[0][0]}function _f(t,{delimiter:e}={}){if(t=String(t).replace(/^\uFEFF/,""),e??=eu(t),typeof e!="string"||e.length!==1||/["\r\n]/.test(e))throw new TypeError("CSV delimiter must be one non-newline character");let n=[],o=[],i="",s=!1,r=1,l=1;for(let d=0;d<t.length;d++){let p=t[d];s?p==='"'?t[d+1]==='"'?(i+='"',d++):s=!1:p==="\r"||p===`
|
|
13
|
-
`?(i+=p,p==="\r"&&t[d+1]===`
|
|
14
|
-
`&&(i+=t[++d]),r++):i+=p:p==='"'&&i===""?(s=!0,l=r):p===e?(o.push(i),i=""):p==="\r"||p===`
|
|
15
|
-
`?(o.push(i),n.push(o),o=[],i="",p==="\r"&&t[d+1]===`
|
|
16
|
-
`&&d++,r++):i+=p}if(s)throw new vi("unterminated-quote",l);if((o.length||i!==""||t&&!/[\r\n]$/.test(t))&&n.push([...o,i]),!n.length)return{header:[],rows:[]};let[a,...h]=n,c=Math.max(a.length,...h.map(d=>d.length));a.length=c;for(let d=0;d<c;d++)a[d]??="";for(let d of h)for(let p=d.length;p<c;p++)d.push("");return{header:a,rows:h}}function bi(t){if(typeof t!="string"||!/^[+-]?(?:0|[1-9]\d*)(?:[.,]\d+)?$/.test(t))return null;let e=Number(t.replace(",","."));return Number.isFinite(e)?e:null}function Xl(t,e){return t.map((n,o)=>{let i=e.map(r=>r[o]??"").filter(r=>r.trim()!=="");return i.length?new Set(i.map(r=>r.includes(",")?",":r.includes(".")?".":null).filter(Boolean)).size<=1&&i.every(r=>bi(r)!==null)?"number":i.every(r=>{if(!/^\d{4}-\d{2}-\d{2}$/.test(r))return!1;let l=new Date(`${r}T00:00:00Z`);return!Number.isNaN(l.getTime())&&l.toISOString().slice(0,10)===r})?"date":"text":"text"})}var nu=Object.freeze(["text","number","date"]);function Qf(t,e){return nu.includes(t)?t:Xl([""],e.map(n=>[n]))[0]}function Zf({header:t,rows:e},{maxBytes:n=1/0,newId:o}={}){if(typeof o!="function")throw new TypeError("tableFromCsv needs newId");let i=Xl(t,e),s={},r=t.map(()=>o()),l=ge(null,null,t.length);t.forEach((f,u)=>{s[r[u]]={pos:l[u],name:f,kind:i[u]}});let a={},h=ge(null,null,e.length),c=new TextEncoder,d=c.encode(JSON.stringify({cols:s,rows:a})).length,p=0;for(let f=0;f<e.length;f++){let u=o(),m={pos:h[f],cells:Object.fromEntries(r.map((v,y)=>[v,e[f][y]??""]))},g=c.encode(`${p?",":""}${JSON.stringify(u)}:${JSON.stringify(m)}`).length;if(d+g>n)break;a[u]=m,d+=g,p++}return{cols:s,rows:a,truncated:p===e.length?null:{kept:p,total:e.length}}}var rt=t=>String(t??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),T=t=>Number(t.toFixed(2)).toString();function ta(t,e,n){t===e&&(t-=Math.max(Math.abs(t)*.05,1),e+=Math.max(Math.abs(e)*.05,1));let o=(e-t)/(n-1),i=10**Math.floor(Math.log10(o)),s=[1,2,5,10].map(a=>a*i),r=s.find(a=>Math.floor(e/a)-Math.ceil(t/a)+1<=n)??s.at(-1);for(;Math.floor(e/r)-Math.ceil(t/r)+1>n;)r*=2;let l=[];for(let a=Math.ceil(t/r);a<=Math.floor(e/r);a++)l.push(Number((a*r).toPrecision(12)));return l.length?l:[Number(t.toFixed(2)),Number(e.toFixed(2))]}var ea=(t,e)=>({state:"missing",reason:e,sourceId:t.source??null,title:t.title??""});function na(t,e){if(!e)return ea(t,"table");let n=e.cols??[],o=e.rows??[];if(!n.find(d=>d.id===t.x)||!t.series?.length||t.series.some(d=>!n.some(p=>p.id===d)))return ea(t,"column");let r=(t.type==="pie"?t.series.slice(0,1):t.series).map((d,p)=>{let f=n.find(m=>m.id===d),u=o.map((m,g)=>({id:`${t.id}:${m.id}:${d}`,rowId:m.id,colId:d,rowIndex:g,xLabel:Ot(m.cells?.[t.x]),value:bi(Ot(m.cells?.[d])),highlight:m.id===t.highlight}));return{id:d,name:f.name,color:`var(--chart-${p%6+1})`,points:u}}),l=r.flatMap(d=>d.points),a=l.map(d=>d.value).filter(d=>d!==null),h=a.length?a.reduce((d,p)=>Math.min(d,p),1/0):0,c=a.length?a.reduce((d,p)=>Math.max(d,p),-1/0):1;if(t.type==="bar")h=Math.min(h,0),c=Math.max(c,0);else{let d=(c-h||Math.max(Math.abs(c),1))*.05;h-=d,c+=d}return h===c&&(c=h+1),{state:"ok",type:t.type,title:t.title??"",series:r,points:l,xLabels:o.map(d=>Ot(d.cells?.[t.x])),yTicks:ta(h,c,6),narrowTicks:ta(h,c,3),domain:[h,c]}}var R={width:560,height:232,cx:150,cy:116,radius:84},jn=6,ou=t=>Math.max(R.height,54+(t-1)*36+24);function oa(t){let e=t.points.filter(n=>n.value!==null);return`${t.name}: ${e.length?`${T(e[0].value)} to ${T(e.at(-1).value)}`:"no values"}`}function iu(t){let e=t.series[0];if(!e)return[];let n=e.points.filter(r=>r.value!==null&&r.value>0),o=n.reduce((r,l)=>r+l.value,0);if(!o)return[];let i=n.length<=jn?n:[...n.slice(0,jn-1),{id:`${n[0].id.split(":")[0]}:other`,xLabel:"Other",value:n.slice(jn-1).reduce((r,l)=>r+l.value,0),highlight:n.slice(jn-1).some(r=>r.highlight)}],s=-Math.PI/2;return i.map((r,l)=>{let a=r.value/o,h={point:r,color:`var(--chart-${l%6+1})`,fraction:a,percent:Math.round(a*100),from:s,to:s+a*Math.PI*2};return s=h.to,h})}function su(t,e,n){let o=ou(e.length),i=T(n*o/R.width),s=t.series[0]?oa(t.series[0]):"no values",r=[`<svg xmlns="http://www.w3.org/2000/svg" role="img" width="${n}" height="${i}" viewBox="0 0 ${R.width} ${o}">`,`<title>${rt(t.title)}</title>`,`<desc>${rt(s)}</desc>`];return e.length||r.push(`<text x="${R.width/2}" y="${R.cy}" text-anchor="middle">No positive values to chart</text>`),e.forEach(l=>{let a=` data-point="${rt(l.point.id)}"${l.point.highlight?' data-highlight="true"':""}`;if(l.fraction>=.999){r.push(`<circle${a} cx="${R.cx}" cy="${R.cy}" r="${R.radius}" fill="${l.color}"/>`);return}let h=T(R.cx+R.radius*Math.cos(l.from)),c=T(R.cy+R.radius*Math.sin(l.from)),d=T(R.cx+R.radius*Math.cos(l.to)),p=T(R.cy+R.radius*Math.sin(l.to));r.push(`<path${a} d="M ${R.cx} ${R.cy} L ${h} ${c} A ${R.radius} ${R.radius} 0 ${l.fraction>.5?1:0} 1 ${d} ${p} Z" fill="${l.color}" stroke="var(--page-bg)" stroke-width="2"/>`)}),e.forEach((l,a)=>{let h=T(54+a*36),c=` data-point="${rt(l.point.id)}"${l.point.highlight?' data-highlight="true"':""}`;r.push(`<g${c}><rect x="290" y="${T(54+a*36-10)}" width="11" height="11" fill="${l.color}"/><text x="310" y="${h}">${rt(l.point.xLabel)}</text><text x="530" y="${h}" text-anchor="end">${T(l.point.value)} (${l.percent}%)</text></g>`)}),r.push("</svg>"),r.join("")}function ia(t,{width:e=640,height:n=320,narrow:o=!1}={}){if(t.state==="missing")return`<svg xmlns="http://www.w3.org/2000/svg" role="img" width="${e}" height="80" viewBox="0 0 ${e} 80"><title>Chart source missing</title><text x="12" y="44">Chart source missing</text></svg>`;if(t.type==="pie")return su(t,iu(t),e);let i={left:52,right:72,top:28,bottom:48},s=Math.max(1,e-i.left-i.right),r=Math.max(1,n-i.top-i.bottom),[l,a]=t.domain,h=u=>i.top+(a-u)/(a-l)*r,c=t.xLabels.length,d=u=>i.left+(c<=1?s/2:u*s/(c-1)),p=[`<svg xmlns="http://www.w3.org/2000/svg" role="img" width="${e}" height="${n}" viewBox="0 0 ${e} ${n}">`,`<title>${rt(t.title)}</title>`],f=t.series.map(oa).join("; ");p.push(`<desc>${rt(f)}</desc>`);for(let u of o?t.narrowTicks:t.yTicks){let m=T(h(u));p.push(`<line x1="${i.left}" y1="${m}" x2="${T(i.left+s)}" y2="${m}" stroke="currentColor" opacity="0.15"/><text x="${i.left-8}" y="${T(h(u)+4)}" text-anchor="end">${T(u)}</text>`)}if(t.type==="bar"){let u=s/Math.max(c,1),m=Math.max(1,Math.min(32,u*.7/t.series.length)),g=h(0);t.series.forEach((v,y)=>{v.points.forEach(S=>{if(S.value===null)return;let $=i.left+(S.rowIndex+.5)*u-t.series.length*m/2+y*m,Y=h(S.value);p.push(`<rect data-point="${rt(S.id)}"${S.highlight?' data-highlight="true"':""} x="${T($)}" y="${T(Math.min(Y,g))}" width="${T(m)}" height="${T(Math.abs(g-Y))}" fill="${v.color}"/>`)});let w=[...v.points].reverse().find(S=>S.value!==null);if(w){let S=i.left+(w.rowIndex+.5)*u-t.series.length*m/2+y*m;p.push(`<text x="${T(S+m/2)}" y="${T(Math.min(h(w.value),g)-7)}" text-anchor="middle">${rt(v.name)}</text>`)}})}else t.series.forEach(u=>{let m=[],g=()=>{m.length>1&&p.push(`<polyline points="${m.join(" ")}" fill="none" stroke="${u.color}" stroke-width="2"/>`),m=[]};u.points.forEach(y=>{if(y.value===null){g();return}m.push(`${T(d(y.rowIndex))},${T(h(y.value))}`),p.push(`<circle data-point="${rt(y.id)}"${y.highlight?' data-highlight="true"':""} cx="${T(d(y.rowIndex))}" cy="${T(h(y.value))}" r="3" fill="${u.color}"/>`)}),g();let v=[...u.points].reverse().find(y=>y.value!==null);v&&p.push(`<text x="${T(d(v.rowIndex)+7)}" y="${T(h(v.value)-5)}">${rt(u.name)}</text>`)});return t.xLabels.forEach((u,m)=>{let g=t.type==="bar"?i.left+(m+.5)*s/Math.max(c,1):d(m);p.push(`<text x="${T(g)}" y="${T(n-14)}" text-anchor="middle">${rt(u)}</text>`)}),p.push("</svg>"),p.join("")}var cn="\uFFFC",Si='@{"type":"hard_break"}',ha=["b","i","s","c","a"],ru={b:"strong",i:"em",s:"s",c:"code"},lu=["a","b","i","s","c"],au=new Set(ha),ln="data-clay-page-opaque",Oi="data-clay-page-value",Ln="data-clay-page-marks",cu="data-page-mention",hu="data-page-date",du=/^\d{4}-\d{2}-\d{2}$/,Hn="1",Mi=new Set(["id","t","parent","c","m"]),Un=t=>Object.hasOwn(ye,t),ye={paragraph:{parent:null},heading:{parent:null,level:2,pageIcon:null,pageCoverSrc:null,pageCoverAlt:"",pageCoverX:50,pageCoverY:50},list_item:{parent:null,kind:"bullet",indent:0,checked:!1,owner:null,due:null},callout:{parent:null},quote:{parent:null},code_block:{parent:null,lang:""},toggle:{parent:null,open:!1,level:null},divider:{parent:null},toc:{parent:null,maxLevel:null},image:{parent:null,src:"",alt:"",caption:"",width:null,align:null},file:{parent:null,src:"",name:"",size:null,mime:null},table:{parent:null,cols:{},sort:null},chart:{parent:null,source:null,kind:"line",x:null,series:[],title:"",highlight:null},board:{parent:null,columns:{},cards:{}},tool:{parent:null,artifact:null,rev:null,state:{}},preserved:{parent:null,html:""}},da=new Set(["paragraph","heading","list_item","callout","quote","code_block","toggle"]),pa="Table of contents",pu="page-block-",uu=t=>`${pu}${dn(String(t??""))}`,ua=3,fu=t=>t.t==="heading"?Math.min(6,Math.max(1,Number.isInteger(t.level)?t.level:2)):t.t==="toggle"&&(t.level===1||t.level===2||t.level===3)?t.level:0,fa=t=>t.t==="heading"&&(t.level??2)===1&&(t.parent??null)===null,mu=t=>Number.isInteger(t)&&t>=1&&t<=6?t:ua,gu=t=>String(t.c??"").replace(/[\s\uFFFC]+/gu," ").trim()||"Untitled";function yu(t,e=ua){let n=mu(e),o=t.find(fa)??null,i=[];for(let s of t){let r=fu(s);!s.id||!r||r>n||s===o||i.push({id:s.id,level:r,text:gu(s)})}return i}function wu(t,e){let n=yu(e,t.maxLevel),o={level:0,children:[]},i=[o];for(let l of n){for(;i.length>1&&i[i.length-1].level>=l.level;)i.pop();let a={...l,children:[]};i[i.length-1].children.push(a),i.push(a)}let s=l=>`<ul>${l.map(a=>`<li><a href="#${uu(a.id)}">${lt(a.text)}</a>${a.children.length?s(a.children):""}</li>`).join("")}</ul>`,r=t.maxLevel==null?"":` data-max-level="${we(t.maxLevel)}"`;return`<nav aria-label="${pa}" data-type="toc" data-id="${we(t.id??"")}"${r}>${n.length?s(o.children):""}</nav>`}var ma=(t,e)=>yt(t)===yt(e);function hn(t){return Object.keys(t).sort((e,n)=>{let o=t[e].pos??"",i=t[n].pos??"";return o!==i?o<i?-1:1:e<n?-1:e>n?1:0})}var dn=t=>{let e="";for(let n of new TextEncoder().encode(t))e+=String.fromCharCode(n);return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")},vu=t=>{let e=atob(String(t).replace(/-/g,"+").replace(/_/g,"/"));return new TextDecoder().decode(Uint8Array.from(e,n=>n.charCodeAt(0)))},ki=t=>t===null||typeof t!="object"?!1:Array.isArray(t)?t.some(ki):Object.keys(t).some(e=>e==="__proto__"||ki(t[e]));function ga(t){let e;try{e=JSON.parse(vu(t))}catch{throw new SyntaxError("page: an envelope is not readable canonical JSON")}try{Vn(e)}catch(n){throw new SyntaxError(n.message)}if(ki(e))throw new SyntaxError("page: an envelope holds a prototype key");return e}function bu(t){let e=ga(t);if(e===null||typeof e!="object"||Array.isArray(e))throw new SyntaxError("page: a block envelope is not a record");if("id"in e||"pos"in e)throw new SyntaxError("page: a block envelope holds a structural field");if("t"in e&&(typeof e.t!="string"||!e.t))throw new SyntaxError("page: a block envelope names no type");return e}function ya(t){try{return Ft(ga(t))}catch(e){throw e instanceof SyntaxError?e:new SyntaxError(e.message)}}var am=t=>ya(t),wa=t=>` ${ln}="${Hn}" ${Oi}="${we(dn(yt(t)))}"`,sa=t=>t.length?` ${Ln}="${we(dn(JSON.stringify(t)))}"`:"",cm=t=>({[ln]:Hn,[Oi]:dn(yt(t))}),hm=t=>({[Ln]:dn(JSON.stringify(Ft(t)))});function Jn(t,e){if(!Array.isArray(t))return null;if(!Array.isArray(t[0]))return t.length===e?t:null;let n=[];for(let o of t){if(!Array.isArray(o)||!Number.isInteger(o[0])||o[0]<1||typeof o[1]!="string"||n.length+o[0]>e)return null;for(let i=0;i<o[0];i++)n.push(o[1])}return n.length===e?n:null}function va(t){let e=[];for(let n of t){let o=e[e.length-1];o&&o[1]===n?o[0]++:e.push([1,n])}return e}function ba(t){let e={},n=[];if(!t||t[0]==="@")return{marks:e,native:[],entries:[]};let o=[];for(let i of en(t)){if(i.name===void 0){au.has(i.code)?e[i.code]=i.attrs??!0:o.push(i);continue}let s=Xe(i.name,i.attrs);s?n.push({name:i.name,attrs:s}):o.push(i)}return{marks:e,native:n,entries:o.length?me(o):[]}}var xa=(t,e,n)=>{if(!t)return"";if(t[0]==="@")return t===Si&&e[n]===cn?t:"";let{marks:o,native:i,entries:s}=ba(t);return Oa(Sa(o),i.length?[...s,...me(i)]:s)},ka=/^(javascript|vbscript|data):/i,Sa=t=>(t.a&&ka.test(String(t.a[0]).replace(/[\u0000-\u0020]/g,""))&&delete t.a,t);function Oa(t,e=[]){let n="";for(let o of ha)t[o]&&(n+=o,Array.isArray(t[o])&&(n+=JSON.stringify(t[o])));return e.length?n+nn(e):n}function ct(t,e){if(!t.includes(`
|
|
17
|
-
`)&&!t.includes("\r"))return{c:t,units:e};let n="",o=[];for(let i=0;i<t.length;)if(/\s/.test(t[i])&&t[i]!=="\xA0"){let s=i;for(;s<t.length&&/\s/.test(t[s])&&t[s]!=="\xA0";)s++;let r=t.slice(i,s);/[\n\r]/.test(r)?i>0&&s<t.length&&(n+=" ",o.push(e?e[i]:"")):(n+=r,e?o.push(...e.slice(i,s)):o.push(...r.split("").map(()=>""))),i=s}else n+=t[i],o.push(e?e[i]:""),i++;return{c:n,units:o}}function an(t,e){let n={c:t};return e&&e.some(Boolean)&&(n.m=va(e)),n}function dm(t){let e={};for(let n of t){if(!n||typeof n!="object")continue;let o=n.deleted||{};for(let[i,s]of Object.entries(n.blocks||{})){if(o[i]||!s||typeof s!="object")continue;let{w:r,...l}=s;e[i]=l}}return e}function xu(t){let e=[],n=[],o=null;for(let i of hn(t)){let s=t[i],r=typeof s.t=="string"&&s.t?s.t:null,l=s.parent??null;if(l!==null){let c=n.lastIndexOf(l);c<0&&(l=null),n.length=c<0?0:c+1}else n.length=0;let a=0;if(r==="list_item"){let c=o&&o.t==="list_item"&&o.parent===l,d=Number.isInteger(s.indent)&&s.indent>0?s.indent:0;a=c?Math.min(d,o.indent+1):0}let h={id:i,b:s,t:r,parent:l,indent:a};e.push(h),o=h,r==="toggle"&&n.push(i)}return e}var P=(t,e)=>{let n={};for(let[o,i]of Object.entries(e))(!(o in ye[t])||!ma(i,ye[t][o]))&&(n[o]=i);return n},qn=t=>Math.min(100,Math.max(0,Number.isFinite(+t)&&t!==null&&t!==""?+t:50)),Wn=t=>typeof t=="number"&&Number.isFinite(t)&&t>0?Math.round(t):null;function ku(t){if(t===null||typeof t!="object"||typeof t.c!="string")return ct(Ot(t),null).c;let e=Jn(t.m,t.c.length),n=e&&e.map((s,r)=>xa(s,t.c,r));if(!n)return ct(Ot(t),null).c;let o=ct(t.c,n),i=an(o.c,o.units);return i.m?i:i.c}function Su(t){let e=t.cols&&typeof t.cols=="object"?t.cols:{},n=t.rows&&typeof t.rows=="object"?t.rows:{},o=hn(e);return{cols:o.map(i=>({id:i,name:ct(String(e[i].name??""),null).c,...e[i].kind!=null?{kind:String(e[i].kind)}:{},...Wn(e[i].width)?{width:Wn(e[i].width)}:{}})),rows:hn(n).map(i=>({id:i,cells:Object.fromEntries(o.map(s=>[s,ku(n[i].cells?.[s])]))}))}}function Ou(t){let e=t.columns&&typeof t.columns=="object"?t.columns:{},n=t.cards&&typeof t.cards=="object"?t.cards:{},o=hn(e),i=[...new Set(Object.values(n).map(l=>String(l.col??"")))].filter(l=>!e[l]).sort(),s=[...o,...i],r=l=>hn(Object.fromEntries(Object.entries(n).filter(([,a])=>String(a.col??"")===l)));return{columns:o.map(l=>({id:l,name:ct(String(e[l].name??""),null).c})),cards:s.flatMap(l=>r(l).map(a=>{let h=n[a];return{id:a,col:l,title:ct(String(h.title??""),null).c,...h.owner!=null?{owner:String(h.owner)}:{},...h.due!=null?{due:String(h.due)}:{}}}))}}var Mu=t=>{let{t:e,parent:n,id:o,...i}=t;return{t:e,...i}},Cu={table:new Set(["rows"])},Kn=t=>{let e={};for(let[n,o]of Object.entries(t))!Mi.has(n)&&!Cu[t.t]?.has(n)&&!(Un(t.t)&&Object.hasOwn(ye[t.t],n))&&(e[n]=o);return Object.keys(e).length?wa(e):""},Nu=(t,e)=>{let n={};for(let[o,i]of Object.entries(e))!Mi.has(o)&&o!=="pos"&&!Object.hasOwn(ye[t],o)&&(n[o]=i);return n};function Ma({id:t,b:e,t:n,parent:o,indent:i}){if(!n)return{id:t,t:"preserved",html:""};if(!Un(n)){let{t:S,id:$,pos:Y,parent:M,...D}=e;if(typeof D.c=="string"&&D.m!==void 0){let z=Jn(D.m,D.c.length);z&&z.some(Boolean)?D.m=va(z):delete D.m}return{id:t,t:n,...o?{parent:o}:{},...D}}let{t:s,id:r,pos:l,c:a,m:h,rows:c,cols:d,columns:p,cards:f,parent:u,indent:m,...g}=e,v=Nu(n,g);for(let S of Object.keys(v))delete g[S];let y={...g,parent:o};n==="list_item"&&(y.indent=i),n==="heading"&&Object.assign(y,{level:Du(g.level??2),pageCoverSrc:ci(y.pageCoverSrc??null),pageCoverX:qn(y.pageCoverX),pageCoverY:qn(y.pageCoverY)}),n==="toggle"&&(y.level=Ca(g.level)),n==="image"&&y.width!=null&&(y.width=Na(String(y.width))),n==="image"&&(y.align=Aa(y.align)),n==="image"&&typeof y.caption=="string"&&(y.caption=ct(y.caption,null).c),n==="chart"&&typeof y.title=="string"&&(y.title=ct(y.title,null).c),n==="table"?Object.assign(y,Su(e)):n==="board"&&Object.assign(y,Ou(e));let w={id:t,t:n,...P(n,y),...v};if(n==="table"&&(w.cols=y.cols,w.rows=y.rows),n==="board"&&(w.columns=y.columns,w.cards=y.cards),da.has(n)){let S=typeof a=="string"?a:"",$=Jn(h,S.length),Y=$&&$.map((M,D)=>xa(M,S,D));if(n==="code_block")Object.assign(w,{c:S.replace(/\r\n?/g,`
|
|
18
|
-
`)});else{let M=ct(S,Y);Object.assign(w,an(M.c,M.units))}}return w}function Au(t,e,n){let{t:o}=e,i=new SyntaxError(`page: an envelope names the known block type ${o}`);if(da.has(o)?e.c!=null&&typeof e.c!="string":e.c!=null||e.m!=null)throw i;let s;try{s=Ma({id:t,b:e,t:o,parent:n,indent:0})}catch{throw i}let r=ye[o];return Object.fromEntries(Object.entries(s).filter(([l])=>l==="id"||l==="t"||Mi.has(l)||l==="rows"||Object.hasOwn(r,l)))}var Du=t=>Math.min(6,Math.max(1,Number.isInteger(t)?t:2)),Ca=t=>t===1||t===2||t===3?t:null,Na=t=>/^\d+$/.test(t)?Number(t):t,Aa=t=>t==="left"||t==="right"?t:null;function pm(t){return xu(t).map(Ma)}var yt=t=>Array.isArray(t)?`[${t.map(yt).join(",")}]`:t&&typeof t=="object"?`{${Object.keys(t).sort().map(e=>JSON.stringify(e)+":"+yt(t[e])).join(",")}}`:JSON.stringify(t??null);function Da(t){let e=2166136261,n=-1623754710;for(let o=0;o<t.length;o++){let i=t.charCodeAt(o);e=Math.imul(e^i,16777619)>>>0,n=Math.imul(n^i,1540483477)>>>0,n=(n^n>>>15)>>>0}return e.toString(16).padStart(8,"0")+n.toString(16).padStart(8,"0")}var um=t=>Da(yt(t)),lt=t=>t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/\r/g," "),we=t=>lt(String(t)).replace(/"/g,"""),C=(t,e)=>e==null?"":` ${t}="${we(e)}"`,Eu={underline:"u",text_color:"span",highlight:"mark"};function Ci(t,e,n=!0){let o=Jn(e,t.length)||[],i="",s=[],r=l=>{for(;s.length>l;)i+=`</${s.pop().tag}>`};for(let l=0;l<t.length;){let a=o[l]||"";if(t[l]===cn&&a[0]==="@"){r(0),i+=a===Si?"<br>":`<span data-atom="${we(a)}"></span>`,l++;continue}let h=l+1;for(;h<t.length&&(o[h]||"")===a&&!(t[h]===cn&&a[0]==="@");)h++;let{marks:c,native:d,entries:p}=ba(a),f=lu.filter(y=>c[y]).map(y=>({code:y,sig:y+JSON.stringify(c[y]),tag:y==="a"?"a":ru[y],href:y==="a"?c.a[0]:null}));for(let y of d)f.push({sig:`native${y.name}${yt(y.attrs)}`,tag:Eu[y.name],color:y.attrs.color??null});let u=p.find(y=>y.name==="mention"),m=p.find(y=>y.name==="date"),g=m&&du.test(String(m.attrs.date))?String(m.attrs.date):null;p.length&&n&&f.push({sig:`marks${yt(p)}`,tag:g?"time":"span",entries:p,mention:u?.attrs.id,day:g});let v=0;for(;v<s.length&&v<f.length&&s[v].sig===f[v].sig;)v++;r(v);for(let y of f.slice(v))y.entries?i+=y.day?`<time${C("datetime",y.day)}${C(hu,"")}${sa(y.entries)}>`:`<span${sa(y.entries)}${C(cu,y.mention)}>`:y.tag==="a"?i+=`<a${C("href",y.href)}>`:i+=y.color?`<${y.tag}${C("data-color",y.color)}>`:`<${y.tag}>`,s.push(y);i+=lt(t.slice(l,h)),l=h}return r(0),i}var Vt=t=>Ci(t.c??"",t.m),Tu=t=>`<header${C("data-id",t.id)} data-page-heading="1"${Kn(t)}>${t.pageCoverSrc?`<img data-page-cover${C("src",t.pageCoverSrc)}${C("alt",t.pageCoverAlt??"")} style="object-position:${t.pageCoverX??50}% ${t.pageCoverY??50}%">`:""}${t.pageIcon?`<span data-page-icon aria-hidden="true">${lt(t.pageIcon)}</span>`:""}<h1>${Vt(t)}</h1></header>`,Ea=t=>t.artifact||t.rev||t.state&&Object.keys(t.state).length?`<script type="application/json" data-tool>${yt({artifact:t.artifact??null,rev:t.rev??null,state:t.state??{}}).replace(/</g,"\\u003c")}<\/script>`:"",ra=(t,e)=>`${t}-${e}`,$u=t=>typeof t=="string"?lt(t):t&&typeof t=="object"?Ci(String(t.c??""),t.m):"",Iu=t=>Object.entries(t).map(([e,n])=>C(`data-${e}`,n)).join("");function Ru(t,e,n){let o=C("data-id",t.id);if(!Un(t.t))return`<div${o}${wa(Mu(t))}>${Ci(t.c??"",t.m,!1)}</div>`;let i=o+Kn(t);switch(t.t){case"paragraph":return`<p${i}>${Vt(t)}</p>`;case"heading":{let s=`h${t.level??2}`;return`<${s}${i}>${Vt(t)}</${s}>`}case"callout":return`<aside${i} class="page-callout">${Vt(t)}</aside>`;case"quote":return`<blockquote${i}>${Vt(t)}</blockquote>`;case"code_block":return`<pre${i}${C("data-lang",t.lang||null)}><code>${lt(t.c??"")}</code></pre>`;case"divider":return`<hr${i}>`;case"image":return`<figure${i} data-type="image"${C("data-align",t.align??null)}><img${C("src",t.src??"")}${C("alt",t.alt??"")}${C("width",t.width??null)}>${t.caption?`<figcaption>${lt(t.caption)}</figcaption>`:""}</figure>`;case"file":{let s=/^(https?:\/\/|\/(?!\/))/i.test(t.src??"")?t.src:null;return`<div${i} data-type="file"${C("data-src",t.src??"")}${C("data-name",t.name??"")}${C("data-size",t.size??null)}${C("data-mime",t.mime??null)}><a${C("href",s)} rel="noopener noreferrer">${lt(t.name||"file")}</a></div>`}case"table":{let s=t.cols.map(l=>{let a=t.sort?.col===l.id?t.sort.dir==="desc"?"descending":"ascending":null;return`<th${C("data-col",l.id)}${C("id",ra(t.id,l.id))}${C("data-kind",l.kind??null)}${C("data-width",l.width??null)}${C("style",l.width?`width:${l.width}px`:null)} scope="col"${C("aria-sort",a)}>${lt(l.name)}</th>`}).join(""),r=t.rows.map(l=>`<tr${C("data-id",l.id)}>${t.cols.map(a=>`<td${C("headers",ra(t.id,a.id))}>${$u(l.cells[a.id])}</td>`).join("")}</tr>`).join(`
|
|
19
|
-
`);return`<table${i} aria-label="Table"${C("data-sort",t.sort!=null?JSON.stringify(t.sort):null)}>
|
|
20
|
-
<thead><tr>${s}</tr></thead>
|
|
21
|
-
<tbody>
|
|
22
|
-
${r}
|
|
23
|
-
</tbody>
|
|
24
|
-
</table>`}case"chart":{let s=Iu({source:t.source??null,kind:t.kind??null,x:t.x??null,series:t.series?JSON.stringify(t.series):null,highlight:t.highlight??null}),r=na({id:t.id,type:t.kind??"line",x:t.x,series:t.series??[],title:t.title??"",highlight:t.highlight},n.get(t.source));return`<figure${i} data-type="chart"${s}>${ia(r,{width:640,height:320})}<figcaption>${lt(t.title??"")}</figcaption></figure>`}case"board":{let r=[...t.columns.map(l=>({...l,known:!0})),...[...new Set(t.cards.map(l=>l.col))].filter(l=>!t.columns.some(a=>a.id===l)).map(l=>({id:l,known:!1}))].map(l=>{let a=t.cards.filter(h=>h.col===l.id).map(h=>`<li${C("data-id",h.id)}${C("data-owner",h.owner??null)}${C("data-due",h.due??null)}>${lt(h.title)}</li>`).join("");return`<div${C("data-col",l.id)}${l.known?"":" data-missing"}>${l.known?`<h4>${lt(l.name)}</h4>`:""}<ul>${a}</ul></div>`});return`<section${i} data-type="board">
|
|
25
|
-
${r.join(`
|
|
26
|
-
`)}
|
|
27
|
-
</section>`}case"tool":return`<section${i} data-type="tool">${Ea(t)}</section>`;case"preserved":return Pu(t,e,i);default:return""}}var Pu=(t,e,n=C("data-id",t.id))=>`<div${n} data-type="preserved">${e.preserved(t.html||"")}</div>`,Bu={preserved:t=>t,fallback:t=>t};function fm(t){let e=(n,o)=>{if(!n)return"";let i=t.createElement("template");if(i.innerHTML=n,o){for(let s of i.content.querySelectorAll("script"))s.remove();for(let s of i.content.querySelectorAll("*"))for(let{name:r,value:l}of[...s.attributes])(/^on/i.test(r)||/^(href|src|action|formaction|xlink:href)$/i.test(r)&&ka.test(l.replace(/[\u0000-\u0020]/g,"")))&&s.removeAttribute(r)}return i.innerHTML};return{preserved:n=>e(n,!1),fallback:n=>e(n,!0)}}function mm(t,{fallbackOf:e=()=>"",clean:n=Bu}={}){let o=[],i=new Map(t.filter(c=>c.t==="table").map(c=>[c.id,c])),s=t.find(fa)??null,r=[null],l=[],a=c=>{l.length?o[o.length-1]+=c:o.push(c)},h=()=>{for(;l.length;){let c=l[l.length-1];o[o.length-1]+=`</li></${c}>`,l.pop()}};for(let c of t){let d=c.parent??null;for(;r.length>1&&r[r.length-1]!==d;)h(),a("</details>"),r.pop();if(c.t!=="list_item"&&h(),c.t==="list_item"){let p=c.indent??0,f=c.kind==="ordered"?"ol":"ul";for(;l.length>p+1;)a(`</li></${l[l.length-1]}>`),l.pop();l.length===p+1&&(a(l[p]===f?"</li>":`</li></${l[p]}>`),l[p]!==f&&l.pop()),l.length<p+1&&(a(`<${f}>`),l.push(f));let u=c.kind==="check"?`<input type="checkbox" disabled${c.checked?" checked":""}>`:"";a(`<li${C("data-id",c.id)}${C("data-owner",c.owner??null)}${C("data-due",c.due??null)}${Kn(c)}>${u}${Vt(c)}`);continue}if(c.t==="toggle"){let p=Ca(c.level);a(`<details${C("data-id",c.id)}${Kn(c)}${c.open?" open":""}>${p?`<summary><h${p}>${Vt(c)}</h${p}></summary>`:`<summary>${Vt(c)}</summary>`}`),r.push(c.id);continue}if(c.t==="tool"){a(`<section${C("data-id",c.id)} data-type="tool">${Ea(c)}${n.fallback(e(c.id))}</section>`);continue}if(c.t==="toc"){a(wu(c,t));continue}if(c===s&&(c.pageIcon||c.pageCoverSrc)){a(Tu(c));continue}a(Ru(c,n,i))}for(h();r.length>1;)a("</details>"),r.pop();return o.join(`
|
|
28
|
-
`)}var Ta=new Set(["SCRIPT","STYLE","TEMPLATE","NOSCRIPT"]),la=new Set(["A","ABBR","B","BDI","BDO","BR","CITE","CODE","DATA","DEL","DFN","EM","FONT","I","INS","KBD","LABEL","MARK","Q","S","SAMP","SMALL","SPAN","STRIKE","STRONG","SUB","SUP","TIME","U","VAR","WBR"]);function zu(t,e){return t==="u"?{name:"underline",attrs:{}}:t!=="mark"&&t!=="span"||t==="span"&&!e.hasAttribute("data-color")?null:{name:t==="mark"?"highlight":"text_color",attrs:{color:e.getAttribute("data-color")}}}function xi(t,e=()=>!1){let n="",o=[],i=(s,r,l)=>{for(let a of s.childNodes){if(e(a))continue;if(a.nodeType===3){n+=a.data;let p=Oa(Sa({...r}),l);for(let f=0;f<a.data.length;f++)o.push(p);continue}if(a.nodeType!==1||Ta.has(a.tagName))continue;let h=a.tagName.toLowerCase();if(h==="br"){n+=cn,o.push(Si);continue}if(h==="span"&&a.hasAttribute("data-atom")){n+=cn,o.push(a.getAttribute("data-atom"));continue}let c={...r};if((h==="span"||h==="time")&&a.hasAttribute(Ln)){i(a,c,Ft([...l,...ya(a.getAttribute(Ln))]));continue}h==="strong"||h==="b"?c.b=!0:h==="em"||h==="i"?c.i=!0:h==="s"||h==="del"||h==="strike"?c.s=!0:h==="code"?c.c=!0:h==="a"&&a.hasAttribute("href")&&(c.a=[a.getAttribute("href")]);let d=zu(h,a);i(a,c,d?[...l,d]:l)}};return i(t,{},[]),ct(n,o)}var rn=t=>ct(t?t.textContent:"",null).c,Ni=t=>{if(!t.hasAttribute(ln))return null;if(t.getAttribute(ln)!==Hn)throw new SyntaxError(`page: unknown envelope version ${t.getAttribute(ln)}`);let e=t.getAttribute(Oi);if(e===null)throw new SyntaxError("page: a block envelope holds no value");return bu(e)},gm=t=>Ni(t),aa=t=>{let e=Ni(t);return e&&typeof e.t!="string"?e:null};function Fu(t){let e=[],n=(c,d)=>{let p=null,f=()=>{if(!p)return;let u=xi(p);u.c&&e.push({id:null,t:"paragraph",parent:d,...an(u.c,u.units)}),p=null};for(let u of[...c.childNodes]){if(u.nodeType===3&&!u.data.trim()){p&&p.appendChild(u.cloneNode());continue}if(!(u.nodeType===8||u.nodeType===1&&Ta.has(u.tagName))){if(u.nodeType===3||u.nodeType===1&&la.has(u.tagName)){p??=c.ownerDocument.createElement("p"),p.appendChild(u.cloneNode(!0));continue}f(),u.nodeType===1&&r(u,d)}}f()},o=c=>c.getAttribute("data-id")||null,i=(c,d,p,f)=>{let u=aa(c);e.push({id:o(c),t:d,parent:p,...u?{...u,...f}:f})},s=(c,d,p)=>{for(let f of c.children){if(f.tagName!=="LI")continue;let u=[...f.childNodes].find(w=>w.nodeType===1&&w.tagName==="INPUT"&&(w.getAttribute("type")||"").toLowerCase()==="checkbox"),m=[...f.children].filter(w=>w.tagName==="UL"||w.tagName==="OL"),g=xi(f,w=>w===u||m.includes(w)),v=u?"check":c.tagName==="OL"?"ordered":"bullet",y={parent:d,kind:v,indent:p,checked:!!(u&&u.hasAttribute("checked")),owner:f.getAttribute("data-owner"),due:f.getAttribute("data-due")};e.push({id:o(f),t:"list_item",...P("list_item",y),...aa(f)??{},...an(g.c,g.units)});for(let w of m)s(w,d,p+1)}},r=(c,d)=>{let p=c.tagName,f={parent:d},u=Ni(c);if(u&&typeof u.t=="string"){if(u.t==="opaque_block")throw new SyntaxError(`page: an envelope names the known block type ${u.t}`);if(Un(u.t)){e.push(Au(o(c),u,d));return}let{t:y,...w}=u;e.push({id:o(c),t:y,parent:d,...w});return}let m=p==="P"&&c.children.length===1&&c.children[0].tagName==="IMG"&&!c.textContent.trim();if(p==="P"&&!m)return i(c,"paragraph",d,{...P("paragraph",f),...l(c)});if(/^H[1-6]$/.test(p))return i(c,"heading",d,{...P("heading",{...f,level:+p[1]}),...l(c)});if(p==="HEADER"&&c.getAttribute("data-page-heading")===Hn){let y=c.querySelector(":scope > [data-page-icon]"),w=c.querySelector(":scope > img"),[,S,$]=/object-position:\s*([-\d.]+)%\s+([-\d.]+)%/.exec(w?.getAttribute("style")??"")??[],Y=w?{pageCoverSrc:ci(w.getAttribute("src")),pageCoverAlt:w.getAttribute("alt")??"",pageCoverX:qn(S),pageCoverY:qn($)}:{};return i(c,"heading",d,{...P("heading",{...f,level:1,pageIcon:y?y.textContent:null,...Y}),...l(c.querySelector(":scope > h1"))})}if(p==="ASIDE")return i(c,"callout",d,{...P("callout",f),...l(c)});if(p==="BLOCKQUOTE")return i(c,"quote",d,{...P("quote",f),...l(c)});if(p==="PRE"){let y=c.querySelector(":scope > code");return i(c,"code_block",d,{...P("code_block",{...f,lang:c.getAttribute("data-lang")||""}),c:(y||c).textContent})}if(p==="HR")return i(c,"divider",d,P("divider",f));if(p==="NAV"&&c.getAttribute("aria-label")===pa){let y=+(c.getAttribute("data-max-level")??0);return i(c,"toc",d,P("toc",{...f,maxLevel:y>=1&&y<=6?y:null}))}if(p==="UL"||p==="OL")return s(c,d,0);if(p==="DETAILS"){let y=c.querySelector(":scope > summary"),w=y?.querySelector(":scope > h1, :scope > h2, :scope > h3"),S=e.length;i(c,"toggle",d,{...P("toggle",{...f,open:c.hasAttribute("open"),level:w?Number(w.tagName[1]):null}),...l(y)});let $=c.ownerDocument.createElement("div");for(let Y of[...c.childNodes])Y!==y&&$.appendChild(Y.cloneNode(!0));n($,{ref:S});return}if(p==="FIGURE"&&c.getAttribute("data-type")==="chart"){let y=S=>c.getAttribute(`data-${S}`),w=[];try{w=JSON.parse(y("series")||"[]")}catch{}return i(c,"chart",d,P("chart",{...f,source:y("source"),kind:y("kind")||"line",x:y("x"),series:w,title:rn(c.querySelector(":scope > figcaption")),highlight:y("highlight")}))}if(p==="DIV"&&c.getAttribute("data-type")==="file"){let y=c.getAttribute("data-size");return i(c,"file",d,P("file",{...f,src:c.getAttribute("data-src")||"",name:c.getAttribute("data-name")||"",size:y===null||y===""||!Number.isFinite(+y)?null:+y,mime:c.getAttribute("data-mime")||null}))}let g=p==="IMG"?c:p==="FIGURE"||m?c.querySelector(":scope > img"):null;if(g){let y=g.getAttribute("width");return i(c,"image",d,P("image",{...f,src:g.getAttribute("src")||"",alt:g.getAttribute("alt")||"",caption:p==="FIGURE"?rn(c.querySelector(":scope > figcaption")):"",width:y===null?null:Na(y),align:p==="FIGURE"?Aa(c.getAttribute("data-align")):null}))}if(p==="TABLE")return i(c,"table",d,a(c,f));if(p==="SECTION"&&c.getAttribute("data-type")==="board")return i(c,"board",d,h(c,f));if(p==="SECTION"&&c.getAttribute("data-type")==="tool"){let y=c.querySelector(':scope > script[type="application/json"][data-tool]'),w={};try{w=y?JSON.parse(y.textContent):{}}catch{}return i(c,"tool",d,P("tool",{...f,artifact:w.artifact??null,rev:w.rev??null,state:w.state??{}}))}if(p==="DIV"&&c.getAttribute("data-type")==="preserved")return i(c,"preserved",d,P("preserved",{...f,html:c.innerHTML}));if(p==="DIV"&&[...c.children].every(y=>la.has(y.tagName)))return i(c,"paragraph",d,{...P("paragraph",f),...l(c)});let v=c.cloneNode(!0);return v.removeAttribute("data-id"),i(c,"preserved",d,P("preserved",{...f,html:v.outerHTML}))},l=c=>{let d=c?xi(c):{c:"",units:[]};return an(d.c,d.units)},a=(c,d)=>{let p=c.querySelector(":scope > thead > tr")||null,u=(p?[...p.children]:[]).map(w=>({id:w.getAttribute("data-col"),name:rn(w),...w.hasAttribute("data-kind")?{kind:w.getAttribute("data-kind")}:{},...Wn(Number(w.getAttribute("data-width")))?{width:Wn(Number(w.getAttribute("data-width")))}:{}})),m=[...c.querySelectorAll(":scope > tbody > tr, :scope > tr")],g=Math.max(u.length,...m.map(w=>w.children.length),0);for(;u.length<g;)u.push({id:null,name:""});let v=m.map(w=>({id:w.getAttribute("data-id"),cellsAt:[...w.children].map(S=>{let $=l(S);return $.m?$:$.c})})),y=null;try{y=c.hasAttribute("data-sort")?JSON.parse(c.getAttribute("data-sort")):null}catch{}return{...P("table",{...d,sort:y}),cols:u,rows:v}},h=(c,d)=>{let p=[],f=[];for(let u of c.querySelectorAll(":scope > div[data-col], :scope > div")){let m=u.getAttribute("data-col"),g=u.hasAttribute("data-missing"),v=g?{id:m}:{id:m,name:rn(u.querySelector(":scope > h4"))};g||p.push(v);for(let y of u.querySelectorAll(":scope > ul > li"))f.push({id:y.getAttribute("data-id"),colRef:v,title:rn(y),...y.hasAttribute("data-owner")?{owner:y.getAttribute("data-owner")}:{},...y.hasAttribute("data-due")?{due:y.getAttribute("data-due")}:{}})}return{...P("board",d),columns:p,cards:f}};return n(t,null),e}function Vu(t,{seed:e="",known:n=new Map,taken:o=new Set}={}){let i=0,s=c=>`${c}-a${Da(`${e}|${c}|${i++}`).slice(0,12)}`,r=new Map;t.forEach((c,d)=>{c.id&&(r.get(c.id)??r.set(c.id,[]).get(c.id)).push(d)});let l=new Map;for(let[c,d]of r){let p=n.get(c),f=p?d.find(u=>ma(ca(t[u]),ca(p))):void 0;l.set(c,f??d[0])}let a=t.map((c,d)=>c.id&&!/^~|~\d+$/.test(c.id)&&l.get(c.id)===d?c.id:s("b"));return t.map((c,d)=>{let{id:p,parent:f,...u}=c,m=f&&typeof f=="object"?a[f.ref]:f,g={id:a[d],t:u.t,...m?{parent:m}:{},...$a(u,["t"])};if(g.t==="table"){let v=new Set,y=new Set;g.cols=g.cols.map(w=>({...w,id:w.id&&!v.has(w.id)?(v.add(w.id),w.id):s("c")})),g.rows=g.rows.map(w=>({id:w.id&&!y.has(w.id)?(y.add(w.id),w.id):s("r"),cells:Object.fromEntries(g.cols.map((S,$)=>[S.id,w.cellsAt[$]??""]))}))}if(g.t==="board"){let v=new Set,y=new Set;for(let w of g.columns)(!w.id||y.has(w.id))&&(w.id=s("c")),y.add(w.id);g.cards=g.cards.map(({colRef:w,...S})=>({id:S.id&&!v.has(S.id)?(v.add(S.id),S.id):s("k"),col:w.id??"",title:S.title,...S.owner!=null?{owner:S.owner}:{},...S.due!=null?{due:S.due}:{}})),g.columns=g.columns.map(({id:w,name:S})=>({id:w,name:S}))}return g})}var $a=(t,e)=>Object.fromEntries(Object.entries(t).filter(([n])=>!e.includes(n))),ca=t=>$a(t,["id","parent"]);function ym(t,e={}){return Vu(Fu(t),e)}export{gt as a,zo as b,pe as c,Tc as d,wd as e,Id as f,Jd as g,rp as h,vp as i,Fn as j,ci as k,hi as l,di as m,Ll as n,en as o,Wl as p,Kl as q,Pf as r,Bf as s,Df as t,Dp as u,Xe as v,Ef as w,Fp as x,Vp as y,fi as z,_l as A,mi as B,gi as C,Ot as D,Jp as E,sn as F,Ql as G,ge as H,wi as I,Wp as J,Yp as K,_p as L,Qp as M,Kf as N,Zp as O,Hf as P,Zl as Q,tu as R,Uf as S,vi as T,_f as U,bi as V,nu as W,Qf as X,Zf as Y,na as Z,ia as _,cn as $,Si as aa,ln as ba,Ln as ca,ye as da,wu as ea,hn as fa,am as ga,cm as ha,hm as ia,Jn as ja,va as ka,dm as la,Ca as ma,pm as na,yt as oa,Da as pa,um as qa,fm as ra,mm as sa,gm as ta,ym as ua};
|