diff --git a/docs/assets/index-CSvukb3X.js b/docs/assets/index-BNcakB_Z.js similarity index 64% rename from docs/assets/index-CSvukb3X.js rename to docs/assets/index-BNcakB_Z.js index 8ba5993..dd5b3de 100644 --- a/docs/assets/index-CSvukb3X.js +++ b/docs/assets/index-BNcakB_Z.js @@ -1,4 +1,4 @@ -(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const o of i)if(o.type==="childList")for(const s of o.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&r(s)}).observe(document,{childList:!0,subtree:!0});function t(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerPolicy&&(o.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?o.credentials="include":i.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(i){if(i.ep)return;i.ep=!0;const o=t(i);fetch(i.href,o)}})();function X1(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var im={exports:{}},Ql={},om={exports:{}},V={};/** +(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const o of i)if(o.type==="childList")for(const s of o.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&r(s)}).observe(document,{childList:!0,subtree:!0});function t(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerPolicy&&(o.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?o.credentials="include":i.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(i){if(i.ep)return;i.ep=!0;const o=t(i);fetch(i.href,o)}})();function eS(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var sm={exports:{}},Yl={},lm={exports:{}},V={};/** * @license React * react.production.min.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 jo=Symbol.for("react.element"),Z1=Symbol.for("react.portal"),eS=Symbol.for("react.fragment"),tS=Symbol.for("react.strict_mode"),nS=Symbol.for("react.profiler"),rS=Symbol.for("react.provider"),iS=Symbol.for("react.context"),oS=Symbol.for("react.forward_ref"),sS=Symbol.for("react.suspense"),lS=Symbol.for("react.memo"),aS=Symbol.for("react.lazy"),yd=Symbol.iterator;function uS(n){return n===null||typeof n!="object"?null:(n=yd&&n[yd]||n["@@iterator"],typeof n=="function"?n:null)}var sm={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},lm=Object.assign,am={};function ci(n,e,t){this.props=n,this.context=e,this.refs=am,this.updater=t||sm}ci.prototype.isReactComponent={};ci.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")};ci.prototype.forceUpdate=function(n){this.updater.enqueueForceUpdate(this,n,"forceUpdate")};function um(){}um.prototype=ci.prototype;function Uc(n,e,t){this.props=n,this.context=e,this.refs=am,this.updater=t||sm}var Hc=Uc.prototype=new um;Hc.constructor=Uc;lm(Hc,ci.prototype);Hc.isPureReactComponent=!0;var Sd=Array.isArray,cm=Object.prototype.hasOwnProperty,jc={current:null},fm={key:!0,ref:!0,__self:!0,__source:!0};function dm(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)cm.call(e,r)&&!fm.hasOwnProperty(r)&&(i[r]=e[r]);var l=arguments.length-2;if(l===1)i.children=t;else if(1>1}};de.from=function(n){if(n instanceof de)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new de(e)};function pm(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=pm(i.content,o.content,t+1);if(s!=null)return s}t+=i.nodeSize}}function mm(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?us(r+1,s):us(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}}_.none=[];class En extends Error{}class k{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=ym(this.content,e+this.openStart,t);return r&&new k(r,this.openStart,this.openEnd)}removeBetween(e,t){return new k(gm(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 k.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 k(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 k(e,r,i)}}k.empty=new k(x.empty,0,0);function gm(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(gm(o.content,e-i-1,t-i-1)))}function ym(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=ym(s.content,e-o-1,t);return l&&n.replaceChild(i,s.copy(l))}function kS(n,e,t){if(t.openStart>n.depth)throw new En("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new En("Inconsistent open depths");return Sm(n,e,t,0)}function Sm(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 Zi(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&&(Yn(n.nodeAfter,r),o++));for(let l=o;li&&wu(n,e,i+1),s=r.depth>i&&wu(t,r,i+1),l=[];return Zi(null,n,i,l),o&&s&&e.index(i)==t.index(i)?(wm(o,s),Yn(Gn(o,km(n,e,t,r,i+1)),l)):(o&&Yn(Gn(o,fl(n,e,i+1)),l),Zi(e,t,i,l),s&&Yn(Gn(s,fl(t,r,i+1)),l)),Zi(r,null,i,l),new x(l)}function fl(n,e,t){let r=[];if(Zi(null,n,t,r),n.depth>t){let i=wu(n,e,t+1);Yn(Gn(i,fl(n,e,t+1)),r)}return Zi(e,null,t,r),new x(r)}function vS(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 NS(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=kd.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()+")"),vm(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 dl 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):vm(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 dl(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new dl(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 vm(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class nr{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new ES(e,t);if(r.next==null)return nr.empty;let i=xm(r);r.next&&r.err("Unexpected trailing text");let o=IS(bS(i));return zS(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(` -`)}}nr.empty=new nr(!0);class ES{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 xm(n){let e=[];do e.push(OS(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function OS(n){let e=[];do e.push(DS(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function DS(n){let e=AS(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=TS(n,e);else break;return e}function vd(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function TS(n,e){let t=vd(n),r=t;return n.eat(",")&&(n.next!="}"?r=vd(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function RS(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 AS(n){if(n.eat("(")){let e=xm(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=RS(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 bS(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 nr(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 Dm(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 PS(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 FS{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?PS(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=Om(e,i.attrs),this.excluded=null;let o=Nm(this.attrs);this.instance=o?new _(this,o):null}create(e=null){return!e&&this.instance?this.instance:new _(this,Mm(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 Tm{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=de.from(e.nodes),t.marks=de.from(e.marks||{}),this.nodes=Cd.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]=nr.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?Nd(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==""?[]:Nd(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 Cd){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 dl(r,r.defaultAttrs,e,_.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 _.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function Nd(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 LS(n){return n.tag!=null}function $S(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(LS(i))this.tags.push(i);else if($S(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 Ed(this,t,!1);return r.addAll(e,_.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new Ed(this,t,!0);return r.addAll(e,_.none,t.from,t.to),k.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=Od(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=Od(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 Rm={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},VS={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Am={ol:!0,ul:!0},hl=1,pl=2,eo=4;function Md(n,e,t){return e!=null?(e?hl:0)|(e==="full"?pl:0):n&&n.whitespace=="pre"?hl|pl:t&~eo}class cs{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=_.none,this.match=o||(s&eo?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&hl)){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&&!Rm.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Ed{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0;let i=t.topNode,o,s=Md(null,t.preserveWhitespace,0)|(r?eo:0);i?o=new cs(i.type,i.attrs,_.none,!0,t.topMatch||i.type.contentMatch,s):r?o=new cs(null,null,_.none,!0,null,s):o=new cs(e.schema.topNodeType,null,_.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&pl||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(i.options&hl)i.options&pl?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;Am.hasOwnProperty(i)&&this.parser.normalizeLists&&BS(e);let s=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,r));if(s?s.ignore:VS.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(Rm.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):Dd(u.type,e))?(a=u.addToSet(a),!1):!0),this.nodes.push(new cs(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 BS(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Am.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function JS(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function Od(n){let e={};for(let t in n)e[t]=n[t];return e}function Dd(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&&Fs(wa(r),i(e,t),null,e.attrs)}static renderSpec(e,t,r=null,i){return Fs(e,t,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new fi(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Td(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return Td(e.marks)}}function Td(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function wa(n){return n.document||window.document}const Rd=new WeakMap;function _S(n){let e=Rd.get(n);return e===void 0&&Rd.set(n,e=WS(n)),e}function WS(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}=Fs(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 bm=65535,Im=Math.pow(2,16);function US(n,e){return n+e*Im}function Ad(n){return n&bm}function HS(n){return(n-(n&bm))/Im}const zm=1,Pm=2,Ls=4,Fm=8;let bd=class{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&Fm)>0}get deletedBefore(){return(this.delInfo&(zm|Ls))>0}get deletedAfter(){return(this.delInfo&(Pm|Ls))>0}get deletedAcross(){return(this.delInfo&Ls)>0}},Hr=class gr{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&gr.empty)return gr.empty}recover(e){let t=0,r=Ad(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:US(l/3,e-a),m=e==a?Pm:e==f?zm:Ls;return(t<0?e!=a:e!=f)&&(m|=Fm),new bd(p,m,h)}i+=c-u}return r?e+i:new bd(e+i,0,null)}touches(e,t){let r=0,i=Ad(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 Le.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 Oi(t.pos,r.pos,this.mark)}merge(e){return e instanceof Oi&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Oi(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 Oi(t.from,t.to,e.markFromJSON(t.mark))}};je.jsonID("addMark",Lm);let $m=class Di extends je{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 k(qc(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return Le.fromReplace(e,this.from,this.to,r)}invert(){return new Lm(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))}};je.jsonID("removeMark",$m);let Vm=class Ti extends je{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Le.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return Le.fromReplace(e,this.pos,this.pos+1,new k(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 $s(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 $s(t.from,t.to,t.gapFrom,t.gapTo,k.fromJSON(e,t.slice),t.insert,!!t.structure)}};je.jsonID("replaceAround",ml);function vu(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 jS(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function Yc(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 Jm(n,e){let t=n.resolve(e),r=t.index();return KS(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function KS(n,e){return!!(n&&e&&!n.isLeaf&&n.canAppend(e))}function _m(n,e,t=e,r=k.empty){if(e==t&&!r.size)return null;let i=n.resolve(e),o=n.resolve(t);return qS(i,o,r)?new Qc(e,t,r):new QS(i,o,r).fit()}function qS(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}let QS=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 k(o,s,l);return e>-1?new ml(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new Qc(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=va(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=va(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new k(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=va(e,t);if(i.childCount<=1&&t>0){let o=e.size-t<=t+i.size;this.unplaced=new k(Ri(e,t-1,1),t-1,o?t-1:r)}else this.unplaced=new k(Ri(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(Wm(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=Ai(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=xa(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=Ai(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=Ai(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=Ai(this.placed,this.frontier.length,t))}};function Ri(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Ri(n.firstChild.content,e-1,t)))}function Ai(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Ai(n.lastChild.content,e-1,t)))}function va(n,e){for(let t=0;t1&&(r=r.replaceChild(0,Wm(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 xa(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&&!YS(t,o.content,s)?l:null}function YS(n,e,t){for(let r=t;r0}get deletedBefore(){return(this.delInfo&(jm|Js))>0}get deletedAfter(){return(this.delInfo&(Km|Js))>0}get deletedAcross(){return(this.delInfo&Js)>0}},jr=class yr{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&yr.empty)return yr.empty}recover(e){let t=0,r=Id(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:XS(l/3,e-a),m=e==a?Km:e==f?jm:Js;return(t<0?e!=a:e!=f)&&(m|=qm),new xu(p,m,h)}i+=c-u}return r?e+i:new xu(e+i,0,null)}touches(e,t){let r=0,i=Id(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 _s;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 $e.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))}};Ke.jsonID("addMark",Xc);let qo=class zi 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 k(Gc(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 Xc(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 zi(t.pos,r.pos,this.mark)}merge(e){return e instanceof zi&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new zi(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 zi(t.from,t.to,e.markFromJSON(t.mark))}};Ke.jsonID("removeMark",qo);let Zc=class Pi 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 k(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 Ws(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 Ws(t.from,t.to,t.gapFrom,t.gapTo,k.fromJSON(e,t.slice),t.insert,!!t.structure)}};Ke.jsonID("replaceAround",ur);function Nu(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 tw(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 nw(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 rw(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 iw(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 ur(i,o,i,o,new k(r,0,0),t.length,!0))}function sw(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)&&lw(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 ur(u,c,u+1,c-1,new k(x.from(r.create(i,null,s.marks)),0,0),1,!0)),!1}})}function lw(n,e,t){let r=n.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,t)}function aw(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 ur(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new k(x.from(s),0,0),1,!0))}function uw(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 Tn(e,e,new k(o.append(s),t,t),!0))}function cw(n,e,t){let r=new Tn(e-t,e+t,k.empty,!0);n.step(r)}function fw(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 k(o,s,l);return e>-1?new ur(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new Tn(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=Na(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=Na(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new k(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=Na(e,t);if(i.childCount<=1&&t>0){let o=e.size-t<=t+i.size;this.unplaced=new k(Fi(e,t-1,1),t-1,o?t-1:r)}else this.unplaced=new k(Fi(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(Ym(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=Li(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=Ma(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=Li(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=Li(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=Li(this.placed,this.frontier.length,t))}};function Fi(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Fi(n.firstChild.content,e-1,t)))}function Li(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Li(n.lastChild.content,e-1,t)))}function Na(n,e){for(let t=0;t1&&(r=r.replaceChild(0,Ym(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 Ma(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&&!pw(t,o.content,s)?l:null}function pw(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=mw(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 Gm(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 yw(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let i=fw(n.doc,e,r.type);i!=null&&(e=t=i)}n.replaceRange(e,t,new k(x.from(r),0,0))}function Sw(n,e,t){let r=n.doc.resolve(e),i=n.doc.resolve(t),o=Xm(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 Xm(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 Zm=class Us extends Ke{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 $e.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 $e.fromReplace(e,this.pos,this.pos+1,new k(x.from(i),0,t.isLeaf?0:1))}getMap(){return jr.empty}invert(e){return new Us(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 Us(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 Us(t.pos,t.attr,t.value)}};Ke.jsonID("attr",Zm);let Kr=class extends Error{};Kr=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};Kr.prototype=Object.create(Error.prototype);Kr.prototype.constructor=Kr;Kr.prototype.name="TransformError";let ww=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new ew}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Kr(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=k.empty){let i=dw(this.doc,e,t,r);return i&&this.step(i),this}replaceWith(e,t,r){return this.replace(e,t,new k(x.from(r),0,0))}delete(e,t){return this.replace(e,t,k.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return gw(this,e,t,r),this}replaceRangeWith(e,t,r){return yw(this,e,t,r),this}deleteRange(e,t){return Sw(this,e,t),this}lift(e,t){return iw(this,e,t),this}join(e,t=1){return cw(this,e,t),this}wrap(e,t){return ow(this,e,t),this}setBlockType(e,t=e,r,i=null){return sw(this,e,t,r,i),this}setNodeMarkup(e,t,r=null,i){return aw(this,e,t,r,i),this}setNodeAttribute(e,t,r){return this.step(new Zm(e,t,r)),this}addNodeMark(e,t){return this.step(new Zc(e,t)),this}removeNodeMark(e,t){if(!(t instanceof _)){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 ef(e,t)),this}split(e,t=1,r){return uw(this,e,t,r),this}addMark(e,t,r){return tw(this,e,t,r),this}removeMark(e,t,r){return nw(this,e,t,r),this}clearIncompatible(e,t,r){return rw(this,e,t,r),this}};const Ea=Object.create(null);class P{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new eg(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?Sr(e.node(0),e.node(o),e.before(o+1),e.index(o),t,r):Sr(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 Ze(e.node(0))}static atStart(e){return Sr(e,e,0,0,1)||new Ze(e)}static atEnd(e){return Sr(e,e,e.content.size,e.childCount,-1)||new Ze(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Ea[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 Ea)throw new RangeError("Duplicate use of selection JSON ID "+e);return Ea[e]=t,t.prototype.jsonID=e,t}getBookmark(){return $.between(this.$anchor,this.$head).getBookmark()}}P.prototype.visible=!0;class eg{constructor(e,t){this.$from=e,this.$to=t}}let zd=!1;function Pd(n){!zd&&!n.parent.inlineContent&&(zd=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class $ extends P{constructor(e,t=e){Pd(e),Pd(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=k.empty){if(super.replace(e,t),t==k.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 Yl(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&&I.isSelectable(l))return I.create(n,t-(i<0?l.nodeSize:0))}else{let a=Sr(n,l,t+i,i<0?l.childCount:0,i,o);if(a)return a}t+=l.nodeSize*i}return null}function Fd(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 Ld=1,fs=2,$d=4;class vw extends ww{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|=fs,this}ensureMarks(e){return _.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&fs)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~fs,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)||_.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|=$d,this}get scrolledIntoView(){return(this.updated&$d)>0}}function Vd(n,e){return!e||!n?n:n.bind(e)}class $i{constructor(e,t,r){this.name=e,this.init=Vd(t.init,r),this.apply=Vd(t.apply,r)}}const xw=[new $i("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new $i("selection",{init(n,e){return n.selection||P.atStart(e.doc)},apply(n){return n.selection}}),new $i("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new $i("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class Oa{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=xw.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 $i(r.key,r.spec.state,r))})}}class cn{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 Oa(e.schema,e.plugins),o=new cn(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 tg(n,e,t){for(let r in n){let i=n[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=tg(i,e,{})),t[r]=i}return t}class Lt{constructor(e){this.spec=e,this.props={},e.props&&tg(e.props,this,this.props),this.key=e.key?e.key.key:ng("plugin")}getState(e){return e[this.key]}}const Da=Object.create(null);function ng(n){return n in Da?n+"$"+ ++Da[n]:(Da[n]=0,n+"$")}class Qo{constructor(e="key"){this.key=ng(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const rg=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function Cw(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const Nw=(n,e,t)=>{let r=Cw(n,t);if(!r)return!1;let i=ig(r);if(!i){let s=r.blockRange(),l=s&&Yc(s);return l==null?!1:(e&&e(n.tr.lift(s,l).scrollIntoView()),!0)}let o=i.nodeBefore;if(!o.type.spec.isolating&&sg(n,i,e))return!0;if(r.parent.content.size==0&&(qr(o,"end")||I.isSelectable(o))){let s=_m(n.doc,r.before(),r.after(),k.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=ig(r)}let s=o&&o.nodeBefore;return!s||!I.isSelectable(s)?!1:(e&&e(n.tr.setSelection(I.create(n.doc,o.pos-s.nodeSize)).scrollIntoView()),!0)};function ig(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 Ew(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset{let r=Ew(n,t);if(!r)return!1;let i=og(r);if(!i)return!1;let o=i.nodeAfter;if(sg(n,i,e))return!0;if(r.parent.content.size==0&&(qr(o,"start")||I.isSelectable(o))){let s=_m(n.doc,r.before(),r.after(),k.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 nf(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=nf(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},Aw=(n,e)=>{let t=n.selection,{$from:r,$to:i}=t;if(t instanceof Ze||r.parent.inlineContent||i.parent.inlineContent)return!1;let o=nf(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(Vs(n.doc,o))return e&&e(n.tr.split(o).scrollIntoView()),!0}let r=t.blockRange(),i=r&&Yc(r);return i==null?!1:(e&&e(n.tr.lift(r,i).scrollIntoView()),!0)};function Iw(n){return(e,t)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof I&&e.selection.node.isBlock)return!r.parentOffset||!Vs(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 Ze)&&s.deleteSelection();let l=r.depth==0?null:nf(r.node(-1).contentMatchAt(r.indexAfter(-1))),a=o&&l?[{type:l}]:void 0,u=Vs(s.doc,s.mapping.map(r.pos),1,a);if(!a&&!u&&Vs(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 zw=Iw(),Pw=(n,e)=>(e&&e(n.tr.setSelection(new Ze(n.doc))),!0);function Fw(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||Jm(n.doc,e.pos))?!1:(t&&t(n.tr.clearIncompatible(e.pos,r.type,r.contentMatchAt(r.childCount)).join(e.pos).scrollIntoView()),!0)}function sg(n,e,t){let r=e.nodeBefore,i=e.nodeAfter,o,s;if(r.type.spec.isolating||i.type.spec.isolating)return!1;if(Fw(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 ml(e.pos-1,f,e.pos,f,new k(d,1,0),o.length,!0)),h=f+2*o.length;Jm(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&&Yc(u);if(c!=null&&c>=e.depth)return t&&t(n.tr.lift(u,c).scrollIntoView()),!0;if(l&&qr(i,"start",!0)&&qr(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 ml(e.pos-d.length,e.pos+i.nodeSize,e.pos+h,e.pos+i.nodeSize-h,new k(m,d.length,0),0,!0));t(w.scrollIntoView())}return!0}}return!1}function lg(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 Lw=lg(-1),$w=lg(1);function Vw(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 Bd(n,e=null){return function(t,r){let{empty:i,$cursor:o,ranges:s}=t.selection;if(i&&!o||!Vw(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:'"'},_d=typeof navigator<"u"&&/Chrome\/(\d+)/.exec(navigator.userAgent),_w=typeof navigator<"u"&&/Mac/.test(navigator.platform),Ww=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Uw=_w||_d&&+_d[1]<57;for(var pe=0;pe<10;pe++)bt[48+pe]=bt[96+pe]=String(pe);for(var pe=1;pe<=24;pe++)bt[pe+111]="F"+pe;for(var pe=65;pe<=90;pe++)bt[pe]=String.fromCharCode(pe+32),gl[pe]=String.fromCharCode(pe);for(var Ra in bt)gl.hasOwnProperty(Ra)||(gl[Ra]=bt[Ra]);function of(n){var e=Uw&&(n.ctrlKey||n.altKey||n.metaKey)||Ww&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?gl:bt)[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 Hw=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function jw(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,i,o,s;for(let l=0;l127)&&(o=bt[r.keyCode])&&o!=i){let l=e[Aa(o,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}const ug=65535,cg=Math.pow(2,16);function Qw(n,e){return n+e*cg}function Wd(n){return n&ug}function Yw(n){return(n-(n&ug))/cg}const fg=1,dg=2,Hs=4,hg=8;let Ud=class{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&hg)>0}get deletedBefore(){return(this.delInfo&(fg|Hs))>0}get deletedAfter(){return(this.delInfo&(dg|Hs))>0}get deletedAcross(){return(this.delInfo&Hs)>0}},Qr=class wr{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&wr.empty)return wr.empty}recover(e){let t=0,r=Wd(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:Qw(l/3,e-a),m=e==a?dg:e==f?fg:Hs;return(t<0?e!=a:e!=f)&&(m|=hg),new Ud(p,m,h)}i+=c-u}return r?e+i:new Ud(e+i,0,null)}touches(e,t){let r=0,i=Wd(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 Ve.fromReplace(e,this.from,this.to,o)}invert(){return new mg(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 Bi(t.pos,r.pos,this.mark)}merge(e){return e instanceof Bi&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Bi(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 Bi(t.from,t.to,e.markFromJSON(t.mark))}};qe.jsonID("addMark",pg);let mg=class Ji 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 k(sf(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 pg(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))}};qe.jsonID("removeMark",mg);let gg=class _i 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 k(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 js(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 js(t.from,t.to,t.gapFrom,t.gapTo,k.fromJSON(e,t.slice),t.insert,!!t.structure)}};qe.jsonID("replaceAround",Xw);function Eu(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 Zw(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 ek=class Ks 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 k(x.from(i),0,t.isLeaf?0:1))}getMap(){return Qr.empty}invert(e){return new Ks(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 Ks(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 Ks(t.pos,t.attr,t.value)}};qe.jsonID("attr",ek);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 me=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 Ou=null;const Jt=function(n,e,t){let r=Ou||(Ou=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},tk=function(){Ou=null},rr=function(n,e,t,r){return t&&(Hd(n,e,t,r,-1)||Hd(n,e,t,r,1))},nk=/^(img|br|input|textarea|hr)$/i;function Hd(n,e,t,r,i){for(;;){if(n==t&&e==r)return!0;if(e==(i<0?0:lt(n))){let o=n.parentNode;if(!o||o.nodeType!=1||Yo(n)||nk.test(n.nodeName)||n.contentEditable=="false")return!1;e=me(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?lt(n):0}else return!1}}function lt(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function rk(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=lt(n)}else if(n.parentNode&&!Yo(n))e=me(n),n=n.parentNode;else return null}}function ik(n,e){for(;;){if(n.nodeType==3&&e2),it=Yr||(It?/Mac/.test(It.platform):!1),ak=It?/Win/.test(It.platform):!1,St=/Android \d/.test(Rn),Go=!!jd&&"webkitFontSmoothing"in jd.documentElement.style,uk=Go?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function ck(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 Vt(n,e){return typeof n=="number"?n:n[e]}function fk(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 Kd(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?ck(o):fk(l),c=0,f=0;if(e.topu.bottom-Vt(r,"bottom")&&(f=e.bottom-e.top>u.bottom-u.top?e.top+Vt(i,"top")-u.top:e.bottom-u.bottom+Vt(i,"bottom")),e.leftu.right-Vt(r,"right")&&(c=e.right-u.right+Vt(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 dk(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:kg(n.dom)}}function kg(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 hk({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;vg(t,r==0?0:r-e)}function vg(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?mk(t,i):!t||r&&t.nodeType==1?{node:n,offset:o}:xg(t,i)}function mk(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 lf(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function gk(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 Sk(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 Cg(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=Sk(n,r,i,e))}l==null&&(l=yk(n,s,e));let a=n.docView.nearestDesc(s,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function qd(n){return n.top=0&&i==r.nodeValue.length?(a--,c=1):t<0?a--:u++,yi(tn(Jt(r,a,u),c),c<0)}if(!n.state.doc.resolve(e-(o||0)).parent.inlineContent){if(o==null&&i&&(t<0||i==lt(r))){let a=r.childNodes[i-1];if(a.nodeType==1)return Ia(a.getBoundingClientRect(),!1)}if(o==null&&i=0)}if(o==null&&i&&(t<0||i==lt(r))){let a=r.childNodes[i-1],u=a.nodeType==3?Jt(a,lt(a)-(s?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(u)return yi(tn(u,1),!1)}if(o==null&&i=0)}function yi(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 Ia(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 Mg(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 vk(n,e,t){let r=e.selection,i=t=="up"?r.$from:r.$to;return Mg(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=Ng(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=Jt(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 xk=/[\u0590-\u08ac]/;function Ck(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?!xk.test(r.parent.textContent)||!l.modify?t=="left"||t=="backward"?o:s:Mg(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 Qd=null,Yd=null,Gd=!1;function Nk(n,e,t){return Qd==e&&Yd==t?Gd:(Qd=e,Yd=t,Gd=t=="up"||t=="down"?vk(n,e,t):Ck(n,e,t))}const ct=0,Xd=1,Hn=2,zt=3;let Xo=class{constructor(e,t,r,i){this.parent=e,this.children=t,this.dom=r,this.contentDOM=i,this.dirty=ct,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;tme(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 Rg){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 Eg&&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?me(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=me(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?Hn:Xd,e==l&&t==a&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=zt:o.markDirty(e-l,t-l);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?Hn:zt}r=s}this.dirty=Hn}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?Hn:Xd;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==ct&&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}},Mk=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}},yl=class Au 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=fi.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new Au(e,t,s.dom,s.contentDOM||s.dom)}parseRule(){return this.dirty&zt||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=zt&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=ct){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty0&&(o=zu(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}=fi.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=Ig(c,r,t),u?a=new Ek(e,t,r,i,c,f||null,d,u,o,s+1):t.isText?new Dg(e,t,r,i,c,d,o):new Og(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==ct&&e.eq(this.node)&&Iu(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 Dk(this,s&&s.node,e);Ak(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?_.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==Hn)&&(s&&this.protectLocalComposition(e,s),Ag(this.contentDOM,this.children,e),Yr&&bk(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=Ik(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 Mk(this,o,t,i);e.input.compositionNodes.push(s),this.children=zu(this.children,r,r+i.length,e,s)}update(e,t,r,i){return this.dirty==zt||!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=ct}updateOuterDeco(e){if(Iu(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=bg(this.dom,this.nodeDOM,bu(this.outerDeco,this.node,t),bu(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 Zd(n,e,t,r,i){Ig(r,e,n);let o=new Fr(void 0,n,e,t,r,r,r,i,0);return o.contentDOM&&o.updateChildren(i,0),o}let Dg=class Tg extends Fr{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==zt||this.dirty!=ct&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=ct||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=ct,!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 Tg(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=zt)}get domAtom(){return!1}isText(e){return this.node.text==e}},Rg=class extends Xo{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==ct&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}};class Ek extends Fr{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==zt)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 Ag(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=yl.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 yl)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 Rk(n,e){return n.type.side-e.type.side}function Ak(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 bk(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 Ik(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 zu(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 af(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(Gl(t)){for(a=l;i&&!i.node;)i=i.parent;let c=i.node;if(i&&c.isAtom&&I.isSelectable(c)&&i.parent&&!(c.isInline&&ok(t.focusNode,t.focusOffset,i.dom))){let f=i.posBefore;u=new I(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(()=>{(!zg(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function Pk(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,me(r)+1):t.setStart(r,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!i&&!n.state.selection.visible&&_e&&gn<=11&&(r.disabled=!0,r.disabled=!1)}function Pg(n,e){if(e instanceof I){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(ih(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else ih(n)}function ih(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function uf(n,e,t,r){return n.someProp("createSelectionBetween",i=>i(n,e,t))||$.between(e,t,r)}function oh(n){return n.editable&&!n.hasFocus()?!1:Fg(n)}function Fg(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 Fk(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return rr(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Pu(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 nn(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function sh(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 nn(n,new $(r.$anchor,s))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let i=Pu(n.state,e);return i&&i instanceof I?nn(n,i):!1}else if(!(it&&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?I.isSelectable(o)?nn(n,new I(e<0?n.state.doc.resolve(i.pos-o.nodeSize):i)):Go?nn(n,new $(n.state.doc.resolve(e<0?l:l+o.nodeSize))):!1:!1}}else return!1;else{if(r instanceof I&&r.node.isInline)return nn(n,new $(e>0?r.$to:r.$from));{let i=Pu(n.state,e);return i?nn(n,i):!1}}}function Sl(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function no(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function pr(n,e){return e<0?Lk(n):$k(n)}function Lk(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i,o,s=!1;for(xt&&t.nodeType==1&&r0){if(t.nodeType!=1)break;{let l=t.childNodes[r-1];if(no(l,-1))i=t,o=--r;else if(l.nodeType==3)t=l,r=t.nodeValue.length;else break}}else{if(Lg(t))break;{let l=t.previousSibling;for(;l&&no(l,-1);)i=t.parentNode,o=me(l),l=l.previousSibling;if(l)t=l,r=Sl(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}s?Fu(n,t,r):i&&Fu(n,i,o)}function $k(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i=Sl(t),o,s;for(;;)if(r{n.state==i&&Kt(n)},50)}function lh(n,e){let t=n.state.doc.resolve(e);if(!(Ne||ak)&&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 ah(n,e,t){let r=n.state.selection;if(r instanceof $&&!r.empty||t.indexOf("s")>-1||it&&t.indexOf("m")>-1)return!1;let{$from:i,$to:o}=r;if(!i.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let s=Pu(n.state,e);if(s&&s instanceof I)return nn(n,s)}if(!i.parent.inlineContent){let s=e<0?i:o,l=r instanceof Ze?P.near(s,e):P.findFrom(s,e);return l?nn(n,l):!1}return!1}function uh(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 ch(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function Jk(n){if(!Ae||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;ch(n,r,"true"),setTimeout(()=>ch(n,r,"false"),20)}return!1}function _k(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function Wk(n,e){let t=e.keyCode,r=_k(e);if(t==8||it&&t==72&&r=="c")return uh(n,-1)||pr(n,-1);if(t==46&&!e.shiftKey||it&&t==68&&r=="c")return uh(n,1)||pr(n,1);if(t==13||t==27)return!0;if(t==37||it&&t==66&&r=="c"){let i=t==37?lh(n,n.state.selection.from)=="ltr"?-1:1:-1;return sh(n,i,r)||pr(n,i)}else if(t==39||it&&t==70&&r=="c"){let i=t==39?lh(n,n.state.selection.from)=="ltr"?1:-1:1;return sh(n,i,r)||pr(n,i)}else{if(t==38||it&&t==80&&r=="c")return ah(n,-1,r)||pr(n,-1);if(t==40||it&&t==78&&r=="c")return Jk(n)||ah(n,1,r)||pr(n,1);if(r==(it?"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")||fi.fromSchema(n.state.schema),l=Ug(),a=l.createElement("div");a.appendChild(s.serializeFragment(r,{document:l}));let u=a.firstChild,c,f=0;for(;u&&u.nodeType==1&&(c=Wg[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,` + */var gS=v,yS=Symbol.for("react.element"),SS=Symbol.for("react.fragment"),wS=Object.prototype.hasOwnProperty,kS=gS.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,vS={key:!0,ref:!0,__self:!0,__source:!0};function mm(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)wS.call(e,r)&&!vS.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:yS,type:n,key:o,ref:s,props:i,_owner:kS.current}}Yl.Fragment=SS;Yl.jsx=mm;Yl.jsxs=mm;sm.exports=Yl;var A=sm.exports;function de(n){this.content=n}de.prototype={constructor:de,find:function(n){for(var e=0;e>1}};de.from=function(n){if(n instanceof de)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new de(e)};function gm(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=gm(i.content,o.content,t+1);if(s!=null)return s}t+=i.nodeSize}}function ym(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?us(r+1,s):us(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}}_.none=[];class On extends Error{}class k{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=wm(this.content,e+this.openStart,t);return r&&new k(r,this.openStart,this.openEnd)}removeBetween(e,t){return new k(Sm(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 k.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 k(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 k(e,r,i)}}k.empty=new k(x.empty,0,0);function Sm(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(Sm(o.content,e-i-1,t-i-1)))}function wm(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=wm(s.content,e-o-1,t);return l&&n.replaceChild(i,s.copy(l))}function xS(n,e,t){if(t.openStart>n.depth)throw new On("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new On("Inconsistent open depths");return km(n,e,t,0)}function km(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 Zi(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&&(Yn(n.nodeAfter,r),o++));for(let l=o;li&&vu(n,e,i+1),s=r.depth>i&&vu(t,r,i+1),l=[];return Zi(null,n,i,l),o&&s&&e.index(i)==t.index(i)?(vm(o,s),Yn(Gn(o,xm(n,e,t,r,i+1)),l)):(o&&Yn(Gn(o,dl(n,e,i+1)),l),Zi(e,t,i,l),s&&Yn(Gn(s,dl(t,r,i+1)),l)),Zi(r,null,i,l),new x(l)}function dl(n,e,t){let r=[];if(Zi(null,n,t,r),n.depth>t){let i=vu(n,e,t+1);Yn(Gn(i,dl(n,e,t+1)),r)}return Zi(e,null,t,r),new x(r)}function CS(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 ES(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=xd.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()+")"),Cm(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 hl 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):Cm(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 hl(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new hl(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 Cm(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class nr{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new DS(e,t);if(r.next==null)return nr.empty;let i=Nm(r);r.next&&r.err("Unexpected trailing text");let o=PS(zS(i));return FS(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(` +`)}}nr.empty=new nr(!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 Nm(n){let e=[];do e.push(TS(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function TS(n){let e=[];do e.push(RS(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function RS(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=AS(n,e);else break;return e}function Cd(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function AS(n,e){let t=Cd(n),r=t;return n.eat(",")&&(n.next!="}"?r=Cd(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function bS(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=Nm(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=bS(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 zS(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 nr(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 Rm(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 LS(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 $S{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?LS(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=Tm(e,i.attrs),this.excluded=null;let o=Em(this.attrs);this.instance=o?new _(this,o):null}create(e=null){return!e&&this.instance?this.instance:new _(this,Om(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 Am{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=de.from(e.nodes),t.marks=de.from(e.marks||{}),this.nodes=Md.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]=nr.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?Ed(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==""?[]:Ed(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 Md){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 hl(r,r.defaultAttrs,e,_.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 _.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function Ed(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 VS(n){return n.tag!=null}function BS(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(VS(i))this.tags.push(i);else if(BS(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 Dd(this,t,!1);return r.addAll(e,_.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new Dd(this,t,!0);return r.addAll(e,_.none,t.from,t.to),k.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=Td(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=Td(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 bm={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},JS={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Im={ol:!0,ul:!0},pl=1,ml=2,eo=4;function Od(n,e,t){return e!=null?(e?pl:0)|(e==="full"?ml:0):n&&n.whitespace=="pre"?pl|ml:t&~eo}class cs{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=_.none,this.match=o||(s&eo?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&pl)){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&&!bm.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Dd{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0;let i=t.topNode,o,s=Od(null,t.preserveWhitespace,0)|(r?eo:0);i?o=new cs(i.type,i.attrs,_.none,!0,t.topMatch||i.type.contentMatch,s):r?o=new cs(null,null,_.none,!0,null,s):o=new cs(e.schema.topNodeType,null,_.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&ml||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(i.options&pl)i.options&ml?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;Im.hasOwnProperty(i)&&this.parser.normalizeLists&&_S(e);let s=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,r));if(s?s.ignore:JS.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(bm.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):Rd(u.type,e))?(a=u.addToSet(a),!1):!0),this.nodes.push(new cs(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 _S(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Im.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function WS(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function Td(n){let e={};for(let t in n)e[t]=n[t];return e}function Rd(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&&Ls(ka(r),i(e,t),null,e.attrs)}static renderSpec(e,t,r=null,i){return Ls(e,t,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new fi(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Ad(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return Ad(e.marks)}}function Ad(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function ka(n){return n.document||window.document}const bd=new WeakMap;function US(n){let e=bd.get(n);return e===void 0&&bd.set(n,e=HS(n)),e}function HS(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}=Ls(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 zm=65535,Pm=Math.pow(2,16);function jS(n,e){return n+e*Pm}function Id(n){return n&zm}function KS(n){return(n-(n&zm))/Pm}const Fm=1,Lm=2,$s=4,$m=8;let zd=class{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&$m)>0}get deletedBefore(){return(this.delInfo&(Fm|$s))>0}get deletedAfter(){return(this.delInfo&(Lm|$s))>0}get deletedAcross(){return(this.delInfo&$s)>0}},Hr=class gr{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&gr.empty)return gr.empty}recover(e){let t=0,r=Id(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:jS(l/3,e-a),m=e==a?Lm:e==f?Fm:$s;return(t<0?e!=a:e!=f)&&(m|=$m),new zd(p,m,h)}i+=c-u}return r?e+i:new zd(e+i,0,null)}touches(e,t){let r=0,i=Id(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 Le.fromReplace(e,this.from,this.to,o)}invert(){return new Bm(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 Oi(t.pos,r.pos,this.mark)}merge(e){return e instanceof Oi&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Oi(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 Oi(t.from,t.to,e.markFromJSON(t.mark))}};je.jsonID("addMark",Vm);let Bm=class Di extends je{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 k(Yc(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return Le.fromReplace(e,this.from,this.to,r)}invert(){return new Vm(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))}};je.jsonID("removeMark",Bm);let Jm=class Ti extends je{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Le.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return Le.fromReplace(e,this.pos,this.pos+1,new k(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 Vs(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 Vs(t.from,t.to,t.gapFrom,t.gapTo,k.fromJSON(e,t.slice),t.insert,!!t.structure)}};je.jsonID("replaceAround",gl);function Cu(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 Xc(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 Wm(n,e){let t=n.resolve(e),r=t.index();return QS(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function QS(n,e){return!!(n&&e&&!n.isLeaf&&n.canAppend(e))}function Um(n,e,t=e,r=k.empty){if(e==t&&!r.size)return null;let i=n.resolve(e),o=n.resolve(t);return YS(i,o,r)?new Gc(e,t,r):new GS(i,o,r).fit()}function YS(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}let GS=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 k(o,s,l);return e>-1?new gl(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new Gc(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=xa(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=xa(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new k(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=xa(e,t);if(i.childCount<=1&&t>0){let o=e.size-t<=t+i.size;this.unplaced=new k(Ri(e,t-1,1),t-1,o?t-1:r)}else this.unplaced=new k(Ri(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(Hm(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=Ai(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=Ca(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=Ai(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=Ai(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=Ai(this.placed,this.frontier.length,t))}};function Ri(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Ri(n.firstChild.content,e-1,t)))}function Ai(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Ai(n.lastChild.content,e-1,t)))}function xa(n,e){for(let t=0;t1&&(r=r.replaceChild(0,Hm(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 Ca(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&&!XS(t,o.content,s)?l:null}function XS(n,e,t){for(let r=t;r0}get deletedBefore(){return(this.delInfo&(qm|_s))>0}get deletedAfter(){return(this.delInfo&(Qm|_s))>0}get deletedAcross(){return(this.delInfo&_s)>0}},jr=class yr{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&yr.empty)return yr.empty}recover(e){let t=0,r=Pd(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:ew(l/3,e-a),m=e==a?Qm:e==f?qm:_s;return(t<0?e!=a:e!=f)&&(m|=Ym),new Nu(p,m,h)}i+=c-u}return r?e+i:new Nu(e+i,0,null)}touches(e,t){let r=0,i=Pd(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 Ws;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 $e.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))}};Ke.jsonID("addMark",ef);let qo=class zi 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 k(Zc(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 ef(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 zi(t.pos,r.pos,this.mark)}merge(e){return e instanceof zi&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new zi(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 zi(t.from,t.to,e.markFromJSON(t.mark))}};Ke.jsonID("removeMark",qo);let tf=class Pi 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 k(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 Us(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 Us(t.from,t.to,t.gapFrom,t.gapTo,k.fromJSON(e,t.slice),t.insert,!!t.structure)}};Ke.jsonID("replaceAround",ur);function Eu(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 rw(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 iw(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 ow(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 sw(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 ur(i,o,i,o,new k(r,0,0),t.length,!0))}function aw(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)&&uw(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 ur(u,c,u+1,c-1,new k(x.from(r.create(i,null,s.marks)),0,0),1,!0)),!1}})}function uw(n,e,t){let r=n.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,t)}function cw(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 ur(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new k(x.from(s),0,0),1,!0))}function fw(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 Rn(e,e,new k(o.append(s),t,t),!0))}function dw(n,e,t){let r=new Rn(e-t,e+t,k.empty,!0);n.step(r)}function hw(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 k(o,s,l);return e>-1?new ur(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new Rn(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=Ma(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=Ma(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new k(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=Ma(e,t);if(i.childCount<=1&&t>0){let o=e.size-t<=t+i.size;this.unplaced=new k(Fi(e,t-1,1),t-1,o?t-1:r)}else this.unplaced=new k(Fi(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(Xm(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=Li(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=Ea(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=Li(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=Li(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=Li(this.placed,this.frontier.length,t))}};function Fi(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Fi(n.firstChild.content,e-1,t)))}function Li(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Li(n.lastChild.content,e-1,t)))}function Ma(n,e){for(let t=0;t1&&(r=r.replaceChild(0,Xm(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 Ea(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&&!gw(t,o.content,s)?l:null}function gw(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=yw(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 Zm(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 ww(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let i=hw(n.doc,e,r.type);i!=null&&(e=t=i)}n.replaceRange(e,t,new k(x.from(r),0,0))}function kw(n,e,t){let r=n.doc.resolve(e),i=n.doc.resolve(t),o=eg(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 eg(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 tg=class Hs extends Ke{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 $e.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 $e.fromReplace(e,this.pos,this.pos+1,new k(x.from(i),0,t.isLeaf?0:1))}getMap(){return jr.empty}invert(e){return new Hs(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 Hs(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 Hs(t.pos,t.attr,t.value)}};Ke.jsonID("attr",tg);let Kr=class extends Error{};Kr=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};Kr.prototype=Object.create(Error.prototype);Kr.prototype.constructor=Kr;Kr.prototype.name="TransformError";let vw=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new nw}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Kr(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=k.empty){let i=pw(this.doc,e,t,r);return i&&this.step(i),this}replaceWith(e,t,r){return this.replace(e,t,new k(x.from(r),0,0))}delete(e,t){return this.replace(e,t,k.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return Sw(this,e,t,r),this}replaceRangeWith(e,t,r){return ww(this,e,t,r),this}deleteRange(e,t){return kw(this,e,t),this}lift(e,t){return sw(this,e,t),this}join(e,t=1){return dw(this,e,t),this}wrap(e,t){return lw(this,e,t),this}setBlockType(e,t=e,r,i=null){return aw(this,e,t,r,i),this}setNodeMarkup(e,t,r=null,i){return cw(this,e,t,r,i),this}setNodeAttribute(e,t,r){return this.step(new tg(e,t,r)),this}addNodeMark(e,t){return this.step(new tf(e,t)),this}removeNodeMark(e,t){if(!(t instanceof _)){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 nf(e,t)),this}split(e,t=1,r){return fw(this,e,t,r),this}addMark(e,t,r){return rw(this,e,t,r),this}removeMark(e,t,r){return iw(this,e,t,r),this}clearIncompatible(e,t,r){return ow(this,e,t,r),this}};const Oa=Object.create(null);class P{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new ng(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?Sr(e.node(0),e.node(o),e.before(o+1),e.index(o),t,r):Sr(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 Ze(e.node(0))}static atStart(e){return Sr(e,e,0,0,1)||new Ze(e)}static atEnd(e){return Sr(e,e,e.content.size,e.childCount,-1)||new Ze(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Oa[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 Oa)throw new RangeError("Duplicate use of selection JSON ID "+e);return Oa[e]=t,t.prototype.jsonID=e,t}getBookmark(){return $.between(this.$anchor,this.$head).getBookmark()}}P.prototype.visible=!0;class ng{constructor(e,t){this.$from=e,this.$to=t}}let Fd=!1;function Ld(n){!Fd&&!n.parent.inlineContent&&(Fd=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class $ extends P{constructor(e,t=e){Ld(e),Ld(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=k.empty){if(super.replace(e,t),t==k.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 Gl(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&&I.isSelectable(l))return I.create(n,t-(i<0?l.nodeSize:0))}else{let a=Sr(n,l,t+i,i<0?l.childCount:0,i,o);if(a)return a}t+=l.nodeSize*i}return null}function $d(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 Vd=1,fs=2,Bd=4;class Cw extends vw{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|=fs,this}ensureMarks(e){return _.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&fs)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~fs,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)||_.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|=Bd,this}get scrolledIntoView(){return(this.updated&Bd)>0}}function Jd(n,e){return!e||!n?n:n.bind(e)}class $i{constructor(e,t,r){this.name=e,this.init=Jd(t.init,r),this.apply=Jd(t.apply,r)}}const Nw=[new $i("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new $i("selection",{init(n,e){return n.selection||P.atStart(e.doc)},apply(n){return n.selection}}),new $i("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new $i("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=Nw.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 $i(r.key,r.spec.state,r))})}}class fn{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 fn(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 rg(n,e,t){for(let r in n){let i=n[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=rg(i,e,{})),t[r]=i}return t}class Lt{constructor(e){this.spec=e,this.props={},e.props&&rg(e.props,this,this.props),this.key=e.key?e.key.key:ig("plugin")}getState(e){return e[this.key]}}const Ta=Object.create(null);function ig(n){return n in Ta?n+"$"+ ++Ta[n]:(Ta[n]=0,n+"$")}class Qo{constructor(e="key"){this.key=ig(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const og=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function Mw(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const Ew=(n,e,t)=>{let r=Mw(n,t);if(!r)return!1;let i=sg(r);if(!i){let s=r.blockRange(),l=s&&Xc(s);return l==null?!1:(e&&e(n.tr.lift(s,l).scrollIntoView()),!0)}let o=i.nodeBefore;if(!o.type.spec.isolating&&ag(n,i,e))return!0;if(r.parent.content.size==0&&(qr(o,"end")||I.isSelectable(o))){let s=Um(n.doc,r.before(),r.after(),k.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=sg(r)}let s=o&&o.nodeBefore;return!s||!I.isSelectable(s)?!1:(e&&e(n.tr.setSelection(I.create(n.doc,o.pos-s.nodeSize)).scrollIntoView()),!0)};function sg(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=lg(r);if(!i)return!1;let o=i.nodeAfter;if(ag(n,i,e))return!0;if(r.parent.content.size==0&&(qr(o,"start")||I.isSelectable(o))){let s=Um(n.doc,r.before(),r.after(),k.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 of(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=of(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 Ze||r.parent.inlineContent||i.parent.inlineContent)return!1;let o=of(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(Bs(n.doc,o))return e&&e(n.tr.split(o).scrollIntoView()),!0}let r=t.blockRange(),i=r&&Xc(r);return i==null?!1:(e&&e(n.tr.lift(r,i).scrollIntoView()),!0)};function Pw(n){return(e,t)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof I&&e.selection.node.isBlock)return!r.parentOffset||!Bs(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 Ze)&&s.deleteSelection();let l=r.depth==0?null:of(r.node(-1).contentMatchAt(r.indexAfter(-1))),a=o&&l?[{type:l}]:void 0,u=Bs(s.doc,s.mapping.map(r.pos),1,a);if(!a&&!u&&Bs(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 Fw=Pw(),Lw=(n,e)=>(e&&e(n.tr.setSelection(new Ze(n.doc))),!0);function $w(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||Wm(n.doc,e.pos))?!1:(t&&t(n.tr.clearIncompatible(e.pos,r.type,r.contentMatchAt(r.childCount)).join(e.pos).scrollIntoView()),!0)}function ag(n,e,t){let r=e.nodeBefore,i=e.nodeAfter,o,s;if(r.type.spec.isolating||i.type.spec.isolating)return!1;if($w(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 gl(e.pos-1,f,e.pos,f,new k(d,1,0),o.length,!0)),h=f+2*o.length;Wm(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&&Xc(u);if(c!=null&&c>=e.depth)return t&&t(n.tr.lift(u,c).scrollIntoView()),!0;if(l&&qr(i,"start",!0)&&qr(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 gl(e.pos-d.length,e.pos+i.nodeSize,e.pos+h,e.pos+i.nodeSize-h,new k(m,d.length,0),0,!0));t(w.scrollIntoView())}return!0}}return!1}function ug(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 Vw=ug(-1),Bw=ug(1);function Jw(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 _d(n,e=null){return function(t,r){let{empty:i,$cursor:o,ranges:s}=t.selection;if(i&&!o||!Jw(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:'"'},Ud=typeof navigator<"u"&&/Chrome\/(\d+)/.exec(navigator.userAgent),Uw=typeof navigator<"u"&&/Mac/.test(navigator.platform),Hw=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),jw=Uw||Ud&&+Ud[1]<57;for(var pe=0;pe<10;pe++)bt[48+pe]=bt[96+pe]=String(pe);for(var pe=1;pe<=24;pe++)bt[pe+111]="F"+pe;for(var pe=65;pe<=90;pe++)bt[pe]=String.fromCharCode(pe+32),yl[pe]=String.fromCharCode(pe);for(var Aa in bt)yl.hasOwnProperty(Aa)||(yl[Aa]=bt[Aa]);function lf(n){var e=jw&&(n.ctrlKey||n.altKey||n.metaKey)||Hw&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?yl:bt)[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 Kw=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=bt[r.keyCode])&&o!=i){let l=e[ba(o,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}const fg=65535,dg=Math.pow(2,16);function Gw(n,e){return n+e*dg}function Hd(n){return n&fg}function Xw(n){return(n-(n&fg))/dg}const hg=1,pg=2,js=4,mg=8;let jd=class{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&mg)>0}get deletedBefore(){return(this.delInfo&(hg|js))>0}get deletedAfter(){return(this.delInfo&(pg|js))>0}get deletedAcross(){return(this.delInfo&js)>0}},Qr=class wr{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&wr.empty)return wr.empty}recover(e){let t=0,r=Hd(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:Gw(l/3,e-a),m=e==a?pg:e==f?hg:js;return(t<0?e!=a:e!=f)&&(m|=mg),new jd(p,m,h)}i+=c-u}return r?e+i:new jd(e+i,0,null)}touches(e,t){let r=0,i=Hd(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 Ve.fromReplace(e,this.from,this.to,o)}invert(){return new yg(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 Bi(t.pos,r.pos,this.mark)}merge(e){return e instanceof Bi&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Bi(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 Bi(t.from,t.to,e.markFromJSON(t.mark))}};qe.jsonID("addMark",gg);let yg=class Ji 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 k(af(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 gg(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))}};qe.jsonID("removeMark",yg);let Sg=class _i 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 k(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 Ks(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 Ks(t.from,t.to,t.gapFrom,t.gapTo,k.fromJSON(e,t.slice),t.insert,!!t.structure)}};qe.jsonID("replaceAround",ek);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 tk(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 nk=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 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 k(x.from(i),0,t.isLeaf?0:1))}getMap(){return Qr.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",nk);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 me=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 Tu=null;const Jt=function(n,e,t){let r=Tu||(Tu=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},rk=function(){Tu=null},rr=function(n,e,t,r){return t&&(Kd(n,e,t,r,-1)||Kd(n,e,t,r,1))},ik=/^(img|br|input|textarea|hr)$/i;function Kd(n,e,t,r,i){for(;;){if(n==t&&e==r)return!0;if(e==(i<0?0:lt(n))){let o=n.parentNode;if(!o||o.nodeType!=1||Yo(n)||ik.test(n.nodeName)||n.contentEditable=="false")return!1;e=me(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?lt(n):0}else return!1}}function lt(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function ok(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=lt(n)}else if(n.parentNode&&!Yo(n))e=me(n),n=n.parentNode;else return null}}function sk(n,e){for(;;){if(n.nodeType==3&&e2),it=Yr||(It?/Mac/.test(It.platform):!1),ck=It?/Win/.test(It.platform):!1,St=/Android \d/.test(An),Go=!!qd&&"webkitFontSmoothing"in qd.documentElement.style,fk=Go?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function dk(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 Vt(n,e){return typeof n=="number"?n:n[e]}function hk(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 Qd(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?dk(o):hk(l),c=0,f=0;if(e.topu.bottom-Vt(r,"bottom")&&(f=e.bottom-e.top>u.bottom-u.top?e.top+Vt(i,"top")-u.top:e.bottom-u.bottom+Vt(i,"bottom")),e.leftu.right-Vt(r,"right")&&(c=e.right-u.right+Vt(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 pk(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:xg(n.dom)}}function xg(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 mk({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;Cg(t,r==0?0:r-e)}function Cg(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?yk(t,i):!t||r&&t.nodeType==1?{node:n,offset:o}:Ng(t,i)}function yk(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 uf(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function Sk(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 kk(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 Mg(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=kk(n,r,i,e))}l==null&&(l=wk(n,s,e));let a=n.docView.nearestDesc(s,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Yd(n){return n.top=0&&i==r.nodeValue.length?(a--,c=1):t<0?a--:u++,yi(tn(Jt(r,a,u),c),c<0)}if(!n.state.doc.resolve(e-(o||0)).parent.inlineContent){if(o==null&&i&&(t<0||i==lt(r))){let a=r.childNodes[i-1];if(a.nodeType==1)return za(a.getBoundingClientRect(),!1)}if(o==null&&i=0)}if(o==null&&i&&(t<0||i==lt(r))){let a=r.childNodes[i-1],u=a.nodeType==3?Jt(a,lt(a)-(s?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(u)return yi(tn(u,1),!1)}if(o==null&&i=0)}function yi(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 za(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 Og(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 Ck(n,e,t){let r=e.selection,i=t=="up"?r.$from:r.$to;return Og(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=Eg(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=Jt(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 Nk=/[\u0590-\u08ac]/;function Mk(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?!Nk.test(r.parent.textContent)||!l.modify?t=="left"||t=="backward"?o:s:Og(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 Gd=null,Xd=null,Zd=!1;function Ek(n,e,t){return Gd==e&&Xd==t?Zd:(Gd=e,Xd=t,Zd=t=="up"||t=="down"?Ck(n,e,t):Mk(n,e,t))}const ct=0,eh=1,Hn=2,zt=3;let Xo=class{constructor(e,t,r,i){this.parent=e,this.children=t,this.dom=r,this.contentDOM=i,this.dirty=ct,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;tme(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 bg){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 Dg&&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?me(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=me(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?Hn:eh,e==l&&t==a&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=zt:o.markDirty(e-l,t-l);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?Hn:zt}r=s}this.dirty=Hn}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?Hn:eh;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==ct&&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}},Ok=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}},Sl=class Iu 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=fi.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new Iu(e,t,s.dom,s.contentDOM||s.dom)}parseRule(){return this.dirty&zt||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=zt&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=ct){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty0&&(o=Fu(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}=fi.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=Pg(c,r,t),u?a=new Dk(e,t,r,i,c,f||null,d,u,o,s+1):t.isText?new Rg(e,t,r,i,c,d,o):new Tg(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==ct&&e.eq(this.node)&&Pu(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 Rk(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?_.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==Hn)&&(s&&this.protectLocalComposition(e,s),Ig(this.contentDOM,this.children,e),Yr&&zk(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=Pk(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 Ok(this,o,t,i);e.input.compositionNodes.push(s),this.children=Fu(this.children,r,r+i.length,e,s)}update(e,t,r,i){return this.dirty==zt||!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=ct}updateOuterDeco(e){if(Pu(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=zg(this.dom,this.nodeDOM,zu(this.outerDeco,this.node,t),zu(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 th(n,e,t,r,i){Pg(r,e,n);let o=new Fr(void 0,n,e,t,r,r,r,i,0);return o.contentDOM&&o.updateChildren(i,0),o}let Rg=class Ag extends Fr{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==zt||this.dirty!=ct&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=ct||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=ct,!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 Ag(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=zt)}get domAtom(){return!1}isText(e){return this.node.text==e}},bg=class extends Xo{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==ct&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}};class Dk extends Fr{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==zt)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 Ig(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=Sl.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 Sl)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 bk(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 zk(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 Pk(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 Fu(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 cf(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(Xl(t)){for(a=l;i&&!i.node;)i=i.parent;let c=i.node;if(i&&c.isAtom&&I.isSelectable(c)&&i.parent&&!(c.isInline&&lk(t.focusNode,t.focusOffset,i.dom))){let f=i.posBefore;u=new I(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(()=>{(!Fg(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function Lk(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,me(r)+1):t.setStart(r,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!i&&!n.state.selection.visible&&_e&&yn<=11&&(r.disabled=!0,r.disabled=!1)}function Lg(n,e){if(e instanceof I){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(sh(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else sh(n)}function sh(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function ff(n,e,t,r){return n.someProp("createSelectionBetween",i=>i(n,e,t))||$.between(e,t,r)}function lh(n){return n.editable&&!n.hasFocus()?!1:$g(n)}function $g(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 $k(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return rr(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Lu(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 nn(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function ah(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 nn(n,new $(r.$anchor,s))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let i=Lu(n.state,e);return i&&i instanceof I?nn(n,i):!1}else if(!(it&&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?I.isSelectable(o)?nn(n,new I(e<0?n.state.doc.resolve(i.pos-o.nodeSize):i)):Go?nn(n,new $(n.state.doc.resolve(e<0?l:l+o.nodeSize))):!1:!1}}else return!1;else{if(r instanceof I&&r.node.isInline)return nn(n,new $(e>0?r.$to:r.$from));{let i=Lu(n.state,e);return i?nn(n,i):!1}}}function wl(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function no(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function pr(n,e){return e<0?Vk(n):Bk(n)}function Vk(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i,o,s=!1;for(xt&&t.nodeType==1&&r0){if(t.nodeType!=1)break;{let l=t.childNodes[r-1];if(no(l,-1))i=t,o=--r;else if(l.nodeType==3)t=l,r=t.nodeValue.length;else break}}else{if(Vg(t))break;{let l=t.previousSibling;for(;l&&no(l,-1);)i=t.parentNode,o=me(l),l=l.previousSibling;if(l)t=l,r=wl(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}s?$u(n,t,r):i&&$u(n,i,o)}function Bk(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i=wl(t),o,s;for(;;)if(r{n.state==i&&Kt(n)},50)}function uh(n,e){let t=n.state.doc.resolve(e);if(!(Ne||ck)&&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 ch(n,e,t){let r=n.state.selection;if(r instanceof $&&!r.empty||t.indexOf("s")>-1||it&&t.indexOf("m")>-1)return!1;let{$from:i,$to:o}=r;if(!i.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let s=Lu(n.state,e);if(s&&s instanceof I)return nn(n,s)}if(!i.parent.inlineContent){let s=e<0?i:o,l=r instanceof Ze?P.near(s,e):P.findFrom(s,e);return l?nn(n,l):!1}return!1}function fh(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 dh(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function Wk(n){if(!Ae||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;dh(n,r,"true"),setTimeout(()=>dh(n,r,"false"),20)}return!1}function Uk(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function Hk(n,e){let t=e.keyCode,r=Uk(e);if(t==8||it&&t==72&&r=="c")return fh(n,-1)||pr(n,-1);if(t==46&&!e.shiftKey||it&&t==68&&r=="c")return fh(n,1)||pr(n,1);if(t==13||t==27)return!0;if(t==37||it&&t==66&&r=="c"){let i=t==37?uh(n,n.state.selection.from)=="ltr"?-1:1:-1;return ah(n,i,r)||pr(n,i)}else if(t==39||it&&t==70&&r=="c"){let i=t==39?uh(n,n.state.selection.from)=="ltr"?1:-1:1;return ah(n,i,r)||pr(n,i)}else{if(t==38||it&&t==80&&r=="c")return ch(n,-1,r)||pr(n,-1);if(t==40||it&&t==78&&r=="c")return Wk(n)||ch(n,1,r)||pr(n,1);if(r==(it?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function Bg(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")||fi.fromSchema(n.state.schema),l=jg(),a=l.createElement("div");a.appendChild(s.serializeFragment(r,{document:l}));let u=a.firstChild,c,f=0;for(;u&&u.nodeType==1&&(c=Hg[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 Vg(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 k(x.from(n.state.schema.text(e.replace(/\r\n?/g,` -`))),0,0):k.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=fi.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=Kk(t),Go&&qk(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&&!Uk.test(d.parentNode.nodeName)?{ignore:!0}:null}})),c)l=Qk(fh(l,+c[1],+c[2]),c[4]);else if(l=k.maxOpen(Hk(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 Uk=/^(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 Hk(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&&Jg(a,o,l,s[s.length-1],0))s[s.length-1]=u;else{s.length&&(s[s.length-1]=_g(s[s.length-1],o.length));let c=Bg(l,a);s.push(c),i=i.matchType(c.type),o=a}}),s)return x.from(s)}return n}function Bg(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,x.from(n));return n}function Jg(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 fh(n,e,t){return et}).createHTML(n):n}function Kk(n){let e=/^(\s*]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Ug().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),i;if((i=r&&Wg[r[1].toLowerCase()])&&(n=i.map(o=>"<"+o+">").join("")+n+i.map(o=>"").reverse().join("")),t.innerHTML=jk(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 k(i,o,s)}const be={},Ie={},Yk={touchstart:!0,touchmove:!0};class Gk{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 Xk(n){for(let e in be){let t=be[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{ev(n,r)&&!cf(n,r)&&(n.editable||!(r.type in Ie))&&t(n,r)},Yk[e]?{passive:!0}:void 0)}Ae&&n.dom.addEventListener("input",()=>null),$u(n)}function fn(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function Zk(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=>cf(n,r))})}function cf(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function ev(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 tv(n,e){!cf(n,e)&&be[e.type]&&(n.editable||!(e.type in Ie))&&be[e.type](n,e)}Ie.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!jg(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(St&&Ne&&t.keyCode==13)))if(n.domObserver.selectionChanged(n.domSelectionRange())?n.domObserver.flush():t.keyCode!=229&&n.domObserver.forceFlush(),Yr&&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,Wn(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||Wk(n,t)?t.preventDefault():fn(n,"key")};Ie.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};Ie.keypress=(n,e)=>{let t=e;if(jg(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||it&&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 Xl(n){return{left:n.clientX,top:n.clientY}}function nv(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function ff(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 Lr(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 rv(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&I.isSelectable(r)?(Lr(n,new I(t)),!0):!1}function iv(n,e){if(e==-1)return!1;let t=n.state.selection,r,i;t instanceof I&&(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(I.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?(Lr(n,I.create(n.state.doc,i)),!0):!1}function ov(n,e,t,r,i){return ff(n,"handleClickOn",e,t,r)||n.someProp("handleClick",o=>o(n,e,r))||(i?iv(n,t):rv(n,t))}function sv(n,e,t,r){return ff(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",i=>i(n,e,r))}function lv(n,e,t,r){return ff(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",i=>i(n,e,r))||av(n,t,r)}function av(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(Lr(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)Lr(n,$.create(r,l+1,l+1+s.content.size));else if(I.isSelectable(s))Lr(n,I.create(r,l));else continue;return!0}}function df(n){return wl(n)}const Hg=it?"metaKey":"ctrlKey";be.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=df(n),i=Date.now(),o="singleClick";i-n.input.lastClick.time<500&&nv(t,n.input.lastClick)&&!t[Hg]&&(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(Xl(t));s&&(o=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new uv(n,s,t,!!r)):(o=="doubleClick"?sv:lv)(n,s.pos,s.inside,t)?t.preventDefault():fn(n,"pointer"))};class uv{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[Hg],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 I&&u.from<=s&&u.to>s)&&(this.mightDrag={node:o,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&xt&&!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)),fn(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(()=>Kt(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(Xl(e))),this.updateAllowDefault(e),this.allowDefault||!t?fn(this.view,"pointer"):ov(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Ae&&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)?(Lr(this.view,P.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):fn(this.view,"pointer")}move(e){this.updateAllowDefault(e),fn(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)}}be.touchstart=n=>{n.input.lastTouch=Date.now(),df(n),fn(n,"pointer")};be.touchmove=n=>{n.input.lastTouch=Date.now(),fn(n,"pointer")};be.contextmenu=n=>df(n);function jg(n,e){return n.composing?!0:Ae&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const cv=St?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(),wl(n,!0),n.markCursor=null;else if(wl(n,!e.selection.empty),xt&&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}Kg(n,cv)};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++,Kg(n,20))};function Kg(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>wl(n),e))}function qg(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=dv());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function fv(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=rk(e.focusNode,e.focusOffset),r=ik(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 dv(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function wl(n,e=!1){if(!(St&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),qg(n),e||n.docView&&n.docView.dirty){let t=af(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 hv(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=_e&&gn<15||Yr&&uk<604;be.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)):hv(n,l),i&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function pv(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function mv(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=Vg(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,i,o||k.empty)))return!0;if(!o)return!1;let s=pv(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 Qg(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&&!St)return;let r=vo?null:t.clipboardData,i=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&xo(n,Qg(r),r.getData("text/html"),i,t)?t.preventDefault():mv(n,t)};class Yg{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}}const Gg=it?"altKey":"ctrlKey";be.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(Xl(t)),s;if(!(o&&o.pos>=i.from&&o.pos<=(i instanceof I?i.to-1:i.to))){if(r&&r.mightDrag)s=I.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=I.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||wg>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 Yg(c,!t[Gg],s)};be.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(Xl(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=Vg(n,Qg(t.dataTransfer),vo?null:t.dataTransfer.getData("text/html"),!1,o);let l=!!(r&&!t[Gg]);if(n.someProp("handleDrop",h=>h(n,t,s||k.empty,l))){t.preventDefault();return}if(!s)return;t.preventDefault();let a=s?Zw(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&&I.isSelectable(s.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(s.content.firstChild))u.setSelection(new I(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(uf(n,p,u.doc.resolve(h)))}n.focus(),n.dispatch(u.setMeta("uiEvent","drop"))};be.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())&&Kt(n)},20))};be.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)};be.beforeinput=(n,e)=>{if(Ne&&St&&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,Wn(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)be[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 kl{constructor(e,t){this.toDOM=e,this.spec=t||Xn,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 ge(o-r,o-r,this)}valid(){return!0}eq(e){return this==e||e instanceof kl&&(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 yn{constructor(e,t){this.attrs=e,this.spec=t||Xn}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 ge(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||Xn)}mapInner(e,t,r,i,o){let s;for(let l=0;l{let u=a+r,c;if(c=ey(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 yn){let u=Math.max(o,a.from)-o,c=Math.min(s,a.to)-o;ui.map(e,t,Xn));return vr.from(r)}forChild(e,t){if(t.isLeaf)return J.empty;let r=[];for(let i=0;it instanceof J)?e:e.reduce((t,r)=>t.concat(r instanceof J?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=yv(l,n,e,t,i,o,s),c=vl(u,r,0,s);e=c.local;for(let f=0;ft&&s.to{let u=ey(n,l,a+t);if(u){o=!0;let c=vl(u,l,t+a+1,r);c!=xe&&i.push(a,a+l.nodeSize,c)}});let s=Zg(o?ty(n):n,-t).sort(Zn);for(let l=0;l0;)e++;n.splice(e,0,t)}function Pa(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=xe&&e.push(r)}),n.cursorWrapper&&e.push(J.create(n.state.doc,[n.cursorWrapper.deco])),Xg.from(e)}const Sv={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},wv=_e&&gn<=11;let kv=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 vv{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new kv,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()}),wv&&(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,Sv)),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(oh(this.view)){if(this.suppressingSelectionUpdates)return Kt(this.view);if(_e&&gn<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&rr(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)&&oh(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||Nv(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),xv(e)),this.handleDOMChange(o,s,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Kt(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:Ev,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 Ev(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(Ae&&/^(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||Ae&&/^(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 Ov=/^(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 Dv(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,z=af(n,b);if(z&&!n.state.selection.eq(z)){if(Ne&&St&&n.input.lastKeyCode===13&&Date.now()-100$t(n,Wn(13,"Enter"))))return;let le=n.state.tr.setSelection(z);b=="pointer"?le.setMeta("pointer",!0):b=="key"&&le.scrollIntoView(),o&&le.setMeta("composition",o),n.dispatch(le)}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=Mv(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||St)&&i.some(b=>b.nodeType==1&&!Ov.test(b.nodeName))&&(!h||h.endA>=h.endB)&&n.someProp("handleKeyDown",b=>b(n,Wn(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=yh(n,n.state.doc,u.sel);if(b&&!b.eq(n.state.selection)){let z=n.state.tr.setSelection(b);o&&z.setMeta("composition",o),n.dispatch(z)}}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)),_e&&gn<=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((Yr&&n.input.lastIOSEnter>Date.now()-225&&(!y||i.some(b=>b.nodeName=="DIV"||b.nodeName=="P"))||!y&&m.posb(n,Wn(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>h.start&&Rv(c,h.start,h.endA,m,w)&&n.someProp("handleKeyDown",b=>b(n,Wn(8,"Backspace")))){St&&Ne&&n.domObserver.suppressSelectionUpdates();return}Ne&&St&&h.endB==h.start&&(n.input.lastAndroidDelete=Date.now()),St&&!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,Wn(13,"Enter"))})},20));let C=h.start,N=h.endA,E,O,T;if(y){if(m.pos==w.pos)_e&&gn<=11&&m.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>Kt(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=Tv(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",z=>z(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=yh(n,E.doc,u.sel);b&&!(Ne&&St&&n.composing&&b.empty&&(h.start!=h.endB||n.input.lastAndroidDeletee.content.size?null:uf(n,e.resolve(t.anchor),e.resolve(t.head))}function Tv(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||Fa(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 Av(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 bv{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 Gk,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Ch),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=vh(this),kh(this),this.nodeViews=xh(this),this.docView=Zd(this.state.doc,wh(this),Pa(this),this.dom,this),this.domObserver=new vv(this,(r,i,o,s)=>Dv(this,r,i,o,s)),this.domObserver.start(),Xk(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(Ch),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&&(qg(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=xh(this);zv(p,this.nodeViews)&&(this.nodeViews=p,o=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&$u(this),this.editable=vh(this),kh(this);let a=Pa(this),u=wh(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&&dk(this);if(s){this.domObserver.stop();let p=f&&(_e||Ne)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&Iv(i.selection,e.selection);if(f){let h=Ne?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=fv(this)),(o||!this.docView.update(e.doc,u,a,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=Zd(e.doc,u,a,this.dom,this)),h&&!this.trackWrites&&(p=!0)}p||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Fk(this))?Kt(this,p):(Pg(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&&hk(d)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof I){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Kd(this,t.getBoundingClientRect(),e)}else Kd(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 Yg(e.slice,e.move,i<0?void 0:I.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 wk(this,e)}coordsAtPos(e,t=1){return Ng(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 Nk(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&&(Zk(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Pa(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,tk())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return tv(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?Ae&&this.root.nodeType===11&&sk(this.dom.ownerDocument)==this.dom&&Cv(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function wh(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"),[ge.node(0,n.state.doc.content.size,e)]}function kh(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:ge.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function vh(n){return!n.someProp("editable",e=>e(n.state)===!1)}function Iv(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 xh(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 zv(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 Ch(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 Z extends P{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return Z.valid(r)?new Z(r):P.near(r)}content(){return k.empty}eq(e){return e instanceof Z&&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 Z(e.resolve(t.pos))}getBookmark(){return new mf(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!Pv(e)||!Fv(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&&Z.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(Z.valid(a))return a}for(;;){let s=t>0?o.firstChild:o.lastChild;if(!s){if(o.isAtom&&!o.isText&&!I.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(Z.valid(l))return l}return null}}}Z.prototype.visible=!1;Z.findFrom=Z.findGapCursorFrom;P.jsonID("gapcursor",Z);class mf{constructor(e){this.pos=e}map(e){return new mf(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return Z.valid(t)?new Z(t):P.near(t)}}function Pv(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 Fv(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 Lv(){return new Lt({props:{decorations:Jv,createSelectionBetween(n,e,t){return e.pos==t.pos&&Z.valid(t)?new Z(t):null},handleClick:Vv,handleKeyDown:$v,handleDOMEvents:{beforeinput:Bv}}})}const $v=qw({ArrowLeft:ds("horiz",-1),ArrowRight:ds("horiz",1),ArrowUp:ds("vert",-1),ArrowDown:ds("vert",1)});function ds(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=Z.findGapCursorFrom(l,e,a);return u?(i&&i(r.tr.setSelection(new Z(u))),!0):!1}}function Vv(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!Z.valid(r))return!1;let i=n.posAtCoords({left:t.clientX,top:t.clientY});return i&&i.inside>-1&&I.isSelectable(n.state.doc.nodeAt(i.inside))?!1:(n.dispatch(n.state.tr.setSelection(new Z(r))),!0)}function Bv(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof Z))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 k(i,0,0));return o.setSelection($.near(o.doc.resolve(t.pos+1))),n.dispatch(o),!1}function Jv(n){if(!(n.selection instanceof Z))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",J.create(n.doc,[ge.widget(n.selection.head,e,{key:"gapcursor"})])}const ny=65535,ry=Math.pow(2,16);function _v(n,e){return n+e*ry}function Nh(n){return n&ny}function Wv(n){return(n-(n&ny))/ry}const iy=1,oy=2,qs=4,sy=8;let Mh=class{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&sy)>0}get deletedBefore(){return(this.delInfo&(iy|qs))>0}get deletedAfter(){return(this.delInfo&(oy|qs))>0}get deletedAcross(){return(this.delInfo&qs)>0}},Gr=class xr{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&xr.empty)return xr.empty}recover(e){let t=0,r=Nh(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:_v(l/3,e-a),m=e==a?oy:e==f?iy:qs;return(t<0?e!=a:e!=f)&&(m|=sy),new Mh(p,m,h)}i+=c-u}return r?e+i:new Mh(e+i,0,null)}touches(e,t){let r=0,i=Nh(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 ay(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 Ui(t.pos,r.pos,this.mark)}merge(e){return e instanceof Ui&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ui(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 Ui(t.from,t.to,e.markFromJSON(t.mark))}};Qe.jsonID("addMark",ly);let ay=class Hi 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 k(gf(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 ly(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:"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 Hi(t.from,t.to,e.markFromJSON(t.mark))}};Qe.jsonID("removeMark",ay);let uy=class ji 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 k(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,k.fromJSON(e,t.slice),t.insert,!!t.structure)}};Qe.jsonID("replaceAround",Hv);function Bu(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 jv(n,e,t=null,r=n){let i=Kv(n,e),o=i&&qv(r,e);return o?i.map(Eh).concat({type:e,attrs:t}).concat(o.map(Eh)):null}function Eh(n){return{type:n,attrs:null}}function Kv(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 qv(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 Zv=500;function ex({rules:n}){let e=new Lt({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 Oh(t,r,i,o,n,e)},handleDOMEvents:{compositionend:t=>{setTimeout(()=>{let{$cursor:r}=t.state.selection;r&&Oh(t,r.pos,r.pos,"",n,e)})}}},isInputRules:!0});return e}function Oh(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-Zv),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&&jv(f,e,a);if(!d)return null;u.wrap(f,d);let p=u.doc.resolve(s-1).nodeBefore;return p&&p.type==e&&Qv(u.doc,s-1)&&!r&&u.join(s-1),u})}const nx=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function rx(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,i,o,s;for(let l=0;l127)&&(o=bt[r.keyCode])&&o!=i){let l=e[$a(o,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}const lx=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function ax(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,i,o,s;for(let l=0;l127)&&(o=bt[r.keyCode])&&o!=i){let l=e[Va(o,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}const fy=65535,dy=Math.pow(2,16);function fx(n,e){return n+e*dy}function Dh(n){return n&fy}function dx(n){return(n-(n&fy))/dy}const hy=1,py=2,Gs=4,my=8;class Ju{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&my)>0}get deletedBefore(){return(this.delInfo&(hy|Gs))>0}get deletedAfter(){return(this.delInfo&(py|Gs))>0}get deletedAcross(){return(this.delInfo&Gs)>0}}class Ge{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&Ge.empty)return Ge.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:fx(l/3,e-a),m=e==a?py:e==f?hy:Gs;return(t<0?e!=a:e!=f)&&(m|=my),new Ju(p,m,h)}i+=c-u}return r?e+i:new Ju(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=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 ro;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 ie.fromReplace(e,this.from,this.to,o)}invert(){return new Ot(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 dn(t.pos,r.pos,this.mark)}merge(e){return e instanceof dn&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new dn(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 dn(t.from,t.to,e.markFromJSON(t.mark))}}Oe.jsonID("addMark",dn);class Ot 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 k(yf(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return ie.fromReplace(e,this.from,this.to,r)}invert(){return new dn(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 Ot(t.pos,r.pos,this.mark)}merge(e){return e instanceof Ot&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ot(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 Ot(t.from,t.to,e.markFromJSON(t.mark))}}Oe.jsonID("removeMark",Ot);class hn extends Oe{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return ie.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return ie.fromReplace(e,this.pos,this.pos+1,new k(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 Tt(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 Tt(t.from,t.to,t.gapFrom,t.gapTo,k.fromJSON(e,t.slice),t.insert,!!t.structure)}}Oe.jsonID("replaceAround",Tt);function _u(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 hx(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 px(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 Ot(s.from,s.to,s.style)))}function mx(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 gx(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 Tt(i,o,i,o,new k(r,0,0),t.length,!0))}function Sx(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)&&wx(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 Tt(u,c,u+1,c-1,new k(x.from(r.create(i,null,s.marks)),0,0),1,!0)),!1}})}function wx(n,e,t){let r=n.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,t)}function kx(n,e,t,r,i){let o=n.doc.nodeAt(e);if(!o)throw new RangeError("No node at given position");t||(t=o.type);let s=t.create(r,null,i||o.marks);if(o.isLeaf)return n.replaceWith(e,e+o.nodeSize,s);if(!t.validContent(o.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new Tt(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new k(x.from(s),0,0),1,!0))}function vx(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 Te(e,e,new k(o.append(s),t,t),!0))}function xx(n,e,t){let r=new Te(e-t,e+t,k.empty,!0);n.step(r)}function Cx(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 k(o,s,l);return e>-1?new Tt(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new Te(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=Ja(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=Ja(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new k(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=Ja(e,t);if(i.childCount<=1&&t>0){let o=e.size-t<=t+i.size;this.unplaced=new k(Ki(e,t-1,1),t-1,o?t-1:r)}else this.unplaced=new k(Ki(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(yy(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=_a(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 Ki(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Ki(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 Ja(n,e){for(let t=0;t1&&(r=r.replaceChild(0,yy(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 _a(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&&!Ex(t,o.content,s)?l:null}function Ex(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=Ox(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 Sy(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 Tx(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let i=Cx(n.doc,e,r.type);i!=null&&(e=t=i)}n.replaceRange(e,t,new k(x.from(r),0,0))}function Rx(n,e,t){let r=n.doc.resolve(e),i=n.doc.resolve(t),o=wy(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 wy(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 $r 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 ie.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 ie.fromReplace(e,this.pos,this.pos+1,new k(x.from(i),0,t.isLeaf?0:1))}getMap(){return Ge.empty}invert(e){return new $r(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 $r(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 $r(t.pos,t.attr,t.value)}}Oe.jsonID("attr",$r);class Mo 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 ie.ok(r)}getMap(){return Ge.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)}}Oe.jsonID("docAttr",Mo);let Zr=class extends Error{};Zr=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};Zr.prototype=Object.create(Error.prototype);Zr.prototype.constructor=Zr;Zr.prototype.name="TransformError";class Ax{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new ro}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Zr(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=k.empty){let i=Nx(this.doc,e,t,r);return i&&this.step(i),this}replaceWith(e,t,r){return this.replace(e,t,new k(x.from(r),0,0))}delete(e,t){return this.replace(e,t,k.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return Dx(this,e,t,r),this}replaceRangeWith(e,t,r){return Tx(this,e,t,r),this}deleteRange(e,t){return Rx(this,e,t),this}lift(e,t){return gx(this,e,t),this}join(e,t=1){return xx(this,e,t),this}wrap(e,t){return yx(this,e,t),this}setBlockType(e,t=e,r,i=null){return Sx(this,e,t,r,i),this}setNodeMarkup(e,t,r=null,i){return kx(this,e,t,r,i),this}setNodeAttribute(e,t,r){return this.step(new $r(e,t,r)),this}setDocAttribute(e,t){return this.step(new Mo(e,t)),this}addNodeMark(e,t){return this.step(new hn(e,t)),this}removeNodeMark(e,t){if(!(t instanceof _)){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 Xr(e,t)),this}split(e,t=1,r){return vx(this,e,t,r),this}addMark(e,t,r){return hx(this,e,t,r),this}removeMark(e,t,r){return px(this,e,t,r),this}clearIncompatible(e,t,r){return mx(this,e,t,r),this}}var Wu,Uu;if(typeof WeakMap<"u"){let n=new WeakMap;Wu=e=>n.get(e),Uu=(e,t)=>(n.set(e,t),t)}else{const n=[];let t=0;Wu=r=>{for(let i=0;i(t==10&&(t=0),n[t++]=r,n[t++]=i)}var ne=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 zx(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 Rh(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 Fx(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=>Th(r,e)}],toDOM(r){return["td",Rh(r,e),0]}},table_header:{content:n.cellContent,attrs:t,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:r=>Th(r,e)}],toDOM(r){return["th",Rh(r,e),0]}}}}function Pt(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 ln=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 Sf(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 ky(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)||Lx(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function Lx(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 Hu(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function wf(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function vy(n,e,t){const r=n.node(-1),i=ne.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 ei(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 ce=class Bt extends P{constructor(e,t=e){const r=e.node(-1),i=ne.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 eg(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(Hu(r)&&Hu(i)&&wf(r,i)){const o=this.$anchorCell.node(-1)!=r.node(-1);return o&&this.isRowSelection()?Bt.rowSelection(r,i):o&&this.isColSelection()?Bt.colSelection(r,i):new Bt(r,i)}return $.between(r,i)}content(){const e=this.$anchorCell.node(-1),t=ne.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=ei(g,0,m)),w>0&&(g=ei(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=ne.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 Bt&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){const r=e.node(-1),i=ne.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(ge.node(r,r+t.nodeSize,{class:"selectedCell"}))}),J.create(n.doc,e)}function Bx({$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 Jx({$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 _x(n,e,t){const r=(e||n).selection,i=(e||n).doc;let o,s;if(r instanceof I&&(s=r.node.type.spec.tableRole)){if(s=="cell"||s=="header_cell")o=ce.create(i,r.from);else if(s=="row"){const l=i.resolve(r.from+1);o=ce.rowSelection(l,l)}else if(!t){const l=ne.get(r.node),a=r.from+1,u=a+l.map[l.width*l.height-1];o=ce.create(i,a+1,u)}}else r instanceof $&&Bx(r)?o=$.create(i,r.from):r instanceof $&&Jx(r)&&(o=$.create(i,r.$from.start(),r.$from.end()));return o&&(e||(e=n.tr)).setSelection(o),e}var Wx=new Qo("fix-tables");function Cy(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=Hx(n,i,o,t))};return e?e.doc!=n.doc&&Cy(e.doc,n.doc,0,r):n.doc.descendants(r),t}function Hx(n,e,t,r){const i=ne.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(ei(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 Qx(n,e,t,r,i,o,s){const l=n.doc.type.schema,a=Pt(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 ce)return Xs(t,r,P.near(o.$headCell,e));if(n!="horiz"&&!o.empty)return!1;const s=Ny(i,n,e);if(s==null)return!1;if(n=="horiz")return Xs(t,r,P.near(t.doc.resolve(o.head+e),e));{const l=t.doc.resolve(s),a=vy(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),Xs(t,r,u)}}}function ps(n,e){return(t,r,i)=>{if(!i)return!1;const o=t.selection;let s;if(o instanceof ce)s=o;else{const a=Ny(i,n,e);if(a==null)return!1;s=new ce(t.doc.resolve(a))}const l=vy(s.$headCell,n,e);return l?Xs(t,r,new ce(s.$anchorCell,l)):!1}}function ms(n,e){const t=n.selection;if(!(t instanceof ce))return!1;if(e){const r=n.tr,i=Pt(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 k(i,0,0))}),r.docChanged&&e(r)}return!0}function Gx(n,e){const t=n.state.doc,r=Zo(t.resolve(e));return r?(n.dispatch(n.state.tr.setSelection(new ce(r))),!0):!1}function Xx(n,e,t){if(!Sf(n.state))return!1;let r=jx(t);const i=n.state.selection;if(i instanceof ce){r||(r={width:1,height:1,rows:[x.from(ju(Pt(n.state.schema).cell,t))]});const o=i.$anchorCell.node(-1),s=i.$anchorCell.start(-1),l=ne.get(o).rectBetween(i.$anchorCell.pos-s,i.$headCell.pos-s);return r=qx(r,l.right-l.left,l.bottom-l.top),Ih(n.state,n.dispatch,s,l,r),!0}else if(r){const o=ky(n.state),s=o.start(-1);return Ih(n.state,n.dispatch,s,ne.get(o.node(-1)).findCell(o.pos-s),r),!0}else return!1}function Zx(n,e){var t;if(e.ctrlKey||e.metaKey)return;const r=zh(n,e.target);let i;if(e.shiftKey&&n.state.selection instanceof ce)o(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(i=Zo(n.state.selection.$anchor))!=null&&((t=Wa(n,e))==null?void 0:t.pos)!=i.pos)o(i,e),e.preventDefault();else if(!r)return;function o(a,u){let c=Wa(n,u);const f=ln.getState(n.state)==null;if(!c||!wf(a,c))if(f)c=a;else return;const d=new ce(a,c);if(f||!n.state.selection.eq(d)){const p=n.state.tr.setSelection(d);f&&p.setMeta(ln,a.pos),n.dispatch(p)}}function s(){n.root.removeEventListener("mouseup",s),n.root.removeEventListener("dragstart",s),n.root.removeEventListener("mousemove",l),ln.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(ln,-1))}function l(a){const u=a,c=ln.getState(n.state);let f;if(c!=null)f=n.state.doc.resolve(c);else if(zh(n,u.target)!=r&&(f=Wa(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 Ny(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 zh(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Wa(n,e){const t=n.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?Zo(n.state.doc.resolve(t.pos)):null}var eC=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")),Ku(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,Ku(n,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(n){return n.type=="attributes"&&(n.target==this.table||this.colgroup.contains(n.target))}};function Ku(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 nC(-1,!1)},apply(o,s){return s.apply(o)}},props:{attributes:o=>{const s=at.getState(o);return s&&s.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(o,s)=>{rC(o,s,n,e,r)},mouseleave:o=>{iC(o)},mousedown:(o,s)=>{oC(o,s,e)}},decorations:o=>{const s=at.getState(o);if(s&&s.activeHandle>-1)return fC(o,s.activeHandle)},nodeViews:{}}});return i}var nC=class Zs{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){const t=this,r=e.getMeta(at);if(r&&r.setHandle!=null)return new Zs(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new Zs(t.activeHandle,r.setDragging);if(t.activeHandle>-1&&e.docChanged){let i=e.mapping.map(t.activeHandle,-1);return Hu(e.doc.resolve(i))||(i=-1),new Zs(i,t.dragging)}return t}};function rC(n,e,t,r,i){const o=at.getState(n.state);if(o&&!o.dragging){const s=lC(e.target);let l=-1;if(s){const{left:a,right:u}=s.getBoundingClientRect();e.clientX-a<=t?l=Ph(n,e,"left",t):u-e.clientX<=t&&(l=Ph(n,e,"right",t))}if(l!=o.activeHandle){if(!i&&l!==-1){const a=n.state.doc.resolve(l),u=a.node(-1),c=ne.get(u),f=a.start(-1);if(c.colCount(a.pos-f)+a.nodeAfter.attrs.colspan-1==c.width-1)return}My(n,l)}}}function iC(n){const e=at.getState(n.state);e&&e.activeHandle>-1&&!e.dragging&&My(n,-1)}function oC(n,e,t){var r;const i=(r=n.dom.ownerDocument.defaultView)!=null?r:window,o=at.getState(n.state);if(!o||o.activeHandle==-1||o.dragging)return!1;const s=n.state.doc.nodeAt(o.activeHandle),l=sC(n,o.activeHandle,s.attrs);n.dispatch(n.state.tr.setMeta(at,{setDragging:{startX:e.clientX,startWidth:l}}));function a(c){i.removeEventListener("mouseup",a),i.removeEventListener("mousemove",u);const f=at.getState(n.state);f!=null&&f.dragging&&(aC(n,f.activeHandle,Fh(f.dragging,c,t)),n.dispatch(n.state.tr.setMeta(at,{setDragging:null})))}function u(c){if(!c.which)return a(c);const f=at.getState(n.state);if(f&&f.dragging){const d=Fh(f.dragging,c,t);uC(n,f.activeHandle,d,t)}}return i.addEventListener("mouseup",a),i.addEventListener("mousemove",u),e.preventDefault(),!0}function sC(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}}kf("row",{useDeprecatedLogic:!0});kf("column",{useDeprecatedLogic:!0});kf("cell",{useDeprecatedLogic:!0});function hC({allowTableNodeSelection:n=!1}={}){return new Lt({key:ln,state:{init(){return null},apply(e,t){const r=e.getMeta(ln);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:Vx,handleDOMEvents:{mousedown:Zx},createSelectionBetween(e){return ln.getState(e.state)!=null?e.state.selection:null},handleTripleClick:Gx,handleKeyDown:Yx,handlePaste:Xx},appendTransaction(e,t,r){return _x(r,Ux(r,t),n)}})}var Oy={exports:{}},nt={},Dy={exports:{}},Ty={};/** +`);return{dom:a,text:d,slice:e}}function Jg(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 k(x.from(n.state.schema.text(e.replace(/\r\n?/g,` +`))),0,0):k.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=fi.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=Qk(t),Go&&Yk(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&&!jk.test(d.parentNode.nodeName)?{ignore:!0}:null}})),c)l=Gk(hh(l,+c[1],+c[2]),c[4]);else if(l=k.maxOpen(Kk(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 jk=/^(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 Kk(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&&Wg(a,o,l,s[s.length-1],0))s[s.length-1]=u;else{s.length&&(s[s.length-1]=Ug(s[s.length-1],o.length));let c=_g(l,a);s.push(c),i=i.matchType(c.type),o=a}}),s)return x.from(s)}return n}function _g(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,x.from(n));return n}function Wg(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 hh(n,e,t){return et}).createHTML(n):n}function Qk(n){let e=/^(\s*]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=jg().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),i;if((i=r&&Hg[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 k(i,o,s)}const be={},Ie={},Xk={touchstart:!0,touchmove:!0};class Zk{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 ev(n){for(let e in be){let t=be[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{nv(n,r)&&!df(n,r)&&(n.editable||!(r.type in Ie))&&t(n,r)},Xk[e]?{passive:!0}:void 0)}Ae&&n.dom.addEventListener("input",()=>null),Bu(n)}function dn(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function tv(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 Bu(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>df(n,r))})}function df(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function nv(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 rv(n,e){!df(n,e)&&be[e.type]&&(n.editable||!(e.type in Ie))&&be[e.type](n,e)}Ie.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!qg(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(St&&Ne&&t.keyCode==13)))if(n.domObserver.selectionChanged(n.domSelectionRange())?n.domObserver.flush():t.keyCode!=229&&n.domObserver.forceFlush(),Yr&&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,Un(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||Hk(n,t)?t.preventDefault():dn(n,"key")};Ie.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};Ie.keypress=(n,e)=>{let t=e;if(qg(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||it&&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 Zl(n){return{left:n.clientX,top:n.clientY}}function iv(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function hf(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 Lr(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 ov(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&I.isSelectable(r)?(Lr(n,new I(t)),!0):!1}function sv(n,e){if(e==-1)return!1;let t=n.state.selection,r,i;t instanceof I&&(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(I.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?(Lr(n,I.create(n.state.doc,i)),!0):!1}function lv(n,e,t,r,i){return hf(n,"handleClickOn",e,t,r)||n.someProp("handleClick",o=>o(n,e,r))||(i?sv(n,t):ov(n,t))}function av(n,e,t,r){return hf(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",i=>i(n,e,r))}function uv(n,e,t,r){return hf(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",i=>i(n,e,r))||cv(n,t,r)}function cv(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(Lr(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)Lr(n,$.create(r,l+1,l+1+s.content.size));else if(I.isSelectable(s))Lr(n,I.create(r,l));else continue;return!0}}function pf(n){return kl(n)}const Kg=it?"metaKey":"ctrlKey";be.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=pf(n),i=Date.now(),o="singleClick";i-n.input.lastClick.time<500&&iv(t,n.input.lastClick)&&!t[Kg]&&(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(Zl(t));s&&(o=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new fv(n,s,t,!!r)):(o=="doubleClick"?av:uv)(n,s.pos,s.inside,t)?t.preventDefault():dn(n,"pointer"))};class fv{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[Kg],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 I&&u.from<=s&&u.to>s)&&(this.mightDrag={node:o,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&xt&&!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)),dn(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(()=>Kt(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(Zl(e))),this.updateAllowDefault(e),this.allowDefault||!t?dn(this.view,"pointer"):lv(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Ae&&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)?(Lr(this.view,P.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):dn(this.view,"pointer")}move(e){this.updateAllowDefault(e),dn(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)}}be.touchstart=n=>{n.input.lastTouch=Date.now(),pf(n),dn(n,"pointer")};be.touchmove=n=>{n.input.lastTouch=Date.now(),dn(n,"pointer")};be.contextmenu=n=>pf(n);function qg(n,e){return n.composing?!0:Ae&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const dv=St?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(),kl(n,!0),n.markCursor=null;else if(kl(n,!e.selection.empty),xt&&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}Qg(n,dv)};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++,Qg(n,20))};function Qg(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>kl(n),e))}function Yg(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=pv());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function hv(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=ok(e.focusNode,e.focusOffset),r=sk(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 pv(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function kl(n,e=!1){if(!(St&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Yg(n),e||n.docView&&n.docView.dirty){let t=cf(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 mv(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=_e&&yn<15||Yr&&fk<604;be.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}=Bg(n,s);o?(t.preventDefault(),o.clearData(),o.setData("text/html",l.innerHTML),o.setData("text/plain",a)):mv(n,l),i&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function gv(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function yv(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=Jg(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,i,o||k.empty)))return!0;if(!o)return!1;let s=gv(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 Gg(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&&!St)return;let r=vo?null:t.clipboardData,i=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&xo(n,Gg(r),r.getData("text/html"),i,t)?t.preventDefault():yv(n,t)};class Xg{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}}const Zg=it?"altKey":"ctrlKey";be.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(Zl(t)),s;if(!(o&&o.pos>=i.from&&o.pos<=(i instanceof I?i.to-1:i.to))){if(r&&r.mightDrag)s=I.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=I.create(n.state.doc,f.posBefore))}}let l=(s||n.state.selection).content(),{dom:a,text:u,slice:c}=Bg(n,l);(!t.dataTransfer.files.length||!Ne||vg>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 Xg(c,!t[Zg],s)};be.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(Zl(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=Jg(n,Gg(t.dataTransfer),vo?null:t.dataTransfer.getData("text/html"),!1,o);let l=!!(r&&!t[Zg]);if(n.someProp("handleDrop",h=>h(n,t,s||k.empty,l))){t.preventDefault();return}if(!s)return;t.preventDefault();let a=s?tk(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&&I.isSelectable(s.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(s.content.firstChild))u.setSelection(new I(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(ff(n,p,u.doc.resolve(h)))}n.focus(),n.dispatch(u.setMeta("uiEvent","drop"))};be.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())&&Kt(n)},20))};be.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)};be.beforeinput=(n,e)=>{if(Ne&&St&&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,Un(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)be[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 vl{constructor(e,t){this.toDOM=e,this.spec=t||Xn,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 ge(o-r,o-r,this)}valid(){return!0}eq(e){return this==e||e instanceof vl&&(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 Sn{constructor(e,t){this.attrs=e,this.spec=t||Xn}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 ge(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||Xn)}mapInner(e,t,r,i,o){let s;for(let l=0;l{let u=a+r,c;if(c=ny(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 Sn){let u=Math.max(o,a.from)-o,c=Math.min(s,a.to)-o;ui.map(e,t,Xn));return vr.from(r)}forChild(e,t){if(t.isLeaf)return J.empty;let r=[];for(let i=0;it instanceof J)?e:e.reduce((t,r)=>t.concat(r instanceof J?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=wv(l,n,e,t,i,o,s),c=xl(u,r,0,s);e=c.local;for(let f=0;ft&&s.to{let u=ny(n,l,a+t);if(u){o=!0;let c=xl(u,l,t+a+1,r);c!=xe&&i.push(a,a+l.nodeSize,c)}});let s=ty(o?ry(n):n,-t).sort(Zn);for(let l=0;l0;)e++;n.splice(e,0,t)}function Fa(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=xe&&e.push(r)}),n.cursorWrapper&&e.push(J.create(n.state.doc,[n.cursorWrapper.deco])),ey.from(e)}const kv={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},vv=_e&&yn<=11;let xv=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 Cv{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new xv,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()}),vv&&(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,kv)),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(lh(this.view)){if(this.suppressingSelectionUpdates)return Kt(this.view);if(_e&&yn<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&rr(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)&&lh(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||Ev(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),Nv(e)),this.handleDOMChange(o,s,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Kt(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(Ae&&/^(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||Ae&&/^(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 Tv=/^(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 Rv(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,z=cf(n,b);if(z&&!n.state.selection.eq(z)){if(Ne&&St&&n.input.lastKeyCode===13&&Date.now()-100$t(n,Un(13,"Enter"))))return;let le=n.state.tr.setSelection(z);b=="pointer"?le.setMeta("pointer",!0):b=="key"&&le.scrollIntoView(),o&&le.setMeta("composition",o),n.dispatch(le)}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=Ov(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||St)&&i.some(b=>b.nodeType==1&&!Tv.test(b.nodeName))&&(!h||h.endA>=h.endB)&&n.someProp("handleKeyDown",b=>b(n,Un(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=wh(n,n.state.doc,u.sel);if(b&&!b.eq(n.state.selection)){let z=n.state.tr.setSelection(b);o&&z.setMeta("composition",o),n.dispatch(z)}}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)),_e&&yn<=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((Yr&&n.input.lastIOSEnter>Date.now()-225&&(!y||i.some(b=>b.nodeName=="DIV"||b.nodeName=="P"))||!y&&m.posb(n,Un(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>h.start&&bv(c,h.start,h.endA,m,w)&&n.someProp("handleKeyDown",b=>b(n,Un(8,"Backspace")))){St&&Ne&&n.domObserver.suppressSelectionUpdates();return}Ne&&St&&h.endB==h.start&&(n.input.lastAndroidDelete=Date.now()),St&&!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,Un(13,"Enter"))})},20));let C=h.start,N=h.endA,E,O,T;if(y){if(m.pos==w.pos)_e&&yn<=11&&m.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>Kt(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=Av(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",z=>z(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=wh(n,E.doc,u.sel);b&&!(Ne&&St&&n.composing&&b.empty&&(h.start!=h.endB||n.input.lastAndroidDeletee.content.size?null:ff(n,e.resolve(t.anchor),e.resolve(t.head))}function Av(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||La(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 zv{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 Zk,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Mh),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=Ch(this),xh(this),this.nodeViews=Nh(this),this.docView=th(this.state.doc,vh(this),Fa(this),this.dom,this),this.domObserver=new Cv(this,(r,i,o,s)=>Rv(this,r,i,o,s)),this.domObserver.start(),ev(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&&Bu(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Mh),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&&(Yg(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=Nh(this);Fv(p,this.nodeViews)&&(this.nodeViews=p,o=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&Bu(this),this.editable=Ch(this),xh(this);let a=Fa(this),u=vh(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&&pk(this);if(s){this.domObserver.stop();let p=f&&(_e||Ne)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&Pv(i.selection,e.selection);if(f){let h=Ne?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=hv(this)),(o||!this.docView.update(e.doc,u,a,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=th(e.doc,u,a,this.dom,this)),h&&!this.trackWrites&&(p=!0)}p||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&$k(this))?Kt(this,p):(Lg(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&&mk(d)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof I){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Qd(this,t.getBoundingClientRect(),e)}else Qd(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 Xg(e.slice,e.move,i<0?void 0:I.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 vk(this,e)}coordsAtPos(e,t=1){return Eg(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 Ek(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&&(tv(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Fa(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,rk())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return rv(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?Ae&&this.root.nodeType===11&&ak(this.dom.ownerDocument)==this.dom&&Mv(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function vh(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"),[ge.node(0,n.state.doc.content.size,e)]}function xh(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:ge.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function Ch(n){return!n.someProp("editable",e=>e(n.state)===!1)}function Pv(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 Nh(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 Fv(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 Mh(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 Z extends P{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return Z.valid(r)?new Z(r):P.near(r)}content(){return k.empty}eq(e){return e instanceof Z&&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 Z(e.resolve(t.pos))}getBookmark(){return new yf(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!Lv(e)||!$v(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&&Z.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(Z.valid(a))return a}for(;;){let s=t>0?o.firstChild:o.lastChild;if(!s){if(o.isAtom&&!o.isText&&!I.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(Z.valid(l))return l}return null}}}Z.prototype.visible=!1;Z.findFrom=Z.findGapCursorFrom;P.jsonID("gapcursor",Z);class yf{constructor(e){this.pos=e}map(e){return new yf(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return Z.valid(t)?new Z(t):P.near(t)}}function Lv(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 $v(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 Vv(){return new Lt({props:{decorations:Wv,createSelectionBetween(n,e,t){return e.pos==t.pos&&Z.valid(t)?new Z(t):null},handleClick:Jv,handleKeyDown:Bv,handleDOMEvents:{beforeinput:_v}}})}const Bv=Yw({ArrowLeft:ds("horiz",-1),ArrowRight:ds("horiz",1),ArrowUp:ds("vert",-1),ArrowDown:ds("vert",1)});function ds(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=Z.findGapCursorFrom(l,e,a);return u?(i&&i(r.tr.setSelection(new Z(u))),!0):!1}}function Jv(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!Z.valid(r))return!1;let i=n.posAtCoords({left:t.clientX,top:t.clientY});return i&&i.inside>-1&&I.isSelectable(n.state.doc.nodeAt(i.inside))?!1:(n.dispatch(n.state.tr.setSelection(new Z(r))),!0)}function _v(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof Z))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 k(i,0,0));return o.setSelection($.near(o.doc.resolve(t.pos+1))),n.dispatch(o),!1}function Wv(n){if(!(n.selection instanceof Z))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",J.create(n.doc,[ge.widget(n.selection.head,e,{key:"gapcursor"})])}const iy=65535,oy=Math.pow(2,16);function Uv(n,e){return n+e*oy}function Eh(n){return n&iy}function Hv(n){return(n-(n&iy))/oy}const sy=1,ly=2,Qs=4,ay=8;let Oh=class{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&ay)>0}get deletedBefore(){return(this.delInfo&(sy|Qs))>0}get deletedAfter(){return(this.delInfo&(ly|Qs))>0}get deletedAcross(){return(this.delInfo&Qs)>0}},Gr=class xr{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&xr.empty)return xr.empty}recover(e){let t=0,r=Eh(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:Uv(l/3,e-a),m=e==a?ly:e==f?sy:Qs;return(t<0?e!=a:e!=f)&&(m|=ay),new Oh(p,m,h)}i+=c-u}return r?e+i:new Oh(e+i,0,null)}touches(e,t){let r=0,i=Eh(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 cy(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 Ui(t.pos,r.pos,this.mark)}merge(e){return e instanceof Ui&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ui(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 Ui(t.from,t.to,e.markFromJSON(t.mark))}};Qe.jsonID("addMark",uy);let cy=class Hi 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 k(Sf(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 uy(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:"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 Hi(t.from,t.to,e.markFromJSON(t.mark))}};Qe.jsonID("removeMark",cy);let fy=class ji 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 k(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 Ys(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 Ys(t.from,t.to,t.gapFrom,t.gapTo,k.fromJSON(e,t.slice),t.insert,!!t.structure)}};Qe.jsonID("replaceAround",Kv);function _u(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=Qv(n,e),o=i&&Yv(r,e);return o?i.map(Dh).concat({type:e,attrs:t}).concat(o.map(Dh)):null}function Dh(n){return{type:n,attrs:null}}function Qv(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 Yv(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 tx=500;function nx({rules:n}){let e=new Lt({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 Th(t,r,i,o,n,e)},handleDOMEvents:{compositionend:t=>{setTimeout(()=>{let{$cursor:r}=t.state.selection;r&&Th(t,r.pos,r.pos,"",n,e)})}}},isInputRules:!0});return e}function Th(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-tx),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&&Gv(u.doc,s-1)&&!r&&u.join(s-1),u})}const ix=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function ox(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,i,o,s;for(let l=0;l127)&&(o=bt[r.keyCode])&&o!=i){let l=e[Va(o,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}const ux=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function cx(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,i,o,s;for(let l=0;l127)&&(o=bt[r.keyCode])&&o!=i){let l=e[Ba(o,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}const hy=65535,py=Math.pow(2,16);function hx(n,e){return n+e*py}function Rh(n){return n&hy}function px(n){return(n-(n&hy))/py}const my=1,gy=2,Xs=4,yy=8;class Wu{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&yy)>0}get deletedBefore(){return(this.delInfo&(my|Xs))>0}get deletedAfter(){return(this.delInfo&(gy|Xs))>0}get deletedAcross(){return(this.delInfo&Xs)>0}}class Ge{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&Ge.empty)return Ge.empty}recover(e){let t=0,r=Rh(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:hx(l/3,e-a),m=e==a?gy:e==f?my:Xs;return(t<0?e!=a:e!=f)&&(m|=yy),new Wu(p,m,h)}i+=c-u}return r?e+i:new Wu(e+i,0,null)}touches(e,t){let r=0,i=Rh(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 ro;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 ie.fromReplace(e,this.from,this.to,o)}invert(){return new Ot(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 hn(t.pos,r.pos,this.mark)}merge(e){return e instanceof hn&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new hn(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 hn(t.from,t.to,e.markFromJSON(t.mark))}}Oe.jsonID("addMark",hn);class Ot 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 k(wf(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return ie.fromReplace(e,this.from,this.to,r)}invert(){return new hn(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 Ot(t.pos,r.pos,this.mark)}merge(e){return e instanceof Ot&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ot(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 Ot(t.from,t.to,e.markFromJSON(t.mark))}}Oe.jsonID("removeMark",Ot);class pn extends Oe{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return ie.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return ie.fromReplace(e,this.pos,this.pos+1,new k(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 Tt(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 Tt(t.from,t.to,t.gapFrom,t.gapTo,k.fromJSON(e,t.slice),t.insert,!!t.structure)}}Oe.jsonID("replaceAround",Tt);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 mx(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 gx(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 Ot(s.from,s.to,s.style)))}function yx(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 Sx(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 Tt(i,o,i,o,new k(r,0,0),t.length,!0))}function kx(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)&&vx(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 Tt(u,c,u+1,c-1,new k(x.from(r.create(i,null,s.marks)),0,0),1,!0)),!1}})}function vx(n,e,t){let r=n.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,t)}function xx(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 Tt(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new k(x.from(s),0,0),1,!0))}function Cx(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 Te(e,e,new k(o.append(s),t,t),!0))}function Nx(n,e,t){let r=new Te(e-t,e+t,k.empty,!0);n.step(r)}function Mx(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let o=r.index(i);if(r.node(i).canReplaceWith(o,o,t))return r.before(i+1);if(o>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let o=r.indexAfter(i);if(r.node(i).canReplaceWith(o,o,t))return r.after(i+1);if(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 k(o,s,l);return e>-1?new Tt(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new Te(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=_a(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=_a(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new k(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=_a(e,t);if(i.childCount<=1&&t>0){let o=e.size-t<=t+i.size;this.unplaced=new k(Ki(e,t-1,1),t-1,o?t-1:r)}else this.unplaced=new k(Ki(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(wy(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=Wa(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 Ki(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Ki(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 _a(n,e){for(let t=0;t1&&(r=r.replaceChild(0,wy(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 Wa(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=Tx(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 ky(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 Ax(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let i=Mx(n.doc,e,r.type);i!=null&&(e=t=i)}n.replaceRange(e,t,new k(x.from(r),0,0))}function bx(n,e,t){let r=n.doc.resolve(e),i=n.doc.resolve(t),o=vy(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 vy(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 $r 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 ie.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 ie.fromReplace(e,this.pos,this.pos+1,new k(x.from(i),0,t.isLeaf?0:1))}getMap(){return Ge.empty}invert(e){return new $r(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 $r(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 $r(t.pos,t.attr,t.value)}}Oe.jsonID("attr",$r);class Mo 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 ie.ok(r)}getMap(){return Ge.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)}}Oe.jsonID("docAttr",Mo);let Zr=class extends Error{};Zr=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};Zr.prototype=Object.create(Error.prototype);Zr.prototype.constructor=Zr;Zr.prototype.name="TransformError";class Ix{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new ro}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Zr(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=k.empty){let i=Ex(this.doc,e,t,r);return i&&this.step(i),this}replaceWith(e,t,r){return this.replace(e,t,new k(x.from(r),0,0))}delete(e,t){return this.replace(e,t,k.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return Rx(this,e,t,r),this}replaceRangeWith(e,t,r){return Ax(this,e,t,r),this}deleteRange(e,t){return bx(this,e,t),this}lift(e,t){return Sx(this,e,t),this}join(e,t=1){return Nx(this,e,t),this}wrap(e,t){return wx(this,e,t),this}setBlockType(e,t=e,r,i=null){return kx(this,e,t,r,i),this}setNodeMarkup(e,t,r=null,i){return xx(this,e,t,r,i),this}setNodeAttribute(e,t,r){return this.step(new $r(e,t,r)),this}setDocAttribute(e,t){return this.step(new Mo(e,t)),this}addNodeMark(e,t){return this.step(new pn(e,t)),this}removeNodeMark(e,t){if(!(t instanceof _)){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 Xr(e,t)),this}split(e,t=1,r){return Cx(this,e,t,r),this}addMark(e,t,r){return mx(this,e,t,r),this}removeMark(e,t,r){return gx(this,e,t,r),this}clearIncompatible(e,t,r){return yx(this,e,t,r),this}}var Hu,ju;if(typeof WeakMap<"u"){let n=new WeakMap;Hu=e=>n.get(e),ju=(e,t)=>(n.set(e,t),t)}else{const n=[];let t=0;Hu=r=>{for(let i=0;i(t==10&&(t=0),n[t++]=r,n[t++]=i)}var ne=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 Fx(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 bh(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 $x(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=>Ah(r,e)}],toDOM(r){return["td",bh(r,e),0]}},table_header:{content:n.cellContent,attrs:t,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:r=>Ah(r,e)}],toDOM(r){return["th",bh(r,e),0]}}}}function Pt(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 ln=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 kf(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 xy(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)||Vx(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function Vx(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 Ku(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function vf(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function Cy(n,e,t){const r=n.node(-1),i=ne.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 ei(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 ce=class Bt extends P{constructor(e,t=e){const r=e.node(-1),i=ne.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 ng(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(Ku(r)&&Ku(i)&&vf(r,i)){const o=this.$anchorCell.node(-1)!=r.node(-1);return o&&this.isRowSelection()?Bt.rowSelection(r,i):o&&this.isColSelection()?Bt.colSelection(r,i):new Bt(r,i)}return $.between(r,i)}content(){const e=this.$anchorCell.node(-1),t=ne.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=ei(g,0,m)),w>0&&(g=ei(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=ne.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 Bt&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){const r=e.node(-1),i=ne.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(ge.node(r,r+t.nodeSize,{class:"selectedCell"}))}),J.create(n.doc,e)}function _x({$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 Wx({$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 Ux(n,e,t){const r=(e||n).selection,i=(e||n).doc;let o,s;if(r instanceof I&&(s=r.node.type.spec.tableRole)){if(s=="cell"||s=="header_cell")o=ce.create(i,r.from);else if(s=="row"){const l=i.resolve(r.from+1);o=ce.rowSelection(l,l)}else if(!t){const l=ne.get(r.node),a=r.from+1,u=a+l.map[l.width*l.height-1];o=ce.create(i,a+1,u)}}else r instanceof $&&_x(r)?o=$.create(i,r.from):r instanceof $&&Wx(r)&&(o=$.create(i,r.$from.start(),r.$from.end()));return o&&(e||(e=n.tr)).setSelection(o),e}var Hx=new Qo("fix-tables");function My(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=Kx(n,i,o,t))};return e?e.doc!=n.doc&&My(e.doc,n.doc,0,r):n.doc.descendants(r),t}function Kx(n,e,t,r){const i=ne.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(ei(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 Gx(n,e,t,r,i,o,s){const l=n.doc.type.schema,a=Pt(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 ce)return Zs(t,r,P.near(o.$headCell,e));if(n!="horiz"&&!o.empty)return!1;const s=Ey(i,n,e);if(s==null)return!1;if(n=="horiz")return Zs(t,r,P.near(t.doc.resolve(o.head+e),e));{const l=t.doc.resolve(s),a=Cy(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),Zs(t,r,u)}}}function ps(n,e){return(t,r,i)=>{if(!i)return!1;const o=t.selection;let s;if(o instanceof ce)s=o;else{const a=Ey(i,n,e);if(a==null)return!1;s=new ce(t.doc.resolve(a))}const l=Cy(s.$headCell,n,e);return l?Zs(t,r,new ce(s.$anchorCell,l)):!1}}function ms(n,e){const t=n.selection;if(!(t instanceof ce))return!1;if(e){const r=n.tr,i=Pt(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 k(i,0,0))}),r.docChanged&&e(r)}return!0}function Zx(n,e){const t=n.state.doc,r=Zo(t.resolve(e));return r?(n.dispatch(n.state.tr.setSelection(new ce(r))),!0):!1}function eC(n,e,t){if(!kf(n.state))return!1;let r=qx(t);const i=n.state.selection;if(i instanceof ce){r||(r={width:1,height:1,rows:[x.from(qu(Pt(n.state.schema).cell,t))]});const o=i.$anchorCell.node(-1),s=i.$anchorCell.start(-1),l=ne.get(o).rectBetween(i.$anchorCell.pos-s,i.$headCell.pos-s);return r=Yx(r,l.right-l.left,l.bottom-l.top),Ph(n.state,n.dispatch,s,l,r),!0}else if(r){const o=xy(n.state),s=o.start(-1);return Ph(n.state,n.dispatch,s,ne.get(o.node(-1)).findCell(o.pos-s),r),!0}else return!1}function tC(n,e){var t;if(e.ctrlKey||e.metaKey)return;const r=Fh(n,e.target);let i;if(e.shiftKey&&n.state.selection instanceof ce)o(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(i=Zo(n.state.selection.$anchor))!=null&&((t=Ua(n,e))==null?void 0:t.pos)!=i.pos)o(i,e),e.preventDefault();else if(!r)return;function o(a,u){let c=Ua(n,u);const f=ln.getState(n.state)==null;if(!c||!vf(a,c))if(f)c=a;else return;const d=new ce(a,c);if(f||!n.state.selection.eq(d)){const p=n.state.tr.setSelection(d);f&&p.setMeta(ln,a.pos),n.dispatch(p)}}function s(){n.root.removeEventListener("mouseup",s),n.root.removeEventListener("dragstart",s),n.root.removeEventListener("mousemove",l),ln.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(ln,-1))}function l(a){const u=a,c=ln.getState(n.state);let f;if(c!=null)f=n.state.doc.resolve(c);else if(Fh(n,u.target)!=r&&(f=Ua(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 Ey(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 Fh(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Ua(n,e){const t=n.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?Zo(n.state.doc.resolve(t.pos)):null}var nC=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")),Qu(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,Qu(n,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(n){return n.type=="attributes"&&(n.target==this.table||this.colgroup.contains(n.target))}};function Qu(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 iC(-1,!1)},apply(o,s){return s.apply(o)}},props:{attributes:o=>{const s=at.getState(o);return s&&s.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(o,s)=>{oC(o,s,n,e,r)},mouseleave:o=>{sC(o)},mousedown:(o,s)=>{lC(o,s,e)}},decorations:o=>{const s=at.getState(o);if(s&&s.activeHandle>-1)return hC(o,s.activeHandle)},nodeViews:{}}});return i}var iC=class el{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){const t=this,r=e.getMeta(at);if(r&&r.setHandle!=null)return new el(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new el(t.activeHandle,r.setDragging);if(t.activeHandle>-1&&e.docChanged){let i=e.mapping.map(t.activeHandle,-1);return Ku(e.doc.resolve(i))||(i=-1),new el(i,t.dragging)}return t}};function oC(n,e,t,r,i){const o=at.getState(n.state);if(o&&!o.dragging){const s=uC(e.target);let l=-1;if(s){const{left:a,right:u}=s.getBoundingClientRect();e.clientX-a<=t?l=Lh(n,e,"left",t):u-e.clientX<=t&&(l=Lh(n,e,"right",t))}if(l!=o.activeHandle){if(!i&&l!==-1){const a=n.state.doc.resolve(l),u=a.node(-1),c=ne.get(u),f=a.start(-1);if(c.colCount(a.pos-f)+a.nodeAfter.attrs.colspan-1==c.width-1)return}Oy(n,l)}}}function sC(n){const e=at.getState(n.state);e&&e.activeHandle>-1&&!e.dragging&&Oy(n,-1)}function lC(n,e,t){var r;const i=(r=n.dom.ownerDocument.defaultView)!=null?r:window,o=at.getState(n.state);if(!o||o.activeHandle==-1||o.dragging)return!1;const s=n.state.doc.nodeAt(o.activeHandle),l=aC(n,o.activeHandle,s.attrs);n.dispatch(n.state.tr.setMeta(at,{setDragging:{startX:e.clientX,startWidth:l}}));function a(c){i.removeEventListener("mouseup",a),i.removeEventListener("mousemove",u);const f=at.getState(n.state);f!=null&&f.dragging&&(cC(n,f.activeHandle,$h(f.dragging,c,t)),n.dispatch(n.state.tr.setMeta(at,{setDragging:null})))}function u(c){if(!c.which)return a(c);const f=at.getState(n.state);if(f&&f.dragging){const d=$h(f.dragging,c,t);fC(n,f.activeHandle,d,t)}}return i.addEventListener("mouseup",a),i.addEventListener("mousemove",u),e.preventDefault(),!0}function aC(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}}xf("row",{useDeprecatedLogic:!0});xf("column",{useDeprecatedLogic:!0});xf("cell",{useDeprecatedLogic:!0});function mC({allowTableNodeSelection:n=!1}={}){return new Lt({key:ln,state:{init(){return null},apply(e,t){const r=e.getMeta(ln);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:Jx,handleDOMEvents:{mousedown:tC},createSelectionBetween(e){return ln.getState(e.state)!=null?e.state.selection:null},handleTripleClick:Zx,handleKeyDown:Xx,handlePaste:eC},appendTransaction(e,t,r){return Ux(r,jx(r,t),n)}})}var Ty={exports:{}},nt={},Ry={exports:{}},Ay={};/** * @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(R,F){var L=R.length;R.push(F);e:for(;0>>1,ae=R[ee];if(0>>1;eei(ga,L))Fni(ls,ga)?(R[ee]=ls,R[Fn]=L,ee=Fn):(R[ee]=ga,R[Pn]=L,ee=Pn);else if(Fni(ls,L))R[ee]=ls,R[Fn]=L,ee=Fn;else break e}}return F}function i(R,F){var L=R.sortIndex-F.sortIndex;return L!==0?L:R.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(R){for(var F=t(u);F!==null;){if(F.callback===null)r(u);else if(F.startTime<=R)r(u),F.sortIndex=F.expirationTime,e(a,F);else break;F=t(u)}}function C(R){if(m=!1,S(R),!h)if(t(a)!==null)h=!0,gi(N);else{var F=t(u);F!==null&&ma(C,F.startTime-R)}}function N(R,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)||R&&!le());){var ee=f.callback;if(typeof ee=="function"){f.callback=null,d=f.priorityLevel;var ae=ee(f.expirationTime<=F);F=n.unstable_now(),typeof ae=="function"?f.callback=ae:f===t(a)&&r(a),S(F)}else r(a);f=t(a)}if(f!==null)var ss=!0;else{var Pn=t(u);Pn!==null&&ma(C,Pn.startTime-F),ss=!1}return ss}finally{f=null,d=L,p=!1}}var E=!1,O=null,T=-1,b=5,z=-1;function le(){return!(n.unstable_now()-zR||125ee?(R.sortIndex=L,e(u,R),t(a)===null&&R===t(u)&&(m?(g(T),T=-1):m=!0,ma(C,L-ee))):(R.sortIndex=ae,e(a,R),h||p||(h=!0,gi(N))),R},n.unstable_shouldYield=le,n.unstable_wrapCallback=function(R){var F=d;return function(){var L=d;d=F;try{return R.apply(this,arguments)}finally{d=L}}}})(Ty);Dy.exports=Ty;var pC=Dy.exports;/** + */(function(n){function e(R,F){var L=R.length;R.push(F);e:for(;0>>1,ae=R[ee];if(0>>1;eei(ya,L))Lni(ls,ya)?(R[ee]=ls,R[Ln]=L,ee=Ln):(R[ee]=ya,R[Fn]=L,ee=Fn);else if(Lni(ls,L))R[ee]=ls,R[Ln]=L,ee=Ln;else break e}}return F}function i(R,F){var L=R.sortIndex-F.sortIndex;return L!==0?L:R.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(R){for(var F=t(u);F!==null;){if(F.callback===null)r(u);else if(F.startTime<=R)r(u),F.sortIndex=F.expirationTime,e(a,F);else break;F=t(u)}}function C(R){if(m=!1,S(R),!h)if(t(a)!==null)h=!0,gi(N);else{var F=t(u);F!==null&&ga(C,F.startTime-R)}}function N(R,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)||R&&!le());){var ee=f.callback;if(typeof ee=="function"){f.callback=null,d=f.priorityLevel;var ae=ee(f.expirationTime<=F);F=n.unstable_now(),typeof ae=="function"?f.callback=ae:f===t(a)&&r(a),S(F)}else r(a);f=t(a)}if(f!==null)var ss=!0;else{var Fn=t(u);Fn!==null&&ga(C,Fn.startTime-F),ss=!1}return ss}finally{f=null,d=L,p=!1}}var E=!1,O=null,T=-1,b=5,z=-1;function le(){return!(n.unstable_now()-zR||125ee?(R.sortIndex=L,e(u,R),t(a)===null&&R===t(u)&&(m?(g(T),T=-1):m=!0,ga(C,L-ee))):(R.sortIndex=ae,e(a,R),h||p||(h=!0,gi(N))),R},n.unstable_shouldYield=le,n.unstable_wrapCallback=function(R){var F=d;return function(){var L=d;d=F;try{return R.apply(this,arguments)}finally{d=L}}}})(Ay);Ry.exports=Ay;var gC=Ry.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 Ry=v,tt=pC;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"),qu=Object.prototype.hasOwnProperty,mC=/^[: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]*$/,$h={},Vh={};function gC(n){return qu.call(Vh,n)?!0:qu.call($h,n)?!1:mC.test(n)?Vh[n]=!0:($h[n]=!0,!1)}function yC(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 SC(n,e,t,r){if(e===null||typeof e>"u"||yC(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 Pe(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 Se={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(n){Se[n]=new Pe(n,0,!1,n,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(n){var e=n[0];Se[e]=new Pe(e,1,!1,n[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(n){Se[n]=new Pe(n,2,!1,n.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(n){Se[n]=new Pe(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){Se[n]=new Pe(n,3,!1,n.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(n){Se[n]=new Pe(n,3,!0,n,null,!1,!1)});["capture","download"].forEach(function(n){Se[n]=new Pe(n,4,!1,n,null,!1,!1)});["cols","rows","size","span"].forEach(function(n){Se[n]=new Pe(n,6,!1,n,null,!1,!1)});["rowSpan","start"].forEach(function(n){Se[n]=new Pe(n,5,!1,n.toLowerCase(),null,!1,!1)});var vf=/[\-:]([a-z])/g;function xf(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(vf,xf);Se[e]=new Pe(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(vf,xf);Se[e]=new Pe(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(vf,xf);Se[e]=new Pe(e,1,!1,n,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(n){Se[n]=new Pe(n,1,!1,n.toLowerCase(),null,!1,!1)});Se.xlinkHref=new Pe("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(n){Se[n]=new Pe(n,1,!1,n.toLowerCase(),null,!0,!0)});function Cf(n,e,t,r){var i=Se.hasOwnProperty(e)?Se[e]:null;(i!==null?i.type!==0:r||!(2"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Yu=Object.prototype.hasOwnProperty,yC=/^[: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]*$/,Bh={},Jh={};function SC(n){return Yu.call(Jh,n)?!0:Yu.call(Bh,n)?!1:yC.test(n)?Jh[n]=!0:(Bh[n]=!0,!1)}function wC(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 kC(n,e,t,r){if(e===null||typeof e>"u"||wC(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 Pe(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 Se={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(n){Se[n]=new Pe(n,0,!1,n,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(n){var e=n[0];Se[e]=new Pe(e,1,!1,n[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(n){Se[n]=new Pe(n,2,!1,n.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(n){Se[n]=new Pe(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){Se[n]=new Pe(n,3,!1,n.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(n){Se[n]=new Pe(n,3,!0,n,null,!1,!1)});["capture","download"].forEach(function(n){Se[n]=new Pe(n,4,!1,n,null,!1,!1)});["cols","rows","size","span"].forEach(function(n){Se[n]=new Pe(n,6,!1,n,null,!1,!1)});["rowSpan","start"].forEach(function(n){Se[n]=new Pe(n,5,!1,n.toLowerCase(),null,!1,!1)});var Cf=/[\-:]([a-z])/g;function Nf(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(Cf,Nf);Se[e]=new Pe(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(Cf,Nf);Se[e]=new Pe(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(Cf,Nf);Se[e]=new Pe(e,1,!1,n,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(n){Se[n]=new Pe(n,1,!1,n.toLowerCase(),null,!1,!1)});Se.xlinkHref=new Pe("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(n){Se[n]=new Pe(n,1,!1,n.toLowerCase(),null,!0,!0)});function Mf(n,e,t,r){var i=Se.hasOwnProperty(e)?Se[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{Ha=!1,Error.prepareStackTrace=t}return(n=n?n.displayName||n.name:"")?Qi(n):""}function wC(n){switch(n.tag){case 5:return Qi(n.type);case 16:return Qi("Lazy");case 13:return Qi("Suspense");case 19:return Qi("SuspenseList");case 0:case 2:case 15:return n=ja(n.type,!1),n;case 11:return n=ja(n.type.render,!1),n;case 1:return n=ja(n.type,!0),n;default:return""}}function Xu(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 Nr:return"Fragment";case Cr:return"Portal";case Qu:return"Profiler";case Nf:return"StrictMode";case Yu:return"Suspense";case Gu:return"SuspenseList"}if(typeof n=="object")switch(n.$$typeof){case Iy:return(n.displayName||"Context")+".Consumer";case by:return(n._context.displayName||"Context")+".Provider";case Mf:var e=n.render;return n=n.displayName,n||(n=e.displayName||e.name||"",n=n!==""?"ForwardRef("+n+")":"ForwardRef"),n;case Ef:return e=n.displayName||null,e!==null?e:Xu(n.type)||"Memo";case rn:e=n._payload,n=n._init;try{return Xu(n(e))}catch{}}return null}function kC(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 Xu(e);case 8:return e===Nf?"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 On(n){switch(typeof n){case"boolean":case"number":case"string":case"undefined":return n;case"object":return n;default:return""}}function Py(n){var e=n.type;return(n=n.nodeName)&&n.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function vC(n){var e=Py(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 ys(n){n._valueTracker||(n._valueTracker=vC(n))}function Fy(n){if(!n)return!1;var e=n._valueTracker;if(!e)return!0;var t=e.getValue(),r="";return n&&(r=Py(n)?n.checked?"true":"false":n.value),n=r,n!==t?(e.setValue(n),!0):!1}function xl(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 Zu(n,e){var t=e.checked;return G({},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=On(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 Ly(n,e){e=e.checked,e!=null&&Cf(n,"checked",e,!1)}function ec(n,e){Ly(n,e);var t=On(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")?tc(n,e.type,t):e.hasOwnProperty("defaultValue")&&tc(n,e.type,On(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(n.defaultChecked=!!e.defaultChecked)}function _h(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 tc(n,e,t){(e!=="number"||xl(n.ownerDocument)!==n)&&(t==null?n.defaultValue=""+n._wrapperState.initialValue:n.defaultValue!==""+t&&(n.defaultValue=""+t))}var Yi=Array.isArray;function Vr(n,e,t,r){if(n=n.options,e){e={};for(var i=0;i"+e.valueOf().toString()+"",e=Ss.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 io={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},xC=["Webkit","ms","Moz","O"];Object.keys(io).forEach(function(n){xC.forEach(function(e){e=e+n.charAt(0).toUpperCase()+n.substring(1),io[e]=io[n]})});function Jy(n,e,t){return e==null||typeof e=="boolean"||e===""?"":t||typeof e!="number"||e===0||io.hasOwnProperty(n)&&io[n]?(""+e).trim():e+"px"}function _y(n,e){n=n.style;for(var t in e)if(e.hasOwnProperty(t)){var r=t.indexOf("--")===0,i=Jy(t,e[t],r);t==="float"&&(t="cssFloat"),r?n.setProperty(t,i):n[t]=i}}var CC=G({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 ic(n,e){if(e){if(CC[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 oc(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 sc=null;function Of(n){return n=n.target||n.srcElement||window,n.correspondingUseElement&&(n=n.correspondingUseElement),n.nodeType===3?n.parentNode:n}var lc=null,Br=null,Jr=null;function Hh(n){if(n=ns(n)){if(typeof lc!="function")throw Error(M(280));var e=n.stateNode;e&&(e=ra(e),lc(n.stateNode,n.type,e))}}function Wy(n){Br?Jr?Jr.push(n):Jr=[n]:Br=n}function Uy(){if(Br){var n=Br,e=Jr;if(Jr=Br=null,Hh(n),e)for(n=0;n>>=0,n===0?32:31-(zC(n)/PC|0)|0}var ws=64,ks=4194304;function Gi(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 El(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=Gi(l):(o&=s,o!==0&&(r=Gi(o)))}else s=t&~i,s!==0?r=Gi(s):o!==0&&(r=Gi(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-kt(e),n[e]=t}function VC(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=so),ep=" ",tp=!1;function c0(n,e){switch(n){case"keyup":return hN.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function f0(n){return n=n.detail,typeof n=="object"&&"data"in n?n.data:null}var Mr=!1;function mN(n,e){switch(n){case"compositionend":return f0(e);case"keypress":return e.which!==32?null:(tp=!0,ep);case"textInput":return n=e.data,n===ep&&tp?null:n;default:return null}}function gN(n,e){if(Mr)return n==="compositionend"||!Pf&&c0(n,e)?(n=a0(),tl=bf=pn=null,Mr=!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=op(t)}}function m0(n,e){return n&&e?n===e?!0:n&&n.nodeType===3?!1:e&&e.nodeType===3?m0(n,e.parentNode):"contains"in n?n.contains(e):n.compareDocumentPosition?!!(n.compareDocumentPosition(e)&16):!1:!1}function g0(){for(var n=window,e=xl();e instanceof n.HTMLIFrameElement;){try{var t=typeof e.contentWindow.location.href=="string"}catch{t=!1}if(t)n=e.contentWindow;else break;e=xl(n.document)}return e}function Ff(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 MN(n){var e=g0(),t=n.focusedElem,r=n.selectionRange;if(e!==t&&t&&t.ownerDocument&&m0(t.ownerDocument.documentElement,t)){if(r!==null&&Ff(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=sp(t,o);var s=sp(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,Er=null,hc=null,ao=null,pc=!1;function lp(n,e,t){var r=t.window===t?t.document:t.nodeType===9?t:t.ownerDocument;pc||Er==null||Er!==xl(r)||(r=Er,"selectionStart"in r&&Ff(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}),ao&&Io(ao,r)||(ao=r,r=Tl(hc,"onSelect"),0Tr||(n.current=kc[Tr],kc[Tr]=null,Tr--)}function H(n,e){Tr++,kc[Tr]=n.current,n.current=e}var Dn={},Ee=bn(Dn),We=bn(!1),ir=Dn;function ni(n,e){var t=n.type.contextTypes;if(!t)return Dn;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 Ue(n){return n=n.childContextTypes,n!=null}function Al(){K(We),K(Ee)}function pp(n,e,t){if(Ee.current!==Dn)throw Error(M(168));H(Ee,e),H(We,t)}function M0(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,kC(n)||"Unknown",i));return G({},t,r)}function bl(n){return n=(n=n.stateNode)&&n.__reactInternalMemoizedMergedChildContext||Dn,ir=Ee.current,H(Ee,n),H(We,We.current),!0}function mp(n,e,t){var r=n.stateNode;if(!r)throw Error(M(169));t?(n=M0(n,e,ir),r.__reactInternalMemoizedMergedChildContext=n,K(We),K(Ee),H(Ee,n)):K(We),H(We,t)}var Ut=null,ia=!1,su=!1;function E0(n){Ut===null?Ut=[n]:Ut.push(n)}function LN(n){ia=!0,E0(n)}function In(){if(!su&&Ut!==null){su=!0;var n=0,e=U;try{var t=Ut;for(U=1;n>=s,i-=s,Ht=1<<32-kt(e)+i|t<T?(b=O,O=null):b=O.sibling;var z=d(g,O,S[T],C);if(z===null){O===null&&(O=b);break}n&&O&&z.alternate===null&&e(g,O),y=o(z,y,T),E===null?N=z:E.sibling=z,E=z,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 le=d(g,O,z.value,C);if(le===null){O===null&&(O=b);break}n&&O&&le.alternate===null&&e(g,O),y=o(le,y,T),E===null?N=le:E.sibling=le,E=le,O=b}if(z.done)return t(g,O),q&&Jn(g,T),N;if(O===null){for(;!z.done;T++,z=S.next())z=f(g,z.value,C),z!==null&&(y=o(z,y,T),E===null?N=z:E.sibling=z,E=z);return q&&Jn(g,T),N}for(O=r(g,O);!z.done;T++,z=S.next())z=p(O,g,T,z.value,C),z!==null&&(n&&z.alternate!==null&&O.delete(z.key===null?T:z.key),y=o(z,y,T),E===null?N=z:E.sibling=z,E=z);return n&&O.forEach(function($t){return e(g,$t)}),q&&Jn(g,T),N}function w(g,y,S,C){if(typeof S=="object"&&S!==null&&S.type===Nr&&S.key===null&&(S=S.props.children),typeof S=="object"&&S!==null){switch(S.$$typeof){case gs:e:{for(var N=S.key,E=y;E!==null;){if(E.key===N){if(N=S.type,N===Nr){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===rn&&xp(N)===E.type){t(g,E.sibling),y=i(E,S.props),y.ref=Ci(g,E,S),y.return=g,g=y;break e}t(g,E);break}else e(g,E);E=E.sibling}S.type===Nr?(y=tr(S.props.children,g.mode,C,S.key),y.return=g,g=y):(C=ul(S.type,S.key,S.props,null,g.mode,C),C.ref=Ci(g,y,S),C.return=g,g=C)}return s(g);case Cr: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=pu(S,g.mode,C),y.return=g,g=y}return s(g);case rn:return E=S._init,w(g,y,E(S._payload),C)}if(Yi(S))return h(g,y,S,C);if(Si(S))return m(g,y,S,C);Os(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=hu(S,g.mode,C),y.return=g,g=y),s(g)):t(g,y)}return w}var ii=z0(!0),P0=z0(!1),rs={},At=bn(rs),Lo=bn(rs),$o=bn(rs);function Qn(n){if(n===rs)throw Error(M(174));return n}function Hf(n,e){switch(H($o,e),H(Lo,n),H(At,rs),n=e.nodeType,n){case 9:case 11:e=(e=e.documentElement)?e.namespaceURI:rc(null,"");break;default:n=n===8?e.parentNode:e,e=n.namespaceURI||null,n=n.tagName,e=rc(e,n)}K(At),H(At,e)}function oi(){K(At),K(Lo),K($o)}function F0(n){Qn($o.current);var e=Qn(At.current),t=rc(e,n.type);e!==t&&(H(Lo,n),H(At,t))}function jf(n){Lo.current===n&&(K(At),K(Lo))}var Q=bn(0);function $l(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 lu=[];function Kf(){for(var n=0;nt?t:4,n(!0);var r=au.transition;au.transition={};try{n(!1),e()}finally{U=t,au.transition=r}}function X0(){return ht().memoizedState}function JN(n,e,t){var r=Nn(n);if(t={lane:r,action:t,hasEagerState:!1,eagerState:null,next:null},Z0(n))e1(e,t);else if(t=R0(n,e,t,r),t!==null){var i=Re();vt(t,n,r,i),t1(t,e,r)}}function _N(n,e,t){var r=Nn(n),i={lane:r,action:t,hasEagerState:!1,eagerState:null,next:null};if(Z0(n))e1(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,Ct(l,s)){var a=e.interleaved;a===null?(i.next=i,Wf(e)):(i.next=a.next,a.next=i),e.interleaved=i;return}}catch{}finally{}t=R0(n,e,i,r),t!==null&&(i=Re(),vt(t,n,r,i),t1(t,e,r))}}function Z0(n){var e=n.alternate;return n===Y||e!==null&&e===Y}function e1(n,e){uo=Vl=!0;var t=n.pending;t===null?e.next=e:(e.next=t.next,t.next=e),n.pending=e}function t1(n,e,t){if(t&4194240){var r=e.lanes;r&=n.pendingLanes,t|=r,e.lanes=t,Tf(n,t)}}var Bl={readContext:dt,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},WN={readContext:dt,useCallback:function(n,e){return Mt().memoizedState=[n,e===void 0?null:e],n},useContext:dt,useEffect:Np,useImperativeHandle:function(n,e,t){return t=t!=null?t.concat([n]):null,ol(4194308,4,K0.bind(null,e,n),t)},useLayoutEffect:function(n,e){return ol(4194308,4,n,e)},useInsertionEffect:function(n,e){return ol(4,2,n,e)},useMemo:function(n,e){var t=Mt();return e=e===void 0?null:e,n=n(),t.memoizedState=[n,e],n},useReducer:function(n,e,t){var r=Mt();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=JN.bind(null,Y,n),[r.memoizedState,n]},useRef:function(n){var e=Mt();return n={current:n},e.memoizedState=n},useState:Cp,useDebugValue:Xf,useDeferredValue:function(n){return Mt().memoizedState=n},useTransition:function(){var n=Cp(!1),e=n[0];return n=BN.bind(null,n[1]),Mt().memoizedState=n,[e,n]},useMutableSource:function(){},useSyncExternalStore:function(n,e,t){var r=Y,i=Mt();if(q){if(t===void 0)throw Error(M(407));t=t()}else{if(t=e(),fe===null)throw Error(M(349));sr&30||V0(r,e,t)}i.memoizedState=t;var o={value:t,getSnapshot:e};return i.queue=o,Np(J0.bind(null,r,o,n),[n]),r.flags|=2048,Jo(9,B0.bind(null,r,o,t,e),void 0,null),t},useId:function(){var n=Mt(),e=fe.identifierPrefix;if(q){var t=jt,r=Ht;t=(r&~(1<<32-kt(r)-1)).toString(32)+t,e=":"+e+"R"+t,t=Vo++,0")&&(a=a.replace("",n.displayName)),a}while(1<=s&&0<=l);break}}}finally{ja=!1,Error.prepareStackTrace=t}return(n=n?n.displayName||n.name:"")?Qi(n):""}function vC(n){switch(n.tag){case 5:return Qi(n.type);case 16:return Qi("Lazy");case 13:return Qi("Suspense");case 19:return Qi("SuspenseList");case 0:case 2:case 15:return n=Ka(n.type,!1),n;case 11:return n=Ka(n.type.render,!1),n;case 1:return n=Ka(n.type,!0),n;default:return""}}function ec(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 Nr:return"Fragment";case Cr:return"Portal";case Gu:return"Profiler";case Ef:return"StrictMode";case Xu:return"Suspense";case Zu:return"SuspenseList"}if(typeof n=="object")switch(n.$$typeof){case Py:return(n.displayName||"Context")+".Consumer";case zy:return(n._context.displayName||"Context")+".Provider";case Of:var e=n.render;return n=n.displayName,n||(n=e.displayName||e.name||"",n=n!==""?"ForwardRef("+n+")":"ForwardRef"),n;case Df:return e=n.displayName||null,e!==null?e:ec(n.type)||"Memo";case rn:e=n._payload,n=n._init;try{return ec(n(e))}catch{}}return null}function xC(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 ec(e);case 8:return e===Ef?"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 Dn(n){switch(typeof n){case"boolean":case"number":case"string":case"undefined":return n;case"object":return n;default:return""}}function Ly(n){var e=n.type;return(n=n.nodeName)&&n.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function CC(n){var e=Ly(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 ys(n){n._valueTracker||(n._valueTracker=CC(n))}function $y(n){if(!n)return!1;var e=n._valueTracker;if(!e)return!0;var t=e.getValue(),r="";return n&&(r=Ly(n)?n.checked?"true":"false":n.value),n=r,n!==t?(e.setValue(n),!0):!1}function Cl(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 tc(n,e){var t=e.checked;return G({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:t??n._wrapperState.initialChecked})}function Wh(n,e){var t=e.defaultValue==null?"":e.defaultValue,r=e.checked!=null?e.checked:e.defaultChecked;t=Dn(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 Vy(n,e){e=e.checked,e!=null&&Mf(n,"checked",e,!1)}function nc(n,e){Vy(n,e);var t=Dn(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")?rc(n,e.type,t):e.hasOwnProperty("defaultValue")&&rc(n,e.type,Dn(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(n.defaultChecked=!!e.defaultChecked)}function Uh(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 rc(n,e,t){(e!=="number"||Cl(n.ownerDocument)!==n)&&(t==null?n.defaultValue=""+n._wrapperState.initialValue:n.defaultValue!==""+t&&(n.defaultValue=""+t))}var Yi=Array.isArray;function Vr(n,e,t,r){if(n=n.options,e){e={};for(var i=0;i"+e.valueOf().toString()+"",e=Ss.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 io={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},NC=["Webkit","ms","Moz","O"];Object.keys(io).forEach(function(n){NC.forEach(function(e){e=e+n.charAt(0).toUpperCase()+n.substring(1),io[e]=io[n]})});function Wy(n,e,t){return e==null||typeof e=="boolean"||e===""?"":t||typeof e!="number"||e===0||io.hasOwnProperty(n)&&io[n]?(""+e).trim():e+"px"}function Uy(n,e){n=n.style;for(var t in e)if(e.hasOwnProperty(t)){var r=t.indexOf("--")===0,i=Wy(t,e[t],r);t==="float"&&(t="cssFloat"),r?n.setProperty(t,i):n[t]=i}}var MC=G({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 sc(n,e){if(e){if(MC[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 lc(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 ac=null;function Tf(n){return n=n.target||n.srcElement||window,n.correspondingUseElement&&(n=n.correspondingUseElement),n.nodeType===3?n.parentNode:n}var uc=null,Br=null,Jr=null;function Kh(n){if(n=ns(n)){if(typeof uc!="function")throw Error(M(280));var e=n.stateNode;e&&(e=ia(e),uc(n.stateNode,n.type,e))}}function Hy(n){Br?Jr?Jr.push(n):Jr=[n]:Br=n}function jy(){if(Br){var n=Br,e=Jr;if(Jr=Br=null,Kh(n),e)for(n=0;n>>=0,n===0?32:31-(FC(n)/LC|0)|0}var ws=64,ks=4194304;function Gi(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 Ol(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=Gi(l):(o&=s,o!==0&&(r=Gi(o)))}else s=t&~i,s!==0?r=Gi(s):o!==0&&(r=Gi(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-kt(e),n[e]=t}function JC(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=so),np=" ",rp=!1;function d0(n,e){switch(n){case"keyup":return mN.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function h0(n){return n=n.detail,typeof n=="object"&&"data"in n?n.data:null}var Mr=!1;function yN(n,e){switch(n){case"compositionend":return h0(e);case"keypress":return e.which!==32?null:(rp=!0,np);case"textInput":return n=e.data,n===np&&rp?null:n;default:return null}}function SN(n,e){if(Mr)return n==="compositionend"||!Lf&&d0(n,e)?(n=c0(),nl=zf=mn=null,Mr=!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=lp(t)}}function y0(n,e){return n&&e?n===e?!0:n&&n.nodeType===3?!1:e&&e.nodeType===3?y0(n,e.parentNode):"contains"in n?n.contains(e):n.compareDocumentPosition?!!(n.compareDocumentPosition(e)&16):!1:!1}function S0(){for(var n=window,e=Cl();e instanceof n.HTMLIFrameElement;){try{var t=typeof e.contentWindow.location.href=="string"}catch{t=!1}if(t)n=e.contentWindow;else break;e=Cl(n.document)}return e}function $f(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 ON(n){var e=S0(),t=n.focusedElem,r=n.selectionRange;if(e!==t&&t&&t.ownerDocument&&y0(t.ownerDocument.documentElement,t)){if(r!==null&&$f(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=ap(t,o);var s=ap(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,Er=null,mc=null,ao=null,gc=!1;function up(n,e,t){var r=t.window===t?t.document:t.nodeType===9?t:t.ownerDocument;gc||Er==null||Er!==Cl(r)||(r=Er,"selectionStart"in r&&$f(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}),ao&&Io(ao,r)||(ao=r,r=Rl(mc,"onSelect"),0Tr||(n.current=xc[Tr],xc[Tr]=null,Tr--)}function H(n,e){Tr++,xc[Tr]=n.current,n.current=e}var Tn={},Ee=In(Tn),We=In(!1),ir=Tn;function ni(n,e){var t=n.type.contextTypes;if(!t)return Tn;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 Ue(n){return n=n.childContextTypes,n!=null}function bl(){K(We),K(Ee)}function gp(n,e,t){if(Ee.current!==Tn)throw Error(M(168));H(Ee,e),H(We,t)}function O0(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,xC(n)||"Unknown",i));return G({},t,r)}function Il(n){return n=(n=n.stateNode)&&n.__reactInternalMemoizedMergedChildContext||Tn,ir=Ee.current,H(Ee,n),H(We,We.current),!0}function yp(n,e,t){var r=n.stateNode;if(!r)throw Error(M(169));t?(n=O0(n,e,ir),r.__reactInternalMemoizedMergedChildContext=n,K(We),K(Ee),H(Ee,n)):K(We),H(We,t)}var Ut=null,oa=!1,lu=!1;function D0(n){Ut===null?Ut=[n]:Ut.push(n)}function VN(n){oa=!0,D0(n)}function zn(){if(!lu&&Ut!==null){lu=!0;var n=0,e=U;try{var t=Ut;for(U=1;n>=s,i-=s,Ht=1<<32-kt(e)+i|t<T?(b=O,O=null):b=O.sibling;var z=d(g,O,S[T],C);if(z===null){O===null&&(O=b);break}n&&O&&z.alternate===null&&e(g,O),y=o(z,y,T),E===null?N=z:E.sibling=z,E=z,O=b}if(T===S.length)return t(g,O),q&&_n(g,T),N;if(O===null){for(;TT?(b=O,O=null):b=O.sibling;var le=d(g,O,z.value,C);if(le===null){O===null&&(O=b);break}n&&O&&le.alternate===null&&e(g,O),y=o(le,y,T),E===null?N=le:E.sibling=le,E=le,O=b}if(z.done)return t(g,O),q&&_n(g,T),N;if(O===null){for(;!z.done;T++,z=S.next())z=f(g,z.value,C),z!==null&&(y=o(z,y,T),E===null?N=z:E.sibling=z,E=z);return q&&_n(g,T),N}for(O=r(g,O);!z.done;T++,z=S.next())z=p(O,g,T,z.value,C),z!==null&&(n&&z.alternate!==null&&O.delete(z.key===null?T:z.key),y=o(z,y,T),E===null?N=z:E.sibling=z,E=z);return n&&O.forEach(function($t){return e(g,$t)}),q&&_n(g,T),N}function w(g,y,S,C){if(typeof S=="object"&&S!==null&&S.type===Nr&&S.key===null&&(S=S.props.children),typeof S=="object"&&S!==null){switch(S.$$typeof){case gs:e:{for(var N=S.key,E=y;E!==null;){if(E.key===N){if(N=S.type,N===Nr){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===rn&&Np(N)===E.type){t(g,E.sibling),y=i(E,S.props),y.ref=Ci(g,E,S),y.return=g,g=y;break e}t(g,E);break}else e(g,E);E=E.sibling}S.type===Nr?(y=tr(S.props.children,g.mode,C,S.key),y.return=g,g=y):(C=cl(S.type,S.key,S.props,null,g.mode,C),C.ref=Ci(g,y,S),C.return=g,g=C)}return s(g);case Cr: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=mu(S,g.mode,C),y.return=g,g=y}return s(g);case rn:return E=S._init,w(g,y,E(S._payload),C)}if(Yi(S))return h(g,y,S,C);if(Si(S))return m(g,y,S,C);Os(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=pu(S,g.mode,C),y.return=g,g=y),s(g)):t(g,y)}return w}var ii=F0(!0),L0=F0(!1),rs={},At=In(rs),Lo=In(rs),$o=In(rs);function Qn(n){if(n===rs)throw Error(M(174));return n}function Kf(n,e){switch(H($o,e),H(Lo,n),H(At,rs),n=e.nodeType,n){case 9:case 11:e=(e=e.documentElement)?e.namespaceURI:oc(null,"");break;default:n=n===8?e.parentNode:e,e=n.namespaceURI||null,n=n.tagName,e=oc(e,n)}K(At),H(At,e)}function oi(){K(At),K(Lo),K($o)}function $0(n){Qn($o.current);var e=Qn(At.current),t=oc(e,n.type);e!==t&&(H(Lo,n),H(At,t))}function qf(n){Lo.current===n&&(K(At),K(Lo))}var Q=In(0);function Vl(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 au=[];function Qf(){for(var n=0;nt?t:4,n(!0);var r=uu.transition;uu.transition={};try{n(!1),e()}finally{U=t,uu.transition=r}}function e1(){return ht().memoizedState}function WN(n,e,t){var r=Mn(n);if(t={lane:r,action:t,hasEagerState:!1,eagerState:null,next:null},t1(n))n1(e,t);else if(t=b0(n,e,t,r),t!==null){var i=Re();vt(t,n,r,i),r1(t,e,r)}}function UN(n,e,t){var r=Mn(n),i={lane:r,action:t,hasEagerState:!1,eagerState:null,next:null};if(t1(n))n1(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,Ct(l,s)){var a=e.interleaved;a===null?(i.next=i,Hf(e)):(i.next=a.next,a.next=i),e.interleaved=i;return}}catch{}finally{}t=b0(n,e,i,r),t!==null&&(i=Re(),vt(t,n,r,i),r1(t,e,r))}}function t1(n){var e=n.alternate;return n===Y||e!==null&&e===Y}function n1(n,e){uo=Bl=!0;var t=n.pending;t===null?e.next=e:(e.next=t.next,t.next=e),n.pending=e}function r1(n,e,t){if(t&4194240){var r=e.lanes;r&=n.pendingLanes,t|=r,e.lanes=t,Af(n,t)}}var Jl={readContext:dt,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},HN={readContext:dt,useCallback:function(n,e){return Mt().memoizedState=[n,e===void 0?null:e],n},useContext:dt,useEffect:Ep,useImperativeHandle:function(n,e,t){return t=t!=null?t.concat([n]):null,sl(4194308,4,Q0.bind(null,e,n),t)},useLayoutEffect:function(n,e){return sl(4194308,4,n,e)},useInsertionEffect:function(n,e){return sl(4,2,n,e)},useMemo:function(n,e){var t=Mt();return e=e===void 0?null:e,n=n(),t.memoizedState=[n,e],n},useReducer:function(n,e,t){var r=Mt();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=WN.bind(null,Y,n),[r.memoizedState,n]},useRef:function(n){var e=Mt();return n={current:n},e.memoizedState=n},useState:Mp,useDebugValue:ed,useDeferredValue:function(n){return Mt().memoizedState=n},useTransition:function(){var n=Mp(!1),e=n[0];return n=_N.bind(null,n[1]),Mt().memoizedState=n,[e,n]},useMutableSource:function(){},useSyncExternalStore:function(n,e,t){var r=Y,i=Mt();if(q){if(t===void 0)throw Error(M(407));t=t()}else{if(t=e(),fe===null)throw Error(M(349));sr&30||J0(r,e,t)}i.memoizedState=t;var o={value:t,getSnapshot:e};return i.queue=o,Ep(W0.bind(null,r,o,n),[n]),r.flags|=2048,Jo(9,_0.bind(null,r,o,t,e),void 0,null),t},useId:function(){var n=Mt(),e=fe.identifierPrefix;if(q){var t=jt,r=Ht;t=(r&~(1<<32-kt(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[Et]=e,n[Fo]=r,c1(n,e,!1,!1),e.stateNode=n;e:{switch(s=oc(t,r),t){case"dialog":j("cancel",n),j("close",n),i=r;break;case"iframe":case"object":case"embed":j("load",n),i=r;break;case"video":case"audio":for(i=0;ili&&(e.flags|=128,r=!0,Ni(o,!1),e.lanes=4194304)}else{if(!r)if(n=$l(s),n!==null){if(e.flags|=128,r=!0,t=n.updateQueue,t!==null&&(e.updateQueue=t,e.flags|=4),Ni(o,!0),o.tail===null&&o.tailMode==="hidden"&&!s.alternate&&!q)return ve(e),null}else 2*te()-o.renderingStartTime>li&&t!==1073741824&&(e.flags|=128,r=!0,Ni(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=te(),e.sibling=null,t=Q.current,H(Q,r?t&1|2:t&1),e):(ve(e),null);case 22:case 23:return id(),r=e.memoizedState!==null,n!==null&&n.memoizedState!==null!==r&&(e.flags|=8192),r&&e.mode&1?Ye&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 GN(n,e){switch($f(e),e.tag){case 1:return Ue(e.type)&&Al(),n=e.flags,n&65536?(e.flags=n&-65537|128,e):null;case 3:return oi(),K(We),K(Ee),Kf(),n=e.flags,n&65536&&!(n&128)?(e.flags=n&-65537|128,e):null;case 5:return jf(e),null;case 13:if(K(Q),n=e.memoizedState,n!==null&&n.dehydrated!==null){if(e.alternate===null)throw Error(M(340));ri()}return n=e.flags,n&65536?(e.flags=n&-65537|128,e):null;case 19:return K(Q),null;case 4:return oi(),null;case 10:return _f(e.type._context),null;case 22:case 23:return id(),null;case 24:return null;default:return null}}var Ts=!1,Ce=!1,XN=typeof WeakSet=="function"?WeakSet:Set,D=null;function Ir(n,e){var t=n.ref;if(t!==null)if(typeof t=="function")try{t(null)}catch(r){X(n,e,r)}else t.current=null}function bc(n,e,t){try{t()}catch(r){X(n,e,r)}}var Ip=!1;function ZN(n,e){if(mc=Ol,n=g0(),Ff(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(gc={focusedElem:n,selectionRange:t},Ol=!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:gt(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){X(e,e.return,C)}if(n=e.sibling,n!==null){n.return=e.return,D=n;break}D=e.return}return h=Ip,Ip=!1,h}function co(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&&bc(e,t,o)}i=i.next}while(i!==r)}}function la(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 Ic(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 h1(n){var e=n.alternate;e!==null&&(n.alternate=null,h1(e)),n.child=null,n.deletions=null,n.sibling=null,n.tag===5&&(e=n.stateNode,e!==null&&(delete e[Et],delete e[Fo],delete e[wc],delete e[PN],delete e[FN])),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 p1(n){return n.tag===5||n.tag===3||n.tag===4}function zp(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||p1(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 zc(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=Rl));else if(r!==4&&(n=n.child,n!==null))for(zc(n,e,t),n=n.sibling;n!==null;)zc(n,e,t),n=n.sibling}function Pc(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(Pc(n,e,t),n=n.sibling;n!==null;)Pc(n,e,t),n=n.sibling}var he=null,yt=!1;function en(n,e,t){for(t=t.child;t!==null;)m1(n,e,t),t=t.sibling}function m1(n,e,t){if(Rt&&typeof Rt.onCommitFiberUnmount=="function")try{Rt.onCommitFiberUnmount(Zl,t)}catch{}switch(t.tag){case 5:Ce||Ir(t,e);case 6:var r=he,i=yt;he=null,en(n,e,t),he=r,yt=i,he!==null&&(yt?(n=he,t=t.stateNode,n.nodeType===8?n.parentNode.removeChild(t):n.removeChild(t)):he.removeChild(t.stateNode));break;case 18:he!==null&&(yt?(n=he,t=t.stateNode,n.nodeType===8?ou(n.parentNode,t):n.nodeType===1&&ou(n,t),Ao(n)):ou(he,t.stateNode));break;case 4:r=he,i=yt,he=t.stateNode.containerInfo,yt=!0,en(n,e,t),he=r,yt=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)&&bc(t,e,s),i=i.next}while(i!==r)}en(n,e,t);break;case 1:if(!Ce&&(Ir(t,e),r=t.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=t.memoizedProps,r.state=t.memoizedState,r.componentWillUnmount()}catch(l){X(t,e,l)}en(n,e,t);break;case 21:en(n,e,t);break;case 22:t.mode&1?(Ce=(r=Ce)||t.memoizedState!==null,en(n,e,t),Ce=r):en(n,e,t);break;default:en(n,e,t)}}function Pp(n){var e=n.updateQueue;if(e!==null){n.updateQueue=null;var t=n.stateNode;t===null&&(t=n.stateNode=new XN),e.forEach(function(r){var i=aM.bind(null,n,r);t.has(r)||(t.add(r),r.then(i,i))})}}function mt(n,e){var t=e.deletions;if(t!==null)for(var r=0;ri&&(i=s),r&=~o}if(r=i,r=te()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*tM(r/1960))-r,10n?16:n,mn===null)var r=!1;else{if(n=mn,mn=null,Wl=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;ate()-nd?er(n,0):td|=t),He(n,e)}function C1(n,e){e===0&&(n.mode&1?(e=ks,ks<<=1,!(ks&130023424)&&(ks=4194304)):e=1);var t=Re();n=Gt(n,e),n!==null&&(es(n,e,t),He(n,t))}function lM(n){var e=n.memoizedState,t=0;e!==null&&(t=e.retryLane),C1(n,t)}function aM(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),C1(n,t)}var N1;N1=function(n,e,t){if(n!==null)if(n.memoizedProps!==e.pendingProps||We.current)Je=!0;else{if(!(n.lanes&t)&&!(e.flags&128))return Je=!1,QN(n,e,t);Je=!!(n.flags&131072)}else Je=!1,q&&e.flags&1048576&&O0(e,zl,e.index);switch(e.lanes=0,e.tag){case 2:var r=e.type;sl(n,e),n=e.pendingProps;var i=ni(e,Ee.current);Wr(e,t),i=Qf(null,e,r,n,i,t);var o=Yf();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,Ue(r)?(o=!0,bl(e)):o=!1,e.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,Uf(e),i.updater=oa,e.stateNode=i,i._reactInternals=e,Mc(e,r,n,t),e=Dc(null,e,r,!0,o,t)):(e.tag=0,q&&o&&Lf(e),De(null,e,i,t),e=e.child),e;case 16:r=e.elementType;e:{switch(sl(n,e),n=e.pendingProps,i=r._init,r=i(r._payload),e.type=r,i=e.tag=cM(r),n=gt(r,n),i){case 0:e=Oc(null,e,r,n,t);break e;case 1:e=Rp(null,e,r,n,t);break e;case 11:e=Dp(null,e,r,n,t);break e;case 14:e=Tp(null,e,r,gt(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:gt(r,i),Oc(n,e,r,i,t);case 1:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:gt(r,i),Rp(n,e,r,i,t);case 3:e:{if(l1(e),n===null)throw Error(M(387));r=e.pendingProps,o=e.memoizedState,i=o.element,A0(n,e),Ll(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=si(Error(M(423)),e),e=Ap(n,e,r,t,i);break e}else if(r!==i){i=si(Error(M(424)),e),e=Ap(n,e,r,t,i);break e}else for(Xe=vn(e.stateNode.containerInfo.firstChild),et=e,q=!0,wt=null,t=P0(e,null,r,t),e.child=t;t;)t.flags=t.flags&-3|4096,t=t.sibling;else{if(ri(),r===i){e=Xt(n,e,t);break e}De(n,e,r,t)}e=e.child}return e;case 5:return F0(e),n===null&&xc(e),r=e.type,i=e.pendingProps,o=n!==null?n.memoizedProps:null,s=i.children,yc(r,i)?s=null:o!==null&&yc(r,o)&&(e.flags|=32),s1(n,e),De(n,e,s,t),e.child;case 6:return n===null&&xc(e),null;case 13:return a1(n,e,t);case 4:return Hf(e,e.stateNode.containerInfo),r=e.pendingProps,n===null?e.child=ii(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:gt(r,i),Dp(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(Pl,r._currentValue),r._currentValue=s,o!==null)if(Ct(o.value,s)){if(o.children===i.children&&!We.current){e=Xt(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),Cc(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),Cc(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,Wr(e,t),i=dt(i),r=r(i),e.flags|=1,De(n,e,r,t),e.child;case 14:return r=e.type,i=gt(r,e.pendingProps),i=gt(r.type,i),Tp(n,e,r,i,t);case 15:return i1(n,e,e.type,e.pendingProps,t);case 17:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:gt(r,i),sl(n,e),e.tag=1,Ue(r)?(n=!0,bl(e)):n=!1,Wr(e,t),I0(e,r,i),Mc(e,r,i,t),Dc(null,e,r,!0,n,t);case 19:return u1(n,e,t);case 22:return o1(n,e,t)}throw Error(M(156,e.tag))};function M1(n,e){return Gy(n,e)}function uM(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 ut(n,e,t,r){return new uM(n,e,t,r)}function sd(n){return n=n.prototype,!(!n||!n.isReactComponent)}function cM(n){if(typeof n=="function")return sd(n)?1:0;if(n!=null){if(n=n.$$typeof,n===Mf)return 11;if(n===Ef)return 14}return 2}function Mn(n,e){var t=n.alternate;return t===null?(t=ut(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 ul(n,e,t,r,i,o){var s=2;if(r=n,typeof n=="function")sd(n)&&(s=1);else if(typeof n=="string")s=5;else e:switch(n){case Nr:return tr(t.children,i,o,e);case Nf:s=8,i|=8;break;case Qu:return n=ut(12,t,e,i|2),n.elementType=Qu,n.lanes=o,n;case Yu:return n=ut(13,t,e,i),n.elementType=Yu,n.lanes=o,n;case Gu:return n=ut(19,t,e,i),n.elementType=Gu,n.lanes=o,n;case zy:return ua(t,i,o,e);default:if(typeof n=="object"&&n!==null)switch(n.$$typeof){case by:s=10;break e;case Iy:s=9;break e;case Mf:s=11;break e;case Ef:s=14;break e;case rn:s=16,r=null;break e}throw Error(M(130,n==null?n:typeof n,""))}return e=ut(s,t,e,i),e.elementType=n,e.type=r,e.lanes=o,e}function tr(n,e,t,r){return n=ut(7,n,r,e),n.lanes=t,n}function ua(n,e,t,r){return n=ut(22,n,r,e),n.elementType=zy,n.lanes=t,n.stateNode={isHidden:!1},n}function hu(n,e,t){return n=ut(6,n,null,e),n.lanes=t,n}function pu(n,e,t){return e=ut(4,n.children!==null?n.children:[],n.key,e),e.lanes=t,e.stateNode={containerInfo:n.containerInfo,pendingChildren:null,implementation:n.implementation},e}function fM(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=qa(0),this.expirationTimes=qa(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=qa(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function ld(n,e,t,r,i,o,s,l,a){return n=new fM(n,e,t,l,a),e===1?(e=1,o===!0&&(e|=8)):e=0,o=ut(3,null,null,e),n.current=o,o.stateNode=n,o.memoizedState={element:r,isDehydrated:t,cache:null,transitions:null,pendingSuspenseBoundaries:null},Uf(o),n}function dM(n,e,t){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(T1)}catch(n){console.error(n)}}T1(),Oy.exports=nt;var ai=Oy.exports,R1,Wp=ai;R1=Wp.createRoot,Wp.hydrateRoot;const pi=v.createContext(null),yM=v.createContext(null),A1=v.createContext(null);function SM(n,e){const t=Object.create(null);return t.class="ProseMirror",t.contenteditable=String(n.editable),n.someProp("attributes",r=>{if(typeof r=="function"&&(r=r(e)),r)for(const i in r)i=="class"?t.class+=" "+r[i]:i=="style"?t.style=(t.style?t.style+";":"")+r[i]:!t[i]&&i!="contenteditable"&&i!="nodeName"&&(t[i]=String(r[i]))}),t.translate||(t.translate="no"),[ge.node(0,e.doc.content.size,t)]}const wM=[],kM={},Bc=J.empty;class Un{constructor(e){this.members=e}map(e,t){const r=this.members.map(i=>i.map(e,t,kM));return Un.from(r)}forChild(e,t){if(t.isLeaf)return J.empty;let r=[];for(let i=0;it instanceof J)?e:e.reduce((t,r)=>t.concat(r instanceof J?r:r.members),[]))}}forEachSet(e){for(let t=0;t0;)e++;n.splice(e,0,t)}function xM(n,e,t){const r=[];return n.someProp("decorations",i=>{const o=i(e);o&&o!=Bc&&r.push(o)}),t&&r.push(J.create(e.doc,[t])),Un.from(r)}const fd=function(n){for(let e=0;;e++)if(n=n.previousSibling,!n)return e},Hp=function(n){const e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e},CM=function(n,e,t,r){return t&&(jp(n,e,t,r,-1)||jp(n,e,t,r,1))},NM=/^(img|br|input|textarea|hr)$/i;function jp(n,e,t,r,i){for(;;){if(n==t&&e==r)return!0;if(e==(i<0?0:jl(n))){const o=n.parentNode;if(!o||o.nodeType!=1||EM(n)||NM.test(n.nodeName)||n.contentEditable=="false")return!1;e=fd(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?jl(n):0}else return!1}}function jl(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function MM(n,e,t){for(let r=e==0,i=e==jl(n);r||i;){if(n==t)return!0;const o=fd(n);if(n=n.parentNode,!n)return!1;r=r&&o==0,i=i&&o==jl(n)}return!1}function EM(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 I1=function(n){return n.focusNode&&CM(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)},z1=v.createContext(null);function OM(n,e){const t=v.useContext(z1);v.useLayoutEffect(()=>t(n),e)}function P1(n,e){const{view:t}=v.useContext(pi);OM(()=>{if(t)return n(t)},e&&[t,...e])}const DM=v.forwardRef(function({widget:e,pos:t,...r},i){const[o,s]=v.useState(!0),l=v.useRef(null);return v.useImperativeHandle(i,()=>l.current,[]),P1(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,fd(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 TM(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 RM={side:0};class Wo{constructor(e,t){this.Component=e,this.spec=t??RM,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 ge(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&&TM(this.spec,e.spec))}destroy(){}}function F1(n,e,t){return new ge(n,n,new Wo(e,t))}function mu(){return Math.floor(Math.random()*0xffffffffffff).toString(16)}const Uo=new Qo("@nytimes/react-prosemirror/reactKeys");function AM(){let n=!1;return new Lt({key:Uo,state:{init(e,t){const r={posToKey:new Map,keyToPos:new Map};return t.doc.descendants((i,o)=>{const s=mu();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=mu()),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=mu();return l.posToKey.set(c,f),l.keyToPos.set(f,c),!0}),l}},props:{handleDOMEvents:{compositionstart:()=>{n=!0},compositionend:()=>{n=!1}}}})}function gu(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 bM(n){let e=null,t=null;return new Lt({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(F1(i.selection.from,DM,{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 gu(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);gu(r,a,{from:c,to:f})}});break}case"insertText":{gu(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 Ft=typeof navigator<"u"?navigator:null,Kp=typeof document<"u"?document:null,zn=Ft&&Ft.userAgent||"",Jc=/Edge\/(\d+)/.exec(zn),L1=/MSIE \d/.exec(zn),_c=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(zn),pa=!!(L1||_c||Jc),IM=L1?document.documentMode:_c?+_c[1]:Jc?+Jc[1]:0,$1=!pa&&/gecko\/(\d+)/i.test(zn),zM=$1&&+(/Firefox\/(\d+)/.exec(zn)||[0,0])[1],Wc=!pa&&/Chrome\/(\d+)/.exec(zn),PM=!!Wc,FM=Wc?+Wc[1]:0,V1=!pa&&!!Ft&&/Apple Computer/.test(Ft.vendor),B1=V1&&(/Mobile\/\w+/.test(zn)||!!Ft&&Ft.maxTouchPoints>2),LM=B1||(Ft?/Mac/.test(Ft.platform):!1),$M=Ft?/Win/.test(Ft.platform):!1,VM=/Android \d/.test(zn),J1=!!Kp&&"webkitFontSmoothing"in Kp.documentElement.style,BM=J1?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,Me={ie:pa,ie_version:IM,gecko:$1,gecko_version:zM,chrome:PM,chrome_version:FM,safari:V1,ios:B1,mac:LM,windows:$M,android:VM,webkit:J1,webkit_version:BM};function yu(n){return n.editable&&!n.hasFocus()?!1:JM(n)}function JM(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 _M(n,e,t,r){return n.someProp("createSelectionBetween",i=>i(n,e,t))||$.between(e,t,r)}function qp(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(I1(t)){for(a=s;i&&!i.node;)i=i.parent;const f=i.node;if(i&&f.isAtom&&I.isSelectable(f)&&i.parent&&!(f.isInline&&MM(t.focusNode,t.focusOffset,i.dom))){const d=i.posBefore;u=new I(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(()=>{(!_1(e)||e.state.selection.visible)&&e.dom.classList.remove("ProseMirror-hideselection")},20))})}const em=Me.safari||Me.chrome&&Me.chrome_version<63;function bs(n,e=!1){const t=n,r=t.state.selection;if(HM(t,r),!!_1(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&&Kl(i.anchorNode,i.anchorOffset,o.anchorNode,o.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)KM(t);else{const{anchor:i,head:o}=r;let s,l;em&&!(r instanceof $)&&(r.$from.parent.inlineContent||(s=Xp(t,r.from)),!r.empty&&!r.$from.parent.inlineContent&&(l=Xp(t,r.to))),t.docView.setSelection(i,o,t.root,e),em&&(s&&Zp(s),l&&Zp(l)),r.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&qM(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}class QM{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 YM{constructor(e){this.view=e,this.flushingSoon=-1,this.currentSelection=new QM,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=Hp(o))t.add(o);for(let o=e.anchorNode;o;o=Hp(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=qp(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;bs(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)&&yu(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(yu(this.view)&&!this.view.composing){if(this.suppressingSelectionUpdates)return bs(this.view);if(Me.ie&&Me.ie_version<=11&&!this.view.state.selection.empty){const e=this.view.domSelectionRange();if(e.focusNode&&Kl(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}}const ui=0,tm=1,Is=2,Ho=3;class is{constructor(e,t,r,i,o){this.parent=e,this.children=t,this.pos=r,this.dom=i,this.contentDOM=o,this.dirty=ui,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;tsn(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 pd){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 dd&&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?sn(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=sn(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?Is:tm,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?Is:Ho}r=s}this.dirty=Is}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){const r=e==1?Is:tm;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==ui&&e.eq(this.node)&&ZM(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 XM extends hd{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 pd extends is{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==ui&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}function ZM(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 Lt({key:new Qo("@nytimes/react-prosemirror/componentEventListeners"),props:{handleDOMEvents:e}})}function tE(){const[n,e]=v.useState(new Map),t=v.useCallback((o,s)=>{const l=n.get(o)??[];l.unshift(s),n.has(o)||(n.set(o,l),e(new Map(n)))},[n]),r=v.useCallback((o,s)=>{const l=n.get(o);l==null||l.splice(l.indexOf(s),1)},[n]),i=v.useMemo(()=>eE(n),[n]);return{registerEventListener:t,unregisterEventListener:r,componentEventListenersPlugin:i}}function W1(){const[,n]=v.useReducer(e=>e+1,0);return n}function nE(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 rE(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 iE(n,e){for(const t of Object.keys(n))if(n[t]!==e[t])return!0;return!1}function nm(n){return!n.someProp("editable",e=>e(n.state)===!1)}class oE extends bv{constructor(e,t){super(e,{state:cn.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 YM(this),this.domObserver.start(),this.editable=nm(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=nE(this);return rE(this.nodeViews,e)}pureSetProps(e){this._props={...this._props,...e},this.state=this._props.state,this.editable=nm(this)}runPendingEffects(){if(iE(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 sE=new Tm({nodes:{doc:{content:"text*"},text:{inline:!0}}}),lE=cn.create({schema:sE});function aE(n,e){const[t,r]=v.useState(null),[i,o]=v.useState(null),s=W1(),l=e.defaultState??lE,[a,u]=v.useState(l),c=e.state??a,{componentEventListenersPlugin:f,registerEventListener:d,unregisterEventListener:p}=tE(),h=v.useCallback(N=>{ai.flushSync(()=>{o(N)})},[]),m=v.useMemo(()=>[...e.plugins??[],f,bM(h)],[e.plugins,f,h]),w=v.useCallback(function(E){ai.flushSync(()=>{e.state||u(O=>O.apply(E)),e.dispatchTransaction&&e.dispatchTransaction.call(this,E)})},[e.dispatchTransaction,e.state]),g=document.createElement("div"),y=v.useRef(new hd(void 0,[],-1,c.doc,[],J.empty,g,null,g,()=>!1)),S={...e,state:c,plugins:m,dispatchTransaction:w,docView:y.current};return v.useLayoutEffect(()=>()=>{t==null||t.destroy()},[t]),v.useLayoutEffect(()=>{if(t&&t.dom!==n&&r(null),!!n&&!t){const N=new oE({mount:n},S);r(N),N.dom.addEventListener("compositionend",s);return}}),v.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:v.useMemo(()=>({view:t,registerEventListener:d,unregisterEventListener:p,cursorWrapper:i,docViewDescRef:y}),[t,d,p,i]),state:c}}function uE({children:n}){const e=v.useRef(new Set).current,t=v.useRef(new Set).current,r=v.useRef(!1),i=W1(),o=v.useRef(!0),s=v.useCallback(()=>{o.current||(i(),o.current=!0)},[i]),l=v.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 v.useLayoutEffect(()=>(o.current=!1,e.forEach(a=>a()),e.clear(),()=>{t.forEach(a=>a()),t.clear()})),v.useLayoutEffect(()=>(r.current=!0,()=>{r.current=!1}),[]),A.jsx(z1.Provider,{value:l,children:n})}const pt=v.createContext({parentRef:{current:void 0},siblingsRef:{current:[]}});function U1(n,e,t,r,i,o,s,l){const{view:a}=v.useContext(pi),[u,c]=v.useState(!0),f=v.useRef(s),d=v.useRef(()=>!1),p=v.useCallback(g=>{d.current=g},[]),{siblingsRef:h,parentRef:m}=v.useContext(pt),w=v.useRef([]);return v.useLayoutEffect(()=>{const g=h.current;return()=>{if(f.current&&g.includes(f.current)){const y=g.indexOf(f.current);g.splice(y,1)}}},[h]),v.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.pos=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 hd(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.pos-C.pos);for(const S of w.current)if(S.parent=f.current,S instanceof ql){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 ql&&!(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 cE(n,e){return n.type.side-e.type.side}function fE(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 H1(){const{view:n}=v.useContext(pi);return n&&Uo.getState(n.state)}var j1={exports:{}};/*! +`+o.stack}return{value:n,source:e,stack:i,digest:null}}function du(n,e,t){return{value:n,source:null,stack:t??null,digest:e??null}}function Dc(n,e){try{console.error(e.value)}catch(t){setTimeout(function(){throw t})}}var qN=typeof WeakMap=="function"?WeakMap:Map;function i1(n,e,t){t=qt(-1,t),t.tag=3,t.payload={element:null};var r=e.value;return t.callback=function(){Wl||(Wl=!0,$c=r),Dc(n,e)},t}function o1(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(){Dc(n,e)}}var o=n.stateNode;return o!==null&&typeof o.componentDidCatch=="function"&&(t.callback=function(){Dc(n,e),typeof r!="function"&&(Nn===null?Nn=new Set([this]):Nn.add(this));var s=e.stack;this.componentDidCatch(e.value,{componentStack:s!==null?s:""})}),t}function Op(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=aM.bind(null,n,e,t),e.then(n,n))}function Dp(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 Tp(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,Cn(t,e,1))),t.lanes|=1),n)}var QN=Zt.ReactCurrentOwner,Je=!1;function De(n,e,t,r){e.child=n===null?L0(e,null,t,r):ii(e,n.child,t,r)}function Rp(n,e,t,r,i){t=t.render;var o=e.ref;return Wr(e,i),r=Gf(n,e,t,r,o,i),t=Xf(),n!==null&&!Je?(e.updateQueue=n.updateQueue,e.flags&=-2053,n.lanes&=~i,Xt(n,e,i)):(q&&t&&Vf(e),e.flags|=1,De(n,e,r,i),e.child)}function Ap(n,e,t,r,i){if(n===null){var o=t.type;return typeof o=="function"&&!ad(o)&&o.defaultProps===void 0&&t.compare===null&&t.defaultProps===void 0?(e.tag=15,e.type=o,s1(n,e,o,r,i)):(n=cl(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:Io,t(s,r)&&n.ref===e.ref)return Xt(n,e,i)}return e.flags|=1,n=En(o,r),n.ref=e.ref,n.return=e,e.child=n}function s1(n,e,t,r,i){if(n!==null){var o=n.memoizedProps;if(Io(o,r)&&n.ref===e.ref)if(Je=!1,e.pendingProps=r=o,(n.lanes&i)!==0)n.flags&131072&&(Je=!0);else return e.lanes=n.lanes,Xt(n,e,i)}return Tc(n,e,t,r,i)}function l1(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(zr,Ye),Ye|=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(zr,Ye),Ye|=n,null;e.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=o!==null?o.baseLanes:t,H(zr,Ye),Ye|=r}else o!==null?(r=o.baseLanes|t,e.memoizedState=null):r=t,H(zr,Ye),Ye|=r;return De(n,e,i,t),e.child}function a1(n,e){var t=e.ref;(n===null&&t!==null||n!==null&&n.ref!==t)&&(e.flags|=512,e.flags|=2097152)}function Tc(n,e,t,r,i){var o=Ue(t)?ir:Ee.current;return o=ni(e,o),Wr(e,i),t=Gf(n,e,t,r,o,i),r=Xf(),n!==null&&!Je?(e.updateQueue=n.updateQueue,e.flags&=-2053,n.lanes&=~i,Xt(n,e,i)):(q&&r&&Vf(e),e.flags|=1,De(n,e,t,i),e.child)}function bp(n,e,t,r,i){if(Ue(t)){var o=!0;Il(e)}else o=!1;if(Wr(e,i),e.stateNode===null)ll(n,e),P0(e,t,r),Oc(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=dt(u):(u=Ue(t)?ir:Ee.current,u=ni(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)&&Cp(e,s,r,u),on=!1;var d=e.memoizedState;s.state=d,$l(e,r,s,i),a=e.memoizedState,l!==r||d!==a||We.current||on?(typeof c=="function"&&(Ec(e,t,c,r),a=e.memoizedState),(l=on||xp(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,I0(n,e),l=e.memoizedProps,u=e.type===e.elementType?l:gt(e.type,l),s.props=u,f=e.pendingProps,d=s.context,a=t.contextType,typeof a=="object"&&a!==null?a=dt(a):(a=Ue(t)?ir:Ee.current,a=ni(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)&&Cp(e,s,r,a),on=!1,d=e.memoizedState,s.state=d,$l(e,r,s,i);var h=e.memoizedState;l!==f||d!==h||We.current||on?(typeof p=="function"&&(Ec(e,t,p,r),h=e.memoizedState),(u=on||xp(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 Rc(n,e,t,r,o,i)}function Rc(n,e,t,r,i,o){a1(n,e);var s=(e.flags&128)!==0;if(!r&&!s)return i&&yp(e,t,!1),Xt(n,e,o);r=e.stateNode,QN.current=e;var l=s&&typeof t.getDerivedStateFromError!="function"?null:r.render();return e.flags|=1,n!==null&&s?(e.child=ii(e,n.child,null,o),e.child=ii(e,null,l,o)):De(n,e,l,o),e.memoizedState=r.state,i&&yp(e,t,!0),e.child}function u1(n){var e=n.stateNode;e.pendingContext?gp(n,e.pendingContext,e.pendingContext!==e.context):e.context&&gp(n,e.context,!1),Kf(n,e.containerInfo)}function Ip(n,e,t,r,i){return ri(),Jf(i),e.flags|=256,De(n,e,t,r),e.child}var Ac={dehydrated:null,treeContext:null,retryLane:0};function bc(n){return{baseLanes:n,cachePool:null,transitions:null}}function c1(n,e,t){var r=e.pendingProps,i=Q.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(Q,i&1),n===null)return Nc(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=ca(s,r,0,null),n=tr(n,r,t,null),o.return=e,n.return=e,o.sibling=n,e.child=o,e.child.memoizedState=bc(t),e.memoizedState=Ac,n):td(e,s));if(i=n.memoizedState,i!==null&&(l=i.dehydrated,l!==null))return YN(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=En(i,a),r.subtreeFlags=i.subtreeFlags&14680064),l!==null?o=En(l,o):(o=tr(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?bc(t):{baseLanes:s.baseLanes|t,cachePool:null,transitions:s.transitions},o.memoizedState=s,o.childLanes=n.childLanes&~t,e.memoizedState=Ac,r}return o=n.child,n=o.sibling,r=En(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 td(n,e){return e=ca({mode:"visible",children:e},n.mode,0,null),e.return=n,n.child=e}function Ds(n,e,t,r){return r!==null&&Jf(r),ii(e,n.child,null,t),n=td(e,e.pendingProps.children),n.flags|=2,e.memoizedState=null,n}function YN(n,e,t,r,i,o,s){if(t)return e.flags&256?(e.flags&=-257,r=du(Error(M(422))),Ds(n,e,s,r)):e.memoizedState!==null?(e.child=n.child,e.flags|=128,null):(o=r.fallback,i=e.mode,r=ca({mode:"visible",children:r.children},i,0,null),o=tr(o,i,s,null),o.flags|=2,r.return=e,o.return=e,r.sibling=o,e.child=r,e.mode&1&&ii(e,n.child,null,s),e.child.memoizedState=bc(s),e.memoizedState=Ac,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(M(419)),r=du(o,r,void 0),Ds(n,e,s,r)}if(l=(s&n.childLanes)!==0,Je||l){if(r=fe,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,Gt(n,i),vt(r,n,i,-1))}return ld(),r=du(Error(M(421))),Ds(n,e,s,r)}return i.data==="$?"?(e.flags|=128,e.child=n.child,e=uM.bind(null,n),i._reactRetry=e,null):(n=o.treeContext,Xe=xn(i.nextSibling),et=e,q=!0,wt=null,n!==null&&(ot[st++]=Ht,ot[st++]=jt,ot[st++]=or,Ht=n.id,jt=n.overflow,or=e),e=td(e,r.children),e.flags|=4096,e)}function zp(n,e,t){n.lanes|=e;var r=n.alternate;r!==null&&(r.lanes|=e),Mc(n.return,e,t)}function hu(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 f1(n,e,t){var r=e.pendingProps,i=r.revealOrder,o=r.tail;if(De(n,e,r.children,t),r=Q.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&&zp(n,t,e);else if(n.tag===19)zp(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(Q,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&&Vl(n)===null&&(i=t),t=t.sibling;t=i,t===null?(i=e.child,e.child=null):(i=t.sibling,t.sibling=null),hu(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&&Vl(n)===null){e.child=i;break}n=i.sibling,i.sibling=t,t=i,i=n}hu(e,!0,t,null,o);break;case"together":hu(e,!1,null,null,void 0);break;default:e.memoizedState=null}return e.child}function ll(n,e){!(e.mode&1)&&n!==null&&(n.alternate=null,e.alternate=null,e.flags|=2)}function Xt(n,e,t){if(n!==null&&(e.dependencies=n.dependencies),lr|=e.lanes,!(t&e.childLanes))return null;if(n!==null&&e.child!==n.child)throw Error(M(153));if(e.child!==null){for(n=e.child,t=En(n,n.pendingProps),e.child=t,t.return=e;n.sibling!==null;)n=n.sibling,t=t.sibling=En(n,n.pendingProps),t.return=e;t.sibling=null}return e.child}function GN(n,e,t){switch(e.tag){case 3:u1(e),ri();break;case 5:$0(e);break;case 1:Ue(e.type)&&Il(e);break;case 4:Kf(e,e.stateNode.containerInfo);break;case 10:var r=e.type._context,i=e.memoizedProps.value;H(Fl,r._currentValue),r._currentValue=i;break;case 13:if(r=e.memoizedState,r!==null)return r.dehydrated!==null?(H(Q,Q.current&1),e.flags|=128,null):t&e.child.childLanes?c1(n,e,t):(H(Q,Q.current&1),n=Xt(n,e,t),n!==null?n.sibling:null);H(Q,Q.current&1);break;case 19:if(r=(t&e.childLanes)!==0,n.flags&128){if(r)return f1(n,e,t);e.flags|=128}if(i=e.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),H(Q,Q.current),r)break;return null;case 22:case 23:return e.lanes=0,l1(n,e,t)}return Xt(n,e,t)}var d1,Ic,h1,p1;d1=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}};Ic=function(){};h1=function(n,e,t,r){var i=n.memoizedProps;if(i!==r){n=e.stateNode,Qn(At.current);var o=null;switch(t){case"input":i=tc(n,i),r=tc(n,r),o=[];break;case"select":i=G({},i,{value:void 0}),r=G({},r,{value:void 0}),o=[];break;case"textarea":i=ic(n,i),r=ic(n,r),o=[];break;default:typeof i.onClick!="function"&&typeof r.onClick=="function"&&(n.onclick=Al)}sc(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"&&j("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)}};p1=function(n,e,t,r){t!==r&&(e.flags|=4)};function Ni(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 ve(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 XN(n,e,t){var r=e.pendingProps;switch(Bf(e),e.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return ve(e),null;case 1:return Ue(e.type)&&bl(),ve(e),null;case 3:return r=e.stateNode,oi(),K(We),K(Ee),Qf(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(n===null||n.child===null)&&(Es(e)?e.flags|=4:n===null||n.memoizedState.isDehydrated&&!(e.flags&256)||(e.flags|=1024,wt!==null&&(Jc(wt),wt=null))),Ic(n,e),ve(e),null;case 5:qf(e);var i=Qn($o.current);if(t=e.type,n!==null&&e.stateNode!=null)h1(n,e,t,r,i),n.ref!==e.ref&&(e.flags|=512,e.flags|=2097152);else{if(!r){if(e.stateNode===null)throw Error(M(166));return ve(e),null}if(n=Qn(At.current),Es(e)){r=e.stateNode,t=e.type;var o=e.memoizedProps;switch(r[Et]=e,r[Fo]=o,n=(e.mode&1)!==0,t){case"dialog":j("cancel",r),j("close",r);break;case"iframe":case"object":case"embed":j("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[Et]=e,n[Fo]=r,d1(n,e,!1,!1),e.stateNode=n;e:{switch(s=lc(t,r),t){case"dialog":j("cancel",n),j("close",n),i=r;break;case"iframe":case"object":case"embed":j("load",n),i=r;break;case"video":case"audio":for(i=0;ili&&(e.flags|=128,r=!0,Ni(o,!1),e.lanes=4194304)}else{if(!r)if(n=Vl(s),n!==null){if(e.flags|=128,r=!0,t=n.updateQueue,t!==null&&(e.updateQueue=t,e.flags|=4),Ni(o,!0),o.tail===null&&o.tailMode==="hidden"&&!s.alternate&&!q)return ve(e),null}else 2*te()-o.renderingStartTime>li&&t!==1073741824&&(e.flags|=128,r=!0,Ni(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=te(),e.sibling=null,t=Q.current,H(Q,r?t&1|2:t&1),e):(ve(e),null);case 22:case 23:return sd(),r=e.memoizedState!==null,n!==null&&n.memoizedState!==null!==r&&(e.flags|=8192),r&&e.mode&1?Ye&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 ZN(n,e){switch(Bf(e),e.tag){case 1:return Ue(e.type)&&bl(),n=e.flags,n&65536?(e.flags=n&-65537|128,e):null;case 3:return oi(),K(We),K(Ee),Qf(),n=e.flags,n&65536&&!(n&128)?(e.flags=n&-65537|128,e):null;case 5:return qf(e),null;case 13:if(K(Q),n=e.memoizedState,n!==null&&n.dehydrated!==null){if(e.alternate===null)throw Error(M(340));ri()}return n=e.flags,n&65536?(e.flags=n&-65537|128,e):null;case 19:return K(Q),null;case 4:return oi(),null;case 10:return Uf(e.type._context),null;case 22:case 23:return sd(),null;case 24:return null;default:return null}}var Ts=!1,Ce=!1,eM=typeof WeakSet=="function"?WeakSet:Set,D=null;function Ir(n,e){var t=n.ref;if(t!==null)if(typeof t=="function")try{t(null)}catch(r){X(n,e,r)}else t.current=null}function zc(n,e,t){try{t()}catch(r){X(n,e,r)}}var Pp=!1;function tM(n,e){if(yc=Dl,n=S0(),$f(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(Sc={focusedElem:n,selectionRange:t},Dl=!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:gt(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){X(e,e.return,C)}if(n=e.sibling,n!==null){n.return=e.return,D=n;break}D=e.return}return h=Pp,Pp=!1,h}function co(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&&zc(e,t,o)}i=i.next}while(i!==r)}}function aa(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 Pc(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 m1(n){var e=n.alternate;e!==null&&(n.alternate=null,m1(e)),n.child=null,n.deletions=null,n.sibling=null,n.tag===5&&(e=n.stateNode,e!==null&&(delete e[Et],delete e[Fo],delete e[vc],delete e[LN],delete e[$N])),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 g1(n){return n.tag===5||n.tag===3||n.tag===4}function Fp(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||g1(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 Fc(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=Al));else if(r!==4&&(n=n.child,n!==null))for(Fc(n,e,t),n=n.sibling;n!==null;)Fc(n,e,t),n=n.sibling}function Lc(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(Lc(n,e,t),n=n.sibling;n!==null;)Lc(n,e,t),n=n.sibling}var he=null,yt=!1;function en(n,e,t){for(t=t.child;t!==null;)y1(n,e,t),t=t.sibling}function y1(n,e,t){if(Rt&&typeof Rt.onCommitFiberUnmount=="function")try{Rt.onCommitFiberUnmount(ea,t)}catch{}switch(t.tag){case 5:Ce||Ir(t,e);case 6:var r=he,i=yt;he=null,en(n,e,t),he=r,yt=i,he!==null&&(yt?(n=he,t=t.stateNode,n.nodeType===8?n.parentNode.removeChild(t):n.removeChild(t)):he.removeChild(t.stateNode));break;case 18:he!==null&&(yt?(n=he,t=t.stateNode,n.nodeType===8?su(n.parentNode,t):n.nodeType===1&&su(n,t),Ao(n)):su(he,t.stateNode));break;case 4:r=he,i=yt,he=t.stateNode.containerInfo,yt=!0,en(n,e,t),he=r,yt=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)&&zc(t,e,s),i=i.next}while(i!==r)}en(n,e,t);break;case 1:if(!Ce&&(Ir(t,e),r=t.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=t.memoizedProps,r.state=t.memoizedState,r.componentWillUnmount()}catch(l){X(t,e,l)}en(n,e,t);break;case 21:en(n,e,t);break;case 22:t.mode&1?(Ce=(r=Ce)||t.memoizedState!==null,en(n,e,t),Ce=r):en(n,e,t);break;default:en(n,e,t)}}function Lp(n){var e=n.updateQueue;if(e!==null){n.updateQueue=null;var t=n.stateNode;t===null&&(t=n.stateNode=new eM),e.forEach(function(r){var i=cM.bind(null,n,r);t.has(r)||(t.add(r),r.then(i,i))})}}function mt(n,e){var t=e.deletions;if(t!==null)for(var r=0;ri&&(i=s),r&=~o}if(r=i,r=te()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*rM(r/1960))-r,10n?16:n,gn===null)var r=!1;else{if(n=gn,gn=null,Ul=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;ate()-id?er(n,0):rd|=t),He(n,e)}function M1(n,e){e===0&&(n.mode&1?(e=ks,ks<<=1,!(ks&130023424)&&(ks=4194304)):e=1);var t=Re();n=Gt(n,e),n!==null&&(es(n,e,t),He(n,t))}function uM(n){var e=n.memoizedState,t=0;e!==null&&(t=e.retryLane),M1(n,t)}function cM(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),M1(n,t)}var E1;E1=function(n,e,t){if(n!==null)if(n.memoizedProps!==e.pendingProps||We.current)Je=!0;else{if(!(n.lanes&t)&&!(e.flags&128))return Je=!1,GN(n,e,t);Je=!!(n.flags&131072)}else Je=!1,q&&e.flags&1048576&&T0(e,Pl,e.index);switch(e.lanes=0,e.tag){case 2:var r=e.type;ll(n,e),n=e.pendingProps;var i=ni(e,Ee.current);Wr(e,t),i=Gf(null,e,r,n,i,t);var o=Xf();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,Ue(r)?(o=!0,Il(e)):o=!1,e.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,jf(e),i.updater=sa,e.stateNode=i,i._reactInternals=e,Oc(e,r,n,t),e=Rc(null,e,r,!0,o,t)):(e.tag=0,q&&o&&Vf(e),De(null,e,i,t),e=e.child),e;case 16:r=e.elementType;e:{switch(ll(n,e),n=e.pendingProps,i=r._init,r=i(r._payload),e.type=r,i=e.tag=dM(r),n=gt(r,n),i){case 0:e=Tc(null,e,r,n,t);break e;case 1:e=bp(null,e,r,n,t);break e;case 11:e=Rp(null,e,r,n,t);break e;case 14:e=Ap(null,e,r,gt(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:gt(r,i),Tc(n,e,r,i,t);case 1:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:gt(r,i),bp(n,e,r,i,t);case 3:e:{if(u1(e),n===null)throw Error(M(387));r=e.pendingProps,o=e.memoizedState,i=o.element,I0(n,e),$l(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=si(Error(M(423)),e),e=Ip(n,e,r,t,i);break e}else if(r!==i){i=si(Error(M(424)),e),e=Ip(n,e,r,t,i);break e}else for(Xe=xn(e.stateNode.containerInfo.firstChild),et=e,q=!0,wt=null,t=L0(e,null,r,t),e.child=t;t;)t.flags=t.flags&-3|4096,t=t.sibling;else{if(ri(),r===i){e=Xt(n,e,t);break e}De(n,e,r,t)}e=e.child}return e;case 5:return $0(e),n===null&&Nc(e),r=e.type,i=e.pendingProps,o=n!==null?n.memoizedProps:null,s=i.children,wc(r,i)?s=null:o!==null&&wc(r,o)&&(e.flags|=32),a1(n,e),De(n,e,s,t),e.child;case 6:return n===null&&Nc(e),null;case 13:return c1(n,e,t);case 4:return Kf(e,e.stateNode.containerInfo),r=e.pendingProps,n===null?e.child=ii(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:gt(r,i),Rp(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(Fl,r._currentValue),r._currentValue=s,o!==null)if(Ct(o.value,s)){if(o.children===i.children&&!We.current){e=Xt(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),Mc(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),Mc(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,Wr(e,t),i=dt(i),r=r(i),e.flags|=1,De(n,e,r,t),e.child;case 14:return r=e.type,i=gt(r,e.pendingProps),i=gt(r.type,i),Ap(n,e,r,i,t);case 15:return s1(n,e,e.type,e.pendingProps,t);case 17:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:gt(r,i),ll(n,e),e.tag=1,Ue(r)?(n=!0,Il(e)):n=!1,Wr(e,t),P0(e,r,i),Oc(e,r,i,t),Rc(null,e,r,!0,n,t);case 19:return f1(n,e,t);case 22:return l1(n,e,t)}throw Error(M(156,e.tag))};function O1(n,e){return Zy(n,e)}function fM(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 ut(n,e,t,r){return new fM(n,e,t,r)}function ad(n){return n=n.prototype,!(!n||!n.isReactComponent)}function dM(n){if(typeof n=="function")return ad(n)?1:0;if(n!=null){if(n=n.$$typeof,n===Of)return 11;if(n===Df)return 14}return 2}function En(n,e){var t=n.alternate;return t===null?(t=ut(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 cl(n,e,t,r,i,o){var s=2;if(r=n,typeof n=="function")ad(n)&&(s=1);else if(typeof n=="string")s=5;else e:switch(n){case Nr:return tr(t.children,i,o,e);case Ef:s=8,i|=8;break;case Gu:return n=ut(12,t,e,i|2),n.elementType=Gu,n.lanes=o,n;case Xu:return n=ut(13,t,e,i),n.elementType=Xu,n.lanes=o,n;case Zu:return n=ut(19,t,e,i),n.elementType=Zu,n.lanes=o,n;case Fy:return ca(t,i,o,e);default:if(typeof n=="object"&&n!==null)switch(n.$$typeof){case zy:s=10;break e;case Py:s=9;break e;case Of:s=11;break e;case Df:s=14;break e;case rn:s=16,r=null;break e}throw Error(M(130,n==null?n:typeof n,""))}return e=ut(s,t,e,i),e.elementType=n,e.type=r,e.lanes=o,e}function tr(n,e,t,r){return n=ut(7,n,r,e),n.lanes=t,n}function ca(n,e,t,r){return n=ut(22,n,r,e),n.elementType=Fy,n.lanes=t,n.stateNode={isHidden:!1},n}function pu(n,e,t){return n=ut(6,n,null,e),n.lanes=t,n}function mu(n,e,t){return e=ut(4,n.children!==null?n.children:[],n.key,e),e.lanes=t,e.stateNode={containerInfo:n.containerInfo,pendingChildren:null,implementation:n.implementation},e}function hM(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=Qa(0),this.expirationTimes=Qa(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Qa(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function ud(n,e,t,r,i,o,s,l,a){return n=new hM(n,e,t,l,a),e===1?(e=1,o===!0&&(e|=8)):e=0,o=ut(3,null,null,e),n.current=o,o.stateNode=n,o.memoizedState={element:r,isDehydrated:t,cache:null,transitions:null,pendingSuspenseBoundaries:null},jf(o),n}function pM(n,e,t){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(A1)}catch(n){console.error(n)}}A1(),Ty.exports=nt;var ai=Ty.exports,b1,Hp=ai;b1=Hp.createRoot,Hp.hydrateRoot;const pi=v.createContext(null),wM=v.createContext(null),I1=v.createContext(null),bs=new WeakMap;function kM(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=[ge.node(0,n.state.doc.content.size,e)],r=bs.get(n);return!r||r[0].to!==n.state.doc.content.size||!r[0].type.eq(t[0].type)?(bs.set(n,t),t):r}const vM=[],xM={},_c=J.empty;class cn{constructor(e){this.members=e}map(e,t){const r=this.members.map(i=>i.map(e,t,xM));return cn.from(r)}forChild(e,t){if(t.isLeaf)return J.empty;let r=[];for(let i=0;it instanceof J)?e:e.reduce((t,r)=>t.concat(r instanceof J?r:r.members),[]))}}forEachSet(e){for(let t=0;t0;)e++;n.splice(e,0,t)}const gu=new WeakMap;function NM(n,e){const t=[];n.someProp("decorations",s=>{const l=s(n.state);l&&l!=_c&&t.push(l)}),e&&t.push(J.create(n.state.doc,[e]));const r=gu.get(n);if(!r){const s=cn.from(t);return gu.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=cn.from(t);return gu.set(n,s),s}return r}const hd=function(n){for(let e=0;;e++)if(n=n.previousSibling,!n)return e},Kp=function(n){const e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e},MM=function(n,e,t,r){return t&&(qp(n,e,t,r,-1)||qp(n,e,t,r,1))},EM=/^(img|br|input|textarea|hr)$/i;function qp(n,e,t,r,i){for(;;){if(n==t&&e==r)return!0;if(e==(i<0?0:Kl(n))){const o=n.parentNode;if(!o||o.nodeType!=1||DM(n)||EM.test(n.nodeName)||n.contentEditable=="false")return!1;e=hd(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?Kl(n):0}else return!1}}function Kl(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function OM(n,e,t){for(let r=e==0,i=e==Kl(n);r||i;){if(n==t)return!0;const o=hd(n);if(n=n.parentNode,!n)return!1;r=r&&o==0,i=i&&o==Kl(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 P1=function(n){return n.focusNode&&MM(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)},F1=v.createContext(null);function TM(n,e){const t=v.useContext(F1);v.useLayoutEffect(()=>t(n),e)}function L1(n,e){const{view:t}=v.useContext(pi);TM(()=>{if(t)return n(t)},e&&[t,...e])}const RM=v.forwardRef(function({widget:e,pos:t,...r},i){const[o,s]=v.useState(!0),l=v.useRef(null);return v.useImperativeHandle(i,()=>l.current,[]),L1(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,hd(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 AM(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 bM={side:0};class Wo{constructor(e,t){this.Component=e,this.spec=t??bM,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 ge(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&&AM(this.spec,e.spec))}destroy(){}}function $1(n,e,t){return new ge(n,n,new Wo(e,t))}function yu(){return Math.floor(Math.random()*0xffffffffffff).toString(16)}const Uo=new Qo("@nytimes/react-prosemirror/reactKeys");function IM(){let n=!1;return new Lt({key:Uo,state:{init(e,t){const r={posToKey:new Map,keyToPos:new Map};return t.doc.descendants((i,o)=>{const s=yu();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=yu()),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=yu();return l.posToKey.set(c,f),l.keyToPos.set(f,c),!0}),l}},props:{handleDOMEvents:{compositionstart:()=>{n=!0},compositionend:()=>{n=!1}}}})}function Su(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 zM(n){let e=null,t=null;return new Lt({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($1(i.selection.from,RM,{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 Su(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);Su(r,a,{from:c,to:f})}});break}case"insertText":{Su(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 Ft=typeof navigator<"u"?navigator:null,Qp=typeof document<"u"?document:null,Pn=Ft&&Ft.userAgent||"",Wc=/Edge\/(\d+)/.exec(Pn),V1=/MSIE \d/.exec(Pn),Uc=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Pn),ma=!!(V1||Uc||Wc),PM=V1?document.documentMode:Uc?+Uc[1]:Wc?+Wc[1]:0,B1=!ma&&/gecko\/(\d+)/i.test(Pn),FM=B1&&+(/Firefox\/(\d+)/.exec(Pn)||[0,0])[1],Hc=!ma&&/Chrome\/(\d+)/.exec(Pn),LM=!!Hc,$M=Hc?+Hc[1]:0,J1=!ma&&!!Ft&&/Apple Computer/.test(Ft.vendor),_1=J1&&(/Mobile\/\w+/.test(Pn)||!!Ft&&Ft.maxTouchPoints>2),VM=_1||(Ft?/Mac/.test(Ft.platform):!1),BM=Ft?/Win/.test(Ft.platform):!1,JM=/Android \d/.test(Pn),W1=!!Qp&&"webkitFontSmoothing"in Qp.documentElement.style,_M=W1?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,Me={ie:ma,ie_version:PM,gecko:B1,gecko_version:FM,chrome:LM,chrome_version:$M,safari:J1,ios:_1,mac:VM,windows:BM,android:JM,webkit:W1,webkit_version:_M};function wu(n){return n.editable&&!n.hasFocus()?!1:WM(n)}function WM(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 UM(n,e,t,r){return n.someProp("createSelectionBetween",i=>i(n,e,t))||$.between(e,t,r)}function Yp(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(P1(t)){for(a=s;i&&!i.node;)i=i.parent;const f=i.node;if(i&&f.isAtom&&I.isSelectable(f)&&i.parent&&!(f.isInline&&OM(t.focusNode,t.focusOffset,i.dom))){const d=i.posBefore;u=new I(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(()=>{(!U1(e)||e.state.selection.visible)&&e.dom.classList.remove("ProseMirror-hideselection")},20))})}const nm=Me.safari||Me.chrome&&Me.chrome_version<63;function Is(n,e=!1){const t=n,r=t.state.selection;if(KM(t,r),!!U1(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)QM(t);else{const{anchor:i,head:o}=r;let s,l;nm&&!(r instanceof $)&&(r.$from.parent.inlineContent||(s=em(t,r.from)),!r.empty&&!r.$from.parent.inlineContent&&(l=em(t,r.to))),t.docView.setSelection(i,o,t.root,e),nm&&(s&&tm(s),l&&tm(l)),r.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&YM(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}class GM{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 XM{constructor(e){this.view=e,this.flushingSoon=-1,this.currentSelection=new GM,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=Kp(o))t.add(o);for(let o=e.anchorNode;o;o=Kp(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=Yp(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)&&wu(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(wu(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 ui=0,rm=1,zs=2,Ho=3;class is{constructor(e,t,r,i,o){this.parent=e,this.children=t,this.pos=r,this.dom=i,this.contentDOM=o,this.dirty=ui,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;tsn(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 gd){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 pd&&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?sn(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=sn(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?zs:rm,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?zs:Ho}r=s}this.dirty=zs}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){const r=e==1?zs:rm;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==ui&&e.eq(this.node)&&tE(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 eE extends md{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 gd extends is{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==ui&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}function tE(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 Lt({key:new Qo("@nytimes/react-prosemirror/componentEventListeners"),props:{handleDOMEvents:e}})}function rE(){const[n,e]=v.useState(new Map),t=v.useCallback((o,s)=>{const l=n.get(o)??[];l.unshift(s),n.has(o)||(n.set(o,l),e(new Map(n)))},[n]),r=v.useCallback((o,s)=>{const l=n.get(o);l==null||l.splice(l.indexOf(s),1)},[n]),i=v.useMemo(()=>nE(n),[n]);return{registerEventListener:t,unregisterEventListener:r,componentEventListenersPlugin:i}}function H1(){const[,n]=v.useReducer(e=>e+1,0);return n}function iE(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 oE(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 sE(n,e){for(const t of Object.keys(n))if(n[t]!==e[t])return!0;return!1}function im(n){return!n.someProp("editable",e=>e(n.state)===!1)}class lE extends zv{constructor(e,t){super(e,{state:fn.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 XM(this),this.domObserver.start(),this.editable=im(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=iE(this);return oE(this.nodeViews,e)}pureSetProps(e){this._props={...this._props,...e},this.state=this._props.state,this.editable=im(this)}runPendingEffects(){if(sE(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 aE=new Am({nodes:{doc:{content:"text*"},text:{inline:!0}}}),uE=fn.create({schema:aE});function cE(n,e){const[t,r]=v.useState(null),[i,o]=v.useState(null),s=H1(),l=e.defaultState??uE,[a,u]=v.useState(l),c=e.state??a,{componentEventListenersPlugin:f,registerEventListener:d,unregisterEventListener:p}=rE(),h=v.useCallback(N=>{ai.flushSync(()=>{o(N)})},[]),m=v.useMemo(()=>[...e.plugins??[],f,zM(h)],[e.plugins,f,h]),w=v.useCallback(function(E){ai.flushSync(()=>{e.state||u(O=>O.apply(E)),e.dispatchTransaction&&e.dispatchTransaction.call(this,E)})},[e.dispatchTransaction,e.state]),g=document.createElement("div"),y=v.useRef(new md(void 0,[],-1,c.doc,[],J.empty,g,null,g,()=>!1)),S={...e,state:c,plugins:m,dispatchTransaction:w,docView:y.current};return v.useLayoutEffect(()=>()=>{t==null||t.destroy()},[t]),v.useLayoutEffect(()=>{if(t&&t.dom!==n&&r(null),!!n&&!t){const N=new lE({mount:n},S);r(N),N.dom.addEventListener("compositionend",s);return}}),v.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:v.useMemo(()=>({view:t,registerEventListener:d,unregisterEventListener:p,cursorWrapper:i,docViewDescRef:y}),[t,d,p,i]),state:c}}function fE({children:n}){const e=v.useRef(new Set).current,t=v.useRef(new Set).current,r=v.useRef(!1),i=H1(),o=v.useRef(!0),s=v.useCallback(()=>{o.current||(i(),o.current=!0)},[i]),l=v.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 v.useLayoutEffect(()=>(o.current=!1,e.forEach(a=>a()),e.clear(),()=>{t.forEach(a=>a()),t.clear()})),v.useLayoutEffect(()=>(r.current=!0,()=>{r.current=!1}),[]),A.jsx(F1.Provider,{value:l,children:n})}const pt=v.createContext({parentRef:{current:void 0},siblingsRef:{current:[]}});function j1(n,e,t,r,i,o,s,l){const{view:a}=v.useContext(pi),[u,c]=v.useState(!0),f=v.useRef(s),d=v.useRef(()=>!1),p=v.useCallback(g=>{d.current=g},[]),{siblingsRef:h,parentRef:m}=v.useContext(pt),w=v.useRef([]);return v.useLayoutEffect(()=>{const g=h.current;return()=>{if(f.current&&g.includes(f.current)){const y=g.indexOf(f.current);g.splice(y,1)}}},[h]),v.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.pos=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 md(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.pos-C.pos);for(const S of w.current)if(S.parent=f.current,S instanceof Ql){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 Ql&&!(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 dE(n,e){return n.type.side-e.type.side}function hE(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 K1(){const{view:n}=v.useContext(pi);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 mE(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 md=v.memo(v.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=K1(q1(l),a));const c=[];for(let f=u;fu)throw new RangeError("Content hole must be the only child of its parent node");return v.createElement(s,a,t)}c.push(A.jsx(md,{outputSpec:d,children:t}))}return v.createElement(s,a,...c)})),Q1=v.memo(v.forwardRef(function({mark:e,pos:t,children:r},i){const{siblingsRef:o,parentRef:s}=v.useContext(pt),l=v.useRef(void 0),a=v.useRef([]),u=v.useRef(null);v.useImperativeHandle(i,()=>u.current,[]);const c=v.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`);v.useLayoutEffect(()=>{const d=o.current;return()=>{if(l.current&&d.includes(l.current)){const p=d.indexOf(l.current);d.splice(p,1)}}},[o]),v.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.pos=t):l.current=new GM(s.current,a.current,t,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.pos-h.pos);for(const p of a.current)p.parent=l.current});const f=v.useMemo(()=>({parentRef:l,siblingsRef:a}),[a,l]);return A.jsx(md,{ref:u,outputSpec:c,children:A.jsx(pt.Provider,{value:f,children:r})})}));function gE({widget:n,pos:e}){const{siblingsRef:t,parentRef:r}=v.useContext(pt),i=v.useRef(null),o=v.useRef(null),s=v.useRef(e);return s.current=e,v.useLayoutEffect(()=>{const l=t.current;return()=>{if(i.current&&l.includes(i.current)){const a=l.indexOf(i.current);l.splice(a,1)}}},[t]),P1(l=>{if(!o.current)return;const a=n.type.toDOM;let u=typeof a=="function"?a(l,()=>s.current):a;if(!n.type.spec.raw){if(u.nodeType!=1){const c=document.createElement("span");c.appendChild(u),u=c}u.contentEditable="false",u.classList.add("ProseMirror-widget")}o.current.firstElementChild!==u&&o.current.replaceChildren(u)}),v.useLayoutEffect(()=>{o.current&&(i.current?(i.current.parent=r.current,i.current.widget=n,i.current.pos=e,i.current.dom=o.current):i.current=new dd(r.current,e,n,o.current),t.current.includes(i.current)||t.current.push(i.current),t.current.sort((l,a)=>l.pos-a.pos))}),A.jsx("span",{ref:o})}const yE=v.createContext(null),Y1=v.memo(function({outerDeco:e,pos:t,node:r,innerDeco:i,...o}){const s=v.useRef(null),l=v.useRef(null),a=v.useRef(null),u=v.useRef(r),c=v.useRef(e),f=v.useRef(i),d=v.useRef(t);d.current=t;const p=v.useRef(null),h=v.useRef(null),{nodeViews:m}=v.useContext(A1),{view:w}=v.useContext(pi);let g=null;const y=m[r.type.name],S=v.useMemo(()=>{var W,we;return(we=(W=r.type.spec).toDOM)==null?void 0:we.call(W,r)},[r]),C=w==null?void 0:w.someProp("nodeViews",W=>W==null?void 0:W[r.type.name]);v.useLayoutEffect(()=>{if(!h.current||!p.current)return;const{dom:W}=h.current;return l.current=p.current,p.current.appendChild(W),()=>{var we,mi;(mi=(we=h.current)==null?void 0:we.destroy)==null||mi.call(we)}},[]),v.useLayoutEffect(()=>{if(!C||!h.current)return;const{destroy:W,update:we}=h.current;if(((we==null?void 0:we.call(h.current,r,e,i))??!0)||(W==null||W.call(h.current),!p.current))return;u.current=r,c.current=e,f.current=i,h.current=C(u.current,w,()=>d.current,c.current,f.current);const{dom:gi}=h.current;l.current=p.current,p.current.appendChild(gi)},[C,w,i,r,e]);const{hasContentDOM:N,childDescriptors:E,setStopEvent:O,nodeViewDescRef:T}=U1(r,t,s,l,i,e,void 0,a),b={...o,...!N&&{contentEditable:!1}};if(y)g=A.jsx(y,{...b,ref:l,nodeProps:{node:r,pos:t,decorations:e,innerDecorations:i,isSelected:!1},children:A.jsx(mo,{pos:t,node:r,innerDecorations:i})});else if(C){h.current||(h.current=C(u.current,w,()=>d.current,c.current,f.current));const{contentDOM:W}=h.current;a.current=W??null,g=v.createElement(r.isInline?"span":"div",{ref:p,contentEditable:!!W,suppressContentEditableWarning:!0},W&&ai.createPortal(A.jsx(mo,{pos:t,node:r,innerDecorations:i}),W))}else S&&(g=A.jsx(md,{...b,ref:l,outputSpec:S,children:A.jsx(mo,{pos:t,node:r,innerDecorations:i})}));if(!g)throw new Error(`Node spec for ${r.type.name} is missing toDOM`);const z=v.cloneElement(e.reduce(gd,g),e.some(W=>W.type.attrs.nodeName)?{ref:s}:void 0),le=r.marks.reduce((W,we)=>A.jsx(Q1,{pos:t,mark:we,children:W}),z),$t=v.useMemo(()=>({parentRef:T,siblingsRef:E}),[E,T]);return A.jsx(yE.Provider,{value:O,children:A.jsx(pt.Provider,{value:$t,children:v.cloneElement(le,r.marks.length||e.some(W=>W.type.attrs.nodeName)?{ref:s}:void 0)})})});function SE({pos:n}){const{siblingsRef:e,parentRef:t}=v.useContext(pt),r=v.useRef(null),i=v.useRef(null),[o,s]=v.useState(!1);return v.useLayoutEffect(()=>{const l=e.current;return()=>{if(r.current&&l.includes(r.current)){const a=l.indexOf(r.current);l.splice(a,1)}}},[e]),v.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.pos=n):r.current=new pd(t.current,[],n,i.current,null),e.current.includes(r.current)||e.current.push(r.current))}),o?A.jsx("img",{ref:i,className:"ProseMirror-separator"}):null}function wE(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;ou.pos-c.pos)}shouldComponentUpdate(e){return!wE(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,pos:t,node:r,decorations:i}=this.props;return e!=null&&e.composing&&e.state.selection.from>=t&&e.state.selection.from<=t+r.nodeSize?this.renderRef:(this.renderRef=i.reduce(gd,r.text),this.renderRef)}}function vE({pos:n}){const{siblingsRef:e,parentRef:t}=v.useContext(pt),r=v.useRef(null),i=v.useRef(null);return v.useLayoutEffect(()=>{const o=e.current;return()=>{if(r.current&&o.includes(r.current)){const s=o.indexOf(r.current);o.splice(s,1)}}},[e]),v.useLayoutEffect(()=>{i.current&&(r.current?(r.current.parent=t.current,r.current.dom=i.current,r.current.pos=n):r.current=new pd(t.current,[],n,i.current,null),e.current.includes(r.current)||e.current.push(r.current),e.current.sort((o,s)=>o.pos-s.pos))}),A.jsx("br",{ref:i,className:"ProseMirror-trailingBreak"})}function xE({widget:n,pos:e}){const{siblingsRef:t,parentRef:r}=v.useContext(pt),i=v.useRef(null),o=v.useRef(null);v.useLayoutEffect(()=>{const l=t.current;return()=>{if(i.current&&l.includes(i.current)){const a=l.indexOf(i.current);l.splice(a,1)}}},[t]),v.useLayoutEffect(()=>{o.current&&(i.current?(i.current.parent=r.current,i.current.widget=n,i.current.pos=e,i.current.dom=o.current):i.current=new dd(r.current,e,n,o.current),t.current.includes(i.current)||t.current.push(i.current),t.current.sort((l,a)=>l.pos-a.pos))});const{Component:s}=n.type;return s&&A.jsx(s,{ref:o,widget:n,pos:e,contentEditable:!1})}function gd(n,e){const{nodeName:t,...r}=e.type.attrs,i=q1(r);return t||typeof n=="string"?v.createElement(t??"span",i,n):v.cloneElement(n,K1(n.props,i))}const rm=v.memo(function n({innerPos:e,childViews:t}){const{view:r}=v.useContext(pi),i=H1(),o=t.reduce((s,l)=>{var c;const a=s[s.length-1];if(!a)return[[l]];const u=a[a.length-1];return u?!l.marks.length&&!u.marks.length||l.marks.length&&u.marks.length&&((c=l.marks[0])!=null&&c.eq(u.marks[0]))?[...s.slice(0,s.length-1),[...a.slice(0,a.length),l]]:[...s,[l]]:[...s.slice(0,s.length),[l]]},[]);return A.jsx(A.Fragment,{children:o.map(s=>{const l=s[0];if(!l)return null;const a=l.marks[0];return a?A.jsx(Q1,{pos:e+l.offset,mark:a,children:A.jsx(n,{innerPos:e,childViews:s.map(u=>({...u,marks:u.marks.slice(1)}))},po(e,l,i==null?void 0:i.posToKey))},po(e,l,i==null?void 0:i.posToKey)):s.map(u=>{const c=e+u.offset,f=u.type==="widget"?A.jsx(xE,{widget:u.widget,pos:c}):u.type==="native-widget"?A.jsx(gE,{widget:u.widget,pos:c}):u.node.isText?A.jsx(pt.Consumer,{children:({siblingsRef:d,parentRef:p})=>A.jsx(kE,{view:r,node:u.node,pos:c,siblingsRef:d,parentRef:p,decorations:u.outerDeco})}):A.jsx(Y1,{node:u.node,pos:c,outerDeco:u.outerDeco,innerDeco:u.innerDeco});return v.cloneElement(f,{key:po(e,u,i==null?void 0:i.posToKey)})})})})});function po(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 CE(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 NE(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)}}function ME(n,e,t){return n.length?n.every(r=>r.type!=="node"||r.node.isInline)?[A.jsx(rm,{childViews:n,innerPos:e},po(e,n[0],t))]:n.map(r=>{if(r.type==="node"){const i=e+r.offset,o=(t==null?void 0:t.get(i))??i;return A.jsx(Y1,{outerDeco:r.outerDeco,node:r.node,innerDeco:r.innerDeco,pos:i},o)}else return A.jsx(rm,{childViews:[r],innerPos:e},po(e,r,t))}):[]}const mo=v.memo(function({pos:e,node:t,innerDecorations:r}){const i=H1();if(!t)return null;const o=e+1,s=[];fE(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}),CE(s)},(u,c,f,d)=>{s.push({type:"node",node:u,marks:u.marks,innerDeco:f,outerDeco:c,offset:d}),NE(s)});const l=ME(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(SE,{pos:o},"trailing-hack-img"),A.jsx(vE,{pos:o},"trailing-hack-br")),A.jsx(A.Fragment,{children:l})}),EE=v.memo(v.forwardRef(function({className:e,node:t,innerDeco:r,outerDeco:i,as:o,viewDesc:s,...l},a){const u=v.useRef(null);v.useImperativeHandle(a,()=>u.current,[]);const{childDescriptors:c,nodeViewDescRef:f}=U1(t,-1,u,u,r,i,s),d=v.useMemo(()=>({parentRef:f,siblingsRef:c}),[c,f]),p={...l,ref:u,className:e,suppressContentEditableWarning:!0},h=o?v.cloneElement(o,p,A.jsx(pt.Provider,{value:d,children:A.jsx(mo,{pos:-1,node:t,innerDecorations:r})})):v.createElement("div",p,A.jsx(pt.Provider,{value:d,children:A.jsx(mo,{pos:-1,node:t,innerDecorations:r})}));if(!t)return h;const m=i.filter(g=>!g.inline);return m.length?m.reduce(gd,h):h})),G1=v.createContext(null);function OE({as:n,...e},t){const r=v.useRef([]),i=v.useRef(null),{setMount:o,...s}=v.useContext(G1),l=v.useRef(void 0);v.useImperativeHandle(t,()=>i.current,[]);const a=v.useMemo(()=>({parentRef:l,siblingsRef:r}),[r,l]);return A.jsx(pt.Provider,{value:a,children:A.jsx(EE,{ref:u=>{i.current=u,o(u)},...e,...s,as:n})})}const DE=v.forwardRef(OE);function TE({className:n,children:e,nodeViews:t={},customNodeViews:r,...i}){var p;const[o,s]=v.useState(null),{editor:l,state:a}=aE(o,{...i,nodeViews:r}),u=v.useMemo(()=>l.view?xM(l.view,a,l.cursorWrapper):J.empty,[l.cursorWrapper,l.view,a,i.decorations]),c=v.useMemo(()=>l.view?SM(l.view,a):[],[l.view,a,i.attributes,i.editable]),f=v.useMemo(()=>({nodeViews:t}),[t]),d=v.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(pi.Provider,{value:l,children:A.jsx(yM.Provider,{value:a,children:A.jsx(A1.Provider,{value:f,children:A.jsx(G1.Provider,{value:d,children:e})})})})}function RE(n){return A.jsx(uE,{children:A.jsx(TE,{...n})})}const Pr=new Tm({nodes:{doc:{content:"block+"},paragraph:{group:"block",content:"inline*",toDOM(){return["p",0]}},...Fx({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]}}}}),AE=cn.create({schema:Pr,doc:Pr.nodes.doc.create({},[Pr.nodes.paragraph.create()]),plugins:[AM(),ex({rules:[tx(/^\s*([-+*])\s$/,Pr.nodes.list)]}),tC(),hC()]});v.forwardRef(function({children:e,nodeProps:t,...r},i){return A.jsx("p",{ref:i,...r,children:e})});const bE=v.forwardRef(function({children:e,nodeProps:t,...r},i){return A.jsx("ul",{ref:i,...r,children:e})}),IE=v.forwardRef(function({children:e,nodeProps:t,...r},i){return A.jsx("li",{ref:i,...r,children:e})}),zE=v.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})})}),PE=v.forwardRef(function({widget:e,pos: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"})}),FE=new Lt({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 Lt({props:{decorations(n){return J.create(n.doc,[F1(n.selection.from,PE,{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 LE=[ox({...Jw,"Mod-i":Bd(Pr.marks.em),"Mod-b":Bd(Pr.marks.strong)}),FE,Lv()],$E={paragraph:()=>{const n=document.createElement("p");return{dom:n,contentDOM:n}}};function VE(){const[n,e]=v.useState(AE),[t,r]=v.useState(!0),i=v.useMemo(()=>t?{list:bE,list_item:IE,footnote:zE}:void 0,[t]),o=v.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(RE,{className:"ProseMirror",state:n,dispatchTransaction:o,plugins:LE,nodeViews:i,customNodeViews:t?void 0:$E,children:A.jsx(DE,{})},`${t}`)]})}const BE=R1(document.getElementById("root"));BE.render(A.jsx(v.StrictMode,{children:A.jsx(VE,{})})); +*/(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 yE(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 yd=v.memo(v.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=Q1(Y1(l),a));const c=[];for(let f=u;fu)throw new RangeError("Content hole must be the only child of its parent node");return v.createElement(s,a,t)}c.push(A.jsx(yd,{outputSpec:d,children:t}))}return v.createElement(s,a,...c)})),G1=v.memo(v.forwardRef(function({mark:e,pos:t,children:r},i){const{siblingsRef:o,parentRef:s}=v.useContext(pt),l=v.useRef(void 0),a=v.useRef([]),u=v.useRef(null);v.useImperativeHandle(i,()=>u.current,[]);const c=v.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`);v.useLayoutEffect(()=>{const d=o.current;return()=>{if(l.current&&d.includes(l.current)){const p=d.indexOf(l.current);d.splice(p,1)}}},[o]),v.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.pos=t):l.current=new ZM(s.current,a.current,t,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.pos-h.pos);for(const p of a.current)p.parent=l.current});const f=v.useMemo(()=>({parentRef:l,siblingsRef:a}),[a,l]);return A.jsx(yd,{ref:u,outputSpec:c,children:A.jsx(pt.Provider,{value:f,children:r})})}));function SE({widget:n,pos:e}){const{siblingsRef:t,parentRef:r}=v.useContext(pt),i=v.useRef(null),o=v.useRef(null),s=v.useRef(e);return s.current=e,v.useLayoutEffect(()=>{const l=t.current;return()=>{if(i.current&&l.includes(i.current)){const a=l.indexOf(i.current);l.splice(a,1)}}},[t]),L1(l=>{if(!o.current)return;const a=n.type.toDOM;let u=typeof a=="function"?a(l,()=>s.current):a;if(!n.type.spec.raw){if(u.nodeType!=1){const c=document.createElement("span");c.appendChild(u),u=c}u.contentEditable="false",u.classList.add("ProseMirror-widget")}o.current.firstElementChild!==u&&o.current.replaceChildren(u)}),v.useLayoutEffect(()=>{o.current&&(i.current?(i.current.parent=r.current,i.current.widget=n,i.current.pos=e,i.current.dom=o.current):i.current=new pd(r.current,e,n,o.current),t.current.includes(i.current)||t.current.push(i.current),t.current.sort((l,a)=>l.pos-a.pos))}),A.jsx("span",{ref:o})}const wE=v.createContext(null),X1=v.memo(function({outerDeco:e,pos:t,node:r,innerDeco:i,...o}){const s=v.useRef(null),l=v.useRef(null),a=v.useRef(null),u=v.useRef(r),c=v.useRef(e),f=v.useRef(i),d=v.useRef(t);d.current=t;const p=v.useRef(null),h=v.useRef(null),{nodeViews:m}=v.useContext(I1),{view:w}=v.useContext(pi);let g=null;const y=m[r.type.name],S=v.useMemo(()=>{var W,we;return(we=(W=r.type.spec).toDOM)==null?void 0:we.call(W,r)},[r]),C=w==null?void 0:w.someProp("nodeViews",W=>W==null?void 0:W[r.type.name]);v.useLayoutEffect(()=>{if(!h.current||!p.current)return;const{dom:W}=h.current;return l.current=p.current,p.current.appendChild(W),()=>{var we,mi;(mi=(we=h.current)==null?void 0:we.destroy)==null||mi.call(we)}},[]),v.useLayoutEffect(()=>{if(!C||!h.current)return;const{destroy:W,update:we}=h.current;if(((we==null?void 0:we.call(h.current,r,e,i))??!0)||(W==null||W.call(h.current),!p.current))return;u.current=r,c.current=e,f.current=i,h.current=C(u.current,w,()=>d.current,c.current,f.current);const{dom:gi}=h.current;l.current=p.current,p.current.appendChild(gi)},[C,w,i,r,e]);const{hasContentDOM:N,childDescriptors:E,setStopEvent:O,nodeViewDescRef:T}=j1(r,t,s,l,i,e,void 0,a),b={...o,...!N&&{contentEditable:!1}};if(y)g=A.jsx(y,{...b,ref:l,nodeProps:{node:r,pos:t,decorations:e,innerDecorations:i,isSelected:!1},children:A.jsx(mo,{pos:t,node:r,innerDecorations:i})});else if(C){h.current||(h.current=C(u.current,w,()=>d.current,c.current,f.current));const{contentDOM:W}=h.current;a.current=W??null,g=v.createElement(r.isInline?"span":"div",{ref:p,contentEditable:!!W,suppressContentEditableWarning:!0},W&&ai.createPortal(A.jsx(mo,{pos:t,node:r,innerDecorations:i}),W))}else S&&(g=A.jsx(yd,{...b,ref:l,outputSpec:S,children:A.jsx(mo,{pos:t,node:r,innerDecorations:i})}));if(!g)throw new Error(`Node spec for ${r.type.name} is missing toDOM`);const z=v.cloneElement(e.reduce(Sd,g),e.some(W=>W.type.attrs.nodeName)?{ref:s}:void 0),le=r.marks.reduce((W,we)=>A.jsx(G1,{pos:t,mark:we,children:W}),z),$t=v.useMemo(()=>({parentRef:T,siblingsRef:E}),[E,T]);return A.jsx(wE.Provider,{value:O,children:A.jsx(pt.Provider,{value:$t,children:v.cloneElement(le,r.marks.length||e.some(W=>W.type.attrs.nodeName)?{ref:s}:void 0)})})});function kE({pos:n}){const{siblingsRef:e,parentRef:t}=v.useContext(pt),r=v.useRef(null),i=v.useRef(null),[o,s]=v.useState(!1);return v.useLayoutEffect(()=>{const l=e.current;return()=>{if(r.current&&l.includes(r.current)){const a=l.indexOf(r.current);l.splice(a,1)}}},[e]),v.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.pos=n):r.current=new gd(t.current,[],n,i.current,null),e.current.includes(r.current)||e.current.push(r.current))}),o?A.jsx("img",{ref:i,className:"ProseMirror-separator"}):null}function vE(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;ou.pos-c.pos)}shouldComponentUpdate(e){return!vE(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,pos:t,node:r,decorations:i}=this.props;return e!=null&&e.composing&&e.state.selection.from>=t&&e.state.selection.from<=t+r.nodeSize?this.renderRef:(this.renderRef=i.reduce(Sd,r.text),this.renderRef)}}function CE({pos:n}){const{siblingsRef:e,parentRef:t}=v.useContext(pt),r=v.useRef(null),i=v.useRef(null);return v.useLayoutEffect(()=>{const o=e.current;return()=>{if(r.current&&o.includes(r.current)){const s=o.indexOf(r.current);o.splice(s,1)}}},[e]),v.useLayoutEffect(()=>{i.current&&(r.current?(r.current.parent=t.current,r.current.dom=i.current,r.current.pos=n):r.current=new gd(t.current,[],n,i.current,null),e.current.includes(r.current)||e.current.push(r.current),e.current.sort((o,s)=>o.pos-s.pos))}),A.jsx("br",{ref:i,className:"ProseMirror-trailingBreak"})}function NE({widget:n,pos:e}){const{siblingsRef:t,parentRef:r}=v.useContext(pt),i=v.useRef(null),o=v.useRef(null);v.useLayoutEffect(()=>{const l=t.current;return()=>{if(i.current&&l.includes(i.current)){const a=l.indexOf(i.current);l.splice(a,1)}}},[t]),v.useLayoutEffect(()=>{o.current&&(i.current?(i.current.parent=r.current,i.current.widget=n,i.current.pos=e,i.current.dom=o.current):i.current=new pd(r.current,e,n,o.current),t.current.includes(i.current)||t.current.push(i.current),t.current.sort((l,a)=>l.pos-a.pos))});const{Component:s}=n.type;return s&&A.jsx(s,{ref:o,widget:n,pos:e,contentEditable:!1})}function Sd(n,e){const{nodeName:t,...r}=e.type.attrs,i=Y1(r);return t||typeof n=="string"?v.createElement(t??"span",i,n):v.cloneElement(n,Q1(n.props,i))}const om=v.memo(function n({innerPos:e,childViews:t}){const{view:r}=v.useContext(pi),i=K1(),o=t.reduce((s,l)=>{var c;const a=s[s.length-1];if(!a)return[[l]];const u=a[a.length-1];return u?!l.marks.length&&!u.marks.length||l.marks.length&&u.marks.length&&((c=l.marks[0])!=null&&c.eq(u.marks[0]))?[...s.slice(0,s.length-1),[...a.slice(0,a.length),l]]:[...s,[l]]:[...s.slice(0,s.length),[l]]},[]);return A.jsx(A.Fragment,{children:o.map(s=>{const l=s[0];if(!l)return null;const a=l.marks[0];return a?A.jsx(G1,{pos:e+l.offset,mark:a,children:A.jsx(n,{innerPos:e,childViews:s.map(u=>({...u,marks:u.marks.slice(1)}))},po(e,l,i==null?void 0:i.posToKey))},po(e,l,i==null?void 0:i.posToKey)):s.map(u=>{const c=e+u.offset,f=u.type==="widget"?A.jsx(NE,{widget:u.widget,pos:c}):u.type==="native-widget"?A.jsx(SE,{widget:u.widget,pos:c}):u.node.isText?A.jsx(pt.Consumer,{children:({siblingsRef:d,parentRef:p})=>A.jsx(xE,{view:r,node:u.node,pos:c,siblingsRef:d,parentRef:p,decorations:u.outerDeco})}):A.jsx(X1,{node:u.node,pos:c,outerDeco:u.outerDeco,innerDeco:u.innerDeco});return v.cloneElement(f,{key:po(e,u,i==null?void 0:i.posToKey)})})})})});function po(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 ME(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 EE(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)}}function OE(n,e,t){return n.length?n.every(r=>r.type!=="node"||r.node.isInline)?[A.jsx(om,{childViews:n,innerPos:e},po(e,n[0],t))]:n.map(r=>{if(r.type==="node"){const i=e+r.offset,o=(t==null?void 0:t.get(i))??i;return A.jsx(X1,{outerDeco:r.outerDeco,node:r.node,innerDeco:r.innerDeco,pos:i},o)}else return A.jsx(om,{childViews:[r],innerPos:e},po(e,r,t))}):[]}const mo=v.memo(function({pos:e,node:t,innerDecorations:r}){const i=K1();if(!t)return null;const o=e+1,s=[];hE(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}),ME(s)},(u,c,f,d)=>{s.push({type:"node",node:u,marks:u.marks,innerDeco:f,outerDeco:c,offset:d}),EE(s)});const l=OE(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(kE,{pos:o},"trailing-hack-img"),A.jsx(CE,{pos:o},"trailing-hack-br")),A.jsx(A.Fragment,{children:l})}),DE=v.memo(v.forwardRef(function({className:e,node:t,innerDeco:r,outerDeco:i,as:o,viewDesc:s,...l},a){const u=v.useRef(null);v.useImperativeHandle(a,()=>u.current,[]);const{childDescriptors:c,nodeViewDescRef:f}=j1(t,-1,u,u,r,i,s),d=v.useMemo(()=>({parentRef:f,siblingsRef:c}),[c,f]),p={...l,ref:u,className:e,suppressContentEditableWarning:!0},h=o?v.cloneElement(o,p,A.jsx(pt.Provider,{value:d,children:A.jsx(mo,{pos:-1,node:t,innerDecorations:r})})):v.createElement("div",p,A.jsx(pt.Provider,{value:d,children:A.jsx(mo,{pos:-1,node:t,innerDecorations:r})}));if(!t)return h;const m=i.filter(g=>!g.inline);return m.length?m.reduce(Sd,h):h})),Z1=v.createContext(null);function TE({as:n,...e},t){const r=v.useRef([]),i=v.useRef(null),{setMount:o,...s}=v.useContext(Z1),l=v.useRef(void 0);v.useImperativeHandle(t,()=>i.current,[]);const a=v.useMemo(()=>({parentRef:l,siblingsRef:r}),[r,l]);return A.jsx(pt.Provider,{value:a,children:A.jsx(DE,{ref:u=>{i.current=u,o(u)},...e,...s,as:n})})}const RE=v.forwardRef(TE),AE=[];function bE({className:n,children:e,nodeViews:t={},customNodeViews:r,...i}){var p;const[o,s]=v.useState(null),{editor:l,state:a}=cE(o,{...i,nodeViews:r}),u=l.view?NM(l.view,l.cursorWrapper):J.empty,c=l.view?kM(l.view):AE,f=v.useMemo(()=>({nodeViews:t}),[t]),d=v.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(pi.Provider,{value:l,children:A.jsx(wM.Provider,{value:a,children:A.jsx(I1.Provider,{value:f,children:A.jsx(Z1.Provider,{value:d,children:e})})})})}function IE(n){return A.jsx(fE,{children:A.jsx(bE,{...n})})}const Pr=new Am({nodes:{doc:{content:"block+"},paragraph:{group:"block",content:"inline*",toDOM(){return["p",0]}},...$x({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]}}}}),zE=fn.create({schema:Pr,doc:Pr.nodes.doc.create({},[Pr.nodes.paragraph.create()]),plugins:[IM(),nx({rules:[rx(/^\s*([-+*])\s$/,Pr.nodes.list)]}),rC(),mC()]});v.forwardRef(function({children:e,nodeProps:t,...r},i){return A.jsx("p",{ref:i,...r,children:e})});const PE=v.forwardRef(function({children:e,nodeProps:t,...r},i){return A.jsx("ul",{ref:i,...r,children:e})}),FE=v.forwardRef(function({children:e,nodeProps:t,...r},i){return A.jsx("li",{ref:i,...r,children:e})}),LE=v.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})})}),$E=v.forwardRef(function({widget:e,pos: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"})}),VE=new Lt({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 Lt({props:{decorations(n){return J.create(n.doc,[$1(n.selection.from,$E,{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 BE=[lx({...Ww,"Mod-i":_d(Pr.marks.em),"Mod-b":_d(Pr.marks.strong)}),VE,Vv()],JE={paragraph:()=>{const n=document.createElement("p");return{dom:n,contentDOM:n}}};function _E(){const[n,e]=v.useState(zE),[t,r]=v.useState(!0),i=v.useMemo(()=>t?{list:PE,list_item:FE,footnote:LE}:void 0,[t]),o=v.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(IE,{className:"ProseMirror",state:n,dispatchTransaction:o,plugins:BE,nodeViews:i,customNodeViews:t?void 0:JE,children:A.jsx(RE,{})},`${t}`)]})}const WE=b1(document.getElementById("root"));WE.render(A.jsx(v.StrictMode,{children:A.jsx(_E,{})})); diff --git a/docs/index.html b/docs/index.html index c4471a7..4e741c5 100644 --- a/docs/index.html +++ b/docs/index.html @@ -5,7 +5,7 @@ React-ProseMirror Demo - + diff --git a/package.json b/package.json index 233fd60..b8d191b 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,9 @@ "@vitejs/plugin-react": "^4.3.1", "@wdio/browser-runner": "^9.0.9", "@wdio/cli": "^9.0.9", + "@wdio/dot-reporter": "^9.1.0", "@wdio/mocha-framework": "^9.0.8", + "@wdio/spec-reporter": "^9.1.0", "@wdio/types": "^9.0.8", "@yarnpkg/sdks": "^3.0.0-rc.38", "concurrently": "^7.6.0", diff --git a/src/components/ProseMirror.tsx b/src/components/ProseMirror.tsx index 50c1849..868bfb5 100644 --- a/src/components/ProseMirror.tsx +++ b/src/components/ProseMirror.tsx @@ -1,4 +1,8 @@ -import { DecorationSet, NodeViewConstructor } from "prosemirror-view"; +import { + Decoration, + DecorationSet, + NodeViewConstructor, +} from "prosemirror-view"; import React, { ForwardRefExoticComponent, ReactNode, @@ -36,6 +40,8 @@ export type Props = Omit & { }; }; +const EMPTY_OUTER_DECOS: Decoration[] = []; + function ProseMirrorInner({ className, children, @@ -50,18 +56,13 @@ function ProseMirrorInner({ nodeViews: customNodeViews, }); - const innerDecos = useMemo( - () => - editor.view - ? viewDecorations(editor.view, editor.cursorWrapper) - : (DecorationSet.empty as unknown as DecorationSet), - [editor.cursorWrapper, editor.view] - ); + const innerDecos = editor.view + ? viewDecorations(editor.view, editor.cursorWrapper) + : (DecorationSet.empty as unknown as DecorationSet); - const outerDecos = useMemo( - () => (editor.view ? computeDocDeco(editor.view) : []), - [editor.view] - ); + const outerDecos = editor.view + ? computeDocDeco(editor.view) + : EMPTY_OUTER_DECOS; const nodeViewContextValue = useMemo( () => ({ diff --git a/src/decorations/computeDocDeco.ts b/src/decorations/computeDocDeco.ts index 82eb5ef..bd43fc1 100644 --- a/src/decorations/computeDocDeco.ts +++ b/src/decorations/computeDocDeco.ts @@ -1,5 +1,18 @@ import { Decoration, EditorView } from "prosemirror-view"; +const DocDecorationsCache = new WeakMap(); + +/** + * Produces the outer decorations for the doc node, based + * on the attributes editor prop. + * + * The return value of this function is memoized; if it is to + * return an equivalent value to the last time it was called for + * a given EditorView, it will return exactly that previous value. + * + * This makes it safe to call in a React render function, even + * if its result is used in a dependencies array for a hook. + */ export function computeDocDeco(view: EditorView) { const attrs = Object.create(null); attrs.class = "ProseMirror"; @@ -22,5 +35,26 @@ export function computeDocDeco(view: EditorView) { }); if (!attrs.translate) attrs.translate = "no"; - return [Decoration.node(0, view.state.doc.content.size, attrs)]; + const next: [Decoration] = [ + Decoration.node(0, view.state.doc.content.size, attrs), + ]; + + const previous = DocDecorationsCache.get(view); + if (!previous) { + DocDecorationsCache.set(view, next); + return next; + } + + if (previous[0].to !== view.state.doc.content.size) { + DocDecorationsCache.set(view, next); + return next; + } + + // @ts-expect-error Internal property (Decoration.type) + if (!previous[0].type.eq(next[0].type)) { + DocDecorationsCache.set(view, next); + return next; + } + + return previous; } diff --git a/src/decorations/viewDecorations.tsx b/src/decorations/viewDecorations.tsx index 4e2f315..14d220b 100644 --- a/src/decorations/viewDecorations.tsx +++ b/src/decorations/viewDecorations.tsx @@ -179,6 +179,19 @@ function insertAhead(array: Decoration[], i: number, deco: Decoration) { array.splice(i, 0, deco); } +const ViewDecorationsCache = new WeakMap(); + +/** + * Produces the DecorationSource for the current state, based + * on the decorations editor prop. + * + * The return value of this function is memoized; if it is to + * return an equivalent value to the last time it was called for + * a given EditorView, it will return exactly that previous value. + * + * This makes it safe to call in a React render function, even + * if its result is used in a dependencies array for a hook. + */ export function viewDecorations( view: EditorView, cursorWrapper: Decoration | null @@ -196,5 +209,27 @@ export function viewDecorations( DecorationSet.create(view.state.doc, [cursorWrapper]) ); } - return DecorationGroup.from(found); + const previous = ViewDecorationsCache.get(view); + if (!previous) { + const result = DecorationGroup.from(found); + ViewDecorationsCache.set(view, result); + return result; + } + let numPrevious = 0; + let areSetsEqual = true; + previous.forEachSet((set) => { + const next = found[numPrevious++]; + if (next !== set) { + areSetsEqual = false; + } + }); + if (numPrevious !== found.length) { + areSetsEqual = false; + } + if (!areSetsEqual) { + const result = DecorationGroup.from(found); + ViewDecorationsCache.set(view, result); + return result; + } + return previous; } diff --git a/wdio.conf.ts b/wdio.conf.ts index 6f1ccba..e298ba2 100644 --- a/wdio.conf.ts +++ b/wdio.conf.ts @@ -129,7 +129,7 @@ export const config: WebdriverIO.Config = { // Test reporter for stdout. // The only one supported by default is 'dot' // see also: https://webdriver.io/docs/dot-reporter - // reporters: ['dot'], + reporters: ["spec"], // Options to be passed to Mocha. // See the full list at http://mochajs.org/ diff --git a/yarn.lock b/yarn.lock index d2fda0d..213658d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1944,7 +1944,9 @@ __metadata: "@vitejs/plugin-react": ^4.3.1 "@wdio/browser-runner": ^9.0.9 "@wdio/cli": ^9.0.9 + "@wdio/dot-reporter": ^9.1.0 "@wdio/mocha-framework": ^9.0.8 + "@wdio/spec-reporter": ^9.1.0 "@wdio/types": ^9.0.8 "@yarnpkg/sdks": ^3.0.0-rc.38 classnames: ^2.3.2 @@ -3251,6 +3253,17 @@ __metadata: languageName: node linkType: hard +"@wdio/dot-reporter@npm:^9.1.0": + version: 9.1.0 + resolution: "@wdio/dot-reporter@npm:9.1.0" + dependencies: + "@wdio/reporter": 9.1.0 + "@wdio/types": 9.1.0 + chalk: ^5.0.1 + checksum: 7bea6e022b8de1fd4509f4bd34d0460923628bed68928fd383f4bcb7d2005e4476cafa186ca609756035f338ba83ffbc48602f3173dd11c9200e2d0698a1451f + languageName: node + linkType: hard + "@wdio/globals@npm:9.0.9": version: 9.0.9 resolution: "@wdio/globals@npm:9.0.9" @@ -3294,6 +3307,18 @@ __metadata: languageName: node linkType: hard +"@wdio/logger@npm:9.1.0": + version: 9.1.0 + resolution: "@wdio/logger@npm:9.1.0" + dependencies: + chalk: ^5.1.2 + loglevel: ^1.6.0 + loglevel-plugin-prefix: ^0.8.4 + strip-ansi: ^7.1.0 + checksum: 52c3574c644fbc623565e913d0cb943bd45284148f4c93b378b3dc835a8d9e263680310f190ab240e76f60f00d6254e1063cc3a7db38ec7cfcf6dc7797a9e434 + languageName: node + linkType: hard + "@wdio/logger@npm:^8.38.0": version: 8.38.0 resolution: "@wdio/logger@npm:8.38.0" @@ -3336,6 +3361,19 @@ __metadata: languageName: node linkType: hard +"@wdio/reporter@npm:9.1.0": + version: 9.1.0 + resolution: "@wdio/reporter@npm:9.1.0" + dependencies: + "@types/node": ^20.1.0 + "@wdio/logger": 9.1.0 + "@wdio/types": 9.1.0 + diff: ^7.0.0 + object-inspect: ^1.12.0 + checksum: 6afb1984c8f437e5c88e213fc1c857c29c873599f9375c4e859c86fe97a85cd95050ee363db039a5b55e1598f6ab13a3577db4775698215ba1b748fe8fa236c6 + languageName: node + linkType: hard + "@wdio/runner@npm:9.0.9": version: 9.0.9 resolution: "@wdio/runner@npm:9.0.9" @@ -3355,6 +3393,19 @@ __metadata: languageName: node linkType: hard +"@wdio/spec-reporter@npm:^9.1.0": + version: 9.1.0 + resolution: "@wdio/spec-reporter@npm:9.1.0" + dependencies: + "@wdio/reporter": 9.1.0 + "@wdio/types": 9.1.0 + chalk: ^5.1.2 + easy-table: ^1.2.0 + pretty-ms: ^9.0.0 + checksum: 9c74032d8ec9259e89e057dc310f71f8af84d50ecada98e29fb8ccea4643c1a1a746c4873d5365475e79749bbe4ccbe443f9d24bf31ae8f22dfdabc1f0cdcc72 + languageName: node + linkType: hard + "@wdio/types@npm:9.0.8, @wdio/types@npm:^9.0.8": version: 9.0.8 resolution: "@wdio/types@npm:9.0.8" @@ -3364,6 +3415,15 @@ __metadata: languageName: node linkType: hard +"@wdio/types@npm:9.1.0": + version: 9.1.0 + resolution: "@wdio/types@npm:9.1.0" + dependencies: + "@types/node": ^20.1.0 + checksum: 14632e3b4dd041d5ccacace3e333ddc1854853ddae853dc6a846601fb7da1d31003f3a1b66afda45e943af0b42537f80e30375def810e946318343f15769f3f4 + languageName: node + linkType: hard + "@wdio/utils@npm:9.0.8": version: 9.0.8 resolution: "@wdio/utils@npm:9.0.8" @@ -4368,7 +4428,7 @@ __metadata: languageName: node linkType: hard -"chalk@npm:^5.1.2, chalk@npm:^5.2.0": +"chalk@npm:^5.0.1, chalk@npm:^5.1.2, chalk@npm:^5.2.0": version: 5.3.0 resolution: "chalk@npm:5.3.0" checksum: 623922e077b7d1e9dedaea6f8b9e9352921f8ae3afe739132e0e00c275971bdd331268183b2628cf4ab1727c45ea1f28d7e24ac23ce1db1eb653c414ca8a5a80 @@ -4570,6 +4630,13 @@ __metadata: languageName: node linkType: hard +"clone@npm:^1.0.2": + version: 1.0.4 + resolution: "clone@npm:1.0.4" + checksum: d06418b7335897209e77bdd430d04f882189582e67bd1f75a04565f3f07f5b3f119a9d670c943b6697d0afb100f03b866b3b8a1f91d4d02d72c4ecf2bb64b5dd + languageName: node + linkType: hard + "co@npm:^4.6.0": version: 4.6.0 resolution: "co@npm:4.6.0" @@ -5046,6 +5113,15 @@ __metadata: languageName: node linkType: hard +"defaults@npm:^1.0.3": + version: 1.0.4 + resolution: "defaults@npm:1.0.4" + dependencies: + clone: ^1.0.2 + checksum: 3a88b7a587fc076b84e60affad8b85245c01f60f38fc1d259e7ac1d89eb9ce6abb19e27215de46b98568dd5bc48471730b327637e6f20b0f1bc85cf00440c80a + languageName: node + linkType: hard + "defer-to-connect@npm:^2.0.0": version: 2.0.1 resolution: "defer-to-connect@npm:2.0.1" @@ -5172,6 +5248,13 @@ __metadata: languageName: node linkType: hard +"diff@npm:^7.0.0": + version: 7.0.0 + resolution: "diff@npm:7.0.0" + checksum: 5db0d339476b18dfbc8a08a7504fbcc74789eec626c8d20cf2cdd1871f1448962888128f4447c8f50a1e41a80decfe5e8489c375843b8cf1d42b7c2b611da4e1 + languageName: node + linkType: hard + "dir-glob@npm:^3.0.1": version: 3.0.1 resolution: "dir-glob@npm:3.0.1" @@ -5267,6 +5350,19 @@ __metadata: languageName: node linkType: hard +"easy-table@npm:^1.2.0": + version: 1.2.0 + resolution: "easy-table@npm:1.2.0" + dependencies: + ansi-regex: ^5.0.1 + wcwidth: ^1.0.1 + dependenciesMeta: + wcwidth: + optional: true + checksum: 66961b19751a68d2d30ce9b74ef750c374cc3112bbcac3d1ed5a939e43c035ecf6b1954098df2d5b05f1e853ab2b67de893794390dcbf0abe1f157fddeb52174 + languageName: node + linkType: hard + "edge-paths@npm:^3.0.5": version: 3.0.5 resolution: "edge-paths@npm:3.0.5" @@ -10109,6 +10205,13 @@ __metadata: languageName: node linkType: hard +"object-inspect@npm:^1.12.0": + version: 1.13.2 + resolution: "object-inspect@npm:1.13.2" + checksum: 9f850b3c045db60e0e97746e809ee4090d6ce62195af17dd1e9438ac761394a7d8ec4f7906559aea5424eaf61e35d3e53feded2ccd5f62fcc7d9670d3c8eb353 + languageName: node + linkType: hard + "object-inspect@npm:^1.12.2, object-inspect@npm:^1.9.0": version: 1.12.3 resolution: "object-inspect@npm:1.12.3" @@ -13136,6 +13239,15 @@ __metadata: languageName: node linkType: hard +"wcwidth@npm:^1.0.1": + version: 1.0.1 + resolution: "wcwidth@npm:1.0.1" + dependencies: + defaults: ^1.0.3 + checksum: 814e9d1ddcc9798f7377ffa448a5a3892232b9275ebb30a41b529607691c0491de47cba426e917a4d08ded3ee7e9ba2f3fe32e62ee3cd9c7d3bafb7754bd553c + languageName: node + linkType: hard + "web-streams-polyfill@npm:^3.0.3": version: 3.3.3 resolution: "web-streams-polyfill@npm:3.3.3"