milkdown-inline-diff 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs ADDED
@@ -0,0 +1,75 @@
1
+ "use strict";var Pm=n=>{throw TypeError(n)};var Wc=(n,e,t)=>e.has(n)||Pm("Cannot "+t);var j=(n,e,t)=>(Wc(n,e,"read from private field"),t?t.call(n):e.get(n)),xe=(n,e,t)=>e.has(n)?Pm("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),Ke=(n,e,t,r)=>(Wc(n,e,"write to private field"),r?r.call(n,t):e.set(n,t),t),Bm=(n,e,t)=>(Wc(n,e,"access private method"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ae=require("@milkdown/ctx"),nn=require("@milkdown/prose"),LN={};function Sh(n,e){const t=LN,r=typeof t.includeImageAlt=="boolean"?t.includeImageAlt:!0,i=typeof t.includeHtml=="boolean"?t.includeHtml:!0;return Xy(n,r,i)}function Xy(n,e,t){if(PN(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 Fm(n.children,e,t)}return Array.isArray(n)?Fm(n,e,t):""}function Fm(n,e,t){const r=[];let i=-1;for(;++i<n.length;)r[i]=Xy(n[i],e,t);return r.join("")}function PN(n){return!!(n&&typeof n=="object")}const zm=document.createElement("i");function vh(n){const e="&"+n+";";zm.innerHTML=e;const t=zm.textContent;return t.charCodeAt(t.length-1)===59&&n!=="semi"||t===e?!1:t}function Qt(n,e,t,r){const i=n.length;let 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 gn(n,e){return n.length>0?(Qt(n,n.length,0,e),n):e}const $m={}.hasOwnProperty;function Qy(n){const e={};let t=-1;for(;++t<n.length;)BN(e,n[t]);return e}function BN(n,e){let t;for(t in e){const i=($m.call(n,t)?n[t]:void 0)||(n[t]={}),o=e[t];let s;if(o)for(s in o){$m.call(i,s)||(i[s]=[]);const a=o[s];FN(i[s],Array.isArray(a)?a:a?[a]:[])}}}function FN(n,e){let t=-1;const r=[];for(;++t<e.length;)(e[t].add==="after"?n:r).push(e[t]);Qt(n,0,0,r)}function Zy(n,e){const 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?"�":String.fromCodePoint(t)}function _n(n){return n.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const St=Zr(/[A-Za-z]/),_t=Zr(/[\dA-Za-z]/),zN=Zr(/[#-'*+\--9=?A-Z^-~]/);function ba(n){return n!==null&&(n<32||n===127)}const Ff=Zr(/\d/),$N=Zr(/[\dA-Fa-f]/),WN=Zr(/[!-/:-@[-`{-~]/);function ne(n){return n!==null&&n<-2}function Fe(n){return n!==null&&(n<0||n===32)}function Ce(n){return n===-2||n===-1||n===32}const Qa=Zr(new RegExp("\\p{P}|\\p{S}","u")),Di=Zr(/\s/);function Zr(n){return e;function e(t){return t!==null&&t>-1&&n.test(String.fromCharCode(t))}}function Ae(n,e,t,r){const i=r?r-1:Number.POSITIVE_INFINITY;let o=0;return s;function s(u){return Ce(u)?(n.enter(t),a(u)):e(u)}function a(u){return Ce(u)&&o++<i?(n.consume(u),a):(n.exit(t),e(u))}}const VN={tokenize:HN};function HN(n){const e=n.attempt(this.parser.constructs.contentInitial,r,i);let t;return e;function r(a){if(a===null){n.consume(a);return}return n.enter("lineEnding"),n.consume(a),n.exit("lineEnding"),Ae(n,e,"linePrefix")}function i(a){return n.enter("paragraph"),o(a)}function o(a){const u=n.enter("chunkText",{contentType:"text",previous:t});return t&&(t.next=u),t=u,s(a)}function s(a){if(a===null){n.exit("chunkText"),n.exit("paragraph"),n.consume(a);return}return ne(a)?(n.consume(a),n.exit("chunkText"),o):(n.consume(a),s)}}const qN={tokenize:KN},Wm={tokenize:UN};function KN(n){const e=this,t=[];let r=0,i,o,s;return a;function a(R){if(r<t.length){const K=t[r];return e.containerState=K[1],n.attempt(K[0].continuation,u,f)(R)}return f(R)}function u(R){if(r++,e.containerState._closeFlow){e.containerState._closeFlow=void 0,i&&L();const K=e.events.length;let q=K,O;for(;q--;)if(e.events[q][0]==="exit"&&e.events[q][1].type==="chunkFlow"){O=e.events[q][1].end;break}S(r);let H=K;for(;H<e.events.length;)e.events[H][1].end={...O},H++;return Qt(e.events,q+1,0,e.events.slice(K)),e.events.length=H,f(R)}return a(R)}function f(R){if(r===t.length){if(!i)return m(R);if(i.currentConstruct&&i.currentConstruct.concrete)return k(R);e.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return e.containerState={},n.check(Wm,h,d)(R)}function h(R){return i&&L(),S(r),m(R)}function d(R){return e.parser.lazy[e.now().line]=r!==t.length,s=e.now().offset,k(R)}function m(R){return e.containerState={},n.attempt(Wm,g,k)(R)}function g(R){return r++,t.push([e.currentConstruct,e.containerState]),m(R)}function k(R){if(R===null){i&&L(),S(0),n.consume(R);return}return i=i||e.parser.flow(e.now()),n.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:o}),C(R)}function C(R){if(R===null){v(n.exit("chunkFlow"),!0),S(0),n.consume(R);return}return ne(R)?(n.consume(R),v(n.exit("chunkFlow")),r=0,e.interrupt=void 0,a):(n.consume(R),C)}function v(R,K){const q=e.sliceStream(R);if(K&&q.push(null),R.previous=o,o&&(o.next=R),o=R,i.defineSkip(R.start),i.write(q),e.parser.lazy[R.start.line]){let O=i.events.length;for(;O--;)if(i.events[O][1].start.offset<s&&(!i.events[O][1].end||i.events[O][1].end.offset>s))return;const H=e.events.length;let X=H,te,D;for(;X--;)if(e.events[X][0]==="exit"&&e.events[X][1].type==="chunkFlow"){if(te){D=e.events[X][1].end;break}te=!0}for(S(r),O=H;O<e.events.length;)e.events[O][1].end={...D},O++;Qt(e.events,X+1,0,e.events.slice(H)),e.events.length=O}}function S(R){let K=t.length;for(;K-- >R;){const q=t[K];e.containerState=q[1],q[0].exit.call(e,n)}t.length=R}function L(){i.write([null]),o=void 0,i=void 0,e.containerState._closeFlow=void 0}}function UN(n,e,t){return Ae(n,n.attempt(this.parser.constructs.document,e,t),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function To(n){if(n===null||Fe(n)||Di(n))return 1;if(Qa(n))return 2}function Za(n,e,t){const r=[];let i=-1;for(;++i<n.length;){const o=n[i].resolveAll;o&&!r.includes(o)&&(e=o(e,t),r.push(o))}return e}const zf={name:"attention",resolveAll:jN,tokenize:JN};function jN(n,e){let t=-1,r,i,o,s,a,u,f,h;for(;++t<n.length;)if(n[t][0]==="enter"&&n[t][1].type==="attentionSequence"&&n[t][1]._close){for(r=t;r--;)if(n[r][0]==="exit"&&n[r][1].type==="attentionSequence"&&n[r][1]._open&&e.sliceSerialize(n[r][1]).charCodeAt(0)===e.sliceSerialize(n[t][1]).charCodeAt(0)){if((n[r][1]._close||n[t][1]._open)&&(n[t][1].end.offset-n[t][1].start.offset)%3&&!((n[r][1].end.offset-n[r][1].start.offset+n[t][1].end.offset-n[t][1].start.offset)%3))continue;u=n[r][1].end.offset-n[r][1].start.offset>1&&n[t][1].end.offset-n[t][1].start.offset>1?2:1;const d={...n[r][1].end},m={...n[t][1].start};Vm(d,-u),Vm(m,u),s={type:u>1?"strongSequence":"emphasisSequence",start:d,end:{...n[r][1].end}},a={type:u>1?"strongSequence":"emphasisSequence",start:{...n[t][1].start},end:m},o={type:u>1?"strongText":"emphasisText",start:{...n[r][1].end},end:{...n[t][1].start}},i={type:u>1?"strong":"emphasis",start:{...s.start},end:{...a.end}},n[r][1].end={...s.start},n[t][1].start={...a.end},f=[],n[r][1].end.offset-n[r][1].start.offset&&(f=gn(f,[["enter",n[r][1],e],["exit",n[r][1],e]])),f=gn(f,[["enter",i,e],["enter",s,e],["exit",s,e],["enter",o,e]]),f=gn(f,Za(e.parser.constructs.insideSpan.null,n.slice(r+1,t),e)),f=gn(f,[["exit",o,e],["enter",a,e],["exit",a,e],["exit",i,e]]),n[t][1].end.offset-n[t][1].start.offset?(h=2,f=gn(f,[["enter",n[t][1],e],["exit",n[t][1],e]])):h=0,Qt(n,r-1,t-r+3,f),t=r+f.length-h-2;break}}for(t=-1;++t<n.length;)n[t][1].type==="attentionSequence"&&(n[t][1].type="data");return n}function JN(n,e){const t=this.parser.constructs.attentionMarkers.null,r=this.previous,i=To(r);let o;return s;function s(u){return o=u,n.enter("attentionSequence"),a(u)}function a(u){if(u===o)return n.consume(u),a;const f=n.exit("attentionSequence"),h=To(u),d=!h||h===2&&i||t.includes(u),m=!i||i===2&&h||t.includes(r);return f._open=!!(o===42?d:d&&(i||!m)),f._close=!!(o===42?m:m&&(h||!d)),e(u)}}function Vm(n,e){n.column+=e,n.offset+=e,n._bufferIndex+=e}const GN={name:"autolink",tokenize:YN};function YN(n,e,t){let r=0;return i;function i(g){return n.enter("autolink"),n.enter("autolinkMarker"),n.consume(g),n.exit("autolinkMarker"),n.enter("autolinkProtocol"),o}function o(g){return St(g)?(n.consume(g),s):g===64?t(g):f(g)}function s(g){return g===43||g===45||g===46||_t(g)?(r=1,a(g)):f(g)}function a(g){return g===58?(n.consume(g),r=0,u):(g===43||g===45||g===46||_t(g))&&r++<32?(n.consume(g),a):(r=0,f(g))}function u(g){return g===62?(n.exit("autolinkProtocol"),n.enter("autolinkMarker"),n.consume(g),n.exit("autolinkMarker"),n.exit("autolink"),e):g===null||g===32||g===60||ba(g)?t(g):(n.consume(g),u)}function f(g){return g===64?(n.consume(g),h):zN(g)?(n.consume(g),f):t(g)}function h(g){return _t(g)?d(g):t(g)}function d(g){return g===46?(n.consume(g),r=0,h):g===62?(n.exit("autolinkProtocol").type="autolinkEmail",n.enter("autolinkMarker"),n.consume(g),n.exit("autolinkMarker"),n.exit("autolink"),e):m(g)}function m(g){if((g===45||_t(g))&&r++<63){const k=g===45?m:d;return n.consume(g),k}return t(g)}}const Us={partial:!0,tokenize:XN};function XN(n,e,t){return r;function r(o){return Ce(o)?Ae(n,i,"linePrefix")(o):i(o)}function i(o){return o===null||ne(o)?e(o):t(o)}}const e1={continuation:{tokenize:ZN},exit:eM,name:"blockQuote",tokenize:QN};function QN(n,e,t){const r=this;return i;function i(s){if(s===62){const a=r.containerState;return a.open||(n.enter("blockQuote",{_container:!0}),a.open=!0),n.enter("blockQuotePrefix"),n.enter("blockQuoteMarker"),n.consume(s),n.exit("blockQuoteMarker"),o}return t(s)}function o(s){return Ce(s)?(n.enter("blockQuotePrefixWhitespace"),n.consume(s),n.exit("blockQuotePrefixWhitespace"),n.exit("blockQuotePrefix"),e):(n.exit("blockQuotePrefix"),e(s))}}function ZN(n,e,t){const r=this;return i;function i(s){return Ce(s)?Ae(n,o,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(s):o(s)}function o(s){return n.attempt(e1,e,t)(s)}}function eM(n){n.exit("blockQuote")}const t1={name:"characterEscape",tokenize:tM};function tM(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 WN(o)?(n.enter("characterEscapeValue"),n.consume(o),n.exit("characterEscapeValue"),n.exit("characterEscape"),e):t(o)}}const n1={name:"characterReference",tokenize:nM};function nM(n,e,t){const r=this;let i=0,o,s;return a;function a(d){return n.enter("characterReference"),n.enter("characterReferenceMarker"),n.consume(d),n.exit("characterReferenceMarker"),u}function u(d){return d===35?(n.enter("characterReferenceMarkerNumeric"),n.consume(d),n.exit("characterReferenceMarkerNumeric"),f):(n.enter("characterReferenceValue"),o=31,s=_t,h(d))}function f(d){return d===88||d===120?(n.enter("characterReferenceMarkerHexadecimal"),n.consume(d),n.exit("characterReferenceMarkerHexadecimal"),n.enter("characterReferenceValue"),o=6,s=$N,h):(n.enter("characterReferenceValue"),o=7,s=Ff,h(d))}function h(d){if(d===59&&i){const m=n.exit("characterReferenceValue");return s===_t&&!vh(r.sliceSerialize(m))?t(d):(n.enter("characterReferenceMarker"),n.consume(d),n.exit("characterReferenceMarker"),n.exit("characterReference"),e)}return s(d)&&i++<o?(n.consume(d),h):t(d)}}const Hm={partial:!0,tokenize:iM},qm={concrete:!0,name:"codeFenced",tokenize:rM};function rM(n,e,t){const r=this,i={partial:!0,tokenize:q};let o=0,s=0,a;return u;function u(O){return f(O)}function f(O){const H=r.events[r.events.length-1];return o=H&&H[1].type==="linePrefix"?H[2].sliceSerialize(H[1],!0).length:0,a=O,n.enter("codeFenced"),n.enter("codeFencedFence"),n.enter("codeFencedFenceSequence"),h(O)}function h(O){return O===a?(s++,n.consume(O),h):s<3?t(O):(n.exit("codeFencedFenceSequence"),Ce(O)?Ae(n,d,"whitespace")(O):d(O))}function d(O){return O===null||ne(O)?(n.exit("codeFencedFence"),r.interrupt?e(O):n.check(Hm,C,K)(O)):(n.enter("codeFencedFenceInfo"),n.enter("chunkString",{contentType:"string"}),m(O))}function m(O){return O===null||ne(O)?(n.exit("chunkString"),n.exit("codeFencedFenceInfo"),d(O)):Ce(O)?(n.exit("chunkString"),n.exit("codeFencedFenceInfo"),Ae(n,g,"whitespace")(O)):O===96&&O===a?t(O):(n.consume(O),m)}function g(O){return O===null||ne(O)?d(O):(n.enter("codeFencedFenceMeta"),n.enter("chunkString",{contentType:"string"}),k(O))}function k(O){return O===null||ne(O)?(n.exit("chunkString"),n.exit("codeFencedFenceMeta"),d(O)):O===96&&O===a?t(O):(n.consume(O),k)}function C(O){return n.attempt(i,K,v)(O)}function v(O){return n.enter("lineEnding"),n.consume(O),n.exit("lineEnding"),S}function S(O){return o>0&&Ce(O)?Ae(n,L,"linePrefix",o+1)(O):L(O)}function L(O){return O===null||ne(O)?n.check(Hm,C,K)(O):(n.enter("codeFlowValue"),R(O))}function R(O){return O===null||ne(O)?(n.exit("codeFlowValue"),L(O)):(n.consume(O),R)}function K(O){return n.exit("codeFenced"),e(O)}function q(O,H,X){let te=0;return D;function D(ye){return O.enter("lineEnding"),O.consume(ye),O.exit("lineEnding"),Q}function Q(ye){return O.enter("codeFencedFence"),Ce(ye)?Ae(O,ee,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(ye):ee(ye)}function ee(ye){return ye===a?(O.enter("codeFencedFenceSequence"),Ie(ye)):X(ye)}function Ie(ye){return ye===a?(te++,O.consume(ye),Ie):te>=s?(O.exit("codeFencedFenceSequence"),Ce(ye)?Ae(O,Te,"whitespace")(ye):Te(ye)):X(ye)}function Te(ye){return ye===null||ne(ye)?(O.exit("codeFencedFence"),H(ye)):X(ye)}}}function iM(n,e,t){const 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)}}const Vc={name:"codeIndented",tokenize:sM},oM={partial:!0,tokenize:lM};function sM(n,e,t){const r=this;return i;function i(f){return n.enter("codeIndented"),Ae(n,o,"linePrefix",5)(f)}function o(f){const h=r.events[r.events.length-1];return h&&h[1].type==="linePrefix"&&h[2].sliceSerialize(h[1],!0).length>=4?s(f):t(f)}function s(f){return f===null?u(f):ne(f)?n.attempt(oM,s,u)(f):(n.enter("codeFlowValue"),a(f))}function a(f){return f===null||ne(f)?(n.exit("codeFlowValue"),s(f)):(n.consume(f),a)}function u(f){return n.exit("codeIndented"),e(f)}}function lM(n,e,t){const r=this;return i;function i(s){return r.parser.lazy[r.now().line]?t(s):ne(s)?(n.enter("lineEnding"),n.consume(s),n.exit("lineEnding"),i):Ae(n,o,"linePrefix",5)(s)}function o(s){const a=r.events[r.events.length-1];return a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?e(s):ne(s)?i(s):t(s)}}const aM={name:"codeText",previous:cM,resolve:uM,tokenize:fM};function uM(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 cM(n){return n!==96||this.events[this.events.length-1][1].type==="characterEscape"}function fM(n,e,t){let r=0,i,o;return s;function s(d){return n.enter("codeText"),n.enter("codeTextSequence"),a(d)}function a(d){return d===96?(n.consume(d),r++,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?(o=n.enter("codeTextSequence"),i=0,h(d)):ne(d)?(n.enter("lineEnding"),n.consume(d),n.exit("lineEnding"),u):(n.enter("codeTextData"),f(d))}function f(d){return d===null||d===32||d===96||ne(d)?(n.exit("codeTextData"),u(d)):(n.consume(d),f)}function h(d){return d===96?(n.consume(d),i++,h):i===r?(n.exit("codeTextSequence"),n.exit("codeText"),e(d)):(o.type="codeTextData",f(d))}}class hM{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){const 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){const i=t||0;this.setCursor(Math.trunc(e));const o=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&es(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),es(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),es(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){const t=this.left.splice(e,Number.POSITIVE_INFINITY);es(this.right,t.reverse())}else{const t=this.right.splice(this.left.length+this.right.length-e,Number.POSITIVE_INFINITY);es(this.left,t.reverse())}}}function es(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 r1(n){const e={};let t=-1,r,i,o,s,a,u,f;const h=new hM(n);for(;++t<h.length;){for(;t in e;)t=e[t];if(r=h.get(t),t&&r[1].type==="chunkFlow"&&h.get(t-1)[1].type==="listItemPrefix"&&(u=r[1]._tokenizer.events,o=0,o<u.length&&u[o][1].type==="lineEndingBlank"&&(o+=2),o<u.length&&u[o][1].type==="content"))for(;++o<u.length&&u[o][1].type!=="content";)u[o][1].type==="chunkText"&&(u[o][1]._isInFirstContentOfListItem=!0,o++);if(r[0]==="enter")r[1].contentType&&(Object.assign(e,dM(h,t)),t=e[t],f=!0);else if(r[1]._container){for(o=t,i=void 0;o--;)if(s=h.get(o),s[1].type==="lineEnding"||s[1].type==="lineEndingBlank")s[0]==="enter"&&(i&&(h.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={...h.get(i)[1].start},a=h.slice(i,t),a.unshift(r),h.splice(i,t-i+1,a))}}return Qt(n,0,Number.POSITIVE_INFINITY,h.slice(0)),!f}function dM(n,e){const t=n.get(e)[1],r=n.get(e)[2];let i=e-1;const o=[];let s=t._tokenizer;s||(s=r.parser[t.contentType](t.start),t._contentTypeTextTrailing&&(s._contentTypeTextTrailing=!0));const a=s.events,u=[],f={};let h,d,m=-1,g=t,k=0,C=0;const v=[C];for(;g;){for(;n.get(++i)[1]!==g;);o.push(i),g._tokenizer||(h=r.sliceStream(g),g.next||h.push(null),d&&s.defineSkip(g.start),g._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=!0),s.write(h),g._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=void 0)),d=g,g=g.next}for(g=t;++m<a.length;)a[m][0]==="exit"&&a[m-1][0]==="enter"&&a[m][1].type===a[m-1][1].type&&a[m][1].start.line!==a[m][1].end.line&&(C=m+1,v.push(C),g._tokenizer=void 0,g.previous=void 0,g=g.next);for(s.events=[],g?(g._tokenizer=void 0,g.previous=void 0):v.pop(),m=v.length;m--;){const S=a.slice(v[m],v[m+1]),L=o.pop();u.push([L,L+S.length-1]),n.splice(L,2,S)}for(u.reverse(),m=-1;++m<u.length;)f[k+u[m][0]]=k+u[m][1],k+=u[m][1]-u[m][0]-1;return f}const pM={resolve:gM,tokenize:yM},mM={partial:!0,tokenize:kM};function gM(n){return r1(n),n}function yM(n,e){let t;return r;function r(a){return n.enter("content"),t=n.enter("chunkContent",{contentType:"content"}),i(a)}function i(a){return a===null?o(a):ne(a)?n.check(mM,s,o)(a):(n.consume(a),i)}function o(a){return n.exit("chunkContent"),n.exit("content"),e(a)}function s(a){return n.consume(a),n.exit("chunkContent"),t.next=n.enter("chunkContent",{contentType:"content",previous:t}),t=t.next,i}}function kM(n,e,t){const r=this;return i;function i(s){return n.exit("chunkContent"),n.enter("lineEnding"),n.consume(s),n.exit("lineEnding"),Ae(n,o,"linePrefix")}function o(s){if(s===null||ne(s))return t(s);const a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?e(s):n.interrupt(r.parser.constructs.flow,t,e)(s)}}function i1(n,e,t,r,i,o,s,a,u){const f=u||Number.POSITIVE_INFINITY;let h=0;return d;function d(S){return S===60?(n.enter(r),n.enter(i),n.enter(o),n.consume(S),n.exit(o),m):S===null||S===32||S===41||ba(S)?t(S):(n.enter(r),n.enter(s),n.enter(a),n.enter("chunkString",{contentType:"string"}),C(S))}function m(S){return S===62?(n.enter(o),n.consume(S),n.exit(o),n.exit(i),n.exit(r),e):(n.enter(a),n.enter("chunkString",{contentType:"string"}),g(S))}function g(S){return S===62?(n.exit("chunkString"),n.exit(a),m(S)):S===null||S===60||ne(S)?t(S):(n.consume(S),S===92?k:g)}function k(S){return S===60||S===62||S===92?(n.consume(S),g):g(S)}function C(S){return!h&&(S===null||S===41||Fe(S))?(n.exit("chunkString"),n.exit(a),n.exit(s),n.exit(r),e(S)):h<f&&S===40?(n.consume(S),h++,C):S===41?(n.consume(S),h--,C):S===null||S===32||S===40||ba(S)?t(S):(n.consume(S),S===92?v:C)}function v(S){return S===40||S===41||S===92?(n.consume(S),C):C(S)}}function o1(n,e,t,r,i,o){const s=this;let a=0,u;return f;function f(g){return n.enter(r),n.enter(i),n.consume(g),n.exit(i),n.enter(o),h}function h(g){return a>999||g===null||g===91||g===93&&!u||g===94&&!a&&"_hiddenFootnoteSupport"in s.parser.constructs?t(g):g===93?(n.exit(o),n.enter(i),n.consume(g),n.exit(i),n.exit(r),e):ne(g)?(n.enter("lineEnding"),n.consume(g),n.exit("lineEnding"),h):(n.enter("chunkString",{contentType:"string"}),d(g))}function d(g){return g===null||g===91||g===93||ne(g)||a++>999?(n.exit("chunkString"),h(g)):(n.consume(g),u||(u=!Ce(g)),g===92?m:d)}function m(g){return g===91||g===92||g===93?(n.consume(g),a++,d):d(g)}}function s1(n,e,t,r,i,o){let s;return a;function a(m){return m===34||m===39||m===40?(n.enter(r),n.enter(i),n.consume(m),n.exit(i),s=m===40?41:m,u):t(m)}function u(m){return m===s?(n.enter(i),n.consume(m),n.exit(i),n.exit(r),e):(n.enter(o),f(m))}function f(m){return m===s?(n.exit(o),u(s)):m===null?t(m):ne(m)?(n.enter("lineEnding"),n.consume(m),n.exit("lineEnding"),Ae(n,f,"linePrefix")):(n.enter("chunkString",{contentType:"string"}),h(m))}function h(m){return m===s||m===null||ne(m)?(n.exit("chunkString"),f(m)):(n.consume(m),m===92?d:h)}function d(m){return m===s||m===92?(n.consume(m),h):h(m)}}function us(n,e){let t;return r;function r(i){return ne(i)?(n.enter("lineEnding"),n.consume(i),n.exit("lineEnding"),t=!0,r):Ce(i)?Ae(n,r,t?"linePrefix":"lineSuffix")(i):e(i)}}const bM={name:"definition",tokenize:wM},xM={partial:!0,tokenize:CM};function wM(n,e,t){const r=this;let i;return o;function o(g){return n.enter("definition"),s(g)}function s(g){return o1.call(r,n,a,t,"definitionLabel","definitionLabelMarker","definitionLabelString")(g)}function a(g){return i=_n(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),g===58?(n.enter("definitionMarker"),n.consume(g),n.exit("definitionMarker"),u):t(g)}function u(g){return Fe(g)?us(n,f)(g):f(g)}function f(g){return i1(n,h,t,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(g)}function h(g){return n.attempt(xM,d,d)(g)}function d(g){return Ce(g)?Ae(n,m,"whitespace")(g):m(g)}function m(g){return g===null||ne(g)?(n.exit("definition"),r.parser.defined.push(i),e(g)):t(g)}}function CM(n,e,t){return r;function r(a){return Fe(a)?us(n,i)(a):t(a)}function i(a){return s1(n,o,t,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function o(a){return Ce(a)?Ae(n,s,"whitespace")(a):s(a)}function s(a){return a===null||ne(a)?e(a):t(a)}}const SM={name:"hardBreakEscape",tokenize:vM};function vM(n,e,t){return r;function r(o){return n.enter("hardBreakEscape"),n.consume(o),i}function i(o){return ne(o)?(n.exit("hardBreakEscape"),e(o)):t(o)}}const TM={name:"headingAtx",resolve:AM,tokenize:NM};function AM(n,e){let t=n.length-2,r=3,i,o;return 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&&(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"},Qt(n,r,t-r+1,[["enter",i,e],["enter",o,e],["exit",o,e],["exit",i,e]])),n}function NM(n,e,t){let r=0;return i;function i(h){return n.enter("atxHeading"),o(h)}function o(h){return n.enter("atxHeadingSequence"),s(h)}function s(h){return h===35&&r++<6?(n.consume(h),s):h===null||Fe(h)?(n.exit("atxHeadingSequence"),a(h)):t(h)}function a(h){return h===35?(n.enter("atxHeadingSequence"),u(h)):h===null||ne(h)?(n.exit("atxHeading"),e(h)):Ce(h)?Ae(n,a,"whitespace")(h):(n.enter("atxHeadingText"),f(h))}function u(h){return h===35?(n.consume(h),u):(n.exit("atxHeadingSequence"),a(h))}function f(h){return h===null||h===35||Fe(h)?(n.exit("atxHeadingText"),a(h)):(n.consume(h),f)}}const MM=["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"],Km=["pre","script","style","textarea"],IM={concrete:!0,name:"htmlFlow",resolveTo:RM,tokenize:_M},EM={partial:!0,tokenize:LM},OM={partial:!0,tokenize:DM};function RM(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 _M(n,e,t){const r=this;let i,o,s,a,u;return f;function f(M){return h(M)}function h(M){return n.enter("htmlFlow"),n.enter("htmlFlowData"),n.consume(M),d}function d(M){return M===33?(n.consume(M),m):M===47?(n.consume(M),o=!0,C):M===63?(n.consume(M),i=3,r.interrupt?e:A):St(M)?(n.consume(M),s=String.fromCharCode(M),v):t(M)}function m(M){return M===45?(n.consume(M),i=2,g):M===91?(n.consume(M),i=5,a=0,k):St(M)?(n.consume(M),i=4,r.interrupt?e:A):t(M)}function g(M){return M===45?(n.consume(M),r.interrupt?e:A):t(M)}function k(M){const zt="CDATA[";return M===zt.charCodeAt(a++)?(n.consume(M),a===zt.length?r.interrupt?e:ee:k):t(M)}function C(M){return St(M)?(n.consume(M),s=String.fromCharCode(M),v):t(M)}function v(M){if(M===null||M===47||M===62||Fe(M)){const zt=M===47,At=s.toLowerCase();return!zt&&!o&&Km.includes(At)?(i=1,r.interrupt?e(M):ee(M)):MM.includes(s.toLowerCase())?(i=6,zt?(n.consume(M),S):r.interrupt?e(M):ee(M)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?t(M):o?L(M):R(M))}return M===45||_t(M)?(n.consume(M),s+=String.fromCharCode(M),v):t(M)}function S(M){return M===62?(n.consume(M),r.interrupt?e:ee):t(M)}function L(M){return Ce(M)?(n.consume(M),L):D(M)}function R(M){return M===47?(n.consume(M),D):M===58||M===95||St(M)?(n.consume(M),K):Ce(M)?(n.consume(M),R):D(M)}function K(M){return M===45||M===46||M===58||M===95||_t(M)?(n.consume(M),K):q(M)}function q(M){return M===61?(n.consume(M),O):Ce(M)?(n.consume(M),q):R(M)}function O(M){return M===null||M===60||M===61||M===62||M===96?t(M):M===34||M===39?(n.consume(M),u=M,H):Ce(M)?(n.consume(M),O):X(M)}function H(M){return M===u?(n.consume(M),u=null,te):M===null||ne(M)?t(M):(n.consume(M),H)}function X(M){return M===null||M===34||M===39||M===47||M===60||M===61||M===62||M===96||Fe(M)?q(M):(n.consume(M),X)}function te(M){return M===47||M===62||Ce(M)?R(M):t(M)}function D(M){return M===62?(n.consume(M),Q):t(M)}function Q(M){return M===null||ne(M)?ee(M):Ce(M)?(n.consume(M),Q):t(M)}function ee(M){return M===45&&i===2?(n.consume(M),He):M===60&&i===1?(n.consume(M),Me):M===62&&i===4?(n.consume(M),je):M===63&&i===3?(n.consume(M),A):M===93&&i===5?(n.consume(M),Qe):ne(M)&&(i===6||i===7)?(n.exit("htmlFlowData"),n.check(EM,Tn,Ie)(M)):M===null||ne(M)?(n.exit("htmlFlowData"),Ie(M)):(n.consume(M),ee)}function Ie(M){return n.check(OM,Te,Tn)(M)}function Te(M){return n.enter("lineEnding"),n.consume(M),n.exit("lineEnding"),ye}function ye(M){return M===null||ne(M)?Ie(M):(n.enter("htmlFlowData"),ee(M))}function He(M){return M===45?(n.consume(M),A):ee(M)}function Me(M){return M===47?(n.consume(M),s="",Ee):ee(M)}function Ee(M){if(M===62){const zt=s.toLowerCase();return Km.includes(zt)?(n.consume(M),je):ee(M)}return St(M)&&s.length<8?(n.consume(M),s+=String.fromCharCode(M),Ee):ee(M)}function Qe(M){return M===93?(n.consume(M),A):ee(M)}function A(M){return M===62?(n.consume(M),je):M===45&&i===2?(n.consume(M),A):ee(M)}function je(M){return M===null||ne(M)?(n.exit("htmlFlowData"),Tn(M)):(n.consume(M),je)}function Tn(M){return n.exit("htmlFlow"),e(M)}}function DM(n,e,t){const r=this;return i;function i(s){return ne(s)?(n.enter("lineEnding"),n.consume(s),n.exit("lineEnding"),o):t(s)}function o(s){return r.parser.lazy[r.now().line]?t(s):e(s)}}function LM(n,e,t){return r;function r(i){return n.enter("lineEnding"),n.consume(i),n.exit("lineEnding"),n.attempt(Us,e,t)}}const PM={name:"htmlText",tokenize:BM};function BM(n,e,t){const r=this;let i,o,s;return a;function a(A){return n.enter("htmlText"),n.enter("htmlTextData"),n.consume(A),u}function u(A){return A===33?(n.consume(A),f):A===47?(n.consume(A),q):A===63?(n.consume(A),R):St(A)?(n.consume(A),X):t(A)}function f(A){return A===45?(n.consume(A),h):A===91?(n.consume(A),o=0,k):St(A)?(n.consume(A),L):t(A)}function h(A){return A===45?(n.consume(A),g):t(A)}function d(A){return A===null?t(A):A===45?(n.consume(A),m):ne(A)?(s=d,Me(A)):(n.consume(A),d)}function m(A){return A===45?(n.consume(A),g):d(A)}function g(A){return A===62?He(A):A===45?m(A):d(A)}function k(A){const je="CDATA[";return A===je.charCodeAt(o++)?(n.consume(A),o===je.length?C:k):t(A)}function C(A){return A===null?t(A):A===93?(n.consume(A),v):ne(A)?(s=C,Me(A)):(n.consume(A),C)}function v(A){return A===93?(n.consume(A),S):C(A)}function S(A){return A===62?He(A):A===93?(n.consume(A),S):C(A)}function L(A){return A===null||A===62?He(A):ne(A)?(s=L,Me(A)):(n.consume(A),L)}function R(A){return A===null?t(A):A===63?(n.consume(A),K):ne(A)?(s=R,Me(A)):(n.consume(A),R)}function K(A){return A===62?He(A):R(A)}function q(A){return St(A)?(n.consume(A),O):t(A)}function O(A){return A===45||_t(A)?(n.consume(A),O):H(A)}function H(A){return ne(A)?(s=H,Me(A)):Ce(A)?(n.consume(A),H):He(A)}function X(A){return A===45||_t(A)?(n.consume(A),X):A===47||A===62||Fe(A)?te(A):t(A)}function te(A){return A===47?(n.consume(A),He):A===58||A===95||St(A)?(n.consume(A),D):ne(A)?(s=te,Me(A)):Ce(A)?(n.consume(A),te):He(A)}function D(A){return A===45||A===46||A===58||A===95||_t(A)?(n.consume(A),D):Q(A)}function Q(A){return A===61?(n.consume(A),ee):ne(A)?(s=Q,Me(A)):Ce(A)?(n.consume(A),Q):te(A)}function ee(A){return A===null||A===60||A===61||A===62||A===96?t(A):A===34||A===39?(n.consume(A),i=A,Ie):ne(A)?(s=ee,Me(A)):Ce(A)?(n.consume(A),ee):(n.consume(A),Te)}function Ie(A){return A===i?(n.consume(A),i=void 0,ye):A===null?t(A):ne(A)?(s=Ie,Me(A)):(n.consume(A),Ie)}function Te(A){return A===null||A===34||A===39||A===60||A===61||A===96?t(A):A===47||A===62||Fe(A)?te(A):(n.consume(A),Te)}function ye(A){return A===47||A===62||Fe(A)?te(A):t(A)}function He(A){return A===62?(n.consume(A),n.exit("htmlTextData"),n.exit("htmlText"),e):t(A)}function Me(A){return n.exit("htmlTextData"),n.enter("lineEnding"),n.consume(A),n.exit("lineEnding"),Ee}function Ee(A){return Ce(A)?Ae(n,Qe,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(A):Qe(A)}function Qe(A){return n.enter("htmlTextData"),s(A)}}const Th={name:"labelEnd",resolveAll:WM,resolveTo:VM,tokenize:HM},FM={tokenize:qM},zM={tokenize:KM},$M={tokenize:UM};function WM(n){let e=-1;const t=[];for(;++e<n.length;){const r=n[e][1];if(t.push(n[e]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const i=r.type==="labelImage"?4:2;r.type="data",e+=i}}return n.length!==t.length&&Qt(n,0,n.length,t),n}function VM(n,e){let t=n.length,r=0,i,o,s,a;for(;t--;)if(i=n[t][1],o){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;n[t][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(s){if(n[t][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(o=t,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(s=t);const u={type:n[o][1].type==="labelLink"?"link":"image",start:{...n[o][1].start},end:{...n[n.length-1][1].end}},f={type:"label",start:{...n[o][1].start},end:{...n[s][1].end}},h={type:"labelText",start:{...n[o+r+2][1].end},end:{...n[s-2][1].start}};return a=[["enter",u,e],["enter",f,e]],a=gn(a,n.slice(o+1,o+r+3)),a=gn(a,[["enter",h,e]]),a=gn(a,Za(e.parser.constructs.insideSpan.null,n.slice(o+r+4,s-3),e)),a=gn(a,[["exit",h,e],n[s-2],n[s-1],["exit",f,e]]),a=gn(a,n.slice(s+1)),a=gn(a,[["exit",u,e]]),Qt(n,o,n.length,a),n}function HM(n,e,t){const r=this;let i=r.events.length,o,s;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){o=r.events[i][1];break}return a;function a(m){return o?o._inactive?d(m):(s=r.parser.defined.includes(_n(r.sliceSerialize({start:o.end,end:r.now()}))),n.enter("labelEnd"),n.enter("labelMarker"),n.consume(m),n.exit("labelMarker"),n.exit("labelEnd"),u):t(m)}function u(m){return m===40?n.attempt(FM,h,s?h:d)(m):m===91?n.attempt(zM,h,s?f:d)(m):s?h(m):d(m)}function f(m){return n.attempt($M,h,d)(m)}function h(m){return e(m)}function d(m){return o._balanced=!0,t(m)}}function qM(n,e,t){return r;function r(d){return n.enter("resource"),n.enter("resourceMarker"),n.consume(d),n.exit("resourceMarker"),i}function i(d){return Fe(d)?us(n,o)(d):o(d)}function o(d){return d===41?h(d):i1(n,s,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(d)}function s(d){return Fe(d)?us(n,u)(d):h(d)}function a(d){return t(d)}function u(d){return d===34||d===39||d===40?s1(n,f,t,"resourceTitle","resourceTitleMarker","resourceTitleString")(d):h(d)}function f(d){return Fe(d)?us(n,h)(d):h(d)}function h(d){return d===41?(n.enter("resourceMarker"),n.consume(d),n.exit("resourceMarker"),n.exit("resource"),e):t(d)}}function KM(n,e,t){const r=this;return i;function i(a){return o1.call(r,n,o,s,"reference","referenceMarker","referenceString")(a)}function o(a){return r.parser.defined.includes(_n(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?e(a):t(a)}function s(a){return t(a)}}function UM(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)}}const jM={name:"labelStartImage",resolveAll:Th.resolveAll,tokenize:JM};function JM(n,e,t){const r=this;return i;function i(a){return n.enter("labelImage"),n.enter("labelImageMarker"),n.consume(a),n.exit("labelImageMarker"),o}function o(a){return a===91?(n.enter("labelMarker"),n.consume(a),n.exit("labelMarker"),n.exit("labelImage"),s):t(a)}function s(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?t(a):e(a)}}const GM={name:"labelStartLink",resolveAll:Th.resolveAll,tokenize:YM};function YM(n,e,t){const r=this;return i;function i(s){return n.enter("labelLink"),n.enter("labelMarker"),n.consume(s),n.exit("labelMarker"),n.exit("labelLink"),o}function o(s){return s===94&&"_hiddenFootnoteSupport"in r.parser.constructs?t(s):e(s)}}const Hc={name:"lineEnding",tokenize:XM};function XM(n,e){return t;function t(r){return n.enter("lineEnding"),n.consume(r),n.exit("lineEnding"),Ae(n,e,"linePrefix")}}const aa={name:"thematicBreak",tokenize:QM};function QM(n,e,t){let r=0,i;return o;function o(f){return n.enter("thematicBreak"),s(f)}function s(f){return i=f,a(f)}function a(f){return f===i?(n.enter("thematicBreakSequence"),u(f)):r>=3&&(f===null||ne(f))?(n.exit("thematicBreak"),e(f)):t(f)}function u(f){return f===i?(n.consume(f),r++,u):(n.exit("thematicBreakSequence"),Ce(f)?Ae(n,a,"whitespace")(f):a(f))}}const Rt={continuation:{tokenize:nI},exit:iI,name:"list",tokenize:tI},ZM={partial:!0,tokenize:oI},eI={partial:!0,tokenize:rI};function tI(n,e,t){const r=this,i=r.events[r.events.length-1];let o=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,s=0;return a;function a(g){const k=r.containerState.type||(g===42||g===43||g===45?"listUnordered":"listOrdered");if(k==="listUnordered"?!r.containerState.marker||g===r.containerState.marker:Ff(g)){if(r.containerState.type||(r.containerState.type=k,n.enter(k,{_container:!0})),k==="listUnordered")return n.enter("listItemPrefix"),g===42||g===45?n.check(aa,t,f)(g):f(g);if(!r.interrupt||g===49)return n.enter("listItemPrefix"),n.enter("listItemValue"),u(g)}return t(g)}function u(g){return Ff(g)&&++s<10?(n.consume(g),u):(!r.interrupt||s<2)&&(r.containerState.marker?g===r.containerState.marker:g===41||g===46)?(n.exit("listItemValue"),f(g)):t(g)}function f(g){return n.enter("listItemMarker"),n.consume(g),n.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||g,n.check(Us,r.interrupt?t:h,n.attempt(ZM,m,d))}function h(g){return r.containerState.initialBlankLine=!0,o++,m(g)}function d(g){return Ce(g)?(n.enter("listItemPrefixWhitespace"),n.consume(g),n.exit("listItemPrefixWhitespace"),m):t(g)}function m(g){return r.containerState.size=o+r.sliceSerialize(n.exit("listItemPrefix"),!0).length,e(g)}}function nI(n,e,t){const r=this;return r.containerState._closeFlow=void 0,n.check(Us,i,o);function i(a){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Ae(n,e,"listItemIndent",r.containerState.size+1)(a)}function o(a){return r.containerState.furtherBlankLines||!Ce(a)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,s(a)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,n.attempt(eI,e,s)(a))}function s(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,Ae(n,n.attempt(Rt,e,t),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function rI(n,e,t){const r=this;return Ae(n,i,"listItemIndent",r.containerState.size+1);function i(o){const 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 iI(n){n.exit(this.containerState.type)}function oI(n,e,t){const r=this;return Ae(n,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(o){const s=r.events[r.events.length-1];return!Ce(o)&&s&&s[1].type==="listItemPrefixWhitespace"?e(o):t(o)}}const Um={name:"setextUnderline",resolveTo:sI,tokenize:lI};function sI(n,e){let t=n.length,r,i,o;for(;t--;)if(n[t][0]==="enter"){if(n[t][1].type==="content"){r=t;break}n[t][1].type==="paragraph"&&(i=t)}else n[t][1].type==="content"&&n.splice(t,1),!o&&n[t][1].type==="definition"&&(o=t);const s={type:"setextHeading",start:{...n[r][1].start},end:{...n[n.length-1][1].end}};return n[i][1].type="setextHeadingText",o?(n.splice(i,0,["enter",s,e]),n.splice(o+1,0,["exit",n[r][1],e]),n[r][1].end={...n[o][1].end}):n[r][1]=s,n.push(["exit",s,e]),n}function lI(n,e,t){const r=this;let i;return o;function o(f){let h=r.events.length,d;for(;h--;)if(r.events[h][1].type!=="lineEnding"&&r.events[h][1].type!=="linePrefix"&&r.events[h][1].type!=="content"){d=r.events[h][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||d)?(n.enter("setextHeadingLine"),i=f,s(f)):t(f)}function s(f){return n.enter("setextHeadingLineSequence"),a(f)}function a(f){return f===i?(n.consume(f),a):(n.exit("setextHeadingLineSequence"),Ce(f)?Ae(n,u,"lineSuffix")(f):u(f))}function u(f){return f===null||ne(f)?(n.exit("setextHeadingLine"),e(f)):t(f)}}const aI={tokenize:uI};function uI(n){const e=this,t=n.attempt(Us,r,n.attempt(this.parser.constructs.flowInitial,i,Ae(n,n.attempt(this.parser.constructs.flow,i,n.attempt(pM,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}}const cI={resolveAll:a1()},fI=l1("string"),hI=l1("text");function l1(n){return{resolveAll:a1(n==="text"?dI:void 0),tokenize:e};function e(t){const r=this,i=this.parser.constructs[n],o=t.attempt(i,s,a);return s;function s(h){return f(h)?o(h):a(h)}function a(h){if(h===null){t.consume(h);return}return t.enter("data"),t.consume(h),u}function u(h){return f(h)?(t.exit("data"),o(h)):(t.consume(h),u)}function f(h){if(h===null)return!0;const d=i[h];let m=-1;if(d)for(;++m<d.length;){const g=d[m];if(!g.previous||g.previous.call(r,r.previous))return!0}return!1}}}function a1(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 dI(n,e){let t=0;for(;++t<=n.length;)if((t===n.length||n[t][1].type==="lineEnding")&&n[t-1][1].type==="data"){const r=n[t-1][1],i=e.sliceStream(r);let o=i.length,s=-1,a=0,u;for(;o--;){const f=i[o];if(typeof f=="string"){for(s=f.length;f.charCodeAt(s-1)===32;)a++,s--;if(s)break;s=-1}else if(f===-2)u=!0,a++;else if(f!==-1){o++;break}}if(e._contentTypeTextTrailing&&t===n.length&&(a=0),a){const f={type:t===n.length||u||a<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:o?s:r.start._bufferIndex+s,_index:r.start._index+o,line:r.end.line,column:r.end.column-a,offset:r.end.offset-a},end:{...r.end}};r.end={...f.start},r.start.offset===r.end.offset?Object.assign(r,f):(n.splice(t,0,["enter",f,e],["exit",f,e]),t+=2)}t++}return n}const pI={42:Rt,43:Rt,45:Rt,48:Rt,49:Rt,50:Rt,51:Rt,52:Rt,53:Rt,54:Rt,55:Rt,56:Rt,57:Rt,62:e1},mI={91:bM},gI={[-2]:Vc,[-1]:Vc,32:Vc},yI={35:TM,42:aa,45:[Um,aa],60:IM,61:Um,95:aa,96:qm,126:qm},kI={38:n1,92:t1},bI={[-5]:Hc,[-4]:Hc,[-3]:Hc,33:jM,38:n1,42:zf,60:[GN,PM],91:GM,92:[SM,t1],93:Th,95:zf,96:aM},xI={null:[zf,cI]},wI={null:[42,95]},CI={null:[]},SI=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:wI,contentInitial:mI,disable:CI,document:pI,flow:yI,flowInitial:gI,insideSpan:xI,string:kI,text:bI},Symbol.toStringTag,{value:"Module"}));function vI(n,e,t){let r={_bufferIndex:-1,_index:0,line:t&&t.line||1,column:t&&t.column||1,offset:t&&t.offset||0};const i={},o=[];let s=[],a=[];const u={attempt:H(q),check:H(O),consume:L,enter:R,exit:K,interrupt:H(O,{interrupt:!0})},f={code:null,containerState:{},defineSkip:C,events:[],now:k,parser:n,previous:null,sliceSerialize:m,sliceStream:g,write:d};let h=e.tokenize.call(f,u);return e.resolveAll&&o.push(e),f;function d(Q){return s=gn(s,Q),v(),s[s.length-1]!==null?[]:(X(e,0),f.events=Za(o,f.events,f),f.events)}function m(Q,ee){return AI(g(Q),ee)}function g(Q){return TI(s,Q)}function k(){const{_bufferIndex:Q,_index:ee,line:Ie,column:Te,offset:ye}=r;return{_bufferIndex:Q,_index:ee,line:Ie,column:Te,offset:ye}}function C(Q){i[Q.line]=Q.column,D()}function v(){let Q;for(;r._index<s.length;){const ee=s[r._index];if(typeof ee=="string")for(Q=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===Q&&r._bufferIndex<ee.length;)S(ee.charCodeAt(r._bufferIndex));else S(ee)}}function S(Q){h=h(Q)}function L(Q){ne(Q)?(r.line++,r.column=1,r.offset+=Q===-3?2:1,D()):Q!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===s[r._index].length&&(r._bufferIndex=-1,r._index++)),f.previous=Q}function R(Q,ee){const Ie=ee||{};return Ie.type=Q,Ie.start=k(),f.events.push(["enter",Ie,f]),a.push(Ie),Ie}function K(Q){const ee=a.pop();return ee.end=k(),f.events.push(["exit",ee,f]),ee}function q(Q,ee){X(Q,ee.from)}function O(Q,ee){ee.restore()}function H(Q,ee){return Ie;function Ie(Te,ye,He){let Me,Ee,Qe,A;return Array.isArray(Te)?Tn(Te):"tokenize"in Te?Tn([Te]):je(Te);function je(Je){return ri;function ri(Nt){const on=Nt!==null&&Je[Nt],Tr=Nt!==null&&Je.null,er=[...Array.isArray(on)?on:on?[on]:[],...Array.isArray(Tr)?Tr:Tr?[Tr]:[]];return Tn(er)(Nt)}}function Tn(Je){return Me=Je,Ee=0,Je.length===0?He:M(Je[Ee])}function M(Je){return ri;function ri(Nt){return A=te(),Qe=Je,Je.partial||(f.currentConstruct=Je),Je.name&&f.parser.constructs.disable.null.includes(Je.name)?At():Je.tokenize.call(ee?Object.assign(Object.create(f),ee):f,u,zt,At)(Nt)}}function zt(Je){return Q(Qe,A),ye}function At(Je){return A.restore(),++Ee<Me.length?M(Me[Ee]):He}}}function X(Q,ee){Q.resolveAll&&!o.includes(Q)&&o.push(Q),Q.resolve&&Qt(f.events,ee,f.events.length-ee,Q.resolve(f.events.slice(ee),f)),Q.resolveTo&&(f.events=Q.resolveTo(f.events,f))}function te(){const Q=k(),ee=f.previous,Ie=f.currentConstruct,Te=f.events.length,ye=Array.from(a);return{from:Te,restore:He};function He(){r=Q,f.previous=ee,f.currentConstruct=Ie,f.events.length=Te,a=ye,D()}}function D(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function TI(n,e){const t=e.start._index,r=e.start._bufferIndex,i=e.end._index,o=e.end._bufferIndex;let s;if(t===i)s=[n[t].slice(r,o)];else{if(s=n.slice(t,i),r>-1){const a=s[0];typeof a=="string"?s[0]=a.slice(r):s.shift()}o>0&&s.push(n[i].slice(0,o))}return s}function AI(n,e){let t=-1;const r=[];let i;for(;++t<n.length;){const o=n[t];let s;if(typeof o=="string")s=o;else switch(o){case-5:{s="\r";break}case-4:{s=`
2
+ `;break}case-3:{s=`\r
3
+ `;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 NI(n){const r={constructs:Qy([SI,...(n||{}).extensions||[]]),content:i(VN),defined:[],document:i(qN),flow:i(aI),lazy:{},string:i(fI),text:i(hI)};return r;function i(o){return s;function s(a){return vI(r,o,a)}}}function MI(n){for(;!r1(n););return n}const jm=/[\0\t\n\r]/g;function II(){let n=1,e="",t=!0,r;return i;function i(o,s,a){const u=[];let f,h,d,m,g;for(o=e+(typeof o=="string"?o.toString():new TextDecoder(s||void 0).decode(o)),d=0,e="",t&&(o.charCodeAt(0)===65279&&d++,t=void 0);d<o.length;){if(jm.lastIndex=d,f=jm.exec(o),m=f&&f.index!==void 0?f.index:o.length,g=o.charCodeAt(m),!f){e=o.slice(d);break}if(g===10&&d===m&&r)u.push(-3),r=void 0;else switch(r&&(u.push(-5),r=void 0),d<m&&(u.push(o.slice(d,m)),n+=m-d),g){case 0:{u.push(65533),n++;break}case 9:{for(h=Math.ceil(n/4)*4,u.push(-2);n++<h;)u.push(-1);break}case 10:{u.push(-4),n=1;break}default:r=!0,n=1}d=m+1}return a&&(r&&u.push(-5),e&&u.push(e),u.push(null)),u}}const EI=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function u1(n){return n.replace(EI,OI)}function OI(n,e,t){if(e)return e;if(t.charCodeAt(0)===35){const i=t.charCodeAt(1),o=i===120||i===88;return Zy(t.slice(o?2:1),o?16:10)}return vh(t)||n}function cs(n){return!n||typeof n!="object"?"":"position"in n||"type"in n?Jm(n.position):"start"in n||"end"in n?Jm(n):"line"in n||"column"in n?$f(n):""}function $f(n){return Gm(n&&n.line)+":"+Gm(n&&n.column)}function Jm(n){return $f(n&&n.start)+"-"+$f(n&&n.end)}function Gm(n){return n&&typeof n=="number"?n:1}const c1={}.hasOwnProperty;function RI(n,e,t){return e&&typeof e=="object"&&(t=e,e=void 0),_I(t)(MI(NI(t).document().write(II()(n,e,!0))))}function _I(n){const e={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:o(cl),autolinkProtocol:te,autolinkEmail:te,atxHeading:o(Ar),blockQuote:o(Tr),characterEscape:te,characterReference:te,codeFenced:o(er),codeFencedFenceInfo:s,codeFencedFenceMeta:s,codeIndented:o(er,s),codeText:o(qi,s),codeTextData:te,data:te,codeFlowValue:te,definition:o(ll),definitionDestinationString:s,definitionLabelString:s,definitionTitleString:s,emphasis:o($t),hardBreakEscape:o(al),hardBreakTrailing:o(al),htmlFlow:o(sn,s),htmlFlowData:te,htmlText:o(sn,s),htmlTextData:te,image:o(ul),label:s,link:o(cl),listItem:o(Wt),listItemValue:m,listOrdered:o(Nr,d),listUnordered:o(Nr),paragraph:o(ii),reference:M,referenceString:s,resourceDestinationString:s,resourceTitleString:s,setextHeading:o(Ar),strong:o(Ki),thematicBreak:o(oi)},exit:{atxHeading:u(),atxHeadingSequence:q,autolink:u(),autolinkEmail:on,autolinkProtocol:Nt,blockQuote:u(),characterEscapeValue:D,characterReferenceMarkerHexadecimal:At,characterReferenceMarkerNumeric:At,characterReferenceValue:Je,characterReference:ri,codeFenced:u(v),codeFencedFence:C,codeFencedFenceInfo:g,codeFencedFenceMeta:k,codeFlowValue:D,codeIndented:u(S),codeText:u(ye),codeTextData:D,data:D,definition:u(),definitionDestinationString:K,definitionLabelString:L,definitionTitleString:R,emphasis:u(),hardBreakEscape:u(ee),hardBreakTrailing:u(ee),htmlFlow:u(Ie),htmlFlowData:D,htmlText:u(Te),htmlTextData:D,image:u(Me),label:Qe,labelText:Ee,lineEnding:Q,link:u(He),listItem:u(),listOrdered:u(),listUnordered:u(),paragraph:u(),referenceString:zt,resourceDestinationString:A,resourceTitleString:je,resource:Tn,setextHeading:u(X),setextHeadingLineSequence:H,setextHeadingText:O,strong:u(),thematicBreak:u()}};f1(e,(n||{}).mdastExtensions||[]);const t={};return r;function r(B){let U={type:"root",children:[]};const ie={stack:[U],tokenStack:[],config:e,enter:a,exit:f,buffer:s,resume:h,data:t},ke=[];let Oe=-1;for(;++Oe<B.length;)if(B[Oe][1].type==="listOrdered"||B[Oe][1].type==="listUnordered")if(B[Oe][0]==="enter")ke.push(Oe);else{const bt=ke.pop();Oe=i(B,bt,Oe)}for(Oe=-1;++Oe<B.length;){const bt=e[B[Oe][0]];c1.call(bt,B[Oe][1].type)&&bt[B[Oe][1].type].call(Object.assign({sliceSerialize:B[Oe][2].sliceSerialize},ie),B[Oe][1])}if(ie.tokenStack.length>0){const bt=ie.tokenStack[ie.tokenStack.length-1];(bt[1]||Ym).call(ie,void 0,bt[0])}for(U.position={start:Br(B.length>0?B[0][1].start:{line:1,column:1,offset:0}),end:Br(B.length>0?B[B.length-2][1].end:{line:1,column:1,offset:0})},Oe=-1;++Oe<e.transforms.length;)U=e.transforms[Oe](U)||U;return U}function i(B,U,ie){let ke=U-1,Oe=-1,bt=!1,An,Vt,tr,nr;for(;++ke<=ie;){const st=B[ke];switch(st[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{st[0]==="enter"?Oe++:Oe--,nr=void 0;break}case"lineEndingBlank":{st[0]==="enter"&&(An&&!nr&&!Oe&&!tr&&(tr=ke),nr=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:nr=void 0}if(!Oe&&st[0]==="enter"&&st[1].type==="listItemPrefix"||Oe===-1&&st[0]==="exit"&&(st[1].type==="listUnordered"||st[1].type==="listOrdered")){if(An){let Fn=ke;for(Vt=void 0;Fn--;){const Nn=B[Fn];if(Nn[1].type==="lineEnding"||Nn[1].type==="lineEndingBlank"){if(Nn[0]==="exit")continue;Vt&&(B[Vt][1].type="lineEndingBlank",bt=!0),Nn[1].type="lineEnding",Vt=Fn}else if(!(Nn[1].type==="linePrefix"||Nn[1].type==="blockQuotePrefix"||Nn[1].type==="blockQuotePrefixWhitespace"||Nn[1].type==="blockQuoteMarker"||Nn[1].type==="listItemIndent"))break}tr&&(!Vt||tr<Vt)&&(An._spread=!0),An.end=Object.assign({},Vt?B[Vt][1].start:st[1].end),B.splice(Vt||ke,0,["exit",An,st[2]]),ke++,ie++}if(st[1].type==="listItemPrefix"){const Fn={type:"listItem",_spread:!1,start:Object.assign({},st[1].start),end:void 0};An=Fn,B.splice(ke,0,["enter",Fn,st[2]]),ke++,ie++,tr=void 0,nr=!0}}}return B[U][1]._spread=bt,ie}function o(B,U){return ie;function ie(ke){a.call(this,B(ke),ke),U&&U.call(this,ke)}}function s(){this.stack.push({type:"fragment",children:[]})}function a(B,U,ie){this.stack[this.stack.length-1].children.push(B),this.stack.push(B),this.tokenStack.push([U,ie||void 0]),B.position={start:Br(U.start),end:void 0}}function u(B){return U;function U(ie){B&&B.call(this,ie),f.call(this,ie)}}function f(B,U){const ie=this.stack.pop(),ke=this.tokenStack.pop();if(ke)ke[0].type!==B.type&&(U?U.call(this,B,ke[0]):(ke[1]||Ym).call(this,B,ke[0]));else throw new Error("Cannot close `"+B.type+"` ("+cs({start:B.start,end:B.end})+"): it’s not open");ie.position.end=Br(B.end)}function h(){return Sh(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function m(B){if(this.data.expectingFirstListItemValue){const U=this.stack[this.stack.length-2];U.start=Number.parseInt(this.sliceSerialize(B),10),this.data.expectingFirstListItemValue=void 0}}function g(){const B=this.resume(),U=this.stack[this.stack.length-1];U.lang=B}function k(){const B=this.resume(),U=this.stack[this.stack.length-1];U.meta=B}function C(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function v(){const B=this.resume(),U=this.stack[this.stack.length-1];U.value=B.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function S(){const B=this.resume(),U=this.stack[this.stack.length-1];U.value=B.replace(/(\r?\n|\r)$/g,"")}function L(B){const U=this.resume(),ie=this.stack[this.stack.length-1];ie.label=U,ie.identifier=_n(this.sliceSerialize(B)).toLowerCase()}function R(){const B=this.resume(),U=this.stack[this.stack.length-1];U.title=B}function K(){const B=this.resume(),U=this.stack[this.stack.length-1];U.url=B}function q(B){const U=this.stack[this.stack.length-1];if(!U.depth){const ie=this.sliceSerialize(B).length;U.depth=ie}}function O(){this.data.setextHeadingSlurpLineEnding=!0}function H(B){const U=this.stack[this.stack.length-1];U.depth=this.sliceSerialize(B).codePointAt(0)===61?1:2}function X(){this.data.setextHeadingSlurpLineEnding=void 0}function te(B){const ie=this.stack[this.stack.length-1].children;let ke=ie[ie.length-1];(!ke||ke.type!=="text")&&(ke=Mu(),ke.position={start:Br(B.start),end:void 0},ie.push(ke)),this.stack.push(ke)}function D(B){const U=this.stack.pop();U.value+=this.sliceSerialize(B),U.position.end=Br(B.end)}function Q(B){const U=this.stack[this.stack.length-1];if(this.data.atHardBreak){const ie=U.children[U.children.length-1];ie.position.end=Br(B.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&e.canContainEols.includes(U.type)&&(te.call(this,B),D.call(this,B))}function ee(){this.data.atHardBreak=!0}function Ie(){const B=this.resume(),U=this.stack[this.stack.length-1];U.value=B}function Te(){const B=this.resume(),U=this.stack[this.stack.length-1];U.value=B}function ye(){const B=this.resume(),U=this.stack[this.stack.length-1];U.value=B}function He(){const B=this.stack[this.stack.length-1];if(this.data.inReference){const U=this.data.referenceType||"shortcut";B.type+="Reference",B.referenceType=U,delete B.url,delete B.title}else delete B.identifier,delete B.label;this.data.referenceType=void 0}function Me(){const B=this.stack[this.stack.length-1];if(this.data.inReference){const U=this.data.referenceType||"shortcut";B.type+="Reference",B.referenceType=U,delete B.url,delete B.title}else delete B.identifier,delete B.label;this.data.referenceType=void 0}function Ee(B){const U=this.sliceSerialize(B),ie=this.stack[this.stack.length-2];ie.label=u1(U),ie.identifier=_n(U).toLowerCase()}function Qe(){const B=this.stack[this.stack.length-1],U=this.resume(),ie=this.stack[this.stack.length-1];if(this.data.inReference=!0,ie.type==="link"){const ke=B.children;ie.children=ke}else ie.alt=U}function A(){const B=this.resume(),U=this.stack[this.stack.length-1];U.url=B}function je(){const B=this.resume(),U=this.stack[this.stack.length-1];U.title=B}function Tn(){this.data.inReference=void 0}function M(){this.data.referenceType="collapsed"}function zt(B){const U=this.resume(),ie=this.stack[this.stack.length-1];ie.label=U,ie.identifier=_n(this.sliceSerialize(B)).toLowerCase(),this.data.referenceType="full"}function At(B){this.data.characterReferenceType=B.type}function Je(B){const U=this.sliceSerialize(B),ie=this.data.characterReferenceType;let ke;ie?(ke=Zy(U,ie==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):ke=vh(U);const Oe=this.stack[this.stack.length-1];Oe.value+=ke}function ri(B){const U=this.stack.pop();U.position.end=Br(B.end)}function Nt(B){D.call(this,B);const U=this.stack[this.stack.length-1];U.url=this.sliceSerialize(B)}function on(B){D.call(this,B);const U=this.stack[this.stack.length-1];U.url="mailto:"+this.sliceSerialize(B)}function Tr(){return{type:"blockquote",children:[]}}function er(){return{type:"code",lang:null,meta:null,value:""}}function qi(){return{type:"inlineCode",value:""}}function ll(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function $t(){return{type:"emphasis",children:[]}}function Ar(){return{type:"heading",depth:0,children:[]}}function al(){return{type:"break"}}function sn(){return{type:"html",value:""}}function ul(){return{type:"image",title:null,url:"",alt:null}}function cl(){return{type:"link",title:null,url:"",children:[]}}function Nr(B){return{type:"list",ordered:B.type==="listOrdered",start:null,spread:B._spread,children:[]}}function Wt(B){return{type:"listItem",spread:B._spread,checked:null,children:[]}}function ii(){return{type:"paragraph",children:[]}}function Ki(){return{type:"strong",children:[]}}function Mu(){return{type:"text",value:""}}function oi(){return{type:"thematicBreak"}}}function Br(n){return{line:n.line,column:n.column,offset:n.offset}}function f1(n,e){let t=-1;for(;++t<e.length;){const r=e[t];Array.isArray(r)?f1(n,r):DI(n,r)}}function DI(n,e){let t;for(t in e)if(c1.call(e,t))switch(t){case"canContainEols":{const r=e[t];r&&n[t].push(...r);break}case"transforms":{const r=e[t];r&&n[t].push(...r);break}case"enter":case"exit":{const r=e[t];r&&Object.assign(n[t],r);break}}}function Ym(n,e){throw n?new Error("Cannot close `"+n.type+"` ("+cs({start:n.start,end:n.end})+"): a different token (`"+e.type+"`, "+cs({start:e.start,end:e.end})+") is open"):new Error("Cannot close document, a token (`"+e.type+"`, "+cs({start:e.start,end:e.end})+") is still open")}function LI(n){const e=this;e.parser=t;function t(r){return RI(r,{...e.data("settings"),...n,extensions:e.data("micromarkExtensions")||[],mdastExtensions:e.data("fromMarkdownExtensions")||[]})}}const Xm={}.hasOwnProperty;function PI(n,e){const t=e||{};function r(i,...o){let s=r.invalid;const a=r.handlers;if(i&&Xm.call(i,n)){const u=String(i[n]);s=Xm.call(a,u)?a[u]:r.unknown}if(s)return s.call(this,i,...o)}return r.handlers=t.handlers||{},r.invalid=t.invalid,r.unknown=t.unknown,r}const BI={}.hasOwnProperty;function h1(n,e){let t=-1,r;if(e.extensions)for(;++t<e.extensions.length;)h1(n,e.extensions[t]);for(r in e)if(BI.call(e,r))switch(r){case"extensions":break;case"unsafe":{Qm(n[r],e[r]);break}case"join":{Qm(n[r],e[r]);break}case"handlers":{FI(n[r],e[r]);break}default:n.options[r]=e[r]}return n}function Qm(n,e){e&&n.push(...e)}function FI(n,e){e&&Object.assign(n,e)}function zI(n,e,t,r){const i=t.enter("blockquote"),o=t.createTracker(r);o.move("> "),o.shift(2);const s=t.indentLines(t.containerFlow(n,o.current()),$I);return i(),s}function $I(n,e,t){return">"+(t?"":" ")+n}function d1(n,e){return Zm(n,e.inConstruct,!0)&&!Zm(n,e.notInConstruct,!1)}function Zm(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 eg(n,e,t,r){let i=-1;for(;++i<t.unsafe.length;)if(t.unsafe[i].character===`
4
+ `&&d1(t.stack,t.unsafe[i]))return/[ \t]/.test(r.before)?"":" ";return`\\
5
+ `}function WI(n,e){const t=String(n);let 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 Wf(n,e){return!!(e.options.fences===!1&&n.value&&!n.lang&&/[^ \r\n]/.test(n.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(n.value))}function VI(n){const e=n.options.fence||"`";if(e!=="`"&&e!=="~")throw new Error("Cannot serialize code with `"+e+"` for `options.fence`, expected `` ` `` or `~`");return e}function HI(n,e,t,r){const i=VI(t),o=n.value||"",s=i==="`"?"GraveAccent":"Tilde";if(Wf(n,t)){const d=t.enter("codeIndented"),m=t.indentLines(o,qI);return d(),m}const a=t.createTracker(r),u=i.repeat(Math.max(WI(o,i)+1,3)),f=t.enter("codeFenced");let h=a.move(u);if(n.lang){const d=t.enter(`codeFencedLang${s}`);h+=a.move(t.safe(n.lang,{before:h,after:" ",encode:["`"],...a.current()})),d()}if(n.lang&&n.meta){const d=t.enter(`codeFencedMeta${s}`);h+=a.move(" "),h+=a.move(t.safe(n.meta,{before:h,after:`
6
+ `,encode:["`"],...a.current()})),d()}return h+=a.move(`
7
+ `),o&&(h+=a.move(o+`
8
+ `)),h+=a.move(u),f(),h}function qI(n,e,t){return(t?"":" ")+n}function Ah(n){const e=n.options.quote||'"';if(e!=='"'&&e!=="'")throw new Error("Cannot serialize title with `"+e+"` for `options.quote`, expected `\"`, or `'`");return e}function KI(n,e,t,r){const i=Ah(t),o=i==='"'?"Quote":"Apostrophe",s=t.enter("definition");let a=t.enter("label");const u=t.createTracker(r);let f=u.move("[");return f+=u.move(t.safe(t.associationId(n),{before:f,after:"]",...u.current()})),f+=u.move("]: "),a(),!n.url||/[\0- \u007F]/.test(n.url)?(a=t.enter("destinationLiteral"),f+=u.move("<"),f+=u.move(t.safe(n.url,{before:f,after:">",...u.current()})),f+=u.move(">")):(a=t.enter("destinationRaw"),f+=u.move(t.safe(n.url,{before:f,after:n.title?" ":`
9
+ `,...u.current()}))),a(),n.title&&(a=t.enter(`title${o}`),f+=u.move(" "+i),f+=u.move(t.safe(n.title,{before:f,after:i,...u.current()})),f+=u.move(i),a()),s(),f}function UI(n){const e=n.options.emphasis||"*";if(e!=="*"&&e!=="_")throw new Error("Cannot serialize emphasis with `"+e+"` for `options.emphasis`, expected `*`, or `_`");return e}function Yr(n){return"&#x"+n.toString(16).toUpperCase()+";"}function xa(n,e,t){const r=To(n),i=To(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}}p1.peek=jI;function p1(n,e,t,r){const i=UI(t),o=t.enter("emphasis"),s=t.createTracker(r),a=s.move(i);let u=s.move(t.containerPhrasing(n,{after:i,before:a,...s.current()}));const f=u.charCodeAt(0),h=xa(r.before.charCodeAt(r.before.length-1),f,i);h.inside&&(u=Yr(f)+u.slice(1));const d=u.charCodeAt(u.length-1),m=xa(r.after.charCodeAt(0),d,i);m.inside&&(u=u.slice(0,-1)+Yr(d));const g=s.move(i);return o(),t.attentionEncodeSurroundingInfo={after:m.outside,before:h.outside},a+u+g}function jI(n,e,t){return t.options.emphasis||"*"}const eu=function(n){if(n==null)return XI;if(typeof n=="function")return tu(n);if(typeof n=="object")return Array.isArray(n)?JI(n):GI(n);if(typeof n=="string")return YI(n);throw new Error("Expected function, string, or object as test")};function JI(n){const e=[];let t=-1;for(;++t<n.length;)e[t]=eu(n[t]);return tu(r);function r(...i){let o=-1;for(;++o<e.length;)if(e[o].apply(this,i))return!0;return!1}}function GI(n){const e=n;return tu(t);function t(r){const i=r;let o;for(o in n)if(i[o]!==e[o])return!1;return!0}}function YI(n){return tu(e);function e(t){return t&&t.type===n}}function tu(n){return e;function e(t,r,i){return!!(QI(t)&&n.call(this,t,typeof r=="number"?r:void 0,i||void 0))}}function XI(){return!0}function QI(n){return n!==null&&typeof n=="object"&&"type"in n}const m1=[],ZI=!0,Vf=!1,Hf="skip";function Nh(n,e,t,r){let i;typeof e=="function"&&typeof t!="function"?(r=t,t=e):i=e;const o=eu(i),s=r?-1:1;a(n,void 0,[])();function a(u,f,h){const d=u&&typeof u=="object"?u:{};if(typeof d.type=="string"){const g=typeof d.tagName=="string"?d.tagName:typeof d.name=="string"?d.name:void 0;Object.defineProperty(m,"name",{value:"node ("+(u.type+(g?"<"+g+">":""))+")"})}return m;function m(){let g=m1,k,C,v;if((!e||o(u,f,h[h.length-1]||void 0))&&(g=eE(t(u,h)),g[0]===Vf))return g;if("children"in u&&u.children){const S=u;if(S.children&&g[0]!==Hf)for(C=(r?S.children.length:-1)+s,v=h.concat(S);C>-1&&C<S.children.length;){const L=S.children[C];if(k=a(L,C,v)(),k[0]===Vf)return k;C=typeof k[1]=="number"?k[1]:C+s}}return g}}}function eE(n){return Array.isArray(n)?n:typeof n=="number"?[ZI,n]:n==null?m1:[n]}function _o(n,e,t,r){let i,o,s;typeof e=="function"&&typeof t!="function"?(o=void 0,s=e,i=t):(o=e,s=t,i=r),Nh(n,o,a,i);function a(u,f){const h=f[f.length-1],d=h?h.children.indexOf(u):void 0;return s(u,d,h)}}function g1(n,e){let t=!1;return _o(n,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return t=!0,Vf}),!!((!n.depth||n.depth<3)&&Sh(n)&&(e.options.setext||t))}function tE(n,e,t,r){const i=Math.max(Math.min(6,n.depth||1),1),o=t.createTracker(r);if(g1(n,t)){const h=t.enter("headingSetext"),d=t.enter("phrasing"),m=t.containerPhrasing(n,{...o.current(),before:`
10
+ `,after:`
11
+ `});return d(),h(),m+`
12
+ `+(i===1?"=":"-").repeat(m.length-(Math.max(m.lastIndexOf("\r"),m.lastIndexOf(`
13
+ `))+1))}const s="#".repeat(i),a=t.enter("headingAtx"),u=t.enter("phrasing");o.move(s+" ");let f=t.containerPhrasing(n,{before:"# ",after:`
14
+ `,...o.current()});return/^[\t ]/.test(f)&&(f=Yr(f.charCodeAt(0))+f.slice(1)),f=f?s+" "+f:s,t.options.closeAtx&&(f+=" "+s),u(),a(),f}y1.peek=nE;function y1(n){return n.value||""}function nE(){return"<"}k1.peek=rE;function k1(n,e,t,r){const i=Ah(t),o=i==='"'?"Quote":"Apostrophe",s=t.enter("image");let a=t.enter("label");const u=t.createTracker(r);let f=u.move("![");return f+=u.move(t.safe(n.alt,{before:f,after:"]",...u.current()})),f+=u.move("]("),a(),!n.url&&n.title||/[\0- \u007F]/.test(n.url)?(a=t.enter("destinationLiteral"),f+=u.move("<"),f+=u.move(t.safe(n.url,{before:f,after:">",...u.current()})),f+=u.move(">")):(a=t.enter("destinationRaw"),f+=u.move(t.safe(n.url,{before:f,after:n.title?" ":")",...u.current()}))),a(),n.title&&(a=t.enter(`title${o}`),f+=u.move(" "+i),f+=u.move(t.safe(n.title,{before:f,after:i,...u.current()})),f+=u.move(i),a()),f+=u.move(")"),s(),f}function rE(){return"!"}b1.peek=iE;function b1(n,e,t,r){const i=n.referenceType,o=t.enter("imageReference");let s=t.enter("label");const a=t.createTracker(r);let u=a.move("![");const f=t.safe(n.alt,{before:u,after:"]",...a.current()});u+=a.move(f+"]["),s();const h=t.stack;t.stack=[],s=t.enter("reference");const d=t.safe(t.associationId(n),{before:u,after:"]",...a.current()});return s(),t.stack=h,o(),i==="full"||!f||f!==d?u+=a.move(d+"]"):i==="shortcut"?u=u.slice(0,-1):u+=a.move("]"),u}function iE(){return"!"}x1.peek=oE;function x1(n,e,t){let r=n.value||"",i="`",o=-1;for(;new RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++o<t.unsafe.length;){const s=t.unsafe[o],a=t.compilePattern(s);let u;if(s.atBreak)for(;u=a.exec(r);){let f=u.index;r.charCodeAt(f)===10&&r.charCodeAt(f-1)===13&&f--,r=r.slice(0,f)+" "+r.slice(u.index+1)}}return i+r+i}function oE(){return"`"}function w1(n,e){const t=Sh(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))}C1.peek=sE;function C1(n,e,t,r){const i=Ah(t),o=i==='"'?"Quote":"Apostrophe",s=t.createTracker(r);let a,u;if(w1(n,t)){const h=t.stack;t.stack=[],a=t.enter("autolink");let d=s.move("<");return d+=s.move(t.containerPhrasing(n,{before:d,after:">",...s.current()})),d+=s.move(">"),a(),t.stack=h,d}a=t.enter("link"),u=t.enter("label");let f=s.move("[");return f+=s.move(t.containerPhrasing(n,{before:f,after:"](",...s.current()})),f+=s.move("]("),u(),!n.url&&n.title||/[\0- \u007F]/.test(n.url)?(u=t.enter("destinationLiteral"),f+=s.move("<"),f+=s.move(t.safe(n.url,{before:f,after:">",...s.current()})),f+=s.move(">")):(u=t.enter("destinationRaw"),f+=s.move(t.safe(n.url,{before:f,after:n.title?" ":")",...s.current()}))),u(),n.title&&(u=t.enter(`title${o}`),f+=s.move(" "+i),f+=s.move(t.safe(n.title,{before:f,after:i,...s.current()})),f+=s.move(i),u()),f+=s.move(")"),a(),f}function sE(n,e,t){return w1(n,t)?"<":"["}S1.peek=lE;function S1(n,e,t,r){const i=n.referenceType,o=t.enter("linkReference");let s=t.enter("label");const a=t.createTracker(r);let u=a.move("[");const f=t.containerPhrasing(n,{before:u,after:"]",...a.current()});u+=a.move(f+"]["),s();const h=t.stack;t.stack=[],s=t.enter("reference");const d=t.safe(t.associationId(n),{before:u,after:"]",...a.current()});return s(),t.stack=h,o(),i==="full"||!f||f!==d?u+=a.move(d+"]"):i==="shortcut"?u=u.slice(0,-1):u+=a.move("]"),u}function lE(){return"["}function Mh(n){const e=n.options.bullet||"*";if(e!=="*"&&e!=="+"&&e!=="-")throw new Error("Cannot serialize items with `"+e+"` for `options.bullet`, expected `*`, `+`, or `-`");return e}function aE(n){const e=Mh(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 uE(n){const e=n.options.bulletOrdered||".";if(e!=="."&&e!==")")throw new Error("Cannot serialize items with `"+e+"` for `options.bulletOrdered`, expected `.` or `)`");return e}function v1(n){const e=n.options.rule||"*";if(e!=="*"&&e!=="-"&&e!=="_")throw new Error("Cannot serialize rules with `"+e+"` for `options.rule`, expected `*`, `-`, or `_`");return e}function cE(n,e,t,r){const i=t.enter("list"),o=t.bulletCurrent;let s=n.ordered?uE(t):Mh(t);const a=n.ordered?s==="."?")":".":aE(t);let u=e&&t.bulletLastUsed?s===t.bulletLastUsed:!1;if(!n.ordered){const h=n.children?n.children[0]:void 0;if((s==="*"||s==="-")&&h&&(!h.children||!h.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&&(u=!0),v1(t)===s&&h){let d=-1;for(;++d<n.children.length;){const m=n.children[d];if(m&&m.type==="listItem"&&m.children&&m.children[0]&&m.children[0].type==="thematicBreak"){u=!0;break}}}}u&&(s=a),t.bulletCurrent=s;const f=t.containerFlow(n,r);return t.bulletLastUsed=s,t.bulletCurrent=o,i(),f}function fE(n){const 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 hE(n,e,t,r){const i=fE(t);let o=t.bulletCurrent||Mh(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);const a=t.createTracker(r);a.move(o+" ".repeat(s-o.length)),a.shift(s);const u=t.enter("listItem"),f=t.indentLines(t.containerFlow(n,a.current()),h);return u(),f;function h(d,m,g){return m?(g?"":" ".repeat(s))+d:(g?o:o+" ".repeat(s-o.length))+d}}function dE(n,e,t,r){const i=t.enter("paragraph"),o=t.enter("phrasing"),s=t.containerPhrasing(n,r);return o(),i(),s}const pE=eu(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function mE(n,e,t,r){return(n.children.some(function(s){return pE(s)})?t.containerPhrasing:t.containerFlow).call(t,n,r)}function gE(n){const e=n.options.strong||"*";if(e!=="*"&&e!=="_")throw new Error("Cannot serialize strong with `"+e+"` for `options.strong`, expected `*`, or `_`");return e}T1.peek=yE;function T1(n,e,t,r){const i=gE(t),o=t.enter("strong"),s=t.createTracker(r),a=s.move(i+i);let u=s.move(t.containerPhrasing(n,{after:i,before:a,...s.current()}));const f=u.charCodeAt(0),h=xa(r.before.charCodeAt(r.before.length-1),f,i);h.inside&&(u=Yr(f)+u.slice(1));const d=u.charCodeAt(u.length-1),m=xa(r.after.charCodeAt(0),d,i);m.inside&&(u=u.slice(0,-1)+Yr(d));const g=s.move(i+i);return o(),t.attentionEncodeSurroundingInfo={after:m.outside,before:h.outside},a+u+g}function yE(n,e,t){return t.options.strong||"*"}function kE(n,e,t,r){return t.safe(n.value,r)}function bE(n){const 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 xE(n,e,t){const r=(v1(t)+(t.options.ruleSpaces?" ":"")).repeat(bE(t));return t.options.ruleSpaces?r.slice(0,-1):r}const Ih={blockquote:zI,break:eg,code:HI,definition:KI,emphasis:p1,hardBreak:eg,heading:tE,html:y1,image:k1,imageReference:b1,inlineCode:x1,link:C1,linkReference:S1,list:cE,listItem:hE,paragraph:dE,root:mE,strong:T1,text:kE,thematicBreak:xE},wE=[CE];function CE(n,e,t,r){if(e.type==="code"&&Wf(e,r)&&(n.type==="list"||n.type===e.type&&Wf(n,r)))return!1;if("spread"in t&&typeof t.spread=="boolean")return n.type==="paragraph"&&(n.type===e.type||e.type==="definition"||e.type==="heading"&&g1(e,r))?void 0:t.spread?1:0}const mi=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"],SE=[{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:`
15
+ `,inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde","codeFencedMetaGraveAccent","codeFencedMetaTilde","destinationLiteral","headingAtx"]},{character:" ",after:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",before:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde"]},{character:"!",after:"\\[",inConstruct:"phrasing",notInConstruct:mi},{character:'"',inConstruct:"titleQuote"},{atBreak:!0,character:"#"},{character:"#",inConstruct:"headingAtx",after:`(?:[\r
16
+ ]|$)`},{character:"&",after:"[#A-Za-z]",inConstruct:"phrasing"},{character:"'",inConstruct:"titleApostrophe"},{character:"(",inConstruct:"destinationRaw"},{before:"\\]",character:"(",inConstruct:"phrasing",notInConstruct:mi},{atBreak:!0,before:"\\d+",character:")"},{character:")",inConstruct:"destinationRaw"},{atBreak:!0,character:"*",after:`(?:[ \r
17
+ *])`},{character:"*",inConstruct:"phrasing",notInConstruct:mi},{atBreak:!0,character:"+",after:`(?:[ \r
18
+ ])`},{atBreak:!0,character:"-",after:`(?:[ \r
19
+ -])`},{atBreak:!0,before:"\\d+",character:".",after:`(?:[ \r
20
+ ]|$)`},{atBreak:!0,character:"<",after:"[!/?A-Za-z]"},{character:"<",after:"[!/?A-Za-z]",inConstruct:"phrasing",notInConstruct:mi},{character:"<",inConstruct:"destinationLiteral"},{atBreak:!0,character:"="},{atBreak:!0,character:">"},{character:">",inConstruct:"destinationLiteral"},{atBreak:!0,character:"["},{character:"[",inConstruct:"phrasing",notInConstruct:mi},{character:"[",inConstruct:["label","reference"]},{character:"\\",after:"[\\r\\n]",inConstruct:"phrasing"},{character:"]",inConstruct:["label","reference"]},{atBreak:!0,character:"_"},{character:"_",inConstruct:"phrasing",notInConstruct:mi},{atBreak:!0,character:"`"},{character:"`",inConstruct:["codeFencedLangGraveAccent","codeFencedMetaGraveAccent"]},{character:"`",inConstruct:"phrasing",notInConstruct:mi},{atBreak:!0,character:"~"}];function vE(n){return n.label||!n.identifier?n.label||"":u1(n.identifier)}function TE(n){if(!n._compiled){const e=(n.atBreak?"[\\r\\n][\\t ]*":"")+(n.before?"(?:"+n.before+")":"");n._compiled=new RegExp((e?"("+e+")":"")+(/[|\\{}()[\]^$+*?.-]/.test(n.character)?"\\":"")+n.character+(n.after?"(?:"+n.after+")":""),"g")}return n._compiled}function AE(n,e,t){const r=e.indexStack,i=n.children||[],o=[];let s=-1,a=t.before,u;r.push(-1);let f=e.createTracker(t);for(;++s<i.length;){const h=i[s];let d;if(r[r.length-1]=s,s+1<i.length){let k=e.handle.handlers[i[s+1].type];k&&k.peek&&(k=k.peek),d=k?k(i[s+1],n,e,{before:"",after:"",...f.current()}).charAt(0):""}else d=t.after;o.length>0&&(a==="\r"||a===`
21
+ `)&&h.type==="html"&&(o[o.length-1]=o[o.length-1].replace(/(\r?\n|\r)$/," "),a=" ",f=e.createTracker(t),f.move(o.join("")));let m=e.handle(h,n,e,{...f.current(),after:d,before:a});u&&u===m.slice(0,1)&&(m=Yr(u.charCodeAt(0))+m.slice(1));const g=e.attentionEncodeSurroundingInfo;e.attentionEncodeSurroundingInfo=void 0,u=void 0,g&&(o.length>0&&g.before&&a===o[o.length-1].slice(-1)&&(o[o.length-1]=o[o.length-1].slice(0,-1)+Yr(a.charCodeAt(0))),g.after&&(u=d)),f.move(m),o.push(m),a=m.slice(-1)}return r.pop(),o.join("")}function NE(n,e,t){const r=e.indexStack,i=n.children||[],o=e.createTracker(t),s=[];let a=-1;for(r.push(-1);++a<i.length;){const u=i[a];r[r.length-1]=a,s.push(o.move(e.handle(u,n,e,{before:`
22
+ `,after:`
23
+ `,...o.current()}))),u.type!=="list"&&(e.bulletLastUsed=void 0),a<i.length-1&&s.push(o.move(ME(u,i[a+1],n,e)))}return r.pop(),s.join("")}function ME(n,e,t,r){let i=r.join.length;for(;i--;){const o=r.join[i](n,e,t,r);if(o===!0||o===1)break;if(typeof o=="number")return`
24
+ `.repeat(1+o);if(o===!1)return`
25
+
26
+ <!---->
27
+
28
+ `}return`
29
+
30
+ `}const IE=/\r?\n|\r/g;function EE(n,e){const t=[];let r=0,i=0,o;for(;o=IE.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(a){t.push(e(a,i,!a))}}function OE(n,e,t){const r=(t.before||"")+(e||"")+(t.after||""),i=[],o=[],s={};let a=-1;for(;++a<n.unsafe.length;){const h=n.unsafe[a];if(!d1(n.stack,h))continue;const d=n.compilePattern(h);let m;for(;m=d.exec(r);){const g="before"in h||!!h.atBreak,k="after"in h,C=m.index+(g?m[1].length:0);i.includes(C)?(s[C].before&&!g&&(s[C].before=!1),s[C].after&&!k&&(s[C].after=!1)):(i.push(C),s[C]={before:g,after:k})}}i.sort(RE);let u=t.before?t.before.length:0;const f=r.length-(t.after?t.after.length:0);for(a=-1;++a<i.length;){const h=i[a];h<u||h>=f||h+1<f&&i[a+1]===h+1&&s[h].after&&!s[h+1].before&&!s[h+1].after||i[a-1]===h-1&&s[h].before&&!s[h-1].before&&!s[h-1].after||(u!==h&&o.push(tg(r.slice(u,h),"\\")),u=h,/[!-/:-@[-`{-~]/.test(r.charAt(h))&&(!t.encode||!t.encode.includes(r.charAt(h)))?o.push("\\"):(o.push(Yr(r.charCodeAt(h))),u++))}return o.push(tg(r.slice(u,f),t.after)),o.join("")}function RE(n,e){return n-e}function tg(n,e){const t=/\\(?=[!-/:-@[-`{-~])/g,r=[],i=[],o=n+e;let s=-1,a=0,u;for(;u=t.exec(o);)r.push(u.index);for(;++s<r.length;)a!==r[s]&&i.push(n.slice(a,r[s])),i.push("\\"),a=r[s];return i.push(n.slice(a)),i.join("")}function _E(n){const e=n||{},t=e.now||{};let r=e.lineShift||0,i=t.line||1,o=t.column||1;return{move:u,current:s,shift:a};function s(){return{now:{line:i,column:o},lineShift:r}}function a(f){r+=f}function u(f){const h=f||"",d=h.split(/\r?\n|\r/g),m=d[d.length-1];return i+=d.length-1,o=d.length===1?o+m.length:1+m.length+r,h}}function DE(n,e){const t=e||{},r={associationId:vE,containerPhrasing:FE,containerFlow:zE,createTracker:_E,compilePattern:TE,enter:o,handlers:{...Ih},handle:void 0,indentLines:EE,indexStack:[],join:[...wE],options:{},safe:$E,stack:[],unsafe:[...SE]};h1(r,t),r.options.tightDefinitions&&r.join.push(BE),r.handle=PI("type",{invalid:LE,unknown:PE,handlers:r.handlers});let i=r.handle(n,void 0,r,{before:`
31
+ `,after:`
32
+ `,now:{line:1,column:1},lineShift:0});return i&&i.charCodeAt(i.length-1)!==10&&i.charCodeAt(i.length-1)!==13&&(i+=`
33
+ `),i;function o(s){return r.stack.push(s),a;function a(){r.stack.pop()}}}function LE(n){throw new Error("Cannot handle value `"+n+"`, expected node")}function PE(n){const e=n;throw new Error("Cannot handle unknown node `"+e.type+"`")}function BE(n,e){if(n.type==="definition"&&n.type===e.type)return 0}function FE(n,e){return AE(n,this,e)}function zE(n,e){return NE(n,this,e)}function $E(n,e){return OE(this,n,e)}function WE(n){const e=this;e.compiler=t;function t(r){return DE(r,{...e.data("settings"),...n,extensions:e.data("toMarkdownExtensions")||[]})}}function ng(n){if(n)throw n}var ts=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function VE(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var ua=Object.prototype.hasOwnProperty,A1=Object.prototype.toString,rg=Object.defineProperty,ig=Object.getOwnPropertyDescriptor,og=function(e){return typeof Array.isArray=="function"?Array.isArray(e):A1.call(e)==="[object Array]"},sg=function(e){if(!e||A1.call(e)!=="[object Object]")return!1;var t=ua.call(e,"constructor"),r=e.constructor&&e.constructor.prototype&&ua.call(e.constructor.prototype,"isPrototypeOf");if(e.constructor&&!t&&!r)return!1;var i;for(i in e);return typeof i>"u"||ua.call(e,i)},lg=function(e,t){rg&&t.name==="__proto__"?rg(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},ag=function(e,t){if(t==="__proto__")if(ua.call(e,t)){if(ig)return ig(e,t).value}else return;return e[t]},HE=function n(){var e,t,r,i,o,s,a=arguments[0],u=1,f=arguments.length,h=!1;for(typeof a=="boolean"&&(h=a,a=arguments[1]||{},u=2),(a==null||typeof a!="object"&&typeof a!="function")&&(a={});u<f;++u)if(e=arguments[u],e!=null)for(t in e)r=ag(a,t),i=ag(e,t),a!==i&&(h&&i&&(sg(i)||(o=og(i)))?(o?(o=!1,s=r&&og(r)?r:[]):s=r&&sg(r)?r:{},lg(a,{name:t,newValue:n(h,s,i)})):typeof i<"u"&&lg(a,{name:t,newValue:i}));return a};const qc=VE(HE);function qf(n){if(typeof n!="object"||n===null)return!1;const e=Object.getPrototypeOf(n);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in n)&&!(Symbol.iterator in n)}function qE(){const n=[],e={run:t,use:r};return e;function t(...i){let o=-1;const s=i.pop();if(typeof s!="function")throw new TypeError("Expected function as last argument, not "+s);a(null,...i);function a(u,...f){const h=n[++o];let d=-1;if(u){s(u);return}for(;++d<i.length;)(f[d]===null||f[d]===void 0)&&(f[d]=i[d]);i=f,h?KE(h,a)(...f):s(null,...f)}}function r(i){if(typeof i!="function")throw new TypeError("Expected `middelware` to be a function, not "+i);return n.push(i),e}}function KE(n,e){let t;return r;function r(...s){const a=n.length>s.length;let u;a&&s.push(i);try{u=n.apply(this,s)}catch(f){const h=f;if(a&&t)throw h;return i(h)}a||(u&&u.then&&typeof u.then=="function"?u.then(o,i):u instanceof Error?i(u):o(u))}function i(s,...a){t||(t=!0,e(s,...a))}function o(s){i(null,s)}}class Lt 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"){const u=r.indexOf(":");u===-1?o.ruleId=r:(o.source=r.slice(0,u),o.ruleId=r.slice(u+1))}if(!o.place&&o.ancestors&&o.ancestors){const u=o.ancestors[o.ancestors.length-1];u&&(o.place=u.position)}const a=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=a?a.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=a?a.line:void 0,this.name=cs(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}}Lt.prototype.file="";Lt.prototype.name="";Lt.prototype.reason="";Lt.prototype.message="";Lt.prototype.stack="";Lt.prototype.column=void 0;Lt.prototype.line=void 0;Lt.prototype.ancestors=void 0;Lt.prototype.cause=void 0;Lt.prototype.fatal=void 0;Lt.prototype.place=void 0;Lt.prototype.ruleId=void 0;Lt.prototype.source=void 0;const Vn={basename:UE,dirname:jE,extname:JE,join:GE,sep:"/"};function UE(n,e){if(e!==void 0&&typeof e!="string")throw new TypeError('"ext" argument must be a string');js(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,a=e.length-1;for(;i--;)if(n.codePointAt(i)===47){if(o){t=i+1;break}}else s<0&&(o=!0,s=i+1),a>-1&&(n.codePointAt(i)===e.codePointAt(a--)?a<0&&(r=i):(a=-1,r=s));return t===r?r=s:r<0&&(r=n.length),n.slice(t,r)}function jE(n){if(js(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 JE(n){js(n);let e=n.length,t=-1,r=0,i=-1,o=0,s;for(;e--;){const a=n.codePointAt(e);if(a===47){if(s){r=e+1;break}continue}t<0&&(s=!0,t=e+1),a===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 GE(...n){let e=-1,t;for(;++e<n.length;)js(n[e]),n[e]&&(t=t===void 0?n[e]:t+"/"+n[e]);return t===void 0?".":YE(t)}function YE(n){js(n);const e=n.codePointAt(0)===47;let t=XE(n,!e);return t.length===0&&!e&&(t="."),t.length>0&&n.codePointAt(n.length-1)===47&&(t+="/"),e?"/"+t:t}function XE(n,e){let t="",r=0,i=-1,o=0,s=-1,a,u;for(;++s<=n.length;){if(s<n.length)a=n.codePointAt(s);else{if(a===47)break;a=47}if(a===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(u=t.lastIndexOf("/"),u!==t.length-1){u<0?(t="",r=0):(t=t.slice(0,u),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 a===46&&o>-1?o++:o=-1}return t}function js(n){if(typeof n!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(n))}const QE={cwd:ZE};function ZE(){return"/"}function Kf(n){return!!(n!==null&&typeof n=="object"&&"href"in n&&n.href&&"protocol"in n&&n.protocol&&n.auth===void 0)}function eO(n){if(typeof n=="string")n=new URL(n);else if(!Kf(n)){const 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:"){const e=new TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return tO(n)}function tO(n){if(n.hostname!==""){const r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}const e=n.pathname;let t=-1;for(;++t<e.length;)if(e.codePointAt(t)===37&&e.codePointAt(t+1)===50){const r=e.codePointAt(t+2);if(r===70||r===102){const i=new TypeError("File URL path must not include encoded / characters");throw i.code="ERR_INVALID_FILE_URL_PATH",i}}return decodeURIComponent(e)}const Kc=["history","path","basename","stem","extname","dirname"];class nO{constructor(e){let t;e?Kf(e)?t={path:e}:typeof e=="string"||rO(e)?t={value:e}:t=e:t={},this.cwd="cwd"in t?"":QE.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<Kc.length;){const o=Kc[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)Kc.includes(i)||(this[i]=t[i])}get basename(){return typeof this.path=="string"?Vn.basename(this.path):void 0}set basename(e){jc(e,"basename"),Uc(e,"basename"),this.path=Vn.join(this.dirname||"",e)}get dirname(){return typeof this.path=="string"?Vn.dirname(this.path):void 0}set dirname(e){ug(this.basename,"dirname"),this.path=Vn.join(e||"",this.basename)}get extname(){return typeof this.path=="string"?Vn.extname(this.path):void 0}set extname(e){if(Uc(e,"extname"),ug(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=Vn.join(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){Kf(e)&&(e=eO(e)),jc(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path=="string"?Vn.basename(this.path,this.extname):void 0}set stem(e){jc(e,"stem"),Uc(e,"stem"),this.path=Vn.join(this.dirname||"",e+(this.extname||""))}fail(e,t,r){const i=this.message(e,t,r);throw i.fatal=!0,i}info(e,t,r){const i=this.message(e,t,r);return i.fatal=void 0,i}message(e,t,r){const i=new Lt(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 Uc(n,e){if(n&&n.includes(Vn.sep))throw new Error("`"+e+"` cannot be a path: did not expect `"+Vn.sep+"`")}function jc(n,e){if(!n)throw new Error("`"+e+"` cannot be empty")}function ug(n,e){if(!n)throw new Error("Setting `"+e+"` requires `path` to be set too")}function rO(n){return!!(n&&typeof n=="object"&&"byteLength"in n&&"byteOffset"in n)}const iO=function(n){const r=this.constructor.prototype,i=r[n],o=function(){return i.apply(o,arguments)};return Object.setPrototypeOf(o,r),o},oO={}.hasOwnProperty;class Eh extends iO{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=qE()}copy(){const e=new Eh;let t=-1;for(;++t<this.attachers.length;){const r=this.attachers[t];e.use(...r)}return e.data(qc(!0,{},this.namespace)),e}data(e,t){return typeof e=="string"?arguments.length===2?(Yc("data",this.frozen),this.namespace[e]=t,this):oO.call(this.namespace,e)&&this.namespace[e]||void 0:e?(Yc("data",this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;const e=this;for(;++this.freezeIndex<this.attachers.length;){const[t,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);const 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();const t=Zl(e),r=this.parser||this.Parser;return Jc("parse",r),r(String(t),t)}process(e,t){const r=this;return this.freeze(),Jc("process",this.parser||this.Parser),Gc("process",this.compiler||this.Compiler),t?i(void 0,t):new Promise(i);function i(o,s){const a=Zl(e),u=r.parse(a);r.run(u,a,function(h,d,m){if(h||!d||!m)return f(h);const g=d,k=r.stringify(g,m);aO(k)?m.value=k:m.result=k,f(h,m)});function f(h,d){h||!d?s(h):o?o(d):t(void 0,d)}}}processSync(e){let t=!1,r;return this.freeze(),Jc("processSync",this.parser||this.Parser),Gc("processSync",this.compiler||this.Compiler),this.process(e,i),fg("processSync","process",t),r;function i(o,s){t=!0,ng(o),r=s}}run(e,t,r){cg(e),this.freeze();const i=this.transformers;return!r&&typeof t=="function"&&(r=t,t=void 0),r?o(void 0,r):new Promise(o);function o(s,a){const u=Zl(t);i.run(e,u,f);function f(h,d,m){const g=d||e;h?a(h):s?s(g):r(void 0,g,m)}}}runSync(e,t){let r=!1,i;return this.run(e,t,o),fg("runSync","run",r),i;function o(s,a){ng(s),i=a,r=!0}}stringify(e,t){this.freeze();const r=Zl(t),i=this.compiler||this.Compiler;return Gc("stringify",i),cg(e),i(e,r)}use(e,...t){const r=this.attachers,i=this.namespace;if(Yc("use",this.frozen),e!=null)if(typeof e=="function")u(e,t);else if(typeof e=="object")Array.isArray(e)?a(e):s(e);else throw new TypeError("Expected usable value, not `"+e+"`");return this;function o(f){if(typeof f=="function")u(f,[]);else if(typeof f=="object")if(Array.isArray(f)){const[h,...d]=f;u(h,d)}else s(f);else throw new TypeError("Expected usable value, not `"+f+"`")}function s(f){if(!("plugins"in f)&&!("settings"in f))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");a(f.plugins),f.settings&&(i.settings=qc(!0,i.settings,f.settings))}function a(f){let h=-1;if(f!=null)if(Array.isArray(f))for(;++h<f.length;){const d=f[h];o(d)}else throw new TypeError("Expected a list of plugins, not `"+f+"`")}function u(f,h){let d=-1,m=-1;for(;++d<r.length;)if(r[d][0]===f){m=d;break}if(m===-1)r.push([f,...h]);else if(h.length>0){let[g,...k]=h;const C=r[m][1];qf(C)&&qf(g)&&(g=qc(!0,C,g)),r[m]=[f,g,...k]}}}}const sO=new Eh().freeze();function Jc(n,e){if(typeof e!="function")throw new TypeError("Cannot `"+n+"` without `parser`")}function Gc(n,e){if(typeof e!="function")throw new TypeError("Cannot `"+n+"` without `compiler`")}function Yc(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 cg(n){if(!qf(n)||typeof n.type!="string")throw new TypeError("Expected node, got `"+n+"`")}function fg(n,e,t){if(!t)throw new Error("`"+n+"` finished async. Use `"+e+"` instead")}function Zl(n){return lO(n)?n:new nO(n)}function lO(n){return!!(n&&typeof n=="object"&&"message"in n&&"messages"in n)}function aO(n){return typeof n=="string"||uO(n)}function uO(n){return!!(n&&typeof n=="object"&&"byteLength"in n&&"byteOffset"in n)}var Gn=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}({}),Yn=class extends Error{constructor(n,e){super(e),this.name="MilkdownError",this.code=n}},cO=(n,e)=>typeof e=="function"?"[Function]":e,nu=n=>JSON.stringify(n,cO);function fO(n){return new Yn(Gn.docTypeError,`Doc type error, unsupported type: ${nu(n)}`)}function Oh(){return new Yn(Gn.ctxCallOutOfScope,"Should not call a context out of the plugin.")}function hO(n,e,t){const 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,[a,u])=>{const f=`${a}: ${i(u)}.`;return s.concat(f)},[]);return new Yn(Gn.createNodeInParserFail,o.join(`
34
+ `))}function N1(){return new Yn(Gn.stackOverFlow,"Stack over flow, cannot pop on an empty stack.")}function dO(n){return new Yn(Gn.parserMatchError,`Cannot match target parser for node: ${nu(n)}.`)}function pO(n){return new Yn(Gn.serializerMatchError,`Cannot match target serializer for node: ${nu(n)}.`)}function Xn(n){return new Yn(Gn.expectDomTypeError,`Expect to be a dom, but get: ${nu(n)}.`)}function Xc(){return new Yn(Gn.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 mO(n){return new Yn(Gn.missingNodeInSchema,`Missing node in schema, milkdown cannot find "${n}" in schema.`)}function gO(n){return new Yn(Gn.missingMarkInSchema,`Missing mark in schema, milkdown cannot find "${n}" in schema.`)}function ut(n){this.content=n}ut.prototype={constructor:ut,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 ut(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 ut(t)},addToStart:function(n,e){return new ut([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new ut(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 ut(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=ut.from(n),n.size?new ut(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=ut.from(n),n.size?new ut(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=ut.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}};ut.from=function(n){if(n instanceof ut)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new ut(e)};function M1(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){for(let s=0;i.text[s]==o.text[s];s++)t++;return t}if(i.content.size||o.content.size){let s=M1(i.content,o.content,t+1);if(s!=null)return s}t+=i.nodeSize}}function I1(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),a=e.child(--o),u=s.nodeSize;if(s==a){t-=u,r-=u;continue}if(!s.sameMarkup(a))return{a:t,b:r};if(s.isText&&s.text!=a.text){let f=0,h=Math.min(s.text.length,a.text.length);for(;f<h&&s.text[s.text.length-f-1]==a.text[a.text.length-f-1];)f++,t--,r--;return{a:t,b:r}}if(s.content.size||a.content.size){let f=I1(s.content,a.content,t-1,r-1);if(f)return f}t-=u,r-=u}}class W{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,a=0;a<t;s++){let u=this.content[s],f=a+u.nodeSize;if(f>e&&r(u,i+a,o||null,s)!==!1&&u.content.size){let h=a+1;u.nodesBetween(Math.max(0,e-h),Math.min(u.content.size,t-h),r,i+h)}a=f}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,i){let o="",s=!0;return this.nodesBetween(e,t,(a,u)=>{let f=a.isText?a.text.slice(Math.max(e,u)-u,t-u):a.isLeaf?i?typeof i=="function"?i(a):i:a.type.spec.leafText?a.type.spec.leafText(a):"":"";a.isBlock&&(a.isLeaf&&f||a.isTextblock)&&r&&(s?s=!1:o+=r),o+=f},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 W(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 a=this.content[o],u=s+a.nodeSize;u>e&&((s<e||u>t)&&(a.isText?a=a.cut(Math.max(0,e-s),Math.min(a.text.length,t-s)):a=a.cut(Math.max(0,e-s-1),Math.min(a.content.size,t-s-1))),r.push(a),i+=a.nodeSize),s=u}return new W(r,i)}cutByIndex(e,t){return e==t?W.empty:e==0&&t==this.content.length?this:new W(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 W(i,o)}addToStart(e){return new W([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new W(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 M1(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return I1(this,e,t,r)}findIndex(e){if(e==0)return ea(0,e);if(e==this.size)return ea(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?ea(t+1,o):ea(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 W.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new W(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return W.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 W(t||e,r)}static from(e){if(!e)return W.empty;if(e instanceof W)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new W([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}W.empty=new W([],0);const Qc={index:0,offset:0};function ea(n,e){return Qc.index=n,Qc.offset=e,Qc}function wa(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(!wa(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!wa(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}class Ne{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&&wa(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`);let i=r.create(t.attrs);return r.checkAttrs(i.attrs),i}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 Ne.none;if(e instanceof Ne)return[e];let t=e.slice();return t.sort((r,i)=>r.type.rank-i.type.rank),t}}Ne.none=[];class Ca extends Error{}class J{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=O1(this.content,e+this.openStart,t);return r&&new J(r,this.openStart,this.openEnd)}removeBetween(e,t){return new J(E1(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 J.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 J(W.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 J(e,r,i)}}J.empty=new J(W.empty,0,0);function E1(n,e,t){let{index:r,offset:i}=n.findIndex(e),o=n.maybeChild(r),{index:s,offset:a}=n.findIndex(t);if(i==e||o.isText){if(a!=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(E1(o.content,e-i-1,t-i-1)))}function O1(n,e,t,r){let{index:i,offset:o}=n.findIndex(e),s=n.maybeChild(i);if(o==e||s.isText)return r&&!r.canReplace(i,i,t)?null:n.cut(0,e).append(t).append(n.cut(e));let a=O1(s.content,e-o-1,t,s);return a&&n.replaceChild(i,s.copy(a))}function yO(n,e,t){if(t.openStart>n.depth)throw new Ca("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new Ca("Inconsistent open depths");return R1(n,e,t,0)}function R1(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=R1(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,a=s.content;return Ni(s,a.cut(0,n.parentOffset).append(t.content).append(a.cut(e.parentOffset)))}else{let{start:s,end:a}=kO(t,n);return Ni(o,D1(n,s,a,e,r))}else return Ni(o,Sa(n,e,r))}function _1(n,e){if(!e.type.compatibleContent(n.type))throw new Ca("Cannot join "+e.type.name+" onto "+n.type.name)}function Uf(n,e,t){let r=n.node(t);return _1(r,e.node(t)),r}function Ai(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 fs(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&&(Ai(n.nodeAfter,r),o++));for(let a=o;a<s;a++)Ai(i.child(a),r);e&&e.depth==t&&e.textOffset&&Ai(e.nodeBefore,r)}function Ni(n,e){return n.type.checkContent(e),n.copy(e)}function D1(n,e,t,r,i){let o=n.depth>i&&Uf(n,e,i+1),s=r.depth>i&&Uf(t,r,i+1),a=[];return fs(null,n,i,a),o&&s&&e.index(i)==t.index(i)?(_1(o,s),Ai(Ni(o,D1(n,e,t,r,i+1)),a)):(o&&Ai(Ni(o,Sa(n,e,i+1)),a),fs(e,t,i,a),s&&Ai(Ni(s,Sa(t,r,i+1)),a)),fs(r,null,i,a),new W(a)}function Sa(n,e,t){let r=[];if(fs(null,n,t,r),n.depth>t){let i=Uf(n,e,t+1);Ai(Ni(i,Sa(n,e,t+1)),r)}return fs(e,null,t,r),new W(r)}function kO(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(W.from(i));return{start:i.resolveNoCache(n.openStart+t),end:i.resolveNoCache(i.content.size-n.openEnd-t)}}class xs{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 Ne.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),i=e.maybeChild(t);if(!r){let a=r;r=i,i=a}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 L1(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:a,offset:u}=s.content.findIndex(o),f=o-u;if(r.push(s,a,i+u),!f||(s=s.child(a),s.isText))break;o=f-1,i+=u+1}return new xs(t,r,o)}static resolveCached(e,t){let r=hg.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 hg.set(e,r=new bO);let i=r.elts[r.i]=xs.resolve(e,t);return r.i=(r.i+1)%xO,i}}class bO{constructor(){this.elts=[],this.i=0}}const xO=12,hg=new WeakMap;class L1{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)}}const wO=Object.create(null);let br=class jf{constructor(e,t,r,i=Ne.none){this.type=e,this.attrs=t,this.marks=i,this.content=r||W.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&&wa(this.attrs,t||e.defaultAttrs||wO)&&Ne.sameSet(this.marks,r||Ne.none)}copy(e=null){return e==this.content?this:new jf(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new jf(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 J.empty;let i=this.resolve(e),o=this.resolve(t),s=r?0:i.sharedDepth(t),a=i.start(s),f=i.node(s).content.cut(i.pos-a,o.pos-a);return new J(f,i.depth-s,o.depth-s)}replace(e,t,r){return yO(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 xs.resolveCached(this,e)}resolveNoCache(e){return xs.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()+")"),P1(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=W.empty,i=0,o=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,i,o),a=s&&s.matchFragment(this.content,t);if(!a||!a.validEnd)return!1;for(let u=i;u<o;u++)if(!this.type.allowsMarks(r.child(u).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),this.type.checkAttrs(this.attrs);let e=Ne.none;for(let t=0;t<this.marks.length;t++){let r=this.marks[t];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!Ne.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=W.fromJSON(e,t.content),o=e.nodeType(t.type).create(t.attrs,i,r);return o.type.checkAttrs(o.attrs),o}};br.prototype.text=void 0;class va extends br{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):P1(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 va(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new va(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 P1(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class Li{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new CO(e,t);if(r.next==null)return Li.empty;let i=B1(r);r.next&&r.err("Unexpected trailing text");let o=IO(MO(i));return EO(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,a){let u=s.matchFragment(e,r);if(u&&(!t||u.validEnd))return W.from(a.map(f=>f.createAndFill()));for(let f=0;f<s.next.length;f++){let{type:h,next:d}=s.next[f];if(!(h.isText||h.hasRequiredAttrs())&&i.indexOf(d)==-1){i.push(d);let m=o(d,a.concat(h));if(m)return m}}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 a=i;a.type;a=a.via)s.push(a.type);return s.reverse()}for(let s=0;s<o.next.length;s++){let{type:a,next:u}=o.next[s];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in t)&&(!i.type||u.validEnd)&&(r.push({match:a.contentMatch,type:a,via:i}),t[a.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(`
35
+ `)}}Li.empty=new Li(!0);class CO{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 B1(n){let e=[];do e.push(SO(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function SO(n){let e=[];do e.push(vO(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function vO(n){let e=NO(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=TO(n,e);else break;return e}function dg(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function TO(n,e){let t=dg(n),r=t;return n.eat(",")&&(n.next!="}"?r=dg(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function AO(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 NO(n){if(n.eat("(")){let e=B1(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=AO(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 MO(n){let e=[[]];return i(o(n,0),t()),e;function t(){return e.push([])-1}function r(s,a,u){let f={term:u,to:a};return e[s].push(f),f}function i(s,a){s.forEach(u=>u.to=a)}function o(s,a){if(s.type=="choice")return s.exprs.reduce((u,f)=>u.concat(o(f,a)),[]);if(s.type=="seq")for(let u=0;;u++){let f=o(s.exprs[u],a);if(u==s.exprs.length-1)return f;i(f,a=t())}else if(s.type=="star"){let u=t();return r(a,u),i(o(s.expr,u),u),[r(u)]}else if(s.type=="plus"){let u=t();return i(o(s.expr,a),u),i(o(s.expr,u),u),[r(u)]}else{if(s.type=="opt")return[r(a)].concat(o(s.expr,a));if(s.type=="range"){let u=a;for(let f=0;f<s.min;f++){let h=t();i(o(s.expr,u),h),u=h}if(s.max==-1)i(o(s.expr,u),u);else for(let f=s.min;f<s.max;f++){let h=t();r(u,h),i(o(s.expr,u),h),u=h}return[r(u)]}else{if(s.type=="name")return[r(a,void 0,s.value)];throw new Error("Unknown expr type")}}}}function F1(n,e){return e-n}function pg(n,e){let t=[];return r(e),t.sort(F1);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:a,to:u}=o[s];!a&&t.indexOf(u)==-1&&r(u)}}}function IO(n){let e=Object.create(null);return t(pg(n,0));function t(r){let i=[];r.forEach(s=>{n[s].forEach(({term:a,to:u})=>{if(!a)return;let f;for(let h=0;h<i.length;h++)i[h][0]==a&&(f=i[h][1]);pg(n,u).forEach(h=>{f||i.push([a,f=[]]),f.indexOf(h)==-1&&f.push(h)})})});let o=e[r.join(",")]=new Li(r.indexOf(n.length-1)>-1);for(let s=0;s<i.length;s++){let a=i[s][1].sort(F1);o.next.push({type:i[s][0],next:e[a.join(",")]||t(a)})}return o}}function EO(n,e){for(let t=0,r=[n];t<r.length;t++){let i=r[t],o=!i.validEnd,s=[];for(let a=0;a<i.next.length;a++){let{type:u,next:f}=i.next[a];s.push(u.name),o&&!(u.isText||u.hasRequiredAttrs())&&(o=!1),r.indexOf(f)==-1&&r.push(f)}o&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function z1(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 $1(n,e){let t=Object.create(null);for(let r in n){let i=e&&e[r];if(i===void 0){let o=n[r];if(o.hasDefault)i=o.default;else throw new RangeError("No value supplied for attribute "+r)}t[r]=i}return t}function W1(n,e,t,r){for(let i in e)if(!(i in n))throw new RangeError(`Unsupported attribute ${i} for ${t} of type ${i}`);for(let i in n){let o=n[i];o.validate&&o.validate(e[i])}}function V1(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new RO(n,r,e[r]);return t}let mg=class H1{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=V1(e,r.attrs),this.defaultAttrs=z1(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==Li.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:$1(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new br(this,this.computeAttrs(e),W.from(t),Ne.setFrom(r))}createChecked(e=null,t,r){return t=W.from(t),this.checkContent(t),new br(this,this.computeAttrs(e),t,Ne.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=W.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(W.empty,!0);return o?new br(this,e,t.append(o),Ne.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){W1(this.attrs,e,"node",this.name)}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:Ne.none:e}static compile(e,t){let r=Object.create(null);e.forEach((o,s)=>r[o]=new H1(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 OO(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}`)}}class RO{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?OO(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class ru{constructor(e,t,r,i){this.name=e,this.rank=t,this.schema=r,this.spec=i,this.attrs=V1(e,i.attrs),this.excluded=null;let o=z1(this.attrs);this.instance=o?new Ne(this,o):null}create(e=null){return!e&&this.instance?this.instance:new Ne(this,$1(this.attrs,e))}static compile(e,t){let r=Object.create(null),i=0;return e.forEach((o,s)=>r[o]=new ru(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]}checkAttrs(e){W1(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class _O{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=ut.from(e.nodes),t.marks=ut.from(e.marks||{}),this.nodes=mg.compile(this.spec.nodes,this),this.marks=ru.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||"",a=o.spec.marks;if(o.contentMatch=r[s]||(r[s]=Li.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=a=="_"?null:a?gg(this,a.split(" ")):a==""||!o.inlineContent?[]:null}for(let i in this.marks){let o=this.marks[i],s=o.spec.excludes;o.excluded=s==null?[o]:s==""?[]:gg(this,s.split(" "))}this.nodeFromJSON=i=>br.fromJSON(this,i),this.markFromJSON=i=>Ne.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 mg){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 va(r,r.defaultAttrs,e,Ne.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 gg(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 a in n.marks){let u=n.marks[a];(i=="_"||u.spec.group&&u.spec.group.split(" ").indexOf(i)>-1)&&t.push(s=u)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function DO(n){return n.tag!=null}function LO(n){return n.style!=null}class Ao{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(i=>{if(DO(i))this.tags.push(i);else if(LO(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 kg(this,t,!1);return r.addAll(e,Ne.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new kg(this,t,!0);return r.addAll(e,Ne.none,t.from,t.to),J.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(FO(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],a=s.style;if(!(a.indexOf(e)!=0||s.context&&!r.matchesContext(s.context)||a.length>e.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=t))){if(s.getAttrs){let u=s.getAttrs(t);if(u===!1)continue;s.attrs=u||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 a=t[s];if((a.priority==null?50:a.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=bg(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=bg(s)),s.node||s.ignore||s.mark||(s.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Ao(e,Ao.schemaRules(e)))}}const q1={address:!0,article:!0,aside:!0,blockquote:!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},PO={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},K1={ol:!0,ul:!0},ws=1,Jf=2,hs=4;function yg(n,e,t){return e!=null?(e?ws:0)|(e==="full"?Jf:0):n&&n.whitespace=="pre"?ws|Jf:t&~hs}class ta{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=Ne.none,this.match=o||(s&hs?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(W.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&ws)){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=W.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(W.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&&!q1.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class kg{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=yg(null,t.preserveWhitespace,0)|(r?hs:0);i?o=new ta(i.type,i.attrs,Ne.none,!0,t.topMatch||i.type.contentMatch,s):r?o=new ta(null,null,Ne.none,!0,null,s):o=new ta(e.schema.topNodeType,null,Ne.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&Jf?"full":this.localPreserveWS||(i.options&ws)>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,`
36
+ `);else if(s.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(s.linebreakReplacement.create())){let a=r.split(/\r?\n|\r/);for(let u=0;u<a.length;u++)u&&this.insertNode(s.linebreakReplacement.create(),t,!0),a[u]&&this.insertNode(s.text(a[u]),t,!/\S/.test(a[u]));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 a=i.content[i.content.length-1],u=e.previousSibling;(!a||u&&u.nodeName=="BR"||a.isText&&/[ \t\r\n\u000c]$/.test(a.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(),a;K1.hasOwnProperty(s)&&this.parser.normalizeLists&&BO(e);let u=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(a=this.parser.matchTag(e,this,r));e:if(u?u.ignore:PO.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,t);else if(!u||u.skip||u.closeParent){u&&u.closeParent?this.open=Math.max(0,this.open-1):u&&u.skip.nodeType&&(e=u.skip);let f,h=this.needsBlock;if(q1.hasOwnProperty(s))o.content.length&&o.content[0].isInline&&this.open&&(this.open--,o=this.top),f=!0,o.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let d=u&&u.skip?t:this.readStyles(e,t);d&&this.addAll(e,d),f&&this.sync(o),this.needsBlock=h}else{let f=this.readStyles(e,t);f&&this.addElementByRule(e,u,f,u.consuming===!1?a:void 0)}this.localPreserveWS=i}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
37
+ `),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 a=void 0;;){let u=this.parser.matchStyle(o,s,this,a);if(!u)break;if(u.ignore)return null;if(u.clearMark?t=t.filter(f=>!u.clearMark(f)):t=t.concat(this.parser.schema.marks[u.mark].create(u.attrs)),u.consuming===!1)a=u;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 u=this.enter(s,t.attrs||null,r,t.preserveWhitespace);u&&(o=!0,r=u)}else{let u=this.parser.schema.marks[t.mark];r=r.concat(u.create(t.attrs))}let a=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(u=>this.insertNode(u,r,!1));else{let u=e;typeof t.contentElement=="string"?u=e.querySelector(t.contentElement):typeof t.contentElement=="function"?u=t.contentElement(e):t.contentElement&&(u=t.contentElement),this.findAround(e,u,!0),this.addAll(u,r),this.findAround(e,u,!1)}o&&this.sync(a)&&this.open--}addAll(e,t,r,i){let o=r||0;for(let s=r?e.childNodes[r]:e.firstChild,a=i==null?null:e.childNodes[i];s!=a;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,a=0;s>=0;s--){let u=this.nodes[s],f=u.findWrapping(e);if(f&&(!i||i.length>f.length+a)&&(i=f,o=u,!f.length))break;if(u.solid){if(r)break;a+=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=Ne.none;for(let a of i.concat(e.marks))(o.type?o.type.allowsMarkType(a.type):xg(a.type,e.type))&&(s=a.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 a=yg(e,o,s.options);s.options&hs&&s.content.length==0&&(a|=hs);let u=Ne.none;return r=r.filter(f=>(s.type?s.type.allowsMarkType(f.type):xg(f.type,e))?(u=f.addToSet(u),!1):!0),this.nodes.push(new ta(e,t,u,i,null,a)),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|=ws)}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=(a,u)=>{for(;a>=0;a--){let f=t[a];if(f==""){if(a==t.length-1||a==0)continue;for(;u>=o;u--)if(s(a-1,u))return!0;return!1}else{let h=u>0||u==0&&i?this.nodes[u].type:r&&u>=o?r.node(u-o).type:null;if(!h||h.name!=f&&!h.isInGroup(f))return!1;u--}}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 BO(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&K1.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function FO(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function bg(n){let e={};for(let t in n)e[t]=n[t];return e}function xg(n,e){let t=e.schema.nodes;for(let r in t){let i=t[r];if(!i.allowsMarkType(n))continue;let o=[],s=a=>{o.push(a);for(let u=0;u<a.edgeCount;u++){let{type:f,next:h}=a.edge(u);if(f==e||o.indexOf(h)<0&&s(h))return!0}};if(s(i.contentMatch))return!0}}class Do{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=Zc(t).createDocumentFragment());let i=r,o=[];return e.forEach(s=>{if(o.length||s.marks.length){let a=0,u=0;for(;a<o.length&&u<s.marks.length;){let f=s.marks[u];if(!this.marks[f.type.name]){u++;continue}if(!f.eq(o[a][0])||f.type.spec.spanning===!1)break;a++,u++}for(;a<o.length;)i=o.pop()[1];for(;u<s.marks.length;){let f=s.marks[u++],h=this.serializeMark(f,s.isInline,t);h&&(o.push([f,i]),i.appendChild(h.dom),i=h.contentDOM||h.dom)}}i.appendChild(this.serializeNodeInner(s,t))}),r}serializeNodeInner(e,t){let{dom:r,contentDOM:i}=ca(Zc(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&&ca(Zc(r),i(e,t),null,e.attrs)}static renderSpec(e,t,r=null,i){return ca(e,t,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Do(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=wg(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return wg(e.marks)}}function wg(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function Zc(n){return n.document||window.document}const Cg=new WeakMap;function zO(n){let e=Cg.get(n);return e===void 0&&Cg.set(n,e=$O(n)),e}function $O(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 ca(n,e,t,r){if(typeof e=="string")return{dom:n.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let i=e[0],o;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(o=zO(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 a,u=t?n.createElementNS(t,i):n.createElement(i),f=e[1],h=1;if(f&&typeof f=="object"&&f.nodeType==null&&!Array.isArray(f)){h=2;for(let d in f)if(f[d]!=null){let m=d.indexOf(" ");m>0?u.setAttributeNS(d.slice(0,m),d.slice(m+1),f[d]):d=="style"&&u.style?u.style.cssText=f[d]:u.setAttribute(d,f[d])}}for(let d=h;d<e.length;d++){let m=e[d];if(m===0){if(d<e.length-1||d>h)throw new RangeError("Content hole must be the only child of its parent node");return{dom:u,contentDOM:u}}else{let{dom:g,contentDOM:k}=ca(n,m,t,r);if(u.appendChild(g),k){if(a)throw new RangeError("Multiple content holes");a=k}}}return{dom:u,contentDOM:a}}const U1=65535,j1=Math.pow(2,16);function WO(n,e){return n+e*j1}function Sg(n){return n&U1}function VO(n){return(n-(n&U1))/j1}const J1=1,G1=2,fa=4,Y1=8;class Gf{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&Y1)>0}get deletedBefore(){return(this.delInfo&(J1|fa))>0}get deletedAfter(){return(this.delInfo&(G1|fa))>0}get deletedAcross(){return(this.delInfo&fa)>0}}class Yt{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&Yt.empty)return Yt.empty}recover(e){let t=0,r=Sg(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+VO(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 a=0;a<this.ranges.length;a+=3){let u=this.ranges[a]-(this.inverted?i:0);if(u>e)break;let f=this.ranges[a+o],h=this.ranges[a+s],d=u+f;if(e<=d){let m=f?e==u?-1:e==d?1:t:t,g=u+i+(m<0?0:h);if(r)return g;let k=e==(t<0?u:d)?null:WO(a/3,e-u),C=e==u?G1:e==d?J1:fa;return(t<0?e!=u:e!=d)&&(C|=Y1),new Gf(g,C,k)}i+=h-f}return r?e+i:new Gf(e+i,0,null)}touches(e,t){let r=0,i=Sg(t),o=this.inverted?2:1,s=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let u=this.ranges[a]-(this.inverted?r:0);if(u>e)break;let f=this.ranges[a+o],h=u+f;if(e<=h&&a==i*3)return!0;r+=this.ranges[a+s]-f}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],a=s-(this.inverted?o:0),u=s+(this.inverted?0:o),f=this.ranges[i+t],h=this.ranges[i+r];e(a,a+f,u,u+h),o+=h-f}}invert(){return new Yt(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Yt.empty:new Yt(e<0?[0,-e,0]:[0,0,e])}}Yt.empty=new Yt([]);class Ta{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 Ta(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 Ta;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],a=s.mapResult(e,t);if(a.recover!=null){let u=this.getMirror(o);if(u!=null&&u>o&&u<this.to){o=u,e=this._maps[u].recover(a.recover);continue}}i|=a.delInfo,e=a.pos}return r?e:new Gf(e,i,null)}}const ef=Object.create(null);class kt{getMap(){return Yt.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=ef[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 ef)throw new RangeError("Duplicate use of step JSON ID "+e);return ef[e]=t,t.prototype.jsonID=e,t}}class Ze{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new Ze(e,null)}static fail(e){return new Ze(null,e)}static fromReplace(e,t,r,i){try{return Ze.ok(e.replace(t,r,i))}catch(o){if(o instanceof Ca)return Ze.fail(o.message);throw o}}}function Rh(n,e,t){let r=[];for(let i=0;i<n.childCount;i++){let o=n.child(i);o.content.size&&(o=o.copy(Rh(o.content,e,o))),o.isInline&&(o=e(o,t,i)),r.push(o)}return W.fromArray(r)}class yr extends kt{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 J(Rh(t.content,(s,a)=>!s.isAtom||!a.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),i),t.openStart,t.openEnd);return Ze.fromReplace(e,this.from,this.to,o)}invert(){return new Kn(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new yr(t.pos,r.pos,this.mark)}merge(e){return e instanceof yr&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new yr(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 yr(t.from,t.to,e.markFromJSON(t.mark))}}kt.jsonID("addMark",yr);class Kn extends kt{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 J(Rh(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return Ze.fromReplace(e,this.from,this.to,r)}invert(){return new yr(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new Kn(t.pos,r.pos,this.mark)}merge(e){return e instanceof Kn&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Kn(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 Kn(t.from,t.to,e.markFromJSON(t.mark))}}kt.jsonID("removeMark",Kn);class Vr extends kt{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Ze.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return Ze.fromReplace(e,this.pos,this.pos+1,new J(W.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 Vr(this.pos,t.marks[i]);return new Vr(this.pos,this.mark)}}return new Pi(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Vr(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 Vr(t.pos,e.markFromJSON(t.mark))}}kt.jsonID("addNodeMark",Vr);class Pi extends kt{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Ze.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return Ze.fromReplace(e,this.pos,this.pos+1,new J(W.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Vr(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Pi(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 Pi(t.pos,e.markFromJSON(t.mark))}}kt.jsonID("removeNodeMark",Pi);class ot extends kt{constructor(e,t,r,i=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=i}apply(e){return this.structure&&Yf(e,this.from,this.to)?Ze.fail("Structure replace would overwrite content"):Ze.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Yt([this.from,this.to-this.from,this.slice.size])}invert(e){return new ot(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deletedAcross&&r.deletedAcross?null:new ot(t.pos,Math.max(t.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof ot)||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?J.empty:new J(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new ot(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?J.empty:new J(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new ot(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 ot(t.from,t.to,J.fromJSON(e,t.slice),!!t.structure)}}kt.jsonID("replace",ot);class gt extends kt{constructor(e,t,r,i,o,s,a=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=i,this.slice=o,this.insert=s,this.structure=a}apply(e){if(this.structure&&(Yf(e,this.from,this.gapFrom)||Yf(e,this.gapTo,this.to)))return Ze.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return Ze.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?Ze.fromReplace(e,this.from,this.to,r):Ze.fail("Content does not fit in gap")}getMap(){return new Yt([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 gt(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 gt(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 gt(t.from,t.to,t.gapFrom,t.gapTo,J.fromJSON(e,t.slice),t.insert,!!t.structure)}}kt.jsonID("replaceAround",gt);function Yf(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 HO(n,e,t,r){let i=[],o=[],s,a;n.doc.nodesBetween(e,t,(u,f,h)=>{if(!u.isInline)return;let d=u.marks;if(!r.isInSet(d)&&h.type.allowsMarkType(r.type)){let m=Math.max(f,e),g=Math.min(f+u.nodeSize,t),k=r.addToSet(d);for(let C=0;C<d.length;C++)d[C].isInSet(k)||(s&&s.to==m&&s.mark.eq(d[C])?s.to=g:i.push(s=new Kn(m,g,d[C])));a&&a.to==m?a.to=g:o.push(a=new yr(m,g,r))}}),i.forEach(u=>n.step(u)),o.forEach(u=>n.step(u))}function qO(n,e,t,r){let i=[],o=0;n.doc.nodesBetween(e,t,(s,a)=>{if(!s.isInline)return;o++;let u=null;if(r instanceof ru){let f=s.marks,h;for(;h=r.isInSet(f);)(u||(u=[])).push(h),f=h.removeFromSet(f)}else r?r.isInSet(s.marks)&&(u=[r]):u=s.marks;if(u&&u.length){let f=Math.min(a+s.nodeSize,t);for(let h=0;h<u.length;h++){let d=u[h],m;for(let g=0;g<i.length;g++){let k=i[g];k.step==o-1&&d.eq(i[g].style)&&(m=k)}m?(m.to=f,m.step=o):i.push({style:d,from:Math.max(a,e),to:f,step:o})}}}),i.forEach(s=>n.step(new Kn(s.from,s.to,s.style)))}function _h(n,e,t,r=t.contentMatch,i=!0){let o=n.doc.nodeAt(e),s=[],a=e+1;for(let u=0;u<o.childCount;u++){let f=o.child(u),h=a+f.nodeSize,d=r.matchType(f.type);if(!d)s.push(new ot(a,h,J.empty));else{r=d;for(let m=0;m<f.marks.length;m++)t.allowsMarkType(f.marks[m].type)||n.step(new Kn(a,h,f.marks[m]));if(i&&f.isText&&t.whitespace!="pre"){let m,g=/\r?\n|\r/g,k;for(;m=g.exec(f.text);)k||(k=new J(W.from(t.schema.text(" ",t.allowedMarks(f.marks))),0,0)),s.push(new ot(a+m.index,a+m.index+m[0].length,k))}}a=h}if(!r.validEnd){let u=r.fillBefore(W.empty,!0);n.replace(a,a,new J(u,0,0))}for(let u=s.length-1;u>=0;u--)n.step(s[u])}function KO(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function iu(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),a=n.$from.index(r)+i,u=n.$to.indexAfter(r)-o;if(r<n.depth&&s.canReplace(a,u,t))return r;if(r==0||s.type.spec.isolating||!KO(s,a,u))break;a&&(i=1),u<s.childCount&&(o=1)}return null}function UO(n,e,t){let{$from:r,$to:i,depth:o}=e,s=r.before(o+1),a=i.after(o+1),u=s,f=a,h=W.empty,d=0;for(let k=o,C=!1;k>t;k--)C||r.index(k)>0?(C=!0,h=W.from(r.node(k).copy(h)),d++):u--;let m=W.empty,g=0;for(let k=o,C=!1;k>t;k--)C||i.after(k+1)<i.end(k)?(C=!0,m=W.from(i.node(k).copy(m)),g++):f++;n.step(new gt(u,f,s,a,new J(h.append(m),d,g),h.size-d,!0))}function Dh(n,e,t=null,r=n){let i=jO(n,e),o=i&&JO(r,e);return o?i.map(vg).concat({type:e,attrs:t}).concat(o.map(vg)):null}function vg(n){return{type:n,attrs:null}}function jO(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 JO(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 u=(s.length?s[s.length-1]:e).contentMatch;for(let f=r;u&&f<i;f++)u=u.matchType(t.child(f).type);return!u||!u.validEnd?null:s}function GO(n,e,t){let r=W.empty;for(let s=t.length-1;s>=0;s--){if(r.size){let a=t[s].type.contentMatch.matchFragment(r);if(!a||!a.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=W.from(t[s].type.create(t[s].attrs,r))}let i=e.start,o=e.end;n.step(new gt(i,o,i,o,new J(r,0,0),t.length,!0))}function YO(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,a)=>{let u=typeof i=="function"?i(s):i;if(s.isTextblock&&!s.hasMarkup(r,u)&&XO(n.doc,n.mapping.slice(o).map(a),r)){let f=null;if(r.schema.linebreakReplacement){let g=r.whitespace=="pre",k=!!r.contentMatch.matchType(r.schema.linebreakReplacement);g&&!k?f=!1:!g&&k&&(f=!0)}f===!1&&Q1(n,s,a,o),_h(n,n.mapping.slice(o).map(a,1),r,void 0,f===null);let h=n.mapping.slice(o),d=h.map(a,1),m=h.map(a+s.nodeSize,1);return n.step(new gt(d,m,d+1,m-1,new J(W.from(r.create(u,null,s.marks)),0,0),1,!0)),f===!0&&X1(n,s,a,o),!1}})}function X1(n,e,t,r){e.forEach((i,o)=>{if(i.isText){let s,a=/\r?\n|\r/g;for(;s=a.exec(i.text);){let u=n.mapping.slice(r).map(t+1+o+s.index);n.replaceWith(u,u+1,e.type.schema.linebreakReplacement.create())}}})}function Q1(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(`
38
+ `))}})}function XO(n,e,t){let r=n.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,t)}function QO(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 gt(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new J(W.from(s),0,0),1,!0))}function ds(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 f=i.depth-1,h=t-2;f>o;f--,h--){let d=i.node(f),m=i.index(f);if(d.type.spec.isolating)return!1;let g=d.content.cutByIndex(m,d.childCount),k=r&&r[h+1];k&&(g=g.replaceChild(0,k.type.create(k.attrs)));let C=r&&r[h]||d;if(!d.canReplace(m+1,d.childCount)||!C.type.validContent(g))return!1}let a=i.indexAfter(o),u=r&&r[0];return i.node(o).canReplaceWith(a,a,u?u.type:i.node(o+1).type)}function ZO(n,e,t=1,r){let i=n.doc.resolve(e),o=W.empty,s=W.empty;for(let a=i.depth,u=i.depth-t,f=t-1;a>u;a--,f--){o=W.from(i.node(a).copy(o));let h=r&&r[f];s=W.from(h?h.type.create(h.attrs,s):i.node(a).copy(s))}n.step(new ot(e,e,new J(o.append(s),t,t),!0))}function ou(n,e){let t=n.resolve(e),r=t.index();return tR(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function eR(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 tR(n,e){return!!(n&&e&&!n.isLeaf&&eR(n,e))}function nR(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 h=s.whitespace=="pre",d=!!s.contentMatch.matchType(i);h&&!d?r=!1:!h&&d&&(r=!0)}let a=n.steps.length;if(r===!1){let h=n.doc.resolve(e+t);Q1(n,h.node(),h.before(),a)}s.inlineContent&&_h(n,e+t-1,s,o.node().contentMatchAt(o.index()),r==null);let u=n.mapping.slice(a),f=u.map(e-t);if(n.step(new ot(f,u.map(e+t,-1),J.empty,!0)),r===!0){let h=n.doc.resolve(f);X1(n,h.node(),h.before(),n.steps.length)}return n}function rR(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 iR(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 a=s==r.depth?0:r.pos<=(r.start(s+1)+r.end(s+1))/2?-1:1,u=r.index(s)+(a>0?1:0),f=r.node(s),h=!1;if(o==1)h=f.canReplace(u,u,i);else{let d=f.contentMatchAt(u).findWrapping(i.firstChild.type);h=d&&f.canReplaceWith(u,u,d[0])}if(h)return a==0?r.pos:a<0?r.before(s+1):r.after(s+1)}return null}function su(n,e,t=e,r=J.empty){if(e==t&&!r.size)return null;let i=n.resolve(e),o=n.resolve(t);return Z1(i,o,r)?new ot(e,t,r):new oR(i,o,r).fit()}function Z1(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class oR{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=W.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=W.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let f=this.findFittable();f?this.placeNodes(f):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,a=i.depth;for(;s&&a&&o.childCount==1;)o=o.firstChild.content,s--,a--;let u=new J(o,s,a);return e>-1?new gt(r.pos,e,this.$to.pos,this.$to.end(),u,t):u.size||r.pos!=this.$to.pos?new ot(r.pos,i.pos,u):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=tf(this.unplaced.content,r-1).firstChild,i=o.content):i=this.unplaced.content;let s=i.firstChild;for(let a=this.depth;a>=0;a--){let{type:u,match:f}=this.frontier[a],h,d=null;if(t==1&&(s?f.matchType(s.type)||(d=f.fillBefore(W.from(s),!1)):o&&u.compatibleContent(o.type)))return{sliceDepth:r,frontierDepth:a,parent:o,inject:d};if(t==2&&s&&(h=f.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:a,parent:o,wrap:h};if(o&&f.matchType(o.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=tf(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new J(e,t+1,Math.max(r,i.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=tf(e,t);if(i.childCount<=1&&t>0){let o=e.size-t<=t+i.size;this.unplaced=new J(is(e,t-1,1),t-1,o?t-1:r)}else this.unplaced=new J(is(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 C=0;C<o.length;C++)this.openFrontierNode(o[C]);let s=this.unplaced,a=r?r.content:s.content,u=s.openStart-e,f=0,h=[],{match:d,type:m}=this.frontier[t];if(i){for(let C=0;C<i.childCount;C++)h.push(i.child(C));d=d.matchFragment(i)}let g=a.size+e-(s.content.size-s.openEnd);for(;f<a.childCount;){let C=a.child(f),v=d.matchType(C.type);if(!v)break;f++,(f>1||u==0||C.content.size)&&(d=v,h.push(e0(C.mark(m.allowedMarks(C.marks)),f==1?u:0,f==a.childCount?g:-1)))}let k=f==a.childCount;k||(g=-1),this.placed=ss(this.placed,t,W.from(h)),this.frontier[t].match=d,k&&g<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let C=0,v=a;C<g;C++){let S=v.lastChild;this.frontier.push({type:S.type,match:S.contentMatchAt(S.childCount)}),v=S.content}this.unplaced=k?e==0?J.empty:new J(is(s.content,e-1,1),e-1,g<0?s.openEnd:e-1):new J(is(s.content,e,f),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!nf(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=nf(e,t,i,r,o);if(s){for(let a=t-1;a>=0;a--){let{match:u,type:f}=this.frontier[a],h=nf(e,a,f,u,!0);if(!h||h.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=ss(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=ss(this.placed,this.depth,W.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(W.empty,!0);t.childCount&&(this.placed=ss(this.placed,this.frontier.length,t))}}function is(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(is(n.firstChild.content,e-1,t)))}function ss(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(ss(n.lastChild.content,e-1,t)))}function tf(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function e0(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,e0(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(W.empty,!0)))),n.copy(r)}function nf(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 a=r.fillBefore(o.content,!0,s);return a&&!sR(t,o.content,s)?a:null}function sR(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function lR(n){return n.spec.defining||n.spec.definingForContent}function aR(n,e,t,r){if(!r.size)return n.deleteRange(e,t);let i=n.doc.resolve(e),o=n.doc.resolve(t);if(Z1(i,o,r))return n.step(new ot(e,t,r));let s=n0(i,o);s[s.length-1]==0&&s.pop();let a=-(i.depth+1);s.unshift(a);for(let m=i.depth,g=i.pos-1;m>0;m--,g--){let k=i.node(m).type.spec;if(k.defining||k.definingAsContext||k.isolating)break;s.indexOf(m)>-1?a=m:i.before(m)==g&&s.splice(1,0,-m)}let u=s.indexOf(a),f=[],h=r.openStart;for(let m=r.content,g=0;;g++){let k=m.firstChild;if(f.push(k),g==r.openStart)break;m=k.content}for(let m=h-1;m>=0;m--){let g=f[m],k=lR(g.type);if(k&&!g.sameMarkup(i.node(Math.abs(a)-1)))h=m;else if(k||!g.type.isTextblock)break}for(let m=r.openStart;m>=0;m--){let g=(m+h+1)%(r.openStart+1),k=f[g];if(k)for(let C=0;C<s.length;C++){let v=s[(C+u)%s.length],S=!0;v<0&&(S=!1,v=-v);let L=i.node(v-1),R=i.index(v-1);if(L.canReplaceWith(R,R,k.type,k.marks))return n.replace(i.before(v),S?o.after(v):t,new J(t0(r.content,0,r.openStart,g),g,r.openEnd))}}let d=n.steps.length;for(let m=s.length-1;m>=0&&(n.replace(e,t,r),!(n.steps.length>d));m--){let g=s[m];g<0||(e=i.before(g),t=o.after(g))}}function t0(n,e,t,r,i){if(e<t){let o=n.firstChild;n=n.replaceChild(0,o.copy(t0(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(W.empty,!0))}return n}function uR(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let i=rR(n.doc,e,r.type);i!=null&&(e=t=i)}n.replaceRange(e,t,new J(W.from(r),0,0))}function cR(n,e,t){let r=n.doc.resolve(e),i=n.doc.resolve(t),o=n0(r,i);for(let s=0;s<o.length;s++){let a=o[s],u=s==o.length-1;if(u&&a==0||r.node(a).type.contentMatch.validEnd)return n.delete(r.start(a),i.end(a));if(a>0&&(u||r.node(a-1).canReplace(r.index(a-1),i.indexAfter(a-1))))return n.delete(r.before(a),i.after(a))}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 n0(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}class po extends kt{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 Ze.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 Ze.fromReplace(e,this.pos,this.pos+1,new J(W.from(i),0,t.isLeaf?0:1))}getMap(){return Yt.empty}invert(e){return new po(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 po(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 po(t.pos,t.attr,t.value)}}kt.jsonID("attr",po);class Cs extends kt{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 Ze.ok(r)}getMap(){return Yt.empty}invert(e){return new Cs(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 Cs(t.attr,t.value)}}kt.jsonID("docAttr",Cs);let No=class extends Error{};No=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};No.prototype=Object.create(Error.prototype);No.prototype.constructor=No;No.prototype.name="TransformError";class r0{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Ta}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new No(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,a,u)=>{e=Math.min(e,a),t=Math.max(t,u)})}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=J.empty){let i=su(this.doc,e,t,r);return i&&this.step(i),this}replaceWith(e,t,r){return this.replace(e,t,new J(W.from(r),0,0))}delete(e,t){return this.replace(e,t,J.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return aR(this,e,t,r),this}replaceRangeWith(e,t,r){return uR(this,e,t,r),this}deleteRange(e,t){return cR(this,e,t),this}lift(e,t){return UO(this,e,t),this}join(e,t=1){return nR(this,e,t),this}wrap(e,t){return GO(this,e,t),this}setBlockType(e,t=e,r,i=null){return YO(this,e,t,r,i),this}setNodeMarkup(e,t,r=null,i){return QO(this,e,t,r,i),this}setNodeAttribute(e,t,r){return this.step(new po(e,t,r)),this}setDocAttribute(e,t){return this.step(new Cs(e,t)),this}addNodeMark(e,t){return this.step(new Vr(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 Ne)t.isInSet(r.marks)&&this.step(new Pi(e,t));else{let i=r.marks,o,s=[];for(;o=t.isInSet(i);)s.push(new Pi(e,o)),i=o.removeFromSet(i);for(let a=s.length-1;a>=0;a--)this.step(s[a])}return this}split(e,t=1,r){return ZO(this,e,t,r),this}addMark(e,t,r){return HO(this,e,t,r),this}removeMark(e,t,r){return qO(this,e,t,r),this}clearIncompatible(e,t,r){return _h(this,e,t,r),this}}const rf=Object.create(null);class de{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new i0(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=J.empty){let r=t.content.lastChild,i=null;for(let a=0;a<t.openEnd;a++)i=r,r=r.lastChild;let o=e.steps.length,s=this.ranges;for(let a=0;a<s.length;a++){let{$from:u,$to:f}=s[a],h=e.mapping.slice(o);e.replaceRange(h.map(u.pos),h.map(f.pos),a?J.empty:t),a==0&&Ng(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:a}=i[o],u=e.mapping.slice(r),f=u.map(s.pos),h=u.map(a.pos);o?e.deleteRange(f,h):(e.replaceRangeWith(f,h,t),Ng(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let i=e.parent.inlineContent?new pe(e):ao(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?ao(e.node(0),e.node(o),e.before(o+1),e.index(o),t,r):ao(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 Zt(e.node(0))}static atStart(e){return ao(e,e,0,0,1)||new Zt(e)}static atEnd(e){return ao(e,e,e.content.size,e.childCount,-1)||new Zt(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=rf[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 rf)throw new RangeError("Duplicate use of selection JSON ID "+e);return rf[e]=t,t.prototype.jsonID=e,t}getBookmark(){return pe.between(this.$anchor,this.$head).getBookmark()}}de.prototype.visible=!0;class i0{constructor(e,t){this.$from=e,this.$to=t}}let Tg=!1;function Ag(n){!Tg&&!n.parent.inlineContent&&(Tg=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class pe extends de{constructor(e,t=e){Ag(e),Ag(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 de.near(r);let i=e.resolve(t.map(this.anchor));return new pe(i.parent.inlineContent?i:r,r)}replace(e,t=J.empty){if(super.replace(e,t),t==J.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof pe&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new lu(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 pe(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=de.findFrom(t,r,!0)||de.findFrom(t,-r,!0);if(o)t=o.$head;else return de.near(t,r)}return e.parent.inlineContent||(i==0?e=t:(e=(de.findFrom(e,-r,!0)||de.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=i<0&&(e=t))),new pe(e,t)}}de.jsonID("text",pe);class lu{constructor(e,t){this.anchor=e,this.head=t}map(e){return new lu(e.map(this.anchor),e.map(this.head))}resolve(e){return pe.between(e.resolve(this.anchor),e.resolve(this.head))}}class ce extends de{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?de.near(o):new ce(o)}content(){return new J(W.from(this.node),0,0)}eq(e){return e instanceof ce&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Lh(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new ce(e.resolve(t.anchor))}static create(e,t){return new ce(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}ce.prototype.visible=!1;de.jsonID("node",ce);class Lh{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new lu(r,r):new Lh(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&ce.isSelectable(r)?new ce(t):de.near(t)}}class Zt extends de{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=J.empty){if(t==J.empty){e.delete(0,e.doc.content.size);let r=de.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new Zt(e)}map(e){return new Zt(e)}eq(e){return e instanceof Zt}getBookmark(){return fR}}de.jsonID("all",Zt);const fR={map(){return this},resolve(n){return new Zt(n)}};function ao(n,e,t,r,i,o=!1){if(e.inlineContent)return pe.create(n,t);for(let s=r-(i>0?0:1);i>0?s<e.childCount:s>=0;s+=i){let a=e.child(s);if(a.isAtom){if(!o&&ce.isSelectable(a))return ce.create(n,t-(i<0?a.nodeSize:0))}else{let u=ao(n,a,t+i,i<0?a.childCount:0,i,o);if(u)return u}t+=a.nodeSize*i}return null}function Ng(n,e,t){let r=n.steps.length-1;if(r<e)return;let i=n.steps[r];if(!(i instanceof ot||i instanceof gt))return;let o=n.mapping.maps[r],s;o.forEach((a,u,f,h)=>{s==null&&(s=h)}),n.setSelection(de.near(n.doc.resolve(s),t))}const Mg=1,na=2,Ig=4;class hR extends r0{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|Mg)&~na,this.storedMarks=null,this}get selectionSet(){return(this.updated&Mg)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=na,this}ensureMarks(e){return Ne.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&na)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~na,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)||Ne.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(de.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|=Ig,this}get scrolledIntoView(){return(this.updated&Ig)>0}}function Eg(n,e){return!e||!n?n:n.bind(e)}class ls{constructor(e,t,r){this.name=e,this.init=Eg(t.init,r),this.apply=Eg(t.apply,r)}}const dR=[new ls("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new ls("selection",{init(n,e){return n.selection||de.atStart(e.doc)},apply(n){return n.selection}}),new ls("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new ls("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class of{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=dR.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 ls(r.key,r.spec.state,r))})}}class xi{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 a=this.config.plugins[s];if(a.spec.appendTransaction){let u=i?i[s].n:0,f=i?i[s].state:this,h=u<t.length&&a.spec.appendTransaction.call(a,u?t.slice(u):t,f,r);if(h&&r.filterTransaction(h,s)){if(h.setMeta("appendedTransaction",e),!i){i=[];for(let d=0;d<this.config.plugins.length;d++)i.push(d<s?{state:r,n:t.length}:{state:this,n:0})}t.push(h),r=r.applyInner(h),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 xi(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 hR(this)}static create(e){let t=new of(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new xi(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 of(this.schema,e.plugins),r=t.fields,i=new xi(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 of(e.schema,e.plugins),o=new xi(i);return i.fields.forEach(s=>{if(s.name=="doc")o.doc=br.fromJSON(e.schema,t.doc);else if(s.name=="selection")o.selection=de.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 a in r){let u=r[a],f=u.spec.state;if(u.key==s.name&&f&&f.fromJSON&&Object.prototype.hasOwnProperty.call(t,a)){o[s.name]=f.fromJSON.call(u,e,t[a],o);return}}o[s.name]=s.init(e,o)}}),o}}function o0(n,e,t){for(let r in n){let i=n[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=o0(i,e,{})),t[r]=i}return t}class Pt{constructor(e){this.spec=e,this.props={},e.props&&o0(e.props,this,this.props),this.key=e.key?e.key.key:s0("plugin")}getState(e){return e[this.key]}}const sf=Object.create(null);function s0(n){return n in sf?n+"$"+ ++sf[n]:(sf[n]=0,n+"$")}class Bt{constructor(e="key"){this.key=s0(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Ph=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function l0(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const a0=(n,e,t)=>{let r=l0(n,t);if(!r)return!1;let i=Bh(r);if(!i){let s=r.blockRange(),a=s&&iu(s);return a==null?!1:(e&&e(n.tr.lift(s,a).scrollIntoView()),!0)}let o=i.nodeBefore;if(f0(n,i,e,-1))return!0;if(r.parent.content.size==0&&(Mo(o,"end")||ce.isSelectable(o)))for(let s=r.depth;;s--){let a=su(n.doc,r.before(s),r.after(s),J.empty);if(a&&a.slice.size<a.to-a.from){if(e){let u=n.tr.step(a);u.setSelection(Mo(o,"end")?de.findFrom(u.doc.resolve(u.mapping.map(i.pos,-1)),-1):ce.create(u.doc,i.pos-o.nodeSize)),e(u.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},pR=(n,e,t)=>{let r=l0(n,t);if(!r)return!1;let i=Bh(r);return i?mR(n,i,e):!1};function mR(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 h=i.lastChild;if(!h)return!1;i=h}let s=e.nodeAfter,a=s,u=e.pos+1;for(;!a.isTextblock;u++){if(a.type.spec.isolating)return!1;let h=a.firstChild;if(!h)return!1;a=h}let f=su(n.doc,o,u,J.empty);if(!f||f.from!=o||f instanceof ot&&f.slice.size>=u-o)return!1;if(t){let h=n.tr.step(f);h.setSelection(pe.create(h.doc,o)),t(h.scrollIntoView())}return!0}function Mo(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}const u0=(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=Bh(r)}let s=o&&o.nodeBefore;return!s||!ce.isSelectable(s)?!1:(e&&e(n.tr.setSelection(ce.create(n.doc,o.pos-s.nodeSize)).scrollIntoView()),!0)};function Bh(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 gR(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const yR=(n,e,t)=>{let r=gR(n,t);if(!r)return!1;let i=c0(r);if(!i)return!1;let o=i.nodeAfter;if(f0(n,i,e,1))return!0;if(r.parent.content.size==0&&(Mo(o,"start")||ce.isSelectable(o))){let s=su(n.doc,r.before(),r.after(),J.empty);if(s&&s.slice.size<s.to-s.from){if(e){let a=n.tr.step(s);a.setSelection(Mo(o,"start")?de.findFrom(a.doc.resolve(a.mapping.map(i.pos)),1):ce.create(a.doc,a.mapping.map(i.pos))),e(a.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},kR=(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=c0(r)}let s=o&&o.nodeAfter;return!s||!ce.isSelectable(s)?!1:(e&&e(n.tr.setSelection(ce.create(n.doc,o.pos)).scrollIntoView()),!0)};function c0(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}const bR=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(`
39
+ `).scrollIntoView()),!0)};function Fh(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}const xR=(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=Fh(i.contentMatchAt(o));if(!s||!i.canReplaceWith(o,o,s))return!1;if(e){let a=t.after(),u=n.tr.replaceWith(a,a,s.createAndFill());u.setSelection(de.near(u.doc.resolve(a),1)),e(u.scrollIntoView())}return!0},wR=(n,e)=>{let t=n.selection,{$from:r,$to:i}=t;if(t instanceof Zt||r.parent.inlineContent||i.parent.inlineContent)return!1;let o=Fh(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,a=n.tr.insert(s,o.createAndFill());a.setSelection(pe.create(a.doc,s+1)),e(a.scrollIntoView())}return!0},CR=(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(ds(n.doc,o))return e&&e(n.tr.split(o).scrollIntoView()),!0}let r=t.blockRange(),i=r&&iu(r);return i==null?!1:(e&&e(n.tr.lift(r,i).scrollIntoView()),!0)};function SR(n){return(e,t)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof ce&&e.selection.node.isBlock)return!r.parentOffset||!ds(e.doc,r.pos)?!1:(t&&t(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let o=[],s,a,u=!1,f=!1;for(let g=r.depth;;g--)if(r.node(g).isBlock){u=r.end(g)==r.pos+(r.depth-g),f=r.start(g)==r.pos-(r.depth-g),a=Fh(r.node(g-1).contentMatchAt(r.indexAfter(g-1))),o.unshift(u&&a?{type:a}:null),s=g;break}else{if(g==1)return!1;o.unshift(null)}let h=e.tr;(e.selection instanceof pe||e.selection instanceof Zt)&&h.deleteSelection();let d=h.mapping.map(r.pos),m=ds(h.doc,d,o.length,o);if(m||(o[0]=a?{type:a}:null,m=ds(h.doc,d,o.length,o)),!m)return!1;if(h.split(d,o.length,o),!u&&f&&r.node(s).type!=a){let g=h.mapping.map(r.before(s)),k=h.doc.resolve(g);a&&r.node(s-1).canReplaceWith(k.index(),k.index()+1,a)&&h.setNodeMarkup(h.mapping.map(r.before(s)),a)}return t&&t(h.scrollIntoView()),!0}}const vR=SR(),TR=(n,e)=>(e&&e(n.tr.setSelection(new Zt(n.doc))),!0);function AR(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||ou(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function f0(n,e,t,r){let i=e.nodeBefore,o=e.nodeAfter,s,a,u=i.type.spec.isolating||o.type.spec.isolating;if(!u&&AR(n,e,t))return!0;let f=!u&&e.parent.canReplace(e.index(),e.index()+1);if(f&&(s=(a=i.contentMatchAt(i.childCount)).findWrapping(o.type))&&a.matchType(s[0]||o.type).validEnd){if(t){let g=e.pos+o.nodeSize,k=W.empty;for(let S=s.length-1;S>=0;S--)k=W.from(s[S].create(null,k));k=W.from(i.copy(k));let C=n.tr.step(new gt(e.pos-1,g,e.pos,g,new J(k,1,0),s.length,!0)),v=C.doc.resolve(g+2*s.length);v.nodeAfter&&v.nodeAfter.type==i.type&&ou(C.doc,v.pos)&&C.join(v.pos),t(C.scrollIntoView())}return!0}let h=o.type.spec.isolating||r>0&&u?null:de.findFrom(e,1),d=h&&h.$from.blockRange(h.$to),m=d&&iu(d);if(m!=null&&m>=e.depth)return t&&t(n.tr.lift(d,m).scrollIntoView()),!0;if(f&&Mo(o,"start",!0)&&Mo(i,"end")){let g=i,k=[];for(;k.push(g),!g.isTextblock;)g=g.lastChild;let C=o,v=1;for(;!C.isTextblock;C=C.firstChild)v++;if(g.canReplace(g.childCount,g.childCount,C.content)){if(t){let S=W.empty;for(let R=k.length-1;R>=0;R--)S=W.from(k[R].copy(S));let L=n.tr.step(new gt(e.pos-k.length,e.pos+o.nodeSize,e.pos+v,e.pos+o.nodeSize-v,new J(S,k.length,0),0,!0));t(L.scrollIntoView())}return!0}}return!1}function h0(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(pe.create(e.doc,n<0?i.start(o):i.end(o)))),!0):!1}}const NR=h0(-1),MR=h0(1);function zh(n,e=null){return function(t,r){let{$from:i,$to:o}=t.selection,s=i.blockRange(o),a=s&&Dh(s,n,e);return a?(r&&r(t.tr.wrap(s,a).scrollIntoView()),!0):!1}}function Ss(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:a}}=t.selection.ranges[o];t.doc.nodesBetween(s,a,(u,f)=>{if(i)return!1;if(!(!u.isTextblock||u.hasMarkup(n,e)))if(u.type==n)i=!0;else{let h=t.doc.resolve(f),d=h.index();i=h.parent.canReplaceWith(d,d+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:a},$to:{pos:u}}=t.selection.ranges[s];o.setBlockType(a,u,n,e)}r(o.scrollIntoView())}return!0}}function IR(n,e,t,r){for(let i=0;i<e.length;i++){let{$from:o,$to:s}=e[i],a=o.depth==0?n.inlineContent&&n.type.allowsMarkType(t):!1;if(n.nodesBetween(o.pos,s.pos,(u,f)=>{if(a)return!1;a=u.inlineContent&&u.type.allowsMarkType(t)}),a)return!0}return!1}function au(n,e=null,t){return function(r,i){let{empty:o,$cursor:s,ranges:a}=r.selection;if(o&&!s||!IR(r.doc,a,n))return!1;if(i)if(s)n.isInSet(r.storedMarks||s.marks())?i(r.tr.removeStoredMark(n)):i(r.tr.addStoredMark(n.create(e)));else{let u,f=r.tr;u=!a.some(h=>r.doc.rangeHasMark(h.$from.pos,h.$to.pos,n));for(let h=0;h<a.length;h++){let{$from:d,$to:m}=a[h];if(!u)f.removeMark(d.pos,m.pos,n);else{let g=d.pos,k=m.pos,C=d.nodeAfter,v=m.nodeBefore,S=C&&C.isText?/^\s*/.exec(C.text)[0].length:0,L=v&&v.isText?/\s*$/.exec(v.text)[0].length:0;g+S<k&&(g+=S,k-=L),f.addMark(g,k,n.create(e))}}i(f.scrollIntoView())}return!0}}function Lo(...n){return function(e,t,r){for(let i=0;i<n.length;i++)if(n[i](e,t,r))return!0;return!1}}let lf=Lo(Ph,a0,u0),Og=Lo(Ph,yR,kR);const mr={Enter:Lo(bR,wR,CR,vR),"Mod-Enter":xR,Backspace:lf,"Mod-Backspace":lf,"Shift-Backspace":lf,Delete:Og,"Mod-Delete":Og,"Mod-a":TR},d0={"Ctrl-h":mr.Backspace,"Alt-Backspace":mr["Mod-Backspace"],"Ctrl-d":mr.Delete,"Ctrl-Alt-Backspace":mr["Mod-Delete"],"Alt-Delete":mr["Mod-Delete"],"Alt-d":mr["Mod-Delete"],"Ctrl-a":NR,"Ctrl-e":MR};for(let n in mr)d0[n]=mr[n];const ER=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1,OR=ER?d0:mr;var Xr={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:"'"},Aa={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},RR=typeof navigator<"u"&&/Mac/.test(navigator.platform),_R=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var ct=0;ct<10;ct++)Xr[48+ct]=Xr[96+ct]=String(ct);for(var ct=1;ct<=24;ct++)Xr[ct+111]="F"+ct;for(var ct=65;ct<=90;ct++)Xr[ct]=String.fromCharCode(ct+32),Aa[ct]=String.fromCharCode(ct);for(var af in Xr)Aa.hasOwnProperty(af)||(Aa[af]=Xr[af]);function DR(n){var e=RR&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||_R&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Aa:Xr)[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}const LR=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),PR=typeof navigator<"u"&&/Win/.test(navigator.platform);function BR(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,i,o,s;for(let a=0;a<e.length-1;a++){let u=e[a];if(/^(cmd|meta|m)$/i.test(u))s=!0;else if(/^a(lt)?$/i.test(u))r=!0;else if(/^(c|ctrl|control)$/i.test(u))i=!0;else if(/^s(hift)?$/i.test(u))o=!0;else if(/^mod$/i.test(u))LR?s=!0:i=!0;else throw new Error("Unrecognized modifier name: "+u)}return r&&(t="Alt-"+t),i&&(t="Ctrl-"+t),s&&(t="Meta-"+t),o&&(t="Shift-"+t),t}function FR(n){let e=Object.create(null);for(let t in n)e[BR(t)]=n[t];return e}function uf(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 zR(n){return new Pt({props:{handleKeyDown:p0(n)}})}function p0(n){let e=FR(n);return function(t,r){let i=DR(r),o,s=e[uf(i,r)];if(s&&s(t.state,t.dispatch,t))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let a=e[uf(i,r,!1)];if(a&&a(t.state,t.dispatch,t))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(PR&&r.ctrlKey&&r.altKey)&&(o=Xr[r.keyCode])&&o!=i){let a=e[uf(o,r)];if(a&&a(t.state,t.dispatch,t))return!0}}return!1}}class Cn{constructor(e,t,r={}){this.match=e,this.match=e,this.handler=typeof t=="string"?$R(t):t,this.undoable=r.undoable!==!1,this.inCode=r.inCode||!1,this.inCodeMark=r.inCodeMark!==!1}}function $R(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 a=r-i;a>0&&(o=t[0].slice(s-a,s)+o,r=i)}return e.tr.insertText(o,r,i)}}const WR=(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,a=o.transform;for(let u=a.steps.length-1;u>=0;u--)s.step(a.steps[u].invert(a.docs[u]));if(o.text){let u=s.doc.resolve(o.from).marks();s.replaceWith(o.from,o.to,n.schema.text(o.text,u))}else s.delete(o.from,o.to);e(s)}return!0}}return!1};new Cn(/--$/,"—",{inCodeMark:!1});new Cn(/\.\.\.$/,"…",{inCodeMark:!1});new Cn(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“",{inCodeMark:!1});new Cn(/"$/,"”",{inCodeMark:!1});new Cn(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘",{inCodeMark:!1});new Cn(/'$/,"’",{inCodeMark:!1});function $h(n,e,t=null,r){return new Cn(n,(i,o,s,a)=>{let u=t instanceof Function?t(o):t,f=i.tr.delete(s,a),h=f.doc.resolve(s),d=h.blockRange(),m=d&&Dh(d,e,u);if(!m)return null;f.wrap(d,m);let g=f.doc.resolve(s-1).nodeBefore;return g&&g.type==e&&ou(f.doc,s-1)&&(!r||r(o,g))&&f.join(s-1),f})}function m0(n,e,t=null){return new Cn(n,(r,i,o,s)=>{let a=r.doc.resolve(o),u=t instanceof Function?t(i):t;return a.node(-1).canReplaceWith(a.index(-1),a.indexAfter(-1),e)?r.tr.delete(o,s).setBlockType(o,o,e,u):null})}var g0=class{},y0=class{constructor(){this.elements=[],this.size=()=>this.elements.length,this.top=()=>this.elements.at(-1),this.push=n=>{var e;(e=this.top())==null||e.push(n)},this.open=n=>{this.elements.push(n)},this.close=()=>{const n=this.elements.pop();if(!n)throw N1();return n}}},VR=class k0 extends g0{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 k0(e,t,r)}},Hn,Rs,Wa,Va,Ha,_s,Ds,Oi,HR=(Oi=class extends y0{constructor(t){super();xe(this,Hn,Ne.none);xe(this,Rs,t=>t.isText);xe(this,Wa,(t,r)=>{if(j(this,Rs).call(this,t)&&j(this,Rs).call(this,r)&&Ne.sameSet(t.marks,r.marks))return this.schema.text(t.text+r.text,t.marks)});xe(this,Va,t=>{const r=Object.values({...this.schema.nodes,...this.schema.marks}).find(i=>i.spec.parseMarkdown.match(t));if(!r)throw dO(t);return r});xe(this,Ha,t=>{const r=j(this,Va).call(this,t);r.spec.parseMarkdown.runner(this,t,r)});xe(this,_s,()=>{Ke(this,Hn,Ne.none);const t=this.close();return j(this,Ds).call(this,t.type,t.attrs,t.content)});xe(this,Ds,(t,r,i)=>{const o=t.createAndFill(r,i,j(this,Hn));if(!o)throw hO(t,r,i);return this.push(o),o});this.injectRoot=(r,i,o)=>(this.openNode(i,o),this.next(r.children),this),this.openNode=(r,i)=>(this.open(VR.create(r,[],i)),this),this.closeNode=()=>{try{j(this,_s).call(this)}catch(r){console.error(r)}return this},this.addNode=(r,i,o)=>{try{j(this,Ds).call(this,r,i,o)}catch(s){console.error(s)}return this},this.openMark=(r,i)=>(Ke(this,Hn,r.create(i).addToSet(j(this,Hn))),this),this.closeMark=r=>(Ke(this,Hn,r.removeFromSet(j(this,Hn))),this),this.addText=r=>{try{const i=this.top();if(!i)throw N1();const o=i.pop(),s=this.schema.text(r,j(this,Hn));if(!o)return i.push(s),this;const a=j(this,Wa).call(this,o,s);return a?(i.push(a),this):(i.push(o,s),this)}catch(i){return console.error(i),this}},this.build=()=>{let r;do r=j(this,_s).call(this);while(this.size());return r},this.next=(r=[])=>([r].flat().forEach(i=>j(this,Ha).call(this,i)),this),this.toDoc=()=>this.build(),this.run=(r,i)=>{const o=r.runSync(r.parse(i),i);return this.next(o),this},this.schema=t}},Hn=new WeakMap,Rs=new WeakMap,Wa=new WeakMap,Va=new WeakMap,Ha=new WeakMap,_s=new WeakMap,Ds=new WeakMap,Oi.create=(t,r)=>{const i=new Oi(t);return o=>(i.run(r,o),i.toDoc())},Oi),Ri,Rg=(Ri=class extends g0{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=()=>{var o;return(o=this.children)==null?void 0:o.pop()}}},Ri.create=(e,t,r,i={})=>new Ri(e,t,r,i),Ri),qR=n=>Object.prototype.hasOwnProperty.call(n,"size"),gr,Ls,qa,Ka,Ps,Ua,Bs,ja,Ja,bo,vi,Ga,Fs,_i,KR=(_i=class extends y0{constructor(t){super();xe(this,gr,Ne.none);xe(this,Ls,t=>{const r=Object.values({...this.schema.nodes,...this.schema.marks}).find(i=>i.spec.toMarkdown.match(t));if(!r)throw pO(t.type);return r});xe(this,qa,t=>j(this,Ls).call(this,t).spec.toMarkdown.runner(this,t));xe(this,Ka,(t,r)=>j(this,Ls).call(this,t).spec.toMarkdown.runner(this,t,r));xe(this,Ps,t=>{const{marks:r}=t,i=o=>o.type.spec.priority??50;[...r].sort((o,s)=>i(o)-i(s)).every(o=>!j(this,Ka).call(this,o,t))&&j(this,qa).call(this,t),r.forEach(o=>j(this,Fs).call(this,o))});xe(this,Ua,(t,r)=>{var u;if(t.type===r||((u=t.children)==null?void 0:u.length)!==1)return t;const i=f=>{var d;if(f.type===r)return f.value!=null?null:f;if(((d=f.children)==null?void 0:d.length)!==1)return null;const[h]=f.children;return h?i(h):null},o=i(t);if(!o)return t;const s=o.children?[...o.children]:void 0,a={...t,children:s};return a.children=s,o.children=[a],o});xe(this,Bs,t=>{const{children:r}=t;return r&&(t.children=r.reduce((i,o,s)=>{if(s===0)return[o];const a=i.at(-1);if(a&&a.isMark&&o.isMark){o=j(this,Ua).call(this,o,a.type);const{children:u,...f}=o,{children:h,...d}=a;if(o.type===a.type&&u&&h&&JSON.stringify(f)===JSON.stringify(d)){const m={...d,children:[...h,...u]};return i.slice(0,-1).concat(j(this,Bs).call(this,m))}}return i.concat(o)},[])),t});xe(this,ja,t=>{const r={...t.props,type:t.type};return t.children&&(r.children=t.children),t.value&&(r.value=t.value),r});xe(this,Ja,(t,r)=>{let i="",o="";const s=t.children;let a=-1,u=-1;const f=d=>{d&&d.forEach((m,g)=>{m.type==="text"&&m.value&&(a<0&&(a=g),u=g)})};if(s){f(s);const d=s==null?void 0:s[u],m=s==null?void 0:s[a];if(d&&d.value.endsWith(" ")){const g=d.value,k=g.trimEnd();o=g.slice(k.length),d.value=k}if(m&&m.value.startsWith(" ")){const g=m.value,k=g.trimStart();i=g.slice(0,g.length-k.length),m.value=k}}i.length&&j(this,vi).call(this,"text",void 0,i);const h=r();return o.length&&j(this,vi).call(this,"text",void 0,o),h});xe(this,bo,(t=!1)=>{const r=this.close(),i=()=>j(this,vi).call(this,r.type,r.children,r.value,r.props);return t?j(this,Ja).call(this,r,i):i()});xe(this,vi,(t,r,i,o)=>{const s=Rg.create(t,r,i,o),a=j(this,Bs).call(this,j(this,ja).call(this,s));return this.push(a),a});xe(this,Ga,(t,r,i,o)=>t.isInSet(j(this,gr))?this:(Ke(this,gr,t.addToSet(j(this,gr))),this.openNode(r,i,{...o,isMark:!0})));xe(this,Fs,t=>{t.isInSet(j(this,gr))&&(Ke(this,gr,t.type.removeFromSet(j(this,gr))),j(this,bo).call(this,!0))});this.openNode=(r,i,o)=>(this.open(Rg.create(r,void 0,i,o)),this),this.closeNode=()=>(j(this,bo).call(this),this),this.addNode=(r,i,o,s)=>(j(this,vi).call(this,r,i,o,s),this),this.withMark=(r,i,o,s)=>(j(this,Ga).call(this,r,i,o,s),this),this.closeMark=r=>(j(this,Fs).call(this,r),this),this.build=()=>{let r=null;do r=j(this,bo).call(this);while(this.size());return r},this.next=r=>qR(r)?(r.forEach(i=>{j(this,Ps).call(this,i)}),this):(j(this,Ps).call(this,r),this),this.toString=r=>r.stringify(this.build()),this.run=r=>(this.next(r),this),this.schema=t}},gr=new WeakMap,Ls=new WeakMap,qa=new WeakMap,Ka=new WeakMap,Ps=new WeakMap,Ua=new WeakMap,Bs=new WeakMap,ja=new WeakMap,Ja=new WeakMap,bo=new WeakMap,vi=new WeakMap,Ga=new WeakMap,Fs=new WeakMap,_i.create=(t,r)=>{const i=new _i(t);return o=>(i.run(o),i.toString(r))},_i);const ft=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},Io=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let Xf=null;const pr=function(n,e,t){let r=Xf||(Xf=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},UR=function(){Xf=null},Bi=function(n,e,t,r){return t&&(_g(n,e,t,r,-1)||_g(n,e,t,r,1))},jR=/^(img|br|input|textarea|hr)$/i;function _g(n,e,t,r,i){for(var o;;){if(n==t&&e==r)return!0;if(e==(i<0?0:yn(n))){let s=n.parentNode;if(!s||s.nodeType!=1||Js(n)||jR.test(n.nodeName)||n.contentEditable=="false")return!1;e=ft(n)+(i<0?0:1),n=s}else if(n.nodeType==1){let s=n.childNodes[e+(i<0?-1:0)];if(s.nodeType==1&&s.contentEditable=="false")if(!((o=s.pmViewDesc)===null||o===void 0)&&o.ignoreForSelection)e+=i;else return!1;else n=s,e=i<0?yn(n):0}else return!1}}function yn(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function JR(n,e){for(;;){if(n.nodeType==3&&e)return n;if(n.nodeType==1&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=yn(n)}else if(n.parentNode&&!Js(n))e=ft(n),n=n.parentNode;else return null}}function GR(n,e){for(;;){if(n.nodeType==3&&e<n.nodeValue.length)return n;if(n.nodeType==1&&e<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[e],e=0}else if(n.parentNode&&!Js(n))e=ft(n)+1,n=n.parentNode;else return null}}function YR(n,e,t){for(let r=e==0,i=e==yn(n);r||i;){if(n==t)return!0;let o=ft(n);if(n=n.parentNode,!n)return!1;r=r&&o==0,i=i&&o==yn(n)}}function Js(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)}const uu=function(n){return n.focusNode&&Bi(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function bi(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function XR(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function QR(n,e,t){if(n.caretPositionFromPoint)try{let r=n.caretPositionFromPoint(e,t);if(r)return{node:r.offsetNode,offset:Math.min(yn(r.offsetNode),r.offset)}}catch{}if(n.caretRangeFromPoint){let r=n.caretRangeFromPoint(e,t);if(r)return{node:r.startContainer,offset:Math.min(yn(r.startContainer),r.startOffset)}}}const jn=typeof navigator<"u"?navigator:null,Dg=typeof document<"u"?document:null,ei=jn&&jn.userAgent||"",Qf=/Edge\/(\d+)/.exec(ei),b0=/MSIE \d/.exec(ei),Zf=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ei),Dt=!!(b0||Zf||Qf),Ur=b0?document.documentMode:Zf?+Zf[1]:Qf?+Qf[1]:0,kn=!Dt&&/gecko\/(\d+)/i.test(ei);kn&&+(/Firefox\/(\d+)/.exec(ei)||[0,0])[1];const eh=!Dt&&/Chrome\/(\d+)/.exec(ei),ht=!!eh,x0=eh?+eh[1]:0,yt=!Dt&&!!jn&&/Apple Computer/.test(jn.vendor),Eo=yt&&(/Mobile\/\w+/.test(ei)||!!jn&&jn.maxTouchPoints>2),mn=Eo||(jn?/Mac/.test(jn.platform):!1),w0=jn?/Win/.test(jn.platform):!1,kr=/Android \d/.test(ei),Gs=!!Dg&&"webkitFontSmoothing"in Dg.documentElement.style,ZR=Gs?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function e_(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 hr(n,e){return typeof n=="number"?n:n[e]}function t_(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 Lg(n,e,t){let r=n.someProp("scrollThreshold")||0,i=n.someProp("scrollMargin")||5,o=n.dom.ownerDocument;for(let s=t||n.dom;s;){if(s.nodeType!=1){s=Io(s);continue}let a=s,u=a==o.body,f=u?e_(o):t_(a),h=0,d=0;if(e.top<f.top+hr(r,"top")?d=-(f.top-e.top+hr(i,"top")):e.bottom>f.bottom-hr(r,"bottom")&&(d=e.bottom-e.top>f.bottom-f.top?e.top+hr(i,"top")-f.top:e.bottom-f.bottom+hr(i,"bottom")),e.left<f.left+hr(r,"left")?h=-(f.left-e.left+hr(i,"left")):e.right>f.right-hr(r,"right")&&(h=e.right-f.right+hr(i,"right")),h||d)if(u)o.defaultView.scrollBy(h,d);else{let g=a.scrollLeft,k=a.scrollTop;d&&(a.scrollTop+=d),h&&(a.scrollLeft+=h);let C=a.scrollLeft-g,v=a.scrollTop-k;e={left:e.left-C,top:e.top-v,right:e.right-C,bottom:e.bottom-v}}let m=u?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(m))break;s=m=="absolute"?s.offsetParent:Io(s)}}function n_(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 a=n.root.elementFromPoint(o,s);if(!a||a==n.dom||!n.dom.contains(a))continue;let u=a.getBoundingClientRect();if(u.top>=t-20){r=a,i=u.top;break}}return{refDOM:r,refTop:i,stack:C0(n.dom)}}function C0(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=Io(r));return e}function r_({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;S0(t,r==0?0:r-e)}function S0(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)}}let so=null;function i_(n){if(n.setActive)return n.setActive();if(so)return n.focus(so);let e=C0(n);n.focus(so==null?{get preventScroll(){return so={preventScroll:!0},!0}}:void 0),so||(so=!1,S0(e,0))}function v0(n,e){let t,r=2e8,i,o=0,s=e.top,a=e.top,u,f;for(let h=n.firstChild,d=0;h;h=h.nextSibling,d++){let m;if(h.nodeType==1)m=h.getClientRects();else if(h.nodeType==3)m=pr(h).getClientRects();else continue;for(let g=0;g<m.length;g++){let k=m[g];if(k.top<=s&&k.bottom>=a){s=Math.max(k.bottom,s),a=Math.min(k.top,a);let C=k.left>e.left?k.left-e.left:k.right<e.left?e.left-k.right:0;if(C<r){t=h,r=C,i=C&&t.nodeType==3?{left:k.right<e.left?k.right:k.left,top:e.top}:e,h.nodeType==1&&C&&(o=d+(e.left>=(k.left+k.right)/2?1:0));continue}}else k.top>e.top&&!u&&k.left<=e.left&&k.right>=e.left&&(u=h,f={left:Math.max(k.left,Math.min(k.right,e.left)),top:k.top});!t&&(e.left>=k.right&&e.top>=k.top||e.left>=k.left&&e.top>=k.bottom)&&(o=d+1)}}return!t&&u&&(t=u,i=f,r=0),t&&t.nodeType==3?o_(t,i):!t||r&&t.nodeType==1?{node:n,offset:o}:v0(t,i)}function o_(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=Fr(r,1);if(s.top!=s.bottom&&Wh(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 Wh(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function s_(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function l_(n,e,t){let{node:r,offset:i}=v0(e,t),o=-1;if(r.nodeType==1&&!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 a_(n,e,t,r){let i=-1;for(let o=e,s=!1;o!=n.dom;){let a=n.docView.nearestDesc(o,!0),u;if(!a)return null;if(a.dom.nodeType==1&&(a.node.isBlock&&a.parent||!a.contentDOM)&&((u=a.dom.getBoundingClientRect()).width||u.height)&&(a.node.isBlock&&a.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(a.dom.nodeName)&&(!s&&u.left>r.left||u.top>r.top?i=a.posBefore:(!s&&u.right<r.left||u.bottom<r.top)&&(i=a.posAfter),s=!0),!a.contentDOM&&i<0&&!a.node.isText))return(a.node.isBlock?r.top<(u.top+u.bottom)/2:r.left<(u.left+u.right)/2)?a.posBefore:a.posAfter;o=a.dom.parentNode}return i>-1?i:n.docView.posFromDOM(e,t,-1)}function T0(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(s.nodeType==1){let a=s.getClientRects();for(let u=0;u<a.length;u++){let f=a[u];if(Wh(e,f))return T0(s,e,f)}}if((o=(o+1)%r)==i)break}return n}function u_(n,e){let t=n.dom.ownerDocument,r,i=0,o=QR(t,e.left,e.top);o&&({node:r,offset:i}=o);let s=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),a;if(!s||!n.dom.contains(s.nodeType!=1?s.parentNode:s)){let f=n.dom.getBoundingClientRect();if(!Wh(e,f)||(s=T0(n.dom,e,f),!s))return null}if(yt)for(let f=s;r&&f;f=Io(f))f.draggable&&(r=void 0);if(s=s_(s,e),r){if(kn&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let h=r.childNodes[i],d;h.nodeName=="IMG"&&(d=h.getBoundingClientRect()).right<=e.left&&d.bottom>e.top&&i++}let f;Gs&&i&&r.nodeType==1&&(f=r.childNodes[i-1]).nodeType==1&&f.contentEditable=="false"&&f.getBoundingClientRect().top>=e.top&&i--,r==n.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?a=n.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(a=a_(n,r,i,e))}a==null&&(a=l_(n,s,e));let u=n.docView.nearestDesc(s,!0);return{pos:a,inside:u?u.posAtStart-u.border:-1}}function Pg(n){return n.top<n.bottom||n.left<n.right}function Fr(n,e){let t=n.getClientRects();if(t.length){let r=t[e<0?0:t.length-1];if(Pg(r))return r}return Array.prototype.find.call(t,Pg)||n.getBoundingClientRect()}const c_=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function A0(n,e,t){let{node:r,offset:i,atom:o}=n.docView.domFromPos(e,t<0?-1:1),s=Gs||kn;if(r.nodeType==3)if(s&&(c_.test(r.nodeValue)||(t<0?!i:i==r.nodeValue.length))){let u=Fr(pr(r,i,i),t);if(kn&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let f=Fr(pr(r,i-1,i-1),-1);if(f.top==u.top){let h=Fr(pr(r,i,i+1),-1);if(h.top!=u.top)return ns(h,h.left<f.left)}}return u}else{let u=i,f=i,h=t<0?1:-1;return t<0&&!i?(f++,h=-1):t>=0&&i==r.nodeValue.length?(u--,h=1):t<0?u--:f++,ns(Fr(pr(r,u,f),h),h<0)}if(!n.state.doc.resolve(e-(o||0)).parent.inlineContent){if(o==null&&i&&(t<0||i==yn(r))){let u=r.childNodes[i-1];if(u.nodeType==1)return cf(u.getBoundingClientRect(),!1)}if(o==null&&i<yn(r)){let u=r.childNodes[i];if(u.nodeType==1)return cf(u.getBoundingClientRect(),!0)}return cf(r.getBoundingClientRect(),t>=0)}if(o==null&&i&&(t<0||i==yn(r))){let u=r.childNodes[i-1],f=u.nodeType==3?pr(u,yn(u)-(s?0:1)):u.nodeType==1&&(u.nodeName!="BR"||!u.nextSibling)?u:null;if(f)return ns(Fr(f,1),!1)}if(o==null&&i<yn(r)){let u=r.childNodes[i];for(;u.pmViewDesc&&u.pmViewDesc.ignoreForCoords;)u=u.nextSibling;let f=u?u.nodeType==3?pr(u,0,s?0:1):u.nodeType==1?u:null:null;if(f)return ns(Fr(f,-1),!0)}return ns(Fr(r.nodeType==3?pr(r):r,-t),t>=0)}function ns(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 cf(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 N0(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 f_(n,e,t){let r=e.selection,i=t=="up"?r.$from:r.$to;return N0(n,e,()=>{let{node:o}=n.docView.domFromPos(i.pos,t=="up"?-1:1);for(;;){let a=n.docView.nearestDesc(o,!0);if(!a)break;if(a.node.isBlock){o=a.contentDOM||a.dom;break}o=a.dom.parentNode}let s=A0(n,i.pos,1);for(let a=o.firstChild;a;a=a.nextSibling){let u;if(a.nodeType==1)u=a.getClientRects();else if(a.nodeType==3)u=pr(a,0,a.nodeValue.length).getClientRects();else continue;for(let f=0;f<u.length;f++){let h=u[f];if(h.bottom>h.top+1&&(t=="up"?s.top-h.top>(h.bottom-s.top)*2:h.bottom-s.bottom>(s.bottom-h.top)*2))return!1}}return!0})}const h_=/[\u0590-\u08ac]/;function d_(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,a=n.domSelection();return a?!h_.test(r.parent.textContent)||!a.modify?t=="left"||t=="backward"?o:s:N0(n,e,()=>{let{focusNode:u,focusOffset:f,anchorNode:h,anchorOffset:d}=n.domSelectionRange(),m=a.caretBidiLevel;a.modify("move",t,"character");let g=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:k,focusOffset:C}=n.domSelectionRange(),v=k&&!g.contains(k.nodeType==1?k:k.parentNode)||u==k&&f==C;try{a.collapse(h,d),u&&(u!=h||f!=d)&&a.extend&&a.extend(u,f)}catch{}return m!=null&&(a.caretBidiLevel=m),v}):r.pos==r.start()||r.pos==r.end()}let Bg=null,Fg=null,zg=!1;function p_(n,e,t){return Bg==e&&Fg==t?zg:(Bg=e,Fg=t,zg=t=="up"||t=="down"?f_(n,e,t):d_(n,e,t))}const bn=0,$g=1,wi=2,Jn=3;class Ys{constructor(e,t,r,i){this.parent=e,this.children=t,this.dom=r,this.contentDOM=i,this.dirty=bn,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){return!1}matchesHack(e){return!1}parseRule(){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&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))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>ft(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;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)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):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 a=i.children[s];if(a.size){i=a;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],a=o+s.size;if(a>e||s instanceof I0){i=e-o;break}o=a}if(i)return this.children[r].domFromPos(i-this.children[r].border,t);for(let o;r&&!(o=this.children[r-1]).size&&o instanceof M0&&o.side>=0;r--);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?ft(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?ft(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,a=0;;a++){let u=this.children[a],f=s+u.size;if(i==-1&&e<=f){let h=s+u.border;if(e>=h&&t<=f-u.border&&u.node&&u.contentDOM&&this.contentDOM.contains(u.contentDOM))return u.parseRange(e,t,h);e=s;for(let d=a;d>0;d--){let m=this.children[d-1];if(m.size&&m.dom.parentNode==this.contentDOM&&!m.emptyChildAt(1)){i=ft(m.dom)+1;break}e-=m.size}i==-1&&(i=0)}if(i>-1&&(f>t||a==this.children.length-1)){t=f;for(let h=a+1;h<this.children.length;h++){let d=this.children[h];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(-1)){o=ft(d.dom);break}t+=d.size}o==-1&&(o=this.contentDOM.childNodes.length);break}s=f}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(t.nodeType!=1||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 g=0,k=0;g<this.children.length;g++){let C=this.children[g],v=k+C.size;if(o>k&&s<v)return C.setSelection(e-k-C.border,t-k-C.border,r,i);k=v}let a=this.domFromPos(e,e?-1:1),u=t==e?a:this.domFromPos(t,t?-1:1),f=r.root.getSelection(),h=r.domSelectionRange(),d=!1;if((kn||yt)&&e==t){let{node:g,offset:k}=a;if(g.nodeType==3){if(d=!!(k&&g.nodeValue[k-1]==`
40
+ `),d&&k==g.nodeValue.length)for(let C=g,v;C;C=C.parentNode){if(v=C.nextSibling){v.nodeName=="BR"&&(a=u={node:v.parentNode,offset:ft(v)+1});break}let S=C.pmViewDesc;if(S&&S.node&&S.node.isBlock)break}}else{let C=g.childNodes[k-1];d=C&&(C.nodeName=="BR"||C.contentEditable=="false")}}if(kn&&h.focusNode&&h.focusNode!=u.node&&h.focusNode.nodeType==1){let g=h.focusNode.childNodes[h.focusOffset];g&&g.contentEditable=="false"&&(i=!0)}if(!(i||d&&yt)&&Bi(a.node,a.offset,h.anchorNode,h.anchorOffset)&&Bi(u.node,u.offset,h.focusNode,h.focusOffset))return;let m=!1;if((f.extend||e==t)&&!(d&&kn)){f.collapse(a.node,a.offset);try{e!=t&&f.extend(u.node,u.offset),m=!0}catch{}}if(!m){if(e>t){let k=a;a=u,u=k}let g=document.createRange();g.setEnd(u.node,u.offset),g.setStart(a.node,a.offset),f.removeAllRanges(),f.addRange(g)}}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 a=r+o.border,u=s-o.border;if(e>=a&&t<=u){this.dirty=e==r||t==s?wi:$g,e==a&&t==u&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=Jn:o.markDirty(e-a,t-a);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?wi:Jn}r=s}this.dirty=wi}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?wi:$g;t.dirty<r&&(t.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class M0 extends Ys{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){if(s.nodeType!=1){let a=document.createElement("span");a.appendChild(s),s=a}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=t,this.widget=t,o=this}matchesWidget(e){return this.dirty==bn&&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}}class m_ extends Ys{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}}class Fi extends Ys{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=Do.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new Fi(e,t,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.dirty&Jn||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Jn&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=bn){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=bn}}slice(e,t,r){let i=Fi.create(this.parent,this.mark,!0,r),o=this.children,s=this.size;t<s&&(o=nh(o,t,s,r)),e>0&&(o=nh(o,0,e,r));for(let a=0;a<o.length;a++)o[a].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()}}class jr extends Ys{constructor(e,t,r,i,o,s,a,u,f){super(e,[],o,s),this.node=t,this.outerDeco=r,this.innerDeco=i,this.nodeDOM=a}static create(e,t,r,i,o,s){let a=o.nodeViews[t.type.name],u,f=a&&a(t,o,()=>{if(!u)return s;if(u.parent)return u.parent.posBeforeChild(u)},r,i),h=f&&f.dom,d=f&&f.contentDOM;if(t.isText){if(!h)h=document.createTextNode(t.text);else if(h.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else h||({dom:h,contentDOM:d}=Do.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!d&&!t.isText&&h.nodeName!="BR"&&(h.hasAttribute("contenteditable")||(h.contentEditable="false"),t.type.spec.draggable&&(h.draggable=!0));let m=h;return h=R0(h,r,t),f?u=new g_(e,t,r,i,h,d||null,m,f,o,s+1):t.isText?new cu(e,t,r,i,h,m,o):new jr(e,t,r,i,h,d||null,m,o,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let r=this.children[t];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>W.empty)}return e}matchesNode(e,t,r){return this.dirty==bn&&e.eq(this.node)&&Na(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,a=o&&o.pos<0,u=new k_(this,s&&s.node,e);w_(this.node,this.innerDeco,(f,h,d)=>{f.spec.marks?u.syncToMarks(f.spec.marks,r,e,h):f.type.side>=0&&!d&&u.syncToMarks(h==this.node.childCount?Ne.none:this.node.child(h).marks,r,e,h),u.placeWidget(f,e,i)},(f,h,d,m)=>{u.syncToMarks(f.marks,r,e,m);let g;u.findNodeMatch(f,h,d,m)||a&&e.state.selection.from>i&&e.state.selection.to<i+f.nodeSize&&(g=u.findIndexWithChild(o.node))>-1&&u.updateNodeAt(f,h,d,g,e)||u.updateNextNode(f,h,d,e,m,i)||u.addNode(f,h,d,e,i),i+=f.nodeSize}),u.syncToMarks([],r,e,0),this.node.isTextblock&&u.addTextblockHacks(),u.destroyRest(),(u.changed||this.dirty==wi)&&(s&&this.protectLocalComposition(e,s),E0(this.contentDOM,this.children,e),Eo&&C_(this.dom))}localCompositionInfo(e,t){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof pe)||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,a=S_(this.node.content,s,r-t,i-t);return a<0?null:{node:o,pos:a,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 m_(this,o,t,i);e.input.compositionNodes.push(s),this.children=nh(this.children,r,r+i.length,e,s)}update(e,t,r,i){return this.dirty==Jn||!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=bn}updateOuterDeco(e){if(Na(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=O0(this.dom,this.nodeDOM,th(this.outerDeco,this.node,t),th(e,this.node,t)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function Wg(n,e,t,r,i){R0(r,e,n);let o=new jr(void 0,n,e,t,r,r,r,i,0);return o.contentDOM&&o.updateChildren(i,0),o}class cu extends jr{constructor(e,t,r,i,o,s,a){super(e,t,r,i,o,null,s,a,0)}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==Jn||this.dirty!=bn&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=bn||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=bn,!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 cu(this.parent,i,this.outerDeco,this.innerDeco,o,o,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=Jn)}get domAtom(){return!1}isText(e){return this.node.text==e}}class I0 extends Ys{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==bn&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class g_ extends jr{constructor(e,t,r,i,o,s,a,u,f,h){super(e,t,r,i,o,s,a,f,h),this.spec=u}update(e,t,r,i){if(this.dirty==Jn)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 E0(n,e,t){let r=n.firstChild,i=!1;for(let o=0;o<e.length;o++){let s=e[o],a=s.dom;if(a.parentNode==n){for(;a!=r;)r=Vg(r),i=!0;r=r.nextSibling}else i=!0,n.insertBefore(a,r);if(s instanceof Fi){let u=r?r.previousSibling:n.lastChild;E0(s.contentDOM,s.children,t),r=u?u.nextSibling:n.firstChild}}for(;r;)r=Vg(r),i=!0;i&&t.trackWrites==n&&(t.trackWrites=null)}const ps=function(n){n&&(this.nodeName=n)};ps.prototype=Object.create(null);const Ci=[new ps];function th(n,e,t){if(n.length==0)return Ci;let r=t?Ci[0]:new ps,i=[r];for(let o=0;o<n.length;o++){let s=n[o].type.attrs;if(s){s.nodeName&&i.push(r=new ps(s.nodeName));for(let a in s){let u=s[a];u!=null&&(t&&i.length==1&&i.push(r=new ps(e.isInline?"span":"div")),a=="class"?r.class=(r.class?r.class+" ":"")+u:a=="style"?r.style=(r.style?r.style+";":"")+u:a!="nodeName"&&(r[a]=u))}}}return i}function O0(n,e,t,r){if(t==Ci&&r==Ci)return e;let i=e;for(let o=0;o<r.length;o++){let s=r[o],a=t[o];if(o){let u;a&&a.nodeName==s.nodeName&&i!=n&&(u=i.parentNode)&&u.nodeName.toLowerCase()==s.nodeName||(u=document.createElement(s.nodeName),u.pmIsDeco=!0,u.appendChild(i),a=Ci[0]),i=u}y_(i,a||Ci[0],s)}return i}function y_(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 R0(n,e,t){return O0(n,n,Ci,th(e,t,n.nodeType!=1))}function Na(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 Vg(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class k_{constructor(e,t,r){this.lock=t,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=b_(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,a=Math.min(s,e.length);for(;o<a&&(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=bn,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let u=-1,f=this.top.children.length;i<this.preMatch.index&&(f=Math.min(this.index+3,f));for(let h=this.index;h<f;h++){let d=this.top.children[h];if(d.matchesMark(e[s])&&!this.isLocked(d.dom)){u=h;break}}if(u>-1)u>this.index&&(this.changed=!0,this.destroyBetween(this.index,u)),this.top=this.top.children[this.index];else{let h=Fi.create(this.top,e[s],t,r);this.top.children.splice(this.index,0,h),this.top=h,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 a=this.index,u=Math.min(this.top.children.length,a+5);a<u;a++){let f=this.top.children[a];if(f.matchesNode(e,t,r)&&!this.preMatch.matched.has(f)){o=a;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==Jn&&s.dom==s.contentDOM&&(s.dirty=wi),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 a=this.index;a<this.top.children.length;a++){let u=this.top.children[a];if(u instanceof jr){let f=this.preMatch.matched.get(u);if(f!=null&&f!=o)return!1;let h=u.dom,d,m=this.isLocked(h)&&!(e.isText&&u.node&&u.node.isText&&u.nodeDOM.nodeValue==e.text&&u.dirty!=Jn&&Na(t,u.outerDeco));if(!m&&u.update(e,t,r,i))return this.destroyBetween(this.index,a),u.dom!=h&&(this.changed=!0),this.index++,!0;if(!m&&(d=this.recreateWrapper(u,e,t,r,i,s)))return this.destroyBetween(this.index,a),this.top.children[this.index]=d,d.contentDOM&&(d.dirty=wi,d.updateChildren(i,s+1),d.dirty=bn),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)||!Na(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let a=jr.create(this.top,t,r,i,o,s);if(a.contentDOM){a.children=e.children,e.children=[];for(let u of a.children)u.parent=a}return e.destroy(),a}addNode(e,t,r,i,o){let s=jr.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 M0(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 Fi;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof cu)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((yt||ht)&&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 I0(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||e.nodeType==1&&e.contains(this.lock.parentNode))}}function b_(n,e){let t=e,r=t.children.length,i=n.childCount,o=new Map,s=[];e:for(;i>0;){let a;for(;;)if(r){let f=t.children[r-1];if(f instanceof Fi)t=f,r=f.children.length;else{a=f,r--;break}}else{if(t==e)break e;r=t.parent.children.indexOf(t),t=t.parent}let u=a.node;if(u){if(u!=n.child(i-1))break;--i,o.set(a,i),s.push(a)}}return{index:i,matched:o,matches:s.reverse()}}function x_(n,e){return n.type.side-e.type.side}function w_(n,e,t,r){let i=e.locals(n),o=0;if(i.length==0){for(let f=0;f<n.childCount;f++){let h=n.child(f);r(h,i,e.forChild(o,h),f),o+=h.nodeSize}return}let s=0,a=[],u=null;for(let f=0;;){let h,d;for(;s<i.length&&i[s].to==o;){let v=i[s++];v.widget&&(h?(d||(d=[h])).push(v):h=v)}if(h)if(d){d.sort(x_);for(let v=0;v<d.length;v++)t(d[v],f,!!u)}else t(h,f,!!u);let m,g;if(u)g=-1,m=u,u=null;else if(f<n.childCount)g=f,m=n.child(f++);else break;for(let v=0;v<a.length;v++)a[v].to<=o&&a.splice(v--,1);for(;s<i.length&&i[s].from<=o&&i[s].to>o;)a.push(i[s++]);let k=o+m.nodeSize;if(m.isText){let v=k;s<i.length&&i[s].from<v&&(v=i[s].from);for(let S=0;S<a.length;S++)a[S].to<v&&(v=a[S].to);v<k&&(u=m.cut(v-o),m=m.cut(0,v-o),k=v,g=-1)}else for(;s<i.length&&i[s].to<k;)s++;let C=m.isInline&&!m.isLeaf?a.filter(v=>!v.inline):a.slice();r(m,C,e.forChild(o,m),g),o=k}}function C_(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 S_(n,e,t,r){for(let i=0,o=0;i<n.childCount&&o<=r;){let s=n.child(i++),a=o;if(o+=s.nodeSize,!s.isText)continue;let u=s.text;for(;i<n.childCount;){let f=n.child(i++);if(o+=f.nodeSize,!f.isText)break;u+=f.text}if(o>=t){if(o>=r&&u.slice(r-e.length-a,r-a)==e)return r-e.length;let f=a<r?u.lastIndexOf(e,r-a-1):-1;if(f>=0&&f+e.length+a>=t)return a+f;if(t==r&&u.length>=r+e.length-a&&u.slice(r-a,r-a+e.length)==e)return r}}return-1}function nh(n,e,t,r,i){let o=[];for(let s=0,a=0;s<n.length;s++){let u=n[s],f=a,h=a+=u.size;f>=t||h<=e?o.push(u):(f<e&&o.push(u.slice(0,e-f,r)),i&&(o.push(i),i=void 0),h>t&&o.push(u.slice(t-f,u.size,r)))}return o}function Vh(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 a=r.resolve(s),u,f;if(uu(t)){for(u=s;i&&!i.node;)i=i.parent;let d=i.node;if(i&&d.isAtom&&ce.isSelectable(d)&&i.parent&&!(d.isInline&&YR(t.focusNode,t.focusOffset,i.dom))){let m=i.posBefore;f=new ce(s==m?a:r.resolve(m))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let d=s,m=s;for(let g=0;g<t.rangeCount;g++){let k=t.getRangeAt(g);d=Math.min(d,n.docView.posFromDOM(k.startContainer,k.startOffset,1)),m=Math.max(m,n.docView.posFromDOM(k.endContainer,k.endOffset,-1))}if(d<0)return null;[u,s]=m==n.state.selection.anchor?[m,d]:[d,m],a=r.resolve(s)}else u=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(u<0)return null}let h=r.resolve(u);if(!f){let d=e=="pointer"||n.state.selection.head<a.pos&&!o?1:-1;f=Hh(n,h,a,d)}return f}function _0(n){return n.editable?n.hasFocus():L0(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function xr(n,e=!1){let t=n.state.selection;if(D0(n,t),!!_0(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&ht){let r=n.domSelectionRange(),i=n.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&Bi(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)T_(n);else{let{anchor:r,head:i}=t,o,s;Hg&&!(t instanceof pe)&&(t.$from.parent.inlineContent||(o=qg(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(s=qg(n,t.to))),n.docView.setSelection(r,i,n,e),Hg&&(o&&Kg(o),s&&Kg(s)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&v_(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const Hg=yt||ht&&x0<63;function qg(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(yt&&i&&i.contentEditable=="false")return ff(i);if((!i||i.contentEditable=="false")&&(!o||o.contentEditable=="false")){if(i)return ff(i);if(o)return ff(o)}}function ff(n){return n.contentEditable="true",yt&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function Kg(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function v_(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(()=>{(!_0(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function T_(n){let e=n.domSelection();if(!e)return;let t=n.cursorWrapper.dom,r=t.nodeName=="IMG";r?e.collapse(t.parentNode,ft(t)+1):e.collapse(t,0),!r&&!n.state.selection.visible&&Dt&&Ur<=11&&(t.disabled=!0,t.disabled=!1)}function D0(n,e){if(e instanceof ce){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(Ug(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else Ug(n)}function Ug(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function Hh(n,e,t,r){return n.someProp("createSelectionBetween",i=>i(n,e,t))||pe.between(e,t,r)}function jg(n){return n.editable&&!n.hasFocus()?!1:L0(n)}function L0(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function A_(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return Bi(e.node,e.offset,t.anchorNode,t.anchorOffset)}function rh(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&&de.findFrom(o,e)}function zr(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function Jg(n,e,t){let r=n.state.selection;if(r instanceof pe)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 zr(n,new pe(r.$anchor,s))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let i=rh(n.state,e);return i&&i instanceof ce?zr(n,i):!1}else if(!(mn&&t.indexOf("m")>-1)){let i=r.$head,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,s;if(!o||o.isText)return!1;let a=e<0?i.pos-o.nodeSize:i.pos;return o.isAtom||(s=n.docView.descAt(a))&&!s.contentDOM?ce.isSelectable(o)?zr(n,new ce(e<0?n.state.doc.resolve(i.pos-o.nodeSize):i)):Gs?zr(n,new pe(n.state.doc.resolve(e<0?a:a+o.nodeSize))):!1:!1}}else return!1;else{if(r instanceof ce&&r.node.isInline)return zr(n,new pe(e>0?r.$to:r.$from));{let i=rh(n.state,e);return i?zr(n,i):!1}}}function Ma(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function ms(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function lo(n,e){return e<0?N_(n):M_(n)}function N_(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i,o,s=!1;for(kn&&t.nodeType==1&&r<Ma(t)&&ms(t.childNodes[r],-1)&&(s=!0);;)if(r>0){if(t.nodeType!=1)break;{let a=t.childNodes[r-1];if(ms(a,-1))i=t,o=--r;else if(a.nodeType==3)t=a,r=t.nodeValue.length;else break}}else{if(P0(t))break;{let a=t.previousSibling;for(;a&&ms(a,-1);)i=t.parentNode,o=ft(a),a=a.previousSibling;if(a)t=a,r=Ma(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}s?ih(n,t,r):i&&ih(n,i,o)}function M_(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i=Ma(t),o,s;for(;;)if(r<i){if(t.nodeType!=1)break;let a=t.childNodes[r];if(ms(a,1))o=t,s=++r;else break}else{if(P0(t))break;{let a=t.nextSibling;for(;a&&ms(a,1);)o=a.parentNode,s=ft(a)+1,a=a.nextSibling;if(a)t=a,r=0,i=Ma(t);else{if(t=t.parentNode,t==n.dom)break;r=i=0}}}o&&ih(n,o,s)}function P0(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function I_(n,e){for(;n&&e==n.childNodes.length&&!Js(n);)e=ft(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=0}}function E_(n,e){for(;n&&!e&&!Js(n);)e=ft(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function ih(n,e,t){if(e.nodeType!=3){let o,s;(s=I_(e,t))?(e=s,t=0):(o=E_(e,t))&&(e=o,t=o.nodeValue.length)}let r=n.domSelection();if(!r)return;if(uu(r)){let o=document.createRange();o.setEnd(e,t),o.setStart(e,t),r.removeAllRanges(),r.addRange(o)}else r.extend&&r.extend(e,t);n.domObserver.setCurSelection();let{state:i}=n;setTimeout(()=>{n.state==i&&xr(n)},50)}function Gg(n,e){let t=n.state.doc.resolve(e);if(!(ht||w0)&&t.parent.inlineContent){let i=n.coordsAtPos(e);if(e>t.start()){let o=n.coordsAtPos(e-1),s=(o.top+o.bottom)/2;if(s>i.top&&s<i.bottom&&Math.abs(o.left-i.left)>1)return o.left<i.left?"ltr":"rtl"}if(e<t.end()){let o=n.coordsAtPos(e+1),s=(o.top+o.bottom)/2;if(s>i.top&&s<i.bottom&&Math.abs(o.left-i.left)>1)return o.left>i.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function Yg(n,e,t){let r=n.state.selection;if(r instanceof pe&&!r.empty||t.indexOf("s")>-1||mn&&t.indexOf("m")>-1)return!1;let{$from:i,$to:o}=r;if(!i.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let s=rh(n.state,e);if(s&&s instanceof ce)return zr(n,s)}if(!i.parent.inlineContent){let s=e<0?i:o,a=r instanceof Zt?de.near(s,e):de.findFrom(s,e);return a?zr(n,a):!1}return!1}function Xg(n,e){if(!(n.state.selection instanceof pe))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 Qg(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function O_(n){if(!yt||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;Qg(n,r,"true"),setTimeout(()=>Qg(n,r,"false"),20)}return!1}function R_(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function __(n,e){let t=e.keyCode,r=R_(e);if(t==8||mn&&t==72&&r=="c")return Xg(n,-1)||lo(n,-1);if(t==46&&!e.shiftKey||mn&&t==68&&r=="c")return Xg(n,1)||lo(n,1);if(t==13||t==27)return!0;if(t==37||mn&&t==66&&r=="c"){let i=t==37?Gg(n,n.state.selection.from)=="ltr"?-1:1:-1;return Jg(n,i,r)||lo(n,i)}else if(t==39||mn&&t==70&&r=="c"){let i=t==39?Gg(n,n.state.selection.from)=="ltr"?1:-1:1;return Jg(n,i,r)||lo(n,i)}else{if(t==38||mn&&t==80&&r=="c")return Yg(n,-1,r)||lo(n,-1);if(t==40||mn&&t==78&&r=="c")return O_(n)||Yg(n,1,r)||lo(n,1);if(r==(mn?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function qh(n,e){n.someProp("transformCopied",g=>{e=g(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 g=r.firstChild;t.push(g.type.name,g.attrs!=g.type.defaultAttrs?g.attrs:null),r=g.content}let s=n.someProp("clipboardSerializer")||Do.fromSchema(n.state.schema),a=V0(),u=a.createElement("div");u.appendChild(s.serializeFragment(r,{document:a}));let f=u.firstChild,h,d=0;for(;f&&f.nodeType==1&&(h=W0[f.nodeName.toLowerCase()]);){for(let g=h.length-1;g>=0;g--){let k=a.createElement(h[g]);for(;u.firstChild;)k.appendChild(u.firstChild);u.appendChild(k),d++}f=u.firstChild}f&&f.nodeType==1&&f.setAttribute("data-pm-slice",`${i} ${o}${d?` -${d}`:""} ${JSON.stringify(t)}`);let m=n.someProp("clipboardTextSerializer",g=>g(e,n))||e.content.textBetween(0,e.content.size,`
41
+
42
+ `);return{dom:u,text:m,slice:e}}function B0(n,e,t,r,i){let o=i.parent.type.spec.code,s,a;if(!t&&!e)return null;let u=!!e&&(r||o||!t);if(u){if(n.someProp("transformPastedText",m=>{e=m(e,o||r,n)}),o)return a=new J(W.from(n.state.schema.text(e.replace(/\r\n?/g,`
43
+ `))),0,0),n.someProp("transformPasted",m=>{a=m(a,n,!0)}),a;let d=n.someProp("clipboardTextParser",m=>m(e,i,r,n));if(d)a=d;else{let m=i.marks(),{schema:g}=n.state,k=Do.fromSchema(g);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(C=>{let v=s.appendChild(document.createElement("p"));C&&v.appendChild(k.serializeNode(g.text(C,m)))})}}else n.someProp("transformPastedHTML",d=>{t=d(t,n)}),s=B_(t),Gs&&F_(s);let f=s&&s.querySelector("[data-pm-slice]"),h=f&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(f.getAttribute("data-pm-slice")||"");if(h&&h[3])for(let d=+h[3];d>0;d--){let m=s.firstChild;for(;m&&m.nodeType!=1;)m=m.nextSibling;if(!m)break;s=m}if(a||(a=(n.someProp("clipboardParser")||n.someProp("domParser")||Ao.fromSchema(n.state.schema)).parseSlice(s,{preserveWhitespace:!!(u||h),context:i,ruleFromNode(m){return m.nodeName=="BR"&&!m.nextSibling&&m.parentNode&&!D_.test(m.parentNode.nodeName)?{ignore:!0}:null}})),h)a=z_(Zg(a,+h[1],+h[2]),h[4]);else if(a=J.maxOpen(L_(a.content,i),!0),a.openStart||a.openEnd){let d=0,m=0;for(let g=a.content.firstChild;d<a.openStart&&!g.type.spec.isolating;d++,g=g.firstChild);for(let g=a.content.lastChild;m<a.openEnd&&!g.type.spec.isolating;m++,g=g.lastChild);a=Zg(a,d,m)}return n.someProp("transformPasted",d=>{a=d(a,n,u)}),a}const D_=/^(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 L_(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(a=>{if(!s)return;let u=i.findWrapping(a.type),f;if(!u)return s=null;if(f=s.length&&o.length&&z0(u,o,a,s[s.length-1],0))s[s.length-1]=f;else{s.length&&(s[s.length-1]=$0(s[s.length-1],o.length));let h=F0(a,u);s.push(h),i=i.matchType(h.type),o=u}}),s)return W.from(s)}return n}function F0(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,W.from(n));return n}function z0(n,e,t,r,i){if(i<n.length&&i<e.length&&n[i]==e[i]){let o=z0(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(W.from(F0(t,n,i+1))))}}function $0(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,$0(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(W.empty,!0);return n.copy(t.append(r))}function oh(n,e,t,r,i,o){let s=e<0?n.firstChild:n.lastChild,a=s.content;return n.childCount>1&&(o=0),i<r-1&&(a=oh(a,e,t,r,i+1,o)),i>=t&&(a=e<0?s.contentMatchAt(0).fillBefore(a,o<=i).append(a):a.append(s.contentMatchAt(s.childCount).fillBefore(W.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,s.copy(a))}function Zg(n,e,t){return e<n.openStart&&(n=new J(oh(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new J(oh(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const W0={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let ey=null;function V0(){return ey||(ey=document.implementation.createHTMLDocument("title"))}let hf=null;function P_(n){let e=window.trustedTypes;return e?(hf||(hf=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),hf.createHTML(n)):n}function B_(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=V0().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),i;if((i=r&&W0[r[1].toLowerCase()])&&(n=i.map(o=>"<"+o+">").join("")+n+i.map(o=>"</"+o+">").reverse().join("")),t.innerHTML=P_(n),i)for(let o=0;o<i.length;o++)t=t.querySelector(i[o])||t;return t}function F_(n){let e=n.querySelectorAll(ht?"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==" "&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function z_(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 a=r.length-2;a>=0;a-=2){let u=t.nodes[r[a]];if(!u||u.hasRequiredAttrs())break;i=W.from(u.create(r[a+1],i)),o++,s++}return new J(i,o,s)}const vt={},Tt={},$_={touchstart:!0,touchmove:!0};class W_{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 V_(n){for(let e in vt){let t=vt[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{q_(n,r)&&!Kh(n,r)&&(n.editable||!(r.type in Tt))&&t(n,r)},$_[e]?{passive:!0}:void 0)}yt&&n.dom.addEventListener("input",()=>null),sh(n)}function Hr(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function H_(n){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 sh(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>Kh(n,r))})}function Kh(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function q_(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 K_(n,e){!Kh(n,e)&&vt[e.type]&&(n.editable||!(e.type in Tt))&&vt[e.type](n,e)}Tt.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!q0(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(kr&&ht&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),Eo&&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,bi(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||__(n,t)?t.preventDefault():Hr(n,"key")};Tt.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};Tt.keypress=(n,e)=>{let t=e;if(q0(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||mn&&t.metaKey)return;if(n.someProp("handleKeyPress",i=>i(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof pe)||!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 fu(n){return{left:n.clientX,top:n.clientY}}function U_(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function Uh(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,a=>s>o.depth?a(n,t,o.nodeAfter,o.before(s),i,!0):a(n,t,o.node(s),o.before(s),i,!1)))return!0;return!1}function mo(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 j_(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&ce.isSelectable(r)?(mo(n,new ce(t)),!0):!1}function J_(n,e){if(e==-1)return!1;let t=n.state.selection,r,i;t instanceof ce&&(r=t.node);let o=n.state.doc.resolve(e);for(let s=o.depth+1;s>0;s--){let a=s>o.depth?o.nodeAfter:o.node(s);if(ce.isSelectable(a)){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?(mo(n,ce.create(n.state.doc,i)),!0):!1}function G_(n,e,t,r,i){return Uh(n,"handleClickOn",e,t,r)||n.someProp("handleClick",o=>o(n,e,r))||(i?J_(n,t):j_(n,t))}function Y_(n,e,t,r){return Uh(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",i=>i(n,e,r))}function X_(n,e,t,r){return Uh(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",i=>i(n,e,r))||Q_(n,t,r)}function Q_(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(mo(n,pe.create(r,0,r.content.size)),!0):!1;let i=r.resolve(e);for(let o=i.depth+1;o>0;o--){let s=o>i.depth?i.nodeAfter:i.node(o),a=i.before(o);if(s.inlineContent)mo(n,pe.create(r,a+1,a+1+s.content.size));else if(ce.isSelectable(s))mo(n,ce.create(r,a));else continue;return!0}}function jh(n){return Ia(n)}const H0=mn?"metaKey":"ctrlKey";vt.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=jh(n),i=Date.now(),o="singleClick";i-n.input.lastClick.time<500&&U_(t,n.input.lastClick)&&!t[H0]&&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};let s=n.posAtCoords(fu(t));s&&(o=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new Z_(n,s,t,!!r)):(o=="doubleClick"?Y_:X_)(n,s.pos,s.inside,t)?t.preventDefault():Hr(n,"pointer"))};class Z_{constructor(e,t,r,i){this.view=e,this.pos=t,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[H0],this.allowDefault=r.shiftKey;let o,s;if(t.inside>-1)o=e.state.doc.nodeAt(t.inside),s=t.inside;else{let h=e.state.doc.resolve(t.pos);o=h.parent,s=h.depth?h.before():0}const a=i?null:r.target,u=a?e.docView.nearestDesc(a,!0):null;this.target=u&&u.nodeDOM.nodeType==1?u.nodeDOM:null;let{selection:f}=e.state;(r.button==0&&o.type.spec.draggable&&o.type.spec.selectable!==!1||f instanceof ce&&f.from<=s&&f.to>s)&&(this.mightDrag={node:o,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&kn&&!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()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),Hr(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),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(()=>xr(this.view)),this.view.input.mouseDown=null}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(fu(e))),this.updateAllowDefault(e),this.allowDefault||!t?Hr(this.view,"pointer"):G_(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||yt&&this.mightDrag&&!this.mightDrag.node.isAtom||ht&&!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)?(mo(this.view,de.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):Hr(this.view,"pointer")}move(e){this.updateAllowDefault(e),Hr(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}vt.touchstart=n=>{n.input.lastTouch=Date.now(),jh(n),Hr(n,"pointer")};vt.touchmove=n=>{n.input.lastTouch=Date.now(),Hr(n,"pointer")};vt.contextmenu=n=>jh(n);function q0(n,e){return n.composing?!0:yt&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const eD=kr?5e3:-1;Tt.compositionstart=Tt.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof pe&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||ht&&w0&&tD(n)))n.markCursor=n.state.storedMarks||t.marks(),Ia(n,!0),n.markCursor=null;else if(Ia(n,!e.selection.empty),kn&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let i=r.focusNode,o=r.focusOffset;i&&i.nodeType==1&&o!=0;){let s=o<0?i.lastChild:i.childNodes[o-1];if(!s)break;if(s.nodeType==3){let a=n.domSelection();a&&a.collapse(s,s.nodeValue.length);break}else i=s,o=-1}}n.input.composing=!0}K0(n,eD)};function tD(n){let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(!e||e.nodeType!=1||t>=e.childNodes.length)return!1;let r=e.childNodes[t];return r.nodeType==1&&r.contentEditable=="false"}Tt.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,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++,K0(n,20))};function K0(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>Ia(n),e))}function U0(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=rD());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function nD(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=JR(e.focusNode,e.focusOffset),r=GR(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 rD(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function Ia(n,e=!1){if(!(kr&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),U0(n),e||n.docView&&n.docView.dirty){let t=Vh(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 iD(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)}const vs=Dt&&Ur<15||Eo&&ZR<604;vt.copy=Tt.cut=(n,e)=>{let t=e,r=n.state.selection,i=t.type=="cut";if(r.empty)return;let o=vs?null:t.clipboardData,s=r.content(),{dom:a,text:u}=qh(n,s);o?(t.preventDefault(),o.clearData(),o.setData("text/html",a.innerHTML),o.setData("text/plain",u)):iD(n,a),i&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function oD(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function sD(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?Ts(n,r.value,null,i,e):Ts(n,r.textContent,r.innerHTML,i,e)},50)}function Ts(n,e,t,r,i){let o=B0(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",u=>u(n,i,o||J.empty)))return!0;if(!o)return!1;let s=oD(o),a=s?n.state.tr.replaceSelectionWith(s,r):n.state.tr.replaceSelection(o);return n.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function j0(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," "):""}Tt.paste=(n,e)=>{let t=e;if(n.composing&&!kr)return;let r=vs?null:t.clipboardData,i=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&Ts(n,j0(r),r.getData("text/html"),i,t)?t.preventDefault():sD(n,t)};class J0{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}}const lD=mn?"altKey":"ctrlKey";function G0(n,e){let t=n.someProp("dragCopies",r=>!r(e));return t??!e[lD]}vt.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(fu(t)),s;if(!(o&&o.pos>=i.from&&o.pos<=(i instanceof ce?i.to-1:i.to))){if(r&&r.mightDrag)s=ce.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let d=n.docView.nearestDesc(t.target,!0);d&&d.node.type.spec.draggable&&d!=n.docView&&(s=ce.create(n.state.doc,d.posBefore))}}let a=(s||n.state.selection).content(),{dom:u,text:f,slice:h}=qh(n,a);(!t.dataTransfer.files.length||!ht||x0>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(vs?"Text":"text/html",u.innerHTML),t.dataTransfer.effectAllowed="copyMove",vs||t.dataTransfer.setData("text/plain",f),n.dragging=new J0(h,G0(n,t),s)};vt.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};Tt.dragover=Tt.dragenter=(n,e)=>e.preventDefault();Tt.drop=(n,e)=>{try{aD(n,e,n.dragging)}finally{n.dragging=null}};function aD(n,e,t){if(!e.dataTransfer)return;let r=n.posAtCoords(fu(e));if(!r)return;let i=n.state.doc.resolve(r.pos),o=t&&t.slice;o?n.someProp("transformPasted",g=>{o=g(o,n,!1)}):o=B0(n,j0(e.dataTransfer),vs?null:e.dataTransfer.getData("text/html"),!1,i);let s=!!(t&&G0(n,e));if(n.someProp("handleDrop",g=>g(n,e,o||J.empty,s))){e.preventDefault();return}if(!o)return;e.preventDefault();let a=o?iR(n.state.doc,i.pos,o):i.pos;a==null&&(a=i.pos);let u=n.state.tr;if(s){let{node:g}=t;g?g.replace(u):u.deleteSelection()}let f=u.mapping.map(a),h=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,d=u.doc;if(h?u.replaceRangeWith(f,f,o.content.firstChild):u.replaceRange(f,f,o),u.doc.eq(d))return;let m=u.doc.resolve(f);if(h&&ce.isSelectable(o.content.firstChild)&&m.nodeAfter&&m.nodeAfter.sameMarkup(o.content.firstChild))u.setSelection(new ce(m));else{let g=u.mapping.map(a);u.mapping.maps[u.mapping.maps.length-1].forEach((k,C,v,S)=>g=S),u.setSelection(Hh(n,m,u.doc.resolve(g)))}n.focus(),n.dispatch(u.setMeta("uiEvent","drop"))}vt.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())&&xr(n)},20))};vt.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)};vt.beforeinput=(n,e)=>{if(ht&&kr&&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,bi(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 Tt)vt[n]=Tt[n];function As(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}class Ea{constructor(e,t){this.toDOM=e,this.spec=t||Mi,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 nt(o-r,o-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Ea&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&As(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Jr{constructor(e,t){this.attrs=e,this.spec=t||Mi}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 nt(o,s,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof Jr&&As(this.attrs,e.attrs)&&As(this.spec,e.spec)}static is(e){return e.type instanceof Jr}destroy(){}}class Jh{constructor(e,t){this.attrs=e,this.spec=t||Mi}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 nt(o.pos-r,s.pos-r,this)}valid(e,t){let{index:r,offset:i}=e.content.findIndex(t.from),o;return i==t.from&&!(o=e.child(r)).isText&&i+o.nodeSize==t.to}eq(e){return this==e||e instanceof Jh&&As(this.attrs,e.attrs)&&As(this.spec,e.spec)}destroy(){}}class nt{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new nt(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 nt(e,e,new Ea(t,r))}static inline(e,t,r,i){return new nt(e,t,new Jr(r,i))}static node(e,t,r,i){return new nt(e,t,new Jh(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Jr}get widget(){return this.type instanceof Ea}}const uo=[],Mi={};class $e{constructor(e,t){this.local=e.length?e:uo,this.children=t.length?t:uo}static create(e,t){return t.length?Oa(t,e,0,Mi):mt}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 a=this.local[s];a.from<=t&&a.to>=e&&(!o||o(a.spec))&&r.push(a.copy(a.from+i,a.to+i))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<t&&this.children[s+1]>e){let a=this.children[s]+1;this.children[s+2].findInner(e-a,t-a,r,i+a,o)}}map(e,t,r){return this==mt||e.maps.length==0?this:this.mapInner(e,t,0,0,r||Mi)}mapInner(e,t,r,i,o){let s;for(let a=0;a<this.local.length;a++){let u=this.local[a].map(e,r,i);u&&u.type.valid(t,u)?(s||(s=[])).push(u):o.onRemove&&o.onRemove(this.local[a].spec)}return this.children.length?uD(this.children,s||[],e,t,r,i,o):s?new $e(s.sort(Ii),uo):mt}add(e,t){return t.length?this==mt?$e.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let i,o=0;e.forEach((a,u)=>{let f=u+r,h;if(h=X0(t,a,f)){for(i||(i=this.children.slice());o<i.length&&i[o]<u;)o+=3;i[o]==u?i[o+2]=i[o+2].addInner(a,h,f+1):i.splice(o,0,u,u+a.nodeSize,Oa(h,a,f+1,Mi)),o+=3}});let s=Y0(o?Q0(t):t,-r);for(let a=0;a<s.length;a++)s[a].type.valid(e,s[a])||s.splice(a--,1);return new $e(s.length?this.local.concat(s).sort(Ii):this.local,i||this.children)}remove(e){return e.length==0||this==mt?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,a=r[o]+t,u=r[o+1]+t;for(let h=0,d;h<e.length;h++)(d=e[h])&&d.from>a&&d.to<u&&(e[h]=null,(s||(s=[])).push(d));if(!s)continue;r==this.children&&(r=this.children.slice());let f=r[o+2].removeInner(s,a+1);f!=mt?r[o+2]=f:(r.splice(o,3),o-=3)}if(i.length){for(let o=0,s;o<e.length;o++)if(s=e[o])for(let a=0;a<i.length;a++)i[a].eq(s,t)&&(i==this.local&&(i=this.local.slice()),i.splice(a--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new $e(i,r):mt}forChild(e,t){if(this==mt)return this;if(t.isLeaf)return $e.empty;let r,i;for(let a=0;a<this.children.length;a+=3)if(this.children[a]>=e){this.children[a]==e&&(r=this.children[a+2]);break}let o=e+1,s=o+t.content.size;for(let a=0;a<this.local.length;a++){let u=this.local[a];if(u.from<s&&u.to>o&&u.type instanceof Jr){let f=Math.max(o,u.from)-o,h=Math.min(s,u.to)-o;f<h&&(i||(i=[])).push(u.copy(f,h))}}if(i){let a=new $e(i.sort(Ii),uo);return r?new $r([a,r]):a}return r||mt}eq(e){if(this==e)return!0;if(!(e instanceof $e)||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 Gh(this.localsInner(e))}localsInner(e){if(this==mt)return uo;if(e.inlineContent||!this.local.some(Jr.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Jr||t.push(this.local[r]);return t}forEachSet(e){e(this)}}$e.empty=new $e([],[]);$e.removeOverlap=Gh;const mt=$e.empty;class $r{constructor(e){this.members=e}map(e,t){const r=this.members.map(i=>i.map(e,t,Mi));return $r.from(r)}forChild(e,t){if(t.isLeaf)return $e.empty;let r=[];for(let i=0;i<this.members.length;i++){let o=this.members[i].forChild(e,t);o!=mt&&(o instanceof $r?r=r.concat(o.members):r.push(o))}return $r.from(r)}eq(e){if(!(e instanceof $r)||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?Gh(r?t:t.sort(Ii)):uo}static from(e){switch(e.length){case 0:return mt;case 1:return e[0];default:return new $r(e.every(t=>t instanceof $e)?e:e.reduce((t,r)=>t.concat(r instanceof $e?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function uD(n,e,t,r,i,o,s){let a=n.slice();for(let f=0,h=o;f<t.maps.length;f++){let d=0;t.maps[f].forEach((m,g,k,C)=>{let v=C-k-(g-m);for(let S=0;S<a.length;S+=3){let L=a[S+1];if(L<0||m>L+h-d)continue;let R=a[S]+h-d;g>=R?a[S+1]=m<=R?-2:-1:m>=h&&v&&(a[S]+=v,a[S+1]+=v)}d+=v}),h=t.maps[f].map(h,-1)}let u=!1;for(let f=0;f<a.length;f+=3)if(a[f+1]<0){if(a[f+1]==-2){u=!0,a[f+1]=-1;continue}let h=t.map(n[f]+o),d=h-i;if(d<0||d>=r.content.size){u=!0;continue}let m=t.map(n[f+1]+o,-1),g=m-i,{index:k,offset:C}=r.content.findIndex(d),v=r.maybeChild(k);if(v&&C==d&&C+v.nodeSize==g){let S=a[f+2].mapInner(t,v,h+1,n[f]+o+1,s);S!=mt?(a[f]=d,a[f+1]=g,a[f+2]=S):(a[f+1]=-2,u=!0)}else u=!0}if(u){let f=cD(a,n,e,t,i,o,s),h=Oa(f,r,0,s);e=h.local;for(let d=0;d<a.length;d+=3)a[d+1]<0&&(a.splice(d,3),d-=3);for(let d=0,m=0;d<h.children.length;d+=3){let g=h.children[d];for(;m<a.length&&a[m]<g;)m+=3;a.splice(m,0,h.children[d],h.children[d+1],h.children[d+2])}}return new $e(e.sort(Ii),a)}function Y0(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 nt(i.from+e,i.to+e,i.type))}return t}function cD(n,e,t,r,i,o,s){function a(u,f){for(let h=0;h<u.local.length;h++){let d=u.local[h].map(r,i,f);d?t.push(d):s.onRemove&&s.onRemove(u.local[h].spec)}for(let h=0;h<u.children.length;h+=3)a(u.children[h+2],u.children[h]+f+1)}for(let u=0;u<n.length;u+=3)n[u+1]==-1&&a(n[u+2],e[u]+o+1);return t}function X0(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 Q0(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function Oa(n,e,t,r){let i=[],o=!1;e.forEach((a,u)=>{let f=X0(n,a,u+t);if(f){o=!0;let h=Oa(f,a,t+u+1,r);h!=mt&&i.push(u,u+a.nodeSize,h)}});let s=Y0(o?Q0(n):n,-t).sort(Ii);for(let a=0;a<s.length;a++)s[a].type.valid(e,s[a])||(r.onRemove&&r.onRemove(s[a].spec),s.splice(a--,1));return s.length||i.length?new $e(s,i):mt}function Ii(n,e){return n.from-e.from||n.to-e.to}function Gh(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),ty(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),ty(e,i,r.copy(o.from,r.to)));break}}}return e}function ty(n,e,t){for(;e<n.length&&Ii(t,n[e])>0;)e++;n.splice(e,0,t)}function df(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=mt&&e.push(r)}),n.cursorWrapper&&e.push($e.create(n.state.doc,[n.cursorWrapper.deco])),$r.from(e)}const fD={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},hD=Dt&&Ur<=11;class dD{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class pD{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new dD,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]);Dt&&Ur<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():yt&&e.composing&&r.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),hD&&(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,fD)),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(jg(this.view)){if(this.suppressingSelectionUpdates)return xr(this.view);if(Dt&&Ur<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Bi(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=Io(o))t.add(o);for(let o=e.anchorNode;o;o=Io(o))if(t.has(o)){r=o;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?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=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&jg(e)&&!this.ignoreSelectionChange(r),o=-1,s=-1,a=!1,u=[];if(e.editable)for(let h=0;h<t.length;h++){let d=this.registerMutation(t[h],u);d&&(o=o<0?d.from:Math.min(d.from,o),s=s<0?d.to:Math.max(d.to,s),d.typeOver&&(a=!0))}if(u.some(h=>h.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let h of u)if(h.nodeName=="BR"&&h.parentNode){let d=h.nextSibling;for(;d&&d.nodeType==1;){if(d.contentEditable=="false"){h.parentNode.removeChild(h);break}d=d.firstChild}}}else if(kn&&u.length){let h=u.filter(d=>d.nodeName=="BR");if(h.length==2){let[d,m]=h;d.parentNode&&d.parentNode.parentNode==m.parentNode?m.remove():d.remove()}else{let{focusNode:d}=this.currentSelection;for(let m of h){let g=m.parentNode;g&&g.nodeName=="LI"&&(!d||yD(e,d)!=g)&&m.remove()}}}let f=null;o<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&uu(r)&&(f=Vh(e))&&f.eq(de.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,xr(e),this.currentSelection.set(r),e.scrollToSelection()):(o>-1||i)&&(o>-1&&(e.docView.markDirty(o,s),mD(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,kD(e,u)),this.handleDOMChange(o,s,a,u),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||xr(e),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 h=0;h<e.addedNodes.length;h++){let d=e.addedNodes[h];t.push(d),d.nodeType==3&&(this.lastChangedTextNode=d)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let i=e.previousSibling,o=e.nextSibling;if(Dt&&Ur<=11&&e.addedNodes.length)for(let h=0;h<e.addedNodes.length;h++){let{previousSibling:d,nextSibling:m}=e.addedNodes[h];(!d||Array.prototype.indexOf.call(e.addedNodes,d)<0)&&(i=d),(!m||Array.prototype.indexOf.call(e.addedNodes,m)<0)&&(o=m)}let s=i&&i.parentNode==e.target?ft(i)+1:0,a=r.localPosFromDOM(e.target,s,-1),u=o&&o.parentNode==e.target?ft(o):e.target.childNodes.length,f=r.localPosFromDOM(e.target,u,1);return{from:a,to:f}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let ny=new WeakMap,ry=!1;function mD(n){if(!ny.has(n)&&(ny.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=kn,ry)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."),ry=!0}}function iy(n,e){let t=e.startContainer,r=e.startOffset,i=e.endContainer,o=e.endOffset,s=n.domAtPos(n.state.selection.anchor);return Bi(s.node,s.offset,i,o)&&([t,r,i,o]=[i,o,t,r]),{anchorNode:t,anchorOffset:r,focusNode:i,focusOffset:o}}function gD(n,e){if(e.getComposedRanges){let i=e.getComposedRanges(n.root)[0];if(i)return iy(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?iy(n,t):null}function yD(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 kD(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 a=s;for(;;){let u=a.firstChild;if(!u||u.nodeType!=1||u.contentEditable=="false"||/^(BR|IMG)$/.test(u.nodeName))break;a=u}a.insertBefore(o,a.firstChild),r==o&&n.domSelection().collapse(o,i)}else o.parentNode.removeChild(o)}}function bD(n,e,t){let{node:r,fromOffset:i,toOffset:o,from:s,to:a}=n.docView.parseRange(e,t),u=n.domSelectionRange(),f,h=u.anchorNode;if(h&&n.dom.contains(h.nodeType==1?h:h.parentNode)&&(f=[{node:h,offset:u.anchorOffset}],uu(u)||f.push({node:u.focusNode,offset:u.focusOffset})),ht&&n.input.lastKeyCode===8)for(let v=o;v>i;v--){let S=r.childNodes[v-1],L=S.pmViewDesc;if(S.nodeName=="BR"&&!L){o=v;break}if(!L||L.size)break}let d=n.state.doc,m=n.someProp("domParser")||Ao.fromSchema(n.state.schema),g=d.resolve(s),k=null,C=m.parse(r,{topNode:g.parent,topMatch:g.parent.contentMatchAt(g.index()),topOpen:!0,from:i,to:o,preserveWhitespace:g.parent.type.whitespace=="pre"?"full":!0,findPositions:f,ruleFromNode:xD,context:g});if(f&&f[0].pos!=null){let v=f[0].pos,S=f[1]&&f[1].pos;S==null&&(S=v),k={anchor:v+s,head:S+s}}return{doc:C,sel:k,from:s,to:a}}function xD(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(yt&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(n.parentNode.lastChild==n||yt&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}const wD=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function CD(n,e,t,r,i){let o=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let H=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,X=Vh(n,H);if(X&&!n.state.selection.eq(X)){if(ht&&kr&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",D=>D(n,bi(13,"Enter"))))return;let te=n.state.tr.setSelection(X);H=="pointer"?te.setMeta("pointer",!0):H=="key"&&te.scrollIntoView(),o&&te.setMeta("composition",o),n.dispatch(te)}return}let s=n.state.doc.resolve(e),a=s.sharedDepth(t);e=s.before(a+1),t=n.state.doc.resolve(t).after(a+1);let u=n.state.selection,f=bD(n,e,t),h=n.state.doc,d=h.slice(f.from,f.to),m,g;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(m=n.state.selection.to,g="end"):(m=n.state.selection.from,g="start"),n.input.lastKeyCode=null;let k=TD(d.content,f.doc.content,f.from,m,g);if(k&&n.input.domChangeCount++,(Eo&&n.input.lastIOSEnter>Date.now()-225||kr)&&i.some(H=>H.nodeType==1&&!wD.test(H.nodeName))&&(!k||k.endA>=k.endB)&&n.someProp("handleKeyDown",H=>H(n,bi(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!k)if(r&&u instanceof pe&&!u.empty&&u.$head.sameParent(u.$anchor)&&!n.composing&&!(f.sel&&f.sel.anchor!=f.sel.head))k={start:u.from,endA:u.to,endB:u.to};else{if(f.sel){let H=oy(n,n.state.doc,f.sel);if(H&&!H.eq(n.state.selection)){let X=n.state.tr.setSelection(H);o&&X.setMeta("composition",o),n.dispatch(X)}}return}n.state.selection.from<n.state.selection.to&&k.start==k.endB&&n.state.selection instanceof pe&&(k.start>n.state.selection.from&&k.start<=n.state.selection.from+2&&n.state.selection.from>=f.from?k.start=n.state.selection.from:k.endA<n.state.selection.to&&k.endA>=n.state.selection.to-2&&n.state.selection.to<=f.to&&(k.endB+=n.state.selection.to-k.endA,k.endA=n.state.selection.to)),Dt&&Ur<=11&&k.endB==k.start+1&&k.endA==k.start&&k.start>f.from&&f.doc.textBetween(k.start-f.from-1,k.start-f.from+1)=="  "&&(k.start--,k.endA--,k.endB--);let C=f.doc.resolveNoCache(k.start-f.from),v=f.doc.resolveNoCache(k.endB-f.from),S=h.resolve(k.start),L=C.sameParent(v)&&C.parent.inlineContent&&S.end()>=k.endA;if((Eo&&n.input.lastIOSEnter>Date.now()-225&&(!L||i.some(H=>H.nodeName=="DIV"||H.nodeName=="P"))||!L&&C.pos<f.doc.content.size&&(!C.sameParent(v)||!C.parent.inlineContent)&&C.pos<v.pos&&!/\S/.test(f.doc.textBetween(C.pos,v.pos,"","")))&&n.someProp("handleKeyDown",H=>H(n,bi(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>k.start&&vD(h,k.start,k.endA,C,v)&&n.someProp("handleKeyDown",H=>H(n,bi(8,"Backspace")))){kr&&ht&&n.domObserver.suppressSelectionUpdates();return}ht&&k.endB==k.start&&(n.input.lastChromeDelete=Date.now()),kr&&!L&&C.start()!=v.start()&&v.parentOffset==0&&C.depth==v.depth&&f.sel&&f.sel.anchor==f.sel.head&&f.sel.head==k.endA&&(k.endB-=2,v=f.doc.resolveNoCache(k.endB-f.from),setTimeout(()=>{n.someProp("handleKeyDown",function(H){return H(n,bi(13,"Enter"))})},20));let R=k.start,K=k.endA,q=H=>{let X=H||n.state.tr.replace(R,K,f.doc.slice(k.start-f.from,k.endB-f.from));if(f.sel){let te=oy(n,X.doc,f.sel);te&&!(ht&&n.composing&&te.empty&&(k.start!=k.endB||n.input.lastChromeDelete<Date.now()-100)&&(te.head==R||te.head==X.mapping.map(K)-1)||Dt&&te.empty&&te.head==R)&&X.setSelection(te)}return o&&X.setMeta("composition",o),X.scrollIntoView()},O;if(L)if(C.pos==v.pos){Dt&&Ur<=11&&C.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>xr(n),20));let H=q(n.state.tr.delete(R,K)),X=h.resolve(k.start).marksAcross(h.resolve(k.endA));X&&H.ensureMarks(X),n.dispatch(H)}else if(k.endA==k.endB&&(O=SD(C.parent.content.cut(C.parentOffset,v.parentOffset),S.parent.content.cut(S.parentOffset,k.endA-S.start())))){let H=q(n.state.tr);O.type=="add"?H.addMark(R,K,O.mark):H.removeMark(R,K,O.mark),n.dispatch(H)}else if(C.parent.child(C.index()).isText&&C.index()==v.index()-(v.textOffset?0:1)){let H=C.parent.textBetween(C.parentOffset,v.parentOffset),X=()=>q(n.state.tr.insertText(H,R,K));n.someProp("handleTextInput",te=>te(n,R,K,H,X))||n.dispatch(X())}else n.dispatch(q());else n.dispatch(q())}function oy(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:Hh(n,e.resolve(t.anchor),e.resolve(t.head))}function SD(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,i=t,o=r,s,a,u;for(let h=0;h<r.length;h++)i=r[h].removeFromSet(i);for(let h=0;h<t.length;h++)o=t[h].removeFromSet(o);if(i.length==1&&o.length==0)a=i[0],s="add",u=h=>h.mark(a.addToSet(h.marks));else if(i.length==0&&o.length==1)a=o[0],s="remove",u=h=>h.mark(a.removeFromSet(h.marks));else return null;let f=[];for(let h=0;h<e.childCount;h++)f.push(u(e.child(h)));if(W.from(f).eq(n))return{mark:a,type:s}}function vD(n,e,t,r,i){if(t-e<=i.pos-r.pos||pf(r,!0,!1)<i.pos)return!1;let o=n.resolve(e);if(!r.parent.isTextblock){let a=o.nodeAfter;return a!=null&&t==e+a.nodeSize}if(o.parentOffset<o.parent.content.size||!o.parent.isTextblock)return!1;let s=n.resolve(pf(o,!0,!0));return!s.parent.isTextblock||s.pos>t||pf(s,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(s.parent.content)}function pf(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 TD(n,e,t,r,i){let o=n.findDiffStart(e,t);if(o==null)return null;let{a:s,b:a}=n.findDiffEnd(e,t+n.size,t+e.size);if(i=="end"){let u=Math.max(0,o-Math.min(s,a));r-=s+u-o}if(s<o&&n.size<e.size){let u=r<=o&&r>=s?o-r:0;o-=u,o&&o<e.size&&sy(e.textBetween(o-1,o+1))&&(o+=u?1:-1),a=o+(a-s),s=o}else if(a<o){let u=r<=o&&r>=a?o-r:0;o-=u,o&&o<n.size&&sy(n.textBetween(o-1,o+1))&&(o+=u?1:-1),s=o+(s-a),a=o}return{start:o,endA:s,endB:a}}function sy(n){if(n.length!=2)return!1;let e=n.charCodeAt(0),t=n.charCodeAt(1);return e>=56320&&e<=57343&&t>=55296&&t<=56319}class Z0{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 W_,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(fy),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=uy(this),ay(this),this.nodeViews=cy(this),this.docView=Wg(this.state.doc,ly(this),df(this),this.dom,this),this.domObserver=new pD(this,(r,i,o,s)=>CD(this,r,i,o,s)),this.domObserver.start(),V_(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&&sh(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(fy),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&&(U0(this),s=!0),this.state=e;let a=i.plugins!=e.plugins||this._props.plugins!=t.plugins;if(a||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let g=cy(this);ND(g,this.nodeViews)&&(this.nodeViews=g,o=!0)}(a||t.handleDOMEvents!=this._props.handleDOMEvents)&&sh(this),this.editable=uy(this),ay(this);let u=df(this),f=ly(this),h=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",d=o||!this.docView.matchesNode(e.doc,f,u);(d||!e.selection.eq(i.selection))&&(s=!0);let m=h=="preserve"&&s&&this.dom.style.overflowAnchor==null&&n_(this);if(s){this.domObserver.stop();let g=d&&(Dt||ht)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&AD(i.selection,e.selection);if(d){let k=ht?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=nD(this)),(o||!this.docView.update(e.doc,f,u,this))&&(this.docView.updateOuterDeco(f),this.docView.destroy(),this.docView=Wg(e.doc,f,u,this.dom,this)),k&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(g=!0)}g||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&A_(this))?xr(this,g):(D0(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),h=="reset"?this.dom.scrollTop=0:h=="to selection"?this.scrollToSelection():m&&r_(m)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof ce){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Lg(this,t.getBoundingClientRect(),e)}else Lg(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 J0(e.slice,e.move,i<0?void 0:ce.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 a=this.directPlugins[s].props[e];if(a!=null&&(i=t?t(a):a))return i}let o=this.state.plugins;if(o)for(let s=0;s<o.length;s++){let a=o[s].props[e];if(a!=null&&(i=t?t(a):a))return i}}hasFocus(){if(Dt){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&&i_(this.dom),xr(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 u_(this,e)}coordsAtPos(e,t=1){return A0(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 p_(this,t||this.state,e)}pasteHTML(e,t){return Ts(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Ts(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return qh(this,e)}destroy(){this.docView&&(H_(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],df(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,UR())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return K_(this,e)}domSelectionRange(){let e=this.domSelection();return e?yt&&this.root.nodeType===11&&XR(this.dom.ownerDocument)==this.dom&&gD(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}Z0.prototype.dispatch=function(n){let e=this._props.dispatchTransaction;e?e.call(this,n):this.updateState(this.state.apply(n))};function ly(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"),[nt.node(0,n.state.doc.content.size,e)]}function ay(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:nt.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function uy(n){return!n.someProp("editable",e=>e(n.state)===!1)}function AD(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 cy(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 ND(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 fy(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 Vi(n,e){return n.meta={package:"@milkdown/core",group:"System",...e},n}var MD={text:(n,e,t,r)=>{const i=n.value;return/^[^*_\\]*\s+$/.test(i)?i:t.safe(i,{...r,encode:[]})},strong:(n,e,t,r)=>{const i=n.marker||t.options.strong||"*",o=t.enter("strong"),s=t.createTracker(r);let a=s.move(i+i);return a+=s.move(t.containerPhrasing(n,{before:a,after:i,...s.current()})),a+=s.move(i+i),o(),a},emphasis:(n,e,t,r)=>{const i=n.marker||t.options.emphasis||"*",o=t.enter("emphasis"),s=t.createTracker(r);let a=s.move(i);return a+=s.move(t.containerPhrasing(n,{before:a,after:i,...s.current()})),a+=s.move(i),o(),a}},xn=ae.createSlice({},"editorView"),as=ae.createSlice({},"editorState");ae.createSlice([],"initTimer");ae.createSlice({},"editor");var lh=ae.createSlice([],"inputRules"),Ns=ae.createSlice([],"prosePlugins"),ah=ae.createSlice([],"remarkPlugins"),ID=ae.createSlice([],"nodeView"),ED=ae.createSlice([],"markView"),Ra=ae.createSlice(sO().use(LI).use(WE),"remark"),ek=ae.createSlice({handlers:MD,encode:[]},"remarkStringifyOptions"),OD=ae.createTimer("ConfigReady"),Yh=ae.createTimer("InitReady"),en=ae.createTimer("SchemaReady"),mf=ae.createSlice([],"schemaTimer"),Gr=ae.createSlice({},"schema"),gs=ae.createSlice([],"nodes"),ys=ae.createSlice([],"marks");function hy(n){var e;return{...n,parseDOM:(e=n.parseDOM)==null?void 0:e.map(t=>({priority:n.priority,...t}))}}var RD=n=>(n.inject(Gr,{}).inject(gs,[]).inject(ys,[]).inject(mf,[Yh]).record(en),async()=>{await n.waitTimers(mf);const e=n.get(Ra),t=n.get(ah).reduce((i,o)=>i.use(o.plugin,o.options),e);n.set(Ra,t);const r=new _O({nodes:Object.fromEntries(n.get(gs).map(([i,o])=>[i,hy(o)])),marks:Object.fromEntries(n.get(ys).map(([i,o])=>[i,hy(o)]))});return n.set(Gr,r),n.done(en),()=>{n.remove(Gr).remove(gs).remove(ys).remove(mf).clearTimer(en)}});Vi(RD,{displayName:"Schema"});var xo,Rn,Jy,tk=(Jy=class{constructor(){xe(this,xo,new ae.Container);xe(this,Rn,null);this.setCtx=n=>{Ke(this,Rn,n)},this.chain=()=>{if(j(this,Rn)==null)throw Xc();const n=j(this,Rn),e=[],t=this.get.bind(this),r={run:()=>{const o=Lo(...e),s=n.get(xn);return o(s.state,s.dispatch,s)},inline:o=>(e.push(o),r),pipe:i.bind(this)};function i(o,s){const a=t(o);return e.push(a(s)),r}return r}}get ctx(){return j(this,Rn)}create(n,e){const t=n.create(j(this,xo).sliceMap);return t.set(e),t}get(n){return j(this,xo).get(n).get()}remove(n){return j(this,xo).remove(n)}call(n,e){if(j(this,Rn)==null)throw Xc();const t=this.get(n)(e),r=j(this,Rn).get(xn);return t(r.state,r.dispatch,r)}inline(n){if(j(this,Rn)==null)throw Xc();const e=j(this,Rn).get(xn);return n(e.state,e.dispatch,e)}},xo=new WeakMap,Rn=new WeakMap,Jy);function _D(n="cmdKey"){return ae.createSlice(()=>()=>!1,n)}var Pe=ae.createSlice(new tk,"commands"),gf=ae.createSlice([en],"commandsTimer"),ks=ae.createTimer("CommandsReady"),DD=n=>{const e=new tk;return e.setCtx(n),n.inject(Pe,e).inject(gf,[en]).record(ks),async()=>(await n.waitTimers(gf),n.done(ks),()=>{n.remove(Pe).remove(gf).clearTimer(ks)})};Vi(DD,{displayName:"Commands"});function LD(n){return n.Backspace=Lo(WR,Ph,pR,u0),n}var wo,Gt,Gy,PD=(Gy=class{constructor(){xe(this,wo,null);xe(this,Gt,[]);this.setCtx=n=>{Ke(this,wo,n)},this.add=n=>(j(this,Gt).push(n),()=>{Ke(this,Gt,j(this,Gt).filter(e=>e!==n))}),this.addObjectKeymap=n=>{const e=[];return Object.entries(n).forEach(([t,r])=>{if(typeof r=="function"){const i={key:t,onRun:()=>r};j(this,Gt).push(i),e.push(()=>{Ke(this,Gt,j(this,Gt).filter(o=>o!==i))})}else j(this,Gt).push(r),e.push(()=>{Ke(this,Gt,j(this,Gt).filter(i=>i!==r))})}),()=>{e.forEach(t=>t())}},this.addBaseKeymap=()=>{const n=LD(OR);return this.addObjectKeymap(n)},this.build=()=>{const n={};return j(this,Gt).forEach(e=>{n[e.key]=[...n[e.key]||[],e]}),Object.fromEntries(Object.entries(n).map(([e,t])=>{const r=t.sort((o,s)=>(s.priority??50)-(o.priority??50));return[e,(o,s,a)=>{const u=j(this,wo);if(u==null)throw Oh();return Lo(...r.map(f=>f.onRun(u)))(o,s,a)}]}))}}get ctx(){return j(this,wo)}},wo=new WeakMap,Gt=new WeakMap,Gy),nk=ae.createSlice(new PD,"keymap");ae.createSlice([en],"keymapTimer");var rk=ae.createTimer("KeymapReady"),ha=ae.createTimer("ParserReady"),ik=()=>{throw Oh()},go=ae.createSlice(ik,"parser"),yf=ae.createSlice([],"parserTimer"),BD=n=>(n.inject(go,ik).inject(yf,[en]).record(ha),async()=>{await n.waitTimers(yf);const e=n.get(Ra),t=n.get(Gr);return n.set(go,HR.create(t,e)),n.done(ha),()=>{n.remove(go).remove(yf).clearTimer(ha)}});Vi(BD,{displayName:"Parser"});var da=ae.createTimer("SerializerReady"),kf=ae.createSlice([],"serializerTimer"),ok=()=>{throw Oh()},bf=ae.createSlice(ok,"serializer"),FD=n=>(n.inject(bf,ok).inject(kf,[en]).record(da),async()=>{await n.waitTimers(kf);const e=n.get(Ra),t=n.get(Gr);return n.set(bf,KR.create(t,e)),n.done(da),()=>{n.remove(bf).remove(kf).clearTimer(da)}});Vi(FD,{displayName:"Serializer"});var xf=ae.createSlice("","defaultValue"),wf=ae.createSlice(n=>n,"stateOptions"),Cf=ae.createSlice([],"editorStateTimer"),pa=ae.createTimer("EditorStateReady");function zD(n,e,t){if(typeof n=="string")return e(n);if(n.type==="html")return Ao.fromSchema(t).parse(n.dom);if(n.type==="json")return br.fromJSON(t,n.value);throw fO(n)}var $D=new Bt("MILKDOWN_STATE_TRACKER"),WD=n=>(n.inject(xf,"").inject(as,{}).inject(wf,e=>e).inject(Cf,[ha,da,ks,rk]).record(pa),async()=>{await n.waitTimers(Cf);const e=n.get(Gr),t=n.get(go),r=n.get(lh),i=n.get(wf),o=n.get(Ns),s=zD(n.get(xf),t,e),a=n.get(nk),u=a.addBaseKeymap(),f=[...o,new Pt({key:$D,state:{init:()=>{},apply:(m,g,k,C)=>{n.set(as,C)}}}),nn.customInputRules({rules:r}),zR(a.build())];n.set(Ns,f);const h=i({schema:e,doc:s,plugins:f}),d=xi.create(h);return n.set(as,d),n.done(pa),()=>{u(),n.remove(xf).remove(as).remove(wf).remove(Cf).clearTimer(pa)}});Vi(WD,{displayName:"EditorState"});var Ms=ae.createSlice([],"pasteRule"),Sf=ae.createSlice([en],"pasteRuleTimer"),ma=ae.createTimer("PasteRuleReady"),VD=n=>(n.inject(Ms,[]).inject(Sf,[en]).record(ma),async()=>(await n.waitTimers(Sf),n.done(ma),()=>{n.remove(Ms).remove(Sf).clearTimer(ma)}));Vi(VD,{displayName:"PasteRule"});var ga=ae.createTimer("EditorViewReady"),vf=ae.createSlice([],"editorViewTimer"),Tf=ae.createSlice({},"editorViewOptions"),Af=ae.createSlice(null,"root"),uh=ae.createSlice(null,"rootDOM"),ch=ae.createSlice({},"rootAttrs");function HD(n,e){const t=document.createElement("div");t.className="milkdown",n.appendChild(t),e.set(uh,t);const r=e.get(ch);return Object.entries(r).forEach(([i,o])=>t.setAttribute(i,o)),t}function qD(n){n.classList.add("editor"),n.setAttribute("role","textbox")}var KD=new Bt("MILKDOWN_VIEW_CLEAR"),UD=n=>(n.inject(Af,document.body).inject(xn,{}).inject(Tf,{}).inject(uh,null).inject(ch,{}).inject(vf,[pa,ma]).record(ga),async()=>{await n.wait(Yh);const e=n.get(Af)||document.body,t=typeof e=="string"?document.querySelector(e):e;n.update(Ns,s=>[new Pt({key:KD,view:a=>{const u=t?HD(t,n):void 0;return(()=>{if(u&&t){const h=a.dom;t.replaceChild(u,h),u.appendChild(h)}})(),{destroy:()=>{u!=null&&u.parentNode&&(u==null||u.parentNode.replaceChild(a.dom,u)),u==null||u.remove()}}}}),...s]),await n.waitTimers(vf);const r=n.get(as),i=n.get(Tf),o=new Z0(t,{state:r,nodeViews:Object.fromEntries(n.get(ID)),markViews:Object.fromEntries(n.get(ED)),transformPasted:(s,a,u)=>(n.get(Ms).sort((f,h)=>(h.priority??50)-(f.priority??50)).map(f=>f.run).forEach(f=>{s=f(s,a,u)}),s),...i});return qD(o.dom),n.set(xn,o),n.done(ga),()=>{o==null||o.destroy(),n.remove(Af).remove(xn).remove(Tf).remove(uh).remove(ch).remove(vf).clearTimer(ga)}});Vi(UD,{displayName:"EditorView"});function fe(n,e){const t=_D(n),r=i=>async()=>{r.key=t,await i.wait(ks);const o=e(i);return i.get(Pe).create(t,o),r.run=s=>i.get(Pe).call(n,s),()=>{i.get(Pe).remove(t)}};return r}function Ft(n){const e=t=>async()=>{await t.wait(en);const r=n(t);return t.update(lh,i=>[...i,r]),e.inputRule=r,()=>{t.update(lh,i=>i.filter(o=>o!==r))}};return e}function jD(n){const e=t=>async()=>{await t.wait(en);const r=n(t);return t.update(Ms,i=>[...i,r]),e.pasteRule=r,()=>{t.update(Ms,i=>i.filter(o=>o!==r))}};return e}function JD(n,e){const t=r=>async()=>{const i=e(r);return r.update(ys,o=>[...o.filter(s=>s[0]!==n),[n,i]]),t.id=n,t.schema=i,()=>{r.update(ys,o=>o.filter(([s])=>s!==n))}};return t.type=r=>{const i=r.get(Gr).marks[n];if(!i)throw gO(n);return i},t}function Xh(n,e){const t=r=>async()=>{const i=e(r);return r.update(gs,o=>[...o.filter(s=>s[0]!==n),[n,i]]),t.id=n,t.schema=i,()=>{r.update(gs,o=>o.filter(([s])=>s!==n))}};return t.type=r=>{const i=r.get(Gr).nodes[n];if(!i)throw mO(n);return i},t}function Pn(n){let e;const t=r=>async()=>(await r.wait(en),e=n(r),r.update(Ns,i=>[...i,e]),()=>{r.update(Ns,i=>i.filter(o=>o!==e))});return t.plugin=()=>e,t.key=()=>e.spec.key,t}function GD(n){const e=t=>async()=>{await t.wait(rk);const r=t.get(nk),i=n(t),o=r.addObjectKeymap(i);return e.keymap=i,()=>{o()}};return e}function Sn(n,e){const t=ae.createSlice(n,e),r=i=>(i.inject(t),()=>()=>{i.remove(t)});return r.key=t,r}function rt(n,e){const t=Sn(e,n),r=Xh(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=>rt(n,o(e)),i}function Po(n,e){const t=Sn(e,n),r=JD(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=>Po(n,o(e)),i}function rn(n,e){const t=Sn(Object.fromEntries(Object.entries(e).map(([o,{shortcuts:s,priority:a}])=>[o,{shortcuts:s,priority:a}])),`${n}Keymap`),r=GD(o=>{const s=o.get(t.key),a=Object.entries(e).flatMap(([u,{command:f}])=>{const h=s[u],d=[h.shortcuts].flat(),m=h.priority;return d.map(g=>[g,{key:g,onRun:f,priority:m}])});return Object.fromEntries(a)}),i=[t,r];return i.ctx=t,i.shortcuts=r,i.key=t.key,i.keymap=r.keymap,i}var Bn=(n,e=()=>({}))=>Sn(e,`${n}Attr`),Xs=(n,e=()=>({}))=>Sn(e,`${n}Attr`);function Hi(n,e,t){const r=Sn({},n),i=s=>async()=>{await s.wait(Yh);const a={plugin:e(s),options:s.get(r.key)};return s.update(ah,u=>[...u,a]),()=>{s.update(ah,u=>u.filter(f=>f!==a))}},o=[r,i];return o.id=n,o.plugin=i,o.options=r,o}const fh={acceptButtonTitle:"Accept",rejectButtonTitle:"Reject"},hu=Sn(fh,"diffInlineConfig");function YD(n={}){return e=>{e.update(hu.key,t=>({...t,...n}))}}const qr=Sn({decorations:null},"diffDecorationState"),XD=Pn(n=>{const e=new Bt("MILKDOWN_DIFF_DECORATION");return n.inject(qr.key),new Pt({key:e,state:{init(){return $e.empty},apply(t,r){const i=n.get(qr.key).decorations;if(i&&i!==r)return n.set(qr.key,{decorations:i}),i;let o=r.map(t.mapping,t.doc);return n.set(qr.key,{decorations:o}),o}},props:{decorations(t){return this.getState(t)}}})});let hh,dh;if(typeof WeakMap<"u"){let n=new WeakMap;hh=e=>n.get(e),dh=(e,t)=>(n.set(e,t),t)}else{const n=[];let t=0;hh=r=>{for(let i=0;i<n.length;i+=2)if(n[i]==r)return n[i+1]},dh=(r,i)=>(t==10&&(t=0),n[t++]=r,n[t++]=i)}var Le=class{constructor(n,e,t,r){this.width=n,this.height=e,this.map=t,this.problems=r}findCell(n){for(let e=0;e<this.map.length;e++){const t=this.map[e];if(t!=n)continue;const r=e%this.width,i=e/this.width|0;let o=r+1,s=i+1;for(let a=1;o<this.width&&this.map[e+a]==t;a++)o++;for(let a=1;s<this.height&&this.map[e+this.width*a]==t;a++)s++;return{left:r,top:i,right:o,bottom:s}}throw new RangeError(`No cell with offset ${n} found`)}colCount(n){for(let e=0;e<this.map.length;e++)if(this.map[e]==n)return e%this.width;throw new RangeError(`No cell with offset ${n} found`)}nextCell(n,e,t){const{left:r,right:i,top:o,bottom:s}=this.findCell(n);return e=="horiz"?(t<0?r==0:i==this.width)?null:this.map[o*this.width+(t<0?r-1:i)]:(t<0?o==0:s==this.height)?null:this.map[r+this.width*(t<0?o-1:s)]}rectBetween(n,e){const{left:t,right:r,top:i,bottom:o}=this.findCell(n),{left:s,right:a,top:u,bottom:f}=this.findCell(e);return{left:Math.min(t,s),top:Math.min(i,u),right:Math.max(r,a),bottom:Math.max(o,f)}}cellsInRect(n){const e=[],t={};for(let r=n.top;r<n.bottom;r++)for(let i=n.left;i<n.right;i++){const o=r*this.width+i,s=this.map[o];t[s]||(t[s]=!0,!(i==n.left&&i&&this.map[o-1]==s||r==n.top&&r&&this.map[o-this.width]==s)&&e.push(s))}return e}positionAt(n,e,t){for(let r=0,i=0;;r++){const o=i+t.child(r).nodeSize;if(r==n){let s=e+n*this.width;const a=(n+1)*this.width;for(;s<a&&this.map[s]<i;)s++;return s==a?o-1:this.map[s]}i=o}}static get(n){return hh(n)||dh(n,QD(n))}};function QD(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);const e=ZD(n),t=n.childCount,r=[];let i=0,o=null;const s=[];for(let f=0,h=e*t;f<h;f++)r[f]=0;for(let f=0,h=0;f<t;f++){const d=n.child(f);h++;for(let k=0;;k++){for(;i<r.length&&r[i]!=0;)i++;if(k==d.childCount)break;const C=d.child(k),{colspan:v,rowspan:S,colwidth:L}=C.attrs;for(let R=0;R<S;R++){if(R+f>=t){(o||(o=[])).push({type:"overlong_rowspan",pos:h,n:S-R});break}const K=i+R*e;for(let q=0;q<v;q++){r[K+q]==0?r[K+q]=h:(o||(o=[])).push({type:"collision",row:f,pos:h,n:v-q});const O=L&&L[q];if(O){const H=(K+q)%e*2,X=s[H];X==null||X!=O&&s[H+1]==1?(s[H]=O,s[H+1]=1):X==O&&s[H+1]++}}}i+=v,h+=C.nodeSize}const m=(f+1)*e;let g=0;for(;i<m;)r[i++]==0&&g++;g&&(o||(o=[])).push({type:"missing",row:f,n:g}),h++}(e===0||t===0)&&(o||(o=[])).push({type:"zero_sized"});const a=new Le(e,t,r,o);let u=!1;for(let f=0;!u&&f<s.length;f+=2)s[f]!=null&&s[f+1]<t&&(u=!0);return u&&eL(a,s,n),a}function ZD(n){let e=-1,t=!1;for(let r=0;r<n.childCount;r++){const i=n.child(r);let o=0;if(t)for(let s=0;s<r;s++){const a=n.child(s);for(let u=0;u<a.childCount;u++){const f=a.child(u);s+f.attrs.rowspan>r&&(o+=f.attrs.colspan)}}for(let s=0;s<i.childCount;s++){const a=i.child(s);o+=a.attrs.colspan,a.attrs.rowspan>1&&(t=!0)}e==-1?e=o:e!=o&&(e=Math.max(e,o))}return e}function eL(n,e,t){n.problems||(n.problems=[]);const r={};for(let i=0;i<n.map.length;i++){const o=n.map[i];if(r[o])continue;r[o]=!0;const s=t.nodeAt(o);if(!s)throw new RangeError(`No cell with offset ${o} found`);let a=null;const u=s.attrs;for(let f=0;f<u.colspan;f++){const h=e[(i+f)%n.width*2];h!=null&&(!u.colwidth||u.colwidth[f]!=h)&&((a||(a=tL(u)))[f]=h)}a&&n.problems.unshift({type:"colwidth mismatch",pos:o,colwidth:a})}}function tL(n){if(n.colwidth)return n.colwidth.slice();const e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function dy(n,e){if(typeof n=="string")return{};const t=n.getAttribute("data-colwidth"),r=t&&/^\d+(,\d+)*$/.test(t)?t.split(",").map(s=>Number(s)):null,i=Number(n.getAttribute("colspan")||1),o={colspan:i,rowspan:Number(n.getAttribute("rowspan")||1),colwidth:r&&r.length==i?r:null};for(const s in e){const a=e[s].getFromDOM,u=a&&a(n);u!=null&&(o[s]=u)}return o}function py(n,e){const t={};n.attrs.colspan!=1&&(t.colspan=n.attrs.colspan),n.attrs.rowspan!=1&&(t.rowspan=n.attrs.rowspan),n.attrs.colwidth&&(t["data-colwidth"]=n.attrs.colwidth.join(","));for(const r in e){const i=e[r].setDOMAttr;i&&i(n.attrs[r],t)}return t}function nL(n){if(n!==null){if(!Array.isArray(n))throw new TypeError("colwidth must be null or an array");for(const e of n)if(typeof e!="number")throw new TypeError("colwidth must be null or an array of numbers")}}function rL(n){const e=n.cellAttributes||{},t={colspan:{default:1,validate:"number"},rowspan:{default:1,validate:"number"},colwidth:{default:null,validate:nL}};for(const r in e)t[r]={default:e[r].default,validate:e[r].validate};return{table:{content:"table_row+",tableRole:"table",isolating:!0,group:n.tableGroup,parseDOM:[{tag:"table"}],toDOM(){return["table",["tbody",0]]}},table_row:{content:"(table_cell | table_header)*",tableRole:"row",parseDOM:[{tag:"tr"}],toDOM(){return["tr",0]}},table_cell:{content:n.cellContent,attrs:t,tableRole:"cell",isolating:!0,parseDOM:[{tag:"td",getAttrs:r=>dy(r,e)}],toDOM(r){return["td",py(r,e),0]}},table_header:{content:n.cellContent,attrs:t,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:r=>dy(r,e)}],toDOM(r){return["th",py(r,e),0]}}}}function wn(n){let e=n.cached.tableNodeTypes;if(!e){e=n.cached.tableNodeTypes={};for(const t in n.nodes){const r=n.nodes[t],i=r.spec.tableRole;i&&(e[i]=r)}}return e}const Wr=new Bt("selectingCells");function Oo(n){for(let e=n.depth-1;e>0;e--)if(n.node(e).type.spec.tableRole=="row")return n.node(0).resolve(n.before(e+1));return null}function vn(n){const e=n.selection.$head;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return!0;return!1}function du(n){const e=n.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const t=Oo(e.$head)||iL(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function iL(n){for(let e=n.nodeAfter,t=n.pos;e;e=e.firstChild,t++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t)}for(let e=n.nodeBefore,t=n.pos;e;e=e.lastChild,t--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t-e.nodeSize)}}function ph(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function oL(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function Qh(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function sk(n,e,t){const r=n.node(-1),i=Le.get(r),o=n.start(-1),s=i.nextCell(n.pos-o,e,t);return s==null?null:n.node(0).resolve(o+s)}function zi(n,e,t=1){const r={...n,colspan:n.colspan-t};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,t),r.colwidth.some(i=>i>0)||(r.colwidth=null)),r}function sL(n,e,t=1){const r={...n,colspan:n.colspan+t};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let i=0;i<t;i++)r.colwidth.splice(e,0,0)}return r}function lL(n,e,t){const r=wn(e.type.schema).header_cell;for(let i=0;i<n.height;i++)if(e.nodeAt(n.map[t+i*n.width]).type!=r)return!1;return!0}var Ve=class dr extends de{constructor(e,t=e){const r=e.node(-1),i=Le.get(r),o=e.start(-1),s=i.rectBetween(e.pos-o,t.pos-o),a=e.node(0),u=i.cellsInRect(s).filter(h=>h!=t.pos-o);u.unshift(t.pos-o);const f=u.map(h=>{const d=r.nodeAt(h);if(!d)throw new RangeError(`No cell with offset ${h} found`);const m=o+h+1;return new i0(a.resolve(m),a.resolve(m+d.content.size))});super(f[0].$from,f[0].$to,f),this.$anchorCell=e,this.$headCell=t}map(e,t){const r=e.resolve(t.map(this.$anchorCell.pos)),i=e.resolve(t.map(this.$headCell.pos));if(ph(r)&&ph(i)&&Qh(r,i)){const o=this.$anchorCell.node(-1)!=r.node(-1);return o&&this.isRowSelection()?dr.rowSelection(r,i):o&&this.isColSelection()?dr.colSelection(r,i):new dr(r,i)}return pe.between(r,i)}content(){const e=this.$anchorCell.node(-1),t=Le.get(e),r=this.$anchorCell.start(-1),i=t.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),o={},s=[];for(let u=i.top;u<i.bottom;u++){const f=[];for(let h=u*t.width+i.left,d=i.left;d<i.right;d++,h++){const m=t.map[h];if(o[m])continue;o[m]=!0;const g=t.findCell(m);let k=e.nodeAt(m);if(!k)throw new RangeError(`No cell with offset ${m} found`);const C=i.left-g.left,v=g.right-i.right;if(C>0||v>0){let S=k.attrs;if(C>0&&(S=zi(S,0,C)),v>0&&(S=zi(S,S.colspan-v,v)),g.left<i.left){if(k=k.type.createAndFill(S),!k)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(S)}`)}else k=k.type.create(S,k.content)}if(g.top<i.top||g.bottom>i.bottom){const S={...k.attrs,rowspan:Math.min(g.bottom,i.bottom)-Math.max(g.top,i.top)};g.top<i.top?k=k.type.createAndFill(S):k=k.type.create(S,k.content)}f.push(k)}s.push(e.child(u).copy(W.from(f)))}const a=this.isColSelection()&&this.isRowSelection()?e:s;return new J(W.from(a),1,1)}replace(e,t=J.empty){const r=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){const{$from:a,$to:u}=i[s],f=e.mapping.slice(r);e.replace(f.map(a.pos),f.map(u.pos),s?J.empty:t)}const o=de.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);o&&e.setSelection(o)}replaceWith(e,t){this.replace(e,new J(W.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),r=Le.get(t),i=this.$anchorCell.start(-1),o=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-i,this.$headCell.pos-i));for(let s=0;s<o.length;s++)e(t.nodeAt(o[s]),i+o[s])}isColSelection(){const e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,i=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,i)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){const r=e.node(-1),i=Le.get(r),o=e.start(-1),s=i.findCell(e.pos-o),a=i.findCell(t.pos-o),u=e.node(0);return s.top<=a.top?(s.top>0&&(e=u.resolve(o+i.map[s.left])),a.bottom<i.height&&(t=u.resolve(o+i.map[i.width*(i.height-1)+a.right-1]))):(a.top>0&&(t=u.resolve(o+i.map[a.left])),s.bottom<i.height&&(e=u.resolve(o+i.map[i.width*(i.height-1)+s.right-1]))),new dr(e,t)}isRowSelection(){const e=this.$anchorCell.node(-1),t=Le.get(e),r=this.$anchorCell.start(-1),i=t.colCount(this.$anchorCell.pos-r),o=t.colCount(this.$headCell.pos-r);if(Math.min(i,o)>0)return!1;const s=i+this.$anchorCell.nodeAfter.attrs.colspan,a=o+this.$headCell.nodeAfter.attrs.colspan;return Math.max(s,a)==t.width}eq(e){return e instanceof dr&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){const r=e.node(-1),i=Le.get(r),o=e.start(-1),s=i.findCell(e.pos-o),a=i.findCell(t.pos-o),u=e.node(0);return s.left<=a.left?(s.left>0&&(e=u.resolve(o+i.map[s.top*i.width])),a.right<i.width&&(t=u.resolve(o+i.map[i.width*(a.top+1)-1]))):(a.left>0&&(t=u.resolve(o+i.map[a.top*i.width])),s.right<i.width&&(e=u.resolve(o+i.map[i.width*(s.top+1)-1]))),new dr(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new dr(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){return new dr(e.resolve(t),e.resolve(r))}getBookmark(){return new aL(this.$anchorCell.pos,this.$headCell.pos)}};Ve.prototype.visible=!1;de.jsonID("cell",Ve);var aL=class lk{constructor(e,t){this.anchor=e,this.head=t}map(e){return new lk(e.map(this.anchor),e.map(this.head))}resolve(e){const t=e.resolve(this.anchor),r=e.resolve(this.head);return t.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&t.index()<t.parent.childCount&&r.index()<r.parent.childCount&&Qh(t,r)?new Ve(t,r):de.near(r,1)}};function uL(n){if(!(n.selection instanceof Ve))return null;const e=[];return n.selection.forEachCell((t,r)=>{e.push(nt.node(r,r+t.nodeSize,{class:"selectedCell"}))}),$e.create(n.doc,e)}function cL({$from:n,$to:e}){if(n.pos==e.pos||n.pos<e.pos-6)return!1;let t=n.pos,r=e.pos,i=n.depth;for(;i>=0&&!(n.after(i+1)<n.end(i));i--,t++);for(let o=e.depth;o>=0&&!(e.before(o+1)>e.start(o));o--,r--);return t==r&&/row|table/.test(n.node(i).type.spec.tableRole)}function fL({$from:n,$to:e}){let t,r;for(let i=n.depth;i>0;i--){const o=n.node(i);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){t=o;break}}for(let i=e.depth;i>0;i--){const o=e.node(i);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){r=o;break}}return t!==r&&e.parentOffset===0}function hL(n,e,t){const r=(e||n).selection,i=(e||n).doc;let o,s;if(r instanceof ce&&(s=r.node.type.spec.tableRole)){if(s=="cell"||s=="header_cell")o=Ve.create(i,r.from);else if(s=="row"){const a=i.resolve(r.from+1);o=Ve.rowSelection(a,a)}else if(!t){const a=Le.get(r.node),u=r.from+1,f=u+a.map[a.width*a.height-1];o=Ve.create(i,u+1,f)}}else r instanceof pe&&cL(r)?o=pe.create(i,r.from):r instanceof pe&&fL(r)&&(o=pe.create(i,r.$from.start(),r.$from.end()));return o&&(e||(e=n.tr)).setSelection(o),e}const dL=new Bt("fix-tables");function ak(n,e,t,r){const i=n.childCount,o=e.childCount;e:for(let s=0,a=0;s<o;s++){const u=e.child(s);for(let f=a,h=Math.min(i,s+3);f<h;f++)if(n.child(f)==u){a=f+1,t+=u.nodeSize;continue e}r(u,t),a<i&&n.child(a).sameMarkup(u)?ak(n.child(a),u,t+1,r):u.nodesBetween(0,u.content.size,r,t+1),t+=u.nodeSize}}function pL(n,e){let t;const r=(i,o)=>{i.type.spec.tableRole=="table"&&(t=mL(n,i,o,t))};return e?e.doc!=n.doc&&ak(e.doc,n.doc,0,r):n.doc.descendants(r),t}function mL(n,e,t,r){const i=Le.get(e);if(!i.problems)return r;r||(r=n.tr);const o=[];for(let u=0;u<i.height;u++)o.push(0);for(let u=0;u<i.problems.length;u++){const f=i.problems[u];if(f.type=="collision"){const h=e.nodeAt(f.pos);if(!h)continue;const d=h.attrs;for(let m=0;m<d.rowspan;m++)o[f.row+m]+=f.n;r.setNodeMarkup(r.mapping.map(t+1+f.pos),null,zi(d,d.colspan-f.n,f.n))}else if(f.type=="missing")o[f.row]+=f.n;else if(f.type=="overlong_rowspan"){const h=e.nodeAt(f.pos);if(!h)continue;r.setNodeMarkup(r.mapping.map(t+1+f.pos),null,{...h.attrs,rowspan:h.attrs.rowspan-f.n})}else if(f.type=="colwidth mismatch"){const h=e.nodeAt(f.pos);if(!h)continue;r.setNodeMarkup(r.mapping.map(t+1+f.pos),null,{...h.attrs,colwidth:f.colwidth})}else if(f.type=="zero_sized"){const h=r.mapping.map(t);r.delete(h,h+e.nodeSize)}}let s,a;for(let u=0;u<o.length;u++)o[u]&&(s==null&&(s=u),a=u);for(let u=0,f=t+1;u<i.height;u++){const h=e.child(u),d=f+h.nodeSize,m=o[u];if(m>0){let g="cell";h.firstChild&&(g=h.firstChild.type.spec.tableRole);const k=[];for(let v=0;v<m;v++){const S=wn(n.schema)[g].createAndFill();S&&k.push(S)}const C=(u==0||s==u-1)&&a==u?f+1:d-1;r.insert(r.mapping.map(C),k)}f=d}return r.setMeta(dL,{fixTables:!0})}function uk(n){const e=Le.get(n),t=[],r=e.height,i=e.width;for(let o=0;o<r;o++){const s=[];for(let a=0;a<i;a++){const u=o*i+a,f=e.map[u];if(o>0){const h=u-i;if(f===e.map[h]){s.push(null);continue}}if(a>0){const h=u-1;if(f===e.map[h]){s.push(null);continue}}s.push(n.nodeAt(f))}t.push(s)}return t}function ck(n,e){const t=[],r=Le.get(n),i=r.height,o=r.width;for(let s=0;s<i;s++){const a=n.child(s),u=[];for(let h=0;h<o;h++){const d=e[s][h];if(!d)continue;const m=r.map[s*r.width+h],g=n.nodeAt(m);if(!g)continue;const k=g.type.createChecked(d.attrs,d.content,d.marks);u.push(k)}const f=a.type.createChecked(a.attrs,u,a.marks);t.push(f)}return n.type.createChecked(n.attrs,t,n.marks)}function fk(n,e,t,r){const i=e[0]>t[0]?-1:1,o=n.splice(e[0],e.length),s=o.length%2===0?1:0;let a;return a=i===-1?t[0]:t[t.length-1]-s,n.splice(a,0,...o),n}function Qs(n){return gL(e=>e.type.spec.tableRole==="table",n)}function gL(n,e){for(let t=e.depth;t>=0;t-=1){const r=e.node(t);if(n(r))return{node:r,pos:t===0?0:e.before(t),start:e.start(t),depth:t}}return null}function co(n,e){const t=Qs(e.$from);if(!t)return;const r=Le.get(t.node);if(!(n<0||n>r.width-1))return r.cellsInRect({left:n,right:n+1,top:0,bottom:r.height}).map(i=>{const o=t.node.nodeAt(i),s=i+t.start;return{pos:s,start:s+1,node:o,depth:t.depth+2}})}function fo(n,e){const t=Qs(e.$from);if(!t)return;const r=Le.get(t.node);if(!(n<0||n>r.height-1))return r.cellsInRect({left:0,right:r.width,top:n,bottom:n+1}).map(i=>{const o=t.node.nodeAt(i),s=i+t.start;return{pos:s,start:s+1,node:o,depth:t.depth+2}})}function my(n,e,t=e){let r=e,i=t;for(let h=e;h>=0;h--){const d=co(h,n.selection);d&&d.forEach(m=>{const g=m.node.attrs.colspan+h-1;g>=r&&(r=h),g>i&&(i=g)})}for(let h=e;h<=i;h++){const d=co(h,n.selection);d&&d.forEach(m=>{const g=m.node.attrs.colspan+h-1;m.node.attrs.colspan>1&&g>i&&(i=g)})}const o=[];for(let h=r;h<=i;h++){const d=co(h,n.selection);d&&d.length>0&&o.push(h)}r=o[0],i=o[o.length-1];const s=co(r,n.selection),a=fo(0,n.selection);if(!s||!a)return;const u=n.doc.resolve(s[s.length-1].pos);let f;for(let h=i;h>=r;h--){const d=co(h,n.selection);if(d&&d.length>0){for(let m=a.length-1;m>=0;m--)if(a[m].pos===d[0].pos){f=d[0];break}if(f)break}}if(f)return{$anchor:u,$head:n.doc.resolve(f.pos),indexes:o}}function gy(n,e,t=e){let r=e,i=t;for(let h=e;h>=0;h--){const d=fo(h,n.selection);d&&d.forEach(m=>{const g=m.node.attrs.rowspan+h-1;g>=r&&(r=h),g>i&&(i=g)})}for(let h=e;h<=i;h++){const d=fo(h,n.selection);d&&d.forEach(m=>{const g=m.node.attrs.rowspan+h-1;m.node.attrs.rowspan>1&&g>i&&(i=g)})}const o=[];for(let h=r;h<=i;h++){const d=fo(h,n.selection);d&&d.length>0&&o.push(h)}r=o[0],i=o[o.length-1];const s=fo(r,n.selection),a=co(0,n.selection);if(!s||!a)return;const u=n.doc.resolve(s[s.length-1].pos);let f;for(let h=i;h>=r;h--){const d=fo(h,n.selection);if(d&&d.length>0){for(let m=a.length-1;m>=0;m--)if(a[m].pos===d[0].pos){f=d[0];break}if(f)break}}if(f)return{$anchor:u,$head:n.doc.resolve(f.pos),indexes:o}}function yy(n){return n[0].map((e,t)=>n.map(r=>r[t]))}function yL(n){var e,t;const{tr:r,originIndex:i,targetIndex:o,select:s,pos:a}=n,u=Qs(r.doc.resolve(a));if(!u)return!1;const f=(e=my(r,i))===null||e===void 0?void 0:e.indexes,h=(t=my(r,o))===null||t===void 0?void 0:t.indexes;if(!f||!h||f.includes(o))return!1;const d=kL(u.node,f,h);if(r.replaceWith(u.pos,u.pos+u.node.nodeSize,d),!s)return!0;const m=Le.get(d),g=u.start,k=o,C=m.positionAt(m.height-1,k,d),v=r.doc.resolve(g+C),S=m.positionAt(0,k,d),L=r.doc.resolve(g+S);return r.setSelection(Ve.colSelection(v,L)),!0}function kL(n,e,t,r){let i=yy(uk(n));return i=fk(i,e,t),i=yy(i),ck(n,i)}function bL(n){var e,t;const{tr:r,originIndex:i,targetIndex:o,select:s,pos:a}=n,u=Qs(r.doc.resolve(a));if(!u)return!1;const f=(e=gy(r,i))===null||e===void 0?void 0:e.indexes,h=(t=gy(r,o))===null||t===void 0?void 0:t.indexes;if(!f||!h||f.includes(o))return!1;const d=xL(u.node,f,h);if(r.replaceWith(u.pos,u.pos+u.node.nodeSize,d),!s)return!0;const m=Le.get(d),g=u.start,k=o,C=m.positionAt(k,m.width-1,d),v=r.doc.resolve(g+C),S=m.positionAt(k,0,d),L=r.doc.resolve(g+S);return r.setSelection(Ve.rowSelection(v,L)),!0}function xL(n,e,t,r){let i=uk(n);return i=fk(i,e,t),ck(n,i)}function ti(n){const e=n.selection,t=du(n),r=t.node(-1),i=t.start(-1),o=Le.get(r);return{...e instanceof Ve?o.rectBetween(e.$anchorCell.pos-i,e.$headCell.pos-i):o.findCell(t.pos-i),tableStart:i,map:o,table:r}}function hk(n,{map:e,tableStart:t,table:r},i){let o=i>0?-1:0;lL(e,r,i+o)&&(o=i==0||i==e.width?null:0);for(let s=0;s<e.height;s++){const a=s*e.width+i;if(i>0&&i<e.width&&e.map[a-1]==e.map[a]){const u=e.map[a],f=r.nodeAt(u);n.setNodeMarkup(n.mapping.map(t+u),null,sL(f.attrs,i-e.colCount(u))),s+=f.attrs.rowspan-1}else{const u=o==null?wn(r.type.schema).cell:r.nodeAt(e.map[a+o]).type,f=e.positionAt(s,i,r);n.insert(n.mapping.map(t+f),u.createAndFill())}}return n}function wL(n,e){if(!vn(n))return!1;if(e){const t=ti(n);e(hk(n.tr,t,t.left))}return!0}function CL(n,e){if(!vn(n))return!1;if(e){const t=ti(n);e(hk(n.tr,t,t.right))}return!0}function SL(n,{map:e,table:t,tableStart:r},i){const o=n.mapping.maps.length;for(let s=0;s<e.height;){const a=s*e.width+i,u=e.map[a],f=t.nodeAt(u),h=f.attrs;if(i>0&&e.map[a-1]==u||i<e.width-1&&e.map[a+1]==u)n.setNodeMarkup(n.mapping.slice(o).map(r+u),null,zi(h,i-e.colCount(u)));else{const d=n.mapping.slice(o).map(r+u);n.delete(d,d+f.nodeSize)}s+=h.rowspan}}function vL(n,e){if(!vn(n))return!1;if(e){const t=ti(n),r=n.tr;if(t.left==0&&t.right==t.map.width)return!1;for(let i=t.right-1;SL(r,t,i),i!=t.left;i--){const o=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc;if(!o)throw new RangeError("No table found");t.table=o,t.map=Le.get(o)}e(r)}return!0}function TL(n,{map:e,table:t,tableStart:r},i){let o=0;for(let f=0;f<i;f++)o+=t.child(f).nodeSize;const s=o+t.child(i).nodeSize,a=n.mapping.maps.length;n.delete(o+r,s+r);const u=new Set;for(let f=0,h=i*e.width;f<e.width;f++,h++){const d=e.map[h];if(!u.has(d)){if(u.add(d),i>0&&d==e.map[h-e.width]){const m=t.nodeAt(d).attrs;n.setNodeMarkup(n.mapping.slice(a).map(d+r),null,{...m,rowspan:m.rowspan-1}),f+=m.colspan-1}else if(i<e.height&&d==e.map[h+e.width]){const m=t.nodeAt(d),g=m.attrs,k=m.type.create({...g,rowspan:m.attrs.rowspan-1},m.content),C=e.positionAt(i+1,f,t);n.insert(n.mapping.slice(a).map(r+C),k),f+=g.colspan-1}}}}function AL(n,e){if(!vn(n))return!1;if(e){const t=ti(n),r=n.tr;if(t.top==0&&t.bottom==t.map.height)return!1;for(let i=t.bottom-1;TL(r,t,i),i!=t.top;i--){const o=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc;if(!o)throw new RangeError("No table found");t.table=o,t.map=Le.get(t.table)}e(r)}return!0}function NL(n,e){return function(t,r){if(!vn(t))return!1;const i=du(t);if(i.nodeAfter.attrs[n]===e)return!1;if(r){const o=t.tr;t.selection instanceof Ve?t.selection.forEachCell((s,a)=>{s.attrs[n]!==e&&o.setNodeMarkup(a,null,{...s.attrs,[n]:e})}):o.setNodeMarkup(i.pos,null,{...i.nodeAfter.attrs,[n]:e}),r(o)}return!0}}function ML(n){return function(e,t){if(!vn(e))return!1;if(t){const r=wn(e.schema),i=ti(e),o=e.tr,s=i.map.cellsInRect(n=="column"?{left:i.left,top:0,right:i.right,bottom:i.map.height}:n=="row"?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),a=s.map(u=>i.table.nodeAt(u));for(let u=0;u<s.length;u++)a[u].type==r.header_cell&&o.setNodeMarkup(i.tableStart+s[u],r.cell,a[u].attrs);if(o.steps.length===0)for(let u=0;u<s.length;u++)o.setNodeMarkup(i.tableStart+s[u],r.header_cell,a[u].attrs);t(o)}return!0}}function ky(n,e,t){const r=e.map.cellsInRect({left:0,top:0,right:n=="row"?e.map.width:1,bottom:n=="column"?e.map.height:1});for(let i=0;i<r.length;i++){const o=e.table.nodeAt(r[i]);if(o&&o.type!==t.header_cell)return!1}return!0}function Zh(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?ML(n):function(t,r){if(!vn(t))return!1;if(r){const i=wn(t.schema),o=ti(t),s=t.tr,a=ky("row",o,i),u=ky("column",o,i),f=(n==="column"?a:n==="row"&&u)?1:0,h=n=="column"?{left:0,top:f,right:1,bottom:o.map.height}:n=="row"?{left:f,top:0,right:o.map.width,bottom:1}:o,d=n=="column"?u?i.cell:i.header_cell:n=="row"?a?i.cell:i.header_cell:i.cell;o.map.cellsInRect(h).forEach(m=>{const g=m+o.tableStart,k=s.doc.nodeAt(g);k&&s.setNodeMarkup(g,d,k.attrs)}),r(s)}return!0}}Zh("row",{useDeprecatedLogic:!0});Zh("column",{useDeprecatedLogic:!0});Zh("cell",{useDeprecatedLogic:!0});function IL(n,e){if(e<0){const t=n.nodeBefore;if(t)return n.pos-t.nodeSize;for(let r=n.index(-1)-1,i=n.before();r>=0;r--){const o=n.node(-1).child(r),s=o.lastChild;if(s)return i-1-s.nodeSize;i-=o.nodeSize}}else{if(n.index()<n.parent.childCount-1)return n.pos+n.nodeAfter.nodeSize;const t=n.node(-1);for(let r=n.indexAfter(-1),i=n.after();r<t.childCount;r++){const o=t.child(r);if(o.childCount)return i+1;i+=o.nodeSize}}return null}function dk(n){return function(e,t){if(!vn(e))return!1;const r=IL(du(e),n);if(r==null)return!1;if(t){const i=e.doc.resolve(r);t(e.tr.setSelection(pe.between(i,oL(i))).scrollIntoView())}return!0}}function EL(n,e){const t=n.selection.$anchor;for(let r=t.depth;r>0;r--)if(t.node(r).type.spec.tableRole=="table")return e&&e(n.tr.delete(t.before(r),t.after(r)).scrollIntoView()),!0;return!1}function ra(n,e){const t=n.selection;if(!(t instanceof Ve))return!1;if(e){const r=n.tr,i=wn(n.schema).cell.createAndFill().content;t.forEachCell((o,s)=>{o.content.eq(i)||r.replace(r.mapping.map(s+1),r.mapping.map(s+o.nodeSize-1),new J(i,0,0))}),r.docChanged&&e(r)}return!0}function OL(n){return(e,t)=>{const{from:r,to:i,select:o=!0,pos:s=e.selection.from}=n,a=e.tr;return bL({tr:a,originIndex:r,targetIndex:i,select:o,pos:s})?(t==null||t(a),!0):!1}}function RL(n){return(e,t)=>{const{from:r,to:i,select:o=!0,pos:s=e.selection.from}=n,a=e.tr;return yL({tr:a,originIndex:r,targetIndex:i,select:o,pos:s})?(t==null||t(a),!0):!1}}function _L(n){if(n.size===0)return null;let{content:e,openStart:t,openEnd:r}=n;for(;e.childCount==1&&(t>0&&r>0||e.child(0).type.spec.tableRole=="table");)t--,r--,e=e.child(0).content;const i=e.child(0),o=i.type.spec.tableRole,s=i.type.schema,a=[];if(o=="row")for(let u=0;u<e.childCount;u++){let f=e.child(u).content;const h=u?0:Math.max(0,t-1),d=u<e.childCount-1?0:Math.max(0,r-1);(h||d)&&(f=mh(wn(s).row,new J(f,h,d)).content),a.push(f)}else if(o=="cell"||o=="header_cell")a.push(t||r?mh(wn(s).row,new J(e,t,r)).content:e);else return null;return DL(s,a)}function DL(n,e){const t=[];for(let i=0;i<e.length;i++){const o=e[i];for(let s=o.childCount-1;s>=0;s--){const{rowspan:a,colspan:u}=o.child(s).attrs;for(let f=i;f<i+a;f++)t[f]=(t[f]||0)+u}}let r=0;for(let i=0;i<t.length;i++)r=Math.max(r,t[i]);for(let i=0;i<t.length;i++)if(i>=e.length&&e.push(W.empty),t[i]<r){const o=wn(n).cell.createAndFill(),s=[];for(let a=t[i];a<r;a++)s.push(o);e[i]=e[i].append(W.from(s))}return{height:e.length,width:r,rows:e}}function mh(n,e){const t=n.createAndFill();return new r0(t).replace(0,t.content.size,e).doc}function LL({width:n,height:e,rows:t},r,i){if(n!=r){const o=[],s=[];for(let a=0;a<t.length;a++){const u=t[a],f=[];for(let h=o[a]||0,d=0;h<r;d++){let m=u.child(d%u.childCount);h+m.attrs.colspan>r&&(m=m.type.createChecked(zi(m.attrs,m.attrs.colspan,h+m.attrs.colspan-r),m.content)),f.push(m),h+=m.attrs.colspan;for(let g=1;g<m.attrs.rowspan;g++)o[a+g]=(o[a+g]||0)+m.attrs.colspan}s.push(W.from(f))}t=s,n=r}if(e!=i){const o=[];for(let s=0,a=0;s<i;s++,a++){const u=[],f=t[a%e];for(let h=0;h<f.childCount;h++){let d=f.child(h);s+d.attrs.rowspan>i&&(d=d.type.create({...d.attrs,rowspan:Math.max(1,i-d.attrs.rowspan)},d.content)),u.push(d)}o.push(W.from(u))}t=o,e=i}return{width:n,height:e,rows:t}}function PL(n,e,t,r,i,o,s){const a=n.doc.type.schema,u=wn(a);let f,h;if(i>e.width)for(let d=0,m=0;d<e.height;d++){const g=t.child(d);m+=g.nodeSize;const k=[];let C;g.lastChild==null||g.lastChild.type==u.cell?C=f||(f=u.cell.createAndFill()):C=h||(h=u.header_cell.createAndFill());for(let v=e.width;v<i;v++)k.push(C);n.insert(n.mapping.slice(s).map(m-1+r),k)}if(o>e.height){const d=[];for(let k=0,C=(e.height-1)*e.width;k<Math.max(e.width,i);k++){const v=k>=e.width?!1:t.nodeAt(e.map[C+k]).type==u.header_cell;d.push(v?h||(h=u.header_cell.createAndFill()):f||(f=u.cell.createAndFill()))}const m=u.row.create(null,W.from(d)),g=[];for(let k=e.height;k<o;k++)g.push(m);n.insert(n.mapping.slice(s).map(r+t.nodeSize-2),g)}return!!(f||h)}function by(n,e,t,r,i,o,s,a){if(s==0||s==e.height)return!1;let u=!1;for(let f=i;f<o;f++){const h=s*e.width+f,d=e.map[h];if(e.map[h-e.width]==d){u=!0;const m=t.nodeAt(d),{top:g,left:k}=e.findCell(d);n.setNodeMarkup(n.mapping.slice(a).map(d+r),null,{...m.attrs,rowspan:s-g}),n.insert(n.mapping.slice(a).map(e.positionAt(s,k,t)),m.type.createAndFill({...m.attrs,rowspan:g+m.attrs.rowspan-s})),f+=m.attrs.colspan-1}}return u}function xy(n,e,t,r,i,o,s,a){if(s==0||s==e.width)return!1;let u=!1;for(let f=i;f<o;f++){const h=f*e.width+s,d=e.map[h];if(e.map[h-1]==d){u=!0;const m=t.nodeAt(d),g=e.colCount(d),k=n.mapping.slice(a).map(d+r);n.setNodeMarkup(k,null,zi(m.attrs,s-g,m.attrs.colspan-(s-g))),n.insert(k+m.nodeSize,m.type.createAndFill(zi(m.attrs,0,s-g))),f+=m.attrs.rowspan-1}}return u}function wy(n,e,t,r,i){let o=t?n.doc.nodeAt(t-1):n.doc;if(!o)throw new Error("No table found");let s=Le.get(o);const{top:a,left:u}=r,f=u+i.width,h=a+i.height,d=n.tr;let m=0;function g(){if(o=t?d.doc.nodeAt(t-1):d.doc,!o)throw new Error("No table found");s=Le.get(o),m=d.mapping.maps.length}PL(d,s,o,t,f,h,m)&&g(),by(d,s,o,t,u,f,a,m)&&g(),by(d,s,o,t,u,f,h,m)&&g(),xy(d,s,o,t,a,h,u,m)&&g(),xy(d,s,o,t,a,h,f,m)&&g();for(let k=a;k<h;k++){const C=s.positionAt(k,u,o),v=s.positionAt(k,f,o);d.replace(d.mapping.slice(m).map(C+t),d.mapping.slice(m).map(v+t),new J(i.rows[k-a],0,0))}g(),d.setSelection(new Ve(d.doc.resolve(t+s.positionAt(a,u,o)),d.doc.resolve(t+s.positionAt(h-1,f-1,o)))),e(d)}const BL=p0({ArrowLeft:ia("horiz",-1),ArrowRight:ia("horiz",1),ArrowUp:ia("vert",-1),ArrowDown:ia("vert",1),"Shift-ArrowLeft":oa("horiz",-1),"Shift-ArrowRight":oa("horiz",1),"Shift-ArrowUp":oa("vert",-1),"Shift-ArrowDown":oa("vert",1),Backspace:ra,"Mod-Backspace":ra,Delete:ra,"Mod-Delete":ra});function ya(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function ia(n,e){return(t,r,i)=>{if(!i)return!1;const o=t.selection;if(o instanceof Ve)return ya(t,r,de.near(o.$headCell,e));if(n!="horiz"&&!o.empty)return!1;const s=pk(i,n,e);if(s==null)return!1;if(n=="horiz")return ya(t,r,de.near(t.doc.resolve(o.head+e),e));{const a=t.doc.resolve(s),u=sk(a,n,e);let f;return u?f=de.near(u,1):e<0?f=de.near(t.doc.resolve(a.before(-1)),-1):f=de.near(t.doc.resolve(a.after(-1)),1),ya(t,r,f)}}}function oa(n,e){return(t,r,i)=>{if(!i)return!1;const o=t.selection;let s;if(o instanceof Ve)s=o;else{const u=pk(i,n,e);if(u==null)return!1;s=new Ve(t.doc.resolve(u))}const a=sk(s.$headCell,n,e);return a?ya(t,r,new Ve(s.$anchorCell,a)):!1}}function FL(n,e){const t=n.state.doc,r=Oo(t.resolve(e));return r?(n.dispatch(n.state.tr.setSelection(new Ve(r))),!0):!1}function zL(n,e,t){if(!vn(n.state))return!1;let r=_L(t);const i=n.state.selection;if(i instanceof Ve){r||(r={width:1,height:1,rows:[W.from(mh(wn(n.state.schema).cell,t))]});const o=i.$anchorCell.node(-1),s=i.$anchorCell.start(-1),a=Le.get(o).rectBetween(i.$anchorCell.pos-s,i.$headCell.pos-s);return r=LL(r,a.right-a.left,a.bottom-a.top),wy(n.state,n.dispatch,s,a,r),!0}else if(r){const o=du(n.state),s=o.start(-1);return wy(n.state,n.dispatch,s,Le.get(o.node(-1)).findCell(o.pos-s),r),!0}else return!1}function $L(n,e){var t;if(e.button!=0||e.ctrlKey||e.metaKey)return;const r=Cy(n,e.target);let i;if(e.shiftKey&&n.state.selection instanceof Ve)o(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(i=Oo(n.state.selection.$anchor))!=null&&((t=Nf(n,e))===null||t===void 0?void 0:t.pos)!=i.pos)o(i,e),e.preventDefault();else if(!r)return;function o(u,f){let h=Nf(n,f);const d=Wr.getState(n.state)==null;if(!h||!Qh(u,h))if(d)h=u;else return;const m=new Ve(u,h);if(d||!n.state.selection.eq(m)){const g=n.state.tr.setSelection(m);d&&g.setMeta(Wr,u.pos),n.dispatch(g)}}function s(){n.root.removeEventListener("mouseup",s),n.root.removeEventListener("dragstart",s),n.root.removeEventListener("mousemove",a),Wr.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(Wr,-1))}function a(u){const f=u,h=Wr.getState(n.state);let d;if(h!=null)d=n.state.doc.resolve(h);else if(Cy(n,f.target)!=r&&(d=Nf(n,e),!d))return s();d&&o(d,f)}n.root.addEventListener("mouseup",s),n.root.addEventListener("dragstart",s),n.root.addEventListener("mousemove",a)}function pk(n,e,t){if(!(n.state.selection instanceof pe))return null;const{$head:r}=n.state.selection;for(let i=r.depth-1;i>=0;i--){const o=r.node(i);if((t<0?r.index(i):r.indexAfter(i))!=(t<0?0:o.childCount))return null;if(o.type.spec.tableRole=="cell"||o.type.spec.tableRole=="header_cell"){const s=r.before(i),a=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(a)?s:null}}return null}function Cy(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Nf(n,e){const t=n.posAtCoords({left:e.clientX,top:e.clientY});if(!t)return null;let{inside:r,pos:i}=t;return r>=0&&Oo(n.state.doc.resolve(r))||Oo(n.state.doc.resolve(i))}var WL=class{constructor(n,e){this.node=n,this.defaultCellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${e}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),gh(n,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(n){return n.type!=this.node.type?!1:(this.node=n,gh(n,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(n){return n.type=="attributes"&&(n.target==this.table||this.colgroup.contains(n.target))}};function gh(n,e,t,r,i,o){let s=0,a=!0,u=e.firstChild;const f=n.firstChild;if(f){for(let d=0,m=0;d<f.childCount;d++){const{colspan:g,colwidth:k}=f.child(d).attrs;for(let C=0;C<g;C++,m++){const v=i==m?o:k&&k[C],S=v?v+"px":"";if(s+=v||r,v||(a=!1),u)u.style.width!=S&&(u.style.width=S),u=u.nextSibling;else{const L=document.createElement("col");L.style.width=S,e.appendChild(L)}}}for(;u;){var h;const d=u.nextSibling;(h=u.parentNode)===null||h===void 0||h.removeChild(u),u=d}a?(t.style.width=s+"px",t.style.minWidth=""):(t.style.width="",t.style.minWidth=s+"px")}}const Xt=new Bt("tableColumnResizing");function VL({handleWidth:n=5,cellMinWidth:e=25,defaultCellMinWidth:t=100,View:r=WL,lastColumnResizable:i=!0}={}){const o=new Pt({key:Xt,state:{init(s,a){var u;const f=(u=o.spec)===null||u===void 0||(u=u.props)===null||u===void 0?void 0:u.nodeViews,h=wn(a.schema).table.name;return r&&f&&(f[h]=(d,m)=>new r(d,t,m)),new HL(-1,!1)},apply(s,a){return a.apply(s)}},props:{attributes:s=>{const a=Xt.getState(s);return a&&a.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(s,a)=>{qL(s,a,n,i)},mouseleave:s=>{KL(s)},mousedown:(s,a)=>{UL(s,a,e,t)}},decorations:s=>{const a=Xt.getState(s);if(a&&a.activeHandle>-1)return XL(s,a.activeHandle)},nodeViews:{}}});return o}var HL=class ka{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){const t=this,r=e.getMeta(Xt);if(r&&r.setHandle!=null)return new ka(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new ka(t.activeHandle,r.setDragging);if(t.activeHandle>-1&&e.docChanged){let i=e.mapping.map(t.activeHandle,-1);return ph(e.doc.resolve(i))||(i=-1),new ka(i,t.dragging)}return t}};function qL(n,e,t,r){if(!n.editable)return;const i=Xt.getState(n.state);if(i&&!i.dragging){const o=JL(e.target);let s=-1;if(o){const{left:a,right:u}=o.getBoundingClientRect();e.clientX-a<=t?s=Sy(n,e,"left",t):u-e.clientX<=t&&(s=Sy(n,e,"right",t))}if(s!=i.activeHandle){if(!r&&s!==-1){const a=n.state.doc.resolve(s),u=a.node(-1),f=Le.get(u),h=a.start(-1);if(f.colCount(a.pos-h)+a.nodeAfter.attrs.colspan-1==f.width-1)return}mk(n,s)}}}function KL(n){if(!n.editable)return;const e=Xt.getState(n.state);e&&e.activeHandle>-1&&!e.dragging&&mk(n,-1)}function UL(n,e,t,r){var i;if(!n.editable)return!1;const o=(i=n.dom.ownerDocument.defaultView)!==null&&i!==void 0?i:window,s=Xt.getState(n.state);if(!s||s.activeHandle==-1||s.dragging)return!1;const a=n.state.doc.nodeAt(s.activeHandle),u=jL(n,s.activeHandle,a.attrs);n.dispatch(n.state.tr.setMeta(Xt,{setDragging:{startX:e.clientX,startWidth:u}}));function f(d){o.removeEventListener("mouseup",f),o.removeEventListener("mousemove",h);const m=Xt.getState(n.state);m!=null&&m.dragging&&(GL(n,m.activeHandle,vy(m.dragging,d,t)),n.dispatch(n.state.tr.setMeta(Xt,{setDragging:null})))}function h(d){if(!d.which)return f(d);const m=Xt.getState(n.state);if(m&&m.dragging){const g=vy(m.dragging,d,t);Ty(n,m.activeHandle,g,r)}}return Ty(n,s.activeHandle,u,r),o.addEventListener("mouseup",f),o.addEventListener("mousemove",h),e.preventDefault(),!0}function jL(n,e,{colspan:t,colwidth:r}){const i=r&&r[r.length-1];if(i)return i;const o=n.domAtPos(e);let s=o.node.childNodes[o.offset].offsetWidth,a=t;if(r)for(let u=0;u<t;u++)r[u]&&(s-=r[u],a--);return s/a}function JL(n){for(;n&&n.nodeName!="TD"&&n.nodeName!="TH";)n=n.classList&&n.classList.contains("ProseMirror")?null:n.parentNode;return n}function Sy(n,e,t,r){const i=t=="right"?-r:r,o=n.posAtCoords({left:e.clientX+i,top:e.clientY});if(!o)return-1;const{pos:s}=o,a=Oo(n.state.doc.resolve(s));if(!a)return-1;if(t=="right")return a.pos;const u=Le.get(a.node(-1)),f=a.start(-1),h=u.map.indexOf(a.pos-f);return h%u.width==0?-1:f+u.map[h-1]}function vy(n,e,t){const r=e.clientX-n.startX;return Math.max(t,n.startWidth+r)}function mk(n,e){n.dispatch(n.state.tr.setMeta(Xt,{setHandle:e}))}function GL(n,e,t){const r=n.state.doc.resolve(e),i=r.node(-1),o=Le.get(i),s=r.start(-1),a=o.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1,u=n.state.tr;for(let f=0;f<o.height;f++){const h=f*o.width+a;if(f&&o.map[h]==o.map[h-o.width])continue;const d=o.map[h],m=i.nodeAt(d).attrs,g=m.colspan==1?0:a-o.colCount(d);if(m.colwidth&&m.colwidth[g]==t)continue;const k=m.colwidth?m.colwidth.slice():YL(m.colspan);k[g]=t,u.setNodeMarkup(s+d,null,{...m,colwidth:k})}u.docChanged&&n.dispatch(u)}function Ty(n,e,t,r){const i=n.state.doc.resolve(e),o=i.node(-1),s=i.start(-1),a=Le.get(o).colCount(i.pos-s)+i.nodeAfter.attrs.colspan-1;let u=n.domAtPos(i.start(-1)).node;for(;u&&u.nodeName!="TABLE";)u=u.parentNode;u&&gh(o,u.firstChild,u,r,a,t)}function YL(n){return Array(n).fill(0)}function XL(n,e){const t=[],r=n.doc.resolve(e),i=r.node(-1);if(!i)return $e.empty;const o=Le.get(i),s=r.start(-1),a=o.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1;for(let f=0;f<o.height;f++){const h=a+f*o.width;if((a==o.width-1||o.map[h]!=o.map[h+1])&&(f==0||o.map[h]!=o.map[h-o.width])){var u;const d=o.map[h],m=s+d+i.nodeAt(d).nodeSize-1,g=document.createElement("div");g.className="column-resize-handle",!((u=Xt.getState(n))===null||u===void 0)&&u.dragging&&t.push(nt.node(s+d,s+d+i.nodeAt(d).nodeSize,{class:"column-resize-dragging"})),t.push(nt.widget(m,g))}}return $e.create(n.doc,t)}function QL({allowTableNodeSelection:n=!1}={}){return new Pt({key:Wr,state:{init(){return null},apply(e,t){const r=e.getMeta(Wr);if(r!=null)return r==-1?null:r;if(t==null||!e.docChanged)return t;const{deleted:i,pos:o}=e.mapping.mapResult(t);return i?null:o}},props:{decorations:uL,handleDOMEvents:{mousedown:$L},createSelectionBetween(e){return Wr.getState(e.state)!=null?e.state.selection:null},handleTripleClick:FL,handleKeyDown:BL,handlePaste:zL},appendTransaction(e,t,r){return hL(r,pL(r,t),n)}})}function ZL(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 a=i.node(-1);if(a.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 d=W.empty,m=i.index(-1)?1:i.index(-2)?2:3;for(let S=i.depth-m;S>=i.depth-3;S--)d=W.from(i.node(S).copy(d));let g=i.indexAfter(-1)<i.node(-2).childCount?1:i.indexAfter(-2)<i.node(-3).childCount?2:3;d=d.append(W.from(n.createAndFill()));let k=i.before(i.depth-(m-1)),C=t.tr.replace(k,i.after(-g),new J(d,4-m,0)),v=-1;C.doc.nodesBetween(k,C.doc.content.size,(S,L)=>{if(v>-1)return!1;S.isTextblock&&S.content.size==0&&(v=L+1)}),v>-1&&C.setSelection(de.near(C.doc.resolve(v))),r(C.scrollIntoView())}return!0}let u=o.pos==i.end()?a.contentMatchAt(0).defaultType:null,f=t.tr.delete(i.pos,o.pos),h=u?[null,{type:u}]:void 0;return ds(f.doc,i.pos,2,h)?(r&&r(f.split(i.pos,2,h).scrollIntoView()),!0):!1}}function eP(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?tP(e,t,n,o):nP(e,t,o):!0:!1}}function tP(n,e,t,r){let i=n.tr,o=r.end,s=r.$to.end(r.depth);o<s&&(i.step(new gt(o-1,s,o,s,new J(W.from(t.create(null,r.parent.copy())),1,0),1,!0)),r=new L1(i.doc.resolve(r.$from.pos),i.doc.resolve(s),r.depth));const a=iu(r);if(a==null)return!1;i.lift(r,a);let u=i.doc.resolve(i.mapping.map(o,-1)-1);return ou(i.doc,u.pos)&&u.nodeBefore.type==u.nodeAfter.type&&i.join(u.pos),e(i.scrollIntoView()),!0}function nP(n,e,t){let r=n.tr,i=t.parent;for(let g=t.end,k=t.endIndex-1,C=t.startIndex;k>C;k--)g-=i.child(k).nodeSize,r.delete(g-1,g+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 a=t.startIndex==0,u=t.endIndex==i.childCount,f=o.node(-1),h=o.index(-1);if(!f.canReplace(h+(a?0:1),h+1,s.content.append(u?W.empty:W.from(i))))return!1;let d=o.pos,m=d+s.nodeSize;return r.step(new gt(d-(a?1:0),m+(u?1:0),d+1,m-1,new J((a?W.empty:W.from(i.copy(W.empty))).append(u?W.empty:W.from(i.copy(W.empty))),a?0:1,u?0:1),a?0:1)),e(r.scrollIntoView()),!0}function rP(n){return function(e,t){let{$from:r,$to:i}=e.selection,o=r.blockRange(i,f=>f.childCount>0&&f.firstChild.type==n);if(!o)return!1;let s=o.startIndex;if(s==0)return!1;let a=o.parent,u=a.child(s-1);if(u.type!=n)return!1;if(t){let f=u.lastChild&&u.lastChild.type==a.type,h=W.from(f?n.create():null),d=new J(W.from(n.create(null,W.from(a.type.create(null,h)))),f?3:1,0),m=o.start,g=o.end;t(e.tr.step(new gt(m-(f?3:1),g,m,g,d,1,!0)).scrollIntoView())}return!0}}function iP(n){const e=new Map;if(!n||!n.type)throw new Error("mdast-util-definitions expected node");return _o(n,"definition",function(r){const i=Ay(r.identifier);i&&!e.get(i)&&e.set(i,r)}),t;function t(r){const i=Ay(r);return e.get(i)}}function Ay(n){return String(n||"").toUpperCase()}function oP(){return function(n){const e=iP(n);_o(n,function(t,r,i){if(t.type==="definition"&&i!==void 0&&typeof r=="number")return i.children.splice(r,1),[Hf,r];if(t.type==="imageReference"||t.type==="linkReference"){const 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},[Hf,r]}})}}function gk(n,e){var r;if(!(e.childCount>=1&&((r=e.lastChild)==null?void 0:r.type.name)==="hardbreak")){n.next(e.content);return}const t=[];e.content.forEach((i,o,s)=>{s!==e.childCount-1&&t.push(i)}),n.next(W.fromArray(t))}function F(n,e){return Object.assign(n,{meta:{package:"@milkdown/preset-commonmark",...e}}),n}var yk=Xs("emphasis");F(yk,{displayName:"Attr<emphasis>",group:"Emphasis"});var Zs=Po("emphasis",n=>({attrs:{marker:{default:n.get(ek).emphasis||"*",validate:"string"}},parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style",getAttrs:e=>e==="italic"}],toDOM:e=>["em",n.get(yk.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})}}}));F(Zs.mark,{displayName:"MarkSchema<emphasis>",group:"Emphasis"});F(Zs.ctx,{displayName:"MarkSchemaCtx<emphasis>",group:"Emphasis"});var kk=fe("ToggleEmphasis",n=>()=>au(Zs.type(n)));F(kk,{displayName:"Command<toggleEmphasisCommand>",group:"Emphasis"});var sP=Ft(n=>nn.markRule(/(?:^|[^*])\*([^*]+)\*$/,Zs.type(n),{getAttr:()=>({marker:"*"}),updateCaptured:({fullMatch:e,start:t})=>e.startsWith("*")?{}:{fullMatch:e.slice(1),start:t+1}}));F(sP,{displayName:"InputRule<emphasis>|Star",group:"Emphasis"});var lP=Ft(n=>nn.markRule(/\b_(?![_\s])(.*?[^_\s])_\b/,Zs.type(n),{getAttr:()=>({marker:"_"}),updateCaptured:({fullMatch:e,start:t})=>e.startsWith("_")?{}:{fullMatch:e.slice(1),start:t+1}}));F(lP,{displayName:"InputRule<emphasis>|Underscore",group:"Emphasis"});var bk=rn("emphasisKeymap",{ToggleEmphasis:{shortcuts:"Mod-i",command:n=>{const e=n.get(Pe);return()=>e.call(kk.key)}}});F(bk.ctx,{displayName:"KeymapCtx<emphasis>",group:"Emphasis"});F(bk.shortcuts,{displayName:"Keymap<emphasis>",group:"Emphasis"});var xk=Xs("strong");F(xk,{displayName:"Attr<strong>",group:"Strong"});var pu=Po("strong",n=>({attrs:{marker:{default:n.get(ek).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(xk.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})}}}));F(pu.mark,{displayName:"MarkSchema<strong>",group:"Strong"});F(pu.ctx,{displayName:"MarkSchemaCtx<strong>",group:"Strong"});var wk=fe("ToggleStrong",n=>()=>au(pu.type(n)));F(wk,{displayName:"Command<toggleStrongCommand>",group:"Strong"});var aP=Ft(n=>nn.markRule(new RegExp("(?<![\\w:/])(?:\\*\\*|__)([^*_]+?)(?:\\*\\*|__)(?![\\w/])$"),pu.type(n),{getAttr:e=>({marker:e[0].startsWith("*")?"*":"_"})}));F(aP,{displayName:"InputRule<strong>",group:"Strong"});var Ck=rn("strongKeymap",{ToggleBold:{shortcuts:["Mod-b"],command:n=>{const e=n.get(Pe);return()=>e.call(wk.key)}}});F(Ck.ctx,{displayName:"KeymapCtx<strong>",group:"Strong"});F(Ck.shortcuts,{displayName:"Keymap<strong>",group:"Strong"});var Sk=Xs("inlineCode");F(Sk,{displayName:"Attr<inlineCode>",group:"InlineCode"});var Si=Po("inlineCode",n=>({priority:100,code:!0,parseDOM:[{tag:"code"}],toDOM:e=>["code",n.get(Sk.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)}}));F(Si.mark,{displayName:"MarkSchema<inlineCode>",group:"InlineCode"});F(Si.ctx,{displayName:"MarkSchemaCtx<inlineCode>",group:"InlineCode"});var vk=fe("ToggleInlineCode",n=>()=>(e,t)=>{const{selection:r,tr:i}=e;if(r.empty)return!1;const{from:o,to:s}=r;return e.doc.rangeHasMark(o,s,Si.type(n))?(t==null||t(i.removeMark(o,s,Si.type(n))),!0):(Object.keys(e.schema.marks).filter(a=>a!==Si.type.name).map(a=>e.schema.marks[a]).forEach(a=>{i.removeMark(o,s,a)}),t==null||t(i.addMark(o,s,Si.type(n).create())),!0)});F(vk,{displayName:"Command<toggleInlineCodeCommand>",group:"InlineCode"});var uP=Ft(n=>nn.markRule(/(?:`)([^`]+)(?:`)$/,Si.type(n)));F(uP,{displayName:"InputRule<inlineCodeInputRule>",group:"InlineCode"});var Tk=rn("inlineCodeKeymap",{ToggleInlineCode:{shortcuts:"Mod-e",command:n=>{const e=n.get(Pe);return()=>e.call(vk.key)}}});F(Tk.ctx,{displayName:"KeymapCtx<inlineCode>",group:"InlineCode"});F(Tk.shortcuts,{displayName:"Keymap<inlineCode>",group:"InlineCode"});var Ak=Xs("link");F(Ak,{displayName:"Attr<link>",group:"Link"});var bs=Po("link",n=>({attrs:{href:{validate:"string"},title:{default:null,validate:"string|null"}},parseDOM:[{tag:"a[href]",getAttrs:e=>{if(!(e instanceof HTMLElement))throw Xn(e);return{href:e.getAttribute("href"),title:e.getAttribute("title")}}}],toDOM:e=>["a",{...n.get(Ak.key)(e),...e.attrs}],parseMarkdown:{match:e=>e.type==="link",runner:(e,t,r)=>{const 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})}}}));F(bs.mark,{displayName:"MarkSchema<link>",group:"Link"});var cP=fe("ToggleLink",n=>(e={})=>au(bs.type(n),e));F(cP,{displayName:"Command<toggleLinkCommand>",group:"Link"});var fP=fe("UpdateLink",n=>(e={})=>(t,r)=>{if(!r)return!1;let i,o=-1;const{selection:s}=t,{from:a,to:u}=s;if(t.doc.nodesBetween(a,a===u?u+1:u,(k,C)=>{if(bs.type(n).isInSet(k.marks))return i=k,o=C,!1}),!i)return!1;const f=i.marks.find(({type:k})=>k===bs.type(n));if(!f)return!1;const h=o,d=o+i.nodeSize,{tr:m}=t,g=bs.type(n).create({...f.attrs,...e});return g?(r(m.removeMark(h,d,f).addMark(h,d,g).setSelection(new pe(m.selection.$anchor)).scrollIntoView()),!0):!1});F(fP,{displayName:"Command<updateLinkCommand>",group:"Link"});var hP=Xh("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"),n.next(e.content)}}}));F(hP,{displayName:"NodeSchema<doc>",group:"Doc"});function dP(n){return Nh(n,e=>{var t;return e.type==="html"&&["<br />","<br>","<br >","<br/>"].includes((t=e.value)==null?void 0:t.trim())},(e,t)=>{if(!t.length)return;const r=t[t.length-1];if(!r)return;const i=r.children.indexOf(e);i!==-1&&r.children.splice(i,1)},!0)}var ed=Hi("remark-preserve-empty-line",()=>()=>dP);F(ed.plugin,{displayName:"Remark<remarkPreserveEmptyLine>",group:"Remark"});F(ed.options,{displayName:"RemarkConfig<remarkPreserveEmptyLine>",group:"Remark"});var Nk=Bn("paragraph");F(Nk,{displayName:"Attr<paragraph>",group:"Paragraph"});var Cr=rt("paragraph",n=>({content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM:e=>["p",n.get(Nk.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)=>{var i;const r=(i=n.get(xn).state)==null?void 0:i.doc.lastChild;e.openNode("paragraph"),(!t.content||t.content.size===0)&&t!==r&&pP(n)?e.addNode("html",void 0,"<br />"):gk(e,t),e.closeNode()}}}));function pP(n){let e=!1;try{n.get(ed.id),e=!0}catch{e=!1}return e}F(Cr.node,{displayName:"NodeSchema<paragraph>",group:"Paragraph"});F(Cr.ctx,{displayName:"NodeSchemaCtx<paragraph>",group:"Paragraph"});var Mk=fe("TurnIntoText",n=>()=>Ss(Cr.type(n)));F(Mk,{displayName:"Command<turnIntoTextCommand>",group:"Paragraph"});var Ik=rn("paragraphKeymap",{TurnIntoText:{shortcuts:"Mod-Alt-0",command:n=>{const e=n.get(Pe);return()=>e.call(Mk.key)}}});F(Ik.ctx,{displayName:"KeymapCtx<paragraph>",group:"Paragraph"});F(Ik.shortcuts,{displayName:"Keymap<paragraph>",group:"Paragraph"});var mP=Array(6).fill(0).map((n,e)=>e+1);function gP(n){return n.textContent.toLowerCase().trim().replace(/\s+/g,"-")}var td=Sn(gP,"headingIdGenerator");F(td,{displayName:"Ctx<HeadingIdGenerator>",group:"Heading"});var Ek=Bn("heading");F(Ek,{displayName:"Attr<heading>",group:"Heading"});var Bo=rt("heading",n=>{const e=n.get(td.key);return{content:"inline*",group:"block",defining:!0,attrs:{id:{default:"",validate:"string"},level:{default:1,validate:"number"}},parseDOM:mP.map(t=>({tag:`h${t}`,getAttrs:r=>{if(!(r instanceof HTMLElement))throw Xn(r);return{level:t,id:r.id}}})),toDOM:t=>[`h${t.attrs.level}`,{...n.get(Ek.key)(t),id:t.attrs.id||e(t)},0],parseMarkdown:{match:({type:t})=>t==="heading",runner:(t,r,i)=>{const 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}),gk(t,r),t.closeNode()}}}});F(Bo.node,{displayName:"NodeSchema<heading>",group:"Heading"});F(Bo.ctx,{displayName:"NodeSchemaCtx<heading>",group:"Heading"});var yP=Ft(n=>m0(/^(?<hashes>#+)\s$/,Bo.type(n),e=>{var o,s;const t=((s=(o=e.groups)==null?void 0:o.hashes)==null?void 0:s.length)||0,{$from:r}=n.get(xn).state.selection,i=r.node();if(i.type.name==="heading"){let a=Number(i.attrs.level)+Number(t);return a>6&&(a=6),{level:a}}return{level:t}}));F(yP,{displayName:"InputRule<wrapInHeadingInputRule>",group:"Heading"});var ki=fe("WrapInHeading",n=>e=>(e??(e=1),e<1?Ss(Cr.type(n)):Ss(Bo.type(n),{level:e})));F(ki,{displayName:"Command<wrapInHeadingCommand>",group:"Heading"});var Ok=fe("DowngradeHeading",n=>()=>(e,t,r)=>{const{$from:i}=e.selection,o=i.node();if(o.type!==Bo.type(n)||!e.selection.empty||i.parentOffset!==0)return!1;const s=o.attrs.level-1;return s?(t==null||t(e.tr.setNodeMarkup(e.selection.$from.before(),void 0,{...o.attrs,level:s})),!0):Ss(Cr.type(n))(e,t,r)});F(Ok,{displayName:"Command<downgradeHeadingCommand>",group:"Heading"});var Rk=rn("headingKeymap",{TurnIntoH1:{shortcuts:"Mod-Alt-1",command:n=>{const e=n.get(Pe);return()=>e.call(ki.key,1)}},TurnIntoH2:{shortcuts:"Mod-Alt-2",command:n=>{const e=n.get(Pe);return()=>e.call(ki.key,2)}},TurnIntoH3:{shortcuts:"Mod-Alt-3",command:n=>{const e=n.get(Pe);return()=>e.call(ki.key,3)}},TurnIntoH4:{shortcuts:"Mod-Alt-4",command:n=>{const e=n.get(Pe);return()=>e.call(ki.key,4)}},TurnIntoH5:{shortcuts:"Mod-Alt-5",command:n=>{const e=n.get(Pe);return()=>e.call(ki.key,5)}},TurnIntoH6:{shortcuts:"Mod-Alt-6",command:n=>{const e=n.get(Pe);return()=>e.call(ki.key,6)}},DowngradeHeading:{shortcuts:["Delete","Backspace"],command:n=>{const e=n.get(Pe);return()=>e.call(Ok.key)}}});F(Rk.ctx,{displayName:"KeymapCtx<heading>",group:"Heading"});F(Rk.shortcuts,{displayName:"Keymap<heading>",group:"Heading"});var _k=Bn("blockquote");F(_k,{displayName:"Attr<blockquote>",group:"Blockquote"});var mu=rt("blockquote",n=>({content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM:e=>["blockquote",n.get(_k.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()}}}));F(mu.node,{displayName:"NodeSchema<blockquote>",group:"Blockquote"});F(mu.ctx,{displayName:"NodeSchemaCtx<blockquote>",group:"Blockquote"});var kP=Ft(n=>$h(/^\s*>\s$/,mu.type(n)));F(kP,{displayName:"InputRule<wrapInBlockquoteInputRule>",group:"Blockquote"});var Dk=fe("WrapInBlockquote",n=>()=>zh(mu.type(n)));F(Dk,{displayName:"Command<wrapInBlockquoteCommand>",group:"Blockquote"});var Lk=rn("blockquoteKeymap",{WrapInBlockquote:{shortcuts:"Mod-Shift-b",command:n=>{const e=n.get(Pe);return()=>e.call(Dk.key)}}});F(Lk.ctx,{displayName:"KeymapCtx<blockquote>",group:"Blockquote"});F(Lk.shortcuts,{displayName:"Keymap<blockquote>",group:"Blockquote"});var Pk=Bn("codeBlock",()=>({pre:{},code:{}}));F(Pk,{displayName:"Attr<codeBlock>",group:"CodeBlock"});var gu=rt("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 Xn(e);return{language:e.dataset.language}}}],toDOM:e=>{const t=n.get(Pk.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)=>{const 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)=>{var r;e.addNode("code",void 0,((r=t.content.firstChild)==null?void 0:r.text)||"",{lang:t.attrs.language})}}}));F(gu.node,{displayName:"NodeSchema<codeBlock>",group:"CodeBlock"});F(gu.ctx,{displayName:"NodeSchemaCtx<codeBlock>",group:"CodeBlock"});var bP=Ft(n=>m0(/^```(?<language>[a-z]*)?[\s\n]$/,gu.type(n),e=>{var t;return{language:((t=e.groups)==null?void 0:t.language)??""}}));F(bP,{displayName:"InputRule<createCodeBlockInputRule>",group:"CodeBlock"});var Bk=fe("CreateCodeBlock",n=>(e="")=>Ss(gu.type(n),{language:e}));F(Bk,{displayName:"Command<createCodeBlockCommand>",group:"CodeBlock"});var xP=fe("UpdateCodeBlockLanguage",()=>({pos:n,language:e}={pos:-1,language:""})=>(t,r)=>n>=0?(r==null||r(t.tr.setNodeAttribute(n,"language",e)),!0):!1);F(xP,{displayName:"Command<updateCodeBlockLanguageCommand>",group:"CodeBlock"});var Fk=rn("codeBlockKeymap",{CreateCodeBlock:{shortcuts:"Mod-Alt-c",command:n=>{const e=n.get(Pe);return()=>e.call(Bk.key)}}});F(Fk.ctx,{displayName:"KeymapCtx<codeBlock>",group:"CodeBlock"});F(Fk.shortcuts,{displayName:"Keymap<codeBlock>",group:"CodeBlock"});var zk=Bn("image");F(zk,{displayName:"Attr<image>",group:"Image"});var el=rt("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 Xn(e);return{src:e.getAttribute("src")||"",alt:e.getAttribute("alt")||"",title:e.getAttribute("title")||e.getAttribute("alt")||""}}}],toDOM:e=>["img",{...n.get(zk.key)(e),...e.attrs}],parseMarkdown:{match:({type:e})=>e==="image",runner:(e,t,r)=>{const 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})}}}));F(el.node,{displayName:"NodeSchema<image>",group:"Image"});F(el.ctx,{displayName:"NodeSchemaCtx<image>",group:"Image"});var wP=fe("InsertImage",n=>(e={})=>(t,r)=>{if(!r)return!0;const{src:i="",alt:o="",title:s=""}=e,a=el.type(n).create({src:i,alt:o,title:s});return a&&r(t.tr.replaceSelectionWith(a).scrollIntoView()),!0});F(wP,{displayName:"Command<insertImageCommand>",group:"Image"});var CP=fe("UpdateImage",n=>(e={})=>(t,r)=>{const i=nn.findSelectedNodeOfType(t.selection,el.type(n));if(!i)return!1;const{node:o,pos:s}=i,a={...o.attrs},{src:u,alt:f,title:h}=e;return u!==void 0&&(a.src=u),f!==void 0&&(a.alt=f),h!==void 0&&(a.title=h),r==null||r(t.tr.setNodeMarkup(s,void 0,a).scrollIntoView()),!0});F(CP,{displayName:"Command<updateImageCommand>",group:"Image"});var SP=Ft(n=>new Cn(/!\[(?<alt>.*?)]\((?<filename>.*?)\s*(?="|\))"?(?<title>[^"]+)?"?\)/,(e,t,r,i)=>{const[o,s,a="",u]=t;return o?e.tr.replaceWith(r,i,el.type(n).create({src:a,alt:s,title:u})):null}));F(SP,{displayName:"InputRule<insertImageInputRule>",group:"Image"});var yh=Bn("hardbreak",n=>({"data-type":"hardbreak","data-is-inline":n.attrs.isInline}));F(yh,{displayName:"Attr<hardbreak>",group:"Hardbreak"});var yo=rt("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(yh.key)(e)," "]:["br",n.get(yh.key)(e)],parseMarkdown:{match:({type:e})=>e==="break",runner:(e,t,r)=>{var i;e.addNode(r,{isInline:!!((i=t.data)!=null&&i.isInline)})}},leafText:()=>`
44
+ `,toMarkdown:{match:e=>e.type.name==="hardbreak",runner:(e,t)=>{t.attrs.isInline?e.addNode("text",void 0,`
45
+ `):e.addNode("break")}}}));F(yo.node,{displayName:"NodeSchema<hardbreak>",group:"Hardbreak"});F(yo.ctx,{displayName:"NodeSchemaCtx<hardbreak>",group:"Hardbreak"});var $k=fe("InsertHardbreak",n=>()=>(e,t)=>{var o;const{selection:r,tr:i}=e;if(!(r instanceof pe))return!1;if(r.empty){const s=r.$from.node();if(s.childCount>0&&((o=s.lastChild)==null?void 0:o.type.name)==="hardbreak")return t==null||t(i.replaceRangeWith(r.to-1,r.to,e.schema.node("paragraph")).setSelection(de.near(i.doc.resolve(r.to))).scrollIntoView()),!0}return t==null||t(i.setMeta("hardbreak",!0).replaceSelectionWith(yo.type(n).create()).scrollIntoView()),!0});F($k,{displayName:"Command<insertHardbreakCommand>",group:"Hardbreak"});var Wk=rn("hardbreakKeymap",{InsertHardbreak:{shortcuts:"Shift-Enter",command:n=>{const e=n.get(Pe);return()=>e.call($k.key)}}});F(Wk.ctx,{displayName:"KeymapCtx<hardbreak>",group:"Hardbreak"});F(Wk.shortcuts,{displayName:"Keymap<hardbreak>",group:"Hardbreak"});var Vk=Bn("hr");F(Vk,{displayName:"Attr<hr>",group:"Hr"});var yu=rt("hr",n=>({group:"block",parseDOM:[{tag:"hr"}],toDOM:e=>["hr",n.get(Vk.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")}}}));F(yu.node,{displayName:"NodeSchema<hr>",group:"Hr"});F(yu.ctx,{displayName:"NodeSchemaCtx<hr>",group:"Hr"});var vP=Ft(n=>new Cn(/^(?:---|___\s|\*\*\*\s)$/,(e,t,r,i)=>{const{tr:o}=e;return t[0]&&o.replaceWith(r-1,i,yu.type(n).create()),o}));F(vP,{displayName:"InputRule<insertHrInputRule>",group:"Hr"});var TP=fe("InsertHr",n=>()=>(e,t)=>{if(!t)return!0;const r=Cr.node.type(n).create(),{tr:i,selection:o}=e,{from:s}=o,a=yu.type(n).create();if(!a)return!0;const u=i.replaceSelectionWith(a).insert(s,r),f=de.findFrom(u.doc.resolve(s),1,!0);return f&&t(u.setSelection(f).scrollIntoView()),!0});F(TP,{displayName:"Command<insertHrCommand>",group:"Hr"});var Hk=Bn("bulletList");F(Hk,{displayName:"Attr<bulletList>",group:"BulletList"});var tl=rt("bullet_list",n=>({content:"listItem+",group:"block",attrs:{spread:{default:!1,validate:"boolean"}},parseDOM:[{tag:"ul",getAttrs:e=>{if(!(e instanceof HTMLElement))throw Xn(e);return{spread:e.dataset.spread==="true"}}}],toDOM:e=>["ul",{...n.get(Hk.key)(e),"data-spread":e.attrs.spread},0],parseMarkdown:{match:({type:e,ordered:t})=>e==="list"&&!t,runner:(e,t,r)=>{const i=t.spread!=null?`${t.spread}`:"false";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()}}}));F(tl.node,{displayName:"NodeSchema<bulletList>",group:"BulletList"});F(tl.ctx,{displayName:"NodeSchemaCtx<bulletList>",group:"BulletList"});var AP=Ft(n=>$h(/^\s*([-+*])\s$/,tl.type(n)));F(AP,{displayName:"InputRule<wrapInBulletListInputRule>",group:"BulletList"});var qk=fe("WrapInBulletList",n=>()=>zh(tl.type(n)));F(qk,{displayName:"Command<wrapInBulletListCommand>",group:"BulletList"});var Kk=rn("bulletListKeymap",{WrapInBulletList:{shortcuts:"Mod-Alt-8",command:n=>{const e=n.get(Pe);return()=>e.call(qk.key)}}});F(Kk.ctx,{displayName:"KeymapCtx<bulletListKeymap>",group:"BulletList"});F(Kk.shortcuts,{displayName:"Keymap<bulletListKeymap>",group:"BulletList"});var Uk=Bn("orderedList");F(Uk,{displayName:"Attr<orderedList>",group:"OrderedList"});var nl=rt("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 Xn(e);return{spread:e.dataset.spread,order:e.hasAttribute("start")?Number(e.getAttribute("start")):1}}}],toDOM:e=>["ol",{...n.get(Uk.key)(e),...e.attrs.order===1?{}:e.attrs.order,"data-spread":e.attrs.spread},0],parseMarkdown:{match:({type:e,ordered:t})=>e==="list"&&!!t,runner:(e,t,r)=>{const i=t.spread!=null?`${t.spread}`:"true";e.openNode(r,{spread:i}).next(t.children).closeNode()}},toMarkdown:{match:e=>e.type.name==="ordered_list",runner:(e,t)=>{e.openNode("list",void 0,{ordered:!0,start:1,spread:t.attrs.spread==="true"}),e.next(t.content),e.closeNode()}}}));F(nl.node,{displayName:"NodeSchema<orderedList>",group:"OrderedList"});F(nl.ctx,{displayName:"NodeSchemaCtx<orderedList>",group:"OrderedList"});var NP=Ft(n=>$h(/^\s*(\d+)\.\s$/,nl.type(n),e=>({order:Number(e[1])}),(e,t)=>t.childCount+t.attrs.order===Number(e[1])));F(NP,{displayName:"InputRule<wrapInOrderedListInputRule>",group:"OrderedList"});var jk=fe("WrapInOrderedList",n=>()=>zh(nl.type(n)));F(jk,{displayName:"Command<wrapInOrderedListCommand>",group:"OrderedList"});var Jk=rn("orderedListKeymap",{WrapInOrderedList:{shortcuts:"Mod-Alt-7",command:n=>{const e=n.get(Pe);return()=>e.call(jk.key)}}});F(Jk.ctx,{displayName:"KeymapCtx<orderedList>",group:"OrderedList"});F(Jk.shortcuts,{displayName:"Keymap<orderedList>",group:"OrderedList"});var Gk=Bn("listItem");F(Gk,{displayName:"Attr<listItem>",group:"ListItem"});var ni=rt("list_item",n=>({group:"listItem",content:"paragraph block*",attrs:{label:{default:"•",validate:"string"},listType:{default:"bullet",validate:"string"},spread:{default:!0,validate:"boolean"}},defining:!0,parseDOM:[{tag:"li",getAttrs:e=>{if(!(e instanceof HTMLElement))throw Xn(e);return{label:e.dataset.label,listType:e.dataset.listType,spread:e.dataset.spread==="true"}}}],toDOM:e=>["li",{...n.get(Gk.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)=>{const i=t.label!=null?`${t.label}.`:"•",o=t.label!=null?"ordered":"bullet",s=t.spread!=null?`${t.spread}`:"true";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()}}}));F(ni.node,{displayName:"NodeSchema<listItem>",group:"ListItem"});F(ni.ctx,{displayName:"NodeSchemaCtx<listItem>",group:"ListItem"});var Yk=fe("SinkListItem",n=>()=>rP(ni.type(n)));F(Yk,{displayName:"Command<sinkListItemCommand>",group:"ListItem"});var Xk=fe("LiftListItem",n=>()=>eP(ni.type(n)));F(Xk,{displayName:"Command<liftListItemCommand>",group:"ListItem"});var Qk=fe("SplitListItem",n=>()=>ZL(ni.type(n)));F(Qk,{displayName:"Command<splitListItemCommand>",group:"ListItem"});function MP(n){return(e,t,r)=>{const{selection:i}=e;if(!(i instanceof pe))return!1;const{empty:o,$from:s}=i;return!o||s.parentOffset!==0||s.node(-1).type!==ni.type(n)?!1:a0(e,t,r)}}var Zk=fe("LiftFirstListItem",n=>()=>MP(n));F(Zk,{displayName:"Command<liftFirstListItemCommand>",group:"ListItem"});var eb=rn("listItemKeymap",{NextListItem:{shortcuts:"Enter",command:n=>{const e=n.get(Pe);return()=>e.call(Qk.key)}},SinkListItem:{shortcuts:["Tab","Mod-]"],command:n=>{const e=n.get(Pe);return()=>e.call(Yk.key)}},LiftListItem:{shortcuts:["Shift-Tab","Mod-["],command:n=>{const e=n.get(Pe);return()=>e.call(Xk.key)}},LiftFirstListItem:{shortcuts:["Backspace","Delete"],command:n=>{const e=n.get(Pe);return()=>e.call(Zk.key)}}});F(eb.ctx,{displayName:"KeymapCtx<listItem>",group:"ListItem"});F(eb.shortcuts,{displayName:"Keymap<listItem>",group:"ListItem"});var IP=Xh("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)}}}));F(IP,{displayName:"NodeSchema<text>",group:"Text"});var tb=Bn("html");F(tb,{displayName:"Attr<html>",group:"Html"});var nb=rt("html",n=>({atom:!0,group:"inline",inline:!0,attrs:{value:{default:"",validate:"string"}},toDOM:e=>{const t=document.createElement("span"),r={...n.get(tb.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)}}}));F(nb.node,{displayName:"NodeSchema<html>",group:"Html"});F(nb.ctx,{displayName:"NodeSchemaCtx<html>",group:"Html"});fe("IsMarkSelected",()=>n=>e=>{if(!n)return!1;const{doc:t,selection:r}=e;return t.rangeHasMark(r.from,r.to,n)});fe("IsNoteSelected",()=>n=>e=>n?nn.findNodeInSelection(e,n).hasNode:!1);fe("ClearTextInCurrentBlock",()=>()=>(n,e)=>{let t=n.tr;const{$from:r,$to:i}=t.selection,{pos:o}=r,{pos:s}=i,a=o-r.node().content.size;return a<0?!1:(t=t.deleteRange(a,s),e==null||e(t),!0)});fe("SetBlockType",()=>n=>(e,t)=>{const{nodeType:r,attrs:i=null}=n??{};if(!r)return!1;const o=e.tr,{from:s,to:a}=o.selection;try{o.setBlockType(s,a,r,i)}catch{return!1}return t==null||t(o),!0});fe("WrapInBlockType",()=>n=>(e,t)=>{const{nodeType:r,attrs:i=null}=n??{};if(!r)return!1;let o=e.tr;try{const{$from:s,$to:a}=o.selection,u=s.blockRange(a),f=u&&Dh(u,r,i);if(!f)return!1;o=o.wrap(u,f)}catch{return!1}return t==null||t(o),!0});fe("AddBlockType",()=>n=>(e,t)=>{const{nodeType:r,attrs:i=null}=n??{};if(!r)return!1;const o=e.tr;try{const s=r instanceof br?r:r.createAndFill(i);if(!s)return!1;o.replaceSelectionWith(s)}catch{return!1}return t==null||t(o),!0});fe("SelectTextNearPos",()=>n=>(e,t)=>{const{pos:r}=n??{};if(r==null)return!1;const i=(s,a,u)=>Math.min(Math.max(s,a),u),o=e.tr;try{const s=e.doc.resolve(i(r,0,e.doc.content.size));o.setSelection(pe.near(s))}catch{return!1}return t==null||t(o.scrollIntoView()),!0});var rb=Hi("remarkAddOrderInList",()=>()=>n=>{_o(n,"list",e=>{if(e.ordered){const t=e.start??1;e.children.forEach((r,i)=>{r.label=i+t})}})});F(rb.plugin,{displayName:"Remark<remarkAddOrderInListPlugin>",group:"Remark"});F(rb.options,{displayName:"RemarkConfig<remarkAddOrderInListPlugin>",group:"Remark"});var ib=Hi("remarkLineBreak",()=>()=>n=>{const e=/[\t ]*(?:\r?\n|\r)/g;_o(n,"text",(t,r,i)=>{if(!t.value||typeof t.value!="string")return;const o=[];let s=0;e.lastIndex=0;let a=e.exec(t.value);for(;a;){const u=a.index;s!==u&&o.push({type:"text",value:t.value.slice(s,u)}),o.push({type:"break",data:{isInline:!0}}),s=u+a[0].length,a=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})});F(ib.plugin,{displayName:"Remark<remarkLineBreak>",group:"Remark"});F(ib.options,{displayName:"RemarkConfig<remarkLineBreak>",group:"Remark"});var ob=Hi("remarkInlineLink",()=>oP);F(ob.plugin,{displayName:"Remark<remarkInlineLinkPlugin>",group:"Remark"});F(ob.options,{displayName:"RemarkConfig<remarkInlineLinkPlugin>",group:"Remark"});var EP=n=>!!n.children,OP=n=>n.type==="html";function RP(n,e){return t(n,0,null)[0];function t(r,i,o){if(EP(r)){const s=[];for(let a=0,u=r.children.length;a<u;a++){const f=r.children[a];if(f){const h=t(f,a,r);if(h)for(let d=0,m=h.length;d<m;d++){const g=h[d];g&&s.push(g)}}}r.children=s}return e(r,i,o)}}var _P=["root","blockquote","listItem"],sb=Hi("remarkHTMLTransformer",()=>()=>n=>{RP(n,(e,t,r)=>OP(e)?(r&&_P.includes(r.type)&&(e.children=[{...e}],delete e.value,e.type="paragraph"),[e]):[e])});F(sb.plugin,{displayName:"Remark<remarkHtmlTransformer>",group:"Remark"});F(sb.options,{displayName:"RemarkConfig<remarkHtmlTransformer>",group:"Remark"});var lb=Hi("remarkMarker",()=>()=>(n,e)=>{const t=r=>e.value.charAt(r.position.start.offset);_o(n,r=>["strong","emphasis"].includes(r.type),r=>{r.marker=t(r)})});F(lb.plugin,{displayName:"Remark<remarkMarker>",group:"Remark"});F(lb.options,{displayName:"RemarkConfig<remarkMarker>",group:"Remark"});var DP=Pn(()=>{let n=!1;const e=new Pt({key:new Bt("MILKDOWN_INLINE_NODES_CURSOR"),state:{init(){return!1},apply(t){if(!t.selection.empty)return!1;const r=t.selection.$from,i=r.nodeBefore,o=r.nodeAfter;return!!(i&&o&&i.isInline&&!i.isText&&o.isInline&&!o.isText)}},props:{handleDOMEvents:{compositionend:(t,r)=>n?(n=!1,requestAnimationFrame(()=>{if(e.getState(t.state)){const i=t.state.selection.from;r.preventDefault(),t.dispatch(t.state.tr.insertText(r.data||"",i))}}),!0):!1,compositionstart:t=>(e.getState(t.state)&&(n=!0),!1),beforeinput:(t,r)=>{if(e.getState(t.state)&&r instanceof InputEvent&&r.data&&!n){const i=t.state.selection.from;return r.preventDefault(),t.dispatch(t.state.tr.insertText(r.data||"",i)),!0}return!1}},decorations(t){if(e.getState(t)){const r=t.selection.$from.pos,i=document.createElement("span"),o=nt.widget(r,i,{side:-1}),s=document.createElement("span"),a=nt.widget(r,s);return setTimeout(()=>{i.contentEditable="true",s.contentEditable="true"}),$e.create(t.doc,[o,a])}return $e.empty}}});return e});F(DP,{displayName:"Prose<inlineNodesCursorPlugin>",group:"Prose"});var LP=Pn(n=>new Pt({key:new Bt("MILKDOWN_HARDBREAK_MARKS"),appendTransaction:(e,t,r)=>{if(!e.length)return;const[i]=e;if(!i)return;const[o]=i.steps;if(i.getMeta("hardbreak")){if(!(o instanceof ot))return;const{from:s}=o;return r.tr.setNodeMarkup(s,yo.type(n),void 0,[])}if(o instanceof yr){let s=r.tr;const{from:a,to:u}=o;return r.doc.nodesBetween(a,u,(f,h)=>{f.type===yo.type(n)&&(s=s.setNodeMarkup(h,yo.type(n),void 0,[]))}),s}}}));F(LP,{displayName:"Prose<hardbreakClearMarkPlugin>",group:"Prose"});var ab=Sn(["table","code_block"],"hardbreakFilterNodes");F(ab,{displayName:"Ctx<hardbreakFilterNodes>",group:"Prose"});var PP=Pn(n=>{const e=n.get(ab.key);return new Pt({key:new Bt("MILKDOWN_HARDBREAK_FILTER"),filterTransaction:(t,r)=>{const i=t.getMeta("hardbreak"),[o]=t.steps;if(i&&o){const{from:s}=o,a=r.doc.resolve(s);let u=a.depth,f=!0;for(;u>0;)e.includes(a.node(u).type.name)&&(f=!1),u--;return f}return!0}})});F(PP,{displayName:"Prose<hardbreakFilterPlugin>",group:"Prose"});var BP=Pn(n=>{const e=new Bt("MILKDOWN_HEADING_ID"),t=r=>{if(r.composing)return;const i=n.get(td.key),o=r.state.tr.setMeta("addToHistory",!1);let s=!1;const a={};r.state.doc.descendants((u,f)=>{if(u.type===Bo.type(n)){if(u.textContent.trim().length===0)return;const h=u.attrs;let d=i(u);a[d]?(a[d]+=1,d+=`-#${a[d]}`):a[d]=1,h.id!==d&&(s=!0,o.setMeta(e,!0).setNodeMarkup(f,void 0,{...h,id:d}))}}),s&&r.dispatch(o)};return new Pt({key:e,view:r=>(t(r),{update:(i,o)=>{i.state.doc.eq(o.doc)||t(i)}})})});F(BP,{displayName:"Prose<syncHeadingIdPlugin>",group:"Prose"});var FP=Pn(n=>{const e=(t,r,i)=>{if(!i.selection||t.some(d=>d.getMeta("addToHistory")===!1||!d.isGeneric))return null;const o=nl.type(n),s=tl.type(n),a=ni.type(n),u=(d,m)=>{let g=!1;const k=`${m+1}.`;return d.label!==k&&(d.label=k,g=!0),g};let f=i.tr,h=!1;return i.doc.descendants((d,m,g,k)=>{if(d.type===s){const C=d.maybeChild(0);(C==null?void 0:C.type)===a&&C.attrs.listType==="ordered"&&(h=!0,f.setNodeMarkup(m,o,{spread:"true"}),d.descendants((v,S,L,R)=>{if(v.type===a){const K={...v.attrs};u(K,R)&&(f=f.setNodeMarkup(S,void 0,K))}return!1}))}else if(d.type===a&&(g==null?void 0:g.type)===o){const C={...d.attrs};let v=!1;C.listType!=="ordered"&&(C.listType="ordered",v=!0),g!=null&&g.maybeChild(0)&&(v=u(C,k)),v&&(f=f.setNodeMarkup(m,void 0,C),h=!0)}}),h?f.setMeta("addToHistory",!1):null};return new Pt({key:new Bt("MILKDOWN_KEEP_LIST_ORDER"),appendTransaction:e})});F(FP,{displayName:"Prose<syncListOrderPlugin>",group:"Prose"});var _a=typeof navigator<"u"?navigator:null,nd=_a&&_a.userAgent||"",zP=/Edge\/(\d+)/.exec(nd),$P=/MSIE \d/.exec(nd),WP=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(nd),VP=!!($P||WP||zP),HP=!VP&&!!_a&&/Apple Computer/.test(_a.vendor),ub=new Bt("safari-ime-span"),kh=!1,qP={key:ub,props:{decorations:KP,handleDOMEvents:{compositionstart:()=>{kh=!0},compositionend:()=>{kh=!1}}}};function KP(n){const{$from:e,$to:t,to:r}=n.selection;if(kh&&e.sameParent(t)){const i=nt.widget(r,UP,{ignoreSelection:!0,key:"safari-ime-span"});return $e.create(n.doc,[i])}}function UP(n){const e=n.dom.ownerDocument.createElement("span");return e.className="ProseMirror-safari-ime-span",e}var jP=new Pt(HP?qP:{key:ub});function Ny(n,e){const t=String(n);if(typeof e!="string")throw new TypeError("Expected character");let r=0,i=t.indexOf(e);for(;i!==-1;)r++,i=t.indexOf(e,i+e.length);return r}function JP(n){if(typeof n!="string")throw new TypeError("Expected a string");return n.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function GP(n,e,t){const i=eu((t||{}).ignore||[]),o=YP(e);let s=-1;for(;++s<o.length;)Nh(n,"text",a);function a(f,h){let d=-1,m;for(;++d<h.length;){const g=h[d],k=m?m.children:void 0;if(i(g,k?k.indexOf(g):void 0,m))return;m=g}if(m)return u(f,h)}function u(f,h){const d=h[h.length-1],m=o[s][0],g=o[s][1];let k=0;const v=d.children.indexOf(f);let S=!1,L=[];m.lastIndex=0;let R=m.exec(f.value);for(;R;){const K=R.index,q={index:R.index,input:R.input,stack:[...h,f]};let O=g(...R,q);if(typeof O=="string"&&(O=O.length>0?{type:"text",value:O}:void 0),O===!1?m.lastIndex=K+1:(k!==K&&L.push({type:"text",value:f.value.slice(k,K)}),Array.isArray(O)?L.push(...O):O&&L.push(O),k=K+R[0].length,S=!0),!m.global)break;R=m.exec(f.value)}return S?(k<f.value.length&&L.push({type:"text",value:f.value.slice(k)}),d.children.splice(v,1,...L)):L=[f],v+L.length}}function YP(n){const e=[];if(!Array.isArray(n))throw new TypeError("Expected find and replace tuple or list of tuples");const t=!n[0]||Array.isArray(n[0])?n:[n];let r=-1;for(;++r<t.length;){const i=t[r];e.push([XP(i[0]),QP(i[1])])}return e}function XP(n){return typeof n=="string"?new RegExp(JP(n),"g"):n}function QP(n){return typeof n=="function"?n:function(){return n}}const Mf="phrasing",If=["autolink","link","image","label"];function ZP(){return{transforms:[sB],enter:{literalAutolink:tB,literalAutolinkEmail:Ef,literalAutolinkHttp:Ef,literalAutolinkWww:Ef},exit:{literalAutolink:oB,literalAutolinkEmail:iB,literalAutolinkHttp:nB,literalAutolinkWww:rB}}}function eB(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:Mf,notInConstruct:If},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:Mf,notInConstruct:If},{character:":",before:"[ps]",after:"\\/",inConstruct:Mf,notInConstruct:If}]}}function tB(n){this.enter({type:"link",title:null,url:"",children:[]},n)}function Ef(n){this.config.enter.autolinkProtocol.call(this,n)}function nB(n){this.config.exit.autolinkProtocol.call(this,n)}function rB(n){this.config.exit.data.call(this,n);const e=this.stack[this.stack.length-1];e.type,e.url="http://"+this.sliceSerialize(n)}function iB(n){this.config.exit.autolinkEmail.call(this,n)}function oB(n){this.exit(n)}function sB(n){GP(n,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,lB],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),aB]],{ignore:["link","linkReference"]})}function lB(n,e,t,r,i){let o="";if(!cb(i)||(/^w/i.test(e)&&(t=e+t,e="",o="http://"),!uB(t)))return!1;const s=cB(t+r);if(!s[0])return!1;const a={type:"link",title:null,url:o+e+s[0],children:[{type:"text",value:e+s[0]}]};return s[1]?[a,{type:"text",value:s[1]}]:a}function aB(n,e,t,r){return!cb(r,!0)||/[-\d_]$/.test(t)?!1:{type:"link",title:null,url:"mailto:"+e+"@"+t,children:[{type:"text",value:e+"@"+t}]}}function uB(n){const e=n.split(".");return!(e.length<2||e[e.length-1]&&(/_/.test(e[e.length-1])||!/[a-zA-Z\d]/.test(e[e.length-1]))||e[e.length-2]&&(/_/.test(e[e.length-2])||!/[a-zA-Z\d]/.test(e[e.length-2])))}function cB(n){const e=/[!"&'),.:;<>?\]}]+$/.exec(n);if(!e)return[n,void 0];n=n.slice(0,e.index);let t=e[0],r=t.indexOf(")");const i=Ny(n,"(");let o=Ny(n,")");for(;r!==-1&&i>o;)n+=t.slice(0,r+1),t=t.slice(r+1),r=t.indexOf(")"),o++;return[n,t]}function cb(n,e){const t=n.input.charCodeAt(n.index-1);return(n.index===0||Di(t)||Qa(t))&&(!e||t!==47)}fb.peek=bB;function fB(){this.buffer()}function hB(n){this.enter({type:"footnoteReference",identifier:"",label:""},n)}function dB(){this.buffer()}function pB(n){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},n)}function mB(n){const e=this.resume(),t=this.stack[this.stack.length-1];t.type,t.identifier=_n(this.sliceSerialize(n)).toLowerCase(),t.label=e}function gB(n){this.exit(n)}function yB(n){const e=this.resume(),t=this.stack[this.stack.length-1];t.type,t.identifier=_n(this.sliceSerialize(n)).toLowerCase(),t.label=e}function kB(n){this.exit(n)}function bB(){return"["}function fb(n,e,t,r){const i=t.createTracker(r);let o=i.move("[^");const s=t.enter("footnoteReference"),a=t.enter("reference");return o+=i.move(t.safe(t.associationId(n),{after:"]",before:o})),a(),s(),o+=i.move("]"),o}function xB(){return{enter:{gfmFootnoteCallString:fB,gfmFootnoteCall:hB,gfmFootnoteDefinitionLabelString:dB,gfmFootnoteDefinition:pB},exit:{gfmFootnoteCallString:mB,gfmFootnoteCall:gB,gfmFootnoteDefinitionLabelString:yB,gfmFootnoteDefinition:kB}}}function wB(n){let e=!1;return n&&n.firstLineBlank&&(e=!0),{handlers:{footnoteDefinition:t,footnoteReference:fb},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function t(r,i,o,s){const a=o.createTracker(s);let u=a.move("[^");const f=o.enter("footnoteDefinition"),h=o.enter("label");return u+=a.move(o.safe(o.associationId(r),{before:u,after:"]"})),h(),u+=a.move("]:"),r.children&&r.children.length>0&&(a.shift(4),u+=a.move((e?`
46
+ `:" ")+o.indentLines(o.containerFlow(r,a.current()),e?hb:CB))),f(),u}}function CB(n,e,t){return e===0?n:hb(n,e,t)}function hb(n,e,t){return(t?"":" ")+n}const SB=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];db.peek=MB;function vB(){return{canContainEols:["delete"],enter:{strikethrough:AB},exit:{strikethrough:NB}}}function TB(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:SB}],handlers:{delete:db}}}function AB(n){this.enter({type:"delete",children:[]},n)}function NB(n){this.exit(n)}function db(n,e,t,r){const i=t.createTracker(r),o=t.enter("strikethrough");let s=i.move("~~");return s+=t.containerPhrasing(n,{...i.current(),before:s,after:"~"}),s+=i.move("~~"),o(),s}function MB(){return"~"}function IB(n){return n.length}function EB(n,e){const t=e||{},r=(t.align||[]).concat(),i=t.stringLength||IB,o=[],s=[],a=[],u=[];let f=0,h=-1;for(;++h<n.length;){const C=[],v=[];let S=-1;for(n[h].length>f&&(f=n[h].length);++S<n[h].length;){const L=OB(n[h][S]);if(t.alignDelimiters!==!1){const R=i(L);v[S]=R,(u[S]===void 0||R>u[S])&&(u[S]=R)}C.push(L)}s[h]=C,a[h]=v}let d=-1;if(typeof r=="object"&&"length"in r)for(;++d<f;)o[d]=My(r[d]);else{const C=My(r);for(;++d<f;)o[d]=C}d=-1;const m=[],g=[];for(;++d<f;){const C=o[d];let v="",S="";C===99?(v=":",S=":"):C===108?v=":":C===114&&(S=":");let L=t.alignDelimiters===!1?1:Math.max(1,u[d]-v.length-S.length);const R=v+"-".repeat(L)+S;t.alignDelimiters!==!1&&(L=v.length+L+S.length,L>u[d]&&(u[d]=L),g[d]=L),m[d]=R}s.splice(1,0,m),a.splice(1,0,g),h=-1;const k=[];for(;++h<s.length;){const C=s[h],v=a[h];d=-1;const S=[];for(;++d<f;){const L=C[d]||"";let R="",K="";if(t.alignDelimiters!==!1){const q=u[d]-(v[d]||0),O=o[d];O===114?R=" ".repeat(q):O===99?q%2?(R=" ".repeat(q/2+.5),K=" ".repeat(q/2-.5)):(R=" ".repeat(q/2),K=R):K=" ".repeat(q)}t.delimiterStart!==!1&&!d&&S.push("|"),t.padding!==!1&&!(t.alignDelimiters===!1&&L==="")&&(t.delimiterStart!==!1||d)&&S.push(" "),t.alignDelimiters!==!1&&S.push(R),S.push(L),t.alignDelimiters!==!1&&S.push(K),t.padding!==!1&&S.push(" "),(t.delimiterEnd!==!1||d!==f-1)&&S.push("|")}k.push(t.delimiterEnd===!1?S.join("").replace(/ +$/,""):S.join(""))}return k.join(`
47
+ `)}function OB(n){return n==null?"":String(n)}function My(n){const e=typeof n=="string"?n.codePointAt(0):0;return e===67||e===99?99:e===76||e===108?108:e===82||e===114?114:0}function RB(){return{enter:{table:_B,tableData:Iy,tableHeader:Iy,tableRow:LB},exit:{codeText:PB,table:DB,tableData:Of,tableHeader:Of,tableRow:Of}}}function _B(n){const e=n._align;this.enter({type:"table",align:e.map(function(t){return t==="none"?null:t}),children:[]},n),this.data.inTable=!0}function DB(n){this.exit(n),this.data.inTable=void 0}function LB(n){this.enter({type:"tableRow",children:[]},n)}function Of(n){this.exit(n)}function Iy(n){this.enter({type:"tableCell",children:[]},n)}function PB(n){let e=this.resume();this.data.inTable&&(e=e.replace(/\\([\\|])/g,BB));const t=this.stack[this.stack.length-1];t.type,t.value=e,this.exit(n)}function BB(n,e){return e==="|"?e:n}function FB(n){const e=n||{},t=e.tableCellPadding,r=e.tablePipeAlign,i=e.stringLength,o=t?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
48
+ `,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:m,table:s,tableCell:u,tableRow:a}};function s(g,k,C,v){return f(h(g,C,v),g.align)}function a(g,k,C,v){const S=d(g,C,v),L=f([S]);return L.slice(0,L.indexOf(`
49
+ `))}function u(g,k,C,v){const S=C.enter("tableCell"),L=C.enter("phrasing"),R=C.containerPhrasing(g,{...v,before:o,after:o});return L(),S(),R}function f(g,k){return EB(g,{align:k,alignDelimiters:r,padding:t,stringLength:i})}function h(g,k,C){const v=g.children;let S=-1;const L=[],R=k.enter("table");for(;++S<v.length;)L[S]=d(v[S],k,C);return R(),L}function d(g,k,C){const v=g.children;let S=-1;const L=[],R=k.enter("tableRow");for(;++S<v.length;)L[S]=u(v[S],g,k,C);return R(),L}function m(g,k,C){let v=Ih.inlineCode(g,k,C);return C.stack.includes("tableCell")&&(v=v.replace(/\|/g,"\\$&")),v}}function zB(){return{exit:{taskListCheckValueChecked:Ey,taskListCheckValueUnchecked:Ey,paragraph:WB}}}function $B(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:VB}}}function Ey(n){const e=this.stack[this.stack.length-2];e.type,e.checked=n.type==="taskListCheckValueChecked"}function WB(n){const e=this.stack[this.stack.length-2];if(e&&e.type==="listItem"&&typeof e.checked=="boolean"){const t=this.stack[this.stack.length-1];t.type;const r=t.children[0];if(r&&r.type==="text"){const i=e.children;let o=-1,s;for(;++o<i.length;){const a=i[o];if(a.type==="paragraph"){s=a;break}}s===t&&(r.value=r.value.slice(1),r.value.length===0?t.children.shift():t.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,t.position.start=Object.assign({},r.position.start)))}}this.exit(n)}function VB(n,e,t,r){const i=n.children[0],o=typeof n.checked=="boolean"&&i&&i.type==="paragraph",s="["+(n.checked?"x":" ")+"] ",a=t.createTracker(r);o&&a.move(s);let u=Ih.listItem(n,e,t,{...r,...a.current()});return o&&(u=u.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,f)),u;function f(h){return h+s}}function HB(){return[ZP(),xB(),vB(),RB(),zB()]}function qB(n){return{extensions:[eB(),wB(n),TB(),FB(n),$B()]}}const KB={tokenize:XB,partial:!0},pb={tokenize:QB,partial:!0},mb={tokenize:ZB,partial:!0},gb={tokenize:eF,partial:!0},UB={tokenize:tF,partial:!0},yb={name:"wwwAutolink",tokenize:GB,previous:bb},kb={name:"protocolAutolink",tokenize:YB,previous:xb},Sr={name:"emailAutolink",tokenize:JB,previous:wb},Qn={};function jB(){return{text:Qn}}let gi=48;for(;gi<123;)Qn[gi]=Sr,gi++,gi===58?gi=65:gi===91&&(gi=97);Qn[43]=Sr;Qn[45]=Sr;Qn[46]=Sr;Qn[95]=Sr;Qn[72]=[Sr,kb];Qn[104]=[Sr,kb];Qn[87]=[Sr,yb];Qn[119]=[Sr,yb];function JB(n,e,t){const r=this;let i,o;return s;function s(d){return!bh(d)||!wb.call(r,r.previous)||rd(r.events)?t(d):(n.enter("literalAutolink"),n.enter("literalAutolinkEmail"),a(d))}function a(d){return bh(d)?(n.consume(d),a):d===64?(n.consume(d),u):t(d)}function u(d){return d===46?n.check(UB,h,f)(d):d===45||d===95||_t(d)?(o=!0,n.consume(d),u):h(d)}function f(d){return n.consume(d),i=!0,u}function h(d){return o&&i&&St(r.previous)?(n.exit("literalAutolinkEmail"),n.exit("literalAutolink"),e(d)):t(d)}}function GB(n,e,t){const r=this;return i;function i(s){return s!==87&&s!==119||!bb.call(r,r.previous)||rd(r.events)?t(s):(n.enter("literalAutolink"),n.enter("literalAutolinkWww"),n.check(KB,n.attempt(pb,n.attempt(mb,o),t),t)(s))}function o(s){return n.exit("literalAutolinkWww"),n.exit("literalAutolink"),e(s)}}function YB(n,e,t){const r=this;let i="",o=!1;return s;function s(d){return(d===72||d===104)&&xb.call(r,r.previous)&&!rd(r.events)?(n.enter("literalAutolink"),n.enter("literalAutolinkHttp"),i+=String.fromCodePoint(d),n.consume(d),a):t(d)}function a(d){if(St(d)&&i.length<5)return i+=String.fromCodePoint(d),n.consume(d),a;if(d===58){const m=i.toLowerCase();if(m==="http"||m==="https")return n.consume(d),u}return t(d)}function u(d){return d===47?(n.consume(d),o?f:(o=!0,u)):t(d)}function f(d){return d===null||ba(d)||Fe(d)||Di(d)||Qa(d)?t(d):n.attempt(pb,n.attempt(mb,h),t)(d)}function h(d){return n.exit("literalAutolinkHttp"),n.exit("literalAutolink"),e(d)}}function XB(n,e,t){let r=0;return i;function i(s){return(s===87||s===119)&&r<3?(r++,n.consume(s),i):s===46&&r===3?(n.consume(s),o):t(s)}function o(s){return s===null?t(s):e(s)}}function QB(n,e,t){let r,i,o;return s;function s(f){return f===46||f===95?n.check(gb,u,a)(f):f===null||Fe(f)||Di(f)||f!==45&&Qa(f)?u(f):(o=!0,n.consume(f),s)}function a(f){return f===95?r=!0:(i=r,r=void 0),n.consume(f),s}function u(f){return i||r||!o?t(f):e(f)}}function ZB(n,e){let t=0,r=0;return i;function i(s){return s===40?(t++,n.consume(s),i):s===41&&r<t?o(s):s===33||s===34||s===38||s===39||s===41||s===42||s===44||s===46||s===58||s===59||s===60||s===63||s===93||s===95||s===126?n.check(gb,e,o)(s):s===null||Fe(s)||Di(s)?e(s):(n.consume(s),i)}function o(s){return s===41&&r++,n.consume(s),i}}function eF(n,e,t){return r;function r(a){return a===33||a===34||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===63||a===95||a===126?(n.consume(a),r):a===38?(n.consume(a),o):a===93?(n.consume(a),i):a===60||a===null||Fe(a)||Di(a)?e(a):t(a)}function i(a){return a===null||a===40||a===91||Fe(a)||Di(a)?e(a):r(a)}function o(a){return St(a)?s(a):t(a)}function s(a){return a===59?(n.consume(a),r):St(a)?(n.consume(a),s):t(a)}}function tF(n,e,t){return r;function r(o){return n.consume(o),i}function i(o){return _t(o)?t(o):e(o)}}function bb(n){return n===null||n===40||n===42||n===95||n===91||n===93||n===126||Fe(n)}function xb(n){return!St(n)}function wb(n){return!(n===47||bh(n))}function bh(n){return n===43||n===45||n===46||n===95||_t(n)}function rd(n){let e=n.length,t=!1;for(;e--;){const r=n[e][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){t=!0;break}if(r._gfmAutolinkLiteralWalkedInto){t=!1;break}}return n.length>0&&!t&&(n[n.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),t}const nF={tokenize:cF,partial:!0};function rF(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:lF,continuation:{tokenize:aF},exit:uF}},text:{91:{name:"gfmFootnoteCall",tokenize:sF},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:iF,resolveTo:oF}}}}function iF(n,e,t){const r=this;let i=r.events.length;const o=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s;for(;i--;){const u=r.events[i][1];if(u.type==="labelImage"){s=u;break}if(u.type==="gfmFootnoteCall"||u.type==="labelLink"||u.type==="label"||u.type==="image"||u.type==="link")break}return a;function a(u){if(!s||!s._balanced)return t(u);const f=_n(r.sliceSerialize({start:s.end,end:r.now()}));return f.codePointAt(0)!==94||!o.includes(f.slice(1))?t(u):(n.enter("gfmFootnoteCallLabelMarker"),n.consume(u),n.exit("gfmFootnoteCallLabelMarker"),e(u))}}function oF(n,e){let t=n.length;for(;t--;)if(n[t][1].type==="labelImage"&&n[t][0]==="enter"){n[t][1];break}n[t+1][1].type="data",n[t+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},n[t+3][1].start),end:Object.assign({},n[n.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},n[t+3][1].end),end:Object.assign({},n[t+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const o={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},n[n.length-1][1].start)},s={type:"chunkString",contentType:"string",start:Object.assign({},o.start),end:Object.assign({},o.end)},a=[n[t+1],n[t+2],["enter",r,e],n[t+3],n[t+4],["enter",i,e],["exit",i,e],["enter",o,e],["enter",s,e],["exit",s,e],["exit",o,e],n[n.length-2],n[n.length-1],["exit",r,e]];return n.splice(t,n.length-t+1,...a),n}function sF(n,e,t){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o=0,s;return a;function a(d){return n.enter("gfmFootnoteCall"),n.enter("gfmFootnoteCallLabelMarker"),n.consume(d),n.exit("gfmFootnoteCallLabelMarker"),u}function u(d){return d!==94?t(d):(n.enter("gfmFootnoteCallMarker"),n.consume(d),n.exit("gfmFootnoteCallMarker"),n.enter("gfmFootnoteCallString"),n.enter("chunkString").contentType="string",f)}function f(d){if(o>999||d===93&&!s||d===null||d===91||Fe(d))return t(d);if(d===93){n.exit("chunkString");const m=n.exit("gfmFootnoteCallString");return i.includes(_n(r.sliceSerialize(m)))?(n.enter("gfmFootnoteCallLabelMarker"),n.consume(d),n.exit("gfmFootnoteCallLabelMarker"),n.exit("gfmFootnoteCall"),e):t(d)}return Fe(d)||(s=!0),o++,n.consume(d),d===92?h:f}function h(d){return d===91||d===92||d===93?(n.consume(d),o++,f):f(d)}}function lF(n,e,t){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o,s=0,a;return u;function u(k){return n.enter("gfmFootnoteDefinition")._container=!0,n.enter("gfmFootnoteDefinitionLabel"),n.enter("gfmFootnoteDefinitionLabelMarker"),n.consume(k),n.exit("gfmFootnoteDefinitionLabelMarker"),f}function f(k){return k===94?(n.enter("gfmFootnoteDefinitionMarker"),n.consume(k),n.exit("gfmFootnoteDefinitionMarker"),n.enter("gfmFootnoteDefinitionLabelString"),n.enter("chunkString").contentType="string",h):t(k)}function h(k){if(s>999||k===93&&!a||k===null||k===91||Fe(k))return t(k);if(k===93){n.exit("chunkString");const C=n.exit("gfmFootnoteDefinitionLabelString");return o=_n(r.sliceSerialize(C)),n.enter("gfmFootnoteDefinitionLabelMarker"),n.consume(k),n.exit("gfmFootnoteDefinitionLabelMarker"),n.exit("gfmFootnoteDefinitionLabel"),m}return Fe(k)||(a=!0),s++,n.consume(k),k===92?d:h}function d(k){return k===91||k===92||k===93?(n.consume(k),s++,h):h(k)}function m(k){return k===58?(n.enter("definitionMarker"),n.consume(k),n.exit("definitionMarker"),i.includes(o)||i.push(o),Ae(n,g,"gfmFootnoteDefinitionWhitespace")):t(k)}function g(k){return e(k)}}function aF(n,e,t){return n.check(Us,e,n.attempt(nF,e,t))}function uF(n){n.exit("gfmFootnoteDefinition")}function cF(n,e,t){const r=this;return Ae(n,i,"gfmFootnoteDefinitionIndent",5);function i(o){const s=r.events[r.events.length-1];return s&&s[1].type==="gfmFootnoteDefinitionIndent"&&s[2].sliceSerialize(s[1],!0).length===4?e(o):t(o)}}function fF(n){let t=(n||{}).singleTilde;const r={name:"strikethrough",tokenize:o,resolveAll:i};return t==null&&(t=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(s,a){let u=-1;for(;++u<s.length;)if(s[u][0]==="enter"&&s[u][1].type==="strikethroughSequenceTemporary"&&s[u][1]._close){let f=u;for(;f--;)if(s[f][0]==="exit"&&s[f][1].type==="strikethroughSequenceTemporary"&&s[f][1]._open&&s[u][1].end.offset-s[u][1].start.offset===s[f][1].end.offset-s[f][1].start.offset){s[u][1].type="strikethroughSequence",s[f][1].type="strikethroughSequence";const h={type:"strikethrough",start:Object.assign({},s[f][1].start),end:Object.assign({},s[u][1].end)},d={type:"strikethroughText",start:Object.assign({},s[f][1].end),end:Object.assign({},s[u][1].start)},m=[["enter",h,a],["enter",s[f][1],a],["exit",s[f][1],a],["enter",d,a]],g=a.parser.constructs.insideSpan.null;g&&Qt(m,m.length,0,Za(g,s.slice(f+1,u),a)),Qt(m,m.length,0,[["exit",d,a],["enter",s[u][1],a],["exit",s[u][1],a],["exit",h,a]]),Qt(s,f-1,u-f+3,m),u=f+m.length-2;break}}for(u=-1;++u<s.length;)s[u][1].type==="strikethroughSequenceTemporary"&&(s[u][1].type="data");return s}function o(s,a,u){const f=this.previous,h=this.events;let d=0;return m;function m(k){return f===126&&h[h.length-1][1].type!=="characterEscape"?u(k):(s.enter("strikethroughSequenceTemporary"),g(k))}function g(k){const C=To(f);if(k===126)return d>1?u(k):(s.consume(k),d++,g);if(d<2&&!t)return u(k);const v=s.exit("strikethroughSequenceTemporary"),S=To(k);return v._open=!S||S===2&&!!C,v._close=!C||C===2&&!!S,a(k)}}}class hF{constructor(){this.map=[]}add(e,t,r){dF(this,e,t,r)}consume(e){if(this.map.sort(function(o,s){return o[0]-s[0]}),this.map.length===0)return;let t=this.map.length;const 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(const o of i)e.push(o);i=r.pop()}this.map.length=0}}function dF(n,e,t,r){let i=0;if(!(t===0&&r.length===0)){for(;i<n.map.length;){if(n.map[i][0]===e){n.map[i][1]+=t,n.map[i][2].push(...r);return}i+=1}n.map.push([e,t,r])}}function pF(n,e){let t=!1;const r=[];for(;e<n.length;){const i=n[e];if(t){if(i[0]==="enter")i[1].type==="tableContent"&&r.push(n[e+1][1].type==="tableDelimiterMarker"?"left":"none");else if(i[1].type==="tableContent"){if(n[e-1][1].type==="tableDelimiterMarker"){const o=r.length-1;r[o]=r[o]==="left"?"center":"right"}}else if(i[1].type==="tableDelimiterRow")break}else i[0]==="enter"&&i[1].type==="tableDelimiterRow"&&(t=!0);e+=1}return r}function mF(){return{flow:{null:{name:"table",tokenize:gF,resolveAll:yF}}}}function gF(n,e,t){const r=this;let i=0,o=0,s;return a;function a(D){let Q=r.events.length-1;for(;Q>-1;){const Te=r.events[Q][1].type;if(Te==="lineEnding"||Te==="linePrefix")Q--;else break}const ee=Q>-1?r.events[Q][1].type:null,Ie=ee==="tableHead"||ee==="tableRow"?O:u;return Ie===O&&r.parser.lazy[r.now().line]?t(D):Ie(D)}function u(D){return n.enter("tableHead"),n.enter("tableRow"),f(D)}function f(D){return D===124||(s=!0,o+=1),h(D)}function h(D){return D===null?t(D):ne(D)?o>1?(o=0,r.interrupt=!0,n.exit("tableRow"),n.enter("lineEnding"),n.consume(D),n.exit("lineEnding"),g):t(D):Ce(D)?Ae(n,h,"whitespace")(D):(o+=1,s&&(s=!1,i+=1),D===124?(n.enter("tableCellDivider"),n.consume(D),n.exit("tableCellDivider"),s=!0,h):(n.enter("data"),d(D)))}function d(D){return D===null||D===124||Fe(D)?(n.exit("data"),h(D)):(n.consume(D),D===92?m:d)}function m(D){return D===92||D===124?(n.consume(D),d):d(D)}function g(D){return r.interrupt=!1,r.parser.lazy[r.now().line]?t(D):(n.enter("tableDelimiterRow"),s=!1,Ce(D)?Ae(n,k,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(D):k(D))}function k(D){return D===45||D===58?v(D):D===124?(s=!0,n.enter("tableCellDivider"),n.consume(D),n.exit("tableCellDivider"),C):q(D)}function C(D){return Ce(D)?Ae(n,v,"whitespace")(D):v(D)}function v(D){return D===58?(o+=1,s=!0,n.enter("tableDelimiterMarker"),n.consume(D),n.exit("tableDelimiterMarker"),S):D===45?(o+=1,S(D)):D===null||ne(D)?K(D):q(D)}function S(D){return D===45?(n.enter("tableDelimiterFiller"),L(D)):q(D)}function L(D){return D===45?(n.consume(D),L):D===58?(s=!0,n.exit("tableDelimiterFiller"),n.enter("tableDelimiterMarker"),n.consume(D),n.exit("tableDelimiterMarker"),R):(n.exit("tableDelimiterFiller"),R(D))}function R(D){return Ce(D)?Ae(n,K,"whitespace")(D):K(D)}function K(D){return D===124?k(D):D===null||ne(D)?!s||i!==o?q(D):(n.exit("tableDelimiterRow"),n.exit("tableHead"),e(D)):q(D)}function q(D){return t(D)}function O(D){return n.enter("tableRow"),H(D)}function H(D){return D===124?(n.enter("tableCellDivider"),n.consume(D),n.exit("tableCellDivider"),H):D===null||ne(D)?(n.exit("tableRow"),e(D)):Ce(D)?Ae(n,H,"whitespace")(D):(n.enter("data"),X(D))}function X(D){return D===null||D===124||Fe(D)?(n.exit("data"),H(D)):(n.consume(D),D===92?te:X)}function te(D){return D===92||D===124?(n.consume(D),X):X(D)}}function yF(n,e){let t=-1,r=!0,i=0,o=[0,0,0,0],s=[0,0,0,0],a=!1,u=0,f,h,d;const m=new hF;for(;++t<n.length;){const g=n[t],k=g[1];g[0]==="enter"?k.type==="tableHead"?(a=!1,u!==0&&(Oy(m,e,u,f,h),h=void 0,u=0),f={type:"table",start:Object.assign({},k.start),end:Object.assign({},k.end)},m.add(t,0,[["enter",f,e]])):k.type==="tableRow"||k.type==="tableDelimiterRow"?(r=!0,d=void 0,o=[0,0,0,0],s=[0,t+1,0,0],a&&(a=!1,h={type:"tableBody",start:Object.assign({},k.start),end:Object.assign({},k.end)},m.add(t,0,[["enter",h,e]])),i=k.type==="tableDelimiterRow"?2:h?3:1):i&&(k.type==="data"||k.type==="tableDelimiterMarker"||k.type==="tableDelimiterFiller")?(r=!1,s[2]===0&&(o[1]!==0&&(s[0]=s[1],d=sa(m,e,o,i,void 0,d),o=[0,0,0,0]),s[2]=t)):k.type==="tableCellDivider"&&(r?r=!1:(o[1]!==0&&(s[0]=s[1],d=sa(m,e,o,i,void 0,d)),o=s,s=[o[1],t,0,0])):k.type==="tableHead"?(a=!0,u=t):k.type==="tableRow"||k.type==="tableDelimiterRow"?(u=t,o[1]!==0?(s[0]=s[1],d=sa(m,e,o,i,t,d)):s[1]!==0&&(d=sa(m,e,s,i,t,d)),i=0):i&&(k.type==="data"||k.type==="tableDelimiterMarker"||k.type==="tableDelimiterFiller")&&(s[3]=t)}for(u!==0&&Oy(m,e,u,f,h),m.consume(e.events),t=-1;++t<e.events.length;){const g=e.events[t];g[0]==="enter"&&g[1].type==="table"&&(g[1]._align=pF(e.events,t))}return n}function sa(n,e,t,r,i,o){const s=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",a="tableContent";t[0]!==0&&(o.end=Object.assign({},ho(e.events,t[0])),n.add(t[0],0,[["exit",o,e]]));const u=ho(e.events,t[1]);if(o={type:s,start:Object.assign({},u),end:Object.assign({},u)},n.add(t[1],0,[["enter",o,e]]),t[2]!==0){const f=ho(e.events,t[2]),h=ho(e.events,t[3]),d={type:a,start:Object.assign({},f),end:Object.assign({},h)};if(n.add(t[2],0,[["enter",d,e]]),r!==2){const m=e.events[t[2]],g=e.events[t[3]];if(m[1].end=Object.assign({},g[1].end),m[1].type="chunkText",m[1].contentType="text",t[3]>t[2]+1){const k=t[2]+1,C=t[3]-t[2]-1;n.add(k,C,[])}}n.add(t[3]+1,0,[["exit",d,e]])}return i!==void 0&&(o.end=Object.assign({},ho(e.events,i)),n.add(i,0,[["exit",o,e]]),o=void 0),o}function Oy(n,e,t,r,i){const o=[],s=ho(e.events,t);i&&(i.end=Object.assign({},s),o.push(["exit",i,e])),r.end=Object.assign({},s),o.push(["exit",r,e]),n.add(t+1,0,o)}function ho(n,e){const t=n[e],r=t[0]==="enter"?"start":"end";return t[1][r]}const kF={name:"tasklistCheck",tokenize:xF};function bF(){return{text:{91:kF}}}function xF(n,e,t){const r=this;return i;function i(u){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?t(u):(n.enter("taskListCheck"),n.enter("taskListCheckMarker"),n.consume(u),n.exit("taskListCheckMarker"),o)}function o(u){return Fe(u)?(n.enter("taskListCheckValueUnchecked"),n.consume(u),n.exit("taskListCheckValueUnchecked"),s):u===88||u===120?(n.enter("taskListCheckValueChecked"),n.consume(u),n.exit("taskListCheckValueChecked"),s):t(u)}function s(u){return u===93?(n.enter("taskListCheckMarker"),n.consume(u),n.exit("taskListCheckMarker"),n.exit("taskListCheck"),a):t(u)}function a(u){return ne(u)?e(u):Ce(u)?n.check({tokenize:wF},e,t)(u):t(u)}}function wF(n,e,t){return Ae(n,r,"whitespace");function r(i){return i===null?t(i):e(i)}}function CF(n){return Qy([jB(),rF(),fF(n),mF(),bF()])}const SF={};function vF(n){const e=this,t=n||SF,r=e.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),o=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),s=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(CF(t)),o.push(HB()),s.push(qB(t))}function le(n,e){return Object.assign(n,{meta:{package:"@milkdown/preset-gfm",...e}}),n}var Cb=Xs("strike_through");le(Cb,{displayName:"Attr<strikethrough>",group:"Strikethrough"});var ku=Po("strike_through",n=>({parseDOM:[{tag:"del"},{style:"text-decoration",getAttrs:e=>e==="line-through"}],toDOM:e=>["del",n.get(Cb.key)(e)],parseMarkdown:{match:e=>e.type==="delete",runner:(e,t,r)=>{e.openMark(r),e.next(t.children),e.closeMark(r)}},toMarkdown:{match:e=>e.type.name==="strike_through",runner:(e,t)=>{e.withMark(t,"delete")}}}));le(ku.mark,{displayName:"MarkSchema<strikethrough>",group:"Strikethrough"});le(ku.ctx,{displayName:"MarkSchemaCtx<strikethrough>",group:"Strikethrough"});var Sb=fe("ToggleStrikeThrough",n=>()=>au(ku.type(n)));le(Sb,{displayName:"Command<ToggleStrikethrough>",group:"Strikethrough"});var TF=Ft(n=>nn.markRule(new RegExp("(?<![\\w:/])(~{1,2})(.+?)\\1(?!\\w|\\/)"),ku.type(n)));le(TF,{displayName:"InputRule<strikethrough>",group:"Strikethrough"});var vb=rn("strikeThroughKeymap",{ToggleStrikethrough:{shortcuts:"Mod-Alt-x",command:n=>{const e=n.get(Pe);return()=>e.call(Sb.key)}}});le(vb.ctx,{displayName:"KeymapCtx<strikethrough>",group:"Strikethrough"});le(vb.shortcuts,{displayName:"Keymap<strikethrough>",group:"Strikethrough"});var rl=rL({tableGroup:"block",cellContent:"paragraph",cellAttributes:{alignment:{default:"left",getFromDOM:n=>n.style.textAlign||"left",setDOMAttr:(n,e)=>{e.style=`text-align: ${n||"left"}`}}}}),wr=rt("table",()=>({...rl.table,content:"table_header_row table_row+",disableDropCursor:!0,parseMarkdown:{match:n=>n.type==="table",runner:(n,e,t)=>{const r=e.align,i=e.children.map((o,s)=>({...o,align:r,isHeader:s===0}));n.openNode(t),n.next(i),n.closeNode()}},toMarkdown:{match:n=>n.type.name==="table",runner:(n,e)=>{var i;const t=(i=e.content.firstChild)==null?void 0:i.content;if(!t)return;const r=[];t.forEach(o=>{r.push(o.attrs.alignment)}),n.openNode("table",void 0,{align:r}),n.next(e.content),n.closeNode()}}}));le(wr.node,{displayName:"NodeSchema<table>",group:"Table"});le(wr.ctx,{displayName:"NodeSchemaCtx<table>",group:"Table"});var bu=rt("table_header_row",()=>({...rl.table_row,disableDropCursor:!0,content:"(table_header)*",parseDOM:[{tag:"tr[data-is-header]"},{tag:"tr",getAttrs:n=>n instanceof HTMLElement&&n.querySelector("th")?{}:!1}],toDOM(){return["tr",{"data-is-header":!0},0]},parseMarkdown:{match:n=>!!(n.type==="tableRow"&&n.isHeader),runner:(n,e,t)=>{const r=e.align,i=e.children.map((o,s)=>({...o,align:r[s],isHeader:e.isHeader}));n.openNode(t),n.next(i),n.closeNode()}},toMarkdown:{match:n=>n.type.name==="table_header_row",runner:(n,e)=>{e.content.size!==0&&(n.openNode("tableRow",void 0,{isHeader:!0}),n.next(e.content),n.closeNode())}}}));le(bu.node,{displayName:"NodeSchema<tableHeaderRow>",group:"Table"});le(bu.ctx,{displayName:"NodeSchemaCtx<tableHeaderRow>",group:"Table"});var il=rt("table_row",()=>({...rl.table_row,disableDropCursor:!0,content:"(table_cell)*",parseMarkdown:{match:n=>n.type==="tableRow",runner:(n,e,t)=>{const r=e.align,i=e.children.map((o,s)=>({...o,align:r[s]}));n.openNode(t),n.next(i),n.closeNode()}},toMarkdown:{match:n=>n.type.name==="table_row",runner:(n,e)=>{e.content.size!==0&&(n.openNode("tableRow"),n.next(e.content),n.closeNode())}}}));le(il.node,{displayName:"NodeSchema<tableRow>",group:"Table"});le(il.ctx,{displayName:"NodeSchemaCtx<tableRow>",group:"Table"});var xu=rt("table_cell",()=>({...rl.table_cell,disableDropCursor:!0,parseMarkdown:{match:n=>n.type==="tableCell"&&!n.isHeader,runner:(n,e,t)=>{const r=e.align;n.openNode(t,{alignment:r}).openNode(n.schema.nodes.paragraph).next(e.children).closeNode().closeNode()}},toMarkdown:{match:n=>n.type.name==="table_cell",runner:(n,e)=>{n.openNode("tableCell").next(e.content).closeNode()}}}));le(xu.node,{displayName:"NodeSchema<tableCell>",group:"Table"});le(xu.ctx,{displayName:"NodeSchemaCtx<tableCell>",group:"Table"});var Is=rt("table_header",()=>({...rl.table_header,disableDropCursor:!0,parseMarkdown:{match:n=>n.type==="tableCell"&&!!n.isHeader,runner:(n,e,t)=>{const r=e.align;n.openNode(t,{alignment:r}),n.openNode(n.schema.nodes.paragraph),n.next(e.children),n.closeNode(),n.closeNode()}},toMarkdown:{match:n=>n.type.name==="table_header",runner:(n,e)=>{n.openNode("tableCell"),n.next(e.content),n.closeNode()}}}));le(Is.node,{displayName:"NodeSchema<tableHeader>",group:"Table"});le(Is.ctx,{displayName:"NodeSchemaCtx<tableHeader>",group:"Table"});function Tb(n,e=3,t=3){const r=Array(t).fill(0).map(()=>xu.type(n).createAndFill()),i=Array(t).fill(0).map(()=>Is.type(n).createAndFill()),o=Array(e).fill(0).map((s,a)=>a===0?bu.type(n).create(null,i):il.type(n).create(null,r));return wr.type(n).create(null,o)}function Ab(n){return(e,t)=>r=>{t=t??r.selection.from;const i=r.doc.resolve(t),o=nn.findParentNodeClosestToPos(u=>u.type.name==="table")(i),s=o?{node:o.node,from:o.start}:void 0,a=n==="row";if(s){const u=Le.get(s.node);if(e>=0&&e<(a?u.height:u.width)){const f=u.positionAt(a?e:u.height-1,a?u.width-1:e,s.node),h=r.doc.resolve(s.from+f),d=a?Ve.rowSelection:Ve.colSelection,m=u.positionAt(a?e:0,a?0:e,s.node),g=r.doc.resolve(s.from+m);return nn.cloneTr(r.setSelection(d(h,g)))}}return r}}var AF=Ab("row"),NF=Ab("col");function Nb(n,e,{map:t,tableStart:r,table:i},o){const s=Array(o).fill(0).reduce((u,f,h)=>u+i.child(h).nodeSize,r),a=Array(t.width).fill(0).map((u,f)=>{const h=i.nodeAt(t.map[f]);return xu.type(n).createAndFill({alignment:h==null?void 0:h.attrs.alignment})});return e.insert(s,il.type(n).create(null,a)),e}function MF(n){const e=Qs(n.$from);if(!e)return;const t=Le.get(e.node);return t.cellsInRect({left:0,right:t.width,top:0,bottom:t.height}).map(r=>{const i=e.node.nodeAt(r),o=r+e.start;return{pos:o,start:o+1,node:i}})}function IF(n){const e=MF(n.selection);if(e&&e[0]){const t=n.doc.resolve(e[0].pos),r=e[e.length-1];if(r){const i=n.doc.resolve(r.pos);return nn.cloneTr(n.setSelection(new Ve(i,t)))}}return n}var Mb=fe("GoToPrevTableCell",()=>()=>dk(-1));le(Mb,{displayName:"Command<goToPrevTableCellCommand>",group:"Table"});var Ib=fe("GoToNextTableCell",()=>()=>dk(1));le(Ib,{displayName:"Command<goToNextTableCellCommand>",group:"Table"});var Eb=fe("ExitTable",n=>()=>(e,t)=>{if(!vn(e))return!1;const{$head:r}=e.selection,i=nn.findParentNodeType(r,wr.type(n));if(!i)return!1;const{to:o}=i,s=e.tr.replaceWith(o,o,Cr.type(n).createAndFill());return s.setSelection(de.near(s.doc.resolve(o),1)).scrollIntoView(),t==null||t(s),!0});le(Eb,{displayName:"Command<breakTableCommand>",group:"Table"});var EF=fe("InsertTable",n=>({row:e,col:t}={})=>(r,i)=>{const{selection:o,tr:s}=r,{from:a}=o,u=Tb(n,e,t),f=s.replaceSelectionWith(u),h=de.findFrom(f.doc.resolve(a),1,!0);return h&&f.setSelection(h),i==null||i(f),!0});le(EF,{displayName:"Command<insertTableCommand>",group:"Table"});var OF=fe("MoveRow",()=>({from:n,to:e,pos:t}={})=>OL({from:n??0,to:e??0,pos:t}));le(OF,{displayName:"Command<moveRowCommand>",group:"Table"});var RF=fe("MoveCol",()=>({from:n,to:e,pos:t}={})=>RL({from:n??0,to:e??0,pos:t}));le(RF,{displayName:"Command<moveColCommand>",group:"Table"});var _F=fe("SelectRow",()=>(n={index:0})=>(e,t)=>{const{tr:r}=e;return!!(t==null?void 0:t(AF(n.index,n.pos)(r)))});le(_F,{displayName:"Command<selectRowCommand>",group:"Table"});var DF=fe("SelectCol",()=>(n={index:0})=>(e,t)=>{const{tr:r}=e;return!!(t==null?void 0:t(NF(n.index,n.pos)(r)))});le(DF,{displayName:"Command<selectColCommand>",group:"Table"});var LF=fe("SelectTable",()=>()=>(n,e)=>{const{tr:t}=n;return!!(e==null?void 0:e(IF(t)))});le(LF,{displayName:"Command<selectTableCommand>",group:"Table"});var PF=fe("DeleteSelectedCells",()=>()=>(n,e)=>{const{selection:t}=n;if(!(t instanceof Ve))return!1;const r=t.isRowSelection(),i=t.isColSelection();return r&&i?EL(n,e):i?vL(n,e):AL(n,e)});le(PF,{displayName:"Command<deleteSelectedCellsCommand>",group:"Table"});var BF=fe("AddColBefore",()=>()=>wL);le(BF,{displayName:"Command<addColBeforeCommand>",group:"Table"});var FF=fe("AddColAfter",()=>()=>CL);le(FF,{displayName:"Command<addColAfterCommand>",group:"Table"});var zF=fe("AddRowBefore",n=>()=>(e,t)=>{if(!vn(e))return!1;if(t){const r=ti(e);t(Nb(n,e.tr,r,r.top))}return!0});le(zF,{displayName:"Command<addRowBeforeCommand>",group:"Table"});var $F=fe("AddRowAfter",n=>()=>(e,t)=>{if(!vn(e))return!1;if(t){const r=ti(e);t(Nb(n,e.tr,r,r.bottom))}return!0});le($F,{displayName:"Command<addRowAfterCommand>",group:"Table"});var WF=fe("SetAlign",()=>(n="left")=>NL("alignment",n));le(WF,{displayName:"Command<setAlignCommand>",group:"Table"});var VF=Ft(n=>new Cn(/^\|(?<col>\d+)[xX](?<row>\d+)\|\s$/,(e,t,r,i)=>{var u,f;const o=e.doc.resolve(r);if(!o.node(-1).canReplaceWith(o.index(-1),o.indexAfter(-1),wr.type(n)))return null;const s=Tb(n,Math.max(Number(((u=t.groups)==null?void 0:u.row)??0),2),Number((f=t.groups)==null?void 0:f.col)),a=e.tr.replaceRangeWith(r,i,s);return a.setSelection(pe.create(a.doc,r+3)).scrollIntoView()}));le(VF,{displayName:"InputRule<insertTableInputRule>",group:"Table"});var HF=jD(n=>({run:(e,t,r)=>{if(r)return e;function i(f){var v;const h=f.childCount,d=((v=f.lastChild)==null?void 0:v.childCount)??0;if(h===0||d===0)return Cr.type(n).create();const m=f.firstChild;if(!(d>0&&m&&m.childCount===0))return f;if(h>=3){const S=f.child(1),L=[];for(let q=0;q<S.childCount;q++){const O=S.child(q);L.push(Is.type(n).create(O.attrs,O.content,O.marks))}const R=m.type.create(m.attrs,L),K=[];for(let q=2;q<h;q++)K.push(f.child(q));return f.type.create(f.attrs,[R,...K])}const g=Array(d).fill(0).map(()=>Is.type(n).createAndFill()),k=new J(W.from(g),0,0),C=m.replace(0,0,k);return f.replace(0,m.nodeSize,new J(W.from(C),0,0))}function o(f){const h=il.type(n),d=[];let m=[],g=!1;function k(){if(m.length===0)return;const C=bu.type(n).createAndFill(),v=wr.type(n).create(null,[C,...m]);d.push(i(v)),m=[]}return f.forEach(C=>{C.type===h?(g=!0,m.push(C)):(k(),d.push(C))}),k(),g?W.from(d):f}function s(f){let h=o(f),d=h!==f;const m=[];return h.forEach(g=>{if(g.type===wr.type(n)){const k=i(g);k!==g&&(d=!0),m.push(k)}else if(g.childCount>0){const k=s(g.content);k!==g.content?(d=!0,m.push(g.copy(k))):m.push(g)}else m.push(g)}),d?W.from(m):f}function a(f){const h=[],d=[];f.forEach(m=>d.push(m));for(let m=0;m<d.length;m++){const g=d[m],k=d[m+1];g.type===Cr.type(n)&&g.content.size===0&&k&&k.type===wr.type(n)||h.push(g)}return h.length<d.length?W.from(h):f}let u=s(e.content);return u=a(u),new J(W.from(u),e.openStart,e.openEnd)}}));le(HF,{displayName:"PasteRule<table>",group:"Table"});var Ob=rn("tableKeymap",{NextCell:{priority:100,shortcuts:["Mod-]","Tab"],command:n=>{const e=n.get(Pe);return()=>e.call(Ib.key)}},PrevCell:{shortcuts:["Mod-[","Shift-Tab"],command:n=>{const e=n.get(Pe);return()=>e.call(Mb.key)}},ExitTable:{shortcuts:["Mod-Enter","Enter"],command:n=>{const e=n.get(Pe);return()=>e.call(Eb.key)}}});le(Ob.ctx,{displayName:"KeymapCtx<table>",group:"Table"});le(Ob.shortcuts,{displayName:"Keymap<table>",group:"Table"});var Rf="footnote_definition",Ry="footnoteDefinition",Rb=rt("footnote_definition",()=>({group:"block",content:"block+",defining:!0,attrs:{label:{default:"",validate:"string"}},parseDOM:[{tag:`dl[data-type="${Rf}"]`,getAttrs:n=>{if(!(n instanceof HTMLElement))throw Xn(n);return{label:n.dataset.label}},contentElement:"dd"}],toDOM:n=>{const e=n.attrs.label;return["dl",{"data-label":e,"data-type":Rf},["dt",e],["dd",0]]},parseMarkdown:{match:({type:n})=>n===Ry,runner:(n,e,t)=>{n.openNode(t,{label:e.label}).next(e.children).closeNode()}},toMarkdown:{match:n=>n.type.name===Rf,runner:(n,e)=>{n.openNode(Ry,void 0,{label:e.attrs.label,identifier:e.attrs.label}).next(e.content).closeNode()}}}));le(Rb.ctx,{displayName:"NodeSchemaCtx<footnodeDef>",group:"footnote"});le(Rb.node,{displayName:"NodeSchema<footnodeDef>",group:"footnote"});var _f="footnote_reference",_b=rt("footnote_reference",()=>({group:"inline",inline:!0,atom:!0,attrs:{label:{default:"",validate:"string"}},parseDOM:[{tag:`sup[data-type="${_f}"]`,getAttrs:n=>{if(!(n instanceof HTMLElement))throw Xn(n);return{label:n.dataset.label}}}],toDOM:n=>{const e=n.attrs.label;return["sup",{"data-label":e,"data-type":_f},e]},parseMarkdown:{match:({type:n})=>n==="footnoteReference",runner:(n,e,t)=>{n.addNode(t,{label:e.label})}},toMarkdown:{match:n=>n.type.name===_f,runner:(n,e)=>{n.addNode("footnoteReference",void 0,void 0,{label:e.attrs.label,identifier:e.attrs.label})}}}));le(_b.ctx,{displayName:"NodeSchemaCtx<footnodeRef>",group:"footnote"});le(_b.node,{displayName:"NodeSchema<footnodeRef>",group:"footnote"});var Db=ni.extendSchema(n=>e=>{const t=n(e);return{...t,attrs:{...t.attrs,checked:{default:null,validate:"boolean|null"}},parseDOM:[{tag:'li[data-item-type="task"]',getAttrs:r=>{if(!(r instanceof HTMLElement))throw Xn(r);return{label:r.dataset.label,listType:r.dataset.listType,spread:r.dataset.spread,checked:r.dataset.checked?r.dataset.checked==="true":null}}},...(t==null?void 0:t.parseDOM)||[]],toDOM:r=>t.toDOM&&r.attrs.checked==null?t.toDOM(r):["li",{"data-item-type":"task","data-label":r.attrs.label,"data-list-type":r.attrs.listType,"data-spread":r.attrs.spread,"data-checked":r.attrs.checked},0],parseMarkdown:{match:({type:r})=>r==="listItem",runner:(r,i,o)=>{if(i.checked==null){t.parseMarkdown.runner(r,i,o);return}const s=i.label!=null?`${i.label}.`:"•",a=i.checked!=null?!!i.checked:null,u=i.label!=null?"ordered":"bullet",f=i.spread!=null?`${i.spread}`:"true";r.openNode(o,{label:s,listType:u,spread:f,checked:a}),r.next(i.children),r.closeNode()}},toMarkdown:{match:r=>r.type.name==="list_item",runner:(r,i)=>{if(i.attrs.checked==null){t.toMarkdown.runner(r,i);return}const o=i.attrs.label,s=i.attrs.listType,a=i.attrs.spread==="true",u=i.attrs.checked;r.openNode("listItem",void 0,{label:o,listType:s,spread:a,checked:u}),r.next(i.content),r.closeNode()}}}});le(Db.node,{displayName:"NodeSchema<taskListItem>",group:"ListItem"});le(Db.ctx,{displayName:"NodeSchemaCtx<taskListItem>",group:"ListItem"});var qF=Ft(()=>new Cn(/^\[(?<checked>\s|x)\]\s$/,(n,e,t,r)=>{var h;const i=n.doc.resolve(t);let o=0,s=i.node(o);for(;s&&s.type.name!=="list_item";)o--,s=i.node(o);if(!s||s.attrs.checked!=null)return null;const a=((h=e.groups)==null?void 0:h.checked)==="x",u=i.before(o),f=n.tr;return f.deleteRange(t,r).setNodeMarkup(u,void 0,{...s.attrs,checked:a}),f}));le(qF,{displayName:"InputRule<wrapInTaskListInputRule>",group:"ListItem"});var KF=Pn(()=>jP);le(KF,{displayName:"Prose<autoInsertSpanPlugin>",group:"Prose"});var UF=Pn(()=>VL({}));le(UF,{displayName:"Prose<columnResizingPlugin>",group:"Prose"});var jF=Pn(()=>QL({allowTableNodeSelection:!0}));le(jF,{displayName:"Prose<tableEditingPlugin>",group:"Prose"});var Lb=Hi("remarkGFM",()=>vF);le(Lb.plugin,{displayName:"Remark<remarkGFMPlugin>",group:"Remark"});le(Lb.options,{displayName:"RemarkConfig<remarkGFMPlugin>",group:"Remark"});var JF=new Bt("MILKDOWN_KEEP_TABLE_ALIGN_PLUGIN");function GF(n,e){let t=0;return e.forEach((r,i,o)=>{r===n&&(t=o)}),t}var YF=Pn(()=>new Pt({key:JF,appendTransaction:(n,e,t)=>{let r;const i=(o,s)=>{if(r||(r=t.tr),o.type.name!=="table_cell")return;const a=t.doc.resolve(s),u=a.node(a.depth),f=a.node(a.depth-1).firstChild;if(!f)return;const h=GF(o,u),d=f.maybeChild(h);if(!d)return;const m=d.attrs.alignment;m!==o.attrs.alignment&&r.setNodeMarkup(s,void 0,{...o.attrs,alignment:m})};return e.doc!==t.doc&&t.doc.descendants(i),r}}));le(YF,{displayName:"Prose<keepTableAlignPlugin>",group:"Prose"});const XF=wr.extendSchema(n=>e=>({...n(e),content:"table_header_row+ table_row+"})),Da=Math.min,Ei=Math.max,La=Math.round,la=Math.floor,Un=n=>({x:n,y:n}),QF={left:"right",right:"left",bottom:"top",top:"bottom"};function _y(n,e,t){return Ei(n,Da(e,t))}function wu(n,e){return typeof n=="function"?n(e):n}function $i(n){return n.split("-")[0]}function Cu(n){return n.split("-")[1]}function Pb(n){return n==="x"?"y":"x"}function Bb(n){return n==="y"?"height":"width"}function Kr(n){const e=n[0];return e==="t"||e==="b"?"y":"x"}function Fb(n){return Pb(Kr(n))}function ZF(n,e,t){t===void 0&&(t=!1);const r=Cu(n),i=Fb(n),o=Bb(i);let s=i==="x"?r===(t?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[o]>e.floating[o]&&(s=Pa(s)),[s,Pa(s)]}function ez(n){const e=Pa(n);return[xh(n),e,xh(e)]}function xh(n){return n.includes("start")?n.replace("start","end"):n.replace("end","start")}const Dy=["left","right"],Ly=["right","left"],tz=["top","bottom"],nz=["bottom","top"];function rz(n,e,t){switch(n){case"top":case"bottom":return t?e?Ly:Dy:e?Dy:Ly;case"left":case"right":return e?tz:nz;default:return[]}}function iz(n,e,t,r){const i=Cu(n);let o=rz($i(n),t==="start",r);return i&&(o=o.map(s=>s+"-"+i),e&&(o=o.concat(o.map(xh)))),o}function Pa(n){const e=$i(n);return QF[e]+n.slice(e.length)}function oz(n){return{top:0,right:0,bottom:0,left:0,...n}}function sz(n){return typeof n!="number"?oz(n):{top:n,right:n,bottom:n,left:n}}function Ba(n){const{x:e,y:t,width:r,height:i}=n;return{width:r,height:i,top:t,left:e,right:e+r,bottom:t+i,x:e,y:t}}function Py(n,e,t){let{reference:r,floating:i}=n;const o=Kr(e),s=Fb(e),a=Bb(s),u=$i(e),f=o==="y",h=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,m=r[a]/2-i[a]/2;let g;switch(u){case"top":g={x:h,y:r.y-i.height};break;case"bottom":g={x:h,y:r.y+r.height};break;case"right":g={x:r.x+r.width,y:d};break;case"left":g={x:r.x-i.width,y:d};break;default:g={x:r.x,y:r.y}}switch(Cu(e)){case"start":g[s]-=m*(t&&f?-1:1);break;case"end":g[s]+=m*(t&&f?-1:1);break}return g}async function lz(n,e){var t;e===void 0&&(e={});const{x:r,y:i,platform:o,rects:s,elements:a,strategy:u}=n,{boundary:f="clippingAncestors",rootBoundary:h="viewport",elementContext:d="floating",altBoundary:m=!1,padding:g=0}=wu(e,n),k=sz(g),v=a[m?d==="floating"?"reference":"floating":d],S=Ba(await o.getClippingRect({element:(t=await(o.isElement==null?void 0:o.isElement(v)))==null||t?v:v.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(a.floating)),boundary:f,rootBoundary:h,strategy:u})),L=d==="floating"?{x:r,y:i,width:s.floating.width,height:s.floating.height}:s.reference,R=await(o.getOffsetParent==null?void 0:o.getOffsetParent(a.floating)),K=await(o.isElement==null?void 0:o.isElement(R))?await(o.getScale==null?void 0:o.getScale(R))||{x:1,y:1}:{x:1,y:1},q=Ba(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:L,offsetParent:R,strategy:u}):L);return{top:(S.top-q.top+k.top)/K.y,bottom:(q.bottom-S.bottom+k.bottom)/K.y,left:(S.left-q.left+k.left)/K.x,right:(q.right-S.right+k.right)/K.x}}const az=50,uz=async(n,e,t)=>{const{placement:r="bottom",strategy:i="absolute",middleware:o=[],platform:s}=t,a=s.detectOverflow?s:{...s,detectOverflow:lz},u=await(s.isRTL==null?void 0:s.isRTL(e));let f=await s.getElementRects({reference:n,floating:e,strategy:i}),{x:h,y:d}=Py(f,r,u),m=r,g=0;const k={};for(let C=0;C<o.length;C++){const v=o[C];if(!v)continue;const{name:S,fn:L}=v,{x:R,y:K,data:q,reset:O}=await L({x:h,y:d,initialPlacement:r,placement:m,strategy:i,middlewareData:k,rects:f,platform:a,elements:{reference:n,floating:e}});h=R??h,d=K??d,k[S]={...k[S],...q},O&&g<az&&(g++,typeof O=="object"&&(O.placement&&(m=O.placement),O.rects&&(f=O.rects===!0?await s.getElementRects({reference:n,floating:e,strategy:i}):O.rects),{x:h,y:d}=Py(f,m,u)),C=-1)}return{x:h,y:d,placement:m,strategy:i,middlewareData:k}},cz=function(n){return n===void 0&&(n={}),{name:"flip",options:n,async fn(e){var t,r;const{placement:i,middlewareData:o,rects:s,initialPlacement:a,platform:u,elements:f}=e,{mainAxis:h=!0,crossAxis:d=!0,fallbackPlacements:m,fallbackStrategy:g="bestFit",fallbackAxisSideDirection:k="none",flipAlignment:C=!0,...v}=wu(n,e);if((t=o.arrow)!=null&&t.alignmentOffset)return{};const S=$i(i),L=Kr(a),R=$i(a)===a,K=await(u.isRTL==null?void 0:u.isRTL(f.floating)),q=m||(R||!C?[Pa(a)]:ez(a)),O=k!=="none";!m&&O&&q.push(...iz(a,C,k,K));const H=[a,...q],X=await u.detectOverflow(e,v),te=[];let D=((r=o.flip)==null?void 0:r.overflows)||[];if(h&&te.push(X[S]),d){const Te=ZF(i,s,K);te.push(X[Te[0]],X[Te[1]])}if(D=[...D,{placement:i,overflows:te}],!te.every(Te=>Te<=0)){var Q,ee;const Te=(((Q=o.flip)==null?void 0:Q.index)||0)+1,ye=H[Te];if(ye&&(!(d==="alignment"?L!==Kr(ye):!1)||D.every(Ee=>Kr(Ee.placement)===L?Ee.overflows[0]>0:!0)))return{data:{index:Te,overflows:D},reset:{placement:ye}};let He=(ee=D.filter(Me=>Me.overflows[0]<=0).sort((Me,Ee)=>Me.overflows[1]-Ee.overflows[1])[0])==null?void 0:ee.placement;if(!He)switch(g){case"bestFit":{var Ie;const Me=(Ie=D.filter(Ee=>{if(O){const Qe=Kr(Ee.placement);return Qe===L||Qe==="y"}return!0}).map(Ee=>[Ee.placement,Ee.overflows.filter(Qe=>Qe>0).reduce((Qe,A)=>Qe+A,0)]).sort((Ee,Qe)=>Ee[1]-Qe[1])[0])==null?void 0:Ie[0];Me&&(He=Me);break}case"initialPlacement":He=a;break}if(i!==He)return{reset:{placement:He}}}return{}}}},fz=new Set(["left","top"]);async function hz(n,e){const{placement:t,platform:r,elements:i}=n,o=await(r.isRTL==null?void 0:r.isRTL(i.floating)),s=$i(t),a=Cu(t),u=Kr(t)==="y",f=fz.has(s)?-1:1,h=o&&u?-1:1,d=wu(e,n);let{mainAxis:m,crossAxis:g,alignmentAxis:k}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return a&&typeof k=="number"&&(g=a==="end"?k*-1:k),u?{x:g*h,y:m*f}:{x:m*f,y:g*h}}const dz=function(n){return n===void 0&&(n=0),{name:"offset",options:n,async fn(e){var t,r;const{x:i,y:o,placement:s,middlewareData:a}=e,u=await hz(e,n);return s===((t=a.offset)==null?void 0:t.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:i+u.x,y:o+u.y,data:{...u,placement:s}}}}},pz=function(n){return n===void 0&&(n={}),{name:"shift",options:n,async fn(e){const{x:t,y:r,placement:i,platform:o}=e,{mainAxis:s=!0,crossAxis:a=!1,limiter:u={fn:S=>{let{x:L,y:R}=S;return{x:L,y:R}}},...f}=wu(n,e),h={x:t,y:r},d=await o.detectOverflow(e,f),m=Kr($i(i)),g=Pb(m);let k=h[g],C=h[m];if(s){const S=g==="y"?"top":"left",L=g==="y"?"bottom":"right",R=k+d[S],K=k-d[L];k=_y(R,k,K)}if(a){const S=m==="y"?"top":"left",L=m==="y"?"bottom":"right",R=C+d[S],K=C-d[L];C=_y(R,C,K)}const v=u.fn({...e,[g]:k,[m]:C});return{...v,data:{x:v.x-t,y:v.y-r,enabled:{[g]:s,[m]:a}}}}}};function Su(){return typeof window<"u"}function Fo(n){return zb(n)?(n.nodeName||"").toLowerCase():"#document"}function tn(n){var e;return(n==null||(e=n.ownerDocument)==null?void 0:e.defaultView)||window}function Zn(n){var e;return(e=(zb(n)?n.ownerDocument:n.document)||window.document)==null?void 0:e.documentElement}function zb(n){return Su()?n instanceof Node||n instanceof tn(n).Node:!1}function Dn(n){return Su()?n instanceof Element||n instanceof tn(n).Element:!1}function vr(n){return Su()?n instanceof HTMLElement||n instanceof tn(n).HTMLElement:!1}function By(n){return!Su()||typeof ShadowRoot>"u"?!1:n instanceof ShadowRoot||n instanceof tn(n).ShadowRoot}function ol(n){const{overflow:e,overflowX:t,overflowY:r,display:i}=Ln(n);return/auto|scroll|overlay|hidden|clip/.test(e+r+t)&&i!=="inline"&&i!=="contents"}function mz(n){return/^(table|td|th)$/.test(Fo(n))}function vu(n){try{if(n.matches(":popover-open"))return!0}catch{}try{return n.matches(":modal")}catch{return!1}}const gz=/transform|translate|scale|rotate|perspective|filter/,yz=/paint|layout|strict|content/,yi=n=>!!n&&n!=="none";let Df;function id(n){const e=Dn(n)?Ln(n):n;return yi(e.transform)||yi(e.translate)||yi(e.scale)||yi(e.rotate)||yi(e.perspective)||!od()&&(yi(e.backdropFilter)||yi(e.filter))||gz.test(e.willChange||"")||yz.test(e.contain||"")}function kz(n){let e=Qr(n);for(;vr(e)&&!Ro(e);){if(id(e))return e;if(vu(e))return null;e=Qr(e)}return null}function od(){return Df==null&&(Df=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Df}function Ro(n){return/^(html|body|#document)$/.test(Fo(n))}function Ln(n){return tn(n).getComputedStyle(n)}function Tu(n){return Dn(n)?{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}:{scrollLeft:n.scrollX,scrollTop:n.scrollY}}function Qr(n){if(Fo(n)==="html")return n;const e=n.assignedSlot||n.parentNode||By(n)&&n.host||Zn(n);return By(e)?e.host:e}function $b(n){const e=Qr(n);return Ro(e)?n.ownerDocument?n.ownerDocument.body:n.body:vr(e)&&ol(e)?e:$b(e)}function Es(n,e,t){var r;e===void 0&&(e=[]),t===void 0&&(t=!0);const i=$b(n),o=i===((r=n.ownerDocument)==null?void 0:r.body),s=tn(i);if(o){const a=wh(s);return e.concat(s,s.visualViewport||[],ol(i)?i:[],a&&t?Es(a):[])}else return e.concat(i,Es(i,[],t))}function wh(n){return n.parent&&Object.getPrototypeOf(n.parent)?n.frameElement:null}function Wb(n){const e=Ln(n);let t=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const i=vr(n),o=i?n.offsetWidth:t,s=i?n.offsetHeight:r,a=La(t)!==o||La(r)!==s;return a&&(t=o,r=s),{width:t,height:r,$:a}}function sd(n){return Dn(n)?n:n.contextElement}function ko(n){const e=sd(n);if(!vr(e))return Un(1);const t=e.getBoundingClientRect(),{width:r,height:i,$:o}=Wb(e);let s=(o?La(t.width):t.width)/r,a=(o?La(t.height):t.height)/i;return(!s||!Number.isFinite(s))&&(s=1),(!a||!Number.isFinite(a))&&(a=1),{x:s,y:a}}const bz=Un(0);function Vb(n){const e=tn(n);return!od()||!e.visualViewport?bz:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function xz(n,e,t){return e===void 0&&(e=!1),!t||e&&t!==tn(n)?!1:e}function Wi(n,e,t,r){e===void 0&&(e=!1),t===void 0&&(t=!1);const i=n.getBoundingClientRect(),o=sd(n);let s=Un(1);e&&(r?Dn(r)&&(s=ko(r)):s=ko(n));const a=xz(o,t,r)?Vb(o):Un(0);let u=(i.left+a.x)/s.x,f=(i.top+a.y)/s.y,h=i.width/s.x,d=i.height/s.y;if(o){const m=tn(o),g=r&&Dn(r)?tn(r):r;let k=m,C=wh(k);for(;C&&r&&g!==k;){const v=ko(C),S=C.getBoundingClientRect(),L=Ln(C),R=S.left+(C.clientLeft+parseFloat(L.paddingLeft))*v.x,K=S.top+(C.clientTop+parseFloat(L.paddingTop))*v.y;u*=v.x,f*=v.y,h*=v.x,d*=v.y,u+=R,f+=K,k=tn(C),C=wh(k)}}return Ba({width:h,height:d,x:u,y:f})}function Au(n,e){const t=Tu(n).scrollLeft;return e?e.left+t:Wi(Zn(n)).left+t}function Hb(n,e){const t=n.getBoundingClientRect(),r=t.left+e.scrollLeft-Au(n,t),i=t.top+e.scrollTop;return{x:r,y:i}}function wz(n){let{elements:e,rect:t,offsetParent:r,strategy:i}=n;const o=i==="fixed",s=Zn(r),a=e?vu(e.floating):!1;if(r===s||a&&o)return t;let u={scrollLeft:0,scrollTop:0},f=Un(1);const h=Un(0),d=vr(r);if((d||!d&&!o)&&((Fo(r)!=="body"||ol(s))&&(u=Tu(r)),d)){const g=Wi(r);f=ko(r),h.x=g.x+r.clientLeft,h.y=g.y+r.clientTop}const m=s&&!d&&!o?Hb(s,u):Un(0);return{width:t.width*f.x,height:t.height*f.y,x:t.x*f.x-u.scrollLeft*f.x+h.x+m.x,y:t.y*f.y-u.scrollTop*f.y+h.y+m.y}}function Cz(n){return Array.from(n.getClientRects())}function Sz(n){const e=Zn(n),t=Tu(n),r=n.ownerDocument.body,i=Ei(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),o=Ei(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let s=-t.scrollLeft+Au(n);const a=-t.scrollTop;return Ln(r).direction==="rtl"&&(s+=Ei(e.clientWidth,r.clientWidth)-i),{width:i,height:o,x:s,y:a}}const Fy=25;function vz(n,e){const t=tn(n),r=Zn(n),i=t.visualViewport;let o=r.clientWidth,s=r.clientHeight,a=0,u=0;if(i){o=i.width,s=i.height;const h=od();(!h||h&&e==="fixed")&&(a=i.offsetLeft,u=i.offsetTop)}const f=Au(r);if(f<=0){const h=r.ownerDocument,d=h.body,m=getComputedStyle(d),g=h.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,k=Math.abs(r.clientWidth-d.clientWidth-g);k<=Fy&&(o-=k)}else f<=Fy&&(o+=f);return{width:o,height:s,x:a,y:u}}function Tz(n,e){const t=Wi(n,!0,e==="fixed"),r=t.top+n.clientTop,i=t.left+n.clientLeft,o=vr(n)?ko(n):Un(1),s=n.clientWidth*o.x,a=n.clientHeight*o.y,u=i*o.x,f=r*o.y;return{width:s,height:a,x:u,y:f}}function zy(n,e,t){let r;if(e==="viewport")r=vz(n,t);else if(e==="document")r=Sz(Zn(n));else if(Dn(e))r=Tz(e,t);else{const i=Vb(n);r={x:e.x-i.x,y:e.y-i.y,width:e.width,height:e.height}}return Ba(r)}function qb(n,e){const t=Qr(n);return t===e||!Dn(t)||Ro(t)?!1:Ln(t).position==="fixed"||qb(t,e)}function Az(n,e){const t=e.get(n);if(t)return t;let r=Es(n,[],!1).filter(a=>Dn(a)&&Fo(a)!=="body"),i=null;const o=Ln(n).position==="fixed";let s=o?Qr(n):n;for(;Dn(s)&&!Ro(s);){const a=Ln(s),u=id(s);!u&&a.position==="fixed"&&(i=null),(o?!u&&!i:!u&&a.position==="static"&&!!i&&(i.position==="absolute"||i.position==="fixed")||ol(s)&&!u&&qb(n,s))?r=r.filter(h=>h!==s):i=a,s=Qr(s)}return e.set(n,r),r}function Nz(n){let{element:e,boundary:t,rootBoundary:r,strategy:i}=n;const s=[...t==="clippingAncestors"?vu(e)?[]:Az(e,this._c):[].concat(t),r],a=zy(e,s[0],i);let u=a.top,f=a.right,h=a.bottom,d=a.left;for(let m=1;m<s.length;m++){const g=zy(e,s[m],i);u=Ei(g.top,u),f=Da(g.right,f),h=Da(g.bottom,h),d=Ei(g.left,d)}return{width:f-d,height:h-u,x:d,y:u}}function Mz(n){const{width:e,height:t}=Wb(n);return{width:e,height:t}}function Iz(n,e,t){const r=vr(e),i=Zn(e),o=t==="fixed",s=Wi(n,!0,o,e);let a={scrollLeft:0,scrollTop:0};const u=Un(0);function f(){u.x=Au(i)}if(r||!r&&!o)if((Fo(e)!=="body"||ol(i))&&(a=Tu(e)),r){const g=Wi(e,!0,o,e);u.x=g.x+e.clientLeft,u.y=g.y+e.clientTop}else i&&f();o&&!r&&i&&f();const h=i&&!r&&!o?Hb(i,a):Un(0),d=s.left+a.scrollLeft-u.x-h.x,m=s.top+a.scrollTop-u.y-h.y;return{x:d,y:m,width:s.width,height:s.height}}function Lf(n){return Ln(n).position==="static"}function $y(n,e){if(!vr(n)||Ln(n).position==="fixed")return null;if(e)return e(n);let t=n.offsetParent;return Zn(n)===t&&(t=t.ownerDocument.body),t}function Kb(n,e){const t=tn(n);if(vu(n))return t;if(!vr(n)){let i=Qr(n);for(;i&&!Ro(i);){if(Dn(i)&&!Lf(i))return i;i=Qr(i)}return t}let r=$y(n,e);for(;r&&mz(r)&&Lf(r);)r=$y(r,e);return r&&Ro(r)&&Lf(r)&&!id(r)?t:r||kz(n)||t}const Ez=async function(n){const e=this.getOffsetParent||Kb,t=this.getDimensions,r=await t(n.floating);return{reference:Iz(n.reference,await e(n.floating),n.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Oz(n){return Ln(n).direction==="rtl"}const Rz={convertOffsetParentRelativeRectToViewportRelativeRect:wz,getDocumentElement:Zn,getClippingRect:Nz,getOffsetParent:Kb,getElementRects:Ez,getClientRects:Cz,getDimensions:Mz,getScale:ko,isElement:Dn,isRTL:Oz};function Ub(n,e){return n.x===e.x&&n.y===e.y&&n.width===e.width&&n.height===e.height}function _z(n,e){let t=null,r;const i=Zn(n);function o(){var a;clearTimeout(r),(a=t)==null||a.disconnect(),t=null}function s(a,u){a===void 0&&(a=!1),u===void 0&&(u=1),o();const f=n.getBoundingClientRect(),{left:h,top:d,width:m,height:g}=f;if(a||e(),!m||!g)return;const k=la(d),C=la(i.clientWidth-(h+m)),v=la(i.clientHeight-(d+g)),S=la(h),R={rootMargin:-k+"px "+-C+"px "+-v+"px "+-S+"px",threshold:Ei(0,Da(1,u))||1};let K=!0;function q(O){const H=O[0].intersectionRatio;if(H!==u){if(!K)return s();H?s(!1,H):r=setTimeout(()=>{s(!1,1e-7)},1e3)}H===1&&!Ub(f,n.getBoundingClientRect())&&s(),K=!1}try{t=new IntersectionObserver(q,{...R,root:i.ownerDocument})}catch{t=new IntersectionObserver(q,R)}t.observe(n)}return s(!0),o}function Wy(n,e,t,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:o=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:u=!1}=r,f=sd(n),h=i||o?[...f?Es(f):[],...e?Es(e):[]]:[];h.forEach(S=>{i&&S.addEventListener("scroll",t,{passive:!0}),o&&S.addEventListener("resize",t)});const d=f&&a?_z(f,t):null;let m=-1,g=null;s&&(g=new ResizeObserver(S=>{let[L]=S;L&&L.target===f&&g&&e&&(g.unobserve(e),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var R;(R=g)==null||R.observe(e)})),t()}),f&&!u&&g.observe(f),e&&g.observe(e));let k,C=u?Wi(n):null;u&&v();function v(){const S=Wi(n);C&&!Ub(C,S)&&t(),C=S,k=requestAnimationFrame(v)}return t(),()=>{var S;h.forEach(L=>{i&&L.removeEventListener("scroll",t),o&&L.removeEventListener("resize",t)}),d==null||d(),(S=g)==null||S.disconnect(),g=null,u&&cancelAnimationFrame(k)}}const Dz=dz,Lz=pz,Pz=cz,Bz=(n,e,t)=>{const r=new Map,i={platform:Rz,...t},o={...i.platform,_c:r};return uz(n,e,{...i,platform:o})};var Fz=typeof global=="object"&&global&&global.Object===Object&&global,zz=typeof self=="object"&&self&&self.Object===Object&&self,jb=Fz||zz||Function("return this")(),Fa=jb.Symbol,Jb=Object.prototype,$z=Jb.hasOwnProperty,Wz=Jb.toString,rs=Fa?Fa.toStringTag:void 0;function Vz(n){var e=$z.call(n,rs),t=n[rs];try{n[rs]=void 0;var r=!0}catch{}var i=Wz.call(n);return r&&(e?n[rs]=t:delete n[rs]),i}var Hz=Object.prototype,qz=Hz.toString;function Kz(n){return qz.call(n)}var Uz="[object Null]",jz="[object Undefined]",Vy=Fa?Fa.toStringTag:void 0;function Jz(n){return n==null?n===void 0?jz:Uz:Vy&&Vy in Object(n)?Vz(n):Kz(n)}function Gz(n){return n!=null&&typeof n=="object"}var Yz="[object Symbol]";function Xz(n){return typeof n=="symbol"||Gz(n)&&Jz(n)==Yz}var Qz=/\s/;function Zz(n){for(var e=n.length;e--&&Qz.test(n.charAt(e)););return e}var e2=/^\s+/;function t2(n){return n&&n.slice(0,Zz(n)+1).replace(e2,"")}function za(n){var e=typeof n;return n!=null&&(e=="object"||e=="function")}var Hy=NaN,n2=/^[-+]0x[0-9a-f]+$/i,r2=/^0b[01]+$/i,i2=/^0o[0-7]+$/i,o2=parseInt;function qy(n){if(typeof n=="number")return n;if(Xz(n))return Hy;if(za(n)){var e=typeof n.valueOf=="function"?n.valueOf():n;n=za(e)?e+"":e}if(typeof n!="string")return n===0?n:+n;n=t2(n);var t=r2.test(n);return t||i2.test(n)?o2(n.slice(2),t?2:8):n2.test(n)?Hy:+n}var Pf=function(){return jb.Date.now()},s2="Expected a function",l2=Math.max,a2=Math.min;function u2(n,e,t){var r,i,o,s,a,u,f=0,h=!1,d=!1,m=!0;if(typeof n!="function")throw new TypeError(s2);e=qy(e)||0,za(t)&&(h=!!t.leading,d="maxWait"in t,o=d?l2(qy(t.maxWait)||0,e):o,m="trailing"in t?!!t.trailing:m);function g(O){var H=r,X=i;return r=i=void 0,f=O,s=n.apply(X,H),s}function k(O){return f=O,a=setTimeout(S,e),h?g(O):s}function C(O){var H=O-u,X=O-f,te=e-H;return d?a2(te,o-X):te}function v(O){var H=O-u,X=O-f;return u===void 0||H>=e||H<0||d&&X>=o}function S(){var O=Pf();if(v(O))return L(O);a=setTimeout(S,C(O))}function L(O){return a=void 0,m&&r?g(O):(r=i=void 0,s)}function R(){a!==void 0&&clearTimeout(a),f=0,r=u=i=a=void 0}function K(){return a===void 0?s:L(Pf())}function q(){var O=Pf(),H=v(O);if(r=arguments,i=this,u=O,H){if(a===void 0)return k(u);if(d)return clearTimeout(a),a=setTimeout(S,e),g(u)}return a===void 0&&(a=setTimeout(S,e)),s}return q.cancel=R,q.flush=K,q}var c2="Expected a function";function f2(n,e,t){var r=!0,i=!0;if(typeof n!="function")throw new TypeError(c2);return za(t)&&(r="leading"in t?!!t.leading:r,i="trailing"in t?!!t.trailing:i),u2(n,e,{leading:r,maxWait:e,trailing:i})}var zs,$s,Ws,Co,So,Vs,qn,Hs,qs,vo,Ti,Ks,Ya,Xa,Gb,Yy,h2=(Yy=class{constructor(n){xe(this,Xa);xe(this,zs);xe(this,$s);xe(this,Ws);xe(this,Co);xe(this,So);xe(this,Vs,!1);xe(this,qn);xe(this,Hs);xe(this,qs);xe(this,vo);xe(this,Ti,n=>{Bz(n,this.element,{placement:j(this,Co).placement??"top",middleware:[Pz(),Dz(j(this,Hs)),Lz(j(this,qs)),...j(this,Ws)],...j(this,Co)}).then(({x:e,y:t})=>{Object.assign(this.element.style,{left:`${e}px`,top:`${t}px`})}).catch(console.error)});xe(this,Ks,n=>j(this,So)!==n.dom.parentElement);xe(this,Ya,(n,e)=>{var d;const{state:t,composing:r}=n,{selection:i,doc:o}=t,{ranges:s}=i,a=Math.min(...s.map(m=>m.$from.pos)),u=Math.max(...s.map(m=>m.$to.pos)),f=e&&e.doc.eq(o)&&e.selection.eq(i);if(j(this,Vs)||((j(this,So)??n.dom.parentElement??document.body).appendChild(this.element),Ke(this,Vs,!0)),r||f)return;if((d=j(this,qn))==null||d.call(this),Ke(this,qn,void 0),!j(this,$s).call(this,n,e)){this.hide();return}const h={getBoundingClientRect:()=>nn.posToDOMRect(n,a,u),contextElement:n.dom};j(this,Ks).call(this,n)?Ke(this,qn,Wy(h,this.element,()=>j(this,Ti).call(this,h))):j(this,Ti).call(this,h),this.show()});this.onShow=()=>{},this.onHide=()=>{},this.update=(e,t)=>{j(this,vo).call(this,e,t)},this.destroy=()=>{var e;(e=j(this,qn))==null||e.call(this),j(this,vo).cancel()},this.show=(e,t)=>{var r;if(this.element.dataset.show="true",e){(r=j(this,qn))==null||r.call(this),Ke(this,qn,void 0);const i={...e,contextElement:t==null?void 0:t.dom};t&&j(this,Ks).call(this,t)?Ke(this,qn,Wy(i,this.element,()=>j(this,Ti).call(this,i))):j(this,Ti).call(this,i)}this.onShow()},this.hide=()=>{this.element.dataset.show!=="false"&&(this.element.dataset.show="false",this.onHide())},this.element=n.content,Ke(this,zs,n.debounce??200),Ke(this,$s,n.shouldShow??Bm(this,Xa,Gb)),Ke(this,Hs,n.offset),Ke(this,qs,n.shift),Ke(this,Ws,n.middleware??[]),Ke(this,Co,n.floatingUIOptions??{}),Ke(this,So,n.root),this.element.dataset.show="false",Ke(this,vo,f2(j(this,Ya),j(this,zs)))}},zs=new WeakMap,$s=new WeakMap,Ws=new WeakMap,Co=new WeakMap,So=new WeakMap,Vs=new WeakMap,qn=new WeakMap,Hs=new WeakMap,qs=new WeakMap,vo=new WeakMap,Ti=new WeakMap,Ks=new WeakMap,Ya=new WeakMap,Xa=new WeakSet,Gb=function(n){const{doc:e,selection:t}=n.state,{empty:r,from:i,to:o}=t,s=!e.textBetween(i,o).length&&n.state.selection instanceof pe,a=this.element.contains(document.activeElement),u=!n.hasFocus()&&!a,f=!n.editable;return!(u||r||s||f)},Yy);function d2(n){const e=Sn({},`${n}_TOOLTIP_SPEC`),t=Pn(i=>{const o=i.get(e.key);return new Pt({key:new Bt(`${n}_TOOLTIP`),...o})}),r=[e,t];return r.key=e.key,r.pluginKey=t.key,e.meta={package:"@milkdown/plugin-tooltip",displayName:`Ctx<tooltipSpec>|${n}`},t.meta={package:"@milkdown/plugin-tooltip",displayName:`Prose<tooltip>|${n}`},r}var $a={exports:{}};/**
50
+ * @license
51
+ * Lodash <https://lodash.com/>
52
+ * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
53
+ * Released under MIT license <https://lodash.com/license>
54
+ * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
55
+ * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
56
+ */$a.exports;(function(n,e){(function(){var t,r="4.17.23",i=200,o="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",s="Expected a function",a="Invalid `variable` option passed into `_.template`",u="__lodash_hash_undefined__",f=500,h="__lodash_placeholder__",d=1,m=2,g=4,k=1,C=2,v=1,S=2,L=4,R=8,K=16,q=32,O=64,H=128,X=256,te=512,D=30,Q="...",ee=800,Ie=16,Te=1,ye=2,He=3,Me=1/0,Ee=9007199254740991,Qe=17976931348623157e292,A=NaN,je=4294967295,Tn=je-1,M=je>>>1,zt=[["ary",H],["bind",v],["bindKey",S],["curry",R],["curryRight",K],["flip",te],["partial",q],["partialRight",O],["rearg",X]],At="[object Arguments]",Je="[object Array]",ri="[object AsyncFunction]",Nt="[object Boolean]",on="[object Date]",Tr="[object DOMException]",er="[object Error]",qi="[object Function]",ll="[object GeneratorFunction]",$t="[object Map]",Ar="[object Number]",al="[object Null]",sn="[object Object]",ul="[object Promise]",cl="[object Proxy]",Nr="[object RegExp]",Wt="[object Set]",ii="[object String]",Ki="[object Symbol]",Mu="[object Undefined]",oi="[object WeakMap]",B="[object WeakSet]",U="[object ArrayBuffer]",ie="[object DataView]",ke="[object Float32Array]",Oe="[object Float64Array]",bt="[object Int8Array]",An="[object Int16Array]",Vt="[object Int32Array]",tr="[object Uint8Array]",nr="[object Uint8ClampedArray]",st="[object Uint16Array]",Fn="[object Uint32Array]",Nn=/\b__p \+= '';/g,rx=/\b(__p \+=) '' \+/g,ix=/(__e\(.*?\)|\b__t\)) \+\n'';/g,ld=/&(?:amp|lt|gt|quot|#39);/g,ad=/[&<>"']/g,ox=RegExp(ld.source),sx=RegExp(ad.source),lx=/<%-([\s\S]+?)%>/g,ax=/<%([\s\S]+?)%>/g,ud=/<%=([\s\S]+?)%>/g,ux=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,cx=/^\w*$/,fx=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Iu=/[\\^$.*+?()[\]{}|]/g,hx=RegExp(Iu.source),Eu=/^\s+/,dx=/\s/,px=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,mx=/\{\n\/\* \[wrapped with (.+)\] \*/,gx=/,? & /,yx=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,kx=/[()=,{}\[\]\/\s]/,bx=/\\(\\)?/g,xx=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,cd=/\w*$/,wx=/^[-+]0x[0-9a-f]+$/i,Cx=/^0b[01]+$/i,Sx=/^\[object .+?Constructor\]$/,vx=/^0o[0-7]+$/i,Tx=/^(?:0|[1-9]\d*)$/,Ax=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,fl=/($^)/,Nx=/['\n\r\u2028\u2029\\]/g,hl="\\ud800-\\udfff",Mx="\\u0300-\\u036f",Ix="\\ufe20-\\ufe2f",Ex="\\u20d0-\\u20ff",fd=Mx+Ix+Ex,hd="\\u2700-\\u27bf",dd="a-z\\xdf-\\xf6\\xf8-\\xff",Ox="\\xac\\xb1\\xd7\\xf7",Rx="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",_x="\\u2000-\\u206f",Dx=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",pd="A-Z\\xc0-\\xd6\\xd8-\\xde",md="\\ufe0e\\ufe0f",gd=Ox+Rx+_x+Dx,Ou="['’]",Lx="["+hl+"]",yd="["+gd+"]",dl="["+fd+"]",kd="\\d+",Px="["+hd+"]",bd="["+dd+"]",xd="[^"+hl+gd+kd+hd+dd+pd+"]",Ru="\\ud83c[\\udffb-\\udfff]",Bx="(?:"+dl+"|"+Ru+")",wd="[^"+hl+"]",_u="(?:\\ud83c[\\udde6-\\uddff]){2}",Du="[\\ud800-\\udbff][\\udc00-\\udfff]",Ui="["+pd+"]",Cd="\\u200d",Sd="(?:"+bd+"|"+xd+")",Fx="(?:"+Ui+"|"+xd+")",vd="(?:"+Ou+"(?:d|ll|m|re|s|t|ve))?",Td="(?:"+Ou+"(?:D|LL|M|RE|S|T|VE))?",Ad=Bx+"?",Nd="["+md+"]?",zx="(?:"+Cd+"(?:"+[wd,_u,Du].join("|")+")"+Nd+Ad+")*",$x="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Wx="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Md=Nd+Ad+zx,Vx="(?:"+[Px,_u,Du].join("|")+")"+Md,Hx="(?:"+[wd+dl+"?",dl,_u,Du,Lx].join("|")+")",qx=RegExp(Ou,"g"),Kx=RegExp(dl,"g"),Lu=RegExp(Ru+"(?="+Ru+")|"+Hx+Md,"g"),Ux=RegExp([Ui+"?"+bd+"+"+vd+"(?="+[yd,Ui,"$"].join("|")+")",Fx+"+"+Td+"(?="+[yd,Ui+Sd,"$"].join("|")+")",Ui+"?"+Sd+"+"+vd,Ui+"+"+Td,Wx,$x,kd,Vx].join("|"),"g"),jx=RegExp("["+Cd+hl+fd+md+"]"),Jx=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Gx=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],Yx=-1,We={};We[ke]=We[Oe]=We[bt]=We[An]=We[Vt]=We[tr]=We[nr]=We[st]=We[Fn]=!0,We[At]=We[Je]=We[U]=We[Nt]=We[ie]=We[on]=We[er]=We[qi]=We[$t]=We[Ar]=We[sn]=We[Nr]=We[Wt]=We[ii]=We[oi]=!1;var ze={};ze[At]=ze[Je]=ze[U]=ze[ie]=ze[Nt]=ze[on]=ze[ke]=ze[Oe]=ze[bt]=ze[An]=ze[Vt]=ze[$t]=ze[Ar]=ze[sn]=ze[Nr]=ze[Wt]=ze[ii]=ze[Ki]=ze[tr]=ze[nr]=ze[st]=ze[Fn]=!0,ze[er]=ze[qi]=ze[oi]=!1;var Xx={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},Qx={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Zx={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"},ew={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},tw=parseFloat,nw=parseInt,Id=typeof ts=="object"&&ts&&ts.Object===Object&&ts,rw=typeof self=="object"&&self&&self.Object===Object&&self,lt=Id||rw||Function("return this")(),Pu=e&&!e.nodeType&&e,si=Pu&&!0&&n&&!n.nodeType&&n,Ed=si&&si.exports===Pu,Bu=Ed&&Id.process,ln=function(){try{var I=si&&si.require&&si.require("util").types;return I||Bu&&Bu.binding&&Bu.binding("util")}catch{}}(),Od=ln&&ln.isArrayBuffer,Rd=ln&&ln.isDate,_d=ln&&ln.isMap,Dd=ln&&ln.isRegExp,Ld=ln&&ln.isSet,Pd=ln&&ln.isTypedArray;function Ht(I,P,_){switch(_.length){case 0:return I.call(P);case 1:return I.call(P,_[0]);case 2:return I.call(P,_[0],_[1]);case 3:return I.call(P,_[0],_[1],_[2])}return I.apply(P,_)}function iw(I,P,_,Y){for(var ue=-1,Re=I==null?0:I.length;++ue<Re;){var et=I[ue];P(Y,et,_(et),I)}return Y}function an(I,P){for(var _=-1,Y=I==null?0:I.length;++_<Y&&P(I[_],_,I)!==!1;);return I}function ow(I,P){for(var _=I==null?0:I.length;_--&&P(I[_],_,I)!==!1;);return I}function Bd(I,P){for(var _=-1,Y=I==null?0:I.length;++_<Y;)if(!P(I[_],_,I))return!1;return!0}function Mr(I,P){for(var _=-1,Y=I==null?0:I.length,ue=0,Re=[];++_<Y;){var et=I[_];P(et,_,I)&&(Re[ue++]=et)}return Re}function pl(I,P){var _=I==null?0:I.length;return!!_&&ji(I,P,0)>-1}function Fu(I,P,_){for(var Y=-1,ue=I==null?0:I.length;++Y<ue;)if(_(P,I[Y]))return!0;return!1}function qe(I,P){for(var _=-1,Y=I==null?0:I.length,ue=Array(Y);++_<Y;)ue[_]=P(I[_],_,I);return ue}function Ir(I,P){for(var _=-1,Y=P.length,ue=I.length;++_<Y;)I[ue+_]=P[_];return I}function zu(I,P,_,Y){var ue=-1,Re=I==null?0:I.length;for(Y&&Re&&(_=I[++ue]);++ue<Re;)_=P(_,I[ue],ue,I);return _}function sw(I,P,_,Y){var ue=I==null?0:I.length;for(Y&&ue&&(_=I[--ue]);ue--;)_=P(_,I[ue],ue,I);return _}function $u(I,P){for(var _=-1,Y=I==null?0:I.length;++_<Y;)if(P(I[_],_,I))return!0;return!1}var lw=Wu("length");function aw(I){return I.split("")}function uw(I){return I.match(yx)||[]}function Fd(I,P,_){var Y;return _(I,function(ue,Re,et){if(P(ue,Re,et))return Y=Re,!1}),Y}function ml(I,P,_,Y){for(var ue=I.length,Re=_+(Y?1:-1);Y?Re--:++Re<ue;)if(P(I[Re],Re,I))return Re;return-1}function ji(I,P,_){return P===P?ww(I,P,_):ml(I,zd,_)}function cw(I,P,_,Y){for(var ue=_-1,Re=I.length;++ue<Re;)if(Y(I[ue],P))return ue;return-1}function zd(I){return I!==I}function $d(I,P){var _=I==null?0:I.length;return _?Hu(I,P)/_:A}function Wu(I){return function(P){return P==null?t:P[I]}}function Vu(I){return function(P){return I==null?t:I[P]}}function Wd(I,P,_,Y,ue){return ue(I,function(Re,et,Be){_=Y?(Y=!1,Re):P(_,Re,et,Be)}),_}function fw(I,P){var _=I.length;for(I.sort(P);_--;)I[_]=I[_].value;return I}function Hu(I,P){for(var _,Y=-1,ue=I.length;++Y<ue;){var Re=P(I[Y]);Re!==t&&(_=_===t?Re:_+Re)}return _}function qu(I,P){for(var _=-1,Y=Array(I);++_<I;)Y[_]=P(_);return Y}function hw(I,P){return qe(P,function(_){return[_,I[_]]})}function Vd(I){return I&&I.slice(0,Ud(I)+1).replace(Eu,"")}function qt(I){return function(P){return I(P)}}function Ku(I,P){return qe(P,function(_){return I[_]})}function zo(I,P){return I.has(P)}function Hd(I,P){for(var _=-1,Y=I.length;++_<Y&&ji(P,I[_],0)>-1;);return _}function qd(I,P){for(var _=I.length;_--&&ji(P,I[_],0)>-1;);return _}function dw(I,P){for(var _=I.length,Y=0;_--;)I[_]===P&&++Y;return Y}var pw=Vu(Xx),mw=Vu(Qx);function gw(I){return"\\"+ew[I]}function yw(I,P){return I==null?t:I[P]}function Ji(I){return jx.test(I)}function kw(I){return Jx.test(I)}function bw(I){for(var P,_=[];!(P=I.next()).done;)_.push(P.value);return _}function Uu(I){var P=-1,_=Array(I.size);return I.forEach(function(Y,ue){_[++P]=[ue,Y]}),_}function Kd(I,P){return function(_){return I(P(_))}}function Er(I,P){for(var _=-1,Y=I.length,ue=0,Re=[];++_<Y;){var et=I[_];(et===P||et===h)&&(I[_]=h,Re[ue++]=_)}return Re}function gl(I){var P=-1,_=Array(I.size);return I.forEach(function(Y){_[++P]=Y}),_}function xw(I){var P=-1,_=Array(I.size);return I.forEach(function(Y){_[++P]=[Y,Y]}),_}function ww(I,P,_){for(var Y=_-1,ue=I.length;++Y<ue;)if(I[Y]===P)return Y;return-1}function Cw(I,P,_){for(var Y=_+1;Y--;)if(I[Y]===P)return Y;return Y}function Gi(I){return Ji(I)?vw(I):lw(I)}function Mn(I){return Ji(I)?Tw(I):aw(I)}function Ud(I){for(var P=I.length;P--&&dx.test(I.charAt(P)););return P}var Sw=Vu(Zx);function vw(I){for(var P=Lu.lastIndex=0;Lu.test(I);)++P;return P}function Tw(I){return I.match(Lu)||[]}function Aw(I){return I.match(Ux)||[]}var Nw=function I(P){P=P==null?lt:Yi.defaults(lt.Object(),P,Yi.pick(lt,Gx));var _=P.Array,Y=P.Date,ue=P.Error,Re=P.Function,et=P.Math,Be=P.Object,ju=P.RegExp,Mw=P.String,un=P.TypeError,yl=_.prototype,Iw=Re.prototype,Xi=Be.prototype,kl=P["__core-js_shared__"],bl=Iw.toString,_e=Xi.hasOwnProperty,Ew=0,jd=function(){var l=/[^.]+$/.exec(kl&&kl.keys&&kl.keys.IE_PROTO||"");return l?"Symbol(src)_1."+l:""}(),xl=Xi.toString,Ow=bl.call(Be),Rw=lt._,_w=ju("^"+bl.call(_e).replace(Iu,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),wl=Ed?P.Buffer:t,Or=P.Symbol,Cl=P.Uint8Array,Jd=wl?wl.allocUnsafe:t,Sl=Kd(Be.getPrototypeOf,Be),Gd=Be.create,Yd=Xi.propertyIsEnumerable,vl=yl.splice,Xd=Or?Or.isConcatSpreadable:t,$o=Or?Or.iterator:t,li=Or?Or.toStringTag:t,Tl=function(){try{var l=hi(Be,"defineProperty");return l({},"",{}),l}catch{}}(),Dw=P.clearTimeout!==lt.clearTimeout&&P.clearTimeout,Lw=Y&&Y.now!==lt.Date.now&&Y.now,Pw=P.setTimeout!==lt.setTimeout&&P.setTimeout,Al=et.ceil,Nl=et.floor,Ju=Be.getOwnPropertySymbols,Bw=wl?wl.isBuffer:t,Qd=P.isFinite,Fw=yl.join,zw=Kd(Be.keys,Be),tt=et.max,dt=et.min,$w=Y.now,Ww=P.parseInt,Zd=et.random,Vw=yl.reverse,Gu=hi(P,"DataView"),Wo=hi(P,"Map"),Yu=hi(P,"Promise"),Qi=hi(P,"Set"),Vo=hi(P,"WeakMap"),Ho=hi(Be,"create"),Ml=Vo&&new Vo,Zi={},Hw=di(Gu),qw=di(Wo),Kw=di(Yu),Uw=di(Qi),jw=di(Vo),Il=Or?Or.prototype:t,qo=Il?Il.valueOf:t,ep=Il?Il.toString:t;function x(l){if(Ge(l)&&!he(l)&&!(l instanceof Se)){if(l instanceof cn)return l;if(_e.call(l,"__wrapped__"))return tm(l)}return new cn(l)}var eo=function(){function l(){}return function(c){if(!Ue(c))return{};if(Gd)return Gd(c);l.prototype=c;var p=new l;return l.prototype=t,p}}();function El(){}function cn(l,c){this.__wrapped__=l,this.__actions__=[],this.__chain__=!!c,this.__index__=0,this.__values__=t}x.templateSettings={escape:lx,evaluate:ax,interpolate:ud,variable:"",imports:{_:x}},x.prototype=El.prototype,x.prototype.constructor=x,cn.prototype=eo(El.prototype),cn.prototype.constructor=cn;function Se(l){this.__wrapped__=l,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=je,this.__views__=[]}function Jw(){var l=new Se(this.__wrapped__);return l.__actions__=Mt(this.__actions__),l.__dir__=this.__dir__,l.__filtered__=this.__filtered__,l.__iteratees__=Mt(this.__iteratees__),l.__takeCount__=this.__takeCount__,l.__views__=Mt(this.__views__),l}function Gw(){if(this.__filtered__){var l=new Se(this);l.__dir__=-1,l.__filtered__=!0}else l=this.clone(),l.__dir__*=-1;return l}function Yw(){var l=this.__wrapped__.value(),c=this.__dir__,p=he(l),y=c<0,b=p?l.length:0,w=aS(0,b,this.__views__),T=w.start,N=w.end,E=N-T,z=y?N:T-1,$=this.__iteratees__,V=$.length,G=0,Z=dt(E,this.__takeCount__);if(!p||!y&&b==E&&Z==E)return vp(l,this.__actions__);var oe=[];e:for(;E--&&G<Z;){z+=c;for(var ge=-1,se=l[z];++ge<V;){var we=$[ge],ve=we.iteratee,jt=we.type,Ct=ve(se);if(jt==ye)se=Ct;else if(!Ct){if(jt==Te)continue e;break e}}oe[G++]=se}return oe}Se.prototype=eo(El.prototype),Se.prototype.constructor=Se;function ai(l){var c=-1,p=l==null?0:l.length;for(this.clear();++c<p;){var y=l[c];this.set(y[0],y[1])}}function Xw(){this.__data__=Ho?Ho(null):{},this.size=0}function Qw(l){var c=this.has(l)&&delete this.__data__[l];return this.size-=c?1:0,c}function Zw(l){var c=this.__data__;if(Ho){var p=c[l];return p===u?t:p}return _e.call(c,l)?c[l]:t}function eC(l){var c=this.__data__;return Ho?c[l]!==t:_e.call(c,l)}function tC(l,c){var p=this.__data__;return this.size+=this.has(l)?0:1,p[l]=Ho&&c===t?u:c,this}ai.prototype.clear=Xw,ai.prototype.delete=Qw,ai.prototype.get=Zw,ai.prototype.has=eC,ai.prototype.set=tC;function rr(l){var c=-1,p=l==null?0:l.length;for(this.clear();++c<p;){var y=l[c];this.set(y[0],y[1])}}function nC(){this.__data__=[],this.size=0}function rC(l){var c=this.__data__,p=Ol(c,l);if(p<0)return!1;var y=c.length-1;return p==y?c.pop():vl.call(c,p,1),--this.size,!0}function iC(l){var c=this.__data__,p=Ol(c,l);return p<0?t:c[p][1]}function oC(l){return Ol(this.__data__,l)>-1}function sC(l,c){var p=this.__data__,y=Ol(p,l);return y<0?(++this.size,p.push([l,c])):p[y][1]=c,this}rr.prototype.clear=nC,rr.prototype.delete=rC,rr.prototype.get=iC,rr.prototype.has=oC,rr.prototype.set=sC;function ir(l){var c=-1,p=l==null?0:l.length;for(this.clear();++c<p;){var y=l[c];this.set(y[0],y[1])}}function lC(){this.size=0,this.__data__={hash:new ai,map:new(Wo||rr),string:new ai}}function aC(l){var c=Hl(this,l).delete(l);return this.size-=c?1:0,c}function uC(l){return Hl(this,l).get(l)}function cC(l){return Hl(this,l).has(l)}function fC(l,c){var p=Hl(this,l),y=p.size;return p.set(l,c),this.size+=p.size==y?0:1,this}ir.prototype.clear=lC,ir.prototype.delete=aC,ir.prototype.get=uC,ir.prototype.has=cC,ir.prototype.set=fC;function ui(l){var c=-1,p=l==null?0:l.length;for(this.__data__=new ir;++c<p;)this.add(l[c])}function hC(l){return this.__data__.set(l,u),this}function dC(l){return this.__data__.has(l)}ui.prototype.add=ui.prototype.push=hC,ui.prototype.has=dC;function In(l){var c=this.__data__=new rr(l);this.size=c.size}function pC(){this.__data__=new rr,this.size=0}function mC(l){var c=this.__data__,p=c.delete(l);return this.size=c.size,p}function gC(l){return this.__data__.get(l)}function yC(l){return this.__data__.has(l)}function kC(l,c){var p=this.__data__;if(p instanceof rr){var y=p.__data__;if(!Wo||y.length<i-1)return y.push([l,c]),this.size=++p.size,this;p=this.__data__=new ir(y)}return p.set(l,c),this.size=p.size,this}In.prototype.clear=pC,In.prototype.delete=mC,In.prototype.get=gC,In.prototype.has=yC,In.prototype.set=kC;function tp(l,c){var p=he(l),y=!p&&pi(l),b=!p&&!y&&Pr(l),w=!p&&!y&&!b&&io(l),T=p||y||b||w,N=T?qu(l.length,Mw):[],E=N.length;for(var z in l)(c||_e.call(l,z))&&!(T&&(z=="length"||b&&(z=="offset"||z=="parent")||w&&(z=="buffer"||z=="byteLength"||z=="byteOffset")||ar(z,E)))&&N.push(z);return N}function np(l){var c=l.length;return c?l[lc(0,c-1)]:t}function bC(l,c){return ql(Mt(l),ci(c,0,l.length))}function xC(l){return ql(Mt(l))}function Xu(l,c,p){(p!==t&&!En(l[c],p)||p===t&&!(c in l))&&or(l,c,p)}function Ko(l,c,p){var y=l[c];(!(_e.call(l,c)&&En(y,p))||p===t&&!(c in l))&&or(l,c,p)}function Ol(l,c){for(var p=l.length;p--;)if(En(l[p][0],c))return p;return-1}function wC(l,c,p,y){return Rr(l,function(b,w,T){c(y,b,p(b),T)}),y}function rp(l,c){return l&&$n(c,it(c),l)}function CC(l,c){return l&&$n(c,Et(c),l)}function or(l,c,p){c=="__proto__"&&Tl?Tl(l,c,{configurable:!0,enumerable:!0,value:p,writable:!0}):l[c]=p}function Qu(l,c){for(var p=-1,y=c.length,b=_(y),w=l==null;++p<y;)b[p]=w?t:Rc(l,c[p]);return b}function ci(l,c,p){return l===l&&(p!==t&&(l=l<=p?l:p),c!==t&&(l=l>=c?l:c)),l}function fn(l,c,p,y,b,w){var T,N=c&d,E=c&m,z=c&g;if(p&&(T=b?p(l,y,b,w):p(l)),T!==t)return T;if(!Ue(l))return l;var $=he(l);if($){if(T=cS(l),!N)return Mt(l,T)}else{var V=pt(l),G=V==qi||V==ll;if(Pr(l))return Np(l,N);if(V==sn||V==At||G&&!b){if(T=E||G?{}:Up(l),!N)return E?ZC(l,CC(T,l)):QC(l,rp(T,l))}else{if(!ze[V])return b?l:{};T=fS(l,V,N)}}w||(w=new In);var Z=w.get(l);if(Z)return Z;w.set(l,T),wm(l)?l.forEach(function(se){T.add(fn(se,c,p,se,l,w))}):bm(l)&&l.forEach(function(se,we){T.set(we,fn(se,c,p,we,l,w))});var oe=z?E?kc:yc:E?Et:it,ge=$?t:oe(l);return an(ge||l,function(se,we){ge&&(we=se,se=l[we]),Ko(T,we,fn(se,c,p,we,l,w))}),T}function SC(l){var c=it(l);return function(p){return ip(p,l,c)}}function ip(l,c,p){var y=p.length;if(l==null)return!y;for(l=Be(l);y--;){var b=p[y],w=c[b],T=l[b];if(T===t&&!(b in l)||!w(T))return!1}return!0}function op(l,c,p){if(typeof l!="function")throw new un(s);return Qo(function(){l.apply(t,p)},c)}function Uo(l,c,p,y){var b=-1,w=pl,T=!0,N=l.length,E=[],z=c.length;if(!N)return E;p&&(c=qe(c,qt(p))),y?(w=Fu,T=!1):c.length>=i&&(w=zo,T=!1,c=new ui(c));e:for(;++b<N;){var $=l[b],V=p==null?$:p($);if($=y||$!==0?$:0,T&&V===V){for(var G=z;G--;)if(c[G]===V)continue e;E.push($)}else w(c,V,y)||E.push($)}return E}var Rr=Rp(zn),sp=Rp(ec,!0);function vC(l,c){var p=!0;return Rr(l,function(y,b,w){return p=!!c(y,b,w),p}),p}function Rl(l,c,p){for(var y=-1,b=l.length;++y<b;){var w=l[y],T=c(w);if(T!=null&&(N===t?T===T&&!Ut(T):p(T,N)))var N=T,E=w}return E}function TC(l,c,p,y){var b=l.length;for(p=me(p),p<0&&(p=-p>b?0:b+p),y=y===t||y>b?b:me(y),y<0&&(y+=b),y=p>y?0:Sm(y);p<y;)l[p++]=c;return l}function lp(l,c){var p=[];return Rr(l,function(y,b,w){c(y,b,w)&&p.push(y)}),p}function at(l,c,p,y,b){var w=-1,T=l.length;for(p||(p=dS),b||(b=[]);++w<T;){var N=l[w];c>0&&p(N)?c>1?at(N,c-1,p,y,b):Ir(b,N):y||(b[b.length]=N)}return b}var Zu=_p(),ap=_p(!0);function zn(l,c){return l&&Zu(l,c,it)}function ec(l,c){return l&&ap(l,c,it)}function _l(l,c){return Mr(c,function(p){return ur(l[p])})}function fi(l,c){c=Dr(c,l);for(var p=0,y=c.length;l!=null&&p<y;)l=l[Wn(c[p++])];return p&&p==y?l:t}function up(l,c,p){var y=c(l);return he(l)?y:Ir(y,p(l))}function xt(l){return l==null?l===t?Mu:al:li&&li in Be(l)?lS(l):xS(l)}function tc(l,c){return l>c}function AC(l,c){return l!=null&&_e.call(l,c)}function NC(l,c){return l!=null&&c in Be(l)}function MC(l,c,p){return l>=dt(c,p)&&l<tt(c,p)}function nc(l,c,p){for(var y=p?Fu:pl,b=l[0].length,w=l.length,T=w,N=_(w),E=1/0,z=[];T--;){var $=l[T];T&&c&&($=qe($,qt(c))),E=dt($.length,E),N[T]=!p&&(c||b>=120&&$.length>=120)?new ui(T&&$):t}$=l[0];var V=-1,G=N[0];e:for(;++V<b&&z.length<E;){var Z=$[V],oe=c?c(Z):Z;if(Z=p||Z!==0?Z:0,!(G?zo(G,oe):y(z,oe,p))){for(T=w;--T;){var ge=N[T];if(!(ge?zo(ge,oe):y(l[T],oe,p)))continue e}G&&G.push(oe),z.push(Z)}}return z}function IC(l,c,p,y){return zn(l,function(b,w,T){c(y,p(b),w,T)}),y}function jo(l,c,p){c=Dr(c,l),l=Yp(l,c);var y=l==null?l:l[Wn(dn(c))];return y==null?t:Ht(y,l,p)}function cp(l){return Ge(l)&&xt(l)==At}function EC(l){return Ge(l)&&xt(l)==U}function OC(l){return Ge(l)&&xt(l)==on}function Jo(l,c,p,y,b){return l===c?!0:l==null||c==null||!Ge(l)&&!Ge(c)?l!==l&&c!==c:RC(l,c,p,y,Jo,b)}function RC(l,c,p,y,b,w){var T=he(l),N=he(c),E=T?Je:pt(l),z=N?Je:pt(c);E=E==At?sn:E,z=z==At?sn:z;var $=E==sn,V=z==sn,G=E==z;if(G&&Pr(l)){if(!Pr(c))return!1;T=!0,$=!1}if(G&&!$)return w||(w=new In),T||io(l)?Hp(l,c,p,y,b,w):oS(l,c,E,p,y,b,w);if(!(p&k)){var Z=$&&_e.call(l,"__wrapped__"),oe=V&&_e.call(c,"__wrapped__");if(Z||oe){var ge=Z?l.value():l,se=oe?c.value():c;return w||(w=new In),b(ge,se,p,y,w)}}return G?(w||(w=new In),sS(l,c,p,y,b,w)):!1}function _C(l){return Ge(l)&&pt(l)==$t}function rc(l,c,p,y){var b=p.length,w=b,T=!y;if(l==null)return!w;for(l=Be(l);b--;){var N=p[b];if(T&&N[2]?N[1]!==l[N[0]]:!(N[0]in l))return!1}for(;++b<w;){N=p[b];var E=N[0],z=l[E],$=N[1];if(T&&N[2]){if(z===t&&!(E in l))return!1}else{var V=new In;if(y)var G=y(z,$,E,l,c,V);if(!(G===t?Jo($,z,k|C,y,V):G))return!1}}return!0}function fp(l){if(!Ue(l)||mS(l))return!1;var c=ur(l)?_w:Sx;return c.test(di(l))}function DC(l){return Ge(l)&&xt(l)==Nr}function LC(l){return Ge(l)&&pt(l)==Wt}function PC(l){return Ge(l)&&Yl(l.length)&&!!We[xt(l)]}function hp(l){return typeof l=="function"?l:l==null?Ot:typeof l=="object"?he(l)?mp(l[0],l[1]):pp(l):Dm(l)}function ic(l){if(!Xo(l))return zw(l);var c=[];for(var p in Be(l))_e.call(l,p)&&p!="constructor"&&c.push(p);return c}function BC(l){if(!Ue(l))return bS(l);var c=Xo(l),p=[];for(var y in l)y=="constructor"&&(c||!_e.call(l,y))||p.push(y);return p}function oc(l,c){return l<c}function dp(l,c){var p=-1,y=It(l)?_(l.length):[];return Rr(l,function(b,w,T){y[++p]=c(b,w,T)}),y}function pp(l){var c=xc(l);return c.length==1&&c[0][2]?Jp(c[0][0],c[0][1]):function(p){return p===l||rc(p,l,c)}}function mp(l,c){return Cc(l)&&jp(c)?Jp(Wn(l),c):function(p){var y=Rc(p,l);return y===t&&y===c?_c(p,l):Jo(c,y,k|C)}}function Dl(l,c,p,y,b){l!==c&&Zu(c,function(w,T){if(b||(b=new In),Ue(w))FC(l,c,T,p,Dl,y,b);else{var N=y?y(vc(l,T),w,T+"",l,c,b):t;N===t&&(N=w),Xu(l,T,N)}},Et)}function FC(l,c,p,y,b,w,T){var N=vc(l,p),E=vc(c,p),z=T.get(E);if(z){Xu(l,p,z);return}var $=w?w(N,E,p+"",l,c,T):t,V=$===t;if(V){var G=he(E),Z=!G&&Pr(E),oe=!G&&!Z&&io(E);$=E,G||Z||oe?he(N)?$=N:Ye(N)?$=Mt(N):Z?(V=!1,$=Np(E,!0)):oe?(V=!1,$=Mp(E,!0)):$=[]:Zo(E)||pi(E)?($=N,pi(N)?$=vm(N):(!Ue(N)||ur(N))&&($=Up(E))):V=!1}V&&(T.set(E,$),b($,E,y,w,T),T.delete(E)),Xu(l,p,$)}function gp(l,c){var p=l.length;if(p)return c+=c<0?p:0,ar(c,p)?l[c]:t}function yp(l,c,p){c.length?c=qe(c,function(w){return he(w)?function(T){return fi(T,w.length===1?w[0]:w)}:w}):c=[Ot];var y=-1;c=qe(c,qt(re()));var b=dp(l,function(w,T,N){var E=qe(c,function(z){return z(w)});return{criteria:E,index:++y,value:w}});return fw(b,function(w,T){return XC(w,T,p)})}function zC(l,c){return kp(l,c,function(p,y){return _c(l,y)})}function kp(l,c,p){for(var y=-1,b=c.length,w={};++y<b;){var T=c[y],N=fi(l,T);p(N,T)&&Go(w,Dr(T,l),N)}return w}function $C(l){return function(c){return fi(c,l)}}function sc(l,c,p,y){var b=y?cw:ji,w=-1,T=c.length,N=l;for(l===c&&(c=Mt(c)),p&&(N=qe(l,qt(p)));++w<T;)for(var E=0,z=c[w],$=p?p(z):z;(E=b(N,$,E,y))>-1;)N!==l&&vl.call(N,E,1),vl.call(l,E,1);return l}function bp(l,c){for(var p=l?c.length:0,y=p-1;p--;){var b=c[p];if(p==y||b!==w){var w=b;ar(b)?vl.call(l,b,1):cc(l,b)}}return l}function lc(l,c){return l+Nl(Zd()*(c-l+1))}function WC(l,c,p,y){for(var b=-1,w=tt(Al((c-l)/(p||1)),0),T=_(w);w--;)T[y?w:++b]=l,l+=p;return T}function ac(l,c){var p="";if(!l||c<1||c>Ee)return p;do c%2&&(p+=l),c=Nl(c/2),c&&(l+=l);while(c);return p}function be(l,c){return Tc(Gp(l,c,Ot),l+"")}function VC(l){return np(oo(l))}function HC(l,c){var p=oo(l);return ql(p,ci(c,0,p.length))}function Go(l,c,p,y){if(!Ue(l))return l;c=Dr(c,l);for(var b=-1,w=c.length,T=w-1,N=l;N!=null&&++b<w;){var E=Wn(c[b]),z=p;if(E==="__proto__"||E==="constructor"||E==="prototype")return l;if(b!=T){var $=N[E];z=y?y($,E,N):t,z===t&&(z=Ue($)?$:ar(c[b+1])?[]:{})}Ko(N,E,z),N=N[E]}return l}var xp=Ml?function(l,c){return Ml.set(l,c),l}:Ot,qC=Tl?function(l,c){return Tl(l,"toString",{configurable:!0,enumerable:!1,value:Lc(c),writable:!0})}:Ot;function KC(l){return ql(oo(l))}function hn(l,c,p){var y=-1,b=l.length;c<0&&(c=-c>b?0:b+c),p=p>b?b:p,p<0&&(p+=b),b=c>p?0:p-c>>>0,c>>>=0;for(var w=_(b);++y<b;)w[y]=l[y+c];return w}function UC(l,c){var p;return Rr(l,function(y,b,w){return p=c(y,b,w),!p}),!!p}function Ll(l,c,p){var y=0,b=l==null?y:l.length;if(typeof c=="number"&&c===c&&b<=M){for(;y<b;){var w=y+b>>>1,T=l[w];T!==null&&!Ut(T)&&(p?T<=c:T<c)?y=w+1:b=w}return b}return uc(l,c,Ot,p)}function uc(l,c,p,y){var b=0,w=l==null?0:l.length;if(w===0)return 0;c=p(c);for(var T=c!==c,N=c===null,E=Ut(c),z=c===t;b<w;){var $=Nl((b+w)/2),V=p(l[$]),G=V!==t,Z=V===null,oe=V===V,ge=Ut(V);if(T)var se=y||oe;else z?se=oe&&(y||G):N?se=oe&&G&&(y||!Z):E?se=oe&&G&&!Z&&(y||!ge):Z||ge?se=!1:se=y?V<=c:V<c;se?b=$+1:w=$}return dt(w,Tn)}function wp(l,c){for(var p=-1,y=l.length,b=0,w=[];++p<y;){var T=l[p],N=c?c(T):T;if(!p||!En(N,E)){var E=N;w[b++]=T===0?0:T}}return w}function Cp(l){return typeof l=="number"?l:Ut(l)?A:+l}function Kt(l){if(typeof l=="string")return l;if(he(l))return qe(l,Kt)+"";if(Ut(l))return ep?ep.call(l):"";var c=l+"";return c=="0"&&1/l==-Me?"-0":c}function _r(l,c,p){var y=-1,b=pl,w=l.length,T=!0,N=[],E=N;if(p)T=!1,b=Fu;else if(w>=i){var z=c?null:rS(l);if(z)return gl(z);T=!1,b=zo,E=new ui}else E=c?[]:N;e:for(;++y<w;){var $=l[y],V=c?c($):$;if($=p||$!==0?$:0,T&&V===V){for(var G=E.length;G--;)if(E[G]===V)continue e;c&&E.push(V),N.push($)}else b(E,V,p)||(E!==N&&E.push(V),N.push($))}return N}function cc(l,c){c=Dr(c,l);var p=-1,y=c.length;if(!y)return!0;for(var b=l==null||typeof l!="object"&&typeof l!="function";++p<y;){var w=c[p];if(typeof w=="string"){if(w==="__proto__"&&!_e.call(l,"__proto__"))return!1;if(w==="constructor"&&p+1<y&&typeof c[p+1]=="string"&&c[p+1]==="prototype"){if(b&&p===0)continue;return!1}}}var T=Yp(l,c);return T==null||delete T[Wn(dn(c))]}function Sp(l,c,p,y){return Go(l,c,p(fi(l,c)),y)}function Pl(l,c,p,y){for(var b=l.length,w=y?b:-1;(y?w--:++w<b)&&c(l[w],w,l););return p?hn(l,y?0:w,y?w+1:b):hn(l,y?w+1:0,y?b:w)}function vp(l,c){var p=l;return p instanceof Se&&(p=p.value()),zu(c,function(y,b){return b.func.apply(b.thisArg,Ir([y],b.args))},p)}function fc(l,c,p){var y=l.length;if(y<2)return y?_r(l[0]):[];for(var b=-1,w=_(y);++b<y;)for(var T=l[b],N=-1;++N<y;)N!=b&&(w[b]=Uo(w[b]||T,l[N],c,p));return _r(at(w,1),c,p)}function Tp(l,c,p){for(var y=-1,b=l.length,w=c.length,T={};++y<b;){var N=y<w?c[y]:t;p(T,l[y],N)}return T}function hc(l){return Ye(l)?l:[]}function dc(l){return typeof l=="function"?l:Ot}function Dr(l,c){return he(l)?l:Cc(l,c)?[l]:em(De(l))}var jC=be;function Lr(l,c,p){var y=l.length;return p=p===t?y:p,!c&&p>=y?l:hn(l,c,p)}var Ap=Dw||function(l){return lt.clearTimeout(l)};function Np(l,c){if(c)return l.slice();var p=l.length,y=Jd?Jd(p):new l.constructor(p);return l.copy(y),y}function pc(l){var c=new l.constructor(l.byteLength);return new Cl(c).set(new Cl(l)),c}function JC(l,c){var p=c?pc(l.buffer):l.buffer;return new l.constructor(p,l.byteOffset,l.byteLength)}function GC(l){var c=new l.constructor(l.source,cd.exec(l));return c.lastIndex=l.lastIndex,c}function YC(l){return qo?Be(qo.call(l)):{}}function Mp(l,c){var p=c?pc(l.buffer):l.buffer;return new l.constructor(p,l.byteOffset,l.length)}function Ip(l,c){if(l!==c){var p=l!==t,y=l===null,b=l===l,w=Ut(l),T=c!==t,N=c===null,E=c===c,z=Ut(c);if(!N&&!z&&!w&&l>c||w&&T&&E&&!N&&!z||y&&T&&E||!p&&E||!b)return 1;if(!y&&!w&&!z&&l<c||z&&p&&b&&!y&&!w||N&&p&&b||!T&&b||!E)return-1}return 0}function XC(l,c,p){for(var y=-1,b=l.criteria,w=c.criteria,T=b.length,N=p.length;++y<T;){var E=Ip(b[y],w[y]);if(E){if(y>=N)return E;var z=p[y];return E*(z=="desc"?-1:1)}}return l.index-c.index}function Ep(l,c,p,y){for(var b=-1,w=l.length,T=p.length,N=-1,E=c.length,z=tt(w-T,0),$=_(E+z),V=!y;++N<E;)$[N]=c[N];for(;++b<T;)(V||b<w)&&($[p[b]]=l[b]);for(;z--;)$[N++]=l[b++];return $}function Op(l,c,p,y){for(var b=-1,w=l.length,T=-1,N=p.length,E=-1,z=c.length,$=tt(w-N,0),V=_($+z),G=!y;++b<$;)V[b]=l[b];for(var Z=b;++E<z;)V[Z+E]=c[E];for(;++T<N;)(G||b<w)&&(V[Z+p[T]]=l[b++]);return V}function Mt(l,c){var p=-1,y=l.length;for(c||(c=_(y));++p<y;)c[p]=l[p];return c}function $n(l,c,p,y){var b=!p;p||(p={});for(var w=-1,T=c.length;++w<T;){var N=c[w],E=y?y(p[N],l[N],N,p,l):t;E===t&&(E=l[N]),b?or(p,N,E):Ko(p,N,E)}return p}function QC(l,c){return $n(l,wc(l),c)}function ZC(l,c){return $n(l,qp(l),c)}function Bl(l,c){return function(p,y){var b=he(p)?iw:wC,w=c?c():{};return b(p,l,re(y,2),w)}}function to(l){return be(function(c,p){var y=-1,b=p.length,w=b>1?p[b-1]:t,T=b>2?p[2]:t;for(w=l.length>3&&typeof w=="function"?(b--,w):t,T&&wt(p[0],p[1],T)&&(w=b<3?t:w,b=1),c=Be(c);++y<b;){var N=p[y];N&&l(c,N,y,w)}return c})}function Rp(l,c){return function(p,y){if(p==null)return p;if(!It(p))return l(p,y);for(var b=p.length,w=c?b:-1,T=Be(p);(c?w--:++w<b)&&y(T[w],w,T)!==!1;);return p}}function _p(l){return function(c,p,y){for(var b=-1,w=Be(c),T=y(c),N=T.length;N--;){var E=T[l?N:++b];if(p(w[E],E,w)===!1)break}return c}}function eS(l,c,p){var y=c&v,b=Yo(l);function w(){var T=this&&this!==lt&&this instanceof w?b:l;return T.apply(y?p:this,arguments)}return w}function Dp(l){return function(c){c=De(c);var p=Ji(c)?Mn(c):t,y=p?p[0]:c.charAt(0),b=p?Lr(p,1).join(""):c.slice(1);return y[l]()+b}}function no(l){return function(c){return zu(Rm(Om(c).replace(qx,"")),l,"")}}function Yo(l){return function(){var c=arguments;switch(c.length){case 0:return new l;case 1:return new l(c[0]);case 2:return new l(c[0],c[1]);case 3:return new l(c[0],c[1],c[2]);case 4:return new l(c[0],c[1],c[2],c[3]);case 5:return new l(c[0],c[1],c[2],c[3],c[4]);case 6:return new l(c[0],c[1],c[2],c[3],c[4],c[5]);case 7:return new l(c[0],c[1],c[2],c[3],c[4],c[5],c[6])}var p=eo(l.prototype),y=l.apply(p,c);return Ue(y)?y:p}}function tS(l,c,p){var y=Yo(l);function b(){for(var w=arguments.length,T=_(w),N=w,E=ro(b);N--;)T[N]=arguments[N];var z=w<3&&T[0]!==E&&T[w-1]!==E?[]:Er(T,E);if(w-=z.length,w<p)return zp(l,c,Fl,b.placeholder,t,T,z,t,t,p-w);var $=this&&this!==lt&&this instanceof b?y:l;return Ht($,this,T)}return b}function Lp(l){return function(c,p,y){var b=Be(c);if(!It(c)){var w=re(p,3);c=it(c),p=function(N){return w(b[N],N,b)}}var T=l(c,p,y);return T>-1?b[w?c[T]:T]:t}}function Pp(l){return lr(function(c){var p=c.length,y=p,b=cn.prototype.thru;for(l&&c.reverse();y--;){var w=c[y];if(typeof w!="function")throw new un(s);if(b&&!T&&Vl(w)=="wrapper")var T=new cn([],!0)}for(y=T?y:p;++y<p;){w=c[y];var N=Vl(w),E=N=="wrapper"?bc(w):t;E&&Sc(E[0])&&E[1]==(H|R|q|X)&&!E[4].length&&E[9]==1?T=T[Vl(E[0])].apply(T,E[3]):T=w.length==1&&Sc(w)?T[N]():T.thru(w)}return function(){var z=arguments,$=z[0];if(T&&z.length==1&&he($))return T.plant($).value();for(var V=0,G=p?c[V].apply(this,z):$;++V<p;)G=c[V].call(this,G);return G}})}function Fl(l,c,p,y,b,w,T,N,E,z){var $=c&H,V=c&v,G=c&S,Z=c&(R|K),oe=c&te,ge=G?t:Yo(l);function se(){for(var we=arguments.length,ve=_(we),jt=we;jt--;)ve[jt]=arguments[jt];if(Z)var Ct=ro(se),Jt=dw(ve,Ct);if(y&&(ve=Ep(ve,y,b,Z)),w&&(ve=Op(ve,w,T,Z)),we-=Jt,Z&&we<z){var Xe=Er(ve,Ct);return zp(l,c,Fl,se.placeholder,p,ve,Xe,N,E,z-we)}var On=V?p:this,fr=G?On[l]:l;return we=ve.length,N?ve=wS(ve,N):oe&&we>1&&ve.reverse(),$&&E<we&&(ve.length=E),this&&this!==lt&&this instanceof se&&(fr=ge||Yo(fr)),fr.apply(On,ve)}return se}function Bp(l,c){return function(p,y){return IC(p,l,c(y),{})}}function zl(l,c){return function(p,y){var b;if(p===t&&y===t)return c;if(p!==t&&(b=p),y!==t){if(b===t)return y;typeof p=="string"||typeof y=="string"?(p=Kt(p),y=Kt(y)):(p=Cp(p),y=Cp(y)),b=l(p,y)}return b}}function mc(l){return lr(function(c){return c=qe(c,qt(re())),be(function(p){var y=this;return l(c,function(b){return Ht(b,y,p)})})})}function $l(l,c){c=c===t?" ":Kt(c);var p=c.length;if(p<2)return p?ac(c,l):c;var y=ac(c,Al(l/Gi(c)));return Ji(c)?Lr(Mn(y),0,l).join(""):y.slice(0,l)}function nS(l,c,p,y){var b=c&v,w=Yo(l);function T(){for(var N=-1,E=arguments.length,z=-1,$=y.length,V=_($+E),G=this&&this!==lt&&this instanceof T?w:l;++z<$;)V[z]=y[z];for(;E--;)V[z++]=arguments[++N];return Ht(G,b?p:this,V)}return T}function Fp(l){return function(c,p,y){return y&&typeof y!="number"&&wt(c,p,y)&&(p=y=t),c=cr(c),p===t?(p=c,c=0):p=cr(p),y=y===t?c<p?1:-1:cr(y),WC(c,p,y,l)}}function Wl(l){return function(c,p){return typeof c=="string"&&typeof p=="string"||(c=pn(c),p=pn(p)),l(c,p)}}function zp(l,c,p,y,b,w,T,N,E,z){var $=c&R,V=$?T:t,G=$?t:T,Z=$?w:t,oe=$?t:w;c|=$?q:O,c&=~($?O:q),c&L||(c&=-4);var ge=[l,c,b,Z,V,oe,G,N,E,z],se=p.apply(t,ge);return Sc(l)&&Xp(se,ge),se.placeholder=y,Qp(se,l,c)}function gc(l){var c=et[l];return function(p,y){if(p=pn(p),y=y==null?0:dt(me(y),292),y&&Qd(p)){var b=(De(p)+"e").split("e"),w=c(b[0]+"e"+(+b[1]+y));return b=(De(w)+"e").split("e"),+(b[0]+"e"+(+b[1]-y))}return c(p)}}var rS=Qi&&1/gl(new Qi([,-0]))[1]==Me?function(l){return new Qi(l)}:Fc;function $p(l){return function(c){var p=pt(c);return p==$t?Uu(c):p==Wt?xw(c):hw(c,l(c))}}function sr(l,c,p,y,b,w,T,N){var E=c&S;if(!E&&typeof l!="function")throw new un(s);var z=y?y.length:0;if(z||(c&=-97,y=b=t),T=T===t?T:tt(me(T),0),N=N===t?N:me(N),z-=b?b.length:0,c&O){var $=y,V=b;y=b=t}var G=E?t:bc(l),Z=[l,c,p,y,b,$,V,w,T,N];if(G&&kS(Z,G),l=Z[0],c=Z[1],p=Z[2],y=Z[3],b=Z[4],N=Z[9]=Z[9]===t?E?0:l.length:tt(Z[9]-z,0),!N&&c&(R|K)&&(c&=-25),!c||c==v)var oe=eS(l,c,p);else c==R||c==K?oe=tS(l,c,N):(c==q||c==(v|q))&&!b.length?oe=nS(l,c,p,y):oe=Fl.apply(t,Z);var ge=G?xp:Xp;return Qp(ge(oe,Z),l,c)}function Wp(l,c,p,y){return l===t||En(l,Xi[p])&&!_e.call(y,p)?c:l}function Vp(l,c,p,y,b,w){return Ue(l)&&Ue(c)&&(w.set(c,l),Dl(l,c,t,Vp,w),w.delete(c)),l}function iS(l){return Zo(l)?t:l}function Hp(l,c,p,y,b,w){var T=p&k,N=l.length,E=c.length;if(N!=E&&!(T&&E>N))return!1;var z=w.get(l),$=w.get(c);if(z&&$)return z==c&&$==l;var V=-1,G=!0,Z=p&C?new ui:t;for(w.set(l,c),w.set(c,l);++V<N;){var oe=l[V],ge=c[V];if(y)var se=T?y(ge,oe,V,c,l,w):y(oe,ge,V,l,c,w);if(se!==t){if(se)continue;G=!1;break}if(Z){if(!$u(c,function(we,ve){if(!zo(Z,ve)&&(oe===we||b(oe,we,p,y,w)))return Z.push(ve)})){G=!1;break}}else if(!(oe===ge||b(oe,ge,p,y,w))){G=!1;break}}return w.delete(l),w.delete(c),G}function oS(l,c,p,y,b,w,T){switch(p){case ie:if(l.byteLength!=c.byteLength||l.byteOffset!=c.byteOffset)return!1;l=l.buffer,c=c.buffer;case U:return!(l.byteLength!=c.byteLength||!w(new Cl(l),new Cl(c)));case Nt:case on:case Ar:return En(+l,+c);case er:return l.name==c.name&&l.message==c.message;case Nr:case ii:return l==c+"";case $t:var N=Uu;case Wt:var E=y&k;if(N||(N=gl),l.size!=c.size&&!E)return!1;var z=T.get(l);if(z)return z==c;y|=C,T.set(l,c);var $=Hp(N(l),N(c),y,b,w,T);return T.delete(l),$;case Ki:if(qo)return qo.call(l)==qo.call(c)}return!1}function sS(l,c,p,y,b,w){var T=p&k,N=yc(l),E=N.length,z=yc(c),$=z.length;if(E!=$&&!T)return!1;for(var V=E;V--;){var G=N[V];if(!(T?G in c:_e.call(c,G)))return!1}var Z=w.get(l),oe=w.get(c);if(Z&&oe)return Z==c&&oe==l;var ge=!0;w.set(l,c),w.set(c,l);for(var se=T;++V<E;){G=N[V];var we=l[G],ve=c[G];if(y)var jt=T?y(ve,we,G,c,l,w):y(we,ve,G,l,c,w);if(!(jt===t?we===ve||b(we,ve,p,y,w):jt)){ge=!1;break}se||(se=G=="constructor")}if(ge&&!se){var Ct=l.constructor,Jt=c.constructor;Ct!=Jt&&"constructor"in l&&"constructor"in c&&!(typeof Ct=="function"&&Ct instanceof Ct&&typeof Jt=="function"&&Jt instanceof Jt)&&(ge=!1)}return w.delete(l),w.delete(c),ge}function lr(l){return Tc(Gp(l,t,im),l+"")}function yc(l){return up(l,it,wc)}function kc(l){return up(l,Et,qp)}var bc=Ml?function(l){return Ml.get(l)}:Fc;function Vl(l){for(var c=l.name+"",p=Zi[c],y=_e.call(Zi,c)?p.length:0;y--;){var b=p[y],w=b.func;if(w==null||w==l)return b.name}return c}function ro(l){var c=_e.call(x,"placeholder")?x:l;return c.placeholder}function re(){var l=x.iteratee||Pc;return l=l===Pc?hp:l,arguments.length?l(arguments[0],arguments[1]):l}function Hl(l,c){var p=l.__data__;return pS(c)?p[typeof c=="string"?"string":"hash"]:p.map}function xc(l){for(var c=it(l),p=c.length;p--;){var y=c[p],b=l[y];c[p]=[y,b,jp(b)]}return c}function hi(l,c){var p=yw(l,c);return fp(p)?p:t}function lS(l){var c=_e.call(l,li),p=l[li];try{l[li]=t;var y=!0}catch{}var b=xl.call(l);return y&&(c?l[li]=p:delete l[li]),b}var wc=Ju?function(l){return l==null?[]:(l=Be(l),Mr(Ju(l),function(c){return Yd.call(l,c)}))}:zc,qp=Ju?function(l){for(var c=[];l;)Ir(c,wc(l)),l=Sl(l);return c}:zc,pt=xt;(Gu&&pt(new Gu(new ArrayBuffer(1)))!=ie||Wo&&pt(new Wo)!=$t||Yu&&pt(Yu.resolve())!=ul||Qi&&pt(new Qi)!=Wt||Vo&&pt(new Vo)!=oi)&&(pt=function(l){var c=xt(l),p=c==sn?l.constructor:t,y=p?di(p):"";if(y)switch(y){case Hw:return ie;case qw:return $t;case Kw:return ul;case Uw:return Wt;case jw:return oi}return c});function aS(l,c,p){for(var y=-1,b=p.length;++y<b;){var w=p[y],T=w.size;switch(w.type){case"drop":l+=T;break;case"dropRight":c-=T;break;case"take":c=dt(c,l+T);break;case"takeRight":l=tt(l,c-T);break}}return{start:l,end:c}}function uS(l){var c=l.match(mx);return c?c[1].split(gx):[]}function Kp(l,c,p){c=Dr(c,l);for(var y=-1,b=c.length,w=!1;++y<b;){var T=Wn(c[y]);if(!(w=l!=null&&p(l,T)))break;l=l[T]}return w||++y!=b?w:(b=l==null?0:l.length,!!b&&Yl(b)&&ar(T,b)&&(he(l)||pi(l)))}function cS(l){var c=l.length,p=new l.constructor(c);return c&&typeof l[0]=="string"&&_e.call(l,"index")&&(p.index=l.index,p.input=l.input),p}function Up(l){return typeof l.constructor=="function"&&!Xo(l)?eo(Sl(l)):{}}function fS(l,c,p){var y=l.constructor;switch(c){case U:return pc(l);case Nt:case on:return new y(+l);case ie:return JC(l,p);case ke:case Oe:case bt:case An:case Vt:case tr:case nr:case st:case Fn:return Mp(l,p);case $t:return new y;case Ar:case ii:return new y(l);case Nr:return GC(l);case Wt:return new y;case Ki:return YC(l)}}function hS(l,c){var p=c.length;if(!p)return l;var y=p-1;return c[y]=(p>1?"& ":"")+c[y],c=c.join(p>2?", ":" "),l.replace(px,`{
57
+ /* [wrapped with `+c+`] */
58
+ `)}function dS(l){return he(l)||pi(l)||!!(Xd&&l&&l[Xd])}function ar(l,c){var p=typeof l;return c=c??Ee,!!c&&(p=="number"||p!="symbol"&&Tx.test(l))&&l>-1&&l%1==0&&l<c}function wt(l,c,p){if(!Ue(p))return!1;var y=typeof c;return(y=="number"?It(p)&&ar(c,p.length):y=="string"&&c in p)?En(p[c],l):!1}function Cc(l,c){if(he(l))return!1;var p=typeof l;return p=="number"||p=="symbol"||p=="boolean"||l==null||Ut(l)?!0:cx.test(l)||!ux.test(l)||c!=null&&l in Be(c)}function pS(l){var c=typeof l;return c=="string"||c=="number"||c=="symbol"||c=="boolean"?l!=="__proto__":l===null}function Sc(l){var c=Vl(l),p=x[c];if(typeof p!="function"||!(c in Se.prototype))return!1;if(l===p)return!0;var y=bc(p);return!!y&&l===y[0]}function mS(l){return!!jd&&jd in l}var gS=kl?ur:$c;function Xo(l){var c=l&&l.constructor,p=typeof c=="function"&&c.prototype||Xi;return l===p}function jp(l){return l===l&&!Ue(l)}function Jp(l,c){return function(p){return p==null?!1:p[l]===c&&(c!==t||l in Be(p))}}function yS(l){var c=Jl(l,function(y){return p.size===f&&p.clear(),y}),p=c.cache;return c}function kS(l,c){var p=l[1],y=c[1],b=p|y,w=b<(v|S|H),T=y==H&&p==R||y==H&&p==X&&l[7].length<=c[8]||y==(H|X)&&c[7].length<=c[8]&&p==R;if(!(w||T))return l;y&v&&(l[2]=c[2],b|=p&v?0:L);var N=c[3];if(N){var E=l[3];l[3]=E?Ep(E,N,c[4]):N,l[4]=E?Er(l[3],h):c[4]}return N=c[5],N&&(E=l[5],l[5]=E?Op(E,N,c[6]):N,l[6]=E?Er(l[5],h):c[6]),N=c[7],N&&(l[7]=N),y&H&&(l[8]=l[8]==null?c[8]:dt(l[8],c[8])),l[9]==null&&(l[9]=c[9]),l[0]=c[0],l[1]=b,l}function bS(l){var c=[];if(l!=null)for(var p in Be(l))c.push(p);return c}function xS(l){return xl.call(l)}function Gp(l,c,p){return c=tt(c===t?l.length-1:c,0),function(){for(var y=arguments,b=-1,w=tt(y.length-c,0),T=_(w);++b<w;)T[b]=y[c+b];b=-1;for(var N=_(c+1);++b<c;)N[b]=y[b];return N[c]=p(T),Ht(l,this,N)}}function Yp(l,c){return c.length<2?l:fi(l,hn(c,0,-1))}function wS(l,c){for(var p=l.length,y=dt(c.length,p),b=Mt(l);y--;){var w=c[y];l[y]=ar(w,p)?b[w]:t}return l}function vc(l,c){if(!(c==="constructor"&&typeof l[c]=="function")&&c!="__proto__")return l[c]}var Xp=Zp(xp),Qo=Pw||function(l,c){return lt.setTimeout(l,c)},Tc=Zp(qC);function Qp(l,c,p){var y=c+"";return Tc(l,hS(y,CS(uS(y),p)))}function Zp(l){var c=0,p=0;return function(){var y=$w(),b=Ie-(y-p);if(p=y,b>0){if(++c>=ee)return arguments[0]}else c=0;return l.apply(t,arguments)}}function ql(l,c){var p=-1,y=l.length,b=y-1;for(c=c===t?y:c;++p<c;){var w=lc(p,b),T=l[w];l[w]=l[p],l[p]=T}return l.length=c,l}var em=yS(function(l){var c=[];return l.charCodeAt(0)===46&&c.push(""),l.replace(fx,function(p,y,b,w){c.push(b?w.replace(bx,"$1"):y||p)}),c});function Wn(l){if(typeof l=="string"||Ut(l))return l;var c=l+"";return c=="0"&&1/l==-Me?"-0":c}function di(l){if(l!=null){try{return bl.call(l)}catch{}try{return l+""}catch{}}return""}function CS(l,c){return an(zt,function(p){var y="_."+p[0];c&p[1]&&!pl(l,y)&&l.push(y)}),l.sort()}function tm(l){if(l instanceof Se)return l.clone();var c=new cn(l.__wrapped__,l.__chain__);return c.__actions__=Mt(l.__actions__),c.__index__=l.__index__,c.__values__=l.__values__,c}function SS(l,c,p){(p?wt(l,c,p):c===t)?c=1:c=tt(me(c),0);var y=l==null?0:l.length;if(!y||c<1)return[];for(var b=0,w=0,T=_(Al(y/c));b<y;)T[w++]=hn(l,b,b+=c);return T}function vS(l){for(var c=-1,p=l==null?0:l.length,y=0,b=[];++c<p;){var w=l[c];w&&(b[y++]=w)}return b}function TS(){var l=arguments.length;if(!l)return[];for(var c=_(l-1),p=arguments[0],y=l;y--;)c[y-1]=arguments[y];return Ir(he(p)?Mt(p):[p],at(c,1))}var AS=be(function(l,c){return Ye(l)?Uo(l,at(c,1,Ye,!0)):[]}),NS=be(function(l,c){var p=dn(c);return Ye(p)&&(p=t),Ye(l)?Uo(l,at(c,1,Ye,!0),re(p,2)):[]}),MS=be(function(l,c){var p=dn(c);return Ye(p)&&(p=t),Ye(l)?Uo(l,at(c,1,Ye,!0),t,p):[]});function IS(l,c,p){var y=l==null?0:l.length;return y?(c=p||c===t?1:me(c),hn(l,c<0?0:c,y)):[]}function ES(l,c,p){var y=l==null?0:l.length;return y?(c=p||c===t?1:me(c),c=y-c,hn(l,0,c<0?0:c)):[]}function OS(l,c){return l&&l.length?Pl(l,re(c,3),!0,!0):[]}function RS(l,c){return l&&l.length?Pl(l,re(c,3),!0):[]}function _S(l,c,p,y){var b=l==null?0:l.length;return b?(p&&typeof p!="number"&&wt(l,c,p)&&(p=0,y=b),TC(l,c,p,y)):[]}function nm(l,c,p){var y=l==null?0:l.length;if(!y)return-1;var b=p==null?0:me(p);return b<0&&(b=tt(y+b,0)),ml(l,re(c,3),b)}function rm(l,c,p){var y=l==null?0:l.length;if(!y)return-1;var b=y-1;return p!==t&&(b=me(p),b=p<0?tt(y+b,0):dt(b,y-1)),ml(l,re(c,3),b,!0)}function im(l){var c=l==null?0:l.length;return c?at(l,1):[]}function DS(l){var c=l==null?0:l.length;return c?at(l,Me):[]}function LS(l,c){var p=l==null?0:l.length;return p?(c=c===t?1:me(c),at(l,c)):[]}function PS(l){for(var c=-1,p=l==null?0:l.length,y={};++c<p;){var b=l[c];y[b[0]]=b[1]}return y}function om(l){return l&&l.length?l[0]:t}function BS(l,c,p){var y=l==null?0:l.length;if(!y)return-1;var b=p==null?0:me(p);return b<0&&(b=tt(y+b,0)),ji(l,c,b)}function FS(l){var c=l==null?0:l.length;return c?hn(l,0,-1):[]}var zS=be(function(l){var c=qe(l,hc);return c.length&&c[0]===l[0]?nc(c):[]}),$S=be(function(l){var c=dn(l),p=qe(l,hc);return c===dn(p)?c=t:p.pop(),p.length&&p[0]===l[0]?nc(p,re(c,2)):[]}),WS=be(function(l){var c=dn(l),p=qe(l,hc);return c=typeof c=="function"?c:t,c&&p.pop(),p.length&&p[0]===l[0]?nc(p,t,c):[]});function VS(l,c){return l==null?"":Fw.call(l,c)}function dn(l){var c=l==null?0:l.length;return c?l[c-1]:t}function HS(l,c,p){var y=l==null?0:l.length;if(!y)return-1;var b=y;return p!==t&&(b=me(p),b=b<0?tt(y+b,0):dt(b,y-1)),c===c?Cw(l,c,b):ml(l,zd,b,!0)}function qS(l,c){return l&&l.length?gp(l,me(c)):t}var KS=be(sm);function sm(l,c){return l&&l.length&&c&&c.length?sc(l,c):l}function US(l,c,p){return l&&l.length&&c&&c.length?sc(l,c,re(p,2)):l}function jS(l,c,p){return l&&l.length&&c&&c.length?sc(l,c,t,p):l}var JS=lr(function(l,c){var p=l==null?0:l.length,y=Qu(l,c);return bp(l,qe(c,function(b){return ar(b,p)?+b:b}).sort(Ip)),y});function GS(l,c){var p=[];if(!(l&&l.length))return p;var y=-1,b=[],w=l.length;for(c=re(c,3);++y<w;){var T=l[y];c(T,y,l)&&(p.push(T),b.push(y))}return bp(l,b),p}function Ac(l){return l==null?l:Vw.call(l)}function YS(l,c,p){var y=l==null?0:l.length;return y?(p&&typeof p!="number"&&wt(l,c,p)?(c=0,p=y):(c=c==null?0:me(c),p=p===t?y:me(p)),hn(l,c,p)):[]}function XS(l,c){return Ll(l,c)}function QS(l,c,p){return uc(l,c,re(p,2))}function ZS(l,c){var p=l==null?0:l.length;if(p){var y=Ll(l,c);if(y<p&&En(l[y],c))return y}return-1}function ev(l,c){return Ll(l,c,!0)}function tv(l,c,p){return uc(l,c,re(p,2),!0)}function nv(l,c){var p=l==null?0:l.length;if(p){var y=Ll(l,c,!0)-1;if(En(l[y],c))return y}return-1}function rv(l){return l&&l.length?wp(l):[]}function iv(l,c){return l&&l.length?wp(l,re(c,2)):[]}function ov(l){var c=l==null?0:l.length;return c?hn(l,1,c):[]}function sv(l,c,p){return l&&l.length?(c=p||c===t?1:me(c),hn(l,0,c<0?0:c)):[]}function lv(l,c,p){var y=l==null?0:l.length;return y?(c=p||c===t?1:me(c),c=y-c,hn(l,c<0?0:c,y)):[]}function av(l,c){return l&&l.length?Pl(l,re(c,3),!1,!0):[]}function uv(l,c){return l&&l.length?Pl(l,re(c,3)):[]}var cv=be(function(l){return _r(at(l,1,Ye,!0))}),fv=be(function(l){var c=dn(l);return Ye(c)&&(c=t),_r(at(l,1,Ye,!0),re(c,2))}),hv=be(function(l){var c=dn(l);return c=typeof c=="function"?c:t,_r(at(l,1,Ye,!0),t,c)});function dv(l){return l&&l.length?_r(l):[]}function pv(l,c){return l&&l.length?_r(l,re(c,2)):[]}function mv(l,c){return c=typeof c=="function"?c:t,l&&l.length?_r(l,t,c):[]}function Nc(l){if(!(l&&l.length))return[];var c=0;return l=Mr(l,function(p){if(Ye(p))return c=tt(p.length,c),!0}),qu(c,function(p){return qe(l,Wu(p))})}function lm(l,c){if(!(l&&l.length))return[];var p=Nc(l);return c==null?p:qe(p,function(y){return Ht(c,t,y)})}var gv=be(function(l,c){return Ye(l)?Uo(l,c):[]}),yv=be(function(l){return fc(Mr(l,Ye))}),kv=be(function(l){var c=dn(l);return Ye(c)&&(c=t),fc(Mr(l,Ye),re(c,2))}),bv=be(function(l){var c=dn(l);return c=typeof c=="function"?c:t,fc(Mr(l,Ye),t,c)}),xv=be(Nc);function wv(l,c){return Tp(l||[],c||[],Ko)}function Cv(l,c){return Tp(l||[],c||[],Go)}var Sv=be(function(l){var c=l.length,p=c>1?l[c-1]:t;return p=typeof p=="function"?(l.pop(),p):t,lm(l,p)});function am(l){var c=x(l);return c.__chain__=!0,c}function vv(l,c){return c(l),l}function Kl(l,c){return c(l)}var Tv=lr(function(l){var c=l.length,p=c?l[0]:0,y=this.__wrapped__,b=function(w){return Qu(w,l)};return c>1||this.__actions__.length||!(y instanceof Se)||!ar(p)?this.thru(b):(y=y.slice(p,+p+(c?1:0)),y.__actions__.push({func:Kl,args:[b],thisArg:t}),new cn(y,this.__chain__).thru(function(w){return c&&!w.length&&w.push(t),w}))});function Av(){return am(this)}function Nv(){return new cn(this.value(),this.__chain__)}function Mv(){this.__values__===t&&(this.__values__=Cm(this.value()));var l=this.__index__>=this.__values__.length,c=l?t:this.__values__[this.__index__++];return{done:l,value:c}}function Iv(){return this}function Ev(l){for(var c,p=this;p instanceof El;){var y=tm(p);y.__index__=0,y.__values__=t,c?b.__wrapped__=y:c=y;var b=y;p=p.__wrapped__}return b.__wrapped__=l,c}function Ov(){var l=this.__wrapped__;if(l instanceof Se){var c=l;return this.__actions__.length&&(c=new Se(this)),c=c.reverse(),c.__actions__.push({func:Kl,args:[Ac],thisArg:t}),new cn(c,this.__chain__)}return this.thru(Ac)}function Rv(){return vp(this.__wrapped__,this.__actions__)}var _v=Bl(function(l,c,p){_e.call(l,p)?++l[p]:or(l,p,1)});function Dv(l,c,p){var y=he(l)?Bd:vC;return p&&wt(l,c,p)&&(c=t),y(l,re(c,3))}function Lv(l,c){var p=he(l)?Mr:lp;return p(l,re(c,3))}var Pv=Lp(nm),Bv=Lp(rm);function Fv(l,c){return at(Ul(l,c),1)}function zv(l,c){return at(Ul(l,c),Me)}function $v(l,c,p){return p=p===t?1:me(p),at(Ul(l,c),p)}function um(l,c){var p=he(l)?an:Rr;return p(l,re(c,3))}function cm(l,c){var p=he(l)?ow:sp;return p(l,re(c,3))}var Wv=Bl(function(l,c,p){_e.call(l,p)?l[p].push(c):or(l,p,[c])});function Vv(l,c,p,y){l=It(l)?l:oo(l),p=p&&!y?me(p):0;var b=l.length;return p<0&&(p=tt(b+p,0)),Xl(l)?p<=b&&l.indexOf(c,p)>-1:!!b&&ji(l,c,p)>-1}var Hv=be(function(l,c,p){var y=-1,b=typeof c=="function",w=It(l)?_(l.length):[];return Rr(l,function(T){w[++y]=b?Ht(c,T,p):jo(T,c,p)}),w}),qv=Bl(function(l,c,p){or(l,p,c)});function Ul(l,c){var p=he(l)?qe:dp;return p(l,re(c,3))}function Kv(l,c,p,y){return l==null?[]:(he(c)||(c=c==null?[]:[c]),p=y?t:p,he(p)||(p=p==null?[]:[p]),yp(l,c,p))}var Uv=Bl(function(l,c,p){l[p?0:1].push(c)},function(){return[[],[]]});function jv(l,c,p){var y=he(l)?zu:Wd,b=arguments.length<3;return y(l,re(c,4),p,b,Rr)}function Jv(l,c,p){var y=he(l)?sw:Wd,b=arguments.length<3;return y(l,re(c,4),p,b,sp)}function Gv(l,c){var p=he(l)?Mr:lp;return p(l,Gl(re(c,3)))}function Yv(l){var c=he(l)?np:VC;return c(l)}function Xv(l,c,p){(p?wt(l,c,p):c===t)?c=1:c=me(c);var y=he(l)?bC:HC;return y(l,c)}function Qv(l){var c=he(l)?xC:KC;return c(l)}function Zv(l){if(l==null)return 0;if(It(l))return Xl(l)?Gi(l):l.length;var c=pt(l);return c==$t||c==Wt?l.size:ic(l).length}function eT(l,c,p){var y=he(l)?$u:UC;return p&&wt(l,c,p)&&(c=t),y(l,re(c,3))}var tT=be(function(l,c){if(l==null)return[];var p=c.length;return p>1&&wt(l,c[0],c[1])?c=[]:p>2&&wt(c[0],c[1],c[2])&&(c=[c[0]]),yp(l,at(c,1),[])}),jl=Lw||function(){return lt.Date.now()};function nT(l,c){if(typeof c!="function")throw new un(s);return l=me(l),function(){if(--l<1)return c.apply(this,arguments)}}function fm(l,c,p){return c=p?t:c,c=l&&c==null?l.length:c,sr(l,H,t,t,t,t,c)}function hm(l,c){var p;if(typeof c!="function")throw new un(s);return l=me(l),function(){return--l>0&&(p=c.apply(this,arguments)),l<=1&&(c=t),p}}var Mc=be(function(l,c,p){var y=v;if(p.length){var b=Er(p,ro(Mc));y|=q}return sr(l,y,c,p,b)}),dm=be(function(l,c,p){var y=v|S;if(p.length){var b=Er(p,ro(dm));y|=q}return sr(c,y,l,p,b)});function pm(l,c,p){c=p?t:c;var y=sr(l,R,t,t,t,t,t,c);return y.placeholder=pm.placeholder,y}function mm(l,c,p){c=p?t:c;var y=sr(l,K,t,t,t,t,t,c);return y.placeholder=mm.placeholder,y}function gm(l,c,p){var y,b,w,T,N,E,z=0,$=!1,V=!1,G=!0;if(typeof l!="function")throw new un(s);c=pn(c)||0,Ue(p)&&($=!!p.leading,V="maxWait"in p,w=V?tt(pn(p.maxWait)||0,c):w,G="trailing"in p?!!p.trailing:G);function Z(Xe){var On=y,fr=b;return y=b=t,z=Xe,T=l.apply(fr,On),T}function oe(Xe){return z=Xe,N=Qo(we,c),$?Z(Xe):T}function ge(Xe){var On=Xe-E,fr=Xe-z,Lm=c-On;return V?dt(Lm,w-fr):Lm}function se(Xe){var On=Xe-E,fr=Xe-z;return E===t||On>=c||On<0||V&&fr>=w}function we(){var Xe=jl();if(se(Xe))return ve(Xe);N=Qo(we,ge(Xe))}function ve(Xe){return N=t,G&&y?Z(Xe):(y=b=t,T)}function jt(){N!==t&&Ap(N),z=0,y=E=b=N=t}function Ct(){return N===t?T:ve(jl())}function Jt(){var Xe=jl(),On=se(Xe);if(y=arguments,b=this,E=Xe,On){if(N===t)return oe(E);if(V)return Ap(N),N=Qo(we,c),Z(E)}return N===t&&(N=Qo(we,c)),T}return Jt.cancel=jt,Jt.flush=Ct,Jt}var rT=be(function(l,c){return op(l,1,c)}),iT=be(function(l,c,p){return op(l,pn(c)||0,p)});function oT(l){return sr(l,te)}function Jl(l,c){if(typeof l!="function"||c!=null&&typeof c!="function")throw new un(s);var p=function(){var y=arguments,b=c?c.apply(this,y):y[0],w=p.cache;if(w.has(b))return w.get(b);var T=l.apply(this,y);return p.cache=w.set(b,T)||w,T};return p.cache=new(Jl.Cache||ir),p}Jl.Cache=ir;function Gl(l){if(typeof l!="function")throw new un(s);return function(){var c=arguments;switch(c.length){case 0:return!l.call(this);case 1:return!l.call(this,c[0]);case 2:return!l.call(this,c[0],c[1]);case 3:return!l.call(this,c[0],c[1],c[2])}return!l.apply(this,c)}}function sT(l){return hm(2,l)}var lT=jC(function(l,c){c=c.length==1&&he(c[0])?qe(c[0],qt(re())):qe(at(c,1),qt(re()));var p=c.length;return be(function(y){for(var b=-1,w=dt(y.length,p);++b<w;)y[b]=c[b].call(this,y[b]);return Ht(l,this,y)})}),Ic=be(function(l,c){var p=Er(c,ro(Ic));return sr(l,q,t,c,p)}),ym=be(function(l,c){var p=Er(c,ro(ym));return sr(l,O,t,c,p)}),aT=lr(function(l,c){return sr(l,X,t,t,t,c)});function uT(l,c){if(typeof l!="function")throw new un(s);return c=c===t?c:me(c),be(l,c)}function cT(l,c){if(typeof l!="function")throw new un(s);return c=c==null?0:tt(me(c),0),be(function(p){var y=p[c],b=Lr(p,0,c);return y&&Ir(b,y),Ht(l,this,b)})}function fT(l,c,p){var y=!0,b=!0;if(typeof l!="function")throw new un(s);return Ue(p)&&(y="leading"in p?!!p.leading:y,b="trailing"in p?!!p.trailing:b),gm(l,c,{leading:y,maxWait:c,trailing:b})}function hT(l){return fm(l,1)}function dT(l,c){return Ic(dc(c),l)}function pT(){if(!arguments.length)return[];var l=arguments[0];return he(l)?l:[l]}function mT(l){return fn(l,g)}function gT(l,c){return c=typeof c=="function"?c:t,fn(l,g,c)}function yT(l){return fn(l,d|g)}function kT(l,c){return c=typeof c=="function"?c:t,fn(l,d|g,c)}function bT(l,c){return c==null||ip(l,c,it(c))}function En(l,c){return l===c||l!==l&&c!==c}var xT=Wl(tc),wT=Wl(function(l,c){return l>=c}),pi=cp(function(){return arguments}())?cp:function(l){return Ge(l)&&_e.call(l,"callee")&&!Yd.call(l,"callee")},he=_.isArray,CT=Od?qt(Od):EC;function It(l){return l!=null&&Yl(l.length)&&!ur(l)}function Ye(l){return Ge(l)&&It(l)}function ST(l){return l===!0||l===!1||Ge(l)&&xt(l)==Nt}var Pr=Bw||$c,vT=Rd?qt(Rd):OC;function TT(l){return Ge(l)&&l.nodeType===1&&!Zo(l)}function AT(l){if(l==null)return!0;if(It(l)&&(he(l)||typeof l=="string"||typeof l.splice=="function"||Pr(l)||io(l)||pi(l)))return!l.length;var c=pt(l);if(c==$t||c==Wt)return!l.size;if(Xo(l))return!ic(l).length;for(var p in l)if(_e.call(l,p))return!1;return!0}function NT(l,c){return Jo(l,c)}function MT(l,c,p){p=typeof p=="function"?p:t;var y=p?p(l,c):t;return y===t?Jo(l,c,t,p):!!y}function Ec(l){if(!Ge(l))return!1;var c=xt(l);return c==er||c==Tr||typeof l.message=="string"&&typeof l.name=="string"&&!Zo(l)}function IT(l){return typeof l=="number"&&Qd(l)}function ur(l){if(!Ue(l))return!1;var c=xt(l);return c==qi||c==ll||c==ri||c==cl}function km(l){return typeof l=="number"&&l==me(l)}function Yl(l){return typeof l=="number"&&l>-1&&l%1==0&&l<=Ee}function Ue(l){var c=typeof l;return l!=null&&(c=="object"||c=="function")}function Ge(l){return l!=null&&typeof l=="object"}var bm=_d?qt(_d):_C;function ET(l,c){return l===c||rc(l,c,xc(c))}function OT(l,c,p){return p=typeof p=="function"?p:t,rc(l,c,xc(c),p)}function RT(l){return xm(l)&&l!=+l}function _T(l){if(gS(l))throw new ue(o);return fp(l)}function DT(l){return l===null}function LT(l){return l==null}function xm(l){return typeof l=="number"||Ge(l)&&xt(l)==Ar}function Zo(l){if(!Ge(l)||xt(l)!=sn)return!1;var c=Sl(l);if(c===null)return!0;var p=_e.call(c,"constructor")&&c.constructor;return typeof p=="function"&&p instanceof p&&bl.call(p)==Ow}var Oc=Dd?qt(Dd):DC;function PT(l){return km(l)&&l>=-Ee&&l<=Ee}var wm=Ld?qt(Ld):LC;function Xl(l){return typeof l=="string"||!he(l)&&Ge(l)&&xt(l)==ii}function Ut(l){return typeof l=="symbol"||Ge(l)&&xt(l)==Ki}var io=Pd?qt(Pd):PC;function BT(l){return l===t}function FT(l){return Ge(l)&&pt(l)==oi}function zT(l){return Ge(l)&&xt(l)==B}var $T=Wl(oc),WT=Wl(function(l,c){return l<=c});function Cm(l){if(!l)return[];if(It(l))return Xl(l)?Mn(l):Mt(l);if($o&&l[$o])return bw(l[$o]());var c=pt(l),p=c==$t?Uu:c==Wt?gl:oo;return p(l)}function cr(l){if(!l)return l===0?l:0;if(l=pn(l),l===Me||l===-Me){var c=l<0?-1:1;return c*Qe}return l===l?l:0}function me(l){var c=cr(l),p=c%1;return c===c?p?c-p:c:0}function Sm(l){return l?ci(me(l),0,je):0}function pn(l){if(typeof l=="number")return l;if(Ut(l))return A;if(Ue(l)){var c=typeof l.valueOf=="function"?l.valueOf():l;l=Ue(c)?c+"":c}if(typeof l!="string")return l===0?l:+l;l=Vd(l);var p=Cx.test(l);return p||vx.test(l)?nw(l.slice(2),p?2:8):wx.test(l)?A:+l}function vm(l){return $n(l,Et(l))}function VT(l){return l?ci(me(l),-Ee,Ee):l===0?l:0}function De(l){return l==null?"":Kt(l)}var HT=to(function(l,c){if(Xo(c)||It(c)){$n(c,it(c),l);return}for(var p in c)_e.call(c,p)&&Ko(l,p,c[p])}),Tm=to(function(l,c){$n(c,Et(c),l)}),Ql=to(function(l,c,p,y){$n(c,Et(c),l,y)}),qT=to(function(l,c,p,y){$n(c,it(c),l,y)}),KT=lr(Qu);function UT(l,c){var p=eo(l);return c==null?p:rp(p,c)}var jT=be(function(l,c){l=Be(l);var p=-1,y=c.length,b=y>2?c[2]:t;for(b&&wt(c[0],c[1],b)&&(y=1);++p<y;)for(var w=c[p],T=Et(w),N=-1,E=T.length;++N<E;){var z=T[N],$=l[z];($===t||En($,Xi[z])&&!_e.call(l,z))&&(l[z]=w[z])}return l}),JT=be(function(l){return l.push(t,Vp),Ht(Am,t,l)});function GT(l,c){return Fd(l,re(c,3),zn)}function YT(l,c){return Fd(l,re(c,3),ec)}function XT(l,c){return l==null?l:Zu(l,re(c,3),Et)}function QT(l,c){return l==null?l:ap(l,re(c,3),Et)}function ZT(l,c){return l&&zn(l,re(c,3))}function eA(l,c){return l&&ec(l,re(c,3))}function tA(l){return l==null?[]:_l(l,it(l))}function nA(l){return l==null?[]:_l(l,Et(l))}function Rc(l,c,p){var y=l==null?t:fi(l,c);return y===t?p:y}function rA(l,c){return l!=null&&Kp(l,c,AC)}function _c(l,c){return l!=null&&Kp(l,c,NC)}var iA=Bp(function(l,c,p){c!=null&&typeof c.toString!="function"&&(c=xl.call(c)),l[c]=p},Lc(Ot)),oA=Bp(function(l,c,p){c!=null&&typeof c.toString!="function"&&(c=xl.call(c)),_e.call(l,c)?l[c].push(p):l[c]=[p]},re),sA=be(jo);function it(l){return It(l)?tp(l):ic(l)}function Et(l){return It(l)?tp(l,!0):BC(l)}function lA(l,c){var p={};return c=re(c,3),zn(l,function(y,b,w){or(p,c(y,b,w),y)}),p}function aA(l,c){var p={};return c=re(c,3),zn(l,function(y,b,w){or(p,b,c(y,b,w))}),p}var uA=to(function(l,c,p){Dl(l,c,p)}),Am=to(function(l,c,p,y){Dl(l,c,p,y)}),cA=lr(function(l,c){var p={};if(l==null)return p;var y=!1;c=qe(c,function(w){return w=Dr(w,l),y||(y=w.length>1),w}),$n(l,kc(l),p),y&&(p=fn(p,d|m|g,iS));for(var b=c.length;b--;)cc(p,c[b]);return p});function fA(l,c){return Nm(l,Gl(re(c)))}var hA=lr(function(l,c){return l==null?{}:zC(l,c)});function Nm(l,c){if(l==null)return{};var p=qe(kc(l),function(y){return[y]});return c=re(c),kp(l,p,function(y,b){return c(y,b[0])})}function dA(l,c,p){c=Dr(c,l);var y=-1,b=c.length;for(b||(b=1,l=t);++y<b;){var w=l==null?t:l[Wn(c[y])];w===t&&(y=b,w=p),l=ur(w)?w.call(l):w}return l}function pA(l,c,p){return l==null?l:Go(l,c,p)}function mA(l,c,p,y){return y=typeof y=="function"?y:t,l==null?l:Go(l,c,p,y)}var Mm=$p(it),Im=$p(Et);function gA(l,c,p){var y=he(l),b=y||Pr(l)||io(l);if(c=re(c,4),p==null){var w=l&&l.constructor;b?p=y?new w:[]:Ue(l)?p=ur(w)?eo(Sl(l)):{}:p={}}return(b?an:zn)(l,function(T,N,E){return c(p,T,N,E)}),p}function yA(l,c){return l==null?!0:cc(l,c)}function kA(l,c,p){return l==null?l:Sp(l,c,dc(p))}function bA(l,c,p,y){return y=typeof y=="function"?y:t,l==null?l:Sp(l,c,dc(p),y)}function oo(l){return l==null?[]:Ku(l,it(l))}function xA(l){return l==null?[]:Ku(l,Et(l))}function wA(l,c,p){return p===t&&(p=c,c=t),p!==t&&(p=pn(p),p=p===p?p:0),c!==t&&(c=pn(c),c=c===c?c:0),ci(pn(l),c,p)}function CA(l,c,p){return c=cr(c),p===t?(p=c,c=0):p=cr(p),l=pn(l),MC(l,c,p)}function SA(l,c,p){if(p&&typeof p!="boolean"&&wt(l,c,p)&&(c=p=t),p===t&&(typeof c=="boolean"?(p=c,c=t):typeof l=="boolean"&&(p=l,l=t)),l===t&&c===t?(l=0,c=1):(l=cr(l),c===t?(c=l,l=0):c=cr(c)),l>c){var y=l;l=c,c=y}if(p||l%1||c%1){var b=Zd();return dt(l+b*(c-l+tw("1e-"+((b+"").length-1))),c)}return lc(l,c)}var vA=no(function(l,c,p){return c=c.toLowerCase(),l+(p?Em(c):c)});function Em(l){return Dc(De(l).toLowerCase())}function Om(l){return l=De(l),l&&l.replace(Ax,pw).replace(Kx,"")}function TA(l,c,p){l=De(l),c=Kt(c);var y=l.length;p=p===t?y:ci(me(p),0,y);var b=p;return p-=c.length,p>=0&&l.slice(p,b)==c}function AA(l){return l=De(l),l&&sx.test(l)?l.replace(ad,mw):l}function NA(l){return l=De(l),l&&hx.test(l)?l.replace(Iu,"\\$&"):l}var MA=no(function(l,c,p){return l+(p?"-":"")+c.toLowerCase()}),IA=no(function(l,c,p){return l+(p?" ":"")+c.toLowerCase()}),EA=Dp("toLowerCase");function OA(l,c,p){l=De(l),c=me(c);var y=c?Gi(l):0;if(!c||y>=c)return l;var b=(c-y)/2;return $l(Nl(b),p)+l+$l(Al(b),p)}function RA(l,c,p){l=De(l),c=me(c);var y=c?Gi(l):0;return c&&y<c?l+$l(c-y,p):l}function _A(l,c,p){l=De(l),c=me(c);var y=c?Gi(l):0;return c&&y<c?$l(c-y,p)+l:l}function DA(l,c,p){return p||c==null?c=0:c&&(c=+c),Ww(De(l).replace(Eu,""),c||0)}function LA(l,c,p){return(p?wt(l,c,p):c===t)?c=1:c=me(c),ac(De(l),c)}function PA(){var l=arguments,c=De(l[0]);return l.length<3?c:c.replace(l[1],l[2])}var BA=no(function(l,c,p){return l+(p?"_":"")+c.toLowerCase()});function FA(l,c,p){return p&&typeof p!="number"&&wt(l,c,p)&&(c=p=t),p=p===t?je:p>>>0,p?(l=De(l),l&&(typeof c=="string"||c!=null&&!Oc(c))&&(c=Kt(c),!c&&Ji(l))?Lr(Mn(l),0,p):l.split(c,p)):[]}var zA=no(function(l,c,p){return l+(p?" ":"")+Dc(c)});function $A(l,c,p){return l=De(l),p=p==null?0:ci(me(p),0,l.length),c=Kt(c),l.slice(p,p+c.length)==c}function WA(l,c,p){var y=x.templateSettings;p&&wt(l,c,p)&&(c=t),l=De(l),c=Ql({},c,y,Wp);var b=Ql({},c.imports,y.imports,Wp),w=it(b),T=Ku(b,w),N,E,z=0,$=c.interpolate||fl,V="__p += '",G=ju((c.escape||fl).source+"|"+$.source+"|"+($===ud?xx:fl).source+"|"+(c.evaluate||fl).source+"|$","g"),Z="//# sourceURL="+(_e.call(c,"sourceURL")?(c.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++Yx+"]")+`
59
+ `;l.replace(G,function(se,we,ve,jt,Ct,Jt){return ve||(ve=jt),V+=l.slice(z,Jt).replace(Nx,gw),we&&(N=!0,V+=`' +
60
+ __e(`+we+`) +
61
+ '`),Ct&&(E=!0,V+=`';
62
+ `+Ct+`;
63
+ __p += '`),ve&&(V+=`' +
64
+ ((__t = (`+ve+`)) == null ? '' : __t) +
65
+ '`),z=Jt+se.length,se}),V+=`';
66
+ `;var oe=_e.call(c,"variable")&&c.variable;if(!oe)V=`with (obj) {
67
+ `+V+`
68
+ }
69
+ `;else if(kx.test(oe))throw new ue(a);V=(E?V.replace(Nn,""):V).replace(rx,"$1").replace(ix,"$1;"),V="function("+(oe||"obj")+`) {
70
+ `+(oe?"":`obj || (obj = {});
71
+ `)+"var __t, __p = ''"+(N?", __e = _.escape":"")+(E?`, __j = Array.prototype.join;
72
+ function print() { __p += __j.call(arguments, '') }
73
+ `:`;
74
+ `)+V+`return __p
75
+ }`;var ge=_m(function(){return Re(w,Z+"return "+V).apply(t,T)});if(ge.source=V,Ec(ge))throw ge;return ge}function VA(l){return De(l).toLowerCase()}function HA(l){return De(l).toUpperCase()}function qA(l,c,p){if(l=De(l),l&&(p||c===t))return Vd(l);if(!l||!(c=Kt(c)))return l;var y=Mn(l),b=Mn(c),w=Hd(y,b),T=qd(y,b)+1;return Lr(y,w,T).join("")}function KA(l,c,p){if(l=De(l),l&&(p||c===t))return l.slice(0,Ud(l)+1);if(!l||!(c=Kt(c)))return l;var y=Mn(l),b=qd(y,Mn(c))+1;return Lr(y,0,b).join("")}function UA(l,c,p){if(l=De(l),l&&(p||c===t))return l.replace(Eu,"");if(!l||!(c=Kt(c)))return l;var y=Mn(l),b=Hd(y,Mn(c));return Lr(y,b).join("")}function jA(l,c){var p=D,y=Q;if(Ue(c)){var b="separator"in c?c.separator:b;p="length"in c?me(c.length):p,y="omission"in c?Kt(c.omission):y}l=De(l);var w=l.length;if(Ji(l)){var T=Mn(l);w=T.length}if(p>=w)return l;var N=p-Gi(y);if(N<1)return y;var E=T?Lr(T,0,N).join(""):l.slice(0,N);if(b===t)return E+y;if(T&&(N+=E.length-N),Oc(b)){if(l.slice(N).search(b)){var z,$=E;for(b.global||(b=ju(b.source,De(cd.exec(b))+"g")),b.lastIndex=0;z=b.exec($);)var V=z.index;E=E.slice(0,V===t?N:V)}}else if(l.indexOf(Kt(b),N)!=N){var G=E.lastIndexOf(b);G>-1&&(E=E.slice(0,G))}return E+y}function JA(l){return l=De(l),l&&ox.test(l)?l.replace(ld,Sw):l}var GA=no(function(l,c,p){return l+(p?" ":"")+c.toUpperCase()}),Dc=Dp("toUpperCase");function Rm(l,c,p){return l=De(l),c=p?t:c,c===t?kw(l)?Aw(l):uw(l):l.match(c)||[]}var _m=be(function(l,c){try{return Ht(l,t,c)}catch(p){return Ec(p)?p:new ue(p)}}),YA=lr(function(l,c){return an(c,function(p){p=Wn(p),or(l,p,Mc(l[p],l))}),l});function XA(l){var c=l==null?0:l.length,p=re();return l=c?qe(l,function(y){if(typeof y[1]!="function")throw new un(s);return[p(y[0]),y[1]]}):[],be(function(y){for(var b=-1;++b<c;){var w=l[b];if(Ht(w[0],this,y))return Ht(w[1],this,y)}})}function QA(l){return SC(fn(l,d))}function Lc(l){return function(){return l}}function ZA(l,c){return l==null||l!==l?c:l}var eN=Pp(),tN=Pp(!0);function Ot(l){return l}function Pc(l){return hp(typeof l=="function"?l:fn(l,d))}function nN(l){return pp(fn(l,d))}function rN(l,c){return mp(l,fn(c,d))}var iN=be(function(l,c){return function(p){return jo(p,l,c)}}),oN=be(function(l,c){return function(p){return jo(l,p,c)}});function Bc(l,c,p){var y=it(c),b=_l(c,y);p==null&&!(Ue(c)&&(b.length||!y.length))&&(p=c,c=l,l=this,b=_l(c,it(c)));var w=!(Ue(p)&&"chain"in p)||!!p.chain,T=ur(l);return an(b,function(N){var E=c[N];l[N]=E,T&&(l.prototype[N]=function(){var z=this.__chain__;if(w||z){var $=l(this.__wrapped__),V=$.__actions__=Mt(this.__actions__);return V.push({func:E,args:arguments,thisArg:l}),$.__chain__=z,$}return E.apply(l,Ir([this.value()],arguments))})}),l}function sN(){return lt._===this&&(lt._=Rw),this}function Fc(){}function lN(l){return l=me(l),be(function(c){return gp(c,l)})}var aN=mc(qe),uN=mc(Bd),cN=mc($u);function Dm(l){return Cc(l)?Wu(Wn(l)):$C(l)}function fN(l){return function(c){return l==null?t:fi(l,c)}}var hN=Fp(),dN=Fp(!0);function zc(){return[]}function $c(){return!1}function pN(){return{}}function mN(){return""}function gN(){return!0}function yN(l,c){if(l=me(l),l<1||l>Ee)return[];var p=je,y=dt(l,je);c=re(c),l-=je;for(var b=qu(y,c);++p<l;)c(p);return b}function kN(l){return he(l)?qe(l,Wn):Ut(l)?[l]:Mt(em(De(l)))}function bN(l){var c=++Ew;return De(l)+c}var xN=zl(function(l,c){return l+c},0),wN=gc("ceil"),CN=zl(function(l,c){return l/c},1),SN=gc("floor");function vN(l){return l&&l.length?Rl(l,Ot,tc):t}function TN(l,c){return l&&l.length?Rl(l,re(c,2),tc):t}function AN(l){return $d(l,Ot)}function NN(l,c){return $d(l,re(c,2))}function MN(l){return l&&l.length?Rl(l,Ot,oc):t}function IN(l,c){return l&&l.length?Rl(l,re(c,2),oc):t}var EN=zl(function(l,c){return l*c},1),ON=gc("round"),RN=zl(function(l,c){return l-c},0);function _N(l){return l&&l.length?Hu(l,Ot):0}function DN(l,c){return l&&l.length?Hu(l,re(c,2)):0}return x.after=nT,x.ary=fm,x.assign=HT,x.assignIn=Tm,x.assignInWith=Ql,x.assignWith=qT,x.at=KT,x.before=hm,x.bind=Mc,x.bindAll=YA,x.bindKey=dm,x.castArray=pT,x.chain=am,x.chunk=SS,x.compact=vS,x.concat=TS,x.cond=XA,x.conforms=QA,x.constant=Lc,x.countBy=_v,x.create=UT,x.curry=pm,x.curryRight=mm,x.debounce=gm,x.defaults=jT,x.defaultsDeep=JT,x.defer=rT,x.delay=iT,x.difference=AS,x.differenceBy=NS,x.differenceWith=MS,x.drop=IS,x.dropRight=ES,x.dropRightWhile=OS,x.dropWhile=RS,x.fill=_S,x.filter=Lv,x.flatMap=Fv,x.flatMapDeep=zv,x.flatMapDepth=$v,x.flatten=im,x.flattenDeep=DS,x.flattenDepth=LS,x.flip=oT,x.flow=eN,x.flowRight=tN,x.fromPairs=PS,x.functions=tA,x.functionsIn=nA,x.groupBy=Wv,x.initial=FS,x.intersection=zS,x.intersectionBy=$S,x.intersectionWith=WS,x.invert=iA,x.invertBy=oA,x.invokeMap=Hv,x.iteratee=Pc,x.keyBy=qv,x.keys=it,x.keysIn=Et,x.map=Ul,x.mapKeys=lA,x.mapValues=aA,x.matches=nN,x.matchesProperty=rN,x.memoize=Jl,x.merge=uA,x.mergeWith=Am,x.method=iN,x.methodOf=oN,x.mixin=Bc,x.negate=Gl,x.nthArg=lN,x.omit=cA,x.omitBy=fA,x.once=sT,x.orderBy=Kv,x.over=aN,x.overArgs=lT,x.overEvery=uN,x.overSome=cN,x.partial=Ic,x.partialRight=ym,x.partition=Uv,x.pick=hA,x.pickBy=Nm,x.property=Dm,x.propertyOf=fN,x.pull=KS,x.pullAll=sm,x.pullAllBy=US,x.pullAllWith=jS,x.pullAt=JS,x.range=hN,x.rangeRight=dN,x.rearg=aT,x.reject=Gv,x.remove=GS,x.rest=uT,x.reverse=Ac,x.sampleSize=Xv,x.set=pA,x.setWith=mA,x.shuffle=Qv,x.slice=YS,x.sortBy=tT,x.sortedUniq=rv,x.sortedUniqBy=iv,x.split=FA,x.spread=cT,x.tail=ov,x.take=sv,x.takeRight=lv,x.takeRightWhile=av,x.takeWhile=uv,x.tap=vv,x.throttle=fT,x.thru=Kl,x.toArray=Cm,x.toPairs=Mm,x.toPairsIn=Im,x.toPath=kN,x.toPlainObject=vm,x.transform=gA,x.unary=hT,x.union=cv,x.unionBy=fv,x.unionWith=hv,x.uniq=dv,x.uniqBy=pv,x.uniqWith=mv,x.unset=yA,x.unzip=Nc,x.unzipWith=lm,x.update=kA,x.updateWith=bA,x.values=oo,x.valuesIn=xA,x.without=gv,x.words=Rm,x.wrap=dT,x.xor=yv,x.xorBy=kv,x.xorWith=bv,x.zip=xv,x.zipObject=wv,x.zipObjectDeep=Cv,x.zipWith=Sv,x.entries=Mm,x.entriesIn=Im,x.extend=Tm,x.extendWith=Ql,Bc(x,x),x.add=xN,x.attempt=_m,x.camelCase=vA,x.capitalize=Em,x.ceil=wN,x.clamp=wA,x.clone=mT,x.cloneDeep=yT,x.cloneDeepWith=kT,x.cloneWith=gT,x.conformsTo=bT,x.deburr=Om,x.defaultTo=ZA,x.divide=CN,x.endsWith=TA,x.eq=En,x.escape=AA,x.escapeRegExp=NA,x.every=Dv,x.find=Pv,x.findIndex=nm,x.findKey=GT,x.findLast=Bv,x.findLastIndex=rm,x.findLastKey=YT,x.floor=SN,x.forEach=um,x.forEachRight=cm,x.forIn=XT,x.forInRight=QT,x.forOwn=ZT,x.forOwnRight=eA,x.get=Rc,x.gt=xT,x.gte=wT,x.has=rA,x.hasIn=_c,x.head=om,x.identity=Ot,x.includes=Vv,x.indexOf=BS,x.inRange=CA,x.invoke=sA,x.isArguments=pi,x.isArray=he,x.isArrayBuffer=CT,x.isArrayLike=It,x.isArrayLikeObject=Ye,x.isBoolean=ST,x.isBuffer=Pr,x.isDate=vT,x.isElement=TT,x.isEmpty=AT,x.isEqual=NT,x.isEqualWith=MT,x.isError=Ec,x.isFinite=IT,x.isFunction=ur,x.isInteger=km,x.isLength=Yl,x.isMap=bm,x.isMatch=ET,x.isMatchWith=OT,x.isNaN=RT,x.isNative=_T,x.isNil=LT,x.isNull=DT,x.isNumber=xm,x.isObject=Ue,x.isObjectLike=Ge,x.isPlainObject=Zo,x.isRegExp=Oc,x.isSafeInteger=PT,x.isSet=wm,x.isString=Xl,x.isSymbol=Ut,x.isTypedArray=io,x.isUndefined=BT,x.isWeakMap=FT,x.isWeakSet=zT,x.join=VS,x.kebabCase=MA,x.last=dn,x.lastIndexOf=HS,x.lowerCase=IA,x.lowerFirst=EA,x.lt=$T,x.lte=WT,x.max=vN,x.maxBy=TN,x.mean=AN,x.meanBy=NN,x.min=MN,x.minBy=IN,x.stubArray=zc,x.stubFalse=$c,x.stubObject=pN,x.stubString=mN,x.stubTrue=gN,x.multiply=EN,x.nth=qS,x.noConflict=sN,x.noop=Fc,x.now=jl,x.pad=OA,x.padEnd=RA,x.padStart=_A,x.parseInt=DA,x.random=SA,x.reduce=jv,x.reduceRight=Jv,x.repeat=LA,x.replace=PA,x.result=dA,x.round=ON,x.runInContext=I,x.sample=Yv,x.size=Zv,x.snakeCase=BA,x.some=eT,x.sortedIndex=XS,x.sortedIndexBy=QS,x.sortedIndexOf=ZS,x.sortedLastIndex=ev,x.sortedLastIndexBy=tv,x.sortedLastIndexOf=nv,x.startCase=zA,x.startsWith=$A,x.subtract=RN,x.sum=_N,x.sumBy=DN,x.template=WA,x.times=yN,x.toFinite=cr,x.toInteger=me,x.toLength=Sm,x.toLower=VA,x.toNumber=pn,x.toSafeInteger=VT,x.toString=De,x.toUpper=HA,x.trim=qA,x.trimEnd=KA,x.trimStart=UA,x.truncate=jA,x.unescape=JA,x.uniqueId=bN,x.upperCase=GA,x.upperFirst=Dc,x.each=um,x.eachRight=cm,x.first=om,Bc(x,function(){var l={};return zn(x,function(c,p){_e.call(x.prototype,p)||(l[p]=c)}),l}(),{chain:!1}),x.VERSION=r,an(["bind","bindKey","curry","curryRight","partial","partialRight"],function(l){x[l].placeholder=x}),an(["drop","take"],function(l,c){Se.prototype[l]=function(p){p=p===t?1:tt(me(p),0);var y=this.__filtered__&&!c?new Se(this):this.clone();return y.__filtered__?y.__takeCount__=dt(p,y.__takeCount__):y.__views__.push({size:dt(p,je),type:l+(y.__dir__<0?"Right":"")}),y},Se.prototype[l+"Right"]=function(p){return this.reverse()[l](p).reverse()}}),an(["filter","map","takeWhile"],function(l,c){var p=c+1,y=p==Te||p==He;Se.prototype[l]=function(b){var w=this.clone();return w.__iteratees__.push({iteratee:re(b,3),type:p}),w.__filtered__=w.__filtered__||y,w}}),an(["head","last"],function(l,c){var p="take"+(c?"Right":"");Se.prototype[l]=function(){return this[p](1).value()[0]}}),an(["initial","tail"],function(l,c){var p="drop"+(c?"":"Right");Se.prototype[l]=function(){return this.__filtered__?new Se(this):this[p](1)}}),Se.prototype.compact=function(){return this.filter(Ot)},Se.prototype.find=function(l){return this.filter(l).head()},Se.prototype.findLast=function(l){return this.reverse().find(l)},Se.prototype.invokeMap=be(function(l,c){return typeof l=="function"?new Se(this):this.map(function(p){return jo(p,l,c)})}),Se.prototype.reject=function(l){return this.filter(Gl(re(l)))},Se.prototype.slice=function(l,c){l=me(l);var p=this;return p.__filtered__&&(l>0||c<0)?new Se(p):(l<0?p=p.takeRight(-l):l&&(p=p.drop(l)),c!==t&&(c=me(c),p=c<0?p.dropRight(-c):p.take(c-l)),p)},Se.prototype.takeRightWhile=function(l){return this.reverse().takeWhile(l).reverse()},Se.prototype.toArray=function(){return this.take(je)},zn(Se.prototype,function(l,c){var p=/^(?:filter|find|map|reject)|While$/.test(c),y=/^(?:head|last)$/.test(c),b=x[y?"take"+(c=="last"?"Right":""):c],w=y||/^find/.test(c);b&&(x.prototype[c]=function(){var T=this.__wrapped__,N=y?[1]:arguments,E=T instanceof Se,z=N[0],$=E||he(T),V=function(we){var ve=b.apply(x,Ir([we],N));return y&&G?ve[0]:ve};$&&p&&typeof z=="function"&&z.length!=1&&(E=$=!1);var G=this.__chain__,Z=!!this.__actions__.length,oe=w&&!G,ge=E&&!Z;if(!w&&$){T=ge?T:new Se(this);var se=l.apply(T,N);return se.__actions__.push({func:Kl,args:[V],thisArg:t}),new cn(se,G)}return oe&&ge?l.apply(this,N):(se=this.thru(V),oe?y?se.value()[0]:se.value():se)})}),an(["pop","push","shift","sort","splice","unshift"],function(l){var c=yl[l],p=/^(?:push|sort|unshift)$/.test(l)?"tap":"thru",y=/^(?:pop|shift)$/.test(l);x.prototype[l]=function(){var b=arguments;if(y&&!this.__chain__){var w=this.value();return c.apply(he(w)?w:[],b)}return this[p](function(T){return c.apply(he(T)?T:[],b)})}}),zn(Se.prototype,function(l,c){var p=x[c];if(p){var y=p.name+"";_e.call(Zi,y)||(Zi[y]=[]),Zi[y].push({name:c,func:p})}}),Zi[Fl(t,S).name]=[{name:"wrapper",func:t}],Se.prototype.clone=Jw,Se.prototype.reverse=Gw,Se.prototype.value=Yw,x.prototype.at=Tv,x.prototype.chain=Av,x.prototype.commit=Nv,x.prototype.next=Mv,x.prototype.plant=Ev,x.prototype.reverse=Ov,x.prototype.toJSON=x.prototype.valueOf=x.prototype.value=Rv,x.prototype.first=x.prototype.head,$o&&(x.prototype[$o]=Iv),x},Yi=Nw();si?((si.exports=Yi)._=Yi,Pu._=Yi):lt._=Yi}).call(ts)})($a,$a.exports);var p2=$a.exports;function m2(n,e,t){const r=n.length,i=e.length;if(r===0&&i===0)return[];if(r===0)return[{type:"insert",items:[...e]}];if(i===0)return[{type:"delete",items:[...n]}];const o=r+i,s=o,a=new Array(2*o+1).fill(0);a[1+s]=0;const u=[];for(let f=0;f<=o;f++){u.push([...a]);for(let h=-f;h<=f;h+=2){const d=h+s;let m;h===-f||h!==f&&a[h-1+s]<a[h+1+s]?m=a[h+1+s]:m=a[h-1+s]+1;let g=m-h;for(;m<r&&g<i;){const k=n[m],C=e[g];if(!k||!C||!t(k,C))break;m++,g++}if(a[d]=m,m>=r&&g>=i)return g2(u,n,e,r,i,s)}}return[]}function g2(n,e,t,r,i,o){let s=r,a=i;const u=[];for(let f=n.length-1;f>=0;f--){const h=n[f],d=s-a;let m;d===-f||d!==f&&h[d-1+o]<h[d+1+o]?m=d+1:m=d-1;const g=h[m+o],k=g-m;for(;s>g&&a>k;){const C=e[s-1];C&&Bf(u,"equal",C),s--,a--}if(f===0)break;if(s===g){const C=t[a-1];C&&Bf(u,"insert",C),a--}else{const C=e[s-1];C&&Bf(u,"delete",C),s--}}return y2(u.reverse())}function Bf(n,e,t){n.push({type:e,items:[t]})}function y2(n){const e=[];for(const t of n){const r=e[e.length-1];r&&r.type===t.type?r.items.push(...t.items):e.push({...t})}return e}const k2=["paragraph","heading","code_block","hr","table_header_row","table_row"];function Ky(n){const e=[],t=(r,i)=>{const o=r.type.name;if(k2.indexOf(o)>=0){e.push({nodes:[...i,r]});return}r.childCount>0&&r.forEach(s=>{t(s,[...i,r])})};return n.forEach(r=>{t(r,[n])}),e}function Nu(n,e){if(n.type.name!==e.type.name)return!1;const t=n.attrs||{},r=e.attrs||{},i=Object.keys(t).sort(),o=Object.keys(r).sort();if(i.length!==o.length)return!1;for(let u=0;u<i.length;u++){const f=i[u];if(f!==o[u]||t[f]!==r[f])return!1}const s=n.marks||[],a=e.marks||[];if(s.length!==a.length)return!1;for(let u=0;u<s.length;u++){const f=s[u],h=a[u];if(f.type.name!==h.type.name)return!1;const d=f.attrs||{},m=h.attrs||{},g=Object.keys(d).sort(),k=Object.keys(m).sort();if(g.length!==k.length)return!1;for(let C=0;C<g.length;C++){const v=g[C];if(v!==k[C]||d[v]!==m[v])return!1}}return!0}function Yb(n,e){if(n.childCount!==e.childCount)return!1;for(let t=0;t<n.childCount;t++){const r=n.child(t),i=e.child(t);if(!Nu(r,i)||r.isText&&i.isText&&r.text!==i.text||(r.childCount>0||i.childCount>0)&&!Yb(r,i))return!1}return!0}function b2(n,e){if(n.nodes.length!==e.nodes.length)return!1;for(let i=0;i<n.nodes.length;i++)if(!Nu(n.nodes[i],e.nodes[i]))return!1;const t=n.nodes[n.nodes.length-1],r=e.nodes[e.nodes.length-1];return Yb(t,r)}function x2(n,e){const t=Ky(n),r=Ky(e);let i=[];const o=m2(t,r,b2);for(const s of o)switch(s.type){case"equal":for(let a=0;a<s.items.length;a++){const u={type:"unchanged",A:s.items[a],B:s.items[a]};i.push(u)}break;case"delete":for(const a of s.items){const u={type:"delete",A:a,B:null};i.push(u)}break;case"insert":for(const a of s.items){const u={type:"insert",A:null,B:a};i.push(u)}break}return i=T2(i),i}function Uy(n){var i,o;const e=(i=n.A)==null?void 0:i.nodes[n.A.nodes.length-1],t=(o=n.B)==null?void 0:o.nodes[n.B.nodes.length-1],r=e??t;return(r==null?void 0:r.type.name)==="table_row"||(r==null?void 0:r.type.name)==="table_header_row"}function w2(n){var t,r;const e=((t=n.A)==null?void 0:t.nodes[n.A.nodes.length-1])??((r=n.B)==null?void 0:r.nodes[n.B.nodes.length-1]);return(e==null?void 0:e.type.name)==="table_header_row"}function C2(n){var t,r;const e=((t=n.A)==null?void 0:t.nodes[n.A.nodes.length-1])??((r=n.B)==null?void 0:r.nodes[n.B.nodes.length-1]);return(e==null?void 0:e.childCount)??0}function jy(n){var t,r;const e=((t=n.A)==null?void 0:t.nodes)??((r=n.B)==null?void 0:r.nodes);return!e||e.length<2?null:e.slice(0,-1)}function S2(n,e){const t=jy(n),r=jy(e);return!t||!r||t.length!==r.length?!1:t.every((i,o)=>Nu(i,r[o]))}function v2(n){const e=n.map((i,o)=>({change:i,columnCount:C2(i),originalIndex:o,isHeader:w2(i)})),t=new Map;let r=0;for(const i of e)t.has(i.columnCount)||t.set(i.columnCount,r++);return e.sort((i,o)=>{const s=t.get(i.columnCount),a=t.get(o.columnCount);return s!==a?s-a:i.isHeader!==o.isHeader?i.isHeader?-1:1:i.originalIndex-o.originalIndex}),e.map(i=>i.change)}function T2(n){const e=[];let t=0;for(;t<n.length;){const r=n[t];if(!Uy(r)){e.push(r),t++;continue}const i=[r];let o=t+1;for(;o<n.length;){const a=n[o];if(!Uy(a)||!S2(r,a))break;i.push(a),o++}const s=v2(i);e.push(...s),t=o}return e}function sl(n){const e=n.get(qr.key).decorations;if(!e)return[];const t=[],i=e.find(0,void 0,o=>o.decorationType==="diff").filter(o=>o!==null);for(const o of i){const s=o.spec,a=s.groupIndex,u=s.changeType;let f=t.find(h=>h.groupIndex===a);f||(f={groupIndex:a,delete:[],insert:[]},t.push(f)),u==="delete"?f.delete.push(o):u==="insert"&&f.insert.push(o)}return t}function A2(n,e){let t=-1;return n.descendants((r,i)=>r===e?(t=i,!1):!0),t}function N2(n,e){let t=[];const r=Math.min(n.length,e.length);for(let i=0;i<r&&Nu(n[i].node,e[i]);i++)t.push(n[i]);return t}function M2(n,e,t){let r=e[e.length-1];if(r&&r.children.length>0&&r.children[0].node.childCount!=n.childCount){e.pop();let o={node:t[t.length-1],children:[],changeType:"unchanged"};e.length>0&&e[e.length-1].children.push(o),e.push(o),r=o}return r}function I2(n,e,t){let r=e[e.length-1],i=t[t.length-1];if(r.children.length>0&&n.type.name=="paragraph"){e.pop();let s={node:i,children:[],changeType:"unchanged"};e.length>0&&e[e.length-1].children.push(s),e.push(s),r=s}return r}function E2(n){var o,s;let e=[],t=[],r="unchanged",i=[];for(const a of n){let u=((o=a.A)==null?void 0:o.nodes)||((s=a.B)==null?void 0:s.nodes)||[];if(u.length===0)continue;let f=u.slice(0,-1),h=u[u.length-1];const d=N2(i,f);if(d.length>=f.length)i=i.slice(0,f.length);else if(d.length<f.length){i=i.slice(0,d.length);for(let k=d.length;k<f.length;k++){let v={node:f[k],children:[],changeType:"unchanged"};i.length>0&&i[i.length-1].children.push(v),i.push(v)}}let m=i.length>0?i[i.length-1]:null;(h.type.name=="table_row"||h.type.name=="table_header_row")&&(m=M2(h,i,f)),(m==null?void 0:m.node.type.name)=="list_item"&&(m=I2(h,i,f));let g={node:h,children:[],changeType:a.type};m&&m.children.push(g),i.push(g),a.type==="unchanged"?t.length&&(e.push(t),t=[]):a.type==="delete"?(r==="insert"&&(e.push(t),t=[]),t.push(g)):a.type==="insert"&&t.push(g),r=a.type}return t.length>0&&e.push(t),{root:i[0],mergeGroups:e}}function O2(n,e,t,r){const i=_2(t);return e.type.name==="heading"?nt.inline(n+1,n+e.nodeSize-1,{class:i},{changeType:t,groupIndex:r,decorationType:"diff",offset:!0}):nt.node(n,n+e.nodeSize,{class:i},{changeType:t,groupIndex:r,decorationType:"diff"})}function Xb(n,e){if(n.isText)return e.text(n.text,n.marks);const t=e.nodes[n.type.name];if(!t)throw new Error(`Node type ${n.type.name} not found`);const r=[];return n.content.forEach(i=>{r.push(Xb(i,e))}),t.createChecked(n.attrs,W.from(r))}function Qb(n,e){if(n.children.length>0){const t=[];for(const o of n.children)t.push(Qb(o,e));const r=e.nodes[n.node.type.name];if(!r)throw new Error(`Node type ${n.node.type.name} not found`);const i=r.createChecked(n.node.attrs,W.from(t));return n.newNode=i,i}else{const t=Xb(n.node,e);return n.newNode=t,t}}function R2(n,e,t){const r=x2(n,e),{root:i,mergeGroups:o}=E2(r),s=Qb(i,t),a=[];for(let f=0;f<o.length;f++){const h=o[f];for(const d of h)if(d.newNode){const m=A2(s,d.newNode);if(m!==-1){const g=O2(m,d.newNode,d.changeType,f);a.push(g)}}}const u=$e.create(s,a);return{mergedDoc:s,decorations:u,mergeGroups:o}}function _2(n){switch(n){case"delete":return"diff-decoration-delete";case"insert":return"diff-decoration-insert";case"modify":return"diff-decoration-modify"}}function D2(n,e){const t=[];for(const r of n)e==="accept"?t.push(...r.delete):t.push(...r.insert);return t}function L2(n){const e={node:n,pos:0,children:[],parent:null,toDelete:!1},t=new Map;return t.set(n,e),n.descendants((r,i,o)=>{if(o===null)return;const s=t.get(o);if(!s)return;const a={node:r,pos:i,children:[],parent:s,toDelete:!1};s.children.push(a),t.set(r,a)}),e}function P2(n,e){for(const t of e){const r=t.from,i=t.to,o=new Set;n.node.descendants((s,a,u)=>{const f=a+s.nodeSize;if(!o.has(s)){o.add(s);const h=B2(n,s);h&&a>=r&&f<=i&&(h.toDelete=!0)}})}}function B2(n,e){function t(r){if(r.node===e)return r;for(const i of r.children){const o=t(i);if(o)return o}return null}return t(n)}function F2(n){function e(t,r=0){if(t.node.type.name==="doc"){for(const o of t.children)e(o,r+1);return}let i=!0;for(const o of t.children)e(o,r+1),o.toDelete||(i=!1);i&&t.children.length>0&&(t.toDelete=!0)}e(n)}function z2(n){const e=[];function t(r){if(r.toDelete){e.push(r);return}for(const i of r.children)t(i)}return t(n),e}function $2(n){if(n.node.type.name!=="doc")return!1;for(const e of n.children)if(!e.toDelete)return!1;return n.children.length>0}function Zb(n,e,t,r){let i=!0;const o=n.get(xn),s=o.state,a=sl(n);if(a.length==0)return!1;const u=n.get(qr.key).decorations;let f;r?f=a:f=[a[t]];let h=D2(f,e),d=f.map(R=>[...R.delete,...R.insert]).flat();const m=u.remove(d);n.set(qr.key,{decorations:m}),i=m.find().length>0;const g=s.tr;o.dispatch(g);const k=L2(s.doc);P2(k,h),F2(k);const C=z2(k),v=$2(k);if(C.length===0)return i;if(v){const R=s.doc.type.schema,K=R.text(""),q=R.nodes.paragraph.create(null,[K]),O=R.nodes.doc.create(null,[q]);let H=s.tr;return H.replaceWith(0,s.doc.nodeSize,O),o.dispatch(H),i}const S=C.sort((R,K)=>K.pos-R.pos);let L=s.tr;for(const R of S){const K=R.pos,q=R.pos+R.node.nodeSize;L.delete(K,q)}return o.dispatch(L),i}function W2(n){const e=sl(n);if(e.length==0)return{currentIndex:-1,count:0};const r=n.get(xn).state.selection.from;let i=-1;for(let o=e.length-1;o>=0;o--){const s=e[o],a=[...s.delete,...s.insert][0];if(a&&a.from<=r){i=o;break}}return{currentIndex:i,count:e.length}}function V2(n,e){const t=n.get(xn),r=sl(n);if(e<0||e>=r.length)return;const i=r[e],o=t.state.doc;let s=[...i.delete,...i.insert][0];const a=o.resolve(s.from),u=pe.near(a,1);t.focus();const f=t.state.tr.setSelection(u);t.dispatch(f);const h=t.domAtPos(a.pos).node;h&&h.scrollIntoView({behavior:"smooth",block:"center"})}function ex(n,e,t){const r=n.get(xn);if(!r){console.warn("Editor view not found.");return}const i=r.state,o=t===void 0?i.doc:n.get(go)(t),s=i.schema,a=n.get(go)(e),u=R2(o,a,s);n.set(qr.key,{decorations:u.decorations});let f=xi.create({doc:u.mergedDoc,schema:s,plugins:i.plugins});r.updateState(f)}const Os=Sn(void 0,"onMergeCtx"),tx=d2("MERGE_TOOL");class H2{constructor(e,t){this.ctx=e,this.editView=t,this.shouldShow=!1,this.scrollTarget=null,this.handleScroll=()=>{this.shouldShow&&this.currentDisplayPos!==void 0&&Ch(this,this.ctx,this.editView,this.currentDisplayPos)},this.hide=()=>{this.shouldShow=!1,this.toggleShow()},this.hideImmediate=()=>{this.shouldShow=!1,this.tooltipProvider.hide(),this.currentGroupIndex=void 0},this.destroy=()=>{this.scrollTarget&&this.scrollTarget.removeEventListener("scroll",this.handleScroll),this.tooltipProvider.destroy(),this.tooltipElement.remove()},this.tooltipElement=document.createElement("div"),this.tooltipElement.className="milkdown-merge-tool-tooltip";const r=document.createElement("div");r.className="milkdown-merge-tool-button-container";const i=e.get(hu.key),o=i.acceptButtonTitle??fh.acceptButtonTitle??"Accept",s=i.rejectButtonTitle??fh.rejectButtonTitle??"Reject";this.acceptButton=document.createElement("button"),this.acceptButton.textContent=o,this.acceptButton.className="milkdown-merge-tool-button accept",this.acceptButton.addEventListener("click",()=>this.handleAccept()),this.rejectButton=document.createElement("button"),this.rejectButton.textContent=s,this.rejectButton.className="milkdown-merge-tool-button reject",this.rejectButton.addEventListener("click",()=>this.handleReject()),r.appendChild(this.rejectButton),r.appendChild(this.acceptButton),this.tooltipElement.appendChild(r),this.tooltipProvider=new h2({content:this.tooltipElement,offset:-2,shouldShow:f=>!1,floatingUIOptions:{placement:"top-end"}}),(t.dom.parentElement??document.body).appendChild(this.tooltipElement);const u=G2(t.dom);this.scrollTarget=u.target,this.scrollTarget&&this.scrollTarget.addEventListener("scroll",this.handleScroll)}handleAccept(){const e=this.ctx.get(Os.key);e==null||e("accept",this.currentGroupIndex),this.hideImmediate()}handleReject(){const e=this.ctx.get(Os.key);e==null||e("reject",this.currentGroupIndex),this.hideImmediate()}toggleShow(){this.shouldShow&&this.showRect?this.tooltipProvider.show({getBoundingClientRect:()=>this.showRect},this.editView):(this.tooltipProvider.hide(),this.currentGroupIndex=void 0)}show(e,t,r){this.currentGroupIndex=e,this.showRect=t,this.shouldShow=!0,r!==void 0&&(this.currentDisplayPos=r),this.toggleShow()}isVisible(){return this.shouldShow}update(e,t){const o=e.state.selection.from;this.currentPos!==o&&(this.currentPos=o,Ch(this,this.ctx,e,o))}}const q2=n=>(n.inject(Os.key),async()=>()=>{n.remove(Os.key)}),K2=[q2,...tx],U2=n=>{let e=null;const t=p2.debounce((r,i)=>{if(!e)return;const o=j2(r,i);if(o===void 0){e.hide();return}Ch(e,n,r,o)},0);n.set(Os.key,(r,i)=>{Zb(n,r,i,!1)}),n.set(tx.key,{props:{handleDOMEvents:{mousemove:t}},view:r=>(e=new H2(n,r),e)})};function j2(n,e){const t=n.posAtCoords({left:e.clientX,top:e.clientY});return t==null?void 0:t.pos}function J2(n){const e=window.getComputedStyle(n),t=e.overflowY,r=e.overflowX,i=e.overflow,o=/(auto|scroll|overlay)/.test(t)||/(auto|scroll|overlay)/.test(i),s=/(auto|scroll|overlay)/.test(r)||/(auto|scroll|overlay)/.test(i);return o&&n.scrollHeight>n.clientHeight||s&&n.scrollWidth>n.clientWidth}function G2(n){let e=n.parentElement;for(;e;){if(J2(e))return{element:e,target:e};e=e.parentElement}return{element:document.scrollingElement instanceof HTMLElement?document.scrollingElement:document.documentElement,target:window}}function Y2(n,e){const t=sl(n),r=t.findIndex(i=>{const o=[...i.delete,...i.insert],s=o[0].from,a=o[o.length-1].to;return s<=e&&e<=a});if(r>=0){const i=t[r],o=i.delete[0]||i.insert[0];return{index:r,decoration:o}}}function Ch(n,e,t,r){var s;if(sl(e).length===0){n.hideImmediate();return}const o=Y2(e,r);if(o){const{index:a,decoration:u}=o,f=(s=u.spec)!=null&&s.offset?u.from:u.from+1,d=t.domAtPos(f).node.getBoundingClientRect();n.show(a,d,r)}}const X2=XF,Q2=n=>async()=>{await n.wait(OD),await n.wait(ga);const{originContent:e,modifiedContent:t}=n.get(hu.key);e!==void 0&&t!==void 0&&ex(n,t,e)},Z2=n=>(U2(n),async()=>{}),nx=[hu,...X2,XD,...K2,Z2,Q2],e3=nx;exports.diff=ex;exports.diffConfig=YD;exports.diffPlugIns=e3;exports.diffPlugins=nx;exports.getDiffState=W2;exports.jumpTo=V2;exports.merge=Zb;