react-latex-editor-custom-mhzn-v2 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -0
- package/README.md +342 -0
- package/dist/components/CharacterCount.d.ts +6 -0
- package/dist/components/CharacterCount.d.ts.map +1 -0
- package/dist/components/Editor.d.ts +83 -0
- package/dist/components/Editor.d.ts.map +1 -0
- package/dist/components/EditorToolbar.d.ts +10 -0
- package/dist/components/EditorToolbar.d.ts.map +1 -0
- package/dist/components/ErrorBoundary.d.ts +20 -0
- package/dist/components/ErrorBoundary.d.ts.map +1 -0
- package/dist/components/ImagePickerDialog.d.ts +15 -0
- package/dist/components/ImagePickerDialog.d.ts.map +1 -0
- package/dist/components/LoadingOverlay.d.ts +5 -0
- package/dist/components/LoadingOverlay.d.ts.map +1 -0
- package/dist/components/MathEquationDialog.d.ts +39 -0
- package/dist/components/MathEquationDialog.d.ts.map +1 -0
- package/dist/components/ModalPortal.d.ts +11 -0
- package/dist/components/ModalPortal.d.ts.map +1 -0
- package/dist/components/ResizableImageView.d.ts +22 -0
- package/dist/components/ResizableImageView.d.ts.map +1 -0
- package/dist/components/ResizableYoutubeView.d.ts +18 -0
- package/dist/components/ResizableYoutubeView.d.ts.map +1 -0
- package/dist/components/TableControls.d.ts +8 -0
- package/dist/components/TableControls.d.ts.map +1 -0
- package/dist/components/Viewer.d.ts +38 -0
- package/dist/components/Viewer.d.ts.map +1 -0
- package/dist/components/toolbars/AlignmentControls.d.ts +8 -0
- package/dist/components/toolbars/AlignmentControls.d.ts.map +1 -0
- package/dist/components/toolbars/BlockControls.d.ts +8 -0
- package/dist/components/toolbars/BlockControls.d.ts.map +1 -0
- package/dist/components/toolbars/ColorControls.d.ts +8 -0
- package/dist/components/toolbars/ColorControls.d.ts.map +1 -0
- package/dist/components/toolbars/FontControls.d.ts +8 -0
- package/dist/components/toolbars/FontControls.d.ts.map +1 -0
- package/dist/components/toolbars/HeadingControls.d.ts +8 -0
- package/dist/components/toolbars/HeadingControls.d.ts.map +1 -0
- package/dist/components/toolbars/HistoryControls.d.ts +8 -0
- package/dist/components/toolbars/HistoryControls.d.ts.map +1 -0
- package/dist/components/toolbars/ImageAlignmentControls.d.ts +13 -0
- package/dist/components/toolbars/ImageAlignmentControls.d.ts.map +1 -0
- package/dist/components/toolbars/ImageGroupAlignmentControls.d.ts +13 -0
- package/dist/components/toolbars/ImageGroupAlignmentControls.d.ts.map +1 -0
- package/dist/components/toolbars/ListControls.d.ts +8 -0
- package/dist/components/toolbars/ListControls.d.ts.map +1 -0
- package/dist/components/toolbars/SpecialFeaturesControls.d.ts +10 -0
- package/dist/components/toolbars/SpecialFeaturesControls.d.ts.map +1 -0
- package/dist/components/toolbars/TextFormattingControls.d.ts +8 -0
- package/dist/components/toolbars/TextFormattingControls.d.ts.map +1 -0
- package/dist/components/toolbars/ToolbarButton.d.ts +12 -0
- package/dist/components/toolbars/ToolbarButton.d.ts.map +1 -0
- package/dist/components/toolbars/ToolbarDivider.d.ts +3 -0
- package/dist/components/toolbars/ToolbarDivider.d.ts.map +1 -0
- package/dist/components/toolbars/YouTubeControls.d.ts +13 -0
- package/dist/components/toolbars/YouTubeControls.d.ts.map +1 -0
- package/dist/constants/config.d.ts +144 -0
- package/dist/constants/config.d.ts.map +1 -0
- package/dist/constants/editorConstants.d.ts +12 -0
- package/dist/constants/editorConstants.d.ts.map +1 -0
- package/dist/extensions/BackgroundColor.d.ts +12 -0
- package/dist/extensions/BackgroundColor.d.ts.map +1 -0
- package/dist/extensions/CustomTextStyle.d.ts +16 -0
- package/dist/extensions/CustomTextStyle.d.ts.map +1 -0
- package/dist/extensions/ImageGroup.d.ts +4 -0
- package/dist/extensions/ImageGroup.d.ts.map +1 -0
- package/dist/extensions/InlineMath.d.ts +11 -0
- package/dist/extensions/InlineMath.d.ts.map +1 -0
- package/dist/extensions/MathNode.d.ts +4 -0
- package/dist/extensions/MathNode.d.ts.map +1 -0
- package/dist/extensions/MathNodeView.d.ts +28 -0
- package/dist/extensions/MathNodeView.d.ts.map +1 -0
- package/dist/extensions/ResizableImageExtension.d.ts +3 -0
- package/dist/extensions/ResizableImageExtension.d.ts.map +1 -0
- package/dist/extensions/ResizableYoutubeExtension.d.ts +3 -0
- package/dist/extensions/ResizableYoutubeExtension.d.ts.map +1 -0
- package/dist/hooks/useEditorForceUpdate.d.ts +7 -0
- package/dist/hooks/useEditorForceUpdate.d.ts.map +1 -0
- package/dist/hooks/useEditorKeyboard.d.ts +10 -0
- package/dist/hooks/useEditorKeyboard.d.ts.map +1 -0
- package/dist/hooks/useEditorState.d.ts +38 -0
- package/dist/hooks/useEditorState.d.ts.map +1 -0
- package/dist/hooks/useResponsive.d.ts +2 -0
- package/dist/hooks/useResponsive.d.ts.map +1 -0
- package/dist/index.cjs.js +131 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.esm.js +23223 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.html +6 -0
- package/dist/react-latex-editor-custom-mhzn-v2.css +1 -0
- package/dist/styles.d.ts +1 -0
- package/dist/styles.d.ts.map +1 -0
- package/dist/types/editor.d.ts +87 -0
- package/dist/types/editor.d.ts.map +1 -0
- package/dist/types/mathlive.d.ts +25 -0
- package/dist/types/mathlive.d.ts.map +1 -0
- package/dist/utils/contentStats.d.ts +13 -0
- package/dist/utils/contentStats.d.ts.map +1 -0
- package/dist/utils/editorConfig.d.ts +23 -0
- package/dist/utils/editorConfig.d.ts.map +1 -0
- package/dist/utils/editorUtils.d.ts +23 -0
- package/dist/utils/editorUtils.d.ts.map +1 -0
- package/dist/utils/helpers.d.ts +58 -0
- package/dist/utils/helpers.d.ts.map +1 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/media.d.ts +30 -0
- package/dist/utils/media.d.ts.map +1 -0
- package/dist/utils/svgDom.d.ts +19 -0
- package/dist/utils/svgDom.d.ts.map +1 -0
- package/dist/vite.svg +1 -0
- package/package.json +124 -0
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";var Of=Object.create;var yl=Object.defineProperty;var Rf=Object.getOwnPropertyDescriptor;var Lf=Object.getOwnPropertyNames;var Df=Object.getPrototypeOf,If=Object.prototype.hasOwnProperty;var Pf=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Lf(e))!If.call(n,s)&&s!==t&&yl(n,s,{get:()=>e[s],enumerable:!(r=Rf(e,s))||r.enumerable});return n};var bl=(n,e,t)=>(t=n!=null?Of(Df(n)):{},Pf(e||!n||!n.__esModule?yl(t,"default",{value:n,enumerable:!0}):t,n));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("react/jsx-runtime"),S=require("react"),bo=require("react-dom"),xl=require("lowlight");require("mathlive");function pe(n){this.content=n}pe.prototype={constructor:pe,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var r=t&&t!=n?this.remove(t):this,s=r.find(n),i=r.content.slice();return s==-1?i.push(t||n,e):(i[s+1]=e,t&&(i[s]=t)),new pe(i)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new pe(t)},addToStart:function(n,e){return new pe([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new pe(t)},addBefore:function(n,e,t){var r=this.remove(e),s=r.content.slice(),i=r.find(n);return s.splice(i==-1?s.length:i,0,e,t),new pe(s)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=pe.from(n),n.size?new pe(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=pe.from(n),n.size?new pe(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=pe.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}};pe.from=function(n){if(n instanceof pe)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new pe(e)};function bc(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let s=n.child(r),i=e.child(r);if(s==i){t+=s.nodeSize;continue}if(!s.sameMarkup(i))return t;if(s.isText&&s.text!=i.text){for(let o=0;s.text[o]==i.text[o];o++)t++;return t}if(s.content.size||i.content.size){let o=bc(s.content,i.content,t+1);if(o!=null)return o}t+=s.nodeSize}}function xc(n,e,t,r){for(let s=n.childCount,i=e.childCount;;){if(s==0||i==0)return s==i?null:{a:t,b:r};let o=n.child(--s),l=e.child(--i),a=o.nodeSize;if(o==l){t-=a,r-=a;continue}if(!o.sameMarkup(l))return{a:t,b:r};if(o.isText&&o.text!=l.text){let c=0,u=Math.min(o.text.length,l.text.length);for(;c<u&&o.text[o.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,r--;return{a:t,b:r}}if(o.content.size||l.content.size){let c=xc(o.content,l.content,t-1,r-1);if(c)return c}t-=a,r-=a}}class v{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,s=0,i){for(let o=0,l=0;l<t;o++){let a=this.content[o],c=l+a.nodeSize;if(c>e&&r(a,s+l,i||null,o)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,t-u),r,s+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,s){let i="",o=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?s?typeof s=="function"?s(l):s:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(o?o=!1:i+=r),i+=c},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,s=this.content.slice(),i=0;for(t.isText&&t.sameMarkup(r)&&(s[s.length-1]=t.withText(t.text+r.text),i=1);i<e.content.length;i++)s.push(e.content[i]);return new v(s,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],s=0;if(t>e)for(let i=0,o=0;o<t;i++){let l=this.content[i],a=o+l.nodeSize;a>e&&((o<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,t-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,t-o-1))),r.push(l),s+=l.nodeSize),o=a}return new v(r,s)}cutByIndex(e,t){return e==t?v.empty:e==0&&t==this.content.length?this:new v(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let s=this.content.slice(),i=this.size+t.nodeSize-r.nodeSize;return s[e]=t,new v(s,i)}addToStart(e){return new v([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new v(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let s=this.content[t];e(s,r,t),r+=s.nodeSize}}findDiffStart(e,t=0){return bc(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return xc(this,e,t,r)}findIndex(e,t=-1){if(e==0)return mr(0,e);if(e==this.size)return mr(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let r=0,s=0;;r++){let i=this.child(r),o=s+i.nodeSize;if(o>=e)return o==e||t>0?mr(r+1,o):mr(r,s);s=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return v.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new v(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return v.empty;let t,r=0;for(let s=0;s<e.length;s++){let i=e[s];r+=i.nodeSize,s&&i.isText&&e[s-1].sameMarkup(i)?(t||(t=e.slice(0,s)),t[t.length-1]=i.withText(t[t.length-1].text+i.text)):t&&t.push(i)}return new v(t||e,r)}static from(e){if(!e)return v.empty;if(e instanceof v)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new v([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}v.empty=new v([],0);const Qs={index:0,offset:0};function mr(n,e){return Qs.index=n,Qs.offset=e,Qs}function Hr(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!Hr(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!Hr(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}let J=class Ri{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let s=0;s<e.length;s++){let i=e[s];if(this.eq(i))return e;if(this.type.excludes(i.type))t||(t=e.slice(0,s));else{if(i.type.excludes(this.type))return e;!r&&i.type.rank>this.type.rank&&(t||(t=e.slice(0,s)),t.push(this),r=!0),t&&t.push(i)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Hr(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);let s=r.create(t.attrs);return r.checkAttrs(s.attrs),s}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return Ri.none;if(e instanceof Ri)return[e];let t=e.slice();return t.sort((r,s)=>r.type.rank-s.type.rank),t}};J.none=[];class _r extends Error{}class A{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=Sc(this.content,e+this.openStart,t);return r&&new A(r,this.openStart,this.openEnd)}removeBetween(e,t){return new A(kc(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return A.empty;let r=t.openStart||0,s=t.openEnd||0;if(typeof r!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new A(v.fromJSON(e,t.content),r,s)}static maxOpen(e,t=!0){let r=0,s=0;for(let i=e.firstChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.lastChild)s++;return new A(e,r,s)}}A.empty=new A(v.empty,0,0);function kc(n,e,t){let{index:r,offset:s}=n.findIndex(e),i=n.maybeChild(r),{index:o,offset:l}=n.findIndex(t);if(s==e||i.isText){if(l!=t&&!n.child(o).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=o)throw new RangeError("Removing non-flat range");return n.replaceChild(r,i.copy(kc(i.content,e-s-1,t-s-1)))}function Sc(n,e,t,r){let{index:s,offset:i}=n.findIndex(e),o=n.maybeChild(s);if(i==e||o.isText)return n.cut(0,e).append(t).append(n.cut(e));let l=Sc(o.content,e-i-1,t);return l&&n.replaceChild(s,o.copy(l))}function jf(n,e,t){if(t.openStart>n.depth)throw new _r("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new _r("Inconsistent open depths");return wc(n,e,t,0)}function wc(n,e,t,r){let s=n.index(r),i=n.node(r);if(s==e.index(r)&&r<n.depth-t.openStart){let o=wc(n,e,t,r+1);return i.copy(i.content.replaceChild(s,o))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let o=n.parent,l=o.content;return Wt(o,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=Bf(t,n);return Wt(i,vc(n,o,l,e,r))}else return Wt(i,Fr(n,e,r))}function Cc(n,e){if(!e.type.compatibleContent(n.type))throw new _r("Cannot join "+e.type.name+" onto "+n.type.name)}function Li(n,e,t){let r=n.node(t);return Cc(r,e.node(t)),r}function Vt(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function Pn(n,e,t,r){let s=(e||n).node(t),i=0,o=e?e.index(t):s.childCount;n&&(i=n.index(t),n.depth>t?i++:n.textOffset&&(Vt(n.nodeAfter,r),i++));for(let l=i;l<o;l++)Vt(s.child(l),r);e&&e.depth==t&&e.textOffset&&Vt(e.nodeBefore,r)}function Wt(n,e){return n.type.checkContent(e),n.copy(e)}function vc(n,e,t,r,s){let i=n.depth>s&&Li(n,e,s+1),o=r.depth>s&&Li(t,r,s+1),l=[];return Pn(null,n,s,l),i&&o&&e.index(s)==t.index(s)?(Cc(i,o),Vt(Wt(i,vc(n,e,t,r,s+1)),l)):(i&&Vt(Wt(i,Fr(n,e,s+1)),l),Pn(e,t,s,l),o&&Vt(Wt(o,Fr(t,r,s+1)),l)),Pn(r,null,s,l),new v(l)}function Fr(n,e,t){let r=[];if(Pn(null,n,t,r),n.depth>t){let s=Li(n,e,t+1);Vt(Wt(s,Fr(n,e,t+1)),r)}return Pn(e,null,t,r),new v(r)}function Bf(n,e){let t=e.depth-n.openStart,s=e.node(t).copy(n.content);for(let i=t-1;i>=0;i--)s=e.node(i).copy(v.from(s));return{start:s.resolveNoCache(n.openStart+t),end:s.resolveNoCache(s.content.size-n.openEnd-t)}}class qn{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],s=e.child(t);return r?e.child(t).cut(r):s}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],s=t==0?0:this.path[t*3-1]+1;for(let i=0;i<e;i++)s+=r.child(i).nodeSize;return s}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return J.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),s=e.maybeChild(t);if(!r){let l=r;r=s,s=l}let i=r.marks;for(var o=0;o<i.length;o++)i[o].type.spec.inclusive===!1&&(!s||!i[o].isInSet(s.marks))&&(i=i[o--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.marks,s=e.parent.maybeChild(e.index());for(var i=0;i<r.length;i++)r[i].type.spec.inclusive===!1&&(!s||!r[i].isInSet(s.marks))&&(r=r[i--].removeFromSet(r));return r}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new $r(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],s=0,i=t;for(let o=e;;){let{index:l,offset:a}=o.content.findIndex(i),c=i-a;if(r.push(o,l,s+a),!c||(o=o.child(l),o.isText))break;i=c-1,s+=a+1}return new qn(t,r,i)}static resolveCached(e,t){let r=kl.get(e);if(r)for(let i=0;i<r.elts.length;i++){let o=r.elts[i];if(o.pos==t)return o}else kl.set(e,r=new zf);let s=r.elts[r.i]=qn.resolve(e,t);return r.i=(r.i+1)%Hf,s}}class zf{constructor(){this.elts=[],this.i=0}}const Hf=12,kl=new WeakMap;class $r{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const _f=Object.create(null);let Mt=class Di{constructor(e,t,r,s=J.none){this.type=e,this.attrs=t,this.marks=s,this.content=r||v.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,r,s=0){this.content.nodesBetween(e,t,r,s,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,r,s){return this.content.textBetween(e,t,r,s)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,r){return this.type==e&&Hr(this.attrs,t||e.defaultAttrs||_f)&&J.sameSet(this.marks,r||J.none)}copy(e=null){return e==this.content?this:new Di(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new Di(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,r=!1){if(e==t)return A.empty;let s=this.resolve(e),i=this.resolve(t),o=r?0:s.sharedDepth(t),l=s.start(o),c=s.node(o).content.cut(s.pos-l,i.pos-l);return new A(c,s.depth-o,i.depth-o)}replace(e,t,r){return jf(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:s}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(s==e||t.isText)return t;e-=s+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let s=this.content.child(t-1);return{node:s,index:t-1,offset:r-s.nodeSize}}resolve(e){return qn.resolveCached(this,e)}resolveNoCache(e){return qn.resolve(this,e)}rangeHasMark(e,t,r){let s=!1;return t>e&&this.nodesBetween(e,t,i=>(r.isInSet(i.marks)&&(s=!0),!s)),s}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()+")"),Mc(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=v.empty,s=0,i=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,s,i),l=o&&o.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=s;a<i;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,t,r,s){if(s&&!this.type.allowsMarks(s))return!1;let i=this.contentMatchAt(e).matchType(r),o=i&&i.matchFragment(this.content,t);return o?o.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=J.none;for(let t=0;t<this.marks.length;t++){let r=this.marks[t];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!J.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let s=v.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,s,r);return i.type.checkAttrs(i.attrs),i}};Mt.prototype.text=void 0;class Vr extends Mt{constructor(e,t,r,s){if(super(e,t,null,s),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Mc(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new Vr(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Vr(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function Mc(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class Jt{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new Ff(e,t);if(r.next==null)return Jt.empty;let s=Ec(r);r.next&&r.err("Unexpected trailing text");let i=Gf(qf(s));return Jf(i,r),i}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,r=e.childCount){let s=this;for(let i=t;s&&i<r;i++)s=s.matchType(e.child(i).type);return s}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let s=[this];function i(o,l){let a=o.matchFragment(e,r);if(a&&(!t||a.validEnd))return v.from(l.map(c=>c.createAndFill()));for(let c=0;c<o.next.length;c++){let{type:u,next:d}=o.next[c];if(!(u.isText||u.hasRequiredAttrs())&&s.indexOf(d)==-1){s.push(d);let f=i(d,l.concat(u));if(f)return f}}return null}return i(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let s=r.shift(),i=s.match;if(i.matchType(e)){let o=[];for(let l=s;l.type;l=l.via)o.push(l.type);return o.reverse()}for(let o=0;o<i.next.length;o++){let{type:l,next:a}=i.next[o];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!s.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:s}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let s=0;s<r.next.length;s++)e.indexOf(r.next[s].next)==-1&&t(r.next[s].next)}return t(this),e.map((r,s)=>{let i=s+(r.validEnd?"*":" ")+" ";for(let o=0;o<r.next.length;o++)i+=(o?", ":"")+r.next[o].type.name+"->"+e.indexOf(r.next[o].next);return i}).join(`
|
|
2
|
+
`)}}Jt.empty=new Jt(!0);class Ff{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function Ec(n){let e=[];do e.push($f(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function $f(n){let e=[];do e.push(Vf(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Vf(n){let e=Kf(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=Wf(n,e);else break;return e}function Sl(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function Wf(n,e){let t=Sl(n),r=t;return n.eat(",")&&(n.next!="}"?r=Sl(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function Uf(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let s=[];for(let i in t){let o=t[i];o.isInGroup(e)&&s.push(o)}return s.length==0&&n.err("No node type or group '"+e+"' found"),s}function Kf(n){if(n.eat("(")){let e=Ec(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=Uf(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function qf(n){let e=[[]];return s(i(n,0),t()),e;function t(){return e.push([])-1}function r(o,l,a){let c={term:a,to:l};return e[o].push(c),c}function s(o,l){o.forEach(a=>a.to=l)}function i(o,l){if(o.type=="choice")return o.exprs.reduce((a,c)=>a.concat(i(c,l)),[]);if(o.type=="seq")for(let a=0;;a++){let c=i(o.exprs[a],l);if(a==o.exprs.length-1)return c;s(c,l=t())}else if(o.type=="star"){let a=t();return r(l,a),s(i(o.expr,a),a),[r(a)]}else if(o.type=="plus"){let a=t();return s(i(o.expr,l),a),s(i(o.expr,a),a),[r(a)]}else{if(o.type=="opt")return[r(l)].concat(i(o.expr,l));if(o.type=="range"){let a=l;for(let c=0;c<o.min;c++){let u=t();s(i(o.expr,a),u),a=u}if(o.max==-1)s(i(o.expr,a),a);else for(let c=o.min;c<o.max;c++){let u=t();r(a,u),s(i(o.expr,a),u),a=u}return[r(a)]}else{if(o.type=="name")return[r(l,void 0,o.value)];throw new Error("Unknown expr type")}}}}function Tc(n,e){return e-n}function wl(n,e){let t=[];return r(e),t.sort(Tc);function r(s){let i=n[s];if(i.length==1&&!i[0].term)return r(i[0].to);t.push(s);for(let o=0;o<i.length;o++){let{term:l,to:a}=i[o];!l&&t.indexOf(a)==-1&&r(a)}}}function Gf(n){let e=Object.create(null);return t(wl(n,0));function t(r){let s=[];r.forEach(o=>{n[o].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let u=0;u<s.length;u++)s[u][0]==l&&(c=s[u][1]);wl(n,a).forEach(u=>{c||s.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let i=e[r.join(",")]=new Jt(r.indexOf(n.length-1)>-1);for(let o=0;o<s.length;o++){let l=s[o][1].sort(Tc);i.next.push({type:s[o][0],next:e[l.join(",")]||t(l)})}return i}}function Jf(n,e){for(let t=0,r=[n];t<r.length;t++){let s=r[t],i=!s.validEnd,o=[];for(let l=0;l<s.next.length;l++){let{type:a,next:c}=s.next[l];o.push(a.name),i&&!(a.isText||a.hasRequiredAttrs())&&(i=!1),r.indexOf(c)==-1&&r.push(c)}i&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Ac(n){let e=Object.create(null);for(let t in n){let r=n[t];if(!r.hasDefault)return null;e[t]=r.default}return e}function Nc(n,e){let t=Object.create(null);for(let r in n){let s=e&&e[r];if(s===void 0){let i=n[r];if(i.hasDefault)s=i.default;else throw new RangeError("No value supplied for attribute "+r)}t[r]=s}return t}function Oc(n,e,t,r){for(let s in e)if(!(s in n))throw new RangeError(`Unsupported attribute ${s} for ${t} of type ${s}`);for(let s in n){let i=n[s];i.validate&&i.validate(e[s])}}function Rc(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new Xf(n,r,e[r]);return t}let Cl=class Lc{constructor(e,t,r){this.name=e,this.schema=t,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=Rc(e,r.attrs),this.defaultAttrs=Ac(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Jt.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:Nc(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Mt(this,this.computeAttrs(e),v.from(t),J.setFrom(r))}createChecked(e=null,t,r){return t=v.from(t),this.checkContent(t),new Mt(this,this.computeAttrs(e),t,J.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=v.from(t),t.size){let o=this.contentMatch.fillBefore(t);if(!o)return null;t=o.append(t)}let s=this.contentMatch.matchFragment(t),i=s&&s.fillBefore(v.empty,!0);return i?new Mt(this,e,t.append(i),J.setFrom(r)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){Oc(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?t&&t.push(e[r]):t||(t=e.slice(0,r));return t?t.length?t:J.none:e}static compile(e,t){let r=Object.create(null);e.forEach((i,o)=>r[i]=new Lc(i,t,o));let s=t.spec.topNode||"doc";if(!r[s])throw new RangeError("Schema is missing its top node type ('"+s+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let i in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function Yf(n,e,t){let r=t.split("|");return s=>{let i=s===null?"null":typeof s;if(r.indexOf(i)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${i}`)}}class Xf{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?Yf(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class Rs{constructor(e,t,r,s){this.name=e,this.rank=t,this.schema=r,this.spec=s,this.attrs=Rc(e,s.attrs),this.excluded=null;let i=Ac(this.attrs);this.instance=i?new J(this,i):null}create(e=null){return!e&&this.instance?this.instance:new J(this,Nc(this.attrs,e))}static compile(e,t){let r=Object.create(null),s=0;return e.forEach((i,o)=>r[i]=new Rs(i,s++,t,o)),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){Oc(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Dc{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let s in e)t[s]=e[s];t.nodes=pe.from(e.nodes),t.marks=pe.from(e.marks||{}),this.nodes=Cl.compile(this.spec.nodes,this),this.marks=Rs.compile(this.spec.marks,this);let r=Object.create(null);for(let s in this.nodes){if(s in this.marks)throw new RangeError(s+" can not be both a node and a mark");let i=this.nodes[s],o=i.spec.content||"",l=i.spec.marks;if(i.contentMatch=r[o]||(r[o]=Jt.parse(o,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!i.isInline||!i.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=i}i.markSet=l=="_"?null:l?vl(this,l.split(" ")):l==""||!i.inlineContent?[]:null}for(let s in this.marks){let i=this.marks[s],o=i.spec.excludes;i.excluded=o==null?[i]:o==""?[]:vl(this,o.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,s){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Cl){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,r,s)}text(e,t){let r=this.nodes.text;return new Vr(r,r.defaultAttrs,e,J.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return Mt.fromJSON(this,e)}markFromJSON(e){return J.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function vl(n,e){let t=[];for(let r=0;r<e.length;r++){let s=e[r],i=n.marks[s],o=i;if(i)t.push(i);else for(let l in n.marks){let a=n.marks[l];(s=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(s)>-1)&&t.push(o=a)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function Qf(n){return n.tag!=null}function Zf(n){return n.style!=null}let jn=class Ii{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(s=>{if(Qf(s))this.tags.push(s);else if(Zf(s)){let i=/[^=]*/.exec(s.style)[0];r.indexOf(i)<0&&r.push(i),this.styles.push(s)}}),this.normalizeLists=!this.tags.some(s=>{if(!/^(ul|ol)\b/.test(s.tag)||!s.node)return!1;let i=e.nodes[s.node];return i.contentMatch.matchType(i)})}parse(e,t={}){let r=new El(this,t,!1);return r.addAll(e,J.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new El(this,t,!0);return r.addAll(e,J.none,t.from,t.to),A.maxOpen(r.finish())}matchTag(e,t,r){for(let s=r?this.tags.indexOf(r)+1:0;s<this.tags.length;s++){let i=this.tags[s];if(nh(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||t.matchesContext(i.context))){if(i.getAttrs){let o=i.getAttrs(e);if(o===!1)continue;i.attrs=o||void 0}return i}}}matchStyle(e,t,r,s){for(let i=s?this.styles.indexOf(s)+1:0;i<this.styles.length;i++){let o=this.styles[i],l=o.style;if(!(l.indexOf(e)!=0||o.context&&!r.matchesContext(o.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(o.getAttrs){let a=o.getAttrs(t);if(a===!1)continue;o.attrs=a||void 0}return o}}}static schemaRules(e){let t=[];function r(s){let i=s.priority==null?50:s.priority,o=0;for(;o<t.length;o++){let l=t[o];if((l.priority==null?50:l.priority)<i)break}t.splice(o,0,s)}for(let s in e.marks){let i=e.marks[s].spec.parseDOM;i&&i.forEach(o=>{r(o=Tl(o)),o.mark||o.ignore||o.clearMark||(o.mark=s)})}for(let s in e.nodes){let i=e.nodes[s].spec.parseDOM;i&&i.forEach(o=>{r(o=Tl(o)),o.node||o.ignore||o.mark||(o.node=s)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Ii(e,Ii.schemaRules(e)))}};const Ic={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},eh={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Pc={ol:!0,ul:!0},Gn=1,Pi=2,Bn=4;function Ml(n,e,t){return e!=null?(e?Gn:0)|(e==="full"?Pi:0):n&&n.whitespace=="pre"?Gn|Pi:t&~Bn}class gr{constructor(e,t,r,s,i,o){this.type=e,this.attrs=t,this.marks=r,this.solid=s,this.options=o,this.content=[],this.activeMarks=J.none,this.match=i||(o&Bn?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(v.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,s;return(s=r.findWrapping(e.type))?(this.match=r,s):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Gn)){let r=this.content[this.content.length-1],s;if(r&&r.isText&&(s=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==s[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-s[0].length))}}let t=v.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(v.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&&!Ic.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class El{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let s=t.topNode,i,o=Ml(null,t.preserveWhitespace,0)|(r?Bn:0);s?i=new gr(s.type,s.attrs,J.none,!0,t.topMatch||s.type.contentMatch,o):r?i=new gr(null,null,J.none,!0,null,o):i=new gr(e.schema.topNodeType,null,J.none,!0,null,o),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 r=e.nodeValue,s=this.top,i=s.options&Pi?"full":this.localPreserveWS||(s.options&Gn)>0;if(i==="full"||s.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(i)i!=="full"?r=r.replace(/\r?\n|\r/g," "):r=r.replace(/\r\n?/g,`
|
|
3
|
+
`);else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let o=s.content[s.content.length-1],l=e.previousSibling;(!o||l&&l.nodeName=="BR"||o.isText&&/[ \t\r\n\u000c]$/.test(o.text))&&(r=r.slice(1))}r&&this.insertNode(this.parser.schema.text(r),t,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,t,r){let s=this.localPreserveWS,i=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),l;Pc.hasOwnProperty(o)&&this.parser.normalizeLists&&th(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:eh.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,t);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let c,u=this.needsBlock;if(Ic.hasOwnProperty(o))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),c=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let d=a&&a.skip?t:this.readStyles(e,t);d&&this.addAll(e,d),c&&this.sync(i),this.needsBlock=u}else{let c=this.readStyles(e,t);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=s}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 r=e.style;if(r&&r.length)for(let s=0;s<this.parser.matchedStyles.length;s++){let i=this.parser.matchedStyles[s],o=r.getPropertyValue(i);if(o)for(let l=void 0;;){let a=this.parser.matchStyle(i,o,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?t=t.filter(c=>!a.clearMark(c)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,r,s){let i,o;if(t.node)if(o=this.parser.schema.nodes[t.node],o.isLeaf)this.insertNode(o.create(t.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(o,t.attrs||null,r,t.preserveWhitespace);a&&(i=!0,r=a)}else{let a=this.parser.schema.marks[t.mark];r=r.concat(a.create(t.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(s)this.addElement(e,r,s);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}i&&this.sync(l)&&this.open--}addAll(e,t,r,s){let i=r||0;for(let o=r?e.childNodes[r]:e.firstChild,l=s==null?null:e.childNodes[s];o!=l;o=o.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(o,t);this.findAtPoint(e,i)}findPlace(e,t,r){let s,i;for(let o=this.open,l=0;o>=0;o--){let a=this.nodes[o],c=a.findWrapping(e);if(c&&(!s||s.length>c.length+l)&&(s=c,i=a,!c.length))break;if(a.solid){if(r)break;l+=2}}if(!s)return null;this.sync(i);for(let o=0;o<s.length;o++)t=this.enterInner(s[o],null,t,!1);return t}insertNode(e,t,r){if(e.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(t=this.enterInner(i,null,t))}let s=this.findPlace(e,t,r);if(s){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let o=J.none;for(let l of s.concat(e.marks))(i.type?i.type.allowsMarkType(l.type):Al(l.type,e.type))&&(o=l.addToSet(o));return i.content.push(e.mark(o)),!0}return!1}enter(e,t,r,s){let i=this.findPlace(e.create(t),r,!1);return i&&(i=this.enterInner(e,t,r,!0,s)),i}enterInner(e,t,r,s=!1,i){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let l=Ml(e,i,o.options);o.options&Bn&&o.content.length==0&&(l|=Bn);let a=J.none;return r=r.filter(c=>(o.type?o.type.allowsMarkType(c.type):Al(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new gr(e,t,a,s,null,l)),this.open++,r}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=Gn)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let s=r.length-1;s>=0;s--)e+=r[s].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==t&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,r){if(e!=t&&this.find)for(let s=0;s<this.find.length;s++)this.find[s].pos==null&&e.nodeType==1&&e.contains(this.find[s].node)&&t.compareDocumentPosition(this.find[s].node)&(r?2:4)&&(this.find[s].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),r=this.options.context,s=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(s?0:1),o=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=i;a--)if(o(l-1,a))return!0;return!1}else{let u=a>0||a==0&&s?this.nodes[a].type:r&&a>=i?r.node(a-i).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;a--}}return!0};return o(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}}function th(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Pc.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function nh(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function Tl(n){let e={};for(let t in n)e[t]=n[t];return e}function Al(n,e){let t=e.schema.nodes;for(let r in t){let s=t[r];if(!s.allowsMarkType(n))continue;let i=[],o=l=>{i.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:u}=l.edge(a);if(c==e||i.indexOf(u)<0&&o(u))return!0}};if(o(s.contentMatch))return!0}}class nn{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=Zs(t).createDocumentFragment());let s=r,i=[];return e.forEach(o=>{if(i.length||o.marks.length){let l=0,a=0;for(;l<i.length&&a<o.marks.length;){let c=o.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(i[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<i.length;)s=i.pop()[1];for(;a<o.marks.length;){let c=o.marks[a++],u=this.serializeMark(c,o.isInline,t);u&&(i.push([c,s]),s.appendChild(u.dom),s=u.contentDOM||u.dom)}}s.appendChild(this.serializeNodeInner(o,t))}),r}serializeNodeInner(e,t){let{dom:r,contentDOM:s}=Lr(Zs(t),this.nodes[e.type.name](e),null,e.attrs);if(s){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,s)}return r}serializeNode(e,t={}){let r=this.serializeNodeInner(e,t);for(let s=e.marks.length-1;s>=0;s--){let i=this.serializeMark(e.marks[s],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,t,r={}){let s=this.marks[e.type.name];return s&&Lr(Zs(r),s(e,t),null,e.attrs)}static renderSpec(e,t,r=null,s){return Lr(e,t,r,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new nn(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Nl(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return Nl(e.marks)}}function Nl(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function Zs(n){return n.document||window.document}const Ol=new WeakMap;function rh(n){let e=Ol.get(n);return e===void 0&&Ol.set(n,e=sh(n)),e}function sh(n){let e=null;function t(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let s=0;s<r.length;s++)t(r[s]);else for(let s in r)t(r[s])}return t(n),e}function Lr(n,e,t,r){if(typeof e=="string")return{dom:n.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let s=e[0],i;if(typeof s!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(i=rh(r))&&i.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=s.indexOf(" ");o>0&&(t=s.slice(0,o),s=s.slice(o+1));let l,a=t?n.createElementNS(t,s):n.createElement(s),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let d in c)if(c[d]!=null){let f=d.indexOf(" ");f>0?a.setAttributeNS(d.slice(0,f),d.slice(f+1),c[d]):a.setAttribute(d,c[d])}}for(let d=u;d<e.length;d++){let f=e[d];if(f===0){if(d<e.length-1||d>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:h,contentDOM:p}=Lr(n,f,t,r);if(a.appendChild(h),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}const jc=65535,Bc=Math.pow(2,16);function ih(n,e){return n+e*Bc}function Rl(n){return n&jc}function oh(n){return(n-(n&jc))/Bc}const zc=1,Hc=2,Dr=4,_c=8;class ji{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&_c)>0}get deletedBefore(){return(this.delInfo&(zc|Dr))>0}get deletedAfter(){return(this.delInfo&(Hc|Dr))>0}get deletedAcross(){return(this.delInfo&Dr)>0}}class Ie{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&Ie.empty)return Ie.empty}recover(e){let t=0,r=Rl(e);if(!this.inverted)for(let s=0;s<r;s++)t+=this.ranges[s*3+2]-this.ranges[s*3+1];return this.ranges[r*3]+t+oh(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let s=0,i=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?s:0);if(a>e)break;let c=this.ranges[l+i],u=this.ranges[l+o],d=a+c;if(e<=d){let f=c?e==a?-1:e==d?1:t:t,h=a+s+(f<0?0:u);if(r)return h;let p=e==(t<0?a:d)?null:ih(l/3,e-a),g=e==a?Hc:e==d?zc:Dr;return(t<0?e!=a:e!=d)&&(g|=_c),new ji(h,g,p)}s+=u-c}return r?e+s:new ji(e+s,0,null)}touches(e,t){let r=0,s=Rl(t),i=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+i],u=a+c;if(e<=u&&l==s*3)return!0;r+=this.ranges[l+o]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let s=0,i=0;s<this.ranges.length;s+=3){let o=this.ranges[s],l=o-(this.inverted?i:0),a=o+(this.inverted?0:i),c=this.ranges[s+t],u=this.ranges[s+r];e(l,l+c,a,a+u),i+=u-c}}invert(){return new Ie(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Ie.empty:new Ie(e<0?[0,-e,0]:[0,0,e])}}Ie.empty=new Ie([]);class Jn{constructor(e,t,r=0,s=e?e.length:0){this.mirror=t,this.from=r,this.to=s,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new Jn(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,r=this._maps.length;t<e._maps.length;t++){let s=e.getMirror(t);this.appendMap(e._maps[t],s!=null&&s<t?r+s:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,r=this._maps.length+e._maps.length;t>=0;t--){let s=e.getMirror(t);this.appendMap(e._maps[t].invert(),s!=null&&s>t?r-s-1:void 0)}}invert(){let e=new Jn;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,r){let s=0;for(let i=this.from;i<this.to;i++){let o=this._maps[i],l=o.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(i);if(a!=null&&a>i&&a<this.to){i=a,e=this._maps[a].recover(l.recover);continue}}s|=l.delInfo,e=l.pos}return r?e:new ji(e,s,null)}}const ei=Object.create(null);class Ce{getMap(){return Ie.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=ei[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in ei)throw new RangeError("Duplicate use of step JSON ID "+e);return ei[e]=t,t.prototype.jsonID=e,t}}class oe{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new oe(e,null)}static fail(e){return new oe(null,e)}static fromReplace(e,t,r,s){try{return oe.ok(e.replace(t,r,s))}catch(i){if(i instanceof _r)return oe.fail(i.message);throw i}}}function xo(n,e,t){let r=[];for(let s=0;s<n.childCount;s++){let i=n.child(s);i.content.size&&(i=i.copy(xo(i.content,e,i))),i.isInline&&(i=e(i,t,s)),r.push(i)}return v.fromArray(r)}class St extends Ce{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),s=r.node(r.sharedDepth(this.to)),i=new A(xo(t.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),s),t.openStart,t.openEnd);return oe.fromReplace(e,this.from,this.to,i)}invert(){return new Ze(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new St(t.pos,r.pos,this.mark)}merge(e){return e instanceof St&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new St(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new St(t.from,t.to,e.markFromJSON(t.mark))}}Ce.jsonID("addMark",St);class Ze extends Ce{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new A(xo(t.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),t.openStart,t.openEnd);return oe.fromReplace(e,this.from,this.to,r)}invert(){return new St(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new Ze(t.pos,r.pos,this.mark)}merge(e){return e instanceof Ze&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ze(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Ze(t.from,t.to,e.markFromJSON(t.mark))}}Ce.jsonID("removeMark",Ze);class wt extends Ce{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return oe.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return oe.fromReplace(e,this.pos,this.pos+1,new A(v.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let s=0;s<t.marks.length;s++)if(!t.marks[s].isInSet(r))return new wt(this.pos,t.marks[s]);return new wt(this.pos,this.mark)}}return new Yt(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new wt(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new wt(t.pos,e.markFromJSON(t.mark))}}Ce.jsonID("addNodeMark",wt);class Yt extends Ce{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return oe.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return oe.fromReplace(e,this.pos,this.pos+1,new A(v.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new wt(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Yt(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Yt(t.pos,e.markFromJSON(t.mark))}}Ce.jsonID("removeNodeMark",Yt);class ce extends Ce{constructor(e,t,r,s=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=s}apply(e){return this.structure&&Bi(e,this.from,this.to)?oe.fail("Structure replace would overwrite content"):oe.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Ie([this.from,this.to-this.from,this.slice.size])}invert(e){return new ce(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deletedAcross&&r.deletedAcross?null:new ce(t.pos,Math.max(t.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof ce)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?A.empty:new A(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new ce(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?A.empty:new A(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new ce(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new ce(t.from,t.to,A.fromJSON(e,t.slice),!!t.structure)}}Ce.jsonID("replace",ce);class ue extends Ce{constructor(e,t,r,s,i,o,l=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=s,this.slice=i,this.insert=o,this.structure=l}apply(e){if(this.structure&&(Bi(e,this.from,this.gapFrom)||Bi(e,this.gapTo,this.to)))return oe.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return oe.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?oe.fromReplace(e,this.from,this.to,r):oe.fail("Content does not fit in gap")}getMap(){return new Ie([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new ue(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),s=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||s<t.pos||i>r.pos?null:new ue(t.pos,r.pos,s,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new ue(t.from,t.to,t.gapFrom,t.gapTo,A.fromJSON(e,t.slice),t.insert,!!t.structure)}}Ce.jsonID("replaceAround",ue);function Bi(n,e,t){let r=n.resolve(e),s=t-e,i=r.depth;for(;s>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,s--;if(s>0){let o=r.node(i).maybeChild(r.indexAfter(i));for(;s>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,s--}}return!1}function lh(n,e,t,r){let s=[],i=[],o,l;n.doc.nodesBetween(e,t,(a,c,u)=>{if(!a.isInline)return;let d=a.marks;if(!r.isInSet(d)&&u.type.allowsMarkType(r.type)){let f=Math.max(c,e),h=Math.min(c+a.nodeSize,t),p=r.addToSet(d);for(let g=0;g<d.length;g++)d[g].isInSet(p)||(o&&o.to==f&&o.mark.eq(d[g])?o.to=h:s.push(o=new Ze(f,h,d[g])));l&&l.to==f?l.to=h:i.push(l=new St(f,h,r))}}),s.forEach(a=>n.step(a)),i.forEach(a=>n.step(a))}function ah(n,e,t,r){let s=[],i=0;n.doc.nodesBetween(e,t,(o,l)=>{if(!o.isInline)return;i++;let a=null;if(r instanceof Rs){let c=o.marks,u;for(;u=r.isInSet(c);)(a||(a=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(o.marks)&&(a=[r]):a=o.marks;if(a&&a.length){let c=Math.min(l+o.nodeSize,t);for(let u=0;u<a.length;u++){let d=a[u],f;for(let h=0;h<s.length;h++){let p=s[h];p.step==i-1&&d.eq(s[h].style)&&(f=p)}f?(f.to=c,f.step=i):s.push({style:d,from:Math.max(l,e),to:c,step:i})}}}),s.forEach(o=>n.step(new Ze(o.from,o.to,o.style)))}function ko(n,e,t,r=t.contentMatch,s=!0){let i=n.doc.nodeAt(e),o=[],l=e+1;for(let a=0;a<i.childCount;a++){let c=i.child(a),u=l+c.nodeSize,d=r.matchType(c.type);if(!d)o.push(new ce(l,u,A.empty));else{r=d;for(let f=0;f<c.marks.length;f++)t.allowsMarkType(c.marks[f].type)||n.step(new Ze(l,u,c.marks[f]));if(s&&c.isText&&t.whitespace!="pre"){let f,h=/\r?\n|\r/g,p;for(;f=h.exec(c.text);)p||(p=new A(v.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),o.push(new ce(l+f.index,l+f.index+f[0].length,p))}}l=u}if(!r.validEnd){let a=r.fillBefore(v.empty,!0);n.replace(l,l,new A(a,0,0))}for(let a=o.length-1;a>=0;a--)n.step(o[a])}function ch(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function Mn(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth;;--r){let s=n.$from.node(r),i=n.$from.index(r),o=n.$to.indexAfter(r);if(r<n.depth&&s.canReplace(i,o,t))return r;if(r==0||s.type.spec.isolating||!ch(s,i,o))break}return null}function uh(n,e,t){let{$from:r,$to:s,depth:i}=e,o=r.before(i+1),l=s.after(i+1),a=o,c=l,u=v.empty,d=0;for(let p=i,g=!1;p>t;p--)g||r.index(p)>0?(g=!0,u=v.from(r.node(p).copy(u)),d++):a--;let f=v.empty,h=0;for(let p=i,g=!1;p>t;p--)g||s.after(p+1)<s.end(p)?(g=!0,f=v.from(s.node(p).copy(f)),h++):c++;n.step(new ue(a,c,o,l,new A(u.append(f),d,h),u.size-d,!0))}function So(n,e,t=null,r=n){let s=dh(n,e),i=s&&fh(r,e);return i?s.map(Ll).concat({type:e,attrs:t}).concat(i.map(Ll)):null}function Ll(n){return{type:n,attrs:null}}function dh(n,e){let{parent:t,startIndex:r,endIndex:s}=n,i=t.contentMatchAt(r).findWrapping(e);if(!i)return null;let o=i.length?i[0]:e;return t.canReplaceWith(r,s,o)?i:null}function fh(n,e){let{parent:t,startIndex:r,endIndex:s}=n,i=t.child(r),o=e.contentMatch.findWrapping(i.type);if(!o)return null;let a=(o.length?o[o.length-1]:e).contentMatch;for(let c=r;a&&c<s;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:o}function hh(n,e,t){let r=v.empty;for(let o=t.length-1;o>=0;o--){if(r.size){let l=t[o].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=v.from(t[o].type.create(t[o].attrs,r))}let s=e.start,i=e.end;n.step(new ue(s,i,s,i,new A(r,0,0),t.length,!0))}function ph(n,e,t,r,s){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=n.steps.length;n.doc.nodesBetween(e,t,(o,l)=>{let a=typeof s=="function"?s(o):s;if(o.isTextblock&&!o.hasMarkup(r,a)&&mh(n.doc,n.mapping.slice(i).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let h=r.whitespace=="pre",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);h&&!p?c=!1:!h&&p&&(c=!0)}c===!1&&$c(n,o,l,i),ko(n,n.mapping.slice(i).map(l,1),r,void 0,c===null);let u=n.mapping.slice(i),d=u.map(l,1),f=u.map(l+o.nodeSize,1);return n.step(new ue(d,f,d+1,f-1,new A(v.from(r.create(a,null,o.marks)),0,0),1,!0)),c===!0&&Fc(n,o,l,i),!1}})}function Fc(n,e,t,r){e.forEach((s,i)=>{if(s.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(s.text);){let a=n.mapping.slice(r).map(t+1+i+o.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function $c(n,e,t,r){e.forEach((s,i)=>{if(s.type==s.type.schema.linebreakReplacement){let o=n.mapping.slice(r).map(t+1+i);n.replaceWith(o,o+1,e.type.schema.text(`
|
|
5
|
+
`))}})}function mh(n,e,t){let r=n.resolve(e),s=r.index();return r.parent.canReplaceWith(s,s+1,t)}function gh(n,e,t,r,s){let i=n.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");t||(t=i.type);let o=t.create(r,null,s||i.marks);if(i.isLeaf)return n.replaceWith(e,e+i.nodeSize,o);if(!t.validContent(i.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new ue(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new A(v.from(o),0,0),1,!0))}function dt(n,e,t=1,r){let s=n.resolve(e),i=s.depth-t,o=r&&r[r.length-1]||s.parent;if(i<0||s.parent.type.spec.isolating||!s.parent.canReplace(s.index(),s.parent.childCount)||!o.type.validContent(s.parent.content.cutByIndex(s.index(),s.parent.childCount)))return!1;for(let c=s.depth-1,u=t-2;c>i;c--,u--){let d=s.node(c),f=s.index(c);if(d.type.spec.isolating)return!1;let h=d.content.cutByIndex(f,d.childCount),p=r&&r[u+1];p&&(h=h.replaceChild(0,p.type.create(p.attrs)));let g=r&&r[u]||d;if(!d.canReplace(f+1,d.childCount)||!g.type.validContent(h))return!1}let l=s.indexAfter(i),a=r&&r[0];return s.node(i).canReplaceWith(l,l,a?a.type:s.node(i+1).type)}function yh(n,e,t=1,r){let s=n.doc.resolve(e),i=v.empty,o=v.empty;for(let l=s.depth,a=s.depth-t,c=t-1;l>a;l--,c--){i=v.from(s.node(l).copy(i));let u=r&&r[c];o=v.from(u?u.type.create(u.attrs,o):s.node(l).copy(o))}n.step(new ce(e,e,new A(i.append(o),t,t),!0))}function Rt(n,e){let t=n.resolve(e),r=t.index();return Vc(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function bh(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:r}=n.type.schema;for(let s=0;s<e.childCount;s++){let i=e.child(s),o=i.type==r?n.type.schema.nodes.text:i.type;if(t=t.matchType(o),!t||!n.type.allowsMarks(i.marks))return!1}return t.validEnd}function Vc(n,e){return!!(n&&e&&!n.isLeaf&&bh(n,e))}function Ls(n,e,t=-1){let r=n.resolve(e);for(let s=r.depth;;s--){let i,o,l=r.index(s);if(s==r.depth?(i=r.nodeBefore,o=r.nodeAfter):t>0?(i=r.node(s+1),l++,o=r.node(s).maybeChild(l)):(i=r.node(s).maybeChild(l-1),o=r.node(s+1)),i&&!i.isTextblock&&Vc(i,o)&&r.node(s).canReplace(l,l+1))return e;if(s==0)break;e=t<0?r.before(s):r.after(s)}}function xh(n,e,t){let r=null,{linebreakReplacement:s}=n.doc.type.schema,i=n.doc.resolve(e-t),o=i.node().type;if(s&&o.inlineContent){let u=o.whitespace=="pre",d=!!o.contentMatch.matchType(s);u&&!d?r=!1:!u&&d&&(r=!0)}let l=n.steps.length;if(r===!1){let u=n.doc.resolve(e+t);$c(n,u.node(),u.before(),l)}o.inlineContent&&ko(n,e+t-1,o,i.node().contentMatchAt(i.index()),r==null);let a=n.mapping.slice(l),c=a.map(e-t);if(n.step(new ce(c,a.map(e+t,-1),A.empty,!0)),r===!0){let u=n.doc.resolve(c);Fc(n,u.node(),u.before(),n.steps.length)}return n}function kh(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let s=r.depth-1;s>=0;s--){let i=r.index(s);if(r.node(s).canReplaceWith(i,i,t))return r.before(s+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(let s=r.depth-1;s>=0;s--){let i=r.indexAfter(s);if(r.node(s).canReplaceWith(i,i,t))return r.after(s+1);if(i<r.node(s).childCount)return null}return null}function Wc(n,e,t){let r=n.resolve(e);if(!t.content.size)return e;let s=t.content;for(let i=0;i<t.openStart;i++)s=s.firstChild.content;for(let i=1;i<=(t.openStart==0&&t.size?2:1);i++)for(let o=r.depth;o>=0;o--){let l=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,a=r.index(o)+(l>0?1:0),c=r.node(o),u=!1;if(i==1)u=c.canReplace(a,a,s);else{let d=c.contentMatchAt(a).findWrapping(s.firstChild.type);u=d&&c.canReplaceWith(a,a,d[0])}if(u)return l==0?r.pos:l<0?r.before(o+1):r.after(o+1)}return null}function Ds(n,e,t=e,r=A.empty){if(e==t&&!r.size)return null;let s=n.resolve(e),i=n.resolve(t);return Uc(s,i,r)?new ce(e,t,r):new Sh(s,i,r).fit()}function Uc(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class Sh{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=v.empty;for(let s=0;s<=e.depth;s++){let i=e.node(s);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(s))})}for(let s=e.depth;s>0;s--)this.placed=v.from(e.node(s).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,s=this.close(e<0?this.$to:r.doc.resolve(e));if(!s)return null;let i=this.placed,o=r.depth,l=s.depth;for(;o&&l&&i.childCount==1;)i=i.firstChild.content,o--,l--;let a=new A(i,o,l);return e>-1?new ue(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new ce(r.pos,s.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,s=this.unplaced.openEnd;r<e;r++){let i=t.firstChild;if(t.childCount>1&&(s=0),i.type.spec.isolating&&s<=r){e=r;break}t=i.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let s,i=null;r?(i=ti(this.unplaced.content,r-1).firstChild,s=i.content):s=this.unplaced.content;let o=s.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],u,d=null;if(t==1&&(o?c.matchType(o.type)||(d=c.fillBefore(v.from(o),!1)):i&&a.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:l,parent:i,inject:d};if(t==2&&o&&(u=c.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:l,parent:i,wrap:u};if(i&&c.matchType(i.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,s=ti(e,t);return!s.childCount||s.firstChild.isLeaf?!1:(this.unplaced=new A(e,t+1,Math.max(r,s.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,s=ti(e,t);if(s.childCount<=1&&t>0){let i=e.size-t<=t+s.size;this.unplaced=new A(Rn(e,t-1,1),t-1,i?t-1:r)}else this.unplaced=new A(Rn(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:s,wrap:i}){for(;this.depth>t;)this.closeFrontierNode();if(i)for(let g=0;g<i.length;g++)this.openFrontierNode(i[g]);let o=this.unplaced,l=r?r.content:o.content,a=o.openStart-e,c=0,u=[],{match:d,type:f}=this.frontier[t];if(s){for(let g=0;g<s.childCount;g++)u.push(s.child(g));d=d.matchFragment(s)}let h=l.size+e-(o.content.size-o.openEnd);for(;c<l.childCount;){let g=l.child(c),y=d.matchType(g.type);if(!y)break;c++,(c>1||a==0||g.content.size)&&(d=y,u.push(Kc(g.mark(f.allowedMarks(g.marks)),c==1?a:0,c==l.childCount?h:-1)))}let p=c==l.childCount;p||(h=-1),this.placed=Ln(this.placed,t,v.from(u)),this.frontier[t].match=d,p&&h<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let g=0,y=l;g<h;g++){let b=y.lastChild;this.frontier.push({type:b.type,match:b.contentMatchAt(b.childCount)}),y=b.content}this.unplaced=p?e==0?A.empty:new A(Rn(o.content,e-1,1),e-1,h<0?o.openEnd:e-1):new A(Rn(o.content,e,c),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!ni(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:r}=this.$to,s=this.$to.after(r);for(;r>1&&s==this.$to.end(--r);)++s;return s}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:s}=this.frontier[t],i=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),o=ni(e,t,s,r,i);if(o){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],u=ni(e,l,c,a,!0);if(!u||u.childCount)continue e}return{depth:t,fit:o,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=Ln(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let s=e.node(r),i=s.type.contentMatch.fillBefore(s.content,!0,e.index(r));this.openFrontierNode(s.type,s.attrs,i)}return e}openFrontierNode(e,t=null,r){let s=this.frontier[this.depth];s.match=s.match.matchType(e),this.placed=Ln(this.placed,this.depth,v.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(v.empty,!0);t.childCount&&(this.placed=Ln(this.placed,this.frontier.length,t))}}function Rn(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Rn(n.firstChild.content,e-1,t)))}function Ln(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Ln(n.lastChild.content,e-1,t)))}function ti(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function Kc(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,Kc(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(v.empty,!0)))),n.copy(r)}function ni(n,e,t,r,s){let i=n.node(e),o=s?n.indexAfter(e):n.index(e);if(o==i.childCount&&!t.compatibleContent(i.type))return null;let l=r.fillBefore(i.content,!0,o);return l&&!wh(t,i.content,o)?l:null}function wh(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function Ch(n){return n.spec.defining||n.spec.definingForContent}function vh(n,e,t,r){if(!r.size)return n.deleteRange(e,t);let s=n.doc.resolve(e),i=n.doc.resolve(t);if(Uc(s,i,r))return n.step(new ce(e,t,r));let o=Gc(s,n.doc.resolve(t));o[o.length-1]==0&&o.pop();let l=-(s.depth+1);o.unshift(l);for(let f=s.depth,h=s.pos-1;f>0;f--,h--){let p=s.node(f).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;o.indexOf(f)>-1?l=f:s.before(f)==h&&o.splice(1,0,-f)}let a=o.indexOf(l),c=[],u=r.openStart;for(let f=r.content,h=0;;h++){let p=f.firstChild;if(c.push(p),h==r.openStart)break;f=p.content}for(let f=u-1;f>=0;f--){let h=c[f],p=Ch(h.type);if(p&&!h.sameMarkup(s.node(Math.abs(l)-1)))u=f;else if(p||!h.type.isTextblock)break}for(let f=r.openStart;f>=0;f--){let h=(f+u+1)%(r.openStart+1),p=c[h];if(p)for(let g=0;g<o.length;g++){let y=o[(g+a)%o.length],b=!0;y<0&&(b=!1,y=-y);let x=s.node(y-1),C=s.index(y-1);if(x.canReplaceWith(C,C,p.type,p.marks))return n.replace(s.before(y),b?i.after(y):t,new A(qc(r.content,0,r.openStart,h),h,r.openEnd))}}let d=n.steps.length;for(let f=o.length-1;f>=0&&(n.replace(e,t,r),!(n.steps.length>d));f--){let h=o[f];h<0||(e=s.before(h),t=i.after(h))}}function qc(n,e,t,r,s){if(e<t){let i=n.firstChild;n=n.replaceChild(0,i.copy(qc(i.content,e+1,t,r,i)))}if(e>r){let i=s.contentMatchAt(0),o=i.fillBefore(n).append(n);n=o.append(i.matchFragment(o).fillBefore(v.empty,!0))}return n}function Mh(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let s=kh(n.doc,e,r.type);s!=null&&(e=t=s)}n.replaceRange(e,t,new A(v.from(r),0,0))}function Eh(n,e,t){let r=n.doc.resolve(e),s=n.doc.resolve(t),i=Gc(r,s);for(let o=0;o<i.length;o++){let l=i[o],a=o==i.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return n.delete(r.start(l),s.end(l));if(l>0&&(a||r.node(l-1).canReplace(r.index(l-1),s.indexAfter(l-1))))return n.delete(r.before(l),s.after(l))}for(let o=1;o<=r.depth&&o<=s.depth;o++)if(e-r.start(o)==r.depth-o&&t>r.end(o)&&s.end(o)-t!=s.depth-o&&r.start(o-1)==s.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),s.index(o-1)))return n.delete(r.before(o),t);n.delete(e,t)}function Gc(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let s=r;s>=0;s--){let i=n.start(s);if(i<n.pos-(n.depth-s)||e.end(s)>e.pos+(e.depth-s)||n.node(s).type.spec.isolating||e.node(s).type.spec.isolating)break;(i==e.start(s)||s==n.depth&&s==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&s&&e.start(s-1)==i-1)&&t.push(s)}return t}class mn extends Ce{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return oe.fail("No node at attribute step's position");let r=Object.create(null);for(let i in t.attrs)r[i]=t.attrs[i];r[this.attr]=this.value;let s=t.type.create(r,null,t.marks);return oe.fromReplace(e,this.pos,this.pos+1,new A(v.from(s),0,t.isLeaf?0:1))}getMap(){return Ie.empty}invert(e){return new mn(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new mn(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new mn(t.pos,t.attr,t.value)}}Ce.jsonID("attr",mn);class Yn extends Ce{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let s in e.attrs)t[s]=e.attrs[s];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return oe.ok(r)}getMap(){return Ie.empty}invert(e){return new Yn(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Yn(t.attr,t.value)}}Ce.jsonID("docAttr",Yn);let bn=class extends Error{};bn=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};bn.prototype=Object.create(Error.prototype);bn.prototype.constructor=bn;bn.prototype.name="TransformError";class wo{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Jn}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new bn(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}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,r=A.empty){let s=Ds(this.doc,e,t,r);return s&&this.step(s),this}replaceWith(e,t,r){return this.replace(e,t,new A(v.from(r),0,0))}delete(e,t){return this.replace(e,t,A.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return vh(this,e,t,r),this}replaceRangeWith(e,t,r){return Mh(this,e,t,r),this}deleteRange(e,t){return Eh(this,e,t),this}lift(e,t){return uh(this,e,t),this}join(e,t=1){return xh(this,e,t),this}wrap(e,t){return hh(this,e,t),this}setBlockType(e,t=e,r,s=null){return ph(this,e,t,r,s),this}setNodeMarkup(e,t,r=null,s){return gh(this,e,t,r,s),this}setNodeAttribute(e,t,r){return this.step(new mn(e,t,r)),this}setDocAttribute(e,t){return this.step(new Yn(e,t)),this}addNodeMark(e,t){return this.step(new wt(e,t)),this}removeNodeMark(e,t){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t instanceof J)t.isInSet(r.marks)&&this.step(new Yt(e,t));else{let s=r.marks,i,o=[];for(;i=t.isInSet(s);)o.push(new Yt(e,i)),s=i.removeFromSet(s);for(let l=o.length-1;l>=0;l--)this.step(o[l])}return this}split(e,t=1,r){return yh(this,e,t,r),this}addMark(e,t,r){return lh(this,e,t,r),this}removeMark(e,t,r){return ah(this,e,t,r),this}clearIncompatible(e,t,r){return ko(this,e,t,r),this}}const ri=Object.create(null);class B{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new Jc(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=A.empty){let r=t.content.lastChild,s=null;for(let l=0;l<t.openEnd;l++)s=r,r=r.lastChild;let i=e.steps.length,o=this.ranges;for(let l=0;l<o.length;l++){let{$from:a,$to:c}=o[l],u=e.mapping.slice(i);e.replaceRange(u.map(a.pos),u.map(c.pos),l?A.empty:t),l==0&&Pl(e,i,(r?r.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(e,t){let r=e.steps.length,s=this.ranges;for(let i=0;i<s.length;i++){let{$from:o,$to:l}=s[i],a=e.mapping.slice(r),c=a.map(o.pos),u=a.map(l.pos);i?e.deleteRange(c,u):(e.replaceRangeWith(c,u,t),Pl(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let s=e.parent.inlineContent?new P(e):un(e.node(0),e.parent,e.pos,e.index(),t,r);if(s)return s;for(let i=e.depth-1;i>=0;i--){let o=t<0?un(e.node(0),e.node(i),e.before(i+1),e.index(i),t,r):un(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,t,r);if(o)return o}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new je(e.node(0))}static atStart(e){return un(e,e,0,0,1)||new je(e)}static atEnd(e){return un(e,e,e.content.size,e.childCount,-1)||new je(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=ri[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in ri)throw new RangeError("Duplicate use of selection JSON ID "+e);return ri[e]=t,t.prototype.jsonID=e,t}getBookmark(){return P.between(this.$anchor,this.$head).getBookmark()}}B.prototype.visible=!0;class Jc{constructor(e,t){this.$from=e,this.$to=t}}let Dl=!1;function Il(n){!Dl&&!n.parent.inlineContent&&(Dl=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class P extends B{constructor(e,t=e){Il(e),Il(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return B.near(r);let s=e.resolve(t.map(this.anchor));return new P(s.parent.inlineContent?s:r,r)}replace(e,t=A.empty){if(super.replace(e,t),t==A.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof P&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Is(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new P(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let s=e.resolve(t);return new this(s,r==t?s:e.resolve(r))}static between(e,t,r){let s=e.pos-t.pos;if((!r||s)&&(r=s>=0?1:-1),!t.parent.inlineContent){let i=B.findFrom(t,r,!0)||B.findFrom(t,-r,!0);if(i)t=i.$head;else return B.near(t,r)}return e.parent.inlineContent||(s==0?e=t:(e=(B.findFrom(e,-r,!0)||B.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=s<0&&(e=t))),new P(e,t)}}B.jsonID("text",P);class Is{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Is(e.map(this.anchor),e.map(this.head))}resolve(e){return P.between(e.resolve(this.anchor),e.resolve(this.head))}}class I extends B{constructor(e){let t=e.nodeAfter,r=e.node(0).resolve(e.pos+t.nodeSize);super(e,r),this.node=t}map(e,t){let{deleted:r,pos:s}=t.mapResult(this.anchor),i=e.resolve(s);return r?B.near(i):new I(i)}content(){return new A(v.from(this.node),0,0)}eq(e){return e instanceof I&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Co(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new I(e.resolve(t.anchor))}static create(e,t){return new I(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}I.prototype.visible=!1;B.jsonID("node",I);class Co{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new Is(r,r):new Co(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&I.isSelectable(r)?new I(t):B.near(t)}}class je extends B{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=A.empty){if(t==A.empty){e.delete(0,e.doc.content.size);let r=B.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new je(e)}map(e){return new je(e)}eq(e){return e instanceof je}getBookmark(){return Th}}B.jsonID("all",je);const Th={map(){return this},resolve(n){return new je(n)}};function un(n,e,t,r,s,i=!1){if(e.inlineContent)return P.create(n,t);for(let o=r-(s>0?0:1);s>0?o<e.childCount:o>=0;o+=s){let l=e.child(o);if(l.isAtom){if(!i&&I.isSelectable(l))return I.create(n,t-(s<0?l.nodeSize:0))}else{let a=un(n,l,t+s,s<0?l.childCount:0,s,i);if(a)return a}t+=l.nodeSize*s}return null}function Pl(n,e,t){let r=n.steps.length-1;if(r<e)return;let s=n.steps[r];if(!(s instanceof ce||s instanceof ue))return;let i=n.mapping.maps[r],o;i.forEach((l,a,c,u)=>{o==null&&(o=u)}),n.setSelection(B.near(n.doc.resolve(o),t))}const jl=1,yr=2,Bl=4;class Ah extends wo{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|jl)&~yr,this.storedMarks=null,this}get selectionSet(){return(this.updated&jl)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=yr,this}ensureMarks(e){return J.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&yr)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~yr,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||J.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let s=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(s.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),r=r??t,!e)return this.deleteRange(t,r);let i=this.storedMarks;if(!i){let o=this.doc.resolve(t);i=r==t?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,s.text(e,i)),this.selection.empty||this.setSelection(B.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|=Bl,this}get scrolledIntoView(){return(this.updated&Bl)>0}}function zl(n,e){return!e||!n?n:n.bind(e)}class Dn{constructor(e,t,r){this.name=e,this.init=zl(t.init,r),this.apply=zl(t.apply,r)}}const Nh=[new Dn("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Dn("selection",{init(n,e){return n.selection||B.atStart(e.doc)},apply(n){return n.selection}}),new Dn("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new Dn("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class si{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Nh.slice(),t&&t.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Dn(r.key,r.spec.state,r))})}}class hn{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=t){let s=this.config.plugins[r];if(s.spec.filterTransaction&&!s.spec.filterTransaction.call(s,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],r=this.applyInner(e),s=null;for(;;){let i=!1;for(let o=0;o<this.config.plugins.length;o++){let l=this.config.plugins[o];if(l.spec.appendTransaction){let a=s?s[o].n:0,c=s?s[o].state:this,u=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,c,r);if(u&&r.filterTransaction(u,o)){if(u.setMeta("appendedTransaction",e),!s){s=[];for(let d=0;d<this.config.plugins.length;d++)s.push(d<o?{state:r,n:t.length}:{state:this,n:0})}t.push(u),r=r.applyInner(u),i=!0}s&&(s[o]={state:r,n:t.length})}}if(!i)return{state:r,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new hn(this.config),r=this.config.fields;for(let s=0;s<r.length;s++){let i=r[s];t[i.name]=i.apply(e,this[i.name],this,t)}return t}get tr(){return new Ah(this)}static create(e){let t=new si(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new hn(t);for(let s=0;s<t.fields.length;s++)r[t.fields[s].name]=t.fields[s].init(e,r);return r}reconfigure(e){let t=new si(this.schema,e.plugins),r=t.fields,s=new hn(t);for(let i=0;i<r.length;i++){let o=r[i].name;s[o]=this.hasOwnProperty(o)?this[o]:r[i].init(e,s)}return s}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let s=e[r],i=s.spec.state;i&&i.toJSON&&(t[r]=i.toJSON.call(s,this[s.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let s=new si(e.schema,e.plugins),i=new hn(s);return s.fields.forEach(o=>{if(o.name=="doc")i.doc=Mt.fromJSON(e.schema,t.doc);else if(o.name=="selection")i.selection=B.fromJSON(i.doc,t.selection);else if(o.name=="storedMarks")t.storedMarks&&(i.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==o.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){i[o.name]=c.fromJSON.call(a,e,t[l],i);return}}i[o.name]=o.init(e,i)}}),i}}function Yc(n,e,t){for(let r in n){let s=n[r];s instanceof Function?s=s.bind(e):r=="handleDOMEvents"&&(s=Yc(s,e,{})),t[r]=s}return t}class se{constructor(e){this.spec=e,this.props={},e.props&&Yc(e.props,this,this.props),this.key=e.key?e.key.key:Xc("plugin")}getState(e){return e[this.key]}}const ii=Object.create(null);function Xc(n){return n in ii?n+"$"+ ++ii[n]:(ii[n]=0,n+"$")}class ae{constructor(e="key"){this.key=Xc(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const me=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},xn=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let zi=null;const ct=function(n,e,t){let r=zi||(zi=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},Oh=function(){zi=null},Xt=function(n,e,t,r){return t&&(Hl(n,e,t,r,-1)||Hl(n,e,t,r,1))},Rh=/^(img|br|input|textarea|hr)$/i;function Hl(n,e,t,r,s){for(var i;;){if(n==t&&e==r)return!0;if(e==(s<0?0:Fe(n))){let o=n.parentNode;if(!o||o.nodeType!=1||ar(n)||Rh.test(n.nodeName)||n.contentEditable=="false")return!1;e=me(n)+(s<0?0:1),n=o}else if(n.nodeType==1){let o=n.childNodes[e+(s<0?-1:0)];if(o.nodeType==1&&o.contentEditable=="false")if(!((i=o.pmViewDesc)===null||i===void 0)&&i.ignoreForSelection)e+=s;else return!1;else n=o,e=s<0?Fe(n):0}else return!1}}function Fe(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Lh(n,e){for(;;){if(n.nodeType==3&&e)return n;if(n.nodeType==1&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=Fe(n)}else if(n.parentNode&&!ar(n))e=me(n),n=n.parentNode;else return null}}function Dh(n,e){for(;;){if(n.nodeType==3&&e<n.nodeValue.length)return n;if(n.nodeType==1&&e<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[e],e=0}else if(n.parentNode&&!ar(n))e=me(n)+1,n=n.parentNode;else return null}}function Ih(n,e,t){for(let r=e==0,s=e==Fe(n);r||s;){if(n==t)return!0;let i=me(n);if(n=n.parentNode,!n)return!1;r=r&&i==0,s=s&&i==Fe(n)}}function ar(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const Ps=function(n){return n.focusNode&&Xt(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function jt(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function Ph(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function jh(n,e,t){if(n.caretPositionFromPoint)try{let r=n.caretPositionFromPoint(e,t);if(r)return{node:r.offsetNode,offset:Math.min(Fe(r.offsetNode),r.offset)}}catch{}if(n.caretRangeFromPoint){let r=n.caretRangeFromPoint(e,t);if(r)return{node:r.startContainer,offset:Math.min(Fe(r.startContainer),r.startOffset)}}}const et=typeof navigator<"u"?navigator:null,_l=typeof document<"u"?document:null,Lt=et&&et.userAgent||"",Hi=/Edge\/(\d+)/.exec(Lt),Qc=/MSIE \d/.exec(Lt),_i=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Lt),Re=!!(Qc||_i||Hi),Et=Qc?document.documentMode:_i?+_i[1]:Hi?+Hi[1]:0,Ke=!Re&&/gecko\/(\d+)/i.test(Lt);Ke&&+(/Firefox\/(\d+)/.exec(Lt)||[0,0])[1];const Fi=!Re&&/Chrome\/(\d+)/.exec(Lt),ke=!!Fi,Zc=Fi?+Fi[1]:0,Me=!Re&&!!et&&/Apple Computer/.test(et.vendor),kn=Me&&(/Mobile\/\w+/.test(Lt)||!!et&&et.maxTouchPoints>2),_e=kn||(et?/Mac/.test(et.platform):!1),Bh=et?/Win/.test(et.platform):!1,ut=/Android \d/.test(Lt),cr=!!_l&&"webkitFontSmoothing"in _l.documentElement.style,zh=cr?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Hh(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function st(n,e){return typeof n=="number"?n:n[e]}function _h(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,r=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*r}}function Fl(n,e,t){let r=n.someProp("scrollThreshold")||0,s=n.someProp("scrollMargin")||5,i=n.dom.ownerDocument;for(let o=t||n.dom;o;){if(o.nodeType!=1){o=xn(o);continue}let l=o,a=l==i.body,c=a?Hh(i):_h(l),u=0,d=0;if(e.top<c.top+st(r,"top")?d=-(c.top-e.top+st(s,"top")):e.bottom>c.bottom-st(r,"bottom")&&(d=e.bottom-e.top>c.bottom-c.top?e.top+st(s,"top")-c.top:e.bottom-c.bottom+st(s,"bottom")),e.left<c.left+st(r,"left")?u=-(c.left-e.left+st(s,"left")):e.right>c.right-st(r,"right")&&(u=e.right-c.right+st(s,"right")),u||d)if(a)i.defaultView.scrollBy(u,d);else{let h=l.scrollLeft,p=l.scrollTop;d&&(l.scrollTop+=d),u&&(l.scrollLeft+=u);let g=l.scrollLeft-h,y=l.scrollTop-p;e={left:e.left-g,top:e.top-y,right:e.right-g,bottom:e.bottom-y}}let f=a?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(f))break;o=f=="absolute"?o.offsetParent:xn(o)}}function Fh(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,s;for(let i=(e.left+e.right)/2,o=t+1;o<Math.min(innerHeight,e.bottom);o+=5){let l=n.root.elementFromPoint(i,o);if(!l||l==n.dom||!n.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=t-20){r=l,s=a.top;break}}return{refDOM:r,refTop:s,stack:eu(n.dom)}}function eu(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=xn(r));return e}function $h({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;tu(t,r==0?0:r-e)}function tu(n,e){for(let t=0;t<n.length;t++){let{dom:r,top:s,left:i}=n[t];r.scrollTop!=s+e&&(r.scrollTop=s+e),r.scrollLeft!=i&&(r.scrollLeft=i)}}let on=null;function Vh(n){if(n.setActive)return n.setActive();if(on)return n.focus(on);let e=eu(n);n.focus(on==null?{get preventScroll(){return on={preventScroll:!0},!0}}:void 0),on||(on=!1,tu(e,0))}function nu(n,e){let t,r=2e8,s,i=0,o=e.top,l=e.top,a,c;for(let u=n.firstChild,d=0;u;u=u.nextSibling,d++){let f;if(u.nodeType==1)f=u.getClientRects();else if(u.nodeType==3)f=ct(u).getClientRects();else continue;for(let h=0;h<f.length;h++){let p=f[h];if(p.top<=o&&p.bottom>=l){o=Math.max(p.bottom,o),l=Math.min(p.top,l);let g=p.left>e.left?p.left-e.left:p.right<e.left?e.left-p.right:0;if(g<r){t=u,r=g,s=g&&t.nodeType==3?{left:p.right<e.left?p.right:p.left,top:e.top}:e,u.nodeType==1&&g&&(i=d+(e.left>=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!a&&p.left<=e.left&&p.right>=e.left&&(a=u,c={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!t&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(i=d+1)}}return!t&&a&&(t=a,s=c,r=0),t&&t.nodeType==3?Wh(t,s):!t||r&&t.nodeType==1?{node:n,offset:i}:nu(t,s)}function Wh(n,e){let t=n.nodeValue.length,r=document.createRange();for(let s=0;s<t;s++){r.setEnd(n,s+1),r.setStart(n,s);let i=mt(r,1);if(i.top!=i.bottom&&vo(e,i))return{node:n,offset:s+(e.left>=(i.left+i.right)/2?1:0)}}return{node:n,offset:0}}function vo(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function Uh(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function Kh(n,e,t){let{node:r,offset:s}=nu(e,t),i=-1;if(r.nodeType==1&&!r.firstChild){let o=r.getBoundingClientRect();i=o.left!=o.right&&t.left>(o.left+o.right)/2?1:-1}return n.docView.posFromDOM(r,s,i)}function qh(n,e,t,r){let s=-1;for(let i=e,o=!1;i!=n.dom;){let l=n.docView.nearestDesc(i,!0),a;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&(!o&&a.left>r.left||a.top>r.top?s=l.posBefore:(!o&&a.right<r.left||a.bottom<r.top)&&(s=l.posAfter),o=!0),!l.contentDOM&&s<0&&!l.node.isText))return(l.node.isBlock?r.top<(a.top+a.bottom)/2:r.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;i=l.dom.parentNode}return s>-1?s:n.docView.posFromDOM(e,t,-1)}function ru(n,e,t){let r=n.childNodes.length;if(r&&t.top<t.bottom)for(let s=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-t.top)/(t.bottom-t.top))-2)),i=s;;){let o=n.childNodes[i];if(o.nodeType==1){let l=o.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(vo(e,c))return ru(o,e,c)}}if((i=(i+1)%r)==s)break}return n}function Gh(n,e){let t=n.dom.ownerDocument,r,s=0,i=jh(t,e.left,e.top);i&&({node:r,offset:s}=i);let o=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),l;if(!o||!n.dom.contains(o.nodeType!=1?o.parentNode:o)){let c=n.dom.getBoundingClientRect();if(!vo(e,c)||(o=ru(n.dom,e,c),!o))return null}if(Me)for(let c=o;r&&c;c=xn(c))c.draggable&&(r=void 0);if(o=Uh(o,e),r){if(Ke&&r.nodeType==1&&(s=Math.min(s,r.childNodes.length),s<r.childNodes.length)){let u=r.childNodes[s],d;u.nodeName=="IMG"&&(d=u.getBoundingClientRect()).right<=e.left&&d.bottom>e.top&&s++}let c;cr&&s&&r.nodeType==1&&(c=r.childNodes[s-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&s--,r==n.dom&&s==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(s==0||r.nodeType!=1||r.childNodes[s-1].nodeName!="BR")&&(l=qh(n,r,s,e))}l==null&&(l=Kh(n,o,e));let a=n.docView.nearestDesc(o,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function $l(n){return n.top<n.bottom||n.left<n.right}function mt(n,e){let t=n.getClientRects();if(t.length){let r=t[e<0?0:t.length-1];if($l(r))return r}return Array.prototype.find.call(t,$l)||n.getBoundingClientRect()}const Jh=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function su(n,e,t){let{node:r,offset:s,atom:i}=n.docView.domFromPos(e,t<0?-1:1),o=cr||Ke;if(r.nodeType==3)if(o&&(Jh.test(r.nodeValue)||(t<0?!s:s==r.nodeValue.length))){let a=mt(ct(r,s,s),t);if(Ke&&s&&/\s/.test(r.nodeValue[s-1])&&s<r.nodeValue.length){let c=mt(ct(r,s-1,s-1),-1);if(c.top==a.top){let u=mt(ct(r,s,s+1),-1);if(u.top!=a.top)return An(u,u.left<c.left)}}return a}else{let a=s,c=s,u=t<0?1:-1;return t<0&&!s?(c++,u=-1):t>=0&&s==r.nodeValue.length?(a--,u=1):t<0?a--:c++,An(mt(ct(r,a,c),u),u<0)}if(!n.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&s&&(t<0||s==Fe(r))){let a=r.childNodes[s-1];if(a.nodeType==1)return oi(a.getBoundingClientRect(),!1)}if(i==null&&s<Fe(r)){let a=r.childNodes[s];if(a.nodeType==1)return oi(a.getBoundingClientRect(),!0)}return oi(r.getBoundingClientRect(),t>=0)}if(i==null&&s&&(t<0||s==Fe(r))){let a=r.childNodes[s-1],c=a.nodeType==3?ct(a,Fe(a)-(o?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return An(mt(c,1),!1)}if(i==null&&s<Fe(r)){let a=r.childNodes[s];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?ct(a,0,o?0:1):a.nodeType==1?a:null:null;if(c)return An(mt(c,-1),!0)}return An(mt(r.nodeType==3?ct(r):r,-t),t>=0)}function An(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function oi(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function iu(n,e,t){let r=n.state,s=n.root.activeElement;r!=e&&n.updateState(e),s!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),s!=n.dom&&s&&s.focus()}}function Yh(n,e,t){let r=e.selection,s=t=="up"?r.$from:r.$to;return iu(n,e,()=>{let{node:i}=n.docView.domFromPos(s.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(i,!0);if(!l)break;if(l.node.isBlock){i=l.contentDOM||l.dom;break}i=l.dom.parentNode}let o=su(n,s.pos,1);for(let l=i.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=ct(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let u=a[c];if(u.bottom>u.top+1&&(t=="up"?o.top-u.top>(u.bottom-o.top)*2:u.bottom-o.bottom>(o.bottom-u.top)*2))return!1}}return!0})}const Xh=/[\u0590-\u08ac]/;function Qh(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let s=r.parentOffset,i=!s,o=s==r.parent.content.size,l=n.domSelection();return l?!Xh.test(r.parent.textContent)||!l.modify?t=="left"||t=="backward"?i:o:iu(n,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:u,anchorOffset:d}=n.domSelectionRange(),f=l.caretBidiLevel;l.modify("move",t,"character");let h=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:p,focusOffset:g}=n.domSelectionRange(),y=p&&!h.contains(p.nodeType==1?p:p.parentNode)||a==p&&c==g;try{l.collapse(u,d),a&&(a!=u||c!=d)&&l.extend&&l.extend(a,c)}catch{}return f!=null&&(l.caretBidiLevel=f),y}):r.pos==r.start()||r.pos==r.end()}let Vl=null,Wl=null,Ul=!1;function Zh(n,e,t){return Vl==e&&Wl==t?Ul:(Vl=e,Wl=t,Ul=t=="up"||t=="down"?Yh(n,e,t):Qh(n,e,t))}const $e=0,Kl=1,zt=2,tt=3;class ur{constructor(e,t,r,s){this.parent=e,this.children=t,this.dom=r,this.contentDOM=s,this.dirty=$e,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,r=this.posAtStart;;t++){let s=this.children[t];if(s==e)return r;r+=s.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let i,o;if(e==this.contentDOM)i=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.previousSibling}for(;i&&!((o=i.pmViewDesc)&&o.parent==this);)i=i.previousSibling;return i?this.posBeforeChild(o)+o.size:this.posAtStart}else{let i,o;if(e==this.contentDOM)i=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&!((o=i.pmViewDesc)&&o.parent==this);)i=i.nextSibling;return i?this.posBeforeChild(o):this.posAtEnd}let s;if(e==this.dom&&this.contentDOM)s=t>me(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))s=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let i=e;;i=i.parentNode){if(i==this.dom){s=!1;break}if(i.previousSibling)break}if(s==null&&t==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){s=!0;break}if(i.nextSibling)break}}return s??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,s=e;s;s=s.parentNode){let i=this.getDesc(s),o;if(i&&(!t||i.node))if(r&&(o=i.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))r=!1;else return i}}getDesc(e){let t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let s=e;s;s=s.parentNode){let i=this.getDesc(s);if(i)return i.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;t<this.children.length;t++){let s=this.children[t],i=r+s.size;if(r==e&&i!=r){for(;!s.border&&s.children.length;)for(let o=0;o<s.children.length;o++){let l=s.children[o];if(l.size){s=l;break}}return s}if(e<i)return s.descAt(e-r-s.border);r=i}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,s=0;for(let i=0;r<this.children.length;r++){let o=this.children[r],l=i+o.size;if(l>e||o instanceof lu){s=e-i;break}i=l}if(s)return this.children[r].domFromPos(s-this.children[r].border,t);for(let i;r&&!(i=this.children[r-1]).size&&i instanceof ou&&i.side>=0;r--);if(t<=0){let i,o=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,o=!1);return i&&t&&o&&!i.border&&!i.domAtom?i.domFromPos(i.size,t):{node:this.contentDOM,offset:i?me(i.dom)+1:0}}else{let i,o=!0;for(;i=r<this.children.length?this.children[r]:null,!(!i||i.dom.parentNode==this.contentDOM);r++,o=!1);return i&&o&&!i.border&&!i.domAtom?i.domFromPos(0,t):{node:this.contentDOM,offset:i?me(i.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let s=-1,i=-1;for(let o=r,l=0;;l++){let a=this.children[l],c=o+a.size;if(s==-1&&e<=c){let u=o+a.border;if(e>=u&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,u);e=o;for(let d=l;d>0;d--){let f=this.children[d-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){s=me(f.dom)+1;break}e-=f.size}s==-1&&(s=0)}if(s>-1&&(c>t||l==this.children.length-1)){t=c;for(let u=l+1;u<this.children.length;u++){let d=this.children[u];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(-1)){i=me(d.dom);break}t+=d.size}i==-1&&(i=this.contentDOM.childNodes.length);break}o=c}return{node:this.contentDOM,from:e,to:t,fromOffset:s,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:r}=this.domFromPos(e,0);if(t.nodeType!=1||r==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[r]}setSelection(e,t,r,s=!1){let i=Math.min(e,t),o=Math.max(e,t);for(let h=0,p=0;h<this.children.length;h++){let g=this.children[h],y=p+g.size;if(i>p&&o<y)return g.setSelection(e-p-g.border,t-p-g.border,r,s);p=y}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),c=r.root.getSelection(),u=r.domSelectionRange(),d=!1;if((Ke||Me)&&e==t){let{node:h,offset:p}=l;if(h.nodeType==3){if(d=!!(p&&h.nodeValue[p-1]==`
|
|
6
|
+
`),d&&p==h.nodeValue.length)for(let g=h,y;g;g=g.parentNode){if(y=g.nextSibling){y.nodeName=="BR"&&(l=a={node:y.parentNode,offset:me(y)+1});break}let b=g.pmViewDesc;if(b&&b.node&&b.node.isBlock)break}}else{let g=h.childNodes[p-1];d=g&&(g.nodeName=="BR"||g.contentEditable=="false")}}if(Ke&&u.focusNode&&u.focusNode!=a.node&&u.focusNode.nodeType==1){let h=u.focusNode.childNodes[u.focusOffset];h&&h.contentEditable=="false"&&(s=!0)}if(!(s||d&&Me)&&Xt(l.node,l.offset,u.anchorNode,u.anchorOffset)&&Xt(a.node,a.offset,u.focusNode,u.focusOffset))return;let f=!1;if((c.extend||e==t)&&!d){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),f=!0}catch{}}if(!f){if(e>t){let p=l;l=a,a=p}let h=document.createRange();h.setEnd(a.node,a.offset),h.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let r=0,s=0;s<this.children.length;s++){let i=this.children[s],o=r+i.size;if(r==o?e<=o&&t>=r:e<o&&t>r){let l=r+i.border,a=o-i.border;if(e>=l&&t<=a){this.dirty=e==r||t==o?zt:Kl,e==l&&t==a&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=tt:i.markDirty(e-l,t-l);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?zt:tt}r=o}this.dirty=zt}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?zt:Kl;t.dirty<r&&(t.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class ou extends ur{constructor(e,t,r,s){let i,o=t.type.toDOM;if(typeof o=="function"&&(o=o(r,()=>{if(!i)return s;if(i.parent)return i.parent.posBeforeChild(i)})),!t.type.spec.raw){if(o.nodeType!=1){let l=document.createElement("span");l.appendChild(o),o=l}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return this.dirty==$e&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class ep extends ur{constructor(e,t,r,s){super(e,[],t,null),this.textDOM=r,this.text=s}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class Qt extends ur{constructor(e,t,r,s,i){super(e,[],r,s),this.mark=t,this.spec=i}static create(e,t,r,s){let i=s.nodeViews[t.type.name],o=i&&i(t,s,r);return(!o||!o.dom)&&(o=nn.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new Qt(e,t,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&tt||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=tt&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=$e){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=$e}}slice(e,t,r){let s=Qt.create(this.parent,this.mark,!0,r),i=this.children,o=this.size;t<o&&(i=Vi(i,t,o,r)),e>0&&(i=Vi(i,0,e,r));for(let l=0;l<i.length;l++)i[l].parent=s;return s.children=i,s}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class Tt extends ur{constructor(e,t,r,s,i,o,l,a,c){super(e,[],i,o),this.node=t,this.outerDeco=r,this.innerDeco=s,this.nodeDOM=l}static create(e,t,r,s,i,o){let l=i.nodeViews[t.type.name],a,c=l&&l(t,i,()=>{if(!a)return o;if(a.parent)return a.parent.posBeforeChild(a)},r,s),u=c&&c.dom,d=c&&c.contentDOM;if(t.isText){if(!u)u=document.createTextNode(t.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:d}=nn.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!d&&!t.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),t.type.spec.draggable&&(u.draggable=!0));let f=u;return u=uu(u,r,t),c?a=new tp(e,t,r,s,u,d||null,f,c,i,o+1):t.isText?new js(e,t,r,s,u,f,i):new Tt(e,t,r,s,u,d||null,f,i,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let r=this.children[t];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>v.empty)}return e}matchesNode(e,t,r){return this.dirty==$e&&e.eq(this.node)&&Wr(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,s=t,i=e.composing?this.localCompositionInfo(e,t):null,o=i&&i.pos>-1?i:null,l=i&&i.pos<0,a=new rp(this,o&&o.node,e);op(this.node,this.innerDeco,(c,u,d)=>{c.spec.marks?a.syncToMarks(c.spec.marks,r,e):c.type.side>=0&&!d&&a.syncToMarks(u==this.node.childCount?J.none:this.node.child(u).marks,r,e),a.placeWidget(c,e,s)},(c,u,d,f)=>{a.syncToMarks(c.marks,r,e);let h;a.findNodeMatch(c,u,d,f)||l&&e.state.selection.from>s&&e.state.selection.to<s+c.nodeSize&&(h=a.findIndexWithChild(i.node))>-1&&a.updateNodeAt(c,u,d,h,e)||a.updateNextNode(c,u,d,e,f,s)||a.addNode(c,u,d,e,s),s+=c.nodeSize}),a.syncToMarks([],r,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==zt)&&(o&&this.protectLocalComposition(e,o),au(this.contentDOM,this.children,e),kn&&lp(this.dom))}localCompositionInfo(e,t){let{from:r,to:s}=e.state.selection;if(!(e.state.selection instanceof P)||r<t||s>t+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let o=i.nodeValue,l=ap(this.node.content,o,r-t,s-t);return l<0?null:{node:i,pos:l,text:o}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:s}){if(this.getDesc(t))return;let i=t;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let o=new ep(this,i,t,s);e.input.compositionNodes.push(o),this.children=Vi(this.children,r,r+s.length,e,o)}update(e,t,r,s){return this.dirty==tt||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,s),!0)}updateInner(e,t,r,s){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(s,this.posAtStart),this.dirty=$e}updateOuterDeco(e){if(Wr(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=cu(this.dom,this.nodeDOM,$i(this.outerDeco,this.node,t),$i(e,this.node,t)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.dom.draggable=!0)}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function ql(n,e,t,r,s){uu(r,e,n);let i=new Tt(void 0,n,e,t,r,r,r,s,0);return i.contentDOM&&i.updateChildren(s,0),i}class js extends Tt{constructor(e,t,r,s,i,o,l){super(e,t,r,s,i,null,o,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,s){return this.dirty==tt||this.dirty!=$e&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=$e||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,s.trackWrites==this.nodeDOM&&(s.trackWrites=null)),this.node=e,this.dirty=$e,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,r){let s=this.node.cut(e,t),i=document.createTextNode(s.text);return new js(this.parent,s,this.outerDeco,this.innerDeco,i,i,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=tt)}get domAtom(){return!1}isText(e){return this.node.text==e}}class lu extends ur{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==$e&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class tp extends Tt{constructor(e,t,r,s,i,o,l,a,c,u){super(e,t,r,s,i,o,l,c,u),this.spec=a}update(e,t,r,s){if(this.dirty==tt)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,t,r);return i&&this.updateInner(e,t,r,s),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,s)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,r,s){this.spec.setSelection?this.spec.setSelection(e,t,r.root):super.setSelection(e,t,r,s)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function au(n,e,t){let r=n.firstChild,s=!1;for(let i=0;i<e.length;i++){let o=e[i],l=o.dom;if(l.parentNode==n){for(;l!=r;)r=Gl(r),s=!0;r=r.nextSibling}else s=!0,n.insertBefore(l,r);if(o instanceof Qt){let a=r?r.previousSibling:n.lastChild;au(o.contentDOM,o.children,t),r=a?a.nextSibling:n.firstChild}}for(;r;)r=Gl(r),s=!0;s&&t.trackWrites==n&&(t.trackWrites=null)}const zn=function(n){n&&(this.nodeName=n)};zn.prototype=Object.create(null);const Ht=[new zn];function $i(n,e,t){if(n.length==0)return Ht;let r=t?Ht[0]:new zn,s=[r];for(let i=0;i<n.length;i++){let o=n[i].type.attrs;if(o){o.nodeName&&s.push(r=new zn(o.nodeName));for(let l in o){let a=o[l];a!=null&&(t&&s.length==1&&s.push(r=new zn(e.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+a:l=="style"?r.style=(r.style?r.style+";":"")+a:l!="nodeName"&&(r[l]=a))}}}return s}function cu(n,e,t,r){if(t==Ht&&r==Ht)return e;let s=e;for(let i=0;i<r.length;i++){let o=r[i],l=t[i];if(i){let a;l&&l.nodeName==o.nodeName&&s!=n&&(a=s.parentNode)&&a.nodeName.toLowerCase()==o.nodeName||(a=document.createElement(o.nodeName),a.pmIsDeco=!0,a.appendChild(s),l=Ht[0]),s=a}np(s,l||Ht[0],o)}return s}function np(n,e,t){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in t)&&n.removeAttribute(r);for(let r in t)r!="class"&&r!="style"&&r!="nodeName"&&t[r]!=e[r]&&n.setAttribute(r,t[r]);if(e.class!=t.class){let r=e.class?e.class.split(" ").filter(Boolean):[],s=t.class?t.class.split(" ").filter(Boolean):[];for(let i=0;i<r.length;i++)s.indexOf(r[i])==-1&&n.classList.remove(r[i]);for(let i=0;i<s.length;i++)r.indexOf(s[i])==-1&&n.classList.add(s[i]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,s;for(;s=r.exec(e.style);)n.style.removeProperty(s[1])}t.style&&(n.style.cssText+=t.style)}}function uu(n,e,t){return cu(n,n,Ht,$i(e,t,n.nodeType!=1))}function Wr(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].type.eq(e[t].type))return!1;return!0}function Gl(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class rp{constructor(e,t,r){this.lock=t,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=sp(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let r=e;r<t;r++)this.top.children[r].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,r){let s=0,i=this.stack.length>>1,o=Math.min(i,e.length);for(;s<o&&(s==i-1?this.top:this.stack[s+1<<1]).matchesMark(e[s])&&e[s].type.spec.spanning!==!1;)s++;for(;s<i;)this.destroyRest(),this.top.dirty=$e,this.index=this.stack.pop(),this.top=this.stack.pop(),i--;for(;i<e.length;){this.stack.push(this.top,this.index+1);let l=-1;for(let a=this.index;a<Math.min(this.index+3,this.top.children.length);a++){let c=this.top.children[a];if(c.matchesMark(e[i])&&!this.isLocked(c.dom)){l=a;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let a=Qt.create(this.top,e[i],t,r);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,i++}}findNodeMatch(e,t,r,s){let i=-1,o;if(s>=this.preMatch.index&&(o=this.preMatch.matches[s-this.preMatch.index]).parent==this.top&&o.matchesNode(e,t,r))i=this.top.children.indexOf(o,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,t,r)&&!this.preMatch.matched.has(c)){i=l;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,t,r,s,i){let o=this.top.children[s];return o.dirty==tt&&o.dom==o.contentDOM&&(o.dirty=zt),o.update(e,t,r,i)?(this.destroyBetween(this.index,s),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let s=this.index;s<this.top.children.length;s++)if(this.top.children[s]==r)return s}return-1}e=t}}updateNextNode(e,t,r,s,i,o){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof Tt){let c=this.preMatch.matched.get(a);if(c!=null&&c!=i)return!1;let u=a.dom,d,f=this.isLocked(u)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=tt&&Wr(t,a.outerDeco));if(!f&&a.update(e,t,r,s))return this.destroyBetween(this.index,l),a.dom!=u&&(this.changed=!0),this.index++,!0;if(!f&&(d=this.recreateWrapper(a,e,t,r,s,o)))return this.destroyBetween(this.index,l),this.top.children[this.index]=d,d.contentDOM&&(d.dirty=zt,d.updateChildren(s,o+1),d.dirty=$e),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,r,s,i,o){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Wr(r,e.outerDeco)||!s.eq(e.innerDeco))return null;let l=Tt.create(this.top,t,r,s,i,o);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,t,r,s,i){let o=Tt.create(this.top,e,t,r,s,i);o.contentDOM&&o.updateChildren(s,i+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,t,r){let s=this.index<this.top.children.length?this.top.children[this.index]:null;if(s&&s.matchesWidget(e)&&(e==s.widget||!s.widget.type.toDOM.parentNode))this.index++;else{let i=new ou(this.top,e,t,r);this.top.children.splice(this.index++,0,i),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Qt;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof js)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Me||ke)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let s=new lu(this.top,[],r,null);t!=this.top?t.children.push(s):t.children.splice(this.index++,0,s),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function sp(n,e){let t=e,r=t.children.length,s=n.childCount,i=new Map,o=[];e:for(;s>0;){let l;for(;;)if(r){let c=t.children[r-1];if(c instanceof Qt)t=c,r=c.children.length;else{l=c,r--;break}}else{if(t==e)break e;r=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=n.child(s-1))break;--s,i.set(l,s),o.push(l)}}return{index:s,matched:i,matches:o.reverse()}}function ip(n,e){return n.type.side-e.type.side}function op(n,e,t,r){let s=e.locals(n),i=0;if(s.length==0){for(let c=0;c<n.childCount;c++){let u=n.child(c);r(u,s,e.forChild(i,u),c),i+=u.nodeSize}return}let o=0,l=[],a=null;for(let c=0;;){let u,d;for(;o<s.length&&s[o].to==i;){let y=s[o++];y.widget&&(u?(d||(d=[u])).push(y):u=y)}if(u)if(d){d.sort(ip);for(let y=0;y<d.length;y++)t(d[y],c,!!a)}else t(u,c,!!a);let f,h;if(a)h=-1,f=a,a=null;else if(c<n.childCount)h=c,f=n.child(c++);else break;for(let y=0;y<l.length;y++)l[y].to<=i&&l.splice(y--,1);for(;o<s.length&&s[o].from<=i&&s[o].to>i;)l.push(s[o++]);let p=i+f.nodeSize;if(f.isText){let y=p;o<s.length&&s[o].from<y&&(y=s[o].from);for(let b=0;b<l.length;b++)l[b].to<y&&(y=l[b].to);y<p&&(a=f.cut(y-i),f=f.cut(0,y-i),p=y,h=-1)}else for(;o<s.length&&s[o].to<p;)o++;let g=f.isInline&&!f.isLeaf?l.filter(y=>!y.inline):l.slice();r(f,g,e.forChild(i,f),h),i=p}}function lp(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function ap(n,e,t,r){for(let s=0,i=0;s<n.childCount&&i<=r;){let o=n.child(s++),l=i;if(i+=o.nodeSize,!o.isText)continue;let a=o.text;for(;s<n.childCount;){let c=n.child(s++);if(i+=c.nodeSize,!c.isText)break;a+=c.text}if(i>=t){if(i>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l<r?a.lastIndexOf(e,r-l-1):-1;if(c>=0&&c+e.length+l>=t)return l+c;if(t==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function Vi(n,e,t,r,s){let i=[];for(let o=0,l=0;o<n.length;o++){let a=n[o],c=l,u=l+=a.size;c>=t||u<=e?i.push(a):(c<e&&i.push(a.slice(0,e-c,r)),s&&(i.push(s),s=void 0),u>t&&i.push(a.slice(t-c,a.size,r)))}return i}function Mo(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let s=n.docView.nearestDesc(t.focusNode),i=s&&s.size==0,o=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(o<0)return null;let l=r.resolve(o),a,c;if(Ps(t)){for(a=o;s&&!s.node;)s=s.parent;let d=s.node;if(s&&d.isAtom&&I.isSelectable(d)&&s.parent&&!(d.isInline&&Ih(t.focusNode,t.focusOffset,s.dom))){let f=s.posBefore;c=new I(o==f?l:r.resolve(f))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let d=o,f=o;for(let h=0;h<t.rangeCount;h++){let p=t.getRangeAt(h);d=Math.min(d,n.docView.posFromDOM(p.startContainer,p.startOffset,1)),f=Math.max(f,n.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(d<0)return null;[a,o]=f==n.state.selection.anchor?[f,d]:[d,f],l=r.resolve(o)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let u=r.resolve(a);if(!c){let d=e=="pointer"||n.state.selection.head<l.pos&&!i?1:-1;c=Eo(n,u,l,d)}return c}function du(n){return n.editable?n.hasFocus():hu(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function ft(n,e=!1){let t=n.state.selection;if(fu(n,t),!!du(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&ke){let r=n.domSelectionRange(),s=n.domObserver.currentSelection;if(r.anchorNode&&s.anchorNode&&Xt(r.anchorNode,r.anchorOffset,s.anchorNode,s.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)up(n);else{let{anchor:r,head:s}=t,i,o;Jl&&!(t instanceof P)&&(t.$from.parent.inlineContent||(i=Yl(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(o=Yl(n,t.to))),n.docView.setSelection(r,s,n,e),Jl&&(i&&Xl(i),o&&Xl(o)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&cp(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const Jl=Me||ke&&Zc<63;function Yl(n,e){let{node:t,offset:r}=n.docView.domFromPos(e,0),s=r<t.childNodes.length?t.childNodes[r]:null,i=r?t.childNodes[r-1]:null;if(Me&&s&&s.contentEditable=="false")return li(s);if((!s||s.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(s)return li(s);if(i)return li(i)}}function li(n){return n.contentEditable="true",Me&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function Xl(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function cp(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),r=t.anchorNode,s=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=r||t.anchorOffset!=s)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!du(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function up(n){let e=n.domSelection(),t=document.createRange();if(!e)return;let r=n.cursorWrapper.dom,s=r.nodeName=="IMG";s?t.setStart(r.parentNode,me(r)+1):t.setStart(r,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!s&&!n.state.selection.visible&&Re&&Et<=11&&(r.disabled=!0,r.disabled=!1)}function fu(n,e){if(e instanceof I){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(Ql(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else Ql(n)}function Ql(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function Eo(n,e,t,r){return n.someProp("createSelectionBetween",s=>s(n,e,t))||P.between(e,t,r)}function Zl(n){return n.editable&&!n.hasFocus()?!1:hu(n)}function hu(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function dp(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return Xt(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Wi(n,e){let{$anchor:t,$head:r}=n.selection,s=e>0?t.max(r):t.min(r),i=s.parent.inlineContent?s.depth?n.doc.resolve(e>0?s.after():s.before()):null:s;return i&&B.findFrom(i,e)}function gt(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function ea(n,e,t){let r=n.state.selection;if(r instanceof P)if(t.indexOf("s")>-1){let{$head:s}=r,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let o=n.state.doc.resolve(s.pos+i.nodeSize*(e<0?-1:1));return gt(n,new P(r.$anchor,o))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let s=Wi(n.state,e);return s&&s instanceof I?gt(n,s):!1}else if(!(_e&&t.indexOf("m")>-1)){let s=r.$head,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter,o;if(!i||i.isText)return!1;let l=e<0?s.pos-i.nodeSize:s.pos;return i.isAtom||(o=n.docView.descAt(l))&&!o.contentDOM?I.isSelectable(i)?gt(n,new I(e<0?n.state.doc.resolve(s.pos-i.nodeSize):s)):cr?gt(n,new P(n.state.doc.resolve(e<0?l:l+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof I&&r.node.isInline)return gt(n,new P(e>0?r.$to:r.$from));{let s=Wi(n.state,e);return s?gt(n,s):!1}}}function Ur(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Hn(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function ln(n,e){return e<0?fp(n):hp(n)}function fp(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let s,i,o=!1;for(Ke&&t.nodeType==1&&r<Ur(t)&&Hn(t.childNodes[r],-1)&&(o=!0);;)if(r>0){if(t.nodeType!=1)break;{let l=t.childNodes[r-1];if(Hn(l,-1))s=t,i=--r;else if(l.nodeType==3)t=l,r=t.nodeValue.length;else break}}else{if(pu(t))break;{let l=t.previousSibling;for(;l&&Hn(l,-1);)s=t.parentNode,i=me(l),l=l.previousSibling;if(l)t=l,r=Ur(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}o?Ui(n,t,r):s&&Ui(n,s,i)}function hp(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let s=Ur(t),i,o;for(;;)if(r<s){if(t.nodeType!=1)break;let l=t.childNodes[r];if(Hn(l,1))i=t,o=++r;else break}else{if(pu(t))break;{let l=t.nextSibling;for(;l&&Hn(l,1);)i=l.parentNode,o=me(l)+1,l=l.nextSibling;if(l)t=l,r=0,s=Ur(t);else{if(t=t.parentNode,t==n.dom)break;r=s=0}}}i&&Ui(n,i,o)}function pu(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function pp(n,e){for(;n&&e==n.childNodes.length&&!ar(n);)e=me(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=0}}function mp(n,e){for(;n&&!e&&!ar(n);)e=me(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function Ui(n,e,t){if(e.nodeType!=3){let i,o;(o=pp(e,t))?(e=o,t=0):(i=mp(e,t))&&(e=i,t=i.nodeValue.length)}let r=n.domSelection();if(!r)return;if(Ps(r)){let i=document.createRange();i.setEnd(e,t),i.setStart(e,t),r.removeAllRanges(),r.addRange(i)}else r.extend&&r.extend(e,t);n.domObserver.setCurSelection();let{state:s}=n;setTimeout(()=>{n.state==s&&ft(n)},50)}function ta(n,e){let t=n.state.doc.resolve(e);if(!(ke||Bh)&&t.parent.inlineContent){let s=n.coordsAtPos(e);if(e>t.start()){let i=n.coordsAtPos(e-1),o=(i.top+i.bottom)/2;if(o>s.top&&o<s.bottom&&Math.abs(i.left-s.left)>1)return i.left<s.left?"ltr":"rtl"}if(e<t.end()){let i=n.coordsAtPos(e+1),o=(i.top+i.bottom)/2;if(o>s.top&&o<s.bottom&&Math.abs(i.left-s.left)>1)return i.left>s.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function na(n,e,t){let r=n.state.selection;if(r instanceof P&&!r.empty||t.indexOf("s")>-1||_e&&t.indexOf("m")>-1)return!1;let{$from:s,$to:i}=r;if(!s.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let o=Wi(n.state,e);if(o&&o instanceof I)return gt(n,o)}if(!s.parent.inlineContent){let o=e<0?s:i,l=r instanceof je?B.near(o,e):B.findFrom(o,e);return l?gt(n,l):!1}return!1}function ra(n,e){if(!(n.state.selection instanceof P))return!0;let{$head:t,$anchor:r,empty:s}=n.state.selection;if(!t.sameParent(r))return!0;if(!s)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(i&&!i.isText){let o=n.state.tr;return e<0?o.delete(t.pos-i.nodeSize,t.pos):o.delete(t.pos,t.pos+i.nodeSize),n.dispatch(o),!0}return!1}function sa(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function gp(n){if(!Me||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;sa(n,r,"true"),setTimeout(()=>sa(n,r,"false"),20)}return!1}function yp(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function bp(n,e){let t=e.keyCode,r=yp(e);if(t==8||_e&&t==72&&r=="c")return ra(n,-1)||ln(n,-1);if(t==46&&!e.shiftKey||_e&&t==68&&r=="c")return ra(n,1)||ln(n,1);if(t==13||t==27)return!0;if(t==37||_e&&t==66&&r=="c"){let s=t==37?ta(n,n.state.selection.from)=="ltr"?-1:1:-1;return ea(n,s,r)||ln(n,s)}else if(t==39||_e&&t==70&&r=="c"){let s=t==39?ta(n,n.state.selection.from)=="ltr"?1:-1:1;return ea(n,s,r)||ln(n,s)}else{if(t==38||_e&&t==80&&r=="c")return na(n,-1,r)||ln(n,-1);if(t==40||_e&&t==78&&r=="c")return gp(n)||na(n,1,r)||ln(n,1);if(r==(_e?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function To(n,e){n.someProp("transformCopied",h=>{e=h(e,n)});let t=[],{content:r,openStart:s,openEnd:i}=e;for(;s>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){s--,i--;let h=r.firstChild;t.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let o=n.someProp("clipboardSerializer")||nn.fromSchema(n.state.schema),l=ku(),a=l.createElement("div");a.appendChild(o.serializeFragment(r,{document:l}));let c=a.firstChild,u,d=0;for(;c&&c.nodeType==1&&(u=xu[c.nodeName.toLowerCase()]);){for(let h=u.length-1;h>=0;h--){let p=l.createElement(u[h]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),d++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${s} ${i}${d?` -${d}`:""} ${JSON.stringify(t)}`);let f=n.someProp("clipboardTextSerializer",h=>h(e,n))||e.content.textBetween(0,e.content.size,`
|
|
7
|
+
|
|
8
|
+
`);return{dom:a,text:f,slice:e}}function mu(n,e,t,r,s){let i=s.parent.type.spec.code,o,l;if(!t&&!e)return null;let a=e&&(r||i||!t);if(a){if(n.someProp("transformPastedText",f=>{e=f(e,i||r,n)}),i)return e?new A(v.from(n.state.schema.text(e.replace(/\r\n?/g,`
|
|
9
|
+
`))),0,0):A.empty;let d=n.someProp("clipboardTextParser",f=>f(e,s,r,n));if(d)l=d;else{let f=s.marks(),{schema:h}=n.state,p=nn.fromSchema(h);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(g=>{let y=o.appendChild(document.createElement("p"));g&&y.appendChild(p.serializeNode(h.text(g,f)))})}}else n.someProp("transformPastedHTML",d=>{t=d(t,n)}),o=wp(t),cr&&Cp(o);let c=o&&o.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let d=+u[3];d>0;d--){let f=o.firstChild;for(;f&&f.nodeType!=1;)f=f.nextSibling;if(!f)break;o=f}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||jn.fromSchema(n.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||u),context:s,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!xp.test(f.parentNode.nodeName)?{ignore:!0}:null}})),u)l=vp(ia(l,+u[1],+u[2]),u[4]);else if(l=A.maxOpen(kp(l.content,s),!0),l.openStart||l.openEnd){let d=0,f=0;for(let h=l.content.firstChild;d<l.openStart&&!h.type.spec.isolating;d++,h=h.firstChild);for(let h=l.content.lastChild;f<l.openEnd&&!h.type.spec.isolating;f++,h=h.lastChild);l=ia(l,d,f)}return n.someProp("transformPasted",d=>{l=d(l,n)}),l}const xp=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function kp(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let s=e.node(t).contentMatchAt(e.index(t)),i,o=[];if(n.forEach(l=>{if(!o)return;let a=s.findWrapping(l.type),c;if(!a)return o=null;if(c=o.length&&i.length&&yu(a,i,l,o[o.length-1],0))o[o.length-1]=c;else{o.length&&(o[o.length-1]=bu(o[o.length-1],i.length));let u=gu(l,a);o.push(u),s=s.matchType(u.type),i=a}}),o)return v.from(o)}return n}function gu(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,v.from(n));return n}function yu(n,e,t,r,s){if(s<n.length&&s<e.length&&n[s]==e[s]){let i=yu(n,e,t,r.lastChild,s+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(s==n.length-1?t.type:n[s+1]))return r.copy(r.content.append(v.from(gu(t,n,s+1))))}}function bu(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,bu(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(v.empty,!0);return n.copy(t.append(r))}function Ki(n,e,t,r,s,i){let o=e<0?n.firstChild:n.lastChild,l=o.content;return n.childCount>1&&(i=0),s<r-1&&(l=Ki(l,e,t,r,s+1,i)),s>=t&&(l=e<0?o.contentMatchAt(0).fillBefore(l,i<=s).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(v.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,o.copy(l))}function ia(n,e,t){return e<n.openStart&&(n=new A(Ki(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new A(Ki(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const xu={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let oa=null;function ku(){return oa||(oa=document.implementation.createHTMLDocument("title"))}let ai=null;function Sp(n){let e=window.trustedTypes;return e?(ai||(ai=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),ai.createHTML(n)):n}function wp(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=ku().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),s;if((s=r&&xu[r[1].toLowerCase()])&&(n=s.map(i=>"<"+i+">").join("")+n+s.map(i=>"</"+i+">").reverse().join("")),t.innerHTML=Sp(n),s)for(let i=0;i<s.length;i++)t=t.querySelector(s[i])||t;return t}function Cp(n){let e=n.querySelectorAll(ke?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let r=e[t];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function vp(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:s,openStart:i,openEnd:o}=n;for(let l=r.length-2;l>=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;s=v.from(a.create(r[l+1],s)),i++,o++}return new A(s,i,o)}const Ee={},Te={},Mp={touchstart:!0,touchmove:!0};class Ep{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function Tp(n){for(let e in Ee){let t=Ee[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{Np(n,r)&&!Ao(n,r)&&(n.editable||!(r.type in Te))&&t(n,r)},Mp[e]?{passive:!0}:void 0)}Me&&n.dom.addEventListener("input",()=>null),qi(n)}function Ct(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function Ap(n){n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function qi(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>Ao(n,r))})}function Ao(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function Np(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function Op(n,e){!Ao(n,e)&&Ee[e.type]&&(n.editable||!(e.type in Te))&&Ee[e.type](n,e)}Te.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!wu(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(ut&&ke&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),kn&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",s=>s(n,jt(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||bp(n,t)?t.preventDefault():Ct(n,"key")};Te.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};Te.keypress=(n,e)=>{let t=e;if(wu(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||_e&&t.metaKey)return;if(n.someProp("handleKeyPress",s=>s(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof P)||!r.$from.sameParent(r.$to)){let s=String.fromCharCode(t.charCode),i=()=>n.state.tr.insertText(s).scrollIntoView();!/[\r\n]/.test(s)&&!n.someProp("handleTextInput",o=>o(n,r.$from.pos,r.$to.pos,s,i))&&n.dispatch(i()),t.preventDefault()}};function Bs(n){return{left:n.clientX,top:n.clientY}}function Rp(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function No(n,e,t,r,s){if(r==-1)return!1;let i=n.state.doc.resolve(r);for(let o=i.depth+1;o>0;o--)if(n.someProp(e,l=>o>i.depth?l(n,t,i.nodeAfter,i.before(o),s,!0):l(n,t,i.node(o),i.before(o),s,!1)))return!0;return!1}function gn(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);r.setMeta("pointer",!0),n.dispatch(r)}function Lp(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&I.isSelectable(r)?(gn(n,new I(t)),!0):!1}function Dp(n,e){if(e==-1)return!1;let t=n.state.selection,r,s;t instanceof I&&(r=t.node);let i=n.state.doc.resolve(e);for(let o=i.depth+1;o>0;o--){let l=o>i.depth?i.nodeAfter:i.node(o);if(I.isSelectable(l)){r&&t.$from.depth>0&&o>=t.$from.depth&&i.before(t.$from.depth+1)==t.$from.pos?s=i.before(t.$from.depth):s=i.before(o);break}}return s!=null?(gn(n,I.create(n.state.doc,s)),!0):!1}function Ip(n,e,t,r,s){return No(n,"handleClickOn",e,t,r)||n.someProp("handleClick",i=>i(n,e,r))||(s?Dp(n,t):Lp(n,t))}function Pp(n,e,t,r){return No(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",s=>s(n,e,r))}function jp(n,e,t,r){return No(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",s=>s(n,e,r))||Bp(n,t,r)}function Bp(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(gn(n,P.create(r,0,r.content.size)),!0):!1;let s=r.resolve(e);for(let i=s.depth+1;i>0;i--){let o=i>s.depth?s.nodeAfter:s.node(i),l=s.before(i);if(o.inlineContent)gn(n,P.create(r,l+1,l+1+o.content.size));else if(I.isSelectable(o))gn(n,I.create(r,l));else continue;return!0}}function Oo(n){return Kr(n)}const Su=_e?"metaKey":"ctrlKey";Ee.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=Oo(n),s=Date.now(),i="singleClick";s-n.input.lastClick.time<500&&Rp(t,n.input.lastClick)&&!t[Su]&&n.input.lastClick.button==t.button&&(n.input.lastClick.type=="singleClick"?i="doubleClick":n.input.lastClick.type=="doubleClick"&&(i="tripleClick")),n.input.lastClick={time:s,x:t.clientX,y:t.clientY,type:i,button:t.button};let o=n.posAtCoords(Bs(t));o&&(i=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new zp(n,o,t,!!r)):(i=="doubleClick"?Pp:jp)(n,o.pos,o.inside,t)?t.preventDefault():Ct(n,"pointer"))};class zp{constructor(e,t,r,s){this.view=e,this.pos=t,this.event=r,this.flushed=s,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[Su],this.allowDefault=r.shiftKey;let i,o;if(t.inside>-1)i=e.state.doc.nodeAt(t.inside),o=t.inside;else{let u=e.state.doc.resolve(t.pos);i=u.parent,o=u.depth?u.before():0}const l=s?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.dom.nodeType==1?a.dom:null;let{selection:c}=e.state;(r.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof I&&c.from<=o&&c.to>o)&&(this.mightDrag={node:i,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Ke&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),Ct(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>ft(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(Bs(e))),this.updateAllowDefault(e),this.allowDefault||!t?Ct(this.view,"pointer"):Ip(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Me&&this.mightDrag&&!this.mightDrag.node.isAtom||ke&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(gn(this.view,B.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):Ct(this.view,"pointer")}move(e){this.updateAllowDefault(e),Ct(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}Ee.touchstart=n=>{n.input.lastTouch=Date.now(),Oo(n),Ct(n,"pointer")};Ee.touchmove=n=>{n.input.lastTouch=Date.now(),Ct(n,"pointer")};Ee.contextmenu=n=>Oo(n);function wu(n,e){return n.composing?!0:Me&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const Hp=ut?5e3:-1;Te.compositionstart=Te.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof P&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),Kr(n,!0),n.markCursor=null;else if(Kr(n,!e.selection.empty),Ke&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let s=r.focusNode,i=r.focusOffset;s&&s.nodeType==1&&i!=0;){let o=i<0?s.lastChild:s.childNodes[i-1];if(!o)break;if(o.nodeType==3){let l=n.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else s=o,i=-1}}n.input.composing=!0}Cu(n,Hp)};Te.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,Cu(n,20))};function Cu(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>Kr(n),e))}function vu(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Fp());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function _p(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=Lh(e.focusNode,e.focusOffset),r=Dh(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let s=r.pmViewDesc,i=n.domObserver.lastChangedTextNode;if(t==i||r==i)return i;if(!s||!s.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let o=t.pmViewDesc;if(!(!o||!o.isText(t.nodeValue)))return r}}return t||r}function Fp(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function Kr(n,e=!1){if(!(ut&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),vu(n),e||n.docView&&n.docView.dirty){let t=Mo(n),r=n.state.selection;return t&&!t.eq(r)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function $p(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),s=document.createRange();s.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(s),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const Xn=Re&&Et<15||kn&&zh<604;Ee.copy=Te.cut=(n,e)=>{let t=e,r=n.state.selection,s=t.type=="cut";if(r.empty)return;let i=Xn?null:t.clipboardData,o=r.content(),{dom:l,text:a}=To(n,o);i?(t.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):$p(n,l),s&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Vp(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function Wp(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let s=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?Qn(n,r.value,null,s,e):Qn(n,r.textContent,r.innerHTML,s,e)},50)}function Qn(n,e,t,r,s){let i=mu(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,s,i||A.empty)))return!0;if(!i)return!1;let o=Vp(i),l=o?n.state.tr.replaceSelectionWith(o,r):n.state.tr.replaceSelection(i);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Mu(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}Te.paste=(n,e)=>{let t=e;if(n.composing&&!ut)return;let r=Xn?null:t.clipboardData,s=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&Qn(n,Mu(r),r.getData("text/html"),s,t)?t.preventDefault():Wp(n,t)};class Eu{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}}const Up=_e?"altKey":"ctrlKey";function Tu(n,e){let t=n.someProp("dragCopies",r=>!r(e));return t??!e[Up]}Ee.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let s=n.state.selection,i=s.empty?null:n.posAtCoords(Bs(t)),o;if(!(i&&i.pos>=s.from&&i.pos<=(s instanceof I?s.to-1:s.to))){if(r&&r.mightDrag)o=I.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let d=n.docView.nearestDesc(t.target,!0);d&&d.node.type.spec.draggable&&d!=n.docView&&(o=I.create(n.state.doc,d.posBefore))}}let l=(o||n.state.selection).content(),{dom:a,text:c,slice:u}=To(n,l);(!t.dataTransfer.files.length||!ke||Zc>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Xn?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",Xn||t.dataTransfer.setData("text/plain",c),n.dragging=new Eu(u,Tu(n,t),o)};Ee.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};Te.dragover=Te.dragenter=(n,e)=>e.preventDefault();Te.drop=(n,e)=>{let t=e,r=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let s=n.posAtCoords(Bs(t));if(!s)return;let i=n.state.doc.resolve(s.pos),o=r&&r.slice;o?n.someProp("transformPasted",p=>{o=p(o,n)}):o=mu(n,Mu(t.dataTransfer),Xn?null:t.dataTransfer.getData("text/html"),!1,i);let l=!!(r&&Tu(n,t));if(n.someProp("handleDrop",p=>p(n,t,o||A.empty,l))){t.preventDefault();return}if(!o)return;t.preventDefault();let a=o?Wc(n.state.doc,i.pos,o):i.pos;a==null&&(a=i.pos);let c=n.state.tr;if(l){let{node:p}=r;p?p.replace(c):c.deleteSelection()}let u=c.mapping.map(a),d=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,f=c.doc;if(d?c.replaceRangeWith(u,u,o.content.firstChild):c.replaceRange(u,u,o),c.doc.eq(f))return;let h=c.doc.resolve(u);if(d&&I.isSelectable(o.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(o.content.firstChild))c.setSelection(new I(h));else{let p=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((g,y,b,x)=>p=x),c.setSelection(Eo(n,h,c.doc.resolve(p)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))};Ee.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&ft(n)},20))};Ee.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)};Ee.beforeinput=(n,e)=>{if(ke&&ut&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",i=>i(n,jt(8,"Backspace")))))return;let{$cursor:s}=n.state.selection;s&&s.pos>0&&n.dispatch(n.state.tr.delete(s.pos-1,s.pos).scrollIntoView())},50)}};for(let n in Te)Ee[n]=Te[n];function Zn(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}class qr{constructor(e,t){this.toDOM=e,this.spec=t||Ut,this.side=this.spec.side||0}map(e,t,r,s){let{pos:i,deleted:o}=e.mapResult(t.from+s,this.side<0?-1:1);return o?null:new ye(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof qr&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Zn(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class At{constructor(e,t){this.attrs=e,this.spec=t||Ut}map(e,t,r,s){let i=e.map(t.from+s,this.spec.inclusiveStart?-1:1)-r,o=e.map(t.to+s,this.spec.inclusiveEnd?1:-1)-r;return i>=o?null:new ye(i,o,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof At&&Zn(this.attrs,e.attrs)&&Zn(this.spec,e.spec)}static is(e){return e.type instanceof At}destroy(){}}class Ro{constructor(e,t){this.attrs=e,this.spec=t||Ut}map(e,t,r,s){let i=e.mapResult(t.from+s,1);if(i.deleted)return null;let o=e.mapResult(t.to+s,-1);return o.deleted||o.pos<=i.pos?null:new ye(i.pos-r,o.pos-r,this)}valid(e,t){let{index:r,offset:s}=e.content.findIndex(t.from),i;return s==t.from&&!(i=e.child(r)).isText&&s+i.nodeSize==t.to}eq(e){return this==e||e instanceof Ro&&Zn(this.attrs,e.attrs)&&Zn(this.spec,e.spec)}destroy(){}}class ye{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new ye(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new ye(e,e,new qr(t,r))}static inline(e,t,r,s){return new ye(e,t,new At(r,s))}static node(e,t,r,s){return new ye(e,t,new Ro(r,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof At}get widget(){return this.type instanceof qr}}const dn=[],Ut={};class ee{constructor(e,t){this.local=e.length?e:dn,this.children=t.length?t:dn}static create(e,t){return t.length?Gr(t,e,0,Ut):xe}find(e,t,r){let s=[];return this.findInner(e??0,t??1e9,s,0,r),s}findInner(e,t,r,s,i){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=t&&l.to>=e&&(!i||i(l.spec))&&r.push(l.copy(l.from+s,l.to+s))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<t&&this.children[o+1]>e){let l=this.children[o]+1;this.children[o+2].findInner(e-l,t-l,r,s+l,i)}}map(e,t,r){return this==xe||e.maps.length==0?this:this.mapInner(e,t,0,0,r||Ut)}mapInner(e,t,r,s,i){let o;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,s);a&&a.type.valid(t,a)?(o||(o=[])).push(a):i.onRemove&&i.onRemove(this.local[l].spec)}return this.children.length?Kp(this.children,o||[],e,t,r,s,i):o?new ee(o.sort(Kt),dn):xe}add(e,t){return t.length?this==xe?ee.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let s,i=0;e.forEach((l,a)=>{let c=a+r,u;if(u=Nu(t,l,c)){for(s||(s=this.children.slice());i<s.length&&s[i]<a;)i+=3;s[i]==a?s[i+2]=s[i+2].addInner(l,u,c+1):s.splice(i,0,a,a+l.nodeSize,Gr(u,l,c+1,Ut)),i+=3}});let o=Au(i?Ou(t):t,-r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new ee(o.length?this.local.concat(o).sort(Kt):this.local,s||this.children)}remove(e){return e.length==0||this==xe?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,s=this.local;for(let i=0;i<r.length;i+=3){let o,l=r[i]+t,a=r[i+1]+t;for(let u=0,d;u<e.length;u++)(d=e[u])&&d.from>l&&d.to<a&&(e[u]=null,(o||(o=[])).push(d));if(!o)continue;r==this.children&&(r=this.children.slice());let c=r[i+2].removeInner(o,l+1);c!=xe?r[i+2]=c:(r.splice(i,3),i-=3)}if(s.length){for(let i=0,o;i<e.length;i++)if(o=e[i])for(let l=0;l<s.length;l++)s[l].eq(o,t)&&(s==this.local&&(s=this.local.slice()),s.splice(l--,1))}return r==this.children&&s==this.local?this:s.length||r.length?new ee(s,r):xe}forChild(e,t){if(this==xe)return this;if(t.isLeaf)return ee.empty;let r,s;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let i=e+1,o=i+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<o&&a.to>i&&a.type instanceof At){let c=Math.max(i,a.from)-i,u=Math.min(o,a.to)-i;c<u&&(s||(s=[])).push(a.copy(c,u))}}if(s){let l=new ee(s.sort(Kt),dn);return r?new xt([l,r]):l}return r||xe}eq(e){if(this==e)return!0;if(!(e instanceof ee)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return Lo(this.localsInner(e))}localsInner(e){if(this==xe)return dn;if(e.inlineContent||!this.local.some(At.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof At||t.push(this.local[r]);return t}forEachSet(e){e(this)}}ee.empty=new ee([],[]);ee.removeOverlap=Lo;const xe=ee.empty;class xt{constructor(e){this.members=e}map(e,t){const r=this.members.map(s=>s.map(e,t,Ut));return xt.from(r)}forChild(e,t){if(t.isLeaf)return ee.empty;let r=[];for(let s=0;s<this.members.length;s++){let i=this.members[s].forChild(e,t);i!=xe&&(i instanceof xt?r=r.concat(i.members):r.push(i))}return xt.from(r)}eq(e){if(!(e instanceof xt)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,r=!0;for(let s=0;s<this.members.length;s++){let i=this.members[s].localsInner(e);if(i.length)if(!t)t=i;else{r&&(t=t.slice(),r=!1);for(let o=0;o<i.length;o++)t.push(i[o])}}return t?Lo(r?t:t.sort(Kt)):dn}static from(e){switch(e.length){case 0:return xe;case 1:return e[0];default:return new xt(e.every(t=>t instanceof ee)?e:e.reduce((t,r)=>t.concat(r instanceof ee?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function Kp(n,e,t,r,s,i,o){let l=n.slice();for(let c=0,u=i;c<t.maps.length;c++){let d=0;t.maps[c].forEach((f,h,p,g)=>{let y=g-p-(h-f);for(let b=0;b<l.length;b+=3){let x=l[b+1];if(x<0||f>x+u-d)continue;let C=l[b]+u-d;h>=C?l[b+1]=f<=C?-2:-1:f>=u&&y&&(l[b]+=y,l[b+1]+=y)}d+=y}),u=t.maps[c].map(u,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let u=t.map(n[c]+i),d=u-s;if(d<0||d>=r.content.size){a=!0;continue}let f=t.map(n[c+1]+i,-1),h=f-s,{index:p,offset:g}=r.content.findIndex(d),y=r.maybeChild(p);if(y&&g==d&&g+y.nodeSize==h){let b=l[c+2].mapInner(t,y,u+1,n[c]+i+1,o);b!=xe?(l[c]=d,l[c+1]=h,l[c+2]=b):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=qp(l,n,e,t,s,i,o),u=Gr(c,r,0,o);e=u.local;for(let d=0;d<l.length;d+=3)l[d+1]<0&&(l.splice(d,3),d-=3);for(let d=0,f=0;d<u.children.length;d+=3){let h=u.children[d];for(;f<l.length&&l[f]<h;)f+=3;l.splice(f,0,u.children[d],u.children[d+1],u.children[d+2])}}return new ee(e.sort(Kt),l)}function Au(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let s=n[r];t.push(new ye(s.from+e,s.to+e,s.type))}return t}function qp(n,e,t,r,s,i,o){function l(a,c){for(let u=0;u<a.local.length;u++){let d=a.local[u].map(r,s,c);d?t.push(d):o.onRemove&&o.onRemove(a.local[u].spec)}for(let u=0;u<a.children.length;u+=3)l(a.children[u+2],a.children[u]+c+1)}for(let a=0;a<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+i+1);return t}function Nu(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,s=null;for(let i=0,o;i<n.length;i++)(o=n[i])&&o.from>t&&o.to<r&&((s||(s=[])).push(o),n[i]=null);return s}function Ou(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function Gr(n,e,t,r){let s=[],i=!1;e.forEach((l,a)=>{let c=Nu(n,l,a+t);if(c){i=!0;let u=Gr(c,l,t+a+1,r);u!=xe&&s.push(a,a+l.nodeSize,u)}});let o=Au(i?Ou(n):n,-t).sort(Kt);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||(r.onRemove&&r.onRemove(o[l].spec),o.splice(l--,1));return o.length||s.length?new ee(o,s):xe}function Kt(n,e){return n.from-e.from||n.to-e.to}function Lo(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let s=t+1;s<e.length;s++){let i=e[s];if(i.from==r.from){i.to!=r.to&&(e==n&&(e=n.slice()),e[s]=i.copy(i.from,r.to),la(e,s+1,i.copy(r.to,i.to)));continue}else{i.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,i.from),la(e,s,r.copy(i.from,r.to)));break}}}return e}function la(n,e,t){for(;e<n.length&&Kt(t,n[e])>0;)e++;n.splice(e,0,t)}function ci(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=xe&&e.push(r)}),n.cursorWrapper&&e.push(ee.create(n.state.doc,[n.cursorWrapper.deco])),xt.from(e)}const Gp={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Jp=Re&&Et<=11;class Yp{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class Xp{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Yp,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let s=0;s<r.length;s++)this.queue.push(r[s]);Re&&Et<=11&&r.some(s=>s.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():this.flush()}),Jp&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,Gp)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(Zl(this.view)){if(this.suppressingSelectionUpdates)return ft(this.view);if(Re&&Et<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Xt(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,r;for(let i=e.focusNode;i;i=xn(i))t.add(i);for(let i=e.anchorNode;i;i=xn(i))if(t.has(i)){r=i;break}let s=r&&this.view.docView.nearestDesc(r);if(s&&s.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let r=e.domSelectionRange(),s=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&Zl(e)&&!this.ignoreSelectionChange(r),i=-1,o=-1,l=!1,a=[];if(e.editable)for(let u=0;u<t.length;u++){let d=this.registerMutation(t[u],a);d&&(i=i<0?d.from:Math.min(d.from,i),o=o<0?d.to:Math.max(d.to,o),d.typeOver&&(l=!0))}if(Ke&&a.length){let u=a.filter(d=>d.nodeName=="BR");if(u.length==2){let[d,f]=u;d.parentNode&&d.parentNode.parentNode==f.parentNode?f.remove():d.remove()}else{let{focusNode:d}=this.currentSelection;for(let f of u){let h=f.parentNode;h&&h.nodeName=="LI"&&(!d||em(e,d)!=h)&&f.remove()}}}let c=null;i<0&&s&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Ps(r)&&(c=Mo(e))&&c.eq(B.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,ft(e),this.currentSelection.set(r),e.scrollToSelection()):(i>-1||s)&&(i>-1&&(e.docView.markDirty(i,o),Qp(e)),this.handleDOMChange(i,o,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||ft(e),this.currentSelection.set(r))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let u=0;u<e.addedNodes.length;u++){let d=e.addedNodes[u];t.push(d),d.nodeType==3&&(this.lastChangedTextNode=d)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let s=e.previousSibling,i=e.nextSibling;if(Re&&Et<=11&&e.addedNodes.length)for(let u=0;u<e.addedNodes.length;u++){let{previousSibling:d,nextSibling:f}=e.addedNodes[u];(!d||Array.prototype.indexOf.call(e.addedNodes,d)<0)&&(s=d),(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(i=f)}let o=s&&s.parentNode==e.target?me(s)+1:0,l=r.localPosFromDOM(e.target,o,-1),a=i&&i.parentNode==e.target?me(i):e.target.childNodes.length,c=r.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let aa=new WeakMap,ca=!1;function Qp(n){if(!aa.has(n)&&(aa.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=Ke,ca)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),ca=!0}}function ua(n,e){let t=e.startContainer,r=e.startOffset,s=e.endContainer,i=e.endOffset,o=n.domAtPos(n.state.selection.anchor);return Xt(o.node,o.offset,s,i)&&([t,r,s,i]=[s,i,t,r]),{anchorNode:t,anchorOffset:r,focusNode:s,focusOffset:i}}function Zp(n,e){if(e.getComposedRanges){let s=e.getComposedRanges(n.root)[0];if(s)return ua(n,s)}let t;function r(s){s.preventDefault(),s.stopImmediatePropagation(),t=s.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",r,!0),t?ua(n,t):null}function em(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let r=n.docView.nearestDesc(t,!0);if(r&&r.node.isBlock)return t}return null}function tm(n,e,t){let{node:r,fromOffset:s,toOffset:i,from:o,to:l}=n.docView.parseRange(e,t),a=n.domSelectionRange(),c,u=a.anchorNode;if(u&&n.dom.contains(u.nodeType==1?u:u.parentNode)&&(c=[{node:u,offset:a.anchorOffset}],Ps(a)||c.push({node:a.focusNode,offset:a.focusOffset})),ke&&n.input.lastKeyCode===8)for(let y=i;y>s;y--){let b=r.childNodes[y-1],x=b.pmViewDesc;if(b.nodeName=="BR"&&!x){i=y;break}if(!x||x.size)break}let d=n.state.doc,f=n.someProp("domParser")||jn.fromSchema(n.state.schema),h=d.resolve(o),p=null,g=f.parse(r,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:s,to:i,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:nm,context:h});if(c&&c[0].pos!=null){let y=c[0].pos,b=c[1]&&c[1].pos;b==null&&(b=y),p={anchor:y+o,head:b+o}}return{doc:g,sel:p,from:o,to:l}}function nm(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(Me&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(n.parentNode.lastChild==n||Me&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}const rm=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function sm(n,e,t,r,s){let i=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let w=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,j=Mo(n,w);if(j&&!n.state.selection.eq(j)){if(ke&&ut&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",Ae=>Ae(n,jt(13,"Enter"))))return;let G=n.state.tr.setSelection(j);w=="pointer"?G.setMeta("pointer",!0):w=="key"&&G.scrollIntoView(),i&&G.setMeta("composition",i),n.dispatch(G)}return}let o=n.state.doc.resolve(e),l=o.sharedDepth(t);e=o.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,c=tm(n,e,t),u=n.state.doc,d=u.slice(c.from,c.to),f,h;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(f=n.state.selection.to,h="end"):(f=n.state.selection.from,h="start"),n.input.lastKeyCode=null;let p=lm(d.content,c.doc.content,c.from,f,h);if(p&&n.input.domChangeCount++,(kn&&n.input.lastIOSEnter>Date.now()-225||ut)&&s.some(w=>w.nodeType==1&&!rm.test(w.nodeName))&&(!p||p.endA>=p.endB)&&n.someProp("handleKeyDown",w=>w(n,jt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!p)if(r&&a instanceof P&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let w=da(n,n.state.doc,c.sel);if(w&&!w.eq(n.state.selection)){let j=n.state.tr.setSelection(w);i&&j.setMeta("composition",i),n.dispatch(j)}}return}n.state.selection.from<n.state.selection.to&&p.start==p.endB&&n.state.selection instanceof P&&(p.start>n.state.selection.from&&p.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?p.start=n.state.selection.from:p.endA<n.state.selection.to&&p.endA>=n.state.selection.to-2&&n.state.selection.to<=c.to&&(p.endB+=n.state.selection.to-p.endA,p.endA=n.state.selection.to)),Re&&Et<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)==" "&&(p.start--,p.endA--,p.endB--);let g=c.doc.resolveNoCache(p.start-c.from),y=c.doc.resolveNoCache(p.endB-c.from),b=u.resolve(p.start),x=g.sameParent(y)&&g.parent.inlineContent&&b.end()>=p.endA,C;if((kn&&n.input.lastIOSEnter>Date.now()-225&&(!x||s.some(w=>w.nodeName=="DIV"||w.nodeName=="P"))||!x&&g.pos<c.doc.content.size&&(!g.sameParent(y)||!g.parent.inlineContent)&&!/\S/.test(c.doc.textBetween(g.pos,y.pos,"",""))&&(C=B.findFrom(c.doc.resolve(g.pos+1),1,!0))&&C.head>g.pos)&&n.someProp("handleKeyDown",w=>w(n,jt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>p.start&&om(u,p.start,p.endA,g,y)&&n.someProp("handleKeyDown",w=>w(n,jt(8,"Backspace")))){ut&&ke&&n.domObserver.suppressSelectionUpdates();return}ke&&p.endB==p.start&&(n.input.lastChromeDelete=Date.now()),ut&&!x&&g.start()!=y.start()&&y.parentOffset==0&&g.depth==y.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,y=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{n.someProp("handleKeyDown",function(w){return w(n,jt(13,"Enter"))})},20));let k=p.start,M=p.endA,R=w=>{let j=w||n.state.tr.replace(k,M,c.doc.slice(p.start-c.from,p.endB-c.from));if(c.sel){let G=da(n,j.doc,c.sel);G&&!(ke&&n.composing&&G.empty&&(p.start!=p.endB||n.input.lastChromeDelete<Date.now()-100)&&(G.head==k||G.head==j.mapping.map(M)-1)||Re&&G.empty&&G.head==k)&&j.setSelection(G)}return i&&j.setMeta("composition",i),j.scrollIntoView()},z;if(x){if(g.pos==y.pos){Re&&Et<=11&&g.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>ft(n),20));let w=R(n.state.tr.delete(k,M)),j=u.resolve(p.start).marksAcross(u.resolve(p.endA));j&&w.ensureMarks(j),n.dispatch(w)}else if(p.endA==p.endB&&(z=im(g.parent.content.cut(g.parentOffset,y.parentOffset),b.parent.content.cut(b.parentOffset,p.endA-b.start())))){let w=R(n.state.tr);z.type=="add"?w.addMark(k,M,z.mark):w.removeMark(k,M,z.mark),n.dispatch(w)}else if(g.parent.child(g.index()).isText&&g.index()==y.index()-(y.textOffset?0:1)){let w=g.parent.textBetween(g.parentOffset,y.parentOffset),j=()=>R(n.state.tr.insertText(w,k,M));n.someProp("handleTextInput",G=>G(n,k,M,w,j))||n.dispatch(j())}}else n.dispatch(R())}function da(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:Eo(n,e.resolve(t.anchor),e.resolve(t.head))}function im(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,s=t,i=r,o,l,a;for(let u=0;u<r.length;u++)s=r[u].removeFromSet(s);for(let u=0;u<t.length;u++)i=t[u].removeFromSet(i);if(s.length==1&&i.length==0)l=s[0],o="add",a=u=>u.mark(l.addToSet(u.marks));else if(s.length==0&&i.length==1)l=i[0],o="remove",a=u=>u.mark(l.removeFromSet(u.marks));else return null;let c=[];for(let u=0;u<e.childCount;u++)c.push(a(e.child(u)));if(v.from(c).eq(n))return{mark:l,type:o}}function om(n,e,t,r,s){if(t-e<=s.pos-r.pos||ui(r,!0,!1)<s.pos)return!1;let i=n.resolve(e);if(!r.parent.isTextblock){let l=i.nodeAfter;return l!=null&&t==e+l.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let o=n.resolve(ui(i,!0,!0));return!o.parent.isTextblock||o.pos>t||ui(o,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function ui(n,e,t){let r=n.depth,s=e?n.end():n.pos;for(;r>0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,s++,e=!1;if(t){let i=n.node(r).maybeChild(n.indexAfter(r));for(;i&&!i.isLeaf;)i=i.firstChild,s++}return s}function lm(n,e,t,r,s){let i=n.findDiffStart(e,t);if(i==null)return null;let{a:o,b:l}=n.findDiffEnd(e,t+n.size,t+e.size);if(s=="end"){let a=Math.max(0,i-Math.min(o,l));r-=o+a-i}if(o<i&&n.size<e.size){let a=r<=i&&r>=o?i-r:0;i-=a,i&&i<e.size&&fa(e.textBetween(i-1,i+1))&&(i+=a?1:-1),l=i+(l-o),o=i}else if(l<i){let a=r<=i&&r>=l?i-r:0;i-=a,i&&i<n.size&&fa(n.textBetween(i-1,i+1))&&(i+=a?1:-1),o=i+(o-l),l=i}return{start:i,endA:o,endB:l}}function fa(n){if(n.length!=2)return!1;let e=n.charCodeAt(0),t=n.charCodeAt(1);return e>=56320&&e<=57343&&t>=55296&&t<=56319}class Ru{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new Ep,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(ya),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=ma(this),pa(this),this.nodeViews=ga(this),this.docView=ql(this.state.doc,ha(this),ci(this),this.dom,this),this.domObserver=new Xp(this,(r,s,i,o)=>sm(this,r,s,i,o)),this.domObserver.start(),Tp(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&qi(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(ya),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let s=this.state,i=!1,o=!1;e.storedMarks&&this.composing&&(vu(this),o=!0),this.state=e;let l=s.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let h=ga(this);cm(h,this.nodeViews)&&(this.nodeViews=h,i=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&qi(this),this.editable=ma(this),pa(this);let a=ci(this),c=ha(this),u=s.plugins!=e.plugins&&!s.doc.eq(e.doc)?"reset":e.scrollToSelection>s.scrollToSelection?"to selection":"preserve",d=i||!this.docView.matchesNode(e.doc,c,a);(d||!e.selection.eq(s.selection))&&(o=!0);let f=u=="preserve"&&o&&this.dom.style.overflowAnchor==null&&Fh(this);if(o){this.domObserver.stop();let h=d&&(Re||ke)&&!this.composing&&!s.selection.empty&&!e.selection.empty&&am(s.selection,e.selection);if(d){let p=ke?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=_p(this)),(i||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=ql(e.doc,c,a,this.dom,this)),p&&!this.trackWrites&&(h=!0)}h||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&dp(this))?ft(this,h):(fu(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(s),!((r=this.dragging)===null||r===void 0)&&r.node&&!s.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,s),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():f&&$h(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof I){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Fl(this,t.getBoundingClientRect(),e)}else Fl(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let r=this.directPlugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let r=this.state.plugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let r=this.pluginViews[t];r.update&&r.update(this,e)}}updateDraggedNode(e,t){let r=e.node,s=-1;if(this.state.doc.nodeAt(r.from)==r.node)s=r.from;else{let i=r.from+(this.state.doc.content.size-t.doc.content.size);(i>0&&this.state.doc.nodeAt(i))==r.node&&(s=i)}this.dragging=new Eu(e.slice,e.move,s<0?void 0:I.create(this.state.doc,s))}someProp(e,t){let r=this._props&&this._props[e],s;if(r!=null&&(s=t?t(r):r))return s;for(let o=0;o<this.directPlugins.length;o++){let l=this.directPlugins[o].props[e];if(l!=null&&(s=t?t(l):l))return s}let i=this.state.plugins;if(i)for(let o=0;o<i.length;o++){let l=i[o].props[e];if(l!=null&&(s=t?t(l):l))return s}}hasFocus(){if(Re){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&Vh(this.dom),ft(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return Gh(this,e)}coordsAtPos(e,t=1){return su(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,r=-1){let s=this.docView.posFromDOM(e,t,r);if(s==null)throw new RangeError("DOM position not inside the editor");return s}endOfTextblock(e,t){return Zh(this,t||this.state,e)}pasteHTML(e,t){return Qn(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Qn(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return To(this,e)}destroy(){this.docView&&(Ap(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],ci(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Oh())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Op(this,e)}domSelectionRange(){let e=this.domSelection();return e?Me&&this.root.nodeType===11&&Ph(this.dom.ownerDocument)==this.dom&&Zp(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}Ru.prototype.dispatch=function(n){let e=this._props.dispatchTransaction;e?e.call(this,n):this.updateState(this.state.apply(n))};function ha(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[ye.node(0,n.state.doc.content.size,e)]}function pa(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:ye.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function ma(n){return!n.someProp("editable",e=>e(n.state)===!1)}function am(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function ga(n){let e=Object.create(null);function t(r){for(let s in r)Object.prototype.hasOwnProperty.call(e,s)||(e[s]=r[s])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function cm(n,e){let t=0,r=0;for(let s in n){if(n[s]!=e[s])return!0;t++}for(let s in e)r++;return t!=r}function ya(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var Nt={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Jr={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},um=typeof navigator<"u"&&/Mac/.test(navigator.platform),dm=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var ge=0;ge<10;ge++)Nt[48+ge]=Nt[96+ge]=String(ge);for(var ge=1;ge<=24;ge++)Nt[ge+111]="F"+ge;for(var ge=65;ge<=90;ge++)Nt[ge]=String.fromCharCode(ge+32),Jr[ge]=String.fromCharCode(ge);for(var di in Nt)Jr.hasOwnProperty(di)||(Jr[di]=Nt[di]);function fm(n){var e=um&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||dm&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Jr:Nt)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}const hm=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),pm=typeof navigator<"u"&&/Win/.test(navigator.platform);function mm(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,s,i,o;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))s=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))hm?o=!0:s=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(t="Alt-"+t),s&&(t="Ctrl-"+t),o&&(t="Meta-"+t),i&&(t="Shift-"+t),t}function gm(n){let e=Object.create(null);for(let t in n)e[mm(t)]=n[t];return e}function fi(n,e,t=!0){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t&&e.shiftKey&&(n="Shift-"+n),n}function ym(n){return new se({props:{handleKeyDown:Do(n)}})}function Do(n){let e=gm(n);return function(t,r){let s=fm(r),i,o=e[fi(s,r)];if(o&&o(t.state,t.dispatch,t))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let l=e[fi(s,r,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(pm&&r.ctrlKey&&r.altKey)&&(i=Nt[r.keyCode])&&i!=s){let l=e[fi(i,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}const Io=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function Lu(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const Du=(n,e,t)=>{let r=Lu(n,t);if(!r)return!1;let s=Po(r);if(!s){let o=r.blockRange(),l=o&&Mn(o);return l==null?!1:(e&&e(n.tr.lift(o,l).scrollIntoView()),!0)}let i=s.nodeBefore;if($u(n,s,e,-1))return!0;if(r.parent.content.size==0&&(Sn(i,"end")||I.isSelectable(i)))for(let o=r.depth;;o--){let l=Ds(n.doc,r.before(o),r.after(o),A.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=n.tr.step(l);a.setSelection(Sn(i,"end")?B.findFrom(a.doc.resolve(a.mapping.map(s.pos,-1)),-1):I.create(a.doc,s.pos-i.nodeSize)),e(a.scrollIntoView())}return!0}if(o==1||r.node(o-1).childCount>1)break}return i.isAtom&&s.depth==r.depth-1?(e&&e(n.tr.delete(s.pos-i.nodeSize,s.pos).scrollIntoView()),!0):!1},bm=(n,e,t)=>{let r=Lu(n,t);if(!r)return!1;let s=Po(r);return s?Iu(n,s,e):!1},xm=(n,e,t)=>{let r=ju(n,t);if(!r)return!1;let s=jo(r);return s?Iu(n,s,e):!1};function Iu(n,e,t){let r=e.nodeBefore,s=r,i=e.pos-1;for(;!s.isTextblock;i--){if(s.type.spec.isolating)return!1;let u=s.lastChild;if(!u)return!1;s=u}let o=e.nodeAfter,l=o,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let u=l.firstChild;if(!u)return!1;l=u}let c=Ds(n.doc,i,a,A.empty);if(!c||c.from!=i||c instanceof ce&&c.slice.size>=a-i)return!1;if(t){let u=n.tr.step(c);u.setSelection(P.create(u.doc,i)),t(u.scrollIntoView())}return!0}function Sn(n,e,t=!1){for(let r=n;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(t&&r.childCount!=1)return!1}return!1}const Pu=(n,e,t)=>{let{$head:r,empty:s}=n.selection,i=r;if(!s)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;i=Po(r)}let o=i&&i.nodeBefore;return!o||!I.isSelectable(o)?!1:(e&&e(n.tr.setSelection(I.create(n.doc,i.pos-o.nodeSize)).scrollIntoView()),!0)};function Po(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function ju(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const Bu=(n,e,t)=>{let r=ju(n,t);if(!r)return!1;let s=jo(r);if(!s)return!1;let i=s.nodeAfter;if($u(n,s,e,1))return!0;if(r.parent.content.size==0&&(Sn(i,"start")||I.isSelectable(i))){let o=Ds(n.doc,r.before(),r.after(),A.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=n.tr.step(o);l.setSelection(Sn(i,"start")?B.findFrom(l.doc.resolve(l.mapping.map(s.pos)),1):I.create(l.doc,l.mapping.map(s.pos))),e(l.scrollIntoView())}return!0}}return i.isAtom&&s.depth==r.depth-1?(e&&e(n.tr.delete(s.pos,s.pos+i.nodeSize).scrollIntoView()),!0):!1},zu=(n,e,t)=>{let{$head:r,empty:s}=n.selection,i=r;if(!s)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset<r.parent.content.size)return!1;i=jo(r)}let o=i&&i.nodeAfter;return!o||!I.isSelectable(o)?!1:(e&&e(n.tr.setSelection(I.create(n.doc,i.pos)).scrollIntoView()),!0)};function jo(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){let t=n.node(e);if(n.index(e)+1<t.childCount)return n.doc.resolve(n.after(e+1));if(t.type.spec.isolating)break}return null}const km=(n,e)=>{let t=n.selection,r=t instanceof I,s;if(r){if(t.node.isTextblock||!Rt(n.doc,t.from))return!1;s=t.from}else if(s=Ls(n.doc,t.from,-1),s==null)return!1;if(e){let i=n.tr.join(s);r&&i.setSelection(I.create(i.doc,s-n.doc.resolve(s).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},Sm=(n,e)=>{let t=n.selection,r;if(t instanceof I){if(t.node.isTextblock||!Rt(n.doc,t.to))return!1;r=t.to}else if(r=Ls(n.doc,t.to,1),r==null)return!1;return e&&e(n.tr.join(r).scrollIntoView()),!0},wm=(n,e)=>{let{$from:t,$to:r}=n.selection,s=t.blockRange(r),i=s&&Mn(s);return i==null?!1:(e&&e(n.tr.lift(s,i).scrollIntoView()),!0)},Hu=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(`
|
|
10
|
+
`).scrollIntoView()),!0)};function Bo(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}const Cm=(n,e)=>{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let s=t.node(-1),i=t.indexAfter(-1),o=Bo(s.contentMatchAt(i));if(!o||!s.canReplaceWith(i,i,o))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,o.createAndFill());a.setSelection(B.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},_u=(n,e)=>{let t=n.selection,{$from:r,$to:s}=t;if(t instanceof je||r.parent.inlineContent||s.parent.inlineContent)return!1;let i=Bo(s.parent.contentMatchAt(s.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let o=(!r.parentOffset&&s.index()<s.parent.childCount?r:s).pos,l=n.tr.insert(o,i.createAndFill());l.setSelection(P.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},Fu=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let i=t.before();if(dt(n.doc,i))return e&&e(n.tr.split(i).scrollIntoView()),!0}let r=t.blockRange(),s=r&&Mn(r);return s==null?!1:(e&&e(n.tr.lift(r,s).scrollIntoView()),!0)};function vm(n){return(e,t)=>{let{$from:r,$to:s}=e.selection;if(e.selection instanceof I&&e.selection.node.isBlock)return!r.parentOffset||!dt(e.doc,r.pos)?!1:(t&&t(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let i=[],o,l,a=!1,c=!1;for(let h=r.depth;;h--)if(r.node(h).isBlock){a=r.end(h)==r.pos+(r.depth-h),c=r.start(h)==r.pos-(r.depth-h),l=Bo(r.node(h-1).contentMatchAt(r.indexAfter(h-1))),i.unshift(a&&l?{type:l}:null),o=h;break}else{if(h==1)return!1;i.unshift(null)}let u=e.tr;(e.selection instanceof P||e.selection instanceof je)&&u.deleteSelection();let d=u.mapping.map(r.pos),f=dt(u.doc,d,i.length,i);if(f||(i[0]=l?{type:l}:null,f=dt(u.doc,d,i.length,i)),!f)return!1;if(u.split(d,i.length,i),!a&&c&&r.node(o).type!=l){let h=u.mapping.map(r.before(o)),p=u.doc.resolve(h);l&&r.node(o-1).canReplaceWith(p.index(),p.index()+1,l)&&u.setNodeMarkup(u.mapping.map(r.before(o)),l)}return t&&t(u.scrollIntoView()),!0}}const Mm=vm(),Em=(n,e)=>{let{$from:t,to:r}=n.selection,s,i=t.sharedDepth(r);return i==0?!1:(s=t.before(i),e&&e(n.tr.setSelection(I.create(n.doc,s))),!0)};function Tm(n,e,t){let r=e.nodeBefore,s=e.nodeAfter,i=e.index();return!r||!s||!r.type.compatibleContent(s.type)?!1:!r.content.size&&e.parent.canReplace(i-1,i)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(s.isTextblock||Rt(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function $u(n,e,t,r){let s=e.nodeBefore,i=e.nodeAfter,o,l,a=s.type.spec.isolating||i.type.spec.isolating;if(!a&&Tm(n,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(o=(l=s.contentMatchAt(s.childCount)).findWrapping(i.type))&&l.matchType(o[0]||i.type).validEnd){if(t){let h=e.pos+i.nodeSize,p=v.empty;for(let b=o.length-1;b>=0;b--)p=v.from(o[b].create(null,p));p=v.from(s.copy(p));let g=n.tr.step(new ue(e.pos-1,h,e.pos,h,new A(p,1,0),o.length,!0)),y=g.doc.resolve(h+2*o.length);y.nodeAfter&&y.nodeAfter.type==s.type&&Rt(g.doc,y.pos)&&g.join(y.pos),t(g.scrollIntoView())}return!0}let u=i.type.spec.isolating||r>0&&a?null:B.findFrom(e,1),d=u&&u.$from.blockRange(u.$to),f=d&&Mn(d);if(f!=null&&f>=e.depth)return t&&t(n.tr.lift(d,f).scrollIntoView()),!0;if(c&&Sn(i,"start",!0)&&Sn(s,"end")){let h=s,p=[];for(;p.push(h),!h.isTextblock;)h=h.lastChild;let g=i,y=1;for(;!g.isTextblock;g=g.firstChild)y++;if(h.canReplace(h.childCount,h.childCount,g.content)){if(t){let b=v.empty;for(let C=p.length-1;C>=0;C--)b=v.from(p[C].copy(b));let x=n.tr.step(new ue(e.pos-p.length,e.pos+i.nodeSize,e.pos+y,e.pos+i.nodeSize-y,new A(b,p.length,0),0,!0));t(x.scrollIntoView())}return!0}}return!1}function Vu(n){return function(e,t){let r=e.selection,s=n<0?r.$from:r.$to,i=s.depth;for(;s.node(i).isInline;){if(!i)return!1;i--}return s.node(i).isTextblock?(t&&t(e.tr.setSelection(P.create(e.doc,n<0?s.start(i):s.end(i)))),!0):!1}}const Am=Vu(-1),Nm=Vu(1);function Om(n,e=null){return function(t,r){let{$from:s,$to:i}=t.selection,o=s.blockRange(i),l=o&&So(o,n,e);return l?(r&&r(t.tr.wrap(o,l).scrollIntoView()),!0):!1}}function ba(n,e=null){return function(t,r){let s=!1;for(let i=0;i<t.selection.ranges.length&&!s;i++){let{$from:{pos:o},$to:{pos:l}}=t.selection.ranges[i];t.doc.nodesBetween(o,l,(a,c)=>{if(s)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)s=!0;else{let u=t.doc.resolve(c),d=u.index();s=u.parent.canReplaceWith(d,d+1,n)}})}if(!s)return!1;if(r){let i=t.tr;for(let o=0;o<t.selection.ranges.length;o++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[o];i.setBlockType(l,a,n,e)}r(i.scrollIntoView())}return!0}}function zo(...n){return function(e,t,r){for(let s=0;s<n.length;s++)if(n[s](e,t,r))return!0;return!1}}zo(Io,Du,Pu);zo(Io,Bu,zu);zo(Hu,_u,Fu,Mm);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function Rm(n,e=null){return function(t,r){let{$from:s,$to:i}=t.selection,o=s.blockRange(i);if(!o)return!1;let l=r?t.tr:null;return Lm(l,o,n,e)?(r&&r(l.scrollIntoView()),!0):!1}}function Lm(n,e,t,r=null){let s=!1,i=e,o=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(t)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=o.resolve(e.start-2);i=new $r(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new $r(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),s=!0}let l=So(i,t,r,e);return l?(n&&Dm(n,e,l,s,t),!0):!1}function Dm(n,e,t,r,s){let i=v.empty;for(let u=t.length-1;u>=0;u--)i=v.from(t[u].type.create(t[u].attrs,i));n.step(new ue(e.start-(r?2:0),e.end,e.start,e.end,new A(i,0,0),t.length,!0));let o=0;for(let u=0;u<t.length;u++)t[u].type==s&&(o=u+1);let l=t.length-o,a=e.start+t.length-(r?2:0),c=e.parent;for(let u=e.startIndex,d=e.endIndex,f=!0;u<d;u++,f=!1)!f&&dt(n.doc,a,l)&&(n.split(a,l),a+=2*l),a+=c.child(u).nodeSize;return n}function Im(n){return function(e,t){let{$from:r,$to:s}=e.selection,i=r.blockRange(s,o=>o.childCount>0&&o.firstChild.type==n);return i?t?r.node(i.depth-1).type==n?Pm(e,t,n,i):jm(e,t,i):!0:!1}}function Pm(n,e,t,r){let s=n.tr,i=r.end,o=r.$to.end(r.depth);i<o&&(s.step(new ue(i-1,o,i,o,new A(v.from(t.create(null,r.parent.copy())),1,0),1,!0)),r=new $r(s.doc.resolve(r.$from.pos),s.doc.resolve(o),r.depth));const l=Mn(r);if(l==null)return!1;s.lift(r,l);let a=s.doc.resolve(s.mapping.map(i,-1)-1);return Rt(s.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&s.join(a.pos),e(s.scrollIntoView()),!0}function jm(n,e,t){let r=n.tr,s=t.parent;for(let h=t.end,p=t.endIndex-1,g=t.startIndex;p>g;p--)h-=s.child(p).nodeSize,r.delete(h-1,h+1);let i=r.doc.resolve(t.start),o=i.nodeAfter;if(r.mapping.map(t.end)!=t.start+i.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==s.childCount,c=i.node(-1),u=i.index(-1);if(!c.canReplace(u+(l?0:1),u+1,o.content.append(a?v.empty:v.from(s))))return!1;let d=i.pos,f=d+o.nodeSize;return r.step(new ue(d-(l?1:0),f+(a?1:0),d+1,f-1,new A((l?v.empty:v.from(s.copy(v.empty))).append(a?v.empty:v.from(s.copy(v.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function Bm(n){return function(e,t){let{$from:r,$to:s}=e.selection,i=r.blockRange(s,c=>c.childCount>0&&c.firstChild.type==n);if(!i)return!1;let o=i.startIndex;if(o==0)return!1;let l=i.parent,a=l.child(o-1);if(a.type!=n)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,u=v.from(c?n.create():null),d=new A(v.from(n.create(null,v.from(l.type.create(null,u)))),c?3:1,0),f=i.start,h=i.end;t(e.tr.step(new ue(f-(c?3:1),h,f,h,d,1,!0)).scrollIntoView())}return!0}}function zs(n){const{state:e,transaction:t}=n;let{selection:r}=t,{doc:s}=t,{storedMarks:i}=t;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return i},get selection(){return r},get doc(){return s},get tr(){return r=t.selection,s=t.doc,i=t.storedMarks,t}}}class Hs{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:e,editor:t,state:r}=this,{view:s}=t,{tr:i}=r,o=this.buildProps(i);return Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...u)=>{const d=a(...u)(o);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(i),d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){const{rawCommands:r,editor:s,state:i}=this,{view:o}=s,l=[],a=!!e,c=e||i.tr,u=()=>(!a&&t&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&o.dispatch(c),l.every(f=>f===!0)),d={...Object.fromEntries(Object.entries(r).map(([f,h])=>[f,(...g)=>{const y=this.buildProps(c,t),b=h(...g)(y);return l.push(b),d}])),run:u};return d}createCan(e){const{rawCommands:t,state:r}=this,s=!1,i=e||r.tr,o=this.buildProps(i,s);return{...Object.fromEntries(Object.entries(t).map(([a,c])=>[a,(...u)=>c(...u)({...o,dispatch:void 0})])),chain:()=>this.createChain(i,s)}}buildProps(e,t=!0){const{rawCommands:r,editor:s,state:i}=this,{view:o}=s,l={tr:e,editor:s,view:o,state:zs({state:i,transaction:e}),dispatch:t?()=>{}:void 0,chain:()=>this.createChain(e,t),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(r).map(([a,c])=>[a,(...u)=>c(...u)(l)]))}};return l}}class zm{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){const r=this.callbacks[e];return r&&r.forEach(s=>s.apply(this,t)),this}off(e,t){const r=this.callbacks[e];return r&&(t?this.callbacks[e]=r.filter(s=>s!==t):delete this.callbacks[e]),this}once(e,t){const r=(...s)=>{this.off(e,r),t.apply(this,s)};return this.on(e,r)}removeAllListeners(){this.callbacks={}}}function L(n,e,t){return n.config[e]===void 0&&n.parent?L(n.parent,e,t):typeof n.config[e]=="function"?n.config[e].bind({...t,parent:n.parent?L(n.parent,e,t):null}):n.config[e]}function _s(n){const e=n.filter(s=>s.type==="extension"),t=n.filter(s=>s.type==="node"),r=n.filter(s=>s.type==="mark");return{baseExtensions:e,nodeExtensions:t,markExtensions:r}}function Wu(n){const e=[],{nodeExtensions:t,markExtensions:r}=_s(n),s=[...t,...r],i={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return n.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage,extensions:s},a=L(o,"addGlobalAttributes",l);if(!a)return;a().forEach(u=>{u.types.forEach(d=>{Object.entries(u.attributes).forEach(([f,h])=>{e.push({type:d,name:f,attribute:{...i,...h}})})})})}),s.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage},a=L(o,"addAttributes",l);if(!a)return;const c=a();Object.entries(c).forEach(([u,d])=>{const f={...i,...d};typeof f?.default=="function"&&(f.default=f.default()),f?.isRequired&&f?.default===void 0&&delete f.default,e.push({type:o.name,name:u,attribute:f})})}),e}function fe(n,e){if(typeof n=="string"){if(!e.nodes[n])throw Error(`There is no node type named '${n}'. Maybe you forgot to add the extension?`);return e.nodes[n]}return n}function K(...n){return n.filter(e=>!!e).reduce((e,t)=>{const r={...e};return Object.entries(t).forEach(([s,i])=>{if(!r[s]){r[s]=i;return}if(s==="class"){const l=i?String(i).split(" "):[],a=r[s]?r[s].split(" "):[],c=l.filter(u=>!a.includes(u));r[s]=[...a,...c].join(" ")}else if(s==="style"){const l=i?i.split(";").map(u=>u.trim()).filter(Boolean):[],a=r[s]?r[s].split(";").map(u=>u.trim()).filter(Boolean):[],c=new Map;a.forEach(u=>{const[d,f]=u.split(":").map(h=>h.trim());c.set(d,f)}),l.forEach(u=>{const[d,f]=u.split(":").map(h=>h.trim());c.set(d,f)}),r[s]=Array.from(c.entries()).map(([u,d])=>`${u}: ${d}`).join("; ")}else r[s]=i}),r},{})}function Yr(n,e){return e.filter(t=>t.type===n.type.name).filter(t=>t.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(n.attrs)||{}:{[t.name]:n.attrs[t.name]}).reduce((t,r)=>K(t,r),{})}function Uu(n){return typeof n=="function"}function F(n,e=void 0,...t){return Uu(n)?e?n.bind(e)(...t):n(...t):n}function Hm(n={}){return Object.keys(n).length===0&&n.constructor===Object}function _m(n){return typeof n!="string"?n:n.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(n):n==="true"?!0:n==="false"?!1:n}function xa(n,e){return"style"in n?n:{...n,getAttrs:t=>{const r=n.getAttrs?n.getAttrs(t):n.attrs;if(r===!1)return!1;const s=e.reduce((i,o)=>{const l=o.attribute.parseHTML?o.attribute.parseHTML(t):_m(t.getAttribute(o.name));return l==null?i:{...i,[o.name]:l}},{});return{...r,...s}}}}function ka(n){return Object.fromEntries(Object.entries(n).filter(([e,t])=>e==="attrs"&&Hm(t)?!1:t!=null))}function Fm(n,e){var t;const r=Wu(n),{nodeExtensions:s,markExtensions:i}=_s(n),o=(t=s.find(c=>L(c,"topNode")))===null||t===void 0?void 0:t.name,l=Object.fromEntries(s.map(c=>{const u=r.filter(b=>b.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:e},f=n.reduce((b,x)=>{const C=L(x,"extendNodeSchema",d);return{...b,...C?C(c):{}}},{}),h=ka({...f,content:F(L(c,"content",d)),marks:F(L(c,"marks",d)),group:F(L(c,"group",d)),inline:F(L(c,"inline",d)),atom:F(L(c,"atom",d)),selectable:F(L(c,"selectable",d)),draggable:F(L(c,"draggable",d)),code:F(L(c,"code",d)),whitespace:F(L(c,"whitespace",d)),linebreakReplacement:F(L(c,"linebreakReplacement",d)),defining:F(L(c,"defining",d)),isolating:F(L(c,"isolating",d)),attrs:Object.fromEntries(u.map(b=>{var x;return[b.name,{default:(x=b?.attribute)===null||x===void 0?void 0:x.default}]}))}),p=F(L(c,"parseHTML",d));p&&(h.parseDOM=p.map(b=>xa(b,u)));const g=L(c,"renderHTML",d);g&&(h.toDOM=b=>g({node:b,HTMLAttributes:Yr(b,u)}));const y=L(c,"renderText",d);return y&&(h.toText=y),[c.name,h]})),a=Object.fromEntries(i.map(c=>{const u=r.filter(y=>y.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:e},f=n.reduce((y,b)=>{const x=L(b,"extendMarkSchema",d);return{...y,...x?x(c):{}}},{}),h=ka({...f,inclusive:F(L(c,"inclusive",d)),excludes:F(L(c,"excludes",d)),group:F(L(c,"group",d)),spanning:F(L(c,"spanning",d)),code:F(L(c,"code",d)),attrs:Object.fromEntries(u.map(y=>{var b;return[y.name,{default:(b=y?.attribute)===null||b===void 0?void 0:b.default}]}))}),p=F(L(c,"parseHTML",d));p&&(h.parseDOM=p.map(y=>xa(y,u)));const g=L(c,"renderHTML",d);return g&&(h.toDOM=y=>g({mark:y,HTMLAttributes:Yr(y,u)})),[c.name,h]}));return new Dc({topNode:o,nodes:l,marks:a})}function hi(n,e){return e.nodes[n]||e.marks[n]||null}function Sa(n,e){return Array.isArray(e)?e.some(t=>(typeof t=="string"?t:t.name)===n.name):e}function Ho(n,e){const t=nn.fromSchema(e).serializeFragment(n),s=document.implementation.createHTMLDocument().createElement("div");return s.appendChild(t),s.innerHTML}const $m=(n,e=500)=>{let t="";const r=n.parentOffset;return n.parent.nodesBetween(Math.max(0,r-e),r,(s,i,o,l)=>{var a,c;const u=((c=(a=s.type.spec).toText)===null||c===void 0?void 0:c.call(a,{node:s,pos:i,parent:o,index:l}))||s.textContent||"%leaf%";t+=s.isAtom&&!s.isText?u:u.slice(0,Math.max(0,r-i))}),t};function _o(n){return Object.prototype.toString.call(n)==="[object RegExp]"}class wn{constructor(e){this.find=e.find,this.handler=e.handler}}const Vm=(n,e)=>{if(_o(e))return e.exec(n);const t=e(n);if(!t)return null;const r=[t.text];return r.index=t.index,r.input=n,r.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(t.replaceWith)),r};function br(n){var e;const{editor:t,from:r,to:s,text:i,rules:o,plugin:l}=n,{view:a}=t;if(a.composing)return!1;const c=a.state.doc.resolve(r);if(c.parent.type.spec.code||!((e=c.nodeBefore||c.nodeAfter)===null||e===void 0)&&e.marks.find(f=>f.type.spec.code))return!1;let u=!1;const d=$m(c)+i;return o.forEach(f=>{if(u)return;const h=Vm(d,f.find);if(!h)return;const p=a.state.tr,g=zs({state:a.state,transaction:p}),y={from:r-(h[0].length-i.length),to:s},{commands:b,chain:x,can:C}=new Hs({editor:t,state:g});f.handler({state:g,range:y,match:h,commands:b,chain:x,can:C})===null||!p.steps.length||(p.setMeta(l,{transform:p,from:r,to:s,text:i}),a.dispatch(p),u=!0)}),u}function Wm(n){const{editor:e,rules:t}=n,r=new se({state:{init(){return null},apply(s,i,o){const l=s.getMeta(r);if(l)return l;const a=s.getMeta("applyInputRules");return!!a&&setTimeout(()=>{let{text:u}=a;typeof u=="string"?u=u:u=Ho(v.from(u),o.schema);const{from:d}=a,f=d+u.length;br({editor:e,from:d,to:f,text:u,rules:t,plugin:r})}),s.selectionSet||s.docChanged?null:i}},props:{handleTextInput(s,i,o,l){return br({editor:e,from:i,to:o,text:l,rules:t,plugin:r})},handleDOMEvents:{compositionend:s=>(setTimeout(()=>{const{$cursor:i}=s.state.selection;i&&br({editor:e,from:i.pos,to:i.pos,text:"",rules:t,plugin:r})}),!1)},handleKeyDown(s,i){if(i.key!=="Enter")return!1;const{$cursor:o}=s.state.selection;return o?br({editor:e,from:o.pos,to:o.pos,text:`
|
|
11
|
+
`,rules:t,plugin:r}):!1}},isInputRules:!0});return r}function Um(n){return Object.prototype.toString.call(n).slice(8,-1)}function xr(n){return Um(n)!=="Object"?!1:n.constructor===Object&&Object.getPrototypeOf(n)===Object.prototype}function Fs(n,e){const t={...n};return xr(n)&&xr(e)&&Object.keys(e).forEach(r=>{xr(e[r])&&xr(n[r])?t[r]=Fs(n[r],e[r]):t[r]=e[r]}),t}class Se{constructor(e={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=F(L(this,"addOptions",{name:this.name}))),this.storage=F(L(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new Se(e)}configure(e={}){const t=this.extend({...this.config,addOptions:()=>Fs(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const t=new Se(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=F(L(t,"addOptions",{name:t.name})),t.storage=F(L(t,"addStorage",{name:t.name,options:t.options})),t}static handleExit({editor:e,mark:t}){const{tr:r}=e.state,s=e.state.selection.$from;if(s.pos===s.end()){const o=s.marks();if(!!!o.find(c=>c?.type.name===t.name))return!1;const a=o.find(c=>c?.type.name===t.name);return a&&r.removeStoredMark(a),r.insertText(" ",s.pos),e.view.dispatch(r),!0}return!1}}function Km(n){return typeof n=="number"}class Ku{constructor(e){this.find=e.find,this.handler=e.handler}}const qm=(n,e,t)=>{if(_o(e))return[...n.matchAll(e)];const r=e(n,t);return r?r.map(s=>{const i=[s.text];return i.index=s.index,i.input=n,i.data=s.data,s.replaceWith&&(s.text.includes(s.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),i.push(s.replaceWith)),i}):[]};function Gm(n){const{editor:e,state:t,from:r,to:s,rule:i,pasteEvent:o,dropEvent:l}=n,{commands:a,chain:c,can:u}=new Hs({editor:e,state:t}),d=[];return t.doc.nodesBetween(r,s,(h,p)=>{if(!h.isTextblock||h.type.spec.code)return;const g=Math.max(r,p),y=Math.min(s,p+h.content.size),b=h.textBetween(g-p,y-p,void 0,"");qm(b,i.find,o).forEach(C=>{if(C.index===void 0)return;const k=g+C.index+1,M=k+C[0].length,R={from:t.tr.mapping.map(k),to:t.tr.mapping.map(M)},z=i.handler({state:t,range:R,match:C,commands:a,chain:c,can:u,pasteEvent:o,dropEvent:l});d.push(z)})}),d.every(h=>h!==null)}let kr=null;const Jm=n=>{var e;const t=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=t.clipboardData)===null||e===void 0||e.setData("text/html",n),t};function Ym(n){const{editor:e,rules:t}=n;let r=null,s=!1,i=!1,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}const a=({state:u,from:d,to:f,rule:h,pasteEvt:p})=>{const g=u.tr,y=zs({state:u,transaction:g});if(!(!Gm({editor:e,state:y,from:Math.max(d-1,0),to:f.b-1,rule:h,pasteEvent:p,dropEvent:l})||!g.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,g}};return t.map(u=>new se({view(d){const f=p=>{var g;r=!((g=d.dom.parentElement)===null||g===void 0)&&g.contains(p.target)?d.dom.parentElement:null,r&&(kr=e)},h=()=>{kr&&(kr=null)};return window.addEventListener("dragstart",f),window.addEventListener("dragend",h),{destroy(){window.removeEventListener("dragstart",f),window.removeEventListener("dragend",h)}}},props:{handleDOMEvents:{drop:(d,f)=>{if(i=r===d.dom.parentElement,l=f,!i){const h=kr;h?.isEditable&&setTimeout(()=>{const p=h.state.selection;p&&h.commands.deleteRange({from:p.from,to:p.to})},10)}return!1},paste:(d,f)=>{var h;const p=(h=f.clipboardData)===null||h===void 0?void 0:h.getData("text/html");return o=f,s=!!p?.includes("data-pm-slice"),!1}}},appendTransaction:(d,f,h)=>{const p=d[0],g=p.getMeta("uiEvent")==="paste"&&!s,y=p.getMeta("uiEvent")==="drop"&&!i,b=p.getMeta("applyPasteRules"),x=!!b;if(!g&&!y&&!x)return;if(x){let{text:M}=b;typeof M=="string"?M=M:M=Ho(v.from(M),h.schema);const{from:R}=b,z=R+M.length,w=Jm(M);return a({rule:u,state:h,from:R,to:{b:z},pasteEvt:w})}const C=f.doc.content.findDiffStart(h.doc.content),k=f.doc.content.findDiffEnd(h.doc.content);if(!(!Km(C)||!k||C===k.b))return a({rule:u,state:h,from:C,to:k,pasteEvt:o})}}))}function Xm(n){const e=n.filter((t,r)=>n.indexOf(t)!==r);return Array.from(new Set(e))}class pn{constructor(e,t){this.splittableMarks=[],this.editor=t,this.extensions=pn.resolve(e),this.schema=Fm(this.extensions,t),this.setupExtensions()}static resolve(e){const t=pn.sort(pn.flatten(e)),r=Xm(t.map(s=>s.name));return r.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${r.map(s=>`'${s}'`).join(", ")}]. This can lead to issues.`),t}static flatten(e){return e.map(t=>{const r={name:t.name,options:t.options,storage:t.storage},s=L(t,"addExtensions",r);return s?[t,...this.flatten(s())]:t}).flat(10)}static sort(e){return e.sort((r,s)=>{const i=L(r,"priority")||100,o=L(s,"priority")||100;return i>o?-1:i<o?1:0})}get commands(){return this.extensions.reduce((e,t)=>{const r={name:t.name,options:t.options,storage:t.storage,editor:this.editor,type:hi(t.name,this.schema)},s=L(t,"addCommands",r);return s?{...e,...s()}:e},{})}get plugins(){const{editor:e}=this,t=pn.sort([...this.extensions].reverse()),r=[],s=[],i=t.map(o=>{const l={name:o.name,options:o.options,storage:o.storage,editor:e,type:hi(o.name,this.schema)},a=[],c=L(o,"addKeyboardShortcuts",l);let u={};if(o.type==="mark"&&L(o,"exitable",l)&&(u.ArrowRight=()=>Se.handleExit({editor:e,mark:o})),c){const g=Object.fromEntries(Object.entries(c()).map(([y,b])=>[y,()=>b({editor:e})]));u={...u,...g}}const d=ym(u);a.push(d);const f=L(o,"addInputRules",l);Sa(o,e.options.enableInputRules)&&f&&r.push(...f());const h=L(o,"addPasteRules",l);Sa(o,e.options.enablePasteRules)&&h&&s.push(...h());const p=L(o,"addProseMirrorPlugins",l);if(p){const g=p();a.push(...g)}return a}).flat();return[Wm({editor:e,rules:r}),...Ym({editor:e,rules:s}),...i]}get attributes(){return Wu(this.extensions)}get nodeViews(){const{editor:e}=this,{nodeExtensions:t}=_s(this.extensions);return Object.fromEntries(t.filter(r=>!!L(r,"addNodeView")).map(r=>{const s=this.attributes.filter(a=>a.type===r.name),i={name:r.name,options:r.options,storage:r.storage,editor:e,type:fe(r.name,this.schema)},o=L(r,"addNodeView",i);if(!o)return[];const l=(a,c,u,d,f)=>{const h=Yr(a,s);return o()({node:a,view:c,getPos:u,decorations:d,innerDecorations:f,editor:e,extension:r,HTMLAttributes:h})};return[r.name,l]}))}setupExtensions(){this.extensions.forEach(e=>{var t;this.editor.extensionStorage[e.name]=e.storage;const r={name:e.name,options:e.options,storage:e.storage,editor:this.editor,type:hi(e.name,this.schema)};e.type==="mark"&&(!((t=F(L(e,"keepOnSplit",r)))!==null&&t!==void 0)||t)&&this.splittableMarks.push(e.name);const s=L(e,"onBeforeCreate",r),i=L(e,"onCreate",r),o=L(e,"onUpdate",r),l=L(e,"onSelectionUpdate",r),a=L(e,"onTransaction",r),c=L(e,"onFocus",r),u=L(e,"onBlur",r),d=L(e,"onDestroy",r);s&&this.editor.on("beforeCreate",s),i&&this.editor.on("create",i),o&&this.editor.on("update",o),l&&this.editor.on("selectionUpdate",l),a&&this.editor.on("transaction",a),c&&this.editor.on("focus",c),u&&this.editor.on("blur",u),d&&this.editor.on("destroy",d)})}}class le{constructor(e={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=F(L(this,"addOptions",{name:this.name}))),this.storage=F(L(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new le(e)}configure(e={}){const t=this.extend({...this.config,addOptions:()=>Fs(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const t=new le({...this.config,...e});return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=F(L(t,"addOptions",{name:t.name})),t.storage=F(L(t,"addStorage",{name:t.name,options:t.options})),t}}function qu(n,e,t){const{from:r,to:s}=e,{blockSeparator:i=`
|
|
12
|
+
|
|
13
|
+
`,textSerializers:o={}}=t||{};let l="";return n.nodesBetween(r,s,(a,c,u,d)=>{var f;a.isBlock&&c>r&&(l+=i);const h=o?.[a.type.name];if(h)return u&&(l+=h({node:a,pos:c,parent:u,index:d,range:e})),!1;a.isText&&(l+=(f=a?.text)===null||f===void 0?void 0:f.slice(Math.max(r,c)-c,s-c))}),l}function Gu(n){return Object.fromEntries(Object.entries(n.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}const Qm=le.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new se({key:new ae("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:n}=this,{state:e,schema:t}=n,{doc:r,selection:s}=e,{ranges:i}=s,o=Math.min(...i.map(u=>u.$from.pos)),l=Math.max(...i.map(u=>u.$to.pos)),a=Gu(t);return qu(r,{from:o,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:a})}}})]}}),Zm=()=>({editor:n,view:e})=>(requestAnimationFrame(()=>{var t;n.isDestroyed||(e.dom.blur(),(t=window?.getSelection())===null||t===void 0||t.removeAllRanges())}),!0),eg=(n=!1)=>({commands:e})=>e.setContent("",n),tg=()=>({state:n,tr:e,dispatch:t})=>{const{selection:r}=e,{ranges:s}=r;return t&&s.forEach(({$from:i,$to:o})=>{n.doc.nodesBetween(i.pos,o.pos,(l,a)=>{if(l.type.isText)return;const{doc:c,mapping:u}=e,d=c.resolve(u.map(a)),f=c.resolve(u.map(a+l.nodeSize)),h=d.blockRange(f);if(!h)return;const p=Mn(h);if(l.type.isTextblock){const{defaultType:g}=d.parent.contentMatchAt(d.index());e.setNodeMarkup(h.start,g)}(p||p===0)&&e.lift(h,p)})}),!0},ng=n=>e=>n(e),rg=()=>({state:n,dispatch:e})=>_u(n,e),sg=(n,e)=>({editor:t,tr:r})=>{const{state:s}=t,i=s.doc.slice(n.from,n.to);r.deleteRange(n.from,n.to);const o=r.mapping.map(e);return r.insert(o,i.content),r.setSelection(new P(r.doc.resolve(Math.max(o-1,0)))),!0},ig=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,r=t.$anchor.node();if(r.content.size>0)return!1;const s=n.selection.$anchor;for(let i=s.depth;i>0;i-=1)if(s.node(i).type===r.type){if(e){const l=s.before(i),a=s.after(i);n.delete(l,a).scrollIntoView()}return!0}return!1},og=n=>({tr:e,state:t,dispatch:r})=>{const s=fe(n,t.schema),i=e.selection.$anchor;for(let o=i.depth;o>0;o-=1)if(i.node(o).type===s){if(r){const a=i.before(o),c=i.after(o);e.delete(a,c).scrollIntoView()}return!0}return!1},lg=n=>({tr:e,dispatch:t})=>{const{from:r,to:s}=n;return t&&e.delete(r,s),!0},ag=()=>({state:n,dispatch:e})=>Io(n,e),cg=()=>({commands:n})=>n.keyboardShortcut("Enter"),ug=()=>({state:n,dispatch:e})=>Cm(n,e);function Xr(n,e,t={strict:!0}){const r=Object.keys(e);return r.length?r.every(s=>t.strict?e[s]===n[s]:_o(e[s])?e[s].test(n[s]):e[s]===n[s]):!0}function Ju(n,e,t={}){return n.find(r=>r.type===e&&Xr(Object.fromEntries(Object.keys(t).map(s=>[s,r.attrs[s]])),t))}function wa(n,e,t={}){return!!Ju(n,e,t)}function Fo(n,e,t){var r;if(!n||!e)return;let s=n.parent.childAfter(n.parentOffset);if((!s.node||!s.node.marks.some(u=>u.type===e))&&(s=n.parent.childBefore(n.parentOffset)),!s.node||!s.node.marks.some(u=>u.type===e)||(t=t||((r=s.node.marks[0])===null||r===void 0?void 0:r.attrs),!Ju([...s.node.marks],e,t)))return;let o=s.index,l=n.start()+s.offset,a=o+1,c=l+s.node.nodeSize;for(;o>0&&wa([...n.parent.child(o-1).marks],e,t);)o-=1,l-=n.parent.child(o).nodeSize;for(;a<n.parent.childCount&&wa([...n.parent.child(a).marks],e,t);)c+=n.parent.child(a).nodeSize,a+=1;return{from:l,to:c}}function Dt(n,e){if(typeof n=="string"){if(!e.marks[n])throw Error(`There is no mark type named '${n}'. Maybe you forgot to add the extension?`);return e.marks[n]}return n}const dg=(n,e={})=>({tr:t,state:r,dispatch:s})=>{const i=Dt(n,r.schema),{doc:o,selection:l}=t,{$from:a,from:c,to:u}=l;if(s){const d=Fo(a,i,e);if(d&&d.from<=c&&d.to>=u){const f=P.create(o,d.from,d.to);t.setSelection(f)}}return!0},fg=n=>e=>{const t=typeof n=="function"?n(e):n;for(let r=0;r<t.length;r+=1)if(t[r](e))return!0;return!1};function Yu(n){return n instanceof P}function _t(n=0,e=0,t=0){return Math.min(Math.max(n,e),t)}function Xu(n,e=null){if(!e)return null;const t=B.atStart(n),r=B.atEnd(n);if(e==="start"||e===!0)return t;if(e==="end")return r;const s=t.from,i=r.to;return e==="all"?P.create(n,_t(0,s,i),_t(n.content.size,s,i)):P.create(n,_t(e,s,i),_t(e,s,i))}function Gi(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function er(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function hg(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}const pg=(n=null,e={})=>({editor:t,view:r,tr:s,dispatch:i})=>{e={scrollIntoView:!0,...e};const o=()=>{(er()||Gi())&&r.dom.focus(),requestAnimationFrame(()=>{t.isDestroyed||(r.focus(),hg()&&!er()&&!Gi()&&r.dom.focus({preventScroll:!0}))})};if(r.hasFocus()&&n===null||n===!1)return!0;if(i&&n===null&&!Yu(t.state.selection))return o(),!0;const l=Xu(s.doc,n)||t.state.selection,a=t.state.selection.eq(l);return i&&(a||s.setSelection(l),a&&s.storedMarks&&s.setStoredMarks(s.storedMarks),o()),!0},mg=(n,e)=>t=>n.every((r,s)=>e(r,{...t,index:s})),gg=(n,e)=>({tr:t,commands:r})=>r.insertContentAt({from:t.selection.from,to:t.selection.to},n,e),Qu=n=>{const e=n.childNodes;for(let t=e.length-1;t>=0;t-=1){const r=e[t];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?n.removeChild(r):r.nodeType===1&&Qu(r)}return n};function Sr(n){const e=`<body>${n}</body>`,t=new window.DOMParser().parseFromString(e,"text/html").body;return Qu(t)}function tr(n,e,t){if(n instanceof Mt||n instanceof v)return n;t={slice:!0,parseOptions:{},...t};const r=typeof n=="object"&&n!==null,s=typeof n=="string";if(r)try{if(Array.isArray(n)&&n.length>0)return v.fromArray(n.map(l=>e.nodeFromJSON(l)));const o=e.nodeFromJSON(n);return t.errorOnInvalidContent&&o.check(),o}catch(i){if(t.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:i});return console.warn("[tiptap warn]: Invalid content.","Passed value:",n,"Error:",i),tr("",e,t)}if(s){if(t.errorOnInvalidContent){let o=!1,l="";const a=new Dc({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(o=!0,l=typeof c=="string"?c:c.outerHTML,null)}]}})});if(t.slice?jn.fromSchema(a).parseSlice(Sr(n),t.parseOptions):jn.fromSchema(a).parse(Sr(n),t.parseOptions),t.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const i=jn.fromSchema(e);return t.slice?i.parseSlice(Sr(n),t.parseOptions).content:i.parse(Sr(n),t.parseOptions)}return tr("",e,t)}function yg(n,e,t){const r=n.steps.length-1;if(r<e)return;const s=n.steps[r];if(!(s instanceof ce||s instanceof ue))return;const i=n.mapping.maps[r];let o=0;i.forEach((l,a,c,u)=>{o===0&&(o=u)}),n.setSelection(B.near(n.doc.resolve(o),t))}const bg=n=>!("type"in n),xg=(n,e,t)=>({tr:r,dispatch:s,editor:i})=>{var o;if(s){t={parseOptions:i.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...t};let l;const a=y=>{i.emit("contentError",{editor:i,error:y,disableCollaboration:()=>{i.storage.collaboration&&(i.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...t.parseOptions};if(!t.errorOnInvalidContent&&!i.options.enableContentCheck&&i.options.emitContentError)try{tr(e,i.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(y){a(y)}try{l=tr(e,i.schema,{parseOptions:c,errorOnInvalidContent:(o=t.errorOnInvalidContent)!==null&&o!==void 0?o:i.options.enableContentCheck})}catch(y){return a(y),!1}let{from:u,to:d}=typeof n=="number"?{from:n,to:n}:{from:n.from,to:n.to},f=!0,h=!0;if((bg(l)?l:[l]).forEach(y=>{y.check(),f=f?y.isText&&y.marks.length===0:!1,h=h?y.isBlock:!1}),u===d&&h){const{parent:y}=r.doc.resolve(u);y.isTextblock&&!y.type.spec.code&&!y.childCount&&(u-=1,d+=1)}let g;if(f){if(Array.isArray(e))g=e.map(y=>y.text||"").join("");else if(e instanceof v){let y="";e.forEach(b=>{b.text&&(y+=b.text)}),g=y}else typeof e=="object"&&e&&e.text?g=e.text:g=e;r.insertText(g,u,d)}else g=l,r.replaceWith(u,d,g);t.updateSelection&&yg(r,r.steps.length-1,-1),t.applyInputRules&&r.setMeta("applyInputRules",{from:u,text:g}),t.applyPasteRules&&r.setMeta("applyPasteRules",{from:u,text:g})}return!0},kg=()=>({state:n,dispatch:e})=>km(n,e),Sg=()=>({state:n,dispatch:e})=>Sm(n,e),wg=()=>({state:n,dispatch:e})=>Du(n,e),Cg=()=>({state:n,dispatch:e})=>Bu(n,e),vg=()=>({state:n,dispatch:e,tr:t})=>{try{const r=Ls(n.doc,n.selection.$from.pos,-1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},Mg=()=>({state:n,dispatch:e,tr:t})=>{try{const r=Ls(n.doc,n.selection.$from.pos,1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},Eg=()=>({state:n,dispatch:e})=>bm(n,e),Tg=()=>({state:n,dispatch:e})=>xm(n,e);function Zu(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function Ag(n){const e=n.split(/-(?!$)/);let t=e[e.length-1];t==="Space"&&(t=" ");let r,s,i,o;for(let l=0;l<e.length-1;l+=1){const a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))s=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))er()||Zu()?o=!0:s=!0;else throw new Error(`Unrecognized modifier name: ${a}`)}return r&&(t=`Alt-${t}`),s&&(t=`Ctrl-${t}`),o&&(t=`Meta-${t}`),i&&(t=`Shift-${t}`),t}const Ng=n=>({editor:e,view:t,tr:r,dispatch:s})=>{const i=Ag(n).split(/-(?!$)/),o=i.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),l=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:i.includes("Alt"),ctrlKey:i.includes("Ctrl"),metaKey:i.includes("Meta"),shiftKey:i.includes("Shift"),bubbles:!0,cancelable:!0}),a=e.captureTransaction(()=>{t.someProp("handleKeyDown",c=>c(t,l))});return a?.steps.forEach(c=>{const u=c.map(r.mapping);u&&s&&r.maybeStep(u)}),!0};function nr(n,e,t={}){const{from:r,to:s,empty:i}=n.selection,o=e?fe(e,n.schema):null,l=[];n.doc.nodesBetween(r,s,(d,f)=>{if(d.isText)return;const h=Math.max(r,f),p=Math.min(s,f+d.nodeSize);l.push({node:d,from:h,to:p})});const a=s-r,c=l.filter(d=>o?o.name===d.node.type.name:!0).filter(d=>Xr(d.node.attrs,t,{strict:!1}));return i?!!c.length:c.reduce((d,f)=>d+f.to-f.from,0)>=a}const Og=(n,e={})=>({state:t,dispatch:r})=>{const s=fe(n,t.schema);return nr(t,s,e)?wm(t,r):!1},Rg=()=>({state:n,dispatch:e})=>Fu(n,e),Lg=n=>({state:e,dispatch:t})=>{const r=fe(n,e.schema);return Im(r)(e,t)},Dg=()=>({state:n,dispatch:e})=>Hu(n,e);function $s(n,e){return e.nodes[n]?"node":e.marks[n]?"mark":null}function Ca(n,e){const t=typeof e=="string"?[e]:e;return Object.keys(n).reduce((r,s)=>(t.includes(s)||(r[s]=n[s]),r),{})}const Ig=(n,e)=>({tr:t,state:r,dispatch:s})=>{let i=null,o=null;const l=$s(typeof n=="string"?n:n.name,r.schema);return l?(l==="node"&&(i=fe(n,r.schema)),l==="mark"&&(o=Dt(n,r.schema)),s&&t.selection.ranges.forEach(a=>{r.doc.nodesBetween(a.$from.pos,a.$to.pos,(c,u)=>{i&&i===c.type&&t.setNodeMarkup(u,void 0,Ca(c.attrs,e)),o&&c.marks.length&&c.marks.forEach(d=>{o===d.type&&t.addMark(u,u+c.nodeSize,o.create(Ca(d.attrs,e)))})})}),!0):!1},Pg=()=>({tr:n,dispatch:e})=>(e&&n.scrollIntoView(),!0),jg=()=>({tr:n,dispatch:e})=>{if(e){const t=new je(n.doc);n.setSelection(t)}return!0},Bg=()=>({state:n,dispatch:e})=>Pu(n,e),zg=()=>({state:n,dispatch:e})=>zu(n,e),Hg=()=>({state:n,dispatch:e})=>Em(n,e),_g=()=>({state:n,dispatch:e})=>Nm(n,e),Fg=()=>({state:n,dispatch:e})=>Am(n,e);function Ji(n,e,t={},r={}){return tr(n,e,{slice:!1,parseOptions:t,errorOnInvalidContent:r.errorOnInvalidContent})}const $g=(n,e=!1,t={},r={})=>({editor:s,tr:i,dispatch:o,commands:l})=>{var a,c;const{doc:u}=i;if(t.preserveWhitespace!=="full"){const d=Ji(n,s.schema,t,{errorOnInvalidContent:(a=r.errorOnInvalidContent)!==null&&a!==void 0?a:s.options.enableContentCheck});return o&&i.replaceWith(0,u.content.size,d).setMeta("preventUpdate",!e),!0}return o&&i.setMeta("preventUpdate",!e),l.insertContentAt({from:0,to:u.content.size},n,{parseOptions:t,errorOnInvalidContent:(c=r.errorOnInvalidContent)!==null&&c!==void 0?c:s.options.enableContentCheck})};function ed(n,e){const t=Dt(e,n.schema),{from:r,to:s,empty:i}=n.selection,o=[];i?(n.storedMarks&&o.push(...n.storedMarks),o.push(...n.selection.$head.marks())):n.doc.nodesBetween(r,s,a=>{o.push(...a.marks)});const l=o.find(a=>a.type.name===t.name);return l?{...l.attrs}:{}}function Vg(n,e){const t=new wo(n);return e.forEach(r=>{r.steps.forEach(s=>{t.step(s)})}),t}function Wg(n){for(let e=0;e<n.edgeCount;e+=1){const{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}function Yi(n,e){const t=[];return n.descendants((r,s)=>{e(r)&&t.push({node:r,pos:s})}),t}function Ug(n,e,t){const r=[];return n.nodesBetween(e.from,e.to,(s,i)=>{t(s)&&r.push({node:s,pos:i})}),r}function td(n,e){for(let t=n.depth;t>0;t-=1){const r=n.node(t);if(e(r))return{pos:t>0?n.before(t):0,start:n.start(t),depth:t,node:r}}}function $o(n){return e=>td(e.$from,n)}function Kg(n,e){const t={from:0,to:n.content.size};return qu(n,t,e)}function qg(n,e){const t=fe(e,n.schema),{from:r,to:s}=n.selection,i=[];n.doc.nodesBetween(r,s,l=>{i.push(l)});const o=i.reverse().find(l=>l.type.name===t.name);return o?{...o.attrs}:{}}function nd(n,e){const t=$s(typeof e=="string"?e:e.name,n.schema);return t==="node"?qg(n,e):t==="mark"?ed(n,e):{}}function Gg(n,e=JSON.stringify){const t={};return n.filter(r=>{const s=e(r);return Object.prototype.hasOwnProperty.call(t,s)?!1:t[s]=!0})}function Jg(n){const e=Gg(n);return e.length===1?e:e.filter((t,r)=>!e.filter((i,o)=>o!==r).some(i=>t.oldRange.from>=i.oldRange.from&&t.oldRange.to<=i.oldRange.to&&t.newRange.from>=i.newRange.from&&t.newRange.to<=i.newRange.to))}function Yg(n){const{mapping:e,steps:t}=n,r=[];return e.maps.forEach((s,i)=>{const o=[];if(s.ranges.length)s.forEach((l,a)=>{o.push({from:l,to:a})});else{const{from:l,to:a}=t[i];if(l===void 0||a===void 0)return;o.push({from:l,to:a})}o.forEach(({from:l,to:a})=>{const c=e.slice(i).map(l,-1),u=e.slice(i).map(a),d=e.invert().map(c,-1),f=e.invert().map(u);r.push({oldRange:{from:d,to:f},newRange:{from:c,to:u}})})}),Jg(r)}function Vo(n,e,t){const r=[];return n===e?t.resolve(n).marks().forEach(s=>{const i=t.resolve(n),o=Fo(i,s.type);o&&r.push({mark:s,...o})}):t.nodesBetween(n,e,(s,i)=>{!s||s?.nodeSize===void 0||r.push(...s.marks.map(o=>({from:i,to:i+s.nodeSize,mark:o})))}),r}function Ir(n,e,t){return Object.fromEntries(Object.entries(t).filter(([r])=>{const s=n.find(i=>i.type===e&&i.name===r);return s?s.attribute.keepOnSplit:!1}))}function Xi(n,e,t={}){const{empty:r,ranges:s}=n.selection,i=e?Dt(e,n.schema):null;if(r)return!!(n.storedMarks||n.selection.$from.marks()).filter(d=>i?i.name===d.type.name:!0).find(d=>Xr(d.attrs,t,{strict:!1}));let o=0;const l=[];if(s.forEach(({$from:d,$to:f})=>{const h=d.pos,p=f.pos;n.doc.nodesBetween(h,p,(g,y)=>{if(!g.isText&&!g.marks.length)return;const b=Math.max(h,y),x=Math.min(p,y+g.nodeSize),C=x-b;o+=C,l.push(...g.marks.map(k=>({mark:k,from:b,to:x})))})}),o===0)return!1;const a=l.filter(d=>i?i.name===d.mark.type.name:!0).filter(d=>Xr(d.mark.attrs,t,{strict:!1})).reduce((d,f)=>d+f.to-f.from,0),c=l.filter(d=>i?d.mark.type!==i&&d.mark.type.excludes(i):!0).reduce((d,f)=>d+f.to-f.from,0);return(a>0?a+c:a)>=o}function Xg(n,e,t={}){if(!e)return nr(n,null,t)||Xi(n,null,t);const r=$s(e,n.schema);return r==="node"?nr(n,e,t):r==="mark"?Xi(n,e,t):!1}function va(n,e){const{nodeExtensions:t}=_s(e),r=t.find(o=>o.name===n);if(!r)return!1;const s={name:r.name,options:r.options,storage:r.storage},i=F(L(r,"group",s));return typeof i!="string"?!1:i.split(" ").includes("list")}function Vs(n,{checkChildren:e=!0,ignoreWhitespace:t=!1}={}){var r;if(t){if(n.type.name==="hardBreak")return!0;if(n.isText)return/^\s*$/m.test((r=n.text)!==null&&r!==void 0?r:"")}if(n.isText)return!n.text;if(n.isAtom||n.isLeaf)return!1;if(n.content.childCount===0)return!0;if(e){let s=!0;return n.content.forEach(i=>{s!==!1&&(Vs(i,{ignoreWhitespace:t,checkChildren:e})||(s=!1))}),s}return!1}function Qg(n){return n instanceof I}function Zg(n,e,t){var r;const{selection:s}=e;let i=null;if(Yu(s)&&(i=s.$cursor),i){const l=(r=n.storedMarks)!==null&&r!==void 0?r:i.marks();return!!t.isInSet(l)||!l.some(a=>a.type.excludes(t))}const{ranges:o}=s;return o.some(({$from:l,$to:a})=>{let c=l.depth===0?n.doc.inlineContent&&n.doc.type.allowsMarkType(t):!1;return n.doc.nodesBetween(l.pos,a.pos,(u,d,f)=>{if(c)return!1;if(u.isInline){const h=!f||f.type.allowsMarkType(t),p=!!t.isInSet(u.marks)||!u.marks.some(g=>g.type.excludes(t));c=h&&p}return!c}),c})}const ey=(n,e={})=>({tr:t,state:r,dispatch:s})=>{const{selection:i}=t,{empty:o,ranges:l}=i,a=Dt(n,r.schema);if(s)if(o){const c=ed(r,a);t.addStoredMark(a.create({...c,...e}))}else l.forEach(c=>{const u=c.$from.pos,d=c.$to.pos;r.doc.nodesBetween(u,d,(f,h)=>{const p=Math.max(h,u),g=Math.min(h+f.nodeSize,d);f.marks.find(b=>b.type===a)?f.marks.forEach(b=>{a===b.type&&t.addMark(p,g,a.create({...b.attrs,...e}))}):t.addMark(p,g,a.create(e))})});return Zg(r,t,a)},ty=(n,e)=>({tr:t})=>(t.setMeta(n,e),!0),ny=(n,e={})=>({state:t,dispatch:r,chain:s})=>{const i=fe(n,t.schema);let o;return t.selection.$anchor.sameParent(t.selection.$head)&&(o=t.selection.$anchor.parent.attrs),i.isTextblock?s().command(({commands:l})=>ba(i,{...o,...e})(t)?!0:l.clearNodes()).command(({state:l})=>ba(i,{...o,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},ry=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,s=_t(n,0,r.content.size),i=I.create(r,s);e.setSelection(i)}return!0},sy=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,{from:s,to:i}=typeof n=="number"?{from:n,to:n}:n,o=P.atStart(r).from,l=P.atEnd(r).to,a=_t(s,o,l),c=_t(i,o,l),u=P.create(r,a,c);e.setSelection(u)}return!0},iy=n=>({state:e,dispatch:t})=>{const r=fe(n,e.schema);return Bm(r)(e,t)};function Ma(n,e){const t=n.storedMarks||n.selection.$to.parentOffset&&n.selection.$from.marks();if(t){const r=t.filter(s=>e?.includes(s.type.name));n.tr.ensureMarks(r)}}const oy=({keepMarks:n=!0}={})=>({tr:e,state:t,dispatch:r,editor:s})=>{const{selection:i,doc:o}=e,{$from:l,$to:a}=i,c=s.extensionManager.attributes,u=Ir(c,l.node().type.name,l.node().attrs);if(i instanceof I&&i.node.isBlock)return!l.parentOffset||!dt(o,l.pos)?!1:(r&&(n&&Ma(t,s.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const d=a.parentOffset===a.parent.content.size,f=l.depth===0?void 0:Wg(l.node(-1).contentMatchAt(l.indexAfter(-1)));let h=d&&f?[{type:f,attrs:u}]:void 0,p=dt(e.doc,e.mapping.map(l.pos),1,h);if(!h&&!p&&dt(e.doc,e.mapping.map(l.pos),1,f?[{type:f}]:void 0)&&(p=!0,h=f?[{type:f,attrs:u}]:void 0),r){if(p&&(i instanceof P&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,h),f&&!d&&!l.parentOffset&&l.parent.type!==f)){const g=e.mapping.map(l.before()),y=e.doc.resolve(g);l.node(-1).canReplaceWith(y.index(),y.index()+1,f)&&e.setNodeMarkup(e.mapping.map(l.before()),f)}n&&Ma(t,s.extensionManager.splittableMarks),e.scrollIntoView()}return p},ly=(n,e={})=>({tr:t,state:r,dispatch:s,editor:i})=>{var o;const l=fe(n,r.schema),{$from:a,$to:c}=r.selection,u=r.selection.node;if(u&&u.isBlock||a.depth<2||!a.sameParent(c))return!1;const d=a.node(-1);if(d.type!==l)return!1;const f=i.extensionManager.attributes;if(a.parent.content.size===0&&a.node(-1).childCount===a.indexAfter(-1)){if(a.depth===2||a.node(-3).type!==l||a.index(-2)!==a.node(-2).childCount-1)return!1;if(s){let b=v.empty;const x=a.index(-1)?1:a.index(-2)?2:3;for(let w=a.depth-x;w>=a.depth-3;w-=1)b=v.from(a.node(w).copy(b));const C=a.indexAfter(-1)<a.node(-2).childCount?1:a.indexAfter(-2)<a.node(-3).childCount?2:3,k={...Ir(f,a.node().type.name,a.node().attrs),...e},M=((o=l.contentMatch.defaultType)===null||o===void 0?void 0:o.createAndFill(k))||void 0;b=b.append(v.from(l.createAndFill(null,M)||void 0));const R=a.before(a.depth-(x-1));t.replace(R,a.after(-C),new A(b,4-x,0));let z=-1;t.doc.nodesBetween(R,t.doc.content.size,(w,j)=>{if(z>-1)return!1;w.isTextblock&&w.content.size===0&&(z=j+1)}),z>-1&&t.setSelection(P.near(t.doc.resolve(z))),t.scrollIntoView()}return!0}const h=c.pos===a.end()?d.contentMatchAt(0).defaultType:null,p={...Ir(f,d.type.name,d.attrs),...e},g={...Ir(f,a.node().type.name,a.node().attrs),...e};t.delete(a.pos,c.pos);const y=h?[{type:l,attrs:p},{type:h,attrs:g}]:[{type:l,attrs:p}];if(!dt(t.doc,a.pos,2))return!1;if(s){const{selection:b,storedMarks:x}=r,{splittableMarks:C}=i.extensionManager,k=x||b.$to.parentOffset&&b.$from.marks();if(t.split(a.pos,2,y).scrollIntoView(),!k||!s)return!0;const M=k.filter(R=>C.includes(R.type.name));t.ensureMarks(M)}return!0},pi=(n,e)=>{const t=$o(o=>o.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(Math.max(0,t.pos-1)).before(t.depth);if(r===void 0)return!0;const s=n.doc.nodeAt(r);return t.node.type===s?.type&&Rt(n.doc,t.pos)&&n.join(t.pos),!0},mi=(n,e)=>{const t=$o(o=>o.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(t.start).after(t.depth);if(r===void 0)return!0;const s=n.doc.nodeAt(r);return t.node.type===s?.type&&Rt(n.doc,r)&&n.join(r),!0},ay=(n,e,t,r={})=>({editor:s,tr:i,state:o,dispatch:l,chain:a,commands:c,can:u})=>{const{extensions:d,splittableMarks:f}=s.extensionManager,h=fe(n,o.schema),p=fe(e,o.schema),{selection:g,storedMarks:y}=o,{$from:b,$to:x}=g,C=b.blockRange(x),k=y||g.$to.parentOffset&&g.$from.marks();if(!C)return!1;const M=$o(R=>va(R.type.name,d))(g);if(C.depth>=1&&M&&C.depth-M.depth<=1){if(M.node.type===h)return c.liftListItem(p);if(va(M.node.type.name,d)&&h.validContent(M.node.content)&&l)return a().command(()=>(i.setNodeMarkup(M.pos,h),!0)).command(()=>pi(i,h)).command(()=>mi(i,h)).run()}return!t||!k||!l?a().command(()=>u().wrapInList(h,r)?!0:c.clearNodes()).wrapInList(h,r).command(()=>pi(i,h)).command(()=>mi(i,h)).run():a().command(()=>{const R=u().wrapInList(h,r),z=k.filter(w=>f.includes(w.type.name));return i.ensureMarks(z),R?!0:c.clearNodes()}).wrapInList(h,r).command(()=>pi(i,h)).command(()=>mi(i,h)).run()},cy=(n,e={},t={})=>({state:r,commands:s})=>{const{extendEmptyMarkRange:i=!1}=t,o=Dt(n,r.schema);return Xi(r,o,e)?s.unsetMark(o,{extendEmptyMarkRange:i}):s.setMark(o,e)},uy=(n,e,t={})=>({state:r,commands:s})=>{const i=fe(n,r.schema),o=fe(e,r.schema),l=nr(r,i,t);let a;return r.selection.$anchor.sameParent(r.selection.$head)&&(a=r.selection.$anchor.parent.attrs),l?s.setNode(o,a):s.setNode(i,{...a,...t})},dy=(n,e={})=>({state:t,commands:r})=>{const s=fe(n,t.schema);return nr(t,s,e)?r.lift(s):r.wrapIn(s,e)},fy=()=>({state:n,dispatch:e})=>{const t=n.plugins;for(let r=0;r<t.length;r+=1){const s=t[r];let i;if(s.spec.isInputRules&&(i=s.getState(n))){if(e){const o=n.tr,l=i.transform;for(let a=l.steps.length-1;a>=0;a-=1)o.step(l.steps[a].invert(l.docs[a]));if(i.text){const a=o.doc.resolve(i.from).marks();o.replaceWith(i.from,i.to,n.schema.text(i.text,a))}else o.delete(i.from,i.to)}return!0}}return!1},hy=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,{empty:r,ranges:s}=t;return r||e&&s.forEach(i=>{n.removeMark(i.$from.pos,i.$to.pos)}),!0},py=(n,e={})=>({tr:t,state:r,dispatch:s})=>{var i;const{extendEmptyMarkRange:o=!1}=e,{selection:l}=t,a=Dt(n,r.schema),{$from:c,empty:u,ranges:d}=l;if(!s)return!0;if(u&&o){let{from:f,to:h}=l;const p=(i=c.marks().find(y=>y.type===a))===null||i===void 0?void 0:i.attrs,g=Fo(c,a,p);g&&(f=g.from,h=g.to),t.removeMark(f,h,a)}else d.forEach(f=>{t.removeMark(f.$from.pos,f.$to.pos,a)});return t.removeStoredMark(a),!0},my=(n,e={})=>({tr:t,state:r,dispatch:s})=>{let i=null,o=null;const l=$s(typeof n=="string"?n:n.name,r.schema);return l?(l==="node"&&(i=fe(n,r.schema)),l==="mark"&&(o=Dt(n,r.schema)),s&&t.selection.ranges.forEach(a=>{const c=a.$from.pos,u=a.$to.pos;let d,f,h,p;t.selection.empty?r.doc.nodesBetween(c,u,(g,y)=>{i&&i===g.type&&(h=Math.max(y,c),p=Math.min(y+g.nodeSize,u),d=y,f=g)}):r.doc.nodesBetween(c,u,(g,y)=>{y<c&&i&&i===g.type&&(h=Math.max(y,c),p=Math.min(y+g.nodeSize,u),d=y,f=g),y>=c&&y<=u&&(i&&i===g.type&&t.setNodeMarkup(y,void 0,{...g.attrs,...e}),o&&g.marks.length&&g.marks.forEach(b=>{if(o===b.type){const x=Math.max(y,c),C=Math.min(y+g.nodeSize,u);t.addMark(x,C,o.create({...b.attrs,...e}))}}))}),f&&(d!==void 0&&t.setNodeMarkup(d,void 0,{...f.attrs,...e}),o&&f.marks.length&&f.marks.forEach(g=>{o===g.type&&t.addMark(h,p,o.create({...g.attrs,...e}))}))}),!0):!1},gy=(n,e={})=>({state:t,dispatch:r})=>{const s=fe(n,t.schema);return Om(s,e)(t,r)},yy=(n,e={})=>({state:t,dispatch:r})=>{const s=fe(n,t.schema);return Rm(s,e)(t,r)};var by=Object.freeze({__proto__:null,blur:Zm,clearContent:eg,clearNodes:tg,command:ng,createParagraphNear:rg,cut:sg,deleteCurrentNode:ig,deleteNode:og,deleteRange:lg,deleteSelection:ag,enter:cg,exitCode:ug,extendMarkRange:dg,first:fg,focus:pg,forEach:mg,insertContent:gg,insertContentAt:xg,joinBackward:wg,joinDown:Sg,joinForward:Cg,joinItemBackward:vg,joinItemForward:Mg,joinTextblockBackward:Eg,joinTextblockForward:Tg,joinUp:kg,keyboardShortcut:Ng,lift:Og,liftEmptyBlock:Rg,liftListItem:Lg,newlineInCode:Dg,resetAttributes:Ig,scrollIntoView:Pg,selectAll:jg,selectNodeBackward:Bg,selectNodeForward:zg,selectParentNode:Hg,selectTextblockEnd:_g,selectTextblockStart:Fg,setContent:$g,setMark:ey,setMeta:ty,setNode:ny,setNodeSelection:ry,setTextSelection:sy,sinkListItem:iy,splitBlock:oy,splitListItem:ly,toggleList:ay,toggleMark:cy,toggleNode:uy,toggleWrap:dy,undoInputRule:fy,unsetAllMarks:hy,unsetMark:py,updateAttributes:my,wrapIn:gy,wrapInList:yy});const xy=le.create({name:"commands",addCommands(){return{...by}}}),ky=le.create({name:"drop",addProseMirrorPlugins(){return[new se({key:new ae("tiptapDrop"),props:{handleDrop:(n,e,t,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:t,moved:r})}}})]}}),Sy=le.create({name:"editable",addProseMirrorPlugins(){return[new se({key:new ae("editable"),props:{editable:()=>this.editor.options.editable}})]}}),wy=new ae("focusEvents"),Cy=le.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:n}=this;return[new se({key:wy,props:{handleDOMEvents:{focus:(e,t)=>{n.isFocused=!0;const r=n.state.tr.setMeta("focus",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,t)=>{n.isFocused=!1;const r=n.state.tr.setMeta("blur",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),vy=le.create({name:"keymap",addKeyboardShortcuts(){const n=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:l})=>{const{selection:a,doc:c}=l,{empty:u,$anchor:d}=a,{pos:f,parent:h}=d,p=d.parent.isTextblock&&f>0?l.doc.resolve(f-1):d,g=p.parent.type.spec.isolating,y=d.pos-d.parentOffset,b=g&&p.parent.childCount===1?y===d.pos:B.atStart(c).from===f;return!u||!h.type.isTextblock||h.textContent.length||!b||b&&d.parent.type.name==="paragraph"?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:n,"Mod-Backspace":n,"Shift-Backspace":n,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},s={...r},i={...r,"Ctrl-h":n,"Alt-Backspace":n,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return er()||Zu()?i:s},addProseMirrorPlugins(){return[new se({key:new ae("clearDocument"),appendTransaction:(n,e,t)=>{if(n.some(g=>g.getMeta("composition")))return;const r=n.some(g=>g.docChanged)&&!e.doc.eq(t.doc),s=n.some(g=>g.getMeta("preventClearDocument"));if(!r||s)return;const{empty:i,from:o,to:l}=e.selection,a=B.atStart(e.doc).from,c=B.atEnd(e.doc).to;if(i||!(o===a&&l===c)||!Vs(t.doc))return;const f=t.tr,h=zs({state:t,transaction:f}),{commands:p}=new Hs({editor:this.editor,state:h});if(p.clearNodes(),!!f.steps.length)return f}})]}}),My=le.create({name:"paste",addProseMirrorPlugins(){return[new se({key:new ae("tiptapPaste"),props:{handlePaste:(n,e,t)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:t})}}})]}}),Ey=le.create({name:"tabindex",addProseMirrorPlugins(){return[new se({key:new ae("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});class Bt{get name(){return this.node.type.name}constructor(e,t,r=!1,s=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=t,this.currentNode=s}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!==null&&e!==void 0?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}t=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:t,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),t=this.resolvedPos.doc.resolve(e);return new Bt(t,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new Bt(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new Bt(e,this.editor)}get children(){const e=[];return this.node.content.forEach((t,r)=>{const s=t.isBlock&&!t.isTextblock,i=t.isAtom&&!t.isText,o=this.pos+r+(i?0:1);if(o<0||o>this.resolvedPos.doc.nodeSize-2)return;const l=this.resolvedPos.doc.resolve(o);if(!s&&l.depth<=this.depth)return;const a=new Bt(l,this.editor,s,s?t:null);s&&(a.actualDepth=this.depth+1),e.push(new Bt(l,this.editor,s,s?t:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,t={}){let r=null,s=this.parent;for(;s&&!r;){if(s.node.type.name===e)if(Object.keys(t).length>0){const i=s.node.attrs,o=Object.keys(t);for(let l=0;l<o.length;l+=1){const a=o[l];if(i[a]!==t[a])break}}else r=s;s=s.parent}return r}querySelector(e,t={}){return this.querySelectorAll(e,t,!0)[0]||null}querySelectorAll(e,t={},r=!1){let s=[];if(!this.children||this.children.length===0)return s;const i=Object.keys(t);return this.children.forEach(o=>{r&&s.length>0||(o.node.type.name===e&&i.every(a=>t[a]===o.node.attrs[a])&&s.push(o),!(r&&s.length>0)&&(s=s.concat(o.querySelectorAll(e,t,r))))}),s}setAttribute(e){const{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}}const Ty=`.ProseMirror {
|
|
14
|
+
position: relative;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.ProseMirror {
|
|
18
|
+
word-wrap: break-word;
|
|
19
|
+
white-space: pre-wrap;
|
|
20
|
+
white-space: break-spaces;
|
|
21
|
+
-webkit-font-variant-ligatures: none;
|
|
22
|
+
font-variant-ligatures: none;
|
|
23
|
+
font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.ProseMirror [contenteditable="false"] {
|
|
27
|
+
white-space: normal;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.ProseMirror [contenteditable="false"] [contenteditable="true"] {
|
|
31
|
+
white-space: pre-wrap;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.ProseMirror pre {
|
|
35
|
+
white-space: pre-wrap;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
img.ProseMirror-separator {
|
|
39
|
+
display: inline !important;
|
|
40
|
+
border: none !important;
|
|
41
|
+
margin: 0 !important;
|
|
42
|
+
width: 0 !important;
|
|
43
|
+
height: 0 !important;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.ProseMirror-gapcursor {
|
|
47
|
+
display: none;
|
|
48
|
+
pointer-events: none;
|
|
49
|
+
position: absolute;
|
|
50
|
+
margin: 0;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.ProseMirror-gapcursor:after {
|
|
54
|
+
content: "";
|
|
55
|
+
display: block;
|
|
56
|
+
position: absolute;
|
|
57
|
+
top: -2px;
|
|
58
|
+
width: 20px;
|
|
59
|
+
border-top: 1px solid black;
|
|
60
|
+
animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
@keyframes ProseMirror-cursor-blink {
|
|
64
|
+
to {
|
|
65
|
+
visibility: hidden;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.ProseMirror-hideselection *::selection {
|
|
70
|
+
background: transparent;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.ProseMirror-hideselection *::-moz-selection {
|
|
74
|
+
background: transparent;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.ProseMirror-hideselection * {
|
|
78
|
+
caret-color: transparent;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.ProseMirror-focused .ProseMirror-gapcursor {
|
|
82
|
+
display: block;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.tippy-box[data-animation=fade][data-state=hidden] {
|
|
86
|
+
opacity: 0
|
|
87
|
+
}`;function Ay(n,e,t){const r=document.querySelector("style[data-tiptap-style]");if(r!==null)return r;const s=document.createElement("style");return e&&s.setAttribute("nonce",e),s.setAttribute("data-tiptap-style",""),s.innerHTML=n,document.getElementsByTagName("head")[0].appendChild(s),s}let Ny=class extends zm{constructor(e={}){super(),this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.options={element:document.createElement("div"),content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:t})=>{throw t},onPaste:()=>null,onDrop:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("contentError",this.options.onContentError),this.createView(),this.injectCSS(),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:t,slice:r,moved:s})=>this.options.onDrop(t,r,s)),this.on("paste",({event:t,slice:r})=>this.options.onPaste(t,r)),window.setTimeout(()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&document&&(this.css=Ay(Ty,this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},!(!this.view||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(e,t=!0){this.setOptions({editable:e}),t&&this.emit("update",{editor:this,transaction:this.state.tr})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get state(){return this.view.state}registerPlugin(e,t){const r=Uu(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],s=this.state.reconfigure({plugins:r});return this.view.updateState(s),s}unregisterPlugin(e){if(this.isDestroyed)return;const t=this.state.plugins;let r=t;if([].concat(e).forEach(i=>{const o=typeof i=="string"?`${i}$`:i.key;r=r.filter(l=>!l.key.startsWith(o))}),t.length===r.length)return;const s=this.state.reconfigure({plugins:r});return this.view.updateState(s),s}createExtensionManager(){var e,t;const s=[...this.options.enableCoreExtensions?[Sy,Qm.configure({blockSeparator:(t=(e=this.options.coreExtensionOptions)===null||e===void 0?void 0:e.clipboardTextSerializer)===null||t===void 0?void 0:t.blockSeparator}),xy,Cy,vy,Ey,ky,My].filter(i=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[i.name]!==!1:!0):[],...this.options.extensions].filter(i=>["extension","node","mark"].includes(i?.type));this.extensionManager=new pn(s,this)}createCommandManager(){this.commandManager=new Hs({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){var e;let t;try{t=Ji(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(o){if(!(o instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(o.message))throw o;this.emit("contentError",{editor:this,error:o,disableCollaboration:()=>{this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(l=>l.name!=="collaboration"),this.createExtensionManager()}}),t=Ji(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}const r=Xu(t,this.options.autofocus);this.view=new Ru(this.options.element,{...this.options.editorProps,attributes:{role:"textbox",...(e=this.options.editorProps)===null||e===void 0?void 0:e.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:hn.create({doc:t,selection:r||void 0})});const s=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(s),this.createNodeViews(),this.prependClass();const i=this.view.dom;i.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`tiptap ${this.view.dom.className}`}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;const t=this.capturedTransaction;return this.capturedTransaction=null,t}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=e;return}e.steps.forEach(o=>{var l;return(l=this.capturedTransaction)===null||l===void 0?void 0:l.step(o)});return}const t=this.state.apply(e),r=!this.state.selection.eq(t.selection);this.emit("beforeTransaction",{editor:this,transaction:e,nextState:t}),this.view.updateState(t),this.emit("transaction",{editor:this,transaction:e}),r&&this.emit("selectionUpdate",{editor:this,transaction:e});const s=e.getMeta("focus"),i=e.getMeta("blur");s&&this.emit("focus",{editor:this,event:s.event,transaction:e}),i&&this.emit("blur",{editor:this,event:i.event,transaction:e}),!(!e.docChanged||e.getMeta("preventUpdate"))&&this.emit("update",{editor:this,transaction:e})}getAttributes(e){return nd(this.state,e)}isActive(e,t){const r=typeof e=="string"?e:null,s=typeof e=="string"?t:e;return Xg(this.state,r,s)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Ho(this.state.doc.content,this.schema)}getText(e){const{blockSeparator:t=`
|
|
88
|
+
|
|
89
|
+
`,textSerializers:r={}}=e||{};return Kg(this.state.doc,{blockSeparator:t,textSerializers:{...Gu(this.schema),...r}})}get isEmpty(){return Vs(this.state.doc)}getCharacterCount(){return console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.'),this.state.doc.content.size-2}destroy(){if(this.emit("destroy"),this.view){const e=this.view.dom;e&&e.editor&&delete e.editor,this.view.destroy()}this.removeAllListeners()}get isDestroyed(){var e;return!(!((e=this.view)===null||e===void 0)&&e.docView)}$node(e,t){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelector(e,t))||null}$nodes(e,t){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelectorAll(e,t))||null}$pos(e){const t=this.state.doc.resolve(e);return new Bt(t,this)}get $doc(){return this.$pos(0)}};function Zt(n){return new wn({find:n.find,handler:({state:e,range:t,match:r})=>{const s=F(n.getAttributes,void 0,r);if(s===!1||s===null)return null;const{tr:i}=e,o=r[r.length-1],l=r[0];if(o){const a=l.search(/\S/),c=t.from+l.indexOf(o),u=c+o.length;if(Vo(t.from,t.to,e.doc).filter(h=>h.mark.type.excluded.find(g=>g===n.type&&g!==h.mark.type)).filter(h=>h.to>c).length)return null;u<t.to&&i.delete(u,t.to),c>t.from&&i.delete(t.from+a,c);const f=t.from+a+o.length;i.addMark(t.from+a,f,n.type.create(s||{})),i.removeStoredMark(n.type)}}})}function rd(n){return new wn({find:n.find,handler:({state:e,range:t,match:r})=>{const s=F(n.getAttributes,void 0,r)||{},{tr:i}=e,o=t.from;let l=t.to;const a=n.type.create(s);if(r[1]){const c=r[0].lastIndexOf(r[1]);let u=o+c;u>l?u=l:l=u+r[1].length;const d=r[0][r[0].length-1];i.insertText(d,o+r[0].length-1),i.replaceWith(u,l,a)}else if(r[0]){const c=n.type.isInline?o:o-1;i.insert(c,n.type.create(s)).delete(i.mapping.map(o),i.mapping.map(l))}i.scrollIntoView()}})}function Qi(n){return new wn({find:n.find,handler:({state:e,range:t,match:r})=>{const s=e.doc.resolve(t.from),i=F(n.getAttributes,void 0,r)||{};if(!s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),n.type))return null;e.tr.delete(t.from,t.to).setBlockType(t.from,t.from,n.type,i)}})}function Cn(n){return new wn({find:n.find,handler:({state:e,range:t,match:r,chain:s})=>{const i=F(n.getAttributes,void 0,r)||{},o=e.tr.delete(t.from,t.to),a=o.doc.resolve(t.from).blockRange(),c=a&&So(a,n.type,i);if(!c)return null;if(o.wrap(a,c),n.keepMarks&&n.editor){const{selection:d,storedMarks:f}=e,{splittableMarks:h}=n.editor.extensionManager,p=f||d.$to.parentOffset&&d.$from.marks();if(p){const g=p.filter(y=>h.includes(y.type.name));o.ensureMarks(g)}}if(n.keepAttributes){const d=n.type.name==="bulletList"||n.type.name==="orderedList"?"listItem":"taskList";s().updateAttributes(d,i).run()}const u=o.doc.resolve(t.from-1).nodeBefore;u&&u.type===n.type&&Rt(o.doc,t.from-1)&&(!n.joinPredicate||n.joinPredicate(r,u))&&o.join(t.from-1)}})}let ie=class Zi{constructor(e={}){this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=F(L(this,"addOptions",{name:this.name}))),this.storage=F(L(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new Zi(e)}configure(e={}){const t=this.extend({...this.config,addOptions:()=>Fs(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const t=new Zi(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=F(L(t,"addOptions",{name:t.name})),t.storage=F(L(t,"addStorage",{name:t.name,options:t.options})),t}};class Oy{constructor(e,t,r){this.isDragging=!1,this.component=e,this.editor=t.editor,this.options={stopEvent:null,ignoreMutation:null,...r},this.extension=t.extension,this.node=t.node,this.decorations=t.decorations,this.innerDecorations=t.innerDecorations,this.view=t.view,this.HTMLAttributes=t.HTMLAttributes,this.getPos=t.getPos,this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(e){var t,r,s,i,o,l,a;const{view:c}=this.editor,u=e.target,d=u.nodeType===3?(t=u.parentElement)===null||t===void 0?void 0:t.closest("[data-drag-handle]"):u.closest("[data-drag-handle]");if(!this.dom||!((r=this.contentDOM)===null||r===void 0)&&r.contains(u)||!d)return;let f=0,h=0;if(this.dom!==d){const x=this.dom.getBoundingClientRect(),C=d.getBoundingClientRect(),k=(s=e.offsetX)!==null&&s!==void 0?s:(i=e.nativeEvent)===null||i===void 0?void 0:i.offsetX,M=(o=e.offsetY)!==null&&o!==void 0?o:(l=e.nativeEvent)===null||l===void 0?void 0:l.offsetY;f=C.x-x.x+k,h=C.y-x.y+M}const p=this.dom.cloneNode(!0);(a=e.dataTransfer)===null||a===void 0||a.setDragImage(p,f,h);const g=this.getPos();if(typeof g!="number")return;const y=I.create(c.state.doc,g),b=c.state.tr.setSelection(y);c.dispatch(b)}stopEvent(e){var t;if(!this.dom)return!1;if(typeof this.options.stopEvent=="function")return this.options.stopEvent({event:e});const r=e.target;if(!(this.dom.contains(r)&&!(!((t=this.contentDOM)===null||t===void 0)&&t.contains(r))))return!1;const i=e.type.startsWith("drag"),o=e.type==="drop";if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(r.tagName)||r.isContentEditable)&&!o&&!i)return!0;const{isEditable:a}=this.editor,{isDragging:c}=this,u=!!this.node.type.spec.draggable,d=I.isSelectable(this.node),f=e.type==="copy",h=e.type==="paste",p=e.type==="cut",g=e.type==="mousedown";if(!u&&d&&i&&e.target===this.dom&&e.preventDefault(),u&&i&&!c&&e.target===this.dom)return e.preventDefault(),!1;if(u&&a&&!c&&g){const y=r.closest("[data-drag-handle]");y&&(this.dom===y||this.dom.contains(y))&&(this.isDragging=!0,document.addEventListener("dragend",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("drop",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("mouseup",()=>{this.isDragging=!1},{once:!0}))}return!(c||o||f||h||p||g&&d)}ignoreMutation(e){return!this.dom||!this.contentDOM?!0:typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:e}):this.node.isLeaf||this.node.isAtom?!0:e.type==="selection"||this.dom.contains(e.target)&&e.type==="childList"&&(er()||Gi())&&this.editor.isFocused&&[...Array.from(e.addedNodes),...Array.from(e.removedNodes)].every(r=>r.isContentEditable)?!1:this.contentDOM===e.target&&e.type==="attributes"?!0:!this.contentDOM.contains(e.target)}updateAttributes(e){this.editor.commands.command(({tr:t})=>{const r=this.getPos();return typeof r!="number"?!1:(t.setNodeMarkup(r,void 0,{...this.node.attrs,...e}),!0)})}deleteNode(){const e=this.getPos();if(typeof e!="number")return;const t=e+this.node.nodeSize;this.editor.commands.deleteRange({from:e,to:t})}}function Ot(n){return new Ku({find:n.find,handler:({state:e,range:t,match:r,pasteEvent:s})=>{const i=F(n.getAttributes,void 0,r,s);if(i===!1||i===null)return null;const{tr:o}=e,l=r[r.length-1],a=r[0];let c=t.to;if(l){const u=a.search(/\S/),d=t.from+a.indexOf(l),f=d+l.length;if(Vo(t.from,t.to,e.doc).filter(p=>p.mark.type.excluded.find(y=>y===n.type&&y!==p.mark.type)).filter(p=>p.to>d).length)return null;f<t.to&&o.delete(f,t.to),d>t.from&&o.delete(t.from+u,d),c=t.from+u+l.length,o.addMark(t.from+u,c,n.type.create(i||{})),o.removeStoredMark(n.type)}}})}function Ry(n,e){const{selection:t}=n,{$from:r}=t;if(t instanceof I){const i=r.index();return r.parent.canReplaceWith(i,i+1,e)}let s=r.depth;for(;s>=0;){const i=r.index(s);if(r.node(s).contentMatchAt(i).matchType(e))return!0;s-=1}return!1}function Ly(n){return new Ku({find:n.find,handler({match:e,chain:t,range:r,pasteEvent:s}){const i=F(n.getAttributes,void 0,e,s),o=F(n.getContent,void 0,i);if(i===!1||i===null)return null;const l={type:n.type.name,attrs:i};o&&(l.content=o),e.input&&t().deleteRange(r).insertContentAt(r.from,l)}})}function Dy(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var eo={exports:{}},gi={};/**
|
|
90
|
+
* @license React
|
|
91
|
+
* use-sync-external-store-shim.production.min.js
|
|
92
|
+
*
|
|
93
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
94
|
+
*
|
|
95
|
+
* This source code is licensed under the MIT license found in the
|
|
96
|
+
* LICENSE file in the root directory of this source tree.
|
|
97
|
+
*/var Ea;function Iy(){if(Ea)return gi;Ea=1;var n=S;function e(d,f){return d===f&&(d!==0||1/d===1/f)||d!==d&&f!==f}var t=typeof Object.is=="function"?Object.is:e,r=n.useState,s=n.useEffect,i=n.useLayoutEffect,o=n.useDebugValue;function l(d,f){var h=f(),p=r({inst:{value:h,getSnapshot:f}}),g=p[0].inst,y=p[1];return i(function(){g.value=h,g.getSnapshot=f,a(g)&&y({inst:g})},[d,h,f]),s(function(){return a(g)&&y({inst:g}),d(function(){a(g)&&y({inst:g})})},[d]),o(h),h}function a(d){var f=d.getSnapshot;d=d.value;try{var h=f();return!t(d,h)}catch{return!0}}function c(d,f){return f()}var u=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?c:l;return gi.useSyncExternalStore=n.useSyncExternalStore!==void 0?n.useSyncExternalStore:u,gi}var yi={};/**
|
|
98
|
+
* @license React
|
|
99
|
+
* use-sync-external-store-shim.development.js
|
|
100
|
+
*
|
|
101
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
102
|
+
*
|
|
103
|
+
* This source code is licensed under the MIT license found in the
|
|
104
|
+
* LICENSE file in the root directory of this source tree.
|
|
105
|
+
*/var Ta;function Py(){return Ta||(Ta=1,process.env.NODE_ENV!=="production"&&function(){typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var n=S,e=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function t(C){{for(var k=arguments.length,M=new Array(k>1?k-1:0),R=1;R<k;R++)M[R-1]=arguments[R];r("error",C,M)}}function r(C,k,M){{var R=e.ReactDebugCurrentFrame,z=R.getStackAddendum();z!==""&&(k+="%s",M=M.concat([z]));var w=M.map(function(j){return String(j)});w.unshift("Warning: "+k),Function.prototype.apply.call(console[C],console,w)}}function s(C,k){return C===k&&(C!==0||1/C===1/k)||C!==C&&k!==k}var i=typeof Object.is=="function"?Object.is:s,o=n.useState,l=n.useEffect,a=n.useLayoutEffect,c=n.useDebugValue,u=!1,d=!1;function f(C,k,M){u||n.startTransition!==void 0&&(u=!0,t("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var R=k();if(!d){var z=k();i(R,z)||(t("The result of getSnapshot should be cached to avoid an infinite loop"),d=!0)}var w=o({inst:{value:R,getSnapshot:k}}),j=w[0].inst,G=w[1];return a(function(){j.value=R,j.getSnapshot=k,h(j)&&G({inst:j})},[C,R,k]),l(function(){h(j)&&G({inst:j});var Ae=function(){h(j)&&G({inst:j})};return C(Ae)},[C]),c(R),R}function h(C){var k=C.getSnapshot,M=C.value;try{var R=k();return!i(M,R)}catch{return!0}}function p(C,k,M){return k()}var g=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",y=!g,b=y?p:f,x=n.useSyncExternalStore!==void 0?n.useSyncExternalStore:b;yi.useSyncExternalStore=x,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),yi}process.env.NODE_ENV==="production"?eo.exports=Iy():eo.exports=Py();var Ws=eo.exports;const jy=(...n)=>e=>{n.forEach(t=>{typeof t=="function"?t(e):t&&(t.current=e)})},By=({contentComponent:n})=>{const e=Ws.useSyncExternalStore(n.subscribe,n.getSnapshot,n.getServerSnapshot);return S.createElement(S.Fragment,null,Object.values(e))};function zy(){const n=new Set;let e={};return{subscribe(t){return n.add(t),()=>{n.delete(t)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(t,r){e={...e,[t]:bo.createPortal(r.reactElement,r.element,t)},n.forEach(s=>s())},removeRenderer(t){const r={...e};delete r[t],e=r,n.forEach(s=>s())}}}class Hy extends S.Component{constructor(e){var t;super(e),this.editorContentRef=S.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!(!((t=e.editor)===null||t===void 0)&&t.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){const e=this.props.editor;if(e&&!e.isDestroyed&&e.options.element){if(e.contentComponent)return;const t=this.editorContentRef.current;t.append(...e.options.element.childNodes),e.setOptions({element:t}),e.contentComponent=zy(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=e.contentComponent.subscribe(()=>{this.setState(r=>r.hasContentComponentInitialized?r:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),e.createNodeViews(),this.initialized=!0}}componentWillUnmount(){const e=this.props.editor;if(!e||(this.initialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),e.contentComponent=null,!e.options.element.firstChild))return;const t=document.createElement("div");t.append(...e.options.element.childNodes),e.setOptions({element:t})}render(){const{editor:e,innerRef:t,...r}=this.props;return S.createElement(S.Fragment,null,S.createElement("div",{ref:jy(t,this.editorContentRef),...r}),e?.contentComponent&&S.createElement(By,{contentComponent:e.contentComponent}))}}const _y=S.forwardRef((n,e)=>{const t=S.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[n.editor]);return S.createElement(Hy,{key:t,innerRef:e,...n})}),Fy=S.memo(_y);var $y=function n(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){if(e.constructor!==t.constructor)return!1;var r,s,i;if(Array.isArray(e)){if(r=e.length,r!=t.length)return!1;for(s=r;s--!==0;)if(!n(e[s],t[s]))return!1;return!0}if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(s of e.entries())if(!t.has(s[0]))return!1;for(s of e.entries())if(!n(s[1],t.get(s[0])))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(s of e.entries())if(!t.has(s[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){if(r=e.length,r!=t.length)return!1;for(s=r;s--!==0;)if(e[s]!==t[s])return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString();if(i=Object.keys(e),r=i.length,r!==Object.keys(t).length)return!1;for(s=r;s--!==0;)if(!Object.prototype.hasOwnProperty.call(t,i[s]))return!1;for(s=r;s--!==0;){var o=i[s];if(!(o==="_owner"&&e.$$typeof)&&!n(e[o],t[o]))return!1}return!0}return e!==e&&t!==t},Vy=Dy($y),to={exports:{}},bi={};/**
|
|
106
|
+
* @license React
|
|
107
|
+
* use-sync-external-store-shim/with-selector.production.min.js
|
|
108
|
+
*
|
|
109
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
110
|
+
*
|
|
111
|
+
* This source code is licensed under the MIT license found in the
|
|
112
|
+
* LICENSE file in the root directory of this source tree.
|
|
113
|
+
*/var Aa;function Wy(){if(Aa)return bi;Aa=1;var n=S,e=Ws;function t(c,u){return c===u&&(c!==0||1/c===1/u)||c!==c&&u!==u}var r=typeof Object.is=="function"?Object.is:t,s=e.useSyncExternalStore,i=n.useRef,o=n.useEffect,l=n.useMemo,a=n.useDebugValue;return bi.useSyncExternalStoreWithSelector=function(c,u,d,f,h){var p=i(null);if(p.current===null){var g={hasValue:!1,value:null};p.current=g}else g=p.current;p=l(function(){function b(R){if(!x){if(x=!0,C=R,R=f(R),h!==void 0&&g.hasValue){var z=g.value;if(h(z,R))return k=z}return k=R}if(z=k,r(C,R))return z;var w=f(R);return h!==void 0&&h(z,w)?z:(C=R,k=w)}var x=!1,C,k,M=d===void 0?null:d;return[function(){return b(u())},M===null?void 0:function(){return b(M())}]},[u,d,f,h]);var y=s(c,p[0],p[1]);return o(function(){g.hasValue=!0,g.value=y},[y]),a(y),y},bi}var xi={};/**
|
|
114
|
+
* @license React
|
|
115
|
+
* use-sync-external-store-shim/with-selector.development.js
|
|
116
|
+
*
|
|
117
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
118
|
+
*
|
|
119
|
+
* This source code is licensed under the MIT license found in the
|
|
120
|
+
* LICENSE file in the root directory of this source tree.
|
|
121
|
+
*/var Na;function Uy(){return Na||(Na=1,process.env.NODE_ENV!=="production"&&function(){typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var n=S,e=Ws;function t(u,d){return u===d&&(u!==0||1/u===1/d)||u!==u&&d!==d}var r=typeof Object.is=="function"?Object.is:t,s=e.useSyncExternalStore,i=n.useRef,o=n.useEffect,l=n.useMemo,a=n.useDebugValue;function c(u,d,f,h,p){var g=i(null),y;g.current===null?(y={hasValue:!1,value:null},g.current=y):y=g.current;var b=l(function(){var M=!1,R,z,w=function(Be){if(!M){M=!0,R=Be;var Ve=h(Be);if(p!==void 0&&y.hasValue){var Le=y.value;if(p(Le,Ve))return z=Le,Le}return z=Ve,Ve}var ve=R,Ne=z;if(r(ve,Be))return Ne;var E=h(Be);return p!==void 0&&p(Ne,E)?Ne:(R=Be,z=E,E)},j=f===void 0?null:f,G=function(){return w(d())},Ae=j===null?void 0:function(){return w(j())};return[G,Ae]},[d,f,h,p]),x=b[0],C=b[1],k=s(u,x,C);return o(function(){y.hasValue=!0,y.value=k},[k]),a(k),k}xi.useSyncExternalStoreWithSelector=c,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),xi}process.env.NODE_ENV==="production"?to.exports=Wy():to.exports=Uy();var Ky=to.exports;const qy=typeof window<"u"?S.useLayoutEffect:S.useEffect;class Gy{constructor(e){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=e,this.lastSnapshot={editor:e,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}watch(e){if(this.editor=e,this.editor){const t=()=>{this.transactionNumber+=1,this.subscribers.forEach(s=>s())},r=this.editor;return r.on("transaction",t),()=>{r.off("transaction",t)}}}}function Jy(n){var e;const[t]=S.useState(()=>new Gy(n.editor)),r=Ky.useSyncExternalStoreWithSelector(t.subscribe,t.getSnapshot,t.getServerSnapshot,n.selector,(e=n.equalityFn)!==null&&e!==void 0?e:Vy);return qy(()=>t.watch(n.editor),[n.editor,t]),S.useDebugValue(r),r}const Oa=process.env.NODE_ENV!=="production",no=typeof window>"u",Yy=no||!!(typeof window<"u"&&window.next);class Wo{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(t=>t())}getInitialEditor(){if(this.options.current.immediatelyRender===void 0)return no||Yy?(Oa&&console.warn("Tiptap Error: SSR has been detected, please set `immediatelyRender` explicitly to `false` to avoid hydration mismatches."),null):this.createEditor();if(this.options.current.immediatelyRender&&no&&Oa)throw new Error("Tiptap Error: SSR has been detected, and `immediatelyRender` has been set to `true` this is an unsupported configuration that may result in errors, explicitly set `immediatelyRender` to `false` to avoid hydration mismatches.");return this.options.current.immediatelyRender?this.createEditor():null}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var s,i;return(i=(s=this.options.current).onBeforeCreate)===null||i===void 0?void 0:i.call(s,...r)},onBlur:(...r)=>{var s,i;return(i=(s=this.options.current).onBlur)===null||i===void 0?void 0:i.call(s,...r)},onCreate:(...r)=>{var s,i;return(i=(s=this.options.current).onCreate)===null||i===void 0?void 0:i.call(s,...r)},onDestroy:(...r)=>{var s,i;return(i=(s=this.options.current).onDestroy)===null||i===void 0?void 0:i.call(s,...r)},onFocus:(...r)=>{var s,i;return(i=(s=this.options.current).onFocus)===null||i===void 0?void 0:i.call(s,...r)},onSelectionUpdate:(...r)=>{var s,i;return(i=(s=this.options.current).onSelectionUpdate)===null||i===void 0?void 0:i.call(s,...r)},onTransaction:(...r)=>{var s,i;return(i=(s=this.options.current).onTransaction)===null||i===void 0?void 0:i.call(s,...r)},onUpdate:(...r)=>{var s,i;return(i=(s=this.options.current).onUpdate)===null||i===void 0?void 0:i.call(s,...r)},onContentError:(...r)=>{var s,i;return(i=(s=this.options.current).onContentError)===null||i===void 0?void 0:i.call(s,...r)},onDrop:(...r)=>{var s,i;return(i=(s=this.options.current).onDrop)===null||i===void 0?void 0:i.call(s,...r)},onPaste:(...r)=>{var s,i;return(i=(s=this.options.current).onPaste)===null||i===void 0?void 0:i.call(s,...r)}};return new Ny(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,t){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&t.extensions?e.extensions.length!==t.extensions.length?!1:e.extensions.every((s,i)=>{var o;return s===((o=t.extensions)===null||o===void 0?void 0:o[i])}):e[r]===t[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?Wo.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(e),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((r,s)=>r===e[s]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,t=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){t&&t.setOptions(this.options.current);return}t&&!t.isDestroyed&&(t.destroy(),this.instanceId===e&&this.setEditor(null))},1)}}function Xy(n={},e=[]){const t=S.useRef(n);t.current=n;const[r]=S.useState(()=>new Wo(t)),s=Ws.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return S.useDebugValue(s),S.useEffect(r.onRender(e)),Jy({editor:s,selector:({transactionNumber:i})=>n.shouldRerenderOnTransaction===!1?null:n.immediatelyRender&&i===0?0:i+1}),s}const Qy=S.createContext({editor:null});Qy.Consumer;const sd=S.createContext({onDragStart:void 0}),Zy=()=>S.useContext(sd),Uo=S.forwardRef((n,e)=>{const{onDragStart:t}=Zy(),r=n.as||"div";return S.createElement(r,{...n,ref:e,"data-node-view-wrapper":"",onDragStart:t,style:{whiteSpace:"normal",...n.style}})});function Ra(n){return!!(typeof n=="function"&&n.prototype&&n.prototype.isReactComponent)}function La(n){return!!(typeof n=="object"&&n.$$typeof&&(n.$$typeof.toString()==="Symbol(react.forward_ref)"||n.$$typeof.description==="react.forward_ref"))}function eb(n){return!!(typeof n=="object"&&n.$$typeof&&(n.$$typeof.toString()==="Symbol(react.memo)"||n.$$typeof.description==="react.memo"))}function tb(n){if(Ra(n)||La(n))return!0;if(eb(n)){const e=n.type;if(e)return Ra(e)||La(e)}return!1}function nb(){try{if(S.version)return parseInt(S.version.split(".")[0],10)>=19}catch{}return!1}class rb{constructor(e,{editor:t,props:r={},as:s="div",className:i=""}){this.ref=null,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=e,this.editor=t,this.props=r,this.element=document.createElement(s),this.element.classList.add("react-renderer"),i&&this.element.classList.add(...i.split(" ")),this.editor.isInitialized?bo.flushSync(()=>{this.render()}):queueMicrotask(()=>{this.render()})}render(){var e;const t=this.component,r=this.props,s=this.editor,i=nb(),o=tb(t),l={...r};l.ref&&!(i||o)&&delete l.ref,!l.ref&&(i||o)&&(l.ref=a=>{this.ref=a}),this.reactElement=S.createElement(t,{...l}),(e=s?.contentComponent)===null||e===void 0||e.setRenderer(this.id,this)}updateProps(e={}){this.props={...this.props,...e},this.render()}destroy(){var e;const t=this.editor;(e=t?.contentComponent)===null||e===void 0||e.removeRenderer(this.id)}updateAttributes(e){Object.keys(e).forEach(t=>{this.element.setAttribute(t,e[t])})}}class sb extends Oy{constructor(e,t,r){if(super(e,t,r),!this.node.isLeaf){this.options.contentDOMElementTag?this.contentDOMElement=document.createElement(this.options.contentDOMElementTag):this.contentDOMElement=document.createElement(this.node.isInline?"span":"div"),this.contentDOMElement.dataset.nodeViewContentReact="",this.contentDOMElement.dataset.nodeViewWrapper="",this.contentDOMElement.style.whiteSpace="inherit";const s=this.dom.querySelector("[data-node-view-content]");if(!s)return;s.appendChild(this.contentDOMElement)}}mount(){const e={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extension,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(c={})=>this.updateAttributes(c),deleteNode:()=>this.deleteNode(),ref:S.createRef()};if(!this.component.displayName){const c=u=>u.charAt(0).toUpperCase()+u.substring(1);this.component.displayName=c(this.extension.name)}const s={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:c=>{c&&this.contentDOMElement&&c.firstChild!==this.contentDOMElement&&(c.hasAttribute("data-node-view-wrapper")&&c.removeAttribute("data-node-view-wrapper"),c.appendChild(this.contentDOMElement))}},i=this.component,o=S.memo(c=>S.createElement(sd.Provider,{value:s},S.createElement(i,c)));o.displayName="ReactNodeView";let l=this.node.isInline?"span":"div";this.options.as&&(l=this.options.as);const{className:a=""}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new rb(o,{editor:this.editor,props:e,as:l,className:`node-${this.node.type.name} ${a}`.trim()}),this.editor.on("selectionUpdate",this.handleSelectionUpdate),this.updateElementAttributes()}get dom(){var e;if(this.renderer.element.firstElementChild&&!(!((e=this.renderer.element.firstElementChild)===null||e===void 0)&&e.hasAttribute("data-node-view-wrapper")))throw Error("Please use the NodeViewWrapper component for your node view.");return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}handleSelectionUpdate(){const{from:e,to:t}=this.editor.state.selection,r=this.getPos();if(typeof r=="number")if(e<=r&&t>=r+this.node.nodeSize){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}}update(e,t,r){const s=i=>{this.renderer.updateProps(i),typeof this.options.attrs=="function"&&this.updateElementAttributes()};if(e.type!==this.node.type)return!1;if(typeof this.options.update=="function"){const i=this.node,o=this.decorations,l=this.innerDecorations;return this.node=e,this.decorations=t,this.innerDecorations=r,this.options.update({oldNode:i,oldDecorations:o,newNode:e,newDecorations:t,oldInnerDecorations:l,innerDecorations:r,updateProps:()=>s({node:e,decorations:t,innerDecorations:r})})}return e===this.node&&this.decorations===t&&this.innerDecorations===r||(this.node=e,this.decorations=t,this.innerDecorations=r,s({node:e,decorations:t,innerDecorations:r})),!0}selectNode(){this.renderer.updateProps({selected:!0}),this.renderer.element.classList.add("ProseMirror-selectednode")}deselectNode(){this.renderer.updateProps({selected:!1}),this.renderer.element.classList.remove("ProseMirror-selectednode")}destroy(){this.renderer.destroy(),this.editor.off("selectionUpdate",this.handleSelectionUpdate),this.contentDOMElement=null}updateElementAttributes(){if(this.options.attrs){let e={};if(typeof this.options.attrs=="function"){const t=this.editor.extensionManager.attributes,r=Yr(this.node,t);e=this.options.attrs({node:this.node,HTMLAttributes:r})}else e=this.options.attrs;this.renderer.updateAttributes(e)}}}function Ko(n,e){return t=>t.editor.contentComponent?new sb(n,t,e):{}}const ib=/^\s*>\s$/,id=ie.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:n}){return["blockquote",K(this.options.HTMLAttributes,n),0]},addCommands(){return{setBlockquote:()=>({commands:n})=>n.wrapIn(this.name),toggleBlockquote:()=>({commands:n})=>n.toggleWrap(this.name),unsetBlockquote:()=>({commands:n})=>n.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[Cn({find:ib,type:this.type})]}}),ob=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,lb=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,ab=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,cb=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,ub=Se.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:n=>n.type.name===this.name},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&null}]},renderHTML({HTMLAttributes:n}){return["strong",K(this.options.HTMLAttributes,n),0]},addCommands(){return{setBold:()=>({commands:n})=>n.setMark(this.name),toggleBold:()=>({commands:n})=>n.toggleMark(this.name),unsetBold:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[Zt({find:ob,type:this.type}),Zt({find:ab,type:this.type})]},addPasteRules(){return[Ot({find:lb,type:this.type}),Ot({find:cb,type:this.type})]}}),db="listItem",Da="textStyle",Ia=/^\s*([-+*])\s$/,fb=ie.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:n}){return["ul",K(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleBulletList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(db,this.editor.getAttributes(Da)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let n=Cn({find:Ia,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(n=Cn({find:Ia,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Da),editor:this.editor})),[n]}}),hb=/(^|[^`])`([^`]+)`(?!`)/,pb=/(^|[^`])`([^`]+)`(?!`)/g,mb=Se.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:n}){return["code",K(this.options.HTMLAttributes,n),0]},addCommands(){return{setCode:()=>({commands:n})=>n.setMark(this.name),toggleCode:()=>({commands:n})=>n.toggleMark(this.name),unsetCode:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[Zt({find:hb,type:this.type})]},addPasteRules(){return[Ot({find:pb,type:this.type})]}}),gb=/^```([a-z]+)?[\s\n]$/,yb=/^~~~([a-z]+)?[\s\n]$/,od=ie.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:n=>{var e;const{languageClassPrefix:t}=this.options,i=[...((e=n.firstElementChild)===null||e===void 0?void 0:e.classList)||[]].filter(o=>o.startsWith(t)).map(o=>o.replace(t,""))[0];return i||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:n,HTMLAttributes:e}){return["pre",K(this.options.HTMLAttributes,e),["code",{class:n.attrs.language?this.options.languageClassPrefix+n.attrs.language:null},0]]},addCommands(){return{setCodeBlock:n=>({commands:e})=>e.setNode(this.name,n),toggleCodeBlock:n=>({commands:e})=>e.toggleNode(this.name,"paragraph",n)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:n,$anchor:e}=this.editor.state.selection,t=e.pos===1;return!n||e.parent.type.name!==this.name?!1:t||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:n})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=n,{selection:t}=e,{$from:r,empty:s}=t;if(!s||r.parent.type!==this.type)return!1;const i=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(`
|
|
122
|
+
|
|
123
|
+
`);return!i||!o?!1:n.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:n})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=n,{selection:t,doc:r}=e,{$from:s,empty:i}=t;if(!i||s.parent.type!==this.type||!(s.parentOffset===s.parent.nodeSize-2))return!1;const l=s.after();return l===void 0?!1:r.nodeAt(l)?n.commands.command(({tr:c})=>(c.setSelection(B.near(r.resolve(l))),!0)):n.commands.exitCode()}}},addInputRules(){return[Qi({find:gb,type:this.type,getAttributes:n=>({language:n[1]})}),Qi({find:yb,type:this.type,getAttributes:n=>({language:n[1]})})]},addProseMirrorPlugins(){return[new se({key:new ae("codeBlockVSCodeHandler"),props:{handlePaste:(n,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const t=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),s=r?JSON.parse(r):void 0,i=s?.mode;if(!t||!i)return!1;const{tr:o,schema:l}=n.state,a=l.text(t.replace(/\r\n?/g,`
|
|
124
|
+
`));return o.replaceSelectionWith(this.type.create({language:i},a)),o.selection.$from.parent.type!==this.type&&o.setSelection(P.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),n.dispatch(o),!0}}})]}}),bb=ie.create({name:"doc",topNode:!0,content:"block+"});function xb(n={}){return new se({view(e){return new kb(e,n)}})}class kb{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(s=>{let i=o=>{this[s](o)};return e.dom.addEventListener(s,i),{name:s,handler:i}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,r,s=this.editorView.dom,i=s.getBoundingClientRect(),o=i.width/s.offsetWidth,l=i.height/s.offsetHeight;if(t){let d=e.nodeBefore,f=e.nodeAfter;if(d||f){let h=this.editorView.nodeDOM(this.cursorPos-(d?d.nodeSize:0));if(h){let p=h.getBoundingClientRect(),g=d?p.bottom:p.top;d&&f&&(g=(g+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let y=this.width/2*l;r={left:p.left,right:p.right,top:g-y,bottom:g+y}}}}if(!r){let d=this.editorView.coordsAtPos(this.cursorPos),f=this.width/2*o;r={left:d.left-f,right:d.left+f,top:d.top,bottom:d.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let c,u;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,u=-pageYOffset;else{let d=a.getBoundingClientRect(),f=d.width/a.offsetWidth,h=d.height/a.offsetHeight;c=d.left-a.scrollLeft*f,u=d.top-a.scrollTop*h}this.element.style.left=(r.left-c)/o+"px",this.element.style.top=(r.top-u)/l+"px",this.element.style.width=(r.right-r.left)/o+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),s=r&&r.type.spec.disableDropCursor,i=typeof s=="function"?s(this.editorView,t,e):s;if(t&&!i){let o=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=Wc(this.editorView.state.doc,o,this.editorView.dragging.slice);l!=null&&(o=l)}this.setCursor(o),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}const ld=le.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[xb(this.options)]}});class ne extends B{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return ne.valid(r)?new ne(r):B.near(r)}content(){return A.empty}eq(e){return e instanceof ne&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new ne(e.resolve(t.pos))}getBookmark(){return new qo(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!Sb(e)||!wb(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let s=t.contentMatchAt(e.index()).defaultType;return s&&s.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&ne.valid(e))return e;let s=e.pos,i=null;for(let o=e.depth;;o--){let l=e.node(o);if(t>0?e.indexAfter(o)<l.childCount:e.index(o)>0){i=l.child(t>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;s+=t;let a=e.doc.resolve(s);if(ne.valid(a))return a}for(;;){let o=t>0?i.firstChild:i.lastChild;if(!o){if(i.isAtom&&!i.isText&&!I.isSelectable(i)){e=e.doc.resolve(s+i.nodeSize*t),r=!1;continue e}break}i=o,s+=t;let l=e.doc.resolve(s);if(ne.valid(l))return l}return null}}}ne.prototype.visible=!1;ne.findFrom=ne.findGapCursorFrom;B.jsonID("gapcursor",ne);class qo{constructor(e){this.pos=e}map(e){return new qo(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return ne.valid(t)?new ne(t):B.near(t)}}function Sb(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(t-1);;s=s.lastChild){if(s.childCount==0&&!s.inlineContent||s.isAtom||s.type.spec.isolating)return!0;if(s.inlineContent)return!1}}return!0}function wb(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(t);;s=s.firstChild){if(s.childCount==0&&!s.inlineContent||s.isAtom||s.type.spec.isolating)return!0;if(s.inlineContent)return!1}}return!0}function Cb(){return new se({props:{decorations:Tb,createSelectionBetween(n,e,t){return e.pos==t.pos&&ne.valid(t)?new ne(t):null},handleClick:Mb,handleKeyDown:vb,handleDOMEvents:{beforeinput:Eb}}})}const vb=Do({ArrowLeft:wr("horiz",-1),ArrowRight:wr("horiz",1),ArrowUp:wr("vert",-1),ArrowDown:wr("vert",1)});function wr(n,e){const t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,s,i){let o=r.selection,l=e>0?o.$to:o.$from,a=o.empty;if(o instanceof P){if(!i.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=ne.findGapCursorFrom(l,e,a);return c?(s&&s(r.tr.setSelection(new ne(c))),!0):!1}}function Mb(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!ne.valid(r))return!1;let s=n.posAtCoords({left:t.clientX,top:t.clientY});return s&&s.inside>-1&&I.isSelectable(n.state.doc.nodeAt(s.inside))?!1:(n.dispatch(n.state.tr.setSelection(new ne(r))),!0)}function Eb(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof ne))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let s=v.empty;for(let o=r.length-1;o>=0;o--)s=v.from(r[o].createAndFill(null,s));let i=n.state.tr.replace(t.pos,t.pos,new A(s,0,0));return i.setSelection(P.near(i.doc.resolve(t.pos+1))),n.dispatch(i),!1}function Tb(n){if(!(n.selection instanceof ne))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",ee.create(n.doc,[ye.widget(n.selection.head,e,{key:"gapcursor"})])}const ad=le.create({name:"gapCursor",addProseMirrorPlugins(){return[Cb()]},extendNodeSchema(n){var e;const t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=F(L(n,"allowGapCursor",t)))!==null&&e!==void 0?e:null}}}),cd=ie.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:n}){return["br",K(this.options.HTMLAttributes,n)]},renderText(){return`
|
|
125
|
+
`},addCommands(){return{setHardBreak:()=>({commands:n,chain:e,state:t,editor:r})=>n.first([()=>n.exitCode(),()=>n.command(()=>{const{selection:s,storedMarks:i}=t;if(s.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:l}=r.extensionManager,a=i||s.$to.parentOffset&&s.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:u})=>{if(u&&a&&o){const d=a.filter(f=>l.includes(f.type.name));c.ensureMarks(d)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),Ab=ie.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(n=>({tag:`h${n}`,attrs:{level:n}}))},renderHTML({node:n,HTMLAttributes:e}){return[`h${this.options.levels.includes(n.attrs.level)?n.attrs.level:this.options.levels[0]}`,K(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.setNode(this.name,n):!1,toggleHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.toggleNode(this.name,"paragraph",n):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((n,e)=>({...n,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(n=>Qi({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}});var Qr=200,de=function(){};de.prototype.append=function(e){return e.length?(e=de.from(e),!this.length&&e||e.length<Qr&&this.leafAppend(e)||this.length<Qr&&e.leafPrepend(this)||this.appendInner(e)):this};de.prototype.prepend=function(e){return e.length?de.from(e).append(this):this};de.prototype.appendInner=function(e){return new Nb(this,e)};de.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?de.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};de.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};de.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)};de.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var s=[];return this.forEach(function(i,o){return s.push(e(i,o))},t,r),s};de.from=function(e){return e instanceof de?e:e&&e.length?new ud(e):de.empty};var ud=function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(s,i){return s==0&&i==this.length?this:new e(this.values.slice(s,i))},e.prototype.getInner=function(s){return this.values[s]},e.prototype.forEachInner=function(s,i,o,l){for(var a=i;a<o;a++)if(s(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(s,i,o,l){for(var a=i-1;a>=o;a--)if(s(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=Qr)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=Qr)return new e(s.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e}(de);de.empty=new ud([]);var Nb=function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,s,i,o){var l=this.left.length;if(s<l&&this.left.forEachInner(r,s,Math.min(i,l),o)===!1||i>l&&this.right.forEachInner(r,Math.max(s-l,0),Math.min(this.length,i)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,s,i,o){var l=this.left.length;if(s>l&&this.right.forEachInvertedInner(r,s-l,Math.max(i,l)-l,o+l)===!1||i<l&&this.left.forEachInvertedInner(r,Math.min(s,l),i,o)===!1)return!1},e.prototype.sliceInner=function(r,s){if(r==0&&s==this.length)return this;var i=this.left.length;return s<=i?this.left.slice(r,s):r>=i?this.right.slice(r-i,s-i):this.left.slice(r,i).append(this.right.slice(0,s-i))},e.prototype.leafAppend=function(r){var s=this.right.leafAppend(r);if(s)return new e(this.left,s)},e.prototype.leafPrepend=function(r){var s=this.left.leafPrepend(r);if(s)return new e(s,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e}(de);const Ob=500;class Ue{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let s,i;t&&(s=this.remapping(r,this.items.length),i=s.maps.length);let o=e.tr,l,a,c=[],u=[];return this.items.forEach((d,f)=>{if(!d.step){s||(s=this.remapping(r,f+1),i=s.maps.length),i--,u.push(d);return}if(s){u.push(new Ye(d.map));let h=d.step.map(s.slice(i)),p;h&&o.maybeStep(h).doc&&(p=o.mapping.maps[o.mapping.maps.length-1],c.push(new Ye(p,void 0,void 0,c.length+u.length))),i--,p&&s.appendMap(p,i)}else o.maybeStep(d.step);if(d.selection)return l=s?d.selection.map(s.slice(i)):d.selection,a=new Ue(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:o,selection:l}}addTransform(e,t,r,s){let i=[],o=this.eventCount,l=this.items,a=!s&&l.length?l.get(l.length-1):null;for(let u=0;u<e.steps.length;u++){let d=e.steps[u].invert(e.docs[u]),f=new Ye(e.mapping.maps[u],d,t),h;(h=a&&a.merge(f))&&(f=h,u?i.pop():l=l.slice(0,l.length-1)),i.push(f),t&&(o++,t=void 0),s||(a=f)}let c=o-r.depth;return c>Lb&&(l=Rb(l,c),o-=c),new Ue(l.append(i),o)}remapping(e,t){let r=new Jn;return this.items.forEach((s,i)=>{let o=s.mirrorOffset!=null&&i-s.mirrorOffset>=e?r.maps.length-s.mirrorOffset:void 0;r.appendMap(s.map,o)},e,t),r}addMaps(e){return this.eventCount==0?this:new Ue(this.items.append(e.map(t=>new Ye(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],s=Math.max(0,this.items.length-t),i=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},s);let a=t;this.items.forEach(f=>{let h=i.getMirror(--a);if(h==null)return;o=Math.min(o,h);let p=i.maps[h];if(f.step){let g=e.steps[h].invert(e.docs[h]),y=f.selection&&f.selection.map(i.slice(a+1,h));y&&l++,r.push(new Ye(p,g,y))}else r.push(new Ye(p))},s);let c=[];for(let f=t;f<o;f++)c.push(new Ye(i.maps[f]));let u=this.items.slice(0,s).append(c).append(r),d=new Ue(u,l);return d.emptyItemCount()>Ob&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,s=[],i=0;return this.items.forEach((o,l)=>{if(l>=e)s.push(o),o.selection&&i++;else if(o.step){let a=o.step.map(t.slice(r)),c=a&&a.getMap();if(r--,c&&t.appendMap(c,r),a){let u=o.selection&&o.selection.map(t.slice(r));u&&i++;let d=new Ye(c.invert(),a,u),f,h=s.length-1;(f=s.length&&s[h].merge(d))?s[h]=f:s.push(d)}}else o.map&&r--},this.items.length,0),new Ue(de.from(s.reverse()),i)}}Ue.empty=new Ue(de.empty,0);function Rb(n,e){let t;return n.forEach((r,s)=>{if(r.selection&&e--==0)return t=s,!1}),n.slice(t)}class Ye{constructor(e,t,r,s){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=s}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new Ye(t.getMap().invert(),t,this.selection)}}}class yt{constructor(e,t,r,s,i){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=s,this.prevComposition=i}}const Lb=20;function Db(n,e,t,r){let s=t.getMeta(qt),i;if(s)return s.historyState;t.getMeta(jb)&&(n=new yt(n.done,n.undone,null,0,-1));let o=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(o&&o.getMeta(qt))return o.getMeta(qt).redo?new yt(n.done.addTransform(t,void 0,r,Pr(e)),n.undone,Pa(t.mapping.maps),n.prevTime,n.prevComposition):new yt(n.done,n.undone.addTransform(t,void 0,r,Pr(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!o&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-r.newGroupDelay||!Ib(t,n.prevRanges)),c=o?ki(n.prevRanges,t.mapping):Pa(t.mapping.maps);return new yt(n.done.addTransform(t,a?e.selection.getBookmark():void 0,r,Pr(e)),Ue.empty,c,t.time,l??n.prevComposition)}else return(i=t.getMeta("rebased"))?new yt(n.done.rebased(t,i),n.undone.rebased(t,i),ki(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new yt(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),ki(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function Ib(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,s)=>{for(let i=0;i<e.length;i+=2)r<=e[i+1]&&s>=e[i]&&(t=!0)}),t}function Pa(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,s,i,o)=>e.push(i,o));return e}function ki(n,e){if(!n)return null;let t=[];for(let r=0;r<n.length;r+=2){let s=e.map(n[r],1),i=e.map(n[r+1],-1);s<=i&&t.push(s,i)}return t}function Pb(n,e,t){let r=Pr(e),s=qt.get(e).spec.config,i=(t?n.undone:n.done).popEvent(e,r);if(!i)return null;let o=i.selection.resolve(i.transform.doc),l=(t?n.done:n.undone).addTransform(i.transform,e.selection.getBookmark(),s,r),a=new yt(t?l:i.remaining,t?i.remaining:l,null,0,-1);return i.transform.setSelection(o).setMeta(qt,{redo:t,historyState:a})}let Si=!1,ja=null;function Pr(n){let e=n.plugins;if(ja!=e){Si=!1,ja=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){Si=!0;break}}return Si}const qt=new ae("history"),jb=new ae("closeHistory");function Bb(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new se({key:qt,state:{init(){return new yt(Ue.empty,Ue.empty,null,0,-1)},apply(e,t,r){return Db(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,s=r=="historyUndo"?fd:r=="historyRedo"?hd:null;return s?(t.preventDefault(),s(e.state,e.dispatch)):!1}}}})}function dd(n,e){return(t,r)=>{let s=qt.getState(t);if(!s||(n?s.undone:s.done).eventCount==0)return!1;if(r){let i=Pb(s,t,n);i&&r(e?i.scrollIntoView():i)}return!0}}const fd=dd(!1,!0),hd=dd(!0,!0),zb=le.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>fd(n,e),redo:()=>({state:n,dispatch:e})=>hd(n,e)}},addProseMirrorPlugins(){return[Bb(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),pd=ie.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:n}){return["hr",K(this.options.HTMLAttributes,n)]},addCommands(){return{setHorizontalRule:()=>({chain:n,state:e})=>{if(!Ry(e,e.schema.nodes[this.name]))return!1;const{selection:t}=e,{$from:r,$to:s}=t,i=n();return r.parentOffset===0?i.insertContentAt({from:Math.max(r.pos-1,0),to:s.pos},{type:this.name}):Qg(t)?i.insertContentAt(s.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({tr:o,dispatch:l})=>{var a;if(l){const{$to:c}=o.selection,u=c.end();if(c.nodeAfter)c.nodeAfter.isTextblock?o.setSelection(P.create(o.doc,c.pos+1)):c.nodeAfter.isBlock?o.setSelection(I.create(o.doc,c.pos)):o.setSelection(P.create(o.doc,c.pos));else{const d=(a=c.parent.type.contentMatch.defaultType)===null||a===void 0?void 0:a.create();d&&(o.insert(u,d),o.setSelection(P.create(o.doc,u+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[rd({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),Hb=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,_b=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Fb=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,$b=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Vb=Se.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:n=>n.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:n=>n.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:n}){return["em",K(this.options.HTMLAttributes,n),0]},addCommands(){return{setItalic:()=>({commands:n})=>n.setMark(this.name),toggleItalic:()=>({commands:n})=>n.toggleMark(this.name),unsetItalic:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Zt({find:Hb,type:this.type}),Zt({find:Fb,type:this.type})]},addPasteRules(){return[Ot({find:_b,type:this.type}),Ot({find:$b,type:this.type})]}}),Wb=ie.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",K(this.options.HTMLAttributes,n),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),Ub="listItem",Ba="textStyle",za=/^(\d+)\.\s$/,Kb=ie.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:n=>n.hasAttribute("start")?parseInt(n.getAttribute("start")||"",10):1},type:{default:null,parseHTML:n=>n.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:n}){const{start:e,...t}=n;return e===1?["ol",K(this.options.HTMLAttributes,t),0]:["ol",K(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleOrderedList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Ub,this.editor.getAttributes(Ba)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let n=Cn({find:za,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(n=Cn({find:za,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Ba)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[n]}}),qb=ie.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",K(this.options.HTMLAttributes,n),0]},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Gb=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Jb=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,md=Se.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["s",K(this.options.HTMLAttributes,n),0]},addCommands(){return{setStrike:()=>({commands:n})=>n.setMark(this.name),toggleStrike:()=>({commands:n})=>n.toggleMark(this.name),unsetStrike:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Zt({find:Gb,type:this.type})]},addPasteRules(){return[Ot({find:Jb,type:this.type})]}}),Yb=ie.create({name:"text",group:"inline"}),Xb=le.create({name:"starterKit",addExtensions(){const n=[];return this.options.bold!==!1&&n.push(ub.configure(this.options.bold)),this.options.blockquote!==!1&&n.push(id.configure(this.options.blockquote)),this.options.bulletList!==!1&&n.push(fb.configure(this.options.bulletList)),this.options.code!==!1&&n.push(mb.configure(this.options.code)),this.options.codeBlock!==!1&&n.push(od.configure(this.options.codeBlock)),this.options.document!==!1&&n.push(bb.configure(this.options.document)),this.options.dropcursor!==!1&&n.push(ld.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&n.push(ad.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&n.push(cd.configure(this.options.hardBreak)),this.options.heading!==!1&&n.push(Ab.configure(this.options.heading)),this.options.history!==!1&&n.push(zb.configure(this.options.history)),this.options.horizontalRule!==!1&&n.push(pd.configure(this.options.horizontalRule)),this.options.italic!==!1&&n.push(Vb.configure(this.options.italic)),this.options.listItem!==!1&&n.push(Wb.configure(this.options.listItem)),this.options.orderedList!==!1&&n.push(Kb.configure(this.options.orderedList)),this.options.paragraph!==!1&&n.push(qb.configure(this.options.paragraph)),this.options.strike!==!1&&n.push(md.configure(this.options.strike)),this.options.text!==!1&&n.push(Yb.configure(this.options.text)),n}});var ro,so;if(typeof WeakMap<"u"){let n=new WeakMap;ro=e=>n.get(e),so=(e,t)=>(n.set(e,t),t)}else{const n=[];let t=0;ro=r=>{for(let s=0;s<n.length;s+=2)if(n[s]==r)return n[s+1]},so=(r,s)=>(t==10&&(t=0),n[t++]=r,n[t++]=s)}var re=class{constructor(n,e,t,r){this.width=n,this.height=e,this.map=t,this.problems=r}findCell(n){for(let e=0;e<this.map.length;e++){const t=this.map[e];if(t!=n)continue;const r=e%this.width,s=e/this.width|0;let i=r+1,o=s+1;for(let l=1;i<this.width&&this.map[e+l]==t;l++)i++;for(let l=1;o<this.height&&this.map[e+this.width*l]==t;l++)o++;return{left:r,top:s,right:i,bottom:o}}throw new RangeError(`No cell with offset ${n} found`)}colCount(n){for(let e=0;e<this.map.length;e++)if(this.map[e]==n)return e%this.width;throw new RangeError(`No cell with offset ${n} found`)}nextCell(n,e,t){const{left:r,right:s,top:i,bottom:o}=this.findCell(n);return e=="horiz"?(t<0?r==0:s==this.width)?null:this.map[i*this.width+(t<0?r-1:s)]:(t<0?i==0:o==this.height)?null:this.map[r+this.width*(t<0?i-1:o)]}rectBetween(n,e){const{left:t,right:r,top:s,bottom:i}=this.findCell(n),{left:o,right:l,top:a,bottom:c}=this.findCell(e);return{left:Math.min(t,o),top:Math.min(s,a),right:Math.max(r,l),bottom:Math.max(i,c)}}cellsInRect(n){const e=[],t={};for(let r=n.top;r<n.bottom;r++)for(let s=n.left;s<n.right;s++){const i=r*this.width+s,o=this.map[i];t[o]||(t[o]=!0,!(s==n.left&&s&&this.map[i-1]==o||r==n.top&&r&&this.map[i-this.width]==o)&&e.push(o))}return e}positionAt(n,e,t){for(let r=0,s=0;;r++){const i=s+t.child(r).nodeSize;if(r==n){let o=e+n*this.width;const l=(n+1)*this.width;for(;o<l&&this.map[o]<s;)o++;return o==l?i-1:this.map[o]}s=i}}static get(n){return ro(n)||so(n,Qb(n))}};function Qb(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);const e=Zb(n),t=n.childCount,r=[];let s=0,i=null;const o=[];for(let c=0,u=e*t;c<u;c++)r[c]=0;for(let c=0,u=0;c<t;c++){const d=n.child(c);u++;for(let p=0;;p++){for(;s<r.length&&r[s]!=0;)s++;if(p==d.childCount)break;const g=d.child(p),{colspan:y,rowspan:b,colwidth:x}=g.attrs;for(let C=0;C<b;C++){if(C+c>=t){(i||(i=[])).push({type:"overlong_rowspan",pos:u,n:b-C});break}const k=s+C*e;for(let M=0;M<y;M++){r[k+M]==0?r[k+M]=u:(i||(i=[])).push({type:"collision",row:c,pos:u,n:y-M});const R=x&&x[M];if(R){const z=(k+M)%e*2,w=o[z];w==null||w!=R&&o[z+1]==1?(o[z]=R,o[z+1]=1):w==R&&o[z+1]++}}}s+=y,u+=g.nodeSize}const f=(c+1)*e;let h=0;for(;s<f;)r[s++]==0&&h++;h&&(i||(i=[])).push({type:"missing",row:c,n:h}),u++}(e===0||t===0)&&(i||(i=[])).push({type:"zero_sized"});const l=new re(e,t,r,i);let a=!1;for(let c=0;!a&&c<o.length;c+=2)o[c]!=null&&o[c+1]<t&&(a=!0);return a&&e0(l,o,n),l}function Zb(n){let e=-1,t=!1;for(let r=0;r<n.childCount;r++){const s=n.child(r);let i=0;if(t)for(let o=0;o<r;o++){const l=n.child(o);for(let a=0;a<l.childCount;a++){const c=l.child(a);o+c.attrs.rowspan>r&&(i+=c.attrs.colspan)}}for(let o=0;o<s.childCount;o++){const l=s.child(o);i+=l.attrs.colspan,l.attrs.rowspan>1&&(t=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function e0(n,e,t){n.problems||(n.problems=[]);const r={};for(let s=0;s<n.map.length;s++){const i=n.map[s];if(r[i])continue;r[i]=!0;const o=t.nodeAt(i);if(!o)throw new RangeError(`No cell with offset ${i} found`);let l=null;const a=o.attrs;for(let c=0;c<a.colspan;c++){const u=(s+c)%n.width,d=e[u*2];d!=null&&(!a.colwidth||a.colwidth[c]!=d)&&((l||(l=t0(a)))[c]=d)}l&&n.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:l})}}function t0(n){if(n.colwidth)return n.colwidth.slice();const e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function we(n){let e=n.cached.tableNodeTypes;if(!e){e=n.cached.tableNodeTypes={};for(const t in n.nodes){const r=n.nodes[t],s=r.spec.tableRole;s&&(e[s]=r)}}return e}var kt=new ae("selectingCells");function En(n){for(let e=n.depth-1;e>0;e--)if(n.node(e).type.spec.tableRole=="row")return n.node(0).resolve(n.before(e+1));return null}function n0(n){for(let e=n.depth;e>0;e--){const t=n.node(e).type.spec.tableRole;if(t==="cell"||t==="header_cell")return n.node(e)}return null}function qe(n){const e=n.selection.$head;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return!0;return!1}function Us(n){const e=n.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const t=En(e.$head)||r0(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function r0(n){for(let e=n.nodeAfter,t=n.pos;e;e=e.firstChild,t++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t)}for(let e=n.nodeBefore,t=n.pos;e;e=e.lastChild,t--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t-e.nodeSize)}}function io(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function s0(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function Go(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function gd(n,e,t){const r=n.node(-1),s=re.get(r),i=n.start(-1),o=s.nextCell(n.pos-i,e,t);return o==null?null:n.node(0).resolve(i+o)}function en(n,e,t=1){const r={...n,colspan:n.colspan-t};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,t),r.colwidth.some(s=>s>0)||(r.colwidth=null)),r}function yd(n,e,t=1){const r={...n,colspan:n.colspan+t};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let s=0;s<t;s++)r.colwidth.splice(e,0,0)}return r}function i0(n,e,t){const r=we(e.type.schema).header_cell;for(let s=0;s<n.height;s++)if(e.nodeAt(n.map[t+s*n.width]).type!=r)return!1;return!0}var Y=class lt extends B{constructor(e,t=e){const r=e.node(-1),s=re.get(r),i=e.start(-1),o=s.rectBetween(e.pos-i,t.pos-i),l=e.node(0),a=s.cellsInRect(o).filter(u=>u!=t.pos-i);a.unshift(t.pos-i);const c=a.map(u=>{const d=r.nodeAt(u);if(!d)throw RangeError(`No cell with offset ${u} found`);const f=i+u+1;return new Jc(l.resolve(f),l.resolve(f+d.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){const r=e.resolve(t.map(this.$anchorCell.pos)),s=e.resolve(t.map(this.$headCell.pos));if(io(r)&&io(s)&&Go(r,s)){const i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?lt.rowSelection(r,s):i&&this.isColSelection()?lt.colSelection(r,s):new lt(r,s)}return P.between(r,s)}content(){const e=this.$anchorCell.node(-1),t=re.get(e),r=this.$anchorCell.start(-1),s=t.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),i={},o=[];for(let a=s.top;a<s.bottom;a++){const c=[];for(let u=a*t.width+s.left,d=s.left;d<s.right;d++,u++){const f=t.map[u];if(i[f])continue;i[f]=!0;const h=t.findCell(f);let p=e.nodeAt(f);if(!p)throw RangeError(`No cell with offset ${f} found`);const g=s.left-h.left,y=h.right-s.right;if(g>0||y>0){let b=p.attrs;if(g>0&&(b=en(b,0,g)),y>0&&(b=en(b,b.colspan-y,y)),h.left<s.left){if(p=p.type.createAndFill(b),!p)throw RangeError(`Could not create cell with attrs ${JSON.stringify(b)}`)}else p=p.type.create(b,p.content)}if(h.top<s.top||h.bottom>s.bottom){const b={...p.attrs,rowspan:Math.min(h.bottom,s.bottom)-Math.max(h.top,s.top)};h.top<s.top?p=p.type.createAndFill(b):p=p.type.create(b,p.content)}c.push(p)}o.push(e.child(a).copy(v.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:o;return new A(v.from(l),1,1)}replace(e,t=A.empty){const r=e.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){const{$from:l,$to:a}=s[o],c=e.mapping.slice(r);e.replace(c.map(l.pos),c.map(a.pos),o?A.empty:t)}const i=B.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,t){this.replace(e,new A(v.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),r=re.get(t),s=this.$anchorCell.start(-1),i=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-s,this.$headCell.pos-s));for(let o=0;o<i.length;o++)e(t.nodeAt(i[o]),s+i[o])}isColSelection(){const e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,s=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,s)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){const r=e.node(-1),s=re.get(r),i=e.start(-1),o=s.findCell(e.pos-i),l=s.findCell(t.pos-i),a=e.node(0);return o.top<=l.top?(o.top>0&&(e=a.resolve(i+s.map[o.left])),l.bottom<s.height&&(t=a.resolve(i+s.map[s.width*(s.height-1)+l.right-1]))):(l.top>0&&(t=a.resolve(i+s.map[l.left])),o.bottom<s.height&&(e=a.resolve(i+s.map[s.width*(s.height-1)+o.right-1]))),new lt(e,t)}isRowSelection(){const e=this.$anchorCell.node(-1),t=re.get(e),r=this.$anchorCell.start(-1),s=t.colCount(this.$anchorCell.pos-r),i=t.colCount(this.$headCell.pos-r);if(Math.min(s,i)>0)return!1;const o=s+this.$anchorCell.nodeAfter.attrs.colspan,l=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(o,l)==t.width}eq(e){return e instanceof lt&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){const r=e.node(-1),s=re.get(r),i=e.start(-1),o=s.findCell(e.pos-i),l=s.findCell(t.pos-i),a=e.node(0);return o.left<=l.left?(o.left>0&&(e=a.resolve(i+s.map[o.top*s.width])),l.right<s.width&&(t=a.resolve(i+s.map[s.width*(l.top+1)-1]))):(l.left>0&&(t=a.resolve(i+s.map[l.top*s.width])),o.right<s.width&&(e=a.resolve(i+s.map[s.width*(o.top+1)-1]))),new lt(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new lt(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){return new lt(e.resolve(t),e.resolve(r))}getBookmark(){return new o0(this.$anchorCell.pos,this.$headCell.pos)}};Y.prototype.visible=!1;B.jsonID("cell",Y);var o0=class bd{constructor(e,t){this.anchor=e,this.head=t}map(e){return new bd(e.map(this.anchor),e.map(this.head))}resolve(e){const t=e.resolve(this.anchor),r=e.resolve(this.head);return t.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&t.index()<t.parent.childCount&&r.index()<r.parent.childCount&&Go(t,r)?new Y(t,r):B.near(r,1)}};function l0(n){if(!(n.selection instanceof Y))return null;const e=[];return n.selection.forEachCell((t,r)=>{e.push(ye.node(r,r+t.nodeSize,{class:"selectedCell"}))}),ee.create(n.doc,e)}function a0({$from:n,$to:e}){if(n.pos==e.pos||n.pos<e.pos-6)return!1;let t=n.pos,r=e.pos,s=n.depth;for(;s>=0&&!(n.after(s+1)<n.end(s));s--,t++);for(let i=e.depth;i>=0&&!(e.before(i+1)>e.start(i));i--,r--);return t==r&&/row|table/.test(n.node(s).type.spec.tableRole)}function c0({$from:n,$to:e}){let t,r;for(let s=n.depth;s>0;s--){const i=n.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){t=i;break}}for(let s=e.depth;s>0;s--){const i=e.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){r=i;break}}return t!==r&&e.parentOffset===0}function u0(n,e,t){const r=(e||n).selection,s=(e||n).doc;let i,o;if(r instanceof I&&(o=r.node.type.spec.tableRole)){if(o=="cell"||o=="header_cell")i=Y.create(s,r.from);else if(o=="row"){const l=s.resolve(r.from+1);i=Y.rowSelection(l,l)}else if(!t){const l=re.get(r.node),a=r.from+1,c=a+l.map[l.width*l.height-1];i=Y.create(s,a+1,c)}}else r instanceof P&&a0(r)?i=P.create(s,r.from):r instanceof P&&c0(r)&&(i=P.create(s,r.$from.start(),r.$from.end()));return i&&(e||(e=n.tr)).setSelection(i),e}var d0=new ae("fix-tables");function xd(n,e,t,r){const s=n.childCount,i=e.childCount;e:for(let o=0,l=0;o<i;o++){const a=e.child(o);for(let c=l,u=Math.min(s,o+3);c<u;c++)if(n.child(c)==a){l=c+1,t+=a.nodeSize;continue e}r(a,t),l<s&&n.child(l).sameMarkup(a)?xd(n.child(l),a,t+1,r):a.nodesBetween(0,a.content.size,r,t+1),t+=a.nodeSize}}function kd(n,e){let t;const r=(s,i)=>{s.type.spec.tableRole=="table"&&(t=f0(n,s,i,t))};return e?e.doc!=n.doc&&xd(e.doc,n.doc,0,r):n.doc.descendants(r),t}function f0(n,e,t,r){const s=re.get(e);if(!s.problems)return r;r||(r=n.tr);const i=[];for(let a=0;a<s.height;a++)i.push(0);for(let a=0;a<s.problems.length;a++){const c=s.problems[a];if(c.type=="collision"){const u=e.nodeAt(c.pos);if(!u)continue;const d=u.attrs;for(let f=0;f<d.rowspan;f++)i[c.row+f]+=c.n;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,en(d,d.colspan-c.n,c.n))}else if(c.type=="missing")i[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const u=e.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,{...u.attrs,rowspan:u.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const u=e.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,{...u.attrs,colwidth:c.colwidth})}else if(c.type=="zero_sized"){const u=r.mapping.map(t);r.delete(u,u+e.nodeSize)}}let o,l;for(let a=0;a<i.length;a++)i[a]&&(o==null&&(o=a),l=a);for(let a=0,c=t+1;a<s.height;a++){const u=e.child(a),d=c+u.nodeSize,f=i[a];if(f>0){let h="cell";u.firstChild&&(h=u.firstChild.type.spec.tableRole);const p=[];for(let y=0;y<f;y++){const b=we(n.schema)[h].createAndFill();b&&p.push(b)}const g=(a==0||o==a-1)&&l==a?c+1:d-1;r.insert(r.mapping.map(g),p)}c=d}return r.setMeta(d0,{fixTables:!0})}function nt(n){const e=n.selection,t=Us(n),r=t.node(-1),s=t.start(-1),i=re.get(r);return{...e instanceof Y?i.rectBetween(e.$anchorCell.pos-s,e.$headCell.pos-s):i.findCell(t.pos-s),tableStart:s,map:i,table:r}}function Sd(n,{map:e,tableStart:t,table:r},s){let i=s>0?-1:0;i0(e,r,s+i)&&(i=s==0||s==e.width?null:0);for(let o=0;o<e.height;o++){const l=o*e.width+s;if(s>0&&s<e.width&&e.map[l-1]==e.map[l]){const a=e.map[l],c=r.nodeAt(a);n.setNodeMarkup(n.mapping.map(t+a),null,yd(c.attrs,s-e.colCount(a))),o+=c.attrs.rowspan-1}else{const a=i==null?we(r.type.schema).cell:r.nodeAt(e.map[l+i]).type,c=e.positionAt(o,s,r);n.insert(n.mapping.map(t+c),a.createAndFill())}}return n}function h0(n,e){if(!qe(n))return!1;if(e){const t=nt(n);e(Sd(n.tr,t,t.left))}return!0}function p0(n,e){if(!qe(n))return!1;if(e){const t=nt(n);e(Sd(n.tr,t,t.right))}return!0}function m0(n,{map:e,table:t,tableStart:r},s){const i=n.mapping.maps.length;for(let o=0;o<e.height;){const l=o*e.width+s,a=e.map[l],c=t.nodeAt(a),u=c.attrs;if(s>0&&e.map[l-1]==a||s<e.width-1&&e.map[l+1]==a)n.setNodeMarkup(n.mapping.slice(i).map(r+a),null,en(u,s-e.colCount(a)));else{const d=n.mapping.slice(i).map(r+a);n.delete(d,d+c.nodeSize)}o+=u.rowspan}}function g0(n,e){if(!qe(n))return!1;if(e){const t=nt(n),r=n.tr;if(t.left==0&&t.right==t.map.width)return!1;for(let s=t.right-1;m0(r,t,s),s!=t.left;s--){const i=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc;if(!i)throw RangeError("No table found");t.table=i,t.map=re.get(i)}e(r)}return!0}function y0(n,e,t){var r;const s=we(e.type.schema).header_cell;for(let i=0;i<n.width;i++)if(((r=e.nodeAt(n.map[i+t*n.width]))==null?void 0:r.type)!=s)return!1;return!0}function wd(n,{map:e,tableStart:t,table:r},s){var i;let o=t;for(let c=0;c<s;c++)o+=r.child(c).nodeSize;const l=[];let a=s>0?-1:0;y0(e,r,s+a)&&(a=s==0||s==e.height?null:0);for(let c=0,u=e.width*s;c<e.width;c++,u++)if(s>0&&s<e.height&&e.map[u]==e.map[u-e.width]){const d=e.map[u],f=r.nodeAt(d).attrs;n.setNodeMarkup(t+d,null,{...f,rowspan:f.rowspan+1}),c+=f.colspan-1}else{const d=a==null?we(r.type.schema).cell:(i=r.nodeAt(e.map[u+a*e.width]))==null?void 0:i.type,f=d?.createAndFill();f&&l.push(f)}return n.insert(o,we(r.type.schema).row.create(null,l)),n}function b0(n,e){if(!qe(n))return!1;if(e){const t=nt(n);e(wd(n.tr,t,t.top))}return!0}function x0(n,e){if(!qe(n))return!1;if(e){const t=nt(n);e(wd(n.tr,t,t.bottom))}return!0}function k0(n,{map:e,table:t,tableStart:r},s){let i=0;for(let c=0;c<s;c++)i+=t.child(c).nodeSize;const o=i+t.child(s).nodeSize,l=n.mapping.maps.length;n.delete(i+r,o+r);const a=new Set;for(let c=0,u=s*e.width;c<e.width;c++,u++){const d=e.map[u];if(!a.has(d)){if(a.add(d),s>0&&d==e.map[u-e.width]){const f=t.nodeAt(d).attrs;n.setNodeMarkup(n.mapping.slice(l).map(d+r),null,{...f,rowspan:f.rowspan-1}),c+=f.colspan-1}else if(s<e.height&&d==e.map[u+e.width]){const f=t.nodeAt(d),h=f.attrs,p=f.type.create({...h,rowspan:f.attrs.rowspan-1},f.content),g=e.positionAt(s+1,c,t);n.insert(n.mapping.slice(l).map(r+g),p),c+=h.colspan-1}}}}function S0(n,e){if(!qe(n))return!1;if(e){const t=nt(n),r=n.tr;if(t.top==0&&t.bottom==t.map.height)return!1;for(let s=t.bottom-1;k0(r,t,s),s!=t.top;s--){const i=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc;if(!i)throw RangeError("No table found");t.table=i,t.map=re.get(t.table)}e(r)}return!0}function Ha(n){const e=n.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function w0({width:n,height:e,map:t},r){let s=r.top*n+r.left,i=s,o=(r.bottom-1)*n+r.left,l=s+(r.right-r.left-1);for(let a=r.top;a<r.bottom;a++){if(r.left>0&&t[i]==t[i-1]||r.right<n&&t[l]==t[l+1])return!0;i+=n,l+=n}for(let a=r.left;a<r.right;a++){if(r.top>0&&t[s]==t[s-n]||r.bottom<e&&t[o]==t[o+n])return!0;s++,o++}return!1}function _a(n,e){const t=n.selection;if(!(t instanceof Y)||t.$anchorCell.pos==t.$headCell.pos)return!1;const r=nt(n),{map:s}=r;if(w0(s,r))return!1;if(e){const i=n.tr,o={};let l=v.empty,a,c;for(let u=r.top;u<r.bottom;u++)for(let d=r.left;d<r.right;d++){const f=s.map[u*s.width+d],h=r.table.nodeAt(f);if(!(o[f]||!h))if(o[f]=!0,a==null)a=f,c=h;else{Ha(h)||(l=l.append(h.content));const p=i.mapping.map(f+r.tableStart);i.delete(p,p+h.nodeSize)}}if(a==null||c==null)return!0;if(i.setNodeMarkup(a+r.tableStart,null,{...yd(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),rowspan:r.bottom-r.top}),l.size){const u=a+1+c.content.size,d=Ha(c)?a+1:u;i.replaceWith(d+r.tableStart,u+r.tableStart,l)}i.setSelection(new Y(i.doc.resolve(a+r.tableStart))),e(i)}return!0}function Fa(n,e){const t=we(n.schema);return C0(({node:r})=>t[r.type.spec.tableRole])(n,e)}function C0(n){return(e,t)=>{var r;const s=e.selection;let i,o;if(s instanceof Y){if(s.$anchorCell.pos!=s.$headCell.pos)return!1;i=s.$anchorCell.nodeAfter,o=s.$anchorCell.pos}else{if(i=n0(s.$from),!i)return!1;o=(r=En(s.$from))==null?void 0:r.pos}if(i==null||o==null||i.attrs.colspan==1&&i.attrs.rowspan==1)return!1;if(t){let l=i.attrs;const a=[],c=l.colwidth;l.rowspan>1&&(l={...l,rowspan:1}),l.colspan>1&&(l={...l,colspan:1});const u=nt(e),d=e.tr;for(let h=0;h<u.right-u.left;h++)a.push(c?{...l,colwidth:c&&c[h]?[c[h]]:null}:l);let f;for(let h=u.top;h<u.bottom;h++){let p=u.map.positionAt(h,u.left,u.table);h==u.top&&(p+=i.nodeSize);for(let g=u.left,y=0;g<u.right;g++,y++)g==u.left&&h==u.top||d.insert(f=d.mapping.map(p+u.tableStart,1),n({node:i,row:h,col:g}).createAndFill(a[y]))}d.setNodeMarkup(o,n({node:i,row:u.top,col:u.left}),a[0]),s instanceof Y&&d.setSelection(new Y(d.doc.resolve(s.$anchorCell.pos),f?d.doc.resolve(f):void 0)),t(d)}return!0}}function v0(n,e){return function(t,r){if(!qe(t))return!1;const s=Us(t);if(s.nodeAfter.attrs[n]===e)return!1;if(r){const i=t.tr;t.selection instanceof Y?t.selection.forEachCell((o,l)=>{o.attrs[n]!==e&&i.setNodeMarkup(l,null,{...o.attrs,[n]:e})}):i.setNodeMarkup(s.pos,null,{...s.nodeAfter.attrs,[n]:e}),r(i)}return!0}}function M0(n){return function(e,t){if(!qe(e))return!1;if(t){const r=we(e.schema),s=nt(e),i=e.tr,o=s.map.cellsInRect(n=="column"?{left:s.left,top:0,right:s.right,bottom:s.map.height}:n=="row"?{left:0,top:s.top,right:s.map.width,bottom:s.bottom}:s),l=o.map(a=>s.table.nodeAt(a));for(let a=0;a<o.length;a++)l[a].type==r.header_cell&&i.setNodeMarkup(s.tableStart+o[a],r.cell,l[a].attrs);if(i.steps.length==0)for(let a=0;a<o.length;a++)i.setNodeMarkup(s.tableStart+o[a],r.header_cell,l[a].attrs);t(i)}return!0}}function $a(n,e,t){const r=e.map.cellsInRect({left:0,top:0,right:n=="row"?e.map.width:1,bottom:n=="column"?e.map.height:1});for(let s=0;s<r.length;s++){const i=e.table.nodeAt(r[s]);if(i&&i.type!==t.header_cell)return!1}return!0}function rr(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?M0(n):function(t,r){if(!qe(t))return!1;if(r){const s=we(t.schema),i=nt(t),o=t.tr,l=$a("row",i,s),a=$a("column",i,s),u=(n==="column"?l:n==="row"?a:!1)?1:0,d=n=="column"?{left:0,top:u,right:1,bottom:i.map.height}:n=="row"?{left:u,top:0,right:i.map.width,bottom:1}:i,f=n=="column"?a?s.cell:s.header_cell:n=="row"?l?s.cell:s.header_cell:s.cell;i.map.cellsInRect(d).forEach(h=>{const p=h+i.tableStart,g=o.doc.nodeAt(p);g&&o.setNodeMarkup(p,f,g.attrs)}),r(o)}return!0}}rr("row",{useDeprecatedLogic:!0});rr("column",{useDeprecatedLogic:!0});var E0=rr("cell",{useDeprecatedLogic:!0});function T0(n,e){if(e<0){const t=n.nodeBefore;if(t)return n.pos-t.nodeSize;for(let r=n.index(-1)-1,s=n.before();r>=0;r--){const i=n.node(-1).child(r),o=i.lastChild;if(o)return s-1-o.nodeSize;s-=i.nodeSize}}else{if(n.index()<n.parent.childCount-1)return n.pos+n.nodeAfter.nodeSize;const t=n.node(-1);for(let r=n.indexAfter(-1),s=n.after();r<t.childCount;r++){const i=t.child(r);if(i.childCount)return s+1;s+=i.nodeSize}}return null}function Va(n){return function(e,t){if(!qe(e))return!1;const r=T0(Us(e),n);if(r==null)return!1;if(t){const s=e.doc.resolve(r);t(e.tr.setSelection(P.between(s,s0(s))).scrollIntoView())}return!0}}function A0(n,e){const t=n.selection.$anchor;for(let r=t.depth;r>0;r--)if(t.node(r).type.spec.tableRole=="table")return e&&e(n.tr.delete(t.before(r),t.after(r)).scrollIntoView()),!0;return!1}function Cr(n,e){const t=n.selection;if(!(t instanceof Y))return!1;if(e){const r=n.tr,s=we(n.schema).cell.createAndFill().content;t.forEachCell((i,o)=>{i.content.eq(s)||r.replace(r.mapping.map(o+1),r.mapping.map(o+i.nodeSize-1),new A(s,0,0))}),r.docChanged&&e(r)}return!0}function N0(n){if(!n.size)return null;let{content:e,openStart:t,openEnd:r}=n;for(;e.childCount==1&&(t>0&&r>0||e.child(0).type.spec.tableRole=="table");)t--,r--,e=e.child(0).content;const s=e.child(0),i=s.type.spec.tableRole,o=s.type.schema,l=[];if(i=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content;const u=a?0:Math.max(0,t-1),d=a<e.childCount-1?0:Math.max(0,r-1);(u||d)&&(c=oo(we(o).row,new A(c,u,d)).content),l.push(c)}else if(i=="cell"||i=="header_cell")l.push(t||r?oo(we(o).row,new A(e,t,r)).content:e);else return null;return O0(o,l)}function O0(n,e){const t=[];for(let s=0;s<e.length;s++){const i=e[s];for(let o=i.childCount-1;o>=0;o--){const{rowspan:l,colspan:a}=i.child(o).attrs;for(let c=s;c<s+l;c++)t[c]=(t[c]||0)+a}}let r=0;for(let s=0;s<t.length;s++)r=Math.max(r,t[s]);for(let s=0;s<t.length;s++)if(s>=e.length&&e.push(v.empty),t[s]<r){const i=we(n).cell.createAndFill(),o=[];for(let l=t[s];l<r;l++)o.push(i);e[s]=e[s].append(v.from(o))}return{height:e.length,width:r,rows:e}}function oo(n,e){const t=n.createAndFill();return new wo(t).replace(0,t.content.size,e).doc}function R0({width:n,height:e,rows:t},r,s){if(n!=r){const i=[],o=[];for(let l=0;l<t.length;l++){const a=t[l],c=[];for(let u=i[l]||0,d=0;u<r;d++){let f=a.child(d%a.childCount);u+f.attrs.colspan>r&&(f=f.type.createChecked(en(f.attrs,f.attrs.colspan,u+f.attrs.colspan-r),f.content)),c.push(f),u+=f.attrs.colspan;for(let h=1;h<f.attrs.rowspan;h++)i[l+h]=(i[l+h]||0)+f.attrs.colspan}o.push(v.from(c))}t=o,n=r}if(e!=s){const i=[];for(let o=0,l=0;o<s;o++,l++){const a=[],c=t[l%e];for(let u=0;u<c.childCount;u++){let d=c.child(u);o+d.attrs.rowspan>s&&(d=d.type.create({...d.attrs,rowspan:Math.max(1,s-d.attrs.rowspan)},d.content)),a.push(d)}i.push(v.from(a))}t=i,e=s}return{width:n,height:e,rows:t}}function L0(n,e,t,r,s,i,o){const l=n.doc.type.schema,a=we(l);let c,u;if(s>e.width)for(let d=0,f=0;d<e.height;d++){const h=t.child(d);f+=h.nodeSize;const p=[];let g;h.lastChild==null||h.lastChild.type==a.cell?g=c||(c=a.cell.createAndFill()):g=u||(u=a.header_cell.createAndFill());for(let y=e.width;y<s;y++)p.push(g);n.insert(n.mapping.slice(o).map(f-1+r),p)}if(i>e.height){const d=[];for(let p=0,g=(e.height-1)*e.width;p<Math.max(e.width,s);p++){const y=p>=e.width?!1:t.nodeAt(e.map[g+p]).type==a.header_cell;d.push(y?u||(u=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const f=a.row.create(null,v.from(d)),h=[];for(let p=e.height;p<i;p++)h.push(f);n.insert(n.mapping.slice(o).map(r+t.nodeSize-2),h)}return!!(c||u)}function Wa(n,e,t,r,s,i,o,l){if(o==0||o==e.height)return!1;let a=!1;for(let c=s;c<i;c++){const u=o*e.width+c,d=e.map[u];if(e.map[u-e.width]==d){a=!0;const f=t.nodeAt(d),{top:h,left:p}=e.findCell(d);n.setNodeMarkup(n.mapping.slice(l).map(d+r),null,{...f.attrs,rowspan:o-h}),n.insert(n.mapping.slice(l).map(e.positionAt(o,p,t)),f.type.createAndFill({...f.attrs,rowspan:h+f.attrs.rowspan-o})),c+=f.attrs.colspan-1}}return a}function Ua(n,e,t,r,s,i,o,l){if(o==0||o==e.width)return!1;let a=!1;for(let c=s;c<i;c++){const u=c*e.width+o,d=e.map[u];if(e.map[u-1]==d){a=!0;const f=t.nodeAt(d),h=e.colCount(d),p=n.mapping.slice(l).map(d+r);n.setNodeMarkup(p,null,en(f.attrs,o-h,f.attrs.colspan-(o-h))),n.insert(p+f.nodeSize,f.type.createAndFill(en(f.attrs,0,o-h))),c+=f.attrs.rowspan-1}}return a}function Ka(n,e,t,r,s){let i=t?n.doc.nodeAt(t-1):n.doc;if(!i)throw new Error("No table found");let o=re.get(i);const{top:l,left:a}=r,c=a+s.width,u=l+s.height,d=n.tr;let f=0;function h(){if(i=t?d.doc.nodeAt(t-1):d.doc,!i)throw new Error("No table found");o=re.get(i),f=d.mapping.maps.length}L0(d,o,i,t,c,u,f)&&h(),Wa(d,o,i,t,a,c,l,f)&&h(),Wa(d,o,i,t,a,c,u,f)&&h(),Ua(d,o,i,t,l,u,a,f)&&h(),Ua(d,o,i,t,l,u,c,f)&&h();for(let p=l;p<u;p++){const g=o.positionAt(p,a,i),y=o.positionAt(p,c,i);d.replace(d.mapping.slice(f).map(g+t),d.mapping.slice(f).map(y+t),new A(s.rows[p-l],0,0))}h(),d.setSelection(new Y(d.doc.resolve(t+o.positionAt(l,a,i)),d.doc.resolve(t+o.positionAt(u-1,c-1,i)))),e(d)}var D0=Do({ArrowLeft:vr("horiz",-1),ArrowRight:vr("horiz",1),ArrowUp:vr("vert",-1),ArrowDown:vr("vert",1),"Shift-ArrowLeft":Mr("horiz",-1),"Shift-ArrowRight":Mr("horiz",1),"Shift-ArrowUp":Mr("vert",-1),"Shift-ArrowDown":Mr("vert",1),Backspace:Cr,"Mod-Backspace":Cr,Delete:Cr,"Mod-Delete":Cr});function jr(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function vr(n,e){return(t,r,s)=>{if(!s)return!1;const i=t.selection;if(i instanceof Y)return jr(t,r,B.near(i.$headCell,e));if(n!="horiz"&&!i.empty)return!1;const o=Cd(s,n,e);if(o==null)return!1;if(n=="horiz")return jr(t,r,B.near(t.doc.resolve(i.head+e),e));{const l=t.doc.resolve(o),a=gd(l,n,e);let c;return a?c=B.near(a,1):e<0?c=B.near(t.doc.resolve(l.before(-1)),-1):c=B.near(t.doc.resolve(l.after(-1)),1),jr(t,r,c)}}}function Mr(n,e){return(t,r,s)=>{if(!s)return!1;const i=t.selection;let o;if(i instanceof Y)o=i;else{const a=Cd(s,n,e);if(a==null)return!1;o=new Y(t.doc.resolve(a))}const l=gd(o.$headCell,n,e);return l?jr(t,r,new Y(o.$anchorCell,l)):!1}}function I0(n,e){const t=n.state.doc,r=En(t.resolve(e));return r?(n.dispatch(n.state.tr.setSelection(new Y(r))),!0):!1}function P0(n,e,t){if(!qe(n.state))return!1;let r=N0(t);const s=n.state.selection;if(s instanceof Y){r||(r={width:1,height:1,rows:[v.from(oo(we(n.state.schema).cell,t))]});const i=s.$anchorCell.node(-1),o=s.$anchorCell.start(-1),l=re.get(i).rectBetween(s.$anchorCell.pos-o,s.$headCell.pos-o);return r=R0(r,l.right-l.left,l.bottom-l.top),Ka(n.state,n.dispatch,o,l,r),!0}else if(r){const i=Us(n.state),o=i.start(-1);return Ka(n.state,n.dispatch,o,re.get(i.node(-1)).findCell(i.pos-o),r),!0}else return!1}function j0(n,e){var t;if(e.ctrlKey||e.metaKey)return;const r=qa(n,e.target);let s;if(e.shiftKey&&n.state.selection instanceof Y)i(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(s=En(n.state.selection.$anchor))!=null&&((t=wi(n,e))==null?void 0:t.pos)!=s.pos)i(s,e),e.preventDefault();else if(!r)return;function i(a,c){let u=wi(n,c);const d=kt.getState(n.state)==null;if(!u||!Go(a,u))if(d)u=a;else return;const f=new Y(a,u);if(d||!n.state.selection.eq(f)){const h=n.state.tr.setSelection(f);d&&h.setMeta(kt,a.pos),n.dispatch(h)}}function o(){n.root.removeEventListener("mouseup",o),n.root.removeEventListener("dragstart",o),n.root.removeEventListener("mousemove",l),kt.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(kt,-1))}function l(a){const c=a,u=kt.getState(n.state);let d;if(u!=null)d=n.state.doc.resolve(u);else if(qa(n,c.target)!=r&&(d=wi(n,e),!d))return o();d&&i(d,c)}n.root.addEventListener("mouseup",o),n.root.addEventListener("dragstart",o),n.root.addEventListener("mousemove",l)}function Cd(n,e,t){if(!(n.state.selection instanceof P))return null;const{$head:r}=n.state.selection;for(let s=r.depth-1;s>=0;s--){const i=r.node(s);if((t<0?r.index(s):r.indexAfter(s))!=(t<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){const l=r.before(s),a=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(a)?l:null}}return null}function qa(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function wi(n,e){const t=n.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?En(n.state.doc.resolve(t.pos)):null}var B0=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")),lo(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,lo(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function lo(n,e,t,r,s,i){var o;let l=0,a=!0,c=e.firstChild;const u=n.firstChild;if(u){for(let d=0,f=0;d<u.childCount;d++){const{colspan:h,colwidth:p}=u.child(d).attrs;for(let g=0;g<h;g++,f++){const y=s==f?i:p&&p[g],b=y?y+"px":"";if(l+=y||r,y||(a=!1),c)c.style.width!=b&&(c.style.width=b),c=c.nextSibling;else{const x=document.createElement("col");x.style.width=b,e.appendChild(x)}}}for(;c;){const d=c.nextSibling;(o=c.parentNode)==null||o.removeChild(c),c=d}a?(t.style.width=l+"px",t.style.minWidth=""):(t.style.width="",t.style.minWidth=l+"px")}}var Pe=new ae("tableColumnResizing");function z0({handleWidth:n=5,cellMinWidth:e=25,defaultCellMinWidth:t=100,View:r=B0,lastColumnResizable:s=!0}={}){const i=new se({key:Pe,state:{init(o,l){var a,c;const u=(c=(a=i.spec)==null?void 0:a.props)==null?void 0:c.nodeViews,d=we(l.schema).table.name;return r&&u&&(u[d]=(f,h)=>new r(f,t,h)),new H0(-1,!1)},apply(o,l){return l.apply(o)}},props:{attributes:o=>{const l=Pe.getState(o);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(o,l)=>{_0(o,l,n,s)},mouseleave:o=>{F0(o)},mousedown:(o,l)=>{$0(o,l,e,t)}},decorations:o=>{const l=Pe.getState(o);if(l&&l.activeHandle>-1)return q0(o,l.activeHandle)},nodeViews:{}}});return i}var H0=class Br{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){const t=this,r=e.getMeta(Pe);if(r&&r.setHandle!=null)return new Br(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new Br(t.activeHandle,r.setDragging);if(t.activeHandle>-1&&e.docChanged){let s=e.mapping.map(t.activeHandle,-1);return io(e.doc.resolve(s))||(s=-1),new Br(s,t.dragging)}return t}};function _0(n,e,t,r){if(!n.editable)return;const s=Pe.getState(n.state);if(s&&!s.dragging){const i=W0(e.target);let o=-1;if(i){const{left:l,right:a}=i.getBoundingClientRect();e.clientX-l<=t?o=Ga(n,e,"left",t):a-e.clientX<=t&&(o=Ga(n,e,"right",t))}if(o!=s.activeHandle){if(!r&&o!==-1){const l=n.state.doc.resolve(o),a=l.node(-1),c=re.get(a),u=l.start(-1);if(c.colCount(l.pos-u)+l.nodeAfter.attrs.colspan-1==c.width-1)return}vd(n,o)}}}function F0(n){if(!n.editable)return;const e=Pe.getState(n.state);e&&e.activeHandle>-1&&!e.dragging&&vd(n,-1)}function $0(n,e,t,r){var s;if(!n.editable)return!1;const i=(s=n.dom.ownerDocument.defaultView)!=null?s:window,o=Pe.getState(n.state);if(!o||o.activeHandle==-1||o.dragging)return!1;const l=n.state.doc.nodeAt(o.activeHandle),a=V0(n,o.activeHandle,l.attrs);n.dispatch(n.state.tr.setMeta(Pe,{setDragging:{startX:e.clientX,startWidth:a}}));function c(d){i.removeEventListener("mouseup",c),i.removeEventListener("mousemove",u);const f=Pe.getState(n.state);f?.dragging&&(U0(n,f.activeHandle,Ja(f.dragging,d,t)),n.dispatch(n.state.tr.setMeta(Pe,{setDragging:null})))}function u(d){if(!d.which)return c(d);const f=Pe.getState(n.state);if(f&&f.dragging){const h=Ja(f.dragging,d,t);Ya(n,f.activeHandle,h,r)}}return Ya(n,o.activeHandle,a,r),i.addEventListener("mouseup",c),i.addEventListener("mousemove",u),e.preventDefault(),!0}function V0(n,e,{colspan:t,colwidth:r}){const s=r&&r[r.length-1];if(s)return s;const i=n.domAtPos(e);let l=i.node.childNodes[i.offset].offsetWidth,a=t;if(r)for(let c=0;c<t;c++)r[c]&&(l-=r[c],a--);return l/a}function W0(n){for(;n&&n.nodeName!="TD"&&n.nodeName!="TH";)n=n.classList&&n.classList.contains("ProseMirror")?null:n.parentNode;return n}function Ga(n,e,t,r){const s=t=="right"?-r:r,i=n.posAtCoords({left:e.clientX+s,top:e.clientY});if(!i)return-1;const{pos:o}=i,l=En(n.state.doc.resolve(o));if(!l)return-1;if(t=="right")return l.pos;const a=re.get(l.node(-1)),c=l.start(-1),u=a.map.indexOf(l.pos-c);return u%a.width==0?-1:c+a.map[u-1]}function Ja(n,e,t){const r=e.clientX-n.startX;return Math.max(t,n.startWidth+r)}function vd(n,e){n.dispatch(n.state.tr.setMeta(Pe,{setHandle:e}))}function U0(n,e,t){const r=n.state.doc.resolve(e),s=r.node(-1),i=re.get(s),o=r.start(-1),l=i.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1,a=n.state.tr;for(let c=0;c<i.height;c++){const u=c*i.width+l;if(c&&i.map[u]==i.map[u-i.width])continue;const d=i.map[u],f=s.nodeAt(d).attrs,h=f.colspan==1?0:l-i.colCount(d);if(f.colwidth&&f.colwidth[h]==t)continue;const p=f.colwidth?f.colwidth.slice():K0(f.colspan);p[h]=t,a.setNodeMarkup(o+d,null,{...f,colwidth:p})}a.docChanged&&n.dispatch(a)}function Ya(n,e,t,r){const s=n.state.doc.resolve(e),i=s.node(-1),o=s.start(-1),l=re.get(i).colCount(s.pos-o)+s.nodeAfter.attrs.colspan-1;let a=n.domAtPos(s.start(-1)).node;for(;a&&a.nodeName!="TABLE";)a=a.parentNode;a&&lo(i,a.firstChild,a,r,l,t)}function K0(n){return Array(n).fill(0)}function q0(n,e){var t;const r=[],s=n.doc.resolve(e),i=s.node(-1);if(!i)return ee.empty;const o=re.get(i),l=s.start(-1),a=o.colCount(s.pos-l)+s.nodeAfter.attrs.colspan-1;for(let c=0;c<o.height;c++){const u=a+c*o.width;if((a==o.width-1||o.map[u]!=o.map[u+1])&&(c==0||o.map[u]!=o.map[u-o.width])){const d=o.map[u],f=l+d+i.nodeAt(d).nodeSize-1,h=document.createElement("div");h.className="column-resize-handle",(t=Pe.getState(n))!=null&&t.dragging&&r.push(ye.node(l+d,l+d+i.nodeAt(d).nodeSize,{class:"column-resize-dragging"})),r.push(ye.widget(f,h))}}return ee.create(n.doc,r)}function G0({allowTableNodeSelection:n=!1}={}){return new se({key:kt,state:{init(){return null},apply(e,t){const r=e.getMeta(kt);if(r!=null)return r==-1?null:r;if(t==null||!e.docChanged)return t;const{deleted:s,pos:i}=e.mapping.mapResult(t);return s?null:i}},props:{decorations:l0,handleDOMEvents:{mousedown:j0},createSelectionBetween(e){return kt.getState(e.state)!=null?e.state.selection:null},handleTripleClick:I0,handleKeyDown:D0,handlePaste:P0},appendTransaction(e,t,r){return u0(r,kd(r,t),n)}})}function ao(n,e){return e?["width",`${Math.max(e,n)}px`]:["min-width",`${n}px`]}function Xa(n,e,t,r,s,i){var o;let l=0,a=!0,c=e.firstChild;const u=n.firstChild;if(u!==null)for(let d=0,f=0;d<u.childCount;d+=1){const{colspan:h,colwidth:p}=u.child(d).attrs;for(let g=0;g<h;g+=1,f+=1){const y=s===f?i:p&&p[g],b=y?`${y}px`:"";if(l+=y||r,y||(a=!1),c){if(c.style.width!==b){const[x,C]=ao(r,y);c.style.setProperty(x,C)}c=c.nextSibling}else{const x=document.createElement("col"),[C,k]=ao(r,y);x.style.setProperty(C,k),e.appendChild(x)}}}for(;c;){const d=c.nextSibling;(o=c.parentNode)===null||o===void 0||o.removeChild(c),c=d}a?(t.style.width=`${l}px`,t.style.minWidth=""):(t.style.width="",t.style.minWidth=`${l}px`)}class J0{constructor(e,t){this.node=e,this.cellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Xa(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!==this.node.type?!1:(this.node=e,Xa(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type==="attributes"&&(e.target===this.table||this.colgroup.contains(e.target))}}function Y0(n,e,t,r){let s=0,i=!0;const o=[],l=n.firstChild;if(!l)return{};for(let d=0,f=0;d<l.childCount;d+=1){const{colspan:h,colwidth:p}=l.child(d).attrs;for(let g=0;g<h;g+=1,f+=1){const y=t===f?r:p&&p[g];s+=y||e,y||(i=!1);const[b,x]=ao(e,y);o.push(["col",{style:`${b}: ${x}`}])}}const a=i?`${s}px`:"",c=i?"":`${s}px`;return{colgroup:["colgroup",{},...o],tableWidth:a,tableMinWidth:c}}function Qa(n,e){return n.createAndFill()}function X0(n){if(n.cached.tableNodeTypes)return n.cached.tableNodeTypes;const e={};return Object.keys(n.nodes).forEach(t=>{const r=n.nodes[t];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),n.cached.tableNodeTypes=e,e}function Q0(n,e,t,r,s){const i=X0(n),o=[],l=[];for(let c=0;c<t;c+=1){const u=Qa(i.cell);if(u&&l.push(u),r){const d=Qa(i.header_cell);d&&o.push(d)}}const a=[];for(let c=0;c<e;c+=1)a.push(i.row.createChecked(null,r&&c===0?o:l));return i.table.createChecked(null,a)}function Z0(n){return n instanceof Y}const Er=({editor:n})=>{const{selection:e}=n.state;if(!Z0(e))return!1;let t=0;const r=td(e.ranges[0].$from,i=>i.type.name==="table");return r?.node.descendants(i=>{if(i.type.name==="table")return!1;["tableCell","tableHeader"].includes(i.type.name)&&(t+=1)}),t===e.ranges.length?(n.commands.deleteTable(),!0):!1},ex=ie.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:J0,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:n,HTMLAttributes:e}){const{colgroup:t,tableWidth:r,tableMinWidth:s}=Y0(n,this.options.cellMinWidth),i=["table",K(this.options.HTMLAttributes,e,{style:r?`width: ${r}`:`min-width: ${s}`}),t,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},i]:i},addCommands(){return{insertTable:({rows:n=3,cols:e=3,withHeaderRow:t=!0}={})=>({tr:r,dispatch:s,editor:i})=>{const o=Q0(i.schema,n,e,t);if(s){const l=r.selection.from+1;r.replaceSelectionWith(o).scrollIntoView().setSelection(P.near(r.doc.resolve(l)))}return!0},addColumnBefore:()=>({state:n,dispatch:e})=>h0(n,e),addColumnAfter:()=>({state:n,dispatch:e})=>p0(n,e),deleteColumn:()=>({state:n,dispatch:e})=>g0(n,e),addRowBefore:()=>({state:n,dispatch:e})=>b0(n,e),addRowAfter:()=>({state:n,dispatch:e})=>x0(n,e),deleteRow:()=>({state:n,dispatch:e})=>S0(n,e),deleteTable:()=>({state:n,dispatch:e})=>A0(n,e),mergeCells:()=>({state:n,dispatch:e})=>_a(n,e),splitCell:()=>({state:n,dispatch:e})=>Fa(n,e),toggleHeaderColumn:()=>({state:n,dispatch:e})=>rr("column")(n,e),toggleHeaderRow:()=>({state:n,dispatch:e})=>rr("row")(n,e),toggleHeaderCell:()=>({state:n,dispatch:e})=>E0(n,e),mergeOrSplit:()=>({state:n,dispatch:e})=>_a(n,e)?!0:Fa(n,e),setCellAttribute:(n,e)=>({state:t,dispatch:r})=>v0(n,e)(t,r),goToNextCell:()=>({state:n,dispatch:e})=>Va(1)(n,e),goToPreviousCell:()=>({state:n,dispatch:e})=>Va(-1)(n,e),fixTables:()=>({state:n,dispatch:e})=>(e&&kd(n),!0),setCellSelection:n=>({tr:e,dispatch:t})=>{if(t){const r=Y.create(e.doc,n.anchorCell,n.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:Er,"Mod-Backspace":Er,Delete:Er,"Mod-Delete":Er}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[z0({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],G0({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(n){const e={name:n.name,options:n.options,storage:n.storage};return{tableRole:F(L(n,"tableRole",e))}}}),tx=ie.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:n}){return["tr",K(this.options.HTMLAttributes,n),0]}}),nx=ie.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:n=>{const e=n.getAttribute("colwidth");return e?e.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:n}){return["td",K(this.options.HTMLAttributes,n),0]}}),rx=ie.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:n=>{const e=n.getAttribute("colwidth");return e?e.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:n}){return["th",K(this.options.HTMLAttributes,n),0]}}),sx="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",ix="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2",co="numeric",uo="ascii",fo="alpha",_n="asciinumeric",In="alphanumeric",ho="domain",Md="emoji",ox="scheme",lx="slashscheme",Ci="whitespace";function ax(n,e){return n in e||(e[n]=[]),e[n]}function Ft(n,e,t){e[co]&&(e[_n]=!0,e[In]=!0),e[uo]&&(e[_n]=!0,e[fo]=!0),e[_n]&&(e[In]=!0),e[fo]&&(e[In]=!0),e[In]&&(e[ho]=!0),e[Md]&&(e[ho]=!0);for(const r in e){const s=ax(r,t);s.indexOf(n)<0&&s.push(n)}}function cx(n,e){const t={};for(const r in e)e[r].indexOf(n)>=0&&(t[r]=!0);return t}function Oe(n=null){this.j={},this.jr=[],this.jd=null,this.t=n}Oe.groups={};Oe.prototype={accepts(){return!!this.t},go(n){const e=this,t=e.j[n];if(t)return t;for(let r=0;r<e.jr.length;r++){const s=e.jr[r][0],i=e.jr[r][1];if(i&&s.test(n))return i}return e.jd},has(n,e=!1){return e?n in this.j:!!this.go(n)},ta(n,e,t,r){for(let s=0;s<n.length;s++)this.tt(n[s],e,t,r)},tr(n,e,t,r){r=r||Oe.groups;let s;return e&&e.j?s=e:(s=new Oe(e),t&&r&&Ft(e,t,r)),this.jr.push([n,s]),s},ts(n,e,t,r){let s=this;const i=n.length;if(!i)return s;for(let o=0;o<i-1;o++)s=s.tt(n[o]);return s.tt(n[i-1],e,t,r)},tt(n,e,t,r){r=r||Oe.groups;const s=this;if(e&&e.j)return s.j[n]=e,e;const i=e;let o,l=s.go(n);if(l?(o=new Oe,Object.assign(o.j,l.j),o.jr.push.apply(o.jr,l.jr),o.jd=l.jd,o.t=l.t):o=new Oe,i){if(r)if(o.t&&typeof o.t=="string"){const a=Object.assign(cx(o.t,r),t);Ft(i,a,r)}else t&&Ft(i,t,r);o.t=i}return s.j[n]=o,o}};const V=(n,e,t,r,s)=>n.ta(e,t,r,s),te=(n,e,t,r,s)=>n.tr(e,t,r,s),Za=(n,e,t,r,s)=>n.ts(e,t,r,s),T=(n,e,t,r,s)=>n.tt(e,t,r,s),at="WORD",po="UWORD",Ed="ASCIINUMERICAL",Td="ALPHANUMERICAL",sr="LOCALHOST",mo="TLD",go="UTLD",zr="SCHEME",fn="SLASH_SCHEME",Jo="NUM",yo="WS",Yo="NL",Fn="OPENBRACE",$n="CLOSEBRACE",Zr="OPENBRACKET",es="CLOSEBRACKET",ts="OPENPAREN",ns="CLOSEPAREN",rs="OPENANGLEBRACKET",ss="CLOSEANGLEBRACKET",is="FULLWIDTHLEFTPAREN",ls="FULLWIDTHRIGHTPAREN",as="LEFTCORNERBRACKET",cs="RIGHTCORNERBRACKET",us="LEFTWHITECORNERBRACKET",ds="RIGHTWHITECORNERBRACKET",fs="FULLWIDTHLESSTHAN",hs="FULLWIDTHGREATERTHAN",ps="AMPERSAND",ms="APOSTROPHE",gs="ASTERISK",bt="AT",ys="BACKSLASH",bs="BACKTICK",xs="CARET",$t="COLON",Xo="COMMA",ks="DOLLAR",Xe="DOT",Ss="EQUALS",Qo="EXCLAMATION",He="HYPHEN",Vn="PERCENT",ws="PIPE",Cs="PLUS",vs="POUND",Wn="QUERY",Zo="QUOTE",Ad="FULLWIDTHMIDDLEDOT",el="SEMI",Qe="SLASH",Un="TILDE",Ms="UNDERSCORE",Nd="EMOJI",Es="SYM";var Od=Object.freeze({__proto__:null,ALPHANUMERICAL:Td,AMPERSAND:ps,APOSTROPHE:ms,ASCIINUMERICAL:Ed,ASTERISK:gs,AT:bt,BACKSLASH:ys,BACKTICK:bs,CARET:xs,CLOSEANGLEBRACKET:ss,CLOSEBRACE:$n,CLOSEBRACKET:es,CLOSEPAREN:ns,COLON:$t,COMMA:Xo,DOLLAR:ks,DOT:Xe,EMOJI:Nd,EQUALS:Ss,EXCLAMATION:Qo,FULLWIDTHGREATERTHAN:hs,FULLWIDTHLEFTPAREN:is,FULLWIDTHLESSTHAN:fs,FULLWIDTHMIDDLEDOT:Ad,FULLWIDTHRIGHTPAREN:ls,HYPHEN:He,LEFTCORNERBRACKET:as,LEFTWHITECORNERBRACKET:us,LOCALHOST:sr,NL:Yo,NUM:Jo,OPENANGLEBRACKET:rs,OPENBRACE:Fn,OPENBRACKET:Zr,OPENPAREN:ts,PERCENT:Vn,PIPE:ws,PLUS:Cs,POUND:vs,QUERY:Wn,QUOTE:Zo,RIGHTCORNERBRACKET:cs,RIGHTWHITECORNERBRACKET:ds,SCHEME:zr,SEMI:el,SLASH:Qe,SLASH_SCHEME:fn,SYM:Es,TILDE:Un,TLD:mo,UNDERSCORE:Ms,UTLD:go,UWORD:po,WORD:at,WS:yo});const it=/[a-z]/,Nn=new RegExp("\\p{L}","u"),vi=new RegExp("\\p{Emoji}","u"),ot=/\d/,Mi=/\s/,ec="\r",Ei=`
|
|
126
|
+
`,ux="️",dx="",Ti="";let Tr=null,Ar=null;function fx(n=[]){const e={};Oe.groups=e;const t=new Oe;Tr==null&&(Tr=tc(sx)),Ar==null&&(Ar=tc(ix)),T(t,"'",ms),T(t,"{",Fn),T(t,"}",$n),T(t,"[",Zr),T(t,"]",es),T(t,"(",ts),T(t,")",ns),T(t,"<",rs),T(t,">",ss),T(t,"(",is),T(t,")",ls),T(t,"「",as),T(t,"」",cs),T(t,"『",us),T(t,"』",ds),T(t,"<",fs),T(t,">",hs),T(t,"&",ps),T(t,"*",gs),T(t,"@",bt),T(t,"`",bs),T(t,"^",xs),T(t,":",$t),T(t,",",Xo),T(t,"$",ks),T(t,".",Xe),T(t,"=",Ss),T(t,"!",Qo),T(t,"-",He),T(t,"%",Vn),T(t,"|",ws),T(t,"+",Cs),T(t,"#",vs),T(t,"?",Wn),T(t,'"',Zo),T(t,"/",Qe),T(t,";",el),T(t,"~",Un),T(t,"_",Ms),T(t,"\\",ys),T(t,"・",Ad);const r=te(t,ot,Jo,{[co]:!0});te(r,ot,r);const s=te(r,it,Ed,{[_n]:!0}),i=te(r,Nn,Td,{[In]:!0}),o=te(t,it,at,{[uo]:!0});te(o,ot,s),te(o,it,o),te(s,ot,s),te(s,it,s);const l=te(t,Nn,po,{[fo]:!0});te(l,it),te(l,ot,i),te(l,Nn,l),te(i,ot,i),te(i,it),te(i,Nn,i);const a=T(t,Ei,Yo,{[Ci]:!0}),c=T(t,ec,yo,{[Ci]:!0}),u=te(t,Mi,yo,{[Ci]:!0});T(t,Ti,u),T(c,Ei,a),T(c,Ti,u),te(c,Mi,u),T(u,ec),T(u,Ei),te(u,Mi,u),T(u,Ti,u);const d=te(t,vi,Nd,{[Md]:!0});T(d,"#"),te(d,vi,d),T(d,ux,d);const f=T(d,dx);T(f,"#"),te(f,vi,d);const h=[[it,o],[ot,s]],p=[[it,null],[Nn,l],[ot,i]];for(let g=0;g<Tr.length;g++)pt(t,Tr[g],mo,at,h);for(let g=0;g<Ar.length;g++)pt(t,Ar[g],go,po,p);Ft(mo,{tld:!0,ascii:!0},e),Ft(go,{utld:!0,alpha:!0},e),pt(t,"file",zr,at,h),pt(t,"mailto",zr,at,h),pt(t,"http",fn,at,h),pt(t,"https",fn,at,h),pt(t,"ftp",fn,at,h),pt(t,"ftps",fn,at,h),Ft(zr,{scheme:!0,ascii:!0},e),Ft(fn,{slashscheme:!0,ascii:!0},e),n=n.sort((g,y)=>g[0]>y[0]?1:-1);for(let g=0;g<n.length;g++){const y=n[g][0],x=n[g][1]?{[ox]:!0}:{[lx]:!0};y.indexOf("-")>=0?x[ho]=!0:it.test(y)?ot.test(y)?x[_n]=!0:x[uo]=!0:x[co]=!0,Za(t,y,y,x)}return Za(t,"localhost",sr,{ascii:!0}),t.jd=new Oe(Es),{start:t,tokens:Object.assign({groups:e},Od)}}function Rd(n,e){const t=hx(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=t.length,s=[];let i=0,o=0;for(;o<r;){let l=n,a=null,c=0,u=null,d=-1,f=-1;for(;o<r&&(a=l.go(t[o]));)l=a,l.accepts()?(d=0,f=0,u=l):d>=0&&(d+=t[o].length,f++),c+=t[o].length,i+=t[o].length,o++;i-=d,o-=f,c-=d,s.push({t:u.t,v:e.slice(i-c,i),s:i-c,e:i})}return s}function hx(n){const e=[],t=n.length;let r=0;for(;r<t;){let s=n.charCodeAt(r),i,o=s<55296||s>56319||r+1===t||(i=n.charCodeAt(r+1))<56320||i>57343?n[r]:n.slice(r,r+2);e.push(o),r+=o.length}return e}function pt(n,e,t,r,s){let i;const o=e.length;for(let l=0;l<o-1;l++){const a=e[l];n.j[a]?i=n.j[a]:(i=new Oe(r),i.jr=s.slice(),n.j[a]=i),n=i}return i=new Oe(t),i.jr=s.slice(),n.j[e[o-1]]=i,i}function tc(n){const e=[],t=[];let r=0,s="0123456789";for(;r<n.length;){let i=0;for(;s.indexOf(n[r+i])>=0;)i++;if(i>0){e.push(t.join(""));for(let o=parseInt(n.substring(r,r+i),10);o>0;o--)t.pop();r+=i}else t.push(n[r]),r++}return e}const ir={defaultProtocol:"http",events:null,format:nc,formatHref:nc,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function tl(n,e=null){let t=Object.assign({},ir);n&&(t=Object.assign(t,n instanceof tl?n.o:n));const r=t.ignoreTags,s=[];for(let i=0;i<r.length;i++)s.push(r[i].toUpperCase());this.o=t,e&&(this.defaultRender=e),this.ignoreTags=s}tl.prototype={o:ir,ignoreTags:[],defaultRender(n){return n},check(n){return this.get("validate",n.toString(),n)},get(n,e,t){const r=e!=null;let s=this.o[n];return s&&(typeof s=="object"?(s=t.t in s?s[t.t]:ir[n],typeof s=="function"&&r&&(s=s(e,t))):typeof s=="function"&&r&&(s=s(e,t.t,t)),s)},getObj(n,e,t){let r=this.o[n];return typeof r=="function"&&e!=null&&(r=r(e,t.t,t)),r},render(n){const e=n.render(this);return(this.get("render",null,n)||this.defaultRender)(e,n.t,n)}};function nc(n){return n}function Ld(n,e){this.t="token",this.v=n,this.tk=e}Ld.prototype={isLink:!1,toString(){return this.v},toHref(n){return this.toString()},toFormattedString(n){const e=this.toString(),t=n.get("truncate",e,this),r=n.get("format",e,this);return t&&r.length>t?r.substring(0,t)+"…":r},toFormattedHref(n){return n.get("formatHref",this.toHref(n.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(n=ir.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(n),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(n){return{type:this.t,value:this.toFormattedString(n),isLink:this.isLink,href:this.toFormattedHref(n),start:this.startIndex(),end:this.endIndex()}},validate(n){return n.get("validate",this.toString(),this)},render(n){const e=this,t=this.toHref(n.get("defaultProtocol")),r=n.get("formatHref",t,this),s=n.get("tagName",t,e),i=this.toFormattedString(n),o={},l=n.get("className",t,e),a=n.get("target",t,e),c=n.get("rel",t,e),u=n.getObj("attributes",t,e),d=n.getObj("events",t,e);return o.href=r,l&&(o.class=l),a&&(o.target=a),c&&(o.rel=c),u&&Object.assign(o,u),{tagName:s,attributes:o,content:i,eventListeners:d}}};function Ks(n,e){class t extends Ld{constructor(s,i){super(s,i),this.t=n}}for(const r in e)t.prototype[r]=e[r];return t.t=n,t}const px=Ks("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),rc=Ks("text"),mx=Ks("nl"),Nr=Ks("url",{isLink:!0,toHref(n=ir.defaultProtocol){return this.hasProtocol()?this.v:`${n}://${this.v}`},hasProtocol(){const n=this.tk;return n.length>=2&&n[0].t!==sr&&n[1].t===$t}}),ze=n=>new Oe(n);function gx({groups:n}){const e=n.domain.concat([ps,gs,bt,ys,bs,xs,ks,Ss,He,Jo,Vn,ws,Cs,vs,Qe,Es,Un,Ms]),t=[ms,$t,Xo,Xe,Qo,Vn,Wn,Zo,el,rs,ss,Fn,$n,es,Zr,ts,ns,is,ls,as,cs,us,ds,fs,hs],r=[ps,ms,gs,ys,bs,xs,ks,Ss,He,Fn,$n,Vn,ws,Cs,vs,Wn,Qe,Es,Un,Ms],s=ze(),i=T(s,Un);V(i,r,i),V(i,n.domain,i);const o=ze(),l=ze(),a=ze();V(s,n.domain,o),V(s,n.scheme,l),V(s,n.slashscheme,a),V(o,r,i),V(o,n.domain,o);const c=T(o,bt);T(i,bt,c),T(l,bt,c),T(a,bt,c);const u=T(i,Xe);V(u,r,i),V(u,n.domain,i);const d=ze();V(c,n.domain,d),V(d,n.domain,d);const f=T(d,Xe);V(f,n.domain,d);const h=ze(px);V(f,n.tld,h),V(f,n.utld,h),T(c,sr,h);const p=T(d,He);T(p,He,p),V(p,n.domain,d),V(h,n.domain,d),T(h,Xe,f),T(h,He,p);const g=T(o,He),y=T(o,Xe);T(g,He,g),V(g,n.domain,o),V(y,r,i),V(y,n.domain,o);const b=ze(Nr);V(y,n.tld,b),V(y,n.utld,b),V(b,n.domain,o),V(b,r,i),T(b,Xe,y),T(b,He,g),T(b,bt,c);const x=T(b,$t),C=ze(Nr);V(x,n.numeric,C);const k=ze(Nr),M=ze();V(k,e,k),V(k,t,M),V(M,e,k),V(M,t,M),T(b,Qe,k),T(C,Qe,k);const R=T(l,$t),z=T(a,$t),w=T(z,Qe),j=T(w,Qe);V(l,n.domain,o),T(l,Xe,y),T(l,He,g),V(a,n.domain,o),T(a,Xe,y),T(a,He,g),V(R,n.domain,k),T(R,Qe,k),T(R,Wn,k),V(j,n.domain,k),V(j,e,k),T(j,Qe,k);const G=[[Fn,$n],[Zr,es],[ts,ns],[rs,ss],[is,ls],[as,cs],[us,ds],[fs,hs]];for(let Ae=0;Ae<G.length;Ae++){const[Be,Ve]=G[Ae],Le=T(k,Be);T(M,Be,Le);const ve=ze(Nr);V(Le,e,ve);const Ne=ze();V(Le,t,Ne),T(Le,Ve,k),V(ve,e,ve),V(ve,t,Ne),V(Ne,e,ve),V(Ne,t,Ne),T(ve,Ve,k),T(Ne,Ve,k)}return T(s,sr,b),T(s,Yo,mx),{start:s,tokens:Od}}function yx(n,e,t){let r=t.length,s=0,i=[],o=[];for(;s<r;){let l=n,a=null,c=null,u=0,d=null,f=-1;for(;s<r&&!(a=l.go(t[s].t));)o.push(t[s++]);for(;s<r&&(c=a||l.go(t[s].t));)a=null,l=c,l.accepts()?(f=0,d=l):f>=0&&f++,s++,u++;if(f<0)s-=u,s<r&&(o.push(t[s]),s++);else{o.length>0&&(i.push(Ai(rc,e,o)),o=[]),s-=f,u-=f;const h=d.t,p=t.slice(s-u,s);i.push(Ai(h,e,p))}}return o.length>0&&i.push(Ai(rc,e,o)),i}function Ai(n,e,t){const r=t[0].s,s=t[t.length-1].e,i=e.slice(r,s);return new n(i,t)}const bx=typeof console<"u"&&console&&console.warn||(()=>{}),xx="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",Q={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function kx(){return Oe.groups={},Q.scanner=null,Q.parser=null,Q.tokenQueue=[],Q.pluginQueue=[],Q.customSchemes=[],Q.initialized=!1,Q}function sc(n,e=!1){if(Q.initialized&&bx(`linkifyjs: already initialized - will not register custom scheme "${n}" ${xx}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(n))throw new Error(`linkifyjs: incorrect scheme format.
|
|
127
|
+
1. Must only contain digits, lowercase ASCII letters or "-"
|
|
128
|
+
2. Cannot start or end with "-"
|
|
129
|
+
3. "-" cannot repeat`);Q.customSchemes.push([n,e])}function Sx(){Q.scanner=fx(Q.customSchemes);for(let n=0;n<Q.tokenQueue.length;n++)Q.tokenQueue[n][1]({scanner:Q.scanner});Q.parser=gx(Q.scanner.tokens);for(let n=0;n<Q.pluginQueue.length;n++)Q.pluginQueue[n][1]({scanner:Q.scanner,parser:Q.parser});return Q.initialized=!0,Q}function nl(n){return Q.initialized||Sx(),yx(Q.parser.start,n,Rd(Q.scanner.start,n))}nl.scan=Rd;function Dd(n,e=null,t=null){if(e&&typeof e=="object"){if(t)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);t=e,e=null}const r=new tl(t),s=nl(n),i=[];for(let o=0;o<s.length;o++){const l=s[o];l.isLink&&(!e||l.t===e)&&r.check(l)&&i.push(l.toFormattedObject(r))}return i}const rl="[\0- -\u2029 ]",wx=new RegExp(rl),Cx=new RegExp(`${rl}$`),vx=new RegExp(rl,"g");function Mx(n){return n.length===1?n[0].isLink:n.length===3&&n[1].isLink?["()","[]"].includes(n[0].value+n[2].value):!1}function Ex(n){return new se({key:new ae("autolink"),appendTransaction:(e,t,r)=>{const s=e.some(c=>c.docChanged)&&!t.doc.eq(r.doc),i=e.some(c=>c.getMeta("preventAutolink"));if(!s||i)return;const{tr:o}=r,l=Vg(t.doc,[...e]);if(Yg(l).forEach(({newRange:c})=>{const u=Ug(r.doc,c,h=>h.isTextblock);let d,f;if(u.length>1)d=u[0],f=r.doc.textBetween(d.pos,d.pos+d.node.nodeSize,void 0," ");else if(u.length){const h=r.doc.textBetween(c.from,c.to," "," ");if(!Cx.test(h))return;d=u[0],f=r.doc.textBetween(d.pos,c.to,void 0," ")}if(d&&f){const h=f.split(wx).filter(Boolean);if(h.length<=0)return!1;const p=h[h.length-1],g=d.pos+f.lastIndexOf(p);if(!p)return!1;const y=nl(p).map(b=>b.toObject(n.defaultProtocol));if(!Mx(y))return!1;y.filter(b=>b.isLink).map(b=>({...b,from:g+b.start+1,to:g+b.end+1})).filter(b=>r.schema.marks.code?!r.doc.rangeHasMark(b.from,b.to,r.schema.marks.code):!0).filter(b=>n.validate(b.value)).filter(b=>n.shouldAutoLink(b.value)).forEach(b=>{Vo(b.from,b.to,r.doc).some(x=>x.mark.type===n.type)||o.addMark(b.from,b.to,n.type.create({href:b.href}))})}}),!!o.steps.length)return o}})}function Tx(n){return new se({key:new ae("handleClickLink"),props:{handleClick:(e,t,r)=>{var s,i;if(r.button!==0||!e.editable)return!1;let o=r.target;const l=[];for(;o.nodeName!=="DIV";)l.push(o),o=o.parentNode;if(!l.find(f=>f.nodeName==="A"))return!1;const a=nd(e.state,n.type.name),c=r.target,u=(s=c?.href)!==null&&s!==void 0?s:a.href,d=(i=c?.target)!==null&&i!==void 0?i:a.target;return c&&u?(window.open(u,d),!0):!1}}})}function Ax(n){return new se({key:new ae("handlePasteLink"),props:{handlePaste:(e,t,r)=>{const{state:s}=e,{selection:i}=s,{empty:o}=i;if(o)return!1;let l="";r.content.forEach(c=>{l+=c.textContent});const a=Dd(l,{defaultProtocol:n.defaultProtocol}).find(c=>c.isLink&&c.value===l);return!l||!a?!1:n.editor.commands.setMark(n.type,{href:a.href})}}})}function Pt(n,e){const t=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const s=typeof r=="string"?r:r.scheme;s&&t.push(s)}),!n||n.replace(vx,"").match(new RegExp(`^(?:(?:${t.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}const Nx=Se.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(n=>{if(typeof n=="string"){sc(n);return}sc(n.scheme,n.optionalSlashes)})},onDestroy(){kx()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(n,e)=>!!Pt(n,e.protocols),validate:n=>!!n,shouldAutoLink:n=>!!n}},addAttributes(){return{href:{default:null,parseHTML(n){return n.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:n=>{const e=n.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:t=>!!Pt(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:n}){return this.options.isAllowedUri(n.href,{defaultValidate:e=>!!Pt(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",K(this.options.HTMLAttributes,n),0]:["a",K(this.options.HTMLAttributes,{...n,href:""}),0]},addCommands(){return{setLink:n=>({chain:e})=>{const{href:t}=n;return this.options.isAllowedUri(t,{defaultValidate:r=>!!Pt(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,n).setMeta("preventAutolink",!0).run():!1},toggleLink:n=>({chain:e})=>{const{href:t}=n;return this.options.isAllowedUri(t,{defaultValidate:r=>!!Pt(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().toggleMark(this.name,n,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run():!1},unsetLink:()=>({chain:n})=>n().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[Ot({find:n=>{const e=[];if(n){const{protocols:t,defaultProtocol:r}=this.options,s=Dd(n).filter(i=>i.isLink&&this.options.isAllowedUri(i.value,{defaultValidate:o=>!!Pt(o,t),protocols:t,defaultProtocol:r}));s.length&&s.forEach(i=>e.push({text:i.value,data:{href:i.href},index:i.start}))}return e},type:this.type,getAttributes:n=>{var e;return{href:(e=n.data)===null||e===void 0?void 0:e.href}}})]},addProseMirrorPlugins(){const n=[],{protocols:e,defaultProtocol:t}=this.options;return this.options.autolink&&n.push(Ex({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:s=>!!Pt(s,e),protocols:e,defaultProtocol:t}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&n.push(Tx({type:this.type})),this.options.linkOnPaste&&n.push(Ax({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),n}}),Ox=le.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:n=>{const e=n.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:n=>n.textAlign?{style:`text-align: ${n.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:n=>({commands:e})=>this.options.alignments.includes(n)?this.options.types.map(t=>e.updateAttributes(t,{textAlign:n})).every(t=>t):!1,unsetTextAlign:()=>({commands:n})=>this.options.types.map(e=>n.resetAttributes(e,"textAlign")).every(e=>e),toggleTextAlign:n=>({editor:e,commands:t})=>this.options.alignments.includes(n)?e.isActive({textAlign:n})?t.unsetTextAlign():t.setTextAlign(n):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),Rx=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,Lx=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,Dx=Se.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:n=>n.getAttribute("data-color")||n.style.backgroundColor,renderHTML:n=>n.color?{"data-color":n.color,style:`background-color: ${n.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:n}){return["mark",K(this.options.HTMLAttributes,n),0]},addCommands(){return{setHighlight:n=>({commands:e})=>e.setMark(this.name,n),toggleHighlight:n=>({commands:e})=>e.toggleMark(this.name,n),unsetHighlight:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[Zt({find:Rx,type:this.type})]},addPasteRules(){return[Ot({find:Lx,type:this.type})]}}),Ix=Se.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["u",K(this.options.HTMLAttributes,n),0]},addCommands(){return{setUnderline:()=>({commands:n})=>n.setMark(this.name),toggleUnderline:()=>({commands:n})=>n.toggleMark(this.name),unsetUnderline:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),Px=Se.create({name:"subscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sub"},{style:"vertical-align",getAttrs(n){return n!=="sub"?!1:null}}]},renderHTML({HTMLAttributes:n}){return["sub",K(this.options.HTMLAttributes,n),0]},addCommands(){return{setSubscript:()=>({commands:n})=>n.setMark(this.name),toggleSubscript:()=>({commands:n})=>n.toggleMark(this.name),unsetSubscript:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}}),jx=Se.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(n){return n!=="super"?!1:null}}]},renderHTML({HTMLAttributes:n}){return["sup",K(this.options.HTMLAttributes,n),0]},addCommands(){return{setSuperscript:()=>({commands:n})=>n.setMark(this.name),toggleSuperscript:()=>({commands:n})=>n.toggleMark(this.name),unsetSuperscript:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}});function Bx(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}function Id(n){return n instanceof Map?n.clear=n.delete=n.set=function(){throw new Error("map is read-only")}:n instanceof Set&&(n.add=n.clear=n.delete=function(){throw new Error("set is read-only")}),Object.freeze(n),Object.getOwnPropertyNames(n).forEach(e=>{const t=n[e],r=typeof t;(r==="object"||r==="function")&&!Object.isFrozen(t)&&Id(t)}),n}class ic{constructor(e){e.data===void 0&&(e.data={}),this.data=e.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function Pd(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function vt(n,...e){const t=Object.create(null);for(const r in n)t[r]=n[r];return e.forEach(function(r){for(const s in r)t[s]=r[s]}),t}const zx="</span>",oc=n=>!!n.scope,Hx=(n,{prefix:e})=>{if(n.startsWith("language:"))return n.replace("language:","language-");if(n.includes(".")){const t=n.split(".");return[`${e}${t.shift()}`,...t.map((r,s)=>`${r}${"_".repeat(s+1)}`)].join(" ")}return`${e}${n}`};class _x{constructor(e,t){this.buffer="",this.classPrefix=t.classPrefix,e.walk(this)}addText(e){this.buffer+=Pd(e)}openNode(e){if(!oc(e))return;const t=Hx(e.scope,{prefix:this.classPrefix});this.span(t)}closeNode(e){oc(e)&&(this.buffer+=zx)}value(){return this.buffer}span(e){this.buffer+=`<span class="${e}">`}}const lc=(n={})=>{const e={children:[]};return Object.assign(e,n),e};class sl{constructor(){this.rootNode=lc(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(e){this.top.children.push(e)}openNode(e){const t=lc({scope:e});this.add(t),this.stack.push(t)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(e){return this.constructor._walk(e,this.rootNode)}static _walk(e,t){return typeof t=="string"?e.addText(t):t.children&&(e.openNode(t),t.children.forEach(r=>this._walk(e,r)),e.closeNode(t)),e}static _collapse(e){typeof e!="string"&&e.children&&(e.children.every(t=>typeof t=="string")?e.children=[e.children.join("")]:e.children.forEach(t=>{sl._collapse(t)}))}}class Fx extends sl{constructor(e){super(),this.options=e}addText(e){e!==""&&this.add(e)}startScope(e){this.openNode(e)}endScope(){this.closeNode()}__addSublanguage(e,t){const r=e.root;t&&(r.scope=`language:${t}`),this.add(r)}toHTML(){return new _x(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function or(n){return n?typeof n=="string"?n:n.source:null}function jd(n){return rn("(?=",n,")")}function $x(n){return rn("(?:",n,")*")}function Vx(n){return rn("(?:",n,")?")}function rn(...n){return n.map(t=>or(t)).join("")}function Wx(n){const e=n[n.length-1];return typeof e=="object"&&e.constructor===Object?(n.splice(n.length-1,1),e):{}}function il(...n){return"("+(Wx(n).capture?"":"?:")+n.map(r=>or(r)).join("|")+")"}function Bd(n){return new RegExp(n.toString()+"|").exec("").length-1}function Ux(n,e){const t=n&&n.exec(e);return t&&t.index===0}const Kx=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function ol(n,{joinWith:e}){let t=0;return n.map(r=>{t+=1;const s=t;let i=or(r),o="";for(;i.length>0;){const l=Kx.exec(i);if(!l){o+=i;break}o+=i.substring(0,l.index),i=i.substring(l.index+l[0].length),l[0][0]==="\\"&&l[1]?o+="\\"+String(Number(l[1])+s):(o+=l[0],l[0]==="("&&t++)}return o}).map(r=>`(${r})`).join(e)}const qx=/\b\B/,zd="[a-zA-Z]\\w*",ll="[a-zA-Z_]\\w*",Hd="\\b\\d+(\\.\\d+)?",_d="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",Fd="\\b(0b[01]+)",Gx="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",Jx=(n={})=>{const e=/^#![ ]*\//;return n.binary&&(n.begin=rn(e,/.*\b/,n.binary,/\b.*/)),vt({scope:"meta",begin:e,end:/$/,relevance:0,"on:begin":(t,r)=>{t.index!==0&&r.ignoreMatch()}},n)},lr={begin:"\\\\[\\s\\S]",relevance:0},Yx={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[lr]},Xx={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[lr]},Qx={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},qs=function(n,e,t={}){const r=vt({scope:"comment",begin:n,end:e,contains:[]},t);r.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});const s=il("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return r.contains.push({begin:rn(/[ ]+/,"(",s,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),r},Zx=qs("//","$"),e1=qs("/\\*","\\*/"),t1=qs("#","$"),n1={scope:"number",begin:Hd,relevance:0},r1={scope:"number",begin:_d,relevance:0},s1={scope:"number",begin:Fd,relevance:0},i1={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[lr,{begin:/\[/,end:/\]/,relevance:0,contains:[lr]}]},o1={scope:"title",begin:zd,relevance:0},l1={scope:"title",begin:ll,relevance:0},a1={begin:"\\.\\s*"+ll,relevance:0},c1=function(n){return Object.assign(n,{"on:begin":(e,t)=>{t.data._beginMatch=e[1]},"on:end":(e,t)=>{t.data._beginMatch!==e[1]&&t.ignoreMatch()}})};var Or=Object.freeze({__proto__:null,APOS_STRING_MODE:Yx,BACKSLASH_ESCAPE:lr,BINARY_NUMBER_MODE:s1,BINARY_NUMBER_RE:Fd,COMMENT:qs,C_BLOCK_COMMENT_MODE:e1,C_LINE_COMMENT_MODE:Zx,C_NUMBER_MODE:r1,C_NUMBER_RE:_d,END_SAME_AS_BEGIN:c1,HASH_COMMENT_MODE:t1,IDENT_RE:zd,MATCH_NOTHING_RE:qx,METHOD_GUARD:a1,NUMBER_MODE:n1,NUMBER_RE:Hd,PHRASAL_WORDS_MODE:Qx,QUOTE_STRING_MODE:Xx,REGEXP_MODE:i1,RE_STARTERS_RE:Gx,SHEBANG:Jx,TITLE_MODE:o1,UNDERSCORE_IDENT_RE:ll,UNDERSCORE_TITLE_MODE:l1});function u1(n,e){n.input[n.index-1]==="."&&e.ignoreMatch()}function d1(n,e){n.className!==void 0&&(n.scope=n.className,delete n.className)}function f1(n,e){e&&n.beginKeywords&&(n.begin="\\b("+n.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",n.__beforeBegin=u1,n.keywords=n.keywords||n.beginKeywords,delete n.beginKeywords,n.relevance===void 0&&(n.relevance=0))}function h1(n,e){Array.isArray(n.illegal)&&(n.illegal=il(...n.illegal))}function p1(n,e){if(n.match){if(n.begin||n.end)throw new Error("begin & end are not supported with match");n.begin=n.match,delete n.match}}function m1(n,e){n.relevance===void 0&&(n.relevance=1)}const g1=(n,e)=>{if(!n.beforeMatch)return;if(n.starts)throw new Error("beforeMatch cannot be used with starts");const t=Object.assign({},n);Object.keys(n).forEach(r=>{delete n[r]}),n.keywords=t.keywords,n.begin=rn(t.beforeMatch,jd(t.begin)),n.starts={relevance:0,contains:[Object.assign(t,{endsParent:!0})]},n.relevance=0,delete t.beforeMatch},y1=["of","and","for","in","not","or","if","then","parent","list","value"],b1="keyword";function $d(n,e,t=b1){const r=Object.create(null);return typeof n=="string"?s(t,n.split(" ")):Array.isArray(n)?s(t,n):Object.keys(n).forEach(function(i){Object.assign(r,$d(n[i],e,i))}),r;function s(i,o){e&&(o=o.map(l=>l.toLowerCase())),o.forEach(function(l){const a=l.split("|");r[a[0]]=[i,x1(a[0],a[1])]})}}function x1(n,e){return e?Number(e):k1(n)?0:1}function k1(n){return y1.includes(n.toLowerCase())}const ac={},Gt=n=>{console.error(n)},cc=(n,...e)=>{console.log(`WARN: ${n}`,...e)},an=(n,e)=>{ac[`${n}/${e}`]||(console.log(`Deprecated as of ${n}. ${e}`),ac[`${n}/${e}`]=!0)},Ts=new Error;function Vd(n,e,{key:t}){let r=0;const s=n[t],i={},o={};for(let l=1;l<=e.length;l++)o[l+r]=s[l],i[l+r]=!0,r+=Bd(e[l-1]);n[t]=o,n[t]._emit=i,n[t]._multi=!0}function S1(n){if(Array.isArray(n.begin)){if(n.skip||n.excludeBegin||n.returnBegin)throw Gt("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),Ts;if(typeof n.beginScope!="object"||n.beginScope===null)throw Gt("beginScope must be object"),Ts;Vd(n,n.begin,{key:"beginScope"}),n.begin=ol(n.begin,{joinWith:""})}}function w1(n){if(Array.isArray(n.end)){if(n.skip||n.excludeEnd||n.returnEnd)throw Gt("skip, excludeEnd, returnEnd not compatible with endScope: {}"),Ts;if(typeof n.endScope!="object"||n.endScope===null)throw Gt("endScope must be object"),Ts;Vd(n,n.end,{key:"endScope"}),n.end=ol(n.end,{joinWith:""})}}function C1(n){n.scope&&typeof n.scope=="object"&&n.scope!==null&&(n.beginScope=n.scope,delete n.scope)}function v1(n){C1(n),typeof n.beginScope=="string"&&(n.beginScope={_wrap:n.beginScope}),typeof n.endScope=="string"&&(n.endScope={_wrap:n.endScope}),S1(n),w1(n)}function M1(n){function e(o,l){return new RegExp(or(o),"m"+(n.case_insensitive?"i":"")+(n.unicodeRegex?"u":"")+(l?"g":""))}class t{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(l,a){a.position=this.position++,this.matchIndexes[this.matchAt]=a,this.regexes.push([a,l]),this.matchAt+=Bd(l)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const l=this.regexes.map(a=>a[1]);this.matcherRe=e(ol(l,{joinWith:"|"}),!0),this.lastIndex=0}exec(l){this.matcherRe.lastIndex=this.lastIndex;const a=this.matcherRe.exec(l);if(!a)return null;const c=a.findIndex((d,f)=>f>0&&d!==void 0),u=this.matchIndexes[c];return a.splice(0,c),Object.assign(a,u)}}class r{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(l){if(this.multiRegexes[l])return this.multiRegexes[l];const a=new t;return this.rules.slice(l).forEach(([c,u])=>a.addRule(c,u)),a.compile(),this.multiRegexes[l]=a,a}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(l,a){this.rules.push([l,a]),a.type==="begin"&&this.count++}exec(l){const a=this.getMatcher(this.regexIndex);a.lastIndex=this.lastIndex;let c=a.exec(l);if(this.resumingScanAtSamePosition()&&!(c&&c.index===this.lastIndex)){const u=this.getMatcher(0);u.lastIndex=this.lastIndex+1,c=u.exec(l)}return c&&(this.regexIndex+=c.position+1,this.regexIndex===this.count&&this.considerAll()),c}}function s(o){const l=new r;return o.contains.forEach(a=>l.addRule(a.begin,{rule:a,type:"begin"})),o.terminatorEnd&&l.addRule(o.terminatorEnd,{type:"end"}),o.illegal&&l.addRule(o.illegal,{type:"illegal"}),l}function i(o,l){const a=o;if(o.isCompiled)return a;[d1,p1,v1,g1].forEach(u=>u(o,l)),n.compilerExtensions.forEach(u=>u(o,l)),o.__beforeBegin=null,[f1,h1,m1].forEach(u=>u(o,l)),o.isCompiled=!0;let c=null;return typeof o.keywords=="object"&&o.keywords.$pattern&&(o.keywords=Object.assign({},o.keywords),c=o.keywords.$pattern,delete o.keywords.$pattern),c=c||/\w+/,o.keywords&&(o.keywords=$d(o.keywords,n.case_insensitive)),a.keywordPatternRe=e(c,!0),l&&(o.begin||(o.begin=/\B|\b/),a.beginRe=e(a.begin),!o.end&&!o.endsWithParent&&(o.end=/\B|\b/),o.end&&(a.endRe=e(a.end)),a.terminatorEnd=or(a.end)||"",o.endsWithParent&&l.terminatorEnd&&(a.terminatorEnd+=(o.end?"|":"")+l.terminatorEnd)),o.illegal&&(a.illegalRe=e(o.illegal)),o.contains||(o.contains=[]),o.contains=[].concat(...o.contains.map(function(u){return E1(u==="self"?o:u)})),o.contains.forEach(function(u){i(u,a)}),o.starts&&i(o.starts,l),a.matcher=s(a),a}if(n.compilerExtensions||(n.compilerExtensions=[]),n.contains&&n.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return n.classNameAliases=vt(n.classNameAliases||{}),i(n)}function Wd(n){return n?n.endsWithParent||Wd(n.starts):!1}function E1(n){return n.variants&&!n.cachedVariants&&(n.cachedVariants=n.variants.map(function(e){return vt(n,{variants:null},e)})),n.cachedVariants?n.cachedVariants:Wd(n)?vt(n,{starts:n.starts?vt(n.starts):null}):Object.isFrozen(n)?vt(n):n}var T1="11.10.0";class A1 extends Error{constructor(e,t){super(e),this.name="HTMLInjectionError",this.html=t}}const Ni=Pd,uc=vt,dc=Symbol("nomatch"),N1=7,Ud=function(n){const e=Object.create(null),t=Object.create(null),r=[];let s=!0;const i="Could not find the language '{}', did you forget to load/include a language module?",o={disableAutodetect:!0,name:"Plain text",contains:[]};let l={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:Fx};function a(E){return l.noHighlightRe.test(E)}function c(E){let N=E.className+" ";N+=E.parentNode?E.parentNode.className:"";const _=l.languageDetectRe.exec(N);if(_){const U=j(_[1]);return U||(cc(i.replace("{}",_[1])),cc("Falling back to no-highlight mode for this block.",E)),U?_[1]:"no-highlight"}return N.split(/\s+/).find(U=>a(U)||j(U))}function u(E,N,_){let U="",Z="";typeof N=="object"?(U=E,_=N.ignoreIllegals,Z=N.language):(an("10.7.0","highlight(lang, code, ...args) has been deprecated."),an("10.7.0",`Please use highlight(code, options) instead.
|
|
130
|
+
https://github.com/highlightjs/highlight.js/issues/2277`),Z=E,U=N),_===void 0&&(_=!0);const We={code:U,language:Z};ve("before:highlight",We);const ht=We.result?We.result:d(We.language,We.code,_);return ht.code=We.code,ve("after:highlight",ht),ht}function d(E,N,_,U){const Z=Object.create(null);function We(O,D){return O.keywords[D]}function ht(){if(!H.keywords){he.addText(X);return}let O=0;H.keywordPatternRe.lastIndex=0;let D=H.keywordPatternRe.exec(X),$="";for(;D;){$+=X.substring(O,D.index);const q=Je.case_insensitive?D[0].toLowerCase():D[0],be=We(H,q);if(be){const[rt,Af]=be;if(he.addText($),$="",Z[q]=(Z[q]||0)+1,Z[q]<=N1&&(pr+=Af),rt.startsWith("_"))$+=D[0];else{const Nf=Je.classNameAliases[rt]||rt;Ge(D[0],Nf)}}else $+=D[0];O=H.keywordPatternRe.lastIndex,D=H.keywordPatternRe.exec(X)}$+=X.substring(O),he.addText($)}function fr(){if(X==="")return;let O=null;if(typeof H.subLanguage=="string"){if(!e[H.subLanguage]){he.addText(X);return}O=d(H.subLanguage,X,!0,gl[H.subLanguage]),gl[H.subLanguage]=O._top}else O=h(X,H.subLanguage.length?H.subLanguage:null);H.relevance>0&&(pr+=O.relevance),he.__addSublanguage(O._emitter,O.language)}function De(){H.subLanguage!=null?fr():ht(),X=""}function Ge(O,D){O!==""&&(he.startScope(D),he.addText(O),he.endScope())}function fl(O,D){let $=1;const q=D.length-1;for(;$<=q;){if(!O._emit[$]){$++;continue}const be=Je.classNameAliases[O[$]]||O[$],rt=D[$];be?Ge(rt,be):(X=rt,ht(),X=""),$++}}function hl(O,D){return O.scope&&typeof O.scope=="string"&&he.openNode(Je.classNameAliases[O.scope]||O.scope),O.beginScope&&(O.beginScope._wrap?(Ge(X,Je.classNameAliases[O.beginScope._wrap]||O.beginScope._wrap),X=""):O.beginScope._multi&&(fl(O.beginScope,D),X="")),H=Object.create(O,{parent:{value:H}}),H}function pl(O,D,$){let q=Ux(O.endRe,$);if(q){if(O["on:end"]){const be=new ic(O);O["on:end"](D,be),be.isMatchIgnored&&(q=!1)}if(q){for(;O.endsParent&&O.parent;)O=O.parent;return O}}if(O.endsWithParent)return pl(O.parent,D,$)}function Cf(O){return H.matcher.regexIndex===0?(X+=O[0],1):(Xs=!0,0)}function vf(O){const D=O[0],$=O.rule,q=new ic($),be=[$.__beforeBegin,$["on:begin"]];for(const rt of be)if(rt&&(rt(O,q),q.isMatchIgnored))return Cf(D);return $.skip?X+=D:($.excludeBegin&&(X+=D),De(),!$.returnBegin&&!$.excludeBegin&&(X=D)),hl($,O),$.returnBegin?0:D.length}function Mf(O){const D=O[0],$=N.substring(O.index),q=pl(H,O,$);if(!q)return dc;const be=H;H.endScope&&H.endScope._wrap?(De(),Ge(D,H.endScope._wrap)):H.endScope&&H.endScope._multi?(De(),fl(H.endScope,O)):be.skip?X+=D:(be.returnEnd||be.excludeEnd||(X+=D),De(),be.excludeEnd&&(X=D));do H.scope&&he.closeNode(),!H.skip&&!H.subLanguage&&(pr+=H.relevance),H=H.parent;while(H!==q.parent);return q.starts&&hl(q.starts,O),be.returnEnd?0:D.length}function Ef(){const O=[];for(let D=H;D!==Je;D=D.parent)D.scope&&O.unshift(D.scope);O.forEach(D=>he.openNode(D))}let hr={};function ml(O,D){const $=D&&D[0];if(X+=O,$==null)return De(),0;if(hr.type==="begin"&&D.type==="end"&&hr.index===D.index&&$===""){if(X+=N.slice(D.index,D.index+1),!s){const q=new Error(`0 width match regex (${E})`);throw q.languageName=E,q.badRule=hr.rule,q}return 1}if(hr=D,D.type==="begin")return vf(D);if(D.type==="illegal"&&!_){const q=new Error('Illegal lexeme "'+$+'" for mode "'+(H.scope||"<unnamed>")+'"');throw q.mode=H,q}else if(D.type==="end"){const q=Mf(D);if(q!==dc)return q}if(D.type==="illegal"&&$==="")return 1;if(Ys>1e5&&Ys>D.index*3)throw new Error("potential infinite loop, way more iterations than matches");return X+=$,$.length}const Je=j(E);if(!Je)throw Gt(i.replace("{}",E)),new Error('Unknown language: "'+E+'"');const Tf=M1(Je);let Js="",H=U||Tf;const gl={},he=new l.__emitter(l);Ef();let X="",pr=0,It=0,Ys=0,Xs=!1;try{if(Je.__emitTokens)Je.__emitTokens(N,he);else{for(H.matcher.considerAll();;){Ys++,Xs?Xs=!1:H.matcher.considerAll(),H.matcher.lastIndex=It;const O=H.matcher.exec(N);if(!O)break;const D=N.substring(It,O.index),$=ml(D,O);It=O.index+$}ml(N.substring(It))}return he.finalize(),Js=he.toHTML(),{language:E,value:Js,relevance:pr,illegal:!1,_emitter:he,_top:H}}catch(O){if(O.message&&O.message.includes("Illegal"))return{language:E,value:Ni(N),illegal:!0,relevance:0,_illegalBy:{message:O.message,index:It,context:N.slice(It-100,It+100),mode:O.mode,resultSoFar:Js},_emitter:he};if(s)return{language:E,value:Ni(N),illegal:!1,relevance:0,errorRaised:O,_emitter:he,_top:H};throw O}}function f(E){const N={value:Ni(E),illegal:!1,relevance:0,_top:o,_emitter:new l.__emitter(l)};return N._emitter.addText(E),N}function h(E,N){N=N||l.languages||Object.keys(e);const _=f(E),U=N.filter(j).filter(Ae).map(De=>d(De,E,!1));U.unshift(_);const Z=U.sort((De,Ge)=>{if(De.relevance!==Ge.relevance)return Ge.relevance-De.relevance;if(De.language&&Ge.language){if(j(De.language).supersetOf===Ge.language)return 1;if(j(Ge.language).supersetOf===De.language)return-1}return 0}),[We,ht]=Z,fr=We;return fr.secondBest=ht,fr}function p(E,N,_){const U=N&&t[N]||_;E.classList.add("hljs"),E.classList.add(`language-${U}`)}function g(E){let N=null;const _=c(E);if(a(_))return;if(ve("before:highlightElement",{el:E,language:_}),E.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",E);return}if(E.children.length>0&&(l.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(E)),l.throwUnescapedHTML))throw new A1("One of your code blocks includes unescaped HTML.",E.innerHTML);N=E;const U=N.textContent,Z=_?u(U,{language:_,ignoreIllegals:!0}):h(U);E.innerHTML=Z.value,E.dataset.highlighted="yes",p(E,_,Z.language),E.result={language:Z.language,re:Z.relevance,relevance:Z.relevance},Z.secondBest&&(E.secondBest={language:Z.secondBest.language,relevance:Z.secondBest.relevance}),ve("after:highlightElement",{el:E,result:Z,text:U})}function y(E){l=uc(l,E)}const b=()=>{k(),an("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function x(){k(),an("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let C=!1;function k(){if(document.readyState==="loading"){C=!0;return}document.querySelectorAll(l.cssSelector).forEach(g)}function M(){C&&k()}typeof window<"u"&&window.addEventListener&&window.addEventListener("DOMContentLoaded",M,!1);function R(E,N){let _=null;try{_=N(n)}catch(U){if(Gt("Language definition for '{}' could not be registered.".replace("{}",E)),s)Gt(U);else throw U;_=o}_.name||(_.name=E),e[E]=_,_.rawDefinition=N.bind(null,n),_.aliases&&G(_.aliases,{languageName:E})}function z(E){delete e[E];for(const N of Object.keys(t))t[N]===E&&delete t[N]}function w(){return Object.keys(e)}function j(E){return E=(E||"").toLowerCase(),e[E]||e[t[E]]}function G(E,{languageName:N}){typeof E=="string"&&(E=[E]),E.forEach(_=>{t[_.toLowerCase()]=N})}function Ae(E){const N=j(E);return N&&!N.disableAutodetect}function Be(E){E["before:highlightBlock"]&&!E["before:highlightElement"]&&(E["before:highlightElement"]=N=>{E["before:highlightBlock"](Object.assign({block:N.el},N))}),E["after:highlightBlock"]&&!E["after:highlightElement"]&&(E["after:highlightElement"]=N=>{E["after:highlightBlock"](Object.assign({block:N.el},N))})}function Ve(E){Be(E),r.push(E)}function Le(E){const N=r.indexOf(E);N!==-1&&r.splice(N,1)}function ve(E,N){const _=E;r.forEach(function(U){U[_]&&U[_](N)})}function Ne(E){return an("10.7.0","highlightBlock will be removed entirely in v12.0"),an("10.7.0","Please use highlightElement now."),g(E)}Object.assign(n,{highlight:u,highlightAuto:h,highlightAll:k,highlightElement:g,highlightBlock:Ne,configure:y,initHighlighting:b,initHighlightingOnLoad:x,registerLanguage:R,unregisterLanguage:z,listLanguages:w,getLanguage:j,registerAliases:G,autoDetection:Ae,inherit:uc,addPlugin:Ve,removePlugin:Le}),n.debugMode=function(){s=!1},n.safeMode=function(){s=!0},n.versionString=T1,n.regex={concat:rn,lookahead:jd,either:il,optional:Vx,anyNumberOfTimes:$x};for(const E in Or)typeof Or[E]=="object"&&Id(Or[E]);return Object.assign(n,Or),n},vn=Ud({});vn.newInstance=()=>Ud({});var O1=vn;vn.HighlightJS=vn;vn.default=vn;var R1=Bx(O1);function Kd(n,e=[]){return n.map(t=>{const r=[...e,...t.properties?t.properties.className:[]];return t.children?Kd(t.children,r):{text:t.value,classes:r}}).flat()}function fc(n){return n.value||n.children||[]}function L1(n){return!!R1.getLanguage(n)}function hc({doc:n,name:e,lowlight:t,defaultLanguage:r}){const s=[];return Yi(n,i=>i.type.name===e).forEach(i=>{var o;let l=i.pos+1;const a=i.node.attrs.language||r,c=t.listLanguages(),u=a&&(c.includes(a)||L1(a)||!((o=t.registered)===null||o===void 0)&&o.call(t,a))?fc(t.highlight(a,i.node.textContent)):fc(t.highlightAuto(i.node.textContent));Kd(u).forEach(d=>{const f=l+d.text.length;if(d.classes.length){const h=ye.inline(l,f,{class:d.classes.join(" ")});s.push(h)}l=f})}),ee.create(n,s)}function D1(n){return typeof n=="function"}function I1({name:n,lowlight:e,defaultLanguage:t}){if(!["highlight","highlightAuto","listLanguages"].every(s=>D1(e[s])))throw Error("You should provide an instance of lowlight to use the code-block-lowlight extension");const r=new se({key:new ae("lowlight"),state:{init:(s,{doc:i})=>hc({doc:i,name:n,lowlight:e,defaultLanguage:t}),apply:(s,i,o,l)=>{const a=o.selection.$head.parent.type.name,c=l.selection.$head.parent.type.name,u=Yi(o.doc,f=>f.type.name===n),d=Yi(l.doc,f=>f.type.name===n);return s.docChanged&&([a,c].includes(n)||d.length!==u.length||s.steps.some(f=>f.from!==void 0&&f.to!==void 0&&u.some(h=>h.pos>=f.from&&h.pos+h.node.nodeSize<=f.to)))?hc({doc:s.doc,name:n,lowlight:e,defaultLanguage:t}):i.map(s.mapping,s.doc)}},props:{decorations(s){return r.getState(s)}}});return r}const P1=od.extend({addOptions(){var n;return{...(n=this.parent)===null||n===void 0?void 0:n.call(this),lowlight:{},languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,HTMLAttributes:{}}},addProseMirrorPlugins(){var n;return[...((n=this.parent)===null||n===void 0?void 0:n.call(this))||[],I1({name:this.name,lowlight:this.options.lowlight,defaultLanguage:this.options.defaultLanguage})]}}),j1=n=>{if(!n.children.length)return;const e=n.querySelectorAll("span");e&&e.forEach(t=>{var r,s;const i=t.getAttribute("style"),o=(s=(r=t.parentElement)===null||r===void 0?void 0:r.closest("span"))===null||s===void 0?void 0:s.getAttribute("style");t.setAttribute("style",`${o};${i}`)})},B1=Se.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!1}},parseHTML(){return[{tag:"span",getAttrs:n=>n.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&j1(n),{}):!1}]},renderHTML({HTMLAttributes:n}){return["span",K(this.options.HTMLAttributes,n),0]},addCommands(){return{removeEmptyTextStyle:()=>({tr:n})=>{const{selection:e}=n;return n.doc.nodesBetween(e.from,e.to,(t,r)=>{if(t.isTextblock)return!0;t.marks.filter(s=>s.type===this.type).some(s=>Object.values(s.attrs).some(i=>!!i))||n.removeMark(r,r+t.nodeSize,this.type)}),!0}}}}),z1=le.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:n=>{var e;return(e=n.style.color)===null||e===void 0?void 0:e.replace(/['"]+/g,"")},renderHTML:n=>n.color?{style:`color: ${n.color}`}:{}}}}]},addCommands(){return{setColor:n=>({chain:e})=>e().setMark("textStyle",{color:n}).run(),unsetColor:()=>({chain:n})=>n().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),H1=ie.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:n}){return["ul",K(this.options.HTMLAttributes,n,{"data-type":this.name}),0]},addCommands(){return{toggleTaskList:()=>({commands:n})=>n.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}}),_1=/^\s*(\[([( |x])?\])\s$/,F1=ie.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:n=>{const e=n.getAttribute("data-checked");return e===""||e==="true"},renderHTML:n=>({"data-checked":n.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:n,HTMLAttributes:e}){return["li",K(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:n.attrs.checked?"checked":null}],["span"]],["div",0]]},addKeyboardShortcuts(){const n={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...n,Tab:()=>this.editor.commands.sinkListItem(this.name)}:n},addNodeView(){return({node:n,HTMLAttributes:e,getPos:t,editor:r})=>{const s=document.createElement("li"),i=document.createElement("label"),o=document.createElement("span"),l=document.createElement("input"),a=document.createElement("div"),c=()=>{var u,d;l.ariaLabel=((d=(u=this.options.a11y)===null||u===void 0?void 0:u.checkboxLabel)===null||d===void 0?void 0:d.call(u,n,l.checked))||`Task item checkbox for ${n.textContent||"empty task item"}`};return c(),i.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",u=>u.preventDefault()),l.addEventListener("change",u=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}const{checked:d}=u.target;r.isEditable&&typeof t=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:f})=>{const h=t();if(typeof h!="number")return!1;const p=f.doc.nodeAt(h);return f.setNodeMarkup(h,void 0,{...p?.attrs,checked:d}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(n,d)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([u,d])=>{s.setAttribute(u,d)}),s.dataset.checked=n.attrs.checked,l.checked=n.attrs.checked,i.append(l,o),s.append(i,a),Object.entries(e).forEach(([u,d])=>{s.setAttribute(u,d)}),{dom:s,contentDOM:a,update:u=>u.type!==this.type?!1:(s.dataset.checked=u.attrs.checked,l.checked=u.attrs.checked,c(),!0)}}},addInputRules(){return[Cn({find:_1,type:this.type,getAttributes:n=>({checked:n[n.length-1]==="x"})})]}}),$1=le.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new se({key:new ae("placeholder"),props:{decorations:({doc:n,selection:e})=>{const t=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,s=[];if(!t)return null;const i=this.editor.isEmpty;return n.descendants((o,l)=>{const a=r>=l&&r<=l+o.nodeSize,c=!o.isLeaf&&Vs(o);if((a||!this.options.showOnlyCurrent)&&c){const u=[this.options.emptyNodeClass];i&&u.push(this.options.emptyEditorClass);const d=ye.node(l,l+o.nodeSize,{class:u.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:o,pos:l,hasAnchor:a}):this.options.placeholder});s.push(d)}return this.options.includeChildren}),ee.create(n,s)}}})]}}),V1=le.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:n=>n.length,wordCounter:n=>n.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=n=>{const e=n?.node||this.editor.state.doc;if((n?.mode||this.options.mode)==="textSize"){const r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=n=>{const e=n?.node||this.editor.state.doc,t=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(t)}},addProseMirrorPlugins(){let n=!1;return[new se({key:new ae("characterCount"),appendTransaction:(e,t,r)=>{if(n)return;const s=this.options.limit;if(s==null||s===0){n=!0;return}const i=this.storage.characters({node:r.doc});if(i>s){const o=i-s,l=0,a=o;console.warn(`[CharacterCount] Initial content exceeded limit of ${s} characters. Content was automatically trimmed.`);const c=r.tr.deleteRange(l,a);return n=!0,c}n=!0},filterTransaction:(e,t)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const s=this.storage.characters({node:t.doc}),i=this.storage.characters({node:e.doc});if(i<=r||s>r&&i>r&&i<=s)return!0;if(s>r&&i>r&&i>s||!e.getMeta("paste"))return!1;const l=e.selection.$head.pos,a=i-r,c=l-a,u=l;return e.deleteRange(c,u),!(this.storage.characters({node:e.doc})>r)}})]}});class W1 extends S.Component{mathFieldRef;cleanup;mounted=!1;constructor(e){super(e),this.mathFieldRef=S.createRef()}async componentDidMount(){if(this.mounted=!0,!(typeof window>"u"))try{const e=await import("mathlive");customElements.get("math-field")||customElements.define("math-field",e.MathfieldElement),e.MathfieldElement&&(e.MathfieldElement.fontsDirectory=null),this.mounted&&this.setupMathField()}catch(e){console.error("Failed to load MathLive:",e)}}componentDidUpdate(e){e.node.attrs.latex!==this.props.node.attrs.latex&&this.updateMathField()}componentWillUnmount(){this.mounted=!1,this.cleanupMathField()}setupMathField(){const e=this.mathFieldRef.current;if(!e)return;requestAnimationFrame(()=>{if(e.isConnected)try{e.value=this.props.node.attrs.latex||"",e.readOnly=!0}catch(r){console.error("Error setting up math field:",r)}}),this.cleanup=()=>{try{e.isConnected&&(e.menuItems=[])}catch{}}}updateMathField(){const e=this.mathFieldRef.current;if(!(!e||!e.isConnected))try{e.value!==(this.props.node.attrs.latex||"")&&(e.value=this.props.node.attrs.latex||"")}catch(t){console.error("Error updating math field:",t)}}cleanupMathField(){this.cleanup?.()}render(){const{node:e,selected:t}=this.props,{displayMode:r,latex:s}=e.attrs;return m.jsx(Uo,{as:"span",className:`math-node-wrapper ${r?"math-node-wrapper-block":"math-node-wrapper-inline"} ${t?"is-selected":""}`,"data-latex":s,"data-display-mode":r?"true":void 0,"data-drag-handle":"",children:S.createElement("math-field",{ref:this.mathFieldRef,className:"math-field-display",readOnly:!0,contentEditable:!1})})}}const qd=ie.create({name:"math",group:"inline",inline:!0,atom:!0,selectable:!0,draggable:!0,addAttributes(){return{latex:{default:"",parseHTML:n=>n.getAttribute("data-latex")||"",renderHTML:n=>({"data-latex":n.latex||""})},displayMode:{default:!1,parseHTML:n=>n.hasAttribute("data-display-mode")&&n.getAttribute("data-display-mode")!=="false",renderHTML:n=>n.displayMode?{"data-display-mode":"true"}:{}}}},parseHTML(){return[{tag:'span[data-type="math"]'},{tag:'div[data-type="math"]'}]},renderHTML({HTMLAttributes:n,node:e}){const t=!!e?.attrs?.displayMode,r=e?.attrs?.latex||"";return["span",{...n,"data-type":"math","data-latex":r,...t?{"data-display-mode":"true"}:{},class:t?"math-node-wrapper math-node-wrapper-block":"math-node-wrapper math-node-wrapper-inline"},r]},addNodeView(){return Ko(W1)}});function pc(n){return n.replace(/[-\/\\^$*+?.()|\[\]{}]/g,"\\$&")}const Gd=le.create({name:"inlineMath",addOptions(){return{inlineDelimiter:"$",blockDelimiter:"$$"}},addCommands(){return{insertInlineMath:(n,e=!1)=>({commands:t})=>t.insertContent({type:"math",attrs:{latex:n,displayMode:e}})}},addInputRules(){const n=pc(this.options.inlineDelimiter),e=pc(this.options.blockDelimiter);return[new wn({find:new RegExp(`${e}([^$]+)${e}$`),handler:({state:t,range:r,match:s})=>{const i=s[1]?.trim();if(!i)return;const{from:o,to:l}=r,a=t.schema.nodes.math;a&&t.tr.replaceWith(o,l,a.create({latex:i,displayMode:!0}))}}),new wn({find:new RegExp(`(?<!\\$)${n}([^$\\n]+)${n}(?!\\$)$`),handler:({state:t,range:r,match:s})=>{const i=s[1]?.trim();if(!i)return;const{from:o,to:l}=r,a=t.schema.nodes.math;a&&t.tr.replaceWith(o,l,a.create({latex:i,displayMode:!1}))}})]}}),U1=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,K1=ie.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{}}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:n}){return["img",K(this.options.HTMLAttributes,n)]},addCommands(){return{setImage:n=>({commands:e})=>e.insertContent({type:this.name,attrs:n})}},addInputRules(){return[rd({find:U1,type:this.type,getAttributes:n=>{const[,,e,t,r]=n;return{src:t,alt:e,title:r}}})]}}),q1={minHeight:"300px",maxHeight:"800px",placeholder:"Start typing...",autoFocus:!1,showCharacterCount:!0,showTableControls:!0},G1={inline:"$",block:"$$"},J1={bold:"Mod-b",italic:"Mod-i",underline:"Mod-u",strike:"Mod-Shift-x",code:"Mod-e",undo:"Mod-z",redo:"Mod-Shift-z",save:"Mod-s",link:"Mod-k",math:"Mod-m"},Jd=["image/jpeg","image/jpg","image/png","image/gif","image/webp","image/svg+xml"],As={image:5*1024*1024,video:50*1024*1024},al={maxCharacters:1e5,maxImages:50,maxTables:20,maxMathEquations:200},Y1=["#000000","#ffffff","#ef4444","#f97316","#f59e0b","#eab308","#84cc16","#22c55e","#10b981","#14b8a6","#06b6d4","#0ea5e9","#3b82f6","#6366f1","#8b5cf6","#a855f7","#d946ef","#ec4899","#f43f5e"],X1=[{label:"Default",value:""},{label:"Arial",value:"Arial, sans-serif"},{label:"Times New Roman",value:"Times New Roman, serif"},{label:"Courier New",value:"Courier New, monospace"},{label:"Georgia",value:"Georgia, serif"},{label:"Verdana",value:"Verdana, sans-serif"},{label:"Trebuchet",value:"Trebuchet MS, sans-serif"}],Q1=[{label:"8",value:"8px"},{label:"10",value:"10px"},{label:"12",value:"12px"},{label:"14",value:"14px"},{label:"16",value:"16px"},{label:"18",value:"18px"},{label:"20",value:"20px"},{label:"24",value:"24px"},{label:"28",value:"28px"},{label:"32",value:"32px"},{label:"36",value:"36px"},{label:"48",value:"48px"},{label:"64",value:"64px"}],Z1=[1,2,3,4,5,6],ek={base:1,dropdown:10,toolbar:50,modal:100,tooltip:150,notification:200};function Yd(n){const e={};for(const r of Array.from(n.attributes))e[r.name]=r.value;const t=[];return n.childNodes.forEach(r=>{if(r.nodeType===Node.TEXT_NODE){const s=r.textContent;s&&t.push(s);return}r.nodeType===Node.ELEMENT_NODE&&t.push(Yd(r))}),t.length===0?[n.tagName,e]:[n.tagName,e,...t]}function Rr(n){if(!n||/%\s*$/.test(n.trim()))return null;const e=n.trim().match(/^([\d.]+)(px|pt)?$/i);if(!e)return null;const t=Number(e[1]);return Number.isFinite(t)&&t>0?t:null}function sn(n){const r=new DOMParser().parseFromString(n,"image/svg+xml").documentElement;if(r.tagName.toLowerCase()!=="svg")throw new Error("Not valid SVG markup");if(r.getAttribute("xmlns")||r.setAttribute("xmlns","http://www.w3.org/2000/svg"),!(r.hasAttribute("viewBox")||r.hasAttribute("viewbox"))){let i=Rr(r.getAttribute("width")),o=Rr(r.getAttribute("height"));if(!i||!o){const l=r.querySelector(":scope > svg");if(l){const a=l.getAttribute("viewBox")||l.getAttribute("viewbox");if(a){const c=a.trim().split(/[\s,]+/).map(Number);c.length===4&&c[2]>0&&c[3]>0&&(i=i||c[2],o=o||c[3])}(!i||!o)&&(i=i||Rr(l.getAttribute("width")),o=o||Rr(l.getAttribute("height")))}}i&&o&&r.setAttribute("viewBox",`0 0 ${i} ${o}`)}return r.getAttribute("preserveAspectRatio")||r.setAttribute("preserveAspectRatio","xMidYMid meet"),r.removeAttribute("width"),r.removeAttribute("height"),new XMLSerializer().serializeToString(r)}function tk(n){const e=sn(n),s=new DOMParser().parseFromString(e,"image/svg+xml").documentElement;if(s.tagName.toLowerCase()!=="svg")throw new Error("Not valid SVG markup");return Yd(s)}function nk(n){let e=null;if(n.tagName.toLowerCase()==="svg"?e=n.outerHTML:e=n.querySelector("svg")?.outerHTML??null,!e)return null;try{return sn(e)}catch{return e}}function Kn(n){if(!n.startsWith("data:image/svg+xml"))return null;const e=n.indexOf(",");if(e===-1)return null;const t=n.slice(0,e),r=n.slice(e+1);try{const s=t.includes(";base64")?atob(r):decodeURIComponent(r);try{return sn(s)}catch{return s}}catch{return null}}const rk=/\.(jpe?g|png|gif|webp|svg)$/i;function Ns(n){return Jd.includes(n.type)?!0:rk.test(n.name)}function Xd(n){return n.type==="image/svg+xml"||n.type==="image/svg"||/\.svg$/i.test(n.name)}function Os(n){return n?n.startsWith("data:image/svg+xml")||n.includes("image/svg+xml")||/\.svg(\?|#|$)/i.test(n):!1}function dr(n){const e=n.trim();return/^<\?xml[\s\S]*<svg[\s>]/i.test(e)||/^<svg[\s>]/i.test(e)}function Tn(n){let e=n.trim();if(!dr(e))throw new Error("Not valid SVG markup");e=e.replace(/<\?xml[\s\S]*?\?>/gi,"").trim(),e=e.replace(/<!DOCTYPE[\s\S]*?>/gi,"").trim(),e=e.replace(/<script[\s\S]*?<\/script>/gi,""),e=e.replace(/<foreignObject[\s\S]*?<\/foreignObject>/gi,""),e=e.replace(/\son[a-z]+\s*=\s*("[^"]*"|'[^']*'|[^\s>]+)/gi,""),e=e.replace(/(href|xlink:href)\s*=\s*("|')\s*javascript:[^"']*\2/gi,"$1=$2#$2"),/\sxmlns\s*=/.test(e)||(e=e.replace(/<svg\b/i,'<svg xmlns="http://www.w3.org/2000/svg"'));try{return sn(e)}catch{return e}}function sk(n){const e=Tn(n);return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`}function ik(n){return new Promise((e,t)=>{const r=new FileReader;r.onload=()=>{try{e(Tn(String(r.result)))}catch(s){t(s instanceof Error?s:new Error("Invalid SVG file"))}},r.onerror=()=>t(new Error(`Failed to read ${n.name}`)),r.readAsText(n)})}const cl="image/jpeg,image/jpg,image/png,image/gif,image/webp,image/svg+xml,.svg,.jpg,.jpeg,.png,.gif,.webp",ok="image/svg+xml,.svg";function lk(n){if(n.size>As.image)throw new Error(`"${n.name}" is too large (max ${Math.round(As.image/(1024*1024))}MB)`)}function Qd(n){return new Promise((e,t)=>{const r=new FileReader;r.onload=()=>e(String(r.result)),r.onerror=()=>t(new Error(`Failed to read ${n.name}`)),r.readAsDataURL(n)})}async function tn(n){const e=Array.from(n),t=[];for(const r of e){if(!Ns(r))throw new Error(`Unsupported format: ${r.name}`);if(lk(r),Xd(r)){const i=await ik(r);t.push({src:"",alt:r.name.replace(/\.[^.]+$/,""),isSvg:!0,svgContent:i});continue}const s=await Qd(r);t.push({src:s,alt:r.name.replace(/\.[^.]+$/,""),isSvg:!1})}return t}const On=80,ak=({node:n,updateAttributes:e,selected:t})=>{const r=S.useRef(null),s=S.useMemo(()=>n.attrs.align||"left",[n.attrs.align]),i=S.useMemo(()=>{if(n.attrs.mediaType==="svg"||n.attrs.svgContent)return!0;const u=n.attrs.src||"";return u.startsWith("data:image/svg+xml")||u.includes("image/svg+xml")||/\.svg(\?|#|$)/i.test(u)},[n.attrs.mediaType,n.attrs.src,n.attrs.svgContent]),o=S.useMemo(()=>{let u=null;if(n.attrs.svgContent?u=n.attrs.svgContent:i&&n.attrs.src&&(u=Kn(n.attrs.src)),!u)return null;try{return sn(u)}catch{return u}},[n.attrs.svgContent,n.attrs.src,i]),l=S.useCallback((u,d)=>{u.preventDefault(),u.stopPropagation();const f=parseInt(String(n.attrs.width||"300"),10)||300,h=parseInt(String(n.attrs.height||"200"),10)||200;r.current={startX:u.clientX,startY:u.clientY,startWidth:f,startHeight:h,direction:d,aspectRatio:f/Math.max(h,1)};const p=y=>{const b=r.current;if(!b)return;const x=y.clientX-b.startX,C=y.clientY-b.startY;let k=b.startWidth,M=b.startHeight;b.direction.includes("right")&&(k=Math.max(On,b.startWidth+x)),b.direction.includes("left")&&(k=Math.max(On,b.startWidth-x)),b.direction.includes("bottom")&&(M=Math.max(On,b.startHeight+C)),b.direction.includes("top")&&(M=Math.max(On,b.startHeight-C)),!y.shiftKey&&(b.direction==="bottom-right"||b.direction==="bottom-left"||b.direction==="top-right"||b.direction==="top-left")&&(M=Math.max(On,Math.round(k/b.aspectRatio))),e({width:`${Math.round(k)}px`,height:`${Math.round(M)}px`})},g=()=>{r.current=null,document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",g)};document.addEventListener("mousemove",p),document.addEventListener("mouseup",g)},[n.attrs.width,n.attrs.height,e]),a=u=>{e({align:u})},c=S.useMemo(()=>({textAlign:s==="center"||s==="right"?s:"left",width:"100%",display:"block",margin:"0",padding:"0",boxSizing:"border-box"}),[s]);return m.jsx(Uo,{className:`resizable-image-wrapper resizable-image-wrapper-align-${s}${i?" is-svg":""} ${t?"ProseMirror-selectednode":""}`,style:c,"data-align":s,"data-media-type":i?"svg":"image",children:m.jsxs("div",{className:`resizable-image-container align-${s}${i?" is-svg":""}`,style:{width:i?"100%":n.attrs.width||"auto",maxWidth:"100%",height:i?"auto":n.attrs.height||"auto",display:i?"block":"inline-block",position:"relative"},children:[i&&m.jsx("span",{className:"svg-badge",children:"SVG"}),o?m.jsx("div",{className:"inline-svg-host",style:{display:"block",width:"100%",maxWidth:"100%",height:"auto",userSelect:"none"},dangerouslySetInnerHTML:{__html:o},"aria-label":n.attrs.alt||"SVG figure"}):m.jsx("img",{src:n.attrs.src,alt:n.attrs.alt||(i?"SVG figure":""),title:n.attrs.title||"",width:i?void 0:n.attrs.width,height:i?void 0:n.attrs.height,draggable:!1,style:{display:"block",maxWidth:"100%",width:i?"100%":void 0,height:"auto",userSelect:"none"}}),t&&!i&&m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"resize-handle resize-handle-bottom-right",onMouseDown:u=>l(u,"bottom-right"),"aria-hidden":"true"}),m.jsx("div",{className:"resize-handle resize-handle-bottom-left",onMouseDown:u=>l(u,"bottom-left"),"aria-hidden":"true"}),m.jsx("div",{className:"resize-handle resize-handle-top-right",onMouseDown:u=>l(u,"top-right"),"aria-hidden":"true"}),m.jsx("div",{className:"resize-handle resize-handle-top-left",onMouseDown:u=>l(u,"top-left"),"aria-hidden":"true"})]}),t&&m.jsxs("div",{className:"alignment-controls",role:"group","aria-label":"Image alignment",children:[m.jsx("button",{onClick:()=>a("left"),className:s==="left"?"is-active":"",type:"button","aria-label":"Align left","aria-pressed":s==="left",children:"←"}),m.jsx("button",{onClick:()=>a("center"),className:s==="center"?"is-active":"",type:"button","aria-label":"Align center","aria-pressed":s==="center",children:"⟷"}),m.jsx("button",{onClick:()=>a("right"),className:s==="right"?"is-active":"",type:"button","aria-label":"Align right","aria-pressed":s==="right",children:"→"})]})]})})};function ck(n){let e=null;if(n.svgContent?e=n.svgContent:n.mediaType==="svg"&&n.src&&(e=Kn(n.src)),!e)return null;try{return sn(e)}catch{return e}}const Zd=K1.extend({addAttributes(){return{...this.parent?.(),width:{default:"500px",renderHTML:n=>({width:n.width})},height:{default:"auto",renderHTML:n=>({height:n.height})},align:{default:"left",renderHTML:n=>({"data-align":n.align}),parseHTML:n=>n.getAttribute("data-align")||"left"},svgContent:{default:null,parseHTML:n=>{if(typeof n=="string")return null;const e=n,t=e.closest(".resizable-image-wrapper")||e;return nk(t)},renderHTML:()=>({})},mediaType:{default:"image",parseHTML:n=>{const e=n.getAttribute("data-media-type");if(e==="svg"||e==="image")return e;const t=n.getAttribute("src")||"";return n.closest(".resizable-image-wrapper.is-svg")||n.querySelector("svg")||n.tagName.toLowerCase()==="svg"||t.startsWith("data:image/svg+xml")||t.includes("image/svg+xml")||/\.svg(\?|#|$)/i.test(t)?"svg":"image"},renderHTML:n=>({"data-media-type":n.mediaType||"image"})}}},renderHTML({node:n,HTMLAttributes:e}){const t=n.attrs.align||"left",r=n.attrs.mediaType||"image",s=ck(n.attrs),o={left:"left",center:"center",right:"right"}[t]||"left";if(r==="svg"&&s){const l=tk(s);return["div",{class:`resizable-image-wrapper resizable-image-wrapper-align-${t} is-svg`,style:`text-align: ${o}; width: 100%; display: block;`,"data-align":t,"data-media-type":"svg"},["div",{class:`resizable-image-container align-${t} is-svg`,style:"display: block; width: 100%; max-width: 100%; height: auto;"},l]]}return["div",{class:`resizable-image-wrapper resizable-image-wrapper-align-${t}${r==="svg"?" is-svg":""}`,style:`text-align: ${o}; width: 100%; display: block;`,"data-align":t,"data-media-type":r},["div",{class:`resizable-image-container align-${t}${r==="svg"?" is-svg":""}`,style:`display: inline-block; width: ${n.attrs.width||"500px"}; height: ${n.attrs.height||"auto"};`},["img",K(e,{src:n.attrs.src,alt:n.attrs.alt||"",title:n.attrs.title||"",width:n.attrs.width,height:n.attrs.height,"data-align":t,"data-media-type":r})]]]},parseHTML(){const n=(t,r)=>{let s="left";if(r){const a=r.getAttribute("data-align")||t.getAttribute("data-align");if(a)s=a;else if(typeof window<"u"){const u=window.getComputedStyle(r).textAlign;u==="center"?s="center":u==="right"&&(s="right")}}else{const a=t.getAttribute("data-align");a&&(s=a)}const i=t.getAttribute("src")||"",o=t.getAttribute("data-media-type")||r?.getAttribute("data-media-type"),l=o==="svg"||o==="image"?o:i.startsWith("data:image/svg+xml")||/\.svg(\?|#|$)/i.test(i)?"svg":"image";return{src:i,alt:t.getAttribute("alt"),title:t.getAttribute("title"),width:t.getAttribute("width")||"500px",height:t.getAttribute("height")||"auto",align:s,mediaType:l,svgContent:null}},e=t=>{const r=t.querySelector("svg");if(!r)return!1;const s=t.getAttribute("data-align")||"left",i=r.getAttribute("width")||"auto",o=r.getAttribute("height")||"auto";return{src:"",alt:r.getAttribute("aria-label")||"SVG figure",title:r.getAttribute("title"),width:i,height:o,align:s,mediaType:"svg",svgContent:r.outerHTML}};return[{tag:"div.resizable-image-wrapper.is-svg",getAttrs:t=>{if(typeof t=="string")return!1;const r=t,s=e(r);if(s)return s;const i=r.querySelector("img");if(!i)return!1;const o=n(i,r);return o.mediaType==="svg"&&o.src&&(o.svgContent=Kn(o.src)),o}},{tag:"img[src]",getAttrs:t=>{if(typeof t=="string")return!1;const r=t,s=r.closest(".resizable-image-wrapper")||r.parentElement,i=n(r,s);return i.mediaType==="svg"&&i.src&&(i.svgContent=Kn(i.src)),i}},{tag:"div.resizable-image-wrapper img",getAttrs:t=>{if(typeof t=="string")return!1;const r=t,s=r.closest(".resizable-image-wrapper"),i=n(r,s);return i.mediaType==="svg"&&i.src&&(i.svgContent=Kn(i.src)),i}}]},addNodeView(){return Ko(ak)}}),ef=ie.create({name:"imageGroup",group:"block",content:"image+",addAttributes(){return{align:{default:"left",parseHTML:n=>n.getAttribute("data-align")||"left",renderHTML:n=>({"data-align":n.align||"left"})}}},renderHTML({node:n,HTMLAttributes:e}){const t=n.attrs.align||"left",s={left:"flex-start",center:"center",right:"flex-end"}[t]||"flex-start";return["div",K(e,{"data-type":"image-group","data-align":t,class:"image-group",style:`display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: ${s}`}),0]},parseHTML(){return[{tag:'div[data-type="image-group"]',getAttrs:n=>{if(typeof n=="string")return!1;const e=n,t=e.getAttribute("data-align");if(t==="center"||t==="right"||t==="left")return{align:t};const r=e.style.justifyContent;return r==="center"?{align:"center"}:r==="flex-end"||r==="right"?{align:"right"}:{align:"left"}}}]}});function uk(...n){return n.filter(Boolean).join(" ")||void 0}const tf=Se.create({name:"customTextStyle",addOptions(){return{HTMLAttributes:{}}},addAttributes(){return{fontSize:{default:null,parseHTML:n=>n.style.fontSize?.replace(/\s*!important/gi,"")||null,renderHTML:n=>n.fontSize?{style:`font-size: ${n.fontSize}`}:{}},color:{default:null,parseHTML:n=>n.style.color||null,renderHTML:n=>n.color?{style:`color: ${n.color}`}:{}},fontFamily:{default:null,parseHTML:n=>n.style.fontFamily||null,renderHTML:n=>n.fontFamily?{style:`font-family: ${n.fontFamily}`}:{}}}},parseHTML(){return[{tag:"span[style]",getAttrs:n=>{if(typeof n=="string")return!1;const e=n,t=e.style.fontSize||null,r=e.style.color||null,s=e.style.fontFamily||null;return!t&&!r&&!s?!1:{fontSize:t?.replace(/\s*!important/gi,"")||null,color:r,fontFamily:s}}}]},renderHTML({HTMLAttributes:n}){const{style:e,...t}=n,r=uk(e);return["span",K(this.options.HTMLAttributes,t,r?{style:r}:{}),0]},addCommands(){return{setCustomTextStyle:n=>({commands:e})=>e.setMark(this.name,n),unsetCustomTextStyle:()=>({commands:n})=>n.unsetMark(this.name)}}}),nf=Se.create({name:"backgroundColor",addOptions(){return{HTMLAttributes:{}}},addAttributes(){return{backgroundColor:{default:null,parseHTML:n=>n.style.backgroundColor||null,renderHTML:n=>n.backgroundColor?{style:`background-color: ${n.backgroundColor}`}:{}}}},parseHTML(){return[{style:"background-color"}]},renderHTML({HTMLAttributes:n}){return["span",K(this.options.HTMLAttributes,n),0]},addCommands(){return{setBackgroundColor:n=>({commands:e})=>e.setMark(this.name,{backgroundColor:n}),unsetBackgroundColor:()=>({commands:n})=>n.unsetMark(this.name)}}}),dk=/^((?:https?:)?\/\/)?((?:www|m|music)\.)?((?:youtube\.com|youtu\.be|youtube-nocookie\.com))(\/(?:[\w-]+\?v=|embed\/|v\/)?)([\w-]+)(\S+)?$/,fk=/^((?:https?:)?\/\/)?((?:www|m|music)\.)?((?:youtube\.com|youtu\.be|youtube-nocookie\.com))(\/(?:[\w-]+\?v=|embed\/|v\/)?)([\w-]+)(\S+)?$/g,rf=n=>n.match(dk),hk=(n,e)=>e?"https://www.youtube-nocookie.com/embed/videoseries?list=":n?"https://www.youtube-nocookie.com/embed/":"https://www.youtube.com/embed/",pk=n=>n.searchParams.has("v")?{id:n.searchParams.get("v")}:n.hostname==="youtu.be"||n.pathname.includes("shorts")||n.pathname.includes("live")?{id:n.pathname.split("/").pop()}:n.searchParams.has("list")?{id:n.searchParams.get("list"),isPlaylist:!0}:null,mk=n=>{var e;const{url:t,allowFullscreen:r,autoplay:s,ccLanguage:i,ccLoadPolicy:o,controls:l,disableKBcontrols:a,enableIFrameApi:c,endTime:u,interfaceLanguage:d,ivLoadPolicy:f,loop:h,modestBranding:p,nocookie:g,origin:y,playlist:b,progressBarColor:x,startAt:C,rel:k}=n;if(!rf(t))return null;if(t.includes("/embed/"))return t;const M=new URL(t),{id:R,isPlaylist:z}=(e=pk(M))!==null&&e!==void 0?e:{};if(!R)return null;const w=new URL(`${hk(g,z)}${R}`);return M.searchParams.has("t")&&w.searchParams.set("start",M.searchParams.get("t").replaceAll("s","")),r===!1&&w.searchParams.set("fs","0"),s&&w.searchParams.set("autoplay","1"),i&&w.searchParams.set("cc_lang_pref",i),o&&w.searchParams.set("cc_load_policy","1"),l||w.searchParams.set("controls","0"),a&&w.searchParams.set("disablekb","1"),c&&w.searchParams.set("enablejsapi","1"),u&&w.searchParams.set("end",u.toString()),d&&w.searchParams.set("hl",d),f&&w.searchParams.set("iv_load_policy",f.toString()),h&&w.searchParams.set("loop","1"),p&&w.searchParams.set("modestbranding","1"),y&&w.searchParams.set("origin",y),b&&w.searchParams.set("playlist",b),C&&w.searchParams.set("start",C.toString()),x&&w.searchParams.set("color",x),k!==void 0&&w.searchParams.set("rel",k.toString()),w.toString()},gk=ie.create({name:"youtube",addOptions(){return{addPasteHandler:!0,allowFullscreen:!0,autoplay:!1,ccLanguage:void 0,ccLoadPolicy:void 0,controls:!0,disableKBcontrols:!1,enableIFrameApi:!1,endTime:0,height:480,interfaceLanguage:void 0,ivLoadPolicy:0,loop:!1,modestBranding:!1,HTMLAttributes:{},inline:!1,nocookie:!1,origin:"",playlist:"",progressBarColor:void 0,width:640,rel:1}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},start:{default:0},width:{default:this.options.width},height:{default:this.options.height}}},parseHTML(){return[{tag:"div[data-youtube-video] iframe"}]},addCommands(){return{setYoutubeVideo:n=>({commands:e})=>rf(n.src)?e.insertContent({type:this.name,attrs:n}):!1}},addPasteRules(){return this.options.addPasteHandler?[Ly({find:fk,type:this.type,getAttributes:n=>({src:n.input})})]:[]},renderHTML({HTMLAttributes:n}){const e=mk({url:n.src,allowFullscreen:this.options.allowFullscreen,autoplay:this.options.autoplay,ccLanguage:this.options.ccLanguage,ccLoadPolicy:this.options.ccLoadPolicy,controls:this.options.controls,disableKBcontrols:this.options.disableKBcontrols,enableIFrameApi:this.options.enableIFrameApi,endTime:this.options.endTime,interfaceLanguage:this.options.interfaceLanguage,ivLoadPolicy:this.options.ivLoadPolicy,loop:this.options.loop,modestBranding:this.options.modestBranding,nocookie:this.options.nocookie,origin:this.options.origin,playlist:this.options.playlist,progressBarColor:this.options.progressBarColor,startAt:n.start||0,rel:this.options.rel});return n.src=e,["div",{"data-youtube-video":""},["iframe",K(this.options.HTMLAttributes,{width:this.options.width,height:this.options.height,allowfullscreen:this.options.allowFullscreen,autoplay:this.options.autoplay,ccLanguage:this.options.ccLanguage,ccLoadPolicy:this.options.ccLoadPolicy,disableKBcontrols:this.options.disableKBcontrols,enableIFrameApi:this.options.enableIFrameApi,endTime:this.options.endTime,interfaceLanguage:this.options.interfaceLanguage,ivLoadPolicy:this.options.ivLoadPolicy,loop:this.options.loop,modestBranding:this.options.modestBranding,origin:this.options.origin,playlist:this.options.playlist,progressBarColor:this.options.progressBarColor,rel:this.options.rel},n)]]}}),mc=200,gc=150,yk=({node:n,updateAttributes:e,selected:t})=>{const r=S.useRef(null),s=S.useCallback((l,a)=>{l.preventDefault(),l.stopPropagation(),r.current={startX:l.clientX,startY:l.clientY,startWidth:parseInt(String(n.attrs.width),10)||640,startHeight:parseInt(String(n.attrs.height),10)||360,direction:a};const c=d=>{const f=r.current;if(!f)return;const h=d.clientX-f.startX,p=d.clientY-f.startY;let g=f.startWidth,y=f.startHeight;f.direction.includes("right")&&(g=Math.max(mc,f.startWidth+h)),f.direction.includes("left")&&(g=Math.max(mc,f.startWidth-h)),f.direction.includes("bottom")&&(y=Math.max(gc,f.startHeight+p)),f.direction.includes("top")&&(y=Math.max(gc,f.startHeight-p)),e({width:`${Math.round(g)}px`,height:`${Math.round(y)}px`})},u=()=>{r.current=null,document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",u)};document.addEventListener("mousemove",c),document.addEventListener("mouseup",u)},[n.attrs.width,n.attrs.height,e]),i=l=>{e({align:l})},o=n.attrs.align||"center";return m.jsx(Uo,{className:`resizable-youtube-wrapper ${t?"ProseMirror-selectednode":""}`,style:{textAlign:o,position:"relative",display:"block",width:"100%"},"data-align":o,children:m.jsxs("div",{className:"resizable-youtube-container",style:{position:"relative",display:"inline-block",width:n.attrs.width,height:n.attrs.height,maxWidth:"100%"},children:[m.jsx("iframe",{src:n.attrs.src,width:n.attrs.width,height:n.attrs.height,title:"YouTube video",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,style:{display:"block",width:"100%",height:"100%",border:0}}),t&&m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"resize-handle resize-handle-bottom-right",onMouseDown:l=>s(l,"bottom-right"),"aria-hidden":"true"}),m.jsx("div",{className:"resize-handle resize-handle-bottom-left",onMouseDown:l=>s(l,"bottom-left"),"aria-hidden":"true"}),m.jsx("div",{className:"resize-handle resize-handle-top-right",onMouseDown:l=>s(l,"top-right"),"aria-hidden":"true"}),m.jsx("div",{className:"resize-handle resize-handle-top-left",onMouseDown:l=>s(l,"top-left"),"aria-hidden":"true"}),m.jsxs("div",{className:"alignment-controls",role:"group","aria-label":"Video alignment",children:[m.jsx("button",{onClick:()=>i("left"),className:o==="left"?"is-active":"",type:"button","aria-label":"Align left","aria-pressed":o==="left",children:"←"}),m.jsx("button",{onClick:()=>i("center"),className:o==="center"?"is-active":"",type:"button","aria-label":"Align center","aria-pressed":o==="center",children:"⟷"}),m.jsx("button",{onClick:()=>i("right"),className:o==="right"?"is-active":"",type:"button","aria-label":"Align right","aria-pressed":o==="right",children:"→"})]})]})]})})},sf=gk.extend({addAttributes(){return{...this.parent?.(),width:{default:"640px",renderHTML:n=>({width:n.width})},height:{default:"360px",renderHTML:n=>({height:n.height})},align:{default:"center",renderHTML:n=>({"data-align":n.align}),parseHTML:n=>n.getAttribute("data-align")||"center"}}},addNodeView(){return Ko(yk)}}),bk=xl.createLowlight(xl.common);function Oi(n,e){const t=n.state.schema.nodes.image;if(!t||e.length===0)return;let r=n.state.tr;if(e.length===1){const s=e[0],i=t.create({src:s.src,alt:s.alt||"",width:s.width||(s.mediaType==="svg"?"auto":"500px"),height:"auto",mediaType:s.mediaType||"image",svgContent:s.svgContent||null});r=r.replaceSelectionWith(i)}else{const s=n.state.schema.nodes.imageGroup,i=e.map(o=>t.create({src:o.src,alt:o.alt||"",width:"250px",height:"auto",mediaType:o.mediaType||"image",svgContent:o.svgContent||null}));if(s)r=r.replaceSelectionWith(s.create(null,i));else for(const o of i)r=r.replaceSelectionWith(o).scrollIntoView()}n.dispatch(r.scrollIntoView())}function of(n={}){const{placeholder:e="Start typing...",characterLimit:t=al.maxCharacters}=n;return[Xb.configure({heading:{levels:[1,2,3,4,5,6]},codeBlock:!1,blockquote:!1,horizontalRule:!1,hardBreak:!1,strike:!1,dropcursor:!1,gapcursor:!1}),ld.configure({color:"#3b82f6",width:2}),ad,qd,Gd,Zd.configure({allowBase64:!0}),ef,B1,z1,nf,H1.configure({HTMLAttributes:{class:"editor-task-list"}}),F1.configure({nested:!0,HTMLAttributes:{class:"editor-task-item"}}),ex.configure({resizable:!0,HTMLAttributes:{class:"editor-table"}}),tx,nx,rx,Nx.configure({openOnClick:!1,autolink:!0,linkOnPaste:!0,HTMLAttributes:{class:"editor-link",rel:"noopener noreferrer nofollow",target:"_blank"}}),Ox.configure({types:["heading","paragraph"],alignments:["left","center","right","justify"]}),Dx.configure({multicolor:!1}),Ix,Px,jx,P1.configure({lowlight:bk,HTMLAttributes:{class:"editor-code-block"}}),sf.configure({controls:!0,nocookie:!0,modestBranding:!0}),$1.configure({placeholder:e,emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty"}),V1.configure({limit:t}),id.configure({HTMLAttributes:{class:"editor-blockquote"}}),pd,cd,md,tf.configure({HTMLAttributes:{class:"editor-text-style"}})]}function lf({className:n="",placeholder:e="Start typing..."}){return{attributes:{class:`prose focus:outline-none ${n}`.trim(),"aria-label":"Rich text editor content","aria-placeholder":e,spellcheck:"true"},handlePaste:(t,r)=>{const s=r.clipboardData;if(!s)return!1;const i=Array.from(s.files||[]).filter(Ns);if(i.length>0)return r.preventDefault(),tn(i).then(l=>{Oi(t,l.map(a=>({src:a.src,alt:a.alt,mediaType:a.isSvg?"svg":"image",svgContent:a.svgContent})))}).catch(l=>{console.error("Paste image/SVG failed:",l)}),!0;const o=s.getData("text/plain");if(o&&dr(o)){r.preventDefault();try{const l=Tn(o);Oi(t,[{src:"",alt:"SVG figure",mediaType:"svg",width:"auto",svgContent:l}])}catch(l){return console.error("Paste SVG markup failed:",l),!1}return!0}return!1},handleDrop:(t,r)=>{const s=Array.from(r.dataTransfer?.files||[]).filter(Ns);return s.length?(r.preventDefault(),tn(s).then(i=>{Oi(t,i.map(o=>({src:o.src,alt:o.alt,mediaType:o.isSvg?"svg":"image",svgContent:o.svgContent})))}).catch(i=>{console.error("Drop image/SVG failed:",i)}),!0):!1}}}function af(n){if(!n||n.trim()==="")return{isValid:!1,error:"LaTeX expression cannot be empty"};let e=0,t=0;for(let r=0;r<n.length;r++){const s=n[r];if(n[r-1]!=="\\"){if(s==="{"&&e++,s==="}"&&e--,s==="["&&t++,s==="]"&&t--,e<0)return{isValid:!1,error:"Unbalanced braces"};if(t<0)return{isValid:!1,error:"Unbalanced brackets"}}}return e!==0?{isValid:!1,error:"Unbalanced braces"}:t!==0?{isValid:!1,error:"Unbalanced brackets"}:{isValid:!0}}function xk(n){if(typeof document>"u")return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'");const e=document.createElement("div");return e.textContent=n,e.innerHTML}function cf(n){if(typeof document>"u")return n.replace(/<[^>]*>/g," ").replace(/\s+/g," ").trim();const e=document.createElement("div");return e.innerHTML=n,e.textContent||e.innerText||""}function kk(n){return n.trim().split(/\s+/).filter(Boolean).length}function uf(n){if(!Number.isFinite(n)||n<0||n===0)return"0 Bytes";const e=1024,t=["Bytes","KB","MB","GB"],r=Math.min(Math.floor(Math.log(n)/Math.log(e)),t.length-1);return`${Math.round(n/Math.pow(e,r)*100)/100} ${t[r]}`}function Sk(n,e){let t=null;return function(...s){const i=()=>{t=null,n(...s)};t&&clearTimeout(t),t=setTimeout(i,e)}}function wk(n,e){let t=!1,r=null;return function(...i){t?r=i:(n(...i),t=!0,setTimeout(()=>{if(t=!1,r){const o=r;r=null,n(...o)}},e))}}function Ck(){const n=[];if(typeof window>"u")return{supported:!1,missingFeatures:["window object"]};window.customElements||n.push("Custom Elements");try{const e="__rle_test__";window.localStorage.setItem(e,e),window.localStorage.removeItem(e)}catch{n.push("Local Storage")}return{supported:n.length===0,missingFeatures:n}}function vk(n){return typeof structuredClone=="function"?structuredClone(n):JSON.parse(JSON.stringify(n))}function Mk(n){return!n||!n.trim()?!0:cf(n).trim().length===0}function Ek(n="rle"){return typeof crypto<"u"&&"randomUUID"in crypto?`${n}-${crypto.randomUUID()}`:`${n}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,11)}`}function df(n){const e=n.trim();return!e||/^(https?:|mailto:|tel:|\/|#)/i.test(e)?e:`https://${e}`}function Tk(n){return typeof n=="number"?`${n}px`:/^\d+$/.test(n)?`${n}px`:n}function Ak(n,e){n&&n.chain().focus().setMark("customTextStyle",{fontSize:Tk(e)}).run()}function Nk(n,e){n&&n.chain().focus().setBackgroundColor(e).run()}function Ok(n,e){if(n){if(!e){n.chain().focus().unsetMark("customTextStyle").run();return}n.chain().focus().setMark("customTextStyle",{fontFamily:e}).run()}}function Rk(n,e=3,t=3,r=!0){n&&n.chain().focus().insertTable({rows:e,cols:t,withHeaderRow:r}).run()}function Lk(n){if(typeof n=="string"){const t=Os(n);return{src:n,alt:"",width:t?"auto":"500px",height:"auto",mediaType:t?"svg":"image"}}const e=n.mediaType==="svg"||Os(n.src)||!!n.svgContent;return{src:n.src,alt:n.alt||"",width:n.width||(e?"auto":"500px"),height:n.height||"auto",mediaType:n.mediaType||(e?"svg":"image"),svgContent:n.svgContent,align:n.align}}function yn(n,e){if(!n)return;const t=(Array.isArray(e)?e:[e]).map(Lk).filter(r=>!!(r.src||r.svgContent));if(t.length!==0){if(t.length>1){const r=t.map(s=>({type:"image",attrs:{src:s.src,alt:s.alt,width:s.mediaType==="svg"?"auto":"250px",height:s.height,mediaType:s.mediaType,svgContent:s.svgContent,align:s.align||"left"}}));n.chain().focus().insertContent([{type:"imageGroup",content:r}]).run();return}n.chain().focus().insertContent({type:"image",attrs:{...t[0],align:t[0].align||"left"}}).run()}}function ul(n,e,t){if(!n)return Promise.reject(new Error("Editor instance is not available"));const r=i=>{yn(n,{...i,alt:i.alt||t?.alt||"SVG figure",width:i.width||"auto",mediaType:"svg"})};if(typeof e!="string")return tn([e]).then(i=>{const o=i[0];if(!o)throw new Error("No SVG file provided");r({src:o.src,svgContent:o.svgContent,alt:o.alt})});const s=e.trim();return s.startsWith("<")||s.includes("<svg")?(r({src:"",svgContent:Tn(s)}),Promise.resolve()):(r({src:s}),Promise.resolve())}async function ff(n,e){if(!n)throw new Error("Editor instance is not available");const t=await tn(e);yn(n,t.map(r=>({src:r.src,alt:r.alt,mediaType:r.isSvg?"svg":"image",svgContent:r.svgContent})))}function hf(n,e,t=!1){if(!n)throw new Error("Editor instance is not available");const r=e.trim(),s=af(r);if(!s.isValid)throw new Error(s.error||"Invalid LaTeX expression");n.chain().focus().insertContent({type:"math",attrs:{latex:r,displayMode:t}}).run()}const W=S.memo(S.forwardRef(({onClick:n,isActive:e,title:t,children:r,shortcut:s,disabled:i},o)=>{const l=s?`${t} (${s})`:t;return m.jsx("button",{ref:o,onClick:n,className:`toolbar-button${e?" is-active":""}${i?" is-disabled":""}`,"aria-label":l,"aria-pressed":e,disabled:i,type:"button",title:l,children:r})}));W.displayName="ToolbarButton";const Dk=({editor:n,readOnly:e})=>m.jsxs("div",{className:"toolbar-group",role:"group","aria-label":"Text alignment",children:[m.jsx(W,{onClick:()=>n?.chain().focus().setTextAlign("left").run(),isActive:n?.isActive({textAlign:"left"}),title:"Align left",disabled:!n||e,children:m.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.25",strokeLinecap:"round",strokeLinejoin:"round",children:[m.jsx("line",{x1:"4",y1:"6",x2:"20",y2:"6"}),m.jsx("line",{x1:"4",y1:"12",x2:"14",y2:"12"}),m.jsx("line",{x1:"4",y1:"18",x2:"18",y2:"18"})]})}),m.jsx(W,{onClick:()=>n?.chain().focus().setTextAlign("center").run(),isActive:n?.isActive({textAlign:"center"}),title:"Align center",disabled:!n||e,children:m.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.25",strokeLinecap:"round",strokeLinejoin:"round",children:[m.jsx("line",{x1:"4",y1:"6",x2:"20",y2:"6"}),m.jsx("line",{x1:"6",y1:"12",x2:"18",y2:"12"}),m.jsx("line",{x1:"8",y1:"18",x2:"16",y2:"18"})]})}),m.jsx(W,{onClick:()=>n?.chain().focus().setTextAlign("right").run(),isActive:n?.isActive({textAlign:"right"}),title:"Align right",disabled:!n||e,children:m.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.25",strokeLinecap:"round",strokeLinejoin:"round",children:[m.jsx("line",{x1:"4",y1:"6",x2:"20",y2:"6"}),m.jsx("line",{x1:"10",y1:"12",x2:"20",y2:"12"}),m.jsx("line",{x1:"6",y1:"18",x2:"20",y2:"18"})]})}),m.jsx(W,{onClick:()=>n?.chain().focus().setTextAlign("justify").run(),isActive:n?.isActive({textAlign:"justify"}),title:"Justify",disabled:!n||e,children:m.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.25",strokeLinecap:"round",strokeLinejoin:"round",children:[m.jsx("line",{x1:"4",y1:"6",x2:"20",y2:"6"}),m.jsx("line",{x1:"4",y1:"12",x2:"20",y2:"12"}),m.jsx("line",{x1:"4",y1:"18",x2:"20",y2:"18"})]})})]}),Ik=({editor:n,readOnly:e})=>m.jsxs("div",{className:"toolbar-group",role:"group","aria-label":"Blocks",children:[m.jsx(W,{onClick:()=>n?.chain().focus().toggleBlockquote().run(),isActive:n?.isActive("blockquote"),title:"Quote",disabled:!n||e,children:m.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.25",strokeLinecap:"round",strokeLinejoin:"round",children:[m.jsx("path",{d:"M3 21c3 0 7-1 7-8V5c0-1.25-.756-2.017-2-2H4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2 1 0 1 0 1 1v1c0 1-1 2-2 2s-1 .008-1 1.031V20c0 1 0 1 1 1z"}),m.jsx("path",{d:"M15 21c3 0 7-1 7-8V5c0-1.25-.757-2.017-2-2h-4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2h.75c0 2.25.25 4-2.75 4v3c0 1 0 1 1 1z"})]})}),m.jsx(W,{onClick:()=>n?.chain().focus().toggleCodeBlock().run(),isActive:n?.isActive("codeBlock"),title:"Code block",disabled:!n||e,children:m.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.25",strokeLinecap:"round",strokeLinejoin:"round",children:[m.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),m.jsx("path",{d:"M8 10l-2 2 2 2"}),m.jsx("path",{d:"M16 10l2 2-2 2"}),m.jsx("path",{d:"M13 9l-2 6"})]})}),m.jsx(W,{onClick:()=>n?.chain().focus().setHorizontalRule().run(),title:"Divider",disabled:!n||e,children:m.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.25",strokeLinecap:"round",strokeLinejoin:"round",children:m.jsx("line",{x1:"4",y1:"12",x2:"20",y2:"12"})})}),m.jsx(W,{onClick:()=>n?.chain().focus().toggleSubscript().run(),isActive:n?.isActive("subscript"),title:"Subscript",disabled:!n||e,children:m.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.25",strokeLinecap:"round",strokeLinejoin:"round",children:[m.jsx("path",{d:"M5 7l8 10m-8 0l8-10"}),m.jsx("path",{d:"M21 20h-4l3.5-4a1.73 1.73 0 0 0-3.5-2"})]})}),m.jsx(W,{onClick:()=>n?.chain().focus().toggleSuperscript().run(),isActive:n?.isActive("superscript"),title:"Superscript",disabled:!n||e,children:m.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.25",strokeLinecap:"round",strokeLinejoin:"round",children:[m.jsx("path",{d:"M5 7l8 10m-8 0l8-10"}),m.jsx("path",{d:"M21 11h-4l3.5-4a1.73 1.73 0 0 0-3.5-2"})]})})]}),Pk=({editor:n,readOnly:e})=>{const t=n?.getAttributes("textStyle")?.color||"#000000",r=n?.getAttributes("backgroundColor")?.backgroundColor||"#ffffff";return m.jsxs("div",{className:"toolbar-group",role:"group","aria-label":"Colors",children:[m.jsxs("label",{className:"toolbar-color",title:"Text color",children:[m.jsxs("span",{className:"toolbar-color-icon","aria-hidden":"true",children:["A",m.jsx("i",{style:{background:t}})]}),m.jsx("input",{type:"color","aria-label":"Text color",disabled:!n||e,value:/^#[0-9A-Fa-f]{6}$/.test(t)?t:"#000000",onChange:s=>n?.chain().focus().setColor(s.target.value).run()})]}),m.jsxs("label",{className:"toolbar-color",title:"Highlight color",children:[m.jsx("span",{className:"toolbar-color-icon toolbar-color-icon-bg","aria-hidden":"true",children:m.jsx("i",{style:{background:r}})}),m.jsx("input",{type:"color","aria-label":"Background color",disabled:!n||e,value:/^#[0-9A-Fa-f]{6}$/.test(r)?r:"#ffffff",onChange:s=>Nk(n,s.target.value)})]})]})},jk=["12px","14px","16px","18px","20px","24px","28px","32px","36px","48px"],Bk=[{name:"Default",value:""},{name:"Arial",value:"Arial, Helvetica, sans-serif"},{name:"Times New Roman",value:"'Times New Roman', Times, serif"},{name:"Georgia",value:"Georgia, serif"},{name:"Courier New",value:"'Courier New', Courier, monospace"},{name:"Verdana",value:"Verdana, Geneva, sans-serif"},{name:"Tahoma",value:"Tahoma, Geneva, sans-serif"},{name:"Trebuchet MS",value:"'Trebuchet MS', Helvetica, sans-serif"},{name:"Roboto",value:"Roboto, Arial, sans-serif"},{name:"Open Sans",value:"'Open Sans', Arial, sans-serif"},{name:"Noto Sans Bengali",value:"'Noto Sans Bengali', 'Noto Sans Bengali UI', 'Noto Sans', sans-serif"},{name:"SolaimanLipi",value:"'SolaimanLipi', 'Noto Sans Bengali', 'Noto Sans', sans-serif"},{name:"Siyam Rupali",value:"'Siyam Rupali', 'Noto Sans Bengali', 'Noto Sans', sans-serif"},{name:"Kalpurush",value:"'Kalpurush', 'Noto Sans Bengali', 'Noto Sans', sans-serif"},{name:"Nikosh",value:"'Nikosh', 'Noto Sans Bengali', 'Noto Sans', sans-serif"}],pf=[1,2,3,4,5,6],mf=768,zk=({editor:n,readOnly:e})=>{const t=n?.getAttributes("customTextStyle")?.fontSize||"",r=n?.getAttributes("customTextStyle")?.fontFamily||"";return m.jsxs("div",{className:"toolbar-group toolbar-font-controls",role:"group","aria-label":"Font",children:[m.jsx("select",{className:"toolbar-select toolbar-select-font","aria-label":"Font family",disabled:!n||e,value:r,onChange:s=>Ok(n,s.target.value),children:Bk.map(s=>m.jsx("option",{value:s.value,children:s.name},s.name))}),m.jsxs("select",{className:"toolbar-select toolbar-select-size","aria-label":"Font size",disabled:!n||e,value:t,onChange:s=>{s.target.value?Ak(n,s.target.value):n?.chain().focus().unsetMark("customTextStyle").run()},children:[m.jsx("option",{value:"",children:"Size"}),jk.map(s=>m.jsx("option",{value:s,children:s.replace("px","")},s))]})]})};function Hk(n){if(!n)return"paragraph";for(const e of pf)if(n.isActive("heading",{level:e}))return String(e);return"paragraph"}const _k=({editor:n,readOnly:e})=>{const t=Hk(n);return m.jsx("div",{className:"toolbar-group",role:"group","aria-label":"Block style",children:m.jsxs("select",{className:"toolbar-select toolbar-select-heading","aria-label":"Text style",disabled:!n||e,value:t,onChange:r=>{if(!n)return;const s=r.target.value;if(s==="paragraph"){n.chain().focus().setParagraph().run();return}n.chain().focus().toggleHeading({level:Number(s)}).run()},children:[m.jsx("option",{value:"paragraph",children:"Paragraph"}),pf.map(r=>m.jsxs("option",{value:r,children:["Heading ",r]},r))]})})},Fk=({editor:n,readOnly:e})=>m.jsxs("div",{className:"toolbar-group",role:"group","aria-label":"History",children:[m.jsx(W,{onClick:()=>n?.chain().focus().undo().run(),title:"Undo",shortcut:"Ctrl+Z",disabled:!n||e||!n.can().undo(),children:m.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.25",strokeLinecap:"round",strokeLinejoin:"round",children:[m.jsx("path",{d:"M3 7v6h6"}),m.jsx("path",{d:"M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6.7 3L3 13"})]})}),m.jsx(W,{onClick:()=>n?.chain().focus().redo().run(),title:"Redo",shortcut:"Ctrl+Shift+Z",disabled:!n||e||!n.can().redo(),children:m.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.25",strokeLinecap:"round",strokeLinejoin:"round",children:[m.jsx("path",{d:"M21 7v6h-6"}),m.jsx("path",{d:"M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6.7 3L21 13"})]})})]}),$k=({editor:n,readOnly:e})=>!n?.isActive("image")||n?.isActive("imageGroup")?null:m.jsxs("div",{className:"toolbar-group",role:"group","aria-label":"Image alignment",children:[m.jsx(W,{onClick:()=>n?.chain().focus().updateAttributes("image",{align:"left"}).run(),isActive:n?.isActive("image",{align:"left"}),title:"Align Image Left",disabled:!n?.isActive("image")||e,children:m.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[m.jsx("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),m.jsx("line",{x1:"3",y1:"12",x2:"15",y2:"12"}),m.jsx("line",{x1:"3",y1:"18",x2:"18",y2:"18"})]})}),m.jsx(W,{onClick:()=>n?.chain().focus().updateAttributes("image",{align:"center"}).run(),isActive:n?.isActive("image",{align:"center"}),title:"Align Image Center",disabled:!n?.isActive("image")||e,children:m.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[m.jsx("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),m.jsx("line",{x1:"6",y1:"12",x2:"18",y2:"12"}),m.jsx("line",{x1:"4",y1:"18",x2:"20",y2:"18"})]})}),m.jsx(W,{onClick:()=>n?.chain().focus().updateAttributes("image",{align:"right"}).run(),isActive:n?.isActive("image",{align:"right"}),title:"Align Image Right",disabled:!n?.isActive("image")||e,children:m.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[m.jsx("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),m.jsx("line",{x1:"9",y1:"12",x2:"21",y2:"12"}),m.jsx("line",{x1:"6",y1:"18",x2:"21",y2:"18"})]})})]}),Vk=({editor:n,readOnly:e})=>n?.isActive("imageGroup")?m.jsxs("div",{className:"toolbar-group",role:"group","aria-label":"Image group alignment",children:[m.jsx(W,{onClick:()=>n?.chain().focus().updateAttributes("imageGroup",{align:"left"}).run(),isActive:n?.isActive("imageGroup",{align:"left"}),title:"Align Group Left",disabled:!n?.isActive("imageGroup")||e,children:m.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[m.jsx("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),m.jsx("line",{x1:"3",y1:"12",x2:"15",y2:"12"}),m.jsx("line",{x1:"3",y1:"18",x2:"18",y2:"18"})]})}),m.jsx(W,{onClick:()=>n?.chain().focus().updateAttributes("imageGroup",{align:"center"}).run(),isActive:n?.isActive("imageGroup",{align:"center"}),title:"Align Group Center",disabled:!n?.isActive("imageGroup")||e,children:m.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[m.jsx("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),m.jsx("line",{x1:"6",y1:"12",x2:"18",y2:"12"}),m.jsx("line",{x1:"4",y1:"18",x2:"20",y2:"18"})]})}),m.jsx(W,{onClick:()=>n?.chain().focus().updateAttributes("imageGroup",{align:"right"}).run(),isActive:n?.isActive("imageGroup",{align:"right"}),title:"Align Group Right",disabled:!n?.isActive("imageGroup")||e,children:m.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[m.jsx("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),m.jsx("line",{x1:"9",y1:"12",x2:"21",y2:"12"}),m.jsx("line",{x1:"6",y1:"18",x2:"21",y2:"18"})]})})]}):null,Wk=({editor:n,readOnly:e})=>m.jsxs("div",{className:"toolbar-group",role:"group","aria-label":"Lists",children:[m.jsx(W,{onClick:()=>n?.chain().focus().toggleBulletList().run(),isActive:n?.isActive("bulletList"),title:"Bullet list",disabled:!n||e,children:m.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.25",strokeLinecap:"round",strokeLinejoin:"round",children:[m.jsx("line",{x1:"9",y1:"6",x2:"20",y2:"6"}),m.jsx("line",{x1:"9",y1:"12",x2:"20",y2:"12"}),m.jsx("line",{x1:"9",y1:"18",x2:"20",y2:"18"}),m.jsx("circle",{cx:"5",cy:"6",r:"1",fill:"currentColor"}),m.jsx("circle",{cx:"5",cy:"12",r:"1",fill:"currentColor"}),m.jsx("circle",{cx:"5",cy:"18",r:"1",fill:"currentColor"})]})}),m.jsx(W,{onClick:()=>n?.chain().focus().toggleOrderedList().run(),isActive:n?.isActive("orderedList"),title:"Numbered list",disabled:!n||e,children:m.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.25",strokeLinecap:"round",strokeLinejoin:"round",children:[m.jsx("line",{x1:"10",y1:"6",x2:"20",y2:"6"}),m.jsx("line",{x1:"10",y1:"12",x2:"20",y2:"12"}),m.jsx("line",{x1:"10",y1:"18",x2:"20",y2:"18"}),m.jsx("path",{d:"M4 6h1v4"}),m.jsx("path",{d:"M4 10h2"}),m.jsx("path",{d:"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1"})]})}),m.jsx(W,{onClick:()=>n?.chain().focus().toggleTaskList().run(),isActive:n?.isActive("taskList"),title:"Task list",disabled:!n||e,children:m.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.25",strokeLinecap:"round",strokeLinejoin:"round",children:[m.jsx("rect",{x:"3",y:"5",width:"6",height:"6",rx:"1"}),m.jsx("path",{d:"M4.5 8l1.2 1.2L9 6.5"}),m.jsx("line",{x1:"13",y1:"8",x2:"21",y2:"8"}),m.jsx("rect",{x:"3",y:"13",width:"6",height:"6",rx:"1"}),m.jsx("line",{x1:"13",y1:"16",x2:"21",y2:"16"})]})})]});function dl({children:n}){const[e,t]=S.useState(!1);return S.useEffect(()=>{t(!0)},[]),!e||typeof document>"u"?null:bo.createPortal(m.jsx("div",{className:"react-latex-editor-portal","data-rle-portal":"",children:n}),document.body)}function Uk(n){try{const{hostname:e}=new URL(n);return e==="youtu.be"||e==="youtube.com"||e==="www.youtube.com"||e==="m.youtube.com"||e==="www.youtube-nocookie.com"}catch{return!1}}const Kk=({editor:n,readOnly:e,onMathDialogOpen:t,onImagePicker:r})=>{const[s,i]=S.useState(!1),[o,l]=S.useState(""),[a,c]=S.useState(null),u=S.useCallback(()=>{i(!1),l(""),c(null)},[]),d=S.useCallback(async()=>{if(!n)return;const h=o.trim();if(!h||!dr(h)){c("Paste valid SVG markup (must include an <svg> element)");return}try{await ul(n,h),u()}catch(p){c(p instanceof Error?p.message:"Failed to insert SVG")}},[n,o,u]),f=S.useCallback(h=>{(h.ctrlKey||h.metaKey)&&h.key==="Enter"&&(h.preventDefault(),h.stopPropagation(),d())},[d]);return m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"toolbar-group",role:"group","aria-label":"Insert",children:[m.jsx(W,{onClick:t,title:"Insert equation",shortcut:"Ctrl+M",disabled:!n||e,children:m.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.25",strokeLinecap:"round",strokeLinejoin:"round",children:[m.jsx("path",{d:"M19 5H9l-4 14H3"}),m.jsx("path",{d:"M13 13l6 6"}),m.jsx("path",{d:"M13 19l6-6"})]})}),m.jsx(W,{onClick:r,title:"Insert image",disabled:!n||e,children:m.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.25",strokeLinecap:"round",strokeLinejoin:"round",children:[m.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),m.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),m.jsx("path",{d:"M21 15l-5-5L5 21"})]})}),m.jsx(W,{onClick:h=>{h.preventDefault(),h.stopPropagation(),i(!0)},title:"Paste SVG code",disabled:!n||e,children:m.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.25",strokeLinecap:"round",strokeLinejoin:"round",children:[m.jsx("path",{d:"M16 18l6-6-6-6"}),m.jsx("path",{d:"M8 6l-6 6 6 6"})]})}),m.jsx(W,{onClick:()=>Rk(n),title:"Insert table",disabled:!n||e,children:m.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.25",strokeLinecap:"round",strokeLinejoin:"round",children:[m.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"1"}),m.jsx("path",{d:"M3 9h18"}),m.jsx("path",{d:"M3 15h18"}),m.jsx("path",{d:"M9 3v18"})]})}),m.jsx(W,{onClick:()=>{if(!n)return;const h=window.prompt("Enter YouTube video URL:");if(h){if(!Uk(h.trim())){window.alert("Please enter a valid YouTube URL");return}n.chain().focus().setYoutubeVideo({src:h.trim()}).run()}},title:"Insert YouTube video",disabled:!n||e,children:m.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.25",strokeLinecap:"round",strokeLinejoin:"round",children:[m.jsx("rect",{x:"2",y:"5",width:"20",height:"14",rx:"3"}),m.jsx("path",{d:"M10 9l5 3-5 3V9z",fill:"currentColor",stroke:"none"})]})})]}),s&&m.jsx(dl,{children:m.jsx("div",{className:"image-dialog-overlay",onClick:u,role:"presentation",children:m.jsxs("div",{className:"image-dialog",onClick:h=>h.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"svg-paste-dialog-title",children:[m.jsx("h3",{id:"svg-paste-dialog-title",children:"Paste SVG code"}),a&&m.jsx("p",{className:"image-dialog-error",role:"alert",children:a}),m.jsxs("div",{children:[m.jsx("label",{htmlFor:"toolbar-svg-markup-input",className:"sr-only",children:"SVG markup"}),m.jsx("textarea",{id:"toolbar-svg-markup-input",className:"image-dialog-svg-input",placeholder:'<svg xmlns="http://www.w3.org/2000/svg" ...>...</svg>',value:o,onChange:h=>{l(h.target.value),c(null)},onKeyDown:f,rows:10,autoFocus:!0}),m.jsxs("div",{className:"image-dialog-buttons",children:[m.jsx("button",{type:"button",disabled:!o.trim(),onClick:h=>{h.preventDefault(),h.stopPropagation(),d()},children:"Insert SVG"}),m.jsx("button",{type:"button",onClick:u,children:"Cancel"})]})]})]})})})]})},qk=({editor:n,readOnly:e})=>{const t=()=>{if(!n)return;const r=n.getAttributes("link").href||"",s=window.prompt("Enter URL:",r);if(s!==null){if(s===""){n.chain().focus().extendMarkRange("link").unsetLink().run();return}n.chain().focus().extendMarkRange("link").setLink({href:df(s)}).run()}};return m.jsxs("div",{className:"toolbar-group",role:"group","aria-label":"Text formatting",children:[m.jsx(W,{onClick:()=>n?.chain().focus().toggleBold().run(),isActive:n?.isActive("bold"),title:"Bold",shortcut:"Ctrl+B",disabled:!n||e,children:m.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.25",strokeLinecap:"round",strokeLinejoin:"round",children:[m.jsx("path",{d:"M7 5h6a3.5 3.5 0 0 1 0 7H7z"}),m.jsx("path",{d:"M7 12h7a3.5 3.5 0 0 1 0 7H7z"})]})}),m.jsx(W,{onClick:()=>n?.chain().focus().toggleItalic().run(),isActive:n?.isActive("italic"),title:"Italic",shortcut:"Ctrl+I",disabled:!n||e,children:m.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.25",strokeLinecap:"round",strokeLinejoin:"round",children:[m.jsx("line",{x1:"19",y1:"4",x2:"10",y2:"4"}),m.jsx("line",{x1:"14",y1:"20",x2:"5",y2:"20"}),m.jsx("line",{x1:"15",y1:"4",x2:"9",y2:"20"})]})}),m.jsx(W,{onClick:()=>n?.chain().focus().toggleUnderline().run(),isActive:n?.isActive("underline"),title:"Underline",shortcut:"Ctrl+U",disabled:!n||e,children:m.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.25",strokeLinecap:"round",strokeLinejoin:"round",children:[m.jsx("path",{d:"M6 4v6a6 6 0 0 0 12 0V4"}),m.jsx("line",{x1:"4",y1:"20",x2:"20",y2:"20"})]})}),m.jsx(W,{onClick:()=>n?.chain().focus().toggleStrike().run(),isActive:n?.isActive("strike"),title:"Strikethrough",disabled:!n||e,children:m.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.25",strokeLinecap:"round",strokeLinejoin:"round",children:[m.jsx("path",{d:"M5 12h14"}),m.jsx("path",{d:"M16 6.5a4 2.5 0 0 0-4-1.5h-1a3.5 3.5 0 0 0 0 7h2a3.5 3.5 0 0 1 0 7h-1.5a4 2.5 0 0 1-4-1.5"})]})}),m.jsx(W,{onClick:()=>n?.chain().focus().toggleHighlight().run(),isActive:n?.isActive("highlight"),title:"Highlight",disabled:!n||e,children:m.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.25",strokeLinecap:"round",strokeLinejoin:"round",children:[m.jsx("path",{d:"M9 11l-6 6v3h9l3-3"}),m.jsx("path",{d:"M14 7l3 3 4-4a2.12 2.12 0 0 0-3-3z"})]})}),m.jsx(W,{onClick:()=>n?.chain().focus().toggleCode().run(),isActive:n?.isActive("code"),title:"Inline code",disabled:!n||e,children:m.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.25",strokeLinecap:"round",strokeLinejoin:"round",children:[m.jsx("polyline",{points:"16 18 22 12 16 6"}),m.jsx("polyline",{points:"8 6 2 12 8 18"})]})}),m.jsx(W,{onClick:t,isActive:n?.isActive("link"),title:"Insert link",shortcut:"Ctrl+K",disabled:!n||e,children:m.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.25",strokeLinecap:"round",strokeLinejoin:"round",children:[m.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),m.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})}),m.jsx(W,{onClick:()=>n?.chain().focus().extendMarkRange("link").unsetLink().run(),title:"Remove link",disabled:!n||e||!n?.isActive("link"),children:m.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.25",strokeLinecap:"round",strokeLinejoin:"round",children:[m.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),m.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"}),m.jsx("line",{x1:"4",y1:"4",x2:"20",y2:"20"})]})}),m.jsx(W,{onClick:()=>n?.chain().focus().unsetAllMarks().clearNodes().run(),title:"Clear formatting",disabled:!n||e,children:m.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.25",strokeLinecap:"round",strokeLinejoin:"round",children:[m.jsx("path",{d:"M4 7h16"}),m.jsx("path",{d:"M9 7v13"}),m.jsx("path",{d:"M15 7v13"}),m.jsx("path",{d:"M6 20h12"}),m.jsx("path",{d:"M8 3l1 4"}),m.jsx("path",{d:"M15 3l1 4"})]})})]})},Gk=({editor:n,readOnly:e})=>n?.isActive("youtube")?m.jsxs("div",{className:"toolbar-group",role:"group","aria-label":"YouTube controls",style:{display:"flex",alignItems:"center",gap:8},children:[m.jsx(W,{onClick:()=>n?.chain().focus().updateAttributes("youtube",{align:"left"}).run(),isActive:n?.isActive("youtube",{align:"left"}),title:"Align YouTube Left",disabled:!n?.isActive("youtube")||e,children:m.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[m.jsx("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),m.jsx("line",{x1:"3",y1:"12",x2:"15",y2:"12"}),m.jsx("line",{x1:"3",y1:"18",x2:"18",y2:"18"})]})}),m.jsx(W,{onClick:()=>n?.chain().focus().updateAttributes("youtube",{align:"center"}).run(),isActive:n?.isActive("youtube",{align:"center"}),title:"Align YouTube Center",disabled:!n?.isActive("youtube")||e,children:m.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[m.jsx("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),m.jsx("line",{x1:"6",y1:"12",x2:"18",y2:"12"}),m.jsx("line",{x1:"4",y1:"18",x2:"20",y2:"18"})]})}),m.jsx(W,{onClick:()=>n?.chain().focus().updateAttributes("youtube",{align:"right"}).run(),isActive:n?.isActive("youtube",{align:"right"}),title:"Align YouTube Right",disabled:!n?.isActive("youtube")||e,children:m.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[m.jsx("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),m.jsx("line",{x1:"9",y1:"12",x2:"21",y2:"12"}),m.jsx("line",{x1:"6",y1:"18",x2:"21",y2:"18"})]})}),m.jsx("input",{type:"number",min:100,max:1920,step:10,value:parseInt(n.getAttributes("youtube").width||640,10),onChange:t=>n.chain().focus().updateAttributes("youtube",{width:`${t.target.value}px`}).run(),style:{width:60,marginLeft:8,marginRight:2,fontSize:14,padding:"2px 4px"},"aria-label":"YouTube width",disabled:!n?.isActive("youtube")||e,title:"YouTube Width"}),m.jsx("span",{style:{fontSize:14},children:"×"}),m.jsx("input",{type:"number",min:56,max:1080,step:10,value:parseInt(n.getAttributes("youtube").height||360,10),onChange:t=>n.chain().focus().updateAttributes("youtube",{height:`${t.target.value}px`}).run(),style:{width:60,marginLeft:2,fontSize:14,padding:"2px 4px"},"aria-label":"YouTube height",disabled:!n?.isActive("youtube")||e,title:"YouTube Height"})]}):null,cn=()=>m.jsx("div",{className:"toolbar-divider",role:"separator","aria-orientation":"vertical"});function Gs(n){const[,e]=S.useReducer(t=>t+1,0);S.useEffect(()=>{if(!n)return;const t=()=>e();return n.on("transaction",t),n.on("selectionUpdate",t),n.on("focus",t),n.on("blur",t),()=>{n.off("transaction",t),n.off("selectionUpdate",t),n.off("focus",t),n.off("blur",t)}},[n])}const Jk=n=>{const{editor:e,readOnly:t,onMathDialogOpen:r,onImagePicker:s}=n;return Gs(e),m.jsx("div",{className:"toolbar",role:"toolbar","aria-label":"Editor toolbar",children:m.jsxs("div",{className:"toolbar-row",children:[m.jsx(Fk,{editor:e,readOnly:t}),m.jsx(cn,{}),m.jsx(qk,{editor:e,readOnly:t}),m.jsx(cn,{}),m.jsx(Pk,{editor:e,readOnly:t}),m.jsx(cn,{}),m.jsx(zk,{editor:e,readOnly:t}),m.jsx(_k,{editor:e,readOnly:t}),m.jsx(cn,{}),m.jsx(Dk,{editor:e,readOnly:t}),m.jsx(Wk,{editor:e,readOnly:t}),m.jsx(cn,{}),m.jsx(Ik,{editor:e,readOnly:t}),m.jsx(cn,{}),m.jsx(Kk,{editor:e,readOnly:t,onMathDialogOpen:r??(()=>{}),onImagePicker:s??(()=>{})}),m.jsx($k,{editor:e,readOnly:t}),m.jsx(Vk,{editor:e,readOnly:t}),m.jsx(Gk,{editor:e,readOnly:t})]})})},Yk=({isLoading:n})=>m.jsx("div",{children:n&&m.jsx("div",{className:"loading-overlay",children:m.jsx("div",{className:"spinner"})})}),gf=()=>typeof window>"u"?Promise.resolve():import("mathlive").then(()=>{});gf();const yf=S.forwardRef(({onClose:n,onInsert:e,initialValue:t=""},r)=>{const[s,i]=S.useState(t),[o,l]=S.useState("basic"),[a,c]=S.useState(!1),[u,d]=S.useState(!1),f=S.useRef(null),h=S.useRef(null),p=S.useRef(s);p.current=s;const g=S.useCallback(k=>{i(k.target.value)},[]),y=S.useCallback(()=>{const k=p.current.trim();if(k){c(!0);try{e(k,u),n()}finally{c(!1)}}},[e,n,u]),b=S.useCallback(k=>{f.current&&(f.current.insert(k),f.current.focus(),i(f.current.value))},[]);S.useEffect(()=>{const k=requestAnimationFrame(()=>{f.current&&(t&&(f.current.value=t),f.current.focus())});return()=>cancelAnimationFrame(k)},[t]),S.useEffect(()=>{const k=M=>{if(M.key==="Escape"){M.preventDefault(),n();return}M.key==="Enter"&&(M.ctrlKey||M.metaKey)&&(M.preventDefault(),y())};return document.addEventListener("keydown",k),()=>document.removeEventListener("keydown",k)},[n,y]),S.useEffect(()=>{const k=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=k}},[]);const x=S.useMemo(()=>({basic:[{symbol:"+",title:"Plus",display:"+"},{symbol:"-",title:"Minus",display:"−"},{symbol:"\\times",title:"Multiply",display:"×"},{symbol:"\\div",title:"Divide",display:"÷"},{symbol:"\\pm",title:"Plus Minus",display:"±"},{symbol:"\\mp",title:"Minus Plus",display:"∓"},{symbol:"=",title:"Equals",display:"="},{symbol:"\\neq",title:"Not Equal",display:"≠"},{symbol:"\\approx",title:"Approximately",display:"≈"},{symbol:"\\equiv",title:"Equivalent",display:"≡"},{symbol:"<",title:"Less Than",display:"<"},{symbol:">",title:"Greater Than",display:">"},{symbol:"\\leq",title:"Less or Equal",display:"≤"},{symbol:"\\geq",title:"Greater or Equal",display:"≥"},{symbol:"\\ll",title:"Much Less",display:"≪"},{symbol:"\\gg",title:"Much Greater",display:"≫"}],fractions:[{symbol:"\\frac{a}{b}",title:"Fraction",display:"a/b"},{symbol:"\\frac{1}{2}",title:"One Half",display:"½"},{symbol:"\\frac{1}{3}",title:"One Third",display:"⅓"},{symbol:"\\frac{1}{4}",title:"One Quarter",display:"¼"},{symbol:"\\frac{3}{4}",title:"Three Quarters",display:"¾"},{symbol:"\\frac{2}{3}",title:"Two Thirds",display:"⅔"},{symbol:"\\frac{d}{dx}",title:"Derivative",display:"d/dx"},{symbol:"\\frac{\\partial}{\\partial x}",title:"Partial Derivative",display:"∂/∂x"}],powers:[{symbol:"#@^2",title:"Square",display:"x²"},{symbol:"#@^3",title:"Cube",display:"x³"},{symbol:"#@^{}",title:"Power",display:"xⁿ"},{symbol:"#@_{}",title:"Subscript",display:"x₁"},{symbol:"#@_{}^{}",title:"Sub-Superscript",display:"xₙᵐ"},{symbol:"\\sqrt{}",title:"Square Root",display:"√"},{symbol:"\\sqrt[3]{}",title:"Cube Root",display:"∛"},{symbol:"\\sqrt[n]{}",title:"Nth Root",display:"ⁿ√"},{symbol:"e^{}",title:"Exponential",display:"eˣ"},{symbol:"10^{}",title:"Power of 10",display:"10ˣ"},{symbol:"#@^{-1}",title:"Reciprocal",display:"x⁻¹"}],trig:[{symbol:"\\sin",title:"Sine",display:"sin"},{symbol:"\\cos",title:"Cosine",display:"cos"},{symbol:"\\tan",title:"Tangent",display:"tan"},{symbol:"\\cot",title:"Cotangent",display:"cot"},{symbol:"\\sec",title:"Secant",display:"sec"},{symbol:"\\csc",title:"Cosecant",display:"csc"},{symbol:"\\arcsin",title:"Arcsine",display:"sin⁻¹"},{symbol:"\\arccos",title:"Arccosine",display:"cos⁻¹"},{symbol:"\\arctan",title:"Arctangent",display:"tan⁻¹"},{symbol:"\\sinh",title:"Hyperbolic Sine",display:"sinh"},{symbol:"\\cosh",title:"Hyperbolic Cosine",display:"cosh"},{symbol:"\\tanh",title:"Hyperbolic Tangent",display:"tanh"}],logs:[{symbol:"\\log",title:"Logarithm",display:"log"},{symbol:"\\log_{}",title:"Log Base",display:"log₍ₓ₎"},{symbol:"\\log_{10}",title:"Log Base 10",display:"log₁₀"},{symbol:"\\log_2",title:"Log Base 2",display:"log₂"},{symbol:"\\ln",title:"Natural Log",display:"ln"},{symbol:"\\lg",title:"Common Log",display:"lg"},{symbol:"e",title:"Euler's Number",display:"e"},{symbol:"\\exp",title:"Exponential Function",display:"exp"}],greek:[{symbol:"\\alpha",title:"Alpha",display:"α"},{symbol:"\\beta",title:"Beta",display:"β"},{symbol:"\\gamma",title:"Gamma",display:"γ"},{symbol:"\\delta",title:"Delta",display:"δ"},{symbol:"\\epsilon",title:"Epsilon",display:"ε"},{symbol:"\\zeta",title:"Zeta",display:"ζ"},{symbol:"\\eta",title:"Eta",display:"η"},{symbol:"\\theta",title:"Theta",display:"θ"},{symbol:"\\lambda",title:"Lambda",display:"λ"},{symbol:"\\mu",title:"Mu",display:"μ"},{symbol:"\\nu",title:"Nu",display:"ν"},{symbol:"\\pi",title:"Pi",display:"π"},{symbol:"\\rho",title:"Rho",display:"ρ"},{symbol:"\\sigma",title:"Sigma",display:"σ"},{symbol:"\\tau",title:"Tau",display:"τ"},{symbol:"\\phi",title:"Phi",display:"φ"},{symbol:"\\chi",title:"Chi",display:"χ"},{symbol:"\\psi",title:"Psi",display:"ψ"},{symbol:"\\omega",title:"Omega",display:"ω"},{symbol:"\\Gamma",title:"Capital Gamma",display:"Γ"},{symbol:"\\Delta",title:"Capital Delta",display:"Δ"},{symbol:"\\Theta",title:"Capital Theta",display:"Θ"},{symbol:"\\Lambda",title:"Capital Lambda",display:"Λ"},{symbol:"\\Pi",title:"Capital Pi",display:"Π"},{symbol:"\\Sigma",title:"Capital Sigma",display:"Σ"},{symbol:"\\Phi",title:"Capital Phi",display:"Φ"},{symbol:"\\Psi",title:"Capital Psi",display:"Ψ"},{symbol:"\\Omega",title:"Capital Omega",display:"Ω"}],calculus:[{symbol:"\\sum",title:"Sum",display:"∑"},{symbol:"\\sum_{i=1}^{n}",title:"Sum with Limits",display:"∑ᵢ₌₁ⁿ"},{symbol:"\\prod",title:"Product",display:"∏"},{symbol:"\\prod_{i=1}^{n}",title:"Product with Limits",display:"∏ᵢ₌₁ⁿ"},{symbol:"\\int",title:"Integral",display:"∫"},{symbol:"\\int_{a}^{b}",title:"Definite Integral",display:"∫ₐᵇ"},{symbol:"\\iint",title:"Double Integral",display:"∬"},{symbol:"\\iiint",title:"Triple Integral",display:"∭"},{symbol:"\\oint",title:"Contour Integral",display:"∮"},{symbol:"\\lim",title:"Limit",display:"lim"},{symbol:"\\lim_{x \\to \\infty}",title:"Limit to Infinity",display:"lim_{x→∞}"},{symbol:"\\lim_{x \\to 0}",title:"Limit to Zero",display:"lim_{x→0}"},{symbol:"\\nabla",title:"Nabla/Gradient",display:"∇"},{symbol:"\\partial",title:"Partial",display:"∂"}],symbols:[{symbol:"\\infty",title:"Infinity",display:"∞"},{symbol:"\\emptyset",title:"Empty Set",display:"∅"},{symbol:"\\in",title:"Element Of",display:"∈"},{symbol:"\\notin",title:"Not Element Of",display:"∉"},{symbol:"\\subset",title:"Subset",display:"⊂"},{symbol:"\\supset",title:"Superset",display:"⊃"},{symbol:"\\subseteq",title:"Subset or Equal",display:"⊆"},{symbol:"\\supseteq",title:"Superset or Equal",display:"⊇"},{symbol:"\\cup",title:"Union",display:"∪"},{symbol:"\\cap",title:"Intersection",display:"∩"},{symbol:"\\forall",title:"For All",display:"∀"},{symbol:"\\exists",title:"Exists",display:"∃"},{symbol:"\\nexists",title:"Does Not Exist",display:"∄"},{symbol:"\\therefore",title:"Therefore",display:"∴"},{symbol:"\\because",title:"Because",display:"∵"},{symbol:"\\propto",title:"Proportional",display:"∝"},{symbol:"\\cdot",title:"Center Dot",display:"·"},{symbol:"\\bullet",title:"Bullet",display:"•"}],geometry:[{symbol:"#@^\\circ",title:"Degree Symbol",display:"°"},{symbol:"100^\\circ",title:"100 Degrees",display:"100°"},{symbol:"90^\\circ",title:"90 Degrees",display:"90°"},{symbol:"180^\\circ",title:"180 Degrees",display:"180°"},{symbol:"360^\\circ",title:"360 Degrees",display:"360°"},{symbol:"\\angle",title:"Angle",display:"∠"},{symbol:"\\angle ABC",title:"Angle ABC",display:"∠ABC"},{symbol:"\\measuredangle",title:"Measured Angle",display:"∡"},{symbol:"\\sphericalangle",title:"Spherical Angle",display:"∢"},{symbol:"\\triangle",title:"Triangle",display:"△"},{symbol:"\\triangle ABC",title:"Triangle ABC",display:"△ABC"},{symbol:"\\square",title:"Square",display:"□"},{symbol:"\\blacksquare",title:"Black Square",display:"■"},{symbol:"\\diamond",title:"Diamond",display:"◊"},{symbol:"\\blacklozenge",title:"Black Diamond",display:"⧫"},{symbol:"\\bigcirc",title:"Circle",display:"○"},{symbol:"\\circ",title:"Small Circle",display:"∘"},{symbol:"\\odot",title:"Circle Dot",display:"⊙"},{symbol:"\\parallel",title:"Parallel",display:"∥"},{symbol:"\\nparallel",title:"Not Parallel",display:"∦"},{symbol:"\\perp",title:"Perpendicular",display:"⊥"},{symbol:"\\cong",title:"Congruent",display:"≅"},{symbol:"\\ncong",title:"Not Congruent",display:"≇"},{symbol:"\\sim",title:"Similar",display:"∼"},{symbol:"\\nsim",title:"Not Similar",display:"≁"},{symbol:"\\simeq",title:"Similar or Equal",display:"≃"},{symbol:"\\overline{AB}",title:"Line Segment",display:"AB̄"},{symbol:"\\overrightarrow{AB}",title:"Ray",display:"AB⃗"},{symbol:"\\overleftrightarrow{AB}",title:"Line",display:"AB↔"}],brackets:[{symbol:"()",title:"Parentheses",display:"( )"},{symbol:"[]",title:"Square Brackets",display:"[ ]"},{symbol:"\\{\\}",title:"Curly Braces",display:"{ }"},{symbol:"\\langle\\rangle",title:"Angle Brackets",display:"⟨ ⟩"},{symbol:"\\left(\\right)",title:"Auto-sized Parentheses",display:"( )"},{symbol:"\\left[\\right]",title:"Auto-sized Brackets",display:"[ ]"},{symbol:"\\left\\{\\right\\}",title:"Auto-sized Braces",display:"{ }"},{symbol:"\\left|\\right|",title:"Absolute Value",display:"| |"},{symbol:"\\left\\|\\right\\|",title:"Norm",display:"‖ ‖"},{symbol:"\\left\\langle\\right\\rangle",title:"Auto-sized Angle",display:"⟨ ⟩"},{symbol:"\\left\\lceil\\right\\rceil",title:"Ceiling",display:"⌈ ⌉"},{symbol:"\\left\\lfloor\\right\\rfloor",title:"Floor",display:"⌊ ⌋"}]}),[]),C=S.useCallback(k=>m.jsx("div",{className:"math-toolbar-grid",children:k.map((M,R)=>m.jsx("button",{onClick:()=>b(M.symbol),title:M.title,className:"math-symbol-button",type:"button",children:M.display},R))}),[b]);return m.jsx(dl,{children:m.jsx("div",{className:"math-dialog-overlay",onClick:n,role:"presentation",children:m.jsxs("div",{className:"math-dialog",ref:h,onClick:k=>k.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"math-dialog-title",children:[m.jsxs("div",{className:"math-dialog-header",children:[m.jsx("h3",{id:"math-dialog-title",children:"Insert Math Equation"}),m.jsx("button",{className:"close-button",onClick:n,type:"button","aria-label":"Close dialog",children:"×"})]}),m.jsx("div",{className:"math-toolbar-tabs",children:Object.keys(x).map(k=>m.jsx("button",{className:`tab-button ${o===k?"active":""}`,onClick:()=>l(k),type:"button",children:k.charAt(0).toUpperCase()+k.slice(1)},k))}),m.jsx("div",{className:"math-editor",children:S.createElement("math-field",{ref:f,value:s,onInput:g,"virtual-keyboard-mode":"manual",className:"math-dialog-math-field","math-mode":"latex","smart-mode":"on","smart-fence":"on","smart-superscript":"on","smart-subscript":"on","smart-operator":"on","smart-fraction":"on","smart-sqrt":"on","smart-bracket":"on","smart-paren":"on","smart-quote":"on","smart-space":"on","smart-command":"on"})}),m.jsx("div",{className:"math-toolbar-container",children:C(x[o])}),m.jsxs("div",{className:"math-examples",children:[m.jsx("h4",{children:"General"}),m.jsx("div",{className:"equation-buttons",children:m.jsx("button",{onClick:()=>b("\\space"),type:"button",children:"Spasi"})})]}),m.jsxs("div",{className:"math-display-mode-toggle",children:[m.jsxs("label",{children:[m.jsx("input",{type:"checkbox",checked:u,onChange:k=>d(k.target.checked)}),"Display as centered block (still allows text before/after)"]}),m.jsx("span",{className:"math-dialog-hint",children:"Tip: Ctrl/Cmd + Enter to insert"})]}),m.jsxs("div",{className:"math-dialog-footer",children:[m.jsx("button",{className:"cancel-button",onClick:n,type:"button",children:"Cancel"}),m.jsx("button",{className:"save-button",onClick:y,type:"button",disabled:a||!s.trim(),"aria-busy":a,children:a?"Inserting...":"Insert Equation"})]})]})})})});yf.displayName="MathEquationDialog";function bf(n,e){S.useEffect(()=>{if(!n)return;const t=s=>{if(!n.isFocused&&!n.view.hasFocus())return;const i=s.ctrlKey||s.metaKey;if(i&&s.key.toLowerCase()==="k"){s.preventDefault();const o=n.getAttributes("link").href||"",l=window.prompt("Enter URL:",o);if(l===null)return;if(l===""){n.chain().focus().extendMarkRange("link").unsetLink().run();return}const a=/^(https?:|mailto:|tel:|\/|#)/i.test(l)?l:`https://${l}`;n.chain().focus().extendMarkRange("link").setLink({href:a}).run();return}i&&s.key.toLowerCase()==="m"&&e?.onMathDialogOpen&&(s.preventDefault(),e.onMathDialogOpen())},r=n.view.dom;return r.addEventListener("keydown",t),()=>r.removeEventListener("keydown",t)},[n,e?.onMathDialogOpen])}const Xk=({editor:n,readOnly:e})=>{if(Gs(n),!n?.isActive("table"))return null;const t=r=>{e||r()};return m.jsxs("div",{className:"table-controls",role:"toolbar","aria-label":"Table controls",children:[m.jsxs("div",{className:"table-controls-group",children:[m.jsx("button",{onClick:()=>t(()=>n.chain().focus().addColumnBefore().run()),title:"Add column before",disabled:e,type:"button",children:"←+"}),m.jsx("button",{onClick:()=>t(()=>n.chain().focus().addColumnAfter().run()),title:"Add column after",disabled:e,type:"button",children:"+→"}),m.jsx("button",{onClick:()=>t(()=>n.chain().focus().deleteColumn().run()),title:"Delete column",disabled:e,type:"button",children:"− Col"})]}),m.jsxs("div",{className:"table-controls-group",children:[m.jsx("button",{onClick:()=>t(()=>n.chain().focus().addRowBefore().run()),title:"Add row before",disabled:e,type:"button",children:"↑+"}),m.jsx("button",{onClick:()=>t(()=>n.chain().focus().addRowAfter().run()),title:"Add row after",disabled:e,type:"button",children:"+↓"}),m.jsx("button",{onClick:()=>t(()=>n.chain().focus().deleteRow().run()),title:"Delete row",disabled:e,type:"button",children:"− Row"})]}),m.jsx("button",{onClick:()=>t(()=>n.chain().focus().deleteTable().run()),title:"Delete table",disabled:e,className:"delete-table-button",type:"button",children:"Delete table"})]})};function xf(n){const e={characters:0,words:0,equations:0,images:0,videos:0};if(!n)return e;let t=0,r=0,s=0,i=0,o=0;return n.state.doc.descendants(l=>{if(l.isText&&l.text){t+=l.text.length,r+=l.text.trim().split(/\s+/).filter(Boolean).length;return}if(l.type.name==="math"){const a=String(l.attrs.latex||"");s+=1,t+=Math.max(a.length,1),r+=1;return}if(l.type.name==="image"){i+=1,t+=1;return}l.type.name==="youtube"&&(o+=1,t+=1)}),{characters:t,words:r,equations:s,images:i,videos:o}}const Qk=({editor:n})=>{if(Gs(n),!n)return null;const{characters:e,words:t,equations:r,images:s,videos:i}=xf(n),o=al.maxCharacters,l=e>=o*.9,a=e>=o,c=[];return r&&c.push(`${r} eq`),s&&c.push(`${s} img`),i&&c.push(`${i} video`),m.jsxs("div",{className:`character-count${a?" is-over-limit":l?" is-near-limit":""}`,"aria-live":"polite",children:[m.jsxs("span",{className:"character-count-primary",children:[m.jsxs("span",{children:[e.toLocaleString(),o?` / ${o.toLocaleString()}`:""," chars"]}),m.jsx("span",{"aria-hidden":"true",children:" · "}),m.jsxs("span",{children:[t.toLocaleString()," words"]})]}),c.length>0&&m.jsx("span",{className:"character-count-extras",children:c.join(" · ")})]})};class kf extends S.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error("Editor Error Boundary caught an error:",e,t)}render(){return this.state.hasError?this.props.fallback?this.props.fallback:m.jsxs("div",{style:{padding:"20px",border:"2px solid #ef4444",borderRadius:"8px",backgroundColor:"#fef2f2",color:"#991b1b"},role:"alert",children:[m.jsx("h3",{style:{margin:"0 0 10px 0"},children:"Something went wrong with the editor"}),m.jsx("p",{style:{margin:"0 0 10px 0"},children:this.state.error?.message||"An unexpected error occurred"}),m.jsx("button",{onClick:()=>this.setState({hasError:!1,error:void 0}),style:{padding:"8px 16px",backgroundColor:"#dc2626",color:"white",border:"none",borderRadius:"4px",cursor:"pointer"},children:"Try Again"})]}):this.props.children}}function Zk(n){try{const e=new URL(n);return e.protocol==="http:"||e.protocol==="https:"}catch{return!1}}function eS(n){return new Promise((e,t)=>{const r=new Image;r.onload=()=>e(),r.onerror=()=>t(new Error("Could not load image from URL")),r.src=n})}const Sf=({isOpen:n,onClose:e,onImageSelect:t,onUploadClick:r})=>{const[s,i]=S.useState("upload"),[o,l]=S.useState(""),[a,c]=S.useState(""),[u,d]=S.useState(!1),[f,h]=S.useState(null),p=S.useRef(null);S.useEffect(()=>{if(!n)return;h(null);const x=C=>{C.key==="Escape"&&e()};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[n,e]);const g=S.useCallback(async x=>{const C=x.target.files;if(C?.length){d(!0),h(null);try{const k=await tn(C);t(k.map(M=>({src:M.src,alt:M.alt,mediaType:M.isSvg?"svg":"image",svgContent:M.svgContent}))),e()}catch(k){h(k instanceof Error?k.message:"Failed to load file")}finally{d(!1),x.target.value=""}}},[t,e]),y=S.useCallback(async()=>{const x=o.trim();if(x){if(!Zk(x)){h("Please enter a valid http(s) image or SVG URL");return}d(!0),h(null);try{await eS(x),t([{src:x,mediaType:Os(x)?"svg":"image"}]),l(""),e()}catch(C){h(C instanceof Error?C.message:"Failed to load image")}finally{d(!1)}}},[o,t,e]),b=S.useCallback(()=>{const x=a.trim();if(x){h(null);try{if(!dr(x))throw new Error("Paste valid SVG markup starting with <svg>");const C=Tn(x);t([{src:"",alt:"SVG figure",mediaType:"svg",svgContent:C}]),c(""),e()}catch(C){h(C instanceof Error?C.message:"Invalid SVG")}}},[a,t,e]);return n?m.jsx(dl,{children:m.jsx("div",{className:"image-dialog-overlay",onClick:e,role:"presentation",children:m.jsxs("div",{className:"image-dialog",onClick:x=>x.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"image-dialog-title",children:[m.jsx("h3",{id:"image-dialog-title",children:"Insert Image / SVG"}),m.jsx("div",{className:"image-dialog-tabs",role:"tablist",children:[["upload","Upload"],["url","URL"],["svg","Paste SVG"]].map(([x,C])=>m.jsx("button",{type:"button",role:"tab","aria-selected":s===x,className:`image-dialog-tab${s===x?" is-active":""}`,onClick:()=>{i(x),h(null)},children:C},x))}),f&&m.jsx("p",{className:"image-dialog-error",role:"alert",children:f}),s==="upload"&&m.jsxs("div",{className:"image-dialog-upload",children:[m.jsx("button",{type:"button",className:"image-dialog-upload-btn",disabled:u,onClick:()=>{r?(e(),r()):p.current?.click()},children:u?"Loading...":"Choose image or SVG file"}),m.jsx("input",{ref:p,type:"file",accept:cl,multiple:!0,onChange:g,hidden:!0}),m.jsxs("p",{className:"image-dialog-hint",children:["JPG, PNG, GIF, WebP, ",m.jsx("strong",{children:"SVG"})," · max"," ",uf(As.image)]}),m.jsx("p",{className:"image-dialog-hint",children:"Ideal for math figures, graphs, and diagrams exported as SVG."})]}),s==="url"&&m.jsxs("div",{children:[m.jsx("label",{htmlFor:"image-url-input",className:"sr-only",children:"Image or SVG URL"}),m.jsx("input",{id:"image-url-input",type:"url",placeholder:"https://example.com/figure.svg",value:o,onChange:x=>{l(x.target.value),h(null)},onKeyDown:x=>{x.key==="Enter"&&(x.preventDefault(),x.stopPropagation(),y())},disabled:u,autoComplete:"off"}),m.jsxs("div",{className:"image-dialog-buttons",children:[m.jsx("button",{type:"button",disabled:!o.trim()||u,onClick:x=>{x.preventDefault(),x.stopPropagation(),y()},children:u?"Loading...":"Insert URL"}),m.jsx("button",{type:"button",onClick:e,children:"Cancel"})]})]}),s==="svg"&&m.jsxs("div",{children:[m.jsx("label",{htmlFor:"svg-markup-input",className:"sr-only",children:"SVG markup"}),m.jsx("textarea",{id:"svg-markup-input",className:"image-dialog-svg-input",placeholder:'<svg xmlns="http://www.w3.org/2000/svg" ...>...</svg>',value:a,onChange:x=>{c(x.target.value),h(null)},onKeyDown:x=>{(x.ctrlKey||x.metaKey)&&x.key==="Enter"&&(x.preventDefault(),x.stopPropagation(),b())},rows:8}),m.jsxs("div",{className:"image-dialog-buttons",children:[m.jsx("button",{type:"button",disabled:!a.trim(),onClick:x=>{x.preventDefault(),x.stopPropagation(),b()},children:"Insert SVG"}),m.jsx("button",{type:"button",onClick:e,children:"Cancel"})]})]})]})})}):null},wf=S.forwardRef((n,e)=>{const[t,r]=S.useState(!1),[s,i]=S.useState(!1),[o,l]=S.useState(null),[a,c]=S.useState(!1),u=S.useRef(null),{initialContent:d="<p></p>",onChange:f,placeholder:h="Start typing...",readOnly:p=!1,autoFocus:g=!1,className:y="",onImageSelectionRequest:b,minHeight:x="300px",maxHeight:C,showCharacterCount:k=!0,showTableControls:M=!0,onError:R}=n,z=S.useMemo(()=>of({placeholder:h}),[h]),w=Xy({content:d,editable:!p,autofocus:g,immediatelyRender:!1,editorProps:lf({className:y,placeholder:h}),onUpdate:({editor:N})=>{f?.(N.getHTML())},extensions:z});S.useEffect(()=>{w&&w.setEditable(!p)},[w,p]),S.useImperativeHandle(e,()=>({addImage:N=>{w&&yn(w,N)},addSvg:(N,_)=>w?ul(w,N,_):Promise.reject(new Error("Editor is not ready")),addImagesFromFiles:N=>w?ff(w,N):Promise.reject(new Error("Editor is not ready")),getHTML:()=>w?.getHTML()??"",getJSON:()=>w?.getJSON()??{},getText:()=>w?.getText()??"",setContent:N=>{w?.commands.setContent(N)},clearContent:()=>{w?.commands.clearContent(!0)},focus:()=>{w?.commands.focus()},blur:()=>{w?.commands.blur()},isEmpty:()=>w?.isEmpty??!0,getEditor:()=>w}),[w]);const j=S.useCallback(N=>{l(N),R?.(N)},[R]),G=S.useCallback(()=>{u.current?.click()},[]),Ae=S.useCallback(async N=>{const _=N.target.files;if(!(!_?.length||!w)){c(!0);try{const U=await tn(_);yn(w,U.map(Z=>({src:Z.src,alt:Z.alt,mediaType:Z.isSvg?"svg":"image",svgContent:Z.svgContent}))),l(null)}catch(U){j(U instanceof Error?U:new Error("Failed to add image"))}finally{c(!1),N.target.value=""}}},[w,j]),Be=S.useCallback(()=>{!w||p||(b?b():i(!0))},[w,b,p]),Ve=S.useCallback(N=>{w&&yn(w,N)},[w]),Le=S.useCallback(()=>{p||r(!0)},[p]);bf(w,{onMathDialogOpen:Le});const ve=S.useCallback((N,_=!1)=>{try{w&&(hf(w,N,_),l(null))}catch(U){j(U instanceof Error?U:new Error("Math insertion failed"))}},[w,j]),Ne=S.useCallback(()=>{l(null)},[]),E={minHeight:x,...C&&{maxHeight:C,overflow:"auto"}};return m.jsx(kf,{children:m.jsxs("div",{className:`editor-shell ${y}`.trim(),children:[m.jsxs("div",{className:"custom-editor",style:E,role:"application","aria-label":"Rich text editor",children:[m.jsx(Jk,{editor:w,readOnly:p,onMathDialogOpen:Le,onImagePicker:Be}),m.jsx(Fy,{editor:w,className:"editor-content"}),m.jsx(Yk,{isLoading:a}),k&&m.jsx(Qk,{editor:w})]}),M&&m.jsx(Xk,{editor:w,readOnly:p}),t&&m.jsx(yf,{onClose:()=>r(!1),onInsert:ve}),!b&&m.jsx(Sf,{isOpen:s,onClose:()=>i(!1),onImageSelect:Ve,onUploadClick:G}),m.jsx("input",{ref:u,type:"file",accept:cl,multiple:!0,hidden:!0,onChange:Ae,"aria-hidden":"true"}),o&&m.jsxs("div",{className:"error-message",role:"alert",children:[m.jsx("p",{children:o.message}),m.jsx("button",{onClick:Ne,className:"error-close","aria-label":"Close error message",type:"button",children:"×"})]})]})})});wf.displayName="Editor";const tS="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js",yc="react-latex-editor-mathjax";function nS(n){return typeof window>"u"||window.MathJax?.typesetPromise?Promise.resolve():new Promise((e,t)=>{if(window.MathJax||(window.MathJax={tex:{inlineMath:n?.inlineMath||[["$","$"],["\\(","\\)"]],displayMath:n?.displayMath||[["$$","$$"],["\\[","\\]"]],processEscapes:!0,processEnvironments:!0,packages:n?.packages||["base","ams","noerrors","noundefined"]},options:{skipHtmlTags:["script","noscript","style","textarea","pre","code"],ignoreHtmlClass:"tex2jax_ignore",processHtmlClass:"tex2jax_process"},startup:{defaultPageReady:()=>Promise.resolve()}}),document.getElementById(yc)){const i=setInterval(()=>{window.MathJax?.typesetPromise&&(clearInterval(i),e())},50);setTimeout(()=>{clearInterval(i),window.MathJax?.typesetPromise||t(new Error("MathJax failed to load"))},8e3);return}const s=document.createElement("script");s.id=yc,s.src=tS,s.async=!0,s.onload=()=>{const i=setInterval(()=>{window.MathJax?.typesetPromise&&(clearInterval(i),e())},50);setTimeout(()=>{clearInterval(i),window.MathJax?.typesetPromise||t(new Error("MathJax failed to initialize"))},8e3)},s.onerror=()=>t(new Error("Failed to load MathJax script")),document.head.appendChild(s)})}const rS=({content:n,className:e="",contentClassName:t="",enableMath:r=!0,mathJaxConfig:s})=>{const i=S.useRef(null),[o,l]=S.useState(!r),[a,c]=S.useState(null),u=S.useRef(!1),d=S.useRef(0),f=S.useMemo(()=>JSON.stringify(s??{}),[s]);S.useEffect(()=>{if(!r){l(!0);return}let p=!1;return nS(s).then(()=>{p||(l(!0),c(null))}).catch(g=>{p||c(g.message)}),()=>{p=!0}},[r,f]),S.useLayoutEffect(()=>{const p=i.current?.querySelector(".viewer-content");if(!p)return;const g=++d.current;if(!r||!o){p.innerHTML=n||"";return}u.current&&(p.innerHTML=n||""),(async()=>{u.current=!0;try{window.MathJax?.typesetClear&&window.MathJax.typesetClear([p]),p.innerHTML=n||"",p.querySelectorAll("[data-latex]").forEach(x=>{const C=x.getAttribute("data-latex");if(!C)return;if(x.getAttribute("data-display-mode")==="true"||x.hasAttribute("data-display-mode")||x.classList.contains("math-node-wrapper-block")){const M=document.createElement("div");M.className="viewer-math-block",M.textContent=`\\[${C}\\]`,x.replaceWith(M)}else{const M=document.createElement("span");M.className="viewer-math-inline",M.textContent=`\\(${C}\\)`,x.replaceWith(M)}}),window.MathJax&&typeof window.MathJax.typesetPromise=="function"&&g===d.current&&await window.MathJax.typesetPromise([p])}catch(b){console.error("MathJax processing error:",b),g===d.current&&c(`Failed to render mathematical equations: ${b}`)}finally{u.current=!1}})()},[n,o,r]);const h=S.useCallback(()=>{c(null)},[]);return m.jsxs("div",{className:`editor-viewer ${e}`.trim(),ref:i,children:[m.jsx("div",{className:`viewer-content prose ${t}`.trim()}),a&&m.jsxs("div",{className:"error-message",role:"alert",children:[m.jsx("p",{children:a}),m.jsx("button",{onClick:h,className:"error-close","aria-label":"Close error message",type:"button",children:"×"})]})]})};function sS(n){const[e,t]=S.useState({isEmpty:!0,isFocused:!1,characterCount:0,wordCount:0,canUndo:!1,canRedo:!1});return S.useEffect(()=>{if(!n)return;const r=()=>{const s=n.getText(),i=n.storage.characterCount?.characters()||0,o=s.trim().split(/\s+/).filter(l=>l.length>0).length;t({isEmpty:n.isEmpty,isFocused:n.isFocused,characterCount:i,wordCount:o,canUndo:n.can().undo(),canRedo:n.can().redo()})};return n.on("update",r),n.on("focus",r),n.on("blur",r),n.on("selectionUpdate",r),r(),()=>{n.off("update",r),n.off("focus",r),n.off("blur",r),n.off("selectionUpdate",r)}},[n]),e}function iS(n,e,t=2e3){const[r,s]=S.useState(!1),[i,o]=S.useState(null);return S.useEffect(()=>{if(!n)return;let l;const a=()=>{clearTimeout(l),l=setTimeout(async()=>{s(!0);try{await e(n.getHTML()),o(new Date)}catch(c){console.error("Auto-save failed:",c)}finally{s(!1)}},t)};return n.on("update",a),()=>{clearTimeout(l),n.off("update",a)}},[n,e,t]),{isSaving:r,lastSaved:i}}function oS(n){const[e,t]=S.useState({from:0,to:0,empty:!0});S.useEffect(()=>{if(!n)return;const s=()=>{const{from:i,to:o,empty:l}=n.state.selection;t({from:i,to:o,empty:l})};return n.on("selectionUpdate",s),s(),()=>{n.off("selectionUpdate",s)}},[n]);const r=S.useCallback(()=>{if(!n)return"";const{from:s,to:i}=n.state.selection;return n.state.doc.textBetween(s,i," ")},[n]);return{...e,getSelectedText:r}}function lS(n){const[e,t]=S.useState(!1),[r,s]=S.useState(!1);S.useEffect(()=>{if(!n)return;const l=()=>{t(n.can().undo()),s(n.can().redo())};return n.on("update",l),n.on("transaction",l),l(),()=>{n.off("update",l),n.off("transaction",l)}},[n]);const i=S.useCallback(()=>{n?.commands.undo()},[n]),o=S.useCallback(()=>{n?.commands.redo()},[n]);return{canUndo:e,canRedo:r,undo:i,redo:o}}function aS(){return typeof window>"u"?!1:window.innerWidth<=mf}function cS(){const[n,e]=S.useState(aS);return S.useEffect(()=>{const t=()=>{e(window.innerWidth<=mf)};return t(),window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[]),n}exports.BackgroundColor=nf;exports.CustomTextStyle=tf;exports.DEFAULT_COLORS=Y1;exports.DEFAULT_CONFIG=q1;exports.EDITOR_LIMITS=al;exports.Editor=wf;exports.ErrorBoundary=kf;exports.FONT_FAMILIES=X1;exports.FONT_SIZES=Q1;exports.HEADING_LEVELS=Z1;exports.IMAGE_ACCEPT=cl;exports.ImageGroup=ef;exports.ImagePickerDialog=Sf;exports.InlineMath=Gd;exports.KEYBOARD_SHORTCUTS=J1;exports.MATH_DELIMITERS=G1;exports.MAX_FILE_SIZE=As;exports.MathNode=qd;exports.ResizableImageExtension=Zd;exports.ResizableYoutubeExtension=sf;exports.SUPPORTED_IMAGE_FORMATS=Jd;exports.SVG_ACCEPT=ok;exports.Viewer=rS;exports.Z_INDEX=ek;exports.addImage=yn;exports.addImagesFromFiles=ff;exports.checkBrowserSupport=Ck;exports.countWords=kk;exports.debounce=Sk;exports.deepClone=vk;exports.ensureMathLiveLoaded=gf;exports.extractTextFromHtml=cf;exports.fileToDataUrl=Qd;exports.filesToImageSources=tn;exports.formatFileSize=uf;exports.generateId=Ek;exports.getEditorContentStats=xf;exports.getEditorExtensions=of;exports.getEditorProps=lf;exports.insertMath=hf;exports.insertSvg=ul;exports.isContentEmpty=Mk;exports.isLikelySvgMarkup=dr;exports.isSupportedImageFile=Ns;exports.isSvgFile=Xd;exports.isSvgSource=Os;exports.normalizeSvgForResponsive=sn;exports.normalizeUrl=df;exports.sanitizeHtml=xk;exports.sanitizeSvgMarkup=Tn;exports.svgMarkupToDataUrl=sk;exports.throttle=wk;exports.useEditorAutoSave=iS;exports.useEditorForceUpdate=Gs;exports.useEditorHistory=lS;exports.useEditorKeyboard=bf;exports.useEditorSelection=oS;exports.useEditorState=sS;exports.useResponsive=cS;exports.validateLatex=af;
|
|
131
|
+
//# sourceMappingURL=index.cjs.js.map
|