@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
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
var Er=Object.defineProperty,ot=(e,t)=>{for(var n in t)Er(e,n,{get:t[n],enumerable:!0})},Ar={};ot(Ar,{ContentMatch:()=>Ht,DOMParser:()=>Un,DOMSerializer:()=>Me,Fragment:()=>y,Mark:()=>M,MarkType:()=>Hn,Node:()=>wt,NodeRange:()=>Ro,NodeType:()=>On,ReplaceError:()=>Kt,ResolvedPos:()=>xn,Schema:()=>Yr,Slice:()=>w});function z(e){this.content=e}z.prototype={constructor:z,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return t==-1?void 0:this.content[t+1]},update:function(e,t,n){var i=n&&n!=e?this.remove(n):this,o=i.find(e),s=i.content.slice();return o==-1?s.push(n||e,t):(s[o+1]=t,n&&(s[o]=n)),new z(s)},remove:function(e){var t=this.find(e);if(t==-1)return this;var n=this.content.slice();return n.splice(t,2),new z(n)},addToStart:function(e,t){return new z([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new z(n)},addBefore:function(e,t,n){var i=this.remove(t),o=i.content.slice(),s=i.find(e);return o.splice(s==-1?o.length:s,0,t,n),new z(o)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return e=z.from(e),e.size?new z(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=z.from(e),e.size?new z(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=z.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}};z.from=function(e){if(e instanceof z)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new z(t)};var vi=z;function So(e,t,n){for(let i=0;;i++){if(i==e.childCount||i==t.childCount)return e.childCount==t.childCount?null:n;let o=e.child(i),s=t.child(i);if(o==s){n+=o.nodeSize;continue}if(!o.sameMarkup(s))return n;if(o.isText&&o.text!=s.text){let r=o.text,l=s.text,a=0;for(;r[a]==l[a];a++)n++;return a&&a<r.length&&a<l.length&&Oo(r.charCodeAt(a-1))&&Mo(r.charCodeAt(a))&&n--,n}if(o.content.size||s.content.size){let r=So(o.content,s.content,n+1);if(r!=null)return r}n+=o.nodeSize}}function Co(e,t,n,i){for(let o=e.childCount,s=t.childCount;;){if(o==0||s==0)return o==s?null:{a:n,b:i};let r=e.child(--o),l=t.child(--s),a=r.nodeSize;if(r==l){n-=a,i-=a;continue}if(!r.sameMarkup(l))return{a:n,b:i};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--,i--;return d&&p&&d<h.length&&Oo(h.charCodeAt(d-1))&&Mo(h.charCodeAt(d))&&(n++,i++),{a:n,b:i}}if(r.content.size||l.content.size){let h=Co(r.content,l.content,n-1,i-1);if(h)return h}n-=a,i-=a}}function Mo(e){return e>=56320&&e<57344}function Oo(e){return e>=55296&&e<56320}var y=class L{constructor(t,n){if(this.content=t,this.size=n||0,n==null)for(let i=0;i<t.length;i++)this.size+=t[i].nodeSize}nodesBetween(t,n,i,o=0,s){for(let r=0,l=0;l<n;r++){let a=this.content[r],h=l+a.nodeSize;if(h>t&&i(a,o+l,s||null,r)!==!1&&a.content.size){let c=l+1;a.nodesBetween(Math.max(0,t-c),Math.min(a.content.size,n-c),i,o+c)}l=h}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,n,i,o){let s="",r=!0;return this.nodesBetween(t,n,(l,a)=>{let h=l.isText?l.text.slice(Math.max(t,a)-a,n-a):l.isLeaf?o?typeof o=="function"?o(l):o:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&h||l.isTextblock)&&i&&(r?r=!1:s+=i),s+=h},0),s}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,i=t.firstChild,o=this.content.slice(),s=0;for(n.isText&&n.sameMarkup(i)&&(o[o.length-1]=n.withText(n.text+i.text),s=1);s<t.content.length;s++)o.push(t.content[s]);return new L(o,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let i=[],o=0;if(n>t)for(let s=0,r=0;r<n;s++){let l=this.content[s],a=r+l.nodeSize;a>t&&((r<t||a>n)&&(l.isText?l=l.cut(Math.max(0,t-r),Math.min(l.text.length,n-r)):l=l.cut(Math.max(0,t-r-1),Math.min(l.content.size,n-r-1))),i.push(l),o+=l.nodeSize),r=a}return new L(i,o)}cutByIndex(t,n){return t==n?L.empty:t==0&&n==this.content.length?this:new L(this.content.slice(t,n))}replaceChild(t,n){let i=this.content[t];if(i==n)return this;let o=this.content.slice(),s=this.size+n.nodeSize-i.nodeSize;return o[t]=n,new L(o,s)}addToStart(t){return new L([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new L(this.content.concat(t),this.size+t.nodeSize)}eq(t){if(this.content.length!=t.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(t.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(t){let n=this.content[t];if(!n)throw new RangeError("Index "+t+" out of range for "+this);return n}maybeChild(t){return this.content[t]||null}forEach(t){for(let n=0,i=0;n<this.content.length;n++){let o=this.content[n];t(o,i,n),i+=o.nodeSize}}findDiffStart(t,n=0){return So(this,t,n)}findDiffEnd(t,n=this.size,i=t.size){return Co(this,t,n,i)}findIndex(t){if(t==0)return Ie(0,t);if(t==this.size)return Ie(this.content.length,t);if(t>this.size||t<0)throw new RangeError(`Position ${t} outside of fragment (${this})`);for(let n=0,i=0;;n++){let o=this.child(n),s=i+o.nodeSize;if(s>=t)return s==t?Ie(n+1,s):Ie(n,i);i=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(t=>t.toJSON()):null}static fromJSON(t,n){if(!n)return L.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return L.fromArray(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return L.empty;let n,i=0;for(let o=0;o<t.length;o++){let s=t[o];i+=s.nodeSize,o&&s.isText&&t[o-1].sameMarkup(s)?(n||(n=t.slice(0,o)),n[n.length-1]=s.withText(n[n.length-1].text+s.text)):n&&n.push(s)}return new L(n||t,i)}static from(t){if(!t)return L.empty;if(t instanceof L)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new L([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}};y.empty=new y([],0);var rn={index:0,offset:0};function Ie(e,t){return rn.index=e,rn.offset=t,rn}function Ke(e,t){if(e===t)return!0;if(!(e&&typeof e=="object")||!(t&&typeof t=="object"))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let i=0;i<e.length;i++)if(!Ke(e[i],t[i]))return!1}else{for(let i in e)if(!(i in t)||!Ke(e[i],t[i]))return!1;for(let i in t)if(!(i in e))return!1}return!0}var M=class bn{constructor(t,n){this.type=t,this.attrs=n}addToSet(t){let n,i=!1;for(let o=0;o<t.length;o++){let s=t[o];if(this.eq(s))return t;if(this.type.excludes(s.type))n||(n=t.slice(0,o));else{if(s.type.excludes(this.type))return t;!i&&s.type.rank>this.type.rank&&(n||(n=t.slice(0,o)),n.push(this),i=!0),n&&n.push(s)}}return n||(n=t.slice()),i||n.push(this),n}removeFromSet(t){for(let n=0;n<t.length;n++)if(this.eq(t[n]))return t.slice(0,n).concat(t.slice(n+1));return t}isInSet(t){for(let n=0;n<t.length;n++)if(this.eq(t[n]))return!0;return!1}eq(t){return this==t||this.type==t.type&&Ke(this.attrs,t.attrs)}toJSON(){let t={type:this.type.name};for(let n in this.attrs){t.attrs=this.attrs;break}return t}static fromJSON(t,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let i=t.marks[n.type];if(!i)throw new RangeError(`There is no mark type ${n.type} in this schema`);return i.create(n.attrs)}static sameSet(t,n){if(t==n)return!0;if(t.length!=n.length)return!1;for(let i=0;i<t.length;i++)if(!t[i].eq(n[i]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return bn.none;if(t instanceof bn)return[t];let n=t.slice();return n.sort((i,o)=>i.type.rank-o.type.rank),n}};M.none=[];var Kt=class extends Error{},w=class Vt{constructor(t,n,i){this.content=t,this.openStart=n,this.openEnd=i}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let i=Do(this.content,t+this.openStart,n,this.openStart+1,this.openEnd+1);return i&&new Vt(i,this.openStart,this.openEnd)}removeBetween(t,n){return new Vt(No(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let t={content:this.content.toJSON()};return this.openStart>0&&(t.openStart=this.openStart),this.openEnd>0&&(t.openEnd=this.openEnd),t}static fromJSON(t,n){if(!n)return Vt.empty;let i=n.openStart||0,o=n.openEnd||0;if(typeof i!="number"||typeof o!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new Vt(y.fromJSON(t,n.content),i,o)}static maxOpen(t,n=!0){let i=0,o=0;for(let s=t.firstChild;s&&!s.isLeaf&&(n||!s.type.spec.isolating);s=s.firstChild)i++;for(let s=t.lastChild;s&&!s.isLeaf&&(n||!s.type.spec.isolating);s=s.lastChild)o++;return new Vt(t,i,o)}};w.empty=new w(y.empty,0,0);function No(e,t,n){let{index:i,offset:o}=e.findIndex(t),s=e.maybeChild(i),{index:r,offset:l}=e.findIndex(n);if(o==t||s.isText){if(l!=n&&!e.child(r).isText)throw new RangeError("Removing non-flat range");return e.cut(0,t).append(e.cut(n))}if(i!=r)throw new RangeError("Removing non-flat range");return e.replaceChild(i,s.copy(No(s.content,t-o-1,n-o-1)))}function Do(e,t,n,i,o,s){let{index:r,offset:l}=e.findIndex(t),a=e.maybeChild(r);if(l==t||a.isText)return s&&i<=0&&o<=0&&!s.canReplace(r,r,n)?null:e.cut(0,t).append(n).append(e.cut(t));let h=Do(a.content,t-l-1,n,r==0?i-1:0,r==e.childCount-1?o-1:0,a);return h&&e.replaceChild(r,a.copy(h))}function Rr(e,t,n){if(n.openStart>e.depth)throw new Kt("Inserted content deeper than insertion position");if(e.depth-n.openStart!=t.depth-n.openEnd)throw new Kt("Inconsistent open depths");return To(e,t,n,0)}function To(e,t,n,i){let o=e.index(i),s=e.node(i);if(o==t.index(i)&&i<e.depth-n.openStart){let r=To(e,t,n,i+1);return s.copy(s.content.replaceChild(o,r))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&e.depth==i&&t.depth==i){let r=e.parent,l=r.content;return Tt(r,l.cut(0,e.parentOffset).append(n.content).append(l.cut(t.parentOffset)))}else{let{start:r,end:l}=Ir(n,e);return Tt(s,Ao(e,r,l,t,i))}else return Tt(s,He(e,t,i))}function Eo(e,t){if(!t.type.compatibleContent(e.type))throw new Kt("Cannot join "+t.type.name+" onto "+e.type.name)}function kn(e,t,n){let i=e.node(n);return Eo(i,t.node(n)),i}function Dt(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function de(e,t,n,i){let o=(t||e).node(n),s=0,r=t?t.index(n):o.childCount;e&&(s=e.index(n),e.depth>n?s++:e.textOffset&&(Dt(e.nodeAfter,i),s++));for(let l=s;l<r;l++)Dt(o.child(l),i);t&&t.depth==n&&t.textOffset&&Dt(t.nodeBefore,i)}function Tt(e,t){if(!e.type.validContent(t))throw new Kt("Invalid content for node "+e.type.name);return e.copy(t)}function Ao(e,t,n,i,o){let s=e.depth>o&&kn(e,t,o+1),r=i.depth>o&&kn(n,i,o+1),l=[];return de(null,e,o,l),s&&r&&t.index(o)==n.index(o)?(Eo(s,r),Dt(Tt(s,Ao(e,t,n,i,o+1)),l)):(s&&Dt(Tt(s,He(e,t,o+1)),l),de(t,n,o,l),r&&Dt(Tt(r,He(n,i,o+1)),l)),de(i,null,o,l),new y(l)}function He(e,t,n){let i=[];if(de(null,e,n,i),e.depth>n){let o=kn(e,t,n+1);Dt(Tt(o,He(e,t,n+1)),i)}return de(t,null,n,i),new y(i)}function Ir(e,t){let n=t.depth-e.openStart,i=t.node(n).copy(e.content);for(let o=n-1;o>=0;o--)i=t.node(o).copy(y.from(i));return{start:i.resolveNoCache(e.openStart+n),end:i.resolveNoCache(i.content.size-e.openEnd-n)}}var xn=class Sn{constructor(t,n,i){this.pos=t,this.path=n,this.parentOffset=i,this.depth=n.length/3-1}resolveDepth(t){return t==null?this.depth:t<0?this.depth+t:t}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(t){return this.path[this.resolveDepth(t)*3]}index(t){return this.path[this.resolveDepth(t)*3+1]}indexAfter(t){return t=this.resolveDepth(t),this.index(t)+(t==this.depth&&!this.textOffset?0:1)}start(t){return t=this.resolveDepth(t),t==0?0:this.path[t*3-1]+1}end(t){return t=this.resolveDepth(t),this.start(t)+this.node(t).content.size}before(t){if(t=this.resolveDepth(t),!t)throw new RangeError("There is no position before the top-level node");return t==this.depth+1?this.pos:this.path[t*3-1]}after(t){if(t=this.resolveDepth(t),!t)throw new RangeError("There is no position after the top-level node");return t==this.depth+1?this.pos:this.path[t*3-1]+this.path[t*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let t=this.parent,n=this.index(this.depth);if(n==t.childCount)return null;let i=this.pos-this.path[this.path.length-1],o=t.child(n);return i?t.child(n).cut(i):o}get nodeBefore(){let t=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(t).cut(0,n):t==0?null:this.parent.child(t-1)}posAtIndex(t,n){n=this.resolveDepth(n);let i=this.path[n*3],o=n==0?0:this.path[n*3-1]+1;for(let s=0;s<t;s++)o+=i.child(s).nodeSize;return o}marks(){let t=this.parent,n=this.index();if(t.content.size==0)return M.none;if(this.textOffset)return t.child(n).marks;let i=t.maybeChild(n-1),o=t.maybeChild(n);if(!i){let l=i;i=o,o=l}let s=i.marks;for(var r=0;r<s.length;r++)s[r].type.spec.inclusive===!1&&(!o||!s[r].isInSet(o.marks))&&(s=s[r--].removeFromSet(s));return s}marksAcross(t){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let i=n.marks,o=t.parent.maybeChild(t.index());for(var s=0;s<i.length;s++)i[s].type.spec.inclusive===!1&&(!o||!i[s].isInSet(o.marks))&&(i=i[s--].removeFromSet(i));return i}sharedDepth(t){for(let n=this.depth;n>0;n--)if(this.start(n)<=t&&this.end(n)>=t)return n;return 0}blockRange(t=this,n){if(t.pos<this.pos)return t.blockRange(this);for(let i=this.depth-(this.parent.inlineContent||this.pos==t.pos?1:0);i>=0;i--)if(t.pos<=this.end(i)&&(!n||n(this.node(i))))return new Ro(this,t,i);return null}sameParent(t){return this.pos-this.parentOffset==t.pos-t.parentOffset}max(t){return t.pos>this.pos?t:this}min(t){return t.pos<this.pos?t:this}toString(){let t="";for(let n=1;n<=this.depth;n++)t+=(t?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return t+":"+this.parentOffset}static resolve(t,n){if(!(n>=0&&n<=t.content.size))throw new RangeError("Position "+n+" out of range");let i=[],o=0,s=n;for(let r=t;;){let{index:l,offset:a}=r.content.findIndex(s),h=s-a;if(i.push(r,l,o+a),!h||(r=r.child(l),r.isText))break;s=h-1,o+=a+1}return new Sn(n,i,s)}static resolveCached(t,n){let i=bi.get(t);if(i)for(let s=0;s<i.elts.length;s++){let r=i.elts[s];if(r.pos==n)return r}else bi.set(t,i=new Pr);let o=i.elts[i.i]=Sn.resolve(t,n);return i.i=(i.i+1)%zr,o}},Pr=class{constructor(){this.elts=[],this.i=0}},zr=12,bi=new WeakMap,Ro=class{constructor(e,t,n){this.$from=e,this.$to=t,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)}},Br=Object.create(null),wt=class Cn{constructor(t,n,i,o=M.none){this.type=t,this.attrs=n,this.marks=o,this.content=i||y.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(t){return this.content.child(t)}maybeChild(t){return this.content.maybeChild(t)}forEach(t){this.content.forEach(t)}nodesBetween(t,n,i,o=0){this.content.nodesBetween(t,n,i,o,this)}descendants(t){this.nodesBetween(0,this.content.size,t)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(t,n,i,o){return this.content.textBetween(t,n,i,o)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(t){return this==t||this.sameMarkup(t)&&this.content.eq(t.content)}sameMarkup(t){return this.hasMarkup(t.type,t.attrs,t.marks)}hasMarkup(t,n,i){return this.type==t&&Ke(this.attrs,n||t.defaultAttrs||Br)&&M.sameSet(this.marks,i||M.none)}copy(t=null){return t==this.content?this:new Cn(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new Cn(this.type,this.attrs,this.content,t)}cut(t,n=this.content.size){return t==0&&n==this.content.size?this:this.copy(this.content.cut(t,n))}slice(t,n=this.content.size,i=!1){if(t==n)return w.empty;let o=this.resolve(t),s=this.resolve(n),r=i?0:o.sharedDepth(n),l=o.start(r),a=o.node(r).content.cut(o.pos-l,s.pos-l);return new w(a,o.depth-r,s.depth-r)}replace(t,n,i){return Rr(this.resolve(t),this.resolve(n),i)}nodeAt(t){for(let n=this;;){let{index:i,offset:o}=n.content.findIndex(t);if(n=n.maybeChild(i),!n)return null;if(o==t||n.isText)return n;t-=o+1}}childAfter(t){let{index:n,offset:i}=this.content.findIndex(t);return{node:this.content.maybeChild(n),index:n,offset:i}}childBefore(t){if(t==0)return{node:null,index:0,offset:0};let{index:n,offset:i}=this.content.findIndex(t);if(i<t)return{node:this.content.child(n),index:n,offset:i};let o=this.content.child(n-1);return{node:o,index:n-1,offset:i-o.nodeSize}}resolve(t){return xn.resolveCached(this,t)}resolveNoCache(t){return xn.resolve(this,t)}rangeHasMark(t,n,i){let o=!1;return n>t&&this.nodesBetween(t,n,s=>(i.isInSet(s.marks)&&(o=!0),!o)),o}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let t=this.type.name;return this.content.size&&(t+="("+this.content.toStringInner()+")"),Io(this.marks,t)}contentMatchAt(t){let n=this.type.contentMatch.matchFragment(this.content,0,t);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(t,n,i=y.empty,o=0,s=i.childCount){let r=this.contentMatchAt(t).matchFragment(i,o,s),l=r&&r.matchFragment(this.content,n);if(!l||!l.validEnd)return!1;for(let a=o;a<s;a++)if(!this.type.allowsMarks(i.child(a).marks))return!1;return!0}canReplaceWith(t,n,i,o){if(o&&!this.type.allowsMarks(o))return!1;let s=this.contentMatchAt(t).matchType(i),r=s&&s.matchFragment(this.content,n);return r?r.validEnd:!1}canAppend(t){return t.content.size?this.canReplace(this.childCount,this.childCount,t.content):this.type.compatibleContent(t.type)}check(){this.type.checkContent(this.content),ki(this.type.attrs,this.attrs,"node",this.type.name);let t=M.none;for(let n=0;n<this.marks.length;n++){let i=this.marks[n];ki(i.type.attrs,i.attrs,"mark",i.type.name),t=i.addToSet(t)}if(!M.sameSet(t,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 t={type:this.type.name};for(let n in this.attrs){t.attrs=this.attrs;break}return this.content.size&&(t.content=this.content.toJSON()),this.marks.length&&(t.marks=this.marks.map(n=>n.toJSON())),t}static fromJSON(t,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let i;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");i=n.marks.map(t.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return t.text(n.text,i)}let o=y.fromJSON(t,n.content);return t.nodeType(n.type).create(n.attrs,o,i)}};wt.prototype.text=void 0;var $r=class Mn extends wt{constructor(t,n,i,o){if(super(t,n,null,o),!i)throw new RangeError("Empty text nodes are not allowed");this.text=i}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Io(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(t,n){return this.text.slice(t,n)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new Mn(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new Mn(this.type,this.attrs,t,this.marks)}cut(t=0,n=this.text.length){return t==0&&n==this.text.length?this:this.withText(this.text.slice(t,n))}eq(t){return this.sameMarkup(t)&&this.text==t.text}toJSON(){let t=super.toJSON();return t.text=this.text,t}};function Io(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+"("+t+")";return t}function ki(e,t,n,i){for(let o in t)if(!(o in e))throw new RangeError(`Unsupported attribute ${o} for ${n} of type ${i}`);for(let o in e)e[o].validate&&e[o].validate(t[o])}var Ht=class Po{constructor(t){this.validEnd=t,this.next=[],this.wrapCache=[]}static parse(t,n){let i=new Vr(t,n);if(i.next==null)return Po.empty;let o=zo(i);i.next&&i.err("Unexpected trailing text");let s=Kr(jr(o));return Hr(s,i),s}matchType(t){for(let n=0;n<this.next.length;n++)if(this.next[n].type==t)return this.next[n].next;return null}matchFragment(t,n=0,i=t.childCount){let o=this;for(let s=n;o&&s<i;s++)o=o.matchType(t.child(s).type);return o}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let t=0;t<this.next.length;t++){let{type:n}=this.next[t];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(t){for(let n=0;n<this.next.length;n++)for(let i=0;i<t.next.length;i++)if(this.next[n].type==t.next[i].type)return!0;return!1}fillBefore(t,n=!1,i=0){let o=[this];function s(r,l){let a=r.matchFragment(t,i);if(a&&(!n||a.validEnd))return y.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())&&o.indexOf(d)==-1){o.push(d);let p=s(d,l.concat(c));if(p)return p}}return null}return s(this,[])}findWrapping(t){for(let i=0;i<this.wrapCache.length;i+=2)if(this.wrapCache[i]==t)return this.wrapCache[i+1];let n=this.computeWrapping(t);return this.wrapCache.push(t,n),n}computeWrapping(t){let n=Object.create(null),i=[{match:this,type:null,via:null}];for(;i.length;){let o=i.shift(),s=o.match;if(s.matchType(t)){let r=[];for(let l=o;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)&&(!o.type||a.validEnd)&&(i.push({match:l.contentMatch,type:l,via:o}),n[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(t){if(t>=this.next.length)throw new RangeError(`There's no ${t}th edge in this content match`);return this.next[t]}toString(){let t=[];function n(i){t.push(i);for(let o=0;o<i.next.length;o++)t.indexOf(i.next[o].next)==-1&&n(i.next[o].next)}return n(this),t.map((i,o)=>{let s=o+(i.validEnd?"*":" ")+" ";for(let r=0;r<i.next.length;r++)s+=(r?", ":"")+i.next[r].type.name+"->"+t.indexOf(i.next[r].next);return s}).join(`
|
|
2
|
+
`)}};Ht.empty=new Ht(!0);var Vr=class{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}};function zo(e){let t=[];do t.push(Fr(e));while(e.eat("|"));return t.length==1?t[0]:{type:"choice",exprs:t}}function Fr(e){let t=[];do t.push(Lr(e));while(e.next&&e.next!=")"&&e.next!="|");return t.length==1?t[0]:{type:"seq",exprs:t}}function Lr(e){let t=qr(e);for(;;)if(e.eat("+"))t={type:"plus",expr:t};else if(e.eat("*"))t={type:"star",expr:t};else if(e.eat("?"))t={type:"opt",expr:t};else if(e.eat("{"))t=Jr(e,t);else break;return t}function xi(e){/\D/.test(e.next)&&e.err("Expected number, got '"+e.next+"'");let t=Number(e.next);return e.pos++,t}function Jr(e,t){let n=xi(e),i=n;return e.eat(",")&&(e.next!="}"?i=xi(e):i=-1),e.eat("}")||e.err("Unclosed braced range"),{type:"range",min:n,max:i,expr:t}}function Wr(e,t){let n=e.nodeTypes,i=n[t];if(i)return[i];let o=[];for(let s in n){let r=n[s];r.isInGroup(t)&&o.push(r)}return o.length==0&&e.err("No node type or group '"+t+"' found"),o}function qr(e){if(e.eat("(")){let t=zo(e);return e.eat(")")||e.err("Missing closing paren"),t}else if(/\W/.test(e.next))e.err("Unexpected token '"+e.next+"'");else{let t=Wr(e,e.next).map(n=>(e.inline==null?e.inline=n.isInline:e.inline!=n.isInline&&e.err("Mixing inline and block content"),{type:"name",value:n}));return e.pos++,t.length==1?t[0]:{type:"choice",exprs:t}}}function jr(e){let t=[[]];return o(s(e,0),n()),t;function n(){return t.push([])-1}function i(r,l,a){let h={term:a,to:l};return t[r].push(h),h}function o(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;o(h,l=n())}else if(r.type=="star"){let a=n();return i(l,a),o(s(r.expr,a),a),[i(a)]}else if(r.type=="plus"){let a=n();return o(s(r.expr,l),a),o(s(r.expr,a),a),[i(a)]}else{if(r.type=="opt")return[i(l)].concat(s(r.expr,l));if(r.type=="range"){let a=l;for(let h=0;h<r.min;h++){let c=n();o(s(r.expr,a),c),a=c}if(r.max==-1)o(s(r.expr,a),a);else for(let h=r.min;h<r.max;h++){let c=n();i(a,c),o(s(r.expr,a),c),a=c}return[i(a)]}else{if(r.type=="name")return[i(l,void 0,r.value)];throw new Error("Unknown expr type")}}}}function Bo(e,t){return t-e}function Si(e,t){let n=[];return i(t),n.sort(Bo);function i(o){let s=e[o];if(s.length==1&&!s[0].term)return i(s[0].to);n.push(o);for(let r=0;r<s.length;r++){let{term:l,to:a}=s[r];!l&&n.indexOf(a)==-1&&i(a)}}}function Kr(e){let t=Object.create(null);return n(Si(e,0));function n(i){let o=[];i.forEach(r=>{e[r].forEach(({term:l,to:a})=>{if(!l)return;let h;for(let c=0;c<o.length;c++)o[c][0]==l&&(h=o[c][1]);Si(e,a).forEach(c=>{h||o.push([l,h=[]]),h.indexOf(c)==-1&&h.push(c)})})});let s=t[i.join(",")]=new Ht(i.indexOf(e.length-1)>-1);for(let r=0;r<o.length;r++){let l=o[r][1].sort(Bo);s.next.push({type:o[r][0],next:t[l.join(",")]||n(l)})}return s}}function Hr(e,t){for(let n=0,i=[e];n<i.length;n++){let o=i[n],s=!o.validEnd,r=[];for(let l=0;l<o.next.length;l++){let{type:a,next:h}=o.next[l];r.push(a.name),s&&!(a.isText||a.hasRequiredAttrs())&&(s=!1),i.indexOf(h)==-1&&i.push(h)}s&&t.err("Only non-generatable nodes ("+r.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function $o(e){let t=Object.create(null);for(let n in e){let i=e[n];if(!i.hasDefault)return null;t[n]=i.default}return t}function Vo(e,t){let n=Object.create(null);for(let i in e){let o=e[i],s=t&&t[i];if(s===void 0)if(o.hasDefault)s=o.default;else throw new RangeError("No value supplied for attribute "+i);else o.validate&&o.validate(s);n[i]=s}return n}function Fo(e,t){let n=Object.create(null);if(t)for(let i in t)n[i]=new Gr(e,i,t[i]);return n}var On=class Lo{constructor(t,n,i){this.name=t,this.schema=n,this.spec=i,this.markSet=null,this.groups=i.group?i.group.split(" "):[],this.attrs=Fo(t,i.attrs),this.defaultAttrs=$o(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(i.inline||t=="text"),this.isText=t=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Ht.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(t){return this.groups.indexOf(t)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let t in this.attrs)if(this.attrs[t].isRequired)return!0;return!1}compatibleContent(t){return this==t||this.contentMatch.compatible(t.contentMatch)}computeAttrs(t){return!t&&this.defaultAttrs?this.defaultAttrs:Vo(this.attrs,t)}create(t=null,n,i){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new wt(this,this.computeAttrs(t),y.from(n),M.setFrom(i))}createChecked(t=null,n,i){return n=y.from(n),this.checkContent(n),new wt(this,this.computeAttrs(t),n,M.setFrom(i))}createAndFill(t=null,n,i){if(t=this.computeAttrs(t),n=y.from(n),n.size){let r=this.contentMatch.fillBefore(n);if(!r)return null;n=r.append(n)}let o=this.contentMatch.matchFragment(n),s=o&&o.fillBefore(y.empty,!0);return s?new wt(this,t,n.append(s),M.setFrom(i)):null}validContent(t){let n=this.contentMatch.matchFragment(t);if(!n||!n.validEnd)return!1;for(let i=0;i<t.childCount;i++)if(!this.allowsMarks(t.child(i).marks))return!1;return!0}checkContent(t){if(!this.validContent(t))throw new RangeError(`Invalid content for node ${this.name}: ${t.toString().slice(0,50)}`)}checkAttrs(t){}allowsMarkType(t){return this.markSet==null||this.markSet.indexOf(t)>-1}allowsMarks(t){if(this.markSet==null)return!0;for(let n=0;n<t.length;n++)if(!this.allowsMarkType(t[n].type))return!1;return!0}allowedMarks(t){if(this.markSet==null)return t;let n;for(let i=0;i<t.length;i++)this.allowsMarkType(t[i].type)?n&&n.push(t[i]):n||(n=t.slice(0,i));return n?n.length?n:M.none:t}static compile(t,n){let i=Object.create(null);t.forEach((s,r)=>i[s]=new Lo(s,n,r));let o=n.spec.topNode||"doc";if(!i[o])throw new RangeError("Schema is missing its top node type ('"+o+"')");if(!i.text)throw new RangeError("Every schema needs a 'text' type");for(let s in i.text.attrs)throw new RangeError("The text node type should not have attributes");return i}};function Ur(e,t,n){let i=n.split("|");return o=>{let s=o===null?"null":typeof o;if(i.indexOf(s)<0)throw new RangeError(`Expected value of type ${i} for attribute ${t} on type ${e}, got ${s}`)}}var Gr=class{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate=typeof n.validate=="string"?Ur(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}},Hn=class Jo{constructor(t,n,i,o){this.name=t,this.rank=n,this.schema=i,this.spec=o,this.attrs=Fo(t,o.attrs),this.excluded=null;let s=$o(this.attrs);this.instance=s?new M(this,s):null}create(t=null){return!t&&this.instance?this.instance:new M(this,Vo(this.attrs,t))}static compile(t,n){let i=Object.create(null),o=0;return t.forEach((s,r)=>i[s]=new Jo(s,o++,n,r)),i}removeFromSet(t){for(var n=0;n<t.length;n++)t[n].type==this&&(t=t.slice(0,n).concat(t.slice(n+1)),n--);return t}isInSet(t){for(let n=0;n<t.length;n++)if(t[n].type==this)return t[n]}excludes(t){return this.excluded.indexOf(t)>-1}},Yr=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let i in e)t[i]=e[i];t.nodes=vi.from(e.nodes),t.marks=vi.from(e.marks||{}),this.nodes=On.compile(this.spec.nodes,this),this.marks=Hn.compile(this.spec.marks,this);let n=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let o=this.nodes[i],s=o.spec.content||"",r=o.spec.marks;if(o.contentMatch=n[s]||(n[s]=Ht.parse(s,this.nodes)),o.inlineContent=o.contentMatch.inlineContent,o.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!o.isInline||!o.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=o}o.markSet=r=="_"?null:r?Ci(this,r.split(" ")):r==""||!o.inlineContent?[]:null}for(let i in this.marks){let o=this.marks[i],s=o.spec.excludes;o.excluded=s==null?[o]:s==""?[]:Ci(this,s.split(" "))}this.nodeFromJSON=i=>wt.fromJSON(this,i),this.markFromJSON=i=>M.fromJSON(this,i),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,n,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof On){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,n,i)}text(e,t){let n=this.nodes.text;return new $r(n,n.defaultAttrs,e,M.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}};function Ci(e,t){let n=[];for(let i=0;i<t.length;i++){let o=t[i],s=e.marks[o],r=s;if(s)n.push(s);else for(let l in e.marks){let a=e.marks[l];(o=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(o)>-1)&&n.push(r=a)}if(!r)throw new SyntaxError("Unknown mark type: '"+t[i]+"'")}return n}function Xr(e){return e.tag!=null}function Qr(e){return e.style!=null}var Un=class Nn{constructor(t,n){this.schema=t,this.rules=n,this.tags=[],this.styles=[];let i=this.matchedStyles=[];n.forEach(o=>{if(Xr(o))this.tags.push(o);else if(Qr(o)){let s=/[^=]*/.exec(o.style)[0];i.indexOf(s)<0&&i.push(s),this.styles.push(o)}}),this.normalizeLists=!this.tags.some(o=>{if(!/^(ul|ol)\b/.test(o.tag)||!o.node)return!1;let s=t.nodes[o.node];return s.contentMatch.matchType(s)})}parse(t,n={}){let i=new Oi(this,n,!1);return i.addAll(t,M.none,n.from,n.to),i.finish()}parseSlice(t,n={}){let i=new Oi(this,n,!0);return i.addAll(t,M.none,n.from,n.to),w.maxOpen(i.finish())}matchTag(t,n,i){for(let o=i?this.tags.indexOf(i)+1:0;o<this.tags.length;o++){let s=this.tags[o];if(tl(t,s.tag)&&(s.namespace===void 0||t.namespaceURI==s.namespace)&&(!s.context||n.matchesContext(s.context))){if(s.getAttrs){let r=s.getAttrs(t);if(r===!1)continue;s.attrs=r||void 0}return s}}}matchStyle(t,n,i,o){for(let s=o?this.styles.indexOf(o)+1:0;s<this.styles.length;s++){let r=this.styles[s],l=r.style;if(!(l.indexOf(t)!=0||r.context&&!i.matchesContext(r.context)||l.length>t.length&&(l.charCodeAt(t.length)!=61||l.slice(t.length+1)!=n))){if(r.getAttrs){let a=r.getAttrs(n);if(a===!1)continue;r.attrs=a||void 0}return r}}}static schemaRules(t){let n=[];function i(o){let s=o.priority==null?50:o.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,o)}for(let o in t.marks){let s=t.marks[o].spec.parseDOM;s&&s.forEach(r=>{i(r=Ni(r)),r.mark||r.ignore||r.clearMark||(r.mark=o)})}for(let o in t.nodes){let s=t.nodes[o].spec.parseDOM;s&&s.forEach(r=>{i(r=Ni(r)),r.node||r.ignore||r.mark||(r.node=o)})}return n}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new Nn(t,Nn.schemaRules(t)))}},Wo={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},Zr={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},qo={ol:!0,ul:!0},we=1,Dn=2,pe=4;function Mi(e,t,n){return t!=null?(t?we:0)|(t==="full"?Dn:0):e&&e.whitespace=="pre"?we|Dn:n&~pe}var Pe=class{constructor(e,t,n,i,o,s){this.type=e,this.attrs=t,this.marks=n,this.solid=i,this.options=s,this.content=[],this.activeMarks=M.none,this.match=o||(s&pe?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(y.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let n=this.type.contentMatch,i;return(i=n.findWrapping(e.type))?(this.match=n,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&we)){let n=this.content[this.content.length-1],i;if(n&&n.isText&&(i=/[ \t\r\n\u000c]+$/.exec(n.text))){let o=n;n.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=o.withText(o.text.slice(0,o.text.length-i[0].length))}}let t=y.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(y.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Wo.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},Oi=class{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let i=t.topNode,o,s=Mi(null,t.preserveWhitespace,0)|(n?pe:0);i?o=new Pe(i.type,i.attrs,M.none,!0,t.topMatch||i.type.contentMatch,s):n?o=new Pe(null,null,M.none,!0,null,s):o=new Pe(e.schema.topNodeType,null,M.none,!0,null,s),this.nodes=[o],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,i=this.top,o=i.options&Dn?"full":this.localPreserveWS||(i.options&we)>0,{schema:s}=this.parser;if(o==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(o)if(o==="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(),t,!0),r[l]&&this.insertNode(s.text(r[l]),t,!/\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=i.content[i.content.length-1],l=e.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),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let i=this.localPreserveWS,o=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let s=e.nodeName.toLowerCase(),r;qo.hasOwnProperty(s)&&this.parser.normalizeLists&&_r(e);let l=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(r=this.parser.matchTag(e,this,n));t:if(l?l.ignore:Zr.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,t);else if(!l||l.skip||l.closeParent){l&&l.closeParent?this.open=Math.max(0,this.open-1):l&&l.skip.nodeType&&(e=l.skip);let a,h=this.needsBlock;if(Wo.hasOwnProperty(s))o.content.length&&o.content[0].isInline&&this.open&&(this.open--,o=this.top),a=!0,o.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break t}let c=l&&l.skip?t:this.readStyles(e,t);c&&this.addAll(e,c),a&&this.sync(o),this.needsBlock=h}else{let a=this.readStyles(e,t);a&&this.addElementByRule(e,l,a,l.consuming===!1?r:void 0)}this.localPreserveWS=i}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
4
|
+
`),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let o=this.parser.matchedStyles[i],s=n.getPropertyValue(o);if(s)for(let r=void 0;;){let l=this.parser.matchStyle(o,s,this,r);if(!l)break;if(l.ignore)return null;if(l.clearMark?t=t.filter(a=>!l.clearMark(a)):t=t.concat(this.parser.schema.marks[l.mark].create(l.attrs)),l.consuming===!1)r=l;else break}}return t}addElementByRule(e,t,n,i){let o,s;if(t.node)if(s=this.parser.schema.nodes[t.node],s.isLeaf)this.insertNode(s.create(t.attrs),n,e.nodeName=="BR")||this.leafFallback(e,n);else{let l=this.enter(s,t.attrs||null,n,t.preserveWhitespace);l&&(o=!0,n=l)}else{let l=this.parser.schema.marks[t.mark];n=n.concat(l.create(t.attrs))}let r=this.top;if(s&&s.isLeaf)this.findInside(e);else if(i)this.addElement(e,n,i);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(l=>this.insertNode(l,n,!1));else{let l=e;typeof t.contentElement=="string"?l=e.querySelector(t.contentElement):typeof t.contentElement=="function"?l=t.contentElement(e):t.contentElement&&(l=t.contentElement),this.findAround(e,l,!0),this.addAll(l,n),this.findAround(e,l,!1)}o&&this.sync(r)&&this.open--}addAll(e,t,n,i){let o=n||0;for(let s=n?e.childNodes[n]:e.firstChild,r=i==null?null:e.childNodes[i];s!=r;s=s.nextSibling,++o)this.findAtPoint(e,o),this.addDOM(s,t);this.findAtPoint(e,o)}findPlace(e,t,n){let i,o;for(let s=this.open,r=0;s>=0;s--){let l=this.nodes[s],a=l.findWrapping(e);if(a&&(!i||i.length>a.length+r)&&(i=a,o=l,!a.length))break;if(l.solid){if(n)break;r+=2}}if(!i)return null;this.sync(o);for(let s=0;s<i.length;s++)t=this.enterInner(i[s],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let o=this.textblockFromContext();o&&(t=this.enterInner(o,null,t))}let i=this.findPlace(e,t,n);if(i){this.closeExtra();let o=this.top;o.match&&(o.match=o.match.matchType(e.type));let s=M.none;for(let r of i.concat(e.marks))(o.type?o.type.allowsMarkType(r.type):Di(r.type,e.type))&&(s=r.addToSet(s));return o.content.push(e.mark(s)),!0}return!1}enter(e,t,n,i){let o=this.findPlace(e.create(t),n,!1);return o&&(o=this.enterInner(e,t,n,!0,i)),o}enterInner(e,t,n,i=!1,o){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(e);let r=Mi(e,o,s.options);s.options&pe&&s.content.length==0&&(r|=pe);let l=M.none;return n=n.filter(a=>(s.type?s.type.allowsMarkType(a.type):Di(a.type,e))?(l=a.addToSet(l),!1):!0),this.nodes.push(new Pe(e,t,l,i,null,r)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=we)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let i=n.length-1;i>=0;i--)e+=n[i].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&t.compareDocumentPosition(this.find[i].node)&(n?2:4)&&(this.find[i].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),n=this.options.context,i=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),o=-(n?n.depth+1:0)+(i?0:1),s=(r,l)=>{for(;r>=0;r--){let a=t[r];if(a==""){if(r==t.length-1||r==0)continue;for(;l>=o;l--)if(s(r-1,l))return!0;return!1}else{let h=l>0||l==0&&i?this.nodes[l].type:n&&l>=o?n.node(l-o).type:null;if(!h||h.name!=a&&!h.isInGroup(a))return!1;l--}}return!0};return s(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let t in this.parser.schema.nodes){let n=this.parser.schema.nodes[t];if(n.isTextblock&&n.defaultAttrs)return n}}};function _r(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let i=t.nodeType==1?t.nodeName.toLowerCase():null;i&&qo.hasOwnProperty(i)&&n?(n.appendChild(t),t=n):i=="li"?n=t:i&&(n=null)}}function tl(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function Ni(e){let t={};for(let n in e)t[n]=e[n];return t}function Di(e,t){let n=t.schema.nodes;for(let i in n){let o=n[i];if(!o.allowsMarkType(e))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==t||s.indexOf(c)<0&&r(c))return!0}};if(r(o.contentMatch))return!0}}var Me=class jo{constructor(t,n){this.nodes=t,this.marks=n}serializeFragment(t,n={},i){i||(i=ze(n).createDocumentFragment());let o=i,s=[];return t.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;)o=s.pop()[1];for(;a<r.marks.length;){let h=r.marks[a++],c=this.serializeMark(h,r.isInline,n);c&&(s.push([h,o]),o.appendChild(c.dom),o=c.contentDOM||c.dom)}}o.appendChild(this.serializeNodeInner(r,n))}),i}serializeNodeInner(t,n){if(t.isText)return ze(n).createTextNode(t.text);let{dom:i,contentDOM:o}=Fe(ze(n),this.nodes[t.type.name](t),null,t.attrs);if(o){if(t.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(t.content,n,o)}return i}serializeNode(t,n={}){let i=this.serializeNodeInner(t,n);for(let o=t.marks.length-1;o>=0;o--){let s=this.serializeMark(t.marks[o],t.isInline,n);s&&((s.contentDOM||s.dom).appendChild(i),i=s.dom)}return i}serializeMark(t,n,i={}){let o=this.marks[t.type.name];return o&&Fe(ze(i),o(t,n),null,t.attrs)}static renderSpec(t,n,i=null,o){return typeof n=="string"?{dom:t.createTextNode(n)}:Fe(t,n,i,o)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new jo(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(t){let n=Ti(t.nodes);return n.text||(n.text=i=>i.text),n}static marksFromSchema(t){return Ti(t.marks)}};function Ti(e){let t={};for(let n in e){let i=e[n].spec.toDOM;i&&(t[n]=i)}return t}function ze(e){return e.document||window.document}var Ei=new WeakMap;function el(e){let t=Ei.get(e);return t===void 0&&Ei.set(e,t=nl(e)),t}function nl(e){let t=null;function n(i){if(i&&typeof i=="object")if(Array.isArray(i))if(typeof i[0]=="string")t||(t=[]),t.push(i);else for(let o=0;o<i.length;o++)n(i[o]);else for(let o in i)n(i[o])}return n(e),t}function Fe(e,t,n,i){if(t.nodeType==1)return{dom:t};if(t.dom&&t.dom.nodeType==1)return t;let o=t[0],s;if(typeof o!="string")throw new RangeError("Invalid array passed to renderSpec");if(i&&(s=el(i))&&s.indexOf(t)>-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=o.indexOf(" ");r>0&&(n=o.slice(0,r),o=o.slice(r+1));let l,a=n?e.createElementNS(n,o):e.createElement(o),h=t[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<t.length;d++){let p=t[d];if(p===0){if(d<t.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(e.createTextNode(p));else{let{dom:u,contentDOM:f}=Fe(e,p,n,i);if(a.appendChild(u),f){if(l)throw new RangeError("Multiple content holes");l=f}}}return{dom:a,contentDOM:l}}var il={};ot(il,{AllSelection:()=>tt,EditorState:()=>Tl,NodeSelection:()=>k,Plugin:()=>Qt,PluginKey:()=>ni,Selection:()=>x,SelectionRange:()=>Ge,TextSelection:()=>C,Transaction:()=>hs});var ol={};ot(ol,{AddMarkStep:()=>_e,AddNodeMarkStep:()=>tn,AttrStep:()=>ti,DocAttrStep:()=>ei,MapResult:()=>Ue,Mapping:()=>Gn,RemoveMarkStep:()=>Xt,RemoveNodeMarkStep:()=>ve,ReplaceAroundStep:()=>nt,ReplaceStep:()=>X,Step:()=>P,StepMap:()=>bt,StepResult:()=>V,Transform:()=>ss,TransformError:()=>Rt,canJoin:()=>zt,canSplit:()=>fe,dropPoint:()=>_n,findWrapping:()=>Qn,insertPoint:()=>_o,joinPoint:()=>Zn,liftTarget:()=>Oe,replaceStep:()=>Ne});var Ko=65535,Ho=Math.pow(2,16);function sl(e,t){return e+t*Ho}function Ai(e){return e&Ko}function rl(e){return(e-(e&Ko))/Ho}var Uo=1,Go=2,Le=4,Yo=8,Ue=class{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&Yo)>0}get deletedBefore(){return(this.delInfo&(Uo|Le))>0}get deletedAfter(){return(this.delInfo&(Go|Le))>0}get deletedAcross(){return(this.delInfo&Le)>0}},bt=class Ft{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&Ft.empty)return Ft.empty}recover(t){let n=0,i=Ai(t);if(!this.inverted)for(let o=0;o<i;o++)n+=this.ranges[o*3+2]-this.ranges[o*3+1];return this.ranges[i*3]+n+rl(t)}mapResult(t,n=1){return this._map(t,n,!1)}map(t,n=1){return this._map(t,n,!0)}_map(t,n,i){let o=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?o:0);if(a>t)break;let h=this.ranges[l+s],c=this.ranges[l+r],d=a+h;if(t<=d){let p=h?t==a?-1:t==d?1:n:n,u=a+o+(p<0?0:c);if(i)return u;let f=t==(n<0?a:d)?null:sl(l/3,t-a),m=0;return h&&(m|=t==a?Go:t==d?Uo:Le,(n<0?t!=a:t!=d)&&(m|=Yo)),new Ue(u,m,f)}o+=c-h}return i?t+o:new Ue(t+o,0,null)}touches(t,n){let i=0,o=Ai(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?i:0);if(a>t)break;let h=this.ranges[l+s],c=a+h;if(t<=c&&l==o*3)return!0;i+=this.ranges[l+r]-h}return!1}forEach(t){let n=this.inverted?2:1,i=this.inverted?1:2;for(let o=0,s=0;o<this.ranges.length;o+=3){let r=this.ranges[o],l=r-(this.inverted?s:0),a=r+(this.inverted?0:s),h=this.ranges[o+n],c=this.ranges[o+i];t(l,l+h,a,a+c),s+=c-h}}invert(){return new Ft(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(t){return t==0?Ft.empty:new Ft(t<0?[0,-t,0]:[0,0,t])}};bt.empty=new bt([]);var Gn=class Tn{constructor(t,n,i=0,o=t?t.length:0){this.mirror=n,this.from=i,this.to=o,this._maps=t||[],this.ownData=!(t||n)}get maps(){return this._maps}slice(t=0,n=this.maps.length){return new Tn(this._maps,this.mirror,t,n)}appendMap(t,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(t),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(t){for(let n=0,i=this._maps.length;n<t._maps.length;n++){let o=t.getMirror(n);this.appendMap(t._maps[n],o!=null&&o<n?i+o:void 0)}}getMirror(t){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==t)return this.mirror[n+(n%2?-1:1)]}}setMirror(t,n){this.mirror||(this.mirror=[]),this.mirror.push(t,n)}appendMappingInverted(t){for(let n=t.maps.length-1,i=this._maps.length+t._maps.length;n>=0;n--){let o=t.getMirror(n);this.appendMap(t._maps[n].invert(),o!=null&&o>n?i-o-1:void 0)}}invert(){let t=new Tn;return t.appendMappingInverted(this),t}map(t,n=1){if(this.mirror)return this._map(t,n,!0);for(let i=this.from;i<this.to;i++)t=this._maps[i].map(t,n);return t}mapResult(t,n=1){return this._map(t,n,!1)}_map(t,n,i){let o=0;for(let s=this.from;s<this.to;s++){let r=this._maps[s],l=r.mapResult(t,n);if(l.recover!=null){let a=this.getMirror(s);if(a!=null&&a>s&&a<this.to){s=a,t=this._maps[a].recover(l.recover);continue}}o|=l.delInfo,t=l.pos}return i?t:new Ue(t,o,null)}},ln=Object.create(null),P=class{getMap(){return bt.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=ln[t.stepType];if(!n)throw new RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in ln)throw new RangeError("Duplicate use of step JSON ID "+e);return ln[e]=t,t.prototype.jsonID=e,t}},V=class te{constructor(t,n){this.doc=t,this.failed=n}static ok(t){return new te(t,null)}static fail(t){return new te(null,t)}static fromReplace(t,n,i,o){try{return te.ok(t.replace(n,i,o))}catch(s){if(s instanceof Kt)return te.fail(s.message);throw s}}};function Yn(e,t,n){let i=[];for(let o=0;o<e.childCount;o++){let s=e.child(o);s.content.size&&(s=s.copy(Yn(s.content,t,s))),s.isInline&&(s=t(s,n,o)),i.push(s)}return y.fromArray(i)}var _e=class ee extends P{constructor(t,n,i){super(),this.from=t,this.to=n,this.mark=i}apply(t){let n=t.slice(this.from,this.to),i=t.resolve(this.from),o=i.node(i.sharedDepth(this.to)),s=new w(Yn(n.content,(r,l)=>!r.isAtom||!l.type.allowsMarkType(this.mark.type)?r:r.mark(this.mark.addToSet(r.marks)),o),n.openStart,n.openEnd);return V.fromReplace(t,this.from,this.to,s)}invert(){return new Xt(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),i=t.mapResult(this.to,-1);return n.deleted&&i.deleted||n.pos>=i.pos?null:new ee(n.pos,i.pos,this.mark)}merge(t){return t instanceof ee&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new ee(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new ee(n.from,n.to,t.markFromJSON(n.mark))}};P.jsonID("addMark",_e);var Xt=class ne extends P{constructor(t,n,i){super(),this.from=t,this.to=n,this.mark=i}apply(t){let n=t.slice(this.from,this.to),i=new w(Yn(n.content,o=>o.mark(this.mark.removeFromSet(o.marks)),t),n.openStart,n.openEnd);return V.fromReplace(t,this.from,this.to,i)}invert(){return new _e(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),i=t.mapResult(this.to,-1);return n.deleted&&i.deleted||n.pos>=i.pos?null:new ne(n.pos,i.pos,this.mark)}merge(t){return t instanceof ne&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new ne(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new ne(n.from,n.to,t.markFromJSON(n.mark))}};P.jsonID("removeMark",Xt);var tn=class ie extends P{constructor(t,n){super(),this.pos=t,this.mark=n}apply(t){let n=t.nodeAt(this.pos);if(!n)return V.fail("No node at mark step's position");let i=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return V.fromReplace(t,this.pos,this.pos+1,new w(y.from(i),0,n.isLeaf?0:1))}invert(t){let n=t.nodeAt(this.pos);if(n){let i=this.mark.addToSet(n.marks);if(i.length==n.marks.length){for(let o=0;o<n.marks.length;o++)if(!n.marks[o].isInSet(i))return new ie(this.pos,n.marks[o]);return new ie(this.pos,this.mark)}}return new ve(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new ie(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new ie(n.pos,t.markFromJSON(n.mark))}};P.jsonID("addNodeMark",tn);var ve=class En extends P{constructor(t,n){super(),this.pos=t,this.mark=n}apply(t){let n=t.nodeAt(this.pos);if(!n)return V.fail("No node at mark step's position");let i=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return V.fromReplace(t,this.pos,this.pos+1,new w(y.from(i),0,n.isLeaf?0:1))}invert(t){let n=t.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new tn(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new En(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new En(n.pos,t.markFromJSON(n.mark))}};P.jsonID("removeNodeMark",ve);var X=class pt extends P{constructor(t,n,i,o=!1){super(),this.from=t,this.to=n,this.slice=i,this.structure=o}apply(t){return this.structure&&An(t,this.from,this.to)?V.fail("Structure replace would overwrite content"):V.fromReplace(t,this.from,this.to,this.slice)}getMap(){return new bt([this.from,this.to-this.from,this.slice.size])}invert(t){return new pt(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let n=t.mapResult(this.to,-1),i=this.from==this.to&&pt.MAP_BIAS<0?n:t.mapResult(this.from,1);return i.deletedAcross&&n.deletedAcross?null:new pt(i.pos,Math.max(i.pos,n.pos),this.slice,this.structure)}merge(t){if(!(t instanceof pt)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let n=this.slice.size+t.slice.size==0?w.empty:new w(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new pt(this.from,this.to+(t.to-t.from),n,this.structure)}else if(t.to==this.from&&!this.slice.openStart&&!t.slice.openEnd){let n=this.slice.size+t.slice.size==0?w.empty:new w(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new pt(t.from,this.to,n,this.structure)}else return null}toJSON(){let t={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new pt(n.from,n.to,w.fromJSON(t,n.slice),!!n.structure)}};X.MAP_BIAS=1;P.jsonID("replace",X);var nt=class Je extends P{constructor(t,n,i,o,s,r,l=!1){super(),this.from=t,this.to=n,this.gapFrom=i,this.gapTo=o,this.slice=s,this.insert=r,this.structure=l}apply(t){if(this.structure&&(An(t,this.from,this.gapFrom)||An(t,this.gapTo,this.to)))return V.fail("Structure gap-replace would overwrite content");let n=t.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return V.fail("Gap is not a flat range");let i=this.slice.insertAt(this.insert,n.content);return i?V.fromReplace(t,this.from,this.to,i):V.fail("Content does not fit in gap")}getMap(){return new bt([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let n=this.gapTo-this.gapFrom;return new Je(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let n=t.mapResult(this.from,1),i=t.mapResult(this.to,-1),o=this.from==this.gapFrom?n.pos:t.map(this.gapFrom,-1),s=this.to==this.gapTo?i.pos:t.map(this.gapTo,1);return n.deletedAcross&&i.deletedAcross||o<n.pos||s>i.pos?null:new Je(n.pos,i.pos,o,s,this.slice,this.insert,this.structure)}toJSON(){let t={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,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 Je(n.from,n.to,n.gapFrom,n.gapTo,w.fromJSON(t,n.slice),n.insert,!!n.structure)}};P.jsonID("replaceAround",nt);function An(e,t,n){let i=e.resolve(t),o=n-t,s=i.depth;for(;o>0&&s>0&&i.indexAfter(s)==i.node(s).childCount;)s--,o--;if(o>0){let r=i.node(s).maybeChild(i.indexAfter(s));for(;o>0;){if(!r||r.isLeaf)return!0;r=r.firstChild,o--}}return!1}function ll(e,t,n,i){let o=[],s=[],r,l;e.doc.nodesBetween(t,n,(a,h,c)=>{if(!a.isInline)return;let d=a.marks;if(!i.isInSet(d)&&c.type.allowsMarkType(i.type)){let p=Math.max(h,t),u=Math.min(h+a.nodeSize,n),f=i.addToSet(d);for(let m=0;m<d.length;m++)d[m].isInSet(f)||(r&&r.to==p&&r.mark.eq(d[m])?r.to=u:o.push(r=new Xt(p,u,d[m])));l&&l.to==p?l.to=u:s.push(l=new _e(p,u,i))}}),o.forEach(a=>e.step(a)),s.forEach(a=>e.step(a))}function al(e,t,n,i){let o=[],s=0;e.doc.nodesBetween(t,n,(r,l)=>{if(!r.isInline)return;s++;let a=null;if(i instanceof Hn){let h=r.marks,c;for(;c=i.isInSet(h);)(a||(a=[])).push(c),h=c.removeFromSet(h)}else i?i.isInSet(r.marks)&&(a=[i]):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 u=0;u<o.length;u++){let f=o[u];f.step==s-1&&d.eq(o[u].style)&&(p=f)}p?(p.to=h,p.step=s):o.push({style:d,from:Math.max(l,t),to:h,step:s})}}}),o.forEach(r=>e.step(new Xt(r.from,r.to,r.style)))}function Xn(e,t,n,i=n.contentMatch,o=!0){let s=e.doc.nodeAt(t),r=[],l=t+1;for(let a=0;a<s.childCount;a++){let h=s.child(a),c=l+h.nodeSize,d=i.matchType(h.type);if(!d)r.push(new X(l,c,w.empty));else{i=d;for(let p=0;p<h.marks.length;p++)n.allowsMarkType(h.marks[p].type)||e.step(new Xt(l,c,h.marks[p]));if(o&&h.isText&&n.whitespace!="pre"){let p,u=/\r?\n|\r/g,f;for(;p=u.exec(h.text);)f||(f=new w(y.from(n.schema.text(" ",n.allowedMarks(h.marks))),0,0)),r.push(new X(l+p.index,l+p.index+p[0].length,f))}}l=c}if(!i.validEnd){let a=i.fillBefore(y.empty,!0);e.replace(l,l,new w(a,0,0))}for(let a=r.length-1;a>=0;a--)e.step(r[a])}function hl(e,t,n){return(t==0||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function Oe(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,i=0,o=0;;--n){let s=e.$from.node(n),r=e.$from.index(n)+i,l=e.$to.indexAfter(n)-o;if(n<e.depth&&s.canReplace(r,l,t))return n;if(n==0||s.type.spec.isolating||!hl(s,r,l))break;r&&(i=1),l<s.childCount&&(o=1)}return null}function cl(e,t,n){let{$from:i,$to:o,depth:s}=t,r=i.before(s+1),l=o.after(s+1),a=r,h=l,c=y.empty,d=0;for(let f=s,m=!1;f>n;f--)m||i.index(f)>0?(m=!0,c=y.from(i.node(f).copy(c)),d++):a--;let p=y.empty,u=0;for(let f=s,m=!1;f>n;f--)m||o.after(f+1)<o.end(f)?(m=!0,p=y.from(o.node(f).copy(p)),u++):h++;e.step(new nt(a,h,r,l,new w(c.append(p),d,u),c.size-d,!0))}function Qn(e,t,n=null,i=e){let o=dl(e,t),s=o&&pl(i,t);return s?o.map(Ri).concat({type:t,attrs:n}).concat(s.map(Ri)):null}function Ri(e){return{type:e,attrs:null}}function dl(e,t){let{parent:n,startIndex:i,endIndex:o}=e,s=n.contentMatchAt(i).findWrapping(t);if(!s)return null;let r=s.length?s[0]:t;return n.canReplaceWith(i,o,r)?s:null}function pl(e,t){let{parent:n,startIndex:i,endIndex:o}=e,s=n.child(i),r=t.contentMatch.findWrapping(s.type);if(!r)return null;let l=(r.length?r[r.length-1]:t).contentMatch;for(let a=i;l&&a<o;a++)l=l.matchType(n.child(a).type);return!l||!l.validEnd?null:r}function fl(e,t,n){let i=y.empty;for(let r=n.length-1;r>=0;r--){if(i.size){let l=n[r].type.contentMatch.matchFragment(i);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}i=y.from(n[r].type.create(n[r].attrs,i))}let o=t.start,s=t.end;e.step(new nt(o,s,o,s,new w(i,0,0),n.length,!0))}function ul(e,t,n,i,o){if(!i.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=e.steps.length;e.doc.nodesBetween(t,n,(r,l)=>{let a=typeof o=="function"?o(r):o;if(r.isTextblock&&!r.hasMarkup(i,a)&&ml(e.doc,e.mapping.slice(s).map(l),i)){let h=null;if(i.schema.linebreakReplacement){let u=i.whitespace=="pre",f=!!i.contentMatch.matchType(i.schema.linebreakReplacement);u&&!f?h=!1:!u&&f&&(h=!0)}h===!1&&Qo(e,r,l,s),Xn(e,e.mapping.slice(s).map(l,1),i,void 0,h===null);let c=e.mapping.slice(s),d=c.map(l,1),p=c.map(l+r.nodeSize,1);return e.step(new nt(d,p,d+1,p-1,new w(y.from(i.create(a,null,r.marks)),0,0),1,!0)),h===!0&&Xo(e,r,l,s),!1}})}function Xo(e,t,n,i){t.forEach((o,s)=>{if(o.isText){let r,l=/\r?\n|\r/g;for(;r=l.exec(o.text);){let a=e.mapping.slice(i).map(n+1+s+r.index);e.replaceWith(a,a+1,t.type.schema.linebreakReplacement.create())}}})}function Qo(e,t,n,i){t.forEach((o,s)=>{if(o.type==o.type.schema.linebreakReplacement){let r=e.mapping.slice(i).map(n+1+s);e.replaceWith(r,r+1,t.type.schema.text(`
|
|
5
|
+
`))}})}function ml(e,t,n){let i=e.resolve(t),o=i.index();return i.parent.canReplaceWith(o,o+1,n)}function gl(e,t,n,i,o){let s=e.doc.nodeAt(t);if(!s)throw new RangeError("No node at given position");n||(n=s.type);let r=n.create(i,null,o||s.marks);if(s.isLeaf)return e.replaceWith(t,t+s.nodeSize,r);if(!n.validContent(s.content))throw new RangeError("Invalid content for node type "+n.name);e.step(new nt(t,t+s.nodeSize,t+1,t+s.nodeSize-1,new w(y.from(r),0,0),1,!0))}function fe(e,t,n=1,i){let o=e.resolve(t),s=o.depth-n,r=i&&i[i.length-1]||o.parent;if(s<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!r.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(let h=o.depth-1,c=n-2;h>s;h--,c--){let d=o.node(h),p=o.index(h);if(d.type.spec.isolating)return!1;let u=d.content.cutByIndex(p,d.childCount),f=i&&i[c+1];f&&(u=u.replaceChild(0,f.type.create(f.attrs)));let m=i&&i[c]||d;if(!d.canReplace(p+1,d.childCount)||!m.type.validContent(u))return!1}let l=o.indexAfter(s),a=i&&i[0];return o.node(s).canReplaceWith(l,l,a?a.type:o.node(s+1).type)}function yl(e,t,n=1,i){let o=e.doc.resolve(t),s=y.empty,r=y.empty;for(let l=o.depth,a=o.depth-n,h=n-1;l>a;l--,h--){s=y.from(o.node(l).copy(s));let c=i&&i[h];r=y.from(c?c.type.create(c.attrs,r):o.node(l).copy(r))}e.step(new X(t,t,new w(s.append(r),n,n),!0))}function zt(e,t){let n=e.resolve(t),i=n.index();return Zo(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(i,i+1)}function wl(e,t){t.content.size||e.type.compatibleContent(t.type);let n=e.contentMatchAt(e.childCount),{linebreakReplacement:i}=e.type.schema;for(let o=0;o<t.childCount;o++){let s=t.child(o),r=s.type==i?e.type.schema.nodes.text:s.type;if(n=n.matchType(r),!n||!e.type.allowsMarks(s.marks))return!1}return n.validEnd}function Zo(e,t){return!!(e&&t&&!e.isLeaf&&wl(e,t))}function Zn(e,t,n=-1){let i=e.resolve(t);for(let o=i.depth;;o--){let s,r,l=i.index(o);if(o==i.depth?(s=i.nodeBefore,r=i.nodeAfter):n>0?(s=i.node(o+1),l++,r=i.node(o).maybeChild(l)):(s=i.node(o).maybeChild(l-1),r=i.node(o+1)),s&&!s.isTextblock&&Zo(s,r)&&i.node(o).canReplace(l,l+1))return t;if(o==0)break;t=n<0?i.before(o):i.after(o)}}function vl(e,t,n){let i=null,{linebreakReplacement:o}=e.doc.type.schema,s=e.doc.resolve(t-n),r=s.node().type;if(o&&r.inlineContent){let c=r.whitespace=="pre",d=!!r.contentMatch.matchType(o);c&&!d?i=!1:!c&&d&&(i=!0)}let l=e.steps.length;if(i===!1){let c=e.doc.resolve(t+n);Qo(e,c.node(),c.before(),l)}r.inlineContent&&Xn(e,t+n-1,r,s.node().contentMatchAt(s.index()),i==null);let a=e.mapping.slice(l),h=a.map(t-n);if(e.step(new X(h,a.map(t+n,-1),w.empty,!0)),i===!0){let c=e.doc.resolve(h);Xo(e,c.node(),c.before(),e.steps.length)}return e}function _o(e,t,n){let i=e.resolve(t);if(i.parent.canReplaceWith(i.index(),i.index(),n))return t;if(i.parentOffset==0)for(let o=i.depth-1;o>=0;o--){let s=i.index(o);if(i.node(o).canReplaceWith(s,s,n))return i.before(o+1);if(s>0)return null}if(i.parentOffset==i.parent.content.size)for(let o=i.depth-1;o>=0;o--){let s=i.indexAfter(o);if(i.node(o).canReplaceWith(s,s,n))return i.after(o+1);if(s<i.node(o).childCount)return null}return null}function _n(e,t,n){let i=e.resolve(t);if(!n.content.size)return t;let o=n.content;for(let s=0;s<n.openStart;s++)o=o.firstChild.content;for(let s=1;s<=(n.openStart==0&&n.size?2:1);s++)for(let r=i.depth;r>=0;r--){let l=r==i.depth?0:i.pos<=(i.start(r+1)+i.end(r+1))/2?-1:1,a=i.index(r)+(l>0?1:0),h=i.node(r),c=!1;if(s==1)c=h.canReplace(a,a,o);else{let d=h.contentMatchAt(a).findWrapping(o.firstChild.type);c=d&&h.canReplaceWith(a,a,d[0])}if(c)return l==0?i.pos:l<0?i.before(r+1):i.after(r+1)}return null}function Ne(e,t,n=t,i=w.empty){if(t==n&&!i.size)return null;let o=e.resolve(t),s=e.resolve(n);return ts(o,s,i)?new X(t,n,i):new bl(o,s,i).fit()}function ts(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}var bl=class{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=y.empty;for(let i=0;i<=e.depth;i++){let o=e.node(i);this.frontier.push({type:o.type,match:o.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=y.from(e.node(i).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 e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,i=this.close(e<0?this.$to:n.doc.resolve(e));if(!i)return null;let o=this.placed,s=n.depth,r=i.depth;for(;s&&r&&o.childCount==1;)o=o.firstChild.content,s--,r--;let l=new w(o,s,r);return e>-1?new nt(n.pos,e,this.$to.pos,this.$to.end(),l,t):l.size||n.pos!=this.$to.pos?new X(n.pos,i.pos,l):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,i=this.unplaced.openEnd;n<e;n++){let o=t.firstChild;if(t.childCount>1&&(i=0),o.type.spec.isolating&&i<=n){e=n;break}t=o.content}for(let t=1;t<=2;t++)for(let n=t==1?e:this.unplaced.openStart;n>=0;n--){let i,o=null;n?(o=Ii(this.unplaced.content,n-1).firstChild,i=o.content):i=this.unplaced.content;let s=i.firstChild;for(let r=this.depth;r>=0;r--){let{type:l,match:a}=this.frontier[r],h,c=null;if(t==1&&(s?a.matchType(s.type)||(c=a.fillBefore(y.from(s),!1)):o&&l.compatibleContent(o.type)))return{sliceDepth:n,frontierDepth:r,parent:o,inject:c};if(t==2&&s&&(h=a.findWrapping(s.type)))return{sliceDepth:n,frontierDepth:r,parent:o,wrap:h};if(o&&a.matchType(o.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced;return Pi(e,-1)<=t?!1:(this.unplaced.size>1&&Pi(e,1)>n&&n++,this.unplaced=new w(e,t+1,n),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,i=Ii(e,t);if(i.childCount<=1&&t>0){let o=e.size-t<=t+i.size;this.unplaced=new w(oe(e,t-1,1),t-1,o?t-1:n)}else this.unplaced=new w(oe(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:i,wrap:o}){for(;this.depth>t;)this.closeFrontierNode();if(o)for(let f=0;f<o.length;f++)this.openFrontierNode(o[f]);let s=this.unplaced,r=n?n.content:s.content,l=s.openStart-e,a=0,h=[],{match:c,type:d}=this.frontier[t];if(i){for(let f=0;f<i.childCount;f++)h.push(i.child(f));c=c.matchFragment(i)}let p=r.size+e-(s.content.size-s.openEnd);for(;a<r.childCount;){let f=r.child(a),m=c.matchType(f.type);if(!m)break;a++,(a>1||l==0||f.content.size)&&(c=m,h.push(es(f.mark(d.allowedMarks(f.marks)),a==1?l:0,a==r.childCount?p:-1)))}let u=a==r.childCount;u||(p=-1),this.placed=se(this.placed,t,y.from(h)),this.frontier[t].match=c,u&&p<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let f=0,m=r;f<p;f++){let g=m.lastChild;this.frontier.push({type:g.type,match:g.contentMatchAt(g.childCount)}),m=g.content}this.unplaced=u?e==0?w.empty:new w(oe(s.content,e-1,1),e-1,p<0?s.openEnd:e-1):new w(oe(s.content,e,a),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!an(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:n}=this.$to,i=this.$to.after(n);for(;n>1&&i==this.$to.end(--n);)++i;return i}findCloseLevel(e){t:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:i}=this.frontier[t],o=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),s=an(e,t,i,n,o);if(s){for(let r=t-1;r>=0;r--){let{match:l,type:a}=this.frontier[r],h=an(e,r,a,l,!0);if(!h||h.childCount)continue t}return{depth:t,fit:s,move:o?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=se(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let i=e.node(n),o=i.type.contentMatch.fillBefore(i.content,!0,e.index(n));this.openFrontierNode(i.type,i.attrs,o)}return e}openFrontierNode(e,t=null,n){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=se(this.placed,this.depth,y.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(y.empty,!0);e.childCount&&(this.placed=se(this.placed,this.frontier.length,e))}};function oe(e,t,n){return t==0?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(oe(e.firstChild.content,t-1,n)))}function se(e,t,n){return t==0?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(se(e.lastChild.content,t-1,n)))}function Ii(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function es(e,t,n){if(t<=0)return e;let i=e.content;return t>1&&(i=i.replaceChild(0,es(i.firstChild,t-1,i.childCount==1?n-1:0))),t>0&&(i=e.type.contentMatch.fillBefore(i).append(i),n<=0&&(i=i.append(e.type.contentMatch.matchFragment(i).fillBefore(y.empty,!0)))),e.copy(i)}function an(e,t,n,i,o){let s=e.node(t),r=o?e.indexAfter(t):e.index(t);if(r==s.childCount&&!n.compatibleContent(s.type))return null;let l=i.fillBefore(s.content,!0,r);return l&&!kl(n,s.content,r)?l:null}function kl(e,t,n){for(let i=n;i<t.childCount;i++)if(!e.allowsMarks(t.child(i).marks))return!0;return!1}function xl(e){return e.spec.defining||e.spec.definingForContent}function Pi(e,t){for(let n=0;;n++){let i=t<0?e.firstChild:e.lastChild;if(!i||i.isAtom)return n;e=i.content}}function Sl(e,t,n,i){if(!i.size)return e.deleteRange(t,n);let o=e.doc.resolve(t),s=e.doc.resolve(n);if(ts(o,s,i))return e.step(new X(t,n,i));let r=is(o,s);r[r.length-1]==0&&r.pop();let l=-(o.depth+1);r.unshift(l);for(let p=o.depth,u=o.pos-1;p>0;p--,u--){let f=o.node(p).type.spec;if(f.defining||f.definingAsContext||f.isolating)break;r.indexOf(p)>-1?l=p:o.before(p)==u&&r.splice(1,0,-p)}let a=r.indexOf(l),h=[],c=i.openStart;for(let p=i.content,u=0;;u++){let f=p.firstChild;if(h.push(f),u==i.openStart)break;p=f.content}for(let p=c-1;p>=0;p--){let u=h[p],f=xl(u.type);if(f&&!u.sameMarkup(o.node(Math.abs(l)-1)))c=p;else if(f||!u.type.isTextblock)break}for(let p=i.openStart;p>=0;p--){let u=(p+c+1)%(i.openStart+1),f=h[u];if(f)for(let m=0;m<r.length;m++){let g=r[(m+a)%r.length],b=!0;g<0&&(b=!1,g=-g);let N=o.node(g-1),O=o.index(g-1);if(N.canReplaceWith(O,O,f.type,f.marks))return e.replace(o.before(g),b?s.after(g):n,new w(ns(i.content,0,i.openStart,u),u,i.openEnd))}}let d=e.steps.length;for(let p=r.length-1;p>=0&&(e.replace(t,n,i),!(e.steps.length>d));p--){let u=r[p];u<0||(t=o.before(u),n=s.after(u))}}function ns(e,t,n,i,o){if(t<n){let s=e.firstChild;e=e.replaceChild(0,s.copy(ns(s.content,t+1,n,i,s)))}if(t>i){let s=o.contentMatchAt(0),r=s.fillBefore(e).append(e);e=r.append(s.matchFragment(r).fillBefore(y.empty,!0))}return e}function Cl(e,t,n,i){if(!i.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let o=_o(e.doc,t,i.type);o!=null&&(t=n=o)}e.replaceRange(t,n,new w(y.from(i),0,0))}function Ml(e,t,n){let i=e.doc.resolve(t),o=e.doc.resolve(n);if(i.parent.isTextblock&&o.parent.isTextblock&&i.start()!=o.start()&&i.parentOffset==0&&o.parentOffset==0){let r=i.sharedDepth(n),l=!1;for(let a=i.depth;a>r;a--)i.node(a).type.spec.isolating&&(l=!0);for(let a=o.depth;a>r;a--)o.node(a).type.spec.isolating&&(l=!0);if(!l){for(let a=i.depth;a>0&&t==i.start(a);a--)t=i.before(a);for(let a=o.depth;a>0&&n==o.start(a);a--)n=o.before(a);i=e.doc.resolve(t),o=e.doc.resolve(n)}}let s=is(i,o);for(let r=0;r<s.length;r++){let l=s[r],a=r==s.length-1;if(a&&l==0||i.node(l).type.contentMatch.validEnd)return e.delete(i.start(l),o.end(l));if(l>0&&(a||i.node(l-1).canReplace(i.index(l-1),o.indexAfter(l-1))))return e.delete(i.before(l),o.after(l))}for(let r=1;r<=i.depth&&r<=o.depth;r++)if(t-i.start(r)==i.depth-r&&n>i.end(r)&&o.end(r)-n!=o.depth-r&&i.start(r-1)==o.start(r-1)&&i.node(r-1).canReplace(i.index(r-1),o.index(r-1)))return e.delete(i.before(r),n);e.delete(t,n)}function is(e,t){let n=[],i=Math.min(e.depth,t.depth);for(let o=i;o>=0;o--){let s=e.start(o);if(s<e.pos-(e.depth-o)||t.end(o)>t.pos+(t.depth-o)||e.node(o).type.spec.isolating||t.node(o).type.spec.isolating)break;(s==t.start(o)||o==e.depth&&o==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&o&&t.start(o-1)==s-1)&&n.push(o)}return n}var ti=class We extends P{constructor(t,n,i){super(),this.pos=t,this.attr=n,this.value=i}apply(t){let n=t.nodeAt(this.pos);if(!n)return V.fail("No node at attribute step's position");let i=Object.create(null);for(let s in n.attrs)i[s]=n.attrs[s];i[this.attr]=this.value;let o=n.type.create(i,null,n.marks);return V.fromReplace(t,this.pos,this.pos+1,new w(y.from(o),0,n.isLeaf?0:1))}getMap(){return bt.empty}invert(t){return new We(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new We(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new We(n.pos,n.attr,n.value)}};P.jsonID("attr",ti);var ei=class Rn extends P{constructor(t,n){super(),this.attr=t,this.value=n}apply(t){let n=Object.create(null);for(let o in t.attrs)n[o]=t.attrs[o];n[this.attr]=this.value;let i=t.type.create(n,t.content,t.marks);return V.ok(i)}getMap(){return bt.empty}invert(t){return new Rn(this.attr,t.attrs[this.attr])}map(t){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Rn(n.attr,n.value)}};P.jsonID("docAttr",ei);var Rt=class extends Error{};Rt=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n};Rt.prototype=Object.create(Error.prototype);Rt.prototype.constructor=Rt;Rt.prototype.name="TransformError";var ss=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Gn}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Rt(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let n=0;n<this.mapping.maps.length;n++){let i=this.mapping.maps[n];n&&(e=i.map(e,1),t=i.map(t,-1)),i.forEach((o,s,r,l)=>{e=Math.min(e,r),t=Math.max(t,l)})}return e==1e9?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,n=w.empty){let i=Ne(this.doc,e,t,n);return i&&this.step(i),this}replaceWith(e,t,n){return this.replace(e,t,new w(y.from(n),0,0))}delete(e,t){return this.replace(e,t,w.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return Sl(this,e,t,n),this}replaceRangeWith(e,t,n){return Cl(this,e,t,n),this}deleteRange(e,t){return Ml(this,e,t),this}lift(e,t){return cl(this,e,t),this}join(e,t=1){return vl(this,e,t),this}wrap(e,t){return fl(this,e,t),this}setBlockType(e,t=e,n,i=null){return ul(this,e,t,n,i),this}setNodeMarkup(e,t,n=null,i){return gl(this,e,t,n,i),this}setNodeAttribute(e,t,n){return this.step(new ti(e,t,n)),this}setDocAttribute(e,t){return this.step(new ei(e,t)),this}addNodeMark(e,t){return this.step(new tn(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw new RangeError("No node at position "+e);if(t instanceof M)t.isInSet(n.marks)&&this.step(new ve(e,t));else{let i=n.marks,o,s=[];for(;o=t.isInSet(i);)s.push(new ve(e,o)),i=o.removeFromSet(i);for(let r=s.length-1;r>=0;r--)this.step(s[r])}return this}split(e,t=1,n){return yl(this,e,t,n),this}addMark(e,t,n){return ll(this,e,t,n),this}removeMark(e,t,n){return al(this,e,t,n),this}clearIncompatible(e,t,n){return Xn(this,e,t,n),this}},hn=Object.create(null),x=class{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new Ge(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=w.empty){let n=t.content.lastChild,i=null;for(let r=0;r<t.openEnd;r++)i=n,n=n.lastChild;let o=e.steps.length,s=this.ranges;for(let r=0;r<s.length;r++){let{$from:l,$to:a}=s[r],h=e.mapping.slice(o);e.replaceRange(h.map(l.pos),h.map(a.pos),r?w.empty:t),r==0&&$i(e,o,(n?n.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,i=this.ranges;for(let o=0;o<i.length;o++){let{$from:s,$to:r}=i[o],l=e.mapping.slice(n),a=l.map(s.pos),h=l.map(r.pos);o?e.deleteRange(a,h):(e.replaceRangeWith(a,h,t),$i(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let i=e.parent.inlineContent?new C(e):Lt(e.node(0),e.parent,e.pos,e.index(),t,n);if(i)return i;for(let o=e.depth-1;o>=0;o--){let s=t<0?Lt(e.node(0),e.node(o),e.before(o+1),e.index(o),t,n):Lt(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,t,n);if(s)return s}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new tt(e.node(0))}static atStart(e){return Lt(e,e,0,0,1)||new tt(e)}static atEnd(e){return Lt(e,e,e.content.size,e.childCount,-1)||new tt(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=hn[t.type];if(!n)throw new RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in hn)throw new RangeError("Duplicate use of selection JSON ID "+e);return hn[e]=t,t.prototype.jsonID=e,t}getBookmark(){return C.between(this.$anchor,this.$head).getBookmark()}};x.prototype.visible=!0;var Ge=class{constructor(e,t){this.$from=e,this.$to=t}},zi=!1;function Bi(e){!zi&&!e.parent.inlineContent&&(zi=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}var C=class re extends x{constructor(t,n=t){Bi(t),Bi(n),super(t,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,n){let i=t.resolve(n.map(this.head));if(!i.parent.inlineContent)return x.near(i);let o=t.resolve(n.map(this.anchor));return new re(o.parent.inlineContent?o:i,i)}replace(t,n=w.empty){if(super.replace(t,n),n==w.empty){let i=this.$from.marksAcross(this.$to);i&&t.ensureMarks(i)}}eq(t){return t instanceof re&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new rs(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(t,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new re(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,i=n){let o=t.resolve(n);return new this(o,i==n?o:t.resolve(i))}static between(t,n,i){let o=t.pos-n.pos;if((!i||o)&&(i=o>=0?1:-1),!n.parent.inlineContent){let s=x.findFrom(n,i,!0)||x.findFrom(n,-i,!0);if(s)n=s.$head;else return x.near(n,i)}return t.parent.inlineContent||(o==0?t=n:(t=(x.findFrom(t,-i,!0)||x.findFrom(t,i,!0)).$anchor,t.pos<n.pos!=o<0&&(t=n))),new re(t,n)}};x.jsonID("text",C);var rs=class ls{constructor(t,n){this.anchor=t,this.head=n}map(t){return new ls(t.map(this.anchor),t.map(this.head))}resolve(t){return C.between(t.resolve(this.anchor),t.resolve(this.head))}},k=class le extends x{constructor(t){let n=t.nodeAfter,i=t.node(0).resolve(t.pos+n.nodeSize);super(t,i),this.node=n}map(t,n){let{deleted:i,pos:o}=n.mapResult(this.anchor),s=t.resolve(o);return i?x.near(s):new le(s)}content(){return new w(y.from(this.node),0,0)}eq(t){return t instanceof le&&t.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Ol(this.anchor)}static fromJSON(t,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new le(t.resolve(n.anchor))}static create(t,n){return new le(t.resolve(n))}static isSelectable(t){return!t.isText&&t.type.spec.selectable!==!1}};k.prototype.visible=!1;x.jsonID("node",k);var Ol=class as{constructor(t){this.anchor=t}map(t){let{deleted:n,pos:i}=t.mapResult(this.anchor);return n?new rs(i,i):new as(i)}resolve(t){let n=t.resolve(this.anchor),i=n.nodeAfter;return i&&k.isSelectable(i)?new k(n):x.near(n)}},tt=class qe extends x{constructor(t){super(t.resolve(0),t.resolve(t.content.size))}replace(t,n=w.empty){if(n==w.empty){t.delete(0,t.doc.content.size);let i=x.atStart(t.doc);i.eq(t.selection)||t.setSelection(i)}else super.replace(t,n)}toJSON(){return{type:"all"}}static fromJSON(t){return new qe(t)}map(t){return new qe(t)}eq(t){return t instanceof qe}getBookmark(){return Nl}};x.jsonID("all",tt);var Nl={map(){return this},resolve(e){return new tt(e)}};function Lt(e,t,n,i,o,s=!1){if(t.inlineContent)return C.create(e,n);for(let r=i-(o>0?0:1);o>0?r<t.childCount:r>=0;r+=o){let l=t.child(r);if(l.isAtom){if(!s&&k.isSelectable(l))return k.create(e,n-(o<0?l.nodeSize:0))}else{let a=Lt(e,l,n+o,o<0?l.childCount:0,o,s);if(a)return a}n+=l.nodeSize*o}return null}function $i(e,t,n){let i=e.steps.length-1;if(i<t)return;let o=e.steps[i];if(!(o instanceof X||o instanceof nt))return;let s=e.mapping.maps[i],r;s.forEach((l,a,h,c)=>{r==null&&(r=c)}),e.setSelection(x.near(e.doc.resolve(r),n))}var Vi=1,Be=2,Fi=4,hs=class extends ss{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|Vi)&~Be,this.storedMarks=null,this}get selectionSet(){return(this.updated&Vi)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Be,this}ensureMarks(e){return M.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&Be)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~Be,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||M.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let i=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(n==null&&(n=t),!e)return this.deleteRange(t,n);let o=this.storedMarks;if(!o){let s=this.doc.resolve(t);o=n==t?s.marks():s.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,i.text(e,o)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(x.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=Fi,this}get scrolledIntoView(){return(this.updated&Fi)>0}};function Li(e,t){return!t||!e?e:e.bind(t)}var ae=class{constructor(e,t,n){this.name=e,this.init=Li(t.init,n),this.apply=Li(t.apply,n)}},Dl=[new ae("doc",{init(e){return e.doc||e.schema.topNodeType.createAndFill()},apply(e){return e.doc}}),new ae("selection",{init(e,t){return e.selection||x.atStart(t.doc)},apply(e){return e.selection}}),new ae("storedMarks",{init(e){return e.storedMarks||null},apply(e,t,n,i){return i.selection.$cursor?e.storedMarks:null}}),new ae("scrollToSelection",{init(){return 0},apply(e,t){return e.scrolledIntoView?t+1:t}})],cn=class{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Dl.slice(),t&&t.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 ae(n.key,n.spec.state,n))})}},Tl=class he{constructor(t){this.config=t}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(t){return this.applyTransaction(t).state}filterTransaction(t,n=-1){for(let i=0;i<this.config.plugins.length;i++)if(i!=n){let o=this.config.plugins[i];if(o.spec.filterTransaction&&!o.spec.filterTransaction.call(o,t,this))return!1}return!0}applyTransaction(t){if(!this.filterTransaction(t))return{state:this,transactions:[]};let n=[t],i=this.applyInner(t),o=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=o?o[r].n:0,h=o?o[r].state:this,c=a<n.length&&l.spec.appendTransaction.call(l,a?n.slice(a):n,h,i);if(c&&i.filterTransaction(c,r)){if(c.setMeta("appendedTransaction",t),!o){o=[];for(let d=0;d<this.config.plugins.length;d++)o.push(d<r?{state:i,n:n.length}:{state:this,n:0})}n.push(c),i=i.applyInner(c),s=!0}o&&(o[r]={state:i,n:n.length})}}if(!s)return{state:i,transactions:n}}}applyInner(t){if(!t.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new he(this.config),i=this.config.fields;for(let o=0;o<i.length;o++){let s=i[o];n[s.name]=s.apply(t,this[s.name],this,n)}return n}get tr(){return new hs(this)}static create(t){let n=new cn(t.doc?t.doc.type.schema:t.schema,t.plugins),i=new he(n);for(let o=0;o<n.fields.length;o++)i[n.fields[o].name]=n.fields[o].init(t,i);return i}reconfigure(t){let n=new cn(this.schema,t.plugins),i=n.fields,o=new he(n);for(let s=0;s<i.length;s++){let r=i[s].name;o[r]=this.hasOwnProperty(r)?this[r]:i[s].init(t,o)}return o}toJSON(t){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(i=>i.toJSON())),t&&typeof t=="object")for(let i in t){if(i=="doc"||i=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let o=t[i],s=o.spec.state;s&&s.toJSON&&(n[i]=s.toJSON.call(o,this[o.key]))}return n}static fromJSON(t,n,i){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!t.schema)throw new RangeError("Required config field 'schema' missing");let o=new cn(t.schema,t.plugins),s=new he(o);return o.fields.forEach(r=>{if(r.name=="doc")s.doc=wt.fromJSON(t.schema,n.doc);else if(r.name=="selection")s.selection=x.fromJSON(s.doc,n.selection);else if(r.name=="storedMarks")n.storedMarks&&(s.storedMarks=n.storedMarks.map(t.schema.markFromJSON));else{if(i)for(let l in i){let a=i[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,t,n[l],s);return}}s[r.name]=r.init(t,s)}}),s}};function cs(e,t,n){for(let i in e){let o=e[i];o instanceof Function?o=o.bind(t):i=="handleDOMEvents"&&(o=cs(o,t,{})),n[i]=o}return n}var Qt=class{constructor(e){this.spec=e,this.props={},e.props&&cs(e.props,this,this.props),this.key=e.key?e.key.key:ds("plugin")}getState(e){return e[this.key]}},dn=Object.create(null);function ds(e){return e in dn?e+"$"+ ++dn[e]:(dn[e]=0,e+"$")}var ni=class{constructor(e="key"){this.key=ds(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}},El={};ot(El,{Decoration:()=>St,DecorationSet:()=>Y,EditorView:()=>_s,__endComposition:()=>uh,__parseFromClipboard:()=>fh});var A=function(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t},Ut=function(e){let t=e.assignedSlot||e.parentNode;return t&&t.nodeType==11?t.host:t},In=null,rt=function(e,t,n){let i=In||(In=document.createRange());return i.setEnd(e,n??e.nodeValue.length),i.setStart(e,t||0),i},Al=function(){In=null},It=function(e,t,n,i){return n&&(Ji(e,t,n,i,-1)||Ji(e,t,n,i,1))},Rl=/^(img|br|input|textarea|hr)$/i;function Ji(e,t,n,i,o){for(var s;;){if(e==n&&t==i)return!0;if(t==(o<0?0:$(e))){let r=e.parentNode;if(!r||!v(r)||De(e)||Rl.test(e.nodeName)||e.contentEditable=="false")return!1;t=A(e)+(o<0?0:1),e=r}else if(v(e)){let r=e.childNodes[t+(o<0?-1:0)];if(v(r)&&r.contentEditable=="false")if(!((s=r.pmViewDesc)===null||s===void 0)&&s.ignoreForSelection)t+=o;else return!1;else e=r,t=o<0?$(e):0}else return!1}}function $(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function v(e){return e.nodeType==1}function T(e){return e.nodeType==3}function Pt(e,t){return t?e.contains(v(t)?t:t.parentNode):!1}function Il(e,t){for(;;){if(T(e)&&t)return e;if(v(e)&&t>0){if(e.contentEditable=="false")return null;e=e.childNodes[t-1],t=$(e)}else if(e.parentNode&&!De(e))t=A(e),e=e.parentNode;else return null}}function Pl(e,t){for(;;){if(T(e)&&t<e.nodeValue.length)return e;if(v(e)&&t<e.childNodes.length){if(e.contentEditable=="false")return null;e=e.childNodes[t],t=0}else if(e.parentNode&&!De(e))t=A(e)+1,e=e.parentNode;else return null}}function zl(e,t,n){for(let i=t==0,o=t==$(e);i||o;){if(e==n)return!0;let s=A(e);if(e=e.parentNode,!e)return!1;i=i&&s==0,o=o&&s==$(e)}}function De(e){let t;for(let n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}var en=function(e){return e.focusNode&&It(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function Mt(e,t){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}function Bl(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}function $l(e,t,n){if(e.caretPositionFromPoint)try{let i=e.caretPositionFromPoint(t,n);if(i)return{node:i.offsetNode,offset:Math.min($(i.offsetNode),i.offset)}}catch{}if(e.caretRangeFromPoint){let i=e.caretRangeFromPoint(t,n);if(i)return{node:i.startContainer,offset:Math.min($(i.startContainer),i.startOffset)}}}var it=typeof navigator<"u"?navigator:null,Wi=typeof document<"u"?document:null,xt=it&&it.userAgent||"",Pn=/Edge\/(\d+)/.exec(xt),ps=/MSIE \d/.exec(xt),zn=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(xt),K=!!(ps||zn||Pn),vt=ps?document.documentMode:zn?+zn[1]:Pn?+Pn[1]:0,H=!K&&/gecko\/(\d+)/i.test(xt);H&&+(/Firefox\/(\d+)/.exec(xt)||[0,0])[1];var Bn=!K&&/Chrome\/(\d+)/.exec(xt),R=!!Bn,fs=Bn?+Bn[1]:0,F=!K&&!!it&&/Apple Computer/.test(it.vendor),Gt=F&&(/Mobile\/\w+/.test(xt)||!!it&&it.maxTouchPoints>2),U=Gt||(it?/Mac/.test(it.platform):!1),us=it?/Win/.test(it.platform):!1,lt=/Android \d/.test(xt),nn=!!Wi&&"webkitFontSmoothing"in Wi.documentElement.style,Vl=nn?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Fl(e){let t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function st(e,t){return typeof e=="number"?e:e[t]}function Ll(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,i=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*i}}function qi(e,t,n){if(!$n(t)&&t.left==0)return;let i=e.someProp("scrollThreshold")||0,o=e.someProp("scrollMargin")||5,s=e.dom.ownerDocument;for(let r=n||e.dom;r;){if(!v(r)){r=Ut(r);continue}let l=r==s.body,a=l?Fl(s):Ll(r),h=0,c=0;if(t.top<a.top+st(i,"top")?c=-(a.top-t.top+st(o,"top")):t.bottom>a.bottom-st(i,"bottom")&&(c=t.bottom-t.top>a.bottom-a.top?t.top+st(o,"top")-a.top:t.bottom-a.bottom+st(o,"bottom")),t.left<a.left+st(i,"left")?h=-(a.left-t.left+st(o,"left")):t.right>a.right-st(i,"right")&&(h=t.right-a.right+st(o,"right")),h||c)if(l)s.defaultView.scrollBy(h,c);else{let p=r.scrollLeft,u=r.scrollTop;c&&(r.scrollTop+=c),h&&(r.scrollLeft+=h);let f=r.scrollLeft-p,m=r.scrollTop-u;t={left:t.left-f,top:t.top-m,right:t.right-f,bottom:t.bottom-m}}let d=l?"fixed":getComputedStyle(r).position;if(/^(fixed|sticky)$/.test(d))break;r=d=="absolute"?r.offsetParent:Ut(r)}}function Jl(e){let t=e.dom.getBoundingClientRect(),n=Math.max(0,t.top),i,o;for(let s=(t.left+t.right)/2,r=n+1;r<Math.min(innerHeight,t.bottom);r+=5){let l=e.root.elementFromPoint(s,r);if(!l||l==e.dom||!e.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=n-20){i=l,o=a.top;break}}return{refDOM:i,refTop:o,stack:ms(e.dom)}}function ms(e){let t=[],n=e.ownerDocument;for(let i=e;i&&(t.push({dom:i,top:i.scrollTop,left:i.scrollLeft}),e!=n);i=Ut(i));return t}function Wl({refDOM:e,refTop:t,stack:n}){let i=e?e.getBoundingClientRect().top:0;gs(n,i==0?0:i-t)}function gs(e,t){for(let n=0;n<e.length;n++){let{dom:i,top:o,left:s}=e[n];i.scrollTop!=o+t&&(i.scrollTop=o+t),i.scrollLeft!=s&&(i.scrollLeft=s)}}var Bt=null;function ql(e){if(e.setActive)return e.setActive();if(Bt)return e.focus(Bt);let t=ms(e);e.focus(Bt==null?{get preventScroll(){return Bt={preventScroll:!0},!0}}:void 0),Bt||(Bt=!1,gs(t,0))}function ys(e,t){let n,i=2e8,o,s=0,r=t.top,l=t.top,a,h;for(let c=e.firstChild,d=0;c;c=c.nextSibling,d++){let p;if(v(c))p=c.getClientRects();else if(T(c))p=rt(c).getClientRects();else continue;for(let u=0;u<p.length;u++){let f=p[u];if(f.top<=r&&f.bottom>=l){r=Math.max(f.bottom,r),l=Math.min(f.top,l);let m=f.left>t.left?f.left-t.left:f.right<t.left?t.left-f.right:0;if(m<i){n=c,i=m,o=m&&T(n)?{left:f.right<t.left?f.right:f.left,top:t.top}:t,v(c)&&m&&(s=d+(t.left>=(f.left+f.right)/2?1:0));continue}}else f.top>t.top&&!a&&f.left<=t.left&&f.right>=t.left&&(a=c,h={left:Math.max(f.left,Math.min(f.right,t.left)),top:f.top});!n&&(t.left>=f.right&&t.top>=f.top||t.left>=f.left&&t.top>=f.bottom)&&(s=d+1)}}return!n&&a&&(n=a,o=h,i=0),n&&T(n)?jl(n,o):!n||i?{node:e,offset:s}:ys(n,o)}function jl(e,t){let n=e.nodeValue.length,i=document.createRange(),o;for(let s=0;s<n;s++){i.setEnd(e,s+1),i.setStart(e,s);let r=ft(i,1);if(r.top!=r.bottom&&ii(t,r)){o={node:e,offset:s+(t.left>=(r.left+r.right)/2?1:0)};break}}return i.detach(),o||{node:e,offset:0}}function ii(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function Kl(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}function Hl(e,t,n){let{node:i,offset:o}=ys(t,n),s=-1;if(v(i)&&!i.firstChild){let r=i.getBoundingClientRect();s=r.left!=r.right&&n.left>(r.left+r.right)/2?1:-1}return e.docView.posFromDOM(i,o,s)}function Ul(e,t,n,i){let o=-1;for(let s=t,r=!1;s!=e.dom;){let l=e.docView.nearestDesc(s,!0),a;if(!l)return null;if(v(l.dom)&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!r&&a.left>i.left||a.top>i.top?o=l.posBefore:(!r&&a.right<i.left||a.bottom<i.top)&&(o=l.posAfter),r=!0),!l.contentDOM&&o<0&&!l.node.isText))return(l.node.isBlock?i.top<(a.top+a.bottom)/2:i.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;s=l.dom.parentNode}return o>-1?o:e.docView.posFromDOM(t,n,-1)}function ws(e,t,n){let i=e.childNodes.length;if(i&&n.top<n.bottom)for(let o=Math.max(0,Math.min(i-1,Math.floor(i*(t.top-n.top)/(n.bottom-n.top))-2)),s=o;;){let r=e.childNodes[s];if(v(r)){let l=r.getClientRects();for(let a=0;a<l.length;a++){let h=l[a];if(ii(t,h))return ws(r,t,h)}}if((s=(s+1)%i)==o)break}return e}function Gl(e,t){let n=e.dom.ownerDocument,i,o=0,s=$l(n,t.left,t.top);s&&({node:i,offset:o}=s);let r=(e.root.elementFromPoint?e.root:n).elementFromPoint(t.left,t.top),l;if(!r||!e.dom.contains(r)){let h=e.dom.getBoundingClientRect();if(!ii(t,h)||(r=ws(e.dom,t,h),!r))return null}if(F)for(let h=r;i&&h;h=Ut(h))h.draggable&&(i=void 0);if(r=Kl(r,t),i){if(H&&v(i)&&(o=Math.min(o,i.childNodes.length),o<i.childNodes.length)){let c=i.childNodes[o],d;c.nodeName=="IMG"&&(d=c.getBoundingClientRect()).right<=t.left&&d.bottom>t.top&&o++}let h;nn&&o&&v(i)&&v(h=i.childNodes[o-1])&&h.contentEditable=="false"&&h.getBoundingClientRect().top>=t.top&&o--,i==e.dom&&o==i.childNodes.length-1&&v(i.lastChild)&&t.top>i.lastChild.getBoundingClientRect().bottom?l=e.state.doc.content.size:(o==0||!v(i)||i.childNodes[o-1].nodeName!="BR")&&(l=Ul(e,i,o,t))}l==null&&(l=Hl(e,r,t));let a=e.docView.nearestDesc(r,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function $n(e){return e.top<e.bottom||e.left<e.right}function ft(e,t){let n=e.getClientRects();if(n.length){let i=n[t<0?0:n.length-1];if($n(i))return i}return Array.prototype.find.call(n,$n)||e.getBoundingClientRect()}var Yl=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function vs(e,t,n){let{node:i,offset:o,atom:s}=e.docView.domFromPos(t,n<0?-1:1),r=nn||H;if(T(i))if(r&&(Yl.test(i.nodeValue)||(n<0?!o:o==i.nodeValue.length))){let l=ft(rt(i,o,o),n);if(H&&o&&/\s/.test(i.nodeValue[o-1])&&o<i.nodeValue.length){let a=ft(rt(i,o-1,o-1),-1);if(a.top==l.top){let h=ft(rt(i,o,o+1),-1);if(h.top!=l.top)return Zt(h,h.left<a.left)}}return l}else{let l=o,a=o,h=n<0?1:-1;return n<0&&!o?(a++,h=-1):n>=0&&o==i.nodeValue.length?(l--,h=1):n<0?l--:a++,Zt(ft(rt(i,l,a),h),h<0)}if(!e.state.doc.resolve(t-(s||0)).parent.inlineContent){if(s==null&&o&&(n<0||o==$(i))){let l=i.childNodes[o-1];if(v(l))return pn(l.getBoundingClientRect(),!1)}if(s==null&&o<$(i)){let l=i.childNodes[o];if(v(l))return pn(l.getBoundingClientRect(),!0)}return pn(i.getBoundingClientRect(),n>=0)}if(s==null&&o&&(n<0||o==$(i))){let l=i.childNodes[o-1],a=T(l)?rt(l,$(l)-(r?0:1)):v(l)&&(l.nodeName!="BR"||!l.nextSibling)?l:null;if(a)return Zt(ft(a,1),!1)}if(s==null&&o<$(i)){let l=i.childNodes[o];for(;l.pmViewDesc&&l.pmViewDesc.ignoreForCoords;)l=l.nextSibling;let a=l?T(l)?rt(l,0,r?0:1):v(l)?l:null:null;if(a)return Zt(ft(a,-1),!0)}return Zt(ft(T(i)?rt(i):i,-n),n>=0)}function Zt(e,t){if(e.width==0)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function pn(e,t){if(e.height==0)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function bs(e,t,n){let i=e.state,o=e.root.activeElement;i!=t&&e.updateState(t),o!=e.dom&&e.focus();try{return n()}finally{i!=t&&e.updateState(i),o!=e.dom&&o&&o.focus()}}function Xl(e,t,n){let i=t.selection,o=n=="up"?i.$from:i.$to;return bs(e,t,()=>{let{node:s}=e.docView.domFromPos(o.pos,n=="up"?-1:1);for(;;){let l=e.docView.nearestDesc(s,!0);if(!l)break;if(l.node.isBlock){s=l.contentDOM||l.dom;break}s=l.dom.parentNode}let r=vs(e,o.pos,1);for(let l=s.firstChild;l;l=l.nextSibling){let a;if(v(l))a=l.getClientRects();else if(T(l))a=rt(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 Ql=/[\u0590-\u08ac]/;function Zl(e,t,n){let{$head:i}=t.selection;if(!i.parent.isTextblock)return!1;let o=i.parentOffset,s=!o,r=o==i.parent.content.size,l=e.domSelection();return l?!Ql.test(i.parent.textContent)||!l.modify?n=="left"||n=="backward"?s:r:bs(e,t,()=>{let{focusNode:a,focusOffset:h,anchorNode:c,anchorOffset:d}=e.domSelectionRange(),p=l.caretBidiLevel;l.modify("move",n,"character");let u=i.depth?e.docView.domAfterPos(i.before()):e.dom,{focusNode:f,focusOffset:m}=e.domSelectionRange(),g=f&&!Pt(u,f)||a==f&&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}):i.pos==i.start()||i.pos==i.end()}var ji=null,Ki=null,Hi=!1;function _l(e,t,n){return ji==t&&Ki==n?Hi:(ji=t,Ki=n,Hi=n=="up"||n=="down"?Xl(e,t,n):Zl(e,t,n))}var G=0,Ui=1,Ot=2,Q=3,Te=class{constructor(e,t,n,i){this.parent=e,this.children=t,this.dom=n,this.contentDOM=i,this.dirty=G,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(e){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,n=this.posAtStart;;t++){let i=this.children[t];if(i==e)return n;n+=i.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,n){if(this.contentDOM&&Pt(this.contentDOM,e))if(n<0){let o,s;if(e==this.contentDOM)o=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.previousSibling}for(;o&&!((s=o.pmViewDesc)&&s.parent==this);)o=o.previousSibling;return o?this.posBeforeChild(s)+s.size:this.posAtStart}else{let o,s;if(e==this.contentDOM)o=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.nextSibling}for(;o&&!((s=o.pmViewDesc)&&s.parent==this);)o=o.nextSibling;return o?this.posBeforeChild(s):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=t>A(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=!!(e.compareDocumentPosition(this.contentDOM)&4);else if(this.dom.firstChild){if(t==0)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!1;break}if(o.previousSibling)break}if(i==null&&t==e.childNodes.length)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!0;break}if(o.nextSibling)break}}return i??n>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,i=e;i;i=i.parentNode){let o=this.getDesc(i),s;if(o&&(!t||o.node))if(n&&(s=o.nodeDOM)&&!(v(s)?Pt(s,e):s==e))n=!1;else return o}}getDesc(e){let t=e.pmViewDesc;for(let n=t;n;n=n.parent)if(n==this)return t}posFromDOM(e,t,n){for(let i=e;i;i=i.parentNode){let o=this.getDesc(i);if(o)return o.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let i=this.children[t],o=n+i.size;if(n==e&&o!=n){for(;!i.border&&i.children.length;)for(let s=0;s<i.children.length;s++){let r=i.children[s];if(r.size){i=r;break}}return i}if(e<o)return i.descAt(e-n-i.border);n=o}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,i=0;for(let o=0;n<this.children.length;n++){let s=this.children[n],r=o+s.size;if(r>e){i=e-o;break}o=r}if(i)return this.children[n].domFromPos(i-this.children[n].border,t);for(;n>0;n--){let o=this.children[n-1];if(o.size||!(o instanceof Ms||o instanceof ks&&o.side>=0))break}if(t<=0){let o,s=!0;for(;o=n?this.children[n-1]:null,!(!o||o.dom.parentNode==this.contentDOM);n--,s=!1);return o&&t&&s&&!o.border&&!o.domAtom?o.domFromPos(o.size,t):{node:this.contentDOM,offset:o?A(o.dom)+1:0}}else{let o,s=!0;for(;o=n<this.children.length?this.children[n]:null,!(!o||o.dom.parentNode==this.contentDOM);n++,s=!1);return o&&s&&!o.border&&!o.domAtom?o.domFromPos(0,t):{node:this.contentDOM,offset:o?A(o.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,n=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let i=-1,o=-1;for(let s=n,r=0;;r++){let l=this.children[r],a=s+l.size;if(i==-1&&e<=a){let h=s+l.border;if(e>=h&&t<=a-l.border&&l.node&&l.contentDOM&&this.contentDOM.contains(l.contentDOM))return l.parseRange(e,t,h);e=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)){i=A(d.dom)+1;break}e-=d.size}i==-1&&(i=0)}if(i>-1&&(a>t||r==this.children.length-1)){t=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)){o=A(c.dom);break}t+=c.size}o==-1&&(o=this.contentDOM.childNodes.length);break}s=a}return{node:this.contentDOM,from:e,to:t,fromOffset:i,toOffset:o}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:n}=this.domFromPos(e,0);if(!v(t)||n==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[n]}setSelection(e,t,n,i=!1){let o=Math.min(e,t),s=Math.max(e,t);for(let p=0,u=0;p<this.children.length;p++){let f=this.children[p],m=u+f.size;if(o>u&&s<m)return f.setSelection(e-u-f.border,t-u-f.border,n,i);u=m}let r=this.domFromPos(e,e?-1:1),l=t==e?r:this.domFromPos(t,t?-1:1),a=n.root.getSelection(),h=n.domSelectionRange(),c=!1;if((H||F)&&e==t){let{node:p,offset:u}=r;if(T(p)){if(c=!!(u&&p.nodeValue[u-1]==`
|
|
6
|
+
`),c&&u==p.nodeValue.length)for(let f=p,m;f;f=f.parentNode){if(m=f.nextSibling){m.nodeName=="BR"&&(r=l={node:m.parentNode,offset:A(m)+1});break}let g=f.pmViewDesc;if(g&&g.node&&g.node.isBlock)break}}else{let f=p.childNodes[u-1];c=f&&(f.nodeName=="BR"||f.contentEditable=="false")}}if(H&&h.focusNode&&h.focusNode!=l.node&&v(h.focusNode)){let p=h.focusNode.childNodes[h.focusOffset];p&&p.contentEditable=="false"&&(i=!0)}if(!(i||c&&F)&&It(r.node,r.offset,h.anchorNode,h.anchorOffset)&&It(l.node,l.offset,h.focusNode,h.focusOffset))return;let d=!1;if((a.extend||e==t)&&!(c&&H)){a.collapse(r.node,r.offset);try{e!=t&&a.extend(l.node,l.offset),d=!0}catch{}}if(!d){if(e>t){let u=r;r=l,l=u}let p=document.createRange();p.setEnd(l.node,l.offset),p.setStart(r.node,r.offset),a.removeAllRanges(),a.addRange(p)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,i=0;i<this.children.length;i++){let o=this.children[i],s=n+o.size;if(n==s?e<=s&&t>=n:e<s&&t>n){let r=n+o.border,l=s-o.border;if(e>=r&&t<=l){this.dirty=e==n||t==s?Ot:Ui,e==r&&t==l&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=Q:o.markDirty(e-r,t-r);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?Ot:Q}n=s}this.dirty=Ot}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=e==1?Ot:Ui;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}},ks=class extends Te{constructor(e,t,n,i){let o,s=t.type.toDOM;if(typeof s=="function"&&(s=s(n,()=>{if(!o)return i;if(o.parent)return o.parent.posBeforeChild(o)})),!t.type.spec.raw){let r=v(s)?s:document.createElement("span");r!=s&&r.appendChild(s),r.hasAttribute("contenteditable")||(r.contentEditable="false"),r.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=t,this.widget=t,o=this}matchesWidget(e){return this.dirty==G&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}},ta=class extends Te{constructor(e,t,n,i){super(e,[],t,null),this.textDOM=n,this.text=i}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}},ue=class Vn extends Te{constructor(t,n,i,o,s){super(t,[],i,o),this.mark=n,this.spec=s}static create(t,n,i,o){let s=o.nodeViews[n.type.name],r=s&&s(n,o,i);return(!r||!r.dom)&&(r=Me.renderSpec(document,n.type.spec.toDOM(n,i),null,n.attrs)),new Vn(t,n,r.dom,r.contentDOM||r.dom,r)}parseRule(){return this.dirty&Q||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(t){return this.dirty!=Q&&this.mark.eq(t)}markDirty(t,n){if(super.markDirty(t,n),this.dirty!=G){let i=this.parent;for(;!i.node;)i=i.parent;i.dirty<this.dirty&&(i.dirty=this.dirty),this.dirty=G}}slice(t,n,i){let o=Vn.create(this.parent,this.mark,!0,i),s=this.children,r=this.size;n<r&&(s=Ln(s,n,r,i)),t>0&&(s=Ln(s,0,t,i));for(let l=0;l<s.length;l++)s[l].parent=o;return o.children=s,o}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},jt=class xs extends Te{constructor(t,n,i,o,s,r,l){super(t,[],s,r),this.node=n,this.outerDeco=i,this.innerDeco=o,this.nodeDOM=l}static create(t,n,i,o,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)},i,o),c=h&&h.dom,d=h&&h.contentDOM;if(n.isText){if(!c)c=document.createTextNode(n.text);else if(!T(c))throw new RangeError("Text must be rendered as a DOM text node")}else c||({dom:c,contentDOM:d}=Me.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=Ds(c,i,n),h?a=new ea(t,n,i,o,c,d||null,p,h):n.isText?new Ss(t,n,i,o,c,p):new xs(t,n,i,o,c,d||null,p)}parseRule(t){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 i=this.children.length-1;i>=0;i--){let o=this.children[i];if(this.dom.contains(o.dom.parentNode)){n.contentElement=o.dom.parentNode;break}}if(!n.contentElement){let i=t&&t.find(o=>v(o)&&t.indexOf(o.parentNode)<0&&this.dom.contains(o));i?n.contentElement=i:n.getContent=()=>y.empty}}return n}matchesNode(t,n,i){return this.dirty==G&&t.eq(this.node)&&Ye(n,this.outerDeco)&&i.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(t,n){let i=this.node.inlineContent,o=n,s=t.composing?this.localCompositionInfo(t,n):null,r=s&&s.pos>-1?s:null,l=s&&s.pos<0,a=new ia(this,r&&r.node,t),h=this.node.inlineContent,c=h&&this.node.isBlock;ra(this.node,this.innerDeco,(d,p,u)=>{d.spec.marks?a.syncToMarks(d.spec.marks,i,t,p):d.type.side>=0&&!u&&a.syncToMarks(p==this.node.childCount?M.none:this.node.child(p).marks,i,t,p),a.placeWidget(d,t,o)},(d,p,u,f)=>{a.syncToMarks(d.marks,i,t,f),c&&d.isAtom&&!d.isText&&a.addHackNode("IMG",a.top);let m;a.findNodeMatch(d,p,u,f)||l&&t.state.selection.from>o&&t.state.selection.to<o+d.nodeSize&&(m=a.findIndexWithChild(s.node))>-1&&a.updateNodeAt(d,p,u,m,t)||a.updateNextNode(d,p,u,t,f,o)||a.addNode(d,p,u,t,o),o+=d.nodeSize,h&&(c=d.isAtom&&!d.isText)}),a.syncToMarks([],i,t,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==Ot)&&(r&&this.protectLocalComposition(t,r),Os(this.contentDOM,this.children,t),Gt&&la(this.dom))}localCompositionInfo(t,n){let{from:i,to:o}=t.state.selection;if(!(t.state.selection instanceof C)||i<n||o>n+this.node.content.size)return null;let s=t.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let r=s.nodeValue,l=aa(this.node.content,r,i-n,o-n);return l<0?null:{node:s,pos:l,text:r}}else return{node:s,pos:-1,text:""}}protectLocalComposition(t,{node:n,pos:i,text:o}){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 ta(this,s,n,o);t.input.compositionNodes.push(r),this.children=Ln(this.children,i,i+o.length,t,r)}update(t,n,i,o){return this.dirty==Q||!t.sameMarkup(this.node)?!1:(this.updateInner(t,n,i,o),!0)}updateInner(t,n,i,o){this.updateOuterDeco(n),this.node=t,this.innerDeco=i,this.contentDOM&&this.updateChildren(o,this.posAtStart),this.dirty=G}updateOuterDeco(t){if(Ye(t,this.outerDeco))return;let n=!v(this.nodeDOM),i=this.dom;this.dom=Ns(this.dom,this.nodeDOM,Fn(this.outerDeco,this.node,n),Fn(t,this.node,n)),this.dom!=i&&(i.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=t}selectNode(){v(this.nodeDOM)&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){v(this.nodeDOM)&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}};function Gi(e,t,n,i,o){Ds(i,t,e);let s=new jt(void 0,e,t,n,i,i,i);return s.contentDOM&&s.updateChildren(o,0),s}var Ss=class Cs extends jt{constructor(t,n,i,o,s,r){super(t,n,i,o,s,null,r)}parseRule(){let t=this.nodeDOM.parentNode;for(;t&&t!=this.dom&&!t.pmIsDeco;)t=t.parentNode;return{skip:t||!0}}update(t,n,i,o){return this.dirty==Q||this.dirty!=G&&!this.inParent()||!t.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=G||t.text!=this.node.text)&&t.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=t.text,o.trackWrites==this.nodeDOM&&(o.trackWrites=null)),this.node=t,this.dirty=G,!0)}inParent(){let t=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==t)return!0;return!1}domFromPos(t){return{node:this.nodeDOM,offset:t}}localPosFromDOM(t,n,i){return t==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(t,n,i)}ignoreMutation(t){return t.type!="characterData"&&t.type!="selection"}slice(t,n,i){let o=this.node.cut(t,n),s=document.createTextNode(o.text);return new Cs(this.parent,o,this.outerDeco,this.innerDeco,s,s)}markDirty(t,n){super.markDirty(t,n),this.dom!=this.nodeDOM&&(t==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=Q)}get domAtom(){return!1}isText(t){return this.node.text==t}},Ms=class extends Te{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==G&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}},ea=class extends jt{constructor(e,t,n,i,o,s,r,l){super(e,t,n,i,o,s,r),this.spec=l}update(e,t,n,i){if(this.dirty==Q)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let o=this.spec.update(e,t,n);return o&&this.updateInner(e,t,n,i),o}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,n,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,i){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}};function Os(e,t,n){let i=e.firstChild,o=!1;for(let s=0;s<t.length;s++){let r=t[s],l=r.dom;if(l.parentNode==e){for(;l!=i;)i=Yi(i),o=!0;i=i.nextSibling}else o=!0,e.insertBefore(l,i);if(r instanceof ue){let a=i?i.previousSibling:e.lastChild;Os(r.contentDOM,r.children,n),i=a?a.nextSibling:e.firstChild}}for(;i;)i=Yi(i),o=!0;o&&n.trackWrites==e&&(n.trackWrites=null)}var me=function(e){e&&(this.nodeName=e)};me.prototype=Object.create(null);var Nt=[new me];function Fn(e,t,n){if(e.length==0)return Nt;let i=n?Nt[0]:new me,o=[i];for(let s=0;s<e.length;s++){let r=e[s].type.attrs;if(r){r.nodeName&&o.push(i=new me(r.nodeName));for(let l in r){let a=r[l];a!=null&&(n&&o.length==1&&o.push(i=new me(t.isInline?"span":"div")),l=="class"?i.class=(i.class?i.class+" ":"")+a:l=="style"?i.style=(i.style?i.style+";":"")+a:l!="nodeName"&&(i[l]=a))}}}return o}function Ns(e,t,n,i){if(n==Nt&&i==Nt)return t;let o=t;for(let s=0;s<i.length;s++){let r=i[s],l=n[s];if(s){let a;l&&l.nodeName==r.nodeName&&o!=e&&(a=o.parentNode)&&a.nodeName.toLowerCase()==r.nodeName||(a=document.createElement(r.nodeName),a.pmIsDeco=!0,a.appendChild(o),l=Nt[0]),o=a}na(o,l||Nt[0],r)}return o}function na(e,t,n){for(let i in t)i!="class"&&i!="style"&&i!="nodeName"&&!(i in n)&&e.removeAttribute(i);for(let i in n)i!="class"&&i!="style"&&i!="nodeName"&&n[i]!=t[i]&&e.setAttribute(i,n[i]);if(t.class!=n.class){let i=t.class?t.class.split(" ").filter(Boolean):[],o=n.class?n.class.split(" ").filter(Boolean):[];for(let s=0;s<i.length;s++)o.indexOf(i[s])==-1&&e.classList.remove(i[s]);for(let s=0;s<o.length;s++)i.indexOf(o[s])==-1&&e.classList.add(o[s]);e.classList.length==0&&e.removeAttribute("class")}if(t.style!=n.style){if(t.style){let i=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,o;for(;o=i.exec(t.style);)e.style.removeProperty(o[1])}n.style&&(e.style.cssText+=n.style)}}function Ds(e,t,n){return Ns(e,e,Nt,Fn(t,n,!v(e)))}function Ye(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].type.eq(t[n].type))return!1;return!0}function Yi(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}var ia=class{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=oa(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,n,i){let o=0,s=this.stack.length>>1,r=Math.min(s,e.length);for(;o<r&&(o==s-1?this.top:this.stack[o+1<<1]).matchesMark(e[o])&&e[o].type.spec.spanning!==!1;)o++;for(;o<s;)this.destroyRest(),this.top.dirty=G,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let l=-1,a=this.top.children.length;i<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(e[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 ue&&h.dirty!=Q&&h.mark.type==e[s].type&&h.spec.update&&!this.isLocked(h.dom)&&h.spec.update(e[s])&&(h.mark=e[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=ue.create(this.top,e[s],t,n);this.top.children.splice(this.index,0,h),this.top=h,this.changed=!0}this.index=0,s++}}findNodeMatch(e,t,n,i){let o=-1,s;if(i>=this.preMatch.index&&(s=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&s.matchesNode(e,t,n))o=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(e,t,n)&&!this.preMatch.matched.has(a)){o=r;break}}return o<0?!1:(this.destroyBetween(this.index,o),this.index++,!0)}updateNodeAt(e,t,n,i,o){let s=this.top.children[i];return s.dirty==Q&&s.dom==s.contentDOM&&(s.dirty=Ot),s.update(e,t,n,o)?(this.destroyBetween(this.index,i),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let n=e.pmViewDesc;if(n){for(let i=this.index;i<this.top.children.length;i++)if(this.top.children[i]==n)return i}return-1}e=t}}updateNextNode(e,t,n,i,o,s){for(let r=this.index;r<this.top.children.length;r++){let l=this.top.children[r];if(l instanceof jt){let a=this.preMatch.matched.get(l);if(a!=null&&a!=o)return!1;let h=l.dom,c,d=this.isLocked(h)&&!(e.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==e.text&&l.dirty!=Q&&Ye(t,l.outerDeco));if(!d&&l.update(e,t,n,i))return this.destroyBetween(this.index,r),l.dom!=h&&(this.changed=!0),this.index++,!0;if(!d&&(c=this.recreateWrapper(l,e,t,n,i,s)))return this.destroyBetween(this.index,r),this.top.children[this.index]=c,c.contentDOM&&(c.dirty=Ot,c.updateChildren(i,s+1),c.dirty=G),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,i,o,s){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Ye(n,e.outerDeco)||!i.eq(e.innerDeco))return null;let r=jt.create(this.top,t,n,i,o,s);if(r.contentDOM){r.children=e.children,e.children=[];for(let l of r.children)l.parent=r}return e.destroy(),r}addNode(e,t,n,i,o){let s=jt.create(this.top,e,t,n,i,o);s.contentDOM&&s.updateChildren(i,o+1),this.top.children.splice(this.index++,0,s),this.changed=!0}placeWidget(e,t,n){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(i&&i.matchesWidget(e)&&(e==i.widget||!i.widget.type.toDOM.parentNode))this.index++;else{let o=new ks(this.top,e,t,n);this.top.children.splice(this.index++,0,o),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof ue;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Ss)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((F||R)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let n=document.createElement(e);e=="IMG"&&(n.className="ProseMirror-separator",n.alt=""),e=="BR"&&(n.className="ProseMirror-trailingBreak");let i=new Ms(this.top,[],n,null);t!=this.top?t.children.push(i):t.children.splice(this.index++,0,i),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||v(e)&&e.contains(this.lock.parentNode))}};function oa(e,t){let n=t,i=n.children.length,o=e.childCount,s=new Map,r=[];t:for(;o>0;){let l;for(;;)if(i){let h=n.children[i-1];if(h instanceof ue)n=h,i=h.children.length;else{l=h,i--;break}}else{if(n==t)break t;i=n.parent.children.indexOf(n),n=n.parent}let a=l.node;if(a){if(a!=e.child(o-1))break;--o,s.set(l,o),r.push(l)}}return{index:o,matched:s,matches:r.reverse()}}function sa(e,t){return e.type.side-t.type.side}function ra(e,t,n,i){let o=t.locals(e),s=0;if(o.length==0){for(let h=0;h<e.childCount;h++){let c=e.child(h);i(c,o,t.forChild(s,c),h),s+=c.nodeSize}return}let r=0,l=[],a=null;for(let h=0;;){let c,d;for(;r<o.length&&o[r].to==s;){let g=o[r++];g.widget&&(c?(d||(d=[c])).push(g):c=g)}if(c)if(d){d.sort(sa);for(let g=0;g<d.length;g++)n(d[g],h,!!a)}else n(c,h,!!a);let p,u;if(a)u=-1,p=a,a=null;else if(h<e.childCount)u=h,p=e.child(h++);else break;for(let g=0;g<l.length;g++)l[g].to<=s&&l.splice(g--,1);for(;r<o.length&&o[r].from<=s&&o[r].to>s;)l.push(o[r++]);let f=s+p.nodeSize;if(p.isText){let g=f;r<o.length&&o[r].from<g&&(g=o[r].from);for(let b=0;b<l.length;b++)l[b].to<g&&(g=l[b].to);g<f&&(a=p.cut(g-s),p=p.cut(0,g-s),f=g,u=-1)}else for(;r<o.length&&o[r].to<f;)r++;let m=p.isInline&&!p.isLeaf?l.filter(g=>!g.inline):l.slice();i(p,m,t.forChild(s,p),u),s=f}}function la(e){if(e.nodeName=="UL"||e.nodeName=="OL"){let t=e.style.cssText;e.style.cssText=t+"; list-style: square !important",window.getComputedStyle(e).listStyle,e.style.cssText=t}}function aa(e,t,n,i){for(let o=0,s=0;o<e.childCount&&s<=i;){let r=e.child(o++),l=s;if(s+=r.nodeSize,!r.isText)continue;let a=r.text;for(;o<e.childCount;){let h=e.child(o++);if(s+=h.nodeSize,!h.isText)break;a+=h.text}if(s>=n){if(s>=i&&a.slice(i-t.length-l,i-l)==t)return i-t.length;let h=l<i?a.lastIndexOf(t,i-l-1):-1;if(h>=0&&h+t.length+l>=n)return l+h;if(n==i&&a.length>=i+t.length-l&&a.slice(i-l,i-l+t.length)==t)return i}}return-1}function Ln(e,t,n,i,o){let s=[];for(let r=0,l=0;r<e.length;r++){let a=e[r],h=l,c=l+=a.size;h>=n||c<=t?s.push(a):(h<t&&s.push(a.slice(0,t-h,i)),o&&(s.push(o),o=void 0),c>n&&s.push(a.slice(n-h,a.size,i)))}return s}function oi(e,t=null){let n=e.domSelectionRange(),i=e.state.doc;if(!n.focusNode)return null;let o=e.docView.nearestDesc(n.focusNode),s=o&&o.size==0,r=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(r<0)return null;let l=i.resolve(r),a,h;if(en(n)){for(a=r;o&&!o.node;)o=o.parent;if(o&&o.node.isAtom&&k.isSelectable(o.node)&&o.parent&&!(o.node.isInline&&zl(n.focusNode,n.focusOffset,o.dom))){let d=o.posBefore;h=new k(r==d?l:i.resolve(d))}else if(H&&t=="key"&&r>e.state.selection.to&&v(n.focusNode)&&n.focusOffset==n.focusNode.childNodes.length&&o&&o.posAtStart>e.state.selection.to)for(let d=n.focusNode;;d=d.parentNode){if(getComputedStyle(d).overflow!="visible"){h=x.findFrom(i.resolve(o.posAtStart),1);break}if(d==o.dom||d.nextSibling||!d.parentNode||!v(d.parentNode))break}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let d=r,p=r;for(let u=0;u<n.rangeCount;u++){let f=n.getRangeAt(u);d=Math.min(d,e.docView.posFromDOM(f.startContainer,f.startOffset,1)),p=Math.max(p,e.docView.posFromDOM(f.endContainer,f.endOffset,-1))}if(d<0)return null;[a,r]=p==e.state.selection.anchor?[p,d]:[d,p],l=i.resolve(r)}else a=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(a<0)return null}let c=i.resolve(a);if(!h){let d=t=="pointer"||e.state.selection.head<l.pos&&!s?1:-1;h=si(e,c,l,d)}return h}function Ts(e){return e.editable?e.hasFocus():As(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function ht(e,t=!1){let n=e.state.selection;if(Es(e,n),!Ts(e))return;let i=e.input.mouseDown;if(!t&&R&&i){let o=e.domSelectionRange(),s=e.domObserver.currentSelection;if(o.anchorNode&&s.anchorNode&&It(o.anchorNode,o.anchorOffset,s.anchorNode,s.anchorOffset)&&i.delaySelUpdate()){e.domObserver.setCurSelection();return}}if(e.domObserver.disconnectSelection(),e.cursorWrapper)ca(e);else{let{anchor:o,head:s}=n,r,l;Xi&&!(n instanceof C)&&(n.$from.parent.inlineContent||(r=Qi(e,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(l=Qi(e,n.to))),e.docView.setSelection(o,s,e,t),Xi&&(r&&Zi(r),l&&Zi(l)),n.visible?e.dom.classList.remove("ProseMirror-hideselection"):(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&ha(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}var Xi=F||R&&fs<63;function Qi(e,t){let{node:n,offset:i}=e.docView.domFromPos(t,0),o=i<n.childNodes.length?n.childNodes[i]:null,s=i?n.childNodes[i-1]:null;if(F&&o&&o.contentEditable=="false")return fn(o);if((!o||o.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(o)return fn(o);if(s)return fn(s)}}function fn(e){return e.contentEditable="true",F&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function Zi(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function ha(e){let t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.input.hideSelectionGuard);let n=e.domSelectionRange(),i=n.anchorNode,o=n.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=()=>{(n.anchorNode!=i||n.anchorOffset!=o)&&(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout(()=>{(!Ts(e)||e.state.selection.visible)&&e.dom.classList.remove("ProseMirror-hideselection")},20))})}function ca(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,i=n.nodeName=="IMG";i?t.collapse(n.parentNode,A(n)+1):t.collapse(n,0),!i&&!e.state.selection.visible&&K&&vt<=11&&(n.disabled=!0,n.disabled=!1)}function Es(e,t){if(t instanceof k){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(_i(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else _i(e)}function _i(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function si(e,t,n,i){return e.someProp("createSelectionBetween",o=>o(e,t,n))||C.between(t,n,i)}function to(e){return e.editable&&!e.hasFocus()?!1:As(e)}function As(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return Pt(e.dom,t.anchorNode)&&(e.editable||Pt(e.dom,t.focusNode))}catch{return!1}}function da(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return It(t.node,t.offset,n.anchorNode,n.anchorOffset)}function Jn(e,t){let{$anchor:n,$head:i}=e.selection,o=t>0?n.max(i):n.min(i),s=o.parent.inlineContent?o.depth?e.doc.resolve(t>0?o.after():o.before()):null:o;return s&&x.findFrom(s,t)}function gt(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function eo(e,t,n){let i=e.state.selection;if(i instanceof C)if(n.indexOf("s")>-1){let{$head:o}=i,s=o.textOffset?null:t<0?o.nodeBefore:o.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let r=e.state.doc.resolve(o.pos+s.nodeSize*(t<0?-1:1));return gt(e,new C(i.$anchor,r))}else if(i.empty){if(e.endOfTextblock(t>0?"forward":"backward")){let o=Jn(e.state,t);return o&&o instanceof k?gt(e,o):!1}else if(!(U&&n.indexOf("m")>-1)){let o=i.$head,s=o.textOffset?null:t<0?o.nodeBefore:o.nodeAfter,r;if(!s||s.isText)return!1;let l=t<0?o.pos-s.nodeSize:o.pos;return s.isAtom||(r=e.docView.descAt(l))&&!r.contentDOM?k.isSelectable(s)?gt(e,new k(t<0?e.state.doc.resolve(o.pos-s.nodeSize):o)):gt(e,new C(e.state.doc.resolve(t<0?l:l+s.nodeSize))):!1}}else return!1;else{if(i instanceof k&&i.node.isInline)return gt(e,new C(t>0?i.$to:i.$from));{let o=Jn(e.state,t);return o?gt(e,o):!1}}}function ge(e,t){let n=e.pmViewDesc;return n?n.size==0&&(t<0||e.nextSibling||e.nodeName!="BR"):v(e)&&e.contentEditable=="false"}function $t(e,t){return t<0?pa(e):fa(e)}function pa(e){let t=e.domSelectionRange(),n=t.focusNode,i=t.focusOffset;if(!n)return;let o,s,r=!1;for(H&&v(n)&&i<$(n)&&ge(n.childNodes[i],-1)&&(r=!0);;)if(i>0){if(!v(n))break;let l=n.childNodes[i-1];if(ge(l,-1))o=n,s=--i;else if(T(l))n=l,i=n.nodeValue.length;else break}else{if(Rs(n))break;{let l=n.previousSibling;for(;l&&ge(l,-1);)o=n.parentNode,s=A(l),l=l.previousSibling;if(l)n=l,i=$(n);else{if(n=n.parentNode,n==e.dom)break;i=0}}}r?Wn(e,n,i):o&&Wn(e,o,s)}function fa(e){let t=e.domSelectionRange(),n=t.focusNode,i=t.focusOffset;if(!n)return;let o=$(n),s,r;for(;;)if(i<o){if(!v(n))break;let l=n.childNodes[i];if(ge(l,1))s=n,r=++i;else break}else{if(Rs(n))break;{let l=n.nextSibling;for(;l&&ge(l,1);)s=l.parentNode,r=A(l)+1,l=l.nextSibling;if(l)n=l,i=0,o=$(n);else{if(n=n.parentNode,n==e.dom)break;i=o=0}}}s&&Wn(e,s,r)}function Rs(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function ua(e,t){for(;e&&t==e.childNodes.length&&!De(e);)t=A(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){let n=e.childNodes[t];if(T(n))return n;if(v(n)&&n.contentEditable=="false")break;e=n,t=0}}function ma(e,t){for(;e&&!t&&!De(e);)t=A(e),e=e.parentNode;for(;e&&t;){let n=e.childNodes[t-1];if(T(n))return n;if(v(n)&&n.contentEditable=="false")break;e=n,t=e.childNodes.length}}function Wn(e,t,n){if(!T(t)){let s,r;(r=ua(t,n))?(t=r,n=0):(s=ma(t,n))&&(t=s,n=s.nodeValue.length)}let i=e.domSelection();if(!i)return;if(en(i)){let s=document.createRange();s.setEnd(t,n),s.setStart(t,n),i.removeAllRanges(),i.addRange(s)}else i.extend&&i.extend(t,n);e.domObserver.setCurSelection();let{state:o}=e;setTimeout(()=>{e.state==o&&ht(e)},50)}function no(e,t){let n=e.state.doc.resolve(t);if(!(R||us)&&n.parent.inlineContent){let i=e.coordsAtPos(t);if(t>n.start()){let o=e.coordsAtPos(t-1),s=(o.top+o.bottom)/2;if(s>i.top&&s<i.bottom&&Math.abs(o.left-i.left)>1)return o.left<i.left?"ltr":"rtl"}if(t<n.end()){let o=e.coordsAtPos(t+1),s=(o.top+o.bottom)/2;if(s>i.top&&s<i.bottom&&Math.abs(o.left-i.left)>1)return o.left>i.left?"ltr":"rtl"}}return getComputedStyle(e.dom).direction=="rtl"?"rtl":"ltr"}function io(e,t,n){let i=e.state.selection;if(i instanceof C&&!i.empty||n.indexOf("s")>-1||U&&n.indexOf("m")>-1)return!1;let{$from:o,$to:s}=i;if(!o.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let r=Jn(e.state,t);if(r&&r instanceof k)return gt(e,r)}if(!o.parent.inlineContent){let r=t<0?o:s,l=i instanceof tt?x.near(r,t):x.findFrom(r,t);return l?gt(e,l):!1}return!1}function oo(e,t){if(!(e.state.selection instanceof C))return!0;let{$head:n,$anchor:i,empty:o}=e.state.selection;if(!n.sameParent(i))return!0;if(!o)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;let s=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(s&&!s.isText){let r=e.state.tr;return t<0?r.delete(n.pos-s.nodeSize,n.pos):r.delete(n.pos,n.pos+s.nodeSize),e.dispatch(r),!0}return!1}function so(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function ga(e){if(!F||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&v(t)&&n==0&&t.firstChild&&v(t.firstChild)&&t.firstChild.contentEditable=="false"){let i=t.firstChild;so(e,i,"true"),setTimeout(()=>so(e,i,"false"),20)}return!1}function ya(e){let t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}function wa(e,t){let n=t.keyCode,i=ya(t);if(n==8||U&&n==72&&i=="c")return oo(e,-1)||$t(e,-1);if(n==46&&!t.shiftKey||U&&n==68&&i=="c")return oo(e,1)||$t(e,1);if(n==13||n==27)return!0;if(n==37||U&&n==66&&i=="c"){let o=n==37?no(e,e.state.selection.from)=="ltr"?-1:1:-1;return eo(e,o,i)||$t(e,o)}else if(n==39||U&&n==70&&i=="c"){let o=n==39?no(e,e.state.selection.from)=="ltr"?1:-1:1;return eo(e,o,i)||$t(e,o)}else{if(n==38||U&&n==80&&i=="c")return io(e,-1,i)||$t(e,-1);if(n==40||U&&n==78&&i=="c")return ga(e)||io(e,1,i)||$t(e,1);if(i==(U?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function ri(e,t){e.someProp("transformCopied",u=>{t=u(t,e)});let n=[],{content:i,openStart:o,openEnd:s}=t;for(;o>1&&s>1&&i.childCount==1&&i.firstChild.childCount==1;){o--,s--;let u=i.firstChild;n.push(u.type.name,u.attrs!=u.type.defaultAttrs?u.attrs:null),i=u.content}let r=e.someProp("clipboardSerializer")||Me.fromSchema(e.state.schema),l=$s(),a=l.createElement("div");a.appendChild(r.serializeFragment(i,{document:l}));let h=a.firstChild,c,d=0;for(;h&&v(h)&&(c=Bs[h.nodeName.toLowerCase()]);){for(let u=c.length-1;u>=0;u--){let f=l.createElement(c[u]);for(;a.firstChild;)f.appendChild(a.firstChild);a.appendChild(f),d++}h=a.firstChild}h&&v(h)&&h.setAttribute("data-pm-slice",`${o} ${s}${d?` -${d}`:""} ${JSON.stringify(n)}`);let p=e.someProp("clipboardTextSerializer",u=>u(t,e))||t.content.textBetween(0,t.content.size,`
|
|
7
|
+
|
|
8
|
+
`);return{dom:a,text:p,slice:t}}function li(e,t,n,i,o){let s=o.parent.type.spec.code,r,l;if(!n&&!t)return null;let a=!!t&&(i||s||!n);if(a){if(e.someProp("transformPastedText",p=>{t=p(t,s||i,e)}),s)return l=new w(y.from(e.state.schema.text(t.replace(/\r\n?/g,`
|
|
9
|
+
`))),0,0),e.someProp("transformPasted",p=>{l=p(l,e,!0)}),l;let d=e.someProp("clipboardTextParser",p=>p(t,o,i,e));if(d)l=d;else{let p=o.marks(),{schema:u}=e.state,f=Me.fromSchema(u);r=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=r.appendChild(document.createElement("p"));m&&g.appendChild(f.serializeNode(u.text(m,p)))})}}else e.someProp("transformPastedHTML",d=>{n=d(n,e)}),r=xa(n),nn&&Sa(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&&!v(p);)p=p.nextSibling;if(!p)break;r=p}if(l||(l=(e.someProp("clipboardParser")||e.someProp("domParser")||Un.fromSchema(e.state.schema)).parseSlice(r,{preserveWhitespace:!!(a||c),context:o,ruleFromNode(d){return d.nodeName=="BR"&&!d.nextSibling&&d.parentNode&&!va.test(d.parentNode.nodeName)?{ignore:!0}:null}})),c)l=Ca(ro(l,+c[1],+c[2]),c[4]);else if(l=w.maxOpen(ba(l.content,o),!0),l.openStart||l.openEnd){let d=0,p=0;for(let u=l.content.firstChild;d<l.openStart&&!u.type.spec.isolating;d++,u=u.firstChild);for(let u=l.content.lastChild;p<l.openEnd&&!u.type.spec.isolating;p++,u=u.lastChild);l=ro(l,d,p)}return e.someProp("transformPasted",d=>{l=d(l,e,a)}),l}var va=/^(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 ba(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let i=t.node(n).contentMatchAt(t.index(n)),o,s=[];if(e.forEach(r=>{if(!s)return;let l=i.findWrapping(r.type),a;if(!l)return s=null;if(a=s.length&&o.length&&Ps(l,o,r,s[s.length-1],0))s[s.length-1]=a;else{s.length&&(s[s.length-1]=zs(s[s.length-1],o.length));let h=Is(r,l);s.push(h),i=i.matchType(h.type),o=l}}),s)return y.from(s)}return e}function Is(e,t,n=0){for(let i=t.length-1;i>=n;i--)e=t[i].create(null,y.from(e));return e}function Ps(e,t,n,i,o){if(o<e.length&&o<t.length&&e[o]==t[o]){let s=Ps(e,t,n,i.lastChild,o+1);if(s)return i.copy(i.content.replaceChild(i.childCount-1,s));if(i.contentMatchAt(i.childCount).matchType(o==e.length-1?n.type:e[o+1]))return i.copy(i.content.append(y.from(Is(n,e,o+1))))}}function zs(e,t){if(t==0)return e;let n=e.content.replaceChild(e.childCount-1,zs(e.lastChild,t-1)),i=e.contentMatchAt(e.childCount).fillBefore(y.empty,!0);return e.copy(n.append(i))}function qn(e,t,n,i,o,s){let r=t<0?e.firstChild:e.lastChild,l=r.content;return e.childCount>1&&(s=0),o<i-1&&(l=qn(l,t,n,i,o+1,s)),o>=n&&(l=t<0?r.contentMatchAt(0).fillBefore(l,s<=o).append(l):l.append(r.contentMatchAt(r.childCount).fillBefore(y.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,r.copy(l))}function ro(e,t,n){return t<e.openStart&&(e=new w(qn(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new w(qn(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}var Bs={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 $s(){return document.implementation.createHTMLDocument("title")}var _t=null;function ka(e){let t=window.trustedTypes;if(!t)return e;if(!_t){if(_t=t.defaultPolicy)try{return _t.createHTML(e)}catch{}_t=t.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})}return _t.createHTML(e)}function xa(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n=$s(),i=n.body,o=/<([a-z][^>\s]+)/i.exec(e),s;if((s=o&&Bs[o[1].toLowerCase()])&&(e=s.map(r=>"<"+r+">").join("")+e+s.map(r=>"</"+r+">").reverse().join("")),i.innerHTML=ka(e),s)for(let r=0;r<s.length;r++)i=i.querySelector(s[r])||i;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=i.querySelectorAll(h.selectorText);for(let d=0;d<c.length;d++)c[d].style.cssText+=h.style.cssText}}}return i}function Sa(e){let t=e.querySelectorAll(R?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<t.length;n++){let i=t[n];i.childNodes.length==1&&i.textContent=="\xA0"&&i.parentNode&&i.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),i)}}function Ca(e,t){if(!e.size)return e;let n=e.content.firstChild.type.schema,i;try{i=JSON.parse(t)}catch{return e}let{content:o,openStart:s,openEnd:r}=e;for(let l=i.length-2;l>=0;l-=2){let a=n.nodes[i[l]];if(!a||a.hasRequiredAttrs())break;try{o=y.from(a.create(i[l+1],o))}catch{break}s++,r++}return new w(o,s,r)}var J={},W={},Ma={touchstart:!0,touchmove:!0},Oa=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 Na(e){for(let t in J){let n=J[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=i=>{Ta(e,i)&&!ai(e,i)&&(e.editable||!(i.type in W))&&n(e,i)},Ma[t]?{passive:!0}:void 0)}F&&e.dom.addEventListener("input",()=>null),jn(e)}function at(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function Da(e){e.input.mouseDown&&e.input.mouseDown.done(),e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}function jn(e){e.someProp("handleDOMEvents",t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=i=>ai(e,i))})}function ai(e,t){return e.someProp("handleDOMEvents",n=>{let i=n[t.type];return i?i(e,t)||t.defaultPrevented:!1})}function Ta(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}function Ea(e,t){!ai(e,t)&&J[t.type]&&(e.editable||!(t.type in W))&&J[t.type](e,t)}W.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=n.keyCode==16||n.shiftKey,!Js(e)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!(lt&&R&&n.keyCode==13)))if(n.keyCode!=229&&e.domObserver.forceFlush(),Gt&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let i=Date.now();e.input.lastIOSEnter=i,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==i&&(e.someProp("handleKeyDown",o=>o(e,Mt(13,"Enter"))),e.input.lastIOSEnter=0)},200)}else e.someProp("handleKeyDown",i=>i(e,n))||wa(e,n)?n.preventDefault():at(e,"key")};W.keyup=(e,t)=>{t.keyCode==16&&(e.input.shiftKey=!1)};W.keypress=(e,t)=>{let n=t;if(Js(e)||!n.charCode||n.ctrlKey&&!n.altKey||U&&n.metaKey)return;if(e.someProp("handleKeyPress",o=>o(e,n))){n.preventDefault();return}let i=e.state.selection;if(!(i instanceof C)||!i.$from.sameParent(i.$to)){let o=String.fromCharCode(n.charCode),s=()=>e.state.tr.insertText(o).scrollIntoView();!/[\r\n]/.test(o)&&!e.someProp("handleTextInput",r=>r(e,i.$from.pos,i.$to.pos,o,s))&&e.dispatch(s()),n.preventDefault()}};function Ee(e){return{left:e.clientX,top:e.clientY}}function Aa(e,t){let n=t.x-e.clientX,i=t.y-e.clientY;return n*n+i*i<100}function hi(e,t,n,i,o){if(i==-1)return!1;let s=e.state.doc.resolve(i);for(let r=s.depth+1;r>0;r--)if(e.someProp(t,l=>r>s.depth?l(e,n,s.nodeAfter,s.before(r),o,!0):l(e,n,s.node(r),s.before(r),o,!1)))return!0;return!1}function Ae(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let i=e.state.tr.setSelection(t);i.setMeta("pointer",!0),e.dispatch(i)}function Ra(e,t){if(t==-1)return!1;let n=e.state.doc.resolve(t),i=n.nodeAfter;return i&&i.isAtom&&k.isSelectable(i)?(Ae(e,new k(n)),!0):!1}function Ia(e,t){if(t==-1)return!1;let n=e.state.selection,i,o;n instanceof k&&(i=n.node);let s=e.state.doc.resolve(t);for(let r=s.depth+1;r>0;r--){let l=r>s.depth?s.nodeAfter:s.node(r);if(k.isSelectable(l)){i&&n.$from.depth>0&&r>=n.$from.depth&&s.before(n.$from.depth+1)==n.$from.pos?o=s.before(n.$from.depth):o=s.before(r);break}}return o!=null?(Ae(e,k.create(e.state.doc,o)),!0):!1}function Pa(e,t,n,i,o){return hi(e,"handleClickOn",t,n,i)||e.someProp("handleClick",s=>s(e,t,i))||(o?Ia(e,n):Ra(e,n))}function za(e,t,n,i){return hi(e,"handleDoubleClickOn",t,n,i)||e.someProp("handleDoubleClick",o=>o(e,t,i))}function Ba(e,t,n,i){return hi(e,"handleTripleClickOn",t,n,i)||e.someProp("handleTripleClick",o=>o(e,t,i))||$a(e,n,i)}function $a(e,t,n){if(n.button!=0)return!1;let i=Vs(e,t,!0),o=e.state.doc;return i?(Ae(e,i),i instanceof C&&o.eq(e.state.doc)&&(e.input.mouseDown=new Fa(e,i)),!0):!1}function Vs(e,t,n){let i=e.state.doc;if(t==-1)return i.inlineContent?C.create(i,0,i.content.size):null;let o=i.resolve(t);for(let s=o.depth+1;s>0;s--){let r=s>o.depth?o.nodeAfter:o.node(s),l=o.before(s);if(r.inlineContent)return C.create(i,l+1,l+1+r.content.size);if(n&&k.isSelectable(r))return k.create(i,l)}return null}function ci(e){return be(e)}var Fs=U?"metaKey":"ctrlKey";J.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let i=ci(e),o=Date.now(),s="singleClick";o-e.input.lastClick.time<500&&Aa(n,e.input.lastClick)&&!n[Fs]&&e.input.lastClick.button==n.button&&(e.input.lastClick.type=="singleClick"?s="doubleClick":e.input.lastClick.type=="doubleClick"&&(s="tripleClick")),e.input.lastClick={time:o,x:n.clientX,y:n.clientY,type:s,button:n.button},e.input.mouseDown&&e.input.mouseDown.done();let r=e.posAtCoords(Ee(n));r&&(s=="singleClick"?e.input.mouseDown=new Va(e,r,n,!!i):(s=="doubleClick"?za:Ba)(e,r.pos,r.inside,n)?n.preventDefault():at(e,"pointer"))};var Ls=class{constructor(e){this.view=e,this.mightDrag=null,e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this))}up(e){this.done()}move(e){e.buttons==0&&this.done()}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null)}delaySelUpdate(){return!1}},Va=class extends Ls{constructor(e,t,n,i){super(e),this.pos=t,this.event=n,this.flushed=i,this.delayedSelectionSync=!1,this.startDoc=e.state.doc,this.selectNode=!!n[Fs],this.allowDefault=n.shiftKey;let o,s;if(t.inside>-1)o=e.state.doc.nodeAt(t.inside),s=t.inside;else{let h=e.state.doc.resolve(t.pos);o=h.parent,s=h.depth?h.before():0}let r=i?null:n.target,l=r?e.docView.nearestDesc(r,!0):null;this.target=l&&v(l.nodeDOM)?l.nodeDOM:null;let{selection:a}=e.state;n.button==0&&(o.type.spec.draggable&&o.type.spec.selectable!==!1||a instanceof k&&a.from<=s&&a.to>s)&&(this.mightDrag={node:o,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&H&&!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()),at(e,"pointer")}done(){super.done(),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>{this.view.isDestroyed||ht(this.view)})}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(Ee(e))),this.updateAllowDefault(e),this.allowDefault||!t?at(this.view,"pointer"):Pa(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||F&&this.mightDrag&&!this.mightDrag.node.isAtom||R&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(Ae(this.view,x.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):at(this.view,"pointer")}move(e){this.updateAllowDefault(e),at(this.view,"pointer"),super.move(e)}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}delaySelUpdate(){return this.allowDefault?(this.delayedSelectionSync=!0,!0):!1}},Fa=class extends Ls{constructor(e,t){super(e),this.startSelection=t,this.startDoc=e.state.doc}move(e){if(e.buttons==0||this.view.isDestroyed||!this.view.state.doc.eq(this.startDoc)){this.done();return}e.preventDefault(),at(this.view,"pointer");let t=this.view.posAtCoords(Ee(e)),n=t&&Vs(this.view,t.inside,!1);if(!n)return;let{doc:i}=this.view.state,o=this.startSelection,[s,r]=n.from<o.from?[o.to,n.from]:[o.from,n.to];Ae(this.view,C.create(i,s,r))}};J.touchstart=e=>{e.input.lastTouch=Date.now(),ci(e),at(e,"pointer")};J.touchmove=e=>{e.input.lastTouch=Date.now(),at(e,"pointer")};J.contextmenu=e=>ci(e);function Js(e,t){return e.composing?!0:F&&Math.abs(Date.now()-e.input.compositionEndedAt)<500?(e.input.compositionEndedAt=-2e8,!0):!1}var La=lt?5e3:-1;W.compositionstart=W.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof C&&t.selection.empty&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(i=>i.type.spec.inclusive===!1)||R&&us&&Ja(e)))e.markCursor=e.state.storedMarks||n.marks(),be(e,!0),e.markCursor=null;else if(be(e,!t.selection.empty),H&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let i=e.domSelectionRange();for(let o=i.focusNode,s=i.focusOffset;o&&v(o)&&s!=0;){let r=s<0?o.lastChild:o.childNodes[s-1];if(!r)break;if(T(r)){let l=e.domSelection();l&&l.collapse(r,r.nodeValue.length);break}else o=r,s=-1}}e.input.composing=!0}Ws(e,La)};function Ja(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||!v(t)||n>=t.childNodes.length)return!1;let i=t.childNodes[n];return v(i)&&i.contentEditable=="false"}W.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Date.now(),e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.badSafariComposition?e.domObserver.forceFlush():e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,Ws(e,20))};function Ws(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>be(e),t))}function qs(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Date.now());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function Wa(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=Il(t.focusNode,t.focusOffset),i=Pl(t.focusNode,t.focusOffset);if(n&&i&&n!=i){let o=i.pmViewDesc,s=e.domObserver.lastChangedTextNode;if(n==s||i==s)return s;if(!o||!o.isText(i.nodeValue))return i;if(e.input.compositionNode==i){let r=n.pmViewDesc;if(!(!r||!r.isText(n.nodeValue)))return i}}return n||i}function be(e,t=!1){if(!(lt&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),qs(e),t||e.docView&&e.docView.dirty){let n=oi(e),i=e.state.selection;return n&&!n.eq(i)?e.dispatch(e.state.tr.setSelection(n)):(e.markCursor||t)&&!i.$from.node(i.$from.sharedDepth(i.to)).inlineContent?e.dispatch(e.state.tr.deleteSelection()):e.updateState(e.state),!0}return!1}}function qa(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(t),n.style.cssText="position: fixed; left: -10000px; top: 10px";let i=getSelection(),o=document.createRange();o.selectNodeContents(t),e.dom.blur(),i.removeAllRanges(),i.addRange(o),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}var ke=K&&vt<15||Gt&&Vl<604;J.copy=W.cut=(e,t)=>{let n=t,i=e.state.selection,o=n.type=="cut";if(i.empty)return;let s=ke?null:n.clipboardData,r=i.content(),{dom:l,text:a}=ri(e,r);s?(n.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):qa(e,l),o&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function ja(e){return e.openStart==0&&e.openEnd==0&&e.content.childCount==1?e.content.firstChild:null}function Ka(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,i=e.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(i.contentEditable="true"),i.style.cssText="position: fixed; left: -10000px; top: 10px",i.focus();let o=e.input.shiftKey&&e.input.lastKeyCode!=45;setTimeout(()=>{e.focus(),i.parentNode&&i.parentNode.removeChild(i),n?xe(e,i.value,null,o,t):xe(e,i.textContent,i.innerHTML,o,t)},50)}function xe(e,t,n,i,o){let s=li(e,t,n,i,e.state.selection.$from);if(e.someProp("handlePaste",a=>a(e,o,s||w.empty)))return!0;if(!s)return!1;let r=ja(s),l=r?e.state.tr.replaceSelectionWith(r,i):e.state.tr.replaceSelection(s);return e.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function js(e){let t=e.getData("text/plain")||e.getData("Text");if(t)return t;let n=e.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}W.paste=(e,t)=>{let n=t;if(e.composing&&!lt)return;let i=ke?null:n.clipboardData,o=e.input.shiftKey&&e.input.lastKeyCode!=45;i&&xe(e,js(i),i.getData("text/html"),o,n)?n.preventDefault():Ka(e,n)};var Ks=class{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}},Ha=U?"altKey":"ctrlKey";function Hs(e,t){let n;return e.someProp("dragCopies",i=>{n=n||i(t)}),n!=null?!n:!t[Ha]}J.dragstart=(e,t)=>{let n=t,i=e.input.mouseDown;if(i&&i.done(),!n.dataTransfer)return;let o=e.state.selection,s=o.empty?null:e.posAtCoords(Ee(n)),r;if(!(s&&s.pos>=o.from&&s.pos<=(o instanceof k?o.to-1:o.to))){if(i&&i.mightDrag)r=k.create(e.state.doc,i.mightDrag.pos);else if(n.target&&v(n.target)){let d=e.docView.nearestDesc(n.target,!0);d&&d.node.type.spec.draggable&&d!=e.docView&&(r=k.create(e.state.doc,d.posBefore))}}let l=(r||e.state.selection).content(),{dom:a,text:h,slice:c}=ri(e,l);(!n.dataTransfer.files.length||!R||fs>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(ke?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",ke||n.dataTransfer.setData("text/plain",h),e.dragging=new Ks(c,Hs(e,n),r)};J.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)};W.dragover=W.dragenter=(e,t)=>t.preventDefault();W.drop=(e,t)=>{try{Ua(e,t,e.dragging)}finally{e.dragging=null}};function Ua(e,t,n){if(!t.dataTransfer)return;let i=e.posAtCoords(Ee(t));if(!i)return;let o=e.state.doc.resolve(i.pos),s=n&&n.slice;s?e.someProp("transformPasted",u=>{s=u(s,e,!1)}):s=li(e,js(t.dataTransfer),ke?null:t.dataTransfer.getData("text/html"),!1,o);let r=!!(n&&Hs(e,t));if(e.someProp("handleDrop",u=>u(e,t,s||w.empty,r))){t.preventDefault();return}if(!s)return;t.preventDefault();let l=s?_n(e.state.doc,o.pos,s):o.pos;l==null&&(l=o.pos);let a=e.state.tr;if(r){let{node:u}=n;u?u.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&&k.isSelectable(s.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(s.content.firstChild))a.setSelection(new k(p));else{let u=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((f,m,g,b)=>u=b),a.setSelection(si(e,p,a.doc.resolve(u)))}e.focus(),e.dispatch(a.setMeta("uiEvent","drop"))}J.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0,setTimeout(()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&ht(e)},20))};J.blur=(e,t)=>{let n=t;e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),e.focused=!1)};J.beforeinput=(e,t)=>{if(lt&&t.inputType=="deleteContentBackward"){e.domObserver.flushSoon();let{domChangeCount:n}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=n||(e.dom.blur(),e.focus(),e.someProp("handleKeyDown",o=>o(e,Mt(8,"Backspace")))))return;let{$cursor:i}=e.state.selection;i&&i.pos>0&&e.dispatch(e.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let e in W)J[e]=W[e];function Se(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}var lo=class Us{constructor(t,n){this.toDOM=t,this.spec=n||Et,this.side=this.spec.side||0}map(t,n,i,o){let{pos:s,deleted:r}=t.mapResult(n.from+o,this.side<0?-1:1);return r?null:new St(s-i,s-i,this)}valid(){return!0}eq(t){return this==t||t instanceof Us&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&Se(this.spec,t.spec))}destroy(t){this.spec.destroy&&this.spec.destroy(t)}},ye=class Kn{constructor(t,n){this.attrs=t,this.spec=n||Et}map(t,n,i,o){let s=t.map(n.from+o,this.spec.inclusiveStart?-1:1)-i,r=t.map(n.to+o,this.spec.inclusiveEnd?1:-1)-i;return s>=r?null:new St(s,r,this)}valid(t,n){return n.from<n.to}eq(t){return this==t||t instanceof Kn&&Se(this.attrs,t.attrs)&&Se(this.spec,t.spec)}static is(t){return t.type instanceof Kn}destroy(){}},Ga=class Gs{constructor(t,n){this.attrs=t,this.spec=n||Et}map(t,n,i,o){let s=t.mapResult(n.from+o,1);if(s.deleted)return null;let r=t.mapResult(n.to+o,-1);return r.deleted||r.pos<=s.pos?null:new St(s.pos-i,r.pos-i,this)}valid(t,n){let{index:i,offset:o}=t.content.findIndex(n.from),s;return o==n.from&&!(s=t.child(i)).isText&&o+s.nodeSize==n.to}eq(t){return this==t||t instanceof Gs&&Se(this.attrs,t.attrs)&&Se(this.spec,t.spec)}destroy(){}},St=class ce{constructor(t,n,i){this.from=t,this.to=n,this.type=i}copy(t,n){return new ce(t,n,this.type)}eq(t,n=0){return this.type.eq(t.type)&&this.from+n==t.from&&this.to+n==t.to}map(t,n,i){return this.type.map(t,this,n,i)}static widget(t,n,i){return new ce(t,t,new lo(n,i))}static inline(t,n,i,o){return new ce(t,n,new ye(i,o))}static node(t,n,i,o){return new ce(t,n,new Ga(i,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof ye}get widget(){return this.type instanceof lo}},Jt=[],Et={},Y=class ut{constructor(t,n){this.local=t.length?t:Jt,this.children=n.length?n:Jt}static create(t,n){return n.length?Xe(n,t,0,Et):B}find(t,n,i){let o=[];return this.findInner(t??0,n??1e9,o,0,i),o}findInner(t,n,i,o,s){for(let r=0;r<this.local.length;r++){let l=this.local[r];l.from<=n&&l.to>=t&&(!s||s(l.spec))&&i.push(l.copy(l.from+o,l.to+o))}for(let r=0;r<this.children.length;r+=3)if(this.children[r]<n&&this.children[r+1]>t){let l=this.children[r]+1;this.children[r+2].findInner(t-l,n-l,i,o+l,s)}}map(t,n,i){return this==B||t.maps.length==0?this:this.mapInner(t,n,0,0,i||Et)}mapInner(t,n,i,o,s){let r;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(t,i,o);a&&a.type.valid(n,a)?(r||(r=[])).push(a):s.onRemove&&s.onRemove(this.local[l].spec)}return this.children.length?Ya(this.children,r||[],t,n,i,o,s):r?new ut(r.sort(At),Jt):B}add(t,n){return n.length?this==B?ut.create(t,n):this.addInner(t,n,0):this}addInner(t,n,i){let o,s=0;t.forEach((l,a)=>{let h=a+i,c;if(c=Qs(n,l,h)){for(o||(o=this.children.slice());s<o.length&&o[s]<a;)s+=3;o[s]==a?o[s+2]=o[s+2].addInner(l,c,h+1):o.splice(s,0,a,a+l.nodeSize,Xe(c,l,h+1,Et)),s+=3}});let r=Xs(s?Zs(n):n,-i);for(let l=0;l<r.length;l++)r[l].type.valid(t,r[l])||r.splice(l--,1);return new ut(r.length?this.local.concat(r).sort(At):this.local,o||this.children)}remove(t){return t.length==0||this==B?this:this.removeInner(t,0)}removeInner(t,n){let i=this.children,o=this.local;for(let s=0;s<i.length;s+=3){let r,l=i[s]+n,a=i[s+1]+n;for(let c=0,d;c<t.length;c++)(d=t[c])&&d.from>l&&d.to<a&&(t[c]=null,(r||(r=[])).push(d));if(!r)continue;i==this.children&&(i=this.children.slice());let h=i[s+2].removeInner(r,l+1);h!=B?i[s+2]=h:(i.splice(s,3),s-=3)}if(o.length){for(let s=0,r;s<t.length;s++)if(r=t[s])for(let l=0;l<o.length;l++)o[l].eq(r,n)&&(o==this.local&&(o=this.local.slice()),o.splice(l--,1))}return i==this.children&&o==this.local?this:o.length||i.length?new ut(o,i):B}forChild(t,n){if(this==B)return this;if(n.isLeaf)return ut.empty;let i,o;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=t){this.children[l]==t&&(i=this.children[l+2]);break}let s=t+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 ye){let h=Math.max(s,a.from)-s,c=Math.min(r,a.to)-s;h<c&&(o||(o=[])).push(a.copy(h,c))}}if(o){let l=new ut(o.sort(At),Jt);return i?new Ys([l,i]):l}return i||B}eq(t){if(this==t)return!0;if(!(t instanceof ut)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(t.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=t.children[n]||this.children[n+1]!=t.children[n+1]||!this.children[n+2].eq(t.children[n+2]))return!1;return!0}locals(t){return di(this.localsInner(t))}localsInner(t){if(this==B)return Jt;if(t.inlineContent||!this.local.some(ye.is))return this.local;let n=[];for(let i=0;i<this.local.length;i++)this.local[i].type instanceof ye||n.push(this.local[i]);return n}forEachSet(t){t(this)}};Y.empty=new Y([],[]);Y.removeOverlap=di;var B=Y.empty,Ys=class Wt{constructor(t){this.members=t}map(t,n){let i=this.members.map(o=>o.map(t,n,Et));return Wt.from(i)}forChild(t,n){if(n.isLeaf)return Y.empty;let i=[];for(let o=0;o<this.members.length;o++){let s=this.members[o].forChild(t,n);s!=B&&(s instanceof Wt?i=i.concat(s.members):i.push(s))}return Wt.from(i)}eq(t){if(!(t instanceof Wt)||t.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(t.members[n]))return!1;return!0}locals(t){let n,i=!0;for(let o=0;o<this.members.length;o++){let s=this.members[o].localsInner(t);if(s.length)if(!n)n=s;else{i&&(n=n.slice(),i=!1);for(let r=0;r<s.length;r++)n.push(s[r])}}return n?di(i?n:n.sort(At)):Jt}static from(t){switch(t.length){case 0:return B;case 1:return t[0];default:return new Wt(t.every(n=>n instanceof Y)?t:t.reduce((n,i)=>n.concat(i instanceof Y?i:i.members),[]))}}forEachSet(t){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(t)}};function Ya(e,t,n,i,o,s,r){let l=e.slice();for(let h=0,c=s;h<n.maps.length;h++){let d=0;n.maps[h].forEach((p,u,f,m)=>{let g=m-f-(u-p);for(let b=0;b<l.length;b+=3){let N=l[b+1];if(N<0||p>N+c-d)continue;let O=l[b]+c-d;u>=O?l[b+1]=p<=O?-2:-1:p>=c&&g&&(l[b]+=g,l[b+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(e[h]+s),d=c-o;if(d<0||d>=i.content.size){a=!0;continue}let p=n.map(e[h+1]+s,-1),u=p-o,{index:f,offset:m}=i.content.findIndex(d),g=i.maybeChild(f);if(g&&m==d&&m+g.nodeSize==u){let b=l[h+2].mapInner(n,g,c+1,e[h]+s+1,r);b!=B?(l[h]=d,l[h+1]=u,l[h+2]=b):(l[h+1]=-2,a=!0)}else a=!0}if(a){let h=Xa(l,e,t,n,o,s,r),c=Xe(h,i,0,r);t=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 u=c.children[d];for(;p<l.length&&l[p]<u;)p+=3;l.splice(p,0,c.children[d],c.children[d+1],c.children[d+2])}}return new Y(t.sort(At),l)}function Xs(e,t){if(!t||!e.length)return e;let n=[];for(let i=0;i<e.length;i++){let o=e[i];n.push(new St(o.from+t,o.to+t,o.type))}return n}function Xa(e,t,n,i,o,s,r){function l(a,h){for(let c=0;c<a.local.length;c++){let d=a.local[c].map(i,o,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<e.length;a+=3)e[a+1]==-1&&l(e[a+2],t[a]+s+1);return n}function Qs(e,t,n){if(t.isLeaf)return null;let i=n+t.nodeSize,o=null;for(let s=0,r;s<e.length;s++)(r=e[s])&&r.from>n&&r.to<i&&((o||(o=[])).push(r),e[s]=null);return o}function Zs(e){let t=[];for(let n=0;n<e.length;n++)e[n]!=null&&t.push(e[n]);return t}function Xe(e,t,n,i){let o=[],s=!1;t.forEach((l,a)=>{let h=Qs(e,l,a+n);if(h){s=!0;let c=Xe(h,l,n+a+1,i);c!=B&&o.push(a,a+l.nodeSize,c)}});let r=Xs(s?Zs(e):e,-n).sort(At);for(let l=0;l<r.length;l++)r[l].type.valid(t,r[l])||(i.onRemove&&i.onRemove(r[l].spec),r.splice(l--,1));return r.length||o.length?new Y(r,o):B}function At(e,t){return e.from-t.from||e.to-t.to}function di(e){let t=e;for(let n=0;n<t.length-1;n++){let i=t[n];if(i.from!=i.to)for(let o=n+1;o<t.length;o++){let s=t[o];if(s.from==i.from){s.to!=i.to&&(t==e&&(t=e.slice()),t[o]=s.copy(s.from,i.to),ao(t,o+1,s.copy(i.to,s.to)));continue}else{s.from<i.to&&(t==e&&(t=e.slice()),t[n]=i.copy(i.from,s.from),ao(t,o,i.copy(s.from,i.to)));break}}}return t}function ao(e,t,n){for(;t<e.length&&At(n,e[t])>0;)t++;e.splice(t,0,n)}function un(e){let t=[];return e.someProp("decorations",n=>{let i=n(e.state);i&&i!=B&&t.push(i)}),e.cursorWrapper&&t.push(Y.create(e.state.doc,[e.cursorWrapper.deco])),Ys.from(t)}var Qa={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Za=K&&vt<=11,_a=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}},th=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new _a,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(n=>{for(let i=0;i<n.length;i++)this.queue.push(n[i]);K&&vt<=11&&n.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():F&&e.composing&&n.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),Za&&(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,Qa)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(to(this.view)){if(this.suppressingSelectionUpdates)return ht(this.view);if(K&&vt<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&It(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,n;for(let o=e.focusNode;o;o=Ut(o))t.add(o);for(let o=e.anchorNode;o;o=Ut(o))if(t.has(o)){n=o;break}let i=n&&this.view.docView.nearestDesc(n);if(i&&i.ignoreMutation({type:"selection",target:T(n)?n.parentNode:n}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let n=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&to(e)&&!this.ignoreSelectionChange(n),o=-1,s=-1,r=!1,l=[];if(e.editable)for(let h=0;h<t.length;h++){let c=this.registerMutation(t[h],l);c&&(o=o<0?c.from:Math.min(c.from,o),s=s<0?c.to:Math.max(c.to,s),c.typeOver&&(r=!0))}if(l.some(h=>h.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46||R&&(e.composing||e.input.compositionEndedAt>Date.now()-50)&&t.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&&v(c);){if(c.contentEditable=="false"){h.parentNode.removeChild(h);break}c=c.firstChild}}}else if(H&&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||ih(e,c)!=p)&&d.remove()}}}let a=null;o<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&en(n)&&(a=oi(e))&&a.eq(x.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,ht(e),this.currentSelection.set(n),e.scrollToSelection()):(o>-1||i)&&(o>-1&&(e.docView.markDirty(o,s),eh(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,oh(e,l)),this.handleDOMChange(o,s,r,l),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||ht(e),this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(n==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!n||n.ignoreMutation(e))return null;if(e.type=="childList"){for(let h=0;h<e.addedNodes.length;h++){let c=e.addedNodes[h];t.push(c),T(c)&&(this.lastChangedTextNode=c)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let i=e.previousSibling,o=e.nextSibling;if(K&&vt<=11&&e.addedNodes.length)for(let h=0;h<e.addedNodes.length;h++){let{previousSibling:c,nextSibling:d}=e.addedNodes[h];(!c||Array.prototype.indexOf.call(e.addedNodes,c)<0)&&(i=c),(!d||Array.prototype.indexOf.call(e.addedNodes,d)<0)&&(o=d)}let s=i&&i.parentNode==e.target?A(i)+1:0,r=n.localPosFromDOM(e.target,s,-1),l=o&&o.parentNode==e.target?A(o):e.target.childNodes.length,a=n.localPosFromDOM(e.target,l,1);return{from:r,to:a}}else return e.type=="attributes"?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:(this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}},ho=new WeakMap,co=!1;function eh(e){if(!ho.has(e)&&(ho.set(e,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(e.dom).whiteSpace)!==-1)){if(e.requiresGeckoHackNode=H,co)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."),co=!0}}function po(e,t){let n=t.startContainer,i=t.startOffset,o=t.endContainer,s=t.endOffset,r=e.domAtPos(e.state.selection.anchor);return It(r.node,r.offset,o,s)&&([n,i,o,s]=[o,s,n,i]),{anchorNode:n,anchorOffset:i,focusNode:o,focusOffset:s}}function nh(e,t){if(t.getComposedRanges){let o=t.getComposedRanges(e.root)[0];if(o)return po(e,o)}let n;function i(o){o.preventDefault(),o.stopImmediatePropagation(),n=o.getTargetRanges()[0]}return e.dom.addEventListener("beforeinput",i,!0),document.execCommand("indent"),e.dom.removeEventListener("beforeinput",i,!0),n?po(e,n):null}function ih(e,t){for(let n=t.parentNode;n&&n!=e.dom;n=n.parentNode){let i=e.docView.nearestDesc(n,!0);if(i&&i.node.isBlock)return n}return null}function oh(e,t){var n;let{focusNode:i,focusOffset:o}=e.domSelectionRange();for(let s of t)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||!v(a)||a.contentEditable=="false"||/^(BR|IMG)$/.test(a.nodeName))break;l=a}l.insertBefore(s,l.firstChild),i==s&&e.domSelection().collapse(s,o)}else s.parentNode.removeChild(s)}}function sh(e,t,n,i){let{node:o,fromOffset:s,toOffset:r,from:l,to:a}=e.docView.parseRange(t,n),h=e.domSelectionRange(),c,d=h.anchorNode;if(d&&Pt(e.dom,d)&&(c=[{node:d,offset:h.anchorOffset}],en(h)||c.push({node:h.focusNode,offset:h.focusOffset})),R&&e.input.lastKeyCode===8)for(let b=r;b>s;b--){let N=o.childNodes[b-1],O=N.pmViewDesc;if(N.nodeName=="BR"&&!O){r=b;break}if(!O||O.size)break}let p=e.state.doc,u=e.someProp("domParser")||Un.fromSchema(e.state.schema),f=p.resolve(l),m=null,g=u.parse(o,{topNode:f.parent,topMatch:f.parent.contentMatchAt(f.index()),topOpen:!0,from:s,to:r,preserveWhitespace:f.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:rh(i),context:f});if(c&&c[0].pos!=null){let b=c[0].pos,N=c[1]&&c[1].pos;N==null&&(N=b),m={anchor:b+l,head:N+l}}return{doc:g,sel:m,from:l,to:a}}var rh=e=>t=>{let n=t.pmViewDesc;if(n)return n.parseRule(e);if(t.nodeName=="BR"&&t.parentNode){if(F&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let i=document.createElement("div");return i.appendChild(document.createElement("li")),{skip:i}}else if(t.parentNode.lastChild==t||F&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null},lh=/^(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 ah(e,t,n,i,o){let s=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let S=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,E=oi(e,S);if(E&&!e.state.selection.eq(E)){if(R&<&&e.input.lastKeyCode===13&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp("handleKeyDown",Tr=>Tr(e,Mt(13,"Enter"))))return;let j=e.state.tr.setSelection(E);S=="pointer"?j.setMeta("pointer",!0):S=="key"&&j.scrollIntoView(),s&&j.setMeta("composition",s),e.dispatch(j)}return}let r=e.state.doc.resolve(t),l=r.sharedDepth(n);t=r.before(l+1),n=e.state.doc.resolve(n).after(l+1);let a=e.state.selection,h=sh(e,t,n,o),c=e.state.doc,d=c.slice(h.from,h.to),p,u;e.input.lastKeyCode===8&&Date.now()-100<e.input.lastKeyCodeTime?(p=e.state.selection.to,u="end"):(p=e.state.selection.from,u="start"),e.input.lastKeyCode=null;let f=ph(d.content,h.doc.content,h.from,p,u);if(f&&e.input.domChangeCount++,(Gt&&e.input.lastIOSEnter>Date.now()-225||lt)&&o.some(S=>v(S)&&!lh.test(S.nodeName))&&(!f||f.endA>=f.endB)&&e.someProp("handleKeyDown",S=>S(e,Mt(13,"Enter")))){e.input.lastIOSEnter=0;return}if(!f)if(i&&a instanceof C&&!a.empty&&a.$head.sameParent(a.$anchor)&&!e.composing&&!(h.sel&&h.sel.anchor!=h.sel.head))f={start:a.from,endA:a.to,endB:a.to};else{if(h.sel){let S=fo(e,e.state.doc,h.sel);if(S&&!S.eq(e.state.selection)){let E=e.state.tr.setSelection(S);s&&E.setMeta("composition",s),e.dispatch(E)}}return}e.state.selection.from<e.state.selection.to&&f.start==f.endB&&e.state.selection instanceof C&&(f.start>e.state.selection.from&&f.start<=e.state.selection.from+2&&e.state.selection.from>=h.from?f.start=e.state.selection.from:f.endA<e.state.selection.to&&f.endA>=e.state.selection.to-2&&e.state.selection.to<=h.to&&(f.endB+=e.state.selection.to-f.endA,f.endA=e.state.selection.to)),K&&vt<=11&&f.endB==f.start+1&&f.endA==f.start&&f.start>h.from&&h.doc.textBetween(f.start-h.from-1,f.start-h.from+1)==" \xA0"&&(f.start--,f.endA--,f.endB--);let m=h.doc.resolveNoCache(f.start-h.from),g=h.doc.resolveNoCache(f.endB-h.from),b=c.resolve(f.start),N=m.sameParent(g)&&m.parent.inlineContent&&b.end()>=f.endA;if((Gt&&e.input.lastIOSEnter>Date.now()-225&&(!N||o.some(S=>S.nodeName=="DIV"||S.nodeName=="P"))||!N&&dh(h.doc,m.pos,g.pos))&&e.someProp("handleKeyDown",S=>S(e,Mt(13,"Enter")))){e.input.lastIOSEnter=0;return}if(e.state.selection.anchor>f.start&&ch(c,f.start,f.endA,m,g)&&e.someProp("handleKeyDown",S=>S(e,Mt(8,"Backspace")))){lt&&R&&e.domObserver.suppressSelectionUpdates();return}R&&f.endB==f.start&&(e.input.lastChromeDelete=Date.now()),lt&&!N&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&h.sel&&h.sel.anchor==h.sel.head&&h.sel.head==f.endA&&(f.endB-=2,g=h.doc.resolveNoCache(f.endB-h.from),setTimeout(()=>{e.someProp("handleKeyDown",function(S){return S(e,Mt(13,"Enter"))})},20));let O=f.start,Z=f.endA,Ct=S=>{let E=S||e.state.tr.replace(O,Z,h.doc.slice(f.start-h.from,f.endB-h.from));if(h.sel){let j=fo(e,E.doc,h.sel);j&&!(R&&e.composing&&j.empty&&(f.start!=f.endB||e.input.lastChromeDelete<Date.now()-100)&&(j.head==O||j.head==E.mapping.map(Z)-1)||K&&j.empty&&j.head==O)&&E.setSelection(j)}return s&&E.setMeta("composition",s),E.scrollIntoView()},Re;if(N)if(m.pos==g.pos){K&&vt<=11&&m.parentOffset==0&&(e.domObserver.suppressSelectionUpdates(),setTimeout(()=>ht(e),20));let S=Ct(e.state.tr.delete(O,Z)),E=c.resolve(f.start).marksAcross(c.resolve(f.endA));E&&S.ensureMarks(E),e.dispatch(S)}else if(f.endA==f.endB&&(Re=hh(m.parent.content.cut(m.parentOffset,g.parentOffset),b.parent.content.cut(b.parentOffset,f.endA-b.start())))){let S=Ct(e.state.tr);Re.type=="add"?S.addMark(O,Z,Re.mark):S.removeMark(O,Z,Re.mark),e.dispatch(S)}else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let S=m.parent.textBetween(m.parentOffset,g.parentOffset),E=()=>Ct(e.state.tr.insertText(S,O,Z));e.someProp("handleTextInput",j=>j(e,O,Z,S,E))||e.dispatch(E())}else e.dispatch(Ct());else e.dispatch(Ct())}function fo(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:si(e,t.resolve(n.anchor),t.resolve(n.head))}function hh(e,t){let n=e.firstChild.marks,i=t.firstChild.marks,o=n,s=i,r,l,a;for(let c=0;c<i.length;c++)o=i[c].removeFromSet(o);for(let c=0;c<n.length;c++)s=n[c].removeFromSet(s);if(o.length==1&&s.length==0)l=o[0],r="add",a=c=>c.mark(l.addToSet(c.marks));else if(o.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<t.childCount;c++)h.push(a(t.child(c)));if(y.from(h).eq(e))return{mark:l,type:r}}function ch(e,t,n,i,o){if(n-t<=o.pos-i.pos||mn(i,!0,!1)<o.pos)return!1;let s=e.resolve(t);if(!i.parent.isTextblock){let l=s.nodeAfter;return l!=null&&n==t+l.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let r=e.resolve(mn(s,!0,!0));return!r.parent.isTextblock||r.pos>n||mn(r,!0,!1)<n?!1:i.parent.content.cut(i.parentOffset).eq(r.parent.content)}function dh(e,t,n){let i=0,o=0;return e.nodesBetween(t,n,(s,r)=>{s.isTextblock&&r>=t&&r<n?i++:(s.isText?/\S/.test(s.text.slice(Math.max(0,t-r),Math.min(s.nodeSize,n-r))):s.isLeaf)&&o++}),o==0&&i==1}function mn(e,t,n){let i=e.depth,o=t?e.end():e.pos;for(;i>0&&(t||e.indexAfter(i)==e.node(i).childCount);)i--,o++,t=!1;if(n){let s=e.node(i).maybeChild(e.indexAfter(i));for(;s&&!s.isLeaf;)s=s.firstChild,o++}return o}function ph(e,t,n,i,o){let s=e.findDiffStart(t,n),r=n+e.size,l=n+t.size;if(s==null)return null;let{a,b:h}=e.findDiffEnd(t,r,l);if(o=="end"){let c=Math.max(0,s-Math.min(a,h));i-=a+c-s}if(a<s&&r<l){let c=i<=s&&i>=a?s-i:0;s-=c,h=s+(h-a),a=s}else if(h<s){let c=i<=s&&i>=h?s-i:0;s-=c,a=s+(a-h),h=s}return{start:s,endA:a,endB:h}}var fh=li,uh=be,_s=class{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new Oa,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(wo),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=go(this),mo(this),this.nodeViews=yo(this),this.docView=Gi(this.state.doc,uo(this),un(this),this.dom,this),this.domObserver=new th(this,(n,i,o,s)=>ah(this,n,i,o,s)),this.domObserver.start(),Na(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&jn(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(wo),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let n in this._props)t[n]=this._props[n];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var n;let i=this.state,o=!1,s=!1;e.storedMarks&&this.composing&&(qs(this),s=!0),this.state=e;let r=i.plugins!=e.plugins||this._props.plugins!=t.plugins;if(r||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let p=yo(this);gh(p,this.nodeViews)&&(this.nodeViews=p,o=!0)}(r||t.handleDOMEvents!=this._props.handleDOMEvents)&&jn(this),this.editable=go(this),mo(this);let l=un(this),a=uo(this),h=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",c=o||!this.docView.matchesNode(e.doc,a,l);(c||!e.selection.eq(i.selection))&&(s=!0);let d=h=="preserve"&&s&&this.dom.style.overflowAnchor==null&&Jl(this);if(s){this.domObserver.stop();let p=c&&(K||R)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&mh(i.selection,e.selection);if(c){let f=R?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Wa(this)),(o||!this.docView.update(e.doc,a,l,this))&&(this.docView.updateOuterDeco(a),this.docView.destroy(),this.docView=Gi(e.doc,a,l,this.dom,this)),f&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(p=!0)}let u=this.input.mouseDown;p||!(u&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&da(this)&&u.delaySelUpdate())?ht(this,p):(Es(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((n=this.dragging)===null||n===void 0)&&n.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),h=="reset"?this.dom.scrollTop=0:h=="to selection"?this.scrollToSelection():d&&Wl(d)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!Pt(this.dom,e))&&!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof k){let t=this.docView.domAfterPos(this.state.selection.from);v(t)&&qi(this,t.getBoundingClientRect(),e)}else qi(this,this.coordsAtPos(this.state.selection.head,1),e)}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let n=this.directPlugins[t];n.spec.view&&this.pluginViews.push(n.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let n=this.state.plugins[t];n.spec.view&&this.pluginViews.push(n.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}}updateDraggedNode(e,t){let n=e.node,i=-1;if(n.from<this.state.doc.content.size&&this.state.doc.nodeAt(n.from)==n.node)i=n.from;else{let o=n.from+(this.state.doc.content.size-t.doc.content.size);(o>0&&o<this.state.doc.content.size&&this.state.doc.nodeAt(o))==n.node&&(i=o)}this.dragging=new Ks(e.slice,e.move,i<0?void 0:k.create(this.state.doc,i))}someProp(e,t){let n=this._props&&this._props[e],i;if(n!=null&&(i=t?t(n):n))return i;for(let s=0;s<this.directPlugins.length;s++){let r=this.directPlugins[s].props[e];if(r!=null&&(i=t?t(r):r))return i}let o=this.state.plugins;if(o)for(let s=0;s<o.length;s++){let r=o[s].props[e];if(r!=null&&(i=t?t(r):r))return i}}hasFocus(){if(K){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&ql(this.dom),ht(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return Gl(this,e)}coordsAtPos(e,t=1){return vs(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let i=this.docView.posFromDOM(e,t,n);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,t){return _l(this,t||this.state,e)}pasteHTML(e,t){return xe(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return xe(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return ri(this,e)}destroy(){this.docView&&(Da(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],un(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Al())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Ea(this,e)}domSelectionRange(){let e=this.dom.isConnected!==!1&&this.domSelection();return e?F&&this.root.nodeType===11&&Bl(this.dom.ownerDocument)==this.dom&&nh(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};_s.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};function uo(e){let t=Object.create(null);return t.class="ProseMirror",t.contenteditable=String(e.editable),e.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(e.state)),n)for(let i in n)i=="class"?t.class+=" "+n[i]:i=="style"?t.style=(t.style?t.style+";":"")+n[i]:!t[i]&&i!="contenteditable"&&i!="nodeName"&&(t[i]=String(n[i]))}),t.translate||(t.translate="no"),[St.node(0,e.state.doc.content.size,t)]}function mo(e){if(e.markCursor){let t=document.createElement("img");t.className="ProseMirror-separator",t.setAttribute("mark-placeholder","true"),t.setAttribute("alt",""),e.cursorWrapper={dom:t,deco:St.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function go(e){return!e.someProp("editable",t=>t(e.state)===!1)}function mh(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}function yo(e){let t=Object.create(null);function n(i){for(let o in i)Object.prototype.hasOwnProperty.call(t,o)||(t[o]=i[o])}return e.someProp("nodeViews",n),e.someProp("markViews",n),t}function gh(e,t){let n=0,i=0;for(let o in e){if(e[o]!=t[o])return!0;n++}for(let o in t)i++;return n!=i}function wo(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var yh={};ot(yh,{closeHistory:()=>Mh,history:()=>Oh,isHistoryTransaction:()=>Ah,redo:()=>sr,redoDepth:()=>Eh,redoNoScroll:()=>Dh,undo:()=>or,undoDepth:()=>Th,undoNoScroll:()=>Nh});var Qe=200,I=function(){};I.prototype.append=function(e){return e.length?(e=I.from(e),!this.length&&e||e.length<Qe&&this.leafAppend(e)||this.length<Qe&&e.leafPrepend(this)||this.appendInner(e)):this};I.prototype.prepend=function(e){return e.length?I.from(e).append(this):this};I.prototype.appendInner=function(e){return new wh(this,e)};I.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?I.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};I.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};I.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)};I.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var i=[];return this.forEach(function(o,s){return i.push(e(o,s))},t,n),i};I.from=function(e){return e instanceof I?e:e&&e.length?new tr(e):I.empty};var tr=(function(e){function t(i){e.call(this),this.values=i}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(i,o){return i==0&&o==this.length?this:new t(this.values.slice(i,o))},t.prototype.getInner=function(i){return this.values[i]},t.prototype.forEachInner=function(i,o,s,r){for(var l=o;l<s;l++)if(i(this.values[l],r+l)===!1)return!1},t.prototype.forEachInvertedInner=function(i,o,s,r){for(var l=o-1;l>=s;l--)if(i(this.values[l],r+l)===!1)return!1},t.prototype.leafAppend=function(i){if(this.length+i.length<=Qe)return new t(this.values.concat(i.flatten()))},t.prototype.leafPrepend=function(i){if(this.length+i.length<=Qe)return new t(i.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t})(I);I.empty=new tr([]);var wh=(function(e){function t(n,i){e.call(this),this.left=n,this.right=i,this.length=n.length+i.length,this.depth=Math.max(n.depth,i.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(n){return n<this.left.length?this.left.get(n):this.right.get(n-this.left.length)},t.prototype.forEachInner=function(n,i,o,s){var r=this.left.length;if(i<r&&this.left.forEachInner(n,i,Math.min(o,r),s)===!1||o>r&&this.right.forEachInner(n,Math.max(i-r,0),Math.min(this.length,o)-r,s+r)===!1)return!1},t.prototype.forEachInvertedInner=function(n,i,o,s){var r=this.left.length;if(i>r&&this.right.forEachInvertedInner(n,i-r,Math.max(o,r)-r,s+r)===!1||o<r&&this.left.forEachInvertedInner(n,Math.min(i,r),o,s)===!1)return!1},t.prototype.sliceInner=function(n,i){if(n==0&&i==this.length)return this;var o=this.left.length;return i<=o?this.left.slice(n,i):n>=o?this.right.slice(n-o,i-o):this.left.slice(n,o).append(this.right.slice(0,i-o))},t.prototype.leafAppend=function(n){var i=this.right.leafAppend(n);if(i)return new t(this.left,i)},t.prototype.leafPrepend=function(n){var i=this.left.leafPrepend(n);if(i)return new t(i,this.right)},t.prototype.appendInner=function(n){return this.left.depth>=Math.max(this.right.depth,n.depth)+1?new t(this.left,new t(this.right,n)):new t(this,n)},t})(I),er=I,vh=500,Ce=class qt{constructor(t,n){this.items=t,this.eventCount=n}popEvent(t,n){if(this.eventCount==0)return null;let i=this.items.length;for(;;i--)if(this.items.get(i-1).selection){--i;break}let o,s;n&&(o=this.remapping(i,this.items.length),s=o.maps.length);let r=t.tr,l,a,h=[],c=[];return this.items.forEach((d,p)=>{if(!d.step){o||(o=this.remapping(i,p+1),s=o.maps.length),s--,c.push(d);return}if(o){c.push(new dt(d.map));let u=d.step.map(o.slice(s)),f;u&&r.maybeStep(u).doc&&(f=r.mapping.maps[r.mapping.maps.length-1],h.push(new dt(f,void 0,void 0,h.length+c.length))),s--,f&&o.appendMap(f,s)}else r.maybeStep(d.step);if(d.selection)return l=o?d.selection.map(o.slice(s)):d.selection,a=new qt(this.items.slice(0,i).append(c.reverse().concat(h)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:r,selection:l}}addTransform(t,n,i,o){let s=[],r=this.eventCount,l=this.items,a=!o&&l.length?l.get(l.length-1):null;for(let c=0;c<t.steps.length;c++){let d=t.steps[c].invert(t.docs[c]),p=new dt(t.mapping.maps[c],d,n),u;(u=a&&a.merge(p))&&(p=u,c?s.pop():l=l.slice(0,l.length-1)),s.push(p),n&&(r++,n=void 0),o||(a=p)}let h=r-i.depth;return h>kh&&(l=bh(l,h),r-=h),new qt(l.append(s),r)}remapping(t,n){let i=new Gn;return this.items.forEach((o,s)=>{let r=o.mirrorOffset!=null&&s-o.mirrorOffset>=t?i.maps.length-o.mirrorOffset:void 0;i.appendMap(o.map,r)},t,n),i}addMaps(t){return this.eventCount==0?this:new qt(this.items.append(t.map(n=>new dt(n))),this.eventCount)}rebased(t,n){if(!this.eventCount)return this;n=Math.min(this.items.length,n);let i=[],o=this.items.length-n,s=t.mapping,r=t.steps.length,l=this.eventCount;this.items.forEach(p=>{p.selection&&l--},o);let a=n;this.items.forEach(p=>{let u=s.getMirror(--a);if(u==null)return;r=Math.min(r,u);let f=s.maps[u];if(p.step){let m=t.steps[u].invert(t.docs[u]),g=p.selection&&p.selection.map(s.slice(a+1,u));g&&l++,i.push(new dt(f,m,g))}else i.push(new dt(f))},o);let h=[];for(let p=n;p<r;p++)h.push(new dt(s.maps[p]));let c=this.items.slice(0,o).append(h).append(i),d=new qt(c,l);return d.emptyItemCount()>vh&&(d=d.compress(this.items.length-i.length)),d}emptyItemCount(){let t=0;return this.items.forEach(n=>{n.step||t++}),t}compress(t=this.items.length){let n=this.remapping(0,t),i=n.maps.length,o=[],s=0;return this.items.forEach((r,l)=>{if(l>=t)o.push(r),r.selection&&s++;else if(r.step){let a=r.step.map(n.slice(i)),h=a&&a.getMap();if(i--,h&&n.appendMap(h,i),a){let c=r.selection&&r.selection.map(n.slice(i));c&&s++;let d=new dt(h.invert(),a,c),p,u=o.length-1;(p=o.length&&o[u].merge(d))?o[u]=p:o.push(d)}}else r.map&&i--},this.items.length,0),new qt(er.from(o.reverse()),s)}};Ce.empty=new Ce(er.empty,0);function bh(e,t){let n;return e.forEach((i,o)=>{if(i.selection&&t--==0)return n=o,!1}),e.slice(n)}var dt=class nr{constructor(t,n,i,o){this.map=t,this.step=n,this.selection=i,this.mirrorOffset=o}merge(t){if(this.step&&t.step&&!t.selection){let n=t.step.merge(this.step);if(n)return new nr(n.getMap().invert(),n,this.selection)}}},yt=class{constructor(e,t,n,i,o){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=i,this.prevComposition=o}},kh=20;function xh(e,t,n,i){let o=n.getMeta(et),s;if(o)return o.historyState;n.getMeta(ir)&&(e=new yt(e.done,e.undone,null,0,-1));let r=n.getMeta("appendedTransaction");if(n.steps.length==0)return e;if(r&&r.getMeta(et))return r.getMeta(et).redo?new yt(e.done.addTransform(n,void 0,i,je(t)),e.undone,vo(n.mapping.maps),e.prevTime,e.prevComposition):new yt(e.done,e.undone.addTransform(n,void 0,i,je(t)),null,e.prevTime,e.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(r&&r.getMeta("addToHistory")===!1)){let l=n.getMeta("composition"),a=e.prevTime==0||!r&&e.prevComposition!=l&&(e.prevTime<(n.time||0)-i.newGroupDelay||!Sh(n,e.prevRanges)),h=r?gn(e.prevRanges,n.mapping):vo(n.mapping.maps);return new yt(e.done.addTransform(n,a?t.selection.getBookmark():void 0,i,je(t)),Ce.empty,h,n.time,l??e.prevComposition)}else return(s=n.getMeta("rebased"))?new yt(e.done.rebased(n,s),e.undone.rebased(n,s),gn(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new yt(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),gn(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function Sh(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((i,o)=>{for(let s=0;s<t.length;s+=2)i<=t[s+1]&&o>=t[s]&&(n=!0)}),n}function vo(e){let t=[];for(let n=e.length-1;n>=0&&t.length==0;n--)e[n].forEach((i,o,s,r)=>t.push(s,r));return t}function gn(e,t){if(!e)return null;let n=[];for(let i=0;i<e.length;i+=2){let o=t.map(e[i],1),s=t.map(e[i+1],-1);o<=s&&n.push(o,s)}return n}function Ch(e,t,n){let i=je(t),o=et.get(t).spec.config,s=(n?e.undone:e.done).popEvent(t,i);if(!s)return null;let r=s.selection.resolve(s.transform.doc),l=(n?e.done:e.undone).addTransform(s.transform,t.selection.getBookmark(),o,i),a=new yt(n?l:s.remaining,n?s.remaining:l,null,0,-1);return s.transform.setSelection(r).setMeta(et,{redo:n,historyState:a})}var yn=!1,bo=null;function je(e){let t=e.plugins;if(bo!=t){yn=!1,bo=t;for(let n=0;n<t.length;n++)if(t[n].spec.historyPreserveItems){yn=!0;break}}return yn}function Mh(e){return e.setMeta(ir,!0)}var et=new ni("history"),ir=new ni("closeHistory");function Oh(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new Qt({key:et,state:{init(){return new yt(Ce.empty,Ce.empty,null,0,-1)},apply(t,n,i){return xh(n,i,t,e)}},config:e,props:{handleDOMEvents:{beforeinput(t,n){let i=n.inputType,o=i=="historyUndo"?or:i=="historyRedo"?sr:null;return!o||!t.editable?!1:(n.preventDefault(),o(t.state,t.dispatch))}}}})}function on(e,t){return(n,i)=>{let o=et.getState(n);if(!o||(e?o.undone:o.done).eventCount==0)return!1;if(i){let s=Ch(o,n,e);s&&i(t?s.scrollIntoView():s)}return!0}}var or=on(!1,!0),sr=on(!0,!0),Nh=on(!1,!1),Dh=on(!0,!1);function Th(e){let t=et.getState(e);return t?t.done.eventCount:0}function Eh(e){let t=et.getState(e);return t?t.undone.eventCount:0}function Ah(e){return e.getMeta(et)!=null}var Rh={};ot(Rh,{keydownHandler:()=>pi,keymap:()=>Lh});var kt={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:"'"},Ze={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Ih=typeof navigator<"u"&&/Mac/.test(navigator.platform),Ph=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(D=0;D<10;D++)kt[48+D]=kt[96+D]=String(D);var D;for(D=1;D<=24;D++)kt[D+111]="F"+D;var D;for(D=65;D<=90;D++)kt[D]=String.fromCharCode(D+32),Ze[D]=String.fromCharCode(D);var D;for($e in kt)Ze.hasOwnProperty($e)||(Ze[$e]=kt[$e]);var $e;function zh(e){var t=Ih&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||Ph&&e.shiftKey&&e.key&&e.key.length==1||e.key=="Unidentified",n=!t&&e.key||(e.shiftKey?Ze:kt)[e.keyCode]||e.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 Bh=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),$h=typeof navigator<"u"&&/Win/.test(navigator.platform);function Vh(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n=="Space"&&(n=" ");let i,o,s,r;for(let l=0;l<t.length-1;l++){let a=t[l];if(/^(cmd|meta|m)$/i.test(a))r=!0;else if(/^a(lt)?$/i.test(a))i=!0;else if(/^(c|ctrl|control)$/i.test(a))o=!0;else if(/^s(hift)?$/i.test(a))s=!0;else if(/^mod$/i.test(a))Bh?r=!0:o=!0;else throw new Error("Unrecognized modifier name: "+a)}return i&&(n="Alt-"+n),o&&(n="Ctrl-"+n),r&&(n="Meta-"+n),s&&(n="Shift-"+n),n}function Fh(e){let t=Object.create(null);for(let n in e)t[Vh(n)]=e[n];return t}function wn(e,t,n=!0){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),n&&t.shiftKey&&(e="Shift-"+e),e}function Lh(e){return new Qt({props:{handleKeyDown:pi(e)}})}function pi(e){let t=Fh(e);return function(n,i){let o=zh(i),s,r=t[wn(o,i)];if(r&&r(n.state,n.dispatch,n))return!0;if(o.length==1&&o!=" "){if(i.shiftKey){let l=t[wn(o,i,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((i.altKey||i.metaKey||i.ctrlKey)&&!($h&&i.ctrlKey&&i.altKey)&&(s=kt[i.keyCode])&&s!=o){let l=t[wn(s,i)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var Jh={};ot(Jh,{autoJoin:()=>nc,baseKeymap:()=>oc,chainCommands:()=>sn,createParagraphNear:()=>mr,deleteSelection:()=>fi,exitCode:()=>ur,joinBackward:()=>lr,joinDown:()=>Kh,joinForward:()=>dr,joinTextblockBackward:()=>Wh,joinTextblockForward:()=>qh,joinUp:()=>jh,lift:()=>Hh,liftEmptyBlock:()=>gr,macBaseKeymap:()=>wi,newlineInCode:()=>fr,pcBaseKeymap:()=>_,selectAll:()=>wr,selectNodeBackward:()=>hr,selectNodeForward:()=>pr,selectParentNode:()=>Gh,selectTextblockEnd:()=>xr,selectTextblockStart:()=>kr,setBlockType:()=>Qh,splitBlock:()=>yi,splitBlockAs:()=>yr,splitBlockKeepMarks:()=>Uh,toggleMark:()=>tc,wrapIn:()=>Xh});var fi=(e,t)=>e.selection.empty?!1:(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function rr(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("backward",e):n.parentOffset>0)?null:n}var lr=(e,t,n)=>{let i=rr(e,n);if(!i)return!1;let o=ui(i);if(!o){let r=i.blockRange(),l=r&&Oe(r);return l==null?!1:(t&&t(e.tr.lift(r,l).scrollIntoView()),!0)}let s=o.nodeBefore;if(vr(e,o,t,-1))return!0;if(i.parent.content.size==0&&(Yt(s,"end")||k.isSelectable(s)))for(let r=i.depth;;r--){let l=Ne(e.doc,i.before(r),i.after(r),w.empty);if(l&&l.slice.size<l.to-l.from){if(t){let a=e.tr.step(l);a.setSelection(Yt(s,"end")?x.findFrom(a.doc.resolve(a.mapping.map(o.pos,-1)),-1):k.create(a.doc,o.pos-s.nodeSize)),t(a.scrollIntoView())}return!0}if(r==1||i.node(r-1).childCount>1)break}return s.isAtom&&o.depth==i.depth-1?(t&&t(e.tr.delete(o.pos-s.nodeSize,o.pos).scrollIntoView()),!0):!1},Wh=(e,t,n)=>{let i=rr(e,n);if(!i)return!1;let o=ui(i);return o?ar(e,o,t):!1},qh=(e,t,n)=>{let i=cr(e,n);if(!i)return!1;let o=mi(i);return o?ar(e,o,t):!1};function ar(e,t,n){let i=t.nodeBefore,o=i,s=t.pos-1;for(;!o.isTextblock;s--){if(o.type.spec.isolating)return!1;let c=o.lastChild;if(!c)return!1;o=c}let r=t.nodeAfter,l=r,a=t.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=Ne(e.doc,s,a,w.empty);if(!h||h.from!=s||h instanceof X&&h.slice.size>=a-s)return!1;if(n){let c=e.tr.step(h);c.setSelection(C.create(c.doc,s)),n(c.scrollIntoView())}return!0}function Yt(e,t,n=!1){for(let i=e;i;i=t=="start"?i.firstChild:i.lastChild){if(i.isTextblock)return!0;if(n&&i.childCount!=1)return!1}return!1}var hr=(e,t,n)=>{let{$head:i,empty:o}=e.selection,s=i;if(!o)return!1;if(i.parent.isTextblock){if(n?!n.endOfTextblock("backward",e):i.parentOffset>0)return!1;s=ui(i)}let r=s&&s.nodeBefore;return!r||!k.isSelectable(r)?!1:(t&&t(e.tr.setSelection(k.create(e.doc,s.pos-r.nodeSize)).scrollIntoView()),!0)};function ui(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function cr(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("forward",e):n.parentOffset<n.parent.content.size)?null:n}var dr=(e,t,n)=>{let i=cr(e,n);if(!i)return!1;let o=mi(i);if(!o)return!1;let s=o.nodeAfter;if(vr(e,o,t,1))return!0;if(i.parent.content.size==0&&(Yt(s,"start")||k.isSelectable(s))){let r=Ne(e.doc,i.before(),i.after(),w.empty);if(r&&r.slice.size<r.to-r.from){if(t){let l=e.tr.step(r);l.setSelection(Yt(s,"start")?x.findFrom(l.doc.resolve(l.mapping.map(o.pos)),1):k.create(l.doc,l.mapping.map(o.pos))),t(l.scrollIntoView())}return!0}}return s.isAtom&&o.depth==i.depth-1?(t&&t(e.tr.delete(o.pos,o.pos+s.nodeSize).scrollIntoView()),!0):!1},pr=(e,t,n)=>{let{$head:i,empty:o}=e.selection,s=i;if(!o)return!1;if(i.parent.isTextblock){if(n?!n.endOfTextblock("forward",e):i.parentOffset<i.parent.content.size)return!1;s=mi(i)}let r=s&&s.nodeAfter;return!r||!k.isSelectable(r)?!1:(t&&t(e.tr.setSelection(k.create(e.doc,s.pos)).scrollIntoView()),!0)};function mi(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){let n=e.node(t);if(e.index(t)+1<n.childCount)return e.doc.resolve(e.after(t+1));if(n.type.spec.isolating)break}return null}var jh=(e,t)=>{let n=e.selection,i=n instanceof k,o;if(i){if(n.node.isTextblock||!zt(e.doc,n.from))return!1;o=n.from}else if(o=Zn(e.doc,n.from,-1),o==null)return!1;if(t){let s=e.tr.join(o);i&&s.setSelection(k.create(s.doc,o-e.doc.resolve(o).nodeBefore.nodeSize)),t(s.scrollIntoView())}return!0},Kh=(e,t)=>{let n=e.selection,i;if(n instanceof k){if(n.node.isTextblock||!zt(e.doc,n.to))return!1;i=n.to}else if(i=Zn(e.doc,n.to,1),i==null)return!1;return t&&t(e.tr.join(i).scrollIntoView()),!0},Hh=(e,t)=>{let{$from:n,$to:i}=e.selection,o=n.blockRange(i),s=o&&Oe(o);return s==null?!1:(t&&t(e.tr.lift(o,s).scrollIntoView()),!0)},fr=(e,t)=>{let{$head:n,$anchor:i}=e.selection;return!n.parent.type.spec.code||!n.sameParent(i)?!1:(t&&t(e.tr.insertText(`
|
|
10
|
+
`).scrollIntoView()),!0)};function gi(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}var ur=(e,t)=>{let{$head:n,$anchor:i}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(i))return!1;let o=n.node(-1),s=n.indexAfter(-1),r=gi(o.contentMatchAt(s));if(!r||!o.canReplaceWith(s,s,r))return!1;if(t){let l=n.after(),a=e.tr.replaceWith(l,l,r.createAndFill());a.setSelection(x.near(a.doc.resolve(l),1)),t(a.scrollIntoView())}return!0},mr=(e,t)=>{let n=e.selection,{$from:i,$to:o}=n;if(n instanceof tt||i.parent.inlineContent||o.parent.inlineContent)return!1;let s=gi(o.parent.contentMatchAt(o.indexAfter()));if(!s||!s.isTextblock)return!1;if(t){let r=(!i.parentOffset&&o.index()<o.parent.childCount?i:o).pos,l=e.tr.insert(r,s.createAndFill());l.setSelection(C.create(l.doc,r+1)),t(l.scrollIntoView())}return!0},gr=(e,t)=>{let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let s=n.before();if(fe(e.doc,s))return t&&t(e.tr.split(s).scrollIntoView()),!0}let i=n.blockRange(),o=i&&Oe(i);return o==null?!1:(t&&t(e.tr.lift(i,o).scrollIntoView()),!0)};function yr(e){return(t,n)=>{if(t.selection instanceof k&&t.selection.node.isBlock){let{$from:u}=t.selection;return!u.parentOffset||!fe(t.doc,u.pos)?!1:(n&&n(t.tr.split(u.pos).scrollIntoView()),!0)}if(!t.selection.$from.depth)return!1;let i=t.tr;!t.selection.empty&&(t.selection instanceof C||t.selection instanceof tt)&&i.deleteSelection();let{$from:o}=i.selection,s=i.steps.length,r=[],l,a,h=!1,c=!1;for(let u=o.depth;;u--)if(o.node(u).isBlock){h=o.end(u)==o.pos+(o.depth-u),c=o.start(u)==o.pos-(o.depth-u),a=gi(o.node(u-1).contentMatchAt(o.indexAfter(u-1)));let f=e&&e(o.parent,h,o);r.unshift(f||(h&&a?{type:a}:null)),l=u;break}else{if(u==1)return!1;r.unshift(null)}let d=o.pos,p=fe(i.doc,d,r.length,r);if(p||(r[0]=a?{type:a}:null,p=fe(i.doc,d,r.length,r)),!p)return!1;if(i.split(d,r.length,r),!h&&c&&o.node(l).type!=a){let u=i.mapping.slice(s),f=u.map(o.before(l)),m=i.doc.resolve(f);a&&o.node(l-1).canReplaceWith(m.index(),m.index()+1,a)&&i.setNodeMarkup(u.map(o.before(l)),a)}return n&&n(i.scrollIntoView()),!0}}var yi=yr(),Uh=(e,t)=>yi(e,t&&(n=>{let i=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();i&&n.ensureMarks(i),t(n)})),Gh=(e,t)=>{let{$from:n,to:i}=e.selection,o,s=n.sharedDepth(i);return s==0?!1:(o=n.before(s),t&&t(e.tr.setSelection(k.create(e.doc,o))),!0)},wr=(e,t)=>(t&&t(e.tr.setSelection(new tt(e.doc))),!0);function Yh(e,t,n){let i=t.nodeBefore,o=t.nodeAfter,s=t.index();return!i||!o||!i.type.compatibleContent(o.type)?!1:!i.content.size&&t.parent.canReplace(s-1,s)?(n&&n(e.tr.delete(t.pos-i.nodeSize,t.pos).scrollIntoView()),!0):!t.parent.canReplace(s,s+1)||!(o.isTextblock||zt(e.doc,t.pos))?!1:(n&&n(e.tr.join(t.pos).scrollIntoView()),!0)}function vr(e,t,n,i){let o=t.nodeBefore,s=t.nodeAfter,r,l,a=o.type.spec.isolating||s.type.spec.isolating;if(!a&&Yh(e,t,n))return!0;let h=!a&&t.parent.canReplace(t.index(),t.index()+1);if(h&&(r=(l=o.contentMatchAt(o.childCount)).findWrapping(s.type))&&l.matchType(r[0]||s.type).validEnd){if(n){let u=t.pos+s.nodeSize,f=y.empty;for(let b=r.length-1;b>=0;b--)f=y.from(r[b].create(null,f));f=y.from(o.copy(f));let m=e.tr.step(new nt(t.pos-1,u,t.pos,u,new w(f,1,0),r.length,!0)),g=m.doc.resolve(u+2*r.length);g.nodeAfter&&g.nodeAfter.type==o.type&&zt(m.doc,g.pos)&&m.join(g.pos),n(m.scrollIntoView())}return!0}let c=s.type.spec.isolating||i>0&&a?null:x.findFrom(t,1),d=c&&c.$from.blockRange(c.$to),p=d&&Oe(d);if(p!=null&&p>=t.depth)return n&&n(e.tr.lift(d,p).scrollIntoView()),!0;if(h&&Yt(s,"start",!0)&&Yt(o,"end")){let u=o,f=[];for(;f.push(u),!u.isTextblock;)u=u.lastChild;let m=s,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(u.canReplace(u.childCount,u.childCount,m.content)){if(n){let b=y.empty;for(let O=f.length-1;O>=0;O--)b=y.from(f[O].copy(b));let N=e.tr.step(new nt(t.pos-f.length,t.pos+s.nodeSize,t.pos+g,t.pos+s.nodeSize-g,new w(b,f.length,0),0,!0));n(N.scrollIntoView())}return!0}}return!1}function br(e){return function(t,n){let i=t.selection,o=e<0?i.$from:i.$to,s=o.depth;for(;o.node(s).isInline;){if(!s)return!1;s--}return o.node(s).isTextblock?(n&&n(t.tr.setSelection(C.create(t.doc,e<0?o.start(s):o.end(s)))),!0):!1}}var kr=br(-1),xr=br(1);function Xh(e,t=null){return function(n,i){let{$from:o,$to:s}=n.selection,r=o.blockRange(s),l=r&&Qn(r,e,t);return l?(i&&i(n.tr.wrap(r,l).scrollIntoView()),!0):!1}}function Qh(e,t=null){return function(n,i){let o=!1;for(let s=0;s<n.selection.ranges.length&&!o;s++){let{$from:{pos:r},$to:{pos:l}}=n.selection.ranges[s];n.doc.nodesBetween(r,l,(a,h)=>{if(o)return!1;if(!(!a.isTextblock||a.hasMarkup(e,t)))if(a.type==e)o=!0;else{let c=n.doc.resolve(h),d=c.index();o=c.parent.canReplaceWith(d,d+1,e)}})}if(!o)return!1;if(i){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,e,t)}i(s.scrollIntoView())}return!0}}function Zh(e,t,n,i){for(let o=0;o<t.length;o++){let{$from:s,$to:r}=t[o],l=s.depth==0?e.inlineContent&&e.type.allowsMarkType(n):!1;if(e.nodesBetween(s.pos,r.pos,(a,h)=>{if(l||!i&&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 _h(e){let t=[];for(let n=0;n<e.length;n++){let{$from:i,$to:o}=e[n];i.doc.nodesBetween(i.pos,o.pos,(s,r)=>{if(s.isAtom&&s.content.size&&s.isInline&&r>=i.pos&&r+s.nodeSize<=o.pos)return r+1>i.pos&&t.push(new Ge(i,i.doc.resolve(r+1))),i=i.doc.resolve(r+1+s.content.size),!1}),i.pos<o.pos&&t.push(new Ge(i,o))}return t}function tc(e,t=null,n){let i=(n&&n.removeWhenPresent)!==!1,o=(n&&n.enterInlineAtoms)!==!1,s=!(n&&n.includeWhitespace);return function(r,l){let{empty:a,$cursor:h,ranges:c}=r.selection;if(a&&!h||!Zh(r.doc,c,e,o))return!1;if(l)if(h)e.isInSet(r.storedMarks||h.marks())?l(r.tr.removeStoredMark(e)):l(r.tr.addStoredMark(e.create(t)));else{let d,p=r.tr;o||(c=_h(c)),i?d=!c.some(u=>r.doc.rangeHasMark(u.$from.pos,u.$to.pos,e)):d=!c.every(u=>{let f=!1;return p.doc.nodesBetween(u.$from.pos,u.$to.pos,(m,g,b)=>{if(f)return!1;f=!e.isInSet(m.marks)&&!!b&&b.type.allowsMarkType(e)&&!(m.isText&&/^\s*$/.test(m.textBetween(Math.max(0,u.$from.pos-g),Math.min(m.nodeSize,u.$to.pos-g))))}),!f});for(let u=0;u<c.length;u++){let{$from:f,$to:m}=c[u];if(!d)p.removeMark(f.pos,m.pos,e);else{let g=f.pos,b=m.pos,N=f.nodeAfter,O=m.nodeBefore,Z=s&&N&&N.isText?/^\s*/.exec(N.text)[0].length:0,Ct=s&&O&&O.isText?/\s*$/.exec(O.text)[0].length:0;g+Z<b&&(g+=Z,b-=Ct),p.addMark(g,b,e.create(t))}}l(p.scrollIntoView())}return!0}}function ec(e,t){return n=>{if(!n.isGeneric)return e(n);let i=[];for(let s=0;s<n.mapping.maps.length;s++){let r=n.mapping.maps[s];for(let l=0;l<i.length;l++)i[l]=r.map(i[l]);r.forEach((l,a,h,c)=>i.push(h,c))}let o=[];for(let s=0;s<i.length;s+=2){let r=i[s],l=i[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 u=c.maybeChild(d);if(!u)break;if(d&&o.indexOf(p)==-1){let f=c.child(d-1);f.type==u.type&&t(f,u)&&o.push(p)}p+=u.nodeSize}}o.sort((s,r)=>s-r);for(let s=o.length-1;s>=0;s--)zt(n.doc,o[s])&&n.join(o[s]);e(n)}}function nc(e,t){let n=Array.isArray(t)?i=>t.indexOf(i.type.name)>-1:t;return(i,o,s)=>e(i,o&&ec(o,n),s)}function sn(...e){return function(t,n,i){for(let o=0;o<e.length;o++)if(e[o](t,n,i))return!0;return!1}}var vn=sn(fi,lr,hr),ko=sn(fi,dr,pr),_={Enter:sn(fr,mr,gr,yi),"Mod-Enter":ur,Backspace:vn,"Mod-Backspace":vn,"Shift-Backspace":vn,Delete:ko,"Mod-Delete":ko,"Mod-a":wr},wi={"Ctrl-h":_.Backspace,"Alt-Backspace":_["Mod-Backspace"],"Ctrl-d":_.Delete,"Ctrl-Alt-Backspace":_["Mod-Delete"],"Alt-Delete":_["Mod-Delete"],"Alt-d":_["Mod-Delete"],"Ctrl-a":kr,"Ctrl-e":xr};for(let e in _)wi[e]=_[e];var ic=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1,oc=ic?wi:_,sc={};ot(sc,{InputRule:()=>ct,closeDoubleQuote:()=>Cr,closeSingleQuote:()=>Or,ellipsis:()=>dc,emDash:()=>cc,inputRules:()=>ac,openDoubleQuote:()=>Sr,openSingleQuote:()=>Mr,smartQuotes:()=>pc,textblockTypeInputRule:()=>uc,undoInputRule:()=>hc,wrappingInputRule:()=>fc});var ct=class{constructor(e,t,n={}){this.match=e,this.match=e,this.handler=typeof t=="string"?rc(t):t,this.undoable=n.undoable!==!1,this.inCode=n.inCode||!1,this.inCodeMark=n.inCodeMark!==!1}};function rc(e){return function(t,n,i,o){let s=e;if(n[1]){let r=n[0].lastIndexOf(n[1]);s+=n[0].slice(r+n[1].length),i+=r;let l=i-o;l>0&&(s=n[0].slice(r-l,r)+s,i=o)}return t.tr.insertText(s,i,o)}}var lc=500;function ac({rules:e}){let t=new Qt({state:{init(){return null},apply(n,i){return n.getMeta(this)||(n.selectionSet||n.docChanged?null:i)}},props:{handleTextInput(n,i,o,s){return xo(n,i,o,s,e,t)},handleDOMEvents:{compositionend:n=>{setTimeout(()=>{let{$cursor:i}=n.state.selection;i&&xo(n,i.pos,i.pos,"",e,t)})}}},isInputRules:!0});return t}function xo(e,t,n,i,o,s){if(e.composing)return!1;let r=e.state,l=r.doc.resolve(t),a=l.parent.textBetween(Math.max(0,l.parentOffset-lc),l.parentOffset,null,"\uFFFC")+i;for(let h=0;h<o.length;h++){let c=o[h];if(!c.inCodeMark&&l.marks().some(f=>f.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<i.length)continue;let p=t-(d[0].length-i.length);if(!c.inCodeMark){let f=!1;if(r.doc.nodesBetween(p,l.pos,m=>{m.isInline&&m.marks.some(g=>g.type.spec.code)&&(f=!0)}),f)continue}let u=c.handler(r,d,p,n);if(u)return c.undoable&&u.setMeta(s,{transform:u,from:t,to:n,text:i}),e.dispatch(u),!0}return!1}var hc=(e,t)=>{let n=e.plugins;for(let i=0;i<n.length;i++){let o=n[i],s;if(o.spec.isInputRules&&(s=o.getState(e))){if(t){let r=e.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,e.schema.text(s.text,a))}else r.delete(s.from,s.to);t(r)}return!0}}return!1},cc=new ct(/--$/,"\u2014",{inCodeMark:!1}),dc=new ct(/\.\.\.$/,"\u2026",{inCodeMark:!1}),Sr=new ct(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"\u201C",{inCodeMark:!1}),Cr=new ct(/"$/,"\u201D",{inCodeMark:!1}),Mr=new ct(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"\u2018",{inCodeMark:!1}),Or=new ct(/'$/,"\u2019",{inCodeMark:!1}),pc=[Sr,Cr,Mr,Or];function fc(e,t,n=null,i){return new ct(e,(o,s,r,l)=>{let a=n instanceof Function?n(s):n,h=o.tr.delete(r,l),c=h.doc.resolve(r),d=c.blockRange(),p=d&&Qn(d,t,a);if(!p)return null;h.wrap(d,p);let u=h.doc.resolve(r-1).nodeBefore;return u&&u.type==t&&zt(h.doc,r-1)&&(!i||i(s,u))&&h.join(r-1),h})}function uc(e,t,n=null){return new ct(e,(i,o,s,r)=>{let l=i.doc.resolve(s),a=n instanceof Function?n(o):n;return l.node(-1).canReplaceWith(l.index(-1),l.indexAfter(-1),t)?i.tr.delete(s,r).setBlockType(s,s,t,a):null})}var mc={};ot(mc,{dropCursor:()=>gc});function gc(e={}){return new Qt({view(t){return new yc(t,e)}})}var yc=class{constructor(e,t){var n;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,this.width=(n=t.width)!==null&&n!==void 0?n:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let o=s=>{this[i](s)};return e.dom.addEventListener(i,o),{name:i,handler:o}})}destroy(){this.setCursor(null),this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){if(this.cursorPos!=null&&t.doc!=e.state.doc)if(this.lastDragEvent){let n=this.computeTarget(this.lastDragEvent);n==this.cursorPos?this.updateOverlay():this.setCursor(n)}else this.updateOverlay()}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,n,i=this.editorView.dom,o=i.getBoundingClientRect(),s=o.width/i.offsetWidth,r=o.height/i.offsetHeight;if(t){let c=e.nodeBefore,d=e.nodeAfter;if(c||d){let p=this.editorView.nodeDOM(this.cursorPos-(c?c.nodeSize:0));if(p){let u=p.getBoundingClientRect(),f=c?u.bottom:u.top;c&&d&&(f=(f+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let m=this.width/2*r;n={left:u.left,right:u.right,top:f-m,bottom:f+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",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);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(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}computeTarget(e){let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),i=n&&n.type.spec.disableDropCursor,o=typeof i=="function"?i(this.editorView,t,e):i;if(!t||o)return null;let s=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let r=_n(this.editorView.state.doc,s,this.editorView.dragging.slice);r!=null&&(s=r)}return s}dragover(e){if(!this.editorView.editable)return;this.lastDragEvent=e;let t=this.computeTarget(e);t!=null&&(this.setCursor(t),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}},wc={};ot(wc,{GapCursor:()=>q,gapCursor:()=>xc});var q=class mt extends x{constructor(t){super(t,t)}map(t,n){let i=t.resolve(n.map(this.head));return mt.valid(i)?new mt(i):x.near(i)}content(){return w.empty}eq(t){return t instanceof mt&&t.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(t,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new mt(t.resolve(n.pos))}getBookmark(){return new vc(this.anchor)}static valid(t){let n=t.parent;if(n.inlineContent||!bc(t)||!kc(t))return!1;let i=n.type.spec.allowGapCursor;if(i!=null)return i;let o=n.contentMatchAt(t.index()).defaultType;return o&&o.isTextblock}static findGapCursorFrom(t,n,i=!1){t:for(;;){if(!i&&mt.valid(t))return t;let o=t.pos,s=null;for(let r=t.depth;;r--){let l=t.node(r);if(n>0?t.indexAfter(r)<l.childCount:t.index(r)>0){s=l.child(n>0?t.indexAfter(r):t.index(r)-1);break}else if(r==0)return null;o+=n;let a=t.doc.resolve(o);if(mt.valid(a))return a}for(;;){let r=n>0?s.firstChild:s.lastChild;if(!r){if(s.isAtom&&!s.isText&&!k.isSelectable(s)){t=t.doc.resolve(o+s.nodeSize*n),i=!1;continue t}break}s=r,o+=n;let l=t.doc.resolve(o);if(mt.valid(l))return l}return null}}};q.prototype.visible=!1;q.findFrom=q.findGapCursorFrom;x.jsonID("gapcursor",q);var vc=class Nr{constructor(t){this.pos=t}map(t){return new Nr(t.map(this.pos))}resolve(t){let n=t.resolve(this.pos);return q.valid(n)?new q(n):x.near(n)}};function Dr(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function bc(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),i=e.node(t);if(n==0){if(i.type.spec.isolating)return!0;continue}for(let o=i.child(n-1);;o=o.lastChild){if(o.childCount==0&&!o.inlineContent||Dr(o.type))return!0;if(o.inlineContent)return!1}}return!0}function kc(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),i=e.node(t);if(n==i.childCount){if(i.type.spec.isolating)return!0;continue}for(let o=i.child(n);;o=o.firstChild){if(o.childCount==0&&!o.inlineContent||Dr(o.type))return!0;if(o.inlineContent)return!1}}return!0}function xc(){return new Qt({props:{decorations:Oc,createSelectionBetween(e,t,n){return t.pos==n.pos&&q.valid(n)?new q(n):null},handleClick:Cc,handleKeyDown:Sc,handleDOMEvents:{beforeinput:Mc}}})}var Sc=pi({ArrowLeft:Ve("horiz",-1),ArrowRight:Ve("horiz",1),ArrowUp:Ve("vert",-1),ArrowDown:Ve("vert",1)});function Ve(e,t){let n=e=="vert"?t>0?"down":"up":t>0?"right":"left";return function(i,o,s){let r=i.selection,l=t>0?r.$to:r.$from,a=r.empty;if(r instanceof C){if(!s.endOfTextblock(n)||l.depth==0)return!1;a=!1,l=i.doc.resolve(t>0?l.after():l.before())}let h=q.findGapCursorFrom(l,t,a);return h?(o&&o(i.tr.setSelection(new q(h))),!0):!1}}function Cc(e,t,n){if(!e||!e.editable)return!1;let i=e.state.doc.resolve(t);if(!q.valid(i))return!1;let o=e.posAtCoords({left:n.clientX,top:n.clientY});return o&&o.inside>-1&&k.isSelectable(e.state.doc.nodeAt(o.inside))?!1:(e.dispatch(e.state.tr.setSelection(new q(i))),!0)}function Mc(e,t){if(t.inputType!="insertCompositionText"||!(e.state.selection instanceof q))return!1;let{$from:n}=e.state.selection,i=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!i)return!1;let o=y.empty;for(let r=i.length-1;r>=0;r--)o=y.from(i[r].createAndFill(null,o));let s=e.state.tr.replace(n.pos,n.pos,new w(o,0,0));return s.setSelection(C.near(s.doc.resolve(n.pos+1))),e.dispatch(s),!1}function Oc(e){if(!(e.selection instanceof q))return null;let t=document.createElement("div");return t.className="ProseMirror-gapcursor",Y.create(e.doc,[St.widget(e.selection.head,t,{key:"gapcursor"})])}export{Ar as a,il as b,ol as c,El as d,yh as e,Rh as f,Jh as g,sc as h,wc as i};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{y as O}from"./c-ZRGEN6QQ.js";import{A as $,d as N,y as x,z as C}from"./c-OH2FPYSY.js";import{a as A}from"./c-RETTCOWO.js";import"./c-VHNSBD2M.js";var g=N.nodes,H=e=>e.attrs.parent??null,_=e=>{let a=new Set;return e.forEach(t=>t.forEach(o=>a.add(o.attrs.col))),C(e.attrs.cols).filter(t=>a.has(t))};function S(e,a){let t=a.ownerDocument,o=t.createElement("thead").appendChild(t.createElement("tr"));for(let s of _(e)){let p=e.attrs.cols[s],r=o.appendChild(t.createElement("th"));r.setAttribute("data-col",s),r.setAttribute("scope","col"),p.kind&&r.setAttribute("data-kind",p.kind),p.width&&(r.setAttribute("data-width",String(p.width)),r.style.width=`${p.width}px`),r.textContent=p.name??""}a.prepend(o.parentNode),e.attrs.sort&&a.setAttribute("data-sort",JSON.stringify(e.attrs.sort))}function v(e,a){let t=[];e.forEach((o,s,p)=>{let r=a[p];if(!r||r.nodeType!==1)return;if(o.type===g.table&&S(o,r),o.type!==g.list_item||H(o)!==null){t=[];return}let f=r.ownerDocument,{indent:d,kind:i}=o.attrs,l=i==="ordered"?"OL":"UL";for(;t.length&&t.at(-1).indent>d;)t.pop();if(t.at(-1)?.indent===d&&t.at(-1).list.tagName!==l&&t.pop(),!t.length||t.at(-1).indent<d){let c=f.createElement(l);t.length?t.at(-1).li.append(c):r.before(c),t.push({indent:d,list:c,li:null})}let u=f.createElement("li");i==="check"&&(u.innerHTML=`<input type="checkbox" disabled${o.attrs.checked?" checked":""}>`),u.append(...r.childNodes),t.at(-1).list.append(u),t.at(-1).li=u,r.remove()})}var T=e=>/[\t\n\r"]/.test(e)?`"${e.replace(/"/g,'""')}"`:e;function q(e){if(!e.content.firstChild?.type.spec.group?.includes("block"))return null;let a="",t=[],o=!1;return e.content.forEach((s,p,r)=>{let f=s.type===g.list_item,d=s.textBetween(0,s.content.size,`
|
|
2
|
+
|
|
3
|
+
`);if(f){let{indent:i,kind:l}=s.attrs;for(;t.length&&t.at(-1).indent>i;)t.pop();t.at(-1)?.indent===i&&t.at(-1).kind!==l&&t.pop(),(!t.length||t.at(-1).indent<i)&&t.push({indent:i,kind:l,n:0});let u=t.at(-1),c=l==="ordered"?`${++u.n}.`:l==="check"?`- [${s.attrs.checked?"x":" "}]`:"-";d=`${" ".repeat(t.length-1)}${c} ${d}`}else t=[];if(s.type===g.table){let i=[_(s).map(l=>T(s.attrs.cols[l].name??""))];s.forEach(l=>{let u=[];l.forEach(c=>u.push(T(c.textContent))),i.push(u)}),d=i.map(l=>l.join(" ")).join(`
|
|
4
|
+
`)}a+=(r?o&&f?`
|
|
5
|
+
`:`
|
|
6
|
+
|
|
7
|
+
`:"")+d,o=f}),a}var b=new WeakMap;function w(e){if(b.has(e))return b.get(e);let a=n=>[...n.children].filter(h=>h.tagName==="TD"||h.tagName==="TH"),t=[...e.querySelectorAll("tr")].filter(n=>n.closest("table")===e),o=t.find(n=>n.parentElement.tagName==="THEAD")??(t.length>1&&a(t[0]).every(n=>n.tagName==="TH")?t[0]:null),s=t.filter(n=>n!==o),p=o?a(o):[],r=Math.max(1,p.length,...s.map(n=>a(n).length)),f=x(null,null,r),d=[],i={};for(let n=0;n<r;n++){let h=p[n],m=h?.getAttribute("data-col");(!m||Object.hasOwn(i,m))&&(m=$("c"));let y=h?.getAttribute("data-kind"),E=Math.round(Number(h?.getAttribute("data-width")));i[m]={pos:f[n],name:h?.textContent.replace(/\s+/g," ").trim()||`Column ${n+1}`,...y?{kind:y}:{},...E>0?{width:E}:{}},d.push(m)}let l=(n,h)=>n?O.parse(n,{topNode:g.table_cell.create({col:h})}):g.table_cell.create({col:h}),u=(s.length?s:[null]).map(n=>g.table_row.create(null,d.map((h,m)=>l(n&&a(n)[m],h)))),c=null;try{c=JSON.parse(e.getAttribute("data-sort"))}catch{}let k={cols:i,sort:c&&d.includes(c.col)&&(c.dir==="asc"||c.dir==="desc")?{col:c.col,dir:c.dir}:null,rows:A.Fragment.from(u)};return b.set(e,k),k}var B=e=>({cols:w(e).cols,sort:w(e).sort,parent:e.getAttribute("data-blockeditor-parent")||null}),I=e=>w(e).rows;export{v as copy,I as rows,B as table,q as text};
|