dsh-npie-reader 0.0.0-stage → 0.87.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13852 -0
- package/LICENSE +21 -0
- package/README.md +316 -2
- package/THIRD-PARTY-NOTICES.md +82 -0
- package/cordis.patch.yml +8 -0
- package/lib/client.js +38321 -0
- package/lib/index.js +21070 -0
- package/package.json +109 -4
- package/src/host/ocr-vision.js +66 -0
- package/vendor/chinese-independent-blogs/LICENSE +21 -0
- package/vendor/editor/LICENSE +21 -0
- package/vendor/editor/editor.mjs +49 -0
- package/vendor/pdfjs/README.md +45 -0
- package/vendor/pdfjs/cmaps/78-EUC-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/78-EUC-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/78-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/78-RKSJ-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/78-RKSJ-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/78-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/78ms-RKSJ-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/78ms-RKSJ-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/83pv-RKSJ-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/90ms-RKSJ-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/90ms-RKSJ-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/90msp-RKSJ-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/90msp-RKSJ-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/90pv-RKSJ-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/90pv-RKSJ-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/Add-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/Add-RKSJ-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/Add-RKSJ-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/Add-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/Adobe-CNS1-0.bcmap +0 -0
- package/vendor/pdfjs/cmaps/Adobe-CNS1-1.bcmap +0 -0
- package/vendor/pdfjs/cmaps/Adobe-CNS1-2.bcmap +0 -0
- package/vendor/pdfjs/cmaps/Adobe-CNS1-3.bcmap +0 -0
- package/vendor/pdfjs/cmaps/Adobe-CNS1-4.bcmap +0 -0
- package/vendor/pdfjs/cmaps/Adobe-CNS1-5.bcmap +0 -0
- package/vendor/pdfjs/cmaps/Adobe-CNS1-6.bcmap +0 -0
- package/vendor/pdfjs/cmaps/Adobe-CNS1-UCS2.bcmap +0 -0
- package/vendor/pdfjs/cmaps/Adobe-GB1-0.bcmap +0 -0
- package/vendor/pdfjs/cmaps/Adobe-GB1-1.bcmap +0 -0
- package/vendor/pdfjs/cmaps/Adobe-GB1-2.bcmap +0 -0
- package/vendor/pdfjs/cmaps/Adobe-GB1-3.bcmap +0 -0
- package/vendor/pdfjs/cmaps/Adobe-GB1-4.bcmap +0 -0
- package/vendor/pdfjs/cmaps/Adobe-GB1-5.bcmap +0 -0
- package/vendor/pdfjs/cmaps/Adobe-GB1-UCS2.bcmap +0 -0
- package/vendor/pdfjs/cmaps/Adobe-Japan1-0.bcmap +0 -0
- package/vendor/pdfjs/cmaps/Adobe-Japan1-1.bcmap +0 -0
- package/vendor/pdfjs/cmaps/Adobe-Japan1-2.bcmap +0 -0
- package/vendor/pdfjs/cmaps/Adobe-Japan1-3.bcmap +0 -0
- package/vendor/pdfjs/cmaps/Adobe-Japan1-4.bcmap +0 -0
- package/vendor/pdfjs/cmaps/Adobe-Japan1-5.bcmap +0 -0
- package/vendor/pdfjs/cmaps/Adobe-Japan1-6.bcmap +0 -0
- package/vendor/pdfjs/cmaps/Adobe-Japan1-UCS2.bcmap +0 -0
- package/vendor/pdfjs/cmaps/Adobe-Korea1-0.bcmap +0 -0
- package/vendor/pdfjs/cmaps/Adobe-Korea1-1.bcmap +0 -0
- package/vendor/pdfjs/cmaps/Adobe-Korea1-2.bcmap +0 -0
- package/vendor/pdfjs/cmaps/Adobe-Korea1-UCS2.bcmap +0 -0
- package/vendor/pdfjs/cmaps/B5-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/B5-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/B5pc-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/B5pc-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/CNS-EUC-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/CNS-EUC-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/CNS1-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/CNS1-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/CNS2-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/CNS2-V.bcmap +3 -0
- package/vendor/pdfjs/cmaps/ETHK-B5-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/ETHK-B5-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/ETen-B5-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/ETen-B5-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/ETenms-B5-H.bcmap +3 -0
- package/vendor/pdfjs/cmaps/ETenms-B5-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/EUC-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/EUC-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/Ext-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/Ext-RKSJ-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/Ext-RKSJ-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/Ext-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/GB-EUC-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/GB-EUC-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/GB-H.bcmap +4 -0
- package/vendor/pdfjs/cmaps/GB-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/GBK-EUC-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/GBK-EUC-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/GBK2K-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/GBK2K-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/GBKp-EUC-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/GBKp-EUC-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/GBT-EUC-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/GBT-EUC-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/GBT-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/GBT-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/GBTpc-EUC-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/GBTpc-EUC-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/GBpc-EUC-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/GBpc-EUC-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/HKdla-B5-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/HKdla-B5-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/HKdlb-B5-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/HKdlb-B5-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/HKgccs-B5-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/HKgccs-B5-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/HKm314-B5-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/HKm314-B5-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/HKm471-B5-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/HKm471-B5-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/HKscs-B5-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/HKscs-B5-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/Hankaku.bcmap +0 -0
- package/vendor/pdfjs/cmaps/Hiragana.bcmap +0 -0
- package/vendor/pdfjs/cmaps/KSC-EUC-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/KSC-EUC-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/KSC-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/KSC-Johab-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/KSC-Johab-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/KSC-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/KSCms-UHC-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/KSCms-UHC-HW-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/KSCms-UHC-HW-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/KSCms-UHC-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/KSCpc-EUC-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/KSCpc-EUC-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/Katakana.bcmap +0 -0
- package/vendor/pdfjs/cmaps/NWP-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/NWP-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/RKSJ-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/RKSJ-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/Roman.bcmap +0 -0
- package/vendor/pdfjs/cmaps/UniCNS-UCS2-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/UniCNS-UCS2-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/UniCNS-UTF16-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/UniCNS-UTF16-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/UniCNS-UTF32-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/UniCNS-UTF32-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/UniCNS-UTF8-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/UniCNS-UTF8-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/UniGB-UCS2-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/UniGB-UCS2-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/UniGB-UTF16-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/UniGB-UTF16-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/UniGB-UTF32-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/UniGB-UTF32-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/UniGB-UTF8-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/UniGB-UTF8-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/UniJIS-UCS2-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/UniJIS-UCS2-HW-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/UniJIS-UCS2-HW-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/UniJIS-UCS2-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/UniJIS-UTF16-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/UniJIS-UTF16-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/UniJIS-UTF32-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/UniJIS-UTF32-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/UniJIS-UTF8-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/UniJIS-UTF8-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/UniJIS2004-UTF16-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/UniJIS2004-UTF16-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/UniJIS2004-UTF32-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/UniJIS2004-UTF32-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/UniJIS2004-UTF8-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/UniJIS2004-UTF8-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/UniJISPro-UCS2-HW-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/UniJISPro-UCS2-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/UniJISPro-UTF8-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/UniJISX0213-UTF32-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/UniJISX0213-UTF32-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/UniJISX02132004-UTF32-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/UniJISX02132004-UTF32-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/UniKS-UCS2-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/UniKS-UCS2-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/UniKS-UTF16-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/UniKS-UTF16-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/UniKS-UTF32-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/UniKS-UTF32-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/UniKS-UTF8-H.bcmap +0 -0
- package/vendor/pdfjs/cmaps/UniKS-UTF8-V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/V.bcmap +0 -0
- package/vendor/pdfjs/cmaps/WP-Symbol.bcmap +0 -0
- package/vendor/pdfjs/pdf.mjs +27 -0
- package/vendor/pdfjs/pdf.worker.mjs +27 -0
- package/vendor/pdfjs/standard_fonts/FoxitDingbats.pfb +0 -0
- package/vendor/pdfjs/standard_fonts/FoxitFixed.pfb +0 -0
- package/vendor/pdfjs/standard_fonts/FoxitFixedBold.pfb +0 -0
- package/vendor/pdfjs/standard_fonts/FoxitFixedBoldItalic.pfb +0 -0
- package/vendor/pdfjs/standard_fonts/FoxitFixedItalic.pfb +0 -0
- package/vendor/pdfjs/standard_fonts/FoxitSerif.pfb +0 -0
- package/vendor/pdfjs/standard_fonts/FoxitSerifBold.pfb +0 -0
- package/vendor/pdfjs/standard_fonts/FoxitSerifBoldItalic.pfb +0 -0
- package/vendor/pdfjs/standard_fonts/FoxitSerifItalic.pfb +0 -0
- package/vendor/pdfjs/standard_fonts/FoxitSymbol.pfb +0 -0
- package/vendor/pdfjs/standard_fonts/LiberationSans-Bold.ttf +0 -0
- package/vendor/pdfjs/standard_fonts/LiberationSans-BoldItalic.ttf +0 -0
- package/vendor/pdfjs/standard_fonts/LiberationSans-Italic.ttf +0 -0
- package/vendor/pdfjs/standard_fonts/LiberationSans-Regular.ttf +0 -0
- package/vendor/pdfjs/wasm/LICENSE_JBIG2 +196 -0
- package/vendor/pdfjs/wasm/LICENSE_OPENJPEG +39 -0
- package/vendor/pdfjs/wasm/LICENSE_QCMS +21 -0
- package/vendor/pdfjs/wasm/jbig2.wasm +0 -0
- package/vendor/pdfjs/wasm/jbig2_nowasm_fallback.js +15 -0
- package/vendor/pdfjs/wasm/openjpeg.wasm +0 -0
- package/vendor/pdfjs/wasm/openjpeg_nowasm_fallback.js +17 -0
- package/vendor/pdfjs/wasm/qcms_bg.wasm +0 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
var am=Object.create;var cs=Object.defineProperty;var um=Object.getOwnPropertyDescriptor;var cm=Object.getOwnPropertyNames;var fm=Object.getPrototypeOf,hm=Object.prototype.hasOwnProperty;var dm=(n,e)=>()=>{try{return e||n((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}},pm=(n,e)=>{for(var t in e)cs(n,t,{get:e[t],enumerable:!0})},mm=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of cm(e))!hm.call(n,i)&&i!==t&&cs(n,i,{get:()=>e[i],enumerable:!(r=um(e,i))||r.enumerable});return n};var gm=(n,e,t)=>(t=n!=null?am(fm(n)):{},mm(e||!n||!n.__esModule?cs(t,"default",{value:n,enumerable:!0}):t,n));var ef=dm((UI,Zc)=>{"use strict";var Zi=Object.prototype.hasOwnProperty,Xc=Object.prototype.toString,Kc=Object.defineProperty,Uc=Object.getOwnPropertyDescriptor,Jc=function(e){return typeof Array.isArray=="function"?Array.isArray(e):Xc.call(e)==="[object Array]"},Gc=function(e){if(!e||Xc.call(e)!=="[object Object]")return!1;var t=Zi.call(e,"constructor"),r=e.constructor&&e.constructor.prototype&&Zi.call(e.constructor.prototype,"isPrototypeOf");if(e.constructor&&!t&&!r)return!1;var i;for(i in e);return typeof i>"u"||Zi.call(e,i)},Qc=function(e,t){Kc&&t.name==="__proto__"?Kc(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},Yc=function(e,t){if(t==="__proto__")if(Zi.call(e,t)){if(Uc)return Uc(e,t).value}else return;return e[t]};Zc.exports=function n(){var e,t,r,i,o,s,l=arguments[0],a=1,u=arguments.length,c=!1;for(typeof l=="boolean"&&(c=l,l=arguments[1]||{},a=2),(l==null||typeof l!="object"&&typeof l!="function")&&(l={});a<u;++a)if(e=arguments[a],e!=null)for(t in e)r=Yc(l,t),i=Yc(e,t),l!==i&&(c&&i&&(Gc(i)||(o=Jc(i)))?(o?(o=!1,s=r&&Jc(r)?r:[]):s=r&&Gc(r)?r:{},Qc(l,{name:t,newValue:n(c,s,i)})):typeof i<"u"&&Qc(l,{name:t,newValue:i}));return l}});var $e=(function(n){return n.docTypeError="docTypeError",n.contextNotFound="contextNotFound",n.timerNotFound="timerNotFound",n.ctxCallOutOfScope="ctxCallOutOfScope",n.createNodeInParserFail="createNodeInParserFail",n.stackOverFlow="stackOverFlow",n.parserMatchError="parserMatchError",n.serializerMatchError="serializerMatchError",n.getAtomFromSchemaFail="getAtomFromSchemaFail",n.expectDomTypeError="expectDomTypeError",n.callCommandBeforeEditorView="callCommandBeforeEditorView",n.missingRootElement="missingRootElement",n.missingNodeInSchema="missingNodeInSchema",n.missingMarkInSchema="missingMarkInSchema",n.ctxNotBind="ctxNotBind",n.missingYjsDoc="missingYjsDoc",n.aiProviderError="aiProviderError",n.aiBuildContextError="aiBuildContextError",n})({}),je=class extends Error{constructor(n,e,t){super(e,t),this.name="MilkdownError",this.code=n,t?.cause!==void 0&&(this.cause=t.cause)}},ym=(n,e)=>typeof e=="function"?"[Function]":e,Ti=n=>JSON.stringify(n,ym);function Mu(n){return new je($e.docTypeError,`Doc type error, unsupported type: ${Ti(n)}`)}function Nu(n){return new je($e.contextNotFound,`Context "${n}" not found, do you forget to inject it?`)}function Iu(n){return new je($e.timerNotFound,`Timer "${n}" not found, do you forget to record it?`)}function En(){return new je($e.ctxCallOutOfScope,"Should not call a context out of the plugin.")}function Eu(n,e,t){let r=`Cannot create node for ${"name"in n?n.name:n}`,i=s=>{if(s==null)return"null";if(Array.isArray(s))return`[${s.map(i).join(", ")}]`;if(typeof s=="object")return"toJSON"in s&&typeof s.toJSON=="function"?JSON.stringify(s.toJSON()):"spec"in s?JSON.stringify(s.spec):JSON.stringify(s);if(typeof s=="string"||typeof s=="number"||typeof s=="boolean")return JSON.stringify(s);if(typeof s=="function")return`[Function: ${s.name||"anonymous"}]`;try{return String(s)}catch{return"[Unserializable]"}},o=[["[Description]",r],["[Attributes]",e],["[Content]",(t??[]).map(s=>s?typeof s=="object"&&"type"in s?`${s}`:i(s):"null")]].reduce((s,[l,a])=>{let u=`${l}: ${i(a)}.`;return s.concat(u)},[]);return new je($e.createNodeInParserFail,o.join(`
|
|
2
|
+
`))}function fs(){return new je($e.stackOverFlow,"Stack over flow, cannot pop on an empty stack.")}function Ou(n){return new je($e.parserMatchError,`Cannot match target parser for node: ${Ti(n)}.`)}function Tu(n){return new je($e.serializerMatchError,`Cannot match target serializer for node: ${Ti(n)}.`)}function Nt(n){return new je($e.expectDomTypeError,`Expect to be a dom, but get: ${Ti(n)}.`)}function Ai(){return new je($e.callCommandBeforeEditorView,"You're trying to call a command before editor view initialized, make sure to get commandManager from ctx after editor view has been initialized")}function Au(n){return new je($e.missingNodeInSchema,`Missing node in schema, milkdown cannot find "${n}" in schema.`)}function vu(n){return new je($e.missingMarkInSchema,`Missing mark in schema, milkdown cannot find "${n}" in schema.`)}var hs=class{constructor(){this.sliceMap=new Map,this.get=n=>{let e=typeof n=="string"?[...this.sliceMap.values()].find(t=>t.type.name===n):this.sliceMap.get(n.id);if(!e){let t=typeof n=="string"?n:n.name;throw Nu(t)}return e},this.remove=n=>{let e=typeof n=="string"?[...this.sliceMap.values()].find(t=>t.type.name===n):this.sliceMap.get(n.id);e&&this.sliceMap.delete(e.type.id)},this.has=n=>typeof n=="string"?[...this.sliceMap.values()].some(e=>e.type.name===n):this.sliceMap.has(n.id)}},xm=class{#t;#e;#r;constructor(n,e,t){this.#t=[],this.#r=()=>{this.#t.forEach(r=>r(this.#e))},this.set=r=>{this.#e=r,this.#r()},this.get=()=>this.#e,this.update=r=>{this.#e=r(this.#e),this.#r()},this.type=t,this.#e=e,n.set(t.id,this)}on(n){return this.#t.push(n),()=>{this.#t=this.#t.filter(e=>e!==n)}}once(n){let e=this.on(t=>{n(t),e()});return e}off(n){this.#t=this.#t.filter(e=>e!==n)}offAll(){this.#t=[]}},km=class{constructor(n,e){this.id=Symbol(`Context-${e}`),this.name=e,this._defaultValue=n,this._typeInfo=()=>{throw En()}}create(n,e=this._defaultValue){return new xm(n,e,this)}},$=(n,e)=>new km(n,e),bm=class{#t;#e;#r;#n;#o;#s;#i;constructor(n,e,t){this.#n=new Set,this.#o=new Set,this.#s=new Map,this.#i=new Map,this.read=()=>({metadata:this.#t,injectedSlices:[...this.#n].map(r=>({name:typeof r=="string"?r:r.name,value:this.#l(r)})),consumedSlices:[...this.#o].map(r=>({name:typeof r=="string"?r:r.name,value:this.#l(r)})),recordedTimers:[...this.#s].map(([r,{duration:i}])=>({name:r.name,duration:i,status:this.#a(r)})),waitTimers:[...this.#i].map(([r,{duration:i}])=>({name:r.name,duration:i,status:this.#a(r)}))}),this.onRecord=r=>{this.#s.set(r,{start:Date.now(),duration:0})},this.onClear=r=>{this.#s.delete(r)},this.onDone=r=>{let i=this.#s.get(r);i&&(i.duration=Date.now()-i.start)},this.onWait=(r,i)=>{let o=Date.now();i.finally(()=>{this.#i.set(r,{duration:Date.now()-o})}).catch(console.error)},this.onInject=r=>{this.#n.add(r)},this.onRemove=r=>{this.#n.delete(r)},this.onUse=r=>{this.#o.add(r)},this.#l=r=>this.#e.get(r).get(),this.#a=r=>this.#r.get(r).status,this.#e=n,this.#r=e,this.#t=t}#l;#a},Du=class Ru{#t;#e;#r;#n;constructor(e,t,r){this.produce=i=>i&&Object.keys(i).length?new Ru(this.#t,this.#e,{...i}):this,this.inject=(i,o)=>{let s=i.create(this.#t.sliceMap);return o!=null&&s.set(o),this.#n?.onInject(i),this},this.remove=i=>(this.#t.remove(i),this.#n?.onRemove(i),this),this.record=i=>(i.create(this.#e.store),this.#n?.onRecord(i),this),this.clearTimer=i=>(this.#e.remove(i),this.#n?.onClear(i),this),this.isInjected=i=>this.#t.has(i),this.isRecorded=i=>this.#e.has(i),this.use=i=>(this.#n?.onUse(i),this.#t.get(i)),this.get=i=>this.use(i).get(),this.set=(i,o)=>this.use(i).set(o),this.update=(i,o)=>this.use(i).update(o),this.timer=i=>this.#e.get(i),this.done=i=>{this.timer(i).done(),this.#n?.onDone(i)},this.wait=i=>{let o=this.timer(i).start();return this.#n?.onWait(i,o),o},this.waitTimers=async i=>{await Promise.all(this.get(i).map(o=>this.wait(o)))},this.#t=e,this.#e=t,this.#r=r,r&&(this.#n=new bm(e,t,r))}get meta(){return this.#r}get inspector(){return this.#n}},Pu=class{constructor(){this.store=new Map,this.get=n=>{let e=this.store.get(n.id);if(!e)throw Iu(n.name);return e},this.remove=n=>{this.store.delete(n.id)},this.has=n=>this.store.has(n.id)}},Sm=class{#t;#e;#r;#n;#o;constructor(n,e){this.#t=null,this.#e=null,this.#n="pending",this.#o=null,this.start=()=>(this.#t??=new Promise((t,r)=>{this.#e=i=>{i instanceof CustomEvent&&i.detail.id===this.#r&&(this.#n="resolved",this.#s(),i.stopImmediatePropagation(),t())},this.#i(()=>{this.#n==="pending"&&(this.#n="rejected"),this.#s(),r(new Error(`Timing ${this.type.name} timeout.`))}),this.#n="pending",addEventListener(this.type.name,this.#e)}),this.#t),this.done=()=>{let t=new CustomEvent(this.type.name,{detail:{id:this.#r}});dispatchEvent(t)},this.#s=()=>{this.#o!==null&&(clearTimeout(this.#o),this.#o=null),this.#e&&removeEventListener(this.type.name,this.#e)},this.#i=t=>{this.#o=setTimeout(()=>{this.#o=null,t()},this.type.timeout)},this.#r=Symbol(e.name),this.type=e,n.set(e.id,this)}get status(){return this.#n}#s;#i},wm=class{constructor(n,e=3e3){this.create=t=>new Sm(t,this),this.id=Symbol(`Timer-${n}`),this.name=n,this.timeout=e}},qe=(n,e=3e3)=>new wm(n,e);var Cm={};function Ht(n,e){let t=e||Cm,r=typeof t.includeImageAlt=="boolean"?t.includeImageAlt:!0,i=typeof t.includeHtml=="boolean"?t.includeHtml:!0;return Lu(n,r,i)}function Lu(n,e,t){if(Mm(n)){if("value"in n)return n.type==="html"&&!t?"":n.value;if(e&&"alt"in n&&n.alt)return n.alt;if("children"in n)return Bu(n.children,e,t)}return Array.isArray(n)?Bu(n,e,t):""}function Bu(n,e,t){let r=[],i=-1;for(;++i<n.length;)r[i]=Lu(n[i],e,t);return r.join("")}function Mm(n){return!!(n&&typeof n=="object")}var zu=document.createElement("i");function On(n){let e="&"+n+";";zu.innerHTML=e;let t=zu.textContent;return t.charCodeAt(t.length-1)===59&&n!=="semi"||t===e?!1:t}function Te(n,e,t,r){let i=n.length,o=0,s;if(e<0?e=-e>i?0:i+e:e=e>i?i:e,t=t>0?t:0,r.length<1e4)s=Array.from(r),s.unshift(e,t),n.splice(...s);else for(t&&n.splice(e,t);o<r.length;)s=r.slice(o,o+1e4),s.unshift(e,0),n.splice(...s),o+=1e4,e+=1e4}function we(n,e){return n.length>0?(Te(n,n.length,0,e),n):e}var Fu={}.hasOwnProperty;function _u(n){let e={},t=-1;for(;++t<n.length;)Nm(e,n[t]);return e}function Nm(n,e){let t;for(t in e){let i=(Fu.call(n,t)?n[t]:void 0)||(n[t]={}),o=e[t],s;if(o)for(s in o){Fu.call(i,s)||(i[s]=[]);let l=o[s];Im(i[s],Array.isArray(l)?l:l?[l]:[])}}}function Im(n,e){let t=-1,r=[];for(;++t<e.length;)(e[t].add==="after"?n:r).push(e[t]);Te(n,0,0,r)}function vi(n,e){let t=Number.parseInt(n,e);return t<9||t===11||t>13&&t<32||t>126&&t<160||t>55295&&t<57344||t>64975&&t<65008||(t&65535)===65535||(t&65535)===65534||t>1114111?"\uFFFD":String.fromCodePoint(t)}function dt(n){return n.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}var ge=It(/[A-Za-z]/),ce=It(/[\dA-Za-z]/),Vu=It(/[#-'*+\--9=?A-Z^-~]/);function Sr(n){return n!==null&&(n<32||n===127)}var wr=It(/\d/),$u=It(/[\dA-Fa-f]/),Di=It(/[!-/:-@[-`{-~]/);function T(n){return n!==null&&n<-2}function ee(n){return n!==null&&(n<0||n===32)}function P(n){return n===-2||n===-1||n===32}var ju=It(new RegExp("\\p{P}|\\p{S}","u")),qu=It(/\s/);function It(n){return e;function e(t){return t!==null&&t>-1&&n.test(String.fromCharCode(t))}}function _(n,e,t,r){let i=r?r-1:1/0,o=0;return s;function s(a){return P(a)?(n.enter(t),l(a)):e(a)}function l(a){return P(a)&&o++<i?(n.consume(a),l):(n.exit(t),e(a))}}function ds(n,e,t,r,i,o){let s=0;return l;function l(c){return o>0&&P(c)?(n.enter(r),a(c)):u(c)}function a(c){return P(c)&&s<o?(n.consume(c),s++,a):(n.exit(r),u(c))}function u(c){return s>=i?e(c):t(c)}}var Wu={tokenize:Em};function Em(n){let e=n.attempt(this.parser.constructs.contentInitial,r,i),t;return e;function r(l){if(l===null){n.consume(l);return}return n.enter("lineEnding"),n.consume(l),n.exit("lineEnding"),_(n,e,"linePrefix")}function i(l){return n.enter("paragraph"),o(l)}function o(l){let a=n.enter("chunkText",{contentType:"text",previous:t});return t&&(t.next=a),t=a,s(l)}function s(l){if(l===null){n.exit("chunkText"),n.exit("paragraph"),n.consume(l);return}return T(l)?(n.consume(l),n.exit("chunkText"),o):(n.consume(l),s)}}var pt=class{constructor(){this.index=new Map,this.map=[]}add(e,t,r){Hu(this,e,t,r,!1)}addBefore(e,t,r){Hu(this,e,t,r,!0)}consume(e){if(this.map.sort(function(o,s){return o[0]-s[0]}),this.map.length===0)return;let t=this.map.length,r=[];for(;t>0;)t-=1,r.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];r.push(e.slice()),e.length=0;let i=r.pop();for(;i;){for(let o of i)e.push(o);i=r.pop()}this.map.length=0,this.index.clear()}};function Hu(n,e,t,r,i){if(t===0&&r.length===0)return;let o=n.index.get(e);if(o){o[1]+=t,i?(r.push(...o[2]),o[2]=r):o[2].push(...r);return}let s=[e,t,r];n.map.push(s),n.index.set(e,s)}var Uu={tokenize:Om},Ku={tokenize:Tm};function Om(n){let e=this,t=[],r=0,i,o,s;return l;function l(C){if(r<t.length){let A=t[r];return e.containerState=A[1],n.attempt(A[0].continuation,a,u)(C)}return u(C)}function a(C){if(r++,e.containerState._closeFlow){e.containerState._closeFlow=void 0,i&&O();let A=e.events.length,z=A,S;for(;z--;)if(e.events[z][0]==="exit"&&e.events[z][1].type==="chunkFlow"){S=e.events[z][1].end;break}x(r);let I=A;for(;I<e.events.length;)e.events[I][1].end={...S},I++;let R=new pt;return R.add(z+1,0,e.events.slice(A)),R.add(A,I-A,[]),R.consume(e.events),u(C)}return l(C)}function u(C){if(r===t.length){if(!i)return d(C);if(i.currentConstruct&&i.currentConstruct.concrete)return p(C);e.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return e.containerState={},n.check(Ku,c,f)(C)}function c(C){return i&&O(),x(r),d(C)}function f(C){return e.parser.lazy[e.now().line]=r!==t.length,s=e.now().offset,p(C)}function d(C){return e.containerState={},n.attempt(Ku,h,p)(C)}function h(C){return r++,t.push([e.currentConstruct,e.containerState]),d(C)}function p(C){if(C===null){i&&O(),x(0),n.consume(C);return}return i=i||e.parser.flow(e.now()),n.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:o}),m(C)}function m(C){if(C===null){k(n.exit("chunkFlow"),!0),x(0),n.consume(C);return}return T(C)?(n.consume(C),k(n.exit("chunkFlow")),r=0,e.interrupt=void 0,l):(n.consume(C),m)}function k(C,A){let z=e.sliceStream(C);if(A&&z.push(null),C.previous=o,o&&(o.next=C),o=C,i.defineSkip(C.start),i.write(z),e.parser.lazy[C.start.line]){let S=i.events.length;for(;S--;)if(i.events[S][1].start.offset<s&&(!i.events[S][1].end||i.events[S][1].end.offset>s))return;let I=e.events.length,R=I,q,G;for(;R--;)if(e.events[R][0]==="exit"&&e.events[R][1].type==="chunkFlow"){if(q){G=e.events[R][1].end;break}q=!0}for(x(r),S=I;S<e.events.length;)e.events[S][1].end={...G},S++;let X=new pt;X.add(R+1,0,e.events.slice(I)),X.add(I,S-I,[]),X.consume(e.events)}}function x(C){let A=t.length;for(;A-- >C;){let z=t[A];e.containerState=z[1],z[0].exit.call(e,n)}t.length=C}function O(){i.write([null]),o=void 0,i=void 0,e.containerState._closeFlow=void 0}}function Tm(n,e,t){return _(n,n.attempt(this.parser.constructs.document,e,t),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function We(n){if(n===null||ee(n)||qu(n))return 1;if(ju(n))return 2}function Tn(n,e,t){let r=[],i=-1;for(;++i<n.length;){let o=n[i].resolveAll;o&&!r.includes(o)&&(e=o(e,t),r.push(o))}return e}var Cr={name:"attention",resolveAll:Am,tokenize:vm};function Am(n,e){let t=-1,r;for(;++t<n.length;)if(n[t][0]==="enter"&&n[t][1].type==="attentionSequence"&&n[t][1]._close){let i=t;for(;i--;)if(n[i][0]==="exit"&&n[i][1].type==="attentionSequence"&&n[i][1]._open&&e.sliceSerialize(n[i][1]).charCodeAt(0)===e.sliceSerialize(n[t][1]).charCodeAt(0)){if((n[i][1]._close||n[t][1]._open)&&(n[t][1].end.offset-n[t][1].start.offset)%3&&!((n[i][1].end.offset-n[i][1].start.offset+n[t][1].end.offset-n[t][1].start.offset)%3))continue;let o=n[i][1].end.offset-n[i][1].start.offset>1&&n[t][1].end.offset-n[t][1].start.offset>1?2:1,s={...n[i][1].end},l={...n[t][1].start};Ju(s,-o),Ju(l,o);let a={type:o>1?"strongSequence":"emphasisSequence",start:s,end:{...n[i][1].end}},u={type:o>1?"strongSequence":"emphasisSequence",start:{...n[t][1].start},end:l},c={type:o>1?"strongText":"emphasisText",start:{...n[i][1].end},end:{...n[t][1].start}},f={type:o>1?"strong":"emphasis",start:{...a.start},end:{...u.end}};n[i][1].end={...a.start},n[t][1].start={...u.end},r=[],n[i][1].end.offset-n[i][1].start.offset&&(r=we(r,[["enter",n[i][1],e],["exit",n[i][1],e]])),r=we(r,[["enter",f,e],["enter",a,e],["exit",a,e],["enter",c,e]]),r=we(r,Tn(e.parser.constructs.insideSpan.null,n.slice(i+1,t),e)),r=we(r,[["exit",c,e],["enter",u,e],["exit",u,e],["exit",f,e]]);let d=0;n[t][1].end.offset-n[t][1].start.offset&&(d=2,r=we(r,[["enter",n[t][1],e],["exit",n[t][1],e]])),Te(n,i-1,t-i+3,r),t=i+r.length-d-2;break}}for(t=-1;++t<n.length;)n[t][1].type==="attentionSequence"&&(n[t][1].type="data");return n}function vm(n,e){let t=this.parser.constructs.attentionMarkers.null,r=this.previous,i=We(r),o;return s;function s(a){return o=a,n.enter("attentionSequence"),l(a)}function l(a){if(a===o)return n.consume(a),l;let u=n.exit("attentionSequence"),c=We(a),f=!c||c===2&&i||t.includes(a)&&a!==42&&a!==95,d=!i||i===2&&c||t.includes(r)&&r!==42&&r!==95;return u._open=!!(o===42?f:f&&(i||!d)),u._close=!!(o===42?d:d&&(c||!f)),e(a)}}function Ju(n,e){n.column+=e,n.offset+=e,n._bufferIndex+=e}var ps={name:"autolink",tokenize:Dm};function Dm(n,e,t){let r=0;return i;function i(h){return n.enter("autolink"),n.enter("autolinkMarker"),n.consume(h),n.exit("autolinkMarker"),n.enter("autolinkProtocol"),o}function o(h){return ge(h)?(n.consume(h),s):h===64?t(h):u(h)}function s(h){return h===43||h===45||h===46||ce(h)?(r=1,l(h)):u(h)}function l(h){return h===58?(n.consume(h),r=0,a):(h===43||h===45||h===46||ce(h))&&r++<32?(n.consume(h),l):(r=0,u(h))}function a(h){return h===62?(n.exit("autolinkProtocol"),n.enter("autolinkMarker"),n.consume(h),n.exit("autolinkMarker"),n.exit("autolink"),e):h===null||h===32||h===60||Sr(h)?t(h):(n.consume(h),a)}function u(h){return h===64?(n.consume(h),c):Vu(h)?(n.consume(h),u):t(h)}function c(h){return ce(h)?f(h):t(h)}function f(h){return h===46?(n.consume(h),r=0,c):h===62?(n.exit("autolinkProtocol").type="autolinkEmail",n.enter("autolinkMarker"),n.consume(h),n.exit("autolinkMarker"),n.exit("autolink"),e):d(h)}function d(h){if((h===45||ce(h))&&r++<63){let p=h===45?d:f;return n.consume(h),p}return t(h)}}var Et={partial:!0,tokenize:Rm};function Rm(n,e,t){return r;function r(o){return P(o)?_(n,i,"linePrefix")(o):i(o)}function i(o){return o===null||T(o)?e(o):t(o)}}var Ri={continuation:{tokenize:Bm},exit:Lm,name:"blockQuote",tokenize:Pm};function Pm(n,e,t){let r=this;return i;function i(s){if(s===62){let l=r.containerState;return l.open||(n.enter("blockQuote",{_container:!0}),l.open=!0),n.enter("blockQuotePrefix"),n.enter("blockQuoteMarker"),n.consume(s),n.exit("blockQuoteMarker"),o}return t(s)}function o(s){return P(s)?(n.enter("blockQuotePrefixWhitespace"),n.consume(s),n.exit("blockQuotePrefixWhitespace"),n.exit("blockQuotePrefix"),e):(n.exit("blockQuotePrefix"),e(s))}}function Bm(n,e,t){let r=this;return i;function i(s){return P(s)?_(n,o,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(s):o(s)}function o(s){return n.attempt(Ri,e,t)(s)}}function Lm(n){n.exit("blockQuote")}var Pi={name:"characterEscape",tokenize:zm};function zm(n,e,t){return r;function r(o){return n.enter("characterEscape"),n.enter("escapeMarker"),n.consume(o),n.exit("escapeMarker"),i}function i(o){return Di(o)?(n.enter("characterEscapeValue"),n.consume(o),n.exit("characterEscapeValue"),n.exit("characterEscape"),e):t(o)}}var Bi={name:"characterReference",tokenize:Fm};function Fm(n,e,t){let r=this,i=0,o,s;return l;function l(f){return n.enter("characterReference"),n.enter("characterReferenceMarker"),n.consume(f),n.exit("characterReferenceMarker"),a}function a(f){return f===35?(n.enter("characterReferenceMarkerNumeric"),n.consume(f),n.exit("characterReferenceMarkerNumeric"),u):(n.enter("characterReferenceValue"),o=31,s=ce,c(f))}function u(f){return f===88||f===120?(n.enter("characterReferenceMarkerHexadecimal"),n.consume(f),n.exit("characterReferenceMarkerHexadecimal"),n.enter("characterReferenceValue"),o=6,s=$u,c):(n.enter("characterReferenceValue"),o=7,s=wr,c(f))}function c(f){if(f===59&&i){let d=n.exit("characterReferenceValue");return s===ce&&!On(r.sliceSerialize(d))?t(f):(n.enter("characterReferenceMarker"),n.consume(f),n.exit("characterReferenceMarker"),n.exit("characterReference"),e)}return s(f)&&i++<o?(n.consume(f),c):t(f)}}var Mr={partial:!0,tokenize:_m};function _m(n,e,t){let r=this;return i;function i(s){return s===null?t(s):(n.enter("lineEnding"),n.consume(s),n.exit("lineEnding"),o)}function o(s){return r.parser.lazy[r.now().line]?t(s):e(s)}}var Li={concrete:!0,name:"codeFenced",tokenize:Vm};function Vm(n,e,t){let r=this,i={partial:!0,tokenize:z},o=0,s=0,l;return a;function a(S){return u(S)}function u(S){let I=r.events[r.events.length-1];return o=I&&I[1].type==="linePrefix"?I[2].sliceSerialize(I[1],!0).length:0,l=S,n.enter("codeFenced"),n.enter("codeFencedFence"),n.enter("codeFencedFenceSequence"),c(S)}function c(S){return S===l?(s++,n.consume(S),c):s<3?t(S):(n.exit("codeFencedFenceSequence"),P(S)?_(n,f,"whitespace")(S):f(S))}function f(S){return S===null||T(S)?(n.exit("codeFencedFence"),r.interrupt?e(S):n.check(Mr,m,A)(S)):(n.enter("codeFencedFenceInfo"),n.enter("chunkString",{contentType:"string"}),d(S))}function d(S){return S===null||T(S)?(n.exit("chunkString"),n.exit("codeFencedFenceInfo"),f(S)):P(S)?(n.exit("chunkString"),n.exit("codeFencedFenceInfo"),_(n,h,"whitespace")(S)):S===96&&S===l?t(S):(n.consume(S),d)}function h(S){return S===null||T(S)?f(S):(n.enter("codeFencedFenceMeta"),n.enter("chunkString",{contentType:"string"}),p(S))}function p(S){return S===null||T(S)?(n.exit("chunkString"),n.exit("codeFencedFenceMeta"),f(S)):S===96&&S===l?t(S):(n.consume(S),p)}function m(S){return n.attempt(i,A,k)(S)}function k(S){return n.enter("lineEnding"),n.consume(S),n.exit("lineEnding"),x}function x(S){return o>0&&P(S)?_(n,O,"linePrefix",o+1)(S):O(S)}function O(S){return S===null||T(S)?n.check(Mr,m,A)(S):(n.enter("codeFlowValue"),C(S))}function C(S){return S===null||T(S)?(n.exit("codeFlowValue"),O(S)):(n.consume(S),C)}function A(S){return n.exit("codeFenced"),e(S)}function z(S,I,R){let q=0;return G;function G(V){return S.enter("lineEnding"),S.consume(V),S.exit("lineEnding"),X}function X(V){return S.enter("codeFencedFence"),P(V)?_(S,Q,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(V):Q(V)}function Q(V){return V===l?(S.enter("codeFencedFenceSequence"),v(V)):R(V)}function v(V){return V===l?(q++,S.consume(V),v):q>=s?(S.exit("codeFencedFenceSequence"),P(V)?_(S,K,"whitespace")(V):K(V)):R(V)}function K(V){return V===null||T(V)?(S.exit("codeFencedFence"),I(V)):R(V)}}}var Nr={name:"codeIndented",tokenize:jm},$m={partial:!0,tokenize:qm};function jm(n,e,t){return r;function r(l){return n.enter("codeIndented"),ds(n,i,t,"linePrefix",4,4)(l)}function i(l){return l===null?s(l):T(l)?n.attempt($m,i,s)(l):(n.enter("codeFlowValue"),o(l))}function o(l){return l===null||T(l)?(n.exit("codeFlowValue"),i(l)):(n.consume(l),o)}function s(l){return n.exit("codeIndented"),e(l)}}function qm(n,e,t){let r=this;return i;function i(s){return r.parser.lazy[r.now().line]?t(s):T(s)?(n.enter("lineEnding"),n.consume(s),n.exit("lineEnding"),i):ds(n,e,o,"linePrefix",4,4)(s)}function o(s){return T(s)?i(s):t(s)}}var ms={name:"codeText",previous:Hm,resolve:Wm,tokenize:Km};function Wm(n){let e=n.length-4,t=3,r,i;if((n[t][1].type==="lineEnding"||n[t][1].type==="space")&&(n[e][1].type==="lineEnding"||n[e][1].type==="space")){for(r=t;++r<e;)if(n[r][1].type==="codeTextData"){n[t][1].type="codeTextPadding",n[e][1].type="codeTextPadding",t+=2,e-=2;break}}for(r=t-1,e++;++r<=e;)i===void 0?r!==e&&n[r][1].type!=="lineEnding"&&(i=r):(r===e||n[r][1].type==="lineEnding")&&(n[i][1].type="codeTextData",r!==i+2&&(n[i][1].end=n[r-1][1].end,n.splice(i+2,r-i-2),e-=r-i-2,r=i+2),i=void 0);return n}function Hm(n){return n!==96||this.events[this.events.length-1][1].type==="characterEscape"}function Km(n,e,t){let r=this,i=0,o,s;return l;function l(d){return n.enter("codeText"),n.enter("codeTextSequence"),a(d)}function a(d){return d===96?(n.consume(d),i++,a):(n.exit("codeTextSequence"),u(d))}function u(d){return d===null?t(d):d===32?(n.enter("space"),n.consume(d),n.exit("space"),u):d===96?(s=n.enter("codeTextSequence"),o=0,f(d)):T(d)?(n.enter("lineEnding"),n.consume(d),n.exit("lineEnding"),u):(n.enter("codeTextData"),c(d))}function c(d){return d===null||d===32||d===96||T(d)?(n.exit("codeTextData"),u(d)):(n.consume(d),c)}function f(d){return d===96?(n.consume(d),o++,f):o===i?(n.exit("codeTextSequence"),n.exit("codeText"),e(d)):(s.type="codeTextData",c(d))}}var zi=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let r=t??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(e,r):e>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(e,t,r){let i=t||0;this.setCursor(Math.trunc(e));let o=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&Ir(this.left,r),o.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(e){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(e)}pushMany(e){this.setCursor(Number.POSITIVE_INFINITY),Ir(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),Ir(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0))if(e<this.left.length){let t=this.left.splice(e,Number.POSITIVE_INFINITY);Ir(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,Number.POSITIVE_INFINITY);Ir(this.left,t.reverse())}}};function Ir(n,e){let t=0;if(e.length<1e4)n.push(...e);else for(;t<e.length;)n.push(...e.slice(t,t+1e4)),t+=1e4}function Fi(n){let e={},t=-1,r,i,o,s,l,a,u,c=new zi(n);for(;++t<c.length;){for(;t in e;)t=e[t];if(r=c.get(t),t&&r[1].type==="chunkFlow"&&c.get(t-1)[1].type==="listItemPrefix"&&(a=r[1]._tokenizer.events,o=0,o<a.length&&a[o][1].type==="lineEndingBlank"&&(o+=2),o<a.length&&a[o][1].type==="content"))for(;++o<a.length&&a[o][1].type!=="content";)a[o][1].type==="chunkText"&&(a[o][1]._isInFirstContentOfListItem=!0,o++);if(r[0]==="enter")r[1].contentType&&(Object.assign(e,Um(c,t)),t=e[t],u=!0);else if(r[1]._container){for(o=t,i=void 0;o--;)if(s=c.get(o),s[1].type==="lineEnding"||s[1].type==="lineEndingBlank")s[0]==="enter"&&(i&&(c.get(i)[1].type="lineEndingBlank"),s[1].type="lineEnding",i=o);else if(!(s[1].type==="linePrefix"||s[1].type==="listItemIndent"))break;i&&(r[1].end={...c.get(i)[1].start},l=c.slice(i,t),l.unshift(r),c.splice(i,t-i+1,l))}}return Te(n,0,Number.POSITIVE_INFINITY,c.slice(0)),!u}function Um(n,e){let t=n.get(e)[1],r=n.get(e)[2],i=e-1,o=[],s=t._tokenizer;s||(s=r.parser[t.contentType](t.start),t._contentTypeTextTrailing&&(s._contentTypeTextTrailing=!0));let l=s.events,a=[],u={},c,f,d=-1,h=t,p=0,m=0,k=[m];for(;h;){for(;n.get(++i)[1]!==h;);o.push(i),h._tokenizer||(c=r.sliceStream(h),h.next||c.push(null),f&&s.defineSkip(h.start),h._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=!0),s.write(c),h._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=void 0)),f=h,h=h.next}for(h=t;++d<l.length;)l[d][0]==="exit"&&l[d-1][0]==="enter"&&l[d][1].type===l[d-1][1].type&&l[d][1].start.line!==l[d][1].end.line&&(m=d+1,k.push(m),h._tokenizer=void 0,h.previous=void 0,h=h.next);for(s.events=[],h?(h._tokenizer=void 0,h.previous=void 0):k.pop(),d=k.length;d--;){let x=l.slice(k[d],k[d+1]),O=o.pop();a.push([O,O+x.length-1]),n.splice(O,2,x)}for(a.reverse(),d=-1;++d<a.length;)u[p+a[d][0]]=p+a[d][1],p+=a[d][1]-a[d][0]-1;return u}var gs={resolve:Gm,tokenize:Qm},Jm={partial:!0,tokenize:Ym};function Gm(n){return Fi(n),n}function Qm(n,e){let t;return r;function r(l){return n.enter("content"),t=n.enter("chunkContent",{contentType:"content"}),i(l)}function i(l){return l===null?o(l):T(l)?n.check(Jm,s,o)(l):(n.consume(l),i)}function o(l){return n.exit("chunkContent"),n.exit("content"),e(l)}function s(l){return n.consume(l),n.exit("chunkContent"),t.next=n.enter("chunkContent",{contentType:"content",previous:t}),t=t.next,i}}function Ym(n,e,t){let r=this;return i;function i(s){return n.exit("chunkContent"),n.enter("lineEnding"),n.consume(s),n.exit("lineEnding"),_(n,o,"linePrefix")}function o(s){if(s===null||T(s))return t(s);let l=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?e(s):n.interrupt(r.parser.constructs.flow,t,e)(s)}}function _i(n,e,t,r,i,o,s,l,a){let u=a||Number.POSITIVE_INFINITY,c=0;return f;function f(x){return x===60?(n.enter(r),n.enter(i),n.enter(o),n.consume(x),n.exit(o),d):x===null||x===32||x===41||Sr(x)?t(x):(n.enter(r),n.enter(s),n.enter(l),n.enter("chunkString",{contentType:"string"}),m(x))}function d(x){return x===62?(n.enter(o),n.consume(x),n.exit(o),n.exit(i),n.exit(r),e):(n.enter(l),n.enter("chunkString",{contentType:"string"}),h(x))}function h(x){return x===62?(n.exit("chunkString"),n.exit(l),d(x)):x===null||x===60||T(x)?t(x):(n.consume(x),x===92?p:h)}function p(x){return x===60||x===62||x===92?(n.consume(x),h):h(x)}function m(x){return!c&&(x===null||x===41||ee(x))?(n.exit("chunkString"),n.exit(l),n.exit(s),n.exit(r),e(x)):c<u&&x===40?(n.consume(x),c++,m):x===41?(n.consume(x),c--,m):x===null||x===32||x===40||Sr(x)?t(x):(n.consume(x),x===92?k:m)}function k(x){return x===40||x===41||x===92?(n.consume(x),m):m(x)}}function Vi(n,e,t,r,i,o){let s=this,l=0,a;return u;function u(h){return n.enter(r),n.enter(i),n.consume(h),n.exit(i),n.enter(o),c}function c(h){return l>999||h===null||h===91||h===93&&!a||h===94&&!l&&"_hiddenFootnoteSupport"in s.parser.constructs?t(h):h===93?(n.exit(o),n.enter(i),n.consume(h),n.exit(i),n.exit(r),e):T(h)?(n.enter("lineEnding"),n.consume(h),n.exit("lineEnding"),c):(n.enter("chunkString",{contentType:"string"}),f(h))}function f(h){return h===null||h===91||h===93||T(h)||l++>999?(n.exit("chunkString"),c(h)):(n.consume(h),a||(a=!P(h)),h===92?d:f)}function d(h){return h===91||h===92||h===93?(n.consume(h),l++,f):f(h)}}function $i(n,e,t,r,i,o){let s;return l;function l(d){return d===34||d===39||d===40?(n.enter(r),n.enter(i),n.consume(d),n.exit(i),s=d===40?41:d,a):t(d)}function a(d){return d===s?(n.enter(i),n.consume(d),n.exit(i),n.exit(r),e):(n.enter(o),u(d))}function u(d){return d===s?(n.exit(o),a(s)):d===null?t(d):T(d)?(n.enter("lineEnding"),n.consume(d),n.exit("lineEnding"),_(n,u,"linePrefix")):(n.enter("chunkString",{contentType:"string"}),c(d))}function c(d){return d===s||d===null||T(d)?(n.exit("chunkString"),u(d)):(n.consume(d),d===92?f:c)}function f(d){return d===s||d===92?(n.consume(d),c):c(d)}}function Kt(n,e){let t;return r;function r(i){return T(i)?(n.enter("lineEnding"),n.consume(i),n.exit("lineEnding"),t=!0,r):P(i)?_(n,r,t?"linePrefix":"lineSuffix")(i):e(i)}}var ys={name:"definition",tokenize:Zm},Xm={partial:!0,tokenize:eg};function Zm(n,e,t){let r=this,i;return o;function o(h){return n.enter("definition"),s(h)}function s(h){return Vi.call(r,n,l,t,"definitionLabel","definitionLabelMarker","definitionLabelString")(h)}function l(h){return i=dt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),h===58?(n.enter("definitionMarker"),n.consume(h),n.exit("definitionMarker"),a):t(h)}function a(h){return ee(h)?Kt(n,u)(h):u(h)}function u(h){return _i(n,c,t,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(h)}function c(h){return n.attempt(Xm,f,f)(h)}function f(h){return P(h)?_(n,d,"whitespace")(h):d(h)}function d(h){return h===null||T(h)?(n.exit("definition"),r.parser.defined.push(i),e(h)):t(h)}}function eg(n,e,t){return r;function r(l){return ee(l)?Kt(n,i)(l):t(l)}function i(l){return $i(n,o,t,"definitionTitle","definitionTitleMarker","definitionTitleString")(l)}function o(l){return P(l)?_(n,s,"whitespace")(l):s(l)}function s(l){return l===null||T(l)?e(l):t(l)}}var xs={name:"hardBreakEscape",tokenize:tg};function tg(n,e,t){return r;function r(o){return n.enter("hardBreakEscape"),n.consume(o),i}function i(o){return T(o)?(n.exit("hardBreakEscape"),e(o)):t(o)}}var ks={name:"headingAtx",resolve:ng,tokenize:rg};function ng(n,e){let t=n.length-2,r=3;if(n[r][1].type==="whitespace"&&(r+=2),t-2>r&&n[t][1].type==="whitespace"&&(t-=2),n[t][1].type==="atxHeadingSequence"&&(r===t-1||t-4>r&&n[t-2][1].type==="whitespace")&&(t-=r+1===t?2:4),t>r){let i={type:"atxHeadingText",start:n[r][1].start,end:n[t][1].end},o={type:"chunkText",start:n[r][1].start,end:n[t][1].end,contentType:"text"};Te(n,r,t-r+1,[["enter",i,e],["enter",o,e],["exit",o,e],["exit",i,e]])}return n}function rg(n,e,t){let r=0;return i;function i(c){return n.enter("atxHeading"),o(c)}function o(c){return n.enter("atxHeadingSequence"),s(c)}function s(c){return c===35&&r++<6?(n.consume(c),s):c===null||ee(c)?(n.exit("atxHeadingSequence"),l(c)):t(c)}function l(c){return c===35?(n.enter("atxHeadingSequence"),a(c)):c===null||T(c)?(n.exit("atxHeading"),e(c)):P(c)?_(n,l,"whitespace")(c):(n.enter("atxHeadingText"),u(c))}function a(c){return c===35?(n.consume(c),a):(n.exit("atxHeadingSequence"),l(c))}function u(c){return c===null||c===35||ee(c)?(n.exit("atxHeadingText"),l(c)):(n.consume(c),u)}}var ji=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],Er=["pre","script","style","textarea"];var bs={concrete:!0,name:"htmlFlow",resolveTo:og,tokenize:sg},ig={partial:!0,tokenize:lg};function og(n){let e=n.length;for(;e--&&!(n[e][0]==="enter"&&n[e][1].type==="htmlFlow"););return e>1&&n[e-2][1].type==="linePrefix"&&(n[e][1].start=n[e-2][1].start,n[e+1][1].start=n[e-2][1].start,n.splice(e-2,2)),n}function sg(n,e,t){let r=this,i,o,s,l,a;return u;function u(y){return c(y)}function c(y){return n.enter("htmlFlow"),n.enter("htmlFlowData"),n.consume(y),f}function f(y){return y===33?(n.consume(y),d):y===47?(n.consume(y),o=!0,m):y===63?(n.consume(y),i=3,r.interrupt?e:g):ge(y)?(n.consume(y),s=String.fromCharCode(y),k):t(y)}function d(y){return y===45?(n.consume(y),i=2,h):y===91?(n.consume(y),i=5,l=0,p):ge(y)?(n.consume(y),i=4,r.interrupt?e:g):t(y)}function h(y){return y===45?(n.consume(y),r.interrupt?e:g):t(y)}function p(y){let Pe="CDATA[";return y===Pe.charCodeAt(l++)?(n.consume(y),l===Pe.length?r.interrupt?e:Q:p):t(y)}function m(y){return ge(y)?(n.consume(y),s=String.fromCharCode(y),k):t(y)}function k(y){if(y===null||y===47||y===62||ee(y)){let Pe=y===47,Mn=s.toLowerCase();return!Pe&&!o&&Er.includes(Mn)?(i=1,r.interrupt?e(y):Q(y)):ji.includes(s.toLowerCase())?(i=6,Pe?(n.consume(y),x):r.interrupt?e(y):Q(y)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?t(y):o?O(y):C(y))}return y===45||ce(y)?(n.consume(y),s+=String.fromCharCode(y),k):t(y)}function x(y){return y===62?(n.consume(y),r.interrupt?e:Q):t(y)}function O(y){return P(y)?(n.consume(y),O):G(y)}function C(y){return y===47?(n.consume(y),G):y===58||y===95||ge(y)?(n.consume(y),A):P(y)?(n.consume(y),C):G(y)}function A(y){return y===45||y===46||y===58||y===95||ce(y)?(n.consume(y),A):z(y)}function z(y){return y===61?(n.consume(y),S):P(y)?(n.consume(y),z):C(y)}function S(y){return y===null||y===60||y===61||y===62||y===96?t(y):y===34||y===39?(n.consume(y),a=y,I):P(y)?(n.consume(y),S):R(y)}function I(y){return y===a?(n.consume(y),a=null,q):y===null||T(y)?t(y):(n.consume(y),I)}function R(y){return y===null||y===34||y===39||y===47||y===60||y===61||y===62||y===96||ee(y)?z(y):(n.consume(y),R)}function q(y){return y===47||y===62||P(y)?C(y):t(y)}function G(y){return y===62?(n.consume(y),X):t(y)}function X(y){return y===null||T(y)?Q(y):P(y)?(n.consume(y),X):t(y)}function Q(y){return y===45&&i===2?(n.consume(y),Z):y===60&&i===1?(n.consume(y),re):y===62&&i===4?(n.consume(y),Ve):y===63&&i===3?(n.consume(y),g):y===93&&i===5?(n.consume(y),rt):T(y)&&(i===6||i===7)?(n.exit("htmlFlowData"),n.check(ig,ct,v)(y)):y===null||T(y)?(n.exit("htmlFlowData"),v(y)):(n.consume(y),Q)}function v(y){return n.check(Mr,K,ct)(y)}function K(y){return n.enter("lineEnding"),n.consume(y),n.exit("lineEnding"),V}function V(y){return y===null||T(y)?v(y):(n.enter("htmlFlowData"),Q(y))}function Z(y){return y===45?(n.consume(y),g):Q(y)}function re(y){return y===47?(n.consume(y),s="",Qe):Q(y)}function Qe(y){if(y===62){let Pe=s.toLowerCase();return Er.includes(Pe)?(n.consume(y),Ve):Q(y)}return ge(y)&&s.length<8?(n.consume(y),s+=String.fromCharCode(y),Qe):Q(y)}function rt(y){return y===93?(n.consume(y),g):Q(y)}function g(y){return y===62?(n.consume(y),Ve):y===45&&i===2?(n.consume(y),g):Q(y)}function Ve(y){return y===null||T(y)?(n.exit("htmlFlowData"),ct(y)):(n.consume(y),Ve)}function ct(y){return n.exit("htmlFlow"),e(y)}}function lg(n,e,t){return r;function r(i){return n.enter("lineEnding"),n.consume(i),n.exit("lineEnding"),n.attempt(Et,e,t)}}var Ss={name:"htmlText",tokenize:ag};function ag(n,e,t){let r=this,i,o,s;return l;function l(g){return n.enter("htmlText"),n.enter("htmlTextData"),n.consume(g),a}function a(g){return g===33?(n.consume(g),u):g===47?(n.consume(g),z):g===63?(n.consume(g),C):ge(g)?(n.consume(g),R):t(g)}function u(g){return g===45?(n.consume(g),c):g===91?(n.consume(g),o=0,p):ge(g)?(n.consume(g),O):t(g)}function c(g){return g===45?(n.consume(g),h):t(g)}function f(g){return g===null?t(g):g===45?(n.consume(g),d):T(g)?(s=f,re(g)):(n.consume(g),f)}function d(g){return g===45?(n.consume(g),h):f(g)}function h(g){return g===62?Z(g):g===45?d(g):f(g)}function p(g){let Ve="CDATA[";return g===Ve.charCodeAt(o++)?(n.consume(g),o===Ve.length?m:p):t(g)}function m(g){return g===null?t(g):g===93?(n.consume(g),k):T(g)?(s=m,re(g)):(n.consume(g),m)}function k(g){return g===93?(n.consume(g),x):m(g)}function x(g){return g===62?Z(g):g===93?(n.consume(g),x):m(g)}function O(g){return g===null||g===62?Z(g):T(g)?(s=O,re(g)):(n.consume(g),O)}function C(g){return g===null?t(g):g===63?(n.consume(g),A):T(g)?(s=C,re(g)):(n.consume(g),C)}function A(g){return g===62?Z(g):C(g)}function z(g){return ge(g)?(n.consume(g),S):t(g)}function S(g){return g===45||ce(g)?(n.consume(g),S):I(g)}function I(g){return T(g)?(s=I,re(g)):P(g)?(n.consume(g),I):Z(g)}function R(g){return g===45||ce(g)?(n.consume(g),R):g===47||g===62||ee(g)?q(g):t(g)}function q(g){return g===47?(n.consume(g),Z):g===58||g===95||ge(g)?(n.consume(g),G):T(g)?(s=q,re(g)):P(g)?(n.consume(g),q):Z(g)}function G(g){return g===45||g===46||g===58||g===95||ce(g)?(n.consume(g),G):X(g)}function X(g){return g===61?(n.consume(g),Q):T(g)?(s=X,re(g)):P(g)?(n.consume(g),X):q(g)}function Q(g){return g===null||g===60||g===61||g===62||g===96?t(g):g===34||g===39?(n.consume(g),i=g,v):T(g)?(s=Q,re(g)):P(g)?(n.consume(g),Q):(n.consume(g),K)}function v(g){return g===i?(n.consume(g),i=void 0,V):g===null?t(g):T(g)?(s=v,re(g)):(n.consume(g),v)}function K(g){return g===null||g===34||g===39||g===60||g===61||g===96?t(g):g===47||g===62||ee(g)?q(g):(n.consume(g),K)}function V(g){return g===47||g===62||ee(g)?q(g):t(g)}function Z(g){return g===62?(n.consume(g),n.exit("htmlTextData"),n.exit("htmlText"),e):t(g)}function re(g){return n.exit("htmlTextData"),n.enter("lineEnding"),n.consume(g),n.exit("lineEnding"),Qe}function Qe(g){return P(g)?_(n,rt,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(g):rt(g)}function rt(g){return n.enter("htmlTextData"),s(g)}}var Ut={name:"labelEnd",resolveAll:hg,resolveTo:dg,tokenize:pg},ug={tokenize:mg},cg={tokenize:gg},fg={tokenize:yg};function hg(n){let e=-1,t=[];for(;++e<n.length;){let r=n[e][1];if(t.push(n[e]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){let i=r.type==="labelImage"?4:2;r.type="data",e+=i}}return n.length!==t.length&&Te(n,0,n.length,t),n}function dg(n,e){let t=n.length,r=0,i,o,s;for(;t--;){let c=n[t][1];if(i){if(c.type==="link"||c.type==="labelLink"&&c._inactive)break;n[t][0]==="enter"&&c.type==="labelLink"&&(c._inactive=!0)}else if(o){if(n[t][0]==="enter"&&(c.type==="labelImage"||c.type==="labelLink")&&!c._balanced&&(i=t,c.type!=="labelLink")){r=2;break}}else c.type==="labelEnd"&&(o=t)}let l={type:n[i][1].type==="labelLink"?"link":"image",start:{...n[i][1].start},end:{...n[n.length-1][1].end}},a={type:"label",start:{...n[i][1].start},end:{...n[o][1].end}},u={type:"labelText",start:{...n[i+r+2][1].end},end:{...n[o-2][1].start}};return s=[["enter",l,e],["enter",a,e]],s=we(s,n.slice(i+1,i+r+3)),s=we(s,[["enter",u,e]]),s=we(s,Tn(e.parser.constructs.insideSpan.null,n.slice(i+r+4,o-3),e)),s=we(s,[["exit",u,e],n[o-2],n[o-1],["exit",a,e]]),s=we(s,n.slice(o+1)),s=we(s,[["exit",l,e]]),Te(n,i,n.length,s),n}function pg(n,e,t){let r=this,i=r._labelStarts,o,s;if(i){for(;i.length>0&&i[i.length-1]._balanced;)i.pop();o=i[i.length-1]}return l;function l(d){return o?o._inactive?f(d):(s=r.parser.defined.includes(dt(r.sliceSerialize({start:o.end,end:r.now()}))),n.enter("labelEnd"),n.enter("labelMarker"),n.consume(d),n.exit("labelMarker"),n.exit("labelEnd"),a):t(d)}function a(d){return d===40?n.attempt(ug,c,s?c:f)(d):d===91?n.attempt(cg,c,s?u:f)(d):s?c(d):f(d)}function u(d){return n.attempt(fg,c,f)(d)}function c(d){return i.pop(),e(d)}function f(d){return o._balanced=!0,t(d)}}function mg(n,e,t){return r;function r(f){return n.enter("resource"),n.enter("resourceMarker"),n.consume(f),n.exit("resourceMarker"),i}function i(f){return ee(f)?Kt(n,o)(f):o(f)}function o(f){return f===41?c(f):_i(n,s,l,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(f)}function s(f){return ee(f)?Kt(n,a)(f):c(f)}function l(f){return t(f)}function a(f){return f===34||f===39||f===40?$i(n,u,t,"resourceTitle","resourceTitleMarker","resourceTitleString")(f):c(f)}function u(f){return ee(f)?Kt(n,c)(f):c(f)}function c(f){return f===41?(n.enter("resourceMarker"),n.consume(f),n.exit("resourceMarker"),n.exit("resource"),e):t(f)}}function gg(n,e,t){let r=this;return i;function i(l){return Vi.call(r,n,o,s,"reference","referenceMarker","referenceString")(l)}function o(l){return r.parser.defined.includes(dt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?e(l):t(l)}function s(l){return t(l)}}function yg(n,e,t){return r;function r(o){return n.enter("reference"),n.enter("referenceMarker"),n.consume(o),n.exit("referenceMarker"),i}function i(o){return o===93?(n.enter("referenceMarker"),n.consume(o),n.exit("referenceMarker"),n.exit("reference"),e):t(o)}}var ws={name:"labelStartImage",resolveAll:Ut.resolveAll,tokenize:xg};function xg(n,e,t){let r=this,i;return o;function o(a){return n.enter("labelImage"),n.enter("labelImageMarker"),n.consume(a),n.exit("labelImageMarker"),s}function s(a){return a===91?(n.enter("labelMarker"),n.consume(a),n.exit("labelMarker"),i=n.exit("labelImage"),l):t(a)}function l(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?t(a):(r._labelStarts=r._labelStarts||[],r._labelStarts.push(i),e(a))}}var Cs={name:"labelStartLink",resolveAll:Ut.resolveAll,tokenize:kg};function kg(n,e,t){let r=this,i;return o;function o(l){return n.enter("labelLink"),n.enter("labelMarker"),n.consume(l),n.exit("labelMarker"),i=n.exit("labelLink"),s}function s(l){return l===94&&"_hiddenFootnoteSupport"in r.parser.constructs?t(l):(r._labelStarts=r._labelStarts||[],r._labelStarts.push(i),e(l))}}var Or={name:"lineEnding",tokenize:bg};function bg(n,e){return t;function t(r){return n.enter("lineEnding"),n.consume(r),n.exit("lineEnding"),_(n,e,"linePrefix")}}var Jt={name:"thematicBreak",tokenize:Sg};function Sg(n,e,t){let r=0,i;return o;function o(u){return n.enter("thematicBreak"),s(u)}function s(u){return i=u,l(u)}function l(u){return u===i?(n.enter("thematicBreakSequence"),a(u)):r>=3&&(u===null||T(u))?(n.exit("thematicBreak"),e(u)):t(u)}function a(u){return u===i?(n.consume(u),r++,a):(n.exit("thematicBreakSequence"),P(u)?_(n,l,"whitespace")(u):l(u))}}var ye={continuation:{tokenize:Ng},exit:Eg,name:"list",tokenize:Mg},wg={partial:!0,tokenize:Og},Cg={partial:!0,tokenize:Ig};function Mg(n,e,t){let r=this,i=r.events[r.events.length-1],o=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,s=0;return l;function l(h){let p=r.containerState.type||(h===42||h===43||h===45?"listUnordered":"listOrdered");if(p==="listUnordered"?!r.containerState.marker||h===r.containerState.marker:wr(h)){if(r.containerState.type||(r.containerState.type=p,n.enter(p,{_container:!0})),p==="listUnordered")return n.enter("listItemPrefix"),h===42||h===45?n.check(Jt,t,u)(h):u(h);if(!r.interrupt||h===49)return n.enter("listItemPrefix"),n.enter("listItemValue"),a(h)}return t(h)}function a(h){return wr(h)&&++s<10?(n.consume(h),a):(!r.interrupt||s<2)&&(r.containerState.marker?h===r.containerState.marker:h===41||h===46)?(n.exit("listItemValue"),u(h)):t(h)}function u(h){return n.enter("listItemMarker"),n.consume(h),n.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||h,n.check(Et,r.interrupt?t:c,n.attempt(wg,d,f))}function c(h){return r.containerState.initialBlankLine=!0,o++,d(h)}function f(h){return P(h)?(n.enter("listItemPrefixWhitespace"),n.consume(h),n.exit("listItemPrefixWhitespace"),d):t(h)}function d(h){return r.containerState.size=o+r.sliceSerialize(n.exit("listItemPrefix"),!0).length,e(h)}}function Ng(n,e,t){let r=this;return r.containerState._closeFlow=void 0,n.check(Et,i,o);function i(l){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,_(n,e,"listItemIndent",r.containerState.size+1)(l)}function o(l){return r.containerState.furtherBlankLines||!P(l)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,s(l)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,n.attempt(Cg,e,s)(l))}function s(l){return r.containerState._closeFlow=!0,r.interrupt=void 0,_(n,n.attempt(ye,e,t),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l)}}function Ig(n,e,t){let r=this;return _(n,i,"listItemIndent",r.containerState.size+1);function i(o){let s=r.events[r.events.length-1];return s&&s[1].type==="listItemIndent"&&s[2].sliceSerialize(s[1],!0).length===r.containerState.size?e(o):t(o)}}function Eg(n){n.exit(this.containerState.type)}function Og(n,e,t){let r=this;return _(n,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(o){let s=r.events[r.events.length-1];return!P(o)&&s&&s[1].type==="listItemPrefixWhitespace"?e(o):t(o)}}var qi={name:"setextUnderline",resolveTo:Tg,tokenize:Ag};function Tg(n,e){let t=new pt,r=n.length,i,o,s;for(;r--;)if(n[r][0]==="enter"){if(n[r][1].type==="content"){i=r;break}n[r][1].type==="paragraph"&&(o=r)}else n[r][1].type==="content"&&t.add(r,1,[]),!s&&n[r][1].type==="definition"&&(s=r);let l={type:"setextHeading",start:{...n[i][1].start},end:{...n[n.length-1][1].end}};return n[o][1].type="setextHeadingText",s?(t.add(o,0,[["enter",l,e]]),t.add(s+1,0,[["exit",n[i][1],e]]),n[i][1].end={...n[s][1].end}):n[i][1]=l,t.add(n.length,0,[["exit",l,e]]),t.consume(n),n}function Ag(n,e,t){let r=this,i;return o;function o(u){let c=r.events.length,f;for(;c--;)if(r.events[c][1].type!=="lineEnding"&&r.events[c][1].type!=="linePrefix"&&r.events[c][1].type!=="content"){f=r.events[c][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||f)?(n.enter("setextHeadingLine"),i=u,s(u)):t(u)}function s(u){return n.enter("setextHeadingLineSequence"),l(u)}function l(u){return u===i?(n.consume(u),l):(n.exit("setextHeadingLineSequence"),P(u)?_(n,a,"lineSuffix")(u):a(u))}function a(u){return u===null||T(u)?(n.exit("setextHeadingLine"),e(u)):t(u)}}var Gu={tokenize:vg};function vg(n){let e=this,t=n.attempt(Et,r,n.attempt(this.parser.constructs.flowInitial,i,_(n,n.attempt(this.parser.constructs.flow,i,n.attempt(gs,i)),"linePrefix")));return t;function r(o){if(o===null){n.consume(o);return}return n.enter("lineEndingBlank"),n.consume(o),n.exit("lineEndingBlank"),e.currentConstruct=void 0,t}function i(o){if(o===null){n.consume(o);return}return n.enter("lineEnding"),n.consume(o),n.exit("lineEnding"),e.currentConstruct=void 0,t}}var Qu={resolveAll:ec()},Yu=Zu("string"),Xu=Zu("text");function Zu(n){return{resolveAll:ec(n==="text"?Dg:void 0),tokenize:e};function e(t){let r=this,i=this.parser.constructs[n],o=t.attempt(i,s,l);return s;function s(c){return u(c)?o(c):l(c)}function l(c){if(c===null){t.consume(c);return}return t.enter("data"),t.consume(c),a}function a(c){return u(c)?(t.exit("data"),o(c)):(t.consume(c),a)}function u(c){if(c===null)return!0;let f=i[c],d=-1;if(f)for(;++d<f.length;){let h=f[d];if(!h.previous||h.previous.call(r,r.previous))return!0}return!1}}}function ec(n){return e;function e(t,r){let i=-1,o;for(;++i<=t.length;)o===void 0?t[i]&&t[i][1].type==="data"&&(o=i,i++):(!t[i]||t[i][1].type!=="data")&&(i!==o+2&&(t[o][1].end=t[i-1][1].end,t.splice(o+2,i-o-2),i=o+2),o=void 0);return n?n(t,r):t}}function Dg(n,e){let t=new pt,r=0;for(;++r<=n.length;)if((r===n.length||n[r][1].type==="lineEnding")&&n[r-1][1].type==="data"){let i=n[r-1][1],o=e.sliceStream(i),s=o.length,l=-1,a=0,u;for(;s--;){let c=o[s];if(typeof c=="string"){for(l=c.length;c.charCodeAt(l-1)===32;)a++,l--;if(l)break;l=-1}else if(c===-2)u=!0,a++;else if(c!==-1){s++;break}}if(e._contentTypeTextTrailing&&r===n.length&&(a=0),a){let c={type:r===n.length||u||a<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:s?l:i.start._bufferIndex+l,_index:i.start._index+s,line:i.end.line,column:i.end.column-a,offset:i.end.offset-a},end:{...i.end}};i.end={...c.start},i.start.offset===i.end.offset?Object.assign(i,c):t.add(r,0,[["enter",c,e],["exit",c,e]])}r++}return t.consume(n),n}var Ms={};pm(Ms,{attentionMarkers:()=>Vg,contentInitial:()=>Pg,disable:()=>$g,document:()=>Rg,flow:()=>Lg,flowInitial:()=>Bg,insideSpan:()=>_g,string:()=>zg,text:()=>Fg});var Rg={42:ye,43:ye,45:ye,48:ye,49:ye,50:ye,51:ye,52:ye,53:ye,54:ye,55:ye,56:ye,57:ye,62:Ri},Pg={91:ys},Bg={[-2]:Nr,[-1]:Nr,32:Nr},Lg={35:ks,42:Jt,45:[qi,Jt],60:bs,61:qi,95:Jt,96:Li,126:Li},zg={38:Bi,92:Pi},Fg={[-5]:Or,[-4]:Or,[-3]:Or,33:ws,38:Bi,42:Cr,60:[ps,Ss],91:Cs,92:[xs,Pi],93:Ut,95:Cr,96:ms},_g={null:[Cr,Qu]},Vg={null:[42,95]},$g={null:[]};function tc(n,e,t){let r={_bufferIndex:-1,_index:0,line:t&&t.line||1,column:t&&t.column||1,offset:t&&t.offset||0},i={},o=[],s=[],l=[],a=!0,u={attempt:q(I),check:q(R),consume:A,enter:z,exit:S,interrupt:q(R,{interrupt:!0})},c={code:null,containerState:{},defineSkip:x,events:[],now:k,parser:n,previous:null,sliceSerialize:p,sliceStream:m,write:h},f=e.tokenize.call(c,u),d;return e.resolveAll&&o.push(e),c;function h(v){return s=we(s,v),O(),s[s.length-1]!==null?[]:(G(e,0),c.events=Tn(o,c.events,c),c.events)}function p(v,K){return qg(m(v),K)}function m(v){return jg(s,v)}function k(){let{_bufferIndex:v,_index:K,line:V,column:Z,offset:re}=r;return{_bufferIndex:v,_index:K,line:V,column:Z,offset:re}}function x(v){i[v.line]=v.column,Q()}function O(){for(;r._index<s.length;){let v=s[r._index];if(typeof v=="string"){let K=r._index;for(r._bufferIndex<0&&(r._bufferIndex=0);r._index===K&&r._bufferIndex<v.length;)C(v.charCodeAt(r._bufferIndex))}else C(v)}}function C(v){a=void 0,d=v,f=f(v)}function A(v){T(v)?(r.line++,r.column=1,r.offset+=v===-3?2:1,Q()):v!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===s[r._index].length&&(r._bufferIndex=-1,r._index++)),c.previous=v,a=!0}function z(v,K){let V=K||{};return V.type=v,V.start=k(),c.events.push(["enter",V,c]),l.push(V),V}function S(v){let K=l.pop();return K.end=k(),c.events.push(["exit",K,c]),K}function I(v,K){G(v,K.from)}function R(v,K){K.restore()}function q(v,K){return V;function V(Z,re,Qe){let rt,g,Ve,ct;return Array.isArray(Z)?Pe(Z):"tokenize"in Z?Pe([Z]):y(Z);function y(ue){return yr;function yr(ft){let Nn=ft!==null&&ue[ft],Wt=ft!==null&&ue.null,as=[...Array.isArray(Nn)?Nn:Nn?[Nn]:[],...Array.isArray(Wt)?Wt:Wt?[Wt]:[]];return Pe(as)(ft)}}function Pe(ue){return rt=ue,g=0,ue.length===0?Qe:Mn(ue[g])}function Mn(ue){return yr;function yr(ft){return ct=X(),Ve=ue,ue.partial||(c.currentConstruct=ue),ue.name&&c.parser.constructs.disable.null.includes(ue.name)?Oi(ft):ue.tokenize.call(K?Object.assign(Object.create(c),K):c,u,Ei,Oi)(ft)}}function Ei(ue){return a=!0,v(Ve,ct),re}function Oi(ue){return a=!0,ct.restore(),++g<rt.length?Mn(rt[g]):Qe}}}function G(v,K){v.resolveAll&&!o.includes(v)&&o.push(v),v.resolve&&Te(c.events,K,c.events.length-K,v.resolve(c.events.slice(K),c)),v.resolveTo&&(c.events=v.resolveTo(c.events,c))}function X(){let v=k(),K=c.previous,V=c.currentConstruct,Z=c.events.length,re=Array.from(l);return{from:Z,restore:Qe};function Qe(){r=v,c.previous=K,c.currentConstruct=V,c.events.length=Z,l=re,Q()}}function Q(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function jg(n,e){let t=e.start._index,r=e.start._bufferIndex,i=e.end._index,o=e.end._bufferIndex,s;if(t===i)s=[n[t].slice(r,o)];else{if(s=n.slice(t,i),r>-1){let l=s[0];typeof l=="string"?s[0]=l.slice(r):s.shift()}o>0&&s.push(n[i].slice(0,o))}return s}function qg(n,e){let t=-1,r=[],i;for(;++t<n.length;){let o=n[t],s;if(typeof o=="string")s=o;else switch(o){case-5:{s="\r";break}case-4:{s=`
|
|
3
|
+
`;break}case-3:{s=`\r
|
|
4
|
+
`;break}case-2:{s=e?" ":" ";break}case-1:{if(!e&&i)continue;s=" ";break}default:s=String.fromCharCode(o)}i=o===-2,r.push(s)}return r.join("")}function Ns(n){let r={constructs:_u([Ms,...(n||{}).extensions||[]]),content:i(Wu),defined:[],document:i(Uu),flow:i(Gu),lazy:{},string:i(Yu),text:i(Xu)};return r;function i(o){return s;function s(l){return tc(r,o,l)}}}function Is(n){for(;!Fi(n););return n}var nc=/[\0\t\n\r]/g;function Es(){let n=1,e="",t=!0,r;return i;function i(o,s,l){o=e+(typeof o=="string"?o.toString():new TextDecoder(s||void 0).decode(o));let a=[],u=0;for(e="",t&&(o.charCodeAt(0)===65279&&u++,t=void 0);u<o.length;){nc.lastIndex=u;let c=nc.exec(o),f=c&&c.index!==void 0?c.index:o.length,d=o.charCodeAt(f);if(!c){e=o.slice(u);break}if(d===10&&u===f&&r)a.push(-3),r=void 0;else switch(r&&(a.push(-5),r=void 0),u<f&&(a.push(o.slice(u,f)),n+=f-u),d){case 0:{a.push(65533),n++;break}case 9:{let h=Math.ceil(n/4)*4;for(a.push(-2);n++<h;)a.push(-1);break}case 10:{a.push(-4),n=1;break}default:r=!0,n=1}u=f+1}return l&&(r&&a.push(-5),e&&a.push(e),a.push(null)),a}}var Wg=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Wi(n){return n.replace(Wg,Hg)}function Hg(n,e,t){if(e)return e;if(t.charCodeAt(0)===35){let i=t.charCodeAt(1),o=i===120||i===88;return vi(t.slice(o?2:1),o?16:10)}return On(t)||n}function Ot(n){return!n||typeof n!="object"?"":"position"in n||"type"in n?rc(n.position):"start"in n||"end"in n?rc(n):"line"in n||"column"in n?Os(n):""}function Os(n){return ic(n&&n.line)+":"+ic(n&&n.column)}function rc(n){return Os(n&&n.start)+"-"+Os(n&&n.end)}function ic(n){return n&&typeof n=="number"?n:1}var sc={}.hasOwnProperty;function Ts(n,e,t){return e&&typeof e=="object"&&(t=e,e=void 0),Kg(t)(Is(Ns(t).document().write(Es()(n,e,!0))))}function Kg(n){let e={afterExit:[],beforeEnter:[],transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(Su),autolinkProtocol:G,autolinkEmail:G,atxHeading:s(xu),blockQuote:s(Nn),characterEscape:G,characterReference:G,codeFenced:s(Wt),codeFencedFenceInfo:l,codeFencedFenceMeta:l,codeIndented:s(Wt,l),codeText:s(as,l),codeTextData:G,data:G,codeFlowValue:G,definition:s(em),definitionDestinationString:l,definitionLabelString:l,definitionTitleString:l,emphasis:s(tm),hardBreakEscape:s(ku),hardBreakTrailing:s(ku),htmlFlow:s(bu,l),htmlFlowData:G,htmlText:s(bu,l),htmlTextData:G,image:s(nm),label:l,link:s(Su),listItem:s(rm),listItemValue:h,listOrdered:s(wu,d),listUnordered:s(wu),paragraph:s(im),reference:Pe,referenceString:l,resourceDestinationString:l,resourceTitleString:l,setextHeading:s(xu),strong:s(om),thematicBreak:s(lm)},exit:{atxHeading:u(),atxHeadingSequence:S,autolink:u(),autolinkEmail:ft,autolinkProtocol:yr,blockQuote:u(),characterEscapeValue:X,characterReferenceMarkerHexadecimal:Ei,characterReferenceMarkerNumeric:Ei,characterReferenceValue:Oi,characterReference:ue,codeFenced:u(x),codeFencedFence:k,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:X,codeIndented:u(O),codeText:u(Z),codeTextData:X,data:X,definition:u(),definitionDestinationString:z,definitionLabelString:C,definitionTitleString:A,emphasis:u(),hardBreakEscape:u(v),hardBreakTrailing:u(v),htmlFlow:u(K),htmlFlowData:X,htmlText:u(V),htmlTextData:X,image:u(Qe),label:g,labelText:rt,lineEnding:Q,link:u(re),listItem:u(),listOrdered:u(),listUnordered:u(),paragraph:u(),referenceString:Mn,resourceDestinationString:Ve,resourceTitleString:ct,resource:y,setextHeading:u(q),setextHeadingLineSequence:R,setextHeadingText:I,strong:u(),thematicBreak:u()}};lc(e,(n||{}).mdastExtensions||[]);let t={};return r;function r(b){let N={type:"root",children:[],position:void 0},L={stack:[N],tokenStack:[],config:e,enter:a,exit:c,buffer:l,resume:f,data:t},F=[],Ee=[],Y=-1;for(;++Y<b.length;)if(Ee.push(b[Y]),b[Y][1].type==="listOrdered"||b[Y][1].type==="listUnordered")if(b[Y][0]==="enter")F.push(Ee.length-1);else{let Oe=F.pop();o(Ee,Oe)}for(b=Ee,Y=-1;++Y<b.length;){let Oe=e[b[Y][0]];b[Y][0]==="enter"&&e.beforeEnter.length>0&&i(e.beforeEnter,{...L,sliceSerialize:b[Y][2].sliceSerialize},b[Y][1]),sc.call(Oe,b[Y][1].type)&&Oe[b[Y][1].type].call({...L,sliceSerialize:b[Y][2].sliceSerialize},b[Y][1]),b[Y][0]==="exit"&&e.afterExit.length>0&&i(e.afterExit,{...L,sliceSerialize:b[Y][2].sliceSerialize},b[Y][1])}if(L.tokenStack.length>0){let Oe=L.tokenStack[L.tokenStack.length-1];(Oe[1]||oc).call(L,void 0,Oe[0])}for(N.position={start:Tt(b.length>0?b[0][1].start:{line:1,column:1,offset:0}),end:Tt(b.length>0?b[b.length-2][1].end:{line:1,column:1,offset:0})},Y=-1;++Y<e.transforms.length;)N=e.transforms[Y](N)||N;return N}function i(b,N,L){let F=-1;for(;++F<b.length;)b[F].call(N,L)}function o(b,N){let L=b.length-1,F=N-1,Ee=-1,Y=!1,Oe,it,xr,kr,br=[];for(;++F<=L;){let Be=b[F];switch(Be[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Be[0]==="enter"?Ee++:Ee--,kr=void 0;break}case"lineEndingBlank":{Be[0]==="enter"&&(Oe&&!kr&&!Ee&&!xr&&(xr=F),kr=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:kr=void 0}if(!Ee&&Be[0]==="enter"&&Be[1].type==="listItemPrefix"||Ee===-1&&Be[0]==="exit"&&(Be[1].type==="listUnordered"||Be[1].type==="listOrdered")){if(Oe){let In=F;for(it=void 0;In--;){let ht=b[In];if(ht[1].type==="lineEnding"||ht[1].type==="lineEndingBlank"){if(ht[0]==="exit")continue;it&&(b[it][1].type="lineEndingBlank",Y=!0),ht[1].type="lineEnding",it=In}else if(!(ht[1].type==="linePrefix"||ht[1].type==="blockQuotePrefix"||ht[1].type==="blockQuotePrefixWhitespace"||ht[1].type==="blockQuoteMarker"||ht[1].type==="listItemIndent"))break}xr&&(!it||xr<it)&&(Oe._spread=!0),Oe.end=Object.assign({},it?b[it][1].start:Be[1].end),br.push({at:it||F,event:["exit",Oe,Be[2]]})}if(Be[1].type==="listItemPrefix"){let In={type:"listItem",_spread:!1,start:Object.assign({},Be[1].start),end:void 0};Oe=In,br.push({at:F,event:["enter",In,Be[2]]}),xr=void 0,kr=!0}}}let Cu=b.splice(N),us=0;for(F=-1;++F<Cu.length;){for(;us<br.length&&br[us].at===N+F;)b.push(br[us++].event);b.push(Cu[F])}b[N][1]._spread=Y}function s(b,N){return L;function L(F){a.call(this,b(F),F),N&&N.call(this,F)}}function l(){this.stack.push({type:"fragment",children:[]})}function a(b,N,L){this.stack[this.stack.length-1].children.push(b),this.stack.push(b),this.tokenStack.push([N,L||void 0]),b.position={start:Tt(N.start),end:void 0}}function u(b){return N;function N(L){b&&b.call(this,L),c.call(this,L)}}function c(b,N){let L=this.stack.pop(),F=this.tokenStack.pop();if(!F)throw new Error("Cannot close `"+b.type+"` ("+Ot({start:b.start,end:b.end})+"): it\u2019s not open");F[0].type!==b.type&&(N?N.call(this,b,F[0]):(F[1]||oc).call(this,b,F[0])),L.position.end=Tt(b.end)}function f(){return Ht(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function h(b){if(this.data.expectingFirstListItemValue){let N=this.stack[this.stack.length-2];N.start=Number.parseInt(this.sliceSerialize(b),10),this.data.expectingFirstListItemValue=void 0}}function p(){let b=this.resume(),N=this.stack[this.stack.length-1];N.lang=b}function m(){let b=this.resume(),N=this.stack[this.stack.length-1];N.meta=b}function k(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function x(){let b=this.resume(),N=this.stack[this.stack.length-1];N.value=b.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function O(){let b=this.resume(),N=this.stack[this.stack.length-1];N.value=b.replace(/(\r?\n|\r)$/g,"")}function C(b){let N=this.resume(),L=this.stack[this.stack.length-1];L.label=N,L.identifier=dt(this.sliceSerialize(b)).toLowerCase()}function A(){let b=this.resume(),N=this.stack[this.stack.length-1];N.title=b}function z(){let b=this.resume(),N=this.stack[this.stack.length-1];N.url=b}function S(b){let N=this.stack[this.stack.length-1];if(!N.depth){let L=this.sliceSerialize(b).length;N.depth=L}}function I(){this.data.setextHeadingSlurpLineEnding=!0}function R(b){let N=this.stack[this.stack.length-1];N.depth=this.sliceSerialize(b).codePointAt(0)===61?1:2}function q(){this.data.setextHeadingSlurpLineEnding=void 0}function G(b){let L=this.stack[this.stack.length-1].children,F=L[L.length-1];(!F||F.type!=="text")&&(F=sm(),F.position={start:Tt(b.start),end:void 0},L.push(F)),this.stack.push(F)}function X(b){let N=this.stack.pop();N.value+=this.sliceSerialize(b),N.position.end=Tt(b.end)}function Q(b){let N=this.stack[this.stack.length-1];if(this.data.atHardBreak){let L=N.children[N.children.length-1];L.position.end=Tt(b.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&e.canContainEols.includes(N.type)&&(G.call(this,b),X.call(this,b))}function v(){this.data.atHardBreak=!0}function K(){let b=this.resume(),N=this.stack[this.stack.length-1];N.value=b}function V(){let b=this.resume(),N=this.stack[this.stack.length-1];N.value=b}function Z(){let b=this.resume(),N=this.stack[this.stack.length-1];N.value=b}function re(){let b=this.stack[this.stack.length-1];if(this.data.inReference){let N=this.data.referenceType||"shortcut";b.type+="Reference",b.referenceType=N,delete b.url,delete b.title}else delete b.identifier,delete b.label;this.data.referenceType=void 0}function Qe(){let b=this.stack[this.stack.length-1];if(this.data.inReference){let N=this.data.referenceType||"shortcut";b.type+="Reference",b.referenceType=N,delete b.url,delete b.title}else delete b.identifier,delete b.label;this.data.referenceType=void 0}function rt(b){let N=this.sliceSerialize(b),L=this.stack[this.stack.length-2];L.label=Wi(N),L.identifier=dt(N).toLowerCase()}function g(){let b=this.stack[this.stack.length-1],N=this.resume(),L=this.stack[this.stack.length-1];if(this.data.inReference=!0,L.type==="link"){let F=b.children;L.children=F}else L.alt=N}function Ve(){let b=this.resume(),N=this.stack[this.stack.length-1];N.url=b}function ct(){let b=this.resume(),N=this.stack[this.stack.length-1];N.title=b}function y(){this.data.inReference=void 0}function Pe(){this.data.referenceType="collapsed"}function Mn(b){let N=this.resume(),L=this.stack[this.stack.length-1];L.label=N,L.identifier=dt(this.sliceSerialize(b)).toLowerCase(),this.data.referenceType="full"}function Ei(b){this.data.characterReferenceType=b.type}function Oi(b){let N=this.sliceSerialize(b),L=this.data.characterReferenceType,F;L?(F=vi(N,L==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):F=On(N);let Ee=this.stack[this.stack.length-1];Ee.value+=F}function ue(b){let N=this.stack.pop();N.position.end=Tt(b.end)}function yr(b){X.call(this,b);let N=this.stack[this.stack.length-1];N.url=this.sliceSerialize(b)}function ft(b){X.call(this,b);let N=this.stack[this.stack.length-1];N.url="mailto:"+this.sliceSerialize(b)}function Nn(){return{type:"blockquote",children:[],position:void 0}}function Wt(){return{type:"code",lang:null,meta:null,value:"",position:void 0}}function as(){return{type:"inlineCode",value:"",position:void 0}}function em(){return{type:"definition",identifier:"",label:null,title:null,url:"",position:void 0}}function tm(){return{type:"emphasis",children:[],position:void 0}}function xu(){return{type:"heading",depth:0,children:[],position:void 0}}function ku(){return{type:"break",position:void 0}}function bu(){return{type:"html",value:"",position:void 0}}function nm(){return{type:"image",title:null,url:"",alt:null,position:void 0}}function Su(){return{type:"link",title:null,url:"",children:[],position:void 0}}function wu(b){return{type:"list",ordered:b.type==="listOrdered",start:null,spread:b._spread,children:[],position:void 0}}function rm(b){return{type:"listItem",spread:b._spread,checked:null,children:[],position:void 0}}function im(){return{type:"paragraph",children:[],position:void 0}}function om(){return{type:"strong",children:[],position:void 0}}function sm(){return{type:"text",value:"",position:void 0}}function lm(){return{type:"thematicBreak",position:void 0}}}function Tt(n){return{line:n.line,column:n.column,offset:n.offset}}function lc(n,e){let t=-1;for(;++t<e.length;){let r=e[t];Array.isArray(r)?lc(n,r):Ug(n,r)}}function Ug(n,e){let t;for(t in e)if(sc.call(e,t))switch(t){case"canContainEols":{let r=e[t];r&&n[t].push(...r);break}case"transforms":{let r=e[t];r&&n[t].push(...r);break}case"afterExit":case"beforeEnter":{let r=e[t];r&&n[t].push(r);break}case"enter":case"exit":{let r=e[t];r&&Object.assign(n[t],r);break}}}function oc(n,e){throw n?new Error("Cannot close `"+n.type+"` ("+Ot({start:n.start,end:n.end})+"): a different token (`"+e.type+"`, "+Ot({start:e.start,end:e.end})+") is open"):new Error("Cannot close document, a token (`"+e.type+"`, "+Ot({start:e.start,end:e.end})+") is still open")}function An(n){let e=this;e.parser=t;function t(r){return Ts(r,{...e.data("settings"),...n,extensions:e.data("micromarkExtensions")||[],mdastExtensions:e.data("fromMarkdownExtensions")||[]})}}var vn=(function(n){if(n==null)return Yg;if(typeof n=="function")return Hi(n);if(typeof n=="object")return Array.isArray(n)?Jg(n):Gg(n);if(typeof n=="string")return Qg(n);throw new Error("Expected function, string, or object as test")});function Jg(n){let e=[],t=-1;for(;++t<n.length;)e[t]=vn(n[t]);return Hi(r);function r(...i){let o=-1;for(;++o<e.length;)if(e[o].apply(this,i))return!0;return!1}}function Gg(n){let e=n;return Hi(t);function t(r){let i=r,o;for(o in n)if(i[o]!==e[o])return!1;return!0}}function Qg(n){return Hi(e);function e(t){return t&&t.type===n}}function Hi(n){return e;function e(t,r,i){return!!(Xg(t)&&n.call(this,t,typeof r=="number"?r:void 0,i||void 0))}}function Yg(){return!0}function Xg(n){return n!==null&&typeof n=="object"&&"type"in n}var Tr=vn(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);var ac={}.hasOwnProperty;function uc(n,e){let t=e||{};function r(i,...o){let s=r.invalid,l=r.handlers;if(i&&ac.call(i,n)){let a=String(i[n]);s=ac.call(l,a)?l[a]:r.unknown}if(s)return s.call(this,i,...o)}return r.handlers=t.handlers||{},r.invalid=t.invalid,r.unknown=t.unknown,r}var Zg={}.hasOwnProperty;function As(n,e){let t=-1,r;if(e.extensions)for(;++t<e.extensions.length;)As(n,e.extensions[t]);for(r in e)if(Zg.call(e,r))switch(r){case"extensions":break;case"unsafe":{cc(n[r],e[r]);break}case"join":{cc(n[r],e[r]);break}case"handlers":{ey(n[r],e[r]);break}default:n.options[r]=e[r]}return n}function cc(n,e){e&&n.push(...e)}function ey(n,e){e&&Object.assign(n,e)}function fc(n,e,t,r){let i=t.enter("blockquote"),o=t.createTracker(r);o.move("> "),o.shift(2);let s=t.indentLines(t.containerFlow(n,o.current()),ty);return i(),s}function ty(n,e,t){return">"+(t?"":" ")+n}function Ki(n,e){return hc(n,e.inConstruct,!0)&&!hc(n,e.notInConstruct,!1)}function hc(n,e,t){if(typeof e=="string"&&(e=[e]),!e||e.length===0)return t;let r=-1;for(;++r<e.length;)if(n.includes(e[r]))return!0;return!1}function vs(n,e,t,r){let i=-1;for(;++i<t.unsafe.length;){let o=t.unsafe[i];if(o.character===`
|
|
5
|
+
`&&!o.before&&!o.after&&Ki(t.stack,o))return/[\t ]/.test(r.before)?"":" "}return`\\
|
|
6
|
+
`}function dc(n,e){let t=String(n),r=t.indexOf(e),i=r,o=0,s=0;if(typeof e!="string")throw new TypeError("Expected substring");for(;r!==-1;)r===i?++o>s&&(s=o):o=1,i=r+e.length,r=t.indexOf(e,i);return s}function Ar(n,e){return!!(e.options.fences===!1&&n.value&&!n.lang&&/[^\n\r ]/.test(n.value)&&!/^[\t ]*(?:[\n\r]|$)|(?:^|[\n\r])[\t ]*$/.test(n.value))}function pc(n){let e=n.options.fence||"`";if(e!=="`"&&e!=="~")throw new Error("Cannot serialize code with `"+e+"` for `options.fence`, expected `` ` `` or `~`");return e}function mc(n,e,t,r){let i=pc(t),o=n.value||"";if(Ar(n,t)){let f=t.enter("codeIndented"),d=t.indentLines(o,ny);return f(),d}let s=t.createTracker(r),l=i.repeat(Math.max(dc(o,i)+1,3)),a=t.enter("codeFenced"),u=i==="`"?"GraveAccent":"Tilde",c=s.move(l);if(n.lang){let f=t.enter(`codeFencedLang${u}`);c+=s.move(t.safe(n.lang,{before:c,after:" ",encode:["`"],...s.current()})),f()}if(n.lang&&n.meta){let f=t.enter(`codeFencedMeta${u}`);c+=s.move(" "),c+=s.move(t.safe(n.meta,{before:c,after:`
|
|
7
|
+
`,encode:["`"],...s.current()})),f()}return c+=s.move(`
|
|
8
|
+
`),o&&(c+=s.move(o+`
|
|
9
|
+
`)),c+=s.move(l),a(),c}function ny(n,e,t){return(t?"":" ")+n}function Dn(n){let e=n.options.quote||'"';if(e!=='"'&&e!=="'")throw new Error("Cannot serialize title with `"+e+"` for `options.quote`, expected `\"`, or `'`");return e}function gc(n,e,t,r){let i=Dn(t),o=i==='"'?"Quote":"Apostrophe",s=t.enter("definition"),l=t.enter("label"),a=t.createTracker(r),u=a.move("[");return u+=a.move(t.safe(t.associationId(n),{before:u,after:"]",...a.current()})),u+=a.move("]: "),l(),!n.url||/[\0- \u007F]/.test(n.url)?(l=t.enter("destinationLiteral"),u+=a.move("<"),u+=a.move(t.safe(n.url,{before:u,after:">",...a.current()})),u+=a.move(">")):(l=t.enter("destinationRaw"),u+=a.move(t.safe(n.url,{before:u,after:n.title?" ":`
|
|
10
|
+
`,...a.current()}))),l(),n.title&&(l=t.enter(`title${o}`),u+=a.move(" "+i),u+=a.move(t.safe(n.title,{before:u,after:i,...a.current()})),u+=a.move(i),l()),s(),u}function yc(n){let e=n.options.emphasis||"*";if(e!=="*"&&e!=="_")throw new Error("Cannot serialize emphasis with `"+e+"` for `options.emphasis`, expected `*`, or `_`");return e}Ui.attention=ry;Ui.peek=iy;function Ui(n,e,t,r){let i=t.enter("phrasing"),o=t.containerPhrasing({type:"root",children:[n]},r);return i(),o}function ry(n,e){return{construct:"emphasis",markers:yc(e)==="*"?["*","_"]:["_","*"],sizes:[1]}}function iy(n,e,t){return t.options.emphasis||"*"}function Rn(n){return"&#x"+n.toString(16).toUpperCase()+";"}var kc=[],Ji=!0,At=!1,ot="skip";function Pn(n,e,t,r){if(!n||typeof n!="object")throw new Error("Unexpected value `"+n+"` for `tree`, expected node");let i=!0,o,s,l,a;if(typeof t=="function"||t&&typeof t=="object"?(o=e,s=t,r&&(i=!1)):(s=e,t&&(i=!1)),typeof s=="function")l=s;else if(s&&typeof s=="object"){if(!(s.enter===null||s.enter===void 0))if(typeof s.enter=="function")l=s.enter;else throw new Error("Unexpected value `"+s.enter+"` for `visitors.enter`, expected optional visitor");if(typeof s.exit=="function")a=s.exit;else throw new Error("Unexpected value `"+s.exit+"` for `visitors.exit`, expected visitor (pass a visitor directly if you only want an enter visitor)")}else throw new Error("Unexpected value `"+s+"` for `enter` or `visitors`, expected visitor or object with visitors");let u=vn(o),c=i?1:-1;f(n,void 0,[])();function f(d,h,p){let m=d&&typeof d=="object"?d:{};if(typeof m.type=="string"){let x=typeof m.tagName=="string"?m.tagName:typeof m.name=="string"?m.name:void 0;Object.defineProperty(k,"name",{value:"node ("+(d.type+(x?"<"+x+">":""))+")"})}return k;function k(){let x=!o||u(d,h,p[p.length-1]||void 0),O=kc;if(l&&x&&(O=xc(l(d,p,h)),O[0]===At))return O;if("children"in d&&d.children){let C=d;if(C.children&&O[0]!==ot){let A=(i?-1:C.children.length)+c,z=[...p,C];for(;A>-1&&A<C.children.length;){let S=C.children[A],I=f(S,A,z)();if(I[0]===At)return I;A=typeof I[1]=="number"?I[1]:A+c}}}if(a&&x){let C=xc(a(d,p,h));if(C[0]===ot)throw new Error("Unexpected value `"+C[0]+"` from `exit`, expected `CONTINUE`, `EXIT`, index, or nothing");if(C[0]===At||typeof C[1]=="number")return C}return O}}}function xc(n){return Array.isArray(n)?n:typeof n=="number"?[Ji,n]:n==null?kc:[n]}function Ye(n,e,t,r){let i,o,s;typeof t=="function"||t&&typeof t=="object"?(i=e,o=t,s=r):(o=e,s=t),typeof o=="function"?Pn(n,i,Ds(o),s):Pn(n,i,oy(o),s)}function oy(n){return!n||typeof n!="object"?n:{enter:typeof n.enter=="function"?Ds(n.enter):n.enter,exit:typeof n.exit=="function"?Ds(n.exit):n.exit}}function Ds(n){return e;function e(t,r,i){return n(t,i,r[r.length-1])}}function Gi(n,e){let t=!1;return Ye(n,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return t=!0,At}),!!((!n.depth||n.depth<3)&&Ht(n)&&(e.options.setext||t))}function bc(n,e,t,r){let i=Math.max(Math.min(6,n.depth||1),1),o=t.createTracker(r);if(Gi(n,t)){let f=t.enter("headingSetext"),d=t.enter("phrasing"),h=t.containerPhrasing(n,{...o.current(),before:`
|
|
11
|
+
`,after:`
|
|
12
|
+
`});return d(),f(),h+`
|
|
13
|
+
`+(i===1?"=":"-").repeat(h.length-(Math.max(h.lastIndexOf("\r"),h.lastIndexOf(`
|
|
14
|
+
`))+1))}let s="#".repeat(i),l=t.enter("headingAtx"),a=t.enter("phrasing");o.move(s+" ");let u=t.containerPhrasing(n,{before:"# ",after:`
|
|
15
|
+
`,...o.current()}),c=u.charCodeAt(0);return(c===9||c===32)&&(u=Rn(c)+u.slice(1)),u=u?s+" "+u:s,t.options.closeAtx&&(u+=" "+s),a(),l(),u}Rs.peek=sy;function Rs(n){return n.value||""}function sy(){return"<"}Ps.peek=ly;function Ps(n,e,t,r){let i=Dn(t),o=i==='"'?"Quote":"Apostrophe",s=t.enter("image"),l=t.enter("label"),a=t.createTracker(r),u=a.move("![");return u+=a.move(t.safe(n.alt,{before:u,after:"]",...a.current()})),u+=a.move("]("),l(),!n.url&&n.title||/[\0- \u007F]/.test(n.url)?(l=t.enter("destinationLiteral"),u+=a.move("<"),u+=a.move(t.safe(n.url,{before:u,after:">",...a.current()})),u+=a.move(">")):(l=t.enter("destinationRaw"),u+=a.move(t.safe(n.url,{before:u,after:n.title?" ":")",...a.current()}))),l(),n.title&&(l=t.enter(`title${o}`),u+=a.move(" "+i),u+=a.move(t.safe(n.title,{before:u,after:i,...a.current()})),u+=a.move(i),l()),u+=a.move(")"),s(),u}function ly(){return"!"}Bs.peek=ay;function Bs(n,e,t,r){let i=n.referenceType,o=t.enter("imageReference"),s=t.enter("label"),l=t.createTracker(r),a=l.move("!["),u=t.safe(n.alt,{before:a,after:"]",...l.current()});a+=l.move(u+"]["),s();let c=t.stack;t.stack=c.filter(function(d){return d!=="phrasing"}),s=t.enter("reference");let f=t.safe(t.associationId(n),{before:a,after:"]",...l.current()});return s(),t.stack=c,o(),i==="full"||!u||u!==f?a+=l.move(f+"]"):i==="shortcut"?a=a.slice(0,-1):a+=l.move("]"),a}function ay(){return"!"}Ls.peek=uy;function Ls(n,e,t){let r=n.value||"",i="`",o=-1;for(;new RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^\n\r ]/.test(r)&&(/^[\n\r ]/.test(r)&&/[\n\r ]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++o<t.unsafe.length;){let s=t.unsafe[o],l=t.compilePattern(s);if(!s.atBreak)continue;let a;for(;a=l.exec(r);){let u=a.index;r.charCodeAt(u)===10&&r.charCodeAt(u-1)===13&&u--,r=r.slice(0,u)+" "+r.slice(a.index+1)}}return i+r+i}function uy(){return"`"}function zs(n,e){let t=Ht(n);return!!(!e.options.resourceLink&&n.url&&!n.title&&n.children&&n.children.length===1&&n.children[0].type==="text"&&(t===n.url||"mailto:"+t===n.url)&&/^[a-z][+\-.a-z]+:/i.test(n.url)&&!/[\0- <>\u007F]/.test(n.url))}Fs.peek=cy;function Fs(n,e,t,r){let i=Dn(t),o=i==='"'?"Quote":"Apostrophe",s=t.createTracker(r);if(zs(n,t)){let c=t.stack;t.stack=c.filter(function(h){return h!=="phrasing"});let f=t.enter("autolink"),d=s.move("<");return d+=s.move(t.containerPhrasing(n,{before:d,after:">",...s.current()})),d+=s.move(">"),f(),t.stack=c,d}let l=t.enter("link"),a=t.enter("label"),u=s.move("[");return u+=s.move(t.containerPhrasing(n,{before:u,after:"](",...s.current()})),u+=s.move("]("),a(),!n.url&&n.title||/[\0- \u007F]/.test(n.url)?(a=t.enter("destinationLiteral"),u+=s.move("<"),u+=s.move(t.safe(n.url,{before:u,after:">",...s.current()})),u+=s.move(">")):(a=t.enter("destinationRaw"),u+=s.move(t.safe(n.url,{before:u,after:n.title?" ":")",...s.current()}))),a(),n.title&&(a=t.enter(`title${o}`),u+=s.move(" "+i),u+=s.move(t.safe(n.title,{before:u,after:i,...s.current()})),u+=s.move(i),a()),u+=s.move(")"),l(),u}function cy(n,e,t){return zs(n,t)?"<":"["}_s.peek=fy;function _s(n,e,t,r){let i=n.referenceType,o=t.enter("linkReference"),s=t.enter("label"),l=t.createTracker(r),a=l.move("["),u=t.containerPhrasing(n,{before:a,after:"]",...l.current()});a+=l.move(u+"]["),s();let c=t.stack;t.stack=c.filter(function(d){return d!=="phrasing"}),s=t.enter("reference");let f=t.safe(t.associationId(n),{before:a,after:"]",...l.current()});return s(),t.stack=c,o(),i==="full"||!u||u!==f?a+=l.move(f+"]"):i==="shortcut"?a=a.slice(0,-1):a+=l.move("]"),a}function fy(){return"["}function Bn(n){let e=n.options.bullet||"*";if(e!=="*"&&e!=="+"&&e!=="-")throw new Error("Cannot serialize items with `"+e+"` for `options.bullet`, expected `*`, `+`, or `-`");return e}function Sc(n){let e=Bn(n),t=n.options.bulletOther;if(!t)return e==="*"?"-":"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(t===e)throw new Error("Expected `bullet` (`"+e+"`) and `bulletOther` (`"+t+"`) to be different");return t}function wc(n){let e=n.options.bulletOrdered||".";if(e!=="."&&e!==")")throw new Error("Cannot serialize items with `"+e+"` for `options.bulletOrdered`, expected `.` or `)`");return e}function Qi(n){let e=n.options.rule||"*";if(e!=="*"&&e!=="-"&&e!=="_")throw new Error("Cannot serialize rules with `"+e+"` for `options.rule`, expected `*`, `-`, or `_`");return e}function Cc(n,e,t,r){let i=t.enter("list"),o=t.bulletCurrent,s=n.ordered?wc(t):Bn(t),l=n.ordered?s==="."?")":".":Sc(t),a=e&&t.bulletLastUsed?s===t.bulletLastUsed:!1;if(!n.ordered){let c=n.children?n.children[0]:void 0;if((s==="*"||s==="-")&&c&&(!c.children||!c.children[0])&&t.stack[t.stack.length-1]==="list"&&t.stack[t.stack.length-2]==="listItem"&&t.stack[t.stack.length-3]==="list"&&t.stack[t.stack.length-4]==="listItem"&&t.indexStack[t.indexStack.length-1]===0&&t.indexStack[t.indexStack.length-2]===0&&t.indexStack[t.indexStack.length-3]===0&&(a=!0),Qi(t)===s&&c){let f=-1;for(;++f<n.children.length;){let d=n.children[f];if(d&&d.type==="listItem"&&d.children&&d.children[0]&&d.children[0].type==="thematicBreak"){a=!0;break}}}}a&&(s=l),t.bulletCurrent=s;let u=t.containerFlow(n,r);return t.bulletLastUsed=s,t.bulletCurrent=o,i(),u}function Mc(n){let e=n.options.listItemIndent||"one";if(e!=="tab"&&e!=="one"&&e!=="mixed")throw new Error("Cannot serialize items with `"+e+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return e}function Nc(n,e,t,r){let i=Mc(t),o=t.bulletCurrent||Bn(t);e&&e.type==="list"&&e.ordered&&(o=(typeof e.start=="number"&&e.start>-1?e.start:1)+(t.options.incrementListMarker===!1?0:e.children.indexOf(n))+o);let s=o.length+1;(i==="tab"||i==="mixed"&&(e&&e.type==="list"&&e.spread||n.spread))&&(s=Math.ceil(s/4)*4);let l=t.createTracker(r);l.move(o+" ".repeat(s-o.length)),l.shift(s);let a=t.enter("listItem"),u=t.indentLines(t.containerFlow(n,l.current()),c);return a(),u;function c(f,d,h){return d?(h?"":" ".repeat(s))+f:(h?o:o+" ".repeat(s-o.length))+f}}function Ic(n,e,t,r){let i=t.enter("paragraph"),o=t.enter("phrasing"),s=t.containerPhrasing(n,r);return o(),i(),s}function Ec(n,e,t,r){if(!n.children.some(function(l){return Tr(l)}))return t.containerFlow(n,r);let o=t.enter("phrasing"),s=t.containerPhrasing(n,r);return o(),s}function Oc(n){let e=n.options.strong||"*";if(e!=="*"&&e!=="_")throw new Error("Cannot serialize strong with `"+e+"` for `options.strong`, expected `*`, or `_`");return e}Yi.attention=hy;Yi.peek=dy;function Yi(n,e,t,r){let i=t.enter("phrasing"),o=t.containerPhrasing({type:"root",children:[n]},r);return i(),o}function hy(n,e){return{construct:"strong",markers:Oc(e)==="*"?["*","_"]:["_","*"],sizes:[2]}}function dy(n,e,t){return t.options.strong||"*"}function Tc(n,e,t,r){let i=e?e.children:[],o=i.indexOf(n);return t.safe(n.value,{...r,afterNode:i[o+1],beforeNode:i[o-1]})}function Ac(n){let e=n.options.ruleRepetition||3;if(e<3)throw new Error("Cannot serialize rules with repetition `"+e+"` for `options.ruleRepetition`, expected `3` or more");return e}function vc(n,e,t){let r=(Qi(t)+(t.options.ruleSpaces?" ":"")).repeat(Ac(t));return t.options.ruleSpaces?r.slice(0,-1):r}var Dc={blockquote:fc,break:vs,code:mc,definition:gc,emphasis:Ui,hardBreak:vs,heading:bc,html:Rs,image:Ps,imageReference:Bs,inlineCode:Ls,link:Fs,linkReference:_s,list:Cc,listItem:Nc,paragraph:Ic,root:Ec,strong:Yi,text:Tc,thematicBreak:vc};function vr(n){if(n.charCodeAt(0)!==60)return;let e=n.charCodeAt(1);if(e===33){let l=n.charCodeAt(2);return l===45?2:l===91?5:ge(l)?4:void 0}if(e===63)return 3;let t=e===47,r=t?2:1,i=r,o=n.charCodeAt(i);if(!ge(o))return;for(;o===45||ce(o);)o=n.charCodeAt(++i);let s=n.slice(r,i).toLowerCase();return!t&&o!==47&&Er.includes(s)?1:ji.includes(s)?6:7}var Rc=[py];function py(n,e,t,r){if(e.type==="code"&&Ar(e,r)&&(n.type==="list"||n.type===e.type&&Ar(n,r)))return!1;if("spread"in t&&typeof t.spread=="boolean"){if(n.type==="paragraph"&&(n.type===e.type||e.type==="definition"||e.type==="heading"&&Gi(e,r)))return;if(n.type==="html"){let i=vr(n.value);if(i===void 0||i===6||i===7)return 1}if(n.type==="paragraph"&&e.type==="html"){let i=vr(e.value);if(i===void 0||i===7)return 1}return t.spread?1:0}}var Gt=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"],Vs=[{character:" ",after:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",before:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde"]},{character:"\r",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde","codeFencedMetaGraveAccent","codeFencedMetaTilde","destinationLiteral","headingAtx"]},{character:`
|
|
16
|
+
`,inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde","codeFencedMetaGraveAccent","codeFencedMetaTilde","destinationLiteral","headingAtx"]},{character:"\r",before:"[\\r\\n]",inConstruct:"phrasing"},{character:"\r",after:"\\r",inConstruct:"phrasing"},{character:`
|
|
17
|
+
`,before:"\\n",inConstruct:"phrasing"},{character:`
|
|
18
|
+
`,after:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",after:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",before:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde"]},{character:"!",after:"\\[",inConstruct:"phrasing",notInConstruct:Gt},{character:'"',inConstruct:"titleQuote"},{atBreak:!0,character:"#"},{character:"#",inConstruct:"headingAtx",after:`(?:[\r
|
|
19
|
+
]|$)`},{character:"&",after:"[#A-Za-z]",inConstruct:"phrasing"},{character:"'",inConstruct:"titleApostrophe"},{character:"(",inConstruct:"destinationRaw"},{before:"\\]",character:"(",inConstruct:"phrasing",notInConstruct:Gt},{atBreak:!0,before:"\\d+",character:")"},{character:")",inConstruct:"destinationRaw"},{atBreak:!0,character:"*",after:`(?:[ \r
|
|
20
|
+
*])`},{character:"*",inConstruct:"phrasing",notInConstruct:Gt},{atBreak:!0,character:"+",after:`(?:[ \r
|
|
21
|
+
])`},{atBreak:!0,character:"-",after:`(?:[ \r
|
|
22
|
+
-])`},{atBreak:!0,before:"\\d+",character:".",after:`(?:[ \r
|
|
23
|
+
]|$)`},{atBreak:!0,character:"<",after:"[!/?A-Za-z]"},{character:"<",after:"[!/?A-Za-z]",inConstruct:"phrasing",notInConstruct:Gt},{character:"<",inConstruct:"destinationLiteral"},{atBreak:!0,character:"="},{atBreak:!0,character:">"},{character:">",inConstruct:"destinationLiteral"},{atBreak:!0,character:"["},{character:"[",inConstruct:"phrasing",notInConstruct:Gt},{character:"[",inConstruct:["label","reference"]},{character:"\\",after:"[\\r\\n]",inConstruct:"phrasing"},{character:"]",inConstruct:["label","reference"]},{atBreak:!0,character:"_"},{character:"_",inConstruct:"phrasing",notInConstruct:Gt},{atBreak:!0,character:"`"},{character:"`",inConstruct:["codeFencedLangGraveAccent","codeFencedMetaGraveAccent"]},{character:"`",inConstruct:"phrasing",notInConstruct:Gt},{atBreak:!0,character:"~"},{character:"<",inConstruct:"autolink"},{character:">",inConstruct:"autolink"},{character:"\x7F",inConstruct:"autolink"}],Pc=-1;for(;++Pc<33;)Vs.push({character:String.fromCharCode(Pc),inConstruct:"autolink"});function Bc(n){return n.label||!n.identifier?n.label||"":Wi(n.identifier)}function Lc(n){if(!n._compiled){let e=(n.atBreak?"[\\r\\n][\\t ]*":"")+(n.before?"(?:"+n.before+")":"");n._compiled=new RegExp((n.beforeNode?"^":e?"("+e+")":"")+(/[$()*+.?[\\\]^{|}]/.test(n.character)?"\\":"")+n.character+(n.afterNode?"$":n.after?"(?:"+n.after+")":""),n.unicode?"gu":"g")}return n._compiled}function Dr(n){let e=n.codePointAt(0);return e===void 0?"":String.fromCodePoint(e)}function Ln(n){let e=n.codePointAt(n.length-2);return e!==void 0&&e>65535?n.slice(-2):n.slice(-1)}function $s(n,e,t){let r=We(n),i=We(e);return r===void 0?i===void 0?t==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}var my=new Map([["*",!1],["_",!0]]);function gy(n,e,t){let r=new Set;for(let o of n){let s=t.get(o);if(s&&o.attention&&e.some(l=>l.attention===o.attention))for(let l of s.tokens)r.add(l.attention)}let i=[];for(let o of n)o.attention&&r.delete(o.attention)&&i.push(o.attention);return i.reverse(),i}function zc(n,e,t){let r=[],i=new Map,o=new Map,s=0;for(;s<n.length;){if(!n[s].attention){s++;continue}let l=n[s].value.charAt(0),a=my.get(l),u=s+1;for(;u<n.length&&n[u].attention&&n[u].value.charAt(0)===l;)u++;let c=s?n[s-1].value:e,f=We(c.charCodeAt(c.length-1)),d=We((u<n.length?n[u].value:t).charCodeAt(0)),h=!d||d===2&&!!f,p=!f||f===2&&!!d,m={tokens:n.slice(s,u),markers:[],start:0,end:0,open:a?h&&(!!f||!p):h,close:a?p&&(!!d||!h):p,split:a!==void 0};for(let k of m.tokens){i.set(k,[...m.tokens]),o.set(k,m);let x=k.value.length;for(;x--;)m.markers.push(k)}m.end=m.markers.length,r.push(m),s=u}for(xy(r,i),s=-1;++s<n.length;){let l=i.get(n[s]);if(l)return{attention:gy(n,l,o),index:s}}}function Fc(n,e,t){return js(_c(n,e,t),t.before,t.after)}function Xi(n,e){let t=n[e?0:n.length-1];if(!t||t.attention)return;let r=e?Dr(t.value):Ln(t.value),i=Rn(r.codePointAt(0));t.value=e?i+t.value.slice(r.length):t.value.slice(0,t.value.length-r.length)+i}function yy(n,e,t,r,i){for(let o of t.attention){let s=e.get(o)||o.sequences[0];for(let l of o.sequences){if(l===s)continue;let a=new Map(e);a.set(o,l);let u=qs(n,a,r,i),c=zc(u,r,i);if(!c||c.index>t.index)return{chosen:a,mistake:c,tokens:u}}}}function xy(n,e){let t=0;for(;t<n.length;){let r=n[t],i=r.tokens[0].value.charAt(0),o=r.end-r.start,s=r.close&&o?t:0;for(;s--;){let l=n[s],a=l.end-l.start;if(l.tokens[0].value.charAt(0)===i&&l.open&&a&&(r.split?!((l.close||r.open)&&o%3)||(a+o)%3:a===l.markers.length&&a===o)){let u=r.split?a>1&&o>1?2:1:o,c=l.markers.slice(l.end-u,l.end),f=r.markers.slice(r.start,r.start+u),d=c[0],h=f[0];if(d===c[u-1]&&d.value.length===u&&h===f[u-1]&&h.value.length===u&&d.attention===h.attention)e.delete(d),e.delete(h);else{let p=[...new Set([...c,...f])];for(let m of p){let k=e.get(m);k&&k.push(...p)}}l.end-=u,r.start+=u;break}}(s===-1||r.start===r.end)&&t++}}function ky(n,e,t){if(e.length===0)throw new Error("Cannot serialize `"+n+"` as attention without markers, expected one or more markers");if(t.length===0)throw new Error("Cannot serialize `"+n+"` as attention without sizes, expected one or more sizes");for(let i of t)if(!Number.isSafeInteger(i)||i<1)throw new Error("Cannot serialize `"+n+"` as attention with `"+i+"` as size, expected positive integer");let r=[];for(let i of e){if(i.length!==1)throw new Error("Cannot serialize `"+n+"` as attention with `"+i+"` as marker, expected a single ascii character");if(!Di(i.charCodeAt(0)))throw new Error("Cannot serialize `"+n+"` as attention with `"+i+"` as marker, expected ascii punctuation");for(let o of t)r.push(i.repeat(o))}return r}function _c(n,e,t){let r=e.indexStack,i=n.children||[],o=[],s=-1,l=t.before;r.push(-1);let a=e.createTracker(t);for(;++s<i.length;){let u=i[s],c;if(r[r.length-1]=s,s+1<i.length){let h=e.handle.handlers[i[s+1].type];h&&h.peek&&(h=h.peek),c=h?Dr(h(i[s+1],n,e,{before:"",after:"",...a.current()})):""}else c=t.after;let f=o[o.length-1];typeof f=="string"&&(l==="\r"||l===`
|
|
24
|
+
`)&&u.type==="html"&&vr(u.value)!==7&&(o[o.length-1]=f.replace(/(\r?\n|\r)$/," "),l=" ",a=e.createTracker(t),a.move(js(o,t.before,t.after)));let d=e.handle.handlers[u.type];if(d&&d.attention){let{construct:h,markers:p,sizes:m}=d.attention(u,e),k=ky(u.type,p,m),x=k[0],O=e.enter(h);a.move(x);let C=_c(u,e,{...a.current(),before:x,after:x});a.move(js(C,x,x)),a.move(x),O(),o.push({children:C,sequences:k}),l=x.charAt(x.length-1)}else{let h=e.handle(u,n,e,{...a.current(),after:c,before:l});if(!h)continue;a.move(h),o.push(h),l=Ln(h)}}return r.pop(),o}function qs(n,e,t,r){let i=[],o,s=Ln(t),l=-1;for(;++l<n.length;){let a=n[l];if(typeof a=="string"){let C={value:a,attention:void 0};o&&o===Dr(a)&&Xi([C],!0),o=void 0,i.push(C),C.value&&(s=Ln(C.value));continue}let u=e.get(a)||a.sequences[0],c=u.charAt(0),f=n[l+1],d=s,h=Dr(f===void 0?r:typeof f=="string"?f:e.get(f)||f.sequences[0]),p=qs(a.children,e,u,u),m=p.length>0?p[0].value:"",k=$s(d.charCodeAt(d.length-1),m.charCodeAt(0),c);k.inside&&Xi(p,!0);let x=p.length>0?Ln(p[p.length-1].value):"",O=$s(h.charCodeAt(0),x.charCodeAt(x.length-1),c);O.inside&&Xi(p,!1),k.outside&&d!==`
|
|
25
|
+
`&&d!=="\r"&&Xi(i,!1),O.outside&&(o=h),i.push({value:u,attention:a},...p,{value:u,attention:a}),s=u.charAt(u.length-1)}return i}function js(n,e,t){let r=new Map,i=qs(n,r,e,t),o=i,s=zc(o,e,t);for(;s;){let a=yy(n,r,s,e,t);if(!a){o=i;break}r=a.chosen,o=a.tokens,s=a.mistake}let l="";for(let a of o)l+=a.value;return l}function Vc(n,e,t){let r=e.indexStack,i=n.children||[],o=e.createTracker(t),s=[],l=-1;for(r.push(-1);++l<i.length;){let a=i[l];r[r.length-1]=l,s.push(o.move(e.handle(a,n,e,{before:`
|
|
26
|
+
`,after:`
|
|
27
|
+
`,...o.current()}))),a.type!=="list"&&(e.bulletLastUsed=void 0),l<i.length-1&&s.push(o.move(by(a,i[l+1],n,e)))}return r.pop(),s.join("")}function by(n,e,t,r){let i=r.join.length;for(;i--;){let o=r.join[i](n,e,t,r);if(o===!0||o===1)break;if(typeof o=="number")return`
|
|
28
|
+
`.repeat(1+o);if(o===!1)return`
|
|
29
|
+
|
|
30
|
+
<!---->
|
|
31
|
+
|
|
32
|
+
`}return`
|
|
33
|
+
|
|
34
|
+
`}var Sy=/\r?\n|\r/g;function $c(n,e){let t=[],r=0,i=0,o;for(;o=Sy.exec(n);)s(n.slice(r,o.index)),t.push(o[0]),r=o.index+o[0].length,i++;return s(n.slice(r)),t.join("");function s(l){t.push(e(l,i,!l))}}var Ws={}.hasOwnProperty;function Wc(n,e,t){let r=(t.before||"")+(e||"")+(t.after||""),i=[],o=[],s={},l=n.stack.includes("autolink"),a=t.before?t.before.length:0,u=r.length-(t.after?t.after.length:0),c=-1;for(;++c<n.unsafe.length;){let h=n.unsafe[c];if(!Ki(n.stack,h)||!jc(h.beforeNode,t.beforeNode)||!jc(h.afterNode,t.afterNode))continue;let p=n.compilePattern(h),m=h.beforeNode?a:0,k=r.slice(m,h.afterNode?u:void 0),x;for(;x=p.exec(k);){let O="before"in h||!!h.atBreak,C="after"in h,A=m+x.index+(O?x[1].length:0);Ws.call(s,A)?(s[A].before&&!O&&(s[A].before=!1),s[A].after&&!C&&(s[A].after=!1)):(i.push(A),s[A]={before:O,after:C})}}i.sort(wy);let f=a;for(c=-1;++c<i.length;){let h=i[c];if(!(h<f||h>=u)){if(r.charAt(h)==="_"&&h>0&&We(r.charCodeAt(h-1))===void 0&&!Ws.call(s,h-1)&&!(h-1===a&&/[*_]/.test(r.charAt(a-1)))){let p=h+1;for(;p<u&&r.charAt(p)==="_";)p++;let m=p-h-1;if(i[c+m]===p-1&&p<r.length&&We(r.charCodeAt(p))===void 0&&!Ws.call(s,p)&&!(p===u-1&&/[*_]/.test(r.charAt(u)))){c+=m;continue}}if(!(h+1<u&&i[c+1]===h+1&&s[h].after&&!s[h+1].before&&!s[h+1].after||i[c-1]===h-1&&s[h].before&&!s[h-1].before&&!s[h-1].after)){if(f!==h){let p=r.slice(f,h);o.push(l?p:qc(p,"\\"))}f=h,l?(o.push("%"+r.charCodeAt(h).toString(16).toUpperCase().padStart(2,"0")),f++):/[!-/:-@[-`{-~]/.test(r.charAt(h))&&(!t.encode||!t.encode.includes(r.charAt(h)))?o.push("\\"):(o.push(Rn(r.charCodeAt(h))),f++)}}}let d=r.slice(f,u);return o.push(l?d:qc(d,t.after)),o.join("")}function jc(n,e){return n?e?typeof n=="string"?n===e.type:n.includes(e.type):!1:!0}function wy(n,e){return n-e}function qc(n,e){let t=/\\(?=[!-/:-@[-`{-~])/g,r=[],i=[],o=n+e,s=-1,l=0,a;for(;a=t.exec(o);)r.push(a.index);for(;++s<r.length;)l!==r[s]&&i.push(n.slice(l,r[s])),i.push("\\"),l=r[s];return i.push(n.slice(l)),i.join("")}function Hc(n){let e=n||{},t=e.now||{},r=e.lineShift||0,i=t.line||1,o=t.column||1;return{move:a,current:s,shift:l};function s(){return{now:{line:i,column:o},lineShift:r}}function l(u){r+=u}function a(u){let c=u||"",f=c.split(/\r?\n|\r/g),d=f[f.length-1];return i+=f.length-1,o=f.length===1?o+d.length:1+d.length+r,c}}function Hs(n,e){let t=e||{},r={associationId:Bc,bulletCurrent:void 0,bulletLastUsed:void 0,containerPhrasing:Iy,containerFlow:Ey,createTracker:Hc,compilePattern:Lc,enter:o,handlers:{...Dc},handle:void 0,indentLines:$c,indexStack:[],join:[...Rc],options:{},safe:Oy,stack:[],unsafe:[...Vs]};As(r,t),r.options.tightDefinitions&&r.join.push(Ny),r.handle=uc("type",{invalid:Cy,unknown:My,handlers:r.handlers});let i=r.handle(Tr(n)?{type:"root",children:[n]}:n,void 0,r,{before:`
|
|
35
|
+
`,after:`
|
|
36
|
+
`,now:{line:1,column:1},lineShift:0});return i&&i.charCodeAt(i.length-1)!==10&&i.charCodeAt(i.length-1)!==13&&(i+=`
|
|
37
|
+
`),i;function o(s){return r.stack.push(s),l;function l(){r.stack.pop()}}}function Cy(n){throw new Error("Cannot handle value `"+n+"`, expected node")}function My(n){let e=n;throw new Error("Cannot handle unknown node `"+e.type+"`")}function Ny(n,e){if(n.type==="definition"&&n.type===e.type)return 0}function Iy(n,e){return Fc(n,this,e)}function Ey(n,e){return Vc(n,this,e)}function Oy(n,e){return Wc(this,n,e)}function zn(n){let e=this;e.compiler=t;function t(r){return Hs(r,{...e.data("settings"),...n,extensions:e.data("toMarkdownExtensions")||[]})}}function Ks(n){if(n)throw n}var to=gm(ef(),1);function Rr(n){if(typeof n!="object"||n===null)return!1;let e=Object.getPrototypeOf(n);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in n)&&!(Symbol.iterator in n)}function Us(){let n=[],e={run:t,use:r};return e;function t(...i){let o=-1,s=i.pop();if(typeof s!="function")throw new TypeError("Expected function as last argument, not "+s);l(null,...i);function l(a,...u){let c=n[++o],f=-1;if(a){s(a);return}for(;++f<i.length;)(u[f]===null||u[f]===void 0)&&(u[f]=i[f]);i=u,c?tf(c,l)(...u):s(null,...u)}}function r(i){if(typeof i!="function")throw new TypeError("Expected `middelware` to be a function, not "+i);return n.push(i),e}}function tf(n,e){let t;return r;function r(...s){let l=n.length>s.length,a;l&&s.push(i);try{a=n.apply(this,s)}catch(u){let c=u;if(l&&t)throw c;return i(c)}l||(a&&a.then&&typeof a.then=="function"?a.then(o,i):a instanceof Error?i(a):o(a))}function i(s,...l){t||(t=!0,e(s,...l))}function o(s){i(null,s)}}var se=class extends Error{constructor(e,t,r){super(),typeof t=="string"&&(r=t,t=void 0);let i="",o={},s=!1;if(t&&("line"in t&&"column"in t?o={place:t}:"start"in t&&"end"in t?o={place:t}:"type"in t?o={ancestors:[t],place:t.position}:o={...t}),typeof e=="string"?i=e:!o.cause&&e&&(s=!0,i=e.message,o.cause=e),!o.ruleId&&!o.source&&typeof r=="string"){let a=r.indexOf(":");a===-1?o.ruleId=r:(o.source=r.slice(0,a),o.ruleId=r.slice(a+1))}if(!o.place&&o.ancestors&&o.ancestors){let a=o.ancestors[o.ancestors.length-1];a&&(o.place=a.position)}let l=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=l?l.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=l?l.line:void 0,this.name=Ot(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=s&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};se.prototype.file="";se.prototype.name="";se.prototype.reason="";se.prototype.message="";se.prototype.stack="";se.prototype.column=void 0;se.prototype.line=void 0;se.prototype.ancestors=void 0;se.prototype.cause=void 0;se.prototype.fatal=void 0;se.prototype.place=void 0;se.prototype.ruleId=void 0;se.prototype.source=void 0;var Xe={basename:Ty,dirname:Ay,extname:vy,join:Dy,sep:"/"};function Ty(n,e){if(e!==void 0&&typeof e!="string")throw new TypeError('"ext" argument must be a string');Pr(n);let t=0,r=-1,i=n.length,o;if(e===void 0||e.length===0||e.length>n.length){for(;i--;)if(n.codePointAt(i)===47){if(o){t=i+1;break}}else r<0&&(o=!0,r=i+1);return r<0?"":n.slice(t,r)}if(e===n)return"";let s=-1,l=e.length-1;for(;i--;)if(n.codePointAt(i)===47){if(o){t=i+1;break}}else s<0&&(o=!0,s=i+1),l>-1&&(n.codePointAt(i)===e.codePointAt(l--)?l<0&&(r=i):(l=-1,r=s));return t===r?r=s:r<0&&(r=n.length),n.slice(t,r)}function Ay(n){if(Pr(n),n.length===0)return".";let e=-1,t=n.length,r;for(;--t;)if(n.codePointAt(t)===47){if(r){e=t;break}}else r||(r=!0);return e<0?n.codePointAt(0)===47?"/":".":e===1&&n.codePointAt(0)===47?"//":n.slice(0,e)}function vy(n){Pr(n);let e=n.length,t=-1,r=0,i=-1,o=0,s;for(;e--;){let l=n.codePointAt(e);if(l===47){if(s){r=e+1;break}continue}t<0&&(s=!0,t=e+1),l===46?i<0?i=e:o!==1&&(o=1):i>-1&&(o=-1)}return i<0||t<0||o===0||o===1&&i===t-1&&i===r+1?"":n.slice(i,t)}function Dy(...n){let e=-1,t;for(;++e<n.length;)Pr(n[e]),n[e]&&(t=t===void 0?n[e]:t+"/"+n[e]);return t===void 0?".":Ry(t)}function Ry(n){Pr(n);let e=n.codePointAt(0)===47,t=Py(n,!e);return t.length===0&&!e&&(t="."),t.length>0&&n.codePointAt(n.length-1)===47&&(t+="/"),e?"/"+t:t}function Py(n,e){let t="",r=0,i=-1,o=0,s=-1,l,a;for(;++s<=n.length;){if(s<n.length)l=n.codePointAt(s);else{if(l===47)break;l=47}if(l===47){if(!(i===s-1||o===1))if(i!==s-1&&o===2){if(t.length<2||r!==2||t.codePointAt(t.length-1)!==46||t.codePointAt(t.length-2)!==46){if(t.length>2){if(a=t.lastIndexOf("/"),a!==t.length-1){a<0?(t="",r=0):(t=t.slice(0,a),r=t.length-1-t.lastIndexOf("/")),i=s,o=0;continue}}else if(t.length>0){t="",r=0,i=s,o=0;continue}}e&&(t=t.length>0?t+"/..":"..",r=2)}else t.length>0?t+="/"+n.slice(i+1,s):t=n.slice(i+1,s),r=s-i-1;i=s,o=0}else l===46&&o>-1?o++:o=-1}return t}function Pr(n){if(typeof n!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(n))}var nf={cwd:By};function By(){return"/"}function Fn(n){return!!(n!==null&&typeof n=="object"&&"href"in n&&n.href&&"protocol"in n&&n.protocol&&n.auth===void 0)}function rf(n){if(typeof n=="string")n=new URL(n);else if(!Fn(n)){let e=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+n+"`");throw e.code="ERR_INVALID_ARG_TYPE",e}if(n.protocol!=="file:"){let e=new TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return Ly(n)}function Ly(n){if(n.hostname!==""){let r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}let e=n.pathname,t=-1;for(;++t<e.length;)if(e.codePointAt(t)===37&&e.codePointAt(t+1)===50){let r=e.codePointAt(t+2);if(r===70||r===102){let i=new TypeError("File URL path must not include encoded / characters");throw i.code="ERR_INVALID_FILE_URL_PATH",i}}return decodeURIComponent(e)}var Js=["history","path","basename","stem","extname","dirname"],Br=class{constructor(e){let t;e?Fn(e)?t={path:e}:typeof e=="string"||zy(e)?t={value:e}:t=e:t={},this.cwd="cwd"in t?"":nf.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<Js.length;){let o=Js[r];o in t&&t[o]!==void 0&&t[o]!==null&&(this[o]=o==="history"?[...t[o]]:t[o])}let i;for(i in t)Js.includes(i)||(this[i]=t[i])}get basename(){return typeof this.path=="string"?Xe.basename(this.path):void 0}set basename(e){Qs(e,"basename"),Gs(e,"basename"),this.path=Xe.join(this.dirname||"",e)}get dirname(){return typeof this.path=="string"?Xe.dirname(this.path):void 0}set dirname(e){of(this.basename,"dirname"),this.path=Xe.join(e||"",this.basename)}get extname(){return typeof this.path=="string"?Xe.extname(this.path):void 0}set extname(e){if(Gs(e,"extname"),of(this.dirname,"extname"),e){if(e.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(e.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Xe.join(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){Fn(e)&&(e=rf(e)),Qs(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path=="string"?Xe.basename(this.path,this.extname):void 0}set stem(e){Qs(e,"stem"),Gs(e,"stem"),this.path=Xe.join(this.dirname||"",e+(this.extname||""))}fail(e,t,r){let i=this.message(e,t,r);throw i.fatal=!0,i}info(e,t,r){let i=this.message(e,t,r);return i.fatal=void 0,i}message(e,t,r){let i=new se(e,t,r);return this.path&&(i.name=this.path+":"+i.name,i.file=this.path),i.fatal=!1,this.messages.push(i),i}toString(e){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(e||void 0).decode(this.value)}};function Gs(n,e){if(n&&n.includes(Xe.sep))throw new Error("`"+e+"` cannot be a path: did not expect `"+Xe.sep+"`")}function Qs(n,e){if(!n)throw new Error("`"+e+"` cannot be empty")}function of(n,e){if(!n)throw new Error("Setting `"+e+"` requires `path` to be set too")}function zy(n){return!!(n&&typeof n=="object"&&"byteLength"in n&&"byteOffset"in n)}var sf=(function(n){let r=this.constructor.prototype,i=r[n],o=function(){return i.apply(o,arguments)};return Object.setPrototypeOf(o,r),o});var Fy={}.hasOwnProperty,el=class n extends sf{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=Us()}copy(){let e=new n,t=-1;for(;++t<this.attachers.length;){let r=this.attachers[t];e.use(...r)}return e.data((0,to.default)(!0,{},this.namespace)),e}data(e,t){return typeof e=="string"?arguments.length===2?(Zs("data",this.frozen),this.namespace[e]=t,this):Fy.call(this.namespace,e)&&this.namespace[e]||void 0:e?(Zs("data",this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;let e=this;for(;++this.freezeIndex<this.attachers.length;){let[t,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);let i=t.call(e,...r);typeof i=="function"&&this.transformers.use(i)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(e){this.freeze();let t=eo(e),r=this.parser||this.Parser;return Ys("parse",r),r(String(t),t)}process(e,t){let r=this;return this.freeze(),Ys("process",this.parser||this.Parser),Xs("process",this.compiler||this.Compiler),t?i(void 0,t):new Promise(i);function i(o,s){let l=eo(e),a=r.parse(l);r.run(a,l,function(c,f,d){if(c||!f||!d)return u(c);let h=f,p=r.stringify(h,d);Vy(p)?d.value=p:d.result=p,u(c,d)});function u(c,f){c||!f?s(c):o?o(f):t(void 0,f)}}}processSync(e){let t=!1,r;return this.freeze(),Ys("processSync",this.parser||this.Parser),Xs("processSync",this.compiler||this.Compiler),this.process(e,i),af("processSync","process",t),r;function i(o,s){t=!0,Ks(o),r=s}}run(e,t,r){lf(e),this.freeze();let i=this.transformers;return!r&&typeof t=="function"&&(r=t,t=void 0),r?o(void 0,r):new Promise(o);function o(s,l){let a=eo(t);i.run(e,a,u);function u(c,f,d){let h=f||e;c?l(c):s?s(h):r(void 0,h,d)}}}runSync(e,t){let r=!1,i;return this.run(e,t,o),af("runSync","run",r),i;function o(s,l){Ks(s),i=l,r=!0}}stringify(e,t){this.freeze();let r=eo(t),i=this.compiler||this.Compiler;return Xs("stringify",i),lf(e),i(e,r)}use(e,...t){let r=this.attachers,i=this.namespace;if(Zs("use",this.frozen),e!=null)if(typeof e=="function")a(e,t);else if(typeof e=="object")Array.isArray(e)?l(e):s(e);else throw new TypeError("Expected usable value, not `"+e+"`");return this;function o(u){if(typeof u=="function")a(u,[]);else if(typeof u=="object")if(Array.isArray(u)){let[c,...f]=u;a(c,f)}else s(u);else throw new TypeError("Expected usable value, not `"+u+"`")}function s(u){if(!("plugins"in u)&&!("settings"in u))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");l(u.plugins),u.settings&&(i.settings=(0,to.default)(!0,i.settings,u.settings))}function l(u){let c=-1;if(u!=null)if(Array.isArray(u))for(;++c<u.length;){let f=u[c];o(f)}else throw new TypeError("Expected a list of plugins, not `"+u+"`")}function a(u,c){let f=-1,d=-1;for(;++f<r.length;)if(r[f][0]===u){d=f;break}if(d===-1)r.push([u,...c]);else if(c.length>0){let[h,...p]=c,m=r[d][1];Rr(m)&&Rr(h)&&(h=(0,to.default)(!0,m,h)),r[d]=[u,h,...p]}}}},Lr=new el().freeze();function Ys(n,e){if(typeof e!="function")throw new TypeError("Cannot `"+n+"` without `parser`")}function Xs(n,e){if(typeof e!="function")throw new TypeError("Cannot `"+n+"` without `compiler`")}function Zs(n,e){if(e)throw new Error("Cannot call `"+n+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function lf(n){if(!Rr(n)||typeof n.type!="string")throw new TypeError("Expected node, got `"+n+"`")}function af(n,e,t){if(!t)throw new Error("`"+n+"` finished async. Use `"+e+"` instead")}function eo(n){return _y(n)?n:new Br(n)}function _y(n){return!!(n&&typeof n=="object"&&"message"in n&&"messages"in n)}function Vy(n){return typeof n=="string"||$y(n)}function $y(n){return!!(n&&typeof n=="object"&&"byteLength"in n&&"byteOffset"in n)}function xe(n){this.content=n}xe.prototype={constructor:xe,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var r=t&&t!=n?this.remove(t):this,i=r.find(n),o=r.content.slice();return i==-1?o.push(t||n,e):(o[i+1]=e,t&&(o[i]=t)),new xe(o)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new xe(t)},addToStart:function(n,e){return new xe([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new xe(t)},addBefore:function(n,e,t){var r=this.remove(e),i=r.content.slice(),o=r.find(n);return i.splice(o==-1?i.length:o,0,e,t),new xe(i)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=xe.from(n),n.size?new xe(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=xe.from(n),n.size?new xe(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=xe.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}};xe.from=function(n){if(n instanceof xe)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new xe(e)};var tl=xe;function kf(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let i=n.child(r),o=e.child(r);if(i==o){t+=i.nodeSize;continue}if(!i.sameMarkup(o))return t;if(i.isText&&i.text!=o.text){let s=i.text,l=o.text,a=0;for(;s[a]==l[a];a++)t++;return a&&a<s.length&&a<l.length&&wf(s.charCodeAt(a-1))&&Sf(s.charCodeAt(a))&&t--,t}if(i.content.size||o.content.size){let s=kf(i.content,o.content,t+1);if(s!=null)return s}t+=i.nodeSize}}function bf(n,e,t,r){for(let i=n.childCount,o=e.childCount;;){if(i==0||o==0)return i==o?null:{a:t,b:r};let s=n.child(--i),l=e.child(--o),a=s.nodeSize;if(s==l){t-=a,r-=a;continue}if(!s.sameMarkup(l))return{a:t,b:r};if(s.isText&&s.text!=l.text){let u=s.text,c=l.text,f=u.length,d=c.length;for(;f>0&&d>0&&u[f-1]==c[d-1];)f--,d--,t--,r--;return f&&d&&f<u.length&&wf(u.charCodeAt(f-1))&&Sf(u.charCodeAt(f))&&(t++,r++),{a:t,b:r}}if(s.content.size||l.content.size){let u=bf(s.content,l.content,t-1,r-1);if(u)return u}t-=a,r-=a}}function Sf(n){return n>=56320&&n<57344}function wf(n){return n>=55296&&n<56320}var M=class n{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,i=0,o){for(let s=0,l=0;l<t;s++){let a=this.content[s],u=l+a.nodeSize;if(u>e&&r(a,i+l,o||null,s)!==!1&&a.content.size){let c=l+1;a.nodesBetween(Math.max(0,e-c),Math.min(a.content.size,t-c),r,i+c)}l=u}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,i){let o="",s=!0;return this.nodesBetween(e,t,(l,a)=>{let u=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&u||l.isTextblock)&&r&&(s?s=!1:o+=r),o+=u},0),o}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,i=this.content.slice(),o=0;for(t.isText&&t.sameMarkup(r)&&(i[i.length-1]=t.withText(t.text+r.text),o=1);o<e.content.length;o++)i.push(e.content[o]);return new n(i,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],i=0;if(t>e)for(let o=0,s=0;s<t;o++){let l=this.content[o],a=s+l.nodeSize;a>e&&((s<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-s),Math.min(l.text.length,t-s)):l=l.cut(Math.max(0,e-s-1),Math.min(l.content.size,t-s-1))),r.push(l),i+=l.nodeSize),s=a}return new n(r,i)}cutByIndex(e,t){return e==t?n.empty:e==0&&t==this.content.length?this:new n(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let i=this.content.slice(),o=this.size+t.nodeSize-r.nodeSize;return i[e]=t,new n(i,o)}addToStart(e){return new n([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new n(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let i=this.content[t];e(i,r,t),r+=i.nodeSize}}findDiffStart(e,t=0){return kf(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return bf(this,e,t,r)}findIndex(e){if(e==0)return no(0,e);if(e==this.size)return no(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,r=0;;t++){let i=this.child(t),o=r+i.nodeSize;if(o>=e)return o==e?no(t+1,o):no(t,r);r=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return n.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return n.fromArray(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return n.empty;let t,r=0;for(let i=0;i<e.length;i++){let o=e[i];r+=o.nodeSize,i&&o.isText&&e[i-1].sameMarkup(o)?(t||(t=e.slice(0,i)),t[t.length-1]=o.withText(t[t.length-1].text+o.text)):t&&t.push(o)}return new n(t||e,r)}static from(e){if(!e)return n.empty;if(e instanceof n)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new n([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}};M.empty=new M([],0);var nl={index:0,offset:0};function no(n,e){return nl.index=n,nl.offset=e,nl}function oo(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!oo(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!oo(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}var W=class n{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let i=0;i<e.length;i++){let o=e[i];if(this.eq(o))return e;if(this.type.excludes(o.type))t||(t=e.slice(0,i));else{if(o.type.excludes(this.type))return e;!r&&o.type.rank>this.type.rank&&(t||(t=e.slice(0,i)),t.push(this),r=!0),t&&t.push(o)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&oo(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);return r.create(t.attrs)}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return n.none;if(e instanceof n)return[e];let t=e.slice();return t.sort((r,i)=>r.type.rank-i.type.rank),t}};W.none=[];var vt=class extends Error{},E=class n{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=Mf(this.content,e+this.openStart,t,this.openStart+1,this.openEnd+1);return r&&new n(r,this.openStart,this.openEnd)}removeBetween(e,t){return new n(Cf(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return n.empty;let r=t.openStart||0,i=t.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new n(M.fromJSON(e,t.content),r,i)}static maxOpen(e,t=!0){let r=0,i=0;for(let o=e.firstChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.firstChild)r++;for(let o=e.lastChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.lastChild)i++;return new n(e,r,i)}};E.empty=new E(M.empty,0,0);function Cf(n,e,t){let{index:r,offset:i}=n.findIndex(e),o=n.maybeChild(r),{index:s,offset:l}=n.findIndex(t);if(i==e||o.isText){if(l!=t&&!n.child(s).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=s)throw new RangeError("Removing non-flat range");return n.replaceChild(r,o.copy(Cf(o.content,e-i-1,t-i-1)))}function Mf(n,e,t,r,i,o){let{index:s,offset:l}=n.findIndex(e),a=n.maybeChild(s);if(l==e||a.isText)return o&&r<=0&&i<=0&&!o.canReplace(s,s,t)?null:n.cut(0,e).append(t).append(n.cut(e));let u=Mf(a.content,e-l-1,t,s==0?r-1:0,s==n.childCount-1?i-1:0,a);return u&&n.replaceChild(s,a.copy(u))}function jy(n,e,t){if(t.openStart>n.depth)throw new vt("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new vt("Inconsistent open depths");return Nf(n,e,t,0)}function Nf(n,e,t,r){let i=n.index(r),o=n.node(r);if(i==e.index(r)&&r<n.depth-t.openStart){let s=Nf(n,e,t,r+1);return o.copy(o.content.replaceChild(i,s))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let s=n.parent,l=s.content;return Yt(s,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:s,end:l}=qy(t,n);return Yt(o,Ef(n,s,l,e,r))}else return Yt(o,so(n,e,r))}function If(n,e){if(!e.type.compatibleContent(n.type))throw new vt("Cannot join "+e.type.name+" onto "+n.type.name)}function rl(n,e,t){let r=n.node(t);return If(r,e.node(t)),r}function Qt(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function zr(n,e,t,r){let i=(e||n).node(t),o=0,s=e?e.index(t):i.childCount;n&&(o=n.index(t),n.depth>t?o++:n.textOffset&&(Qt(n.nodeAfter,r),o++));for(let l=o;l<s;l++)Qt(i.child(l),r);e&&e.depth==t&&e.textOffset&&Qt(e.nodeBefore,r)}function Yt(n,e){if(!n.type.validContent(e))throw new vt("Invalid content for node "+n.type.name);return n.copy(e)}function Ef(n,e,t,r,i){let o=n.depth>i&&rl(n,e,i+1),s=r.depth>i&&rl(t,r,i+1),l=[];return zr(null,n,i,l),o&&s&&e.index(i)==t.index(i)?(If(o,s),Qt(Yt(o,Ef(n,e,t,r,i+1)),l)):(o&&Qt(Yt(o,so(n,e,i+1)),l),zr(e,t,i,l),s&&Qt(Yt(s,so(t,r,i+1)),l)),zr(r,null,i,l),new M(l)}function so(n,e,t){let r=[];if(zr(null,n,t,r),n.depth>t){let i=rl(n,e,t+1);Qt(Yt(i,so(n,e,t+1)),r)}return zr(e,null,t,r),new M(r)}function qy(n,e){let t=e.depth-n.openStart,i=e.node(t).copy(n.content);for(let o=t-1;o>=0;o--)i=e.node(o).copy(M.from(i));return{start:i.resolveNoCache(n.openStart+t),end:i.resolveNoCache(i.content.size-n.openEnd-t)}}var lo=class n{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(t);return r?e.child(t).cut(r):i}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],i=t==0?0:this.path[t*3-1]+1;for(let o=0;o<e;o++)i+=r.child(o).nodeSize;return i}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return W.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),i=e.maybeChild(t);if(!r){let l=r;r=i,i=l}let o=r.marks;for(var s=0;s<o.length;s++)o[s].type.spec.inclusive===!1&&(!i||!o[s].isInSet(i.marks))&&(o=o[s--].removeFromSet(o));return o}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.marks,i=e.parent.maybeChild(e.index());for(var o=0;o<r.length;o++)r[o].type.spec.inclusive===!1&&(!i||!r[o].isInSet(i.marks))&&(r=r[o--].removeFromSet(r));return r}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new _r(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],i=0,o=t;for(let s=e;;){let{index:l,offset:a}=s.content.findIndex(o),u=o-a;if(r.push(s,l,i+a),!u||(s=s.child(l),s.isText))break;o=u-1,i+=a+1}return new n(t,r,o)}static resolveCached(e,t){let r=uf.get(e);if(r)for(let o=0;o<r.elts.length;o++){let s=r.elts[o];if(s.pos==t)return s}else uf.set(e,r=new il);let i=r.elts[r.i]=n.resolve(e,t);return r.i=(r.i+1)%Wy,i}},il=class{constructor(){this.elts=[],this.i=0}},Wy=12,uf=new WeakMap,_r=class{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},Hy=Object.create(null),Ae=class n{constructor(e,t,r,i=W.none){this.type=e,this.attrs=t,this.marks=i,this.content=r||M.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,r,i=0){this.content.nodesBetween(e,t,r,i,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,r,i){return this.content.textBetween(e,t,r,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,r){return this.type==e&&oo(this.attrs,t||e.defaultAttrs||Hy)&&W.sameSet(this.marks,r||W.none)}copy(e=null){return e==this.content?this:new n(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new n(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,r=!1){if(e==t)return E.empty;let i=this.resolve(e),o=this.resolve(t),s=r?0:i.sharedDepth(t),l=i.start(s),u=i.node(s).content.cut(i.pos-l,o.pos-l);return new E(u,i.depth-s,o.depth-s)}replace(e,t,r){return jy(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:i}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(i==e||t.isText)return t;e-=i+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let i=this.content.child(t-1);return{node:i,index:t-1,offset:r-i.nodeSize}}resolve(e){return lo.resolveCached(this,e)}resolveNoCache(e){return lo.resolve(this,e)}rangeHasMark(e,t,r){let i=!1;return t>e&&this.nodesBetween(e,t,o=>(r.isInSet(o.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Of(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=M.empty,i=0,o=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,i,o),l=s&&s.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=i;a<o;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,t,r,i){if(i&&!this.type.allowsMarks(i))return!1;let o=this.contentMatchAt(e).matchType(r),s=o&&o.matchFragment(this.content,t);return s?s.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),cf(this.type.attrs,this.attrs,"node",this.type.name);let e=W.none;for(let t=0;t<this.marks.length;t++){let r=this.marks[t];cf(r.type.attrs,r.attrs,"mark",r.type.name),e=r.addToSet(e)}if(!W.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let i=M.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,i,r)}};Ae.prototype.text=void 0;var ol=class n extends Ae{constructor(e,t,r,i){if(super(e,t,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Of(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new n(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new n(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function Of(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}function cf(n,e,t,r){for(let i in e)if(!(i in n))throw new RangeError(`Unsupported attribute ${i} for ${t} of type ${r}`);for(let i in n)n[i].validate&&n[i].validate(e[i])}var Xt=class n{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new sl(e,t);if(r.next==null)return n.empty;let i=Tf(r);r.next&&r.err("Unexpected trailing text");let o=Xy(Yy(i));return Zy(o,r),o}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,r=e.childCount){let i=this;for(let o=t;i&&o<r;o++)i=i.matchType(e.child(o).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let i=[this];function o(s,l){let a=s.matchFragment(e,r);if(a&&(!t||a.validEnd))return M.from(l.map(u=>u.createAndFill()));for(let u=0;u<s.next.length;u++){let{type:c,next:f}=s.next[u];if(!(c.isText||c.hasRequiredAttrs())&&i.indexOf(f)==-1){i.push(f);let d=o(f,l.concat(c));if(d)return d}}return null}return o(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),o=i.match;if(o.matchType(e)){let s=[];for(let l=i;l.type;l=l.via)s.push(l.type);return s.reverse()}for(let s=0;s<o.next.length;s++){let{type:l,next:a}=o.next[s];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!i.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:i}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&t(r.next[i].next)}return t(this),e.map((r,i)=>{let o=i+(r.validEnd?"*":" ")+" ";for(let s=0;s<r.next.length;s++)o+=(s?", ":"")+r.next[s].type.name+"->"+e.indexOf(r.next[s].next);return o}).join(`
|
|
38
|
+
`)}};Xt.empty=new Xt(!0);var sl=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 Tf(n){let e=[];do e.push(Ky(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Ky(n){let e=[];do e.push(Uy(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Uy(n){let e=Qy(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=Jy(n,e);else break;return e}function ff(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function Jy(n,e){let t=ff(n),r=t;return n.eat(",")&&(n.next!="}"?r=ff(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function Gy(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let i=[];for(let o in t){let s=t[o];s.isInGroup(e)&&i.push(s)}return i.length==0&&n.err("No node type or group '"+e+"' found"),i}function Qy(n){if(n.eat("(")){let e=Tf(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=Gy(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function Yy(n){let e=[[]];return i(o(n,0),t()),e;function t(){return e.push([])-1}function r(s,l,a){let u={term:a,to:l};return e[s].push(u),u}function i(s,l){s.forEach(a=>a.to=l)}function o(s,l){if(s.type=="choice")return s.exprs.reduce((a,u)=>a.concat(o(u,l)),[]);if(s.type=="seq")for(let a=0;;a++){let u=o(s.exprs[a],l);if(a==s.exprs.length-1)return u;i(u,l=t())}else if(s.type=="star"){let a=t();return r(l,a),i(o(s.expr,a),a),[r(a)]}else if(s.type=="plus"){let a=t();return i(o(s.expr,l),a),i(o(s.expr,a),a),[r(a)]}else{if(s.type=="opt")return[r(l)].concat(o(s.expr,l));if(s.type=="range"){let a=l;for(let u=0;u<s.min;u++){let c=t();i(o(s.expr,a),c),a=c}if(s.max==-1)i(o(s.expr,a),a);else for(let u=s.min;u<s.max;u++){let c=t();r(a,c),i(o(s.expr,a),c),a=c}return[r(a)]}else{if(s.type=="name")return[r(l,void 0,s.value)];throw new Error("Unknown expr type")}}}}function Af(n,e){return e-n}function hf(n,e){let t=[];return r(e),t.sort(Af);function r(i){let o=n[i];if(o.length==1&&!o[0].term)return r(o[0].to);t.push(i);for(let s=0;s<o.length;s++){let{term:l,to:a}=o[s];!l&&t.indexOf(a)==-1&&r(a)}}}function Xy(n){let e=Object.create(null);return t(hf(n,0));function t(r){let i=[];r.forEach(s=>{n[s].forEach(({term:l,to:a})=>{if(!l)return;let u;for(let c=0;c<i.length;c++)i[c][0]==l&&(u=i[c][1]);hf(n,a).forEach(c=>{u||i.push([l,u=[]]),u.indexOf(c)==-1&&u.push(c)})})});let o=e[r.join(",")]=new Xt(r.indexOf(n.length-1)>-1);for(let s=0;s<i.length;s++){let l=i[s][1].sort(Af);o.next.push({type:i[s][0],next:e[l.join(",")]||t(l)})}return o}}function Zy(n,e){for(let t=0,r=[n];t<r.length;t++){let i=r[t],o=!i.validEnd,s=[];for(let l=0;l<i.next.length;l++){let{type:a,next:u}=i.next[l];s.push(a.name),o&&!(a.isText||a.hasRequiredAttrs())&&(o=!1),r.indexOf(u)==-1&&r.push(u)}o&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function vf(n){let e=Object.create(null);for(let t in n){let r=n[t];if(!r.hasDefault)return null;e[t]=r.default}return e}function Df(n,e){let t=Object.create(null);for(let r in n){let i=n[r],o=e&&e[r];if(o===void 0)if(i.hasDefault)o=i.default;else throw new RangeError("No value supplied for attribute "+r);else i.validate&&i.validate(o);t[r]=o}return t}function Rf(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new ll(n,r,e[r]);return t}var Vr=class n{constructor(e,t,r){this.name=e,this.schema=t,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=Rf(e,r.attrs),this.defaultAttrs=vf(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Xt.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:Df(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Ae(this,this.computeAttrs(e),M.from(t),W.setFrom(r))}createChecked(e=null,t,r){return t=M.from(t),this.checkContent(t),new Ae(this,this.computeAttrs(e),t,W.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=M.from(t),t.size){let s=this.contentMatch.fillBefore(t);if(!s)return null;t=s.append(t)}let i=this.contentMatch.matchFragment(t),o=i&&i.fillBefore(M.empty,!0);return o?new Ae(this,e,t.append(o),W.setFrom(r)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?t&&t.push(e[r]):t||(t=e.slice(0,r));return t?t.length?t:W.none:e}static compile(e,t){let r=Object.create(null);e.forEach((o,s)=>r[o]=new n(o,t,s));let i=t.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let o in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function ex(n,e,t){let r=t.split("|");return i=>{let o=i===null?"null":typeof i;if(r.indexOf(o)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${o}`)}}var ll=class{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?ex(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}},$r=class n{constructor(e,t,r,i){this.name=e,this.rank=t,this.schema=r,this.spec=i,this.attrs=Rf(e,i.attrs),this.excluded=null;let o=vf(this.attrs);this.instance=o?new W(this,o):null}create(e=null){return!e&&this.instance?this.instance:new W(this,Df(this.attrs,e))}static compile(e,t){let r=Object.create(null),i=0;return e.forEach((o,s)=>r[o]=new n(o,i++,t,s)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}excludes(e){return this.excluded.indexOf(e)>-1}},ao=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=tl.from(e.nodes),t.marks=tl.from(e.marks||{}),this.nodes=Vr.compile(this.spec.nodes,this),this.marks=$r.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let o=this.nodes[i],s=o.spec.content||"",l=o.spec.marks;if(o.contentMatch=r[s]||(r[s]=Xt.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=l=="_"?null:l?df(this,l.split(" ")):l==""||!o.inlineContent?[]:null}for(let i in this.marks){let o=this.marks[i],s=o.spec.excludes;o.excluded=s==null?[o]:s==""?[]:df(this,s.split(" "))}this.nodeFromJSON=i=>Ae.fromJSON(this,i),this.markFromJSON=i=>W.fromJSON(this,i),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Vr){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,r,i)}text(e,t){let r=this.nodes.text;return new ol(r,r.defaultAttrs,e,W.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 df(n,e){let t=[];for(let r=0;r<e.length;r++){let i=e[r],o=n.marks[i],s=o;if(o)t.push(o);else for(let l in n.marks){let a=n.marks[l];(i=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(i)>-1)&&t.push(s=a)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function tx(n){return n.tag!=null}function nx(n){return n.style!=null}var Dt=class n{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(i=>{if(tx(i))this.tags.push(i);else if(nx(i)){let o=/[^=]*/.exec(i.style)[0];r.indexOf(o)<0&&r.push(o),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let o=e.nodes[i.node];return o.contentMatch.matchType(o)})}parse(e,t={}){let r=new uo(this,t,!1);return r.addAll(e,W.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new uo(this,t,!0);return r.addAll(e,W.none,t.from,t.to),E.maxOpen(r.finish())}matchTag(e,t,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let o=this.tags[i];if(ox(e,o.tag)&&(o.namespace===void 0||e.namespaceURI==o.namespace)&&(!o.context||t.matchesContext(o.context))){if(o.getAttrs){let s=o.getAttrs(e);if(s===!1)continue;o.attrs=s||void 0}return o}}}matchStyle(e,t,r,i){for(let o=i?this.styles.indexOf(i)+1:0;o<this.styles.length;o++){let s=this.styles[o],l=s.style;if(!(l.indexOf(e)!=0||s.context&&!r.matchesContext(s.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(s.getAttrs){let a=s.getAttrs(t);if(a===!1)continue;s.attrs=a||void 0}return s}}}static schemaRules(e){let t=[];function r(i){let o=i.priority==null?50:i.priority,s=0;for(;s<t.length;s++){let l=t[s];if((l.priority==null?50:l.priority)<o)break}t.splice(s,0,i)}for(let i in e.marks){let o=e.marks[i].spec.parseDOM;o&&o.forEach(s=>{r(s=mf(s)),s.mark||s.ignore||s.clearMark||(s.mark=i)})}for(let i in e.nodes){let o=e.nodes[i].spec.parseDOM;o&&o.forEach(s=>{r(s=mf(s)),s.node||s.ignore||s.mark||(s.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new n(e,n.schemaRules(e)))}},Pf={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},rx={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Bf={ol:!0,ul:!0},jr=1,al=2,Fr=4;function pf(n,e,t){return e!=null?(e?jr:0)|(e==="full"?al:0):n&&n.whitespace=="pre"?jr|al:t&~Fr}var _n=class{constructor(e,t,r,i,o,s){this.type=e,this.attrs=t,this.marks=r,this.solid=i,this.options=s,this.content=[],this.activeMarks=W.none,this.match=o||(s&Fr?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(M.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&jr)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let o=r;r.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=M.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(M.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&&!Pf.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},uo=class{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=t.topNode,o,s=pf(null,t.preserveWhitespace,0)|(r?Fr:0);i?o=new _n(i.type,i.attrs,W.none,!0,t.topMatch||i.type.contentMatch,s):r?o=new _n(null,null,W.none,!0,null,s):o=new _n(e.schema.topNodeType,null,W.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 r=e.nodeValue,i=this.top,o=i.options&al?"full":this.localPreserveWS||(i.options&jr)>0,{schema:s}=this.parser;if(o==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(o)if(o==="full")r=r.replace(/\r\n?/g,`
|
|
39
|
+
`);else if(s.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(s.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let a=0;a<l.length;a++)a&&this.insertNode(s.linebreakReplacement.create(),t,!0),l[a]&&this.insertNode(s.text(l[a]),t,!/\S/.test(l[a]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let l=i.content[i.content.length-1],a=e.previousSibling;(!l||a&&a.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(r=r.slice(1))}r&&this.insertNode(s.text(r),t,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,t,r){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(),l;Bf.hasOwnProperty(s)&&this.parser.normalizeLists&&ix(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:rx.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,t);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let u,c=this.needsBlock;if(Pf.hasOwnProperty(s))o.content.length&&o.content[0].isInline&&this.open&&(this.open--,o=this.top),u=!0,o.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let f=a&&a.skip?t:this.readStyles(e,t);f&&this.addAll(e,f),u&&this.sync(o),this.needsBlock=c}else{let u=this.readStyles(e,t);u&&this.addElementByRule(e,a,u,a.consuming===!1?l:void 0)}this.localPreserveWS=i}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
40
|
+
`),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 r=e.style;if(r&&r.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let o=this.parser.matchedStyles[i],s=r.getPropertyValue(o);if(s)for(let l=void 0;;){let a=this.parser.matchStyle(o,s,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?t=t.filter(u=>!a.clearMark(u)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,r,i){let o,s;if(t.node)if(s=this.parser.schema.nodes[t.node],s.isLeaf)this.insertNode(s.create(t.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(s,t.attrs||null,r,t.preserveWhitespace);a&&(o=!0,r=a)}else{let a=this.parser.schema.marks[t.mark];r=r.concat(a.create(t.attrs))}let l=this.top;if(s&&s.isLeaf)this.findInside(e);else if(i)this.addElement(e,r,i);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}o&&this.sync(l)&&this.open--}addAll(e,t,r,i){let o=r||0;for(let s=r?e.childNodes[r]:e.firstChild,l=i==null?null:e.childNodes[i];s!=l;s=s.nextSibling,++o)this.findAtPoint(e,o),this.addDOM(s,t);this.findAtPoint(e,o)}findPlace(e,t,r){let i,o;for(let s=this.open,l=0;s>=0;s--){let a=this.nodes[s],u=a.findWrapping(e);if(u&&(!i||i.length>u.length+l)&&(i=u,o=a,!u.length))break;if(a.solid){if(r)break;l+=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,r){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,r);if(i){this.closeExtra();let o=this.top;o.match&&(o.match=o.match.matchType(e.type));let s=W.none;for(let l of i.concat(e.marks))(o.type?o.type.allowsMarkType(l.type):gf(l.type,e.type))&&(s=l.addToSet(s));return o.content.push(e.mark(s)),!0}return!1}enter(e,t,r,i){let o=this.findPlace(e.create(t),r,!1);return o&&(o=this.enterInner(e,t,r,!0,i)),o}enterInner(e,t,r,i=!1,o){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(e);let l=pf(e,o,s.options);s.options&Fr&&s.content.length==0&&(l|=Fr);let a=W.none;return r=r.filter(u=>(s.type?s.type.allowsMarkType(u.type):gf(u.type,e))?(a=u.addToSet(a),!1):!0),this.nodes.push(new _n(e,t,a,i,null,l)),this.open++,r}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|=jr)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==t&&(this.find[r].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,r){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)&(r?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("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),o=-(r?r.depth+1:0)+(i?0:1),s=(l,a)=>{for(;l>=0;l--){let u=t[l];if(u==""){if(l==t.length-1||l==0)continue;for(;a>=o;a--)if(s(l-1,a))return!0;return!1}else{let c=a>0||a==0&&i?this.nodes[a].type:r&&a>=o?r.node(a-o).type:null;if(!c||c.name!=u&&!c.isInGroup(u))return!1;a--}}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 r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}};function ix(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Bf.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function ox(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function mf(n){let e={};for(let t in n)e[t]=n[t];return e}function gf(n,e){let t=e.schema.nodes;for(let r in t){let i=t[r];if(!i.allowsMarkType(n))continue;let o=[],s=l=>{o.push(l);for(let a=0;a<l.edgeCount;a++){let{type:u,next:c}=l.edge(a);if(u==e||o.indexOf(c)<0&&s(c))return!0}};if(s(i.contentMatch))return!0}}var Rt=class n{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=ro(t).createDocumentFragment());let i=r,o=[];return e.forEach(s=>{if(o.length||s.marks.length){let l=0,a=0;for(;l<o.length&&a<s.marks.length;){let u=s.marks[a];if(!this.marks[u.type.name]){a++;continue}if(!u.eq(o[l][0])||u.type.spec.spanning===!1)break;l++,a++}for(;l<o.length;)i=o.pop()[1];for(;a<s.marks.length;){let u=s.marks[a++],c=this.serializeMark(u,s.isInline,t);c&&(o.push([u,i]),i.appendChild(c.dom),i=c.contentDOM||c.dom)}}i.appendChild(this.serializeNodeInner(s,t))}),r}serializeNodeInner(e,t){if(e.isText)return ro(t).createTextNode(e.text);let{dom:r,contentDOM:i}=io(ro(t),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,i)}return r}serializeNode(e,t={}){let r=this.serializeNodeInner(e,t);for(let i=e.marks.length-1;i>=0;i--){let o=this.serializeMark(e.marks[i],e.isInline,t);o&&((o.contentDOM||o.dom).appendChild(r),r=o.dom)}return r}serializeMark(e,t,r={}){let i=this.marks[e.type.name];return i&&io(ro(r),i(e,t),null,e.attrs)}static renderSpec(e,t,r=null,i){return typeof t=="string"?{dom:e.createTextNode(t)}:io(e,t,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new n(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=yf(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return yf(e.marks)}};function yf(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function ro(n){return n.document||window.document}var xf=new WeakMap;function sx(n){let e=xf.get(n);return e===void 0&&xf.set(n,e=lx(n)),e}function lx(n){let e=null;function t(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let i=0;i<r.length;i++)t(r[i]);else for(let i in r)t(r[i])}return t(n),e}function io(n,e,t,r){if(e.nodeType==1)return{dom:e};if(e.dom&&e.dom.nodeType==1)return e;let i=e[0],o;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(o=sx(r))&&o.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let s=i.indexOf(" ");s>0&&(t=i.slice(0,s),i=i.slice(s+1));let l,a=t?n.createElementNS(t,i):n.createElement(i),u=e[1],c=1;if(u&&typeof u=="object"&&u.nodeType==null&&!Array.isArray(u)){c=2;for(let f in u)if(u[f]!=null){let d=f.indexOf(" ");d>0?a.setAttributeNS(f.slice(0,d),f.slice(d+1),u[f]):f=="style"&&a.style?a.style.cssText=u[f]:a.setAttribute(f,u[f])}}for(let f=c;f<e.length;f++){let d=e[f];if(d===0){if(f<e.length-1||f>c)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else if(typeof d=="string")a.appendChild(n.createTextNode(d));else{let{dom:h,contentDOM:p}=io(n,d,t,r);if(a.appendChild(h),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}var Vf=65535,$f=Math.pow(2,16);function ax(n,e){return n+e*$f}function Lf(n){return n&Vf}function ux(n){return(n-(n&Vf))/$f}var jf=1,qf=2,co=4,Wf=8,Hr=class{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&Wf)>0}get deletedBefore(){return(this.delInfo&(jf|co))>0}get deletedAfter(){return(this.delInfo&(qf|co))>0}get deletedAcross(){return(this.delInfo&co)>0}},mt=class n{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&n.empty)return n.empty}recover(e){let t=0,r=Lf(e);if(!this.inverted)for(let i=0;i<r;i++)t+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[r*3]+t+ux(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let i=0,o=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?i:0);if(a>e)break;let u=this.ranges[l+o],c=this.ranges[l+s],f=a+u;if(e<=f){let d=u?e==a?-1:e==f?1:t:t,h=a+i+(d<0?0:c);if(r)return h;let p=e==(t<0?a:f)?null:ax(l/3,e-a),m=0;return u&&(m|=e==a?qf:e==f?jf:co,(t<0?e!=a:e!=f)&&(m|=Wf)),new Hr(h,m,p)}i+=c-u}return r?e+i:new Hr(e+i,0,null)}touches(e,t){let r=0,i=Lf(t),o=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let u=this.ranges[l+o],c=a+u;if(e<=c&&l==i*3)return!0;r+=this.ranges[l+s]-u}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,o=0;i<this.ranges.length;i+=3){let s=this.ranges[i],l=s-(this.inverted?o:0),a=s+(this.inverted?0:o),u=this.ranges[i+t],c=this.ranges[i+r];e(l,l+u,a,a+c),o+=c-u}}invert(){return new n(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?n.empty:new n(e<0?[0,-e,0]:[0,0,e])}};mt.empty=new mt([]);var Kr=class n{constructor(e,t,r=0,i=e?e.length:0){this.mirror=t,this.from=r,this.to=i,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new n(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,r=this._maps.length;t<e._maps.length;t++){let i=e.getMirror(t);this.appendMap(e._maps[t],i!=null&&i<t?r+i:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,r=this._maps.length+e._maps.length;t>=0;t--){let i=e.getMirror(t);this.appendMap(e._maps[t].invert(),i!=null&&i>t?r-i-1:void 0)}}invert(){let e=new n;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,r){let i=0;for(let o=this.from;o<this.to;o++){let s=this._maps[o],l=s.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(o);if(a!=null&&a>o&&a<this.to){o=a,e=this._maps[a].recover(l.recover);continue}}i|=l.delInfo,e=l.pos}return r?e:new Hr(e,i,null)}},ul=Object.create(null),te=class{getMap(){return mt.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=ul[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in ul)throw new RangeError("Duplicate use of step JSON ID "+e);return ul[e]=t,t.prototype.jsonID=e,t}},le=class n{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new n(e,null)}static fail(e){return new n(null,e)}static fromReplace(e,t,r,i){try{return n.ok(e.replace(t,r,i))}catch(o){if(o instanceof vt)return n.fail(o.message);throw o}}};function dl(n,e,t){let r=[];for(let i=0;i<n.childCount;i++){let o=n.child(i);o.content.size&&(o=o.copy(dl(o.content,e,o))),o.isInline&&(o=e(o,t,i)),r.push(o)}return M.fromArray(r)}var Zt=class n extends te{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),i=r.node(r.sharedDepth(this.to)),o=new E(dl(t.content,(s,l)=>!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),i),t.openStart,t.openEnd);return le.fromReplace(e,this.from,this.to,o)}invert(e){let t=[];return e.nodesBetween(this.from,this.to,(r,i)=>{if(r.isInline&&r.isAtom){let o=this.mark.addToSet(r.marks);if(!W.sameSet(o,r.marks)){let s=Math.max(this.from,i),l=Math.min(this.to,i+r.nodeSize);fo(Vn,s,l,this.mark,t);for(let a of r.marks)a.isInSet(o)||fo(n,s,l,a,t)}}}),t.length==1?t[0]:new Ur(t)}map(e){let t=e.map(this.from,1),r=e.map(this.to,-1);return t>=r?null:new n(t,r,this.mark)}merge(e){return e instanceof n&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new n(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new n(t.from,t.to,e.markFromJSON(t.mark))}};te.jsonID("addMark",Zt);var Vn=class n extends te{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new E(dl(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return le.fromReplace(e,this.from,this.to,r)}invert(e){let t=[];return e.nodesBetween(this.from,this.to,(r,i)=>{r.isInline&&r.isAtom&&this.mark.isInSet(r.marks)&&fo(Zt,Math.max(this.from,i),Math.min(this.to,i+r.nodeSize),this.mark,t)}),t.length==1?t[0]:new Ur(t)}map(e){let t=e.map(this.from,1),r=e.map(this.to,-1);return t>=r?null:new n(t,r,this.mark)}merge(e){return e instanceof n&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new n(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new n(t.from,t.to,e.markFromJSON(t.mark))}};te.jsonID("removeMark",Vn);function fo(n,e,t,r,i){let o=i.length?i[i.length-1]:null;o&&o instanceof n&&o.to==e&&o.mark.eq(r)?i[i.length-1]=new n(o.from,t,r):i.push(new n(e,t,r))}var Ur=class n extends te{constructor(e){super(),this.steps=e}apply(e){for(let t of this.steps){let r=t.apply(e);if(!r.doc)return r;e=r.doc}return new le(e,null)}invert(e){return new n(this.steps.map(t=>t.invert(e)))}map(e){let t=[];for(let r of this.steps){let i=r.map(e);i&&t.push(i)}return t.length?new n(t):null}toJSON(){return{stepType:"markSet",steps:this.steps.map(e=>e.toJSON())}}static fromJSON(e,t){if(!Array.isArray(t.steps)||!t.steps.every(r=>r.stepType=="addMark"||r.stepType=="removeMark"))throw new RangeError("Invalid JSON for MarkSetStep");return new n(t.steps.map(r=>te.fromJSON(e,r)))}};te.jsonID("markSet",Ur);var Jr=class n extends te{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return le.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return le.fromReplace(e,this.pos,this.pos+1,new E(M.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let i=0;i<t.marks.length;i++)if(!t.marks[i].isInSet(r))return new n(this.pos,t.marks[i]);return new n(this.pos,this.mark)}}return new $n(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new n(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new n(t.pos,e.markFromJSON(t.mark))}};te.jsonID("addNodeMark",Jr);var $n=class n extends te{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return le.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return le.fromReplace(e,this.pos,this.pos+1,new E(M.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Jr(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new n(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new n(t.pos,e.markFromJSON(t.mark))}};te.jsonID("removeNodeMark",$n);var fe=class n extends te{constructor(e,t,r,i=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=i}apply(e){return this.structure&&fl(e,this.from,this.to)?le.fail("Structure replace would overwrite content"):le.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new mt([this.from,this.to-this.from,this.slice.size])}invert(e){return new n(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.to,-1),r=this.from==this.to&&n.MAP_BIAS<0?t:e.mapResult(this.from,1);return r.deletedAcross&&t.deletedAcross?null:new n(r.pos,Math.max(r.pos,t.pos),this.slice,this.structure)}merge(e){if(!(e instanceof n)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?E.empty:new E(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new n(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?E.empty:new E(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new n(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new n(t.from,t.to,E.fromJSON(e,t.slice),!!t.structure)}};fe.MAP_BIAS=1;te.jsonID("replace",fe);var he=class n extends te{constructor(e,t,r,i,o,s,l=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=i,this.slice=o,this.insert=s,this.structure=l}apply(e){if(this.structure&&(fl(e,this.from,this.gapFrom)||fl(e,this.gapTo,this.to)))return le.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return le.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?le.fromReplace(e,this.from,this.to,r):le.fail("Content does not fit in gap")}getMap(){return new mt([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new n(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),i=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),o=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||i<t.pos||o>r.pos?null:new n(t.pos,r.pos,i,o,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new n(t.from,t.to,t.gapFrom,t.gapTo,E.fromJSON(e,t.slice),t.insert,!!t.structure)}};te.jsonID("replaceAround",he);function fl(n,e,t){let r=n.resolve(e),i=t-e,o=r.depth;for(;i>0&&o>0&&r.indexAfter(o)==r.node(o).childCount;)o--,i--;if(i>0){let s=r.node(o).maybeChild(r.indexAfter(o));for(;i>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,i--}}return!1}function cx(n,e,t,r){let i=[];n.doc.nodesBetween(e,t,(o,s,l)=>{if(!o.isInline)return;let a=o.marks;if(!r.isInSet(a)&&l.type.allowsMarkType(r.type)){let u=Math.max(s,e),c=Math.min(s+o.nodeSize,t);fo(Zt,u,c,r,i)}}),i.forEach(o=>n.step(o))}function fx(n,e,t,r){let i=[],o=0;n.doc.nodesBetween(e,t,(s,l)=>{if(!s.isInline||!s.isAtom)return;o++;let a=null;if(r instanceof $r){let u=s.marks,c;for(;c=r.isInSet(u);)(a||(a=[])).push(c),u=c.removeFromSet(u)}else r?r.isInSet(s.marks)&&(a=[r]):a=s.marks;if(a&&a.length){let u=Math.min(l+s.nodeSize,t);for(let c=0;c<a.length;c++){let f=a[c],d;for(let h=0;h<i.length;h++){let p=i[h];p.step==o-1&&f.eq(i[h].style)&&(d=p)}d?(d.to=u,d.step=o):i.push({style:f,from:Math.max(l,e),to:u,step:o})}}}),i.forEach(s=>n.step(new Vn(s.from,s.to,s.style)))}function pl(n,e,t,r=t.contentMatch,i=!0){let o=n.doc.nodeAt(e),s=[],l=e+1;for(let a=0;a<o.childCount;a++){let u=o.child(a),c=l+u.nodeSize,f=r.matchType(u.type);if(!f)s.push(new fe(l,c,E.empty));else{r=f;for(let d=0;d<u.marks.length;d++)t.allowsMarkType(u.marks[d].type)||n.step(new Vn(l,c,u.marks[d]));if(i&&u.isText&&t.whitespace!="pre"){let d,h=/\r?\n|\r/g,p;for(;d=h.exec(u.text);)p||(p=new E(M.from(t.schema.text(" ",t.allowedMarks(u.marks))),0,0)),s.push(new fe(l+d.index,l+d.index+d[0].length,p))}}l=c}if(!r.validEnd){let a=r.fillBefore(M.empty,!0);n.replace(l,l,new E(a,0,0))}for(let a=s.length-1;a>=0;a--)n.step(s[a])}function hx(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function qn(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth,i=0,o=0;;--r){let s=n.$from.node(r),l=n.$from.index(r)+i,a=n.$to.indexAfter(r)-o;if(r<n.depth&&s.canReplace(l,a,t))return r;if(r==0||s.type.spec.isolating||!hx(s,l,a))break;l&&(i=1),a<s.childCount&&(o=1)}return null}function dx(n,e,t){let{$from:r,$to:i,depth:o}=e,s=r.before(o+1),l=i.after(o+1),a=s,u=l,c=M.empty,f=0;for(let p=o,m=!1;p>t;p--)m||r.index(p)>0?(m=!0,c=M.from(r.node(p).copy(c)),f++):a--;let d=M.empty,h=0;for(let p=o,m=!1;p>t;p--)m||i.after(p+1)<i.end(p)?(m=!0,d=M.from(i.node(p).copy(d)),h++):u++;n.step(new he(a,u,s,l,new E(c.append(d),f,h),c.size-f,!0))}function en(n,e,t=null,r=n){let i=px(n,e),o=i&&mx(r,e);return o?i.map(zf).concat({type:e,attrs:t}).concat(o.map(zf)):null}function zf(n){return{type:n,attrs:null}}function px(n,e){let{parent:t,startIndex:r,endIndex:i}=n,o=t.contentMatchAt(r).findWrapping(e);if(!o)return null;let s=o.length?o[0]:e;return t.canReplaceWith(r,i,s)?o:null}function mx(n,e){let{parent:t,startIndex:r,endIndex:i}=n,o=t.child(r),s=e.contentMatch.findWrapping(o.type);if(!s)return null;let a=(s.length?s[s.length-1]:e).contentMatch;for(let u=r;a&&u<i;u++)a=a.matchType(t.child(u).type);return!a||!a.validEnd?null:s}function gx(n,e,t){let r=M.empty;for(let s=t.length-1;s>=0;s--){if(r.size){let l=t[s].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=M.from(t[s].type.create(t[s].attrs,r))}let i=e.start,o=e.end;n.step(new he(i,o,i,o,new E(r,0,0),t.length,!0))}function yx(n,e,t,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=n.steps.length;n.doc.nodesBetween(e,t,(s,l)=>{let a=typeof i=="function"?i(s):i;if(s.isTextblock&&!s.hasMarkup(r,a)&&xx(n.doc,n.mapping.slice(o).map(l),r)){let u=null;if(r.schema.linebreakReplacement){let h=r.whitespace=="pre",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);h&&!p?u=!1:!h&&p&&(u=!0)}u===!1&&Kf(n,s,l,o),pl(n,n.mapping.slice(o).map(l,1),r,void 0,u===null);let c=n.mapping.slice(o),f=c.map(l,1),d=c.map(l+s.nodeSize,1);return n.step(new he(f,d,f+1,d-1,new E(M.from(r.create(a,null,s.marks)),0,0),1,!0)),u===!0&&Hf(n,s,l,o),!1}})}function Hf(n,e,t,r){e.forEach((i,o)=>{if(i.isText){let s,l=/\r?\n|\r/g;for(;s=l.exec(i.text);){let a=n.mapping.slice(r).map(t+1+o+s.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Kf(n,e,t,r){e.forEach((i,o)=>{if(i.type==i.type.schema.linebreakReplacement){let s=n.mapping.slice(r).map(t+1+o);n.replaceWith(s,s+1,e.type.schema.text(`
|
|
41
|
+
`))}})}function xx(n,e,t){let r=n.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,t)}function kx(n,e,t,r,i){let o=n.doc.nodeAt(e);if(!o)throw new RangeError("No node at given position");t||(t=o.type);let s=t.create(r,null,i||o.marks);if(o.isLeaf)return n.replaceWith(e,e+o.nodeSize,s);if(!t.validContent(o.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new he(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new E(M.from(s),0,0),1,!0))}function tn(n,e,t=1,r){let i=n.resolve(e),o=i.depth-t,s=r&&r[r.length-1]||i.parent;if(o<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!s.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let u=i.depth-1,c=t-2;u>o;u--,c--){let f=i.node(u),d=i.index(u);if(f.type.spec.isolating)return!1;let h=f.content.cutByIndex(d,f.childCount),p=r&&r[c+1];p&&(h=h.replaceChild(0,p.type.create(p.attrs)));let m=r&&r[c]||f;if(!f.canReplace(d+1,f.childCount)||!m.type.validContent(h))return!1}let l=i.indexAfter(o),a=r&&r[0];return i.node(o).canReplaceWith(l,l,a?a.type:i.node(o+1).type)}function bx(n,e,t=1,r){let i=n.doc.resolve(e),o=M.empty,s=M.empty;for(let l=i.depth,a=i.depth-t,u=t-1;l>a;l--,u--){o=M.from(i.node(l).copy(o));let c=r&&r[u];s=M.from(c?c.type.create(c.attrs,s):i.node(l).copy(s))}n.step(new fe(e,e,new E(o.append(s),t,t),!0))}function nn(n,e){let t=n.resolve(e),r=t.index();return wx(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function Sx(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:r}=n.type.schema;for(let i=0;i<e.childCount;i++){let o=e.child(i),s=o.type==r?n.type.schema.nodes.text:o.type;if(t=t.matchType(s),!t||!n.type.allowsMarks(o.marks))return!1}return t.validEnd}function wx(n,e){return!!(n&&e&&!n.isLeaf&&Sx(n,e))}function Cx(n,e,t){let r=null,{linebreakReplacement:i}=n.doc.type.schema,o=n.doc.resolve(e-t),s=o.node().type;if(i&&s.inlineContent){let c=s.whitespace=="pre",f=!!s.contentMatch.matchType(i);c&&!f?r=!1:!c&&f&&(r=!0)}let l=n.steps.length;if(r===!1){let c=n.doc.resolve(e+t);Kf(n,c.node(),c.before(),l)}s.inlineContent&&pl(n,e+t-1,s,o.node().contentMatchAt(o.index()),r==null);let a=n.mapping.slice(l),u=a.map(e-t);if(n.step(new fe(u,a.map(e+t,-1),E.empty,!0)),r===!0){let c=n.doc.resolve(u);Hf(n,c.node(),c.before(),n.steps.length)}return n}function Mx(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let o=r.index(i);if(r.node(i).canReplaceWith(o,o,t))return r.before(i+1);if(o>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let o=r.indexAfter(i);if(r.node(i).canReplaceWith(o,o,t))return r.after(i+1);if(o<r.node(i).childCount)return null}return null}function Uf(n,e,t){let r=n.resolve(e);if(!t.content.size)return e;let i=t.content;for(let o=0;o<t.openStart;o++)i=i.firstChild.content;for(let o=1;o<=(t.openStart==0&&t.size?2:1);o++)for(let s=r.depth;s>=0;s--){let l=s==r.depth?0:r.pos<=(r.start(s+1)+r.end(s+1))/2?-1:1,a=r.index(s)+(l>0?1:0),u=r.node(s),c=!1;if(o==1)c=u.canReplace(a,a,i);else{let f=u.contentMatchAt(a).findWrapping(i.firstChild.type);c=f&&u.canReplaceWith(a,a,f[0])}if(c)return l==0?r.pos:l<0?r.before(s+1):r.after(s+1)}return null}function Gr(n,e,t=e,r=E.empty){if(e==t&&!r.size)return null;let i=n.resolve(e),o=n.resolve(t);return Jf(i,o,r)?new fe(e,t,r):new hl(i,o,r).fit()}function Jf(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}var hl=class{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=M.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=M.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let u=this.findFittable();u?this.placeNodes(u):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let o=this.placed,s=r.depth,l=i.depth;for(;s&&l&&o.childCount==1;)o=o.firstChild.content,s--,l--;let a=new E(o,s,l);return e>-1?new he(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new fe(r.pos,i.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<e;r++){let o=t.firstChild;if(t.childCount>1&&(i=0),o.type.spec.isolating&&i<=r){e=r;break}t=o.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let i,o=null;r?(o=Ff(this.unplaced.content,r-1).firstChild,i=o.content):i=this.unplaced.content;let s=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:u}=this.frontier[l],c,f=null;if(t==1&&(s?u.matchType(s.type)||(f=u.fillBefore(M.from(s),!1)):o&&a.compatibleContent(o.type)))return{sliceDepth:r,frontierDepth:l,parent:o,inject:f};if(t==2&&s&&(c=u.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:l,parent:o,wrap:c};if(o&&u.matchType(o.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced;return _f(e,-1)<=t?!1:(this.unplaced.size>1&&_f(e,1)>r&&r++,this.unplaced=new E(e,t+1,r),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=Ff(e,t);if(i.childCount<=1&&t>0){let o=e.size-t<=t+i.size;this.unplaced=new E(qr(e,t-1,1),t-1,o?t-1:r)}else this.unplaced=new E(qr(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:i,wrap:o}){for(;this.depth>t;)this.closeFrontierNode();if(o)for(let m=0;m<o.length;m++)this.openFrontierNode(o[m]);let s=this.unplaced,l=r?r.content:s.content,a=s.openStart-e,u=0,c=[],{match:f,type:d}=this.frontier[t];if(i){for(let m=0;m<i.childCount;m++)c.push(i.child(m));f=f.matchFragment(i)}let h=l.size+e-(s.content.size-s.openEnd);for(;u<l.childCount;){let m=l.child(u),k=f.matchType(m.type);if(!k)break;u++,(u>1||a==0||m.content.size)&&(f=k,c.push(Gf(m.mark(d.allowedMarks(m.marks)),u==1?a:0,u==l.childCount?h:-1)))}let p=u==l.childCount;p||(h=-1),this.placed=Wr(this.placed,t,M.from(c)),this.frontier[t].match=f,p&&h<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,k=l;m<h;m++){let x=k.lastChild;this.frontier.push({type:x.type,match:x.contentMatchAt(x.childCount)}),k=x.content}this.unplaced=p?e==0?E.empty:new E(qr(s.content,e-1,1),e-1,h<0?s.openEnd:e-1):new E(qr(s.content,e,u),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!cl(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:r}=this.$to,i=this.$to.after(r);for(;r>1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:i}=this.frontier[t],o=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),s=cl(e,t,i,r,o);if(s){for(let l=t-1;l>=0;l--){let{match:a,type:u}=this.frontier[l],c=cl(e,l,u,a,!0);if(!c||c.childCount)continue e}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=Wr(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let i=e.node(r),o=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,o)}return e}openFrontierNode(e,t=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=Wr(this.placed,this.depth,M.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(M.empty,!0);t.childCount&&(this.placed=Wr(this.placed,this.frontier.length,t))}};function qr(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(qr(n.firstChild.content,e-1,t)))}function Wr(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Wr(n.lastChild.content,e-1,t)))}function Ff(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function Gf(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,Gf(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(M.empty,!0)))),n.copy(r)}function cl(n,e,t,r,i){let o=n.node(e),s=i?n.indexAfter(e):n.index(e);if(s==o.childCount&&!t.compatibleContent(o.type))return null;let l=r.fillBefore(o.content,!0,s);return l&&!Nx(t,o.content,s)?l:null}function Nx(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function Ix(n){return n.spec.defining||n.spec.definingForContent}function _f(n,e){for(let t=0;;t++){let r=e<0?n.firstChild:n.lastChild;if(!r||r.isAtom)return t;n=r.content}}function Ex(n,e,t,r){if(!r.size)return n.deleteRange(e,t);let i=n.doc.resolve(e),o=n.doc.resolve(t);if(Jf(i,o,r))return n.step(new fe(e,t,r));let s=Yf(i,o);s[s.length-1]==0&&s.pop();let l=-(i.depth+1);s.unshift(l);for(let d=i.depth,h=i.pos-1;d>0;d--,h--){let p=i.node(d).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;s.indexOf(d)>-1?l=d:i.before(d)==h&&s.splice(1,0,-d)}let a=s.indexOf(l),u=[],c=r.openStart;for(let d=r.content,h=0;;h++){let p=d.firstChild;if(u.push(p),h==r.openStart)break;d=p.content}for(let d=c-1;d>=0;d--){let h=u[d],p=Ix(h.type);if(p&&!h.sameMarkup(i.node(Math.abs(l)-1)))c=d;else if(p||!h.type.isTextblock)break}for(let d=r.openStart;d>=0;d--){let h=(d+c+1)%(r.openStart+1),p=u[h];if(p)for(let m=0;m<s.length;m++){let k=s[(m+a)%s.length],x=!0;k<0&&(x=!1,k=-k);let O=i.node(k-1),C=i.index(k-1);if(O.canReplaceWith(C,C,p.type,p.marks))return n.replace(i.before(k),x?o.after(k):t,new E(Qf(r.content,0,r.openStart,h),h,r.openEnd))}}let f=n.steps.length;for(let d=s.length-1;d>=0&&(n.replace(e,t,r),!(n.steps.length>f));d--){let h=s[d];h<0||(e=i.before(h),t=o.after(h))}}function Qf(n,e,t,r,i){if(e<t){let o=n.firstChild;n=n.replaceChild(0,o.copy(Qf(o.content,e+1,t,r,o)))}if(e>r){let o=i.contentMatchAt(0),s=o.fillBefore(n).append(n);n=s.append(o.matchFragment(s).fillBefore(M.empty,!0))}return n}function Ox(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let i=Mx(n.doc,e,r.type);i!=null&&(e=t=i)}n.replaceRange(e,t,new E(M.from(r),0,0))}function Tx(n,e,t){let r=n.doc.resolve(e),i=n.doc.resolve(t);if(r.parent.isTextblock&&i.parent.isTextblock&&r.start()!=i.start()&&r.parentOffset==0&&i.parentOffset==0){let s=r.sharedDepth(t),l=!1;for(let a=r.depth;a>s;a--)r.node(a).type.spec.isolating&&(l=!0);for(let a=i.depth;a>s;a--)i.node(a).type.spec.isolating&&(l=!0);if(!l){for(let a=r.depth;a>0&&e==r.start(a);a--)e=r.before(a);for(let a=i.depth;a>0&&t==i.start(a);a--)t=i.before(a);r=n.doc.resolve(e),i=n.doc.resolve(t)}}let o=Yf(r,i);for(let s=0;s<o.length;s++){let l=o[s],a=s==o.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return n.delete(r.start(l),i.end(l));if(l>0&&(a||r.node(l-1).canReplace(r.index(l-1),i.indexAfter(l-1))))return n.delete(r.before(l),i.after(l))}for(let s=1;s<=r.depth&&s<=i.depth;s++)if(e-r.start(s)==r.depth-s&&t>r.end(s)&&i.end(s)-t!=i.depth-s&&r.start(s-1)==i.start(s-1)&&r.node(s-1).canReplace(r.index(s-1),i.index(s-1)))return n.delete(r.before(s),t);n.delete(e,t)}function Yf(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let i=r;i>=0;i--){let o=n.start(i);if(o<n.pos-(n.depth-i)||e.end(i)>e.pos+(e.depth-i)||n.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(o==e.start(i)||i==n.depth&&i==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==o-1)&&t.push(i)}return t}var ho=class n extends te{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return le.fail("No node at attribute step's position");let r=Object.create(null);for(let o in t.attrs)r[o]=t.attrs[o];r[this.attr]=this.value;let i=t.type.create(r,null,t.marks);return le.fromReplace(e,this.pos,this.pos+1,new E(M.from(i),0,t.isLeaf?0:1))}getMap(){return mt.empty}invert(e){return new n(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new n(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new n(t.pos,t.attr,t.value)}};te.jsonID("attr",ho);var po=class n extends te{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let i in e.attrs)t[i]=e.attrs[i];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return le.ok(r)}getMap(){return mt.empty}invert(e){return new n(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new n(t.attr,t.value)}};te.jsonID("docAttr",po);var jn=class extends Error{};jn=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};jn.prototype=Object.create(Error.prototype);jn.prototype.constructor=jn;jn.prototype.name="TransformError";var mo=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Kr}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new jn(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 r=0;r<this.mapping.maps.length;r++){let i=this.mapping.maps[r];r&&(e=i.map(e,1),t=i.map(t,-1)),i.forEach((o,s,l,a)=>{e=Math.min(e,l),t=Math.max(t,a)})}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,r=E.empty){let i=Gr(this.doc,e,t,r);return i&&this.step(i),this}replaceWith(e,t,r){return this.replace(e,t,new E(M.from(r),0,0))}delete(e,t){return this.replace(e,t,E.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return Ex(this,e,t,r),this}replaceRangeWith(e,t,r){return Ox(this,e,t,r),this}deleteRange(e,t){return Tx(this,e,t),this}lift(e,t){return dx(this,e,t),this}join(e,t=1){return Cx(this,e,t),this}wrap(e,t){return gx(this,e,t),this}setBlockType(e,t=e,r,i=null){return yx(this,e,t,r,i),this}setNodeMarkup(e,t,r=null,i){return kx(this,e,t,r,i),this}setNodeAttribute(e,t,r){return this.step(new ho(e,t,r)),this}setDocAttribute(e,t){return this.step(new po(e,t)),this}addNodeMark(e,t){return this.step(new Jr(e,t)),this}removeNodeMark(e,t){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t instanceof W)t.isInSet(r.marks)&&this.step(new $n(e,t));else{let i=r.marks,o,s=[];for(;o=t.isInSet(i);)s.push(new $n(e,o)),i=o.removeFromSet(i);for(let l=s.length-1;l>=0;l--)this.step(s[l])}return this}split(e,t=1,r){return bx(this,e,t,r),this}addMark(e,t,r){return cx(this,e,t,r),this}removeMark(e,t,r){return fx(this,e,t,r),this}clearIncompatible(e,t,r){return pl(this,e,t,r),this}};var ml=Object.create(null),j=class{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new Hn(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=E.empty){let r=t.content.lastChild,i=null;for(let l=0;l<t.openEnd;l++)i=r,r=r.lastChild;let o=e.steps.length,s=this.ranges;for(let l=0;l<s.length;l++){let{$from:a,$to:u}=s[l],c=e.mapping.slice(o);e.replaceRange(c.map(a.pos),c.map(u.pos),l?E.empty:t),l==0&&eh(e,o,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,t){let r=e.steps.length,i=this.ranges;for(let o=0;o<i.length;o++){let{$from:s,$to:l}=i[o],a=e.mapping.slice(r),u=a.map(s.pos),c=a.map(l.pos);o?e.deleteRange(u,c):(e.replaceRangeWith(u,c,t),eh(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let i=e.parent.inlineContent?new H(e):Wn(e.node(0),e.parent,e.pos,e.index(),t,r);if(i)return i;for(let o=e.depth-1;o>=0;o--){let s=t<0?Wn(e.node(0),e.node(o),e.before(o+1),e.index(o),t,r):Wn(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,t,r);if(s)return s}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new Le(e.node(0))}static atStart(e){return Wn(e,e,0,0,1)||new Le(e)}static atEnd(e){return Wn(e,e,e.content.size,e.childCount,-1)||new Le(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=ml[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in ml)throw new RangeError("Duplicate use of selection JSON ID "+e);return ml[e]=t,t.prototype.jsonID=e,t}getBookmark(){return H.between(this.$anchor,this.$head).getBookmark()}};j.prototype.visible=!0;var Hn=class{constructor(e,t){this.$from=e,this.$to=t}},Xf=!1;function Zf(n){!Xf&&!n.parent.inlineContent&&(Xf=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}var H=class n extends j{constructor(e,t=e){Zf(e),Zf(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return j.near(r);let i=e.resolve(t.map(this.anchor));return new n(i.parent.inlineContent?i:r,r)}replace(e,t=E.empty){if(super.replace(e,t),t==E.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof n&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new yo(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new n(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let i=e.resolve(t);return new this(i,r==t?i:e.resolve(r))}static between(e,t,r){let i=e.pos-t.pos;if((!r||i)&&(r=i>=0?1:-1),!t.parent.inlineContent){let o=j.findFrom(t,r,!0)||j.findFrom(t,-r,!0);if(o)t=o.$head;else return j.near(t,r)}return e.parent.inlineContent||(i==0?e=t:(e=(j.findFrom(e,-r,!0)||j.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=i<0&&(e=t))),new n(e,t)}};j.jsonID("text",H);var yo=class n{constructor(e,t){this.anchor=e,this.head=t}map(e){return new n(e.map(this.anchor),e.map(this.head))}resolve(e){return H.between(e.resolve(this.anchor),e.resolve(this.head))}},B=class n extends j{constructor(e){let t=e.nodeAfter,r=e.node(0).resolve(e.pos+t.nodeSize);super(e,r),this.node=t}map(e,t){let{deleted:r,pos:i}=t.mapResult(this.anchor),o=e.resolve(i);return r?j.near(o):new n(o)}content(){return new E(M.from(this.node),0,0)}eq(e){return e instanceof n&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new yl(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new n(e.resolve(t.anchor))}static create(e,t){return new n(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}};B.prototype.visible=!1;j.jsonID("node",B);var yl=class n{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new yo(r,r):new n(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&B.isSelectable(r)?new B(t):j.near(t)}},Le=class n extends j{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=E.empty){if(t==E.empty){e.delete(0,e.doc.content.size);let r=j.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new n(e)}map(e){return new n(e)}eq(e){return e instanceof n}getBookmark(){return Ax}};j.jsonID("all",Le);var Ax={map(){return this},resolve(n){return new Le(n)}};function Wn(n,e,t,r,i,o=!1){if(e.inlineContent)return H.create(n,t);for(let s=r-(i>0?0:1);i>0?s<e.childCount:s>=0;s+=i){let l=e.child(s);if(l.isAtom){if(!o&&B.isSelectable(l))return B.create(n,t-(i<0?l.nodeSize:0))}else{let a=Wn(n,l,t+i,i<0?l.childCount:0,i,o);if(a)return a}t+=l.nodeSize*i}return null}function eh(n,e,t){let r=n.steps.length-1;if(r<e)return;let i=n.steps[r];if(!(i instanceof fe||i instanceof he))return;let o=n.mapping.maps[r],s;o.forEach((l,a,u,c)=>{s==null&&(s=c)}),n.setSelection(j.near(n.doc.resolve(s),t))}var th=1,go=2,nh=4,xl=class extends mo{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|th)&~go,this.storedMarks=null,this}get selectionSet(){return(this.updated&th)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=go,this}ensureMarks(e){return W.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&go)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~go,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||W.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let i=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),!e)return this.deleteRange(t,r);let o=this.storedMarks;if(!o){let s=this.doc.resolve(t);o=r==t?s.marks():s.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,i.text(e,o)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(j.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|=nh,this}get scrolledIntoView(){return(this.updated&nh)>0}};function rh(n,e){return!e||!n?n:n.bind(e)}var rn=class{constructor(e,t,r){this.name=e,this.init=rh(t.init,r),this.apply=rh(t.apply,r)}},vx=[new rn("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new rn("selection",{init(n,e){return n.selection||j.atStart(e.doc)},apply(n){return n.selection}}),new rn("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new rn("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})],Qr=class{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=vx.slice(),t&&t.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new rn(r.key,r.spec.state,r))})}},Kn=class n{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=t){let i=this.config.plugins[r];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],r=this.applyInner(e),i=null;for(;;){let o=!1;for(let s=0;s<this.config.plugins.length;s++){let l=this.config.plugins[s];if(l.spec.appendTransaction){let a=i?i[s].n:0,u=i?i[s].state:this,c=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,u,r);if(c&&r.filterTransaction(c,s)){if(c.setMeta("appendedTransaction",e),!i){i=[];for(let f=0;f<this.config.plugins.length;f++)i.push(f<s?{state:r,n:t.length}:{state:this,n:0})}t.push(c),r=r.applyInner(c),o=!0}i&&(i[s]={state:r,n:t.length})}}if(!o)return{state:r,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new n(this.config),r=this.config.fields;for(let i=0;i<r.length;i++){let o=r[i];t[o.name]=o.apply(e,this[o.name],this,t)}return t}get tr(){return new xl(this)}static create(e){let t=new Qr(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new n(t);for(let i=0;i<t.fields.length;i++)r[t.fields[i].name]=t.fields[i].init(e,r);return r}reconfigure(e){let t=new Qr(this.schema,e.plugins),r=t.fields,i=new n(t);for(let o=0;o<r.length;o++){let s=r[o].name;i[s]=this.hasOwnProperty(s)?this[s]:r[o].init(e,i)}return i}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],o=i.spec.state;o&&o.toJSON&&(t[r]=o.toJSON.call(i,this[i.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new Qr(e.schema,e.plugins),o=new n(i);return i.fields.forEach(s=>{if(s.name=="doc")o.doc=Ae.fromJSON(e.schema,t.doc);else if(s.name=="selection")o.selection=j.fromJSON(o.doc,t.selection);else if(s.name=="storedMarks")t.storedMarks&&(o.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],u=a.spec.state;if(a.key==s.name&&u&&u.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){o[s.name]=u.fromJSON.call(a,e,t[l],o);return}}o[s.name]=s.init(e,o)}}),o}};function ih(n,e,t){for(let r in n){let i=n[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=ih(i,e,{})),t[r]=i}return t}var ie=class{constructor(e){this.spec=e,this.props={},e.props&&ih(e.props,this,this.props),this.key=e.key?e.key.key:oh("plugin")}getState(e){return e[this.key]}},gl=Object.create(null);function oh(n){return n in gl?n+"$"+ ++gl[n]:(gl[n]=0,n+"$")}var ae=class{constructor(e="key"){this.key=oh(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}};var xo=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function lh(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}var bl=(n,e,t)=>{let r=lh(n,t);if(!r)return!1;let i=wl(r);if(!i){let s=r.blockRange(),l=s&&qn(s);return l==null?!1:(e&&e(n.tr.lift(s,l).scrollIntoView()),!0)}let o=i.nodeBefore;if(ch(n,i,e,-1))return!0;if(r.parent.content.size==0&&(Un(o,"end")||B.isSelectable(o)))for(let s=r.depth;;s--){let l=Gr(n.doc,r.before(s),r.after(s),E.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=n.tr.step(l);a.setSelection(Un(o,"end")?j.findFrom(a.doc.resolve(a.mapping.map(i.pos,-1)),-1):B.create(a.doc,i.pos-o.nodeSize)),e(a.scrollIntoView())}return!0}if(s==1||r.node(s-1).childCount>1)break}return o.isAtom&&i.depth==r.depth-1?(e&&e(n.tr.delete(i.pos-o.nodeSize,i.pos).scrollIntoView()),!0):!1},ah=(n,e,t)=>{let r=lh(n,t);if(!r)return!1;let i=wl(r);return i?Dx(n,i,e):!1};function Dx(n,e,t){let r=e.nodeBefore,i=r,o=e.pos-1;for(;!i.isTextblock;o--){if(i.type.spec.isolating)return!1;let c=i.lastChild;if(!c)return!1;i=c}let s=e.nodeAfter,l=s,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let c=l.firstChild;if(!c)return!1;l=c}let u=Gr(n.doc,o,a,E.empty);if(!u||u.from!=o||u instanceof fe&&u.slice.size>=a-o)return!1;if(t){let c=n.tr.step(u);c.setSelection(H.create(c.doc,o)),t(c.scrollIntoView())}return!0}function Un(n,e,t=!1){for(let r=n;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(t&&r.childCount!=1)return!1}return!1}var Sl=(n,e,t)=>{let{$head:r,empty:i}=n.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;o=wl(r)}let s=o&&o.nodeBefore;return!s||!B.isSelectable(s)?!1:(e&&e(n.tr.setSelection(B.create(n.doc,o.pos-s.nodeSize)).scrollIntoView()),!0)};function wl(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function Rx(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}var Px=(n,e,t)=>{let r=Rx(n,t);if(!r)return!1;let i=uh(r);if(!i)return!1;let o=i.nodeAfter;if(ch(n,i,e,1))return!0;if(r.parent.content.size==0&&(Un(o,"start")||B.isSelectable(o))){let s=Gr(n.doc,r.before(),r.after(),E.empty);if(s&&s.slice.size<s.to-s.from){if(e){let l=n.tr.step(s);l.setSelection(Un(o,"start")?j.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):B.create(l.doc,l.mapping.map(i.pos))),e(l.scrollIntoView())}return!0}}return o.isAtom&&i.depth==r.depth-1?(e&&e(n.tr.delete(i.pos,i.pos+o.nodeSize).scrollIntoView()),!0):!1},Bx=(n,e,t)=>{let{$head:r,empty:i}=n.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset<r.parent.content.size)return!1;o=uh(r)}let s=o&&o.nodeAfter;return!s||!B.isSelectable(s)?!1:(e&&e(n.tr.setSelection(B.create(n.doc,o.pos)).scrollIntoView()),!0)};function uh(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){let t=n.node(e);if(n.index(e)+1<t.childCount)return n.doc.resolve(n.after(e+1));if(t.type.spec.isolating)break}return null}var Lx=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(`
|
|
42
|
+
`).scrollIntoView()),!0)};function Cl(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}var zx=(n,e)=>{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let i=t.node(-1),o=t.indexAfter(-1),s=Cl(i.contentMatchAt(o));if(!s||!i.canReplaceWith(o,o,s))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,s.createAndFill());a.setSelection(j.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Fx=(n,e)=>{let t=n.selection,{$from:r,$to:i}=t;if(t instanceof Le||r.parent.inlineContent||i.parent.inlineContent)return!1;let o=Cl(i.parent.contentMatchAt(i.indexAfter()));if(!o||!o.isTextblock)return!1;if(e){let s=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,l=n.tr.insert(s,o.createAndFill());l.setSelection(H.create(l.doc,s+1)),e(l.scrollIntoView())}return!0},_x=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let o=t.before();if(tn(n.doc,o))return e&&e(n.tr.split(o).scrollIntoView()),!0}let r=t.blockRange(),i=r&&qn(r);return i==null?!1:(e&&e(n.tr.lift(r,i).scrollIntoView()),!0)};function Vx(n){return(e,t)=>{if(e.selection instanceof B&&e.selection.node.isBlock){let{$from:h}=e.selection;return!h.parentOffset||!tn(e.doc,h.pos)?!1:(t&&t(e.tr.split(h.pos).scrollIntoView()),!0)}if(!e.selection.$from.depth)return!1;let r=e.tr;!e.selection.empty&&(e.selection instanceof H||e.selection instanceof Le)&&r.deleteSelection();let{$from:i}=r.selection,o=r.steps.length,s=[],l,a,u=!1,c=!1;for(let h=i.depth;;h--)if(i.node(h).isBlock){u=i.end(h)==i.pos+(i.depth-h),c=i.start(h)==i.pos-(i.depth-h),a=Cl(i.node(h-1).contentMatchAt(i.indexAfter(h-1)));let m=n&&n(i.parent,u,i);s.unshift(m||(u&&a?{type:a}:null)),l=h;break}else{if(h==1)return!1;s.unshift(null)}let f=i.pos,d=tn(r.doc,f,s.length,s);if(d||(s[0]=a?{type:a}:null,d=tn(r.doc,f,s.length,s)),!d)return!1;if(r.split(f,s.length,s),!u&&c&&i.node(l).type!=a){let h=r.mapping.slice(o),p=h.map(i.before(l)),m=r.doc.resolve(p);a&&i.node(l-1).canReplaceWith(m.index(),m.index()+1,a)&&r.setNodeMarkup(h.map(i.before(l)),a)}return t&&t(r.scrollIntoView()),!0}}var $x=Vx();var jx=(n,e)=>(e&&e(n.tr.setSelection(new Le(n.doc))),!0);function qx(n,e,t){let r=e.nodeBefore,i=e.nodeAfter,o=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(o-1,o)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(o,o+1)||!(i.isTextblock||nn(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function ch(n,e,t,r){let i=e.nodeBefore,o=e.nodeAfter,s,l,a=i.type.spec.isolating||o.type.spec.isolating;if(!a&&qx(n,e,t))return!0;let u=!a&&e.parent.canReplace(e.index(),e.index()+1);if(u&&(s=(l=i.contentMatchAt(i.childCount)).findWrapping(o.type))&&l.matchType(s[0]||o.type).validEnd){if(t){let h=e.pos+o.nodeSize,p=M.empty;for(let x=s.length-1;x>=0;x--)p=M.from(s[x].create(null,p));p=M.from(i.copy(p));let m=n.tr.step(new he(e.pos-1,h,e.pos,h,new E(p,1,0),s.length,!0)),k=m.doc.resolve(h+2*s.length);k.nodeAfter&&k.nodeAfter.type==i.type&&nn(m.doc,k.pos)&&m.join(k.pos),t(m.scrollIntoView())}return!0}let c=o.type.spec.isolating||r>0&&a?null:j.findFrom(e,1),f=c&&c.$from.blockRange(c.$to),d=f&&qn(f);if(d!=null&&d>=e.depth)return t&&t(n.tr.lift(f,d).scrollIntoView()),!0;if(u&&Un(o,"start",!0)&&Un(i,"end")){let h=i,p=[];for(;p.push(h),!h.isTextblock;)h=h.lastChild;let m=o,k=1;for(;!m.isTextblock;m=m.firstChild)k++;if(h.canReplace(h.childCount,h.childCount,m.content)){if(t){let x=M.empty;for(let C=p.length-1;C>=0;C--)x=M.from(p[C].copy(x));let O=n.tr.step(new he(e.pos-p.length,e.pos+o.nodeSize,e.pos+k,e.pos+o.nodeSize-k,new E(x,p.length,0),0,!0));t(O.scrollIntoView())}return!0}}return!1}function fh(n){return function(e,t){let r=e.selection,i=n<0?r.$from:r.$to,o=i.depth;for(;i.node(o).isInline;){if(!o)return!1;o--}return i.node(o).isTextblock?(t&&t(e.tr.setSelection(H.create(e.doc,n<0?i.start(o):i.end(o)))),!0):!1}}var Wx=fh(-1),Hx=fh(1);function ko(n,e=null){return function(t,r){let{$from:i,$to:o}=t.selection,s=i.blockRange(o),l=s&&en(s,n,e);return l?(r&&r(t.tr.wrap(s,l).scrollIntoView()),!0):!1}}function Jn(n,e=null){return function(t,r){let i=!1;for(let o=0;o<t.selection.ranges.length&&!i;o++){let{$from:{pos:s},$to:{pos:l}}=t.selection.ranges[o];t.doc.nodesBetween(s,l,(a,u)=>{if(i)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)i=!0;else{let c=t.doc.resolve(u),f=c.index();i=c.parent.canReplaceWith(f,f+1,n)}})}if(!i)return!1;if(r){let o=t.tr;for(let s=0;s<t.selection.ranges.length;s++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[s];o.setBlockType(l,a,n,e)}r(o.scrollIntoView())}return!0}}function Kx(n,e,t,r){for(let i=0;i<e.length;i++){let{$from:o,$to:s}=e[i],l=o.depth==0?n.inlineContent&&n.type.allowsMarkType(t):!1;if(n.nodesBetween(o.pos,s.pos,(a,u)=>{if(l||!r&&a.isAtom&&a.isInline&&u>=o.pos&&u+a.nodeSize<=s.pos)return!1;l=a.inlineContent&&a.type.allowsMarkType(t)}),l)return!0}return!1}function Ux(n){let e=[];for(let t=0;t<n.length;t++){let{$from:r,$to:i}=n[t];r.doc.nodesBetween(r.pos,i.pos,(o,s)=>{if(o.isAtom&&o.content.size&&o.isInline&&s>=r.pos&&s+o.nodeSize<=i.pos)return s+1>r.pos&&e.push(new Hn(r,r.doc.resolve(s+1))),r=r.doc.resolve(s+1+o.content.size),!1}),r.pos<i.pos&&e.push(new Hn(r,i))}return e}function bo(n,e=null,t){let r=(t&&t.removeWhenPresent)!==!1,i=(t&&t.enterInlineAtoms)!==!1,o=!(t&&t.includeWhitespace);return function(s,l){let{empty:a,$cursor:u,ranges:c}=s.selection;if(a&&!u||!Kx(s.doc,c,n,i))return!1;if(l)if(u)n.isInSet(s.storedMarks||u.marks())?l(s.tr.removeStoredMark(n)):l(s.tr.addStoredMark(n.create(e)));else{let f,d=s.tr;i||(c=Ux(c)),r?f=!c.some(h=>s.doc.rangeHasMark(h.$from.pos,h.$to.pos,n)):f=!c.every(h=>{let p=!1;return d.doc.nodesBetween(h.$from.pos,h.$to.pos,(m,k,x)=>{if(p)return!1;p=!n.isInSet(m.marks)&&!!x&&x.type.allowsMarkType(n)&&!(m.isText&&/^\s*$/.test(m.textBetween(Math.max(0,h.$from.pos-k),Math.min(m.nodeSize,h.$to.pos-k))))}),!p});for(let h=0;h<c.length;h++){let{$from:p,$to:m}=c[h];if(!f)d.removeMark(p.pos,m.pos,n);else{let k=p.pos,x=m.pos,O=p.nodeAfter,C=m.nodeBefore,A=o&&O&&O.isText?/^\s*/.exec(O.text)[0].length:0,z=o&&C&&C.isText?/\s*$/.exec(C.text)[0].length:0;k+A<x&&(k+=A,x-=z),d.addMark(k,x,n.create(e))}}l(d.scrollIntoView())}return!0}}function on(...n){return function(e,t,r){for(let i=0;i<n.length;i++)if(n[i](e,t,r))return!0;return!1}}var kl=on(xo,bl,Sl),sh=on(xo,Px,Bx),gt={Enter:on(Lx,Fx,_x,$x),"Mod-Enter":zx,Backspace:kl,"Mod-Backspace":kl,"Shift-Backspace":kl,Delete:sh,"Mod-Delete":sh,"Mod-a":jx},hh={"Ctrl-h":gt.Backspace,"Alt-Backspace":gt["Mod-Backspace"],"Ctrl-d":gt.Delete,"Ctrl-Alt-Backspace":gt["Mod-Delete"],"Alt-Delete":gt["Mod-Delete"],"Alt-d":gt["Mod-Delete"],"Ctrl-a":Wx,"Ctrl-e":Hx};for(let n in gt)hh[n]=gt[n];var Jx=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1,dh=Jx?hh:gt;var Ce=class{constructor(e,t,r={}){this.match=e,this.match=e,this.handler=typeof t=="string"?Gx(t):t,this.undoable=r.undoable!==!1,this.inCode=r.inCode||!1,this.inCodeMark=r.inCodeMark!==!1}};function Gx(n){return function(e,t,r,i){let o=n;if(t[1]){let s=t[0].lastIndexOf(t[1]);o+=t[0].slice(s+t[1].length),r+=s;let l=r-i;l>0&&(o=t[0].slice(s-l,s)+o,r=i)}return e.tr.insertText(o,r,i)}}var ph=(n,e)=>{let t=n.plugins;for(let r=0;r<t.length;r++){let i=t[r],o;if(i.spec.isInputRules&&(o=i.getState(n))){if(e){let s=n.tr,l=o.transform;for(let a=l.steps.length-1;a>=0;a--)s.step(l.steps[a].invert(l.docs[a]));if(o.text){let a=s.doc.resolve(o.from).marks();s.replaceWith(o.from,o.to,n.schema.text(o.text,a))}else s.delete(o.from,o.to);e(s)}return!0}}return!1},_E=new Ce(/--$/,"\u2014",{inCodeMark:!1}),VE=new Ce(/\.\.\.$/,"\u2026",{inCodeMark:!1}),$E=new Ce(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"\u201C",{inCodeMark:!1}),jE=new Ce(/"$/,"\u201D",{inCodeMark:!1}),qE=new Ce(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"\u2018",{inCodeMark:!1}),WE=new Ce(/'$/,"\u2019",{inCodeMark:!1});function So(n,e,t=null,r){return new Ce(n,(i,o,s,l)=>{let a=t instanceof Function?t(o):t,u=i.tr.delete(s,l),c=u.doc.resolve(s),f=c.blockRange(),d=f&&en(f,e,a);if(!d)return null;u.wrap(f,d);let h=u.doc.resolve(s-1).nodeBefore;return h&&h.type==e&&nn(u.doc,s-1)&&(!r||r(o,h))&&u.join(s-1),u})}function Ml(n,e,t=null){return new Ce(n,(r,i,o,s)=>{let l=r.doc.resolve(o),a=t instanceof Function?t(i):t;return l.node(-1).canReplaceWith(l.index(-1),l.indexAfter(-1),e)?r.tr.delete(o,s).setBlockType(o,o,e,a):null})}var Pt=typeof navigator<"u"?navigator:null,mh=typeof document<"u"?document:null,Bt=Pt&&Pt.userAgent||"",Il=/Edge\/(\d+)/.exec(Bt),yh=/MSIE \d/.exec(Bt),El=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Bt),Tl=!!(yh||El||Il),JE=yh?document.documentMode:El?+El[1]:Il?+Il[1]:0,Qx=!Tl&&/gecko\/(\d+)/i.test(Bt),GE=Qx&&+(/Firefox\/(\d+)/.exec(Bt)||[0,0])[1],Ol=!Tl&&/Chrome\/(\d+)/.exec(Bt),Yx=!!Ol,QE=Ol?+Ol[1]:0,Xx=!Tl&&!!Pt&&/Apple Computer/.test(Pt.vendor),Zx=Xx&&(/Mobile\/\w+/.test(Bt)||!!Pt&&Pt.maxTouchPoints>2),YE=Zx||(Pt?/Mac/.test(Pt.platform):!1),ek=/Android \d/.test(Bt),tk=!!mh&&"webkitFontSmoothing"in mh.documentElement.style,XE=tk?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Nl(n,e,t,r,i,o){if(n.composing)return!1;let s=n.state,l=s.doc.resolve(e);if(l.parent.type.spec.code)return!1;let a=l.parent.textBetween(Math.max(0,l.parentOffset-500),l.parentOffset,void 0,"\uFFFC")+r;for(let u of i){let c=u,f=c.match.exec(a),d=f&&f[0]&&c.handler(s,f,e-(f[0].length-r.length),t);if(d)return c.undoable!==!1&&d.setMeta(o,{transform:d,from:e,to:t,text:r}),n.dispatch(d),!0}return!1}var nk=new ae("MILKDOWN_CUSTOM_INPUTRULES");function xh({rules:n}){let e=new ie({key:nk,isInputRules:!0,state:{init(){return null},apply(t,r){let i=t.getMeta(this);return i||(t.selectionSet||t.docChanged?null:r)}},props:{handleTextInput(t,r,i,o){return Nl(t,r,i,o,n,e)},handleDOMEvents:{compositionend:t=>(setTimeout(()=>{let{$cursor:r}=t.state.selection;r&&Nl(t,r.pos,r.pos,"",n,e)}),!1),keydown:(t,r)=>!(ek&&Yx&&r.key==="Enter")||t.composing?!1:t.someProp("handleKeyDown",i=>i(t,r))?(r.preventDefault(),!0):!1},handleKeyDown(t,r){if(r.key!=="Enter")return!1;let{$cursor:i}=t.state.selection;return i?Nl(t,i.pos,i.pos,`
|
|
43
|
+
`,n,e):!1}}});return e}function kh(n){return n.some(e=>e.type.spec.code)}function gh(n,e,t){if(e>=t)return!1;let r=!1;return n.doc.nodesBetween(e,t,i=>(i.isInline&&kh(i.marks)&&(r=!0),!r)),r}function rk(n,e){var t;return kh((t=n.storedMarks)!=null?t:n.doc.resolve(e).marks())}function Yr(n,e,t={}){return new Ce(n,(r,i,o,s)=>{var l,a,u,c;let{tr:f}=r,d=i.length,h=i[d-1],p=i[0],m=[],k,x={group:h,fullMatch:p,start:o,end:s},O=(l=t.updateCaptured)==null?void 0:l.call(t,x);if(Object.assign(x,O),{group:h,fullMatch:p,start:o,end:s}=x,p===null||h?.trim()==="")return null;if(h){let C=p.search(/\S/),A=o+p.indexOf(h),z=A+h.length,S=gh(r,o+C,A),I=z<s&&gh(r,z,s);if(S||I||rk(r,s))return null;m=(a=f.storedMarks)!=null?a:[],z<s&&f.delete(z,s),A>o&&f.delete(o+C,A),k=o+C+h.length;let R=(u=t.getAttr)==null?void 0:u.call(t,i);f.addMark(o,k,e.create(R)),f.setStoredMarks(m),(c=t.beforeDispatch)==null||c.call(t,{match:i,start:o,end:s,tr:f})}return f})}function ik(n,e){return Array.isArray(n)&&n.includes(e.type)||e.type===n}function bh(n,e){if(!(n instanceof B))return;let{node:t,$from:r}=n;if(ik(e,t))return{node:t,pos:r.pos,start:r.start(r.depth),depth:r.depth}}var Sh=(n,e)=>{let{selection:t,doc:r}=n;if(t instanceof B)return{hasNode:t.node.type===e,pos:t.from,target:t.node};let{from:i,to:o}=t,s=!1,l=-1,a=null;return r.nodesBetween(i,o,(u,c)=>a?!1:u.type===e?(s=!0,l=c,a=u,!1):!0),{hasNode:s,pos:l,target:a}};var yt={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:"'"},Co={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},ok=typeof navigator<"u"&&/Mac/.test(navigator.platform),sk=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(ne=0;ne<10;ne++)yt[48+ne]=yt[96+ne]=String(ne);var ne;for(ne=1;ne<=24;ne++)yt[ne+111]="F"+ne;var ne;for(ne=65;ne<=90;ne++)yt[ne]=String.fromCharCode(ne+32),Co[ne]=String.fromCharCode(ne);var ne;for(wo in yt)Co.hasOwnProperty(wo)||(Co[wo]=yt[wo]);var wo;function wh(n){var e=ok&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||sk&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Co:yt)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}var lk=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),ak=typeof navigator<"u"&&/Win/.test(navigator.platform);function uk(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,i,o,s;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))s=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))i=!0;else if(/^s(hift)?$/i.test(a))o=!0;else if(/^mod$/i.test(a))lk?s=!0:i=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(t="Alt-"+t),i&&(t="Ctrl-"+t),s&&(t="Meta-"+t),o&&(t="Shift-"+t),t}function ck(n){let e=Object.create(null);for(let t in n)e[uk(t)]=n[t];return e}function Al(n,e,t=!0){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t&&e.shiftKey&&(n="Shift-"+n),n}function Ch(n){return new ie({props:{handleKeyDown:fk(n)}})}function fk(n){let e=ck(n);return function(t,r){let i=wh(r),o,s=e[Al(i,r)];if(s&&s(t.state,t.dispatch,t))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let l=e[Al(i,r,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(ak&&r.ctrlKey&&r.altKey)&&(o=yt[r.keyCode])&&o!=i){let l=e[Al(o,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}var Nh=class{},Ih=class{constructor(){this.elements=[],this.size=()=>this.elements.length,this.top=()=>this.elements.at(-1),this.push=n=>{this.top()?.push(n)},this.open=n=>{this.elements.push(n)},this.close=()=>{let n=this.elements.pop();if(!n)throw fs();return n}}},hk=class Eh extends Nh{constructor(e,t,r){super(),this.type=e,this.content=t,this.attrs=r}push(e,...t){this.content.push(e,...t)}pop(){return this.content.pop()}static create(e,t,r){return new Eh(e,t,r)}},Oh=class extends Ih{#t;static{this.create=(n,e)=>{let t=new this(n);return r=>(t.run(e,r),t.toDoc())}}constructor(n){super(),this.#t=W.none,this.#e=e=>e.isText,this.#r=(e,t)=>{if(this.#e(e)&&this.#e(t)&&W.sameSet(e.marks,t.marks))return this.schema.text(e.text+t.text,e.marks)},this.#n=e=>{let t=Object.values({...this.schema.nodes,...this.schema.marks}).find(r=>r.spec.parseMarkdown.match(e));if(!t)throw Ou(e);return t},this.#o=e=>{let t=this.#n(e);t.spec.parseMarkdown.runner(this,e,t)},this.injectRoot=(e,t,r)=>(this.openNode(t,r),this.next(e.children),this),this.openNode=(e,t)=>(this.open(hk.create(e,[],t)),this),this.#s=()=>{this.#t=W.none;let e=this.close();return this.#i(e.type,e.attrs,e.content)},this.closeNode=()=>{try{this.#s()}catch(e){console.error(e)}return this},this.#i=(e,t,r)=>{let i=e.createAndFill(t,r,this.#t);if(!i)throw Eu(e,t,r);return this.push(i),i},this.addNode=(e,t,r)=>{try{this.#i(e,t,r)}catch(i){console.error(i)}return this},this.openMark=(e,t)=>{let r=e.create(t);return this.#t=r.addToSet(this.#t),this},this.closeMark=e=>(this.#t=e.removeFromSet(this.#t),this),this.addText=e=>{try{let t=this.top();if(!t)throw fs();let r=t.pop(),i=this.schema.text(e,this.#t);if(!r)return t.push(i),this;let o=this.#r(r,i);return o?(t.push(o),this):(t.push(r,i),this)}catch(t){return console.error(t),this}},this.build=()=>{let e;do e=this.#s();while(this.size());return e},this.next=(e=[])=>([e].flat().forEach(t=>this.#o(t)),this),this.toDoc=()=>this.build(),this.run=(e,t)=>{let r=e.runSync(e.parse(t),t);return this.next(r),this},this.schema=n}#e;#r;#n;#o;#s;#i},Mh=class Th extends Nh{constructor(e,t,r,i={}){super(),this.type=e,this.children=t,this.value=r,this.props=i,this.push=(o,...s)=>{this.children||(this.children=[]),this.children.push(o,...s)},this.pop=()=>this.children?.pop()}static{this.create=(e,t,r,i={})=>new Th(e,t,r,i)}},dk=n=>Object.prototype.hasOwnProperty.call(n,"size"),Ah=class extends Ih{#t;static{this.create=(n,e)=>{let t=new this(n);return r=>(t.run(r),t.toString(e))}}constructor(n){super(),this.#t=[],this.#e=e=>{let t=Object.values({...this.schema.nodes,...this.schema.marks}).find(r=>r.spec.toMarkdown.match(e));if(!t)throw Tu(e.type);return t},this.#r=e=>this.#e(e).spec.toMarkdown.runner(this,e),this.#n=(e,t)=>this.#e(e).spec.toMarkdown.runner(this,e,t),this.#o=e=>{let t=o=>o.type.spec.priority??50,r=[...e].sort((o,s)=>t(o)-t(s)),i=[];return this.#t.forEach(({mark:o})=>{let s=r.findIndex(l=>l.eq(o));s>=0&&i.push(...r.splice(s,1))}),i.concat(r)},this.#s=e=>{let t=e?.marks,r=0;for(;r<this.#t.length;){let{mark:i,spanning:o}=this.#t[r];if(o&&t?.some(s=>s.eq(i)))r++;else break}for(let i=this.#t.length-1;i>=r;i--)this.#f(this.#t[i].mark)},this.#i=(e,t)=>{this.#o(e.marks).every(r=>!this.#n(r,e))&&this.#r(e),this.#s(t)},this.#l=e=>{let{children:t}=e;return t&&(e.children=t.reduce((r,i,o)=>{if(o===0)return[i];let s=r.at(-1);if(s&&s.isMark&&i.isMark){let{children:l,...a}=i,{children:u,...c}=s;if(i.type===s.type&&l&&u&&JSON.stringify(a)===JSON.stringify(c)){let f={...c,children:[...u,...l]};return r.slice(0,-1).concat(this.#l(f))}}return r.concat(i)},[])),e},this.#a=e=>{let t={...e.props,type:e.type};return e.children&&(t.children=e.children),e.value&&(t.value=e.value),t},this.openNode=(e,t,r)=>(this.open(Mh.create(e,void 0,t,r)),this),this.#h=(e,t)=>{let r="",i="",o=e.children;if(o){let l=o[0],a=o.at(-1);if(a&&a.type==="text"&&a.value.endsWith(" ")){let u=a.value,c=u.trimEnd();i=u.slice(c.length),a.value=c}if(l&&l.type==="text"&&l.value.startsWith(" ")){let u=l.value,c=u.trimStart();r=u.slice(0,u.length-c.length),l.value=c}}r.length&&this.#c("text",void 0,r);let s=t();return i.length&&this.#c("text",void 0,i),s},this.#u=(e=!1)=>{let t=this.close(),r=()=>this.#c(t.type,t.children,t.value,t.props);return e?this.#h(t,r):r()},this.closeNode=()=>(this.#u(),this),this.#c=(e,t,r,i)=>{let o=Mh.create(e,t,r,i),s=this.#l(this.#a(o));return this.push(s),s},this.addNode=(e,t,r,i)=>(this.#c(e,t,r,i),this),this.#d=(e,t,r,i)=>this.#t.some(o=>o.mark.eq(e))?this:(this.#t.push({mark:e,spanning:r==null}),this.openNode(t,r,{...i,isMark:!0})),this.#f=e=>{let t=-1;for(let r=this.#t.length-1;r>=0;r--)if(this.#t[r].mark.eq(e)){t=r;break}t<0||(this.#t.splice(t,1),this.#u(!0))},this.withMark=(e,t,r,i)=>(this.#d(e,t,r,i),this),this.closeMark=e=>(this.#f(e),this),this.build=()=>{let e=null;do e=this.#u();while(this.size());return e.children||(e.children=[]),e},this.next=e=>dk(e)?(e.forEach((t,r,i)=>{this.#i(t,e.maybeChild(i+1)??void 0)}),this):(this.#i(e),this),this.toString=e=>e.stringify(this.build()),this.run=e=>(this.#t=[],this.next(e),this),this.schema=n}#e;#r;#n;#o;#s;#i;#l;#a;#h;#u;#c;#d;#f};var de=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},Xn=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e},Bl=null,kt=function(n,e,t){let r=Bl||(Bl=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},pk=function(){Bl=null},dn=function(n,e,t,r){return t&&(vh(n,e,t,r,-1)||vh(n,e,t,r,1))},mk=/^(img|br|input|textarea|hr)$/i;function vh(n,e,t,r,i){for(var o;;){if(n==t&&e==r)return!0;if(e==(i<0?0:be(n))){let s=n.parentNode;if(!s||!D(s)||li(n)||mk.test(n.nodeName)||n.contentEditable=="false")return!1;e=de(n)+(i<0?0:1),n=s}else if(D(n)){let s=n.childNodes[e+(i<0?-1:0)];if(D(s)&&s.contentEditable=="false")if(!((o=s.pmViewDesc)===null||o===void 0)&&o.ignoreForSelection)e+=i;else return!1;else n=s,e=i<0?be(n):0}else return!1}}function be(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function D(n){return n.nodeType==1}function oe(n){return n.nodeType==3}function pn(n,e){return e?n.contains(D(e)?e:e.parentNode):!1}function gk(n,e){for(;;){if(oe(n)&&e)return n;if(D(n)&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=be(n)}else if(n.parentNode&&!li(n))e=de(n),n=n.parentNode;else return null}}function yk(n,e){for(;;){if(oe(n)&&e<n.nodeValue.length)return n;if(D(n)&&e<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[e],e=0}else if(n.parentNode&&!li(n))e=de(n)+1,n=n.parentNode;else return null}}function xk(n,e,t){for(let r=e==0,i=e==be(n);r||i;){if(n==t)return!0;let o=de(n);if(n=n.parentNode,!n)return!1;r=r&&o==0,i=i&&o==be(n)}}function li(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}var Po=function(n){return n.focusNode&&dn(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function sn(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function kk(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function bk(n,e,t){if(n.caretPositionFromPoint)try{let r=n.caretPositionFromPoint(e,t);if(r)return{node:r.offsetNode,offset:Math.min(be(r.offsetNode),r.offset)}}catch{}if(n.caretRangeFromPoint){let r=n.caretRangeFromPoint(e,t);if(r)return{node:r.startContainer,offset:Math.min(be(r.startContainer),r.startOffset)}}}var st=typeof navigator<"u"?navigator:null,Dh=typeof document<"u"?document:null,Vt=st&&st.userAgent||"",Ll=/Edge\/(\d+)/.exec(Vt),ld=/MSIE \d/.exec(Vt),zl=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Vt),ve=!!(ld||zl||Ll),Ft=ld?document.documentMode:zl?+zl[1]:Ll?+Ll[1]:0,ze=!ve&&/gecko\/(\d+)/i.test(Vt);ze&&+(/Firefox\/(\d+)/.exec(Vt)||[0,0])[1];var Fl=!ve&&/Chrome\/(\d+)/.exec(Vt),pe=!!Fl,ad=Fl?+Fl[1]:0,Se=!ve&&!!st&&/Apple Computer/.test(st.vendor),Zn=Se&&(/Mobile\/\w+/.test(Vt)||!!st&&st.maxTouchPoints>2),He=Zn||(st?/Mac/.test(st.platform):!1),ud=st?/Win/.test(st.platform):!1,bt=/Android \d/.test(Vt),Bo=!!Dh&&"webkitFontSmoothing"in Dh.documentElement.style,Sk=Bo?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function wk(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function xt(n,e){return typeof n=="number"?n:n[e]}function Ck(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,r=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*r}}function Rh(n,e,t){if(!_l(e)&&e.left==0)return;let r=n.someProp("scrollThreshold")||0,i=n.someProp("scrollMargin")||5,o=n.dom.ownerDocument;for(let s=t||n.dom;s;){if(!D(s)){s=Xn(s);continue}let l=s==o.body,a=l?wk(o):Ck(s),u=0,c=0;if(e.top<a.top+xt(r,"top")?c=-(a.top-e.top+xt(i,"top")):e.bottom>a.bottom-xt(r,"bottom")&&(c=e.bottom-e.top>a.bottom-a.top?e.top+xt(i,"top")-a.top:e.bottom-a.bottom+xt(i,"bottom")),e.left<a.left+xt(r,"left")?u=-(a.left-e.left+xt(i,"left")):e.right>a.right-xt(r,"right")&&(u=e.right-a.right+xt(i,"right")),u||c)if(l)o.defaultView.scrollBy(u,c);else{let d=s.scrollLeft,h=s.scrollTop;c&&(s.scrollTop+=c),u&&(s.scrollLeft+=u);let p=s.scrollLeft-d,m=s.scrollTop-h;e={left:e.left-p,top:e.top-m,right:e.right-p,bottom:e.bottom-m}}let f=l?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(f))break;s=f=="absolute"?s.offsetParent:Xn(s)}}function Mk(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,i;for(let o=(e.left+e.right)/2,s=t+1;s<Math.min(innerHeight,e.bottom);s+=5){let l=n.root.elementFromPoint(o,s);if(!l||l==n.dom||!n.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=t-20){r=l,i=a.top;break}}return{refDOM:r,refTop:i,stack:cd(n.dom)}}function cd(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=Xn(r));return e}function Nk({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;fd(t,r==0?0:r-e)}function fd(n,e){for(let t=0;t<n.length;t++){let{dom:r,top:i,left:o}=n[t];r.scrollTop!=i+e&&(r.scrollTop=i+e),r.scrollLeft!=o&&(r.scrollLeft=o)}}var Gn=null;function Ik(n){if(n.setActive)return n.setActive();if(Gn)return n.focus(Gn);let e=cd(n);n.focus(Gn==null?{get preventScroll(){return Gn={preventScroll:!0},!0}}:void 0),Gn||(Gn=!1,fd(e,0))}function hd(n,e){let t,r=2e8,i,o=0,s=e.top,l=e.top,a,u;for(let c=n.firstChild,f=0;c;c=c.nextSibling,f++){let d;if(D(c))d=c.getClientRects();else if(oe(c))d=kt(c).getClientRects();else continue;for(let h=0;h<d.length;h++){let p=d[h];if(p.top<=s&&p.bottom>=l){s=Math.max(p.bottom,s),l=Math.min(p.top,l);let m=p.left>e.left?p.left-e.left:p.right<e.left?e.left-p.right:0;if(m<r){t=c,r=m,i=m&&oe(t)?{left:p.right<e.left?p.right:p.left,top:e.top}:e,D(c)&&m&&(o=f+(e.left>=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!a&&p.left<=e.left&&p.right>=e.left&&(a=c,u={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!t&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(o=f+1)}}return!t&&a&&(t=a,i=u,r=0),t&&oe(t)?Ek(t,i):!t||r?{node:n,offset:o}:hd(t,i)}function Ek(n,e){let t=n.nodeValue.length,r=document.createRange(),i;for(let o=0;o<t;o++){r.setEnd(n,o+1),r.setStart(n,o);let s=Lt(r,1);if(s.top!=s.bottom&&ta(e,s)){i={node:n,offset:o+(e.left>=(s.left+s.right)/2?1:0)};break}}return r.detach(),i||{node:n,offset:0}}function ta(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function Ok(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function Tk(n,e,t){let{node:r,offset:i}=hd(e,t),o=-1;if(D(r)&&!r.firstChild){let s=r.getBoundingClientRect();o=s.left!=s.right&&t.left>(s.left+s.right)/2?1:-1}return n.docView.posFromDOM(r,i,o)}function Ak(n,e,t,r){let i=-1;for(let o=e,s=!1;o!=n.dom;){let l=n.docView.nearestDesc(o,!0),a;if(!l)return null;if(D(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)&&(!s&&a.left>r.left||a.top>r.top?i=l.posBefore:(!s&&a.right<r.left||a.bottom<r.top)&&(i=l.posAfter),s=!0),!l.contentDOM&&i<0&&!l.node.isText))return(l.node.isBlock?r.top<(a.top+a.bottom)/2:r.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;o=l.dom.parentNode}return i>-1?i:n.docView.posFromDOM(e,t,-1)}function dd(n,e,t){let r=n.childNodes.length;if(r&&t.top<t.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-t.top)/(t.bottom-t.top))-2)),o=i;;){let s=n.childNodes[o];if(D(s)){let l=s.getClientRects();for(let a=0;a<l.length;a++){let u=l[a];if(ta(e,u))return dd(s,e,u)}}if((o=(o+1)%r)==i)break}return n}function vk(n,e){let t=n.dom.ownerDocument,r,i=0,o=bk(t,e.left,e.top);o&&({node:r,offset:i}=o);let s=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),l;if(!s||!n.dom.contains(s)){let u=n.dom.getBoundingClientRect();if(!ta(e,u)||(s=dd(n.dom,e,u),!s))return null}if(Se)for(let u=s;r&&u;u=Xn(u))u.draggable&&(r=void 0);if(s=Ok(s,e),r){if(ze&&D(r)&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let c=r.childNodes[i],f;c.nodeName=="IMG"&&(f=c.getBoundingClientRect()).right<=e.left&&f.bottom>e.top&&i++}let u;Bo&&i&&D(r)&&D(u=r.childNodes[i-1])&&u.contentEditable=="false"&&u.getBoundingClientRect().top>=e.top&&i--,r==n.dom&&i==r.childNodes.length-1&&D(r.lastChild)&&e.top>r.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(i==0||!D(r)||r.childNodes[i-1].nodeName!="BR")&&(l=Ak(n,r,i,e))}l==null&&(l=Tk(n,s,e));let a=n.docView.nearestDesc(s,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function _l(n){return n.top<n.bottom||n.left<n.right}function Lt(n,e){let t=n.getClientRects();if(t.length){let r=t[e<0?0:t.length-1];if(_l(r))return r}return Array.prototype.find.call(t,_l)||n.getBoundingClientRect()}var Dk=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function pd(n,e,t){let{node:r,offset:i,atom:o}=n.docView.domFromPos(e,t<0?-1:1),s=Bo||ze;if(oe(r))if(s&&(Dk.test(r.nodeValue)||(t<0?!i:i==r.nodeValue.length))){let a=Lt(kt(r,i,i),t);if(ze&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let u=Lt(kt(r,i-1,i-1),-1);if(u.top==a.top){let c=Lt(kt(r,i,i+1),-1);if(c.top!=a.top)return Xr(c,c.left<u.left)}}return a}else{let a=i,u=i,c=t<0?1:-1;return t<0&&!i?(u++,c=-1):t>=0&&i==r.nodeValue.length?(a--,c=1):t<0?a--:u++,Xr(Lt(kt(r,a,u),c),c<0)}if(!n.state.doc.resolve(e-(o||0)).parent.inlineContent){if(o==null&&i&&(t<0||i==be(r))){let a=r.childNodes[i-1];if(D(a))return vl(a.getBoundingClientRect(),!1)}if(o==null&&i<be(r)){let a=r.childNodes[i];if(D(a))return vl(a.getBoundingClientRect(),!0)}return vl(r.getBoundingClientRect(),t>=0)}if(o==null&&i&&(t<0||i==be(r))){let a=r.childNodes[i-1],u=oe(a)?kt(a,be(a)-(s?0:1)):D(a)&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(u)return Xr(Lt(u,1),!1)}if(o==null&&i<be(r)){let a=r.childNodes[i];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let u=a?oe(a)?kt(a,0,s?0:1):D(a)?a:null:null;if(u)return Xr(Lt(u,-1),!0)}return Xr(Lt(oe(r)?kt(r):r,-t),t>=0)}function Xr(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function vl(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function md(n,e,t){let r=n.state,i=n.root.activeElement;r!=e&&n.updateState(e),i!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),i!=n.dom&&i&&i.focus()}}function Rk(n,e,t){let r=e.selection,i=t=="up"?r.$from:r.$to;return md(n,e,()=>{let{node:o}=n.docView.domFromPos(i.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(o,!0);if(!l)break;if(l.node.isBlock){o=l.contentDOM||l.dom;break}o=l.dom.parentNode}let s=pd(n,i.pos,1);for(let l=o.firstChild;l;l=l.nextSibling){let a;if(D(l))a=l.getClientRects();else if(oe(l))a=kt(l,0,l.nodeValue.length).getClientRects();else continue;for(let u=0;u<a.length;u++){let c=a[u];if(c.bottom>c.top+1&&(t=="up"?s.top-c.top>(c.bottom-s.top)*2:c.bottom-s.bottom>(s.bottom-c.top)*2))return!1}}return!0})}var Pk=/[\u0590-\u08ac]/;function Bk(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,o=!i,s=i==r.parent.content.size,l=n.domSelection();return l?!Pk.test(r.parent.textContent)||!l.modify?t=="left"||t=="backward"?o:s:md(n,e,()=>{let{focusNode:a,focusOffset:u,anchorNode:c,anchorOffset:f}=n.domSelectionRange(),d=l.caretBidiLevel;l.modify("move",t,"character");let h=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:p,focusOffset:m}=n.domSelectionRange(),k=p&&!pn(h,p)||a==p&&u==m;try{l.collapse(c,f),a&&(a!=c||u!=f)&&l.extend&&l.extend(a,u)}catch{}return d!=null&&(l.caretBidiLevel=d),k}):r.pos==r.start()||r.pos==r.end()}var Ph=null,Bh=null,Lh=!1;function Lk(n,e,t){return Ph==e&&Bh==t?Lh:(Ph=e,Bh=t,Lh=t=="up"||t=="down"?Rk(n,e,t):Bk(n,e,t))}var Ke=0,zh=1,ln=2,Ze=3,mn=class{constructor(e,t,r,i){this.parent=e,this.children=t,this.dom=r,this.contentDOM=i,this.dirty=Ke,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){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,r=this.posAtStart;;t++){let i=this.children[t];if(i==e)return r;r+=i.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,r){if(this.contentDOM&&pn(this.contentDOM,e))if(r<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>de(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM)){let o=e.compareDocumentPosition(this.contentDOM);o&16?i=t>Array.from(e.childNodes).findIndex(s=>s.contains(this.contentDOM)):i=!(o&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??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,i=e;i;i=i.parentNode){let o=this.getDesc(i),s;if(o&&(!t||o.node))if(r&&(s=o.nodeDOM)&&!(D(s)?pn(s,e):s==e))r=!1;else return o}}getDesc(e){let t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let i=e;i;i=i.parentNode){let o=this.getDesc(i);if(o)return o.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;t<this.children.length;t++){let i=this.children[t],o=r+i.size;if(r==e&&o!=r){for(;!i.border&&i.children.length;)for(let s=0;s<i.children.length;s++){let l=i.children[s];if(l.size){i=l;break}}return i}if(e<o)return i.descAt(e-r-i.border);r=o}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,i=0;for(let o=0;r<this.children.length;r++){let s=this.children[r],l=o+s.size;if(l>e){i=e-o;break}o=l}if(i)return this.children[r].domFromPos(i-this.children[r].border,t);for(;r>0;r--){let o=this.children[r-1];if(o.size||!(o instanceof Io||o instanceof Mo&&o.side>=0))break}if(t<=0){let o,s=!0;for(;o=r?this.children[r-1]:null,!(!o||o.dom.parentNode==this.contentDOM);r--,s=!1);return o&&t&&s&&!o.border&&!o.domAtom?o.domFromPos(o.size,t):{node:this.contentDOM,offset:o?de(o.dom)+1:0}}else{let o,s=!0;for(;o=r<this.children.length?this.children[r]:null,!(!o||o.dom.parentNode==this.contentDOM);r++,s=!1);return o&&s&&!o.border&&!o.domAtom?o.domFromPos(0,t):{node:this.contentDOM,offset:o?de(o.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,r=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=r,l=0;;l++){let a=this.children[l],u=s+a.size;if(i==-1&&e<=u){let c=s+a.border;if(e>=c&&t<=u-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,c);e=s;for(let f=l;f>0;f--){let d=this.children[f-1];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(1)){i=de(d.dom)+1;break}e-=d.size}i==-1&&(i=0)}if(i>-1&&(u>t||l==this.children.length-1)){t=u;for(let c=l+1;c<this.children.length;c++){let f=this.children[c];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(-1)){o=de(f.dom);break}t+=f.size}o==-1&&(o=this.contentDOM.childNodes.length);break}s=u}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:r}=this.domFromPos(e,0);if(!D(t)||r==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[r]}setSelection(e,t,r,i=!1){let o=Math.min(e,t),s=Math.max(e,t);for(let h=0,p=0;h<this.children.length;h++){let m=this.children[h],k=p+m.size;if(o>p&&s<k)return m.setSelection(e-p-m.border,t-p-m.border,r,i);p=k}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),u=r.root.getSelection(),c=r.domSelectionRange(),f=!1;if((ze||Se)&&e==t){let{node:h,offset:p}=l;if(oe(h)){if(f=!!(p&&h.nodeValue[p-1]==`
|
|
44
|
+
`),f&&p==h.nodeValue.length)for(let m=h,k;m;m=m.parentNode){if(k=m.nextSibling){k.nodeName=="BR"&&(l=a={node:k.parentNode,offset:de(k)+1});break}let x=m.pmViewDesc;if(x&&x.node&&x.node.isBlock)break}}else{let m=h.childNodes[p-1];f=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(ze&&c.focusNode&&c.focusNode!=a.node&&D(c.focusNode)){let h=c.focusNode.childNodes[c.focusOffset];h&&h.contentEditable=="false"&&(i=!0)}if(!(i||f&&Se)&&dn(l.node,l.offset,c.anchorNode,c.anchorOffset)&&dn(a.node,a.offset,c.focusNode,c.focusOffset))return;let d=!1;if((u.extend||e==t)&&!(f&&ze)){u.collapse(l.node,l.offset);try{e!=t&&u.extend(a.node,a.offset),d=!0}catch{}}if(!d){if(e>t){let p=l;l=a,a=p}let h=document.createRange();h.setEnd(a.node,a.offset),h.setStart(l.node,l.offset),u.removeAllRanges(),u.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let r=0,i=0;i<this.children.length;i++){let o=this.children[i],s=r+o.size;if(r==s?e<=s&&t>=r:e<s&&t>r){let l=r+o.border,a=s-o.border;if(e>=l&&t<=a){this.dirty=e==r||t==s?ln:zh,e==l&&t==a&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=Ze:o.markDirty(e-l,t-l);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?ln:Ze}r=s}this.dirty=ln}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?ln:zh;t.dirty<r&&(t.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}},Mo=class extends mn{constructor(e,t,r,i){let o,s=t.type.toDOM;if(typeof s=="function"&&(s=s(r,()=>{if(!o)return i;if(o.parent)return o.parent.posBeforeChild(o)})),!t.type.spec.raw){let l=D(s)?s:document.createElement("span");l!=s&&(l.appendChild(s),s=l),l.hasAttribute("contenteditable")||(l.contentEditable="false"),l.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=t,this.widget=t,o=this}matchesWidget(e){return this.dirty==Ke&&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}},Vl=class extends mn{constructor(e,t,r,i){super(e,[],t,null),this.textDOM=r,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}},un=class n extends mn{constructor(e,t,r,i,o){super(e,[],r,i),this.mark=t,this.spec=o}static create(e,t,r,i){let o=i.nodeViews[t.type.name],s=o&&o(t,i,r);return(!s||!s.dom)&&(s=Rt.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new n(e,t,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.dirty&Ze||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Ze&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Ke){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Ke}}slice(e,t,r){let i=n.create(this.parent,this.mark,!0,r),o=this.children,s=this.size;t<s&&(o=Wl(o,t,s,r)),e>0&&(o=Wl(o,0,e,r));for(let l=0;l<o.length;l++)o[l].parent=i;return i.children=o,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},_t=class n extends mn{constructor(e,t,r,i,o,s,l){super(e,[],o,s),this.node=t,this.outerDeco=r,this.innerDeco=i,this.nodeDOM=l}static create(e,t,r,i,o,s){let l=o.nodeViews[t.type.name],a,u=l&&l(t,o,()=>{if(!a)return s;if(a.parent)return a.parent.posBeforeChild(a)},r,i),c=u&&u.dom,f=u&&u.contentDOM;if(t.isText){if(!c)c=document.createTextNode(t.text);else if(!oe(c))throw new RangeError("Text must be rendered as a DOM text node")}else c||({dom:c,contentDOM:f}=Rt.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!f&&!t.isText&&c.nodeName!="BR"&&(c.hasAttribute("contenteditable")||(c.contentEditable="false"),t.type.spec.draggable&&(c.draggable=!0));let d=c;return c=xd(c,r,t),u?a=new $l(e,t,r,i,c,f||null,d,u):t.isText?new No(e,t,r,i,c,d):new n(e,t,r,i,c,f||null,d)}parseRule(e){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(t.preserveWhitespace="full"),!this.contentDOM)t.getContent=()=>this.node.content;else if(!this.contentLost)t.contentElement=this.contentDOM;else{for(let r=this.children.length-1;r>=0;r--){let i=this.children[r];if(this.dom.contains(i.dom.parentNode)){t.contentElement=i.dom.parentNode;break}}if(!t.contentElement){let r=e&&e.find(i=>D(i)&&e.indexOf(i.parentNode)<0&&this.dom.contains(i));r?t.contentElement=r:t.getContent=()=>M.empty}}return t}matchesNode(e,t,r){return this.dirty==Ke&&e.eq(this.node)&&Eo(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,i=t,o=e.composing?this.localCompositionInfo(e,t):null,s=o&&o.pos>-1?o:null,l=o&&o.pos<0,a=new ql(this,s&&s.node,e),u=this.node.inlineContent,c=u&&this.node.isBlock;Vk(this.node,this.innerDeco,(f,d,h)=>{f.spec.marks?a.syncToMarks(f.spec.marks,r,e,d):f.type.side>=0&&!h&&a.syncToMarks(d==this.node.childCount?W.none:this.node.child(d).marks,r,e,d),a.placeWidget(f,e,i)},(f,d,h,p)=>{a.syncToMarks(f.marks,r,e,p),c&&f.isAtom&&!f.isText&&a.addHackNode("IMG",a.top);let m;a.findNodeMatch(f,d,h,p)||l&&e.state.selection.from>i&&e.state.selection.to<i+f.nodeSize&&(m=a.findIndexWithChild(o.node))>-1&&a.updateNodeAt(f,d,h,m,e)||a.updateNextNode(f,d,h,e,p,i)||a.addNode(f,d,h,e,i),i+=f.nodeSize,u&&(c=f.isAtom&&!f.isText)}),a.syncToMarks([],r,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==ln)&&(s&&this.protectLocalComposition(e,s),gd(this.contentDOM,this.children,e),Zn&&$k(this.dom))}localCompositionInfo(e,t){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof H)||r<t||i>t+this.node.content.size)return null;let o=e.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let s=o.nodeValue,l=jk(this.node.content,s,r-t,i-t);return l<0?null:{node:o,pos:l,text:s}}else return{node:o,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:i}){if(this.getDesc(t))return;let o=t;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let s=new Vl(this,o,t,i);e.input.compositionNodes.push(s),this.children=Wl(this.children,r,r+i.length,e,s)}update(e,t,r,i){return this.dirty==Ze||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,i),!0)}updateInner(e,t,r,i){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=Ke}updateOuterDeco(e){if(Eo(e,this.outerDeco))return;let t=!D(this.nodeDOM),r=this.dom;this.dom=yd(this.dom,this.nodeDOM,jl(this.outerDeco,this.node,t),jl(e,this.node,t)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){D(this.nodeDOM)&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){D(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 Fh(n,e,t,r,i){xd(r,e,n);let o=new _t(void 0,n,e,t,r,r,r);return o.contentDOM&&o.updateChildren(i,0),o}var No=class n extends _t{constructor(e,t,r,i,o,s){super(e,t,r,i,o,null,s)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,i){return this.dirty==Ze||this.dirty!=Ke&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Ke||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=Ke,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,r){let i=this.node.cut(e,t),o=document.createTextNode(i.text);return new n(this.parent,i,this.outerDeco,this.innerDeco,o,o)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=Ze)}get domAtom(){return!1}isText(e){return this.node.text==e}},Io=class extends mn{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Ke&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}},$l=class extends _t{constructor(e,t,r,i,o,s,l,a){super(e,t,r,i,o,s,l),this.spec=a}update(e,t,r,i){if(this.dirty==Ze)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let o=this.spec.update(e,t,r);return o&&this.updateInner(e,t,r,i),o}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,r,i){this.spec.setSelection?this.spec.setSelection(e,t,r.root):super.setSelection(e,t,r,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}};function gd(n,e,t){let r=n.firstChild,i=!1;for(let o=0;o<e.length;o++){let s=e[o],l=s.dom;if(l.parentNode==n){for(;l!=r;)r=_h(r),i=!0;r=r.nextSibling}else i=!0,n.insertBefore(l,r);if(s instanceof un){let a=r?r.previousSibling:n.lastChild;gd(s.contentDOM,s.children,t),r=a?a.nextSibling:n.firstChild}}for(;r;)r=_h(r),i=!0;i&&t.trackWrites==n&&(t.trackWrites=null)}var ei=function(n){n&&(this.nodeName=n)};ei.prototype=Object.create(null);var an=[new ei];function jl(n,e,t){if(n.length==0)return an;let r=t?an[0]:new ei,i=[r];for(let o=0;o<n.length;o++){let s=n[o].type.attrs;if(s){s.nodeName&&i.push(r=new ei(s.nodeName));for(let l in s){let a=s[l];a!=null&&(t&&i.length==1&&i.push(r=new ei(e.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+a:l=="style"?r.style=(r.style?r.style+";":"")+a:l!="nodeName"&&(r[l]=a))}}}return i}function yd(n,e,t,r){if(t==an&&r==an)return e;let i=e;for(let o=0;o<r.length;o++){let s=r[o],l=t[o];if(o){let a;l&&l.nodeName==s.nodeName&&i!=n&&(a=i.parentNode)&&a.nodeName.toLowerCase()==s.nodeName||(a=document.createElement(s.nodeName),a.pmIsDeco=!0,a.appendChild(i),l=an[0]),i=a}zk(i,l||an[0],s)}return i}function zk(n,e,t){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in t)&&n.removeAttribute(r);for(let r in t)r!="class"&&r!="style"&&r!="nodeName"&&t[r]!=e[r]&&n.setAttribute(r,t[r]);if(e.class!=t.class){let r=e.class?e.class.split(" ").filter(Boolean):[],i=t.class?t.class.split(" ").filter(Boolean):[];for(let o=0;o<r.length;o++)i.indexOf(r[o])==-1&&n.classList.remove(r[o]);for(let o=0;o<i.length;o++)r.indexOf(i[o])==-1&&n.classList.add(i[o]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=r.exec(e.style);)n.style.removeProperty(i[1])}t.style&&(n.style.cssText+=t.style)}}function xd(n,e,t){return yd(n,n,an,jl(e,t,!D(n)))}function Eo(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].type.eq(e[t].type))return!1;return!0}function _h(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}var ql=class{constructor(e,t,r){this.lock=t,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Fk(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let r=e;r<t;r++)this.top.children[r].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,r,i){let o=0,s=this.stack.length>>1,l=Math.min(s,e.length);for(;o<l&&(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=Ke,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let a=-1,u=this.top.children.length;i<this.preMatch.index&&(u=Math.min(this.index+3,u));for(let c=this.index;c<u;c++){let f=this.top.children[c];if(f.matchesMark(e[s])&&!this.isLocked(f.dom)){a=c;break}}if(a<0&&this.index<this.top.children.length){let c=this.top.children[this.index];c instanceof un&&c.dirty!=Ze&&c.mark.type==e[s].type&&c.spec.update&&!this.isLocked(c.dom)&&c.spec.update(e[s])&&(c.mark=e[s],a=this.index,this.changed=!0)}if(a>-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{let c=un.create(this.top,e[s],t,r);this.top.children.splice(this.index,0,c),this.top=c,this.changed=!0}this.index=0,s++}}findNodeMatch(e,t,r,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,r))o=this.top.children.indexOf(s,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let u=this.top.children[l];if(u.matchesNode(e,t,r)&&!this.preMatch.matched.has(u)){o=l;break}}return o<0?!1:(this.destroyBetween(this.index,o),this.index++,!0)}updateNodeAt(e,t,r,i,o){let s=this.top.children[i];return s.dirty==Ze&&s.dom==s.contentDOM&&(s.dirty=ln),s.update(e,t,r,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 r=e.pmViewDesc;if(r){for(let i=this.index;i<this.top.children.length;i++)if(this.top.children[i]==r)return i}return-1}e=t}}updateNextNode(e,t,r,i,o,s){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof _t){let u=this.preMatch.matched.get(a);if(u!=null&&u!=o)return!1;let c=a.dom,f,d=this.isLocked(c)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=Ze&&Eo(t,a.outerDeco));if(!d&&a.update(e,t,r,i))return this.destroyBetween(this.index,l),a.dom!=c&&(this.changed=!0),this.index++,!0;if(!d&&(f=this.recreateWrapper(a,e,t,r,i,s)))return this.destroyBetween(this.index,l),this.top.children[this.index]=f,f.contentDOM&&(f.dirty=ln,f.updateChildren(i,s+1),f.dirty=Ke),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,r,i,o,s){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Eo(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let l=_t.create(this.top,t,r,i,o,s);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,t,r,i,o){let s=_t.create(this.top,e,t,r,i,o);s.contentDOM&&s.updateChildren(i,o+1),this.top.children.splice(this.index++,0,s),this.changed=!0}placeWidget(e,t,r){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(i&&i.matchesWidget(e)&&(e==i.widget||!i.widget.type.toDOM.parentNode))this.index++;else{let o=new Mo(this.top,e,t,r);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 un;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof No)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Se||pe)&&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 r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let i=new Io(this.top,[],r,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||D(e)&&e.contains(this.lock.parentNode))}};function Fk(n,e){let t=e,r=t.children.length,i=n.childCount,o=new Map,s=[];e:for(;i>0;){let l;for(;;)if(r){let u=t.children[r-1];if(u instanceof un)t=u,r=u.children.length;else{l=u,r--;break}}else{if(t==e)break e;r=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=n.child(i-1))break;--i,o.set(l,i),s.push(l)}}return{index:i,matched:o,matches:s.reverse()}}function _k(n,e){return n.type.side-e.type.side}function Vk(n,e,t,r){let i=e.locals(n),o=0;if(i.length==0){for(let u=0;u<n.childCount;u++){let c=n.child(u);r(c,i,e.forChild(o,c),u),o+=c.nodeSize}return}let s=0,l=[],a=null;for(let u=0;;){let c,f;for(;s<i.length&&i[s].to==o;){let k=i[s++];k.widget&&(c?(f||(f=[c])).push(k):c=k)}if(c)if(f){f.sort(_k);for(let k=0;k<f.length;k++)t(f[k],u,!!a)}else t(c,u,!!a);let d,h;if(a)h=-1,d=a,a=null;else if(u<n.childCount)h=u,d=n.child(u++);else break;for(let k=0;k<l.length;k++)l[k].to<=o&&l.splice(k--,1);for(;s<i.length&&i[s].from<=o&&i[s].to>o;)l.push(i[s++]);let p=o+d.nodeSize;if(d.isText){let k=p;s<i.length&&i[s].from<k&&(k=i[s].from);for(let x=0;x<l.length;x++)l[x].to<k&&(k=l[x].to);k<p&&(a=d.cut(k-o),d=d.cut(0,k-o),p=k,h=-1)}else for(;s<i.length&&i[s].to<p;)s++;let m=d.isInline&&!d.isLeaf?l.filter(k=>!k.inline):l.slice();r(d,m,e.forChild(o,d),h),o=p}}function $k(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function jk(n,e,t,r){for(let i=0,o=0;i<n.childCount&&o<=r;){let s=n.child(i++),l=o;if(o+=s.nodeSize,!s.isText)continue;let a=s.text;for(;i<n.childCount;){let u=n.child(i++);if(o+=u.nodeSize,!u.isText)break;a+=u.text}if(o>=t){if(o>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let u=l<r?a.lastIndexOf(e,r-l-1):-1;if(u>=0&&u+e.length+l>=t)return l+u;if(t==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function Wl(n,e,t,r,i){let o=[];for(let s=0,l=0;s<n.length;s++){let a=n[s],u=l,c=l+=a.size;u>=t||c<=e?o.push(a):(u<e&&o.push(a.slice(0,e-u,r)),i&&(o.push(i),i=void 0),c>t&&o.push(a.slice(t-u,a.size,r)))}return o}function na(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let i=n.docView.nearestDesc(t.focusNode),o=i&&i.size==0,s=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(s<0)return null;let l=r.resolve(s),a,u;if(Po(t)){for(a=s;i&&!i.node;)i=i.parent;if(i&&i.node.isAtom&&B.isSelectable(i.node)&&i.parent&&!(i.node.isInline&&xk(t.focusNode,t.focusOffset,i.dom))){let f=i.posBefore;u=new B(s==f?l:r.resolve(f))}else if(ze&&e=="key"&&s>n.state.selection.to&&D(t.focusNode)&&t.focusOffset==t.focusNode.childNodes.length&&i&&i.posAtStart>n.state.selection.to)for(let f=t.focusNode;;f=f.parentNode){if(getComputedStyle(f).overflow!="visible"){u=j.findFrom(r.resolve(i.posAtStart),1);break}if(f==i.dom||f.nextSibling||!f.parentNode||!D(f.parentNode))break}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let f=s,d=s;for(let h=0;h<t.rangeCount;h++){let p=t.getRangeAt(h);f=Math.min(f,n.docView.posFromDOM(p.startContainer,p.startOffset,1)),d=Math.max(d,n.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(f<0)return null;[a,s]=d==n.state.selection.anchor?[d,f]:[f,d],l=r.resolve(s)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let c=r.resolve(a);if(!u){let f=e=="pointer"||n.state.selection.head<l.pos&&!o?1:-1;u=ra(n,c,l,f)}return u}function kd(n){return n.editable?n.hasFocus():Sd(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function wt(n,e=!1){let t=n.state.selection;if(bd(n,t),!kd(n))return;let r=n.input.mouseDown;if(!e&&pe&&r){let i=n.domSelectionRange(),o=n.domObserver.currentSelection;if(i.anchorNode&&o.anchorNode&&dn(i.anchorNode,i.anchorOffset,o.anchorNode,o.anchorOffset)&&r.delaySelUpdate()){n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)Wk(n);else{let{anchor:i,head:o}=t,s,l;Vh&&!(t instanceof H)&&(t.$from.parent.inlineContent||(s=$h(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(l=$h(n,t.to))),n.docView.setSelection(i,o,n,e),Vh&&(s&&jh(s),l&&jh(l)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&qk(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}var Vh=Se||pe&&ad<63;function $h(n,e){let{node:t,offset:r}=n.docView.domFromPos(e,0),i=r<t.childNodes.length?t.childNodes[r]:null,o=r?t.childNodes[r-1]:null;if(Se&&i&&i.contentEditable=="false")return Dl(i);if((!i||i.contentEditable=="false")&&(!o||o.contentEditable=="false")){if(i)return Dl(i);if(o)return Dl(o)}}function Dl(n){return n.contentEditable="true",Se&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function jh(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function qk(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),r=t.anchorNode,i=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=r||t.anchorOffset!=i)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!kd(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function Wk(n){let e=n.domSelection();if(!e)return;let t=n.cursorWrapper.dom,r=t.nodeName=="IMG";r?e.collapse(t.parentNode,de(t)+1):e.collapse(t,0),!r&&!n.state.selection.visible&&ve&&Ft<=11&&(t.disabled=!0,t.disabled=!1)}function bd(n,e){if(e instanceof B){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(qh(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else qh(n)}function qh(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function ra(n,e,t,r){return n.someProp("createSelectionBetween",i=>i(n,e,t))||H.between(e,t,r)}function Wh(n){return n.editable&&!n.hasFocus()?!1:Sd(n)}function Sd(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return pn(n.dom,e.anchorNode)&&(n.editable||pn(n.dom,e.focusNode))}catch{return!1}}function Hk(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return dn(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Hl(n,e){let{$anchor:t,$head:r}=n.selection,i=e>0?t.max(r):t.min(r),o=i.parent.inlineContent?i.depth?n.doc.resolve(e>0?i.after():i.before()):null:i;return o&&j.findFrom(o,e)}function zt(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function Hh(n,e,t){let r=n.state.selection;if(r instanceof H)if(t.indexOf("s")>-1){let{$head:i}=r,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let s=n.state.doc.resolve(i.pos+o.nodeSize*(e<0?-1:1));return zt(n,new H(r.$anchor,s))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let i=Hl(n.state,e);return i&&i instanceof B?zt(n,i):!1}else if(!He||t.indexOf("m")<0){let i=r.$head,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,s;if(!o||o.isText)return!1;let l=e<0?i.pos-o.nodeSize:i.pos;return o.isAtom||(s=n.docView.descAt(l))&&!s.contentDOM?B.isSelectable(o)?zt(n,new B(e<0?n.state.doc.resolve(i.pos-o.nodeSize):i)):zt(n,new H(n.state.doc.resolve(e<0?l:l+o.nodeSize))):!1}}else return!1;else{if(r instanceof B&&r.node.isInline)return zt(n,new H(e>0?r.$to:r.$from));{let i=Hl(n.state,e);return i?zt(n,i):!1}}}function ti(n,e){let t=n.pmViewDesc;return t?t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR"):D(n)&&n.contentEditable=="false"}function Qn(n,e){return e<0?Kk(n):Uk(n)}function Kk(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i,o,s=!1;for(ze&&D(t)&&r<be(t)&&ti(t.childNodes[r],-1)&&(s=!0);;)if(r>0){if(!D(t))break;let l=t.childNodes[r-1];if(ti(l,-1))i=t,o=--r;else if(oe(l))t=l,r=t.nodeValue.length;else break}else{if(wd(t))break;{let l=t.previousSibling;for(;l&&ti(l,-1);)i=t.parentNode,o=de(l),l=l.previousSibling;if(l)t=l,r=be(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}s?Kl(n,t,r):i&&Kl(n,i,o)}function Uk(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i=be(t),o,s;for(;;)if(r<i){if(!D(t))break;let l=t.childNodes[r];if(ti(l,1))o=t,s=++r;else break}else{if(wd(t))break;{let l=t.nextSibling;for(;l&&ti(l,1);)o=l.parentNode,s=de(l)+1,l=l.nextSibling;if(l)t=l,r=0,i=be(t);else{if(t=t.parentNode,t==n.dom)break;r=i=0}}}o&&Kl(n,o,s)}function wd(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function Jk(n,e){for(;n&&e==n.childNodes.length&&!li(n);)e=de(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(oe(t))return t;if(D(t)&&t.contentEditable=="false")break;n=t,e=0}}function Gk(n,e){for(;n&&!e&&!li(n);)e=de(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(oe(t))return t;if(D(t)&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function Kl(n,e,t){if(!oe(e)){let s,l;(l=Jk(e,t))?(e=l,t=0):(s=Gk(e,t))&&(e=s,t=s.nodeValue.length)}let r=n.domSelection(),i=n.domSelectionRange();if(!r)return;Po(i)?r.collapse(e,t):r.extend&&(r.collapse(i.anchorNode,i.anchorOffset),r.extend(e,t)),n.domObserver.setCurSelection();let{state:o}=n;setTimeout(()=>{n.state==o&&wt(n)},50)}function Kh(n,e){let t=n.state.doc.resolve(e);if(!(pe||ud)&&t.parent.inlineContent){let o=n.coordsAtPos(e);if(e>t.start()){let s=n.coordsAtPos(e-1),l=(s.top+s.bottom)/2;if(l>o.top&&l<o.bottom&&Math.abs(s.left-o.left)>1)return s.left<o.left?"ltr":"rtl"}if(e<t.end()){let s=n.coordsAtPos(e+1),l=(s.top+s.bottom)/2;if(l>o.top&&l<o.bottom&&Math.abs(s.left-o.left)>1)return s.left>o.left?"ltr":"rtl"}}let r=n.dom;for(let o=t.depth;o>0;o--)if(t.node(o).isBlock){r=n.nodeDOM(t.before(o))||r;break}return getComputedStyle(r).direction=="rtl"?"rtl":"ltr"}function Uh(n,e,t){let r=n.state.selection;if(r instanceof H&&!r.empty||t.indexOf("s")>-1||He&&t.indexOf("m")>-1)return!1;let{$from:i,$to:o}=r;if(!i.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let s=Hl(n.state,e);if(s&&s instanceof B)return zt(n,s)}if(!i.parent.inlineContent){let s=e<0?i:o,l=r instanceof Le?j.near(s,e):j.findFrom(s,e);return l?zt(n,l):!1}return!1}function Jh(n,e){if(!(n.state.selection instanceof H))return!0;let{$head:t,$anchor:r,empty:i}=n.state.selection;if(!t.sameParent(r))return!0;if(!i)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let o=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(o&&!o.isText){let s=n.state.tr;return e<0?s.delete(t.pos-o.nodeSize,t.pos):s.delete(t.pos,t.pos+o.nodeSize),n.dispatch(s),!0}return!1}function Gh(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function Qk(n){if(!Se||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&D(e)&&t==0&&e.firstChild&&D(e.firstChild)&&e.firstChild.contentEditable=="false"){let r=e.firstChild;Gh(n,r,"true"),setTimeout(()=>Gh(n,r,"false"),20)}return!1}function Yk(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function Xk(n,e){let t=e.keyCode,r=Yk(e);if(t==8||He&&t==72&&r=="c")return Jh(n,-1)||Qn(n,-1);if(t==46&&!e.shiftKey||He&&t==68&&r=="c")return Jh(n,1)||Qn(n,1);if(t==13||t==27)return!0;if(t==37||He&&t==66&&r=="c"){let i=t==37?Kh(n,n.state.selection.from)=="ltr"?-1:1:-1;return Hh(n,i,r)||Qn(n,i)}else if(t==39||He&&t==70&&r=="c"){let i=t==39?Kh(n,n.state.selection.from)=="ltr"?1:-1:1;return Hh(n,i,r)||Qn(n,i)}else{if(t==38||He&&t==80&&r=="c")return Uh(n,-1,r)||Qn(n,-1);if(t==40||He&&t==78&&r=="c")return Qk(n)||Uh(n,1,r)||Qn(n,1);if(r==(He?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function ia(n,e){n.someProp("transformCopied",h=>{e=h(e,n)});let t=[],{content:r,openStart:i,openEnd:o}=e;for(;i>1&&o>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,o--;let h=r.firstChild;t.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let s=n.someProp("clipboardSerializer")||Rt.fromSchema(n.state.schema),l=Od(),a=l.createElement("div");a.appendChild(s.serializeFragment(r,{document:l}));let u=a.firstChild,c,f=0;for(;u&&D(u)&&(c=Ed[u.nodeName.toLowerCase()]);){for(let h=c.length-1;h>=0;h--){let p=l.createElement(c[h]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),f++}u=a.firstChild}u&&D(u)&&u.setAttribute("data-pm-slice",`${i} ${o}${f?` -${f}`:""} ${JSON.stringify(t)}`);let d=n.someProp("clipboardTextSerializer",h=>h(e,n))||e.content.textBetween(0,e.content.size,`
|
|
45
|
+
|
|
46
|
+
`);return{dom:a,text:d,slice:e}}function Cd(n,e,t,r,i){let o=i.parent.type.spec.code,s,l;if(!t&&!e)return null;let a=!!e&&(r||o||!t);if(a){if(n.someProp("transformPastedText",d=>{e=d(e,o||r,n)}),o)return l=new E(M.from(n.state.schema.text(e.replace(/\r\n?/g,`
|
|
47
|
+
`))),0,0),n.someProp("transformPasted",d=>{l=d(l,n,!0)}),l;let f=n.someProp("clipboardTextParser",d=>d(e,i,r,n));if(f)l=f;else{let d=i.marks(),{schema:h}=n.state,p=Rt.fromSchema(h);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let k=s.appendChild(document.createElement("p"));m&&k.appendChild(p.serializeNode(h.text(m,d)))})}}else n.someProp("transformPastedHTML",f=>{t=f(t,n)}),s=nb(t),Bo&&rb(s);let u=s&&s.querySelector("[data-pm-slice]"),c=u&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(u.getAttribute("data-pm-slice")||"");if(c&&c[3])for(let f=+c[3];f>0;f--){let d=s.firstChild;for(;d&&!D(d);)d=d.nextSibling;if(!d)break;s=d}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||Dt.fromSchema(n.state.schema)).parseSlice(s,{preserveWhitespace:!!(a||c),context:i,ruleFromNode(d){return d.nodeName=="BR"&&!d.nextSibling&&d.parentNode&&!Zk.test(d.parentNode.nodeName)?{ignore:!0}:null}})),c)l=ib(Qh(l,+c[1],+c[2]),c[4]);else if(l=E.maxOpen(eb(l.content,i),!0),l.openStart||l.openEnd){let f=0,d=0;for(let h=l.content.firstChild;f<l.openStart&&!h.type.spec.isolating;f++,h=h.firstChild);for(let h=l.content.lastChild;d<l.openEnd&&!h.type.spec.isolating;d++,h=h.lastChild);l=Qh(l,f,d)}return n.someProp("transformPasted",f=>{l=f(l,n,a)}),l}var Zk=/^(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 eb(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let i=e.node(t).contentMatchAt(e.index(t)),o,s=[];if(n.forEach(l=>{if(!s)return;let a=i.findWrapping(l.type),u;if(!a)return s=null;if(u=s.length&&o.length&&Nd(a,o,l,s[s.length-1],0))s[s.length-1]=u;else{s.length&&(s[s.length-1]=Id(s[s.length-1],o.length));let c=Md(l,a);s.push(c),i=i.matchType(c.type),o=a}}),s)return M.from(s)}return n}function Md(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,M.from(n));return n}function Nd(n,e,t,r,i){if(i<n.length&&i<e.length&&n[i]==e[i]){let o=Nd(n,e,t,r.lastChild,i+1);if(o)return r.copy(r.content.replaceChild(r.childCount-1,o));if(r.contentMatchAt(r.childCount).matchType(i==n.length-1?t.type:n[i+1]))return r.copy(r.content.append(M.from(Md(t,n,i+1))))}}function Id(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,Id(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(M.empty,!0);return n.copy(t.append(r))}function Ul(n,e,t,r,i,o){let s=e<0?n.firstChild:n.lastChild,l=s.content;return n.childCount>1&&(o=0),i<r-1&&(l=Ul(l,e,t,r,i+1,o)),i>=t&&(l=e<0?s.contentMatchAt(0).fillBefore(l,o<=i).append(l):l.append(s.contentMatchAt(s.childCount).fillBefore(M.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,s.copy(l))}function Qh(n,e,t){return e<n.openStart&&(n=new E(Ul(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new E(Ul(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}var Ed={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 Od(){return document.implementation.createHTMLDocument("title")}var Zr=null;function tb(n){let e=window.trustedTypes;if(!e)return n;if(!Zr){if(Zr=e.defaultPolicy)try{return Zr.createHTML(n)}catch{}Zr=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})}return Zr.createHTML(n)}function nb(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Od(),r=t.body,i=/<([a-z][^>\s]+)/i.exec(n),o;if((o=i&&Ed[i[1].toLowerCase()])&&(n=o.map(s=>"<"+s+">").join("")+n+o.map(s=>"</"+s+">").reverse().join("")),r.innerHTML=tb(n),o)for(let s=0;s<o.length;s++)r=r.querySelector(o[s])||r;for(let s=0;s<t.styleSheets.length;s++){let l=t.styleSheets[s];for(let a=0;a<l.rules.length;a++){let u=l.rules[a];if(u instanceof CSSStyleRule){let c=r.querySelectorAll(u.selectorText);for(let f=0;f<c.length;f++)c[f].style.cssText+=u.style.cssText}}}return r}function rb(n){let e=n.querySelectorAll(pe?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let r=e[t];r.childNodes.length==1&&r.textContent=="\xA0"&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function ib(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:i,openStart:o,openEnd:s}=n;for(let l=r.length-2;l>=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;try{i=M.from(a.create(r[l+1],i))}catch{break}o++,s++}return new E(i,o,s)}var Ne={},Ie={},ob={touchstart:!0,touchmove:!0},Jl=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 sb(n){for(let e in Ne){let t=Ne[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{ab(n,r)&&!oa(n,r)&&(n.editable||!(r.type in Ie))&&t(n,r)},ob[e]?{passive:!0}:void 0)}Se&&n.dom.addEventListener("input",()=>null),Gl(n)}function St(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function lb(n){n.input.mouseDown&&n.input.mouseDown.done(),n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function Gl(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>oa(n,r))})}function oa(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function ab(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function ub(n,e){!oa(n,e)&&Ne[e.type]&&(n.editable||!(e.type in Ie))&&Ne[e.type](n,e)}Ie.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!vd(n)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(bt&&pe&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),Zn&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",i=>i(n,sn(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||Xk(n,t)?t.preventDefault():St(n,"key")};Ie.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};Ie.keypress=(n,e)=>{let t=e;if(vd(n)||!t.charCode||t.ctrlKey&&!t.altKey||He&&t.metaKey)return;if(n.someProp("handleKeyPress",i=>i(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof H)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(t.charCode),o=()=>n.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!n.someProp("handleTextInput",s=>s(n,r.$from.pos,r.$to.pos,i,o))&&n.dispatch(o()),t.preventDefault()}};function ai(n){return{left:n.clientX,top:n.clientY}}function cb(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function sa(n,e,t,r,i){if(r==-1)return!1;let o=n.state.doc.resolve(r);for(let s=o.depth+1;s>0;s--)if(n.someProp(e,l=>s>o.depth?l(n,t,o.nodeAfter,o.before(s),i,!0):l(n,t,o.node(s),o.before(s),i,!1)))return!0;return!1}function ui(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);r.setMeta("pointer",!0),n.dispatch(r)}function fb(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&B.isSelectable(r)?(ui(n,new B(t)),!0):!1}function hb(n,e){if(e==-1)return!1;let t=n.state.selection,r,i;t instanceof B&&(r=t.node);let o=n.state.doc.resolve(e);for(let s=o.depth+1;s>0;s--){let l=s>o.depth?o.nodeAfter:o.node(s);if(B.isSelectable(l)){r&&t.$from.depth>0&&s>=t.$from.depth&&o.before(t.$from.depth+1)==t.$from.pos?i=o.before(t.$from.depth):i=o.before(s);break}}return i!=null?(ui(n,B.create(n.state.doc,i)),!0):!1}function db(n,e,t,r,i){return sa(n,"handleClickOn",e,t,r)||n.someProp("handleClick",o=>o(n,e,r))||(i?hb(n,t):fb(n,t))}function pb(n,e,t,r){return sa(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",i=>i(n,e,r))}function mb(n,e,t,r){return sa(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",i=>i(n,e,r))||gb(n,t,r)}function gb(n,e,t){if(t.button!=0)return!1;let r=Td(n,e,!0),i=n.state.doc;return r?(ui(n,r),r instanceof H&&i.eq(n.state.doc)&&(n.input.mouseDown=new Yl(n,r)),!0):!1}function Td(n,e,t){let r=n.state.doc;if(e==-1)return r.inlineContent?H.create(r,0,r.content.size):null;let i=r.resolve(e);for(let o=i.depth+1;o>0;o--){let s=o>i.depth?i.nodeAfter:i.node(o),l=i.before(o);if(s.inlineContent)return H.create(r,l+1,l+1+s.content.size);if(t&&B.isSelectable(s))return B.create(r,l)}return null}function la(n){return To(n)}var Ad=He?"metaKey":"ctrlKey";Ne.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=la(n),i=Date.now(),o="singleClick";i-n.input.lastClick.time<500&&cb(t,n.input.lastClick)&&!t[Ad]&&n.input.lastClick.button==t.button&&(n.input.lastClick.type=="singleClick"?o="doubleClick":n.input.lastClick.type=="doubleClick"&&(o="tripleClick")),n.input.lastClick={time:i,x:t.clientX,y:t.clientY,type:o,button:t.button},n.input.mouseDown&&n.input.mouseDown.done();let s=n.posAtCoords(ai(t));s&&(o=="singleClick"?n.input.mouseDown=new Ql(n,s,t,!!r):(o=="doubleClick"?pb:mb)(n,s.pos,s.inside,t)?t.preventDefault():St(n,"pointer"))};var Oo=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}},Ql=class extends Oo{constructor(e,t,r,i){super(e),this.pos=t,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.startDoc=e.state.doc,this.selectNode=!!r[Ad],this.allowDefault=r.shiftKey;let o,s;if(t.inside>-1)o=e.state.doc.nodeAt(t.inside),s=t.inside;else{let c=e.state.doc.resolve(t.pos);o=c.parent,s=c.depth?c.before():0}let l=i?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&D(a.nodeDOM)?a.nodeDOM:null;let{selection:u}=e.state;r.button==0&&(o.type.spec.draggable&&o.type.spec.selectable!==!1||u instanceof B&&u.from<=s&&u.to>s)&&(this.mightDrag={node:o,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&ze&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),St(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||wt(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(ai(e))),this.updateAllowDefault(e),this.allowDefault||!t?St(this.view,"pointer"):db(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Se&&this.mightDrag&&!this.mightDrag.node.isAtom||pe&&!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)?(ui(this.view,j.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):St(this.view,"pointer")}move(e){this.updateAllowDefault(e),St(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}},Yl=class extends Oo{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(),St(this.view,"pointer");let t=this.view.posAtCoords(ai(e)),r=t&&Td(this.view,t.inside,!1);if(!r)return;let{doc:i}=this.view.state,o=this.startSelection,[s,l]=r.from<o.from?[o.to,r.from]:[o.from,r.to];ui(this.view,H.create(i,s,l))}};Ne.touchstart=n=>{n.input.lastTouch=Date.now(),la(n),St(n,"pointer")};Ne.touchmove=n=>{n.input.lastTouch=Date.now(),St(n,"pointer")};Ne.contextmenu=n=>la(n);function vd(n,e){return n.composing?!0:Se&&Math.abs(Date.now()-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}var yb=bt?5e3:-1;Ie.compositionstart=Ie.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof H&&e.selection.empty&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||pe&&ud&&xb(n)))n.markCursor=n.state.storedMarks||t.marks(),To(n,!0),n.markCursor=null;else if(To(n,!e.selection.empty),ze&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let i=r.focusNode,o=r.focusOffset;i&&D(i)&&o!=0;){let s=o<0?i.lastChild:i.childNodes[o-1];if(!s)break;if(oe(s)){let l=n.domSelection();l&&l.collapse(s,s.nodeValue.length);break}else i=s,o=-1}}n.input.composing=!0}Dd(n,yb)};function xb(n){let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(!e||!D(e)||t>=e.childNodes.length)return!1;let r=e.childNodes[t];return D(r)&&r.contentEditable=="false"}Ie.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Date.now(),n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.badSafariComposition?n.domObserver.forceFlush():n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,Dd(n,20))};function Dd(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>To(n),e))}function Rd(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Date.now());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function kb(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=gk(e.focusNode,e.focusOffset),r=yk(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let i=r.pmViewDesc,o=n.domObserver.lastChangedTextNode;if(t==o||r==o)return o;if(!i||!i.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let s=t.pmViewDesc;if(!(!s||!s.isText(t.nodeValue)))return r}}return t||r}function To(n,e=!1){if(!(bt&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Rd(n),e||n.docView&&n.docView.dirty){let t=na(n),r=n.state.selection;return t&&!t.eq(r)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function bb(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}var ni=ve&&Ft<15||Zn&&Sk<604;Ne.copy=Ie.cut=(n,e)=>{let t=e,r=n.state.selection,i=t.type=="cut";if(r.empty)return;let o=ni?null:t.clipboardData,s=r.content(),{dom:l,text:a}=ia(n,s);o?(t.preventDefault(),o.clearData(),o.setData("text/html",l.innerHTML),o.setData("text/plain",a)):bb(n,l),i&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Sb(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function wb(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?ri(n,r.value,null,i,e):ri(n,r.textContent,r.innerHTML,i,e)},50)}function ri(n,e,t,r,i){let o=Cd(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,i,o||E.empty)))return!0;if(!o)return!1;let s=Sb(o),l=s?n.state.tr.replaceSelectionWith(s,r):n.state.tr.replaceSelection(o);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Pd(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}Ie.paste=(n,e)=>{let t=e;if(n.composing&&!bt)return;let r=ni?null:t.clipboardData,i=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&ri(n,Pd(r),r.getData("text/html"),i,t)?t.preventDefault():wb(n,t)};var Ao=class{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}},Cb=He?"altKey":"ctrlKey";function Bd(n,e){let t;return n.someProp("dragCopies",r=>{t=t||r(e)}),t!=null?!t:!e[Cb]}Ne.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let i=n.state.selection,o=i.empty?null:n.posAtCoords(ai(t)),s;if(!(o&&o.pos>=i.from&&o.pos<=(i instanceof B?i.to-1:i.to))){if(r&&r.mightDrag)s=B.create(n.state.doc,r.mightDrag.pos);else if(t.target&&D(t.target)){let f=n.docView.nearestDesc(t.target,!0);f&&f.node.type.spec.draggable&&f!=n.docView&&(s=B.create(n.state.doc,f.posBefore))}}let l=(s||n.state.selection).content(),{dom:a,text:u,slice:c}=ia(n,l);(!t.dataTransfer.files.length||!pe||ad>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(ni?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",ni||t.dataTransfer.setData("text/plain",u),n.dragging=new Ao(c,Bd(n,t),s)};Ne.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};Ie.dragover=Ie.dragenter=(n,e)=>e.preventDefault();Ie.drop=(n,e)=>{try{Mb(n,e,n.dragging)}finally{n.dragging=null}};function Mb(n,e,t){if(!e.dataTransfer)return;let r=n.posAtCoords(ai(e));if(!r)return;let i=n.state.doc.resolve(r.pos),o=t&&t.slice;o?n.someProp("transformPasted",h=>{o=h(o,n,!1)}):o=Cd(n,Pd(e.dataTransfer),ni?null:e.dataTransfer.getData("text/html"),!1,i);let s=!!(t&&Bd(n,e));if(n.someProp("handleDrop",h=>h(n,e,o||E.empty,s))){e.preventDefault();return}if(!o)return;e.preventDefault();let l=o?Uf(n.state.doc,i.pos,o):i.pos;l==null&&(l=i.pos);let a=n.state.tr;if(s){let{node:h}=t;h?h.replace(a):a.deleteSelection()}let u=a.mapping.map(l),c=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,f=a.doc;if(c?a.replaceRangeWith(u,u,o.content.firstChild):a.replaceRange(u,u,o),a.doc.eq(f))return;let d=a.doc.resolve(u);if(c&&B.isSelectable(o.content.firstChild)&&d.nodeAfter&&d.nodeAfter.sameMarkup(o.content.firstChild))a.setSelection(new B(d));else{let h=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((p,m,k,x)=>h=x),a.setSelection(ra(n,d,a.doc.resolve(h)))}n.focus(),n.dispatch(a.setMeta("uiEvent","drop"))}Ne.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&wt(n)},20))};Ne.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)};Ne.beforeinput=(n,e)=>{if(bt&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",o=>o(n,sn(8,"Backspace")))))return;let{$cursor:i}=n.state.selection;i&&i.pos>0&&n.dispatch(n.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let n in Ie)Ne[n]=Ie[n];function ii(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}var oi=class{constructor(e){this.frag=e,this.index=0,this.off=0}nodeAt(e){for(;this.off<=e&&this.index<this.frag.childCount;){let t=this.frag.child(this.index);if(this.off==e)return t;this.off+=t.nodeSize,this.index++}return null}},vo=class n{constructor(e,t){this.toDOM=e,this.spec=t||fn,this.side=this.spec.side||0}map(e,t,r,i){let{pos:o,deleted:s}=e.mapResult(t.from+i,this.side<0?-1:1);return s?null:new et(o-r,o-r,this)}valid(){return!0}eq(e){return this==e||e instanceof n&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&ii(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},cn=class n{constructor(e,t){this.attrs=e,this.spec=t||fn}map(e,t,r,i){let o=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-r,s=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-r;return o>=s?null:new et(o,s,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof n&&ii(this.attrs,e.attrs)&&ii(this.spec,e.spec)}static is(e){return e.type instanceof n}destroy(){}},Xl=class n{constructor(e,t){this.attrs=e,this.spec=t||fn}map(e,t,r,i){let o=e.mapResult(t.from+i,1);if(o.deleted)return null;let s=e.mapResult(t.to+i,-1);return s.deleted||s.pos<=o.pos?null:new et(o.pos-r,s.pos-r,this)}valid(e,t,r){let i=r.nodeAt(t.from);return!!i&&!i.isText&&t.from+i.nodeSize==t.to}eq(e){return this==e||e instanceof n&&ii(this.attrs,e.attrs)&&ii(this.spec,e.spec)}destroy(){}},et=class n{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new n(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new n(e,e,new vo(t,r))}static inline(e,t,r,i){return new n(e,t,new cn(r,i))}static node(e,t,r,i){return new n(e,t,new Xl(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof cn}get widget(){return this.type instanceof vo}},Yn=[],fn={},Me=class n{constructor(e,t){this.local=e.length?e:Yn,this.children=t.length?t:Yn}static create(e,t){return t.length?Ro(t,e,0,fn):ke}find(e,t,r){let i=[];return this.findInner(e??0,t??1e9,i,0,r),i}findInner(e,t,r,i,o){for(let s=0;s<this.local.length;s++){let l=this.local[s];l.from<=t&&l.to>=e&&(!o||o(l.spec))&&r.push(l.copy(l.from+i,l.to+i))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<t&&this.children[s+1]>e){let l=this.children[s]+1;this.children[s+2].findInner(e-l,t-l,r,i+l,o)}}map(e,t,r){return this==ke||e.maps.length==0?this:this.mapInner(e,t,0,0,r||fn)}mapInner(e,t,r,i,o){let s;if(this.local.length){let l=new oi(t.content);for(let a=0;a<this.local.length;a++){let u=this.local[a].map(e,r,i);u&&u.type.valid(t,u,l)?(s||(s=[])).push(u):o.onRemove&&o.onRemove(this.local[a].spec)}}return this.children.length?Nb(this.children,s||[],e,t,r,i,o):s?new n(s.sort(hn),Yn):ke}add(e,t){return t.length?this==ke?n.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let i,o=0;e.forEach((l,a)=>{let u=a+r,c;if(c=zd(t,l,u)){for(i||(i=this.children.slice());o<i.length&&i[o]<a;)o+=3;i[o]==a?i[o+2]=i[o+2].addInner(l,c,u+1):i.splice(o,0,a,a+l.nodeSize,Ro(c,l,u+1,fn)),o+=3}});let s=Ld(o?Fd(t):t,-r);if(s.length){let l=new oi(e.content);for(let a=0;a<s.length;a++)s[a].type.valid(e,s[a],l)||s.splice(a--,1)}return new n(s.length?this.local.concat(s).sort(hn):this.local,i||this.children)}remove(e){return e.length==0||this==ke?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,i=this.local;for(let o=0;o<r.length;o+=3){let s,l=r[o]+t,a=r[o+1]+t;for(let c=0,f;c<e.length;c++)(f=e[c])&&f.from>l&&f.to<a&&(e[c]=null,(s||(s=[])).push(f));if(!s)continue;r==this.children&&(r=this.children.slice());let u=r[o+2].removeInner(s,l+1);u!=ke?r[o+2]=u:(r.splice(o,3),o-=3)}if(i.length){for(let o=0,s;o<e.length;o++)if(s=e[o])for(let l=0;l<i.length;l++)i[l].eq(s,t)&&(i==this.local&&(i=this.local.slice()),i.splice(l--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new n(i,r):ke}forChild(e,t){if(this==ke)return this;if(t.isLeaf)return n.empty;let r,i;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let o=e+1,s=o+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<s&&a.to>o&&a.type instanceof cn){let u=Math.max(o,a.from)-o,c=Math.min(s,a.to)-o;u<c&&(i||(i=[])).push(a.copy(u,c))}}if(i){let l=new n(i.sort(hn),Yn);return r?new Do([l,r]):l}return r||ke}eq(e){if(this==e)return!0;if(!(e instanceof n)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return aa(this.localsInner(e))}localsInner(e){if(this==ke)return Yn;if(e.inlineContent||!this.local.some(cn.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof cn||t.push(this.local[r]);return t}forEachSet(e){e(this)}};Me.empty=new Me([],[]);Me.removeOverlap=aa;var ke=Me.empty,Do=class n{constructor(e){this.members=e}map(e,t){let r=this.members.map(i=>i.map(e,t,fn));return n.from(r)}forChild(e,t){if(t.isLeaf)return Me.empty;let r=[];for(let i=0;i<this.members.length;i++){let o=this.members[i].forChild(e,t);o!=ke&&(o instanceof n?r=r.concat(o.members):r.push(o))}return n.from(r)}eq(e){if(!(e instanceof n)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,r=!0;for(let i=0;i<this.members.length;i++){let o=this.members[i].localsInner(e);if(o.length)if(!t)t=o;else{r&&(t=t.slice(),r=!1);for(let s=0;s<o.length;s++)t.push(o[s])}}return t?aa(r?t:t.sort(hn)):Yn}static from(e){switch(e.length){case 0:return ke;case 1:return e[0];default:return new n(e.every(t=>t instanceof Me)?e:e.reduce((t,r)=>t.concat(r instanceof Me?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function Nb(n,e,t,r,i,o,s){let l=n.slice();for(let u=0,c=o;u<t.maps.length;u++){let f=0;t.maps[u].forEach((d,h,p,m)=>{let k=m-p-(h-d);for(let x=0;x<l.length;x+=3){let O=l[x+1];if(O<0||d>O+c-f)continue;let C=l[x]+c-f;h>=C?l[x+1]=d<=C?-2:-1:d>=c&&k&&(l[x]+=k,l[x+1]+=k)}f+=k}),c=t.maps[u].map(c,-1)}let a=!1;for(let u=0;u<l.length;u+=3)if(l[u+1]<0){if(l[u+1]==-2){a=!0,l[u+1]=-1;continue}let c=t.map(n[u]+o),f=c-i;if(f<0||f>=r.content.size){a=!0;continue}let d=t.map(n[u+1]+o,-1),h=d-i,{index:p,offset:m}=r.content.findIndex(f),k=r.maybeChild(p);if(k&&m==f&&m+k.nodeSize==h){let x=l[u+2].mapInner(t,k,c+1,n[u]+o+1,s);x!=ke?(l[u]=f,l[u+1]=h,l[u+2]=x):(l[u+1]=-2,a=!0)}else a=!0}if(a){let u=Ib(l,n,e,t,i,o,s),c=Ro(u,r,0,s);e=c.local;for(let f=0;f<l.length;f+=3)l[f+1]<0&&(l.splice(f,3),f-=3);for(let f=0,d=0;f<c.children.length;f+=3){let h=c.children[f];for(;d<l.length&&l[d]<h;)d+=3;l.splice(d,0,c.children[f],c.children[f+1],c.children[f+2])}}return new Me(e.sort(hn),l)}function Ld(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let i=n[r];t.push(new et(i.from+e,i.to+e,i.type))}return t}function Ib(n,e,t,r,i,o,s){function l(a,u){for(let c=0;c<a.local.length;c++){let f=a.local[c].map(r,i,u);f?t.push(f):s.onRemove&&s.onRemove(a.local[c].spec)}for(let c=0;c<a.children.length;c+=3)l(a.children[c+2],a.children[c]+u+1)}for(let a=0;a<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+o+1);return t}function zd(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,i=null;for(let o=0,s;o<n.length;o++)(s=n[o])&&s.from>t&&s.to<r&&((i||(i=[])).push(s),n[o]=null);return i}function Fd(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function Ro(n,e,t,r){let i=[],o=!1;e.forEach((l,a)=>{let u=zd(n,l,a+t);if(u){o=!0;let c=Ro(u,l,t+a+1,r);c!=ke&&i.push(a,a+l.nodeSize,c)}});let s=Ld(o?Fd(n):n,-t).sort(hn);if(s.length){let l=new oi(e.content);for(let a=0;a<s.length;a++)s[a].type.valid(e,s[a],l)||(r.onRemove&&r.onRemove(s[a].spec),s.splice(a--,1))}return s.length||i.length?new Me(s,i):ke}function hn(n,e){return n.from-e.from||n.to-e.to}function aa(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let i=t+1;i<e.length;i++){let o=e[i];if(o.from==r.from){o.to!=r.to&&(e==n&&(e=n.slice()),e[i]=o.copy(o.from,r.to),Yh(e,i+1,o.copy(r.to,o.to)));continue}else{o.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,o.from),Yh(e,i,r.copy(o.from,r.to)));break}}}return e}function Yh(n,e,t){for(;e<n.length&&hn(t,n[e])>0;)e++;n.splice(e,0,t)}function Rl(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=ke&&e.push(r)}),n.cursorWrapper&&e.push(Me.create(n.state.doc,[n.cursorWrapper.deco])),Do.from(e)}var Eb={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Ob=ve&&Ft<=11,Zl=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}},ea=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Zl,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;i<r.length;i++)this.queue.push(r[i]);ve&&Ft<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():Se&&e.composing&&r.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),Ob&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,Eb)),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(Wh(this.view)){if(this.suppressingSelectionUpdates)return wt(this.view);if(ve&&Ft<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&dn(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,r;for(let o=e.focusNode;o;o=Xn(o))t.add(o);for(let o=e.anchorNode;o;o=Xn(o))if(t.has(o)){r=o;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:oe(r)?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let r,i=!1;!this.suppressingSelectionUpdates&&Wh(e)&&(r=e.domSelectionRange(),i=!this.currentSelection.eq(r)&&!this.ignoreSelectionChange(r));let o=-1,s=-1,l=!1,a=[];if(e.editable)for(let c=0;c<t.length;c++){let f=this.registerMutation(t[c],a);f&&(o=o<0?f.from:Math.min(f.from,o),s=s<0?f.to:Math.max(f.to,s),f.typeOver&&(l=!0))}if(a.some(c=>c.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46||pe&&(e.composing||e.input.compositionEndedAt>Date.now()-50)&&t.some(c=>c.type=="childList"&&c.removedNodes.length))){for(let c of a)if(c.nodeName=="BR"&&c.parentNode){let f=c.nextSibling;for(;f&&D(f);){if(f.contentEditable=="false"){c.parentNode.removeChild(c);break}f=f.firstChild}}}else if(ze&&a.length){let c=a.filter(f=>f.nodeName=="BR");if(c.length==2){let[f,d]=c;f.parentNode&&f.parentNode.parentNode==d.parentNode?d.remove():f.remove()}else{let{focusNode:f}=this.currentSelection;for(let d of c){let h=d.parentNode;h&&h.nodeName=="LI"&&(!f||vb(e,f)!=h)&&d.remove()}}}let u=null;o<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Po(r)&&(u=na(e))&&u.eq(j.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,wt(e),this.currentSelection.set(r),e.scrollToSelection()):(o>-1||i)&&(o>-1&&(e.docView.markDirty(o,s),Tb(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,Db(e,a)),this.handleDOMChange(o,s,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):r&&!this.currentSelection.eq(r)&&wt(e),r&&this.currentSelection.set(r))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let c=0;c<e.addedNodes.length;c++){let f=e.addedNodes[c];t.push(f),oe(f)&&(this.lastChangedTextNode=f)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let i=e.previousSibling,o=e.nextSibling;if(ve&&Ft<=11&&e.addedNodes.length)for(let c=0;c<e.addedNodes.length;c++){let{previousSibling:f,nextSibling:d}=e.addedNodes[c];(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(i=f),(!d||Array.prototype.indexOf.call(e.addedNodes,d)<0)&&(o=d)}let s=i&&i.parentNode==e.target?de(i)+1:0,l=r.localPosFromDOM(e.target,s,-1),a=o&&o.parentNode==e.target?de(o):e.target.childNodes.length,u=r.localPosFromDOM(e.target,a,1);return{from:l,to:u}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}},Xh=new WeakMap,Zh=!1;function Tb(n){if(!Xh.has(n)&&(Xh.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=ze,Zh)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."),Zh=!0}}function ed(n,e){let t=e.startContainer,r=e.startOffset,i=e.endContainer,o=e.endOffset,s=n.domAtPos(n.state.selection.anchor);return dn(s.node,s.offset,i,o)&&([t,r,i,o]=[i,o,t,r]),{anchorNode:t,anchorOffset:r,focusNode:i,focusOffset:o}}function Ab(n,e){if(e.getComposedRanges){let i=e.getComposedRanges(n.root)[0];if(i)return ed(n,i)}let t;function r(i){i.preventDefault(),i.stopImmediatePropagation(),t=i.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",r,!0),t?ed(n,t):null}function vb(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let r=n.docView.nearestDesc(t,!0);if(r&&r.node.isBlock)return t}return null}function Db(n,e){var t;let{focusNode:r,focusOffset:i}=n.domSelectionRange();for(let o of e)if(((t=o.parentNode)===null||t===void 0?void 0:t.nodeName)=="TR"){let s=o.nextSibling;for(;s&&s.nodeName!="TD"&&s.nodeName!="TH";)s=s.nextSibling;if(s){let l=s;for(;;){let a=l.firstChild;if(!a||!D(a)||a.contentEditable=="false"||/^(BR|IMG)$/.test(a.nodeName))break;l=a}l.insertBefore(o,l.firstChild),r==o&&n.domSelection().collapse(o,i)}else o.parentNode.removeChild(o)}}function Rb(n,e,t,r){let{node:i,fromOffset:o,toOffset:s,from:l,to:a}=n.docView.parseRange(e,t),u=n.domSelectionRange(),c,f=u.anchorNode;if(f&&pn(n.dom,f)&&(c=[{node:f,offset:u.anchorOffset}],Po(u)||c.push({node:u.focusNode,offset:u.focusOffset})),pe&&n.input.lastKeyCode===8)for(let x=s;x>o;x--){let O=i.childNodes[x-1],C=O.pmViewDesc;if(O.nodeName=="BR"&&!C){s=x;break}if(!C||C.size)break}let d=n.state.doc,h=n.someProp("domParser")||Dt.fromSchema(n.state.schema),p=d.resolve(l),m=null,k=h.parse(i,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:o,to:s,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:Pb(r),context:p});if(c&&c[0].pos!=null){let x=c[0].pos,O=c[1]&&c[1].pos;O==null&&(O=x),m={anchor:x+l,head:O+l}}return{doc:k,sel:m,from:l,to:a}}var Pb=n=>e=>{let t=e.pmViewDesc;if(t)return t.parseRule(n);if(e.nodeName=="BR"&&e.parentNode){if(Se&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let r=document.createElement("div");return r.appendChild(document.createElement("li")),{skip:r}}else if(e.parentNode.lastChild==e||Se&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName=="IMG"&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null},Bb=/^(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 Lb(n,e,t,r,i){let o=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let I=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,R=na(n,I);if(R&&!n.state.selection.eq(R)){if(pe&&bt&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",G=>G(n,sn(13,"Enter"))))return;let q=n.state.tr.setSelection(R);I=="pointer"?q.setMeta("pointer",!0):I=="key"&&q.scrollIntoView(),o&&q.setMeta("composition",o),n.dispatch(q)}return}let s=n.state.doc.resolve(e),l=s.sharedDepth(t);e=s.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,u=Rb(n,e,t,i),c=n.state.doc,f=c.slice(u.from,u.to),d,h;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(d=n.state.selection.to,h="end"):(d=n.state.selection.from,h="start"),n.input.lastKeyCode=null;let p=Vb(f.content,u.doc.content,u.from,d,h);if(p&&n.input.domChangeCount++,(Zn&&n.input.lastIOSEnter>Date.now()-225||bt)&&i.some(I=>D(I)&&!Bb.test(I.nodeName))&&(!p||p.endA>=p.endB)&&n.someProp("handleKeyDown",I=>I(n,sn(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!p)if(r&&a instanceof H&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.composing&&!(u.sel&&u.sel.anchor!=u.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(u.sel){let I=td(n,n.state.doc,u.sel);if(I&&!I.eq(n.state.selection)){let R=n.state.tr.setSelection(I);o&&R.setMeta("composition",o),n.dispatch(R)}}return}n.state.selection.from<n.state.selection.to&&p.start==p.endB&&n.state.selection instanceof H&&(p.start>n.state.selection.from&&p.start<=n.state.selection.from+2&&n.state.selection.from>=u.from?p.start=n.state.selection.from:p.endA<n.state.selection.to&&p.endA>=n.state.selection.to-2&&n.state.selection.to<=u.to&&(p.endB+=n.state.selection.to-p.endA,p.endA=n.state.selection.to)),ve&&Ft<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>u.from&&u.doc.textBetween(p.start-u.from-1,p.start-u.from+1)==" \xA0"&&(p.start--,p.endA--,p.endB--);let m=u.doc.resolveNoCache(p.start-u.from),k=u.doc.resolveNoCache(p.endB-u.from),x=c.resolve(p.start),O=m.sameParent(k)&&m.parent.inlineContent&&x.end()>=p.endA;if((Zn&&n.input.lastIOSEnter>Date.now()-225&&(!O||i.some(I=>I.nodeName=="DIV"||I.nodeName=="P"))||!O&&_b(u.doc,m.pos,k.pos))&&n.someProp("handleKeyDown",I=>I(n,sn(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>p.start&&(O?p.endA>p.start&&p.endB==p.start:Fb(c,p.start,p.endA,m,k))&&n.someProp("handleKeyDown",I=>I(n,sn(8,"Backspace")))){bt&&pe&&n.domObserver.suppressSelectionUpdates();return}pe&&p.endB==p.start&&(n.input.lastChromeDelete=Date.now()),bt&&!O&&m.start()!=k.start()&&k.parentOffset==0&&m.depth==k.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==p.endA&&(p.endB-=2,k=u.doc.resolveNoCache(p.endB-u.from),setTimeout(()=>{n.someProp("handleKeyDown",function(I){return I(n,sn(13,"Enter"))})},20));let C=p.start,A=p.endA,z=I=>{let R=I||n.state.tr.replace(C,A,u.doc.slice(p.start-u.from,p.endB-u.from));if(u.sel){let q=td(n,R.doc,u.sel);q&&!(pe&&n.composing&&q.empty&&(p.start!=p.endB||n.input.lastChromeDelete<Date.now()-100)&&(q.head==C||q.head==R.mapping.map(A)-1)||ve&&q.empty&&q.head==C)&&R.setSelection(q)}return o&&R.setMeta("composition",o),R.scrollIntoView()},S;if(O)if(m.pos==k.pos){ve&&Ft<=11&&m.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>wt(n),20));let I=z(n.state.tr.delete(C,A)),R=c.resolve(p.start).marksAcross(c.resolve(p.endA));R&&I.ensureMarks(R),n.dispatch(I)}else if(p.endA==p.endB&&(S=zb(m.parent.content.cut(m.parentOffset,k.parentOffset),x.parent.content.cut(x.parentOffset,p.endA-x.start())))){let I=z(n.state.tr);S.type=="add"?I.addMark(C,A,S.mark):I.removeMark(C,A,S.mark),n.dispatch(I)}else if(m.parent.child(m.index()).isText&&m.index()==k.index()-(k.textOffset?0:1)){let I=m.parent.textBetween(m.parentOffset,k.parentOffset),R=()=>z(n.state.tr.insertText(I,C,A));n.someProp("handleTextInput",q=>q(n,C,A,I,R))||n.dispatch(R())}else n.dispatch(z());else n.dispatch(z())}function td(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:ra(n,e.resolve(t.anchor),e.resolve(t.head))}function zb(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,i=t,o=r,s,l,a;for(let c=0;c<r.length;c++)i=r[c].removeFromSet(i);for(let c=0;c<t.length;c++)o=t[c].removeFromSet(o);if(i.length==1&&o.length==0)l=i[0],s="add",a=c=>c.mark(l.addToSet(c.marks));else if(i.length==0&&o.length==1)l=o[0],s="remove",a=c=>c.mark(l.removeFromSet(c.marks));else return null;let u=[];for(let c=0;c<e.childCount;c++)u.push(a(e.child(c)));if(M.from(u).eq(n))return{mark:l,type:s}}function Fb(n,e,t,r,i){if(t-e<=i.pos-r.pos||Pl(r,!0,!1)<i.pos)return!1;let o=n.resolve(e);if(!r.parent.inlineContent){let l=o.nodeAfter;return l!=null&&t==e+l.nodeSize}if(o.parentOffset<o.parent.content.size||!o.parent.isTextblock)return!1;let s=n.resolve(Pl(o,!0,!0));return!s.parent.isTextblock||s.pos>t||Pl(s,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(s.parent.content)}function _b(n,e,t){let r=0,i=0;return n.nodesBetween(e,t,(o,s)=>{o.isTextblock&&s>=e&&s<t?r++:(o.isText?/\S/.test(o.text.slice(Math.max(0,e-s),Math.min(o.nodeSize,t-s))):o.isLeaf)&&i++}),i==0&&r==1}function Pl(n,e,t){let r=n.depth,i=e?n.end():n.pos;for(;r>0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,i++,e=!1;if(t){let o=n.node(r).maybeChild(n.indexAfter(r));for(;o&&!o.isLeaf;)o=o.firstChild,i++}return i}function Vb(n,e,t,r,i){let o=n.findDiffStart(e,t),s=t+n.size,l=t+e.size;if(o==null)return null;let{a,b:u}=n.findDiffEnd(e,s,l);if(i=="end"){let c=Math.max(0,o-Math.min(a,u));r-=a+c-o}if(a<o&&s<l){let c=r<=o&&r>=a?o-r:0;o-=c,u=o+(u-a),a=o}else if(u<o){let c=r<=o&&r>=u?o-r:0;o-=c,a=o+(a-u),u=o}return{start:o,endA:a,endB:u}}var si=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 Jl,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(sd),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=id(this),rd(this),this.nodeViews=od(this),this.docView=Fh(this.state.doc,nd(this),Rl(this),this.dom,this),this.domObserver=new ea(this,(r,i,o,s)=>Lb(this,r,i,o,s)),this.domObserver.start(),sb(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&&Gl(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(sd),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let i=this.state,o=!1,s=!1;e.storedMarks&&this.composing&&(Rd(this),s=!0),this.state=e;let l=i.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let h=od(this);jb(h,this.nodeViews)&&(this.nodeViews=h,o=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&Gl(this),this.editable=id(this),rd(this);let a=Rl(this),u=nd(this),c=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",f=o||!this.docView.matchesNode(e.doc,u,a);(f||!e.selection.eq(i.selection))&&(s=!0);let d=c=="preserve"&&s&&this.dom.style.overflowAnchor==null&&Mk(this);if(s){this.domObserver.stop();let h=f&&(ve||pe)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&$b(i.selection,e.selection);if(f){let m=pe?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=kb(this)),(o||!this.docView.update(e.doc,u,a,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=Fh(e.doc,u,a,this.dom,this)),m&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(h=!0)}let p=this.input.mouseDown;h||!(p&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Hk(this)&&p.delaySelUpdate())?wt(this,h):(bd(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),c=="reset"?this.dom.scrollTop=0:c=="to selection"?this.scrollToSelection():d&&Nk(d)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!pn(this.dom,e))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof B){let t=this.docView.domAfterPos(this.state.selection.from);D(t)&&Rh(this,t.getBoundingClientRect(),e)}else Rh(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 r=this.directPlugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let r=this.state.plugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let r=this.pluginViews[t];r.update&&r.update(this,e)}}updateDraggedNode(e,t){let r=e.node,i=-1;if(r.from<this.state.doc.content.size&&this.state.doc.nodeAt(r.from)==r.node)i=r.from;else{let o=r.from+(this.state.doc.content.size-t.doc.content.size);(o>0&&o<this.state.doc.content.size&&this.state.doc.nodeAt(o))==r.node&&(i=o)}this.dragging=new Ao(e.slice,e.move,i<0?void 0:B.create(this.state.doc,i))}someProp(e,t){let r=this._props&&this._props[e],i;if(r!=null&&(i=t?t(r):r))return i;for(let s=0;s<this.directPlugins.length;s++){let l=this.directPlugins[s].props[e];if(l!=null&&(i=t?t(l):l))return i}let o=this.state.plugins;if(o)for(let s=0;s<o.length;s++){let l=o[s].props[e];if(l!=null&&(i=t?t(l):l))return i}}hasFocus(){if(ve){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&&Ik(this.dom),wt(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 vk(this,e)}coordsAtPos(e,t=1){return pd(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,r=-1){let i=this.docView.posFromDOM(e,t,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,t){return Lk(this,t||this.state,e)}pasteHTML(e,t){return ri(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return ri(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return ia(this,e)}destroy(){this.docView&&(lb(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Rl(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,pk())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return ub(this,e)}domSelectionRange(){let e=this.dom.isConnected!==!1&&this.domSelection();return e?Se&&this.root.nodeType===11&&kk(this.dom.ownerDocument)==this.dom&&Ab(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};si.prototype.dispatch=function(n){let e=this._props.dispatchTransaction;e?e.call(this,n):this.updateState(this.state.apply(n))};function nd(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[et.node(0,n.state.doc.content.size,e)]}function rd(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:et.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function id(n){return!n.someProp("editable",e=>e(n.state)===!1)}function $b(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function od(n){let e=Object.create(null);function t(r){for(let i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function jb(n,e){let t=0,r=0;for(let i in n){if(n[i]!=e[i])return!0;t++}for(let i in e)r++;return t!=r}function sd(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}function Mt(n,e){return n.meta={package:"@milkdown/core",group:"System",...e},n}var $d={text:(n,e,t,r)=>{let i=n.value;return/^[^*_\\]*\s+$/.test(i)?i:t.safe(i,{...r,encode:[]})},strong:(n,e,t,r)=>{let i=n.marker||t.options.strong||"*",o=t.enter("strong"),s=t.createTracker(r),l=s.move(i+i);return l+=s.move(t.containerPhrasing(n,{before:l,after:i,...s.current()})),l+=s.move(i+i),o(),l},emphasis:(n,e,t,r)=>{let i=n.marker||t.options.emphasis||"*",o=t.enter("emphasis"),s=t.createTracker(r),l=s.move(i);return l+=s.move(t.containerPhrasing(n,{before:l,after:i,...s.current()})),l+=s.move(i),o(),l}},Fe=$({},"editorView"),ci=$({},"editorState"),ua=$([],"initTimer"),_d=$({},"editor"),lr=$([],"inputRules"),nt=$([],"prosePlugins"),ar=$([],"remarkPlugins"),Ho=$([],"nodeView"),Ko=$([],"markView"),gn=$(Lr().use(An).use(zn),"remark"),er=$({handlers:$d,encode:[]},"remarkStringifyOptions"),Lo=qe("ConfigReady");function qb(n){let e=t=>(t.record(Lo),async()=>(await n(t),t.done(Lo),()=>{t.clearTimer(Lo)}));return Mt(e,{displayName:"Config"}),e}var Ct=qe("InitReady");function Wb(n){let e=t=>(t.inject(_d,n).inject(nt,[]).inject(ar,[]).inject(lr,[]).inject(Ho,[]).inject(Ko,[]).inject(er,{handlers:$d,encode:[]}).inject(gn,Lr().use(An).use(zn)).inject(ua,[Lo]).record(Ct),async()=>{await t.waitTimers(ua);let r=t.get(er);return t.set(gn,Lr().use(An).use(zn,r)),t.done(Ct),()=>{t.remove(_d).remove(nt).remove(ar).remove(lr).remove(Ho).remove(Ko).remove(er).remove(gn).remove(ua).clearTimer(Ct)}});return Mt(e,{displayName:"Init"}),e}var De=qe("SchemaReady"),zo=$([],"schemaTimer"),tt=$({},"schema"),tr=$([],"nodes"),nr=$([],"marks");function Vd(n){return{...n,parseDOM:n.parseDOM?.map(e=>({priority:n.priority,...e}))}}var jd=n=>(n.inject(tt,{}).inject(tr,[]).inject(nr,[]).inject(zo,[Ct]).record(De),async()=>{await n.waitTimers(zo);let e=n.get(gn),t=n.get(ar).reduce((s,l)=>s.use(l.plugin,l.options),e);n.set(gn,t);let r=Object.fromEntries(n.get(tr).map(([s,l])=>[s,Vd(l)])),i=Object.fromEntries(n.get(nr).map(([s,l])=>[s,Vd(l)])),o=new ao({nodes:r,marks:i});return n.set(tt,o),n.done(De),()=>{n.remove(tt).remove(tr).remove(nr).remove(zo).clearTimer(De)}});Mt(jd,{displayName:"Schema"});var qd=class{constructor(){this.#t=new hs,this.#e=null,this.setCtx=n=>{this.#e=n},this.chain=()=>{if(this.#e==null)throw Ai();let n=this.#e,e=[],t=this.get.bind(this),r={run:()=>{let o=on(...e),s=n.get(Fe);return o(s.state,s.dispatch,s)},inline:o=>(e.push(o),r),pipe:i.bind(this)};function i(o,s){let l=t(o);return e.push(l(s)),r}return r}}#t;#e;get ctx(){return this.#e}create(n,e){let t=n.create(this.#t.sliceMap);return t.set(e),t}get(n){return this.#t.get(n).get()}remove(n){return this.#t.remove(n)}call(n,e){if(this.#e==null)throw Ai();let t=this.get(n)(e),r=this.#e.get(Fe);return t(r.state,r.dispatch,r)}inline(n){if(this.#e==null)throw Ai();let e=this.#e.get(Fe);return n(e.state,e.dispatch,e)}};function Wd(n="cmdKey"){return $((()=>()=>!1),n)}var J=$(new qd,"commands"),Fo=$([De],"commandsTimer"),rr=qe("CommandsReady"),Hd=n=>{let e=new qd;return e.setCtx(n),n.inject(J,e).inject(Fo,[De]).record(rr),async()=>(await n.waitTimers(Fo),n.done(rr),()=>{n.remove(J).remove(Fo).clearTimer(rr)})};Mt(Hd,{displayName:"Commands"});function Hb(n){return n.Backspace=on(ph,xo,ah,Sl),n}var Kd=class{constructor(){this.#t=null,this.#e=[],this.setCtx=n=>{this.#t=n},this.add=n=>(this.#e.push(n),()=>{this.#e=this.#e.filter(e=>e!==n)}),this.addObjectKeymap=n=>{let e=[];return Object.entries(n).forEach(([t,r])=>{if(typeof r=="function"){let i={key:t,onRun:()=>r};this.#e.push(i),e.push(()=>{this.#e=this.#e.filter(o=>o!==i)})}else this.#e.push(r),e.push(()=>{this.#e=this.#e.filter(i=>i!==r)})}),()=>{e.forEach(t=>t())}},this.addBaseKeymap=()=>{let n=Hb(dh);return this.addObjectKeymap(n)},this.build=()=>{let n={};return this.#e.forEach(e=>{n[e.key]=[...n[e.key]||[],e]}),Object.fromEntries(Object.entries(n).map(([e,t])=>{let r=t.sort((o,s)=>(s.priority??50)-(o.priority??50));return[e,(o,s,l)=>{let a=this.#t;if(a==null)throw En();let u=r.map(c=>c.onRun(a));return on(...u)(o,s,l)}]}))}}#t;#e;get ctx(){return this.#t}},mi=$(new Kd,"keymap"),ca=$([De],"keymapTimer"),ir=qe("KeymapReady"),Kb=n=>{let e=new Kd;return e.setCtx(n),n.inject(mi,e).inject(ca,[De]).record(ir),async()=>(await n.waitTimers(ca),n.done(ir),()=>{n.remove(mi).remove(ca).clearTimer(ir)})},_o=qe("ParserReady"),Ud=(()=>{throw En()}),or=$(Ud,"parser"),fa=$([],"parserTimer"),Jd=n=>(n.inject(or,Ud).inject(fa,[De]).record(_o),async()=>{await n.waitTimers(fa);let e=n.get(gn),t=n.get(tt);return n.set(or,Oh.create(t,e)),n.done(_o),()=>{n.remove(or).remove(fa).clearTimer(_o)}});Mt(Jd,{displayName:"Parser"});var sr=qe("SerializerReady"),ha=$([],"serializerTimer"),Gd=(()=>{throw En()}),yn=$(Gd,"serializer"),Qd=n=>(n.inject(yn,Gd).inject(ha,[De]).record(sr),async()=>{await n.waitTimers(ha);let e=n.get(gn),t=n.get(tt);return n.set(yn,Ah.create(t,e)),n.done(sr),()=>{n.remove(yn).remove(ha).clearTimer(sr)}});Mt(Qd,{displayName:"Serializer"});var fi=$("","defaultValue"),hi=$(n=>n,"stateOptions"),Vo=$([],"editorStateTimer"),$o=qe("EditorStateReady");function Ub(n,e,t){if(typeof n=="string")return e(n);if(n.type==="html")return Dt.fromSchema(t).parse(n.dom);if(n.type==="json")return Ae.fromJSON(t,n.value);throw Mu(n)}var Jb=new ae("MILKDOWN_STATE_TRACKER"),Yd=n=>(n.inject(fi,"").inject(ci,{}).inject(hi,e=>e).inject(Vo,[_o,sr,rr,ir]).record($o),async()=>{await n.waitTimers(Vo);let e=n.get(tt),t=n.get(or),r=n.get(lr),i=n.get(hi),o=n.get(nt),s=Ub(n.get(fi),t,e),l=n.get(mi),a=l.addBaseKeymap(),u=[...o,new ie({key:Jb,state:{init:()=>{},apply:(d,h,p,m)=>{n.set(ci,m)}}}),xh({rules:r}),Ch(l.build())];n.set(nt,u);let c=i({schema:e,doc:s,plugins:u}),f=Kn.create(c);return n.set(ci,f),n.done($o),()=>{a(),n.remove(fi).remove(ci).remove(hi).remove(Vo).clearTimer($o)}});Mt(Yd,{displayName:"EditorState"});var Uo=$([],"pasteRule"),jo=$([De],"pasteRuleTimer"),qo=qe("PasteRuleReady"),Xd=n=>(n.inject(Uo,[]).inject(jo,[De]).record(qo),async()=>(await n.waitTimers(jo),n.done(qo),()=>{n.remove(Uo).remove(jo).clearTimer(qo)}));Mt(Xd,{displayName:"PasteRule"});var di=qe("EditorViewReady"),Wo=$([],"editorViewTimer"),da=$({},"editorViewOptions"),pi=$(null,"root"),pa=$(null,"rootDOM"),ma=$({},"rootAttrs");function Gb(n,e){let t=document.createElement("div");t.className="milkdown",n.appendChild(t),e.set(pa,t);let r=e.get(ma);return Object.entries(r).forEach(([i,o])=>t.setAttribute(i,o)),t}function Qb(n){n.classList.add("editor"),n.setAttribute("role","textbox")}var Yb=new ae("MILKDOWN_VIEW_CLEAR"),Zd=n=>(n.inject(pi,document.body).inject(Fe,{}).inject(da,{}).inject(pa,null).inject(ma,{}).inject(Wo,[$o,qo]).record(di),async()=>{await n.wait(Ct);let e=n.get(pi)||document.body,t=typeof e=="string"?document.querySelector(e):e;n.update(nt,a=>[new ie({key:Yb,view:u=>{let c=t?Gb(t,n):void 0;return(()=>{if(c&&t){let d=u.dom;t.replaceChild(c,d),c.appendChild(d)}})(),{destroy:()=>{c?.parentNode&&c?.parentNode.replaceChild(u.dom,c),c?.remove()}}}}),...a]),await n.waitTimers(Wo);let r=n.get(ci),i=n.get(da),o=Object.fromEntries(n.get(Ho)),s=Object.fromEntries(n.get(Ko)),l=new si(t,{state:r,nodeViews:o,markViews:s,transformPasted:(a,u,c)=>(n.get(Uo).sort((f,d)=>(d.priority??50)-(f.priority??50)).map(f=>f.run).forEach(f=>{a=f(a,u,c)}),a),...i});return Qb(l.dom),n.set(Fe,l),n.done(di),()=>{l?.destroy(),n.remove(pi).remove(Fe).remove(da).remove(pa).remove(ma).remove(Wo).clearTimer(di)}});Mt(Zd,{displayName:"EditorView"});var ep=class tp{constructor(){this.#t=!1,this.#e="Idle",this.#r=[],this.#n=()=>{},this.#o=new hs,this.#s=new Pu,this.#i=new Map,this.#l=new Map,this.#a=new Du(this.#o,this.#s),this.#h=()=>{let e=qb(async r=>{await Promise.all(this.#r.map(i=>Promise.resolve(i(r))))}),t=[jd,Jd,Qd,Hd,Kb,Xd,Yd,Zd,Wb(this),e];this.#u(t,this.#l)},this.#u=(e,t)=>{e.forEach(r=>{let i=this.#a.produce(this.#t?r.meta:void 0),o=r(i);t.set(r,{ctx:i,handler:o,cleanup:void 0})})},this.#c=(e,t=!1)=>Promise.all([e].flat().map(async r=>{let i=this.#i.get(r)?.cleanup;return t?this.#i.delete(r):this.#i.set(r,{ctx:void 0,handler:void 0,cleanup:void 0}),typeof i=="function"?i():i})),this.#d=async()=>{await Promise.all([...this.#l.entries()].map(async([e,{cleanup:t}])=>typeof t=="function"?t():t)),this.#l.clear()},this.#f=e=>{this.#e=e,this.#n(e)},this.#p=e=>[...e.entries()].map(async([t,r])=>{let{ctx:i,handler:o}=r;if(!o)return;let s=await o();e.set(t,{ctx:i,handler:o,cleanup:s})}),this.enableInspector=(e=!0)=>(this.#t=e,this),this.onStatusChange=e=>(this.#n=e,this),this.config=e=>(this.#r.push(e),this),this.removeConfig=e=>(this.#r=this.#r.filter(t=>t!==e),this),this.use=e=>{let t=[e].flat();return t.flat().forEach(r=>{this.#i.set(r,{ctx:void 0,handler:void 0,cleanup:void 0})}),this.#e==="Created"&&this.#u(t,this.#i),this},this.remove=async e=>this.#e==="OnCreate"?(console.warn("[Milkdown]: You are trying to remove plugins when the editor is creating, this is not recommended, please check your code."),new Promise(t=>{setTimeout(()=>{t(this.remove(e))},50)})):(await this.#c([e].flat(),!0),this),this.create=async()=>this.#e==="OnCreate"?this:(this.#e==="Created"&&await this.destroy(),this.#f("OnCreate"),this.#h(),this.#u([...this.#i.keys()],this.#i),await Promise.all([this.#p(this.#l),this.#p(this.#i)].flat()),this.#f("Created"),this),this.destroy=async(e=!1)=>this.#e==="Destroyed"||this.#e==="OnDestroy"?this:this.#e==="OnCreate"?new Promise(t=>{setTimeout(()=>{t(this.destroy(e))},50)}):(e&&(this.#r=[]),this.#f("OnDestroy"),await this.#c([...this.#i.keys()],e),await this.#d(),this.#f("Destroyed"),this),this.action=e=>e(this.#a),this.inspect=()=>this.#t?[...this.#l.values(),...this.#i.values()].map(({ctx:e})=>e?.inspector?.read()).filter(e=>!!e):(console.warn("[Milkdown]: You are trying to collect inspection when inspector is disabled, please enable inspector by `editor.enableInspector()` first."),[])}static make(){return new tp}#t;#e;#r;#n;#o;#s;#i;#l;#a;#h;#u;#c;#d;#f;#p;get ctx(){return this.#a}get status(){return this.#e}};var Xb=n=>crypto.getRandomValues(new Uint8Array(n)),Zb=(n,e,t)=>{let r=256-256%n.length;if(r===256){let i=n.length-1;return(o=e)=>{if(!o)return"";let s="";for(;;){let l=t(o),a=o|=0;for(;a--;)if(s+=n[l[a]&i],s.length>=o)return s}}}return(i=e)=>{if(!i)return"";let o="",s=Math.ceil(1.6*256*i/r);for(;;){let l=t(s),a=s;for(;a--;)if(l[a]<r&&(o+=n[l[a]%n.length],o.length>=i))return o}}},np=(n,e=21)=>Zb(n,e|0,Xb);var FO=np("abcedfghicklmn",10);function rp(n,e,t){let r=n.findIndex(([o])=>o===e);if(r===-1)return[...n,t];let i=n.slice();return i[r]=t,i}function U(n,e){let t=Wd(n),r=i=>async()=>{r.key=t,await i.wait(rr);let o=e(i);return i.get(J).create(t,o),r.run=s=>i.get(J).call(n,s),()=>{i.get(J).remove(t)}};return r}function Ue(n){let e=t=>async()=>{await t.wait(De);let r=n(t);return t.update(lr,i=>[...i,r]),e.inputRule=r,()=>{t.update(lr,i=>i.filter(o=>o!==r))}};return e}function e0(n,e){let t=r=>async()=>{let i=e(r);return r.update(nr,o=>rp(o,n,[n,i])),t.id=n,t.schema=i,()=>{r.update(nr,o=>o.filter(([s])=>s!==n))}};return t.type=r=>{let i=r.get(tt).marks[n];if(!i)throw vu(n);return i},t}function Jo(n,e){let t=r=>async()=>{let i=e(r);return r.update(tr,o=>rp(o,n,[n,i])),t.id=n,t.schema=i,()=>{r.update(tr,o=>o.filter(([s])=>s!==n))}};return t.type=r=>{let i=r.get(tt).nodes[n];if(!i)throw Au(n);return i},t}function $t(n){let e,t=r=>async()=>(await r.wait(De),e=n(r),r.update(nt,i=>[...i,e]),()=>{r.update(nt,i=>i.filter(o=>o!==e))});return t.plugin=()=>e,t.key=()=>e.spec.key,t}function t0(n){let e=t=>async()=>{await t.wait(ir);let r=t.get(mi),i=n(t),o=r.addObjectKeymap(i);return e.keymap=i,()=>{o()}};return e}function Je(n,e){let t=$(n,e),r=i=>(i.inject(t),()=>()=>{i.remove(t)});return r.key=t,r}function _e(n,e){let t=Je(e,n),r=Jo(n,o=>o.get(t.key)(o)),i=[t,r];return i.id=r.id,i.node=r,i.type=o=>r.type(o),i.ctx=t,i.key=t.key,i.extendSchema=o=>_e(n,o(e)),i}function ur(n,e){let t=Je(e,n),r=e0(n,o=>o.get(t.key)(o)),i=[t,r];return i.id=r.id,i.mark=r,i.type=o=>r.type(o),i.ctx=t,i.key=t.key,i.extendSchema=o=>ur(n,o(e)),i}function Re(n,e){let t=Je(Object.fromEntries(Object.entries(e).map(([o,{shortcuts:s,priority:l}])=>[o,{shortcuts:s,priority:l}])),`${n}Keymap`),r=t0(o=>{let s=o.get(t.key),l=Object.entries(e).flatMap(([a,{command:u}])=>{let c=s[a],f=[c.shortcuts].flat(),d=c.priority;return f.map(h=>[h,{key:h,onRun:u,priority:d}])});return Object.fromEntries(l)}),i=[t,r];return i.ctx=t,i.shortcuts=r,i.key=t.key,i.keymap=r.keymap,i}var Ge=(n,e=()=>({}))=>Je(e,`${n}Attr`),gi=(n,e=()=>({}))=>Je(e,`${n}Attr`);function xn(n,e,t){let r=Je(t??{},n),i=s=>async()=>{await s.wait(Ct);let l={plugin:e(s),options:s.get(r.key)};return s.update(ar,a=>[...a,l]),()=>{s.update(ar,a=>a.filter(u=>u!==l))}},o=[r,i];return o.id=n,o.plugin=i,o.options=r,o}function ga(n,e){return t=>t.get(J).call(n,e)}function ip(n){return e=>{let t=e.get(Fe),r=e.get(tt),i=e.get(yn);if(!n)return i(t.state.doc);let o=t.state.doc.slice(n.from,n.to,!0),s=r.topNodeType.createAndFill(null,o.content);return s?i(s):(console.error("No document found"),"")}}function op(n,e=!1){return t=>{let r=t.get(Fe),i=t.get(or)(n);if(!i)return;if(!e){let{state:a}=r;return r.dispatch(a.tr.replace(0,a.doc.content.size,new E(i.content,0,0)))}let o=t.get(tt),s=t.get(hi)({schema:o,doc:i,plugins:t.get(nt)}),l=Kn.create(s);r.updateState(l)}}function sp(n,e){return function(t,r){let{$from:i,$to:o,node:s}=t.selection;if(s&&s.isBlock||i.depth<2||!i.sameParent(o))return!1;let l=i.node(-1);if(l.type!=n)return!1;if(i.parent.content.size==0&&i.node(-1).childCount==i.indexAfter(-1)){if(i.depth==3||i.node(-3).type!=n||i.index(-2)!=i.node(-2).childCount-1)return!1;if(r){let f=M.empty,d=i.index(-1)?1:i.index(-2)?2:3;for(let x=i.depth-d;x>=i.depth-3;x--)f=M.from(i.node(x).copy(f));let h=i.indexAfter(-1)<i.node(-2).childCount?1:i.indexAfter(-2)<i.node(-3).childCount?2:3;f=f.append(M.from(n.createAndFill()));let p=i.before(i.depth-(d-1)),m=t.tr.replace(p,i.after(-h),new E(f,4-d,0)),k=-1;m.doc.nodesBetween(p,m.doc.content.size,(x,O)=>{if(k>-1)return!1;x.isTextblock&&x.content.size==0&&(k=O+1)}),k>-1&&m.setSelection(j.near(m.doc.resolve(k))),r(m.scrollIntoView())}return!0}let a=o.pos==i.end()?l.contentMatchAt(0).defaultType:null,u=t.tr.delete(i.pos,o.pos),c=a?[e?{type:n,attrs:e}:null,{type:a}]:void 0;return tn(u.doc,i.pos,2,c)?(r&&r(u.split(i.pos,2,c).scrollIntoView()),!0):!1}}function lp(n){return function(e,t){let{$from:r,$to:i}=e.selection,o=r.blockRange(i,s=>s.childCount>0&&s.firstChild.type==n);return o?t?r.node(o.depth-1).type==n?n0(e,t,n,o):r0(e,t,o):!0:!1}}function n0(n,e,t,r){let i=n.tr,o=r.end,s=r.$to.end(r.depth);o<s&&(i.step(new he(o-1,s,o,s,new E(M.from(t.create(null,r.parent.copy())),1,0),1,!0)),r=new _r(i.doc.resolve(r.$from.pos),i.doc.resolve(s),r.depth));let l=qn(r);if(l==null)return!1;i.lift(r,l);let a=i.doc.resolve(i.mapping.map(o,-1)-1);return nn(i.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&i.join(a.pos),e(i.scrollIntoView()),!0}function r0(n,e,t){let r=n.tr,i=t.parent;for(let h=t.end,p=t.endIndex-1,m=t.startIndex;p>m;p--)h-=i.child(p).nodeSize,r.delete(h-1,h+1);let o=r.doc.resolve(t.start),s=o.nodeAfter;if(r.mapping.map(t.end)!=t.start+o.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==i.childCount,u=o.node(-1),c=o.index(-1);if(!u.canReplace(c+(l?0:1),c+1,s.content.append(a?M.empty:M.from(i))))return!1;let f=o.pos,d=f+s.nodeSize;return r.step(new he(f-(l?1:0),d+(a?1:0),f+1,d-1,new E((l?M.empty:M.from(i.copy(M.empty))).append(a?M.empty:M.from(i.copy(M.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function ap(n){return function(e,t){let{$from:r,$to:i}=e.selection,o=r.blockRange(i,u=>u.childCount>0&&u.firstChild.type==n);if(!o)return!1;let s=o.startIndex;if(s==0)return!1;let l=o.parent,a=l.child(s-1);if(a.type!=n)return!1;if(t){let u=a.lastChild&&a.lastChild.type==l.type,c=M.from(u?n.create():null),f=new E(M.from(n.create(null,M.from(l.type.create(null,c)))),u?3:1,0),d=o.start,h=o.end;t(e.tr.step(new he(d-(u?3:1),h,d,h,f,1,!0)).scrollIntoView())}return!0}}function ya(n){let e=new Map;if(!n||!n.type)throw new Error("mdast-util-definitions expected node");return Ye(n,"definition",function(r){let i=up(r.identifier);i&&!e.get(i)&&e.set(i,r)}),t;function t(r){let i=up(r);return e.get(i)}}function up(n){return String(n||"").toUpperCase()}function Go(){return function(n){let e=ya(n);Ye(n,function(t,r,i){if(t.type==="definition"&&i!==void 0&&typeof r=="number")return i.children.splice(r,1),[ot,r];if(t.type==="imageReference"||t.type==="linkReference"){let o=e(t.identifier);if(o&&i&&typeof r=="number")return i.children[r]=t.type==="imageReference"?{type:"image",url:o.url,title:o.title,alt:t.alt}:{type:"link",url:o.url,title:o.title,children:t.children},[ot,r]}})}}function i0(n){let e={...n};return e.position&&(e.position={start:{...e.position.start},end:{...e.position.end}}),delete e.children,e}var o0="<br />",s0=/^<br\s*\/?\s*>$/i,l0=n=>typeof n=="string"&&s0.test(n.trim());function fp(n,e){if(!(e.childCount>=1&&e.lastChild?.type.name==="hardbreak")){n.next(e.content);return}let t=[];e.content.forEach((r,i,o)=>{o!==e.childCount-1&&t.push(r)}),n.next(M.fromArray(t))}function w(n,e){return Object.assign(n,{meta:{package:"@milkdown/preset-commonmark",...e}}),n}var xa=gi("emphasis");w(xa,{displayName:"Attr<emphasis>",group:"Emphasis"});var fr=ur("emphasis",n=>({attrs:{marker:{default:n.get(er).emphasis||"*",validate:"string"}},parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style",getAttrs:e=>e==="italic"}],toDOM:e=>["em",n.get(xa.key)(e)],parseMarkdown:{match:e=>e.type==="emphasis",runner:(e,t,r)=>{e.openMark(r,{marker:t.marker}),e.next(t.children),e.closeMark(r)}},toMarkdown:{match:e=>e.type.name==="emphasis",runner:(e,t)=>{e.withMark(t,"emphasis",void 0,{marker:t.attrs.marker})}}}));w(fr.mark,{displayName:"MarkSchema<emphasis>",group:"Emphasis"});w(fr.ctx,{displayName:"MarkSchemaCtx<emphasis>",group:"Emphasis"});var yi=U("ToggleEmphasis",n=>()=>bo(fr.type(n)));w(yi,{displayName:"Command<toggleEmphasisCommand>",group:"Emphasis"});var hp=Ue(n=>Yr(/(?:^|[^*])\*([^*]+)\*$/,fr.type(n),{getAttr:()=>({marker:"*"}),updateCaptured:({fullMatch:e,start:t})=>e.startsWith("*")?{}:{fullMatch:e.slice(1),start:t+1}}));w(hp,{displayName:"InputRule<emphasis>|Star",group:"Emphasis"});var dp=Ue(n=>Yr(/\b_(?![_\s])(.*?[^_\s])_$/,fr.type(n),{getAttr:()=>({marker:"_"}),updateCaptured:({fullMatch:e,start:t})=>e.startsWith("_")?{}:{fullMatch:e.slice(1),start:t+1}}));w(dp,{displayName:"InputRule<emphasis>|Underscore",group:"Emphasis"});var ka=Re("emphasisKeymap",{ToggleEmphasis:{shortcuts:"Mod-i",command:n=>{let e=n.get(J);return()=>e.call(yi.key)}}});w(ka.ctx,{displayName:"KeymapCtx<emphasis>",group:"Emphasis"});w(ka.shortcuts,{displayName:"Keymap<emphasis>",group:"Emphasis"});var ba=gi("strong");w(ba,{displayName:"Attr<strong>",group:"Strong"});var xi=ur("strong",n=>({attrs:{marker:{default:n.get(er).strong||"*",validate:"string"}},parseDOM:[{tag:"b",getAttrs:e=>e.style.fontWeight!="normal"&&null},{tag:"strong"},{style:"font-style",getAttrs:e=>e==="bold"},{style:"font-weight=400",clearMark:e=>e.type.name=="strong"},{style:"font-weight",getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}],toDOM:e=>["strong",n.get(ba.key)(e)],parseMarkdown:{match:e=>e.type==="strong",runner:(e,t,r)=>{e.openMark(r,{marker:t.marker}),e.next(t.children),e.closeMark(r)}},toMarkdown:{match:e=>e.type.name==="strong",runner:(e,t)=>{e.withMark(t,"strong",void 0,{marker:t.attrs.marker})}}}));w(xi.mark,{displayName:"MarkSchema<strong>",group:"Strong"});w(xi.ctx,{displayName:"MarkSchemaCtx<strong>",group:"Strong"});var ki=U("ToggleStrong",n=>()=>bo(xi.type(n)));w(ki,{displayName:"Command<toggleStrongCommand>",group:"Strong"});var pp=Ue(n=>Yr(/(?<![\w:/])(?:\*\*|__)([^*_]+?)(?:\*\*|__)(?![\w/])$/,xi.type(n),{getAttr:e=>({marker:e[0].startsWith("*")?"*":"_"})}));w(pp,{displayName:"InputRule<strong>",group:"Strong"});var Sa=Re("strongKeymap",{ToggleBold:{shortcuts:["Mod-b"],command:n=>{let e=n.get(J);return()=>e.call(ki.key)}}});w(Sa.ctx,{displayName:"KeymapCtx<strong>",group:"Strong"});w(Sa.shortcuts,{displayName:"Keymap<strong>",group:"Strong"});var wa=gi("inlineCode");w(wa,{displayName:"Attr<inlineCode>",group:"InlineCode"});var jt=ur("inlineCode",n=>({priority:100,code:!0,inclusive:!1,parseDOM:[{tag:"code"}],toDOM:e=>["code",n.get(wa.key)(e)],parseMarkdown:{match:e=>e.type==="inlineCode",runner:(e,t,r)=>{e.openMark(r),e.addText(t.value),e.closeMark(r)}},toMarkdown:{match:e=>e.type.name==="inlineCode",runner:(e,t,r)=>(e.withMark(t,"inlineCode",r.text||""),!0)}}));w(jt.mark,{displayName:"MarkSchema<inlineCode>",group:"InlineCode"});w(jt.ctx,{displayName:"MarkSchemaCtx<inlineCode>",group:"InlineCode"});var Ca=U("ToggleInlineCode",n=>()=>(e,t)=>{let{selection:r,tr:i}=e;if(r.empty)return!1;let{from:o,to:s}=r;return e.doc.rangeHasMark(o,s,jt.type(n))?(t?.(i.removeMark(o,s,jt.type(n))),!0):(Object.keys(e.schema.marks).filter(l=>l!==jt.type.name).map(l=>e.schema.marks[l]).forEach(l=>{i.removeMark(o,s,l)}),t?.(i.addMark(o,s,jt.type(n).create())),!0)});w(Ca,{displayName:"Command<toggleInlineCodeCommand>",group:"InlineCode"});var mp=Ue(n=>Yr(/(?:`)([^`]+)(?:`)$/,jt.type(n)));w(mp,{displayName:"InputRule<inlineCodeInputRule>",group:"InlineCode"});var Ma=Re("inlineCodeKeymap",{ToggleInlineCode:{shortcuts:"Mod-e",command:n=>{let e=n.get(J);return()=>e.call(Ca.key)}}});w(Ma.ctx,{displayName:"KeymapCtx<inlineCode>",group:"InlineCode"});w(Ma.shortcuts,{displayName:"Keymap<inlineCode>",group:"InlineCode"});var a0=new Set(["http:","https:","mailto:","tel:","ftp:"]);function u0(n){return n<=32||n>=127&&n<=160||n>=8203&&n<=8205||n===8232||n===8233||n===65279}function c0(n){let e="";for(let t of n)u0(t.codePointAt(0)??0)||(e+=t);return e}function f0(n){if(typeof n!="string")return"";let e=n.trim();if(!e)return"";let t=c0(e),r=/^([a-z][a-z0-9+.-]*):/i.exec(t)?.[1];return!r||a0.has(`${r.toLowerCase()}:`)?e:""}var Na=gi("link");w(Na,{displayName:"Attr<link>",group:"Link"});var cr=ur("link",n=>({attrs:{href:{validate:"string"},title:{default:null,validate:"string|null"}},parseDOM:[{tag:"a[href]",getAttrs:e=>{if(!(e instanceof HTMLElement))throw Nt(e);return{href:e.getAttribute("href"),title:e.getAttribute("title")}}}],toDOM:e=>["a",{...n.get(Na.key)(e),...e.attrs,href:f0(e.attrs.href)}],parseMarkdown:{match:e=>e.type==="link",runner:(e,t,r)=>{let i=t.url,o=t.title;e.openMark(r,{href:i,title:o}),e.next(t.children),e.closeMark(r)}},toMarkdown:{match:e=>e.type.name==="link",runner:(e,t)=>{e.withMark(t,"link",void 0,{title:t.attrs.title,url:t.attrs.href})}}}));w(cr.mark,{displayName:"MarkSchema<link>",group:"Link"});var gp=U("ToggleLink",n=>(e={})=>bo(cr.type(n),e));w(gp,{displayName:"Command<toggleLinkCommand>",group:"Link"});var yp=U("UpdateLink",n=>(e={})=>(t,r)=>{if(!r)return!1;let i,o=-1,{selection:s}=t,{from:l,to:a}=s;if(t.doc.nodesBetween(l,l===a?a+1:a,(p,m)=>{if(cr.type(n).isInSet(p.marks))return i=p,o=m,!1}),!i)return!1;let u=i.marks.find(({type:p})=>p===cr.type(n));if(!u)return!1;let c=o,f=o+i.nodeSize,{tr:d}=t,h=cr.type(n).create({...u.attrs,...e});return h?(r(d.removeMark(c,f,u).addMark(c,f,h).setSelection(new H(d.selection.$anchor)).scrollIntoView()),!0):!1});w(yp,{displayName:"Command<updateLinkCommand>",group:"Link"});var xp=Jo("doc",()=>({content:"block+",parseMarkdown:{match:({type:n})=>n==="root",runner:(n,e,t)=>{n.injectRoot(e,t)}},toMarkdown:{match:n=>n.type.name==="doc",runner:(n,e)=>{n.openNode("root");let t=e.childCount>0?e.child(e.childCount-1):null,r=t?.type.name==="paragraph"&&t.content.size===0?e.content.cut(0,e.content.size-t.nodeSize):e.content;n.next(r)}}}));w(xp,{displayName:"NodeSchema<doc>",group:"Doc"});var kp=Object.freeze(["root","blockquote","listItem","footnoteDefinition"]),h0=new Set(["paragraph","heading","tableCell","link","linkReference","emphasis","strong","delete","footnote"]),Qo=Je(kp,"blockContainerTypes");w(Qo,{displayName:"Ctx<blockContainerTypes>",group:"Remark"});var cp=new Set;function bp(n){let e=n.isInjected(Qo.key)?n.get(Qo.key):kp,t=new Set;for(let r of e){if(h0.has(r)){cp.has(r)||(cp.add(r),console.warn(`[milkdown/preset-commonmark] "${r}" holds phrasing content and cannot be a block container; it is ignored in blockContainerTypes.`));continue}t.add(r)}return t}var d0=new Set(["paragraph","tableCell"]);function p0(n,e){return Pn(n,t=>t.type==="html"&&l0(t.value),(t,r)=>{let i=r[r.length-1];if(i){if(d0.has(i.type)){i.children.length===1&&(i.children=[]);return}if(e.has(i.type)){let o=t;return o.children=[],delete o.value,o.type="paragraph",ot}}})}var Xo=xn("remark-preserve-empty-line",n=>()=>e=>p0(e,bp(n)));w(Xo.plugin,{displayName:"Remark<remarkPreserveEmptyLine>",group:"Remark"});w(Xo.options,{displayName:"RemarkConfig<remarkPreserveEmptyLine>",group:"Remark"});var Ia=Ge("paragraph");w(Ia,{displayName:"Attr<paragraph>",group:"Paragraph"});var bn=_e("paragraph",n=>({content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM:e=>["p",n.get(Ia.key)(e),0],parseMarkdown:{match:e=>e.type==="paragraph",runner:(e,t,r)=>{e.openNode(r),t.children?e.next(t.children):e.addText(t.value||""),e.closeNode()}},toMarkdown:{match:e=>e.type.name==="paragraph",runner:(e,t)=>{e.openNode("paragraph"),(!t.content||t.content.size===0)&&m0(n)?e.addNode("html",void 0,o0):fp(e,t),e.closeNode()}}}));function m0(n){return n.isInjected(Xo.options.key)}w(bn.node,{displayName:"NodeSchema<paragraph>",group:"Paragraph"});w(bn.ctx,{displayName:"NodeSchemaCtx<paragraph>",group:"Paragraph"});var Ea=U("TurnIntoText",n=>()=>Jn(bn.type(n)));w(Ea,{displayName:"Command<turnIntoTextCommand>",group:"Paragraph"});var Oa=Re("paragraphKeymap",{TurnIntoText:{shortcuts:"Mod-Alt-0",command:n=>{let e=n.get(J);return()=>e.call(Ea.key)}}});w(Oa.ctx,{displayName:"KeymapCtx<paragraph>",group:"Paragraph"});w(Oa.shortcuts,{displayName:"Keymap<paragraph>",group:"Paragraph"});var g0=Array(6).fill(0).map((n,e)=>e+1);function y0(n){return n.textContent.toLowerCase().trim().replace(/\s+/g,"-")}var Zo=Je(y0,"headingIdGenerator");w(Zo,{displayName:"Ctx<HeadingIdGenerator>",group:"Heading"});var Ta=Ge("heading");w(Ta,{displayName:"Attr<heading>",group:"Heading"});var Sn=_e("heading",n=>{let e=n.get(Zo.key);return{content:"inline*",group:"block",defining:!0,attrs:{id:{default:"",validate:"string"},level:{default:1,validate:"number"}},parseDOM:g0.map(t=>({tag:`h${t}`,getAttrs:r=>{if(!(r instanceof HTMLElement))throw Nt(r);return{level:t,id:r.id}}})),toDOM:t=>[`h${t.attrs.level}`,{...n.get(Ta.key)(t),id:t.attrs.id||e(t)},0],parseMarkdown:{match:({type:t})=>t==="heading",runner:(t,r,i)=>{let o=r.depth;t.openNode(i,{level:o}),t.next(r.children),t.closeNode()}},toMarkdown:{match:t=>t.type.name==="heading",runner:(t,r)=>{t.openNode("heading",void 0,{depth:r.attrs.level}),fp(t,r),t.closeNode()}}}});w(Sn.node,{displayName:"NodeSchema<heading>",group:"Heading"});w(Sn.ctx,{displayName:"NodeSchemaCtx<heading>",group:"Heading"});var Sp=Ue(n=>Ml(/^(?<hashes>#+)\s$/,Sn.type(n),e=>{let t=e.groups?.hashes?.length||0,{$from:r}=n.get(Fe).state.selection,i=r.node();if(i.type.name==="heading"){let o=Number(i.attrs.level)+Number(t);return o>6&&(o=6),{level:o}}return{level:t}}));w(Sp,{displayName:"InputRule<wrapInHeadingInputRule>",group:"Heading"});var lt=U("WrapInHeading",n=>e=>(e??=1,e<1?Jn(bn.type(n)):Jn(Sn.type(n),{level:e})));w(lt,{displayName:"Command<wrapInHeadingCommand>",group:"Heading"});var Aa=U("DowngradeHeading",n=>()=>(e,t,r)=>{let{$from:i}=e.selection,o=i.node();if(o.type!==Sn.type(n)||!e.selection.empty||i.parentOffset!==0)return!1;let s=o.attrs.level-1;return s?(t?.(e.tr.setNodeMarkup(e.selection.$from.before(),void 0,{...o.attrs,level:s})),!0):Jn(bn.type(n))(e,t,r)});w(Aa,{displayName:"Command<downgradeHeadingCommand>",group:"Heading"});var va=Re("headingKeymap",{TurnIntoH1:{shortcuts:"Mod-Alt-1",command:n=>{let e=n.get(J);return()=>e.call(lt.key,1)}},TurnIntoH2:{shortcuts:"Mod-Alt-2",command:n=>{let e=n.get(J);return()=>e.call(lt.key,2)}},TurnIntoH3:{shortcuts:"Mod-Alt-3",command:n=>{let e=n.get(J);return()=>e.call(lt.key,3)}},TurnIntoH4:{shortcuts:"Mod-Alt-4",command:n=>{let e=n.get(J);return()=>e.call(lt.key,4)}},TurnIntoH5:{shortcuts:"Mod-Alt-5",command:n=>{let e=n.get(J);return()=>e.call(lt.key,5)}},TurnIntoH6:{shortcuts:"Mod-Alt-6",command:n=>{let e=n.get(J);return()=>e.call(lt.key,6)}},DowngradeHeading:{shortcuts:["Delete","Backspace"],command:n=>{let e=n.get(J);return()=>e.call(Aa.key)}}});w(va.ctx,{displayName:"KeymapCtx<heading>",group:"Heading"});w(va.shortcuts,{displayName:"Keymap<heading>",group:"Heading"});var Da=Ge("blockquote");w(Da,{displayName:"Attr<blockquote>",group:"Blockquote"});var bi=_e("blockquote",n=>({content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM:e=>["blockquote",n.get(Da.key)(e),0],parseMarkdown:{match:({type:e})=>e==="blockquote",runner:(e,t,r)=>{e.openNode(r).next(t.children).closeNode()}},toMarkdown:{match:e=>e.type.name==="blockquote",runner:(e,t)=>{e.openNode("blockquote").next(t.content).closeNode()}}}));w(bi.node,{displayName:"NodeSchema<blockquote>",group:"Blockquote"});w(bi.ctx,{displayName:"NodeSchemaCtx<blockquote>",group:"Blockquote"});var wp=Ue(n=>So(/^\s*>\s$/,bi.type(n)));w(wp,{displayName:"InputRule<wrapInBlockquoteInputRule>",group:"Blockquote"});var Si=U("WrapInBlockquote",n=>()=>ko(bi.type(n)));w(Si,{displayName:"Command<wrapInBlockquoteCommand>",group:"Blockquote"});var Ra=Re("blockquoteKeymap",{WrapInBlockquote:{shortcuts:"Mod-Shift-b",command:n=>{let e=n.get(J);return()=>e.call(Si.key)}}});w(Ra.ctx,{displayName:"KeymapCtx<blockquote>",group:"Blockquote"});w(Ra.shortcuts,{displayName:"Keymap<blockquote>",group:"Blockquote"});var Pa=Ge("codeBlock",()=>({pre:{},code:{}}));w(Pa,{displayName:"Attr<codeBlock>",group:"CodeBlock"});var wi=_e("code_block",n=>({content:"text*",group:"block",marks:"",defining:!0,code:!0,attrs:{language:{default:"",validate:"string"}},parseDOM:[{tag:"pre",preserveWhitespace:"full",getAttrs:e=>{if(!(e instanceof HTMLElement))throw Nt(e);return{language:e.dataset.language}}}],toDOM:e=>{let t=n.get(Pa.key)(e),r=e.attrs.language,i=r&&r.length>0?{"data-language":r}:void 0;return["pre",{...t.pre,...i},["code",t.code,0]]},parseMarkdown:{match:({type:e})=>e==="code",runner:(e,t,r)=>{let i=t.lang??"",o=t.value;e.openNode(r,{language:i}),o&&e.addText(o),e.closeNode()}},toMarkdown:{match:e=>e.type.name==="code_block",runner:(e,t)=>{e.addNode("code",void 0,t.content.firstChild?.text||"",{lang:t.attrs.language})}}}));w(wi.node,{displayName:"NodeSchema<codeBlock>",group:"CodeBlock"});w(wi.ctx,{displayName:"NodeSchemaCtx<codeBlock>",group:"CodeBlock"});var Cp=Ue(n=>Ml(/^```(?<language>[a-z]*)?[\s\n]$/,wi.type(n),e=>({language:e.groups?.language??""})));w(Cp,{displayName:"InputRule<createCodeBlockInputRule>",group:"CodeBlock"});var Ba=U("CreateCodeBlock",n=>(e="")=>Jn(wi.type(n),{language:e}));w(Ba,{displayName:"Command<createCodeBlockCommand>",group:"CodeBlock"});var x0=U("UpdateCodeBlockLanguage",()=>({pos:n,language:e}={pos:-1,language:""})=>(t,r)=>n>=0?(r?.(t.tr.setNodeAttribute(n,"language",e)),!0):!1);w(x0,{displayName:"Command<updateCodeBlockLanguageCommand>",group:"CodeBlock"});var La=Re("codeBlockKeymap",{CreateCodeBlock:{shortcuts:"Mod-Alt-c",command:n=>{let e=n.get(J);return()=>e.call(Ba.key)}}});w(La.ctx,{displayName:"KeymapCtx<codeBlock>",group:"CodeBlock"});w(La.shortcuts,{displayName:"Keymap<codeBlock>",group:"CodeBlock"});var za=Ge("image");w(za,{displayName:"Attr<image>",group:"Image"});var hr=_e("image",n=>({inline:!0,group:"inline",selectable:!0,draggable:!0,marks:"",atom:!0,defining:!0,isolating:!0,attrs:{src:{default:"",validate:"string"},alt:{default:"",validate:"string"},title:{default:"",validate:"string"}},parseDOM:[{tag:"img[src]",getAttrs:e=>{if(!(e instanceof HTMLElement))throw Nt(e);return{src:e.getAttribute("src")||"",alt:e.getAttribute("alt")||"",title:e.getAttribute("title")||e.getAttribute("alt")||""}}}],toDOM:e=>["img",{...n.get(za.key)(e),...e.attrs}],parseMarkdown:{match:({type:e})=>e==="image",runner:(e,t,r)=>{let i=t.url,o=t.alt??"",s=t.title??"";e.addNode(r,{src:i,alt:o,title:s})}},toMarkdown:{match:e=>e.type.name==="image",runner:(e,t)=>{e.addNode("image",void 0,void 0,{title:t.attrs.title,url:t.attrs.src,alt:t.attrs.alt})}}}));w(hr.node,{displayName:"NodeSchema<image>",group:"Image"});w(hr.ctx,{displayName:"NodeSchemaCtx<image>",group:"Image"});var Mp=U("InsertImage",n=>(e={})=>(t,r)=>{if(!r)return!0;let{src:i="",alt:o="",title:s=""}=e,l=hr.type(n).create({src:i,alt:o,title:s});return l&&r(t.tr.replaceSelectionWith(l).scrollIntoView()),!0});w(Mp,{displayName:"Command<insertImageCommand>",group:"Image"});var Np=U("UpdateImage",n=>(e={})=>(t,r)=>{let i=bh(t.selection,hr.type(n));if(!i)return!1;let{node:o,pos:s}=i,l={...o.attrs},{src:a,alt:u,title:c}=e;return a!==void 0&&(l.src=a),u!==void 0&&(l.alt=u),c!==void 0&&(l.title=c),r?.(t.tr.setNodeMarkup(s,void 0,l).scrollIntoView()),!0});w(Np,{displayName:"Command<updateImageCommand>",group:"Image"});var k0=Ue(n=>new Ce(/!\[(?<alt>.*?)]\((?<filename>.*?)\s*(?="|\))"?(?<title>[^"]+)?"?\)/,(e,t,r,i)=>{let[o,s,l="",a]=t;return o?e.tr.replaceWith(r,i,hr.type(n).create({src:l,alt:s,title:a})):null}));w(k0,{displayName:"InputRule<insertImageInputRule>",group:"Image"});var Yo=Ge("hardbreak",n=>({"data-type":"hardbreak","data-is-inline":n.attrs.isInline}));w(Yo,{displayName:"Attr<hardbreak>",group:"Hardbreak"});var kn=_e("hardbreak",n=>({inline:!0,group:"inline",attrs:{isInline:{default:!1,validate:"boolean"}},selectable:!1,parseDOM:[{tag:"br"},{tag:'span[data-type="hardbreak"]',getAttrs:()=>({isInline:!0})}],toDOM:e=>e.attrs.isInline?["span",n.get(Yo.key)(e)," "]:["br",n.get(Yo.key)(e)],parseMarkdown:{match:({type:e})=>e==="break",runner:(e,t,r)=>{e.addNode(r,{isInline:!!t.data?.isInline})}},leafText:()=>`
|
|
48
|
+
`,toMarkdown:{match:e=>e.type.name==="hardbreak",runner:(e,t)=>{t.attrs.isInline?e.addNode("text",void 0,`
|
|
49
|
+
`):e.addNode("break")}}}));w(kn.node,{displayName:"NodeSchema<hardbreak>",group:"Hardbreak"});w(kn.ctx,{displayName:"NodeSchemaCtx<hardbreak>",group:"Hardbreak"});var Fa=U("InsertHardbreak",n=>()=>(e,t)=>{let{selection:r,tr:i}=e;if(!(r instanceof H))return!1;if(r.empty){let o=r.$from.node();if(o.childCount>0&&o.lastChild?.type.name==="hardbreak")return t?.(i.replaceRangeWith(r.to-1,r.to,e.schema.node("paragraph")).setSelection(j.near(i.doc.resolve(r.to))).scrollIntoView()),!0}return t?.(i.setMeta("hardbreak",!0).replaceSelectionWith(kn.type(n).create()).scrollIntoView()),!0});w(Fa,{displayName:"Command<insertHardbreakCommand>",group:"Hardbreak"});var _a=Re("hardbreakKeymap",{InsertHardbreak:{shortcuts:"Shift-Enter",command:n=>{let e=n.get(J);return()=>e.call(Fa.key)}}});w(_a.ctx,{displayName:"KeymapCtx<hardbreak>",group:"Hardbreak"});w(_a.shortcuts,{displayName:"Keymap<hardbreak>",group:"Hardbreak"});var Va=Ge("hr");w(Va,{displayName:"Attr<hr>",group:"Hr"});var Ci=_e("hr",n=>({group:"block",parseDOM:[{tag:"hr"}],toDOM:e=>["hr",n.get(Va.key)(e)],parseMarkdown:{match:({type:e})=>e==="thematicBreak",runner:(e,t,r)=>{e.addNode(r)}},toMarkdown:{match:e=>e.type.name==="hr",runner:e=>{e.addNode("thematicBreak")}}}));w(Ci.node,{displayName:"NodeSchema<hr>",group:"Hr"});w(Ci.ctx,{displayName:"NodeSchemaCtx<hr>",group:"Hr"});var Ip=Ue(n=>new Ce(/^(?:---|___\s|\*\*\*\s)$/,(e,t,r,i)=>{let{tr:o}=e;return t[0]&&o.replaceWith(r-1,i,Ci.type(n).create()),o}));w(Ip,{displayName:"InputRule<insertHrInputRule>",group:"Hr"});var es=U("InsertHr",n=>()=>(e,t)=>{if(!t)return!0;let r=bn.node.type(n).create(),{tr:i,selection:o}=e,{from:s}=o,l=Ci.type(n).create();if(!l)return!0;let a=i.replaceSelectionWith(l).insert(s,r),u=j.findFrom(a.doc.resolve(s),1,!0);return u&&t(a.setSelection(u).scrollIntoView()),!0});w(es,{displayName:"Command<insertHrCommand>",group:"Hr"});var $a=Ge("bulletList");w($a,{displayName:"Attr<bulletList>",group:"BulletList"});var dr=_e("bullet_list",n=>({content:"listItem+",group:"block",attrs:{spread:{default:!1,validate:"boolean"}},parseDOM:[{tag:"ul",getAttrs:e=>{if(!(e instanceof HTMLElement))throw Nt(e);return{spread:e.dataset.spread==="true"}}}],toDOM:e=>["ul",{...n.get($a.key)(e),"data-spread":e.attrs.spread},0],parseMarkdown:{match:({type:e,ordered:t})=>e==="list"&&!t,runner:(e,t,r)=>{let i=t.spread??!1;e.openNode(r,{spread:i}).next(t.children).closeNode()}},toMarkdown:{match:e=>e.type.name==="bullet_list",runner:(e,t)=>{e.openNode("list",void 0,{ordered:!1,spread:t.attrs.spread}).next(t.content).closeNode()}}}));w(dr.node,{displayName:"NodeSchema<bulletList>",group:"BulletList"});w(dr.ctx,{displayName:"NodeSchemaCtx<bulletList>",group:"BulletList"});var Ep=Ue(n=>So(/^\s*([-+*])\s$/,dr.type(n)));w(Ep,{displayName:"InputRule<wrapInBulletListInputRule>",group:"BulletList"});var Mi=U("WrapInBulletList",n=>()=>ko(dr.type(n)));w(Mi,{displayName:"Command<wrapInBulletListCommand>",group:"BulletList"});var ja=Re("bulletListKeymap",{WrapInBulletList:{shortcuts:"Mod-Alt-8",command:n=>{let e=n.get(J);return()=>e.call(Mi.key)}}});w(ja.ctx,{displayName:"KeymapCtx<bulletListKeymap>",group:"BulletList"});w(ja.shortcuts,{displayName:"Keymap<bulletListKeymap>",group:"BulletList"});var qa=Ge("orderedList");w(qa,{displayName:"Attr<orderedList>",group:"OrderedList"});var pr=_e("ordered_list",n=>({content:"listItem+",group:"block",attrs:{order:{default:1,validate:"number"},spread:{default:!1,validate:"boolean"}},parseDOM:[{tag:"ol",getAttrs:e=>{if(!(e instanceof HTMLElement))throw Nt(e);return{spread:e.dataset.spread==="true",order:e.hasAttribute("start")?Number(e.getAttribute("start")):1}}}],toDOM:e=>["ol",{...n.get(qa.key)(e),...e.attrs.order===1?{}:{start:e.attrs.order},"data-spread":e.attrs.spread},0],parseMarkdown:{match:({type:e,ordered:t})=>e==="list"&&!!t,runner:(e,t,r)=>{let i=t.spread??!0;e.openNode(r,{spread:i,order:t.start??1}).next(t.children).closeNode()}},toMarkdown:{match:e=>e.type.name==="ordered_list",runner:(e,t)=>{e.openNode("list",void 0,{ordered:!0,start:t.attrs.order??1,spread:t.attrs.spread}),e.next(t.content),e.closeNode()}}}));w(pr.node,{displayName:"NodeSchema<orderedList>",group:"OrderedList"});w(pr.ctx,{displayName:"NodeSchemaCtx<orderedList>",group:"OrderedList"});var Op=Ue(n=>So(/^\s*(\d+)\.\s$/,pr.type(n),e=>({order:Number(e[1])}),(e,t)=>t.childCount+t.attrs.order===Number(e[1])));w(Op,{displayName:"InputRule<wrapInOrderedListInputRule>",group:"OrderedList"});var Wa=U("WrapInOrderedList",n=>()=>ko(pr.type(n)));w(Wa,{displayName:"Command<wrapInOrderedListCommand>",group:"OrderedList"});var Ha=Re("orderedListKeymap",{WrapInOrderedList:{shortcuts:"Mod-Alt-7",command:n=>{let e=n.get(J);return()=>e.call(Wa.key)}}});w(Ha.ctx,{displayName:"KeymapCtx<orderedList>",group:"OrderedList"});w(Ha.shortcuts,{displayName:"Keymap<orderedList>",group:"OrderedList"});var Ka=Ge("listItem");w(Ka,{displayName:"Attr<listItem>",group:"ListItem"});var qt=_e("list_item",n=>({group:"listItem",content:"paragraph block*",attrs:{label:{default:"\u2022",validate:"string"},listType:{default:"bullet",validate:"string"},spread:{default:!0,validate:"boolean"}},defining:!0,parseDOM:[{tag:"li",getAttrs:e=>{if(!(e instanceof HTMLElement))throw Nt(e);return{label:e.dataset.label,listType:e.dataset.listType,spread:e.dataset.spread==="true"}}}],toDOM:e=>["li",{...n.get(Ka.key)(e),"data-label":e.attrs.label,"data-list-type":e.attrs.listType,"data-spread":e.attrs.spread},0],parseMarkdown:{match:({type:e})=>e==="listItem",runner:(e,t,r)=>{let i=t.label!=null?`${t.label}.`:"\u2022",o=t.label!=null?"ordered":"bullet",s=t.spread??!0;e.openNode(r,{label:i,listType:o,spread:s}),e.next(t.children),e.closeNode()}},toMarkdown:{match:e=>e.type.name==="list_item",runner:(e,t)=>{e.openNode("listItem",void 0,{spread:t.attrs.spread}),e.next(t.content),e.closeNode()}}}));w(qt.node,{displayName:"NodeSchema<listItem>",group:"ListItem"});w(qt.ctx,{displayName:"NodeSchemaCtx<listItem>",group:"ListItem"});var Ua=U("SinkListItem",n=>()=>ap(qt.type(n)));w(Ua,{displayName:"Command<sinkListItemCommand>",group:"ListItem"});var Ja=U("LiftListItem",n=>()=>lp(qt.type(n)));w(Ja,{displayName:"Command<liftListItemCommand>",group:"ListItem"});var Ga=U("SplitListItem",n=>()=>sp(qt.type(n)));w(Ga,{displayName:"Command<splitListItemCommand>",group:"ListItem"});function b0(n){return(e,t,r)=>{let{selection:i}=e;if(!(i instanceof H))return!1;let{empty:o,$from:s}=i;return!o||s.parentOffset!==0||s.node(-1).type!==qt.type(n)?!1:bl(e,t,r)}}var Qa=U("LiftFirstListItem",n=>()=>b0(n));w(Qa,{displayName:"Command<liftFirstListItemCommand>",group:"ListItem"});var Ya=Re("listItemKeymap",{NextListItem:{shortcuts:"Enter",command:n=>{let e=n.get(J);return()=>e.call(Ga.key)}},SinkListItem:{shortcuts:["Tab","Mod-]"],command:n=>{let e=n.get(J);return()=>e.call(Ua.key)}},LiftListItem:{shortcuts:["Shift-Tab","Mod-["],command:n=>{let e=n.get(J);return()=>e.call(Ja.key)}},LiftFirstListItem:{shortcuts:["Backspace","Delete"],command:n=>{let e=n.get(J);return()=>e.call(Qa.key)}}});w(Ya.ctx,{displayName:"KeymapCtx<listItem>",group:"ListItem"});w(Ya.shortcuts,{displayName:"Keymap<listItem>",group:"ListItem"});var Tp=Jo("text",()=>({group:"inline",parseMarkdown:{match:({type:n})=>n==="text",runner:(n,e)=>{n.addText(e.value)}},toMarkdown:{match:n=>n.type.name==="text",runner:(n,e)=>{n.addNode("text",void 0,e.text)}}}));w(Tp,{displayName:"NodeSchema<text>",group:"Text"});var Xa=Ge("html");w(Xa,{displayName:"Attr<html>",group:"Html"});var Za=_e("html",n=>({atom:!0,group:"inline",inline:!0,attrs:{value:{default:"",validate:"string"}},toDOM:e=>{let t=document.createElement("span"),r={...n.get(Xa.key)(e),"data-value":e.attrs.value,"data-type":"html"};return t.textContent=e.attrs.value,["span",r,e.attrs.value]},parseDOM:[{tag:'span[data-type="html"]',getAttrs:e=>({value:e.dataset.value??""})}],parseMarkdown:{match:({type:e})=>e==="html",runner:(e,t,r)=>{e.addNode(r,{value:t.value})}},toMarkdown:{match:e=>e.type.name==="html",runner:(e,t)=>{e.addNode("html",void 0,t.attrs.value)}}}));w(Za.node,{displayName:"NodeSchema<html>",group:"Html"});w(Za.ctx,{displayName:"NodeSchemaCtx<html>",group:"Html"});var S0=[xp,Ia,bn,Zo,Ta,Sn,Yo,kn,Da,bi,Pa,wi,Va,Ci,za,hr,$a,dr,qa,pr,Ka,qt,xa,fr,ba,xi,wa,jt,Na,cr,Xa,Za,Tp].flat(),w0=[wp,Ep,Op,Cp,Ip,Sp].flat(),C0=[hp,dp,mp,pp],M0=U("IsMarkSelected",()=>n=>e=>{if(!n)return!1;let{doc:t,selection:r}=e;return t.rangeHasMark(r.from,r.to,n)}),N0=U("IsNoteSelected",()=>n=>e=>n?Sh(e,n).hasNode:!1),I0=U("ClearTextInCurrentBlock",()=>()=>(n,e)=>{let t=n.tr,{$from:r,$to:i}=t.selection,{pos:o}=r,{pos:s}=i,l=o-r.node().content.size;return l<0?!1:(t=t.deleteRange(l,s),e?.(t),!0)}),E0=U("SetBlockType",()=>n=>(e,t)=>{let{nodeType:r,attrs:i=null}=n??{};if(!r)return!1;let o=e.tr,{from:s,to:l}=o.selection;try{o.setBlockType(s,l,r,i)}catch{return!1}return t?.(o),!0}),O0=U("WrapInBlockType",()=>n=>(e,t)=>{let{nodeType:r,attrs:i=null}=n??{};if(!r)return!1;let o=e.tr;try{let{$from:s,$to:l}=o.selection,a=s.blockRange(l),u=a&&en(a,r,i);if(!u)return!1;o=o.wrap(a,u)}catch{return!1}return t?.(o),!0}),T0=U("AddBlockType",()=>n=>(e,t)=>{let{nodeType:r,attrs:i=null}=n??{};if(!r)return!1;let o=e.tr;try{let s=r instanceof Ae?r:r.createAndFill(i);if(!s)return!1;o.replaceSelectionWith(s)}catch{return!1}return t?.(o),!0}),A0=U("SelectTextNearPos",()=>n=>(e,t)=>{let{pos:r}=n??{};if(r==null)return!1;let i=(s,l,a)=>Math.min(Math.max(s,l),a),o=e.tr;try{let s=e.doc.resolve(i(r,0,e.doc.content.size));o.setSelection(H.near(s))}catch{return!1}return t?.(o.scrollIntoView()),!0}),v0=[Ea,Si,lt,Aa,Ba,Fa,es,Mp,Np,Wa,Mi,Ua,Ga,Ja,Qa,yi,Ca,ki,gp,yp,M0,N0,I0,E0,O0,T0,A0],D0=[Ra,La,_a,va,Ya,Ha,ja,Oa,ka,Ma,Sa].flat(),eu=xn("remarkAddOrderInList",()=>()=>n=>{Ye(n,"list",e=>{if(e.ordered){let t=e.start??1;e.children.forEach((r,i)=>{r.label=i+t})}})});w(eu.plugin,{displayName:"Remark<remarkAddOrderInListPlugin>",group:"Remark"});w(eu.options,{displayName:"RemarkConfig<remarkAddOrderInListPlugin>",group:"Remark"});var tu=xn("remarkLineBreak",()=>()=>n=>{let e=/[\t ]*(?:\r?\n|\r)/g;Ye(n,"text",(t,r,i)=>{if(!t.value||typeof t.value!="string")return;let o=[],s=0;e.lastIndex=0;let l=e.exec(t.value);for(;l;){let a=l.index;s!==a&&o.push({type:"text",value:t.value.slice(s,a)}),o.push({type:"break",data:{isInline:!0}}),s=a+l[0].length,l=e.exec(t.value)}if(o.length>0&&i&&typeof r=="number")return s<t.value.length&&o.push({type:"text",value:t.value.slice(s)}),i.children.splice(r,1,...o),r+o.length})});w(tu.plugin,{displayName:"Remark<remarkLineBreak>",group:"Remark"});w(tu.options,{displayName:"RemarkConfig<remarkLineBreak>",group:"Remark"});var nu=xn("remarkInlineLink",()=>Go);w(nu.plugin,{displayName:"Remark<remarkInlineLinkPlugin>",group:"Remark"});w(nu.options,{displayName:"RemarkConfig<remarkInlineLinkPlugin>",group:"Remark"});var R0=n=>!!n.children,P0=n=>n.type==="html";function B0(n,e){return t(n,0,null)[0];function t(r,i,o){if(R0(r)){let s=[];for(let l=0,a=r.children.length;l<a;l++){let u=r.children[l];if(u){let c=t(u,l,r);if(c)for(let f=0,d=c.length;f<d;f++){let h=c[f];h&&s.push(h)}}}r.children=s}return e(r,i,o)}}var ru=xn("remarkHTMLTransformer",n=>()=>e=>{let t=bp(n);B0(e,(r,i,o)=>P0(r)?(o&&t.has(o.type)&&(r.children=[i0(r)],delete r.value,r.type="paragraph"),[r]):[r])});w(ru.plugin,{displayName:"Remark<remarkHtmlTransformer>",group:"Remark"});w(ru.options,{displayName:"RemarkConfig<remarkHtmlTransformer>",group:"Remark"});var iu=xn("remarkMarker",()=>()=>(n,e)=>{let t=r=>e.value.charAt(r.position.start.offset);Ye(n,r=>["strong","emphasis"].includes(r.type),r=>{r.marker=t(r)})});w(iu.plugin,{displayName:"Remark<remarkMarker>",group:"Remark"});w(iu.options,{displayName:"RemarkConfig<remarkMarker>",group:"Remark"});var Ap=$t(()=>{let n=!1,e=new ae("MILKDOWN_INLINE_NODES_CURSOR"),t=new ie({key:e,state:{init(){return!1},apply(r){if(!r.selection.empty)return!1;let i=r.selection.$from,o=i.nodeBefore,s=i.nodeAfter;return!!(o&&s&&o.isInline&&!o.isText&&s.isInline&&!s.isText)}},props:{handleDOMEvents:{compositionend:(r,i)=>n?(n=!1,requestAnimationFrame(()=>{if(t.getState(r.state)){let o=r.state.selection.from;i.preventDefault(),r.dispatch(r.state.tr.insertText(i.data||"",o))}}),!0):!1,compositionstart:r=>(t.getState(r.state)&&(n=!0),!1),beforeinput:(r,i)=>{if(t.getState(r.state)&&i instanceof InputEvent&&i.data&&!n){let o=r.state.selection.from;return i.preventDefault(),r.dispatch(r.state.tr.insertText(i.data||"",o)),!0}return!1}},decorations(r){if(t.getState(r)){let i=r.selection.$from.pos,o=document.createElement("span"),s=et.widget(i,o,{side:-1}),l=document.createElement("span"),a=et.widget(i,l);return setTimeout(()=>{o.contentEditable="true",l.contentEditable="true"}),Me.create(r.doc,[s,a])}return Me.empty}}});return t});w(Ap,{displayName:"Prose<inlineNodesCursorPlugin>",group:"Prose"});var vp=$t(n=>new ie({key:new ae("MILKDOWN_HARDBREAK_MARKS"),appendTransaction:(e,t,r)=>{if(!e.length)return;let[i]=e;if(!i)return;let[o]=i.steps;if(i.getMeta("hardbreak")){if(!(o instanceof fe))return;let{from:s}=o;return r.tr.setNodeMarkup(s,kn.type(n),void 0,[])}if(o instanceof Zt){let s=r.tr,{from:l,to:a}=o;return r.doc.nodesBetween(l,a,(u,c)=>{u.type===kn.type(n)&&(s=s.setNodeMarkup(c,kn.type(n),void 0,[]))}),s}}}));w(vp,{displayName:"Prose<hardbreakClearMarkPlugin>",group:"Prose"});var ou=Je(["table","code_block"],"hardbreakFilterNodes");w(ou,{displayName:"Ctx<hardbreakFilterNodes>",group:"Prose"});var Dp=$t(n=>{let e=n.get(ou.key);return new ie({key:new ae("MILKDOWN_HARDBREAK_FILTER"),filterTransaction:(t,r)=>{let i=t.getMeta("hardbreak"),[o]=t.steps;if(i&&o){let{from:s}=o,l=r.doc.resolve(s),a=l.depth,u=!0;for(;a>0;)e.includes(l.node(a).type.name)&&(u=!1),a--;return u}return!0}})});w(Dp,{displayName:"Prose<hardbreakFilterPlugin>",group:"Prose"});var Rp=$t(n=>{let e=new ae("MILKDOWN_HEADING_ID"),t=r=>{if(r.composing)return;let i=n.get(Zo.key),o=r.state.tr.setMeta("addToHistory",!1),s=!1,l={};r.state.doc.descendants((a,u)=>{if(a.type===Sn.type(n)){if(a.textContent.trim().length===0)return;let c=a.attrs,f=i(a);l[f]?(l[f]+=1,f+=`-#${l[f]}`):l[f]=1,c.id!==f&&(s=!0,o.setMeta(e,!0).setNodeMarkup(u,void 0,{...c,id:f}))}}),s&&r.dispatch(o)};return new ie({key:e,view:r=>(t(r),{update:(i,o)=>{i.state.doc.eq(o.doc)||t(i)}})})});w(Rp,{displayName:"Prose<syncHeadingIdPlugin>",group:"Prose"});var Pp=$t(n=>{let e=(t,r,i)=>{if(!i.selection||t.some(f=>f.getMeta("addToHistory")===!1||!f.isGeneric))return null;let o=pr.type(n),s=dr.type(n),l=qt.type(n),a=(f,d,h=1)=>{let p=!1,m=`${d+h}.`;return f.label!==m&&(f.label=m,p=!0),p},u=i.tr,c=!1;return i.doc.descendants((f,d,h,p)=>{if(f.type===s){let m=f.maybeChild(0);m?.type===l&&m.attrs.listType==="ordered"&&(c=!0,u.setNodeMarkup(d,o,{spread:!0}),f.descendants((k,x,O,C)=>{if(k.type===l){let A={...k.attrs};a(A,C)&&(u=u.setNodeMarkup(x,void 0,A))}return!1}))}else if(f.type===l&&h?.type===o){let m={...f.attrs},k=!1;m.listType!=="ordered"&&(m.listType="ordered",k=!0),h?.maybeChild(0)&&(k=a(m,p,h?.attrs.order??1)),k&&(u=u.setNodeMarkup(d,void 0,m),c=!0)}}),c?u.setMeta("addToHistory",!1):null};return new ie({key:new ae("MILKDOWN_KEEP_LIST_ORDER"),appendTransaction:e})});w(Pp,{displayName:"Prose<syncListOrderPlugin>",group:"Prose"});var L0=[vp,ou,Dp,Ap,Qo,eu,nu,tu,ru,iu,Xo,Rp,Pp].flat(),Bp=[S0,w0,C0,v0,D0,L0].flat();var ts=200,me=function(){};me.prototype.append=function(e){return e.length?(e=me.from(e),!this.length&&e||e.length<ts&&this.leafAppend(e)||this.length<ts&&e.leafPrepend(this)||this.appendInner(e)):this};me.prototype.prepend=function(e){return e.length?me.from(e).append(this):this};me.prototype.appendInner=function(e){return new z0(this,e)};me.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?me.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};me.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};me.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)};me.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(o,s){return i.push(e(o,s))},t,r),i};me.from=function(e){return e instanceof me?e:e&&e.length?new Lp(e):me.empty};var Lp=(function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,o){return i==0&&o==this.length?this:new e(this.values.slice(i,o))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,o,s,l){for(var a=o;a<s;a++)if(i(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(i,o,s,l){for(var a=o-1;a>=s;a--)if(i(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=ts)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=ts)return new e(i.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e})(me);me.empty=new Lp([]);var z0=(function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,i,o,s){var l=this.left.length;if(i<l&&this.left.forEachInner(r,i,Math.min(o,l),s)===!1||o>l&&this.right.forEachInner(r,Math.max(i-l,0),Math.min(this.length,o)-l,s+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,o,s){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(r,i-l,Math.max(o,l)-l,s+l)===!1||o<l&&this.left.forEachInvertedInner(r,Math.min(i,l),o,s)===!1)return!1},e.prototype.sliceInner=function(r,i){if(r==0&&i==this.length)return this;var o=this.left.length;return i<=o?this.left.slice(r,i):r>=o?this.right.slice(r-o,i-o):this.left.slice(r,o).append(this.right.slice(0,i-o))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(me),su=me;var F0=500,Cn=class n{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,o;t&&(i=this.remapping(r,this.items.length),o=i.maps.length);let s=e.tr,l,a,u=[],c=[];return this.items.forEach((f,d)=>{if(!f.step){i||(i=this.remapping(r,d+1),o=i.maps.length),o--,c.push(f);return}if(i){c.push(new at(f.map));let h=f.step.map(i.slice(o)),p;h&&s.maybeStep(h).doc&&(p=s.mapping.maps[s.mapping.maps.length-1],u.push(new at(p,void 0,void 0,u.length+c.length))),o--,p&&i.appendMap(p,o)}else s.maybeStep(f.step);if(f.selection)return l=i?f.selection.map(i.slice(o)):f.selection,a=new n(this.items.slice(0,r).append(c.reverse().concat(u)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:s,selection:l}}addTransform(e,t,r,i){let o=[],s=this.eventCount,l=this.items,a=!i&&l.length?l.get(l.length-1):null;for(let c=0;c<e.steps.length;c++){let f=e.steps[c].invert(e.docs[c]),d=new at(e.mapping.maps[c],f,t),h;(h=a&&a.merge(d))&&(d=h,c?o.pop():l=l.slice(0,l.length-1)),o.push(d),t&&(s++,t=void 0),i||(a=d)}let u=s-r.depth;return u>V0&&(l=_0(l,u),s-=u),new n(l.append(o),s)}remapping(e,t){let r=new Kr;return this.items.forEach((i,o)=>{let s=i.mirrorOffset!=null&&o-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,s)},e,t),r}addMaps(e){return this.eventCount==0?this:new n(this.items.append(e.map(t=>new at(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;t=Math.min(this.items.length,t);let r=[],i=this.items.length-t,o=e.mapping,s=e.steps.length,l=this.eventCount;this.items.forEach(d=>{d.selection&&l--},i);let a=t;this.items.forEach(d=>{let h=o.getMirror(--a);if(h==null)return;s=Math.min(s,h);let p=o.maps[h];if(d.step){let m=e.steps[h].invert(e.docs[h]),k=d.selection&&d.selection.map(o.slice(a+1,h));k&&l++,r.push(new at(p,m,k))}else r.push(new at(p))},i);let u=[];for(let d=t;d<s;d++)u.push(new at(o.maps[d]));let c=this.items.slice(0,i).append(u).append(r),f=new n(c,l);return f.emptyItemCount()>F0&&(f=f.compress(this.items.length-r.length)),f}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,i=[],o=0;return this.items.forEach((s,l)=>{if(l>=e)i.push(s),s.selection&&o++;else if(s.step){let a=s.step.map(t.slice(r)),u=a&&a.getMap();if(r--,u&&t.appendMap(u,r),a){let c=s.selection&&s.selection.map(t.slice(r));c&&o++;let f=new at(u.invert(),a,c),d,h=i.length-1;(d=i.length&&i[h].merge(f))?i[h]=d:i.push(f)}}else s.map&&r--},this.items.length,0),new n(su.from(i.reverse()),o)}};Cn.empty=new Cn(su.empty,0);function _0(n,e){let t;return n.forEach((r,i)=>{if(r.selection&&e--==0)return t=i,!1}),n.slice(t)}var at=class n{constructor(e,t,r,i){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new n(t.getMap().invert(),t,this.selection)}}},ut=class{constructor(e,t,r,i,o){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=i,this.prevComposition=o}},V0=20;function $0(n,e,t,r){let i=t.getMeta(wn),o;if(i)return i.historyState;t.getMeta(W0)&&(n=new ut(n.done,n.undone,null,0,-1));let s=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(s&&s.getMeta(wn))return s.getMeta(wn).redo?new ut(n.done.addTransform(t,void 0,r,ns(e)),n.undone,zp(t.mapping.maps),n.prevTime,n.prevComposition):new ut(n.done,n.undone.addTransform(t,void 0,r,ns(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!s&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-r.newGroupDelay||!j0(t,n.prevRanges)),u=s?lu(n.prevRanges,t.mapping):zp(t.mapping.maps);return new ut(n.done.addTransform(t,a?e.selection.getBookmark():void 0,r,ns(e)),Cn.empty,u,t.time,l??n.prevComposition)}else return(o=t.getMeta("rebased"))?new ut(n.done.rebased(t,o),n.undone.rebased(t,o),lu(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new ut(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),lu(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function j0(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,i)=>{for(let o=0;o<e.length;o+=2)r<=e[o+1]&&i>=e[o]&&(t=!0)}),t}function zp(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,i,o,s)=>e.push(o,s));return e}function lu(n,e){if(!n)return null;let t=[];for(let r=0;r<n.length;r+=2){let i=e.map(n[r],1),o=e.map(n[r+1],-1);i<=o&&t.push(i,o)}return t}function q0(n,e,t){let r=ns(e),i=wn.get(e).spec.config,o=(t?n.undone:n.done).popEvent(e,r);if(!o)return null;let s=o.selection.resolve(o.transform.doc),l=(t?n.done:n.undone).addTransform(o.transform,e.selection.getBookmark(),i,r),a=new ut(t?l:o.remaining,t?o.remaining:l,null,0,-1);return o.transform.setSelection(s).setMeta(wn,{redo:t,historyState:a})}var au=!1,Fp=null;function ns(n){let e=n.plugins;if(Fp!=e){au=!1,Fp=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){au=!0;break}}return au}var wn=new ae("history"),W0=new ae("closeHistory");function _p(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new ie({key:wn,state:{init(){return new ut(Cn.empty,Cn.empty,null,0,-1)},apply(e,t,r){return $0(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,i=r=="historyUndo"?uu:r=="historyRedo"?cu:null;return!i||!e.editable?!1:(t.preventDefault(),i(e.state,e.dispatch))}}}})}function rs(n,e){return(t,r)=>{let i=wn.getState(t);if(!i||(n?i.undone:i.done).eventCount==0)return!1;if(r){let o=q0(i,t,n);o&&r(e?o.scrollIntoView():o)}return!0}}var uu=rs(!1,!0),cu=rs(!0,!0),xT=rs(!1,!1),kT=rs(!0,!1);function mr(n,e){return Object.assign(n,{meta:{package:"@milkdown/plugin-history",...e}}),n}var fu=U("Undo",()=>()=>uu);mr(fu,{displayName:"Command<undo>"});var hu=U("Redo",()=>()=>cu);mr(hu,{displayName:"Command<redo>"});var du=Je({},"historyProviderConfig");mr(du,{displayName:"Ctx<historyProviderConfig>"});var Vp=$t(n=>_p(n.get(du.key)));mr(Vp,{displayName:"Ctx<historyProviderPlugin>"});var pu=Re("historyKeymap",{Undo:{shortcuts:"Mod-z",command:n=>{let e=n.get(J);return()=>e.call(fu.key)}},Redo:{shortcuts:["Mod-y","Shift-Mod-z"],command:n=>{let e=n.get(J);return()=>e.call(hu.key)}}});mr(pu.ctx,{displayName:"KeymapCtx<history>"});mr(pu.shortcuts,{displayName:"Keymap<history>"});var $p=[du,Vp,pu,fu,hu].flat();var H0=typeof global=="object"&&global&&global.Object===Object&&global,jp=H0;var K0=typeof self=="object"&&self&&self.Object===Object&&self,U0=jp||K0||Function("return this")(),is=U0;var J0=is.Symbol,gr=J0;var qp=Object.prototype,G0=qp.hasOwnProperty,Q0=qp.toString,Ni=gr?gr.toStringTag:void 0;function Y0(n){var e=G0.call(n,Ni),t=n[Ni];try{n[Ni]=void 0;var r=!0}catch{}var i=Q0.call(n);return r&&(e?n[Ni]=t:delete n[Ni]),i}var Wp=Y0;var X0=Object.prototype,Z0=X0.toString;function e1(n){return Z0.call(n)}var Hp=e1;var t1="[object Null]",n1="[object Undefined]",Kp=gr?gr.toStringTag:void 0;function r1(n){return n==null?n===void 0?n1:t1:Kp&&Kp in Object(n)?Wp(n):Hp(n)}var Up=r1;function i1(n){return n!=null&&typeof n=="object"}var Jp=i1;var o1="[object Symbol]";function s1(n){return typeof n=="symbol"||Jp(n)&&Up(n)==o1}var Gp=s1;var l1=/\s/;function a1(n){for(var e=n.length;e--&&l1.test(n.charAt(e)););return e}var Qp=a1;var u1=/^\s+/;function c1(n){return n&&n.slice(0,Qp(n)+1).replace(u1,"")}var Yp=c1;function f1(n){var e=typeof n;return n!=null&&(e=="object"||e=="function")}var Ii=f1;var Xp=NaN,h1=/^[-+]0x[0-9a-f]+$/i,d1=/^0b[01]+$/i,p1=/^0o[0-7]+$/i,m1=parseInt;function g1(n){if(typeof n=="number")return n;if(Gp(n))return Xp;if(Ii(n)){var e=typeof n.valueOf=="function"?n.valueOf():n;n=Ii(e)?e+"":e}if(typeof n!="string")return n===0?n:+n;n=Yp(n);var t=d1.test(n);return t||p1.test(n)?m1(n.slice(2),t?2:8):h1.test(n)?Xp:+n}var mu=g1;var y1=function(){return is.Date.now()},ss=y1;var x1="Expected a function",k1=Math.max,b1=Math.min;function S1(n,e,t){var r,i,o,s,l,a,u=0,c=!1,f=!1,d=!0;if(typeof n!="function")throw new TypeError(x1);e=mu(e)||0,Ii(t)&&(c=!!t.leading,f="maxWait"in t,o=f?k1(mu(t.maxWait)||0,e):o,d="trailing"in t?!!t.trailing:d);function h(S){var I=r,R=i;return r=i=void 0,u=S,s=n.apply(R,I),s}function p(S){return u=S,l=setTimeout(x,e),c?h(S):s}function m(S){var I=S-a,R=S-u,q=e-I;return f?b1(q,o-R):q}function k(S){var I=S-a,R=S-u;return a===void 0||I>=e||I<0||f&&R>=o}function x(){var S=ss();if(k(S))return O(S);l=setTimeout(x,m(S))}function O(S){return l=void 0,d&&r?h(S):(r=i=void 0,s)}function C(){l!==void 0&&clearTimeout(l),u=0,r=a=i=l=void 0}function A(){return l===void 0?s:O(ss())}function z(){var S=ss(),I=k(S);if(r=arguments,i=this,a=S,I){if(l===void 0)return p(a);if(f)return clearTimeout(l),l=setTimeout(x,e),h(a)}return l===void 0&&(l=setTimeout(x,e)),s}return z.cancel=C,z.flush=A,z}var gu=S1;var Zp=class{constructor(){this.beforeMountedListeners=[],this.mountedListeners=[],this.updatedListeners=[],this.selectionUpdatedListeners=[],this.markdownUpdatedListeners=[],this.blurListeners=[],this.focusListeners=[],this.destroyListeners=[],this.beforeMount=n=>(this.beforeMountedListeners.push(n),this),this.mounted=n=>(this.mountedListeners.push(n),this),this.updated=n=>(this.updatedListeners.push(n),this)}get listeners(){return{beforeMount:this.beforeMountedListeners,mounted:this.mountedListeners,updated:this.updatedListeners,markdownUpdated:this.markdownUpdatedListeners,blur:this.blurListeners,focus:this.focusListeners,destroy:this.destroyListeners,selectionUpdated:this.selectionUpdatedListeners}}markdownUpdated(n){return this.markdownUpdatedListeners.push(n),this}blur(n){return this.blurListeners.push(n),this}focus(n){return this.focusListeners.push(n),this}destroy(n){return this.destroyListeners.push(n),this}selectionUpdated(n){return this.selectionUpdatedListeners.push(n),this}},ls=$(new Zp,"listener"),w1=new ae("MILKDOWN_LISTENER"),yu=n=>(n.inject(ls,new Zp),async()=>{await n.wait(Ct);let{listeners:e}=n.get(ls);e.beforeMount.forEach(u=>u(n)),await n.wait(sr);let t=n.get(yn),r=null,i=null,o=null,s=null,l=gu(()=>{if(!s)return;let{doc:u}=s;if(e.updated.length>0&&r&&!r.eq(u)&&e.updated.forEach(c=>{c(n,u,r)}),e.markdownUpdated.length>0&&r&&!r.eq(u)){let c=t(u);e.markdownUpdated.forEach(f=>{f(n,c,i)}),i=c}r=u,s=null},200),a=new ie({key:w1,view:()=>({destroy:()=>{l.cancel(),e.destroy.forEach(u=>u(n))}}),props:{handleDOMEvents:{focus:()=>(e.focus.forEach(u=>u(n)),!1),blur:()=>(e.blur.forEach(u=>u(n)),!1)}},state:{init:(u,c)=>{r=c.doc,i=t(c.doc)},apply:u=>{let c=u.selection;(!o&&c||o&&!c.eq(o))&&(e.selectionUpdated.forEach(f=>{f(n,c,o)}),o=c),!(!(u.docChanged||u.storedMarksSet)||u.getMeta("addToHistory")===!1)&&(s=u,l())}}});n.update(nt,u=>u.concat(a)),await n.wait(di),e.mounted.forEach(u=>u(n))});yu.meta={package:"@milkdown/plugin-listener",displayName:"Listener"};var C1={bold:ki,italic:yi,list:Mi,quote:Si,rule:es};async function pA(n){let e=n.root,t=typeof n.onUpdate=="function"?n.onUpdate:()=>{},r=typeof n.value=="string"?n.value:"",i=!1,o=await ep.make().config(s=>{s.set(pi,e),s.set(fi,r),s.get(ls).markdownUpdated((l,a)=>{i||a!==r&&(r=a,t(a))})}).use(Bp).use($p).use(yu).create();return{destroy(){try{o.destroy()}catch{}},setMarkdown(s){let l=typeof s=="string"?s:"";if(l!==r){r=l,i=!0;try{o.action(op(l))}finally{queueMicrotask(()=>{i=!1})}}},getMarkdown(){return o.action(ip())},run(s){try{if(s==="h2"){o.action(ga(lt.key,2));return}let l=C1[s];l&&o.action(ga(l.key))}catch{}},focus(){let s=e.querySelector(".ProseMirror");s&&typeof s.focus=="function"&&s.focus()},insert(s,l){let a=typeof s=="string"?s:"";if(a==="")return!1;try{let u=o.ctx.get(Fe),c=u.state.selection.from;if(l&&Number.isFinite(l.x)&&Number.isFinite(l.y))try{let f=u.posAtCoords({left:l.x,top:l.y});f&&Number.isInteger(f.pos)&&(c=f.pos)}catch{}return u.dispatch(u.state.tr.insertText(a,c)),u.focus(),!0}catch{return!1}}}}export{pA as createDiaryEditor};
|