zt-react-milkdown 0.1.0 → 0.1.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/{dist-Cxaq2crg.js → commands-BJpevWrH.js} +123 -123
- package/dist/commands-BmZHd6RL.js +2 -0
- package/dist/{dist-CPVooDwj.cjs → commands-CM7IuhpT.cjs} +2 -2
- package/dist/commands-f4yOm8DQ.cjs +1 -0
- package/dist/{debounce-Bqj_3iJs.cjs → debounce-C_TNzOFT.cjs} +1 -1
- package/dist/{dist-DaM7GJv6.js → dist-CLTsQjPD.js} +319 -318
- package/dist/{dist-CxZn1qUo.js → dist-CZTw9GLV.js} +198 -198
- package/dist/dist-DQnWlYyo.cjs +5 -0
- package/dist/dist-ZPtYoqTI.cjs +1 -0
- package/dist/floating-ui.dom-CV-TLBRq.cjs +1 -0
- package/dist/floating-ui.dom-CoOubeUs.js +762 -0
- package/dist/index.cjs +25 -149
- package/dist/index.mjs +6235 -15737
- package/dist/{lib-C8xOD1Bp.cjs → lib-5pUyY-Tl.cjs} +1 -1
- package/dist/{lib-DkE7Uq2b.js → lib-Bhr5EVOu.js} +110 -112
- package/dist/lib-BmAQCwSQ.cjs +1 -0
- package/dist/{lib-wmHesNI0.js → lib-C1A-pN4b.js} +574 -575
- package/dist/lib-CVebEyb8.cjs +4 -0
- package/dist/lib-ChwoE6v5.js +331 -0
- package/dist/lib-DIx8C5AZ.cjs +1 -0
- package/dist/lib-DVE2k9i1.js +387 -0
- package/dist/{lib-DzK_kn7a.js → lib-D_0WAhKU.js} +3 -3
- package/dist/{lib-m8lKZKxK.js → lib-Dd20rlmV.js} +28 -28
- package/dist/lib-De0djIEV.cjs +5 -0
- package/dist/{lib-D4HMdvmK.cjs → lib-DgEwQN1U.cjs} +1 -1
- package/dist/{dist-Dhukmh4L.js → lib-DmD940Fq.js} +2849 -1735
- package/dist/lib-Dplx6t-N.cjs +3 -0
- package/dist/lib-DzY83R_P.cjs +39 -0
- package/dist/lib-F08NY8fk.cjs +1 -0
- package/dist/{lib-B0rHJ9lJ.js → lib-_NDReOAt.js} +3 -3
- package/dist/{lib-CK9MEMX-.js → lib-bsXGz3fj.js} +28 -27
- package/dist/schema-list-D9Q6QKgo.cjs +1 -0
- package/dist/schema-list-DooYP5HM.js +110 -0
- package/dist/src/core/createEditor.d.ts.map +1 -1
- package/dist/src/local/en-US.d.ts.map +1 -1
- package/dist/src/local/zh-CN.d.ts.map +1 -1
- package/dist/src/plugins/custom/block-transform/block-transform.d.ts +15 -0
- package/dist/src/plugins/custom/block-transform/block-transform.d.ts.map +1 -0
- package/dist/src/plugins/custom/block-transform/index.d.ts +2 -0
- package/dist/src/plugins/custom/block-transform/index.d.ts.map +1 -0
- package/dist/src/plugins/custom/math/index.d.ts +6 -0
- package/dist/src/plugins/custom/math/index.d.ts.map +1 -1
- package/dist/src/plugins/custom/math/math-block-editable.d.ts.map +1 -1
- package/dist/src/plugins/custom/math/math-inline-arrow-navigation.d.ts +5 -0
- package/dist/src/plugins/custom/math/math-inline-arrow-navigation.d.ts.map +1 -0
- package/dist/src/plugins/custom/math/math-inline-edit-plugin.d.ts +29 -0
- package/dist/src/plugins/custom/math/math-inline-edit-plugin.d.ts.map +1 -0
- package/dist/src/plugins/custom/math/math-inline-editable.d.ts +7 -0
- package/dist/src/plugins/custom/math/math-inline-editable.d.ts.map +1 -0
- package/dist/src/plugins/custom/math/math-plugin.d.ts.map +1 -1
- package/dist/src/plugins/custom/selection-tooltip/constants.d.ts +5 -1
- package/dist/src/plugins/custom/selection-tooltip/constants.d.ts.map +1 -1
- package/dist/src/plugins/custom/selection-tooltip/index.d.ts.map +1 -1
- package/dist/src/plugins/custom/selection-tooltip/tooltip-view.d.ts +34 -3
- package/dist/src/plugins/custom/selection-tooltip/tooltip-view.d.ts.map +1 -1
- package/dist/src/plugins/custom/selection-tooltip/types.d.ts +16 -1
- package/dist/src/plugins/custom/selection-tooltip/types.d.ts.map +1 -1
- package/dist/src/plugins/custom/slash-menu/slash-menu-commands.d.ts.map +1 -1
- package/dist/src/plugins/custom/slash-menu/slash-menu-logic.d.ts +4 -0
- package/dist/src/plugins/custom/slash-menu/slash-menu-logic.d.ts.map +1 -1
- package/dist/src/plugins/custom/slash-menu/slash-menu-view.d.ts.map +1 -1
- package/dist/src/plugins/custom/slash-menu/slash-menu.d.ts.map +1 -1
- package/dist/src/plugins/preset-common.d.ts +6 -0
- package/dist/src/plugins/preset-common.d.ts.map +1 -1
- package/dist/src/react/hooks/useMilkdownEditor.d.ts +2 -2
- package/dist/src/react/hooks/useMilkdownEditor.d.ts.map +1 -1
- package/dist/src/types/editor.d.ts +35 -5
- package/dist/src/types/editor.d.ts.map +1 -1
- package/dist/state-BC1dqWPQ.cjs +1 -0
- package/dist/state-BvRk9kiK.cjs +0 -0
- package/dist/state-BvRk9kiK.js +0 -0
- package/dist/state-rTW_1XVf.js +3 -0
- package/dist/style.css +2 -2
- package/package.json +1 -1
- package/dist/commands-CDrea4WB.cjs +0 -1
- package/dist/commands-DoqeX5uJ.js +0 -36
- package/dist/dist-BCCSKc3M.cjs +0 -5
- package/dist/dist-C0PSMrs7.cjs +0 -37
- package/dist/dist-mOpTMw1E.cjs +0 -1
- package/dist/floating-ui.dom-CKbcbmJV.js +0 -883
- package/dist/floating-ui.dom-VaZZ2gzS.cjs +0 -1
- package/dist/index.browser-5LtNN9G9.cjs +0 -1
- package/dist/index.browser-D2DmEB8o.js +0 -26
- package/dist/lib-38nxOnTd.cjs +0 -4
- package/dist/lib-8Tr6mAln.cjs +0 -1
- package/dist/lib-BJgvZywM.cjs +0 -3
- package/dist/lib-BNOSyYeU.cjs +0 -3
- package/dist/lib-C5AzmhNY.cjs +0 -5
- package/dist/lib-CCUU16r8.js +0 -1081
- package/dist/lib-DWZA8C0h.cjs +0 -1
- package/dist/lib-Dbe-cVjv.js +0 -367
- package/dist/lib-IahjxPWM.cjs +0 -3
- package/dist/lib-r5eNG0sa.js +0 -754
- package/dist/rolldown-runtime-CerMd-t8.cjs +0 -1
- package/dist/rolldown-runtime-DnwLefa7.js +0 -23
- package/dist/schema-list-DSdBEAWW.js +0 -171
- package/dist/schema-list-bL8FNes5.cjs +0 -1
- package/dist/state-CHAiIqOA.cjs +0 -1
- package/dist/state-DNxqltZl.js +0 -16
- /package/dist/{debounce-Cuk3VGPr.js → debounce-Z8-khnlZ.js} +0 -0
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
function e(e){this.content=e}e.prototype={constructor:e,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return t==-1?void 0:this.content[t+1]},update:function(t,n,r){var i=r&&r!=t?this.remove(r):this,a=i.find(t),o=i.content.slice();return a==-1?o.push(r||t,n):(o[a+1]=n,r&&(o[a]=r)),new e(o)},remove:function(t){var n=this.find(t);if(n==-1)return this;var r=this.content.slice();return r.splice(n,2),new e(r)},addToStart:function(t,n){return new e([t,n].concat(this.remove(t).content))},addToEnd:function(t,n){var r=this.remove(t).content.slice();return r.push(t,n),new e(r)},addBefore:function(t,n,r){var i=this.remove(n),a=i.content.slice(),o=i.find(t);return a.splice(o==-1?a.length:o,0,n,r),new e(a)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(t){return t=e.from(t),t.size?new e(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=e.from(t),t.size?new e(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var n=this;t=e.from(t);for(var r=0;r<t.content.length;r+=2)n=n.remove(t.content[r]);return n},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},e.from=function(t){if(t instanceof e)return t;var n=[];if(t)for(var r in t)n.push(r,t[r]);return new e(n)};function t(e,n,r){for(let i=0;;i++){if(i==e.childCount||i==n.childCount)return e.childCount==n.childCount?null:r;let a=e.child(i),o=n.child(i);if(a==o){r+=a.nodeSize;continue}if(!a.sameMarkup(o))return r;if(a.isText&&a.text!=o.text){for(let e=0;a.text[e]==o.text[e];e++)r++;return r}if(a.content.size||o.content.size){let e=t(a.content,o.content,r+1);if(e!=null)return e}r+=a.nodeSize}}function n(e,t,r,i){for(let a=e.childCount,o=t.childCount;;){if(a==0||o==0)return a==o?null:{a:r,b:i};let s=e.child(--a),c=t.child(--o),l=s.nodeSize;if(s==c){r-=l,i-=l;continue}if(!s.sameMarkup(c))return{a:r,b:i};if(s.isText&&s.text!=c.text){let e=0,t=Math.min(s.text.length,c.text.length);for(;e<t&&s.text[s.text.length-e-1]==c.text[c.text.length-e-1];)e++,r--,i--;return{a:r,b:i}}if(s.content.size||c.content.size){let e=n(s.content,c.content,r-1,i-1);if(e)return e}r-=l,i-=l}}var r=class e{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,i){for(let a=0,o=0;o<t;a++){let s=this.content[a],c=o+s.nodeSize;if(c>e&&n(s,r+o,i||null,a)!==!1&&s.content.size){let i=o+1;s.nodesBetween(Math.max(0,e-i),Math.min(s.content.size,t-i),n,r+i)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i=``,a=!0;return this.nodesBetween(e,t,(o,s)=>{let c=o.isText?o.text.slice(Math.max(e,s)-s,t-s):o.isLeaf?r?typeof r==`function`?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):``:``;o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<t.content.length;a++)i.push(t.content[a]);return new e(i,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],i=0;if(n>t)for(let e=0,a=0;a<n;e++){let o=this.content[e],s=a+o.nodeSize;s>t&&((a<t||s>n)&&(o=o.isText?o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=s}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,a)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.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 RangeError(`Index `+e+` out of range for `+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,n=0){return t(this,e,n)}findDiffEnd(e,t=this.size,r=e.size){return n(this,e,t,r)}findIndex(e){if(e==0)return a(0,e);if(e==this.size)return a(this.content.length,e);if(e>this.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),i=n+r.nodeSize;if(i>=e)return i==e?a(t+1,i):a(t,n);n=i}}toString(){return`<`+this.toStringInner()+`>`}toStringInner(){return this.content.join(`, `)}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw RangeError(`Invalid input for Fragment.fromJSON`);return e.fromArray(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;e<t.length;e++){let i=t[e];r+=i.nodeSize,e&&i.isText&&t[e-1].sameMarkup(i)?(n||=t.slice(0,e),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new e(n||t,r)}static from(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw RangeError(`Can not convert `+t+` to a Fragment`+(t.nodesBetween?` (looks like multiple versions of prosemirror-model were loaded)`:``))}};r.empty=new r([],0);var i={index:0,offset:0};function a(e,t){return i.index=e,i.offset=t,i}function o(e,t){if(e===t)return!0;if(!(e&&typeof e==`object`)||!(t&&typeof t==`object`))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!o(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!o(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}var s=class e{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))t||=e.slice(0,r);else if(i.type.excludes(this.type))return e;else !n&&i.type.rank>this.type.rank&&(t||=e.slice(0,r),t.push(this),n=!0),t&&t.push(i)}return t||=e.slice(),n||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&&o(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 RangeError(`Invalid input for Mark.fromJSON`);let n=e.marks[t.type];if(!n)throw RangeError(`There is no mark type ${t.type} in this schema`);let r=n.create(t.attrs);return n.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return e.none;if(t instanceof e)return[t];let n=t.slice();return n.sort((e,t)=>e.type.rank-t.type.rank),n}};s.none=[];var c=class extends Error{},l=class e{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=d(this.content,t+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e(u(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+`(`+this.openStart+`,`+this.openEnd+`)`}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(t,n){if(!n)return e.empty;let i=n.openStart||0,a=n.openEnd||0;if(typeof i!=`number`||typeof a!=`number`)throw RangeError(`Invalid input for Slice.fromJSON`);return new e(r.fromJSON(t,n.content),i,a)}static maxOpen(t,n=!0){let r=0,i=0;for(let e=t.firstChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.firstChild)r++;for(let e=t.lastChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.lastChild)i++;return new e(t,r,i)}};l.empty=new l(r.empty,0,0);function u(e,t,n){let{index:r,offset:i}=e.findIndex(t),a=e.maybeChild(r),{index:o,offset:s}=e.findIndex(n);if(i==t||a.isText){if(s!=n&&!e.child(o).isText)throw RangeError(`Removing non-flat range`);return e.cut(0,t).append(e.cut(n))}if(r!=o)throw RangeError(`Removing non-flat range`);return e.replaceChild(r,a.copy(u(a.content,t-i-1,n-i-1)))}function d(e,t,n,r,i,a){let{index:o,offset:s}=e.findIndex(t),c=e.maybeChild(o);if(s==t||c.isText)return a&&r<=0&&i<=0&&!a.canReplace(o,o,n)?null:e.cut(0,t).append(n).append(e.cut(t));let l=d(c.content,t-s-1,n,o==0?r-1:0,o==e.childCount-1?i-1:0,c);return l&&e.replaceChild(o,c.copy(l))}function f(e,t,n){if(n.openStart>e.depth)throw new c(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new c(`Inconsistent open depths`);return p(e,t,n,0)}function p(e,t,n,r){let i=e.index(r),a=e.node(r);if(i==t.index(r)&&r<e.depth-n.openStart){let o=p(e,t,n,r+1);return a.copy(a.content.replaceChild(i,o))}else if(!n.content.size)return v(a,y(e,t,r));else if(!n.openStart&&!n.openEnd&&e.depth==r&&t.depth==r){let r=e.parent,i=r.content;return v(r,i.cut(0,e.parentOffset).append(n.content).append(i.cut(t.parentOffset)))}else{let{start:i,end:o}=te(n,e);return v(a,ee(e,i,o,t,r))}}function m(e,t){if(!t.type.compatibleContent(e.type))throw new c(`Cannot join `+t.type.name+` onto `+e.type.name)}function h(e,t,n){let r=e.node(n);return m(r,t.node(n)),r}function g(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function _(e,t,n,r){let i=(t||e).node(n),a=0,o=t?t.index(n):i.childCount;e&&(a=e.index(n),e.depth>n?a++:e.textOffset&&(g(e.nodeAfter,r),a++));for(let e=a;e<o;e++)g(i.child(e),r);t&&t.depth==n&&t.textOffset&&g(t.nodeBefore,r)}function v(e,t){return e.type.checkContent(t),e.copy(t)}function ee(e,t,n,i,a){let o=e.depth>a&&h(e,t,a+1),s=i.depth>a&&h(n,i,a+1),c=[];return _(null,e,a,c),o&&s&&t.index(a)==n.index(a)?(m(o,s),g(v(o,ee(e,t,n,i,a+1)),c)):(o&&g(v(o,y(e,t,a+1)),c),_(t,n,a,c),s&&g(v(s,y(n,i,a+1)),c)),_(i,null,a,c),new r(c)}function y(e,t,n){let i=[];return _(null,e,n,i),e.depth>n&&g(v(h(e,t,n+1),y(e,t,n+1)),i),_(t,null,n,i),new r(i)}function te(e,t){let n=t.depth-e.openStart,i=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)i=t.node(e).copy(r.from(i));return{start:i.resolveNoCache(e.openStart+n),end:i.resolveNoCache(i.content.size-e.openEnd-n)}}var ne=class e{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,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 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 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 n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}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 n=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return s.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let i=n.marks;for(var a=0;a<i.length;a++)i[a].type.spec.inclusive===!1&&(!r||!i[a].isInSet(r.marks))&&(i=i[a--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var i=0;i<n.length;i++)n[i].type.spec.inclusive===!1&&(!r||!n[i].isInSet(r.marks))&&(n=n[i--].removeFromSet(n));return n}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 n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new oe(this,e,n);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(t,n){if(!(n>=0&&n<=t.content.size))throw RangeError(`Position `+n+` out of range`);let r=[],i=0,a=n;for(let e=t;;){let{index:t,offset:n}=e.content.findIndex(a),o=a-n;if(r.push(e,t,i+n),!o||(e=e.child(t),e.isText))break;a=o-1,i+=n+1}return new e(n,r,a)}static resolveCached(t,n){let r=ae.get(t);if(r)for(let e=0;e<r.elts.length;e++){let t=r.elts[e];if(t.pos==n)return t}else ae.set(t,r=new re);let i=r.elts[r.i]=e.resolve(t,n);return r.i=(r.i+1)%ie,i}},re=class{constructor(){this.elts=[],this.i=0}},ie=12,ae=new WeakMap,oe=class{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},se=Object.create(null),b=class e{constructor(e,t,n,i=s.none){this.type=e,this.attrs=t,this.marks=i,this.content=n||r.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,n,r=0){this.content.nodesBetween(e,t,n,r,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,n,r){return this.content.textBetween(e,t,n,r)}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,n){return this.type==e&&o(this.attrs,t||e.defaultAttrs||se)&&s.sameSet(this.marks,n||s.none)}copy(t=null){return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}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,n=!1){if(e==t)return l.empty;let r=this.resolve(e),i=this.resolve(t),a=n?0:r.sharedDepth(t),o=r.start(a);return new l(r.node(a).content.cut(r.pos-o,i.pos-o),r.depth-a,i.depth-a)}replace(e,t,n){return f(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return ne.resolveCached(this,e)}resolveNoCache(e){return ne.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}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()+`)`),le(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error(`Called contentMatchAt on a node with invalid content`);return t}canReplace(e,t,n=r.empty,i=0,a=n.childCount){let o=this.contentMatchAt(e).matchFragment(n,i,a),s=o&&o.matchFragment(this.content,t);if(!s||!s.validEnd)return!1;for(let e=i;e<a;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(e).matchType(n),a=i&&i.matchFragment(this.content,t);return a?a.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=s.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!s.sameSet(e,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.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(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Node.fromJSON`);let n;if(t.marks){if(!Array.isArray(t.marks))throw RangeError(`Invalid mark data for Node.fromJSON`);n=t.marks.map(e.markFromJSON)}if(t.type==`text`){if(typeof t.text!=`string`)throw RangeError(`Invalid text node in JSON`);return e.text(t.text,n)}let i=r.fromJSON(e,t.content),a=e.nodeType(t.type).create(t.attrs,i,n);return a.type.checkAttrs(a.attrs),a}};b.prototype.text=void 0;var ce=class e extends b{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError(`Empty text nodes are not allowed`);this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):le(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(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,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 le(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}var x=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new ue(t,n);if(r.next==null)return e.empty;let i=de(r);r.next&&r.err(`Unexpected trailing text`);let a=xe(ve(i));return Se(a,r),a}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,n=e.childCount){let r=this;for(let i=t;r&&i<n;i++)r=r.matchType(e.child(i).type);return r}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 n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let i=[this];function a(o,s){let c=o.matchFragment(e,n);if(c&&(!t||c.validEnd))return r.from(s.map(e=>e.createAndFill()));for(let e=0;e<o.next.length;e++){let{type:t,next:n}=o.next[e];if(!(t.isText||t.hasRequiredAttrs())&&i.indexOf(n)==-1){i.push(n);let e=a(n,s.concat(t));if(e)return e}}return null}return a(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<i.next.length;e++){let{type:a,next:o}=i.next[e];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in t)&&(!r.type||o.validEnd)&&(n.push({match:a.contentMatch,type:a,via:r}),t[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let r=0;r<n.next.length;r++)e.indexOf(n.next[r].next)==-1&&t(n.next[r].next)}return t(this),e.map((t,n)=>{let r=n+(t.validEnd?`*`:` `)+` `;for(let n=0;n<t.next.length;n++)r+=(n?`, `:``)+t.next[n].type.name+`->`+e.indexOf(t.next[n].next);return r}).join(`
|
|
2
|
+
`)}};x.empty=new x(!0);var ue=class{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==``&&this.tokens.pop(),this.tokens[0]==``&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw SyntaxError(e+` (in content expression '`+this.string+`')`)}};function de(e){let t=[];do t.push(fe(e));while(e.eat(`|`));return t.length==1?t[0]:{type:`choice`,exprs:t}}function fe(e){let t=[];do t.push(pe(e));while(e.next&&e.next!=`)`&&e.next!=`|`);return t.length==1?t[0]:{type:`seq`,exprs:t}}function pe(e){let t=_e(e);for(;;)if(e.eat(`+`))t={type:`plus`,expr:t};else if(e.eat(`*`))t={type:`star`,expr:t};else if(e.eat(`?`))t={type:`opt`,expr:t};else if(e.eat(`{`))t=he(e,t);else break;return t}function me(e){/\D/.test(e.next)&&e.err(`Expected number, got '`+e.next+`'`);let t=Number(e.next);return e.pos++,t}function he(e,t){let n=me(e),r=n;return e.eat(`,`)&&(r=e.next==`}`?-1:me(e)),e.eat(`}`)||e.err(`Unclosed braced range`),{type:`range`,min:n,max:r,expr:t}}function ge(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let i=[];for(let e in n){let r=n[e];r.isInGroup(t)&&i.push(r)}return i.length==0&&e.err(`No node type or group '`+t+`' found`),i}function _e(e){if(e.eat(`(`)){let t=de(e);return e.eat(`)`)||e.err(`Missing closing paren`),t}else if(/\W/.test(e.next))e.err(`Unexpected token '`+e.next+`'`);else{let t=ge(e,e.next).map(t=>(e.inline==null?e.inline=t.isInline:e.inline!=t.isInline&&e.err(`Mixing inline and block content`),{type:`name`,value:t}));return e.pos++,t.length==1?t[0]:{type:`choice`,exprs:t}}}function ve(e){let t=[[]];return i(a(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let i={term:r,to:n};return t[e].push(i),i}function i(e,t){e.forEach(e=>e.to=t)}function a(e,t){if(e.type==`choice`)return e.exprs.reduce((e,n)=>e.concat(a(n,t)),[]);if(e.type==`seq`)for(let r=0;;r++){let o=a(e.exprs[r],t);if(r==e.exprs.length-1)return o;i(o,t=n())}else if(e.type==`star`){let o=n();return r(t,o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`plus`){let o=n();return i(a(e.expr,t),o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`opt`)return[r(t)].concat(a(e.expr,t));else if(e.type==`range`){let o=t;for(let t=0;t<e.min;t++){let t=n();i(a(e.expr,o),t),o=t}if(e.max==-1)i(a(e.expr,o),o);else for(let t=e.min;t<e.max;t++){let t=n();r(o,t),i(a(e.expr,o),t),o=t}return[r(o)]}else if(e.type==`name`)return[r(t,void 0,e.value)];else throw Error(`Unknown expr type`)}}function ye(e,t){return t-e}function be(e,t){let n=[];return r(t),n.sort(ye);function r(t){let i=e[t];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(t);for(let e=0;e<i.length;e++){let{term:t,to:a}=i[e];!t&&n.indexOf(a)==-1&&r(a)}}}function xe(e){let t=Object.create(null);return n(be(e,0));function n(r){let i=[];r.forEach(t=>{e[t].forEach(({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e<i.length;e++)i[e][0]==t&&(r=i[e][1]);be(e,n).forEach(e=>{r||i.push([t,r=[]]),r.indexOf(e)==-1&&r.push(e)})})});let a=t[r.join(`,`)]=new x(r.indexOf(e.length-1)>-1);for(let e=0;e<i.length;e++){let r=i[e][1].sort(ye);a.next.push({type:i[e][0],next:t[r.join(`,`)]||n(r)})}return a}}function Se(e,t){for(let n=0,r=[e];n<r.length;n++){let e=r[n],i=!e.validEnd,a=[];for(let t=0;t<e.next.length;t++){let{type:n,next:o}=e.next[t];a.push(n.name),i&&!(n.isText||n.hasRequiredAttrs())&&(i=!1),r.indexOf(o)==-1&&r.push(o)}i&&t.err(`Only non-generatable nodes (`+a.join(`, `)+`) in a required position (see https://prosemirror.net/docs/guide/#generatable)`)}}function Ce(e){let t=Object.create(null);for(let n in e){let r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function we(e,t){let n=Object.create(null);for(let r in e){let i=t&&t[r];if(i===void 0){let t=e[r];if(t.hasDefault)i=t.default;else throw RangeError(`No value supplied for attribute `+r)}n[r]=i}return n}function Te(e,t,n,r){for(let r in t)if(!(r in e))throw RangeError(`Unsupported attribute ${r} for ${n} of type ${r}`);for(let n in e){let r=e[n];r.validate&&r.validate(t[n])}}function Ee(e,t){let n=Object.create(null);if(t)for(let r in t)n[r]=new ke(e,r,t[r]);return n}var De=class e{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(` `):[],this.attrs=Ee(e,n.attrs),this.defaultAttrs=Ce(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||e==`text`),this.isText=e==`text`}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==x.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:we(this.attrs,e)}create(e=null,t,n){if(this.isText)throw Error(`NodeType.create can't construct text nodes`);return new b(this,this.computeAttrs(e),r.from(t),s.setFrom(n))}createChecked(e=null,t,n){return t=r.from(t),this.checkContent(t),new b(this,this.computeAttrs(e),t,s.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),t=r.from(t),t.size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let i=this.contentMatch.matchFragment(t),a=i&&i.fillBefore(r.empty,!0);return a?new b(this,e,t.append(a),s.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t<e.childCount;t++)if(!this.allowsMarks(e.child(t).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){Te(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 n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||=e.slice(0,n);return t?t.length?t:s.none:e}static compile(t,n){let r=Object.create(null);t.forEach((t,i)=>r[t]=new e(t,n,i));let i=n.spec.topNode||`doc`;if(!r[i])throw RangeError(`Schema is missing its top node type ('`+i+`')`);if(!r.text)throw RangeError(`Every schema needs a 'text' type`);for(let e in r.text.attrs)throw RangeError(`The text node type should not have attributes`);return r}};function Oe(e,t,n){let r=n.split(`|`);return n=>{let i=n===null?`null`:typeof n;if(r.indexOf(i)<0)throw RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${i}`)}}var ke=class{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,`default`),this.default=n.default,this.validate=typeof n.validate==`string`?Oe(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}},Ae=class e{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=Ee(e,r.attrs),this.excluded=null;let i=Ce(this.attrs);this.instance=i?new s(this,i):null}create(e=null){return!e&&this.instance?this.instance:new s(this,we(this.attrs,e))}static compile(t,n){let r=Object.create(null),i=0;return t.forEach((t,a)=>r[t]=new e(t,i++,n,a)),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){Te(this.attrs,e,`mark`,this.name)}excludes(e){return this.excluded.indexOf(e)>-1}},je=class{constructor(t){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let e in t)n[e]=t[e];n.nodes=e.from(t.nodes),n.marks=e.from(t.marks||{}),this.nodes=De.compile(this.spec.nodes,this),this.marks=Ae.compile(this.spec.marks,this);let r=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw RangeError(e+` can not be both a node and a mark`);let t=this.nodes[e],n=t.spec.content||``,i=t.spec.marks;if(t.contentMatch=r[n]||(r[n]=x.parse(n,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.spec.linebreakReplacement){if(this.linebreakReplacement)throw RangeError(`Multiple linebreak nodes defined`);if(!t.isInline||!t.isLeaf)throw RangeError(`Linebreak replacement nodes must be inline leaf nodes`);this.linebreakReplacement=t}t.markSet=i==`_`?null:i?Me(this,i.split(` `)):i==``||!t.inlineContent?[]:null}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=n==null?[t]:n==``?[]:Me(this,n.split(` `))}this.nodeFromJSON=e=>b.fromJSON(this,e),this.markFromJSON=e=>s.fromJSON(this,e),this.topNodeType=this.nodes[this.spec.topNode||`doc`],this.cached.wrappings=Object.create(null)}node(e,t=null,n,r){if(typeof e==`string`)e=this.nodeType(e);else if(!(e instanceof De))throw RangeError(`Invalid node type: `+e);else if(e.schema!=this)throw RangeError(`Node type from different schema used (`+e.name+`)`);return e.createChecked(t,n,r)}text(e,t){let n=this.nodes.text;return new ce(n,n.defaultAttrs,e,s.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 RangeError(`Unknown node type: `+e);return t}};function Me(e,t){let n=[];for(let r=0;r<t.length;r++){let i=t[r],a=e.marks[i],o=a;if(a)n.push(a);else for(let t in e.marks){let r=e.marks[t];(i==`_`||r.spec.group&&r.spec.group.split(` `).indexOf(i)>-1)&&n.push(o=r)}if(!o)throw SyntaxError(`Unknown mark type: '`+t[r]+`'`)}return n}function Ne(e){return e.tag!=null}function Pe(e){return e.style!=null}var Fe=class e{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(e=>{if(Ne(e))this.tags.push(e);else if(Pe(e)){let t=/[^=]*/.exec(e.style)[0];n.indexOf(t)<0&&n.push(t),this.styles.push(e)}}),this.normalizeLists=!this.tags.some(t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)})}parse(e,t={}){let n=new Ve(this,t,!1);return n.addAll(e,s.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new Ve(this,t,!0);return n.addAll(e,s.none,t.from,t.to),l.maxOpen(n.finish())}matchTag(e,t,n){for(let r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){let n=this.tags[r];if(Ue(e,n.tag)&&(n.namespace===void 0||e.namespaceURI==n.namespace)&&(!n.context||t.matchesContext(n.context))){if(n.getAttrs){let t=n.getAttrs(e);if(t===!1)continue;n.attrs=t||void 0}return n}}}matchStyle(e,t,n,r){for(let i=r?this.styles.indexOf(r)+1:0;i<this.styles.length;i++){let r=this.styles[i],a=r.style;if(!(a.indexOf(e)!=0||r.context&&!n.matchesContext(r.context)||a.length>e.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=t))){if(r.getAttrs){let e=r.getAttrs(t);if(e===!1)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=e.priority==null?50:e.priority,r=0;for(;r<t.length;r++){let e=t[r];if((e.priority==null?50:e.priority)<n)break}t.splice(r,0,e)}for(let t in e.marks){let r=e.marks[t].spec.parseDOM;r&&r.forEach(e=>{n(e=We(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)})}for(let t in e.nodes){let r=e.nodes[t].spec.parseDOM;r&&r.forEach(e=>{n(e=We(e)),e.node||e.ignore||e.mark||(e.node=t)})}return t}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new e(t,e.schemaRules(t)))}},Ie={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},Le={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Re={ol:!0,ul:!0},S=1,ze=2,C=4;function Be(e,t,n){return t==null?e&&e.whitespace==`pre`?3:n&-5:(t?S:0)|(t===`full`?ze:0)}var w=class{constructor(e,t,n,r,i,a){this.type=e,this.attrs=t,this.marks=n,this.solid=r,this.options=a,this.content=[],this.activeMarks=s.none,this.match=i||(a&C?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(r.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let t=this.type.contentMatch,n;return(n=t.findWrapping(e.type))?(this.match=t,n):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&S)){let e=this.content[this.content.length-1],t;if(e&&e.isText&&(t=/[ \t\r\n\u000c]+$/.exec(e.text))){let n=e;e.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-t[0].length))}}let t=r.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(r.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&&!Ie.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},Ve=class{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r=t.topNode,i,a=Be(null,t.preserveWhitespace,0)|(n?C:0);i=r?new w(r.type,r.attrs,s.none,!0,t.topMatch||r.type.contentMatch,a):n?new w(null,null,s.none,!0,null,a):new w(e.schema.topNodeType,null,s.none,!0,null,a),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,r=this.top,i=r.options&ze?`full`:this.localPreserveWS||(r.options&S)>0,{schema:a}=this.parser;if(i===`full`||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(!i){if(n=n.replace(/[ \t\r\n\u000c]+/g,` `),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let t=r.content[r.content.length-1],i=e.previousSibling;(!t||i&&i.nodeName==`BR`||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}}else if(i===`full`)n=n.replace(/\r\n?/g,`
|
|
3
|
+
`);else if(a.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(a.linebreakReplacement.create())){let e=n.split(/\r?\n|\r/);for(let n=0;n<e.length;n++)n&&this.insertNode(a.linebreakReplacement.create(),t,!0),e[n]&&this.insertNode(a.text(e[n]),t,!/\S/.test(e[n]));n=``}else n=n.replace(/\r?\n|\r/g,` `);n&&this.insertNode(a.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let r=this.localPreserveWS,i=this.top;(e.tagName==`PRE`||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let a=e.nodeName.toLowerCase(),o;Re.hasOwnProperty(a)&&this.parser.normalizeLists&&He(e);let s=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,n));out:if(s?s.ignore:Le.hasOwnProperty(a))this.findInside(e),this.ignoreFallback(e,t);else if(!s||s.skip||s.closeParent){s&&s.closeParent?this.open=Math.max(0,this.open-1):s&&s.skip.nodeType&&(e=s.skip);let n,r=this.needsBlock;if(Ie.hasOwnProperty(a))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),n=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break out}let o=s&&s.skip?t:this.readStyles(e,t);o&&this.addAll(e,o),n&&this.sync(i),this.needsBlock=r}else{let n=this.readStyles(e,t);n&&this.addElementByRule(e,s,n,s.consuming===!1?o:void 0)}this.localPreserveWS=r}leafFallback(e,t){e.nodeName==`BR`&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
4
|
+
`),t)}ignoreFallback(e,t){e.nodeName==`BR`&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text(`-`),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let e=0;e<this.parser.matchedStyles.length;e++){let r=this.parser.matchedStyles[e],i=n.getPropertyValue(r);if(i)for(let e;;){let n=this.parser.matchStyle(r,i,this,e);if(!n)break;if(n.ignore)return null;if(t=n.clearMark?t.filter(e=>!n.clearMark(e)):t.concat(this.parser.schema.marks[n.mark].create(n.attrs)),n.consuming===!1)e=n;else break}}return t}addElementByRule(e,t,n,r){let i,a;if(t.node)if(a=this.parser.schema.nodes[t.node],a.isLeaf)this.insertNode(a.create(t.attrs),n,e.nodeName==`BR`)||this.leafFallback(e,n);else{let e=this.enter(a,t.attrs||null,n,t.preserveWhitespace);e&&(i=!0,n=e)}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let o=this.top;if(a&&a.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e,n,!1));else{let r=e;typeof t.contentElement==`string`?r=e.querySelector(t.contentElement):typeof t.contentElement==`function`?r=t.contentElement(e):t.contentElement&&(r=t.contentElement),this.findAround(e,r,!0),this.addAll(r,n),this.findAround(e,r,!1)}i&&this.sync(o)&&this.open--}addAll(e,t,n,r){let i=n||0;for(let a=n?e.childNodes[n]:e.firstChild,o=r==null?null:e.childNodes[r];a!=o;a=a.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(a,t);this.findAtPoint(e,i)}findPlace(e,t,n){let r,i;for(let t=this.open,a=0;t>=0;t--){let o=this.nodes[t],s=o.findWrapping(e);if(s&&(!r||r.length>s.length+a)&&(r=s,i=o,!s.length))break;if(o.solid){if(n)break;a+=2}}if(!r)return null;this.sync(i);for(let e=0;e<r.length;e++)t=this.enterInner(r[e],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&(t=this.enterInner(e,null,t))}let r=this.findPlace(e,t,n);if(r){this.closeExtra();let t=this.top;t.match&&=t.match.matchType(e.type);let n=s.none;for(let i of r.concat(e.marks))(t.type?t.type.allowsMarkType(i.type):Ge(i.type,e.type))&&(n=i.addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n,r){let i=this.findPlace(e.create(t),n,!1);return i&&=this.enterInner(e,t,n,!0,r),i}enterInner(e,t,n,r=!1,i){this.closeExtra();let a=this.top;a.match=a.match&&a.match.matchType(e);let o=Be(e,i,a.options);a.options&C&&a.content.length==0&&(o|=C);let c=s.none;return n=n.filter(t=>(a.type?a.type.allowsMarkType(t.type):Ge(t.type,e))?(c=t.addToSet(c),!1):!0),this.nodes.push(new w(e,t,c,r,null,o)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;else this.localPreserveWS&&(this.nodes[t].options|=S);return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let r=0;r<this.find.length;r++)this.find[r].pos==null&&e.nodeType==1&&e.contains(this.find[r].node)&&t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf(`|`)>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split(`/`),n=this.options.context,r=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),i=-(n?n.depth+1:0)+ +!r,a=(e,o)=>{for(;e>=0;e--){let s=t[e];if(s==``){if(e==t.length-1||e==0)continue;for(;o>=i;o--)if(a(e-1,o))return!0;return!1}else{let e=o>0||o==0&&r?this.nodes[o].type:n&&o>=i?n.node(o-i).type:null;if(!e||e.name!=s&&!e.isInGroup(s))return!1;o--}}return!0};return a(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}};function He(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=t.nodeType==1?t.nodeName.toLowerCase():null;e&&Re.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):e==`li`?n=t:e&&(n=null)}}function Ue(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function We(e){let t={};for(let n in e)t[n]=e[n];return t}function Ge(e,t){let n=t.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(e))continue;let a=[],o=e=>{a.push(e);for(let n=0;n<e.edgeCount;n++){let{type:r,next:i}=e.edge(n);if(r==t||a.indexOf(i)<0&&o(i))return!0}};if(o(i.contentMatch))return!0}}var Ke=class e{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||=T(t).createDocumentFragment();let r=n,i=[];return e.forEach(e=>{if(i.length||e.marks.length){let n=0,a=0;for(;n<i.length&&a<e.marks.length;){let t=e.marks[a];if(!this.marks[t.type.name]){a++;continue}if(!t.eq(i[n][0])||t.type.spec.spanning===!1)break;n++,a++}for(;n<i.length;)r=i.pop()[1];for(;a<e.marks.length;){let n=e.marks[a++],o=this.serializeMark(n,e.isInline,t);o&&(i.push([n,r]),r.appendChild(o.dom),r=o.contentDOM||o.dom)}}r.appendChild(this.serializeNodeInner(e,t))}),n}serializeNodeInner(e,t){if(e.isText)return T(t).createTextNode(e.text);let{dom:n,contentDOM:r}=E(T(t),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw RangeError(`Content hole not allowed in a leaf node spec`);this.serializeFragment(e.content,t,r)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let i=this.serializeMark(e.marks[r],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(n),n=i.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&E(T(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return typeof t==`string`?{dom:e.createTextNode(t)}:E(e,t,n,r)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new e(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(e){let t=qe(e.nodes);return t.text||=e=>e.text,t}static marksFromSchema(e){return qe(e.marks)}};function qe(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function T(e){return e.document||window.document}var Je=new WeakMap;function Ye(e){let t=Je.get(e);return t===void 0&&Je.set(e,t=Xe(e)),t}function Xe(e){let t=null;function n(e){if(e&&typeof e==`object`)if(Array.isArray(e))if(typeof e[0]==`string`)t||=[],t.push(e);else for(let t=0;t<e.length;t++)n(e[t]);else for(let t in e)n(e[t])}return n(e),t}function E(e,t,n,r){if(t.nodeType==1)return{dom:t};if(t.dom&&t.dom.nodeType==1)return t;let i=t[0],a;if(typeof i!=`string`)throw RangeError(`Invalid array passed to renderSpec`);if(r&&(a=Ye(r))&&a.indexOf(t)>-1)throw RangeError(`Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.`);let o=i.indexOf(` `);o>0&&(n=i.slice(0,o),i=i.slice(o+1));let s,c=n?e.createElementNS(n,i):e.createElement(i),l=t[1],u=1;if(l&&typeof l==`object`&&l.nodeType==null&&!Array.isArray(l)){u=2;for(let e in l)if(l[e]!=null){let t=e.indexOf(` `);t>0?c.setAttributeNS(e.slice(0,t),e.slice(t+1),l[e]):e==`style`&&c.style?c.style.cssText=l[e]:c.setAttribute(e,l[e])}}for(let i=u;i<t.length;i++){let a=t[i];if(a===0){if(i<t.length-1||i>u)throw RangeError(`Content hole must be the only child of its parent node`);return{dom:c,contentDOM:c}}else if(typeof a==`string`)c.appendChild(e.createTextNode(a));else{let{dom:t,contentDOM:i}=E(e,a,n,r);if(c.appendChild(t),i){if(s)throw RangeError(`Multiple content holes`);s=i}}}return{dom:c,contentDOM:s}}var Ze=65535,Qe=2**16;function $e(e,t){return e+t*Qe}function et(e){return e&Ze}function tt(e){return(e-(e&Ze))/Qe}var nt=1,rt=2,it=4,at=8,D=class{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&at)>0}get deletedBefore(){return(this.delInfo&5)>0}get deletedAfter(){return(this.delInfo&6)>0}get deletedAcross(){return(this.delInfo&it)>0}},O=class e{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&e.empty)return e.empty}recover(e){let t=0,n=et(e);if(!this.inverted)for(let e=0;e<n;e++)t+=this.ranges[e*3+2]-this.ranges[e*3+1];return this.ranges[n*3]+t+tt(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let r=0,i=this.inverted?2:1,a=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let s=this.ranges[o]-(this.inverted?r:0);if(s>e)break;let c=this.ranges[o+i],l=this.ranges[o+a],u=s+c;if(e<=u){let i=c?e==s?-1:e==u?1:t:t,a=s+r+(i<0?0:l);if(n)return a;let d=e==(t<0?s:u)?null:$e(o/3,e-s),f=e==s?rt:e==u?nt:it;return(t<0?e!=s:e!=u)&&(f|=at),new D(a,f,d)}r+=l-c}return n?e+r:new D(e+r,0,null)}touches(e,t){let n=0,r=et(t),i=this.inverted?2:1,a=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let o=this.ranges[t]-(this.inverted?n:0);if(o>e)break;let s=this.ranges[t+i];if(e<=o+s&&t==r*3)return!0;n+=this.ranges[t+a]-s}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,i=0;r<this.ranges.length;r+=3){let a=this.ranges[r],o=a-(this.inverted?i:0),s=a+(this.inverted?0:i),c=this.ranges[r+t],l=this.ranges[r+n];e(o,o+c,s,s+l),i+=l-c}}invert(){return new e(this.ranges,!this.inverted)}toString(){return(this.inverted?`-`:``)+JSON.stringify(this.ranges)}static offset(t){return t==0?e.empty:new e(t<0?[0,-t,0]:[0,0,t])}};O.empty=new O([]);var ot=class e{constructor(e,t,n=0,r=e?e.length:0){this.mirror=t,this.from=n,this.to=r,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(t=0,n=this.maps.length){return new e(this._maps,this.mirror,t,n)}appendMap(e,t){this.ownData||=(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,n=this._maps.length;t<e._maps.length;t++){let r=e.getMirror(t);this.appendMap(e._maps[t],r!=null&&r<t?n+r: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.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){let r=e.getMirror(t);this.appendMap(e._maps[t].invert(),r!=null&&r>t?n-r-1:void 0)}}invert(){let t=new e;return t.appendMappingInverted(this),t}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let r=0;for(let n=this.from;n<this.to;n++){let i=this._maps[n].mapResult(e,t);if(i.recover!=null){let t=this.getMirror(n);if(t!=null&&t>n&&t<this.to){n=t,e=this._maps[t].recover(i.recover);continue}}r|=i.delInfo,e=i.pos}return n?e:new D(e,r,null)}},k=Object.create(null),A=class{getMap(){return O.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw RangeError(`Invalid input for Step.fromJSON`);let n=k[t.stepType];if(!n)throw RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in k)throw RangeError(`Duplicate use of step JSON ID `+e);return k[e]=t,t.prototype.jsonID=e,t}},j=class e{constructor(e,t){this.doc=e,this.failed=t}static ok(t){return new e(t,null)}static fail(t){return new e(null,t)}static fromReplace(t,n,r,i){try{return e.ok(t.replace(n,r,i))}catch(t){if(t instanceof c)return e.fail(t.message);throw t}}};function M(e,t,n){let i=[];for(let r=0;r<e.childCount;r++){let a=e.child(r);a.content.size&&(a=a.copy(M(a.content,t,a))),a.isInline&&(a=t(a,n,r)),i.push(a)}return r.fromArray(i)}var N=class e extends A{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),r=n.node(n.sharedDepth(this.to)),i=new l(M(t.content,(e,t)=>!e.isAtom||!t.type.allowsMarkType(this.mark.type)?e:e.mark(this.mark.addToSet(e.marks)),r),t.openStart,t.openEnd);return j.fromReplace(e,this.from,this.to,i)}invert(){return new P(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`addMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for AddMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};A.jsonID(`addMark`,N);var P=class e extends A{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new l(M(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return j.fromReplace(e,this.from,this.to,n)}invert(){return new N(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`removeMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for RemoveMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};A.jsonID(`removeMark`,P);var F=class e extends A{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return j.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return j.fromReplace(e,this.pos,this.pos+1,new l(r.from(n),0,+!t.isLeaf))}invert(t){let n=t.nodeAt(this.pos);if(n){let t=this.mark.addToSet(n.marks);if(t.length==n.marks.length){for(let r=0;r<n.marks.length;r++)if(!n.marks[r].isInSet(t))return new e(this.pos,n.marks[r]);return new e(this.pos,this.mark)}}return new I(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`addNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for AddNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};A.jsonID(`addNodeMark`,F);var I=class e extends A{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return j.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return j.fromReplace(e,this.pos,this.pos+1,new l(r.from(n),0,+!t.isLeaf))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new F(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`removeNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for RemoveNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};A.jsonID(`removeNodeMark`,I);var L=class e extends A{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&z(e,this.from,this.to)?j.fail(`Structure replace would overwrite content`):j.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new O([this.from,this.to-this.from,this.slice.size])}invert(t){return new e(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let n=t.mapResult(this.to,-1),r=this.from==this.to&&e.MAP_BIAS<0?n:t.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new e(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(t){if(!(t instanceof e)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let n=this.slice.size+t.slice.size==0?l.empty:new l(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new e(this.from,this.to+(t.to-t.from),n,this.structure)}else if(t.to==this.from&&!this.slice.openStart&&!t.slice.openEnd){let n=this.slice.size+t.slice.size==0?l.empty:new l(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new e(t.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:`replace`,from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for ReplaceStep.fromJSON`);return new e(n.from,n.to,l.fromJSON(t,n.slice),!!n.structure)}};L.MAP_BIAS=1,A.jsonID(`replace`,L);var R=class e extends A{constructor(e,t,n,r,i,a,o=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=i,this.insert=a,this.structure=o}apply(e){if(this.structure&&(z(e,this.from,this.gapFrom)||z(e,this.gapTo,this.to)))return j.fail(`Structure gap-replace would overwrite content`);let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return j.fail(`Gap is not a flat range`);let n=this.slice.insertAt(this.insert,t.content);return n?j.fromReplace(e,this.from,this.to,n):j.fail(`Content does not fit in gap`)}getMap(){return new O([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let n=this.gapTo-this.gapFrom;return new e(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:t.map(this.gapFrom,-1),a=this.to==this.gapTo?r.pos:t.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||a>r.pos?null:new e(n.pos,r.pos,i,a,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(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`||typeof n.gapFrom!=`number`||typeof n.gapTo!=`number`||typeof n.insert!=`number`)throw RangeError(`Invalid input for ReplaceAroundStep.fromJSON`);return new e(n.from,n.to,n.gapFrom,n.gapTo,l.fromJSON(t,n.slice),n.insert,!!n.structure)}};A.jsonID(`replaceAround`,R);function z(e,t,n){let r=e.resolve(t),i=n-t,a=r.depth;for(;i>0&&a>0&&r.indexAfter(a)==r.node(a).childCount;)a--,i--;if(i>0){let e=r.node(a).maybeChild(r.indexAfter(a));for(;i>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,i--}}return!1}function st(e,t,n,r){let i=[],a=[],o,s;e.doc.nodesBetween(t,n,(e,c,l)=>{if(!e.isInline)return;let u=e.marks;if(!r.isInSet(u)&&l.type.allowsMarkType(r.type)){let l=Math.max(c,t),d=Math.min(c+e.nodeSize,n),f=r.addToSet(u);for(let e=0;e<u.length;e++)u[e].isInSet(f)||(o&&o.to==l&&o.mark.eq(u[e])?o.to=d:i.push(o=new P(l,d,u[e])));s&&s.to==l?s.to=d:a.push(s=new N(l,d,r))}}),i.forEach(t=>e.step(t)),a.forEach(t=>e.step(t))}function ct(e,t,n,r){let i=[],a=0;e.doc.nodesBetween(t,n,(e,o)=>{if(!e.isInline)return;a++;let s=null;if(r instanceof Ae){let t=e.marks,n;for(;n=r.isInSet(t);)(s||=[]).push(n),t=n.removeFromSet(t)}else r?r.isInSet(e.marks)&&(s=[r]):s=e.marks;if(s&&s.length){let r=Math.min(o+e.nodeSize,n);for(let e=0;e<s.length;e++){let n=s[e],c;for(let e=0;e<i.length;e++){let t=i[e];t.step==a-1&&n.eq(i[e].style)&&(c=t)}c?(c.to=r,c.step=a):i.push({style:n,from:Math.max(o,t),to:r,step:a})}}}),i.forEach(t=>e.step(new P(t.from,t.to,t.style)))}function B(e,t,n,i=n.contentMatch,a=!0){let o=e.doc.nodeAt(t),s=[],c=t+1;for(let t=0;t<o.childCount;t++){let u=o.child(t),d=c+u.nodeSize,f=i.matchType(u.type);if(!f)s.push(new L(c,d,l.empty));else{i=f;for(let t=0;t<u.marks.length;t++)n.allowsMarkType(u.marks[t].type)||e.step(new P(c,d,u.marks[t]));if(a&&u.isText&&n.whitespace!=`pre`){let e,t=/\r?\n|\r/g,i;for(;e=t.exec(u.text);)i||=new l(r.from(n.schema.text(` `,n.allowedMarks(u.marks))),0,0),s.push(new L(c+e.index,c+e.index+e[0].length,i))}}c=d}if(!i.validEnd){let t=i.fillBefore(r.empty,!0);e.replace(c,c,new l(t,0,0))}for(let t=s.length-1;t>=0;t--)e.step(s[t])}function lt(e,t,n){return(t==0||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function ut(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,r=0,i=0;;--n){let a=e.$from.node(n),o=e.$from.index(n)+r,s=e.$to.indexAfter(n)-i;if(n<e.depth&&a.canReplace(o,s,t))return n;if(n==0||a.type.spec.isolating||!lt(a,o,s))break;o&&(r=1),s<a.childCount&&(i=1)}return null}function dt(e,t,n){let{$from:i,$to:a,depth:o}=t,s=i.before(o+1),c=a.after(o+1),u=s,d=c,f=r.empty,p=0;for(let e=o,t=!1;e>n;e--)t||i.index(e)>0?(t=!0,f=r.from(i.node(e).copy(f)),p++):u--;let m=r.empty,h=0;for(let e=o,t=!1;e>n;e--)t||a.after(e+1)<a.end(e)?(t=!0,m=r.from(a.node(e).copy(m)),h++):d++;e.step(new R(u,d,s,c,new l(f.append(m),p,h),f.size-p,!0))}function ft(e,t,n=null,r=e){let i=mt(e,t),a=i&&ht(r,t);return a?i.map(pt).concat({type:t,attrs:n}).concat(a.map(pt)):null}function pt(e){return{type:e,attrs:null}}function mt(e,t){let{parent:n,startIndex:r,endIndex:i}=e,a=n.contentMatchAt(r).findWrapping(t);if(!a)return null;let o=a.length?a[0]:t;return n.canReplaceWith(r,i,o)?a:null}function ht(e,t){let{parent:n,startIndex:r,endIndex:i}=e,a=n.child(r),o=t.contentMatch.findWrapping(a.type);if(!o)return null;let s=(o.length?o[o.length-1]:t).contentMatch;for(let e=r;s&&e<i;e++)s=s.matchType(n.child(e).type);return!s||!s.validEnd?null:o}function gt(e,t,n){let i=r.empty;for(let e=n.length-1;e>=0;e--){if(i.size){let t=n[e].type.contentMatch.matchFragment(i);if(!t||!t.validEnd)throw RangeError(`Wrapper type given to Transform.wrap does not form valid content of its parent wrapper`)}i=r.from(n[e].type.create(n[e].attrs,i))}let a=t.start,o=t.end;e.step(new R(a,o,a,o,new l(i,0,0),n.length,!0))}function _t(e,t,n,i,a){if(!i.isTextblock)throw RangeError(`Type given to setBlockType should be a textblock`);let o=e.steps.length;e.doc.nodesBetween(t,n,(t,n)=>{let s=typeof a==`function`?a(t):a;if(t.isTextblock&&!t.hasMarkup(i,s)&&bt(e.doc,e.mapping.slice(o).map(n),i)){let a=null;if(i.schema.linebreakReplacement){let e=i.whitespace==`pre`,t=!!i.contentMatch.matchType(i.schema.linebreakReplacement);e&&!t?a=!1:!e&&t&&(a=!0)}a===!1&&yt(e,t,n,o),B(e,e.mapping.slice(o).map(n,1),i,void 0,a===null);let c=e.mapping.slice(o),u=c.map(n,1),d=c.map(n+t.nodeSize,1);return e.step(new R(u,d,u+1,d-1,new l(r.from(i.create(s,null,t.marks)),0,0),1,!0)),a===!0&&vt(e,t,n,o),!1}})}function vt(e,t,n,r){t.forEach((i,a)=>{if(i.isText){let o,s=/\r?\n|\r/g;for(;o=s.exec(i.text);){let i=e.mapping.slice(r).map(n+1+a+o.index);e.replaceWith(i,i+1,t.type.schema.linebreakReplacement.create())}}})}function yt(e,t,n,r){t.forEach((i,a)=>{if(i.type==i.type.schema.linebreakReplacement){let i=e.mapping.slice(r).map(n+1+a);e.replaceWith(i,i+1,t.type.schema.text(`
|
|
5
|
+
`))}})}function bt(e,t,n){let r=e.resolve(t),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function xt(e,t,n,i,a){let o=e.doc.nodeAt(t);if(!o)throw RangeError(`No node at given position`);n||=o.type;let s=n.create(i,null,a||o.marks);if(o.isLeaf)return e.replaceWith(t,t+o.nodeSize,s);if(!n.validContent(o.content))throw RangeError(`Invalid content for node type `+n.name);e.step(new R(t,t+o.nodeSize,t+1,t+o.nodeSize-1,new l(r.from(s),0,0),1,!0))}function St(e,t,n=1,r){let i=e.resolve(t),a=i.depth-n,o=r&&r[r.length-1]||i.parent;if(a<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let e=i.depth-1,t=n-2;e>a;e--,t--){let n=i.node(e),a=i.index(e);if(n.type.spec.isolating)return!1;let o=n.content.cutByIndex(a,n.childCount),s=r&&r[t+1];s&&(o=o.replaceChild(0,s.type.create(s.attrs)));let c=r&&r[t]||n;if(!n.canReplace(a+1,n.childCount)||!c.type.validContent(o))return!1}let s=i.indexAfter(a),c=r&&r[0];return i.node(a).canReplaceWith(s,s,c?c.type:i.node(a+1).type)}function Ct(e,t,n=1,i){let a=e.doc.resolve(t),o=r.empty,s=r.empty;for(let e=a.depth,t=a.depth-n,c=n-1;e>t;e--,c--){o=r.from(a.node(e).copy(o));let t=i&&i[c];s=r.from(t?t.type.create(t.attrs,s):a.node(e).copy(s))}e.step(new L(t,t,new l(o.append(s),n,n),!0))}function wt(e,t){let n=e.resolve(t),r=n.index();return Et(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function Tt(e,t){t.content.size||e.type.compatibleContent(t.type);let n=e.contentMatchAt(e.childCount),{linebreakReplacement:r}=e.type.schema;for(let i=0;i<t.childCount;i++){let a=t.child(i),o=a.type==r?e.type.schema.nodes.text:a.type;if(n=n.matchType(o),!n||!e.type.allowsMarks(a.marks))return!1}return n.validEnd}function Et(e,t){return!!(e&&t&&!e.isLeaf&&Tt(e,t))}function Dt(e,t,n=-1){let r=e.resolve(t);for(let e=r.depth;;e--){let i,a,o=r.index(e);if(e==r.depth?(i=r.nodeBefore,a=r.nodeAfter):n>0?(i=r.node(e+1),o++,a=r.node(e).maybeChild(o)):(i=r.node(e).maybeChild(o-1),a=r.node(e+1)),i&&!i.isTextblock&&Et(i,a)&&r.node(e).canReplace(o,o+1))return t;if(e==0)break;t=n<0?r.before(e):r.after(e)}}function Ot(e,t,n){let r=null,{linebreakReplacement:i}=e.doc.type.schema,a=e.doc.resolve(t-n),o=a.node().type;if(i&&o.inlineContent){let e=o.whitespace==`pre`,t=!!o.contentMatch.matchType(i);e&&!t?r=!1:!e&&t&&(r=!0)}let s=e.steps.length;if(r===!1){let r=e.doc.resolve(t+n);yt(e,r.node(),r.before(),s)}o.inlineContent&&B(e,t+n-1,o,a.node().contentMatchAt(a.index()),r==null);let c=e.mapping.slice(s),u=c.map(t-n);if(e.step(new L(u,c.map(t+n,-1),l.empty,!0)),r===!0){let t=e.doc.resolve(u);vt(e,t.node(),t.before(),e.steps.length)}return e}function kt(e,t,n){let r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(r.parentOffset==0)for(let e=r.depth-1;e>=0;e--){let t=r.index(e);if(r.node(e).canReplaceWith(t,t,n))return r.before(e+1);if(t>0)return null}if(r.parentOffset==r.parent.content.size)for(let e=r.depth-1;e>=0;e--){let t=r.indexAfter(e);if(r.node(e).canReplaceWith(t,t,n))return r.after(e+1);if(t<r.node(e).childCount)return null}return null}function At(e,t,n){let r=e.resolve(t);if(!n.content.size)return t;let i=n.content;for(let e=0;e<n.openStart;e++)i=i.firstChild.content;for(let e=1;e<=(n.openStart==0&&n.size?2:1);e++)for(let t=r.depth;t>=0;t--){let n=t==r.depth?0:r.pos<=(r.start(t+1)+r.end(t+1))/2?-1:1,a=r.index(t)+ +(n>0),o=r.node(t),s=!1;if(e==1)s=o.canReplace(a,a,i);else{let e=o.contentMatchAt(a).findWrapping(i.firstChild.type);s=e&&o.canReplaceWith(a,a,e[0])}if(s)return n==0?r.pos:n<0?r.before(t+1):r.after(t+1)}return null}function jt(e,t,n=t,r=l.empty){if(t==n&&!r.size)return null;let i=e.resolve(t),a=e.resolve(n);return Mt(i,a,r)?new L(t,n,r):new Nt(i,a,r).fit()}function Mt(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}var Nt=class{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=r.empty;for(let t=0;t<=e.depth;t++){let n=e.node(t);this.frontier.push({type:n.type,match:n.contentMatchAt(e.indexAfter(t))})}for(let t=e.depth;t>0;t--)this.placed=r.from(e.node(t).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,r=this.close(e<0?this.$to:n.doc.resolve(e));if(!r)return null;let i=this.placed,a=n.depth,o=r.depth;for(;a&&o&&i.childCount==1;)i=i.firstChild.content,a--,o--;let s=new l(i,a,o);return e>-1?new R(n.pos,e,this.$to.pos,this.$to.end(),s,t):s.size||n.pos!=this.$to.pos?new L(n.pos,r.pos,s):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,r=this.unplaced.openEnd;n<e;n++){let i=t.firstChild;if(t.childCount>1&&(r=0),i.type.spec.isolating&&r<=n){e=n;break}t=i.content}for(let t=1;t<=2;t++)for(let n=t==1?e:this.unplaced.openStart;n>=0;n--){let e,i=null;n?(i=U(this.unplaced.content,n-1).firstChild,e=i.content):e=this.unplaced.content;let a=e.firstChild;for(let e=this.depth;e>=0;e--){let{type:o,match:s}=this.frontier[e],c,l=null;if(t==1&&(a?s.matchType(a.type)||(l=s.fillBefore(r.from(a),!1)):i&&o.compatibleContent(i.type)))return{sliceDepth:n,frontierDepth:e,parent:i,inject:l};if(t==2&&a&&(c=s.findWrapping(a.type)))return{sliceDepth:n,frontierDepth:e,parent:i,wrap:c};if(i&&s.matchType(i.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=U(e,t);return!r.childCount||r.firstChild.isLeaf?!1:(this.unplaced=new l(e,t+1,Math.max(n,r.size+t>=e.size-n?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=U(e,t);if(r.childCount<=1&&t>0){let i=e.size-t<=t+r.size;this.unplaced=new l(V(e,t-1,1),t-1,i?t-1:n)}else this.unplaced=new l(V(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:i,wrap:a}){for(;this.depth>t;)this.closeFrontierNode();if(a)for(let e=0;e<a.length;e++)this.openFrontierNode(a[e]);let o=this.unplaced,s=n?n.content:o.content,c=o.openStart-e,u=0,d=[],{match:f,type:p}=this.frontier[t];if(i){for(let e=0;e<i.childCount;e++)d.push(i.child(e));f=f.matchFragment(i)}let m=s.size+e-(o.content.size-o.openEnd);for(;u<s.childCount;){let e=s.child(u),t=f.matchType(e.type);if(!t)break;u++,(u>1||c==0||e.content.size)&&(f=t,d.push(Pt(e.mark(p.allowedMarks(e.marks)),u==1?c:0,u==s.childCount?m:-1)))}let h=u==s.childCount;h||(m=-1),this.placed=H(this.placed,t,r.from(d)),this.frontier[t].match=f,h&&m<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let e=0,t=s;e<m;e++){let e=t.lastChild;this.frontier.push({type:e.type,match:e.contentMatchAt(e.childCount)}),t=e.content}this.unplaced=h?e==0?l.empty:new l(V(o.content,e-1,1),e-1,m<0?o.openEnd:e-1):new l(V(o.content,e,u),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!W(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:n}=this.$to,r=this.$to.after(n);for(;n>1&&r==this.$to.end(--n);)++r;return r}findCloseLevel(e){scan:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:r}=this.frontier[t],i=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),a=W(e,t,r,n,i);if(a){for(let n=t-1;n>=0;n--){let{match:t,type:r}=this.frontier[n],i=W(e,n,r,t,!0);if(!i||i.childCount)continue scan}return{depth:t,fit:a,move:i?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=H(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let t=e.node(n),r=t.type.contentMatch.fillBefore(t.content,!0,e.index(n));this.openFrontierNode(t.type,t.attrs,r)}return e}openFrontierNode(e,t=null,n){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=H(this.placed,this.depth,r.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(r.empty,!0);e.childCount&&(this.placed=H(this.placed,this.frontier.length,e))}};function V(e,t,n){return t==0?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(V(e.firstChild.content,t-1,n)))}function H(e,t,n){return t==0?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(H(e.lastChild.content,t-1,n)))}function U(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function Pt(e,t,n){if(t<=0)return e;let i=e.content;return t>1&&(i=i.replaceChild(0,Pt(i.firstChild,t-1,i.childCount==1?n-1:0))),t>0&&(i=e.type.contentMatch.fillBefore(i).append(i),n<=0&&(i=i.append(e.type.contentMatch.matchFragment(i).fillBefore(r.empty,!0)))),e.copy(i)}function W(e,t,n,r,i){let a=e.node(t),o=i?e.indexAfter(t):e.index(t);if(o==a.childCount&&!n.compatibleContent(a.type))return null;let s=r.fillBefore(a.content,!0,o);return s&&!Ft(n,a.content,o)?s:null}function Ft(e,t,n){for(let r=n;r<t.childCount;r++)if(!e.allowsMarks(t.child(r).marks))return!0;return!1}function It(e){return e.spec.defining||e.spec.definingForContent}function Lt(e,t,n,r){if(!r.size)return e.deleteRange(t,n);let i=e.doc.resolve(t),a=e.doc.resolve(n);if(Mt(i,a,r))return e.step(new L(t,n,r));let o=Vt(i,a);o[o.length-1]==0&&o.pop();let s=-(i.depth+1);o.unshift(s);for(let e=i.depth,t=i.pos-1;e>0;e--,t--){let n=i.node(e).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;o.indexOf(e)>-1?s=e:i.before(e)==t&&o.splice(1,0,-e)}let c=o.indexOf(s),u=[],d=r.openStart;for(let e=r.content,t=0;;t++){let n=e.firstChild;if(u.push(n),t==r.openStart)break;e=n.content}for(let e=d-1;e>=0;e--){let t=u[e],n=It(t.type);if(n&&!t.sameMarkup(i.node(Math.abs(s)-1)))d=e;else if(n||!t.type.isTextblock)break}for(let t=r.openStart;t>=0;t--){let s=(t+d+1)%(r.openStart+1),f=u[s];if(f)for(let t=0;t<o.length;t++){let u=o[(t+c)%o.length],d=!0;u<0&&(d=!1,u=-u);let p=i.node(u-1),m=i.index(u-1);if(p.canReplaceWith(m,m,f.type,f.marks))return e.replace(i.before(u),d?a.after(u):n,new l(Rt(r.content,0,r.openStart,s),s,r.openEnd))}}let f=e.steps.length;for(let s=o.length-1;s>=0&&(e.replace(t,n,r),!(e.steps.length>f));s--){let e=o[s];e<0||(t=i.before(e),n=a.after(e))}}function Rt(e,t,n,i,a){if(t<n){let r=e.firstChild;e=e.replaceChild(0,r.copy(Rt(r.content,t+1,n,i,r)))}if(t>i){let t=a.contentMatchAt(0),n=t.fillBefore(e).append(e);e=n.append(t.matchFragment(n).fillBefore(r.empty,!0))}return e}function zt(e,t,n,i){if(!i.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let r=kt(e.doc,t,i.type);r!=null&&(t=n=r)}e.replaceRange(t,n,new l(r.from(i),0,0))}function Bt(e,t,n){let r=e.doc.resolve(t),i=e.doc.resolve(n);if(r.parent.isTextblock&&i.parent.isTextblock&&r.start()!=i.start()&&r.parentOffset==0&&i.parentOffset==0){let a=r.sharedDepth(n),o=!1;for(let e=r.depth;e>a;e--)r.node(e).type.spec.isolating&&(o=!0);for(let e=i.depth;e>a;e--)i.node(e).type.spec.isolating&&(o=!0);if(!o){for(let e=r.depth;e>0&&t==r.start(e);e--)t=r.before(e);for(let e=i.depth;e>0&&n==i.start(e);e--)n=i.before(e);r=e.doc.resolve(t),i=e.doc.resolve(n)}}let a=Vt(r,i);for(let t=0;t<a.length;t++){let n=a[t],o=t==a.length-1;if(o&&n==0||r.node(n).type.contentMatch.validEnd)return e.delete(r.start(n),i.end(n));if(n>0&&(o||r.node(n-1).canReplace(r.index(n-1),i.indexAfter(n-1))))return e.delete(r.before(n),i.after(n))}for(let a=1;a<=r.depth&&a<=i.depth;a++)if(t-r.start(a)==r.depth-a&&n>r.end(a)&&i.end(a)-n!=i.depth-a&&r.start(a-1)==i.start(a-1)&&r.node(a-1).canReplace(r.index(a-1),i.index(a-1)))return e.delete(r.before(a),n);e.delete(t,n)}function Vt(e,t){let n=[],r=Math.min(e.depth,t.depth);for(let i=r;i>=0;i--){let r=e.start(i);if(r<e.pos-(e.depth-i)||t.end(i)>t.pos+(t.depth-i)||e.node(i).type.spec.isolating||t.node(i).type.spec.isolating)break;(r==t.start(i)||i==e.depth&&i==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&i&&t.start(i-1)==r-1)&&n.push(i)}return n}var Ht=class e extends A{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return j.fail(`No node at attribute step's position`);let n=Object.create(null);for(let e in t.attrs)n[e]=t.attrs[e];n[this.attr]=this.value;let i=t.type.create(n,null,t.marks);return j.fromReplace(e,this.pos,this.pos+1,new l(r.from(i),0,+!t.isLeaf))}getMap(){return O.empty}invert(t){return new e(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.attr,this.value)}toJSON(){return{stepType:`attr`,pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.pos!=`number`||typeof n.attr!=`string`)throw RangeError(`Invalid input for AttrStep.fromJSON`);return new e(n.pos,n.attr,n.value)}};A.jsonID(`attr`,Ht);var Ut=class e extends A{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let n in e.attrs)t[n]=e.attrs[n];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return j.ok(n)}getMap(){return O.empty}invert(t){return new e(this.attr,t.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:`docAttr`,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.attr!=`string`)throw RangeError(`Invalid input for DocAttrStep.fromJSON`);return new e(n.attr,n.value)}};A.jsonID(`docAttr`,Ut);var G=class extends Error{};G=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},G.prototype=Object.create(Error.prototype),G.prototype.constructor=G,G.prototype.name=`TransformError`;var Wt=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new ot}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new G(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let n=0;n<this.mapping.maps.length;n++){let r=this.mapping.maps[n];n&&(e=r.map(e,1),t=r.map(t,-1)),r.forEach((n,r,i,a)=>{e=Math.min(e,i),t=Math.max(t,a)})}return e==1e9?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,n=l.empty){let r=jt(this.doc,e,t,n);return r&&this.step(r),this}replaceWith(e,t,n){return this.replace(e,t,new l(r.from(n),0,0))}delete(e,t){return this.replace(e,t,l.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return Lt(this,e,t,n),this}replaceRangeWith(e,t,n){return zt(this,e,t,n),this}deleteRange(e,t){return Bt(this,e,t),this}lift(e,t){return dt(this,e,t),this}join(e,t=1){return Ot(this,e,t),this}wrap(e,t){return gt(this,e,t),this}setBlockType(e,t=e,n,r=null){return _t(this,e,t,n,r),this}setNodeMarkup(e,t,n=null,r){return xt(this,e,t,n,r),this}setNodeAttribute(e,t,n){return this.step(new Ht(e,t,n)),this}setDocAttribute(e,t){return this.step(new Ut(e,t)),this}addNodeMark(e,t){return this.step(new F(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw RangeError(`No node at position `+e);if(t instanceof s)t.isInSet(n.marks)&&this.step(new I(e,t));else{let r=n.marks,i,a=[];for(;i=t.isInSet(r);)a.push(new I(e,i)),r=i.removeFromSet(r);for(let e=a.length-1;e>=0;e--)this.step(a[e])}return this}split(e,t=1,n){return Ct(this,e,t,n),this}addMark(e,t,n){return st(this,e,t,n),this}removeMark(e,t,n){return ct(this,e,t,n),this}clearIncompatible(e,t,n){return B(this,e,t,n),this}},K=Object.create(null),q=class{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new Gt(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=l.empty){let n=t.content.lastChild,r=null;for(let e=0;e<t.openEnd;e++)r=n,n=n.lastChild;let i=e.steps.length,a=this.ranges;for(let o=0;o<a.length;o++){let{$from:s,$to:c}=a[o],u=e.mapping.slice(i);e.replaceRange(u.map(s.pos),u.map(c.pos),o?l.empty:t),o==0&&Zt(e,i,(n?n.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,r=this.ranges;for(let i=0;i<r.length;i++){let{$from:a,$to:o}=r[i],s=e.mapping.slice(n),c=s.map(a.pos),l=s.map(o.pos);i?e.deleteRange(c,l):(e.replaceRangeWith(c,l,t),Zt(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let r=e.parent.inlineContent?new J(e):Z(e.node(0),e.parent,e.pos,e.index(),t,n);if(r)return r;for(let r=e.depth-1;r>=0;r--){let i=t<0?Z(e.node(0),e.node(r),e.before(r+1),e.index(r),t,n):Z(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,t,n);if(i)return i}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new X(e.node(0))}static atStart(e){return Z(e,e,0,0,1)||new X(e)}static atEnd(e){return Z(e,e,e.content.size,e.childCount,-1)||new X(e)}static fromJSON(e,t){if(!t||!t.type)throw RangeError(`Invalid input for Selection.fromJSON`);let n=K[t.type];if(!n)throw RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in K)throw RangeError(`Duplicate use of selection JSON ID `+e);return K[e]=t,t.prototype.jsonID=e,t}getBookmark(){return J.between(this.$anchor,this.$head).getBookmark()}};q.prototype.visible=!0;var Gt=class{constructor(e,t){this.$from=e,this.$to=t}},Kt=!1;function qt(e){!Kt&&!e.parent.inlineContent&&(Kt=!0,console.warn(`TextSelection endpoint not pointing into a node with inline content (`+e.parent.type.name+`)`))}var J=class e extends q{constructor(e,t=e){qt(e),qt(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,n){let r=t.resolve(n.map(this.head));if(!r.parent.inlineContent)return q.near(r);let i=t.resolve(n.map(this.anchor));return new e(i.parent.inlineContent?i:r,r)}replace(e,t=l.empty){if(super.replace(e,t),t==l.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(t){return t instanceof e&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new Jt(this.anchor,this.head)}toJSON(){return{type:`text`,anchor:this.anchor,head:this.head}}static fromJSON(t,n){if(typeof n.anchor!=`number`||typeof n.head!=`number`)throw RangeError(`Invalid input for TextSelection.fromJSON`);return new e(t.resolve(n.anchor),t.resolve(n.head))}static create(e,t,n=t){let r=e.resolve(t);return new this(r,n==t?r:e.resolve(n))}static between(t,n,r){let i=t.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let e=q.findFrom(n,r,!0)||q.findFrom(n,-r,!0);if(e)n=e.$head;else return q.near(n,r)}return t.parent.inlineContent||(i==0?t=n:(t=(q.findFrom(t,-r,!0)||q.findFrom(t,r,!0)).$anchor,t.pos<n.pos!=i<0&&(t=n))),new e(t,n)}};q.jsonID(`text`,J);var Jt=class e{constructor(e,t){this.anchor=e,this.head=t}map(t){return new e(t.map(this.anchor),t.map(this.head))}resolve(e){return J.between(e.resolve(this.anchor),e.resolve(this.head))}},Y=class e extends q{constructor(e){let t=e.nodeAfter,n=e.node(0).resolve(e.pos+t.nodeSize);super(e,n),this.node=t}map(t,n){let{deleted:r,pos:i}=n.mapResult(this.anchor),a=t.resolve(i);return r?q.near(a):new e(a)}content(){return new l(r.from(this.node),0,0)}eq(t){return t instanceof e&&t.anchor==this.anchor}toJSON(){return{type:`node`,anchor:this.anchor}}getBookmark(){return new Yt(this.anchor)}static fromJSON(t,n){if(typeof n.anchor!=`number`)throw RangeError(`Invalid input for NodeSelection.fromJSON`);return new e(t.resolve(n.anchor))}static create(t,n){return new e(t.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}};Y.prototype.visible=!1,q.jsonID(`node`,Y);var Yt=class e{constructor(e){this.anchor=e}map(t){let{deleted:n,pos:r}=t.mapResult(this.anchor);return n?new Jt(r,r):new e(r)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&Y.isSelectable(n)?new Y(t):q.near(t)}},X=class e extends q{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=l.empty){if(t==l.empty){e.delete(0,e.doc.content.size);let t=q.atStart(e.doc);t.eq(e.selection)||e.setSelection(t)}else super.replace(e,t)}toJSON(){return{type:`all`}}static fromJSON(t){return new e(t)}map(t){return new e(t)}eq(t){return t instanceof e}getBookmark(){return Xt}};q.jsonID(`all`,X);var Xt={map(){return this},resolve(e){return new X(e)}};function Z(e,t,n,r,i,a=!1){if(t.inlineContent)return J.create(e,n);for(let o=r-(i>0?0:1);i>0?o<t.childCount:o>=0;o+=i){let r=t.child(o);if(!r.isAtom){let t=Z(e,r,n+i,i<0?r.childCount:0,i,a);if(t)return t}else if(!a&&Y.isSelectable(r))return Y.create(e,n-(i<0?r.nodeSize:0));n+=r.nodeSize*i}return null}function Zt(e,t,n){let r=e.steps.length-1;if(r<t)return;let i=e.steps[r];if(!(i instanceof L||i instanceof R))return;let a=e.mapping.maps[r],o;a.forEach((e,t,n,r)=>{o??=r}),e.setSelection(q.near(e.doc.resolve(o),n))}var Qt=1,$t=2,en=4,tn=class extends Wt{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 RangeError(`Selection passed to setSelection must point at the current document`);return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|Qt)&-3,this.storedMarks=null,this}get selectionSet(){return(this.updated&Qt)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=$t,this}ensureMarks(e){return s.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&$t)>0}addStep(e,t){super.addStep(e,t),this.updated&=-3,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||s.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let r=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();{if(n??=t,!e)return this.deleteRange(t,n);let i=this.storedMarks;if(!i){let e=this.doc.resolve(t);i=n==t?e.marks():e.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,r.text(e,i)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(q.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|=en,this}get scrolledIntoView(){return(this.updated&en)>0}};function nn(e,t){return!t||!e?e:e.bind(t)}var Q=class{constructor(e,t,n){this.name=e,this.init=nn(t.init,n),this.apply=nn(t.apply,n)}},rn=[new Q(`doc`,{init(e){return e.doc||e.schema.topNodeType.createAndFill()},apply(e){return e.doc}}),new Q(`selection`,{init(e,t){return e.selection||q.atStart(t.doc)},apply(e){return e.selection}}),new Q(`storedMarks`,{init(e){return e.storedMarks||null},apply(e,t,n,r){return r.selection.$cursor?e.storedMarks:null}}),new Q(`scrollToSelection`,{init(){return 0},apply(e,t){return e.scrolledIntoView?t+1:t}})],an=class{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=rn.slice(),t&&t.forEach(e=>{if(this.pluginsByKey[e.key])throw RangeError(`Adding different instances of a keyed plugin (`+e.key+`)`);this.plugins.push(e),this.pluginsByKey[e.key]=e,e.spec.state&&this.fields.push(new Q(e.key,e.spec.state,e))})}},on=class e{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 n=0;n<this.config.plugins.length;n++)if(n!=t){let t=this.config.plugins[n];if(t.spec.filterTransaction&&!t.spec.filterTransaction.call(t,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],n=this.applyInner(e),r=null;for(;;){let i=!1;for(let a=0;a<this.config.plugins.length;a++){let o=this.config.plugins[a];if(o.spec.appendTransaction){let s=r?r[a].n:0,c=r?r[a].state:this,l=s<t.length&&o.spec.appendTransaction.call(o,s?t.slice(s):t,c,n);if(l&&n.filterTransaction(l,a)){if(l.setMeta(`appendedTransaction`,e),!r){r=[];for(let e=0;e<this.config.plugins.length;e++)r.push(e<a?{state:n,n:t.length}:{state:this,n:0})}t.push(l),n=n.applyInner(l),i=!0}r&&(r[a]={state:n,n:t.length})}}if(!i)return{state:n,transactions:t}}}applyInner(t){if(!t.before.eq(this.doc))throw RangeError(`Applying a mismatched transaction`);let n=new e(this.config),r=this.config.fields;for(let e=0;e<r.length;e++){let i=r[e];n[i.name]=i.apply(t,this[i.name],this,n)}return n}get tr(){return new tn(this)}static create(t){let n=new an(t.doc?t.doc.type.schema:t.schema,t.plugins),r=new e(n);for(let e=0;e<n.fields.length;e++)r[n.fields[e].name]=n.fields[e].init(t,r);return r}reconfigure(t){let n=new an(this.schema,t.plugins),r=n.fields,i=new e(n);for(let e=0;e<r.length;e++){let n=r[e].name;i[n]=this.hasOwnProperty(n)?this[n]:r[e].init(t,i)}return i}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(e=>e.toJSON())),e&&typeof e==`object`)for(let n in e){if(n==`doc`||n==`selection`)throw RangeError("The JSON fields `doc` and `selection` are reserved");let r=e[n],i=r.spec.state;i&&i.toJSON&&(t[n]=i.toJSON.call(r,this[r.key]))}return t}static fromJSON(t,n,r){if(!n)throw RangeError(`Invalid input for EditorState.fromJSON`);if(!t.schema)throw RangeError(`Required config field 'schema' missing`);let i=new an(t.schema,t.plugins),a=new e(i);return i.fields.forEach(e=>{if(e.name==`doc`)a.doc=b.fromJSON(t.schema,n.doc);else if(e.name==`selection`)a.selection=q.fromJSON(a.doc,n.selection);else if(e.name==`storedMarks`)n.storedMarks&&(a.storedMarks=n.storedMarks.map(t.schema.markFromJSON));else{if(r)for(let i in r){let o=r[i],s=o.spec.state;if(o.key==e.name&&s&&s.fromJSON&&Object.prototype.hasOwnProperty.call(n,i)){a[e.name]=s.fromJSON.call(o,t,n[i],a);return}}a[e.name]=e.init(t,a)}}),a}};function sn(e,t,n){for(let r in e){let i=e[r];i instanceof Function?i=i.bind(t):r==`handleDOMEvents`&&(i=sn(i,t,{})),n[r]=i}return n}var cn=class{constructor(e){this.spec=e,this.props={},e.props&&sn(e.props,this,this.props),this.key=e.key?e.key.key:ln(`plugin`)}getState(e){return e[this.key]}},$=Object.create(null);function ln(e){return e in $?e+`$`+ ++$[e]:($[e]=0,e+`$`)}var un=class{constructor(e=`key`){this.key=ln(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}};Object.defineProperty(exports,"A",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"C",{enumerable:!0,get:function(){return Ke}}),Object.defineProperty(exports,"D",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(exports,"E",{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,"O",{enumerable:!0,get:function(){return De}}),Object.defineProperty(exports,"S",{enumerable:!0,get:function(){return Fe}}),Object.defineProperty(exports,"T",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return At}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return un}}),Object.defineProperty(exports,"b",{enumerable:!0,get:function(){return ut}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return J}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return ot}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return R}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return St}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return wt}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return cn}}),Object.defineProperty(exports,"k",{enumerable:!0,get:function(){return je}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return tn}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return Wt}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return on}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return q}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return L}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return Gt}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return X}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return N}}),Object.defineProperty(exports,"v",{enumerable:!0,get:function(){return ft}}),Object.defineProperty(exports,"w",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"x",{enumerable:!0,get:function(){return jt}}),Object.defineProperty(exports,"y",{enumerable:!0,get:function(){return Dt}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./lib-DzY83R_P.cjs"),t=require("./dist-DQnWlYyo.cjs");var n,r;if(typeof WeakMap<`u`){let e=new WeakMap;n=t=>e.get(t),r=(t,n)=>(e.set(t,n),n)}else{let e=[],t=0;n=t=>{for(let n=0;n<e.length;n+=2)if(e[n]==t)return e[n+1]},r=(n,r)=>(t==10&&(t=0),e[t++]=n,e[t++]=r)}var i=class{constructor(e,t,n,r){this.width=e,this.height=t,this.map=n,this.problems=r}findCell(e){for(let t=0;t<this.map.length;t++){let n=this.map[t];if(n!=e)continue;let r=t%this.width,i=t/this.width|0,a=r+1,o=i+1;for(let e=1;a<this.width&&this.map[t+e]==n;e++)a++;for(let e=1;o<this.height&&this.map[t+this.width*e]==n;e++)o++;return{left:r,top:i,right:a,bottom:o}}throw RangeError(`No cell with offset ${e} found`)}colCount(e){for(let t=0;t<this.map.length;t++)if(this.map[t]==e)return t%this.width;throw RangeError(`No cell with offset ${e} found`)}nextCell(e,t,n){let{left:r,right:i,top:a,bottom:o}=this.findCell(e);return t==`horiz`?(n<0?r==0:i==this.width)?null:this.map[a*this.width+(n<0?r-1:i)]:(n<0?a==0:o==this.height)?null:this.map[r+this.width*(n<0?a-1:o)]}rectBetween(e,t){let{left:n,right:r,top:i,bottom:a}=this.findCell(e),{left:o,right:s,top:c,bottom:l}=this.findCell(t);return{left:Math.min(n,o),top:Math.min(i,c),right:Math.max(r,s),bottom:Math.max(a,l)}}cellsInRect(e){let t=[],n={};for(let r=e.top;r<e.bottom;r++)for(let i=e.left;i<e.right;i++){let a=r*this.width+i,o=this.map[a];n[o]||(n[o]=!0,!(i==e.left&&i&&this.map[a-1]==o||r==e.top&&r&&this.map[a-this.width]==o)&&t.push(o))}return t}positionAt(e,t,n){for(let r=0,i=0;;r++){let a=i+n.child(r).nodeSize;if(r==e){let n=t+e*this.width,r=(e+1)*this.width;for(;n<r&&this.map[n]<i;)n++;return n==r?a-1:this.map[n]}i=a}}static get(e){return n(e)||r(e,a(e))}};function a(e){if(e.type.spec.tableRole!=`table`)throw RangeError(`Not a table node: `+e.type.name);let t=o(e),n=e.childCount,r=[],a=0,c=null,l=[];for(let e=0,i=t*n;e<i;e++)r[e]=0;for(let i=0,o=0;i<n;i++){let s=e.child(i);o++;for(let e=0;;e++){for(;a<r.length&&r[a]!=0;)a++;if(e==s.childCount)break;let u=s.child(e),{colspan:d,rowspan:f,colwidth:p}=u.attrs;for(let e=0;e<f;e++){if(e+i>=n){(c||=[]).push({type:`overlong_rowspan`,pos:o,n:f-e});break}let s=a+e*t;for(let e=0;e<d;e++){r[s+e]==0?r[s+e]=o:(c||=[]).push({type:`collision`,row:i,pos:o,n:d-e});let n=p&&p[e];if(n){let r=(s+e)%t*2,i=l[r];i==null||i!=n&&l[r+1]==1?(l[r]=n,l[r+1]=1):i==n&&l[r+1]++}}}a+=d,o+=u.nodeSize}let u=(i+1)*t,d=0;for(;a<u;)r[a++]==0&&d++;d&&(c||=[]).push({type:`missing`,row:i,n:d}),o++}(t===0||n===0)&&(c||=[]).push({type:`zero_sized`});let u=new i(t,n,r,c),d=!1;for(let e=0;!d&&e<l.length;e+=2)l[e]!=null&&l[e+1]<n&&(d=!0);return d&&s(u,l,e),u}function o(e){let t=-1,n=!1;for(let r=0;r<e.childCount;r++){let i=e.child(r),a=0;if(n)for(let t=0;t<r;t++){let n=e.child(t);for(let e=0;e<n.childCount;e++){let i=n.child(e);t+i.attrs.rowspan>r&&(a+=i.attrs.colspan)}}for(let e=0;e<i.childCount;e++){let t=i.child(e);a+=t.attrs.colspan,t.attrs.rowspan>1&&(n=!0)}t==-1?t=a:t!=a&&(t=Math.max(t,a))}return t}function s(e,t,n){e.problems||=[];let r={};for(let i=0;i<e.map.length;i++){let a=e.map[i];if(r[a])continue;r[a]=!0;let o=n.nodeAt(a);if(!o)throw RangeError(`No cell with offset ${a} found`);let s=null,l=o.attrs;for(let n=0;n<l.colspan;n++){let r=t[(i+n)%e.width*2];r!=null&&(!l.colwidth||l.colwidth[n]!=r)&&((s||=c(l))[n]=r)}s&&e.problems.unshift({type:`colwidth mismatch`,pos:a,colwidth:s})}}function c(e){if(e.colwidth)return e.colwidth.slice();let t=[];for(let n=0;n<e.colspan;n++)t.push(0);return t}function l(e,t){if(typeof e==`string`)return{};let n=e.getAttribute(`data-colwidth`),r=n&&/^\d+(,\d+)*$/.test(n)?n.split(`,`).map(e=>Number(e)):null,i=Number(e.getAttribute(`colspan`)||1),a={colspan:i,rowspan:Number(e.getAttribute(`rowspan`)||1),colwidth:r&&r.length==i?r:null};for(let n in t){let r=t[n].getFromDOM,i=r&&r(e);i!=null&&(a[n]=i)}return a}function u(e,t){let n={};e.attrs.colspan!=1&&(n.colspan=e.attrs.colspan),e.attrs.rowspan!=1&&(n.rowspan=e.attrs.rowspan),e.attrs.colwidth&&(n[`data-colwidth`]=e.attrs.colwidth.join(`,`));for(let r in t){let i=t[r].setDOMAttr;i&&i(e.attrs[r],n)}return n}function d(e){if(e!==null){if(!Array.isArray(e))throw TypeError(`colwidth must be null or an array`);for(let t of e)if(typeof t!=`number`)throw TypeError(`colwidth must be null or an array of numbers`)}}function f(e){let t=e.cellAttributes||{},n={colspan:{default:1,validate:`number`},rowspan:{default:1,validate:`number`},colwidth:{default:null,validate:d}};for(let e in t)n[e]={default:t[e].default,validate:t[e].validate};return{table:{content:`table_row+`,tableRole:`table`,isolating:!0,group:e.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:e.cellContent,attrs:n,tableRole:`cell`,isolating:!0,parseDOM:[{tag:`td`,getAttrs:e=>l(e,t)}],toDOM(e){return[`td`,u(e,t),0]}},table_header:{content:e.cellContent,attrs:n,tableRole:`header_cell`,isolating:!0,parseDOM:[{tag:`th`,getAttrs:e=>l(e,t)}],toDOM(e){return[`th`,u(e,t),0]}}}}function p(e){let t=e.cached.tableNodeTypes;if(!t){t=e.cached.tableNodeTypes={};for(let n in e.nodes){let r=e.nodes[n],i=r.spec.tableRole;i&&(t[i]=r)}}return t}var m=new t.a(`selectingCells`);function h(e){for(let t=e.depth-1;t>0;t--)if(e.node(t).type.spec.tableRole==`row`)return e.node(0).resolve(e.before(t+1));return null}function g(e){let t=e.selection.$head;for(let e=t.depth;e>0;e--)if(t.node(e).type.spec.tableRole==`row`)return!0;return!1}function _(e){let t=e.selection;if(`$anchorCell`in t&&t.$anchorCell)return t.$anchorCell.pos>t.$headCell.pos?t.$anchorCell:t.$headCell;if(`node`in t&&t.node&&t.node.type.spec.tableRole==`cell`)return t.$anchor;let n=h(t.$head)||ee(t.$head);if(n)return n;throw RangeError(`No cell found around position ${t.head}`)}function ee(e){for(let t=e.nodeAfter,n=e.pos;t;t=t.firstChild,n++){let r=t.type.spec.tableRole;if(r==`cell`||r==`header_cell`)return e.doc.resolve(n)}for(let t=e.nodeBefore,n=e.pos;t;t=t.lastChild,n--){let r=t.type.spec.tableRole;if(r==`cell`||r==`header_cell`)return e.doc.resolve(n-t.nodeSize)}}function v(e){return e.parent.type.spec.tableRole==`row`&&!!e.nodeAfter}function te(e){return e.node(0).resolve(e.pos+e.nodeAfter.nodeSize)}function y(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function b(e,t,n){let r=e.node(-1),a=i.get(r),o=e.start(-1),s=a.nextCell(e.pos-o,t,n);return s==null?null:e.node(0).resolve(o+s)}function x(e,t,n=1){let r={...e,colspan:e.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(t,n),r.colwidth.some(e=>e>0)||(r.colwidth=null)),r}function ne(e,t,n=1){let r={...e,colspan:e.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let e=0;e<n;e++)r.colwidth.splice(t,0,0)}return r}function re(e,t,n){let r=p(t.type.schema).header_cell;for(let i=0;i<e.height;i++)if(t.nodeAt(e.map[n+i*e.width]).type!=r)return!1;return!0}var S=class e extends t.o{constructor(e,n=e){let r=e.node(-1),a=i.get(r),o=e.start(-1),s=a.rectBetween(e.pos-o,n.pos-o),c=e.node(0),l=a.cellsInRect(s).filter(e=>e!=n.pos-o);l.unshift(n.pos-o);let u=l.map(e=>{let n=r.nodeAt(e);if(!n)throw RangeError(`No cell with offset ${e} found`);let i=o+e+1;return new t.s(c.resolve(i),c.resolve(i+n.content.size))});super(u[0].$from,u[0].$to,u),this.$anchorCell=e,this.$headCell=n}map(n,r){let i=n.resolve(r.map(this.$anchorCell.pos)),a=n.resolve(r.map(this.$headCell.pos));if(v(i)&&v(a)&&y(i,a)){let t=this.$anchorCell.node(-1)!=i.node(-1);return t&&this.isRowSelection()?e.rowSelection(i,a):t&&this.isColSelection()?e.colSelection(i,a):new e(i,a)}return t.c.between(i,a)}content(){let e=this.$anchorCell.node(-1),n=i.get(e),r=this.$anchorCell.start(-1),a=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),o={},s=[];for(let r=a.top;r<a.bottom;r++){let i=[];for(let t=r*n.width+a.left,s=a.left;s<a.right;s++,t++){let r=n.map[t];if(o[r])continue;o[r]=!0;let s=n.findCell(r),c=e.nodeAt(r);if(!c)throw RangeError(`No cell with offset ${r} found`);let l=a.left-s.left,u=s.right-a.right;if(l>0||u>0){let e=c.attrs;if(l>0&&(e=x(e,0,l)),u>0&&(e=x(e,e.colspan-u,u)),s.left<a.left){if(c=c.type.createAndFill(e),!c)throw RangeError(`Could not create cell with attrs ${JSON.stringify(e)}`)}else c=c.type.create(e,c.content)}if(s.top<a.top||s.bottom>a.bottom){let e={...c.attrs,rowspan:Math.min(s.bottom,a.bottom)-Math.max(s.top,a.top)};c=s.top<a.top?c.type.createAndFill(e):c.type.create(e,c.content)}i.push(c)}s.push(e.child(r).copy(t.w.from(i)))}let c=this.isColSelection()&&this.isRowSelection()?e:s;return new t.A(t.w.from(c),1,1)}replace(e,n=t.A.empty){let r=e.steps.length,i=this.ranges;for(let a=0;a<i.length;a++){let{$from:o,$to:s}=i[a],c=e.mapping.slice(r);e.replace(c.map(o.pos),c.map(s.pos),a?t.A.empty:n)}let a=t.o.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);a&&e.setSelection(a)}replaceWith(e,n){this.replace(e,new t.A(t.w.from(n),0,0))}forEachCell(e){let t=this.$anchorCell.node(-1),n=i.get(t),r=this.$anchorCell.start(-1),a=n.cellsInRect(n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r));for(let n=0;n<a.length;n++)e(t.nodeAt(a[n]),r+a[n])}isColSelection(){let e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;let n=e+this.$anchorCell.nodeAfter.attrs.rowspan,r=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(n,r)==this.$headCell.node(-1).childCount}static colSelection(t,n=t){let r=t.node(-1),a=i.get(r),o=t.start(-1),s=a.findCell(t.pos-o),c=a.findCell(n.pos-o),l=t.node(0);return s.top<=c.top?(s.top>0&&(t=l.resolve(o+a.map[s.left])),c.bottom<a.height&&(n=l.resolve(o+a.map[a.width*(a.height-1)+c.right-1]))):(c.top>0&&(n=l.resolve(o+a.map[c.left])),s.bottom<a.height&&(t=l.resolve(o+a.map[a.width*(a.height-1)+s.right-1]))),new e(t,n)}isRowSelection(){let e=this.$anchorCell.node(-1),t=i.get(e),n=this.$anchorCell.start(-1),r=t.colCount(this.$anchorCell.pos-n),a=t.colCount(this.$headCell.pos-n);if(Math.min(r,a)>0)return!1;let o=r+this.$anchorCell.nodeAfter.attrs.colspan,s=a+this.$headCell.nodeAfter.attrs.colspan;return Math.max(o,s)==t.width}eq(t){return t instanceof e&&t.$anchorCell.pos==this.$anchorCell.pos&&t.$headCell.pos==this.$headCell.pos}static rowSelection(t,n=t){let r=t.node(-1),a=i.get(r),o=t.start(-1),s=a.findCell(t.pos-o),c=a.findCell(n.pos-o),l=t.node(0);return s.left<=c.left?(s.left>0&&(t=l.resolve(o+a.map[s.top*a.width])),c.right<a.width&&(n=l.resolve(o+a.map[a.width*(c.top+1)-1]))):(c.left>0&&(n=l.resolve(o+a.map[c.top*a.width])),s.right<a.width&&(t=l.resolve(o+a.map[a.width*(s.top+1)-1]))),new e(t,n)}toJSON(){return{type:`cell`,anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(t,n){return new e(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,r=n){return new e(t.resolve(n),t.resolve(r))}getBookmark(){return new ie(this.$anchorCell.pos,this.$headCell.pos)}};S.prototype.visible=!1,t.o.jsonID(`cell`,S);var ie=class e{constructor(e,t){this.anchor=e,this.head=t}map(t){return new e(t.map(this.anchor),t.map(this.head))}resolve(e){let n=e.resolve(this.anchor),r=e.resolve(this.head);return n.parent.type.spec.tableRole==`row`&&r.parent.type.spec.tableRole==`row`&&n.index()<n.parent.childCount&&r.index()<r.parent.childCount&&y(n,r)?new S(n,r):t.o.near(r,1)}};function ae(t){if(!(t.selection instanceof S))return null;let n=[];return t.selection.forEachCell((t,r)=>{n.push(e.j.node(r,r+t.nodeSize,{class:`selectedCell`}))}),e.M.create(t.doc,n)}function oe({$from:e,$to:t}){if(e.pos==t.pos||e.pos<t.pos-6)return!1;let n=e.pos,r=t.pos,i=e.depth;for(;i>=0&&!(e.after(i+1)<e.end(i));i--,n++);for(let e=t.depth;e>=0&&!(t.before(e+1)>t.start(e));e--,r--);return n==r&&/row|table/.test(e.node(i).type.spec.tableRole)}function se({$from:e,$to:t}){let n,r;for(let t=e.depth;t>0;t--){let r=e.node(t);if(r.type.spec.tableRole===`cell`||r.type.spec.tableRole===`header_cell`){n=r;break}}for(let e=t.depth;e>0;e--){let n=t.node(e);if(n.type.spec.tableRole===`cell`||n.type.spec.tableRole===`header_cell`){r=n;break}}return n!==r&&t.parentOffset===0}function ce(e,n,r){let a=(n||e).selection,o=(n||e).doc,s,c;if(a instanceof t.r&&(c=a.node.type.spec.tableRole)){if(c==`cell`||c==`header_cell`)s=S.create(o,a.from);else if(c==`row`){let e=o.resolve(a.from+1);s=S.rowSelection(e,e)}else if(!r){let e=i.get(a.node),t=a.from+1,n=t+e.map[e.width*e.height-1];s=S.create(o,t+1,n)}}else a instanceof t.c&&oe(a)?s=t.c.create(o,a.from):a instanceof t.c&&se(a)&&(s=t.c.create(o,a.$from.start(),a.$from.end()));return s&&(n||=e.tr).setSelection(s),n}var le=new t.a(`fix-tables`);function C(e,t,n,r){let i=e.childCount,a=t.childCount;outer:for(let o=0,s=0;o<a;o++){let a=t.child(o);for(let t=s,r=Math.min(i,o+3);t<r;t++)if(e.child(t)==a){s=t+1,n+=a.nodeSize;continue outer}r(a,n),s<i&&e.child(s).sameMarkup(a)?C(e.child(s),a,n+1,r):a.nodesBetween(0,a.content.size,r,n+1),n+=a.nodeSize}}function ue(e,t){let n,r=(t,r)=>{t.type.spec.tableRole==`table`&&(n=de(e,t,r,n))};return t?t.doc!=e.doc&&C(t.doc,e.doc,0,r):e.doc.descendants(r),n}function de(e,t,n,r){let a=i.get(t);if(!a.problems)return r;r||=e.tr;let o=[];for(let e=0;e<a.height;e++)o.push(0);for(let e=0;e<a.problems.length;e++){let i=a.problems[e];if(i.type==`collision`){let e=t.nodeAt(i.pos);if(!e)continue;let a=e.attrs;for(let e=0;e<a.rowspan;e++)o[i.row+e]+=i.n;r.setNodeMarkup(r.mapping.map(n+1+i.pos),null,x(a,a.colspan-i.n,i.n))}else if(i.type==`missing`)o[i.row]+=i.n;else if(i.type==`overlong_rowspan`){let e=t.nodeAt(i.pos);if(!e)continue;r.setNodeMarkup(r.mapping.map(n+1+i.pos),null,{...e.attrs,rowspan:e.attrs.rowspan-i.n})}else if(i.type==`colwidth mismatch`){let e=t.nodeAt(i.pos);if(!e)continue;r.setNodeMarkup(r.mapping.map(n+1+i.pos),null,{...e.attrs,colwidth:i.colwidth})}else if(i.type==`zero_sized`){let e=r.mapping.map(n);r.delete(e,e+t.nodeSize)}}let s,c;for(let e=0;e<o.length;e++)o[e]&&(s??=e,c=e);for(let i=0,l=n+1;i<a.height;i++){let n=t.child(i),a=l+n.nodeSize,u=o[i];if(u>0){let t=`cell`;n.firstChild&&(t=n.firstChild.type.spec.tableRole);let o=[];for(let n=0;n<u;n++){let n=p(e.schema)[t].createAndFill();n&&o.push(n)}let d=(i==0||s==i-1)&&c==i?l+1:a-1;r.insert(r.mapping.map(d),o)}l=a}return r.setMeta(le,{fixTables:!0})}function w(e){let t=i.get(e),n=[],r=t.height,a=t.width;for(let i=0;i<r;i++){let r=[];for(let n=0;n<a;n++){let o=i*a+n,s=t.map[o];if(i>0){let e=o-a;if(s===t.map[e]){r.push(null);continue}}if(n>0){let e=o-1;if(s===t.map[e]){r.push(null);continue}}r.push(e.nodeAt(s))}n.push(r)}return n}function T(e,t){let n=[],r=i.get(e),a=r.height,o=r.width;for(let i=0;i<a;i++){let a=e.child(i),s=[];for(let n=0;n<o;n++){let a=t[i][n];if(!a)continue;let o=r.map[i*r.width+n],c=e.nodeAt(o);if(!c)continue;let l=c.type.createChecked(a.attrs,a.content,a.marks);s.push(l)}let c=a.type.createChecked(a.attrs,s,a.marks);n.push(c)}return e.type.createChecked(e.attrs,n,e.marks)}function E(e,t,n,r){let i=t[0]>n[0]?-1:1,a=e.splice(t[0],t.length),o=+(a.length%2==0),s;return s=r===-1&&i===1?n[0]-1:r===1&&i===-1?n[n.length-1]-o+1:i===-1?n[0]:n[n.length-1]-o,e.splice(s,0,...a),e}function D(e){return fe(e=>e.type.spec.tableRole===`table`,e)}function fe(e,t){for(let n=t.depth;n>=0;--n){let r=t.node(n);if(e(r))return{node:r,pos:n===0?0:t.before(n),start:t.start(n),depth:n}}return null}function O(e,t){let n=D(t.$from);if(!n)return;let r=i.get(n.node);if(!(e<0||e>r.width-1))return r.cellsInRect({left:e,right:e+1,top:0,bottom:r.height}).map(e=>{let t=n.node.nodeAt(e),r=e+n.start;return{pos:r,start:r+1,node:t,depth:n.depth+2}})}function k(e,t){let n=D(t.$from);if(!n)return;let r=i.get(n.node);if(!(e<0||e>r.height-1))return r.cellsInRect({left:0,right:r.width,top:e,bottom:e+1}).map(e=>{let t=n.node.nodeAt(e),r=e+n.start;return{pos:r,start:r+1,node:t,depth:n.depth+2}})}function A(e,t,n=t){let r=t,i=n;for(let n=t;n>=0;n--){let t=O(n,e.selection);t&&t.forEach(e=>{let t=e.node.attrs.colspan+n-1;t>=r&&(r=n),t>i&&(i=t)})}for(let n=t;n<=i;n++){let t=O(n,e.selection);t&&t.forEach(e=>{let t=e.node.attrs.colspan+n-1;e.node.attrs.colspan>1&&t>i&&(i=t)})}let a=[];for(let t=r;t<=i;t++){let n=O(t,e.selection);n&&n.length>0&&a.push(t)}r=a[0],i=a[a.length-1];let o=O(r,e.selection),s=k(0,e.selection);if(!o||!s)return;let c=e.doc.resolve(o[o.length-1].pos),l;for(let t=i;t>=r;t--){let n=O(t,e.selection);if(n&&n.length>0){for(let e=s.length-1;e>=0;e--)if(s[e].pos===n[0].pos){l=n[0];break}if(l)break}}if(l)return{$anchor:c,$head:e.doc.resolve(l.pos),indexes:a}}function j(e,t,n=t){let r=t,i=n;for(let n=t;n>=0;n--){let t=k(n,e.selection);t&&t.forEach(e=>{let t=e.node.attrs.rowspan+n-1;t>=r&&(r=n),t>i&&(i=t)})}for(let n=t;n<=i;n++){let t=k(n,e.selection);t&&t.forEach(e=>{let t=e.node.attrs.rowspan+n-1;e.node.attrs.rowspan>1&&t>i&&(i=t)})}let a=[];for(let t=r;t<=i;t++){let n=k(t,e.selection);n&&n.length>0&&a.push(t)}r=a[0],i=a[a.length-1];let o=k(r,e.selection),s=O(0,e.selection);if(!o||!s)return;let c=e.doc.resolve(o[o.length-1].pos),l;for(let t=i;t>=r;t--){let n=k(t,e.selection);if(n&&n.length>0){for(let e=s.length-1;e>=0;e--)if(s[e].pos===n[0].pos){l=n[0];break}if(l)break}}if(l)return{$anchor:c,$head:e.doc.resolve(l.pos),indexes:a}}function M(e){return e[0].map((t,n)=>e.map(e=>e[n]))}function pe(e){let{tr:t,originIndex:n,targetIndex:r,select:a,pos:o}=e,s=D(t.doc.resolve(o));if(!s)return!1;let c=A(t,n)?.indexes,l=A(t,r)?.indexes;if(!c||!l||c.includes(r))return!1;let u=me(s.node,c,l,0);if(t.replaceWith(s.pos,s.pos+s.node.nodeSize,u),!a)return!0;let d=i.get(u),f=s.start,p=r,m=d.positionAt(d.height-1,p,u),h=t.doc.resolve(f+m),g=d.positionAt(0,p,u),_=t.doc.resolve(f+g);return t.setSelection(S.colSelection(h,_)),!0}function me(e,t,n,r){let i=M(w(e));return i=E(i,t,n,r),i=M(i),T(e,i)}function he(e){let{tr:t,originIndex:n,targetIndex:r,select:a,pos:o}=e,s=D(t.doc.resolve(o));if(!s)return!1;let c=j(t,n)?.indexes,l=j(t,r)?.indexes;if(!c||!l||c.includes(r))return!1;let u=ge(s.node,c,l,0);if(t.replaceWith(s.pos,s.pos+s.node.nodeSize,u),!a)return!0;let d=i.get(u),f=s.start,p=r,m=d.positionAt(p,d.width-1,u),h=t.doc.resolve(f+m),g=d.positionAt(p,0,u),_=t.doc.resolve(f+g);return t.setSelection(S.rowSelection(h,_)),!0}function ge(e,t,n,r){let i=w(e);return i=E(i,t,n,r),T(e,i)}function N(e){let t=e.selection,n=_(e),r=n.node(-1),a=n.start(-1),o=i.get(r);return{...t instanceof S?o.rectBetween(t.$anchorCell.pos-a,t.$headCell.pos-a):o.findCell(n.pos-a),tableStart:a,map:o,table:r}}function P(e,{map:t,tableStart:n,table:r},i){let a=i>0?-1:0;re(t,r,i+a)&&(a=i==0||i==t.width?null:0);for(let o=0;o<t.height;o++){let s=o*t.width+i;if(i>0&&i<t.width&&t.map[s-1]==t.map[s]){let a=t.map[s],c=r.nodeAt(a);e.setNodeMarkup(e.mapping.map(n+a),null,ne(c.attrs,i-t.colCount(a))),o+=c.attrs.rowspan-1}else{let c=a==null?p(r.type.schema).cell:r.nodeAt(t.map[s+a]).type,l=t.positionAt(o,i,r);e.insert(e.mapping.map(n+l),c.createAndFill())}}return e}function _e(e,t){if(!g(e))return!1;if(t){let n=N(e);t(P(e.tr,n,n.left))}return!0}function ve(e,t){if(!g(e))return!1;if(t){let n=N(e);t(P(e.tr,n,n.right))}return!0}function ye(e,{map:t,table:n,tableStart:r},i){let a=e.mapping.maps.length;for(let o=0;o<t.height;){let s=o*t.width+i,c=t.map[s],l=n.nodeAt(c),u=l.attrs;if(i>0&&t.map[s-1]==c||i<t.width-1&&t.map[s+1]==c)e.setNodeMarkup(e.mapping.slice(a).map(r+c),null,x(u,i-t.colCount(c)));else{let t=e.mapping.slice(a).map(r+c);e.delete(t,t+l.nodeSize)}o+=u.rowspan}}function be(e,t){if(!g(e))return!1;if(t){let n=N(e),r=e.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let e=n.right-1;ye(r,n,e),e!=n.left;e--){let e=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!e)throw RangeError(`No table found`);n.table=e,n.map=i.get(e)}t(r)}return!0}function xe(e,t,n){let r=p(t.type.schema).header_cell;for(let i=0;i<e.width;i++)if(t.nodeAt(e.map[i+n*e.width])?.type!=r)return!1;return!0}function F(e,{map:t,tableStart:n,table:r},i){let a=n;for(let e=0;e<i;e++)a+=r.child(e).nodeSize;let o=[],s=i>0?-1:0;xe(t,r,i+s)&&(s=i==0||i==t.height?null:0);for(let a=0,c=t.width*i;a<t.width;a++,c++)if(i>0&&i<t.height&&t.map[c]==t.map[c-t.width]){let i=t.map[c],o=r.nodeAt(i).attrs;e.setNodeMarkup(n+i,null,{...o,rowspan:o.rowspan+1}),a+=o.colspan-1}else{let e=(s==null?p(r.type.schema).cell:r.nodeAt(t.map[c+s*t.width])?.type)?.createAndFill();e&&o.push(e)}return e.insert(a,p(r.type.schema).row.create(null,o)),e}function Se(e,t){if(!g(e))return!1;if(t){let n=N(e);t(F(e.tr,n,n.top))}return!0}function Ce(e,t){if(!g(e))return!1;if(t){let n=N(e);t(F(e.tr,n,n.bottom))}return!0}function we(e,{map:t,table:n,tableStart:r},i){let a=0;for(let e=0;e<i;e++)a+=n.child(e).nodeSize;let o=a+n.child(i).nodeSize,s=e.mapping.maps.length;e.delete(a+r,o+r);let c=new Set;for(let a=0,o=i*t.width;a<t.width;a++,o++){let l=t.map[o];if(!c.has(l)){if(c.add(l),i>0&&l==t.map[o-t.width]){let t=n.nodeAt(l).attrs;e.setNodeMarkup(e.mapping.slice(s).map(l+r),null,{...t,rowspan:t.rowspan-1}),a+=t.colspan-1}else if(i<t.height&&l==t.map[o+t.width]){let o=n.nodeAt(l),c=o.attrs,u=o.type.create({...c,rowspan:o.attrs.rowspan-1},o.content),d=t.positionAt(i+1,a,n);e.insert(e.mapping.slice(s).map(r+d),u),a+=c.colspan-1}}}}function Te(e,t){if(!g(e))return!1;if(t){let n=N(e),r=e.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let e=n.bottom-1;we(r,n,e),e!=n.top;e--){let e=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!e)throw RangeError(`No table found`);n.table=e,n.map=i.get(n.table)}t(r)}return!0}function Ee(e,t){return function(n,r){if(!g(n))return!1;let i=_(n);if(i.nodeAfter.attrs[e]===t)return!1;if(r){let a=n.tr;n.selection instanceof S?n.selection.forEachCell((n,r)=>{n.attrs[e]!==t&&a.setNodeMarkup(r,null,{...n.attrs,[e]:t})}):a.setNodeMarkup(i.pos,null,{...i.nodeAfter.attrs,[e]:t}),r(a)}return!0}}function De(e){return function(t,n){if(!g(t))return!1;if(n){let r=p(t.schema),i=N(t),a=t.tr,o=i.map.cellsInRect(e==`column`?{left:i.left,top:0,right:i.right,bottom:i.map.height}:e==`row`?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),s=o.map(e=>i.table.nodeAt(e));for(let e=0;e<o.length;e++)s[e].type==r.header_cell&&a.setNodeMarkup(i.tableStart+o[e],r.cell,s[e].attrs);if(a.steps.length===0)for(let e=0;e<o.length;e++)a.setNodeMarkup(i.tableStart+o[e],r.header_cell,s[e].attrs);n(a)}return!0}}function I(e,t,n){let r=t.map.cellsInRect({left:0,top:0,right:e==`row`?t.map.width:1,bottom:e==`column`?t.map.height:1});for(let e=0;e<r.length;e++){let i=t.table.nodeAt(r[e]);if(i&&i.type!==n.header_cell)return!1}return!0}function L(e,t){return t||={useDeprecatedLogic:!1},t.useDeprecatedLogic?De(e):function(t,n){if(!g(t))return!1;if(n){let r=p(t.schema),i=N(t),a=t.tr,o=I(`row`,i,r),s=I(`column`,i,r),c=(e===`column`?o:e===`row`&&s)?1:0,l=e==`column`?{left:0,top:c,right:1,bottom:i.map.height}:e==`row`?{left:c,top:0,right:i.map.width,bottom:1}:i,u=e==`column`?s?r.cell:r.header_cell:e==`row`?o?r.cell:r.header_cell:r.cell;i.map.cellsInRect(l).forEach(e=>{let t=e+i.tableStart,n=a.doc.nodeAt(t);n&&a.setNodeMarkup(t,u,n.attrs)}),n(a)}return!0}}L(`row`,{useDeprecatedLogic:!0}),L(`column`,{useDeprecatedLogic:!0}),L(`cell`,{useDeprecatedLogic:!0});function Oe(e,t){if(t<0){let t=e.nodeBefore;if(t)return e.pos-t.nodeSize;for(let t=e.index(-1)-1,n=e.before();t>=0;t--){let r=e.node(-1).child(t),i=r.lastChild;if(i)return n-1-i.nodeSize;n-=r.nodeSize}}else{if(e.index()<e.parent.childCount-1)return e.pos+e.nodeAfter.nodeSize;let t=e.node(-1);for(let n=e.indexAfter(-1),r=e.after();n<t.childCount;n++){let e=t.child(n);if(e.childCount)return r+1;r+=e.nodeSize}}return null}function ke(e){return function(n,r){if(!g(n))return!1;let i=Oe(_(n),e);if(i==null)return!1;if(r){let e=n.doc.resolve(i);r(n.tr.setSelection(t.c.between(e,te(e))).scrollIntoView())}return!0}}function Ae(e,t){let n=e.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole==`table`)return t&&t(e.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function R(e,n){let r=e.selection;if(!(r instanceof S))return!1;if(n){let i=e.tr,a=p(e.schema).cell.createAndFill().content;r.forEachCell((e,n)=>{e.content.eq(a)||i.replace(i.mapping.map(n+1),i.mapping.map(n+e.nodeSize-1),new t.A(a,0,0))}),i.docChanged&&n(i)}return!0}function je(e){return(t,n)=>{let{from:r,to:i,select:a=!0,pos:o=t.selection.from}=e,s=t.tr;return he({tr:s,originIndex:r,targetIndex:i,select:a,pos:o})?(n?.(s),!0):!1}}function Me(e){return(t,n)=>{let{from:r,to:i,select:a=!0,pos:o=t.selection.from}=e,s=t.tr;return pe({tr:s,originIndex:r,targetIndex:i,select:a,pos:o})?(n?.(s),!0):!1}}function Ne(e){if(e.size===0)return null;let{content:n,openStart:r,openEnd:i}=e;for(;n.childCount==1&&(r>0&&i>0||n.child(0).type.spec.tableRole==`table`);)r--,i--,n=n.child(0).content;let a=n.child(0),o=a.type.spec.tableRole,s=a.type.schema,c=[];if(o==`row`)for(let e=0;e<n.childCount;e++){let a=n.child(e).content,o=e?0:Math.max(0,r-1),l=e<n.childCount-1?0:Math.max(0,i-1);(o||l)&&(a=z(p(s).row,new t.A(a,o,l)).content),c.push(a)}else if(o==`cell`||o==`header_cell`)c.push(r||i?z(p(s).row,new t.A(n,r,i)).content:n);else return null;return Pe(s,c)}function Pe(e,n){let r=[];for(let e=0;e<n.length;e++){let t=n[e];for(let n=t.childCount-1;n>=0;n--){let{rowspan:i,colspan:a}=t.child(n).attrs;for(let t=e;t<e+i;t++)r[t]=(r[t]||0)+a}}let i=0;for(let e=0;e<r.length;e++)i=Math.max(i,r[e]);for(let a=0;a<r.length;a++)if(a>=n.length&&n.push(t.w.empty),r[a]<i){let o=p(e).cell.createAndFill(),s=[];for(let e=r[a];e<i;e++)s.push(o);n[a]=n[a].append(t.w.from(s))}return{height:n.length,width:i,rows:n}}function z(e,n){let r=e.createAndFill();return new t.m(r).replace(0,r.content.size,n).doc}function Fe({width:e,height:n,rows:r},i,a){if(e!=i){let n=[],a=[];for(let e=0;e<r.length;e++){let o=r[e],s=[];for(let t=n[e]||0,r=0;t<i;r++){let a=o.child(r%o.childCount);t+a.attrs.colspan>i&&(a=a.type.createChecked(x(a.attrs,a.attrs.colspan,t+a.attrs.colspan-i),a.content)),s.push(a),t+=a.attrs.colspan;for(let t=1;t<a.attrs.rowspan;t++)n[e+t]=(n[e+t]||0)+a.attrs.colspan}a.push(t.w.from(s))}r=a,e=i}if(n!=a){let e=[];for(let i=0,o=0;i<a;i++,o++){let s=[],c=r[o%n];for(let e=0;e<c.childCount;e++){let t=c.child(e);i+t.attrs.rowspan>a&&(t=t.type.create({...t.attrs,rowspan:Math.max(1,a-t.attrs.rowspan)},t.content)),s.push(t)}e.push(t.w.from(s))}r=e,n=a}return{width:e,height:n,rows:r}}function Ie(e,n,r,i,a,o,s){let c=e.doc.type.schema,l=p(c),u,d;if(a>n.width)for(let t=0,o=0;t<n.height;t++){let c=r.child(t);o+=c.nodeSize;let f=[],p;p=c.lastChild==null||c.lastChild.type==l.cell?u||=l.cell.createAndFill():d||=l.header_cell.createAndFill();for(let e=n.width;e<a;e++)f.push(p);e.insert(e.mapping.slice(s).map(o-1+i),f)}if(o>n.height){let c=[];for(let e=0,t=(n.height-1)*n.width;e<Math.max(n.width,a);e++){let i=e>=n.width?!1:r.nodeAt(n.map[t+e]).type==l.header_cell;c.push(i?d||=l.header_cell.createAndFill():u||=l.cell.createAndFill())}let f=l.row.create(null,t.w.from(c)),p=[];for(let e=n.height;e<o;e++)p.push(f);e.insert(e.mapping.slice(s).map(i+r.nodeSize-2),p)}return!!(u||d)}function B(e,t,n,r,i,a,o,s){if(o==0||o==t.height)return!1;let c=!1;for(let l=i;l<a;l++){let i=o*t.width+l,a=t.map[i];if(t.map[i-t.width]==a){c=!0;let i=n.nodeAt(a),{top:u,left:d}=t.findCell(a);e.setNodeMarkup(e.mapping.slice(s).map(a+r),null,{...i.attrs,rowspan:o-u}),e.insert(e.mapping.slice(s).map(t.positionAt(o,d,n)),i.type.createAndFill({...i.attrs,rowspan:u+i.attrs.rowspan-o})),l+=i.attrs.colspan-1}}return c}function V(e,t,n,r,i,a,o,s){if(o==0||o==t.width)return!1;let c=!1;for(let l=i;l<a;l++){let i=l*t.width+o,a=t.map[i];if(t.map[i-1]==a){c=!0;let i=n.nodeAt(a),u=t.colCount(a),d=e.mapping.slice(s).map(a+r);e.setNodeMarkup(d,null,x(i.attrs,o-u,i.attrs.colspan-(o-u))),e.insert(d+i.nodeSize,i.type.createAndFill(x(i.attrs,0,o-u))),l+=i.attrs.rowspan-1}}return c}function H(e,n,r,a,o){let s=r?e.doc.nodeAt(r-1):e.doc;if(!s)throw Error(`No table found`);let c=i.get(s),{top:l,left:u}=a,d=u+o.width,f=l+o.height,p=e.tr,m=0;function h(){if(s=r?p.doc.nodeAt(r-1):p.doc,!s)throw Error(`No table found`);c=i.get(s),m=p.mapping.maps.length}Ie(p,c,s,r,d,f,m)&&h(),B(p,c,s,r,u,d,l,m)&&h(),B(p,c,s,r,u,d,f,m)&&h(),V(p,c,s,r,l,f,u,m)&&h(),V(p,c,s,r,l,f,d,m)&&h();for(let e=l;e<f;e++){let n=c.positionAt(e,u,s),i=c.positionAt(e,d,s);p.replace(p.mapping.slice(m).map(n+r),p.mapping.slice(m).map(i+r),new t.A(o.rows[e-l],0,0))}h(),p.setSelection(new S(p.doc.resolve(r+c.positionAt(l,u,s)),p.doc.resolve(r+c.positionAt(f-1,d-1,s)))),n(p)}var Le=e.N({ArrowLeft:W(`horiz`,-1),ArrowRight:W(`horiz`,1),ArrowUp:W(`vert`,-1),ArrowDown:W(`vert`,1),"Shift-ArrowLeft":G(`horiz`,-1),"Shift-ArrowRight":G(`horiz`,1),"Shift-ArrowUp":G(`vert`,-1),"Shift-ArrowDown":G(`vert`,1),Backspace:R,"Mod-Backspace":R,Delete:R,"Mod-Delete":R});function U(e,t,n){return n.eq(e.selection)?!1:(t&&t(e.tr.setSelection(n).scrollIntoView()),!0)}function W(e,n){return(r,i,a)=>{if(!a)return!1;let o=r.selection;if(o instanceof S)return U(r,i,t.o.near(o.$headCell,n));if(e!=`horiz`&&!o.empty)return!1;let s=K(a,e,n);if(s==null)return!1;if(e==`horiz`)return U(r,i,t.o.near(r.doc.resolve(o.head+n),n));{let a=r.doc.resolve(s),o=b(a,e,n),c;return c=o?t.o.near(o,1):n<0?t.o.near(r.doc.resolve(a.before(-1)),-1):t.o.near(r.doc.resolve(a.after(-1)),1),U(r,i,c)}}}function G(e,t){return(n,r,i)=>{if(!i)return!1;let a=n.selection,o;if(a instanceof S)o=a;else{let r=K(i,e,t);if(r==null)return!1;o=new S(n.doc.resolve(r))}let s=b(o.$headCell,e,t);return s?U(n,r,new S(o.$anchorCell,s)):!1}}function Re(e,t){let n=e.state.doc,r=h(n.resolve(t));return r?(e.dispatch(e.state.tr.setSelection(new S(r))),!0):!1}function ze(e,n,r){if(!g(e.state))return!1;let a=Ne(r),o=e.state.selection;if(o instanceof S){a||={width:1,height:1,rows:[t.w.from(z(p(e.state.schema).cell,r))]};let n=o.$anchorCell.node(-1),s=o.$anchorCell.start(-1),c=i.get(n).rectBetween(o.$anchorCell.pos-s,o.$headCell.pos-s);return a=Fe(a,c.right-c.left,c.bottom-c.top),H(e.state,e.dispatch,s,c,a),!0}else if(a){let t=_(e.state),n=t.start(-1);return H(e.state,e.dispatch,n,i.get(t.node(-1)).findCell(t.pos-n),a),!0}else return!1}function Be(e,t){if(t.button!=0||t.ctrlKey||t.metaKey)return;let n=q(e,t.target),r;if(t.shiftKey&&e.state.selection instanceof S)i(e.state.selection.$anchorCell,t),t.preventDefault();else if(t.shiftKey&&n&&(r=h(e.state.selection.$anchor))!=null&&J(e,t)?.pos!=r.pos)i(r,t),t.preventDefault();else if(!n)return;function i(t,n){let r=J(e,n),i=m.getState(e.state)==null;if(!r||!y(t,r))if(i)r=t;else return;let a=new S(t,r);if(i||!e.state.selection.eq(a)){let n=e.state.tr.setSelection(a);i&&n.setMeta(m,t.pos),e.dispatch(n)}}function a(){e.root.removeEventListener(`mouseup`,a),e.root.removeEventListener(`dragstart`,a),e.root.removeEventListener(`mousemove`,o),m.getState(e.state)!=null&&e.dispatch(e.state.tr.setMeta(m,-1))}function o(r){let o=r,s=m.getState(e.state),c;if(s!=null)c=e.state.doc.resolve(s);else if(q(e,o.target)!=n&&(c=J(e,t),!c))return a();c&&i(c,o)}e.root.addEventListener(`mouseup`,a),e.root.addEventListener(`dragstart`,a),e.root.addEventListener(`mousemove`,o)}function K(e,n,r){if(!(e.state.selection instanceof t.c))return null;let{$head:i}=e.state.selection;for(let t=i.depth-1;t>=0;t--){let a=i.node(t);if((r<0?i.index(t):i.indexAfter(t))!=(r<0?0:a.childCount))return null;if(a.type.spec.tableRole==`cell`||a.type.spec.tableRole==`header_cell`){let a=i.before(t),o=n==`vert`?r>0?`down`:`up`:r>0?`right`:`left`;return e.endOfTextblock(o)?a:null}}return null}function q(e,t){for(;t&&t!=e.dom;t=t.parentNode)if(t.nodeName==`TD`||t.nodeName==`TH`)return t;return null}function J(e,t){let n=e.posAtCoords({left:t.clientX,top:t.clientY});if(!n)return null;let{inside:r,pos:i}=n;return r>=0&&h(e.state.doc.resolve(r))||h(e.state.doc.resolve(i))}var Ve=class{constructor(e,t){this.node=e,this.defaultCellMinWidth=t,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`,`${t}px`),this.colgroup=this.table.appendChild(document.createElement(`colgroup`)),Y(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement(`tbody`))}update(e){return e.type==this.node.type?(this.node=e,Y(e,this.colgroup,this.table,this.defaultCellMinWidth),!0):!1}ignoreMutation(e){return e.type==`attributes`&&(e.target==this.table||this.colgroup.contains(e.target))}};function Y(e,t,n,r,i,a){let o=0,s=!0,c=t.firstChild,l=e.firstChild;if(l){for(let e=0,n=0;e<l.childCount;e++){let{colspan:u,colwidth:d}=l.child(e).attrs;for(let e=0;e<u;e++,n++){let l=i==n?a:d&&d[e],u=l?l+`px`:``;if(o+=l||r,l||(s=!1),c)c.style.width!=u&&(c.style.width=u),c=c.nextSibling;else{let e=document.createElement(`col`);e.style.width=u,t.appendChild(e)}}}for(;c;){var u;let e=c.nextSibling;(u=c.parentNode)==null||u.removeChild(c),c=e}s?(n.style.width=o+`px`,n.style.minWidth=``):(n.style.width=``,n.style.minWidth=o+`px`)}}var X=new t.a(`tableColumnResizing`);function He({handleWidth:e=5,cellMinWidth:n=25,defaultCellMinWidth:r=100,View:i=Ve,lastColumnResizable:a=!0}={}){let o=new t.i({key:X,state:{init(e,t){var n;let a=(n=o.spec)==null||(n=n.props)==null?void 0:n.nodeViews,s=p(t.schema).table.name;return i&&a&&(a[s]=(e,t)=>new i(e,r,t)),new Ue(-1,!1)},apply(e,t){return t.apply(e)}},props:{attributes:e=>{let t=X.getState(e);return t&&t.activeHandle>-1?{class:`resize-cursor`}:{}},handleDOMEvents:{mousemove:(t,n)=>{We(t,n,e,a)},mouseleave:e=>{Ge(e)},mousedown:(e,t)=>{Ke(e,t,n,r)}},decorations:e=>{let t=X.getState(e);if(t&&t.activeHandle>-1)return Qe(e,t.activeHandle)},nodeViews:{}}});return o}var Ue=class e{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(t){let n=this,r=t.getMeta(X);if(r&&r.setHandle!=null)return new e(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new e(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&t.docChanged){let r=t.mapping.map(n.activeHandle,-1);return v(t.doc.resolve(r))||(r=-1),new e(r,n.dragging)}return n}};function We(e,t,n,r){if(!e.editable)return;let a=X.getState(e.state);if(a&&!a.dragging){let o=Je(t.target),s=-1;if(o){let{left:r,right:i}=o.getBoundingClientRect();t.clientX-r<=n?s=Z(e,t,`left`,n):i-t.clientX<=n&&(s=Z(e,t,`right`,n))}if(s!=a.activeHandle){if(!r&&s!==-1){let t=e.state.doc.resolve(s),n=t.node(-1),r=i.get(n),a=t.start(-1);if(r.colCount(t.pos-a)+t.nodeAfter.attrs.colspan-1==r.width-1)return}$(e,s)}}}function Ge(e){if(!e.editable)return;let t=X.getState(e.state);t&&t.activeHandle>-1&&!t.dragging&&$(e,-1)}function Ke(e,t,n,r){if(!e.editable)return!1;let i=e.dom.ownerDocument.defaultView??window,a=X.getState(e.state);if(!a||a.activeHandle==-1||a.dragging)return!1;let o=e.state.doc.nodeAt(a.activeHandle),s=qe(e,a.activeHandle,o.attrs);e.dispatch(e.state.tr.setMeta(X,{setDragging:{startX:t.clientX,startWidth:s}}));function c(t){i.removeEventListener(`mouseup`,c),i.removeEventListener(`mousemove`,l);let r=X.getState(e.state);r?.dragging&&(Ye(e,r.activeHandle,Q(r.dragging,t,n)),e.dispatch(e.state.tr.setMeta(X,{setDragging:null})))}function l(t){if(!t.which)return c(t);let i=X.getState(e.state);if(i&&i.dragging){let a=Q(i.dragging,t,n);Xe(e,i.activeHandle,a,r)}}return Xe(e,a.activeHandle,s,r),i.addEventListener(`mouseup`,c),i.addEventListener(`mousemove`,l),t.preventDefault(),!0}function qe(e,t,{colspan:n,colwidth:r}){let i=r&&r[r.length-1];if(i)return i;let a=e.domAtPos(t),o=a.node.childNodes[a.offset].offsetWidth,s=n;if(r)for(let e=0;e<n;e++)r[e]&&(o-=r[e],s--);return o/s}function Je(e){for(;e&&e.nodeName!=`TD`&&e.nodeName!=`TH`;)e=e.classList&&e.classList.contains(`ProseMirror`)?null:e.parentNode;return e}function Z(e,t,n,r){let a=n==`right`?-r:r,o=e.posAtCoords({left:t.clientX+a,top:t.clientY});if(!o)return-1;let{pos:s}=o,c=h(e.state.doc.resolve(s));if(!c)return-1;if(n==`right`)return c.pos;let l=i.get(c.node(-1)),u=c.start(-1),d=l.map.indexOf(c.pos-u);return d%l.width==0?-1:u+l.map[d-1]}function Q(e,t,n){let r=t.clientX-e.startX;return Math.max(n,e.startWidth+r)}function $(e,t){e.dispatch(e.state.tr.setMeta(X,{setHandle:t}))}function Ye(e,t,n){let r=e.state.doc.resolve(t),a=r.node(-1),o=i.get(a),s=r.start(-1),c=o.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1,l=e.state.tr;for(let e=0;e<o.height;e++){let t=e*o.width+c;if(e&&o.map[t]==o.map[t-o.width])continue;let r=o.map[t],i=a.nodeAt(r).attrs,u=i.colspan==1?0:c-o.colCount(r);if(i.colwidth&&i.colwidth[u]==n)continue;let d=i.colwidth?i.colwidth.slice():Ze(i.colspan);d[u]=n,l.setNodeMarkup(s+r,null,{...i,colwidth:d})}l.docChanged&&e.dispatch(l)}function Xe(e,t,n,r){let a=e.state.doc.resolve(t),o=a.node(-1),s=a.start(-1),c=i.get(o).colCount(a.pos-s)+a.nodeAfter.attrs.colspan-1,l=e.domAtPos(a.start(-1)).node;for(;l&&l.nodeName!=`TABLE`;)l=l.parentNode;l&&Y(o,l.firstChild,l,r,c,n)}function Ze(e){return Array(e).fill(0)}function Qe(t,n){let r=[],a=t.doc.resolve(n),o=a.node(-1);if(!o)return e.M.empty;let s=i.get(o),c=a.start(-1),l=s.colCount(a.pos-c)+a.nodeAfter.attrs.colspan-1;for(let n=0;n<s.height;n++){let i=l+n*s.width;if((l==s.width-1||s.map[i]!=s.map[i+1])&&(n==0||s.map[i]!=s.map[i-s.width])){let n=s.map[i],a=c+n+o.nodeAt(n).nodeSize-1,l=document.createElement(`div`);l.className=`column-resize-handle`,X.getState(t)?.dragging&&r.push(e.j.node(c+n,c+n+o.nodeAt(n).nodeSize,{class:`column-resize-dragging`})),r.push(e.j.widget(a,l))}}return e.M.create(t.doc,r)}function $e({allowTableNodeSelection:e=!1}={}){return new t.i({key:m,state:{init(){return null},apply(e,t){let n=e.getMeta(m);if(n!=null)return n==-1?null:n;if(t==null||!e.docChanged)return t;let{deleted:r,pos:i}=e.mapping.mapResult(t);return r?null:i}},props:{decorations:ae,handleDOMEvents:{mousedown:Be},createSelectionBetween(e){return m.getState(e.state)==null?null:e.state.selection},handleTripleClick:Re,handleKeyDown:Le,handlePaste:ze},appendTransaction(t,n,r){return ce(r,ue(r,n),e)}})}Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return Ce}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return be}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return N}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return je}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return Te}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return Me}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return Se}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return ve}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return He}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(exports,"v",{enumerable:!0,get:function(){return $e}}),Object.defineProperty(exports,"y",{enumerable:!0,get:function(){return f}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=Math.min,t=Math.max,n=Math.round,r=Math.floor,i=e=>({x:e,y:e}),a={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function o(n,r,i){return t(n,e(r,i))}function s(e,t){return typeof e==`function`?e(t):e}function c(e){return e.split(`-`)[0]}function l(e){return e.split(`-`)[1]}function u(e){return e===`x`?`y`:`x`}function d(e){return e===`y`?`height`:`width`}function f(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function p(e){return u(f(e))}function m(e,t,n){n===void 0&&(n=!1);let r=l(e),i=p(e),a=d(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=C(o)),[o,C(o)]}function h(e){let t=C(e);return[g(e),t,g(t)]}function g(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var _=[`left`,`right`],v=[`right`,`left`],y=[`top`,`bottom`],b=[`bottom`,`top`];function x(e,t,n){switch(e){case`top`:case`bottom`:return n?t?v:_:t?_:v;case`left`:case`right`:return t?y:b;default:return[]}}function S(e,t,n,r){let i=l(e),a=x(c(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(g)))),a}function C(e){let t=c(e);return a[t]+e.slice(t.length)}function w(e){return{top:0,right:0,bottom:0,left:0,...e}}function ee(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:w(e)}function T(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function E(e,t,n){let{reference:r,floating:i}=e,a=f(t),o=p(t),s=d(o),u=c(t),m=a===`y`,h=r.x+r.width/2-i.width/2,g=r.y+r.height/2-i.height/2,_=r[s]/2-i[s]/2,v;switch(u){case`top`:v={x:h,y:r.y-i.height};break;case`bottom`:v={x:h,y:r.y+r.height};break;case`right`:v={x:r.x+r.width,y:g};break;case`left`:v={x:r.x-i.width,y:g};break;default:v={x:r.x,y:r.y}}switch(l(t)){case`start`:v[o]-=_*(n&&m?-1:1);break;case`end`:v[o]+=_*(n&&m?-1:1);break}return v}async function D(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:c}=e,{boundary:l=`clippingAncestors`,rootBoundary:u=`viewport`,elementContext:d=`floating`,altBoundary:f=!1,padding:p=0}=s(t,e),m=ee(p),h=o[f?d===`floating`?`reference`:`floating`:d],g=T(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(h))??!0?h:h.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:l,rootBoundary:u,strategy:c})),_=d===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,v=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),y=await(i.isElement==null?void 0:i.isElement(v))&&await(i.getScale==null?void 0:i.getScale(v))||{x:1,y:1},b=T(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:_,offsetParent:v,strategy:c}):_);return{top:(g.top-b.top+m.top)/y.y,bottom:(b.bottom-g.bottom+m.bottom)/y.y,left:(g.left-b.left+m.left)/y.x,right:(b.right-g.right+m.right)/y.x}}var te=50,O=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:D},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=E(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<te&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=E(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},k=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:l,elements:u}=t,{mainAxis:d=!0,crossAxis:p=!0,fallbackPlacements:g,fallbackStrategy:_=`bestFit`,fallbackAxisSideDirection:v=`none`,flipAlignment:y=!0,...b}=s(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let x=c(r),w=f(o),ee=c(o)===o,T=await(l.isRTL==null?void 0:l.isRTL(u.floating)),E=g||(ee||!y?[C(o)]:h(o)),D=v!==`none`;!g&&D&&E.push(...S(o,y,v,T));let te=[o,...E],O=await l.detectOverflow(t,b),k=[],A=i.flip?.overflows||[];if(d&&k.push(O[x]),p){let e=m(r,a,T);k.push(O[e[0]],O[e[1]])}if(A=[...A,{placement:r,overflows:k}],!k.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=te[e];if(t&&(!(p===`alignment`&&w!==f(t))||A.every(e=>f(e.placement)===w?e.overflows[0]>0:!0)))return{data:{index:e,overflows:A},reset:{placement:t}};let n=A.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(_){case`bestFit`:{let e=A.filter(e=>{if(D){let t=f(e.placement);return t===w||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o;break}if(r!==n)return{reset:{placement:n}}}return{}}}},A=new Set([`left`,`top`]);async function ne(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=c(n),u=l(n),d=f(n)===`y`,p=A.has(o)?-1:1,m=a&&d?-1:1,h=s(t,e),{mainAxis:g,crossAxis:_,alignmentAxis:v}=typeof h==`number`?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return u&&typeof v==`number`&&(_=u===`end`?v*-1:v),d?{x:_*m,y:g*p}:{x:g*p,y:_*m}}var re=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await ne(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},ie=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:l=!0,crossAxis:d=!1,limiter:p={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...m}=s(e,t),h={x:n,y:r},g=await a.detectOverflow(t,m),_=f(c(i)),v=u(_),y=h[v],b=h[_];if(l){let e=v===`y`?`top`:`left`,t=v===`y`?`bottom`:`right`,n=y+g[e],r=y-g[t];y=o(n,y,r)}if(d){let e=_===`y`?`top`:`left`,t=_===`y`?`bottom`:`right`,n=b+g[e],r=b-g[t];b=o(n,b,r)}let x=p.fn({...t,[v]:y,[_]:b});return{...x,data:{x:x.x-n,y:x.y-r,enabled:{[v]:l,[_]:d}}}}}};function j(){return typeof window<`u`}function M(e){return ae(e)?(e.nodeName||``).toLowerCase():`#document`}function N(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function P(e){return((ae(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function ae(e){return j()?e instanceof Node||e instanceof N(e).Node:!1}function F(e){return j()?e instanceof Element||e instanceof N(e).Element:!1}function I(e){return j()?e instanceof HTMLElement||e instanceof N(e).HTMLElement:!1}function oe(e){return!j()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof N(e).ShadowRoot}function L(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=U(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function se(e){return/^(table|td|th)$/.test(M(e))}function R(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var ce=/transform|translate|scale|rotate|perspective|filter/,le=/paint|layout|strict|content/,z=e=>!!e&&e!==`none`,ue;function B(e){let t=F(e)?U(e):e;return z(t.transform)||z(t.translate)||z(t.scale)||z(t.rotate)||z(t.perspective)||!V()&&(z(t.backdropFilter)||z(t.filter))||ce.test(t.willChange||``)||le.test(t.contain||``)}function de(e){let t=G(e);for(;I(t)&&!H(t);){if(B(t))return t;if(R(t))return null;t=G(t)}return null}function V(){return ue??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),ue}function H(e){return/^(html|body|#document)$/.test(M(e))}function U(e){return N(e).getComputedStyle(e)}function W(e){return F(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function G(e){if(M(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||oe(e)&&e.host||P(e);return oe(t)?t.host:t}function fe(e){let t=G(e);return H(t)?e.ownerDocument?e.ownerDocument.body:e.body:I(t)&&L(t)?t:fe(t)}function K(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=fe(e),i=r===e.ownerDocument?.body,a=N(r);if(i){let e=q(a);return t.concat(a,a.visualViewport||[],L(r)?r:[],e&&n?K(e):[])}else return t.concat(r,K(r,[],n))}function q(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function pe(e){let t=U(e),r=parseFloat(t.width)||0,i=parseFloat(t.height)||0,a=I(e),o=a?e.offsetWidth:r,s=a?e.offsetHeight:i,c=n(r)!==o||n(i)!==s;return c&&(r=o,i=s),{width:r,height:i,$:c}}function J(e){return F(e)?e:e.contextElement}function Y(e){let t=J(e);if(!I(t))return i(1);let r=t.getBoundingClientRect(),{width:a,height:o,$:s}=pe(t),c=(s?n(r.width):r.width)/a,l=(s?n(r.height):r.height)/o;return(!c||!Number.isFinite(c))&&(c=1),(!l||!Number.isFinite(l))&&(l=1),{x:c,y:l}}var me=i(0);function he(e){let t=N(e);return!V()||!t.visualViewport?me:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function ge(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==N(e)?!1:t}function X(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let a=e.getBoundingClientRect(),o=J(e),s=i(1);t&&(r?F(r)&&(s=Y(r)):s=Y(e));let c=ge(o,n,r)?he(o):i(0),l=(a.left+c.x)/s.x,u=(a.top+c.y)/s.y,d=a.width/s.x,f=a.height/s.y;if(o){let e=N(o),t=r&&F(r)?N(r):r,n=e,i=q(n);for(;i&&r&&t!==n;){let e=Y(i),t=i.getBoundingClientRect(),r=U(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;l*=e.x,u*=e.y,d*=e.x,f*=e.y,l+=a,u+=o,n=N(i),i=q(n)}}return T({width:d,height:f,x:l,y:u})}function Z(e,t){let n=W(e).scrollLeft;return t?t.left+n:X(P(e)).left+n}function _e(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-Z(e,n),y:n.top+t.scrollTop}}function ve(e){let{elements:t,rect:n,offsetParent:r,strategy:a}=e,o=a===`fixed`,s=P(r),c=t?R(t.floating):!1;if(r===s||c&&o)return n;let l={scrollLeft:0,scrollTop:0},u=i(1),d=i(0),f=I(r);if((f||!f&&!o)&&((M(r)!==`body`||L(s))&&(l=W(r)),f)){let e=X(r);u=Y(r),d.x=e.x+r.clientLeft,d.y=e.y+r.clientTop}let p=s&&!f&&!o?_e(s,l):i(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-l.scrollLeft*u.x+d.x+p.x,y:n.y*u.y-l.scrollTop*u.y+d.y+p.y}}function ye(e){return Array.from(e.getClientRects())}function be(e){let n=P(e),r=W(e),i=e.ownerDocument.body,a=t(n.scrollWidth,n.clientWidth,i.scrollWidth,i.clientWidth),o=t(n.scrollHeight,n.clientHeight,i.scrollHeight,i.clientHeight),s=-r.scrollLeft+Z(e),c=-r.scrollTop;return U(i).direction===`rtl`&&(s+=t(n.clientWidth,i.clientWidth)-a),{width:a,height:o,x:s,y:c}}var xe=25;function Se(e,t){let n=N(e),r=P(e),i=n.visualViewport,a=r.clientWidth,o=r.clientHeight,s=0,c=0;if(i){a=i.width,o=i.height;let e=V();(!e||e&&t===`fixed`)&&(s=i.offsetLeft,c=i.offsetTop)}let l=Z(r);if(l<=0){let e=r.ownerDocument,t=e.body,n=getComputedStyle(t),i=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,o=Math.abs(r.clientWidth-t.clientWidth-i);o<=xe&&(a-=o)}else l<=xe&&(a+=l);return{width:a,height:o,x:s,y:c}}function Ce(e,t){let n=X(e,!0,t===`fixed`),r=n.top+e.clientTop,a=n.left+e.clientLeft,o=I(e)?Y(e):i(1);return{width:e.clientWidth*o.x,height:e.clientHeight*o.y,x:a*o.x,y:r*o.y}}function we(e,t,n){let r;if(t===`viewport`)r=Se(e,n);else if(t===`document`)r=be(P(e));else if(F(t))r=Ce(t,n);else{let n=he(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return T(r)}function Te(e,t){let n=G(e);return n===t||!F(n)||H(n)?!1:U(n).position===`fixed`||Te(n,t)}function Ee(e,t){let n=t.get(e);if(n)return n;let r=K(e,[],!1).filter(e=>F(e)&&M(e)!==`body`),i=null,a=U(e).position===`fixed`,o=a?G(e):e;for(;F(o)&&!H(o);){let t=U(o),n=B(o);!n&&t.position===`fixed`&&(i=null),(a?!n&&!i:!n&&t.position===`static`&&i&&(i.position===`absolute`||i.position===`fixed`)||L(o)&&!n&&Te(e,o))?r=r.filter(e=>e!==o):i=t,o=G(o)}return t.set(e,r),r}function De(n){let{element:r,boundary:i,rootBoundary:a,strategy:o}=n,s=[...i===`clippingAncestors`?R(r)?[]:Ee(r,this._c):[].concat(i),a],c=we(r,s[0],o),l=c.top,u=c.right,d=c.bottom,f=c.left;for(let n=1;n<s.length;n++){let i=we(r,s[n],o);l=t(i.top,l),u=e(i.right,u),d=e(i.bottom,d),f=t(i.left,f)}return{width:u-f,height:d-l,x:f,y:l}}function Oe(e){let{width:t,height:n}=pe(e);return{width:t,height:n}}function ke(e,t,n){let r=I(t),a=P(t),o=n===`fixed`,s=X(e,!0,o,t),c={scrollLeft:0,scrollTop:0},l=i(0);function u(){l.x=Z(a)}if(r||!r&&!o)if((M(t)!==`body`||L(a))&&(c=W(t)),r){let e=X(t,!0,o,t);l.x=e.x+t.clientLeft,l.y=e.y+t.clientTop}else a&&u();o&&!r&&a&&u();let d=a&&!r&&!o?_e(a,c):i(0);return{x:s.left+c.scrollLeft-l.x-d.x,y:s.top+c.scrollTop-l.y-d.y,width:s.width,height:s.height}}function Q(e){return U(e).position===`static`}function Ae(e,t){if(!I(e)||U(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return P(e)===n&&(n=n.ownerDocument.body),n}function je(e,t){let n=N(e);if(R(e))return n;if(!I(e)){let t=G(e);for(;t&&!H(t);){if(F(t)&&!Q(t))return t;t=G(t)}return n}let r=Ae(e,t);for(;r&&se(r)&&Q(r);)r=Ae(r,t);return r&&H(r)&&Q(r)&&!B(r)?n:r||de(e)||n}var Me=async function(e){let t=this.getOffsetParent||je,n=this.getDimensions,r=await n(e.floating);return{reference:ke(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Ne(e){return U(e).direction===`rtl`}var Pe={convertOffsetParentRelativeRectToViewportRelativeRect:ve,getDocumentElement:P,getClippingRect:De,getOffsetParent:je,getElementRects:Me,getClientRects:ye,getDimensions:Oe,getScale:Y,isElement:F,isRTL:Ne};function $(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Fe(n,i){let a=null,o,s=P(n);function c(){var e;clearTimeout(o),(e=a)==null||e.disconnect(),a=null}function l(u,d){u===void 0&&(u=!1),d===void 0&&(d=1),c();let f=n.getBoundingClientRect(),{left:p,top:m,width:h,height:g}=f;if(u||i(),!h||!g)return;let _=r(m),v=r(s.clientWidth-(p+h)),y=r(s.clientHeight-(m+g)),b=r(p),x={rootMargin:-_+`px `+-v+`px `+-y+`px `+-b+`px`,threshold:t(0,e(1,d))||1},S=!0;function C(e){let t=e[0].intersectionRatio;if(t!==d){if(!S)return l();t?l(!1,t):o=setTimeout(()=>{l(!1,1e-7)},1e3)}t===1&&!$(f,n.getBoundingClientRect())&&l(),S=!1}try{a=new IntersectionObserver(C,{...x,root:s.ownerDocument})}catch{a=new IntersectionObserver(C,x)}a.observe(n)}return l(!0),c}function Ie(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=J(e),u=i||a?[...l?K(l):[],...t?K(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n,{passive:!0}),a&&e.addEventListener(`resize`,n)});let d=l&&s?Fe(l,n):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?X(e):null;c&&g();function g(){let t=X(e);h&&!$(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var Le=re,Re=ie,ze=k,Be=(e,t,n)=>{let r=new Map,i={platform:Pe,...n},a={...i.platform,_c:r};return O(e,t,{...i,platform:a})};Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return Re}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return Le}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return Be}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return ze}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return Ie}});
|