diff --git a/README.md b/README.md index 4d1693e..0187987 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,8 @@ yarn add @nytimes/react-prosemirror - [`useEditorEventListener`](#useeditoreventlistener-1) - [`useEditorEffect`](#useeditoreffect-1) - [`NodeViewComponentProps`](#nodeviewcomponentprops) + - [`useStopEvent`](#usestopevent) + - [`useSelectNode`](#useselectnode) - [`widget`](#widget) @@ -573,12 +575,13 @@ export function SelectionWidget() { ```tsx type NodeViewComponentProps = { - decorations: readonly Decoration[]; - innerDecorations: DecorationSource; - node: Node; - children?: ReactNode | ReactNode[]; - isSelected: boolean; - pos: number; + nodeProps: { + decorations: readonly Decoration[]; + innerDecorations: DecorationSource; + node: Node; + children?: ReactNode | ReactNode[]; + getPos: () => number; + }; } & HTMLAttributes; ``` @@ -594,6 +597,27 @@ and should pass them through to their top-level DOM element. In addition to accepting these props, all node view components _must_ forward their ref to their top-level DOM element. +### `useStopEvent` + +```tsx +type useStopEvent = (stopEvent: (view: EditorView, event: Event) => boolean): void +``` + +This hook can be used within a node view component to register a +[stopEvent handler](https://prosemirror.net/docs/ref/#view.NodeView.stopEvent). +Events for which this returns true are not handled by the editor. + +### `useSelectNode` + +```tsx +type useSelectNode = (selectNode: () => void, deselectNode?: () => void): void +``` + +This hook can be used within a node view component to register +[selectNode and deselectNode handlers](https://prosemirror.net/docs/ref/#view.NodeView.selectNode). +The selectNode handler will only be called when a NodeSelection is created whose +node is this one. + ### `widget` ```tsx diff --git a/docs/assets/index-BGqMXhJy.js b/docs/assets/index-Bc7OF9RB.js similarity index 81% rename from docs/assets/index-BGqMXhJy.js rename to docs/assets/index-Bc7OF9RB.js index b724f77..db34988 100644 --- a/docs/assets/index-BGqMXhJy.js +++ b/docs/assets/index-Bc7OF9RB.js @@ -6,7 +6,7 @@ * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var Ko=Symbol.for("react.element"),nS=Symbol.for("react.portal"),rS=Symbol.for("react.fragment"),iS=Symbol.for("react.strict_mode"),oS=Symbol.for("react.profiler"),sS=Symbol.for("react.provider"),lS=Symbol.for("react.context"),aS=Symbol.for("react.forward_ref"),uS=Symbol.for("react.suspense"),cS=Symbol.for("react.memo"),fS=Symbol.for("react.lazy"),xd=Symbol.iterator;function dS(n){return n===null||typeof n!="object"?null:(n=xd&&n[xd]||n["@@iterator"],typeof n=="function"?n:null)}var cm={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},fm=Object.assign,dm={};function hi(n,e,t){this.props=n,this.context=e,this.refs=dm,this.updater=t||cm}hi.prototype.isReactComponent={};hi.prototype.setState=function(n,e){if(typeof n!="object"&&typeof n!="function"&&n!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,n,e,"setState")};hi.prototype.forceUpdate=function(n){this.updater.enqueueForceUpdate(this,n,"forceUpdate")};function hm(){}hm.prototype=hi.prototype;function qc(n,e,t){this.props=n,this.context=e,this.refs=dm,this.updater=t||cm}var Qc=qc.prototype=new hm;Qc.constructor=qc;fm(Qc,hi.prototype);Qc.isPureReactComponent=!0;var Cd=Array.isArray,pm=Object.prototype.hasOwnProperty,Yc={current:null},mm={key:!0,ref:!0,__self:!0,__source:!0};function gm(n,e,t){var r,i={},o=null,s=null;if(e!=null)for(r in e.ref!==void 0&&(s=e.ref),e.key!==void 0&&(o=""+e.key),e)pm.call(e,r)&&!mm.hasOwnProperty(r)&&(i[r]=e[r]);var l=arguments.length-2;if(l===1)i.children=t;else if(1>1}};he.from=function(n){if(n instanceof he)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new he(e)};function Sm(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let i=n.child(r),o=e.child(r);if(i==o){t+=i.nodeSize;continue}if(!i.sameMarkup(o))return t;if(i.isText&&i.text!=o.text){for(let s=0;i.text[s]==o.text[s];s++)t++;return t}if(i.content.size||o.content.size){let s=Sm(i.content,o.content,t+1);if(s!=null)return s}t+=i.nodeSize}}function wm(n,e,t,r){for(let i=n.childCount,o=e.childCount;;){if(i==0||o==0)return i==o?null:{a:t,b:r};let s=n.child(--i),l=e.child(--o),a=s.nodeSize;if(s==l){t-=a,r-=a;continue}if(!s.sameMarkup(l))return{a:t,b:r};if(s.isText&&s.text!=l.text){let u=0,c=Math.min(s.text.length,l.text.length);for(;ue&&r(a,i+l,o||null,s)!==!1&&a.content.size){let c=l+1;a.nodesBetween(Math.max(0,e-c),Math.min(a.content.size,t-c),r,i+c)}l=u}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,i){let o="",s=!0;return this.nodesBetween(e,t,(l,a)=>{let u=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&u||l.isTextblock)&&r&&(s?s=!1:o+=r),o+=u},0),o}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,i=this.content.slice(),o=0;for(t.isText&&t.sameMarkup(r)&&(i[i.length-1]=t.withText(t.text+r.text),o=1);oe)for(let o=0,s=0;se&&((st)&&(l.isText?l=l.cut(Math.max(0,e-s),Math.min(l.text.length,t-s)):l=l.cut(Math.max(0,e-s-1),Math.min(l.content.size,t-s-1))),r.push(l),i+=l.nodeSize),s=a}return new x(r,i)}cutByIndex(e,t){return e==t?x.empty:e==0&&t==this.content.length?this:new x(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let i=this.content.slice(),o=this.size+t.nodeSize-r.nodeSize;return i[e]=t,new x(i,o)}addToStart(e){return new x([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new x(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;tthis.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let r=0,i=0;;r++){let o=this.child(r),s=i+o.nodeSize;if(s>=e)return s==e||t>0?cs(r+1,s):cs(r,i);i=s}}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 x.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new x(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return x.empty;let t,r=0;for(let i=0;ithis.type.rank&&(t||(t=e.slice(0,i)),t.push(this),r=!0),t&&t.push(o)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;tr.type.rank-i.type.rank),t}}W.none=[];class Tn extends Error{}class v{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=vm(this.content,e+this.openStart,t);return r&&new v(r,this.openStart,this.openEnd)}removeBetween(e,t){return new v(km(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 v.empty;let r=t.openStart||0,i=t.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new v(x.fromJSON(e,t.content),r,i)}static maxOpen(e,t=!0){let r=0,i=0;for(let o=e.firstChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.firstChild)r++;for(let o=e.lastChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.lastChild)i++;return new v(e,r,i)}}v.empty=new v(x.empty,0,0);function km(n,e,t){let{index:r,offset:i}=n.findIndex(e),o=n.maybeChild(r),{index:s,offset:l}=n.findIndex(t);if(i==e||o.isText){if(l!=t&&!n.child(s).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=s)throw new RangeError("Removing non-flat range");return n.replaceChild(r,o.copy(km(o.content,e-i-1,t-i-1)))}function vm(n,e,t,r){let{index:i,offset:o}=n.findIndex(e),s=n.maybeChild(i);if(o==e||s.isText)return n.cut(0,e).append(t).append(n.cut(e));let l=vm(s.content,e-o-1,t);return l&&n.replaceChild(i,s.copy(l))}function CS(n,e,t){if(t.openStart>n.depth)throw new Tn("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new Tn("Inconsistent open depths");return xm(n,e,t,0)}function xm(n,e,t,r){let i=n.index(r),o=n.node(r);if(i==e.index(r)&&r=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function to(n,e,t,r){let i=(e||n).node(t),o=0,s=e?e.index(t):i.childCount;n&&(o=n.index(t),n.depth>t?o++:n.textOffset&&(er(n.nodeAfter,r),o++));for(let l=o;li&&Cu(n,e,i+1),s=r.depth>i&&Cu(t,r,i+1),l=[];return to(null,n,i,l),o&&s&&e.index(i)==t.index(i)?(Cm(o,s),er(tr(o,Nm(n,e,t,r,i+1)),l)):(o&&er(tr(o,hl(n,e,i+1)),l),to(e,t,i,l),s&&er(tr(s,hl(t,r,i+1)),l)),to(r,null,i,l),new x(l)}function hl(n,e,t){let r=[];if(to(null,n,t,r),n.depth>t){let i=Cu(n,e,t+1);er(tr(i,hl(n,e,t+1)),r)}return to(e,null,t,r),new x(r)}function NS(n,e){let t=e.depth-n.openStart,i=e.node(t).copy(n.content);for(let o=t-1;o>=0;o--)i=e.node(o).copy(x.from(i));return{start:i.resolveNoCache(n.openStart+t),end:i.resolveNoCache(i.content.size-n.openEnd-t)}}class yo{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(t);return r?e.child(t).cut(r):i}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],i=t==0?0:this.path[t*3-1]+1;for(let o=0;o0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new OS(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=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],i=0,o=t;for(let s=e;;){let{index:l,offset:a}=s.content.findIndex(o),u=o-a;if(r.push(s,l,i+a),!u||(s=s.child(l),s.isText))break;o=u-1,i+=a+1}return new yo(t,r,o)}static resolveCached(e,t){let r=Md.get(e);if(r)for(let o=0;oe&&this.nodesBetween(e,t,o=>(r.isInSet(o.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Mm(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=x.empty,i=0,o=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,i,o),l=s&&s.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=i;at.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let i=x.fromJSON(e,t.content),o=e.nodeType(t.type).create(t.attrs,i,r);return o.type.checkAttrs(o.attrs),o}}Tt.prototype.text=void 0;class pl extends Tt{constructor(e,t,r,i){if(super(e,t,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Mm(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 pl(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new pl(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 Mm(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class sr{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new TS(e,t);if(r.next==null)return sr.empty;let i=Em(r);r.next&&r.err("Unexpected trailing text");let o=FS(PS(i));return LS(o,r),o}matchType(e){for(let t=0;tu.createAndFill()));for(let u=0;u=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let i=0;i{let o=i+(r.validEnd?"*":" ")+" ";for(let s=0;s"+e.indexOf(r.next[s].next);return o}).join(` -`)}}sr.empty=new sr(!0);class TS{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 Em(n){let e=[];do e.push(RS(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function RS(n){let e=[];do e.push(AS(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function AS(n){let e=IS(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=bS(n,e);else break;return e}function Ed(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function bS(n,e){let t=Ed(n),r=t;return n.eat(",")&&(n.next!="}"?r=Ed(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function zS(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let i=[];for(let o in t){let s=t[o];s.groups.indexOf(e)>-1&&i.push(s)}return i.length==0&&n.err("No node type or group '"+e+"' found"),i}function IS(n){if(n.eat("(")){let e=Em(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=zS(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 PS(n){let e=[[]];return i(o(n,0),t()),e;function t(){return e.push([])-1}function r(s,l,a){let u={term:a,to:l};return e[s].push(u),u}function i(s,l){s.forEach(a=>a.to=l)}function o(s,l){if(s.type=="choice")return s.exprs.reduce((a,u)=>a.concat(o(u,l)),[]);if(s.type=="seq")for(let a=0;;a++){let u=o(s.exprs[a],l);if(a==s.exprs.length-1)return u;i(u,l=t())}else if(s.type=="star"){let a=t();return r(l,a),i(o(s.expr,a),a),[r(a)]}else if(s.type=="plus"){let a=t();return i(o(s.expr,l),a),i(o(s.expr,a),a),[r(a)]}else{if(s.type=="opt")return[r(l)].concat(o(s.expr,l));if(s.type=="range"){let a=l;for(let u=0;u{n[s].forEach(({term:l,to:a})=>{if(!l)return;let u;for(let c=0;c{u||i.push([l,u=[]]),u.indexOf(c)==-1&&u.push(c)})})});let o=e[r.join(",")]=new sr(r.indexOf(n.length-1)>-1);for(let s=0;s-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;tr[o]=new bm(o,t,s));let i=t.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let o in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function $S(n,e,t){let r=t.split("|");return i=>{let o=i===null?"null":typeof i;if(r.indexOf(o)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${o}`)}}class VS{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?$S(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class qo{constructor(e,t,r,i){this.name=e,this.rank=t,this.schema=r,this.spec=i,this.attrs=Am(e,i.attrs),this.excluded=null;let o=Dm(this.attrs);this.instance=o?new W(this,o):null}create(e=null){return!e&&this.instance?this.instance:new W(this,Tm(this.attrs,e))}static compile(e,t){let r=Object.create(null),i=0;return e.forEach((o,s)=>r[o]=new qo(o,i++,t,s)),r}removeFromSet(e){for(var t=0;t-1}}class zm{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let i in e)t[i]=e[i];t.nodes=he.from(e.nodes),t.marks=he.from(e.marks||{}),this.nodes=Dd.compile(this.spec.nodes,this),this.marks=qo.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let o=this.nodes[i],s=o.spec.content||"",l=o.spec.marks;if(o.contentMatch=r[s]||(r[s]=sr.parse(s,this.nodes)),o.inlineContent=o.contentMatch.inlineContent,o.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!o.isInline||!o.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=o}o.markSet=l=="_"?null:l?Td(this,l.split(" ")):l==""||!o.inlineContent?[]:null}for(let i in this.marks){let o=this.marks[i],s=o.spec.excludes;o.excluded=s==null?[o]:s==""?[]:Td(this,s.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,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Dd){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,r,i)}text(e,t){let r=this.nodes.text;return new pl(r,r.defaultAttrs,e,W.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return Tt.fromJSON(this,e)}markFromJSON(e){return W.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function Td(n,e){let t=[];for(let r=0;r-1)&&t.push(s=a)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function BS(n){return n.tag!=null}function JS(n){return n.style!=null}class So{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(i=>{if(BS(i))this.tags.push(i);else if(JS(i)){let o=/[^=]*/.exec(i.style)[0];r.indexOf(o)<0&&r.push(o),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let o=e.nodes[i.node];return o.contentMatch.matchType(o)})}parse(e,t={}){let r=new Ad(this,t,!1);return r.addAll(e,W.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new Ad(this,t,!0);return r.addAll(e,W.none,t.from,t.to),v.maxOpen(r.finish())}matchTag(e,t,r){for(let i=r?this.tags.indexOf(r)+1:0;ie.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(s.getAttrs){let a=s.getAttrs(t);if(a===!1)continue;s.attrs=a||void 0}return s}}}static schemaRules(e){let t=[];function r(i){let o=i.priority==null?50:i.priority,s=0;for(;s{r(s=bd(s)),s.mark||s.ignore||s.clearMark||(s.mark=i)})}for(let i in e.nodes){let o=e.nodes[i].spec.parseDOM;o&&o.forEach(s=>{r(s=bd(s)),s.node||s.ignore||s.mark||(s.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new So(e,So.schemaRules(e)))}}const Im={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},_S={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Pm={ol:!0,ul:!0},ml=1,gl=2,no=4;function Rd(n,e,t){return e!=null?(e?ml:0)|(e==="full"?gl:0):n&&n.whitespace=="pre"?ml|gl:t&~no}class fs{constructor(e,t,r,i,o,s){this.type=e,this.attrs=t,this.marks=r,this.solid=i,this.options=s,this.content=[],this.activeMarks=W.none,this.match=o||(s&no?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(x.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&ml)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let o=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=o.withText(o.text.slice(0,o.text.length-i[0].length))}}let t=x.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(x.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&&!Im.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Ad{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0;let i=t.topNode,o,s=Rd(null,t.preserveWhitespace,0)|(r?no:0);i?o=new fs(i.type,i.attrs,W.none,!0,t.topMatch||i.type.contentMatch,s):r?o=new fs(null,null,W.none,!0,null,s):o=new fs(e.schema.topNodeType,null,W.none,!0,null,s),this.nodes=[o],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let r=e.nodeValue,i=this.top;if(i.options&gl||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(i.options&ml)i.options&gl?r=r.replace(/\r\n?/g,` + */var yS=k,SS=Symbol.for("react.element"),wS=Symbol.for("react.fragment"),kS=Object.prototype.hasOwnProperty,vS=yS.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,xS={key:!0,ref:!0,__self:!0,__source:!0};function ym(n,e,t){var r,i={},o=null,s=null;t!==void 0&&(o=""+t),e.key!==void 0&&(o=""+e.key),e.ref!==void 0&&(s=e.ref);for(r in e)kS.call(e,r)&&!xS.hasOwnProperty(r)&&(i[r]=e[r]);if(n&&n.defaultProps)for(r in e=n.defaultProps,e)i[r]===void 0&&(i[r]=e[r]);return{$$typeof:SS,type:n,key:o,ref:s,props:i,_owner:vS.current}}Gl.Fragment=wS;Gl.jsx=ym;Gl.jsxs=ym;am.exports=Gl;var A=am.exports;function pe(n){this.content=n}pe.prototype={constructor:pe,find:function(n){for(var e=0;e>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 Sm(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let i=n.child(r),o=e.child(r);if(i==o){t+=i.nodeSize;continue}if(!i.sameMarkup(o))return t;if(i.isText&&i.text!=o.text){for(let s=0;i.text[s]==o.text[s];s++)t++;return t}if(i.content.size||o.content.size){let s=Sm(i.content,o.content,t+1);if(s!=null)return s}t+=i.nodeSize}}function wm(n,e,t,r){for(let i=n.childCount,o=e.childCount;;){if(i==0||o==0)return i==o?null:{a:t,b:r};let s=n.child(--i),l=e.child(--o),a=s.nodeSize;if(s==l){t-=a,r-=a;continue}if(!s.sameMarkup(l))return{a:t,b:r};if(s.isText&&s.text!=l.text){let u=0,c=Math.min(s.text.length,l.text.length);for(;ue&&r(a,i+l,o||null,s)!==!1&&a.content.size){let c=l+1;a.nodesBetween(Math.max(0,e-c),Math.min(a.content.size,t-c),r,i+c)}l=u}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,i){let o="",s=!0;return this.nodesBetween(e,t,(l,a)=>{let u=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&u||l.isTextblock)&&r&&(s?s=!1:o+=r),o+=u},0),o}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,i=this.content.slice(),o=0;for(t.isText&&t.sameMarkup(r)&&(i[i.length-1]=t.withText(t.text+r.text),o=1);oe)for(let o=0,s=0;se&&((st)&&(l.isText?l=l.cut(Math.max(0,e-s),Math.min(l.text.length,t-s)):l=l.cut(Math.max(0,e-s-1),Math.min(l.content.size,t-s-1))),r.push(l),i+=l.nodeSize),s=a}return new x(r,i)}cutByIndex(e,t){return e==t?x.empty:e==0&&t==this.content.length?this:new x(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let i=this.content.slice(),o=this.size+t.nodeSize-r.nodeSize;return i[e]=t,new x(i,o)}addToStart(e){return new x([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new x(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;tthis.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let r=0,i=0;;r++){let o=this.child(r),s=i+o.nodeSize;if(s>=e)return s==e||t>0?cs(r+1,s):cs(r,i);i=s}}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 x.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new x(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return x.empty;let t,r=0;for(let i=0;ithis.type.rank&&(t||(t=e.slice(0,i)),t.push(this),r=!0),t&&t.push(o)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;tr.type.rank-i.type.rank),t}}W.none=[];class Dn extends Error{}class v{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=vm(this.content,e+this.openStart,t);return r&&new v(r,this.openStart,this.openEnd)}removeBetween(e,t){return new v(km(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 v.empty;let r=t.openStart||0,i=t.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new v(x.fromJSON(e,t.content),r,i)}static maxOpen(e,t=!0){let r=0,i=0;for(let o=e.firstChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.firstChild)r++;for(let o=e.lastChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.lastChild)i++;return new v(e,r,i)}}v.empty=new v(x.empty,0,0);function km(n,e,t){let{index:r,offset:i}=n.findIndex(e),o=n.maybeChild(r),{index:s,offset:l}=n.findIndex(t);if(i==e||o.isText){if(l!=t&&!n.child(s).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=s)throw new RangeError("Removing non-flat range");return n.replaceChild(r,o.copy(km(o.content,e-i-1,t-i-1)))}function vm(n,e,t,r){let{index:i,offset:o}=n.findIndex(e),s=n.maybeChild(i);if(o==e||s.isText)return n.cut(0,e).append(t).append(n.cut(e));let l=vm(s.content,e-o-1,t);return l&&n.replaceChild(i,s.copy(l))}function CS(n,e,t){if(t.openStart>n.depth)throw new Dn("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new Dn("Inconsistent open depths");return xm(n,e,t,0)}function xm(n,e,t,r){let i=n.index(r),o=n.node(r);if(i==e.index(r)&&r=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function eo(n,e,t,r){let i=(e||n).node(t),o=0,s=e?e.index(t):i.childCount;n&&(o=n.index(t),n.depth>t?o++:n.textOffset&&(er(n.nodeAfter,r),o++));for(let l=o;li&&Cu(n,e,i+1),s=r.depth>i&&Cu(t,r,i+1),l=[];return eo(null,n,i,l),o&&s&&e.index(i)==t.index(i)?(Cm(o,s),er(tr(o,Nm(n,e,t,r,i+1)),l)):(o&&er(tr(o,hl(n,e,i+1)),l),eo(e,t,i,l),s&&er(tr(s,hl(t,r,i+1)),l)),eo(r,null,i,l),new x(l)}function hl(n,e,t){let r=[];if(eo(null,n,t,r),n.depth>t){let i=Cu(n,e,t+1);er(tr(i,hl(n,e,t+1)),r)}return eo(e,null,t,r),new x(r)}function NS(n,e){let t=e.depth-n.openStart,i=e.node(t).copy(n.content);for(let o=t-1;o>=0;o--)i=e.node(o).copy(x.from(i));return{start:i.resolveNoCache(n.openStart+t),end:i.resolveNoCache(i.content.size-n.openEnd-t)}}class go{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(t);return r?e.child(t).cut(r):i}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],i=t==0?0:this.path[t*3-1]+1;for(let o=0;o0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new OS(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=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],i=0,o=t;for(let s=e;;){let{index:l,offset:a}=s.content.findIndex(o),u=o-a;if(r.push(s,l,i+a),!u||(s=s.child(l),s.isText))break;o=u-1,i+=a+1}return new go(t,r,o)}static resolveCached(e,t){let r=Md.get(e);if(r)for(let o=0;oe&&this.nodesBetween(e,t,o=>(r.isInSet(o.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Mm(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=x.empty,i=0,o=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,i,o),l=s&&s.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=i;at.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let i=x.fromJSON(e,t.content),o=e.nodeType(t.type).create(t.attrs,i,r);return o.type.checkAttrs(o.attrs),o}}Dt.prototype.text=void 0;class pl extends Dt{constructor(e,t,r,i){if(super(e,t,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Mm(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 pl(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new pl(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 Mm(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class sr{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new DS(e,t);if(r.next==null)return sr.empty;let i=Em(r);r.next&&r.err("Unexpected trailing text");let o=FS(PS(i));return LS(o,r),o}matchType(e){for(let t=0;tu.createAndFill()));for(let u=0;u=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let i=0;i{let o=i+(r.validEnd?"*":" ")+" ";for(let s=0;s"+e.indexOf(r.next[s].next);return o}).join(` +`)}}sr.empty=new sr(!0);class DS{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 Em(n){let e=[];do e.push(RS(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function RS(n){let e=[];do e.push(AS(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function AS(n){let e=IS(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=bS(n,e);else break;return e}function Ed(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function bS(n,e){let t=Ed(n),r=t;return n.eat(",")&&(n.next!="}"?r=Ed(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function zS(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let i=[];for(let o in t){let s=t[o];s.groups.indexOf(e)>-1&&i.push(s)}return i.length==0&&n.err("No node type or group '"+e+"' found"),i}function IS(n){if(n.eat("(")){let e=Em(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=zS(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 PS(n){let e=[[]];return i(o(n,0),t()),e;function t(){return e.push([])-1}function r(s,l,a){let u={term:a,to:l};return e[s].push(u),u}function i(s,l){s.forEach(a=>a.to=l)}function o(s,l){if(s.type=="choice")return s.exprs.reduce((a,u)=>a.concat(o(u,l)),[]);if(s.type=="seq")for(let a=0;;a++){let u=o(s.exprs[a],l);if(a==s.exprs.length-1)return u;i(u,l=t())}else if(s.type=="star"){let a=t();return r(l,a),i(o(s.expr,a),a),[r(a)]}else if(s.type=="plus"){let a=t();return i(o(s.expr,l),a),i(o(s.expr,a),a),[r(a)]}else{if(s.type=="opt")return[r(l)].concat(o(s.expr,l));if(s.type=="range"){let a=l;for(let u=0;u{n[s].forEach(({term:l,to:a})=>{if(!l)return;let u;for(let c=0;c{u||i.push([l,u=[]]),u.indexOf(c)==-1&&u.push(c)})})});let o=e[r.join(",")]=new sr(r.indexOf(n.length-1)>-1);for(let s=0;s-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;tr[o]=new bm(o,t,s));let i=t.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let o in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function $S(n,e,t){let r=t.split("|");return i=>{let o=i===null?"null":typeof i;if(r.indexOf(o)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${o}`)}}class VS{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?$S(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class Ko{constructor(e,t,r,i){this.name=e,this.rank=t,this.schema=r,this.spec=i,this.attrs=Am(e,i.attrs),this.excluded=null;let o=Tm(this.attrs);this.instance=o?new W(this,o):null}create(e=null){return!e&&this.instance?this.instance:new W(this,Dm(this.attrs,e))}static compile(e,t){let r=Object.create(null),i=0;return e.forEach((o,s)=>r[o]=new Ko(o,i++,t,s)),r}removeFromSet(e){for(var t=0;t-1}}class zm{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let i in e)t[i]=e[i];t.nodes=pe.from(e.nodes),t.marks=pe.from(e.marks||{}),this.nodes=Td.compile(this.spec.nodes,this),this.marks=Ko.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let o=this.nodes[i],s=o.spec.content||"",l=o.spec.marks;if(o.contentMatch=r[s]||(r[s]=sr.parse(s,this.nodes)),o.inlineContent=o.contentMatch.inlineContent,o.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!o.isInline||!o.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=o}o.markSet=l=="_"?null:l?Dd(this,l.split(" ")):l==""||!o.inlineContent?[]:null}for(let i in this.marks){let o=this.marks[i],s=o.spec.excludes;o.excluded=s==null?[o]:s==""?[]:Dd(this,s.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,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Td){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,r,i)}text(e,t){let r=this.nodes.text;return new pl(r,r.defaultAttrs,e,W.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return Dt.fromJSON(this,e)}markFromJSON(e){return W.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function Dd(n,e){let t=[];for(let r=0;r-1)&&t.push(s=a)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function BS(n){return n.tag!=null}function JS(n){return n.style!=null}class yo{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(i=>{if(BS(i))this.tags.push(i);else if(JS(i)){let o=/[^=]*/.exec(i.style)[0];r.indexOf(o)<0&&r.push(o),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let o=e.nodes[i.node];return o.contentMatch.matchType(o)})}parse(e,t={}){let r=new Ad(this,t,!1);return r.addAll(e,W.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new Ad(this,t,!0);return r.addAll(e,W.none,t.from,t.to),v.maxOpen(r.finish())}matchTag(e,t,r){for(let i=r?this.tags.indexOf(r)+1:0;ie.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(s.getAttrs){let a=s.getAttrs(t);if(a===!1)continue;s.attrs=a||void 0}return s}}}static schemaRules(e){let t=[];function r(i){let o=i.priority==null?50:i.priority,s=0;for(;s{r(s=bd(s)),s.mark||s.ignore||s.clearMark||(s.mark=i)})}for(let i in e.nodes){let o=e.nodes[i].spec.parseDOM;o&&o.forEach(s=>{r(s=bd(s)),s.node||s.ignore||s.mark||(s.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new yo(e,yo.schemaRules(e)))}}const Im={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},_S={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Pm={ol:!0,ul:!0},ml=1,gl=2,to=4;function Rd(n,e,t){return e!=null?(e?ml:0)|(e==="full"?gl:0):n&&n.whitespace=="pre"?ml|gl:t&~to}class fs{constructor(e,t,r,i,o,s){this.type=e,this.attrs=t,this.marks=r,this.solid=i,this.options=s,this.content=[],this.activeMarks=W.none,this.match=o||(s&to?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(x.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&ml)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let o=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=o.withText(o.text.slice(0,o.text.length-i[0].length))}}let t=x.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(x.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&&!Im.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Ad{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0;let i=t.topNode,o,s=Rd(null,t.preserveWhitespace,0)|(r?to:0);i?o=new fs(i.type,i.attrs,W.none,!0,t.topMatch||i.type.contentMatch,s):r?o=new fs(null,null,W.none,!0,null,s):o=new fs(e.schema.topNodeType,null,W.none,!0,null,s),this.nodes=[o],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let r=e.nodeValue,i=this.top;if(i.options&gl||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(i.options&ml)i.options&gl?r=r.replace(/\r\n?/g,` `):r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let o=i.content[i.content.length-1],s=e.previousSibling;(!o||s&&s.nodeName=="BR"||o.isText&&/[ \t\r\n\u000c]$/.test(o.text))&&(r=r.slice(1))}r&&this.insertNode(this.parser.schema.text(r),t),this.findInText(e)}else this.findInside(e)}addElement(e,t,r){let i=e.nodeName.toLowerCase(),o;Pm.hasOwnProperty(i)&&this.parser.normalizeLists&&WS(e);let s=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,r));if(s?s.ignore:_S.hasOwnProperty(i))this.findInside(e),this.ignoreFallback(e,t);else if(!s||s.skip||s.closeParent){s&&s.closeParent?this.open=Math.max(0,this.open-1):s&&s.skip.nodeType&&(e=s.skip);let l,a=this.top,u=this.needsBlock;if(Im.hasOwnProperty(i))a.content.length&&a.content[0].isInline&&this.open&&(this.open--,a=this.top),l=!0,a.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);return}let c=s&&s.skip?t:this.readStyles(e,t);c&&this.addAll(e,c),l&&this.sync(a),this.needsBlock=u}else{let l=this.readStyles(e,t);l&&this.addElementByRule(e,s,l,s.consuming===!1?o:void 0)}}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(` -`),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t)}readStyles(e,t){let r=e.style;if(r&&r.length)for(let i=0;i!a.clearMark(u)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,r,i){let o,s;if(t.node)if(s=this.parser.schema.nodes[t.node],s.isLeaf)this.insertNode(s.create(t.attrs),r)||this.leafFallback(e,r);else{let a=this.enter(s,t.attrs||null,r,t.preserveWhitespace);a&&(o=!0,r=a)}else{let a=this.parser.schema.marks[t.mark];r=r.concat(a.create(t.attrs))}let l=this.top;if(s&&s.isLeaf)this.findInside(e);else if(i)this.addElement(e,r,i);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r));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)}o&&this.sync(l)&&this.open--}addAll(e,t,r,i){let o=r||0;for(let s=r?e.childNodes[r]:e.firstChild,l=i==null?null:e.childNodes[i];s!=l;s=s.nextSibling,++o)this.findAtPoint(e,o),this.addDOM(s,t);this.findAtPoint(e,o)}findPlace(e,t){let r,i;for(let o=this.open;o>=0;o--){let s=this.nodes[o],l=s.findWrapping(e);if(l&&(!r||r.length>l.length)&&(r=l,i=s,!l.length)||s.solid)break}if(!r)return null;this.sync(i);for(let o=0;o(s.type?s.type.allowsMarkType(u.type):zd(u.type,e))?(a=u.addToSet(a),!1):!0),this.nodes.push(new fs(e,t,a,i,null,l)),this.open++,r}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),o=-(r?r.depth+1:0)+(i?0:1),s=(l,a)=>{for(;l>=0;l--){let u=t[l];if(u==""){if(l==t.length-1||l==0)continue;for(;a>=o;a--)if(s(l-1,a))return!0;return!1}else{let c=a>0||a==0&&i?this.nodes[a].type:r&&a>=o?r.node(a-o).type:null;if(!c||c.name!=u&&c.groups.indexOf(u)==-1)return!1;a--}}return!0};return s(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}}function WS(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Pm.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function US(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function bd(n){let e={};for(let t in n)e[t]=n[t];return e}function zd(n,e){let t=e.schema.nodes;for(let r in t){let i=t[r];if(!i.allowsMarkType(n))continue;let o=[],s=l=>{o.push(l);for(let a=0;a{if(o.length||s.marks.length){let l=0,a=0;for(;l=0;i--){let o=this.serializeMark(e.marks[i],e.isInline,t);o&&((o.contentDOM||o.dom).appendChild(r),r=o.dom)}return r}serializeMark(e,t,r={}){let i=this.marks[e.type.name];return i&&$s(va(r),i(e,t),null,e.attrs)}static renderSpec(e,t,r=null,i){return $s(e,t,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new pi(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Id(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return Id(e.marks)}}function Id(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function va(n){return n.document||window.document}const Pd=new WeakMap;function HS(n){let e=Pd.get(n);return e===void 0&&Pd.set(n,e=jS(n)),e}function jS(n){let e=null;function t(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let i=0;i-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let s=i.indexOf(" ");s>0&&(t=i.slice(0,s),i=i.slice(s+1));let l,a=t?n.createElementNS(t,i):n.createElement(i),u=e[1],c=1;if(u&&typeof u=="object"&&u.nodeType==null&&!Array.isArray(u)){c=2;for(let f in u)if(u[f]!=null){let d=f.indexOf(" ");d>0?a.setAttributeNS(f.slice(0,d),f.slice(d+1),u[f]):a.setAttribute(f,u[f])}}for(let f=c;fc)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:p,contentDOM:h}=$s(n,d,t,r);if(a.appendChild(p),h){if(l)throw new RangeError("Multiple content holes");l=h}}}return{dom:a,contentDOM:l}}const Fm=65535,Lm=Math.pow(2,16);function KS(n,e){return n+e*Lm}function Fd(n){return n&Fm}function qS(n){return(n-(n&Fm))/Lm}const $m=1,Vm=2,Vs=4,Bm=8;let Ld=class{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&Bm)>0}get deletedBefore(){return(this.delInfo&($m|Vs))>0}get deletedAfter(){return(this.delInfo&(Vm|Vs))>0}get deletedAcross(){return(this.delInfo&Vs)>0}},qr=class kr{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&kr.empty)return kr.empty}recover(e){let t=0,r=Fd(e);if(!this.inverted)for(let i=0;ie)break;let u=this.ranges[l+o],c=this.ranges[l+s],f=a+u;if(e<=f){let d=u?e==a?-1:e==f?1:t:t,p=a+i+(d<0?0:c);if(r)return p;let h=e==(t<0?a:f)?null:KS(l/3,e-a),m=e==a?Vm:e==f?$m:Vs;return(t<0?e!=a:e!=f)&&(m|=Bm),new Ld(p,m,h)}i+=c-u}return r?e+i:new Ld(e+i,0,null)}touches(e,t){let r=0,i=Fd(t),o=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;le)break;let u=this.ranges[l+o],c=a+u;if(e<=c&&l==i*3)return!0;r+=this.ranges[l+s]-u}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,o=0;i!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),i),t.openStart,t.openEnd);return $e.fromReplace(e,this.from,this.to,o)}invert(){return new _m(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 Ti(t.pos,r.pos,this.mark)}merge(e){return e instanceof Ti&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ti(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 Ti(t.from,t.to,e.markFromJSON(t.mark))}};Ke.jsonID("addMark",Jm);let _m=class Ri extends Ke{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 v(Xc(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return $e.fromReplace(e,this.from,this.to,r)}invert(){return new Jm(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 Ri(t.pos,r.pos,this.mark)}merge(e){return e instanceof Ri&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ri(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 Ri(t.from,t.to,e.markFromJSON(t.mark))}};Ke.jsonID("removeMark",_m);let Wm=class Ai extends Ke{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return $e.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return $e.fromReplace(e,this.pos,this.pos+1,new v(x.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let i=0;ir.pos?null:new Bs(t.pos,r.pos,i,o,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Bs(t.from,t.to,t.gapFrom,t.gapTo,v.fromJSON(e,t.slice),t.insert,!!t.structure)}};Ke.jsonID("replaceAround",yl);function Mu(n,e,t){let r=n.resolve(e),i=t-e,o=r.depth;for(;i>0&&o>0&&r.indexAfter(o)==r.node(o).childCount;)o--,i--;if(i>0){let s=r.node(o).maybeChild(r.indexAfter(o));for(;i>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,i--}}return!1}function QS(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function ef(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth;;--r){let i=n.$from.node(r),o=n.$from.index(r),s=n.$to.indexAfter(r);if(ro;u--,c--){let f=i.node(u),d=i.index(u);if(f.type.spec.isolating)return!1;let p=f.content.cutByIndex(d,f.childCount),h=r&&r[c]||f;if(h!=f&&(p=p.replaceChild(0,h.type.create(h.attrs))),!f.canReplace(d+1,f.childCount)||!h.type.validContent(p))return!1}let l=i.indexAfter(o),a=r&&r[0];return i.node(o).canReplaceWith(l,l,a?a.type:i.node(o+1).type)}function Hm(n,e){let t=n.resolve(e),r=t.index();return YS(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function YS(n,e){return!!(n&&e&&!n.isLeaf&&n.canAppend(e))}function jm(n,e,t=e,r=v.empty){if(e==t&&!r.size)return null;let i=n.resolve(e),o=n.resolve(t);return GS(i,o,r)?new Zc(e,t,r):new XS(i,o,r).fit()}function GS(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}let XS=class{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=x.empty;for(let i=0;i<=e.depth;i++){let o=e.node(i);this.frontier.push({type:o.type,match:o.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=x.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let u=this.findFittable();u?this.placeNodes(u):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let o=this.placed,s=r.depth,l=i.depth;for(;s&&l&&o.childCount==1;)o=o.firstChild.content,s--,l--;let a=new v(o,s,l);return e>-1?new yl(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new Zc(r.pos,i.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,i=this.unplaced.openEnd;r1&&(i=0),o.type.spec.isolating&&i<=r){e=r;break}t=o.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let i,o=null;r?(o=Ca(this.unplaced.content,r-1).firstChild,i=o.content):i=this.unplaced.content;let s=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:u}=this.frontier[l],c,f=null;if(t==1&&(s?u.matchType(s.type)||(f=u.fillBefore(x.from(s),!1)):o&&a.compatibleContent(o.type)))return{sliceDepth:r,frontierDepth:l,parent:o,inject:f};if(t==2&&s&&(c=u.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:l,parent:o,wrap:c};if(o&&u.matchType(o.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=Ca(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new v(e,t+1,Math.max(r,i.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=Ca(e,t);if(i.childCount<=1&&t>0){let o=e.size-t<=t+i.size;this.unplaced=new v(bi(e,t-1,1),t-1,o?t-1:r)}else this.unplaced=new v(bi(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:i,wrap:o}){for(;this.depth>t;)this.closeFrontierNode();if(o)for(let m=0;m1||a==0||m.content.size)&&(f=w,c.push(Km(m.mark(d.allowedMarks(m.marks)),u==1?a:0,u==l.childCount?p:-1)))}let h=u==l.childCount;h||(p=-1),this.placed=zi(this.placed,t,x.from(c)),this.frontier[t].match=f,h&&p<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,w=l;m1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:i}=this.frontier[t],o=t=0;l--){let{match:a,type:u}=this.frontier[l],c=Na(e,l,u,a,!0);if(!c||c.childCount)continue e}return{depth:t,fit:s,move:o?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=zi(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let i=e.node(r),o=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,o)}return e}openFrontierNode(e,t=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=zi(this.placed,this.depth,x.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(x.empty,!0);t.childCount&&(this.placed=zi(this.placed,this.frontier.length,t))}};function bi(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(bi(n.firstChild.content,e-1,t)))}function zi(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(zi(n.lastChild.content,e-1,t)))}function Ca(n,e){for(let t=0;t1&&(r=r.replaceChild(0,Km(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(x.empty,!0)))),n.copy(r)}function Na(n,e,t,r,i){let o=n.node(e),s=i?n.indexAfter(e):n.index(e);if(s==o.childCount&&!t.compatibleContent(o.type))return null;let l=r.fillBefore(o.content,!0,s);return l&&!ZS(t,o.content,s)?l:null}function ZS(n,e,t){for(let r=t;r0}get deletedBefore(){return(this.delInfo&(Ym|Ws))>0}get deletedAfter(){return(this.delInfo&(Gm|Ws))>0}get deletedAcross(){return(this.delInfo&Ws)>0}},Qr=class vr{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&vr.empty)return vr.empty}recover(e){let t=0,r=$d(e);if(!this.inverted)for(let i=0;ie)break;let u=this.ranges[l+o],c=this.ranges[l+s],f=a+u;if(e<=f){let d=u?e==a?-1:e==f?1:t:t,p=a+i+(d<0?0:c);if(r)return p;let h=e==(t<0?a:f)?null:tw(l/3,e-a),m=e==a?Gm:e==f?Ym:Ws;return(t<0?e!=a:e!=f)&&(m|=Xm),new Eu(p,m,h)}i+=c-u}return r?e+i:new Eu(e+i,0,null)}touches(e,t){let r=0,i=$d(t),o=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;le)break;let u=this.ranges[l+o],c=a+u;if(e<=c&&l==i*3)return!0;r+=this.ranges[l+s]-u}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,o=0;i=0;t--){let i=e.getMirror(t);this.appendMap(e.maps[t].invert(),i!=null&&i>t?r-i-1:void 0)}}invert(){let e=new Us;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;ro&&a!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),i),t.openStart,t.openEnd);return Ve.fromReplace(e,this.from,this.to,o)}invert(){return new Qo(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 Pi(t.pos,r.pos,this.mark)}merge(e){return e instanceof Pi&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Pi(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 Pi(t.from,t.to,e.markFromJSON(t.mark))}};qe.jsonID("addMark",nf);let Qo=class Fi extends qe{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 v(tf(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return Ve.fromReplace(e,this.from,this.to,r)}invert(){return new nf(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 Fi(t.pos,r.pos,this.mark)}merge(e){return e instanceof Fi&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Fi(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 Fi(t.from,t.to,e.markFromJSON(t.mark))}};qe.jsonID("removeMark",Qo);let rf=class Li extends qe{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Ve.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return Ve.fromReplace(e,this.pos,this.pos+1,new v(x.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let i=0;ir.pos?null:new Hs(t.pos,r.pos,i,o,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Hs(t.from,t.to,t.gapFrom,t.gapTo,v.fromJSON(e,t.slice),t.insert,!!t.structure)}};qe.jsonID("replaceAround",hr);function Du(n,e,t){let r=n.resolve(e),i=t-e,o=r.depth;for(;i>0&&o>0&&r.indexAfter(o)==r.node(o).childCount;)o--,i--;if(i>0){let s=r.node(o).maybeChild(r.indexAfter(o));for(;i>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,i--}}return!1}function iw(n,e,t,r){let i=[],o=[],s,l;n.doc.nodesBetween(e,t,(a,u,c)=>{if(!a.isInline)return;let f=a.marks;if(!r.isInSet(f)&&c.type.allowsMarkType(r.type)){let d=Math.max(u,e),p=Math.min(u+a.nodeSize,t),h=r.addToSet(f);for(let m=0;mn.step(a)),o.forEach(a=>n.step(a))}function ow(n,e,t,r){let i=[],o=0;n.doc.nodesBetween(e,t,(s,l)=>{if(!s.isInline)return;o++;let a=null;if(r instanceof qo){let u=s.marks,c;for(;c=r.isInSet(u);)(a||(a=[])).push(c),u=c.removeFromSet(u)}else r?r.isInSet(s.marks)&&(a=[r]):a=s.marks;if(a&&a.length){let u=Math.min(l+s.nodeSize,t);for(let c=0;cn.step(new Qo(s.from,s.to,s.style)))}function sw(n,e,t,r=t.contentMatch){let i=n.doc.nodeAt(e),o=[],s=e+1;for(let l=0;l=0;l--)n.step(o[l])}function lw(n,e,t){let{$from:r,$to:i,depth:o}=e,s=r.before(o+1),l=i.after(o+1),a=s,u=l,c=x.empty,f=0;for(let h=o,m=!1;h>t;h--)m||r.index(h)>0?(m=!0,c=x.from(r.node(h).copy(c)),f++):a--;let d=x.empty,p=0;for(let h=o,m=!1;h>t;h--)m||i.after(h+1)=0;s--){if(r.size){let l=t[s].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=x.from(t[s].type.create(t[s].attrs,r))}let i=e.start,o=e.end;n.step(new hr(i,o,i,o,new v(r,0,0),t.length,!0))}function uw(n,e,t,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=n.steps.length;n.doc.nodesBetween(e,t,(s,l)=>{if(s.isTextblock&&!s.hasMarkup(r,i)&&cw(n.doc,n.mapping.slice(o).map(l),r)){n.clearIncompatible(n.mapping.slice(o).map(l,1),r);let a=n.mapping.slice(o),u=a.map(l,1),c=a.map(l+s.nodeSize,1);return n.step(new hr(u,c,u+1,c-1,new v(x.from(r.create(i,null,s.marks)),0,0),1,!0)),!1}})}function cw(n,e,t){let r=n.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,t)}function fw(n,e,t,r,i){let o=n.doc.nodeAt(e);if(!o)throw new RangeError("No node at given position");t||(t=o.type);let s=t.create(r,null,i||o.marks);if(o.isLeaf)return n.replaceWith(e,e+o.nodeSize,s);if(!t.validContent(o.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new hr(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new v(x.from(s),0,0),1,!0))}function dw(n,e,t=1,r){let i=n.doc.resolve(e),o=x.empty,s=x.empty;for(let l=i.depth,a=i.depth-t,u=t-1;l>a;l--,u--){o=x.from(i.node(l).copy(o));let c=r&&r[u];s=x.from(c?c.type.create(c.attrs,s):i.node(l).copy(s))}n.step(new bn(e,e,new v(o.append(s),t,t),!0))}function hw(n,e,t){let r=new bn(e-t,e+t,v.empty,!0);n.step(r)}function pw(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let o=r.index(i);if(r.node(i).canReplaceWith(o,o,t))return r.before(i+1);if(o>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let o=r.indexAfter(i);if(r.node(i).canReplaceWith(o,o,t))return r.after(i+1);if(o0;i--)this.placed=x.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let u=this.findFittable();u?this.placeNodes(u):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let o=this.placed,s=r.depth,l=i.depth;for(;s&&l&&o.childCount==1;)o=o.firstChild.content,s--,l--;let a=new v(o,s,l);return e>-1?new hr(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new bn(r.pos,i.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,i=this.unplaced.openEnd;r1&&(i=0),o.type.spec.isolating&&i<=r){e=r;break}t=o.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let i,o=null;r?(o=Ea(this.unplaced.content,r-1).firstChild,i=o.content):i=this.unplaced.content;let s=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:u}=this.frontier[l],c,f=null;if(t==1&&(s?u.matchType(s.type)||(f=u.fillBefore(x.from(s),!1)):o&&a.compatibleContent(o.type)))return{sliceDepth:r,frontierDepth:l,parent:o,inject:f};if(t==2&&s&&(c=u.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:l,parent:o,wrap:c};if(o&&u.matchType(o.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=Ea(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new v(e,t+1,Math.max(r,i.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=Ea(e,t);if(i.childCount<=1&&t>0){let o=e.size-t<=t+i.size;this.unplaced=new v($i(e,t-1,1),t-1,o?t-1:r)}else this.unplaced=new v($i(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:i,wrap:o}){for(;this.depth>t;)this.closeFrontierNode();if(o)for(let m=0;m1||a==0||m.content.size)&&(f=w,c.push(eg(m.mark(d.allowedMarks(m.marks)),u==1?a:0,u==l.childCount?p:-1)))}let h=u==l.childCount;h||(p=-1),this.placed=Vi(this.placed,t,x.from(c)),this.frontier[t].match=f,h&&p<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,w=l;m1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:i}=this.frontier[t],o=t=0;l--){let{match:a,type:u}=this.frontier[l],c=Oa(e,l,u,a,!0);if(!c||c.childCount)continue e}return{depth:t,fit:s,move:o?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Vi(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let i=e.node(r),o=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,o)}return e}openFrontierNode(e,t=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=Vi(this.placed,this.depth,x.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(x.empty,!0);t.childCount&&(this.placed=Vi(this.placed,this.frontier.length,t))}};function $i(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy($i(n.firstChild.content,e-1,t)))}function Vi(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Vi(n.lastChild.content,e-1,t)))}function Ea(n,e){for(let t=0;t1&&(r=r.replaceChild(0,eg(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(x.empty,!0)))),n.copy(r)}function Oa(n,e,t,r,i){let o=n.node(e),s=i?n.indexAfter(e):n.index(e);if(s==o.childCount&&!t.compatibleContent(o.type))return null;let l=r.fillBefore(o.content,!0,s);return l&&!yw(t,o.content,s)?l:null}function yw(n,e,t){for(let r=t;r0;d--,p--){let h=i.node(d).type.spec;if(h.defining||h.definingAsContext||h.isolating)break;s.indexOf(d)>-1?l=d:i.before(d)==p&&s.splice(1,0,-d)}let a=s.indexOf(l),u=[],c=r.openStart;for(let d=r.content,p=0;;p++){let h=d.firstChild;if(u.push(h),p==r.openStart)break;d=h.content}for(let d=c-1;d>=0;d--){let p=u[d].type,h=Sw(p);if(h&&i.node(a).type!=p)c=d;else if(h||!p.isTextblock)break}for(let d=r.openStart;d>=0;d--){let p=(d+c+1)%(r.openStart+1),h=u[p];if(h)for(let m=0;m=0&&(n.replace(e,t,r),!(n.steps.length>f));d--){let p=s[d];p<0||(e=i.before(p),t=o.after(p))}}function tg(n,e,t,r,i){if(er){let o=i.contentMatchAt(0),s=o.fillBefore(n).append(n);n=s.append(o.matchFragment(s).fillBefore(x.empty,!0))}return n}function kw(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let i=pw(n.doc,e,r.type);i!=null&&(e=t=i)}n.replaceRange(e,t,new v(x.from(r),0,0))}function vw(n,e,t){let r=n.doc.resolve(e),i=n.doc.resolve(t),o=ng(r,i);for(let s=0;s0&&(a||r.node(l-1).canReplace(r.index(l-1),i.indexAfter(l-1))))return n.delete(r.before(l),i.after(l))}for(let s=1;s<=r.depth&&s<=i.depth;s++)if(e-r.start(s)==r.depth-s&&t>r.end(s)&&i.end(s)-t!=i.depth-s)return n.delete(r.before(s),t);n.delete(e,t)}function ng(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let i=r;i>=0;i--){let o=n.start(i);if(oe.pos+(e.depth-i)||n.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(o==e.start(i)||i==n.depth&&i==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==o-1)&&t.push(i)}return t}let rg=class js extends qe{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 Ve.fail("No node at attribute step's position");let r=Object.create(null);for(let o in t.attrs)r[o]=t.attrs[o];r[this.attr]=this.value;let i=t.type.create(r,null,t.marks);return Ve.fromReplace(e,this.pos,this.pos+1,new v(x.from(i),0,t.isLeaf?0:1))}getMap(){return Qr.empty}invert(e){return new js(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 js(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 js(t.pos,t.attr,t.value)}};qe.jsonID("attr",rg);let Yr=class extends Error{};Yr=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};Yr.prototype=Object.create(Error.prototype);Yr.prototype.constructor=Yr;Yr.prototype.name="TransformError";let xw=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new rw}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Yr(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=v.empty){let i=mw(this.doc,e,t,r);return i&&this.step(i),this}replaceWith(e,t,r){return this.replace(e,t,new v(x.from(r),0,0))}delete(e,t){return this.replace(e,t,v.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return ww(this,e,t,r),this}replaceRangeWith(e,t,r){return kw(this,e,t,r),this}deleteRange(e,t){return vw(this,e,t),this}lift(e,t){return lw(this,e,t),this}join(e,t=1){return hw(this,e,t),this}wrap(e,t){return aw(this,e,t),this}setBlockType(e,t=e,r,i=null){return uw(this,e,t,r,i),this}setNodeMarkup(e,t,r=null,i){return fw(this,e,t,r,i),this}setNodeAttribute(e,t,r){return this.step(new rg(e,t,r)),this}addNodeMark(e,t){return this.step(new rf(e,t)),this}removeNodeMark(e,t){if(!(t instanceof W)){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t=t.isInSet(r.marks),!t)return this}return this.step(new of(e,t)),this}split(e,t=1,r){return dw(this,e,t,r),this}addMark(e,t,r){return iw(this,e,t,r),this}removeMark(e,t,r){return ow(this,e,t,r),this}clearIncompatible(e,t,r){return sw(this,e,t,r),this}};const Da=Object.create(null);class P{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new ig(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=0;o--){let s=t<0?xr(e.node(0),e.node(o),e.before(o+1),e.index(o),t,r):xr(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,t,r);if(s)return s}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new et(e.node(0))}static atStart(e){return xr(e,e,0,0,1)||new et(e)}static atEnd(e){return xr(e,e,e.content.size,e.childCount,-1)||new et(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Da[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 Da)throw new RangeError("Duplicate use of selection JSON ID "+e);return Da[e]=t,t.prototype.jsonID=e,t}getBookmark(){return $.between(this.$anchor,this.$head).getBookmark()}}P.prototype.visible=!0;class ig{constructor(e,t){this.$from=e,this.$to=t}}let Vd=!1;function Bd(n){!Vd&&!n.parent.inlineContent&&(Vd=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class $ extends P{constructor(e,t=e){Bd(e),Bd(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 P.near(r);let i=e.resolve(t.map(this.anchor));return new $(i.parent.inlineContent?i:r,r)}replace(e,t=v.empty){if(super.replace(e,t),t==v.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof $&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Xl(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 $(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let i=e.resolve(t);return new this(i,r==t?i:e.resolve(r))}static between(e,t,r){let i=e.pos-t.pos;if((!r||i)&&(r=i>=0?1:-1),!t.parent.inlineContent){let o=P.findFrom(t,r,!0)||P.findFrom(t,-r,!0);if(o)t=o.$head;else return P.near(t,r)}return e.parent.inlineContent||(i==0?e=t:(e=(P.findFrom(e,-r,!0)||P.findFrom(e,r,!0)).$anchor,e.pos0?0:1);i>0?s=0;s+=i){let l=e.child(s);if(l.isAtom){if(!o&&z.isSelectable(l))return z.create(n,t-(i<0?l.nodeSize:0))}else{let a=xr(n,l,t+i,i<0?l.childCount:0,i,o);if(a)return a}t+=l.nodeSize*i}return null}function Jd(n,e,t){let r=n.steps.length-1;if(r{s==null&&(s=c)}),n.setSelection(P.near(n.doc.resolve(s),t))}const _d=1,ds=2,Wd=4;class Nw extends xw{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.curSelectionFor0}setStoredMarks(e){return this.storedMarks=e,this.updated|=ds,this}ensureMarks(e){return W.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&ds)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~ds,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||W.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let i=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),r=r??t,!e)return this.deleteRange(t,r);let o=this.storedMarks;if(!o){let s=this.doc.resolve(t);o=r==t?s.marks():s.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,i.text(e,o)),this.selection.empty||this.setSelection(P.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|=Wd,this}get scrolledIntoView(){return(this.updated&Wd)>0}}function Ud(n,e){return!e||!n?n:n.bind(e)}class Bi{constructor(e,t,r){this.name=e,this.init=Ud(t.init,r),this.apply=Ud(t.apply,r)}}const Mw=[new Bi("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Bi("selection",{init(n,e){return n.selection||P.atStart(e.doc)},apply(n){return n.selection}}),new Bi("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new Bi("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class Ta{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Mw.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 Bi(r.key,r.spec.state,r))})}}class dn{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;rr.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],o=i.spec.state;o&&o.toJSON&&(t[r]=o.toJSON.call(i,this[i.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new Ta(e.schema,e.plugins),o=new dn(i);return i.fields.forEach(s=>{if(s.name=="doc")o.doc=Tt.fromJSON(e.schema,t.doc);else if(s.name=="selection")o.selection=P.fromJSON(o.doc,t.selection);else if(s.name=="storedMarks")t.storedMarks&&(o.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],u=a.spec.state;if(a.key==s.name&&u&&u.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){o[s.name]=u.fromJSON.call(a,e,t[l],o);return}}o[s.name]=s.init(e,o)}}),o}}function og(n,e,t){for(let r in n){let i=n[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=og(i,e,{})),t[r]=i}return t}class $t{constructor(e){this.spec=e,this.props={},e.props&&og(e.props,this,this.props),this.key=e.key?e.key.key:sg("plugin")}getState(e){return e[this.key]}}const Ra=Object.create(null);function sg(n){return n in Ra?n+"$"+ ++Ra[n]:(Ra[n]=0,n+"$")}class Yo{constructor(e="key"){this.key=sg(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const lg=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function Ew(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const Ow=(n,e,t)=>{let r=Ew(n,t);if(!r)return!1;let i=ag(r);if(!i){let s=r.blockRange(),l=s&&ef(s);return l==null?!1:(e&&e(n.tr.lift(s,l).scrollIntoView()),!0)}let o=i.nodeBefore;if(!o.type.spec.isolating&&cg(n,i,e))return!0;if(r.parent.content.size==0&&(Gr(o,"end")||z.isSelectable(o))){let s=jm(n.doc,r.before(),r.after(),v.empty);if(s&&s.slice.size{let{$head:r,empty:i}=n.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;o=ag(r)}let s=o&&o.nodeBefore;return!s||!z.isSelectable(s)?!1:(e&&e(n.tr.setSelection(z.create(n.doc,o.pos-s.nodeSize)).scrollIntoView()),!0)};function ag(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 Tw(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset{let r=Tw(n,t);if(!r)return!1;let i=ug(r);if(!i)return!1;let o=i.nodeAfter;if(cg(n,i,e))return!0;if(r.parent.content.size==0&&(Gr(o,"start")||z.isSelectable(o))){let s=jm(n.doc,r.before(),r.after(),v.empty);if(s&&s.slice.size{let{$head:r,empty:i}=n.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset=0;e--){let t=n.node(e);if(n.index(e)+1{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(` -`).scrollIntoView()),!0)};function lf(n){for(let e=0;e{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let i=t.node(-1),o=t.indexAfter(-1),s=lf(i.contentMatchAt(o));if(!s||!i.canReplaceWith(o,o,s))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,s.createAndFill());a.setSelection(P.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Iw=(n,e)=>{let t=n.selection,{$from:r,$to:i}=t;if(t instanceof et||r.parent.inlineContent||i.parent.inlineContent)return!1;let o=lf(i.parent.contentMatchAt(i.indexAfter()));if(!o||!o.isTextblock)return!1;if(e){let s=(!r.parentOffset&&i.index(){let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let o=t.before();if(Js(n.doc,o))return e&&e(n.tr.split(o).scrollIntoView()),!0}let r=t.blockRange(),i=r&&ef(r);return i==null?!1:(e&&e(n.tr.lift(r,i).scrollIntoView()),!0)};function Fw(n){return(e,t)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof z&&e.selection.node.isBlock)return!r.parentOffset||!Js(e.doc,r.pos)?!1:(t&&t(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.parent.isBlock)return!1;if(t){let o=i.parentOffset==i.parent.content.size,s=e.tr;(e.selection instanceof $||e.selection instanceof et)&&s.deleteSelection();let l=r.depth==0?null:lf(r.node(-1).contentMatchAt(r.indexAfter(-1))),a=o&&l?[{type:l}]:void 0,u=Js(s.doc,s.mapping.map(r.pos),1,a);if(!a&&!u&&Js(s.doc,s.mapping.map(r.pos),1,l?[{type:l}]:void 0)&&(l&&(a=[{type:l}]),u=!0),u&&(s.split(s.mapping.map(r.pos),1,a),!o&&!r.parentOffset&&r.parent.type!=l)){let c=s.mapping.map(r.before()),f=s.doc.resolve(c);l&&r.node(-1).canReplaceWith(f.index(),f.index()+1,l)&&s.setNodeMarkup(s.mapping.map(r.before()),l)}t(s.scrollIntoView())}return!0}}const Lw=Fw(),$w=(n,e)=>(e&&e(n.tr.setSelection(new et(n.doc))),!0);function Vw(n,e,t){let r=e.nodeBefore,i=e.nodeAfter,o=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(o-1,o)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(o,o+1)||!(i.isTextblock||Hm(n.doc,e.pos))?!1:(t&&t(n.tr.clearIncompatible(e.pos,r.type,r.contentMatchAt(r.childCount)).join(e.pos).scrollIntoView()),!0)}function cg(n,e,t){let r=e.nodeBefore,i=e.nodeAfter,o,s;if(r.type.spec.isolating||i.type.spec.isolating)return!1;if(Vw(n,e,t))return!0;let l=e.parent.canReplace(e.index(),e.index()+1);if(l&&(o=(s=r.contentMatchAt(r.childCount)).findWrapping(i.type))&&s.matchType(o[0]||i.type).validEnd){if(t){let f=e.pos+i.nodeSize,d=x.empty;for(let m=o.length-1;m>=0;m--)d=x.from(o[m].create(null,d));d=x.from(r.copy(d));let p=n.tr.step(new yl(e.pos-1,f,e.pos,f,new v(d,1,0),o.length,!0)),h=f+2*o.length;Hm(p.doc,h)&&p.join(h),t(p.scrollIntoView())}return!0}let a=P.findFrom(e,1),u=a&&a.$from.blockRange(a.$to),c=u&&ef(u);if(c!=null&&c>=e.depth)return t&&t(n.tr.lift(u,c).scrollIntoView()),!0;if(l&&Gr(i,"start",!0)&&Gr(r,"end")){let f=r,d=[];for(;d.push(f),!f.isTextblock;)f=f.lastChild;let p=i,h=1;for(;!p.isTextblock;p=p.firstChild)h++;if(f.canReplace(f.childCount,f.childCount,p.content)){if(t){let m=x.empty;for(let g=d.length-1;g>=0;g--)m=x.from(d[g].copy(m));let w=n.tr.step(new yl(e.pos-d.length,e.pos+i.nodeSize,e.pos+h,e.pos+i.nodeSize-h,new v(m,d.length,0),0,!0));t(w.scrollIntoView())}return!0}}return!1}function fg(n){return function(e,t){let r=e.selection,i=n<0?r.$from:r.$to,o=i.depth;for(;i.node(o).isInline;){if(!o)return!1;o--}return i.node(o).isTextblock?(t&&t(e.tr.setSelection($.create(e.doc,n<0?i.start(o):i.end(o)))),!0):!1}}const Bw=fg(-1),Jw=fg(1);function _w(n,e,t){for(let r=0;r{if(s)return!1;s=l.inlineContent&&l.type.allowsMarkType(t)}),s)return!0}return!1}function Hd(n,e=null){return function(t,r){let{empty:i,$cursor:o,ranges:s}=t.selection;if(i&&!o||!_w(t.doc,s,n))return!1;if(r)if(o)n.isInSet(t.storedMarks||o.marks())?r(t.tr.removeStoredMark(n)):r(t.tr.addStoredMark(n.create(e)));else{let l=!1,a=t.tr;for(let u=0;!l&&u",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Kd=typeof navigator<"u"&&/Chrome\/(\d+)/.exec(navigator.userAgent),Hw=typeof navigator<"u"&&/Mac/.test(navigator.platform),jw=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Kw=Hw||Kd&&+Kd[1]<57;for(var me=0;me<10;me++)zt[48+me]=zt[96+me]=String(me);for(var me=1;me<=24;me++)zt[me+111]="F"+me;for(var me=65;me<=90;me++)zt[me]=String.fromCharCode(me+32),Sl[me]=String.fromCharCode(me);for(var ba in zt)Sl.hasOwnProperty(ba)||(Sl[ba]=zt[ba]);function uf(n){var e=Kw&&(n.ctrlKey||n.altKey||n.metaKey)||jw&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Sl:zt)[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 qw=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function Qw(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,i,o,s;for(let l=0;l127)&&(o=zt[r.keyCode])&&o!=i){let l=e[za(o,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}const hg=65535,pg=Math.pow(2,16);function Xw(n,e){return n+e*pg}function qd(n){return n&hg}function Zw(n){return(n-(n&hg))/pg}const mg=1,gg=2,Ks=4,yg=8;let Qd=class{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&yg)>0}get deletedBefore(){return(this.delInfo&(mg|Ks))>0}get deletedAfter(){return(this.delInfo&(gg|Ks))>0}get deletedAcross(){return(this.delInfo&Ks)>0}},Xr=class Cr{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&Cr.empty)return Cr.empty}recover(e){let t=0,r=qd(e);if(!this.inverted)for(let i=0;ie)break;let u=this.ranges[l+o],c=this.ranges[l+s],f=a+u;if(e<=f){let d=u?e==a?-1:e==f?1:t:t,p=a+i+(d<0?0:c);if(r)return p;let h=e==(t<0?a:f)?null:Xw(l/3,e-a),m=e==a?gg:e==f?mg:Ks;return(t<0?e!=a:e!=f)&&(m|=yg),new Qd(p,m,h)}i+=c-u}return r?e+i:new Qd(e+i,0,null)}touches(e,t){let r=0,i=qd(t),o=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;le)break;let u=this.ranges[l+o],c=a+u;if(e<=c&&l==i*3)return!0;r+=this.ranges[l+s]-u}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,o=0;i!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),i),t.openStart,t.openEnd);return Be.fromReplace(e,this.from,this.to,o)}invert(){return new wg(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 _i(t.pos,r.pos,this.mark)}merge(e){return e instanceof _i&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new _i(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 _i(t.from,t.to,e.markFromJSON(t.mark))}};Qe.jsonID("addMark",Sg);let wg=class Wi extends Qe{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 v(cf(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return Be.fromReplace(e,this.from,this.to,r)}invert(){return new Sg(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 Wi(t.pos,r.pos,this.mark)}merge(e){return e instanceof Wi&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Wi(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 Wi(t.from,t.to,e.markFromJSON(t.mark))}};Qe.jsonID("removeMark",wg);let kg=class Ui extends Qe{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Be.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return Be.fromReplace(e,this.pos,this.pos+1,new v(x.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let i=0;ir.pos?null:new qs(t.pos,r.pos,i,o,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new qs(t.from,t.to,t.gapFrom,t.gapTo,v.fromJSON(e,t.slice),t.insert,!!t.structure)}};Qe.jsonID("replaceAround",tk);function Ru(n,e,t){let r=n.resolve(e),i=t-e,o=r.depth;for(;i>0&&o>0&&r.indexAfter(o)==r.node(o).childCount;)o--,i--;if(i>0){let s=r.node(o).maybeChild(r.indexAfter(o));for(;i>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,i--}}return!1}function nk(n,e,t){let r=n.resolve(e);if(!t.content.size)return e;let i=t.content;for(let o=0;o=0;s--){let l=s==r.depth?0:r.pos<=(r.start(s+1)+r.end(s+1))/2?-1:1,a=r.index(s)+(l>0?1:0),u=r.node(s),c=!1;if(o==1)c=u.canReplace(a,a,i);else{let f=u.contentMatchAt(a).findWrapping(i.firstChild.type);c=f&&u.canReplaceWith(a,a,f[0])}if(c)return l==0?r.pos:l<0?r.before(s+1):r.after(s+1)}return null}let rk=class Qs extends Qe{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 Be.fail("No node at attribute step's position");let r=Object.create(null);for(let o in t.attrs)r[o]=t.attrs[o];r[this.attr]=this.value;let i=t.type.create(r,null,t.marks);return Be.fromReplace(e,this.pos,this.pos+1,new v(x.from(i),0,t.isLeaf?0:1))}getMap(){return Xr.empty}invert(e){return new Qs(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 Qs(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 Qs(t.pos,t.attr,t.value)}};Qe.jsonID("attr",rk);let ko=class extends Error{};ko=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};ko.prototype=Object.create(Error.prototype);ko.prototype.constructor=ko;ko.prototype.name="TransformError";const ge=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},vo=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let Au=null;const _t=function(n,e,t){let r=Au||(Au=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},ik=function(){Au=null},lr=function(n,e,t,r){return t&&(Yd(n,e,t,r,-1)||Yd(n,e,t,r,1))},ok=/^(img|br|input|textarea|hr)$/i;function Yd(n,e,t,r,i){for(;;){if(n==t&&e==r)return!0;if(e==(i<0?0:at(n))){let o=n.parentNode;if(!o||o.nodeType!=1||Go(n)||ok.test(n.nodeName)||n.contentEditable=="false")return!1;e=ge(n)+(i<0?0:1),n=o}else if(n.nodeType==1){if(n=n.childNodes[e+(i<0?-1:0)],n.contentEditable=="false")return!1;e=i<0?at(n):0}else return!1}}function at(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function sk(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=at(n)}else if(n.parentNode&&!Go(n))e=ge(n),n=n.parentNode;else return null}}function lk(n,e){for(;;){if(n.nodeType==3&&e2),ot=Zr||(It?/Mac/.test(It.platform):!1),fk=It?/Win/.test(It.platform):!1,wt=/Android \d/.test(zn),Xo=!!Gd&&"webkitFontSmoothing"in Gd.documentElement.style,dk=Xo?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function hk(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 Bt(n,e){return typeof n=="number"?n:n[e]}function pk(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 Xd(n,e,t){let r=n.someProp("scrollThreshold")||0,i=n.someProp("scrollMargin")||5,o=n.dom.ownerDocument;for(let s=t||n.dom;s;s=vo(s)){if(s.nodeType!=1)continue;let l=s,a=l==o.body,u=a?hk(o):pk(l),c=0,f=0;if(e.topu.bottom-Bt(r,"bottom")&&(f=e.bottom-e.top>u.bottom-u.top?e.top+Bt(i,"top")-u.top:e.bottom-u.bottom+Bt(i,"bottom")),e.leftu.right-Bt(r,"right")&&(c=e.right-u.right+Bt(i,"right")),c||f)if(a)o.defaultView.scrollBy(c,f);else{let d=l.scrollLeft,p=l.scrollTop;f&&(l.scrollTop+=f),c&&(l.scrollLeft+=c);let h=l.scrollLeft-d,m=l.scrollTop-p;e={left:e.left-h,top:e.top-m,right:e.right-h,bottom:e.bottom-m}}if(a||/^(fixed|sticky)$/.test(getComputedStyle(s).position))break}}function mk(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,i;for(let o=(e.left+e.right)/2,s=t+1;s=t-20){r=l,i=a.top;break}}return{refDOM:r,refTop:i,stack:Ng(n.dom)}}function Ng(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=vo(r));return e}function gk({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;Mg(t,r==0?0:r-e)}function Mg(n,e){for(let t=0;t=l){s=Math.max(h.bottom,s),l=Math.min(h.top,l);let m=h.left>e.left?h.left-e.left:h.right=(h.left+h.right)/2?1:0));continue}}else h.top>e.top&&!a&&h.left<=e.left&&h.right>=e.left&&(a=c,u={left:Math.max(h.left,Math.min(h.right,e.left)),top:h.top});!t&&(e.left>=h.right&&e.top>=h.top||e.left>=h.left&&e.top>=h.bottom)&&(o=f+1)}}return!t&&a&&(t=a,i=u,r=0),t&&t.nodeType==3?Sk(t,i):!t||r&&t.nodeType==1?{node:n,offset:o}:Eg(t,i)}function Sk(n,e){let t=n.nodeValue.length,r=document.createRange();for(let i=0;i=(o.left+o.right)/2?1:0)}}return{node:n,offset:0}}function ff(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function wk(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left(s.left+s.right)/2?1:-1}return n.docView.posFromDOM(r,i,o)}function vk(n,e,t,r){let i=-1;for(let o=e,s=!1;o!=n.dom;){let l=n.docView.nearestDesc(o,!0);if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)){let a=l.dom.getBoundingClientRect();if(l.node.isBlock&&l.parent&&(!s&&a.left>r.left||a.top>r.top?i=l.posBefore:(!s&&a.right-1?i:n.docView.posFromDOM(e,t,-1)}function Og(n,e,t){let r=n.childNodes.length;if(r&&t.tope.top&&i++}let u;Xo&&i&&r.nodeType==1&&(u=r.childNodes[i-1]).nodeType==1&&u.contentEditable=="false"&&u.getBoundingClientRect().top>=e.top&&i--,r==n.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(l=vk(n,r,i,e))}l==null&&(l=kk(n,s,e));let a=n.docView.nearestDesc(s,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Zd(n){return n.top=0&&i==r.nodeValue.length?(a--,c=1):t<0?a--:u++,wi(nn(_t(r,a,u),c),c<0)}if(!n.state.doc.resolve(e-(o||0)).parent.inlineContent){if(o==null&&i&&(t<0||i==at(r))){let a=r.childNodes[i-1];if(a.nodeType==1)return Pa(a.getBoundingClientRect(),!1)}if(o==null&&i=0)}if(o==null&&i&&(t<0||i==at(r))){let a=r.childNodes[i-1],u=a.nodeType==3?_t(a,at(a)-(s?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(u)return wi(nn(u,1),!1)}if(o==null&&i=0)}function wi(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 Pa(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 Tg(n,e,t){let r=n.state,i=n.root.activeElement;r!=e&&n.updateState(e),i!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),i!=n.dom&&i&&i.focus()}}function Nk(n,e,t){let r=e.selection,i=t=="up"?r.$from:r.$to;return Tg(n,e,()=>{let{node:o}=n.docView.domFromPos(i.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(o,!0);if(!l)break;if(l.node.isBlock){o=l.contentDOM||l.dom;break}o=l.dom.parentNode}let s=Dg(n,i.pos,1);for(let l=o.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=_t(l,0,l.nodeValue.length).getClientRects();else continue;for(let u=0;uc.top+1&&(t=="up"?s.top-c.top>(c.bottom-s.top)*2:c.bottom-s.bottom>(s.bottom-c.top)*2))return!1}}return!0})}const Mk=/[\u0590-\u08ac]/;function Ek(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,o=!i,s=i==r.parent.content.size,l=n.domSelection();return l?!Mk.test(r.parent.textContent)||!l.modify?t=="left"||t=="backward"?o:s:Tg(n,e,()=>{let{focusNode:a,focusOffset:u,anchorNode:c,anchorOffset:f}=n.domSelectionRange(),d=l.caretBidiLevel;l.modify("move",t,"character");let p=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:h,focusOffset:m}=n.domSelectionRange(),w=h&&!p.contains(h.nodeType==1?h:h.parentNode)||a==h&&u==m;try{l.collapse(c,f),a&&(a!=c||u!=f)&&l.extend&&l.extend(a,u)}catch{}return d!=null&&(l.caretBidiLevel=d),w}):r.pos==r.start()||r.pos==r.end()}let eh=null,th=null,nh=!1;function Ok(n,e,t){return eh==e&&th==t?nh:(eh=e,th=t,nh=t=="up"||t=="down"?Nk(n,e,t):Ek(n,e,t))}const ft=0,rh=1,Qn=2,Pt=3;let Zo=class{constructor(e,t,r,i){this.parent=e,this.children=t,this.dom=r,this.contentDOM=i,this.dirty=ft,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;tge(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!1;break}if(o.previousSibling)break}if(i==null&&t==e.childNodes.length)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!0;break}if(o.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,i=e;i;i=i.parentNode){let o=this.getDesc(i),s;if(o&&(!t||o.node))if(r&&(s=o.nodeDOM)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):s==e))r=!1;else return o}}getDesc(e){let t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let i=e;i;i=i.parentNode){let o=this.getDesc(i);if(o)return o.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;te||s instanceof Ig){i=e-o;break}o=l}if(i)return this.children[r].domFromPos(i-this.children[r].border,t);for(let o;r&&!(o=this.children[r-1]).size&&o instanceof Rg&&o.side>=0;r--);if(t<=0){let o,s=!0;for(;o=r?this.children[r-1]:null,!(!o||o.dom.parentNode==this.contentDOM);r--,s=!1);return o&&t&&s&&!o.border&&!o.domAtom?o.domFromPos(o.size,t):{node:this.contentDOM,offset:o?ge(o.dom)+1:0}}else{let o,s=!0;for(;o=r=c&&t<=u-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,c);e=s;for(let f=l;f>0;f--){let d=this.children[f-1];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(1)){i=ge(d.dom)+1;break}e-=d.size}i==-1&&(i=0)}if(i>-1&&(u>t||l==this.children.length-1)){t=u;for(let c=l+1;cp&&st){let p=l;l=a,a=p}let d=document.createRange();d.setEnd(a.node,a.offset),d.setStart(l.node,l.offset),u.removeAllRanges(),u.addRange(d)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let r=0,i=0;i=r:er){let l=r+o.border,a=s-o.border;if(e>=l&&t<=a){this.dirty=e==r||t==s?Qn:rh,e==l&&t==a&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=Pt:o.markDirty(e-l,t-l);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?Qn:Pt}r=s}this.dirty=Qn}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?Qn:rh;t.dirty{if(!o)return i;if(o.parent)return o.parent.posBeforeChild(o)})),!t.type.spec.raw){if(s.nodeType!=1){let l=document.createElement("span");l.appendChild(s),s=l}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=t,this.widget=t,o=this}matchesWidget(e){return this.dirty==ft&&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 side(){return this.widget.type.side}},Dk=class extends Zo{constructor(e,t,r,i){super(e,[],t,null),this.textDOM=r,this.text=i}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}},wl=class Pu extends Zo{constructor(e,t,r,i){super(e,[],r,i),this.mark=t}static create(e,t,r,i){let o=i.nodeViews[t.type.name],s=o&&o(t,i,r);return(!s||!s.dom)&&(s=pi.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new Pu(e,t,s.dom,s.contentDOM||s.dom)}parseRule(){return this.dirty&Pt||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Pt&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=ft){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty0&&(o=$u(o,0,e,r));for(let l=0;l{if(!a)return s;if(a.parent)return a.parent.posBeforeChild(a)},r,i),c=u&&u.dom,f=u&&u.contentDOM;if(t.isText){if(!c)c=document.createTextNode(t.text);else if(c.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else c||({dom:c,contentDOM:f}=pi.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!f&&!t.isText&&c.nodeName!="BR"&&(c.hasAttribute("contenteditable")||(c.contentEditable="false"),t.type.spec.draggable&&(c.draggable=!0));let d=c;return c=Lg(c,r,t),u?a=new Tk(e,t,r,i,c,f||null,d,u,o,s+1):t.isText?new bg(e,t,r,i,c,d,o):new Ag(e,t,r,i,c,f||null,d,o,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let r=this.children[t];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>x.empty)}return e}matchesNode(e,t,r){return this.dirty==ft&&e.eq(this.node)&&Lu(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,i=t,o=e.composing?this.localCompositionInfo(e,t):null,s=o&&o.pos>-1?o:null,l=o&&o.pos<0,a=new Ak(this,s&&s.node,e);Ik(this.node,this.innerDeco,(u,c,f)=>{u.spec.marks?a.syncToMarks(u.spec.marks,r,e):u.type.side>=0&&!f&&a.syncToMarks(c==this.node.childCount?W.none:this.node.child(c).marks,r,e),a.placeWidget(u,e,i)},(u,c,f,d)=>{a.syncToMarks(u.marks,r,e);let p;a.findNodeMatch(u,c,f,d)||l&&e.state.selection.from>i&&e.state.selection.to-1&&a.updateNodeAt(u,c,f,p,e)||a.updateNextNode(u,c,f,e,d,i)||a.addNode(u,c,f,e,i),i+=u.nodeSize}),a.syncToMarks([],r,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==Qn)&&(s&&this.protectLocalComposition(e,s),Pg(this.contentDOM,this.children,e),Zr&&Pk(this.dom))}localCompositionInfo(e,t){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof $)||rt+this.node.content.size)return null;let o=e.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let s=o.nodeValue,l=Fk(this.node.content,s,r-t,i-t);return l<0?null:{node:o,pos:l,text:s}}else return{node:o,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:i}){if(this.getDesc(t))return;let o=t;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let s=new Dk(this,o,t,i);e.input.compositionNodes.push(s),this.children=$u(this.children,r,r+i.length,e,s)}update(e,t,r,i){return this.dirty==Pt||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,i),!0)}updateInner(e,t,r,i){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=ft}updateOuterDeco(e){if(Lu(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Fg(this.dom,this.nodeDOM,Fu(this.outerDeco,this.node,t),Fu(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 ih(n,e,t,r,i){Lg(r,e,n);let o=new Vr(void 0,n,e,t,r,r,r,i,0);return o.contentDOM&&o.updateChildren(i,0),o}let bg=class zg extends Vr{constructor(e,t,r,i,o,s,l){super(e,t,r,i,o,null,s,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,i){return this.dirty==Pt||this.dirty!=ft&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=ft||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=ft,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,r){let i=this.node.cut(e,t),o=document.createTextNode(i.text);return new zg(this.parent,i,this.outerDeco,this.innerDeco,o,o,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=Pt)}get domAtom(){return!1}isText(e){return this.node.text==e}},Ig=class extends Zo{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==ft&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}};class Tk extends Vr{constructor(e,t,r,i,o,s,l,a,u,c){super(e,t,r,i,o,s,l,u,c),this.spec=a}update(e,t,r,i){if(this.dirty==Pt)return!1;if(this.spec.update){let o=this.spec.update(e,t,r);return o&&this.updateInner(e,t,r,i),o}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,r,i){this.spec.setSelection?this.spec.setSelection(e,t,r):super.setSelection(e,t,r,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function Pg(n,e,t){let r=n.firstChild,i=!1;for(let o=0;o>1,s=Math.min(o,e.length);for(;i-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let a=wl.create(this.top,e[o],t,r);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,o++}}findNodeMatch(e,t,r,i){let o=-1,s;if(i>=this.preMatch.index&&(s=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&s.matchesNode(e,t,r))o=this.top.children.indexOf(s,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l0;){let l;for(;;)if(r){let u=t.children[r-1];if(u instanceof wl)t=u,r=u.children.length;else{l=u,r--;break}}else{if(t==e)break e;r=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=n.child(i-1))break;--i,o.set(l,i),s.push(l)}}return{index:i,matched:o,matches:s.reverse()}}function zk(n,e){return n.type.side-e.type.side}function Ik(n,e,t,r){let i=e.locals(n),o=0;if(i.length==0){for(let u=0;uo;)l.push(i[s++]);let h=o+d.nodeSize;if(d.isText){let w=h;s!w.inline):l.slice();r(d,m,e.forChild(o,d),p),o=h}}function Pk(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 Fk(n,e,t,r){for(let i=0,o=0;i=t){if(o>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let u=l=0&&u+e.length+l>=t)return l+u;if(t==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function $u(n,e,t,r,i){let o=[];for(let s=0,l=0;s=t||c<=e?o.push(a):(ut&&o.push(a.slice(t-u,a.size,r)))}return o}function df(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let i=n.docView.nearestDesc(t.focusNode),o=i&&i.size==0,s=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(s<0)return null;let l=r.resolve(s),a,u;if(Zl(t)){for(a=l;i&&!i.node;)i=i.parent;let c=i.node;if(i&&c.isAtom&&z.isSelectable(c)&&i.parent&&!(c.isInline&&ak(t.focusNode,t.focusOffset,i.dom))){let f=i.posBefore;u=new z(s==f?l:r.resolve(f))}}else{let c=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(c<0)return null;a=r.resolve(c)}if(!u){let c=e=="pointer"||n.state.selection.head{(t.anchorNode!=r||t.anchorOffset!=i)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!$g(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function $k(n){let e=n.domSelection(),t=document.createRange();if(!e)return;let r=n.cursorWrapper.dom,i=r.nodeName=="IMG";i?t.setStart(r.parentNode,ge(r)+1):t.setStart(r,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!i&&!n.state.selection.visible&&We&&Sn<=11&&(r.disabled=!0,r.disabled=!1)}function Vg(n,e){if(e instanceof z){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(uh(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else uh(n)}function uh(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function hf(n,e,t,r){return n.someProp("createSelectionBetween",i=>i(n,e,t))||$.between(e,t,r)}function ch(n){return n.editable&&!n.hasFocus()?!1:Bg(n)}function Bg(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 Vk(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return lr(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Vu(n,e){let{$anchor:t,$head:r}=n.selection,i=e>0?t.max(r):t.min(r),o=i.parent.inlineContent?i.depth?n.doc.resolve(e>0?i.after():i.before()):null:i;return o&&P.findFrom(o,e)}function rn(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function fh(n,e,t){let r=n.state.selection;if(r instanceof $)if(t.indexOf("s")>-1){let{$head:i}=r,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let s=n.state.doc.resolve(i.pos+o.nodeSize*(e<0?-1:1));return rn(n,new $(r.$anchor,s))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let i=Vu(n.state,e);return i&&i instanceof z?rn(n,i):!1}else if(!(ot&&t.indexOf("m")>-1)){let i=r.$head,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,s;if(!o||o.isText)return!1;let l=e<0?i.pos-o.nodeSize:i.pos;return o.isAtom||(s=n.docView.descAt(l))&&!s.contentDOM?z.isSelectable(o)?rn(n,new z(e<0?n.state.doc.resolve(i.pos-o.nodeSize):i)):Xo?rn(n,new $(n.state.doc.resolve(e<0?l:l+o.nodeSize))):!1:!1}}else return!1;else{if(r instanceof z&&r.node.isInline)return rn(n,new $(e>0?r.$to:r.$from));{let i=Vu(n.state,e);return i?rn(n,i):!1}}}function kl(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function io(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function Sr(n,e){return e<0?Bk(n):Jk(n)}function Bk(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i,o,s=!1;for(Ct&&t.nodeType==1&&r0){if(t.nodeType!=1)break;{let l=t.childNodes[r-1];if(io(l,-1))i=t,o=--r;else if(l.nodeType==3)t=l,r=t.nodeValue.length;else break}}else{if(Jg(t))break;{let l=t.previousSibling;for(;l&&io(l,-1);)i=t.parentNode,o=ge(l),l=l.previousSibling;if(l)t=l,r=kl(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}s?Bu(n,t,r):i&&Bu(n,i,o)}function Jk(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i=kl(t),o,s;for(;;)if(r{n.state==i&&qt(n)},50)}function dh(n,e){let t=n.state.doc.resolve(e);if(!(Ne||fk)&&t.parent.inlineContent){let i=n.coordsAtPos(e);if(e>t.start()){let o=n.coordsAtPos(e-1),s=(o.top+o.bottom)/2;if(s>i.top&&s1)return o.lefti.top&&s1)return o.left>i.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function hh(n,e,t){let r=n.state.selection;if(r instanceof $&&!r.empty||t.indexOf("s")>-1||ot&&t.indexOf("m")>-1)return!1;let{$from:i,$to:o}=r;if(!i.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let s=Vu(n.state,e);if(s&&s instanceof z)return rn(n,s)}if(!i.parent.inlineContent){let s=e<0?i:o,l=r instanceof et?P.near(s,e):P.findFrom(s,e);return l?rn(n,l):!1}return!1}function ph(n,e){if(!(n.state.selection instanceof $))return!0;let{$head:t,$anchor:r,empty:i}=n.state.selection;if(!t.sameParent(r))return!0;if(!i)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let o=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(o&&!o.isText){let s=n.state.tr;return e<0?s.delete(t.pos-o.nodeSize,t.pos):s.delete(t.pos,t.pos+o.nodeSize),n.dispatch(s),!0}return!1}function mh(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function Uk(n){if(!be||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;mh(n,r,"true"),setTimeout(()=>mh(n,r,"false"),20)}return!1}function Hk(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function jk(n,e){let t=e.keyCode,r=Hk(e);if(t==8||ot&&t==72&&r=="c")return ph(n,-1)||Sr(n,-1);if(t==46&&!e.shiftKey||ot&&t==68&&r=="c")return ph(n,1)||Sr(n,1);if(t==13||t==27)return!0;if(t==37||ot&&t==66&&r=="c"){let i=t==37?dh(n,n.state.selection.from)=="ltr"?-1:1:-1;return fh(n,i,r)||Sr(n,i)}else if(t==39||ot&&t==70&&r=="c"){let i=t==39?dh(n,n.state.selection.from)=="ltr"?1:-1:1;return fh(n,i,r)||Sr(n,i)}else{if(t==38||ot&&t==80&&r=="c")return hh(n,-1,r)||Sr(n,-1);if(t==40||ot&&t==78&&r=="c")return Uk(n)||hh(n,1,r)||Sr(n,1);if(r==(ot?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function _g(n,e){n.someProp("transformCopied",p=>{e=p(e,n)});let t=[],{content:r,openStart:i,openEnd:o}=e;for(;i>1&&o>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,o--;let p=r.firstChild;t.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),r=p.content}let s=n.someProp("clipboardSerializer")||pi.fromSchema(n.state.schema),l=qg(),a=l.createElement("div");a.appendChild(s.serializeFragment(r,{document:l}));let u=a.firstChild,c,f=0;for(;u&&u.nodeType==1&&(c=Kg[u.nodeName.toLowerCase()]);){for(let p=c.length-1;p>=0;p--){let h=l.createElement(c[p]);for(;a.firstChild;)h.appendChild(a.firstChild);a.appendChild(h),f++}u=a.firstChild}u&&u.nodeType==1&&u.setAttribute("data-pm-slice",`${i} ${o}${f?` -${f}`:""} ${JSON.stringify(t)}`);let d=n.someProp("clipboardTextSerializer",p=>p(e,n))||e.content.textBetween(0,e.content.size,` +`),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t)}readStyles(e,t){let r=e.style;if(r&&r.length)for(let i=0;i!a.clearMark(u)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,r,i){let o,s;if(t.node)if(s=this.parser.schema.nodes[t.node],s.isLeaf)this.insertNode(s.create(t.attrs),r)||this.leafFallback(e,r);else{let a=this.enter(s,t.attrs||null,r,t.preserveWhitespace);a&&(o=!0,r=a)}else{let a=this.parser.schema.marks[t.mark];r=r.concat(a.create(t.attrs))}let l=this.top;if(s&&s.isLeaf)this.findInside(e);else if(i)this.addElement(e,r,i);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r));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)}o&&this.sync(l)&&this.open--}addAll(e,t,r,i){let o=r||0;for(let s=r?e.childNodes[r]:e.firstChild,l=i==null?null:e.childNodes[i];s!=l;s=s.nextSibling,++o)this.findAtPoint(e,o),this.addDOM(s,t);this.findAtPoint(e,o)}findPlace(e,t){let r,i;for(let o=this.open;o>=0;o--){let s=this.nodes[o],l=s.findWrapping(e);if(l&&(!r||r.length>l.length)&&(r=l,i=s,!l.length)||s.solid)break}if(!r)return null;this.sync(i);for(let o=0;o(s.type?s.type.allowsMarkType(u.type):zd(u.type,e))?(a=u.addToSet(a),!1):!0),this.nodes.push(new fs(e,t,a,i,null,l)),this.open++,r}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),o=-(r?r.depth+1:0)+(i?0:1),s=(l,a)=>{for(;l>=0;l--){let u=t[l];if(u==""){if(l==t.length-1||l==0)continue;for(;a>=o;a--)if(s(l-1,a))return!0;return!1}else{let c=a>0||a==0&&i?this.nodes[a].type:r&&a>=o?r.node(a-o).type:null;if(!c||c.name!=u&&c.groups.indexOf(u)==-1)return!1;a--}}return!0};return s(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}}function WS(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Pm.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function US(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function bd(n){let e={};for(let t in n)e[t]=n[t];return e}function zd(n,e){let t=e.schema.nodes;for(let r in t){let i=t[r];if(!i.allowsMarkType(n))continue;let o=[],s=l=>{o.push(l);for(let a=0;a{if(o.length||s.marks.length){let l=0,a=0;for(;l=0;i--){let o=this.serializeMark(e.marks[i],e.isInline,t);o&&((o.contentDOM||o.dom).appendChild(r),r=o.dom)}return r}serializeMark(e,t,r={}){let i=this.marks[e.type.name];return i&&$s(va(r),i(e,t),null,e.attrs)}static renderSpec(e,t,r=null,i){return $s(e,t,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new pi(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Id(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return Id(e.marks)}}function Id(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function va(n){return n.document||window.document}const Pd=new WeakMap;function HS(n){let e=Pd.get(n);return e===void 0&&Pd.set(n,e=jS(n)),e}function jS(n){let e=null;function t(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let i=0;i-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let s=i.indexOf(" ");s>0&&(t=i.slice(0,s),i=i.slice(s+1));let l,a=t?n.createElementNS(t,i):n.createElement(i),u=e[1],c=1;if(u&&typeof u=="object"&&u.nodeType==null&&!Array.isArray(u)){c=2;for(let f in u)if(u[f]!=null){let d=f.indexOf(" ");d>0?a.setAttributeNS(f.slice(0,d),f.slice(d+1),u[f]):a.setAttribute(f,u[f])}}for(let f=c;fc)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:p,contentDOM:h}=$s(n,d,t,r);if(a.appendChild(p),h){if(l)throw new RangeError("Multiple content holes");l=h}}}return{dom:a,contentDOM:l}}const Fm=65535,Lm=Math.pow(2,16);function KS(n,e){return n+e*Lm}function Fd(n){return n&Fm}function qS(n){return(n-(n&Fm))/Lm}const $m=1,Vm=2,Vs=4,Bm=8;let Ld=class{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&Bm)>0}get deletedBefore(){return(this.delInfo&($m|Vs))>0}get deletedAfter(){return(this.delInfo&(Vm|Vs))>0}get deletedAcross(){return(this.delInfo&Vs)>0}},qr=class kr{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&kr.empty)return kr.empty}recover(e){let t=0,r=Fd(e);if(!this.inverted)for(let i=0;ie)break;let u=this.ranges[l+o],c=this.ranges[l+s],f=a+u;if(e<=f){let d=u?e==a?-1:e==f?1:t:t,p=a+i+(d<0?0:c);if(r)return p;let h=e==(t<0?a:f)?null:KS(l/3,e-a),m=e==a?Vm:e==f?$m:Vs;return(t<0?e!=a:e!=f)&&(m|=Bm),new Ld(p,m,h)}i+=c-u}return r?e+i:new Ld(e+i,0,null)}touches(e,t){let r=0,i=Fd(t),o=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;le)break;let u=this.ranges[l+o],c=a+u;if(e<=c&&l==i*3)return!0;r+=this.ranges[l+s]-u}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,o=0;i!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),i),t.openStart,t.openEnd);return $e.fromReplace(e,this.from,this.to,o)}invert(){return new _m(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 Ti(t.pos,r.pos,this.mark)}merge(e){return e instanceof Ti&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ti(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 Ti(t.from,t.to,e.markFromJSON(t.mark))}};Ke.jsonID("addMark",Jm);let _m=class Di extends Ke{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 v(Xc(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return $e.fromReplace(e,this.from,this.to,r)}invert(){return new Jm(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 Di(t.pos,r.pos,this.mark)}merge(e){return e instanceof Di&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Di(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 Di(t.from,t.to,e.markFromJSON(t.mark))}};Ke.jsonID("removeMark",_m);let Wm=class Ri extends Ke{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return $e.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return $e.fromReplace(e,this.pos,this.pos+1,new v(x.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let i=0;ir.pos?null:new Bs(t.pos,r.pos,i,o,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Bs(t.from,t.to,t.gapFrom,t.gapTo,v.fromJSON(e,t.slice),t.insert,!!t.structure)}};Ke.jsonID("replaceAround",yl);function Mu(n,e,t){let r=n.resolve(e),i=t-e,o=r.depth;for(;i>0&&o>0&&r.indexAfter(o)==r.node(o).childCount;)o--,i--;if(i>0){let s=r.node(o).maybeChild(r.indexAfter(o));for(;i>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,i--}}return!1}function QS(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function ef(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth;;--r){let i=n.$from.node(r),o=n.$from.index(r),s=n.$to.indexAfter(r);if(ro;u--,c--){let f=i.node(u),d=i.index(u);if(f.type.spec.isolating)return!1;let p=f.content.cutByIndex(d,f.childCount),h=r&&r[c]||f;if(h!=f&&(p=p.replaceChild(0,h.type.create(h.attrs))),!f.canReplace(d+1,f.childCount)||!h.type.validContent(p))return!1}let l=i.indexAfter(o),a=r&&r[0];return i.node(o).canReplaceWith(l,l,a?a.type:i.node(o+1).type)}function Hm(n,e){let t=n.resolve(e),r=t.index();return YS(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function YS(n,e){return!!(n&&e&&!n.isLeaf&&n.canAppend(e))}function jm(n,e,t=e,r=v.empty){if(e==t&&!r.size)return null;let i=n.resolve(e),o=n.resolve(t);return GS(i,o,r)?new Zc(e,t,r):new XS(i,o,r).fit()}function GS(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}let XS=class{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=x.empty;for(let i=0;i<=e.depth;i++){let o=e.node(i);this.frontier.push({type:o.type,match:o.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=x.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let u=this.findFittable();u?this.placeNodes(u):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let o=this.placed,s=r.depth,l=i.depth;for(;s&&l&&o.childCount==1;)o=o.firstChild.content,s--,l--;let a=new v(o,s,l);return e>-1?new yl(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new Zc(r.pos,i.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,i=this.unplaced.openEnd;r1&&(i=0),o.type.spec.isolating&&i<=r){e=r;break}t=o.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let i,o=null;r?(o=Ca(this.unplaced.content,r-1).firstChild,i=o.content):i=this.unplaced.content;let s=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:u}=this.frontier[l],c,f=null;if(t==1&&(s?u.matchType(s.type)||(f=u.fillBefore(x.from(s),!1)):o&&a.compatibleContent(o.type)))return{sliceDepth:r,frontierDepth:l,parent:o,inject:f};if(t==2&&s&&(c=u.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:l,parent:o,wrap:c};if(o&&u.matchType(o.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=Ca(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new v(e,t+1,Math.max(r,i.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=Ca(e,t);if(i.childCount<=1&&t>0){let o=e.size-t<=t+i.size;this.unplaced=new v(Ai(e,t-1,1),t-1,o?t-1:r)}else this.unplaced=new v(Ai(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:i,wrap:o}){for(;this.depth>t;)this.closeFrontierNode();if(o)for(let m=0;m1||a==0||m.content.size)&&(f=w,c.push(Km(m.mark(d.allowedMarks(m.marks)),u==1?a:0,u==l.childCount?p:-1)))}let h=u==l.childCount;h||(p=-1),this.placed=bi(this.placed,t,x.from(c)),this.frontier[t].match=f,h&&p<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,w=l;m1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:i}=this.frontier[t],o=t=0;l--){let{match:a,type:u}=this.frontier[l],c=Na(e,l,u,a,!0);if(!c||c.childCount)continue e}return{depth:t,fit:s,move:o?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=bi(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let i=e.node(r),o=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,o)}return e}openFrontierNode(e,t=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=bi(this.placed,this.depth,x.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(x.empty,!0);t.childCount&&(this.placed=bi(this.placed,this.frontier.length,t))}};function Ai(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Ai(n.firstChild.content,e-1,t)))}function bi(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(bi(n.lastChild.content,e-1,t)))}function Ca(n,e){for(let t=0;t1&&(r=r.replaceChild(0,Km(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(x.empty,!0)))),n.copy(r)}function Na(n,e,t,r,i){let o=n.node(e),s=i?n.indexAfter(e):n.index(e);if(s==o.childCount&&!t.compatibleContent(o.type))return null;let l=r.fillBefore(o.content,!0,s);return l&&!ZS(t,o.content,s)?l:null}function ZS(n,e,t){for(let r=t;r0}get deletedBefore(){return(this.delInfo&(Ym|Ws))>0}get deletedAfter(){return(this.delInfo&(Gm|Ws))>0}get deletedAcross(){return(this.delInfo&Ws)>0}},Qr=class vr{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&vr.empty)return vr.empty}recover(e){let t=0,r=$d(e);if(!this.inverted)for(let i=0;ie)break;let u=this.ranges[l+o],c=this.ranges[l+s],f=a+u;if(e<=f){let d=u?e==a?-1:e==f?1:t:t,p=a+i+(d<0?0:c);if(r)return p;let h=e==(t<0?a:f)?null:tw(l/3,e-a),m=e==a?Gm:e==f?Ym:Ws;return(t<0?e!=a:e!=f)&&(m|=Xm),new Eu(p,m,h)}i+=c-u}return r?e+i:new Eu(e+i,0,null)}touches(e,t){let r=0,i=$d(t),o=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;le)break;let u=this.ranges[l+o],c=a+u;if(e<=c&&l==i*3)return!0;r+=this.ranges[l+s]-u}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,o=0;i=0;t--){let i=e.getMirror(t);this.appendMap(e.maps[t].invert(),i!=null&&i>t?r-i-1:void 0)}}invert(){let e=new Us;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;ro&&a!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),i),t.openStart,t.openEnd);return Ve.fromReplace(e,this.from,this.to,o)}invert(){return new qo(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 Ii(t.pos,r.pos,this.mark)}merge(e){return e instanceof Ii&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ii(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 Ii(t.from,t.to,e.markFromJSON(t.mark))}};qe.jsonID("addMark",nf);let qo=class Pi extends qe{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 v(tf(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return Ve.fromReplace(e,this.from,this.to,r)}invert(){return new nf(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 Pi(t.pos,r.pos,this.mark)}merge(e){return e instanceof Pi&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Pi(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 Pi(t.from,t.to,e.markFromJSON(t.mark))}};qe.jsonID("removeMark",qo);let rf=class Fi extends qe{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Ve.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return Ve.fromReplace(e,this.pos,this.pos+1,new v(x.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let i=0;ir.pos?null:new Hs(t.pos,r.pos,i,o,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Hs(t.from,t.to,t.gapFrom,t.gapTo,v.fromJSON(e,t.slice),t.insert,!!t.structure)}};qe.jsonID("replaceAround",hr);function Tu(n,e,t){let r=n.resolve(e),i=t-e,o=r.depth;for(;i>0&&o>0&&r.indexAfter(o)==r.node(o).childCount;)o--,i--;if(i>0){let s=r.node(o).maybeChild(r.indexAfter(o));for(;i>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,i--}}return!1}function iw(n,e,t,r){let i=[],o=[],s,l;n.doc.nodesBetween(e,t,(a,u,c)=>{if(!a.isInline)return;let f=a.marks;if(!r.isInSet(f)&&c.type.allowsMarkType(r.type)){let d=Math.max(u,e),p=Math.min(u+a.nodeSize,t),h=r.addToSet(f);for(let m=0;mn.step(a)),o.forEach(a=>n.step(a))}function ow(n,e,t,r){let i=[],o=0;n.doc.nodesBetween(e,t,(s,l)=>{if(!s.isInline)return;o++;let a=null;if(r instanceof Ko){let u=s.marks,c;for(;c=r.isInSet(u);)(a||(a=[])).push(c),u=c.removeFromSet(u)}else r?r.isInSet(s.marks)&&(a=[r]):a=s.marks;if(a&&a.length){let u=Math.min(l+s.nodeSize,t);for(let c=0;cn.step(new qo(s.from,s.to,s.style)))}function sw(n,e,t,r=t.contentMatch){let i=n.doc.nodeAt(e),o=[],s=e+1;for(let l=0;l=0;l--)n.step(o[l])}function lw(n,e,t){let{$from:r,$to:i,depth:o}=e,s=r.before(o+1),l=i.after(o+1),a=s,u=l,c=x.empty,f=0;for(let h=o,m=!1;h>t;h--)m||r.index(h)>0?(m=!0,c=x.from(r.node(h).copy(c)),f++):a--;let d=x.empty,p=0;for(let h=o,m=!1;h>t;h--)m||i.after(h+1)=0;s--){if(r.size){let l=t[s].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=x.from(t[s].type.create(t[s].attrs,r))}let i=e.start,o=e.end;n.step(new hr(i,o,i,o,new v(r,0,0),t.length,!0))}function uw(n,e,t,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=n.steps.length;n.doc.nodesBetween(e,t,(s,l)=>{if(s.isTextblock&&!s.hasMarkup(r,i)&&cw(n.doc,n.mapping.slice(o).map(l),r)){n.clearIncompatible(n.mapping.slice(o).map(l,1),r);let a=n.mapping.slice(o),u=a.map(l,1),c=a.map(l+s.nodeSize,1);return n.step(new hr(u,c,u+1,c-1,new v(x.from(r.create(i,null,s.marks)),0,0),1,!0)),!1}})}function cw(n,e,t){let r=n.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,t)}function fw(n,e,t,r,i){let o=n.doc.nodeAt(e);if(!o)throw new RangeError("No node at given position");t||(t=o.type);let s=t.create(r,null,i||o.marks);if(o.isLeaf)return n.replaceWith(e,e+o.nodeSize,s);if(!t.validContent(o.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new hr(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new v(x.from(s),0,0),1,!0))}function dw(n,e,t=1,r){let i=n.doc.resolve(e),o=x.empty,s=x.empty;for(let l=i.depth,a=i.depth-t,u=t-1;l>a;l--,u--){o=x.from(i.node(l).copy(o));let c=r&&r[u];s=x.from(c?c.type.create(c.attrs,s):i.node(l).copy(s))}n.step(new bn(e,e,new v(o.append(s),t,t),!0))}function hw(n,e,t){let r=new bn(e-t,e+t,v.empty,!0);n.step(r)}function pw(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let o=r.index(i);if(r.node(i).canReplaceWith(o,o,t))return r.before(i+1);if(o>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let o=r.indexAfter(i);if(r.node(i).canReplaceWith(o,o,t))return r.after(i+1);if(o0;i--)this.placed=x.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let u=this.findFittable();u?this.placeNodes(u):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let o=this.placed,s=r.depth,l=i.depth;for(;s&&l&&o.childCount==1;)o=o.firstChild.content,s--,l--;let a=new v(o,s,l);return e>-1?new hr(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new bn(r.pos,i.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,i=this.unplaced.openEnd;r1&&(i=0),o.type.spec.isolating&&i<=r){e=r;break}t=o.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let i,o=null;r?(o=Ea(this.unplaced.content,r-1).firstChild,i=o.content):i=this.unplaced.content;let s=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:u}=this.frontier[l],c,f=null;if(t==1&&(s?u.matchType(s.type)||(f=u.fillBefore(x.from(s),!1)):o&&a.compatibleContent(o.type)))return{sliceDepth:r,frontierDepth:l,parent:o,inject:f};if(t==2&&s&&(c=u.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:l,parent:o,wrap:c};if(o&&u.matchType(o.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=Ea(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new v(e,t+1,Math.max(r,i.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=Ea(e,t);if(i.childCount<=1&&t>0){let o=e.size-t<=t+i.size;this.unplaced=new v(Li(e,t-1,1),t-1,o?t-1:r)}else this.unplaced=new v(Li(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:i,wrap:o}){for(;this.depth>t;)this.closeFrontierNode();if(o)for(let m=0;m1||a==0||m.content.size)&&(f=w,c.push(eg(m.mark(d.allowedMarks(m.marks)),u==1?a:0,u==l.childCount?p:-1)))}let h=u==l.childCount;h||(p=-1),this.placed=$i(this.placed,t,x.from(c)),this.frontier[t].match=f,h&&p<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,w=l;m1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:i}=this.frontier[t],o=t=0;l--){let{match:a,type:u}=this.frontier[l],c=Oa(e,l,u,a,!0);if(!c||c.childCount)continue e}return{depth:t,fit:s,move:o?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=$i(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let i=e.node(r),o=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,o)}return e}openFrontierNode(e,t=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=$i(this.placed,this.depth,x.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(x.empty,!0);t.childCount&&(this.placed=$i(this.placed,this.frontier.length,t))}};function Li(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Li(n.firstChild.content,e-1,t)))}function $i(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy($i(n.lastChild.content,e-1,t)))}function Ea(n,e){for(let t=0;t1&&(r=r.replaceChild(0,eg(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(x.empty,!0)))),n.copy(r)}function Oa(n,e,t,r,i){let o=n.node(e),s=i?n.indexAfter(e):n.index(e);if(s==o.childCount&&!t.compatibleContent(o.type))return null;let l=r.fillBefore(o.content,!0,s);return l&&!yw(t,o.content,s)?l:null}function yw(n,e,t){for(let r=t;r0;d--,p--){let h=i.node(d).type.spec;if(h.defining||h.definingAsContext||h.isolating)break;s.indexOf(d)>-1?l=d:i.before(d)==p&&s.splice(1,0,-d)}let a=s.indexOf(l),u=[],c=r.openStart;for(let d=r.content,p=0;;p++){let h=d.firstChild;if(u.push(h),p==r.openStart)break;d=h.content}for(let d=c-1;d>=0;d--){let p=u[d].type,h=Sw(p);if(h&&i.node(a).type!=p)c=d;else if(h||!p.isTextblock)break}for(let d=r.openStart;d>=0;d--){let p=(d+c+1)%(r.openStart+1),h=u[p];if(h)for(let m=0;m=0&&(n.replace(e,t,r),!(n.steps.length>f));d--){let p=s[d];p<0||(e=i.before(p),t=o.after(p))}}function tg(n,e,t,r,i){if(er){let o=i.contentMatchAt(0),s=o.fillBefore(n).append(n);n=s.append(o.matchFragment(s).fillBefore(x.empty,!0))}return n}function kw(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let i=pw(n.doc,e,r.type);i!=null&&(e=t=i)}n.replaceRange(e,t,new v(x.from(r),0,0))}function vw(n,e,t){let r=n.doc.resolve(e),i=n.doc.resolve(t),o=ng(r,i);for(let s=0;s0&&(a||r.node(l-1).canReplace(r.index(l-1),i.indexAfter(l-1))))return n.delete(r.before(l),i.after(l))}for(let s=1;s<=r.depth&&s<=i.depth;s++)if(e-r.start(s)==r.depth-s&&t>r.end(s)&&i.end(s)-t!=i.depth-s)return n.delete(r.before(s),t);n.delete(e,t)}function ng(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let i=r;i>=0;i--){let o=n.start(i);if(oe.pos+(e.depth-i)||n.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(o==e.start(i)||i==n.depth&&i==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==o-1)&&t.push(i)}return t}let rg=class js extends qe{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 Ve.fail("No node at attribute step's position");let r=Object.create(null);for(let o in t.attrs)r[o]=t.attrs[o];r[this.attr]=this.value;let i=t.type.create(r,null,t.marks);return Ve.fromReplace(e,this.pos,this.pos+1,new v(x.from(i),0,t.isLeaf?0:1))}getMap(){return Qr.empty}invert(e){return new js(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 js(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 js(t.pos,t.attr,t.value)}};qe.jsonID("attr",rg);let Yr=class extends Error{};Yr=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};Yr.prototype=Object.create(Error.prototype);Yr.prototype.constructor=Yr;Yr.prototype.name="TransformError";let xw=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new rw}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Yr(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=v.empty){let i=mw(this.doc,e,t,r);return i&&this.step(i),this}replaceWith(e,t,r){return this.replace(e,t,new v(x.from(r),0,0))}delete(e,t){return this.replace(e,t,v.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return ww(this,e,t,r),this}replaceRangeWith(e,t,r){return kw(this,e,t,r),this}deleteRange(e,t){return vw(this,e,t),this}lift(e,t){return lw(this,e,t),this}join(e,t=1){return hw(this,e,t),this}wrap(e,t){return aw(this,e,t),this}setBlockType(e,t=e,r,i=null){return uw(this,e,t,r,i),this}setNodeMarkup(e,t,r=null,i){return fw(this,e,t,r,i),this}setNodeAttribute(e,t,r){return this.step(new rg(e,t,r)),this}addNodeMark(e,t){return this.step(new rf(e,t)),this}removeNodeMark(e,t){if(!(t instanceof W)){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t=t.isInSet(r.marks),!t)return this}return this.step(new of(e,t)),this}split(e,t=1,r){return dw(this,e,t,r),this}addMark(e,t,r){return iw(this,e,t,r),this}removeMark(e,t,r){return ow(this,e,t,r),this}clearIncompatible(e,t,r){return sw(this,e,t,r),this}};const Ta=Object.create(null);class P{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new ig(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=0;o--){let s=t<0?xr(e.node(0),e.node(o),e.before(o+1),e.index(o),t,r):xr(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,t,r);if(s)return s}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new et(e.node(0))}static atStart(e){return xr(e,e,0,0,1)||new et(e)}static atEnd(e){return xr(e,e,e.content.size,e.childCount,-1)||new et(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Ta[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 Ta)throw new RangeError("Duplicate use of selection JSON ID "+e);return Ta[e]=t,t.prototype.jsonID=e,t}getBookmark(){return $.between(this.$anchor,this.$head).getBookmark()}}P.prototype.visible=!0;class ig{constructor(e,t){this.$from=e,this.$to=t}}let Vd=!1;function Bd(n){!Vd&&!n.parent.inlineContent&&(Vd=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class $ extends P{constructor(e,t=e){Bd(e),Bd(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 P.near(r);let i=e.resolve(t.map(this.anchor));return new $(i.parent.inlineContent?i:r,r)}replace(e,t=v.empty){if(super.replace(e,t),t==v.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof $&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Xl(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 $(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let i=e.resolve(t);return new this(i,r==t?i:e.resolve(r))}static between(e,t,r){let i=e.pos-t.pos;if((!r||i)&&(r=i>=0?1:-1),!t.parent.inlineContent){let o=P.findFrom(t,r,!0)||P.findFrom(t,-r,!0);if(o)t=o.$head;else return P.near(t,r)}return e.parent.inlineContent||(i==0?e=t:(e=(P.findFrom(e,-r,!0)||P.findFrom(e,r,!0)).$anchor,e.pos0?0:1);i>0?s=0;s+=i){let l=e.child(s);if(l.isAtom){if(!o&&z.isSelectable(l))return z.create(n,t-(i<0?l.nodeSize:0))}else{let a=xr(n,l,t+i,i<0?l.childCount:0,i,o);if(a)return a}t+=l.nodeSize*i}return null}function Jd(n,e,t){let r=n.steps.length-1;if(r{s==null&&(s=c)}),n.setSelection(P.near(n.doc.resolve(s),t))}const _d=1,ds=2,Wd=4;class Nw extends xw{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.curSelectionFor0}setStoredMarks(e){return this.storedMarks=e,this.updated|=ds,this}ensureMarks(e){return W.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&ds)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~ds,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||W.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let i=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),r=r??t,!e)return this.deleteRange(t,r);let o=this.storedMarks;if(!o){let s=this.doc.resolve(t);o=r==t?s.marks():s.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,i.text(e,o)),this.selection.empty||this.setSelection(P.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|=Wd,this}get scrolledIntoView(){return(this.updated&Wd)>0}}function Ud(n,e){return!e||!n?n:n.bind(e)}class Vi{constructor(e,t,r){this.name=e,this.init=Ud(t.init,r),this.apply=Ud(t.apply,r)}}const Mw=[new Vi("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Vi("selection",{init(n,e){return n.selection||P.atStart(e.doc)},apply(n){return n.selection}}),new Vi("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new Vi("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class Da{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Mw.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 Vi(r.key,r.spec.state,r))})}}class dn{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;rr.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],o=i.spec.state;o&&o.toJSON&&(t[r]=o.toJSON.call(i,this[i.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new Da(e.schema,e.plugins),o=new dn(i);return i.fields.forEach(s=>{if(s.name=="doc")o.doc=Dt.fromJSON(e.schema,t.doc);else if(s.name=="selection")o.selection=P.fromJSON(o.doc,t.selection);else if(s.name=="storedMarks")t.storedMarks&&(o.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],u=a.spec.state;if(a.key==s.name&&u&&u.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){o[s.name]=u.fromJSON.call(a,e,t[l],o);return}}o[s.name]=s.init(e,o)}}),o}}function og(n,e,t){for(let r in n){let i=n[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=og(i,e,{})),t[r]=i}return t}class $t{constructor(e){this.spec=e,this.props={},e.props&&og(e.props,this,this.props),this.key=e.key?e.key.key:sg("plugin")}getState(e){return e[this.key]}}const Ra=Object.create(null);function sg(n){return n in Ra?n+"$"+ ++Ra[n]:(Ra[n]=0,n+"$")}class Qo{constructor(e="key"){this.key=sg(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const lg=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function Ew(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const Ow=(n,e,t)=>{let r=Ew(n,t);if(!r)return!1;let i=ag(r);if(!i){let s=r.blockRange(),l=s&&ef(s);return l==null?!1:(e&&e(n.tr.lift(s,l).scrollIntoView()),!0)}let o=i.nodeBefore;if(!o.type.spec.isolating&&cg(n,i,e))return!0;if(r.parent.content.size==0&&(Gr(o,"end")||z.isSelectable(o))){let s=jm(n.doc,r.before(),r.after(),v.empty);if(s&&s.slice.size{let{$head:r,empty:i}=n.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;o=ag(r)}let s=o&&o.nodeBefore;return!s||!z.isSelectable(s)?!1:(e&&e(n.tr.setSelection(z.create(n.doc,o.pos-s.nodeSize)).scrollIntoView()),!0)};function ag(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 Dw(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset{let r=Dw(n,t);if(!r)return!1;let i=ug(r);if(!i)return!1;let o=i.nodeAfter;if(cg(n,i,e))return!0;if(r.parent.content.size==0&&(Gr(o,"start")||z.isSelectable(o))){let s=jm(n.doc,r.before(),r.after(),v.empty);if(s&&s.slice.size{let{$head:r,empty:i}=n.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset=0;e--){let t=n.node(e);if(n.index(e)+1{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(` +`).scrollIntoView()),!0)};function lf(n){for(let e=0;e{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let i=t.node(-1),o=t.indexAfter(-1),s=lf(i.contentMatchAt(o));if(!s||!i.canReplaceWith(o,o,s))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,s.createAndFill());a.setSelection(P.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Iw=(n,e)=>{let t=n.selection,{$from:r,$to:i}=t;if(t instanceof et||r.parent.inlineContent||i.parent.inlineContent)return!1;let o=lf(i.parent.contentMatchAt(i.indexAfter()));if(!o||!o.isTextblock)return!1;if(e){let s=(!r.parentOffset&&i.index(){let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let o=t.before();if(Js(n.doc,o))return e&&e(n.tr.split(o).scrollIntoView()),!0}let r=t.blockRange(),i=r&&ef(r);return i==null?!1:(e&&e(n.tr.lift(r,i).scrollIntoView()),!0)};function Fw(n){return(e,t)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof z&&e.selection.node.isBlock)return!r.parentOffset||!Js(e.doc,r.pos)?!1:(t&&t(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.parent.isBlock)return!1;if(t){let o=i.parentOffset==i.parent.content.size,s=e.tr;(e.selection instanceof $||e.selection instanceof et)&&s.deleteSelection();let l=r.depth==0?null:lf(r.node(-1).contentMatchAt(r.indexAfter(-1))),a=o&&l?[{type:l}]:void 0,u=Js(s.doc,s.mapping.map(r.pos),1,a);if(!a&&!u&&Js(s.doc,s.mapping.map(r.pos),1,l?[{type:l}]:void 0)&&(l&&(a=[{type:l}]),u=!0),u&&(s.split(s.mapping.map(r.pos),1,a),!o&&!r.parentOffset&&r.parent.type!=l)){let c=s.mapping.map(r.before()),f=s.doc.resolve(c);l&&r.node(-1).canReplaceWith(f.index(),f.index()+1,l)&&s.setNodeMarkup(s.mapping.map(r.before()),l)}t(s.scrollIntoView())}return!0}}const Lw=Fw(),$w=(n,e)=>(e&&e(n.tr.setSelection(new et(n.doc))),!0);function Vw(n,e,t){let r=e.nodeBefore,i=e.nodeAfter,o=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(o-1,o)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(o,o+1)||!(i.isTextblock||Hm(n.doc,e.pos))?!1:(t&&t(n.tr.clearIncompatible(e.pos,r.type,r.contentMatchAt(r.childCount)).join(e.pos).scrollIntoView()),!0)}function cg(n,e,t){let r=e.nodeBefore,i=e.nodeAfter,o,s;if(r.type.spec.isolating||i.type.spec.isolating)return!1;if(Vw(n,e,t))return!0;let l=e.parent.canReplace(e.index(),e.index()+1);if(l&&(o=(s=r.contentMatchAt(r.childCount)).findWrapping(i.type))&&s.matchType(o[0]||i.type).validEnd){if(t){let f=e.pos+i.nodeSize,d=x.empty;for(let m=o.length-1;m>=0;m--)d=x.from(o[m].create(null,d));d=x.from(r.copy(d));let p=n.tr.step(new yl(e.pos-1,f,e.pos,f,new v(d,1,0),o.length,!0)),h=f+2*o.length;Hm(p.doc,h)&&p.join(h),t(p.scrollIntoView())}return!0}let a=P.findFrom(e,1),u=a&&a.$from.blockRange(a.$to),c=u&&ef(u);if(c!=null&&c>=e.depth)return t&&t(n.tr.lift(u,c).scrollIntoView()),!0;if(l&&Gr(i,"start",!0)&&Gr(r,"end")){let f=r,d=[];for(;d.push(f),!f.isTextblock;)f=f.lastChild;let p=i,h=1;for(;!p.isTextblock;p=p.firstChild)h++;if(f.canReplace(f.childCount,f.childCount,p.content)){if(t){let m=x.empty;for(let g=d.length-1;g>=0;g--)m=x.from(d[g].copy(m));let w=n.tr.step(new yl(e.pos-d.length,e.pos+i.nodeSize,e.pos+h,e.pos+i.nodeSize-h,new v(m,d.length,0),0,!0));t(w.scrollIntoView())}return!0}}return!1}function fg(n){return function(e,t){let r=e.selection,i=n<0?r.$from:r.$to,o=i.depth;for(;i.node(o).isInline;){if(!o)return!1;o--}return i.node(o).isTextblock?(t&&t(e.tr.setSelection($.create(e.doc,n<0?i.start(o):i.end(o)))),!0):!1}}const Bw=fg(-1),Jw=fg(1);function _w(n,e,t){for(let r=0;r{if(s)return!1;s=l.inlineContent&&l.type.allowsMarkType(t)}),s)return!0}return!1}function Hd(n,e=null){return function(t,r){let{empty:i,$cursor:o,ranges:s}=t.selection;if(i&&!o||!_w(t.doc,s,n))return!1;if(r)if(o)n.isInSet(t.storedMarks||o.marks())?r(t.tr.removeStoredMark(n)):r(t.tr.addStoredMark(n.create(e)));else{let l=!1,a=t.tr;for(let u=0;!l&&u",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Kd=typeof navigator<"u"&&/Chrome\/(\d+)/.exec(navigator.userAgent),Hw=typeof navigator<"u"&&/Mac/.test(navigator.platform),jw=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Kw=Hw||Kd&&+Kd[1]<57;for(var ge=0;ge<10;ge++)zt[48+ge]=zt[96+ge]=String(ge);for(var ge=1;ge<=24;ge++)zt[ge+111]="F"+ge;for(var ge=65;ge<=90;ge++)zt[ge]=String.fromCharCode(ge+32),Sl[ge]=String.fromCharCode(ge);for(var ba in zt)Sl.hasOwnProperty(ba)||(Sl[ba]=zt[ba]);function uf(n){var e=Kw&&(n.ctrlKey||n.altKey||n.metaKey)||jw&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Sl:zt)[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 qw=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function Qw(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,i,o,s;for(let l=0;l127)&&(o=zt[r.keyCode])&&o!=i){let l=e[za(o,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}const hg=65535,pg=Math.pow(2,16);function Xw(n,e){return n+e*pg}function qd(n){return n&hg}function Zw(n){return(n-(n&hg))/pg}const mg=1,gg=2,Ks=4,yg=8;let Qd=class{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&yg)>0}get deletedBefore(){return(this.delInfo&(mg|Ks))>0}get deletedAfter(){return(this.delInfo&(gg|Ks))>0}get deletedAcross(){return(this.delInfo&Ks)>0}},Xr=class Cr{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&Cr.empty)return Cr.empty}recover(e){let t=0,r=qd(e);if(!this.inverted)for(let i=0;ie)break;let u=this.ranges[l+o],c=this.ranges[l+s],f=a+u;if(e<=f){let d=u?e==a?-1:e==f?1:t:t,p=a+i+(d<0?0:c);if(r)return p;let h=e==(t<0?a:f)?null:Xw(l/3,e-a),m=e==a?gg:e==f?mg:Ks;return(t<0?e!=a:e!=f)&&(m|=yg),new Qd(p,m,h)}i+=c-u}return r?e+i:new Qd(e+i,0,null)}touches(e,t){let r=0,i=qd(t),o=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;le)break;let u=this.ranges[l+o],c=a+u;if(e<=c&&l==i*3)return!0;r+=this.ranges[l+s]-u}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,o=0;i!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),i),t.openStart,t.openEnd);return Be.fromReplace(e,this.from,this.to,o)}invert(){return new wg(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 Ji(t.pos,r.pos,this.mark)}merge(e){return e instanceof Ji&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ji(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 Ji(t.from,t.to,e.markFromJSON(t.mark))}};Qe.jsonID("addMark",Sg);let wg=class _i extends Qe{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 v(cf(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return Be.fromReplace(e,this.from,this.to,r)}invert(){return new Sg(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 _i(t.pos,r.pos,this.mark)}merge(e){return e instanceof _i&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new _i(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 _i(t.from,t.to,e.markFromJSON(t.mark))}};Qe.jsonID("removeMark",wg);let kg=class Wi extends Qe{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Be.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return Be.fromReplace(e,this.pos,this.pos+1,new v(x.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let i=0;ir.pos?null:new qs(t.pos,r.pos,i,o,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new qs(t.from,t.to,t.gapFrom,t.gapTo,v.fromJSON(e,t.slice),t.insert,!!t.structure)}};Qe.jsonID("replaceAround",tk);function Ru(n,e,t){let r=n.resolve(e),i=t-e,o=r.depth;for(;i>0&&o>0&&r.indexAfter(o)==r.node(o).childCount;)o--,i--;if(i>0){let s=r.node(o).maybeChild(r.indexAfter(o));for(;i>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,i--}}return!1}function nk(n,e,t){let r=n.resolve(e);if(!t.content.size)return e;let i=t.content;for(let o=0;o=0;s--){let l=s==r.depth?0:r.pos<=(r.start(s+1)+r.end(s+1))/2?-1:1,a=r.index(s)+(l>0?1:0),u=r.node(s),c=!1;if(o==1)c=u.canReplace(a,a,i);else{let f=u.contentMatchAt(a).findWrapping(i.firstChild.type);c=f&&u.canReplaceWith(a,a,f[0])}if(c)return l==0?r.pos:l<0?r.before(s+1):r.after(s+1)}return null}let rk=class Qs extends Qe{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 Be.fail("No node at attribute step's position");let r=Object.create(null);for(let o in t.attrs)r[o]=t.attrs[o];r[this.attr]=this.value;let i=t.type.create(r,null,t.marks);return Be.fromReplace(e,this.pos,this.pos+1,new v(x.from(i),0,t.isLeaf?0:1))}getMap(){return Xr.empty}invert(e){return new Qs(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 Qs(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 Qs(t.pos,t.attr,t.value)}};Qe.jsonID("attr",rk);let wo=class extends Error{};wo=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};wo.prototype=Object.create(Error.prototype);wo.prototype.constructor=wo;wo.prototype.name="TransformError";const ye=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},ko=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let Au=null;const _t=function(n,e,t){let r=Au||(Au=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},ik=function(){Au=null},lr=function(n,e,t,r){return t&&(Yd(n,e,t,r,-1)||Yd(n,e,t,r,1))},ok=/^(img|br|input|textarea|hr)$/i;function Yd(n,e,t,r,i){for(;;){if(n==t&&e==r)return!0;if(e==(i<0?0:at(n))){let o=n.parentNode;if(!o||o.nodeType!=1||Yo(n)||ok.test(n.nodeName)||n.contentEditable=="false")return!1;e=ye(n)+(i<0?0:1),n=o}else if(n.nodeType==1){if(n=n.childNodes[e+(i<0?-1:0)],n.contentEditable=="false")return!1;e=i<0?at(n):0}else return!1}}function at(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function sk(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=at(n)}else if(n.parentNode&&!Yo(n))e=ye(n),n=n.parentNode;else return null}}function lk(n,e){for(;;){if(n.nodeType==3&&e2),ot=Zr||(It?/Mac/.test(It.platform):!1),fk=It?/Win/.test(It.platform):!1,wt=/Android \d/.test(zn),Go=!!Gd&&"webkitFontSmoothing"in Gd.documentElement.style,dk=Go?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function hk(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 Bt(n,e){return typeof n=="number"?n:n[e]}function pk(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 Xd(n,e,t){let r=n.someProp("scrollThreshold")||0,i=n.someProp("scrollMargin")||5,o=n.dom.ownerDocument;for(let s=t||n.dom;s;s=ko(s)){if(s.nodeType!=1)continue;let l=s,a=l==o.body,u=a?hk(o):pk(l),c=0,f=0;if(e.topu.bottom-Bt(r,"bottom")&&(f=e.bottom-e.top>u.bottom-u.top?e.top+Bt(i,"top")-u.top:e.bottom-u.bottom+Bt(i,"bottom")),e.leftu.right-Bt(r,"right")&&(c=e.right-u.right+Bt(i,"right")),c||f)if(a)o.defaultView.scrollBy(c,f);else{let d=l.scrollLeft,p=l.scrollTop;f&&(l.scrollTop+=f),c&&(l.scrollLeft+=c);let h=l.scrollLeft-d,m=l.scrollTop-p;e={left:e.left-h,top:e.top-m,right:e.right-h,bottom:e.bottom-m}}if(a||/^(fixed|sticky)$/.test(getComputedStyle(s).position))break}}function mk(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,i;for(let o=(e.left+e.right)/2,s=t+1;s=t-20){r=l,i=a.top;break}}return{refDOM:r,refTop:i,stack:Ng(n.dom)}}function Ng(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=ko(r));return e}function gk({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;Mg(t,r==0?0:r-e)}function Mg(n,e){for(let t=0;t=l){s=Math.max(h.bottom,s),l=Math.min(h.top,l);let m=h.left>e.left?h.left-e.left:h.right=(h.left+h.right)/2?1:0));continue}}else h.top>e.top&&!a&&h.left<=e.left&&h.right>=e.left&&(a=c,u={left:Math.max(h.left,Math.min(h.right,e.left)),top:h.top});!t&&(e.left>=h.right&&e.top>=h.top||e.left>=h.left&&e.top>=h.bottom)&&(o=f+1)}}return!t&&a&&(t=a,i=u,r=0),t&&t.nodeType==3?Sk(t,i):!t||r&&t.nodeType==1?{node:n,offset:o}:Eg(t,i)}function Sk(n,e){let t=n.nodeValue.length,r=document.createRange();for(let i=0;i=(o.left+o.right)/2?1:0)}}return{node:n,offset:0}}function ff(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function wk(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left(s.left+s.right)/2?1:-1}return n.docView.posFromDOM(r,i,o)}function vk(n,e,t,r){let i=-1;for(let o=e,s=!1;o!=n.dom;){let l=n.docView.nearestDesc(o,!0);if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)){let a=l.dom.getBoundingClientRect();if(l.node.isBlock&&l.parent&&(!s&&a.left>r.left||a.top>r.top?i=l.posBefore:(!s&&a.right-1?i:n.docView.posFromDOM(e,t,-1)}function Og(n,e,t){let r=n.childNodes.length;if(r&&t.tope.top&&i++}let u;Go&&i&&r.nodeType==1&&(u=r.childNodes[i-1]).nodeType==1&&u.contentEditable=="false"&&u.getBoundingClientRect().top>=e.top&&i--,r==n.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(l=vk(n,r,i,e))}l==null&&(l=kk(n,s,e));let a=n.docView.nearestDesc(s,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Zd(n){return n.top=0&&i==r.nodeValue.length?(a--,c=1):t<0?a--:u++,Si(nn(_t(r,a,u),c),c<0)}if(!n.state.doc.resolve(e-(o||0)).parent.inlineContent){if(o==null&&i&&(t<0||i==at(r))){let a=r.childNodes[i-1];if(a.nodeType==1)return Pa(a.getBoundingClientRect(),!1)}if(o==null&&i=0)}if(o==null&&i&&(t<0||i==at(r))){let a=r.childNodes[i-1],u=a.nodeType==3?_t(a,at(a)-(s?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(u)return Si(nn(u,1),!1)}if(o==null&&i=0)}function Si(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 Pa(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 Dg(n,e,t){let r=n.state,i=n.root.activeElement;r!=e&&n.updateState(e),i!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),i!=n.dom&&i&&i.focus()}}function Nk(n,e,t){let r=e.selection,i=t=="up"?r.$from:r.$to;return Dg(n,e,()=>{let{node:o}=n.docView.domFromPos(i.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(o,!0);if(!l)break;if(l.node.isBlock){o=l.contentDOM||l.dom;break}o=l.dom.parentNode}let s=Tg(n,i.pos,1);for(let l=o.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=_t(l,0,l.nodeValue.length).getClientRects();else continue;for(let u=0;uc.top+1&&(t=="up"?s.top-c.top>(c.bottom-s.top)*2:c.bottom-s.bottom>(s.bottom-c.top)*2))return!1}}return!0})}const Mk=/[\u0590-\u08ac]/;function Ek(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,o=!i,s=i==r.parent.content.size,l=n.domSelection();return l?!Mk.test(r.parent.textContent)||!l.modify?t=="left"||t=="backward"?o:s:Dg(n,e,()=>{let{focusNode:a,focusOffset:u,anchorNode:c,anchorOffset:f}=n.domSelectionRange(),d=l.caretBidiLevel;l.modify("move",t,"character");let p=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:h,focusOffset:m}=n.domSelectionRange(),w=h&&!p.contains(h.nodeType==1?h:h.parentNode)||a==h&&u==m;try{l.collapse(c,f),a&&(a!=c||u!=f)&&l.extend&&l.extend(a,u)}catch{}return d!=null&&(l.caretBidiLevel=d),w}):r.pos==r.start()||r.pos==r.end()}let eh=null,th=null,nh=!1;function Ok(n,e,t){return eh==e&&th==t?nh:(eh=e,th=t,nh=t=="up"||t=="down"?Nk(n,e,t):Ek(n,e,t))}const ft=0,rh=1,Qn=2,Pt=3;let Xo=class{constructor(e,t,r,i){this.parent=e,this.children=t,this.dom=r,this.contentDOM=i,this.dirty=ft,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;tye(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!1;break}if(o.previousSibling)break}if(i==null&&t==e.childNodes.length)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!0;break}if(o.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,i=e;i;i=i.parentNode){let o=this.getDesc(i),s;if(o&&(!t||o.node))if(r&&(s=o.nodeDOM)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):s==e))r=!1;else return o}}getDesc(e){let t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let i=e;i;i=i.parentNode){let o=this.getDesc(i);if(o)return o.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;te||s instanceof Ig){i=e-o;break}o=l}if(i)return this.children[r].domFromPos(i-this.children[r].border,t);for(let o;r&&!(o=this.children[r-1]).size&&o instanceof Rg&&o.side>=0;r--);if(t<=0){let o,s=!0;for(;o=r?this.children[r-1]:null,!(!o||o.dom.parentNode==this.contentDOM);r--,s=!1);return o&&t&&s&&!o.border&&!o.domAtom?o.domFromPos(o.size,t):{node:this.contentDOM,offset:o?ye(o.dom)+1:0}}else{let o,s=!0;for(;o=r=c&&t<=u-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,c);e=s;for(let f=l;f>0;f--){let d=this.children[f-1];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(1)){i=ye(d.dom)+1;break}e-=d.size}i==-1&&(i=0)}if(i>-1&&(u>t||l==this.children.length-1)){t=u;for(let c=l+1;cp&&st){let p=l;l=a,a=p}let d=document.createRange();d.setEnd(a.node,a.offset),d.setStart(l.node,l.offset),u.removeAllRanges(),u.addRange(d)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let r=0,i=0;i=r:er){let l=r+o.border,a=s-o.border;if(e>=l&&t<=a){this.dirty=e==r||t==s?Qn:rh,e==l&&t==a&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=Pt:o.markDirty(e-l,t-l);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?Qn:Pt}r=s}this.dirty=Qn}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?Qn:rh;t.dirty{if(!o)return i;if(o.parent)return o.parent.posBeforeChild(o)})),!t.type.spec.raw){if(s.nodeType!=1){let l=document.createElement("span");l.appendChild(s),s=l}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=t,this.widget=t,o=this}matchesWidget(e){return this.dirty==ft&&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 side(){return this.widget.type.side}},Tk=class extends Xo{constructor(e,t,r,i){super(e,[],t,null),this.textDOM=r,this.text=i}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}},wl=class Pu extends Xo{constructor(e,t,r,i){super(e,[],r,i),this.mark=t}static create(e,t,r,i){let o=i.nodeViews[t.type.name],s=o&&o(t,i,r);return(!s||!s.dom)&&(s=pi.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new Pu(e,t,s.dom,s.contentDOM||s.dom)}parseRule(){return this.dirty&Pt||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Pt&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=ft){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty0&&(o=$u(o,0,e,r));for(let l=0;l{if(!a)return s;if(a.parent)return a.parent.posBeforeChild(a)},r,i),c=u&&u.dom,f=u&&u.contentDOM;if(t.isText){if(!c)c=document.createTextNode(t.text);else if(c.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else c||({dom:c,contentDOM:f}=pi.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!f&&!t.isText&&c.nodeName!="BR"&&(c.hasAttribute("contenteditable")||(c.contentEditable="false"),t.type.spec.draggable&&(c.draggable=!0));let d=c;return c=Lg(c,r,t),u?a=new Dk(e,t,r,i,c,f||null,d,u,o,s+1):t.isText?new bg(e,t,r,i,c,d,o):new Ag(e,t,r,i,c,f||null,d,o,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let r=this.children[t];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>x.empty)}return e}matchesNode(e,t,r){return this.dirty==ft&&e.eq(this.node)&&Lu(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,i=t,o=e.composing?this.localCompositionInfo(e,t):null,s=o&&o.pos>-1?o:null,l=o&&o.pos<0,a=new Ak(this,s&&s.node,e);Ik(this.node,this.innerDeco,(u,c,f)=>{u.spec.marks?a.syncToMarks(u.spec.marks,r,e):u.type.side>=0&&!f&&a.syncToMarks(c==this.node.childCount?W.none:this.node.child(c).marks,r,e),a.placeWidget(u,e,i)},(u,c,f,d)=>{a.syncToMarks(u.marks,r,e);let p;a.findNodeMatch(u,c,f,d)||l&&e.state.selection.from>i&&e.state.selection.to-1&&a.updateNodeAt(u,c,f,p,e)||a.updateNextNode(u,c,f,e,d,i)||a.addNode(u,c,f,e,i),i+=u.nodeSize}),a.syncToMarks([],r,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==Qn)&&(s&&this.protectLocalComposition(e,s),Pg(this.contentDOM,this.children,e),Zr&&Pk(this.dom))}localCompositionInfo(e,t){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof $)||rt+this.node.content.size)return null;let o=e.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let s=o.nodeValue,l=Fk(this.node.content,s,r-t,i-t);return l<0?null:{node:o,pos:l,text:s}}else return{node:o,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:i}){if(this.getDesc(t))return;let o=t;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let s=new Tk(this,o,t,i);e.input.compositionNodes.push(s),this.children=$u(this.children,r,r+i.length,e,s)}update(e,t,r,i){return this.dirty==Pt||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,i),!0)}updateInner(e,t,r,i){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=ft}updateOuterDeco(e){if(Lu(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Fg(this.dom,this.nodeDOM,Fu(this.outerDeco,this.node,t),Fu(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 ih(n,e,t,r,i){Lg(r,e,n);let o=new Vr(void 0,n,e,t,r,r,r,i,0);return o.contentDOM&&o.updateChildren(i,0),o}let bg=class zg extends Vr{constructor(e,t,r,i,o,s,l){super(e,t,r,i,o,null,s,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,i){return this.dirty==Pt||this.dirty!=ft&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=ft||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=ft,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,r){let i=this.node.cut(e,t),o=document.createTextNode(i.text);return new zg(this.parent,i,this.outerDeco,this.innerDeco,o,o,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=Pt)}get domAtom(){return!1}isText(e){return this.node.text==e}},Ig=class extends Xo{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==ft&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}};class Dk extends Vr{constructor(e,t,r,i,o,s,l,a,u,c){super(e,t,r,i,o,s,l,u,c),this.spec=a}update(e,t,r,i){if(this.dirty==Pt)return!1;if(this.spec.update){let o=this.spec.update(e,t,r);return o&&this.updateInner(e,t,r,i),o}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,r,i){this.spec.setSelection?this.spec.setSelection(e,t,r):super.setSelection(e,t,r,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function Pg(n,e,t){let r=n.firstChild,i=!1;for(let o=0;o>1,s=Math.min(o,e.length);for(;i-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let a=wl.create(this.top,e[o],t,r);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,o++}}findNodeMatch(e,t,r,i){let o=-1,s;if(i>=this.preMatch.index&&(s=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&s.matchesNode(e,t,r))o=this.top.children.indexOf(s,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l0;){let l;for(;;)if(r){let u=t.children[r-1];if(u instanceof wl)t=u,r=u.children.length;else{l=u,r--;break}}else{if(t==e)break e;r=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=n.child(i-1))break;--i,o.set(l,i),s.push(l)}}return{index:i,matched:o,matches:s.reverse()}}function zk(n,e){return n.type.side-e.type.side}function Ik(n,e,t,r){let i=e.locals(n),o=0;if(i.length==0){for(let u=0;uo;)l.push(i[s++]);let h=o+d.nodeSize;if(d.isText){let w=h;s!w.inline):l.slice();r(d,m,e.forChild(o,d),p),o=h}}function Pk(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 Fk(n,e,t,r){for(let i=0,o=0;i=t){if(o>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let u=l=0&&u+e.length+l>=t)return l+u;if(t==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function $u(n,e,t,r,i){let o=[];for(let s=0,l=0;s=t||c<=e?o.push(a):(ut&&o.push(a.slice(t-u,a.size,r)))}return o}function df(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let i=n.docView.nearestDesc(t.focusNode),o=i&&i.size==0,s=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(s<0)return null;let l=r.resolve(s),a,u;if(Zl(t)){for(a=l;i&&!i.node;)i=i.parent;let c=i.node;if(i&&c.isAtom&&z.isSelectable(c)&&i.parent&&!(c.isInline&&ak(t.focusNode,t.focusOffset,i.dom))){let f=i.posBefore;u=new z(s==f?l:r.resolve(f))}}else{let c=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(c<0)return null;a=r.resolve(c)}if(!u){let c=e=="pointer"||n.state.selection.head{(t.anchorNode!=r||t.anchorOffset!=i)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!$g(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function $k(n){let e=n.domSelection(),t=document.createRange();if(!e)return;let r=n.cursorWrapper.dom,i=r.nodeName=="IMG";i?t.setStart(r.parentNode,ye(r)+1):t.setStart(r,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!i&&!n.state.selection.visible&&We&&Sn<=11&&(r.disabled=!0,r.disabled=!1)}function Vg(n,e){if(e instanceof z){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(uh(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else uh(n)}function uh(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function hf(n,e,t,r){return n.someProp("createSelectionBetween",i=>i(n,e,t))||$.between(e,t,r)}function ch(n){return n.editable&&!n.hasFocus()?!1:Bg(n)}function Bg(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 Vk(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return lr(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Vu(n,e){let{$anchor:t,$head:r}=n.selection,i=e>0?t.max(r):t.min(r),o=i.parent.inlineContent?i.depth?n.doc.resolve(e>0?i.after():i.before()):null:i;return o&&P.findFrom(o,e)}function rn(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function fh(n,e,t){let r=n.state.selection;if(r instanceof $)if(t.indexOf("s")>-1){let{$head:i}=r,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let s=n.state.doc.resolve(i.pos+o.nodeSize*(e<0?-1:1));return rn(n,new $(r.$anchor,s))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let i=Vu(n.state,e);return i&&i instanceof z?rn(n,i):!1}else if(!(ot&&t.indexOf("m")>-1)){let i=r.$head,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,s;if(!o||o.isText)return!1;let l=e<0?i.pos-o.nodeSize:i.pos;return o.isAtom||(s=n.docView.descAt(l))&&!s.contentDOM?z.isSelectable(o)?rn(n,new z(e<0?n.state.doc.resolve(i.pos-o.nodeSize):i)):Go?rn(n,new $(n.state.doc.resolve(e<0?l:l+o.nodeSize))):!1:!1}}else return!1;else{if(r instanceof z&&r.node.isInline)return rn(n,new $(e>0?r.$to:r.$from));{let i=Vu(n.state,e);return i?rn(n,i):!1}}}function kl(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function ro(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function Sr(n,e){return e<0?Bk(n):Jk(n)}function Bk(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i,o,s=!1;for(Ct&&t.nodeType==1&&r0){if(t.nodeType!=1)break;{let l=t.childNodes[r-1];if(ro(l,-1))i=t,o=--r;else if(l.nodeType==3)t=l,r=t.nodeValue.length;else break}}else{if(Jg(t))break;{let l=t.previousSibling;for(;l&&ro(l,-1);)i=t.parentNode,o=ye(l),l=l.previousSibling;if(l)t=l,r=kl(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}s?Bu(n,t,r):i&&Bu(n,i,o)}function Jk(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i=kl(t),o,s;for(;;)if(r{n.state==i&&qt(n)},50)}function dh(n,e){let t=n.state.doc.resolve(e);if(!(Me||fk)&&t.parent.inlineContent){let i=n.coordsAtPos(e);if(e>t.start()){let o=n.coordsAtPos(e-1),s=(o.top+o.bottom)/2;if(s>i.top&&s1)return o.lefti.top&&s1)return o.left>i.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function hh(n,e,t){let r=n.state.selection;if(r instanceof $&&!r.empty||t.indexOf("s")>-1||ot&&t.indexOf("m")>-1)return!1;let{$from:i,$to:o}=r;if(!i.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let s=Vu(n.state,e);if(s&&s instanceof z)return rn(n,s)}if(!i.parent.inlineContent){let s=e<0?i:o,l=r instanceof et?P.near(s,e):P.findFrom(s,e);return l?rn(n,l):!1}return!1}function ph(n,e){if(!(n.state.selection instanceof $))return!0;let{$head:t,$anchor:r,empty:i}=n.state.selection;if(!t.sameParent(r))return!0;if(!i)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let o=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(o&&!o.isText){let s=n.state.tr;return e<0?s.delete(t.pos-o.nodeSize,t.pos):s.delete(t.pos,t.pos+o.nodeSize),n.dispatch(s),!0}return!1}function mh(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function Uk(n){if(!be||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;mh(n,r,"true"),setTimeout(()=>mh(n,r,"false"),20)}return!1}function Hk(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function jk(n,e){let t=e.keyCode,r=Hk(e);if(t==8||ot&&t==72&&r=="c")return ph(n,-1)||Sr(n,-1);if(t==46&&!e.shiftKey||ot&&t==68&&r=="c")return ph(n,1)||Sr(n,1);if(t==13||t==27)return!0;if(t==37||ot&&t==66&&r=="c"){let i=t==37?dh(n,n.state.selection.from)=="ltr"?-1:1:-1;return fh(n,i,r)||Sr(n,i)}else if(t==39||ot&&t==70&&r=="c"){let i=t==39?dh(n,n.state.selection.from)=="ltr"?1:-1:1;return fh(n,i,r)||Sr(n,i)}else{if(t==38||ot&&t==80&&r=="c")return hh(n,-1,r)||Sr(n,-1);if(t==40||ot&&t==78&&r=="c")return Uk(n)||hh(n,1,r)||Sr(n,1);if(r==(ot?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function _g(n,e){n.someProp("transformCopied",p=>{e=p(e,n)});let t=[],{content:r,openStart:i,openEnd:o}=e;for(;i>1&&o>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,o--;let p=r.firstChild;t.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),r=p.content}let s=n.someProp("clipboardSerializer")||pi.fromSchema(n.state.schema),l=qg(),a=l.createElement("div");a.appendChild(s.serializeFragment(r,{document:l}));let u=a.firstChild,c,f=0;for(;u&&u.nodeType==1&&(c=Kg[u.nodeName.toLowerCase()]);){for(let p=c.length-1;p>=0;p--){let h=l.createElement(c[p]);for(;a.firstChild;)h.appendChild(a.firstChild);a.appendChild(h),f++}u=a.firstChild}u&&u.nodeType==1&&u.setAttribute("data-pm-slice",`${i} ${o}${f?` -${f}`:""} ${JSON.stringify(t)}`);let d=n.someProp("clipboardTextSerializer",p=>p(e,n))||e.content.textBetween(0,e.content.size,` `);return{dom:a,text:d,slice:e}}function Wg(n,e,t,r,i){let o=i.parent.type.spec.code,s,l;if(!t&&!e)return null;let a=e&&(r||o||!t);if(a){if(n.someProp("transformPastedText",d=>{e=d(e,o||r,n)}),o)return e?new v(x.from(n.state.schema.text(e.replace(/\r\n?/g,` -`))),0,0):v.empty;let f=n.someProp("clipboardTextParser",d=>d(e,i,r,n));if(f)l=f;else{let d=i.marks(),{schema:p}=n.state,h=pi.fromSchema(p);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let w=s.appendChild(document.createElement("p"));m&&w.appendChild(h.serializeNode(p.text(m,d)))})}}else n.someProp("transformPastedHTML",f=>{t=f(t,n)}),s=Yk(t),Xo&&Gk(s);let u=s&&s.querySelector("[data-pm-slice]"),c=u&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(u.getAttribute("data-pm-slice")||"");if(c&&c[3])for(let f=+c[3];f>0;f--){let d=s.firstChild;for(;d&&d.nodeType!=1;)d=d.nextSibling;if(!d)break;s=d}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||So.fromSchema(n.state.schema)).parseSlice(s,{preserveWhitespace:!!(a||c),context:i,ruleFromNode(d){return d.nodeName=="BR"&&!d.nextSibling&&d.parentNode&&!Kk.test(d.parentNode.nodeName)?{ignore:!0}:null}})),c)l=Xk(gh(l,+c[1],+c[2]),c[4]);else if(l=v.maxOpen(qk(l.content,i),!0),l.openStart||l.openEnd){let f=0,d=0;for(let p=l.content.firstChild;f{l=f(l,n)}),l}const Kk=/^(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 qk(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let i=e.node(t).contentMatchAt(e.index(t)),o,s=[];if(n.forEach(l=>{if(!s)return;let a=i.findWrapping(l.type),u;if(!a)return s=null;if(u=s.length&&o.length&&Hg(a,o,l,s[s.length-1],0))s[s.length-1]=u;else{s.length&&(s[s.length-1]=jg(s[s.length-1],o.length));let c=Ug(l,a);s.push(c),i=i.matchType(c.type),o=a}}),s)return x.from(s)}return n}function Ug(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,x.from(n));return n}function Hg(n,e,t,r,i){if(i1&&(o=0),i=t&&(l=e<0?s.contentMatchAt(0).fillBefore(l,o<=i).append(l):l.append(s.contentMatchAt(s.childCount).fillBefore(x.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,s.copy(l))}function gh(n,e,t){return et}).createHTML(n):n}function Yk(n){let e=/^(\s*]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=qg().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),i;if((i=r&&Kg[r[1].toLowerCase()])&&(n=i.map(o=>"<"+o+">").join("")+n+i.map(o=>"").reverse().join("")),t.innerHTML=Qk(n),i)for(let o=0;o=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;i=x.from(a.create(r[l+1],i)),o++,s++}return new v(i,o,s)}const ze={},Ie={},Zk={touchstart:!0,touchmove:!0};class ev{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastAndroidDelete=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 tv(n){for(let e in ze){let t=ze[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{rv(n,r)&&!pf(n,r)&&(n.editable||!(r.type in Ie))&&t(n,r)},Zk[e]?{passive:!0}:void 0)}be&&n.dom.addEventListener("input",()=>null),_u(n)}function hn(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function nv(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 _u(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>pf(n,r))})}function pf(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function rv(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 iv(n,e){!pf(n,e)&&ze[e.type]&&(n.editable||!(e.type in Ie))&&ze[e.type](n,e)}Ie.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!Yg(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(wt&&Ne&&t.keyCode==13)))if(n.domObserver.selectionChanged(n.domSelectionRange())?n.domObserver.flush():t.keyCode!=229&&n.domObserver.forceFlush(),Zr&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",i=>i(n,qn(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||jk(n,t)?t.preventDefault():hn(n,"key")};Ie.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};Ie.keypress=(n,e)=>{let t=e;if(Yg(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||ot&&t.metaKey)return;if(n.someProp("handleKeyPress",i=>i(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof $)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(t.charCode);!/[\r\n]/.test(i)&&!n.someProp("handleTextInput",o=>o(n,r.$from.pos,r.$to.pos,i))&&n.dispatch(n.state.tr.insertText(i).scrollIntoView()),t.preventDefault()}};function ea(n){return{left:n.clientX,top:n.clientY}}function ov(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function mf(n,e,t,r,i){if(r==-1)return!1;let o=n.state.doc.resolve(r);for(let s=o.depth+1;s>0;s--)if(n.someProp(e,l=>s>o.depth?l(n,t,o.nodeAfter,o.before(s),i,!0):l(n,t,o.node(s),o.before(s),i,!1)))return!0;return!1}function Br(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 sv(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&z.isSelectable(r)?(Br(n,new z(t)),!0):!1}function lv(n,e){if(e==-1)return!1;let t=n.state.selection,r,i;t instanceof z&&(r=t.node);let o=n.state.doc.resolve(e);for(let s=o.depth+1;s>0;s--){let l=s>o.depth?o.nodeAfter:o.node(s);if(z.isSelectable(l)){r&&t.$from.depth>0&&s>=t.$from.depth&&o.before(t.$from.depth+1)==t.$from.pos?i=o.before(t.$from.depth):i=o.before(s);break}}return i!=null?(Br(n,z.create(n.state.doc,i)),!0):!1}function av(n,e,t,r,i){return mf(n,"handleClickOn",e,t,r)||n.someProp("handleClick",o=>o(n,e,r))||(i?lv(n,t):sv(n,t))}function uv(n,e,t,r){return mf(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",i=>i(n,e,r))}function cv(n,e,t,r){return mf(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",i=>i(n,e,r))||fv(n,t,r)}function fv(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(Br(n,$.create(r,0,r.content.size)),!0):!1;let i=r.resolve(e);for(let o=i.depth+1;o>0;o--){let s=o>i.depth?i.nodeAfter:i.node(o),l=i.before(o);if(s.inlineContent)Br(n,$.create(r,l+1,l+1+s.content.size));else if(z.isSelectable(s))Br(n,z.create(r,l));else continue;return!0}}function gf(n){return vl(n)}const Qg=ot?"metaKey":"ctrlKey";ze.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=gf(n),i=Date.now(),o="singleClick";i-n.input.lastClick.time<500&&ov(t,n.input.lastClick)&&!t[Qg]&&(n.input.lastClick.type=="singleClick"?o="doubleClick":n.input.lastClick.type=="doubleClick"&&(o="tripleClick")),n.input.lastClick={time:i,x:t.clientX,y:t.clientY,type:o};let s=n.posAtCoords(ea(t));s&&(o=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new dv(n,s,t,!!r)):(o=="doubleClick"?uv:cv)(n,s.pos,s.inside,t)?t.preventDefault():hn(n,"pointer"))};class dv{constructor(e,t,r,i){this.view=e,this.pos=t,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[Qg],this.allowDefault=r.shiftKey;let o,s;if(t.inside>-1)o=e.state.doc.nodeAt(t.inside),s=t.inside;else{let c=e.state.doc.resolve(t.pos);o=c.parent,s=c.depth?c.before():0}const l=i?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.dom.nodeType==1?a.dom:null;let{selection:u}=e.state;(r.button==0&&o.type.spec.draggable&&o.type.spec.selectable!==!1||u instanceof z&&u.from<=s&&u.to>s)&&(this.mightDrag={node:o,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Ct&&!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)),hn(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(()=>qt(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(ea(e))),this.updateAllowDefault(e),this.allowDefault||!t?hn(this.view,"pointer"):av(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||be&&this.mightDrag&&!this.mightDrag.node.isAtom||Ne&&!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)?(Br(this.view,P.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):hn(this.view,"pointer")}move(e){this.updateAllowDefault(e),hn(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)}}ze.touchstart=n=>{n.input.lastTouch=Date.now(),gf(n),hn(n,"pointer")};ze.touchmove=n=>{n.input.lastTouch=Date.now(),hn(n,"pointer")};ze.contextmenu=n=>gf(n);function Yg(n,e){return n.composing?!0:be&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const hv=wt?5e3:-1;Ie.compositionstart=Ie.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof $&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),vl(n,!0),n.markCursor=null;else if(vl(n,!e.selection.empty),Ct&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let i=r.focusNode,o=r.focusOffset;i&&i.nodeType==1&&o!=0;){let s=o<0?i.lastChild:i.childNodes[o-1];if(!s)break;if(s.nodeType==3){let l=n.domSelection();l&&l.collapse(s,s.nodeValue.length);break}else i=s,o=-1}}n.input.composing=!0}Gg(n,hv)};Ie.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++,Gg(n,20))};function Gg(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>vl(n),e))}function Xg(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=mv());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function pv(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=sk(e.focusNode,e.focusOffset),r=lk(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let i=r.pmViewDesc,o=n.domObserver.lastChangedTextNode;if(t==o||r==o)return o;if(!i||!i.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let s=t.pmViewDesc;if(!(!s||!s.isText(t.nodeValue)))return r}}return t||r}function mv(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function vl(n,e=!1){if(!(wt&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Xg(n),e||n.docView&&n.docView.dirty){let t=df(n);return t&&!t.eq(n.state.selection)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!n.state.selection.empty?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function gv(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const xo=We&&Sn<15||Zr&&dk<604;ze.copy=Ie.cut=(n,e)=>{let t=e,r=n.state.selection,i=t.type=="cut";if(r.empty)return;let o=xo?null:t.clipboardData,s=r.content(),{dom:l,text:a}=_g(n,s);o?(t.preventDefault(),o.clearData(),o.setData("text/html",l.innerHTML),o.setData("text/plain",a)):gv(n,l),i&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function yv(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function Sv(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?Co(n,r.value,null,i,e):Co(n,r.textContent,r.innerHTML,i,e)},50)}function Co(n,e,t,r,i){let o=Wg(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,i,o||v.empty)))return!0;if(!o)return!1;let s=yv(o),l=s?n.state.tr.replaceSelectionWith(s,r):n.state.tr.replaceSelection(o);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Zg(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}Ie.paste=(n,e)=>{let t=e;if(n.composing&&!wt)return;let r=xo?null:t.clipboardData,i=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&Co(n,Zg(r),r.getData("text/html"),i,t)?t.preventDefault():Sv(n,t)};class ey{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}}const ty=ot?"altKey":"ctrlKey";ze.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let i=n.state.selection,o=i.empty?null:n.posAtCoords(ea(t)),s;if(!(o&&o.pos>=i.from&&o.pos<=(i instanceof z?i.to-1:i.to))){if(r&&r.mightDrag)s=z.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let f=n.docView.nearestDesc(t.target,!0);f&&f.node.type.spec.draggable&&f!=n.docView&&(s=z.create(n.state.doc,f.posBefore))}}let l=(s||n.state.selection).content(),{dom:a,text:u,slice:c}=_g(n,l);(!t.dataTransfer.files.length||!Ne||Cg>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(xo?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",xo||t.dataTransfer.setData("text/plain",u),n.dragging=new ey(c,!t[ty],s)};ze.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};Ie.dragover=Ie.dragenter=(n,e)=>e.preventDefault();Ie.drop=(n,e)=>{let t=e,r=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let i=n.posAtCoords(ea(t));if(!i)return;let o=n.state.doc.resolve(i.pos),s=r&&r.slice;s?n.someProp("transformPasted",h=>{s=h(s,n)}):s=Wg(n,Zg(t.dataTransfer),xo?null:t.dataTransfer.getData("text/html"),!1,o);let l=!!(r&&!t[ty]);if(n.someProp("handleDrop",h=>h(n,t,s||v.empty,l))){t.preventDefault();return}if(!s)return;t.preventDefault();let a=s?nk(n.state.doc,o.pos,s):o.pos;a==null&&(a=o.pos);let u=n.state.tr;if(l){let{node:h}=r;h?h.replace(u):u.deleteSelection()}let c=u.mapping.map(a),f=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,d=u.doc;if(f?u.replaceRangeWith(c,c,s.content.firstChild):u.replaceRange(c,c,s),u.doc.eq(d))return;let p=u.doc.resolve(c);if(f&&z.isSelectable(s.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(s.content.firstChild))u.setSelection(new z(p));else{let h=u.mapping.map(a);u.mapping.maps[u.mapping.maps.length-1].forEach((m,w,g,y)=>h=y),u.setSelection(hf(n,p,u.doc.resolve(h)))}n.focus(),n.dispatch(u.setMeta("uiEvent","drop"))};ze.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())&&qt(n)},20))};ze.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)};ze.beforeinput=(n,e)=>{if(Ne&&wt&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",o=>o(n,qn(8,"Backspace")))))return;let{$cursor:i}=n.state.selection;i&&i.pos>0&&n.dispatch(n.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let n in Ie)ze[n]=Ie[n];function No(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 xl{constructor(e,t){this.toDOM=e,this.spec=t||nr,this.side=this.spec.side||0}map(e,t,r,i){let{pos:o,deleted:s}=e.mapResult(t.from+i,this.side<0?-1:1);return s?null:new ye(o-r,o-r,this)}valid(){return!0}eq(e){return this==e||e instanceof xl&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&No(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class wn{constructor(e,t){this.attrs=e,this.spec=t||nr}map(e,t,r,i){let o=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-r,s=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-r;return o>=s?null:new ye(o,s,this)}valid(e,t){return t.from=e&&(!o||o(l.spec))&&r.push(l.copy(l.from+i,l.to+i))}for(let s=0;se){let l=this.children[s]+1;this.children[s+2].findInner(e-l,t-l,r,i+l,o)}}map(e,t,r){return this==xe||e.maps.length==0?this:this.mapInner(e,t,0,0,r||nr)}mapInner(e,t,r,i,o){let s;for(let l=0;l{let u=a+r,c;if(c=iy(t,l,u)){for(i||(i=this.children.slice());ol&&f.to=e){this.children[l]==e&&(r=this.children[l+2]);break}let o=e+1,s=o+t.content.size;for(let l=0;lo&&a.type instanceof wn){let u=Math.max(o,a.from)-o,c=Math.min(s,a.to)-o;ui.map(e,t,nr));return Mr.from(r)}forChild(e,t){if(t.isLeaf)return _.empty;let r=[];for(let i=0;it instanceof _)?e:e.reduce((t,r)=>t.concat(r instanceof _?r:r.members),[]))}}forEachSet(e){for(let t=0;t{let w=m-h-(p-d);for(let g=0;gy+c-f)continue;let S=l[g]+c-f;p>=S?l[g+1]=d<=S?-2:-1:d>=c&&w&&(l[g]+=w,l[g+1]+=w)}f+=w}),c=t.maps[u].map(c,-1)}let a=!1;for(let u=0;u=r.content.size){a=!0;continue}let d=t.map(n[u+1]+o,-1),p=d-i,{index:h,offset:m}=r.content.findIndex(f),w=r.maybeChild(h);if(w&&m==f&&m+w.nodeSize==p){let g=l[u+2].mapInner(t,w,c+1,n[u]+o+1,s);g!=xe?(l[u]=f,l[u+1]=p,l[u+2]=g):(l[u+1]=-2,a=!0)}else a=!0}if(a){let u=kv(l,n,e,t,i,o,s),c=Cl(u,r,0,s);e=c.local;for(let f=0;ft&&s.to{let u=iy(n,l,a+t);if(u){o=!0;let c=Cl(u,l,t+a+1,r);c!=xe&&i.push(a,a+l.nodeSize,c)}});let s=ry(o?oy(n):n,-t).sort(rr);for(let l=0;l0;)e++;n.splice(e,0,t)}function La(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=xe&&e.push(r)}),n.cursorWrapper&&e.push(_.create(n.state.doc,[n.cursorWrapper.deco])),ny.from(e)}const vv={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},xv=We&&Sn<=11;let Cv=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}};class Nv{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Cv,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;ii.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),xv&&(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,vv)),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;tthis.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(ch(this.view)){if(this.suppressingSelectionUpdates)return qt(this.view);if(We&&Sn<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&lr(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,r;for(let o=e.focusNode;o;o=vo(o))t.add(o);for(let o=e.anchorNode;o;o=vo(o))if(t.has(o)){r=o;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}selectionChanged(e){return!this.suppressingSelectionUpdates&&!this.currentSelection.eq(e)&&ch(this.view)&&!this.ignoreSelectionChange(e)}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let r=e.domSelectionRange(),i=this.selectionChanged(r),o=-1,s=-1,l=!1,a=[];if(e.editable)for(let c=0;cf.nodeName=="BR");if(c.length==2){let[f,d]=c;f.parentNode&&f.parentNode.parentNode==d.parentNode?d.remove():f.remove()}else{let{focusNode:f}=this.currentSelection;for(let d of c){let p=d.parentNode;p&&p.nodeName=="LI"&&(!f||Ov(e,f)!=p)&&d.remove()}}}let u=null;o<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)-1||i)&&(o>-1&&(e.docView.markDirty(o,s),Mv(e)),this.handleDOMChange(o,s,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||qt(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 c=0;ci;w--){let g=r.childNodes[w-1],y=g.pmViewDesc;if(g.nodeName=="BR"&&!y){o=w;break}if(!y||y.size)break}let f=n.state.doc,d=n.someProp("domParser")||So.fromSchema(n.state.schema),p=f.resolve(s),h=null,m=d.parse(r,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:o,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:Tv,context:p});if(u&&u[0].pos!=null){let w=u[0].pos,g=u[1]&&u[1].pos;g==null&&(g=w),h={anchor:w+s,head:g+s}}return{doc:m,sel:h,from:s,to:l}}function Tv(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(be&&/^(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||be&&/^(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 Rv=/^(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 Av(n,e,t,r,i){let o=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let b=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,I=df(n,b);if(I&&!n.state.selection.eq(I)){if(Ne&&wt&&n.input.lastKeyCode===13&&Date.now()-100Vt(n,qn(13,"Enter"))))return;let ae=n.state.tr.setSelection(I);b=="pointer"?ae.setMeta("pointer",!0):b=="key"&&ae.scrollIntoView(),o&&ae.setMeta("composition",o),n.dispatch(ae)}return}let s=n.state.doc.resolve(e),l=s.sharedDepth(t);e=s.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,u=Dv(n,e,t),c=n.state.doc,f=c.slice(u.from,u.to),d,p;n.input.lastKeyCode===8&&Date.now()-100Date.now()-225||wt)&&i.some(b=>b.nodeType==1&&!Rv.test(b.nodeName))&&(!h||h.endA>=h.endB)&&n.someProp("handleKeyDown",b=>b(n,qn(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!h)if(r&&a instanceof $&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.composing&&!(u.sel&&u.sel.anchor!=u.sel.head))h={start:a.from,endA:a.to,endB:a.to};else{if(u.sel){let b=xh(n,n.state.doc,u.sel);if(b&&!b.eq(n.state.selection)){let I=n.state.tr.setSelection(b);o&&I.setMeta("composition",o),n.dispatch(I)}}return}n.state.selection.fromn.state.selection.from&&h.start<=n.state.selection.from+2&&n.state.selection.from>=u.from?h.start=n.state.selection.from:h.endA=n.state.selection.to-2&&n.state.selection.to<=u.to&&(h.endB+=n.state.selection.to-h.endA,h.endA=n.state.selection.to)),We&&Sn<=11&&h.endB==h.start+1&&h.endA==h.start&&h.start>u.from&&u.doc.textBetween(h.start-u.from-1,h.start-u.from+1)=="  "&&(h.start--,h.endA--,h.endB--);let m=u.doc.resolveNoCache(h.start-u.from),w=u.doc.resolveNoCache(h.endB-u.from),g=c.resolve(h.start),y=m.sameParent(w)&&m.parent.inlineContent&&g.end()>=h.endA,S;if((Zr&&n.input.lastIOSEnter>Date.now()-225&&(!y||i.some(b=>b.nodeName=="DIV"||b.nodeName=="P"))||!y&&m.posb(n,qn(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>h.start&&zv(c,h.start,h.endA,m,w)&&n.someProp("handleKeyDown",b=>b(n,qn(8,"Backspace")))){wt&&Ne&&n.domObserver.suppressSelectionUpdates();return}Ne&&wt&&h.endB==h.start&&(n.input.lastAndroidDelete=Date.now()),wt&&!y&&m.start()!=w.start()&&w.parentOffset==0&&m.depth==w.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==h.endA&&(h.endB-=2,w=u.doc.resolveNoCache(h.endB-u.from),setTimeout(()=>{n.someProp("handleKeyDown",function(b){return b(n,qn(13,"Enter"))})},20));let C=h.start,N=h.endA,E,O,T;if(y){if(m.pos==w.pos)We&&Sn<=11&&m.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>qt(n),20)),E=n.state.tr.delete(C,N),O=c.resolve(h.start).marksAcross(c.resolve(h.endA));else if(h.endA==h.endB&&(T=bv(m.parent.content.cut(m.parentOffset,w.parentOffset),g.parent.content.cut(g.parentOffset,h.endA-g.start()))))E=n.state.tr,T.type=="add"?E.addMark(C,N,T.mark):E.removeMark(C,N,T.mark);else if(m.parent.child(m.index()).isText&&m.index()==w.index()-(w.textOffset?0:1)){let b=m.parent.textBetween(m.parentOffset,w.parentOffset);if(n.someProp("handleTextInput",I=>I(n,C,N,b)))return;E=n.state.tr.insertText(b,C,N)}}if(E||(E=n.state.tr.replace(C,N,u.doc.slice(h.start-u.from,h.endB-u.from))),u.sel){let b=xh(n,E.doc,u.sel);b&&!(Ne&&wt&&n.composing&&b.empty&&(h.start!=h.endB||n.input.lastAndroidDeletee.content.size?null:hf(n,e.resolve(t.anchor),e.resolve(t.head))}function bv(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,i=t,o=r,s,l,a;for(let c=0;cc.mark(l.addToSet(c.marks));else if(i.length==0&&o.length==1)l=o[0],s="remove",a=c=>c.mark(l.removeFromSet(c.marks));else return null;let u=[];for(let c=0;ct||$a(s,!0,!1)0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,i++,e=!1;if(t){let o=n.node(r).maybeChild(n.indexAfter(r));for(;o&&!o.isLeaf;)o=o.firstChild,i++}return i}function Iv(n,e,t,r,i){let o=n.findDiffStart(e,t);if(o==null)return null;let{a:s,b:l}=n.findDiffEnd(e,t+n.size,t+e.size);if(i=="end"){let a=Math.max(0,o-Math.min(s,l));r-=s+a-o}if(s=s?o-r:0;o-=a,o&&o=l?o-r:0;o-=a,o&&o=56320&&e<=57343&&t>=55296&&t<=56319}class Pv{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 ev,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Dh),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=Eh(this),Mh(this),this.nodeViews=Oh(this),this.docView=ih(this.state.doc,Nh(this),La(this),this.dom,this),this.domObserver=new Nv(this,(r,i,o,s)=>Av(this,r,i,o,s)),this.domObserver.start(),tv(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&&_u(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Dh),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let i=this.state,o=!1,s=!1;e.storedMarks&&this.composing&&(Xg(this),s=!0),this.state=e;let l=i.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let p=Oh(this);Lv(p,this.nodeViews)&&(this.nodeViews=p,o=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&_u(this),this.editable=Eh(this),Mh(this);let a=La(this),u=Nh(this),c=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",f=o||!this.docView.matchesNode(e.doc,u,a);(f||!e.selection.eq(i.selection))&&(s=!0);let d=c=="preserve"&&s&&this.dom.style.overflowAnchor==null&&mk(this);if(s){this.domObserver.stop();let p=f&&(We||Ne)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&Fv(i.selection,e.selection);if(f){let h=Ne?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=pv(this)),(o||!this.docView.update(e.doc,u,a,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=ih(e.doc,u,a,this.dom,this)),h&&!this.trackWrites&&(p=!0)}p||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Vk(this))?qt(this,p):(Vg(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),c=="reset"?this.dom.scrollTop=0:c=="to selection"?this.scrollToSelection():d&&gk(d)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof z){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Xd(this,t.getBoundingClientRect(),e)}else Xd(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;t0&&this.state.doc.nodeAt(o))==r.node&&(i=o)}this.dragging=new ey(e.slice,e.move,i<0?void 0:z.create(this.state.doc,i))}someProp(e,t){let r=this._props&&this._props[e],i;if(r!=null&&(i=t?t(r):r))return i;for(let s=0;st.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return xk(this,e)}coordsAtPos(e,t=1){return Dg(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,r=-1){let i=this.docView.posFromDOM(e,t,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,t){return Ok(this,t||this.state,e)}pasteHTML(e,t){return Co(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Co(this,e,null,!0,t||new ClipboardEvent("paste"))}destroy(){this.docView&&(nv(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],La(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,ik())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return iv(this,e)}dispatch(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))}domSelectionRange(){let e=this.domSelection();return e?be&&this.root.nodeType===11&&uk(this.dom.ownerDocument)==this.dom&&Ev(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function Nh(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 Mh(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 Eh(n){return!n.someProp("editable",e=>e(n.state)===!1)}function Fv(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 Oh(n){let e=Object.create(null);function t(r){for(let i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function Lv(n,e){let t=0,r=0;for(let i in n){if(n[i]!=e[i])return!0;t++}for(let i in e)r++;return t!=r}function Dh(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")}class ee extends P{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return ee.valid(r)?new ee(r):P.near(r)}content(){return v.empty}eq(e){return e instanceof ee&&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 ee(e.resolve(t.pos))}getBookmark(){return new wf(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!$v(e)||!Vv(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let i=t.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&ee.valid(e))return e;let i=e.pos,o=null;for(let s=e.depth;;s--){let l=e.node(s);if(t>0?e.indexAfter(s)0){o=l.child(t>0?e.indexAfter(s):e.index(s)-1);break}else if(s==0)return null;i+=t;let a=e.doc.resolve(i);if(ee.valid(a))return a}for(;;){let s=t>0?o.firstChild:o.lastChild;if(!s){if(o.isAtom&&!o.isText&&!z.isSelectable(o)){e=e.doc.resolve(i+o.nodeSize*t),r=!1;continue e}break}o=s,i+=t;let l=e.doc.resolve(i);if(ee.valid(l))return l}return null}}}ee.prototype.visible=!1;ee.findFrom=ee.findGapCursorFrom;P.jsonID("gapcursor",ee);class wf{constructor(e){this.pos=e}map(e){return new wf(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return ee.valid(t)?new ee(t):P.near(t)}}function $v(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 i=r.child(t-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||i.isAtom||i.type.spec.isolating)return!0;if(i.inlineContent)return!1}}return!0}function Vv(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 i=r.child(t);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||i.isAtom||i.type.spec.isolating)return!0;if(i.inlineContent)return!1}}return!0}function Bv(){return new $t({props:{decorations:Uv,createSelectionBetween(n,e,t){return e.pos==t.pos&&ee.valid(t)?new ee(t):null},handleClick:_v,handleKeyDown:Jv,handleDOMEvents:{beforeinput:Wv}}})}const Jv=Gw({ArrowLeft:hs("horiz",-1),ArrowRight:hs("horiz",1),ArrowUp:hs("vert",-1),ArrowDown:hs("vert",1)});function hs(n,e){const t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,o){let s=r.selection,l=e>0?s.$to:s.$from,a=s.empty;if(s instanceof $){if(!o.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let u=ee.findGapCursorFrom(l,e,a);return u?(i&&i(r.tr.setSelection(new ee(u))),!0):!1}}function _v(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!ee.valid(r))return!1;let i=n.posAtCoords({left:t.clientX,top:t.clientY});return i&&i.inside>-1&&z.isSelectable(n.state.doc.nodeAt(i.inside))?!1:(n.dispatch(n.state.tr.setSelection(new ee(r))),!0)}function Wv(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof ee))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 i=x.empty;for(let s=r.length-1;s>=0;s--)i=x.from(r[s].createAndFill(null,i));let o=n.state.tr.replace(t.pos,t.pos,new v(i,0,0));return o.setSelection($.near(o.doc.resolve(t.pos+1))),n.dispatch(o),!1}function Uv(n){if(!(n.selection instanceof ee))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",_.create(n.doc,[ye.widget(n.selection.head,e,{key:"gapcursor"})])}const sy=65535,ly=Math.pow(2,16);function Hv(n,e){return n+e*ly}function Th(n){return n&sy}function jv(n){return(n-(n&sy))/ly}const ay=1,uy=2,Ys=4,cy=8;let Rh=class{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&cy)>0}get deletedBefore(){return(this.delInfo&(ay|Ys))>0}get deletedAfter(){return(this.delInfo&(uy|Ys))>0}get deletedAcross(){return(this.delInfo&Ys)>0}},ei=class Er{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&Er.empty)return Er.empty}recover(e){let t=0,r=Th(e);if(!this.inverted)for(let i=0;ie)break;let u=this.ranges[l+o],c=this.ranges[l+s],f=a+u;if(e<=f){let d=u?e==a?-1:e==f?1:t:t,p=a+i+(d<0?0:c);if(r)return p;let h=e==(t<0?a:f)?null:Hv(l/3,e-a),m=e==a?uy:e==f?ay:Ys;return(t<0?e!=a:e!=f)&&(m|=cy),new Rh(p,m,h)}i+=c-u}return r?e+i:new Rh(e+i,0,null)}touches(e,t){let r=0,i=Th(t),o=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;le)break;let u=this.ranges[l+o],c=a+u;if(e<=c&&l==i*3)return!0;r+=this.ranges[l+s]-u}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,o=0;i!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),i),t.openStart,t.openEnd);return Je.fromReplace(e,this.from,this.to,o)}invert(){return new dy(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 ji(t.pos,r.pos,this.mark)}merge(e){return e instanceof ji&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ji(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 ji(t.from,t.to,e.markFromJSON(t.mark))}};Ye.jsonID("addMark",fy);let dy=class Ki extends Ye{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 v(kf(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return Je.fromReplace(e,this.from,this.to,r)}invert(){return new fy(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 Ki(t.pos,r.pos,this.mark)}merge(e){return e instanceof Ki&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ki(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 Ki(t.from,t.to,e.markFromJSON(t.mark))}};Ye.jsonID("removeMark",dy);let hy=class qi extends Ye{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Je.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return Je.fromReplace(e,this.pos,this.pos+1,new v(x.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let i=0;ir.pos?null:new Gs(t.pos,r.pos,i,o,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Gs(t.from,t.to,t.gapFrom,t.gapTo,v.fromJSON(e,t.slice),t.insert,!!t.structure)}};Ye.jsonID("replaceAround",qv);function Uu(n,e,t){let r=n.resolve(e),i=t-e,o=r.depth;for(;i>0&&o>0&&r.indexAfter(o)==r.node(o).childCount;)o--,i--;if(i>0){let s=r.node(o).maybeChild(r.indexAfter(o));for(;i>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,i--}}return!1}function Qv(n,e,t=null,r=n){let i=Yv(n,e),o=i&&Gv(r,e);return o?i.map(Ah).concat({type:e,attrs:t}).concat(o.map(Ah)):null}function Ah(n){return{type:n,attrs:null}}function Yv(n,e){let{parent:t,startIndex:r,endIndex:i}=n,o=t.contentMatchAt(r).findWrapping(e);if(!o)return null;let s=o.length?o[0]:e;return t.canReplaceWith(r,i,s)?o:null}function Gv(n,e){let{parent:t,startIndex:r,endIndex:i}=n,o=t.child(r),s=e.contentMatch.findWrapping(o.type);if(!s)return null;let a=(s.length?s[s.length-1]:e).contentMatch;for(let u=r;a&&u0&&(o=t[0].slice(s-l,s)+o,r=i)}return e.tr.insertText(o,r,i)}}const nx=500;function rx({rules:n}){let e=new $t({state:{init(){return null},apply(t,r){let i=t.getMeta(this);return i||(t.selectionSet||t.docChanged?null:r)}},props:{handleTextInput(t,r,i,o){return bh(t,r,i,o,n,e)},handleDOMEvents:{compositionend:t=>{setTimeout(()=>{let{$cursor:r}=t.state.selection;r&&bh(t,r.pos,r.pos,"",n,e)})}}},isInputRules:!0});return e}function bh(n,e,t,r,i,o){if(n.composing)return!1;let s=n.state,l=s.doc.resolve(e),a=l.parent.textBetween(Math.max(0,l.parentOffset-nx),l.parentOffset,null,"")+r;for(let u=0;u{let a=t instanceof Function?t(o):t,u=i.tr.delete(s,l),c=u.doc.resolve(s),f=c.blockRange(),d=f&&Qv(f,e,a);if(!d)return null;u.wrap(f,d);let p=u.doc.resolve(s-1).nodeBefore;return p&&p.type==e&&Xv(u.doc,s-1)&&!r&&u.join(s-1),u})}const ox=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function sx(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,i,o,s;for(let l=0;l127)&&(o=zt[r.keyCode])&&o!=i){let l=e[Ba(o,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}const cx=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function fx(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,i,o,s;for(let l=0;l127)&&(o=zt[r.keyCode])&&o!=i){let l=e[Ja(o,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}const my=65535,gy=Math.pow(2,16);function px(n,e){return n+e*gy}function zh(n){return n&my}function mx(n){return(n-(n&my))/gy}const yy=1,Sy=2,Zs=4,wy=8;class Hu{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&wy)>0}get deletedBefore(){return(this.delInfo&(yy|Zs))>0}get deletedAfter(){return(this.delInfo&(Sy|Zs))>0}get deletedAcross(){return(this.delInfo&Zs)>0}}class Xe{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&Xe.empty)return Xe.empty}recover(e){let t=0,r=zh(e);if(!this.inverted)for(let i=0;ie)break;let u=this.ranges[l+o],c=this.ranges[l+s],f=a+u;if(e<=f){let d=u?e==a?-1:e==f?1:t:t,p=a+i+(d<0?0:c);if(r)return p;let h=e==(t<0?a:f)?null:px(l/3,e-a),m=e==a?Sy:e==f?yy:Zs;return(t<0?e!=a:e!=f)&&(m|=wy),new Hu(p,m,h)}i+=c-u}return r?e+i:new Hu(e+i,0,null)}touches(e,t){let r=0,i=zh(t),o=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;le)break;let u=this.ranges[l+o],c=a+u;if(e<=c&&l==i*3)return!0;r+=this.ranges[l+s]-u}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,o=0;i=0;t--){let i=e.getMirror(t);this.appendMap(e.maps[t].invert(),i!=null&&i>t?r-i-1:void 0)}}invert(){let e=new oo;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;ro&&a!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),i),t.openStart,t.openEnd);return oe.fromReplace(e,this.from,this.to,o)}invert(){return new Dt(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 pn(t.pos,r.pos,this.mark)}merge(e){return e instanceof pn&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new pn(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 pn(t.from,t.to,e.markFromJSON(t.mark))}}Oe.jsonID("addMark",pn);class Dt extends Oe{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 v(vf(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return oe.fromReplace(e,this.from,this.to,r)}invert(){return new pn(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 Dt(t.pos,r.pos,this.mark)}merge(e){return e instanceof Dt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Dt(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 Dt(t.from,t.to,e.markFromJSON(t.mark))}}Oe.jsonID("removeMark",Dt);class mn extends Oe{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 v(x.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let i=0;ir.pos?null:new Rt(t.pos,r.pos,i,o,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Rt(t.from,t.to,t.gapFrom,t.gapTo,v.fromJSON(e,t.slice),t.insert,!!t.structure)}}Oe.jsonID("replaceAround",Rt);function ju(n,e,t){let r=n.resolve(e),i=t-e,o=r.depth;for(;i>0&&o>0&&r.indexAfter(o)==r.node(o).childCount;)o--,i--;if(i>0){let s=r.node(o).maybeChild(r.indexAfter(o));for(;i>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,i--}}return!1}function gx(n,e,t,r){let i=[],o=[],s,l;n.doc.nodesBetween(e,t,(a,u,c)=>{if(!a.isInline)return;let f=a.marks;if(!r.isInSet(f)&&c.type.allowsMarkType(r.type)){let d=Math.max(u,e),p=Math.min(u+a.nodeSize,t),h=r.addToSet(f);for(let m=0;mn.step(a)),o.forEach(a=>n.step(a))}function yx(n,e,t,r){let i=[],o=0;n.doc.nodesBetween(e,t,(s,l)=>{if(!s.isInline)return;o++;let a=null;if(r instanceof qo){let u=s.marks,c;for(;c=r.isInSet(u);)(a||(a=[])).push(c),u=c.removeFromSet(u)}else r?r.isInSet(s.marks)&&(a=[r]):a=s.marks;if(a&&a.length){let u=Math.min(l+s.nodeSize,t);for(let c=0;cn.step(new Dt(s.from,s.to,s.style)))}function Sx(n,e,t,r=t.contentMatch){let i=n.doc.nodeAt(e),o=[],s=e+1;for(let l=0;l=0;l--)n.step(o[l])}function wx(n,e,t){let{$from:r,$to:i,depth:o}=e,s=r.before(o+1),l=i.after(o+1),a=s,u=l,c=x.empty,f=0;for(let h=o,m=!1;h>t;h--)m||r.index(h)>0?(m=!0,c=x.from(r.node(h).copy(c)),f++):a--;let d=x.empty,p=0;for(let h=o,m=!1;h>t;h--)m||i.after(h+1)=0;s--){if(r.size){let l=t[s].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=x.from(t[s].type.create(t[s].attrs,r))}let i=e.start,o=e.end;n.step(new Rt(i,o,i,o,new v(r,0,0),t.length,!0))}function vx(n,e,t,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=n.steps.length;n.doc.nodesBetween(e,t,(s,l)=>{if(s.isTextblock&&!s.hasMarkup(r,i)&&xx(n.doc,n.mapping.slice(o).map(l),r)){n.clearIncompatible(n.mapping.slice(o).map(l,1),r);let a=n.mapping.slice(o),u=a.map(l,1),c=a.map(l+s.nodeSize,1);return n.step(new Rt(u,c,u+1,c-1,new v(x.from(r.create(i,null,s.marks)),0,0),1,!0)),!1}})}function xx(n,e,t){let r=n.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,t)}function Cx(n,e,t,r,i){let o=n.doc.nodeAt(e);if(!o)throw new RangeError("No node at given position");t||(t=o.type);let s=t.create(r,null,i||o.marks);if(o.isLeaf)return n.replaceWith(e,e+o.nodeSize,s);if(!t.validContent(o.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new Rt(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new v(x.from(s),0,0),1,!0))}function Nx(n,e,t=1,r){let i=n.doc.resolve(e),o=x.empty,s=x.empty;for(let l=i.depth,a=i.depth-t,u=t-1;l>a;l--,u--){o=x.from(i.node(l).copy(o));let c=r&&r[u];s=x.from(c?c.type.create(c.attrs,s):i.node(l).copy(s))}n.step(new Re(e,e,new v(o.append(s),t,t),!0))}function Mx(n,e,t){let r=new Re(e-t,e+t,v.empty,!0);n.step(r)}function Ex(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let o=r.index(i);if(r.node(i).canReplaceWith(o,o,t))return r.before(i+1);if(o>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let o=r.indexAfter(i);if(r.node(i).canReplaceWith(o,o,t))return r.after(i+1);if(o0;i--)this.placed=x.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let u=this.findFittable();u?this.placeNodes(u):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let o=this.placed,s=r.depth,l=i.depth;for(;s&&l&&o.childCount==1;)o=o.firstChild.content,s--,l--;let a=new v(o,s,l);return e>-1?new Rt(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new Re(r.pos,i.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,i=this.unplaced.openEnd;r1&&(i=0),o.type.spec.isolating&&i<=r){e=r;break}t=o.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let i,o=null;r?(o=Wa(this.unplaced.content,r-1).firstChild,i=o.content):i=this.unplaced.content;let s=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:u}=this.frontier[l],c,f=null;if(t==1&&(s?u.matchType(s.type)||(f=u.fillBefore(x.from(s),!1)):o&&a.compatibleContent(o.type)))return{sliceDepth:r,frontierDepth:l,parent:o,inject:f};if(t==2&&s&&(c=u.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:l,parent:o,wrap:c};if(o&&u.matchType(o.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=Wa(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new v(e,t+1,Math.max(r,i.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=Wa(e,t);if(i.childCount<=1&&t>0){let o=e.size-t<=t+i.size;this.unplaced=new v(Qi(e,t-1,1),t-1,o?t-1:r)}else this.unplaced=new v(Qi(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:i,wrap:o}){for(;this.depth>t;)this.closeFrontierNode();if(o)for(let m=0;m1||a==0||m.content.size)&&(f=w,c.push(vy(m.mark(d.allowedMarks(m.marks)),u==1?a:0,u==l.childCount?p:-1)))}let h=u==l.childCount;h||(p=-1),this.placed=Yi(this.placed,t,x.from(c)),this.frontier[t].match=f,h&&p<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,w=l;m1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:i}=this.frontier[t],o=t=0;l--){let{match:a,type:u}=this.frontier[l],c=Ua(e,l,u,a,!0);if(!c||c.childCount)continue e}return{depth:t,fit:s,move:o?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Yi(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let i=e.node(r),o=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,o)}return e}openFrontierNode(e,t=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=Yi(this.placed,this.depth,x.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(x.empty,!0);t.childCount&&(this.placed=Yi(this.placed,this.frontier.length,t))}}function Qi(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Qi(n.firstChild.content,e-1,t)))}function Yi(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Yi(n.lastChild.content,e-1,t)))}function Wa(n,e){for(let t=0;t1&&(r=r.replaceChild(0,vy(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(x.empty,!0)))),n.copy(r)}function Ua(n,e,t,r,i){let o=n.node(e),s=i?n.indexAfter(e):n.index(e);if(s==o.childCount&&!t.compatibleContent(o.type))return null;let l=r.fillBefore(o.content,!0,s);return l&&!Tx(t,o.content,s)?l:null}function Tx(n,e,t){for(let r=t;r0;d--,p--){let h=i.node(d).type.spec;if(h.defining||h.definingAsContext||h.isolating)break;s.indexOf(d)>-1?l=d:i.before(d)==p&&s.splice(1,0,-d)}let a=s.indexOf(l),u=[],c=r.openStart;for(let d=r.content,p=0;;p++){let h=d.firstChild;if(u.push(h),p==r.openStart)break;d=h.content}for(let d=c-1;d>=0;d--){let p=u[d],h=Rx(p.type);if(h&&!p.sameMarkup(i.node(Math.abs(l)-1)))c=d;else if(h||!p.type.isTextblock)break}for(let d=r.openStart;d>=0;d--){let p=(d+c+1)%(r.openStart+1),h=u[p];if(h)for(let m=0;m=0&&(n.replace(e,t,r),!(n.steps.length>f));d--){let p=s[d];p<0||(e=i.before(p),t=o.after(p))}}function xy(n,e,t,r,i){if(er){let o=i.contentMatchAt(0),s=o.fillBefore(n).append(n);n=s.append(o.matchFragment(s).fillBefore(x.empty,!0))}return n}function bx(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let i=Ex(n.doc,e,r.type);i!=null&&(e=t=i)}n.replaceRange(e,t,new v(x.from(r),0,0))}function zx(n,e,t){let r=n.doc.resolve(e),i=n.doc.resolve(t),o=Cy(r,i);for(let s=0;s0&&(a||r.node(l-1).canReplace(r.index(l-1),i.indexAfter(l-1))))return n.delete(r.before(l),i.after(l))}for(let s=1;s<=r.depth&&s<=i.depth;s++)if(e-r.start(s)==r.depth-s&&t>r.end(s)&&i.end(s)-t!=i.depth-s)return n.delete(r.before(s),t);n.delete(e,t)}function Cy(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let i=r;i>=0;i--){let o=n.start(i);if(oe.pos+(e.depth-i)||n.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(o==e.start(i)||i==n.depth&&i==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==o-1)&&t.push(i)}return t}class Jr extends Oe{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 o in t.attrs)r[o]=t.attrs[o];r[this.attr]=this.value;let i=t.type.create(r,null,t.marks);return oe.fromReplace(e,this.pos,this.pos+1,new v(x.from(i),0,t.isLeaf?0:1))}getMap(){return Xe.empty}invert(e){return new Jr(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 Jr(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 Jr(t.pos,t.attr,t.value)}}Oe.jsonID("attr",Jr);class Eo extends Oe{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let i in e.attrs)t[i]=e.attrs[i];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return oe.ok(r)}getMap(){return Xe.empty}invert(e){return new Eo(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 Eo(t.attr,t.value)}}Oe.jsonID("docAttr",Eo);let ni=class extends Error{};ni=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};ni.prototype=Object.create(Error.prototype);ni.prototype.constructor=ni;ni.prototype.name="TransformError";class Ix{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new oo}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new ni(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=v.empty){let i=Ox(this.doc,e,t,r);return i&&this.step(i),this}replaceWith(e,t,r){return this.replace(e,t,new v(x.from(r),0,0))}delete(e,t){return this.replace(e,t,v.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return Ax(this,e,t,r),this}replaceRangeWith(e,t,r){return bx(this,e,t,r),this}deleteRange(e,t){return zx(this,e,t),this}lift(e,t){return wx(this,e,t),this}join(e,t=1){return Mx(this,e,t),this}wrap(e,t){return kx(this,e,t),this}setBlockType(e,t=e,r,i=null){return vx(this,e,t,r,i),this}setNodeMarkup(e,t,r=null,i){return Cx(this,e,t,r,i),this}setNodeAttribute(e,t,r){return this.step(new Jr(e,t,r)),this}setDocAttribute(e,t){return this.step(new Eo(e,t)),this}addNodeMark(e,t){return this.step(new mn(e,t)),this}removeNodeMark(e,t){if(!(t instanceof W)){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t=t.isInSet(r.marks),!t)return this}return this.step(new ti(e,t)),this}split(e,t=1,r){return Nx(this,e,t,r),this}addMark(e,t,r){return gx(this,e,t,r),this}removeMark(e,t,r){return yx(this,e,t,r),this}clearIncompatible(e,t,r){return Sx(this,e,t,r),this}}var Ku,qu;if(typeof WeakMap<"u"){let n=new WeakMap;Ku=e=>n.get(e),qu=(e,t)=>(n.set(e,t),t)}else{const n=[];let t=0;Ku=r=>{for(let i=0;i(t==10&&(t=0),n[t++]=r,n[t++]=i)}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=t){(o||(o=[])).push({type:"overlong_rowspan",pos:c,n:g-S});break}const C=i+S*e;for(let N=0;Nr&&(o+=u.attrs.colspan)}}for(let s=0;s1&&(t=!0)}e==-1?e=o:e!=o&&(e=Math.max(e,o))}return e}function Lx(n,e,t){n.problems||(n.problems=[]);const r={};for(let i=0;iNumber(s)):null,i=Number(n.getAttribute("colspan")||1),o={colspan:i,rowspan:Number(n.getAttribute("rowspan")||1),colwidth:r&&r.length==i?r:null};for(const s in e){const l=e[s].getFromDOM,a=l&&l(n);a!=null&&(o[s]=a)}return o}function Ph(n,e){const t={};n.attrs.colspan!=1&&(t.colspan=n.attrs.colspan),n.attrs.rowspan!=1&&(t.rowspan=n.attrs.rowspan),n.attrs.colwidth&&(t["data-colwidth"]=n.attrs.colwidth.join(","));for(const r in e){const i=e[r].setDOMAttr;i&&i(n.attrs[r],t)}return t}function Vx(n){const e=n.cellAttributes||{},t={colspan:{default:1},rowspan:{default:1},colwidth:{default:null}};for(const r in e)t[r]={default:e[r].default};return{table:{content:"table_row+",tableRole:"table",isolating:!0,group:n.tableGroup,parseDOM:[{tag:"table"}],toDOM(){return["table",["tbody",0]]}},table_row:{content:"(table_cell | table_header)*",tableRole:"row",parseDOM:[{tag:"tr"}],toDOM(){return["tr",0]}},table_cell:{content:n.cellContent,attrs:t,tableRole:"cell",isolating:!0,parseDOM:[{tag:"td",getAttrs:r=>Ih(r,e)}],toDOM(r){return["td",Ph(r,e),0]}},table_header:{content:n.cellContent,attrs:t,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:r=>Ih(r,e)}],toDOM(r){return["th",Ph(r,e),0]}}}}function Ft(n){let e=n.cached.tableNodeTypes;if(!e){e=n.cached.tableNodeTypes={};for(const t in n.nodes){const r=n.nodes[t],i=r.spec.tableRole;i&&(e[i]=r)}}return e}var an=new Yo("selectingCells");function es(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 xf(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 Ny(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=es(e.$head)||Bx(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function Bx(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 Qu(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function Cf(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function My(n,e,t){const r=n.node(-1),i=re.get(r),o=n.start(-1),s=i.nextCell(n.pos-o,e,t);return s==null?null:n.node(0).resolve(o+s)}function ri(n,e,t=1){const r={...n,colspan:n.colspan-t};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,t),r.colwidth.some(i=>i>0)||(r.colwidth=null)),r}var fe=class Jt extends P{constructor(e,t=e){const r=e.node(-1),i=re.get(r),o=e.start(-1),s=i.rectBetween(e.pos-o,t.pos-o),l=e.node(0),a=i.cellsInRect(s).filter(c=>c!=t.pos-o);a.unshift(t.pos-o);const u=a.map(c=>{const f=r.nodeAt(c);if(!f)throw RangeError(`No cell with offset ${c} found`);const d=o+c+1;return new ig(l.resolve(d),l.resolve(d+f.content.size))});super(u[0].$from,u[0].$to,u),this.$anchorCell=e,this.$headCell=t}map(e,t){const r=e.resolve(t.map(this.$anchorCell.pos)),i=e.resolve(t.map(this.$headCell.pos));if(Qu(r)&&Qu(i)&&Cf(r,i)){const o=this.$anchorCell.node(-1)!=r.node(-1);return o&&this.isRowSelection()?Jt.rowSelection(r,i):o&&this.isColSelection()?Jt.colSelection(r,i):new Jt(r,i)}return $.between(r,i)}content(){const e=this.$anchorCell.node(-1),t=re.get(e),r=this.$anchorCell.start(-1),i=t.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),o={},s=[];for(let a=i.top;a0||w>0){let g=h.attrs;if(m>0&&(g=ri(g,0,m)),w>0&&(g=ri(g,g.colspan-w,w)),p.lefti.bottom){const g={...h.attrs,rowspan:Math.min(p.bottom,i.bottom)-Math.max(p.top,i.top)};p.top0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,i=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,i)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){const r=e.node(-1),i=re.get(r),o=e.start(-1),s=i.findCell(e.pos-o),l=i.findCell(t.pos-o),a=e.node(0);return s.top<=l.top?(s.top>0&&(e=a.resolve(o+i.map[s.left])),l.bottom0&&(t=a.resolve(o+i.map[l.left])),s.bottom0)return!1;const s=i+this.$anchorCell.nodeAfter.attrs.colspan,l=o+this.$headCell.nodeAfter.attrs.colspan;return Math.max(s,l)==t.width}eq(e){return e instanceof Jt&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){const r=e.node(-1),i=re.get(r),o=e.start(-1),s=i.findCell(e.pos-o),l=i.findCell(t.pos-o),a=e.node(0);return s.left<=l.left?(s.left>0&&(e=a.resolve(o+i.map[s.top*i.width])),l.right0&&(t=a.resolve(o+i.map[l.top*i.width])),s.right{e.push(ye.node(r,r+t.nodeSize,{class:"selectedCell"}))}),_.create(n.doc,e)}function Wx({$from:n,$to:e}){if(n.pos==e.pos||n.pos=0&&!(n.after(i+1)=0&&!(e.before(o+1)>e.start(o));o--,r--);return t==r&&/row|table/.test(n.node(i).type.spec.tableRole)}function Ux({$from:n,$to:e}){let t,r;for(let i=n.depth;i>0;i--){const o=n.node(i);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){t=o;break}}for(let i=e.depth;i>0;i--){const o=e.node(i);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){r=o;break}}return t!==r&&e.parentOffset===0}function Hx(n,e,t){const r=(e||n).selection,i=(e||n).doc;let o,s;if(r instanceof z&&(s=r.node.type.spec.tableRole)){if(s=="cell"||s=="header_cell")o=fe.create(i,r.from);else if(s=="row"){const l=i.resolve(r.from+1);o=fe.rowSelection(l,l)}else if(!t){const l=re.get(r.node),a=r.from+1,u=a+l.map[l.width*l.height-1];o=fe.create(i,a+1,u)}}else r instanceof $&&Wx(r)?o=$.create(i,r.from):r instanceof $&&Ux(r)&&(o=$.create(i,r.$from.start(),r.$from.end()));return o&&(e||(e=n.tr)).setSelection(o),e}var jx=new Yo("fix-tables");function Oy(n,e,t,r){const i=n.childCount,o=e.childCount;e:for(let s=0,l=0;s{i.type.spec.tableRole=="table"&&(t=qx(n,i,o,t))};return e?e.doc!=n.doc&&Oy(e.doc,n.doc,0,r):n.doc.descendants(r),t}function qx(n,e,t,r){const i=re.get(e);if(!i.problems)return r;r||(r=n.tr);const o=[];for(let a=0;a0){let p="cell";c.firstChild&&(p=c.firstChild.type.spec.tableRole);const h=[];for(let w=0;w0&&r>0||e.child(0).type.spec.tableRole=="table");)t--,r--,e=e.child(0).content;const i=e.child(0),o=i.type.spec.tableRole,s=i.type.schema,l=[];if(o=="row")for(let a=0;a=0;s--){const{rowspan:l,colspan:a}=o.child(s).attrs;for(let u=i;u=e.length&&e.push(x.empty),t[i]r&&(d=d.type.createChecked(ri(d.attrs,d.attrs.colspan,c+d.attrs.colspan-r),d.content)),u.push(d),c+=d.attrs.colspan;for(let p=1;pi&&(f=f.type.create({...f.attrs,rowspan:Math.max(1,i-f.attrs.rowspan)},f.content)),a.push(f)}o.push(x.from(a))}t=o,e=i}return{width:n,height:e,rows:t}}function Xx(n,e,t,r,i,o,s){const l=n.doc.type.schema,a=Ft(l);let u,c;if(i>e.width)for(let f=0,d=0;fe.height){const f=[];for(let h=0,m=(e.height-1)*e.width;h=e.width?!1:t.nodeAt(e.map[m+h]).type==a.header_cell;f.push(w?c||(c=a.header_cell.createAndFill()):u||(u=a.cell.createAndFill()))}const d=a.row.create(null,x.from(f)),p=[];for(let h=e.height;h{if(!i)return!1;const o=t.selection;if(o instanceof fe)return el(t,r,P.near(o.$headCell,e));if(n!="horiz"&&!o.empty)return!1;const s=Dy(i,n,e);if(s==null)return!1;if(n=="horiz")return el(t,r,P.near(t.doc.resolve(o.head+e),e));{const l=t.doc.resolve(s),a=My(l,n,e);let u;return a?u=P.near(a,1):e<0?u=P.near(t.doc.resolve(l.before(-1)),-1):u=P.near(t.doc.resolve(l.after(-1)),1),el(t,r,u)}}}function ms(n,e){return(t,r,i)=>{if(!i)return!1;const o=t.selection;let s;if(o instanceof fe)s=o;else{const a=Dy(i,n,e);if(a==null)return!1;s=new fe(t.doc.resolve(a))}const l=My(s.$headCell,n,e);return l?el(t,r,new fe(s.$anchorCell,l)):!1}}function gs(n,e){const t=n.selection;if(!(t instanceof fe))return!1;if(e){const r=n.tr,i=Ft(n.schema).cell.createAndFill().content;t.forEachCell((o,s)=>{o.content.eq(i)||r.replace(r.mapping.map(s+1),r.mapping.map(s+o.nodeSize-1),new v(i,0,0))}),r.docChanged&&e(r)}return!0}function eC(n,e){const t=n.state.doc,r=es(t.resolve(e));return r?(n.dispatch(n.state.tr.setSelection(new fe(r))),!0):!1}function tC(n,e,t){if(!xf(n.state))return!1;let r=Qx(t);const i=n.state.selection;if(i instanceof fe){r||(r={width:1,height:1,rows:[x.from(Yu(Ft(n.state.schema).cell,t))]});const o=i.$anchorCell.node(-1),s=i.$anchorCell.start(-1),l=re.get(o).rectBetween(i.$anchorCell.pos-s,i.$headCell.pos-s);return r=Gx(r,l.right-l.left,l.bottom-l.top),$h(n.state,n.dispatch,s,l,r),!0}else if(r){const o=Ny(n.state),s=o.start(-1);return $h(n.state,n.dispatch,s,re.get(o.node(-1)).findCell(o.pos-s),r),!0}else return!1}function nC(n,e){var t;if(e.ctrlKey||e.metaKey)return;const r=Vh(n,e.target);let i;if(e.shiftKey&&n.state.selection instanceof fe)o(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(i=es(n.state.selection.$anchor))!=null&&((t=Ha(n,e))==null?void 0:t.pos)!=i.pos)o(i,e),e.preventDefault();else if(!r)return;function o(a,u){let c=Ha(n,u);const f=an.getState(n.state)==null;if(!c||!Cf(a,c))if(f)c=a;else return;const d=new fe(a,c);if(f||!n.state.selection.eq(d)){const p=n.state.tr.setSelection(d);f&&p.setMeta(an,a.pos),n.dispatch(p)}}function s(){n.root.removeEventListener("mouseup",s),n.root.removeEventListener("dragstart",s),n.root.removeEventListener("mousemove",l),an.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(an,-1))}function l(a){const u=a,c=an.getState(n.state);let f;if(c!=null)f=n.state.doc.resolve(c);else if(Vh(n,u.target)!=r&&(f=Ha(n,e),!f))return s();f&&o(f,u)}n.root.addEventListener("mouseup",s),n.root.addEventListener("dragstart",s),n.root.addEventListener("mousemove",l)}function Dy(n,e,t){if(!(n.state.selection instanceof $))return null;const{$head:r}=n.state.selection;for(let i=r.depth-1;i>=0;i--){const o=r.node(i);if((t<0?r.index(i):r.indexAfter(i))!=(t<0?0:o.childCount))return null;if(o.type.spec.tableRole=="cell"||o.type.spec.tableRole=="header_cell"){const l=r.before(i),a=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(a)?l:null}}return null}function Vh(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Ha(n,e){const t=n.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?es(n.state.doc.resolve(t.pos)):null}var rC=class{constructor(n,e){this.node=n,this.cellMinWidth=e,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")),Gu(n,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(n){return n.type!=this.node.type?!1:(this.node=n,Gu(n,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(n){return n.type=="attributes"&&(n.target==this.table||this.colgroup.contains(n.target))}};function Gu(n,e,t,r,i,o){var s;let l=0,a=!0,u=e.firstChild;const c=n.firstChild;if(c){for(let f=0,d=0;fnew t(l,e,a),new oC(-1,!1)},apply(o,s){return s.apply(o)}},props:{attributes:o=>{const s=ut.getState(o);return s&&s.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(o,s)=>{sC(o,s,n,e,r)},mouseleave:o=>{lC(o)},mousedown:(o,s)=>{aC(o,s,e)}},decorations:o=>{const s=ut.getState(o);if(s&&s.activeHandle>-1)return pC(o,s.activeHandle)},nodeViews:{}}});return i}var oC=class tl{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){const t=this,r=e.getMeta(ut);if(r&&r.setHandle!=null)return new tl(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new tl(t.activeHandle,r.setDragging);if(t.activeHandle>-1&&e.docChanged){let i=e.mapping.map(t.activeHandle,-1);return Qu(e.doc.resolve(i))||(i=-1),new tl(i,t.dragging)}return t}};function sC(n,e,t,r,i){const o=ut.getState(n.state);if(o&&!o.dragging){const s=cC(e.target);let l=-1;if(s){const{left:a,right:u}=s.getBoundingClientRect();e.clientX-a<=t?l=Bh(n,e,"left",t):u-e.clientX<=t&&(l=Bh(n,e,"right",t))}if(l!=o.activeHandle){if(!i&&l!==-1){const a=n.state.doc.resolve(l),u=a.node(-1),c=re.get(u),f=a.start(-1);if(c.colCount(a.pos-f)+a.nodeAfter.attrs.colspan-1==c.width-1)return}Ty(n,l)}}}function lC(n){const e=ut.getState(n.state);e&&e.activeHandle>-1&&!e.dragging&&Ty(n,-1)}function aC(n,e,t){var r;const i=(r=n.dom.ownerDocument.defaultView)!=null?r:window,o=ut.getState(n.state);if(!o||o.activeHandle==-1||o.dragging)return!1;const s=n.state.doc.nodeAt(o.activeHandle),l=uC(n,o.activeHandle,s.attrs);n.dispatch(n.state.tr.setMeta(ut,{setDragging:{startX:e.clientX,startWidth:l}}));function a(c){i.removeEventListener("mouseup",a),i.removeEventListener("mousemove",u);const f=ut.getState(n.state);f!=null&&f.dragging&&(fC(n,f.activeHandle,Jh(f.dragging,c,t)),n.dispatch(n.state.tr.setMeta(ut,{setDragging:null})))}function u(c){if(!c.which)return a(c);const f=ut.getState(n.state);if(f&&f.dragging){const d=Jh(f.dragging,c,t);dC(n,f.activeHandle,d,t)}}return i.addEventListener("mouseup",a),i.addEventListener("mousemove",u),e.preventDefault(),!0}function uC(n,e,{colspan:t,colwidth:r}){const i=r&&r[r.length-1];if(i)return i;const o=n.domAtPos(e);let l=o.node.childNodes[o.offset].offsetWidth,a=t;if(r)for(let u=0;ui.table.nodeAt(a));for(let a=0;a{const h=p+o.tableStart,m=s.doc.nodeAt(h);m&&s.setNodeMarkup(h,d,m.attrs)}),r(s)}return!0}}Nf("row",{useDeprecatedLogic:!0});Nf("column",{useDeprecatedLogic:!0});Nf("cell",{useDeprecatedLogic:!0});function gC({allowTableNodeSelection:n=!1}={}){return new $t({key:an,state:{init(){return null},apply(e,t){const r=e.getMeta(an);if(r!=null)return r==-1?null:r;if(t==null||!e.docChanged)return t;const{deleted:i,pos:o}=e.mapping.mapResult(t);return i?null:o}},props:{decorations:_x,handleDOMEvents:{mousedown:nC},createSelectionBetween(e){return an.getState(e.state)!=null?e.state.selection:null},handleTripleClick:eC,handleKeyDown:Zx,handlePaste:tC},appendTransaction(e,t,r){return Hx(r,Kx(r,t),n)}})}var Ay={exports:{}},rt={},by={exports:{}},zy={};/** +`))),0,0):v.empty;let f=n.someProp("clipboardTextParser",d=>d(e,i,r,n));if(f)l=f;else{let d=i.marks(),{schema:p}=n.state,h=pi.fromSchema(p);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let w=s.appendChild(document.createElement("p"));m&&w.appendChild(h.serializeNode(p.text(m,d)))})}}else n.someProp("transformPastedHTML",f=>{t=f(t,n)}),s=Yk(t),Go&&Gk(s);let u=s&&s.querySelector("[data-pm-slice]"),c=u&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(u.getAttribute("data-pm-slice")||"");if(c&&c[3])for(let f=+c[3];f>0;f--){let d=s.firstChild;for(;d&&d.nodeType!=1;)d=d.nextSibling;if(!d)break;s=d}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||yo.fromSchema(n.state.schema)).parseSlice(s,{preserveWhitespace:!!(a||c),context:i,ruleFromNode(d){return d.nodeName=="BR"&&!d.nextSibling&&d.parentNode&&!Kk.test(d.parentNode.nodeName)?{ignore:!0}:null}})),c)l=Xk(gh(l,+c[1],+c[2]),c[4]);else if(l=v.maxOpen(qk(l.content,i),!0),l.openStart||l.openEnd){let f=0,d=0;for(let p=l.content.firstChild;f{l=f(l,n)}),l}const Kk=/^(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 qk(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let i=e.node(t).contentMatchAt(e.index(t)),o,s=[];if(n.forEach(l=>{if(!s)return;let a=i.findWrapping(l.type),u;if(!a)return s=null;if(u=s.length&&o.length&&Hg(a,o,l,s[s.length-1],0))s[s.length-1]=u;else{s.length&&(s[s.length-1]=jg(s[s.length-1],o.length));let c=Ug(l,a);s.push(c),i=i.matchType(c.type),o=a}}),s)return x.from(s)}return n}function Ug(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,x.from(n));return n}function Hg(n,e,t,r,i){if(i1&&(o=0),i=t&&(l=e<0?s.contentMatchAt(0).fillBefore(l,o<=i).append(l):l.append(s.contentMatchAt(s.childCount).fillBefore(x.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,s.copy(l))}function gh(n,e,t){return et}).createHTML(n):n}function Yk(n){let e=/^(\s*]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=qg().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),i;if((i=r&&Kg[r[1].toLowerCase()])&&(n=i.map(o=>"<"+o+">").join("")+n+i.map(o=>"").reverse().join("")),t.innerHTML=Qk(n),i)for(let o=0;o=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;i=x.from(a.create(r[l+1],i)),o++,s++}return new v(i,o,s)}const ze={},Ie={},Zk={touchstart:!0,touchmove:!0};class ev{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastAndroidDelete=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 tv(n){for(let e in ze){let t=ze[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{rv(n,r)&&!pf(n,r)&&(n.editable||!(r.type in Ie))&&t(n,r)},Zk[e]?{passive:!0}:void 0)}be&&n.dom.addEventListener("input",()=>null),_u(n)}function hn(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function nv(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 _u(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>pf(n,r))})}function pf(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function rv(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 iv(n,e){!pf(n,e)&&ze[e.type]&&(n.editable||!(e.type in Ie))&&ze[e.type](n,e)}Ie.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!Yg(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(wt&&Me&&t.keyCode==13)))if(n.domObserver.selectionChanged(n.domSelectionRange())?n.domObserver.flush():t.keyCode!=229&&n.domObserver.forceFlush(),Zr&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",i=>i(n,qn(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||jk(n,t)?t.preventDefault():hn(n,"key")};Ie.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};Ie.keypress=(n,e)=>{let t=e;if(Yg(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||ot&&t.metaKey)return;if(n.someProp("handleKeyPress",i=>i(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof $)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(t.charCode);!/[\r\n]/.test(i)&&!n.someProp("handleTextInput",o=>o(n,r.$from.pos,r.$to.pos,i))&&n.dispatch(n.state.tr.insertText(i).scrollIntoView()),t.preventDefault()}};function ea(n){return{left:n.clientX,top:n.clientY}}function ov(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function mf(n,e,t,r,i){if(r==-1)return!1;let o=n.state.doc.resolve(r);for(let s=o.depth+1;s>0;s--)if(n.someProp(e,l=>s>o.depth?l(n,t,o.nodeAfter,o.before(s),i,!0):l(n,t,o.node(s),o.before(s),i,!1)))return!0;return!1}function Br(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 sv(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&z.isSelectable(r)?(Br(n,new z(t)),!0):!1}function lv(n,e){if(e==-1)return!1;let t=n.state.selection,r,i;t instanceof z&&(r=t.node);let o=n.state.doc.resolve(e);for(let s=o.depth+1;s>0;s--){let l=s>o.depth?o.nodeAfter:o.node(s);if(z.isSelectable(l)){r&&t.$from.depth>0&&s>=t.$from.depth&&o.before(t.$from.depth+1)==t.$from.pos?i=o.before(t.$from.depth):i=o.before(s);break}}return i!=null?(Br(n,z.create(n.state.doc,i)),!0):!1}function av(n,e,t,r,i){return mf(n,"handleClickOn",e,t,r)||n.someProp("handleClick",o=>o(n,e,r))||(i?lv(n,t):sv(n,t))}function uv(n,e,t,r){return mf(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",i=>i(n,e,r))}function cv(n,e,t,r){return mf(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",i=>i(n,e,r))||fv(n,t,r)}function fv(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(Br(n,$.create(r,0,r.content.size)),!0):!1;let i=r.resolve(e);for(let o=i.depth+1;o>0;o--){let s=o>i.depth?i.nodeAfter:i.node(o),l=i.before(o);if(s.inlineContent)Br(n,$.create(r,l+1,l+1+s.content.size));else if(z.isSelectable(s))Br(n,z.create(r,l));else continue;return!0}}function gf(n){return vl(n)}const Qg=ot?"metaKey":"ctrlKey";ze.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=gf(n),i=Date.now(),o="singleClick";i-n.input.lastClick.time<500&&ov(t,n.input.lastClick)&&!t[Qg]&&(n.input.lastClick.type=="singleClick"?o="doubleClick":n.input.lastClick.type=="doubleClick"&&(o="tripleClick")),n.input.lastClick={time:i,x:t.clientX,y:t.clientY,type:o};let s=n.posAtCoords(ea(t));s&&(o=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new dv(n,s,t,!!r)):(o=="doubleClick"?uv:cv)(n,s.pos,s.inside,t)?t.preventDefault():hn(n,"pointer"))};class dv{constructor(e,t,r,i){this.view=e,this.pos=t,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[Qg],this.allowDefault=r.shiftKey;let o,s;if(t.inside>-1)o=e.state.doc.nodeAt(t.inside),s=t.inside;else{let c=e.state.doc.resolve(t.pos);o=c.parent,s=c.depth?c.before():0}const l=i?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.dom.nodeType==1?a.dom:null;let{selection:u}=e.state;(r.button==0&&o.type.spec.draggable&&o.type.spec.selectable!==!1||u instanceof z&&u.from<=s&&u.to>s)&&(this.mightDrag={node:o,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Ct&&!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)),hn(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(()=>qt(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(ea(e))),this.updateAllowDefault(e),this.allowDefault||!t?hn(this.view,"pointer"):av(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||be&&this.mightDrag&&!this.mightDrag.node.isAtom||Me&&!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)?(Br(this.view,P.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):hn(this.view,"pointer")}move(e){this.updateAllowDefault(e),hn(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)}}ze.touchstart=n=>{n.input.lastTouch=Date.now(),gf(n),hn(n,"pointer")};ze.touchmove=n=>{n.input.lastTouch=Date.now(),hn(n,"pointer")};ze.contextmenu=n=>gf(n);function Yg(n,e){return n.composing?!0:be&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const hv=wt?5e3:-1;Ie.compositionstart=Ie.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof $&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),vl(n,!0),n.markCursor=null;else if(vl(n,!e.selection.empty),Ct&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let i=r.focusNode,o=r.focusOffset;i&&i.nodeType==1&&o!=0;){let s=o<0?i.lastChild:i.childNodes[o-1];if(!s)break;if(s.nodeType==3){let l=n.domSelection();l&&l.collapse(s,s.nodeValue.length);break}else i=s,o=-1}}n.input.composing=!0}Gg(n,hv)};Ie.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++,Gg(n,20))};function Gg(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>vl(n),e))}function Xg(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=mv());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function pv(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=sk(e.focusNode,e.focusOffset),r=lk(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let i=r.pmViewDesc,o=n.domObserver.lastChangedTextNode;if(t==o||r==o)return o;if(!i||!i.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let s=t.pmViewDesc;if(!(!s||!s.isText(t.nodeValue)))return r}}return t||r}function mv(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function vl(n,e=!1){if(!(wt&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Xg(n),e||n.docView&&n.docView.dirty){let t=df(n);return t&&!t.eq(n.state.selection)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!n.state.selection.empty?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function gv(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const vo=We&&Sn<15||Zr&&dk<604;ze.copy=Ie.cut=(n,e)=>{let t=e,r=n.state.selection,i=t.type=="cut";if(r.empty)return;let o=vo?null:t.clipboardData,s=r.content(),{dom:l,text:a}=_g(n,s);o?(t.preventDefault(),o.clearData(),o.setData("text/html",l.innerHTML),o.setData("text/plain",a)):gv(n,l),i&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function yv(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function Sv(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?xo(n,r.value,null,i,e):xo(n,r.textContent,r.innerHTML,i,e)},50)}function xo(n,e,t,r,i){let o=Wg(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,i,o||v.empty)))return!0;if(!o)return!1;let s=yv(o),l=s?n.state.tr.replaceSelectionWith(s,r):n.state.tr.replaceSelection(o);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Zg(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}Ie.paste=(n,e)=>{let t=e;if(n.composing&&!wt)return;let r=vo?null:t.clipboardData,i=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&xo(n,Zg(r),r.getData("text/html"),i,t)?t.preventDefault():Sv(n,t)};class ey{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}}const ty=ot?"altKey":"ctrlKey";ze.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let i=n.state.selection,o=i.empty?null:n.posAtCoords(ea(t)),s;if(!(o&&o.pos>=i.from&&o.pos<=(i instanceof z?i.to-1:i.to))){if(r&&r.mightDrag)s=z.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let f=n.docView.nearestDesc(t.target,!0);f&&f.node.type.spec.draggable&&f!=n.docView&&(s=z.create(n.state.doc,f.posBefore))}}let l=(s||n.state.selection).content(),{dom:a,text:u,slice:c}=_g(n,l);(!t.dataTransfer.files.length||!Me||Cg>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(vo?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",vo||t.dataTransfer.setData("text/plain",u),n.dragging=new ey(c,!t[ty],s)};ze.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};Ie.dragover=Ie.dragenter=(n,e)=>e.preventDefault();Ie.drop=(n,e)=>{let t=e,r=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let i=n.posAtCoords(ea(t));if(!i)return;let o=n.state.doc.resolve(i.pos),s=r&&r.slice;s?n.someProp("transformPasted",h=>{s=h(s,n)}):s=Wg(n,Zg(t.dataTransfer),vo?null:t.dataTransfer.getData("text/html"),!1,o);let l=!!(r&&!t[ty]);if(n.someProp("handleDrop",h=>h(n,t,s||v.empty,l))){t.preventDefault();return}if(!s)return;t.preventDefault();let a=s?nk(n.state.doc,o.pos,s):o.pos;a==null&&(a=o.pos);let u=n.state.tr;if(l){let{node:h}=r;h?h.replace(u):u.deleteSelection()}let c=u.mapping.map(a),f=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,d=u.doc;if(f?u.replaceRangeWith(c,c,s.content.firstChild):u.replaceRange(c,c,s),u.doc.eq(d))return;let p=u.doc.resolve(c);if(f&&z.isSelectable(s.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(s.content.firstChild))u.setSelection(new z(p));else{let h=u.mapping.map(a);u.mapping.maps[u.mapping.maps.length-1].forEach((m,w,g,y)=>h=y),u.setSelection(hf(n,p,u.doc.resolve(h)))}n.focus(),n.dispatch(u.setMeta("uiEvent","drop"))};ze.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())&&qt(n)},20))};ze.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)};ze.beforeinput=(n,e)=>{if(Me&&wt&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",o=>o(n,qn(8,"Backspace")))))return;let{$cursor:i}=n.state.selection;i&&i.pos>0&&n.dispatch(n.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let n in Ie)ze[n]=Ie[n];function Co(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 xl{constructor(e,t){this.toDOM=e,this.spec=t||nr,this.side=this.spec.side||0}map(e,t,r,i){let{pos:o,deleted:s}=e.mapResult(t.from+i,this.side<0?-1:1);return s?null:new Se(o-r,o-r,this)}valid(){return!0}eq(e){return this==e||e instanceof xl&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Co(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class wn{constructor(e,t){this.attrs=e,this.spec=t||nr}map(e,t,r,i){let o=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-r,s=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-r;return o>=s?null:new Se(o,s,this)}valid(e,t){return t.from=e&&(!o||o(l.spec))&&r.push(l.copy(l.from+i,l.to+i))}for(let s=0;se){let l=this.children[s]+1;this.children[s+2].findInner(e-l,t-l,r,i+l,o)}}map(e,t,r){return this==Ce||e.maps.length==0?this:this.mapInner(e,t,0,0,r||nr)}mapInner(e,t,r,i,o){let s;for(let l=0;l{let u=a+r,c;if(c=iy(t,l,u)){for(i||(i=this.children.slice());ol&&f.to=e){this.children[l]==e&&(r=this.children[l+2]);break}let o=e+1,s=o+t.content.size;for(let l=0;lo&&a.type instanceof wn){let u=Math.max(o,a.from)-o,c=Math.min(s,a.to)-o;ui.map(e,t,nr));return Mr.from(r)}forChild(e,t){if(t.isLeaf)return _.empty;let r=[];for(let i=0;it instanceof _)?e:e.reduce((t,r)=>t.concat(r instanceof _?r:r.members),[]))}}forEachSet(e){for(let t=0;t{let w=m-h-(p-d);for(let g=0;gy+c-f)continue;let S=l[g]+c-f;p>=S?l[g+1]=d<=S?-2:-1:d>=c&&w&&(l[g]+=w,l[g+1]+=w)}f+=w}),c=t.maps[u].map(c,-1)}let a=!1;for(let u=0;u=r.content.size){a=!0;continue}let d=t.map(n[u+1]+o,-1),p=d-i,{index:h,offset:m}=r.content.findIndex(f),w=r.maybeChild(h);if(w&&m==f&&m+w.nodeSize==p){let g=l[u+2].mapInner(t,w,c+1,n[u]+o+1,s);g!=Ce?(l[u]=f,l[u+1]=p,l[u+2]=g):(l[u+1]=-2,a=!0)}else a=!0}if(a){let u=kv(l,n,e,t,i,o,s),c=Cl(u,r,0,s);e=c.local;for(let f=0;ft&&s.to{let u=iy(n,l,a+t);if(u){o=!0;let c=Cl(u,l,t+a+1,r);c!=Ce&&i.push(a,a+l.nodeSize,c)}});let s=ry(o?oy(n):n,-t).sort(rr);for(let l=0;l0;)e++;n.splice(e,0,t)}function La(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=Ce&&e.push(r)}),n.cursorWrapper&&e.push(_.create(n.state.doc,[n.cursorWrapper.deco])),ny.from(e)}const vv={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},xv=We&&Sn<=11;let Cv=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}};class Nv{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Cv,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;ii.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),xv&&(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,vv)),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;tthis.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(ch(this.view)){if(this.suppressingSelectionUpdates)return qt(this.view);if(We&&Sn<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&lr(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,r;for(let o=e.focusNode;o;o=ko(o))t.add(o);for(let o=e.anchorNode;o;o=ko(o))if(t.has(o)){r=o;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}selectionChanged(e){return!this.suppressingSelectionUpdates&&!this.currentSelection.eq(e)&&ch(this.view)&&!this.ignoreSelectionChange(e)}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let r=e.domSelectionRange(),i=this.selectionChanged(r),o=-1,s=-1,l=!1,a=[];if(e.editable)for(let c=0;cf.nodeName=="BR");if(c.length==2){let[f,d]=c;f.parentNode&&f.parentNode.parentNode==d.parentNode?d.remove():f.remove()}else{let{focusNode:f}=this.currentSelection;for(let d of c){let p=d.parentNode;p&&p.nodeName=="LI"&&(!f||Ov(e,f)!=p)&&d.remove()}}}let u=null;o<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)-1||i)&&(o>-1&&(e.docView.markDirty(o,s),Mv(e)),this.handleDOMChange(o,s,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||qt(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 c=0;ci;w--){let g=r.childNodes[w-1],y=g.pmViewDesc;if(g.nodeName=="BR"&&!y){o=w;break}if(!y||y.size)break}let f=n.state.doc,d=n.someProp("domParser")||yo.fromSchema(n.state.schema),p=f.resolve(s),h=null,m=d.parse(r,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:o,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:Dv,context:p});if(u&&u[0].pos!=null){let w=u[0].pos,g=u[1]&&u[1].pos;g==null&&(g=w),h={anchor:w+s,head:g+s}}return{doc:m,sel:h,from:s,to:l}}function Dv(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(be&&/^(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||be&&/^(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 Rv=/^(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 Av(n,e,t,r,i){let o=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let b=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,I=df(n,b);if(I&&!n.state.selection.eq(I)){if(Me&&wt&&n.input.lastKeyCode===13&&Date.now()-100Vt(n,qn(13,"Enter"))))return;let ae=n.state.tr.setSelection(I);b=="pointer"?ae.setMeta("pointer",!0):b=="key"&&ae.scrollIntoView(),o&&ae.setMeta("composition",o),n.dispatch(ae)}return}let s=n.state.doc.resolve(e),l=s.sharedDepth(t);e=s.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,u=Tv(n,e,t),c=n.state.doc,f=c.slice(u.from,u.to),d,p;n.input.lastKeyCode===8&&Date.now()-100Date.now()-225||wt)&&i.some(b=>b.nodeType==1&&!Rv.test(b.nodeName))&&(!h||h.endA>=h.endB)&&n.someProp("handleKeyDown",b=>b(n,qn(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!h)if(r&&a instanceof $&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.composing&&!(u.sel&&u.sel.anchor!=u.sel.head))h={start:a.from,endA:a.to,endB:a.to};else{if(u.sel){let b=xh(n,n.state.doc,u.sel);if(b&&!b.eq(n.state.selection)){let I=n.state.tr.setSelection(b);o&&I.setMeta("composition",o),n.dispatch(I)}}return}n.state.selection.fromn.state.selection.from&&h.start<=n.state.selection.from+2&&n.state.selection.from>=u.from?h.start=n.state.selection.from:h.endA=n.state.selection.to-2&&n.state.selection.to<=u.to&&(h.endB+=n.state.selection.to-h.endA,h.endA=n.state.selection.to)),We&&Sn<=11&&h.endB==h.start+1&&h.endA==h.start&&h.start>u.from&&u.doc.textBetween(h.start-u.from-1,h.start-u.from+1)=="  "&&(h.start--,h.endA--,h.endB--);let m=u.doc.resolveNoCache(h.start-u.from),w=u.doc.resolveNoCache(h.endB-u.from),g=c.resolve(h.start),y=m.sameParent(w)&&m.parent.inlineContent&&g.end()>=h.endA,S;if((Zr&&n.input.lastIOSEnter>Date.now()-225&&(!y||i.some(b=>b.nodeName=="DIV"||b.nodeName=="P"))||!y&&m.posb(n,qn(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>h.start&&zv(c,h.start,h.endA,m,w)&&n.someProp("handleKeyDown",b=>b(n,qn(8,"Backspace")))){wt&&Me&&n.domObserver.suppressSelectionUpdates();return}Me&&wt&&h.endB==h.start&&(n.input.lastAndroidDelete=Date.now()),wt&&!y&&m.start()!=w.start()&&w.parentOffset==0&&m.depth==w.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==h.endA&&(h.endB-=2,w=u.doc.resolveNoCache(h.endB-u.from),setTimeout(()=>{n.someProp("handleKeyDown",function(b){return b(n,qn(13,"Enter"))})},20));let C=h.start,M=h.endA,N,O,T;if(y){if(m.pos==w.pos)We&&Sn<=11&&m.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>qt(n),20)),N=n.state.tr.delete(C,M),O=c.resolve(h.start).marksAcross(c.resolve(h.endA));else if(h.endA==h.endB&&(T=bv(m.parent.content.cut(m.parentOffset,w.parentOffset),g.parent.content.cut(g.parentOffset,h.endA-g.start()))))N=n.state.tr,T.type=="add"?N.addMark(C,M,T.mark):N.removeMark(C,M,T.mark);else if(m.parent.child(m.index()).isText&&m.index()==w.index()-(w.textOffset?0:1)){let b=m.parent.textBetween(m.parentOffset,w.parentOffset);if(n.someProp("handleTextInput",I=>I(n,C,M,b)))return;N=n.state.tr.insertText(b,C,M)}}if(N||(N=n.state.tr.replace(C,M,u.doc.slice(h.start-u.from,h.endB-u.from))),u.sel){let b=xh(n,N.doc,u.sel);b&&!(Me&&wt&&n.composing&&b.empty&&(h.start!=h.endB||n.input.lastAndroidDeletee.content.size?null:hf(n,e.resolve(t.anchor),e.resolve(t.head))}function bv(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,i=t,o=r,s,l,a;for(let c=0;cc.mark(l.addToSet(c.marks));else if(i.length==0&&o.length==1)l=o[0],s="remove",a=c=>c.mark(l.removeFromSet(c.marks));else return null;let u=[];for(let c=0;ct||$a(s,!0,!1)0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,i++,e=!1;if(t){let o=n.node(r).maybeChild(n.indexAfter(r));for(;o&&!o.isLeaf;)o=o.firstChild,i++}return i}function Iv(n,e,t,r,i){let o=n.findDiffStart(e,t);if(o==null)return null;let{a:s,b:l}=n.findDiffEnd(e,t+n.size,t+e.size);if(i=="end"){let a=Math.max(0,o-Math.min(s,l));r-=s+a-o}if(s=s?o-r:0;o-=a,o&&o=l?o-r:0;o-=a,o&&o=56320&&e<=57343&&t>=55296&&t<=56319}class Pv{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 ev,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Th),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=Eh(this),Mh(this),this.nodeViews=Oh(this),this.docView=ih(this.state.doc,Nh(this),La(this),this.dom,this),this.domObserver=new Nv(this,(r,i,o,s)=>Av(this,r,i,o,s)),this.domObserver.start(),tv(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&&_u(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Th),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let i=this.state,o=!1,s=!1;e.storedMarks&&this.composing&&(Xg(this),s=!0),this.state=e;let l=i.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let p=Oh(this);Lv(p,this.nodeViews)&&(this.nodeViews=p,o=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&_u(this),this.editable=Eh(this),Mh(this);let a=La(this),u=Nh(this),c=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",f=o||!this.docView.matchesNode(e.doc,u,a);(f||!e.selection.eq(i.selection))&&(s=!0);let d=c=="preserve"&&s&&this.dom.style.overflowAnchor==null&&mk(this);if(s){this.domObserver.stop();let p=f&&(We||Me)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&Fv(i.selection,e.selection);if(f){let h=Me?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=pv(this)),(o||!this.docView.update(e.doc,u,a,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=ih(e.doc,u,a,this.dom,this)),h&&!this.trackWrites&&(p=!0)}p||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Vk(this))?qt(this,p):(Vg(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),c=="reset"?this.dom.scrollTop=0:c=="to selection"?this.scrollToSelection():d&&gk(d)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof z){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Xd(this,t.getBoundingClientRect(),e)}else Xd(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;t0&&this.state.doc.nodeAt(o))==r.node&&(i=o)}this.dragging=new ey(e.slice,e.move,i<0?void 0:z.create(this.state.doc,i))}someProp(e,t){let r=this._props&&this._props[e],i;if(r!=null&&(i=t?t(r):r))return i;for(let s=0;st.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return xk(this,e)}coordsAtPos(e,t=1){return Tg(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,r=-1){let i=this.docView.posFromDOM(e,t,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,t){return Ok(this,t||this.state,e)}pasteHTML(e,t){return xo(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return xo(this,e,null,!0,t||new ClipboardEvent("paste"))}destroy(){this.docView&&(nv(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],La(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,ik())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return iv(this,e)}dispatch(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))}domSelectionRange(){let e=this.domSelection();return e?be&&this.root.nodeType===11&&uk(this.dom.ownerDocument)==this.dom&&Ev(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function Nh(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"),[Se.node(0,n.state.doc.content.size,e)]}function Mh(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:Se.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function Eh(n){return!n.someProp("editable",e=>e(n.state)===!1)}function Fv(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 Oh(n){let e=Object.create(null);function t(r){for(let i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function Lv(n,e){let t=0,r=0;for(let i in n){if(n[i]!=e[i])return!0;t++}for(let i in e)r++;return t!=r}function Th(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")}class ee extends P{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return ee.valid(r)?new ee(r):P.near(r)}content(){return v.empty}eq(e){return e instanceof ee&&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 ee(e.resolve(t.pos))}getBookmark(){return new wf(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!$v(e)||!Vv(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let i=t.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&ee.valid(e))return e;let i=e.pos,o=null;for(let s=e.depth;;s--){let l=e.node(s);if(t>0?e.indexAfter(s)0){o=l.child(t>0?e.indexAfter(s):e.index(s)-1);break}else if(s==0)return null;i+=t;let a=e.doc.resolve(i);if(ee.valid(a))return a}for(;;){let s=t>0?o.firstChild:o.lastChild;if(!s){if(o.isAtom&&!o.isText&&!z.isSelectable(o)){e=e.doc.resolve(i+o.nodeSize*t),r=!1;continue e}break}o=s,i+=t;let l=e.doc.resolve(i);if(ee.valid(l))return l}return null}}}ee.prototype.visible=!1;ee.findFrom=ee.findGapCursorFrom;P.jsonID("gapcursor",ee);class wf{constructor(e){this.pos=e}map(e){return new wf(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return ee.valid(t)?new ee(t):P.near(t)}}function $v(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 i=r.child(t-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||i.isAtom||i.type.spec.isolating)return!0;if(i.inlineContent)return!1}}return!0}function Vv(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 i=r.child(t);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||i.isAtom||i.type.spec.isolating)return!0;if(i.inlineContent)return!1}}return!0}function Bv(){return new $t({props:{decorations:Uv,createSelectionBetween(n,e,t){return e.pos==t.pos&&ee.valid(t)?new ee(t):null},handleClick:_v,handleKeyDown:Jv,handleDOMEvents:{beforeinput:Wv}}})}const Jv=Gw({ArrowLeft:hs("horiz",-1),ArrowRight:hs("horiz",1),ArrowUp:hs("vert",-1),ArrowDown:hs("vert",1)});function hs(n,e){const t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,o){let s=r.selection,l=e>0?s.$to:s.$from,a=s.empty;if(s instanceof $){if(!o.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let u=ee.findGapCursorFrom(l,e,a);return u?(i&&i(r.tr.setSelection(new ee(u))),!0):!1}}function _v(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!ee.valid(r))return!1;let i=n.posAtCoords({left:t.clientX,top:t.clientY});return i&&i.inside>-1&&z.isSelectable(n.state.doc.nodeAt(i.inside))?!1:(n.dispatch(n.state.tr.setSelection(new ee(r))),!0)}function Wv(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof ee))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 i=x.empty;for(let s=r.length-1;s>=0;s--)i=x.from(r[s].createAndFill(null,i));let o=n.state.tr.replace(t.pos,t.pos,new v(i,0,0));return o.setSelection($.near(o.doc.resolve(t.pos+1))),n.dispatch(o),!1}function Uv(n){if(!(n.selection instanceof ee))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",_.create(n.doc,[Se.widget(n.selection.head,e,{key:"gapcursor"})])}const sy=65535,ly=Math.pow(2,16);function Hv(n,e){return n+e*ly}function Dh(n){return n&sy}function jv(n){return(n-(n&sy))/ly}const ay=1,uy=2,Ys=4,cy=8;let Rh=class{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&cy)>0}get deletedBefore(){return(this.delInfo&(ay|Ys))>0}get deletedAfter(){return(this.delInfo&(uy|Ys))>0}get deletedAcross(){return(this.delInfo&Ys)>0}},ei=class Er{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&Er.empty)return Er.empty}recover(e){let t=0,r=Dh(e);if(!this.inverted)for(let i=0;ie)break;let u=this.ranges[l+o],c=this.ranges[l+s],f=a+u;if(e<=f){let d=u?e==a?-1:e==f?1:t:t,p=a+i+(d<0?0:c);if(r)return p;let h=e==(t<0?a:f)?null:Hv(l/3,e-a),m=e==a?uy:e==f?ay:Ys;return(t<0?e!=a:e!=f)&&(m|=cy),new Rh(p,m,h)}i+=c-u}return r?e+i:new Rh(e+i,0,null)}touches(e,t){let r=0,i=Dh(t),o=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;le)break;let u=this.ranges[l+o],c=a+u;if(e<=c&&l==i*3)return!0;r+=this.ranges[l+s]-u}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,o=0;i!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),i),t.openStart,t.openEnd);return Je.fromReplace(e,this.from,this.to,o)}invert(){return new dy(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 Hi(t.pos,r.pos,this.mark)}merge(e){return e instanceof Hi&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Hi(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 Hi(t.from,t.to,e.markFromJSON(t.mark))}};Ye.jsonID("addMark",fy);let dy=class ji extends Ye{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 v(kf(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return Je.fromReplace(e,this.from,this.to,r)}invert(){return new fy(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 ji(t.pos,r.pos,this.mark)}merge(e){return e instanceof ji&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ji(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 ji(t.from,t.to,e.markFromJSON(t.mark))}};Ye.jsonID("removeMark",dy);let hy=class Ki extends Ye{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Je.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return Je.fromReplace(e,this.pos,this.pos+1,new v(x.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let i=0;ir.pos?null:new Gs(t.pos,r.pos,i,o,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Gs(t.from,t.to,t.gapFrom,t.gapTo,v.fromJSON(e,t.slice),t.insert,!!t.structure)}};Ye.jsonID("replaceAround",qv);function Uu(n,e,t){let r=n.resolve(e),i=t-e,o=r.depth;for(;i>0&&o>0&&r.indexAfter(o)==r.node(o).childCount;)o--,i--;if(i>0){let s=r.node(o).maybeChild(r.indexAfter(o));for(;i>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,i--}}return!1}function Qv(n,e,t=null,r=n){let i=Yv(n,e),o=i&&Gv(r,e);return o?i.map(Ah).concat({type:e,attrs:t}).concat(o.map(Ah)):null}function Ah(n){return{type:n,attrs:null}}function Yv(n,e){let{parent:t,startIndex:r,endIndex:i}=n,o=t.contentMatchAt(r).findWrapping(e);if(!o)return null;let s=o.length?o[0]:e;return t.canReplaceWith(r,i,s)?o:null}function Gv(n,e){let{parent:t,startIndex:r,endIndex:i}=n,o=t.child(r),s=e.contentMatch.findWrapping(o.type);if(!s)return null;let a=(s.length?s[s.length-1]:e).contentMatch;for(let u=r;a&&u0&&(o=t[0].slice(s-l,s)+o,r=i)}return e.tr.insertText(o,r,i)}}const nx=500;function rx({rules:n}){let e=new $t({state:{init(){return null},apply(t,r){let i=t.getMeta(this);return i||(t.selectionSet||t.docChanged?null:r)}},props:{handleTextInput(t,r,i,o){return bh(t,r,i,o,n,e)},handleDOMEvents:{compositionend:t=>{setTimeout(()=>{let{$cursor:r}=t.state.selection;r&&bh(t,r.pos,r.pos,"",n,e)})}}},isInputRules:!0});return e}function bh(n,e,t,r,i,o){if(n.composing)return!1;let s=n.state,l=s.doc.resolve(e),a=l.parent.textBetween(Math.max(0,l.parentOffset-nx),l.parentOffset,null,"")+r;for(let u=0;u{let a=t instanceof Function?t(o):t,u=i.tr.delete(s,l),c=u.doc.resolve(s),f=c.blockRange(),d=f&&Qv(f,e,a);if(!d)return null;u.wrap(f,d);let p=u.doc.resolve(s-1).nodeBefore;return p&&p.type==e&&Xv(u.doc,s-1)&&!r&&u.join(s-1),u})}const ox=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function sx(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,i,o,s;for(let l=0;l127)&&(o=zt[r.keyCode])&&o!=i){let l=e[Ba(o,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}const cx=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function fx(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,i,o,s;for(let l=0;l127)&&(o=zt[r.keyCode])&&o!=i){let l=e[Ja(o,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}const my=65535,gy=Math.pow(2,16);function px(n,e){return n+e*gy}function zh(n){return n&my}function mx(n){return(n-(n&my))/gy}const yy=1,Sy=2,Zs=4,wy=8;class Hu{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&wy)>0}get deletedBefore(){return(this.delInfo&(yy|Zs))>0}get deletedAfter(){return(this.delInfo&(Sy|Zs))>0}get deletedAcross(){return(this.delInfo&Zs)>0}}class Xe{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&Xe.empty)return Xe.empty}recover(e){let t=0,r=zh(e);if(!this.inverted)for(let i=0;ie)break;let u=this.ranges[l+o],c=this.ranges[l+s],f=a+u;if(e<=f){let d=u?e==a?-1:e==f?1:t:t,p=a+i+(d<0?0:c);if(r)return p;let h=e==(t<0?a:f)?null:px(l/3,e-a),m=e==a?Sy:e==f?yy:Zs;return(t<0?e!=a:e!=f)&&(m|=wy),new Hu(p,m,h)}i+=c-u}return r?e+i:new Hu(e+i,0,null)}touches(e,t){let r=0,i=zh(t),o=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;le)break;let u=this.ranges[l+o],c=a+u;if(e<=c&&l==i*3)return!0;r+=this.ranges[l+s]-u}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,o=0;i=0;t--){let i=e.getMirror(t);this.appendMap(e.maps[t].invert(),i!=null&&i>t?r-i-1:void 0)}}invert(){let e=new io;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;ro&&a!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),i),t.openStart,t.openEnd);return oe.fromReplace(e,this.from,this.to,o)}invert(){return new Tt(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 pn(t.pos,r.pos,this.mark)}merge(e){return e instanceof pn&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new pn(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 pn(t.from,t.to,e.markFromJSON(t.mark))}}Te.jsonID("addMark",pn);class Tt extends Te{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new v(vf(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return oe.fromReplace(e,this.from,this.to,r)}invert(){return new pn(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 Tt(t.pos,r.pos,this.mark)}merge(e){return e instanceof Tt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Tt(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 Tt(t.from,t.to,e.markFromJSON(t.mark))}}Te.jsonID("removeMark",Tt);class mn extends Te{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 v(x.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let i=0;ir.pos?null:new Rt(t.pos,r.pos,i,o,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Rt(t.from,t.to,t.gapFrom,t.gapTo,v.fromJSON(e,t.slice),t.insert,!!t.structure)}}Te.jsonID("replaceAround",Rt);function ju(n,e,t){let r=n.resolve(e),i=t-e,o=r.depth;for(;i>0&&o>0&&r.indexAfter(o)==r.node(o).childCount;)o--,i--;if(i>0){let s=r.node(o).maybeChild(r.indexAfter(o));for(;i>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,i--}}return!1}function gx(n,e,t,r){let i=[],o=[],s,l;n.doc.nodesBetween(e,t,(a,u,c)=>{if(!a.isInline)return;let f=a.marks;if(!r.isInSet(f)&&c.type.allowsMarkType(r.type)){let d=Math.max(u,e),p=Math.min(u+a.nodeSize,t),h=r.addToSet(f);for(let m=0;mn.step(a)),o.forEach(a=>n.step(a))}function yx(n,e,t,r){let i=[],o=0;n.doc.nodesBetween(e,t,(s,l)=>{if(!s.isInline)return;o++;let a=null;if(r instanceof Ko){let u=s.marks,c;for(;c=r.isInSet(u);)(a||(a=[])).push(c),u=c.removeFromSet(u)}else r?r.isInSet(s.marks)&&(a=[r]):a=s.marks;if(a&&a.length){let u=Math.min(l+s.nodeSize,t);for(let c=0;cn.step(new Tt(s.from,s.to,s.style)))}function Sx(n,e,t,r=t.contentMatch){let i=n.doc.nodeAt(e),o=[],s=e+1;for(let l=0;l=0;l--)n.step(o[l])}function wx(n,e,t){let{$from:r,$to:i,depth:o}=e,s=r.before(o+1),l=i.after(o+1),a=s,u=l,c=x.empty,f=0;for(let h=o,m=!1;h>t;h--)m||r.index(h)>0?(m=!0,c=x.from(r.node(h).copy(c)),f++):a--;let d=x.empty,p=0;for(let h=o,m=!1;h>t;h--)m||i.after(h+1)=0;s--){if(r.size){let l=t[s].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=x.from(t[s].type.create(t[s].attrs,r))}let i=e.start,o=e.end;n.step(new Rt(i,o,i,o,new v(r,0,0),t.length,!0))}function vx(n,e,t,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=n.steps.length;n.doc.nodesBetween(e,t,(s,l)=>{if(s.isTextblock&&!s.hasMarkup(r,i)&&xx(n.doc,n.mapping.slice(o).map(l),r)){n.clearIncompatible(n.mapping.slice(o).map(l,1),r);let a=n.mapping.slice(o),u=a.map(l,1),c=a.map(l+s.nodeSize,1);return n.step(new Rt(u,c,u+1,c-1,new v(x.from(r.create(i,null,s.marks)),0,0),1,!0)),!1}})}function xx(n,e,t){let r=n.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,t)}function Cx(n,e,t,r,i){let o=n.doc.nodeAt(e);if(!o)throw new RangeError("No node at given position");t||(t=o.type);let s=t.create(r,null,i||o.marks);if(o.isLeaf)return n.replaceWith(e,e+o.nodeSize,s);if(!t.validContent(o.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new Rt(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new v(x.from(s),0,0),1,!0))}function Nx(n,e,t=1,r){let i=n.doc.resolve(e),o=x.empty,s=x.empty;for(let l=i.depth,a=i.depth-t,u=t-1;l>a;l--,u--){o=x.from(i.node(l).copy(o));let c=r&&r[u];s=x.from(c?c.type.create(c.attrs,s):i.node(l).copy(s))}n.step(new Re(e,e,new v(o.append(s),t,t),!0))}function Mx(n,e,t){let r=new Re(e-t,e+t,v.empty,!0);n.step(r)}function Ex(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let o=r.index(i);if(r.node(i).canReplaceWith(o,o,t))return r.before(i+1);if(o>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let o=r.indexAfter(i);if(r.node(i).canReplaceWith(o,o,t))return r.after(i+1);if(o0;i--)this.placed=x.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let u=this.findFittable();u?this.placeNodes(u):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let o=this.placed,s=r.depth,l=i.depth;for(;s&&l&&o.childCount==1;)o=o.firstChild.content,s--,l--;let a=new v(o,s,l);return e>-1?new Rt(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new Re(r.pos,i.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,i=this.unplaced.openEnd;r1&&(i=0),o.type.spec.isolating&&i<=r){e=r;break}t=o.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let i,o=null;r?(o=Wa(this.unplaced.content,r-1).firstChild,i=o.content):i=this.unplaced.content;let s=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:u}=this.frontier[l],c,f=null;if(t==1&&(s?u.matchType(s.type)||(f=u.fillBefore(x.from(s),!1)):o&&a.compatibleContent(o.type)))return{sliceDepth:r,frontierDepth:l,parent:o,inject:f};if(t==2&&s&&(c=u.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:l,parent:o,wrap:c};if(o&&u.matchType(o.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=Wa(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new v(e,t+1,Math.max(r,i.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=Wa(e,t);if(i.childCount<=1&&t>0){let o=e.size-t<=t+i.size;this.unplaced=new v(qi(e,t-1,1),t-1,o?t-1:r)}else this.unplaced=new v(qi(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:i,wrap:o}){for(;this.depth>t;)this.closeFrontierNode();if(o)for(let m=0;m1||a==0||m.content.size)&&(f=w,c.push(vy(m.mark(d.allowedMarks(m.marks)),u==1?a:0,u==l.childCount?p:-1)))}let h=u==l.childCount;h||(p=-1),this.placed=Qi(this.placed,t,x.from(c)),this.frontier[t].match=f,h&&p<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,w=l;m1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:i}=this.frontier[t],o=t=0;l--){let{match:a,type:u}=this.frontier[l],c=Ua(e,l,u,a,!0);if(!c||c.childCount)continue e}return{depth:t,fit:s,move:o?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Qi(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let i=e.node(r),o=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,o)}return e}openFrontierNode(e,t=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=Qi(this.placed,this.depth,x.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(x.empty,!0);t.childCount&&(this.placed=Qi(this.placed,this.frontier.length,t))}}function qi(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(qi(n.firstChild.content,e-1,t)))}function Qi(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Qi(n.lastChild.content,e-1,t)))}function Wa(n,e){for(let t=0;t1&&(r=r.replaceChild(0,vy(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(x.empty,!0)))),n.copy(r)}function Ua(n,e,t,r,i){let o=n.node(e),s=i?n.indexAfter(e):n.index(e);if(s==o.childCount&&!t.compatibleContent(o.type))return null;let l=r.fillBefore(o.content,!0,s);return l&&!Dx(t,o.content,s)?l:null}function Dx(n,e,t){for(let r=t;r0;d--,p--){let h=i.node(d).type.spec;if(h.defining||h.definingAsContext||h.isolating)break;s.indexOf(d)>-1?l=d:i.before(d)==p&&s.splice(1,0,-d)}let a=s.indexOf(l),u=[],c=r.openStart;for(let d=r.content,p=0;;p++){let h=d.firstChild;if(u.push(h),p==r.openStart)break;d=h.content}for(let d=c-1;d>=0;d--){let p=u[d],h=Rx(p.type);if(h&&!p.sameMarkup(i.node(Math.abs(l)-1)))c=d;else if(h||!p.type.isTextblock)break}for(let d=r.openStart;d>=0;d--){let p=(d+c+1)%(r.openStart+1),h=u[p];if(h)for(let m=0;m=0&&(n.replace(e,t,r),!(n.steps.length>f));d--){let p=s[d];p<0||(e=i.before(p),t=o.after(p))}}function xy(n,e,t,r,i){if(er){let o=i.contentMatchAt(0),s=o.fillBefore(n).append(n);n=s.append(o.matchFragment(s).fillBefore(x.empty,!0))}return n}function bx(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let i=Ex(n.doc,e,r.type);i!=null&&(e=t=i)}n.replaceRange(e,t,new v(x.from(r),0,0))}function zx(n,e,t){let r=n.doc.resolve(e),i=n.doc.resolve(t),o=Cy(r,i);for(let s=0;s0&&(a||r.node(l-1).canReplace(r.index(l-1),i.indexAfter(l-1))))return n.delete(r.before(l),i.after(l))}for(let s=1;s<=r.depth&&s<=i.depth;s++)if(e-r.start(s)==r.depth-s&&t>r.end(s)&&i.end(s)-t!=i.depth-s)return n.delete(r.before(s),t);n.delete(e,t)}function Cy(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let i=r;i>=0;i--){let o=n.start(i);if(oe.pos+(e.depth-i)||n.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(o==e.start(i)||i==n.depth&&i==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==o-1)&&t.push(i)}return t}class Jr extends Te{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return oe.fail("No node at attribute step's position");let r=Object.create(null);for(let o in t.attrs)r[o]=t.attrs[o];r[this.attr]=this.value;let i=t.type.create(r,null,t.marks);return oe.fromReplace(e,this.pos,this.pos+1,new v(x.from(i),0,t.isLeaf?0:1))}getMap(){return Xe.empty}invert(e){return new Jr(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 Jr(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 Jr(t.pos,t.attr,t.value)}}Te.jsonID("attr",Jr);class Mo extends Te{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let i in e.attrs)t[i]=e.attrs[i];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return oe.ok(r)}getMap(){return Xe.empty}invert(e){return new Mo(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 Mo(t.attr,t.value)}}Te.jsonID("docAttr",Mo);let ni=class extends Error{};ni=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};ni.prototype=Object.create(Error.prototype);ni.prototype.constructor=ni;ni.prototype.name="TransformError";class Ix{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new io}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new ni(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=v.empty){let i=Ox(this.doc,e,t,r);return i&&this.step(i),this}replaceWith(e,t,r){return this.replace(e,t,new v(x.from(r),0,0))}delete(e,t){return this.replace(e,t,v.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return Ax(this,e,t,r),this}replaceRangeWith(e,t,r){return bx(this,e,t,r),this}deleteRange(e,t){return zx(this,e,t),this}lift(e,t){return wx(this,e,t),this}join(e,t=1){return Mx(this,e,t),this}wrap(e,t){return kx(this,e,t),this}setBlockType(e,t=e,r,i=null){return vx(this,e,t,r,i),this}setNodeMarkup(e,t,r=null,i){return Cx(this,e,t,r,i),this}setNodeAttribute(e,t,r){return this.step(new Jr(e,t,r)),this}setDocAttribute(e,t){return this.step(new Mo(e,t)),this}addNodeMark(e,t){return this.step(new mn(e,t)),this}removeNodeMark(e,t){if(!(t instanceof W)){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t=t.isInSet(r.marks),!t)return this}return this.step(new ti(e,t)),this}split(e,t=1,r){return Nx(this,e,t,r),this}addMark(e,t,r){return gx(this,e,t,r),this}removeMark(e,t,r){return yx(this,e,t,r),this}clearIncompatible(e,t,r){return Sx(this,e,t,r),this}}var Ku,qu;if(typeof WeakMap<"u"){let n=new WeakMap;Ku=e=>n.get(e),qu=(e,t)=>(n.set(e,t),t)}else{const n=[];let t=0;Ku=r=>{for(let i=0;i(t==10&&(t=0),n[t++]=r,n[t++]=i)}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=t){(o||(o=[])).push({type:"overlong_rowspan",pos:c,n:g-S});break}const C=i+S*e;for(let M=0;Mr&&(o+=u.attrs.colspan)}}for(let s=0;s1&&(t=!0)}e==-1?e=o:e!=o&&(e=Math.max(e,o))}return e}function Lx(n,e,t){n.problems||(n.problems=[]);const r={};for(let i=0;iNumber(s)):null,i=Number(n.getAttribute("colspan")||1),o={colspan:i,rowspan:Number(n.getAttribute("rowspan")||1),colwidth:r&&r.length==i?r:null};for(const s in e){const l=e[s].getFromDOM,a=l&&l(n);a!=null&&(o[s]=a)}return o}function Ph(n,e){const t={};n.attrs.colspan!=1&&(t.colspan=n.attrs.colspan),n.attrs.rowspan!=1&&(t.rowspan=n.attrs.rowspan),n.attrs.colwidth&&(t["data-colwidth"]=n.attrs.colwidth.join(","));for(const r in e){const i=e[r].setDOMAttr;i&&i(n.attrs[r],t)}return t}function Vx(n){const e=n.cellAttributes||{},t={colspan:{default:1},rowspan:{default:1},colwidth:{default:null}};for(const r in e)t[r]={default:e[r].default};return{table:{content:"table_row+",tableRole:"table",isolating:!0,group:n.tableGroup,parseDOM:[{tag:"table"}],toDOM(){return["table",["tbody",0]]}},table_row:{content:"(table_cell | table_header)*",tableRole:"row",parseDOM:[{tag:"tr"}],toDOM(){return["tr",0]}},table_cell:{content:n.cellContent,attrs:t,tableRole:"cell",isolating:!0,parseDOM:[{tag:"td",getAttrs:r=>Ih(r,e)}],toDOM(r){return["td",Ph(r,e),0]}},table_header:{content:n.cellContent,attrs:t,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:r=>Ih(r,e)}],toDOM(r){return["th",Ph(r,e),0]}}}}function Ft(n){let e=n.cached.tableNodeTypes;if(!e){e=n.cached.tableNodeTypes={};for(const t in n.nodes){const r=n.nodes[t],i=r.spec.tableRole;i&&(e[i]=r)}}return e}var an=new Qo("selectingCells");function Zo(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 xf(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 Ny(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=Zo(e.$head)||Bx(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function Bx(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 Qu(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function Cf(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function My(n,e,t){const r=n.node(-1),i=re.get(r),o=n.start(-1),s=i.nextCell(n.pos-o,e,t);return s==null?null:n.node(0).resolve(o+s)}function ri(n,e,t=1){const r={...n,colspan:n.colspan-t};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,t),r.colwidth.some(i=>i>0)||(r.colwidth=null)),r}var fe=class Jt extends P{constructor(e,t=e){const r=e.node(-1),i=re.get(r),o=e.start(-1),s=i.rectBetween(e.pos-o,t.pos-o),l=e.node(0),a=i.cellsInRect(s).filter(c=>c!=t.pos-o);a.unshift(t.pos-o);const u=a.map(c=>{const f=r.nodeAt(c);if(!f)throw RangeError(`No cell with offset ${c} found`);const d=o+c+1;return new ig(l.resolve(d),l.resolve(d+f.content.size))});super(u[0].$from,u[0].$to,u),this.$anchorCell=e,this.$headCell=t}map(e,t){const r=e.resolve(t.map(this.$anchorCell.pos)),i=e.resolve(t.map(this.$headCell.pos));if(Qu(r)&&Qu(i)&&Cf(r,i)){const o=this.$anchorCell.node(-1)!=r.node(-1);return o&&this.isRowSelection()?Jt.rowSelection(r,i):o&&this.isColSelection()?Jt.colSelection(r,i):new Jt(r,i)}return $.between(r,i)}content(){const e=this.$anchorCell.node(-1),t=re.get(e),r=this.$anchorCell.start(-1),i=t.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),o={},s=[];for(let a=i.top;a0||w>0){let g=h.attrs;if(m>0&&(g=ri(g,0,m)),w>0&&(g=ri(g,g.colspan-w,w)),p.lefti.bottom){const g={...h.attrs,rowspan:Math.min(p.bottom,i.bottom)-Math.max(p.top,i.top)};p.top0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,i=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,i)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){const r=e.node(-1),i=re.get(r),o=e.start(-1),s=i.findCell(e.pos-o),l=i.findCell(t.pos-o),a=e.node(0);return s.top<=l.top?(s.top>0&&(e=a.resolve(o+i.map[s.left])),l.bottom0&&(t=a.resolve(o+i.map[l.left])),s.bottom0)return!1;const s=i+this.$anchorCell.nodeAfter.attrs.colspan,l=o+this.$headCell.nodeAfter.attrs.colspan;return Math.max(s,l)==t.width}eq(e){return e instanceof Jt&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){const r=e.node(-1),i=re.get(r),o=e.start(-1),s=i.findCell(e.pos-o),l=i.findCell(t.pos-o),a=e.node(0);return s.left<=l.left?(s.left>0&&(e=a.resolve(o+i.map[s.top*i.width])),l.right0&&(t=a.resolve(o+i.map[l.top*i.width])),s.right{e.push(Se.node(r,r+t.nodeSize,{class:"selectedCell"}))}),_.create(n.doc,e)}function Wx({$from:n,$to:e}){if(n.pos==e.pos||n.pos=0&&!(n.after(i+1)=0&&!(e.before(o+1)>e.start(o));o--,r--);return t==r&&/row|table/.test(n.node(i).type.spec.tableRole)}function Ux({$from:n,$to:e}){let t,r;for(let i=n.depth;i>0;i--){const o=n.node(i);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){t=o;break}}for(let i=e.depth;i>0;i--){const o=e.node(i);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){r=o;break}}return t!==r&&e.parentOffset===0}function Hx(n,e,t){const r=(e||n).selection,i=(e||n).doc;let o,s;if(r instanceof z&&(s=r.node.type.spec.tableRole)){if(s=="cell"||s=="header_cell")o=fe.create(i,r.from);else if(s=="row"){const l=i.resolve(r.from+1);o=fe.rowSelection(l,l)}else if(!t){const l=re.get(r.node),a=r.from+1,u=a+l.map[l.width*l.height-1];o=fe.create(i,a+1,u)}}else r instanceof $&&Wx(r)?o=$.create(i,r.from):r instanceof $&&Ux(r)&&(o=$.create(i,r.$from.start(),r.$from.end()));return o&&(e||(e=n.tr)).setSelection(o),e}var jx=new Qo("fix-tables");function Oy(n,e,t,r){const i=n.childCount,o=e.childCount;e:for(let s=0,l=0;s{i.type.spec.tableRole=="table"&&(t=qx(n,i,o,t))};return e?e.doc!=n.doc&&Oy(e.doc,n.doc,0,r):n.doc.descendants(r),t}function qx(n,e,t,r){const i=re.get(e);if(!i.problems)return r;r||(r=n.tr);const o=[];for(let a=0;a0){let p="cell";c.firstChild&&(p=c.firstChild.type.spec.tableRole);const h=[];for(let w=0;w0&&r>0||e.child(0).type.spec.tableRole=="table");)t--,r--,e=e.child(0).content;const i=e.child(0),o=i.type.spec.tableRole,s=i.type.schema,l=[];if(o=="row")for(let a=0;a=0;s--){const{rowspan:l,colspan:a}=o.child(s).attrs;for(let u=i;u=e.length&&e.push(x.empty),t[i]r&&(d=d.type.createChecked(ri(d.attrs,d.attrs.colspan,c+d.attrs.colspan-r),d.content)),u.push(d),c+=d.attrs.colspan;for(let p=1;pi&&(f=f.type.create({...f.attrs,rowspan:Math.max(1,i-f.attrs.rowspan)},f.content)),a.push(f)}o.push(x.from(a))}t=o,e=i}return{width:n,height:e,rows:t}}function Xx(n,e,t,r,i,o,s){const l=n.doc.type.schema,a=Ft(l);let u,c;if(i>e.width)for(let f=0,d=0;fe.height){const f=[];for(let h=0,m=(e.height-1)*e.width;h=e.width?!1:t.nodeAt(e.map[m+h]).type==a.header_cell;f.push(w?c||(c=a.header_cell.createAndFill()):u||(u=a.cell.createAndFill()))}const d=a.row.create(null,x.from(f)),p=[];for(let h=e.height;h{if(!i)return!1;const o=t.selection;if(o instanceof fe)return el(t,r,P.near(o.$headCell,e));if(n!="horiz"&&!o.empty)return!1;const s=Ty(i,n,e);if(s==null)return!1;if(n=="horiz")return el(t,r,P.near(t.doc.resolve(o.head+e),e));{const l=t.doc.resolve(s),a=My(l,n,e);let u;return a?u=P.near(a,1):e<0?u=P.near(t.doc.resolve(l.before(-1)),-1):u=P.near(t.doc.resolve(l.after(-1)),1),el(t,r,u)}}}function ms(n,e){return(t,r,i)=>{if(!i)return!1;const o=t.selection;let s;if(o instanceof fe)s=o;else{const a=Ty(i,n,e);if(a==null)return!1;s=new fe(t.doc.resolve(a))}const l=My(s.$headCell,n,e);return l?el(t,r,new fe(s.$anchorCell,l)):!1}}function gs(n,e){const t=n.selection;if(!(t instanceof fe))return!1;if(e){const r=n.tr,i=Ft(n.schema).cell.createAndFill().content;t.forEachCell((o,s)=>{o.content.eq(i)||r.replace(r.mapping.map(s+1),r.mapping.map(s+o.nodeSize-1),new v(i,0,0))}),r.docChanged&&e(r)}return!0}function eC(n,e){const t=n.state.doc,r=Zo(t.resolve(e));return r?(n.dispatch(n.state.tr.setSelection(new fe(r))),!0):!1}function tC(n,e,t){if(!xf(n.state))return!1;let r=Qx(t);const i=n.state.selection;if(i instanceof fe){r||(r={width:1,height:1,rows:[x.from(Yu(Ft(n.state.schema).cell,t))]});const o=i.$anchorCell.node(-1),s=i.$anchorCell.start(-1),l=re.get(o).rectBetween(i.$anchorCell.pos-s,i.$headCell.pos-s);return r=Gx(r,l.right-l.left,l.bottom-l.top),$h(n.state,n.dispatch,s,l,r),!0}else if(r){const o=Ny(n.state),s=o.start(-1);return $h(n.state,n.dispatch,s,re.get(o.node(-1)).findCell(o.pos-s),r),!0}else return!1}function nC(n,e){var t;if(e.ctrlKey||e.metaKey)return;const r=Vh(n,e.target);let i;if(e.shiftKey&&n.state.selection instanceof fe)o(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(i=Zo(n.state.selection.$anchor))!=null&&((t=Ha(n,e))==null?void 0:t.pos)!=i.pos)o(i,e),e.preventDefault();else if(!r)return;function o(a,u){let c=Ha(n,u);const f=an.getState(n.state)==null;if(!c||!Cf(a,c))if(f)c=a;else return;const d=new fe(a,c);if(f||!n.state.selection.eq(d)){const p=n.state.tr.setSelection(d);f&&p.setMeta(an,a.pos),n.dispatch(p)}}function s(){n.root.removeEventListener("mouseup",s),n.root.removeEventListener("dragstart",s),n.root.removeEventListener("mousemove",l),an.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(an,-1))}function l(a){const u=a,c=an.getState(n.state);let f;if(c!=null)f=n.state.doc.resolve(c);else if(Vh(n,u.target)!=r&&(f=Ha(n,e),!f))return s();f&&o(f,u)}n.root.addEventListener("mouseup",s),n.root.addEventListener("dragstart",s),n.root.addEventListener("mousemove",l)}function Ty(n,e,t){if(!(n.state.selection instanceof $))return null;const{$head:r}=n.state.selection;for(let i=r.depth-1;i>=0;i--){const o=r.node(i);if((t<0?r.index(i):r.indexAfter(i))!=(t<0?0:o.childCount))return null;if(o.type.spec.tableRole=="cell"||o.type.spec.tableRole=="header_cell"){const l=r.before(i),a=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(a)?l:null}}return null}function Vh(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Ha(n,e){const t=n.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?Zo(n.state.doc.resolve(t.pos)):null}var rC=class{constructor(n,e){this.node=n,this.cellMinWidth=e,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")),Gu(n,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(n){return n.type!=this.node.type?!1:(this.node=n,Gu(n,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(n){return n.type=="attributes"&&(n.target==this.table||this.colgroup.contains(n.target))}};function Gu(n,e,t,r,i,o){var s;let l=0,a=!0,u=e.firstChild;const c=n.firstChild;if(c){for(let f=0,d=0;fnew t(l,e,a),new oC(-1,!1)},apply(o,s){return s.apply(o)}},props:{attributes:o=>{const s=ut.getState(o);return s&&s.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(o,s)=>{sC(o,s,n,e,r)},mouseleave:o=>{lC(o)},mousedown:(o,s)=>{aC(o,s,e)}},decorations:o=>{const s=ut.getState(o);if(s&&s.activeHandle>-1)return pC(o,s.activeHandle)},nodeViews:{}}});return i}var oC=class tl{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){const t=this,r=e.getMeta(ut);if(r&&r.setHandle!=null)return new tl(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new tl(t.activeHandle,r.setDragging);if(t.activeHandle>-1&&e.docChanged){let i=e.mapping.map(t.activeHandle,-1);return Qu(e.doc.resolve(i))||(i=-1),new tl(i,t.dragging)}return t}};function sC(n,e,t,r,i){const o=ut.getState(n.state);if(o&&!o.dragging){const s=cC(e.target);let l=-1;if(s){const{left:a,right:u}=s.getBoundingClientRect();e.clientX-a<=t?l=Bh(n,e,"left",t):u-e.clientX<=t&&(l=Bh(n,e,"right",t))}if(l!=o.activeHandle){if(!i&&l!==-1){const a=n.state.doc.resolve(l),u=a.node(-1),c=re.get(u),f=a.start(-1);if(c.colCount(a.pos-f)+a.nodeAfter.attrs.colspan-1==c.width-1)return}Dy(n,l)}}}function lC(n){const e=ut.getState(n.state);e&&e.activeHandle>-1&&!e.dragging&&Dy(n,-1)}function aC(n,e,t){var r;const i=(r=n.dom.ownerDocument.defaultView)!=null?r:window,o=ut.getState(n.state);if(!o||o.activeHandle==-1||o.dragging)return!1;const s=n.state.doc.nodeAt(o.activeHandle),l=uC(n,o.activeHandle,s.attrs);n.dispatch(n.state.tr.setMeta(ut,{setDragging:{startX:e.clientX,startWidth:l}}));function a(c){i.removeEventListener("mouseup",a),i.removeEventListener("mousemove",u);const f=ut.getState(n.state);f!=null&&f.dragging&&(fC(n,f.activeHandle,Jh(f.dragging,c,t)),n.dispatch(n.state.tr.setMeta(ut,{setDragging:null})))}function u(c){if(!c.which)return a(c);const f=ut.getState(n.state);if(f&&f.dragging){const d=Jh(f.dragging,c,t);dC(n,f.activeHandle,d,t)}}return i.addEventListener("mouseup",a),i.addEventListener("mousemove",u),e.preventDefault(),!0}function uC(n,e,{colspan:t,colwidth:r}){const i=r&&r[r.length-1];if(i)return i;const o=n.domAtPos(e);let l=o.node.childNodes[o.offset].offsetWidth,a=t;if(r)for(let u=0;ui.table.nodeAt(a));for(let a=0;a{const h=p+o.tableStart,m=s.doc.nodeAt(h);m&&s.setNodeMarkup(h,d,m.attrs)}),r(s)}return!0}}Nf("row",{useDeprecatedLogic:!0});Nf("column",{useDeprecatedLogic:!0});Nf("cell",{useDeprecatedLogic:!0});function gC({allowTableNodeSelection:n=!1}={}){return new $t({key:an,state:{init(){return null},apply(e,t){const r=e.getMeta(an);if(r!=null)return r==-1?null:r;if(t==null||!e.docChanged)return t;const{deleted:i,pos:o}=e.mapping.mapResult(t);return i?null:o}},props:{decorations:_x,handleDOMEvents:{mousedown:nC},createSelectionBetween(e){return an.getState(e.state)!=null?e.state.selection:null},handleTripleClick:eC,handleKeyDown:Zx,handlePaste:tC},appendTransaction(e,t,r){return Hx(r,Kx(r,t),n)}})}var Ay={exports:{}},rt={},by={exports:{}},zy={};/** * @license React * scheduler.production.min.js * @@ -30,7 +30,7 @@ * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */(function(n){function e(A,F){var L=A.length;A.push(F);e:for(;0>>1,ue=A[te];if(0>>1;tei(Sa,L))Jni(as,Sa)?(A[te]=as,A[Jn]=L,te=Jn):(A[te]=Sa,A[Bn]=L,te=Bn);else if(Jni(as,L))A[te]=as,A[Jn]=L,te=Jn;else break e}}return F}function i(A,F){var L=A.sortIndex-F.sortIndex;return L!==0?L:A.id-F.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;n.unstable_now=function(){return o.now()}}else{var s=Date,l=s.now();n.unstable_now=function(){return s.now()-l}}var a=[],u=[],c=1,f=null,d=3,p=!1,h=!1,m=!1,w=typeof setTimeout=="function"?setTimeout:null,g=typeof clearTimeout=="function"?clearTimeout:null,y=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function S(A){for(var F=t(u);F!==null;){if(F.callback===null)r(u);else if(F.startTime<=A)r(u),F.sortIndex=F.expirationTime,e(a,F);else break;F=t(u)}}function C(A){if(m=!1,S(A),!h)if(t(a)!==null)h=!0,Vn(N);else{var F=t(u);F!==null&&Si(C,F.startTime-A)}}function N(A,F){h=!1,m&&(m=!1,g(T),T=-1),p=!0;var L=d;try{for(S(F),f=t(a);f!==null&&(!(f.expirationTime>F)||A&&!ae());){var te=f.callback;if(typeof te=="function"){f.callback=null,d=f.priorityLevel;var ue=te(f.expirationTime<=F);F=n.unstable_now(),typeof ue=="function"?f.callback=ue:f===t(a)&&r(a),S(F)}else r(a);f=t(a)}if(f!==null)var ls=!0;else{var Bn=t(u);Bn!==null&&Si(C,Bn.startTime-F),ls=!1}return ls}finally{f=null,d=L,p=!1}}var E=!1,O=null,T=-1,b=5,I=-1;function ae(){return!(n.unstable_now()-IA||125te?(A.sortIndex=L,e(u,A),t(a)===null&&A===t(u)&&(m?(g(T),T=-1):m=!0,Si(C,L-te))):(A.sortIndex=ue,e(a,A),h||p||(h=!0,Vn(N))),A},n.unstable_shouldYield=ae,n.unstable_wrapCallback=function(A){var F=d;return function(){var L=d;d=F;try{return A.apply(this,arguments)}finally{d=L}}}})(zy);by.exports=zy;var yC=by.exports;/** + */(function(n){function e(D,F){var L=D.length;D.push(F);e:for(;0>>1,ue=D[te];if(0>>1;tei(Sa,L))Jni(as,Sa)?(D[te]=as,D[Jn]=L,te=Jn):(D[te]=Sa,D[Bn]=L,te=Bn);else if(Jni(as,L))D[te]=as,D[Jn]=L,te=Jn;else break e}}return F}function i(D,F){var L=D.sortIndex-F.sortIndex;return L!==0?L:D.id-F.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;n.unstable_now=function(){return o.now()}}else{var s=Date,l=s.now();n.unstable_now=function(){return s.now()-l}}var a=[],u=[],c=1,f=null,d=3,p=!1,h=!1,m=!1,w=typeof setTimeout=="function"?setTimeout:null,g=typeof clearTimeout=="function"?clearTimeout:null,y=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function S(D){for(var F=t(u);F!==null;){if(F.callback===null)r(u);else if(F.startTime<=D)r(u),F.sortIndex=F.expirationTime,e(a,F);else break;F=t(u)}}function C(D){if(m=!1,S(D),!h)if(t(a)!==null)h=!0,he(M);else{var F=t(u);F!==null&&Vn(C,F.startTime-D)}}function M(D,F){h=!1,m&&(m=!1,g(T),T=-1),p=!0;var L=d;try{for(S(F),f=t(a);f!==null&&(!(f.expirationTime>F)||D&&!ae());){var te=f.callback;if(typeof te=="function"){f.callback=null,d=f.priorityLevel;var ue=te(f.expirationTime<=F);F=n.unstable_now(),typeof ue=="function"?f.callback=ue:f===t(a)&&r(a),S(F)}else r(a);f=t(a)}if(f!==null)var ls=!0;else{var Bn=t(u);Bn!==null&&Vn(C,Bn.startTime-F),ls=!1}return ls}finally{f=null,d=L,p=!1}}var N=!1,O=null,T=-1,b=5,I=-1;function ae(){return!(n.unstable_now()-ID||125te?(D.sortIndex=L,e(u,D),t(a)===null&&D===t(u)&&(m?(g(T),T=-1):m=!0,Vn(C,L-te))):(D.sortIndex=ue,e(a,D),h||p||(h=!0,he(M))),D},n.unstable_shouldYield=ae,n.unstable_wrapCallback=function(D){var F=d;return function(){var L=d;d=F;try{return D.apply(this,arguments)}finally{d=L}}}})(zy);by.exports=zy;var yC=by.exports;/** * @license React * react-dom.production.min.js * @@ -38,16 +38,16 @@ * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var Iy=k,nt=yC;function M(n){for(var e="https://reactjs.org/docs/error-decoder.html?invariant="+n,t=1;t"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Xu=Object.prototype.hasOwnProperty,SC=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,Wh={},Uh={};function wC(n){return Xu.call(Uh,n)?!0:Xu.call(Wh,n)?!1:SC.test(n)?Uh[n]=!0:(Wh[n]=!0,!1)}function kC(n,e,t,r){if(t!==null&&t.type===0)return!1;switch(typeof e){case"function":case"symbol":return!0;case"boolean":return r?!1:t!==null?!t.acceptsBooleans:(n=n.toLowerCase().slice(0,5),n!=="data-"&&n!=="aria-");default:return!1}}function vC(n,e,t,r){if(e===null||typeof e>"u"||kC(n,e,t,r))return!0;if(r)return!1;if(t!==null)switch(t.type){case 3:return!e;case 4:return e===!1;case 5:return isNaN(e);case 6:return isNaN(e)||1>e}return!1}function Fe(n,e,t,r,i,o,s){this.acceptsBooleans=e===2||e===3||e===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=t,this.propertyName=n,this.type=e,this.sanitizeURL=o,this.removeEmptyString=s}var we={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(n){we[n]=new Fe(n,0,!1,n,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(n){var e=n[0];we[e]=new Fe(e,1,!1,n[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(n){we[n]=new Fe(n,2,!1,n.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(n){we[n]=new Fe(n,2,!1,n,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(n){we[n]=new Fe(n,3,!1,n.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(n){we[n]=new Fe(n,3,!0,n,null,!1,!1)});["capture","download"].forEach(function(n){we[n]=new Fe(n,4,!1,n,null,!1,!1)});["cols","rows","size","span"].forEach(function(n){we[n]=new Fe(n,6,!1,n,null,!1,!1)});["rowSpan","start"].forEach(function(n){we[n]=new Fe(n,5,!1,n.toLowerCase(),null,!1,!1)});var Mf=/[\-:]([a-z])/g;function Ef(n){return n[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(n){var e=n.replace(Mf,Ef);we[e]=new Fe(e,1,!1,n,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(n){var e=n.replace(Mf,Ef);we[e]=new Fe(e,1,!1,n,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(n){var e=n.replace(Mf,Ef);we[e]=new Fe(e,1,!1,n,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(n){we[n]=new Fe(n,1,!1,n.toLowerCase(),null,!1,!1)});we.xlinkHref=new Fe("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(n){we[n]=new Fe(n,1,!1,n.toLowerCase(),null,!0,!0)});function Of(n,e,t,r){var i=we.hasOwnProperty(e)?we[e]:null;(i!==null?i.type!==0:r||!(2"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Xu=Object.prototype.hasOwnProperty,SC=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,Wh={},Uh={};function wC(n){return Xu.call(Uh,n)?!0:Xu.call(Wh,n)?!1:SC.test(n)?Uh[n]=!0:(Wh[n]=!0,!1)}function kC(n,e,t,r){if(t!==null&&t.type===0)return!1;switch(typeof e){case"function":case"symbol":return!0;case"boolean":return r?!1:t!==null?!t.acceptsBooleans:(n=n.toLowerCase().slice(0,5),n!=="data-"&&n!=="aria-");default:return!1}}function vC(n,e,t,r){if(e===null||typeof e>"u"||kC(n,e,t,r))return!0;if(r)return!1;if(t!==null)switch(t.type){case 3:return!e;case 4:return e===!1;case 5:return isNaN(e);case 6:return isNaN(e)||1>e}return!1}function Fe(n,e,t,r,i,o,s){this.acceptsBooleans=e===2||e===3||e===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=t,this.propertyName=n,this.type=e,this.sanitizeURL=o,this.removeEmptyString=s}var ke={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(n){ke[n]=new Fe(n,0,!1,n,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(n){var e=n[0];ke[e]=new Fe(e,1,!1,n[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(n){ke[n]=new Fe(n,2,!1,n.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(n){ke[n]=new Fe(n,2,!1,n,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(n){ke[n]=new Fe(n,3,!1,n.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(n){ke[n]=new Fe(n,3,!0,n,null,!1,!1)});["capture","download"].forEach(function(n){ke[n]=new Fe(n,4,!1,n,null,!1,!1)});["cols","rows","size","span"].forEach(function(n){ke[n]=new Fe(n,6,!1,n,null,!1,!1)});["rowSpan","start"].forEach(function(n){ke[n]=new Fe(n,5,!1,n.toLowerCase(),null,!1,!1)});var Mf=/[\-:]([a-z])/g;function Ef(n){return n[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(n){var e=n.replace(Mf,Ef);ke[e]=new Fe(e,1,!1,n,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(n){var e=n.replace(Mf,Ef);ke[e]=new Fe(e,1,!1,n,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(n){var e=n.replace(Mf,Ef);ke[e]=new Fe(e,1,!1,n,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(n){ke[n]=new Fe(n,1,!1,n.toLowerCase(),null,!1,!1)});ke.xlinkHref=new Fe("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(n){ke[n]=new Fe(n,1,!1,n.toLowerCase(),null,!0,!0)});function Of(n,e,t,r){var i=ke.hasOwnProperty(e)?ke[e]:null;(i!==null?i.type!==0:r||!(2l||i[s]!==o[l]){var a=` -`+i[s].replace(" at new "," at ");return n.displayName&&a.includes("")&&(a=a.replace("",n.displayName)),a}while(1<=s&&0<=l);break}}}finally{Ka=!1,Error.prepareStackTrace=t}return(n=n?n.displayName||n.name:"")?Gi(n):""}function xC(n){switch(n.tag){case 5:return Gi(n.type);case 16:return Gi("Lazy");case 13:return Gi("Suspense");case 19:return Gi("SuspenseList");case 0:case 2:case 15:return n=qa(n.type,!1),n;case 11:return n=qa(n.type.render,!1),n;case 1:return n=qa(n.type,!0),n;default:return""}}function nc(n){if(n==null)return null;if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case Dr:return"Fragment";case Or:return"Portal";case Zu:return"Profiler";case Df:return"StrictMode";case ec:return"Suspense";case tc:return"SuspenseList"}if(typeof n=="object")switch(n.$$typeof){case Ly:return(n.displayName||"Context")+".Consumer";case Fy:return(n._context.displayName||"Context")+".Provider";case Tf:var e=n.render;return n=n.displayName,n||(n=e.displayName||e.name||"",n=n!==""?"ForwardRef("+n+")":"ForwardRef"),n;case Rf:return e=n.displayName||null,e!==null?e:nc(n.type)||"Memo";case on:e=n._payload,n=n._init;try{return nc(n(e))}catch{}}return null}function CC(n){var e=n.type;switch(n.tag){case 24:return"Cache";case 9:return(e.displayName||"Context")+".Consumer";case 10:return(e._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return n=e.render,n=n.displayName||n.name||"",e.displayName||(n!==""?"ForwardRef("+n+")":"ForwardRef");case 7:return"Fragment";case 5:return e;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return nc(e);case 8:return e===Df?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e}return null}function Rn(n){switch(typeof n){case"boolean":case"number":case"string":case"undefined":return n;case"object":return n;default:return""}}function Vy(n){var e=n.type;return(n=n.nodeName)&&n.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function NC(n){var e=Vy(n)?"checked":"value",t=Object.getOwnPropertyDescriptor(n.constructor.prototype,e),r=""+n[e];if(!n.hasOwnProperty(e)&&typeof t<"u"&&typeof t.get=="function"&&typeof t.set=="function"){var i=t.get,o=t.set;return Object.defineProperty(n,e,{configurable:!0,get:function(){return i.call(this)},set:function(s){r=""+s,o.call(this,s)}}),Object.defineProperty(n,e,{enumerable:t.enumerable}),{getValue:function(){return r},setValue:function(s){r=""+s},stopTracking:function(){n._valueTracker=null,delete n[e]}}}}function Ss(n){n._valueTracker||(n._valueTracker=NC(n))}function By(n){if(!n)return!1;var e=n._valueTracker;if(!e)return!0;var t=e.getValue(),r="";return n&&(r=Vy(n)?n.checked?"true":"false":n.value),n=r,n!==t?(e.setValue(n),!0):!1}function Nl(n){if(n=n||(typeof document<"u"?document:void 0),typeof n>"u")return null;try{return n.activeElement||n.body}catch{return n.body}}function rc(n,e){var t=e.checked;return X({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:t??n._wrapperState.initialChecked})}function jh(n,e){var t=e.defaultValue==null?"":e.defaultValue,r=e.checked!=null?e.checked:e.defaultChecked;t=Rn(e.value!=null?e.value:t),n._wrapperState={initialChecked:r,initialValue:t,controlled:e.type==="checkbox"||e.type==="radio"?e.checked!=null:e.value!=null}}function Jy(n,e){e=e.checked,e!=null&&Of(n,"checked",e,!1)}function ic(n,e){Jy(n,e);var t=Rn(e.value),r=e.type;if(t!=null)r==="number"?(t===0&&n.value===""||n.value!=t)&&(n.value=""+t):n.value!==""+t&&(n.value=""+t);else if(r==="submit"||r==="reset"){n.removeAttribute("value");return}e.hasOwnProperty("value")?oc(n,e.type,t):e.hasOwnProperty("defaultValue")&&oc(n,e.type,Rn(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(n.defaultChecked=!!e.defaultChecked)}function Kh(n,e,t){if(e.hasOwnProperty("value")||e.hasOwnProperty("defaultValue")){var r=e.type;if(!(r!=="submit"&&r!=="reset"||e.value!==void 0&&e.value!==null))return;e=""+n._wrapperState.initialValue,t||e===n.value||(n.value=e),n.defaultValue=e}t=n.name,t!==""&&(n.name=""),n.defaultChecked=!!n._wrapperState.initialChecked,t!==""&&(n.name=t)}function oc(n,e,t){(e!=="number"||Nl(n.ownerDocument)!==n)&&(t==null?n.defaultValue=""+n._wrapperState.initialValue:n.defaultValue!==""+t&&(n.defaultValue=""+t))}var Xi=Array.isArray;function _r(n,e,t,r){if(n=n.options,e){e={};for(var i=0;i"+e.valueOf().toString()+"",e=ws.firstChild;n.firstChild;)n.removeChild(n.firstChild);for(;e.firstChild;)n.appendChild(e.firstChild)}});function Do(n,e){if(e){var t=n.firstChild;if(t&&t===n.lastChild&&t.nodeType===3){t.nodeValue=e;return}}n.textContent=e}var so={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},MC=["Webkit","ms","Moz","O"];Object.keys(so).forEach(function(n){MC.forEach(function(e){e=e+n.charAt(0).toUpperCase()+n.substring(1),so[e]=so[n]})});function Hy(n,e,t){return e==null||typeof e=="boolean"||e===""?"":t||typeof e!="number"||e===0||so.hasOwnProperty(n)&&so[n]?(""+e).trim():e+"px"}function jy(n,e){n=n.style;for(var t in e)if(e.hasOwnProperty(t)){var r=t.indexOf("--")===0,i=Hy(t,e[t],r);t==="float"&&(t="cssFloat"),r?n.setProperty(t,i):n[t]=i}}var EC=X({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function ac(n,e){if(e){if(EC[n]&&(e.children!=null||e.dangerouslySetInnerHTML!=null))throw Error(M(137,n));if(e.dangerouslySetInnerHTML!=null){if(e.children!=null)throw Error(M(60));if(typeof e.dangerouslySetInnerHTML!="object"||!("__html"in e.dangerouslySetInnerHTML))throw Error(M(61))}if(e.style!=null&&typeof e.style!="object")throw Error(M(62))}}function uc(n,e){if(n.indexOf("-")===-1)return typeof e.is=="string";switch(n){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var cc=null;function Af(n){return n=n.target||n.srcElement||window,n.correspondingUseElement&&(n=n.correspondingUseElement),n.nodeType===3?n.parentNode:n}var fc=null,Wr=null,Ur=null;function Yh(n){if(n=rs(n)){if(typeof fc!="function")throw Error(M(280));var e=n.stateNode;e&&(e=oa(e),fc(n.stateNode,n.type,e))}}function Ky(n){Wr?Ur?Ur.push(n):Ur=[n]:Wr=n}function qy(){if(Wr){var n=Wr,e=Ur;if(Ur=Wr=null,Yh(n),e)for(n=0;n>>=0,n===0?32:31-(LC(n)/$C|0)|0}var ks=64,vs=4194304;function Zi(n){switch(n&-n){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return n&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return n&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return n}}function Dl(n,e){var t=n.pendingLanes;if(t===0)return 0;var r=0,i=n.suspendedLanes,o=n.pingedLanes,s=t&268435455;if(s!==0){var l=s&~i;l!==0?r=Zi(l):(o&=s,o!==0&&(r=Zi(o)))}else s=t&~i,s!==0?r=Zi(s):o!==0&&(r=Zi(o));if(r===0)return 0;if(e!==0&&e!==r&&!(e&i)&&(i=r&-r,o=e&-e,i>=o||i===16&&(o&4194240)!==0))return e;if(r&4&&(r|=t&16),e=n.entangledLanes,e!==0)for(n=n.entanglements,e&=r;0t;t++)e.push(n);return e}function ts(n,e,t){n.pendingLanes|=e,e!==536870912&&(n.suspendedLanes=0,n.pingedLanes=0),n=n.eventTimes,e=31-vt(e),n[e]=t}function _C(n,e){var t=n.pendingLanes&~e;n.pendingLanes=e,n.suspendedLanes=0,n.pingedLanes=0,n.expiredLanes&=e,n.mutableReadLanes&=e,n.entangledLanes&=e,e=n.entanglements;var r=n.eventTimes;for(n=n.expirationTimes;0=ao),op=" ",sp=!1;function p0(n,e){switch(n){case"keyup":return gN.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function m0(n){return n=n.detail,typeof n=="object"&&"data"in n?n.data:null}var Tr=!1;function SN(n,e){switch(n){case"compositionend":return m0(e);case"keypress":return e.which!==32?null:(sp=!0,op);case"textInput":return n=e.data,n===op&&sp?null:n;default:return null}}function wN(n,e){if(Tr)return n==="compositionend"||!Vf&&p0(n,e)?(n=d0(),rl=Ff=gn=null,Tr=!1,n):null;switch(n){case"paste":return null;case"keypress":if(!(e.ctrlKey||e.altKey||e.metaKey)||e.ctrlKey&&e.altKey){if(e.char&&1=e)return{node:t,offset:e-n};n=r}e:{for(;t;){if(t.nextSibling){t=t.nextSibling;break e}t=t.parentNode}t=void 0}t=cp(t)}}function w0(n,e){return n&&e?n===e?!0:n&&n.nodeType===3?!1:e&&e.nodeType===3?w0(n,e.parentNode):"contains"in n?n.contains(e):n.compareDocumentPosition?!!(n.compareDocumentPosition(e)&16):!1:!1}function k0(){for(var n=window,e=Nl();e instanceof n.HTMLIFrameElement;){try{var t=typeof e.contentWindow.location.href=="string"}catch{t=!1}if(t)n=e.contentWindow;else break;e=Nl(n.document)}return e}function Bf(n){var e=n&&n.nodeName&&n.nodeName.toLowerCase();return e&&(e==="input"&&(n.type==="text"||n.type==="search"||n.type==="tel"||n.type==="url"||n.type==="password")||e==="textarea"||n.contentEditable==="true")}function DN(n){var e=k0(),t=n.focusedElem,r=n.selectionRange;if(e!==t&&t&&t.ownerDocument&&w0(t.ownerDocument.documentElement,t)){if(r!==null&&Bf(t)){if(e=r.start,n=r.end,n===void 0&&(n=e),"selectionStart"in t)t.selectionStart=e,t.selectionEnd=Math.min(n,t.value.length);else if(n=(e=t.ownerDocument||document)&&e.defaultView||window,n.getSelection){n=n.getSelection();var i=t.textContent.length,o=Math.min(r.start,i);r=r.end===void 0?o:Math.min(r.end,i),!n.extend&&o>r&&(i=r,r=o,o=i),i=fp(t,o);var s=fp(t,r);i&&s&&(n.rangeCount!==1||n.anchorNode!==i.node||n.anchorOffset!==i.offset||n.focusNode!==s.node||n.focusOffset!==s.offset)&&(e=e.createRange(),e.setStart(i.node,i.offset),n.removeAllRanges(),o>r?(n.addRange(e),n.extend(s.node,s.offset)):(e.setEnd(s.node,s.offset),n.addRange(e)))}}for(e=[],n=t;n=n.parentNode;)n.nodeType===1&&e.push({element:n,left:n.scrollLeft,top:n.scrollTop});for(typeof t.focus=="function"&&t.focus(),t=0;t=document.documentMode,Rr=null,yc=null,co=null,Sc=!1;function dp(n,e,t){var r=t.window===t?t.document:t.nodeType===9?t:t.ownerDocument;Sc||Rr==null||Rr!==Nl(r)||(r=Rr,"selectionStart"in r&&Bf(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),co&&Io(co,r)||(co=r,r=Al(yc,"onSelect"),0zr||(n.current=Nc[zr],Nc[zr]=null,zr--)}function j(n,e){zr++,Nc[zr]=n.current,n.current=e}var An={},Ee=Pn(An),Ue=Pn(!1),ar=An;function oi(n,e){var t=n.type.contextTypes;if(!t)return An;var r=n.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===e)return r.__reactInternalMemoizedMaskedChildContext;var i={},o;for(o in t)i[o]=e[o];return r&&(n=n.stateNode,n.__reactInternalMemoizedUnmaskedChildContext=e,n.__reactInternalMemoizedMaskedChildContext=i),i}function He(n){return n=n.childContextTypes,n!=null}function zl(){q(Ue),q(Ee)}function wp(n,e,t){if(Ee.current!==An)throw Error(M(168));j(Ee,e),j(Ue,t)}function T0(n,e,t){var r=n.stateNode;if(e=e.childContextTypes,typeof r.getChildContext!="function")return t;r=r.getChildContext();for(var i in r)if(!(i in e))throw Error(M(108,CC(n)||"Unknown",i));return X({},t,r)}function Il(n){return n=(n=n.stateNode)&&n.__reactInternalMemoizedMergedChildContext||An,ar=Ee.current,j(Ee,n),j(Ue,Ue.current),!0}function kp(n,e,t){var r=n.stateNode;if(!r)throw Error(M(169));t?(n=T0(n,e,ar),r.__reactInternalMemoizedMergedChildContext=n,q(Ue),q(Ee),j(Ee,n)):q(Ue),j(Ue,t)}var Ht=null,sa=!1,au=!1;function R0(n){Ht===null?Ht=[n]:Ht.push(n)}function BN(n){sa=!0,R0(n)}function Fn(){if(!au&&Ht!==null){au=!0;var n=0,e=U;try{var t=Ht;for(U=1;n>=s,i-=s,jt=1<<32-vt(e)+i|t<T?(b=O,O=null):b=O.sibling;var I=d(g,O,S[T],C);if(I===null){O===null&&(O=b);break}n&&O&&I.alternate===null&&e(g,O),y=o(I,y,T),E===null?N=I:E.sibling=I,E=I,O=b}if(T===S.length)return t(g,O),Q&&jn(g,T),N;if(O===null){for(;TT?(b=O,O=null):b=O.sibling;var ae=d(g,O,I.value,C);if(ae===null){O===null&&(O=b);break}n&&O&&ae.alternate===null&&e(g,O),y=o(ae,y,T),E===null?N=ae:E.sibling=ae,E=ae,O=b}if(I.done)return t(g,O),Q&&jn(g,T),N;if(O===null){for(;!I.done;T++,I=S.next())I=f(g,I.value,C),I!==null&&(y=o(I,y,T),E===null?N=I:E.sibling=I,E=I);return Q&&jn(g,T),N}for(O=r(g,O);!I.done;T++,I=S.next())I=p(O,g,T,I.value,C),I!==null&&(n&&I.alternate!==null&&O.delete(I.key===null?T:I.key),y=o(I,y,T),E===null?N=I:E.sibling=I,E=I);return n&&O.forEach(function(Vt){return e(g,Vt)}),Q&&jn(g,T),N}function w(g,y,S,C){if(typeof S=="object"&&S!==null&&S.type===Dr&&S.key===null&&(S=S.props.children),typeof S=="object"&&S!==null){switch(S.$$typeof){case ys:e:{for(var N=S.key,E=y;E!==null;){if(E.key===N){if(N=S.type,N===Dr){if(E.tag===7){t(g,E.sibling),y=i(E,S.props.children),y.return=g,g=y;break e}}else if(E.elementType===N||typeof N=="object"&&N!==null&&N.$$typeof===on&&Op(N)===E.type){t(g,E.sibling),y=i(E,S.props),y.ref=Mi(g,E,S),y.return=g,g=y;break e}t(g,E);break}else e(g,E);E=E.sibling}S.type===Dr?(y=or(S.props.children,g.mode,C,S.key),y.return=g,g=y):(C=fl(S.type,S.key,S.props,null,g.mode,C),C.ref=Mi(g,y,S),C.return=g,g=C)}return s(g);case Or:e:{for(E=S.key;y!==null;){if(y.key===E)if(y.tag===4&&y.stateNode.containerInfo===S.containerInfo&&y.stateNode.implementation===S.implementation){t(g,y.sibling),y=i(y,S.children||[]),y.return=g,g=y;break e}else{t(g,y);break}else e(g,y);y=y.sibling}y=gu(S,g.mode,C),y.return=g,g=y}return s(g);case on:return E=S._init,w(g,y,E(S._payload),C)}if(Xi(S))return h(g,y,S,C);if(ki(S))return m(g,y,S,C);Ds(g,S)}return typeof S=="string"&&S!==""||typeof S=="number"?(S=""+S,y!==null&&y.tag===6?(t(g,y.sibling),y=i(y,S),y.return=g,g=y):(t(g,y),y=mu(S,g.mode,C),y.return=g,g=y),s(g)):t(g,y)}return w}var li=$0(!0),V0=$0(!1),is={},bt=Pn(is),$o=Pn(is),Vo=Pn(is);function Zn(n){if(n===is)throw Error(M(174));return n}function Qf(n,e){switch(j(Vo,e),j($o,n),j(bt,is),n=e.nodeType,n){case 9:case 11:e=(e=e.documentElement)?e.namespaceURI:lc(null,"");break;default:n=n===8?e.parentNode:e,e=n.namespaceURI||null,n=n.tagName,e=lc(e,n)}q(bt),j(bt,e)}function ai(){q(bt),q($o),q(Vo)}function B0(n){Zn(Vo.current);var e=Zn(bt.current),t=lc(e,n.type);e!==t&&(j($o,n),j(bt,t))}function Yf(n){$o.current===n&&(q(bt),q($o))}var Y=Pn(0);function Bl(n){for(var e=n;e!==null;){if(e.tag===13){var t=e.memoizedState;if(t!==null&&(t=t.dehydrated,t===null||t.data==="$?"||t.data==="$!"))return e}else if(e.tag===19&&e.memoizedProps.revealOrder!==void 0){if(e.flags&128)return e}else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===n)break;for(;e.sibling===null;){if(e.return===null||e.return===n)return null;e=e.return}e.sibling.return=e.return,e=e.sibling}return null}var uu=[];function Gf(){for(var n=0;nt?t:4,n(!0);var r=cu.transition;cu.transition={};try{n(!1),e()}finally{U=t,cu.transition=r}}function n1(){return pt().memoizedState}function UN(n,e,t){var r=En(n);if(t={lane:r,action:t,hasEagerState:!1,eagerState:null,next:null},r1(n))i1(e,t);else if(t=I0(n,e,t,r),t!==null){var i=Ae();xt(t,n,r,i),o1(t,e,r)}}function HN(n,e,t){var r=En(n),i={lane:r,action:t,hasEagerState:!1,eagerState:null,next:null};if(r1(n))i1(e,i);else{var o=n.alternate;if(n.lanes===0&&(o===null||o.lanes===0)&&(o=e.lastRenderedReducer,o!==null))try{var s=e.lastRenderedState,l=o(s,t);if(i.hasEagerState=!0,i.eagerState=l,Nt(l,s)){var a=e.interleaved;a===null?(i.next=i,Kf(e)):(i.next=a.next,a.next=i),e.interleaved=i;return}}catch{}finally{}t=I0(n,e,i,r),t!==null&&(i=Ae(),xt(t,n,r,i),o1(t,e,r))}}function r1(n){var e=n.alternate;return n===G||e!==null&&e===G}function i1(n,e){fo=Jl=!0;var t=n.pending;t===null?e.next=e:(e.next=t.next,t.next=e),n.pending=e}function o1(n,e,t){if(t&4194240){var r=e.lanes;r&=n.pendingLanes,t|=r,e.lanes=t,zf(n,t)}}var _l={readContext:ht,useCallback:ke,useContext:ke,useEffect:ke,useImperativeHandle:ke,useInsertionEffect:ke,useLayoutEffect:ke,useMemo:ke,useReducer:ke,useRef:ke,useState:ke,useDebugValue:ke,useDeferredValue:ke,useTransition:ke,useMutableSource:ke,useSyncExternalStore:ke,useId:ke,unstable_isNewReconciler:!1},jN={readContext:ht,useCallback:function(n,e){return Et().memoizedState=[n,e===void 0?null:e],n},useContext:ht,useEffect:Tp,useImperativeHandle:function(n,e,t){return t=t!=null?t.concat([n]):null,ll(4194308,4,G0.bind(null,e,n),t)},useLayoutEffect:function(n,e){return ll(4194308,4,n,e)},useInsertionEffect:function(n,e){return ll(4,2,n,e)},useMemo:function(n,e){var t=Et();return e=e===void 0?null:e,n=n(),t.memoizedState=[n,e],n},useReducer:function(n,e,t){var r=Et();return e=t!==void 0?t(e):e,r.memoizedState=r.baseState=e,n={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:n,lastRenderedState:e},r.queue=n,n=n.dispatch=UN.bind(null,G,n),[r.memoizedState,n]},useRef:function(n){var e=Et();return n={current:n},e.memoizedState=n},useState:Dp,useDebugValue:nd,useDeferredValue:function(n){return Et().memoizedState=n},useTransition:function(){var n=Dp(!1),e=n[0];return n=WN.bind(null,n[1]),Et().memoizedState=n,[e,n]},useMutableSource:function(){},useSyncExternalStore:function(n,e,t){var r=G,i=Et();if(Q){if(t===void 0)throw Error(M(407));t=t()}else{if(t=e(),de===null)throw Error(M(349));cr&30||W0(r,e,t)}i.memoizedState=t;var o={value:t,getSnapshot:e};return i.queue=o,Tp(H0.bind(null,r,o,n),[n]),r.flags|=2048,_o(9,U0.bind(null,r,o,t,e),void 0,null),t},useId:function(){var n=Et(),e=de.identifierPrefix;if(Q){var t=Kt,r=jt;t=(r&~(1<<32-vt(r)-1)).toString(32)+t,e=":"+e+"R"+t,t=Bo++,0")&&(a=a.replace("",n.displayName)),a}while(1<=s&&0<=l);break}}}finally{Ka=!1,Error.prepareStackTrace=t}return(n=n?n.displayName||n.name:"")?Yi(n):""}function xC(n){switch(n.tag){case 5:return Yi(n.type);case 16:return Yi("Lazy");case 13:return Yi("Suspense");case 19:return Yi("SuspenseList");case 0:case 2:case 15:return n=qa(n.type,!1),n;case 11:return n=qa(n.type.render,!1),n;case 1:return n=qa(n.type,!0),n;default:return""}}function nc(n){if(n==null)return null;if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case Tr:return"Fragment";case Or:return"Portal";case Zu:return"Profiler";case Tf:return"StrictMode";case ec:return"Suspense";case tc:return"SuspenseList"}if(typeof n=="object")switch(n.$$typeof){case Ly:return(n.displayName||"Context")+".Consumer";case Fy:return(n._context.displayName||"Context")+".Provider";case Df:var e=n.render;return n=n.displayName,n||(n=e.displayName||e.name||"",n=n!==""?"ForwardRef("+n+")":"ForwardRef"),n;case Rf:return e=n.displayName||null,e!==null?e:nc(n.type)||"Memo";case on:e=n._payload,n=n._init;try{return nc(n(e))}catch{}}return null}function CC(n){var e=n.type;switch(n.tag){case 24:return"Cache";case 9:return(e.displayName||"Context")+".Consumer";case 10:return(e._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return n=e.render,n=n.displayName||n.name||"",e.displayName||(n!==""?"ForwardRef("+n+")":"ForwardRef");case 7:return"Fragment";case 5:return e;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return nc(e);case 8:return e===Tf?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e}return null}function Rn(n){switch(typeof n){case"boolean":case"number":case"string":case"undefined":return n;case"object":return n;default:return""}}function Vy(n){var e=n.type;return(n=n.nodeName)&&n.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function NC(n){var e=Vy(n)?"checked":"value",t=Object.getOwnPropertyDescriptor(n.constructor.prototype,e),r=""+n[e];if(!n.hasOwnProperty(e)&&typeof t<"u"&&typeof t.get=="function"&&typeof t.set=="function"){var i=t.get,o=t.set;return Object.defineProperty(n,e,{configurable:!0,get:function(){return i.call(this)},set:function(s){r=""+s,o.call(this,s)}}),Object.defineProperty(n,e,{enumerable:t.enumerable}),{getValue:function(){return r},setValue:function(s){r=""+s},stopTracking:function(){n._valueTracker=null,delete n[e]}}}}function Ss(n){n._valueTracker||(n._valueTracker=NC(n))}function By(n){if(!n)return!1;var e=n._valueTracker;if(!e)return!0;var t=e.getValue(),r="";return n&&(r=Vy(n)?n.checked?"true":"false":n.value),n=r,n!==t?(e.setValue(n),!0):!1}function Nl(n){if(n=n||(typeof document<"u"?document:void 0),typeof n>"u")return null;try{return n.activeElement||n.body}catch{return n.body}}function rc(n,e){var t=e.checked;return X({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:t??n._wrapperState.initialChecked})}function jh(n,e){var t=e.defaultValue==null?"":e.defaultValue,r=e.checked!=null?e.checked:e.defaultChecked;t=Rn(e.value!=null?e.value:t),n._wrapperState={initialChecked:r,initialValue:t,controlled:e.type==="checkbox"||e.type==="radio"?e.checked!=null:e.value!=null}}function Jy(n,e){e=e.checked,e!=null&&Of(n,"checked",e,!1)}function ic(n,e){Jy(n,e);var t=Rn(e.value),r=e.type;if(t!=null)r==="number"?(t===0&&n.value===""||n.value!=t)&&(n.value=""+t):n.value!==""+t&&(n.value=""+t);else if(r==="submit"||r==="reset"){n.removeAttribute("value");return}e.hasOwnProperty("value")?oc(n,e.type,t):e.hasOwnProperty("defaultValue")&&oc(n,e.type,Rn(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(n.defaultChecked=!!e.defaultChecked)}function Kh(n,e,t){if(e.hasOwnProperty("value")||e.hasOwnProperty("defaultValue")){var r=e.type;if(!(r!=="submit"&&r!=="reset"||e.value!==void 0&&e.value!==null))return;e=""+n._wrapperState.initialValue,t||e===n.value||(n.value=e),n.defaultValue=e}t=n.name,t!==""&&(n.name=""),n.defaultChecked=!!n._wrapperState.initialChecked,t!==""&&(n.name=t)}function oc(n,e,t){(e!=="number"||Nl(n.ownerDocument)!==n)&&(t==null?n.defaultValue=""+n._wrapperState.initialValue:n.defaultValue!==""+t&&(n.defaultValue=""+t))}var Gi=Array.isArray;function _r(n,e,t,r){if(n=n.options,e){e={};for(var i=0;i"+e.valueOf().toString()+"",e=ws.firstChild;n.firstChild;)n.removeChild(n.firstChild);for(;e.firstChild;)n.appendChild(e.firstChild)}});function Oo(n,e){if(e){var t=n.firstChild;if(t&&t===n.lastChild&&t.nodeType===3){t.nodeValue=e;return}}n.textContent=e}var oo={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},MC=["Webkit","ms","Moz","O"];Object.keys(oo).forEach(function(n){MC.forEach(function(e){e=e+n.charAt(0).toUpperCase()+n.substring(1),oo[e]=oo[n]})});function Hy(n,e,t){return e==null||typeof e=="boolean"||e===""?"":t||typeof e!="number"||e===0||oo.hasOwnProperty(n)&&oo[n]?(""+e).trim():e+"px"}function jy(n,e){n=n.style;for(var t in e)if(e.hasOwnProperty(t)){var r=t.indexOf("--")===0,i=Hy(t,e[t],r);t==="float"&&(t="cssFloat"),r?n.setProperty(t,i):n[t]=i}}var EC=X({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function ac(n,e){if(e){if(EC[n]&&(e.children!=null||e.dangerouslySetInnerHTML!=null))throw Error(E(137,n));if(e.dangerouslySetInnerHTML!=null){if(e.children!=null)throw Error(E(60));if(typeof e.dangerouslySetInnerHTML!="object"||!("__html"in e.dangerouslySetInnerHTML))throw Error(E(61))}if(e.style!=null&&typeof e.style!="object")throw Error(E(62))}}function uc(n,e){if(n.indexOf("-")===-1)return typeof e.is=="string";switch(n){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var cc=null;function Af(n){return n=n.target||n.srcElement||window,n.correspondingUseElement&&(n=n.correspondingUseElement),n.nodeType===3?n.parentNode:n}var fc=null,Wr=null,Ur=null;function Yh(n){if(n=ns(n)){if(typeof fc!="function")throw Error(E(280));var e=n.stateNode;e&&(e=oa(e),fc(n.stateNode,n.type,e))}}function Ky(n){Wr?Ur?Ur.push(n):Ur=[n]:Wr=n}function qy(){if(Wr){var n=Wr,e=Ur;if(Ur=Wr=null,Yh(n),e)for(n=0;n>>=0,n===0?32:31-(LC(n)/$C|0)|0}var ks=64,vs=4194304;function Xi(n){switch(n&-n){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return n&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return n&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return n}}function Tl(n,e){var t=n.pendingLanes;if(t===0)return 0;var r=0,i=n.suspendedLanes,o=n.pingedLanes,s=t&268435455;if(s!==0){var l=s&~i;l!==0?r=Xi(l):(o&=s,o!==0&&(r=Xi(o)))}else s=t&~i,s!==0?r=Xi(s):o!==0&&(r=Xi(o));if(r===0)return 0;if(e!==0&&e!==r&&!(e&i)&&(i=r&-r,o=e&-e,i>=o||i===16&&(o&4194240)!==0))return e;if(r&4&&(r|=t&16),e=n.entangledLanes,e!==0)for(n=n.entanglements,e&=r;0t;t++)e.push(n);return e}function es(n,e,t){n.pendingLanes|=e,e!==536870912&&(n.suspendedLanes=0,n.pingedLanes=0),n=n.eventTimes,e=31-vt(e),n[e]=t}function _C(n,e){var t=n.pendingLanes&~e;n.pendingLanes=e,n.suspendedLanes=0,n.pingedLanes=0,n.expiredLanes&=e,n.mutableReadLanes&=e,n.entangledLanes&=e,e=n.entanglements;var r=n.eventTimes;for(n=n.expirationTimes;0=lo),op=" ",sp=!1;function p0(n,e){switch(n){case"keyup":return gN.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function m0(n){return n=n.detail,typeof n=="object"&&"data"in n?n.data:null}var Dr=!1;function SN(n,e){switch(n){case"compositionend":return m0(e);case"keypress":return e.which!==32?null:(sp=!0,op);case"textInput":return n=e.data,n===op&&sp?null:n;default:return null}}function wN(n,e){if(Dr)return n==="compositionend"||!Vf&&p0(n,e)?(n=d0(),rl=Ff=gn=null,Dr=!1,n):null;switch(n){case"paste":return null;case"keypress":if(!(e.ctrlKey||e.altKey||e.metaKey)||e.ctrlKey&&e.altKey){if(e.char&&1=e)return{node:t,offset:e-n};n=r}e:{for(;t;){if(t.nextSibling){t=t.nextSibling;break e}t=t.parentNode}t=void 0}t=cp(t)}}function w0(n,e){return n&&e?n===e?!0:n&&n.nodeType===3?!1:e&&e.nodeType===3?w0(n,e.parentNode):"contains"in n?n.contains(e):n.compareDocumentPosition?!!(n.compareDocumentPosition(e)&16):!1:!1}function k0(){for(var n=window,e=Nl();e instanceof n.HTMLIFrameElement;){try{var t=typeof e.contentWindow.location.href=="string"}catch{t=!1}if(t)n=e.contentWindow;else break;e=Nl(n.document)}return e}function Bf(n){var e=n&&n.nodeName&&n.nodeName.toLowerCase();return e&&(e==="input"&&(n.type==="text"||n.type==="search"||n.type==="tel"||n.type==="url"||n.type==="password")||e==="textarea"||n.contentEditable==="true")}function TN(n){var e=k0(),t=n.focusedElem,r=n.selectionRange;if(e!==t&&t&&t.ownerDocument&&w0(t.ownerDocument.documentElement,t)){if(r!==null&&Bf(t)){if(e=r.start,n=r.end,n===void 0&&(n=e),"selectionStart"in t)t.selectionStart=e,t.selectionEnd=Math.min(n,t.value.length);else if(n=(e=t.ownerDocument||document)&&e.defaultView||window,n.getSelection){n=n.getSelection();var i=t.textContent.length,o=Math.min(r.start,i);r=r.end===void 0?o:Math.min(r.end,i),!n.extend&&o>r&&(i=r,r=o,o=i),i=fp(t,o);var s=fp(t,r);i&&s&&(n.rangeCount!==1||n.anchorNode!==i.node||n.anchorOffset!==i.offset||n.focusNode!==s.node||n.focusOffset!==s.offset)&&(e=e.createRange(),e.setStart(i.node,i.offset),n.removeAllRanges(),o>r?(n.addRange(e),n.extend(s.node,s.offset)):(e.setEnd(s.node,s.offset),n.addRange(e)))}}for(e=[],n=t;n=n.parentNode;)n.nodeType===1&&e.push({element:n,left:n.scrollLeft,top:n.scrollTop});for(typeof t.focus=="function"&&t.focus(),t=0;t=document.documentMode,Rr=null,yc=null,uo=null,Sc=!1;function dp(n,e,t){var r=t.window===t?t.document:t.nodeType===9?t:t.ownerDocument;Sc||Rr==null||Rr!==Nl(r)||(r=Rr,"selectionStart"in r&&Bf(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),uo&&zo(uo,r)||(uo=r,r=Al(yc,"onSelect"),0zr||(n.current=Nc[zr],Nc[zr]=null,zr--)}function H(n,e){zr++,Nc[zr]=n.current,n.current=e}var An={},Oe=Pn(An),Ue=Pn(!1),ar=An;function oi(n,e){var t=n.type.contextTypes;if(!t)return An;var r=n.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===e)return r.__reactInternalMemoizedMaskedChildContext;var i={},o;for(o in t)i[o]=e[o];return r&&(n=n.stateNode,n.__reactInternalMemoizedUnmaskedChildContext=e,n.__reactInternalMemoizedMaskedChildContext=i),i}function He(n){return n=n.childContextTypes,n!=null}function zl(){q(Ue),q(Oe)}function wp(n,e,t){if(Oe.current!==An)throw Error(E(168));H(Oe,e),H(Ue,t)}function D0(n,e,t){var r=n.stateNode;if(e=e.childContextTypes,typeof r.getChildContext!="function")return t;r=r.getChildContext();for(var i in r)if(!(i in e))throw Error(E(108,CC(n)||"Unknown",i));return X({},t,r)}function Il(n){return n=(n=n.stateNode)&&n.__reactInternalMemoizedMergedChildContext||An,ar=Oe.current,H(Oe,n),H(Ue,Ue.current),!0}function kp(n,e,t){var r=n.stateNode;if(!r)throw Error(E(169));t?(n=D0(n,e,ar),r.__reactInternalMemoizedMergedChildContext=n,q(Ue),q(Oe),H(Oe,n)):q(Ue),H(Ue,t)}var Ht=null,sa=!1,au=!1;function R0(n){Ht===null?Ht=[n]:Ht.push(n)}function BN(n){sa=!0,R0(n)}function Fn(){if(!au&&Ht!==null){au=!0;var n=0,e=U;try{var t=Ht;for(U=1;n>=s,i-=s,jt=1<<32-vt(e)+i|t<T?(b=O,O=null):b=O.sibling;var I=d(g,O,S[T],C);if(I===null){O===null&&(O=b);break}n&&O&&I.alternate===null&&e(g,O),y=o(I,y,T),N===null?M=I:N.sibling=I,N=I,O=b}if(T===S.length)return t(g,O),Q&&jn(g,T),M;if(O===null){for(;TT?(b=O,O=null):b=O.sibling;var ae=d(g,O,I.value,C);if(ae===null){O===null&&(O=b);break}n&&O&&ae.alternate===null&&e(g,O),y=o(ae,y,T),N===null?M=ae:N.sibling=ae,N=ae,O=b}if(I.done)return t(g,O),Q&&jn(g,T),M;if(O===null){for(;!I.done;T++,I=S.next())I=f(g,I.value,C),I!==null&&(y=o(I,y,T),N===null?M=I:N.sibling=I,N=I);return Q&&jn(g,T),M}for(O=r(g,O);!I.done;T++,I=S.next())I=p(O,g,T,I.value,C),I!==null&&(n&&I.alternate!==null&&O.delete(I.key===null?T:I.key),y=o(I,y,T),N===null?M=I:N.sibling=I,N=I);return n&&O.forEach(function(Vt){return e(g,Vt)}),Q&&jn(g,T),M}function w(g,y,S,C){if(typeof S=="object"&&S!==null&&S.type===Tr&&S.key===null&&(S=S.props.children),typeof S=="object"&&S!==null){switch(S.$$typeof){case ys:e:{for(var M=S.key,N=y;N!==null;){if(N.key===M){if(M=S.type,M===Tr){if(N.tag===7){t(g,N.sibling),y=i(N,S.props.children),y.return=g,g=y;break e}}else if(N.elementType===M||typeof M=="object"&&M!==null&&M.$$typeof===on&&Op(M)===N.type){t(g,N.sibling),y=i(N,S.props),y.ref=Ni(g,N,S),y.return=g,g=y;break e}t(g,N);break}else e(g,N);N=N.sibling}S.type===Tr?(y=or(S.props.children,g.mode,C,S.key),y.return=g,g=y):(C=fl(S.type,S.key,S.props,null,g.mode,C),C.ref=Ni(g,y,S),C.return=g,g=C)}return s(g);case Or:e:{for(N=S.key;y!==null;){if(y.key===N)if(y.tag===4&&y.stateNode.containerInfo===S.containerInfo&&y.stateNode.implementation===S.implementation){t(g,y.sibling),y=i(y,S.children||[]),y.return=g,g=y;break e}else{t(g,y);break}else e(g,y);y=y.sibling}y=gu(S,g.mode,C),y.return=g,g=y}return s(g);case on:return N=S._init,w(g,y,N(S._payload),C)}if(Gi(S))return h(g,y,S,C);if(wi(S))return m(g,y,S,C);Ts(g,S)}return typeof S=="string"&&S!==""||typeof S=="number"?(S=""+S,y!==null&&y.tag===6?(t(g,y.sibling),y=i(y,S),y.return=g,g=y):(t(g,y),y=mu(S,g.mode,C),y.return=g,g=y),s(g)):t(g,y)}return w}var li=$0(!0),V0=$0(!1),rs={},bt=Pn(rs),Lo=Pn(rs),$o=Pn(rs);function Zn(n){if(n===rs)throw Error(E(174));return n}function Qf(n,e){switch(H($o,e),H(Lo,n),H(bt,rs),n=e.nodeType,n){case 9:case 11:e=(e=e.documentElement)?e.namespaceURI:lc(null,"");break;default:n=n===8?e.parentNode:e,e=n.namespaceURI||null,n=n.tagName,e=lc(e,n)}q(bt),H(bt,e)}function ai(){q(bt),q(Lo),q($o)}function B0(n){Zn($o.current);var e=Zn(bt.current),t=lc(e,n.type);e!==t&&(H(Lo,n),H(bt,t))}function Yf(n){Lo.current===n&&(q(bt),q(Lo))}var Y=Pn(0);function Bl(n){for(var e=n;e!==null;){if(e.tag===13){var t=e.memoizedState;if(t!==null&&(t=t.dehydrated,t===null||t.data==="$?"||t.data==="$!"))return e}else if(e.tag===19&&e.memoizedProps.revealOrder!==void 0){if(e.flags&128)return e}else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===n)break;for(;e.sibling===null;){if(e.return===null||e.return===n)return null;e=e.return}e.sibling.return=e.return,e=e.sibling}return null}var uu=[];function Gf(){for(var n=0;nt?t:4,n(!0);var r=cu.transition;cu.transition={};try{n(!1),e()}finally{U=t,cu.transition=r}}function n1(){return pt().memoizedState}function UN(n,e,t){var r=En(n);if(t={lane:r,action:t,hasEagerState:!1,eagerState:null,next:null},r1(n))i1(e,t);else if(t=I0(n,e,t,r),t!==null){var i=Ae();xt(t,n,r,i),o1(t,e,r)}}function HN(n,e,t){var r=En(n),i={lane:r,action:t,hasEagerState:!1,eagerState:null,next:null};if(r1(n))i1(e,i);else{var o=n.alternate;if(n.lanes===0&&(o===null||o.lanes===0)&&(o=e.lastRenderedReducer,o!==null))try{var s=e.lastRenderedState,l=o(s,t);if(i.hasEagerState=!0,i.eagerState=l,Nt(l,s)){var a=e.interleaved;a===null?(i.next=i,Kf(e)):(i.next=a.next,a.next=i),e.interleaved=i;return}}catch{}finally{}t=I0(n,e,i,r),t!==null&&(i=Ae(),xt(t,n,r,i),o1(t,e,r))}}function r1(n){var e=n.alternate;return n===G||e!==null&&e===G}function i1(n,e){co=Jl=!0;var t=n.pending;t===null?e.next=e:(e.next=t.next,t.next=e),n.pending=e}function o1(n,e,t){if(t&4194240){var r=e.lanes;r&=n.pendingLanes,t|=r,e.lanes=t,zf(n,t)}}var _l={readContext:ht,useCallback:ve,useContext:ve,useEffect:ve,useImperativeHandle:ve,useInsertionEffect:ve,useLayoutEffect:ve,useMemo:ve,useReducer:ve,useRef:ve,useState:ve,useDebugValue:ve,useDeferredValue:ve,useTransition:ve,useMutableSource:ve,useSyncExternalStore:ve,useId:ve,unstable_isNewReconciler:!1},jN={readContext:ht,useCallback:function(n,e){return Et().memoizedState=[n,e===void 0?null:e],n},useContext:ht,useEffect:Dp,useImperativeHandle:function(n,e,t){return t=t!=null?t.concat([n]):null,ll(4194308,4,G0.bind(null,e,n),t)},useLayoutEffect:function(n,e){return ll(4194308,4,n,e)},useInsertionEffect:function(n,e){return ll(4,2,n,e)},useMemo:function(n,e){var t=Et();return e=e===void 0?null:e,n=n(),t.memoizedState=[n,e],n},useReducer:function(n,e,t){var r=Et();return e=t!==void 0?t(e):e,r.memoizedState=r.baseState=e,n={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:n,lastRenderedState:e},r.queue=n,n=n.dispatch=UN.bind(null,G,n),[r.memoizedState,n]},useRef:function(n){var e=Et();return n={current:n},e.memoizedState=n},useState:Tp,useDebugValue:nd,useDeferredValue:function(n){return Et().memoizedState=n},useTransition:function(){var n=Tp(!1),e=n[0];return n=WN.bind(null,n[1]),Et().memoizedState=n,[e,n]},useMutableSource:function(){},useSyncExternalStore:function(n,e,t){var r=G,i=Et();if(Q){if(t===void 0)throw Error(E(407));t=t()}else{if(t=e(),de===null)throw Error(E(349));cr&30||W0(r,e,t)}i.memoizedState=t;var o={value:t,getSnapshot:e};return i.queue=o,Dp(H0.bind(null,r,o,n),[n]),r.flags|=2048,Jo(9,U0.bind(null,r,o,t,e),void 0,null),t},useId:function(){var n=Et(),e=de.identifierPrefix;if(Q){var t=Kt,r=jt;t=(r&~(1<<32-vt(r)-1)).toString(32)+t,e=":"+e+"R"+t,t=Vo++,0<\/script>",n=n.removeChild(n.firstChild)):typeof r.is=="string"?n=s.createElement(t,{is:r.is}):(n=s.createElement(t),t==="select"&&(s=n,r.multiple?s.multiple=!0:r.size&&(s.size=r.size))):n=s.createElementNS(n,t),n[Ot]=e,n[Lo]=r,p1(n,e,!1,!1),e.stateNode=n;e:{switch(s=uc(t,r),t){case"dialog":K("cancel",n),K("close",n),i=r;break;case"iframe":case"object":case"embed":K("load",n),i=r;break;case"video":case"audio":for(i=0;ici&&(e.flags|=128,r=!0,Ei(o,!1),e.lanes=4194304)}else{if(!r)if(n=Bl(s),n!==null){if(e.flags|=128,r=!0,t=n.updateQueue,t!==null&&(e.updateQueue=t,e.flags|=4),Ei(o,!0),o.tail===null&&o.tailMode==="hidden"&&!s.alternate&&!Q)return ve(e),null}else 2*ne()-o.renderingStartTime>ci&&t!==1073741824&&(e.flags|=128,r=!0,Ei(o,!1),e.lanes=4194304);o.isBackwards?(s.sibling=e.child,e.child=s):(t=o.last,t!==null?t.sibling=s:e.child=s,o.last=s)}return o.tail!==null?(e=o.tail,o.rendering=e,o.tail=e.sibling,o.renderingStartTime=ne(),e.sibling=null,t=Y.current,j(Y,r?t&1|2:t&1),e):(ve(e),null);case 22:case 23:return ad(),r=e.memoizedState!==null,n!==null&&n.memoizedState!==null!==r&&(e.flags|=8192),r&&e.mode&1?Ge&1073741824&&(ve(e),e.subtreeFlags&6&&(e.flags|=8192)):ve(e),null;case 24:return null;case 25:return null}throw Error(M(156,e.tag))}function eM(n,e){switch(_f(e),e.tag){case 1:return He(e.type)&&zl(),n=e.flags,n&65536?(e.flags=n&-65537|128,e):null;case 3:return ai(),q(Ue),q(Ee),Gf(),n=e.flags,n&65536&&!(n&128)?(e.flags=n&-65537|128,e):null;case 5:return Yf(e),null;case 13:if(q(Y),n=e.memoizedState,n!==null&&n.dehydrated!==null){if(e.alternate===null)throw Error(M(340));si()}return n=e.flags,n&65536?(e.flags=n&-65537|128,e):null;case 19:return q(Y),null;case 4:return ai(),null;case 10:return jf(e.type._context),null;case 22:case 23:return ad(),null;case 24:return null;default:return null}}var Rs=!1,Ce=!1,tM=typeof WeakSet=="function"?WeakSet:Set,D=null;function Lr(n,e){var t=n.ref;if(t!==null)if(typeof t=="function")try{t(null)}catch(r){Z(n,e,r)}else t.current=null}function Fc(n,e,t){try{t()}catch(r){Z(n,e,r)}}var $p=!1;function nM(n,e){if(wc=Tl,n=k0(),Bf(n)){if("selectionStart"in n)var t={start:n.selectionStart,end:n.selectionEnd};else e:{t=(t=n.ownerDocument)&&t.defaultView||window;var r=t.getSelection&&t.getSelection();if(r&&r.rangeCount!==0){t=r.anchorNode;var i=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{t.nodeType,o.nodeType}catch{t=null;break e}var s=0,l=-1,a=-1,u=0,c=0,f=n,d=null;t:for(;;){for(var p;f!==t||i!==0&&f.nodeType!==3||(l=s+i),f!==o||r!==0&&f.nodeType!==3||(a=s+r),f.nodeType===3&&(s+=f.nodeValue.length),(p=f.firstChild)!==null;)d=f,f=p;for(;;){if(f===n)break t;if(d===t&&++u===i&&(l=s),d===o&&++c===r&&(a=s),(p=f.nextSibling)!==null)break;f=d,d=f.parentNode}f=p}t=l===-1||a===-1?null:{start:l,end:a}}else t=null}t=t||{start:0,end:0}}else t=null;for(kc={focusedElem:n,selectionRange:t},Tl=!1,D=e;D!==null;)if(e=D,n=e.child,(e.subtreeFlags&1028)!==0&&n!==null)n.return=e,D=n;else for(;D!==null;){e=D;try{var h=e.alternate;if(e.flags&1024)switch(e.tag){case 0:case 11:case 15:break;case 1:if(h!==null){var m=h.memoizedProps,w=h.memoizedState,g=e.stateNode,y=g.getSnapshotBeforeUpdate(e.elementType===e.type?m:yt(e.type,m),w);g.__reactInternalSnapshotBeforeUpdate=y}break;case 3:var S=e.stateNode.containerInfo;S.nodeType===1?S.textContent="":S.nodeType===9&&S.documentElement&&S.removeChild(S.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(M(163))}}catch(C){Z(e,e.return,C)}if(n=e.sibling,n!==null){n.return=e.return,D=n;break}D=e.return}return h=$p,$p=!1,h}function ho(n,e,t){var r=e.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var i=r=r.next;do{if((i.tag&n)===n){var o=i.destroy;i.destroy=void 0,o!==void 0&&Fc(e,t,o)}i=i.next}while(i!==r)}}function ua(n,e){if(e=e.updateQueue,e=e!==null?e.lastEffect:null,e!==null){var t=e=e.next;do{if((t.tag&n)===n){var r=t.create;t.destroy=r()}t=t.next}while(t!==e)}}function Lc(n){var e=n.ref;if(e!==null){var t=n.stateNode;switch(n.tag){case 5:n=t;break;default:n=t}typeof e=="function"?e(n):e.current=n}}function y1(n){var e=n.alternate;e!==null&&(n.alternate=null,y1(e)),n.child=null,n.deletions=null,n.sibling=null,n.tag===5&&(e=n.stateNode,e!==null&&(delete e[Ot],delete e[Lo],delete e[Cc],delete e[$N],delete e[VN])),n.stateNode=null,n.return=null,n.dependencies=null,n.memoizedProps=null,n.memoizedState=null,n.pendingProps=null,n.stateNode=null,n.updateQueue=null}function S1(n){return n.tag===5||n.tag===3||n.tag===4}function Vp(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||S1(n.return))return null;n=n.return}for(n.sibling.return=n.return,n=n.sibling;n.tag!==5&&n.tag!==6&&n.tag!==18;){if(n.flags&2||n.child===null||n.tag===4)continue e;n.child.return=n,n=n.child}if(!(n.flags&2))return n.stateNode}}function $c(n,e,t){var r=n.tag;if(r===5||r===6)n=n.stateNode,e?t.nodeType===8?t.parentNode.insertBefore(n,e):t.insertBefore(n,e):(t.nodeType===8?(e=t.parentNode,e.insertBefore(n,t)):(e=t,e.appendChild(n)),t=t._reactRootContainer,t!=null||e.onclick!==null||(e.onclick=bl));else if(r!==4&&(n=n.child,n!==null))for($c(n,e,t),n=n.sibling;n!==null;)$c(n,e,t),n=n.sibling}function Vc(n,e,t){var r=n.tag;if(r===5||r===6)n=n.stateNode,e?t.insertBefore(n,e):t.appendChild(n);else if(r!==4&&(n=n.child,n!==null))for(Vc(n,e,t),n=n.sibling;n!==null;)Vc(n,e,t),n=n.sibling}var pe=null,St=!1;function tn(n,e,t){for(t=t.child;t!==null;)w1(n,e,t),t=t.sibling}function w1(n,e,t){if(At&&typeof At.onCommitFiberUnmount=="function")try{At.onCommitFiberUnmount(ta,t)}catch{}switch(t.tag){case 5:Ce||Lr(t,e);case 6:var r=pe,i=St;pe=null,tn(n,e,t),pe=r,St=i,pe!==null&&(St?(n=pe,t=t.stateNode,n.nodeType===8?n.parentNode.removeChild(t):n.removeChild(t)):pe.removeChild(t.stateNode));break;case 18:pe!==null&&(St?(n=pe,t=t.stateNode,n.nodeType===8?lu(n.parentNode,t):n.nodeType===1&&lu(n,t),bo(n)):lu(pe,t.stateNode));break;case 4:r=pe,i=St,pe=t.stateNode.containerInfo,St=!0,tn(n,e,t),pe=r,St=i;break;case 0:case 11:case 14:case 15:if(!Ce&&(r=t.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var o=i,s=o.destroy;o=o.tag,s!==void 0&&(o&2||o&4)&&Fc(t,e,s),i=i.next}while(i!==r)}tn(n,e,t);break;case 1:if(!Ce&&(Lr(t,e),r=t.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=t.memoizedProps,r.state=t.memoizedState,r.componentWillUnmount()}catch(l){Z(t,e,l)}tn(n,e,t);break;case 21:tn(n,e,t);break;case 22:t.mode&1?(Ce=(r=Ce)||t.memoizedState!==null,tn(n,e,t),Ce=r):tn(n,e,t);break;default:tn(n,e,t)}}function Bp(n){var e=n.updateQueue;if(e!==null){n.updateQueue=null;var t=n.stateNode;t===null&&(t=n.stateNode=new tM),e.forEach(function(r){var i=fM.bind(null,n,r);t.has(r)||(t.add(r),r.then(i,i))})}}function gt(n,e){var t=e.deletions;if(t!==null)for(var r=0;ri&&(i=s),r&=~o}if(r=i,r=ne()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*iM(r/1960))-r,10n?16:n,yn===null)var r=!1;else{if(n=yn,yn=null,Hl=0,B&6)throw Error(M(331));var i=B;for(B|=4,D=n.current;D!==null;){var o=D,s=o.child;if(D.flags&16){var l=o.deletions;if(l!==null){for(var a=0;ane()-sd?ir(n,0):od|=t),je(n,e)}function O1(n,e){e===0&&(n.mode&1?(e=vs,vs<<=1,!(vs&130023424)&&(vs=4194304)):e=1);var t=Ae();n=Xt(n,e),n!==null&&(ts(n,e,t),je(n,t))}function cM(n){var e=n.memoizedState,t=0;e!==null&&(t=e.retryLane),O1(n,t)}function fM(n,e){var t=0;switch(n.tag){case 13:var r=n.stateNode,i=n.memoizedState;i!==null&&(t=i.retryLane);break;case 19:r=n.stateNode;break;default:throw Error(M(314))}r!==null&&r.delete(e),O1(n,t)}var D1;D1=function(n,e,t){if(n!==null)if(n.memoizedProps!==e.pendingProps||Ue.current)_e=!0;else{if(!(n.lanes&t)&&!(e.flags&128))return _e=!1,XN(n,e,t);_e=!!(n.flags&131072)}else _e=!1,Q&&e.flags&1048576&&A0(e,Fl,e.index);switch(e.lanes=0,e.tag){case 2:var r=e.type;al(n,e),n=e.pendingProps;var i=oi(e,Ee.current);jr(e,t),i=Zf(null,e,r,n,i,t);var o=ed();return e.flags|=1,typeof i=="object"&&i!==null&&typeof i.render=="function"&&i.$$typeof===void 0?(e.tag=1,e.memoizedState=null,e.updateQueue=null,He(r)?(o=!0,Il(e)):o=!1,e.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,qf(e),i.updater=la,e.stateNode=i,i._reactInternals=e,Tc(e,r,n,t),e=bc(null,e,r,!0,o,t)):(e.tag=0,Q&&o&&Jf(e),Te(null,e,i,t),e=e.child),e;case 16:r=e.elementType;e:{switch(al(n,e),n=e.pendingProps,i=r._init,r=i(r._payload),e.type=r,i=e.tag=hM(r),n=yt(r,n),i){case 0:e=Ac(null,e,r,n,t);break e;case 1:e=Pp(null,e,r,n,t);break e;case 11:e=zp(null,e,r,n,t);break e;case 14:e=Ip(null,e,r,yt(r.type,n),t);break e}throw Error(M(306,r,""))}return e;case 0:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:yt(r,i),Ac(n,e,r,i,t);case 1:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:yt(r,i),Pp(n,e,r,i,t);case 3:e:{if(f1(e),n===null)throw Error(M(387));r=e.pendingProps,o=e.memoizedState,i=o.element,P0(n,e),Vl(e,r,null,t);var s=e.memoizedState;if(r=s.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:s.cache,pendingSuspenseBoundaries:s.pendingSuspenseBoundaries,transitions:s.transitions},e.updateQueue.baseState=o,e.memoizedState=o,e.flags&256){i=ui(Error(M(423)),e),e=Fp(n,e,r,t,i);break e}else if(r!==i){i=ui(Error(M(424)),e),e=Fp(n,e,r,t,i);break e}else for(Ze=Cn(e.stateNode.containerInfo.firstChild),tt=e,Q=!0,kt=null,t=V0(e,null,r,t),e.child=t;t;)t.flags=t.flags&-3|4096,t=t.sibling;else{if(si(),r===i){e=Zt(n,e,t);break e}Te(n,e,r,t)}e=e.child}return e;case 5:return B0(e),n===null&&Ec(e),r=e.type,i=e.pendingProps,o=n!==null?n.memoizedProps:null,s=i.children,vc(r,i)?s=null:o!==null&&vc(r,o)&&(e.flags|=32),c1(n,e),Te(n,e,s,t),e.child;case 6:return n===null&&Ec(e),null;case 13:return d1(n,e,t);case 4:return Qf(e,e.stateNode.containerInfo),r=e.pendingProps,n===null?e.child=li(e,null,r,t):Te(n,e,r,t),e.child;case 11:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:yt(r,i),zp(n,e,r,i,t);case 7:return Te(n,e,e.pendingProps,t),e.child;case 8:return Te(n,e,e.pendingProps.children,t),e.child;case 12:return Te(n,e,e.pendingProps.children,t),e.child;case 10:e:{if(r=e.type._context,i=e.pendingProps,o=e.memoizedProps,s=i.value,j(Ll,r._currentValue),r._currentValue=s,o!==null)if(Nt(o.value,s)){if(o.children===i.children&&!Ue.current){e=Zt(n,e,t);break e}}else for(o=e.child,o!==null&&(o.return=e);o!==null;){var l=o.dependencies;if(l!==null){s=o.child;for(var a=l.firstContext;a!==null;){if(a.context===r){if(o.tag===1){a=Qt(-1,t&-t),a.tag=2;var u=o.updateQueue;if(u!==null){u=u.shared;var c=u.pending;c===null?a.next=a:(a.next=c.next,c.next=a),u.pending=a}}o.lanes|=t,a=o.alternate,a!==null&&(a.lanes|=t),Oc(o.return,t,e),l.lanes|=t;break}a=a.next}}else if(o.tag===10)s=o.type===e.type?null:o.child;else if(o.tag===18){if(s=o.return,s===null)throw Error(M(341));s.lanes|=t,l=s.alternate,l!==null&&(l.lanes|=t),Oc(s,t,e),s=o.sibling}else s=o.child;if(s!==null)s.return=o;else for(s=o;s!==null;){if(s===e){s=null;break}if(o=s.sibling,o!==null){o.return=s.return,s=o;break}s=s.return}o=s}Te(n,e,i.children,t),e=e.child}return e;case 9:return i=e.type,r=e.pendingProps.children,jr(e,t),i=ht(i),r=r(i),e.flags|=1,Te(n,e,r,t),e.child;case 14:return r=e.type,i=yt(r,e.pendingProps),i=yt(r.type,i),Ip(n,e,r,i,t);case 15:return a1(n,e,e.type,e.pendingProps,t);case 17:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:yt(r,i),al(n,e),e.tag=1,He(r)?(n=!0,Il(e)):n=!1,jr(e,t),L0(e,r,i),Tc(e,r,i,t),bc(null,e,r,!0,n,t);case 19:return h1(n,e,t);case 22:return u1(n,e,t)}throw Error(M(156,e.tag))};function T1(n,e){return t0(n,e)}function dM(n,e,t,r){this.tag=n,this.key=t,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=e,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ct(n,e,t,r){return new dM(n,e,t,r)}function cd(n){return n=n.prototype,!(!n||!n.isReactComponent)}function hM(n){if(typeof n=="function")return cd(n)?1:0;if(n!=null){if(n=n.$$typeof,n===Tf)return 11;if(n===Rf)return 14}return 2}function On(n,e){var t=n.alternate;return t===null?(t=ct(n.tag,e,n.key,n.mode),t.elementType=n.elementType,t.type=n.type,t.stateNode=n.stateNode,t.alternate=n,n.alternate=t):(t.pendingProps=e,t.type=n.type,t.flags=0,t.subtreeFlags=0,t.deletions=null),t.flags=n.flags&14680064,t.childLanes=n.childLanes,t.lanes=n.lanes,t.child=n.child,t.memoizedProps=n.memoizedProps,t.memoizedState=n.memoizedState,t.updateQueue=n.updateQueue,e=n.dependencies,t.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext},t.sibling=n.sibling,t.index=n.index,t.ref=n.ref,t}function fl(n,e,t,r,i,o){var s=2;if(r=n,typeof n=="function")cd(n)&&(s=1);else if(typeof n=="string")s=5;else e:switch(n){case Dr:return or(t.children,i,o,e);case Df:s=8,i|=8;break;case Zu:return n=ct(12,t,e,i|2),n.elementType=Zu,n.lanes=o,n;case ec:return n=ct(13,t,e,i),n.elementType=ec,n.lanes=o,n;case tc:return n=ct(19,t,e,i),n.elementType=tc,n.lanes=o,n;case $y:return fa(t,i,o,e);default:if(typeof n=="object"&&n!==null)switch(n.$$typeof){case Fy:s=10;break e;case Ly:s=9;break e;case Tf:s=11;break e;case Rf:s=14;break e;case on:s=16,r=null;break e}throw Error(M(130,n==null?n:typeof n,""))}return e=ct(s,t,e,i),e.elementType=n,e.type=r,e.lanes=o,e}function or(n,e,t,r){return n=ct(7,n,r,e),n.lanes=t,n}function fa(n,e,t,r){return n=ct(22,n,r,e),n.elementType=$y,n.lanes=t,n.stateNode={isHidden:!1},n}function mu(n,e,t){return n=ct(6,n,null,e),n.lanes=t,n}function gu(n,e,t){return e=ct(4,n.children!==null?n.children:[],n.key,e),e.lanes=t,e.stateNode={containerInfo:n.containerInfo,pendingChildren:null,implementation:n.implementation},e}function pM(n,e,t,r,i){this.tag=e,this.containerInfo=n,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Ya(0),this.expirationTimes=Ya(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ya(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function fd(n,e,t,r,i,o,s,l,a){return n=new pM(n,e,t,l,a),e===1?(e=1,o===!0&&(e|=8)):e=0,o=ct(3,null,null,e),n.current=o,o.stateNode=n,o.memoizedState={element:r,isDehydrated:t,cache:null,transitions:null,pendingSuspenseBoundaries:null},qf(o),n}function mM(n,e,t){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(z1)}catch(n){console.error(n)}}z1(),Ay.exports=rt;var fi=Ay.exports,I1,qp=fi;I1=qp.createRoot,qp.hydrateRoot;const yi=k.createContext(null),kM=k.createContext(null),P1=k.createContext(null),zs=new WeakMap;function vM(n){const e=Object.create(null);e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",i=>{if(typeof i=="function"&&(i=i(n.state)),i)for(const o in i)o=="class"?e.class+=" "+i[o]:o=="style"?e.style=(e.style?e.style+";":"")+i[o]:!e[o]&&o!="contenteditable"&&o!="nodeName"&&(e[o]=String(i[o]))}),e.translate||(e.translate="no");const t=[ye.node(0,n.state.doc.content.size,e)],r=zs.get(n);return!r||r[0].to!==n.state.doc.content.size||!r[0].type.eq(t[0].type)?(zs.set(n,t),t):r}const xM=[],CM={},Uc=_.empty;class fn{constructor(e){this.members=e}map(e,t){const r=this.members.map(i=>i.map(e,t,CM));return fn.from(r)}forChild(e,t){if(t.isLeaf)return _.empty;let r=[];for(let i=0;it instanceof _)?e:e.reduce((t,r)=>t.concat(r instanceof _?r:r.members),[]))}}forEachSet(e){for(let t=0;t0;)e++;n.splice(e,0,t)}const yu=new WeakMap;function MM(n,e){const t=[];n.someProp("decorations",s=>{const l=s(n.state);l&&l!=Uc&&t.push(l)}),e&&t.push(_.create(n.state.doc,[e]));const r=yu.get(n);if(!r){const s=fn.from(t);return yu.set(n,s),s}let i=0,o=!0;if(r.forEachSet(s=>{t[i++]!==s&&(o=!1)}),i!==t.length&&(o=!1),!o){const s=fn.from(t);return yu.set(n,s),s}return r}const md=function(n){for(let e=0;;e++)if(n=n.previousSibling,!n)return e},Yp=function(n){const e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e},EM=function(n,e,t,r){return t&&(Gp(n,e,t,r,-1)||Gp(n,e,t,r,1))},OM=/^(img|br|input|textarea|hr)$/i;function Gp(n,e,t,r,i){for(;;){if(n==t&&e==r)return!0;if(e==(i<0?0:ql(n))){const o=n.parentNode;if(!o||o.nodeType!=1||TM(n)||OM.test(n.nodeName)||n.contentEditable=="false")return!1;e=md(n)+(i<0?0:1),n=o}else if(n.nodeType==1){if(n=n.childNodes[e+(i<0?-1:0)],n.contentEditable=="false")return!1;e=i<0?ql(n):0}else return!1}}function ql(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function DM(n,e,t){for(let r=e==0,i=e==ql(n);r||i;){if(n==t)return!0;const o=md(n);if(n=n.parentNode,!n)return!1;r=r&&o==0,i=i&&o==ql(n)}return!1}function TM(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 L1=function(n){return n.focusNode&&EM(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)},$1=k.createContext(null);function RM(n,e){const t=k.useContext($1);k.useLayoutEffect(()=>t(n),e)}function V1(n,e){const{view:t}=k.useContext(yi);RM(()=>{if(t)return n(t)},e&&[t,...e])}const AM=k.forwardRef(function({widget:e,getPos:t,...r},i){const[o,s]=k.useState(!0),l=k.useRef(null);return k.useImperativeHandle(i,()=>l.current,[]),V1(a=>{if(!a||!l.current)return;a.domObserver.disconnectSelection();const u=a.domSelection(),c=document.createRange(),f=l.current;f.nodeName=="IMG"&&f.parentNode?c.setEnd(f.parentNode,md(f)+1):c.setEnd(f,0),c.collapse(!1),u.removeAllRanges(),u.addRange(c),s(!1),a.domObserver.connectSelection()},[]),o?R.jsx("img",{ref:l,className:"ProseMirror-separator","mark-placeholder":"true",alt:"",...r}):null});function bM(n,e){if(n==e)return!0;for(const t in n)if(n[t]!==e[t])return!1;for(const t in e)if(!(t in n))return!1;return!0}const zM={side:0};class Uo{constructor(e,t){this.Component=e,this.spec=t??zM,this.side=this.spec.side??0}map(e,t,r,i){const{pos:o,deleted:s}=e.mapResult(t.from+i,this.side<0?-1:1);return s?null:new ye(o-r,o-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Uo&&(this.spec.key&&this.spec.key==e.spec.key||this.Component==e.Component&&bM(this.spec,e.spec))}destroy(){}}function B1(n,e,t){return new ye(n,n,new Uo(e,t))}function Su(){return Math.floor(Math.random()*0xffffffffffff).toString(16)}const Ho=new Yo("@nytimes/react-prosemirror/reactKeys");function IM(){let n=!1;return new $t({key:Ho,state:{init(e,t){const r={posToKey:new Map,keyToPos:new Map};return t.doc.descendants((i,o)=>{const s=Su();return r.posToKey.set(o,s),r.keyToPos.set(s,o),!0}),r},apply(e,t,r,i){if(!e.docChanged||n)return t;const o=e.getMeta(Ho),s=(o==null?void 0:o.type)==="bustKey"&&o.payload.key,l={posToKey:new Map,keyToPos:new Map},a=Array.from(t.posToKey.entries()).sort(([u],[c])=>u-c);for(const[u,c]of a){const{pos:f,deleted:d}=e.mapping.mapResult(u);if(d)continue;let p=c;s===c&&(p=Su()),l.posToKey.set(f,p),l.keyToPos.set(p,f)}return i.doc.descendants((u,c)=>{if(l.posToKey.has(c))return!0;const f=Su();return l.posToKey.set(c,f),l.keyToPos.set(f,c),!0}),l}},props:{handleDOMEvents:{compositionstart:()=>{n=!0},compositionend:()=>{n=!1}}}})}function wu(n,e,t={}){var s;if(e===null)return!1;const r=t.from??n.state.selection.from,i=t.to??n.state.selection.to;if(n.someProp("handleTextInput",l=>l(n,r,i,e)))return!0;const{tr:o}=n.state;if(t.marks&&o.ensureMarks(t.marks),o.insertText(e,r,i),t.bust){const l=n.state.doc.resolve(r),a=l.sharedDepth(i),u=l.start(a),c=(s=Ho.getState(n.state))==null?void 0:s.posToKey.get(u-1);o.setMeta(Ho,{type:"bustKey",payload:{key:c}})}return n.dispatch(o),!0}function PM(n){let e=null,t=null;return new $t({props:{handleDOMEvents:{compositionstart(r){var s;const{state:i}=r;r.dispatch(i.tr.deleteSelection());const o=i.selection.$from;return i.selection.empty&&(i.storedMarks||!o.textOffset&&o.parentOffset&&((s=o.nodeBefore)!=null&&s.marks.some(l=>l.type.spec.inclusive===!1)))&&n(B1(i.selection.from,AM,{key:"cursor-wrapper",marks:i.storedMarks??o.marks()})),t=i.storedMarks??o.marks(),r.input.composing=!0,!0},compositionupdate(){return!0},compositionend(r){if(r.input.composing=!1,e!==null)return wu(r,e,{bust:!0,marks:t}),e=null,t=null,n(null),!0},beforeinput(r,i){var o,s;switch(i.preventDefault(),i.inputType){case"insertCompositionText":{if(i.data===null)break;e=i.data;break}case"insertReplacementText":{const l=i.getTargetRanges();(s=(o=i.dataTransfer)==null?void 0:o.items[0])==null||s.getAsString(a=>{for(const u of l){const c=r.posAtDOM(u.startContainer,u.startOffset,1),f=r.posAtDOM(u.endContainer,u.endOffset,1);wu(r,a,{from:c,to:f})}});break}case"insertText":{wu(r,i.data);break}case"deleteWordBackward":case"deleteContentBackward":case"deleteWordForward":case"deleteContentForward":case"deleteContent":{const l=i.getTargetRanges(),{tr:a}=r.state;for(const u of l){const c=r.posAtDOM(u.startContainer,u.startOffset),f=r.posAtDOM(u.endContainer,u.endOffset),{doc:d}=r.state,p=d.resolve(c).marksAcross(d.resolve(f));a.delete(c,f).setStoredMarks(p)}r.dispatch(a);break}}return!0}}}})}const Lt=typeof navigator<"u"?navigator:null,Xp=typeof document<"u"?document:null,Ln=Lt&&Lt.userAgent||"",Hc=/Edge\/(\d+)/.exec(Ln),J1=/MSIE \d/.exec(Ln),jc=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ln),ga=!!(J1||jc||Hc),FM=J1?document.documentMode:jc?+jc[1]:Hc?+Hc[1]:0,_1=!ga&&/gecko\/(\d+)/i.test(Ln),LM=_1&&+(/Firefox\/(\d+)/.exec(Ln)||[0,0])[1],Kc=!ga&&/Chrome\/(\d+)/.exec(Ln),$M=!!Kc,VM=Kc?+Kc[1]:0,W1=!ga&&!!Lt&&/Apple Computer/.test(Lt.vendor),U1=W1&&(/Mobile\/\w+/.test(Ln)||!!Lt&&Lt.maxTouchPoints>2),BM=U1||(Lt?/Mac/.test(Lt.platform):!1),JM=Lt?/Win/.test(Lt.platform):!1,_M=/Android \d/.test(Ln),H1=!!Xp&&"webkitFontSmoothing"in Xp.documentElement.style,WM=H1?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,Me={ie:ga,ie_version:FM,gecko:_1,gecko_version:LM,chrome:$M,chrome_version:VM,safari:W1,ios:U1,mac:BM,windows:JM,android:_M,webkit:H1,webkit_version:WM};function ku(n){return n.editable&&!n.hasFocus()?!1:UM(n)}function UM(n){var t,r;const 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(((t=e.focusNode)==null?void 0:t.nodeType)==3?(r=e.focusNode)==null?void 0:r.parentNode:e.focusNode))}catch{return!1}}function HM(n,e,t,r){return n.someProp("createSelectionBetween",i=>i(n,e,t))||$.between(e,t,r)}function Zp(n,e=null){const t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let i=n.docView.nearestDesc(t.focusNode);const o=i&&i.size==0;let s=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(s<0)return null;let l=r.resolve(s),a,u;if(L1(t)){for(a=s;i&&!i.node;)i=i.parent;const f=i.node;if(i&&f.isAtom&&z.isSelectable(f)&&i.parent&&!(f.isInline&&DM(t.focusNode,t.focusOffset,i.dom))){const d=i.posBefore;u=new z(s==d?l:r.resolve(d))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let f=s,d=s;for(let p=0;p{(r.anchorNode!=i||r.anchorOffset!=o)&&(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout(()=>{(!j1(e)||e.state.selection.visible)&&e.dom.classList.remove("ProseMirror-hideselection")},20))})}const om=Me.safari||Me.chrome&&Me.chrome_version<63;function Is(n,e=!1){const t=n,r=t.state.selection;if(qM(t,r),!!j1(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&Me.chrome){const i=t.domSelectionRange(),o=t.domObserver.currentSelection;if(i.anchorNode&&o.anchorNode&&Ql(i.anchorNode,i.anchorOffset,o.anchorNode,o.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)YM(t);else{const{anchor:i,head:o}=r;let s,l;om&&!(r instanceof $)&&(r.$from.parent.inlineContent||(s=rm(t,r.from)),!r.empty&&!r.$from.parent.inlineContent&&(l=rm(t,r.to))),t.docView.setSelection(i,o,t.root,e),om&&(s&&im(s),l&&im(l)),r.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&GM(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}class XM{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 ZM{constructor(e){this.view=e,this.flushingSoon=-1,this.currentSelection=new XM,this.suppressingSelectionUpdates=!1,this.view=e,this.onSelectionChange=this.onSelectionChange.bind(this)}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}stop(){this.disconnectSelection()}start(){this.connectSelection()}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;const t=new Set;let r;for(let o=e.focusNode;o;o=Yp(o))t.add(o);for(let o=e.anchorNode;o;o=Yp(o))if(t.has(o)){r=o;break}const i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:(r==null?void 0:r.nodeType)==3?r==null?void 0:r.parentNode:r}))return this.setCurSelection(),!0}registerMutation(){}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}updateSelection(){const{view:e}=this,t=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);e.input.compositionPendingChanges=0;const r=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,i=Zp(e,r);if(i&&!e.state.selection.eq(i)){const o=e.state.tr.setSelection(i);r=="pointer"?o.setMeta("pointer",!0):r=="key"&&o.scrollIntoView(),t&&o.setMeta("composition",t),e.dispatch(o)}}selectionToDOM(){const{view:e}=this;Is(e);const t=e.domSelectionRange();this.currentSelection.set(t)}flush(){const{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;const t=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(t)&&ku(e)&&!this.ignoreSelectionChange(t);let i=null;r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}onSelectionChange(){if(ku(this.view)&&!this.view.composing){if(this.suppressingSelectionUpdates)return Is(this.view);if(Me.ie&&Me.ie_version<=11&&!this.view.state.selection.empty){const e=this.view.domSelectionRange();if(e.focusNode&&Ql(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}}const di=0,sm=1,Ps=2,jo=3;class ss{constructor(e,t,r,i,o){this.parent=e,this.children=t,this.getPos=r,this.dom=i,this.contentDOM=o,this.dirty=di,i.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;tln(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!1;break}if(o.previousSibling)break}if(i==null&&t==e.childNodes.length)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!0;break}if(o.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,i=e;i;i=i.parentNode){const o=this.getDesc(i);let s;if(o&&(!t||o.node))if(r&&(s=o.nodeDOM)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):s==e))r=!1;else return o}}getDesc(e){const t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let i=e;i;i=i.parentNode){const o=this.getDesc(i);if(o)return o.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;te||s instanceof Sd){i=e-o;break}o=l}if(i)return this.children[r].domFromPos(i-this.children[r].border,t);for(let o;r&&!(o=this.children[r-1]).size&&o instanceof gd&&o.side>=0;r--);if(t<=0){let o,s=!0;for(;o=r?this.children[r-1]:null,!(!o||o.dom.parentNode==this.contentDOM);r--,s=!1);return o&&t&&s&&!o.border&&!o.domAtom?o.domFromPos(o.size,t):{node:this.contentDOM,offset:o?ln(o.dom)+1:0}}else{let o,s=!0;for(;o=r=c&&t<=u-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,c);e=s;for(let f=l;f>0;f--){const d=this.children[f-1];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(1)){i=ln(d.dom)+1;break}e-=d.size}i==-1&&(i=0)}if(i>-1&&(u>t||l==this.children.length-1)){t=u;for(let c=l+1;ch&&st){const h=l;l=a,a=h}const p=document.createRange();p.setEnd(a.node,a.offset),p.setStart(l.node,l.offset),u.removeAllRanges(),u.addRange(p)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let r=0,i=0;i=r:er){const l=r+o.border,a=s-o.border;if(e>=l&&t<=a){this.dirty=e==r||t==s?Ps:sm,e==l&&t==a&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=jo:o.markDirty(e-l,t-l);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?Ps:jo}r=s}this.dirty=Ps}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){const r=e==1?Ps:sm;t.dirtythis.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){const r=this.children[t];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>x.empty)}return e}matchesNode(e,t,r){return this.dirty==di&&e.eq(this.node)&&nE(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}update(e,t,r,i){return!0}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}}class tE extends yd{constructor(e,t,r,i,o,s,l,a){super(e,t,r,i,o,s,l,null,a,()=>!1)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,i){return!0}inParent(){const 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"}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=jo)}get domAtom(){return!1}}class Sd extends ss{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==di&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}function nE(n,e){if(n.length!=e.length)return!1;for(let t=0;t{u=!!a.call(this,s,l)}),u||l.defaultPrevented)return!0}return!1};e[r]=o}return new $t({key:new Yo("@nytimes/react-prosemirror/componentEventListeners"),props:{handleDOMEvents:e}})}function iE(){const[n,e]=k.useState(new Map),t=k.useCallback((o,s)=>{const l=n.get(o)??[];l.unshift(s),n.has(o)||(n.set(o,l),e(new Map(n)))},[n]),r=k.useCallback((o,s)=>{const l=n.get(o);l==null||l.splice(l.indexOf(s),1)},[n]),i=k.useMemo(()=>rE(n),[n]);return{registerEventListener:t,unregisterEventListener:r,componentEventListenersPlugin:i}}function K1(){const[,n]=k.useReducer(e=>e+1,0);return n}function oE(n){const e=Object.create(null);function t(r){for(const i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function sE(n,e){let t=0,r=0;for(const i in n){if(n[i]!=e[i])return!0;t++}for(const i in e)r++;return t!=r}function lE(n,e){for(const t of Object.keys(n))if(n[t]!==e[t])return!0;return!1}function lm(n){return!n.someProp("editable",e=>e(n.state)===!1)}class aE extends Pv{constructor(e,t){super(e,{state:dn.create({schema:t.state.schema,plugins:t.state.plugins}),plugins:t.plugins}),this.shouldUpdatePluginViews=!1,this.shouldUpdatePluginViews=!0,this._props=t,this.oldProps={state:t.state},this.state=t.state,this.domObserver.stop(),this.domObserver=new ZM(this),this.domObserver.start(),this.editable=lm(this),this.docView.dom.replaceChildren(),this.docView=t.docView}get needsRedraw(){if(this.oldProps.state.plugins===this._props.state.plugins&&this._props.plugins===this.oldProps.plugins)return!1;const e=oE(this);return sE(this.nodeViews,e)}pureSetProps(e){this._props={...this._props,...e},this.state=this._props.state,this.editable=lm(this)}runPendingEffects(){if(lE(this.props,this.oldProps)){const e=this.props;this._props=this.oldProps,this.state=this._props.state,this.update(e)}}update(e){super.update(e),this.oldProps=e}updatePluginViews(e){this.shouldUpdatePluginViews&&super.updatePluginViews(e)}destroy(){this.dom=document.createElement("div"),super.destroy()}}const uE=new zm({nodes:{doc:{content:"text*"},text:{inline:!0}}}),cE=dn.create({schema:uE});function fE(n,e){const[t,r]=k.useState(null),[i,o]=k.useState(null),s=K1(),l=e.defaultState??cE,[a,u]=k.useState(l),c=e.state??a,{componentEventListenersPlugin:f,registerEventListener:d,unregisterEventListener:p}=iE(),h=k.useCallback(N=>{fi.flushSync(()=>{o(N)})},[]),m=k.useMemo(()=>[...e.plugins??[],f,PM(h)],[e.plugins,f,h]),w=k.useCallback(function(E){fi.flushSync(()=>{e.state||u(O=>O.apply(E)),e.dispatchTransaction&&e.dispatchTransaction.call(this,E)})},[e.dispatchTransaction,e.state]),g=document.createElement("div"),y=k.useRef(new yd(void 0,[],()=>-1,c.doc,[],_.empty,g,null,g,()=>!1)),S={...e,state:c,plugins:m,dispatchTransaction:w,docView:y.current};return k.useLayoutEffect(()=>()=>{t==null||t.destroy()},[t]),k.useLayoutEffect(()=>{if(t&&t.dom!==n&&r(null),!!n&&!t){const N=new aE({mount:n},S);r(N),N.dom.addEventListener("compositionend",s);return}}),k.useLayoutEffect(()=>{if(t!=null&&t.needsRedraw){r(null);return}else t==null||t.domObserver.selectionToDOM(),t==null||t.runPendingEffects()}),t==null||t.pureSetProps(S),{editor:k.useMemo(()=>({view:t,registerEventListener:d,unregisterEventListener:p,cursorWrapper:i,docViewDescRef:y}),[t,d,p,i]),state:c}}function dE({children:n}){const e=k.useRef(new Set).current,t=k.useRef(new Set).current,r=k.useRef(!1),i=K1(),o=k.useRef(!0),s=k.useCallback(()=>{o.current||(i(),o.current=!0)},[i]),l=k.useCallback(a=>{let u;const c=()=>{u=a()};return e.add(c),s(),()=>{e.delete(c),u&&(r.current?(t.add(u),s()):u())}},[e,t,s]);return k.useLayoutEffect(()=>(o.current=!1,e.forEach(a=>a()),e.clear(),()=>{t.forEach(a=>a()),t.clear()})),k.useLayoutEffect(()=>(r.current=!0,()=>{r.current=!1}),[]),R.jsx($1.Provider,{value:l,children:n})}const mt=k.createContext({parentRef:{current:void 0},siblingsRef:{current:[]}});function q1(n,e,t,r,i,o,s,l){const{view:a}=k.useContext(yi),[u,c]=k.useState(!0),f=k.useRef(s),d=k.useRef(()=>!1),p=k.useCallback(g=>{d.current=g},[]),{siblingsRef:h,parentRef:m}=k.useContext(mt),w=k.useRef([]);return k.useLayoutEffect(()=>{const g=h.current;return()=>{if(f.current&&g.includes(f.current)){const y=g.indexOf(f.current);g.splice(y,1)}}},[h]),k.useLayoutEffect(()=>{var y;if(!n||!r.current)return;const g=w.current[0];f.current?(f.current.parent=m.current,f.current.children=w.current,f.current.node=n,f.current.getPos=e,f.current.outerDeco=o,f.current.innerDeco=i,f.current.dom=(t==null?void 0:t.current)??r.current,f.current.dom.pmViewDesc=f.current,f.current.contentDOM=(l==null?void 0:l.current)??f.current.contentDOM??(g==null?void 0:g.dom.parentElement)??null,f.current.nodeDOM=r.current):f.current=new yd(m.current,w.current,e,n,o,i,(t==null?void 0:t.current)??r.current,(g==null?void 0:g.dom.parentElement)??null,r.current,S=>!!d.current(S)),c(f.current.contentDOM!==null),h.current.includes(f.current)||h.current.push(f.current),h.current.sort((S,C)=>S.getPos()-C.getPos());for(const S of w.current)if(S.parent=f.current,S instanceof Yl){const C=(y=f.current.contentDOM)==null?void 0:y.firstChild;if(!C)throw new Error("Started a composition but couldn't find the text node it belongs to.");let N=C;for(;N.firstChild;)N=N.firstChild;if(!N||!(N instanceof Text))throw new Error("Started a composition but couldn't find the text node it belongs to.");S.dom=C,S.textDOM=N,S.text=N.data,S.textDOM.pmViewDesc=S,a==null||a.input.compositionNodes.push(S)}return()=>{var S,C,N,E;((S=f.current)==null?void 0:S.children[0])instanceof Yl&&!(a!=null&&a.composing)&&((E=(C=f.current)==null?void 0:C.children[0].dom.parentNode)==null||E.removeChild((N=f.current)==null?void 0:N.children[0].dom))}}),{hasContentDOM:u,childDescriptors:w,nodeViewDescRef:f,setStopEvent:p}}function hE(n,e){return n.type.side-e.type.side}function pE(n,e,t,r){const i=e.locals(n);let o=0;if(i.length==0){for(let u=0;uo;)l.push(i[s++]);let d=o+c.nodeSize;if(c.isText){let h=d;s!h.inline):l.slice();r(c,p,e.forChild(o,c),o,f),o=d}}function ya(){const{view:n}=k.useContext(yi);return n&&Ho.getState(n.state)}var Q1={exports:{}};/*! +`+o.stack}return{value:n,source:e,stack:i,digest:null}}function hu(n,e,t){return{value:n,source:null,stack:t??null,digest:e??null}}function Rc(n,e){try{console.error(e.value)}catch(t){setTimeout(function(){throw t})}}var QN=typeof WeakMap=="function"?WeakMap:Map;function s1(n,e,t){t=Qt(-1,t),t.tag=3,t.payload={element:null};var r=e.value;return t.callback=function(){Ul||(Ul=!0,Bc=r),Rc(n,e)},t}function l1(n,e,t){t=Qt(-1,t),t.tag=3;var r=n.type.getDerivedStateFromError;if(typeof r=="function"){var i=e.value;t.payload=function(){return r(i)},t.callback=function(){Rc(n,e)}}var o=n.stateNode;return o!==null&&typeof o.componentDidCatch=="function"&&(t.callback=function(){Rc(n,e),typeof r!="function"&&(Mn===null?Mn=new Set([this]):Mn.add(this));var s=e.stack;this.componentDidCatch(e.value,{componentStack:s!==null?s:""})}),t}function Rp(n,e,t){var r=n.pingCache;if(r===null){r=n.pingCache=new QN;var i=new Set;r.set(e,i)}else i=r.get(e),i===void 0&&(i=new Set,r.set(e,i));i.has(t)||(i.add(t),n=uM.bind(null,n,e,t),e.then(n,n))}function Ap(n){do{var e;if((e=n.tag===13)&&(e=n.memoizedState,e=e!==null?e.dehydrated!==null:!0),e)return n;n=n.return}while(n!==null);return null}function bp(n,e,t,r,i){return n.mode&1?(n.flags|=65536,n.lanes=i,n):(n===e?n.flags|=65536:(n.flags|=128,t.flags|=131072,t.flags&=-52805,t.tag===1&&(t.alternate===null?t.tag=17:(e=Qt(-1,1),e.tag=2,Nn(t,e,1))),t.lanes|=1),n)}var YN=en.ReactCurrentOwner,_e=!1;function De(n,e,t,r){e.child=n===null?V0(e,null,t,r):li(e,n.child,t,r)}function zp(n,e,t,r,i){t=t.render;var o=e.ref;return jr(e,i),r=Zf(n,e,t,r,o,i),t=ed(),n!==null&&!_e?(e.updateQueue=n.updateQueue,e.flags&=-2053,n.lanes&=~i,Zt(n,e,i)):(Q&&t&&Jf(e),e.flags|=1,De(n,e,r,i),e.child)}function Ip(n,e,t,r,i){if(n===null){var o=t.type;return typeof o=="function"&&!cd(o)&&o.defaultProps===void 0&&t.compare===null&&t.defaultProps===void 0?(e.tag=15,e.type=o,a1(n,e,o,r,i)):(n=fl(t.type,null,r,e,e.mode,i),n.ref=e.ref,n.return=e,e.child=n)}if(o=n.child,!(n.lanes&i)){var s=o.memoizedProps;if(t=t.compare,t=t!==null?t:zo,t(s,r)&&n.ref===e.ref)return Zt(n,e,i)}return e.flags|=1,n=On(o,r),n.ref=e.ref,n.return=e,e.child=n}function a1(n,e,t,r,i){if(n!==null){var o=n.memoizedProps;if(zo(o,r)&&n.ref===e.ref)if(_e=!1,e.pendingProps=r=o,(n.lanes&i)!==0)n.flags&131072&&(_e=!0);else return e.lanes=n.lanes,Zt(n,e,i)}return Ac(n,e,t,r,i)}function u1(n,e,t){var r=e.pendingProps,i=r.children,o=n!==null?n.memoizedState:null;if(r.mode==="hidden")if(!(e.mode&1))e.memoizedState={baseLanes:0,cachePool:null,transitions:null},H($r,Ge),Ge|=t;else{if(!(t&1073741824))return n=o!==null?o.baseLanes|t:t,e.lanes=e.childLanes=1073741824,e.memoizedState={baseLanes:n,cachePool:null,transitions:null},e.updateQueue=null,H($r,Ge),Ge|=n,null;e.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=o!==null?o.baseLanes:t,H($r,Ge),Ge|=r}else o!==null?(r=o.baseLanes|t,e.memoizedState=null):r=t,H($r,Ge),Ge|=r;return De(n,e,i,t),e.child}function c1(n,e){var t=e.ref;(n===null&&t!==null||n!==null&&n.ref!==t)&&(e.flags|=512,e.flags|=2097152)}function Ac(n,e,t,r,i){var o=He(t)?ar:Oe.current;return o=oi(e,o),jr(e,i),t=Zf(n,e,t,r,o,i),r=ed(),n!==null&&!_e?(e.updateQueue=n.updateQueue,e.flags&=-2053,n.lanes&=~i,Zt(n,e,i)):(Q&&r&&Jf(e),e.flags|=1,De(n,e,t,i),e.child)}function Pp(n,e,t,r,i){if(He(t)){var o=!0;Il(e)}else o=!1;if(jr(e,i),e.stateNode===null)al(n,e),L0(e,t,r),Dc(e,t,r,i),r=!0;else if(n===null){var s=e.stateNode,l=e.memoizedProps;s.props=l;var a=s.context,u=t.contextType;typeof u=="object"&&u!==null?u=ht(u):(u=He(t)?ar:Oe.current,u=oi(e,u));var c=t.getDerivedStateFromProps,f=typeof c=="function"||typeof s.getSnapshotBeforeUpdate=="function";f||typeof s.UNSAFE_componentWillReceiveProps!="function"&&typeof s.componentWillReceiveProps!="function"||(l!==r||a!==u)&&Ep(e,s,r,u),sn=!1;var d=e.memoizedState;s.state=d,Vl(e,r,s,i),a=e.memoizedState,l!==r||d!==a||Ue.current||sn?(typeof c=="function"&&(Tc(e,t,c,r),a=e.memoizedState),(l=sn||Mp(e,t,l,r,d,a,u))?(f||typeof s.UNSAFE_componentWillMount!="function"&&typeof s.componentWillMount!="function"||(typeof s.componentWillMount=="function"&&s.componentWillMount(),typeof s.UNSAFE_componentWillMount=="function"&&s.UNSAFE_componentWillMount()),typeof s.componentDidMount=="function"&&(e.flags|=4194308)):(typeof s.componentDidMount=="function"&&(e.flags|=4194308),e.memoizedProps=r,e.memoizedState=a),s.props=r,s.state=a,s.context=u,r=l):(typeof s.componentDidMount=="function"&&(e.flags|=4194308),r=!1)}else{s=e.stateNode,P0(n,e),l=e.memoizedProps,u=e.type===e.elementType?l:yt(e.type,l),s.props=u,f=e.pendingProps,d=s.context,a=t.contextType,typeof a=="object"&&a!==null?a=ht(a):(a=He(t)?ar:Oe.current,a=oi(e,a));var p=t.getDerivedStateFromProps;(c=typeof p=="function"||typeof s.getSnapshotBeforeUpdate=="function")||typeof s.UNSAFE_componentWillReceiveProps!="function"&&typeof s.componentWillReceiveProps!="function"||(l!==f||d!==a)&&Ep(e,s,r,a),sn=!1,d=e.memoizedState,s.state=d,Vl(e,r,s,i);var h=e.memoizedState;l!==f||d!==h||Ue.current||sn?(typeof p=="function"&&(Tc(e,t,p,r),h=e.memoizedState),(u=sn||Mp(e,t,u,r,d,h,a)||!1)?(c||typeof s.UNSAFE_componentWillUpdate!="function"&&typeof s.componentWillUpdate!="function"||(typeof s.componentWillUpdate=="function"&&s.componentWillUpdate(r,h,a),typeof s.UNSAFE_componentWillUpdate=="function"&&s.UNSAFE_componentWillUpdate(r,h,a)),typeof s.componentDidUpdate=="function"&&(e.flags|=4),typeof s.getSnapshotBeforeUpdate=="function"&&(e.flags|=1024)):(typeof s.componentDidUpdate!="function"||l===n.memoizedProps&&d===n.memoizedState||(e.flags|=4),typeof s.getSnapshotBeforeUpdate!="function"||l===n.memoizedProps&&d===n.memoizedState||(e.flags|=1024),e.memoizedProps=r,e.memoizedState=h),s.props=r,s.state=h,s.context=a,r=u):(typeof s.componentDidUpdate!="function"||l===n.memoizedProps&&d===n.memoizedState||(e.flags|=4),typeof s.getSnapshotBeforeUpdate!="function"||l===n.memoizedProps&&d===n.memoizedState||(e.flags|=1024),r=!1)}return bc(n,e,t,r,o,i)}function bc(n,e,t,r,i,o){c1(n,e);var s=(e.flags&128)!==0;if(!r&&!s)return i&&kp(e,t,!1),Zt(n,e,o);r=e.stateNode,YN.current=e;var l=s&&typeof t.getDerivedStateFromError!="function"?null:r.render();return e.flags|=1,n!==null&&s?(e.child=li(e,n.child,null,o),e.child=li(e,null,l,o)):De(n,e,l,o),e.memoizedState=r.state,i&&kp(e,t,!0),e.child}function f1(n){var e=n.stateNode;e.pendingContext?wp(n,e.pendingContext,e.pendingContext!==e.context):e.context&&wp(n,e.context,!1),Qf(n,e.containerInfo)}function Fp(n,e,t,r,i){return si(),Wf(i),e.flags|=256,De(n,e,t,r),e.child}var zc={dehydrated:null,treeContext:null,retryLane:0};function Ic(n){return{baseLanes:n,cachePool:null,transitions:null}}function d1(n,e,t){var r=e.pendingProps,i=Y.current,o=!1,s=(e.flags&128)!==0,l;if((l=s)||(l=n!==null&&n.memoizedState===null?!1:(i&2)!==0),l?(o=!0,e.flags&=-129):(n===null||n.memoizedState!==null)&&(i|=1),H(Y,i&1),n===null)return Ec(e),n=e.memoizedState,n!==null&&(n=n.dehydrated,n!==null)?(e.mode&1?n.data==="$!"?e.lanes=8:e.lanes=1073741824:e.lanes=1,null):(s=r.children,n=r.fallback,o?(r=e.mode,o=e.child,s={mode:"hidden",children:s},!(r&1)&&o!==null?(o.childLanes=0,o.pendingProps=s):o=fa(s,r,0,null),n=or(n,r,t,null),o.return=e,n.return=e,o.sibling=n,e.child=o,e.child.memoizedState=Ic(t),e.memoizedState=zc,n):rd(e,s));if(i=n.memoizedState,i!==null&&(l=i.dehydrated,l!==null))return GN(n,e,s,r,l,i,t);if(o){o=r.fallback,s=e.mode,i=n.child,l=i.sibling;var a={mode:"hidden",children:r.children};return!(s&1)&&e.child!==i?(r=e.child,r.childLanes=0,r.pendingProps=a,e.deletions=null):(r=On(i,a),r.subtreeFlags=i.subtreeFlags&14680064),l!==null?o=On(l,o):(o=or(o,s,t,null),o.flags|=2),o.return=e,r.return=e,r.sibling=o,e.child=r,r=o,o=e.child,s=n.child.memoizedState,s=s===null?Ic(t):{baseLanes:s.baseLanes|t,cachePool:null,transitions:s.transitions},o.memoizedState=s,o.childLanes=n.childLanes&~t,e.memoizedState=zc,r}return o=n.child,n=o.sibling,r=On(o,{mode:"visible",children:r.children}),!(e.mode&1)&&(r.lanes=t),r.return=e,r.sibling=null,n!==null&&(t=e.deletions,t===null?(e.deletions=[n],e.flags|=16):t.push(n)),e.child=r,e.memoizedState=null,r}function rd(n,e){return e=fa({mode:"visible",children:e},n.mode,0,null),e.return=n,n.child=e}function Ds(n,e,t,r){return r!==null&&Wf(r),li(e,n.child,null,t),n=rd(e,e.pendingProps.children),n.flags|=2,e.memoizedState=null,n}function GN(n,e,t,r,i,o,s){if(t)return e.flags&256?(e.flags&=-257,r=hu(Error(E(422))),Ds(n,e,s,r)):e.memoizedState!==null?(e.child=n.child,e.flags|=128,null):(o=r.fallback,i=e.mode,r=fa({mode:"visible",children:r.children},i,0,null),o=or(o,i,s,null),o.flags|=2,r.return=e,o.return=e,r.sibling=o,e.child=r,e.mode&1&&li(e,n.child,null,s),e.child.memoizedState=Ic(s),e.memoizedState=zc,o);if(!(e.mode&1))return Ds(n,e,s,null);if(i.data==="$!"){if(r=i.nextSibling&&i.nextSibling.dataset,r)var l=r.dgst;return r=l,o=Error(E(419)),r=hu(o,r,void 0),Ds(n,e,s,r)}if(l=(s&n.childLanes)!==0,_e||l){if(r=de,r!==null){switch(s&-s){case 4:i=2;break;case 16:i=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:i=32;break;case 536870912:i=268435456;break;default:i=0}i=i&(r.suspendedLanes|s)?0:i,i!==0&&i!==o.retryLane&&(o.retryLane=i,Xt(n,i),xt(r,n,i,-1))}return ud(),r=hu(Error(E(421))),Ds(n,e,s,r)}return i.data==="$?"?(e.flags|=128,e.child=n.child,e=cM.bind(null,n),i._reactRetry=e,null):(n=o.treeContext,Ze=Cn(i.nextSibling),tt=e,Q=!0,kt=null,n!==null&&(st[lt++]=jt,st[lt++]=Kt,st[lt++]=ur,jt=n.id,Kt=n.overflow,ur=e),e=rd(e,r.children),e.flags|=4096,e)}function Lp(n,e,t){n.lanes|=e;var r=n.alternate;r!==null&&(r.lanes|=e),Oc(n.return,e,t)}function pu(n,e,t,r,i){var o=n.memoizedState;o===null?n.memoizedState={isBackwards:e,rendering:null,renderingStartTime:0,last:r,tail:t,tailMode:i}:(o.isBackwards=e,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=t,o.tailMode=i)}function h1(n,e,t){var r=e.pendingProps,i=r.revealOrder,o=r.tail;if(De(n,e,r.children,t),r=Y.current,r&2)r=r&1|2,e.flags|=128;else{if(n!==null&&n.flags&128)e:for(n=e.child;n!==null;){if(n.tag===13)n.memoizedState!==null&&Lp(n,t,e);else if(n.tag===19)Lp(n,t,e);else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===e)break e;for(;n.sibling===null;){if(n.return===null||n.return===e)break e;n=n.return}n.sibling.return=n.return,n=n.sibling}r&=1}if(H(Y,r),!(e.mode&1))e.memoizedState=null;else switch(i){case"forwards":for(t=e.child,i=null;t!==null;)n=t.alternate,n!==null&&Bl(n)===null&&(i=t),t=t.sibling;t=i,t===null?(i=e.child,e.child=null):(i=t.sibling,t.sibling=null),pu(e,!1,i,t,o);break;case"backwards":for(t=null,i=e.child,e.child=null;i!==null;){if(n=i.alternate,n!==null&&Bl(n)===null){e.child=i;break}n=i.sibling,i.sibling=t,t=i,i=n}pu(e,!0,t,null,o);break;case"together":pu(e,!1,null,null,void 0);break;default:e.memoizedState=null}return e.child}function al(n,e){!(e.mode&1)&&n!==null&&(n.alternate=null,e.alternate=null,e.flags|=2)}function Zt(n,e,t){if(n!==null&&(e.dependencies=n.dependencies),fr|=e.lanes,!(t&e.childLanes))return null;if(n!==null&&e.child!==n.child)throw Error(E(153));if(e.child!==null){for(n=e.child,t=On(n,n.pendingProps),e.child=t,t.return=e;n.sibling!==null;)n=n.sibling,t=t.sibling=On(n,n.pendingProps),t.return=e;t.sibling=null}return e.child}function XN(n,e,t){switch(e.tag){case 3:f1(e),si();break;case 5:B0(e);break;case 1:He(e.type)&&Il(e);break;case 4:Qf(e,e.stateNode.containerInfo);break;case 10:var r=e.type._context,i=e.memoizedProps.value;H(Ll,r._currentValue),r._currentValue=i;break;case 13:if(r=e.memoizedState,r!==null)return r.dehydrated!==null?(H(Y,Y.current&1),e.flags|=128,null):t&e.child.childLanes?d1(n,e,t):(H(Y,Y.current&1),n=Zt(n,e,t),n!==null?n.sibling:null);H(Y,Y.current&1);break;case 19:if(r=(t&e.childLanes)!==0,n.flags&128){if(r)return h1(n,e,t);e.flags|=128}if(i=e.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),H(Y,Y.current),r)break;return null;case 22:case 23:return e.lanes=0,u1(n,e,t)}return Zt(n,e,t)}var p1,Pc,m1,g1;p1=function(n,e){for(var t=e.child;t!==null;){if(t.tag===5||t.tag===6)n.appendChild(t.stateNode);else if(t.tag!==4&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return;t=t.return}t.sibling.return=t.return,t=t.sibling}};Pc=function(){};m1=function(n,e,t,r){var i=n.memoizedProps;if(i!==r){n=e.stateNode,Zn(bt.current);var o=null;switch(t){case"input":i=rc(n,i),r=rc(n,r),o=[];break;case"select":i=X({},i,{value:void 0}),r=X({},r,{value:void 0}),o=[];break;case"textarea":i=sc(n,i),r=sc(n,r),o=[];break;default:typeof i.onClick!="function"&&typeof r.onClick=="function"&&(n.onclick=bl)}ac(t,r);var s;t=null;for(u in i)if(!r.hasOwnProperty(u)&&i.hasOwnProperty(u)&&i[u]!=null)if(u==="style"){var l=i[u];for(s in l)l.hasOwnProperty(s)&&(t||(t={}),t[s]="")}else u!=="dangerouslySetInnerHTML"&&u!=="children"&&u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&u!=="autoFocus"&&(Eo.hasOwnProperty(u)?o||(o=[]):(o=o||[]).push(u,null));for(u in r){var a=r[u];if(l=i!=null?i[u]:void 0,r.hasOwnProperty(u)&&a!==l&&(a!=null||l!=null))if(u==="style")if(l){for(s in l)!l.hasOwnProperty(s)||a&&a.hasOwnProperty(s)||(t||(t={}),t[s]="");for(s in a)a.hasOwnProperty(s)&&l[s]!==a[s]&&(t||(t={}),t[s]=a[s])}else t||(o||(o=[]),o.push(u,t)),t=a;else u==="dangerouslySetInnerHTML"?(a=a?a.__html:void 0,l=l?l.__html:void 0,a!=null&&l!==a&&(o=o||[]).push(u,a)):u==="children"?typeof a!="string"&&typeof a!="number"||(o=o||[]).push(u,""+a):u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&(Eo.hasOwnProperty(u)?(a!=null&&u==="onScroll"&&K("scroll",n),o||l===a||(o=[])):(o=o||[]).push(u,a))}t&&(o=o||[]).push("style",t);var u=o;(e.updateQueue=u)&&(e.flags|=4)}};g1=function(n,e,t,r){t!==r&&(e.flags|=4)};function Mi(n,e){if(!Q)switch(n.tailMode){case"hidden":e=n.tail;for(var t=null;e!==null;)e.alternate!==null&&(t=e),e=e.sibling;t===null?n.tail=null:t.sibling=null;break;case"collapsed":t=n.tail;for(var r=null;t!==null;)t.alternate!==null&&(r=t),t=t.sibling;r===null?e||n.tail===null?n.tail=null:n.tail.sibling=null:r.sibling=null}}function xe(n){var e=n.alternate!==null&&n.alternate.child===n.child,t=0,r=0;if(e)for(var i=n.child;i!==null;)t|=i.lanes|i.childLanes,r|=i.subtreeFlags&14680064,r|=i.flags&14680064,i.return=n,i=i.sibling;else for(i=n.child;i!==null;)t|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=n,i=i.sibling;return n.subtreeFlags|=r,n.childLanes=t,e}function ZN(n,e,t){var r=e.pendingProps;switch(_f(e),e.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return xe(e),null;case 1:return He(e.type)&&zl(),xe(e),null;case 3:return r=e.stateNode,ai(),q(Ue),q(Oe),Gf(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(n===null||n.child===null)&&(Os(e)?e.flags|=4:n===null||n.memoizedState.isDehydrated&&!(e.flags&256)||(e.flags|=1024,kt!==null&&(Wc(kt),kt=null))),Pc(n,e),xe(e),null;case 5:Yf(e);var i=Zn($o.current);if(t=e.type,n!==null&&e.stateNode!=null)m1(n,e,t,r,i),n.ref!==e.ref&&(e.flags|=512,e.flags|=2097152);else{if(!r){if(e.stateNode===null)throw Error(E(166));return xe(e),null}if(n=Zn(bt.current),Os(e)){r=e.stateNode,t=e.type;var o=e.memoizedProps;switch(r[Ot]=e,r[Fo]=o,n=(e.mode&1)!==0,t){case"dialog":K("cancel",r),K("close",r);break;case"iframe":case"object":case"embed":K("load",r);break;case"video":case"audio":for(i=0;i<\/script>",n=n.removeChild(n.firstChild)):typeof r.is=="string"?n=s.createElement(t,{is:r.is}):(n=s.createElement(t),t==="select"&&(s=n,r.multiple?s.multiple=!0:r.size&&(s.size=r.size))):n=s.createElementNS(n,t),n[Ot]=e,n[Fo]=r,p1(n,e,!1,!1),e.stateNode=n;e:{switch(s=uc(t,r),t){case"dialog":K("cancel",n),K("close",n),i=r;break;case"iframe":case"object":case"embed":K("load",n),i=r;break;case"video":case"audio":for(i=0;ici&&(e.flags|=128,r=!0,Mi(o,!1),e.lanes=4194304)}else{if(!r)if(n=Bl(s),n!==null){if(e.flags|=128,r=!0,t=n.updateQueue,t!==null&&(e.updateQueue=t,e.flags|=4),Mi(o,!0),o.tail===null&&o.tailMode==="hidden"&&!s.alternate&&!Q)return xe(e),null}else 2*ne()-o.renderingStartTime>ci&&t!==1073741824&&(e.flags|=128,r=!0,Mi(o,!1),e.lanes=4194304);o.isBackwards?(s.sibling=e.child,e.child=s):(t=o.last,t!==null?t.sibling=s:e.child=s,o.last=s)}return o.tail!==null?(e=o.tail,o.rendering=e,o.tail=e.sibling,o.renderingStartTime=ne(),e.sibling=null,t=Y.current,H(Y,r?t&1|2:t&1),e):(xe(e),null);case 22:case 23:return ad(),r=e.memoizedState!==null,n!==null&&n.memoizedState!==null!==r&&(e.flags|=8192),r&&e.mode&1?Ge&1073741824&&(xe(e),e.subtreeFlags&6&&(e.flags|=8192)):xe(e),null;case 24:return null;case 25:return null}throw Error(E(156,e.tag))}function eM(n,e){switch(_f(e),e.tag){case 1:return He(e.type)&&zl(),n=e.flags,n&65536?(e.flags=n&-65537|128,e):null;case 3:return ai(),q(Ue),q(Oe),Gf(),n=e.flags,n&65536&&!(n&128)?(e.flags=n&-65537|128,e):null;case 5:return Yf(e),null;case 13:if(q(Y),n=e.memoizedState,n!==null&&n.dehydrated!==null){if(e.alternate===null)throw Error(E(340));si()}return n=e.flags,n&65536?(e.flags=n&-65537|128,e):null;case 19:return q(Y),null;case 4:return ai(),null;case 10:return jf(e.type._context),null;case 22:case 23:return ad(),null;case 24:return null;default:return null}}var Rs=!1,Ne=!1,tM=typeof WeakSet=="function"?WeakSet:Set,R=null;function Lr(n,e){var t=n.ref;if(t!==null)if(typeof t=="function")try{t(null)}catch(r){Z(n,e,r)}else t.current=null}function Fc(n,e,t){try{t()}catch(r){Z(n,e,r)}}var $p=!1;function nM(n,e){if(wc=Dl,n=k0(),Bf(n)){if("selectionStart"in n)var t={start:n.selectionStart,end:n.selectionEnd};else e:{t=(t=n.ownerDocument)&&t.defaultView||window;var r=t.getSelection&&t.getSelection();if(r&&r.rangeCount!==0){t=r.anchorNode;var i=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{t.nodeType,o.nodeType}catch{t=null;break e}var s=0,l=-1,a=-1,u=0,c=0,f=n,d=null;t:for(;;){for(var p;f!==t||i!==0&&f.nodeType!==3||(l=s+i),f!==o||r!==0&&f.nodeType!==3||(a=s+r),f.nodeType===3&&(s+=f.nodeValue.length),(p=f.firstChild)!==null;)d=f,f=p;for(;;){if(f===n)break t;if(d===t&&++u===i&&(l=s),d===o&&++c===r&&(a=s),(p=f.nextSibling)!==null)break;f=d,d=f.parentNode}f=p}t=l===-1||a===-1?null:{start:l,end:a}}else t=null}t=t||{start:0,end:0}}else t=null;for(kc={focusedElem:n,selectionRange:t},Dl=!1,R=e;R!==null;)if(e=R,n=e.child,(e.subtreeFlags&1028)!==0&&n!==null)n.return=e,R=n;else for(;R!==null;){e=R;try{var h=e.alternate;if(e.flags&1024)switch(e.tag){case 0:case 11:case 15:break;case 1:if(h!==null){var m=h.memoizedProps,w=h.memoizedState,g=e.stateNode,y=g.getSnapshotBeforeUpdate(e.elementType===e.type?m:yt(e.type,m),w);g.__reactInternalSnapshotBeforeUpdate=y}break;case 3:var S=e.stateNode.containerInfo;S.nodeType===1?S.textContent="":S.nodeType===9&&S.documentElement&&S.removeChild(S.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(E(163))}}catch(C){Z(e,e.return,C)}if(n=e.sibling,n!==null){n.return=e.return,R=n;break}R=e.return}return h=$p,$p=!1,h}function fo(n,e,t){var r=e.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var i=r=r.next;do{if((i.tag&n)===n){var o=i.destroy;i.destroy=void 0,o!==void 0&&Fc(e,t,o)}i=i.next}while(i!==r)}}function ua(n,e){if(e=e.updateQueue,e=e!==null?e.lastEffect:null,e!==null){var t=e=e.next;do{if((t.tag&n)===n){var r=t.create;t.destroy=r()}t=t.next}while(t!==e)}}function Lc(n){var e=n.ref;if(e!==null){var t=n.stateNode;switch(n.tag){case 5:n=t;break;default:n=t}typeof e=="function"?e(n):e.current=n}}function y1(n){var e=n.alternate;e!==null&&(n.alternate=null,y1(e)),n.child=null,n.deletions=null,n.sibling=null,n.tag===5&&(e=n.stateNode,e!==null&&(delete e[Ot],delete e[Fo],delete e[Cc],delete e[$N],delete e[VN])),n.stateNode=null,n.return=null,n.dependencies=null,n.memoizedProps=null,n.memoizedState=null,n.pendingProps=null,n.stateNode=null,n.updateQueue=null}function S1(n){return n.tag===5||n.tag===3||n.tag===4}function Vp(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||S1(n.return))return null;n=n.return}for(n.sibling.return=n.return,n=n.sibling;n.tag!==5&&n.tag!==6&&n.tag!==18;){if(n.flags&2||n.child===null||n.tag===4)continue e;n.child.return=n,n=n.child}if(!(n.flags&2))return n.stateNode}}function $c(n,e,t){var r=n.tag;if(r===5||r===6)n=n.stateNode,e?t.nodeType===8?t.parentNode.insertBefore(n,e):t.insertBefore(n,e):(t.nodeType===8?(e=t.parentNode,e.insertBefore(n,t)):(e=t,e.appendChild(n)),t=t._reactRootContainer,t!=null||e.onclick!==null||(e.onclick=bl));else if(r!==4&&(n=n.child,n!==null))for($c(n,e,t),n=n.sibling;n!==null;)$c(n,e,t),n=n.sibling}function Vc(n,e,t){var r=n.tag;if(r===5||r===6)n=n.stateNode,e?t.insertBefore(n,e):t.appendChild(n);else if(r!==4&&(n=n.child,n!==null))for(Vc(n,e,t),n=n.sibling;n!==null;)Vc(n,e,t),n=n.sibling}var me=null,St=!1;function tn(n,e,t){for(t=t.child;t!==null;)w1(n,e,t),t=t.sibling}function w1(n,e,t){if(At&&typeof At.onCommitFiberUnmount=="function")try{At.onCommitFiberUnmount(ta,t)}catch{}switch(t.tag){case 5:Ne||Lr(t,e);case 6:var r=me,i=St;me=null,tn(n,e,t),me=r,St=i,me!==null&&(St?(n=me,t=t.stateNode,n.nodeType===8?n.parentNode.removeChild(t):n.removeChild(t)):me.removeChild(t.stateNode));break;case 18:me!==null&&(St?(n=me,t=t.stateNode,n.nodeType===8?lu(n.parentNode,t):n.nodeType===1&&lu(n,t),Ao(n)):lu(me,t.stateNode));break;case 4:r=me,i=St,me=t.stateNode.containerInfo,St=!0,tn(n,e,t),me=r,St=i;break;case 0:case 11:case 14:case 15:if(!Ne&&(r=t.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var o=i,s=o.destroy;o=o.tag,s!==void 0&&(o&2||o&4)&&Fc(t,e,s),i=i.next}while(i!==r)}tn(n,e,t);break;case 1:if(!Ne&&(Lr(t,e),r=t.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=t.memoizedProps,r.state=t.memoizedState,r.componentWillUnmount()}catch(l){Z(t,e,l)}tn(n,e,t);break;case 21:tn(n,e,t);break;case 22:t.mode&1?(Ne=(r=Ne)||t.memoizedState!==null,tn(n,e,t),Ne=r):tn(n,e,t);break;default:tn(n,e,t)}}function Bp(n){var e=n.updateQueue;if(e!==null){n.updateQueue=null;var t=n.stateNode;t===null&&(t=n.stateNode=new tM),e.forEach(function(r){var i=fM.bind(null,n,r);t.has(r)||(t.add(r),r.then(i,i))})}}function gt(n,e){var t=e.deletions;if(t!==null)for(var r=0;ri&&(i=s),r&=~o}if(r=i,r=ne()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*iM(r/1960))-r,10n?16:n,yn===null)var r=!1;else{if(n=yn,yn=null,Hl=0,B&6)throw Error(E(331));var i=B;for(B|=4,R=n.current;R!==null;){var o=R,s=o.child;if(R.flags&16){var l=o.deletions;if(l!==null){for(var a=0;ane()-sd?ir(n,0):od|=t),je(n,e)}function O1(n,e){e===0&&(n.mode&1?(e=vs,vs<<=1,!(vs&130023424)&&(vs=4194304)):e=1);var t=Ae();n=Xt(n,e),n!==null&&(es(n,e,t),je(n,t))}function cM(n){var e=n.memoizedState,t=0;e!==null&&(t=e.retryLane),O1(n,t)}function fM(n,e){var t=0;switch(n.tag){case 13:var r=n.stateNode,i=n.memoizedState;i!==null&&(t=i.retryLane);break;case 19:r=n.stateNode;break;default:throw Error(E(314))}r!==null&&r.delete(e),O1(n,t)}var T1;T1=function(n,e,t){if(n!==null)if(n.memoizedProps!==e.pendingProps||Ue.current)_e=!0;else{if(!(n.lanes&t)&&!(e.flags&128))return _e=!1,XN(n,e,t);_e=!!(n.flags&131072)}else _e=!1,Q&&e.flags&1048576&&A0(e,Fl,e.index);switch(e.lanes=0,e.tag){case 2:var r=e.type;al(n,e),n=e.pendingProps;var i=oi(e,Oe.current);jr(e,t),i=Zf(null,e,r,n,i,t);var o=ed();return e.flags|=1,typeof i=="object"&&i!==null&&typeof i.render=="function"&&i.$$typeof===void 0?(e.tag=1,e.memoizedState=null,e.updateQueue=null,He(r)?(o=!0,Il(e)):o=!1,e.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,qf(e),i.updater=la,e.stateNode=i,i._reactInternals=e,Dc(e,r,n,t),e=bc(null,e,r,!0,o,t)):(e.tag=0,Q&&o&&Jf(e),De(null,e,i,t),e=e.child),e;case 16:r=e.elementType;e:{switch(al(n,e),n=e.pendingProps,i=r._init,r=i(r._payload),e.type=r,i=e.tag=hM(r),n=yt(r,n),i){case 0:e=Ac(null,e,r,n,t);break e;case 1:e=Pp(null,e,r,n,t);break e;case 11:e=zp(null,e,r,n,t);break e;case 14:e=Ip(null,e,r,yt(r.type,n),t);break e}throw Error(E(306,r,""))}return e;case 0:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:yt(r,i),Ac(n,e,r,i,t);case 1:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:yt(r,i),Pp(n,e,r,i,t);case 3:e:{if(f1(e),n===null)throw Error(E(387));r=e.pendingProps,o=e.memoizedState,i=o.element,P0(n,e),Vl(e,r,null,t);var s=e.memoizedState;if(r=s.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:s.cache,pendingSuspenseBoundaries:s.pendingSuspenseBoundaries,transitions:s.transitions},e.updateQueue.baseState=o,e.memoizedState=o,e.flags&256){i=ui(Error(E(423)),e),e=Fp(n,e,r,t,i);break e}else if(r!==i){i=ui(Error(E(424)),e),e=Fp(n,e,r,t,i);break e}else for(Ze=Cn(e.stateNode.containerInfo.firstChild),tt=e,Q=!0,kt=null,t=V0(e,null,r,t),e.child=t;t;)t.flags=t.flags&-3|4096,t=t.sibling;else{if(si(),r===i){e=Zt(n,e,t);break e}De(n,e,r,t)}e=e.child}return e;case 5:return B0(e),n===null&&Ec(e),r=e.type,i=e.pendingProps,o=n!==null?n.memoizedProps:null,s=i.children,vc(r,i)?s=null:o!==null&&vc(r,o)&&(e.flags|=32),c1(n,e),De(n,e,s,t),e.child;case 6:return n===null&&Ec(e),null;case 13:return d1(n,e,t);case 4:return Qf(e,e.stateNode.containerInfo),r=e.pendingProps,n===null?e.child=li(e,null,r,t):De(n,e,r,t),e.child;case 11:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:yt(r,i),zp(n,e,r,i,t);case 7:return De(n,e,e.pendingProps,t),e.child;case 8:return De(n,e,e.pendingProps.children,t),e.child;case 12:return De(n,e,e.pendingProps.children,t),e.child;case 10:e:{if(r=e.type._context,i=e.pendingProps,o=e.memoizedProps,s=i.value,H(Ll,r._currentValue),r._currentValue=s,o!==null)if(Nt(o.value,s)){if(o.children===i.children&&!Ue.current){e=Zt(n,e,t);break e}}else for(o=e.child,o!==null&&(o.return=e);o!==null;){var l=o.dependencies;if(l!==null){s=o.child;for(var a=l.firstContext;a!==null;){if(a.context===r){if(o.tag===1){a=Qt(-1,t&-t),a.tag=2;var u=o.updateQueue;if(u!==null){u=u.shared;var c=u.pending;c===null?a.next=a:(a.next=c.next,c.next=a),u.pending=a}}o.lanes|=t,a=o.alternate,a!==null&&(a.lanes|=t),Oc(o.return,t,e),l.lanes|=t;break}a=a.next}}else if(o.tag===10)s=o.type===e.type?null:o.child;else if(o.tag===18){if(s=o.return,s===null)throw Error(E(341));s.lanes|=t,l=s.alternate,l!==null&&(l.lanes|=t),Oc(s,t,e),s=o.sibling}else s=o.child;if(s!==null)s.return=o;else for(s=o;s!==null;){if(s===e){s=null;break}if(o=s.sibling,o!==null){o.return=s.return,s=o;break}s=s.return}o=s}De(n,e,i.children,t),e=e.child}return e;case 9:return i=e.type,r=e.pendingProps.children,jr(e,t),i=ht(i),r=r(i),e.flags|=1,De(n,e,r,t),e.child;case 14:return r=e.type,i=yt(r,e.pendingProps),i=yt(r.type,i),Ip(n,e,r,i,t);case 15:return a1(n,e,e.type,e.pendingProps,t);case 17:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:yt(r,i),al(n,e),e.tag=1,He(r)?(n=!0,Il(e)):n=!1,jr(e,t),L0(e,r,i),Dc(e,r,i,t),bc(null,e,r,!0,n,t);case 19:return h1(n,e,t);case 22:return u1(n,e,t)}throw Error(E(156,e.tag))};function D1(n,e){return t0(n,e)}function dM(n,e,t,r){this.tag=n,this.key=t,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=e,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ct(n,e,t,r){return new dM(n,e,t,r)}function cd(n){return n=n.prototype,!(!n||!n.isReactComponent)}function hM(n){if(typeof n=="function")return cd(n)?1:0;if(n!=null){if(n=n.$$typeof,n===Df)return 11;if(n===Rf)return 14}return 2}function On(n,e){var t=n.alternate;return t===null?(t=ct(n.tag,e,n.key,n.mode),t.elementType=n.elementType,t.type=n.type,t.stateNode=n.stateNode,t.alternate=n,n.alternate=t):(t.pendingProps=e,t.type=n.type,t.flags=0,t.subtreeFlags=0,t.deletions=null),t.flags=n.flags&14680064,t.childLanes=n.childLanes,t.lanes=n.lanes,t.child=n.child,t.memoizedProps=n.memoizedProps,t.memoizedState=n.memoizedState,t.updateQueue=n.updateQueue,e=n.dependencies,t.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext},t.sibling=n.sibling,t.index=n.index,t.ref=n.ref,t}function fl(n,e,t,r,i,o){var s=2;if(r=n,typeof n=="function")cd(n)&&(s=1);else if(typeof n=="string")s=5;else e:switch(n){case Tr:return or(t.children,i,o,e);case Tf:s=8,i|=8;break;case Zu:return n=ct(12,t,e,i|2),n.elementType=Zu,n.lanes=o,n;case ec:return n=ct(13,t,e,i),n.elementType=ec,n.lanes=o,n;case tc:return n=ct(19,t,e,i),n.elementType=tc,n.lanes=o,n;case $y:return fa(t,i,o,e);default:if(typeof n=="object"&&n!==null)switch(n.$$typeof){case Fy:s=10;break e;case Ly:s=9;break e;case Df:s=11;break e;case Rf:s=14;break e;case on:s=16,r=null;break e}throw Error(E(130,n==null?n:typeof n,""))}return e=ct(s,t,e,i),e.elementType=n,e.type=r,e.lanes=o,e}function or(n,e,t,r){return n=ct(7,n,r,e),n.lanes=t,n}function fa(n,e,t,r){return n=ct(22,n,r,e),n.elementType=$y,n.lanes=t,n.stateNode={isHidden:!1},n}function mu(n,e,t){return n=ct(6,n,null,e),n.lanes=t,n}function gu(n,e,t){return e=ct(4,n.children!==null?n.children:[],n.key,e),e.lanes=t,e.stateNode={containerInfo:n.containerInfo,pendingChildren:null,implementation:n.implementation},e}function pM(n,e,t,r,i){this.tag=e,this.containerInfo=n,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Ya(0),this.expirationTimes=Ya(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ya(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function fd(n,e,t,r,i,o,s,l,a){return n=new pM(n,e,t,l,a),e===1?(e=1,o===!0&&(e|=8)):e=0,o=ct(3,null,null,e),n.current=o,o.stateNode=n,o.memoizedState={element:r,isDehydrated:t,cache:null,transitions:null,pendingSuspenseBoundaries:null},qf(o),n}function mM(n,e,t){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(z1)}catch(n){console.error(n)}}z1(),Ay.exports=rt;var fi=Ay.exports,I1,qp=fi;I1=qp.createRoot,qp.hydrateRoot;const yi=k.createContext(null),kM=k.createContext(null),P1=k.createContext(null),zs=new WeakMap;function vM(n){const e=Object.create(null);e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",i=>{if(typeof i=="function"&&(i=i(n.state)),i)for(const o in i)o=="class"?e.class+=" "+i[o]:o=="style"?e.style=(e.style?e.style+";":"")+i[o]:!e[o]&&o!="contenteditable"&&o!="nodeName"&&(e[o]=String(i[o]))}),e.translate||(e.translate="no");const t=[Se.node(0,n.state.doc.content.size,e)],r=zs.get(n);return!r||r[0].to!==n.state.doc.content.size||!r[0].type.eq(t[0].type)?(zs.set(n,t),t):r}const xM=[],CM={},Uc=_.empty;class fn{constructor(e){this.members=e}map(e,t){const r=this.members.map(i=>i.map(e,t,CM));return fn.from(r)}forChild(e,t){if(t.isLeaf)return _.empty;let r=[];for(let i=0;it instanceof _)?e:e.reduce((t,r)=>t.concat(r instanceof _?r:r.members),[]))}}forEachSet(e){for(let t=0;t0;)e++;n.splice(e,0,t)}const yu=new WeakMap;function MM(n,e){const t=[];n.someProp("decorations",s=>{const l=s(n.state);l&&l!=Uc&&t.push(l)}),e&&t.push(_.create(n.state.doc,[e]));const r=yu.get(n);if(!r){const s=fn.from(t);return yu.set(n,s),s}let i=0,o=!0;if(r.forEachSet(s=>{t[i++]!==s&&(o=!1)}),i!==t.length&&(o=!1),!o){const s=fn.from(t);return yu.set(n,s),s}return r}const md=function(n){for(let e=0;;e++)if(n=n.previousSibling,!n)return e},Yp=function(n){const e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e},EM=function(n,e,t,r){return t&&(Gp(n,e,t,r,-1)||Gp(n,e,t,r,1))},OM=/^(img|br|input|textarea|hr)$/i;function Gp(n,e,t,r,i){for(;;){if(n==t&&e==r)return!0;if(e==(i<0?0:ql(n))){const o=n.parentNode;if(!o||o.nodeType!=1||DM(n)||OM.test(n.nodeName)||n.contentEditable=="false")return!1;e=md(n)+(i<0?0:1),n=o}else if(n.nodeType==1){if(n=n.childNodes[e+(i<0?-1:0)],n.contentEditable=="false")return!1;e=i<0?ql(n):0}else return!1}}function ql(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function TM(n,e,t){for(let r=e==0,i=e==ql(n);r||i;){if(n==t)return!0;const o=md(n);if(n=n.parentNode,!n)return!1;r=r&&o==0,i=i&&o==ql(n)}return!1}function DM(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 L1=function(n){return n.focusNode&&EM(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)},$1=k.createContext(null);function RM(n,e){const t=k.useContext($1);k.useLayoutEffect(()=>t(n),e)}function V1(n,e){const{view:t}=k.useContext(yi);RM(()=>{if(t)return n(t)},e&&[t,...e])}const AM=k.forwardRef(function({widget:e,getPos:t,...r},i){const[o,s]=k.useState(!0),l=k.useRef(null);return k.useImperativeHandle(i,()=>l.current,[]),V1(a=>{if(!a||!l.current)return;a.domObserver.disconnectSelection();const u=a.domSelection(),c=document.createRange(),f=l.current;f.nodeName=="IMG"&&f.parentNode?c.setEnd(f.parentNode,md(f)+1):c.setEnd(f,0),c.collapse(!1),u.removeAllRanges(),u.addRange(c),s(!1),a.domObserver.connectSelection()},[]),o?A.jsx("img",{ref:l,className:"ProseMirror-separator","mark-placeholder":"true",alt:"",...r}):null});function bM(n,e){if(n==e)return!0;for(const t in n)if(n[t]!==e[t])return!1;for(const t in e)if(!(t in n))return!1;return!0}const zM={side:0};class Wo{constructor(e,t){this.Component=e,this.spec=t??zM,this.side=this.spec.side??0}map(e,t,r,i){const{pos:o,deleted:s}=e.mapResult(t.from+i,this.side<0?-1:1);return s?null:new Se(o-r,o-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Wo&&(this.spec.key&&this.spec.key==e.spec.key||this.Component==e.Component&&bM(this.spec,e.spec))}destroy(){}}function B1(n,e,t){return new Se(n,n,new Wo(e,t))}function Su(){return Math.floor(Math.random()*0xffffffffffff).toString(16)}const Uo=new Qo("@nytimes/react-prosemirror/reactKeys");function IM(){let n=!1;return new $t({key:Uo,state:{init(e,t){const r={posToKey:new Map,keyToPos:new Map};return t.doc.descendants((i,o)=>{const s=Su();return r.posToKey.set(o,s),r.keyToPos.set(s,o),!0}),r},apply(e,t,r,i){if(!e.docChanged||n)return t;const o=e.getMeta(Uo),s=(o==null?void 0:o.type)==="bustKey"&&o.payload.key,l={posToKey:new Map,keyToPos:new Map},a=Array.from(t.posToKey.entries()).sort(([u],[c])=>u-c);for(const[u,c]of a){const{pos:f,deleted:d}=e.mapping.mapResult(u);if(d)continue;let p=c;s===c&&(p=Su()),l.posToKey.set(f,p),l.keyToPos.set(p,f)}return i.doc.descendants((u,c)=>{if(l.posToKey.has(c))return!0;const f=Su();return l.posToKey.set(c,f),l.keyToPos.set(f,c),!0}),l}},props:{handleDOMEvents:{compositionstart:()=>{n=!0},compositionend:()=>{n=!1}}}})}function wu(n,e,t={}){var s;if(e===null)return!1;const r=t.from??n.state.selection.from,i=t.to??n.state.selection.to;if(n.someProp("handleTextInput",l=>l(n,r,i,e)))return!0;const{tr:o}=n.state;if(t.marks&&o.ensureMarks(t.marks),o.insertText(e,r,i),t.bust){const l=n.state.doc.resolve(r),a=l.sharedDepth(i),u=l.start(a),c=(s=Uo.getState(n.state))==null?void 0:s.posToKey.get(u-1);o.setMeta(Uo,{type:"bustKey",payload:{key:c}})}return n.dispatch(o),!0}function PM(n){let e=null,t=null;return new $t({props:{handleDOMEvents:{compositionstart(r){var s;const{state:i}=r;r.dispatch(i.tr.deleteSelection());const o=i.selection.$from;return i.selection.empty&&(i.storedMarks||!o.textOffset&&o.parentOffset&&((s=o.nodeBefore)!=null&&s.marks.some(l=>l.type.spec.inclusive===!1)))&&n(B1(i.selection.from,AM,{key:"cursor-wrapper",marks:i.storedMarks??o.marks()})),t=i.storedMarks??o.marks(),r.input.composing=!0,!0},compositionupdate(){return!0},compositionend(r){if(r.input.composing=!1,e!==null)return wu(r,e,{bust:!0,marks:t}),e=null,t=null,n(null),!0},beforeinput(r,i){var o,s;switch(i.preventDefault(),i.inputType){case"insertCompositionText":{if(i.data===null)break;e=i.data;break}case"insertReplacementText":{const l=i.getTargetRanges();(s=(o=i.dataTransfer)==null?void 0:o.items[0])==null||s.getAsString(a=>{for(const u of l){const c=r.posAtDOM(u.startContainer,u.startOffset,1),f=r.posAtDOM(u.endContainer,u.endOffset,1);wu(r,a,{from:c,to:f})}});break}case"insertText":{wu(r,i.data);break}case"deleteWordBackward":case"deleteContentBackward":case"deleteWordForward":case"deleteContentForward":case"deleteContent":{const l=i.getTargetRanges(),{tr:a}=r.state;for(const u of l){const c=r.posAtDOM(u.startContainer,u.startOffset),f=r.posAtDOM(u.endContainer,u.endOffset),{doc:d}=r.state,p=d.resolve(c).marksAcross(d.resolve(f));a.delete(c,f).setStoredMarks(p)}r.dispatch(a);break}}return!0}}}})}const Lt=typeof navigator<"u"?navigator:null,Xp=typeof document<"u"?document:null,Ln=Lt&&Lt.userAgent||"",Hc=/Edge\/(\d+)/.exec(Ln),J1=/MSIE \d/.exec(Ln),jc=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ln),ga=!!(J1||jc||Hc),FM=J1?document.documentMode:jc?+jc[1]:Hc?+Hc[1]:0,_1=!ga&&/gecko\/(\d+)/i.test(Ln),LM=_1&&+(/Firefox\/(\d+)/.exec(Ln)||[0,0])[1],Kc=!ga&&/Chrome\/(\d+)/.exec(Ln),$M=!!Kc,VM=Kc?+Kc[1]:0,W1=!ga&&!!Lt&&/Apple Computer/.test(Lt.vendor),U1=W1&&(/Mobile\/\w+/.test(Ln)||!!Lt&&Lt.maxTouchPoints>2),BM=U1||(Lt?/Mac/.test(Lt.platform):!1),JM=Lt?/Win/.test(Lt.platform):!1,_M=/Android \d/.test(Ln),H1=!!Xp&&"webkitFontSmoothing"in Xp.documentElement.style,WM=H1?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,Ee={ie:ga,ie_version:FM,gecko:_1,gecko_version:LM,chrome:$M,chrome_version:VM,safari:W1,ios:U1,mac:BM,windows:JM,android:_M,webkit:H1,webkit_version:WM};function ku(n){return n.editable&&!n.hasFocus()?!1:UM(n)}function UM(n){var t,r;const 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(((t=e.focusNode)==null?void 0:t.nodeType)==3?(r=e.focusNode)==null?void 0:r.parentNode:e.focusNode))}catch{return!1}}function HM(n,e,t,r){return n.someProp("createSelectionBetween",i=>i(n,e,t))||$.between(e,t,r)}function Zp(n,e=null){const t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let i=n.docView.nearestDesc(t.focusNode);const o=i&&i.size==0;let s=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(s<0)return null;let l=r.resolve(s),a,u;if(L1(t)){for(a=s;i&&!i.node;)i=i.parent;const f=i.node;if(i&&f.isAtom&&z.isSelectable(f)&&i.parent&&!(f.isInline&&TM(t.focusNode,t.focusOffset,i.dom))){const d=i.posBefore;u=new z(s==d?l:r.resolve(d))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let f=s,d=s;for(let p=0;p{(r.anchorNode!=i||r.anchorOffset!=o)&&(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout(()=>{(!j1(e)||e.state.selection.visible)&&e.dom.classList.remove("ProseMirror-hideselection")},20))})}const om=Ee.safari||Ee.chrome&&Ee.chrome_version<63;function Is(n,e=!1){const t=n,r=t.state.selection;if(qM(t,r),!!j1(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&Ee.chrome){const i=t.domSelectionRange(),o=t.domObserver.currentSelection;if(i.anchorNode&&o.anchorNode&&Ql(i.anchorNode,i.anchorOffset,o.anchorNode,o.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)YM(t);else{const{anchor:i,head:o}=r;let s,l;om&&!(r instanceof $)&&(r.$from.parent.inlineContent||(s=rm(t,r.from)),!r.empty&&!r.$from.parent.inlineContent&&(l=rm(t,r.to))),t.docView.setSelection(i,o,t.root,e),om&&(s&&im(s),l&&im(l)),r.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&GM(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}class XM{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 ZM{constructor(e){this.view=e,this.flushingSoon=-1,this.currentSelection=new XM,this.suppressingSelectionUpdates=!1,this.view=e,this.onSelectionChange=this.onSelectionChange.bind(this)}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}stop(){this.disconnectSelection()}start(){this.connectSelection()}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;const t=new Set;let r;for(let o=e.focusNode;o;o=Yp(o))t.add(o);for(let o=e.anchorNode;o;o=Yp(o))if(t.has(o)){r=o;break}const i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:(r==null?void 0:r.nodeType)==3?r==null?void 0:r.parentNode:r}))return this.setCurSelection(),!0}registerMutation(){}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}updateSelection(){const{view:e}=this,t=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);e.input.compositionPendingChanges=0;const r=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,i=Zp(e,r);if(i&&!e.state.selection.eq(i)){const o=e.state.tr.setSelection(i);r=="pointer"?o.setMeta("pointer",!0):r=="key"&&o.scrollIntoView(),t&&o.setMeta("composition",t),e.dispatch(o)}}selectionToDOM(){const{view:e}=this;Is(e);const t=e.domSelectionRange();this.currentSelection.set(t)}flush(){const{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;const t=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(t)&&ku(e)&&!this.ignoreSelectionChange(t);let i=null;r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}onSelectionChange(){if(ku(this.view)&&!this.view.composing){if(this.suppressingSelectionUpdates)return Is(this.view);if(Ee.ie&&Ee.ie_version<=11&&!this.view.state.selection.empty){const e=this.view.domSelectionRange();if(e.focusNode&&Ql(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}}const di=0,sm=1,Ps=2,Ho=3;class is{constructor(e,t,r,i,o){this.parent=e,this.children=t,this.getPos=r,this.dom=i,this.contentDOM=o,this.dirty=di,i.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;tln(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!1;break}if(o.previousSibling)break}if(i==null&&t==e.childNodes.length)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!0;break}if(o.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,i=e;i;i=i.parentNode){const o=this.getDesc(i);let s;if(o&&(!t||o.node))if(r&&(s=o.nodeDOM)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):s==e))r=!1;else return o}}getDesc(e){const t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let i=e;i;i=i.parentNode){const o=this.getDesc(i);if(o)return o.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;te||s instanceof Sd){i=e-o;break}o=l}if(i)return this.children[r].domFromPos(i-this.children[r].border,t);for(let o;r&&!(o=this.children[r-1]).size&&o instanceof gd&&o.side>=0;r--);if(t<=0){let o,s=!0;for(;o=r?this.children[r-1]:null,!(!o||o.dom.parentNode==this.contentDOM);r--,s=!1);return o&&t&&s&&!o.border&&!o.domAtom?o.domFromPos(o.size,t):{node:this.contentDOM,offset:o?ln(o.dom)+1:0}}else{let o,s=!0;for(;o=r=c&&t<=u-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,c);e=s;for(let f=l;f>0;f--){const d=this.children[f-1];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(1)){i=ln(d.dom)+1;break}e-=d.size}i==-1&&(i=0)}if(i>-1&&(u>t||l==this.children.length-1)){t=u;for(let c=l+1;ch&&st){const h=l;l=a,a=h}const p=document.createRange();p.setEnd(a.node,a.offset),p.setStart(l.node,l.offset),u.removeAllRanges(),u.addRange(p)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let r=0,i=0;i=r:er){const l=r+o.border,a=s-o.border;if(e>=l&&t<=a){this.dirty=e==r||t==s?Ps:sm,e==l&&t==a&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=Ho:o.markDirty(e-l,t-l);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?Ps:Ho}r=s}this.dirty=Ps}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){const r=e==1?Ps:sm;t.dirtythis.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){const r=this.children[t];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>x.empty)}return e}matchesNode(e,t,r){return this.dirty==di&&e.eq(this.node)&&nE(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}update(e,t,r,i){return!0}get domAtom(){return this.node.isAtom}}class tE extends yd{constructor(e,t,r,i,o,s,l,a){super(e,t,r,i,o,s,l,null,a,()=>!1,()=>{},()=>{})}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,i){return!0}inParent(){const 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"}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=Ho)}get domAtom(){return!1}}class Sd extends is{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==di&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}function nE(n,e){if(n.length!=e.length)return!1;for(let t=0;t{u=!!a.call(this,s,l)}),u||l.defaultPrevented)return!0}return!1};e[r]=o}return new $t({key:new Qo("@nytimes/react-prosemirror/componentEventListeners"),props:{handleDOMEvents:e}})}function iE(){const[n,e]=k.useState(new Map),t=k.useCallback((o,s)=>{const l=n.get(o)??[];l.unshift(s),n.has(o)||(n.set(o,l),e(new Map(n)))},[n]),r=k.useCallback((o,s)=>{const l=n.get(o);l==null||l.splice(l.indexOf(s),1)},[n]),i=k.useMemo(()=>rE(n),[n]);return{registerEventListener:t,unregisterEventListener:r,componentEventListenersPlugin:i}}function K1(){const[,n]=k.useReducer(e=>e+1,0);return n}function oE(n){const e=Object.create(null);function t(r){for(const i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function sE(n,e){let t=0,r=0;for(const i in n){if(n[i]!=e[i])return!0;t++}for(const i in e)r++;return t!=r}function lE(n,e){for(const t of Object.keys(n))if(n[t]!==e[t])return!0;return!1}function lm(n){return!n.someProp("editable",e=>e(n.state)===!1)}class aE extends Pv{constructor(e,t){super(e,{state:dn.create({schema:t.state.schema,plugins:t.state.plugins}),plugins:t.plugins}),this.shouldUpdatePluginViews=!1,this.shouldUpdatePluginViews=!0,this._props=t,this.oldProps={state:t.state},this.state=t.state,this.domObserver.stop(),this.domObserver=new ZM(this),this.domObserver.start(),this.editable=lm(this),this.docView.dom.replaceChildren(),this.docView=t.docView}get needsRedraw(){if(this.oldProps.state.plugins===this._props.state.plugins&&this._props.plugins===this.oldProps.plugins)return!1;const e=oE(this);return sE(this.nodeViews,e)}pureSetProps(e){this._props={...this._props,...e},this.state=this._props.state,this.editable=lm(this)}runPendingEffects(){if(lE(this.props,this.oldProps)){const e=this.props;this._props=this.oldProps,this.state=this._props.state,this.update(e)}}update(e){super.update(e),this.oldProps=e}updatePluginViews(e){this.shouldUpdatePluginViews&&super.updatePluginViews(e)}destroy(){this.dom=document.createElement("div"),super.destroy()}}const uE=new zm({nodes:{doc:{content:"text*"},text:{inline:!0}}}),cE=dn.create({schema:uE});function fE(n,e){const[t,r]=k.useState(null),[i,o]=k.useState(null),s=K1(),l=e.defaultState??cE,[a,u]=k.useState(l),c=e.state??a,{componentEventListenersPlugin:f,registerEventListener:d,unregisterEventListener:p}=iE(),h=k.useCallback(M=>{fi.flushSync(()=>{o(M)})},[]),m=k.useMemo(()=>[...e.plugins??[],f,PM(h)],[e.plugins,f,h]),w=k.useCallback(function(N){fi.flushSync(()=>{e.state||u(O=>O.apply(N)),e.dispatchTransaction&&e.dispatchTransaction.call(this,N)})},[e.dispatchTransaction,e.state]),g=document.createElement("div"),y=k.useRef(new yd(void 0,[],()=>-1,c.doc,[],_.empty,g,null,g,()=>!1,()=>{},()=>{})),S={...e,state:c,plugins:m,dispatchTransaction:w,docView:y.current};return k.useLayoutEffect(()=>()=>{t==null||t.destroy()},[t]),k.useLayoutEffect(()=>{if(t&&t.dom!==n&&r(null),!!n&&!t){const M=new aE({mount:n},S);r(M),M.dom.addEventListener("compositionend",s);return}}),k.useLayoutEffect(()=>{if(t!=null&&t.needsRedraw){r(null);return}else t==null||t.domObserver.selectionToDOM(),t==null||t.runPendingEffects()}),t==null||t.pureSetProps(S),{editor:k.useMemo(()=>({view:t,registerEventListener:d,unregisterEventListener:p,cursorWrapper:i,docViewDescRef:y}),[t,d,p,i]),state:c}}function dE({children:n}){const e=k.useRef(new Set).current,t=k.useRef(new Set).current,r=k.useRef(!1),i=K1(),o=k.useRef(!0),s=k.useCallback(()=>{o.current||(i(),o.current=!0)},[i]),l=k.useCallback(a=>{let u;const c=()=>{u=a()};return e.add(c),s(),()=>{e.delete(c),u&&(r.current?(t.add(u),s()):u())}},[e,t,s]);return k.useLayoutEffect(()=>(o.current=!1,e.forEach(a=>a()),e.clear(),()=>{t.forEach(a=>a()),t.clear()})),k.useLayoutEffect(()=>(r.current=!0,()=>{r.current=!1}),[]),A.jsx($1.Provider,{value:l,children:n})}const mt=k.createContext({parentRef:{current:void 0},siblingsRef:{current:[]}});function q1(n,e,t,r,i,o,s,l){const{view:a}=k.useContext(yi),[u,c]=k.useState(!0),f=k.useRef(s),d=k.useRef(()=>!1),p=k.useCallback(C=>{d.current=C},[]),h=k.useRef(()=>{!r.current||!n||(r.current.nodeType==1&&r.current.classList.add("ProseMirror-selectednode"),(l!=null&&l.current||!n.type.spec.draggable)&&(((t==null?void 0:t.current)??r.current).draggable=!0))}),m=k.useRef(()=>{!r.current||!n||r.current.nodeType==1&&(r.current.classList.remove("ProseMirror-selectednode"),(l!=null&&l.current||!n.type.spec.draggable)&&((t==null?void 0:t.current)??r.current).removeAttribute("draggable"))}),w=k.useCallback((C,M)=>{h.current=C,m.current=M},[]),{siblingsRef:g,parentRef:y}=k.useContext(mt),S=k.useRef([]);return k.useLayoutEffect(()=>{const C=g.current;return()=>{if(f.current&&C.includes(f.current)){const M=C.indexOf(f.current);C.splice(M,1)}}},[g]),k.useLayoutEffect(()=>{var M;if(!n||!r.current)return;const C=S.current[0];f.current?(f.current.parent=y.current,f.current.children=S.current,f.current.node=n,f.current.getPos=e,f.current.outerDeco=o,f.current.innerDeco=i,f.current.dom=(t==null?void 0:t.current)??r.current,f.current.dom.pmViewDesc=f.current,f.current.contentDOM=(l==null?void 0:l.current)??f.current.contentDOM??(C==null?void 0:C.dom.parentElement)??null,f.current.nodeDOM=r.current):f.current=new yd(y.current,S.current,e,n,o,i,(t==null?void 0:t.current)??r.current,(C==null?void 0:C.dom.parentElement)??null,r.current,N=>!!d.current(N),()=>h.current(),()=>m.current()),c(f.current.contentDOM!==null),g.current.includes(f.current)||g.current.push(f.current),g.current.sort((N,O)=>N.getPos()-O.getPos());for(const N of S.current)if(N.parent=f.current,N instanceof Yl){const O=(M=f.current.contentDOM)==null?void 0:M.firstChild;if(!O)throw new Error("Started a composition but couldn't find the text node it belongs to.");let T=O;for(;T.firstChild;)T=T.firstChild;if(!T||!(T instanceof Text))throw new Error("Started a composition but couldn't find the text node it belongs to.");N.dom=O,N.textDOM=T,N.text=T.data,N.textDOM.pmViewDesc=N,a==null||a.input.compositionNodes.push(N)}return()=>{var N,O,T,b;((N=f.current)==null?void 0:N.children[0])instanceof Yl&&!(a!=null&&a.composing)&&((b=(O=f.current)==null?void 0:O.children[0].dom.parentNode)==null||b.removeChild((T=f.current)==null?void 0:T.children[0].dom))}}),{hasContentDOM:u,childDescriptors:S,nodeViewDescRef:f,setStopEvent:p,setSelectNode:w}}function hE(n,e){return n.type.side-e.type.side}function pE(n,e,t,r){const i=e.locals(n);let o=0;if(i.length==0){for(let u=0;uo;)l.push(i[s++]);let d=o+c.nodeSize;if(c.isText){let h=d;s!h.inline):l.slice();r(c,p,e.forChild(o,c),o,f),o=d}}function ya(){const{view:n}=k.useContext(yi);return n&&Uo.getState(n.state)}var Q1={exports:{}};/*! Copyright (c) 2018 Jed Watson. Licensed under the MIT License (MIT), see http://jedwatson.github.io/classnames -*/(function(n){(function(){var e={}.hasOwnProperty;function t(){for(var r=[],i=0;i{var t;return((t=e[1])==null?void 0:t.toUpperCase())??""})}function SE(n){const e=new CSSStyleSheet;e.insertRule(`* { ${n} }`);const r=e.cssRules[0].style,i={};for(let o=0;o0&&(e.step=r);break}case"disabled":{e.disabled=r!=null;break}case"rows":{const i=parseInt(r,10);Number.isNaN(i)||(e.rows=r);break}default:{e[t]=r;break}}return e}const wd=k.memo(k.forwardRef(function({outputSpec:e,children:t,...r},i){if(typeof e=="string")return R.jsx(R.Fragment,{children:e});if(!Array.isArray(e))throw new Error("@nytimes/react-prosemirror only supports strings and arrays in toDOM");const s=e[0].replace(" ",":"),l=e[1];let a={ref:i,...r},u=1;l&&typeof l=="object"&&l.nodeType==null&&!Array.isArray(l)&&(u=2,a=Y1(G1(l),a));const c=[];for(let f=u;fu)throw new RangeError("Content hole must be the only child of its parent node");return k.createElement(s,a,t)}c.push(R.jsx(wd,{outputSpec:d,children:t}))}return k.createElement(s,a,...c)})),X1=k.memo(k.forwardRef(function({mark:e,getPos:t,children:r},i){const{siblingsRef:o,parentRef:s}=k.useContext(mt),l=k.useRef(void 0),a=k.useRef([]),u=k.useRef(null);k.useImperativeHandle(i,()=>u.current,[]);const c=k.useMemo(()=>{var d,p;return(p=(d=e.type.spec).toDOM)==null?void 0:p.call(d,e,!0)},[e]);if(!c)throw new Error(`Mark spec for ${e.type.name} is missing toDOM`);k.useLayoutEffect(()=>{const d=o.current;return()=>{if(l.current&&d.includes(l.current)){const p=d.indexOf(l.current);d.splice(p,1)}}},[o]),k.useLayoutEffect(()=>{if(!u.current)return;const d=a.current[0];l.current?(l.current.parent=s.current,l.current.dom=u.current,l.current.contentDOM=(d==null?void 0:d.dom.parentElement)??u.current,l.current.mark=e,l.current.getPos=()=>t.current()):l.current=new eE(s.current,a.current,()=>t.current(),e,u.current,(d==null?void 0:d.dom.parentElement)??u.current),o.current.includes(l.current)||o.current.push(l.current),o.current.sort((p,h)=>p.getPos()-h.getPos());for(const p of a.current)p.parent=l.current});const f=k.useMemo(()=>({parentRef:l,siblingsRef:a}),[a,l]);return R.jsx(wd,{ref:u,outputSpec:c,children:R.jsx(mt.Provider,{value:f,children:r})})}));function wE({widget:n,getPos:e}){const{siblingsRef:t,parentRef:r}=k.useContext(mt),i=k.useRef(null),o=k.useRef(null);return k.useLayoutEffect(()=>{const s=t.current;return()=>{if(i.current&&s.includes(i.current)){const l=s.indexOf(i.current);s.splice(l,1)}}},[t]),V1(s=>{if(!o.current)return;const l=n.type.toDOM;let a=typeof l=="function"?l(s,()=>e.current()):l;if(!n.type.spec.raw){if(a.nodeType!=1){const u=document.createElement("span");u.appendChild(a),a=u}a.contentEditable="false",a.classList.add("ProseMirror-widget")}o.current.firstElementChild!==a&&o.current.replaceChildren(a)}),k.useLayoutEffect(()=>{o.current&&(i.current?(i.current.parent=r.current,i.current.widget=n,i.current.getPos=()=>e.current(),i.current.dom=o.current):i.current=new gd(r.current,()=>e.current(),n,o.current),t.current.includes(i.current)||t.current.push(i.current),t.current.sort((s,l)=>s.getPos()-l.getPos()))}),R.jsx("span",{ref:o})}const kE=k.createContext(null),Z1=k.memo(function({outerDeco:e,getPos:t,node:r,innerDeco:i,...o}){const s=k.useRef(null),l=k.useRef(null),a=k.useRef(null),u=k.useRef(()=>t.current()).current,c=k.useRef(r),f=k.useRef(e),d=k.useRef(i),p=k.useRef(null),h=k.useRef(null),{nodeViews:m}=k.useContext(P1),{view:w}=k.useContext(yi);let g=null;const y=m[r.type.name],S=k.useMemo(()=>{var H,De;return(De=(H=r.type.spec).toDOM)==null?void 0:De.call(H,r)},[r]),C=w==null?void 0:w.someProp("nodeViews",H=>H==null?void 0:H[r.type.name]);k.useLayoutEffect(()=>{if(!h.current||!p.current)return;const{dom:H}=h.current;return l.current=p.current,p.current.appendChild(H),()=>{var De,Vn;(Vn=(De=h.current)==null?void 0:De.destroy)==null||Vn.call(De)}},[]),k.useLayoutEffect(()=>{if(!C||!h.current)return;const{destroy:H,update:De}=h.current;if(((De==null?void 0:De.call(h.current,r,e,i))??!0)||(H==null||H.call(h.current),!p.current))return;c.current=r,f.current=e,d.current=i,h.current=C(c.current,w,()=>t.current(),f.current,d.current);const{dom:Si}=h.current;l.current=p.current,p.current.appendChild(Si)},[C,w,i,r,e,t]);const{hasContentDOM:N,childDescriptors:E,setStopEvent:O,nodeViewDescRef:T}=q1(r,()=>t.current(),s,l,i,e,void 0,a),b={...o,...!N&&{contentEditable:!1}},I=k.useMemo(()=>({node:r,getPos:u,decorations:e,innerDecorations:i,isSelected:!1}),[u,i,r,e]);if(y)g=R.jsx(y,{...b,ref:l,nodeProps:I,children:R.jsx(go,{getPos:t,node:r,innerDecorations:i})});else if(C){h.current||(h.current=C(c.current,w,()=>t.current(),f.current,d.current));const{contentDOM:H}=h.current;a.current=H??null,g=k.createElement(r.isInline?"span":"div",{ref:p,contentEditable:!!H,suppressContentEditableWarning:!0},H&&fi.createPortal(R.jsx(go,{getPos:t,node:r,innerDecorations:i}),H))}else S&&(g=R.jsx(wd,{...b,ref:l,outputSpec:S,children:R.jsx(go,{getPos:t,node:r,innerDecorations:i})}));if(!g)throw new Error(`Node spec for ${r.type.name} is missing toDOM`);const ae=k.cloneElement(e.reduce(kd,g),e.some(H=>H.type.attrs.nodeName)?{ref:s}:void 0),Vt=r.marks.reduce((H,De)=>R.jsx(X1,{getPos:t,mark:De,children:H}),ae),$n=k.useMemo(()=>({parentRef:T,siblingsRef:E}),[E,T]);return R.jsx(kE.Provider,{value:O,children:R.jsx(mt.Provider,{value:$n,children:k.cloneElement(Vt,r.marks.length||e.some(H=>H.type.attrs.nodeName)?{ref:s}:void 0)})})});function vE({getPos:n}){const{siblingsRef:e,parentRef:t}=k.useContext(mt),r=k.useRef(null),i=k.useRef(null),[o,s]=k.useState(!1);return k.useLayoutEffect(()=>{const l=e.current;return()=>{if(r.current&&l.includes(r.current)){const a=l.indexOf(r.current);l.splice(a,1)}}},[e]),k.useLayoutEffect(()=>{var a;const l=e.current[e.current.length-1];if((Me.safari||Me.chrome)&&((a=l==null?void 0:l.dom)==null?void 0:a.contentEditable)=="false"){s(!0);return}i.current&&(r.current?(r.current.parent=t.current,r.current.dom=i.current,r.current.getPos=()=>n.current()):r.current=new Sd(t.current,[],()=>n.current(),i.current,null),e.current.includes(r.current)||e.current.push(r.current),e.current.sort((u,c)=>u.getPos()-c.getPos()))}),o?R.jsx("img",{ref:i,className:"ProseMirror-separator"}):null}function xE(n,e){if(n===e)return!0;if(!n||!e)return!1;const t=Object.keys(n),r=Object.keys(e),i=t.length;if(r.length!==i)return!1;for(let o=0;oo.current(),document.createElement("div"),document.createTextNode(s.text??""),s.text??"");return}let a=l;for(;a.firstChild;)a=a.firstChild;!this.viewDescRef||this.viewDescRef instanceof Yl?this.viewDescRef=new tE(void 0,[],()=>o.current(),s,t,_.empty,l,a):(this.viewDescRef.parent=i.current,this.viewDescRef.children=[],this.viewDescRef.node=s,this.viewDescRef.getPos=()=>o.current(),this.viewDescRef.outerDeco=t,this.viewDescRef.innerDeco=_.empty,this.viewDescRef.dom=l,this.viewDescRef.dom.pmViewDesc=this.viewDescRef,this.viewDescRef.nodeDOM=a),r.current.includes(this.viewDescRef)||r.current.push(this.viewDescRef),r.current.sort((u,c)=>u.getPos()-c.getPos())}shouldComponentUpdate(e){return!xE(this.props,e)}componentDidMount(){this.updateEffect()}componentDidUpdate(){this.updateEffect()}componentWillUnmount(){const{siblingsRef:e}=this.props;if(this.viewDescRef&&e.current.includes(this.viewDescRef)){const t=e.current.indexOf(this.viewDescRef);e.current.splice(t,1)}}render(){const{view:e,getPos:t,node:r,decorations:i}=this.props;return e!=null&&e.composing&&e.state.selection.from>=t.current()&&e.state.selection.from<=t.current()+r.nodeSize?this.renderRef:(this.renderRef=i.reduce(kd,r.text),this.renderRef)}}function NE({getPos:n}){const{siblingsRef:e,parentRef:t}=k.useContext(mt),r=k.useRef(null),i=k.useRef(null);return k.useLayoutEffect(()=>{const o=e.current;return()=>{if(r.current&&o.includes(r.current)){const s=o.indexOf(r.current);o.splice(s,1)}}},[e]),k.useLayoutEffect(()=>{i.current&&(r.current?(r.current.parent=t.current,r.current.dom=i.current,r.current.getPos=()=>n.current()):r.current=new Sd(t.current,[],()=>n.current(),i.current,null),e.current.includes(r.current)||e.current.push(r.current),e.current.sort((o,s)=>o.getPos()-s.getPos()))}),R.jsx("br",{ref:i,className:"ProseMirror-trailingBreak"})}function ME({widget:n,getPos:e}){const{siblingsRef:t,parentRef:r}=k.useContext(mt),i=k.useRef(null),o=k.useRef(()=>e.current()).current,s=k.useRef(null);k.useLayoutEffect(()=>{const a=t.current;return()=>{if(i.current&&a.includes(i.current)){const u=a.indexOf(i.current);a.splice(u,1)}}},[t]),k.useLayoutEffect(()=>{s.current&&(i.current?(i.current.parent=r.current,i.current.widget=n,i.current.getPos=()=>e.current(),i.current.dom=s.current):i.current=new gd(r.current,()=>e.current(),n,s.current),t.current.includes(i.current)||t.current.push(i.current),t.current.sort((a,u)=>a.getPos()-u.getPos()))});const{Component:l}=n.type;return l&&R.jsx(l,{ref:s,widget:n,getPos:o,contentEditable:!1})}function kd(n,e){const{nodeName:t,...r}=e.type.attrs,i=G1(r);return t||typeof n=="string"?k.createElement(t??"span",i,n):k.cloneElement(n,Y1(n.props,i))}const EE=k.memo(function({child:e,getInnerPos:t}){const{view:r}=k.useContext(yi),i=k.useRef(()=>t.current()+e.offset);i.current=()=>t.current()+e.offset;const o=ya(),s=Dn(t.current(),e,o==null?void 0:o.posToKey);return e.type==="widget"?R.jsx(ME,{widget:e.widget,getPos:i},s):e.type==="native-widget"?R.jsx(wE,{widget:e.widget,getPos:i},s):e.node.isText?R.jsx(mt.Consumer,{children:({siblingsRef:l,parentRef:a})=>R.jsx(CE,{view:r,node:e.node,getPos:i,siblingsRef:l,parentRef:a,decorations:e.outerDeco})},s):R.jsx(Z1,{node:e.node,getPos:i,outerDeco:e.outerDeco,innerDeco:e.innerDeco},s)}),OE=k.memo(function({childViews:e,getInnerPos:t}){const r=ya(),i=e[0],o=k.useRef(()=>t.current()+i.offset);o.current=()=>t.current()+i.offset;const s=i.marks[0];return s?R.jsx(X1,{getPos:o,mark:s,children:R.jsx(vd,{getInnerPos:t,childViews:e.map(l=>({...l,marks:l.marks.slice(1)}))},Dn(t.current(),i,r==null?void 0:r.posToKey))},Dn(t.current(),i,r==null?void 0:r.posToKey)):R.jsx(R.Fragment,{children:e.map(l=>{const a=Dn(t.current(),l,r==null?void 0:r.posToKey);return R.jsx(EE,{child:l,getInnerPos:t},a)})})}),vd=k.memo(function({getInnerPos:e,childViews:t}){const r=ya(),i=t.reduce((o,s)=>{var u;const l=o[o.length-1];if(!l)return[[s]];const a=l[l.length-1];return a?!s.marks.length&&!a.marks.length||s.marks.length&&a.marks.length&&((u=s.marks[0])!=null&&u.eq(a.marks[0]))?[...o.slice(0,o.length-1),[...l.slice(0,l.length),s]]:[...o,[s]]:[...o.slice(0,o.length),[s]]},[]);return R.jsx(R.Fragment,{children:i.map(o=>{const s=o[0];if(!s)return null;const l=Dn(e.current(),s,r==null?void 0:r.posToKey);return R.jsx(OE,{childViews:o,getInnerPos:e},l)})})});function Dn(n,e,t){const r=n+e.offset,i=t==null?void 0:t.get(r);return e.type==="widget"||e.type==="native-widget"?e.widget.type.spec.key?e.widget.type.spec.key:(console.warn(`Widget at position ${r} doesn't have a key specified. This has negative performance implications.`),`${i}-${e.index}`):i||r}function DE(n){const e=n[n.length-1];if((e==null?void 0:e.type)!=="widget"&&(e==null?void 0:e.type)!=="native-widget"||e.widget.type.side>=0)return;let t=null;for(let i=n.length-2;i>=0;i--){const o=n[i];if((o==null?void 0:o.type)==="node"){t=o;break}}if(!t||!t.node.isInline)return;const r=t.marks;e.marks=e.marks.reduce((i,o)=>o.addToSet(i),r)}function TE(n){const e=n[n.length-1];if((e==null?void 0:e.type)!=="node"||!e.node.isInline)return;const t=e.marks;for(let r=n.length-2;r>=0;r--){const i=n[r];if((i==null?void 0:i.type)!=="widget"&&(i==null?void 0:i.type)!=="native-widget"||i.widget.type.side<0)break;i.marks=i.marks.reduce((o,s)=>s.addToSet(o),t)}}const RE=k.memo(function({child:e,getInnerPos:t,posToKey:r}){const i=k.useRef(()=>t.current()+e.offset);i.current=()=>t.current()+e.offset;const o=Dn(t.current(),e,r);return e.type==="node"?R.jsx(Z1,{outerDeco:e.outerDeco,node:e.node,innerDeco:e.innerDeco,getPos:i},o):R.jsx(vd,{childViews:[e],getInnerPos:t},o)},(n,e)=>{var t,r,i;return n.child.type===e.child.type&&n.child.marks.every(o=>o.isInSet(e.child.marks))&&e.child.marks.every(o=>o.isInSet(n.child.marks))&&n.child.offset===e.child.offset&&(n.child.type==="node"?((t=n.child.outerDeco)==null?void 0:t.length)===((r=e.child.outerDeco)==null?void 0:r.length)&&((i=n.child.outerDeco)==null?void 0:i.every(o=>{var s;return(s=e.child.outerDeco)==null?void 0:s.some(l=>o.from===l.from&&o.to&&l.to&&o.type.eq(l.type))}))&&n.child.innerDeco.eq(e.child.innerDeco):!0)&&n.child.node===e.child.node&&n.child.widget===e.child.widget});function AE(n,e,t){return n.length?n.every(r=>r.type!=="node"||r.node.isInline)?[R.jsx(vd,{childViews:n,getInnerPos:e},Dn(e.current(),n[0],t))]:n.map(r=>{const i=Dn(e.current(),r,t);return R.jsx(RE,{child:r,posToKey:t,getInnerPos:e},i)}):[]}const go=k.memo(function({getPos:e,node:t,innerDecorations:r}){const i=ya(),o=k.useRef(()=>e.current()+1);if(!t)return null;const s=[];pE(t,r,(u,c,f,d)=>{const p=u.type.spec.marks??[];c?s.push({type:"native-widget",widget:u,marks:p,offset:f,index:d}):s.push({type:"widget",widget:u,marks:p,offset:f,index:d}),DE(s)},(u,c,f,d)=>{s.push({type:"node",node:u,marks:u.marks,innerDeco:f,outerDeco:c,offset:d}),TE(s)});const l=AE(s,o,i==null?void 0:i.posToKey),a=s[s.length-1];return(!a||a.type!=="node"||a.node.isInline&&!a.node.isText||/\n$/.test(a.node.text))&&l.push(R.jsx(vE,{getPos:o},"trailing-hack-img"),R.jsx(NE,{getPos:o},"trailing-hack-br")),R.jsx(R.Fragment,{children:l})}),xu={current(){return-1}},bE=k.memo(k.forwardRef(function({className:e,node:t,innerDeco:r,outerDeco:i,as:o,viewDesc:s,...l},a){const u=k.useRef(null);k.useImperativeHandle(a,()=>u.current,[]);const{childDescriptors:c,nodeViewDescRef:f}=q1(t,()=>xu.current(),u,u,r,i,s),d=k.useMemo(()=>({parentRef:f,siblingsRef:c}),[c,f]),p={...l,ref:u,className:e,suppressContentEditableWarning:!0},h=o?k.cloneElement(o,p,R.jsx(mt.Provider,{value:d,children:R.jsx(go,{getPos:xu,node:t,innerDecorations:r})})):k.createElement("div",p,R.jsx(mt.Provider,{value:d,children:R.jsx(go,{getPos:xu,node:t,innerDecorations:r})}));if(!t)return h;const m=i.filter(g=>!g.inline);return m.length?m.reduce(kd,h):h})),eS=k.createContext(null);function zE({as:n,...e},t){const r=k.useRef([]),i=k.useRef(null),{setMount:o,...s}=k.useContext(eS),l=k.useRef(void 0);k.useImperativeHandle(t,()=>i.current,[]);const a=k.useMemo(()=>({parentRef:l,siblingsRef:r}),[r,l]);return R.jsx(mt.Provider,{value:a,children:R.jsx(bE,{ref:u=>{i.current=u,o(u)},...e,...s,as:n})})}const IE=k.forwardRef(zE),PE=[];function FE({className:n,children:e,nodeViews:t={},customNodeViews:r,...i}){var p;const[o,s]=k.useState(null),{editor:l,state:a}=fE(o,{...i,nodeViews:r}),u=l.view?MM(l.view,l.cursorWrapper):_.empty,c=l.view?vM(l.view):PE,f=k.useMemo(()=>({nodeViews:t}),[t]),d=k.useMemo(()=>{var h;return{className:n,setMount:s,node:(h=l.view)==null?void 0:h.state.doc,innerDeco:u,outerDeco:c,viewDesc:l.docViewDescRef.current}},[n,l.docViewDescRef,(p=l.view)==null?void 0:p.state.doc,u,c]);return R.jsx(yi.Provider,{value:l,children:R.jsx(kM.Provider,{value:a,children:R.jsx(P1.Provider,{value:f,children:R.jsx(eS.Provider,{value:d,children:e})})})})}function LE(n){return R.jsx(dE,{children:R.jsx(FE,{...n})})}const J=new zm({nodes:{doc:{content:"block+"},paragraph:{group:"block",content:"inline*",toDOM(){return["p",0]}},...Vx({cellContent:"inline*",cellAttributes:{},tableGroup:"block"}),footnote:{group:"inline",content:"text*",inline:!0,atom:!0,attrs:{number:{default:0}}},list:{group:"block",content:"list_item+",toDOM(){return["ul",0]}},list_item:{content:"paragraph+",toDOM(){return["li",0]}},image:{group:"block",toDOM(){return["div",["img",{src:"https://smoores.gitlab.io/storyteller/img/Storyteller_Logo.png",height:150,width:150}]]}},text:{group:"inline"}},marks:{em:{toDOM(){return["em",0]}},strong:{toDOM(){return["strong",0]}}}}),$E=dn.create({schema:J,doc:J.nodes.doc.create({},[J.nodes.paragraph.create({},[J.text("This ",[J.marks.em.create()]),J.text("is",[J.marks.em.create(),J.marks.strong.create()]),J.text(" the first paragraph")]),J.nodes.paragraph.create({},[J.text("This is the second paragraph"),J.nodes.footnote.create({number:1},J.text("Footnote"))]),J.nodes.paragraph.create(),J.nodes.image.create(),J.nodes.image.create(),J.nodes.paragraph.create({},J.text("This is the third paragraph 🫵")),J.nodes.table.create({},[J.nodes.table_row.create({},[J.nodes.table_header.create({},J.text("h1")),J.nodes.table_header.create({},J.text("h2"))]),J.nodes.table_row.create({},[J.nodes.table_cell.create({},J.text("c1")),J.nodes.table_cell.create({},J.text("c2"))])])]),plugins:[IM(),rx({rules:[ix(/^\s*([-+*])\s$/,J.nodes.list)]}),iC(),gC()]}),VE=k.forwardRef(function({children:e,nodeProps:t,...r},i){return R.jsx("p",{ref:i,...r,children:e})}),BE=k.forwardRef(function({children:e,nodeProps:t,...r},i){return R.jsx("ul",{ref:i,...r,children:e})}),JE=k.forwardRef(function({children:e,nodeProps:t,...r},i){return R.jsx("li",{ref:i,...r,children:e})}),_E=k.forwardRef(function({nodeProps:e,...t},r){return R.jsx("span",{ref:r,...t,suppressContentEditableWarning:!0,contentEditable:"false",children:R.jsx("button",{children:e.node.attrs.number})})}),WE=k.forwardRef(function({widget:e,getPos:t,...r},i){return R.jsx("span",{...r,ref:i,style:{display:"block",backgroundColor:"blue",width:"4px",height:"4px",position:"absolute",transform:"translateX(-2px)"},children:"Widget"})}),UE=new $t({view(n){const e=n.coordsAtPos(n.state.selection.from),t=document.createElement("div");return t.style.width="4px",t.style.height="4px",t.style.position="absolute",t.style.top=`${e.top-2}px`,t.style.left=`${e.left-2}px`,t.style.backgroundColor="blue",document.body.appendChild(t),{update(r){const i=r.coordsAtPos(r.state.selection.from);t.style.top=`${i.top-2}px`,t.style.left=`${i.left-2}px`},destroy(){document.body.removeChild(t)}}}});new $t({props:{decorations(n){return _.create(n.doc,[B1(n.selection.from,WE,{side:0,key:"widget-plugin-widget"})])}},view(n){const e=n.coordsAtPos(n.state.selection.from),t=document.createElement("div");return t.style.width="4px",t.style.height="4px",t.style.position="absolute",t.style.top=`${e.top-2}px`,t.style.left=`${e.left-2}px`,t.style.backgroundColor="blue",document.body.appendChild(t),{update(r){const i=r.coordsAtPos(r.state.selection.from);t.style.top=`${i.top-2}px`,t.style.left=`${i.left-2}px`},destroy(){document.body.removeChild(t)}}}});const HE=[ax({...Uw,"Mod-i":Hd(J.marks.em),"Mod-b":Hd(J.marks.strong)}),UE,Bv()],jE={paragraph:()=>{const n=document.createElement("p");return{dom:n,contentDOM:n}}};function KE(){const[n,e]=k.useState($E),[t,r]=k.useState(!0),i=k.useMemo(()=>t?{paragraph:VE,list:BE,list_item:JE,footnote:_E}:void 0,[t]),o=k.useCallback(function(s){e(l=>l.apply(s))},[]);return R.jsxs("main",{children:[R.jsx("h1",{children:"React ProseMirror Demo"}),R.jsxs("button",{onClick:()=>{t?r(s=>!s):window.location.reload()},children:["Switch to"," ",t?"ProseMirror node views":"React node views (requires reload)"]}),R.jsx(LE,{className:"ProseMirror",state:n,dispatchTransaction:o,plugins:HE,nodeViews:i,customNodeViews:t?void 0:jE,children:R.jsx(IE,{})},`${t}`)]})}const qE=I1(document.getElementById("root"));qE.render(R.jsx(k.StrictMode,{children:R.jsx(KE,{})})); +*/(function(n){(function(){var e={}.hasOwnProperty;function t(){for(var r=[],i=0;i{var t;return((t=e[1])==null?void 0:t.toUpperCase())??""})}function SE(n){const e=new CSSStyleSheet;e.insertRule(`* { ${n} }`);const r=e.cssRules[0].style,i={};for(let o=0;o0&&(e.step=r);break}case"disabled":{e.disabled=r!=null;break}case"rows":{const i=parseInt(r,10);Number.isNaN(i)||(e.rows=r);break}default:{e[t]=r;break}}return e}const wd=k.memo(k.forwardRef(function({outputSpec:e,children:t,...r},i){if(typeof e=="string")return A.jsx(A.Fragment,{children:e});if(!Array.isArray(e))throw new Error("@nytimes/react-prosemirror only supports strings and arrays in toDOM");const s=e[0].replace(" ",":"),l=e[1];let a={ref:i,...r},u=1;l&&typeof l=="object"&&l.nodeType==null&&!Array.isArray(l)&&(u=2,a=Y1(G1(l),a));const c=[];for(let f=u;fu)throw new RangeError("Content hole must be the only child of its parent node");return k.createElement(s,a,t)}c.push(A.jsx(wd,{outputSpec:d,children:t}))}return k.createElement(s,a,...c)})),X1=k.memo(k.forwardRef(function({mark:e,getPos:t,children:r},i){const{siblingsRef:o,parentRef:s}=k.useContext(mt),l=k.useRef(void 0),a=k.useRef([]),u=k.useRef(null);k.useImperativeHandle(i,()=>u.current,[]);const c=k.useMemo(()=>{var d,p;return(p=(d=e.type.spec).toDOM)==null?void 0:p.call(d,e,!0)},[e]);if(!c)throw new Error(`Mark spec for ${e.type.name} is missing toDOM`);k.useLayoutEffect(()=>{const d=o.current;return()=>{if(l.current&&d.includes(l.current)){const p=d.indexOf(l.current);d.splice(p,1)}}},[o]),k.useLayoutEffect(()=>{if(!u.current)return;const d=a.current[0];l.current?(l.current.parent=s.current,l.current.dom=u.current,l.current.contentDOM=(d==null?void 0:d.dom.parentElement)??u.current,l.current.mark=e,l.current.getPos=()=>t.current()):l.current=new eE(s.current,a.current,()=>t.current(),e,u.current,(d==null?void 0:d.dom.parentElement)??u.current),o.current.includes(l.current)||o.current.push(l.current),o.current.sort((p,h)=>p.getPos()-h.getPos());for(const p of a.current)p.parent=l.current});const f=k.useMemo(()=>({parentRef:l,siblingsRef:a}),[a,l]);return A.jsx(wd,{ref:u,outputSpec:c,children:A.jsx(mt.Provider,{value:f,children:r})})}));function wE({widget:n,getPos:e}){const{siblingsRef:t,parentRef:r}=k.useContext(mt),i=k.useRef(null),o=k.useRef(null);return k.useLayoutEffect(()=>{const s=t.current;return()=>{if(i.current&&s.includes(i.current)){const l=s.indexOf(i.current);s.splice(l,1)}}},[t]),V1(s=>{if(!o.current)return;const l=n.type.toDOM;let a=typeof l=="function"?l(s,()=>e.current()):l;if(!n.type.spec.raw){if(a.nodeType!=1){const u=document.createElement("span");u.appendChild(a),a=u}a.contentEditable="false",a.classList.add("ProseMirror-widget")}o.current.firstElementChild!==a&&o.current.replaceChildren(a)}),k.useLayoutEffect(()=>{o.current&&(i.current?(i.current.parent=r.current,i.current.widget=n,i.current.getPos=()=>e.current(),i.current.dom=o.current):i.current=new gd(r.current,()=>e.current(),n,o.current),t.current.includes(i.current)||t.current.push(i.current),t.current.sort((s,l)=>s.getPos()-l.getPos()))}),A.jsx("span",{ref:o})}const kE=k.createContext(null),vE=k.createContext(null),Z1=k.memo(function({outerDeco:e,getPos:t,node:r,innerDeco:i,...o}){const s=k.useRef(null),l=k.useRef(null),a=k.useRef(null),u=k.useRef(()=>t.current()).current,c=k.useRef(r),f=k.useRef(e),d=k.useRef(i),p=k.useRef(null),h=k.useRef(null),{nodeViews:m}=k.useContext(P1),{view:w}=k.useContext(yi);let g=null;const y=m[r.type.name],S=k.useMemo(()=>{var j,he;return(he=(j=r.type.spec).toDOM)==null?void 0:he.call(j,r)},[r]),C=w==null?void 0:w.someProp("nodeViews",j=>j==null?void 0:j[r.type.name]);k.useLayoutEffect(()=>{if(!h.current||!p.current)return;const{dom:j}=h.current;return l.current=p.current,p.current.appendChild(j),()=>{var he,Vn;(Vn=(he=h.current)==null?void 0:he.destroy)==null||Vn.call(he)}},[]),k.useLayoutEffect(()=>{if(!C||!h.current)return;const{destroy:j,update:he}=h.current;if(((he==null?void 0:he.call(h.current,r,e,i))??!0)||(j==null||j.call(h.current),!p.current))return;c.current=r,f.current=e,d.current=i,h.current=C(c.current,w,()=>t.current(),f.current,d.current);const{dom:D}=h.current;l.current=p.current,p.current.appendChild(D)},[C,w,i,r,e,t]);const{hasContentDOM:M,childDescriptors:N,setStopEvent:O,setSelectNode:T,nodeViewDescRef:b}=q1(r,()=>t.current(),s,l,i,e,void 0,a),I={...o,...!M&&{contentEditable:!1}},ae=k.useMemo(()=>({node:r,getPos:u,decorations:e,innerDecorations:i}),[u,i,r,e]);if(y)g=A.jsx(y,{...I,ref:l,nodeProps:ae,children:A.jsx(mo,{getPos:t,node:r,innerDecorations:i})});else if(C){h.current||(h.current=C(c.current,w,()=>t.current(),f.current,d.current));const{contentDOM:j}=h.current;a.current=j??null,g=k.createElement(r.isInline?"span":"div",{ref:p,contentEditable:!!j,suppressContentEditableWarning:!0},j&&fi.createPortal(A.jsx(mo,{getPos:t,node:r,innerDecorations:i}),j))}else S&&(g=A.jsx(wd,{...I,ref:l,outputSpec:S,children:A.jsx(mo,{getPos:t,node:r,innerDecorations:i})}));if(!g)throw new Error(`Node spec for ${r.type.name} is missing toDOM`);const Vt=k.cloneElement(e.reduce(kd,g),e.some(j=>j.type.attrs.nodeName)?{ref:s}:void 0),$n=r.marks.reduce((j,he)=>A.jsx(X1,{getPos:t,mark:he,children:j}),Vt),ss=k.useMemo(()=>({parentRef:b,siblingsRef:N}),[N,b]);return A.jsx(kE.Provider,{value:T,children:A.jsx(vE.Provider,{value:O,children:A.jsx(mt.Provider,{value:ss,children:k.cloneElement($n,r.marks.length||e.some(j=>j.type.attrs.nodeName)?{ref:s}:void 0)})})})});function xE({getPos:n}){const{siblingsRef:e,parentRef:t}=k.useContext(mt),r=k.useRef(null),i=k.useRef(null),[o,s]=k.useState(!1);return k.useLayoutEffect(()=>{const l=e.current;return()=>{if(r.current&&l.includes(r.current)){const a=l.indexOf(r.current);l.splice(a,1)}}},[e]),k.useLayoutEffect(()=>{var a;const l=e.current[e.current.length-1];if((Ee.safari||Ee.chrome)&&((a=l==null?void 0:l.dom)==null?void 0:a.contentEditable)=="false"){s(!0);return}i.current&&(r.current?(r.current.parent=t.current,r.current.dom=i.current,r.current.getPos=()=>n.current()):r.current=new Sd(t.current,[],()=>n.current(),i.current,null),e.current.includes(r.current)||e.current.push(r.current),e.current.sort((u,c)=>u.getPos()-c.getPos()))}),o?A.jsx("img",{ref:i,className:"ProseMirror-separator"}):null}function CE(n,e){if(n===e)return!0;if(!n||!e)return!1;const t=Object.keys(n),r=Object.keys(e),i=t.length;if(r.length!==i)return!1;for(let o=0;oo.current(),document.createElement("div"),document.createTextNode(s.text??""),s.text??"");return}let a=l;for(;a.firstChild;)a=a.firstChild;!this.viewDescRef||this.viewDescRef instanceof Yl?this.viewDescRef=new tE(void 0,[],()=>o.current(),s,t,_.empty,l,a):(this.viewDescRef.parent=i.current,this.viewDescRef.children=[],this.viewDescRef.node=s,this.viewDescRef.getPos=()=>o.current(),this.viewDescRef.outerDeco=t,this.viewDescRef.innerDeco=_.empty,this.viewDescRef.dom=l,this.viewDescRef.dom.pmViewDesc=this.viewDescRef,this.viewDescRef.nodeDOM=a),r.current.includes(this.viewDescRef)||r.current.push(this.viewDescRef),r.current.sort((u,c)=>u.getPos()-c.getPos())}shouldComponentUpdate(e){return!CE(this.props,e)}componentDidMount(){this.updateEffect()}componentDidUpdate(){this.updateEffect()}componentWillUnmount(){const{siblingsRef:e}=this.props;if(this.viewDescRef&&e.current.includes(this.viewDescRef)){const t=e.current.indexOf(this.viewDescRef);e.current.splice(t,1)}}render(){const{view:e,getPos:t,node:r,decorations:i}=this.props;return e!=null&&e.composing&&e.state.selection.from>=t.current()&&e.state.selection.from<=t.current()+r.nodeSize?this.renderRef:(this.renderRef=i.reduce(kd,r.text),this.renderRef)}}function ME({getPos:n}){const{siblingsRef:e,parentRef:t}=k.useContext(mt),r=k.useRef(null),i=k.useRef(null);return k.useLayoutEffect(()=>{const o=e.current;return()=>{if(r.current&&o.includes(r.current)){const s=o.indexOf(r.current);o.splice(s,1)}}},[e]),k.useLayoutEffect(()=>{i.current&&(r.current?(r.current.parent=t.current,r.current.dom=i.current,r.current.getPos=()=>n.current()):r.current=new Sd(t.current,[],()=>n.current(),i.current,null),e.current.includes(r.current)||e.current.push(r.current),e.current.sort((o,s)=>o.getPos()-s.getPos()))}),A.jsx("br",{ref:i,className:"ProseMirror-trailingBreak"})}function EE({widget:n,getPos:e}){const{siblingsRef:t,parentRef:r}=k.useContext(mt),i=k.useRef(null),o=k.useRef(()=>e.current()).current,s=k.useRef(null);k.useLayoutEffect(()=>{const a=t.current;return()=>{if(i.current&&a.includes(i.current)){const u=a.indexOf(i.current);a.splice(u,1)}}},[t]),k.useLayoutEffect(()=>{s.current&&(i.current?(i.current.parent=r.current,i.current.widget=n,i.current.getPos=()=>e.current(),i.current.dom=s.current):i.current=new gd(r.current,()=>e.current(),n,s.current),t.current.includes(i.current)||t.current.push(i.current),t.current.sort((a,u)=>a.getPos()-u.getPos()))});const{Component:l}=n.type;return l&&A.jsx(l,{ref:s,widget:n,getPos:o,contentEditable:!1})}function kd(n,e){const{nodeName:t,...r}=e.type.attrs,i=G1(r);return t||typeof n=="string"?k.createElement(t??"span",i,n):k.cloneElement(n,Y1(n.props,i))}const OE=k.memo(function({child:e,getInnerPos:t}){const{view:r}=k.useContext(yi),i=k.useRef(()=>t.current()+e.offset);i.current=()=>t.current()+e.offset;const o=ya(),s=Tn(t.current(),e,o==null?void 0:o.posToKey);return e.type==="widget"?A.jsx(EE,{widget:e.widget,getPos:i},s):e.type==="native-widget"?A.jsx(wE,{widget:e.widget,getPos:i},s):e.node.isText?A.jsx(mt.Consumer,{children:({siblingsRef:l,parentRef:a})=>A.jsx(NE,{view:r,node:e.node,getPos:i,siblingsRef:l,parentRef:a,decorations:e.outerDeco})},s):A.jsx(Z1,{node:e.node,getPos:i,outerDeco:e.outerDeco,innerDeco:e.innerDeco},s)}),TE=k.memo(function({childViews:e,getInnerPos:t}){const r=ya(),i=e[0],o=k.useRef(()=>t.current()+i.offset);o.current=()=>t.current()+i.offset;const s=i.marks[0];return s?A.jsx(X1,{getPos:o,mark:s,children:A.jsx(vd,{getInnerPos:t,childViews:e.map(l=>({...l,marks:l.marks.slice(1)}))},Tn(t.current(),i,r==null?void 0:r.posToKey))},Tn(t.current(),i,r==null?void 0:r.posToKey)):A.jsx(A.Fragment,{children:e.map(l=>{const a=Tn(t.current(),l,r==null?void 0:r.posToKey);return A.jsx(OE,{child:l,getInnerPos:t},a)})})}),vd=k.memo(function({getInnerPos:e,childViews:t}){const r=ya(),i=t.reduce((o,s)=>{var u;const l=o[o.length-1];if(!l)return[[s]];const a=l[l.length-1];return a?!s.marks.length&&!a.marks.length||s.marks.length&&a.marks.length&&((u=s.marks[0])!=null&&u.eq(a.marks[0]))?[...o.slice(0,o.length-1),[...l.slice(0,l.length),s]]:[...o,[s]]:[...o.slice(0,o.length),[s]]},[]);return A.jsx(A.Fragment,{children:i.map(o=>{const s=o[0];if(!s)return null;const l=Tn(e.current(),s,r==null?void 0:r.posToKey);return A.jsx(TE,{childViews:o,getInnerPos:e},l)})})});function Tn(n,e,t){const r=n+e.offset,i=t==null?void 0:t.get(r);return e.type==="widget"||e.type==="native-widget"?e.widget.type.spec.key?e.widget.type.spec.key:(console.warn(`Widget at position ${r} doesn't have a key specified. This has negative performance implications.`),`${i}-${e.index}`):i||r}function DE(n){const e=n[n.length-1];if((e==null?void 0:e.type)!=="widget"&&(e==null?void 0:e.type)!=="native-widget"||e.widget.type.side>=0)return;let t=null;for(let i=n.length-2;i>=0;i--){const o=n[i];if((o==null?void 0:o.type)==="node"){t=o;break}}if(!t||!t.node.isInline)return;const r=t.marks;e.marks=e.marks.reduce((i,o)=>o.addToSet(i),r)}function RE(n){const e=n[n.length-1];if((e==null?void 0:e.type)!=="node"||!e.node.isInline)return;const t=e.marks;for(let r=n.length-2;r>=0;r--){const i=n[r];if((i==null?void 0:i.type)!=="widget"&&(i==null?void 0:i.type)!=="native-widget"||i.widget.type.side<0)break;i.marks=i.marks.reduce((o,s)=>s.addToSet(o),t)}}const AE=k.memo(function({child:e,getInnerPos:t,posToKey:r}){const i=k.useRef(()=>t.current()+e.offset);i.current=()=>t.current()+e.offset;const o=Tn(t.current(),e,r);return e.type==="node"?A.jsx(Z1,{outerDeco:e.outerDeco,node:e.node,innerDeco:e.innerDeco,getPos:i},o):A.jsx(vd,{childViews:[e],getInnerPos:t},o)},(n,e)=>{var t,r,i;return n.child.type===e.child.type&&n.child.marks.every(o=>o.isInSet(e.child.marks))&&e.child.marks.every(o=>o.isInSet(n.child.marks))&&n.child.offset===e.child.offset&&(n.child.type==="node"?((t=n.child.outerDeco)==null?void 0:t.length)===((r=e.child.outerDeco)==null?void 0:r.length)&&((i=n.child.outerDeco)==null?void 0:i.every(o=>{var s;return(s=e.child.outerDeco)==null?void 0:s.some(l=>o.from===l.from&&o.to&&l.to&&o.type.eq(l.type))}))&&n.child.innerDeco.eq(e.child.innerDeco):!0)&&n.child.node===e.child.node&&n.child.widget===e.child.widget});function bE(n,e,t){return n.length?n.every(r=>r.type!=="node"||r.node.isInline)?[A.jsx(vd,{childViews:n,getInnerPos:e},Tn(e.current(),n[0],t))]:n.map(r=>{const i=Tn(e.current(),r,t);return A.jsx(AE,{child:r,posToKey:t,getInnerPos:e},i)}):[]}const mo=k.memo(function({getPos:e,node:t,innerDecorations:r}){const i=ya(),o=k.useRef(()=>e.current()+1);if(!t)return null;const s=[];pE(t,r,(u,c,f,d)=>{const p=u.type.spec.marks??[];c?s.push({type:"native-widget",widget:u,marks:p,offset:f,index:d}):s.push({type:"widget",widget:u,marks:p,offset:f,index:d}),DE(s)},(u,c,f,d)=>{s.push({type:"node",node:u,marks:u.marks,innerDeco:f,outerDeco:c,offset:d}),RE(s)});const l=bE(s,o,i==null?void 0:i.posToKey),a=s[s.length-1];return(!a||a.type!=="node"||a.node.isInline&&!a.node.isText||/\n$/.test(a.node.text))&&l.push(A.jsx(xE,{getPos:o},"trailing-hack-img"),A.jsx(ME,{getPos:o},"trailing-hack-br")),A.jsx(A.Fragment,{children:l})}),xu={current(){return-1}},zE=k.memo(k.forwardRef(function({className:e,node:t,innerDeco:r,outerDeco:i,as:o,viewDesc:s,...l},a){const u=k.useRef(null);k.useImperativeHandle(a,()=>u.current,[]);const{childDescriptors:c,nodeViewDescRef:f}=q1(t,()=>xu.current(),u,u,r,i,s),d=k.useMemo(()=>({parentRef:f,siblingsRef:c}),[c,f]),p={...l,ref:u,className:e,suppressContentEditableWarning:!0},h=o?k.cloneElement(o,p,A.jsx(mt.Provider,{value:d,children:A.jsx(mo,{getPos:xu,node:t,innerDecorations:r})})):k.createElement("div",p,A.jsx(mt.Provider,{value:d,children:A.jsx(mo,{getPos:xu,node:t,innerDecorations:r})}));if(!t)return h;const m=i.filter(g=>!g.inline);return m.length?m.reduce(kd,h):h})),eS=k.createContext(null);function IE({as:n,...e},t){const r=k.useRef([]),i=k.useRef(null),{setMount:o,...s}=k.useContext(eS),l=k.useRef(void 0);k.useImperativeHandle(t,()=>i.current,[]);const a=k.useMemo(()=>({parentRef:l,siblingsRef:r}),[r,l]);return A.jsx(mt.Provider,{value:a,children:A.jsx(zE,{ref:u=>{i.current=u,o(u)},...e,...s,as:n})})}const PE=k.forwardRef(IE),FE=[];function LE({className:n,children:e,nodeViews:t={},customNodeViews:r,...i}){var p;const[o,s]=k.useState(null),{editor:l,state:a}=fE(o,{...i,nodeViews:r}),u=l.view?MM(l.view,l.cursorWrapper):_.empty,c=l.view?vM(l.view):FE,f=k.useMemo(()=>({nodeViews:t}),[t]),d=k.useMemo(()=>{var h;return{className:n,setMount:s,node:(h=l.view)==null?void 0:h.state.doc,innerDeco:u,outerDeco:c,viewDesc:l.docViewDescRef.current}},[n,l.docViewDescRef,(p=l.view)==null?void 0:p.state.doc,u,c]);return A.jsx(yi.Provider,{value:l,children:A.jsx(kM.Provider,{value:a,children:A.jsx(P1.Provider,{value:f,children:A.jsx(eS.Provider,{value:d,children:e})})})})}function $E(n){return A.jsx(dE,{children:A.jsx(LE,{...n})})}const J=new zm({nodes:{doc:{content:"block+"},paragraph:{group:"block",content:"inline*",toDOM(){return["p",0]}},...Vx({cellContent:"inline*",cellAttributes:{},tableGroup:"block"}),footnote:{group:"inline",content:"text*",inline:!0,atom:!0,attrs:{number:{default:0}}},list:{group:"block",content:"list_item+",toDOM(){return["ul",0]}},list_item:{content:"paragraph+",toDOM(){return["li",0]}},image:{group:"block",toDOM(){return["div",["img",{src:"https://smoores.gitlab.io/storyteller/img/Storyteller_Logo.png",height:150,width:150}]]}},text:{group:"inline"}},marks:{em:{toDOM(){return["em",0]}},strong:{toDOM(){return["strong",0]}}}}),VE=dn.create({schema:J,doc:J.nodes.doc.create({},[J.nodes.paragraph.create({},[J.text("This ",[J.marks.em.create()]),J.text("is",[J.marks.em.create(),J.marks.strong.create()]),J.text(" the first paragraph")]),J.nodes.paragraph.create({},[J.text("This is the second paragraph"),J.nodes.footnote.create({number:1},J.text("Footnote"))]),J.nodes.paragraph.create(),J.nodes.image.create(),J.nodes.image.create(),J.nodes.paragraph.create({},J.text("This is the third paragraph 🫵")),J.nodes.table.create({},[J.nodes.table_row.create({},[J.nodes.table_header.create({},J.text("h1")),J.nodes.table_header.create({},J.text("h2"))]),J.nodes.table_row.create({},[J.nodes.table_cell.create({},J.text("c1")),J.nodes.table_cell.create({},J.text("c2"))])])]),plugins:[IM(),rx({rules:[ix(/^\s*([-+*])\s$/,J.nodes.list)]}),iC(),gC()]}),BE=k.forwardRef(function({children:e,nodeProps:t,...r},i){return A.jsx("p",{ref:i,...r,children:e})}),JE=k.forwardRef(function({children:e,nodeProps:t,...r},i){return A.jsx("ul",{ref:i,...r,children:e})}),_E=k.forwardRef(function({children:e,nodeProps:t,...r},i){return A.jsx("li",{ref:i,...r,children:e})}),WE=k.forwardRef(function({nodeProps:e,...t},r){return A.jsx("span",{ref:r,...t,suppressContentEditableWarning:!0,contentEditable:"false",children:A.jsx("button",{children:e.node.attrs.number})})}),UE=k.forwardRef(function({widget:e,getPos:t,...r},i){return A.jsx("span",{...r,ref:i,style:{display:"block",backgroundColor:"blue",width:"4px",height:"4px",position:"absolute",transform:"translateX(-2px)"},children:"Widget"})}),HE=new $t({view(n){const e=n.coordsAtPos(n.state.selection.from),t=document.createElement("div");return t.style.width="4px",t.style.height="4px",t.style.position="absolute",t.style.top=`${e.top-2}px`,t.style.left=`${e.left-2}px`,t.style.backgroundColor="blue",document.body.appendChild(t),{update(r){const i=r.coordsAtPos(r.state.selection.from);t.style.top=`${i.top-2}px`,t.style.left=`${i.left-2}px`},destroy(){document.body.removeChild(t)}}}});new $t({props:{decorations(n){return _.create(n.doc,[B1(n.selection.from,UE,{side:0,key:"widget-plugin-widget"})])}},view(n){const e=n.coordsAtPos(n.state.selection.from),t=document.createElement("div");return t.style.width="4px",t.style.height="4px",t.style.position="absolute",t.style.top=`${e.top-2}px`,t.style.left=`${e.left-2}px`,t.style.backgroundColor="blue",document.body.appendChild(t),{update(r){const i=r.coordsAtPos(r.state.selection.from);t.style.top=`${i.top-2}px`,t.style.left=`${i.left-2}px`},destroy(){document.body.removeChild(t)}}}});const jE=[ax({...Uw,"Mod-i":Hd(J.marks.em),"Mod-b":Hd(J.marks.strong)}),HE,Bv()],KE={paragraph:()=>{const n=document.createElement("p");return{dom:n,contentDOM:n}}};function qE(){const[n,e]=k.useState(VE),[t,r]=k.useState(!0),i=k.useMemo(()=>t?{paragraph:BE,list:JE,list_item:_E,footnote:WE}:void 0,[t]),o=k.useCallback(function(s){e(l=>l.apply(s))},[]);return A.jsxs("main",{children:[A.jsx("h1",{children:"React ProseMirror Demo"}),A.jsxs("button",{onClick:()=>{t?r(s=>!s):window.location.reload()},children:["Switch to"," ",t?"ProseMirror node views":"React node views (requires reload)"]}),A.jsx($E,{className:"ProseMirror",state:n,dispatchTransaction:o,plugins:jE,nodeViews:i,customNodeViews:t?void 0:KE,children:A.jsx(PE,{})},`${t}`)]})}const QE=I1(document.getElementById("root"));QE.render(A.jsx(k.StrictMode,{children:A.jsx(qE,{})})); diff --git a/docs/index.html b/docs/index.html index f66165f..4254bf2 100644 --- a/docs/index.html +++ b/docs/index.html @@ -5,7 +5,7 @@ React-ProseMirror Demo - + diff --git a/src/components/NodeView.tsx b/src/components/NodeView.tsx index 2c44de8..09914c6 100644 --- a/src/components/NodeView.tsx +++ b/src/components/NodeView.tsx @@ -21,6 +21,7 @@ import { createPortal } from "react-dom"; import { ChildDescriptorsContext } from "../contexts/ChildDescriptorsContext.js"; import { EditorContext } from "../contexts/EditorContext.js"; import { NodeViewContext } from "../contexts/NodeViewContext.js"; +import { SelectNodeContext } from "../contexts/SelectNodeContext.js"; import { StopEventContext } from "../contexts/StopEventContext.js"; import { useNodeViewDescriptor } from "../hooks/useNodeViewDescriptor.js"; @@ -122,17 +123,22 @@ export const NodeView = memo(function NodeView({ customNodeViewRootRef.current.appendChild(dom); }, [customNodeView, view, innerDeco, node, outerDeco, getPos]); - const { hasContentDOM, childDescriptors, setStopEvent, nodeViewDescRef } = - useNodeViewDescriptor( - node, - () => getPos.current(), - domRef, - nodeDomRef, - innerDeco, - outerDeco, - undefined, - contentDomRef - ); + const { + hasContentDOM, + childDescriptors, + setStopEvent, + setSelectNode, + nodeViewDescRef, + } = useNodeViewDescriptor( + node, + () => getPos.current(), + domRef, + nodeDomRef, + innerDeco, + outerDeco, + undefined, + contentDomRef + ); const finalProps = { ...props, @@ -147,9 +153,6 @@ export const NodeView = memo(function NodeView({ getPos: getPosFunc, decorations: outerDeco, innerDecorations: innerDeco, - isSelected: false, - // state.selection instanceof NodeSelection && - // state.selection.node === node, }), [getPosFunc, innerDeco, node, outerDeco] ); @@ -245,20 +248,22 @@ export const NodeView = memo(function NodeView({ ); return ( - - - {cloneElement( - markedElement, - node.marks.length || - // eslint-disable-next-line @typescript-eslint/no-explicit-any - outerDeco.some((d) => (d as any).type.attrs.nodeName) - ? { ref: domRef } - : // If all of the node decorations were attr-only, then - // we've already passed the domRef to the NodeView component - // as a prop - undefined - )} - - + + + + {cloneElement( + markedElement, + node.marks.length || + // eslint-disable-next-line @typescript-eslint/no-explicit-any + outerDeco.some((d) => (d as any).type.attrs.nodeName) + ? { ref: domRef } + : // If all of the node decorations were attr-only, then + // we've already passed the domRef to the NodeView component + // as a prop + undefined + )} + + + ); }); diff --git a/src/components/NodeViewComponentProps.tsx b/src/components/NodeViewComponentProps.tsx index e065a31..2096af8 100644 --- a/src/components/NodeViewComponentProps.tsx +++ b/src/components/NodeViewComponentProps.tsx @@ -8,7 +8,6 @@ export type NodeViewComponentProps = { innerDecorations: DecorationSource; node: Node; children?: ReactNode | ReactNode[]; - isSelected: boolean; getPos: () => number; }; } & HTMLAttributes; diff --git a/src/contexts/SelectNodeContext.ts b/src/contexts/SelectNodeContext.ts new file mode 100644 index 0000000..49a40d9 --- /dev/null +++ b/src/contexts/SelectNodeContext.ts @@ -0,0 +1,10 @@ +import { createContext } from "react"; + +type SelectNodeContextValue = ( + selectNode: () => void, + deselectNode: () => void +) => void; + +export const SelectNodeContext = createContext( + null as unknown as SelectNodeContextValue +); diff --git a/src/hooks/useEditor.ts b/src/hooks/useEditor.ts index 84aacae..7313202 100644 --- a/src/hooks/useEditor.ts +++ b/src/hooks/useEditor.ts @@ -297,7 +297,13 @@ export function useEditor( tempDom, null, tempDom, - () => false + () => false, + () => { + /* The doc node can't have a node selection*/ + }, + () => { + /* The doc node can't have a node selection*/ + } ) ); diff --git a/src/hooks/useNodeViewDescriptor.ts b/src/hooks/useNodeViewDescriptor.ts index 0aa9db5..5f965dc 100644 --- a/src/hooks/useNodeViewDescriptor.ts +++ b/src/hooks/useNodeViewDescriptor.ts @@ -33,6 +33,30 @@ export function useNodeViewDescriptor( }, [] ); + const selectNode = useRef<() => void>(() => { + if (!nodeDomRef.current || !node) return; + if (nodeDomRef.current.nodeType == 1) + nodeDomRef.current.classList.add("ProseMirror-selectednode"); + if (contentDOMRef?.current || !node.type.spec.draggable) + (domRef?.current ?? nodeDomRef.current).draggable = true; + }); + const deselectNode = useRef<() => void>(() => { + if (!nodeDomRef.current || !node) return; + if (nodeDomRef.current.nodeType == 1) { + (nodeDomRef.current as HTMLElement).classList.remove( + "ProseMirror-selectednode" + ); + if (contentDOMRef?.current || !node.type.spec.draggable) + (domRef?.current ?? nodeDomRef.current).removeAttribute("draggable"); + } + }); + const setSelectNode = useCallback( + (newSelectNode: () => void, newDeselectNode: () => void) => { + selectNode.current = newSelectNode; + deselectNode.current = newDeselectNode; + }, + [] + ); const { siblingsRef, parentRef } = useContext(ChildDescriptorsContext); const childDescriptors = useRef([]); @@ -64,7 +88,9 @@ export function useNodeViewDescriptor( domRef?.current ?? nodeDomRef.current, firstChildDesc?.dom.parentElement ?? null, nodeDomRef.current, - (event) => !!stopEvent.current(event) + (event) => !!stopEvent.current(event), + () => selectNode.current(), + () => deselectNode.current() ); } else { nodeViewDescRef.current.parent = parentRef.current; @@ -141,5 +167,11 @@ export function useNodeViewDescriptor( }; }); - return { hasContentDOM, childDescriptors, nodeViewDescRef, setStopEvent }; + return { + hasContentDOM, + childDescriptors, + nodeViewDescRef, + setStopEvent, + setSelectNode, + }; } diff --git a/src/hooks/useSelectNode.ts b/src/hooks/useSelectNode.ts new file mode 100644 index 0000000..f92f1a5 --- /dev/null +++ b/src/hooks/useSelectNode.ts @@ -0,0 +1,23 @@ +import { useContext } from "react"; + +import { SelectNodeContext } from "../contexts/SelectNodeContext.js"; + +import { useEditorEffect } from "./useEditorEffect.js"; +import { useEditorEventCallback } from "./useEditorEventCallback.js"; + +export function useSelectNode( + selectNode: () => void, + deselectNode?: () => void +) { + const register = useContext(SelectNodeContext); + const selectNodeMemo = useEditorEventCallback(selectNode); + const deselectNodeMemo = useEditorEventCallback( + deselectNode ?? + (() => { + // empty + }) + ); + return useEditorEffect(() => { + register(selectNodeMemo, deselectNodeMemo); + }, [deselectNodeMemo, register, selectNodeMemo]); +} diff --git a/src/index.ts b/src/index.ts index 8b4f9bd..3e190da 100644 --- a/src/index.ts +++ b/src/index.ts @@ -7,6 +7,7 @@ export { useEditorEventCallback } from "./hooks/useEditorEventCallback.js"; export { useEditorEventListener } from "./hooks/useEditorEventListener.js"; export { useEditorState } from "./hooks/useEditorState.js"; export { useStopEvent } from "./hooks/useStopEvent.js"; +export { useSelectNode } from "./hooks/useSelectNode.js"; export { reactKeys } from "./plugins/reactKeys.js"; export { widget } from "./decorations/ReactWidgetType.js"; diff --git a/src/viewdesc.ts b/src/viewdesc.ts index 7a6b911..aaaea5e 100644 --- a/src/viewdesc.ts +++ b/src/viewdesc.ts @@ -754,7 +754,9 @@ export class NodeViewDesc extends ViewDesc { dom: DOMNode, contentDOM: HTMLElement | null, public nodeDOM: DOMNode, - public stopEvent: (event: Event) => boolean + public stopEvent: (event: Event) => boolean, + public selectNode: () => void, + public deselectNode: () => void ) { super(parent, children, getPos, dom, contentDOM); } @@ -829,25 +831,6 @@ export class NodeViewDesc extends ViewDesc { return true; } - // Mark this node as being the selected node. - selectNode() { - if (this.nodeDOM.nodeType == 1) - (this.nodeDOM as HTMLElement).classList.add("ProseMirror-selectednode"); - if (this.contentDOM || !this.node.type.spec.draggable) - (this.dom as HTMLElement).draggable = true; - } - - // Remove selected node marking from this node. - deselectNode() { - if (this.nodeDOM.nodeType == 1) { - (this.nodeDOM as HTMLElement).classList.remove( - "ProseMirror-selectednode" - ); - if (this.contentDOM || !this.node.type.spec.draggable) - (this.dom as HTMLElement).removeAttribute("draggable"); - } - } - get domAtom() { return this.node.isAtom; } @@ -874,7 +857,13 @@ export class TextViewDesc extends NodeViewDesc { dom, null, nodeDOM, - () => false + () => false, + () => { + /* Text nodes can't have node selections */ + }, + () => { + /* Text nodes can't have node selections */ + } ); }