ariadne_view_components 0.0.21-x86_64-darwin → 0.0.22-x86_64-darwin

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,5 +4,5 @@ class e{constructor(e,t,n){this.eventTarget=e,this.eventName=t,this.eventOptions
4
4
  * Copyright 2017 Google LLC
5
5
  * SPDX-License-Identifier: BSD-3-Clause
6
6
  */
7
- var J;q.blessings=[function(e){return k(e,"classes").reduce(((e,t)=>{return Object.assign(e,{[`${n=t}Class`]:{get(){const{classes:e}=this;if(e.has(n))return e.get(n);{const t=e.getAttributeName(n);throw new Error(`Missing attribute "${t}"`)}}},[`${n}Classes`]:{get(){return this.classes.getAll(n)}},[`has${s(n)}Class`]:{get(){return this.classes.has(n)}}});var n}),{})},function(e){return k(e,"targets").reduce(((e,t)=>{return Object.assign(e,{[`${n=t}Target`]:{get(){const e=this.targets.find(n);if(e)return e;throw new Error(`Missing target element "${n}" for "${this.identifier}" controller`)}},[`${n}Targets`]:{get(){return this.targets.findAll(n)}},[`has${s(n)}Target`]:{get(){return this.targets.has(n)}}});var n}),{})},function(e){const t=S(e,"values"),n={valueDescriptorMap:{get(){return t.reduce(((e,t)=>{const n=z(t,this.identifier),r=this.data.getAttributeNameForKey(n.key);return Object.assign(e,{[r]:n})}),{})}}};return t.reduce(((e,t)=>Object.assign(e,function(e,t){const n=z(e,t),{key:r,name:i,reader:o,writer:a}=n;return{[i]:{get(){const e=this.data.get(r);return null!==e?o(e):n.defaultValue},set(e){void 0===e?this.data.delete(r):this.data.set(r,a(e))}},[`has${s(i)}`]:{get(){return this.data.has(r)||n.hasCustomDefaultValue}}}}(t))),n)}],q.targets=[],q.values={};const U=window,G=U.trustedTypes,Y=G?G.createPolicy("lit-html",{createHTML:e=>e}):void 0,X=`lit$${(Math.random()+"").slice(9)}$`,Z="?"+X,Q=`<${Z}>`,ee=document,te=(e="")=>ee.createComment(e),ne=e=>null===e||"object"!=typeof e&&"function"!=typeof e,re=Array.isArray,ie=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,se=/-->/g,oe=/>/g,ae=RegExp(">|[ \t\n\f\r](?:([^\\s\"'>=/]+)([ \t\n\f\r]*=[ \t\n\f\r]*(?:[^ \t\n\f\r\"'`<>=]|(\"|')|))|$)","g"),le=/'/g,ce=/"/g,he=/^(?:script|style|textarea|title)$/i,de=(e=>(t,...n)=>({_$litType$:e,strings:t,values:n}))(1),ue=Symbol.for("lit-noChange"),pe=Symbol.for("lit-nothing"),fe=new WeakMap,me=ee.createTreeWalker(ee,129,null,!1),ge=(e,t)=>{const n=e.length-1,r=[];let i,s=2===t?"<svg>":"",o=ie;for(let t=0;t<n;t++){const n=e[t];let a,l,c=-1,h=0;for(;h<n.length&&(o.lastIndex=h,l=o.exec(n),null!==l);)h=o.lastIndex,o===ie?"!--"===l[1]?o=se:void 0!==l[1]?o=oe:void 0!==l[2]?(he.test(l[2])&&(i=RegExp("</"+l[2],"g")),o=ae):void 0!==l[3]&&(o=ae):o===ae?">"===l[0]?(o=null!=i?i:ie,c=-1):void 0===l[1]?c=-2:(c=o.lastIndex-l[2].length,a=l[1],o=void 0===l[3]?ae:'"'===l[3]?ce:le):o===ce||o===le?o=ae:o===se||o===oe?o=ie:(o=ae,i=void 0);const d=o===ae&&e[t+1].startsWith("/>")?" ":"";s+=o===ie?n+Q:c>=0?(r.push(a),n.slice(0,c)+"$lit$"+n.slice(c)+X+d):n+X+(-2===c?(r.push(void 0),t):d)}const a=s+(e[n]||"<?>")+(2===t?"</svg>":"");if(!Array.isArray(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return[void 0!==Y?Y.createHTML(a):a,r]};class ye{constructor({strings:e,_$litType$:t},n){let r;this.parts=[];let i=0,s=0;const o=e.length-1,a=this.parts,[l,c]=ge(e,t);if(this.el=ye.createElement(l,n),me.currentNode=this.el.content,2===t){const e=this.el.content,t=e.firstChild;t.remove(),e.append(...t.childNodes)}for(;null!==(r=me.nextNode())&&a.length<o;){if(1===r.nodeType){if(r.hasAttributes()){const e=[];for(const t of r.getAttributeNames())if(t.endsWith("$lit$")||t.startsWith(X)){const n=c[s++];if(e.push(t),void 0!==n){const e=r.getAttribute(n.toLowerCase()+"$lit$").split(X),t=/([.?@])?(.*)/.exec(n);a.push({type:1,index:i,name:t[2],strings:e,ctor:"."===t[1]?ke:"?"===t[1]?Me:"@"===t[1]?Oe:xe})}else a.push({type:6,index:i})}for(const t of e)r.removeAttribute(t)}if(he.test(r.tagName)){const e=r.textContent.split(X),t=e.length-1;if(t>0){r.textContent=G?G.emptyScript:"";for(let n=0;n<t;n++)r.append(e[n],te()),me.nextNode(),a.push({type:2,index:++i});r.append(e[t],te())}}}else if(8===r.nodeType)if(r.data===Z)a.push({type:2,index:i});else{let e=-1;for(;-1!==(e=r.data.indexOf(X,e+1));)a.push({type:7,index:i}),e+=X.length-1}i++}}static createElement(e,t){const n=ee.createElement("template");return n.innerHTML=e,n}}function ve(e,t,n=e,r){var i,s,o,a;if(t===ue)return t;let l=void 0!==r?null===(i=n._$Cl)||void 0===i?void 0:i[r]:n._$Cu;const c=ne(t)?void 0:t._$litDirective$;return(null==l?void 0:l.constructor)!==c&&(null===(s=null==l?void 0:l._$AO)||void 0===s||s.call(l,!1),void 0===c?l=void 0:(l=new c(e),l._$AT(e,n,r)),void 0!==r?(null!==(o=(a=n)._$Cl)&&void 0!==o?o:a._$Cl=[])[r]=l:n._$Cu=l),void 0!==l&&(t=ve(e,l._$AS(e,t.values),l,r)),t}class we{constructor(e,t){this.v=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}p(e){var t;const{el:{content:n},parts:r}=this._$AD,i=(null!==(t=null==e?void 0:e.creationScope)&&void 0!==t?t:ee).importNode(n,!0);me.currentNode=i;let s=me.nextNode(),o=0,a=0,l=r[0];for(;void 0!==l;){if(o===l.index){let t;2===l.type?t=new be(s,s.nextSibling,this,e):1===l.type?t=new l.ctor(s,l.name,l.strings,this,e):6===l.type&&(t=new Ce(s,this,e)),this.v.push(t),l=r[++a]}o!==(null==l?void 0:l.index)&&(s=me.nextNode(),o++)}return i}m(e){let t=0;for(const n of this.v)void 0!==n&&(void 0!==n.strings?(n._$AI(e,n,t),t+=n.strings.length-2):n._$AI(e[t])),t++}}class be{constructor(e,t,n,r){var i;this.type=2,this._$AH=pe,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=n,this.options=r,this._$C_=null===(i=null==r?void 0:r.isConnected)||void 0===i||i}get _$AU(){var e,t;return null!==(t=null===(e=this._$AM)||void 0===e?void 0:e._$AU)&&void 0!==t?t:this._$C_}get parentNode(){let e=this._$AA.parentNode;const t=this._$AM;return void 0!==t&&11===e.nodeType&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=ve(this,e,t),ne(e)?e===pe||null==e||""===e?(this._$AH!==pe&&this._$AR(),this._$AH=pe):e!==this._$AH&&e!==ue&&this.$(e):void 0!==e._$litType$?this.T(e):void 0!==e.nodeType?this.k(e):(e=>re(e)||"function"==typeof(null==e?void 0:e[Symbol.iterator]))(e)?this.O(e):this.$(e)}S(e,t=this._$AB){return this._$AA.parentNode.insertBefore(e,t)}k(e){this._$AH!==e&&(this._$AR(),this._$AH=this.S(e))}$(e){this._$AH!==pe&&ne(this._$AH)?this._$AA.nextSibling.data=e:this.k(ee.createTextNode(e)),this._$AH=e}T(e){var t;const{values:n,_$litType$:r}=e,i="number"==typeof r?this._$AC(e):(void 0===r.el&&(r.el=ye.createElement(r.h,this.options)),r);if((null===(t=this._$AH)||void 0===t?void 0:t._$AD)===i)this._$AH.m(n);else{const e=new we(i,this),t=e.p(this.options);e.m(n),this.k(t),this._$AH=e}}_$AC(e){let t=fe.get(e.strings);return void 0===t&&fe.set(e.strings,t=new ye(e)),t}O(e){re(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let n,r=0;for(const i of e)r===t.length?t.push(n=new be(this.S(te()),this.S(te()),this,this.options)):n=t[r],n._$AI(i),r++;r<t.length&&(this._$AR(n&&n._$AB.nextSibling,r),t.length=r)}_$AR(e=this._$AA.nextSibling,t){var n;for(null===(n=this._$AP)||void 0===n||n.call(this,!1,!0,t);e&&e!==this._$AB;){const t=e.nextSibling;e.remove(),e=t}}setConnected(e){var t;void 0===this._$AM&&(this._$C_=e,null===(t=this._$AP)||void 0===t||t.call(this,e))}}class xe{constructor(e,t,n,r,i){this.type=1,this._$AH=pe,this._$AN=void 0,this.element=e,this.name=t,this._$AM=r,this.options=i,n.length>2||""!==n[0]||""!==n[1]?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=pe}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(e,t=this,n,r){const i=this.strings;let s=!1;if(void 0===i)e=ve(this,e,t,0),s=!ne(e)||e!==this._$AH&&e!==ue,s&&(this._$AH=e);else{const r=e;let o,a;for(e=i[0],o=0;o<i.length-1;o++)a=ve(this,r[n+o],t,o),a===ue&&(a=this._$AH[o]),s||(s=!ne(a)||a!==this._$AH[o]),a===pe?e=pe:e!==pe&&(e+=(null!=a?a:"")+i[o+1]),this._$AH[o]=a}s&&!r&&this.P(e)}P(e){e===pe?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=e?e:"")}}class ke extends xe{constructor(){super(...arguments),this.type=3}P(e){this.element[this.name]=e===pe?void 0:e}}const Se=G?G.emptyScript:"";class Me extends xe{constructor(){super(...arguments),this.type=4}P(e){e&&e!==pe?this.element.setAttribute(this.name,Se):this.element.removeAttribute(this.name)}}class Oe extends xe{constructor(e,t,n,r,i){super(e,t,n,r,i),this.type=5}_$AI(e,t=this){var n;if((e=null!==(n=ve(this,e,t,0))&&void 0!==n?n:pe)===ue)return;const r=this._$AH,i=e===pe&&r!==pe||e.capture!==r.capture||e.once!==r.once||e.passive!==r.passive,s=e!==pe&&(r===pe||i);i&&this.element.removeEventListener(this.name,this,r),s&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var t,n;"function"==typeof this._$AH?this._$AH.call(null!==(n=null===(t=this.options)||void 0===t?void 0:t.host)&&void 0!==n?n:this.element,e):this._$AH.handleEvent(e)}}class Ce{constructor(e,t,n){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=n}get _$AU(){return this._$AM._$AU}_$AI(e){ve(this,e)}}const Ae=U.litHtmlPolyfillSupport;null==Ae||Ae(ye,be),(null!==(J=U.litHtmlVersions)&&void 0!==J?J:U.litHtmlVersions=[]).push("2.3.1");class Ee extends q{constructor(){super(...arguments),this.onBlur=e=>{this.validateField(e.target)},this.onSubmit=e=>{var t;this.validateForm()||(e.preventDefault(),null===(t=this.firstInvalidField)||void 0===t||t.focus())},this.getRenderString=e=>{const{strings:t,values:n}=e,r=[...n,""].map((e=>"object"==typeof e?this.getRenderString(e):e));return t.reduce(((e,t,n)=>e+t+r[n]),"")}}connect(){this.element.setAttribute("novalidate","true"),this.element.addEventListener("blur",this.onBlur,!0),this.element.addEventListener("submit",this.onSubmit),this.element.addEventListener("ajax:beforeSend",this.onSubmit)}disconnect(){this.element.removeEventListener("blur",this.onBlur),this.element.removeEventListener("submit",this.onSubmit),this.element.removeEventListener("ajax:beforeSend",this.onSubmit)}validateForm(){let e=!0;for(const t of this.formFields)this.shouldValidateField(t)&&!this.validateField(t)&&(e=!1);return e}validateField(e){if(!this.shouldValidateField(e))return!0;const t=e.checkValidity();return e.classList.toggle("invalid",!t),this.refreshErrorForInvalidField(e,t),t}shouldValidateField(e){return!e.disabled&&!e.classList.contains("ProseMirror")&&!["file","reset","submit","button"].includes(e.type)}refreshErrorForInvalidField(e,t){this.removeExistingErrorMessage(e),t||this.showErrorForInvalidField(e)}removeExistingErrorMessage(e){var t;const n=e.closest(".field");if(!n)return;const r=n.querySelector(".error");r&&(null===(t=null==r?void 0:r.parentNode)||void 0===t||t.removeChild(r))}showErrorForInvalidField(e){e.insertAdjacentHTML("afterend",this.buildFieldErrorHtml(e))}buildFieldErrorHtml(e){const t=de`<p class="error">${e.validationMessage}</p>`;return this.getRenderString(t)}get formFields(){return Array.from(this.formFieldTargets)}get firstInvalidField(){return this.formFields.find((e=>!e.checkValidity()))}}Ee.targets=["formField"];function Te(e){this.content=e}function Ne(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),s=t.child(r);if(i!=s){if(!i.sameMarkup(s))return n;if(i.isText&&i.text!=s.text){for(let e=0;i.text[e]==s.text[e];e++)n++;return n}if(i.content.size||s.content.size){let e=Ne(i.content,s.content,n+1);if(null!=e)return e}n+=i.nodeSize}else n+=i.nodeSize}}function De(e,t,n,r){for(let i=e.childCount,s=t.childCount;;){if(0==i||0==s)return i==s?null:{a:n,b:r};let o=e.child(--i),a=t.child(--s),l=o.nodeSize;if(o!=a){if(!o.sameMarkup(a))return{a:n,b:r};if(o.isText&&o.text!=a.text){let e=0,t=Math.min(o.text.length,a.text.length);for(;e<t&&o.text[o.text.length-e-1]==a.text[a.text.length-e-1];)e++,n--,r--;return{a:n,b:r}}if(o.content.size||a.content.size){let e=De(o.content,a.content,n-1,r-1);if(e)return e}n-=l,r-=l}else n-=l,r-=l}}Te.prototype={constructor:Te,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return-1==t?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,i=r.find(e),s=r.content.slice();return-1==i?s.push(n||e,t):(s[i+1]=t,n&&(s[i]=n)),new Te(s)},remove:function(e){var t=this.find(e);if(-1==t)return this;var n=this.content.slice();return n.splice(t,2),new Te(n)},addToStart:function(e,t){return new Te([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new Te(n)},addBefore:function(e,t,n){var r=this.remove(t),i=r.content.slice(),s=r.find(e);return i.splice(-1==s?i.length:s,0,t,n),new Te(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return(e=Te.from(e)).size?new Te(e.content.concat(this.subtract(e).content)):this},append:function(e){return(e=Te.from(e)).size?new Te(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=Te.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},get size(){return this.content.length>>1}},Te.from=function(e){if(e instanceof Te)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new Te(t)};class $e{constructor(e,t){if(this.content=e,this.size=t||0,null==t)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,i){for(let s=0,o=0;o<t;s++){let a=this.content[s],l=o+a.nodeSize;if(l>e&&!1!==n(a,r+o,i||null,s)&&a.content.size){let i=o+1;a.nodesBetween(Math.max(0,e-i),Math.min(a.content.size,t-i),n,r+i)}o=l}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i="",s=!0;return this.nodesBetween(e,t,((o,a)=>{o.isText?(i+=o.text.slice(Math.max(e,a)-a,t-a),s=!n):o.isLeaf?(r?i+="function"==typeof r?r(o):r:o.type.spec.leafText&&(i+=o.type.spec.leafText(o)),s=!n):!s&&o.isBlock&&(i+=n,s=!0)}),0),i}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,n=e.firstChild,r=this.content.slice(),i=0;for(t.isText&&t.sameMarkup(n)&&(r[r.length-1]=t.withText(t.text+n.text),i=1);i<e.content.length;i++)r.push(e.content[i]);return new $e(r,this.size+e.size)}cut(e,t=this.size){if(0==e&&t==this.size)return this;let n=[],r=0;if(t>e)for(let i=0,s=0;s<t;i++){let o=this.content[i],a=s+o.nodeSize;a>e&&((s<e||a>t)&&(o=o.isText?o.cut(Math.max(0,e-s),Math.min(o.text.length,t-s)):o.cut(Math.max(0,e-s-1),Math.min(o.content.size,t-s-1))),n.push(o),r+=o.nodeSize),s=a}return new $e(n,r)}cutByIndex(e,t){return e==t?$e.empty:0==e&&t==this.content.length?this:new $e(this.content.slice(e,t))}replaceChild(e,t){let n=this.content[e];if(n==t)return this;let r=this.content.slice(),i=this.size+t.nodeSize-n.nodeSize;return r[e]=t,new $e(r,i)}addToStart(e){return new $e([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new $e(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return Ne(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return De(this,e,t,n)}findIndex(e,t=-1){if(0==e)return Re(0,e);if(e==this.size)return Re(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let i=r+this.child(n).nodeSize;if(i>=e)return i==e||t>0?Re(n+1,i):Re(n,r);r=i}}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 $e.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new $e(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return $e.empty;let t,n=0;for(let r=0;r<e.length;r++){let i=e[r];n+=i.nodeSize,r&&i.isText&&e[r-1].sameMarkup(i)?(t||(t=e.slice(0,r)),t[t.length-1]=i.withText(t[t.length-1].text+i.text)):t&&t.push(i)}return new $e(t||e,n)}static from(e){if(!e)return $e.empty;if(e instanceof $e)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new $e([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}$e.empty=new $e([],0);const Ie={index:0,offset:0};function Re(e,t){return Ie.index=e,Ie.offset=t,Ie}function Pe(e,t){if(e===t)return!0;if(!e||"object"!=typeof e||!t||"object"!=typeof t)return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!Pe(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!Pe(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}class Be{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))t||(t=e.slice(0,r));else{if(i.type.excludes(this.type))return e;!n&&i.type.rank>this.type.rank&&(t||(t=e.slice(0,r)),t.push(this),n=!0),t&&t.push(i)}}return t||(t=e.slice()),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Pe(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let n=e.marks[t.type];if(!n)throw new RangeError(`There is no mark type ${t.type} in this schema`);return n.create(t.attrs)}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&0==e.length)return Be.none;if(e instanceof Be)return[e];let t=e.slice();return t.sort(((e,t)=>e.type.rank-t.type.rank)),t}}Be.none=[];class Fe extends Error{}class Le{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let n=Ve(this.content,e+this.openStart,t);return n&&new Le(n,this.openStart,this.openEnd)}removeBetween(e,t){return new Le(ze(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 Le.empty;let n=t.openStart||0,r=t.openEnd||0;if("number"!=typeof n||"number"!=typeof r)throw new RangeError("Invalid input for Slice.fromJSON");return new Le($e.fromJSON(e,t.content),n,r)}static maxOpen(e,t=!0){let n=0,r=0;for(let r=e.firstChild;r&&!r.isLeaf&&(t||!r.type.spec.isolating);r=r.firstChild)n++;for(let n=e.lastChild;n&&!n.isLeaf&&(t||!n.type.spec.isolating);n=n.lastChild)r++;return new Le(e,n,r)}}function ze(e,t,n){let{index:r,offset:i}=e.findIndex(t),s=e.maybeChild(r),{index:o,offset:a}=e.findIndex(n);if(i==t||s.isText){if(a!=n&&!e.child(o).isText)throw new RangeError("Removing non-flat range");return e.cut(0,t).append(e.cut(n))}if(r!=o)throw new RangeError("Removing non-flat range");return e.replaceChild(r,s.copy(ze(s.content,t-i-1,n-i-1)))}function Ve(e,t,n,r){let{index:i,offset:s}=e.findIndex(t),o=e.maybeChild(i);if(s==t||o.isText)return r&&!r.canReplace(i,i,n)?null:e.cut(0,t).append(n).append(e.cut(t));let a=Ve(o.content,t-s-1,n);return a&&e.replaceChild(i,o.copy(a))}function je(e,t,n){if(n.openStart>e.depth)throw new Fe("Inserted content deeper than insertion position");if(e.depth-n.openStart!=t.depth-n.openEnd)throw new Fe("Inconsistent open depths");return _e(e,t,n,0)}function _e(e,t,n,r){let i=e.index(r),s=e.node(r);if(i==t.index(r)&&r<e.depth-n.openStart){let o=_e(e,t,n,r+1);return s.copy(s.content.replaceChild(i,o))}if(n.content.size){if(n.openStart||n.openEnd||e.depth!=r||t.depth!=r){let{start:i,end:o}=function(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy($e.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}(n,e);return Je(s,Ue(e,i,o,t,r))}{let r=e.parent,i=r.content;return Je(r,i.cut(0,e.parentOffset).append(n.content).append(i.cut(t.parentOffset)))}}return Je(s,Ge(e,t,r))}function We(e,t){if(!t.type.compatibleContent(e.type))throw new Fe("Cannot join "+t.type.name+" onto "+e.type.name)}function He(e,t,n){let r=e.node(n);return We(r,t.node(n)),r}function Ke(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function qe(e,t,n,r){let i=(t||e).node(n),s=0,o=t?t.index(n):i.childCount;e&&(s=e.index(n),e.depth>n?s++:e.textOffset&&(Ke(e.nodeAfter,r),s++));for(let e=s;e<o;e++)Ke(i.child(e),r);t&&t.depth==n&&t.textOffset&&Ke(t.nodeBefore,r)}function Je(e,t){if(!e.type.validContent(t))throw new Fe("Invalid content for node "+e.type.name);return e.copy(t)}function Ue(e,t,n,r,i){let s=e.depth>i&&He(e,t,i+1),o=r.depth>i&&He(n,r,i+1),a=[];return qe(null,e,i,a),s&&o&&t.index(i)==n.index(i)?(We(s,o),Ke(Je(s,Ue(e,t,n,r,i+1)),a)):(s&&Ke(Je(s,Ge(e,t,i+1)),a),qe(t,n,i,a),o&&Ke(Je(o,Ge(n,r,i+1)),a)),qe(r,null,i,a),new $e(a)}function Ge(e,t,n){let r=[];if(qe(null,e,n,r),e.depth>n){Ke(Je(He(e,t,n+1),Ge(e,t,n+1)),r)}return qe(t,null,n,r),new $e(r)}Le.empty=new Le($e.empty,0,0);class Ye{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return null==e?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[3*this.resolveDepth(e)]}index(e){return this.path[3*this.resolveDepth(e)+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e!=this.depth||this.textOffset?1:0)}start(e){return 0==(e=this.resolveDepth(e))?0:this.path[3*e-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]}after(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]+this.path[3*e].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):0==e?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[3*t],r=0==t?0:this.path[3*t-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(0==e.content.size)return Be.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let i=n.marks;for(var s=0;s<i.length;s++)!1!==i[s].type.spec.inclusive||r&&i[s].isInSet(r.marks)||(i=i[s--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var i=0;i<n.length;i++)!1!==n[i].type.spec.inclusive||r&&n[i].isInSet(r.marks)||(n=n[i--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new et(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let n=[],r=0,i=t;for(let t=e;;){let{index:e,offset:s}=t.content.findIndex(i),o=i-s;if(n.push(t,e,r+s),!o)break;if(t=t.child(e),t.isText)break;i=o-1,r+=s+1}return new Ye(t,n,i)}static resolveCached(e,t){for(let n=0;n<Xe.length;n++){let r=Xe[n];if(r.pos==t&&r.doc==e)return r}let n=Xe[Ze]=Ye.resolve(e,t);return Ze=(Ze+1)%Qe,n}}let Xe=[],Ze=0,Qe=12;class et{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const tt=Object.create(null);class nt{constructor(e,t,n,r=Be.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||$e.empty}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&Pe(this.attrs,t||e.defaultAttrs||tt)&&Be.sameSet(this.marks,n||Be.none)}copy(e=null){return e==this.content?this:new nt(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new nt(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return 0==e&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return Le.empty;let r=this.resolve(e),i=this.resolve(t),s=n?0:r.sharedDepth(t),o=r.start(s),a=r.node(s).content.cut(r.pos-o,i.pos-o);return new Le(a,r.depth-s,i.depth-s)}replace(e,t,n){return je(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(0==e)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return Ye.resolveCached(this,e)}resolveNoCache(e){return Ye.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,(e=>(n.isInSet(e.marks)&&(r=!0),!r))),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),it(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,n=$e.empty,r=0,i=n.childCount){let s=this.contentMatchAt(e).matchFragment(n,r,i),o=s&&s.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;e<i;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(e).matchType(n),s=i&&i.matchFragment(this.content,t);return!!s&&s.validEnd}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){if(!this.type.validContent(this.content))throw new RangeError(`Invalid content for node ${this.type.name}: ${this.content.toString().slice(0,50)}`);let e=Be.none;for(let t=0;t<this.marks.length;t++)e=this.marks[t].addToSet(e);if(!Be.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map((e=>e.type.name))}`);this.content.forEach((e=>e.check()))}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map((e=>e.toJSON()))),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let n=null;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=t.marks.map(e.markFromJSON)}if("text"==t.type){if("string"!=typeof t.text)throw new RangeError("Invalid text node in JSON");return e.text(t.text,n)}let r=$e.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,r,n)}}nt.prototype.text=void 0;class rt extends nt{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):it(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 rt(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new rt(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return 0==e&&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 it(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+"("+t+")";return t}class st{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let n=new ot(e,t);if(null==n.next)return st.empty;let r=at(n);n.next&&n.err("Unexpected trailing text");let i=function(e){let t=Object.create(null);return n(pt(e,0));function n(r){let i=[];r.forEach((t=>{e[t].forEach((({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e<i.length;e++)i[e][0]==t&&(r=i[e][1]);pt(e,n).forEach((e=>{r||i.push([t,r=[]]),-1==r.indexOf(e)&&r.push(e)}))}))}));let s=t[r.join(",")]=new st(r.indexOf(e.length-1)>-1);for(let e=0;e<i.length;e++){let r=i[e][1].sort(ut);s.next.push({type:i[e][0],next:t[r.join(",")]||n(r)})}return s}}(function(e){let t=[[]];return i(s(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let i={term:r,to:n};return t[e].push(i),i}function i(e,t){e.forEach((e=>e.to=t))}function s(e,t){if("choice"==e.type)return e.exprs.reduce(((e,n)=>e.concat(s(n,t))),[]);if("seq"!=e.type){if("star"==e.type){let o=n();return r(t,o),i(s(e.expr,o),o),[r(o)]}if("plus"==e.type){let o=n();return i(s(e.expr,t),o),i(s(e.expr,o),o),[r(o)]}if("opt"==e.type)return[r(t)].concat(s(e.expr,t));if("range"==e.type){let o=t;for(let t=0;t<e.min;t++){let t=n();i(s(e.expr,o),t),o=t}if(-1==e.max)i(s(e.expr,o),o);else for(let t=e.min;t<e.max;t++){let t=n();r(o,t),i(s(e.expr,o),t),o=t}return[r(o)]}if("name"==e.type)return[r(t,void 0,e.value)];throw new Error("Unknown expr type")}for(let r=0;;r++){let o=s(e.exprs[r],t);if(r==e.exprs.length-1)return o;i(o,t=n())}}}(r));return function(e,t){for(let n=0,r=[e];n<r.length;n++){let e=r[n],i=!e.validEnd,s=[];for(let t=0;t<e.next.length;t++){let{type:n,next:o}=e.next[t];s.push(n.name),!i||n.isText||n.hasRequiredAttrs()||(i=!1),-1==r.indexOf(o)&&r.push(o)}i&&t.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(i,n),i}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let i=t;r&&i<n;i++)r=r.matchType(e.child(i).type);return r}get inlineContent(){return this.next.length&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!t.isText&&!t.hasRequiredAttrs())return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];return function i(s,o){let a=s.matchFragment(e,n);if(a&&(!t||a.validEnd))return $e.from(o.map((e=>e.createAndFill())));for(let e=0;e<s.next.length;e++){let{type:t,next:n}=s.next[e];if(!t.isText&&!t.hasRequiredAttrs()&&-1==r.indexOf(n)){r.push(n);let e=i(n,o.concat(t));if(e)return e}}return null}(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<i.next.length;e++){let{type:s,next:o}=i.next[e];s.isLeaf||s.hasRequiredAttrs()||s.name in t||r.type&&!o.validEnd||(n.push({match:s.contentMatch,type:s,via:r}),t[s.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];return function t(n){e.push(n);for(let r=0;r<n.next.length;r++)-1==e.indexOf(n.next[r].next)&&t(n.next[r].next)}(this),e.map(((t,n)=>{let r=n+(t.validEnd?"*":" ")+" ";for(let n=0;n<t.next.length;n++)r+=(n?", ":"")+t.next[n].type.name+"->"+e.indexOf(t.next[n].next);return r})).join("\n")}}st.empty=new st(!0);class ot{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 at(e){let t=[];do{t.push(lt(e))}while(e.eat("|"));return 1==t.length?t[0]:{type:"choice",exprs:t}}function lt(e){let t=[];do{t.push(ct(e))}while(e.next&&")"!=e.next&&"|"!=e.next);return 1==t.length?t[0]:{type:"seq",exprs:t}}function ct(e){let t=function(e){if(e.eat("(")){let t=at(e);return e.eat(")")||e.err("Missing closing paren"),t}if(!/\W/.test(e.next)){let t=function(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let i=[];for(let e in n){let r=n[e];r.groups.indexOf(t)>-1&&i.push(r)}0==i.length&&e.err("No node type or group '"+t+"' found");return i}(e,e.next).map((t=>(null==e.inline?e.inline=t.isInline:e.inline!=t.isInline&&e.err("Mixing inline and block content"),{type:"name",value:t})));return e.pos++,1==t.length?t[0]:{type:"choice",exprs:t}}e.err("Unexpected token '"+e.next+"'")}(e);for(;;)if(e.eat("+"))t={type:"plus",expr:t};else if(e.eat("*"))t={type:"star",expr:t};else if(e.eat("?"))t={type:"opt",expr:t};else{if(!e.eat("{"))break;t=dt(e,t)}return t}function ht(e){/\D/.test(e.next)&&e.err("Expected number, got '"+e.next+"'");let t=Number(e.next);return e.pos++,t}function dt(e,t){let n=ht(e),r=n;return e.eat(",")&&(r="}"!=e.next?ht(e):-1),e.eat("}")||e.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:t}}function ut(e,t){return t-e}function pt(e,t){let n=[];return function t(r){let i=e[r];if(1==i.length&&!i[0].term)return t(i[0].to);n.push(r);for(let e=0;e<i.length;e++){let{term:r,to:s}=i[e];r||-1!=n.indexOf(s)||t(s)}}(t),n.sort(ut)}function ft(e){let t=Object.create(null);for(let n in e){let r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function mt(e,t){let n=Object.create(null);for(let r in e){let i=t&&t[r];if(void 0===i){let t=e[r];if(!t.hasDefault)throw new RangeError("No value supplied for attribute "+r);i=t.default}n[r]=i}return n}function gt(e){let t=Object.create(null);if(e)for(let n in e)t[n]=new vt(e[n]);return t}class yt{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(" "):[],this.attrs=gt(n.attrs),this.defaultAttrs=ft(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||"text"==e),this.isText="text"==e}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==st.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:mt(this.attrs,e)}create(e=null,t,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new nt(this,this.computeAttrs(e),$e.from(t),Be.setFrom(n))}createChecked(e=null,t,n){if(t=$e.from(t),!this.validContent(t))throw new RangeError("Invalid content for node "+this.name);return new nt(this,this.computeAttrs(e),t,Be.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),(t=$e.from(t)).size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let r=this.contentMatch.matchFragment(t),i=r&&r.fillBefore($e.empty,!0);return i?new nt(this,e,t.append(i),Be.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t<e.childCount;t++)if(!this.allowsMarks(e.child(t).marks))return!1;return!0}allowsMarkType(e){return null==this.markSet||this.markSet.indexOf(e)>-1}allowsMarks(e){if(null==this.markSet)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(null==this.markSet)return e;let t;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||(t=e.slice(0,n));return t?t.length?t:Be.none:e}static compile(e,t){let n=Object.create(null);e.forEach(((e,r)=>n[e]=new yt(e,t,r)));let r=t.spec.topNode||"doc";if(!n[r])throw new RangeError("Schema is missing its top node type ('"+r+"')");if(!n.text)throw new RangeError("Every schema needs a 'text' type");for(let e in n.text.attrs)throw new RangeError("The text node type should not have attributes");return n}}class vt{constructor(e){this.hasDefault=Object.prototype.hasOwnProperty.call(e,"default"),this.default=e.default}get isRequired(){return!this.hasDefault}}class wt{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=gt(r.attrs),this.excluded=null;let i=ft(this.attrs);this.instance=i?new Be(this,i):null}create(e=null){return!e&&this.instance?this.instance:new Be(this,mt(this.attrs,e))}static compile(e,t){let n=Object.create(null),r=0;return e.forEach(((e,i)=>n[e]=new wt(e,r++,t,i))),n}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}excludes(e){return this.excluded.indexOf(e)>-1}}class bt{constructor(e){this.cached=Object.create(null),this.spec={nodes:Te.from(e.nodes),marks:Te.from(e.marks||{}),topNode:e.topNode},this.nodes=yt.compile(this.spec.nodes,this),this.marks=wt.compile(this.spec.marks,this);let t=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw new RangeError(e+" can not be both a node and a mark");let n=this.nodes[e],r=n.spec.content||"",i=n.spec.marks;n.contentMatch=t[r]||(t[r]=st.parse(r,this.nodes)),n.inlineContent=n.contentMatch.inlineContent,n.markSet="_"==i?null:i?xt(this,i.split(" ")):""!=i&&n.inlineContent?null:[]}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=null==n?[t]:""==n?[]:xt(this,n.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,n,r){if("string"==typeof e)e=this.nodeType(e);else{if(!(e instanceof yt))throw new RangeError("Invalid node type: "+e);if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}return e.createChecked(t,n,r)}text(e,t){let n=this.nodes.text;return new rt(n,n.defaultAttrs,e,Be.setFrom(t))}mark(e,t){return"string"==typeof e&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return nt.fromJSON(this,e)}markFromJSON(e){return Be.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function xt(e,t){let n=[];for(let r=0;r<t.length;r++){let i=t[r],s=e.marks[i],o=s;if(s)n.push(s);else for(let t in e.marks){let r=e.marks[t];("_"==i||r.spec.group&&r.spec.group.split(" ").indexOf(i)>-1)&&n.push(o=r)}if(!o)throw new SyntaxError("Unknown mark type: '"+t[r]+"'")}return n}class kt{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[],t.forEach((e=>{e.tag?this.tags.push(e):e.style&&this.styles.push(e)})),this.normalizeLists=!this.tags.some((t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)}))}parse(e,t={}){let n=new Et(this,t,!1);return n.addAll(e,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new Et(this,t,!0);return n.addAll(e,t.from,t.to),Le.maxOpen(n.finish())}matchTag(e,t,n){for(let r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){let n=this.tags[r];if(Tt(e,n.tag)&&(void 0===n.namespace||e.namespaceURI==n.namespace)&&(!n.context||t.matchesContext(n.context))){if(n.getAttrs){let t=n.getAttrs(e);if(!1===t)continue;n.attrs=t||void 0}return n}}}matchStyle(e,t,n,r){for(let i=r?this.styles.indexOf(r)+1:0;i<this.styles.length;i++){let r=this.styles[i],s=r.style;if(!(0!=s.indexOf(e)||r.context&&!n.matchesContext(r.context)||s.length>e.length&&(61!=s.charCodeAt(e.length)||s.slice(e.length+1)!=t))){if(r.getAttrs){let e=r.getAttrs(t);if(!1===e)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=null==e.priority?50:e.priority,r=0;for(;r<t.length;r++){let e=t[r];if((null==e.priority?50:e.priority)<n)break}t.splice(r,0,e)}for(let t in e.marks){let r=e.marks[t].spec.parseDOM;r&&r.forEach((e=>{n(e=Nt(e)),e.mark=t}))}for(let t in e.nodes){let r=e.nodes[t].spec.parseDOM;r&&r.forEach((e=>{n(e=Nt(e)),e.node=t}))}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new kt(e,kt.schemaRules(e)))}}const St={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},Mt={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Ot={ol:!0,ul:!0};function Ct(e,t,n){return null!=t?(t?1:0)|("full"===t?2:0):e&&"pre"==e.whitespace?3:-5&n}class At{constructor(e,t,n,r,i,s,o){this.type=e,this.attrs=t,this.marks=n,this.pendingMarks=r,this.solid=i,this.options=o,this.content=[],this.activeMarks=Be.none,this.stashMarks=[],this.match=s||(4&o?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore($e.from(e));if(!t){let t,n=this.type.contentMatch;return(t=n.findWrapping(e.type))?(this.match=n,t):null}this.match=this.type.contentMatch.matchFragment(t)}return this.match.findWrapping(e.type)}finish(e){if(!(1&this.options)){let e,t=this.content[this.content.length-1];if(t&&t.isText&&(e=/[ \t\r\n\u000c]+$/.exec(t.text))){let n=t;t.text.length==e[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-e[0].length))}}let t=$e.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore($e.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}popFromStashMark(e){for(let t=this.stashMarks.length-1;t>=0;t--)if(e.eq(this.stashMarks[t]))return this.stashMarks.splice(t,1)[0]}applyPending(e){for(let t=0,n=this.pendingMarks;t<n.length;t++){let r=n[t];(this.type?this.type.allowsMarkType(r.type):Dt(r.type,e))&&!r.isInSet(this.activeMarks)&&(this.activeMarks=r.addToSet(this.activeMarks),this.pendingMarks=r.removeFromSet(this.pendingMarks))}}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!St.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Et{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0;let r,i=t.topNode,s=Ct(null,t.preserveWhitespace,0)|(n?4:0);r=i?new At(i.type,i.attrs,Be.none,Be.none,!0,t.topMatch||i.type.contentMatch,s):new At(n?null:e.schema.topNodeType,null,Be.none,Be.none,!0,null,s),this.nodes=[r],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e){if(3==e.nodeType)this.addTextNode(e);else if(1==e.nodeType){let t=e.getAttribute("style"),n=t?this.readStyles(function(e){let t,n=/\s*([\w-]+)\s*:\s*([^;]+)/g,r=[];for(;t=n.exec(e);)r.push(t[1],t[2].trim());return r}(t)):null,r=this.top;if(null!=n)for(let e=0;e<n.length;e++)this.addPendingMark(n[e]);if(this.addElement(e),null!=n)for(let e=0;e<n.length;e++)this.removePendingMark(n[e],r)}}addTextNode(e){let t=e.nodeValue,n=this.top;if(2&n.options||n.inlineContext(e)||/[^ \t\r\n\u000c]/.test(t)){if(1&n.options)t=2&n.options?t.replace(/\r\n?/g,"\n"):t.replace(/\r?\n|\r/g," ");else if(t=t.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(t)&&this.open==this.nodes.length-1){let r=n.content[n.content.length-1],i=e.previousSibling;(!r||i&&"BR"==i.nodeName||r.isText&&/[ \t\r\n\u000c]$/.test(r.text))&&(t=t.slice(1))}t&&this.insertNode(this.parser.schema.text(t)),this.findInText(e)}else this.findInside(e)}addElement(e,t){let n,r=e.nodeName.toLowerCase();Ot.hasOwnProperty(r)&&this.parser.normalizeLists&&function(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=1==t.nodeType?t.nodeName.toLowerCase():null;e&&Ot.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):"li"==e?n=t:e&&(n=null)}}(e);let i=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(n=this.parser.matchTag(e,this,t));if(i?i.ignore:Mt.hasOwnProperty(r))this.findInside(e),this.ignoreFallback(e);else if(!i||i.skip||i.closeParent){i&&i.closeParent?this.open=Math.max(0,this.open-1):i&&i.skip.nodeType&&(e=i.skip);let t,n=this.top,s=this.needsBlock;if(St.hasOwnProperty(r))t=!0,n.type||(this.needsBlock=!0);else if(!e.firstChild)return void this.leafFallback(e);this.addAll(e),t&&this.sync(n),this.needsBlock=s}else this.addElementByRule(e,i,!1===i.consuming?n:void 0)}leafFallback(e){"BR"==e.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode("\n"))}ignoreFallback(e){"BR"!=e.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"))}readStyles(e){let t=Be.none;e:for(let n=0;n<e.length;n+=2)for(let r;;){let i=this.parser.matchStyle(e[n],e[n+1],this,r);if(!i)continue e;if(i.ignore)return null;if(t=this.parser.schema.marks[i.mark].create(i.attrs).addToSet(t),!1!==i.consuming)break;r=i}return t}addElementByRule(e,t,n){let r,i,s;if(t.node)i=this.parser.schema.nodes[t.node],i.isLeaf?this.insertNode(i.create(t.attrs))||this.leafFallback(e):r=this.enter(i,t.attrs||null,t.preserveWhitespace);else{s=this.parser.schema.marks[t.mark].create(t.attrs),this.addPendingMark(s)}let o=this.top;if(i&&i.isLeaf)this.findInside(e);else if(n)this.addElement(e,n);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach((e=>this.insertNode(e)));else{let n=e;"string"==typeof t.contentElement?n=e.querySelector(t.contentElement):"function"==typeof t.contentElement?n=t.contentElement(e):t.contentElement&&(n=t.contentElement),this.findAround(e,n,!0),this.addAll(n)}r&&this.sync(o)&&this.open--,s&&this.removePendingMark(s,o)}addAll(e,t,n){let r=t||0;for(let i=t?e.childNodes[t]:e.firstChild,s=null==n?null:e.childNodes[n];i!=s;i=i.nextSibling,++r)this.findAtPoint(e,r),this.addDOM(i);this.findAtPoint(e,r)}findPlace(e){let t,n;for(let r=this.open;r>=0;r--){let i=this.nodes[r],s=i.findWrapping(e);if(s&&(!t||t.length>s.length)&&(t=s,n=i,!s.length))break;if(i.solid)break}if(!t)return!1;this.sync(n);for(let e=0;e<t.length;e++)this.enterInner(t[e],null,!1);return!0}insertNode(e){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&this.enterInner(e)}if(this.findPlace(e)){this.closeExtra();let t=this.top;t.applyPending(e.type),t.match&&(t.match=t.match.matchType(e.type));let n=t.activeMarks;for(let r=0;r<e.marks.length;r++)t.type&&!t.type.allowsMarkType(e.marks[r].type)||(n=e.marks[r].addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n){let r=this.findPlace(e.create(t));return r&&this.enterInner(e,t,!0,n),r}enterInner(e,t=null,n=!1,r){this.closeExtra();let i=this.top;i.applyPending(e),i.match=i.match&&i.match.matchType(e);let s=Ct(e,r,i.options);4&i.options&&0==i.content.length&&(s|=4),this.nodes.push(new At(e,t,i.activeMarks,i.pendingMarks,n,null,s)),this.open++}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 n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)null==this.find[t].pos&&1==e.nodeType&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let r=0;r<this.find.length;r++)if(null==this.find[r].pos&&1==e.nodeType&&e.contains(this.find[r].node)){t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),n=this.options.context,r=!(this.isOpen||n&&n.parent.type!=this.nodes[0].type),i=-(n?n.depth+1:0)+(r?0:1),s=(e,o)=>{for(;e>=0;e--){let a=t[e];if(""==a){if(e==t.length-1||0==e)continue;for(;o>=i;o--)if(s(e-1,o))return!0;return!1}{let e=o>0||0==o&&r?this.nodes[o].type:n&&o>=i?n.node(o-i).type:null;if(!e||e.name!=a&&-1==e.groups.indexOf(a))return!1;o--}}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 n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}addPendingMark(e){let t=function(e,t){for(let n=0;n<t.length;n++)if(e.eq(t[n]))return t[n]}(e,this.top.pendingMarks);t&&this.top.stashMarks.push(t),this.top.pendingMarks=e.addToSet(this.top.pendingMarks)}removePendingMark(e,t){for(let n=this.open;n>=0;n--){let r=this.nodes[n];if(r.pendingMarks.lastIndexOf(e)>-1)r.pendingMarks=e.removeFromSet(r.pendingMarks);else{r.activeMarks=e.removeFromSet(r.activeMarks);let t=r.popFromStashMark(e);t&&r.type&&r.type.allowsMarkType(t.type)&&(r.activeMarks=t.addToSet(r.activeMarks))}if(r==t)break}}}function Tt(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function Nt(e){let t={};for(let n in e)t[n]=e[n];return t}function Dt(e,t){let n=t.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(e))continue;let s=[],o=e=>{s.push(e);for(let n=0;n<e.edgeCount;n++){let{type:r,next:i}=e.edge(n);if(r==t)return!0;if(s.indexOf(i)<0&&o(i))return!0}};if(o(i.contentMatch))return!0}}class $t{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||(n=Rt(t).createDocumentFragment());let r=n,i=[];return e.forEach((e=>{if(i.length||e.marks.length){let n=0,s=0;for(;n<i.length&&s<e.marks.length;){let t=e.marks[s];if(this.marks[t.type.name]){if(!t.eq(i[n][0])||!1===t.type.spec.spanning)break;n++,s++}else s++}for(;n<i.length;)r=i.pop()[1];for(;s<e.marks.length;){let n=e.marks[s++],o=this.serializeMark(n,e.isInline,t);o&&(i.push([n,r]),r.appendChild(o.dom),r=o.contentDOM||o.dom)}}r.appendChild(this.serializeNodeInner(e,t))})),n}serializeNodeInner(e,t){let{dom:n,contentDOM:r}=$t.renderSpec(Rt(t),this.nodes[e.type.name](e));if(r){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,r)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let i=this.serializeMark(e.marks[r],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(n),n=i.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&$t.renderSpec(Rt(n),r(e,t))}static renderSpec(e,t,n=null){if("string"==typeof t)return{dom:e.createTextNode(t)};if(null!=t.nodeType)return{dom:t};if(t.dom&&null!=t.dom.nodeType)return t;let r,i=t[0],s=i.indexOf(" ");s>0&&(n=i.slice(0,s),i=i.slice(s+1));let o=n?e.createElementNS(n,i):e.createElement(i),a=t[1],l=1;if(a&&"object"==typeof a&&null==a.nodeType&&!Array.isArray(a)){l=2;for(let e in a)if(null!=a[e]){let t=e.indexOf(" ");t>0?o.setAttributeNS(e.slice(0,t),e.slice(t+1),a[e]):o.setAttribute(e,a[e])}}for(let i=l;i<t.length;i++){let s=t[i];if(0===s){if(i<t.length-1||i>l)throw new RangeError("Content hole must be the only child of its parent node");return{dom:o,contentDOM:o}}{let{dom:t,contentDOM:i}=$t.renderSpec(e,s,n);if(o.appendChild(t),i){if(r)throw new RangeError("Multiple content holes");r=i}}}return{dom:o,contentDOM:r}}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new $t(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=It(e.nodes);return t.text||(t.text=e=>e.text),t}static marksFromSchema(e){return It(e.marks)}}function It(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function Rt(e){return e.document||window.document}const Pt=Math.pow(2,16);function Bt(e,t){return e+t*Pt}function Ft(e){return 65535&e}class Lt{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(8&this.delInfo)>0}get deletedBefore(){return(5&this.delInfo)>0}get deletedAfter(){return(6&this.delInfo)>0}get deletedAcross(){return(4&this.delInfo)>0}}class zt{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&zt.empty)return zt.empty}recover(e){let t=0,n=Ft(e);if(!this.inverted)for(let e=0;e<n;e++)t+=this.ranges[3*e+2]-this.ranges[3*e+1];return this.ranges[3*n]+t+function(e){return(e-(65535&e))/Pt}(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let r=0,i=this.inverted?2:1,s=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let a=this.ranges[o]-(this.inverted?r:0);if(a>e)break;let l=this.ranges[o+i],c=this.ranges[o+s],h=a+l;if(e<=h){let i=a+r+((l?e==a?-1:e==h?1:t:t)<0?0:c);if(n)return i;let s=e==(t<0?a:h)?null:Bt(o/3,e-a),d=e==a?2:e==h?1:4;return(t<0?e!=a:e!=h)&&(d|=8),new Lt(i,d,s)}r+=c-l}return n?e+r:new Lt(e+r,0,null)}touches(e,t){let n=0,r=Ft(t),i=this.inverted?2:1,s=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let o=this.ranges[t]-(this.inverted?n:0);if(o>e)break;let a=this.ranges[t+i];if(e<=o+a&&t==3*r)return!0;n+=this.ranges[t+s]-a}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,i=0;r<this.ranges.length;r+=3){let s=this.ranges[r],o=s-(this.inverted?i:0),a=s+(this.inverted?0:i),l=this.ranges[r+t],c=this.ranges[r+n];e(o,o+l,a,a+c),i+=c-l}}invert(){return new zt(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return 0==e?zt.empty:new zt(e<0?[0,-e,0]:[0,0,e])}}zt.empty=new zt([]);class Vt{constructor(e=[],t,n=0,r=e.length){this.maps=e,this.mirror=t,this.from=n,this.to=r}slice(e=0,t=this.maps.length){return new Vt(this.maps,this.mirror,e,t)}copy(){return new Vt(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)}appendMap(e,t){this.to=this.maps.push(e),null!=t&&this.setMirror(this.maps.length-1,t)}appendMapping(e){for(let t=0,n=this.maps.length;t<e.maps.length;t++){let r=e.getMirror(t);this.appendMap(e.maps[t],null!=r&&r<t?n+r:void 0)}}getMirror(e){if(this.mirror)for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this.maps.length+e.maps.length;t>=0;t--){let r=e.getMirror(t);this.appendMap(e.maps[t].invert(),null!=r&&r>t?n-r-1:void 0)}}invert(){let e=new Vt;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this.maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let r=0;for(let n=this.from;n<this.to;n++){let i=this.maps[n].mapResult(e,t);if(null!=i.recover){let t=this.getMirror(n);if(null!=t&&t>n&&t<this.to){n=t,e=this.maps[t].recover(i.recover);continue}}r|=i.delInfo,e=i.pos}return n?e:new Lt(e,r,null)}}const jt=Object.create(null);class _t{getMap(){return zt.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=jt[t.stepType];if(!n)throw new RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in jt)throw new RangeError("Duplicate use of step JSON ID "+e);return jt[e]=t,t.prototype.jsonID=e,t}}class Wt{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new Wt(e,null)}static fail(e){return new Wt(null,e)}static fromReplace(e,t,n,r){try{return Wt.ok(e.replace(t,n,r))}catch(e){if(e instanceof Fe)return Wt.fail(e.message);throw e}}}function Ht(e,t,n){let r=[];for(let i=0;i<e.childCount;i++){let s=e.child(i);s.content.size&&(s=s.copy(Ht(s.content,t,s))),s.isInline&&(s=t(s,n,i)),r.push(s)}return $e.fromArray(r)}class Kt extends _t{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),r=n.node(n.sharedDepth(this.to)),i=new Le(Ht(t.content,((e,t)=>e.isAtom&&t.type.allowsMarkType(this.mark.type)?e.mark(this.mark.addToSet(e.marks)):e),r),t.openStart,t.openEnd);return Wt.fromReplace(e,this.from,this.to,i)}invert(){return new qt(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new Kt(t.pos,n.pos,this.mark)}merge(e){return e instanceof Kt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Kt(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("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Kt(t.from,t.to,e.markFromJSON(t.mark))}}_t.jsonID("addMark",Kt);class qt extends _t{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new Le(Ht(t.content,(e=>e.mark(this.mark.removeFromSet(e.marks))),e),t.openStart,t.openEnd);return Wt.fromReplace(e,this.from,this.to,n)}invert(){return new Kt(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new qt(t.pos,n.pos,this.mark)}merge(e){return e instanceof qt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new qt(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("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new qt(t.from,t.to,e.markFromJSON(t.mark))}}_t.jsonID("removeMark",qt);class Jt extends _t{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Wt.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return Wt.fromReplace(e,this.pos,this.pos+1,new Le($e.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let e=this.mark.addToSet(t.marks);if(e.length==t.marks.length){for(let n=0;n<t.marks.length;n++)if(!t.marks[n].isInSet(e))return new Jt(this.pos,t.marks[n]);return new Jt(this.pos,this.mark)}}return new Ut(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Jt(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Jt(t.pos,e.markFromJSON(t.mark))}}_t.jsonID("addNodeMark",Jt);class Ut extends _t{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Wt.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return Wt.fromReplace(e,this.pos,this.pos+1,new Le($e.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return t&&this.mark.isInSet(t.marks)?new Jt(this.pos,this.mark):this}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Ut(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Ut(t.pos,e.markFromJSON(t.mark))}}_t.jsonID("removeNodeMark",Ut);class Gt extends _t{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&Xt(e,this.from,this.to)?Wt.fail("Structure replace would overwrite content"):Wt.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new zt([this.from,this.to-this.from,this.slice.size])}invert(e){return new Gt(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deletedAcross&&n.deletedAcross?null:new Gt(t.pos,Math.max(t.pos,n.pos),this.slice)}merge(e){if(!(e instanceof Gt)||e.structure||this.structure)return null;if(this.from+this.slice.size!=e.from||this.slice.openEnd||e.slice.openStart){if(e.to!=this.from||this.slice.openStart||e.slice.openEnd)return null;{let t=this.slice.size+e.slice.size==0?Le.empty:new Le(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Gt(e.from,this.to,t,this.structure)}}{let t=this.slice.size+e.slice.size==0?Le.empty:new Le(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Gt(this.from,this.to+(e.to-e.from),t,this.structure)}}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Gt(t.from,t.to,Le.fromJSON(e,t.slice),!!t.structure)}}_t.jsonID("replace",Gt);class Yt extends _t{constructor(e,t,n,r,i,s,o=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=i,this.insert=s,this.structure=o}apply(e){if(this.structure&&(Xt(e,this.from,this.gapFrom)||Xt(e,this.gapTo,this.to)))return Wt.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return Wt.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,t.content);return n?Wt.fromReplace(e,this.from,this.to,n):Wt.fail("Content does not fit in gap")}getMap(){return new zt([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new Yt(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1),r=e.map(this.gapFrom,-1),i=e.map(this.gapTo,1);return t.deletedAcross&&n.deletedAcross||r<t.pos||i>n.pos?null:new Yt(t.pos,n.pos,r,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to||"number"!=typeof t.gapFrom||"number"!=typeof t.gapTo||"number"!=typeof t.insert)throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Yt(t.from,t.to,t.gapFrom,t.gapTo,Le.fromJSON(e,t.slice),t.insert,!!t.structure)}}function Xt(e,t,n){let r=e.resolve(t),i=n-t,s=r.depth;for(;i>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,i--;if(i>0){let e=r.node(s).maybeChild(r.indexAfter(s));for(;i>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,i--}}return!1}function Zt(e,t,n){return(0==t||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function Qt(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth;;--n){let r=e.$from.node(n),i=e.$from.index(n),s=e.$to.indexAfter(n);if(n<e.depth&&r.canReplace(i,s,t))return n;if(0==n||r.type.spec.isolating||!Zt(r,i,s))break}return null}function en(e,t,n=null,r=e){let i=function(e,t){let{parent:n,startIndex:r,endIndex:i}=e,s=n.contentMatchAt(r).findWrapping(t);if(!s)return null;let o=s.length?s[0]:t;return n.canReplaceWith(r,i,o)?s:null}(e,t),s=i&&function(e,t){let{parent:n,startIndex:r,endIndex:i}=e,s=n.child(r),o=t.contentMatch.findWrapping(s.type);if(!o)return null;let a=(o.length?o[o.length-1]:t).contentMatch;for(let e=r;a&&e<i;e++)a=a.matchType(n.child(e).type);return a&&a.validEnd?o:null}(r,t);return s?i.map(tn).concat({type:t,attrs:n}).concat(s.map(tn)):null}function tn(e){return{type:e,attrs:null}}function nn(e,t,n=1,r){let i=e.resolve(t),s=i.depth-n,o=r&&r[r.length-1]||i.parent;if(s<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let e=i.depth-1,t=n-2;e>s;e--,t--){let n=i.node(e),s=i.index(e);if(n.type.spec.isolating)return!1;let o=n.content.cutByIndex(s,n.childCount),a=r&&r[t]||n;if(a!=n&&(o=o.replaceChild(0,a.type.create(a.attrs))),!n.canReplace(s+1,n.childCount)||!a.type.validContent(o))return!1}let a=i.indexAfter(s),l=r&&r[0];return i.node(s).canReplaceWith(a,a,l?l.type:i.node(s+1).type)}function rn(e,t){let n=e.resolve(t),r=n.index();return function(e,t){return!(!e||!t||e.isLeaf||!e.canAppend(t))}(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function sn(e,t,n){let r=e.resolve(t);if(!n.content.size)return t;let i=n.content;for(let e=0;e<n.openStart;e++)i=i.firstChild.content;for(let e=1;e<=(0==n.openStart&&n.size?2:1);e++)for(let t=r.depth;t>=0;t--){let n=t==r.depth?0:r.pos<=(r.start(t+1)+r.end(t+1))/2?-1:1,s=r.index(t)+(n>0?1:0),o=r.node(t),a=!1;if(1==e)a=o.canReplace(s,s,i);else{let e=o.contentMatchAt(s).findWrapping(i.firstChild.type);a=e&&o.canReplaceWith(s,s,e[0])}if(a)return 0==n?r.pos:n<0?r.before(t+1):r.after(t+1)}return null}function on(e,t,n=t,r=Le.empty){if(t==n&&!r.size)return null;let i=e.resolve(t),s=e.resolve(n);return an(i,s,r)?new Gt(t,n,r):new ln(i,s,r).fit()}function an(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}_t.jsonID("replaceAround",Yt);class ln{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=$e.empty;for(let t=0;t<=e.depth;t++){let n=e.node(t);this.frontier.push({type:n.type,match:n.contentMatchAt(e.indexAfter(t))})}for(let t=e.depth;t>0;t--)this.placed=$e.from(e.node(t).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,r=this.close(e<0?this.$to:n.doc.resolve(e));if(!r)return null;let i=this.placed,s=n.depth,o=r.depth;for(;s&&o&&1==i.childCount;)i=i.firstChild.content,s--,o--;let a=new Le(i,s,o);return e>-1?new Yt(n.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||n.pos!=this.$to.pos?new Gt(n.pos,r.pos,a):null}findFittable(){for(let e=1;e<=2;e++)for(let t=this.unplaced.openStart;t>=0;t--){let n,r=null;t?(r=dn(this.unplaced.content,t-1).firstChild,n=r.content):n=this.unplaced.content;let i=n.firstChild;for(let n=this.depth;n>=0;n--){let s,{type:o,match:a}=this.frontier[n],l=null;if(1==e&&(i?a.matchType(i.type)||(l=a.fillBefore($e.from(i),!1)):r&&o.compatibleContent(r.type)))return{sliceDepth:t,frontierDepth:n,parent:r,inject:l};if(2==e&&i&&(s=a.findWrapping(i.type)))return{sliceDepth:t,frontierDepth:n,parent:r,wrap:s};if(r&&a.matchType(r.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=dn(e,t);return!(!r.childCount||r.firstChild.isLeaf)&&(this.unplaced=new Le(e,t+1,Math.max(n,r.size+t>=e.size-n?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=dn(e,t);if(r.childCount<=1&&t>0){let i=e.size-t<=t+r.size;this.unplaced=new Le(cn(e,t-1,1),t-1,i?t-1:n)}else this.unplaced=new Le(cn(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:r,wrap:i}){for(;this.depth>t;)this.closeFrontierNode();if(i)for(let e=0;e<i.length;e++)this.openFrontierNode(i[e]);let s=this.unplaced,o=n?n.content:s.content,a=s.openStart-e,l=0,c=[],{match:h,type:d}=this.frontier[t];if(r){for(let e=0;e<r.childCount;e++)c.push(r.child(e));h=h.matchFragment(r)}let u=o.size+e-(s.content.size-s.openEnd);for(;l<o.childCount;){let e=o.child(l),t=h.matchType(e.type);if(!t)break;l++,(l>1||0==a||e.content.size)&&(h=t,c.push(un(e.mark(d.allowedMarks(e.marks)),1==l?a:0,l==o.childCount?u:-1)))}let p=l==o.childCount;p||(u=-1),this.placed=hn(this.placed,t,$e.from(c)),this.frontier[t].match=h,p&&u<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let e=0,t=o;e<u;e++){let e=t.lastChild;this.frontier.push({type:e.type,match:e.contentMatchAt(e.childCount)}),t=e.content}this.unplaced=p?0==e?Le.empty:new Le(cn(s.content,e-1,1),e-1,u<0?s.openEnd:e-1):new Le(cn(s.content,e,l),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e,t=this.frontier[this.depth];if(!t.type.isTextblock||!pn(this.$to,this.$to.depth,t.type,t.match,!1)||this.$to.depth==this.depth&&(e=this.findCloseLevel(this.$to))&&e.depth==this.depth)return-1;let{depth:n}=this.$to,r=this.$to.after(n);for(;n>1&&r==this.$to.end(--n);)++r;return r}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:r}=this.frontier[t],i=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),s=pn(e,t,r,n,i);if(s){for(let n=t-1;n>=0;n--){let{match:t,type:r}=this.frontier[n],i=pn(e,n,r,t,!0);if(!i||i.childCount)continue e}return{depth:t,fit:s,move:i?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=hn(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let t=e.node(n),r=t.type.contentMatch.fillBefore(t.content,!0,e.index(n));this.openFrontierNode(t.type,t.attrs,r)}return e}openFrontierNode(e,t=null,n){let r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=hn(this.placed,this.depth,$e.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore($e.empty,!0);e.childCount&&(this.placed=hn(this.placed,this.frontier.length,e))}}function cn(e,t,n){return 0==t?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(cn(e.firstChild.content,t-1,n)))}function hn(e,t,n){return 0==t?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(hn(e.lastChild.content,t-1,n)))}function dn(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function un(e,t,n){if(t<=0)return e;let r=e.content;return t>1&&(r=r.replaceChild(0,un(r.firstChild,t-1,1==r.childCount?n-1:0))),t>0&&(r=e.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(e.type.contentMatch.matchFragment(r).fillBefore($e.empty,!0)))),e.copy(r)}function pn(e,t,n,r,i){let s=e.node(t),o=i?e.indexAfter(t):e.index(t);if(o==s.childCount&&!n.compatibleContent(s.type))return null;let a=r.fillBefore(s.content,!0,o);return a&&!function(e,t,n){for(let r=n;r<t.childCount;r++)if(!e.allowsMarks(t.child(r).marks))return!0;return!1}(n,s.content,o)?a:null}function fn(e){return e.spec.defining||e.spec.definingForContent}function mn(e,t,n,r,i){if(t<n){let i=e.firstChild;e=e.replaceChild(0,i.copy(mn(i.content,t+1,n,r,i)))}if(t>r){let t=i.contentMatchAt(0),n=t.fillBefore(e).append(e);e=n.append(t.matchFragment(n).fillBefore($e.empty,!0))}return e}function gn(e,t){let n=[];for(let r=Math.min(e.depth,t.depth);r>=0;r--){let i=e.start(r);if(i<e.pos-(e.depth-r)||t.end(r)>t.pos+(t.depth-r)||e.node(r).type.spec.isolating||t.node(r).type.spec.isolating)break;(i==t.start(r)||r==e.depth&&r==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&r&&t.start(r-1)==i-1)&&n.push(r)}return n}class yn extends _t{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return Wt.fail("No node at attribute step's position");let n=Object.create(null);for(let e in t.attrs)n[e]=t.attrs[e];n[this.attr]=this.value;let r=t.type.create(n,null,t.marks);return Wt.fromReplace(e,this.pos,this.pos+1,new Le($e.from(r),0,t.isLeaf?0:1))}getMap(){return zt.empty}invert(e){return new yn(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 yn(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if("number"!=typeof t.pos||"string"!=typeof t.attr)throw new RangeError("Invalid input for AttrStep.fromJSON");return new yn(t.pos,t.attr,t.value)}}_t.jsonID("attr",yn);let vn=class extends Error{};vn=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},(vn.prototype=Object.create(Error.prototype)).constructor=vn,vn.prototype.name="TransformError";const wn=Object.create(null);class bn{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new xn(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=Le.empty){let n=t.content.lastChild,r=null;for(let e=0;e<t.openEnd;e++)r=n,n=n.lastChild;let i=e.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){let{$from:a,$to:l}=s[o],c=e.mapping.slice(i);e.replaceRange(c.map(a.pos),c.map(l.pos),o?Le.empty:t),0==o&&Dn(e,i,(n?n.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,r=this.ranges;for(let i=0;i<r.length;i++){let{$from:s,$to:o}=r[i],a=e.mapping.slice(n),l=a.map(s.pos),c=a.map(o.pos);i?e.deleteRange(l,c):(e.replaceRangeWith(l,c,t),Dn(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let r=e.parent.inlineContent?new Mn(e):Nn(e.node(0),e.parent,e.pos,e.index(),t,n);if(r)return r;for(let r=e.depth-1;r>=0;r--){let i=t<0?Nn(e.node(0),e.node(r),e.before(r+1),e.index(r),t,n):Nn(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,t,n);if(i)return i}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new En(e.node(0))}static atStart(e){return Nn(e,e,0,0,1)||new En(e)}static atEnd(e){return Nn(e,e,e.content.size,e.childCount,-1)||new En(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=wn[t.type];if(!n)throw new RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in wn)throw new RangeError("Duplicate use of selection JSON ID "+e);return wn[e]=t,t.prototype.jsonID=e,t}getBookmark(){return Mn.between(this.$anchor,this.$head).getBookmark()}}bn.prototype.visible=!0;class xn{constructor(e,t){this.$from=e,this.$to=t}}let kn=!1;function Sn(e){kn||e.parent.inlineContent||(kn=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}class Mn extends bn{constructor(e,t=e){Sn(e),Sn(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let n=e.resolve(t.map(this.head));if(!n.parent.inlineContent)return bn.near(n);let r=e.resolve(t.map(this.anchor));return new Mn(r.parent.inlineContent?r:n,n)}replace(e,t=Le.empty){if(super.replace(e,t),t==Le.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(e){return e instanceof Mn&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new On(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if("number"!=typeof t.anchor||"number"!=typeof t.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new Mn(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,n=t){let r=e.resolve(t);return new this(r,n==t?r:e.resolve(n))}static between(e,t,n){let r=e.pos-t.pos;if(n&&!r||(n=r>=0?1:-1),!t.parent.inlineContent){let e=bn.findFrom(t,n,!0)||bn.findFrom(t,-n,!0);if(!e)return bn.near(t,n);t=e.$head}return e.parent.inlineContent||(0==r||(e=(bn.findFrom(e,-n,!0)||bn.findFrom(e,n,!0)).$anchor).pos<t.pos!=r<0)&&(e=t),new Mn(e,t)}}bn.jsonID("text",Mn);class On{constructor(e,t){this.anchor=e,this.head=t}map(e){return new On(e.map(this.anchor),e.map(this.head))}resolve(e){return Mn.between(e.resolve(this.anchor),e.resolve(this.head))}}class Cn extends bn{constructor(e){let t=e.nodeAfter,n=e.node(0).resolve(e.pos+t.nodeSize);super(e,n),this.node=t}map(e,t){let{deleted:n,pos:r}=t.mapResult(this.anchor),i=e.resolve(r);return n?bn.near(i):new Cn(i)}content(){return new Le($e.from(this.node),0,0)}eq(e){return e instanceof Cn&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new An(this.anchor)}static fromJSON(e,t){if("number"!=typeof t.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Cn(e.resolve(t.anchor))}static create(e,t){return new Cn(e.resolve(t))}static isSelectable(e){return!e.isText&&!1!==e.type.spec.selectable}}Cn.prototype.visible=!1,bn.jsonID("node",Cn);class An{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:n}=e.mapResult(this.anchor);return t?new On(n,n):new An(n)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&Cn.isSelectable(n)?new Cn(t):bn.near(t)}}class En extends bn{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=Le.empty){if(t==Le.empty){e.delete(0,e.doc.content.size);let t=bn.atStart(e.doc);t.eq(e.selection)||e.setSelection(t)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new En(e)}map(e){return new En(e)}eq(e){return e instanceof En}getBookmark(){return Tn}}bn.jsonID("all",En);const Tn={map(){return this},resolve:e=>new En(e)};function Nn(e,t,n,r,i,s=!1){if(t.inlineContent)return Mn.create(e,n);for(let o=r-(i>0?0:1);i>0?o<t.childCount:o>=0;o+=i){let r=t.child(o);if(r.isAtom){if(!s&&Cn.isSelectable(r))return Cn.create(e,n-(i<0?r.nodeSize:0))}else{let t=Nn(e,r,n+i,i<0?r.childCount:0,i,s);if(t)return t}n+=r.nodeSize*i}return null}function Dn(e,t,n){let r=e.steps.length-1;if(r<t)return;let i,s=e.steps[r];(s instanceof Gt||s instanceof Yt)&&(e.mapping.maps[r].forEach(((e,t,n,r)=>{null==i&&(i=r)})),e.setSelection(bn.near(e.doc.resolve(i),n)))}class $n extends class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Vt}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new vn(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,n=Le.empty){let r=on(this.doc,e,t,n);return r&&this.step(r),this}replaceWith(e,t,n){return this.replace(e,t,new Le($e.from(n),0,0))}delete(e,t){return this.replace(e,t,Le.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return function(e,t,n,r){if(!r.size)return e.deleteRange(t,n);let i=e.doc.resolve(t),s=e.doc.resolve(n);if(an(i,s,r))return e.step(new Gt(t,n,r));let o=gn(i,e.doc.resolve(n));0==o[o.length-1]&&o.pop();let a=-(i.depth+1);o.unshift(a);for(let e=i.depth,t=i.pos-1;e>0;e--,t--){let n=i.node(e).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;o.indexOf(e)>-1?a=e:i.before(e)==t&&o.splice(1,0,-e)}let l=o.indexOf(a),c=[],h=r.openStart;for(let e=r.content,t=0;;t++){let n=e.firstChild;if(c.push(n),t==r.openStart)break;e=n.content}for(let e=h-1;e>=0;e--){let t=c[e].type,n=fn(t);if(n&&i.node(l).type!=t)h=e;else if(n||!t.isTextblock)break}for(let t=r.openStart;t>=0;t--){let a=(t+h+1)%(r.openStart+1),d=c[a];if(d)for(let t=0;t<o.length;t++){let c=o[(t+l)%o.length],h=!0;c<0&&(h=!1,c=-c);let u=i.node(c-1),p=i.index(c-1);if(u.canReplaceWith(p,p,d.type,d.marks))return e.replace(i.before(c),h?s.after(c):n,new Le(mn(r.content,0,r.openStart,a),a,r.openEnd))}}let d=e.steps.length;for(let a=o.length-1;a>=0&&(e.replace(t,n,r),!(e.steps.length>d));a--){let e=o[a];e<0||(t=i.before(e),n=s.after(e))}}(this,e,t,n),this}replaceRangeWith(e,t,n){return function(e,t,n,r){if(!r.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let i=function(e,t,n){let r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(0==r.parentOffset)for(let e=r.depth-1;e>=0;e--){let t=r.index(e);if(r.node(e).canReplaceWith(t,t,n))return r.before(e+1);if(t>0)return null}if(r.parentOffset==r.parent.content.size)for(let e=r.depth-1;e>=0;e--){let t=r.indexAfter(e);if(r.node(e).canReplaceWith(t,t,n))return r.after(e+1);if(t<r.node(e).childCount)return null}return null}(e.doc,t,r.type);null!=i&&(t=n=i)}e.replaceRange(t,n,new Le($e.from(r),0,0))}(this,e,t,n),this}deleteRange(e,t){return function(e,t,n){let r=e.doc.resolve(t),i=e.doc.resolve(n),s=gn(r,i);for(let t=0;t<s.length;t++){let n=s[t],o=t==s.length-1;if(o&&0==n||r.node(n).type.contentMatch.validEnd)return e.delete(r.start(n),i.end(n));if(n>0&&(o||r.node(n-1).canReplace(r.index(n-1),i.indexAfter(n-1))))return e.delete(r.before(n),i.after(n))}for(let s=1;s<=r.depth&&s<=i.depth;s++)if(t-r.start(s)==r.depth-s&&n>r.end(s)&&i.end(s)-n!=i.depth-s)return e.delete(r.before(s),n);e.delete(t,n)}(this,e,t),this}lift(e,t){return function(e,t,n){let{$from:r,$to:i,depth:s}=t,o=r.before(s+1),a=i.after(s+1),l=o,c=a,h=$e.empty,d=0;for(let e=s,t=!1;e>n;e--)t||r.index(e)>0?(t=!0,h=$e.from(r.node(e).copy(h)),d++):l--;let u=$e.empty,p=0;for(let e=s,t=!1;e>n;e--)t||i.after(e+1)<i.end(e)?(t=!0,u=$e.from(i.node(e).copy(u)),p++):c++;e.step(new Yt(l,c,o,a,new Le(h.append(u),d,p),h.size-d,!0))}(this,e,t),this}join(e,t=1){return function(e,t,n){let r=new Gt(t-n,t+n,Le.empty,!0);e.step(r)}(this,e,t),this}wrap(e,t){return function(e,t,n){let r=$e.empty;for(let e=n.length-1;e>=0;e--){if(r.size){let t=n[e].type.contentMatch.matchFragment(r);if(!t||!t.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=$e.from(n[e].type.create(n[e].attrs,r))}let i=t.start,s=t.end;e.step(new Yt(i,s,i,s,new Le(r,0,0),n.length,!0))}(this,e,t),this}setBlockType(e,t=e,n,r=null){return function(e,t,n,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=e.steps.length;e.doc.nodesBetween(t,n,((t,n)=>{if(t.isTextblock&&!t.hasMarkup(r,i)&&function(e,t,n){let r=e.resolve(t),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}(e.doc,e.mapping.slice(s).map(n),r)){e.clearIncompatible(e.mapping.slice(s).map(n,1),r);let o=e.mapping.slice(s),a=o.map(n,1),l=o.map(n+t.nodeSize,1);return e.step(new Yt(a,l,a+1,l-1,new Le($e.from(r.create(i,null,t.marks)),0,0),1,!0)),!1}}))}(this,e,t,n,r),this}setNodeMarkup(e,t,n=null,r=[]){return function(e,t,n,r,i){let s=e.doc.nodeAt(t);if(!s)throw new RangeError("No node at given position");n||(n=s.type);let o=n.create(r,null,i||s.marks);if(s.isLeaf)return e.replaceWith(t,t+s.nodeSize,o);if(!n.validContent(s.content))throw new RangeError("Invalid content for node type "+n.name);e.step(new Yt(t,t+s.nodeSize,t+1,t+s.nodeSize-1,new Le($e.from(o),0,0),1,!0))}(this,e,t,n,r),this}setNodeAttribute(e,t,n){return this.step(new yn(e,t,n)),this}addNodeMark(e,t){return this.step(new Jt(e,t)),this}removeNodeMark(e,t){if(!(t instanceof Be)){let n=this.doc.nodeAt(e);if(!n)throw new RangeError("No node at position "+e);if(!(t=t.isInSet(n.marks)))return this}return this.step(new Ut(e,t)),this}split(e,t=1,n){return function(e,t,n=1,r){let i=e.doc.resolve(t),s=$e.empty,o=$e.empty;for(let e=i.depth,t=i.depth-n,a=n-1;e>t;e--,a--){s=$e.from(i.node(e).copy(s));let t=r&&r[a];o=$e.from(t?t.type.create(t.attrs,o):i.node(e).copy(o))}e.step(new Gt(t,t,new Le(s.append(o),n,n),!0))}(this,e,t,n),this}addMark(e,t,n){return function(e,t,n,r){let i,s,o=[],a=[];e.doc.nodesBetween(t,n,((e,l,c)=>{if(!e.isInline)return;let h=e.marks;if(!r.isInSet(h)&&c.type.allowsMarkType(r.type)){let c=Math.max(l,t),d=Math.min(l+e.nodeSize,n),u=r.addToSet(h);for(let e=0;e<h.length;e++)h[e].isInSet(u)||(i&&i.to==c&&i.mark.eq(h[e])?i.to=d:o.push(i=new qt(c,d,h[e])));s&&s.to==c?s.to=d:a.push(s=new Kt(c,d,r))}})),o.forEach((t=>e.step(t))),a.forEach((t=>e.step(t)))}(this,e,t,n),this}removeMark(e,t,n){return function(e,t,n,r){let i=[],s=0;e.doc.nodesBetween(t,n,((e,o)=>{if(!e.isInline)return;s++;let a=null;if(r instanceof wt){let t,n=e.marks;for(;t=r.isInSet(n);)(a||(a=[])).push(t),n=t.removeFromSet(n)}else r?r.isInSet(e.marks)&&(a=[r]):a=e.marks;if(a&&a.length){let r=Math.min(o+e.nodeSize,n);for(let e=0;e<a.length;e++){let n,l=a[e];for(let e=0;e<i.length;e++){let t=i[e];t.step==s-1&&l.eq(i[e].style)&&(n=t)}n?(n.to=r,n.step=s):i.push({style:l,from:Math.max(o,t),to:r,step:s})}}})),i.forEach((t=>e.step(new qt(t.from,t.to,t.style))))}(this,e,t,n),this}clearIncompatible(e,t,n){return function(e,t,n,r=n.contentMatch){let i=e.doc.nodeAt(t),s=[],o=t+1;for(let t=0;t<i.childCount;t++){let a=i.child(t),l=o+a.nodeSize,c=r.matchType(a.type);if(c){r=c;for(let t=0;t<a.marks.length;t++)n.allowsMarkType(a.marks[t].type)||e.step(new qt(o,l,a.marks[t]))}else s.push(new Gt(o,l,Le.empty));o=l}if(!r.validEnd){let t=r.fillBefore($e.empty,!0);e.replace(o,o,new Le(t,0,0))}for(let t=s.length-1;t>=0;t--)e.step(s[t])}(this,e,t,n),this}}{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=-3&(1|this.updated),this.storedMarks=null,this}get selectionSet(){return(1&this.updated)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=2,this}ensureMarks(e){return Be.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(2&this.updated)>0}addStep(e,t){super.addStep(e,t),this.updated=-3&this.updated,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||Be.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let r=this.doc.type.schema;if(null==t)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();{if(null==n&&(n=t),n=null==n?t:n,!e)return this.deleteRange(t,n);let i=this.storedMarks;if(!i){let e=this.doc.resolve(t);i=n==t?e.marks():e.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,r.text(e,i)),this.selection.empty||this.setSelection(bn.near(this.selection.$to)),this}}setMeta(e,t){return this.meta["string"==typeof e?e:e.key]=t,this}getMeta(e){return this.meta["string"==typeof e?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=4,this}get scrolledIntoView(){return(4&this.updated)>0}}function In(e,t){return t&&e?e.bind(t):e}class Rn{constructor(e,t,n){this.name=e,this.init=In(t.init,n),this.apply=In(t.apply,n)}}const Pn=[new Rn("doc",{init:e=>e.doc||e.schema.topNodeType.createAndFill(),apply:e=>e.doc}),new Rn("selection",{init:(e,t)=>e.selection||bn.atStart(t.doc),apply:e=>e.selection}),new Rn("storedMarks",{init:e=>e.storedMarks||null,apply:(e,t,n,r)=>r.selection.$cursor?e.storedMarks:null}),new Rn("scrollToSelection",{init:()=>0,apply:(e,t)=>e.scrolledIntoView?t+1:t})];class Bn{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Pn.slice(),t&&t.forEach((e=>{if(this.pluginsByKey[e.key])throw new RangeError("Adding different instances of a keyed plugin ("+e.key+")");this.plugins.push(e),this.pluginsByKey[e.key]=e,e.spec.state&&this.fields.push(new Rn(e.key,e.spec.state,e))}))}}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 n=0;n<this.config.plugins.length;n++)if(n!=t){let t=this.config.plugins[n];if(t.spec.filterTransaction&&!t.spec.filterTransaction.call(t,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],n=this.applyInner(e),r=null;for(;;){let i=!1;for(let s=0;s<this.config.plugins.length;s++){let o=this.config.plugins[s];if(o.spec.appendTransaction){let a=r?r[s].n:0,l=r?r[s].state:this,c=a<t.length&&o.spec.appendTransaction.call(o,a?t.slice(a):t,l,n);if(c&&n.filterTransaction(c,s)){if(c.setMeta("appendedTransaction",e),!r){r=[];for(let e=0;e<this.config.plugins.length;e++)r.push(e<s?{state:n,n:t.length}:{state:this,n:0})}t.push(c),n=n.applyInner(c),i=!0}r&&(r[s]={state:n,n:t.length})}}if(!i)return{state:n,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new Fn(this.config),n=this.config.fields;for(let r=0;r<n.length;r++){let i=n[r];t[i.name]=i.apply(e,this[i.name],this,t)}return t}get tr(){return new $n(this)}static create(e){let t=new Bn(e.doc?e.doc.type.schema:e.schema,e.plugins),n=new Fn(t);for(let r=0;r<t.fields.length;r++)n[t.fields[r].name]=t.fields[r].init(e,n);return n}reconfigure(e){let t=new Bn(this.schema,e.plugins),n=t.fields,r=new Fn(t);for(let t=0;t<n.length;t++){let i=n[t].name;r[i]=this.hasOwnProperty(i)?this[i]:n[t].init(e,r)}return r}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map((e=>e.toJSON()))),e&&"object"==typeof e)for(let n in e){if("doc"==n||"selection"==n)throw new RangeError("The JSON fields `doc` and `selection` are reserved");let r=e[n],i=r.spec.state;i&&i.toJSON&&(t[n]=i.toJSON.call(r,this[r.key]))}return t}static fromJSON(e,t,n){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let r=new Bn(e.schema,e.plugins),i=new Fn(r);return r.fields.forEach((r=>{if("doc"==r.name)i.doc=nt.fromJSON(e.schema,t.doc);else if("selection"==r.name)i.selection=bn.fromJSON(i.doc,t.selection);else if("storedMarks"==r.name)t.storedMarks&&(i.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(n)for(let s in n){let o=n[s],a=o.spec.state;if(o.key==r.name&&a&&a.fromJSON&&Object.prototype.hasOwnProperty.call(t,s))return void(i[r.name]=a.fromJSON.call(o,e,t[s],i))}i[r.name]=r.init(e,i)}})),i}}function Ln(e,t,n){for(let r in e){let i=e[r];i instanceof Function?i=i.bind(t):"handleDOMEvents"==r&&(i=Ln(i,t,{})),n[r]=i}return n}class zn{constructor(e){this.spec=e,this.props={},e.props&&Ln(e.props,this,this.props),this.key=e.key?e.key.key:jn("plugin")}getState(e){return e[this.key]}}const Vn=Object.create(null);function jn(e){return e in Vn?e+"$"+ ++Vn[e]:(Vn[e]=0,e+"$")}class _n{constructor(e="key"){this.key=jn(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Wn=function(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t},Hn=function(e){let t=e.assignedSlot||e.parentNode;return t&&11==t.nodeType?t.host:t};let Kn=null;const qn=function(e,t,n){let r=Kn||(Kn=document.createRange());return r.setEnd(e,null==n?e.nodeValue.length:n),r.setStart(e,t||0),r},Jn=function(e,t,n,r){return n&&(Gn(e,t,n,r,-1)||Gn(e,t,n,r,1))},Un=/^(img|br|input|textarea|hr)$/i;function Gn(e,t,n,r,i){for(;;){if(e==n&&t==r)return!0;if(t==(i<0?0:Yn(e))){let n=e.parentNode;if(!n||1!=n.nodeType||Xn(e)||Un.test(e.nodeName)||"false"==e.contentEditable)return!1;t=Wn(e)+(i<0?0:1),e=n}else{if(1!=e.nodeType)return!1;if("false"==(e=e.childNodes[t+(i<0?-1:0)]).contentEditable)return!1;t=i<0?Yn(e):0}}}function Yn(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function Xn(e){let t;for(let n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}const Zn=function(e){return e.focusNode&&Jn(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function Qn(e,t){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}const er="undefined"!=typeof navigator?navigator:null,tr="undefined"!=typeof document?document:null,nr=er&&er.userAgent||"",rr=/Edge\/(\d+)/.exec(nr),ir=/MSIE \d/.exec(nr),sr=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(nr),or=!!(ir||sr||rr),ar=ir?document.documentMode:sr?+sr[1]:rr?+rr[1]:0,lr=!or&&/gecko\/(\d+)/i.test(nr);lr&&(/Firefox\/(\d+)/.exec(nr)||[0,0])[1];const cr=!or&&/Chrome\/(\d+)/.exec(nr),hr=!!cr,dr=cr?+cr[1]:0,ur=!or&&!!er&&/Apple Computer/.test(er.vendor),pr=ur&&(/Mobile\/\w+/.test(nr)||!!er&&er.maxTouchPoints>2),fr=pr||!!er&&/Mac/.test(er.platform),mr=/Android \d/.test(nr),gr=!!tr&&"webkitFontSmoothing"in tr.documentElement.style,yr=gr?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function vr(e){return{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function wr(e,t){return"number"==typeof e?e:e[t]}function br(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,r=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*r}}function xr(e,t,n){let r=e.someProp("scrollThreshold")||0,i=e.someProp("scrollMargin")||5,s=e.dom.ownerDocument;for(let o=n||e.dom;o;o=Hn(o)){if(1!=o.nodeType)continue;let e=o,n=e==s.body,a=n?vr(s):br(e),l=0,c=0;if(t.top<a.top+wr(r,"top")?c=-(a.top-t.top+wr(i,"top")):t.bottom>a.bottom-wr(r,"bottom")&&(c=t.bottom-a.bottom+wr(i,"bottom")),t.left<a.left+wr(r,"left")?l=-(a.left-t.left+wr(i,"left")):t.right>a.right-wr(r,"right")&&(l=t.right-a.right+wr(i,"right")),l||c)if(n)s.defaultView.scrollBy(l,c);else{let n=e.scrollLeft,r=e.scrollTop;c&&(e.scrollTop+=c),l&&(e.scrollLeft+=l);let i=e.scrollLeft-n,s=e.scrollTop-r;t={left:t.left-i,top:t.top-s,right:t.right-i,bottom:t.bottom-s}}if(n)break}}function kr(e){let t=[],n=e.ownerDocument;for(let r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=Hn(r));return t}function Sr(e,t){for(let n=0;n<e.length;n++){let{dom:r,top:i,left:s}=e[n];r.scrollTop!=i+t&&(r.scrollTop=i+t),r.scrollLeft!=s&&(r.scrollLeft=s)}}let Mr=null;function Or(e,t){let n,r,i=2e8,s=0,o=t.top,a=t.top;for(let l=e.firstChild,c=0;l;l=l.nextSibling,c++){let e;if(1==l.nodeType)e=l.getClientRects();else{if(3!=l.nodeType)continue;e=qn(l).getClientRects()}for(let h=0;h<e.length;h++){let d=e[h];if(d.top<=o&&d.bottom>=a){o=Math.max(d.bottom,o),a=Math.min(d.top,a);let e=d.left>t.left?d.left-t.left:d.right<t.left?t.left-d.right:0;if(e<i){n=l,i=e,r=e&&3==n.nodeType?{left:d.right<t.left?d.right:d.left,top:t.top}:t,1==l.nodeType&&e&&(s=c+(t.left>=(d.left+d.right)/2?1:0));continue}}!n&&(t.left>=d.right&&t.top>=d.top||t.left>=d.left&&t.top>=d.bottom)&&(s=c+1)}}return n&&3==n.nodeType?function(e,t){let n=e.nodeValue.length,r=document.createRange();for(let i=0;i<n;i++){r.setEnd(e,i+1),r.setStart(e,i);let n=Tr(r,1);if(n.top!=n.bottom&&Cr(t,n))return{node:e,offset:i+(t.left>=(n.left+n.right)/2?1:0)}}return{node:e,offset:0}}(n,r):!n||i&&1==n.nodeType?{node:e,offset:s}:Or(n,r)}function Cr(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function Ar(e,t,n){let r=e.childNodes.length;if(r&&n.top<n.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(t.top-n.top)/(n.bottom-n.top))-2)),s=i;;){let n=e.childNodes[s];if(1==n.nodeType){let e=n.getClientRects();for(let r=0;r<e.length;r++){let i=e[r];if(Cr(t,i))return Ar(n,t,i)}}if((s=(s+1)%r)==i)break}return e}function Er(e,t){let n,r=e.dom.ownerDocument,i=0;if(r.caretPositionFromPoint)try{let e=r.caretPositionFromPoint(t.left,t.top);e&&({offsetNode:n,offset:i}=e)}catch(e){}if(!n&&r.caretRangeFromPoint){let e=r.caretRangeFromPoint(t.left,t.top);e&&({startContainer:n,startOffset:i}=e)}let s,o=(e.root.elementFromPoint?e.root:r).elementFromPoint(t.left,t.top);if(!o||!e.dom.contains(1!=o.nodeType?o.parentNode:o)){let n=e.dom.getBoundingClientRect();if(!Cr(t,n))return null;if(o=Ar(e.dom,t,n),!o)return null}if(ur)for(let e=o;n&&e;e=Hn(e))e.draggable&&(n=void 0);if(o=function(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}(o,t),n){if(lr&&1==n.nodeType&&(i=Math.min(i,n.childNodes.length),i<n.childNodes.length)){let e,r=n.childNodes[i];"IMG"==r.nodeName&&(e=r.getBoundingClientRect()).right<=t.left&&e.bottom>t.top&&i++}n==e.dom&&i==n.childNodes.length-1&&1==n.lastChild.nodeType&&t.top>n.lastChild.getBoundingClientRect().bottom?s=e.state.doc.content.size:0!=i&&1==n.nodeType&&"BR"==n.childNodes[i-1].nodeName||(s=function(e,t,n,r){let i=-1;for(let n=t;n!=e.dom;){let t=e.docView.nearestDesc(n,!0);if(!t)return null;if(t.node.isBlock&&t.parent){let e=t.dom.getBoundingClientRect();if(e.left>r.left||e.top>r.top)i=t.posBefore;else{if(!(e.right<r.left||e.bottom<r.top))break;i=t.posAfter}}n=t.dom.parentNode}return i>-1?i:e.docView.posFromDOM(t,n,1)}(e,n,i,t))}null==s&&(s=function(e,t,n){let{node:r,offset:i}=Or(t,n),s=-1;if(1==r.nodeType&&!r.firstChild){let e=r.getBoundingClientRect();s=e.left!=e.right&&n.left>(e.left+e.right)/2?1:-1}return e.docView.posFromDOM(r,i,s)}(e,o,t));let a=e.docView.nearestDesc(o,!0);return{pos:s,inside:a?a.posAtStart-a.border:-1}}function Tr(e,t){let n=e.getClientRects();return n.length?n[t<0?0:n.length-1]:e.getBoundingClientRect()}const Nr=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Dr(e,t,n){let{node:r,offset:i,atom:s}=e.docView.domFromPos(t,n<0?-1:1),o=gr||lr;if(3==r.nodeType){if(!o||!Nr.test(r.nodeValue)&&(n<0?i:i!=r.nodeValue.length)){let e=i,t=i,s=n<0?1:-1;return n<0&&!i?(t++,s=-1):n>=0&&i==r.nodeValue.length?(e--,s=1):n<0?e--:t++,$r(Tr(qn(r,e,t),1),s<0)}{let e=Tr(qn(r,i,i),n);if(lr&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let t=Tr(qn(r,i-1,i-1),-1);if(t.top==e.top){let n=Tr(qn(r,i,i+1),-1);if(n.top!=e.top)return $r(n,n.left<t.left)}}return e}}if(!e.state.doc.resolve(t-(s||0)).parent.inlineContent){if(null==s&&i&&(n<0||i==Yn(r))){let e=r.childNodes[i-1];if(1==e.nodeType)return Ir(e.getBoundingClientRect(),!1)}if(null==s&&i<Yn(r)){let e=r.childNodes[i];if(1==e.nodeType)return Ir(e.getBoundingClientRect(),!0)}return Ir(r.getBoundingClientRect(),n>=0)}if(null==s&&i&&(n<0||i==Yn(r))){let e=r.childNodes[i-1],t=3==e.nodeType?qn(e,Yn(e)-(o?0:1)):1!=e.nodeType||"BR"==e.nodeName&&e.nextSibling?null:e;if(t)return $r(Tr(t,1),!1)}if(null==s&&i<Yn(r)){let e=r.childNodes[i];for(;e.pmViewDesc&&e.pmViewDesc.ignoreForCoords;)e=e.nextSibling;let t=e?3==e.nodeType?qn(e,0,o?0:1):1==e.nodeType?e:null:null;if(t)return $r(Tr(t,-1),!0)}return $r(Tr(3==r.nodeType?qn(r):r,-n),n>=0)}function $r(e,t){if(0==e.width)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function Ir(e,t){if(0==e.height)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function Rr(e,t,n){let r=e.state,i=e.root.activeElement;r!=t&&e.updateState(t),i!=e.dom&&e.focus();try{return n()}finally{r!=t&&e.updateState(r),i!=e.dom&&i&&i.focus()}}const Pr=/[\u0590-\u08ac]/;let Br=null,Fr=null,Lr=!1;function zr(e,t,n){return Br==t&&Fr==n?Lr:(Br=t,Fr=n,Lr="up"==n||"down"==n?function(e,t,n){let r=t.selection,i="up"==n?r.$from:r.$to;return Rr(e,t,(()=>{let{node:t}=e.docView.domFromPos(i.pos,"up"==n?-1:1);for(;;){let n=e.docView.nearestDesc(t,!0);if(!n)break;if(n.node.isBlock){t=n.dom;break}t=n.dom.parentNode}let r=Dr(e,i.pos,1);for(let e=t.firstChild;e;e=e.nextSibling){let t;if(1==e.nodeType)t=e.getClientRects();else{if(3!=e.nodeType)continue;t=qn(e,0,e.nodeValue.length).getClientRects()}for(let e=0;e<t.length;e++){let i=t[e];if(i.bottom>i.top+1&&("up"==n?r.top-i.top>2*(i.bottom-r.top):i.bottom-r.bottom>2*(r.bottom-i.top)))return!1}}return!0}))}(e,t,n):function(e,t,n){let{$head:r}=t.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,s=!i,o=i==r.parent.content.size,a=e.domSelection();return Pr.test(r.parent.textContent)&&a.modify?Rr(e,t,(()=>{let{focusNode:t,focusOffset:i,anchorNode:s,anchorOffset:o}=e.domSelectionRange(),l=a.caretBidiLevel;a.modify("move",n,"character");let c=r.depth?e.docView.domAfterPos(r.before()):e.dom,{focusNode:h,focusOffset:d}=e.domSelectionRange(),u=h&&!c.contains(1==h.nodeType?h:h.parentNode)||t==h&&i==d;try{a.collapse(s,o),t&&(t!=s||i!=o)&&a.extend&&a.extend(t,i)}catch(e){}return null!=l&&(a.caretBidiLevel=l),u})):"left"==n||"backward"==n?s:o}(e,t,n))}class Vr{constructor(e,t,n,r){this.parent=e,this.children=t,this.dom=n,this.contentDOM=r,this.dirty=0,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,n=this.posAtStart;;t++){let r=this.children[t];if(r==e)return n;n+=r.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,n){if(this.contentDOM&&this.contentDOM.contains(1==e.nodeType?e:e.parentNode)){if(n<0){let n,r;if(e==this.contentDOM)n=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.previousSibling}for(;n&&(!(r=n.pmViewDesc)||r.parent!=this);)n=n.previousSibling;return n?this.posBeforeChild(r)+r.size:this.posAtStart}{let n,r;if(e==this.contentDOM)n=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.nextSibling}for(;n&&(!(r=n.pmViewDesc)||r.parent!=this);)n=n.nextSibling;return n?this.posBeforeChild(r):this.posAtEnd}}let r;if(e==this.dom&&this.contentDOM)r=t>Wn(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))r=2&e.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==t)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!1;break}if(t.previousSibling)break}if(null==r&&t==e.childNodes.length)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!0;break}if(t.nextSibling)break}}return(null==r?n>0:r)?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,r=e;r;r=r.parentNode){let i,s=this.getDesc(r);if(s&&(!t||s.node)){if(!n||!(i=s.nodeDOM)||(1==i.nodeType?i.contains(1==e.nodeType?e:e.parentNode):i==e))return s;n=!1}}}getDesc(e){let t=e.pmViewDesc;for(let e=t;e;e=e.parent)if(e==this)return t}posFromDOM(e,t,n){for(let r=e;r;r=r.parentNode){let i=this.getDesc(r);if(i)return i.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let r=this.children[t],i=n+r.size;if(n==e&&i!=n){for(;!r.border&&r.children.length;)r=r.children[0];return r}if(e<i)return r.descAt(e-n-r.border);n=i}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n,r=0,i=0;for(let t=0;r<this.children.length;r++){let n=this.children[r],s=t+n.size;if(s>e||n instanceof Jr){i=e-t;break}t=s}if(i)return this.children[r].domFromPos(i-this.children[r].border,t);for(;r&&!(n=this.children[r-1]).size&&n instanceof jr&&n.side>=0;r--);if(t<=0){let e,n=!0;for(;e=r?this.children[r-1]:null,e&&e.dom.parentNode!=this.contentDOM;r--,n=!1);return e&&t&&n&&!e.border&&!e.domAtom?e.domFromPos(e.size,t):{node:this.contentDOM,offset:e?Wn(e.dom)+1:0}}{let e,n=!0;for(;e=r<this.children.length?this.children[r]:null,e&&e.dom.parentNode!=this.contentDOM;r++,n=!1);return e&&n&&!e.border&&!e.domAtom?e.domFromPos(0,t):{node:this.contentDOM,offset:e?Wn(e.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,n=0){if(0==this.children.length)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let r=-1,i=-1;for(let s=n,o=0;;o++){let n=this.children[o],a=s+n.size;if(-1==r&&e<=a){let i=s+n.border;if(e>=i&&t<=a-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(e,t,i);e=s;for(let t=o;t>0;t--){let n=this.children[t-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){r=Wn(n.dom)+1;break}e-=n.size}-1==r&&(r=0)}if(r>-1&&(a>t||o==this.children.length-1)){t=a;for(let e=o+1;e<this.children.length;e++){let n=this.children[e];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(-1)){i=Wn(n.dom);break}t+=n.size}-1==i&&(i=this.contentDOM.childNodes.length);break}s=a}return{node:this.contentDOM,from:e,to:t,fromOffset:r,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return 0==t.size||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:n}=this.domFromPos(e,0);if(1!=t.nodeType||n==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[n]}setSelection(e,t,n,r=!1){let i=Math.min(e,t),s=Math.max(e,t);for(let o=0,a=0;o<this.children.length;o++){let l=this.children[o],c=a+l.size;if(i>a&&s<c)return l.setSelection(e-a-l.border,t-a-l.border,n,r);a=c}let o=this.domFromPos(e,e?-1:1),a=t==e?o:this.domFromPos(t,t?-1:1),l=n.getSelection(),c=!1;if((lr||ur)&&e==t){let{node:e,offset:t}=o;if(3==e.nodeType){if(c=!(!t||"\n"!=e.nodeValue[t-1]),c&&t==e.nodeValue.length)for(let t,n=e;n;n=n.parentNode){if(t=n.nextSibling){"BR"==t.nodeName&&(o=a={node:t.parentNode,offset:Wn(t)+1});break}let e=n.pmViewDesc;if(e&&e.node&&e.node.isBlock)break}}else{let n=e.childNodes[t-1];c=n&&("BR"==n.nodeName||"false"==n.contentEditable)}}if(lr&&l.focusNode&&l.focusNode!=a.node&&1==l.focusNode.nodeType){let e=l.focusNode.childNodes[l.focusOffset];e&&"false"==e.contentEditable&&(r=!0)}if(!(r||c&&ur)&&Jn(o.node,o.offset,l.anchorNode,l.anchorOffset)&&Jn(a.node,a.offset,l.focusNode,l.focusOffset))return;let h=!1;if((l.extend||e==t)&&!c){l.collapse(o.node,o.offset);try{e!=t&&l.extend(a.node,a.offset),h=!0}catch(e){}}if(!h){if(e>t){let e=o;o=a,a=e}let n=document.createRange();n.setEnd(a.node,a.offset),n.setStart(o.node,o.offset),l.removeAllRanges(),l.addRange(n)}}ignoreMutation(e){return!this.contentDOM&&"selection"!=e.type}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,r=0;r<this.children.length;r++){let i=this.children[r],s=n+i.size;if(n==s?e<=s&&t>=n:e<s&&t>n){let r=n+i.border,o=s-i.border;if(e>=r&&t<=o)return this.dirty=e==n||t==s?2:1,void(e!=r||t!=o||!i.contentLost&&i.dom.parentNode==this.contentDOM?i.markDirty(e-r,t-r):i.dirty=3);i.dirty=i.dom!=i.contentDOM||i.dom.parentNode!=this.contentDOM||i.children.length?3:2}n=s}this.dirty=2}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=1==e?2:1;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}}class jr extends Vr{constructor(e,t,n,r){let i,s=t.type.toDOM;if("function"==typeof s&&(s=s(n,(()=>i?i.parent?i.parent.posBeforeChild(i):void 0:r))),!t.type.spec.raw){if(1!=s.nodeType){let e=document.createElement("span");e.appendChild(s),s=e}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return 0==this.dirty&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return!!t&&t(e)}ignoreMutation(e){return"selection"!=e.type||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}}class _r extends Vr{constructor(e,t,n,r){super(e,[],t,null),this.textDOM=n,this.text=r}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"characterData"===e.type&&e.target.nodeValue==e.oldValue}}class Wr extends Vr{constructor(e,t,n,r){super(e,[],n,r),this.mark=t}static create(e,t,n,r){let i=r.nodeViews[t.type.name],s=i&&i(t,r,n);return s&&s.dom||(s=$t.renderSpec(document,t.type.spec.toDOM(t,n))),new Wr(e,t,s.dom,s.contentDOM||s.dom)}parseRule(){return 3&this.dirty||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM||void 0}}matchesMark(e){return 3!=this.dirty&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),0!=this.dirty){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty<this.dirty&&(e.dirty=this.dirty),this.dirty=0}}slice(e,t,n){let r=Wr.create(this.parent,this.mark,!0,n),i=this.children,s=this.size;t<s&&(i=oi(i,t,s,n)),e>0&&(i=oi(i,0,e,n));for(let e=0;e<i.length;e++)i[e].parent=r;return r.children=i,r}}class Hr extends Vr{constructor(e,t,n,r,i,s,o,a,l){super(e,[],i,s),this.node=t,this.outerDeco=n,this.innerDeco=r,this.nodeDOM=o,s&&this.updateChildren(a,l)}static create(e,t,n,r,i,s){let o,a=i.nodeViews[t.type.name],l=a&&a(t,i,(()=>o?o.parent?o.parent.posBeforeChild(o):void 0:s),n,r),c=l&&l.dom,h=l&&l.contentDOM;if(t.isText)if(c){if(3!=c.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else c=document.createTextNode(t.text);else c||({dom:c,contentDOM:h}=$t.renderSpec(document,t.type.spec.toDOM(t)));h||t.isText||"BR"==c.nodeName||(c.hasAttribute("contenteditable")||(c.contentEditable="false"),t.type.spec.draggable&&(c.draggable=!0));let d=c;return c=ti(c,n,t),l?o=new Ur(e,t,n,r,c,h||null,d,l,i,s+1):t.isText?new qr(e,t,n,r,c,d,i):new Hr(e,t,n,r,c,h||null,d,i,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(e.preserveWhitespace="full"),this.contentDOM)if(this.contentLost){for(let t=this.children.length-1;t>=0;t--){let n=this.children[t];if(this.dom.contains(n.dom.parentNode)){e.contentElement=n.dom.parentNode;break}}e.contentElement||(e.getContent=()=>$e.empty)}else e.contentElement=this.contentDOM;else e.getContent=()=>this.node.content;return e}matchesNode(e,t,n){return 0==this.dirty&&e.eq(this.node)&&ni(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let n=this.node.inlineContent,r=t,i=e.composing?this.localCompositionInfo(e,t):null,s=i&&i.pos>-1?i:null,o=i&&i.pos<0,a=new ii(this,s&&s.node,e);!function(e,t,n,r){let i=t.locals(e),s=0;if(0==i.length){for(let n=0;n<e.childCount;n++){let o=e.child(n);r(o,i,t.forChild(s,o),n),s+=o.nodeSize}return}let o=0,a=[],l=null;for(let c=0;;){if(o<i.length&&i[o].to==s){let e,t=i[o++];for(;o<i.length&&i[o].to==s;)(e||(e=[t])).push(i[o++]);if(e){e.sort(si);for(let t=0;t<e.length;t++)n(e[t],c,!!l)}else n(t,c,!!l)}let h,d;if(l)d=-1,h=l,l=null;else{if(!(c<e.childCount))break;d=c,h=e.child(c++)}for(let e=0;e<a.length;e++)a[e].to<=s&&a.splice(e--,1);for(;o<i.length&&i[o].from<=s&&i[o].to>s;)a.push(i[o++]);let u=s+h.nodeSize;if(h.isText){let e=u;o<i.length&&i[o].from<e&&(e=i[o].from);for(let t=0;t<a.length;t++)a[t].to<e&&(e=a[t].to);e<u&&(l=h.cut(e-s),h=h.cut(0,e-s),u=e,d=-1)}let p=h.isInline&&!h.isLeaf?a.filter((e=>!e.inline)):a.slice();r(h,p,t.forChild(s,h),d),s=u}}(this.node,this.innerDeco,((t,i,s)=>{t.spec.marks?a.syncToMarks(t.spec.marks,n,e):t.type.side>=0&&!s&&a.syncToMarks(i==this.node.childCount?Be.none:this.node.child(i).marks,n,e),a.placeWidget(t,e,r)}),((t,s,l,c)=>{let h;a.syncToMarks(t.marks,n,e),a.findNodeMatch(t,s,l,c)||o&&e.state.selection.from>r&&e.state.selection.to<r+t.nodeSize&&(h=a.findIndexWithChild(i.node))>-1&&a.updateNodeAt(t,s,l,h,e)||a.updateNextNode(t,s,l,e,c)||a.addNode(t,s,l,e,r),r+=t.nodeSize})),a.syncToMarks([],n,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||2==this.dirty)&&(s&&this.protectLocalComposition(e,s),Gr(this.contentDOM,this.children,e),pr&&function(e){if("UL"==e.nodeName||"OL"==e.nodeName){let t=e.style.cssText;e.style.cssText=t+"; list-style: square !important",window.getComputedStyle(e).listStyle,e.style.cssText=t}}(this.dom))}localCompositionInfo(e,t){let{from:n,to:r}=e.state.selection;if(!(e.state.selection instanceof Mn)||n<t||r>t+this.node.content.size)return null;let i=e.domSelectionRange(),s=function(e,t){for(;;){if(3==e.nodeType)return e;if(1==e.nodeType&&t>0){if(e.childNodes.length>t&&3==e.childNodes[t].nodeType)return e.childNodes[t];t=Yn(e=e.childNodes[t-1])}else{if(!(1==e.nodeType&&t<e.childNodes.length))return null;e=e.childNodes[t],t=0}}}(i.focusNode,i.focusOffset);if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let e=s.nodeValue,i=function(e,t,n,r){for(let i=0,s=0;i<e.childCount&&s<=r;){let o=e.child(i++),a=s;if(s+=o.nodeSize,!o.isText)continue;let l=o.text;for(;i<e.childCount;){let t=e.child(i++);if(s+=t.nodeSize,!t.isText)break;l+=t.text}if(s>=n){let e=a<r?l.lastIndexOf(t,r-a-1):-1;if(e>=0&&e+t.length+a>=n)return a+e;if(n==r&&l.length>=r+t.length-a&&l.slice(r-a,r-a+t.length)==t)return r}}return-1}(this.node.content,e,n-t,r-t);return i<0?null:{node:s,pos:i,text:e}}return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:n,text:r}){if(this.getDesc(t))return;let i=t;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let s=new _r(this,i,t,r);e.input.compositionNodes.push(s),this.children=oi(this.children,n,n+r.length,e,s)}update(e,t,n,r){return!(3==this.dirty||!e.sameMarkup(this.node))&&(this.updateInner(e,t,n,r),!0)}updateInner(e,t,n,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=0}updateOuterDeco(e){if(ni(e,this.outerDeco))return;let t=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=Qr(this.dom,this.nodeDOM,Zr(this.outerDeco,this.node,t),Zr(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){1==this.nodeDOM.nodeType&&this.nodeDOM.classList.add("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.dom.draggable=!0)}deselectNode(){1==this.nodeDOM.nodeType&&this.nodeDOM.classList.remove("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||this.dom.removeAttribute("draggable")}get domAtom(){return this.node.isAtom}}function Kr(e,t,n,r,i){return ti(r,t,e),new Hr(void 0,e,t,n,r,r,r,i,0)}class qr extends Hr{constructor(e,t,n,r,i,s,o){super(e,t,n,r,i,null,s,o,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,r){return!(3==this.dirty||0!=this.dirty&&!this.inParent()||!e.sameMarkup(this.node))&&(this.updateOuterDeco(t),0==this.dirty&&e.text==this.node.text||e.text==this.nodeDOM.nodeValue||(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=e,this.dirty=0,!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,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return"characterData"!=e.type&&"selection"!=e.type}slice(e,t,n){let r=this.node.cut(e,t),i=document.createTextNode(r.text);return new qr(this.parent,r,this.outerDeco,this.innerDeco,i,i,n)}markDirty(e,t){super.markDirty(e,t),this.dom==this.nodeDOM||0!=e&&t!=this.nodeDOM.nodeValue.length||(this.dirty=3)}get domAtom(){return!1}}class Jr extends Vr{parseRule(){return{ignore:!0}}matchesHack(e){return 0==this.dirty&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return"IMG"==this.dom.nodeName}}class Ur extends Hr{constructor(e,t,n,r,i,s,o,a,l,c){super(e,t,n,r,i,s,o,l,c),this.spec=a}update(e,t,n,r){if(3==this.dirty)return!1;if(this.spec.update){let i=this.spec.update(e,t,n);return i&&this.updateInner(e,t,n,r),i}return!(!this.contentDOM&&!e.isLeaf)&&super.update(e,t,n,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,r){this.spec.setSelection?this.spec.setSelection(e,t,n):super.setSelection(e,t,n,r)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return!!this.spec.stopEvent&&this.spec.stopEvent(e)}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function Gr(e,t,n){let r=e.firstChild,i=!1;for(let s=0;s<t.length;s++){let o=t[s],a=o.dom;if(a.parentNode==e){for(;a!=r;)r=ri(r),i=!0;r=r.nextSibling}else i=!0,e.insertBefore(a,r);if(o instanceof Wr){let t=r?r.previousSibling:e.lastChild;Gr(o.contentDOM,o.children,n),r=t?t.nextSibling:e.firstChild}}for(;r;)r=ri(r),i=!0;i&&n.trackWrites==e&&(n.trackWrites=null)}const Yr=function(e){e&&(this.nodeName=e)};Yr.prototype=Object.create(null);const Xr=[new Yr];function Zr(e,t,n){if(0==e.length)return Xr;let r=n?Xr[0]:new Yr,i=[r];for(let s=0;s<e.length;s++){let o=e[s].type.attrs;if(o){o.nodeName&&i.push(r=new Yr(o.nodeName));for(let e in o){let s=o[e];null!=s&&(n&&1==i.length&&i.push(r=new Yr(t.isInline?"span":"div")),"class"==e?r.class=(r.class?r.class+" ":"")+s:"style"==e?r.style=(r.style?r.style+";":"")+s:"nodeName"!=e&&(r[e]=s))}}}return i}function Qr(e,t,n,r){if(n==Xr&&r==Xr)return t;let i=t;for(let t=0;t<r.length;t++){let s=r[t],o=n[t];if(t){let t;o&&o.nodeName==s.nodeName&&i!=e&&(t=i.parentNode)&&t.nodeName.toLowerCase()==s.nodeName||(t=document.createElement(s.nodeName),t.pmIsDeco=!0,t.appendChild(i),o=Xr[0]),i=t}ei(i,o||Xr[0],s)}return i}function ei(e,t,n){for(let r in t)"class"==r||"style"==r||"nodeName"==r||r in n||e.removeAttribute(r);for(let r in n)"class"!=r&&"style"!=r&&"nodeName"!=r&&n[r]!=t[r]&&e.setAttribute(r,n[r]);if(t.class!=n.class){let r=t.class?t.class.split(" ").filter(Boolean):[],i=n.class?n.class.split(" ").filter(Boolean):[];for(let t=0;t<r.length;t++)-1==i.indexOf(r[t])&&e.classList.remove(r[t]);for(let t=0;t<i.length;t++)-1==r.indexOf(i[t])&&e.classList.add(i[t]);0==e.classList.length&&e.removeAttribute("class")}if(t.style!=n.style){if(t.style){let n,r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;for(;n=r.exec(t.style);)e.style.removeProperty(n[1])}n.style&&(e.style.cssText+=n.style)}}function ti(e,t,n){return Qr(e,e,Xr,Zr(t,n,1!=e.nodeType))}function ni(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].type.eq(t[n].type))return!1;return!0}function ri(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}class ii{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=function(e,t){let n=t,r=n.children.length,i=e.childCount,s=new Map,o=[];e:for(;i>0;){let a;for(;;)if(r){let e=n.children[r-1];if(!(e instanceof Wr)){a=e,r--;break}n=e,r=e.children.length}else{if(n==t)break e;r=n.parent.children.indexOf(n),n=n.parent}let l=a.node;if(l){if(l!=e.child(i-1))break;--i,s.set(a,i),o.push(a)}}return{index:i,matched:s,matches:o.reverse()}}(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,n){let r=0,i=this.stack.length>>1,s=Math.min(i,e.length);for(;r<s&&(r==i-1?this.top:this.stack[r+1<<1]).matchesMark(e[r])&&!1!==e[r].type.spec.spanning;)r++;for(;r<i;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),i--;for(;i<e.length;){this.stack.push(this.top,this.index+1);let r=-1;for(let t=this.index;t<Math.min(this.index+3,this.top.children.length);t++)if(this.top.children[t].matchesMark(e[i])){r=t;break}if(r>-1)r>this.index&&(this.changed=!0,this.destroyBetween(this.index,r)),this.top=this.top.children[this.index];else{let r=Wr.create(this.top,e[i],t,n);this.top.children.splice(this.index,0,r),this.top=r,this.changed=!0}this.index=0,i++}}findNodeMatch(e,t,n,r){let i,s=-1;if(r>=this.preMatch.index&&(i=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&i.matchesNode(e,t,n))s=this.top.children.indexOf(i,this.index);else for(let r=this.index,i=Math.min(this.top.children.length,r+5);r<i;r++){let i=this.top.children[r];if(i.matchesNode(e,t,n)&&!this.preMatch.matched.has(i)){s=r;break}}return!(s<0)&&(this.destroyBetween(this.index,s),this.index++,!0)}updateNodeAt(e,t,n,r,i){let s=this.top.children[r];return 3==s.dirty&&s.dom==s.contentDOM&&(s.dirty=2),!!s.update(e,t,n,i)&&(this.destroyBetween(this.index,r),this.index++,!0)}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let t=e.pmViewDesc;if(t)for(let e=this.index;e<this.top.children.length;e++)if(this.top.children[e]==t)return e;return-1}e=t}}updateNextNode(e,t,n,r,i){for(let s=this.index;s<this.top.children.length;s++){let o=this.top.children[s];if(o instanceof Hr){let a=this.preMatch.matched.get(o);if(null!=a&&a!=i)return!1;let l=o.dom;if(!(this.lock&&(l==this.lock||1==l.nodeType&&l.contains(this.lock.parentNode))&&!(e.isText&&o.node&&o.node.isText&&o.nodeDOM.nodeValue==e.text&&3!=o.dirty&&ni(t,o.outerDeco)))&&o.update(e,t,n,r))return this.destroyBetween(this.index,s),o.dom!=l&&(this.changed=!0),this.index++,!0;break}}return!1}addNode(e,t,n,r,i){this.top.children.splice(this.index++,0,Hr.create(this.top,e,t,n,r,i)),this.changed=!0}placeWidget(e,t,n){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(!r||!r.matchesWidget(e)||e!=r.widget&&r.widget.type.toDOM.parentNode){let r=new jr(this.top,e,t,n);this.top.children.splice(this.index++,0,r),this.changed=!0}else this.index++}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Wr;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof qr)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((ur||hr)&&e&&"false"==e.dom.contentEditable&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let n=document.createElement(e);"IMG"==e&&(n.className="ProseMirror-separator",n.alt=""),"BR"==e&&(n.className="ProseMirror-trailingBreak");let r=new Jr(this.top,[],n,null);t!=this.top?t.children.push(r):t.children.splice(this.index++,0,r),this.changed=!0}}}function si(e,t){return e.type.side-t.type.side}function oi(e,t,n,r,i){let s=[];for(let o=0,a=0;o<e.length;o++){let l=e[o],c=a,h=a+=l.size;c>=n||h<=t?s.push(l):(c<t&&s.push(l.slice(0,t-c,r)),i&&(s.push(i),i=void 0),h>n&&s.push(l.slice(n-c,l.size,r)))}return s}function ai(e,t=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let i=e.docView.nearestDesc(n.focusNode),s=i&&0==i.size,o=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let a,l,c=r.resolve(o);if(Zn(n)){for(a=c;i&&!i.node;)i=i.parent;let e=i.node;if(i&&e.isAtom&&Cn.isSelectable(e)&&i.parent&&(!e.isInline||!function(e,t,n){for(let r=0==t,i=t==Yn(e);r||i;){if(e==n)return!0;let t=Wn(e);if(!(e=e.parentNode))return!1;r=r&&0==t,i=i&&t==Yn(e)}}(n.focusNode,n.focusOffset,i.dom))){let e=i.posBefore;l=new Cn(o==e?c:r.resolve(e))}}else{let t=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(t<0)return null;a=r.resolve(t)}if(!l){l=gi(e,a,c,"pointer"==t||e.state.selection.head<c.pos&&!s?1:-1)}return l}function li(e){return e.editable?e.hasFocus():vi(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function ci(e,t=!1){let n=e.state.selection;if(fi(e,n),li(e)){if(!t&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&hr){let t=e.domSelectionRange(),n=e.domObserver.currentSelection;if(t.anchorNode&&n.anchorNode&&Jn(t.anchorNode,t.anchorOffset,n.anchorNode,n.anchorOffset))return e.input.mouseDown.delayedSelectionSync=!0,void e.domObserver.setCurSelection()}if(e.domObserver.disconnectSelection(),e.cursorWrapper)!function(e){let t=e.domSelection(),n=document.createRange(),r=e.cursorWrapper.dom,i="IMG"==r.nodeName;i?n.setEnd(r.parentNode,Wn(r)+1):n.setEnd(r,0);n.collapse(!1),t.removeAllRanges(),t.addRange(n),!i&&!e.state.selection.visible&&or&&ar<=11&&(r.disabled=!0,r.disabled=!1)}(e);else{let r,i,{anchor:s,head:o}=n;!hi||n instanceof Mn||(n.$from.parent.inlineContent||(r=di(e,n.from)),n.empty||n.$from.parent.inlineContent||(i=di(e,n.to))),e.docView.setSelection(s,o,e.root,t),hi&&(r&&pi(r),i&&pi(i)),n.visible?e.dom.classList.remove("ProseMirror-hideselection"):(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&function(e){let t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.input.hideSelectionGuard);let n=e.domSelectionRange(),r=n.anchorNode,i=n.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=()=>{n.anchorNode==r&&n.anchorOffset==i||(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout((()=>{li(e)&&!e.state.selection.visible||e.dom.classList.remove("ProseMirror-hideselection")}),20))})}(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}const hi=ur||hr&&dr<63;function di(e,t){let{node:n,offset:r}=e.docView.domFromPos(t,0),i=r<n.childNodes.length?n.childNodes[r]:null,s=r?n.childNodes[r-1]:null;if(ur&&i&&"false"==i.contentEditable)return ui(i);if(!(i&&"false"!=i.contentEditable||s&&"false"!=s.contentEditable)){if(i)return ui(i);if(s)return ui(s)}}function ui(e){return e.contentEditable="true",ur&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function pi(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function fi(e,t){if(t instanceof Cn){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(mi(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else mi(e)}function mi(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function gi(e,t,n,r){return e.someProp("createSelectionBetween",(r=>r(e,t,n)))||Mn.between(t,n,r)}function yi(e){return!(e.editable&&!e.hasFocus())&&vi(e)}function vi(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(3==t.anchorNode.nodeType?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(3==t.focusNode.nodeType?t.focusNode.parentNode:t.focusNode))}catch(e){return!1}}function wi(e,t){let{$anchor:n,$head:r}=e.selection,i=t>0?n.max(r):n.min(r),s=i.parent.inlineContent?i.depth?e.doc.resolve(t>0?i.after():i.before()):null:i;return s&&bn.findFrom(s,t)}function bi(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function xi(e,t,n){let r=e.state.selection;if(!(r instanceof Mn)){if(r instanceof Cn&&r.node.isInline)return bi(e,new Mn(t>0?r.$to:r.$from));{let n=wi(e.state,t);return!!n&&bi(e,n)}}if(!r.empty||n.indexOf("s")>-1)return!1;if(e.endOfTextblock(t>0?"right":"left")){let n=wi(e.state,t);return!!(n&&n instanceof Cn)&&bi(e,n)}if(!(fr&&n.indexOf("m")>-1)){let n,i=r.$head,s=i.textOffset?null:t<0?i.nodeBefore:i.nodeAfter;if(!s||s.isText)return!1;let o=t<0?i.pos-s.nodeSize:i.pos;return!!(s.isAtom||(n=e.docView.descAt(o))&&!n.contentDOM)&&(Cn.isSelectable(s)?bi(e,new Cn(t<0?e.state.doc.resolve(i.pos-s.nodeSize):i)):!!gr&&bi(e,new Mn(e.state.doc.resolve(t<0?o:o+s.nodeSize))))}}function ki(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function Si(e){let t=e.pmViewDesc;return t&&0==t.size&&(e.nextSibling||"BR"!=e.nodeName)}function Mi(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i,s,o=!1;for(lr&&1==n.nodeType&&r<ki(n)&&Si(n.childNodes[r])&&(o=!0);;)if(r>0){if(1!=n.nodeType)break;{let e=n.childNodes[r-1];if(Si(e))i=n,s=--r;else{if(3!=e.nodeType)break;n=e,r=n.nodeValue.length}}}else{if(Ci(n))break;{let t=n.previousSibling;for(;t&&Si(t);)i=n.parentNode,s=Wn(t),t=t.previousSibling;if(t)n=t,r=ki(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}}o?Ai(e,n,r):i&&Ai(e,i,s)}function Oi(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i,s,o=ki(n);for(;;)if(r<o){if(1!=n.nodeType)break;if(!Si(n.childNodes[r]))break;i=n,s=++r}else{if(Ci(n))break;{let t=n.nextSibling;for(;t&&Si(t);)i=t.parentNode,s=Wn(t)+1,t=t.nextSibling;if(t)n=t,r=0,o=ki(n);else{if(n=n.parentNode,n==e.dom)break;r=o=0}}}i&&Ai(e,i,s)}function Ci(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function Ai(e,t,n){let r=e.domSelection();if(Zn(r)){let e=document.createRange();e.setEnd(t,n),e.setStart(t,n),r.removeAllRanges(),r.addRange(e)}else r.extend&&r.extend(t,n);e.domObserver.setCurSelection();let{state:i}=e;setTimeout((()=>{e.state==i&&ci(e)}),50)}function Ei(e,t,n){let r=e.state.selection;if(r instanceof Mn&&!r.empty||n.indexOf("s")>-1)return!1;if(fr&&n.indexOf("m")>-1)return!1;let{$from:i,$to:s}=r;if(!i.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let n=wi(e.state,t);if(n&&n instanceof Cn)return bi(e,n)}if(!i.parent.inlineContent){let n=t<0?i:s,o=r instanceof En?bn.near(n,t):bn.findFrom(n,t);return!!o&&bi(e,o)}return!1}function Ti(e,t){if(!(e.state.selection instanceof Mn))return!0;let{$head:n,$anchor:r,empty:i}=e.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;let s=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(s&&!s.isText){let r=e.state.tr;return t<0?r.delete(n.pos-s.nodeSize,n.pos):r.delete(n.pos,n.pos+s.nodeSize),e.dispatch(r),!0}return!1}function Ni(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function Di(e,t){let n=t.keyCode,r=function(e){let t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}(t);return 8==n||fr&&72==n&&"c"==r?Ti(e,-1)||Mi(e):46==n||fr&&68==n&&"c"==r?Ti(e,1)||Oi(e):13==n||27==n||(37==n||fr&&66==n&&"c"==r?xi(e,-1,r)||Mi(e):39==n||fr&&70==n&&"c"==r?xi(e,1,r)||Oi(e):38==n||fr&&80==n&&"c"==r?Ei(e,-1,r)||Mi(e):40==n||fr&&78==n&&"c"==r?function(e){if(!ur||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&1==t.nodeType&&0==n&&t.firstChild&&"false"==t.firstChild.contentEditable){let n=t.firstChild;Ni(e,n,"true"),setTimeout((()=>Ni(e,n,"false")),20)}return!1}(e)||Ei(e,1,r)||Oi(e):r==(fr?"m":"c")&&(66==n||73==n||89==n||90==n))}function $i(e,t){e.someProp("transformCopied",(e=>{t=e(t)}));let n=[],{content:r,openStart:i,openEnd:s}=t;for(;i>1&&s>1&&1==r.childCount&&1==r.firstChild.childCount;){i--,s--;let e=r.firstChild;n.push(e.type.name,e.attrs!=e.type.defaultAttrs?e.attrs:null),r=e.content}let o=e.someProp("clipboardSerializer")||$t.fromSchema(e.state.schema),a=_i(),l=a.createElement("div");l.appendChild(o.serializeFragment(r,{document:a}));let c,h=l.firstChild,d=0;for(;h&&1==h.nodeType&&(c=Vi[h.nodeName.toLowerCase()]);){for(let e=c.length-1;e>=0;e--){let t=a.createElement(c[e]);for(;l.firstChild;)t.appendChild(l.firstChild);l.appendChild(t),d++}h=l.firstChild}h&&1==h.nodeType&&h.setAttribute("data-pm-slice",`${i} ${s}${d?` -${d}`:""} ${JSON.stringify(n)}`);let u=e.someProp("clipboardTextSerializer",(e=>e(t)))||t.content.textBetween(0,t.content.size,"\n\n");return{dom:l,text:u}}function Ii(e,t,n,r,i){let s,o,a=i.parent.type.spec.code;if(!n&&!t)return null;let l=t&&(r||a||!n);if(l){if(e.someProp("transformPastedText",(e=>{t=e(t,a||r)})),a)return t?new Le($e.from(e.state.schema.text(t.replace(/\r\n?/g,"\n"))),0,0):Le.empty;let n=e.someProp("clipboardTextParser",(e=>e(t,i,r)));if(n)o=n;else{let n=i.marks(),{schema:r}=e.state,o=$t.fromSchema(r);s=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach((e=>{let t=s.appendChild(document.createElement("p"));e&&t.appendChild(o.serializeNode(r.text(e,n)))}))}}else e.someProp("transformPastedHTML",(e=>{n=e(n)})),s=function(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n,r=_i().createElement("div"),i=/<([a-z][^>\s]+)/i.exec(e);(n=i&&Vi[i[1].toLowerCase()])&&(e=n.map((e=>"<"+e+">")).join("")+e+n.map((e=>"</"+e+">")).reverse().join(""));if(r.innerHTML=e,n)for(let e=0;e<n.length;e++)r=r.querySelector(n[e])||r;return r}(n),gr&&function(e){let t=e.querySelectorAll(hr?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<t.length;n++){let r=t[n];1==r.childNodes.length&&" "==r.textContent&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),r)}}(s);let c=s&&s.querySelector("[data-pm-slice]"),h=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(h&&h[3])for(let e=+h[3];e>0&&s.firstChild;e--)s=s.firstChild;if(!o){let t=e.someProp("clipboardParser")||e.someProp("domParser")||kt.fromSchema(e.state.schema);o=t.parseSlice(s,{preserveWhitespace:!(!l&&!h),context:i,ruleFromNode:e=>"BR"!=e.nodeName||e.nextSibling||!e.parentNode||Ri.test(e.parentNode.nodeName)?null:{ignore:!0}})}if(h)o=function(e,t){if(!e.size)return e;let n,r=e.content.firstChild.type.schema;try{n=JSON.parse(t)}catch(t){return e}let{content:i,openStart:s,openEnd:o}=e;for(let e=n.length-2;e>=0;e-=2){let t=r.nodes[n[e]];if(!t||t.hasRequiredAttrs())break;i=$e.from(t.create(n[e+1],i)),s++,o++}return new Le(i,s,o)}(zi(o,+h[1],+h[2]),h[4]);else if(o=Le.maxOpen(function(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let r,i=t.node(n).contentMatchAt(t.index(n)),s=[];if(e.forEach((e=>{if(!s)return;let t,n=i.findWrapping(e.type);if(!n)return s=null;if(t=s.length&&r.length&&Bi(n,r,e,s[s.length-1],0))s[s.length-1]=t;else{s.length&&(s[s.length-1]=Fi(s[s.length-1],r.length));let t=Pi(e,n);s.push(t),i=i.matchType(t.type),r=n}})),s)return $e.from(s)}return e}(o.content,i),!0),o.openStart||o.openEnd){let e=0,t=0;for(let t=o.content.firstChild;e<o.openStart&&!t.type.spec.isolating;e++,t=t.firstChild);for(let e=o.content.lastChild;t<o.openEnd&&!e.type.spec.isolating;t++,e=e.lastChild);o=zi(o,e,t)}return e.someProp("transformPasted",(e=>{o=e(o)})),o}const Ri=/^(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 Pi(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,$e.from(e));return e}function Bi(e,t,n,r,i){if(i<e.length&&i<t.length&&e[i]==t[i]){let s=Bi(e,t,n,r.lastChild,i+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(i==e.length-1?n.type:e[i+1]))return r.copy(r.content.append($e.from(Pi(n,e,i+1))))}}function Fi(e,t){if(0==t)return e;let n=e.content.replaceChild(e.childCount-1,Fi(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore($e.empty,!0);return e.copy(n.append(r))}function Li(e,t,n,r,i,s){let o=t<0?e.firstChild:e.lastChild,a=o.content;return i<r-1&&(a=Li(a,t,n,r,i+1,s)),i>=n&&(a=t<0?o.contentMatchAt(0).fillBefore(a,e.childCount>1||s<=i).append(a):a.append(o.contentMatchAt(o.childCount).fillBefore($e.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,o.copy(a))}function zi(e,t,n){return t<e.openStart&&(e=new Le(Li(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new Le(Li(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}const Vi={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let ji=null;function _i(){return ji||(ji=document.implementation.createHTMLDocument("title"))}const Wi={},Hi={},Ki={touchstart:!0,touchmove:!0};class qi{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.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function Ji(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function Ui(e){e.someProp("handleDOMEvents",(t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>Gi(e,t))}))}function Gi(e,t){return e.someProp("handleDOMEvents",(n=>{let r=n[t.type];return!!r&&(r(e,t)||t.defaultPrevented)}))}function Yi(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||11==n.nodeType||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}function Xi(e){return{left:e.clientX,top:e.clientY}}function Zi(e,t,n,r,i){if(-1==r)return!1;let s=e.state.doc.resolve(r);for(let r=s.depth+1;r>0;r--)if(e.someProp(t,(t=>r>s.depth?t(e,n,s.nodeAfter,s.before(r),i,!0):t(e,n,s.node(r),s.before(r),i,!1))))return!0;return!1}function Qi(e,t,n){e.focused||e.focus();let r=e.state.tr.setSelection(t);"pointer"==n&&r.setMeta("pointer",!0),e.dispatch(r)}function es(e,t,n,r,i){return Zi(e,"handleClickOn",t,n,r)||e.someProp("handleClick",(n=>n(e,t,r)))||(i?function(e,t){if(-1==t)return!1;let n,r,i=e.state.selection;i instanceof Cn&&(n=i.node);let s=e.state.doc.resolve(t);for(let e=s.depth+1;e>0;e--){let t=e>s.depth?s.nodeAfter:s.node(e);if(Cn.isSelectable(t)){r=n&&i.$from.depth>0&&e>=i.$from.depth&&s.before(i.$from.depth+1)==i.$from.pos?s.before(i.$from.depth):s.before(e);break}}return null!=r&&(Qi(e,Cn.create(e.state.doc,r),"pointer"),!0)}(e,n):function(e,t){if(-1==t)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return!!(r&&r.isAtom&&Cn.isSelectable(r))&&(Qi(e,new Cn(n),"pointer"),!0)}(e,n))}function ts(e,t,n,r){return Zi(e,"handleDoubleClickOn",t,n,r)||e.someProp("handleDoubleClick",(n=>n(e,t,r)))}function ns(e,t,n,r){return Zi(e,"handleTripleClickOn",t,n,r)||e.someProp("handleTripleClick",(n=>n(e,t,r)))||function(e,t,n){if(0!=n.button)return!1;let r=e.state.doc;if(-1==t)return!!r.inlineContent&&(Qi(e,Mn.create(r,0,r.content.size),"pointer"),!0);let i=r.resolve(t);for(let t=i.depth+1;t>0;t--){let n=t>i.depth?i.nodeAfter:i.node(t),s=i.before(t);if(n.inlineContent)Qi(e,Mn.create(r,s+1,s+1+n.content.size),"pointer");else{if(!Cn.isSelectable(n))continue;Qi(e,Cn.create(r,s),"pointer")}return!0}}(e,n,r)}function rs(e){return ds(e)}Hi.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=16==n.keyCode||n.shiftKey,!as(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!mr||!hr||13!=n.keyCode))if(229!=n.keyCode&&e.domObserver.forceFlush(),!pr||13!=n.keyCode||n.ctrlKey||n.altKey||n.metaKey)e.someProp("handleKeyDown",(t=>t(e,n)))||Di(e,n)?n.preventDefault():Ji(e,"key");else{let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout((()=>{e.input.lastIOSEnter==t&&(e.someProp("handleKeyDown",(t=>t(e,Qn(13,"Enter")))),e.input.lastIOSEnter=0)}),200)}},Hi.keyup=(e,t)=>{16==t.keyCode&&(e.input.shiftKey=!1)},Hi.keypress=(e,t)=>{let n=t;if(as(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||fr&&n.metaKey)return;if(e.someProp("handleKeyPress",(t=>t(e,n))))return void n.preventDefault();let r=e.state.selection;if(!(r instanceof Mn&&r.$from.sameParent(r.$to))){let t=String.fromCharCode(n.charCode);e.someProp("handleTextInput",(n=>n(e,r.$from.pos,r.$to.pos,t)))||e.dispatch(e.state.tr.insertText(t).scrollIntoView()),n.preventDefault()}};const is=fr?"metaKey":"ctrlKey";Wi.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=rs(e),i=Date.now(),s="singleClick";i-e.input.lastClick.time<500&&function(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}(n,e.input.lastClick)&&!n[is]&&("singleClick"==e.input.lastClick.type?s="doubleClick":"doubleClick"==e.input.lastClick.type&&(s="tripleClick")),e.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:s};let o=e.posAtCoords(Xi(n));o&&("singleClick"==s?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new ss(e,o,n,!!r)):("doubleClick"==s?ts:ns)(e,o.pos,o.inside,n)?n.preventDefault():Ji(e,"pointer"))};class ss{constructor(e,t,n,r){let i,s;if(this.view=e,this.pos=t,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!n[is],this.allowDefault=n.shiftKey,t.inside>-1)i=e.state.doc.nodeAt(t.inside),s=t.inside;else{let n=e.state.doc.resolve(t.pos);i=n.parent,s=n.depth?n.before():0}const o=r?null:n.target,a=o?e.docView.nearestDesc(o,!0):null;this.target=a?a.dom:null;let{selection:l}=e.state;(0==n.button&&i.type.spec.draggable&&!1!==i.type.spec.selectable||l instanceof Cn&&l.from<=s&&l.to>s)&&(this.mightDrag={node:i,pos:s,addAttr:!(!this.target||this.target.draggable),setUneditable:!(!this.target||!lr||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)),Ji(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((()=>ci(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(Xi(e))),this.updateAllowDefault(e),this.allowDefault||!t?Ji(this.view,"pointer"):es(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():0==e.button&&(this.flushed||ur&&this.mightDrag&&!this.mightDrag.node.isAtom||hr&&!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)?(Qi(this.view,bn.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):Ji(this.view,"pointer")}move(e){this.updateAllowDefault(e),Ji(this.view,"pointer"),0==e.buttons&&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)}}function as(e,t){return!!e.composing||!!(ur&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500)&&(e.input.compositionEndedAt=-2e8,!0)}Wi.touchstart=e=>{e.input.lastTouch=Date.now(),rs(e),Ji(e,"pointer")},Wi.touchmove=e=>{e.input.lastTouch=Date.now(),Ji(e,"pointer")},Wi.contextmenu=e=>rs(e);const ls=mr?5e3:-1;function cs(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout((()=>ds(e)),t))}function hs(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=function(){let e=document.createEvent("Event");return e.initEvent("event",!0,!0),e.timeStamp}());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function ds(e,t=!1){if(!(mr&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),hs(e),t||e.docView&&e.docView.dirty){let t=ai(e);return t&&!t.eq(e.state.selection)?e.dispatch(e.state.tr.setSelection(t)):e.updateState(e.state),!0}return!1}}Hi.compositionstart=Hi.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$from;if(t.selection.empty&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some((e=>!1===e.type.spec.inclusive))))e.markCursor=e.state.storedMarks||n.marks(),ds(e,!0),e.markCursor=null;else if(ds(e),lr&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelectionRange();for(let n=t.focusNode,r=t.focusOffset;n&&1==n.nodeType&&0!=r;){let t=r<0?n.lastChild:n.childNodes[r-1];if(!t)break;if(3==t.nodeType){e.domSelection().collapse(t,t.nodeValue.length);break}n=t,r=-1}}e.input.composing=!0}cs(e,ls)},Hi.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,cs(e,20))};const us=or&&ar<15||pr&&yr<604;function ps(e,t,n,r){let i=Ii(e,t,n,e.input.shiftKey,e.state.selection.$from);if(e.someProp("handlePaste",(t=>t(e,r,i||Le.empty))))return!0;if(!i)return!1;let s=function(e){return 0==e.openStart&&0==e.openEnd&&1==e.content.childCount?e.content.firstChild:null}(i),o=s?e.state.tr.replaceSelectionWith(s,e.input.shiftKey):e.state.tr.replaceSelection(i);return e.dispatch(o.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}Wi.copy=Hi.cut=(e,t)=>{let n=t,r=e.state.selection,i="cut"==n.type;if(r.empty)return;let s=us?null:n.clipboardData,o=r.content(),{dom:a,text:l}=$i(e,o);s?(n.preventDefault(),s.clearData(),s.setData("text/html",a.innerHTML),s.setData("text/plain",l)):function(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(t),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout((()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()}),50)}(e,a),i&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))},Hi.paste=(e,t)=>{let n=t;if(e.composing&&!mr)return;let r=us?null:n.clipboardData;r&&ps(e,r.getData("text/plain"),r.getData("text/html"),n)?n.preventDefault():function(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus(),setTimeout((()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?ps(e,r.value,null,t):ps(e,r.textContent,r.innerHTML,t)}),50)}(e,n)};class fs{constructor(e,t){this.slice=e,this.move=t}}const ms=fr?"altKey":"ctrlKey";Wi.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=e.state.selection,s=i.empty?null:e.posAtCoords(Xi(n));if(s&&s.pos>=i.from&&s.pos<=(i instanceof Cn?i.to-1:i.to));else if(r&&r.mightDrag)e.dispatch(e.state.tr.setSelection(Cn.create(e.state.doc,r.mightDrag.pos)));else if(n.target&&1==n.target.nodeType){let t=e.docView.nearestDesc(n.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&e.dispatch(e.state.tr.setSelection(Cn.create(e.state.doc,t.posBefore)))}let o=e.state.selection.content(),{dom:a,text:l}=$i(e,o);n.dataTransfer.clearData(),n.dataTransfer.setData(us?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",us||n.dataTransfer.setData("text/plain",l),e.dragging=new fs(o,!n[ms])},Wi.dragend=e=>{let t=e.dragging;window.setTimeout((()=>{e.dragging==t&&(e.dragging=null)}),50)},Hi.dragover=Hi.dragenter=(e,t)=>t.preventDefault(),Hi.drop=(e,t)=>{let n=t,r=e.dragging;if(e.dragging=null,!n.dataTransfer)return;let i=e.posAtCoords(Xi(n));if(!i)return;let s=e.state.doc.resolve(i.pos),o=r&&r.slice;o?e.someProp("transformPasted",(e=>{o=e(o)})):o=Ii(e,n.dataTransfer.getData(us?"Text":"text/plain"),us?null:n.dataTransfer.getData("text/html"),!1,s);let a=!(!r||n[ms]);if(e.someProp("handleDrop",(t=>t(e,n,o||Le.empty,a))))return void n.preventDefault();if(!o)return;n.preventDefault();let l=o?sn(e.state.doc,s.pos,o):s.pos;null==l&&(l=s.pos);let c=e.state.tr;a&&c.deleteSelection();let h=c.mapping.map(l),d=0==o.openStart&&0==o.openEnd&&1==o.content.childCount,u=c.doc;if(d?c.replaceRangeWith(h,h,o.content.firstChild):c.replaceRange(h,h,o),c.doc.eq(u))return;let p=c.doc.resolve(h);if(d&&Cn.isSelectable(o.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(o.content.firstChild))c.setSelection(new Cn(p));else{let t=c.mapping.map(l);c.mapping.maps[c.mapping.maps.length-1].forEach(((e,n,r,i)=>t=i)),c.setSelection(gi(e,p,c.doc.resolve(t)))}e.focus(),e.dispatch(c.setMeta("uiEvent","drop"))},Wi.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0,setTimeout((()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&ci(e)}),20))},Wi.blur=(e,t)=>{let n=t;e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),e.focused=!1)},Wi.beforeinput=(e,t)=>{if(hr&&mr&&"deleteContentBackward"==t.inputType){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout((()=>{if(e.input.domChangeCount!=t)return;if(e.dom.blur(),e.focus(),e.someProp("handleKeyDown",(t=>t(e,Qn(8,"Backspace")))))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())}),50)}};for(let e in Hi)Wi[e]=Hi[e];function gs(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}class ys{constructor(e,t){this.toDOM=e,this.spec=t||ks,this.side=this.spec.side||0}map(e,t,n,r){let{pos:i,deleted:s}=e.mapResult(t.from+r,this.side<0?-1:1);return s?null:new bs(i-n,i-n,this)}valid(){return!0}eq(e){return this==e||e instanceof ys&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&gs(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class vs{constructor(e,t){this.attrs=e,this.spec=t||ks}map(e,t,n,r){let i=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-n,s=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-n;return i>=s?null:new bs(i,s,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof vs&&gs(this.attrs,e.attrs)&&gs(this.spec,e.spec)}static is(e){return e.type instanceof vs}destroy(){}}class ws{constructor(e,t){this.attrs=e,this.spec=t||ks}map(e,t,n,r){let i=e.mapResult(t.from+r,1);if(i.deleted)return null;let s=e.mapResult(t.to+r,-1);return s.deleted||s.pos<=i.pos?null:new bs(i.pos-n,s.pos-n,this)}valid(e,t){let n,{index:r,offset:i}=e.content.findIndex(t.from);return i==t.from&&!(n=e.child(r)).isText&&i+n.nodeSize==t.to}eq(e){return this==e||e instanceof ws&&gs(this.attrs,e.attrs)&&gs(this.spec,e.spec)}destroy(){}}class bs{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(e,t){return new bs(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,n){return this.type.map(e,this,t,n)}static widget(e,t,n){return new bs(e,e,new ys(t,n))}static inline(e,t,n,r){return new bs(e,t,new vs(n,r))}static node(e,t,n,r){return new bs(e,t,new ws(n,r))}get spec(){return this.type.spec}get inline(){return this.type instanceof vs}}const xs=[],ks={};class Ss{constructor(e,t){this.local=e.length?e:xs,this.children=t.length?t:xs}static create(e,t){return t.length?Ts(t,e,0,ks):Ms}find(e,t,n){let r=[];return this.findInner(null==e?0:e,null==t?1e9:t,r,0,n),r}findInner(e,t,n,r,i){for(let s=0;s<this.local.length;s++){let o=this.local[s];o.from<=t&&o.to>=e&&(!i||i(o.spec))&&n.push(o.copy(o.from+r,o.to+r))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<t&&this.children[s+1]>e){let o=this.children[s]+1;this.children[s+2].findInner(e-o,t-o,n,r+o,i)}}map(e,t,n){return this==Ms||0==e.maps.length?this:this.mapInner(e,t,0,0,n||ks)}mapInner(e,t,n,r,i){let s;for(let o=0;o<this.local.length;o++){let a=this.local[o].map(e,n,r);a&&a.type.valid(t,a)?(s||(s=[])).push(a):i.onRemove&&i.onRemove(this.local[o].spec)}return this.children.length?function(e,t,n,r,i,s,o){let a=e.slice();for(let e=0,t=s;e<n.maps.length;e++){let r=0;n.maps[e].forEach(((e,n,s,o)=>{let l=o-s-(n-e);for(let o=0;o<a.length;o+=3){let c=a[o+1];if(c<0||e>c+t-r)continue;let h=a[o]+t-r;n>=h?a[o+1]=e<=h?-2:-1:s>=i&&l&&(a[o]+=l,a[o+1]+=l)}r+=l})),t=n.maps[e].map(t,-1)}let l=!1;for(let t=0;t<a.length;t+=3)if(a[t+1]<0){if(-2==a[t+1]){l=!0,a[t+1]=-1;continue}let c=n.map(e[t]+s),h=c-i;if(h<0||h>=r.content.size){l=!0;continue}let d=n.map(e[t+1]+s,-1)-i,{index:u,offset:p}=r.content.findIndex(h),f=r.maybeChild(u);if(f&&p==h&&p+f.nodeSize==d){let r=a[t+2].mapInner(n,f,c+1,e[t]+s+1,o);r!=Ms?(a[t]=h,a[t+1]=d,a[t+2]=r):(a[t+1]=-2,l=!0)}else l=!0}if(l){let l=function(e,t,n,r,i,s,o){function a(e,t){for(let s=0;s<e.local.length;s++){let a=e.local[s].map(r,i,t);a?n.push(a):o.onRemove&&o.onRemove(e.local[s].spec)}for(let n=0;n<e.children.length;n+=3)a(e.children[n+2],e.children[n]+t+1)}for(let n=0;n<e.length;n+=3)-1==e[n+1]&&a(e[n+2],t[n]+s+1);return n}(a,e,t,n,i,s,o),c=Ts(l,r,0,o);t=c.local;for(let e=0;e<a.length;e+=3)a[e+1]<0&&(a.splice(e,3),e-=3);for(let e=0,t=0;e<c.children.length;e+=3){let n=c.children[e];for(;t<a.length&&a[t]<n;)t+=3;a.splice(t,0,c.children[e],c.children[e+1],c.children[e+2])}}return new Ss(t.sort(Ns),a)}(this.children,s||[],e,t,n,r,i):s?new Ss(s.sort(Ns),xs):Ms}add(e,t){return t.length?this==Ms?Ss.create(e,t):this.addInner(e,t,0):this}addInner(e,t,n){let r,i=0;e.forEach(((e,s)=>{let o,a=s+n;if(o=As(t,e,a)){for(r||(r=this.children.slice());i<r.length&&r[i]<s;)i+=3;r[i]==s?r[i+2]=r[i+2].addInner(e,o,a+1):r.splice(i,0,s,s+e.nodeSize,Ts(o,e,a+1,ks)),i+=3}}));let s=Cs(i?Es(t):t,-n);for(let t=0;t<s.length;t++)s[t].type.valid(e,s[t])||s.splice(t--,1);return new Ss(s.length?this.local.concat(s).sort(Ns):this.local,r||this.children)}remove(e){return 0==e.length||this==Ms?this:this.removeInner(e,0)}removeInner(e,t){let n=this.children,r=this.local;for(let r=0;r<n.length;r+=3){let i,s=n[r]+t,o=n[r+1]+t;for(let t,n=0;n<e.length;n++)(t=e[n])&&t.from>s&&t.to<o&&(e[n]=null,(i||(i=[])).push(t));if(!i)continue;n==this.children&&(n=this.children.slice());let a=n[r+2].removeInner(i,s+1);a!=Ms?n[r+2]=a:(n.splice(r,3),r-=3)}if(r.length)for(let n,i=0;i<e.length;i++)if(n=e[i])for(let e=0;e<r.length;e++)r[e].eq(n,t)&&(r==this.local&&(r=this.local.slice()),r.splice(e--,1));return n==this.children&&r==this.local?this:r.length||n.length?new Ss(r,n):Ms}forChild(e,t){if(this==Ms)return this;if(t.isLeaf)return Ss.empty;let n,r;for(let t=0;t<this.children.length;t+=3)if(this.children[t]>=e){this.children[t]==e&&(n=this.children[t+2]);break}let i=e+1,s=i+t.content.size;for(let e=0;e<this.local.length;e++){let t=this.local[e];if(t.from<s&&t.to>i&&t.type instanceof vs){let e=Math.max(i,t.from)-i,n=Math.min(s,t.to)-i;e<n&&(r||(r=[])).push(t.copy(e,n))}}if(r){let e=new Ss(r.sort(Ns),xs);return n?new Os([e,n]):e}return n||Ms}eq(e){if(this==e)return!0;if(!(e instanceof Ss)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return Ds(this.localsInner(e))}localsInner(e){if(this==Ms)return xs;if(e.inlineContent||!this.local.some(vs.is))return this.local;let t=[];for(let e=0;e<this.local.length;e++)this.local[e].type instanceof vs||t.push(this.local[e]);return t}}Ss.empty=new Ss([],[]),Ss.removeOverlap=Ds;const Ms=Ss.empty;class Os{constructor(e){this.members=e}map(e,t){const n=this.members.map((n=>n.map(e,t,ks)));return Os.from(n)}forChild(e,t){if(t.isLeaf)return Ss.empty;let n=[];for(let r=0;r<this.members.length;r++){let i=this.members[r].forChild(e,t);i!=Ms&&(i instanceof Os?n=n.concat(i.members):n.push(i))}return Os.from(n)}eq(e){if(!(e instanceof Os)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,n=!0;for(let r=0;r<this.members.length;r++){let i=this.members[r].localsInner(e);if(i.length)if(t){n&&(t=t.slice(),n=!1);for(let e=0;e<i.length;e++)t.push(i[e])}else t=i}return t?Ds(n?t:t.sort(Ns)):xs}static from(e){switch(e.length){case 0:return Ms;case 1:return e[0];default:return new Os(e)}}}function Cs(e,t){if(!t||!e.length)return e;let n=[];for(let r=0;r<e.length;r++){let i=e[r];n.push(new bs(i.from+t,i.to+t,i.type))}return n}function As(e,t,n){if(t.isLeaf)return null;let r=n+t.nodeSize,i=null;for(let t,s=0;s<e.length;s++)(t=e[s])&&t.from>n&&t.to<r&&((i||(i=[])).push(t),e[s]=null);return i}function Es(e){let t=[];for(let n=0;n<e.length;n++)null!=e[n]&&t.push(e[n]);return t}function Ts(e,t,n,r){let i=[],s=!1;t.forEach(((t,o)=>{let a=As(e,t,o+n);if(a){s=!0;let e=Ts(a,t,n+o+1,r);e!=Ms&&i.push(o,o+t.nodeSize,e)}}));let o=Cs(s?Es(e):e,-n).sort(Ns);for(let e=0;e<o.length;e++)o[e].type.valid(t,o[e])||(r.onRemove&&r.onRemove(o[e].spec),o.splice(e--,1));return o.length||i.length?new Ss(o,i):Ms}function Ns(e,t){return e.from-t.from||e.to-t.to}function Ds(e){let t=e;for(let n=0;n<t.length-1;n++){let r=t[n];if(r.from!=r.to)for(let i=n+1;i<t.length;i++){let s=t[i];if(s.from!=r.from){s.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,s.from),$s(t,i,r.copy(s.from,r.to)));break}s.to!=r.to&&(t==e&&(t=e.slice()),t[i]=s.copy(s.from,r.to),$s(t,i+1,s.copy(r.to,s.to)))}}return t}function $s(e,t,n){for(;t<e.length&&Ns(n,e[t])>0;)t++;e.splice(t,0,n)}function Is(e){let t=[];return e.someProp("decorations",(n=>{let r=n(e.state);r&&r!=Ms&&t.push(r)})),e.cursorWrapper&&t.push(Ss.create(e.state.doc,[e.cursorWrapper.deco])),Os.from(t)}const Rs={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Ps=or&&ar<=11;class Bs{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 Fs{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Bs,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.observer=window.MutationObserver&&new window.MutationObserver((e=>{for(let t=0;t<e.length;t++)this.queue.push(e[t]);or&&ar<=11&&e.some((e=>"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length))?this.flushSoon():this.flush()})),Ps&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.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,Rs)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout((()=>this.flush()),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout((()=>this.suppressingSelectionUpdates=!1),50)}onSelectionChange(){if(yi(this.view)){if(this.suppressingSelectionUpdates)return ci(this.view);if(or&&ar<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Jn(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,n=new Set;for(let t=e.focusNode;t;t=Hn(t))n.add(t);for(let r=e.anchorNode;r;r=Hn(r))if(n.has(r)){t=r;break}let r=t&&this.view.docView.nearestDesc(t);return r&&r.ignoreMutation({type:"selection",target:3==t.nodeType?t.parentNode:t})?(this.setCurSelection(),!0):void 0}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.observer?this.observer.takeRecords():[];this.queue.length&&(t=this.queue.concat(t),this.queue.length=0);let n=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&yi(e)&&!this.ignoreSelectionChange(n),i=-1,s=-1,o=!1,a=[];if(e.editable)for(let e=0;e<t.length;e++){let n=this.registerMutation(t[e],a);n&&(i=i<0?n.from:Math.min(n.from,i),s=s<0?n.to:Math.max(n.to,s),n.typeOver&&(o=!0))}if(lr&&a.length>1){let e=a.filter((e=>"BR"==e.nodeName));if(2==e.length){let t=e[0],n=e[1];t.parentNode&&t.parentNode.parentNode==n.parentNode?n.remove():t.remove()}}let l=null;i<0&&r&&e.input.lastFocus>Date.now()-200&&e.input.lastTouch<Date.now()-300&&Zn(n)&&(l=ai(e))&&l.eq(bn.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,ci(e),this.currentSelection.set(n),e.scrollToSelection()):(i>-1||r)&&(i>-1&&(e.docView.markDirty(i,s),function(e){if(Ls.has(e))return;if(Ls.set(e,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(e.dom).whiteSpace)){if(e.requiresGeckoHackNode=lr,zs)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),zs=!0}}(e)),this.handleDOMChange(i,s,o,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||ci(e),this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if("attributes"==e.type&&(n==this.view.docView||"contenteditable"==e.attributeName||"style"==e.attributeName&&!e.oldValue&&!e.target.getAttribute("style")))return null;if(!n||n.ignoreMutation(e))return null;if("childList"==e.type){for(let n=0;n<e.addedNodes.length;n++)t.push(e.addedNodes[n]);if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let r=e.previousSibling,i=e.nextSibling;if(or&&ar<=11&&e.addedNodes.length)for(let t=0;t<e.addedNodes.length;t++){let{previousSibling:n,nextSibling:s}=e.addedNodes[t];(!n||Array.prototype.indexOf.call(e.addedNodes,n)<0)&&(r=n),(!s||Array.prototype.indexOf.call(e.addedNodes,s)<0)&&(i=s)}let s=r&&r.parentNode==e.target?Wn(r)+1:0,o=n.localPosFromDOM(e.target,s,-1),a=i&&i.parentNode==e.target?Wn(i):e.target.childNodes.length;return{from:o,to:n.localPosFromDOM(e.target,a,1)}}return"attributes"==e.type?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}}}let Ls=new WeakMap,zs=!1;function Vs(e){let t=e.pmViewDesc;if(t)return t.parseRule();if("BR"==e.nodeName&&e.parentNode){if(ur&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let e=document.createElement("div");return e.appendChild(document.createElement("li")),{skip:e}}if(e.parentNode.lastChild==e||ur&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if("IMG"==e.nodeName&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null}function js(e,t,n,r,i){if(t<0){let t=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,n=ai(e,t);if(n&&!e.state.selection.eq(n)){let r=e.state.tr.setSelection(n);"pointer"==t?r.setMeta("pointer",!0):"key"==t&&r.scrollIntoView(),e.dispatch(r)}return}let s=e.state.doc.resolve(t),o=s.sharedDepth(n);t=s.before(o+1),n=e.state.doc.resolve(n).after(o+1);let a,l,c=e.state.selection,h=function(e,t,n){let r,{node:i,fromOffset:s,toOffset:o,from:a,to:l}=e.docView.parseRange(t,n),c=e.domSelectionRange(),h=c.anchorNode;if(h&&e.dom.contains(1==h.nodeType?h:h.parentNode)&&(r=[{node:h,offset:c.anchorOffset}],Zn(c)||r.push({node:c.focusNode,offset:c.focusOffset})),hr&&8===e.input.lastKeyCode)for(let e=o;e>s;e--){let t=i.childNodes[e-1],n=t.pmViewDesc;if("BR"==t.nodeName&&!n){o=e;break}if(!n||n.size)break}let d=e.state.doc,u=e.someProp("domParser")||kt.fromSchema(e.state.schema),p=d.resolve(a),f=null,m=u.parse(i,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:s,to:o,preserveWhitespace:"pre"!=p.parent.type.whitespace||"full",findPositions:r,ruleFromNode:Vs,context:p});if(r&&null!=r[0].pos){let e=r[0].pos,t=r[1]&&r[1].pos;null==t&&(t=e),f={anchor:e+a,head:t+a}}return{doc:m,sel:f,from:a,to:l}}(e,t,n),d=e.state.doc,u=d.slice(h.from,h.to);8===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime?(a=e.state.selection.to,l="end"):(a=e.state.selection.from,l="start"),e.input.lastKeyCode=null;let p=function(e,t,n,r,i){let s=e.findDiffStart(t,n);if(null==s)return null;let{a:o,b:a}=e.findDiffEnd(t,n+e.size,n+t.size);if("end"==i){r-=o+Math.max(0,s-Math.min(o,a))-s}if(o<s&&e.size<t.size){s-=r<=s&&r>=o?s-r:0,a=s+(a-o),o=s}else if(a<s){s-=r<=s&&r>=a?s-r:0,o=s+(o-a),a=s}return{start:s,endA:o,endB:a}}(u.content,h.doc.content,h.from,a,l);if((pr&&e.input.lastIOSEnter>Date.now()-225||mr)&&i.some((e=>"DIV"==e.nodeName||"P"==e.nodeName))&&(!p||p.endA>=p.endB)&&e.someProp("handleKeyDown",(t=>t(e,Qn(13,"Enter")))))return void(e.input.lastIOSEnter=0);if(!p){if(!(r&&c instanceof Mn&&!c.empty&&c.$head.sameParent(c.$anchor))||e.composing||h.sel&&h.sel.anchor!=h.sel.head){if(h.sel){let t=_s(e,e.state.doc,h.sel);t&&!t.eq(e.state.selection)&&e.dispatch(e.state.tr.setSelection(t))}return}p={start:c.from,endA:c.to,endB:c.to}}if(hr&&e.cursorWrapper&&h.sel&&h.sel.anchor==e.cursorWrapper.deco.from&&h.sel.head==h.sel.anchor){let e=p.endB-p.start;h.sel={anchor:h.sel.anchor+e,head:h.sel.anchor+e}}e.input.domChangeCount++,e.state.selection.from<e.state.selection.to&&p.start==p.endB&&e.state.selection instanceof Mn&&(p.start>e.state.selection.from&&p.start<=e.state.selection.from+2&&e.state.selection.from>=h.from?p.start=e.state.selection.from:p.endA<e.state.selection.to&&p.endA>=e.state.selection.to-2&&e.state.selection.to<=h.to&&(p.endB+=e.state.selection.to-p.endA,p.endA=e.state.selection.to)),or&&ar<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>h.from&&"  "==h.doc.textBetween(p.start-h.from-1,p.start-h.from+1)&&(p.start--,p.endA--,p.endB--);let f,m=h.doc.resolveNoCache(p.start-h.from),g=h.doc.resolveNoCache(p.endB-h.from),y=d.resolve(p.start),v=m.sameParent(g)&&m.parent.inlineContent&&y.end()>=p.endA;if((pr&&e.input.lastIOSEnter>Date.now()-225&&(!v||i.some((e=>"DIV"==e.nodeName||"P"==e.nodeName)))||!v&&m.pos<h.doc.content.size&&(f=bn.findFrom(h.doc.resolve(m.pos+1),1,!0))&&f.head==g.pos)&&e.someProp("handleKeyDown",(t=>t(e,Qn(13,"Enter")))))return void(e.input.lastIOSEnter=0);if(e.state.selection.anchor>p.start&&function(e,t,n,r,i){if(!r.parent.isTextblock||n-t<=i.pos-r.pos||Ws(r,!0,!1)<i.pos)return!1;let s=e.resolve(t);if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let o=e.resolve(Ws(s,!0,!0));return!(!o.parent.isTextblock||o.pos>n||Ws(o,!0,!1)<n)&&r.parent.content.cut(r.parentOffset).eq(o.parent.content)}(d,p.start,p.endA,m,g)&&e.someProp("handleKeyDown",(t=>t(e,Qn(8,"Backspace")))))return void(mr&&hr&&e.domObserver.suppressSelectionUpdates());hr&&mr&&p.endB==p.start&&(e.input.lastAndroidDelete=Date.now()),mr&&!v&&m.start()!=g.start()&&0==g.parentOffset&&m.depth==g.depth&&h.sel&&h.sel.anchor==h.sel.head&&h.sel.head==p.endA&&(p.endB-=2,g=h.doc.resolveNoCache(p.endB-h.from),setTimeout((()=>{e.someProp("handleKeyDown",(function(t){return t(e,Qn(13,"Enter"))}))}),20));let w,b,x,k=p.start,S=p.endA;if(v)if(m.pos==g.pos)or&&ar<=11&&0==m.parentOffset&&(e.domObserver.suppressSelectionUpdates(),setTimeout((()=>ci(e)),20)),w=e.state.tr.delete(k,S),b=d.resolve(p.start).marksAcross(d.resolve(p.endA));else if(p.endA==p.endB&&(x=function(e,t){let n,r,i,s=e.firstChild.marks,o=t.firstChild.marks,a=s,l=o;for(let e=0;e<o.length;e++)a=o[e].removeFromSet(a);for(let e=0;e<s.length;e++)l=s[e].removeFromSet(l);if(1==a.length&&0==l.length)r=a[0],n="add",i=e=>e.mark(r.addToSet(e.marks));else{if(0!=a.length||1!=l.length)return null;r=l[0],n="remove",i=e=>e.mark(r.removeFromSet(e.marks))}let c=[];for(let e=0;e<t.childCount;e++)c.push(i(t.child(e)));if($e.from(c).eq(e))return{mark:r,type:n}}(m.parent.content.cut(m.parentOffset,g.parentOffset),y.parent.content.cut(y.parentOffset,p.endA-y.start()))))w=e.state.tr,"add"==x.type?w.addMark(k,S,x.mark):w.removeMark(k,S,x.mark);else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let t=m.parent.textBetween(m.parentOffset,g.parentOffset);if(e.someProp("handleTextInput",(n=>n(e,k,S,t))))return;w=e.state.tr.insertText(t,k,S)}if(w||(w=e.state.tr.replace(k,S,h.doc.slice(p.start-h.from,p.endB-h.from))),h.sel){let t=_s(e,w.doc,h.sel);t&&!(hr&&mr&&e.composing&&t.empty&&(p.start!=p.endB||e.input.lastAndroidDelete<Date.now()-100)&&(t.head==k||t.head==w.mapping.map(S)-1)||or&&t.empty&&t.head==k)&&w.setSelection(t)}b&&w.ensureMarks(b),e.dispatch(w.scrollIntoView())}function _s(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:gi(e,t.resolve(n.anchor),t.resolve(n.head))}function Ws(e,t,n){let r=e.depth,i=t?e.end():e.pos;for(;r>0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,i++,t=!1;if(n){let t=e.node(r).maybeChild(e.indexAfter(r));for(;t&&!t.isLeaf;)t=t.firstChild,i++}return i}class Hs{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 qi,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Gs),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):"function"==typeof e?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=Js(this),qs(this),this.nodeViews=Us(this),this.docView=Kr(this.state.doc,Ks(this),Is(this),this.dom,this),this.domObserver=new Fs(this,((e,t,n,r)=>js(this,e,t,n,r))),this.domObserver.start(),function(e){for(let t in Wi){let n=Wi[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{!Yi(e,t)||Gi(e,t)||!e.editable&&t.type in Hi||n(e,t)},Ki[t]?{passive:!0}:void 0)}ur&&e.dom.addEventListener("input",(()=>null)),Ui(e)}(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&&Ui(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Gs),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let e in this._props)t[e]=this._props[e];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){let n=this.state,r=!1,i=!1;e.storedMarks&&this.composing&&(hs(this),i=!0),this.state=e;let s=n.plugins!=e.plugins||this._props.plugins!=t.plugins;if(s||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=Us(this);(function(e,t){let n=0,r=0;for(let r in e){if(e[r]!=t[r])return!0;n++}for(let e in t)r++;return n!=r})(e,this.nodeViews)&&(this.nodeViews=e,r=!0)}(s||t.handleDOMEvents!=this._props.handleDOMEvents)&&Ui(this),this.editable=Js(this),qs(this);let o=Is(this),a=Ks(this),l=n.plugins==e.plugins||n.doc.eq(e.doc)?e.scrollToSelection>n.scrollToSelection?"to selection":"preserve":"reset",c=r||!this.docView.matchesNode(e.doc,a,o);!c&&e.selection.eq(n.selection)||(i=!0);let h="preserve"==l&&i&&null==this.dom.style.overflowAnchor&&function(e){let t,n,r=e.dom.getBoundingClientRect(),i=Math.max(0,r.top);for(let s=(r.left+r.right)/2,o=i+1;o<Math.min(innerHeight,r.bottom);o+=5){let r=e.root.elementFromPoint(s,o);if(!r||r==e.dom||!e.dom.contains(r))continue;let a=r.getBoundingClientRect();if(a.top>=i-20){t=r,n=a.top;break}}return{refDOM:t,refTop:n,stack:kr(e.dom)}}(this);if(i){this.domObserver.stop();let t=c&&(or||hr)&&!this.composing&&!n.selection.empty&&!e.selection.empty&&function(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}(n.selection,e.selection);if(c){let n=hr?this.trackWrites=this.domSelectionRange().focusNode:null;!r&&this.docView.update(e.doc,a,o,this)||(this.docView.updateOuterDeco([]),this.docView.destroy(),this.docView=Kr(e.doc,a,o,this.dom,this)),n&&!this.trackWrites&&(t=!0)}t||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&function(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return Jn(t.node,t.offset,n.anchorNode,n.anchorOffset)}(this))?ci(this,t):(fi(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(n),"reset"==l?this.dom.scrollTop=0:"to selection"==l?this.scrollToSelection():h&&function({refDOM:e,refTop:t,stack:n}){let r=e?e.getBoundingClientRect().top:0;Sr(n,0==r?0:r-t)}(h)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(this.someProp("handleScrollToSelection",(e=>e(this))));else if(this.state.selection instanceof Cn){let t=this.docView.domAfterPos(this.state.selection.from);1==t.nodeType&&xr(this,t.getBoundingClientRect(),e)}else xr(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)for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}else{this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let e=0;e<this.directPlugins.length;e++){let t=this.directPlugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}for(let e=0;e<this.state.plugins.length;e++){let t=this.state.plugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}}}someProp(e,t){let n,r=this._props&&this._props[e];if(null!=r&&(n=t?t(r):r))return n;for(let r=0;r<this.directPlugins.length;r++){let i=this.directPlugins[r].props[e];if(null!=i&&(n=t?t(i):i))return n}let i=this.state.plugins;if(i)for(let r=0;r<i.length;r++){let s=i[r].props[e];if(null!=s&&(n=t?t(s):s))return n}}hasFocus(){if(or){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if("false"==e.contentEditable)return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&function(e){if(e.setActive)return e.setActive();if(Mr)return e.focus(Mr);let t=kr(e);e.focus(null==Mr?{get preventScroll(){return Mr={preventScroll:!0},!0}}:void 0),Mr||(Mr=!1,Sr(t,0))}(this.dom),ci(this),this.domObserver.start()}get root(){let e=this._root;if(null==e)for(let e=this.dom.parentNode;e;e=e.parentNode)if(9==e.nodeType||11==e.nodeType&&e.host)return e.getSelection||(Object.getPrototypeOf(e).getSelection=()=>e.ownerDocument.getSelection()),this._root=e;return e||document}posAtCoords(e){return Er(this,e)}coordsAtPos(e,t=1){return Dr(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,n=-1){let r=this.docView.posFromDOM(e,t,n);if(null==r)throw new RangeError("DOM position not inside the editor");return r}endOfTextblock(e,t){return zr(this,t||this.state,e)}destroy(){this.docView&&(!function(e){e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Is(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null)}get isDestroyed(){return null==this.docView}dispatchEvent(e){return function(e,t){Gi(e,t)||!Wi[t.type]||!e.editable&&t.type in Hi||Wi[t.type](e,t)}(this,e)}dispatch(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))}domSelectionRange(){return ur&&11===this.root.nodeType&&function(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}(this.dom.ownerDocument)==this.dom?function(e){let t;function n(e){e.preventDefault(),e.stopImmediatePropagation(),t=e.getTargetRanges()[0]}e.dom.addEventListener("beforeinput",n,!0),document.execCommand("indent"),e.dom.removeEventListener("beforeinput",n,!0);let r=t.startContainer,i=t.startOffset,s=t.endContainer,o=t.endOffset,a=e.domAtPos(e.state.selection.anchor);return Jn(a.node,a.offset,s,o)&&([r,i,s,o]=[s,o,r,i]),{anchorNode:r,anchorOffset:i,focusNode:s,focusOffset:o}}(this):this.domSelection()}domSelection(){return this.root.getSelection()}}function Ks(e){let t=Object.create(null);return t.class="ProseMirror",t.contenteditable=String(e.editable),t.translate="no",e.someProp("attributes",(n=>{if("function"==typeof n&&(n=n(e.state)),n)for(let e in n)"class"==e&&(t.class+=" "+n[e]),"style"==e?t.style=(t.style?t.style+";":"")+n[e]:t[e]||"contenteditable"==e||"nodeName"==e||(t[e]=String(n[e]))})),[bs.node(0,e.state.doc.content.size,t)]}function qs(e){if(e.markCursor){let t=document.createElement("img");t.className="ProseMirror-separator",t.setAttribute("mark-placeholder","true"),t.setAttribute("alt",""),e.cursorWrapper={dom:t,deco:bs.widget(e.state.selection.head,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function Js(e){return!e.someProp("editable",(t=>!1===t(e.state)))}function Us(e){let t=Object.create(null);function n(e){for(let n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp("nodeViews",n),e.someProp("markViews",n),t}function Gs(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var Ys={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Xs={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Zs="undefined"!=typeof navigator&&/Chrome\/(\d+)/.exec(navigator.userAgent);"undefined"!=typeof navigator&&/Gecko\/\d+/.test(navigator.userAgent);for(var Qs="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),eo="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),to=Qs||Zs&&+Zs[1]<57,no=0;no<10;no++)Ys[48+no]=Ys[96+no]=String(no);for(no=1;no<=24;no++)Ys[no+111]="F"+no;for(no=65;no<=90;no++)Ys[no]=String.fromCharCode(no+32),Xs[no]=String.fromCharCode(no);for(var ro in Ys)Xs.hasOwnProperty(ro)||(Xs[ro]=Ys[ro]);const io="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform);function so(e){let t,n,r,i,s=e.split(/-(?!$)/),o=s[s.length-1];"Space"==o&&(o=" ");for(let e=0;e<s.length-1;e++){let o=s[e];if(/^(cmd|meta|m)$/i.test(o))i=!0;else if(/^a(lt)?$/i.test(o))t=!0;else if(/^(c|ctrl|control)$/i.test(o))n=!0;else if(/^s(hift)?$/i.test(o))r=!0;else{if(!/^mod$/i.test(o))throw new Error("Unrecognized modifier name: "+o);io?i=!0:n=!0}}return t&&(o="Alt-"+o),n&&(o="Ctrl-"+o),i&&(o="Meta-"+o),r&&(o="Shift-"+o),o}function oo(e,t,n){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),!1!==n&&t.shiftKey&&(e="Shift-"+e),e}function ao(e){let t=function(e){let t=Object.create(null);for(let n in e)t[so(n)]=e[n];return t}(e);return function(e,n){let r,i=function(e){var t=!(to&&(e.ctrlKey||e.altKey||e.metaKey)||eo&&e.shiftKey&&e.key&&1==e.key.length||"Unidentified"==e.key)&&e.key||(e.shiftKey?Xs:Ys)[e.keyCode]||e.key||"Unidentified";return"Esc"==t&&(t="Escape"),"Del"==t&&(t="Delete"),"Left"==t&&(t="ArrowLeft"),"Up"==t&&(t="ArrowUp"),"Right"==t&&(t="ArrowRight"),"Down"==t&&(t="ArrowDown"),t}(n),s=1==i.length&&" "!=i,o=t[oo(i,n,!s)];if(o&&o(e.state,e.dispatch,e))return!0;if(s&&(n.shiftKey||n.altKey||n.metaKey||i.charCodeAt(0)>127)&&(r=Ys[n.keyCode])&&r!=i){let i=t[oo(r,n,!0)];if(i&&i(e.state,e.dispatch,e))return!0}else if(s&&n.shiftKey){let r=t[oo(i,n,!0)];if(r&&r(e.state,e.dispatch,e))return!0}return!1}}function lo(e,t,n=!1){for(let r=e;r;r="start"==t?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&1!=r.childCount)return!1}return!1}function co(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function ho(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){let n=e.node(t);if(e.index(t)+1<n.childCount)return e.doc.resolve(e.after(t+1));if(n.type.spec.isolating)break}return null}function uo(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function po(e,t,n){let r,i,s=t.nodeBefore,o=t.nodeAfter;if(s.type.spec.isolating||o.type.spec.isolating)return!1;if(function(e,t,n){let r=t.nodeBefore,i=t.nodeAfter,s=t.index();return!(!(r&&i&&r.type.compatibleContent(i.type))||(!r.content.size&&t.parent.canReplace(s-1,s)?(n&&n(e.tr.delete(t.pos-r.nodeSize,t.pos).scrollIntoView()),0):!t.parent.canReplace(s,s+1)||!i.isTextblock&&!rn(e.doc,t.pos)||(n&&n(e.tr.clearIncompatible(t.pos,r.type,r.contentMatchAt(r.childCount)).join(t.pos).scrollIntoView()),0)))}(e,t,n))return!0;let a=t.parent.canReplace(t.index(),t.index()+1);if(a&&(r=(i=s.contentMatchAt(s.childCount)).findWrapping(o.type))&&i.matchType(r[0]||o.type).validEnd){if(n){let i=t.pos+o.nodeSize,a=$e.empty;for(let e=r.length-1;e>=0;e--)a=$e.from(r[e].create(null,a));a=$e.from(s.copy(a));let l=e.tr.step(new Yt(t.pos-1,i,t.pos,i,new Le(a,1,0),r.length,!0)),c=i+2*r.length;rn(l.doc,c)&&l.join(c),n(l.scrollIntoView())}return!0}let l=bn.findFrom(t,1),c=l&&l.$from.blockRange(l.$to),h=c&&Qt(c);if(null!=h&&h>=t.depth)return n&&n(e.tr.lift(c,h).scrollIntoView()),!0;if(a&&lo(o,"start",!0)&&lo(s,"end")){let r=s,i=[];for(;i.push(r),!r.isTextblock;)r=r.lastChild;let a=o,l=1;for(;!a.isTextblock;a=a.firstChild)l++;if(r.canReplace(r.childCount,r.childCount,a.content)){if(n){let r=$e.empty;for(let e=i.length-1;e>=0;e--)r=$e.from(i[e].copy(r));n(e.tr.step(new Yt(t.pos-i.length,t.pos+o.nodeSize,t.pos+l,t.pos+o.nodeSize-l,new Le(r,i.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function fo(e){return function(t,n){let r=t.selection,i=e<0?r.$from:r.$to,s=i.depth;for(;i.node(s).isInline;){if(!s)return!1;s--}return!!i.node(s).isTextblock&&(n&&n(t.tr.setSelection(Mn.create(t.doc,e<0?i.start(s):i.end(s)))),!0)}}const mo=fo(-1),go=fo(1);function yo(e,t=null){return function(n,r){let{from:i,to:s}=n.selection,o=!1;return n.doc.nodesBetween(i,s,((r,i)=>{if(o)return!1;if(r.isTextblock&&!r.hasMarkup(e,t))if(r.type==e)o=!0;else{let t=n.doc.resolve(i),r=t.index();o=t.parent.canReplaceWith(r,r+1,e)}})),!!o&&(r&&r(n.tr.setBlockType(i,s,e,t).scrollIntoView()),!0)}}function vo(e,t=null){return function(n,r){let{$from:i,$to:s}=n.selection,o=i.blockRange(s),a=!1,l=o;if(!o)return!1;if(o.depth>=2&&i.node(o.depth-1).type.compatibleContent(e)&&0==o.startIndex){if(0==i.index(o.depth-1))return!1;let e=n.doc.resolve(o.start-2);l=new et(e,e,o.depth),o.endIndex<o.parent.childCount&&(o=new et(i,n.doc.resolve(s.end(o.depth)),o.depth)),a=!0}let c=en(l,e,t,o);return!!c&&(r&&r(function(e,t,n,r,i){let s=$e.empty;for(let e=n.length-1;e>=0;e--)s=$e.from(n[e].type.create(n[e].attrs,s));e.step(new Yt(t.start-(r?2:0),t.end,t.start,t.end,new Le(s,0,0),n.length,!0));let o=0;for(let e=0;e<n.length;e++)n[e].type==i&&(o=e+1);let a=n.length-o,l=t.start+n.length-(r?2:0),c=t.parent;for(let n=t.startIndex,r=t.endIndex,i=!0;n<r;n++,i=!1)!i&&nn(e.doc,l,a)&&(e.split(l,a),l+=2*a),l+=c.child(n).nodeSize;return e}(n.tr,o,c,a,e).scrollIntoView()),!0)}}function wo(e){return function(t,n){let{$from:r,$to:i}=t.selection,s=r.blockRange(i,(t=>t.childCount>0&&t.firstChild.type==e));return!!s&&(!n||(r.node(s.depth-1).type==e?function(e,t,n,r){let i=e.tr,s=r.end,o=r.$to.end(r.depth);s<o&&(i.step(new Yt(s-1,o,s,o,new Le($e.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new et(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth));const a=Qt(r);if(null==a)return!1;i.lift(r,a);let l=i.mapping.map(s,-1)-1;rn(i.doc,l)&&i.join(l);return t(i.scrollIntoView()),!0}(t,n,e,s):function(e,t,n){let r=e.tr,i=n.parent;for(let e=n.end,t=n.endIndex-1,s=n.startIndex;t>s;t--)e-=i.child(t).nodeSize,r.delete(e-1,e+1);let s=r.doc.resolve(n.start),o=s.nodeAfter;if(r.mapping.map(n.end)!=n.start+s.nodeAfter.nodeSize)return!1;let a=0==n.startIndex,l=n.endIndex==i.childCount,c=s.node(-1),h=s.index(-1);if(!c.canReplace(h+(a?0:1),h+1,o.content.append(l?$e.empty:$e.from(i))))return!1;let d=s.pos,u=d+o.nodeSize;return r.step(new Yt(d-(a?1:0),u+(l?1:0),d+1,u-1,new Le((a?$e.empty:$e.from(i.copy($e.empty))).append(l?$e.empty:$e.from(i.copy($e.empty))),a?0:1,l?0:1),a?0:1)),t(r.scrollIntoView()),!0}(t,n,s)))}}function bo(e){const{state:t,transaction:n}=e;let{selection:r}=n,{doc:i}=n,{storedMarks:s}=n;return{...t,apply:t.apply.bind(t),applyTransaction:t.applyTransaction.bind(t),filterTransaction:t.filterTransaction,plugins:t.plugins,schema:t.schema,reconfigure:t.reconfigure.bind(t),toJSON:t.toJSON.bind(t),get storedMarks(){return s},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,s=n.storedMarks,n}}}"undefined"!=typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):"undefined"!=typeof os&&os.platform&&os.platform();class xo{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:e,editor:t,state:n}=this,{view:r}=t,{tr:i}=n,s=this.buildProps(i);return Object.fromEntries(Object.entries(e).map((([e,t])=>[e,(...e)=>{const n=t(...e)(s);return i.getMeta("preventDispatch")||this.hasCustomState||r.dispatch(i),n}])))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){const{rawCommands:n,editor:r,state:i}=this,{view:s}=r,o=[],a=!!e,l=e||i.tr,c={...Object.fromEntries(Object.entries(n).map((([e,n])=>[e,(...e)=>{const r=this.buildProps(l,t),i=n(...e)(r);return o.push(i),c}]))),run:()=>(a||!t||l.getMeta("preventDispatch")||this.hasCustomState||s.dispatch(l),o.every((e=>!0===e)))};return c}createCan(e){const{rawCommands:t,state:n}=this,r=e||n.tr,i=this.buildProps(r,false),s=Object.fromEntries(Object.entries(t).map((([e,t])=>[e,(...e)=>t(...e)({...i,dispatch:void 0})])));return{...s,chain:()=>this.createChain(r,false)}}buildProps(e,t=!0){const{rawCommands:n,editor:r,state:i}=this,{view:s}=r;i.storedMarks&&e.setStoredMarks(i.storedMarks);const o={tr:e,editor:r,view:s,state:bo({state:i,transaction:e}),dispatch:t?()=>{}:void 0,chain:()=>this.createChain(e),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(n).map((([e,t])=>[e,(...e)=>t(...e)(o)])))}};return o}}function ko(e,t,n){if(void 0===e.config[t]&&e.parent)return ko(e.parent,t,n);if("function"==typeof e.config[t]){return e.config[t].bind({...n,parent:e.parent?ko(e.parent,t,n):null})}return e.config[t]}function So(e){return{baseExtensions:e.filter((e=>"extension"===e.type)),nodeExtensions:e.filter((e=>"node"===e.type)),markExtensions:e.filter((e=>"mark"===e.type))}}function Mo(e){const t=[],{nodeExtensions:n,markExtensions:r}=So(e),i=[...n,...r],s={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return e.forEach((e=>{const n=ko(e,"addGlobalAttributes",{name:e.name,options:e.options,storage:e.storage});if(!n)return;n().forEach((e=>{e.types.forEach((n=>{Object.entries(e.attributes).forEach((([e,r])=>{t.push({type:n,name:e,attribute:{...s,...r}})}))}))}))})),i.forEach((e=>{const n={name:e.name,options:e.options,storage:e.storage},r=ko(e,"addAttributes",n);if(!r)return;const i=r();Object.entries(i).forEach((([n,r])=>{const i={...s,...r};(null==r?void 0:r.isRequired)&&void 0===(null==r?void 0:r.default)&&delete i.default,t.push({type:e.name,name:n,attribute:i})}))})),t}function Oo(e,t){if("string"==typeof e){if(!t.nodes[e])throw Error(`There is no node type named '${e}'. Maybe you forgot to add the extension?`);return t.nodes[e]}return e}function Co(...e){return e.filter((e=>!!e)).reduce(((e,t)=>{const n={...e};return Object.entries(t).forEach((([e,t])=>{n[e]?n[e]="class"===e?[n[e],t].join(" "):"style"===e?[n[e],t].join("; "):t:n[e]=t})),n}),{})}function Ao(e,t){return t.filter((e=>e.attribute.rendered)).map((t=>t.attribute.renderHTML?t.attribute.renderHTML(e.attrs)||{}:{[t.name]:e.attrs[t.name]})).reduce(((e,t)=>Co(e,t)),{})}function Eo(e){return"function"==typeof e}function To(e,t,...n){return Eo(e)?t?e.bind(t)(...n):e(...n):e}function No(e,t){return e.style?e:{...e,getAttrs:n=>{const r=e.getAttrs?e.getAttrs(n):e.attrs;if(!1===r)return!1;const i=t.reduce(((e,t)=>{const r=t.attribute.parseHTML?t.attribute.parseHTML(n):function(e){return"string"!=typeof e?e:e.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(e):"true"===e||"false"!==e&&e}(n.getAttribute(t.name));return null==r?e:{...e,[t.name]:r}}),{});return{...r,...i}}}}function Do(e){return Object.fromEntries(Object.entries(e).filter((([e,t])=>("attrs"!==e||!function(e={}){return 0===Object.keys(e).length&&e.constructor===Object}(t))&&null!=t)))}function $o(e,t){return t.nodes[e]||t.marks[e]||null}function Io(e,t){return Array.isArray(t)?t.some((t=>("string"==typeof t?t:t.name)===e.name)):t}function Ro(e){return"[object RegExp]"===Object.prototype.toString.call(e)}function Po(e){var t;const{editor:n,from:r,to:i,text:s,rules:o,plugin:a}=e,{view:l}=n;if(l.composing)return!1;const c=l.state.doc.resolve(r);if(c.parent.type.spec.code||(null===(t=c.nodeBefore||c.nodeAfter)||void 0===t?void 0:t.marks.find((e=>e.type.spec.code))))return!1;let h=!1;const d=((e,t=500)=>{let n="";const r=e.parentOffset;return e.parent.nodesBetween(Math.max(0,r-t),r,((e,t,i,s)=>{var o,a;const l=(null===(a=(o=e.type.spec).toText)||void 0===a?void 0:a.call(o,{node:e,pos:t,parent:i,index:s}))||e.textContent||"%leaf%";n+=l.slice(0,Math.max(0,r-t))})),n})(c)+s;return o.forEach((e=>{if(h)return;const t=((e,t)=>{if(Ro(t))return t.exec(e);const n=t(e);if(!n)return null;const r=[];return r.push(n.text),r.index=n.index,r.input=e,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r})(d,e.find);if(!t)return;const o=l.state.tr,c=bo({state:l.state,transaction:o}),u={from:r-(t[0].length-s.length),to:i},{commands:p,chain:f,can:m}=new xo({editor:n,state:c});null!==e.handler({state:c,range:u,match:t,commands:p,chain:f,can:m})&&o.steps.length&&(o.setMeta(a,{transform:o,from:r,to:i,text:s}),l.dispatch(o),h=!0)})),h}function Bo(e){const{editor:t,rules:n}=e,r=new zn({state:{init:()=>null,apply(e,t){const n=e.getMeta(r);return n||(e.selectionSet||e.docChanged?null:t)}},props:{handleTextInput:(e,i,s,o)=>Po({editor:t,from:i,to:s,text:o,rules:n,plugin:r}),handleDOMEvents:{compositionend:e=>(setTimeout((()=>{const{$cursor:i}=e.state.selection;i&&Po({editor:t,from:i.pos,to:i.pos,text:"",rules:n,plugin:r})})),!1)},handleKeyDown(e,i){if("Enter"!==i.key)return!1;const{$cursor:s}=e.state.selection;return!!s&&Po({editor:t,from:s.pos,to:s.pos,text:"\n",rules:n,plugin:r})}},isInputRules:!0});return r}function Fo(e){const{editor:t,state:n,from:r,to:i,rule:s}=e,{commands:o,chain:a,can:l}=new xo({editor:t,state:n}),c=[];n.doc.nodesBetween(r,i,((e,t)=>{if(!e.isTextblock||e.type.spec.code)return;const h=Math.max(r,t),d=Math.min(i,t+e.content.size);((e,t)=>{if(Ro(t))return[...e.matchAll(t)];const n=t(e);return n?n.map((t=>{const n=[];return n.push(t.text),n.index=t.index,n.input=e,n.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),n.push(t.replaceWith)),n})):[]})(e.textBetween(h-t,d-t,void 0,""),s.find).forEach((e=>{if(void 0===e.index)return;const t=h+e.index+1,r=t+e[0].length,i={from:n.tr.mapping.map(t),to:n.tr.mapping.map(r)},d=s.handler({state:n,range:i,match:e,commands:o,chain:a,can:l});c.push(d)}))}));return c.every((e=>null!==e))}function Lo(e){const{editor:t,rules:n}=e;let r=null,i=!1,s=!1;return n.map((e=>new zn({view(e){const t=t=>{var n;r=(null===(n=e.dom.parentElement)||void 0===n?void 0:n.contains(t.target))?e.dom.parentElement:null};return window.addEventListener("dragstart",t),{destroy(){window.removeEventListener("dragstart",t)}}},props:{handleDOMEvents:{drop:e=>(s=r===e.dom.parentElement,!1),paste:(e,t)=>{var n;const r=null===(n=t.clipboardData)||void 0===n?void 0:n.getData("text/html");return i=!!(null==r?void 0:r.includes("data-pm-slice")),!1}}},appendTransaction:(n,r,o)=>{const a=n[0],l="paste"===a.getMeta("uiEvent")&&!i,c="drop"===a.getMeta("uiEvent")&&!s;if(!l&&!c)return;const h=r.doc.content.findDiffStart(o.doc.content),d=r.doc.content.findDiffEnd(o.doc.content);if("number"!=typeof h||!d||h===d.b)return;const u=o.tr,p=bo({state:o,transaction:u});return Fo({editor:t,state:p,from:Math.max(h-1,0),to:d.b-1,rule:e})&&u.steps.length?u:void 0}})))}class zo{constructor(e,t){this.splittableMarks=[],this.editor=t,this.extensions=zo.resolve(e),this.schema=function(e){var t;const n=Mo(e),{nodeExtensions:r,markExtensions:i}=So(e),s=null===(t=r.find((e=>ko(e,"topNode"))))||void 0===t?void 0:t.name,o=Object.fromEntries(r.map((t=>{const r=n.filter((e=>e.type===t.name)),i={name:t.name,options:t.options,storage:t.storage},s=e.reduce(((e,n)=>{const r=ko(n,"extendNodeSchema",i);return{...e,...r?r(t):{}}}),{}),o=Do({...s,content:To(ko(t,"content",i)),marks:To(ko(t,"marks",i)),group:To(ko(t,"group",i)),inline:To(ko(t,"inline",i)),atom:To(ko(t,"atom",i)),selectable:To(ko(t,"selectable",i)),draggable:To(ko(t,"draggable",i)),code:To(ko(t,"code",i)),defining:To(ko(t,"defining",i)),isolating:To(ko(t,"isolating",i)),attrs:Object.fromEntries(r.map((e=>{var t;return[e.name,{default:null===(t=null==e?void 0:e.attribute)||void 0===t?void 0:t.default}]})))}),a=To(ko(t,"parseHTML",i));a&&(o.parseDOM=a.map((e=>No(e,r))));const l=ko(t,"renderHTML",i);l&&(o.toDOM=e=>l({node:e,HTMLAttributes:Ao(e,r)}));const c=ko(t,"renderText",i);return c&&(o.toText=c),[t.name,o]}))),a=Object.fromEntries(i.map((t=>{const r=n.filter((e=>e.type===t.name)),i={name:t.name,options:t.options,storage:t.storage},s=e.reduce(((e,n)=>{const r=ko(n,"extendMarkSchema",i);return{...e,...r?r(t):{}}}),{}),o=Do({...s,inclusive:To(ko(t,"inclusive",i)),excludes:To(ko(t,"excludes",i)),group:To(ko(t,"group",i)),spanning:To(ko(t,"spanning",i)),code:To(ko(t,"code",i)),attrs:Object.fromEntries(r.map((e=>{var t;return[e.name,{default:null===(t=null==e?void 0:e.attribute)||void 0===t?void 0:t.default}]})))}),a=To(ko(t,"parseHTML",i));a&&(o.parseDOM=a.map((e=>No(e,r))));const l=ko(t,"renderHTML",i);return l&&(o.toDOM=e=>l({mark:e,HTMLAttributes:Ao(e,r)})),[t.name,o]})));return new bt({topNode:s,nodes:o,marks:a})}(this.extensions),this.extensions.forEach((e=>{var t;this.editor.extensionStorage[e.name]=e.storage;const n={name:e.name,options:e.options,storage:e.storage,editor:this.editor,type:$o(e.name,this.schema)};if("mark"===e.type){(null===(t=To(ko(e,"keepOnSplit",n)))||void 0===t||t)&&this.splittableMarks.push(e.name)}const r=ko(e,"onBeforeCreate",n);r&&this.editor.on("beforeCreate",r);const i=ko(e,"onCreate",n);i&&this.editor.on("create",i);const s=ko(e,"onUpdate",n);s&&this.editor.on("update",s);const o=ko(e,"onSelectionUpdate",n);o&&this.editor.on("selectionUpdate",o);const a=ko(e,"onTransaction",n);a&&this.editor.on("transaction",a);const l=ko(e,"onFocus",n);l&&this.editor.on("focus",l);const c=ko(e,"onBlur",n);c&&this.editor.on("blur",c);const h=ko(e,"onDestroy",n);h&&this.editor.on("destroy",h)}))}static resolve(e){const t=zo.sort(zo.flatten(e)),n=function(e){const t=e.filter(((t,n)=>e.indexOf(t)!==n));return[...new Set(t)]}(t.map((e=>e.name)));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map((e=>`'${e}'`)).join(", ")}]. This can lead to issues.`),t}static flatten(e){return e.map((e=>{const t=ko(e,"addExtensions",{name:e.name,options:e.options,storage:e.storage});return t?[e,...this.flatten(t())]:e})).flat(10)}static sort(e){return e.sort(((e,t)=>{const n=ko(e,"priority")||100,r=ko(t,"priority")||100;return n>r?-1:n<r?1:0}))}get commands(){return this.extensions.reduce(((e,t)=>{const n=ko(t,"addCommands",{name:t.name,options:t.options,storage:t.storage,editor:this.editor,type:$o(t.name,this.schema)});return n?{...e,...n()}:e}),{})}get plugins(){const{editor:e}=this,t=zo.sort([...this.extensions].reverse()),n=[],r=[],i=t.map((t=>{const i={name:t.name,options:t.options,storage:t.storage,editor:e,type:$o(t.name,this.schema)},s=[],o=ko(t,"addKeyboardShortcuts",i);let a={};if("mark"===t.type&&t.config.exitable&&(a.ArrowRight=()=>Oa.handleExit({editor:e,mark:t})),o){const t=Object.fromEntries(Object.entries(o()).map((([t,n])=>[t,()=>n({editor:e})])));a={...a,...t}}const l=new zn({props:{handleKeyDown:ao(a)}});s.push(l);const c=ko(t,"addInputRules",i);Io(t,e.options.enableInputRules)&&c&&n.push(...c());const h=ko(t,"addPasteRules",i);Io(t,e.options.enablePasteRules)&&h&&r.push(...h());const d=ko(t,"addProseMirrorPlugins",i);if(d){const e=d();s.push(...e)}return s})).flat();return[Bo({editor:e,rules:n}),...Lo({editor:e,rules:r}),...i]}get attributes(){return Mo(this.extensions)}get nodeViews(){const{editor:e}=this,{nodeExtensions:t}=So(this.extensions);return Object.fromEntries(t.filter((e=>!!ko(e,"addNodeView"))).map((t=>{const n=this.attributes.filter((e=>e.type===t.name)),r={name:t.name,options:t.options,storage:t.storage,editor:e,type:Oo(t.name,this.schema)},i=ko(t,"addNodeView",r);if(!i)return[];return[t.name,(r,s,o,a)=>{const l=Ao(r,n);return i()({editor:e,node:r,getPos:o,decorations:a,HTMLAttributes:l,extension:t})}]})))}}function Vo(e){return"Object"===function(e){return Object.prototype.toString.call(e).slice(8,-1)}(e)&&(e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype)}function jo(e,t){const n={...e};return Vo(e)&&Vo(t)&&Object.keys(t).forEach((r=>{Vo(t[r])?r in e?n[r]=jo(e[r],t[r]):Object.assign(n,{[r]:t[r]}):Object.assign(n,{[r]:t[r]})})),n}class _o{constructor(e={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=To(ko(this,"addOptions",{name:this.name}))),this.storage=To(ko(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new _o(e)}configure(e={}){const t=this.extend();return t.options=jo(this.options,e),t.storage=To(ko(t,"addStorage",{name:t.name,options:t.options})),t}extend(e={}){const t=new _o(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=To(ko(t,"addOptions",{name:t.name})),t.storage=To(ko(t,"addStorage",{name:t.name,options:t.options})),t}}function Wo(e,t,n){const{from:r,to:i}=t,{blockSeparator:s="\n\n",textSerializers:o={}}=n||{};let a="",l=!0;return e.nodesBetween(r,i,((e,n,c,h)=>{var d;const u=null==o?void 0:o[e.type.name];u?(e.isBlock&&!l&&(a+=s,l=!0),c&&(a+=u({node:e,pos:n,parent:c,index:h,range:t}))):e.isText?(a+=null===(d=null==e?void 0:e.text)||void 0===d?void 0:d.slice(Math.max(r,n)-n,i-n),l=!1):e.isBlock&&!l&&(a+=s,l=!0)})),a}function Ho(e){return Object.fromEntries(Object.entries(e.nodes).filter((([,e])=>e.spec.toText)).map((([e,t])=>[e,t.spec.toText])))}const Ko=_o.create({name:"clipboardTextSerializer",addProseMirrorPlugins(){return[new zn({key:new _n("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:e}=this,{state:t,schema:n}=e,{doc:r,selection:i}=t,{ranges:s}=i,o=Math.min(...s.map((e=>e.$from.pos))),a=Math.max(...s.map((e=>e.$to.pos)));return Wo(r,{from:o,to:a},{textSerializers:Ho(n)})}}})]}});function qo(e,t,n={strict:!0}){const r=Object.keys(t);return!r.length||r.every((r=>n.strict?t[r]===e[r]:Ro(t[r])?t[r].test(e[r]):t[r]===e[r]))}function Jo(e,t,n={}){return e.find((e=>e.type===t&&qo(e.attrs,n)))}function Uo(e,t,n={}){return!!Jo(e,t,n)}function Go(e,t,n={}){if(!e||!t)return;let r=e.parent.childAfter(e.parentOffset);if(e.parentOffset===r.offset&&0!==r.offset&&(r=e.parent.childBefore(e.parentOffset)),!r.node)return;const i=Jo([...r.node.marks],t,n);if(!i)return;let s=r.index,o=e.start()+r.offset,a=s+1,l=o+r.node.nodeSize;for(Jo([...r.node.marks],t,n);s>0&&i.isInSet(e.parent.child(s-1).marks);)s-=1,o-=e.parent.child(s).nodeSize;for(;a<e.parent.childCount&&Uo([...e.parent.child(a).marks],t,n);)l+=e.parent.child(a).nodeSize,a+=1;return{from:o,to:l}}function Yo(e,t){if("string"==typeof e){if(!t.marks[e])throw Error(`There is no mark type named '${e}'. Maybe you forgot to add the extension?`);return t.marks[e]}return e}function Xo(e){return e instanceof Mn}function Zo(e=0,t=0,n=0){return Math.min(Math.max(e,t),n)}function Qo(e,t=null){if(!t)return null;const n=bn.atStart(e),r=bn.atEnd(e);if("start"===t||!0===t)return n;if("end"===t)return r;const i=n.from,s=r.to;return"all"===t?Mn.create(e,Zo(0,i,s),Zo(e.content.size,i,s)):Mn.create(e,Zo(t,i,s),Zo(t,i,s))}function ea(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function ta(e){const t=`<body>${e}</body>`;return(new window.DOMParser).parseFromString(t,"text/html").body}function na(e,t,n){if(n={slice:!0,parseOptions:{},...n},"object"==typeof e&&null!==e)try{return Array.isArray(e)?$e.fromArray(e.map((e=>t.nodeFromJSON(e)))):t.nodeFromJSON(e)}catch(r){return console.warn("[tiptap warn]: Invalid content.","Passed value:",e,"Error:",r),na("",t,n)}if("string"==typeof e){const r=kt.fromSchema(t);return n.slice?r.parseSlice(ta(e),n.parseOptions).content:r.parse(ta(e),n.parseOptions)}return na("",t,n)}function ra(){return"undefined"!=typeof navigator&&/Mac/.test(navigator.platform)}function ia(e,t,n={}){const{from:r,to:i,empty:s}=e.selection,o=t?Oo(t,e.schema):null,a=[];e.doc.nodesBetween(r,i,((e,t)=>{if(e.isText)return;const n=Math.max(r,t),s=Math.min(i,t+e.nodeSize);a.push({node:e,from:n,to:s})}));const l=i-r,c=a.filter((e=>!o||o.name===e.node.type.name)).filter((e=>qo(e.node.attrs,n,{strict:!1})));if(s)return!!c.length;return c.reduce(((e,t)=>e+t.to-t.from),0)>=l}function sa(e,t){return t.nodes[e]?"node":t.marks[e]?"mark":null}function oa(e,t){const n="string"==typeof t?[t]:t;return Object.keys(e).reduce(((t,r)=>(n.includes(r)||(t[r]=e[r]),t)),{})}function aa(e,t,n={}){return na(e,t,{slice:!1,parseOptions:n})}function la(e){return t=>function(e,t){for(let n=e.depth;n>0;n-=1){const r=e.node(n);if(t(r))return{pos:n>0?e.before(n):0,start:e.start(n),depth:n,node:r}}}(t.$from,e)}function ca(e,t){const n=Yo(t,e.schema),{from:r,to:i,empty:s}=e.selection,o=[];s?(e.storedMarks&&o.push(...e.storedMarks),o.push(...e.selection.$head.marks())):e.doc.nodesBetween(r,i,(e=>{o.push(...e.marks)}));const a=o.find((e=>e.type.name===n.name));return a?{...a.attrs}:{}}function ha(e,t){const n=sa("string"==typeof t?t:t.name,e.schema);return"node"===n?function(e,t){const n=Oo(t,e.schema),{from:r,to:i}=e.selection,s=[];e.doc.nodesBetween(r,i,(e=>{s.push(e)}));const o=s.reverse().find((e=>e.type.name===n.name));return o?{...o.attrs}:{}}(e,t):"mark"===n?ca(e,t):{}}function da(e,t,n={}){const{empty:r,ranges:i}=e.selection,s=t?Yo(t,e.schema):null;if(r)return!!(e.storedMarks||e.selection.$from.marks()).filter((e=>!s||s.name===e.type.name)).find((e=>qo(e.attrs,n,{strict:!1})));let o=0;const a=[];if(i.forEach((({$from:t,$to:n})=>{const r=t.pos,i=n.pos;e.doc.nodesBetween(r,i,((e,t)=>{if(!e.isText&&!e.marks.length)return;const n=Math.max(r,t),s=Math.min(i,t+e.nodeSize);o+=s-n,a.push(...e.marks.map((e=>({mark:e,from:n,to:s}))))}))})),0===o)return!1;const l=a.filter((e=>!s||s.name===e.mark.type.name)).filter((e=>qo(e.mark.attrs,n,{strict:!1}))).reduce(((e,t)=>e+t.to-t.from),0),c=a.filter((e=>!s||e.mark.type!==s&&e.mark.type.excludes(s))).reduce(((e,t)=>e+t.to-t.from),0);return(l>0?l+c:l)>=o}function ua(e,t){const{nodeExtensions:n}=So(t),r=n.find((t=>t.name===e));if(!r)return!1;const i=To(ko(r,"group",{name:r.name,options:r.options,storage:r.storage}));return"string"==typeof i&&i.split(" ").includes("list")}function pa(e,t,n){return Object.fromEntries(Object.entries(n).filter((([n])=>{const r=e.find((e=>e.type===t&&e.name===n));return!!r&&r.attribute.keepOnSplit})))}function fa(e,t){const n=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();if(n){const r=n.filter((e=>null==t?void 0:t.includes(e.type.name)));e.tr.ensureMarks(r)}}const ma=(e,t)=>{const n=la((e=>e.type===t))(e.selection);if(!n)return!0;const r=e.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(void 0===r)return!0;const i=e.doc.nodeAt(r);return n.node.type!==(null==i?void 0:i.type)||!rn(e.doc,n.pos)||(e.join(n.pos),!0)},ga=(e,t)=>{const n=la((e=>e.type===t))(e.selection);if(!n)return!0;const r=e.doc.resolve(n.start).after(n.depth);if(void 0===r)return!0;const i=e.doc.nodeAt(r);return n.node.type!==(null==i?void 0:i.type)||!rn(e.doc,r)||(e.join(r),!0)};var ya=Object.freeze({__proto__:null,blur:()=>({editor:e,view:t})=>(requestAnimationFrame((()=>{var n;e.isDestroyed||(t.dom.blur(),null===(n=null===window||void 0===window?void 0:window.getSelection())||void 0===n||n.removeAllRanges())})),!0),clearContent:(e=!1)=>({commands:t})=>t.setContent("",e),clearNodes:()=>({state:e,tr:t,dispatch:n})=>{const{selection:r}=t,{ranges:i}=r;return!n||(i.forEach((({$from:n,$to:r})=>{e.doc.nodesBetween(n.pos,r.pos,((e,n)=>{if(e.type.isText)return;const{doc:r,mapping:i}=t,s=r.resolve(i.map(n)),o=r.resolve(i.map(n+e.nodeSize)),a=s.blockRange(o);if(!a)return;const l=Qt(a);if(e.type.isTextblock){const{defaultType:e}=s.parent.contentMatchAt(s.index());t.setNodeMarkup(a.start,e)}(l||0===l)&&t.lift(a,l)}))})),!0)},command:e=>t=>e(t),createParagraphNear:()=>({state:e,dispatch:t})=>((e,t)=>{let n=e.selection,{$from:r,$to:i}=n;if(n instanceof En||r.parent.inlineContent||i.parent.inlineContent)return!1;let s=uo(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return!1;if(t){let n=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,o=e.tr.insert(n,s.createAndFill());o.setSelection(Mn.create(o.doc,n+1)),t(o.scrollIntoView())}return!0})(e,t),deleteNode:e=>({tr:t,state:n,dispatch:r})=>{const i=Oo(e,n.schema),s=t.selection.$anchor;for(let e=s.depth;e>0;e-=1){if(s.node(e).type===i){if(r){const n=s.before(e),r=s.after(e);t.delete(n,r).scrollIntoView()}return!0}}return!1},deleteRange:e=>({tr:t,dispatch:n})=>{const{from:r,to:i}=e;return n&&t.delete(r,i),!0},deleteSelection:()=>({state:e,dispatch:t})=>((e,t)=>!e.selection.empty&&(t&&t(e.tr.deleteSelection().scrollIntoView()),!0))(e,t),enter:()=>({commands:e})=>e.keyboardShortcut("Enter"),exitCode:()=>({state:e,dispatch:t})=>((e,t)=>{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),s=n.indexAfter(-1),o=uo(i.contentMatchAt(s));if(!o||!i.canReplaceWith(s,s,o))return!1;if(t){let r=n.after(),i=e.tr.replaceWith(r,r,o.createAndFill());i.setSelection(bn.near(i.doc.resolve(r),1)),t(i.scrollIntoView())}return!0})(e,t),extendMarkRange:(e,t={})=>({tr:n,state:r,dispatch:i})=>{const s=Yo(e,r.schema),{doc:o,selection:a}=n,{$from:l,from:c,to:h}=a;if(i){const e=Go(l,s,t);if(e&&e.from<=c&&e.to>=h){const t=Mn.create(o,e.from,e.to);n.setSelection(t)}}return!0},first:e=>t=>{const n="function"==typeof e?e(t):e;for(let e=0;e<n.length;e+=1)if(n[e](t))return!0;return!1},focus:(e=null,t={})=>({editor:n,view:r,tr:i,dispatch:s})=>{t={scrollIntoView:!0,...t};const o=()=>{ea()&&r.dom.focus(),requestAnimationFrame((()=>{n.isDestroyed||(r.focus(),(null==t?void 0:t.scrollIntoView)&&n.commands.scrollIntoView())}))};if(r.hasFocus()&&null===e||!1===e)return!0;if(s&&null===e&&!Xo(n.state.selection))return o(),!0;const a=Qo(i.doc,e)||n.state.selection,l=n.state.selection.eq(a);return s&&(l||i.setSelection(a),l&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},forEach:(e,t)=>n=>e.every(((e,r)=>t(e,{...n,index:r}))),insertContent:(e,t)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},e,t),insertContentAt:(e,t,n)=>({tr:r,dispatch:i,editor:s})=>{if(i){n={parseOptions:{},updateSelection:!0,...n};const i=na(t,s.schema,{parseOptions:{preserveWhitespace:"full",...n.parseOptions}});if("<>"===i.toString())return!0;let{from:o,to:a}="number"==typeof e?{from:e,to:e}:e,l=!0,c=!0;if((i.toString().startsWith("<")?i:[i]).forEach((e=>{e.check(),l=!!l&&(e.isText&&0===e.marks.length),c=!!c&&e.isBlock})),o===a&&c){const{parent:e}=r.doc.resolve(o);e.isTextblock&&!e.type.spec.code&&!e.childCount&&(o-=1,a+=1)}l?r.insertText(t,o,a):r.replaceWith(o,a,i),n.updateSelection&&function(e,t,n){const r=e.steps.length-1;if(r<t)return;const i=e.steps[r];if(!(i instanceof Gt||i instanceof Yt))return;const s=e.mapping.maps[r];let o=0;s.forEach(((e,t,n,r)=>{0===o&&(o=r)})),e.setSelection(bn.near(e.doc.resolve(o),n))}(r,r.steps.length-1,-1)}return!0},joinBackward:()=>({state:e,dispatch:t})=>((e,t,n)=>{let{$cursor:r}=e.selection;if(!r||(n?!n.endOfTextblock("backward",e):r.parentOffset>0))return!1;let i=co(r);if(!i){let n=r.blockRange(),i=n&&Qt(n);return null!=i&&(t&&t(e.tr.lift(n,i).scrollIntoView()),!0)}let s=i.nodeBefore;if(!s.type.spec.isolating&&po(e,i,t))return!0;if(0==r.parent.content.size&&(lo(s,"end")||Cn.isSelectable(s))){let n=on(e.doc,r.before(),r.after(),Le.empty);if(n&&n.slice.size<n.to-n.from){if(t){let r=e.tr.step(n);r.setSelection(lo(s,"end")?bn.findFrom(r.doc.resolve(r.mapping.map(i.pos,-1)),-1):Cn.create(r.doc,i.pos-s.nodeSize)),t(r.scrollIntoView())}return!0}}return!(!s.isAtom||i.depth!=r.depth-1||(t&&t(e.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView()),0))})(e,t),joinForward:()=>({state:e,dispatch:t})=>((e,t,n)=>{let{$cursor:r}=e.selection;if(!r||(n?!n.endOfTextblock("forward",e):r.parentOffset<r.parent.content.size))return!1;let i=ho(r);if(!i)return!1;let s=i.nodeAfter;if(po(e,i,t))return!0;if(0==r.parent.content.size&&(lo(s,"start")||Cn.isSelectable(s))){let n=on(e.doc,r.before(),r.after(),Le.empty);if(n&&n.slice.size<n.to-n.from){if(t){let r=e.tr.step(n);r.setSelection(lo(s,"start")?bn.findFrom(r.doc.resolve(r.mapping.map(i.pos)),1):Cn.create(r.doc,r.mapping.map(i.pos))),t(r.scrollIntoView())}return!0}}return!(!s.isAtom||i.depth!=r.depth-1||(t&&t(e.tr.delete(i.pos,i.pos+s.nodeSize).scrollIntoView()),0))})(e,t),keyboardShortcut:e=>({editor:t,view:n,tr:r,dispatch:i})=>{const s=function(e){const t=e.split(/-(?!$)/);let n,r,i,s,o=t[t.length-1];"Space"===o&&(o=" ");for(let e=0;e<t.length-1;e+=1){const o=t[e];if(/^(cmd|meta|m)$/i.test(o))s=!0;else if(/^a(lt)?$/i.test(o))n=!0;else if(/^(c|ctrl|control)$/i.test(o))r=!0;else if(/^s(hift)?$/i.test(o))i=!0;else{if(!/^mod$/i.test(o))throw new Error(`Unrecognized modifier name: ${o}`);ea()||ra()?s=!0:r=!0}}return n&&(o=`Alt-${o}`),r&&(o=`Ctrl-${o}`),s&&(o=`Meta-${o}`),i&&(o=`Shift-${o}`),o}(e).split(/-(?!$)/),o=s.find((e=>!["Alt","Ctrl","Meta","Shift"].includes(e))),a=new KeyboardEvent("keydown",{key:"Space"===o?" ":o,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.includes("Shift"),bubbles:!0,cancelable:!0}),l=t.captureTransaction((()=>{n.someProp("handleKeyDown",(e=>e(n,a)))}));return null==l||l.steps.forEach((e=>{const t=e.map(r.mapping);t&&i&&r.maybeStep(t)})),!0},lift:(e,t={})=>({state:n,dispatch:r})=>!!ia(n,Oo(e,n.schema),t)&&((e,t)=>{let{$from:n,$to:r}=e.selection,i=n.blockRange(r),s=i&&Qt(i);return null!=s&&(t&&t(e.tr.lift(i,s).scrollIntoView()),!0)})(n,r),liftEmptyBlock:()=>({state:e,dispatch:t})=>((e,t)=>{let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let r=n.before();if(nn(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),i=r&&Qt(r);return null!=i&&(t&&t(e.tr.lift(r,i).scrollIntoView()),!0)})(e,t),liftListItem:e=>({state:t,dispatch:n})=>wo(Oo(e,t.schema))(t,n),newlineInCode:()=>({state:e,dispatch:t})=>((e,t)=>{let{$head:n,$anchor:r}=e.selection;return!(!n.parent.type.spec.code||!n.sameParent(r)||(t&&t(e.tr.insertText("\n").scrollIntoView()),0))})(e,t),resetAttributes:(e,t)=>({tr:n,state:r,dispatch:i})=>{let s=null,o=null;const a=sa("string"==typeof e?e:e.name,r.schema);return!!a&&("node"===a&&(s=Oo(e,r.schema)),"mark"===a&&(o=Yo(e,r.schema)),i&&n.selection.ranges.forEach((e=>{r.doc.nodesBetween(e.$from.pos,e.$to.pos,((e,r)=>{s&&s===e.type&&n.setNodeMarkup(r,void 0,oa(e.attrs,t)),o&&e.marks.length&&e.marks.forEach((i=>{o===i.type&&n.addMark(r,r+e.nodeSize,o.create(oa(i.attrs,t)))}))}))})),!0)},scrollIntoView:()=>({tr:e,dispatch:t})=>(t&&e.scrollIntoView(),!0),selectAll:()=>({tr:e,commands:t})=>t.setTextSelection({from:0,to:e.doc.content.size}),selectNodeBackward:()=>({state:e,dispatch:t})=>((e,t,n)=>{let{$head:r,empty:i}=e.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",e):r.parentOffset>0)return!1;s=co(r)}let o=s&&s.nodeBefore;return!(!o||!Cn.isSelectable(o)||(t&&t(e.tr.setSelection(Cn.create(e.doc,s.pos-o.nodeSize)).scrollIntoView()),0))})(e,t),selectNodeForward:()=>({state:e,dispatch:t})=>((e,t,n)=>{let{$head:r,empty:i}=e.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",e):r.parentOffset<r.parent.content.size)return!1;s=ho(r)}let o=s&&s.nodeAfter;return!(!o||!Cn.isSelectable(o)||(t&&t(e.tr.setSelection(Cn.create(e.doc,s.pos)).scrollIntoView()),0))})(e,t),selectParentNode:()=>({state:e,dispatch:t})=>((e,t)=>{let n,{$from:r,to:i}=e.selection,s=r.sharedDepth(i);return 0!=s&&(n=r.before(s),t&&t(e.tr.setSelection(Cn.create(e.doc,n))),!0)})(e,t),selectTextblockEnd:()=>({state:e,dispatch:t})=>go(e,t),selectTextblockStart:()=>({state:e,dispatch:t})=>mo(e,t),setContent:(e,t=!1,n={})=>({tr:r,editor:i,dispatch:s})=>{const{doc:o}=r,a=aa(e,i.schema,n);return s&&r.replaceWith(0,o.content.size,a).setMeta("preventUpdate",!t),!0},setMark:(e,t={})=>({tr:n,state:r,dispatch:i})=>{const{selection:s}=n,{empty:o,ranges:a}=s,l=Yo(e,r.schema);if(i)if(o){const e=ca(r,l);n.addStoredMark(l.create({...e,...t}))}else a.forEach((e=>{const i=e.$from.pos,s=e.$to.pos;r.doc.nodesBetween(i,s,((e,r)=>{const o=Math.max(r,i),a=Math.min(r+e.nodeSize,s);e.marks.find((e=>e.type===l))?e.marks.forEach((e=>{l===e.type&&n.addMark(o,a,l.create({...e.attrs,...t}))})):n.addMark(o,a,l.create(t))}))}));return function(e,t,n){var r;const{selection:i}=t;let s=null;if(Xo(i)&&(s=i.$cursor),s){const t=null!==(r=e.storedMarks)&&void 0!==r?r:s.marks();return!!n.isInSet(t)||!t.some((e=>e.type.excludes(n)))}const{ranges:o}=i;return o.some((({$from:t,$to:r})=>{let i=0===t.depth&&e.doc.inlineContent&&e.doc.type.allowsMarkType(n);return e.doc.nodesBetween(t.pos,r.pos,((e,t,r)=>{if(i)return!1;if(e.isInline){const t=!r||r.type.allowsMarkType(n),s=!!n.isInSet(e.marks)||!e.marks.some((e=>e.type.excludes(n)));i=t&&s}return!i})),i}))}(r,n,l)},setMeta:(e,t)=>({tr:n})=>(n.setMeta(e,t),!0),setNode:(e,t={})=>({state:n,dispatch:r,chain:i})=>{const s=Oo(e,n.schema);return s.isTextblock?i().command((({commands:e})=>!!yo(s,t)(n)||e.clearNodes())).command((({state:e})=>yo(s,t)(e,r))).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},setNodeSelection:e=>({tr:t,dispatch:n})=>{if(n){const{doc:n}=t,r=Zo(e,0,n.content.size),i=Cn.create(n,r);t.setSelection(i)}return!0},setTextSelection:e=>({tr:t,dispatch:n})=>{if(n){const{doc:n}=t,{from:r,to:i}="number"==typeof e?{from:e,to:e}:e,s=Mn.atStart(n).from,o=Mn.atEnd(n).to,a=Zo(r,s,o),l=Zo(i,s,o),c=Mn.create(n,a,l);t.setSelection(c)}return!0},sinkListItem:e=>({state:t,dispatch:n})=>{const r=Oo(e,t.schema);return(i=r,function(e,t){let{$from:n,$to:r}=e.selection,s=n.blockRange(r,(e=>e.childCount>0&&e.firstChild.type==i));if(!s)return!1;let o=s.startIndex;if(0==o)return!1;let a=s.parent,l=a.child(o-1);if(l.type!=i)return!1;if(t){let n=l.lastChild&&l.lastChild.type==a.type,r=$e.from(n?i.create():null),o=new Le($e.from(i.create(null,$e.from(a.type.create(null,r)))),n?3:1,0),c=s.start,h=s.end;t(e.tr.step(new Yt(c-(n?3:1),h,c,h,o,1,!0)).scrollIntoView())}return!0})(t,n);var i},splitBlock:({keepMarks:e=!0}={})=>({tr:t,state:n,dispatch:r,editor:i})=>{const{selection:s,doc:o}=t,{$from:a,$to:l}=s,c=pa(i.extensionManager.attributes,a.node().type.name,a.node().attrs);if(s instanceof Cn&&s.node.isBlock)return!(!a.parentOffset||!nn(o,a.pos))&&(r&&(e&&fa(n,i.extensionManager.splittableMarks),t.split(a.pos).scrollIntoView()),!0);if(!a.parent.isBlock)return!1;if(r){const r=l.parentOffset===l.parent.content.size;s instanceof Mn&&t.deleteSelection();const o=0===a.depth?void 0:function(e){for(let t=0;t<e.edgeCount;t+=1){const{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}(a.node(-1).contentMatchAt(a.indexAfter(-1)));let h=r&&o?[{type:o,attrs:c}]:void 0,d=nn(t.doc,t.mapping.map(a.pos),1,h);if(h||d||!nn(t.doc,t.mapping.map(a.pos),1,o?[{type:o}]:void 0)||(d=!0,h=o?[{type:o,attrs:c}]:void 0),d&&(t.split(t.mapping.map(a.pos),1,h),o&&!r&&!a.parentOffset&&a.parent.type!==o)){const e=t.mapping.map(a.before()),n=t.doc.resolve(e);a.node(-1).canReplaceWith(n.index(),n.index()+1,o)&&t.setNodeMarkup(t.mapping.map(a.before()),o)}e&&fa(n,i.extensionManager.splittableMarks),t.scrollIntoView()}return!0},splitListItem:e=>({tr:t,state:n,dispatch:r,editor:i})=>{var s;const o=Oo(e,n.schema),{$from:a,$to:l}=n.selection,c=n.selection.node;if(c&&c.isBlock||a.depth<2||!a.sameParent(l))return!1;const h=a.node(-1);if(h.type!==o)return!1;const d=i.extensionManager.attributes;if(0===a.parent.content.size&&a.node(-1).childCount===a.indexAfter(-1)){if(2===a.depth||a.node(-3).type!==o||a.index(-2)!==a.node(-2).childCount-1)return!1;if(r){let e=$e.empty;const n=a.index(-1)?1:a.index(-2)?2:3;for(let t=a.depth-n;t>=a.depth-3;t-=1)e=$e.from(a.node(t).copy(e));const r=a.indexAfter(-1)<a.node(-2).childCount?1:a.indexAfter(-2)<a.node(-3).childCount?2:3,i=pa(d,a.node().type.name,a.node().attrs),l=(null===(s=o.contentMatch.defaultType)||void 0===s?void 0:s.createAndFill(i))||void 0;e=e.append($e.from(o.createAndFill(null,l)||void 0));const c=a.before(a.depth-(n-1));t.replace(c,a.after(-r),new Le(e,4-n,0));let h=-1;t.doc.nodesBetween(c,t.doc.content.size,((e,t)=>{if(h>-1)return!1;e.isTextblock&&0===e.content.size&&(h=t+1)})),h>-1&&t.setSelection(Mn.near(t.doc.resolve(h))),t.scrollIntoView()}return!0}const u=l.pos===a.end()?h.contentMatchAt(0).defaultType:null,p=pa(d,h.type.name,h.attrs),f=pa(d,a.node().type.name,a.node().attrs);t.delete(a.pos,l.pos);const m=u?[{type:o,attrs:p},{type:u,attrs:f}]:[{type:o,attrs:p}];return!!nn(t.doc,a.pos,2)&&(r&&t.split(a.pos,2,m).scrollIntoView(),!0)},toggleList:(e,t)=>({editor:n,tr:r,state:i,dispatch:s,chain:o,commands:a,can:l})=>{const{extensions:c}=n.extensionManager,h=Oo(e,i.schema),d=Oo(t,i.schema),{selection:u}=i,{$from:p,$to:f}=u,m=p.blockRange(f);if(!m)return!1;const g=la((e=>ua(e.type.name,c)))(u);if(m.depth>=1&&g&&m.depth-g.depth<=1){if(g.node.type===h)return a.liftListItem(d);if(ua(g.node.type.name,c)&&h.validContent(g.node.content)&&s)return o().command((()=>(r.setNodeMarkup(g.pos,h),!0))).command((()=>ma(r,h))).command((()=>ga(r,h))).run()}return o().command((()=>!!l().wrapInList(h)||a.clearNodes())).wrapInList(h).command((()=>ma(r,h))).command((()=>ga(r,h))).run()},toggleMark:(e,t={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:s=!1}=n,o=Yo(e,r.schema);return da(r,o,t)?i.unsetMark(o,{extendEmptyMarkRange:s}):i.setMark(o,t)},toggleNode:(e,t,n={})=>({state:r,commands:i})=>{const s=Oo(e,r.schema),o=Oo(t,r.schema);return ia(r,s,n)?i.setNode(o):i.setNode(s,n)},toggleWrap:(e,t={})=>({state:n,commands:r})=>{const i=Oo(e,n.schema);return ia(n,i,t)?r.lift(i):r.wrapIn(i,t)},undoInputRule:()=>({state:e,dispatch:t})=>{const n=e.plugins;for(let r=0;r<n.length;r+=1){const i=n[r];let s;if(i.spec.isInputRules&&(s=i.getState(e))){if(t){const t=e.tr,n=s.transform;for(let e=n.steps.length-1;e>=0;e-=1)t.step(n.steps[e].invert(n.docs[e]));if(s.text){const n=t.doc.resolve(s.from).marks();t.replaceWith(s.from,s.to,e.schema.text(s.text,n))}else t.delete(s.from,s.to)}return!0}}return!1},unsetAllMarks:()=>({tr:e,dispatch:t})=>{const{selection:n}=e,{empty:r,ranges:i}=n;return r||t&&i.forEach((t=>{e.removeMark(t.$from.pos,t.$to.pos)})),!0},unsetMark:(e,t={})=>({tr:n,state:r,dispatch:i})=>{var s;const{extendEmptyMarkRange:o=!1}=t,{selection:a}=n,l=Yo(e,r.schema),{$from:c,empty:h,ranges:d}=a;if(!i)return!0;if(h&&o){let{from:e,to:t}=a;const r=null===(s=c.marks().find((e=>e.type===l)))||void 0===s?void 0:s.attrs,i=Go(c,l,r);i&&(e=i.from,t=i.to),n.removeMark(e,t,l)}else d.forEach((e=>{n.removeMark(e.$from.pos,e.$to.pos,l)}));return n.removeStoredMark(l),!0},updateAttributes:(e,t={})=>({tr:n,state:r,dispatch:i})=>{let s=null,o=null;const a=sa("string"==typeof e?e:e.name,r.schema);return!!a&&("node"===a&&(s=Oo(e,r.schema)),"mark"===a&&(o=Yo(e,r.schema)),i&&n.selection.ranges.forEach((e=>{const i=e.$from.pos,a=e.$to.pos;r.doc.nodesBetween(i,a,((e,r)=>{s&&s===e.type&&n.setNodeMarkup(r,void 0,{...e.attrs,...t}),o&&e.marks.length&&e.marks.forEach((s=>{if(o===s.type){const l=Math.max(r,i),c=Math.min(r+e.nodeSize,a);n.addMark(l,c,o.create({...s.attrs,...t}))}}))}))})),!0)},wrapIn:(e,t={})=>({state:n,dispatch:r})=>function(e,t=null){return function(n,r){let{$from:i,$to:s}=n.selection,o=i.blockRange(s),a=o&&en(o,e,t);return!!a&&(r&&r(n.tr.wrap(o,a).scrollIntoView()),!0)}}(Oo(e,n.schema),t)(n,r),wrapInList:(e,t={})=>({state:n,dispatch:r})=>vo(Oo(e,n.schema),t)(n,r)});const va=_o.create({name:"commands",addCommands:()=>({...ya})}),wa=_o.create({name:"editable",addProseMirrorPlugins(){return[new zn({key:new _n("editable"),props:{editable:()=>this.editor.options.editable}})]}}),ba=_o.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:e}=this;return[new zn({key:new _n("focusEvents"),props:{handleDOMEvents:{focus:(t,n)=>{e.isFocused=!0;const r=e.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return t.dispatch(r),!1},blur:(t,n)=>{e.isFocused=!1;const r=e.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return t.dispatch(r),!1}}}})]}}),xa=_o.create({name:"keymap",addKeyboardShortcuts(){const e=()=>this.editor.commands.first((({commands:e})=>[()=>e.undoInputRule(),()=>e.command((({tr:t})=>{const{selection:n,doc:r}=t,{empty:i,$anchor:s}=n,{pos:o,parent:a}=s,l=bn.atStart(r).from===o;return!(!(i&&l&&a.type.isTextblock)||a.textContent.length)&&e.clearNodes()})),()=>e.deleteSelection(),()=>e.joinBackward(),()=>e.selectNodeBackward()])),t=()=>this.editor.commands.first((({commands:e})=>[()=>e.deleteSelection(),()=>e.joinForward(),()=>e.selectNodeForward()])),n={Enter:()=>this.editor.commands.first((({commands:e})=>[()=>e.newlineInCode(),()=>e.createParagraphNear(),()=>e.liftEmptyBlock(),()=>e.splitBlock()])),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:e,"Mod-Backspace":e,"Shift-Backspace":e,Delete:t,"Mod-Delete":t,"Mod-a":()=>this.editor.commands.selectAll()},r={...n},i={...n,"Ctrl-h":e,"Alt-Backspace":e,"Ctrl-d":t,"Ctrl-Alt-Backspace":t,"Alt-Delete":t,"Alt-d":t,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return ea()||ra()?i:r},addProseMirrorPlugins(){return[new zn({key:new _n("clearDocument"),appendTransaction:(e,t,n)=>{if(!(e.some((e=>e.docChanged))&&!t.doc.eq(n.doc)))return;const{empty:r,from:i,to:s}=t.selection,o=bn.atStart(t.doc).from,a=bn.atEnd(t.doc).to,l=i===o&&s===a,c=0===n.doc.textBetween(0,n.doc.content.size," "," ").length;if(r||!l||!c)return;const h=n.tr,d=bo({state:n,transaction:h}),{commands:u}=new xo({editor:this.editor,state:d});return u.clearNodes(),h.steps.length?h:void 0}})]}}),ka=_o.create({name:"tabindex",addProseMirrorPlugins(){return[new zn({key:new _n("tabindex"),props:{attributes:this.editor.isEditable?{tabindex:"0"}:{}}})]}});var Sa=Object.freeze({__proto__:null,ClipboardTextSerializer:Ko,Commands:va,Editable:wa,FocusEvents:ba,Keymap:xa,Tabindex:ka});class Ma extends class{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){const n=this.callbacks[e];return n&&n.forEach((e=>e.apply(this,t))),this}off(e,t){const n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter((e=>e!==t)):delete this.callbacks[e]),this}removeAllListeners(){this.callbacks={}}}{constructor(e={}){super(),this.isFocused=!1,this.extensionStorage={},this.options={element:document.createElement("div"),content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.createView(),this.injectCSS(),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),window.setTimeout((()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}))}),0)}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&document&&(this.css=function(e,t){const n=document.querySelector("style[data-tiptap-style]");if(null!==n)return n;const r=document.createElement("style");return t&&r.setAttribute("nonce",t),r.setAttribute("data-tiptap-style",""),r.innerHTML=e,document.getElementsByTagName("head")[0].appendChild(r),r}('.ProseMirror {\n position: relative;\n}\n\n.ProseMirror {\n word-wrap: break-word;\n white-space: pre-wrap;\n white-space: break-spaces;\n -webkit-font-variant-ligatures: none;\n font-variant-ligatures: none;\n font-feature-settings: "liga" 0; /* the above doesn\'t seem to work in Edge */\n}\n\n.ProseMirror [contenteditable="false"] {\n white-space: normal;\n}\n\n.ProseMirror [contenteditable="false"] [contenteditable="true"] {\n white-space: pre-wrap;\n}\n\n.ProseMirror pre {\n white-space: pre-wrap;\n}\n\nimg.ProseMirror-separator {\n display: inline !important;\n border: none !important;\n margin: 0 !important;\n width: 1px !important;\n height: 1px !important;\n}\n\n.ProseMirror-gapcursor {\n display: none;\n pointer-events: none;\n position: absolute;\n margin: 0;\n}\n\n.ProseMirror-gapcursor:after {\n content: "";\n display: block;\n position: absolute;\n top: -2px;\n width: 20px;\n border-top: 1px solid black;\n animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;\n}\n\n@keyframes ProseMirror-cursor-blink {\n to {\n visibility: hidden;\n }\n}\n\n.ProseMirror-hideselection *::selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection *::-moz-selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection * {\n caret-color: transparent;\n}\n\n.ProseMirror-focused .ProseMirror-gapcursor {\n display: block;\n}\n\n.tippy-box[data-animation=fade][data-state=hidden] {\n opacity: 0\n}',this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},this.view&&this.state&&!this.isDestroyed&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(e){this.setOptions({editable:e}),this.emit("update",{editor:this,transaction:this.state.tr})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get state(){return this.view.state}registerPlugin(e,t){const n=Eo(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],r=this.state.reconfigure({plugins:n});this.view.updateState(r)}unregisterPlugin(e){if(this.isDestroyed)return;const t="string"==typeof e?`${e}$`:e.key,n=this.state.reconfigure({plugins:this.state.plugins.filter((e=>!e.key.startsWith(t)))});this.view.updateState(n)}createExtensionManager(){const e=[...this.options.enableCoreExtensions?Object.values(Sa):[],...this.options.extensions].filter((e=>["extension","node","mark"].includes(null==e?void 0:e.type)));this.extensionManager=new zo(e,this)}createCommandManager(){this.commandManager=new xo({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){const e=aa(this.options.content,this.schema,this.options.parseOptions),t=Qo(e,this.options.autofocus);this.view=new Hs(this.options.element,{...this.options.editorProps,dispatchTransaction:this.dispatchTransaction.bind(this),state:Fn.create({doc:e,selection:t||void 0})});const n=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(n),this.createNodeViews();this.view.dom.editor=this}createNodeViews(){this.view.setProps({nodeViews:this.extensionManager.nodeViews})}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;const t=this.capturedTransaction;return this.capturedTransaction=null,t}dispatchTransaction(e){if(this.isCapturingTransaction)return this.capturedTransaction?void e.steps.forEach((e=>{var t;return null===(t=this.capturedTransaction)||void 0===t?void 0:t.step(e)})):void(this.capturedTransaction=e);const t=this.state.apply(e),n=!this.state.selection.eq(t.selection);this.view.updateState(t),this.emit("transaction",{editor:this,transaction:e}),n&&this.emit("selectionUpdate",{editor:this,transaction:e});const r=e.getMeta("focus"),i=e.getMeta("blur");r&&this.emit("focus",{editor:this,event:r.event,transaction:e}),i&&this.emit("blur",{editor:this,event:i.event,transaction:e}),e.docChanged&&!e.getMeta("preventUpdate")&&this.emit("update",{editor:this,transaction:e})}getAttributes(e){return ha(this.state,e)}isActive(e,t){const n="string"==typeof e?e:null,r="string"==typeof e?t:e;return function(e,t,n={}){if(!t)return ia(e,null,n)||da(e,null,n);const r=sa(t,e.schema);return"node"===r?ia(e,t,n):"mark"===r&&da(e,t,n)}(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return function(e,t){const n=$t.fromSchema(t).serializeFragment(e),r=document.implementation.createHTMLDocument().createElement("div");return r.appendChild(n),r.innerHTML}(this.state.doc.content,this.schema)}getText(e){const{blockSeparator:t="\n\n",textSerializers:n={}}=e||{};return function(e,t){return Wo(e,{from:0,to:e.content.size},t)}(this.state.doc,{blockSeparator:t,textSerializers:{...n,...Ho(this.schema)}})}get isEmpty(){return function(e){var t;const n=null===(t=e.type.createAndFill())||void 0===t?void 0:t.toJSON(),r=e.toJSON();return JSON.stringify(n)===JSON.stringify(r)}(this.state.doc)}getCharacterCount(){return console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.'),this.state.doc.content.size-2}destroy(){this.emit("destroy"),this.view&&this.view.destroy(),this.removeAllListeners()}get isDestroyed(){var e;return!(null===(e=this.view)||void 0===e?void 0:e.docView)}}class Oa{constructor(e={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=To(ko(this,"addOptions",{name:this.name}))),this.storage=To(ko(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new Oa(e)}configure(e={}){const t=this.extend();return t.options=jo(this.options,e),t.storage=To(ko(t,"addStorage",{name:t.name,options:t.options})),t}extend(e={}){const t=new Oa(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=To(ko(t,"addOptions",{name:t.name})),t.storage=To(ko(t,"addStorage",{name:t.name,options:t.options})),t}static handleExit({editor:e,mark:t}){const{tr:n}=e.state,r=e.state.selection.$from;if(r.pos===r.end()){const i=r.marks(),s=!!i.find((e=>(null==e?void 0:e.type.name)===t.name));if(!s)return!1;const o=i.find((e=>(null==e?void 0:e.type.name)===t.name));return o&&n.removeStoredMark(o),n.insertText(" ",r.pos),e.view.dispatch(n),!0}return!1}}class Ca{constructor(e={}){this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=To(ko(this,"addOptions",{name:this.name}))),this.storage=To(ko(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new Ca(e)}configure(e={}){const t=this.extend();return t.options=jo(this.options,e),t.storage=To(ko(t,"addStorage",{name:t.name,options:t.options})),t}extend(e={}){const t=new Ca(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=To(ko(t,"addOptions",{name:t.name})),t.storage=To(ko(t,"addStorage",{name:t.name,options:t.options})),t}}const Aa=Ca.create({name:"doc",topNode:!0,content:"block+"}),Ea=Ca.create({name:"paragraph",priority:1e3,addOptions:()=>({HTMLAttributes:{}}),group:"block",content:"inline*",parseHTML:()=>[{tag:"p"}],renderHTML({HTMLAttributes:e}){return["p",Co(this.options.HTMLAttributes,e),0]},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Ta=Ca.create({name:"text",group:"inline"});function Na(e={}){return new zn({view:t=>new Da(t,e)})}class Da{constructor(e,t){this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=t.width||1,this.color=t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map((t=>{let n=e=>{this[t](e)};return e.dom.addEventListener(t,n),{name:t,handler:n}}))}destroy(){this.handlers.forEach((({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t)))}update(e,t){null!=this.cursorPos&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,null==e?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e,t=this.editorView.state.doc.resolve(this.cursorPos);if(!t.parent.inlineContent){let n=t.nodeBefore,r=t.nodeAfter;if(n||r){let t=this.editorView.nodeDOM(this.cursorPos-(n?n.nodeSize:0)).getBoundingClientRect(),i=n?t.bottom:t.top;n&&r&&(i=(i+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2),e={left:t.left,right:t.right,top:i-this.width/2,bottom:i+this.width/2}}}if(!e){let t=this.editorView.coordsAtPos(this.cursorPos);e={left:t.left-this.width/2,right:t.left+this.width/2,top:t.top,bottom:t.bottom}}let n,r,i=this.editorView.dom.offsetParent;if(this.element||(this.element=i.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none; background-color: "+this.color),!i||i==document.body&&"static"==getComputedStyle(i).position)n=-pageXOffset,r=-pageYOffset;else{let e=i.getBoundingClientRect();n=e.left-i.scrollLeft,r=e.top-i.scrollTop}this.element.style.left=e.left-n+"px",this.element.style.top=e.top-r+"px",this.element.style.width=e.right-e.left+"px",this.element.style.height=e.bottom-e.top+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout((()=>this.setCursor(null)),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=n&&n.type.spec.disableDropCursor,i="function"==typeof r?r(this.editorView,t):r;if(t&&!i){let e=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice&&(e=sn(this.editorView.state.doc,e,this.editorView.dragging.slice),null==e))return this.setCursor(null);this.setCursor(e),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){e.target!=this.editorView.dom&&this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}const $a=_o.create({name:"dropCursor",addOptions:()=>({color:"currentColor",width:1,class:void 0}),addProseMirrorPlugins(){return[Na(this.options)]}});class Ia extends bn{constructor(e){super(e,e)}map(e,t){let n=e.resolve(t.map(this.head));return Ia.valid(n)?new Ia(n):bn.near(n)}content(){return Le.empty}eq(e){return e instanceof Ia&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for GapCursor.fromJSON");return new Ia(e.resolve(t.pos))}getBookmark(){return new Ra(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!function(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(0!=n)for(let e=r.child(n-1);;e=e.lastChild){if(0==e.childCount&&!e.inlineContent||e.isAtom||e.type.spec.isolating)return!0;if(e.inlineContent)return!1}else if(r.type.spec.isolating)return!0}return!0}(e)||!function(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n!=r.childCount)for(let e=r.child(n);;e=e.firstChild){if(0==e.childCount&&!e.inlineContent||e.isAtom||e.type.spec.isolating)return!0;if(e.inlineContent)return!1}else if(r.type.spec.isolating)return!0}return!0}(e))return!1;let n=t.type.spec.allowGapCursor;if(null!=n)return n;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(e,t,n=!1){e:for(;;){if(!n&&Ia.valid(e))return e;let r=e.pos,i=null;for(let n=e.depth;;n--){let s=e.node(n);if(t>0?e.indexAfter(n)<s.childCount:e.index(n)>0){i=s.child(t>0?e.indexAfter(n):e.index(n)-1);break}if(0==n)return null;r+=t;let o=e.doc.resolve(r);if(Ia.valid(o))return o}for(;;){let s=t>0?i.firstChild:i.lastChild;if(!s){if(i.isAtom&&!i.isText&&!Cn.isSelectable(i)){e=e.doc.resolve(r+i.nodeSize*t),n=!1;continue e}break}i=s,r+=t;let o=e.doc.resolve(r);if(Ia.valid(o))return o}return null}}}Ia.prototype.visible=!1,Ia.findFrom=Ia.findGapCursorFrom,bn.jsonID("gapcursor",Ia);class Ra{constructor(e){this.pos=e}map(e){return new Ra(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return Ia.valid(t)?new Ia(t):bn.near(t)}}const Pa=ao({ArrowLeft:Ba("horiz",-1),ArrowRight:Ba("horiz",1),ArrowUp:Ba("vert",-1),ArrowDown:Ba("vert",1)});function Ba(e,t){const n="vert"==e?t>0?"down":"up":t>0?"right":"left";return function(e,r,i){let s=e.selection,o=t>0?s.$to:s.$from,a=s.empty;if(s instanceof Mn){if(!i.endOfTextblock(n)||0==o.depth)return!1;a=!1,o=e.doc.resolve(t>0?o.after():o.before())}let l=Ia.findGapCursorFrom(o,t,a);return!!l&&(r&&r(e.tr.setSelection(new Ia(l))),!0)}}function Fa(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!Ia.valid(r))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return!(i&&i.inside>-1&&Cn.isSelectable(e.state.doc.nodeAt(i.inside)))&&(e.dispatch(e.state.tr.setSelection(new Ia(r))),!0)}function La(e,t){if("insertCompositionText"!=t.inputType||!(e.state.selection instanceof Ia))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let i=$e.empty;for(let e=r.length-1;e>=0;e--)i=$e.from(r[e].createAndFill(null,i));let s=e.state.tr.replace(n.pos,n.pos,new Le(i,0,0));return s.setSelection(Mn.near(s.doc.resolve(n.pos+1))),e.dispatch(s),!1}function za(e){if(!(e.selection instanceof Ia))return null;let t=document.createElement("div");return t.className="ProseMirror-gapcursor",Ss.create(e.doc,[bs.widget(e.selection.head,t,{key:"gapcursor"})])}const Va=_o.create({name:"gapCursor",addProseMirrorPlugins:()=>[new zn({props:{decorations:za,createSelectionBetween:(e,t,n)=>t.pos==n.pos&&Ia.valid(n)?new Ia(n):null,handleClick:Fa,handleKeyDown:Pa,handleDOMEvents:{beforeinput:La}}})],extendNodeSchema(e){var t;return{allowGapCursor:null!==(t=To(ko(e,"allowGapCursor",{name:e.name,options:e.options,storage:e.storage})))&&void 0!==t?t:null}}});var ja=function(){};ja.prototype.append=function(e){return e.length?(e=ja.from(e),!this.length&&e||e.length<200&&this.leafAppend(e)||this.length<200&&e.leafPrepend(this)||this.appendInner(e)):this},ja.prototype.prepend=function(e){return e.length?ja.from(e).append(this):this},ja.prototype.appendInner=function(e){return new Wa(this,e)},ja.prototype.slice=function(e,t){return void 0===e&&(e=0),void 0===t&&(t=this.length),e>=t?ja.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},ja.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},ja.prototype.forEach=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},ja.prototype.map=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length);var r=[];return this.forEach((function(t,n){return r.push(e(t,n))}),t,n),r},ja.from=function(e){return e instanceof ja?e:e&&e.length?new _a(e):ja.empty};var _a=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return 0==e&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var i=t;i<n;i++)if(!1===e(this.values[i],r+i))return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var i=t-1;i>=n;i--)if(!1===e(this.values[i],r+i))return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=200)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=200)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(ja);ja.empty=new _a([]);var Wa=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,r){var i=this.left.length;return!(t<i&&!1===this.left.forEachInner(e,t,Math.min(n,i),r))&&(!(n>i&&!1===this.right.forEachInner(e,Math.max(t-i,0),Math.min(this.length,n)-i,r+i))&&void 0)},t.prototype.forEachInvertedInner=function(e,t,n,r){var i=this.left.length;return!(t>i&&!1===this.right.forEachInvertedInner(e,t-i,Math.max(n,i)-i,r+i))&&(!(n<i&&!1===this.left.forEachInvertedInner(e,Math.min(t,i),n,r))&&void 0)},t.prototype.sliceInner=function(e,t){if(0==e&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(ja),Ha=ja;class Ka{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(0==this.eventCount)return null;let n,r,i=this.items.length;for(;;i--){if(this.items.get(i-1).selection){--i;break}}t&&(n=this.remapping(i,this.items.length),r=n.maps.length);let s,o,a=e.tr,l=[],c=[];return this.items.forEach(((e,t)=>{if(!e.step)return n||(n=this.remapping(i,t+1),r=n.maps.length),r--,void c.push(e);if(n){c.push(new qa(e.map));let t,i=e.step.map(n.slice(r));i&&a.maybeStep(i).doc&&(t=a.mapping.maps[a.mapping.maps.length-1],l.push(new qa(t,void 0,void 0,l.length+c.length))),r--,t&&n.appendMap(t,r)}else a.maybeStep(e.step);return e.selection?(s=n?e.selection.map(n.slice(r)):e.selection,o=new Ka(this.items.slice(0,i).append(c.reverse().concat(l)),this.eventCount-1),!1):void 0}),this.items.length,0),{remaining:o,transform:a,selection:s}}addTransform(e,t,n,r){let i=[],s=this.eventCount,o=this.items,a=!r&&o.length?o.get(o.length-1):null;for(let n=0;n<e.steps.length;n++){let l,c=e.steps[n].invert(e.docs[n]),h=new qa(e.mapping.maps[n],c,t);(l=a&&a.merge(h))&&(h=l,n?i.pop():o=o.slice(0,o.length-1)),i.push(h),t&&(s++,t=void 0),r||(a=h)}let l=s-n.depth;return l>Ua&&(o=function(e,t){let n;return e.forEach(((e,r)=>{if(e.selection&&0==t--)return n=r,!1})),e.slice(n)}(o,l),s-=l),new Ka(o.append(i),s)}remapping(e,t){let n=new Vt;return this.items.forEach(((t,r)=>{let i=null!=t.mirrorOffset&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,i)}),e,t),n}addMaps(e){return 0==this.eventCount?this:new Ka(this.items.append(e.map((e=>new qa(e)))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let n=[],r=Math.max(0,this.items.length-t),i=e.mapping,s=e.steps.length,o=this.eventCount;this.items.forEach((e=>{e.selection&&o--}),r);let a=t;this.items.forEach((t=>{let r=i.getMirror(--a);if(null==r)return;s=Math.min(s,r);let l=i.maps[r];if(t.step){let s=e.steps[r].invert(e.docs[r]),c=t.selection&&t.selection.map(i.slice(a+1,r));c&&o++,n.push(new qa(l,s,c))}else n.push(new qa(l))}),r);let l=[];for(let e=t;e<s;e++)l.push(new qa(i.maps[e]));let c=this.items.slice(0,r).append(l).append(n),h=new Ka(c,o);return h.emptyItemCount()>500&&(h=h.compress(this.items.length-n.length)),h}emptyItemCount(){let e=0;return this.items.forEach((t=>{t.step||e++})),e}compress(e=this.items.length){let t=this.remapping(0,e),n=t.maps.length,r=[],i=0;return this.items.forEach(((s,o)=>{if(o>=e)r.push(s),s.selection&&i++;else if(s.step){let e=s.step.map(t.slice(n)),o=e&&e.getMap();if(n--,o&&t.appendMap(o,n),e){let a=s.selection&&s.selection.map(t.slice(n));a&&i++;let l,c=new qa(o.invert(),e,a),h=r.length-1;(l=r.length&&r[h].merge(c))?r[h]=l:r.push(c)}}else s.map&&n--}),this.items.length,0),new Ka(Ha.from(r.reverse()),i)}}Ka.empty=new Ka(Ha.empty,0);class qa{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new qa(t.getMap().invert(),t,this.selection)}}}class Ja{constructor(e,t,n,r){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r}}const Ua=20;function Ga(e){let t=[];return e.forEach(((e,n,r,i)=>t.push(r,i))),t}function Ya(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let i=t.map(e[r],1),s=t.map(e[r+1],-1);i<=s&&n.push(i,s)}return n}function Xa(e,t,n,r){let i=el(t),s=tl.get(t).spec.config,o=(r?e.undone:e.done).popEvent(t,i);if(!o)return;let a=o.selection.resolve(o.transform.doc),l=(r?e.done:e.undone).addTransform(o.transform,t.selection.getBookmark(),s,i),c=new Ja(r?l:o.remaining,r?o.remaining:l,null,0);n(o.transform.setSelection(a).setMeta(tl,{redo:r,historyState:c}).scrollIntoView())}let Za=!1,Qa=null;function el(e){let t=e.plugins;if(Qa!=t){Za=!1,Qa=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){Za=!0;break}}return Za}const tl=new _n("history"),nl=new _n("closeHistory");function rl(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new zn({key:tl,state:{init:()=>new Ja(Ka.empty,Ka.empty,null,0),apply:(t,n,r)=>function(e,t,n,r){let i,s=n.getMeta(tl);if(s)return s.historyState;n.getMeta(nl)&&(e=new Ja(e.done,e.undone,null,0));let o=n.getMeta("appendedTransaction");if(0==n.steps.length)return e;if(o&&o.getMeta(tl))return o.getMeta(tl).redo?new Ja(e.done.addTransform(n,void 0,r,el(t)),e.undone,Ga(n.mapping.maps[n.steps.length-1]),e.prevTime):new Ja(e.done,e.undone.addTransform(n,void 0,r,el(t)),null,e.prevTime);if(!1===n.getMeta("addToHistory")||o&&!1===o.getMeta("addToHistory"))return(i=n.getMeta("rebased"))?new Ja(e.done.rebased(n,i),e.undone.rebased(n,i),Ya(e.prevRanges,n.mapping),e.prevTime):new Ja(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),Ya(e.prevRanges,n.mapping),e.prevTime);{let i=0==e.prevTime||!o&&(e.prevTime<(n.time||0)-r.newGroupDelay||!function(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach(((e,r)=>{for(let i=0;i<t.length;i+=2)e<=t[i+1]&&r>=t[i]&&(n=!0)})),n}(n,e.prevRanges)),s=o?Ya(e.prevRanges,n.mapping):Ga(n.mapping.maps[n.steps.length-1]);return new Ja(e.done.addTransform(n,i?t.selection.getBookmark():void 0,r,el(t)),Ka.empty,s,n.time)}}(n,r,t,e)},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r="historyUndo"==n?il:"historyRedo"==n?sl:null;return!!r&&(t.preventDefault(),r(e.state,e.dispatch))}}}})}const il=(e,t)=>{let n=tl.getState(e);return!(!n||0==n.done.eventCount)&&(t&&Xa(n,e,t,!1),!0)},sl=(e,t)=>{let n=tl.getState(e);return!(!n||0==n.undone.eventCount)&&(t&&Xa(n,e,t,!0),!0)},ol=_o.create({name:"history",addOptions:()=>({depth:100,newGroupDelay:500}),addCommands:()=>({undo:()=>({state:e,dispatch:t})=>il(e,t),redo:()=>({state:e,dispatch:t})=>sl(e,t)}),addProseMirrorPlugins(){return[rl(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Mod-y":()=>this.editor.commands.redo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}});class al extends q{connect(){for(const e of this.editorTargets){const t=new Ma({extensions:[$a,Va,ol,Aa,Ea,Ta],content:"",injectCSS:!1,element:e,editorProps:{attributes:{class:"ariadne-p-3"}},parseOptions:{preserveWhitespace:!0}}),n=e.previousElementSibling;if(n){const r=e.closest("form");null==r||r.addEventListener("submit",(()=>{n.setAttribute("value",t.getText()||""),t.commands.clearContent()}))}}}}al.targets=["editor"];class ll extends q{toggle(){this.expandableTarget.classList.toggle("ariadne-hidden");for(const e of this.slidePanelTargets)e.classList.toggle("ariadne-hidden")}}ll.targets=["expandable","expandWrapper","slidePanel","buttonWrapper"];class cl extends q{constructor(){super(...arguments),this.SELECTED_CLASSES=["ariadne-border-indigo-500","ariadne-text-indigo-600"],this.UNSELECTED_CLASSES=["ariadne-text-gray-500","hover:ariadne-text-gray-700","hover:ariadne-border-gray-300"]}connect(){for(const e of this.tabTargets)e.hasAttribute("aria-current")&&(e.classList.add(...this.SELECTED_CLASSES),e.classList.remove(...this.UNSELECTED_CLASSES))}toggle(e){for(const t of this.tabTargets)t===e.target?(t.setAttribute("aria-current","page"),t.classList.add(...this.SELECTED_CLASSES),t.classList.remove(...this.UNSELECTED_CLASSES)):t.hasAttribute("aria-current")&&(t.removeAttribute("aria-current"),t.classList.add(...this.UNSELECTED_CLASSES),t.classList.remove(...this.SELECTED_CLASSES))}}cl.targets=["tab"];var hl="top",dl="bottom",ul="right",pl="left",fl=[hl,dl,ul,pl],ml=fl.reduce((function(e,t){return e.concat([t+"-start",t+"-end"])}),[]),gl=[].concat(fl,["auto"]).reduce((function(e,t){return e.concat([t,t+"-start",t+"-end"])}),[]),yl=["beforeRead","read","afterRead","beforeMain","main","afterMain","beforeWrite","write","afterWrite"];function vl(e){return e?(e.nodeName||"").toLowerCase():null}function wl(e){if(null==e)return window;if("[object Window]"!==e.toString()){var t=e.ownerDocument;return t&&t.defaultView||window}return e}function bl(e){return e instanceof wl(e).Element||e instanceof Element}function xl(e){return e instanceof wl(e).HTMLElement||e instanceof HTMLElement}function kl(e){return"undefined"!=typeof ShadowRoot&&(e instanceof wl(e).ShadowRoot||e instanceof ShadowRoot)}var Sl={name:"applyStyles",enabled:!0,phase:"write",fn:function(e){var t=e.state;Object.keys(t.elements).forEach((function(e){var n=t.styles[e]||{},r=t.attributes[e]||{},i=t.elements[e];xl(i)&&vl(i)&&(Object.assign(i.style,n),Object.keys(r).forEach((function(e){var t=r[e];!1===t?i.removeAttribute(e):i.setAttribute(e,!0===t?"":t)})))}))},effect:function(e){var t=e.state,n={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(t.elements.popper.style,n.popper),t.styles=n,t.elements.arrow&&Object.assign(t.elements.arrow.style,n.arrow),function(){Object.keys(t.elements).forEach((function(e){var r=t.elements[e],i=t.attributes[e]||{},s=Object.keys(t.styles.hasOwnProperty(e)?t.styles[e]:n[e]).reduce((function(e,t){return e[t]="",e}),{});xl(r)&&vl(r)&&(Object.assign(r.style,s),Object.keys(i).forEach((function(e){r.removeAttribute(e)})))}))}},requires:["computeStyles"]};function Ml(e){return e.split("-")[0]}var Ol=Math.max,Cl=Math.min,Al=Math.round;function El(){var e=navigator.userAgentData;return null!=e&&e.brands?e.brands.map((function(e){return e.brand+"/"+e.version})).join(" "):navigator.userAgent}function Tl(){return!/^((?!chrome|android).)*safari/i.test(El())}function Nl(e,t,n){void 0===t&&(t=!1),void 0===n&&(n=!1);var r=e.getBoundingClientRect(),i=1,s=1;t&&xl(e)&&(i=e.offsetWidth>0&&Al(r.width)/e.offsetWidth||1,s=e.offsetHeight>0&&Al(r.height)/e.offsetHeight||1);var o=(bl(e)?wl(e):window).visualViewport,a=!Tl()&&n,l=(r.left+(a&&o?o.offsetLeft:0))/i,c=(r.top+(a&&o?o.offsetTop:0))/s,h=r.width/i,d=r.height/s;return{width:h,height:d,top:c,right:l+h,bottom:c+d,left:l,x:l,y:c}}function Dl(e){var t=Nl(e),n=e.offsetWidth,r=e.offsetHeight;return Math.abs(t.width-n)<=1&&(n=t.width),Math.abs(t.height-r)<=1&&(r=t.height),{x:e.offsetLeft,y:e.offsetTop,width:n,height:r}}function $l(e,t){var n=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if(n&&kl(n)){var r=t;do{if(r&&e.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}function Il(e){return wl(e).getComputedStyle(e)}function Rl(e){return["table","td","th"].indexOf(vl(e))>=0}function Pl(e){return((bl(e)?e.ownerDocument:e.document)||window.document).documentElement}function Bl(e){return"html"===vl(e)?e:e.assignedSlot||e.parentNode||(kl(e)?e.host:null)||Pl(e)}function Fl(e){return xl(e)&&"fixed"!==Il(e).position?e.offsetParent:null}function Ll(e){for(var t=wl(e),n=Fl(e);n&&Rl(n)&&"static"===Il(n).position;)n=Fl(n);return n&&("html"===vl(n)||"body"===vl(n)&&"static"===Il(n).position)?t:n||function(e){var t=/firefox/i.test(El());if(/Trident/i.test(El())&&xl(e)&&"fixed"===Il(e).position)return null;var n=Bl(e);for(kl(n)&&(n=n.host);xl(n)&&["html","body"].indexOf(vl(n))<0;){var r=Il(n);if("none"!==r.transform||"none"!==r.perspective||"paint"===r.contain||-1!==["transform","perspective"].indexOf(r.willChange)||t&&"filter"===r.willChange||t&&r.filter&&"none"!==r.filter)return n;n=n.parentNode}return null}(e)||t}function zl(e){return["top","bottom"].indexOf(e)>=0?"x":"y"}function Vl(e,t,n){return Ol(e,Cl(t,n))}function jl(e){return Object.assign({},{top:0,right:0,bottom:0,left:0},e)}function _l(e,t){return t.reduce((function(t,n){return t[n]=e,t}),{})}var Wl={name:"arrow",enabled:!0,phase:"main",fn:function(e){var t,n=e.state,r=e.name,i=e.options,s=n.elements.arrow,o=n.modifiersData.popperOffsets,a=Ml(n.placement),l=zl(a),c=[pl,ul].indexOf(a)>=0?"height":"width";if(s&&o){var h=function(e,t){return jl("number"!=typeof(e="function"==typeof e?e(Object.assign({},t.rects,{placement:t.placement})):e)?e:_l(e,fl))}(i.padding,n),d=Dl(s),u="y"===l?hl:pl,p="y"===l?dl:ul,f=n.rects.reference[c]+n.rects.reference[l]-o[l]-n.rects.popper[c],m=o[l]-n.rects.reference[l],g=Ll(s),y=g?"y"===l?g.clientHeight||0:g.clientWidth||0:0,v=f/2-m/2,w=h[u],b=y-d[c]-h[p],x=y/2-d[c]/2+v,k=Vl(w,x,b),S=l;n.modifiersData[r]=((t={})[S]=k,t.centerOffset=k-x,t)}},effect:function(e){var t=e.state,n=e.options.element,r=void 0===n?"[data-popper-arrow]":n;null!=r&&("string"!=typeof r||(r=t.elements.popper.querySelector(r)))&&$l(t.elements.popper,r)&&(t.elements.arrow=r)},requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function Hl(e){return e.split("-")[1]}var Kl={top:"auto",right:"auto",bottom:"auto",left:"auto"};function ql(e){var t,n=e.popper,r=e.popperRect,i=e.placement,s=e.variation,o=e.offsets,a=e.position,l=e.gpuAcceleration,c=e.adaptive,h=e.roundOffsets,d=e.isFixed,u=o.x,p=void 0===u?0:u,f=o.y,m=void 0===f?0:f,g="function"==typeof h?h({x:p,y:m}):{x:p,y:m};p=g.x,m=g.y;var y=o.hasOwnProperty("x"),v=o.hasOwnProperty("y"),w=pl,b=hl,x=window;if(c){var k=Ll(n),S="clientHeight",M="clientWidth";if(k===wl(n)&&"static"!==Il(k=Pl(n)).position&&"absolute"===a&&(S="scrollHeight",M="scrollWidth"),i===hl||(i===pl||i===ul)&&"end"===s)b=dl,m-=(d&&k===x&&x.visualViewport?x.visualViewport.height:k[S])-r.height,m*=l?1:-1;if(i===pl||(i===hl||i===dl)&&"end"===s)w=ul,p-=(d&&k===x&&x.visualViewport?x.visualViewport.width:k[M])-r.width,p*=l?1:-1}var O,C=Object.assign({position:a},c&&Kl),A=!0===h?function(e){var t=e.x,n=e.y,r=window.devicePixelRatio||1;return{x:Al(t*r)/r||0,y:Al(n*r)/r||0}}({x:p,y:m}):{x:p,y:m};return p=A.x,m=A.y,l?Object.assign({},C,((O={})[b]=v?"0":"",O[w]=y?"0":"",O.transform=(x.devicePixelRatio||1)<=1?"translate("+p+"px, "+m+"px)":"translate3d("+p+"px, "+m+"px, 0)",O)):Object.assign({},C,((t={})[b]=v?m+"px":"",t[w]=y?p+"px":"",t.transform="",t))}var Jl={passive:!0};var Ul={left:"right",right:"left",bottom:"top",top:"bottom"};function Gl(e){return e.replace(/left|right|bottom|top/g,(function(e){return Ul[e]}))}var Yl={start:"end",end:"start"};function Xl(e){return e.replace(/start|end/g,(function(e){return Yl[e]}))}function Zl(e){var t=wl(e);return{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function Ql(e){return Nl(Pl(e)).left+Zl(e).scrollLeft}function ec(e){var t=Il(e),n=t.overflow,r=t.overflowX,i=t.overflowY;return/auto|scroll|overlay|hidden/.test(n+i+r)}function tc(e){return["html","body","#document"].indexOf(vl(e))>=0?e.ownerDocument.body:xl(e)&&ec(e)?e:tc(Bl(e))}function nc(e,t){var n;void 0===t&&(t=[]);var r=tc(e),i=r===(null==(n=e.ownerDocument)?void 0:n.body),s=wl(r),o=i?[s].concat(s.visualViewport||[],ec(r)?r:[]):r,a=t.concat(o);return i?a:a.concat(nc(Bl(o)))}function rc(e){return Object.assign({},e,{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height})}function ic(e,t,n){return"viewport"===t?rc(function(e,t){var n=wl(e),r=Pl(e),i=n.visualViewport,s=r.clientWidth,o=r.clientHeight,a=0,l=0;if(i){s=i.width,o=i.height;var c=Tl();(c||!c&&"fixed"===t)&&(a=i.offsetLeft,l=i.offsetTop)}return{width:s,height:o,x:a+Ql(e),y:l}}(e,n)):bl(t)?function(e,t){var n=Nl(e,!1,"fixed"===t);return n.top=n.top+e.clientTop,n.left=n.left+e.clientLeft,n.bottom=n.top+e.clientHeight,n.right=n.left+e.clientWidth,n.width=e.clientWidth,n.height=e.clientHeight,n.x=n.left,n.y=n.top,n}(t,n):rc(function(e){var t,n=Pl(e),r=Zl(e),i=null==(t=e.ownerDocument)?void 0:t.body,s=Ol(n.scrollWidth,n.clientWidth,i?i.scrollWidth:0,i?i.clientWidth:0),o=Ol(n.scrollHeight,n.clientHeight,i?i.scrollHeight:0,i?i.clientHeight:0),a=-r.scrollLeft+Ql(e),l=-r.scrollTop;return"rtl"===Il(i||n).direction&&(a+=Ol(n.clientWidth,i?i.clientWidth:0)-s),{width:s,height:o,x:a,y:l}}(Pl(e)))}function sc(e,t,n,r){var i="clippingParents"===t?function(e){var t=nc(Bl(e)),n=["absolute","fixed"].indexOf(Il(e).position)>=0&&xl(e)?Ll(e):e;return bl(n)?t.filter((function(e){return bl(e)&&$l(e,n)&&"body"!==vl(e)})):[]}(e):[].concat(t),s=[].concat(i,[n]),o=s[0],a=s.reduce((function(t,n){var i=ic(e,n,r);return t.top=Ol(i.top,t.top),t.right=Cl(i.right,t.right),t.bottom=Cl(i.bottom,t.bottom),t.left=Ol(i.left,t.left),t}),ic(e,o,r));return a.width=a.right-a.left,a.height=a.bottom-a.top,a.x=a.left,a.y=a.top,a}function oc(e){var t,n=e.reference,r=e.element,i=e.placement,s=i?Ml(i):null,o=i?Hl(i):null,a=n.x+n.width/2-r.width/2,l=n.y+n.height/2-r.height/2;switch(s){case hl:t={x:a,y:n.y-r.height};break;case dl:t={x:a,y:n.y+n.height};break;case ul:t={x:n.x+n.width,y:l};break;case pl:t={x:n.x-r.width,y:l};break;default:t={x:n.x,y:n.y}}var c=s?zl(s):null;if(null!=c){var h="y"===c?"height":"width";switch(o){case"start":t[c]=t[c]-(n[h]/2-r[h]/2);break;case"end":t[c]=t[c]+(n[h]/2-r[h]/2)}}return t}function ac(e,t){void 0===t&&(t={});var n=t,r=n.placement,i=void 0===r?e.placement:r,s=n.strategy,o=void 0===s?e.strategy:s,a=n.boundary,l=void 0===a?"clippingParents":a,c=n.rootBoundary,h=void 0===c?"viewport":c,d=n.elementContext,u=void 0===d?"popper":d,p=n.altBoundary,f=void 0!==p&&p,m=n.padding,g=void 0===m?0:m,y=jl("number"!=typeof g?g:_l(g,fl)),v="popper"===u?"reference":"popper",w=e.rects.popper,b=e.elements[f?v:u],x=sc(bl(b)?b:b.contextElement||Pl(e.elements.popper),l,h,o),k=Nl(e.elements.reference),S=oc({reference:k,element:w,strategy:"absolute",placement:i}),M=rc(Object.assign({},w,S)),O="popper"===u?M:k,C={top:x.top-O.top+y.top,bottom:O.bottom-x.bottom+y.bottom,left:x.left-O.left+y.left,right:O.right-x.right+y.right},A=e.modifiersData.offset;if("popper"===u&&A){var E=A[i];Object.keys(C).forEach((function(e){var t=[ul,dl].indexOf(e)>=0?1:-1,n=[hl,dl].indexOf(e)>=0?"y":"x";C[e]+=E[n]*t}))}return C}function lc(e,t){void 0===t&&(t={});var n=t,r=n.placement,i=n.boundary,s=n.rootBoundary,o=n.padding,a=n.flipVariations,l=n.allowedAutoPlacements,c=void 0===l?gl:l,h=Hl(r),d=h?a?ml:ml.filter((function(e){return Hl(e)===h})):fl,u=d.filter((function(e){return c.indexOf(e)>=0}));0===u.length&&(u=d);var p=u.reduce((function(t,n){return t[n]=ac(e,{placement:n,boundary:i,rootBoundary:s,padding:o})[Ml(n)],t}),{});return Object.keys(p).sort((function(e,t){return p[e]-p[t]}))}var cc={name:"flip",enabled:!0,phase:"main",fn:function(e){var t=e.state,n=e.options,r=e.name;if(!t.modifiersData[r]._skip){for(var i=n.mainAxis,s=void 0===i||i,o=n.altAxis,a=void 0===o||o,l=n.fallbackPlacements,c=n.padding,h=n.boundary,d=n.rootBoundary,u=n.altBoundary,p=n.flipVariations,f=void 0===p||p,m=n.allowedAutoPlacements,g=t.options.placement,y=Ml(g),v=l||(y===g||!f?[Gl(g)]:function(e){if("auto"===Ml(e))return[];var t=Gl(e);return[Xl(e),t,Xl(t)]}(g)),w=[g].concat(v).reduce((function(e,n){return e.concat("auto"===Ml(n)?lc(t,{placement:n,boundary:h,rootBoundary:d,padding:c,flipVariations:f,allowedAutoPlacements:m}):n)}),[]),b=t.rects.reference,x=t.rects.popper,k=new Map,S=!0,M=w[0],O=0;O<w.length;O++){var C=w[O],A=Ml(C),E="start"===Hl(C),T=[hl,dl].indexOf(A)>=0,N=T?"width":"height",D=ac(t,{placement:C,boundary:h,rootBoundary:d,altBoundary:u,padding:c}),$=T?E?ul:pl:E?dl:hl;b[N]>x[N]&&($=Gl($));var I=Gl($),R=[];if(s&&R.push(D[A]<=0),a&&R.push(D[$]<=0,D[I]<=0),R.every((function(e){return e}))){M=C,S=!1;break}k.set(C,R)}if(S)for(var P=function(e){var t=w.find((function(t){var n=k.get(t);if(n)return n.slice(0,e).every((function(e){return e}))}));if(t)return M=t,"break"},B=f?3:1;B>0;B--){if("break"===P(B))break}t.placement!==M&&(t.modifiersData[r]._skip=!0,t.placement=M,t.reset=!0)}},requiresIfExists:["offset"],data:{_skip:!1}};function hc(e,t,n){return void 0===n&&(n={x:0,y:0}),{top:e.top-t.height-n.y,right:e.right-t.width+n.x,bottom:e.bottom-t.height+n.y,left:e.left-t.width-n.x}}function dc(e){return[hl,ul,dl,pl].some((function(t){return e[t]>=0}))}var uc={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:function(e){var t=e.state,n=e.options,r=e.name,i=n.offset,s=void 0===i?[0,0]:i,o=gl.reduce((function(e,n){return e[n]=function(e,t,n){var r=Ml(e),i=[pl,hl].indexOf(r)>=0?-1:1,s="function"==typeof n?n(Object.assign({},t,{placement:e})):n,o=s[0],a=s[1];return o=o||0,a=(a||0)*i,[pl,ul].indexOf(r)>=0?{x:a,y:o}:{x:o,y:a}}(n,t.rects,s),e}),{}),a=o[t.placement],l=a.x,c=a.y;null!=t.modifiersData.popperOffsets&&(t.modifiersData.popperOffsets.x+=l,t.modifiersData.popperOffsets.y+=c),t.modifiersData[r]=o}};var pc={name:"preventOverflow",enabled:!0,phase:"main",fn:function(e){var t=e.state,n=e.options,r=e.name,i=n.mainAxis,s=void 0===i||i,o=n.altAxis,a=void 0!==o&&o,l=n.boundary,c=n.rootBoundary,h=n.altBoundary,d=n.padding,u=n.tether,p=void 0===u||u,f=n.tetherOffset,m=void 0===f?0:f,g=ac(t,{boundary:l,rootBoundary:c,padding:d,altBoundary:h}),y=Ml(t.placement),v=Hl(t.placement),w=!v,b=zl(y),x="x"===b?"y":"x",k=t.modifiersData.popperOffsets,S=t.rects.reference,M=t.rects.popper,O="function"==typeof m?m(Object.assign({},t.rects,{placement:t.placement})):m,C="number"==typeof O?{mainAxis:O,altAxis:O}:Object.assign({mainAxis:0,altAxis:0},O),A=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,E={x:0,y:0};if(k){if(s){var T,N="y"===b?hl:pl,D="y"===b?dl:ul,$="y"===b?"height":"width",I=k[b],R=I+g[N],P=I-g[D],B=p?-M[$]/2:0,F="start"===v?S[$]:M[$],L="start"===v?-M[$]:-S[$],z=t.elements.arrow,V=p&&z?Dl(z):{width:0,height:0},j=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:{top:0,right:0,bottom:0,left:0},_=j[N],W=j[D],H=Vl(0,S[$],V[$]),K=w?S[$]/2-B-H-_-C.mainAxis:F-H-_-C.mainAxis,q=w?-S[$]/2+B+H+W+C.mainAxis:L+H+W+C.mainAxis,J=t.elements.arrow&&Ll(t.elements.arrow),U=J?"y"===b?J.clientTop||0:J.clientLeft||0:0,G=null!=(T=null==A?void 0:A[b])?T:0,Y=I+q-G,X=Vl(p?Cl(R,I+K-G-U):R,I,p?Ol(P,Y):P);k[b]=X,E[b]=X-I}if(a){var Z,Q="x"===b?hl:pl,ee="x"===b?dl:ul,te=k[x],ne="y"===x?"height":"width",re=te+g[Q],ie=te-g[ee],se=-1!==[hl,pl].indexOf(y),oe=null!=(Z=null==A?void 0:A[x])?Z:0,ae=se?re:te-S[ne]-M[ne]-oe+C.altAxis,le=se?te+S[ne]+M[ne]-oe-C.altAxis:ie,ce=p&&se?function(e,t,n){var r=Vl(e,t,n);return r>n?n:r}(ae,te,le):Vl(p?ae:re,te,p?le:ie);k[x]=ce,E[x]=ce-te}t.modifiersData[r]=E}},requiresIfExists:["offset"]};function fc(e,t,n){void 0===n&&(n=!1);var r,i,s=xl(t),o=xl(t)&&function(e){var t=e.getBoundingClientRect(),n=Al(t.width)/e.offsetWidth||1,r=Al(t.height)/e.offsetHeight||1;return 1!==n||1!==r}(t),a=Pl(t),l=Nl(e,o,n),c={scrollLeft:0,scrollTop:0},h={x:0,y:0};return(s||!s&&!n)&&(("body"!==vl(t)||ec(a))&&(c=(r=t)!==wl(r)&&xl(r)?{scrollLeft:(i=r).scrollLeft,scrollTop:i.scrollTop}:Zl(r)),xl(t)?((h=Nl(t,!0)).x+=t.clientLeft,h.y+=t.clientTop):a&&(h.x=Ql(a))),{x:l.left+c.scrollLeft-h.x,y:l.top+c.scrollTop-h.y,width:l.width,height:l.height}}function mc(e){var t=new Map,n=new Set,r=[];function i(e){n.add(e.name),[].concat(e.requires||[],e.requiresIfExists||[]).forEach((function(e){if(!n.has(e)){var r=t.get(e);r&&i(r)}})),r.push(e)}return e.forEach((function(e){t.set(e.name,e)})),e.forEach((function(e){n.has(e.name)||i(e)})),r}var gc={placement:"bottom",modifiers:[],strategy:"absolute"};function yc(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return!t.some((function(e){return!(e&&"function"==typeof e.getBoundingClientRect)}))}function vc(e){void 0===e&&(e={});var t=e,n=t.defaultModifiers,r=void 0===n?[]:n,i=t.defaultOptions,s=void 0===i?gc:i;return function(e,t,n){void 0===n&&(n=s);var i,o,a={placement:"bottom",orderedModifiers:[],options:Object.assign({},gc,s),modifiersData:{},elements:{reference:e,popper:t},attributes:{},styles:{}},l=[],c=!1,h={state:a,setOptions:function(n){var i="function"==typeof n?n(a.options):n;d(),a.options=Object.assign({},s,a.options,i),a.scrollParents={reference:bl(e)?nc(e):e.contextElement?nc(e.contextElement):[],popper:nc(t)};var o=function(e){var t=mc(e);return yl.reduce((function(e,n){return e.concat(t.filter((function(e){return e.phase===n})))}),[])}(function(e){var t=e.reduce((function(e,t){var n=e[t.name];return e[t.name]=n?Object.assign({},n,t,{options:Object.assign({},n.options,t.options),data:Object.assign({},n.data,t.data)}):t,e}),{});return Object.keys(t).map((function(e){return t[e]}))}([].concat(r,a.options.modifiers)));return a.orderedModifiers=o.filter((function(e){return e.enabled})),a.orderedModifiers.forEach((function(e){var t=e.name,n=e.options,r=void 0===n?{}:n,i=e.effect;if("function"==typeof i){var s=i({state:a,name:t,instance:h,options:r}),o=function(){};l.push(s||o)}})),h.update()},forceUpdate:function(){if(!c){var e=a.elements,t=e.reference,n=e.popper;if(yc(t,n)){a.rects={reference:fc(t,Ll(n),"fixed"===a.options.strategy),popper:Dl(n)},a.reset=!1,a.placement=a.options.placement,a.orderedModifiers.forEach((function(e){return a.modifiersData[e.name]=Object.assign({},e.data)}));for(var r=0;r<a.orderedModifiers.length;r++)if(!0!==a.reset){var i=a.orderedModifiers[r],s=i.fn,o=i.options,l=void 0===o?{}:o,d=i.name;"function"==typeof s&&(a=s({state:a,options:l,name:d,instance:h})||a)}else a.reset=!1,r=-1}}},update:(i=function(){return new Promise((function(e){h.forceUpdate(),e(a)}))},function(){return o||(o=new Promise((function(e){Promise.resolve().then((function(){o=void 0,e(i())}))}))),o}),destroy:function(){d(),c=!0}};if(!yc(e,t))return h;function d(){l.forEach((function(e){return e()})),l=[]}return h.setOptions(n).then((function(e){!c&&n.onFirstUpdate&&n.onFirstUpdate(e)})),h}}var wc=vc({defaultModifiers:[{name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:function(e){var t=e.state,n=e.instance,r=e.options,i=r.scroll,s=void 0===i||i,o=r.resize,a=void 0===o||o,l=wl(t.elements.popper),c=[].concat(t.scrollParents.reference,t.scrollParents.popper);return s&&c.forEach((function(e){e.addEventListener("scroll",n.update,Jl)})),a&&l.addEventListener("resize",n.update,Jl),function(){s&&c.forEach((function(e){e.removeEventListener("scroll",n.update,Jl)})),a&&l.removeEventListener("resize",n.update,Jl)}},data:{}},{name:"popperOffsets",enabled:!0,phase:"read",fn:function(e){var t=e.state,n=e.name;t.modifiersData[n]=oc({reference:t.rects.reference,element:t.rects.popper,strategy:"absolute",placement:t.placement})},data:{}},{name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:function(e){var t=e.state,n=e.options,r=n.gpuAcceleration,i=void 0===r||r,s=n.adaptive,o=void 0===s||s,a=n.roundOffsets,l=void 0===a||a,c={placement:Ml(t.placement),variation:Hl(t.placement),popper:t.elements.popper,popperRect:t.rects.popper,gpuAcceleration:i,isFixed:"fixed"===t.options.strategy};null!=t.modifiersData.popperOffsets&&(t.styles.popper=Object.assign({},t.styles.popper,ql(Object.assign({},c,{offsets:t.modifiersData.popperOffsets,position:t.options.strategy,adaptive:o,roundOffsets:l})))),null!=t.modifiersData.arrow&&(t.styles.arrow=Object.assign({},t.styles.arrow,ql(Object.assign({},c,{offsets:t.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:l})))),t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-placement":t.placement})},data:{}},Sl,uc,cc,pc,Wl,{name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:function(e){var t=e.state,n=e.name,r=t.rects.reference,i=t.rects.popper,s=t.modifiersData.preventOverflow,o=ac(t,{elementContext:"reference"}),a=ac(t,{altBoundary:!0}),l=hc(o,r),c=hc(a,i,s),h=dc(l),d=dc(c);t.modifiersData[n]={referenceClippingOffsets:l,popperEscapeOffsets:c,isReferenceHidden:h,hasPopperEscaped:d},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":h,"data-popper-escaped":d})}}]});class bc extends q{connect(){this.popperInstance=wc(this.triggerTarget,this.tooltipTarget,{placement:this.placementValue,modifiers:[{name:"offset",options:{offset:this.offsetValue}}]})}disconnect(){this.popperInstance&&this.popperInstance.destroy()}show(){this.tooltipTarget.setAttribute("data-tooltip-show",""),this.tooltipTarget.classList.remove("ariadne-invisible"),this.popperInstance.update(),this.dispatch("shown",{detail:{trigger:this.triggerTarget,tooltip:this.tooltipTarget}})}hide(){this.tooltipTarget.removeAttribute("data-tooltip-show"),this.tooltipTarget.classList.add("ariadne-invisible"),this.dispatch("ariadne-hidden",{detail:{trigger:this.triggerTarget,tooltip:this.tooltipTarget}})}}function xc(e){return Array.from(e.querySelectorAll('[role="tablist"] [role="tab"]')).filter((t=>t instanceof HTMLElement&&t.closest(e.tagName)===e))}bc.targets=["trigger","tooltip"],bc.values={placement:{type:String,default:"top"},offset:{type:Array,default:[0,8]}};class kc extends HTMLElement{constructor(){super(),this.addEventListener("keydown",(e=>{const t=e.target;if(!(t instanceof HTMLElement))return;if(t.closest(this.tagName)!==this)return;if("tab"!==t.getAttribute("role")&&!t.closest('[role="tablist"]'))return;const n=xc(this),r=n.indexOf(n.find((e=>e.matches('[aria-selected="true"]')))),[i,s]="vertical"===t.closest('[role="tablist"]')?.getAttribute("aria-orientation")?[["ArrowDown","ArrowRight"],["ArrowUp","ArrowLeft"]]:[["ArrowRight"],["ArrowLeft"]];if(i.some((t=>e.code===t))){let e=r+1;e>=n.length&&(e=0),this.selectTab(e)}else if(s.some((t=>e.code===t))){let e=r-1;e<0&&(e=n.length-1),this.selectTab(e)}else"Home"===e.code?(this.selectTab(0),e.preventDefault()):"End"===e.code&&(this.selectTab(n.length-1),e.preventDefault())})),this.addEventListener("click",(e=>{const t=xc(this);if(!(e.target instanceof Element))return;if(e.target.closest(this.tagName)!==this)return;const n=e.target.closest('[role="tab"]');if(!(n instanceof HTMLElement&&n.closest('[role="tablist"]')))return;const r=t.indexOf(n);this.selectTab(r)}))}connectedCallback(){for(const e of xc(this))e.hasAttribute("aria-selected")||e.setAttribute("aria-selected","false"),e.hasAttribute("tabindex")||("true"===e.getAttribute("aria-selected")?e.setAttribute("tabindex","0"):e.setAttribute("tabindex","-1"))}selectTab(e){const t=xc(this),n=Array.from(this.querySelectorAll('[role="tabpanel"]')).filter((e=>e.closest(this.tagName)===this));if(e>t.length-1)throw new RangeError(`Index "${e}" out of bounds`);const r=t[e],i=n[e];if(!!this.dispatchEvent(new CustomEvent("tab-container-change",{bubbles:!0,cancelable:!0,detail:{relatedTarget:i}}))){for(const e of t)e.setAttribute("aria-selected","false"),e.setAttribute("tabindex","-1");for(const e of n)e.hidden=!0,e.hasAttribute("tabindex")||e.hasAttribute("data-tab-container-no-tabstop")||e.setAttribute("tabindex","0");r.setAttribute("aria-selected","true"),r.setAttribute("tabindex","0"),r.focus(),i.hidden=!1,this.dispatchEvent(new CustomEvent("tab-container-changed",{bubbles:!0,detail:{relatedTarget:i}}))}}}window.customElements.get("tab-container")||(window.TabContainerElement=kc,window.customElements.define("tab-container",kc));const Sc=["ariadne-border-indigo-500","ariadne-text-indigo-600"],Mc=["ariadne-text-gray-500","hover:ariadne-text-gray-700","hover:ariadne-border-gray-300"];for(const e of document.getElementsByTagName("tab-container"))e.addEventListener("tab-container-change",(function(e){var t;const n=e.detail.relatedTarget,r=n.closest("tab-container").firstElementChild,i=r.querySelector('[aria-selected="true"]'),s=null===(t=n.getAttribute("id"))||void 0===t?void 0:t.split("-").slice(1).join("-"),o=r.querySelector(`#${s}`);i.classList.remove(...Sc),i.classList.add(...Mc),o.classList.add(...Sc),o.classList.remove(...Mc)}));const Oc=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Cc=["January","February","March","April","May","June","July","August","September","October","November","December"];function Ac(e){return`0${e}`.slice(-2)}function Ec(e,t){const n=e.getDay(),r=e.getDate(),i=e.getMonth(),s=e.getFullYear(),o=e.getHours(),a=e.getMinutes(),l=e.getSeconds();return t.replace(/%([%aAbBcdeHIlmMpPSwyYZz])/g,(function(t){let c;switch(t[1]){case"%":return"%";case"a":return Oc[n].slice(0,3);case"A":return Oc[n];case"b":return Cc[i].slice(0,3);case"B":return Cc[i];case"c":return e.toString();case"d":return Ac(r);case"e":return String(r);case"H":return Ac(o);case"I":return Ac(Ec(e,"%l"));case"l":return String(0===o||12===o?12:(o+12)%12);case"m":return Ac(i+1);case"M":return Ac(a);case"p":return o>11?"PM":"AM";case"P":return o>11?"pm":"am";case"S":return Ac(l);case"w":return String(n);case"y":return Ac(s%100);case"Y":return String(s);case"Z":return c=e.toString().match(/\((\w+)\)$/),c?c[1]:"";case"z":return c=e.toString().match(/\w([+-]\d\d\d\d) /),c?c[1]:""}return""}))}function Tc(e){let t;return function(){if(t)return t;if("Intl"in window)try{return t=new Intl.DateTimeFormat(void 0,e),t}catch(e){if(!(e instanceof RangeError))throw e}}}let Nc=null;const Dc=Tc({day:"numeric",month:"short"});function $c(){if(null!==Nc)return Nc;const e=Dc();if(e){const t=e.format(new Date(0));return Nc=!!t.match(/^\d/),Nc}return!1}let Ic=null;const Rc=Tc({day:"numeric",month:"short",year:"numeric"});function Pc(e){const t=e.closest("[lang]");return t instanceof HTMLElement&&t.lang?t.lang:"default"}const Bc=new WeakMap;class Fc extends HTMLElement{static get observedAttributes(){return["datetime","day","format","lang","hour","minute","month","second","title","weekday","year","time-zone-name"]}connectedCallback(){const e=this.getFormattedTitle();e&&!this.hasAttribute("title")&&this.setAttribute("title",e);const t=this.getFormattedDate();t&&(this.textContent=t)}attributeChangedCallback(e,t,n){const r=this.getFormattedTitle();if("datetime"===e){const e=Date.parse(n);isNaN(e)?Bc.delete(this):Bc.set(this,new Date(e))}const i=this.getFormattedTitle(),s=this.getAttribute("title");"title"===e||!i||s&&s!==r||this.setAttribute("title",i);const o=this.getFormattedDate();o&&(this.textContent=o)}get date(){return Bc.get(this)}getFormattedTitle(){const e=this.date;if(!e)return;const t=Lc();if(t)return t.format(e);try{return e.toLocaleString()}catch(t){if(t instanceof RangeError)return e.toString();throw t}}getFormattedDate(){}}const Lc=Tc({day:"numeric",month:"short",year:"numeric",hour:"numeric",minute:"2-digit",timeZoneName:"short"}),zc=new WeakMap;class Vc extends Fc{attributeChangedCallback(e,t,n){"hour"!==e&&"minute"!==e&&"second"!==e&&"time-zone-name"!==e||zc.delete(this),super.attributeChangedCallback(e,t,n)}getFormattedDate(){const e=this.date;if(!e)return;const t=function(e,t){const n={weekday:{short:"%a",long:"%A"},day:{numeric:"%e","2-digit":"%d"},month:{short:"%b",long:"%B"},year:{numeric:"%Y","2-digit":"%y"}};let r=$c()?"weekday day month year":"weekday month day, year";for(const t in n){const i=n[t][e.getAttribute(t)||""];r=r.replace(t,i||"")}return r=r.replace(/(\s,)|(,\s$)/,""),Ec(t,r).replace(/\s+/," ").trim()}(this,e)||"",n=function(e,t){const n={},r=e.getAttribute("hour");"numeric"!==r&&"2-digit"!==r||(n.hour=r);const i=e.getAttribute("minute");"numeric"!==i&&"2-digit"!==i||(n.minute=i);const s=e.getAttribute("second");"numeric"!==s&&"2-digit"!==s||(n.second=s);const o=e.getAttribute("time-zone-name");"short"!==o&&"long"!==o||(n.timeZoneName=o);if(0===Object.keys(n).length)return;let a=zc.get(e);a||(a=Tc(n),zc.set(e,a));const l=a();if(l)return l.format(t);return Ec(t,n.second?"%H:%M:%S":"%H:%M")}(this,e)||"";return`${t} ${n}`.trim()}}window.customElements.get("local-time")||(window.LocalTimeElement=Vc,window.customElements.define("local-time",Vc));class jc{constructor(e,t){this.date=e,this.locale=t}toString(){const e=this.timeElapsed();if(e)return e;{const e=this.timeAhead();return e||`on ${this.formatDate()}`}}timeElapsed(){const e=(new Date).getTime()-this.date.getTime(),t=Math.round(e/1e3),n=Math.round(t/60),r=Math.round(n/60),i=Math.round(r/24);return e>=0&&i<30?this.timeAgoFromMs(e):null}timeAhead(){const e=this.date.getTime()-(new Date).getTime(),t=Math.round(e/1e3),n=Math.round(t/60),r=Math.round(n/60),i=Math.round(r/24);return e>=0&&i<30?this.timeUntil():null}timeAgo(){const e=(new Date).getTime()-this.date.getTime();return this.timeAgoFromMs(e)}timeAgoFromMs(e){const t=Math.round(e/1e3),n=Math.round(t/60),r=Math.round(n/60),i=Math.round(r/24),s=Math.round(i/30),o=Math.round(s/12);return e<0||t<10?_c(this.locale,0,"second"):t<45?_c(this.locale,-t,"second"):t<90||n<45?_c(this.locale,-n,"minute"):n<90||r<24?_c(this.locale,-r,"hour"):r<36||i<30?_c(this.locale,-i,"day"):s<18?_c(this.locale,-s,"month"):_c(this.locale,-o,"year")}microTimeAgo(){const e=(new Date).getTime()-this.date.getTime(),t=Math.round(e/1e3),n=Math.round(t/60),r=Math.round(n/60),i=Math.round(r/24),s=Math.round(i/30),o=Math.round(s/12);return n<1?"1m":n<60?`${n}m`:r<24?`${r}h`:i<365?`${i}d`:`${o}y`}timeUntil(){const e=this.date.getTime()-(new Date).getTime();return this.timeUntilFromMs(e)}timeUntilFromMs(e){const t=Math.round(e/1e3),n=Math.round(t/60),r=Math.round(n/60),i=Math.round(r/24),s=Math.round(i/30),o=Math.round(s/12);return s>=18||s>=12?_c(this.locale,o,"year"):i>=45||i>=30?_c(this.locale,s,"month"):r>=36||r>=24?_c(this.locale,i,"day"):n>=90||n>=45?_c(this.locale,r,"hour"):t>=90||t>=45?_c(this.locale,n,"minute"):_c(this.locale,t>=10?t:0,"second")}microTimeUntil(){const e=this.date.getTime()-(new Date).getTime(),t=Math.round(e/1e3),n=Math.round(t/60),r=Math.round(n/60),i=Math.round(r/24),s=Math.round(i/30),o=Math.round(s/12);return i>=365?`${o}y`:r>=24?`${i}d`:n>=60?`${r}h`:n>1?`${n}m`:"1m"}formatDate(){let e=$c()?"%e %b":"%b %e";var t;return t=this.date,(new Date).getUTCFullYear()!==t.getUTCFullYear()&&(e+=function(){if(null!==Ic)return Ic;const e=Rc();if(e){const t=e.format(new Date(0));return Ic=!!t.match(/\d,/),Ic}return!0}()?", %Y":" %Y"),Ec(this.date,e)}formatTime(){const e=Wc();return e?e.format(this.date):Ec(this.date,"%l:%M%P")}}function _c(e,t,n){const r=function(e,t){if("Intl"in window&&"RelativeTimeFormat"in window.Intl)try{return new Intl.RelativeTimeFormat(e,t)}catch(e){if(!(e instanceof RangeError))throw e}}(e,{numeric:"auto"});return r?r.format(t,n):function(e,t){if(0===e)switch(t){case"year":case"quarter":case"month":case"week":return`this ${t}`;case"day":return"today";case"hour":case"minute":return`in 0 ${t}s`;case"second":return"now"}else if(1===e)switch(t){case"year":case"quarter":case"month":case"week":return`next ${t}`;case"day":return"tomorrow";case"hour":case"minute":case"second":return`in 1 ${t}`}else if(-1===e)switch(t){case"year":case"quarter":case"month":case"week":return`last ${t}`;case"day":return"yesterday";case"hour":case"minute":case"second":return`1 ${t} ago`}else if(e>1)switch(t){case"year":case"quarter":case"month":case"week":case"day":case"hour":case"minute":case"second":return`in ${e} ${t}s`}else if(e<-1)switch(t){case"year":case"quarter":case"month":case"week":case"day":case"hour":case"minute":case"second":return`${-e} ${t}s ago`}throw new RangeError(`Invalid unit argument for format() '${t}'`)}(t,n)}const Wc=Tc({hour:"numeric",minute:"2-digit"});class Hc extends Fc{getFormattedDate(){const e=this.date;if(e)return new jc(e,Pc(this)).toString()}connectedCallback(){Kc.push(this),qc||(Jc(),qc=window.setInterval(Jc,6e4)),super.connectedCallback()}disconnectedCallback(){const e=Kc.indexOf(this);-1!==e&&Kc.splice(e,1),Kc.length||qc&&(clearInterval(qc),qc=null)}}const Kc=[];let qc;function Jc(){let e,t,n;for(t=0,n=Kc.length;t<n;t++)e=Kc[t],e.textContent=e.getFormattedDate()||""}window.customElements.get("relative-time")||(window.RelativeTimeElement=Hc,window.customElements.define("relative-time",Hc));class Uc extends Hc{getFormattedDate(){const e=this.getAttribute("format"),t=this.date;if(t)return"micro"===e?new jc(t,Pc(this)).microTimeAgo():new jc(t,Pc(this)).timeAgo()}}window.customElements.get("time-ago")||(window.TimeAgoElement=Uc,window.customElements.define("time-ago",Uc));class Gc extends Hc{getFormattedDate(){const e=this.getAttribute("format"),t=this.date;if(t)return"micro"===e?new jc(t,Pc(this)).microTimeUntil():new jc(t,Pc(this)).timeUntil()}}window.customElements.get("time-until")||(window.TimeUntilElement=Gc,window.customElements.define("time-until",Gc));const Yc=L.start();Yc.register("clipboard-copy-component",class extends q{copy(){const e=this.element.attributes.getNamedItem("value"),t=this.element.attributes.getNamedItem("for");if(e)navigator.clipboard.writeText(e.value);else if(t){const e=document.getElementById(t.value);navigator.clipboard.writeText((null==e?void 0:e.textContent)||"")}else navigator.clipboard.writeText(this.element.textContent||"")}}),Yc.register("ariadne-form",Ee),Yc.register("rich-text-area-component",al),Yc.register("slideover-component",ll),Yc.register("tab-nav-component",cl),Yc.register("tooltip-component",bc);
7
+ var J;q.blessings=[function(e){return k(e,"classes").reduce(((e,t)=>{return Object.assign(e,{[`${n=t}Class`]:{get(){const{classes:e}=this;if(e.has(n))return e.get(n);{const t=e.getAttributeName(n);throw new Error(`Missing attribute "${t}"`)}}},[`${n}Classes`]:{get(){return this.classes.getAll(n)}},[`has${s(n)}Class`]:{get(){return this.classes.has(n)}}});var n}),{})},function(e){return k(e,"targets").reduce(((e,t)=>{return Object.assign(e,{[`${n=t}Target`]:{get(){const e=this.targets.find(n);if(e)return e;throw new Error(`Missing target element "${n}" for "${this.identifier}" controller`)}},[`${n}Targets`]:{get(){return this.targets.findAll(n)}},[`has${s(n)}Target`]:{get(){return this.targets.has(n)}}});var n}),{})},function(e){const t=S(e,"values"),n={valueDescriptorMap:{get(){return t.reduce(((e,t)=>{const n=z(t,this.identifier),r=this.data.getAttributeNameForKey(n.key);return Object.assign(e,{[r]:n})}),{})}}};return t.reduce(((e,t)=>Object.assign(e,function(e,t){const n=z(e,t),{key:r,name:i,reader:o,writer:a}=n;return{[i]:{get(){const e=this.data.get(r);return null!==e?o(e):n.defaultValue},set(e){void 0===e?this.data.delete(r):this.data.set(r,a(e))}},[`has${s(i)}`]:{get(){return this.data.has(r)||n.hasCustomDefaultValue}}}}(t))),n)}],q.targets=[],q.values={};const U=window,G=U.trustedTypes,Y=G?G.createPolicy("lit-html",{createHTML:e=>e}):void 0,X=`lit$${(Math.random()+"").slice(9)}$`,Z="?"+X,Q=`<${Z}>`,ee=document,te=(e="")=>ee.createComment(e),ne=e=>null===e||"object"!=typeof e&&"function"!=typeof e,re=Array.isArray,ie=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,se=/-->/g,oe=/>/g,ae=RegExp(">|[ \t\n\f\r](?:([^\\s\"'>=/]+)([ \t\n\f\r]*=[ \t\n\f\r]*(?:[^ \t\n\f\r\"'`<>=]|(\"|')|))|$)","g"),le=/'/g,ce=/"/g,he=/^(?:script|style|textarea|title)$/i,de=(e=>(t,...n)=>({_$litType$:e,strings:t,values:n}))(1),ue=Symbol.for("lit-noChange"),pe=Symbol.for("lit-nothing"),fe=new WeakMap,me=ee.createTreeWalker(ee,129,null,!1),ge=(e,t)=>{const n=e.length-1,r=[];let i,s=2===t?"<svg>":"",o=ie;for(let t=0;t<n;t++){const n=e[t];let a,l,c=-1,h=0;for(;h<n.length&&(o.lastIndex=h,l=o.exec(n),null!==l);)h=o.lastIndex,o===ie?"!--"===l[1]?o=se:void 0!==l[1]?o=oe:void 0!==l[2]?(he.test(l[2])&&(i=RegExp("</"+l[2],"g")),o=ae):void 0!==l[3]&&(o=ae):o===ae?">"===l[0]?(o=null!=i?i:ie,c=-1):void 0===l[1]?c=-2:(c=o.lastIndex-l[2].length,a=l[1],o=void 0===l[3]?ae:'"'===l[3]?ce:le):o===ce||o===le?o=ae:o===se||o===oe?o=ie:(o=ae,i=void 0);const d=o===ae&&e[t+1].startsWith("/>")?" ":"";s+=o===ie?n+Q:c>=0?(r.push(a),n.slice(0,c)+"$lit$"+n.slice(c)+X+d):n+X+(-2===c?(r.push(void 0),t):d)}const a=s+(e[n]||"<?>")+(2===t?"</svg>":"");if(!Array.isArray(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return[void 0!==Y?Y.createHTML(a):a,r]};class ye{constructor({strings:e,_$litType$:t},n){let r;this.parts=[];let i=0,s=0;const o=e.length-1,a=this.parts,[l,c]=ge(e,t);if(this.el=ye.createElement(l,n),me.currentNode=this.el.content,2===t){const e=this.el.content,t=e.firstChild;t.remove(),e.append(...t.childNodes)}for(;null!==(r=me.nextNode())&&a.length<o;){if(1===r.nodeType){if(r.hasAttributes()){const e=[];for(const t of r.getAttributeNames())if(t.endsWith("$lit$")||t.startsWith(X)){const n=c[s++];if(e.push(t),void 0!==n){const e=r.getAttribute(n.toLowerCase()+"$lit$").split(X),t=/([.?@])?(.*)/.exec(n);a.push({type:1,index:i,name:t[2],strings:e,ctor:"."===t[1]?ke:"?"===t[1]?Me:"@"===t[1]?Oe:xe})}else a.push({type:6,index:i})}for(const t of e)r.removeAttribute(t)}if(he.test(r.tagName)){const e=r.textContent.split(X),t=e.length-1;if(t>0){r.textContent=G?G.emptyScript:"";for(let n=0;n<t;n++)r.append(e[n],te()),me.nextNode(),a.push({type:2,index:++i});r.append(e[t],te())}}}else if(8===r.nodeType)if(r.data===Z)a.push({type:2,index:i});else{let e=-1;for(;-1!==(e=r.data.indexOf(X,e+1));)a.push({type:7,index:i}),e+=X.length-1}i++}}static createElement(e,t){const n=ee.createElement("template");return n.innerHTML=e,n}}function ve(e,t,n=e,r){var i,s,o,a;if(t===ue)return t;let l=void 0!==r?null===(i=n._$Cl)||void 0===i?void 0:i[r]:n._$Cu;const c=ne(t)?void 0:t._$litDirective$;return(null==l?void 0:l.constructor)!==c&&(null===(s=null==l?void 0:l._$AO)||void 0===s||s.call(l,!1),void 0===c?l=void 0:(l=new c(e),l._$AT(e,n,r)),void 0!==r?(null!==(o=(a=n)._$Cl)&&void 0!==o?o:a._$Cl=[])[r]=l:n._$Cu=l),void 0!==l&&(t=ve(e,l._$AS(e,t.values),l,r)),t}class we{constructor(e,t){this.v=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}p(e){var t;const{el:{content:n},parts:r}=this._$AD,i=(null!==(t=null==e?void 0:e.creationScope)&&void 0!==t?t:ee).importNode(n,!0);me.currentNode=i;let s=me.nextNode(),o=0,a=0,l=r[0];for(;void 0!==l;){if(o===l.index){let t;2===l.type?t=new be(s,s.nextSibling,this,e):1===l.type?t=new l.ctor(s,l.name,l.strings,this,e):6===l.type&&(t=new Ce(s,this,e)),this.v.push(t),l=r[++a]}o!==(null==l?void 0:l.index)&&(s=me.nextNode(),o++)}return i}m(e){let t=0;for(const n of this.v)void 0!==n&&(void 0!==n.strings?(n._$AI(e,n,t),t+=n.strings.length-2):n._$AI(e[t])),t++}}class be{constructor(e,t,n,r){var i;this.type=2,this._$AH=pe,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=n,this.options=r,this._$C_=null===(i=null==r?void 0:r.isConnected)||void 0===i||i}get _$AU(){var e,t;return null!==(t=null===(e=this._$AM)||void 0===e?void 0:e._$AU)&&void 0!==t?t:this._$C_}get parentNode(){let e=this._$AA.parentNode;const t=this._$AM;return void 0!==t&&11===e.nodeType&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=ve(this,e,t),ne(e)?e===pe||null==e||""===e?(this._$AH!==pe&&this._$AR(),this._$AH=pe):e!==this._$AH&&e!==ue&&this.$(e):void 0!==e._$litType$?this.T(e):void 0!==e.nodeType?this.k(e):(e=>re(e)||"function"==typeof(null==e?void 0:e[Symbol.iterator]))(e)?this.O(e):this.$(e)}S(e,t=this._$AB){return this._$AA.parentNode.insertBefore(e,t)}k(e){this._$AH!==e&&(this._$AR(),this._$AH=this.S(e))}$(e){this._$AH!==pe&&ne(this._$AH)?this._$AA.nextSibling.data=e:this.k(ee.createTextNode(e)),this._$AH=e}T(e){var t;const{values:n,_$litType$:r}=e,i="number"==typeof r?this._$AC(e):(void 0===r.el&&(r.el=ye.createElement(r.h,this.options)),r);if((null===(t=this._$AH)||void 0===t?void 0:t._$AD)===i)this._$AH.m(n);else{const e=new we(i,this),t=e.p(this.options);e.m(n),this.k(t),this._$AH=e}}_$AC(e){let t=fe.get(e.strings);return void 0===t&&fe.set(e.strings,t=new ye(e)),t}O(e){re(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let n,r=0;for(const i of e)r===t.length?t.push(n=new be(this.S(te()),this.S(te()),this,this.options)):n=t[r],n._$AI(i),r++;r<t.length&&(this._$AR(n&&n._$AB.nextSibling,r),t.length=r)}_$AR(e=this._$AA.nextSibling,t){var n;for(null===(n=this._$AP)||void 0===n||n.call(this,!1,!0,t);e&&e!==this._$AB;){const t=e.nextSibling;e.remove(),e=t}}setConnected(e){var t;void 0===this._$AM&&(this._$C_=e,null===(t=this._$AP)||void 0===t||t.call(this,e))}}class xe{constructor(e,t,n,r,i){this.type=1,this._$AH=pe,this._$AN=void 0,this.element=e,this.name=t,this._$AM=r,this.options=i,n.length>2||""!==n[0]||""!==n[1]?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=pe}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(e,t=this,n,r){const i=this.strings;let s=!1;if(void 0===i)e=ve(this,e,t,0),s=!ne(e)||e!==this._$AH&&e!==ue,s&&(this._$AH=e);else{const r=e;let o,a;for(e=i[0],o=0;o<i.length-1;o++)a=ve(this,r[n+o],t,o),a===ue&&(a=this._$AH[o]),s||(s=!ne(a)||a!==this._$AH[o]),a===pe?e=pe:e!==pe&&(e+=(null!=a?a:"")+i[o+1]),this._$AH[o]=a}s&&!r&&this.P(e)}P(e){e===pe?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=e?e:"")}}class ke extends xe{constructor(){super(...arguments),this.type=3}P(e){this.element[this.name]=e===pe?void 0:e}}const Se=G?G.emptyScript:"";class Me extends xe{constructor(){super(...arguments),this.type=4}P(e){e&&e!==pe?this.element.setAttribute(this.name,Se):this.element.removeAttribute(this.name)}}class Oe extends xe{constructor(e,t,n,r,i){super(e,t,n,r,i),this.type=5}_$AI(e,t=this){var n;if((e=null!==(n=ve(this,e,t,0))&&void 0!==n?n:pe)===ue)return;const r=this._$AH,i=e===pe&&r!==pe||e.capture!==r.capture||e.once!==r.once||e.passive!==r.passive,s=e!==pe&&(r===pe||i);i&&this.element.removeEventListener(this.name,this,r),s&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var t,n;"function"==typeof this._$AH?this._$AH.call(null!==(n=null===(t=this.options)||void 0===t?void 0:t.host)&&void 0!==n?n:this.element,e):this._$AH.handleEvent(e)}}class Ce{constructor(e,t,n){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=n}get _$AU(){return this._$AM._$AU}_$AI(e){ve(this,e)}}const Ae=U.litHtmlPolyfillSupport;null==Ae||Ae(ye,be),(null!==(J=U.litHtmlVersions)&&void 0!==J?J:U.litHtmlVersions=[]).push("2.3.1");class Ee extends q{constructor(){super(...arguments),this.onBlur=e=>{this.validateField(e.target)},this.onSubmit=e=>{var t;this.validateForm()||(e.preventDefault(),null===(t=this.firstInvalidField)||void 0===t||t.focus())},this.getRenderString=e=>{const{strings:t,values:n}=e,r=[...n,""].map((e=>"object"==typeof e?this.getRenderString(e):e));return t.reduce(((e,t,n)=>e+t+r[n]),"")}}connect(){this.element.setAttribute("novalidate","true"),this.element.addEventListener("blur",this.onBlur,!0),this.element.addEventListener("submit",this.onSubmit),this.element.addEventListener("ajax:beforeSend",this.onSubmit)}disconnect(){this.element.removeEventListener("blur",this.onBlur),this.element.removeEventListener("submit",this.onSubmit),this.element.removeEventListener("ajax:beforeSend",this.onSubmit)}validateForm(){let e=!0;for(const t of this.formFields)this.shouldValidateField(t)&&!this.validateField(t)&&(e=!1);return e}validateField(e){if(!this.shouldValidateField(e))return!0;const t=e.checkValidity();return e.classList.toggle("invalid",!t),this.refreshErrorForInvalidField(e,t),t}shouldValidateField(e){return!e.disabled&&!e.classList.contains("ProseMirror")&&!["file","reset","submit","button"].includes(e.type)}refreshErrorForInvalidField(e,t){this.removeExistingErrorMessage(e),t||this.showErrorForInvalidField(e)}removeExistingErrorMessage(e){var t;const n=e.closest(".field");if(!n)return;const r=n.querySelector(".error");r&&(null===(t=null==r?void 0:r.parentNode)||void 0===t||t.removeChild(r))}showErrorForInvalidField(e){e.insertAdjacentHTML("afterend",this.buildFieldErrorHtml(e))}buildFieldErrorHtml(e){const t=de`<p class="error">${e.validationMessage}</p>`;return this.getRenderString(t)}get formFields(){return Array.from(this.formFieldTargets)}get firstInvalidField(){return this.formFields.find((e=>!e.checkValidity()))}}Ee.targets=["formField"];function Te(e){this.content=e}function Ne(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),s=t.child(r);if(i!=s){if(!i.sameMarkup(s))return n;if(i.isText&&i.text!=s.text){for(let e=0;i.text[e]==s.text[e];e++)n++;return n}if(i.content.size||s.content.size){let e=Ne(i.content,s.content,n+1);if(null!=e)return e}n+=i.nodeSize}else n+=i.nodeSize}}function De(e,t,n,r){for(let i=e.childCount,s=t.childCount;;){if(0==i||0==s)return i==s?null:{a:n,b:r};let o=e.child(--i),a=t.child(--s),l=o.nodeSize;if(o!=a){if(!o.sameMarkup(a))return{a:n,b:r};if(o.isText&&o.text!=a.text){let e=0,t=Math.min(o.text.length,a.text.length);for(;e<t&&o.text[o.text.length-e-1]==a.text[a.text.length-e-1];)e++,n--,r--;return{a:n,b:r}}if(o.content.size||a.content.size){let e=De(o.content,a.content,n-1,r-1);if(e)return e}n-=l,r-=l}else n-=l,r-=l}}Te.prototype={constructor:Te,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return-1==t?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,i=r.find(e),s=r.content.slice();return-1==i?s.push(n||e,t):(s[i+1]=t,n&&(s[i]=n)),new Te(s)},remove:function(e){var t=this.find(e);if(-1==t)return this;var n=this.content.slice();return n.splice(t,2),new Te(n)},addToStart:function(e,t){return new Te([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new Te(n)},addBefore:function(e,t,n){var r=this.remove(t),i=r.content.slice(),s=r.find(e);return i.splice(-1==s?i.length:s,0,t,n),new Te(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return(e=Te.from(e)).size?new Te(e.content.concat(this.subtract(e).content)):this},append:function(e){return(e=Te.from(e)).size?new Te(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=Te.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},get size(){return this.content.length>>1}},Te.from=function(e){if(e instanceof Te)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new Te(t)};class $e{constructor(e,t){if(this.content=e,this.size=t||0,null==t)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,i){for(let s=0,o=0;o<t;s++){let a=this.content[s],l=o+a.nodeSize;if(l>e&&!1!==n(a,r+o,i||null,s)&&a.content.size){let i=o+1;a.nodesBetween(Math.max(0,e-i),Math.min(a.content.size,t-i),n,r+i)}o=l}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i="",s=!0;return this.nodesBetween(e,t,((o,a)=>{o.isText?(i+=o.text.slice(Math.max(e,a)-a,t-a),s=!n):o.isLeaf?(r?i+="function"==typeof r?r(o):r:o.type.spec.leafText&&(i+=o.type.spec.leafText(o)),s=!n):!s&&o.isBlock&&(i+=n,s=!0)}),0),i}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,n=e.firstChild,r=this.content.slice(),i=0;for(t.isText&&t.sameMarkup(n)&&(r[r.length-1]=t.withText(t.text+n.text),i=1);i<e.content.length;i++)r.push(e.content[i]);return new $e(r,this.size+e.size)}cut(e,t=this.size){if(0==e&&t==this.size)return this;let n=[],r=0;if(t>e)for(let i=0,s=0;s<t;i++){let o=this.content[i],a=s+o.nodeSize;a>e&&((s<e||a>t)&&(o=o.isText?o.cut(Math.max(0,e-s),Math.min(o.text.length,t-s)):o.cut(Math.max(0,e-s-1),Math.min(o.content.size,t-s-1))),n.push(o),r+=o.nodeSize),s=a}return new $e(n,r)}cutByIndex(e,t){return e==t?$e.empty:0==e&&t==this.content.length?this:new $e(this.content.slice(e,t))}replaceChild(e,t){let n=this.content[e];if(n==t)return this;let r=this.content.slice(),i=this.size+t.nodeSize-n.nodeSize;return r[e]=t,new $e(r,i)}addToStart(e){return new $e([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new $e(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return Ne(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return De(this,e,t,n)}findIndex(e,t=-1){if(0==e)return Re(0,e);if(e==this.size)return Re(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let i=r+this.child(n).nodeSize;if(i>=e)return i==e||t>0?Re(n+1,i):Re(n,r);r=i}}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 $e.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new $e(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return $e.empty;let t,n=0;for(let r=0;r<e.length;r++){let i=e[r];n+=i.nodeSize,r&&i.isText&&e[r-1].sameMarkup(i)?(t||(t=e.slice(0,r)),t[t.length-1]=i.withText(t[t.length-1].text+i.text)):t&&t.push(i)}return new $e(t||e,n)}static from(e){if(!e)return $e.empty;if(e instanceof $e)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new $e([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}$e.empty=new $e([],0);const Ie={index:0,offset:0};function Re(e,t){return Ie.index=e,Ie.offset=t,Ie}function Pe(e,t){if(e===t)return!0;if(!e||"object"!=typeof e||!t||"object"!=typeof t)return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!Pe(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!Pe(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}class Be{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))t||(t=e.slice(0,r));else{if(i.type.excludes(this.type))return e;!n&&i.type.rank>this.type.rank&&(t||(t=e.slice(0,r)),t.push(this),n=!0),t&&t.push(i)}}return t||(t=e.slice()),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Pe(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let n=e.marks[t.type];if(!n)throw new RangeError(`There is no mark type ${t.type} in this schema`);return n.create(t.attrs)}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&0==e.length)return Be.none;if(e instanceof Be)return[e];let t=e.slice();return t.sort(((e,t)=>e.type.rank-t.type.rank)),t}}Be.none=[];class Fe extends Error{}class Le{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let n=Ve(this.content,e+this.openStart,t);return n&&new Le(n,this.openStart,this.openEnd)}removeBetween(e,t){return new Le(ze(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 Le.empty;let n=t.openStart||0,r=t.openEnd||0;if("number"!=typeof n||"number"!=typeof r)throw new RangeError("Invalid input for Slice.fromJSON");return new Le($e.fromJSON(e,t.content),n,r)}static maxOpen(e,t=!0){let n=0,r=0;for(let r=e.firstChild;r&&!r.isLeaf&&(t||!r.type.spec.isolating);r=r.firstChild)n++;for(let n=e.lastChild;n&&!n.isLeaf&&(t||!n.type.spec.isolating);n=n.lastChild)r++;return new Le(e,n,r)}}function ze(e,t,n){let{index:r,offset:i}=e.findIndex(t),s=e.maybeChild(r),{index:o,offset:a}=e.findIndex(n);if(i==t||s.isText){if(a!=n&&!e.child(o).isText)throw new RangeError("Removing non-flat range");return e.cut(0,t).append(e.cut(n))}if(r!=o)throw new RangeError("Removing non-flat range");return e.replaceChild(r,s.copy(ze(s.content,t-i-1,n-i-1)))}function Ve(e,t,n,r){let{index:i,offset:s}=e.findIndex(t),o=e.maybeChild(i);if(s==t||o.isText)return r&&!r.canReplace(i,i,n)?null:e.cut(0,t).append(n).append(e.cut(t));let a=Ve(o.content,t-s-1,n);return a&&e.replaceChild(i,o.copy(a))}function je(e,t,n){if(n.openStart>e.depth)throw new Fe("Inserted content deeper than insertion position");if(e.depth-n.openStart!=t.depth-n.openEnd)throw new Fe("Inconsistent open depths");return _e(e,t,n,0)}function _e(e,t,n,r){let i=e.index(r),s=e.node(r);if(i==t.index(r)&&r<e.depth-n.openStart){let o=_e(e,t,n,r+1);return s.copy(s.content.replaceChild(i,o))}if(n.content.size){if(n.openStart||n.openEnd||e.depth!=r||t.depth!=r){let{start:i,end:o}=function(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy($e.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}(n,e);return Je(s,Ue(e,i,o,t,r))}{let r=e.parent,i=r.content;return Je(r,i.cut(0,e.parentOffset).append(n.content).append(i.cut(t.parentOffset)))}}return Je(s,Ge(e,t,r))}function We(e,t){if(!t.type.compatibleContent(e.type))throw new Fe("Cannot join "+t.type.name+" onto "+e.type.name)}function He(e,t,n){let r=e.node(n);return We(r,t.node(n)),r}function Ke(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function qe(e,t,n,r){let i=(t||e).node(n),s=0,o=t?t.index(n):i.childCount;e&&(s=e.index(n),e.depth>n?s++:e.textOffset&&(Ke(e.nodeAfter,r),s++));for(let e=s;e<o;e++)Ke(i.child(e),r);t&&t.depth==n&&t.textOffset&&Ke(t.nodeBefore,r)}function Je(e,t){if(!e.type.validContent(t))throw new Fe("Invalid content for node "+e.type.name);return e.copy(t)}function Ue(e,t,n,r,i){let s=e.depth>i&&He(e,t,i+1),o=r.depth>i&&He(n,r,i+1),a=[];return qe(null,e,i,a),s&&o&&t.index(i)==n.index(i)?(We(s,o),Ke(Je(s,Ue(e,t,n,r,i+1)),a)):(s&&Ke(Je(s,Ge(e,t,i+1)),a),qe(t,n,i,a),o&&Ke(Je(o,Ge(n,r,i+1)),a)),qe(r,null,i,a),new $e(a)}function Ge(e,t,n){let r=[];if(qe(null,e,n,r),e.depth>n){Ke(Je(He(e,t,n+1),Ge(e,t,n+1)),r)}return qe(t,null,n,r),new $e(r)}Le.empty=new Le($e.empty,0,0);class Ye{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return null==e?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[3*this.resolveDepth(e)]}index(e){return this.path[3*this.resolveDepth(e)+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e!=this.depth||this.textOffset?1:0)}start(e){return 0==(e=this.resolveDepth(e))?0:this.path[3*e-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]}after(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]+this.path[3*e].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):0==e?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[3*t],r=0==t?0:this.path[3*t-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(0==e.content.size)return Be.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let i=n.marks;for(var s=0;s<i.length;s++)!1!==i[s].type.spec.inclusive||r&&i[s].isInSet(r.marks)||(i=i[s--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var i=0;i<n.length;i++)!1!==n[i].type.spec.inclusive||r&&n[i].isInSet(r.marks)||(n=n[i--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new et(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let n=[],r=0,i=t;for(let t=e;;){let{index:e,offset:s}=t.content.findIndex(i),o=i-s;if(n.push(t,e,r+s),!o)break;if(t=t.child(e),t.isText)break;i=o-1,r+=s+1}return new Ye(t,n,i)}static resolveCached(e,t){for(let n=0;n<Xe.length;n++){let r=Xe[n];if(r.pos==t&&r.doc==e)return r}let n=Xe[Ze]=Ye.resolve(e,t);return Ze=(Ze+1)%Qe,n}}let Xe=[],Ze=0,Qe=12;class et{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const tt=Object.create(null);class nt{constructor(e,t,n,r=Be.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||$e.empty}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&Pe(this.attrs,t||e.defaultAttrs||tt)&&Be.sameSet(this.marks,n||Be.none)}copy(e=null){return e==this.content?this:new nt(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new nt(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return 0==e&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return Le.empty;let r=this.resolve(e),i=this.resolve(t),s=n?0:r.sharedDepth(t),o=r.start(s),a=r.node(s).content.cut(r.pos-o,i.pos-o);return new Le(a,r.depth-s,i.depth-s)}replace(e,t,n){return je(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(0==e)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return Ye.resolveCached(this,e)}resolveNoCache(e){return Ye.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,(e=>(n.isInSet(e.marks)&&(r=!0),!r))),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),it(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,n=$e.empty,r=0,i=n.childCount){let s=this.contentMatchAt(e).matchFragment(n,r,i),o=s&&s.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;e<i;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(e).matchType(n),s=i&&i.matchFragment(this.content,t);return!!s&&s.validEnd}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){if(!this.type.validContent(this.content))throw new RangeError(`Invalid content for node ${this.type.name}: ${this.content.toString().slice(0,50)}`);let e=Be.none;for(let t=0;t<this.marks.length;t++)e=this.marks[t].addToSet(e);if(!Be.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map((e=>e.type.name))}`);this.content.forEach((e=>e.check()))}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map((e=>e.toJSON()))),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let n=null;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=t.marks.map(e.markFromJSON)}if("text"==t.type){if("string"!=typeof t.text)throw new RangeError("Invalid text node in JSON");return e.text(t.text,n)}let r=$e.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,r,n)}}nt.prototype.text=void 0;class rt extends nt{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):it(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 rt(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new rt(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return 0==e&&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 it(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+"("+t+")";return t}class st{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let n=new ot(e,t);if(null==n.next)return st.empty;let r=at(n);n.next&&n.err("Unexpected trailing text");let i=function(e){let t=Object.create(null);return n(pt(e,0));function n(r){let i=[];r.forEach((t=>{e[t].forEach((({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e<i.length;e++)i[e][0]==t&&(r=i[e][1]);pt(e,n).forEach((e=>{r||i.push([t,r=[]]),-1==r.indexOf(e)&&r.push(e)}))}))}));let s=t[r.join(",")]=new st(r.indexOf(e.length-1)>-1);for(let e=0;e<i.length;e++){let r=i[e][1].sort(ut);s.next.push({type:i[e][0],next:t[r.join(",")]||n(r)})}return s}}(function(e){let t=[[]];return i(s(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let i={term:r,to:n};return t[e].push(i),i}function i(e,t){e.forEach((e=>e.to=t))}function s(e,t){if("choice"==e.type)return e.exprs.reduce(((e,n)=>e.concat(s(n,t))),[]);if("seq"!=e.type){if("star"==e.type){let o=n();return r(t,o),i(s(e.expr,o),o),[r(o)]}if("plus"==e.type){let o=n();return i(s(e.expr,t),o),i(s(e.expr,o),o),[r(o)]}if("opt"==e.type)return[r(t)].concat(s(e.expr,t));if("range"==e.type){let o=t;for(let t=0;t<e.min;t++){let t=n();i(s(e.expr,o),t),o=t}if(-1==e.max)i(s(e.expr,o),o);else for(let t=e.min;t<e.max;t++){let t=n();r(o,t),i(s(e.expr,o),t),o=t}return[r(o)]}if("name"==e.type)return[r(t,void 0,e.value)];throw new Error("Unknown expr type")}for(let r=0;;r++){let o=s(e.exprs[r],t);if(r==e.exprs.length-1)return o;i(o,t=n())}}}(r));return function(e,t){for(let n=0,r=[e];n<r.length;n++){let e=r[n],i=!e.validEnd,s=[];for(let t=0;t<e.next.length;t++){let{type:n,next:o}=e.next[t];s.push(n.name),!i||n.isText||n.hasRequiredAttrs()||(i=!1),-1==r.indexOf(o)&&r.push(o)}i&&t.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(i,n),i}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let i=t;r&&i<n;i++)r=r.matchType(e.child(i).type);return r}get inlineContent(){return this.next.length&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!t.isText&&!t.hasRequiredAttrs())return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];return function i(s,o){let a=s.matchFragment(e,n);if(a&&(!t||a.validEnd))return $e.from(o.map((e=>e.createAndFill())));for(let e=0;e<s.next.length;e++){let{type:t,next:n}=s.next[e];if(!t.isText&&!t.hasRequiredAttrs()&&-1==r.indexOf(n)){r.push(n);let e=i(n,o.concat(t));if(e)return e}}return null}(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<i.next.length;e++){let{type:s,next:o}=i.next[e];s.isLeaf||s.hasRequiredAttrs()||s.name in t||r.type&&!o.validEnd||(n.push({match:s.contentMatch,type:s,via:r}),t[s.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];return function t(n){e.push(n);for(let r=0;r<n.next.length;r++)-1==e.indexOf(n.next[r].next)&&t(n.next[r].next)}(this),e.map(((t,n)=>{let r=n+(t.validEnd?"*":" ")+" ";for(let n=0;n<t.next.length;n++)r+=(n?", ":"")+t.next[n].type.name+"->"+e.indexOf(t.next[n].next);return r})).join("\n")}}st.empty=new st(!0);class ot{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 at(e){let t=[];do{t.push(lt(e))}while(e.eat("|"));return 1==t.length?t[0]:{type:"choice",exprs:t}}function lt(e){let t=[];do{t.push(ct(e))}while(e.next&&")"!=e.next&&"|"!=e.next);return 1==t.length?t[0]:{type:"seq",exprs:t}}function ct(e){let t=function(e){if(e.eat("(")){let t=at(e);return e.eat(")")||e.err("Missing closing paren"),t}if(!/\W/.test(e.next)){let t=function(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let i=[];for(let e in n){let r=n[e];r.groups.indexOf(t)>-1&&i.push(r)}0==i.length&&e.err("No node type or group '"+t+"' found");return i}(e,e.next).map((t=>(null==e.inline?e.inline=t.isInline:e.inline!=t.isInline&&e.err("Mixing inline and block content"),{type:"name",value:t})));return e.pos++,1==t.length?t[0]:{type:"choice",exprs:t}}e.err("Unexpected token '"+e.next+"'")}(e);for(;;)if(e.eat("+"))t={type:"plus",expr:t};else if(e.eat("*"))t={type:"star",expr:t};else if(e.eat("?"))t={type:"opt",expr:t};else{if(!e.eat("{"))break;t=dt(e,t)}return t}function ht(e){/\D/.test(e.next)&&e.err("Expected number, got '"+e.next+"'");let t=Number(e.next);return e.pos++,t}function dt(e,t){let n=ht(e),r=n;return e.eat(",")&&(r="}"!=e.next?ht(e):-1),e.eat("}")||e.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:t}}function ut(e,t){return t-e}function pt(e,t){let n=[];return function t(r){let i=e[r];if(1==i.length&&!i[0].term)return t(i[0].to);n.push(r);for(let e=0;e<i.length;e++){let{term:r,to:s}=i[e];r||-1!=n.indexOf(s)||t(s)}}(t),n.sort(ut)}function ft(e){let t=Object.create(null);for(let n in e){let r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function mt(e,t){let n=Object.create(null);for(let r in e){let i=t&&t[r];if(void 0===i){let t=e[r];if(!t.hasDefault)throw new RangeError("No value supplied for attribute "+r);i=t.default}n[r]=i}return n}function gt(e){let t=Object.create(null);if(e)for(let n in e)t[n]=new vt(e[n]);return t}class yt{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(" "):[],this.attrs=gt(n.attrs),this.defaultAttrs=ft(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||"text"==e),this.isText="text"==e}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==st.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:mt(this.attrs,e)}create(e=null,t,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new nt(this,this.computeAttrs(e),$e.from(t),Be.setFrom(n))}createChecked(e=null,t,n){if(t=$e.from(t),!this.validContent(t))throw new RangeError("Invalid content for node "+this.name);return new nt(this,this.computeAttrs(e),t,Be.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),(t=$e.from(t)).size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let r=this.contentMatch.matchFragment(t),i=r&&r.fillBefore($e.empty,!0);return i?new nt(this,e,t.append(i),Be.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t<e.childCount;t++)if(!this.allowsMarks(e.child(t).marks))return!1;return!0}allowsMarkType(e){return null==this.markSet||this.markSet.indexOf(e)>-1}allowsMarks(e){if(null==this.markSet)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(null==this.markSet)return e;let t;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||(t=e.slice(0,n));return t?t.length?t:Be.none:e}static compile(e,t){let n=Object.create(null);e.forEach(((e,r)=>n[e]=new yt(e,t,r)));let r=t.spec.topNode||"doc";if(!n[r])throw new RangeError("Schema is missing its top node type ('"+r+"')");if(!n.text)throw new RangeError("Every schema needs a 'text' type");for(let e in n.text.attrs)throw new RangeError("The text node type should not have attributes");return n}}class vt{constructor(e){this.hasDefault=Object.prototype.hasOwnProperty.call(e,"default"),this.default=e.default}get isRequired(){return!this.hasDefault}}class wt{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=gt(r.attrs),this.excluded=null;let i=ft(this.attrs);this.instance=i?new Be(this,i):null}create(e=null){return!e&&this.instance?this.instance:new Be(this,mt(this.attrs,e))}static compile(e,t){let n=Object.create(null),r=0;return e.forEach(((e,i)=>n[e]=new wt(e,r++,t,i))),n}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}excludes(e){return this.excluded.indexOf(e)>-1}}class bt{constructor(e){this.cached=Object.create(null),this.spec={nodes:Te.from(e.nodes),marks:Te.from(e.marks||{}),topNode:e.topNode},this.nodes=yt.compile(this.spec.nodes,this),this.marks=wt.compile(this.spec.marks,this);let t=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw new RangeError(e+" can not be both a node and a mark");let n=this.nodes[e],r=n.spec.content||"",i=n.spec.marks;n.contentMatch=t[r]||(t[r]=st.parse(r,this.nodes)),n.inlineContent=n.contentMatch.inlineContent,n.markSet="_"==i?null:i?xt(this,i.split(" ")):""!=i&&n.inlineContent?null:[]}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=null==n?[t]:""==n?[]:xt(this,n.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,n,r){if("string"==typeof e)e=this.nodeType(e);else{if(!(e instanceof yt))throw new RangeError("Invalid node type: "+e);if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}return e.createChecked(t,n,r)}text(e,t){let n=this.nodes.text;return new rt(n,n.defaultAttrs,e,Be.setFrom(t))}mark(e,t){return"string"==typeof e&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return nt.fromJSON(this,e)}markFromJSON(e){return Be.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function xt(e,t){let n=[];for(let r=0;r<t.length;r++){let i=t[r],s=e.marks[i],o=s;if(s)n.push(s);else for(let t in e.marks){let r=e.marks[t];("_"==i||r.spec.group&&r.spec.group.split(" ").indexOf(i)>-1)&&n.push(o=r)}if(!o)throw new SyntaxError("Unknown mark type: '"+t[r]+"'")}return n}class kt{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[],t.forEach((e=>{e.tag?this.tags.push(e):e.style&&this.styles.push(e)})),this.normalizeLists=!this.tags.some((t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)}))}parse(e,t={}){let n=new Et(this,t,!1);return n.addAll(e,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new Et(this,t,!0);return n.addAll(e,t.from,t.to),Le.maxOpen(n.finish())}matchTag(e,t,n){for(let r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){let n=this.tags[r];if(Tt(e,n.tag)&&(void 0===n.namespace||e.namespaceURI==n.namespace)&&(!n.context||t.matchesContext(n.context))){if(n.getAttrs){let t=n.getAttrs(e);if(!1===t)continue;n.attrs=t||void 0}return n}}}matchStyle(e,t,n,r){for(let i=r?this.styles.indexOf(r)+1:0;i<this.styles.length;i++){let r=this.styles[i],s=r.style;if(!(0!=s.indexOf(e)||r.context&&!n.matchesContext(r.context)||s.length>e.length&&(61!=s.charCodeAt(e.length)||s.slice(e.length+1)!=t))){if(r.getAttrs){let e=r.getAttrs(t);if(!1===e)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=null==e.priority?50:e.priority,r=0;for(;r<t.length;r++){let e=t[r];if((null==e.priority?50:e.priority)<n)break}t.splice(r,0,e)}for(let t in e.marks){let r=e.marks[t].spec.parseDOM;r&&r.forEach((e=>{n(e=Nt(e)),e.mark=t}))}for(let t in e.nodes){let r=e.nodes[t].spec.parseDOM;r&&r.forEach((e=>{n(e=Nt(e)),e.node=t}))}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new kt(e,kt.schemaRules(e)))}}const St={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},Mt={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Ot={ol:!0,ul:!0};function Ct(e,t,n){return null!=t?(t?1:0)|("full"===t?2:0):e&&"pre"==e.whitespace?3:-5&n}class At{constructor(e,t,n,r,i,s,o){this.type=e,this.attrs=t,this.marks=n,this.pendingMarks=r,this.solid=i,this.options=o,this.content=[],this.activeMarks=Be.none,this.stashMarks=[],this.match=s||(4&o?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore($e.from(e));if(!t){let t,n=this.type.contentMatch;return(t=n.findWrapping(e.type))?(this.match=n,t):null}this.match=this.type.contentMatch.matchFragment(t)}return this.match.findWrapping(e.type)}finish(e){if(!(1&this.options)){let e,t=this.content[this.content.length-1];if(t&&t.isText&&(e=/[ \t\r\n\u000c]+$/.exec(t.text))){let n=t;t.text.length==e[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-e[0].length))}}let t=$e.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore($e.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}popFromStashMark(e){for(let t=this.stashMarks.length-1;t>=0;t--)if(e.eq(this.stashMarks[t]))return this.stashMarks.splice(t,1)[0]}applyPending(e){for(let t=0,n=this.pendingMarks;t<n.length;t++){let r=n[t];(this.type?this.type.allowsMarkType(r.type):Dt(r.type,e))&&!r.isInSet(this.activeMarks)&&(this.activeMarks=r.addToSet(this.activeMarks),this.pendingMarks=r.removeFromSet(this.pendingMarks))}}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!St.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Et{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0;let r,i=t.topNode,s=Ct(null,t.preserveWhitespace,0)|(n?4:0);r=i?new At(i.type,i.attrs,Be.none,Be.none,!0,t.topMatch||i.type.contentMatch,s):new At(n?null:e.schema.topNodeType,null,Be.none,Be.none,!0,null,s),this.nodes=[r],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e){if(3==e.nodeType)this.addTextNode(e);else if(1==e.nodeType){let t=e.getAttribute("style"),n=t?this.readStyles(function(e){let t,n=/\s*([\w-]+)\s*:\s*([^;]+)/g,r=[];for(;t=n.exec(e);)r.push(t[1],t[2].trim());return r}(t)):null,r=this.top;if(null!=n)for(let e=0;e<n.length;e++)this.addPendingMark(n[e]);if(this.addElement(e),null!=n)for(let e=0;e<n.length;e++)this.removePendingMark(n[e],r)}}addTextNode(e){let t=e.nodeValue,n=this.top;if(2&n.options||n.inlineContext(e)||/[^ \t\r\n\u000c]/.test(t)){if(1&n.options)t=2&n.options?t.replace(/\r\n?/g,"\n"):t.replace(/\r?\n|\r/g," ");else if(t=t.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(t)&&this.open==this.nodes.length-1){let r=n.content[n.content.length-1],i=e.previousSibling;(!r||i&&"BR"==i.nodeName||r.isText&&/[ \t\r\n\u000c]$/.test(r.text))&&(t=t.slice(1))}t&&this.insertNode(this.parser.schema.text(t)),this.findInText(e)}else this.findInside(e)}addElement(e,t){let n,r=e.nodeName.toLowerCase();Ot.hasOwnProperty(r)&&this.parser.normalizeLists&&function(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=1==t.nodeType?t.nodeName.toLowerCase():null;e&&Ot.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):"li"==e?n=t:e&&(n=null)}}(e);let i=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(n=this.parser.matchTag(e,this,t));if(i?i.ignore:Mt.hasOwnProperty(r))this.findInside(e),this.ignoreFallback(e);else if(!i||i.skip||i.closeParent){i&&i.closeParent?this.open=Math.max(0,this.open-1):i&&i.skip.nodeType&&(e=i.skip);let t,n=this.top,s=this.needsBlock;if(St.hasOwnProperty(r))t=!0,n.type||(this.needsBlock=!0);else if(!e.firstChild)return void this.leafFallback(e);this.addAll(e),t&&this.sync(n),this.needsBlock=s}else this.addElementByRule(e,i,!1===i.consuming?n:void 0)}leafFallback(e){"BR"==e.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode("\n"))}ignoreFallback(e){"BR"!=e.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"))}readStyles(e){let t=Be.none;e:for(let n=0;n<e.length;n+=2)for(let r;;){let i=this.parser.matchStyle(e[n],e[n+1],this,r);if(!i)continue e;if(i.ignore)return null;if(t=this.parser.schema.marks[i.mark].create(i.attrs).addToSet(t),!1!==i.consuming)break;r=i}return t}addElementByRule(e,t,n){let r,i,s;if(t.node)i=this.parser.schema.nodes[t.node],i.isLeaf?this.insertNode(i.create(t.attrs))||this.leafFallback(e):r=this.enter(i,t.attrs||null,t.preserveWhitespace);else{s=this.parser.schema.marks[t.mark].create(t.attrs),this.addPendingMark(s)}let o=this.top;if(i&&i.isLeaf)this.findInside(e);else if(n)this.addElement(e,n);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach((e=>this.insertNode(e)));else{let n=e;"string"==typeof t.contentElement?n=e.querySelector(t.contentElement):"function"==typeof t.contentElement?n=t.contentElement(e):t.contentElement&&(n=t.contentElement),this.findAround(e,n,!0),this.addAll(n)}r&&this.sync(o)&&this.open--,s&&this.removePendingMark(s,o)}addAll(e,t,n){let r=t||0;for(let i=t?e.childNodes[t]:e.firstChild,s=null==n?null:e.childNodes[n];i!=s;i=i.nextSibling,++r)this.findAtPoint(e,r),this.addDOM(i);this.findAtPoint(e,r)}findPlace(e){let t,n;for(let r=this.open;r>=0;r--){let i=this.nodes[r],s=i.findWrapping(e);if(s&&(!t||t.length>s.length)&&(t=s,n=i,!s.length))break;if(i.solid)break}if(!t)return!1;this.sync(n);for(let e=0;e<t.length;e++)this.enterInner(t[e],null,!1);return!0}insertNode(e){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&this.enterInner(e)}if(this.findPlace(e)){this.closeExtra();let t=this.top;t.applyPending(e.type),t.match&&(t.match=t.match.matchType(e.type));let n=t.activeMarks;for(let r=0;r<e.marks.length;r++)t.type&&!t.type.allowsMarkType(e.marks[r].type)||(n=e.marks[r].addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n){let r=this.findPlace(e.create(t));return r&&this.enterInner(e,t,!0,n),r}enterInner(e,t=null,n=!1,r){this.closeExtra();let i=this.top;i.applyPending(e),i.match=i.match&&i.match.matchType(e);let s=Ct(e,r,i.options);4&i.options&&0==i.content.length&&(s|=4),this.nodes.push(new At(e,t,i.activeMarks,i.pendingMarks,n,null,s)),this.open++}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 n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)null==this.find[t].pos&&1==e.nodeType&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let r=0;r<this.find.length;r++)if(null==this.find[r].pos&&1==e.nodeType&&e.contains(this.find[r].node)){t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),n=this.options.context,r=!(this.isOpen||n&&n.parent.type!=this.nodes[0].type),i=-(n?n.depth+1:0)+(r?0:1),s=(e,o)=>{for(;e>=0;e--){let a=t[e];if(""==a){if(e==t.length-1||0==e)continue;for(;o>=i;o--)if(s(e-1,o))return!0;return!1}{let e=o>0||0==o&&r?this.nodes[o].type:n&&o>=i?n.node(o-i).type:null;if(!e||e.name!=a&&-1==e.groups.indexOf(a))return!1;o--}}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 n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}addPendingMark(e){let t=function(e,t){for(let n=0;n<t.length;n++)if(e.eq(t[n]))return t[n]}(e,this.top.pendingMarks);t&&this.top.stashMarks.push(t),this.top.pendingMarks=e.addToSet(this.top.pendingMarks)}removePendingMark(e,t){for(let n=this.open;n>=0;n--){let r=this.nodes[n];if(r.pendingMarks.lastIndexOf(e)>-1)r.pendingMarks=e.removeFromSet(r.pendingMarks);else{r.activeMarks=e.removeFromSet(r.activeMarks);let t=r.popFromStashMark(e);t&&r.type&&r.type.allowsMarkType(t.type)&&(r.activeMarks=t.addToSet(r.activeMarks))}if(r==t)break}}}function Tt(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function Nt(e){let t={};for(let n in e)t[n]=e[n];return t}function Dt(e,t){let n=t.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(e))continue;let s=[],o=e=>{s.push(e);for(let n=0;n<e.edgeCount;n++){let{type:r,next:i}=e.edge(n);if(r==t)return!0;if(s.indexOf(i)<0&&o(i))return!0}};if(o(i.contentMatch))return!0}}class $t{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||(n=Rt(t).createDocumentFragment());let r=n,i=[];return e.forEach((e=>{if(i.length||e.marks.length){let n=0,s=0;for(;n<i.length&&s<e.marks.length;){let t=e.marks[s];if(this.marks[t.type.name]){if(!t.eq(i[n][0])||!1===t.type.spec.spanning)break;n++,s++}else s++}for(;n<i.length;)r=i.pop()[1];for(;s<e.marks.length;){let n=e.marks[s++],o=this.serializeMark(n,e.isInline,t);o&&(i.push([n,r]),r.appendChild(o.dom),r=o.contentDOM||o.dom)}}r.appendChild(this.serializeNodeInner(e,t))})),n}serializeNodeInner(e,t){let{dom:n,contentDOM:r}=$t.renderSpec(Rt(t),this.nodes[e.type.name](e));if(r){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,r)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let i=this.serializeMark(e.marks[r],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(n),n=i.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&$t.renderSpec(Rt(n),r(e,t))}static renderSpec(e,t,n=null){if("string"==typeof t)return{dom:e.createTextNode(t)};if(null!=t.nodeType)return{dom:t};if(t.dom&&null!=t.dom.nodeType)return t;let r,i=t[0],s=i.indexOf(" ");s>0&&(n=i.slice(0,s),i=i.slice(s+1));let o=n?e.createElementNS(n,i):e.createElement(i),a=t[1],l=1;if(a&&"object"==typeof a&&null==a.nodeType&&!Array.isArray(a)){l=2;for(let e in a)if(null!=a[e]){let t=e.indexOf(" ");t>0?o.setAttributeNS(e.slice(0,t),e.slice(t+1),a[e]):o.setAttribute(e,a[e])}}for(let i=l;i<t.length;i++){let s=t[i];if(0===s){if(i<t.length-1||i>l)throw new RangeError("Content hole must be the only child of its parent node");return{dom:o,contentDOM:o}}{let{dom:t,contentDOM:i}=$t.renderSpec(e,s,n);if(o.appendChild(t),i){if(r)throw new RangeError("Multiple content holes");r=i}}}return{dom:o,contentDOM:r}}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new $t(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=It(e.nodes);return t.text||(t.text=e=>e.text),t}static marksFromSchema(e){return It(e.marks)}}function It(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function Rt(e){return e.document||window.document}const Pt=Math.pow(2,16);function Bt(e,t){return e+t*Pt}function Ft(e){return 65535&e}class Lt{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(8&this.delInfo)>0}get deletedBefore(){return(5&this.delInfo)>0}get deletedAfter(){return(6&this.delInfo)>0}get deletedAcross(){return(4&this.delInfo)>0}}class zt{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&zt.empty)return zt.empty}recover(e){let t=0,n=Ft(e);if(!this.inverted)for(let e=0;e<n;e++)t+=this.ranges[3*e+2]-this.ranges[3*e+1];return this.ranges[3*n]+t+function(e){return(e-(65535&e))/Pt}(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let r=0,i=this.inverted?2:1,s=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let a=this.ranges[o]-(this.inverted?r:0);if(a>e)break;let l=this.ranges[o+i],c=this.ranges[o+s],h=a+l;if(e<=h){let i=a+r+((l?e==a?-1:e==h?1:t:t)<0?0:c);if(n)return i;let s=e==(t<0?a:h)?null:Bt(o/3,e-a),d=e==a?2:e==h?1:4;return(t<0?e!=a:e!=h)&&(d|=8),new Lt(i,d,s)}r+=c-l}return n?e+r:new Lt(e+r,0,null)}touches(e,t){let n=0,r=Ft(t),i=this.inverted?2:1,s=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let o=this.ranges[t]-(this.inverted?n:0);if(o>e)break;let a=this.ranges[t+i];if(e<=o+a&&t==3*r)return!0;n+=this.ranges[t+s]-a}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,i=0;r<this.ranges.length;r+=3){let s=this.ranges[r],o=s-(this.inverted?i:0),a=s+(this.inverted?0:i),l=this.ranges[r+t],c=this.ranges[r+n];e(o,o+l,a,a+c),i+=c-l}}invert(){return new zt(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return 0==e?zt.empty:new zt(e<0?[0,-e,0]:[0,0,e])}}zt.empty=new zt([]);class Vt{constructor(e=[],t,n=0,r=e.length){this.maps=e,this.mirror=t,this.from=n,this.to=r}slice(e=0,t=this.maps.length){return new Vt(this.maps,this.mirror,e,t)}copy(){return new Vt(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)}appendMap(e,t){this.to=this.maps.push(e),null!=t&&this.setMirror(this.maps.length-1,t)}appendMapping(e){for(let t=0,n=this.maps.length;t<e.maps.length;t++){let r=e.getMirror(t);this.appendMap(e.maps[t],null!=r&&r<t?n+r:void 0)}}getMirror(e){if(this.mirror)for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this.maps.length+e.maps.length;t>=0;t--){let r=e.getMirror(t);this.appendMap(e.maps[t].invert(),null!=r&&r>t?n-r-1:void 0)}}invert(){let e=new Vt;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this.maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let r=0;for(let n=this.from;n<this.to;n++){let i=this.maps[n].mapResult(e,t);if(null!=i.recover){let t=this.getMirror(n);if(null!=t&&t>n&&t<this.to){n=t,e=this.maps[t].recover(i.recover);continue}}r|=i.delInfo,e=i.pos}return n?e:new Lt(e,r,null)}}const jt=Object.create(null);class _t{getMap(){return zt.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=jt[t.stepType];if(!n)throw new RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in jt)throw new RangeError("Duplicate use of step JSON ID "+e);return jt[e]=t,t.prototype.jsonID=e,t}}class Wt{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new Wt(e,null)}static fail(e){return new Wt(null,e)}static fromReplace(e,t,n,r){try{return Wt.ok(e.replace(t,n,r))}catch(e){if(e instanceof Fe)return Wt.fail(e.message);throw e}}}function Ht(e,t,n){let r=[];for(let i=0;i<e.childCount;i++){let s=e.child(i);s.content.size&&(s=s.copy(Ht(s.content,t,s))),s.isInline&&(s=t(s,n,i)),r.push(s)}return $e.fromArray(r)}class Kt extends _t{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),r=n.node(n.sharedDepth(this.to)),i=new Le(Ht(t.content,((e,t)=>e.isAtom&&t.type.allowsMarkType(this.mark.type)?e.mark(this.mark.addToSet(e.marks)):e),r),t.openStart,t.openEnd);return Wt.fromReplace(e,this.from,this.to,i)}invert(){return new qt(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new Kt(t.pos,n.pos,this.mark)}merge(e){return e instanceof Kt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Kt(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("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Kt(t.from,t.to,e.markFromJSON(t.mark))}}_t.jsonID("addMark",Kt);class qt extends _t{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new Le(Ht(t.content,(e=>e.mark(this.mark.removeFromSet(e.marks))),e),t.openStart,t.openEnd);return Wt.fromReplace(e,this.from,this.to,n)}invert(){return new Kt(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new qt(t.pos,n.pos,this.mark)}merge(e){return e instanceof qt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new qt(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("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new qt(t.from,t.to,e.markFromJSON(t.mark))}}_t.jsonID("removeMark",qt);class Jt extends _t{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Wt.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return Wt.fromReplace(e,this.pos,this.pos+1,new Le($e.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let e=this.mark.addToSet(t.marks);if(e.length==t.marks.length){for(let n=0;n<t.marks.length;n++)if(!t.marks[n].isInSet(e))return new Jt(this.pos,t.marks[n]);return new Jt(this.pos,this.mark)}}return new Ut(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Jt(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Jt(t.pos,e.markFromJSON(t.mark))}}_t.jsonID("addNodeMark",Jt);class Ut extends _t{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Wt.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return Wt.fromReplace(e,this.pos,this.pos+1,new Le($e.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return t&&this.mark.isInSet(t.marks)?new Jt(this.pos,this.mark):this}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Ut(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Ut(t.pos,e.markFromJSON(t.mark))}}_t.jsonID("removeNodeMark",Ut);class Gt extends _t{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&Xt(e,this.from,this.to)?Wt.fail("Structure replace would overwrite content"):Wt.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new zt([this.from,this.to-this.from,this.slice.size])}invert(e){return new Gt(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deletedAcross&&n.deletedAcross?null:new Gt(t.pos,Math.max(t.pos,n.pos),this.slice)}merge(e){if(!(e instanceof Gt)||e.structure||this.structure)return null;if(this.from+this.slice.size!=e.from||this.slice.openEnd||e.slice.openStart){if(e.to!=this.from||this.slice.openStart||e.slice.openEnd)return null;{let t=this.slice.size+e.slice.size==0?Le.empty:new Le(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Gt(e.from,this.to,t,this.structure)}}{let t=this.slice.size+e.slice.size==0?Le.empty:new Le(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Gt(this.from,this.to+(e.to-e.from),t,this.structure)}}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Gt(t.from,t.to,Le.fromJSON(e,t.slice),!!t.structure)}}_t.jsonID("replace",Gt);class Yt extends _t{constructor(e,t,n,r,i,s,o=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=i,this.insert=s,this.structure=o}apply(e){if(this.structure&&(Xt(e,this.from,this.gapFrom)||Xt(e,this.gapTo,this.to)))return Wt.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return Wt.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,t.content);return n?Wt.fromReplace(e,this.from,this.to,n):Wt.fail("Content does not fit in gap")}getMap(){return new zt([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new Yt(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1),r=e.map(this.gapFrom,-1),i=e.map(this.gapTo,1);return t.deletedAcross&&n.deletedAcross||r<t.pos||i>n.pos?null:new Yt(t.pos,n.pos,r,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to||"number"!=typeof t.gapFrom||"number"!=typeof t.gapTo||"number"!=typeof t.insert)throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Yt(t.from,t.to,t.gapFrom,t.gapTo,Le.fromJSON(e,t.slice),t.insert,!!t.structure)}}function Xt(e,t,n){let r=e.resolve(t),i=n-t,s=r.depth;for(;i>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,i--;if(i>0){let e=r.node(s).maybeChild(r.indexAfter(s));for(;i>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,i--}}return!1}function Zt(e,t,n){return(0==t||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function Qt(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth;;--n){let r=e.$from.node(n),i=e.$from.index(n),s=e.$to.indexAfter(n);if(n<e.depth&&r.canReplace(i,s,t))return n;if(0==n||r.type.spec.isolating||!Zt(r,i,s))break}return null}function en(e,t,n=null,r=e){let i=function(e,t){let{parent:n,startIndex:r,endIndex:i}=e,s=n.contentMatchAt(r).findWrapping(t);if(!s)return null;let o=s.length?s[0]:t;return n.canReplaceWith(r,i,o)?s:null}(e,t),s=i&&function(e,t){let{parent:n,startIndex:r,endIndex:i}=e,s=n.child(r),o=t.contentMatch.findWrapping(s.type);if(!o)return null;let a=(o.length?o[o.length-1]:t).contentMatch;for(let e=r;a&&e<i;e++)a=a.matchType(n.child(e).type);return a&&a.validEnd?o:null}(r,t);return s?i.map(tn).concat({type:t,attrs:n}).concat(s.map(tn)):null}function tn(e){return{type:e,attrs:null}}function nn(e,t,n=1,r){let i=e.resolve(t),s=i.depth-n,o=r&&r[r.length-1]||i.parent;if(s<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let e=i.depth-1,t=n-2;e>s;e--,t--){let n=i.node(e),s=i.index(e);if(n.type.spec.isolating)return!1;let o=n.content.cutByIndex(s,n.childCount),a=r&&r[t]||n;if(a!=n&&(o=o.replaceChild(0,a.type.create(a.attrs))),!n.canReplace(s+1,n.childCount)||!a.type.validContent(o))return!1}let a=i.indexAfter(s),l=r&&r[0];return i.node(s).canReplaceWith(a,a,l?l.type:i.node(s+1).type)}function rn(e,t){let n=e.resolve(t),r=n.index();return function(e,t){return!(!e||!t||e.isLeaf||!e.canAppend(t))}(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function sn(e,t,n){let r=e.resolve(t);if(!n.content.size)return t;let i=n.content;for(let e=0;e<n.openStart;e++)i=i.firstChild.content;for(let e=1;e<=(0==n.openStart&&n.size?2:1);e++)for(let t=r.depth;t>=0;t--){let n=t==r.depth?0:r.pos<=(r.start(t+1)+r.end(t+1))/2?-1:1,s=r.index(t)+(n>0?1:0),o=r.node(t),a=!1;if(1==e)a=o.canReplace(s,s,i);else{let e=o.contentMatchAt(s).findWrapping(i.firstChild.type);a=e&&o.canReplaceWith(s,s,e[0])}if(a)return 0==n?r.pos:n<0?r.before(t+1):r.after(t+1)}return null}function on(e,t,n=t,r=Le.empty){if(t==n&&!r.size)return null;let i=e.resolve(t),s=e.resolve(n);return an(i,s,r)?new Gt(t,n,r):new ln(i,s,r).fit()}function an(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}_t.jsonID("replaceAround",Yt);class ln{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=$e.empty;for(let t=0;t<=e.depth;t++){let n=e.node(t);this.frontier.push({type:n.type,match:n.contentMatchAt(e.indexAfter(t))})}for(let t=e.depth;t>0;t--)this.placed=$e.from(e.node(t).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,r=this.close(e<0?this.$to:n.doc.resolve(e));if(!r)return null;let i=this.placed,s=n.depth,o=r.depth;for(;s&&o&&1==i.childCount;)i=i.firstChild.content,s--,o--;let a=new Le(i,s,o);return e>-1?new Yt(n.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||n.pos!=this.$to.pos?new Gt(n.pos,r.pos,a):null}findFittable(){for(let e=1;e<=2;e++)for(let t=this.unplaced.openStart;t>=0;t--){let n,r=null;t?(r=dn(this.unplaced.content,t-1).firstChild,n=r.content):n=this.unplaced.content;let i=n.firstChild;for(let n=this.depth;n>=0;n--){let s,{type:o,match:a}=this.frontier[n],l=null;if(1==e&&(i?a.matchType(i.type)||(l=a.fillBefore($e.from(i),!1)):r&&o.compatibleContent(r.type)))return{sliceDepth:t,frontierDepth:n,parent:r,inject:l};if(2==e&&i&&(s=a.findWrapping(i.type)))return{sliceDepth:t,frontierDepth:n,parent:r,wrap:s};if(r&&a.matchType(r.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=dn(e,t);return!(!r.childCount||r.firstChild.isLeaf)&&(this.unplaced=new Le(e,t+1,Math.max(n,r.size+t>=e.size-n?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=dn(e,t);if(r.childCount<=1&&t>0){let i=e.size-t<=t+r.size;this.unplaced=new Le(cn(e,t-1,1),t-1,i?t-1:n)}else this.unplaced=new Le(cn(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:r,wrap:i}){for(;this.depth>t;)this.closeFrontierNode();if(i)for(let e=0;e<i.length;e++)this.openFrontierNode(i[e]);let s=this.unplaced,o=n?n.content:s.content,a=s.openStart-e,l=0,c=[],{match:h,type:d}=this.frontier[t];if(r){for(let e=0;e<r.childCount;e++)c.push(r.child(e));h=h.matchFragment(r)}let u=o.size+e-(s.content.size-s.openEnd);for(;l<o.childCount;){let e=o.child(l),t=h.matchType(e.type);if(!t)break;l++,(l>1||0==a||e.content.size)&&(h=t,c.push(un(e.mark(d.allowedMarks(e.marks)),1==l?a:0,l==o.childCount?u:-1)))}let p=l==o.childCount;p||(u=-1),this.placed=hn(this.placed,t,$e.from(c)),this.frontier[t].match=h,p&&u<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let e=0,t=o;e<u;e++){let e=t.lastChild;this.frontier.push({type:e.type,match:e.contentMatchAt(e.childCount)}),t=e.content}this.unplaced=p?0==e?Le.empty:new Le(cn(s.content,e-1,1),e-1,u<0?s.openEnd:e-1):new Le(cn(s.content,e,l),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e,t=this.frontier[this.depth];if(!t.type.isTextblock||!pn(this.$to,this.$to.depth,t.type,t.match,!1)||this.$to.depth==this.depth&&(e=this.findCloseLevel(this.$to))&&e.depth==this.depth)return-1;let{depth:n}=this.$to,r=this.$to.after(n);for(;n>1&&r==this.$to.end(--n);)++r;return r}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:r}=this.frontier[t],i=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),s=pn(e,t,r,n,i);if(s){for(let n=t-1;n>=0;n--){let{match:t,type:r}=this.frontier[n],i=pn(e,n,r,t,!0);if(!i||i.childCount)continue e}return{depth:t,fit:s,move:i?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=hn(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let t=e.node(n),r=t.type.contentMatch.fillBefore(t.content,!0,e.index(n));this.openFrontierNode(t.type,t.attrs,r)}return e}openFrontierNode(e,t=null,n){let r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=hn(this.placed,this.depth,$e.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore($e.empty,!0);e.childCount&&(this.placed=hn(this.placed,this.frontier.length,e))}}function cn(e,t,n){return 0==t?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(cn(e.firstChild.content,t-1,n)))}function hn(e,t,n){return 0==t?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(hn(e.lastChild.content,t-1,n)))}function dn(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function un(e,t,n){if(t<=0)return e;let r=e.content;return t>1&&(r=r.replaceChild(0,un(r.firstChild,t-1,1==r.childCount?n-1:0))),t>0&&(r=e.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(e.type.contentMatch.matchFragment(r).fillBefore($e.empty,!0)))),e.copy(r)}function pn(e,t,n,r,i){let s=e.node(t),o=i?e.indexAfter(t):e.index(t);if(o==s.childCount&&!n.compatibleContent(s.type))return null;let a=r.fillBefore(s.content,!0,o);return a&&!function(e,t,n){for(let r=n;r<t.childCount;r++)if(!e.allowsMarks(t.child(r).marks))return!0;return!1}(n,s.content,o)?a:null}function fn(e){return e.spec.defining||e.spec.definingForContent}function mn(e,t,n,r,i){if(t<n){let i=e.firstChild;e=e.replaceChild(0,i.copy(mn(i.content,t+1,n,r,i)))}if(t>r){let t=i.contentMatchAt(0),n=t.fillBefore(e).append(e);e=n.append(t.matchFragment(n).fillBefore($e.empty,!0))}return e}function gn(e,t){let n=[];for(let r=Math.min(e.depth,t.depth);r>=0;r--){let i=e.start(r);if(i<e.pos-(e.depth-r)||t.end(r)>t.pos+(t.depth-r)||e.node(r).type.spec.isolating||t.node(r).type.spec.isolating)break;(i==t.start(r)||r==e.depth&&r==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&r&&t.start(r-1)==i-1)&&n.push(r)}return n}class yn extends _t{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return Wt.fail("No node at attribute step's position");let n=Object.create(null);for(let e in t.attrs)n[e]=t.attrs[e];n[this.attr]=this.value;let r=t.type.create(n,null,t.marks);return Wt.fromReplace(e,this.pos,this.pos+1,new Le($e.from(r),0,t.isLeaf?0:1))}getMap(){return zt.empty}invert(e){return new yn(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 yn(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if("number"!=typeof t.pos||"string"!=typeof t.attr)throw new RangeError("Invalid input for AttrStep.fromJSON");return new yn(t.pos,t.attr,t.value)}}_t.jsonID("attr",yn);let vn=class extends Error{};vn=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},(vn.prototype=Object.create(Error.prototype)).constructor=vn,vn.prototype.name="TransformError";const wn=Object.create(null);class bn{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new xn(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=Le.empty){let n=t.content.lastChild,r=null;for(let e=0;e<t.openEnd;e++)r=n,n=n.lastChild;let i=e.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){let{$from:a,$to:l}=s[o],c=e.mapping.slice(i);e.replaceRange(c.map(a.pos),c.map(l.pos),o?Le.empty:t),0==o&&Dn(e,i,(n?n.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,r=this.ranges;for(let i=0;i<r.length;i++){let{$from:s,$to:o}=r[i],a=e.mapping.slice(n),l=a.map(s.pos),c=a.map(o.pos);i?e.deleteRange(l,c):(e.replaceRangeWith(l,c,t),Dn(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let r=e.parent.inlineContent?new Mn(e):Nn(e.node(0),e.parent,e.pos,e.index(),t,n);if(r)return r;for(let r=e.depth-1;r>=0;r--){let i=t<0?Nn(e.node(0),e.node(r),e.before(r+1),e.index(r),t,n):Nn(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,t,n);if(i)return i}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new En(e.node(0))}static atStart(e){return Nn(e,e,0,0,1)||new En(e)}static atEnd(e){return Nn(e,e,e.content.size,e.childCount,-1)||new En(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=wn[t.type];if(!n)throw new RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in wn)throw new RangeError("Duplicate use of selection JSON ID "+e);return wn[e]=t,t.prototype.jsonID=e,t}getBookmark(){return Mn.between(this.$anchor,this.$head).getBookmark()}}bn.prototype.visible=!0;class xn{constructor(e,t){this.$from=e,this.$to=t}}let kn=!1;function Sn(e){kn||e.parent.inlineContent||(kn=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}class Mn extends bn{constructor(e,t=e){Sn(e),Sn(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let n=e.resolve(t.map(this.head));if(!n.parent.inlineContent)return bn.near(n);let r=e.resolve(t.map(this.anchor));return new Mn(r.parent.inlineContent?r:n,n)}replace(e,t=Le.empty){if(super.replace(e,t),t==Le.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(e){return e instanceof Mn&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new On(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if("number"!=typeof t.anchor||"number"!=typeof t.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new Mn(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,n=t){let r=e.resolve(t);return new this(r,n==t?r:e.resolve(n))}static between(e,t,n){let r=e.pos-t.pos;if(n&&!r||(n=r>=0?1:-1),!t.parent.inlineContent){let e=bn.findFrom(t,n,!0)||bn.findFrom(t,-n,!0);if(!e)return bn.near(t,n);t=e.$head}return e.parent.inlineContent||(0==r||(e=(bn.findFrom(e,-n,!0)||bn.findFrom(e,n,!0)).$anchor).pos<t.pos!=r<0)&&(e=t),new Mn(e,t)}}bn.jsonID("text",Mn);class On{constructor(e,t){this.anchor=e,this.head=t}map(e){return new On(e.map(this.anchor),e.map(this.head))}resolve(e){return Mn.between(e.resolve(this.anchor),e.resolve(this.head))}}class Cn extends bn{constructor(e){let t=e.nodeAfter,n=e.node(0).resolve(e.pos+t.nodeSize);super(e,n),this.node=t}map(e,t){let{deleted:n,pos:r}=t.mapResult(this.anchor),i=e.resolve(r);return n?bn.near(i):new Cn(i)}content(){return new Le($e.from(this.node),0,0)}eq(e){return e instanceof Cn&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new An(this.anchor)}static fromJSON(e,t){if("number"!=typeof t.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Cn(e.resolve(t.anchor))}static create(e,t){return new Cn(e.resolve(t))}static isSelectable(e){return!e.isText&&!1!==e.type.spec.selectable}}Cn.prototype.visible=!1,bn.jsonID("node",Cn);class An{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:n}=e.mapResult(this.anchor);return t?new On(n,n):new An(n)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&Cn.isSelectable(n)?new Cn(t):bn.near(t)}}class En extends bn{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=Le.empty){if(t==Le.empty){e.delete(0,e.doc.content.size);let t=bn.atStart(e.doc);t.eq(e.selection)||e.setSelection(t)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new En(e)}map(e){return new En(e)}eq(e){return e instanceof En}getBookmark(){return Tn}}bn.jsonID("all",En);const Tn={map(){return this},resolve:e=>new En(e)};function Nn(e,t,n,r,i,s=!1){if(t.inlineContent)return Mn.create(e,n);for(let o=r-(i>0?0:1);i>0?o<t.childCount:o>=0;o+=i){let r=t.child(o);if(r.isAtom){if(!s&&Cn.isSelectable(r))return Cn.create(e,n-(i<0?r.nodeSize:0))}else{let t=Nn(e,r,n+i,i<0?r.childCount:0,i,s);if(t)return t}n+=r.nodeSize*i}return null}function Dn(e,t,n){let r=e.steps.length-1;if(r<t)return;let i,s=e.steps[r];(s instanceof Gt||s instanceof Yt)&&(e.mapping.maps[r].forEach(((e,t,n,r)=>{null==i&&(i=r)})),e.setSelection(bn.near(e.doc.resolve(i),n)))}class $n extends class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Vt}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new vn(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,n=Le.empty){let r=on(this.doc,e,t,n);return r&&this.step(r),this}replaceWith(e,t,n){return this.replace(e,t,new Le($e.from(n),0,0))}delete(e,t){return this.replace(e,t,Le.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return function(e,t,n,r){if(!r.size)return e.deleteRange(t,n);let i=e.doc.resolve(t),s=e.doc.resolve(n);if(an(i,s,r))return e.step(new Gt(t,n,r));let o=gn(i,e.doc.resolve(n));0==o[o.length-1]&&o.pop();let a=-(i.depth+1);o.unshift(a);for(let e=i.depth,t=i.pos-1;e>0;e--,t--){let n=i.node(e).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;o.indexOf(e)>-1?a=e:i.before(e)==t&&o.splice(1,0,-e)}let l=o.indexOf(a),c=[],h=r.openStart;for(let e=r.content,t=0;;t++){let n=e.firstChild;if(c.push(n),t==r.openStart)break;e=n.content}for(let e=h-1;e>=0;e--){let t=c[e].type,n=fn(t);if(n&&i.node(l).type!=t)h=e;else if(n||!t.isTextblock)break}for(let t=r.openStart;t>=0;t--){let a=(t+h+1)%(r.openStart+1),d=c[a];if(d)for(let t=0;t<o.length;t++){let c=o[(t+l)%o.length],h=!0;c<0&&(h=!1,c=-c);let u=i.node(c-1),p=i.index(c-1);if(u.canReplaceWith(p,p,d.type,d.marks))return e.replace(i.before(c),h?s.after(c):n,new Le(mn(r.content,0,r.openStart,a),a,r.openEnd))}}let d=e.steps.length;for(let a=o.length-1;a>=0&&(e.replace(t,n,r),!(e.steps.length>d));a--){let e=o[a];e<0||(t=i.before(e),n=s.after(e))}}(this,e,t,n),this}replaceRangeWith(e,t,n){return function(e,t,n,r){if(!r.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let i=function(e,t,n){let r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(0==r.parentOffset)for(let e=r.depth-1;e>=0;e--){let t=r.index(e);if(r.node(e).canReplaceWith(t,t,n))return r.before(e+1);if(t>0)return null}if(r.parentOffset==r.parent.content.size)for(let e=r.depth-1;e>=0;e--){let t=r.indexAfter(e);if(r.node(e).canReplaceWith(t,t,n))return r.after(e+1);if(t<r.node(e).childCount)return null}return null}(e.doc,t,r.type);null!=i&&(t=n=i)}e.replaceRange(t,n,new Le($e.from(r),0,0))}(this,e,t,n),this}deleteRange(e,t){return function(e,t,n){let r=e.doc.resolve(t),i=e.doc.resolve(n),s=gn(r,i);for(let t=0;t<s.length;t++){let n=s[t],o=t==s.length-1;if(o&&0==n||r.node(n).type.contentMatch.validEnd)return e.delete(r.start(n),i.end(n));if(n>0&&(o||r.node(n-1).canReplace(r.index(n-1),i.indexAfter(n-1))))return e.delete(r.before(n),i.after(n))}for(let s=1;s<=r.depth&&s<=i.depth;s++)if(t-r.start(s)==r.depth-s&&n>r.end(s)&&i.end(s)-n!=i.depth-s)return e.delete(r.before(s),n);e.delete(t,n)}(this,e,t),this}lift(e,t){return function(e,t,n){let{$from:r,$to:i,depth:s}=t,o=r.before(s+1),a=i.after(s+1),l=o,c=a,h=$e.empty,d=0;for(let e=s,t=!1;e>n;e--)t||r.index(e)>0?(t=!0,h=$e.from(r.node(e).copy(h)),d++):l--;let u=$e.empty,p=0;for(let e=s,t=!1;e>n;e--)t||i.after(e+1)<i.end(e)?(t=!0,u=$e.from(i.node(e).copy(u)),p++):c++;e.step(new Yt(l,c,o,a,new Le(h.append(u),d,p),h.size-d,!0))}(this,e,t),this}join(e,t=1){return function(e,t,n){let r=new Gt(t-n,t+n,Le.empty,!0);e.step(r)}(this,e,t),this}wrap(e,t){return function(e,t,n){let r=$e.empty;for(let e=n.length-1;e>=0;e--){if(r.size){let t=n[e].type.contentMatch.matchFragment(r);if(!t||!t.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=$e.from(n[e].type.create(n[e].attrs,r))}let i=t.start,s=t.end;e.step(new Yt(i,s,i,s,new Le(r,0,0),n.length,!0))}(this,e,t),this}setBlockType(e,t=e,n,r=null){return function(e,t,n,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=e.steps.length;e.doc.nodesBetween(t,n,((t,n)=>{if(t.isTextblock&&!t.hasMarkup(r,i)&&function(e,t,n){let r=e.resolve(t),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}(e.doc,e.mapping.slice(s).map(n),r)){e.clearIncompatible(e.mapping.slice(s).map(n,1),r);let o=e.mapping.slice(s),a=o.map(n,1),l=o.map(n+t.nodeSize,1);return e.step(new Yt(a,l,a+1,l-1,new Le($e.from(r.create(i,null,t.marks)),0,0),1,!0)),!1}}))}(this,e,t,n,r),this}setNodeMarkup(e,t,n=null,r=[]){return function(e,t,n,r,i){let s=e.doc.nodeAt(t);if(!s)throw new RangeError("No node at given position");n||(n=s.type);let o=n.create(r,null,i||s.marks);if(s.isLeaf)return e.replaceWith(t,t+s.nodeSize,o);if(!n.validContent(s.content))throw new RangeError("Invalid content for node type "+n.name);e.step(new Yt(t,t+s.nodeSize,t+1,t+s.nodeSize-1,new Le($e.from(o),0,0),1,!0))}(this,e,t,n,r),this}setNodeAttribute(e,t,n){return this.step(new yn(e,t,n)),this}addNodeMark(e,t){return this.step(new Jt(e,t)),this}removeNodeMark(e,t){if(!(t instanceof Be)){let n=this.doc.nodeAt(e);if(!n)throw new RangeError("No node at position "+e);if(!(t=t.isInSet(n.marks)))return this}return this.step(new Ut(e,t)),this}split(e,t=1,n){return function(e,t,n=1,r){let i=e.doc.resolve(t),s=$e.empty,o=$e.empty;for(let e=i.depth,t=i.depth-n,a=n-1;e>t;e--,a--){s=$e.from(i.node(e).copy(s));let t=r&&r[a];o=$e.from(t?t.type.create(t.attrs,o):i.node(e).copy(o))}e.step(new Gt(t,t,new Le(s.append(o),n,n),!0))}(this,e,t,n),this}addMark(e,t,n){return function(e,t,n,r){let i,s,o=[],a=[];e.doc.nodesBetween(t,n,((e,l,c)=>{if(!e.isInline)return;let h=e.marks;if(!r.isInSet(h)&&c.type.allowsMarkType(r.type)){let c=Math.max(l,t),d=Math.min(l+e.nodeSize,n),u=r.addToSet(h);for(let e=0;e<h.length;e++)h[e].isInSet(u)||(i&&i.to==c&&i.mark.eq(h[e])?i.to=d:o.push(i=new qt(c,d,h[e])));s&&s.to==c?s.to=d:a.push(s=new Kt(c,d,r))}})),o.forEach((t=>e.step(t))),a.forEach((t=>e.step(t)))}(this,e,t,n),this}removeMark(e,t,n){return function(e,t,n,r){let i=[],s=0;e.doc.nodesBetween(t,n,((e,o)=>{if(!e.isInline)return;s++;let a=null;if(r instanceof wt){let t,n=e.marks;for(;t=r.isInSet(n);)(a||(a=[])).push(t),n=t.removeFromSet(n)}else r?r.isInSet(e.marks)&&(a=[r]):a=e.marks;if(a&&a.length){let r=Math.min(o+e.nodeSize,n);for(let e=0;e<a.length;e++){let n,l=a[e];for(let e=0;e<i.length;e++){let t=i[e];t.step==s-1&&l.eq(i[e].style)&&(n=t)}n?(n.to=r,n.step=s):i.push({style:l,from:Math.max(o,t),to:r,step:s})}}})),i.forEach((t=>e.step(new qt(t.from,t.to,t.style))))}(this,e,t,n),this}clearIncompatible(e,t,n){return function(e,t,n,r=n.contentMatch){let i=e.doc.nodeAt(t),s=[],o=t+1;for(let t=0;t<i.childCount;t++){let a=i.child(t),l=o+a.nodeSize,c=r.matchType(a.type);if(c){r=c;for(let t=0;t<a.marks.length;t++)n.allowsMarkType(a.marks[t].type)||e.step(new qt(o,l,a.marks[t]))}else s.push(new Gt(o,l,Le.empty));o=l}if(!r.validEnd){let t=r.fillBefore($e.empty,!0);e.replace(o,o,new Le(t,0,0))}for(let t=s.length-1;t>=0;t--)e.step(s[t])}(this,e,t,n),this}}{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=-3&(1|this.updated),this.storedMarks=null,this}get selectionSet(){return(1&this.updated)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=2,this}ensureMarks(e){return Be.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(2&this.updated)>0}addStep(e,t){super.addStep(e,t),this.updated=-3&this.updated,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||Be.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let r=this.doc.type.schema;if(null==t)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();{if(null==n&&(n=t),n=null==n?t:n,!e)return this.deleteRange(t,n);let i=this.storedMarks;if(!i){let e=this.doc.resolve(t);i=n==t?e.marks():e.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,r.text(e,i)),this.selection.empty||this.setSelection(bn.near(this.selection.$to)),this}}setMeta(e,t){return this.meta["string"==typeof e?e:e.key]=t,this}getMeta(e){return this.meta["string"==typeof e?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=4,this}get scrolledIntoView(){return(4&this.updated)>0}}function In(e,t){return t&&e?e.bind(t):e}class Rn{constructor(e,t,n){this.name=e,this.init=In(t.init,n),this.apply=In(t.apply,n)}}const Pn=[new Rn("doc",{init:e=>e.doc||e.schema.topNodeType.createAndFill(),apply:e=>e.doc}),new Rn("selection",{init:(e,t)=>e.selection||bn.atStart(t.doc),apply:e=>e.selection}),new Rn("storedMarks",{init:e=>e.storedMarks||null,apply:(e,t,n,r)=>r.selection.$cursor?e.storedMarks:null}),new Rn("scrollToSelection",{init:()=>0,apply:(e,t)=>e.scrolledIntoView?t+1:t})];class Bn{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Pn.slice(),t&&t.forEach((e=>{if(this.pluginsByKey[e.key])throw new RangeError("Adding different instances of a keyed plugin ("+e.key+")");this.plugins.push(e),this.pluginsByKey[e.key]=e,e.spec.state&&this.fields.push(new Rn(e.key,e.spec.state,e))}))}}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 n=0;n<this.config.plugins.length;n++)if(n!=t){let t=this.config.plugins[n];if(t.spec.filterTransaction&&!t.spec.filterTransaction.call(t,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],n=this.applyInner(e),r=null;for(;;){let i=!1;for(let s=0;s<this.config.plugins.length;s++){let o=this.config.plugins[s];if(o.spec.appendTransaction){let a=r?r[s].n:0,l=r?r[s].state:this,c=a<t.length&&o.spec.appendTransaction.call(o,a?t.slice(a):t,l,n);if(c&&n.filterTransaction(c,s)){if(c.setMeta("appendedTransaction",e),!r){r=[];for(let e=0;e<this.config.plugins.length;e++)r.push(e<s?{state:n,n:t.length}:{state:this,n:0})}t.push(c),n=n.applyInner(c),i=!0}r&&(r[s]={state:n,n:t.length})}}if(!i)return{state:n,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new Fn(this.config),n=this.config.fields;for(let r=0;r<n.length;r++){let i=n[r];t[i.name]=i.apply(e,this[i.name],this,t)}return t}get tr(){return new $n(this)}static create(e){let t=new Bn(e.doc?e.doc.type.schema:e.schema,e.plugins),n=new Fn(t);for(let r=0;r<t.fields.length;r++)n[t.fields[r].name]=t.fields[r].init(e,n);return n}reconfigure(e){let t=new Bn(this.schema,e.plugins),n=t.fields,r=new Fn(t);for(let t=0;t<n.length;t++){let i=n[t].name;r[i]=this.hasOwnProperty(i)?this[i]:n[t].init(e,r)}return r}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map((e=>e.toJSON()))),e&&"object"==typeof e)for(let n in e){if("doc"==n||"selection"==n)throw new RangeError("The JSON fields `doc` and `selection` are reserved");let r=e[n],i=r.spec.state;i&&i.toJSON&&(t[n]=i.toJSON.call(r,this[r.key]))}return t}static fromJSON(e,t,n){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let r=new Bn(e.schema,e.plugins),i=new Fn(r);return r.fields.forEach((r=>{if("doc"==r.name)i.doc=nt.fromJSON(e.schema,t.doc);else if("selection"==r.name)i.selection=bn.fromJSON(i.doc,t.selection);else if("storedMarks"==r.name)t.storedMarks&&(i.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(n)for(let s in n){let o=n[s],a=o.spec.state;if(o.key==r.name&&a&&a.fromJSON&&Object.prototype.hasOwnProperty.call(t,s))return void(i[r.name]=a.fromJSON.call(o,e,t[s],i))}i[r.name]=r.init(e,i)}})),i}}function Ln(e,t,n){for(let r in e){let i=e[r];i instanceof Function?i=i.bind(t):"handleDOMEvents"==r&&(i=Ln(i,t,{})),n[r]=i}return n}class zn{constructor(e){this.spec=e,this.props={},e.props&&Ln(e.props,this,this.props),this.key=e.key?e.key.key:jn("plugin")}getState(e){return e[this.key]}}const Vn=Object.create(null);function jn(e){return e in Vn?e+"$"+ ++Vn[e]:(Vn[e]=0,e+"$")}class _n{constructor(e="key"){this.key=jn(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Wn=function(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t},Hn=function(e){let t=e.assignedSlot||e.parentNode;return t&&11==t.nodeType?t.host:t};let Kn=null;const qn=function(e,t,n){let r=Kn||(Kn=document.createRange());return r.setEnd(e,null==n?e.nodeValue.length:n),r.setStart(e,t||0),r},Jn=function(e,t,n,r){return n&&(Gn(e,t,n,r,-1)||Gn(e,t,n,r,1))},Un=/^(img|br|input|textarea|hr)$/i;function Gn(e,t,n,r,i){for(;;){if(e==n&&t==r)return!0;if(t==(i<0?0:Yn(e))){let n=e.parentNode;if(!n||1!=n.nodeType||Xn(e)||Un.test(e.nodeName)||"false"==e.contentEditable)return!1;t=Wn(e)+(i<0?0:1),e=n}else{if(1!=e.nodeType)return!1;if("false"==(e=e.childNodes[t+(i<0?-1:0)]).contentEditable)return!1;t=i<0?Yn(e):0}}}function Yn(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function Xn(e){let t;for(let n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}const Zn=function(e){return e.focusNode&&Jn(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function Qn(e,t){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}const er="undefined"!=typeof navigator?navigator:null,tr="undefined"!=typeof document?document:null,nr=er&&er.userAgent||"",rr=/Edge\/(\d+)/.exec(nr),ir=/MSIE \d/.exec(nr),sr=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(nr),or=!!(ir||sr||rr),ar=ir?document.documentMode:sr?+sr[1]:rr?+rr[1]:0,lr=!or&&/gecko\/(\d+)/i.test(nr);lr&&(/Firefox\/(\d+)/.exec(nr)||[0,0])[1];const cr=!or&&/Chrome\/(\d+)/.exec(nr),hr=!!cr,dr=cr?+cr[1]:0,ur=!or&&!!er&&/Apple Computer/.test(er.vendor),pr=ur&&(/Mobile\/\w+/.test(nr)||!!er&&er.maxTouchPoints>2),fr=pr||!!er&&/Mac/.test(er.platform),mr=/Android \d/.test(nr),gr=!!tr&&"webkitFontSmoothing"in tr.documentElement.style,yr=gr?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function vr(e){return{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function wr(e,t){return"number"==typeof e?e:e[t]}function br(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,r=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*r}}function xr(e,t,n){let r=e.someProp("scrollThreshold")||0,i=e.someProp("scrollMargin")||5,s=e.dom.ownerDocument;for(let o=n||e.dom;o;o=Hn(o)){if(1!=o.nodeType)continue;let e=o,n=e==s.body,a=n?vr(s):br(e),l=0,c=0;if(t.top<a.top+wr(r,"top")?c=-(a.top-t.top+wr(i,"top")):t.bottom>a.bottom-wr(r,"bottom")&&(c=t.bottom-a.bottom+wr(i,"bottom")),t.left<a.left+wr(r,"left")?l=-(a.left-t.left+wr(i,"left")):t.right>a.right-wr(r,"right")&&(l=t.right-a.right+wr(i,"right")),l||c)if(n)s.defaultView.scrollBy(l,c);else{let n=e.scrollLeft,r=e.scrollTop;c&&(e.scrollTop+=c),l&&(e.scrollLeft+=l);let i=e.scrollLeft-n,s=e.scrollTop-r;t={left:t.left-i,top:t.top-s,right:t.right-i,bottom:t.bottom-s}}if(n)break}}function kr(e){let t=[],n=e.ownerDocument;for(let r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=Hn(r));return t}function Sr(e,t){for(let n=0;n<e.length;n++){let{dom:r,top:i,left:s}=e[n];r.scrollTop!=i+t&&(r.scrollTop=i+t),r.scrollLeft!=s&&(r.scrollLeft=s)}}let Mr=null;function Or(e,t){let n,r,i=2e8,s=0,o=t.top,a=t.top;for(let l=e.firstChild,c=0;l;l=l.nextSibling,c++){let e;if(1==l.nodeType)e=l.getClientRects();else{if(3!=l.nodeType)continue;e=qn(l).getClientRects()}for(let h=0;h<e.length;h++){let d=e[h];if(d.top<=o&&d.bottom>=a){o=Math.max(d.bottom,o),a=Math.min(d.top,a);let e=d.left>t.left?d.left-t.left:d.right<t.left?t.left-d.right:0;if(e<i){n=l,i=e,r=e&&3==n.nodeType?{left:d.right<t.left?d.right:d.left,top:t.top}:t,1==l.nodeType&&e&&(s=c+(t.left>=(d.left+d.right)/2?1:0));continue}}!n&&(t.left>=d.right&&t.top>=d.top||t.left>=d.left&&t.top>=d.bottom)&&(s=c+1)}}return n&&3==n.nodeType?function(e,t){let n=e.nodeValue.length,r=document.createRange();for(let i=0;i<n;i++){r.setEnd(e,i+1),r.setStart(e,i);let n=Tr(r,1);if(n.top!=n.bottom&&Cr(t,n))return{node:e,offset:i+(t.left>=(n.left+n.right)/2?1:0)}}return{node:e,offset:0}}(n,r):!n||i&&1==n.nodeType?{node:e,offset:s}:Or(n,r)}function Cr(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function Ar(e,t,n){let r=e.childNodes.length;if(r&&n.top<n.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(t.top-n.top)/(n.bottom-n.top))-2)),s=i;;){let n=e.childNodes[s];if(1==n.nodeType){let e=n.getClientRects();for(let r=0;r<e.length;r++){let i=e[r];if(Cr(t,i))return Ar(n,t,i)}}if((s=(s+1)%r)==i)break}return e}function Er(e,t){let n,r=e.dom.ownerDocument,i=0;if(r.caretPositionFromPoint)try{let e=r.caretPositionFromPoint(t.left,t.top);e&&({offsetNode:n,offset:i}=e)}catch(e){}if(!n&&r.caretRangeFromPoint){let e=r.caretRangeFromPoint(t.left,t.top);e&&({startContainer:n,startOffset:i}=e)}let s,o=(e.root.elementFromPoint?e.root:r).elementFromPoint(t.left,t.top);if(!o||!e.dom.contains(1!=o.nodeType?o.parentNode:o)){let n=e.dom.getBoundingClientRect();if(!Cr(t,n))return null;if(o=Ar(e.dom,t,n),!o)return null}if(ur)for(let e=o;n&&e;e=Hn(e))e.draggable&&(n=void 0);if(o=function(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}(o,t),n){if(lr&&1==n.nodeType&&(i=Math.min(i,n.childNodes.length),i<n.childNodes.length)){let e,r=n.childNodes[i];"IMG"==r.nodeName&&(e=r.getBoundingClientRect()).right<=t.left&&e.bottom>t.top&&i++}n==e.dom&&i==n.childNodes.length-1&&1==n.lastChild.nodeType&&t.top>n.lastChild.getBoundingClientRect().bottom?s=e.state.doc.content.size:0!=i&&1==n.nodeType&&"BR"==n.childNodes[i-1].nodeName||(s=function(e,t,n,r){let i=-1;for(let n=t;n!=e.dom;){let t=e.docView.nearestDesc(n,!0);if(!t)return null;if(t.node.isBlock&&t.parent){let e=t.dom.getBoundingClientRect();if(e.left>r.left||e.top>r.top)i=t.posBefore;else{if(!(e.right<r.left||e.bottom<r.top))break;i=t.posAfter}}n=t.dom.parentNode}return i>-1?i:e.docView.posFromDOM(t,n,1)}(e,n,i,t))}null==s&&(s=function(e,t,n){let{node:r,offset:i}=Or(t,n),s=-1;if(1==r.nodeType&&!r.firstChild){let e=r.getBoundingClientRect();s=e.left!=e.right&&n.left>(e.left+e.right)/2?1:-1}return e.docView.posFromDOM(r,i,s)}(e,o,t));let a=e.docView.nearestDesc(o,!0);return{pos:s,inside:a?a.posAtStart-a.border:-1}}function Tr(e,t){let n=e.getClientRects();return n.length?n[t<0?0:n.length-1]:e.getBoundingClientRect()}const Nr=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Dr(e,t,n){let{node:r,offset:i,atom:s}=e.docView.domFromPos(t,n<0?-1:1),o=gr||lr;if(3==r.nodeType){if(!o||!Nr.test(r.nodeValue)&&(n<0?i:i!=r.nodeValue.length)){let e=i,t=i,s=n<0?1:-1;return n<0&&!i?(t++,s=-1):n>=0&&i==r.nodeValue.length?(e--,s=1):n<0?e--:t++,$r(Tr(qn(r,e,t),1),s<0)}{let e=Tr(qn(r,i,i),n);if(lr&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let t=Tr(qn(r,i-1,i-1),-1);if(t.top==e.top){let n=Tr(qn(r,i,i+1),-1);if(n.top!=e.top)return $r(n,n.left<t.left)}}return e}}if(!e.state.doc.resolve(t-(s||0)).parent.inlineContent){if(null==s&&i&&(n<0||i==Yn(r))){let e=r.childNodes[i-1];if(1==e.nodeType)return Ir(e.getBoundingClientRect(),!1)}if(null==s&&i<Yn(r)){let e=r.childNodes[i];if(1==e.nodeType)return Ir(e.getBoundingClientRect(),!0)}return Ir(r.getBoundingClientRect(),n>=0)}if(null==s&&i&&(n<0||i==Yn(r))){let e=r.childNodes[i-1],t=3==e.nodeType?qn(e,Yn(e)-(o?0:1)):1!=e.nodeType||"BR"==e.nodeName&&e.nextSibling?null:e;if(t)return $r(Tr(t,1),!1)}if(null==s&&i<Yn(r)){let e=r.childNodes[i];for(;e.pmViewDesc&&e.pmViewDesc.ignoreForCoords;)e=e.nextSibling;let t=e?3==e.nodeType?qn(e,0,o?0:1):1==e.nodeType?e:null:null;if(t)return $r(Tr(t,-1),!0)}return $r(Tr(3==r.nodeType?qn(r):r,-n),n>=0)}function $r(e,t){if(0==e.width)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function Ir(e,t){if(0==e.height)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function Rr(e,t,n){let r=e.state,i=e.root.activeElement;r!=t&&e.updateState(t),i!=e.dom&&e.focus();try{return n()}finally{r!=t&&e.updateState(r),i!=e.dom&&i&&i.focus()}}const Pr=/[\u0590-\u08ac]/;let Br=null,Fr=null,Lr=!1;function zr(e,t,n){return Br==t&&Fr==n?Lr:(Br=t,Fr=n,Lr="up"==n||"down"==n?function(e,t,n){let r=t.selection,i="up"==n?r.$from:r.$to;return Rr(e,t,(()=>{let{node:t}=e.docView.domFromPos(i.pos,"up"==n?-1:1);for(;;){let n=e.docView.nearestDesc(t,!0);if(!n)break;if(n.node.isBlock){t=n.dom;break}t=n.dom.parentNode}let r=Dr(e,i.pos,1);for(let e=t.firstChild;e;e=e.nextSibling){let t;if(1==e.nodeType)t=e.getClientRects();else{if(3!=e.nodeType)continue;t=qn(e,0,e.nodeValue.length).getClientRects()}for(let e=0;e<t.length;e++){let i=t[e];if(i.bottom>i.top+1&&("up"==n?r.top-i.top>2*(i.bottom-r.top):i.bottom-r.bottom>2*(r.bottom-i.top)))return!1}}return!0}))}(e,t,n):function(e,t,n){let{$head:r}=t.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,s=!i,o=i==r.parent.content.size,a=e.domSelection();return Pr.test(r.parent.textContent)&&a.modify?Rr(e,t,(()=>{let{focusNode:t,focusOffset:i,anchorNode:s,anchorOffset:o}=e.domSelectionRange(),l=a.caretBidiLevel;a.modify("move",n,"character");let c=r.depth?e.docView.domAfterPos(r.before()):e.dom,{focusNode:h,focusOffset:d}=e.domSelectionRange(),u=h&&!c.contains(1==h.nodeType?h:h.parentNode)||t==h&&i==d;try{a.collapse(s,o),t&&(t!=s||i!=o)&&a.extend&&a.extend(t,i)}catch(e){}return null!=l&&(a.caretBidiLevel=l),u})):"left"==n||"backward"==n?s:o}(e,t,n))}class Vr{constructor(e,t,n,r){this.parent=e,this.children=t,this.dom=n,this.contentDOM=r,this.dirty=0,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,n=this.posAtStart;;t++){let r=this.children[t];if(r==e)return n;n+=r.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,n){if(this.contentDOM&&this.contentDOM.contains(1==e.nodeType?e:e.parentNode)){if(n<0){let n,r;if(e==this.contentDOM)n=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.previousSibling}for(;n&&(!(r=n.pmViewDesc)||r.parent!=this);)n=n.previousSibling;return n?this.posBeforeChild(r)+r.size:this.posAtStart}{let n,r;if(e==this.contentDOM)n=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.nextSibling}for(;n&&(!(r=n.pmViewDesc)||r.parent!=this);)n=n.nextSibling;return n?this.posBeforeChild(r):this.posAtEnd}}let r;if(e==this.dom&&this.contentDOM)r=t>Wn(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))r=2&e.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==t)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!1;break}if(t.previousSibling)break}if(null==r&&t==e.childNodes.length)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!0;break}if(t.nextSibling)break}}return(null==r?n>0:r)?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,r=e;r;r=r.parentNode){let i,s=this.getDesc(r);if(s&&(!t||s.node)){if(!n||!(i=s.nodeDOM)||(1==i.nodeType?i.contains(1==e.nodeType?e:e.parentNode):i==e))return s;n=!1}}}getDesc(e){let t=e.pmViewDesc;for(let e=t;e;e=e.parent)if(e==this)return t}posFromDOM(e,t,n){for(let r=e;r;r=r.parentNode){let i=this.getDesc(r);if(i)return i.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let r=this.children[t],i=n+r.size;if(n==e&&i!=n){for(;!r.border&&r.children.length;)r=r.children[0];return r}if(e<i)return r.descAt(e-n-r.border);n=i}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n,r=0,i=0;for(let t=0;r<this.children.length;r++){let n=this.children[r],s=t+n.size;if(s>e||n instanceof Jr){i=e-t;break}t=s}if(i)return this.children[r].domFromPos(i-this.children[r].border,t);for(;r&&!(n=this.children[r-1]).size&&n instanceof jr&&n.side>=0;r--);if(t<=0){let e,n=!0;for(;e=r?this.children[r-1]:null,e&&e.dom.parentNode!=this.contentDOM;r--,n=!1);return e&&t&&n&&!e.border&&!e.domAtom?e.domFromPos(e.size,t):{node:this.contentDOM,offset:e?Wn(e.dom)+1:0}}{let e,n=!0;for(;e=r<this.children.length?this.children[r]:null,e&&e.dom.parentNode!=this.contentDOM;r++,n=!1);return e&&n&&!e.border&&!e.domAtom?e.domFromPos(0,t):{node:this.contentDOM,offset:e?Wn(e.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,n=0){if(0==this.children.length)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let r=-1,i=-1;for(let s=n,o=0;;o++){let n=this.children[o],a=s+n.size;if(-1==r&&e<=a){let i=s+n.border;if(e>=i&&t<=a-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(e,t,i);e=s;for(let t=o;t>0;t--){let n=this.children[t-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){r=Wn(n.dom)+1;break}e-=n.size}-1==r&&(r=0)}if(r>-1&&(a>t||o==this.children.length-1)){t=a;for(let e=o+1;e<this.children.length;e++){let n=this.children[e];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(-1)){i=Wn(n.dom);break}t+=n.size}-1==i&&(i=this.contentDOM.childNodes.length);break}s=a}return{node:this.contentDOM,from:e,to:t,fromOffset:r,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return 0==t.size||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:n}=this.domFromPos(e,0);if(1!=t.nodeType||n==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[n]}setSelection(e,t,n,r=!1){let i=Math.min(e,t),s=Math.max(e,t);for(let o=0,a=0;o<this.children.length;o++){let l=this.children[o],c=a+l.size;if(i>a&&s<c)return l.setSelection(e-a-l.border,t-a-l.border,n,r);a=c}let o=this.domFromPos(e,e?-1:1),a=t==e?o:this.domFromPos(t,t?-1:1),l=n.getSelection(),c=!1;if((lr||ur)&&e==t){let{node:e,offset:t}=o;if(3==e.nodeType){if(c=!(!t||"\n"!=e.nodeValue[t-1]),c&&t==e.nodeValue.length)for(let t,n=e;n;n=n.parentNode){if(t=n.nextSibling){"BR"==t.nodeName&&(o=a={node:t.parentNode,offset:Wn(t)+1});break}let e=n.pmViewDesc;if(e&&e.node&&e.node.isBlock)break}}else{let n=e.childNodes[t-1];c=n&&("BR"==n.nodeName||"false"==n.contentEditable)}}if(lr&&l.focusNode&&l.focusNode!=a.node&&1==l.focusNode.nodeType){let e=l.focusNode.childNodes[l.focusOffset];e&&"false"==e.contentEditable&&(r=!0)}if(!(r||c&&ur)&&Jn(o.node,o.offset,l.anchorNode,l.anchorOffset)&&Jn(a.node,a.offset,l.focusNode,l.focusOffset))return;let h=!1;if((l.extend||e==t)&&!c){l.collapse(o.node,o.offset);try{e!=t&&l.extend(a.node,a.offset),h=!0}catch(e){}}if(!h){if(e>t){let e=o;o=a,a=e}let n=document.createRange();n.setEnd(a.node,a.offset),n.setStart(o.node,o.offset),l.removeAllRanges(),l.addRange(n)}}ignoreMutation(e){return!this.contentDOM&&"selection"!=e.type}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,r=0;r<this.children.length;r++){let i=this.children[r],s=n+i.size;if(n==s?e<=s&&t>=n:e<s&&t>n){let r=n+i.border,o=s-i.border;if(e>=r&&t<=o)return this.dirty=e==n||t==s?2:1,void(e!=r||t!=o||!i.contentLost&&i.dom.parentNode==this.contentDOM?i.markDirty(e-r,t-r):i.dirty=3);i.dirty=i.dom!=i.contentDOM||i.dom.parentNode!=this.contentDOM||i.children.length?3:2}n=s}this.dirty=2}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=1==e?2:1;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}}class jr extends Vr{constructor(e,t,n,r){let i,s=t.type.toDOM;if("function"==typeof s&&(s=s(n,(()=>i?i.parent?i.parent.posBeforeChild(i):void 0:r))),!t.type.spec.raw){if(1!=s.nodeType){let e=document.createElement("span");e.appendChild(s),s=e}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return 0==this.dirty&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return!!t&&t(e)}ignoreMutation(e){return"selection"!=e.type||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}}class _r extends Vr{constructor(e,t,n,r){super(e,[],t,null),this.textDOM=n,this.text=r}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"characterData"===e.type&&e.target.nodeValue==e.oldValue}}class Wr extends Vr{constructor(e,t,n,r){super(e,[],n,r),this.mark=t}static create(e,t,n,r){let i=r.nodeViews[t.type.name],s=i&&i(t,r,n);return s&&s.dom||(s=$t.renderSpec(document,t.type.spec.toDOM(t,n))),new Wr(e,t,s.dom,s.contentDOM||s.dom)}parseRule(){return 3&this.dirty||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM||void 0}}matchesMark(e){return 3!=this.dirty&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),0!=this.dirty){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty<this.dirty&&(e.dirty=this.dirty),this.dirty=0}}slice(e,t,n){let r=Wr.create(this.parent,this.mark,!0,n),i=this.children,s=this.size;t<s&&(i=oi(i,t,s,n)),e>0&&(i=oi(i,0,e,n));for(let e=0;e<i.length;e++)i[e].parent=r;return r.children=i,r}}class Hr extends Vr{constructor(e,t,n,r,i,s,o,a,l){super(e,[],i,s),this.node=t,this.outerDeco=n,this.innerDeco=r,this.nodeDOM=o,s&&this.updateChildren(a,l)}static create(e,t,n,r,i,s){let o,a=i.nodeViews[t.type.name],l=a&&a(t,i,(()=>o?o.parent?o.parent.posBeforeChild(o):void 0:s),n,r),c=l&&l.dom,h=l&&l.contentDOM;if(t.isText)if(c){if(3!=c.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else c=document.createTextNode(t.text);else c||({dom:c,contentDOM:h}=$t.renderSpec(document,t.type.spec.toDOM(t)));h||t.isText||"BR"==c.nodeName||(c.hasAttribute("contenteditable")||(c.contentEditable="false"),t.type.spec.draggable&&(c.draggable=!0));let d=c;return c=ti(c,n,t),l?o=new Ur(e,t,n,r,c,h||null,d,l,i,s+1):t.isText?new qr(e,t,n,r,c,d,i):new Hr(e,t,n,r,c,h||null,d,i,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(e.preserveWhitespace="full"),this.contentDOM)if(this.contentLost){for(let t=this.children.length-1;t>=0;t--){let n=this.children[t];if(this.dom.contains(n.dom.parentNode)){e.contentElement=n.dom.parentNode;break}}e.contentElement||(e.getContent=()=>$e.empty)}else e.contentElement=this.contentDOM;else e.getContent=()=>this.node.content;return e}matchesNode(e,t,n){return 0==this.dirty&&e.eq(this.node)&&ni(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let n=this.node.inlineContent,r=t,i=e.composing?this.localCompositionInfo(e,t):null,s=i&&i.pos>-1?i:null,o=i&&i.pos<0,a=new ii(this,s&&s.node,e);!function(e,t,n,r){let i=t.locals(e),s=0;if(0==i.length){for(let n=0;n<e.childCount;n++){let o=e.child(n);r(o,i,t.forChild(s,o),n),s+=o.nodeSize}return}let o=0,a=[],l=null;for(let c=0;;){if(o<i.length&&i[o].to==s){let e,t=i[o++];for(;o<i.length&&i[o].to==s;)(e||(e=[t])).push(i[o++]);if(e){e.sort(si);for(let t=0;t<e.length;t++)n(e[t],c,!!l)}else n(t,c,!!l)}let h,d;if(l)d=-1,h=l,l=null;else{if(!(c<e.childCount))break;d=c,h=e.child(c++)}for(let e=0;e<a.length;e++)a[e].to<=s&&a.splice(e--,1);for(;o<i.length&&i[o].from<=s&&i[o].to>s;)a.push(i[o++]);let u=s+h.nodeSize;if(h.isText){let e=u;o<i.length&&i[o].from<e&&(e=i[o].from);for(let t=0;t<a.length;t++)a[t].to<e&&(e=a[t].to);e<u&&(l=h.cut(e-s),h=h.cut(0,e-s),u=e,d=-1)}let p=h.isInline&&!h.isLeaf?a.filter((e=>!e.inline)):a.slice();r(h,p,t.forChild(s,h),d),s=u}}(this.node,this.innerDeco,((t,i,s)=>{t.spec.marks?a.syncToMarks(t.spec.marks,n,e):t.type.side>=0&&!s&&a.syncToMarks(i==this.node.childCount?Be.none:this.node.child(i).marks,n,e),a.placeWidget(t,e,r)}),((t,s,l,c)=>{let h;a.syncToMarks(t.marks,n,e),a.findNodeMatch(t,s,l,c)||o&&e.state.selection.from>r&&e.state.selection.to<r+t.nodeSize&&(h=a.findIndexWithChild(i.node))>-1&&a.updateNodeAt(t,s,l,h,e)||a.updateNextNode(t,s,l,e,c)||a.addNode(t,s,l,e,r),r+=t.nodeSize})),a.syncToMarks([],n,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||2==this.dirty)&&(s&&this.protectLocalComposition(e,s),Gr(this.contentDOM,this.children,e),pr&&function(e){if("UL"==e.nodeName||"OL"==e.nodeName){let t=e.style.cssText;e.style.cssText=t+"; list-style: square !important",window.getComputedStyle(e).listStyle,e.style.cssText=t}}(this.dom))}localCompositionInfo(e,t){let{from:n,to:r}=e.state.selection;if(!(e.state.selection instanceof Mn)||n<t||r>t+this.node.content.size)return null;let i=e.domSelectionRange(),s=function(e,t){for(;;){if(3==e.nodeType)return e;if(1==e.nodeType&&t>0){if(e.childNodes.length>t&&3==e.childNodes[t].nodeType)return e.childNodes[t];t=Yn(e=e.childNodes[t-1])}else{if(!(1==e.nodeType&&t<e.childNodes.length))return null;e=e.childNodes[t],t=0}}}(i.focusNode,i.focusOffset);if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let e=s.nodeValue,i=function(e,t,n,r){for(let i=0,s=0;i<e.childCount&&s<=r;){let o=e.child(i++),a=s;if(s+=o.nodeSize,!o.isText)continue;let l=o.text;for(;i<e.childCount;){let t=e.child(i++);if(s+=t.nodeSize,!t.isText)break;l+=t.text}if(s>=n){let e=a<r?l.lastIndexOf(t,r-a-1):-1;if(e>=0&&e+t.length+a>=n)return a+e;if(n==r&&l.length>=r+t.length-a&&l.slice(r-a,r-a+t.length)==t)return r}}return-1}(this.node.content,e,n-t,r-t);return i<0?null:{node:s,pos:i,text:e}}return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:n,text:r}){if(this.getDesc(t))return;let i=t;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let s=new _r(this,i,t,r);e.input.compositionNodes.push(s),this.children=oi(this.children,n,n+r.length,e,s)}update(e,t,n,r){return!(3==this.dirty||!e.sameMarkup(this.node))&&(this.updateInner(e,t,n,r),!0)}updateInner(e,t,n,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=0}updateOuterDeco(e){if(ni(e,this.outerDeco))return;let t=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=Qr(this.dom,this.nodeDOM,Zr(this.outerDeco,this.node,t),Zr(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){1==this.nodeDOM.nodeType&&this.nodeDOM.classList.add("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.dom.draggable=!0)}deselectNode(){1==this.nodeDOM.nodeType&&this.nodeDOM.classList.remove("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||this.dom.removeAttribute("draggable")}get domAtom(){return this.node.isAtom}}function Kr(e,t,n,r,i){return ti(r,t,e),new Hr(void 0,e,t,n,r,r,r,i,0)}class qr extends Hr{constructor(e,t,n,r,i,s,o){super(e,t,n,r,i,null,s,o,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,r){return!(3==this.dirty||0!=this.dirty&&!this.inParent()||!e.sameMarkup(this.node))&&(this.updateOuterDeco(t),0==this.dirty&&e.text==this.node.text||e.text==this.nodeDOM.nodeValue||(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=e,this.dirty=0,!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,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return"characterData"!=e.type&&"selection"!=e.type}slice(e,t,n){let r=this.node.cut(e,t),i=document.createTextNode(r.text);return new qr(this.parent,r,this.outerDeco,this.innerDeco,i,i,n)}markDirty(e,t){super.markDirty(e,t),this.dom==this.nodeDOM||0!=e&&t!=this.nodeDOM.nodeValue.length||(this.dirty=3)}get domAtom(){return!1}}class Jr extends Vr{parseRule(){return{ignore:!0}}matchesHack(e){return 0==this.dirty&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return"IMG"==this.dom.nodeName}}class Ur extends Hr{constructor(e,t,n,r,i,s,o,a,l,c){super(e,t,n,r,i,s,o,l,c),this.spec=a}update(e,t,n,r){if(3==this.dirty)return!1;if(this.spec.update){let i=this.spec.update(e,t,n);return i&&this.updateInner(e,t,n,r),i}return!(!this.contentDOM&&!e.isLeaf)&&super.update(e,t,n,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,r){this.spec.setSelection?this.spec.setSelection(e,t,n):super.setSelection(e,t,n,r)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return!!this.spec.stopEvent&&this.spec.stopEvent(e)}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function Gr(e,t,n){let r=e.firstChild,i=!1;for(let s=0;s<t.length;s++){let o=t[s],a=o.dom;if(a.parentNode==e){for(;a!=r;)r=ri(r),i=!0;r=r.nextSibling}else i=!0,e.insertBefore(a,r);if(o instanceof Wr){let t=r?r.previousSibling:e.lastChild;Gr(o.contentDOM,o.children,n),r=t?t.nextSibling:e.firstChild}}for(;r;)r=ri(r),i=!0;i&&n.trackWrites==e&&(n.trackWrites=null)}const Yr=function(e){e&&(this.nodeName=e)};Yr.prototype=Object.create(null);const Xr=[new Yr];function Zr(e,t,n){if(0==e.length)return Xr;let r=n?Xr[0]:new Yr,i=[r];for(let s=0;s<e.length;s++){let o=e[s].type.attrs;if(o){o.nodeName&&i.push(r=new Yr(o.nodeName));for(let e in o){let s=o[e];null!=s&&(n&&1==i.length&&i.push(r=new Yr(t.isInline?"span":"div")),"class"==e?r.class=(r.class?r.class+" ":"")+s:"style"==e?r.style=(r.style?r.style+";":"")+s:"nodeName"!=e&&(r[e]=s))}}}return i}function Qr(e,t,n,r){if(n==Xr&&r==Xr)return t;let i=t;for(let t=0;t<r.length;t++){let s=r[t],o=n[t];if(t){let t;o&&o.nodeName==s.nodeName&&i!=e&&(t=i.parentNode)&&t.nodeName.toLowerCase()==s.nodeName||(t=document.createElement(s.nodeName),t.pmIsDeco=!0,t.appendChild(i),o=Xr[0]),i=t}ei(i,o||Xr[0],s)}return i}function ei(e,t,n){for(let r in t)"class"==r||"style"==r||"nodeName"==r||r in n||e.removeAttribute(r);for(let r in n)"class"!=r&&"style"!=r&&"nodeName"!=r&&n[r]!=t[r]&&e.setAttribute(r,n[r]);if(t.class!=n.class){let r=t.class?t.class.split(" ").filter(Boolean):[],i=n.class?n.class.split(" ").filter(Boolean):[];for(let t=0;t<r.length;t++)-1==i.indexOf(r[t])&&e.classList.remove(r[t]);for(let t=0;t<i.length;t++)-1==r.indexOf(i[t])&&e.classList.add(i[t]);0==e.classList.length&&e.removeAttribute("class")}if(t.style!=n.style){if(t.style){let n,r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;for(;n=r.exec(t.style);)e.style.removeProperty(n[1])}n.style&&(e.style.cssText+=n.style)}}function ti(e,t,n){return Qr(e,e,Xr,Zr(t,n,1!=e.nodeType))}function ni(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].type.eq(t[n].type))return!1;return!0}function ri(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}class ii{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=function(e,t){let n=t,r=n.children.length,i=e.childCount,s=new Map,o=[];e:for(;i>0;){let a;for(;;)if(r){let e=n.children[r-1];if(!(e instanceof Wr)){a=e,r--;break}n=e,r=e.children.length}else{if(n==t)break e;r=n.parent.children.indexOf(n),n=n.parent}let l=a.node;if(l){if(l!=e.child(i-1))break;--i,s.set(a,i),o.push(a)}}return{index:i,matched:s,matches:o.reverse()}}(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,n){let r=0,i=this.stack.length>>1,s=Math.min(i,e.length);for(;r<s&&(r==i-1?this.top:this.stack[r+1<<1]).matchesMark(e[r])&&!1!==e[r].type.spec.spanning;)r++;for(;r<i;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),i--;for(;i<e.length;){this.stack.push(this.top,this.index+1);let r=-1;for(let t=this.index;t<Math.min(this.index+3,this.top.children.length);t++)if(this.top.children[t].matchesMark(e[i])){r=t;break}if(r>-1)r>this.index&&(this.changed=!0,this.destroyBetween(this.index,r)),this.top=this.top.children[this.index];else{let r=Wr.create(this.top,e[i],t,n);this.top.children.splice(this.index,0,r),this.top=r,this.changed=!0}this.index=0,i++}}findNodeMatch(e,t,n,r){let i,s=-1;if(r>=this.preMatch.index&&(i=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&i.matchesNode(e,t,n))s=this.top.children.indexOf(i,this.index);else for(let r=this.index,i=Math.min(this.top.children.length,r+5);r<i;r++){let i=this.top.children[r];if(i.matchesNode(e,t,n)&&!this.preMatch.matched.has(i)){s=r;break}}return!(s<0)&&(this.destroyBetween(this.index,s),this.index++,!0)}updateNodeAt(e,t,n,r,i){let s=this.top.children[r];return 3==s.dirty&&s.dom==s.contentDOM&&(s.dirty=2),!!s.update(e,t,n,i)&&(this.destroyBetween(this.index,r),this.index++,!0)}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let t=e.pmViewDesc;if(t)for(let e=this.index;e<this.top.children.length;e++)if(this.top.children[e]==t)return e;return-1}e=t}}updateNextNode(e,t,n,r,i){for(let s=this.index;s<this.top.children.length;s++){let o=this.top.children[s];if(o instanceof Hr){let a=this.preMatch.matched.get(o);if(null!=a&&a!=i)return!1;let l=o.dom;if(!(this.lock&&(l==this.lock||1==l.nodeType&&l.contains(this.lock.parentNode))&&!(e.isText&&o.node&&o.node.isText&&o.nodeDOM.nodeValue==e.text&&3!=o.dirty&&ni(t,o.outerDeco)))&&o.update(e,t,n,r))return this.destroyBetween(this.index,s),o.dom!=l&&(this.changed=!0),this.index++,!0;break}}return!1}addNode(e,t,n,r,i){this.top.children.splice(this.index++,0,Hr.create(this.top,e,t,n,r,i)),this.changed=!0}placeWidget(e,t,n){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(!r||!r.matchesWidget(e)||e!=r.widget&&r.widget.type.toDOM.parentNode){let r=new jr(this.top,e,t,n);this.top.children.splice(this.index++,0,r),this.changed=!0}else this.index++}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Wr;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof qr)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((ur||hr)&&e&&"false"==e.dom.contentEditable&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let n=document.createElement(e);"IMG"==e&&(n.className="ProseMirror-separator",n.alt=""),"BR"==e&&(n.className="ProseMirror-trailingBreak");let r=new Jr(this.top,[],n,null);t!=this.top?t.children.push(r):t.children.splice(this.index++,0,r),this.changed=!0}}}function si(e,t){return e.type.side-t.type.side}function oi(e,t,n,r,i){let s=[];for(let o=0,a=0;o<e.length;o++){let l=e[o],c=a,h=a+=l.size;c>=n||h<=t?s.push(l):(c<t&&s.push(l.slice(0,t-c,r)),i&&(s.push(i),i=void 0),h>n&&s.push(l.slice(n-c,l.size,r)))}return s}function ai(e,t=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let i=e.docView.nearestDesc(n.focusNode),s=i&&0==i.size,o=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let a,l,c=r.resolve(o);if(Zn(n)){for(a=c;i&&!i.node;)i=i.parent;let e=i.node;if(i&&e.isAtom&&Cn.isSelectable(e)&&i.parent&&(!e.isInline||!function(e,t,n){for(let r=0==t,i=t==Yn(e);r||i;){if(e==n)return!0;let t=Wn(e);if(!(e=e.parentNode))return!1;r=r&&0==t,i=i&&t==Yn(e)}}(n.focusNode,n.focusOffset,i.dom))){let e=i.posBefore;l=new Cn(o==e?c:r.resolve(e))}}else{let t=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(t<0)return null;a=r.resolve(t)}if(!l){l=gi(e,a,c,"pointer"==t||e.state.selection.head<c.pos&&!s?1:-1)}return l}function li(e){return e.editable?e.hasFocus():vi(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function ci(e,t=!1){let n=e.state.selection;if(fi(e,n),li(e)){if(!t&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&hr){let t=e.domSelectionRange(),n=e.domObserver.currentSelection;if(t.anchorNode&&n.anchorNode&&Jn(t.anchorNode,t.anchorOffset,n.anchorNode,n.anchorOffset))return e.input.mouseDown.delayedSelectionSync=!0,void e.domObserver.setCurSelection()}if(e.domObserver.disconnectSelection(),e.cursorWrapper)!function(e){let t=e.domSelection(),n=document.createRange(),r=e.cursorWrapper.dom,i="IMG"==r.nodeName;i?n.setEnd(r.parentNode,Wn(r)+1):n.setEnd(r,0);n.collapse(!1),t.removeAllRanges(),t.addRange(n),!i&&!e.state.selection.visible&&or&&ar<=11&&(r.disabled=!0,r.disabled=!1)}(e);else{let r,i,{anchor:s,head:o}=n;!hi||n instanceof Mn||(n.$from.parent.inlineContent||(r=di(e,n.from)),n.empty||n.$from.parent.inlineContent||(i=di(e,n.to))),e.docView.setSelection(s,o,e.root,t),hi&&(r&&pi(r),i&&pi(i)),n.visible?e.dom.classList.remove("ProseMirror-hideselection"):(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&function(e){let t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.input.hideSelectionGuard);let n=e.domSelectionRange(),r=n.anchorNode,i=n.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=()=>{n.anchorNode==r&&n.anchorOffset==i||(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout((()=>{li(e)&&!e.state.selection.visible||e.dom.classList.remove("ProseMirror-hideselection")}),20))})}(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}const hi=ur||hr&&dr<63;function di(e,t){let{node:n,offset:r}=e.docView.domFromPos(t,0),i=r<n.childNodes.length?n.childNodes[r]:null,s=r?n.childNodes[r-1]:null;if(ur&&i&&"false"==i.contentEditable)return ui(i);if(!(i&&"false"!=i.contentEditable||s&&"false"!=s.contentEditable)){if(i)return ui(i);if(s)return ui(s)}}function ui(e){return e.contentEditable="true",ur&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function pi(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function fi(e,t){if(t instanceof Cn){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(mi(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else mi(e)}function mi(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function gi(e,t,n,r){return e.someProp("createSelectionBetween",(r=>r(e,t,n)))||Mn.between(t,n,r)}function yi(e){return!(e.editable&&!e.hasFocus())&&vi(e)}function vi(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(3==t.anchorNode.nodeType?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(3==t.focusNode.nodeType?t.focusNode.parentNode:t.focusNode))}catch(e){return!1}}function wi(e,t){let{$anchor:n,$head:r}=e.selection,i=t>0?n.max(r):n.min(r),s=i.parent.inlineContent?i.depth?e.doc.resolve(t>0?i.after():i.before()):null:i;return s&&bn.findFrom(s,t)}function bi(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function xi(e,t,n){let r=e.state.selection;if(!(r instanceof Mn)){if(r instanceof Cn&&r.node.isInline)return bi(e,new Mn(t>0?r.$to:r.$from));{let n=wi(e.state,t);return!!n&&bi(e,n)}}if(!r.empty||n.indexOf("s")>-1)return!1;if(e.endOfTextblock(t>0?"right":"left")){let n=wi(e.state,t);return!!(n&&n instanceof Cn)&&bi(e,n)}if(!(fr&&n.indexOf("m")>-1)){let n,i=r.$head,s=i.textOffset?null:t<0?i.nodeBefore:i.nodeAfter;if(!s||s.isText)return!1;let o=t<0?i.pos-s.nodeSize:i.pos;return!!(s.isAtom||(n=e.docView.descAt(o))&&!n.contentDOM)&&(Cn.isSelectable(s)?bi(e,new Cn(t<0?e.state.doc.resolve(i.pos-s.nodeSize):i)):!!gr&&bi(e,new Mn(e.state.doc.resolve(t<0?o:o+s.nodeSize))))}}function ki(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function Si(e){let t=e.pmViewDesc;return t&&0==t.size&&(e.nextSibling||"BR"!=e.nodeName)}function Mi(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i,s,o=!1;for(lr&&1==n.nodeType&&r<ki(n)&&Si(n.childNodes[r])&&(o=!0);;)if(r>0){if(1!=n.nodeType)break;{let e=n.childNodes[r-1];if(Si(e))i=n,s=--r;else{if(3!=e.nodeType)break;n=e,r=n.nodeValue.length}}}else{if(Ci(n))break;{let t=n.previousSibling;for(;t&&Si(t);)i=n.parentNode,s=Wn(t),t=t.previousSibling;if(t)n=t,r=ki(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}}o?Ai(e,n,r):i&&Ai(e,i,s)}function Oi(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i,s,o=ki(n);for(;;)if(r<o){if(1!=n.nodeType)break;if(!Si(n.childNodes[r]))break;i=n,s=++r}else{if(Ci(n))break;{let t=n.nextSibling;for(;t&&Si(t);)i=t.parentNode,s=Wn(t)+1,t=t.nextSibling;if(t)n=t,r=0,o=ki(n);else{if(n=n.parentNode,n==e.dom)break;r=o=0}}}i&&Ai(e,i,s)}function Ci(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function Ai(e,t,n){let r=e.domSelection();if(Zn(r)){let e=document.createRange();e.setEnd(t,n),e.setStart(t,n),r.removeAllRanges(),r.addRange(e)}else r.extend&&r.extend(t,n);e.domObserver.setCurSelection();let{state:i}=e;setTimeout((()=>{e.state==i&&ci(e)}),50)}function Ei(e,t,n){let r=e.state.selection;if(r instanceof Mn&&!r.empty||n.indexOf("s")>-1)return!1;if(fr&&n.indexOf("m")>-1)return!1;let{$from:i,$to:s}=r;if(!i.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let n=wi(e.state,t);if(n&&n instanceof Cn)return bi(e,n)}if(!i.parent.inlineContent){let n=t<0?i:s,o=r instanceof En?bn.near(n,t):bn.findFrom(n,t);return!!o&&bi(e,o)}return!1}function Ti(e,t){if(!(e.state.selection instanceof Mn))return!0;let{$head:n,$anchor:r,empty:i}=e.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;let s=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(s&&!s.isText){let r=e.state.tr;return t<0?r.delete(n.pos-s.nodeSize,n.pos):r.delete(n.pos,n.pos+s.nodeSize),e.dispatch(r),!0}return!1}function Ni(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function Di(e,t){let n=t.keyCode,r=function(e){let t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}(t);return 8==n||fr&&72==n&&"c"==r?Ti(e,-1)||Mi(e):46==n||fr&&68==n&&"c"==r?Ti(e,1)||Oi(e):13==n||27==n||(37==n||fr&&66==n&&"c"==r?xi(e,-1,r)||Mi(e):39==n||fr&&70==n&&"c"==r?xi(e,1,r)||Oi(e):38==n||fr&&80==n&&"c"==r?Ei(e,-1,r)||Mi(e):40==n||fr&&78==n&&"c"==r?function(e){if(!ur||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&1==t.nodeType&&0==n&&t.firstChild&&"false"==t.firstChild.contentEditable){let n=t.firstChild;Ni(e,n,"true"),setTimeout((()=>Ni(e,n,"false")),20)}return!1}(e)||Ei(e,1,r)||Oi(e):r==(fr?"m":"c")&&(66==n||73==n||89==n||90==n))}function $i(e,t){e.someProp("transformCopied",(e=>{t=e(t)}));let n=[],{content:r,openStart:i,openEnd:s}=t;for(;i>1&&s>1&&1==r.childCount&&1==r.firstChild.childCount;){i--,s--;let e=r.firstChild;n.push(e.type.name,e.attrs!=e.type.defaultAttrs?e.attrs:null),r=e.content}let o=e.someProp("clipboardSerializer")||$t.fromSchema(e.state.schema),a=_i(),l=a.createElement("div");l.appendChild(o.serializeFragment(r,{document:a}));let c,h=l.firstChild,d=0;for(;h&&1==h.nodeType&&(c=Vi[h.nodeName.toLowerCase()]);){for(let e=c.length-1;e>=0;e--){let t=a.createElement(c[e]);for(;l.firstChild;)t.appendChild(l.firstChild);l.appendChild(t),d++}h=l.firstChild}h&&1==h.nodeType&&h.setAttribute("data-pm-slice",`${i} ${s}${d?` -${d}`:""} ${JSON.stringify(n)}`);let u=e.someProp("clipboardTextSerializer",(e=>e(t)))||t.content.textBetween(0,t.content.size,"\n\n");return{dom:l,text:u}}function Ii(e,t,n,r,i){let s,o,a=i.parent.type.spec.code;if(!n&&!t)return null;let l=t&&(r||a||!n);if(l){if(e.someProp("transformPastedText",(e=>{t=e(t,a||r)})),a)return t?new Le($e.from(e.state.schema.text(t.replace(/\r\n?/g,"\n"))),0,0):Le.empty;let n=e.someProp("clipboardTextParser",(e=>e(t,i,r)));if(n)o=n;else{let n=i.marks(),{schema:r}=e.state,o=$t.fromSchema(r);s=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach((e=>{let t=s.appendChild(document.createElement("p"));e&&t.appendChild(o.serializeNode(r.text(e,n)))}))}}else e.someProp("transformPastedHTML",(e=>{n=e(n)})),s=function(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n,r=_i().createElement("div"),i=/<([a-z][^>\s]+)/i.exec(e);(n=i&&Vi[i[1].toLowerCase()])&&(e=n.map((e=>"<"+e+">")).join("")+e+n.map((e=>"</"+e+">")).reverse().join(""));if(r.innerHTML=e,n)for(let e=0;e<n.length;e++)r=r.querySelector(n[e])||r;return r}(n),gr&&function(e){let t=e.querySelectorAll(hr?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<t.length;n++){let r=t[n];1==r.childNodes.length&&" "==r.textContent&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),r)}}(s);let c=s&&s.querySelector("[data-pm-slice]"),h=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(h&&h[3])for(let e=+h[3];e>0&&s.firstChild;e--)s=s.firstChild;if(!o){let t=e.someProp("clipboardParser")||e.someProp("domParser")||kt.fromSchema(e.state.schema);o=t.parseSlice(s,{preserveWhitespace:!(!l&&!h),context:i,ruleFromNode:e=>"BR"!=e.nodeName||e.nextSibling||!e.parentNode||Ri.test(e.parentNode.nodeName)?null:{ignore:!0}})}if(h)o=function(e,t){if(!e.size)return e;let n,r=e.content.firstChild.type.schema;try{n=JSON.parse(t)}catch(t){return e}let{content:i,openStart:s,openEnd:o}=e;for(let e=n.length-2;e>=0;e-=2){let t=r.nodes[n[e]];if(!t||t.hasRequiredAttrs())break;i=$e.from(t.create(n[e+1],i)),s++,o++}return new Le(i,s,o)}(zi(o,+h[1],+h[2]),h[4]);else if(o=Le.maxOpen(function(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let r,i=t.node(n).contentMatchAt(t.index(n)),s=[];if(e.forEach((e=>{if(!s)return;let t,n=i.findWrapping(e.type);if(!n)return s=null;if(t=s.length&&r.length&&Bi(n,r,e,s[s.length-1],0))s[s.length-1]=t;else{s.length&&(s[s.length-1]=Fi(s[s.length-1],r.length));let t=Pi(e,n);s.push(t),i=i.matchType(t.type),r=n}})),s)return $e.from(s)}return e}(o.content,i),!0),o.openStart||o.openEnd){let e=0,t=0;for(let t=o.content.firstChild;e<o.openStart&&!t.type.spec.isolating;e++,t=t.firstChild);for(let e=o.content.lastChild;t<o.openEnd&&!e.type.spec.isolating;t++,e=e.lastChild);o=zi(o,e,t)}return e.someProp("transformPasted",(e=>{o=e(o)})),o}const Ri=/^(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 Pi(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,$e.from(e));return e}function Bi(e,t,n,r,i){if(i<e.length&&i<t.length&&e[i]==t[i]){let s=Bi(e,t,n,r.lastChild,i+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(i==e.length-1?n.type:e[i+1]))return r.copy(r.content.append($e.from(Pi(n,e,i+1))))}}function Fi(e,t){if(0==t)return e;let n=e.content.replaceChild(e.childCount-1,Fi(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore($e.empty,!0);return e.copy(n.append(r))}function Li(e,t,n,r,i,s){let o=t<0?e.firstChild:e.lastChild,a=o.content;return i<r-1&&(a=Li(a,t,n,r,i+1,s)),i>=n&&(a=t<0?o.contentMatchAt(0).fillBefore(a,e.childCount>1||s<=i).append(a):a.append(o.contentMatchAt(o.childCount).fillBefore($e.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,o.copy(a))}function zi(e,t,n){return t<e.openStart&&(e=new Le(Li(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new Le(Li(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}const Vi={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let ji=null;function _i(){return ji||(ji=document.implementation.createHTMLDocument("title"))}const Wi={},Hi={},Ki={touchstart:!0,touchmove:!0};class qi{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.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function Ji(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function Ui(e){e.someProp("handleDOMEvents",(t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>Gi(e,t))}))}function Gi(e,t){return e.someProp("handleDOMEvents",(n=>{let r=n[t.type];return!!r&&(r(e,t)||t.defaultPrevented)}))}function Yi(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||11==n.nodeType||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}function Xi(e){return{left:e.clientX,top:e.clientY}}function Zi(e,t,n,r,i){if(-1==r)return!1;let s=e.state.doc.resolve(r);for(let r=s.depth+1;r>0;r--)if(e.someProp(t,(t=>r>s.depth?t(e,n,s.nodeAfter,s.before(r),i,!0):t(e,n,s.node(r),s.before(r),i,!1))))return!0;return!1}function Qi(e,t,n){e.focused||e.focus();let r=e.state.tr.setSelection(t);"pointer"==n&&r.setMeta("pointer",!0),e.dispatch(r)}function es(e,t,n,r,i){return Zi(e,"handleClickOn",t,n,r)||e.someProp("handleClick",(n=>n(e,t,r)))||(i?function(e,t){if(-1==t)return!1;let n,r,i=e.state.selection;i instanceof Cn&&(n=i.node);let s=e.state.doc.resolve(t);for(let e=s.depth+1;e>0;e--){let t=e>s.depth?s.nodeAfter:s.node(e);if(Cn.isSelectable(t)){r=n&&i.$from.depth>0&&e>=i.$from.depth&&s.before(i.$from.depth+1)==i.$from.pos?s.before(i.$from.depth):s.before(e);break}}return null!=r&&(Qi(e,Cn.create(e.state.doc,r),"pointer"),!0)}(e,n):function(e,t){if(-1==t)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return!!(r&&r.isAtom&&Cn.isSelectable(r))&&(Qi(e,new Cn(n),"pointer"),!0)}(e,n))}function ts(e,t,n,r){return Zi(e,"handleDoubleClickOn",t,n,r)||e.someProp("handleDoubleClick",(n=>n(e,t,r)))}function ns(e,t,n,r){return Zi(e,"handleTripleClickOn",t,n,r)||e.someProp("handleTripleClick",(n=>n(e,t,r)))||function(e,t,n){if(0!=n.button)return!1;let r=e.state.doc;if(-1==t)return!!r.inlineContent&&(Qi(e,Mn.create(r,0,r.content.size),"pointer"),!0);let i=r.resolve(t);for(let t=i.depth+1;t>0;t--){let n=t>i.depth?i.nodeAfter:i.node(t),s=i.before(t);if(n.inlineContent)Qi(e,Mn.create(r,s+1,s+1+n.content.size),"pointer");else{if(!Cn.isSelectable(n))continue;Qi(e,Cn.create(r,s),"pointer")}return!0}}(e,n,r)}function rs(e){return ds(e)}Hi.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=16==n.keyCode||n.shiftKey,!as(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!mr||!hr||13!=n.keyCode))if(229!=n.keyCode&&e.domObserver.forceFlush(),!pr||13!=n.keyCode||n.ctrlKey||n.altKey||n.metaKey)e.someProp("handleKeyDown",(t=>t(e,n)))||Di(e,n)?n.preventDefault():Ji(e,"key");else{let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout((()=>{e.input.lastIOSEnter==t&&(e.someProp("handleKeyDown",(t=>t(e,Qn(13,"Enter")))),e.input.lastIOSEnter=0)}),200)}},Hi.keyup=(e,t)=>{16==t.keyCode&&(e.input.shiftKey=!1)},Hi.keypress=(e,t)=>{let n=t;if(as(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||fr&&n.metaKey)return;if(e.someProp("handleKeyPress",(t=>t(e,n))))return void n.preventDefault();let r=e.state.selection;if(!(r instanceof Mn&&r.$from.sameParent(r.$to))){let t=String.fromCharCode(n.charCode);e.someProp("handleTextInput",(n=>n(e,r.$from.pos,r.$to.pos,t)))||e.dispatch(e.state.tr.insertText(t).scrollIntoView()),n.preventDefault()}};const is=fr?"metaKey":"ctrlKey";Wi.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=rs(e),i=Date.now(),s="singleClick";i-e.input.lastClick.time<500&&function(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}(n,e.input.lastClick)&&!n[is]&&("singleClick"==e.input.lastClick.type?s="doubleClick":"doubleClick"==e.input.lastClick.type&&(s="tripleClick")),e.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:s};let o=e.posAtCoords(Xi(n));o&&("singleClick"==s?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new ss(e,o,n,!!r)):("doubleClick"==s?ts:ns)(e,o.pos,o.inside,n)?n.preventDefault():Ji(e,"pointer"))};class ss{constructor(e,t,n,r){let i,s;if(this.view=e,this.pos=t,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!n[is],this.allowDefault=n.shiftKey,t.inside>-1)i=e.state.doc.nodeAt(t.inside),s=t.inside;else{let n=e.state.doc.resolve(t.pos);i=n.parent,s=n.depth?n.before():0}const o=r?null:n.target,a=o?e.docView.nearestDesc(o,!0):null;this.target=a?a.dom:null;let{selection:l}=e.state;(0==n.button&&i.type.spec.draggable&&!1!==i.type.spec.selectable||l instanceof Cn&&l.from<=s&&l.to>s)&&(this.mightDrag={node:i,pos:s,addAttr:!(!this.target||this.target.draggable),setUneditable:!(!this.target||!lr||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)),Ji(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((()=>ci(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(Xi(e))),this.updateAllowDefault(e),this.allowDefault||!t?Ji(this.view,"pointer"):es(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():0==e.button&&(this.flushed||ur&&this.mightDrag&&!this.mightDrag.node.isAtom||hr&&!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)?(Qi(this.view,bn.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):Ji(this.view,"pointer")}move(e){this.updateAllowDefault(e),Ji(this.view,"pointer"),0==e.buttons&&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)}}function as(e,t){return!!e.composing||!!(ur&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500)&&(e.input.compositionEndedAt=-2e8,!0)}Wi.touchstart=e=>{e.input.lastTouch=Date.now(),rs(e),Ji(e,"pointer")},Wi.touchmove=e=>{e.input.lastTouch=Date.now(),Ji(e,"pointer")},Wi.contextmenu=e=>rs(e);const ls=mr?5e3:-1;function cs(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout((()=>ds(e)),t))}function hs(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=function(){let e=document.createEvent("Event");return e.initEvent("event",!0,!0),e.timeStamp}());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function ds(e,t=!1){if(!(mr&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),hs(e),t||e.docView&&e.docView.dirty){let t=ai(e);return t&&!t.eq(e.state.selection)?e.dispatch(e.state.tr.setSelection(t)):e.updateState(e.state),!0}return!1}}Hi.compositionstart=Hi.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$from;if(t.selection.empty&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some((e=>!1===e.type.spec.inclusive))))e.markCursor=e.state.storedMarks||n.marks(),ds(e,!0),e.markCursor=null;else if(ds(e),lr&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelectionRange();for(let n=t.focusNode,r=t.focusOffset;n&&1==n.nodeType&&0!=r;){let t=r<0?n.lastChild:n.childNodes[r-1];if(!t)break;if(3==t.nodeType){e.domSelection().collapse(t,t.nodeValue.length);break}n=t,r=-1}}e.input.composing=!0}cs(e,ls)},Hi.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,cs(e,20))};const us=or&&ar<15||pr&&yr<604;function ps(e,t,n,r){let i=Ii(e,t,n,e.input.shiftKey,e.state.selection.$from);if(e.someProp("handlePaste",(t=>t(e,r,i||Le.empty))))return!0;if(!i)return!1;let s=function(e){return 0==e.openStart&&0==e.openEnd&&1==e.content.childCount?e.content.firstChild:null}(i),o=s?e.state.tr.replaceSelectionWith(s,e.input.shiftKey):e.state.tr.replaceSelection(i);return e.dispatch(o.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}Wi.copy=Hi.cut=(e,t)=>{let n=t,r=e.state.selection,i="cut"==n.type;if(r.empty)return;let s=us?null:n.clipboardData,o=r.content(),{dom:a,text:l}=$i(e,o);s?(n.preventDefault(),s.clearData(),s.setData("text/html",a.innerHTML),s.setData("text/plain",l)):function(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(t),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout((()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()}),50)}(e,a),i&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))},Hi.paste=(e,t)=>{let n=t;if(e.composing&&!mr)return;let r=us?null:n.clipboardData;r&&ps(e,r.getData("text/plain"),r.getData("text/html"),n)?n.preventDefault():function(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus(),setTimeout((()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?ps(e,r.value,null,t):ps(e,r.textContent,r.innerHTML,t)}),50)}(e,n)};class fs{constructor(e,t){this.slice=e,this.move=t}}const ms=fr?"altKey":"ctrlKey";Wi.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=e.state.selection,s=i.empty?null:e.posAtCoords(Xi(n));if(s&&s.pos>=i.from&&s.pos<=(i instanceof Cn?i.to-1:i.to));else if(r&&r.mightDrag)e.dispatch(e.state.tr.setSelection(Cn.create(e.state.doc,r.mightDrag.pos)));else if(n.target&&1==n.target.nodeType){let t=e.docView.nearestDesc(n.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&e.dispatch(e.state.tr.setSelection(Cn.create(e.state.doc,t.posBefore)))}let o=e.state.selection.content(),{dom:a,text:l}=$i(e,o);n.dataTransfer.clearData(),n.dataTransfer.setData(us?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",us||n.dataTransfer.setData("text/plain",l),e.dragging=new fs(o,!n[ms])},Wi.dragend=e=>{let t=e.dragging;window.setTimeout((()=>{e.dragging==t&&(e.dragging=null)}),50)},Hi.dragover=Hi.dragenter=(e,t)=>t.preventDefault(),Hi.drop=(e,t)=>{let n=t,r=e.dragging;if(e.dragging=null,!n.dataTransfer)return;let i=e.posAtCoords(Xi(n));if(!i)return;let s=e.state.doc.resolve(i.pos),o=r&&r.slice;o?e.someProp("transformPasted",(e=>{o=e(o)})):o=Ii(e,n.dataTransfer.getData(us?"Text":"text/plain"),us?null:n.dataTransfer.getData("text/html"),!1,s);let a=!(!r||n[ms]);if(e.someProp("handleDrop",(t=>t(e,n,o||Le.empty,a))))return void n.preventDefault();if(!o)return;n.preventDefault();let l=o?sn(e.state.doc,s.pos,o):s.pos;null==l&&(l=s.pos);let c=e.state.tr;a&&c.deleteSelection();let h=c.mapping.map(l),d=0==o.openStart&&0==o.openEnd&&1==o.content.childCount,u=c.doc;if(d?c.replaceRangeWith(h,h,o.content.firstChild):c.replaceRange(h,h,o),c.doc.eq(u))return;let p=c.doc.resolve(h);if(d&&Cn.isSelectable(o.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(o.content.firstChild))c.setSelection(new Cn(p));else{let t=c.mapping.map(l);c.mapping.maps[c.mapping.maps.length-1].forEach(((e,n,r,i)=>t=i)),c.setSelection(gi(e,p,c.doc.resolve(t)))}e.focus(),e.dispatch(c.setMeta("uiEvent","drop"))},Wi.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0,setTimeout((()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&ci(e)}),20))},Wi.blur=(e,t)=>{let n=t;e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),e.focused=!1)},Wi.beforeinput=(e,t)=>{if(hr&&mr&&"deleteContentBackward"==t.inputType){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout((()=>{if(e.input.domChangeCount!=t)return;if(e.dom.blur(),e.focus(),e.someProp("handleKeyDown",(t=>t(e,Qn(8,"Backspace")))))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())}),50)}};for(let e in Hi)Wi[e]=Hi[e];function gs(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}class ys{constructor(e,t){this.toDOM=e,this.spec=t||ks,this.side=this.spec.side||0}map(e,t,n,r){let{pos:i,deleted:s}=e.mapResult(t.from+r,this.side<0?-1:1);return s?null:new bs(i-n,i-n,this)}valid(){return!0}eq(e){return this==e||e instanceof ys&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&gs(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class vs{constructor(e,t){this.attrs=e,this.spec=t||ks}map(e,t,n,r){let i=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-n,s=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-n;return i>=s?null:new bs(i,s,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof vs&&gs(this.attrs,e.attrs)&&gs(this.spec,e.spec)}static is(e){return e.type instanceof vs}destroy(){}}class ws{constructor(e,t){this.attrs=e,this.spec=t||ks}map(e,t,n,r){let i=e.mapResult(t.from+r,1);if(i.deleted)return null;let s=e.mapResult(t.to+r,-1);return s.deleted||s.pos<=i.pos?null:new bs(i.pos-n,s.pos-n,this)}valid(e,t){let n,{index:r,offset:i}=e.content.findIndex(t.from);return i==t.from&&!(n=e.child(r)).isText&&i+n.nodeSize==t.to}eq(e){return this==e||e instanceof ws&&gs(this.attrs,e.attrs)&&gs(this.spec,e.spec)}destroy(){}}class bs{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(e,t){return new bs(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,n){return this.type.map(e,this,t,n)}static widget(e,t,n){return new bs(e,e,new ys(t,n))}static inline(e,t,n,r){return new bs(e,t,new vs(n,r))}static node(e,t,n,r){return new bs(e,t,new ws(n,r))}get spec(){return this.type.spec}get inline(){return this.type instanceof vs}}const xs=[],ks={};class Ss{constructor(e,t){this.local=e.length?e:xs,this.children=t.length?t:xs}static create(e,t){return t.length?Ts(t,e,0,ks):Ms}find(e,t,n){let r=[];return this.findInner(null==e?0:e,null==t?1e9:t,r,0,n),r}findInner(e,t,n,r,i){for(let s=0;s<this.local.length;s++){let o=this.local[s];o.from<=t&&o.to>=e&&(!i||i(o.spec))&&n.push(o.copy(o.from+r,o.to+r))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<t&&this.children[s+1]>e){let o=this.children[s]+1;this.children[s+2].findInner(e-o,t-o,n,r+o,i)}}map(e,t,n){return this==Ms||0==e.maps.length?this:this.mapInner(e,t,0,0,n||ks)}mapInner(e,t,n,r,i){let s;for(let o=0;o<this.local.length;o++){let a=this.local[o].map(e,n,r);a&&a.type.valid(t,a)?(s||(s=[])).push(a):i.onRemove&&i.onRemove(this.local[o].spec)}return this.children.length?function(e,t,n,r,i,s,o){let a=e.slice();for(let e=0,t=s;e<n.maps.length;e++){let r=0;n.maps[e].forEach(((e,n,s,o)=>{let l=o-s-(n-e);for(let o=0;o<a.length;o+=3){let c=a[o+1];if(c<0||e>c+t-r)continue;let h=a[o]+t-r;n>=h?a[o+1]=e<=h?-2:-1:s>=i&&l&&(a[o]+=l,a[o+1]+=l)}r+=l})),t=n.maps[e].map(t,-1)}let l=!1;for(let t=0;t<a.length;t+=3)if(a[t+1]<0){if(-2==a[t+1]){l=!0,a[t+1]=-1;continue}let c=n.map(e[t]+s),h=c-i;if(h<0||h>=r.content.size){l=!0;continue}let d=n.map(e[t+1]+s,-1)-i,{index:u,offset:p}=r.content.findIndex(h),f=r.maybeChild(u);if(f&&p==h&&p+f.nodeSize==d){let r=a[t+2].mapInner(n,f,c+1,e[t]+s+1,o);r!=Ms?(a[t]=h,a[t+1]=d,a[t+2]=r):(a[t+1]=-2,l=!0)}else l=!0}if(l){let l=function(e,t,n,r,i,s,o){function a(e,t){for(let s=0;s<e.local.length;s++){let a=e.local[s].map(r,i,t);a?n.push(a):o.onRemove&&o.onRemove(e.local[s].spec)}for(let n=0;n<e.children.length;n+=3)a(e.children[n+2],e.children[n]+t+1)}for(let n=0;n<e.length;n+=3)-1==e[n+1]&&a(e[n+2],t[n]+s+1);return n}(a,e,t,n,i,s,o),c=Ts(l,r,0,o);t=c.local;for(let e=0;e<a.length;e+=3)a[e+1]<0&&(a.splice(e,3),e-=3);for(let e=0,t=0;e<c.children.length;e+=3){let n=c.children[e];for(;t<a.length&&a[t]<n;)t+=3;a.splice(t,0,c.children[e],c.children[e+1],c.children[e+2])}}return new Ss(t.sort(Ns),a)}(this.children,s||[],e,t,n,r,i):s?new Ss(s.sort(Ns),xs):Ms}add(e,t){return t.length?this==Ms?Ss.create(e,t):this.addInner(e,t,0):this}addInner(e,t,n){let r,i=0;e.forEach(((e,s)=>{let o,a=s+n;if(o=As(t,e,a)){for(r||(r=this.children.slice());i<r.length&&r[i]<s;)i+=3;r[i]==s?r[i+2]=r[i+2].addInner(e,o,a+1):r.splice(i,0,s,s+e.nodeSize,Ts(o,e,a+1,ks)),i+=3}}));let s=Cs(i?Es(t):t,-n);for(let t=0;t<s.length;t++)s[t].type.valid(e,s[t])||s.splice(t--,1);return new Ss(s.length?this.local.concat(s).sort(Ns):this.local,r||this.children)}remove(e){return 0==e.length||this==Ms?this:this.removeInner(e,0)}removeInner(e,t){let n=this.children,r=this.local;for(let r=0;r<n.length;r+=3){let i,s=n[r]+t,o=n[r+1]+t;for(let t,n=0;n<e.length;n++)(t=e[n])&&t.from>s&&t.to<o&&(e[n]=null,(i||(i=[])).push(t));if(!i)continue;n==this.children&&(n=this.children.slice());let a=n[r+2].removeInner(i,s+1);a!=Ms?n[r+2]=a:(n.splice(r,3),r-=3)}if(r.length)for(let n,i=0;i<e.length;i++)if(n=e[i])for(let e=0;e<r.length;e++)r[e].eq(n,t)&&(r==this.local&&(r=this.local.slice()),r.splice(e--,1));return n==this.children&&r==this.local?this:r.length||n.length?new Ss(r,n):Ms}forChild(e,t){if(this==Ms)return this;if(t.isLeaf)return Ss.empty;let n,r;for(let t=0;t<this.children.length;t+=3)if(this.children[t]>=e){this.children[t]==e&&(n=this.children[t+2]);break}let i=e+1,s=i+t.content.size;for(let e=0;e<this.local.length;e++){let t=this.local[e];if(t.from<s&&t.to>i&&t.type instanceof vs){let e=Math.max(i,t.from)-i,n=Math.min(s,t.to)-i;e<n&&(r||(r=[])).push(t.copy(e,n))}}if(r){let e=new Ss(r.sort(Ns),xs);return n?new Os([e,n]):e}return n||Ms}eq(e){if(this==e)return!0;if(!(e instanceof Ss)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return Ds(this.localsInner(e))}localsInner(e){if(this==Ms)return xs;if(e.inlineContent||!this.local.some(vs.is))return this.local;let t=[];for(let e=0;e<this.local.length;e++)this.local[e].type instanceof vs||t.push(this.local[e]);return t}}Ss.empty=new Ss([],[]),Ss.removeOverlap=Ds;const Ms=Ss.empty;class Os{constructor(e){this.members=e}map(e,t){const n=this.members.map((n=>n.map(e,t,ks)));return Os.from(n)}forChild(e,t){if(t.isLeaf)return Ss.empty;let n=[];for(let r=0;r<this.members.length;r++){let i=this.members[r].forChild(e,t);i!=Ms&&(i instanceof Os?n=n.concat(i.members):n.push(i))}return Os.from(n)}eq(e){if(!(e instanceof Os)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,n=!0;for(let r=0;r<this.members.length;r++){let i=this.members[r].localsInner(e);if(i.length)if(t){n&&(t=t.slice(),n=!1);for(let e=0;e<i.length;e++)t.push(i[e])}else t=i}return t?Ds(n?t:t.sort(Ns)):xs}static from(e){switch(e.length){case 0:return Ms;case 1:return e[0];default:return new Os(e)}}}function Cs(e,t){if(!t||!e.length)return e;let n=[];for(let r=0;r<e.length;r++){let i=e[r];n.push(new bs(i.from+t,i.to+t,i.type))}return n}function As(e,t,n){if(t.isLeaf)return null;let r=n+t.nodeSize,i=null;for(let t,s=0;s<e.length;s++)(t=e[s])&&t.from>n&&t.to<r&&((i||(i=[])).push(t),e[s]=null);return i}function Es(e){let t=[];for(let n=0;n<e.length;n++)null!=e[n]&&t.push(e[n]);return t}function Ts(e,t,n,r){let i=[],s=!1;t.forEach(((t,o)=>{let a=As(e,t,o+n);if(a){s=!0;let e=Ts(a,t,n+o+1,r);e!=Ms&&i.push(o,o+t.nodeSize,e)}}));let o=Cs(s?Es(e):e,-n).sort(Ns);for(let e=0;e<o.length;e++)o[e].type.valid(t,o[e])||(r.onRemove&&r.onRemove(o[e].spec),o.splice(e--,1));return o.length||i.length?new Ss(o,i):Ms}function Ns(e,t){return e.from-t.from||e.to-t.to}function Ds(e){let t=e;for(let n=0;n<t.length-1;n++){let r=t[n];if(r.from!=r.to)for(let i=n+1;i<t.length;i++){let s=t[i];if(s.from!=r.from){s.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,s.from),$s(t,i,r.copy(s.from,r.to)));break}s.to!=r.to&&(t==e&&(t=e.slice()),t[i]=s.copy(s.from,r.to),$s(t,i+1,s.copy(r.to,s.to)))}}return t}function $s(e,t,n){for(;t<e.length&&Ns(n,e[t])>0;)t++;e.splice(t,0,n)}function Is(e){let t=[];return e.someProp("decorations",(n=>{let r=n(e.state);r&&r!=Ms&&t.push(r)})),e.cursorWrapper&&t.push(Ss.create(e.state.doc,[e.cursorWrapper.deco])),Os.from(t)}const Rs={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Ps=or&&ar<=11;class Bs{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 Fs{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Bs,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.observer=window.MutationObserver&&new window.MutationObserver((e=>{for(let t=0;t<e.length;t++)this.queue.push(e[t]);or&&ar<=11&&e.some((e=>"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length))?this.flushSoon():this.flush()})),Ps&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.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,Rs)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout((()=>this.flush()),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout((()=>this.suppressingSelectionUpdates=!1),50)}onSelectionChange(){if(yi(this.view)){if(this.suppressingSelectionUpdates)return ci(this.view);if(or&&ar<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Jn(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,n=new Set;for(let t=e.focusNode;t;t=Hn(t))n.add(t);for(let r=e.anchorNode;r;r=Hn(r))if(n.has(r)){t=r;break}let r=t&&this.view.docView.nearestDesc(t);return r&&r.ignoreMutation({type:"selection",target:3==t.nodeType?t.parentNode:t})?(this.setCurSelection(),!0):void 0}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.observer?this.observer.takeRecords():[];this.queue.length&&(t=this.queue.concat(t),this.queue.length=0);let n=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&yi(e)&&!this.ignoreSelectionChange(n),i=-1,s=-1,o=!1,a=[];if(e.editable)for(let e=0;e<t.length;e++){let n=this.registerMutation(t[e],a);n&&(i=i<0?n.from:Math.min(n.from,i),s=s<0?n.to:Math.max(n.to,s),n.typeOver&&(o=!0))}if(lr&&a.length>1){let e=a.filter((e=>"BR"==e.nodeName));if(2==e.length){let t=e[0],n=e[1];t.parentNode&&t.parentNode.parentNode==n.parentNode?n.remove():t.remove()}}let l=null;i<0&&r&&e.input.lastFocus>Date.now()-200&&e.input.lastTouch<Date.now()-300&&Zn(n)&&(l=ai(e))&&l.eq(bn.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,ci(e),this.currentSelection.set(n),e.scrollToSelection()):(i>-1||r)&&(i>-1&&(e.docView.markDirty(i,s),function(e){if(Ls.has(e))return;if(Ls.set(e,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(e.dom).whiteSpace)){if(e.requiresGeckoHackNode=lr,zs)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),zs=!0}}(e)),this.handleDOMChange(i,s,o,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||ci(e),this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if("attributes"==e.type&&(n==this.view.docView||"contenteditable"==e.attributeName||"style"==e.attributeName&&!e.oldValue&&!e.target.getAttribute("style")))return null;if(!n||n.ignoreMutation(e))return null;if("childList"==e.type){for(let n=0;n<e.addedNodes.length;n++)t.push(e.addedNodes[n]);if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let r=e.previousSibling,i=e.nextSibling;if(or&&ar<=11&&e.addedNodes.length)for(let t=0;t<e.addedNodes.length;t++){let{previousSibling:n,nextSibling:s}=e.addedNodes[t];(!n||Array.prototype.indexOf.call(e.addedNodes,n)<0)&&(r=n),(!s||Array.prototype.indexOf.call(e.addedNodes,s)<0)&&(i=s)}let s=r&&r.parentNode==e.target?Wn(r)+1:0,o=n.localPosFromDOM(e.target,s,-1),a=i&&i.parentNode==e.target?Wn(i):e.target.childNodes.length;return{from:o,to:n.localPosFromDOM(e.target,a,1)}}return"attributes"==e.type?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}}}let Ls=new WeakMap,zs=!1;function Vs(e){let t=e.pmViewDesc;if(t)return t.parseRule();if("BR"==e.nodeName&&e.parentNode){if(ur&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let e=document.createElement("div");return e.appendChild(document.createElement("li")),{skip:e}}if(e.parentNode.lastChild==e||ur&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if("IMG"==e.nodeName&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null}function js(e,t,n,r,i){if(t<0){let t=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,n=ai(e,t);if(n&&!e.state.selection.eq(n)){let r=e.state.tr.setSelection(n);"pointer"==t?r.setMeta("pointer",!0):"key"==t&&r.scrollIntoView(),e.dispatch(r)}return}let s=e.state.doc.resolve(t),o=s.sharedDepth(n);t=s.before(o+1),n=e.state.doc.resolve(n).after(o+1);let a,l,c=e.state.selection,h=function(e,t,n){let r,{node:i,fromOffset:s,toOffset:o,from:a,to:l}=e.docView.parseRange(t,n),c=e.domSelectionRange(),h=c.anchorNode;if(h&&e.dom.contains(1==h.nodeType?h:h.parentNode)&&(r=[{node:h,offset:c.anchorOffset}],Zn(c)||r.push({node:c.focusNode,offset:c.focusOffset})),hr&&8===e.input.lastKeyCode)for(let e=o;e>s;e--){let t=i.childNodes[e-1],n=t.pmViewDesc;if("BR"==t.nodeName&&!n){o=e;break}if(!n||n.size)break}let d=e.state.doc,u=e.someProp("domParser")||kt.fromSchema(e.state.schema),p=d.resolve(a),f=null,m=u.parse(i,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:s,to:o,preserveWhitespace:"pre"!=p.parent.type.whitespace||"full",findPositions:r,ruleFromNode:Vs,context:p});if(r&&null!=r[0].pos){let e=r[0].pos,t=r[1]&&r[1].pos;null==t&&(t=e),f={anchor:e+a,head:t+a}}return{doc:m,sel:f,from:a,to:l}}(e,t,n),d=e.state.doc,u=d.slice(h.from,h.to);8===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime?(a=e.state.selection.to,l="end"):(a=e.state.selection.from,l="start"),e.input.lastKeyCode=null;let p=function(e,t,n,r,i){let s=e.findDiffStart(t,n);if(null==s)return null;let{a:o,b:a}=e.findDiffEnd(t,n+e.size,n+t.size);if("end"==i){r-=o+Math.max(0,s-Math.min(o,a))-s}if(o<s&&e.size<t.size){s-=r<=s&&r>=o?s-r:0,a=s+(a-o),o=s}else if(a<s){s-=r<=s&&r>=a?s-r:0,o=s+(o-a),a=s}return{start:s,endA:o,endB:a}}(u.content,h.doc.content,h.from,a,l);if((pr&&e.input.lastIOSEnter>Date.now()-225||mr)&&i.some((e=>"DIV"==e.nodeName||"P"==e.nodeName))&&(!p||p.endA>=p.endB)&&e.someProp("handleKeyDown",(t=>t(e,Qn(13,"Enter")))))return void(e.input.lastIOSEnter=0);if(!p){if(!(r&&c instanceof Mn&&!c.empty&&c.$head.sameParent(c.$anchor))||e.composing||h.sel&&h.sel.anchor!=h.sel.head){if(h.sel){let t=_s(e,e.state.doc,h.sel);t&&!t.eq(e.state.selection)&&e.dispatch(e.state.tr.setSelection(t))}return}p={start:c.from,endA:c.to,endB:c.to}}if(hr&&e.cursorWrapper&&h.sel&&h.sel.anchor==e.cursorWrapper.deco.from&&h.sel.head==h.sel.anchor){let e=p.endB-p.start;h.sel={anchor:h.sel.anchor+e,head:h.sel.anchor+e}}e.input.domChangeCount++,e.state.selection.from<e.state.selection.to&&p.start==p.endB&&e.state.selection instanceof Mn&&(p.start>e.state.selection.from&&p.start<=e.state.selection.from+2&&e.state.selection.from>=h.from?p.start=e.state.selection.from:p.endA<e.state.selection.to&&p.endA>=e.state.selection.to-2&&e.state.selection.to<=h.to&&(p.endB+=e.state.selection.to-p.endA,p.endA=e.state.selection.to)),or&&ar<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>h.from&&"  "==h.doc.textBetween(p.start-h.from-1,p.start-h.from+1)&&(p.start--,p.endA--,p.endB--);let f,m=h.doc.resolveNoCache(p.start-h.from),g=h.doc.resolveNoCache(p.endB-h.from),y=d.resolve(p.start),v=m.sameParent(g)&&m.parent.inlineContent&&y.end()>=p.endA;if((pr&&e.input.lastIOSEnter>Date.now()-225&&(!v||i.some((e=>"DIV"==e.nodeName||"P"==e.nodeName)))||!v&&m.pos<h.doc.content.size&&(f=bn.findFrom(h.doc.resolve(m.pos+1),1,!0))&&f.head==g.pos)&&e.someProp("handleKeyDown",(t=>t(e,Qn(13,"Enter")))))return void(e.input.lastIOSEnter=0);if(e.state.selection.anchor>p.start&&function(e,t,n,r,i){if(!r.parent.isTextblock||n-t<=i.pos-r.pos||Ws(r,!0,!1)<i.pos)return!1;let s=e.resolve(t);if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let o=e.resolve(Ws(s,!0,!0));return!(!o.parent.isTextblock||o.pos>n||Ws(o,!0,!1)<n)&&r.parent.content.cut(r.parentOffset).eq(o.parent.content)}(d,p.start,p.endA,m,g)&&e.someProp("handleKeyDown",(t=>t(e,Qn(8,"Backspace")))))return void(mr&&hr&&e.domObserver.suppressSelectionUpdates());hr&&mr&&p.endB==p.start&&(e.input.lastAndroidDelete=Date.now()),mr&&!v&&m.start()!=g.start()&&0==g.parentOffset&&m.depth==g.depth&&h.sel&&h.sel.anchor==h.sel.head&&h.sel.head==p.endA&&(p.endB-=2,g=h.doc.resolveNoCache(p.endB-h.from),setTimeout((()=>{e.someProp("handleKeyDown",(function(t){return t(e,Qn(13,"Enter"))}))}),20));let w,b,x,k=p.start,S=p.endA;if(v)if(m.pos==g.pos)or&&ar<=11&&0==m.parentOffset&&(e.domObserver.suppressSelectionUpdates(),setTimeout((()=>ci(e)),20)),w=e.state.tr.delete(k,S),b=d.resolve(p.start).marksAcross(d.resolve(p.endA));else if(p.endA==p.endB&&(x=function(e,t){let n,r,i,s=e.firstChild.marks,o=t.firstChild.marks,a=s,l=o;for(let e=0;e<o.length;e++)a=o[e].removeFromSet(a);for(let e=0;e<s.length;e++)l=s[e].removeFromSet(l);if(1==a.length&&0==l.length)r=a[0],n="add",i=e=>e.mark(r.addToSet(e.marks));else{if(0!=a.length||1!=l.length)return null;r=l[0],n="remove",i=e=>e.mark(r.removeFromSet(e.marks))}let c=[];for(let e=0;e<t.childCount;e++)c.push(i(t.child(e)));if($e.from(c).eq(e))return{mark:r,type:n}}(m.parent.content.cut(m.parentOffset,g.parentOffset),y.parent.content.cut(y.parentOffset,p.endA-y.start()))))w=e.state.tr,"add"==x.type?w.addMark(k,S,x.mark):w.removeMark(k,S,x.mark);else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let t=m.parent.textBetween(m.parentOffset,g.parentOffset);if(e.someProp("handleTextInput",(n=>n(e,k,S,t))))return;w=e.state.tr.insertText(t,k,S)}if(w||(w=e.state.tr.replace(k,S,h.doc.slice(p.start-h.from,p.endB-h.from))),h.sel){let t=_s(e,w.doc,h.sel);t&&!(hr&&mr&&e.composing&&t.empty&&(p.start!=p.endB||e.input.lastAndroidDelete<Date.now()-100)&&(t.head==k||t.head==w.mapping.map(S)-1)||or&&t.empty&&t.head==k)&&w.setSelection(t)}b&&w.ensureMarks(b),e.dispatch(w.scrollIntoView())}function _s(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:gi(e,t.resolve(n.anchor),t.resolve(n.head))}function Ws(e,t,n){let r=e.depth,i=t?e.end():e.pos;for(;r>0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,i++,t=!1;if(n){let t=e.node(r).maybeChild(e.indexAfter(r));for(;t&&!t.isLeaf;)t=t.firstChild,i++}return i}class Hs{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 qi,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Gs),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):"function"==typeof e?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=Js(this),qs(this),this.nodeViews=Us(this),this.docView=Kr(this.state.doc,Ks(this),Is(this),this.dom,this),this.domObserver=new Fs(this,((e,t,n,r)=>js(this,e,t,n,r))),this.domObserver.start(),function(e){for(let t in Wi){let n=Wi[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{!Yi(e,t)||Gi(e,t)||!e.editable&&t.type in Hi||n(e,t)},Ki[t]?{passive:!0}:void 0)}ur&&e.dom.addEventListener("input",(()=>null)),Ui(e)}(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&&Ui(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Gs),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let e in this._props)t[e]=this._props[e];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){let n=this.state,r=!1,i=!1;e.storedMarks&&this.composing&&(hs(this),i=!0),this.state=e;let s=n.plugins!=e.plugins||this._props.plugins!=t.plugins;if(s||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=Us(this);(function(e,t){let n=0,r=0;for(let r in e){if(e[r]!=t[r])return!0;n++}for(let e in t)r++;return n!=r})(e,this.nodeViews)&&(this.nodeViews=e,r=!0)}(s||t.handleDOMEvents!=this._props.handleDOMEvents)&&Ui(this),this.editable=Js(this),qs(this);let o=Is(this),a=Ks(this),l=n.plugins==e.plugins||n.doc.eq(e.doc)?e.scrollToSelection>n.scrollToSelection?"to selection":"preserve":"reset",c=r||!this.docView.matchesNode(e.doc,a,o);!c&&e.selection.eq(n.selection)||(i=!0);let h="preserve"==l&&i&&null==this.dom.style.overflowAnchor&&function(e){let t,n,r=e.dom.getBoundingClientRect(),i=Math.max(0,r.top);for(let s=(r.left+r.right)/2,o=i+1;o<Math.min(innerHeight,r.bottom);o+=5){let r=e.root.elementFromPoint(s,o);if(!r||r==e.dom||!e.dom.contains(r))continue;let a=r.getBoundingClientRect();if(a.top>=i-20){t=r,n=a.top;break}}return{refDOM:t,refTop:n,stack:kr(e.dom)}}(this);if(i){this.domObserver.stop();let t=c&&(or||hr)&&!this.composing&&!n.selection.empty&&!e.selection.empty&&function(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}(n.selection,e.selection);if(c){let n=hr?this.trackWrites=this.domSelectionRange().focusNode:null;!r&&this.docView.update(e.doc,a,o,this)||(this.docView.updateOuterDeco([]),this.docView.destroy(),this.docView=Kr(e.doc,a,o,this.dom,this)),n&&!this.trackWrites&&(t=!0)}t||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&function(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return Jn(t.node,t.offset,n.anchorNode,n.anchorOffset)}(this))?ci(this,t):(fi(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(n),"reset"==l?this.dom.scrollTop=0:"to selection"==l?this.scrollToSelection():h&&function({refDOM:e,refTop:t,stack:n}){let r=e?e.getBoundingClientRect().top:0;Sr(n,0==r?0:r-t)}(h)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(this.someProp("handleScrollToSelection",(e=>e(this))));else if(this.state.selection instanceof Cn){let t=this.docView.domAfterPos(this.state.selection.from);1==t.nodeType&&xr(this,t.getBoundingClientRect(),e)}else xr(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)for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}else{this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let e=0;e<this.directPlugins.length;e++){let t=this.directPlugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}for(let e=0;e<this.state.plugins.length;e++){let t=this.state.plugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}}}someProp(e,t){let n,r=this._props&&this._props[e];if(null!=r&&(n=t?t(r):r))return n;for(let r=0;r<this.directPlugins.length;r++){let i=this.directPlugins[r].props[e];if(null!=i&&(n=t?t(i):i))return n}let i=this.state.plugins;if(i)for(let r=0;r<i.length;r++){let s=i[r].props[e];if(null!=s&&(n=t?t(s):s))return n}}hasFocus(){if(or){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if("false"==e.contentEditable)return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&function(e){if(e.setActive)return e.setActive();if(Mr)return e.focus(Mr);let t=kr(e);e.focus(null==Mr?{get preventScroll(){return Mr={preventScroll:!0},!0}}:void 0),Mr||(Mr=!1,Sr(t,0))}(this.dom),ci(this),this.domObserver.start()}get root(){let e=this._root;if(null==e)for(let e=this.dom.parentNode;e;e=e.parentNode)if(9==e.nodeType||11==e.nodeType&&e.host)return e.getSelection||(Object.getPrototypeOf(e).getSelection=()=>e.ownerDocument.getSelection()),this._root=e;return e||document}posAtCoords(e){return Er(this,e)}coordsAtPos(e,t=1){return Dr(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,n=-1){let r=this.docView.posFromDOM(e,t,n);if(null==r)throw new RangeError("DOM position not inside the editor");return r}endOfTextblock(e,t){return zr(this,t||this.state,e)}destroy(){this.docView&&(!function(e){e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Is(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null)}get isDestroyed(){return null==this.docView}dispatchEvent(e){return function(e,t){Gi(e,t)||!Wi[t.type]||!e.editable&&t.type in Hi||Wi[t.type](e,t)}(this,e)}dispatch(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))}domSelectionRange(){return ur&&11===this.root.nodeType&&function(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}(this.dom.ownerDocument)==this.dom?function(e){let t;function n(e){e.preventDefault(),e.stopImmediatePropagation(),t=e.getTargetRanges()[0]}e.dom.addEventListener("beforeinput",n,!0),document.execCommand("indent"),e.dom.removeEventListener("beforeinput",n,!0);let r=t.startContainer,i=t.startOffset,s=t.endContainer,o=t.endOffset,a=e.domAtPos(e.state.selection.anchor);return Jn(a.node,a.offset,s,o)&&([r,i,s,o]=[s,o,r,i]),{anchorNode:r,anchorOffset:i,focusNode:s,focusOffset:o}}(this):this.domSelection()}domSelection(){return this.root.getSelection()}}function Ks(e){let t=Object.create(null);return t.class="ProseMirror",t.contenteditable=String(e.editable),t.translate="no",e.someProp("attributes",(n=>{if("function"==typeof n&&(n=n(e.state)),n)for(let e in n)"class"==e&&(t.class+=" "+n[e]),"style"==e?t.style=(t.style?t.style+";":"")+n[e]:t[e]||"contenteditable"==e||"nodeName"==e||(t[e]=String(n[e]))})),[bs.node(0,e.state.doc.content.size,t)]}function qs(e){if(e.markCursor){let t=document.createElement("img");t.className="ProseMirror-separator",t.setAttribute("mark-placeholder","true"),t.setAttribute("alt",""),e.cursorWrapper={dom:t,deco:bs.widget(e.state.selection.head,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function Js(e){return!e.someProp("editable",(t=>!1===t(e.state)))}function Us(e){let t=Object.create(null);function n(e){for(let n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp("nodeViews",n),e.someProp("markViews",n),t}function Gs(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var Ys={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Xs={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Zs="undefined"!=typeof navigator&&/Chrome\/(\d+)/.exec(navigator.userAgent);"undefined"!=typeof navigator&&/Gecko\/\d+/.test(navigator.userAgent);for(var Qs="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),eo="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),to=Qs||Zs&&+Zs[1]<57,no=0;no<10;no++)Ys[48+no]=Ys[96+no]=String(no);for(no=1;no<=24;no++)Ys[no+111]="F"+no;for(no=65;no<=90;no++)Ys[no]=String.fromCharCode(no+32),Xs[no]=String.fromCharCode(no);for(var ro in Ys)Xs.hasOwnProperty(ro)||(Xs[ro]=Ys[ro]);const io="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform);function so(e){let t,n,r,i,s=e.split(/-(?!$)/),o=s[s.length-1];"Space"==o&&(o=" ");for(let e=0;e<s.length-1;e++){let o=s[e];if(/^(cmd|meta|m)$/i.test(o))i=!0;else if(/^a(lt)?$/i.test(o))t=!0;else if(/^(c|ctrl|control)$/i.test(o))n=!0;else if(/^s(hift)?$/i.test(o))r=!0;else{if(!/^mod$/i.test(o))throw new Error("Unrecognized modifier name: "+o);io?i=!0:n=!0}}return t&&(o="Alt-"+o),n&&(o="Ctrl-"+o),i&&(o="Meta-"+o),r&&(o="Shift-"+o),o}function oo(e,t,n){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),!1!==n&&t.shiftKey&&(e="Shift-"+e),e}function ao(e){let t=function(e){let t=Object.create(null);for(let n in e)t[so(n)]=e[n];return t}(e);return function(e,n){let r,i=function(e){var t=!(to&&(e.ctrlKey||e.altKey||e.metaKey)||eo&&e.shiftKey&&e.key&&1==e.key.length||"Unidentified"==e.key)&&e.key||(e.shiftKey?Xs:Ys)[e.keyCode]||e.key||"Unidentified";return"Esc"==t&&(t="Escape"),"Del"==t&&(t="Delete"),"Left"==t&&(t="ArrowLeft"),"Up"==t&&(t="ArrowUp"),"Right"==t&&(t="ArrowRight"),"Down"==t&&(t="ArrowDown"),t}(n),s=1==i.length&&" "!=i,o=t[oo(i,n,!s)];if(o&&o(e.state,e.dispatch,e))return!0;if(s&&(n.shiftKey||n.altKey||n.metaKey||i.charCodeAt(0)>127)&&(r=Ys[n.keyCode])&&r!=i){let i=t[oo(r,n,!0)];if(i&&i(e.state,e.dispatch,e))return!0}else if(s&&n.shiftKey){let r=t[oo(i,n,!0)];if(r&&r(e.state,e.dispatch,e))return!0}return!1}}function lo(e,t,n=!1){for(let r=e;r;r="start"==t?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&1!=r.childCount)return!1}return!1}function co(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function ho(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){let n=e.node(t);if(e.index(t)+1<n.childCount)return e.doc.resolve(e.after(t+1));if(n.type.spec.isolating)break}return null}function uo(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function po(e,t,n){let r,i,s=t.nodeBefore,o=t.nodeAfter;if(s.type.spec.isolating||o.type.spec.isolating)return!1;if(function(e,t,n){let r=t.nodeBefore,i=t.nodeAfter,s=t.index();return!(!(r&&i&&r.type.compatibleContent(i.type))||(!r.content.size&&t.parent.canReplace(s-1,s)?(n&&n(e.tr.delete(t.pos-r.nodeSize,t.pos).scrollIntoView()),0):!t.parent.canReplace(s,s+1)||!i.isTextblock&&!rn(e.doc,t.pos)||(n&&n(e.tr.clearIncompatible(t.pos,r.type,r.contentMatchAt(r.childCount)).join(t.pos).scrollIntoView()),0)))}(e,t,n))return!0;let a=t.parent.canReplace(t.index(),t.index()+1);if(a&&(r=(i=s.contentMatchAt(s.childCount)).findWrapping(o.type))&&i.matchType(r[0]||o.type).validEnd){if(n){let i=t.pos+o.nodeSize,a=$e.empty;for(let e=r.length-1;e>=0;e--)a=$e.from(r[e].create(null,a));a=$e.from(s.copy(a));let l=e.tr.step(new Yt(t.pos-1,i,t.pos,i,new Le(a,1,0),r.length,!0)),c=i+2*r.length;rn(l.doc,c)&&l.join(c),n(l.scrollIntoView())}return!0}let l=bn.findFrom(t,1),c=l&&l.$from.blockRange(l.$to),h=c&&Qt(c);if(null!=h&&h>=t.depth)return n&&n(e.tr.lift(c,h).scrollIntoView()),!0;if(a&&lo(o,"start",!0)&&lo(s,"end")){let r=s,i=[];for(;i.push(r),!r.isTextblock;)r=r.lastChild;let a=o,l=1;for(;!a.isTextblock;a=a.firstChild)l++;if(r.canReplace(r.childCount,r.childCount,a.content)){if(n){let r=$e.empty;for(let e=i.length-1;e>=0;e--)r=$e.from(i[e].copy(r));n(e.tr.step(new Yt(t.pos-i.length,t.pos+o.nodeSize,t.pos+l,t.pos+o.nodeSize-l,new Le(r,i.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function fo(e){return function(t,n){let r=t.selection,i=e<0?r.$from:r.$to,s=i.depth;for(;i.node(s).isInline;){if(!s)return!1;s--}return!!i.node(s).isTextblock&&(n&&n(t.tr.setSelection(Mn.create(t.doc,e<0?i.start(s):i.end(s)))),!0)}}const mo=fo(-1),go=fo(1);function yo(e,t=null){return function(n,r){let{from:i,to:s}=n.selection,o=!1;return n.doc.nodesBetween(i,s,((r,i)=>{if(o)return!1;if(r.isTextblock&&!r.hasMarkup(e,t))if(r.type==e)o=!0;else{let t=n.doc.resolve(i),r=t.index();o=t.parent.canReplaceWith(r,r+1,e)}})),!!o&&(r&&r(n.tr.setBlockType(i,s,e,t).scrollIntoView()),!0)}}function vo(e,t=null){return function(n,r){let{$from:i,$to:s}=n.selection,o=i.blockRange(s),a=!1,l=o;if(!o)return!1;if(o.depth>=2&&i.node(o.depth-1).type.compatibleContent(e)&&0==o.startIndex){if(0==i.index(o.depth-1))return!1;let e=n.doc.resolve(o.start-2);l=new et(e,e,o.depth),o.endIndex<o.parent.childCount&&(o=new et(i,n.doc.resolve(s.end(o.depth)),o.depth)),a=!0}let c=en(l,e,t,o);return!!c&&(r&&r(function(e,t,n,r,i){let s=$e.empty;for(let e=n.length-1;e>=0;e--)s=$e.from(n[e].type.create(n[e].attrs,s));e.step(new Yt(t.start-(r?2:0),t.end,t.start,t.end,new Le(s,0,0),n.length,!0));let o=0;for(let e=0;e<n.length;e++)n[e].type==i&&(o=e+1);let a=n.length-o,l=t.start+n.length-(r?2:0),c=t.parent;for(let n=t.startIndex,r=t.endIndex,i=!0;n<r;n++,i=!1)!i&&nn(e.doc,l,a)&&(e.split(l,a),l+=2*a),l+=c.child(n).nodeSize;return e}(n.tr,o,c,a,e).scrollIntoView()),!0)}}function wo(e){return function(t,n){let{$from:r,$to:i}=t.selection,s=r.blockRange(i,(t=>t.childCount>0&&t.firstChild.type==e));return!!s&&(!n||(r.node(s.depth-1).type==e?function(e,t,n,r){let i=e.tr,s=r.end,o=r.$to.end(r.depth);s<o&&(i.step(new Yt(s-1,o,s,o,new Le($e.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new et(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth));const a=Qt(r);if(null==a)return!1;i.lift(r,a);let l=i.mapping.map(s,-1)-1;rn(i.doc,l)&&i.join(l);return t(i.scrollIntoView()),!0}(t,n,e,s):function(e,t,n){let r=e.tr,i=n.parent;for(let e=n.end,t=n.endIndex-1,s=n.startIndex;t>s;t--)e-=i.child(t).nodeSize,r.delete(e-1,e+1);let s=r.doc.resolve(n.start),o=s.nodeAfter;if(r.mapping.map(n.end)!=n.start+s.nodeAfter.nodeSize)return!1;let a=0==n.startIndex,l=n.endIndex==i.childCount,c=s.node(-1),h=s.index(-1);if(!c.canReplace(h+(a?0:1),h+1,o.content.append(l?$e.empty:$e.from(i))))return!1;let d=s.pos,u=d+o.nodeSize;return r.step(new Yt(d-(a?1:0),u+(l?1:0),d+1,u-1,new Le((a?$e.empty:$e.from(i.copy($e.empty))).append(l?$e.empty:$e.from(i.copy($e.empty))),a?0:1,l?0:1),a?0:1)),t(r.scrollIntoView()),!0}(t,n,s)))}}function bo(e){const{state:t,transaction:n}=e;let{selection:r}=n,{doc:i}=n,{storedMarks:s}=n;return{...t,apply:t.apply.bind(t),applyTransaction:t.applyTransaction.bind(t),filterTransaction:t.filterTransaction,plugins:t.plugins,schema:t.schema,reconfigure:t.reconfigure.bind(t),toJSON:t.toJSON.bind(t),get storedMarks(){return s},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,s=n.storedMarks,n}}}"undefined"!=typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):"undefined"!=typeof os&&os.platform&&os.platform();class xo{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:e,editor:t,state:n}=this,{view:r}=t,{tr:i}=n,s=this.buildProps(i);return Object.fromEntries(Object.entries(e).map((([e,t])=>[e,(...e)=>{const n=t(...e)(s);return i.getMeta("preventDispatch")||this.hasCustomState||r.dispatch(i),n}])))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){const{rawCommands:n,editor:r,state:i}=this,{view:s}=r,o=[],a=!!e,l=e||i.tr,c={...Object.fromEntries(Object.entries(n).map((([e,n])=>[e,(...e)=>{const r=this.buildProps(l,t),i=n(...e)(r);return o.push(i),c}]))),run:()=>(a||!t||l.getMeta("preventDispatch")||this.hasCustomState||s.dispatch(l),o.every((e=>!0===e)))};return c}createCan(e){const{rawCommands:t,state:n}=this,r=e||n.tr,i=this.buildProps(r,false),s=Object.fromEntries(Object.entries(t).map((([e,t])=>[e,(...e)=>t(...e)({...i,dispatch:void 0})])));return{...s,chain:()=>this.createChain(r,false)}}buildProps(e,t=!0){const{rawCommands:n,editor:r,state:i}=this,{view:s}=r;i.storedMarks&&e.setStoredMarks(i.storedMarks);const o={tr:e,editor:r,view:s,state:bo({state:i,transaction:e}),dispatch:t?()=>{}:void 0,chain:()=>this.createChain(e),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(n).map((([e,t])=>[e,(...e)=>t(...e)(o)])))}};return o}}function ko(e,t,n){if(void 0===e.config[t]&&e.parent)return ko(e.parent,t,n);if("function"==typeof e.config[t]){return e.config[t].bind({...n,parent:e.parent?ko(e.parent,t,n):null})}return e.config[t]}function So(e){return{baseExtensions:e.filter((e=>"extension"===e.type)),nodeExtensions:e.filter((e=>"node"===e.type)),markExtensions:e.filter((e=>"mark"===e.type))}}function Mo(e){const t=[],{nodeExtensions:n,markExtensions:r}=So(e),i=[...n,...r],s={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return e.forEach((e=>{const n=ko(e,"addGlobalAttributes",{name:e.name,options:e.options,storage:e.storage});if(!n)return;n().forEach((e=>{e.types.forEach((n=>{Object.entries(e.attributes).forEach((([e,r])=>{t.push({type:n,name:e,attribute:{...s,...r}})}))}))}))})),i.forEach((e=>{const n={name:e.name,options:e.options,storage:e.storage},r=ko(e,"addAttributes",n);if(!r)return;const i=r();Object.entries(i).forEach((([n,r])=>{const i={...s,...r};(null==r?void 0:r.isRequired)&&void 0===(null==r?void 0:r.default)&&delete i.default,t.push({type:e.name,name:n,attribute:i})}))})),t}function Oo(e,t){if("string"==typeof e){if(!t.nodes[e])throw Error(`There is no node type named '${e}'. Maybe you forgot to add the extension?`);return t.nodes[e]}return e}function Co(...e){return e.filter((e=>!!e)).reduce(((e,t)=>{const n={...e};return Object.entries(t).forEach((([e,t])=>{n[e]?n[e]="class"===e?[n[e],t].join(" "):"style"===e?[n[e],t].join("; "):t:n[e]=t})),n}),{})}function Ao(e,t){return t.filter((e=>e.attribute.rendered)).map((t=>t.attribute.renderHTML?t.attribute.renderHTML(e.attrs)||{}:{[t.name]:e.attrs[t.name]})).reduce(((e,t)=>Co(e,t)),{})}function Eo(e){return"function"==typeof e}function To(e,t,...n){return Eo(e)?t?e.bind(t)(...n):e(...n):e}function No(e,t){return e.style?e:{...e,getAttrs:n=>{const r=e.getAttrs?e.getAttrs(n):e.attrs;if(!1===r)return!1;const i=t.reduce(((e,t)=>{const r=t.attribute.parseHTML?t.attribute.parseHTML(n):function(e){return"string"!=typeof e?e:e.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(e):"true"===e||"false"!==e&&e}(n.getAttribute(t.name));return null==r?e:{...e,[t.name]:r}}),{});return{...r,...i}}}}function Do(e){return Object.fromEntries(Object.entries(e).filter((([e,t])=>("attrs"!==e||!function(e={}){return 0===Object.keys(e).length&&e.constructor===Object}(t))&&null!=t)))}function $o(e,t){return t.nodes[e]||t.marks[e]||null}function Io(e,t){return Array.isArray(t)?t.some((t=>("string"==typeof t?t:t.name)===e.name)):t}function Ro(e){return"[object RegExp]"===Object.prototype.toString.call(e)}function Po(e){var t;const{editor:n,from:r,to:i,text:s,rules:o,plugin:a}=e,{view:l}=n;if(l.composing)return!1;const c=l.state.doc.resolve(r);if(c.parent.type.spec.code||(null===(t=c.nodeBefore||c.nodeAfter)||void 0===t?void 0:t.marks.find((e=>e.type.spec.code))))return!1;let h=!1;const d=((e,t=500)=>{let n="";const r=e.parentOffset;return e.parent.nodesBetween(Math.max(0,r-t),r,((e,t,i,s)=>{var o,a;const l=(null===(a=(o=e.type.spec).toText)||void 0===a?void 0:a.call(o,{node:e,pos:t,parent:i,index:s}))||e.textContent||"%leaf%";n+=l.slice(0,Math.max(0,r-t))})),n})(c)+s;return o.forEach((e=>{if(h)return;const t=((e,t)=>{if(Ro(t))return t.exec(e);const n=t(e);if(!n)return null;const r=[];return r.push(n.text),r.index=n.index,r.input=e,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r})(d,e.find);if(!t)return;const o=l.state.tr,c=bo({state:l.state,transaction:o}),u={from:r-(t[0].length-s.length),to:i},{commands:p,chain:f,can:m}=new xo({editor:n,state:c});null!==e.handler({state:c,range:u,match:t,commands:p,chain:f,can:m})&&o.steps.length&&(o.setMeta(a,{transform:o,from:r,to:i,text:s}),l.dispatch(o),h=!0)})),h}function Bo(e){const{editor:t,rules:n}=e,r=new zn({state:{init:()=>null,apply(e,t){const n=e.getMeta(r);return n||(e.selectionSet||e.docChanged?null:t)}},props:{handleTextInput:(e,i,s,o)=>Po({editor:t,from:i,to:s,text:o,rules:n,plugin:r}),handleDOMEvents:{compositionend:e=>(setTimeout((()=>{const{$cursor:i}=e.state.selection;i&&Po({editor:t,from:i.pos,to:i.pos,text:"",rules:n,plugin:r})})),!1)},handleKeyDown(e,i){if("Enter"!==i.key)return!1;const{$cursor:s}=e.state.selection;return!!s&&Po({editor:t,from:s.pos,to:s.pos,text:"\n",rules:n,plugin:r})}},isInputRules:!0});return r}function Fo(e){const{editor:t,state:n,from:r,to:i,rule:s}=e,{commands:o,chain:a,can:l}=new xo({editor:t,state:n}),c=[];n.doc.nodesBetween(r,i,((e,t)=>{if(!e.isTextblock||e.type.spec.code)return;const h=Math.max(r,t),d=Math.min(i,t+e.content.size);((e,t)=>{if(Ro(t))return[...e.matchAll(t)];const n=t(e);return n?n.map((t=>{const n=[];return n.push(t.text),n.index=t.index,n.input=e,n.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),n.push(t.replaceWith)),n})):[]})(e.textBetween(h-t,d-t,void 0,""),s.find).forEach((e=>{if(void 0===e.index)return;const t=h+e.index+1,r=t+e[0].length,i={from:n.tr.mapping.map(t),to:n.tr.mapping.map(r)},d=s.handler({state:n,range:i,match:e,commands:o,chain:a,can:l});c.push(d)}))}));return c.every((e=>null!==e))}function Lo(e){const{editor:t,rules:n}=e;let r=null,i=!1,s=!1;return n.map((e=>new zn({view(e){const t=t=>{var n;r=(null===(n=e.dom.parentElement)||void 0===n?void 0:n.contains(t.target))?e.dom.parentElement:null};return window.addEventListener("dragstart",t),{destroy(){window.removeEventListener("dragstart",t)}}},props:{handleDOMEvents:{drop:e=>(s=r===e.dom.parentElement,!1),paste:(e,t)=>{var n;const r=null===(n=t.clipboardData)||void 0===n?void 0:n.getData("text/html");return i=!!(null==r?void 0:r.includes("data-pm-slice")),!1}}},appendTransaction:(n,r,o)=>{const a=n[0],l="paste"===a.getMeta("uiEvent")&&!i,c="drop"===a.getMeta("uiEvent")&&!s;if(!l&&!c)return;const h=r.doc.content.findDiffStart(o.doc.content),d=r.doc.content.findDiffEnd(o.doc.content);if("number"!=typeof h||!d||h===d.b)return;const u=o.tr,p=bo({state:o,transaction:u});return Fo({editor:t,state:p,from:Math.max(h-1,0),to:d.b-1,rule:e})&&u.steps.length?u:void 0}})))}class zo{constructor(e,t){this.splittableMarks=[],this.editor=t,this.extensions=zo.resolve(e),this.schema=function(e){var t;const n=Mo(e),{nodeExtensions:r,markExtensions:i}=So(e),s=null===(t=r.find((e=>ko(e,"topNode"))))||void 0===t?void 0:t.name,o=Object.fromEntries(r.map((t=>{const r=n.filter((e=>e.type===t.name)),i={name:t.name,options:t.options,storage:t.storage},s=e.reduce(((e,n)=>{const r=ko(n,"extendNodeSchema",i);return{...e,...r?r(t):{}}}),{}),o=Do({...s,content:To(ko(t,"content",i)),marks:To(ko(t,"marks",i)),group:To(ko(t,"group",i)),inline:To(ko(t,"inline",i)),atom:To(ko(t,"atom",i)),selectable:To(ko(t,"selectable",i)),draggable:To(ko(t,"draggable",i)),code:To(ko(t,"code",i)),defining:To(ko(t,"defining",i)),isolating:To(ko(t,"isolating",i)),attrs:Object.fromEntries(r.map((e=>{var t;return[e.name,{default:null===(t=null==e?void 0:e.attribute)||void 0===t?void 0:t.default}]})))}),a=To(ko(t,"parseHTML",i));a&&(o.parseDOM=a.map((e=>No(e,r))));const l=ko(t,"renderHTML",i);l&&(o.toDOM=e=>l({node:e,HTMLAttributes:Ao(e,r)}));const c=ko(t,"renderText",i);return c&&(o.toText=c),[t.name,o]}))),a=Object.fromEntries(i.map((t=>{const r=n.filter((e=>e.type===t.name)),i={name:t.name,options:t.options,storage:t.storage},s=e.reduce(((e,n)=>{const r=ko(n,"extendMarkSchema",i);return{...e,...r?r(t):{}}}),{}),o=Do({...s,inclusive:To(ko(t,"inclusive",i)),excludes:To(ko(t,"excludes",i)),group:To(ko(t,"group",i)),spanning:To(ko(t,"spanning",i)),code:To(ko(t,"code",i)),attrs:Object.fromEntries(r.map((e=>{var t;return[e.name,{default:null===(t=null==e?void 0:e.attribute)||void 0===t?void 0:t.default}]})))}),a=To(ko(t,"parseHTML",i));a&&(o.parseDOM=a.map((e=>No(e,r))));const l=ko(t,"renderHTML",i);return l&&(o.toDOM=e=>l({mark:e,HTMLAttributes:Ao(e,r)})),[t.name,o]})));return new bt({topNode:s,nodes:o,marks:a})}(this.extensions),this.extensions.forEach((e=>{var t;this.editor.extensionStorage[e.name]=e.storage;const n={name:e.name,options:e.options,storage:e.storage,editor:this.editor,type:$o(e.name,this.schema)};if("mark"===e.type){(null===(t=To(ko(e,"keepOnSplit",n)))||void 0===t||t)&&this.splittableMarks.push(e.name)}const r=ko(e,"onBeforeCreate",n);r&&this.editor.on("beforeCreate",r);const i=ko(e,"onCreate",n);i&&this.editor.on("create",i);const s=ko(e,"onUpdate",n);s&&this.editor.on("update",s);const o=ko(e,"onSelectionUpdate",n);o&&this.editor.on("selectionUpdate",o);const a=ko(e,"onTransaction",n);a&&this.editor.on("transaction",a);const l=ko(e,"onFocus",n);l&&this.editor.on("focus",l);const c=ko(e,"onBlur",n);c&&this.editor.on("blur",c);const h=ko(e,"onDestroy",n);h&&this.editor.on("destroy",h)}))}static resolve(e){const t=zo.sort(zo.flatten(e)),n=function(e){const t=e.filter(((t,n)=>e.indexOf(t)!==n));return[...new Set(t)]}(t.map((e=>e.name)));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map((e=>`'${e}'`)).join(", ")}]. This can lead to issues.`),t}static flatten(e){return e.map((e=>{const t=ko(e,"addExtensions",{name:e.name,options:e.options,storage:e.storage});return t?[e,...this.flatten(t())]:e})).flat(10)}static sort(e){return e.sort(((e,t)=>{const n=ko(e,"priority")||100,r=ko(t,"priority")||100;return n>r?-1:n<r?1:0}))}get commands(){return this.extensions.reduce(((e,t)=>{const n=ko(t,"addCommands",{name:t.name,options:t.options,storage:t.storage,editor:this.editor,type:$o(t.name,this.schema)});return n?{...e,...n()}:e}),{})}get plugins(){const{editor:e}=this,t=zo.sort([...this.extensions].reverse()),n=[],r=[],i=t.map((t=>{const i={name:t.name,options:t.options,storage:t.storage,editor:e,type:$o(t.name,this.schema)},s=[],o=ko(t,"addKeyboardShortcuts",i);let a={};if("mark"===t.type&&t.config.exitable&&(a.ArrowRight=()=>Oa.handleExit({editor:e,mark:t})),o){const t=Object.fromEntries(Object.entries(o()).map((([t,n])=>[t,()=>n({editor:e})])));a={...a,...t}}const l=new zn({props:{handleKeyDown:ao(a)}});s.push(l);const c=ko(t,"addInputRules",i);Io(t,e.options.enableInputRules)&&c&&n.push(...c());const h=ko(t,"addPasteRules",i);Io(t,e.options.enablePasteRules)&&h&&r.push(...h());const d=ko(t,"addProseMirrorPlugins",i);if(d){const e=d();s.push(...e)}return s})).flat();return[Bo({editor:e,rules:n}),...Lo({editor:e,rules:r}),...i]}get attributes(){return Mo(this.extensions)}get nodeViews(){const{editor:e}=this,{nodeExtensions:t}=So(this.extensions);return Object.fromEntries(t.filter((e=>!!ko(e,"addNodeView"))).map((t=>{const n=this.attributes.filter((e=>e.type===t.name)),r={name:t.name,options:t.options,storage:t.storage,editor:e,type:Oo(t.name,this.schema)},i=ko(t,"addNodeView",r);if(!i)return[];return[t.name,(r,s,o,a)=>{const l=Ao(r,n);return i()({editor:e,node:r,getPos:o,decorations:a,HTMLAttributes:l,extension:t})}]})))}}function Vo(e){return"Object"===function(e){return Object.prototype.toString.call(e).slice(8,-1)}(e)&&(e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype)}function jo(e,t){const n={...e};return Vo(e)&&Vo(t)&&Object.keys(t).forEach((r=>{Vo(t[r])?r in e?n[r]=jo(e[r],t[r]):Object.assign(n,{[r]:t[r]}):Object.assign(n,{[r]:t[r]})})),n}class _o{constructor(e={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=To(ko(this,"addOptions",{name:this.name}))),this.storage=To(ko(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new _o(e)}configure(e={}){const t=this.extend();return t.options=jo(this.options,e),t.storage=To(ko(t,"addStorage",{name:t.name,options:t.options})),t}extend(e={}){const t=new _o(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=To(ko(t,"addOptions",{name:t.name})),t.storage=To(ko(t,"addStorage",{name:t.name,options:t.options})),t}}function Wo(e,t,n){const{from:r,to:i}=t,{blockSeparator:s="\n\n",textSerializers:o={}}=n||{};let a="",l=!0;return e.nodesBetween(r,i,((e,n,c,h)=>{var d;const u=null==o?void 0:o[e.type.name];u?(e.isBlock&&!l&&(a+=s,l=!0),c&&(a+=u({node:e,pos:n,parent:c,index:h,range:t}))):e.isText?(a+=null===(d=null==e?void 0:e.text)||void 0===d?void 0:d.slice(Math.max(r,n)-n,i-n),l=!1):e.isBlock&&!l&&(a+=s,l=!0)})),a}function Ho(e){return Object.fromEntries(Object.entries(e.nodes).filter((([,e])=>e.spec.toText)).map((([e,t])=>[e,t.spec.toText])))}const Ko=_o.create({name:"clipboardTextSerializer",addProseMirrorPlugins(){return[new zn({key:new _n("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:e}=this,{state:t,schema:n}=e,{doc:r,selection:i}=t,{ranges:s}=i,o=Math.min(...s.map((e=>e.$from.pos))),a=Math.max(...s.map((e=>e.$to.pos)));return Wo(r,{from:o,to:a},{textSerializers:Ho(n)})}}})]}});function qo(e,t,n={strict:!0}){const r=Object.keys(t);return!r.length||r.every((r=>n.strict?t[r]===e[r]:Ro(t[r])?t[r].test(e[r]):t[r]===e[r]))}function Jo(e,t,n={}){return e.find((e=>e.type===t&&qo(e.attrs,n)))}function Uo(e,t,n={}){return!!Jo(e,t,n)}function Go(e,t,n={}){if(!e||!t)return;let r=e.parent.childAfter(e.parentOffset);if(e.parentOffset===r.offset&&0!==r.offset&&(r=e.parent.childBefore(e.parentOffset)),!r.node)return;const i=Jo([...r.node.marks],t,n);if(!i)return;let s=r.index,o=e.start()+r.offset,a=s+1,l=o+r.node.nodeSize;for(Jo([...r.node.marks],t,n);s>0&&i.isInSet(e.parent.child(s-1).marks);)s-=1,o-=e.parent.child(s).nodeSize;for(;a<e.parent.childCount&&Uo([...e.parent.child(a).marks],t,n);)l+=e.parent.child(a).nodeSize,a+=1;return{from:o,to:l}}function Yo(e,t){if("string"==typeof e){if(!t.marks[e])throw Error(`There is no mark type named '${e}'. Maybe you forgot to add the extension?`);return t.marks[e]}return e}function Xo(e){return e instanceof Mn}function Zo(e=0,t=0,n=0){return Math.min(Math.max(e,t),n)}function Qo(e,t=null){if(!t)return null;const n=bn.atStart(e),r=bn.atEnd(e);if("start"===t||!0===t)return n;if("end"===t)return r;const i=n.from,s=r.to;return"all"===t?Mn.create(e,Zo(0,i,s),Zo(e.content.size,i,s)):Mn.create(e,Zo(t,i,s),Zo(t,i,s))}function ea(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function ta(e){const t=`<body>${e}</body>`;return(new window.DOMParser).parseFromString(t,"text/html").body}function na(e,t,n){if(n={slice:!0,parseOptions:{},...n},"object"==typeof e&&null!==e)try{return Array.isArray(e)?$e.fromArray(e.map((e=>t.nodeFromJSON(e)))):t.nodeFromJSON(e)}catch(r){return console.warn("[tiptap warn]: Invalid content.","Passed value:",e,"Error:",r),na("",t,n)}if("string"==typeof e){const r=kt.fromSchema(t);return n.slice?r.parseSlice(ta(e),n.parseOptions).content:r.parse(ta(e),n.parseOptions)}return na("",t,n)}function ra(){return"undefined"!=typeof navigator&&/Mac/.test(navigator.platform)}function ia(e,t,n={}){const{from:r,to:i,empty:s}=e.selection,o=t?Oo(t,e.schema):null,a=[];e.doc.nodesBetween(r,i,((e,t)=>{if(e.isText)return;const n=Math.max(r,t),s=Math.min(i,t+e.nodeSize);a.push({node:e,from:n,to:s})}));const l=i-r,c=a.filter((e=>!o||o.name===e.node.type.name)).filter((e=>qo(e.node.attrs,n,{strict:!1})));if(s)return!!c.length;return c.reduce(((e,t)=>e+t.to-t.from),0)>=l}function sa(e,t){return t.nodes[e]?"node":t.marks[e]?"mark":null}function oa(e,t){const n="string"==typeof t?[t]:t;return Object.keys(e).reduce(((t,r)=>(n.includes(r)||(t[r]=e[r]),t)),{})}function aa(e,t,n={}){return na(e,t,{slice:!1,parseOptions:n})}function la(e){return t=>function(e,t){for(let n=e.depth;n>0;n-=1){const r=e.node(n);if(t(r))return{pos:n>0?e.before(n):0,start:e.start(n),depth:n,node:r}}}(t.$from,e)}function ca(e,t){const n=Yo(t,e.schema),{from:r,to:i,empty:s}=e.selection,o=[];s?(e.storedMarks&&o.push(...e.storedMarks),o.push(...e.selection.$head.marks())):e.doc.nodesBetween(r,i,(e=>{o.push(...e.marks)}));const a=o.find((e=>e.type.name===n.name));return a?{...a.attrs}:{}}function ha(e,t){const n=sa("string"==typeof t?t:t.name,e.schema);return"node"===n?function(e,t){const n=Oo(t,e.schema),{from:r,to:i}=e.selection,s=[];e.doc.nodesBetween(r,i,(e=>{s.push(e)}));const o=s.reverse().find((e=>e.type.name===n.name));return o?{...o.attrs}:{}}(e,t):"mark"===n?ca(e,t):{}}function da(e,t,n={}){const{empty:r,ranges:i}=e.selection,s=t?Yo(t,e.schema):null;if(r)return!!(e.storedMarks||e.selection.$from.marks()).filter((e=>!s||s.name===e.type.name)).find((e=>qo(e.attrs,n,{strict:!1})));let o=0;const a=[];if(i.forEach((({$from:t,$to:n})=>{const r=t.pos,i=n.pos;e.doc.nodesBetween(r,i,((e,t)=>{if(!e.isText&&!e.marks.length)return;const n=Math.max(r,t),s=Math.min(i,t+e.nodeSize);o+=s-n,a.push(...e.marks.map((e=>({mark:e,from:n,to:s}))))}))})),0===o)return!1;const l=a.filter((e=>!s||s.name===e.mark.type.name)).filter((e=>qo(e.mark.attrs,n,{strict:!1}))).reduce(((e,t)=>e+t.to-t.from),0),c=a.filter((e=>!s||e.mark.type!==s&&e.mark.type.excludes(s))).reduce(((e,t)=>e+t.to-t.from),0);return(l>0?l+c:l)>=o}function ua(e,t){const{nodeExtensions:n}=So(t),r=n.find((t=>t.name===e));if(!r)return!1;const i=To(ko(r,"group",{name:r.name,options:r.options,storage:r.storage}));return"string"==typeof i&&i.split(" ").includes("list")}function pa(e,t,n){return Object.fromEntries(Object.entries(n).filter((([n])=>{const r=e.find((e=>e.type===t&&e.name===n));return!!r&&r.attribute.keepOnSplit})))}function fa(e,t){const n=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();if(n){const r=n.filter((e=>null==t?void 0:t.includes(e.type.name)));e.tr.ensureMarks(r)}}const ma=(e,t)=>{const n=la((e=>e.type===t))(e.selection);if(!n)return!0;const r=e.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(void 0===r)return!0;const i=e.doc.nodeAt(r);return n.node.type!==(null==i?void 0:i.type)||!rn(e.doc,n.pos)||(e.join(n.pos),!0)},ga=(e,t)=>{const n=la((e=>e.type===t))(e.selection);if(!n)return!0;const r=e.doc.resolve(n.start).after(n.depth);if(void 0===r)return!0;const i=e.doc.nodeAt(r);return n.node.type!==(null==i?void 0:i.type)||!rn(e.doc,r)||(e.join(r),!0)};var ya=Object.freeze({__proto__:null,blur:()=>({editor:e,view:t})=>(requestAnimationFrame((()=>{var n;e.isDestroyed||(t.dom.blur(),null===(n=null===window||void 0===window?void 0:window.getSelection())||void 0===n||n.removeAllRanges())})),!0),clearContent:(e=!1)=>({commands:t})=>t.setContent("",e),clearNodes:()=>({state:e,tr:t,dispatch:n})=>{const{selection:r}=t,{ranges:i}=r;return!n||(i.forEach((({$from:n,$to:r})=>{e.doc.nodesBetween(n.pos,r.pos,((e,n)=>{if(e.type.isText)return;const{doc:r,mapping:i}=t,s=r.resolve(i.map(n)),o=r.resolve(i.map(n+e.nodeSize)),a=s.blockRange(o);if(!a)return;const l=Qt(a);if(e.type.isTextblock){const{defaultType:e}=s.parent.contentMatchAt(s.index());t.setNodeMarkup(a.start,e)}(l||0===l)&&t.lift(a,l)}))})),!0)},command:e=>t=>e(t),createParagraphNear:()=>({state:e,dispatch:t})=>((e,t)=>{let n=e.selection,{$from:r,$to:i}=n;if(n instanceof En||r.parent.inlineContent||i.parent.inlineContent)return!1;let s=uo(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return!1;if(t){let n=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,o=e.tr.insert(n,s.createAndFill());o.setSelection(Mn.create(o.doc,n+1)),t(o.scrollIntoView())}return!0})(e,t),deleteNode:e=>({tr:t,state:n,dispatch:r})=>{const i=Oo(e,n.schema),s=t.selection.$anchor;for(let e=s.depth;e>0;e-=1){if(s.node(e).type===i){if(r){const n=s.before(e),r=s.after(e);t.delete(n,r).scrollIntoView()}return!0}}return!1},deleteRange:e=>({tr:t,dispatch:n})=>{const{from:r,to:i}=e;return n&&t.delete(r,i),!0},deleteSelection:()=>({state:e,dispatch:t})=>((e,t)=>!e.selection.empty&&(t&&t(e.tr.deleteSelection().scrollIntoView()),!0))(e,t),enter:()=>({commands:e})=>e.keyboardShortcut("Enter"),exitCode:()=>({state:e,dispatch:t})=>((e,t)=>{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),s=n.indexAfter(-1),o=uo(i.contentMatchAt(s));if(!o||!i.canReplaceWith(s,s,o))return!1;if(t){let r=n.after(),i=e.tr.replaceWith(r,r,o.createAndFill());i.setSelection(bn.near(i.doc.resolve(r),1)),t(i.scrollIntoView())}return!0})(e,t),extendMarkRange:(e,t={})=>({tr:n,state:r,dispatch:i})=>{const s=Yo(e,r.schema),{doc:o,selection:a}=n,{$from:l,from:c,to:h}=a;if(i){const e=Go(l,s,t);if(e&&e.from<=c&&e.to>=h){const t=Mn.create(o,e.from,e.to);n.setSelection(t)}}return!0},first:e=>t=>{const n="function"==typeof e?e(t):e;for(let e=0;e<n.length;e+=1)if(n[e](t))return!0;return!1},focus:(e=null,t={})=>({editor:n,view:r,tr:i,dispatch:s})=>{t={scrollIntoView:!0,...t};const o=()=>{ea()&&r.dom.focus(),requestAnimationFrame((()=>{n.isDestroyed||(r.focus(),(null==t?void 0:t.scrollIntoView)&&n.commands.scrollIntoView())}))};if(r.hasFocus()&&null===e||!1===e)return!0;if(s&&null===e&&!Xo(n.state.selection))return o(),!0;const a=Qo(i.doc,e)||n.state.selection,l=n.state.selection.eq(a);return s&&(l||i.setSelection(a),l&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},forEach:(e,t)=>n=>e.every(((e,r)=>t(e,{...n,index:r}))),insertContent:(e,t)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},e,t),insertContentAt:(e,t,n)=>({tr:r,dispatch:i,editor:s})=>{if(i){n={parseOptions:{},updateSelection:!0,...n};const i=na(t,s.schema,{parseOptions:{preserveWhitespace:"full",...n.parseOptions}});if("<>"===i.toString())return!0;let{from:o,to:a}="number"==typeof e?{from:e,to:e}:e,l=!0,c=!0;if((i.toString().startsWith("<")?i:[i]).forEach((e=>{e.check(),l=!!l&&(e.isText&&0===e.marks.length),c=!!c&&e.isBlock})),o===a&&c){const{parent:e}=r.doc.resolve(o);e.isTextblock&&!e.type.spec.code&&!e.childCount&&(o-=1,a+=1)}l?r.insertText(t,o,a):r.replaceWith(o,a,i),n.updateSelection&&function(e,t,n){const r=e.steps.length-1;if(r<t)return;const i=e.steps[r];if(!(i instanceof Gt||i instanceof Yt))return;const s=e.mapping.maps[r];let o=0;s.forEach(((e,t,n,r)=>{0===o&&(o=r)})),e.setSelection(bn.near(e.doc.resolve(o),n))}(r,r.steps.length-1,-1)}return!0},joinBackward:()=>({state:e,dispatch:t})=>((e,t,n)=>{let{$cursor:r}=e.selection;if(!r||(n?!n.endOfTextblock("backward",e):r.parentOffset>0))return!1;let i=co(r);if(!i){let n=r.blockRange(),i=n&&Qt(n);return null!=i&&(t&&t(e.tr.lift(n,i).scrollIntoView()),!0)}let s=i.nodeBefore;if(!s.type.spec.isolating&&po(e,i,t))return!0;if(0==r.parent.content.size&&(lo(s,"end")||Cn.isSelectable(s))){let n=on(e.doc,r.before(),r.after(),Le.empty);if(n&&n.slice.size<n.to-n.from){if(t){let r=e.tr.step(n);r.setSelection(lo(s,"end")?bn.findFrom(r.doc.resolve(r.mapping.map(i.pos,-1)),-1):Cn.create(r.doc,i.pos-s.nodeSize)),t(r.scrollIntoView())}return!0}}return!(!s.isAtom||i.depth!=r.depth-1||(t&&t(e.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView()),0))})(e,t),joinForward:()=>({state:e,dispatch:t})=>((e,t,n)=>{let{$cursor:r}=e.selection;if(!r||(n?!n.endOfTextblock("forward",e):r.parentOffset<r.parent.content.size))return!1;let i=ho(r);if(!i)return!1;let s=i.nodeAfter;if(po(e,i,t))return!0;if(0==r.parent.content.size&&(lo(s,"start")||Cn.isSelectable(s))){let n=on(e.doc,r.before(),r.after(),Le.empty);if(n&&n.slice.size<n.to-n.from){if(t){let r=e.tr.step(n);r.setSelection(lo(s,"start")?bn.findFrom(r.doc.resolve(r.mapping.map(i.pos)),1):Cn.create(r.doc,r.mapping.map(i.pos))),t(r.scrollIntoView())}return!0}}return!(!s.isAtom||i.depth!=r.depth-1||(t&&t(e.tr.delete(i.pos,i.pos+s.nodeSize).scrollIntoView()),0))})(e,t),keyboardShortcut:e=>({editor:t,view:n,tr:r,dispatch:i})=>{const s=function(e){const t=e.split(/-(?!$)/);let n,r,i,s,o=t[t.length-1];"Space"===o&&(o=" ");for(let e=0;e<t.length-1;e+=1){const o=t[e];if(/^(cmd|meta|m)$/i.test(o))s=!0;else if(/^a(lt)?$/i.test(o))n=!0;else if(/^(c|ctrl|control)$/i.test(o))r=!0;else if(/^s(hift)?$/i.test(o))i=!0;else{if(!/^mod$/i.test(o))throw new Error(`Unrecognized modifier name: ${o}`);ea()||ra()?s=!0:r=!0}}return n&&(o=`Alt-${o}`),r&&(o=`Ctrl-${o}`),s&&(o=`Meta-${o}`),i&&(o=`Shift-${o}`),o}(e).split(/-(?!$)/),o=s.find((e=>!["Alt","Ctrl","Meta","Shift"].includes(e))),a=new KeyboardEvent("keydown",{key:"Space"===o?" ":o,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.includes("Shift"),bubbles:!0,cancelable:!0}),l=t.captureTransaction((()=>{n.someProp("handleKeyDown",(e=>e(n,a)))}));return null==l||l.steps.forEach((e=>{const t=e.map(r.mapping);t&&i&&r.maybeStep(t)})),!0},lift:(e,t={})=>({state:n,dispatch:r})=>!!ia(n,Oo(e,n.schema),t)&&((e,t)=>{let{$from:n,$to:r}=e.selection,i=n.blockRange(r),s=i&&Qt(i);return null!=s&&(t&&t(e.tr.lift(i,s).scrollIntoView()),!0)})(n,r),liftEmptyBlock:()=>({state:e,dispatch:t})=>((e,t)=>{let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let r=n.before();if(nn(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),i=r&&Qt(r);return null!=i&&(t&&t(e.tr.lift(r,i).scrollIntoView()),!0)})(e,t),liftListItem:e=>({state:t,dispatch:n})=>wo(Oo(e,t.schema))(t,n),newlineInCode:()=>({state:e,dispatch:t})=>((e,t)=>{let{$head:n,$anchor:r}=e.selection;return!(!n.parent.type.spec.code||!n.sameParent(r)||(t&&t(e.tr.insertText("\n").scrollIntoView()),0))})(e,t),resetAttributes:(e,t)=>({tr:n,state:r,dispatch:i})=>{let s=null,o=null;const a=sa("string"==typeof e?e:e.name,r.schema);return!!a&&("node"===a&&(s=Oo(e,r.schema)),"mark"===a&&(o=Yo(e,r.schema)),i&&n.selection.ranges.forEach((e=>{r.doc.nodesBetween(e.$from.pos,e.$to.pos,((e,r)=>{s&&s===e.type&&n.setNodeMarkup(r,void 0,oa(e.attrs,t)),o&&e.marks.length&&e.marks.forEach((i=>{o===i.type&&n.addMark(r,r+e.nodeSize,o.create(oa(i.attrs,t)))}))}))})),!0)},scrollIntoView:()=>({tr:e,dispatch:t})=>(t&&e.scrollIntoView(),!0),selectAll:()=>({tr:e,commands:t})=>t.setTextSelection({from:0,to:e.doc.content.size}),selectNodeBackward:()=>({state:e,dispatch:t})=>((e,t,n)=>{let{$head:r,empty:i}=e.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",e):r.parentOffset>0)return!1;s=co(r)}let o=s&&s.nodeBefore;return!(!o||!Cn.isSelectable(o)||(t&&t(e.tr.setSelection(Cn.create(e.doc,s.pos-o.nodeSize)).scrollIntoView()),0))})(e,t),selectNodeForward:()=>({state:e,dispatch:t})=>((e,t,n)=>{let{$head:r,empty:i}=e.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",e):r.parentOffset<r.parent.content.size)return!1;s=ho(r)}let o=s&&s.nodeAfter;return!(!o||!Cn.isSelectable(o)||(t&&t(e.tr.setSelection(Cn.create(e.doc,s.pos)).scrollIntoView()),0))})(e,t),selectParentNode:()=>({state:e,dispatch:t})=>((e,t)=>{let n,{$from:r,to:i}=e.selection,s=r.sharedDepth(i);return 0!=s&&(n=r.before(s),t&&t(e.tr.setSelection(Cn.create(e.doc,n))),!0)})(e,t),selectTextblockEnd:()=>({state:e,dispatch:t})=>go(e,t),selectTextblockStart:()=>({state:e,dispatch:t})=>mo(e,t),setContent:(e,t=!1,n={})=>({tr:r,editor:i,dispatch:s})=>{const{doc:o}=r,a=aa(e,i.schema,n);return s&&r.replaceWith(0,o.content.size,a).setMeta("preventUpdate",!t),!0},setMark:(e,t={})=>({tr:n,state:r,dispatch:i})=>{const{selection:s}=n,{empty:o,ranges:a}=s,l=Yo(e,r.schema);if(i)if(o){const e=ca(r,l);n.addStoredMark(l.create({...e,...t}))}else a.forEach((e=>{const i=e.$from.pos,s=e.$to.pos;r.doc.nodesBetween(i,s,((e,r)=>{const o=Math.max(r,i),a=Math.min(r+e.nodeSize,s);e.marks.find((e=>e.type===l))?e.marks.forEach((e=>{l===e.type&&n.addMark(o,a,l.create({...e.attrs,...t}))})):n.addMark(o,a,l.create(t))}))}));return function(e,t,n){var r;const{selection:i}=t;let s=null;if(Xo(i)&&(s=i.$cursor),s){const t=null!==(r=e.storedMarks)&&void 0!==r?r:s.marks();return!!n.isInSet(t)||!t.some((e=>e.type.excludes(n)))}const{ranges:o}=i;return o.some((({$from:t,$to:r})=>{let i=0===t.depth&&e.doc.inlineContent&&e.doc.type.allowsMarkType(n);return e.doc.nodesBetween(t.pos,r.pos,((e,t,r)=>{if(i)return!1;if(e.isInline){const t=!r||r.type.allowsMarkType(n),s=!!n.isInSet(e.marks)||!e.marks.some((e=>e.type.excludes(n)));i=t&&s}return!i})),i}))}(r,n,l)},setMeta:(e,t)=>({tr:n})=>(n.setMeta(e,t),!0),setNode:(e,t={})=>({state:n,dispatch:r,chain:i})=>{const s=Oo(e,n.schema);return s.isTextblock?i().command((({commands:e})=>!!yo(s,t)(n)||e.clearNodes())).command((({state:e})=>yo(s,t)(e,r))).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},setNodeSelection:e=>({tr:t,dispatch:n})=>{if(n){const{doc:n}=t,r=Zo(e,0,n.content.size),i=Cn.create(n,r);t.setSelection(i)}return!0},setTextSelection:e=>({tr:t,dispatch:n})=>{if(n){const{doc:n}=t,{from:r,to:i}="number"==typeof e?{from:e,to:e}:e,s=Mn.atStart(n).from,o=Mn.atEnd(n).to,a=Zo(r,s,o),l=Zo(i,s,o),c=Mn.create(n,a,l);t.setSelection(c)}return!0},sinkListItem:e=>({state:t,dispatch:n})=>{const r=Oo(e,t.schema);return(i=r,function(e,t){let{$from:n,$to:r}=e.selection,s=n.blockRange(r,(e=>e.childCount>0&&e.firstChild.type==i));if(!s)return!1;let o=s.startIndex;if(0==o)return!1;let a=s.parent,l=a.child(o-1);if(l.type!=i)return!1;if(t){let n=l.lastChild&&l.lastChild.type==a.type,r=$e.from(n?i.create():null),o=new Le($e.from(i.create(null,$e.from(a.type.create(null,r)))),n?3:1,0),c=s.start,h=s.end;t(e.tr.step(new Yt(c-(n?3:1),h,c,h,o,1,!0)).scrollIntoView())}return!0})(t,n);var i},splitBlock:({keepMarks:e=!0}={})=>({tr:t,state:n,dispatch:r,editor:i})=>{const{selection:s,doc:o}=t,{$from:a,$to:l}=s,c=pa(i.extensionManager.attributes,a.node().type.name,a.node().attrs);if(s instanceof Cn&&s.node.isBlock)return!(!a.parentOffset||!nn(o,a.pos))&&(r&&(e&&fa(n,i.extensionManager.splittableMarks),t.split(a.pos).scrollIntoView()),!0);if(!a.parent.isBlock)return!1;if(r){const r=l.parentOffset===l.parent.content.size;s instanceof Mn&&t.deleteSelection();const o=0===a.depth?void 0:function(e){for(let t=0;t<e.edgeCount;t+=1){const{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}(a.node(-1).contentMatchAt(a.indexAfter(-1)));let h=r&&o?[{type:o,attrs:c}]:void 0,d=nn(t.doc,t.mapping.map(a.pos),1,h);if(h||d||!nn(t.doc,t.mapping.map(a.pos),1,o?[{type:o}]:void 0)||(d=!0,h=o?[{type:o,attrs:c}]:void 0),d&&(t.split(t.mapping.map(a.pos),1,h),o&&!r&&!a.parentOffset&&a.parent.type!==o)){const e=t.mapping.map(a.before()),n=t.doc.resolve(e);a.node(-1).canReplaceWith(n.index(),n.index()+1,o)&&t.setNodeMarkup(t.mapping.map(a.before()),o)}e&&fa(n,i.extensionManager.splittableMarks),t.scrollIntoView()}return!0},splitListItem:e=>({tr:t,state:n,dispatch:r,editor:i})=>{var s;const o=Oo(e,n.schema),{$from:a,$to:l}=n.selection,c=n.selection.node;if(c&&c.isBlock||a.depth<2||!a.sameParent(l))return!1;const h=a.node(-1);if(h.type!==o)return!1;const d=i.extensionManager.attributes;if(0===a.parent.content.size&&a.node(-1).childCount===a.indexAfter(-1)){if(2===a.depth||a.node(-3).type!==o||a.index(-2)!==a.node(-2).childCount-1)return!1;if(r){let e=$e.empty;const n=a.index(-1)?1:a.index(-2)?2:3;for(let t=a.depth-n;t>=a.depth-3;t-=1)e=$e.from(a.node(t).copy(e));const r=a.indexAfter(-1)<a.node(-2).childCount?1:a.indexAfter(-2)<a.node(-3).childCount?2:3,i=pa(d,a.node().type.name,a.node().attrs),l=(null===(s=o.contentMatch.defaultType)||void 0===s?void 0:s.createAndFill(i))||void 0;e=e.append($e.from(o.createAndFill(null,l)||void 0));const c=a.before(a.depth-(n-1));t.replace(c,a.after(-r),new Le(e,4-n,0));let h=-1;t.doc.nodesBetween(c,t.doc.content.size,((e,t)=>{if(h>-1)return!1;e.isTextblock&&0===e.content.size&&(h=t+1)})),h>-1&&t.setSelection(Mn.near(t.doc.resolve(h))),t.scrollIntoView()}return!0}const u=l.pos===a.end()?h.contentMatchAt(0).defaultType:null,p=pa(d,h.type.name,h.attrs),f=pa(d,a.node().type.name,a.node().attrs);t.delete(a.pos,l.pos);const m=u?[{type:o,attrs:p},{type:u,attrs:f}]:[{type:o,attrs:p}];return!!nn(t.doc,a.pos,2)&&(r&&t.split(a.pos,2,m).scrollIntoView(),!0)},toggleList:(e,t)=>({editor:n,tr:r,state:i,dispatch:s,chain:o,commands:a,can:l})=>{const{extensions:c}=n.extensionManager,h=Oo(e,i.schema),d=Oo(t,i.schema),{selection:u}=i,{$from:p,$to:f}=u,m=p.blockRange(f);if(!m)return!1;const g=la((e=>ua(e.type.name,c)))(u);if(m.depth>=1&&g&&m.depth-g.depth<=1){if(g.node.type===h)return a.liftListItem(d);if(ua(g.node.type.name,c)&&h.validContent(g.node.content)&&s)return o().command((()=>(r.setNodeMarkup(g.pos,h),!0))).command((()=>ma(r,h))).command((()=>ga(r,h))).run()}return o().command((()=>!!l().wrapInList(h)||a.clearNodes())).wrapInList(h).command((()=>ma(r,h))).command((()=>ga(r,h))).run()},toggleMark:(e,t={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:s=!1}=n,o=Yo(e,r.schema);return da(r,o,t)?i.unsetMark(o,{extendEmptyMarkRange:s}):i.setMark(o,t)},toggleNode:(e,t,n={})=>({state:r,commands:i})=>{const s=Oo(e,r.schema),o=Oo(t,r.schema);return ia(r,s,n)?i.setNode(o):i.setNode(s,n)},toggleWrap:(e,t={})=>({state:n,commands:r})=>{const i=Oo(e,n.schema);return ia(n,i,t)?r.lift(i):r.wrapIn(i,t)},undoInputRule:()=>({state:e,dispatch:t})=>{const n=e.plugins;for(let r=0;r<n.length;r+=1){const i=n[r];let s;if(i.spec.isInputRules&&(s=i.getState(e))){if(t){const t=e.tr,n=s.transform;for(let e=n.steps.length-1;e>=0;e-=1)t.step(n.steps[e].invert(n.docs[e]));if(s.text){const n=t.doc.resolve(s.from).marks();t.replaceWith(s.from,s.to,e.schema.text(s.text,n))}else t.delete(s.from,s.to)}return!0}}return!1},unsetAllMarks:()=>({tr:e,dispatch:t})=>{const{selection:n}=e,{empty:r,ranges:i}=n;return r||t&&i.forEach((t=>{e.removeMark(t.$from.pos,t.$to.pos)})),!0},unsetMark:(e,t={})=>({tr:n,state:r,dispatch:i})=>{var s;const{extendEmptyMarkRange:o=!1}=t,{selection:a}=n,l=Yo(e,r.schema),{$from:c,empty:h,ranges:d}=a;if(!i)return!0;if(h&&o){let{from:e,to:t}=a;const r=null===(s=c.marks().find((e=>e.type===l)))||void 0===s?void 0:s.attrs,i=Go(c,l,r);i&&(e=i.from,t=i.to),n.removeMark(e,t,l)}else d.forEach((e=>{n.removeMark(e.$from.pos,e.$to.pos,l)}));return n.removeStoredMark(l),!0},updateAttributes:(e,t={})=>({tr:n,state:r,dispatch:i})=>{let s=null,o=null;const a=sa("string"==typeof e?e:e.name,r.schema);return!!a&&("node"===a&&(s=Oo(e,r.schema)),"mark"===a&&(o=Yo(e,r.schema)),i&&n.selection.ranges.forEach((e=>{const i=e.$from.pos,a=e.$to.pos;r.doc.nodesBetween(i,a,((e,r)=>{s&&s===e.type&&n.setNodeMarkup(r,void 0,{...e.attrs,...t}),o&&e.marks.length&&e.marks.forEach((s=>{if(o===s.type){const l=Math.max(r,i),c=Math.min(r+e.nodeSize,a);n.addMark(l,c,o.create({...s.attrs,...t}))}}))}))})),!0)},wrapIn:(e,t={})=>({state:n,dispatch:r})=>function(e,t=null){return function(n,r){let{$from:i,$to:s}=n.selection,o=i.blockRange(s),a=o&&en(o,e,t);return!!a&&(r&&r(n.tr.wrap(o,a).scrollIntoView()),!0)}}(Oo(e,n.schema),t)(n,r),wrapInList:(e,t={})=>({state:n,dispatch:r})=>vo(Oo(e,n.schema),t)(n,r)});const va=_o.create({name:"commands",addCommands:()=>({...ya})}),wa=_o.create({name:"editable",addProseMirrorPlugins(){return[new zn({key:new _n("editable"),props:{editable:()=>this.editor.options.editable}})]}}),ba=_o.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:e}=this;return[new zn({key:new _n("focusEvents"),props:{handleDOMEvents:{focus:(t,n)=>{e.isFocused=!0;const r=e.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return t.dispatch(r),!1},blur:(t,n)=>{e.isFocused=!1;const r=e.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return t.dispatch(r),!1}}}})]}}),xa=_o.create({name:"keymap",addKeyboardShortcuts(){const e=()=>this.editor.commands.first((({commands:e})=>[()=>e.undoInputRule(),()=>e.command((({tr:t})=>{const{selection:n,doc:r}=t,{empty:i,$anchor:s}=n,{pos:o,parent:a}=s,l=bn.atStart(r).from===o;return!(!(i&&l&&a.type.isTextblock)||a.textContent.length)&&e.clearNodes()})),()=>e.deleteSelection(),()=>e.joinBackward(),()=>e.selectNodeBackward()])),t=()=>this.editor.commands.first((({commands:e})=>[()=>e.deleteSelection(),()=>e.joinForward(),()=>e.selectNodeForward()])),n={Enter:()=>this.editor.commands.first((({commands:e})=>[()=>e.newlineInCode(),()=>e.createParagraphNear(),()=>e.liftEmptyBlock(),()=>e.splitBlock()])),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:e,"Mod-Backspace":e,"Shift-Backspace":e,Delete:t,"Mod-Delete":t,"Mod-a":()=>this.editor.commands.selectAll()},r={...n},i={...n,"Ctrl-h":e,"Alt-Backspace":e,"Ctrl-d":t,"Ctrl-Alt-Backspace":t,"Alt-Delete":t,"Alt-d":t,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return ea()||ra()?i:r},addProseMirrorPlugins(){return[new zn({key:new _n("clearDocument"),appendTransaction:(e,t,n)=>{if(!(e.some((e=>e.docChanged))&&!t.doc.eq(n.doc)))return;const{empty:r,from:i,to:s}=t.selection,o=bn.atStart(t.doc).from,a=bn.atEnd(t.doc).to,l=i===o&&s===a,c=0===n.doc.textBetween(0,n.doc.content.size," "," ").length;if(r||!l||!c)return;const h=n.tr,d=bo({state:n,transaction:h}),{commands:u}=new xo({editor:this.editor,state:d});return u.clearNodes(),h.steps.length?h:void 0}})]}}),ka=_o.create({name:"tabindex",addProseMirrorPlugins(){return[new zn({key:new _n("tabindex"),props:{attributes:this.editor.isEditable?{tabindex:"0"}:{}}})]}});var Sa=Object.freeze({__proto__:null,ClipboardTextSerializer:Ko,Commands:va,Editable:wa,FocusEvents:ba,Keymap:xa,Tabindex:ka});class Ma extends class{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){const n=this.callbacks[e];return n&&n.forEach((e=>e.apply(this,t))),this}off(e,t){const n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter((e=>e!==t)):delete this.callbacks[e]),this}removeAllListeners(){this.callbacks={}}}{constructor(e={}){super(),this.isFocused=!1,this.extensionStorage={},this.options={element:document.createElement("div"),content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.createView(),this.injectCSS(),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),window.setTimeout((()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}))}),0)}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&document&&(this.css=function(e,t){const n=document.querySelector("style[data-tiptap-style]");if(null!==n)return n;const r=document.createElement("style");return t&&r.setAttribute("nonce",t),r.setAttribute("data-tiptap-style",""),r.innerHTML=e,document.getElementsByTagName("head")[0].appendChild(r),r}('.ProseMirror {\n position: relative;\n}\n\n.ProseMirror {\n word-wrap: break-word;\n white-space: pre-wrap;\n white-space: break-spaces;\n -webkit-font-variant-ligatures: none;\n font-variant-ligatures: none;\n font-feature-settings: "liga" 0; /* the above doesn\'t seem to work in Edge */\n}\n\n.ProseMirror [contenteditable="false"] {\n white-space: normal;\n}\n\n.ProseMirror [contenteditable="false"] [contenteditable="true"] {\n white-space: pre-wrap;\n}\n\n.ProseMirror pre {\n white-space: pre-wrap;\n}\n\nimg.ProseMirror-separator {\n display: inline !important;\n border: none !important;\n margin: 0 !important;\n width: 1px !important;\n height: 1px !important;\n}\n\n.ProseMirror-gapcursor {\n display: none;\n pointer-events: none;\n position: absolute;\n margin: 0;\n}\n\n.ProseMirror-gapcursor:after {\n content: "";\n display: block;\n position: absolute;\n top: -2px;\n width: 20px;\n border-top: 1px solid black;\n animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;\n}\n\n@keyframes ProseMirror-cursor-blink {\n to {\n visibility: hidden;\n }\n}\n\n.ProseMirror-hideselection *::selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection *::-moz-selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection * {\n caret-color: transparent;\n}\n\n.ProseMirror-focused .ProseMirror-gapcursor {\n display: block;\n}\n\n.tippy-box[data-animation=fade][data-state=hidden] {\n opacity: 0\n}',this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},this.view&&this.state&&!this.isDestroyed&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(e){this.setOptions({editable:e}),this.emit("update",{editor:this,transaction:this.state.tr})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get state(){return this.view.state}registerPlugin(e,t){const n=Eo(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],r=this.state.reconfigure({plugins:n});this.view.updateState(r)}unregisterPlugin(e){if(this.isDestroyed)return;const t="string"==typeof e?`${e}$`:e.key,n=this.state.reconfigure({plugins:this.state.plugins.filter((e=>!e.key.startsWith(t)))});this.view.updateState(n)}createExtensionManager(){const e=[...this.options.enableCoreExtensions?Object.values(Sa):[],...this.options.extensions].filter((e=>["extension","node","mark"].includes(null==e?void 0:e.type)));this.extensionManager=new zo(e,this)}createCommandManager(){this.commandManager=new xo({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){const e=aa(this.options.content,this.schema,this.options.parseOptions),t=Qo(e,this.options.autofocus);this.view=new Hs(this.options.element,{...this.options.editorProps,dispatchTransaction:this.dispatchTransaction.bind(this),state:Fn.create({doc:e,selection:t||void 0})});const n=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(n),this.createNodeViews();this.view.dom.editor=this}createNodeViews(){this.view.setProps({nodeViews:this.extensionManager.nodeViews})}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;const t=this.capturedTransaction;return this.capturedTransaction=null,t}dispatchTransaction(e){if(this.isCapturingTransaction)return this.capturedTransaction?void e.steps.forEach((e=>{var t;return null===(t=this.capturedTransaction)||void 0===t?void 0:t.step(e)})):void(this.capturedTransaction=e);const t=this.state.apply(e),n=!this.state.selection.eq(t.selection);this.view.updateState(t),this.emit("transaction",{editor:this,transaction:e}),n&&this.emit("selectionUpdate",{editor:this,transaction:e});const r=e.getMeta("focus"),i=e.getMeta("blur");r&&this.emit("focus",{editor:this,event:r.event,transaction:e}),i&&this.emit("blur",{editor:this,event:i.event,transaction:e}),e.docChanged&&!e.getMeta("preventUpdate")&&this.emit("update",{editor:this,transaction:e})}getAttributes(e){return ha(this.state,e)}isActive(e,t){const n="string"==typeof e?e:null,r="string"==typeof e?t:e;return function(e,t,n={}){if(!t)return ia(e,null,n)||da(e,null,n);const r=sa(t,e.schema);return"node"===r?ia(e,t,n):"mark"===r&&da(e,t,n)}(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return function(e,t){const n=$t.fromSchema(t).serializeFragment(e),r=document.implementation.createHTMLDocument().createElement("div");return r.appendChild(n),r.innerHTML}(this.state.doc.content,this.schema)}getText(e){const{blockSeparator:t="\n\n",textSerializers:n={}}=e||{};return function(e,t){return Wo(e,{from:0,to:e.content.size},t)}(this.state.doc,{blockSeparator:t,textSerializers:{...n,...Ho(this.schema)}})}get isEmpty(){return function(e){var t;const n=null===(t=e.type.createAndFill())||void 0===t?void 0:t.toJSON(),r=e.toJSON();return JSON.stringify(n)===JSON.stringify(r)}(this.state.doc)}getCharacterCount(){return console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.'),this.state.doc.content.size-2}destroy(){this.emit("destroy"),this.view&&this.view.destroy(),this.removeAllListeners()}get isDestroyed(){var e;return!(null===(e=this.view)||void 0===e?void 0:e.docView)}}class Oa{constructor(e={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=To(ko(this,"addOptions",{name:this.name}))),this.storage=To(ko(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new Oa(e)}configure(e={}){const t=this.extend();return t.options=jo(this.options,e),t.storage=To(ko(t,"addStorage",{name:t.name,options:t.options})),t}extend(e={}){const t=new Oa(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=To(ko(t,"addOptions",{name:t.name})),t.storage=To(ko(t,"addStorage",{name:t.name,options:t.options})),t}static handleExit({editor:e,mark:t}){const{tr:n}=e.state,r=e.state.selection.$from;if(r.pos===r.end()){const i=r.marks(),s=!!i.find((e=>(null==e?void 0:e.type.name)===t.name));if(!s)return!1;const o=i.find((e=>(null==e?void 0:e.type.name)===t.name));return o&&n.removeStoredMark(o),n.insertText(" ",r.pos),e.view.dispatch(n),!0}return!1}}class Ca{constructor(e={}){this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=To(ko(this,"addOptions",{name:this.name}))),this.storage=To(ko(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new Ca(e)}configure(e={}){const t=this.extend();return t.options=jo(this.options,e),t.storage=To(ko(t,"addStorage",{name:t.name,options:t.options})),t}extend(e={}){const t=new Ca(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=To(ko(t,"addOptions",{name:t.name})),t.storage=To(ko(t,"addStorage",{name:t.name,options:t.options})),t}}const Aa=Ca.create({name:"doc",topNode:!0,content:"block+"}),Ea=Ca.create({name:"paragraph",priority:1e3,addOptions:()=>({HTMLAttributes:{}}),group:"block",content:"inline*",parseHTML:()=>[{tag:"p"}],renderHTML({HTMLAttributes:e}){return["p",Co(this.options.HTMLAttributes,e),0]},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Ta=Ca.create({name:"text",group:"inline"});function Na(e={}){return new zn({view:t=>new Da(t,e)})}class Da{constructor(e,t){this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=t.width||1,this.color=t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map((t=>{let n=e=>{this[t](e)};return e.dom.addEventListener(t,n),{name:t,handler:n}}))}destroy(){this.handlers.forEach((({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t)))}update(e,t){null!=this.cursorPos&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,null==e?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e,t=this.editorView.state.doc.resolve(this.cursorPos);if(!t.parent.inlineContent){let n=t.nodeBefore,r=t.nodeAfter;if(n||r){let t=this.editorView.nodeDOM(this.cursorPos-(n?n.nodeSize:0)).getBoundingClientRect(),i=n?t.bottom:t.top;n&&r&&(i=(i+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2),e={left:t.left,right:t.right,top:i-this.width/2,bottom:i+this.width/2}}}if(!e){let t=this.editorView.coordsAtPos(this.cursorPos);e={left:t.left-this.width/2,right:t.left+this.width/2,top:t.top,bottom:t.bottom}}let n,r,i=this.editorView.dom.offsetParent;if(this.element||(this.element=i.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none; background-color: "+this.color),!i||i==document.body&&"static"==getComputedStyle(i).position)n=-pageXOffset,r=-pageYOffset;else{let e=i.getBoundingClientRect();n=e.left-i.scrollLeft,r=e.top-i.scrollTop}this.element.style.left=e.left-n+"px",this.element.style.top=e.top-r+"px",this.element.style.width=e.right-e.left+"px",this.element.style.height=e.bottom-e.top+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout((()=>this.setCursor(null)),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=n&&n.type.spec.disableDropCursor,i="function"==typeof r?r(this.editorView,t):r;if(t&&!i){let e=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice&&(e=sn(this.editorView.state.doc,e,this.editorView.dragging.slice),null==e))return this.setCursor(null);this.setCursor(e),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){e.target!=this.editorView.dom&&this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}const $a=_o.create({name:"dropCursor",addOptions:()=>({color:"currentColor",width:1,class:void 0}),addProseMirrorPlugins(){return[Na(this.options)]}});class Ia extends bn{constructor(e){super(e,e)}map(e,t){let n=e.resolve(t.map(this.head));return Ia.valid(n)?new Ia(n):bn.near(n)}content(){return Le.empty}eq(e){return e instanceof Ia&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for GapCursor.fromJSON");return new Ia(e.resolve(t.pos))}getBookmark(){return new Ra(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!function(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(0!=n)for(let e=r.child(n-1);;e=e.lastChild){if(0==e.childCount&&!e.inlineContent||e.isAtom||e.type.spec.isolating)return!0;if(e.inlineContent)return!1}else if(r.type.spec.isolating)return!0}return!0}(e)||!function(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n!=r.childCount)for(let e=r.child(n);;e=e.firstChild){if(0==e.childCount&&!e.inlineContent||e.isAtom||e.type.spec.isolating)return!0;if(e.inlineContent)return!1}else if(r.type.spec.isolating)return!0}return!0}(e))return!1;let n=t.type.spec.allowGapCursor;if(null!=n)return n;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(e,t,n=!1){e:for(;;){if(!n&&Ia.valid(e))return e;let r=e.pos,i=null;for(let n=e.depth;;n--){let s=e.node(n);if(t>0?e.indexAfter(n)<s.childCount:e.index(n)>0){i=s.child(t>0?e.indexAfter(n):e.index(n)-1);break}if(0==n)return null;r+=t;let o=e.doc.resolve(r);if(Ia.valid(o))return o}for(;;){let s=t>0?i.firstChild:i.lastChild;if(!s){if(i.isAtom&&!i.isText&&!Cn.isSelectable(i)){e=e.doc.resolve(r+i.nodeSize*t),n=!1;continue e}break}i=s,r+=t;let o=e.doc.resolve(r);if(Ia.valid(o))return o}return null}}}Ia.prototype.visible=!1,Ia.findFrom=Ia.findGapCursorFrom,bn.jsonID("gapcursor",Ia);class Ra{constructor(e){this.pos=e}map(e){return new Ra(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return Ia.valid(t)?new Ia(t):bn.near(t)}}const Pa=ao({ArrowLeft:Ba("horiz",-1),ArrowRight:Ba("horiz",1),ArrowUp:Ba("vert",-1),ArrowDown:Ba("vert",1)});function Ba(e,t){const n="vert"==e?t>0?"down":"up":t>0?"right":"left";return function(e,r,i){let s=e.selection,o=t>0?s.$to:s.$from,a=s.empty;if(s instanceof Mn){if(!i.endOfTextblock(n)||0==o.depth)return!1;a=!1,o=e.doc.resolve(t>0?o.after():o.before())}let l=Ia.findGapCursorFrom(o,t,a);return!!l&&(r&&r(e.tr.setSelection(new Ia(l))),!0)}}function Fa(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!Ia.valid(r))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return!(i&&i.inside>-1&&Cn.isSelectable(e.state.doc.nodeAt(i.inside)))&&(e.dispatch(e.state.tr.setSelection(new Ia(r))),!0)}function La(e,t){if("insertCompositionText"!=t.inputType||!(e.state.selection instanceof Ia))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let i=$e.empty;for(let e=r.length-1;e>=0;e--)i=$e.from(r[e].createAndFill(null,i));let s=e.state.tr.replace(n.pos,n.pos,new Le(i,0,0));return s.setSelection(Mn.near(s.doc.resolve(n.pos+1))),e.dispatch(s),!1}function za(e){if(!(e.selection instanceof Ia))return null;let t=document.createElement("div");return t.className="ProseMirror-gapcursor",Ss.create(e.doc,[bs.widget(e.selection.head,t,{key:"gapcursor"})])}const Va=_o.create({name:"gapCursor",addProseMirrorPlugins:()=>[new zn({props:{decorations:za,createSelectionBetween:(e,t,n)=>t.pos==n.pos&&Ia.valid(n)?new Ia(n):null,handleClick:Fa,handleKeyDown:Pa,handleDOMEvents:{beforeinput:La}}})],extendNodeSchema(e){var t;return{allowGapCursor:null!==(t=To(ko(e,"allowGapCursor",{name:e.name,options:e.options,storage:e.storage})))&&void 0!==t?t:null}}});var ja=function(){};ja.prototype.append=function(e){return e.length?(e=ja.from(e),!this.length&&e||e.length<200&&this.leafAppend(e)||this.length<200&&e.leafPrepend(this)||this.appendInner(e)):this},ja.prototype.prepend=function(e){return e.length?ja.from(e).append(this):this},ja.prototype.appendInner=function(e){return new Wa(this,e)},ja.prototype.slice=function(e,t){return void 0===e&&(e=0),void 0===t&&(t=this.length),e>=t?ja.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},ja.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},ja.prototype.forEach=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},ja.prototype.map=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length);var r=[];return this.forEach((function(t,n){return r.push(e(t,n))}),t,n),r},ja.from=function(e){return e instanceof ja?e:e&&e.length?new _a(e):ja.empty};var _a=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return 0==e&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var i=t;i<n;i++)if(!1===e(this.values[i],r+i))return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var i=t-1;i>=n;i--)if(!1===e(this.values[i],r+i))return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=200)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=200)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(ja);ja.empty=new _a([]);var Wa=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,r){var i=this.left.length;return!(t<i&&!1===this.left.forEachInner(e,t,Math.min(n,i),r))&&(!(n>i&&!1===this.right.forEachInner(e,Math.max(t-i,0),Math.min(this.length,n)-i,r+i))&&void 0)},t.prototype.forEachInvertedInner=function(e,t,n,r){var i=this.left.length;return!(t>i&&!1===this.right.forEachInvertedInner(e,t-i,Math.max(n,i)-i,r+i))&&(!(n<i&&!1===this.left.forEachInvertedInner(e,Math.min(t,i),n,r))&&void 0)},t.prototype.sliceInner=function(e,t){if(0==e&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(ja),Ha=ja;class Ka{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(0==this.eventCount)return null;let n,r,i=this.items.length;for(;;i--){if(this.items.get(i-1).selection){--i;break}}t&&(n=this.remapping(i,this.items.length),r=n.maps.length);let s,o,a=e.tr,l=[],c=[];return this.items.forEach(((e,t)=>{if(!e.step)return n||(n=this.remapping(i,t+1),r=n.maps.length),r--,void c.push(e);if(n){c.push(new qa(e.map));let t,i=e.step.map(n.slice(r));i&&a.maybeStep(i).doc&&(t=a.mapping.maps[a.mapping.maps.length-1],l.push(new qa(t,void 0,void 0,l.length+c.length))),r--,t&&n.appendMap(t,r)}else a.maybeStep(e.step);return e.selection?(s=n?e.selection.map(n.slice(r)):e.selection,o=new Ka(this.items.slice(0,i).append(c.reverse().concat(l)),this.eventCount-1),!1):void 0}),this.items.length,0),{remaining:o,transform:a,selection:s}}addTransform(e,t,n,r){let i=[],s=this.eventCount,o=this.items,a=!r&&o.length?o.get(o.length-1):null;for(let n=0;n<e.steps.length;n++){let l,c=e.steps[n].invert(e.docs[n]),h=new qa(e.mapping.maps[n],c,t);(l=a&&a.merge(h))&&(h=l,n?i.pop():o=o.slice(0,o.length-1)),i.push(h),t&&(s++,t=void 0),r||(a=h)}let l=s-n.depth;return l>Ua&&(o=function(e,t){let n;return e.forEach(((e,r)=>{if(e.selection&&0==t--)return n=r,!1})),e.slice(n)}(o,l),s-=l),new Ka(o.append(i),s)}remapping(e,t){let n=new Vt;return this.items.forEach(((t,r)=>{let i=null!=t.mirrorOffset&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,i)}),e,t),n}addMaps(e){return 0==this.eventCount?this:new Ka(this.items.append(e.map((e=>new qa(e)))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let n=[],r=Math.max(0,this.items.length-t),i=e.mapping,s=e.steps.length,o=this.eventCount;this.items.forEach((e=>{e.selection&&o--}),r);let a=t;this.items.forEach((t=>{let r=i.getMirror(--a);if(null==r)return;s=Math.min(s,r);let l=i.maps[r];if(t.step){let s=e.steps[r].invert(e.docs[r]),c=t.selection&&t.selection.map(i.slice(a+1,r));c&&o++,n.push(new qa(l,s,c))}else n.push(new qa(l))}),r);let l=[];for(let e=t;e<s;e++)l.push(new qa(i.maps[e]));let c=this.items.slice(0,r).append(l).append(n),h=new Ka(c,o);return h.emptyItemCount()>500&&(h=h.compress(this.items.length-n.length)),h}emptyItemCount(){let e=0;return this.items.forEach((t=>{t.step||e++})),e}compress(e=this.items.length){let t=this.remapping(0,e),n=t.maps.length,r=[],i=0;return this.items.forEach(((s,o)=>{if(o>=e)r.push(s),s.selection&&i++;else if(s.step){let e=s.step.map(t.slice(n)),o=e&&e.getMap();if(n--,o&&t.appendMap(o,n),e){let a=s.selection&&s.selection.map(t.slice(n));a&&i++;let l,c=new qa(o.invert(),e,a),h=r.length-1;(l=r.length&&r[h].merge(c))?r[h]=l:r.push(c)}}else s.map&&n--}),this.items.length,0),new Ka(Ha.from(r.reverse()),i)}}Ka.empty=new Ka(Ha.empty,0);class qa{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new qa(t.getMap().invert(),t,this.selection)}}}class Ja{constructor(e,t,n,r){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r}}const Ua=20;function Ga(e){let t=[];return e.forEach(((e,n,r,i)=>t.push(r,i))),t}function Ya(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let i=t.map(e[r],1),s=t.map(e[r+1],-1);i<=s&&n.push(i,s)}return n}function Xa(e,t,n,r){let i=el(t),s=tl.get(t).spec.config,o=(r?e.undone:e.done).popEvent(t,i);if(!o)return;let a=o.selection.resolve(o.transform.doc),l=(r?e.done:e.undone).addTransform(o.transform,t.selection.getBookmark(),s,i),c=new Ja(r?l:o.remaining,r?o.remaining:l,null,0);n(o.transform.setSelection(a).setMeta(tl,{redo:r,historyState:c}).scrollIntoView())}let Za=!1,Qa=null;function el(e){let t=e.plugins;if(Qa!=t){Za=!1,Qa=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){Za=!0;break}}return Za}const tl=new _n("history"),nl=new _n("closeHistory");function rl(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new zn({key:tl,state:{init:()=>new Ja(Ka.empty,Ka.empty,null,0),apply:(t,n,r)=>function(e,t,n,r){let i,s=n.getMeta(tl);if(s)return s.historyState;n.getMeta(nl)&&(e=new Ja(e.done,e.undone,null,0));let o=n.getMeta("appendedTransaction");if(0==n.steps.length)return e;if(o&&o.getMeta(tl))return o.getMeta(tl).redo?new Ja(e.done.addTransform(n,void 0,r,el(t)),e.undone,Ga(n.mapping.maps[n.steps.length-1]),e.prevTime):new Ja(e.done,e.undone.addTransform(n,void 0,r,el(t)),null,e.prevTime);if(!1===n.getMeta("addToHistory")||o&&!1===o.getMeta("addToHistory"))return(i=n.getMeta("rebased"))?new Ja(e.done.rebased(n,i),e.undone.rebased(n,i),Ya(e.prevRanges,n.mapping),e.prevTime):new Ja(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),Ya(e.prevRanges,n.mapping),e.prevTime);{let i=0==e.prevTime||!o&&(e.prevTime<(n.time||0)-r.newGroupDelay||!function(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach(((e,r)=>{for(let i=0;i<t.length;i+=2)e<=t[i+1]&&r>=t[i]&&(n=!0)})),n}(n,e.prevRanges)),s=o?Ya(e.prevRanges,n.mapping):Ga(n.mapping.maps[n.steps.length-1]);return new Ja(e.done.addTransform(n,i?t.selection.getBookmark():void 0,r,el(t)),Ka.empty,s,n.time)}}(n,r,t,e)},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r="historyUndo"==n?il:"historyRedo"==n?sl:null;return!!r&&(t.preventDefault(),r(e.state,e.dispatch))}}}})}const il=(e,t)=>{let n=tl.getState(e);return!(!n||0==n.done.eventCount)&&(t&&Xa(n,e,t,!1),!0)},sl=(e,t)=>{let n=tl.getState(e);return!(!n||0==n.undone.eventCount)&&(t&&Xa(n,e,t,!0),!0)},ol=_o.create({name:"history",addOptions:()=>({depth:100,newGroupDelay:500}),addCommands:()=>({undo:()=>({state:e,dispatch:t})=>il(e,t),redo:()=>({state:e,dispatch:t})=>sl(e,t)}),addProseMirrorPlugins(){return[rl(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Mod-y":()=>this.editor.commands.redo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}});class al extends q{connect(){for(const e of this.editorTargets){const t=new Ma({extensions:[$a,Va,ol,Aa,Ea,Ta],content:"",injectCSS:!1,element:e,editorProps:{attributes:{class:"ariadne-h-28 ariadne-max-h-48 ariadne-p-2 ariadne-rounded-lg ariadne-overflow-y-auto focus:ariadne-outline-none"}},parseOptions:{preserveWhitespace:!0}}),n=e.previousElementSibling;if(n){const r=e.closest("form");null==r||r.addEventListener("submit",(()=>{n.setAttribute("value",t.getText()||""),t.commands.clearContent()}))}}}}al.targets=["editor"];class ll extends q{toggle(){this.expandableTarget.classList.toggle("ariadne-hidden");for(const e of this.slidePanelTargets)e.classList.toggle("ariadne-hidden")}}ll.targets=["expandable","expandWrapper","slidePanel","buttonWrapper"];class cl extends q{constructor(){super(...arguments),this.SELECTED_CLASSES=["ariadne-border-indigo-500","ariadne-text-indigo-600"],this.UNSELECTED_CLASSES=["ariadne-text-gray-500","hover:ariadne-text-gray-700","hover:ariadne-border-gray-300"]}connect(){for(const e of this.tabTargets)e.hasAttribute("aria-current")&&(e.classList.add(...this.SELECTED_CLASSES),e.classList.remove(...this.UNSELECTED_CLASSES))}toggle(e){for(const t of this.tabTargets)t===e.target?(t.setAttribute("aria-current","page"),t.classList.add(...this.SELECTED_CLASSES),t.classList.remove(...this.UNSELECTED_CLASSES)):t.hasAttribute("aria-current")&&(t.removeAttribute("aria-current"),t.classList.add(...this.UNSELECTED_CLASSES),t.classList.remove(...this.SELECTED_CLASSES))}}cl.targets=["tab"];var hl="top",dl="bottom",ul="right",pl="left",fl=[hl,dl,ul,pl],ml=fl.reduce((function(e,t){return e.concat([t+"-start",t+"-end"])}),[]),gl=[].concat(fl,["auto"]).reduce((function(e,t){return e.concat([t,t+"-start",t+"-end"])}),[]),yl=["beforeRead","read","afterRead","beforeMain","main","afterMain","beforeWrite","write","afterWrite"];function vl(e){return e?(e.nodeName||"").toLowerCase():null}function wl(e){if(null==e)return window;if("[object Window]"!==e.toString()){var t=e.ownerDocument;return t&&t.defaultView||window}return e}function bl(e){return e instanceof wl(e).Element||e instanceof Element}function xl(e){return e instanceof wl(e).HTMLElement||e instanceof HTMLElement}function kl(e){return"undefined"!=typeof ShadowRoot&&(e instanceof wl(e).ShadowRoot||e instanceof ShadowRoot)}var Sl={name:"applyStyles",enabled:!0,phase:"write",fn:function(e){var t=e.state;Object.keys(t.elements).forEach((function(e){var n=t.styles[e]||{},r=t.attributes[e]||{},i=t.elements[e];xl(i)&&vl(i)&&(Object.assign(i.style,n),Object.keys(r).forEach((function(e){var t=r[e];!1===t?i.removeAttribute(e):i.setAttribute(e,!0===t?"":t)})))}))},effect:function(e){var t=e.state,n={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(t.elements.popper.style,n.popper),t.styles=n,t.elements.arrow&&Object.assign(t.elements.arrow.style,n.arrow),function(){Object.keys(t.elements).forEach((function(e){var r=t.elements[e],i=t.attributes[e]||{},s=Object.keys(t.styles.hasOwnProperty(e)?t.styles[e]:n[e]).reduce((function(e,t){return e[t]="",e}),{});xl(r)&&vl(r)&&(Object.assign(r.style,s),Object.keys(i).forEach((function(e){r.removeAttribute(e)})))}))}},requires:["computeStyles"]};function Ml(e){return e.split("-")[0]}var Ol=Math.max,Cl=Math.min,Al=Math.round;function El(){var e=navigator.userAgentData;return null!=e&&e.brands?e.brands.map((function(e){return e.brand+"/"+e.version})).join(" "):navigator.userAgent}function Tl(){return!/^((?!chrome|android).)*safari/i.test(El())}function Nl(e,t,n){void 0===t&&(t=!1),void 0===n&&(n=!1);var r=e.getBoundingClientRect(),i=1,s=1;t&&xl(e)&&(i=e.offsetWidth>0&&Al(r.width)/e.offsetWidth||1,s=e.offsetHeight>0&&Al(r.height)/e.offsetHeight||1);var o=(bl(e)?wl(e):window).visualViewport,a=!Tl()&&n,l=(r.left+(a&&o?o.offsetLeft:0))/i,c=(r.top+(a&&o?o.offsetTop:0))/s,h=r.width/i,d=r.height/s;return{width:h,height:d,top:c,right:l+h,bottom:c+d,left:l,x:l,y:c}}function Dl(e){var t=Nl(e),n=e.offsetWidth,r=e.offsetHeight;return Math.abs(t.width-n)<=1&&(n=t.width),Math.abs(t.height-r)<=1&&(r=t.height),{x:e.offsetLeft,y:e.offsetTop,width:n,height:r}}function $l(e,t){var n=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if(n&&kl(n)){var r=t;do{if(r&&e.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}function Il(e){return wl(e).getComputedStyle(e)}function Rl(e){return["table","td","th"].indexOf(vl(e))>=0}function Pl(e){return((bl(e)?e.ownerDocument:e.document)||window.document).documentElement}function Bl(e){return"html"===vl(e)?e:e.assignedSlot||e.parentNode||(kl(e)?e.host:null)||Pl(e)}function Fl(e){return xl(e)&&"fixed"!==Il(e).position?e.offsetParent:null}function Ll(e){for(var t=wl(e),n=Fl(e);n&&Rl(n)&&"static"===Il(n).position;)n=Fl(n);return n&&("html"===vl(n)||"body"===vl(n)&&"static"===Il(n).position)?t:n||function(e){var t=/firefox/i.test(El());if(/Trident/i.test(El())&&xl(e)&&"fixed"===Il(e).position)return null;var n=Bl(e);for(kl(n)&&(n=n.host);xl(n)&&["html","body"].indexOf(vl(n))<0;){var r=Il(n);if("none"!==r.transform||"none"!==r.perspective||"paint"===r.contain||-1!==["transform","perspective"].indexOf(r.willChange)||t&&"filter"===r.willChange||t&&r.filter&&"none"!==r.filter)return n;n=n.parentNode}return null}(e)||t}function zl(e){return["top","bottom"].indexOf(e)>=0?"x":"y"}function Vl(e,t,n){return Ol(e,Cl(t,n))}function jl(e){return Object.assign({},{top:0,right:0,bottom:0,left:0},e)}function _l(e,t){return t.reduce((function(t,n){return t[n]=e,t}),{})}var Wl={name:"arrow",enabled:!0,phase:"main",fn:function(e){var t,n=e.state,r=e.name,i=e.options,s=n.elements.arrow,o=n.modifiersData.popperOffsets,a=Ml(n.placement),l=zl(a),c=[pl,ul].indexOf(a)>=0?"height":"width";if(s&&o){var h=function(e,t){return jl("number"!=typeof(e="function"==typeof e?e(Object.assign({},t.rects,{placement:t.placement})):e)?e:_l(e,fl))}(i.padding,n),d=Dl(s),u="y"===l?hl:pl,p="y"===l?dl:ul,f=n.rects.reference[c]+n.rects.reference[l]-o[l]-n.rects.popper[c],m=o[l]-n.rects.reference[l],g=Ll(s),y=g?"y"===l?g.clientHeight||0:g.clientWidth||0:0,v=f/2-m/2,w=h[u],b=y-d[c]-h[p],x=y/2-d[c]/2+v,k=Vl(w,x,b),S=l;n.modifiersData[r]=((t={})[S]=k,t.centerOffset=k-x,t)}},effect:function(e){var t=e.state,n=e.options.element,r=void 0===n?"[data-popper-arrow]":n;null!=r&&("string"!=typeof r||(r=t.elements.popper.querySelector(r)))&&$l(t.elements.popper,r)&&(t.elements.arrow=r)},requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function Hl(e){return e.split("-")[1]}var Kl={top:"auto",right:"auto",bottom:"auto",left:"auto"};function ql(e){var t,n=e.popper,r=e.popperRect,i=e.placement,s=e.variation,o=e.offsets,a=e.position,l=e.gpuAcceleration,c=e.adaptive,h=e.roundOffsets,d=e.isFixed,u=o.x,p=void 0===u?0:u,f=o.y,m=void 0===f?0:f,g="function"==typeof h?h({x:p,y:m}):{x:p,y:m};p=g.x,m=g.y;var y=o.hasOwnProperty("x"),v=o.hasOwnProperty("y"),w=pl,b=hl,x=window;if(c){var k=Ll(n),S="clientHeight",M="clientWidth";if(k===wl(n)&&"static"!==Il(k=Pl(n)).position&&"absolute"===a&&(S="scrollHeight",M="scrollWidth"),i===hl||(i===pl||i===ul)&&"end"===s)b=dl,m-=(d&&k===x&&x.visualViewport?x.visualViewport.height:k[S])-r.height,m*=l?1:-1;if(i===pl||(i===hl||i===dl)&&"end"===s)w=ul,p-=(d&&k===x&&x.visualViewport?x.visualViewport.width:k[M])-r.width,p*=l?1:-1}var O,C=Object.assign({position:a},c&&Kl),A=!0===h?function(e){var t=e.x,n=e.y,r=window.devicePixelRatio||1;return{x:Al(t*r)/r||0,y:Al(n*r)/r||0}}({x:p,y:m}):{x:p,y:m};return p=A.x,m=A.y,l?Object.assign({},C,((O={})[b]=v?"0":"",O[w]=y?"0":"",O.transform=(x.devicePixelRatio||1)<=1?"translate("+p+"px, "+m+"px)":"translate3d("+p+"px, "+m+"px, 0)",O)):Object.assign({},C,((t={})[b]=v?m+"px":"",t[w]=y?p+"px":"",t.transform="",t))}var Jl={passive:!0};var Ul={left:"right",right:"left",bottom:"top",top:"bottom"};function Gl(e){return e.replace(/left|right|bottom|top/g,(function(e){return Ul[e]}))}var Yl={start:"end",end:"start"};function Xl(e){return e.replace(/start|end/g,(function(e){return Yl[e]}))}function Zl(e){var t=wl(e);return{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function Ql(e){return Nl(Pl(e)).left+Zl(e).scrollLeft}function ec(e){var t=Il(e),n=t.overflow,r=t.overflowX,i=t.overflowY;return/auto|scroll|overlay|hidden/.test(n+i+r)}function tc(e){return["html","body","#document"].indexOf(vl(e))>=0?e.ownerDocument.body:xl(e)&&ec(e)?e:tc(Bl(e))}function nc(e,t){var n;void 0===t&&(t=[]);var r=tc(e),i=r===(null==(n=e.ownerDocument)?void 0:n.body),s=wl(r),o=i?[s].concat(s.visualViewport||[],ec(r)?r:[]):r,a=t.concat(o);return i?a:a.concat(nc(Bl(o)))}function rc(e){return Object.assign({},e,{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height})}function ic(e,t,n){return"viewport"===t?rc(function(e,t){var n=wl(e),r=Pl(e),i=n.visualViewport,s=r.clientWidth,o=r.clientHeight,a=0,l=0;if(i){s=i.width,o=i.height;var c=Tl();(c||!c&&"fixed"===t)&&(a=i.offsetLeft,l=i.offsetTop)}return{width:s,height:o,x:a+Ql(e),y:l}}(e,n)):bl(t)?function(e,t){var n=Nl(e,!1,"fixed"===t);return n.top=n.top+e.clientTop,n.left=n.left+e.clientLeft,n.bottom=n.top+e.clientHeight,n.right=n.left+e.clientWidth,n.width=e.clientWidth,n.height=e.clientHeight,n.x=n.left,n.y=n.top,n}(t,n):rc(function(e){var t,n=Pl(e),r=Zl(e),i=null==(t=e.ownerDocument)?void 0:t.body,s=Ol(n.scrollWidth,n.clientWidth,i?i.scrollWidth:0,i?i.clientWidth:0),o=Ol(n.scrollHeight,n.clientHeight,i?i.scrollHeight:0,i?i.clientHeight:0),a=-r.scrollLeft+Ql(e),l=-r.scrollTop;return"rtl"===Il(i||n).direction&&(a+=Ol(n.clientWidth,i?i.clientWidth:0)-s),{width:s,height:o,x:a,y:l}}(Pl(e)))}function sc(e,t,n,r){var i="clippingParents"===t?function(e){var t=nc(Bl(e)),n=["absolute","fixed"].indexOf(Il(e).position)>=0&&xl(e)?Ll(e):e;return bl(n)?t.filter((function(e){return bl(e)&&$l(e,n)&&"body"!==vl(e)})):[]}(e):[].concat(t),s=[].concat(i,[n]),o=s[0],a=s.reduce((function(t,n){var i=ic(e,n,r);return t.top=Ol(i.top,t.top),t.right=Cl(i.right,t.right),t.bottom=Cl(i.bottom,t.bottom),t.left=Ol(i.left,t.left),t}),ic(e,o,r));return a.width=a.right-a.left,a.height=a.bottom-a.top,a.x=a.left,a.y=a.top,a}function oc(e){var t,n=e.reference,r=e.element,i=e.placement,s=i?Ml(i):null,o=i?Hl(i):null,a=n.x+n.width/2-r.width/2,l=n.y+n.height/2-r.height/2;switch(s){case hl:t={x:a,y:n.y-r.height};break;case dl:t={x:a,y:n.y+n.height};break;case ul:t={x:n.x+n.width,y:l};break;case pl:t={x:n.x-r.width,y:l};break;default:t={x:n.x,y:n.y}}var c=s?zl(s):null;if(null!=c){var h="y"===c?"height":"width";switch(o){case"start":t[c]=t[c]-(n[h]/2-r[h]/2);break;case"end":t[c]=t[c]+(n[h]/2-r[h]/2)}}return t}function ac(e,t){void 0===t&&(t={});var n=t,r=n.placement,i=void 0===r?e.placement:r,s=n.strategy,o=void 0===s?e.strategy:s,a=n.boundary,l=void 0===a?"clippingParents":a,c=n.rootBoundary,h=void 0===c?"viewport":c,d=n.elementContext,u=void 0===d?"popper":d,p=n.altBoundary,f=void 0!==p&&p,m=n.padding,g=void 0===m?0:m,y=jl("number"!=typeof g?g:_l(g,fl)),v="popper"===u?"reference":"popper",w=e.rects.popper,b=e.elements[f?v:u],x=sc(bl(b)?b:b.contextElement||Pl(e.elements.popper),l,h,o),k=Nl(e.elements.reference),S=oc({reference:k,element:w,strategy:"absolute",placement:i}),M=rc(Object.assign({},w,S)),O="popper"===u?M:k,C={top:x.top-O.top+y.top,bottom:O.bottom-x.bottom+y.bottom,left:x.left-O.left+y.left,right:O.right-x.right+y.right},A=e.modifiersData.offset;if("popper"===u&&A){var E=A[i];Object.keys(C).forEach((function(e){var t=[ul,dl].indexOf(e)>=0?1:-1,n=[hl,dl].indexOf(e)>=0?"y":"x";C[e]+=E[n]*t}))}return C}function lc(e,t){void 0===t&&(t={});var n=t,r=n.placement,i=n.boundary,s=n.rootBoundary,o=n.padding,a=n.flipVariations,l=n.allowedAutoPlacements,c=void 0===l?gl:l,h=Hl(r),d=h?a?ml:ml.filter((function(e){return Hl(e)===h})):fl,u=d.filter((function(e){return c.indexOf(e)>=0}));0===u.length&&(u=d);var p=u.reduce((function(t,n){return t[n]=ac(e,{placement:n,boundary:i,rootBoundary:s,padding:o})[Ml(n)],t}),{});return Object.keys(p).sort((function(e,t){return p[e]-p[t]}))}var cc={name:"flip",enabled:!0,phase:"main",fn:function(e){var t=e.state,n=e.options,r=e.name;if(!t.modifiersData[r]._skip){for(var i=n.mainAxis,s=void 0===i||i,o=n.altAxis,a=void 0===o||o,l=n.fallbackPlacements,c=n.padding,h=n.boundary,d=n.rootBoundary,u=n.altBoundary,p=n.flipVariations,f=void 0===p||p,m=n.allowedAutoPlacements,g=t.options.placement,y=Ml(g),v=l||(y===g||!f?[Gl(g)]:function(e){if("auto"===Ml(e))return[];var t=Gl(e);return[Xl(e),t,Xl(t)]}(g)),w=[g].concat(v).reduce((function(e,n){return e.concat("auto"===Ml(n)?lc(t,{placement:n,boundary:h,rootBoundary:d,padding:c,flipVariations:f,allowedAutoPlacements:m}):n)}),[]),b=t.rects.reference,x=t.rects.popper,k=new Map,S=!0,M=w[0],O=0;O<w.length;O++){var C=w[O],A=Ml(C),E="start"===Hl(C),T=[hl,dl].indexOf(A)>=0,N=T?"width":"height",D=ac(t,{placement:C,boundary:h,rootBoundary:d,altBoundary:u,padding:c}),$=T?E?ul:pl:E?dl:hl;b[N]>x[N]&&($=Gl($));var I=Gl($),R=[];if(s&&R.push(D[A]<=0),a&&R.push(D[$]<=0,D[I]<=0),R.every((function(e){return e}))){M=C,S=!1;break}k.set(C,R)}if(S)for(var P=function(e){var t=w.find((function(t){var n=k.get(t);if(n)return n.slice(0,e).every((function(e){return e}))}));if(t)return M=t,"break"},B=f?3:1;B>0;B--){if("break"===P(B))break}t.placement!==M&&(t.modifiersData[r]._skip=!0,t.placement=M,t.reset=!0)}},requiresIfExists:["offset"],data:{_skip:!1}};function hc(e,t,n){return void 0===n&&(n={x:0,y:0}),{top:e.top-t.height-n.y,right:e.right-t.width+n.x,bottom:e.bottom-t.height+n.y,left:e.left-t.width-n.x}}function dc(e){return[hl,ul,dl,pl].some((function(t){return e[t]>=0}))}var uc={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:function(e){var t=e.state,n=e.options,r=e.name,i=n.offset,s=void 0===i?[0,0]:i,o=gl.reduce((function(e,n){return e[n]=function(e,t,n){var r=Ml(e),i=[pl,hl].indexOf(r)>=0?-1:1,s="function"==typeof n?n(Object.assign({},t,{placement:e})):n,o=s[0],a=s[1];return o=o||0,a=(a||0)*i,[pl,ul].indexOf(r)>=0?{x:a,y:o}:{x:o,y:a}}(n,t.rects,s),e}),{}),a=o[t.placement],l=a.x,c=a.y;null!=t.modifiersData.popperOffsets&&(t.modifiersData.popperOffsets.x+=l,t.modifiersData.popperOffsets.y+=c),t.modifiersData[r]=o}};var pc={name:"preventOverflow",enabled:!0,phase:"main",fn:function(e){var t=e.state,n=e.options,r=e.name,i=n.mainAxis,s=void 0===i||i,o=n.altAxis,a=void 0!==o&&o,l=n.boundary,c=n.rootBoundary,h=n.altBoundary,d=n.padding,u=n.tether,p=void 0===u||u,f=n.tetherOffset,m=void 0===f?0:f,g=ac(t,{boundary:l,rootBoundary:c,padding:d,altBoundary:h}),y=Ml(t.placement),v=Hl(t.placement),w=!v,b=zl(y),x="x"===b?"y":"x",k=t.modifiersData.popperOffsets,S=t.rects.reference,M=t.rects.popper,O="function"==typeof m?m(Object.assign({},t.rects,{placement:t.placement})):m,C="number"==typeof O?{mainAxis:O,altAxis:O}:Object.assign({mainAxis:0,altAxis:0},O),A=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,E={x:0,y:0};if(k){if(s){var T,N="y"===b?hl:pl,D="y"===b?dl:ul,$="y"===b?"height":"width",I=k[b],R=I+g[N],P=I-g[D],B=p?-M[$]/2:0,F="start"===v?S[$]:M[$],L="start"===v?-M[$]:-S[$],z=t.elements.arrow,V=p&&z?Dl(z):{width:0,height:0},j=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:{top:0,right:0,bottom:0,left:0},_=j[N],W=j[D],H=Vl(0,S[$],V[$]),K=w?S[$]/2-B-H-_-C.mainAxis:F-H-_-C.mainAxis,q=w?-S[$]/2+B+H+W+C.mainAxis:L+H+W+C.mainAxis,J=t.elements.arrow&&Ll(t.elements.arrow),U=J?"y"===b?J.clientTop||0:J.clientLeft||0:0,G=null!=(T=null==A?void 0:A[b])?T:0,Y=I+q-G,X=Vl(p?Cl(R,I+K-G-U):R,I,p?Ol(P,Y):P);k[b]=X,E[b]=X-I}if(a){var Z,Q="x"===b?hl:pl,ee="x"===b?dl:ul,te=k[x],ne="y"===x?"height":"width",re=te+g[Q],ie=te-g[ee],se=-1!==[hl,pl].indexOf(y),oe=null!=(Z=null==A?void 0:A[x])?Z:0,ae=se?re:te-S[ne]-M[ne]-oe+C.altAxis,le=se?te+S[ne]+M[ne]-oe-C.altAxis:ie,ce=p&&se?function(e,t,n){var r=Vl(e,t,n);return r>n?n:r}(ae,te,le):Vl(p?ae:re,te,p?le:ie);k[x]=ce,E[x]=ce-te}t.modifiersData[r]=E}},requiresIfExists:["offset"]};function fc(e,t,n){void 0===n&&(n=!1);var r,i,s=xl(t),o=xl(t)&&function(e){var t=e.getBoundingClientRect(),n=Al(t.width)/e.offsetWidth||1,r=Al(t.height)/e.offsetHeight||1;return 1!==n||1!==r}(t),a=Pl(t),l=Nl(e,o,n),c={scrollLeft:0,scrollTop:0},h={x:0,y:0};return(s||!s&&!n)&&(("body"!==vl(t)||ec(a))&&(c=(r=t)!==wl(r)&&xl(r)?{scrollLeft:(i=r).scrollLeft,scrollTop:i.scrollTop}:Zl(r)),xl(t)?((h=Nl(t,!0)).x+=t.clientLeft,h.y+=t.clientTop):a&&(h.x=Ql(a))),{x:l.left+c.scrollLeft-h.x,y:l.top+c.scrollTop-h.y,width:l.width,height:l.height}}function mc(e){var t=new Map,n=new Set,r=[];function i(e){n.add(e.name),[].concat(e.requires||[],e.requiresIfExists||[]).forEach((function(e){if(!n.has(e)){var r=t.get(e);r&&i(r)}})),r.push(e)}return e.forEach((function(e){t.set(e.name,e)})),e.forEach((function(e){n.has(e.name)||i(e)})),r}var gc={placement:"bottom",modifiers:[],strategy:"absolute"};function yc(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return!t.some((function(e){return!(e&&"function"==typeof e.getBoundingClientRect)}))}function vc(e){void 0===e&&(e={});var t=e,n=t.defaultModifiers,r=void 0===n?[]:n,i=t.defaultOptions,s=void 0===i?gc:i;return function(e,t,n){void 0===n&&(n=s);var i,o,a={placement:"bottom",orderedModifiers:[],options:Object.assign({},gc,s),modifiersData:{},elements:{reference:e,popper:t},attributes:{},styles:{}},l=[],c=!1,h={state:a,setOptions:function(n){var i="function"==typeof n?n(a.options):n;d(),a.options=Object.assign({},s,a.options,i),a.scrollParents={reference:bl(e)?nc(e):e.contextElement?nc(e.contextElement):[],popper:nc(t)};var o=function(e){var t=mc(e);return yl.reduce((function(e,n){return e.concat(t.filter((function(e){return e.phase===n})))}),[])}(function(e){var t=e.reduce((function(e,t){var n=e[t.name];return e[t.name]=n?Object.assign({},n,t,{options:Object.assign({},n.options,t.options),data:Object.assign({},n.data,t.data)}):t,e}),{});return Object.keys(t).map((function(e){return t[e]}))}([].concat(r,a.options.modifiers)));return a.orderedModifiers=o.filter((function(e){return e.enabled})),a.orderedModifiers.forEach((function(e){var t=e.name,n=e.options,r=void 0===n?{}:n,i=e.effect;if("function"==typeof i){var s=i({state:a,name:t,instance:h,options:r}),o=function(){};l.push(s||o)}})),h.update()},forceUpdate:function(){if(!c){var e=a.elements,t=e.reference,n=e.popper;if(yc(t,n)){a.rects={reference:fc(t,Ll(n),"fixed"===a.options.strategy),popper:Dl(n)},a.reset=!1,a.placement=a.options.placement,a.orderedModifiers.forEach((function(e){return a.modifiersData[e.name]=Object.assign({},e.data)}));for(var r=0;r<a.orderedModifiers.length;r++)if(!0!==a.reset){var i=a.orderedModifiers[r],s=i.fn,o=i.options,l=void 0===o?{}:o,d=i.name;"function"==typeof s&&(a=s({state:a,options:l,name:d,instance:h})||a)}else a.reset=!1,r=-1}}},update:(i=function(){return new Promise((function(e){h.forceUpdate(),e(a)}))},function(){return o||(o=new Promise((function(e){Promise.resolve().then((function(){o=void 0,e(i())}))}))),o}),destroy:function(){d(),c=!0}};if(!yc(e,t))return h;function d(){l.forEach((function(e){return e()})),l=[]}return h.setOptions(n).then((function(e){!c&&n.onFirstUpdate&&n.onFirstUpdate(e)})),h}}var wc=vc({defaultModifiers:[{name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:function(e){var t=e.state,n=e.instance,r=e.options,i=r.scroll,s=void 0===i||i,o=r.resize,a=void 0===o||o,l=wl(t.elements.popper),c=[].concat(t.scrollParents.reference,t.scrollParents.popper);return s&&c.forEach((function(e){e.addEventListener("scroll",n.update,Jl)})),a&&l.addEventListener("resize",n.update,Jl),function(){s&&c.forEach((function(e){e.removeEventListener("scroll",n.update,Jl)})),a&&l.removeEventListener("resize",n.update,Jl)}},data:{}},{name:"popperOffsets",enabled:!0,phase:"read",fn:function(e){var t=e.state,n=e.name;t.modifiersData[n]=oc({reference:t.rects.reference,element:t.rects.popper,strategy:"absolute",placement:t.placement})},data:{}},{name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:function(e){var t=e.state,n=e.options,r=n.gpuAcceleration,i=void 0===r||r,s=n.adaptive,o=void 0===s||s,a=n.roundOffsets,l=void 0===a||a,c={placement:Ml(t.placement),variation:Hl(t.placement),popper:t.elements.popper,popperRect:t.rects.popper,gpuAcceleration:i,isFixed:"fixed"===t.options.strategy};null!=t.modifiersData.popperOffsets&&(t.styles.popper=Object.assign({},t.styles.popper,ql(Object.assign({},c,{offsets:t.modifiersData.popperOffsets,position:t.options.strategy,adaptive:o,roundOffsets:l})))),null!=t.modifiersData.arrow&&(t.styles.arrow=Object.assign({},t.styles.arrow,ql(Object.assign({},c,{offsets:t.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:l})))),t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-placement":t.placement})},data:{}},Sl,uc,cc,pc,Wl,{name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:function(e){var t=e.state,n=e.name,r=t.rects.reference,i=t.rects.popper,s=t.modifiersData.preventOverflow,o=ac(t,{elementContext:"reference"}),a=ac(t,{altBoundary:!0}),l=hc(o,r),c=hc(a,i,s),h=dc(l),d=dc(c);t.modifiersData[n]={referenceClippingOffsets:l,popperEscapeOffsets:c,isReferenceHidden:h,hasPopperEscaped:d},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":h,"data-popper-escaped":d})}}]});class bc extends q{connect(){this.popperInstance=wc(this.triggerTarget,this.tooltipTarget,{placement:this.placementValue,modifiers:[{name:"offset",options:{offset:this.offsetValue}}]})}disconnect(){this.popperInstance&&this.popperInstance.destroy()}show(){this.tooltipTarget.setAttribute("data-tooltip-show",""),this.tooltipTarget.classList.remove("ariadne-invisible"),this.popperInstance.update(),this.dispatch("shown",{detail:{trigger:this.triggerTarget,tooltip:this.tooltipTarget}})}hide(){this.tooltipTarget.removeAttribute("data-tooltip-show"),this.tooltipTarget.classList.add("ariadne-invisible"),this.dispatch("ariadne-hidden",{detail:{trigger:this.triggerTarget,tooltip:this.tooltipTarget}})}}function xc(e){return Array.from(e.querySelectorAll('[role="tablist"] [role="tab"]')).filter((t=>t instanceof HTMLElement&&t.closest(e.tagName)===e))}bc.targets=["trigger","tooltip"],bc.values={placement:{type:String,default:"top"},offset:{type:Array,default:[0,8]}};class kc extends HTMLElement{constructor(){super(),this.addEventListener("keydown",(e=>{const t=e.target;if(!(t instanceof HTMLElement))return;if(t.closest(this.tagName)!==this)return;if("tab"!==t.getAttribute("role")&&!t.closest('[role="tablist"]'))return;const n=xc(this),r=n.indexOf(n.find((e=>e.matches('[aria-selected="true"]')))),[i,s]="vertical"===t.closest('[role="tablist"]')?.getAttribute("aria-orientation")?[["ArrowDown","ArrowRight"],["ArrowUp","ArrowLeft"]]:[["ArrowRight"],["ArrowLeft"]];if(i.some((t=>e.code===t))){let e=r+1;e>=n.length&&(e=0),this.selectTab(e)}else if(s.some((t=>e.code===t))){let e=r-1;e<0&&(e=n.length-1),this.selectTab(e)}else"Home"===e.code?(this.selectTab(0),e.preventDefault()):"End"===e.code&&(this.selectTab(n.length-1),e.preventDefault())})),this.addEventListener("click",(e=>{const t=xc(this);if(!(e.target instanceof Element))return;if(e.target.closest(this.tagName)!==this)return;const n=e.target.closest('[role="tab"]');if(!(n instanceof HTMLElement&&n.closest('[role="tablist"]')))return;const r=t.indexOf(n);this.selectTab(r)}))}connectedCallback(){for(const e of xc(this))e.hasAttribute("aria-selected")||e.setAttribute("aria-selected","false"),e.hasAttribute("tabindex")||("true"===e.getAttribute("aria-selected")?e.setAttribute("tabindex","0"):e.setAttribute("tabindex","-1"))}selectTab(e){const t=xc(this),n=Array.from(this.querySelectorAll('[role="tabpanel"]')).filter((e=>e.closest(this.tagName)===this));if(e>t.length-1)throw new RangeError(`Index "${e}" out of bounds`);const r=t[e],i=n[e];if(!!this.dispatchEvent(new CustomEvent("tab-container-change",{bubbles:!0,cancelable:!0,detail:{relatedTarget:i}}))){for(const e of t)e.setAttribute("aria-selected","false"),e.setAttribute("tabindex","-1");for(const e of n)e.hidden=!0,e.hasAttribute("tabindex")||e.hasAttribute("data-tab-container-no-tabstop")||e.setAttribute("tabindex","0");r.setAttribute("aria-selected","true"),r.setAttribute("tabindex","0"),r.focus(),i.hidden=!1,this.dispatchEvent(new CustomEvent("tab-container-changed",{bubbles:!0,detail:{relatedTarget:i}}))}}}window.customElements.get("tab-container")||(window.TabContainerElement=kc,window.customElements.define("tab-container",kc));const Sc=["ariadne-border-indigo-500","ariadne-text-indigo-600"],Mc=["ariadne-text-gray-500","hover:ariadne-text-gray-700","hover:ariadne-border-gray-300"];for(const e of document.getElementsByTagName("tab-container"))e.addEventListener("tab-container-change",(function(e){var t;const n=e.detail.relatedTarget,r=n.closest("tab-container").firstElementChild,i=r.querySelector('[aria-selected="true"]'),s=null===(t=n.getAttribute("id"))||void 0===t?void 0:t.split("-").slice(1).join("-"),o=r.querySelector(`#${s}`);i.classList.remove(...Sc),i.classList.add(...Mc),o.classList.add(...Sc),o.classList.remove(...Mc)}));const Oc=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Cc=["January","February","March","April","May","June","July","August","September","October","November","December"];function Ac(e){return`0${e}`.slice(-2)}function Ec(e,t){const n=e.getDay(),r=e.getDate(),i=e.getMonth(),s=e.getFullYear(),o=e.getHours(),a=e.getMinutes(),l=e.getSeconds();return t.replace(/%([%aAbBcdeHIlmMpPSwyYZz])/g,(function(t){let c;switch(t[1]){case"%":return"%";case"a":return Oc[n].slice(0,3);case"A":return Oc[n];case"b":return Cc[i].slice(0,3);case"B":return Cc[i];case"c":return e.toString();case"d":return Ac(r);case"e":return String(r);case"H":return Ac(o);case"I":return Ac(Ec(e,"%l"));case"l":return String(0===o||12===o?12:(o+12)%12);case"m":return Ac(i+1);case"M":return Ac(a);case"p":return o>11?"PM":"AM";case"P":return o>11?"pm":"am";case"S":return Ac(l);case"w":return String(n);case"y":return Ac(s%100);case"Y":return String(s);case"Z":return c=e.toString().match(/\((\w+)\)$/),c?c[1]:"";case"z":return c=e.toString().match(/\w([+-]\d\d\d\d) /),c?c[1]:""}return""}))}function Tc(e){let t;return function(){if(t)return t;if("Intl"in window)try{return t=new Intl.DateTimeFormat(void 0,e),t}catch(e){if(!(e instanceof RangeError))throw e}}}let Nc=null;const Dc=Tc({day:"numeric",month:"short"});function $c(){if(null!==Nc)return Nc;const e=Dc();if(e){const t=e.format(new Date(0));return Nc=!!t.match(/^\d/),Nc}return!1}let Ic=null;const Rc=Tc({day:"numeric",month:"short",year:"numeric"});function Pc(e){const t=e.closest("[lang]");return t instanceof HTMLElement&&t.lang?t.lang:"default"}const Bc=new WeakMap;class Fc extends HTMLElement{static get observedAttributes(){return["datetime","day","format","lang","hour","minute","month","second","title","weekday","year","time-zone-name"]}connectedCallback(){const e=this.getFormattedTitle();e&&!this.hasAttribute("title")&&this.setAttribute("title",e);const t=this.getFormattedDate();t&&(this.textContent=t)}attributeChangedCallback(e,t,n){const r=this.getFormattedTitle();if("datetime"===e){const e=Date.parse(n);isNaN(e)?Bc.delete(this):Bc.set(this,new Date(e))}const i=this.getFormattedTitle(),s=this.getAttribute("title");"title"===e||!i||s&&s!==r||this.setAttribute("title",i);const o=this.getFormattedDate();o&&(this.textContent=o)}get date(){return Bc.get(this)}getFormattedTitle(){const e=this.date;if(!e)return;const t=Lc();if(t)return t.format(e);try{return e.toLocaleString()}catch(t){if(t instanceof RangeError)return e.toString();throw t}}getFormattedDate(){}}const Lc=Tc({day:"numeric",month:"short",year:"numeric",hour:"numeric",minute:"2-digit",timeZoneName:"short"}),zc=new WeakMap;class Vc extends Fc{attributeChangedCallback(e,t,n){"hour"!==e&&"minute"!==e&&"second"!==e&&"time-zone-name"!==e||zc.delete(this),super.attributeChangedCallback(e,t,n)}getFormattedDate(){const e=this.date;if(!e)return;const t=function(e,t){const n={weekday:{short:"%a",long:"%A"},day:{numeric:"%e","2-digit":"%d"},month:{short:"%b",long:"%B"},year:{numeric:"%Y","2-digit":"%y"}};let r=$c()?"weekday day month year":"weekday month day, year";for(const t in n){const i=n[t][e.getAttribute(t)||""];r=r.replace(t,i||"")}return r=r.replace(/(\s,)|(,\s$)/,""),Ec(t,r).replace(/\s+/," ").trim()}(this,e)||"",n=function(e,t){const n={},r=e.getAttribute("hour");"numeric"!==r&&"2-digit"!==r||(n.hour=r);const i=e.getAttribute("minute");"numeric"!==i&&"2-digit"!==i||(n.minute=i);const s=e.getAttribute("second");"numeric"!==s&&"2-digit"!==s||(n.second=s);const o=e.getAttribute("time-zone-name");"short"!==o&&"long"!==o||(n.timeZoneName=o);if(0===Object.keys(n).length)return;let a=zc.get(e);a||(a=Tc(n),zc.set(e,a));const l=a();if(l)return l.format(t);return Ec(t,n.second?"%H:%M:%S":"%H:%M")}(this,e)||"";return`${t} ${n}`.trim()}}window.customElements.get("local-time")||(window.LocalTimeElement=Vc,window.customElements.define("local-time",Vc));class jc{constructor(e,t){this.date=e,this.locale=t}toString(){const e=this.timeElapsed();if(e)return e;{const e=this.timeAhead();return e||`on ${this.formatDate()}`}}timeElapsed(){const e=(new Date).getTime()-this.date.getTime(),t=Math.round(e/1e3),n=Math.round(t/60),r=Math.round(n/60),i=Math.round(r/24);return e>=0&&i<30?this.timeAgoFromMs(e):null}timeAhead(){const e=this.date.getTime()-(new Date).getTime(),t=Math.round(e/1e3),n=Math.round(t/60),r=Math.round(n/60),i=Math.round(r/24);return e>=0&&i<30?this.timeUntil():null}timeAgo(){const e=(new Date).getTime()-this.date.getTime();return this.timeAgoFromMs(e)}timeAgoFromMs(e){const t=Math.round(e/1e3),n=Math.round(t/60),r=Math.round(n/60),i=Math.round(r/24),s=Math.round(i/30),o=Math.round(s/12);return e<0||t<10?_c(this.locale,0,"second"):t<45?_c(this.locale,-t,"second"):t<90||n<45?_c(this.locale,-n,"minute"):n<90||r<24?_c(this.locale,-r,"hour"):r<36||i<30?_c(this.locale,-i,"day"):s<18?_c(this.locale,-s,"month"):_c(this.locale,-o,"year")}microTimeAgo(){const e=(new Date).getTime()-this.date.getTime(),t=Math.round(e/1e3),n=Math.round(t/60),r=Math.round(n/60),i=Math.round(r/24),s=Math.round(i/30),o=Math.round(s/12);return n<1?"1m":n<60?`${n}m`:r<24?`${r}h`:i<365?`${i}d`:`${o}y`}timeUntil(){const e=this.date.getTime()-(new Date).getTime();return this.timeUntilFromMs(e)}timeUntilFromMs(e){const t=Math.round(e/1e3),n=Math.round(t/60),r=Math.round(n/60),i=Math.round(r/24),s=Math.round(i/30),o=Math.round(s/12);return s>=18||s>=12?_c(this.locale,o,"year"):i>=45||i>=30?_c(this.locale,s,"month"):r>=36||r>=24?_c(this.locale,i,"day"):n>=90||n>=45?_c(this.locale,r,"hour"):t>=90||t>=45?_c(this.locale,n,"minute"):_c(this.locale,t>=10?t:0,"second")}microTimeUntil(){const e=this.date.getTime()-(new Date).getTime(),t=Math.round(e/1e3),n=Math.round(t/60),r=Math.round(n/60),i=Math.round(r/24),s=Math.round(i/30),o=Math.round(s/12);return i>=365?`${o}y`:r>=24?`${i}d`:n>=60?`${r}h`:n>1?`${n}m`:"1m"}formatDate(){let e=$c()?"%e %b":"%b %e";var t;return t=this.date,(new Date).getUTCFullYear()!==t.getUTCFullYear()&&(e+=function(){if(null!==Ic)return Ic;const e=Rc();if(e){const t=e.format(new Date(0));return Ic=!!t.match(/\d,/),Ic}return!0}()?", %Y":" %Y"),Ec(this.date,e)}formatTime(){const e=Wc();return e?e.format(this.date):Ec(this.date,"%l:%M%P")}}function _c(e,t,n){const r=function(e,t){if("Intl"in window&&"RelativeTimeFormat"in window.Intl)try{return new Intl.RelativeTimeFormat(e,t)}catch(e){if(!(e instanceof RangeError))throw e}}(e,{numeric:"auto"});return r?r.format(t,n):function(e,t){if(0===e)switch(t){case"year":case"quarter":case"month":case"week":return`this ${t}`;case"day":return"today";case"hour":case"minute":return`in 0 ${t}s`;case"second":return"now"}else if(1===e)switch(t){case"year":case"quarter":case"month":case"week":return`next ${t}`;case"day":return"tomorrow";case"hour":case"minute":case"second":return`in 1 ${t}`}else if(-1===e)switch(t){case"year":case"quarter":case"month":case"week":return`last ${t}`;case"day":return"yesterday";case"hour":case"minute":case"second":return`1 ${t} ago`}else if(e>1)switch(t){case"year":case"quarter":case"month":case"week":case"day":case"hour":case"minute":case"second":return`in ${e} ${t}s`}else if(e<-1)switch(t){case"year":case"quarter":case"month":case"week":case"day":case"hour":case"minute":case"second":return`${-e} ${t}s ago`}throw new RangeError(`Invalid unit argument for format() '${t}'`)}(t,n)}const Wc=Tc({hour:"numeric",minute:"2-digit"});class Hc extends Fc{getFormattedDate(){const e=this.date;if(e)return new jc(e,Pc(this)).toString()}connectedCallback(){Kc.push(this),qc||(Jc(),qc=window.setInterval(Jc,6e4)),super.connectedCallback()}disconnectedCallback(){const e=Kc.indexOf(this);-1!==e&&Kc.splice(e,1),Kc.length||qc&&(clearInterval(qc),qc=null)}}const Kc=[];let qc;function Jc(){let e,t,n;for(t=0,n=Kc.length;t<n;t++)e=Kc[t],e.textContent=e.getFormattedDate()||""}window.customElements.get("relative-time")||(window.RelativeTimeElement=Hc,window.customElements.define("relative-time",Hc));class Uc extends Hc{getFormattedDate(){const e=this.getAttribute("format"),t=this.date;if(t)return"micro"===e?new jc(t,Pc(this)).microTimeAgo():new jc(t,Pc(this)).timeAgo()}}window.customElements.get("time-ago")||(window.TimeAgoElement=Uc,window.customElements.define("time-ago",Uc));class Gc extends Hc{getFormattedDate(){const e=this.getAttribute("format"),t=this.date;if(t)return"micro"===e?new jc(t,Pc(this)).microTimeUntil():new jc(t,Pc(this)).timeUntil()}}window.customElements.get("time-until")||(window.TimeUntilElement=Gc,window.customElements.define("time-until",Gc));const Yc=L.start();Yc.register("clipboard-copy-component",class extends q{copy(){const e=this.element.attributes.getNamedItem("value"),t=this.element.attributes.getNamedItem("for");if(e)navigator.clipboard.writeText(e.value);else if(t){const e=document.getElementById(t.value);navigator.clipboard.writeText((null==e?void 0:e.textContent)||"")}else navigator.clipboard.writeText(this.element.textContent||"")}}),Yc.register("ariadne-form",Ee),Yc.register("rich-text-area-component",al),Yc.register("slideover-component",ll),Yc.register("tab-nav-component",cl),Yc.register("tooltip-component",bc);
8
8
  //# sourceMappingURL=ariadne_view_components.js.map