@nevuto/editors 0.2.25 → 0.2.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +197 -135
- package/dist/index.mjs +6302 -6072
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use client";"use strict";var sS=Object.defineProperty;var iS=(t,e,n)=>e in t?sS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var _o=(t,e,n)=>iS(t,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("react/jsx-runtime"),S=require("react"),
|
|
1
|
+
"use client";"use strict";var sS=Object.defineProperty;var iS=(t,e,n)=>e in t?sS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var _o=(t,e,n)=>iS(t,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("react/jsx-runtime"),S=require("react"),Hs=require("react-dom"),T=require("@nevuto/components");var $t=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function oS(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Eu={exports:{}},Cc={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* use-sync-external-store-shim.production.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var
|
|
9
|
+
*/var Hf;function lS(){if(Hf)return Cc;Hf=1;var t=S;function e(d,h){return d===h&&(d!==0||1/d===1/h)||d!==d&&h!==h}var n=typeof Object.is=="function"?Object.is:e,r=t.useState,s=t.useEffect,i=t.useLayoutEffect,o=t.useDebugValue;function l(d,h){var f=h(),p=r({inst:{value:f,getSnapshot:h}}),g=p[0].inst,y=p[1];return i(function(){g.value=f,g.getSnapshot=h,a(g)&&y({inst:g})},[d,f,h]),s(function(){return a(g)&&y({inst:g}),d(function(){a(g)&&y({inst:g})})},[d]),o(f),f}function a(d){var h=d.getSnapshot;d=d.value;try{var f=h();return!n(d,f)}catch{return!0}}function c(d,h){return h()}var u=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?c:l;return Cc.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:u,Cc}var Mc={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* use-sync-external-store-shim.development.js
|
|
12
12
|
*
|
|
@@ -14,21 +14,21 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var $h;function aS(){return $h||($h=1,process.env.NODE_ENV!=="production"&&function(){function t(h,p){return h===p&&(h!==0||1/h===1/p)||h!==h&&p!==p}function e(h,p){u||s.startTransition===void 0||(u=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var g=p();if(!d){var y=p();i(g,y)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),d=!0)}y=o({inst:{value:g,getSnapshot:p}});var b=y[0].inst,w=y[1];return a(function(){b.value=g,b.getSnapshot=p,n(b)&&w({inst:b})},[h,g,p]),l(function(){return n(b)&&w({inst:b}),h(function(){n(b)&&w({inst:b})})},[h]),c(g),g}function n(h){var p=h.getSnapshot;h=h.value;try{var g=p();return!i(h,g)}catch{return!0}}function r(h,p){return p()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var s=S,i=typeof Object.is=="function"?Object.is:t,o=s.useState,l=s.useEffect,a=s.useLayoutEffect,c=s.useDebugValue,u=!1,d=!1,f=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?r:e;Ec.useSyncExternalStore=s.useSyncExternalStore!==void 0?s.useSyncExternalStore:f,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),Ec}process.env.NODE_ENV==="production"?Tu.exports=lS():Tu.exports=aS();var $a=Tu.exports;function Xe(t){this.content=t}Xe.prototype={constructor:Xe,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,s=r.find(t),i=r.content.slice();return s==-1?i.push(n||t,e):(i[s+1]=e,n&&(i[s]=n)),new Xe(i)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new Xe(n)},addToStart:function(t,e){return new Xe([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new Xe(n)},addBefore:function(t,e,n){var r=this.remove(e),s=r.content.slice(),i=r.find(t);return s.splice(i==-1?s.length:i,0,e,n),new Xe(s)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return t=Xe.from(t),t.size?new Xe(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=Xe.from(t),t.size?new Xe(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=Xe.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},toObject:function(){var t={};return this.forEach(function(e,n){t[e]=n}),t},get size(){return this.content.length>>1}};Xe.from=function(t){if(t instanceof Xe)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new Xe(e)};function dy(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let s=t.child(r),i=e.child(r);if(s==i){n+=s.nodeSize;continue}if(!s.sameMarkup(i))return n;if(s.isText&&s.text!=i.text){let o=s.text,l=i.text,a=0;for(;o[a]==l[a];a++)n++;return a&&a<o.length&&a<l.length&&py(o.charCodeAt(a-1))&&hy(o.charCodeAt(a))&&n--,n}if(s.content.size||i.content.size){let o=dy(s.content,i.content,n+1);if(o!=null)return o}n+=s.nodeSize}}function fy(t,e,n,r){for(let s=t.childCount,i=e.childCount;;){if(s==0||i==0)return s==i?null:{a:n,b:r};let o=t.child(--s),l=e.child(--i),a=o.nodeSize;if(o==l){n-=a,r-=a;continue}if(!o.sameMarkup(l))return{a:n,b:r};if(o.isText&&o.text!=l.text){let c=o.text,u=l.text,d=c.length,f=u.length;for(;d>0&&f>0&&c[d-1]==u[f-1];)d--,f--,n--,r--;return d&&f&&d<c.length&&py(c.charCodeAt(d-1))&&hy(c.charCodeAt(d))&&(n++,r++),{a:n,b:r}}if(o.content.size||l.content.size){let c=fy(o.content,l.content,n-1,r-1);if(c)return c}n-=a,r-=a}}function hy(t){return t>=56320&&t<57344}function py(t){return t>=55296&&t<56320}let j=class ut{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,s=0,i){for(let o=0,l=0;l<n;o++){let a=this.content[o],c=l+a.nodeSize;if(c>e&&r(a,s+l,i||null,o)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,n-u),r,s+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,s){let i="",o=!0;return this.nodesBetween(e,n,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,n-a):l.isLeaf?s?typeof s=="function"?s(l):s:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(o?o=!1:i+=r),i+=c},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,s=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(r)&&(s[s.length-1]=n.withText(n.text+r.text),i=1);i<e.content.length;i++)s.push(e.content[i]);return new ut(s,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],s=0;if(n>e)for(let i=0,o=0;o<n;i++){let l=this.content[i],a=o+l.nodeSize;a>e&&((o<e||a>n)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,n-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,n-o-1))),r.push(l),s+=l.nodeSize),o=a}return new ut(r,s)}cutByIndex(e,n){return e==n?ut.empty:e==0&&n==this.content.length?this:new ut(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let s=this.content.slice(),i=this.size+n.nodeSize-r.nodeSize;return s[e]=n,new ut(s,i)}addToStart(e){return new ut([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new ut(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))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 n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let s=this.content[n];e(s,r,n),r+=s.nodeSize}}findDiffStart(e,n=0){return dy(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return fy(this,e,n,r)}findIndex(e){if(e==0)return No(0,e);if(e==this.size)return No(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 s=this.child(n),i=r+s.nodeSize;if(i>=e)return i==e?No(n+1,i):No(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,n){if(!n)return ut.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return ut.fromArray(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return ut.empty;let n,r=0;for(let s=0;s<e.length;s++){let i=e[s];r+=i.nodeSize,s&&i.isText&&e[s-1].sameMarkup(i)?(n||(n=e.slice(0,s)),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new ut(n||e,r)}static from(e){if(!e)return ut.empty;if(e instanceof ut)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new ut([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}};j.empty=new j([],0);const Mc={index:0,offset:0};function No(t,e){return Mc.index=t,Mc.offset=e,Mc}function Tl(t,e){if(t===e)return!0;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!Tl(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!Tl(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let xe=class Au{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let s=0;s<e.length;s++){let i=e[s];if(this.eq(i))return e;if(this.type.excludes(i.type))n||(n=e.slice(0,s));else{if(i.type.excludes(this.type))return e;!r&&i.type.rank>this.type.rank&&(n||(n=e.slice(0,s)),n.push(this),r=!0),n&&n.push(i)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Tl(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);let s=r.create(n.attrs);return r.checkAttrs(s.attrs),s}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(n[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return Au.none;if(e instanceof Au)return[e];let n=e.slice();return n.sort((r,s)=>r.type.rank-s.type.rank),n}};xe.none=[];let $i=class extends Error{},K=class is{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=gy(this.content,e+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new is(r,this.openStart,this.openEnd)}removeBetween(e,n){return new is(my(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return is.empty;let r=n.openStart||0,s=n.openEnd||0;if(typeof r!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new is(j.fromJSON(e,n.content),r,s)}static maxOpen(e,n=!0){let r=0,s=0;for(let i=e.firstChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.lastChild)s++;return new is(e,r,s)}};K.empty=new K(j.empty,0,0);function my(t,e,n){let{index:r,offset:s}=t.findIndex(e),i=t.maybeChild(r),{index:o,offset:l}=t.findIndex(n);if(s==e||i.isText){if(l!=n&&!t.child(o).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(r,i.copy(my(i.content,e-s-1,n-s-1)))}function gy(t,e,n,r,s,i){let{index:o,offset:l}=t.findIndex(e),a=t.maybeChild(o);if(l==e||a.isText)return i&&r<=0&&s<=0&&!i.canReplace(o,o,n)?null:t.cut(0,e).append(n).append(t.cut(e));let c=gy(a.content,e-l-1,n,o==0?r-1:0,o==t.childCount-1?s-1:0,a);return c&&t.replaceChild(o,a.copy(c))}function cS(t,e,n){if(n.openStart>t.depth)throw new $i("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new $i("Inconsistent open depths");return yy(t,e,n,0)}function yy(t,e,n,r){let s=t.index(r),i=t.node(r);if(s==e.index(r)&&r<t.depth-n.openStart){let o=yy(t,e,n,r+1);return i.copy(i.content.replaceChild(s,o))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let o=t.parent,l=o.content;return Rr(o,l.cut(0,t.parentOffset).append(n.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=uS(n,t);return Rr(i,wy(t,o,l,e,r))}else return Rr(i,Al(t,e,r))}function by(t,e){if(!e.type.compatibleContent(t.type))throw new $i("Cannot join "+e.type.name+" onto "+t.type.name)}function _u(t,e,n){let r=t.node(n);return by(r,e.node(n)),r}function Ir(t,e){let n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function Ci(t,e,n,r){let s=(e||t).node(n),i=0,o=e?e.index(n):s.childCount;t&&(i=t.index(n),t.depth>n?i++:t.textOffset&&(Ir(t.nodeAfter,r),i++));for(let l=i;l<o;l++)Ir(s.child(l),r);e&&e.depth==n&&e.textOffset&&Ir(e.nodeBefore,r)}function Rr(t,e){if(!t.type.validContent(e))throw new $i("Invalid content for node "+t.type.name);return t.copy(e)}function wy(t,e,n,r,s){let i=t.depth>s&&_u(t,e,s+1),o=r.depth>s&&_u(n,r,s+1),l=[];return Ci(null,t,s,l),i&&o&&e.index(s)==n.index(s)?(by(i,o),Ir(Rr(i,wy(t,e,n,r,s+1)),l)):(i&&Ir(Rr(i,Al(t,e,s+1)),l),Ci(e,n,s,l),o&&Ir(Rr(o,Al(n,r,s+1)),l)),Ci(r,null,s,l),new j(l)}function Al(t,e,n){let r=[];if(Ci(null,t,n,r),t.depth>n){let s=_u(t,e,n+1);Ir(Rr(s,Al(t,e,n+1)),r)}return Ci(e,null,n,r),new j(r)}function uS(t,e){let n=e.depth-t.openStart,s=e.node(n).copy(t.content);for(let i=n-1;i>=0;i--)s=e.node(i).copy(j.from(s));return{start:s.resolveNoCache(t.openStart+n),end:s.resolveNoCache(s.content.size-t.openEnd-n)}}class Hi{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],s=e.child(n);return r?e.child(n).cut(r):s}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],s=n==0?0:this.path[n*3-1]+1;for(let i=0;i<e;i++)s+=r.child(i).nodeSize;return s}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return xe.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),s=e.maybeChild(n);if(!r){let l=r;r=s,s=l}let i=r.marks;for(var o=0;o<i.length;o++)i[o].type.spec.inclusive===!1&&(!s||!i[o].isInSet(s.marks))&&(i=i[o--].removeFromSet(i));return i}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,s=e.parent.maybeChild(e.index());for(var i=0;i<r.length;i++)r[i].type.spec.inclusive===!1&&(!s||!r[i].isInSet(s.marks))&&(r=r[i--].removeFromSet(r));return r}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new Fi(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],s=0,i=n;for(let o=e;;){let{index:l,offset:a}=o.content.findIndex(i),c=i-a;if(r.push(o,l,s+a),!c||(o=o.child(l),o.isText))break;i=c-1,s+=a+1}return new Hi(n,r,i)}static resolveCached(e,n){let r=Hh.get(e);if(r)for(let i=0;i<r.elts.length;i++){let o=r.elts[i];if(o.pos==n)return o}else Hh.set(e,r=new dS);let s=r.elts[r.i]=Hi.resolve(e,n);return r.i=(r.i+1)%fS,s}}class dS{constructor(){this.elts=[],this.i=0}}const fS=12,Hh=new WeakMap;class Fi{constructor(e,n,r){this.$from=e,this.$to=n,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const hS=Object.create(null);let ir=class Nu{constructor(e,n,r,s=xe.none){this.type=e,this.attrs=n,this.marks=s,this.content=r||j.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,n,r,s=0){this.content.nodesBetween(e,n,r,s,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,n,r,s){return this.content.textBetween(e,n,r,s)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,n,r){return this.type==e&&Tl(this.attrs,n||e.defaultAttrs||hS)&&xe.sameSet(this.marks,r||xe.none)}copy(e=null){return e==this.content?this:new Nu(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new Nu(this.type,this.attrs,this.content,e)}cut(e,n=this.content.size){return e==0&&n==this.content.size?this:this.copy(this.content.cut(e,n))}slice(e,n=this.content.size,r=!1){if(e==n)return K.empty;let s=this.resolve(e),i=this.resolve(n),o=r?0:s.sharedDepth(n),l=s.start(o),c=s.node(o).content.cut(s.pos-l,i.pos-l);return new K(c,s.depth-o,i.depth-o)}replace(e,n,r){return cS(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:s}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(s==e||n.isText)return n;e-=s+1}}childAfter(e){let{index:n,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(n),index:n,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:n,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(n),index:n,offset:r};let s=this.content.child(n-1);return{node:s,index:n-1,offset:r-s.nodeSize}}resolve(e){return Hi.resolveCached(this,e)}resolveNoCache(e){return Hi.resolve(this,e)}rangeHasMark(e,n,r){let s=!1;return n>e&&this.nodesBetween(e,n,i=>(r.isInSet(i.marks)&&(s=!0),!s)),s}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),xy(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=j.empty,s=0,i=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,s,i),l=o&&o.matchFragment(this.content,n);if(!l||!l.validEnd)return!1;for(let a=s;a<i;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,n,r,s){if(s&&!this.type.allowsMarks(s))return!1;let i=this.contentMatchAt(e).matchType(r),o=i&&i.matchFragment(this.content,n);return o?o.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=xe.none;for(let n=0;n<this.marks.length;n++){let r=this.marks[n];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!xe.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n 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(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let s=j.fromJSON(e,n.content),i=e.nodeType(n.type).create(n.attrs,s,r);return i.type.checkAttrs(i.attrs),i}};ir.prototype.text=void 0;class _l extends ir{constructor(e,n,r,s){if(super(e,n,null,s),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):xy(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new _l(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new _l(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function xy(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class Br{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new pS(e,n);if(r.next==null)return Br.empty;let s=vy(r);r.next&&r.err("Unexpected trailing text");let i=vS(xS(s));return kS(i,r),i}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,r=e.childCount){let s=this;for(let i=n;s&&i<r;i++)s=s.matchType(e.child(i).type);return s}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let s=[this];function i(o,l){let a=o.matchFragment(e,r);if(a&&(!n||a.validEnd))return j.from(l.map(c=>c.createAndFill()));for(let c=0;c<o.next.length;c++){let{type:u,next:d}=o.next[c];if(!(u.isText||u.hasRequiredAttrs())&&s.indexOf(d)==-1){s.push(d);let f=i(d,l.concat(u));if(f)return f}}return null}return i(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let s=r.shift(),i=s.match;if(i.matchType(e)){let o=[];for(let l=s;l.type;l=l.via)o.push(l.type);return o.reverse()}for(let o=0;o<i.next.length;o++){let{type:l,next:a}=i.next[o];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in n)&&(!s.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:s}),n[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let s=0;s<r.next.length;s++)e.indexOf(r.next[s].next)==-1&&n(r.next[s].next)}return n(this),e.map((r,s)=>{let i=s+(r.validEnd?"*":" ")+" ";for(let o=0;o<r.next.length;o++)i+=(o?", ":"")+r.next[o].type.name+"->"+e.indexOf(r.next[o].next);return i}).join(`
|
|
18
|
-
`)}}Br.empty=new Br(!0);class pS{constructor(e,n){this.string=e,this.nodeTypes=n,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 vy(t){let e=[];do e.push(mS(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function mS(t){let e=[];do e.push(gS(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function gS(t){let e=wS(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=yS(t,e);else break;return e}function Fh(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function yS(t,e){let n=Fh(t),r=n;return t.eat(",")&&(t.next!="}"?r=Fh(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function bS(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let s=[];for(let i in n){let o=n[i];o.isInGroup(e)&&s.push(o)}return s.length==0&&t.err("No node type or group '"+e+"' found"),s}function wS(t){if(t.eat("(")){let e=vy(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=bS(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err("Mixing inline and block content"),{type:"name",value:n}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function xS(t){let e=[[]];return s(i(t,0),n()),e;function n(){return e.push([])-1}function r(o,l,a){let c={term:a,to:l};return e[o].push(c),c}function s(o,l){o.forEach(a=>a.to=l)}function i(o,l){if(o.type=="choice")return o.exprs.reduce((a,c)=>a.concat(i(c,l)),[]);if(o.type=="seq")for(let a=0;;a++){let c=i(o.exprs[a],l);if(a==o.exprs.length-1)return c;s(c,l=n())}else if(o.type=="star"){let a=n();return r(l,a),s(i(o.expr,a),a),[r(a)]}else if(o.type=="plus"){let a=n();return s(i(o.expr,l),a),s(i(o.expr,a),a),[r(a)]}else{if(o.type=="opt")return[r(l)].concat(i(o.expr,l));if(o.type=="range"){let a=l;for(let c=0;c<o.min;c++){let u=n();s(i(o.expr,a),u),a=u}if(o.max==-1)s(i(o.expr,a),a);else for(let c=o.min;c<o.max;c++){let u=n();r(a,u),s(i(o.expr,a),u),a=u}return[r(a)]}else{if(o.type=="name")return[r(l,void 0,o.value)];throw new Error("Unknown expr type")}}}}function ky(t,e){return e-t}function Vh(t,e){let n=[];return r(e),n.sort(ky);function r(s){let i=t[s];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(s);for(let o=0;o<i.length;o++){let{term:l,to:a}=i[o];!l&&n.indexOf(a)==-1&&r(a)}}}function vS(t){let e=Object.create(null);return n(Vh(t,0));function n(r){let s=[];r.forEach(o=>{t[o].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let u=0;u<s.length;u++)s[u][0]==l&&(c=s[u][1]);Vh(t,a).forEach(u=>{c||s.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let i=e[r.join(",")]=new Br(r.indexOf(t.length-1)>-1);for(let o=0;o<s.length;o++){let l=s[o][1].sort(ky);i.next.push({type:s[o][0],next:e[l.join(",")]||n(l)})}return i}}function kS(t,e){for(let n=0,r=[t];n<r.length;n++){let s=r[n],i=!s.validEnd,o=[];for(let l=0;l<s.next.length;l++){let{type:a,next:c}=s.next[l];o.push(a.name),i&&!(a.isText||a.hasRequiredAttrs())&&(i=!1),r.indexOf(c)==-1&&r.push(c)}i&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Sy(t){let e=Object.create(null);for(let n in t){let r=t[n];if(!r.hasDefault)return null;e[n]=r.default}return e}function Cy(t,e){let n=Object.create(null);for(let r in t){let s=e&&e[r];if(s===void 0){let i=t[r];if(i.hasDefault)s=i.default;else throw new RangeError("No value supplied for attribute "+r)}n[r]=s}return n}function Ey(t,e,n,r){for(let s in e)if(!(s in t))throw new RangeError(`Unsupported attribute ${s} for ${n} of type ${r}`);for(let s in t)t[s].validate&&t[s].validate(e[s])}function My(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new CS(t,r,e[r]);return n}let Uh=class Ty{constructor(e,n,r){this.name=e,this.schema=n,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=My(e,r.attrs),this.defaultAttrs=Sy(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Br.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:Cy(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new ir(this,this.computeAttrs(e),j.from(n),xe.setFrom(r))}createChecked(e=null,n,r){return n=j.from(n),this.checkContent(n),new ir(this,this.computeAttrs(e),n,xe.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=j.from(n),n.size){let o=this.contentMatch.fillBefore(n);if(!o)return null;n=o.append(n)}let s=this.contentMatch.matchFragment(n),i=s&&s.fillBefore(j.empty,!0);return i?new ir(this,e,n.append(i),xe.setFrom(r)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){Ey(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;n<e.length;n++)if(!this.allowsMarkType(e[n].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let n;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?n&&n.push(e[r]):n||(n=e.slice(0,r));return n?n.length?n:xe.none:e}static compile(e,n){let r=Object.create(null);e.forEach((i,o)=>r[i]=new Ty(i,n,o));let s=n.spec.topNode||"doc";if(!r[s])throw new RangeError("Schema is missing its top node type ('"+s+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let i in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function SS(t,e,n){let r=n.split("|");return s=>{let i=s===null?"null":typeof s;if(r.indexOf(i)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${i}`)}}class CS{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?SS(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class Ha{constructor(e,n,r,s){this.name=e,this.rank=n,this.schema=r,this.spec=s,this.attrs=My(e,s.attrs),this.excluded=null;let i=Sy(this.attrs);this.instance=i?new xe(this,i):null}create(e=null){return!e&&this.instance?this.instance:new xe(this,Cy(this.attrs,e))}static compile(e,n){let r=Object.create(null),s=0;return e.forEach((i,o)=>r[i]=new Ha(i,s++,n,o)),r}removeFromSet(e){for(var n=0;n<e.length;n++)e[n].type==this&&(e=e.slice(0,n).concat(e.slice(n+1)),n--);return e}isInSet(e){for(let n=0;n<e.length;n++)if(e[n].type==this)return e[n]}checkAttrs(e){Ey(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}let Ay=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let s in e)n[s]=e[s];n.nodes=Xe.from(e.nodes),n.marks=Xe.from(e.marks||{}),this.nodes=Uh.compile(this.spec.nodes,this),this.marks=Ha.compile(this.spec.marks,this);let r=Object.create(null);for(let s in this.nodes){if(s in this.marks)throw new RangeError(s+" can not be both a node and a mark");let i=this.nodes[s],o=i.spec.content||"",l=i.spec.marks;if(i.contentMatch=r[o]||(r[o]=Br.parse(o,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!i.isInline||!i.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=i}i.markSet=l=="_"?null:l?Wh(this,l.split(" ")):l==""||!i.inlineContent?[]:null}for(let s in this.marks){let i=this.marks[s],o=i.spec.excludes;i.excluded=o==null?[i]:o==""?[]:Wh(this,o.split(" "))}this.nodeFromJSON=s=>ir.fromJSON(this,s),this.markFromJSON=s=>xe.fromJSON(this,s),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,s){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Uh){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,r,s)}text(e,n){let r=this.nodes.text;return new _l(r,r.defaultAttrs,e,xe.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}};function Wh(t,e){let n=[];for(let r=0;r<e.length;r++){let s=e[r],i=t.marks[s],o=i;if(i)n.push(i);else for(let l in t.marks){let a=t.marks[l];(s=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(s)>-1)&&n.push(o=a)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function ES(t){return t.tag!=null}function MS(t){return t.style!=null}let Ei=class Ou{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(s=>{if(ES(s))this.tags.push(s);else if(MS(s)){let i=/[^=]*/.exec(s.style)[0];r.indexOf(i)<0&&r.push(i),this.styles.push(s)}}),this.normalizeLists=!this.tags.some(s=>{if(!/^(ul|ol)\b/.test(s.tag)||!s.node)return!1;let i=e.nodes[s.node];return i.contentMatch.matchType(i)})}parse(e,n={}){let r=new Kh(this,n,!1);return r.addAll(e,xe.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new Kh(this,n,!0);return r.addAll(e,xe.none,n.from,n.to),K.maxOpen(r.finish())}matchTag(e,n,r){for(let s=r?this.tags.indexOf(r)+1:0;s<this.tags.length;s++){let i=this.tags[s];if(_S(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||n.matchesContext(i.context))){if(i.getAttrs){let o=i.getAttrs(e);if(o===!1)continue;i.attrs=o||void 0}return i}}}matchStyle(e,n,r,s){for(let i=s?this.styles.indexOf(s)+1:0;i<this.styles.length;i++){let o=this.styles[i],l=o.style;if(!(l.indexOf(e)!=0||o.context&&!r.matchesContext(o.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=n))){if(o.getAttrs){let a=o.getAttrs(n);if(a===!1)continue;o.attrs=a||void 0}return o}}}static schemaRules(e){let n=[];function r(s){let i=s.priority==null?50:s.priority,o=0;for(;o<n.length;o++){let l=n[o];if((l.priority==null?50:l.priority)<i)break}n.splice(o,0,s)}for(let s in e.marks){let i=e.marks[s].spec.parseDOM;i&&i.forEach(o=>{r(o=Jh(o)),o.mark||o.ignore||o.clearMark||(o.mark=s)})}for(let s in e.nodes){let i=e.nodes[s].spec.parseDOM;i&&i.forEach(o=>{r(o=Jh(o)),o.node||o.ignore||o.mark||(o.node=s)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Ou(e,Ou.schemaRules(e)))}};const _y={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},TS={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Ny={ol:!0,ul:!0},Vi=1,Iu=2,Mi=4;function qh(t,e,n){return e!=null?(e?Vi:0)|(e==="full"?Iu:0):t&&t.whitespace=="pre"?Vi|Iu:n&~Mi}class Oo{constructor(e,n,r,s,i,o){this.type=e,this.attrs=n,this.marks=r,this.solid=s,this.options=o,this.content=[],this.activeMarks=xe.none,this.match=i||(o&Mi?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(j.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,s;return(s=r.findWrapping(e.type))?(this.match=r,s):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Vi)){let r=this.content[this.content.length-1],s;if(r&&r.isText&&(s=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==s[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-s[0].length))}}let n=j.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(j.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!_y.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Kh{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let s=n.topNode,i,o=qh(null,n.preserveWhitespace,0)|(r?Mi:0);s?i=new Oo(s.type,s.attrs,xe.none,!0,n.topMatch||s.type.contentMatch,o):r?i=new Oo(null,null,xe.none,!0,null,o):i=new Oo(e.schema.topNodeType,null,xe.none,!0,null,o),this.nodes=[i],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,s=this.top,i=s.options&Iu?"full":this.localPreserveWS||(s.options&Vi)>0,{schema:o}=this.parser;if(i==="full"||s.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(i)if(i==="full")r=r.replace(/\r\n?/g,`
|
|
19
|
-
`);else if(o.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(o.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let a=0;a<l.length;a++)a&&this.insertNode(o.linebreakReplacement.create(),n,!0),l[a]&&this.insertNode(o.text(l[a]),n,!/\S/.test(l[a]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let l=s.content[s.content.length-1],a=e.previousSibling;(!l||a&&a.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(r=r.slice(1))}r&&this.insertNode(o.text(r),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){let s=this.localPreserveWS,i=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),l;
|
|
20
|
-
`),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let s=0;s<this.parser.matchedStyles.length;s++){let i=this.parser.matchedStyles[s],o=r.getPropertyValue(i);if(o)for(let l=void 0;;){let a=this.parser.matchStyle(i,o,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?n=n.filter(c=>!a.clearMark(c)):n=n.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return n}addElementByRule(e,n,r,s){let i,o;if(n.node)if(o=this.parser.schema.nodes[n.node],o.isLeaf)this.insertNode(o.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(o,n.attrs||null,r,n.preserveWhitespace);a&&(i=!0,r=a)}else{let a=this.parser.schema.marks[n.mark];r=r.concat(a.create(n.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(s)this.addElement(e,r,s);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof n.contentElement=="string"?a=e.querySelector(n.contentElement):typeof n.contentElement=="function"?a=n.contentElement(e):n.contentElement&&(a=n.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}i&&this.sync(l)&&this.open--}addAll(e,n,r,s){let i=r||0;for(let o=r?e.childNodes[r]:e.firstChild,l=s==null?null:e.childNodes[s];o!=l;o=o.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(o,n);this.findAtPoint(e,i)}findPlace(e,n,r){let s,i;for(let o=this.open,l=0;o>=0;o--){let a=this.nodes[o],c=a.findWrapping(e);if(c&&(!s||s.length>c.length+l)&&(s=c,i=a,!c.length))break;if(a.solid){if(r)break;l+=2}}if(!s)return null;this.sync(i);for(let o=0;o<s.length;o++)n=this.enterInner(s[o],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(n=this.enterInner(i,null,n))}let s=this.findPlace(e,n,r);if(s){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let o=xe.none;for(let l of s.concat(e.marks))(i.type?i.type.allowsMarkType(l.type):Gh(l.type,e.type))&&(o=l.addToSet(o));return i.content.push(e.mark(o)),!0}return!1}enter(e,n,r,s){let i=this.findPlace(e.create(n),r,!1);return i&&(i=this.enterInner(e,n,r,!0,s)),i}enterInner(e,n,r,s=!1,i){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let l=qh(e,i,o.options);o.options&Mi&&o.content.length==0&&(l|=Mi);let a=xe.none;return r=r.filter(c=>(o.type?o.type.allowsMarkType(c.type):Gh(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new Oo(e,n,a,s,null,l)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].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 n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=Vi)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let s=r.length-1;s>=0;s--)e+=r[s].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&this.find)for(let s=0;s<this.find.length;s++)this.find[s].pos==null&&e.nodeType==1&&e.contains(this.find[s].node)&&n.compareDocumentPosition(this.find[s].node)&(r?2:4)&&(this.find[s].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,s=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(s?0:1),o=(l,a)=>{for(;l>=0;l--){let c=n[l];if(c==""){if(l==n.length-1||l==0)continue;for(;a>=i;a--)if(o(l-1,a))return!0;return!1}else{let u=a>0||a==0&&s?this.nodes[a].type:r&&a>=i?r.node(a-i).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;a--}}return!0};return o(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function AS(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Ny.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function _S(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function Jh(t){let e={};for(let n in t)e[n]=t[n];return e}function Gh(t,e){let n=e.schema.nodes;for(let r in n){let s=n[r];if(!s.allowsMarkType(t))continue;let i=[],o=l=>{i.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:u}=l.edge(a);if(c==e||i.indexOf(u)<0&&o(u))return!0}};if(o(s.contentMatch))return!0}}class Xr{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=Io(n).createDocumentFragment());let s=r,i=[];return e.forEach(o=>{if(i.length||o.marks.length){let l=0,a=0;for(;l<i.length&&a<o.marks.length;){let c=o.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(i[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<i.length;)s=i.pop()[1];for(;a<o.marks.length;){let c=o.marks[a++],u=this.serializeMark(c,o.isInline,n);u&&(i.push([c,s]),s.appendChild(u.dom),s=u.contentDOM||u.dom)}}s.appendChild(this.serializeNodeInner(o,n))}),r}serializeNodeInner(e,n){if(e.isText)return Io(n).createTextNode(e.text);let{dom:r,contentDOM:s}=sl(Io(n),this.nodes[e.type.name](e),null,e.attrs);if(s){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,s)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let s=e.marks.length-1;s>=0;s--){let i=this.serializeMark(e.marks[s],e.isInline,n);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,n,r={}){let s=this.marks[e.type.name];return s&&sl(Io(r),s(e,n),null,e.attrs)}static renderSpec(e,n,r=null,s){return typeof n=="string"?{dom:e.createTextNode(n)}:sl(e,n,r,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Xr(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=Yh(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return Yh(e.marks)}}function Yh(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Io(t){return t.document||window.document}const Xh=new WeakMap;function NS(t){let e=Xh.get(t);return e===void 0&&Xh.set(t,e=OS(t)),e}function OS(t){let e=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let s=0;s<r.length;s++)n(r[s]);else for(let s in r)n(r[s])}return n(t),e}function sl(t,e,n,r){if(e.nodeType==1)return{dom:e};if(e.dom&&e.dom.nodeType==1)return e;let s=e[0],i;if(typeof s!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(i=NS(r))&&i.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=s.indexOf(" ");o>0&&(n=s.slice(0,o),s=s.slice(o+1));let l,a=n?t.createElementNS(n,s):t.createElement(s),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let d in c)if(c[d]!=null){let f=d.indexOf(" ");f>0?a.setAttributeNS(d.slice(0,f),d.slice(f+1),c[d]):d=="style"&&a.style?a.style.cssText=c[d]:a.setAttribute(d,c[d])}}for(let d=u;d<e.length;d++){let f=e[d];if(f===0){if(d<e.length-1||d>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else if(typeof f=="string")a.appendChild(t.createTextNode(f));else{let{dom:h,contentDOM:p}=sl(t,f,n,r);if(a.appendChild(h),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}const Oy=65535,Iy=Math.pow(2,16);function IS(t,e){return t+e*Iy}function Zh(t){return t&Oy}function RS(t){return(t-(t&Oy))/Iy}const Ry=1,Dy=2,il=4,Ly=8;let Ru=class{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&Ly)>0}get deletedBefore(){return(this.delInfo&(Ry|il))>0}get deletedAfter(){return(this.delInfo&(Dy|il))>0}get deletedAcross(){return(this.delInfo&il)>0}},zr=class ls{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&ls.empty)return ls.empty}recover(e){let n=0,r=Zh(e);if(!this.inverted)for(let s=0;s<r;s++)n+=this.ranges[s*3+2]-this.ranges[s*3+1];return this.ranges[r*3]+n+RS(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let s=0,i=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?s:0);if(a>e)break;let c=this.ranges[l+i],u=this.ranges[l+o],d=a+c;if(e<=d){let f=c?e==a?-1:e==d?1:n:n,h=a+s+(f<0?0:u);if(r)return h;let p=e==(n<0?a:d)?null:IS(l/3,e-a),g=e==a?Dy:e==d?Ry:il;return(n<0?e!=a:e!=d)&&(g|=Ly),new Ru(h,g,p)}s+=u-c}return r?e+s:new Ru(e+s,0,null)}touches(e,n){let r=0,s=Zh(n),i=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+i],u=a+c;if(e<=u&&l==s*3)return!0;r+=this.ranges[l+o]-c}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let s=0,i=0;s<this.ranges.length;s+=3){let o=this.ranges[s],l=o-(this.inverted?i:0),a=o+(this.inverted?0:i),c=this.ranges[s+n],u=this.ranges[s+r];e(l,l+c,a,a+u),i+=u-c}}invert(){return new ls(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?ls.empty:new ls(e<0?[0,-e,0]:[0,0,e])}};zr.empty=new zr([]);class Ui{constructor(e,n,r=0,s=e?e.length:0){this.mirror=n,this.from=r,this.to=s,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new Ui(this._maps,this.mirror,e,n)}appendMap(e,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(e){for(let n=0,r=this._maps.length;n<e._maps.length;n++){let s=e.getMirror(n);this.appendMap(e._maps[n],s!=null&&s<n?r+s:void 0)}}getMirror(e){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==e)return this.mirror[n+(n%2?-1:1)]}}setMirror(e,n){this.mirror||(this.mirror=[]),this.mirror.push(e,n)}appendMappingInverted(e){for(let n=e.maps.length-1,r=this._maps.length+e._maps.length;n>=0;n--){let s=e.getMirror(n);this.appendMap(e._maps[n].invert(),s!=null&&s>n?r-s-1:void 0)}}invert(){let e=new Ui;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let s=0;for(let i=this.from;i<this.to;i++){let o=this._maps[i],l=o.mapResult(e,n);if(l.recover!=null){let a=this.getMirror(i);if(a!=null&&a>i&&a<this.to){i=a,e=this._maps[a].recover(l.recover);continue}}s|=l.delInfo,e=l.pos}return r?e:new Ru(e,s,null)}}const Tc=Object.create(null);let lt=class{getMap(){return zr.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Tc[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in Tc)throw new RangeError("Duplicate use of step JSON ID "+e);return Tc[e]=n,n.prototype.jsonID=e,n}},ht=class ii{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new ii(e,null)}static fail(e){return new ii(null,e)}static fromReplace(e,n,r,s){try{return ii.ok(e.replace(n,r,s))}catch(i){if(i instanceof $i)return ii.fail(i.message);throw i}}};function Jd(t,e,n){let r=[];for(let s=0;s<t.childCount;s++){let i=t.child(s);i.content.size&&(i=i.copy(Jd(i.content,e,i))),i.isInline&&(i=e(i,n,s)),r.push(i)}return j.fromArray(r)}let Gd=class oi extends lt{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),s=r.node(r.sharedDepth(this.to)),i=new K(Jd(n.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),s),n.openStart,n.openEnd);return ht.fromReplace(e,this.from,this.to,i)}invert(){return new $s(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new oi(n.pos,r.pos,this.mark)}merge(e){return e instanceof oi&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new oi(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new oi(n.from,n.to,e.markFromJSON(n.mark))}};lt.jsonID("addMark",Gd);let $s=class li extends lt{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new K(Jd(n.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),n.openStart,n.openEnd);return ht.fromReplace(e,this.from,this.to,r)}invert(){return new Gd(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new li(n.pos,r.pos,this.mark)}merge(e){return e instanceof li&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new li(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,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new li(n.from,n.to,e.markFromJSON(n.mark))}};lt.jsonID("removeMark",$s);let Yd=class ai extends lt{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return ht.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return ht.fromReplace(e,this.pos,this.pos+1,new K(j.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let s=0;s<n.marks.length;s++)if(!n.marks[s].isInSet(r))return new ai(this.pos,n.marks[s]);return new ai(this.pos,this.mark)}}return new Nl(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new ai(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new ai(n.pos,e.markFromJSON(n.mark))}};lt.jsonID("addNodeMark",Yd);let Nl=class Du extends lt{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return ht.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return ht.fromReplace(e,this.pos,this.pos+1,new K(j.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new Yd(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Du(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Du(n.pos,e.markFromJSON(n.mark))}};lt.jsonID("removeNodeMark",Nl);let Ft=class Gn extends lt{constructor(e,n,r,s=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=s}apply(e){return this.structure&&Lu(e,this.from,this.to)?ht.fail("Structure replace would overwrite content"):ht.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new zr([this.from,this.to-this.from,this.slice.size])}invert(e){return new Gn(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.to,-1),r=this.from==this.to&&Gn.MAP_BIAS<0?n:e.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new Gn(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Gn)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?K.empty:new K(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Gn(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?K.empty:new K(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Gn(e.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Gn(n.from,n.to,K.fromJSON(e,n.slice),!!n.structure)}};Ft.MAP_BIAS=1;lt.jsonID("replace",Ft);let kt=class ol extends lt{constructor(e,n,r,s,i,o,l=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=s,this.slice=i,this.insert=o,this.structure=l}apply(e){if(this.structure&&(Lu(e,this.from,this.gapFrom)||Lu(e,this.gapTo,this.to)))return ht.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return ht.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?ht.fromReplace(e,this.from,this.to,r):ht.fail("Content does not fit in gap")}getMap(){return new zr([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new ol(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),s=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||s<n.pos||i>r.pos?null:new ol(n.pos,r.pos,s,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new ol(n.from,n.to,n.gapFrom,n.gapTo,K.fromJSON(e,n.slice),n.insert,!!n.structure)}};lt.jsonID("replaceAround",kt);function Lu(t,e,n){let r=t.resolve(e),s=n-e,i=r.depth;for(;s>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,s--;if(s>0){let o=r.node(i).maybeChild(r.indexAfter(i));for(;s>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,s--}}return!1}function DS(t,e,n,r){let s=[],i=[],o,l;t.doc.nodesBetween(e,n,(a,c,u)=>{if(!a.isInline)return;let d=a.marks;if(!r.isInSet(d)&&u.type.allowsMarkType(r.type)){let f=Math.max(c,e),h=Math.min(c+a.nodeSize,n),p=r.addToSet(d);for(let g=0;g<d.length;g++)d[g].isInSet(p)||(o&&o.to==f&&o.mark.eq(d[g])?o.to=h:s.push(o=new $s(f,h,d[g])));l&&l.to==f?l.to=h:i.push(l=new Gd(f,h,r))}}),s.forEach(a=>t.step(a)),i.forEach(a=>t.step(a))}function LS(t,e,n,r){let s=[],i=0;t.doc.nodesBetween(e,n,(o,l)=>{if(!o.isInline)return;i++;let a=null;if(r instanceof Ha){let c=o.marks,u;for(;u=r.isInSet(c);)(a||(a=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(o.marks)&&(a=[r]):a=o.marks;if(a&&a.length){let c=Math.min(l+o.nodeSize,n);for(let u=0;u<a.length;u++){let d=a[u],f;for(let h=0;h<s.length;h++){let p=s[h];p.step==i-1&&d.eq(s[h].style)&&(f=p)}f?(f.to=c,f.step=i):s.push({style:d,from:Math.max(l,e),to:c,step:i})}}}),s.forEach(o=>t.step(new $s(o.from,o.to,o.style)))}function Xd(t,e,n,r=n.contentMatch,s=!0){let i=t.doc.nodeAt(e),o=[],l=e+1;for(let a=0;a<i.childCount;a++){let c=i.child(a),u=l+c.nodeSize,d=r.matchType(c.type);if(!d)o.push(new Ft(l,u,K.empty));else{r=d;for(let f=0;f<c.marks.length;f++)n.allowsMarkType(c.marks[f].type)||t.step(new $s(l,u,c.marks[f]));if(s&&c.isText&&n.whitespace!="pre"){let f,h=/\r?\n|\r/g,p;for(;f=h.exec(c.text);)p||(p=new K(j.from(n.schema.text(" ",n.allowedMarks(c.marks))),0,0)),o.push(new Ft(l+f.index,l+f.index+f[0].length,p))}}l=u}if(!r.validEnd){let a=r.fillBefore(j.empty,!0);t.replace(l,l,new K(a,0,0))}for(let a=o.length-1;a>=0;a--)t.step(o[a])}function jS(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function Hs(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,s=0,i=0;;--r){let o=t.$from.node(r),l=t.$from.index(r)+s,a=t.$to.indexAfter(r)-i;if(r<t.depth&&o.canReplace(l,a,n))return r;if(r==0||o.type.spec.isolating||!jS(o,l,a))break;l&&(s=1),a<o.childCount&&(i=1)}return null}function PS(t,e,n){let{$from:r,$to:s,depth:i}=e,o=r.before(i+1),l=s.after(i+1),a=o,c=l,u=j.empty,d=0;for(let p=i,g=!1;p>n;p--)g||r.index(p)>0?(g=!0,u=j.from(r.node(p).copy(u)),d++):a--;let f=j.empty,h=0;for(let p=i,g=!1;p>n;p--)g||s.after(p+1)<s.end(p)?(g=!0,f=j.from(s.node(p).copy(f)),h++):c++;t.step(new kt(a,c,o,l,new K(u.append(f),d,h),u.size-d,!0))}function Zd(t,e,n=null,r=t){let s=BS(t,e),i=s&&zS(r,e);return i?s.map(Qh).concat({type:e,attrs:n}).concat(i.map(Qh)):null}function Qh(t){return{type:t,attrs:null}}function BS(t,e){let{parent:n,startIndex:r,endIndex:s}=t,i=n.contentMatchAt(r).findWrapping(e);if(!i)return null;let o=i.length?i[0]:e;return n.canReplaceWith(r,s,o)?i:null}function zS(t,e){let{parent:n,startIndex:r,endIndex:s}=t,i=n.child(r),o=e.contentMatch.findWrapping(i.type);if(!o)return null;let a=(o.length?o[o.length-1]:e).contentMatch;for(let c=r;a&&c<s;c++)a=a.matchType(n.child(c).type);return!a||!a.validEnd?null:o}function $S(t,e,n){let r=j.empty;for(let o=n.length-1;o>=0;o--){if(r.size){let l=n[o].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=j.from(n[o].type.create(n[o].attrs,r))}let s=e.start,i=e.end;t.step(new kt(s,i,s,i,new K(r,0,0),n.length,!0))}function HS(t,e,n,r,s){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=t.steps.length;t.doc.nodesBetween(e,n,(o,l)=>{let a=typeof s=="function"?s(o):s;if(o.isTextblock&&!o.hasMarkup(r,a)&&FS(t.doc,t.mapping.slice(i).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let h=r.whitespace=="pre",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);h&&!p?c=!1:!h&&p&&(c=!0)}c===!1&&Py(t,o,l,i),Xd(t,t.mapping.slice(i).map(l,1),r,void 0,c===null);let u=t.mapping.slice(i),d=u.map(l,1),f=u.map(l+o.nodeSize,1);return t.step(new kt(d,f,d+1,f-1,new K(j.from(r.create(a,null,o.marks)),0,0),1,!0)),c===!0&&jy(t,o,l,i),!1}})}function jy(t,e,n,r){e.forEach((s,i)=>{if(s.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(s.text);){let a=t.mapping.slice(r).map(n+1+i+o.index);t.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Py(t,e,n,r){e.forEach((s,i)=>{if(s.type==s.type.schema.linebreakReplacement){let o=t.mapping.slice(r).map(n+1+i);t.replaceWith(o,o+1,e.type.schema.text(`
|
|
21
|
-
`))}})}function FS(t,e,n){let r=t.resolve(e),s=r.index();return r.parent.canReplaceWith(s,s+1,n)}function VS(t,e,n,r,s){let i=t.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");n||(n=i.type);let o=n.create(r,null,s||i.marks);if(i.isLeaf)return t.replaceWith(e,e+i.nodeSize,o);if(!n.validContent(i.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new kt(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new K(j.from(o),0,0),1,!0))}function Rn(t,e,n=1,r){let s=t.resolve(e),i=s.depth-n,o=r&&r[r.length-1]||s.parent;if(i<0||s.parent.type.spec.isolating||!s.parent.canReplace(s.index(),s.parent.childCount)||!o.type.validContent(s.parent.content.cutByIndex(s.index(),s.parent.childCount)))return!1;for(let c=s.depth-1,u=n-2;c>i;c--,u--){let d=s.node(c),f=s.index(c);if(d.type.spec.isolating)return!1;let h=d.content.cutByIndex(f,d.childCount),p=r&&r[u+1];p&&(h=h.replaceChild(0,p.type.create(p.attrs)));let g=r&&r[u]||d;if(!d.canReplace(f+1,d.childCount)||!g.type.validContent(h))return!1}let l=s.indexAfter(i),a=r&&r[0];return s.node(i).canReplaceWith(l,l,a?a.type:s.node(i+1).type)}function US(t,e,n=1,r){let s=t.doc.resolve(e),i=j.empty,o=j.empty;for(let l=s.depth,a=s.depth-n,c=n-1;l>a;l--,c--){i=j.from(s.node(l).copy(i));let u=r&&r[c];o=j.from(u?u.type.create(u.attrs,o):s.node(l).copy(o))}t.step(new Ft(e,e,new K(i.append(o),n,n),!0))}function gr(t,e){let n=t.resolve(e),r=n.index();return By(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function WS(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let s=0;s<e.childCount;s++){let i=e.child(s),o=i.type==r?t.type.schema.nodes.text:i.type;if(n=n.matchType(o),!n||!t.type.allowsMarks(i.marks))return!1}return n.validEnd}function By(t,e){return!!(t&&e&&!t.isLeaf&&WS(t,e))}function Fa(t,e,n=-1){let r=t.resolve(e);for(let s=r.depth;;s--){let i,o,l=r.index(s);if(s==r.depth?(i=r.nodeBefore,o=r.nodeAfter):n>0?(i=r.node(s+1),l++,o=r.node(s).maybeChild(l)):(i=r.node(s).maybeChild(l-1),o=r.node(s+1)),i&&!i.isTextblock&&By(i,o)&&r.node(s).canReplace(l,l+1))return e;if(s==0)break;e=n<0?r.before(s):r.after(s)}}function qS(t,e,n){let r=null,{linebreakReplacement:s}=t.doc.type.schema,i=t.doc.resolve(e-n),o=i.node().type;if(s&&o.inlineContent){let u=o.whitespace=="pre",d=!!o.contentMatch.matchType(s);u&&!d?r=!1:!u&&d&&(r=!0)}let l=t.steps.length;if(r===!1){let u=t.doc.resolve(e+n);Py(t,u.node(),u.before(),l)}o.inlineContent&&Xd(t,e+n-1,o,i.node().contentMatchAt(i.index()),r==null);let a=t.mapping.slice(l),c=a.map(e-n);if(t.step(new Ft(c,a.map(e+n,-1),K.empty,!0)),r===!0){let u=t.doc.resolve(c);jy(t,u.node(),u.before(),t.steps.length)}return t}function KS(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let s=r.depth-1;s>=0;s--){let i=r.index(s);if(r.node(s).canReplaceWith(i,i,n))return r.before(s+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(let s=r.depth-1;s>=0;s--){let i=r.indexAfter(s);if(r.node(s).canReplaceWith(i,i,n))return r.after(s+1);if(i<r.node(s).childCount)return null}return null}function zy(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let s=n.content;for(let i=0;i<n.openStart;i++)s=s.firstChild.content;for(let i=1;i<=(n.openStart==0&&n.size?2:1);i++)for(let o=r.depth;o>=0;o--){let l=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,a=r.index(o)+(l>0?1:0),c=r.node(o),u=!1;if(i==1)u=c.canReplace(a,a,s);else{let d=c.contentMatchAt(a).findWrapping(s.firstChild.type);u=d&&c.canReplaceWith(a,a,d[0])}if(u)return l==0?r.pos:l<0?r.before(o+1):r.after(o+1)}return null}function Va(t,e,n=e,r=K.empty){if(e==n&&!r.size)return null;let s=t.resolve(e),i=t.resolve(n);return $y(s,i,r)?new Ft(e,n,r):new JS(s,i,r).fit()}function $y(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class JS{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=j.empty;for(let s=0;s<=e.depth;s++){let i=e.node(s);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(s))})}for(let s=e.depth;s>0;s--)this.placed=j.from(e.node(s).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,s=this.close(e<0?this.$to:r.doc.resolve(e));if(!s)return null;let i=this.placed,o=r.depth,l=s.depth;for(;o&&l&&i.childCount==1;)i=i.firstChild.content,o--,l--;let a=new K(i,o,l);return e>-1?new kt(r.pos,e,this.$to.pos,this.$to.end(),a,n):a.size||r.pos!=this.$to.pos?new Ft(r.pos,s.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,s=this.unplaced.openEnd;r<e;r++){let i=n.firstChild;if(n.childCount>1&&(s=0),i.type.spec.isolating&&s<=r){e=r;break}n=i.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let s,i=null;r?(i=Ac(this.unplaced.content,r-1).firstChild,s=i.content):s=this.unplaced.content;let o=s.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],u,d=null;if(n==1&&(o?c.matchType(o.type)||(d=c.fillBefore(j.from(o),!1)):i&&a.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:l,parent:i,inject:d};if(n==2&&o&&(u=c.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:l,parent:i,wrap:u};if(i&&c.matchType(i.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,s=Ac(e,n);return!s.childCount||s.firstChild.isLeaf?!1:(this.unplaced=new K(e,n+1,Math.max(r,s.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,s=Ac(e,n);if(s.childCount<=1&&n>0){let i=e.size-n<=n+s.size;this.unplaced=new K(ci(e,n-1,1),n-1,i?n-1:r)}else this.unplaced=new K(ci(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:s,wrap:i}){for(;this.depth>n;)this.closeFrontierNode();if(i)for(let g=0;g<i.length;g++)this.openFrontierNode(i[g]);let o=this.unplaced,l=r?r.content:o.content,a=o.openStart-e,c=0,u=[],{match:d,type:f}=this.frontier[n];if(s){for(let g=0;g<s.childCount;g++)u.push(s.child(g));d=d.matchFragment(s)}let h=l.size+e-(o.content.size-o.openEnd);for(;c<l.childCount;){let g=l.child(c),y=d.matchType(g.type);if(!y)break;c++,(c>1||a==0||g.content.size)&&(d=y,u.push(Hy(g.mark(f.allowedMarks(g.marks)),c==1?a:0,c==l.childCount?h:-1)))}let p=c==l.childCount;p||(h=-1),this.placed=ui(this.placed,n,j.from(u)),this.frontier[n].match=d,p&&h<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let g=0,y=l;g<h;g++){let b=y.lastChild;this.frontier.push({type:b.type,match:b.contentMatchAt(b.childCount)}),y=b.content}this.unplaced=p?e==0?K.empty:new K(ci(o.content,e-1,1),e-1,h<0?o.openEnd:e-1):new K(ci(o.content,e,c),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!_c(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.depth==this.depth)return-1;let{depth:r}=this.$to,s=this.$to.after(r);for(;r>1&&s==this.$to.end(--r);)++s;return s}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:s}=this.frontier[n],i=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),o=_c(e,n,s,r,i);if(o){for(let l=n-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],u=_c(e,l,c,a,!0);if(!u||u.childCount)continue e}return{depth:n,fit:o,move:i?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=ui(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let s=e.node(r),i=s.type.contentMatch.fillBefore(s.content,!0,e.index(r));this.openFrontierNode(s.type,s.attrs,i)}return e}openFrontierNode(e,n=null,r){let s=this.frontier[this.depth];s.match=s.match.matchType(e),this.placed=ui(this.placed,this.depth,j.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(j.empty,!0);n.childCount&&(this.placed=ui(this.placed,this.frontier.length,n))}}function ci(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(ci(t.firstChild.content,e-1,n)))}function ui(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(ui(t.lastChild.content,e-1,n)))}function Ac(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function Hy(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,Hy(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(j.empty,!0)))),t.copy(r)}function _c(t,e,n,r,s){let i=t.node(e),o=s?t.indexAfter(e):t.index(e);if(o==i.childCount&&!n.compatibleContent(i.type))return null;let l=r.fillBefore(i.content,!0,o);return l&&!GS(n,i.content,o)?l:null}function GS(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function YS(t){return t.spec.defining||t.spec.definingForContent}function XS(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let s=t.doc.resolve(e),i=t.doc.resolve(n);if($y(s,i,r))return t.step(new Ft(e,n,r));let o=Vy(s,i);o[o.length-1]==0&&o.pop();let l=-(s.depth+1);o.unshift(l);for(let f=s.depth,h=s.pos-1;f>0;f--,h--){let p=s.node(f).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;o.indexOf(f)>-1?l=f:s.before(f)==h&&o.splice(1,0,-f)}let a=o.indexOf(l),c=[],u=r.openStart;for(let f=r.content,h=0;;h++){let p=f.firstChild;if(c.push(p),h==r.openStart)break;f=p.content}for(let f=u-1;f>=0;f--){let h=c[f],p=YS(h.type);if(p&&!h.sameMarkup(s.node(Math.abs(l)-1)))u=f;else if(p||!h.type.isTextblock)break}for(let f=r.openStart;f>=0;f--){let h=(f+u+1)%(r.openStart+1),p=c[h];if(p)for(let g=0;g<o.length;g++){let y=o[(g+a)%o.length],b=!0;y<0&&(b=!1,y=-y);let w=s.node(y-1),v=s.index(y-1);if(w.canReplaceWith(v,v,p.type,p.marks))return t.replace(s.before(y),b?i.after(y):n,new K(Fy(r.content,0,r.openStart,h),h,r.openEnd))}}let d=t.steps.length;for(let f=o.length-1;f>=0&&(t.replace(e,n,r),!(t.steps.length>d));f--){let h=o[f];h<0||(e=s.before(h),n=i.after(h))}}function Fy(t,e,n,r,s){if(e<n){let i=t.firstChild;t=t.replaceChild(0,i.copy(Fy(i.content,e+1,n,r,i)))}if(e>r){let i=s.contentMatchAt(0),o=i.fillBefore(t).append(t);t=o.append(i.matchFragment(o).fillBefore(j.empty,!0))}return t}function ZS(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let s=KS(t.doc,e,r.type);s!=null&&(e=n=s)}t.replaceRange(e,n,new K(j.from(r),0,0))}function QS(t,e,n){let r=t.doc.resolve(e),s=t.doc.resolve(n);if(r.parent.isTextblock&&s.parent.isTextblock&&r.start()!=s.start()&&r.parentOffset==0&&s.parentOffset==0){let o=r.sharedDepth(n),l=!1;for(let a=r.depth;a>o;a--)r.node(a).type.spec.isolating&&(l=!0);for(let a=s.depth;a>o;a--)s.node(a).type.spec.isolating&&(l=!0);if(!l){for(let a=r.depth;a>0&&e==r.start(a);a--)e=r.before(a);for(let a=s.depth;a>0&&n==s.start(a);a--)n=s.before(a);r=t.doc.resolve(e),s=t.doc.resolve(n)}}let i=Vy(r,s);for(let o=0;o<i.length;o++){let l=i[o],a=o==i.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return t.delete(r.start(l),s.end(l));if(l>0&&(a||r.node(l-1).canReplace(r.index(l-1),s.indexAfter(l-1))))return t.delete(r.before(l),s.after(l))}for(let o=1;o<=r.depth&&o<=s.depth;o++)if(e-r.start(o)==r.depth-o&&n>r.end(o)&&s.end(o)-n!=s.depth-o&&r.start(o-1)==s.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),s.index(o-1)))return t.delete(r.before(o),n);t.delete(e,n)}function Vy(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let s=r;s>=0;s--){let i=t.start(s);if(i<t.pos-(t.depth-s)||e.end(s)>e.pos+(e.depth-s)||t.node(s).type.spec.isolating||e.node(s).type.spec.isolating)break;(i==e.start(s)||s==t.depth&&s==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&s&&e.start(s-1)==i-1)&&n.push(s)}return n}let Uy=class ll extends lt{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return ht.fail("No node at attribute step's position");let r=Object.create(null);for(let i in n.attrs)r[i]=n.attrs[i];r[this.attr]=this.value;let s=n.type.create(r,null,n.marks);return ht.fromReplace(e,this.pos,this.pos+1,new K(j.from(s),0,n.isLeaf?0:1))}getMap(){return zr.empty}invert(e){return new ll(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new ll(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new ll(n.pos,n.attr,n.value)}};lt.jsonID("attr",Uy);let Wy=class ju extends lt{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let s in e.attrs)n[s]=e.attrs[s];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return ht.ok(r)}getMap(){return zr.empty}invert(e){return new ju(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new ju(n.attr,n.value)}};lt.jsonID("docAttr",Wy);let ks=class extends Error{};ks=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};ks.prototype=Object.create(Error.prototype);ks.prototype.constructor=ks;ks.prototype.name="TransformError";class Qd{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Ui}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new ks(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,n=-1e9;for(let r=0;r<this.mapping.maps.length;r++){let s=this.mapping.maps[r];r&&(e=s.map(e,1),n=s.map(n,-1)),s.forEach((i,o,l,a)=>{e=Math.min(e,l),n=Math.max(n,a)})}return e==1e9?null:{from:e,to:n}}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=K.empty){let s=Va(this.doc,e,n,r);return s&&this.step(s),this}replaceWith(e,n,r){return this.replace(e,n,new K(j.from(r),0,0))}delete(e,n){return this.replace(e,n,K.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return XS(this,e,n,r),this}replaceRangeWith(e,n,r){return ZS(this,e,n,r),this}deleteRange(e,n){return QS(this,e,n),this}lift(e,n){return PS(this,e,n),this}join(e,n=1){return qS(this,e,n),this}wrap(e,n){return $S(this,e,n),this}setBlockType(e,n=e,r,s=null){return HS(this,e,n,r,s),this}setNodeMarkup(e,n,r=null,s){return VS(this,e,n,r,s),this}setNodeAttribute(e,n,r){return this.step(new Uy(e,n,r)),this}setDocAttribute(e,n){return this.step(new Wy(e,n)),this}addNodeMark(e,n){return this.step(new Yd(e,n)),this}removeNodeMark(e,n){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n instanceof xe)n.isInSet(r.marks)&&this.step(new Nl(e,n));else{let s=r.marks,i,o=[];for(;i=n.isInSet(s);)o.push(new Nl(e,i)),s=i.removeFromSet(s);for(let l=o.length-1;l>=0;l--)this.step(o[l])}return this}split(e,n=1,r){return US(this,e,n,r),this}addMark(e,n,r){return DS(this,e,n,r),this}removeMark(e,n,r){return LS(this,e,n,r),this}clearIncompatible(e,n,r){return Xd(this,e,n,r),this}}const Nc=Object.create(null);let te=class{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new ef(e.min(n),e.max(n))]}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 n=0;n<e.length;n++)if(e[n].$from.pos!=e[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,n=K.empty){let r=n.content.lastChild,s=null;for(let l=0;l<n.openEnd;l++)s=r,r=r.lastChild;let i=e.steps.length,o=this.ranges;for(let l=0;l<o.length;l++){let{$from:a,$to:c}=o[l],u=e.mapping.slice(i);e.replaceRange(u.map(a.pos),u.map(c.pos),l?K.empty:n),l==0&&np(e,i,(r?r.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,s=this.ranges;for(let i=0;i<s.length;i++){let{$from:o,$to:l}=s[i],a=e.mapping.slice(r),c=a.map(o.pos),u=a.map(l.pos);i?e.deleteRange(c,u):(e.replaceRangeWith(c,u,n),np(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let s=e.parent.inlineContent?new ee(e):as(e.node(0),e.parent,e.pos,e.index(),n,r);if(s)return s;for(let i=e.depth-1;i>=0;i--){let o=n<0?as(e.node(0),e.node(i),e.before(i+1),e.index(i),n,r):as(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,n,r);if(o)return o}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new dn(e.node(0))}static atStart(e){return as(e,e,0,0,1)||new dn(e)}static atEnd(e){return as(e,e,e.content.size,e.childCount,-1)||new dn(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Nc[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in Nc)throw new RangeError("Duplicate use of selection JSON ID "+e);return Nc[e]=n,n.prototype.jsonID=e,n}getBookmark(){return ee.between(this.$anchor,this.$head).getBookmark()}};te.prototype.visible=!0;let ef=class{constructor(e,n){this.$from=e,this.$to=n}},ep=!1;function tp(t){!ep&&!t.parent.inlineContent&&(ep=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}let ee=class di extends te{constructor(e,n=e){tp(e),tp(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return te.near(r);let s=e.resolve(n.map(this.anchor));return new di(s.parent.inlineContent?s:r,r)}replace(e,n=K.empty){if(super.replace(e,n),n==K.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof di&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new qy(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new di(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let s=e.resolve(n);return new this(s,r==n?s:e.resolve(r))}static between(e,n,r){let s=e.pos-n.pos;if((!r||s)&&(r=s>=0?1:-1),!n.parent.inlineContent){let i=te.findFrom(n,r,!0)||te.findFrom(n,-r,!0);if(i)n=i.$head;else return te.near(n,r)}return e.parent.inlineContent||(s==0?e=n:(e=(te.findFrom(e,-r,!0)||te.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=s<0&&(e=n))),new di(e,n)}};te.jsonID("text",ee);let qy=class Ky{constructor(e,n){this.anchor=e,this.head=n}map(e){return new Ky(e.map(this.anchor),e.map(this.head))}resolve(e){return ee.between(e.resolve(this.anchor),e.resolve(this.head))}},Y=class fi extends te{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:s}=n.mapResult(this.anchor),i=e.resolve(s);return r?te.near(i):new fi(i)}content(){return new K(j.from(this.node),0,0)}eq(e){return e instanceof fi&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new eC(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new fi(e.resolve(n.anchor))}static create(e,n){return new fi(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}};Y.prototype.visible=!1;te.jsonID("node",Y);let eC=class Jy{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new qy(r,r):new Jy(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&Y.isSelectable(r)?new Y(n):te.near(n)}},dn=class al extends te{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=K.empty){if(n==K.empty){e.delete(0,e.doc.content.size);let r=te.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new al(e)}map(e){return new al(e)}eq(e){return e instanceof al}getBookmark(){return tC}};te.jsonID("all",dn);const tC={map(){return this},resolve(t){return new dn(t)}};function as(t,e,n,r,s,i=!1){if(e.inlineContent)return ee.create(t,n);for(let o=r-(s>0?0:1);s>0?o<e.childCount:o>=0;o+=s){let l=e.child(o);if(l.isAtom){if(!i&&Y.isSelectable(l))return Y.create(t,n-(s<0?l.nodeSize:0))}else{let a=as(t,l,n+s,s<0?l.childCount:0,s,i);if(a)return a}n+=l.nodeSize*s}return null}function np(t,e,n){let r=t.steps.length-1;if(r<e)return;let s=t.steps[r];if(!(s instanceof Ft||s instanceof kt))return;let i=t.mapping.maps[r],o;i.forEach((l,a,c,u)=>{o==null&&(o=u)}),t.setSelection(te.near(t.doc.resolve(o),n))}const rp=1,Ro=2,sp=4;let nC=class extends Qd{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|rp)&~Ro,this.storedMarks=null,this}get selectionSet(){return(this.updated&rp)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Ro,this}ensureMarks(e){return xe.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&Ro)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~Ro,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||xe.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let s=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(s.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let i=this.storedMarks;if(!i){let o=this.doc.resolve(n);i=r==n?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,s.text(e,i)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(te.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=sp,this}get scrolledIntoView(){return(this.updated&sp)>0}};function ip(t,e){return!e||!t?t:t.bind(e)}let hi=class{constructor(e,n,r){this.name=e,this.init=ip(n.init,r),this.apply=ip(n.apply,r)}};const rC=[new hi("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new hi("selection",{init(t,e){return t.selection||te.atStart(e.doc)},apply(t){return t.selection}}),new hi("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new hi("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class Oc{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=rC.slice(),n&&n.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new hi(r.key,r.spec.state,r))})}}class ps{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,n=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=n){let s=this.config.plugins[r];if(s.spec.filterTransaction&&!s.spec.filterTransaction.call(s,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],r=this.applyInner(e),s=null;for(;;){let i=!1;for(let o=0;o<this.config.plugins.length;o++){let l=this.config.plugins[o];if(l.spec.appendTransaction){let a=s?s[o].n:0,c=s?s[o].state:this,u=a<n.length&&l.spec.appendTransaction.call(l,a?n.slice(a):n,c,r);if(u&&r.filterTransaction(u,o)){if(u.setMeta("appendedTransaction",e),!s){s=[];for(let d=0;d<this.config.plugins.length;d++)s.push(d<o?{state:r,n:n.length}:{state:this,n:0})}n.push(u),r=r.applyInner(u),i=!0}s&&(s[o]={state:r,n:n.length})}}if(!i)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new ps(this.config),r=this.config.fields;for(let s=0;s<r.length;s++){let i=r[s];n[i.name]=i.apply(e,this[i.name],this,n)}return n}get tr(){return new nC(this)}static create(e){let n=new Oc(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new ps(n);for(let s=0;s<n.fields.length;s++)r[n.fields[s].name]=n.fields[s].init(e,r);return r}reconfigure(e){let n=new Oc(this.schema,e.plugins),r=n.fields,s=new ps(n);for(let i=0;i<r.length;i++){let o=r[i].name;s[o]=this.hasOwnProperty(o)?this[o]:r[i].init(e,s)}return s}toJSON(e){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let s=e[r],i=s.spec.state;i&&i.toJSON&&(n[r]=i.toJSON.call(s,this[s.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let s=new Oc(e.schema,e.plugins),i=new ps(s);return s.fields.forEach(o=>{if(o.name=="doc")i.doc=ir.fromJSON(e.schema,n.doc);else if(o.name=="selection")i.selection=te.fromJSON(i.doc,n.selection);else if(o.name=="storedMarks")n.storedMarks&&(i.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==o.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(n,l)){i[o.name]=c.fromJSON.call(a,e,n[l],i);return}}i[o.name]=o.init(e,i)}}),i}}function Gy(t,e,n){for(let r in t){let s=t[r];s instanceof Function?s=s.bind(e):r=="handleDOMEvents"&&(s=Gy(s,e,{})),n[r]=s}return n}class ce{constructor(e){this.spec=e,this.props={},e.props&&Gy(e.props,this,this.props),this.key=e.key?e.key.key:Yy("plugin")}getState(e){return e[this.key]}}const Ic=Object.create(null);function Yy(t){return t in Ic?t+"$"+ ++Ic[t]:(Ic[t]=0,t+"$")}class ae{constructor(e="key"){this.key=Yy(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Xy=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function Zy(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const Qy=(t,e,n)=>{let r=Zy(t,n);if(!r)return!1;let s=tf(r);if(!s){let o=r.blockRange(),l=o&&Hs(o);return l==null?!1:(e&&e(t.tr.lift(o,l).scrollIntoView()),!0)}let i=s.nodeBefore;if(ab(t,s,e,-1))return!0;if(r.parent.content.size==0&&(Ss(i,"end")||Y.isSelectable(i)))for(let o=r.depth;;o--){let l=Va(t.doc,r.before(o),r.after(o),K.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=t.tr.step(l);a.setSelection(Ss(i,"end")?te.findFrom(a.doc.resolve(a.mapping.map(s.pos,-1)),-1):Y.create(a.doc,s.pos-i.nodeSize)),e(a.scrollIntoView())}return!0}if(o==1||r.node(o-1).childCount>1)break}return i.isAtom&&s.depth==r.depth-1?(e&&e(t.tr.delete(s.pos-i.nodeSize,s.pos).scrollIntoView()),!0):!1},sC=(t,e,n)=>{let r=Zy(t,n);if(!r)return!1;let s=tf(r);return s?eb(t,s,e):!1},iC=(t,e,n)=>{let r=nb(t,n);if(!r)return!1;let s=nf(r);return s?eb(t,s,e):!1};function eb(t,e,n){let r=e.nodeBefore,s=r,i=e.pos-1;for(;!s.isTextblock;i--){if(s.type.spec.isolating)return!1;let u=s.lastChild;if(!u)return!1;s=u}let o=e.nodeAfter,l=o,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let u=l.firstChild;if(!u)return!1;l=u}let c=Va(t.doc,i,a,K.empty);if(!c||c.from!=i||c instanceof Ft&&c.slice.size>=a-i)return!1;if(n){let u=t.tr.step(c);u.setSelection(ee.create(u.doc,i)),n(u.scrollIntoView())}return!0}function Ss(t,e,n=!1){for(let r=t;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}const tb=(t,e,n)=>{let{$head:r,empty:s}=t.selection,i=r;if(!s)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;i=tf(r)}let o=i&&i.nodeBefore;return!o||!Y.isSelectable(o)?!1:(e&&e(t.tr.setSelection(Y.create(t.doc,i.pos-o.nodeSize)).scrollIntoView()),!0)};function tf(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function nb(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const rb=(t,e,n)=>{let r=nb(t,n);if(!r)return!1;let s=nf(r);if(!s)return!1;let i=s.nodeAfter;if(ab(t,s,e,1))return!0;if(r.parent.content.size==0&&(Ss(i,"start")||Y.isSelectable(i))){let o=Va(t.doc,r.before(),r.after(),K.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=t.tr.step(o);l.setSelection(Ss(i,"start")?te.findFrom(l.doc.resolve(l.mapping.map(s.pos)),1):Y.create(l.doc,l.mapping.map(s.pos))),e(l.scrollIntoView())}return!0}}return i.isAtom&&s.depth==r.depth-1?(e&&e(t.tr.delete(s.pos,s.pos+i.nodeSize).scrollIntoView()),!0):!1},sb=(t,e,n)=>{let{$head:r,empty:s}=t.selection,i=r;if(!s)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;i=nf(r)}let o=i&&i.nodeAfter;return!o||!Y.isSelectable(o)?!1:(e&&e(t.tr.setSelection(Y.create(t.doc,i.pos)).scrollIntoView()),!0)};function nf(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let n=t.node(e);if(t.index(e)+1<n.childCount)return t.doc.resolve(t.after(e+1));if(n.type.spec.isolating)break}return null}const oC=(t,e)=>{let n=t.selection,r=n instanceof Y,s;if(r){if(n.node.isTextblock||!gr(t.doc,n.from))return!1;s=n.from}else if(s=Fa(t.doc,n.from,-1),s==null)return!1;if(e){let i=t.tr.join(s);r&&i.setSelection(Y.create(i.doc,s-t.doc.resolve(s).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},lC=(t,e)=>{let n=t.selection,r;if(n instanceof Y){if(n.node.isTextblock||!gr(t.doc,n.to))return!1;r=n.to}else if(r=Fa(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},aC=(t,e)=>{let{$from:n,$to:r}=t.selection,s=n.blockRange(r),i=s&&Hs(s);return i==null?!1:(e&&e(t.tr.lift(s,i).scrollIntoView()),!0)},ib=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
|
|
22
|
-
`).scrollIntoView()),!0)};function rf(t){for(let e=0;e<t.edgeCount;e++){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}const cC=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let s=n.node(-1),i=n.indexAfter(-1),o=rf(s.contentMatchAt(i));if(!o||!s.canReplaceWith(i,i,o))return!1;if(e){let l=n.after(),a=t.tr.replaceWith(l,l,o.createAndFill());a.setSelection(te.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},ob=(t,e)=>{let n=t.selection,{$from:r,$to:s}=n;if(n instanceof dn||r.parent.inlineContent||s.parent.inlineContent)return!1;let i=rf(s.parent.contentMatchAt(s.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let o=(!r.parentOffset&&s.index()<s.parent.childCount?r:s).pos,l=t.tr.insert(o,i.createAndFill());l.setSelection(ee.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},lb=(t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let i=n.before();if(Rn(t.doc,i))return e&&e(t.tr.split(i).scrollIntoView()),!0}let r=n.blockRange(),s=r&&Hs(r);return s==null?!1:(e&&e(t.tr.lift(r,s).scrollIntoView()),!0)};function uC(t){return(e,n)=>{let{$from:r,$to:s}=e.selection;if(e.selection instanceof Y&&e.selection.node.isBlock)return!r.parentOffset||!Rn(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let i=[],o,l,a=!1,c=!1;for(let h=r.depth;;h--)if(r.node(h).isBlock){a=r.end(h)==r.pos+(r.depth-h),c=r.start(h)==r.pos-(r.depth-h),l=rf(r.node(h-1).contentMatchAt(r.indexAfter(h-1))),i.unshift(a&&l?{type:l}:null),o=h;break}else{if(h==1)return!1;i.unshift(null)}let u=e.tr;(e.selection instanceof ee||e.selection instanceof dn)&&u.deleteSelection();let d=u.mapping.map(r.pos),f=Rn(u.doc,d,i.length,i);if(f||(i[0]=l?{type:l}:null,f=Rn(u.doc,d,i.length,i)),!f)return!1;if(u.split(d,i.length,i),!a&&c&&r.node(o).type!=l){let h=u.mapping.map(r.before(o)),p=u.doc.resolve(h);l&&r.node(o-1).canReplaceWith(p.index(),p.index()+1,l)&&u.setNodeMarkup(u.mapping.map(r.before(o)),l)}return n&&n(u.scrollIntoView()),!0}}const dC=uC(),fC=(t,e)=>{let{$from:n,to:r}=t.selection,s,i=n.sharedDepth(r);return i==0?!1:(s=n.before(i),e&&e(t.tr.setSelection(Y.create(t.doc,s))),!0)};function hC(t,e,n){let r=e.nodeBefore,s=e.nodeAfter,i=e.index();return!r||!s||!r.type.compatibleContent(s.type)?!1:!r.content.size&&e.parent.canReplace(i-1,i)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(s.isTextblock||gr(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function ab(t,e,n,r){let s=e.nodeBefore,i=e.nodeAfter,o,l,a=s.type.spec.isolating||i.type.spec.isolating;if(!a&&hC(t,e,n))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(o=(l=s.contentMatchAt(s.childCount)).findWrapping(i.type))&&l.matchType(o[0]||i.type).validEnd){if(n){let h=e.pos+i.nodeSize,p=j.empty;for(let b=o.length-1;b>=0;b--)p=j.from(o[b].create(null,p));p=j.from(s.copy(p));let g=t.tr.step(new kt(e.pos-1,h,e.pos,h,new K(p,1,0),o.length,!0)),y=g.doc.resolve(h+2*o.length);y.nodeAfter&&y.nodeAfter.type==s.type&&gr(g.doc,y.pos)&&g.join(y.pos),n(g.scrollIntoView())}return!0}let u=i.type.spec.isolating||r>0&&a?null:te.findFrom(e,1),d=u&&u.$from.blockRange(u.$to),f=d&&Hs(d);if(f!=null&&f>=e.depth)return n&&n(t.tr.lift(d,f).scrollIntoView()),!0;if(c&&Ss(i,"start",!0)&&Ss(s,"end")){let h=s,p=[];for(;p.push(h),!h.isTextblock;)h=h.lastChild;let g=i,y=1;for(;!g.isTextblock;g=g.firstChild)y++;if(h.canReplace(h.childCount,h.childCount,g.content)){if(n){let b=j.empty;for(let v=p.length-1;v>=0;v--)b=j.from(p[v].copy(b));let w=t.tr.step(new kt(e.pos-p.length,e.pos+i.nodeSize,e.pos+y,e.pos+i.nodeSize-y,new K(b,p.length,0),0,!0));n(w.scrollIntoView())}return!0}}return!1}function cb(t){return function(e,n){let r=e.selection,s=t<0?r.$from:r.$to,i=s.depth;for(;s.node(i).isInline;){if(!i)return!1;i--}return s.node(i).isTextblock?(n&&n(e.tr.setSelection(ee.create(e.doc,t<0?s.start(i):s.end(i)))),!0):!1}}const pC=cb(-1),mC=cb(1);function gC(t,e=null){return function(n,r){let{$from:s,$to:i}=n.selection,o=s.blockRange(i),l=o&&Zd(o,t,e);return l?(r&&r(n.tr.wrap(o,l).scrollIntoView()),!0):!1}}function op(t,e=null){return function(n,r){let s=!1;for(let i=0;i<n.selection.ranges.length&&!s;i++){let{$from:{pos:o},$to:{pos:l}}=n.selection.ranges[i];n.doc.nodesBetween(o,l,(a,c)=>{if(s)return!1;if(!(!a.isTextblock||a.hasMarkup(t,e)))if(a.type==t)s=!0;else{let u=n.doc.resolve(c),d=u.index();s=u.parent.canReplaceWith(d,d+1,t)}})}if(!s)return!1;if(r){let i=n.tr;for(let o=0;o<n.selection.ranges.length;o++){let{$from:{pos:l},$to:{pos:a}}=n.selection.ranges[o];i.setBlockType(l,a,t,e)}r(i.scrollIntoView())}return!0}}function sf(...t){return function(e,n,r){for(let s=0;s<t.length;s++)if(t[s](e,n,r))return!0;return!1}}sf(Xy,Qy,tb);sf(Xy,rb,sb);sf(ib,ob,lb,dC);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function yC(t,e=null){return function(n,r){let{$from:s,$to:i}=n.selection,o=s.blockRange(i);if(!o)return!1;let l=r?n.tr:null;return bC(l,o,t,e)?(r&&r(l.scrollIntoView()),!0):!1}}function bC(t,e,n,r=null){let s=!1,i=e,o=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=o.resolve(e.start-2);i=new Fi(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new Fi(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),s=!0}let l=Zd(i,n,r,e);return l?(t&&wC(t,e,l,s,n),!0):!1}function wC(t,e,n,r,s){let i=j.empty;for(let u=n.length-1;u>=0;u--)i=j.from(n[u].type.create(n[u].attrs,i));t.step(new kt(e.start-(r?2:0),e.end,e.start,e.end,new K(i,0,0),n.length,!0));let o=0;for(let u=0;u<n.length;u++)n[u].type==s&&(o=u+1);let l=n.length-o,a=e.start+n.length-(r?2:0),c=e.parent;for(let u=e.startIndex,d=e.endIndex,f=!0;u<d;u++,f=!1)!f&&Rn(t.doc,a,l)&&(t.split(a,l),a+=2*l),a+=c.child(u).nodeSize;return t}function xC(t){return function(e,n){let{$from:r,$to:s}=e.selection,i=r.blockRange(s,o=>o.childCount>0&&o.firstChild.type==t);return i?n?r.node(i.depth-1).type==t?vC(e,n,t,i):kC(e,n,i):!0:!1}}function vC(t,e,n,r){let s=t.tr,i=r.end,o=r.$to.end(r.depth);i<o&&(s.step(new kt(i-1,o,i,o,new K(j.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new Fi(s.doc.resolve(r.$from.pos),s.doc.resolve(o),r.depth));const l=Hs(r);if(l==null)return!1;s.lift(r,l);let a=s.doc.resolve(s.mapping.map(i,-1)-1);return gr(s.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&s.join(a.pos),e(s.scrollIntoView()),!0}function kC(t,e,n){let r=t.tr,s=n.parent;for(let h=n.end,p=n.endIndex-1,g=n.startIndex;p>g;p--)h-=s.child(p).nodeSize,r.delete(h-1,h+1);let i=r.doc.resolve(n.start),o=i.nodeAfter;if(r.mapping.map(n.end)!=n.start+i.nodeAfter.nodeSize)return!1;let l=n.startIndex==0,a=n.endIndex==s.childCount,c=i.node(-1),u=i.index(-1);if(!c.canReplace(u+(l?0:1),u+1,o.content.append(a?j.empty:j.from(s))))return!1;let d=i.pos,f=d+o.nodeSize;return r.step(new kt(d-(l?1:0),f+(a?1:0),d+1,f-1,new K((l?j.empty:j.from(s.copy(j.empty))).append(a?j.empty:j.from(s.copy(j.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function SC(t){return function(e,n){let{$from:r,$to:s}=e.selection,i=r.blockRange(s,c=>c.childCount>0&&c.firstChild.type==t);if(!i)return!1;let o=i.startIndex;if(o==0)return!1;let l=i.parent,a=l.child(o-1);if(a.type!=t)return!1;if(n){let c=a.lastChild&&a.lastChild.type==l.type,u=j.from(c?t.create():null),d=new K(j.from(t.create(null,j.from(l.type.create(null,u)))),c?3:1,0),f=i.start,h=i.end;n(e.tr.step(new kt(f-(c?3:1),h,f,h,d,1,!0)).scrollIntoView())}return!0}}const Ze=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},Cs=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let Pu=null;const _n=function(t,e,n){let r=Pu||(Pu=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},CC=function(){Pu=null},$r=function(t,e,n,r){return n&&(lp(t,e,n,r,-1)||lp(t,e,n,r,1))},EC=/^(img|br|input|textarea|hr)$/i;function lp(t,e,n,r,s){for(var i;;){if(t==n&&e==r)return!0;if(e==(s<0?0:jt(t))){let o=t.parentNode;if(!o||o.nodeType!=1||go(t)||EC.test(t.nodeName)||t.contentEditable=="false")return!1;e=Ze(t)+(s<0?0:1),t=o}else if(t.nodeType==1){let o=t.childNodes[e+(s<0?-1:0)];if(o.nodeType==1&&o.contentEditable=="false")if(!((i=o.pmViewDesc)===null||i===void 0)&&i.ignoreForSelection)e+=s;else return!1;else t=o,e=s<0?jt(t):0}else return!1}}function jt(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function MC(t,e){for(;;){if(t.nodeType==3&&e)return t;if(t.nodeType==1&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1],e=jt(t)}else if(t.parentNode&&!go(t))e=Ze(t),t=t.parentNode;else return null}}function TC(t,e){for(;;){if(t.nodeType==3&&e<t.nodeValue.length)return t;if(t.nodeType==1&&e<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[e],e=0}else if(t.parentNode&&!go(t))e=Ze(t)+1,t=t.parentNode;else return null}}function AC(t,e,n){for(let r=e==0,s=e==jt(t);r||s;){if(t==n)return!0;let i=Ze(t);if(t=t.parentNode,!t)return!1;r=r&&i==0,s=s&&i==jt(t)}}function go(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const Ua=function(t){return t.focusNode&&$r(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Er(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function _C(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function NC(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(jt(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(jt(r.startContainer),r.startOffset)}}}const pn=typeof navigator<"u"?navigator:null,ap=typeof document<"u"?document:null,yr=pn&&pn.userAgent||"",Bu=/Edge\/(\d+)/.exec(yr),ub=/MSIE \d/.exec(yr),zu=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(yr),vt=!!(ub||zu||Bu),or=ub?document.documentMode:zu?+zu[1]:Bu?+Bu[1]:0,Bt=!vt&&/gecko\/(\d+)/i.test(yr);Bt&&+(/Firefox\/(\d+)/.exec(yr)||[0,0])[1];const $u=!vt&&/Chrome\/(\d+)/.exec(yr),Ue=!!$u,db=$u?+$u[1]:0,it=!vt&&!!pn&&/Apple Computer/.test(pn.vendor),Es=it&&(/Mobile\/\w+/.test(yr)||!!pn&&pn.maxTouchPoints>2),Lt=Es||(pn?/Mac/.test(pn.platform):!1),fb=pn?/Win/.test(pn.platform):!1,Nn=/Android \d/.test(yr),yo=!!ap&&"webkitFontSmoothing"in ap.documentElement.style,OC=yo?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function IC(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function kn(t,e){return typeof t=="number"?t:t[e]}function RC(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function cp(t,e,n){let r=t.someProp("scrollThreshold")||0,s=t.someProp("scrollMargin")||5,i=t.dom.ownerDocument;for(let o=n||t.dom;o;){if(o.nodeType!=1){o=Cs(o);continue}let l=o,a=l==i.body,c=a?IC(i):RC(l),u=0,d=0;if(e.top<c.top+kn(r,"top")?d=-(c.top-e.top+kn(s,"top")):e.bottom>c.bottom-kn(r,"bottom")&&(d=e.bottom-e.top>c.bottom-c.top?e.top+kn(s,"top")-c.top:e.bottom-c.bottom+kn(s,"bottom")),e.left<c.left+kn(r,"left")?u=-(c.left-e.left+kn(s,"left")):e.right>c.right-kn(r,"right")&&(u=e.right-c.right+kn(s,"right")),u||d)if(a)i.defaultView.scrollBy(u,d);else{let h=l.scrollLeft,p=l.scrollTop;d&&(l.scrollTop+=d),u&&(l.scrollLeft+=u);let g=l.scrollLeft-h,y=l.scrollTop-p;e={left:e.left-g,top:e.top-y,right:e.right-g,bottom:e.bottom-y}}let f=a?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(f))break;o=f=="absolute"?o.offsetParent:Cs(o)}}function DC(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,s;for(let i=(e.left+e.right)/2,o=n+1;o<Math.min(innerHeight,e.bottom);o+=5){let l=t.root.elementFromPoint(i,o);if(!l||l==t.dom||!t.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=n-20){r=l,s=a.top;break}}return{refDOM:r,refTop:s,stack:hb(t.dom)}}function hb(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=Cs(r));return e}function LC({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;pb(n,r==0?0:r-e)}function pb(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:s,left:i}=t[n];r.scrollTop!=s+e&&(r.scrollTop=s+e),r.scrollLeft!=i&&(r.scrollLeft=i)}}let ts=null;function jC(t){if(t.setActive)return t.setActive();if(ts)return t.focus(ts);let e=hb(t);t.focus(ts==null?{get preventScroll(){return ts={preventScroll:!0},!0}}:void 0),ts||(ts=!1,pb(e,0))}function mb(t,e){let n,r=2e8,s,i=0,o=e.top,l=e.top,a,c;for(let u=t.firstChild,d=0;u;u=u.nextSibling,d++){let f;if(u.nodeType==1)f=u.getClientRects();else if(u.nodeType==3)f=_n(u).getClientRects();else continue;for(let h=0;h<f.length;h++){let p=f[h];if(p.top<=o&&p.bottom>=l){o=Math.max(p.bottom,o),l=Math.min(p.top,l);let g=p.left>e.left?p.left-e.left:p.right<e.left?e.left-p.right:0;if(g<r){n=u,r=g,s=g&&n.nodeType==3?{left:p.right<e.left?p.right:p.left,top:e.top}:e,u.nodeType==1&&g&&(i=d+(e.left>=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!a&&p.left<=e.left&&p.right>=e.left&&(a=u,c={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!n&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(i=d+1)}}return!n&&a&&(n=a,s=c,r=0),n&&n.nodeType==3?PC(n,s):!n||r&&n.nodeType==1?{node:t,offset:i}:mb(n,s)}function PC(t,e){let n=t.nodeValue.length,r=document.createRange(),s;for(let i=0;i<n;i++){r.setEnd(t,i+1),r.setStart(t,i);let o=Yn(r,1);if(o.top!=o.bottom&&of(e,o)){s={node:t,offset:i+(e.left>=(o.left+o.right)/2?1:0)};break}}return r.detach(),s||{node:t,offset:0}}function of(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function BC(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function zC(t,e,n){let{node:r,offset:s}=mb(e,n),i=-1;if(r.nodeType==1&&!r.firstChild){let o=r.getBoundingClientRect();i=o.left!=o.right&&n.left>(o.left+o.right)/2?1:-1}return t.docView.posFromDOM(r,s,i)}function $C(t,e,n,r){let s=-1;for(let i=e,o=!1;i!=t.dom;){let l=t.docView.nearestDesc(i,!0),a;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!o&&a.left>r.left||a.top>r.top?s=l.posBefore:(!o&&a.right<r.left||a.bottom<r.top)&&(s=l.posAfter),o=!0),!l.contentDOM&&s<0&&!l.node.isText))return(l.node.isBlock?r.top<(a.top+a.bottom)/2:r.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;i=l.dom.parentNode}return s>-1?s:t.docView.posFromDOM(e,n,-1)}function gb(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let s=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),i=s;;){let o=t.childNodes[i];if(o.nodeType==1){let l=o.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(of(e,c))return gb(o,e,c)}}if((i=(i+1)%r)==s)break}return t}function HC(t,e){let n=t.dom.ownerDocument,r,s=0,i=NC(n,e.left,e.top);i&&({node:r,offset:s}=i);let o=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),l;if(!o||!t.dom.contains(o.nodeType!=1?o.parentNode:o)){let c=t.dom.getBoundingClientRect();if(!of(e,c)||(o=gb(t.dom,e,c),!o))return null}if(it)for(let c=o;r&&c;c=Cs(c))c.draggable&&(r=void 0);if(o=BC(o,e),r){if(Bt&&r.nodeType==1&&(s=Math.min(s,r.childNodes.length),s<r.childNodes.length)){let u=r.childNodes[s],d;u.nodeName=="IMG"&&(d=u.getBoundingClientRect()).right<=e.left&&d.bottom>e.top&&s++}let c;yo&&s&&r.nodeType==1&&(c=r.childNodes[s-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&s--,r==t.dom&&s==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=t.state.doc.content.size:(s==0||r.nodeType!=1||r.childNodes[s-1].nodeName!="BR")&&(l=$C(t,r,s,e))}l==null&&(l=zC(t,o,e));let a=t.docView.nearestDesc(o,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function up(t){return t.top<t.bottom||t.left<t.right}function Yn(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(up(r))return r}return Array.prototype.find.call(n,up)||t.getBoundingClientRect()}const FC=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function yb(t,e,n){let{node:r,offset:s,atom:i}=t.docView.domFromPos(e,n<0?-1:1),o=yo||Bt;if(r.nodeType==3)if(o&&(FC.test(r.nodeValue)||(n<0?!s:s==r.nodeValue.length))){let a=Yn(_n(r,s,s),n);if(Bt&&s&&/\s/.test(r.nodeValue[s-1])&&s<r.nodeValue.length){let c=Yn(_n(r,s-1,s-1),-1);if(c.top==a.top){let u=Yn(_n(r,s,s+1),-1);if(u.top!=a.top)return Qs(u,u.left<c.left)}}return a}else{let a=s,c=s,u=n<0?1:-1;return n<0&&!s?(c++,u=-1):n>=0&&s==r.nodeValue.length?(a--,u=1):n<0?a--:c++,Qs(Yn(_n(r,a,c),u),u<0)}if(!t.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&s&&(n<0||s==jt(r))){let a=r.childNodes[s-1];if(a.nodeType==1)return Rc(a.getBoundingClientRect(),!1)}if(i==null&&s<jt(r)){let a=r.childNodes[s];if(a.nodeType==1)return Rc(a.getBoundingClientRect(),!0)}return Rc(r.getBoundingClientRect(),n>=0)}if(i==null&&s&&(n<0||s==jt(r))){let a=r.childNodes[s-1],c=a.nodeType==3?_n(a,jt(a)-(o?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return Qs(Yn(c,1),!1)}if(i==null&&s<jt(r)){let a=r.childNodes[s];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?_n(a,0,o?0:1):a.nodeType==1?a:null:null;if(c)return Qs(Yn(c,-1),!0)}return Qs(Yn(r.nodeType==3?_n(r):r,-n),n>=0)}function Qs(t,e){if(t.width==0)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function Rc(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function bb(t,e,n){let r=t.state,s=t.root.activeElement;r!=e&&t.updateState(e),s!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),s!=t.dom&&s&&s.focus()}}function VC(t,e,n){let r=e.selection,s=n=="up"?r.$from:r.$to;return bb(t,e,()=>{let{node:i}=t.docView.domFromPos(s.pos,n=="up"?-1:1);for(;;){let l=t.docView.nearestDesc(i,!0);if(!l)break;if(l.node.isBlock){i=l.contentDOM||l.dom;break}i=l.dom.parentNode}let o=yb(t,s.pos,1);for(let l=i.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=_n(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let u=a[c];if(u.bottom>u.top+1&&(n=="up"?o.top-u.top>(u.bottom-o.top)*2:u.bottom-o.bottom>(o.bottom-u.top)*2))return!1}}return!0})}const UC=/[\u0590-\u08ac]/;function WC(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let s=r.parentOffset,i=!s,o=s==r.parent.content.size,l=t.domSelection();return l?!UC.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?i:o:bb(t,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:u,anchorOffset:d}=t.domSelectionRange(),f=l.caretBidiLevel;l.modify("move",n,"character");let h=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:p,focusOffset:g}=t.domSelectionRange(),y=p&&!h.contains(p.nodeType==1?p:p.parentNode)||a==p&&c==g;try{l.collapse(u,d),a&&(a!=u||c!=d)&&l.extend&&l.extend(a,c)}catch{}return f!=null&&(l.caretBidiLevel=f),y}):r.pos==r.start()||r.pos==r.end()}let dp=null,fp=null,hp=!1;function qC(t,e,n){return dp==e&&fp==n?hp:(dp=e,fp=n,hp=n=="up"||n=="down"?VC(t,e,n):WC(t,e,n))}const zt=0,pp=1,Ar=2,mn=3;class bo{constructor(e,n,r,s){this.parent=e,this.children=n,this.dom=r,this.contentDOM=s,this.dirty=zt,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;n<this.children.length;n++)e+=this.children[n].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 n=0,r=this.posAtStart;;n++){let s=this.children[n];if(s==e)return r;r+=s.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,n,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let i,o;if(e==this.contentDOM)i=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.previousSibling}for(;i&&!((o=i.pmViewDesc)&&o.parent==this);)i=i.previousSibling;return i?this.posBeforeChild(o)+o.size:this.posAtStart}else{let i,o;if(e==this.contentDOM)i=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&!((o=i.pmViewDesc)&&o.parent==this);)i=i.nextSibling;return i?this.posBeforeChild(o):this.posAtEnd}let s;if(e==this.dom&&this.contentDOM)s=n>Ze(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))s=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let i=e;;i=i.parentNode){if(i==this.dom){s=!1;break}if(i.previousSibling)break}if(s==null&&n==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){s=!0;break}if(i.nextSibling)break}}return s??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,s=e;s;s=s.parentNode){let i=this.getDesc(s),o;if(i&&(!n||i.node))if(r&&(o=i.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))r=!1;else return i}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let s=e;s;s=s.parentNode){let i=this.getDesc(s);if(i)return i.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let s=this.children[n],i=r+s.size;if(r==e&&i!=r){for(;!s.border&&s.children.length;)for(let o=0;o<s.children.length;o++){let l=s.children[o];if(l.size){s=l;break}}return s}if(e<i)return s.descAt(e-r-s.border);r=i}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,s=0;for(let i=0;r<this.children.length;r++){let o=this.children[r],l=i+o.size;if(l>e||o instanceof xb){s=e-i;break}i=l}if(s)return this.children[r].domFromPos(s-this.children[r].border,n);for(let i;r&&!(i=this.children[r-1]).size&&i instanceof wb&&i.side>=0;r--);if(n<=0){let i,o=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,o=!1);return i&&n&&o&&!i.border&&!i.domAtom?i.domFromPos(i.size,n):{node:this.contentDOM,offset:i?Ze(i.dom)+1:0}}else{let i,o=!0;for(;i=r<this.children.length?this.children[r]:null,!(!i||i.dom.parentNode==this.contentDOM);r++,o=!1);return i&&o&&!i.border&&!i.domAtom?i.domFromPos(0,n):{node:this.contentDOM,offset:i?Ze(i.dom):this.contentDOM.childNodes.length}}}parseRange(e,n,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let s=-1,i=-1;for(let o=r,l=0;;l++){let a=this.children[l],c=o+a.size;if(s==-1&&e<=c){let u=o+a.border;if(e>=u&&n<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,n,u);e=o;for(let d=l;d>0;d--){let f=this.children[d-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){s=Ze(f.dom)+1;break}e-=f.size}s==-1&&(s=0)}if(s>-1&&(c>n||l==this.children.length-1)){n=c;for(let u=l+1;u<this.children.length;u++){let d=this.children[u];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(-1)){i=Ze(d.dom);break}n+=d.size}i==-1&&(i=this.contentDOM.childNodes.length);break}o=c}return{node:this.contentDOM,from:e,to:n,fromOffset:s,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[e<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(e)}domAfterPos(e){let{node:n,offset:r}=this.domFromPos(e,0);if(n.nodeType!=1||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]}setSelection(e,n,r,s=!1){let i=Math.min(e,n),o=Math.max(e,n);for(let h=0,p=0;h<this.children.length;h++){let g=this.children[h],y=p+g.size;if(i>p&&o<y)return g.setSelection(e-p-g.border,n-p-g.border,r,s);p=y}let l=this.domFromPos(e,e?-1:1),a=n==e?l:this.domFromPos(n,n?-1:1),c=r.root.getSelection(),u=r.domSelectionRange(),d=!1;if((Bt||it)&&e==n){let{node:h,offset:p}=l;if(h.nodeType==3){if(d=!!(p&&h.nodeValue[p-1]==`
|
|
23
|
-
`),d&&p==h.nodeValue.length)for(let g=h,y;g;g=g.parentNode){if(y=g.nextSibling){y.nodeName=="BR"&&(l=a={node:y.parentNode,offset:Ze(y)+1});break}let b=g.pmViewDesc;if(b&&b.node&&b.node.isBlock)break}}else{let g=h.childNodes[p-1];d=g&&(g.nodeName=="BR"||g.contentEditable=="false")}}if(Bt&&u.focusNode&&u.focusNode!=a.node&&u.focusNode.nodeType==1){let h=u.focusNode.childNodes[u.focusOffset];h&&h.contentEditable=="false"&&(s=!0)}if(!(s||d&&it)&&$r(l.node,l.offset,u.anchorNode,u.anchorOffset)&&$r(a.node,a.offset,u.focusNode,u.focusOffset))return;let f=!1;if((c.extend||e==n)&&!(d&&Bt)){c.collapse(l.node,l.offset);try{e!=n&&c.extend(a.node,a.offset),f=!0}catch{}}if(!f){if(e>n){let p=l;l=a,a=p}let h=document.createRange();h.setEnd(a.node,a.offset),h.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,s=0;s<this.children.length;s++){let i=this.children[s],o=r+i.size;if(r==o?e<=o&&n>=r:e<o&&n>r){let l=r+i.border,a=o-i.border;if(e>=l&&n<=a){this.dirty=e==r||n==o?Ar:pp,e==l&&n==a&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=mn:i.markDirty(e-l,n-l);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?Ar:mn}r=o}this.dirty=Ar}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?Ar:pp;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class wb extends bo{constructor(e,n,r,s){let i,o=n.type.toDOM;if(typeof o=="function"&&(o=o(r,()=>{if(!i)return s;if(i.parent)return i.parent.posBeforeChild(i)})),!n.type.spec.raw){if(o.nodeType!=1){let l=document.createElement("span");l.appendChild(o),o=l}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=n,this.widget=n,i=this}matchesWidget(e){return this.dirty==zt&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class KC extends bo{constructor(e,n,r,s){super(e,[],n,null),this.textDOM=r,this.text=s}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class Hr extends bo{constructor(e,n,r,s,i){super(e,[],r,s),this.mark=n,this.spec=i}static create(e,n,r,s){let i=s.nodeViews[n.type.name],o=i&&i(n,s,r);return(!o||!o.dom)&&(o=Xr.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new Hr(e,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&mn||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=mn&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=zt){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=zt}}slice(e,n,r){let s=Hr.create(this.parent,this.mark,!0,r),i=this.children,o=this.size;n<o&&(i=Fu(i,n,o,r)),e>0&&(i=Fu(i,0,e,r));for(let l=0;l<i.length;l++)i[l].parent=s;return s.children=i,s}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class lr extends bo{constructor(e,n,r,s,i,o,l,a,c){super(e,[],i,o),this.node=n,this.outerDeco=r,this.innerDeco=s,this.nodeDOM=l}static create(e,n,r,s,i,o){let l=i.nodeViews[n.type.name],a,c=l&&l(n,i,()=>{if(!a)return o;if(a.parent)return a.parent.posBeforeChild(a)},r,s),u=c&&c.dom,d=c&&c.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:d}=Xr.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!d&&!n.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),n.type.spec.draggable&&(u.draggable=!0));let f=u;return u=Sb(u,r,n),c?a=new JC(e,n,r,s,u,d||null,f,c,i,o+1):n.isText?new Wa(e,n,r,s,u,f,i):new lr(e,n,r,s,u,d||null,f,i,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>j.empty)}return e}matchesNode(e,n,r){return this.dirty==zt&&e.eq(this.node)&&Ol(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,s=n,i=e.composing?this.localCompositionInfo(e,n):null,o=i&&i.pos>-1?i:null,l=i&&i.pos<0,a=new YC(this,o&&o.node,e);QC(this.node,this.innerDeco,(c,u,d)=>{c.spec.marks?a.syncToMarks(c.spec.marks,r,e,u):c.type.side>=0&&!d&&a.syncToMarks(u==this.node.childCount?xe.none:this.node.child(u).marks,r,e,u),a.placeWidget(c,e,s)},(c,u,d,f)=>{a.syncToMarks(c.marks,r,e,f);let h;a.findNodeMatch(c,u,d,f)||l&&e.state.selection.from>s&&e.state.selection.to<s+c.nodeSize&&(h=a.findIndexWithChild(i.node))>-1&&a.updateNodeAt(c,u,d,h,e)||a.updateNextNode(c,u,d,e,f,s)||a.addNode(c,u,d,e,s),s+=c.nodeSize}),a.syncToMarks([],r,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==Ar)&&(o&&this.protectLocalComposition(e,o),vb(this.contentDOM,this.children,e),Es&&eE(this.dom))}localCompositionInfo(e,n){let{from:r,to:s}=e.state.selection;if(!(e.state.selection instanceof ee)||r<n||s>n+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let o=i.nodeValue,l=tE(this.node.content,o,r-n,s-n);return l<0?null:{node:i,pos:l,text:o}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:s}){if(this.getDesc(n))return;let i=n;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let o=new KC(this,i,n,s);e.input.compositionNodes.push(o),this.children=Fu(this.children,r,r+s.length,e,o)}update(e,n,r,s){return this.dirty==mn||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,s),!0)}updateInner(e,n,r,s){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(s,this.posAtStart),this.dirty=zt}updateOuterDeco(e){if(Ol(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=kb(this.dom,this.nodeDOM,Hu(this.outerDeco,this.node,n),Hu(e,this.node,n)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function mp(t,e,n,r,s){Sb(r,e,t);let i=new lr(void 0,t,e,n,r,r,r,s,0);return i.contentDOM&&i.updateChildren(s,0),i}class Wa extends lr{constructor(e,n,r,s,i,o,l){super(e,n,r,s,i,null,o,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,s){return this.dirty==mn||this.dirty!=zt&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=zt||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,s.trackWrites==this.nodeDOM&&(s.trackWrites=null)),this.node=e,this.dirty=zt,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let s=this.node.cut(e,n),i=document.createTextNode(s.text);return new Wa(this.parent,s,this.outerDeco,this.innerDeco,i,i,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=mn)}get domAtom(){return!1}isText(e){return this.node.text==e}}class xb extends bo{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==zt&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class JC extends lr{constructor(e,n,r,s,i,o,l,a,c,u){super(e,n,r,s,i,o,l,c,u),this.spec=a}update(e,n,r,s){if(this.dirty==mn)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,n,r);return i&&this.updateInner(e,n,r,s),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,s)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,s){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,s)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function vb(t,e,n){let r=t.firstChild,s=!1;for(let i=0;i<e.length;i++){let o=e[i],l=o.dom;if(l.parentNode==t){for(;l!=r;)r=gp(r),s=!0;r=r.nextSibling}else s=!0,t.insertBefore(l,r);if(o instanceof Hr){let a=r?r.previousSibling:t.lastChild;vb(o.contentDOM,o.children,n),r=a?a.nextSibling:t.firstChild}}for(;r;)r=gp(r),s=!0;s&&n.trackWrites==t&&(n.trackWrites=null)}const Ti=function(t){t&&(this.nodeName=t)};Ti.prototype=Object.create(null);const _r=[new Ti];function Hu(t,e,n){if(t.length==0)return _r;let r=n?_r[0]:new Ti,s=[r];for(let i=0;i<t.length;i++){let o=t[i].type.attrs;if(o){o.nodeName&&s.push(r=new Ti(o.nodeName));for(let l in o){let a=o[l];a!=null&&(n&&s.length==1&&s.push(r=new Ti(e.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+a:l=="style"?r.style=(r.style?r.style+";":"")+a:l!="nodeName"&&(r[l]=a))}}}return s}function kb(t,e,n,r){if(n==_r&&r==_r)return e;let s=e;for(let i=0;i<r.length;i++){let o=r[i],l=n[i];if(i){let a;l&&l.nodeName==o.nodeName&&s!=t&&(a=s.parentNode)&&a.nodeName.toLowerCase()==o.nodeName||(a=document.createElement(o.nodeName),a.pmIsDeco=!0,a.appendChild(s),l=_r[0]),s=a}GC(s,l||_r[0],o)}return s}function GC(t,e,n){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in n)&&t.removeAttribute(r);for(let r in n)r!="class"&&r!="style"&&r!="nodeName"&&n[r]!=e[r]&&t.setAttribute(r,n[r]);if(e.class!=n.class){let r=e.class?e.class.split(" ").filter(Boolean):[],s=n.class?n.class.split(" ").filter(Boolean):[];for(let i=0;i<r.length;i++)s.indexOf(r[i])==-1&&t.classList.remove(r[i]);for(let i=0;i<s.length;i++)r.indexOf(s[i])==-1&&t.classList.add(s[i]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,s;for(;s=r.exec(e.style);)t.style.removeProperty(s[1])}n.style&&(t.style.cssText+=n.style)}}function Sb(t,e,n){return kb(t,t,_r,Hu(e,n,t.nodeType!=1))}function Ol(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].type.eq(e[n].type))return!1;return!0}function gp(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class YC{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=XC(e.node.content,e)}destroyBetween(e,n){if(e!=n){for(let r=e;r<n;r++)this.top.children[r].destroy();this.top.children.splice(e,n-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,n,r,s){let i=0,o=this.stack.length>>1,l=Math.min(o,e.length);for(;i<l&&(i==o-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<o;)this.destroyRest(),this.top.dirty=zt,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<e.length;){this.stack.push(this.top,this.index+1);let a=-1,c=this.top.children.length;s<this.preMatch.index&&(c=Math.min(this.index+3,c));for(let u=this.index;u<c;u++){let d=this.top.children[u];if(d.matchesMark(e[o])&&!this.isLocked(d.dom)){a=u;break}}if(a>-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{let u=Hr.create(this.top,e[o],n,r);this.top.children.splice(this.index,0,u),this.top=u,this.changed=!0}this.index=0,o++}}findNodeMatch(e,n,r,s){let i=-1,o;if(s>=this.preMatch.index&&(o=this.preMatch.matches[s-this.preMatch.index]).parent==this.top&&o.matchesNode(e,n,r))i=this.top.children.indexOf(o,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,n,r)&&!this.preMatch.matched.has(c)){i=l;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,n,r,s,i){let o=this.top.children[s];return o.dirty==mn&&o.dom==o.contentDOM&&(o.dirty=Ar),o.update(e,n,r,i)?(this.destroyBetween(this.index,s),this.index++,!0):!1}findIndexWithChild(e){for(;;){let n=e.parentNode;if(!n)return-1;if(n==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let s=this.index;s<this.top.children.length;s++)if(this.top.children[s]==r)return s}return-1}e=n}}updateNextNode(e,n,r,s,i,o){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof lr){let c=this.preMatch.matched.get(a);if(c!=null&&c!=i)return!1;let u=a.dom,d,f=this.isLocked(u)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=mn&&Ol(n,a.outerDeco));if(!f&&a.update(e,n,r,s))return this.destroyBetween(this.index,l),a.dom!=u&&(this.changed=!0),this.index++,!0;if(!f&&(d=this.recreateWrapper(a,e,n,r,s,o)))return this.destroyBetween(this.index,l),this.top.children[this.index]=d,d.contentDOM&&(d.dirty=Ar,d.updateChildren(s,o+1),d.dirty=zt),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,s,i,o){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!Ol(r,e.outerDeco)||!s.eq(e.innerDeco))return null;let l=lr.create(this.top,n,r,s,i,o);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,n,r,s,i){let o=lr.create(this.top,e,n,r,s,i);o.contentDOM&&o.updateChildren(s,i+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,n,r){let s=this.index<this.top.children.length?this.top.children[this.index]:null;if(s&&s.matchesWidget(e)&&(e==s.widget||!s.widget.type.toDOM.parentNode))this.index++;else{let i=new wb(this.top,e,n,r);this.top.children.splice(this.index++,0,i),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof Hr;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof Wa)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((it||Ue)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",n),this.addHackNode("BR",this.top))}addHackNode(e,n){if(n==this.top&&this.index<n.children.length&&n.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let s=new xb(this.top,[],r,null);n!=this.top?n.children.push(s):n.children.splice(this.index++,0,s),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function XC(t,e){let n=e,r=n.children.length,s=t.childCount,i=new Map,o=[];e:for(;s>0;){let l;for(;;)if(r){let c=n.children[r-1];if(c instanceof Hr)n=c,r=c.children.length;else{l=c,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let a=l.node;if(a){if(a!=t.child(s-1))break;--s,i.set(l,s),o.push(l)}}return{index:s,matched:i,matches:o.reverse()}}function ZC(t,e){return t.type.side-e.type.side}function QC(t,e,n,r){let s=e.locals(t),i=0;if(s.length==0){for(let c=0;c<t.childCount;c++){let u=t.child(c);r(u,s,e.forChild(i,u),c),i+=u.nodeSize}return}let o=0,l=[],a=null;for(let c=0;;){let u,d;for(;o<s.length&&s[o].to==i;){let y=s[o++];y.widget&&(u?(d||(d=[u])).push(y):u=y)}if(u)if(d){d.sort(ZC);for(let y=0;y<d.length;y++)n(d[y],c,!!a)}else n(u,c,!!a);let f,h;if(a)h=-1,f=a,a=null;else if(c<t.childCount)h=c,f=t.child(c++);else break;for(let y=0;y<l.length;y++)l[y].to<=i&&l.splice(y--,1);for(;o<s.length&&s[o].from<=i&&s[o].to>i;)l.push(s[o++]);let p=i+f.nodeSize;if(f.isText){let y=p;o<s.length&&s[o].from<y&&(y=s[o].from);for(let b=0;b<l.length;b++)l[b].to<y&&(y=l[b].to);y<p&&(a=f.cut(y-i),f=f.cut(0,y-i),p=y,h=-1)}else for(;o<s.length&&s[o].to<p;)o++;let g=f.isInline&&!f.isLeaf?l.filter(y=>!y.inline):l.slice();r(f,g,e.forChild(i,f),h),i=p}}function eE(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}function tE(t,e,n,r){for(let s=0,i=0;s<t.childCount&&i<=r;){let o=t.child(s++),l=i;if(i+=o.nodeSize,!o.isText)continue;let a=o.text;for(;s<t.childCount;){let c=t.child(s++);if(i+=c.nodeSize,!c.isText)break;a+=c.text}if(i>=n){if(i>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l<r?a.lastIndexOf(e,r-l-1):-1;if(c>=0&&c+e.length+l>=n)return l+c;if(n==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function Fu(t,e,n,r,s){let i=[];for(let o=0,l=0;o<t.length;o++){let a=t[o],c=l,u=l+=a.size;c>=n||u<=e?i.push(a):(c<e&&i.push(a.slice(0,e-c,r)),s&&(i.push(s),s=void 0),u>n&&i.push(a.slice(n-c,a.size,r)))}return i}function lf(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let s=t.docView.nearestDesc(n.focusNode),i=s&&s.size==0,o=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let l=r.resolve(o),a,c;if(Ua(n)){for(a=o;s&&!s.node;)s=s.parent;let d=s.node;if(s&&d.isAtom&&Y.isSelectable(d)&&s.parent&&!(d.isInline&&AC(n.focusNode,n.focusOffset,s.dom))){let f=s.posBefore;c=new Y(o==f?l:r.resolve(f))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let d=o,f=o;for(let h=0;h<n.rangeCount;h++){let p=n.getRangeAt(h);d=Math.min(d,t.docView.posFromDOM(p.startContainer,p.startOffset,1)),f=Math.max(f,t.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(d<0)return null;[a,o]=f==t.state.selection.anchor?[f,d]:[d,f],l=r.resolve(o)}else a=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(a<0)return null}let u=r.resolve(a);if(!c){let d=e=="pointer"||t.state.selection.head<l.pos&&!i?1:-1;c=af(t,u,l,d)}return c}function Cb(t){return t.editable?t.hasFocus():Mb(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function Dn(t,e=!1){let n=t.state.selection;if(Eb(t,n),!Cb(t))return;let r=t.input.mouseDown;if(!e&&Ue&&r){let s=t.domSelectionRange(),i=t.domObserver.currentSelection;if(s.anchorNode&&i.anchorNode&&$r(s.anchorNode,s.anchorOffset,i.anchorNode,i.anchorOffset)&&r.delaySelUpdate()){t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)rE(t);else{let{anchor:s,head:i}=n,o,l;yp&&!(n instanceof ee)&&(n.$from.parent.inlineContent||(o=bp(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(l=bp(t,n.to))),t.docView.setSelection(s,i,t,e),yp&&(o&&wp(o),l&&wp(l)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&nE(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}const yp=it||Ue&&db<63;function bp(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),s=r<n.childNodes.length?n.childNodes[r]:null,i=r?n.childNodes[r-1]:null;if(it&&s&&s.contentEditable=="false")return Dc(s);if((!s||s.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(s)return Dc(s);if(i)return Dc(i)}}function Dc(t){return t.contentEditable="true",it&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function wp(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function nE(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),r=n.anchorNode,s=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=s)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!Cb(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function rE(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,Ze(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&vt&&or<=11&&(n.disabled=!0,n.disabled=!1)}function Eb(t,e){if(e instanceof Y){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(xp(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else xp(t)}function xp(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function af(t,e,n,r){return t.someProp("createSelectionBetween",s=>s(t,e,n))||ee.between(e,n,r)}function vp(t){return t.editable&&!t.hasFocus()?!1:Mb(t)}function Mb(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function sE(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return $r(e.node,e.offset,n.anchorNode,n.anchorOffset)}function Vu(t,e){let{$anchor:n,$head:r}=t.selection,s=e>0?n.max(r):n.min(r),i=s.parent.inlineContent?s.depth?t.doc.resolve(e>0?s.after():s.before()):null:s;return i&&te.findFrom(i,e)}function Qn(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function kp(t,e,n){let r=t.state.selection;if(r instanceof ee)if(n.indexOf("s")>-1){let{$head:s}=r,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let o=t.state.doc.resolve(s.pos+i.nodeSize*(e<0?-1:1));return Qn(t,new ee(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let s=Vu(t.state,e);return s&&s instanceof Y?Qn(t,s):!1}else if(!(Lt&&n.indexOf("m")>-1)){let s=r.$head,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter,o;if(!i||i.isText)return!1;let l=e<0?s.pos-i.nodeSize:s.pos;return i.isAtom||(o=t.docView.descAt(l))&&!o.contentDOM?Y.isSelectable(i)?Qn(t,new Y(e<0?t.state.doc.resolve(s.pos-i.nodeSize):s)):yo?Qn(t,new ee(t.state.doc.resolve(e<0?l:l+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof Y&&r.node.isInline)return Qn(t,new ee(e>0?r.$to:r.$from));{let s=Vu(t.state,e);return s?Qn(t,s):!1}}}function Il(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Ai(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function ns(t,e){return e<0?iE(t):oE(t)}function iE(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s,i,o=!1;for(Bt&&n.nodeType==1&&r<Il(n)&&Ai(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(Ai(l,-1))s=n,i=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(Tb(n))break;{let l=n.previousSibling;for(;l&&Ai(l,-1);)s=n.parentNode,i=Ze(l),l=l.previousSibling;if(l)n=l,r=Il(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?Uu(t,n,r):s&&Uu(t,s,i)}function oE(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s=Il(n),i,o;for(;;)if(r<s){if(n.nodeType!=1)break;let l=n.childNodes[r];if(Ai(l,1))i=n,o=++r;else break}else{if(Tb(n))break;{let l=n.nextSibling;for(;l&&Ai(l,1);)i=l.parentNode,o=Ze(l)+1,l=l.nextSibling;if(l)n=l,r=0,s=Il(n);else{if(n=n.parentNode,n==t.dom)break;r=s=0}}}i&&Uu(t,i,o)}function Tb(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function lE(t,e){for(;t&&e==t.childNodes.length&&!go(t);)e=Ze(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let n=t.childNodes[e];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=0}}function aE(t,e){for(;t&&!e&&!go(t);)e=Ze(t),t=t.parentNode;for(;t&&e;){let n=t.childNodes[e-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=t.childNodes.length}}function Uu(t,e,n){if(e.nodeType!=3){let i,o;(o=lE(e,n))?(e=o,n=0):(i=aE(e,n))&&(e=i,n=i.nodeValue.length)}let r=t.domSelection();if(!r)return;if(Ua(r)){let i=document.createRange();i.setEnd(e,n),i.setStart(e,n),r.removeAllRanges(),r.addRange(i)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:s}=t;setTimeout(()=>{t.state==s&&Dn(t)},50)}function Sp(t,e){let n=t.state.doc.resolve(e);if(!(Ue||fb)&&n.parent.inlineContent){let s=t.coordsAtPos(e);if(e>n.start()){let i=t.coordsAtPos(e-1),o=(i.top+i.bottom)/2;if(o>s.top&&o<s.bottom&&Math.abs(i.left-s.left)>1)return i.left<s.left?"ltr":"rtl"}if(e<n.end()){let i=t.coordsAtPos(e+1),o=(i.top+i.bottom)/2;if(o>s.top&&o<s.bottom&&Math.abs(i.left-s.left)>1)return i.left>s.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function Cp(t,e,n){let r=t.state.selection;if(r instanceof ee&&!r.empty||n.indexOf("s")>-1||Lt&&n.indexOf("m")>-1)return!1;let{$from:s,$to:i}=r;if(!s.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=Vu(t.state,e);if(o&&o instanceof Y)return Qn(t,o)}if(!s.parent.inlineContent){let o=e<0?s:i,l=r instanceof dn?te.near(o,e):te.findFrom(o,e);return l?Qn(t,l):!1}return!1}function Ep(t,e){if(!(t.state.selection instanceof ee))return!0;let{$head:n,$anchor:r,empty:s}=t.state.selection;if(!n.sameParent(r))return!0;if(!s)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let o=t.state.tr;return e<0?o.delete(n.pos-i.nodeSize,n.pos):o.delete(n.pos,n.pos+i.nodeSize),t.dispatch(o),!0}return!1}function Mp(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function cE(t){if(!it||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&e.nodeType==1&&n==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;Mp(t,r,"true"),setTimeout(()=>Mp(t,r,"false"),20)}return!1}function uE(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function dE(t,e){let n=e.keyCode,r=uE(e);if(n==8||Lt&&n==72&&r=="c")return Ep(t,-1)||ns(t,-1);if(n==46&&!e.shiftKey||Lt&&n==68&&r=="c")return Ep(t,1)||ns(t,1);if(n==13||n==27)return!0;if(n==37||Lt&&n==66&&r=="c"){let s=n==37?Sp(t,t.state.selection.from)=="ltr"?-1:1:-1;return kp(t,s,r)||ns(t,s)}else if(n==39||Lt&&n==70&&r=="c"){let s=n==39?Sp(t,t.state.selection.from)=="ltr"?1:-1:1;return kp(t,s,r)||ns(t,s)}else{if(n==38||Lt&&n==80&&r=="c")return Cp(t,-1,r)||ns(t,-1);if(n==40||Lt&&n==78&&r=="c")return cE(t)||Cp(t,1,r)||ns(t,1);if(r==(Lt?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function cf(t,e){t.someProp("transformCopied",h=>{e=h(e,t)});let n=[],{content:r,openStart:s,openEnd:i}=e;for(;s>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){s--,i--;let h=r.firstChild;n.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let o=t.someProp("clipboardSerializer")||Xr.fromSchema(t.state.schema),l=Rb(),a=l.createElement("div");a.appendChild(o.serializeFragment(r,{document:l}));let c=a.firstChild,u,d=0;for(;c&&c.nodeType==1&&(u=Ib[c.nodeName.toLowerCase()]);){for(let h=u.length-1;h>=0;h--){let p=l.createElement(u[h]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),d++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${s} ${i}${d?` -${d}`:""} ${JSON.stringify(n)}`);let f=t.someProp("clipboardTextSerializer",h=>h(e,t))||e.content.textBetween(0,e.content.size,`
|
|
17
|
+
*/var zf;function aS(){return zf||(zf=1,process.env.NODE_ENV!=="production"&&function(){function t(f,p){return f===p&&(f!==0||1/f===1/p)||f!==f&&p!==p}function e(f,p){u||s.startTransition===void 0||(u=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var g=p();if(!d){var y=p();i(g,y)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),d=!0)}y=o({inst:{value:g,getSnapshot:p}});var b=y[0].inst,w=y[1];return a(function(){b.value=g,b.getSnapshot=p,n(b)&&w({inst:b})},[f,g,p]),l(function(){return n(b)&&w({inst:b}),f(function(){n(b)&&w({inst:b})})},[f]),c(g),g}function n(f){var p=f.getSnapshot;f=f.value;try{var g=p();return!i(f,g)}catch{return!0}}function r(f,p){return p()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var s=S,i=typeof Object.is=="function"?Object.is:t,o=s.useState,l=s.useEffect,a=s.useLayoutEffect,c=s.useDebugValue,u=!1,d=!1,h=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?r:e;Mc.useSyncExternalStore=s.useSyncExternalStore!==void 0?s.useSyncExternalStore:h,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),Mc}process.env.NODE_ENV==="production"?Eu.exports=lS():Eu.exports=aS();var za=Eu.exports;function Xe(t){this.content=t}Xe.prototype={constructor:Xe,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,s=r.find(t),i=r.content.slice();return s==-1?i.push(n||t,e):(i[s+1]=e,n&&(i[s]=n)),new Xe(i)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new Xe(n)},addToStart:function(t,e){return new Xe([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new Xe(n)},addBefore:function(t,e,n){var r=this.remove(e),s=r.content.slice(),i=r.find(t);return s.splice(i==-1?s.length:i,0,e,n),new Xe(s)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return t=Xe.from(t),t.size?new Xe(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=Xe.from(t),t.size?new Xe(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=Xe.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},toObject:function(){var t={};return this.forEach(function(e,n){t[e]=n}),t},get size(){return this.content.length>>1}};Xe.from=function(t){if(t instanceof Xe)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new Xe(e)};function d1(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let s=t.child(r),i=e.child(r);if(s==i){n+=s.nodeSize;continue}if(!s.sameMarkup(i))return n;if(s.isText&&s.text!=i.text){let o=s.text,l=i.text,a=0;for(;o[a]==l[a];a++)n++;return a&&a<o.length&&a<l.length&&p1(o.charCodeAt(a-1))&&f1(o.charCodeAt(a))&&n--,n}if(s.content.size||i.content.size){let o=d1(s.content,i.content,n+1);if(o!=null)return o}n+=s.nodeSize}}function h1(t,e,n,r){for(let s=t.childCount,i=e.childCount;;){if(s==0||i==0)return s==i?null:{a:n,b:r};let o=t.child(--s),l=e.child(--i),a=o.nodeSize;if(o==l){n-=a,r-=a;continue}if(!o.sameMarkup(l))return{a:n,b:r};if(o.isText&&o.text!=l.text){let c=o.text,u=l.text,d=c.length,h=u.length;for(;d>0&&h>0&&c[d-1]==u[h-1];)d--,h--,n--,r--;return d&&h&&d<c.length&&p1(c.charCodeAt(d-1))&&f1(c.charCodeAt(d))&&(n++,r++),{a:n,b:r}}if(o.content.size||l.content.size){let c=h1(o.content,l.content,n-1,r-1);if(c)return c}n-=a,r-=a}}function f1(t){return t>=56320&&t<57344}function p1(t){return t>=55296&&t<56320}let j=class ut{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,s=0,i){for(let o=0,l=0;l<n;o++){let a=this.content[o],c=l+a.nodeSize;if(c>e&&r(a,s+l,i||null,o)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,n-u),r,s+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,s){let i="",o=!0;return this.nodesBetween(e,n,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,n-a):l.isLeaf?s?typeof s=="function"?s(l):s:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(o?o=!1:i+=r),i+=c},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,s=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(r)&&(s[s.length-1]=n.withText(n.text+r.text),i=1);i<e.content.length;i++)s.push(e.content[i]);return new ut(s,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],s=0;if(n>e)for(let i=0,o=0;o<n;i++){let l=this.content[i],a=o+l.nodeSize;a>e&&((o<e||a>n)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,n-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,n-o-1))),r.push(l),s+=l.nodeSize),o=a}return new ut(r,s)}cutByIndex(e,n){return e==n?ut.empty:e==0&&n==this.content.length?this:new ut(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let s=this.content.slice(),i=this.size+n.nodeSize-r.nodeSize;return s[e]=n,new ut(s,i)}addToStart(e){return new ut([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new ut(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))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 n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let s=this.content[n];e(s,r,n),r+=s.nodeSize}}findDiffStart(e,n=0){return d1(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return h1(this,e,n,r)}findIndex(e){if(e==0)return No(0,e);if(e==this.size)return No(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 s=this.child(n),i=r+s.nodeSize;if(i>=e)return i==e?No(n+1,i):No(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,n){if(!n)return ut.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return ut.fromArray(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return ut.empty;let n,r=0;for(let s=0;s<e.length;s++){let i=e[s];r+=i.nodeSize,s&&i.isText&&e[s-1].sameMarkup(i)?(n||(n=e.slice(0,s)),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new ut(n||e,r)}static from(e){if(!e)return ut.empty;if(e instanceof ut)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new ut([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}};j.empty=new j([],0);const Ac={index:0,offset:0};function No(t,e){return Ac.index=t,Ac.offset=e,Ac}function El(t,e){if(t===e)return!0;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!El(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!El(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let xe=class Tu{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let s=0;s<e.length;s++){let i=e[s];if(this.eq(i))return e;if(this.type.excludes(i.type))n||(n=e.slice(0,s));else{if(i.type.excludes(this.type))return e;!r&&i.type.rank>this.type.rank&&(n||(n=e.slice(0,s)),n.push(this),r=!0),n&&n.push(i)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&El(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);let s=r.create(n.attrs);return r.checkAttrs(s.attrs),s}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(n[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return Tu.none;if(e instanceof Tu)return[e];let n=e.slice();return n.sort((r,s)=>r.type.rank-s.type.rank),n}};xe.none=[];let zi=class extends Error{},q=class is{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=g1(this.content,e+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new is(r,this.openStart,this.openEnd)}removeBetween(e,n){return new is(m1(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return is.empty;let r=n.openStart||0,s=n.openEnd||0;if(typeof r!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new is(j.fromJSON(e,n.content),r,s)}static maxOpen(e,n=!0){let r=0,s=0;for(let i=e.firstChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.lastChild)s++;return new is(e,r,s)}};q.empty=new q(j.empty,0,0);function m1(t,e,n){let{index:r,offset:s}=t.findIndex(e),i=t.maybeChild(r),{index:o,offset:l}=t.findIndex(n);if(s==e||i.isText){if(l!=n&&!t.child(o).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(r,i.copy(m1(i.content,e-s-1,n-s-1)))}function g1(t,e,n,r,s,i){let{index:o,offset:l}=t.findIndex(e),a=t.maybeChild(o);if(l==e||a.isText)return i&&r<=0&&s<=0&&!i.canReplace(o,o,n)?null:t.cut(0,e).append(n).append(t.cut(e));let c=g1(a.content,e-l-1,n,o==0?r-1:0,o==t.childCount-1?s-1:0,a);return c&&t.replaceChild(o,a.copy(c))}function cS(t,e,n){if(n.openStart>t.depth)throw new zi("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new zi("Inconsistent open depths");return y1(t,e,n,0)}function y1(t,e,n,r){let s=t.index(r),i=t.node(r);if(s==e.index(r)&&r<t.depth-n.openStart){let o=y1(t,e,n,r+1);return i.copy(i.content.replaceChild(s,o))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let o=t.parent,l=o.content;return Dr(o,l.cut(0,t.parentOffset).append(n.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=uS(n,t);return Dr(i,w1(t,o,l,e,r))}else return Dr(i,Tl(t,e,r))}function b1(t,e){if(!e.type.compatibleContent(t.type))throw new zi("Cannot join "+e.type.name+" onto "+t.type.name)}function _u(t,e,n){let r=t.node(n);return b1(r,e.node(n)),r}function Ir(t,e){let n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function Ci(t,e,n,r){let s=(e||t).node(n),i=0,o=e?e.index(n):s.childCount;t&&(i=t.index(n),t.depth>n?i++:t.textOffset&&(Ir(t.nodeAfter,r),i++));for(let l=i;l<o;l++)Ir(s.child(l),r);e&&e.depth==n&&e.textOffset&&Ir(e.nodeBefore,r)}function Dr(t,e){if(!t.type.validContent(e))throw new zi("Invalid content for node "+t.type.name);return t.copy(e)}function w1(t,e,n,r,s){let i=t.depth>s&&_u(t,e,s+1),o=r.depth>s&&_u(n,r,s+1),l=[];return Ci(null,t,s,l),i&&o&&e.index(s)==n.index(s)?(b1(i,o),Ir(Dr(i,w1(t,e,n,r,s+1)),l)):(i&&Ir(Dr(i,Tl(t,e,s+1)),l),Ci(e,n,s,l),o&&Ir(Dr(o,Tl(n,r,s+1)),l)),Ci(r,null,s,l),new j(l)}function Tl(t,e,n){let r=[];if(Ci(null,t,n,r),t.depth>n){let s=_u(t,e,n+1);Ir(Dr(s,Tl(t,e,n+1)),r)}return Ci(e,null,n,r),new j(r)}function uS(t,e){let n=e.depth-t.openStart,s=e.node(n).copy(t.content);for(let i=n-1;i>=0;i--)s=e.node(i).copy(j.from(s));return{start:s.resolveNoCache(t.openStart+n),end:s.resolveNoCache(s.content.size-t.openEnd-n)}}class $i{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],s=e.child(n);return r?e.child(n).cut(r):s}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],s=n==0?0:this.path[n*3-1]+1;for(let i=0;i<e;i++)s+=r.child(i).nodeSize;return s}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return xe.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),s=e.maybeChild(n);if(!r){let l=r;r=s,s=l}let i=r.marks;for(var o=0;o<i.length;o++)i[o].type.spec.inclusive===!1&&(!s||!i[o].isInSet(s.marks))&&(i=i[o--].removeFromSet(i));return i}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,s=e.parent.maybeChild(e.index());for(var i=0;i<r.length;i++)r[i].type.spec.inclusive===!1&&(!s||!r[i].isInSet(s.marks))&&(r=r[i--].removeFromSet(r));return r}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new Vi(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],s=0,i=n;for(let o=e;;){let{index:l,offset:a}=o.content.findIndex(i),c=i-a;if(r.push(o,l,s+a),!c||(o=o.child(l),o.isText))break;i=c-1,s+=a+1}return new $i(n,r,i)}static resolveCached(e,n){let r=$f.get(e);if(r)for(let i=0;i<r.elts.length;i++){let o=r.elts[i];if(o.pos==n)return o}else $f.set(e,r=new dS);let s=r.elts[r.i]=$i.resolve(e,n);return r.i=(r.i+1)%hS,s}}class dS{constructor(){this.elts=[],this.i=0}}const hS=12,$f=new WeakMap;class Vi{constructor(e,n,r){this.$from=e,this.$to=n,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const fS=Object.create(null);let ir=class Nu{constructor(e,n,r,s=xe.none){this.type=e,this.attrs=n,this.marks=s,this.content=r||j.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,n,r,s=0){this.content.nodesBetween(e,n,r,s,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,n,r,s){return this.content.textBetween(e,n,r,s)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,n,r){return this.type==e&&El(this.attrs,n||e.defaultAttrs||fS)&&xe.sameSet(this.marks,r||xe.none)}copy(e=null){return e==this.content?this:new Nu(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new Nu(this.type,this.attrs,this.content,e)}cut(e,n=this.content.size){return e==0&&n==this.content.size?this:this.copy(this.content.cut(e,n))}slice(e,n=this.content.size,r=!1){if(e==n)return q.empty;let s=this.resolve(e),i=this.resolve(n),o=r?0:s.sharedDepth(n),l=s.start(o),c=s.node(o).content.cut(s.pos-l,i.pos-l);return new q(c,s.depth-o,i.depth-o)}replace(e,n,r){return cS(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:s}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(s==e||n.isText)return n;e-=s+1}}childAfter(e){let{index:n,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(n),index:n,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:n,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(n),index:n,offset:r};let s=this.content.child(n-1);return{node:s,index:n-1,offset:r-s.nodeSize}}resolve(e){return $i.resolveCached(this,e)}resolveNoCache(e){return $i.resolve(this,e)}rangeHasMark(e,n,r){let s=!1;return n>e&&this.nodesBetween(e,n,i=>(r.isInSet(i.marks)&&(s=!0),!s)),s}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),x1(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=j.empty,s=0,i=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,s,i),l=o&&o.matchFragment(this.content,n);if(!l||!l.validEnd)return!1;for(let a=s;a<i;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,n,r,s){if(s&&!this.type.allowsMarks(s))return!1;let i=this.contentMatchAt(e).matchType(r),o=i&&i.matchFragment(this.content,n);return o?o.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=xe.none;for(let n=0;n<this.marks.length;n++){let r=this.marks[n];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!xe.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n 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(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let s=j.fromJSON(e,n.content),i=e.nodeType(n.type).create(n.attrs,s,r);return i.type.checkAttrs(i.attrs),i}};ir.prototype.text=void 0;class _l extends ir{constructor(e,n,r,s){if(super(e,n,null,s),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):x1(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new _l(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new _l(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function x1(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class Br{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new pS(e,n);if(r.next==null)return Br.empty;let s=v1(r);r.next&&r.err("Unexpected trailing text");let i=vS(xS(s));return kS(i,r),i}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,r=e.childCount){let s=this;for(let i=n;s&&i<r;i++)s=s.matchType(e.child(i).type);return s}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let s=[this];function i(o,l){let a=o.matchFragment(e,r);if(a&&(!n||a.validEnd))return j.from(l.map(c=>c.createAndFill()));for(let c=0;c<o.next.length;c++){let{type:u,next:d}=o.next[c];if(!(u.isText||u.hasRequiredAttrs())&&s.indexOf(d)==-1){s.push(d);let h=i(d,l.concat(u));if(h)return h}}return null}return i(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let s=r.shift(),i=s.match;if(i.matchType(e)){let o=[];for(let l=s;l.type;l=l.via)o.push(l.type);return o.reverse()}for(let o=0;o<i.next.length;o++){let{type:l,next:a}=i.next[o];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in n)&&(!s.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:s}),n[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let s=0;s<r.next.length;s++)e.indexOf(r.next[s].next)==-1&&n(r.next[s].next)}return n(this),e.map((r,s)=>{let i=s+(r.validEnd?"*":" ")+" ";for(let o=0;o<r.next.length;o++)i+=(o?", ":"")+r.next[o].type.name+"->"+e.indexOf(r.next[o].next);return i}).join(`
|
|
18
|
+
`)}}Br.empty=new Br(!0);class pS{constructor(e,n){this.string=e,this.nodeTypes=n,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 v1(t){let e=[];do e.push(mS(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function mS(t){let e=[];do e.push(gS(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function gS(t){let e=wS(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=yS(t,e);else break;return e}function Vf(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function yS(t,e){let n=Vf(t),r=n;return t.eat(",")&&(t.next!="}"?r=Vf(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function bS(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let s=[];for(let i in n){let o=n[i];o.isInGroup(e)&&s.push(o)}return s.length==0&&t.err("No node type or group '"+e+"' found"),s}function wS(t){if(t.eat("(")){let e=v1(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=bS(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err("Mixing inline and block content"),{type:"name",value:n}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function xS(t){let e=[[]];return s(i(t,0),n()),e;function n(){return e.push([])-1}function r(o,l,a){let c={term:a,to:l};return e[o].push(c),c}function s(o,l){o.forEach(a=>a.to=l)}function i(o,l){if(o.type=="choice")return o.exprs.reduce((a,c)=>a.concat(i(c,l)),[]);if(o.type=="seq")for(let a=0;;a++){let c=i(o.exprs[a],l);if(a==o.exprs.length-1)return c;s(c,l=n())}else if(o.type=="star"){let a=n();return r(l,a),s(i(o.expr,a),a),[r(a)]}else if(o.type=="plus"){let a=n();return s(i(o.expr,l),a),s(i(o.expr,a),a),[r(a)]}else{if(o.type=="opt")return[r(l)].concat(i(o.expr,l));if(o.type=="range"){let a=l;for(let c=0;c<o.min;c++){let u=n();s(i(o.expr,a),u),a=u}if(o.max==-1)s(i(o.expr,a),a);else for(let c=o.min;c<o.max;c++){let u=n();r(a,u),s(i(o.expr,a),u),a=u}return[r(a)]}else{if(o.type=="name")return[r(l,void 0,o.value)];throw new Error("Unknown expr type")}}}}function k1(t,e){return e-t}function Ff(t,e){let n=[];return r(e),n.sort(k1);function r(s){let i=t[s];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(s);for(let o=0;o<i.length;o++){let{term:l,to:a}=i[o];!l&&n.indexOf(a)==-1&&r(a)}}}function vS(t){let e=Object.create(null);return n(Ff(t,0));function n(r){let s=[];r.forEach(o=>{t[o].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let u=0;u<s.length;u++)s[u][0]==l&&(c=s[u][1]);Ff(t,a).forEach(u=>{c||s.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let i=e[r.join(",")]=new Br(r.indexOf(t.length-1)>-1);for(let o=0;o<s.length;o++){let l=s[o][1].sort(k1);i.next.push({type:s[o][0],next:e[l.join(",")]||n(l)})}return i}}function kS(t,e){for(let n=0,r=[t];n<r.length;n++){let s=r[n],i=!s.validEnd,o=[];for(let l=0;l<s.next.length;l++){let{type:a,next:c}=s.next[l];o.push(a.name),i&&!(a.isText||a.hasRequiredAttrs())&&(i=!1),r.indexOf(c)==-1&&r.push(c)}i&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function S1(t){let e=Object.create(null);for(let n in t){let r=t[n];if(!r.hasDefault)return null;e[n]=r.default}return e}function C1(t,e){let n=Object.create(null);for(let r in t){let s=e&&e[r];if(s===void 0){let i=t[r];if(i.hasDefault)s=i.default;else throw new RangeError("No value supplied for attribute "+r)}n[r]=s}return n}function M1(t,e,n,r){for(let s in e)if(!(s in t))throw new RangeError(`Unsupported attribute ${s} for ${n} of type ${r}`);for(let s in t)t[s].validate&&t[s].validate(e[s])}function A1(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new CS(t,r,e[r]);return n}let Uf=class E1{constructor(e,n,r){this.name=e,this.schema=n,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=A1(e,r.attrs),this.defaultAttrs=S1(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Br.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:C1(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new ir(this,this.computeAttrs(e),j.from(n),xe.setFrom(r))}createChecked(e=null,n,r){return n=j.from(n),this.checkContent(n),new ir(this,this.computeAttrs(e),n,xe.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=j.from(n),n.size){let o=this.contentMatch.fillBefore(n);if(!o)return null;n=o.append(n)}let s=this.contentMatch.matchFragment(n),i=s&&s.fillBefore(j.empty,!0);return i?new ir(this,e,n.append(i),xe.setFrom(r)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){M1(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;n<e.length;n++)if(!this.allowsMarkType(e[n].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let n;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?n&&n.push(e[r]):n||(n=e.slice(0,r));return n?n.length?n:xe.none:e}static compile(e,n){let r=Object.create(null);e.forEach((i,o)=>r[i]=new E1(i,n,o));let s=n.spec.topNode||"doc";if(!r[s])throw new RangeError("Schema is missing its top node type ('"+s+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let i in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function SS(t,e,n){let r=n.split("|");return s=>{let i=s===null?"null":typeof s;if(r.indexOf(i)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${i}`)}}class CS{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?SS(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class $a{constructor(e,n,r,s){this.name=e,this.rank=n,this.schema=r,this.spec=s,this.attrs=A1(e,s.attrs),this.excluded=null;let i=S1(this.attrs);this.instance=i?new xe(this,i):null}create(e=null){return!e&&this.instance?this.instance:new xe(this,C1(this.attrs,e))}static compile(e,n){let r=Object.create(null),s=0;return e.forEach((i,o)=>r[i]=new $a(i,s++,n,o)),r}removeFromSet(e){for(var n=0;n<e.length;n++)e[n].type==this&&(e=e.slice(0,n).concat(e.slice(n+1)),n--);return e}isInSet(e){for(let n=0;n<e.length;n++)if(e[n].type==this)return e[n]}checkAttrs(e){M1(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}let T1=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let s in e)n[s]=e[s];n.nodes=Xe.from(e.nodes),n.marks=Xe.from(e.marks||{}),this.nodes=Uf.compile(this.spec.nodes,this),this.marks=$a.compile(this.spec.marks,this);let r=Object.create(null);for(let s in this.nodes){if(s in this.marks)throw new RangeError(s+" can not be both a node and a mark");let i=this.nodes[s],o=i.spec.content||"",l=i.spec.marks;if(i.contentMatch=r[o]||(r[o]=Br.parse(o,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!i.isInline||!i.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=i}i.markSet=l=="_"?null:l?Wf(this,l.split(" ")):l==""||!i.inlineContent?[]:null}for(let s in this.marks){let i=this.marks[s],o=i.spec.excludes;i.excluded=o==null?[i]:o==""?[]:Wf(this,o.split(" "))}this.nodeFromJSON=s=>ir.fromJSON(this,s),this.markFromJSON=s=>xe.fromJSON(this,s),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,s){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Uf){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,r,s)}text(e,n){let r=this.nodes.text;return new _l(r,r.defaultAttrs,e,xe.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}};function Wf(t,e){let n=[];for(let r=0;r<e.length;r++){let s=e[r],i=t.marks[s],o=i;if(i)n.push(i);else for(let l in t.marks){let a=t.marks[l];(s=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(s)>-1)&&n.push(o=a)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function MS(t){return t.tag!=null}function AS(t){return t.style!=null}let Mi=class Ou{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(s=>{if(MS(s))this.tags.push(s);else if(AS(s)){let i=/[^=]*/.exec(s.style)[0];r.indexOf(i)<0&&r.push(i),this.styles.push(s)}}),this.normalizeLists=!this.tags.some(s=>{if(!/^(ul|ol)\b/.test(s.tag)||!s.node)return!1;let i=e.nodes[s.node];return i.contentMatch.matchType(i)})}parse(e,n={}){let r=new qf(this,n,!1);return r.addAll(e,xe.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new qf(this,n,!0);return r.addAll(e,xe.none,n.from,n.to),q.maxOpen(r.finish())}matchTag(e,n,r){for(let s=r?this.tags.indexOf(r)+1:0;s<this.tags.length;s++){let i=this.tags[s];if(_S(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||n.matchesContext(i.context))){if(i.getAttrs){let o=i.getAttrs(e);if(o===!1)continue;i.attrs=o||void 0}return i}}}matchStyle(e,n,r,s){for(let i=s?this.styles.indexOf(s)+1:0;i<this.styles.length;i++){let o=this.styles[i],l=o.style;if(!(l.indexOf(e)!=0||o.context&&!r.matchesContext(o.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=n))){if(o.getAttrs){let a=o.getAttrs(n);if(a===!1)continue;o.attrs=a||void 0}return o}}}static schemaRules(e){let n=[];function r(s){let i=s.priority==null?50:s.priority,o=0;for(;o<n.length;o++){let l=n[o];if((l.priority==null?50:l.priority)<i)break}n.splice(o,0,s)}for(let s in e.marks){let i=e.marks[s].spec.parseDOM;i&&i.forEach(o=>{r(o=Jf(o)),o.mark||o.ignore||o.clearMark||(o.mark=s)})}for(let s in e.nodes){let i=e.nodes[s].spec.parseDOM;i&&i.forEach(o=>{r(o=Jf(o)),o.node||o.ignore||o.mark||(o.node=s)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Ou(e,Ou.schemaRules(e)))}};const _1={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},ES={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},N1={ol:!0,ul:!0},Fi=1,Iu=2,Ai=4;function Kf(t,e,n){return e!=null?(e?Fi:0)|(e==="full"?Iu:0):t&&t.whitespace=="pre"?Fi|Iu:n&~Ai}class Oo{constructor(e,n,r,s,i,o){this.type=e,this.attrs=n,this.marks=r,this.solid=s,this.options=o,this.content=[],this.activeMarks=xe.none,this.match=i||(o&Ai?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(j.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,s;return(s=r.findWrapping(e.type))?(this.match=r,s):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Fi)){let r=this.content[this.content.length-1],s;if(r&&r.isText&&(s=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==s[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-s[0].length))}}let n=j.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(j.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!_1.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class qf{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let s=n.topNode,i,o=Kf(null,n.preserveWhitespace,0)|(r?Ai:0);s?i=new Oo(s.type,s.attrs,xe.none,!0,n.topMatch||s.type.contentMatch,o):r?i=new Oo(null,null,xe.none,!0,null,o):i=new Oo(e.schema.topNodeType,null,xe.none,!0,null,o),this.nodes=[i],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,s=this.top,i=s.options&Iu?"full":this.localPreserveWS||(s.options&Fi)>0,{schema:o}=this.parser;if(i==="full"||s.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(i)if(i==="full")r=r.replace(/\r\n?/g,`
|
|
19
|
+
`);else if(o.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(o.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let a=0;a<l.length;a++)a&&this.insertNode(o.linebreakReplacement.create(),n,!0),l[a]&&this.insertNode(o.text(l[a]),n,!/\S/.test(l[a]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let l=s.content[s.content.length-1],a=e.previousSibling;(!l||a&&a.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(r=r.slice(1))}r&&this.insertNode(o.text(r),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){let s=this.localPreserveWS,i=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),l;N1.hasOwnProperty(o)&&this.parser.normalizeLists&&TS(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:ES.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,n);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let c,u=this.needsBlock;if(_1.hasOwnProperty(o))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),c=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let d=a&&a.skip?n:this.readStyles(e,n);d&&this.addAll(e,d),c&&this.sync(i),this.needsBlock=u}else{let c=this.readStyles(e,n);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=s}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
20
|
+
`),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let s=0;s<this.parser.matchedStyles.length;s++){let i=this.parser.matchedStyles[s],o=r.getPropertyValue(i);if(o)for(let l=void 0;;){let a=this.parser.matchStyle(i,o,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?n=n.filter(c=>!a.clearMark(c)):n=n.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return n}addElementByRule(e,n,r,s){let i,o;if(n.node)if(o=this.parser.schema.nodes[n.node],o.isLeaf)this.insertNode(o.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(o,n.attrs||null,r,n.preserveWhitespace);a&&(i=!0,r=a)}else{let a=this.parser.schema.marks[n.mark];r=r.concat(a.create(n.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(s)this.addElement(e,r,s);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof n.contentElement=="string"?a=e.querySelector(n.contentElement):typeof n.contentElement=="function"?a=n.contentElement(e):n.contentElement&&(a=n.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}i&&this.sync(l)&&this.open--}addAll(e,n,r,s){let i=r||0;for(let o=r?e.childNodes[r]:e.firstChild,l=s==null?null:e.childNodes[s];o!=l;o=o.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(o,n);this.findAtPoint(e,i)}findPlace(e,n,r){let s,i;for(let o=this.open,l=0;o>=0;o--){let a=this.nodes[o],c=a.findWrapping(e);if(c&&(!s||s.length>c.length+l)&&(s=c,i=a,!c.length))break;if(a.solid){if(r)break;l+=2}}if(!s)return null;this.sync(i);for(let o=0;o<s.length;o++)n=this.enterInner(s[o],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(n=this.enterInner(i,null,n))}let s=this.findPlace(e,n,r);if(s){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let o=xe.none;for(let l of s.concat(e.marks))(i.type?i.type.allowsMarkType(l.type):Gf(l.type,e.type))&&(o=l.addToSet(o));return i.content.push(e.mark(o)),!0}return!1}enter(e,n,r,s){let i=this.findPlace(e.create(n),r,!1);return i&&(i=this.enterInner(e,n,r,!0,s)),i}enterInner(e,n,r,s=!1,i){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let l=Kf(e,i,o.options);o.options&Ai&&o.content.length==0&&(l|=Ai);let a=xe.none;return r=r.filter(c=>(o.type?o.type.allowsMarkType(c.type):Gf(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new Oo(e,n,a,s,null,l)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].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 n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=Fi)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let s=r.length-1;s>=0;s--)e+=r[s].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&this.find)for(let s=0;s<this.find.length;s++)this.find[s].pos==null&&e.nodeType==1&&e.contains(this.find[s].node)&&n.compareDocumentPosition(this.find[s].node)&(r?2:4)&&(this.find[s].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,s=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(s?0:1),o=(l,a)=>{for(;l>=0;l--){let c=n[l];if(c==""){if(l==n.length-1||l==0)continue;for(;a>=i;a--)if(o(l-1,a))return!0;return!1}else{let u=a>0||a==0&&s?this.nodes[a].type:r&&a>=i?r.node(a-i).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;a--}}return!0};return o(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function TS(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&N1.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function _S(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function Jf(t){let e={};for(let n in t)e[n]=t[n];return e}function Gf(t,e){let n=e.schema.nodes;for(let r in n){let s=n[r];if(!s.allowsMarkType(t))continue;let i=[],o=l=>{i.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:u}=l.edge(a);if(c==e||i.indexOf(u)<0&&o(u))return!0}};if(o(s.contentMatch))return!0}}class Xr{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=Io(n).createDocumentFragment());let s=r,i=[];return e.forEach(o=>{if(i.length||o.marks.length){let l=0,a=0;for(;l<i.length&&a<o.marks.length;){let c=o.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(i[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<i.length;)s=i.pop()[1];for(;a<o.marks.length;){let c=o.marks[a++],u=this.serializeMark(c,o.isInline,n);u&&(i.push([c,s]),s.appendChild(u.dom),s=u.contentDOM||u.dom)}}s.appendChild(this.serializeNodeInner(o,n))}),r}serializeNodeInner(e,n){if(e.isText)return Io(n).createTextNode(e.text);let{dom:r,contentDOM:s}=sl(Io(n),this.nodes[e.type.name](e),null,e.attrs);if(s){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,s)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let s=e.marks.length-1;s>=0;s--){let i=this.serializeMark(e.marks[s],e.isInline,n);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,n,r={}){let s=this.marks[e.type.name];return s&&sl(Io(r),s(e,n),null,e.attrs)}static renderSpec(e,n,r=null,s){return typeof n=="string"?{dom:e.createTextNode(n)}:sl(e,n,r,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Xr(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=Yf(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return Yf(e.marks)}}function Yf(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Io(t){return t.document||window.document}const Xf=new WeakMap;function NS(t){let e=Xf.get(t);return e===void 0&&Xf.set(t,e=OS(t)),e}function OS(t){let e=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let s=0;s<r.length;s++)n(r[s]);else for(let s in r)n(r[s])}return n(t),e}function sl(t,e,n,r){if(e.nodeType==1)return{dom:e};if(e.dom&&e.dom.nodeType==1)return e;let s=e[0],i;if(typeof s!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(i=NS(r))&&i.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=s.indexOf(" ");o>0&&(n=s.slice(0,o),s=s.slice(o+1));let l,a=n?t.createElementNS(n,s):t.createElement(s),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let d in c)if(c[d]!=null){let h=d.indexOf(" ");h>0?a.setAttributeNS(d.slice(0,h),d.slice(h+1),c[d]):d=="style"&&a.style?a.style.cssText=c[d]:a.setAttribute(d,c[d])}}for(let d=u;d<e.length;d++){let h=e[d];if(h===0){if(d<e.length-1||d>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else if(typeof h=="string")a.appendChild(t.createTextNode(h));else{let{dom:f,contentDOM:p}=sl(t,h,n,r);if(a.appendChild(f),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}const O1=65535,I1=Math.pow(2,16);function IS(t,e){return t+e*I1}function Zf(t){return t&O1}function DS(t){return(t-(t&O1))/I1}const D1=1,R1=2,il=4,L1=8;let Du=class{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&L1)>0}get deletedBefore(){return(this.delInfo&(D1|il))>0}get deletedAfter(){return(this.delInfo&(R1|il))>0}get deletedAcross(){return(this.delInfo&il)>0}},Hr=class ls{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&ls.empty)return ls.empty}recover(e){let n=0,r=Zf(e);if(!this.inverted)for(let s=0;s<r;s++)n+=this.ranges[s*3+2]-this.ranges[s*3+1];return this.ranges[r*3]+n+DS(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let s=0,i=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?s:0);if(a>e)break;let c=this.ranges[l+i],u=this.ranges[l+o],d=a+c;if(e<=d){let h=c?e==a?-1:e==d?1:n:n,f=a+s+(h<0?0:u);if(r)return f;let p=e==(n<0?a:d)?null:IS(l/3,e-a),g=e==a?R1:e==d?D1:il;return(n<0?e!=a:e!=d)&&(g|=L1),new Du(f,g,p)}s+=u-c}return r?e+s:new Du(e+s,0,null)}touches(e,n){let r=0,s=Zf(n),i=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+i],u=a+c;if(e<=u&&l==s*3)return!0;r+=this.ranges[l+o]-c}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let s=0,i=0;s<this.ranges.length;s+=3){let o=this.ranges[s],l=o-(this.inverted?i:0),a=o+(this.inverted?0:i),c=this.ranges[s+n],u=this.ranges[s+r];e(l,l+c,a,a+u),i+=u-c}}invert(){return new ls(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?ls.empty:new ls(e<0?[0,-e,0]:[0,0,e])}};Hr.empty=new Hr([]);class Ui{constructor(e,n,r=0,s=e?e.length:0){this.mirror=n,this.from=r,this.to=s,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new Ui(this._maps,this.mirror,e,n)}appendMap(e,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(e){for(let n=0,r=this._maps.length;n<e._maps.length;n++){let s=e.getMirror(n);this.appendMap(e._maps[n],s!=null&&s<n?r+s:void 0)}}getMirror(e){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==e)return this.mirror[n+(n%2?-1:1)]}}setMirror(e,n){this.mirror||(this.mirror=[]),this.mirror.push(e,n)}appendMappingInverted(e){for(let n=e.maps.length-1,r=this._maps.length+e._maps.length;n>=0;n--){let s=e.getMirror(n);this.appendMap(e._maps[n].invert(),s!=null&&s>n?r-s-1:void 0)}}invert(){let e=new Ui;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let s=0;for(let i=this.from;i<this.to;i++){let o=this._maps[i],l=o.mapResult(e,n);if(l.recover!=null){let a=this.getMirror(i);if(a!=null&&a>i&&a<this.to){i=a,e=this._maps[a].recover(l.recover);continue}}s|=l.delInfo,e=l.pos}return r?e:new Du(e,s,null)}}const Ec=Object.create(null);let lt=class{getMap(){return Hr.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Ec[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in Ec)throw new RangeError("Duplicate use of step JSON ID "+e);return Ec[e]=n,n.prototype.jsonID=e,n}},ft=class ii{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new ii(e,null)}static fail(e){return new ii(null,e)}static fromReplace(e,n,r,s){try{return ii.ok(e.replace(n,r,s))}catch(i){if(i instanceof zi)return ii.fail(i.message);throw i}}};function Jd(t,e,n){let r=[];for(let s=0;s<t.childCount;s++){let i=t.child(s);i.content.size&&(i=i.copy(Jd(i.content,e,i))),i.isInline&&(i=e(i,n,s)),r.push(i)}return j.fromArray(r)}let Gd=class oi extends lt{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),s=r.node(r.sharedDepth(this.to)),i=new q(Jd(n.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),s),n.openStart,n.openEnd);return ft.fromReplace(e,this.from,this.to,i)}invert(){return new zs(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new oi(n.pos,r.pos,this.mark)}merge(e){return e instanceof oi&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new oi(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new oi(n.from,n.to,e.markFromJSON(n.mark))}};lt.jsonID("addMark",Gd);let zs=class li extends lt{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new q(Jd(n.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),n.openStart,n.openEnd);return ft.fromReplace(e,this.from,this.to,r)}invert(){return new Gd(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new li(n.pos,r.pos,this.mark)}merge(e){return e instanceof li&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new li(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,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new li(n.from,n.to,e.markFromJSON(n.mark))}};lt.jsonID("removeMark",zs);let Yd=class ai extends lt{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return ft.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return ft.fromReplace(e,this.pos,this.pos+1,new q(j.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let s=0;s<n.marks.length;s++)if(!n.marks[s].isInSet(r))return new ai(this.pos,n.marks[s]);return new ai(this.pos,this.mark)}}return new Nl(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new ai(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new ai(n.pos,e.markFromJSON(n.mark))}};lt.jsonID("addNodeMark",Yd);let Nl=class Ru extends lt{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return ft.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return ft.fromReplace(e,this.pos,this.pos+1,new q(j.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new Yd(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Ru(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Ru(n.pos,e.markFromJSON(n.mark))}};lt.jsonID("removeNodeMark",Nl);let Vt=class Gn extends lt{constructor(e,n,r,s=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=s}apply(e){return this.structure&&Lu(e,this.from,this.to)?ft.fail("Structure replace would overwrite content"):ft.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Hr([this.from,this.to-this.from,this.slice.size])}invert(e){return new Gn(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.to,-1),r=this.from==this.to&&Gn.MAP_BIAS<0?n:e.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new Gn(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Gn)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?q.empty:new q(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Gn(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?q.empty:new q(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Gn(e.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Gn(n.from,n.to,q.fromJSON(e,n.slice),!!n.structure)}};Vt.MAP_BIAS=1;lt.jsonID("replace",Vt);let kt=class ol extends lt{constructor(e,n,r,s,i,o,l=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=s,this.slice=i,this.insert=o,this.structure=l}apply(e){if(this.structure&&(Lu(e,this.from,this.gapFrom)||Lu(e,this.gapTo,this.to)))return ft.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return ft.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?ft.fromReplace(e,this.from,this.to,r):ft.fail("Content does not fit in gap")}getMap(){return new Hr([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new ol(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),s=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||s<n.pos||i>r.pos?null:new ol(n.pos,r.pos,s,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new ol(n.from,n.to,n.gapFrom,n.gapTo,q.fromJSON(e,n.slice),n.insert,!!n.structure)}};lt.jsonID("replaceAround",kt);function Lu(t,e,n){let r=t.resolve(e),s=n-e,i=r.depth;for(;s>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,s--;if(s>0){let o=r.node(i).maybeChild(r.indexAfter(i));for(;s>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,s--}}return!1}function RS(t,e,n,r){let s=[],i=[],o,l;t.doc.nodesBetween(e,n,(a,c,u)=>{if(!a.isInline)return;let d=a.marks;if(!r.isInSet(d)&&u.type.allowsMarkType(r.type)){let h=Math.max(c,e),f=Math.min(c+a.nodeSize,n),p=r.addToSet(d);for(let g=0;g<d.length;g++)d[g].isInSet(p)||(o&&o.to==h&&o.mark.eq(d[g])?o.to=f:s.push(o=new zs(h,f,d[g])));l&&l.to==h?l.to=f:i.push(l=new Gd(h,f,r))}}),s.forEach(a=>t.step(a)),i.forEach(a=>t.step(a))}function LS(t,e,n,r){let s=[],i=0;t.doc.nodesBetween(e,n,(o,l)=>{if(!o.isInline)return;i++;let a=null;if(r instanceof $a){let c=o.marks,u;for(;u=r.isInSet(c);)(a||(a=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(o.marks)&&(a=[r]):a=o.marks;if(a&&a.length){let c=Math.min(l+o.nodeSize,n);for(let u=0;u<a.length;u++){let d=a[u],h;for(let f=0;f<s.length;f++){let p=s[f];p.step==i-1&&d.eq(s[f].style)&&(h=p)}h?(h.to=c,h.step=i):s.push({style:d,from:Math.max(l,e),to:c,step:i})}}}),s.forEach(o=>t.step(new zs(o.from,o.to,o.style)))}function Xd(t,e,n,r=n.contentMatch,s=!0){let i=t.doc.nodeAt(e),o=[],l=e+1;for(let a=0;a<i.childCount;a++){let c=i.child(a),u=l+c.nodeSize,d=r.matchType(c.type);if(!d)o.push(new Vt(l,u,q.empty));else{r=d;for(let h=0;h<c.marks.length;h++)n.allowsMarkType(c.marks[h].type)||t.step(new zs(l,u,c.marks[h]));if(s&&c.isText&&n.whitespace!="pre"){let h,f=/\r?\n|\r/g,p;for(;h=f.exec(c.text);)p||(p=new q(j.from(n.schema.text(" ",n.allowedMarks(c.marks))),0,0)),o.push(new Vt(l+h.index,l+h.index+h[0].length,p))}}l=u}if(!r.validEnd){let a=r.fillBefore(j.empty,!0);t.replace(l,l,new q(a,0,0))}for(let a=o.length-1;a>=0;a--)t.step(o[a])}function jS(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function $s(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,s=0,i=0;;--r){let o=t.$from.node(r),l=t.$from.index(r)+s,a=t.$to.indexAfter(r)-i;if(r<t.depth&&o.canReplace(l,a,n))return r;if(r==0||o.type.spec.isolating||!jS(o,l,a))break;l&&(s=1),a<o.childCount&&(i=1)}return null}function PS(t,e,n){let{$from:r,$to:s,depth:i}=e,o=r.before(i+1),l=s.after(i+1),a=o,c=l,u=j.empty,d=0;for(let p=i,g=!1;p>n;p--)g||r.index(p)>0?(g=!0,u=j.from(r.node(p).copy(u)),d++):a--;let h=j.empty,f=0;for(let p=i,g=!1;p>n;p--)g||s.after(p+1)<s.end(p)?(g=!0,h=j.from(s.node(p).copy(h)),f++):c++;t.step(new kt(a,c,o,l,new q(u.append(h),d,f),u.size-d,!0))}function Zd(t,e,n=null,r=t){let s=BS(t,e),i=s&&HS(r,e);return i?s.map(Qf).concat({type:e,attrs:n}).concat(i.map(Qf)):null}function Qf(t){return{type:t,attrs:null}}function BS(t,e){let{parent:n,startIndex:r,endIndex:s}=t,i=n.contentMatchAt(r).findWrapping(e);if(!i)return null;let o=i.length?i[0]:e;return n.canReplaceWith(r,s,o)?i:null}function HS(t,e){let{parent:n,startIndex:r,endIndex:s}=t,i=n.child(r),o=e.contentMatch.findWrapping(i.type);if(!o)return null;let a=(o.length?o[o.length-1]:e).contentMatch;for(let c=r;a&&c<s;c++)a=a.matchType(n.child(c).type);return!a||!a.validEnd?null:o}function zS(t,e,n){let r=j.empty;for(let o=n.length-1;o>=0;o--){if(r.size){let l=n[o].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=j.from(n[o].type.create(n[o].attrs,r))}let s=e.start,i=e.end;t.step(new kt(s,i,s,i,new q(r,0,0),n.length,!0))}function $S(t,e,n,r,s){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=t.steps.length;t.doc.nodesBetween(e,n,(o,l)=>{let a=typeof s=="function"?s(o):s;if(o.isTextblock&&!o.hasMarkup(r,a)&&VS(t.doc,t.mapping.slice(i).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let f=r.whitespace=="pre",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);f&&!p?c=!1:!f&&p&&(c=!0)}c===!1&&P1(t,o,l,i),Xd(t,t.mapping.slice(i).map(l,1),r,void 0,c===null);let u=t.mapping.slice(i),d=u.map(l,1),h=u.map(l+o.nodeSize,1);return t.step(new kt(d,h,d+1,h-1,new q(j.from(r.create(a,null,o.marks)),0,0),1,!0)),c===!0&&j1(t,o,l,i),!1}})}function j1(t,e,n,r){e.forEach((s,i)=>{if(s.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(s.text);){let a=t.mapping.slice(r).map(n+1+i+o.index);t.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function P1(t,e,n,r){e.forEach((s,i)=>{if(s.type==s.type.schema.linebreakReplacement){let o=t.mapping.slice(r).map(n+1+i);t.replaceWith(o,o+1,e.type.schema.text(`
|
|
21
|
+
`))}})}function VS(t,e,n){let r=t.resolve(e),s=r.index();return r.parent.canReplaceWith(s,s+1,n)}function FS(t,e,n,r,s){let i=t.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");n||(n=i.type);let o=n.create(r,null,s||i.marks);if(i.isLeaf)return t.replaceWith(e,e+i.nodeSize,o);if(!n.validContent(i.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new kt(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new q(j.from(o),0,0),1,!0))}function Dn(t,e,n=1,r){let s=t.resolve(e),i=s.depth-n,o=r&&r[r.length-1]||s.parent;if(i<0||s.parent.type.spec.isolating||!s.parent.canReplace(s.index(),s.parent.childCount)||!o.type.validContent(s.parent.content.cutByIndex(s.index(),s.parent.childCount)))return!1;for(let c=s.depth-1,u=n-2;c>i;c--,u--){let d=s.node(c),h=s.index(c);if(d.type.spec.isolating)return!1;let f=d.content.cutByIndex(h,d.childCount),p=r&&r[u+1];p&&(f=f.replaceChild(0,p.type.create(p.attrs)));let g=r&&r[u]||d;if(!d.canReplace(h+1,d.childCount)||!g.type.validContent(f))return!1}let l=s.indexAfter(i),a=r&&r[0];return s.node(i).canReplaceWith(l,l,a?a.type:s.node(i+1).type)}function US(t,e,n=1,r){let s=t.doc.resolve(e),i=j.empty,o=j.empty;for(let l=s.depth,a=s.depth-n,c=n-1;l>a;l--,c--){i=j.from(s.node(l).copy(i));let u=r&&r[c];o=j.from(u?u.type.create(u.attrs,o):s.node(l).copy(o))}t.step(new Vt(e,e,new q(i.append(o),n,n),!0))}function gr(t,e){let n=t.resolve(e),r=n.index();return B1(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function WS(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let s=0;s<e.childCount;s++){let i=e.child(s),o=i.type==r?t.type.schema.nodes.text:i.type;if(n=n.matchType(o),!n||!t.type.allowsMarks(i.marks))return!1}return n.validEnd}function B1(t,e){return!!(t&&e&&!t.isLeaf&&WS(t,e))}function Va(t,e,n=-1){let r=t.resolve(e);for(let s=r.depth;;s--){let i,o,l=r.index(s);if(s==r.depth?(i=r.nodeBefore,o=r.nodeAfter):n>0?(i=r.node(s+1),l++,o=r.node(s).maybeChild(l)):(i=r.node(s).maybeChild(l-1),o=r.node(s+1)),i&&!i.isTextblock&&B1(i,o)&&r.node(s).canReplace(l,l+1))return e;if(s==0)break;e=n<0?r.before(s):r.after(s)}}function KS(t,e,n){let r=null,{linebreakReplacement:s}=t.doc.type.schema,i=t.doc.resolve(e-n),o=i.node().type;if(s&&o.inlineContent){let u=o.whitespace=="pre",d=!!o.contentMatch.matchType(s);u&&!d?r=!1:!u&&d&&(r=!0)}let l=t.steps.length;if(r===!1){let u=t.doc.resolve(e+n);P1(t,u.node(),u.before(),l)}o.inlineContent&&Xd(t,e+n-1,o,i.node().contentMatchAt(i.index()),r==null);let a=t.mapping.slice(l),c=a.map(e-n);if(t.step(new Vt(c,a.map(e+n,-1),q.empty,!0)),r===!0){let u=t.doc.resolve(c);j1(t,u.node(),u.before(),t.steps.length)}return t}function qS(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let s=r.depth-1;s>=0;s--){let i=r.index(s);if(r.node(s).canReplaceWith(i,i,n))return r.before(s+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(let s=r.depth-1;s>=0;s--){let i=r.indexAfter(s);if(r.node(s).canReplaceWith(i,i,n))return r.after(s+1);if(i<r.node(s).childCount)return null}return null}function H1(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let s=n.content;for(let i=0;i<n.openStart;i++)s=s.firstChild.content;for(let i=1;i<=(n.openStart==0&&n.size?2:1);i++)for(let o=r.depth;o>=0;o--){let l=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,a=r.index(o)+(l>0?1:0),c=r.node(o),u=!1;if(i==1)u=c.canReplace(a,a,s);else{let d=c.contentMatchAt(a).findWrapping(s.firstChild.type);u=d&&c.canReplaceWith(a,a,d[0])}if(u)return l==0?r.pos:l<0?r.before(o+1):r.after(o+1)}return null}function Fa(t,e,n=e,r=q.empty){if(e==n&&!r.size)return null;let s=t.resolve(e),i=t.resolve(n);return z1(s,i,r)?new Vt(e,n,r):new JS(s,i,r).fit()}function z1(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class JS{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=j.empty;for(let s=0;s<=e.depth;s++){let i=e.node(s);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(s))})}for(let s=e.depth;s>0;s--)this.placed=j.from(e.node(s).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,s=this.close(e<0?this.$to:r.doc.resolve(e));if(!s)return null;let i=this.placed,o=r.depth,l=s.depth;for(;o&&l&&i.childCount==1;)i=i.firstChild.content,o--,l--;let a=new q(i,o,l);return e>-1?new kt(r.pos,e,this.$to.pos,this.$to.end(),a,n):a.size||r.pos!=this.$to.pos?new Vt(r.pos,s.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,s=this.unplaced.openEnd;r<e;r++){let i=n.firstChild;if(n.childCount>1&&(s=0),i.type.spec.isolating&&s<=r){e=r;break}n=i.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let s,i=null;r?(i=Tc(this.unplaced.content,r-1).firstChild,s=i.content):s=this.unplaced.content;let o=s.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],u,d=null;if(n==1&&(o?c.matchType(o.type)||(d=c.fillBefore(j.from(o),!1)):i&&a.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:l,parent:i,inject:d};if(n==2&&o&&(u=c.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:l,parent:i,wrap:u};if(i&&c.matchType(i.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,s=Tc(e,n);return!s.childCount||s.firstChild.isLeaf?!1:(this.unplaced=new q(e,n+1,Math.max(r,s.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,s=Tc(e,n);if(s.childCount<=1&&n>0){let i=e.size-n<=n+s.size;this.unplaced=new q(ci(e,n-1,1),n-1,i?n-1:r)}else this.unplaced=new q(ci(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:s,wrap:i}){for(;this.depth>n;)this.closeFrontierNode();if(i)for(let g=0;g<i.length;g++)this.openFrontierNode(i[g]);let o=this.unplaced,l=r?r.content:o.content,a=o.openStart-e,c=0,u=[],{match:d,type:h}=this.frontier[n];if(s){for(let g=0;g<s.childCount;g++)u.push(s.child(g));d=d.matchFragment(s)}let f=l.size+e-(o.content.size-o.openEnd);for(;c<l.childCount;){let g=l.child(c),y=d.matchType(g.type);if(!y)break;c++,(c>1||a==0||g.content.size)&&(d=y,u.push($1(g.mark(h.allowedMarks(g.marks)),c==1?a:0,c==l.childCount?f:-1)))}let p=c==l.childCount;p||(f=-1),this.placed=ui(this.placed,n,j.from(u)),this.frontier[n].match=d,p&&f<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let g=0,y=l;g<f;g++){let b=y.lastChild;this.frontier.push({type:b.type,match:b.contentMatchAt(b.childCount)}),y=b.content}this.unplaced=p?e==0?q.empty:new q(ci(o.content,e-1,1),e-1,f<0?o.openEnd:e-1):new q(ci(o.content,e,c),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!_c(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.depth==this.depth)return-1;let{depth:r}=this.$to,s=this.$to.after(r);for(;r>1&&s==this.$to.end(--r);)++s;return s}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:s}=this.frontier[n],i=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),o=_c(e,n,s,r,i);if(o){for(let l=n-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],u=_c(e,l,c,a,!0);if(!u||u.childCount)continue e}return{depth:n,fit:o,move:i?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=ui(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let s=e.node(r),i=s.type.contentMatch.fillBefore(s.content,!0,e.index(r));this.openFrontierNode(s.type,s.attrs,i)}return e}openFrontierNode(e,n=null,r){let s=this.frontier[this.depth];s.match=s.match.matchType(e),this.placed=ui(this.placed,this.depth,j.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(j.empty,!0);n.childCount&&(this.placed=ui(this.placed,this.frontier.length,n))}}function ci(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(ci(t.firstChild.content,e-1,n)))}function ui(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(ui(t.lastChild.content,e-1,n)))}function Tc(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function $1(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,$1(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(j.empty,!0)))),t.copy(r)}function _c(t,e,n,r,s){let i=t.node(e),o=s?t.indexAfter(e):t.index(e);if(o==i.childCount&&!n.compatibleContent(i.type))return null;let l=r.fillBefore(i.content,!0,o);return l&&!GS(n,i.content,o)?l:null}function GS(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function YS(t){return t.spec.defining||t.spec.definingForContent}function XS(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let s=t.doc.resolve(e),i=t.doc.resolve(n);if(z1(s,i,r))return t.step(new Vt(e,n,r));let o=F1(s,i);o[o.length-1]==0&&o.pop();let l=-(s.depth+1);o.unshift(l);for(let h=s.depth,f=s.pos-1;h>0;h--,f--){let p=s.node(h).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;o.indexOf(h)>-1?l=h:s.before(h)==f&&o.splice(1,0,-h)}let a=o.indexOf(l),c=[],u=r.openStart;for(let h=r.content,f=0;;f++){let p=h.firstChild;if(c.push(p),f==r.openStart)break;h=p.content}for(let h=u-1;h>=0;h--){let f=c[h],p=YS(f.type);if(p&&!f.sameMarkup(s.node(Math.abs(l)-1)))u=h;else if(p||!f.type.isTextblock)break}for(let h=r.openStart;h>=0;h--){let f=(h+u+1)%(r.openStart+1),p=c[f];if(p)for(let g=0;g<o.length;g++){let y=o[(g+a)%o.length],b=!0;y<0&&(b=!1,y=-y);let w=s.node(y-1),v=s.index(y-1);if(w.canReplaceWith(v,v,p.type,p.marks))return t.replace(s.before(y),b?i.after(y):n,new q(V1(r.content,0,r.openStart,f),f,r.openEnd))}}let d=t.steps.length;for(let h=o.length-1;h>=0&&(t.replace(e,n,r),!(t.steps.length>d));h--){let f=o[h];f<0||(e=s.before(f),n=i.after(f))}}function V1(t,e,n,r,s){if(e<n){let i=t.firstChild;t=t.replaceChild(0,i.copy(V1(i.content,e+1,n,r,i)))}if(e>r){let i=s.contentMatchAt(0),o=i.fillBefore(t).append(t);t=o.append(i.matchFragment(o).fillBefore(j.empty,!0))}return t}function ZS(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let s=qS(t.doc,e,r.type);s!=null&&(e=n=s)}t.replaceRange(e,n,new q(j.from(r),0,0))}function QS(t,e,n){let r=t.doc.resolve(e),s=t.doc.resolve(n);if(r.parent.isTextblock&&s.parent.isTextblock&&r.start()!=s.start()&&r.parentOffset==0&&s.parentOffset==0){let o=r.sharedDepth(n),l=!1;for(let a=r.depth;a>o;a--)r.node(a).type.spec.isolating&&(l=!0);for(let a=s.depth;a>o;a--)s.node(a).type.spec.isolating&&(l=!0);if(!l){for(let a=r.depth;a>0&&e==r.start(a);a--)e=r.before(a);for(let a=s.depth;a>0&&n==s.start(a);a--)n=s.before(a);r=t.doc.resolve(e),s=t.doc.resolve(n)}}let i=F1(r,s);for(let o=0;o<i.length;o++){let l=i[o],a=o==i.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return t.delete(r.start(l),s.end(l));if(l>0&&(a||r.node(l-1).canReplace(r.index(l-1),s.indexAfter(l-1))))return t.delete(r.before(l),s.after(l))}for(let o=1;o<=r.depth&&o<=s.depth;o++)if(e-r.start(o)==r.depth-o&&n>r.end(o)&&s.end(o)-n!=s.depth-o&&r.start(o-1)==s.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),s.index(o-1)))return t.delete(r.before(o),n);t.delete(e,n)}function F1(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let s=r;s>=0;s--){let i=t.start(s);if(i<t.pos-(t.depth-s)||e.end(s)>e.pos+(e.depth-s)||t.node(s).type.spec.isolating||e.node(s).type.spec.isolating)break;(i==e.start(s)||s==t.depth&&s==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&s&&e.start(s-1)==i-1)&&n.push(s)}return n}let U1=class ll extends lt{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return ft.fail("No node at attribute step's position");let r=Object.create(null);for(let i in n.attrs)r[i]=n.attrs[i];r[this.attr]=this.value;let s=n.type.create(r,null,n.marks);return ft.fromReplace(e,this.pos,this.pos+1,new q(j.from(s),0,n.isLeaf?0:1))}getMap(){return Hr.empty}invert(e){return new ll(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new ll(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new ll(n.pos,n.attr,n.value)}};lt.jsonID("attr",U1);let W1=class ju extends lt{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let s in e.attrs)n[s]=e.attrs[s];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return ft.ok(r)}getMap(){return Hr.empty}invert(e){return new ju(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new ju(n.attr,n.value)}};lt.jsonID("docAttr",W1);let ks=class extends Error{};ks=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};ks.prototype=Object.create(Error.prototype);ks.prototype.constructor=ks;ks.prototype.name="TransformError";class Qd{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Ui}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new ks(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,n=-1e9;for(let r=0;r<this.mapping.maps.length;r++){let s=this.mapping.maps[r];r&&(e=s.map(e,1),n=s.map(n,-1)),s.forEach((i,o,l,a)=>{e=Math.min(e,l),n=Math.max(n,a)})}return e==1e9?null:{from:e,to:n}}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=q.empty){let s=Fa(this.doc,e,n,r);return s&&this.step(s),this}replaceWith(e,n,r){return this.replace(e,n,new q(j.from(r),0,0))}delete(e,n){return this.replace(e,n,q.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return XS(this,e,n,r),this}replaceRangeWith(e,n,r){return ZS(this,e,n,r),this}deleteRange(e,n){return QS(this,e,n),this}lift(e,n){return PS(this,e,n),this}join(e,n=1){return KS(this,e,n),this}wrap(e,n){return zS(this,e,n),this}setBlockType(e,n=e,r,s=null){return $S(this,e,n,r,s),this}setNodeMarkup(e,n,r=null,s){return FS(this,e,n,r,s),this}setNodeAttribute(e,n,r){return this.step(new U1(e,n,r)),this}setDocAttribute(e,n){return this.step(new W1(e,n)),this}addNodeMark(e,n){return this.step(new Yd(e,n)),this}removeNodeMark(e,n){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n instanceof xe)n.isInSet(r.marks)&&this.step(new Nl(e,n));else{let s=r.marks,i,o=[];for(;i=n.isInSet(s);)o.push(new Nl(e,i)),s=i.removeFromSet(s);for(let l=o.length-1;l>=0;l--)this.step(o[l])}return this}split(e,n=1,r){return US(this,e,n,r),this}addMark(e,n,r){return RS(this,e,n,r),this}removeMark(e,n,r){return LS(this,e,n,r),this}clearIncompatible(e,n,r){return Xd(this,e,n,r),this}}const Nc=Object.create(null);let te=class{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new eh(e.min(n),e.max(n))]}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 n=0;n<e.length;n++)if(e[n].$from.pos!=e[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,n=q.empty){let r=n.content.lastChild,s=null;for(let l=0;l<n.openEnd;l++)s=r,r=r.lastChild;let i=e.steps.length,o=this.ranges;for(let l=0;l<o.length;l++){let{$from:a,$to:c}=o[l],u=e.mapping.slice(i);e.replaceRange(u.map(a.pos),u.map(c.pos),l?q.empty:n),l==0&&np(e,i,(r?r.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,s=this.ranges;for(let i=0;i<s.length;i++){let{$from:o,$to:l}=s[i],a=e.mapping.slice(r),c=a.map(o.pos),u=a.map(l.pos);i?e.deleteRange(c,u):(e.replaceRangeWith(c,u,n),np(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let s=e.parent.inlineContent?new ee(e):as(e.node(0),e.parent,e.pos,e.index(),n,r);if(s)return s;for(let i=e.depth-1;i>=0;i--){let o=n<0?as(e.node(0),e.node(i),e.before(i+1),e.index(i),n,r):as(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,n,r);if(o)return o}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new dn(e.node(0))}static atStart(e){return as(e,e,0,0,1)||new dn(e)}static atEnd(e){return as(e,e,e.content.size,e.childCount,-1)||new dn(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Nc[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in Nc)throw new RangeError("Duplicate use of selection JSON ID "+e);return Nc[e]=n,n.prototype.jsonID=e,n}getBookmark(){return ee.between(this.$anchor,this.$head).getBookmark()}};te.prototype.visible=!0;let eh=class{constructor(e,n){this.$from=e,this.$to=n}},ep=!1;function tp(t){!ep&&!t.parent.inlineContent&&(ep=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}let ee=class di extends te{constructor(e,n=e){tp(e),tp(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return te.near(r);let s=e.resolve(n.map(this.anchor));return new di(s.parent.inlineContent?s:r,r)}replace(e,n=q.empty){if(super.replace(e,n),n==q.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof di&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new K1(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new di(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let s=e.resolve(n);return new this(s,r==n?s:e.resolve(r))}static between(e,n,r){let s=e.pos-n.pos;if((!r||s)&&(r=s>=0?1:-1),!n.parent.inlineContent){let i=te.findFrom(n,r,!0)||te.findFrom(n,-r,!0);if(i)n=i.$head;else return te.near(n,r)}return e.parent.inlineContent||(s==0?e=n:(e=(te.findFrom(e,-r,!0)||te.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=s<0&&(e=n))),new di(e,n)}};te.jsonID("text",ee);let K1=class q1{constructor(e,n){this.anchor=e,this.head=n}map(e){return new q1(e.map(this.anchor),e.map(this.head))}resolve(e){return ee.between(e.resolve(this.anchor),e.resolve(this.head))}},Y=class hi extends te{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:s}=n.mapResult(this.anchor),i=e.resolve(s);return r?te.near(i):new hi(i)}content(){return new q(j.from(this.node),0,0)}eq(e){return e instanceof hi&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new eC(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new hi(e.resolve(n.anchor))}static create(e,n){return new hi(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}};Y.prototype.visible=!1;te.jsonID("node",Y);let eC=class J1{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new K1(r,r):new J1(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&Y.isSelectable(r)?new Y(n):te.near(n)}},dn=class al extends te{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=q.empty){if(n==q.empty){e.delete(0,e.doc.content.size);let r=te.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new al(e)}map(e){return new al(e)}eq(e){return e instanceof al}getBookmark(){return tC}};te.jsonID("all",dn);const tC={map(){return this},resolve(t){return new dn(t)}};function as(t,e,n,r,s,i=!1){if(e.inlineContent)return ee.create(t,n);for(let o=r-(s>0?0:1);s>0?o<e.childCount:o>=0;o+=s){let l=e.child(o);if(l.isAtom){if(!i&&Y.isSelectable(l))return Y.create(t,n-(s<0?l.nodeSize:0))}else{let a=as(t,l,n+s,s<0?l.childCount:0,s,i);if(a)return a}n+=l.nodeSize*s}return null}function np(t,e,n){let r=t.steps.length-1;if(r<e)return;let s=t.steps[r];if(!(s instanceof Vt||s instanceof kt))return;let i=t.mapping.maps[r],o;i.forEach((l,a,c,u)=>{o==null&&(o=u)}),t.setSelection(te.near(t.doc.resolve(o),n))}const rp=1,Do=2,sp=4;let nC=class extends Qd{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|rp)&~Do,this.storedMarks=null,this}get selectionSet(){return(this.updated&rp)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Do,this}ensureMarks(e){return xe.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&Do)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~Do,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||xe.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let s=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(s.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let i=this.storedMarks;if(!i){let o=this.doc.resolve(n);i=r==n?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,s.text(e,i)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(te.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=sp,this}get scrolledIntoView(){return(this.updated&sp)>0}};function ip(t,e){return!e||!t?t:t.bind(e)}let fi=class{constructor(e,n,r){this.name=e,this.init=ip(n.init,r),this.apply=ip(n.apply,r)}};const rC=[new fi("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new fi("selection",{init(t,e){return t.selection||te.atStart(e.doc)},apply(t){return t.selection}}),new fi("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new fi("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class Oc{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=rC.slice(),n&&n.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new fi(r.key,r.spec.state,r))})}}class ps{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,n=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=n){let s=this.config.plugins[r];if(s.spec.filterTransaction&&!s.spec.filterTransaction.call(s,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],r=this.applyInner(e),s=null;for(;;){let i=!1;for(let o=0;o<this.config.plugins.length;o++){let l=this.config.plugins[o];if(l.spec.appendTransaction){let a=s?s[o].n:0,c=s?s[o].state:this,u=a<n.length&&l.spec.appendTransaction.call(l,a?n.slice(a):n,c,r);if(u&&r.filterTransaction(u,o)){if(u.setMeta("appendedTransaction",e),!s){s=[];for(let d=0;d<this.config.plugins.length;d++)s.push(d<o?{state:r,n:n.length}:{state:this,n:0})}n.push(u),r=r.applyInner(u),i=!0}s&&(s[o]={state:r,n:n.length})}}if(!i)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new ps(this.config),r=this.config.fields;for(let s=0;s<r.length;s++){let i=r[s];n[i.name]=i.apply(e,this[i.name],this,n)}return n}get tr(){return new nC(this)}static create(e){let n=new Oc(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new ps(n);for(let s=0;s<n.fields.length;s++)r[n.fields[s].name]=n.fields[s].init(e,r);return r}reconfigure(e){let n=new Oc(this.schema,e.plugins),r=n.fields,s=new ps(n);for(let i=0;i<r.length;i++){let o=r[i].name;s[o]=this.hasOwnProperty(o)?this[o]:r[i].init(e,s)}return s}toJSON(e){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let s=e[r],i=s.spec.state;i&&i.toJSON&&(n[r]=i.toJSON.call(s,this[s.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let s=new Oc(e.schema,e.plugins),i=new ps(s);return s.fields.forEach(o=>{if(o.name=="doc")i.doc=ir.fromJSON(e.schema,n.doc);else if(o.name=="selection")i.selection=te.fromJSON(i.doc,n.selection);else if(o.name=="storedMarks")n.storedMarks&&(i.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==o.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(n,l)){i[o.name]=c.fromJSON.call(a,e,n[l],i);return}}i[o.name]=o.init(e,i)}}),i}}function G1(t,e,n){for(let r in t){let s=t[r];s instanceof Function?s=s.bind(e):r=="handleDOMEvents"&&(s=G1(s,e,{})),n[r]=s}return n}class ce{constructor(e){this.spec=e,this.props={},e.props&&G1(e.props,this,this.props),this.key=e.key?e.key.key:Y1("plugin")}getState(e){return e[this.key]}}const Ic=Object.create(null);function Y1(t){return t in Ic?t+"$"+ ++Ic[t]:(Ic[t]=0,t+"$")}class ae{constructor(e="key"){this.key=Y1(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const X1=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function Z1(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const Q1=(t,e,n)=>{let r=Z1(t,n);if(!r)return!1;let s=th(r);if(!s){let o=r.blockRange(),l=o&&$s(o);return l==null?!1:(e&&e(t.tr.lift(o,l).scrollIntoView()),!0)}let i=s.nodeBefore;if(a0(t,s,e,-1))return!0;if(r.parent.content.size==0&&(Ss(i,"end")||Y.isSelectable(i)))for(let o=r.depth;;o--){let l=Fa(t.doc,r.before(o),r.after(o),q.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=t.tr.step(l);a.setSelection(Ss(i,"end")?te.findFrom(a.doc.resolve(a.mapping.map(s.pos,-1)),-1):Y.create(a.doc,s.pos-i.nodeSize)),e(a.scrollIntoView())}return!0}if(o==1||r.node(o-1).childCount>1)break}return i.isAtom&&s.depth==r.depth-1?(e&&e(t.tr.delete(s.pos-i.nodeSize,s.pos).scrollIntoView()),!0):!1},sC=(t,e,n)=>{let r=Z1(t,n);if(!r)return!1;let s=th(r);return s?e0(t,s,e):!1},iC=(t,e,n)=>{let r=n0(t,n);if(!r)return!1;let s=nh(r);return s?e0(t,s,e):!1};function e0(t,e,n){let r=e.nodeBefore,s=r,i=e.pos-1;for(;!s.isTextblock;i--){if(s.type.spec.isolating)return!1;let u=s.lastChild;if(!u)return!1;s=u}let o=e.nodeAfter,l=o,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let u=l.firstChild;if(!u)return!1;l=u}let c=Fa(t.doc,i,a,q.empty);if(!c||c.from!=i||c instanceof Vt&&c.slice.size>=a-i)return!1;if(n){let u=t.tr.step(c);u.setSelection(ee.create(u.doc,i)),n(u.scrollIntoView())}return!0}function Ss(t,e,n=!1){for(let r=t;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}const t0=(t,e,n)=>{let{$head:r,empty:s}=t.selection,i=r;if(!s)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;i=th(r)}let o=i&&i.nodeBefore;return!o||!Y.isSelectable(o)?!1:(e&&e(t.tr.setSelection(Y.create(t.doc,i.pos-o.nodeSize)).scrollIntoView()),!0)};function th(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function n0(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const r0=(t,e,n)=>{let r=n0(t,n);if(!r)return!1;let s=nh(r);if(!s)return!1;let i=s.nodeAfter;if(a0(t,s,e,1))return!0;if(r.parent.content.size==0&&(Ss(i,"start")||Y.isSelectable(i))){let o=Fa(t.doc,r.before(),r.after(),q.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=t.tr.step(o);l.setSelection(Ss(i,"start")?te.findFrom(l.doc.resolve(l.mapping.map(s.pos)),1):Y.create(l.doc,l.mapping.map(s.pos))),e(l.scrollIntoView())}return!0}}return i.isAtom&&s.depth==r.depth-1?(e&&e(t.tr.delete(s.pos,s.pos+i.nodeSize).scrollIntoView()),!0):!1},s0=(t,e,n)=>{let{$head:r,empty:s}=t.selection,i=r;if(!s)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;i=nh(r)}let o=i&&i.nodeAfter;return!o||!Y.isSelectable(o)?!1:(e&&e(t.tr.setSelection(Y.create(t.doc,i.pos)).scrollIntoView()),!0)};function nh(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let n=t.node(e);if(t.index(e)+1<n.childCount)return t.doc.resolve(t.after(e+1));if(n.type.spec.isolating)break}return null}const oC=(t,e)=>{let n=t.selection,r=n instanceof Y,s;if(r){if(n.node.isTextblock||!gr(t.doc,n.from))return!1;s=n.from}else if(s=Va(t.doc,n.from,-1),s==null)return!1;if(e){let i=t.tr.join(s);r&&i.setSelection(Y.create(i.doc,s-t.doc.resolve(s).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},lC=(t,e)=>{let n=t.selection,r;if(n instanceof Y){if(n.node.isTextblock||!gr(t.doc,n.to))return!1;r=n.to}else if(r=Va(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},aC=(t,e)=>{let{$from:n,$to:r}=t.selection,s=n.blockRange(r),i=s&&$s(s);return i==null?!1:(e&&e(t.tr.lift(s,i).scrollIntoView()),!0)},i0=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
|
|
22
|
+
`).scrollIntoView()),!0)};function rh(t){for(let e=0;e<t.edgeCount;e++){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}const cC=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let s=n.node(-1),i=n.indexAfter(-1),o=rh(s.contentMatchAt(i));if(!o||!s.canReplaceWith(i,i,o))return!1;if(e){let l=n.after(),a=t.tr.replaceWith(l,l,o.createAndFill());a.setSelection(te.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},o0=(t,e)=>{let n=t.selection,{$from:r,$to:s}=n;if(n instanceof dn||r.parent.inlineContent||s.parent.inlineContent)return!1;let i=rh(s.parent.contentMatchAt(s.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let o=(!r.parentOffset&&s.index()<s.parent.childCount?r:s).pos,l=t.tr.insert(o,i.createAndFill());l.setSelection(ee.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},l0=(t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let i=n.before();if(Dn(t.doc,i))return e&&e(t.tr.split(i).scrollIntoView()),!0}let r=n.blockRange(),s=r&&$s(r);return s==null?!1:(e&&e(t.tr.lift(r,s).scrollIntoView()),!0)};function uC(t){return(e,n)=>{let{$from:r,$to:s}=e.selection;if(e.selection instanceof Y&&e.selection.node.isBlock)return!r.parentOffset||!Dn(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let i=[],o,l,a=!1,c=!1;for(let f=r.depth;;f--)if(r.node(f).isBlock){a=r.end(f)==r.pos+(r.depth-f),c=r.start(f)==r.pos-(r.depth-f),l=rh(r.node(f-1).contentMatchAt(r.indexAfter(f-1))),i.unshift(a&&l?{type:l}:null),o=f;break}else{if(f==1)return!1;i.unshift(null)}let u=e.tr;(e.selection instanceof ee||e.selection instanceof dn)&&u.deleteSelection();let d=u.mapping.map(r.pos),h=Dn(u.doc,d,i.length,i);if(h||(i[0]=l?{type:l}:null,h=Dn(u.doc,d,i.length,i)),!h)return!1;if(u.split(d,i.length,i),!a&&c&&r.node(o).type!=l){let f=u.mapping.map(r.before(o)),p=u.doc.resolve(f);l&&r.node(o-1).canReplaceWith(p.index(),p.index()+1,l)&&u.setNodeMarkup(u.mapping.map(r.before(o)),l)}return n&&n(u.scrollIntoView()),!0}}const dC=uC(),hC=(t,e)=>{let{$from:n,to:r}=t.selection,s,i=n.sharedDepth(r);return i==0?!1:(s=n.before(i),e&&e(t.tr.setSelection(Y.create(t.doc,s))),!0)};function fC(t,e,n){let r=e.nodeBefore,s=e.nodeAfter,i=e.index();return!r||!s||!r.type.compatibleContent(s.type)?!1:!r.content.size&&e.parent.canReplace(i-1,i)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(s.isTextblock||gr(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function a0(t,e,n,r){let s=e.nodeBefore,i=e.nodeAfter,o,l,a=s.type.spec.isolating||i.type.spec.isolating;if(!a&&fC(t,e,n))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(o=(l=s.contentMatchAt(s.childCount)).findWrapping(i.type))&&l.matchType(o[0]||i.type).validEnd){if(n){let f=e.pos+i.nodeSize,p=j.empty;for(let b=o.length-1;b>=0;b--)p=j.from(o[b].create(null,p));p=j.from(s.copy(p));let g=t.tr.step(new kt(e.pos-1,f,e.pos,f,new q(p,1,0),o.length,!0)),y=g.doc.resolve(f+2*o.length);y.nodeAfter&&y.nodeAfter.type==s.type&&gr(g.doc,y.pos)&&g.join(y.pos),n(g.scrollIntoView())}return!0}let u=i.type.spec.isolating||r>0&&a?null:te.findFrom(e,1),d=u&&u.$from.blockRange(u.$to),h=d&&$s(d);if(h!=null&&h>=e.depth)return n&&n(t.tr.lift(d,h).scrollIntoView()),!0;if(c&&Ss(i,"start",!0)&&Ss(s,"end")){let f=s,p=[];for(;p.push(f),!f.isTextblock;)f=f.lastChild;let g=i,y=1;for(;!g.isTextblock;g=g.firstChild)y++;if(f.canReplace(f.childCount,f.childCount,g.content)){if(n){let b=j.empty;for(let v=p.length-1;v>=0;v--)b=j.from(p[v].copy(b));let w=t.tr.step(new kt(e.pos-p.length,e.pos+i.nodeSize,e.pos+y,e.pos+i.nodeSize-y,new q(b,p.length,0),0,!0));n(w.scrollIntoView())}return!0}}return!1}function c0(t){return function(e,n){let r=e.selection,s=t<0?r.$from:r.$to,i=s.depth;for(;s.node(i).isInline;){if(!i)return!1;i--}return s.node(i).isTextblock?(n&&n(e.tr.setSelection(ee.create(e.doc,t<0?s.start(i):s.end(i)))),!0):!1}}const pC=c0(-1),mC=c0(1);function gC(t,e=null){return function(n,r){let{$from:s,$to:i}=n.selection,o=s.blockRange(i),l=o&&Zd(o,t,e);return l?(r&&r(n.tr.wrap(o,l).scrollIntoView()),!0):!1}}function op(t,e=null){return function(n,r){let s=!1;for(let i=0;i<n.selection.ranges.length&&!s;i++){let{$from:{pos:o},$to:{pos:l}}=n.selection.ranges[i];n.doc.nodesBetween(o,l,(a,c)=>{if(s)return!1;if(!(!a.isTextblock||a.hasMarkup(t,e)))if(a.type==t)s=!0;else{let u=n.doc.resolve(c),d=u.index();s=u.parent.canReplaceWith(d,d+1,t)}})}if(!s)return!1;if(r){let i=n.tr;for(let o=0;o<n.selection.ranges.length;o++){let{$from:{pos:l},$to:{pos:a}}=n.selection.ranges[o];i.setBlockType(l,a,t,e)}r(i.scrollIntoView())}return!0}}function sh(...t){return function(e,n,r){for(let s=0;s<t.length;s++)if(t[s](e,n,r))return!0;return!1}}sh(X1,Q1,t0);sh(X1,r0,s0);sh(i0,o0,l0,dC);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function yC(t,e=null){return function(n,r){let{$from:s,$to:i}=n.selection,o=s.blockRange(i);if(!o)return!1;let l=r?n.tr:null;return bC(l,o,t,e)?(r&&r(l.scrollIntoView()),!0):!1}}function bC(t,e,n,r=null){let s=!1,i=e,o=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=o.resolve(e.start-2);i=new Vi(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new Vi(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),s=!0}let l=Zd(i,n,r,e);return l?(t&&wC(t,e,l,s,n),!0):!1}function wC(t,e,n,r,s){let i=j.empty;for(let u=n.length-1;u>=0;u--)i=j.from(n[u].type.create(n[u].attrs,i));t.step(new kt(e.start-(r?2:0),e.end,e.start,e.end,new q(i,0,0),n.length,!0));let o=0;for(let u=0;u<n.length;u++)n[u].type==s&&(o=u+1);let l=n.length-o,a=e.start+n.length-(r?2:0),c=e.parent;for(let u=e.startIndex,d=e.endIndex,h=!0;u<d;u++,h=!1)!h&&Dn(t.doc,a,l)&&(t.split(a,l),a+=2*l),a+=c.child(u).nodeSize;return t}function xC(t){return function(e,n){let{$from:r,$to:s}=e.selection,i=r.blockRange(s,o=>o.childCount>0&&o.firstChild.type==t);return i?n?r.node(i.depth-1).type==t?vC(e,n,t,i):kC(e,n,i):!0:!1}}function vC(t,e,n,r){let s=t.tr,i=r.end,o=r.$to.end(r.depth);i<o&&(s.step(new kt(i-1,o,i,o,new q(j.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new Vi(s.doc.resolve(r.$from.pos),s.doc.resolve(o),r.depth));const l=$s(r);if(l==null)return!1;s.lift(r,l);let a=s.doc.resolve(s.mapping.map(i,-1)-1);return gr(s.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&s.join(a.pos),e(s.scrollIntoView()),!0}function kC(t,e,n){let r=t.tr,s=n.parent;for(let f=n.end,p=n.endIndex-1,g=n.startIndex;p>g;p--)f-=s.child(p).nodeSize,r.delete(f-1,f+1);let i=r.doc.resolve(n.start),o=i.nodeAfter;if(r.mapping.map(n.end)!=n.start+i.nodeAfter.nodeSize)return!1;let l=n.startIndex==0,a=n.endIndex==s.childCount,c=i.node(-1),u=i.index(-1);if(!c.canReplace(u+(l?0:1),u+1,o.content.append(a?j.empty:j.from(s))))return!1;let d=i.pos,h=d+o.nodeSize;return r.step(new kt(d-(l?1:0),h+(a?1:0),d+1,h-1,new q((l?j.empty:j.from(s.copy(j.empty))).append(a?j.empty:j.from(s.copy(j.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function SC(t){return function(e,n){let{$from:r,$to:s}=e.selection,i=r.blockRange(s,c=>c.childCount>0&&c.firstChild.type==t);if(!i)return!1;let o=i.startIndex;if(o==0)return!1;let l=i.parent,a=l.child(o-1);if(a.type!=t)return!1;if(n){let c=a.lastChild&&a.lastChild.type==l.type,u=j.from(c?t.create():null),d=new q(j.from(t.create(null,j.from(l.type.create(null,u)))),c?3:1,0),h=i.start,f=i.end;n(e.tr.step(new kt(h-(c?3:1),f,h,f,d,1,!0)).scrollIntoView())}return!0}}const Ze=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},Cs=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let Pu=null;const _n=function(t,e,n){let r=Pu||(Pu=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},CC=function(){Pu=null},zr=function(t,e,n,r){return n&&(lp(t,e,n,r,-1)||lp(t,e,n,r,1))},MC=/^(img|br|input|textarea|hr)$/i;function lp(t,e,n,r,s){for(var i;;){if(t==n&&e==r)return!0;if(e==(s<0?0:jt(t))){let o=t.parentNode;if(!o||o.nodeType!=1||go(t)||MC.test(t.nodeName)||t.contentEditable=="false")return!1;e=Ze(t)+(s<0?0:1),t=o}else if(t.nodeType==1){let o=t.childNodes[e+(s<0?-1:0)];if(o.nodeType==1&&o.contentEditable=="false")if(!((i=o.pmViewDesc)===null||i===void 0)&&i.ignoreForSelection)e+=s;else return!1;else t=o,e=s<0?jt(t):0}else return!1}}function jt(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function AC(t,e){for(;;){if(t.nodeType==3&&e)return t;if(t.nodeType==1&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1],e=jt(t)}else if(t.parentNode&&!go(t))e=Ze(t),t=t.parentNode;else return null}}function EC(t,e){for(;;){if(t.nodeType==3&&e<t.nodeValue.length)return t;if(t.nodeType==1&&e<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[e],e=0}else if(t.parentNode&&!go(t))e=Ze(t)+1,t=t.parentNode;else return null}}function TC(t,e,n){for(let r=e==0,s=e==jt(t);r||s;){if(t==n)return!0;let i=Ze(t);if(t=t.parentNode,!t)return!1;r=r&&i==0,s=s&&i==jt(t)}}function go(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const Ua=function(t){return t.focusNode&&zr(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Mr(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function _C(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function NC(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(jt(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(jt(r.startContainer),r.startOffset)}}}const pn=typeof navigator<"u"?navigator:null,ap=typeof document<"u"?document:null,yr=pn&&pn.userAgent||"",Bu=/Edge\/(\d+)/.exec(yr),u0=/MSIE \d/.exec(yr),Hu=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(yr),vt=!!(u0||Hu||Bu),or=u0?document.documentMode:Hu?+Hu[1]:Bu?+Bu[1]:0,Bt=!vt&&/gecko\/(\d+)/i.test(yr);Bt&&+(/Firefox\/(\d+)/.exec(yr)||[0,0])[1];const zu=!vt&&/Chrome\/(\d+)/.exec(yr),Ue=!!zu,d0=zu?+zu[1]:0,it=!vt&&!!pn&&/Apple Computer/.test(pn.vendor),Ms=it&&(/Mobile\/\w+/.test(yr)||!!pn&&pn.maxTouchPoints>2),Lt=Ms||(pn?/Mac/.test(pn.platform):!1),h0=pn?/Win/.test(pn.platform):!1,Nn=/Android \d/.test(yr),yo=!!ap&&"webkitFontSmoothing"in ap.documentElement.style,OC=yo?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function IC(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function kn(t,e){return typeof t=="number"?t:t[e]}function DC(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function cp(t,e,n){let r=t.someProp("scrollThreshold")||0,s=t.someProp("scrollMargin")||5,i=t.dom.ownerDocument;for(let o=n||t.dom;o;){if(o.nodeType!=1){o=Cs(o);continue}let l=o,a=l==i.body,c=a?IC(i):DC(l),u=0,d=0;if(e.top<c.top+kn(r,"top")?d=-(c.top-e.top+kn(s,"top")):e.bottom>c.bottom-kn(r,"bottom")&&(d=e.bottom-e.top>c.bottom-c.top?e.top+kn(s,"top")-c.top:e.bottom-c.bottom+kn(s,"bottom")),e.left<c.left+kn(r,"left")?u=-(c.left-e.left+kn(s,"left")):e.right>c.right-kn(r,"right")&&(u=e.right-c.right+kn(s,"right")),u||d)if(a)i.defaultView.scrollBy(u,d);else{let f=l.scrollLeft,p=l.scrollTop;d&&(l.scrollTop+=d),u&&(l.scrollLeft+=u);let g=l.scrollLeft-f,y=l.scrollTop-p;e={left:e.left-g,top:e.top-y,right:e.right-g,bottom:e.bottom-y}}let h=a?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(h))break;o=h=="absolute"?o.offsetParent:Cs(o)}}function RC(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,s;for(let i=(e.left+e.right)/2,o=n+1;o<Math.min(innerHeight,e.bottom);o+=5){let l=t.root.elementFromPoint(i,o);if(!l||l==t.dom||!t.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=n-20){r=l,s=a.top;break}}return{refDOM:r,refTop:s,stack:f0(t.dom)}}function f0(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=Cs(r));return e}function LC({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;p0(n,r==0?0:r-e)}function p0(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:s,left:i}=t[n];r.scrollTop!=s+e&&(r.scrollTop=s+e),r.scrollLeft!=i&&(r.scrollLeft=i)}}let ts=null;function jC(t){if(t.setActive)return t.setActive();if(ts)return t.focus(ts);let e=f0(t);t.focus(ts==null?{get preventScroll(){return ts={preventScroll:!0},!0}}:void 0),ts||(ts=!1,p0(e,0))}function m0(t,e){let n,r=2e8,s,i=0,o=e.top,l=e.top,a,c;for(let u=t.firstChild,d=0;u;u=u.nextSibling,d++){let h;if(u.nodeType==1)h=u.getClientRects();else if(u.nodeType==3)h=_n(u).getClientRects();else continue;for(let f=0;f<h.length;f++){let p=h[f];if(p.top<=o&&p.bottom>=l){o=Math.max(p.bottom,o),l=Math.min(p.top,l);let g=p.left>e.left?p.left-e.left:p.right<e.left?e.left-p.right:0;if(g<r){n=u,r=g,s=g&&n.nodeType==3?{left:p.right<e.left?p.right:p.left,top:e.top}:e,u.nodeType==1&&g&&(i=d+(e.left>=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!a&&p.left<=e.left&&p.right>=e.left&&(a=u,c={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!n&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(i=d+1)}}return!n&&a&&(n=a,s=c,r=0),n&&n.nodeType==3?PC(n,s):!n||r&&n.nodeType==1?{node:t,offset:i}:m0(n,s)}function PC(t,e){let n=t.nodeValue.length,r=document.createRange(),s;for(let i=0;i<n;i++){r.setEnd(t,i+1),r.setStart(t,i);let o=Yn(r,1);if(o.top!=o.bottom&&ih(e,o)){s={node:t,offset:i+(e.left>=(o.left+o.right)/2?1:0)};break}}return r.detach(),s||{node:t,offset:0}}function ih(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function BC(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function HC(t,e,n){let{node:r,offset:s}=m0(e,n),i=-1;if(r.nodeType==1&&!r.firstChild){let o=r.getBoundingClientRect();i=o.left!=o.right&&n.left>(o.left+o.right)/2?1:-1}return t.docView.posFromDOM(r,s,i)}function zC(t,e,n,r){let s=-1;for(let i=e,o=!1;i!=t.dom;){let l=t.docView.nearestDesc(i,!0),a;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!o&&a.left>r.left||a.top>r.top?s=l.posBefore:(!o&&a.right<r.left||a.bottom<r.top)&&(s=l.posAfter),o=!0),!l.contentDOM&&s<0&&!l.node.isText))return(l.node.isBlock?r.top<(a.top+a.bottom)/2:r.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;i=l.dom.parentNode}return s>-1?s:t.docView.posFromDOM(e,n,-1)}function g0(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let s=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),i=s;;){let o=t.childNodes[i];if(o.nodeType==1){let l=o.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(ih(e,c))return g0(o,e,c)}}if((i=(i+1)%r)==s)break}return t}function $C(t,e){let n=t.dom.ownerDocument,r,s=0,i=NC(n,e.left,e.top);i&&({node:r,offset:s}=i);let o=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),l;if(!o||!t.dom.contains(o.nodeType!=1?o.parentNode:o)){let c=t.dom.getBoundingClientRect();if(!ih(e,c)||(o=g0(t.dom,e,c),!o))return null}if(it)for(let c=o;r&&c;c=Cs(c))c.draggable&&(r=void 0);if(o=BC(o,e),r){if(Bt&&r.nodeType==1&&(s=Math.min(s,r.childNodes.length),s<r.childNodes.length)){let u=r.childNodes[s],d;u.nodeName=="IMG"&&(d=u.getBoundingClientRect()).right<=e.left&&d.bottom>e.top&&s++}let c;yo&&s&&r.nodeType==1&&(c=r.childNodes[s-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&s--,r==t.dom&&s==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=t.state.doc.content.size:(s==0||r.nodeType!=1||r.childNodes[s-1].nodeName!="BR")&&(l=zC(t,r,s,e))}l==null&&(l=HC(t,o,e));let a=t.docView.nearestDesc(o,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function up(t){return t.top<t.bottom||t.left<t.right}function Yn(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(up(r))return r}return Array.prototype.find.call(n,up)||t.getBoundingClientRect()}const VC=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function y0(t,e,n){let{node:r,offset:s,atom:i}=t.docView.domFromPos(e,n<0?-1:1),o=yo||Bt;if(r.nodeType==3)if(o&&(VC.test(r.nodeValue)||(n<0?!s:s==r.nodeValue.length))){let a=Yn(_n(r,s,s),n);if(Bt&&s&&/\s/.test(r.nodeValue[s-1])&&s<r.nodeValue.length){let c=Yn(_n(r,s-1,s-1),-1);if(c.top==a.top){let u=Yn(_n(r,s,s+1),-1);if(u.top!=a.top)return Qs(u,u.left<c.left)}}return a}else{let a=s,c=s,u=n<0?1:-1;return n<0&&!s?(c++,u=-1):n>=0&&s==r.nodeValue.length?(a--,u=1):n<0?a--:c++,Qs(Yn(_n(r,a,c),u),u<0)}if(!t.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&s&&(n<0||s==jt(r))){let a=r.childNodes[s-1];if(a.nodeType==1)return Dc(a.getBoundingClientRect(),!1)}if(i==null&&s<jt(r)){let a=r.childNodes[s];if(a.nodeType==1)return Dc(a.getBoundingClientRect(),!0)}return Dc(r.getBoundingClientRect(),n>=0)}if(i==null&&s&&(n<0||s==jt(r))){let a=r.childNodes[s-1],c=a.nodeType==3?_n(a,jt(a)-(o?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return Qs(Yn(c,1),!1)}if(i==null&&s<jt(r)){let a=r.childNodes[s];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?_n(a,0,o?0:1):a.nodeType==1?a:null:null;if(c)return Qs(Yn(c,-1),!0)}return Qs(Yn(r.nodeType==3?_n(r):r,-n),n>=0)}function Qs(t,e){if(t.width==0)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function Dc(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function b0(t,e,n){let r=t.state,s=t.root.activeElement;r!=e&&t.updateState(e),s!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),s!=t.dom&&s&&s.focus()}}function FC(t,e,n){let r=e.selection,s=n=="up"?r.$from:r.$to;return b0(t,e,()=>{let{node:i}=t.docView.domFromPos(s.pos,n=="up"?-1:1);for(;;){let l=t.docView.nearestDesc(i,!0);if(!l)break;if(l.node.isBlock){i=l.contentDOM||l.dom;break}i=l.dom.parentNode}let o=y0(t,s.pos,1);for(let l=i.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=_n(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let u=a[c];if(u.bottom>u.top+1&&(n=="up"?o.top-u.top>(u.bottom-o.top)*2:u.bottom-o.bottom>(o.bottom-u.top)*2))return!1}}return!0})}const UC=/[\u0590-\u08ac]/;function WC(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let s=r.parentOffset,i=!s,o=s==r.parent.content.size,l=t.domSelection();return l?!UC.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?i:o:b0(t,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:u,anchorOffset:d}=t.domSelectionRange(),h=l.caretBidiLevel;l.modify("move",n,"character");let f=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:p,focusOffset:g}=t.domSelectionRange(),y=p&&!f.contains(p.nodeType==1?p:p.parentNode)||a==p&&c==g;try{l.collapse(u,d),a&&(a!=u||c!=d)&&l.extend&&l.extend(a,c)}catch{}return h!=null&&(l.caretBidiLevel=h),y}):r.pos==r.start()||r.pos==r.end()}let dp=null,hp=null,fp=!1;function KC(t,e,n){return dp==e&&hp==n?fp:(dp=e,hp=n,fp=n=="up"||n=="down"?FC(t,e,n):WC(t,e,n))}const Ht=0,pp=1,Tr=2,mn=3;class bo{constructor(e,n,r,s){this.parent=e,this.children=n,this.dom=r,this.contentDOM=s,this.dirty=Ht,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;n<this.children.length;n++)e+=this.children[n].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 n=0,r=this.posAtStart;;n++){let s=this.children[n];if(s==e)return r;r+=s.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,n,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let i,o;if(e==this.contentDOM)i=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.previousSibling}for(;i&&!((o=i.pmViewDesc)&&o.parent==this);)i=i.previousSibling;return i?this.posBeforeChild(o)+o.size:this.posAtStart}else{let i,o;if(e==this.contentDOM)i=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&!((o=i.pmViewDesc)&&o.parent==this);)i=i.nextSibling;return i?this.posBeforeChild(o):this.posAtEnd}let s;if(e==this.dom&&this.contentDOM)s=n>Ze(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))s=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let i=e;;i=i.parentNode){if(i==this.dom){s=!1;break}if(i.previousSibling)break}if(s==null&&n==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){s=!0;break}if(i.nextSibling)break}}return s??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,s=e;s;s=s.parentNode){let i=this.getDesc(s),o;if(i&&(!n||i.node))if(r&&(o=i.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))r=!1;else return i}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let s=e;s;s=s.parentNode){let i=this.getDesc(s);if(i)return i.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let s=this.children[n],i=r+s.size;if(r==e&&i!=r){for(;!s.border&&s.children.length;)for(let o=0;o<s.children.length;o++){let l=s.children[o];if(l.size){s=l;break}}return s}if(e<i)return s.descAt(e-r-s.border);r=i}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,s=0;for(let i=0;r<this.children.length;r++){let o=this.children[r],l=i+o.size;if(l>e||o instanceof x0){s=e-i;break}i=l}if(s)return this.children[r].domFromPos(s-this.children[r].border,n);for(let i;r&&!(i=this.children[r-1]).size&&i instanceof w0&&i.side>=0;r--);if(n<=0){let i,o=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,o=!1);return i&&n&&o&&!i.border&&!i.domAtom?i.domFromPos(i.size,n):{node:this.contentDOM,offset:i?Ze(i.dom)+1:0}}else{let i,o=!0;for(;i=r<this.children.length?this.children[r]:null,!(!i||i.dom.parentNode==this.contentDOM);r++,o=!1);return i&&o&&!i.border&&!i.domAtom?i.domFromPos(0,n):{node:this.contentDOM,offset:i?Ze(i.dom):this.contentDOM.childNodes.length}}}parseRange(e,n,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let s=-1,i=-1;for(let o=r,l=0;;l++){let a=this.children[l],c=o+a.size;if(s==-1&&e<=c){let u=o+a.border;if(e>=u&&n<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,n,u);e=o;for(let d=l;d>0;d--){let h=this.children[d-1];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(1)){s=Ze(h.dom)+1;break}e-=h.size}s==-1&&(s=0)}if(s>-1&&(c>n||l==this.children.length-1)){n=c;for(let u=l+1;u<this.children.length;u++){let d=this.children[u];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(-1)){i=Ze(d.dom);break}n+=d.size}i==-1&&(i=this.contentDOM.childNodes.length);break}o=c}return{node:this.contentDOM,from:e,to:n,fromOffset:s,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[e<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(e)}domAfterPos(e){let{node:n,offset:r}=this.domFromPos(e,0);if(n.nodeType!=1||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]}setSelection(e,n,r,s=!1){let i=Math.min(e,n),o=Math.max(e,n);for(let f=0,p=0;f<this.children.length;f++){let g=this.children[f],y=p+g.size;if(i>p&&o<y)return g.setSelection(e-p-g.border,n-p-g.border,r,s);p=y}let l=this.domFromPos(e,e?-1:1),a=n==e?l:this.domFromPos(n,n?-1:1),c=r.root.getSelection(),u=r.domSelectionRange(),d=!1;if((Bt||it)&&e==n){let{node:f,offset:p}=l;if(f.nodeType==3){if(d=!!(p&&f.nodeValue[p-1]==`
|
|
23
|
+
`),d&&p==f.nodeValue.length)for(let g=f,y;g;g=g.parentNode){if(y=g.nextSibling){y.nodeName=="BR"&&(l=a={node:y.parentNode,offset:Ze(y)+1});break}let b=g.pmViewDesc;if(b&&b.node&&b.node.isBlock)break}}else{let g=f.childNodes[p-1];d=g&&(g.nodeName=="BR"||g.contentEditable=="false")}}if(Bt&&u.focusNode&&u.focusNode!=a.node&&u.focusNode.nodeType==1){let f=u.focusNode.childNodes[u.focusOffset];f&&f.contentEditable=="false"&&(s=!0)}if(!(s||d&&it)&&zr(l.node,l.offset,u.anchorNode,u.anchorOffset)&&zr(a.node,a.offset,u.focusNode,u.focusOffset))return;let h=!1;if((c.extend||e==n)&&!(d&&Bt)){c.collapse(l.node,l.offset);try{e!=n&&c.extend(a.node,a.offset),h=!0}catch{}}if(!h){if(e>n){let p=l;l=a,a=p}let f=document.createRange();f.setEnd(a.node,a.offset),f.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(f)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,s=0;s<this.children.length;s++){let i=this.children[s],o=r+i.size;if(r==o?e<=o&&n>=r:e<o&&n>r){let l=r+i.border,a=o-i.border;if(e>=l&&n<=a){this.dirty=e==r||n==o?Tr:pp,e==l&&n==a&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=mn:i.markDirty(e-l,n-l);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?Tr:mn}r=o}this.dirty=Tr}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?Tr:pp;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class w0 extends bo{constructor(e,n,r,s){let i,o=n.type.toDOM;if(typeof o=="function"&&(o=o(r,()=>{if(!i)return s;if(i.parent)return i.parent.posBeforeChild(i)})),!n.type.spec.raw){if(o.nodeType!=1){let l=document.createElement("span");l.appendChild(o),o=l}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=n,this.widget=n,i=this}matchesWidget(e){return this.dirty==Ht&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class qC extends bo{constructor(e,n,r,s){super(e,[],n,null),this.textDOM=r,this.text=s}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class $r extends bo{constructor(e,n,r,s,i){super(e,[],r,s),this.mark=n,this.spec=i}static create(e,n,r,s){let i=s.nodeViews[n.type.name],o=i&&i(n,s,r);return(!o||!o.dom)&&(o=Xr.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new $r(e,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&mn||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=mn&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=Ht){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Ht}}slice(e,n,r){let s=$r.create(this.parent,this.mark,!0,r),i=this.children,o=this.size;n<o&&(i=Vu(i,n,o,r)),e>0&&(i=Vu(i,0,e,r));for(let l=0;l<i.length;l++)i[l].parent=s;return s.children=i,s}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class lr extends bo{constructor(e,n,r,s,i,o,l,a,c){super(e,[],i,o),this.node=n,this.outerDeco=r,this.innerDeco=s,this.nodeDOM=l}static create(e,n,r,s,i,o){let l=i.nodeViews[n.type.name],a,c=l&&l(n,i,()=>{if(!a)return o;if(a.parent)return a.parent.posBeforeChild(a)},r,s),u=c&&c.dom,d=c&&c.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:d}=Xr.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!d&&!n.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),n.type.spec.draggable&&(u.draggable=!0));let h=u;return u=S0(u,r,n),c?a=new JC(e,n,r,s,u,d||null,h,c,i,o+1):n.isText?new Wa(e,n,r,s,u,h,i):new lr(e,n,r,s,u,d||null,h,i,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>j.empty)}return e}matchesNode(e,n,r){return this.dirty==Ht&&e.eq(this.node)&&Ol(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,s=n,i=e.composing?this.localCompositionInfo(e,n):null,o=i&&i.pos>-1?i:null,l=i&&i.pos<0,a=new YC(this,o&&o.node,e);QC(this.node,this.innerDeco,(c,u,d)=>{c.spec.marks?a.syncToMarks(c.spec.marks,r,e,u):c.type.side>=0&&!d&&a.syncToMarks(u==this.node.childCount?xe.none:this.node.child(u).marks,r,e,u),a.placeWidget(c,e,s)},(c,u,d,h)=>{a.syncToMarks(c.marks,r,e,h);let f;a.findNodeMatch(c,u,d,h)||l&&e.state.selection.from>s&&e.state.selection.to<s+c.nodeSize&&(f=a.findIndexWithChild(i.node))>-1&&a.updateNodeAt(c,u,d,f,e)||a.updateNextNode(c,u,d,e,h,s)||a.addNode(c,u,d,e,s),s+=c.nodeSize}),a.syncToMarks([],r,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==Tr)&&(o&&this.protectLocalComposition(e,o),v0(this.contentDOM,this.children,e),Ms&&eM(this.dom))}localCompositionInfo(e,n){let{from:r,to:s}=e.state.selection;if(!(e.state.selection instanceof ee)||r<n||s>n+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let o=i.nodeValue,l=tM(this.node.content,o,r-n,s-n);return l<0?null:{node:i,pos:l,text:o}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:s}){if(this.getDesc(n))return;let i=n;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let o=new qC(this,i,n,s);e.input.compositionNodes.push(o),this.children=Vu(this.children,r,r+s.length,e,o)}update(e,n,r,s){return this.dirty==mn||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,s),!0)}updateInner(e,n,r,s){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(s,this.posAtStart),this.dirty=Ht}updateOuterDeco(e){if(Ol(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=k0(this.dom,this.nodeDOM,$u(this.outerDeco,this.node,n),$u(e,this.node,n)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function mp(t,e,n,r,s){S0(r,e,t);let i=new lr(void 0,t,e,n,r,r,r,s,0);return i.contentDOM&&i.updateChildren(s,0),i}class Wa extends lr{constructor(e,n,r,s,i,o,l){super(e,n,r,s,i,null,o,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,s){return this.dirty==mn||this.dirty!=Ht&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=Ht||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,s.trackWrites==this.nodeDOM&&(s.trackWrites=null)),this.node=e,this.dirty=Ht,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let s=this.node.cut(e,n),i=document.createTextNode(s.text);return new Wa(this.parent,s,this.outerDeco,this.innerDeco,i,i,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=mn)}get domAtom(){return!1}isText(e){return this.node.text==e}}class x0 extends bo{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Ht&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class JC extends lr{constructor(e,n,r,s,i,o,l,a,c,u){super(e,n,r,s,i,o,l,c,u),this.spec=a}update(e,n,r,s){if(this.dirty==mn)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,n,r);return i&&this.updateInner(e,n,r,s),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,s)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,s){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,s)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function v0(t,e,n){let r=t.firstChild,s=!1;for(let i=0;i<e.length;i++){let o=e[i],l=o.dom;if(l.parentNode==t){for(;l!=r;)r=gp(r),s=!0;r=r.nextSibling}else s=!0,t.insertBefore(l,r);if(o instanceof $r){let a=r?r.previousSibling:t.lastChild;v0(o.contentDOM,o.children,n),r=a?a.nextSibling:t.firstChild}}for(;r;)r=gp(r),s=!0;s&&n.trackWrites==t&&(n.trackWrites=null)}const Ei=function(t){t&&(this.nodeName=t)};Ei.prototype=Object.create(null);const _r=[new Ei];function $u(t,e,n){if(t.length==0)return _r;let r=n?_r[0]:new Ei,s=[r];for(let i=0;i<t.length;i++){let o=t[i].type.attrs;if(o){o.nodeName&&s.push(r=new Ei(o.nodeName));for(let l in o){let a=o[l];a!=null&&(n&&s.length==1&&s.push(r=new Ei(e.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+a:l=="style"?r.style=(r.style?r.style+";":"")+a:l!="nodeName"&&(r[l]=a))}}}return s}function k0(t,e,n,r){if(n==_r&&r==_r)return e;let s=e;for(let i=0;i<r.length;i++){let o=r[i],l=n[i];if(i){let a;l&&l.nodeName==o.nodeName&&s!=t&&(a=s.parentNode)&&a.nodeName.toLowerCase()==o.nodeName||(a=document.createElement(o.nodeName),a.pmIsDeco=!0,a.appendChild(s),l=_r[0]),s=a}GC(s,l||_r[0],o)}return s}function GC(t,e,n){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in n)&&t.removeAttribute(r);for(let r in n)r!="class"&&r!="style"&&r!="nodeName"&&n[r]!=e[r]&&t.setAttribute(r,n[r]);if(e.class!=n.class){let r=e.class?e.class.split(" ").filter(Boolean):[],s=n.class?n.class.split(" ").filter(Boolean):[];for(let i=0;i<r.length;i++)s.indexOf(r[i])==-1&&t.classList.remove(r[i]);for(let i=0;i<s.length;i++)r.indexOf(s[i])==-1&&t.classList.add(s[i]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,s;for(;s=r.exec(e.style);)t.style.removeProperty(s[1])}n.style&&(t.style.cssText+=n.style)}}function S0(t,e,n){return k0(t,t,_r,$u(e,n,t.nodeType!=1))}function Ol(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].type.eq(e[n].type))return!1;return!0}function gp(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class YC{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=XC(e.node.content,e)}destroyBetween(e,n){if(e!=n){for(let r=e;r<n;r++)this.top.children[r].destroy();this.top.children.splice(e,n-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,n,r,s){let i=0,o=this.stack.length>>1,l=Math.min(o,e.length);for(;i<l&&(i==o-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<o;)this.destroyRest(),this.top.dirty=Ht,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<e.length;){this.stack.push(this.top,this.index+1);let a=-1,c=this.top.children.length;s<this.preMatch.index&&(c=Math.min(this.index+3,c));for(let u=this.index;u<c;u++){let d=this.top.children[u];if(d.matchesMark(e[o])&&!this.isLocked(d.dom)){a=u;break}}if(a>-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{let u=$r.create(this.top,e[o],n,r);this.top.children.splice(this.index,0,u),this.top=u,this.changed=!0}this.index=0,o++}}findNodeMatch(e,n,r,s){let i=-1,o;if(s>=this.preMatch.index&&(o=this.preMatch.matches[s-this.preMatch.index]).parent==this.top&&o.matchesNode(e,n,r))i=this.top.children.indexOf(o,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,n,r)&&!this.preMatch.matched.has(c)){i=l;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,n,r,s,i){let o=this.top.children[s];return o.dirty==mn&&o.dom==o.contentDOM&&(o.dirty=Tr),o.update(e,n,r,i)?(this.destroyBetween(this.index,s),this.index++,!0):!1}findIndexWithChild(e){for(;;){let n=e.parentNode;if(!n)return-1;if(n==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let s=this.index;s<this.top.children.length;s++)if(this.top.children[s]==r)return s}return-1}e=n}}updateNextNode(e,n,r,s,i,o){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof lr){let c=this.preMatch.matched.get(a);if(c!=null&&c!=i)return!1;let u=a.dom,d,h=this.isLocked(u)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=mn&&Ol(n,a.outerDeco));if(!h&&a.update(e,n,r,s))return this.destroyBetween(this.index,l),a.dom!=u&&(this.changed=!0),this.index++,!0;if(!h&&(d=this.recreateWrapper(a,e,n,r,s,o)))return this.destroyBetween(this.index,l),this.top.children[this.index]=d,d.contentDOM&&(d.dirty=Tr,d.updateChildren(s,o+1),d.dirty=Ht),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,s,i,o){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!Ol(r,e.outerDeco)||!s.eq(e.innerDeco))return null;let l=lr.create(this.top,n,r,s,i,o);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,n,r,s,i){let o=lr.create(this.top,e,n,r,s,i);o.contentDOM&&o.updateChildren(s,i+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,n,r){let s=this.index<this.top.children.length?this.top.children[this.index]:null;if(s&&s.matchesWidget(e)&&(e==s.widget||!s.widget.type.toDOM.parentNode))this.index++;else{let i=new w0(this.top,e,n,r);this.top.children.splice(this.index++,0,i),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof $r;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof Wa)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((it||Ue)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",n),this.addHackNode("BR",this.top))}addHackNode(e,n){if(n==this.top&&this.index<n.children.length&&n.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let s=new x0(this.top,[],r,null);n!=this.top?n.children.push(s):n.children.splice(this.index++,0,s),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function XC(t,e){let n=e,r=n.children.length,s=t.childCount,i=new Map,o=[];e:for(;s>0;){let l;for(;;)if(r){let c=n.children[r-1];if(c instanceof $r)n=c,r=c.children.length;else{l=c,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let a=l.node;if(a){if(a!=t.child(s-1))break;--s,i.set(l,s),o.push(l)}}return{index:s,matched:i,matches:o.reverse()}}function ZC(t,e){return t.type.side-e.type.side}function QC(t,e,n,r){let s=e.locals(t),i=0;if(s.length==0){for(let c=0;c<t.childCount;c++){let u=t.child(c);r(u,s,e.forChild(i,u),c),i+=u.nodeSize}return}let o=0,l=[],a=null;for(let c=0;;){let u,d;for(;o<s.length&&s[o].to==i;){let y=s[o++];y.widget&&(u?(d||(d=[u])).push(y):u=y)}if(u)if(d){d.sort(ZC);for(let y=0;y<d.length;y++)n(d[y],c,!!a)}else n(u,c,!!a);let h,f;if(a)f=-1,h=a,a=null;else if(c<t.childCount)f=c,h=t.child(c++);else break;for(let y=0;y<l.length;y++)l[y].to<=i&&l.splice(y--,1);for(;o<s.length&&s[o].from<=i&&s[o].to>i;)l.push(s[o++]);let p=i+h.nodeSize;if(h.isText){let y=p;o<s.length&&s[o].from<y&&(y=s[o].from);for(let b=0;b<l.length;b++)l[b].to<y&&(y=l[b].to);y<p&&(a=h.cut(y-i),h=h.cut(0,y-i),p=y,f=-1)}else for(;o<s.length&&s[o].to<p;)o++;let g=h.isInline&&!h.isLeaf?l.filter(y=>!y.inline):l.slice();r(h,g,e.forChild(i,h),f),i=p}}function eM(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}function tM(t,e,n,r){for(let s=0,i=0;s<t.childCount&&i<=r;){let o=t.child(s++),l=i;if(i+=o.nodeSize,!o.isText)continue;let a=o.text;for(;s<t.childCount;){let c=t.child(s++);if(i+=c.nodeSize,!c.isText)break;a+=c.text}if(i>=n){if(i>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l<r?a.lastIndexOf(e,r-l-1):-1;if(c>=0&&c+e.length+l>=n)return l+c;if(n==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function Vu(t,e,n,r,s){let i=[];for(let o=0,l=0;o<t.length;o++){let a=t[o],c=l,u=l+=a.size;c>=n||u<=e?i.push(a):(c<e&&i.push(a.slice(0,e-c,r)),s&&(i.push(s),s=void 0),u>n&&i.push(a.slice(n-c,a.size,r)))}return i}function oh(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let s=t.docView.nearestDesc(n.focusNode),i=s&&s.size==0,o=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let l=r.resolve(o),a,c;if(Ua(n)){for(a=o;s&&!s.node;)s=s.parent;let d=s.node;if(s&&d.isAtom&&Y.isSelectable(d)&&s.parent&&!(d.isInline&&TC(n.focusNode,n.focusOffset,s.dom))){let h=s.posBefore;c=new Y(o==h?l:r.resolve(h))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let d=o,h=o;for(let f=0;f<n.rangeCount;f++){let p=n.getRangeAt(f);d=Math.min(d,t.docView.posFromDOM(p.startContainer,p.startOffset,1)),h=Math.max(h,t.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(d<0)return null;[a,o]=h==t.state.selection.anchor?[h,d]:[d,h],l=r.resolve(o)}else a=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(a<0)return null}let u=r.resolve(a);if(!c){let d=e=="pointer"||t.state.selection.head<l.pos&&!i?1:-1;c=lh(t,u,l,d)}return c}function C0(t){return t.editable?t.hasFocus():A0(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function Rn(t,e=!1){let n=t.state.selection;if(M0(t,n),!C0(t))return;let r=t.input.mouseDown;if(!e&&Ue&&r){let s=t.domSelectionRange(),i=t.domObserver.currentSelection;if(s.anchorNode&&i.anchorNode&&zr(s.anchorNode,s.anchorOffset,i.anchorNode,i.anchorOffset)&&r.delaySelUpdate()){t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)rM(t);else{let{anchor:s,head:i}=n,o,l;yp&&!(n instanceof ee)&&(n.$from.parent.inlineContent||(o=bp(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(l=bp(t,n.to))),t.docView.setSelection(s,i,t,e),yp&&(o&&wp(o),l&&wp(l)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&nM(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}const yp=it||Ue&&d0<63;function bp(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),s=r<n.childNodes.length?n.childNodes[r]:null,i=r?n.childNodes[r-1]:null;if(it&&s&&s.contentEditable=="false")return Rc(s);if((!s||s.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(s)return Rc(s);if(i)return Rc(i)}}function Rc(t){return t.contentEditable="true",it&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function wp(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function nM(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),r=n.anchorNode,s=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=s)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!C0(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function rM(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,Ze(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&vt&&or<=11&&(n.disabled=!0,n.disabled=!1)}function M0(t,e){if(e instanceof Y){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(xp(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else xp(t)}function xp(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function lh(t,e,n,r){return t.someProp("createSelectionBetween",s=>s(t,e,n))||ee.between(e,n,r)}function vp(t){return t.editable&&!t.hasFocus()?!1:A0(t)}function A0(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function sM(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return zr(e.node,e.offset,n.anchorNode,n.anchorOffset)}function Fu(t,e){let{$anchor:n,$head:r}=t.selection,s=e>0?n.max(r):n.min(r),i=s.parent.inlineContent?s.depth?t.doc.resolve(e>0?s.after():s.before()):null:s;return i&&te.findFrom(i,e)}function Qn(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function kp(t,e,n){let r=t.state.selection;if(r instanceof ee)if(n.indexOf("s")>-1){let{$head:s}=r,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let o=t.state.doc.resolve(s.pos+i.nodeSize*(e<0?-1:1));return Qn(t,new ee(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let s=Fu(t.state,e);return s&&s instanceof Y?Qn(t,s):!1}else if(!(Lt&&n.indexOf("m")>-1)){let s=r.$head,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter,o;if(!i||i.isText)return!1;let l=e<0?s.pos-i.nodeSize:s.pos;return i.isAtom||(o=t.docView.descAt(l))&&!o.contentDOM?Y.isSelectable(i)?Qn(t,new Y(e<0?t.state.doc.resolve(s.pos-i.nodeSize):s)):yo?Qn(t,new ee(t.state.doc.resolve(e<0?l:l+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof Y&&r.node.isInline)return Qn(t,new ee(e>0?r.$to:r.$from));{let s=Fu(t.state,e);return s?Qn(t,s):!1}}}function Il(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Ti(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function ns(t,e){return e<0?iM(t):oM(t)}function iM(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s,i,o=!1;for(Bt&&n.nodeType==1&&r<Il(n)&&Ti(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(Ti(l,-1))s=n,i=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(E0(n))break;{let l=n.previousSibling;for(;l&&Ti(l,-1);)s=n.parentNode,i=Ze(l),l=l.previousSibling;if(l)n=l,r=Il(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?Uu(t,n,r):s&&Uu(t,s,i)}function oM(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s=Il(n),i,o;for(;;)if(r<s){if(n.nodeType!=1)break;let l=n.childNodes[r];if(Ti(l,1))i=n,o=++r;else break}else{if(E0(n))break;{let l=n.nextSibling;for(;l&&Ti(l,1);)i=l.parentNode,o=Ze(l)+1,l=l.nextSibling;if(l)n=l,r=0,s=Il(n);else{if(n=n.parentNode,n==t.dom)break;r=s=0}}}i&&Uu(t,i,o)}function E0(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function lM(t,e){for(;t&&e==t.childNodes.length&&!go(t);)e=Ze(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let n=t.childNodes[e];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=0}}function aM(t,e){for(;t&&!e&&!go(t);)e=Ze(t),t=t.parentNode;for(;t&&e;){let n=t.childNodes[e-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=t.childNodes.length}}function Uu(t,e,n){if(e.nodeType!=3){let i,o;(o=lM(e,n))?(e=o,n=0):(i=aM(e,n))&&(e=i,n=i.nodeValue.length)}let r=t.domSelection();if(!r)return;if(Ua(r)){let i=document.createRange();i.setEnd(e,n),i.setStart(e,n),r.removeAllRanges(),r.addRange(i)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:s}=t;setTimeout(()=>{t.state==s&&Rn(t)},50)}function Sp(t,e){let n=t.state.doc.resolve(e);if(!(Ue||h0)&&n.parent.inlineContent){let s=t.coordsAtPos(e);if(e>n.start()){let i=t.coordsAtPos(e-1),o=(i.top+i.bottom)/2;if(o>s.top&&o<s.bottom&&Math.abs(i.left-s.left)>1)return i.left<s.left?"ltr":"rtl"}if(e<n.end()){let i=t.coordsAtPos(e+1),o=(i.top+i.bottom)/2;if(o>s.top&&o<s.bottom&&Math.abs(i.left-s.left)>1)return i.left>s.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function Cp(t,e,n){let r=t.state.selection;if(r instanceof ee&&!r.empty||n.indexOf("s")>-1||Lt&&n.indexOf("m")>-1)return!1;let{$from:s,$to:i}=r;if(!s.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=Fu(t.state,e);if(o&&o instanceof Y)return Qn(t,o)}if(!s.parent.inlineContent){let o=e<0?s:i,l=r instanceof dn?te.near(o,e):te.findFrom(o,e);return l?Qn(t,l):!1}return!1}function Mp(t,e){if(!(t.state.selection instanceof ee))return!0;let{$head:n,$anchor:r,empty:s}=t.state.selection;if(!n.sameParent(r))return!0;if(!s)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let o=t.state.tr;return e<0?o.delete(n.pos-i.nodeSize,n.pos):o.delete(n.pos,n.pos+i.nodeSize),t.dispatch(o),!0}return!1}function Ap(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function cM(t){if(!it||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&e.nodeType==1&&n==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;Ap(t,r,"true"),setTimeout(()=>Ap(t,r,"false"),20)}return!1}function uM(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function dM(t,e){let n=e.keyCode,r=uM(e);if(n==8||Lt&&n==72&&r=="c")return Mp(t,-1)||ns(t,-1);if(n==46&&!e.shiftKey||Lt&&n==68&&r=="c")return Mp(t,1)||ns(t,1);if(n==13||n==27)return!0;if(n==37||Lt&&n==66&&r=="c"){let s=n==37?Sp(t,t.state.selection.from)=="ltr"?-1:1:-1;return kp(t,s,r)||ns(t,s)}else if(n==39||Lt&&n==70&&r=="c"){let s=n==39?Sp(t,t.state.selection.from)=="ltr"?1:-1:1;return kp(t,s,r)||ns(t,s)}else{if(n==38||Lt&&n==80&&r=="c")return Cp(t,-1,r)||ns(t,-1);if(n==40||Lt&&n==78&&r=="c")return cM(t)||Cp(t,1,r)||ns(t,1);if(r==(Lt?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function ah(t,e){t.someProp("transformCopied",f=>{e=f(e,t)});let n=[],{content:r,openStart:s,openEnd:i}=e;for(;s>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){s--,i--;let f=r.firstChild;n.push(f.type.name,f.attrs!=f.type.defaultAttrs?f.attrs:null),r=f.content}let o=t.someProp("clipboardSerializer")||Xr.fromSchema(t.state.schema),l=D0(),a=l.createElement("div");a.appendChild(o.serializeFragment(r,{document:l}));let c=a.firstChild,u,d=0;for(;c&&c.nodeType==1&&(u=I0[c.nodeName.toLowerCase()]);){for(let f=u.length-1;f>=0;f--){let p=l.createElement(u[f]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),d++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${s} ${i}${d?` -${d}`:""} ${JSON.stringify(n)}`);let h=t.someProp("clipboardTextSerializer",f=>f(e,t))||e.content.textBetween(0,e.content.size,`
|
|
24
24
|
|
|
25
|
-
`);return{dom:a,text:
|
|
26
|
-
`))),0,0),t.someProp("transformPasted",f=>{l=f(l,t,!0)}),l;let d=t.someProp("clipboardTextParser",f=>f(e,s,r,t));if(d)l=d;else{let f=s.marks(),{schema:h}=t.state,p=Xr.fromSchema(h);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(g=>{let y=o.appendChild(document.createElement("p"));g&&y.appendChild(p.serializeNode(h.text(g,f)))})}}else t.someProp("transformPastedHTML",d=>{n=d(n,t)}),o=mE(n),yo&&gE(o);let c=o&&o.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let d=+u[3];d>0;d--){let f=o.firstChild;for(;f&&f.nodeType!=1;)f=f.nextSibling;if(!f)break;o=f}if(l||(l=(t.someProp("clipboardParser")||t.someProp("domParser")||Ei.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||u),context:s,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!fE.test(f.parentNode.nodeName)?{ignore:!0}:null}})),u)l=yE(Tp(l,+u[1],+u[2]),u[4]);else if(l=K.maxOpen(hE(l.content,s),!0),l.openStart||l.openEnd){let d=0,f=0;for(let h=l.content.firstChild;d<l.openStart&&!h.type.spec.isolating;d++,h=h.firstChild);for(let h=l.content.lastChild;f<l.openEnd&&!h.type.spec.isolating;f++,h=h.lastChild);l=Tp(l,d,f)}return t.someProp("transformPasted",d=>{l=d(l,t,a)}),l}const fE=/^(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 hE(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let s=e.node(n).contentMatchAt(e.index(n)),i,o=[];if(t.forEach(l=>{if(!o)return;let a=s.findWrapping(l.type),c;if(!a)return o=null;if(c=o.length&&i.length&&Nb(a,i,l,o[o.length-1],0))o[o.length-1]=c;else{o.length&&(o[o.length-1]=Ob(o[o.length-1],i.length));let u=_b(l,a);o.push(u),s=s.matchType(u.type),i=a}}),o)return j.from(o)}return t}function _b(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,j.from(t));return t}function Nb(t,e,n,r,s){if(s<t.length&&s<e.length&&t[s]==e[s]){let i=Nb(t,e,n,r.lastChild,s+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(s==t.length-1?n.type:t[s+1]))return r.copy(r.content.append(j.from(_b(n,t,s+1))))}}function Ob(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,Ob(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(j.empty,!0);return t.copy(n.append(r))}function Wu(t,e,n,r,s,i){let o=e<0?t.firstChild:t.lastChild,l=o.content;return t.childCount>1&&(i=0),s<r-1&&(l=Wu(l,e,n,r,s+1,i)),s>=n&&(l=e<0?o.contentMatchAt(0).fillBefore(l,i<=s).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(j.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(l))}function Tp(t,e,n){return e<t.openStart&&(t=new K(Wu(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new K(Wu(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const Ib={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 Ap=null;function Rb(){return Ap||(Ap=document.implementation.createHTMLDocument("title"))}let Lc=null;function pE(t){let e=window.trustedTypes;return e?(Lc||(Lc=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),Lc.createHTML(t)):t}function mE(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=Rb().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),s;if((s=r&&Ib[r[1].toLowerCase()])&&(t=s.map(i=>"<"+i+">").join("")+t+s.map(i=>"</"+i+">").reverse().join("")),n.innerHTML=pE(t),s)for(let i=0;i<s.length;i++)n=n.querySelector(s[i])||n;return n}function gE(t){let e=t.querySelectorAll(Ue?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let r=e[n];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}function yE(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return t}let{content:s,openStart:i,openEnd:o}=t;for(let l=r.length-2;l>=0;l-=2){let a=n.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;s=j.from(a.create(r[l+1],s)),i++,o++}return new K(s,i,o)}const gt={},yt={},bE={touchstart:!0,touchmove:!0};class wE{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function xE(t){for(let e in gt){let n=gt[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{kE(t,r)&&!uf(t,r)&&(t.editable||!(r.type in yt))&&n(t,r)},bE[e]?{passive:!0}:void 0)}it&&t.dom.addEventListener("input",()=>null),qu(t)}function On(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function vE(t){t.input.mouseDown&&t.input.mouseDown.done(),t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function qu(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>uf(t,r))})}function uf(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function kE(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function SE(t,e){!uf(t,e)&>[e.type]&&(t.editable||!(e.type in yt))&>[e.type](t,e)}yt.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!Pb(t)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Nn&&Ue&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),Es&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",s=>s(t,Er(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||dE(t,n)?n.preventDefault():On(t,"key")};yt.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};yt.keypress=(t,e)=>{let n=e;if(Pb(t)||!n.charCode||n.ctrlKey&&!n.altKey||Lt&&n.metaKey)return;if(t.someProp("handleKeyPress",s=>s(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof ee)||!r.$from.sameParent(r.$to)){let s=String.fromCharCode(n.charCode),i=()=>t.state.tr.insertText(s).scrollIntoView();!/[\r\n]/.test(s)&&!t.someProp("handleTextInput",o=>o(t,r.$from.pos,r.$to.pos,s,i))&&t.dispatch(i()),n.preventDefault()}};function wo(t){return{left:t.clientX,top:t.clientY}}function CE(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function df(t,e,n,r,s){if(r==-1)return!1;let i=t.state.doc.resolve(r);for(let o=i.depth+1;o>0;o--)if(t.someProp(e,l=>o>i.depth?l(t,n,i.nodeAfter,i.before(o),s,!0):l(t,n,i.node(o),i.before(o),s,!1)))return!0;return!1}function xo(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);r.setMeta("pointer",!0),t.dispatch(r)}function EE(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&Y.isSelectable(r)?(xo(t,new Y(n)),!0):!1}function ME(t,e){if(e==-1)return!1;let n=t.state.selection,r,s;n instanceof Y&&(r=n.node);let i=t.state.doc.resolve(e);for(let o=i.depth+1;o>0;o--){let l=o>i.depth?i.nodeAfter:i.node(o);if(Y.isSelectable(l)){r&&n.$from.depth>0&&o>=n.$from.depth&&i.before(n.$from.depth+1)==n.$from.pos?s=i.before(n.$from.depth):s=i.before(o);break}}return s!=null?(xo(t,Y.create(t.state.doc,s)),!0):!1}function TE(t,e,n,r,s){return df(t,"handleClickOn",e,n,r)||t.someProp("handleClick",i=>i(t,e,r))||(s?ME(t,n):EE(t,n))}function AE(t,e,n,r){return df(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",s=>s(t,e,r))}function _E(t,e,n,r){return df(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",s=>s(t,e,r))||NE(t,n,r)}function NE(t,e,n){if(n.button!=0)return!1;let r=Db(t,e,!0),s=t.state.doc;return r?(xo(t,r),r instanceof ee&&s.eq(t.state.doc)&&(t.input.mouseDown=new IE(t,r)),!0):!1}function Db(t,e,n){let r=t.state.doc;if(e==-1)return r.inlineContent?ee.create(r,0,r.content.size):null;let s=r.resolve(e);for(let i=s.depth+1;i>0;i--){let o=i>s.depth?s.nodeAfter:s.node(i),l=s.before(i);if(o.inlineContent)return ee.create(r,l+1,l+1+o.content.size);if(n&&Y.isSelectable(o))return Y.create(r,l)}return null}function ff(t){return Rl(t)}const Lb=Lt?"metaKey":"ctrlKey";gt.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=ff(t),s=Date.now(),i="singleClick";s-t.input.lastClick.time<500&&CE(n,t.input.lastClick)&&!n[Lb]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?i="doubleClick":t.input.lastClick.type=="doubleClick"&&(i="tripleClick")),t.input.lastClick={time:s,x:n.clientX,y:n.clientY,type:i,button:n.button},t.input.mouseDown&&t.input.mouseDown.done();let o=t.posAtCoords(wo(n));o&&(i=="singleClick"?t.input.mouseDown=new OE(t,o,n,!!r):(i=="doubleClick"?AE:_E)(t,o.pos,o.inside,n)?n.preventDefault():On(t,"pointer"))};class jb{constructor(e){this.view=e,this.mightDrag=null,e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this))}up(e){this.done()}move(e){e.buttons==0&&this.done()}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null)}delaySelUpdate(){return!1}}class OE extends jb{constructor(e,n,r,s){super(e),this.pos=n,this.event=r,this.flushed=s,this.delayedSelectionSync=!1,this.startDoc=e.state.doc,this.selectNode=!!r[Lb],this.allowDefault=r.shiftKey;let i,o;if(n.inside>-1)i=e.state.doc.nodeAt(n.inside),o=n.inside;else{let u=e.state.doc.resolve(n.pos);i=u.parent,o=u.depth?u.before():0}const l=s?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.nodeDOM.nodeType==1?a.nodeDOM:null;let{selection:c}=e.state;r.button==0&&(i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof Y&&c.from<=o&&c.to>o)&&(this.mightDrag={node:i,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Bt&&!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()),On(e,"pointer")}done(){super.done(),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(()=>{this.view.isDestroyed||Dn(this.view)})}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(wo(e))),this.updateAllowDefault(e),this.allowDefault||!n?On(this.view,"pointer"):TE(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||it&&this.mightDrag&&!this.mightDrag.node.isAtom||Ue&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(xo(this.view,te.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):On(this.view,"pointer")}move(e){this.updateAllowDefault(e),On(this.view,"pointer"),super.move(e)}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}delaySelUpdate(){return this.allowDefault?(this.delayedSelectionSync=!0,!0):!1}}class IE extends jb{constructor(e,n){super(e),this.startSelection=n,this.startDoc=e.state.doc}move(e){if(e.buttons==0||this.view.isDestroyed||!this.view.state.doc.eq(this.startDoc)){this.done();return}e.preventDefault(),On(this.view,"pointer");let n=this.view.posAtCoords(wo(e)),r=n&&Db(this.view,n.inside,!1);if(!r)return;let{doc:s}=this.view.state,i=this.startSelection,[o,l]=r.from<i.from?[i.to,r.from]:[i.from,r.to];xo(this.view,ee.create(s,o,l))}}gt.touchstart=t=>{t.input.lastTouch=Date.now(),ff(t),On(t,"pointer")};gt.touchmove=t=>{t.input.lastTouch=Date.now(),On(t,"pointer")};gt.contextmenu=t=>ff(t);function Pb(t,e){return t.composing?!0:it&&Math.abs(Date.now()-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const RE=Nn?5e3:-1;yt.compositionstart=yt.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof ee&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||Ue&&fb&&DE(t)))t.markCursor=t.state.storedMarks||n.marks(),Rl(t,!0),t.markCursor=null;else if(Rl(t,!e.selection.empty),Bt&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let s=r.focusNode,i=r.focusOffset;s&&s.nodeType==1&&i!=0;){let o=i<0?s.lastChild:s.childNodes[i-1];if(!o)break;if(o.nodeType==3){let l=t.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else s=o,i=-1}}t.input.composing=!0}Bb(t,RE)};function DE(t){let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(!e||e.nodeType!=1||n>=e.childNodes.length)return!1;let r=e.childNodes[n];return r.nodeType==1&&r.contentEditable=="false"}yt.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Date.now(),t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.badSafariComposition?t.domObserver.forceFlush():t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,Bb(t,20))};function Bb(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>Rl(t),e))}function zb(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Date.now());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function LE(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=MC(e.focusNode,e.focusOffset),r=TC(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let s=r.pmViewDesc,i=t.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!s||!s.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let o=n.pmViewDesc;if(!(!o||!o.isText(n.nodeValue)))return r}}return n||r}function Rl(t,e=!1){if(!(Nn&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),zb(t),e||t.docView&&t.docView.dirty){let n=lf(t),r=t.state.selection;return n&&!n.eq(r)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function jE(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),s=document.createRange();s.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(s),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const Wi=vt&&or<15||Es&&OC<604;gt.copy=yt.cut=(t,e)=>{let n=e,r=t.state.selection,s=n.type=="cut";if(r.empty)return;let i=Wi?null:n.clipboardData,o=r.content(),{dom:l,text:a}=cf(t,o);i?(n.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):jE(t,l),s&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function PE(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function BE(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let s=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?qi(t,r.value,null,s,e):qi(t,r.textContent,r.innerHTML,s,e)},50)}function qi(t,e,n,r,s){let i=Ab(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",a=>a(t,s,i||K.empty)))return!0;if(!i)return!1;let o=PE(i),l=o?t.state.tr.replaceSelectionWith(o,r):t.state.tr.replaceSelection(i);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function $b(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}yt.paste=(t,e)=>{let n=e;if(t.composing&&!Nn)return;let r=Wi?null:n.clipboardData,s=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&qi(t,$b(r),r.getData("text/html"),s,n)?n.preventDefault():BE(t,n)};class Hb{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const zE=Lt?"altKey":"ctrlKey";function Fb(t,e){let n;return t.someProp("dragCopies",r=>{n=n||r(e)}),n!=null?!n:!e[zE]}gt.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let s=t.state.selection,i=s.empty?null:t.posAtCoords(wo(n)),o;if(!(i&&i.pos>=s.from&&i.pos<=(s instanceof Y?s.to-1:s.to))){if(r&&r.mightDrag)o=Y.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let d=t.docView.nearestDesc(n.target,!0);d&&d.node.type.spec.draggable&&d!=t.docView&&(o=Y.create(t.state.doc,d.posBefore))}}let l=(o||t.state.selection).content(),{dom:a,text:c,slice:u}=cf(t,l);(!n.dataTransfer.files.length||!Ue||db>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Wi?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",Wi||n.dataTransfer.setData("text/plain",c),t.dragging=new Hb(u,Fb(t,n),o)};gt.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};yt.dragover=yt.dragenter=(t,e)=>e.preventDefault();yt.drop=(t,e)=>{try{$E(t,e,t.dragging)}finally{t.dragging=null}};function $E(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(wo(e));if(!r)return;let s=t.state.doc.resolve(r.pos),i=n&&n.slice;i?t.someProp("transformPasted",h=>{i=h(i,t,!1)}):i=Ab(t,$b(e.dataTransfer),Wi?null:e.dataTransfer.getData("text/html"),!1,s);let o=!!(n&&Fb(t,e));if(t.someProp("handleDrop",h=>h(t,e,i||K.empty,o))){e.preventDefault();return}if(!i)return;e.preventDefault();let l=i?zy(t.state.doc,s.pos,i):s.pos;l==null&&(l=s.pos);let a=t.state.tr;if(o){let{node:h}=n;h?h.replace(a):a.deleteSelection()}let c=a.mapping.map(l),u=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,d=a.doc;if(u?a.replaceRangeWith(c,c,i.content.firstChild):a.replaceRange(c,c,i),a.doc.eq(d))return;let f=a.doc.resolve(c);if(u&&Y.isSelectable(i.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(i.content.firstChild))a.setSelection(new Y(f));else{let h=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((p,g,y,b)=>h=b),a.setSelection(af(t,f,a.doc.resolve(h)))}t.focus(),t.dispatch(a.setMeta("uiEvent","drop"))}gt.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&Dn(t)},20))};gt.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};gt.beforeinput=(t,e)=>{if(Ue&&Nn&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",i=>i(t,Er(8,"Backspace")))))return;let{$cursor:s}=t.state.selection;s&&s.pos>0&&t.dispatch(t.state.tr.delete(s.pos-1,s.pos).scrollIntoView())},50)}};for(let t in yt)gt[t]=yt[t];function Ki(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}class Dl{constructor(e,n){this.toDOM=e,this.spec=n||Dr,this.side=this.spec.side||0}map(e,n,r,s){let{pos:i,deleted:o}=e.mapResult(n.from+s,this.side<0?-1:1);return o?null:new De(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Dl&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Ki(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class ar{constructor(e,n){this.attrs=e,this.spec=n||Dr}map(e,n,r,s){let i=e.map(n.from+s,this.spec.inclusiveStart?-1:1)-r,o=e.map(n.to+s,this.spec.inclusiveEnd?1:-1)-r;return i>=o?null:new De(i,o,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof ar&&Ki(this.attrs,e.attrs)&&Ki(this.spec,e.spec)}static is(e){return e.type instanceof ar}destroy(){}}class hf{constructor(e,n){this.attrs=e,this.spec=n||Dr}map(e,n,r,s){let i=e.mapResult(n.from+s,1);if(i.deleted)return null;let o=e.mapResult(n.to+s,-1);return o.deleted||o.pos<=i.pos?null:new De(i.pos-r,o.pos-r,this)}valid(e,n){let{index:r,offset:s}=e.content.findIndex(n.from),i;return s==n.from&&!(i=e.child(r)).isText&&s+i.nodeSize==n.to}eq(e){return this==e||e instanceof hf&&Ki(this.attrs,e.attrs)&&Ki(this.spec,e.spec)}destroy(){}}class De{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new De(e,n,this.type)}eq(e,n=0){return this.type.eq(e.type)&&this.from+n==e.from&&this.to+n==e.to}map(e,n,r){return this.type.map(e,this,n,r)}static widget(e,n,r){return new De(e,e,new Dl(n,r))}static inline(e,n,r,s){return new De(e,n,new ar(r,s))}static node(e,n,r,s){return new De(e,n,new hf(r,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof ar}get widget(){return this.type instanceof Dl}}const cs=[],Dr={};class he{constructor(e,n){this.local=e.length?e:cs,this.children=n.length?n:cs}static create(e,n){return n.length?Ll(n,e,0,Dr):nt}find(e,n,r){let s=[];return this.findInner(e??0,n??1e9,s,0,r),s}findInner(e,n,r,s,i){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=n&&l.to>=e&&(!i||i(l.spec))&&r.push(l.copy(l.from+s,l.to+s))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<n&&this.children[o+1]>e){let l=this.children[o]+1;this.children[o+2].findInner(e-l,n-l,r,s+l,i)}}map(e,n,r){return this==nt||e.maps.length==0?this:this.mapInner(e,n,0,0,r||Dr)}mapInner(e,n,r,s,i){let o;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,s);a&&a.type.valid(n,a)?(o||(o=[])).push(a):i.onRemove&&i.onRemove(this.local[l].spec)}return this.children.length?HE(this.children,o||[],e,n,r,s,i):o?new he(o.sort(Lr),cs):nt}add(e,n){return n.length?this==nt?he.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let s,i=0;e.forEach((l,a)=>{let c=a+r,u;if(u=Ub(n,l,c)){for(s||(s=this.children.slice());i<s.length&&s[i]<a;)i+=3;s[i]==a?s[i+2]=s[i+2].addInner(l,u,c+1):s.splice(i,0,a,a+l.nodeSize,Ll(u,l,c+1,Dr)),i+=3}});let o=Vb(i?Wb(n):n,-r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new he(o.length?this.local.concat(o).sort(Lr):this.local,s||this.children)}remove(e){return e.length==0||this==nt?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,s=this.local;for(let i=0;i<r.length;i+=3){let o,l=r[i]+n,a=r[i+1]+n;for(let u=0,d;u<e.length;u++)(d=e[u])&&d.from>l&&d.to<a&&(e[u]=null,(o||(o=[])).push(d));if(!o)continue;r==this.children&&(r=this.children.slice());let c=r[i+2].removeInner(o,l+1);c!=nt?r[i+2]=c:(r.splice(i,3),i-=3)}if(s.length){for(let i=0,o;i<e.length;i++)if(o=e[i])for(let l=0;l<s.length;l++)s[l].eq(o,n)&&(s==this.local&&(s=this.local.slice()),s.splice(l--,1))}return r==this.children&&s==this.local?this:s.length||r.length?new he(s,r):nt}forChild(e,n){if(this==nt)return this;if(n.isLeaf)return he.empty;let r,s;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let i=e+1,o=i+n.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<o&&a.to>i&&a.type instanceof ar){let c=Math.max(i,a.from)-i,u=Math.min(o,a.to)-i;c<u&&(s||(s=[])).push(a.copy(c,u))}}if(s){let l=new he(s.sort(Lr),cs);return r?new nr([l,r]):l}return r||nt}eq(e){if(this==e)return!0;if(!(e instanceof he)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(e.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=e.children[n]||this.children[n+1]!=e.children[n+1]||!this.children[n+2].eq(e.children[n+2]))return!1;return!0}locals(e){return pf(this.localsInner(e))}localsInner(e){if(this==nt)return cs;if(e.inlineContent||!this.local.some(ar.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof ar||n.push(this.local[r]);return n}forEachSet(e){e(this)}}he.empty=new he([],[]);he.removeOverlap=pf;const nt=he.empty;class nr{constructor(e){this.members=e}map(e,n){const r=this.members.map(s=>s.map(e,n,Dr));return nr.from(r)}forChild(e,n){if(n.isLeaf)return he.empty;let r=[];for(let s=0;s<this.members.length;s++){let i=this.members[s].forChild(e,n);i!=nt&&(i instanceof nr?r=r.concat(i.members):r.push(i))}return nr.from(r)}eq(e){if(!(e instanceof nr)||e.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(e.members[n]))return!1;return!0}locals(e){let n,r=!0;for(let s=0;s<this.members.length;s++){let i=this.members[s].localsInner(e);if(i.length)if(!n)n=i;else{r&&(n=n.slice(),r=!1);for(let o=0;o<i.length;o++)n.push(i[o])}}return n?pf(r?n:n.sort(Lr)):cs}static from(e){switch(e.length){case 0:return nt;case 1:return e[0];default:return new nr(e.every(n=>n instanceof he)?e:e.reduce((n,r)=>n.concat(r instanceof he?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function HE(t,e,n,r,s,i,o){let l=t.slice();for(let c=0,u=i;c<n.maps.length;c++){let d=0;n.maps[c].forEach((f,h,p,g)=>{let y=g-p-(h-f);for(let b=0;b<l.length;b+=3){let w=l[b+1];if(w<0||f>w+u-d)continue;let v=l[b]+u-d;h>=v?l[b+1]=f<=v?-2:-1:f>=u&&y&&(l[b]+=y,l[b+1]+=y)}d+=y}),u=n.maps[c].map(u,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let u=n.map(t[c]+i),d=u-s;if(d<0||d>=r.content.size){a=!0;continue}let f=n.map(t[c+1]+i,-1),h=f-s,{index:p,offset:g}=r.content.findIndex(d),y=r.maybeChild(p);if(y&&g==d&&g+y.nodeSize==h){let b=l[c+2].mapInner(n,y,u+1,t[c]+i+1,o);b!=nt?(l[c]=d,l[c+1]=h,l[c+2]=b):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=FE(l,t,e,n,s,i,o),u=Ll(c,r,0,o);e=u.local;for(let d=0;d<l.length;d+=3)l[d+1]<0&&(l.splice(d,3),d-=3);for(let d=0,f=0;d<u.children.length;d+=3){let h=u.children[d];for(;f<l.length&&l[f]<h;)f+=3;l.splice(f,0,u.children[d],u.children[d+1],u.children[d+2])}}return new he(e.sort(Lr),l)}function Vb(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let s=t[r];n.push(new De(s.from+e,s.to+e,s.type))}return n}function FE(t,e,n,r,s,i,o){function l(a,c){for(let u=0;u<a.local.length;u++){let d=a.local[u].map(r,s,c);d?n.push(d):o.onRemove&&o.onRemove(a.local[u].spec)}for(let u=0;u<a.children.length;u+=3)l(a.children[u+2],a.children[u]+c+1)}for(let a=0;a<t.length;a+=3)t[a+1]==-1&&l(t[a+2],e[a]+i+1);return n}function Ub(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,s=null;for(let i=0,o;i<t.length;i++)(o=t[i])&&o.from>n&&o.to<r&&((s||(s=[])).push(o),t[i]=null);return s}function Wb(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function Ll(t,e,n,r){let s=[],i=!1;e.forEach((l,a)=>{let c=Ub(t,l,a+n);if(c){i=!0;let u=Ll(c,l,n+a+1,r);u!=nt&&s.push(a,a+l.nodeSize,u)}});let o=Vb(i?Wb(t):t,-n).sort(Lr);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||(r.onRemove&&r.onRemove(o[l].spec),o.splice(l--,1));return o.length||s.length?new he(o,s):nt}function Lr(t,e){return t.from-e.from||t.to-e.to}function pf(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let s=n+1;s<e.length;s++){let i=e[s];if(i.from==r.from){i.to!=r.to&&(e==t&&(e=t.slice()),e[s]=i.copy(i.from,r.to),_p(e,s+1,i.copy(r.to,i.to)));continue}else{i.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,i.from),_p(e,s,r.copy(i.from,r.to)));break}}}return e}function _p(t,e,n){for(;e<t.length&&Lr(n,t[e])>0;)e++;t.splice(e,0,n)}function jc(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=nt&&e.push(r)}),t.cursorWrapper&&e.push(he.create(t.state.doc,[t.cursorWrapper.deco])),nr.from(e)}const VE={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},UE=vt&&or<=11;class WE{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 qE{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new WE,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let s=0;s<r.length;s++)this.queue.push(r[s]);vt&&or<=11&&r.some(s=>s.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():it&&e.composing&&r.some(s=>s.type=="childList"&&s.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),UE&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,VE)),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 n=0;n<e.length;n++)this.queue.push(e[n]);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(vp(this.view)){if(this.suppressingSelectionUpdates)return Dn(this.view);if(vt&&or<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&$r(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 n=new Set,r;for(let i=e.focusNode;i;i=Cs(i))n.add(i);for(let i=e.anchorNode;i;i=Cs(i))if(n.has(i)){r=i;break}let s=r&&this.view.docView.nearestDesc(r);if(s&&s.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),s=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&vp(e)&&!this.ignoreSelectionChange(r),i=-1,o=-1,l=!1,a=[];if(e.editable)for(let u=0;u<n.length;u++){let d=this.registerMutation(n[u],a);d&&(i=i<0?d.from:Math.min(d.from,i),o=o<0?d.to:Math.max(d.to,o),d.typeOver&&(l=!0))}if(a.some(u=>u.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46||Ue&&(e.composing||e.input.compositionEndedAt>Date.now()-50)&&n.some(u=>u.type=="childList"&&u.removedNodes.length))){for(let u of a)if(u.nodeName=="BR"&&u.parentNode){let d=u.nextSibling;for(;d&&d.nodeType==1;){if(d.contentEditable=="false"){u.parentNode.removeChild(u);break}d=d.firstChild}}}else if(Bt&&a.length){let u=a.filter(d=>d.nodeName=="BR");if(u.length==2){let[d,f]=u;d.parentNode&&d.parentNode.parentNode==f.parentNode?f.remove():d.remove()}else{let{focusNode:d}=this.currentSelection;for(let f of u){let h=f.parentNode;h&&h.nodeName=="LI"&&(!d||GE(e,d)!=h)&&f.remove()}}}let c=null;i<0&&s&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Ua(r)&&(c=lf(e))&&c.eq(te.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Dn(e),this.currentSelection.set(r),e.scrollToSelection()):(i>-1||s)&&(i>-1&&(e.docView.markDirty(i,o),KE(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,YE(e,a)),this.handleDOMChange(i,o,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Dn(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let u=0;u<e.addedNodes.length;u++){let d=e.addedNodes[u];n.push(d),d.nodeType==3&&(this.lastChangedTextNode=d)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let s=e.previousSibling,i=e.nextSibling;if(vt&&or<=11&&e.addedNodes.length)for(let u=0;u<e.addedNodes.length;u++){let{previousSibling:d,nextSibling:f}=e.addedNodes[u];(!d||Array.prototype.indexOf.call(e.addedNodes,d)<0)&&(s=d),(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(i=f)}let o=s&&s.parentNode==e.target?Ze(s)+1:0,l=r.localPosFromDOM(e.target,o,-1),a=i&&i.parentNode==e.target?Ze(i):e.target.childNodes.length,c=r.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let Np=new WeakMap,Op=!1;function KE(t){if(!Np.has(t)&&(Np.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=Bt,Op)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."),Op=!0}}function Ip(t,e){let n=e.startContainer,r=e.startOffset,s=e.endContainer,i=e.endOffset,o=t.domAtPos(t.state.selection.anchor);return $r(o.node,o.offset,s,i)&&([n,r,s,i]=[s,i,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:i}}function JE(t,e){if(e.getComposedRanges){let s=e.getComposedRanges(t.root)[0];if(s)return Ip(t,s)}let n;function r(s){s.preventDefault(),s.stopImmediatePropagation(),n=s.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",r,!0),n?Ip(t,n):null}function GE(t,e){for(let n=e.parentNode;n&&n!=t.dom;n=n.parentNode){let r=t.docView.nearestDesc(n,!0);if(r&&r.node.isBlock)return n}return null}function YE(t,e){var n;let{focusNode:r,focusOffset:s}=t.domSelectionRange();for(let i of e)if(((n=i.parentNode)===null||n===void 0?void 0:n.nodeName)=="TR"){let o=i.nextSibling;for(;o&&o.nodeName!="TD"&&o.nodeName!="TH";)o=o.nextSibling;if(o){let l=o;for(;;){let a=l.firstChild;if(!a||a.nodeType!=1||a.contentEditable=="false"||/^(BR|IMG)$/.test(a.nodeName))break;l=a}l.insertBefore(i,l.firstChild),r==i&&t.domSelection().collapse(i,s)}else i.parentNode.removeChild(i)}}function XE(t,e,n){let{node:r,fromOffset:s,toOffset:i,from:o,to:l}=t.docView.parseRange(e,n),a=t.domSelectionRange(),c,u=a.anchorNode;if(u&&t.dom.contains(u.nodeType==1?u:u.parentNode)&&(c=[{node:u,offset:a.anchorOffset}],Ua(a)||c.push({node:a.focusNode,offset:a.focusOffset})),Ue&&t.input.lastKeyCode===8)for(let y=i;y>s;y--){let b=r.childNodes[y-1],w=b.pmViewDesc;if(b.nodeName=="BR"&&!w){i=y;break}if(!w||w.size)break}let d=t.state.doc,f=t.someProp("domParser")||Ei.fromSchema(t.state.schema),h=d.resolve(o),p=null,g=f.parse(r,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:s,to:i,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:ZE,context:h});if(c&&c[0].pos!=null){let y=c[0].pos,b=c[1]&&c[1].pos;b==null&&(b=y),p={anchor:y+o,head:b+o}}return{doc:g,sel:p,from:o,to:l}}function ZE(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(it&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}else if(t.parentNode.lastChild==t||it&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}const QE=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function eM(t,e,n,r,s){let i=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let E=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,O=lf(t,E);if(O&&!t.state.selection.eq(O)){if(Ue&&Nn&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",M=>M(t,Er(13,"Enter"))))return;let _=t.state.tr.setSelection(O);E=="pointer"?_.setMeta("pointer",!0):E=="key"&&_.scrollIntoView(),i&&_.setMeta("composition",i),t.dispatch(_)}return}let o=t.state.doc.resolve(e),l=o.sharedDepth(n);e=o.before(l+1),n=t.state.doc.resolve(n).after(l+1);let a=t.state.selection,c=XE(t,e,n),u=t.state.doc,d=u.slice(c.from,c.to),f,h;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(f=t.state.selection.to,h="end"):(f=t.state.selection.from,h="start"),t.input.lastKeyCode=null;let p=rM(d.content,c.doc.content,c.from,f,h);if(p&&t.input.domChangeCount++,(Es&&t.input.lastIOSEnter>Date.now()-225||Nn)&&s.some(E=>E.nodeType==1&&!QE.test(E.nodeName))&&(!p||p.endA>=p.endB)&&t.someProp("handleKeyDown",E=>E(t,Er(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!p)if(r&&a instanceof ee&&!a.empty&&a.$head.sameParent(a.$anchor)&&!t.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let E=Rp(t,t.state.doc,c.sel);if(E&&!E.eq(t.state.selection)){let O=t.state.tr.setSelection(E);i&&O.setMeta("composition",i),t.dispatch(O)}}return}t.state.selection.from<t.state.selection.to&&p.start==p.endB&&t.state.selection instanceof ee&&(p.start>t.state.selection.from&&p.start<=t.state.selection.from+2&&t.state.selection.from>=c.from?p.start=t.state.selection.from:p.endA<t.state.selection.to&&p.endA>=t.state.selection.to-2&&t.state.selection.to<=c.to&&(p.endB+=t.state.selection.to-p.endA,p.endA=t.state.selection.to)),vt&&or<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)==" "&&(p.start--,p.endA--,p.endB--);let g=c.doc.resolveNoCache(p.start-c.from),y=c.doc.resolveNoCache(p.endB-c.from),b=u.resolve(p.start),w=g.sameParent(y)&&g.parent.inlineContent&&b.end()>=p.endA;if((Es&&t.input.lastIOSEnter>Date.now()-225&&(!w||s.some(E=>E.nodeName=="DIV"||E.nodeName=="P"))||!w&&g.pos<c.doc.content.size&&(!g.sameParent(y)||!g.parent.inlineContent)&&g.pos<y.pos&&!/\S/.test(c.doc.textBetween(g.pos,y.pos,"","")))&&t.someProp("handleKeyDown",E=>E(t,Er(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>p.start&&nM(u,p.start,p.endA,g,y)&&t.someProp("handleKeyDown",E=>E(t,Er(8,"Backspace")))){Nn&&Ue&&t.domObserver.suppressSelectionUpdates();return}Ue&&p.endB==p.start&&(t.input.lastChromeDelete=Date.now()),Nn&&!w&&g.start()!=y.start()&&y.parentOffset==0&&g.depth==y.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,y=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{t.someProp("handleKeyDown",function(E){return E(t,Er(13,"Enter"))})},20));let v=p.start,x=p.endA,k=E=>{let O=E||t.state.tr.replace(v,x,c.doc.slice(p.start-c.from,p.endB-c.from));if(c.sel){let _=Rp(t,O.doc,c.sel);_&&!(Ue&&t.composing&&_.empty&&(p.start!=p.endB||t.input.lastChromeDelete<Date.now()-100)&&(_.head==v||_.head==O.mapping.map(x)-1)||vt&&_.empty&&_.head==v)&&O.setSelection(_)}return i&&O.setMeta("composition",i),O.scrollIntoView()},C;if(w)if(g.pos==y.pos){vt&&or<=11&&g.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>Dn(t),20));let E=k(t.state.tr.delete(v,x)),O=u.resolve(p.start).marksAcross(u.resolve(p.endA));O&&E.ensureMarks(O),t.dispatch(E)}else if(p.endA==p.endB&&(C=tM(g.parent.content.cut(g.parentOffset,y.parentOffset),b.parent.content.cut(b.parentOffset,p.endA-b.start())))){let E=k(t.state.tr);C.type=="add"?E.addMark(v,x,C.mark):E.removeMark(v,x,C.mark),t.dispatch(E)}else if(g.parent.child(g.index()).isText&&g.index()==y.index()-(y.textOffset?0:1)){let E=g.parent.textBetween(g.parentOffset,y.parentOffset),O=()=>k(t.state.tr.insertText(E,v,x));t.someProp("handleTextInput",_=>_(t,v,x,E,O))||t.dispatch(O())}else t.dispatch(k());else t.dispatch(k())}function Rp(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:af(t,e.resolve(n.anchor),e.resolve(n.head))}function tM(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,s=n,i=r,o,l,a;for(let u=0;u<r.length;u++)s=r[u].removeFromSet(s);for(let u=0;u<n.length;u++)i=n[u].removeFromSet(i);if(s.length==1&&i.length==0)l=s[0],o="add",a=u=>u.mark(l.addToSet(u.marks));else if(s.length==0&&i.length==1)l=i[0],o="remove",a=u=>u.mark(l.removeFromSet(u.marks));else return null;let c=[];for(let u=0;u<e.childCount;u++)c.push(a(e.child(u)));if(j.from(c).eq(t))return{mark:l,type:o}}function nM(t,e,n,r,s){if(n-e<=s.pos-r.pos||Pc(r,!0,!1)<s.pos)return!1;let i=t.resolve(e);if(!r.parent.isTextblock){let l=i.nodeAfter;return l!=null&&n==e+l.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let o=t.resolve(Pc(i,!0,!0));return!o.parent.isTextblock||o.pos>n||Pc(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function Pc(t,e,n){let r=t.depth,s=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,s++,e=!1;if(n){let i=t.node(r).maybeChild(t.indexAfter(r));for(;i&&!i.isLeaf;)i=i.firstChild,s++}return s}function rM(t,e,n,r,s){let i=t.findDiffStart(e,n),o=n+t.size,l=n+e.size;if(i==null)return null;let{a,b:c}=t.findDiffEnd(e,o,l);if(s=="end"){let u=Math.max(0,i-Math.min(a,c));r-=a+u-i}if(a<i&&o<l){let u=r<=i&&r>=a?i-r:0;i-=u,c=i+(c-a),a=i}else if(c<i){let u=r<=i&&r>=c?i-r:0;i-=u,a=i+(a-c),c=i}return{start:i,endA:a,endB:c}}class qb{constructor(e,n){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 wE,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(Bp),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=jp(this),Lp(this),this.nodeViews=Pp(this),this.docView=mp(this.state.doc,Dp(this),jc(this),this.dom,this),this.domObserver=new qE(this,(r,s,i,o)=>eM(this,r,s,i,o)),this.domObserver.start(),xE(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 n in e)this._props[n]=e[n];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&qu(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Bp),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let s=this.state,i=!1,o=!1;e.storedMarks&&this.composing&&(zb(this),o=!0),this.state=e;let l=s.plugins!=e.plugins||this._props.plugins!=n.plugins;if(l||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let h=Pp(this);iM(h,this.nodeViews)&&(this.nodeViews=h,i=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&qu(this),this.editable=jp(this),Lp(this);let a=jc(this),c=Dp(this),u=s.plugins!=e.plugins&&!s.doc.eq(e.doc)?"reset":e.scrollToSelection>s.scrollToSelection?"to selection":"preserve",d=i||!this.docView.matchesNode(e.doc,c,a);(d||!e.selection.eq(s.selection))&&(o=!0);let f=u=="preserve"&&o&&this.dom.style.overflowAnchor==null&&DC(this);if(o){this.domObserver.stop();let h=d&&(vt||Ue)&&!this.composing&&!s.selection.empty&&!e.selection.empty&&sM(s.selection,e.selection);if(d){let g=Ue?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=LE(this)),(i||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=mp(e.doc,c,a,this.dom,this)),g&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(h=!0)}let p=this.input.mouseDown;h||!(p&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&sE(this)&&p.delaySelUpdate())?Dn(this,h):(Eb(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(s),!((r=this.dragging)===null||r===void 0)&&r.node&&!s.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,s),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():f&&LC(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof Y){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&cp(this,n.getBoundingClientRect(),e)}else cp(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n<this.directPlugins.length;n++){let r=this.directPlugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let n=0;n<this.state.plugins.length;n++){let r=this.state.plugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let n=0;n<this.pluginViews.length;n++){let r=this.pluginViews[n];r.update&&r.update(this,e)}}updateDraggedNode(e,n){let r=e.node,s=-1;if(r.from<this.state.doc.content.size&&this.state.doc.nodeAt(r.from)==r.node)s=r.from;else{let i=r.from+(this.state.doc.content.size-n.doc.content.size);(i>0&&i<this.state.doc.content.size&&this.state.doc.nodeAt(i))==r.node&&(s=i)}this.dragging=new Hb(e.slice,e.move,s<0?void 0:Y.create(this.state.doc,s))}someProp(e,n){let r=this._props&&this._props[e],s;if(r!=null&&(s=n?n(r):r))return s;for(let o=0;o<this.directPlugins.length;o++){let l=this.directPlugins[o].props[e];if(l!=null&&(s=n?n(l):l))return s}let i=this.state.plugins;if(i)for(let o=0;o<i.length;o++){let l=i[o].props[e];if(l!=null&&(s=n?n(l):l))return s}}hasFocus(){if(vt){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&jC(this.dom),Dn(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let n=this.dom.parentNode;n;n=n.parentNode)if(n.nodeType==9||n.nodeType==11&&n.host)return n.getSelection||(Object.getPrototypeOf(n).getSelection=()=>n.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return HC(this,e)}coordsAtPos(e,n=1){return yb(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,r=-1){let s=this.docView.posFromDOM(e,n,r);if(s==null)throw new RangeError("DOM position not inside the editor");return s}endOfTextblock(e,n){return qC(this,n||this.state,e)}pasteHTML(e,n){return qi(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return qi(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return cf(this,e)}destroy(){this.docView&&(vE(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],jc(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,CC())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return SE(this,e)}domSelectionRange(){let e=this.domSelection();return e?it&&this.root.nodeType===11&&_C(this.dom.ownerDocument)==this.dom&&JE(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}qb.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function Dp(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(t.state)),n)for(let r in n)r=="class"?e.class+=" "+n[r]:r=="style"?e.style=(e.style?e.style+";":"")+n[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(n[r]))}),e.translate||(e.translate="no"),[De.node(0,t.state.doc.content.size,e)]}function Lp(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:De.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function jp(t){return!t.someProp("editable",e=>e(t.state)===!1)}function sM(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}function Pp(t){let e=Object.create(null);function n(r){for(let s in r)Object.prototype.hasOwnProperty.call(e,s)||(e[s]=r[s])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function iM(t,e){let n=0,r=0;for(let s in t){if(t[s]!=e[s])return!0;n++}for(let s in e)r++;return n!=r}function Bp(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var cr={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:"'"},jl={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},oM=typeof navigator<"u"&&/Mac/.test(navigator.platform),lM=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Qe=0;Qe<10;Qe++)cr[48+Qe]=cr[96+Qe]=String(Qe);for(var Qe=1;Qe<=24;Qe++)cr[Qe+111]="F"+Qe;for(var Qe=65;Qe<=90;Qe++)cr[Qe]=String.fromCharCode(Qe+32),jl[Qe]=String.fromCharCode(Qe);for(var Bc in cr)jl.hasOwnProperty(Bc)||(jl[Bc]=cr[Bc]);function aM(t){var e=oM&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||lM&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?jl:cr)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}const cM=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),uM=typeof navigator<"u"&&/Win/.test(navigator.platform);function dM(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,s,i,o;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))s=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))cM?o=!0:s=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(n="Alt-"+n),s&&(n="Ctrl-"+n),o&&(n="Meta-"+n),i&&(n="Shift-"+n),n}function fM(t){let e=Object.create(null);for(let n in t)e[dM(n)]=t[n];return e}function zc(t,e,n=!0){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n&&e.shiftKey&&(t="Shift-"+t),t}function hM(t){return new ce({props:{handleKeyDown:mf(t)}})}function mf(t){let e=fM(t);return function(n,r){let s=aM(r),i,o=e[zc(s,r)];if(o&&o(n.state,n.dispatch,n))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let l=e[zc(s,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(uM&&r.ctrlKey&&r.altKey)&&(i=cr[r.keyCode])&&i!=s){let l=e[zc(i,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var pM=Object.defineProperty,gf=(t,e)=>{for(var n in e)pM(t,n,{get:e[n],enumerable:!0})};function qa(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:s}=n,{storedMarks:i}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return i},get selection(){return r},get doc(){return s},get tr(){return r=n.selection,s=n.doc,i=n.storedMarks,n}}}var Ka=class{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:e,state:n}=this,{view:r}=e,{tr:s}=n,i=this.buildProps(s);return Object.fromEntries(Object.entries(t).map(([o,l])=>[o,(...c)=>{const u=l(...c)(i);return!s.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(s),u}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:r,state:s}=this,{view:i}=r,o=[],l=!!t,a=t||s.tr,c=()=>(!l&&e&&!a.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(a),o.every(d=>d===!0)),u={...Object.fromEntries(Object.entries(n).map(([d,f])=>[d,(...p)=>{const g=this.buildProps(a,e),y=f(...p)(g);return o.push(y),u}])),run:c};return u}createCan(t){const{rawCommands:e,state:n}=this,r=!1,s=t||n.tr,i=this.buildProps(s,r);return{...Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...c)=>a(...c)({...i,dispatch:void 0})])),chain:()=>this.createChain(s,r)}}buildProps(t,e=!0){const{rawCommands:n,editor:r,state:s}=this,{view:i}=r,o={tr:t,editor:r,view:i,state:qa({state:s,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map(([l,a])=>[l,(...c)=>a(...c)(o)]))}};return o}},Kb={};gf(Kb,{blur:()=>mM,clearContent:()=>gM,clearNodes:()=>yM,command:()=>bM,createParagraphNear:()=>wM,cut:()=>xM,deleteCurrentNode:()=>vM,deleteNode:()=>kM,deleteRange:()=>SM,deleteSelection:()=>MM,enter:()=>TM,exitCode:()=>AM,extendMarkRange:()=>_M,first:()=>NM,focus:()=>IM,forEach:()=>RM,insertContent:()=>DM,insertContentAt:()=>PM,joinBackward:()=>$M,joinDown:()=>zM,joinForward:()=>HM,joinItemBackward:()=>FM,joinItemForward:()=>VM,joinTextblockBackward:()=>UM,joinTextblockForward:()=>WM,joinUp:()=>BM,keyboardShortcut:()=>KM,lift:()=>JM,liftEmptyBlock:()=>GM,liftListItem:()=>YM,newlineInCode:()=>XM,resetAttributes:()=>ZM,scrollIntoView:()=>QM,selectAll:()=>eT,selectNodeBackward:()=>tT,selectNodeForward:()=>nT,selectParentNode:()=>rT,selectTextblockEnd:()=>sT,selectTextblockStart:()=>iT,setContent:()=>oT,setMark:()=>ET,setMeta:()=>MT,setNode:()=>TT,setNodeSelection:()=>AT,setTextDirection:()=>_T,setTextSelection:()=>NT,sinkListItem:()=>OT,splitBlock:()=>IT,splitListItem:()=>RT,toggleList:()=>LT,toggleMark:()=>jT,toggleNode:()=>PT,toggleWrap:()=>BT,undoInputRule:()=>zT,unsetAllMarks:()=>$T,unsetMark:()=>HT,unsetTextDirection:()=>FT,updateAttributes:()=>VT,wrapIn:()=>UT,wrapInList:()=>WT});var mM=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window==null?void 0:window.getSelection())==null||n.removeAllRanges())}),!0),gM=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),yM=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:s}=r;return n&&s.forEach(({$from:i,$to:o})=>{t.doc.nodesBetween(i.pos,o.pos,(l,a)=>{if(l.type.isText)return;const{doc:c,mapping:u}=e,d=c.resolve(u.map(a)),f=c.resolve(u.map(a+l.nodeSize)),h=d.blockRange(f);if(!h)return;const p=Hs(h);if(l.type.isTextblock){const{defaultType:g}=d.parent.contentMatchAt(d.index());e.setNodeMarkup(h.start,g)}(p||p===0)&&e.lift(h,p)})}),!0},bM=t=>e=>t(e),wM=()=>({state:t,dispatch:e})=>ob(t,e),xM=(t,e)=>({editor:n,tr:r})=>{const{state:s}=n,i=s.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const o=r.mapping.map(e);return r.insert(o,i.content),r.setSelection(new ee(r.doc.resolve(Math.max(o-1,0)))),!0},vM=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const s=t.selection.$anchor;for(let i=s.depth;i>0;i-=1)if(s.node(i).type===r.type){if(e){const l=s.before(i),a=s.after(i);t.delete(l,a).scrollIntoView()}return!0}return!1};function Le(t,e){if(typeof t=="string"){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}var kM=t=>({tr:e,state:n,dispatch:r})=>{const s=Le(t,n.schema),i=e.selection.$anchor;for(let o=i.depth;o>0;o-=1)if(i.node(o).type===s){if(r){const a=i.before(o),c=i.after(o);e.delete(a,c).scrollIntoView()}return!0}return!1},SM=t=>({tr:e,dispatch:n})=>{const{from:r,to:s}=t;return n&&e.delete(r,s),!0},CM=t=>t.content?/^text(\*|\+)/.test(t.content):!1,zp=(t,e,n)=>{if(!t.parent.isInline||n==="left"&&t.pos>t.start()||n==="right"&&t.pos<t.end())return t.pos;const r=e.nodes[t.parent.type.name].spec;return CM(r)?n==="left"?t.start()-1:t.end()+1:t.pos},EM=(t,e,n)=>{const r=zp(t,n,"left"),s=zp(e,n,"right");return{from:r,to:s}},MM=()=>({state:t,dispatch:e})=>{const{$from:n,$to:r}=t.selection;if(t.selection.empty)return!1;const{from:s,to:i}=EM(n,r,t.schema);return e&&(t.tr.deleteRange(s,i).scrollIntoView(),e(t.tr)),!0},TM=()=>({commands:t})=>t.keyboardShortcut("Enter"),AM=()=>({state:t,dispatch:e})=>cC(t,e);function yf(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function Pl(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(s=>n.strict?e[s]===t[s]:yf(e[s])?e[s].test(t[s]):e[s]===t[s]):!0}function Jb(t,e,n={}){return t.find(r=>r.type===e&&Pl(Object.fromEntries(Object.keys(n).map(s=>[s,r.attrs[s]])),n))}function $p(t,e,n={}){return!!Jb(t,e,n)}function bf(t,e,n){if(!t||!e)return;let r=t.parent.childAfter(t.parentOffset);if((!r.node||!r.node.marks.some(c=>c.type===e))&&(r=t.parent.childBefore(t.parentOffset)),!r.node||!r.node.marks.some(c=>c.type===e))return;if(!n){const c=r.node.marks.find(u=>u.type===e);c&&(n=c.attrs)}if(!Jb([...r.node.marks],e,n))return;let i=r.index,o=t.start()+r.offset,l=i+1,a=o+r.node.nodeSize;for(;i>0&&$p([...t.parent.child(i-1).marks],e,n);)i-=1,o-=t.parent.child(i).nodeSize;for(;l<t.parent.childCount&&$p([...t.parent.child(l).marks],e,n);)a+=t.parent.child(l).nodeSize,l+=1;return{from:o,to:a}}function Bn(t,e){if(typeof t=="string"){if(!e.marks[t])throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`);return e.marks[t]}return t}var _M=(t,e)=>({tr:n,state:r,dispatch:s})=>{const i=Bn(t,r.schema),{doc:o,selection:l}=n,{$from:a,from:c,to:u}=l;if(s){const d=bf(a,i,e);if(d&&d.from<=c&&d.to>=u){const f=ee.create(o,d.from,d.to);n.setSelection(f)}}return!0},NM=t=>e=>{const n=typeof t=="function"?t(e):t;for(let r=0;r<n.length;r+=1)if(n[r](e))return!0;return!1};function Ja(t){return t instanceof ee}function In(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function Gb(t,e=null){if(!e)return null;const n=te.atStart(t),r=te.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const s=n.from,i=r.to;return e==="all"?ee.create(t,In(0,s,i),In(t.content.size,s,i)):ee.create(t,In(e,s,i),In(e,s,i))}function Ku(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function Ji(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function OM(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var IM=(t=null,e={})=>({editor:n,view:r,tr:s,dispatch:i})=>{e={scrollIntoView:!0,...e};const o=()=>{(Ji()||Ku())&&r.dom.focus(),OM()&&!Ji()&&!Ku()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e!=null&&e.scrollIntoView&&n.commands.scrollIntoView())})};try{if(r.hasFocus()&&t===null||t===!1)return!0}catch{return!1}if(i&&t===null&&!Ja(n.state.selection))return o(),!0;const l=Gb(s.doc,t)||n.state.selection,a=n.state.selection.eq(l);return i&&(a||s.setSelection(l),a&&s.storedMarks&&s.setStoredMarks(s.storedMarks),o()),!0},RM=(t,e)=>n=>t.every((r,s)=>e(r,{...n,index:s})),DM=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),Yb=t=>{const e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){const r=e[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?t.removeChild(r):r.nodeType===1&&Yb(r)}return t};function Do(t){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`<body>${t}</body>`,n=new window.DOMParser().parseFromString(e,"text/html").body;return Yb(n)}function Gi(t,e,n){if(t instanceof ir||t instanceof j)return t;n={slice:!0,parseOptions:{},...n};const r=typeof t=="object"&&t!==null,s=typeof t=="string";if(r)try{if(Array.isArray(t)&&t.length>0)return j.fromArray(t.map(l=>e.nodeFromJSON(l)));const o=e.nodeFromJSON(t);return n.errorOnInvalidContent&&o.check(),o}catch(i){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:i});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",i),Gi("",e,n)}if(s){if(n.errorOnInvalidContent){let o=!1,l="";const a=new Ay({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(o=!0,l=typeof c=="string"?c:c.outerHTML,null)}]}})});if(n.slice?Ei.fromSchema(a).parseSlice(Do(t),n.parseOptions):Ei.fromSchema(a).parse(Do(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const i=Ei.fromSchema(e);return n.slice?i.parseSlice(Do(t),n.parseOptions).content:i.parse(Do(t),n.parseOptions)}return Gi("",e,n)}function LM(t,e,n){const r=t.steps.length-1;if(r<e)return;const s=t.steps[r];if(!(s instanceof Ft||s instanceof kt))return;const i=t.mapping.maps[r];let o=0;i.forEach((l,a,c,u)=>{o===0&&(o=u)}),t.setSelection(te.near(t.doc.resolve(o),n))}var jM=t=>!("type"in t),PM=(t,e,n)=>({tr:r,dispatch:s,editor:i})=>{var o;if(s){n={parseOptions:i.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let l;const a=y=>{i.emit("contentError",{editor:i,error:y,disableCollaboration:()=>{"collaboration"in i.storage&&typeof i.storage.collaboration=="object"&&i.storage.collaboration&&(i.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!i.options.enableContentCheck&&i.options.emitContentError)try{Gi(e,i.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(y){a(y)}try{l=Gi(e,i.schema,{parseOptions:c,errorOnInvalidContent:(o=n.errorOnInvalidContent)!=null?o:i.options.enableContentCheck})}catch(y){return a(y),!1}let{from:u,to:d}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},f=!0,h=!0;if((jM(l)?l:[l]).forEach(y=>{y.check(),f=f?y.isText&&y.marks.length===0:!1,h=h?y.isBlock:!1}),u===d&&h){const{parent:y}=r.doc.resolve(u);y.isTextblock&&!y.type.spec.code&&!y.childCount&&(u-=1,d+=1)}let g;if(f){if(Array.isArray(e))g=e.map(y=>y.text||"").join("");else if(e instanceof j){let y="";e.forEach(b=>{b.text&&(y+=b.text)}),g=y}else typeof e=="object"&&e&&e.text?g=e.text:g=e;r.insertText(g,u,d)}else{g=l;const y=r.doc.resolve(u),b=y.node(),w=y.parentOffset===0,v=b.isText||b.isTextblock,x=b.content.size>0;w&&v&&x&&h&&(u=Math.max(0,u-1)),r.replaceWith(u,d,g)}n.updateSelection&&LM(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:u,text:g}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:u,text:g})}return!0},BM=()=>({state:t,dispatch:e})=>oC(t,e),zM=()=>({state:t,dispatch:e})=>lC(t,e),$M=()=>({state:t,dispatch:e})=>Qy(t,e),HM=()=>({state:t,dispatch:e})=>rb(t,e),FM=()=>({state:t,dispatch:e,tr:n})=>{try{const r=Fa(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},VM=()=>({state:t,dispatch:e,tr:n})=>{try{const r=Fa(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},UM=()=>({state:t,dispatch:e})=>sC(t,e),WM=()=>({state:t,dispatch:e})=>iC(t,e);function Xb(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function qM(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,s,i,o;for(let l=0;l<e.length-1;l+=1){const a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))s=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))Ji()||Xb()?o=!0:s=!0;else throw new Error(`Unrecognized modifier name: ${a}`)}return r&&(n=`Alt-${n}`),s&&(n=`Ctrl-${n}`),o&&(n=`Meta-${n}`),i&&(n=`Shift-${n}`),n}var KM=t=>({editor:e,view:n,tr:r,dispatch:s})=>{const i=qM(t).split(/-(?!$)/),o=i.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),l=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:i.includes("Alt"),ctrlKey:i.includes("Ctrl"),metaKey:i.includes("Meta"),shiftKey:i.includes("Shift"),bubbles:!0,cancelable:!0}),a=e.captureTransaction(()=>{n.someProp("handleKeyDown",c=>c(n,l))});return a==null||a.steps.forEach(c=>{const u=c.map(r.mapping);u&&s&&r.maybeStep(u)}),!0};function ur(t,e,n={}){const{from:r,to:s,empty:i}=t.selection,o=e?Le(e,t.schema):null,l=[];t.doc.nodesBetween(r,s,(d,f)=>{if(d.isText)return;const h=Math.max(r,f),p=Math.min(s,f+d.nodeSize);l.push({node:d,from:h,to:p})});const a=s-r,c=l.filter(d=>o?o.name===d.node.type.name:!0).filter(d=>Pl(d.node.attrs,n,{strict:!1}));return i?!!c.length:c.reduce((d,f)=>d+f.to-f.from,0)>=a}var JM=(t,e={})=>({state:n,dispatch:r})=>{const s=Le(t,n.schema);return ur(n,s,e)?aC(n,r):!1},GM=()=>({state:t,dispatch:e})=>lb(t,e),YM=t=>({state:e,dispatch:n})=>{const r=Le(t,e.schema);return xC(r)(e,n)},XM=()=>({state:t,dispatch:e})=>ib(t,e);function Ga(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function Hp(t,e){const n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((r,s)=>(n.includes(s)||(r[s]=t[s]),r),{})}var ZM=(t,e)=>({tr:n,state:r,dispatch:s})=>{let i=null,o=null;const l=Ga(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(i=Le(t,r.schema)),l==="mark"&&(o=Bn(t,r.schema));let a=!1;return n.selection.ranges.forEach(c=>{r.doc.nodesBetween(c.$from.pos,c.$to.pos,(u,d)=>{i&&i===u.type&&(a=!0,s&&n.setNodeMarkup(d,void 0,Hp(u.attrs,e))),o&&u.marks.length&&u.marks.forEach(f=>{o===f.type&&(a=!0,s&&n.addMark(d,d+u.nodeSize,o.create(Hp(f.attrs,e))))})})}),a},QM=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),eT=()=>({tr:t,dispatch:e})=>{if(e){const n=new dn(t.doc);t.setSelection(n)}return!0},tT=()=>({state:t,dispatch:e})=>tb(t,e),nT=()=>({state:t,dispatch:e})=>sb(t,e),rT=()=>({state:t,dispatch:e})=>fC(t,e),sT=()=>({state:t,dispatch:e})=>mC(t,e),iT=()=>({state:t,dispatch:e})=>pC(t,e);function Ju(t,e,n={},r={}){return Gi(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var oT=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:s,tr:i,dispatch:o,commands:l})=>{const{doc:a}=i;if(r.preserveWhitespace!=="full"){const c=Ju(t,s.schema,r,{errorOnInvalidContent:e??s.options.enableContentCheck});return o&&i.replaceWith(0,a.content.size,c).setMeta("preventUpdate",!n),!0}return o&&i.setMeta("preventUpdate",!n),l.insertContentAt({from:0,to:a.content.size},t,{parseOptions:r,errorOnInvalidContent:e??s.options.enableContentCheck})};function Zb(t,e){const n=Bn(e,t.schema),{from:r,to:s,empty:i}=t.selection,o=[];i?(t.storedMarks&&o.push(...t.storedMarks),o.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,s,a=>{o.push(...a.marks)});const l=o.find(a=>a.type.name===n.name);return l?{...l.attrs}:{}}function Qb(t,e){const n=new Qd(t);return e.forEach(r=>{r.steps.forEach(s=>{n.step(s)})}),n}function lT(t){for(let e=0;e<t.edgeCount;e+=1){const{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function aT(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(s,i)=>{n(s)&&r.push({node:s,pos:i})}),r}function e0(t,e){for(let n=t.depth;n>0;n-=1){const r=t.node(n);if(e(r))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:r}}}function Ya(t){return e=>e0(e.$from,t)}function G(t,e,n){return t.config[e]===void 0&&t.parent?G(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?G(t.parent,e,n):null}):t.config[e]}function wf(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=G(e,"addExtensions",n);return r?[e,...wf(r())]:e}).flat(10)}function xf(t,e){const n=Xr.fromSchema(e).serializeFragment(t),s=document.implementation.createHTMLDocument().createElement("div");return s.appendChild(n),s.innerHTML}function t0(t){return typeof t=="function"}function fe(t,e=void 0,...n){return t0(t)?e?t.bind(e)(...n):t(...n):t}function cT(t={}){return Object.keys(t).length===0&&t.constructor===Object}function Ms(t){const e=t.filter(s=>s.type==="extension"),n=t.filter(s=>s.type==="node"),r=t.filter(s=>s.type==="mark");return{baseExtensions:e,nodeExtensions:n,markExtensions:r}}function n0(t){const e=[],{nodeExtensions:n,markExtensions:r}=Ms(t),s=[...n,...r],i={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},o=n.filter(c=>c.name!=="text").map(c=>c.name),l=r.map(c=>c.name),a=[...o,...l];return t.forEach(c=>{const u={name:c.name,options:c.options,storage:c.storage,extensions:s},d=G(c,"addGlobalAttributes",u);if(!d)return;d().forEach(h=>{let p;Array.isArray(h.types)?p=h.types:h.types==="*"?p=a:h.types==="nodes"?p=o:h.types==="marks"?p=l:p=[],p.forEach(g=>{Object.entries(h.attributes).forEach(([y,b])=>{e.push({type:g,name:y,attribute:{...i,...b}})})})})}),s.forEach(c=>{const u={name:c.name,options:c.options,storage:c.storage},d=G(c,"addAttributes",u);if(!d)return;const f=d();Object.entries(f).forEach(([h,p])=>{const g={...i,...p};typeof(g==null?void 0:g.default)=="function"&&(g.default=g.default()),g!=null&&g.isRequired&&(g==null?void 0:g.default)===void 0&&delete g.default,e.push({type:c.name,name:h,attribute:g})})}),e}function uT(t){const e=[];let n="",r=!1,s=!1,i=0;const o=t.length;for(let l=0;l<o;l+=1){const a=t[l];if(a==="'"&&!s){r=!r,n+=a;continue}if(a==='"'&&!r){s=!s,n+=a;continue}if(!r&&!s){if(a==="("){i+=1,n+=a;continue}if(a===")"&&i>0){i-=1,n+=a;continue}if(a===";"&&i===0){e.push(n),n="";continue}}n+=a}return n&&e.push(n),e}function Fp(t){const e=[],n=uT(t||""),r=n.length;for(let s=0;s<r;s+=1){const i=n[s],o=i.indexOf(":");if(o===-1)continue;const l=i.slice(0,o).trim(),a=i.slice(o+1).trim();l&&a&&e.push([l,a])}return e}function le(...t){return t.filter(e=>!!e).reduce((e,n)=>{const r={...e};return Object.entries(n).forEach(([s,i])=>{if(!r[s]){r[s]=i;return}if(s==="class"){const l=i?String(i).split(" "):[],a=r[s]?r[s].split(" "):[],c=l.filter(u=>!a.includes(u));r[s]=[...a,...c].join(" ")}else if(s==="style"){const l=new Map([...Fp(r[s]),...Fp(i)]);r[s]=Array.from(l.entries()).map(([a,c])=>`${a}: ${c}`).join("; ")}else r[s]=i}),r},{})}function Ts(t,e){return e.filter(n=>n.type===t.type.name).filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(t.attrs)||{}:{[n.name]:t.attrs[n.name]}).reduce((n,r)=>le(n,r),{})}function dT(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function Vp(t,e){return"style"in t?t:{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;const s=e.reduce((i,o)=>{const l=o.attribute.parseHTML?o.attribute.parseHTML(n):dT(n.getAttribute(o.name));return l==null?i:{...i,[o.name]:l}},{});return{...r,...s}}}}function Up(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&cT(n)?!1:n!=null))}function Wp(t){var e,n;const r={};return!((e=t==null?void 0:t.attribute)!=null&&e.isRequired)&&"default"in((t==null?void 0:t.attribute)||{})&&(r.default=t.attribute.default),((n=t==null?void 0:t.attribute)==null?void 0:n.validate)!==void 0&&(r.validate=t.attribute.validate),[t.name,r]}function fT(t,e){var n;const r=n0(t),{nodeExtensions:s,markExtensions:i}=Ms(t),o=(n=s.find(c=>G(c,"topNode")))==null?void 0:n.name,l=Object.fromEntries(s.map(c=>{const u=r.filter(b=>b.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:e},f=t.reduce((b,w)=>{const v=G(w,"extendNodeSchema",d);return{...b,...v?v(c):{}}},{}),h=Up({...f,content:fe(G(c,"content",d)),marks:fe(G(c,"marks",d)),group:fe(G(c,"group",d)),inline:fe(G(c,"inline",d)),atom:fe(G(c,"atom",d)),selectable:fe(G(c,"selectable",d)),draggable:fe(G(c,"draggable",d)),code:fe(G(c,"code",d)),whitespace:fe(G(c,"whitespace",d)),linebreakReplacement:fe(G(c,"linebreakReplacement",d)),defining:fe(G(c,"defining",d)),isolating:fe(G(c,"isolating",d)),attrs:Object.fromEntries(u.map(Wp))}),p=fe(G(c,"parseHTML",d));p&&(h.parseDOM=p.map(b=>Vp(b,u)));const g=G(c,"renderHTML",d);g&&(h.toDOM=b=>g({node:b,HTMLAttributes:Ts(b,u)}));const y=G(c,"renderText",d);return y&&(h.toText=y),[c.name,h]})),a=Object.fromEntries(i.map(c=>{const u=r.filter(y=>y.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:e},f=t.reduce((y,b)=>{const w=G(b,"extendMarkSchema",d);return{...y,...w?w(c):{}}},{}),h=Up({...f,inclusive:fe(G(c,"inclusive",d)),excludes:fe(G(c,"excludes",d)),group:fe(G(c,"group",d)),spanning:fe(G(c,"spanning",d)),code:fe(G(c,"code",d)),attrs:Object.fromEntries(u.map(Wp))}),p=fe(G(c,"parseHTML",d));p&&(h.parseDOM=p.map(y=>Vp(y,u)));const g=G(c,"renderHTML",d);return g&&(h.toDOM=y=>g({mark:y,HTMLAttributes:Ts(y,u)})),[c.name,h]}));return new Ay({topNode:o,nodes:l,marks:a})}function hT(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function _i(t){return t.sort((n,r)=>{const s=G(n,"priority")||100,i=G(r,"priority")||100;return s>i?-1:s<i?1:0})}function r0(t){const e=_i(wf(t)),n=hT(e.map(r=>r.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(r=>`'${r}'`).join(", ")}]. This can lead to issues.`),e}function s0(t,e,n){const{from:r,to:s}=e,{blockSeparator:i=`
|
|
25
|
+
`);return{dom:a,text:h,slice:e}}function T0(t,e,n,r,s){let i=s.parent.type.spec.code,o,l;if(!n&&!e)return null;let a=!!e&&(r||i||!n);if(a){if(t.someProp("transformPastedText",h=>{e=h(e,i||r,t)}),i)return l=new q(j.from(t.state.schema.text(e.replace(/\r\n?/g,`
|
|
26
|
+
`))),0,0),t.someProp("transformPasted",h=>{l=h(l,t,!0)}),l;let d=t.someProp("clipboardTextParser",h=>h(e,s,r,t));if(d)l=d;else{let h=s.marks(),{schema:f}=t.state,p=Xr.fromSchema(f);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(g=>{let y=o.appendChild(document.createElement("p"));g&&y.appendChild(p.serializeNode(f.text(g,h)))})}}else t.someProp("transformPastedHTML",d=>{n=d(n,t)}),o=mM(n),yo&&gM(o);let c=o&&o.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let d=+u[3];d>0;d--){let h=o.firstChild;for(;h&&h.nodeType!=1;)h=h.nextSibling;if(!h)break;o=h}if(l||(l=(t.someProp("clipboardParser")||t.someProp("domParser")||Mi.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||u),context:s,ruleFromNode(h){return h.nodeName=="BR"&&!h.nextSibling&&h.parentNode&&!hM.test(h.parentNode.nodeName)?{ignore:!0}:null}})),u)l=yM(Ep(l,+u[1],+u[2]),u[4]);else if(l=q.maxOpen(fM(l.content,s),!0),l.openStart||l.openEnd){let d=0,h=0;for(let f=l.content.firstChild;d<l.openStart&&!f.type.spec.isolating;d++,f=f.firstChild);for(let f=l.content.lastChild;h<l.openEnd&&!f.type.spec.isolating;h++,f=f.lastChild);l=Ep(l,d,h)}return t.someProp("transformPasted",d=>{l=d(l,t,a)}),l}const hM=/^(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 fM(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let s=e.node(n).contentMatchAt(e.index(n)),i,o=[];if(t.forEach(l=>{if(!o)return;let a=s.findWrapping(l.type),c;if(!a)return o=null;if(c=o.length&&i.length&&N0(a,i,l,o[o.length-1],0))o[o.length-1]=c;else{o.length&&(o[o.length-1]=O0(o[o.length-1],i.length));let u=_0(l,a);o.push(u),s=s.matchType(u.type),i=a}}),o)return j.from(o)}return t}function _0(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,j.from(t));return t}function N0(t,e,n,r,s){if(s<t.length&&s<e.length&&t[s]==e[s]){let i=N0(t,e,n,r.lastChild,s+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(s==t.length-1?n.type:t[s+1]))return r.copy(r.content.append(j.from(_0(n,t,s+1))))}}function O0(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,O0(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(j.empty,!0);return t.copy(n.append(r))}function Wu(t,e,n,r,s,i){let o=e<0?t.firstChild:t.lastChild,l=o.content;return t.childCount>1&&(i=0),s<r-1&&(l=Wu(l,e,n,r,s+1,i)),s>=n&&(l=e<0?o.contentMatchAt(0).fillBefore(l,i<=s).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(j.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(l))}function Ep(t,e,n){return e<t.openStart&&(t=new q(Wu(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new q(Wu(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const I0={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 Tp=null;function D0(){return Tp||(Tp=document.implementation.createHTMLDocument("title"))}let Lc=null;function pM(t){let e=window.trustedTypes;return e?(Lc||(Lc=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),Lc.createHTML(t)):t}function mM(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=D0().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),s;if((s=r&&I0[r[1].toLowerCase()])&&(t=s.map(i=>"<"+i+">").join("")+t+s.map(i=>"</"+i+">").reverse().join("")),n.innerHTML=pM(t),s)for(let i=0;i<s.length;i++)n=n.querySelector(s[i])||n;return n}function gM(t){let e=t.querySelectorAll(Ue?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let r=e[n];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}function yM(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return t}let{content:s,openStart:i,openEnd:o}=t;for(let l=r.length-2;l>=0;l-=2){let a=n.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;s=j.from(a.create(r[l+1],s)),i++,o++}return new q(s,i,o)}const gt={},yt={},bM={touchstart:!0,touchmove:!0};class wM{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function xM(t){for(let e in gt){let n=gt[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{kM(t,r)&&!ch(t,r)&&(t.editable||!(r.type in yt))&&n(t,r)},bM[e]?{passive:!0}:void 0)}it&&t.dom.addEventListener("input",()=>null),Ku(t)}function On(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function vM(t){t.input.mouseDown&&t.input.mouseDown.done(),t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function Ku(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>ch(t,r))})}function ch(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function kM(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function SM(t,e){!ch(t,e)&>[e.type]&&(t.editable||!(e.type in yt))&>[e.type](t,e)}yt.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!P0(t)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Nn&&Ue&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),Ms&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",s=>s(t,Mr(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||dM(t,n)?n.preventDefault():On(t,"key")};yt.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};yt.keypress=(t,e)=>{let n=e;if(P0(t)||!n.charCode||n.ctrlKey&&!n.altKey||Lt&&n.metaKey)return;if(t.someProp("handleKeyPress",s=>s(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof ee)||!r.$from.sameParent(r.$to)){let s=String.fromCharCode(n.charCode),i=()=>t.state.tr.insertText(s).scrollIntoView();!/[\r\n]/.test(s)&&!t.someProp("handleTextInput",o=>o(t,r.$from.pos,r.$to.pos,s,i))&&t.dispatch(i()),n.preventDefault()}};function wo(t){return{left:t.clientX,top:t.clientY}}function CM(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function uh(t,e,n,r,s){if(r==-1)return!1;let i=t.state.doc.resolve(r);for(let o=i.depth+1;o>0;o--)if(t.someProp(e,l=>o>i.depth?l(t,n,i.nodeAfter,i.before(o),s,!0):l(t,n,i.node(o),i.before(o),s,!1)))return!0;return!1}function xo(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);r.setMeta("pointer",!0),t.dispatch(r)}function MM(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&Y.isSelectable(r)?(xo(t,new Y(n)),!0):!1}function AM(t,e){if(e==-1)return!1;let n=t.state.selection,r,s;n instanceof Y&&(r=n.node);let i=t.state.doc.resolve(e);for(let o=i.depth+1;o>0;o--){let l=o>i.depth?i.nodeAfter:i.node(o);if(Y.isSelectable(l)){r&&n.$from.depth>0&&o>=n.$from.depth&&i.before(n.$from.depth+1)==n.$from.pos?s=i.before(n.$from.depth):s=i.before(o);break}}return s!=null?(xo(t,Y.create(t.state.doc,s)),!0):!1}function EM(t,e,n,r,s){return uh(t,"handleClickOn",e,n,r)||t.someProp("handleClick",i=>i(t,e,r))||(s?AM(t,n):MM(t,n))}function TM(t,e,n,r){return uh(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",s=>s(t,e,r))}function _M(t,e,n,r){return uh(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",s=>s(t,e,r))||NM(t,n,r)}function NM(t,e,n){if(n.button!=0)return!1;let r=R0(t,e,!0),s=t.state.doc;return r?(xo(t,r),r instanceof ee&&s.eq(t.state.doc)&&(t.input.mouseDown=new IM(t,r)),!0):!1}function R0(t,e,n){let r=t.state.doc;if(e==-1)return r.inlineContent?ee.create(r,0,r.content.size):null;let s=r.resolve(e);for(let i=s.depth+1;i>0;i--){let o=i>s.depth?s.nodeAfter:s.node(i),l=s.before(i);if(o.inlineContent)return ee.create(r,l+1,l+1+o.content.size);if(n&&Y.isSelectable(o))return Y.create(r,l)}return null}function dh(t){return Dl(t)}const L0=Lt?"metaKey":"ctrlKey";gt.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=dh(t),s=Date.now(),i="singleClick";s-t.input.lastClick.time<500&&CM(n,t.input.lastClick)&&!n[L0]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?i="doubleClick":t.input.lastClick.type=="doubleClick"&&(i="tripleClick")),t.input.lastClick={time:s,x:n.clientX,y:n.clientY,type:i,button:n.button},t.input.mouseDown&&t.input.mouseDown.done();let o=t.posAtCoords(wo(n));o&&(i=="singleClick"?t.input.mouseDown=new OM(t,o,n,!!r):(i=="doubleClick"?TM:_M)(t,o.pos,o.inside,n)?n.preventDefault():On(t,"pointer"))};class j0{constructor(e){this.view=e,this.mightDrag=null,e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this))}up(e){this.done()}move(e){e.buttons==0&&this.done()}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null)}delaySelUpdate(){return!1}}class OM extends j0{constructor(e,n,r,s){super(e),this.pos=n,this.event=r,this.flushed=s,this.delayedSelectionSync=!1,this.startDoc=e.state.doc,this.selectNode=!!r[L0],this.allowDefault=r.shiftKey;let i,o;if(n.inside>-1)i=e.state.doc.nodeAt(n.inside),o=n.inside;else{let u=e.state.doc.resolve(n.pos);i=u.parent,o=u.depth?u.before():0}const l=s?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.nodeDOM.nodeType==1?a.nodeDOM:null;let{selection:c}=e.state;r.button==0&&(i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof Y&&c.from<=o&&c.to>o)&&(this.mightDrag={node:i,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Bt&&!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()),On(e,"pointer")}done(){super.done(),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(()=>{this.view.isDestroyed||Rn(this.view)})}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(wo(e))),this.updateAllowDefault(e),this.allowDefault||!n?On(this.view,"pointer"):EM(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||it&&this.mightDrag&&!this.mightDrag.node.isAtom||Ue&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(xo(this.view,te.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):On(this.view,"pointer")}move(e){this.updateAllowDefault(e),On(this.view,"pointer"),super.move(e)}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}delaySelUpdate(){return this.allowDefault?(this.delayedSelectionSync=!0,!0):!1}}class IM extends j0{constructor(e,n){super(e),this.startSelection=n,this.startDoc=e.state.doc}move(e){if(e.buttons==0||this.view.isDestroyed||!this.view.state.doc.eq(this.startDoc)){this.done();return}e.preventDefault(),On(this.view,"pointer");let n=this.view.posAtCoords(wo(e)),r=n&&R0(this.view,n.inside,!1);if(!r)return;let{doc:s}=this.view.state,i=this.startSelection,[o,l]=r.from<i.from?[i.to,r.from]:[i.from,r.to];xo(this.view,ee.create(s,o,l))}}gt.touchstart=t=>{t.input.lastTouch=Date.now(),dh(t),On(t,"pointer")};gt.touchmove=t=>{t.input.lastTouch=Date.now(),On(t,"pointer")};gt.contextmenu=t=>dh(t);function P0(t,e){return t.composing?!0:it&&Math.abs(Date.now()-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const DM=Nn?5e3:-1;yt.compositionstart=yt.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof ee&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||Ue&&h0&&RM(t)))t.markCursor=t.state.storedMarks||n.marks(),Dl(t,!0),t.markCursor=null;else if(Dl(t,!e.selection.empty),Bt&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let s=r.focusNode,i=r.focusOffset;s&&s.nodeType==1&&i!=0;){let o=i<0?s.lastChild:s.childNodes[i-1];if(!o)break;if(o.nodeType==3){let l=t.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else s=o,i=-1}}t.input.composing=!0}B0(t,DM)};function RM(t){let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(!e||e.nodeType!=1||n>=e.childNodes.length)return!1;let r=e.childNodes[n];return r.nodeType==1&&r.contentEditable=="false"}yt.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Date.now(),t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.badSafariComposition?t.domObserver.forceFlush():t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,B0(t,20))};function B0(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>Dl(t),e))}function H0(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Date.now());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function LM(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=AC(e.focusNode,e.focusOffset),r=EC(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let s=r.pmViewDesc,i=t.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!s||!s.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let o=n.pmViewDesc;if(!(!o||!o.isText(n.nodeValue)))return r}}return n||r}function Dl(t,e=!1){if(!(Nn&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),H0(t),e||t.docView&&t.docView.dirty){let n=oh(t),r=t.state.selection;return n&&!n.eq(r)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function jM(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),s=document.createRange();s.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(s),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const Wi=vt&&or<15||Ms&&OC<604;gt.copy=yt.cut=(t,e)=>{let n=e,r=t.state.selection,s=n.type=="cut";if(r.empty)return;let i=Wi?null:n.clipboardData,o=r.content(),{dom:l,text:a}=ah(t,o);i?(n.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):jM(t,l),s&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function PM(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function BM(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let s=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?Ki(t,r.value,null,s,e):Ki(t,r.textContent,r.innerHTML,s,e)},50)}function Ki(t,e,n,r,s){let i=T0(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",a=>a(t,s,i||q.empty)))return!0;if(!i)return!1;let o=PM(i),l=o?t.state.tr.replaceSelectionWith(o,r):t.state.tr.replaceSelection(i);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function z0(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}yt.paste=(t,e)=>{let n=e;if(t.composing&&!Nn)return;let r=Wi?null:n.clipboardData,s=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&Ki(t,z0(r),r.getData("text/html"),s,n)?n.preventDefault():BM(t,n)};class $0{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const HM=Lt?"altKey":"ctrlKey";function V0(t,e){let n;return t.someProp("dragCopies",r=>{n=n||r(e)}),n!=null?!n:!e[HM]}gt.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let s=t.state.selection,i=s.empty?null:t.posAtCoords(wo(n)),o;if(!(i&&i.pos>=s.from&&i.pos<=(s instanceof Y?s.to-1:s.to))){if(r&&r.mightDrag)o=Y.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let d=t.docView.nearestDesc(n.target,!0);d&&d.node.type.spec.draggable&&d!=t.docView&&(o=Y.create(t.state.doc,d.posBefore))}}let l=(o||t.state.selection).content(),{dom:a,text:c,slice:u}=ah(t,l);(!n.dataTransfer.files.length||!Ue||d0>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Wi?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",Wi||n.dataTransfer.setData("text/plain",c),t.dragging=new $0(u,V0(t,n),o)};gt.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};yt.dragover=yt.dragenter=(t,e)=>e.preventDefault();yt.drop=(t,e)=>{try{zM(t,e,t.dragging)}finally{t.dragging=null}};function zM(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(wo(e));if(!r)return;let s=t.state.doc.resolve(r.pos),i=n&&n.slice;i?t.someProp("transformPasted",f=>{i=f(i,t,!1)}):i=T0(t,z0(e.dataTransfer),Wi?null:e.dataTransfer.getData("text/html"),!1,s);let o=!!(n&&V0(t,e));if(t.someProp("handleDrop",f=>f(t,e,i||q.empty,o))){e.preventDefault();return}if(!i)return;e.preventDefault();let l=i?H1(t.state.doc,s.pos,i):s.pos;l==null&&(l=s.pos);let a=t.state.tr;if(o){let{node:f}=n;f?f.replace(a):a.deleteSelection()}let c=a.mapping.map(l),u=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,d=a.doc;if(u?a.replaceRangeWith(c,c,i.content.firstChild):a.replaceRange(c,c,i),a.doc.eq(d))return;let h=a.doc.resolve(c);if(u&&Y.isSelectable(i.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(i.content.firstChild))a.setSelection(new Y(h));else{let f=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((p,g,y,b)=>f=b),a.setSelection(lh(t,h,a.doc.resolve(f)))}t.focus(),t.dispatch(a.setMeta("uiEvent","drop"))}gt.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&Rn(t)},20))};gt.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};gt.beforeinput=(t,e)=>{if(Ue&&Nn&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",i=>i(t,Mr(8,"Backspace")))))return;let{$cursor:s}=t.state.selection;s&&s.pos>0&&t.dispatch(t.state.tr.delete(s.pos-1,s.pos).scrollIntoView())},50)}};for(let t in yt)gt[t]=yt[t];function qi(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}class Rl{constructor(e,n){this.toDOM=e,this.spec=n||Rr,this.side=this.spec.side||0}map(e,n,r,s){let{pos:i,deleted:o}=e.mapResult(n.from+s,this.side<0?-1:1);return o?null:new Re(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Rl&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&qi(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class ar{constructor(e,n){this.attrs=e,this.spec=n||Rr}map(e,n,r,s){let i=e.map(n.from+s,this.spec.inclusiveStart?-1:1)-r,o=e.map(n.to+s,this.spec.inclusiveEnd?1:-1)-r;return i>=o?null:new Re(i,o,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof ar&&qi(this.attrs,e.attrs)&&qi(this.spec,e.spec)}static is(e){return e.type instanceof ar}destroy(){}}class hh{constructor(e,n){this.attrs=e,this.spec=n||Rr}map(e,n,r,s){let i=e.mapResult(n.from+s,1);if(i.deleted)return null;let o=e.mapResult(n.to+s,-1);return o.deleted||o.pos<=i.pos?null:new Re(i.pos-r,o.pos-r,this)}valid(e,n){let{index:r,offset:s}=e.content.findIndex(n.from),i;return s==n.from&&!(i=e.child(r)).isText&&s+i.nodeSize==n.to}eq(e){return this==e||e instanceof hh&&qi(this.attrs,e.attrs)&&qi(this.spec,e.spec)}destroy(){}}class Re{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new Re(e,n,this.type)}eq(e,n=0){return this.type.eq(e.type)&&this.from+n==e.from&&this.to+n==e.to}map(e,n,r){return this.type.map(e,this,n,r)}static widget(e,n,r){return new Re(e,e,new Rl(n,r))}static inline(e,n,r,s){return new Re(e,n,new ar(r,s))}static node(e,n,r,s){return new Re(e,n,new hh(r,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof ar}get widget(){return this.type instanceof Rl}}const cs=[],Rr={};class fe{constructor(e,n){this.local=e.length?e:cs,this.children=n.length?n:cs}static create(e,n){return n.length?Ll(n,e,0,Rr):nt}find(e,n,r){let s=[];return this.findInner(e??0,n??1e9,s,0,r),s}findInner(e,n,r,s,i){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=n&&l.to>=e&&(!i||i(l.spec))&&r.push(l.copy(l.from+s,l.to+s))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<n&&this.children[o+1]>e){let l=this.children[o]+1;this.children[o+2].findInner(e-l,n-l,r,s+l,i)}}map(e,n,r){return this==nt||e.maps.length==0?this:this.mapInner(e,n,0,0,r||Rr)}mapInner(e,n,r,s,i){let o;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,s);a&&a.type.valid(n,a)?(o||(o=[])).push(a):i.onRemove&&i.onRemove(this.local[l].spec)}return this.children.length?$M(this.children,o||[],e,n,r,s,i):o?new fe(o.sort(Lr),cs):nt}add(e,n){return n.length?this==nt?fe.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let s,i=0;e.forEach((l,a)=>{let c=a+r,u;if(u=U0(n,l,c)){for(s||(s=this.children.slice());i<s.length&&s[i]<a;)i+=3;s[i]==a?s[i+2]=s[i+2].addInner(l,u,c+1):s.splice(i,0,a,a+l.nodeSize,Ll(u,l,c+1,Rr)),i+=3}});let o=F0(i?W0(n):n,-r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new fe(o.length?this.local.concat(o).sort(Lr):this.local,s||this.children)}remove(e){return e.length==0||this==nt?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,s=this.local;for(let i=0;i<r.length;i+=3){let o,l=r[i]+n,a=r[i+1]+n;for(let u=0,d;u<e.length;u++)(d=e[u])&&d.from>l&&d.to<a&&(e[u]=null,(o||(o=[])).push(d));if(!o)continue;r==this.children&&(r=this.children.slice());let c=r[i+2].removeInner(o,l+1);c!=nt?r[i+2]=c:(r.splice(i,3),i-=3)}if(s.length){for(let i=0,o;i<e.length;i++)if(o=e[i])for(let l=0;l<s.length;l++)s[l].eq(o,n)&&(s==this.local&&(s=this.local.slice()),s.splice(l--,1))}return r==this.children&&s==this.local?this:s.length||r.length?new fe(s,r):nt}forChild(e,n){if(this==nt)return this;if(n.isLeaf)return fe.empty;let r,s;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let i=e+1,o=i+n.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<o&&a.to>i&&a.type instanceof ar){let c=Math.max(i,a.from)-i,u=Math.min(o,a.to)-i;c<u&&(s||(s=[])).push(a.copy(c,u))}}if(s){let l=new fe(s.sort(Lr),cs);return r?new nr([l,r]):l}return r||nt}eq(e){if(this==e)return!0;if(!(e instanceof fe)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(e.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=e.children[n]||this.children[n+1]!=e.children[n+1]||!this.children[n+2].eq(e.children[n+2]))return!1;return!0}locals(e){return fh(this.localsInner(e))}localsInner(e){if(this==nt)return cs;if(e.inlineContent||!this.local.some(ar.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof ar||n.push(this.local[r]);return n}forEachSet(e){e(this)}}fe.empty=new fe([],[]);fe.removeOverlap=fh;const nt=fe.empty;class nr{constructor(e){this.members=e}map(e,n){const r=this.members.map(s=>s.map(e,n,Rr));return nr.from(r)}forChild(e,n){if(n.isLeaf)return fe.empty;let r=[];for(let s=0;s<this.members.length;s++){let i=this.members[s].forChild(e,n);i!=nt&&(i instanceof nr?r=r.concat(i.members):r.push(i))}return nr.from(r)}eq(e){if(!(e instanceof nr)||e.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(e.members[n]))return!1;return!0}locals(e){let n,r=!0;for(let s=0;s<this.members.length;s++){let i=this.members[s].localsInner(e);if(i.length)if(!n)n=i;else{r&&(n=n.slice(),r=!1);for(let o=0;o<i.length;o++)n.push(i[o])}}return n?fh(r?n:n.sort(Lr)):cs}static from(e){switch(e.length){case 0:return nt;case 1:return e[0];default:return new nr(e.every(n=>n instanceof fe)?e:e.reduce((n,r)=>n.concat(r instanceof fe?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function $M(t,e,n,r,s,i,o){let l=t.slice();for(let c=0,u=i;c<n.maps.length;c++){let d=0;n.maps[c].forEach((h,f,p,g)=>{let y=g-p-(f-h);for(let b=0;b<l.length;b+=3){let w=l[b+1];if(w<0||h>w+u-d)continue;let v=l[b]+u-d;f>=v?l[b+1]=h<=v?-2:-1:h>=u&&y&&(l[b]+=y,l[b+1]+=y)}d+=y}),u=n.maps[c].map(u,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let u=n.map(t[c]+i),d=u-s;if(d<0||d>=r.content.size){a=!0;continue}let h=n.map(t[c+1]+i,-1),f=h-s,{index:p,offset:g}=r.content.findIndex(d),y=r.maybeChild(p);if(y&&g==d&&g+y.nodeSize==f){let b=l[c+2].mapInner(n,y,u+1,t[c]+i+1,o);b!=nt?(l[c]=d,l[c+1]=f,l[c+2]=b):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=VM(l,t,e,n,s,i,o),u=Ll(c,r,0,o);e=u.local;for(let d=0;d<l.length;d+=3)l[d+1]<0&&(l.splice(d,3),d-=3);for(let d=0,h=0;d<u.children.length;d+=3){let f=u.children[d];for(;h<l.length&&l[h]<f;)h+=3;l.splice(h,0,u.children[d],u.children[d+1],u.children[d+2])}}return new fe(e.sort(Lr),l)}function F0(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let s=t[r];n.push(new Re(s.from+e,s.to+e,s.type))}return n}function VM(t,e,n,r,s,i,o){function l(a,c){for(let u=0;u<a.local.length;u++){let d=a.local[u].map(r,s,c);d?n.push(d):o.onRemove&&o.onRemove(a.local[u].spec)}for(let u=0;u<a.children.length;u+=3)l(a.children[u+2],a.children[u]+c+1)}for(let a=0;a<t.length;a+=3)t[a+1]==-1&&l(t[a+2],e[a]+i+1);return n}function U0(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,s=null;for(let i=0,o;i<t.length;i++)(o=t[i])&&o.from>n&&o.to<r&&((s||(s=[])).push(o),t[i]=null);return s}function W0(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function Ll(t,e,n,r){let s=[],i=!1;e.forEach((l,a)=>{let c=U0(t,l,a+n);if(c){i=!0;let u=Ll(c,l,n+a+1,r);u!=nt&&s.push(a,a+l.nodeSize,u)}});let o=F0(i?W0(t):t,-n).sort(Lr);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||(r.onRemove&&r.onRemove(o[l].spec),o.splice(l--,1));return o.length||s.length?new fe(o,s):nt}function Lr(t,e){return t.from-e.from||t.to-e.to}function fh(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let s=n+1;s<e.length;s++){let i=e[s];if(i.from==r.from){i.to!=r.to&&(e==t&&(e=t.slice()),e[s]=i.copy(i.from,r.to),_p(e,s+1,i.copy(r.to,i.to)));continue}else{i.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,i.from),_p(e,s,r.copy(i.from,r.to)));break}}}return e}function _p(t,e,n){for(;e<t.length&&Lr(n,t[e])>0;)e++;t.splice(e,0,n)}function jc(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=nt&&e.push(r)}),t.cursorWrapper&&e.push(fe.create(t.state.doc,[t.cursorWrapper.deco])),nr.from(e)}const FM={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},UM=vt&&or<=11;class WM{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 KM{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new WM,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let s=0;s<r.length;s++)this.queue.push(r[s]);vt&&or<=11&&r.some(s=>s.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():it&&e.composing&&r.some(s=>s.type=="childList"&&s.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),UM&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,FM)),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 n=0;n<e.length;n++)this.queue.push(e[n]);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(vp(this.view)){if(this.suppressingSelectionUpdates)return Rn(this.view);if(vt&&or<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&zr(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 n=new Set,r;for(let i=e.focusNode;i;i=Cs(i))n.add(i);for(let i=e.anchorNode;i;i=Cs(i))if(n.has(i)){r=i;break}let s=r&&this.view.docView.nearestDesc(r);if(s&&s.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),s=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&vp(e)&&!this.ignoreSelectionChange(r),i=-1,o=-1,l=!1,a=[];if(e.editable)for(let u=0;u<n.length;u++){let d=this.registerMutation(n[u],a);d&&(i=i<0?d.from:Math.min(d.from,i),o=o<0?d.to:Math.max(d.to,o),d.typeOver&&(l=!0))}if(a.some(u=>u.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46||Ue&&(e.composing||e.input.compositionEndedAt>Date.now()-50)&&n.some(u=>u.type=="childList"&&u.removedNodes.length))){for(let u of a)if(u.nodeName=="BR"&&u.parentNode){let d=u.nextSibling;for(;d&&d.nodeType==1;){if(d.contentEditable=="false"){u.parentNode.removeChild(u);break}d=d.firstChild}}}else if(Bt&&a.length){let u=a.filter(d=>d.nodeName=="BR");if(u.length==2){let[d,h]=u;d.parentNode&&d.parentNode.parentNode==h.parentNode?h.remove():d.remove()}else{let{focusNode:d}=this.currentSelection;for(let h of u){let f=h.parentNode;f&&f.nodeName=="LI"&&(!d||GM(e,d)!=f)&&h.remove()}}}let c=null;i<0&&s&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Ua(r)&&(c=oh(e))&&c.eq(te.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Rn(e),this.currentSelection.set(r),e.scrollToSelection()):(i>-1||s)&&(i>-1&&(e.docView.markDirty(i,o),qM(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,YM(e,a)),this.handleDOMChange(i,o,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Rn(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let u=0;u<e.addedNodes.length;u++){let d=e.addedNodes[u];n.push(d),d.nodeType==3&&(this.lastChangedTextNode=d)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let s=e.previousSibling,i=e.nextSibling;if(vt&&or<=11&&e.addedNodes.length)for(let u=0;u<e.addedNodes.length;u++){let{previousSibling:d,nextSibling:h}=e.addedNodes[u];(!d||Array.prototype.indexOf.call(e.addedNodes,d)<0)&&(s=d),(!h||Array.prototype.indexOf.call(e.addedNodes,h)<0)&&(i=h)}let o=s&&s.parentNode==e.target?Ze(s)+1:0,l=r.localPosFromDOM(e.target,o,-1),a=i&&i.parentNode==e.target?Ze(i):e.target.childNodes.length,c=r.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let Np=new WeakMap,Op=!1;function qM(t){if(!Np.has(t)&&(Np.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=Bt,Op)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."),Op=!0}}function Ip(t,e){let n=e.startContainer,r=e.startOffset,s=e.endContainer,i=e.endOffset,o=t.domAtPos(t.state.selection.anchor);return zr(o.node,o.offset,s,i)&&([n,r,s,i]=[s,i,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:i}}function JM(t,e){if(e.getComposedRanges){let s=e.getComposedRanges(t.root)[0];if(s)return Ip(t,s)}let n;function r(s){s.preventDefault(),s.stopImmediatePropagation(),n=s.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",r,!0),n?Ip(t,n):null}function GM(t,e){for(let n=e.parentNode;n&&n!=t.dom;n=n.parentNode){let r=t.docView.nearestDesc(n,!0);if(r&&r.node.isBlock)return n}return null}function YM(t,e){var n;let{focusNode:r,focusOffset:s}=t.domSelectionRange();for(let i of e)if(((n=i.parentNode)===null||n===void 0?void 0:n.nodeName)=="TR"){let o=i.nextSibling;for(;o&&o.nodeName!="TD"&&o.nodeName!="TH";)o=o.nextSibling;if(o){let l=o;for(;;){let a=l.firstChild;if(!a||a.nodeType!=1||a.contentEditable=="false"||/^(BR|IMG)$/.test(a.nodeName))break;l=a}l.insertBefore(i,l.firstChild),r==i&&t.domSelection().collapse(i,s)}else i.parentNode.removeChild(i)}}function XM(t,e,n){let{node:r,fromOffset:s,toOffset:i,from:o,to:l}=t.docView.parseRange(e,n),a=t.domSelectionRange(),c,u=a.anchorNode;if(u&&t.dom.contains(u.nodeType==1?u:u.parentNode)&&(c=[{node:u,offset:a.anchorOffset}],Ua(a)||c.push({node:a.focusNode,offset:a.focusOffset})),Ue&&t.input.lastKeyCode===8)for(let y=i;y>s;y--){let b=r.childNodes[y-1],w=b.pmViewDesc;if(b.nodeName=="BR"&&!w){i=y;break}if(!w||w.size)break}let d=t.state.doc,h=t.someProp("domParser")||Mi.fromSchema(t.state.schema),f=d.resolve(o),p=null,g=h.parse(r,{topNode:f.parent,topMatch:f.parent.contentMatchAt(f.index()),topOpen:!0,from:s,to:i,preserveWhitespace:f.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:ZM,context:f});if(c&&c[0].pos!=null){let y=c[0].pos,b=c[1]&&c[1].pos;b==null&&(b=y),p={anchor:y+o,head:b+o}}return{doc:g,sel:p,from:o,to:l}}function ZM(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(it&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}else if(t.parentNode.lastChild==t||it&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}const QM=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function eA(t,e,n,r,s){let i=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let M=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,O=oh(t,M);if(O&&!t.state.selection.eq(O)){if(Ue&&Nn&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",A=>A(t,Mr(13,"Enter"))))return;let _=t.state.tr.setSelection(O);M=="pointer"?_.setMeta("pointer",!0):M=="key"&&_.scrollIntoView(),i&&_.setMeta("composition",i),t.dispatch(_)}return}let o=t.state.doc.resolve(e),l=o.sharedDepth(n);e=o.before(l+1),n=t.state.doc.resolve(n).after(l+1);let a=t.state.selection,c=XM(t,e,n),u=t.state.doc,d=u.slice(c.from,c.to),h,f;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(h=t.state.selection.to,f="end"):(h=t.state.selection.from,f="start"),t.input.lastKeyCode=null;let p=rA(d.content,c.doc.content,c.from,h,f);if(p&&t.input.domChangeCount++,(Ms&&t.input.lastIOSEnter>Date.now()-225||Nn)&&s.some(M=>M.nodeType==1&&!QM.test(M.nodeName))&&(!p||p.endA>=p.endB)&&t.someProp("handleKeyDown",M=>M(t,Mr(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!p)if(r&&a instanceof ee&&!a.empty&&a.$head.sameParent(a.$anchor)&&!t.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let M=Dp(t,t.state.doc,c.sel);if(M&&!M.eq(t.state.selection)){let O=t.state.tr.setSelection(M);i&&O.setMeta("composition",i),t.dispatch(O)}}return}t.state.selection.from<t.state.selection.to&&p.start==p.endB&&t.state.selection instanceof ee&&(p.start>t.state.selection.from&&p.start<=t.state.selection.from+2&&t.state.selection.from>=c.from?p.start=t.state.selection.from:p.endA<t.state.selection.to&&p.endA>=t.state.selection.to-2&&t.state.selection.to<=c.to&&(p.endB+=t.state.selection.to-p.endA,p.endA=t.state.selection.to)),vt&&or<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)==" "&&(p.start--,p.endA--,p.endB--);let g=c.doc.resolveNoCache(p.start-c.from),y=c.doc.resolveNoCache(p.endB-c.from),b=u.resolve(p.start),w=g.sameParent(y)&&g.parent.inlineContent&&b.end()>=p.endA;if((Ms&&t.input.lastIOSEnter>Date.now()-225&&(!w||s.some(M=>M.nodeName=="DIV"||M.nodeName=="P"))||!w&&g.pos<c.doc.content.size&&(!g.sameParent(y)||!g.parent.inlineContent)&&g.pos<y.pos&&!/\S/.test(c.doc.textBetween(g.pos,y.pos,"","")))&&t.someProp("handleKeyDown",M=>M(t,Mr(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>p.start&&nA(u,p.start,p.endA,g,y)&&t.someProp("handleKeyDown",M=>M(t,Mr(8,"Backspace")))){Nn&&Ue&&t.domObserver.suppressSelectionUpdates();return}Ue&&p.endB==p.start&&(t.input.lastChromeDelete=Date.now()),Nn&&!w&&g.start()!=y.start()&&y.parentOffset==0&&g.depth==y.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,y=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{t.someProp("handleKeyDown",function(M){return M(t,Mr(13,"Enter"))})},20));let v=p.start,x=p.endA,k=M=>{let O=M||t.state.tr.replace(v,x,c.doc.slice(p.start-c.from,p.endB-c.from));if(c.sel){let _=Dp(t,O.doc,c.sel);_&&!(Ue&&t.composing&&_.empty&&(p.start!=p.endB||t.input.lastChromeDelete<Date.now()-100)&&(_.head==v||_.head==O.mapping.map(x)-1)||vt&&_.empty&&_.head==v)&&O.setSelection(_)}return i&&O.setMeta("composition",i),O.scrollIntoView()},C;if(w)if(g.pos==y.pos){vt&&or<=11&&g.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>Rn(t),20));let M=k(t.state.tr.delete(v,x)),O=u.resolve(p.start).marksAcross(u.resolve(p.endA));O&&M.ensureMarks(O),t.dispatch(M)}else if(p.endA==p.endB&&(C=tA(g.parent.content.cut(g.parentOffset,y.parentOffset),b.parent.content.cut(b.parentOffset,p.endA-b.start())))){let M=k(t.state.tr);C.type=="add"?M.addMark(v,x,C.mark):M.removeMark(v,x,C.mark),t.dispatch(M)}else if(g.parent.child(g.index()).isText&&g.index()==y.index()-(y.textOffset?0:1)){let M=g.parent.textBetween(g.parentOffset,y.parentOffset),O=()=>k(t.state.tr.insertText(M,v,x));t.someProp("handleTextInput",_=>_(t,v,x,M,O))||t.dispatch(O())}else t.dispatch(k());else t.dispatch(k())}function Dp(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:lh(t,e.resolve(n.anchor),e.resolve(n.head))}function tA(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,s=n,i=r,o,l,a;for(let u=0;u<r.length;u++)s=r[u].removeFromSet(s);for(let u=0;u<n.length;u++)i=n[u].removeFromSet(i);if(s.length==1&&i.length==0)l=s[0],o="add",a=u=>u.mark(l.addToSet(u.marks));else if(s.length==0&&i.length==1)l=i[0],o="remove",a=u=>u.mark(l.removeFromSet(u.marks));else return null;let c=[];for(let u=0;u<e.childCount;u++)c.push(a(e.child(u)));if(j.from(c).eq(t))return{mark:l,type:o}}function nA(t,e,n,r,s){if(n-e<=s.pos-r.pos||Pc(r,!0,!1)<s.pos)return!1;let i=t.resolve(e);if(!r.parent.isTextblock){let l=i.nodeAfter;return l!=null&&n==e+l.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let o=t.resolve(Pc(i,!0,!0));return!o.parent.isTextblock||o.pos>n||Pc(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function Pc(t,e,n){let r=t.depth,s=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,s++,e=!1;if(n){let i=t.node(r).maybeChild(t.indexAfter(r));for(;i&&!i.isLeaf;)i=i.firstChild,s++}return s}function rA(t,e,n,r,s){let i=t.findDiffStart(e,n),o=n+t.size,l=n+e.size;if(i==null)return null;let{a,b:c}=t.findDiffEnd(e,o,l);if(s=="end"){let u=Math.max(0,i-Math.min(a,c));r-=a+u-i}if(a<i&&o<l){let u=r<=i&&r>=a?i-r:0;i-=u,c=i+(c-a),a=i}else if(c<i){let u=r<=i&&r>=c?i-r:0;i-=u,a=i+(a-c),c=i}return{start:i,endA:a,endB:c}}class K0{constructor(e,n){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 wM,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(Bp),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=jp(this),Lp(this),this.nodeViews=Pp(this),this.docView=mp(this.state.doc,Rp(this),jc(this),this.dom,this),this.domObserver=new KM(this,(r,s,i,o)=>eA(this,r,s,i,o)),this.domObserver.start(),xM(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 n in e)this._props[n]=e[n];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Ku(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Bp),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let s=this.state,i=!1,o=!1;e.storedMarks&&this.composing&&(H0(this),o=!0),this.state=e;let l=s.plugins!=e.plugins||this._props.plugins!=n.plugins;if(l||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let f=Pp(this);iA(f,this.nodeViews)&&(this.nodeViews=f,i=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&Ku(this),this.editable=jp(this),Lp(this);let a=jc(this),c=Rp(this),u=s.plugins!=e.plugins&&!s.doc.eq(e.doc)?"reset":e.scrollToSelection>s.scrollToSelection?"to selection":"preserve",d=i||!this.docView.matchesNode(e.doc,c,a);(d||!e.selection.eq(s.selection))&&(o=!0);let h=u=="preserve"&&o&&this.dom.style.overflowAnchor==null&&RC(this);if(o){this.domObserver.stop();let f=d&&(vt||Ue)&&!this.composing&&!s.selection.empty&&!e.selection.empty&&sA(s.selection,e.selection);if(d){let g=Ue?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=LM(this)),(i||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=mp(e.doc,c,a,this.dom,this)),g&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(f=!0)}let p=this.input.mouseDown;f||!(p&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&sM(this)&&p.delaySelUpdate())?Rn(this,f):(M0(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(s),!((r=this.dragging)===null||r===void 0)&&r.node&&!s.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,s),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():h&&LC(h)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof Y){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&cp(this,n.getBoundingClientRect(),e)}else cp(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n<this.directPlugins.length;n++){let r=this.directPlugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let n=0;n<this.state.plugins.length;n++){let r=this.state.plugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let n=0;n<this.pluginViews.length;n++){let r=this.pluginViews[n];r.update&&r.update(this,e)}}updateDraggedNode(e,n){let r=e.node,s=-1;if(r.from<this.state.doc.content.size&&this.state.doc.nodeAt(r.from)==r.node)s=r.from;else{let i=r.from+(this.state.doc.content.size-n.doc.content.size);(i>0&&i<this.state.doc.content.size&&this.state.doc.nodeAt(i))==r.node&&(s=i)}this.dragging=new $0(e.slice,e.move,s<0?void 0:Y.create(this.state.doc,s))}someProp(e,n){let r=this._props&&this._props[e],s;if(r!=null&&(s=n?n(r):r))return s;for(let o=0;o<this.directPlugins.length;o++){let l=this.directPlugins[o].props[e];if(l!=null&&(s=n?n(l):l))return s}let i=this.state.plugins;if(i)for(let o=0;o<i.length;o++){let l=i[o].props[e];if(l!=null&&(s=n?n(l):l))return s}}hasFocus(){if(vt){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&jC(this.dom),Rn(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let n=this.dom.parentNode;n;n=n.parentNode)if(n.nodeType==9||n.nodeType==11&&n.host)return n.getSelection||(Object.getPrototypeOf(n).getSelection=()=>n.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return $C(this,e)}coordsAtPos(e,n=1){return y0(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,r=-1){let s=this.docView.posFromDOM(e,n,r);if(s==null)throw new RangeError("DOM position not inside the editor");return s}endOfTextblock(e,n){return KC(this,n||this.state,e)}pasteHTML(e,n){return Ki(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return Ki(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return ah(this,e)}destroy(){this.docView&&(vM(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],jc(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,CC())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return SM(this,e)}domSelectionRange(){let e=this.domSelection();return e?it&&this.root.nodeType===11&&_C(this.dom.ownerDocument)==this.dom&&JM(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}K0.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function Rp(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(t.state)),n)for(let r in n)r=="class"?e.class+=" "+n[r]:r=="style"?e.style=(e.style?e.style+";":"")+n[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(n[r]))}),e.translate||(e.translate="no"),[Re.node(0,t.state.doc.content.size,e)]}function Lp(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:Re.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function jp(t){return!t.someProp("editable",e=>e(t.state)===!1)}function sA(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}function Pp(t){let e=Object.create(null);function n(r){for(let s in r)Object.prototype.hasOwnProperty.call(e,s)||(e[s]=r[s])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function iA(t,e){let n=0,r=0;for(let s in t){if(t[s]!=e[s])return!0;n++}for(let s in e)r++;return n!=r}function Bp(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var cr={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:"'"},jl={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},oA=typeof navigator<"u"&&/Mac/.test(navigator.platform),lA=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Qe=0;Qe<10;Qe++)cr[48+Qe]=cr[96+Qe]=String(Qe);for(var Qe=1;Qe<=24;Qe++)cr[Qe+111]="F"+Qe;for(var Qe=65;Qe<=90;Qe++)cr[Qe]=String.fromCharCode(Qe+32),jl[Qe]=String.fromCharCode(Qe);for(var Bc in cr)jl.hasOwnProperty(Bc)||(jl[Bc]=cr[Bc]);function aA(t){var e=oA&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||lA&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?jl:cr)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}const cA=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),uA=typeof navigator<"u"&&/Win/.test(navigator.platform);function dA(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,s,i,o;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))s=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))cA?o=!0:s=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(n="Alt-"+n),s&&(n="Ctrl-"+n),o&&(n="Meta-"+n),i&&(n="Shift-"+n),n}function hA(t){let e=Object.create(null);for(let n in t)e[dA(n)]=t[n];return e}function Hc(t,e,n=!0){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n&&e.shiftKey&&(t="Shift-"+t),t}function fA(t){return new ce({props:{handleKeyDown:ph(t)}})}function ph(t){let e=hA(t);return function(n,r){let s=aA(r),i,o=e[Hc(s,r)];if(o&&o(n.state,n.dispatch,n))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let l=e[Hc(s,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(uA&&r.ctrlKey&&r.altKey)&&(i=cr[r.keyCode])&&i!=s){let l=e[Hc(i,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var pA=Object.defineProperty,mh=(t,e)=>{for(var n in e)pA(t,n,{get:e[n],enumerable:!0})};function Ka(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:s}=n,{storedMarks:i}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return i},get selection(){return r},get doc(){return s},get tr(){return r=n.selection,s=n.doc,i=n.storedMarks,n}}}var qa=class{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:e,state:n}=this,{view:r}=e,{tr:s}=n,i=this.buildProps(s);return Object.fromEntries(Object.entries(t).map(([o,l])=>[o,(...c)=>{const u=l(...c)(i);return!s.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(s),u}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:r,state:s}=this,{view:i}=r,o=[],l=!!t,a=t||s.tr,c=()=>(!l&&e&&!a.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(a),o.every(d=>d===!0)),u={...Object.fromEntries(Object.entries(n).map(([d,h])=>[d,(...p)=>{const g=this.buildProps(a,e),y=h(...p)(g);return o.push(y),u}])),run:c};return u}createCan(t){const{rawCommands:e,state:n}=this,r=!1,s=t||n.tr,i=this.buildProps(s,r);return{...Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...c)=>a(...c)({...i,dispatch:void 0})])),chain:()=>this.createChain(s,r)}}buildProps(t,e=!0){const{rawCommands:n,editor:r,state:s}=this,{view:i}=r,o={tr:t,editor:r,view:i,state:Ka({state:s,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map(([l,a])=>[l,(...c)=>a(...c)(o)]))}};return o}},q0={};mh(q0,{blur:()=>mA,clearContent:()=>gA,clearNodes:()=>yA,command:()=>bA,createParagraphNear:()=>wA,cut:()=>xA,deleteCurrentNode:()=>vA,deleteNode:()=>kA,deleteRange:()=>SA,deleteSelection:()=>AA,enter:()=>EA,exitCode:()=>TA,extendMarkRange:()=>_A,first:()=>NA,focus:()=>IA,forEach:()=>DA,insertContent:()=>RA,insertContentAt:()=>PA,joinBackward:()=>zA,joinDown:()=>HA,joinForward:()=>$A,joinItemBackward:()=>VA,joinItemForward:()=>FA,joinTextblockBackward:()=>UA,joinTextblockForward:()=>WA,joinUp:()=>BA,keyboardShortcut:()=>qA,lift:()=>JA,liftEmptyBlock:()=>GA,liftListItem:()=>YA,newlineInCode:()=>XA,resetAttributes:()=>ZA,scrollIntoView:()=>QA,selectAll:()=>e2,selectNodeBackward:()=>t2,selectNodeForward:()=>n2,selectParentNode:()=>r2,selectTextblockEnd:()=>s2,selectTextblockStart:()=>i2,setContent:()=>o2,setMark:()=>M2,setMeta:()=>A2,setNode:()=>E2,setNodeSelection:()=>T2,setTextDirection:()=>_2,setTextSelection:()=>N2,sinkListItem:()=>O2,splitBlock:()=>I2,splitListItem:()=>D2,toggleList:()=>L2,toggleMark:()=>j2,toggleNode:()=>P2,toggleWrap:()=>B2,undoInputRule:()=>H2,unsetAllMarks:()=>z2,unsetMark:()=>$2,unsetTextDirection:()=>V2,updateAttributes:()=>F2,wrapIn:()=>U2,wrapInList:()=>W2});var mA=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window==null?void 0:window.getSelection())==null||n.removeAllRanges())}),!0),gA=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),yA=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:s}=r;return n&&s.forEach(({$from:i,$to:o})=>{t.doc.nodesBetween(i.pos,o.pos,(l,a)=>{if(l.type.isText)return;const{doc:c,mapping:u}=e,d=c.resolve(u.map(a)),h=c.resolve(u.map(a+l.nodeSize)),f=d.blockRange(h);if(!f)return;const p=$s(f);if(l.type.isTextblock){const{defaultType:g}=d.parent.contentMatchAt(d.index());e.setNodeMarkup(f.start,g)}(p||p===0)&&e.lift(f,p)})}),!0},bA=t=>e=>t(e),wA=()=>({state:t,dispatch:e})=>o0(t,e),xA=(t,e)=>({editor:n,tr:r})=>{const{state:s}=n,i=s.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const o=r.mapping.map(e);return r.insert(o,i.content),r.setSelection(new ee(r.doc.resolve(Math.max(o-1,0)))),!0},vA=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const s=t.selection.$anchor;for(let i=s.depth;i>0;i-=1)if(s.node(i).type===r.type){if(e){const l=s.before(i),a=s.after(i);t.delete(l,a).scrollIntoView()}return!0}return!1};function Le(t,e){if(typeof t=="string"){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}var kA=t=>({tr:e,state:n,dispatch:r})=>{const s=Le(t,n.schema),i=e.selection.$anchor;for(let o=i.depth;o>0;o-=1)if(i.node(o).type===s){if(r){const a=i.before(o),c=i.after(o);e.delete(a,c).scrollIntoView()}return!0}return!1},SA=t=>({tr:e,dispatch:n})=>{const{from:r,to:s}=t;return n&&e.delete(r,s),!0},CA=t=>t.content?/^text(\*|\+)/.test(t.content):!1,Hp=(t,e,n)=>{if(!t.parent.isInline||n==="left"&&t.pos>t.start()||n==="right"&&t.pos<t.end())return t.pos;const r=e.nodes[t.parent.type.name].spec;return CA(r)?n==="left"?t.start()-1:t.end()+1:t.pos},MA=(t,e,n)=>{const r=Hp(t,n,"left"),s=Hp(e,n,"right");return{from:r,to:s}},AA=()=>({state:t,dispatch:e})=>{const{$from:n,$to:r}=t.selection;if(t.selection.empty)return!1;const{from:s,to:i}=MA(n,r,t.schema);return e&&(t.tr.deleteRange(s,i).scrollIntoView(),e(t.tr)),!0},EA=()=>({commands:t})=>t.keyboardShortcut("Enter"),TA=()=>({state:t,dispatch:e})=>cC(t,e);function gh(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function Pl(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(s=>n.strict?e[s]===t[s]:gh(e[s])?e[s].test(t[s]):e[s]===t[s]):!0}function J0(t,e,n={}){return t.find(r=>r.type===e&&Pl(Object.fromEntries(Object.keys(n).map(s=>[s,r.attrs[s]])),n))}function zp(t,e,n={}){return!!J0(t,e,n)}function yh(t,e,n){if(!t||!e)return;let r=t.parent.childAfter(t.parentOffset);if((!r.node||!r.node.marks.some(c=>c.type===e))&&(r=t.parent.childBefore(t.parentOffset)),!r.node||!r.node.marks.some(c=>c.type===e))return;if(!n){const c=r.node.marks.find(u=>u.type===e);c&&(n=c.attrs)}if(!J0([...r.node.marks],e,n))return;let i=r.index,o=t.start()+r.offset,l=i+1,a=o+r.node.nodeSize;for(;i>0&&zp([...t.parent.child(i-1).marks],e,n);)i-=1,o-=t.parent.child(i).nodeSize;for(;l<t.parent.childCount&&zp([...t.parent.child(l).marks],e,n);)a+=t.parent.child(l).nodeSize,l+=1;return{from:o,to:a}}function Bn(t,e){if(typeof t=="string"){if(!e.marks[t])throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`);return e.marks[t]}return t}var _A=(t,e)=>({tr:n,state:r,dispatch:s})=>{const i=Bn(t,r.schema),{doc:o,selection:l}=n,{$from:a,from:c,to:u}=l;if(s){const d=yh(a,i,e);if(d&&d.from<=c&&d.to>=u){const h=ee.create(o,d.from,d.to);n.setSelection(h)}}return!0},NA=t=>e=>{const n=typeof t=="function"?t(e):t;for(let r=0;r<n.length;r+=1)if(n[r](e))return!0;return!1};function Ja(t){return t instanceof ee}function In(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function G0(t,e=null){if(!e)return null;const n=te.atStart(t),r=te.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const s=n.from,i=r.to;return e==="all"?ee.create(t,In(0,s,i),In(t.content.size,s,i)):ee.create(t,In(e,s,i),In(e,s,i))}function qu(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function Ji(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function OA(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var IA=(t=null,e={})=>({editor:n,view:r,tr:s,dispatch:i})=>{e={scrollIntoView:!0,...e};const o=()=>{(Ji()||qu())&&r.dom.focus(),OA()&&!Ji()&&!qu()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e!=null&&e.scrollIntoView&&n.commands.scrollIntoView())})};try{if(r.hasFocus()&&t===null||t===!1)return!0}catch{return!1}if(i&&t===null&&!Ja(n.state.selection))return o(),!0;const l=G0(s.doc,t)||n.state.selection,a=n.state.selection.eq(l);return i&&(a||s.setSelection(l),a&&s.storedMarks&&s.setStoredMarks(s.storedMarks),o()),!0},DA=(t,e)=>n=>t.every((r,s)=>e(r,{...n,index:s})),RA=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),Y0=t=>{const e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){const r=e[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?t.removeChild(r):r.nodeType===1&&Y0(r)}return t};function Ro(t){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`<body>${t}</body>`,n=new window.DOMParser().parseFromString(e,"text/html").body;return Y0(n)}function Gi(t,e,n){if(t instanceof ir||t instanceof j)return t;n={slice:!0,parseOptions:{},...n};const r=typeof t=="object"&&t!==null,s=typeof t=="string";if(r)try{if(Array.isArray(t)&&t.length>0)return j.fromArray(t.map(l=>e.nodeFromJSON(l)));const o=e.nodeFromJSON(t);return n.errorOnInvalidContent&&o.check(),o}catch(i){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:i});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",i),Gi("",e,n)}if(s){if(n.errorOnInvalidContent){let o=!1,l="";const a=new T1({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(o=!0,l=typeof c=="string"?c:c.outerHTML,null)}]}})});if(n.slice?Mi.fromSchema(a).parseSlice(Ro(t),n.parseOptions):Mi.fromSchema(a).parse(Ro(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const i=Mi.fromSchema(e);return n.slice?i.parseSlice(Ro(t),n.parseOptions).content:i.parse(Ro(t),n.parseOptions)}return Gi("",e,n)}function LA(t,e,n){const r=t.steps.length-1;if(r<e)return;const s=t.steps[r];if(!(s instanceof Vt||s instanceof kt))return;const i=t.mapping.maps[r];let o=0;i.forEach((l,a,c,u)=>{o===0&&(o=u)}),t.setSelection(te.near(t.doc.resolve(o),n))}var jA=t=>!("type"in t),PA=(t,e,n)=>({tr:r,dispatch:s,editor:i})=>{var o;if(s){n={parseOptions:i.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let l;const a=y=>{i.emit("contentError",{editor:i,error:y,disableCollaboration:()=>{"collaboration"in i.storage&&typeof i.storage.collaboration=="object"&&i.storage.collaboration&&(i.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!i.options.enableContentCheck&&i.options.emitContentError)try{Gi(e,i.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(y){a(y)}try{l=Gi(e,i.schema,{parseOptions:c,errorOnInvalidContent:(o=n.errorOnInvalidContent)!=null?o:i.options.enableContentCheck})}catch(y){return a(y),!1}let{from:u,to:d}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},h=!0,f=!0;if((jA(l)?l:[l]).forEach(y=>{y.check(),h=h?y.isText&&y.marks.length===0:!1,f=f?y.isBlock:!1}),u===d&&f){const{parent:y}=r.doc.resolve(u);y.isTextblock&&!y.type.spec.code&&!y.childCount&&(u-=1,d+=1)}let g;if(h){if(Array.isArray(e))g=e.map(y=>y.text||"").join("");else if(e instanceof j){let y="";e.forEach(b=>{b.text&&(y+=b.text)}),g=y}else typeof e=="object"&&e&&e.text?g=e.text:g=e;r.insertText(g,u,d)}else{g=l;const y=r.doc.resolve(u),b=y.node(),w=y.parentOffset===0,v=b.isText||b.isTextblock,x=b.content.size>0;w&&v&&x&&f&&(u=Math.max(0,u-1)),r.replaceWith(u,d,g)}n.updateSelection&&LA(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:u,text:g}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:u,text:g})}return!0},BA=()=>({state:t,dispatch:e})=>oC(t,e),HA=()=>({state:t,dispatch:e})=>lC(t,e),zA=()=>({state:t,dispatch:e})=>Q1(t,e),$A=()=>({state:t,dispatch:e})=>r0(t,e),VA=()=>({state:t,dispatch:e,tr:n})=>{try{const r=Va(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},FA=()=>({state:t,dispatch:e,tr:n})=>{try{const r=Va(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},UA=()=>({state:t,dispatch:e})=>sC(t,e),WA=()=>({state:t,dispatch:e})=>iC(t,e);function X0(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function KA(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,s,i,o;for(let l=0;l<e.length-1;l+=1){const a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))s=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))Ji()||X0()?o=!0:s=!0;else throw new Error(`Unrecognized modifier name: ${a}`)}return r&&(n=`Alt-${n}`),s&&(n=`Ctrl-${n}`),o&&(n=`Meta-${n}`),i&&(n=`Shift-${n}`),n}var qA=t=>({editor:e,view:n,tr:r,dispatch:s})=>{const i=KA(t).split(/-(?!$)/),o=i.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),l=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:i.includes("Alt"),ctrlKey:i.includes("Ctrl"),metaKey:i.includes("Meta"),shiftKey:i.includes("Shift"),bubbles:!0,cancelable:!0}),a=e.captureTransaction(()=>{n.someProp("handleKeyDown",c=>c(n,l))});return a==null||a.steps.forEach(c=>{const u=c.map(r.mapping);u&&s&&r.maybeStep(u)}),!0};function ur(t,e,n={}){const{from:r,to:s,empty:i}=t.selection,o=e?Le(e,t.schema):null,l=[];t.doc.nodesBetween(r,s,(d,h)=>{if(d.isText)return;const f=Math.max(r,h),p=Math.min(s,h+d.nodeSize);l.push({node:d,from:f,to:p})});const a=s-r,c=l.filter(d=>o?o.name===d.node.type.name:!0).filter(d=>Pl(d.node.attrs,n,{strict:!1}));return i?!!c.length:c.reduce((d,h)=>d+h.to-h.from,0)>=a}var JA=(t,e={})=>({state:n,dispatch:r})=>{const s=Le(t,n.schema);return ur(n,s,e)?aC(n,r):!1},GA=()=>({state:t,dispatch:e})=>l0(t,e),YA=t=>({state:e,dispatch:n})=>{const r=Le(t,e.schema);return xC(r)(e,n)},XA=()=>({state:t,dispatch:e})=>i0(t,e);function Ga(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function $p(t,e){const n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((r,s)=>(n.includes(s)||(r[s]=t[s]),r),{})}var ZA=(t,e)=>({tr:n,state:r,dispatch:s})=>{let i=null,o=null;const l=Ga(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(i=Le(t,r.schema)),l==="mark"&&(o=Bn(t,r.schema));let a=!1;return n.selection.ranges.forEach(c=>{r.doc.nodesBetween(c.$from.pos,c.$to.pos,(u,d)=>{i&&i===u.type&&(a=!0,s&&n.setNodeMarkup(d,void 0,$p(u.attrs,e))),o&&u.marks.length&&u.marks.forEach(h=>{o===h.type&&(a=!0,s&&n.addMark(d,d+u.nodeSize,o.create($p(h.attrs,e))))})})}),a},QA=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),e2=()=>({tr:t,dispatch:e})=>{if(e){const n=new dn(t.doc);t.setSelection(n)}return!0},t2=()=>({state:t,dispatch:e})=>t0(t,e),n2=()=>({state:t,dispatch:e})=>s0(t,e),r2=()=>({state:t,dispatch:e})=>hC(t,e),s2=()=>({state:t,dispatch:e})=>mC(t,e),i2=()=>({state:t,dispatch:e})=>pC(t,e);function Ju(t,e,n={},r={}){return Gi(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var o2=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:s,tr:i,dispatch:o,commands:l})=>{const{doc:a}=i;if(r.preserveWhitespace!=="full"){const c=Ju(t,s.schema,r,{errorOnInvalidContent:e??s.options.enableContentCheck});return o&&i.replaceWith(0,a.content.size,c).setMeta("preventUpdate",!n),!0}return o&&i.setMeta("preventUpdate",!n),l.insertContentAt({from:0,to:a.content.size},t,{parseOptions:r,errorOnInvalidContent:e??s.options.enableContentCheck})};function Z0(t,e){const n=Bn(e,t.schema),{from:r,to:s,empty:i}=t.selection,o=[];i?(t.storedMarks&&o.push(...t.storedMarks),o.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,s,a=>{o.push(...a.marks)});const l=o.find(a=>a.type.name===n.name);return l?{...l.attrs}:{}}function Q0(t,e){const n=new Qd(t);return e.forEach(r=>{r.steps.forEach(s=>{n.step(s)})}),n}function l2(t){for(let e=0;e<t.edgeCount;e+=1){const{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function a2(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(s,i)=>{n(s)&&r.push({node:s,pos:i})}),r}function ey(t,e){for(let n=t.depth;n>0;n-=1){const r=t.node(n);if(e(r))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:r}}}function Ya(t){return e=>ey(e.$from,t)}function G(t,e,n){return t.config[e]===void 0&&t.parent?G(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?G(t.parent,e,n):null}):t.config[e]}function bh(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=G(e,"addExtensions",n);return r?[e,...bh(r())]:e}).flat(10)}function wh(t,e){const n=Xr.fromSchema(e).serializeFragment(t),s=document.implementation.createHTMLDocument().createElement("div");return s.appendChild(n),s.innerHTML}function ty(t){return typeof t=="function"}function he(t,e=void 0,...n){return ty(t)?e?t.bind(e)(...n):t(...n):t}function c2(t={}){return Object.keys(t).length===0&&t.constructor===Object}function As(t){const e=t.filter(s=>s.type==="extension"),n=t.filter(s=>s.type==="node"),r=t.filter(s=>s.type==="mark");return{baseExtensions:e,nodeExtensions:n,markExtensions:r}}function ny(t){const e=[],{nodeExtensions:n,markExtensions:r}=As(t),s=[...n,...r],i={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},o=n.filter(c=>c.name!=="text").map(c=>c.name),l=r.map(c=>c.name),a=[...o,...l];return t.forEach(c=>{const u={name:c.name,options:c.options,storage:c.storage,extensions:s},d=G(c,"addGlobalAttributes",u);if(!d)return;d().forEach(f=>{let p;Array.isArray(f.types)?p=f.types:f.types==="*"?p=a:f.types==="nodes"?p=o:f.types==="marks"?p=l:p=[],p.forEach(g=>{Object.entries(f.attributes).forEach(([y,b])=>{e.push({type:g,name:y,attribute:{...i,...b}})})})})}),s.forEach(c=>{const u={name:c.name,options:c.options,storage:c.storage},d=G(c,"addAttributes",u);if(!d)return;const h=d();Object.entries(h).forEach(([f,p])=>{const g={...i,...p};typeof(g==null?void 0:g.default)=="function"&&(g.default=g.default()),g!=null&&g.isRequired&&(g==null?void 0:g.default)===void 0&&delete g.default,e.push({type:c.name,name:f,attribute:g})})}),e}function u2(t){const e=[];let n="",r=!1,s=!1,i=0;const o=t.length;for(let l=0;l<o;l+=1){const a=t[l];if(a==="'"&&!s){r=!r,n+=a;continue}if(a==='"'&&!r){s=!s,n+=a;continue}if(!r&&!s){if(a==="("){i+=1,n+=a;continue}if(a===")"&&i>0){i-=1,n+=a;continue}if(a===";"&&i===0){e.push(n),n="";continue}}n+=a}return n&&e.push(n),e}function Vp(t){const e=[],n=u2(t||""),r=n.length;for(let s=0;s<r;s+=1){const i=n[s],o=i.indexOf(":");if(o===-1)continue;const l=i.slice(0,o).trim(),a=i.slice(o+1).trim();l&&a&&e.push([l,a])}return e}function le(...t){return t.filter(e=>!!e).reduce((e,n)=>{const r={...e};return Object.entries(n).forEach(([s,i])=>{if(!r[s]){r[s]=i;return}if(s==="class"){const l=i?String(i).split(" "):[],a=r[s]?r[s].split(" "):[],c=l.filter(u=>!a.includes(u));r[s]=[...a,...c].join(" ")}else if(s==="style"){const l=new Map([...Vp(r[s]),...Vp(i)]);r[s]=Array.from(l.entries()).map(([a,c])=>`${a}: ${c}`).join("; ")}else r[s]=i}),r},{})}function Es(t,e){return e.filter(n=>n.type===t.type.name).filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(t.attrs)||{}:{[n.name]:t.attrs[n.name]}).reduce((n,r)=>le(n,r),{})}function d2(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function Fp(t,e){return"style"in t?t:{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;const s=e.reduce((i,o)=>{const l=o.attribute.parseHTML?o.attribute.parseHTML(n):d2(n.getAttribute(o.name));return l==null?i:{...i,[o.name]:l}},{});return{...r,...s}}}}function Up(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&c2(n)?!1:n!=null))}function Wp(t){var e,n;const r={};return!((e=t==null?void 0:t.attribute)!=null&&e.isRequired)&&"default"in((t==null?void 0:t.attribute)||{})&&(r.default=t.attribute.default),((n=t==null?void 0:t.attribute)==null?void 0:n.validate)!==void 0&&(r.validate=t.attribute.validate),[t.name,r]}function h2(t,e){var n;const r=ny(t),{nodeExtensions:s,markExtensions:i}=As(t),o=(n=s.find(c=>G(c,"topNode")))==null?void 0:n.name,l=Object.fromEntries(s.map(c=>{const u=r.filter(b=>b.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:e},h=t.reduce((b,w)=>{const v=G(w,"extendNodeSchema",d);return{...b,...v?v(c):{}}},{}),f=Up({...h,content:he(G(c,"content",d)),marks:he(G(c,"marks",d)),group:he(G(c,"group",d)),inline:he(G(c,"inline",d)),atom:he(G(c,"atom",d)),selectable:he(G(c,"selectable",d)),draggable:he(G(c,"draggable",d)),code:he(G(c,"code",d)),whitespace:he(G(c,"whitespace",d)),linebreakReplacement:he(G(c,"linebreakReplacement",d)),defining:he(G(c,"defining",d)),isolating:he(G(c,"isolating",d)),attrs:Object.fromEntries(u.map(Wp))}),p=he(G(c,"parseHTML",d));p&&(f.parseDOM=p.map(b=>Fp(b,u)));const g=G(c,"renderHTML",d);g&&(f.toDOM=b=>g({node:b,HTMLAttributes:Es(b,u)}));const y=G(c,"renderText",d);return y&&(f.toText=y),[c.name,f]})),a=Object.fromEntries(i.map(c=>{const u=r.filter(y=>y.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:e},h=t.reduce((y,b)=>{const w=G(b,"extendMarkSchema",d);return{...y,...w?w(c):{}}},{}),f=Up({...h,inclusive:he(G(c,"inclusive",d)),excludes:he(G(c,"excludes",d)),group:he(G(c,"group",d)),spanning:he(G(c,"spanning",d)),code:he(G(c,"code",d)),attrs:Object.fromEntries(u.map(Wp))}),p=he(G(c,"parseHTML",d));p&&(f.parseDOM=p.map(y=>Fp(y,u)));const g=G(c,"renderHTML",d);return g&&(f.toDOM=y=>g({mark:y,HTMLAttributes:Es(y,u)})),[c.name,f]}));return new T1({topNode:o,nodes:l,marks:a})}function f2(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function _i(t){return t.sort((n,r)=>{const s=G(n,"priority")||100,i=G(r,"priority")||100;return s>i?-1:s<i?1:0})}function ry(t){const e=_i(bh(t)),n=f2(e.map(r=>r.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(r=>`'${r}'`).join(", ")}]. This can lead to issues.`),e}function sy(t,e,n){const{from:r,to:s}=e,{blockSeparator:i=`
|
|
27
27
|
|
|
28
|
-
`,textSerializers:o={}}=n||{};let l="";return t.nodesBetween(r,s,(a,c,u,d)=>{var f;a.isBlock&&c>r&&(l+=i);const h=o==null?void 0:o[a.type.name];if(h)return u&&(l+=h({node:a,pos:c,parent:u,index:d,range:e})),!1;a.isText&&(l+=(f=a==null?void 0:a.text)==null?void 0:f.slice(Math.max(r,c)-c,s-c))}),l}function i0(t,e){const n={from:0,to:t.content.size};return s0(t,n,e)}function vf(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function pT(t,e){const n=Le(e,t.schema),{from:r,to:s}=t.selection,i=[];t.doc.nodesBetween(r,s,l=>{i.push(l)});const o=i.reverse().find(l=>l.type.name===n.name);return o?{...o.attrs}:{}}function o0(t,e){const n=Ga(typeof e=="string"?e:e.name,t.schema);return n==="node"?pT(t,e):n==="mark"?Zb(t,e):{}}function mT(t,e=JSON.stringify){const n={};return t.filter(r=>{const s=e(r);return Object.prototype.hasOwnProperty.call(n,s)?!1:n[s]=!0})}function gT(t){const e=mT(t);return e.length===1?e:e.filter((n,r)=>!e.filter((i,o)=>o!==r).some(i=>n.oldRange.from>=i.oldRange.from&&n.oldRange.to<=i.oldRange.to&&n.newRange.from>=i.newRange.from&&n.newRange.to<=i.newRange.to))}function l0(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((s,i)=>{const o=[];if(s.ranges.length)s.forEach((l,a)=>{o.push({from:l,to:a})});else{const{from:l,to:a}=n[i];if(l===void 0||a===void 0)return;o.push({from:l,to:a})}o.forEach(({from:l,to:a})=>{const c=e.slice(i).map(l,-1),u=e.slice(i).map(a),d=e.invert().map(c,-1),f=e.invert().map(u);r.push({oldRange:{from:d,to:f},newRange:{from:c,to:u}})})}),gT(r)}function kf(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(s=>{const i=n.resolve(t),o=bf(i,s.type);o&&r.push({mark:s,...o})}):n.nodesBetween(t,e,(s,i)=>{!s||(s==null?void 0:s.nodeSize)===void 0||r.push(...s.marks.map(o=>({from:i,to:i+s.nodeSize,mark:o})))}),r}var yT=(t,e,n,r=20)=>{const s=t.doc.resolve(n);let i=r,o=null;for(;i>0&&o===null;){const l=s.node(i);(l==null?void 0:l.type.name)===e?o=l:i-=1}return[o,i]};function ei(t,e){return e.nodes[t]||e.marks[t]||null}function cl(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const s=t.find(i=>i.type===e&&i.name===r);return s?s.attribute.keepOnSplit:!1}))}var bT=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(s,i,o,l)=>{var a,c;const u=((c=(a=s.type.spec).toText)==null?void 0:c.call(a,{node:s,pos:i,parent:o,index:l}))||s.textContent||"%leaf%";n+=s.isAtom&&!s.isText?u:u.slice(0,Math.max(0,r-i))}),n};function Gu(t,e,n={}){const{empty:r,ranges:s}=t.selection,i=e?Bn(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(d=>i?i.name===d.type.name:!0).find(d=>Pl(d.attrs,n,{strict:!1}));let o=0;const l=[];if(s.forEach(({$from:d,$to:f})=>{const h=d.pos,p=f.pos;t.doc.nodesBetween(h,p,(g,y)=>{if(i&&g.inlineContent&&!g.type.allowsMarkType(i))return!1;if(!g.isText&&!g.marks.length)return;const b=Math.max(h,y),w=Math.min(p,y+g.nodeSize),v=w-b;o+=v,l.push(...g.marks.map(x=>({mark:x,from:b,to:w})))})}),o===0)return!1;const a=l.filter(d=>i?i.name===d.mark.type.name:!0).filter(d=>Pl(d.mark.attrs,n,{strict:!1})).reduce((d,f)=>d+f.to-f.from,0),c=l.filter(d=>i?d.mark.type!==i&&d.mark.type.excludes(i):!0).reduce((d,f)=>d+f.to-f.from,0);return(a>0?a+c:a)>=o}function wT(t,e,n={}){if(!e)return ur(t,null,n)||Gu(t,null,n);const r=Ga(e,t.schema);return r==="node"?ur(t,e,n):r==="mark"?Gu(t,e,n):!1}var xT=(t,e)=>{const{$from:n,$to:r,$anchor:s}=t.selection;if(e){const i=Ya(l=>l.type.name===e)(t.selection);if(!i)return!1;const o=t.doc.resolve(i.pos+1);return s.pos+1===o.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},vT=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function qp(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function $c(t,e){const{nodeExtensions:n}=Ms(e),r=n.find(o=>o.name===t);if(!r)return!1;const s={name:r.name,options:r.options,storage:r.storage},i=fe(G(r,"group",s));return typeof i!="string"?!1:i.split(" ").includes("list")}function Yi(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if(t.type.name==="hardBreak")return!0;if(t.isText)return!/\S/.test((r=t.text)!=null?r:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let s=!0;return t.content.forEach(i=>{s!==!1&&(Yi(i,{ignoreWhitespace:n,checkChildren:e})||(s=!1))}),s}return!1}function a0(t){return t instanceof Y}function kT({selection:t,pos:e,nodeSize:n,selectedOnTextSelection:r=!1}){const{from:s,to:i}=t;return!!(s<=e&&i>=e+n||r&&Ja(t)&&s>e&&i<e+n)}var Sf=class c0{constructor(e){this.position=e}static fromJSON(e){return new c0(e.position)}toJSON(){return{position:this.position}}};function u0(t,e){const n=e.mapping.mapResult(t.position);return{position:new Sf(n.pos),mapResult:n}}function ST(t){return new Sf(t)}function d0(t,e,n){const s=t.state.doc.content.size,i=In(e,0,s),o=In(n,0,s),l=t.coordsAtPos(i),a=t.coordsAtPos(o,-1),c=Math.min(l.top,a.top),u=Math.max(l.bottom,a.bottom),d=Math.min(l.left,a.left),f=Math.max(l.right,a.right),h=f-d,p=u-c,b={top:c,bottom:u,left:d,right:f,width:h,height:p,x:d,y:c};return{...b,toJSON:()=>b}}function CT(t,e,n){var r;const{selection:s}=e;let i=null;if(Ja(s)&&(i=s.$cursor),i){const l=(r=t.storedMarks)!=null?r:i.marks();return i.parent.type.allowsMarkType(n)&&(!!n.isInSet(l)||!l.some(c=>c.type.excludes(n)))}const{ranges:o}=s;return o.some(({$from:l,$to:a})=>{let c=l.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(l.pos,a.pos,(u,d,f)=>{if(c)return!1;if(u.isInline){const h=!f||f.type.allowsMarkType(n),p=!!n.isInSet(u.marks)||!u.marks.some(g=>g.type.excludes(n));c=h&&p}return!c}),c})}var ET=(t,e={})=>({tr:n,state:r,dispatch:s})=>{const{selection:i}=n,{empty:o,ranges:l}=i,a=Bn(t,r.schema);if(s)if(o){const c=Zb(r,a);n.addStoredMark(a.create({...c,...e}))}else l.forEach(c=>{const u=c.$from.pos,d=c.$to.pos;r.doc.nodesBetween(u,d,(f,h)=>{const p=Math.max(h,u),g=Math.min(h+f.nodeSize,d);f.marks.find(b=>b.type===a)?f.marks.forEach(b=>{a===b.type&&n.addMark(p,g,a.create({...b.attrs,...e}))}):n.addMark(p,g,a.create(e))})});return CT(r,n,a)},MT=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),TT=(t,e={})=>({state:n,dispatch:r,chain:s})=>{const i=Le(t,n.schema);let o;return n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),i.isTextblock?s().command(({commands:l})=>op(i,{...o,...e})(n)?!0:l.clearNodes()).command(({state:l})=>op(i,{...o,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},AT=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,s=In(t,0,r.content.size),i=Y.create(r,s);e.setSelection(i)}return!0},_T=(t,e)=>({tr:n,state:r,dispatch:s})=>{const{selection:i}=r;let o,l;return typeof e=="number"?(o=e,l=e):e&&"from"in e&&"to"in e?(o=e.from,l=e.to):(o=i.from,l=i.to),s&&n.doc.nodesBetween(o,l,(a,c)=>{a.isText||n.setNodeMarkup(c,void 0,{...a.attrs,dir:t})}),!0},NT=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:s,to:i}=typeof t=="number"?{from:t,to:t}:t,o=ee.atStart(r).from,l=ee.atEnd(r).to,a=In(s,o,l),c=In(i,o,l),u=ee.create(r,a,c);e.setSelection(u)}return!0},OT=t=>({state:e,dispatch:n})=>{const r=Le(t,e.schema);return SC(r)(e,n)};function Kp(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const r=n.filter(s=>e==null?void 0:e.includes(s.type.name));t.tr.ensureMarks(r)}}var IT=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:s})=>{const{selection:i,doc:o}=e,{$from:l,$to:a}=i,c=s.extensionManager.attributes,u=cl(c,l.node().type.name,l.node().attrs);if(i instanceof Y&&i.node.isBlock)return!l.parentOffset||!Rn(o,l.pos)?!1:(r&&(t&&Kp(n,s.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const d=a.parentOffset===a.parent.content.size,f=l.depth===0?void 0:lT(l.node(-1).contentMatchAt(l.indexAfter(-1)));let h=d&&f?[{type:f,attrs:u}]:void 0,p=Rn(e.doc,e.mapping.map(l.pos),1,h);if(!h&&!p&&Rn(e.doc,e.mapping.map(l.pos),1,f?[{type:f}]:void 0)&&(p=!0,h=f?[{type:f,attrs:u}]:void 0),r){if(p&&(i instanceof ee&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,h),f&&!d&&!l.parentOffset&&l.parent.type!==f)){const g=e.mapping.map(l.before()),y=e.doc.resolve(g);l.node(-1).canReplaceWith(y.index(),y.index()+1,f)&&e.setNodeMarkup(e.mapping.map(l.before()),f)}t&&Kp(n,s.extensionManager.splittableMarks),e.scrollIntoView()}return p},RT=(t,e={})=>({tr:n,state:r,dispatch:s,editor:i})=>{var o;const l=Le(t,r.schema),{$from:a,$to:c}=r.selection,u=r.selection.node;if(u&&u.isBlock||a.depth<2||!a.sameParent(c))return!1;const d=a.node(-1);if(d.type!==l)return!1;const f=i.extensionManager.attributes;if(a.parent.content.size===0&&a.node(-1).childCount===a.indexAfter(-1)){if(a.depth===2||a.node(-3).type!==l||a.index(-2)!==a.node(-2).childCount-1)return!1;if(s){let b=j.empty;const w=a.index(-1)?1:a.index(-2)?2:3;for(let O=a.depth-w;O>=a.depth-3;O-=1)b=j.from(a.node(O).copy(b));const v=a.indexAfter(-1)<a.node(-2).childCount?1:a.indexAfter(-2)<a.node(-3).childCount?2:3,x={...cl(f,a.node().type.name,a.node().attrs),...e},k=((o=l.contentMatch.defaultType)==null?void 0:o.createAndFill(x))||void 0;b=b.append(j.from(l.createAndFill(null,k)||void 0));const C=a.before(a.depth-(w-1));n.replace(C,a.after(-v),new K(b,4-w,0));let E=-1;n.doc.nodesBetween(C,n.doc.content.size,(O,_)=>{if(E>-1)return!1;O.isTextblock&&O.content.size===0&&(E=_+1)}),E>-1&&n.setSelection(ee.near(n.doc.resolve(E))),n.scrollIntoView()}return!0}const h=c.pos===a.end()?d.contentMatchAt(0).defaultType:null,p={...cl(f,d.type.name,d.attrs),...e},g={...cl(f,a.node().type.name,a.node().attrs),...e};n.delete(a.pos,c.pos);const y=h?[{type:l,attrs:p},{type:h,attrs:g}]:[{type:l,attrs:p}];if(!Rn(n.doc,a.pos,2))return!1;if(s){const{selection:b,storedMarks:w}=r,{splittableMarks:v}=i.extensionManager,x=w||b.$to.parentOffset&&b.$from.marks();if(n.split(a.pos,2,y).scrollIntoView(),!x||!s)return!0;const k=x.filter(C=>v.includes(C.type.name));n.ensureMarks(k)}return!0},Hc=(t,e)=>{const n=Ya(o=>o.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;const s=t.doc.nodeAt(r);return n.node.type===(s==null?void 0:s.type)&&gr(t.doc,n.pos)&&t.join(n.pos),!0},Fc=(t,e)=>{const n=Ya(o=>o.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;const s=t.doc.nodeAt(r);return n.node.type===(s==null?void 0:s.type)&&gr(t.doc,r)&&t.join(r),!0};function DT(t){const e=t.doc,n=e.firstChild;if(!n)return null;const r=e.resolve(1),s=e.resolve(n.nodeSize-1);return ee.between(r,s)}var LT=(t,e,n,r={})=>({editor:s,tr:i,state:o,dispatch:l,chain:a,commands:c,can:u})=>{const{extensions:d,splittableMarks:f}=s.extensionManager,h=Le(t,o.schema),p=Le(e,o.schema),{selection:g,storedMarks:y}=o,{$from:b,$to:w}=g,v=b.blockRange(w),x=y||g.$to.parentOffset&&g.$from.marks();if(!v)return!1;const k=Ya(L=>$c(L.type.name,d))(g),C=g.from===0&&g.to===o.doc.content.size,E=o.doc.content.content,O=E.length===1?E[0]:null,_=C&&O&&$c(O.type.name,d)?{node:O,pos:0}:null,M=k??_,D=!!k&&v.depth>=1&&v.depth-k.depth<=1,R=!!_;if((D||R)&&M){if(M.node.type===h)return C&&R?a().command(({tr:L,dispatch:I})=>{const N=DT(L);return N?(L.setSelection(N),I&&I(L),!0):!1}).liftListItem(p).run():c.liftListItem(p);if($c(M.node.type.name,d)&&h.validContent(M.node.content))return a().command(()=>(i.setNodeMarkup(M.pos,h),!0)).command(()=>Hc(i,h)).command(()=>Fc(i,h)).run()}return!n||!x||!l?a().command(()=>u().wrapInList(h,r)?!0:c.clearNodes()).wrapInList(h,r).command(()=>Hc(i,h)).command(()=>Fc(i,h)).run():a().command(()=>{const L=u().wrapInList(h,r),I=x.filter(N=>f.includes(N.type.name));return i.ensureMarks(I),L?!0:c.clearNodes()}).wrapInList(h,r).command(()=>Hc(i,h)).command(()=>Fc(i,h)).run()},jT=(t,e={},n={})=>({state:r,commands:s})=>{const{extendEmptyMarkRange:i=!1}=n,o=Bn(t,r.schema);return Gu(r,o,e)?s.unsetMark(o,{extendEmptyMarkRange:i}):s.setMark(o,e)},PT=(t,e,n={})=>({state:r,commands:s})=>{const i=Le(t,r.schema),o=Le(e,r.schema),l=ur(r,i,n);let a;return r.selection.$anchor.sameParent(r.selection.$head)&&(a=r.selection.$anchor.parent.attrs),l?s.setNode(o,a):s.setNode(i,{...a,...n})},BT=(t,e={})=>({state:n,commands:r})=>{const s=Le(t,n.schema);return ur(n,s,e)?r.lift(s):r.wrapIn(s,e)},zT=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const s=n[r];let i;if(s.spec.isInputRules&&(i=s.getState(t))){if(e){const o=t.tr,l=i.transform;for(let a=l.steps.length-1;a>=0;a-=1)o.step(l.steps[a].invert(l.docs[a]));if(i.text){const a=o.doc.resolve(i.from).marks();o.replaceWith(i.from,i.to,t.schema.text(i.text,a))}else o.delete(i.from,i.to)}return!0}}return!1},$T=(t={})=>({tr:e,dispatch:n,editor:r})=>{const{ignoreClearable:s=!1}=t,{selection:i}=e,{empty:o,ranges:l}=i;if(o)return!0;const{nonClearableMarks:a}=r.extensionManager;if(n){const c=Object.values(r.schema.marks).filter(u=>s||!a.includes(u.name));l.forEach(u=>{for(const d of c)e.removeMark(u.$from.pos,u.$to.pos,d)})}return!0},HT=(t,e={})=>({tr:n,state:r,dispatch:s})=>{var i;const{extendEmptyMarkRange:o=!1}=e,{selection:l}=n,a=Bn(t,r.schema),{$from:c,empty:u,ranges:d}=l;if(!s)return!0;if(u&&o){let{from:f,to:h}=l;const p=(i=c.marks().find(y=>y.type===a))==null?void 0:i.attrs,g=bf(c,a,p);g&&(f=g.from,h=g.to),n.removeMark(f,h,a)}else d.forEach(f=>{n.removeMark(f.$from.pos,f.$to.pos,a)});return n.removeStoredMark(a),!0},FT=t=>({tr:e,state:n,dispatch:r})=>{const{selection:s}=n;let i,o;return typeof t=="number"?(i=t,o=t):t&&"from"in t&&"to"in t?(i=t.from,o=t.to):(i=s.from,o=s.to),r&&e.doc.nodesBetween(i,o,(l,a)=>{if(l.isText)return;const c={...l.attrs};delete c.dir,e.setNodeMarkup(a,void 0,c)}),!0},VT=(t,e={})=>({tr:n,state:r,dispatch:s})=>{let i=null,o=null;const l=Ga(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(i=Le(t,r.schema)),l==="mark"&&(o=Bn(t,r.schema));let a=!1;return n.selection.ranges.forEach(c=>{const u=c.$from.pos,d=c.$to.pos;let f,h,p,g;n.selection.empty?r.doc.nodesBetween(u,d,(y,b)=>{i&&i===y.type&&(a=!0,p=Math.max(b,u),g=Math.min(b+y.nodeSize,d),f=b,h=y)}):r.doc.nodesBetween(u,d,(y,b)=>{b<u&&i&&i===y.type&&(a=!0,p=Math.max(b,u),g=Math.min(b+y.nodeSize,d),f=b,h=y),b>=u&&b<=d&&(i&&i===y.type&&(a=!0,s&&n.setNodeMarkup(b,void 0,{...y.attrs,...e})),o&&y.marks.length&&y.marks.forEach(w=>{if(o===w.type&&(a=!0,s)){const v=Math.max(b,u),x=Math.min(b+y.nodeSize,d);n.addMark(v,x,o.create({...w.attrs,...e}))}}))}),h&&(f!==void 0&&s&&n.setNodeMarkup(f,void 0,{...h.attrs,...e}),o&&h.marks.length&&h.marks.forEach(y=>{o===y.type&&s&&n.addMark(p,g,o.create({...y.attrs,...e}))}))}),a},UT=(t,e={})=>({state:n,dispatch:r})=>{const s=Le(t,n.schema);return gC(s,e)(n,r)},WT=(t,e={})=>({state:n,dispatch:r})=>{const s=Le(t,n.schema);return yC(s,e)(n,r)},qT=class{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){const n=this.callbacks[t];return n&&n.forEach(r=>r.apply(this,e)),this}off(t,e){const n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter(r=>r!==e):delete this.callbacks[t]),this}once(t,e){const n=(...r)=>{this.off(t,n),e.apply(this,r)};return this.on(t,n)}removeAllListeners(){this.callbacks={}}},Xa=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},KT=(t,e)=>{if(yf(e))return e.exec(t);const n=e(t);if(!n)return null;const r=[n.text];return r.index=n.index,r.input=t,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};function Lo(t){var e;const{editor:n,from:r,to:s,text:i,rules:o,plugin:l}=t,{view:a}=n;if(a.composing)return!1;const c=a.state.doc.resolve(r);if(c.parent.type.spec.code||(e=c.nodeBefore||c.nodeAfter)!=null&&e.marks.find(f=>f.type.spec.code))return!1;let u=!1;const d=bT(c)+i;return o.forEach(f=>{if(u)return;const h=KT(d,f.find);if(!h)return;const p=a.state.tr,g=qa({state:a.state,transaction:p}),y={from:r-(h[0].length-i.length),to:s},{commands:b,chain:w,can:v}=new Ka({editor:n,state:g});f.handler({state:g,range:y,match:h,commands:b,chain:w,can:v})===null||!p.steps.length||(f.undoable&&p.setMeta(l,{transform:p,from:r,to:s,text:i}),a.dispatch(p),u=!0)}),u}function JT(t){const{editor:e,rules:n}=t,r=new ce({state:{init(){return null},apply(s,i,o){const l=s.getMeta(r);if(l)return l;const a=s.getMeta("applyInputRules");return!!a&&setTimeout(()=>{let{text:u}=a;typeof u=="string"?u=u:u=xf(j.from(u),o.schema);const{from:d}=a,f=d+u.length;Lo({editor:e,from:d,to:f,text:u,rules:n,plugin:r})}),s.selectionSet||s.docChanged?null:i}},props:{handleTextInput(s,i,o,l){return Lo({editor:e,from:i,to:o,text:l,rules:n,plugin:r})},handleDOMEvents:{compositionend:s=>(setTimeout(()=>{const{$cursor:i}=s.state.selection;i&&Lo({editor:e,from:i.pos,to:i.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(s,i){if(i.key!=="Enter")return!1;const{$cursor:o}=s.state.selection;return o?Lo({editor:e,from:o.pos,to:o.pos,text:`
|
|
29
|
-
`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function
|
|
28
|
+
`,textSerializers:o={}}=n||{};let l="";return t.nodesBetween(r,s,(a,c,u,d)=>{var h;a.isBlock&&c>r&&(l+=i);const f=o==null?void 0:o[a.type.name];if(f)return u&&(l+=f({node:a,pos:c,parent:u,index:d,range:e})),!1;a.isText&&(l+=(h=a==null?void 0:a.text)==null?void 0:h.slice(Math.max(r,c)-c,s-c))}),l}function iy(t,e){const n={from:0,to:t.content.size};return sy(t,n,e)}function xh(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function p2(t,e){const n=Le(e,t.schema),{from:r,to:s}=t.selection,i=[];t.doc.nodesBetween(r,s,l=>{i.push(l)});const o=i.reverse().find(l=>l.type.name===n.name);return o?{...o.attrs}:{}}function oy(t,e){const n=Ga(typeof e=="string"?e:e.name,t.schema);return n==="node"?p2(t,e):n==="mark"?Z0(t,e):{}}function m2(t,e=JSON.stringify){const n={};return t.filter(r=>{const s=e(r);return Object.prototype.hasOwnProperty.call(n,s)?!1:n[s]=!0})}function g2(t){const e=m2(t);return e.length===1?e:e.filter((n,r)=>!e.filter((i,o)=>o!==r).some(i=>n.oldRange.from>=i.oldRange.from&&n.oldRange.to<=i.oldRange.to&&n.newRange.from>=i.newRange.from&&n.newRange.to<=i.newRange.to))}function ly(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((s,i)=>{const o=[];if(s.ranges.length)s.forEach((l,a)=>{o.push({from:l,to:a})});else{const{from:l,to:a}=n[i];if(l===void 0||a===void 0)return;o.push({from:l,to:a})}o.forEach(({from:l,to:a})=>{const c=e.slice(i).map(l,-1),u=e.slice(i).map(a),d=e.invert().map(c,-1),h=e.invert().map(u);r.push({oldRange:{from:d,to:h},newRange:{from:c,to:u}})})}),g2(r)}function vh(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(s=>{const i=n.resolve(t),o=yh(i,s.type);o&&r.push({mark:s,...o})}):n.nodesBetween(t,e,(s,i)=>{!s||(s==null?void 0:s.nodeSize)===void 0||r.push(...s.marks.map(o=>({from:i,to:i+s.nodeSize,mark:o})))}),r}var y2=(t,e,n,r=20)=>{const s=t.doc.resolve(n);let i=r,o=null;for(;i>0&&o===null;){const l=s.node(i);(l==null?void 0:l.type.name)===e?o=l:i-=1}return[o,i]};function ei(t,e){return e.nodes[t]||e.marks[t]||null}function cl(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const s=t.find(i=>i.type===e&&i.name===r);return s?s.attribute.keepOnSplit:!1}))}var b2=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(s,i,o,l)=>{var a,c;const u=((c=(a=s.type.spec).toText)==null?void 0:c.call(a,{node:s,pos:i,parent:o,index:l}))||s.textContent||"%leaf%";n+=s.isAtom&&!s.isText?u:u.slice(0,Math.max(0,r-i))}),n};function Gu(t,e,n={}){const{empty:r,ranges:s}=t.selection,i=e?Bn(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(d=>i?i.name===d.type.name:!0).find(d=>Pl(d.attrs,n,{strict:!1}));let o=0;const l=[];if(s.forEach(({$from:d,$to:h})=>{const f=d.pos,p=h.pos;t.doc.nodesBetween(f,p,(g,y)=>{if(i&&g.inlineContent&&!g.type.allowsMarkType(i))return!1;if(!g.isText&&!g.marks.length)return;const b=Math.max(f,y),w=Math.min(p,y+g.nodeSize),v=w-b;o+=v,l.push(...g.marks.map(x=>({mark:x,from:b,to:w})))})}),o===0)return!1;const a=l.filter(d=>i?i.name===d.mark.type.name:!0).filter(d=>Pl(d.mark.attrs,n,{strict:!1})).reduce((d,h)=>d+h.to-h.from,0),c=l.filter(d=>i?d.mark.type!==i&&d.mark.type.excludes(i):!0).reduce((d,h)=>d+h.to-h.from,0);return(a>0?a+c:a)>=o}function w2(t,e,n={}){if(!e)return ur(t,null,n)||Gu(t,null,n);const r=Ga(e,t.schema);return r==="node"?ur(t,e,n):r==="mark"?Gu(t,e,n):!1}var x2=(t,e)=>{const{$from:n,$to:r,$anchor:s}=t.selection;if(e){const i=Ya(l=>l.type.name===e)(t.selection);if(!i)return!1;const o=t.doc.resolve(i.pos+1);return s.pos+1===o.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},v2=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function Kp(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function zc(t,e){const{nodeExtensions:n}=As(e),r=n.find(o=>o.name===t);if(!r)return!1;const s={name:r.name,options:r.options,storage:r.storage},i=he(G(r,"group",s));return typeof i!="string"?!1:i.split(" ").includes("list")}function Yi(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if(t.type.name==="hardBreak")return!0;if(t.isText)return!/\S/.test((r=t.text)!=null?r:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let s=!0;return t.content.forEach(i=>{s!==!1&&(Yi(i,{ignoreWhitespace:n,checkChildren:e})||(s=!1))}),s}return!1}function ay(t){return t instanceof Y}function k2({selection:t,pos:e,nodeSize:n,selectedOnTextSelection:r=!1}){const{from:s,to:i}=t;return!!(s<=e&&i>=e+n||r&&Ja(t)&&s>e&&i<e+n)}var kh=class cy{constructor(e){this.position=e}static fromJSON(e){return new cy(e.position)}toJSON(){return{position:this.position}}};function uy(t,e){const n=e.mapping.mapResult(t.position);return{position:new kh(n.pos),mapResult:n}}function S2(t){return new kh(t)}function dy(t,e,n){const s=t.state.doc.content.size,i=In(e,0,s),o=In(n,0,s),l=t.coordsAtPos(i),a=t.coordsAtPos(o,-1),c=Math.min(l.top,a.top),u=Math.max(l.bottom,a.bottom),d=Math.min(l.left,a.left),h=Math.max(l.right,a.right),f=h-d,p=u-c,b={top:c,bottom:u,left:d,right:h,width:f,height:p,x:d,y:c};return{...b,toJSON:()=>b}}function C2(t,e,n){var r;const{selection:s}=e;let i=null;if(Ja(s)&&(i=s.$cursor),i){const l=(r=t.storedMarks)!=null?r:i.marks();return i.parent.type.allowsMarkType(n)&&(!!n.isInSet(l)||!l.some(c=>c.type.excludes(n)))}const{ranges:o}=s;return o.some(({$from:l,$to:a})=>{let c=l.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(l.pos,a.pos,(u,d,h)=>{if(c)return!1;if(u.isInline){const f=!h||h.type.allowsMarkType(n),p=!!n.isInSet(u.marks)||!u.marks.some(g=>g.type.excludes(n));c=f&&p}return!c}),c})}var M2=(t,e={})=>({tr:n,state:r,dispatch:s})=>{const{selection:i}=n,{empty:o,ranges:l}=i,a=Bn(t,r.schema);if(s)if(o){const c=Z0(r,a);n.addStoredMark(a.create({...c,...e}))}else l.forEach(c=>{const u=c.$from.pos,d=c.$to.pos;r.doc.nodesBetween(u,d,(h,f)=>{const p=Math.max(f,u),g=Math.min(f+h.nodeSize,d);h.marks.find(b=>b.type===a)?h.marks.forEach(b=>{a===b.type&&n.addMark(p,g,a.create({...b.attrs,...e}))}):n.addMark(p,g,a.create(e))})});return C2(r,n,a)},A2=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),E2=(t,e={})=>({state:n,dispatch:r,chain:s})=>{const i=Le(t,n.schema);let o;return n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),i.isTextblock?s().command(({commands:l})=>op(i,{...o,...e})(n)?!0:l.clearNodes()).command(({state:l})=>op(i,{...o,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},T2=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,s=In(t,0,r.content.size),i=Y.create(r,s);e.setSelection(i)}return!0},_2=(t,e)=>({tr:n,state:r,dispatch:s})=>{const{selection:i}=r;let o,l;return typeof e=="number"?(o=e,l=e):e&&"from"in e&&"to"in e?(o=e.from,l=e.to):(o=i.from,l=i.to),s&&n.doc.nodesBetween(o,l,(a,c)=>{a.isText||n.setNodeMarkup(c,void 0,{...a.attrs,dir:t})}),!0},N2=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:s,to:i}=typeof t=="number"?{from:t,to:t}:t,o=ee.atStart(r).from,l=ee.atEnd(r).to,a=In(s,o,l),c=In(i,o,l),u=ee.create(r,a,c);e.setSelection(u)}return!0},O2=t=>({state:e,dispatch:n})=>{const r=Le(t,e.schema);return SC(r)(e,n)};function qp(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const r=n.filter(s=>e==null?void 0:e.includes(s.type.name));t.tr.ensureMarks(r)}}var I2=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:s})=>{const{selection:i,doc:o}=e,{$from:l,$to:a}=i,c=s.extensionManager.attributes,u=cl(c,l.node().type.name,l.node().attrs);if(i instanceof Y&&i.node.isBlock)return!l.parentOffset||!Dn(o,l.pos)?!1:(r&&(t&&qp(n,s.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const d=a.parentOffset===a.parent.content.size,h=l.depth===0?void 0:l2(l.node(-1).contentMatchAt(l.indexAfter(-1)));let f=d&&h?[{type:h,attrs:u}]:void 0,p=Dn(e.doc,e.mapping.map(l.pos),1,f);if(!f&&!p&&Dn(e.doc,e.mapping.map(l.pos),1,h?[{type:h}]:void 0)&&(p=!0,f=h?[{type:h,attrs:u}]:void 0),r){if(p&&(i instanceof ee&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,f),h&&!d&&!l.parentOffset&&l.parent.type!==h)){const g=e.mapping.map(l.before()),y=e.doc.resolve(g);l.node(-1).canReplaceWith(y.index(),y.index()+1,h)&&e.setNodeMarkup(e.mapping.map(l.before()),h)}t&&qp(n,s.extensionManager.splittableMarks),e.scrollIntoView()}return p},D2=(t,e={})=>({tr:n,state:r,dispatch:s,editor:i})=>{var o;const l=Le(t,r.schema),{$from:a,$to:c}=r.selection,u=r.selection.node;if(u&&u.isBlock||a.depth<2||!a.sameParent(c))return!1;const d=a.node(-1);if(d.type!==l)return!1;const h=i.extensionManager.attributes;if(a.parent.content.size===0&&a.node(-1).childCount===a.indexAfter(-1)){if(a.depth===2||a.node(-3).type!==l||a.index(-2)!==a.node(-2).childCount-1)return!1;if(s){let b=j.empty;const w=a.index(-1)?1:a.index(-2)?2:3;for(let O=a.depth-w;O>=a.depth-3;O-=1)b=j.from(a.node(O).copy(b));const v=a.indexAfter(-1)<a.node(-2).childCount?1:a.indexAfter(-2)<a.node(-3).childCount?2:3,x={...cl(h,a.node().type.name,a.node().attrs),...e},k=((o=l.contentMatch.defaultType)==null?void 0:o.createAndFill(x))||void 0;b=b.append(j.from(l.createAndFill(null,k)||void 0));const C=a.before(a.depth-(w-1));n.replace(C,a.after(-v),new q(b,4-w,0));let M=-1;n.doc.nodesBetween(C,n.doc.content.size,(O,_)=>{if(M>-1)return!1;O.isTextblock&&O.content.size===0&&(M=_+1)}),M>-1&&n.setSelection(ee.near(n.doc.resolve(M))),n.scrollIntoView()}return!0}const f=c.pos===a.end()?d.contentMatchAt(0).defaultType:null,p={...cl(h,d.type.name,d.attrs),...e},g={...cl(h,a.node().type.name,a.node().attrs),...e};n.delete(a.pos,c.pos);const y=f?[{type:l,attrs:p},{type:f,attrs:g}]:[{type:l,attrs:p}];if(!Dn(n.doc,a.pos,2))return!1;if(s){const{selection:b,storedMarks:w}=r,{splittableMarks:v}=i.extensionManager,x=w||b.$to.parentOffset&&b.$from.marks();if(n.split(a.pos,2,y).scrollIntoView(),!x||!s)return!0;const k=x.filter(C=>v.includes(C.type.name));n.ensureMarks(k)}return!0},$c=(t,e)=>{const n=Ya(o=>o.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;const s=t.doc.nodeAt(r);return n.node.type===(s==null?void 0:s.type)&&gr(t.doc,n.pos)&&t.join(n.pos),!0},Vc=(t,e)=>{const n=Ya(o=>o.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;const s=t.doc.nodeAt(r);return n.node.type===(s==null?void 0:s.type)&&gr(t.doc,r)&&t.join(r),!0};function R2(t){const e=t.doc,n=e.firstChild;if(!n)return null;const r=e.resolve(1),s=e.resolve(n.nodeSize-1);return ee.between(r,s)}var L2=(t,e,n,r={})=>({editor:s,tr:i,state:o,dispatch:l,chain:a,commands:c,can:u})=>{const{extensions:d,splittableMarks:h}=s.extensionManager,f=Le(t,o.schema),p=Le(e,o.schema),{selection:g,storedMarks:y}=o,{$from:b,$to:w}=g,v=b.blockRange(w),x=y||g.$to.parentOffset&&g.$from.marks();if(!v)return!1;const k=Ya(L=>zc(L.type.name,d))(g),C=g.from===0&&g.to===o.doc.content.size,M=o.doc.content.content,O=M.length===1?M[0]:null,_=C&&O&&zc(O.type.name,d)?{node:O,pos:0}:null,A=k??_,R=!!k&&v.depth>=1&&v.depth-k.depth<=1,D=!!_;if((R||D)&&A){if(A.node.type===f)return C&&D?a().command(({tr:L,dispatch:I})=>{const N=R2(L);return N?(L.setSelection(N),I&&I(L),!0):!1}).liftListItem(p).run():c.liftListItem(p);if(zc(A.node.type.name,d)&&f.validContent(A.node.content))return a().command(()=>(i.setNodeMarkup(A.pos,f),!0)).command(()=>$c(i,f)).command(()=>Vc(i,f)).run()}return!n||!x||!l?a().command(()=>u().wrapInList(f,r)?!0:c.clearNodes()).wrapInList(f,r).command(()=>$c(i,f)).command(()=>Vc(i,f)).run():a().command(()=>{const L=u().wrapInList(f,r),I=x.filter(N=>h.includes(N.type.name));return i.ensureMarks(I),L?!0:c.clearNodes()}).wrapInList(f,r).command(()=>$c(i,f)).command(()=>Vc(i,f)).run()},j2=(t,e={},n={})=>({state:r,commands:s})=>{const{extendEmptyMarkRange:i=!1}=n,o=Bn(t,r.schema);return Gu(r,o,e)?s.unsetMark(o,{extendEmptyMarkRange:i}):s.setMark(o,e)},P2=(t,e,n={})=>({state:r,commands:s})=>{const i=Le(t,r.schema),o=Le(e,r.schema),l=ur(r,i,n);let a;return r.selection.$anchor.sameParent(r.selection.$head)&&(a=r.selection.$anchor.parent.attrs),l?s.setNode(o,a):s.setNode(i,{...a,...n})},B2=(t,e={})=>({state:n,commands:r})=>{const s=Le(t,n.schema);return ur(n,s,e)?r.lift(s):r.wrapIn(s,e)},H2=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const s=n[r];let i;if(s.spec.isInputRules&&(i=s.getState(t))){if(e){const o=t.tr,l=i.transform;for(let a=l.steps.length-1;a>=0;a-=1)o.step(l.steps[a].invert(l.docs[a]));if(i.text){const a=o.doc.resolve(i.from).marks();o.replaceWith(i.from,i.to,t.schema.text(i.text,a))}else o.delete(i.from,i.to)}return!0}}return!1},z2=(t={})=>({tr:e,dispatch:n,editor:r})=>{const{ignoreClearable:s=!1}=t,{selection:i}=e,{empty:o,ranges:l}=i;if(o)return!0;const{nonClearableMarks:a}=r.extensionManager;if(n){const c=Object.values(r.schema.marks).filter(u=>s||!a.includes(u.name));l.forEach(u=>{for(const d of c)e.removeMark(u.$from.pos,u.$to.pos,d)})}return!0},$2=(t,e={})=>({tr:n,state:r,dispatch:s})=>{var i;const{extendEmptyMarkRange:o=!1}=e,{selection:l}=n,a=Bn(t,r.schema),{$from:c,empty:u,ranges:d}=l;if(!s)return!0;if(u&&o){let{from:h,to:f}=l;const p=(i=c.marks().find(y=>y.type===a))==null?void 0:i.attrs,g=yh(c,a,p);g&&(h=g.from,f=g.to),n.removeMark(h,f,a)}else d.forEach(h=>{n.removeMark(h.$from.pos,h.$to.pos,a)});return n.removeStoredMark(a),!0},V2=t=>({tr:e,state:n,dispatch:r})=>{const{selection:s}=n;let i,o;return typeof t=="number"?(i=t,o=t):t&&"from"in t&&"to"in t?(i=t.from,o=t.to):(i=s.from,o=s.to),r&&e.doc.nodesBetween(i,o,(l,a)=>{if(l.isText)return;const c={...l.attrs};delete c.dir,e.setNodeMarkup(a,void 0,c)}),!0},F2=(t,e={})=>({tr:n,state:r,dispatch:s})=>{let i=null,o=null;const l=Ga(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(i=Le(t,r.schema)),l==="mark"&&(o=Bn(t,r.schema));let a=!1;return n.selection.ranges.forEach(c=>{const u=c.$from.pos,d=c.$to.pos;let h,f,p,g;n.selection.empty?r.doc.nodesBetween(u,d,(y,b)=>{i&&i===y.type&&(a=!0,p=Math.max(b,u),g=Math.min(b+y.nodeSize,d),h=b,f=y)}):r.doc.nodesBetween(u,d,(y,b)=>{b<u&&i&&i===y.type&&(a=!0,p=Math.max(b,u),g=Math.min(b+y.nodeSize,d),h=b,f=y),b>=u&&b<=d&&(i&&i===y.type&&(a=!0,s&&n.setNodeMarkup(b,void 0,{...y.attrs,...e})),o&&y.marks.length&&y.marks.forEach(w=>{if(o===w.type&&(a=!0,s)){const v=Math.max(b,u),x=Math.min(b+y.nodeSize,d);n.addMark(v,x,o.create({...w.attrs,...e}))}}))}),f&&(h!==void 0&&s&&n.setNodeMarkup(h,void 0,{...f.attrs,...e}),o&&f.marks.length&&f.marks.forEach(y=>{o===y.type&&s&&n.addMark(p,g,o.create({...y.attrs,...e}))}))}),a},U2=(t,e={})=>({state:n,dispatch:r})=>{const s=Le(t,n.schema);return gC(s,e)(n,r)},W2=(t,e={})=>({state:n,dispatch:r})=>{const s=Le(t,n.schema);return yC(s,e)(n,r)},K2=class{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){const n=this.callbacks[t];return n&&n.forEach(r=>r.apply(this,e)),this}off(t,e){const n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter(r=>r!==e):delete this.callbacks[t]),this}once(t,e){const n=(...r)=>{this.off(t,n),e.apply(this,r)};return this.on(t,n)}removeAllListeners(){this.callbacks={}}},Xa=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},q2=(t,e)=>{if(gh(e))return e.exec(t);const n=e(t);if(!n)return null;const r=[n.text];return r.index=n.index,r.input=t,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};function Lo(t){var e;const{editor:n,from:r,to:s,text:i,rules:o,plugin:l}=t,{view:a}=n;if(a.composing)return!1;const c=a.state.doc.resolve(r);if(c.parent.type.spec.code||(e=c.nodeBefore||c.nodeAfter)!=null&&e.marks.find(h=>h.type.spec.code))return!1;let u=!1;const d=b2(c)+i;return o.forEach(h=>{if(u)return;const f=q2(d,h.find);if(!f)return;const p=a.state.tr,g=Ka({state:a.state,transaction:p}),y={from:r-(f[0].length-i.length),to:s},{commands:b,chain:w,can:v}=new qa({editor:n,state:g});h.handler({state:g,range:y,match:f,commands:b,chain:w,can:v})===null||!p.steps.length||(h.undoable&&p.setMeta(l,{transform:p,from:r,to:s,text:i}),a.dispatch(p),u=!0)}),u}function J2(t){const{editor:e,rules:n}=t,r=new ce({state:{init(){return null},apply(s,i,o){const l=s.getMeta(r);if(l)return l;const a=s.getMeta("applyInputRules");return!!a&&setTimeout(()=>{let{text:u}=a;typeof u=="string"?u=u:u=wh(j.from(u),o.schema);const{from:d}=a,h=d+u.length;Lo({editor:e,from:d,to:h,text:u,rules:n,plugin:r})}),s.selectionSet||s.docChanged?null:i}},props:{handleTextInput(s,i,o,l){return Lo({editor:e,from:i,to:o,text:l,rules:n,plugin:r})},handleDOMEvents:{compositionend:s=>(setTimeout(()=>{const{$cursor:i}=s.state.selection;i&&Lo({editor:e,from:i.pos,to:i.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(s,i){if(i.key!=="Enter")return!1;const{$cursor:o}=s.state.selection;return o?Lo({editor:e,from:o.pos,to:o.pos,text:`
|
|
29
|
+
`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function G2(t){return Object.prototype.toString.call(t).slice(8,-1)}function jo(t){return G2(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function hy(t,e){const n={...t};return jo(t)&&jo(e)&&Object.keys(e).forEach(r=>{jo(e[r])&&jo(t[r])?n[r]=hy(t[r],e[r]):n[r]=e[r]}),n}var Sh=class{constructor(t={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...t},this.name=this.config.name}get options(){return{...he(G(this,"addOptions",{name:this.name}))}}get storage(){return{...he(G(this,"addStorage",{name:this.name,options:this.options}))}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>hy(this.options,t)});return e.name=this.name,e.parent=this.parent,this.child=null,e}extend(t={}){const e=new this.constructor({...this.config,...t});return e.parent=this,this.child=e,e.name="name"in t?t.name:e.parent.name,e}},Hn=class fy extends Sh{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new fy(n)}static handleExit({editor:e,mark:n}){const{tr:r}=e.state,s=e.state.selection.$from;if(s.pos===s.end()){const o=s.marks();if(!!!o.find(c=>(c==null?void 0:c.type.name)===n.name))return!1;const a=o.find(c=>(c==null?void 0:c.type.name)===n.name);return a&&r.removeStoredMark(a),r.insertText(" ",s.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function Y2(t){return typeof t=="number"}var X2=class{constructor(t){this.find=t.find,this.handler=t.handler}},Z2=(t,e,n)=>{if(gh(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.map(s=>{const i=[s.text];return i.index=s.index,i.input=t,i.data=s.data,s.replaceWith&&(s.text.includes(s.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),i.push(s.replaceWith)),i}):[]};function Q2(t){const{editor:e,state:n,from:r,to:s,rule:i,pasteEvent:o,dropEvent:l}=t,{commands:a,chain:c,can:u}=new qa({editor:e,state:n}),d=[];return n.doc.nodesBetween(r,s,(f,p)=>{var g,y,b,w,v;if((y=(g=f.type)==null?void 0:g.spec)!=null&&y.code||!(f.isText||f.isTextblock||f.isInline))return;const x=(v=(w=(b=f.content)==null?void 0:b.size)!=null?w:f.nodeSize)!=null?v:0,k=Math.max(r,p),C=Math.min(s,p+x);if(k>=C)return;const M=f.isText?f.text||"":f.textBetween(k-p,C-p,void 0,"");Z2(M,i.find,o).forEach(_=>{if(_.index===void 0)return;const A=k+_.index+1,R=A+_[0].length,D={from:n.tr.mapping.map(A),to:n.tr.mapping.map(R)},L=i.handler({state:n,range:D,match:_,commands:a,chain:c,can:u,pasteEvent:o,dropEvent:l});d.push(L)})}),d.every(f=>f!==null)}var Po=null,eE=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function tE(t){const{editor:e,rules:n}=t;let r=null,s=!1,i=!1,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}const a=({state:u,from:d,to:h,rule:f,pasteEvt:p})=>{const g=u.tr,y=Ka({state:u,transaction:g});if(!(!Q2({editor:e,state:y,from:Math.max(d-1,0),to:h.b-1,rule:f,pasteEvent:p,dropEvent:l})||!g.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,g}};return n.map(u=>new ce({view(d){const h=p=>{var g;r=(g=d.dom.parentElement)!=null&&g.contains(p.target)?d.dom.parentElement:null,r&&(Po=e)},f=()=>{Po&&(Po=null)};return window.addEventListener("dragstart",h),window.addEventListener("dragend",f),{destroy(){window.removeEventListener("dragstart",h),window.removeEventListener("dragend",f)}}},props:{handleDOMEvents:{drop:(d,h)=>{if(i=r===d.dom.parentElement,l=h,!i){const f=Po;f!=null&&f.isEditable&&setTimeout(()=>{const p=f.state.selection;p&&f.commands.deleteRange({from:p.from,to:p.to})},10)}return!1},paste:(d,h)=>{var f;const p=(f=h.clipboardData)==null?void 0:f.getData("text/html");return o=h,s=!!(p!=null&&p.includes("data-pm-slice")),!1}}},appendTransaction:(d,h,f)=>{const p=d[0],g=p.getMeta("uiEvent")==="paste"&&!s,y=p.getMeta("uiEvent")==="drop"&&!i,b=p.getMeta("applyPasteRules"),w=!!b;if(!g&&!y&&!w)return;if(w){let{text:k}=b;typeof k=="string"?k=k:k=wh(j.from(k),f.schema);const{from:C}=b,M=C+k.length,O=eE(k);return a({rule:u,state:f,from:C,to:{b:M},pasteEvt:O})}const v=h.doc.content.findDiffStart(f.doc.content),x=h.doc.content.findDiffEnd(f.doc.content);if(!(!Y2(v)||!x||v===x.b))return a({rule:u,state:f,from:v,to:x,pasteEvt:o})}}))}var Za=class{constructor(t,e){this.splittableMarks=[],this.nonClearableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=ry(t),this.schema=h2(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((t,e)=>{const n={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:ei(e.name,this.schema)},r=G(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return _i([...this.extensions].reverse()).flatMap(r=>{const s={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:ei(r.name,this.schema)},i=[],o=G(r,"addKeyboardShortcuts",s);let l={};if(r.type==="mark"&&G(r,"exitable",s)&&(l.ArrowRight=()=>Hn.handleExit({editor:t,mark:r})),o){const h=Object.fromEntries(Object.entries(o()).map(([f,p])=>[f,()=>p({editor:t})]));l={...l,...h}}const a=fA(l);i.push(a);const c=G(r,"addInputRules",s);if(Kp(r,t.options.enableInputRules)&&c){const h=c();if(h&&h.length){const f=J2({editor:t,rules:h}),p=Array.isArray(f)?f:[f];i.push(...p)}}const u=G(r,"addPasteRules",s);if(Kp(r,t.options.enablePasteRules)&&u){const h=u();if(h&&h.length){const f=tE({editor:t,rules:h});i.push(...f)}}const d=G(r,"addProseMirrorPlugins",s);if(d){const h=d();i.push(...h)}return i})}get attributes(){return ny(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=As(this.extensions);return Object.fromEntries(e.filter(n=>!!G(n,"addNodeView")).map(n=>{const r=this.attributes.filter(a=>a.type===n.name),s={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Le(n.name,this.schema)},i=G(n,"addNodeView",s);if(!i)return[];const o=i();if(!o)return[];const l=(a,c,u,d,h)=>{const f=Es(a,r);return o({node:a,view:c,getPos:u,decorations:d,innerDecorations:h,editor:t,extension:n,HTMLAttributes:f})};return[n.name,l]}))}dispatchTransaction(t){const{editor:e}=this;return _i([...this.extensions].reverse()).reduceRight((r,s)=>{const i={name:s.name,options:s.options,storage:this.editor.extensionStorage[s.name],editor:e,type:ei(s.name,this.schema)},o=G(s,"dispatchTransaction",i);return o?l=>{o.call(i,{transaction:l,next:r})}:r},t)}transformPastedHTML(t){const{editor:e}=this;return _i([...this.extensions]).reduce((r,s)=>{const i={name:s.name,options:s.options,storage:this.editor.extensionStorage[s.name],editor:e,type:ei(s.name,this.schema)},o=G(s,"transformPastedHTML",i);return o?(l,a)=>{const c=r(l,a);return o.call(i,c)}:r},t||(r=>r))}get markViews(){const{editor:t}=this,{markExtensions:e}=As(this.extensions);return Object.fromEntries(e.filter(n=>!!G(n,"addMarkView")).map(n=>{const r=this.attributes.filter(l=>l.type===n.name),s={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Bn(n.name,this.schema)},i=G(n,"addMarkView",s);if(!i)return[];const o=(l,a,c)=>{const u=Es(l,r);return i()({mark:l,view:a,inline:c,editor:t,extension:n,HTMLAttributes:u,updateAttributes:d=>{gE(l,t,d)}})};return[n.name,o]}))}destroy(){this.extensions.forEach(t=>{let e=t;for(;e.parent;){const n=e.parent;n.child===e&&(n.child=null),e=n}}),this.extensions=[],this.baseExtensions=[],this.schema=null,this.editor=null}setupExtensions(){const t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(e=>[e.name,e.storage])),t.forEach(e=>{var n,r;const s={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:ei(e.name,this.schema)};e.type==="mark"&&(((n=he(G(e,"keepOnSplit",s)))==null||n)&&this.splittableMarks.push(e.name),(r=he(G(e,"clearable",s)))==null||r||this.nonClearableMarks.push(e.name));const i=G(e,"onBeforeCreate",s),o=G(e,"onCreate",s),l=G(e,"onUpdate",s),a=G(e,"onSelectionUpdate",s),c=G(e,"onTransaction",s),u=G(e,"onFocus",s),d=G(e,"onBlur",s),h=G(e,"onDestroy",s);i&&this.editor.on("beforeCreate",i),o&&this.editor.on("create",o),l&&this.editor.on("update",l),a&&this.editor.on("selectionUpdate",a),c&&this.editor.on("transaction",c),u&&this.editor.on("focus",u),d&&this.editor.on("blur",d),h&&this.editor.on("destroy",h)})}};Za.resolve=ry;Za.sort=_i;Za.flatten=bh;var nE={};mh(nE,{ClipboardTextSerializer:()=>my,Commands:()=>gy,Delete:()=>yy,Drop:()=>by,Editable:()=>wy,FocusEvents:()=>vy,Keymap:()=>ky,Paste:()=>Sy,Tabindex:()=>Cy,TextDirection:()=>My,focusEventsPluginKey:()=>xy});var ie=class py extends Sh{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new py(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},my=ie.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new ce({key:new ae("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:s}=e,i=xh(n),{blockSeparator:o}=this.options,l={...o!==void 0?{blockSeparator:o}:{},textSerializers:i};return[...s.ranges].sort((c,u)=>c.$from.pos-u.$from.pos).map(({$from:c,$to:u})=>sy(r,{from:c.pos,to:u.pos},l)).join(o??`
|
|
30
30
|
|
|
31
|
-
`)}}})]}}),
|
|
31
|
+
`)}}})]}}),gy=ie.create({name:"commands",addCommands(){return{...q0}}}),yy=ie.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,s;const i=()=>{var o,l,a,c;if((c=(a=(l=(o=this.editor.options.coreExtensionOptions)==null?void 0:o.delete)==null?void 0:l.filterTransaction)==null?void 0:a.call(l,t))!=null?c:t.getMeta("y-sync$"))return;const u=Q0(t.before,[t,...e]);ly(u).forEach(f=>{u.mapping.mapResult(f.oldRange.from).deletedAfter&&u.mapping.mapResult(f.oldRange.to).deletedBefore&&u.before.nodesBetween(f.oldRange.from,f.oldRange.to,(p,g)=>{const y=g+p.nodeSize-2,b=f.oldRange.from<=g&&y<=f.oldRange.to;this.editor.emit("delete",{type:"node",node:p,from:g,to:y,newFrom:u.mapping.map(g),newTo:u.mapping.map(y),deletedRange:f.oldRange,newRange:f.newRange,partial:!b,editor:this.editor,transaction:t,combinedTransform:u})})});const h=u.mapping;u.steps.forEach((f,p)=>{var g,y;if(f instanceof zs){const b=h.slice(p).map(f.from,-1),w=h.slice(p).map(f.to),v=h.invert().map(b,-1),x=h.invert().map(w),k=b>0?(g=u.doc.nodeAt(b-1))==null?void 0:g.marks.some(M=>M.eq(f.mark)):!1,C=(y=u.doc.nodeAt(w))==null?void 0:y.marks.some(M=>M.eq(f.mark));this.editor.emit("delete",{type:"mark",mark:f.mark,from:f.from,to:f.to,deletedRange:{from:v,to:x},newRange:{from:b,to:w},partial:!!(C||k),editor:this.editor,transaction:t,combinedTransform:u})}})};(s=(r=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:r.async)==null||s?setTimeout(i,0):i()}}),by=ie.create({name:"drop",addProseMirrorPlugins(){return[new ce({key:new ae("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),wy=ie.create({name:"editable",addProseMirrorPlugins(){return[new ce({key:new ae("editable"),props:{editable:()=>this.editor.options.editable}})]}}),xy=new ae("focusEvents"),vy=ie.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new ce({key:xy,props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;const r=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,n)=>{t.isFocused=!1;const r=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),ky=ie.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:l})=>{const{selection:a,doc:c}=l,{empty:u,$anchor:d}=a,{pos:h,parent:f}=d,p=d.parent.isTextblock&&h>0?l.doc.resolve(h-1):d,g=p.parent.type.spec.isolating,y=d.pos-d.parentOffset,b=g&&p.parent.childCount===1?y===d.pos:te.atStart(c).from===h;return!u||!f.type.isTextblock||f.textContent.length||!b||b&&d.parent.type.name==="paragraph"?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},s={...r},i={...r,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Ji()||X0()?i:s},addProseMirrorPlugins(){return[new ce({key:new ae("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(g=>g.getMeta("composition")))return;const r=t.some(g=>g.docChanged)&&!e.doc.eq(n.doc),s=t.some(g=>g.getMeta("preventClearDocument"));if(!r||s)return;const{empty:i,from:o,to:l}=e.selection,a=te.atStart(e.doc).from,c=te.atEnd(e.doc).to;if(i||!(o===a&&l===c)||!Yi(n.doc))return;const h=n.tr,f=Ka({state:n,transaction:h}),{commands:p}=new qa({editor:this.editor,state:f});if(p.clearNodes(),!!h.steps.length)return h}})]}}),Sy=ie.create({name:"paste",addProseMirrorPlugins(){return[new ce({key:new ae("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),Cy=ie.create({name:"tabindex",addOptions(){return{value:void 0}},addProseMirrorPlugins(){return[new ce({key:new ae("tabindex"),props:{attributes:()=>{var t;return!this.editor.isEditable&&this.options.value===void 0?{}:{tabindex:(t=this.options.value)!=null?t:"0"}}}})]}}),My=ie.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=As(this.extensions);return[{types:t.filter(e=>e.name!=="text").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{const n=e.getAttribute("dir");return n&&(n==="ltr"||n==="rtl"||n==="auto")?n:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new ce({key:new ae("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),rE=class pi{constructor(e,n,r=!1,s=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=n,this.currentNode=s}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!=null?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let n=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}n=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:n,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(e);return new pi(n,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new pi(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new pi(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,r)=>{const s=n.isBlock&&!n.isTextblock,i=n.isAtom&&!n.isText,o=n.isInline,l=this.pos+r+(i?0:1);if(l<0||l>this.resolvedPos.doc.nodeSize-2)return;const a=this.resolvedPos.doc.resolve(l);if(!s&&!o&&a.depth<=this.depth)return;const c=new pi(a,this.editor,s,s||o?n:null);s&&(c.actualDepth=this.depth+1),e.push(c)}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,n={}){let r=null,s=this.parent;for(;s&&!r;){if(s.node.type.name===e)if(Object.keys(n).length>0){const i=s.node.attrs,o=Object.keys(n);for(let l=0;l<o.length;l+=1){const a=o[l];if(i[a]!==n[a])break}}else r=s;s=s.parent}return r}querySelector(e,n={}){return this.querySelectorAll(e,n,!0)[0]||null}querySelectorAll(e,n={},r=!1){let s=[];if(!this.children||this.children.length===0)return s;const i=Object.keys(n);return this.children.forEach(o=>{r&&s.length>0||(o.node.type.name===e&&i.every(a=>n[a]===o.node.attrs[a])&&s.push(o),!(r&&s.length>0)&&(s=s.concat(o.querySelectorAll(e,n,r))))}),s}setAttribute(e){const{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}},sE=`.ProseMirror {
|
|
32
32
|
position: relative;
|
|
33
33
|
}
|
|
34
34
|
|
|
@@ -98,26 +98,26 @@ img.ProseMirror-separator {
|
|
|
98
98
|
|
|
99
99
|
.ProseMirror-focused .ProseMirror-gapcursor {
|
|
100
100
|
display: block;
|
|
101
|
-
}`;function
|
|
101
|
+
}`;function Ay(t,e,n){const r=document.querySelector(`style[data-tiptap-style${n?`-${n}`:""}]`);if(r!==null)return r;const s=document.createElement("style");return e&&s.setAttribute("nonce",e),s.setAttribute(`data-tiptap-style${n?`-${n}`:""}`,""),s.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(s),s}var iE=class extends K2{constructor(e={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.destroyed=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:s})=>{throw s},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:uy,createMappablePosition:S2},this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:s,slice:i,moved:o})=>this.options.onDrop(s,i,o)),this.on("paste",({event:s,slice:i})=>this.options.onPaste(s,i)),this.on("delete",this.options.onDelete);const n=this.createDoc(),r=G0(n,this.options.autofocus);this.editorState=ps.create({doc:n,schema:this.schema,selection:r||void 0}),this.options.element&&this.mount(this.options.element)}mount(e){if(typeof document>"u")throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(e),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){const e=this.editorView.dom;e!=null&&e.editor&&delete e.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove=="function"?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(e){console.warn("Failed to remove CSS element:",e)}this.css=null,this.emit("unmount",{editor:this})}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&&typeof document<"u"&&(this.css=Ay(sE,this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(e,n=!0){this.setOptions({editable:e}),n&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:e=>{this.editorState=e},dispatch:e=>{this.dispatchTransaction(e)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(e,n)=>{if(this.editorView)return this.editorView[n];if(n==="state")return this.editorState;if(n in e)return Reflect.get(e,n);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${n}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(e,n){const r=ty(n)?n(e,[...this.state.plugins]):[...this.state.plugins,e],s=this.state.reconfigure({plugins:r});return this.view.updateState(s),s}unregisterPlugin(e){if(this.isDestroyed)return;const n=this.state.plugins;let r=n;if([].concat(e).forEach(i=>{const o=typeof i=="string"?`${i}$`:i.key;r=r.filter(l=>!l.key.startsWith(o))}),n.length===r.length)return;const s=this.state.reconfigure({plugins:r});return this.view.updateState(s),s}createExtensionManager(){var e,n,r,s;const o=[...this.options.enableCoreExtensions?[wy,my.configure({blockSeparator:(n=(e=this.options.coreExtensionOptions)==null?void 0:e.clipboardTextSerializer)==null?void 0:n.blockSeparator}),gy,vy,ky,Cy.configure({value:(s=(r=this.options.coreExtensionOptions)==null?void 0:r.tabindex)==null?void 0:s.value}),by,Sy,yy,My.configure({direction:this.options.textDirection})].filter(l=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[l.name]!==!1:!0):[],...this.options.extensions].filter(l=>["extension","node","mark"].includes(l==null?void 0:l.type));this.extensionManager=new Za(o,this)}createCommandManager(){this.commandManager=new qa({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let e;try{e=Ju(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(n){if(!(n instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(n.message))throw n;this.emit("contentError",{editor:this,error:n,disableCollaboration:()=>{"collaboration"in this.storage&&typeof this.storage.collaboration=="object"&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(r=>r.name!=="collaboration"),this.createExtensionManager()}}),e=Ju(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return e}createView(e){const{editorProps:n,enableExtensionDispatchTransaction:r}=this.options,s=n.dispatchTransaction||this.dispatchTransaction.bind(this),i=r?this.extensionManager.dispatchTransaction(s):s,o=n.transformPastedHTML,l=this.extensionManager.transformPastedHTML(o);this.editorView=new K0(e,{...n,attributes:{role:"textbox",...n==null?void 0:n.attributes},dispatchTransaction:i,transformPastedHTML:l,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const a=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(a),this.prependClass(),this.injectCSS();const c=this.view.dom;c.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;const n=this.capturedTransaction;return this.capturedTransaction=null,n}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=e;return}e.steps.forEach(u=>{var d;return(d=this.capturedTransaction)==null?void 0:d.step(u)});return}const{state:n,transactions:r}=this.state.applyTransaction(e),s=!this.state.selection.eq(n.selection),i=r.includes(e),o=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:e,nextState:n}),!i)return;this.view.updateState(n),this.emit("transaction",{editor:this,transaction:e,appendedTransactions:r.slice(1)}),s&&this.emit("selectionUpdate",{editor:this,transaction:e});const l=r.findLast(u=>u.getMeta("focus")||u.getMeta("blur")),a=l==null?void 0:l.getMeta("focus"),c=l==null?void 0:l.getMeta("blur");a&&this.emit("focus",{editor:this,event:a.event,transaction:l}),c&&this.emit("blur",{editor:this,event:c.event,transaction:l}),!(e.getMeta("preventUpdate")||!r.some(u=>u.docChanged)||o.doc.eq(n.doc))&&this.emit("update",{editor:this,transaction:e,appendedTransactions:r.slice(1)})}getAttributes(e){return oy(this.state,e)}isActive(e,n){const r=typeof e=="string"?e:null,s=typeof e=="string"?n:e;return w2(this.state,r,s)}getJSON(){return this.state.doc.toJSON()}getHTML(){return wh(this.state.doc.content,this.schema)}getText(e){const{blockSeparator:n=`
|
|
102
102
|
|
|
103
|
-
`,textSerializers:r={}}=e||{};return
|
|
103
|
+
`,textSerializers:r={}}=e||{};return iy(this.state.doc,{blockSeparator:n,textSerializers:{...xh(this.schema),...r}})}get isEmpty(){return Yi(this.state.doc)}destroy(){this.destroyed||(this.destroyed=!0,this.emit("destroy"),this.unmount(),this.removeAllListeners(),this.extensionManager.destroy(),this.extensionManager=null,this.schema=null,this.commandManager=null,this.extensionStorage={})}get isDestroyed(){var e,n;return(n=(e=this.editorView)==null?void 0:e.isDestroyed)!=null?n:!0}$node(e,n){var r;return((r=this.$doc)==null?void 0:r.querySelector(e,n))||null}$nodes(e,n){var r;return((r=this.$doc)==null?void 0:r.querySelectorAll(e,n))||null}$pos(e){const n=this.state.doc.resolve(e),r=e>0&&n.nodeAfter&&!n.nodeAfter.isText?n.nodeAfter:null;return new rE(n,this,!1,r)}get $doc(){return this.$pos(0)}};function Vr(t){return new Xa({find:t.find,handler:({state:e,range:n,match:r})=>{const s=he(t.getAttributes,void 0,r);if(s===!1||s===null)return null;const{tr:i}=e,o=r[r.length-1],l=r[0];if(o){const a=l.search(/\S/),c=n.from+l.indexOf(o),u=c+o.length;if(vh(n.from,n.to,e.doc).filter(f=>f.mark.type.excluded.find(g=>g===t.type&&g!==f.mark.type)).filter(f=>f.to>c).length)return null;u<n.to&&i.delete(u,n.to),c>n.from&&i.delete(n.from+a,c);const h=n.from+a+o.length;i.addMark(n.from+a,h,t.type.create(s||{})),i.removeStoredMark(t.type)}},undoable:t.undoable})}function oE(t){return new Xa({find:t.find,handler:({state:e,range:n,match:r})=>{const s=he(t.getAttributes,void 0,r)||{},{tr:i}=e,o=n.from;let l=n.to;const a=t.type.create(s);if(r[1]){const c=r[0].lastIndexOf(r[1]);let u=o+c;u>l?u=l:l=u+r[1].length;const d=r[0][r[0].length-1];i.insertText(d,o+r[0].length-1),i.replaceWith(u,l,a)}else if(r[0]){const c=t.type.isInline?o:o-1;i.insert(c,t.type.create(s)).delete(i.mapping.map(o),i.mapping.map(l))}i.scrollIntoView()},undoable:t.undoable})}function Yu(t){return new Xa({find:t.find,handler:({state:e,range:n,match:r})=>{const s=e.doc.resolve(n.from),i=he(t.getAttributes,void 0,r)||{};if(!s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,i)},undoable:t.undoable})}function Ts(t){return new Xa({find:t.find,handler:({state:e,range:n,match:r,chain:s})=>{const i=he(t.getAttributes,void 0,r)||{},o=e.tr.delete(n.from,n.to),a=o.doc.resolve(n.from).blockRange(),c=a&&Zd(a,t.type,i);if(!c)return null;if(o.wrap(a,c),t.keepMarks&&t.editor){const{selection:d,storedMarks:h}=e,{splittableMarks:f}=t.editor.extensionManager,p=h||d.$to.parentOffset&&d.$from.marks();if(p){const g=p.filter(y=>f.includes(y.type.name));o.ensureMarks(g)}}if(t.keepAttributes){const d=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";s().updateAttributes(d,i).run()}const u=o.doc.resolve(n.from-1).nodeBefore;u&&u.type===t.type&&gr(o.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,u))&&o.join(n.from-1)},undoable:t.undoable})}function lE(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof Y){const i=r.index();return r.parent.canReplaceWith(i,i+1,e)}let s=r.depth;for(;s>=0;){const i=r.index(s);if(r.node(s).contentMatchAt(i).matchType(e))return!0;s-=1}return!1}function aE(t){return t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}function Vs(t,e){const n=t.getAttribute("style");if(!n)return null;const r=n.split(";").map(i=>i.trim()).filter(Boolean),s=e.toLowerCase();for(let i=r.length-1;i>=0;i-=1){const o=r[i],l=o.indexOf(":");if(l===-1)continue;if(o.slice(0,l).trim().toLowerCase()===s)return o.slice(l+1).trim()}return null}function cE(){return typeof navigator<"u"?/Firefox/.test(navigator.userAgent):!1}var uE={};mh(uE,{createAtomBlockMarkdownSpec:()=>dE,createBlockMarkdownSpec:()=>hE,createInlineMarkdownSpec:()=>mE,parseAttributes:()=>Ch,parseIndentedBlocks:()=>Xu,renderNestedMarkdownContent:()=>Ah,serializeAttributes:()=>Mh});function Ch(t){if(!(t!=null&&t.trim()))return{};const e={},n=[],r=t.replace(/["']([^"']*)["']/g,c=>(n.push(c),`__QUOTED_${n.length-1}__`)),s=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(s){const c=s.map(u=>u.trim().slice(1));e.class=c.join(" ")}const i=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);i&&(e.id=i[1]);const o=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(o)).forEach(([,c,u])=>{var d;const h=parseInt(((d=u.match(/__QUOTED_(\d+)__/))==null?void 0:d[1])||"0",10),f=n[h];f&&(e[c]=f.slice(1,-1))});const a=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return a&&a.split(/\s+/).filter(Boolean).forEach(u=>{u.match(/^[a-zA-Z][\w-]*$/)&&(e[u]=!0)}),e}function Mh(t){if(!t||Object.keys(t).length===0)return"";const e=[];return t.class&&String(t.class).split(/\s+/).filter(Boolean).forEach(r=>e.push(`.${r}`)),t.id&&e.push(`#${t.id}`),Object.entries(t).forEach(([n,r])=>{n==="class"||n==="id"||(r===!0?e.push(n):r!==!1&&r!=null&&e.push(`${n}="${String(r)}"`))}),e.join(" ")}function dE(t){const{nodeName:e,name:n,parseAttributes:r=Ch,serializeAttributes:s=Mh,defaultAttributes:i={},requiredAttributes:o=[],allowedAttributes:l}=t,a=n||e,c=u=>{if(!l)return u;const d={};return l.forEach(h=>{h in u&&(d[h]=u[h])}),d};return{parseMarkdown:(u,d)=>{const h={...i,...u.attributes};return d.createNode(e,h,[])},markdownTokenizer:{name:e,level:"block",start(u){var d;const h=new RegExp(`^:::${a}(?:\\s|$)`,"m"),f=(d=u.match(h))==null?void 0:d.index;return f!==void 0?f:-1},tokenize(u,d,h){const f=new RegExp(`^:::${a}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),p=u.match(f);if(!p)return;const g=p[1]||"",y=r(g);if(!o.find(w=>!(w in y)))return{type:e,raw:p[0],attributes:y}}},renderMarkdown:u=>{const d=c(u.attrs||{}),h=s(d),f=h?` {${h}}`:"";return`:::${a}${f} :::`}}}function hE(t){const{nodeName:e,name:n,getContent:r,parseAttributes:s=Ch,serializeAttributes:i=Mh,defaultAttributes:o={},content:l="block",allowedAttributes:a}=t,c=n||e,u=d=>{if(!a)return d;const h={};return a.forEach(f=>{f in d&&(h[f]=d[f])}),h};return{parseMarkdown:(d,h)=>{let f;if(r){const g=r(d);f=typeof g=="string"?[{type:"text",text:g}]:g}else l==="block"?f=h.parseChildren(d.tokens||[]):f=h.parseInline(d.tokens||[]);const p={...o,...d.attributes};return h.createNode(e,p,f)},markdownTokenizer:{name:e,level:"block",start(d){var h;const f=new RegExp(`^:::${c}`,"m"),p=(h=d.match(f))==null?void 0:h.index;return p!==void 0?p:-1},tokenize(d,h,f){var p;const g=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),y=d.match(g);if(!y)return;const[b,w=""]=y,v=s(w);let x=1;const k=b.length;let C="";const M=/^:::([\w-]*)(\s.*)?/gm,O=d.slice(k);for(M.lastIndex=0;;){const _=M.exec(O);if(_===null)break;const A=_.index,R=_[1];if(!((p=_[2])!=null&&p.endsWith(":::"))){if(R)x+=1;else if(x-=1,x===0){const D=O.slice(0,A);C=D.trim();const L=d.slice(0,k+A+_[0].length);let I=[];if(C)if(l==="block")for(I=f.blockTokens(D),I.forEach(N=>{N.text&&(!N.tokens||N.tokens.length===0)&&(N.tokens=f.inlineTokens(N.text))});I.length>0;){const N=I[I.length-1];if(N.type==="paragraph"&&(!N.text||N.text.trim()===""))I.pop();else break}else I=f.inlineTokens(C);return{type:e,raw:L,attributes:v,content:C,tokens:I}}}}}},renderMarkdown:(d,h)=>{const f=u(d.attrs||{}),p=i(f),g=p?` {${p}}`:"",y=h.renderChildren(d.content||[],`
|
|
104
104
|
|
|
105
105
|
`);return`:::${c}${g}
|
|
106
106
|
|
|
107
107
|
${y}
|
|
108
108
|
|
|
109
|
-
:::`}}}function
|
|
110
|
-
`),a=[];let c="",u=0;const d=e.baseIndentSize||2;for(;u<l.length;){const
|
|
111
|
-
`;continue}else return}const p=e.extractItemData(
|
|
112
|
-
`;const b=[y];for(u+=1;u<l.length;){const k=l[u];if(k.trim()===""){const
|
|
109
|
+
:::`}}}function fE(t){if(!t.trim())return{};const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(t);for(;r!==null;){const[,s,i,o]=r;e[s]=i||o,r=n.exec(t)}return e}function pE(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function mE(t){const{nodeName:e,name:n,getContent:r,parseAttributes:s=fE,serializeAttributes:i=pE,defaultAttributes:o={},selfClosing:l=!1,allowedAttributes:a}=t,c=n||e,u=h=>{if(!a)return h;const f={};return a.forEach(p=>{const g=typeof p=="string"?p:p.name,y=typeof p=="string"?void 0:p.skipIfDefault;if(g in h){const b=h[g];if(y!==void 0&&b===y)return;f[g]=b}}),f},d=c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(h,f)=>{const p={...o,...h.attributes};if(l)return f.createNode(e,p);const g=r?r(h):h.content||"";return g?f.createNode(e,p,[f.createTextNode(g)]):f.createNode(e,p,[])},markdownTokenizer:{name:e,level:"inline",start(h){const f=l?new RegExp(`\\[${d}\\s*[^\\]]*\\]`):new RegExp(`\\[${d}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${d}\\]`),p=h.match(f),g=p==null?void 0:p.index;return g!==void 0?g:-1},tokenize(h,f,p){const g=l?new RegExp(`^\\[${d}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${d}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${d}\\]`),y=h.match(g);if(!y)return;let b="",w="";if(l){const[,x]=y;w=x}else{const[,x,k]=y;w=x,b=k||""}const v=s(w.trim());return{type:e,raw:y[0],content:b.trim(),attributes:v}}},renderMarkdown:h=>{let f="";r?f=r(h):h.content&&h.content.length>0&&(f=h.content.filter(b=>b.type==="text").map(b=>b.text).join(""));const p=u(h.attrs||{}),g=i(p),y=g?` ${g}`:"";return l?`[${c}${y}]`:`[${c}${y}]${f}[/${c}]`}}}function Xu(t,e,n){var r,s,i,o;const l=t.split(`
|
|
110
|
+
`),a=[];let c="",u=0;const d=e.baseIndentSize||2;for(;u<l.length;){const h=l[u],f=h.match(e.itemPattern);if(!f){if(a.length>0)break;if(h.trim()===""){u+=1,c=`${c}${h}
|
|
111
|
+
`;continue}else return}const p=e.extractItemData(f),{indentLevel:g,mainContent:y}=p;c=`${c}${h}
|
|
112
|
+
`;const b=[y];for(u+=1;u<l.length;){const k=l[u];if(k.trim()===""){const M=l.slice(u+1).findIndex(A=>A.trim()!=="");if(M===-1)break;if((((s=(r=l[u+1+M].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:s.length)||0)>g){b.push(k),c=`${c}${k}
|
|
113
113
|
`,u+=1;continue}else break}if((((o=(i=k.match(/^(\s*)/))==null?void 0:i[1])==null?void 0:o.length)||0)>g)b.push(k),c=`${c}${k}
|
|
114
114
|
`,u+=1;else break}let w;const v=b.slice(1);if(v.length>0){const k=v.map(C=>C.slice(g+d)).join(`
|
|
115
|
-
`);k.trim()&&(e.customNestedParser?w=e.customNestedParser(k):w=n.blockTokens(k))}const x=e.createToken(p,w);a.push(x)}if(a.length!==0)return{items:a,raw:c}}function
|
|
115
|
+
`);k.trim()&&(e.customNestedParser?w=e.customNestedParser(k):w=n.blockTokens(k))}const x=e.createToken(p,w);a.push(x)}if(a.length!==0)return{items:a,raw:c}}function Ah(t,e,n,r){if(!t||!Array.isArray(t.content))return"";const s=typeof n=="function"?n(r):n,[i,...o]=t.content,l=e.renderChildren([i]);let a=`${s}${l}`;return o&&o.length>0&&o.forEach((c,u)=>{var d,h;const f=(h=(d=e.renderChild)==null?void 0:d.call(e,c,u+1))!=null?h:e.renderChildren([c]);if(f!=null){const p=f.split(`
|
|
116
116
|
`).map(g=>g?e.indent(g):e.indent("")).join(`
|
|
117
117
|
`);a+=c.type==="paragraph"?`
|
|
118
118
|
|
|
119
119
|
${p}`:`
|
|
120
|
-
${p}`}}),a}function gA(t,e,n={}){const{state:r}=e,{doc:s,tr:i}=r,o=t;s.descendants((l,a)=>{const c=i.mapping.map(a),u=i.mapping.map(a)+l.nodeSize;let d=null;if(l.marks.forEach(h=>{if(h!==o)return!1;d=h}),!d)return;let f=!1;if(Object.keys(n).forEach(h=>{n[h]!==d.attrs[h]&&(f=!0)}),f){const h=t.type.create({...t.attrs,...n});i.removeMark(c,u,t.type),i.addMark(c,u,h)}}),i.docChanged&&e.view.dispatch(i)}var ke=class T0 extends Cf{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new T0(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},yA=class{constructor(t,e,n){this.isDragging=!1,this.component=t,this.editor=e.editor,this.options={stopEvent:null,ignoreMutation:null,...n},this.extension=e.extension,this.node=e.node,this.decorations=e.decorations,this.innerDecorations=e.innerDecorations,this.view=e.view,this.HTMLAttributes=e.HTMLAttributes,this.getPos=e.getPos,this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(t){var e,n,r,s,i,o,l;const{view:a}=this.editor,c=t.target,u=c.nodeType===3?(e=c.parentElement)==null?void 0:e.closest("[data-drag-handle]"):c.closest("[data-drag-handle]");if(!this.dom||(n=this.contentDOM)!=null&&n.contains(c)||!u)return;let d=0,f=0;if(this.dom!==u){const w=this.dom.getBoundingClientRect(),v=u.getBoundingClientRect(),x=(s=t.offsetX)!=null?s:(r=t.nativeEvent)==null?void 0:r.offsetX,k=(o=t.offsetY)!=null?o:(i=t.nativeEvent)==null?void 0:i.offsetY;d=v.x-w.x+x,f=v.y-w.y+k}const h=this.dom.cloneNode(!0);try{const w=this.dom.getBoundingClientRect();h.style.width=`${Math.round(w.width)}px`,h.style.height=`${Math.round(w.height)}px`,h.style.boxSizing="border-box",h.style.pointerEvents="none"}catch{}let p=null;try{p=document.createElement("div"),p.style.position="absolute",p.style.top="-9999px",p.style.left="-9999px",p.style.pointerEvents="none",p.appendChild(h),document.body.appendChild(p),(l=t.dataTransfer)==null||l.setDragImage(h,d,f)}finally{p&&setTimeout(()=>{try{p==null||p.remove()}catch{}},0)}const g=this.getPos();if(typeof g!="number")return;const y=Y.create(a.state.doc,g),b=a.state.tr.setSelection(y);a.dispatch(b)}stopEvent(t){var e;if(!this.dom)return!1;if(typeof this.options.stopEvent=="function")return this.options.stopEvent({event:t});const n=t.target;if(!(this.dom.contains(n)&&!((e=this.contentDOM)!=null&&e.contains(n))))return!1;const s=t.type.startsWith("drag"),i=t.type==="dragover"||t.type==="dragenter",o=t.type==="drop";if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(n.tagName)||n.isContentEditable)&&!o&&!s)return!0;const{isEditable:a}=this.editor,{isDragging:c}=this,u=!!this.node.type.spec.draggable,d=Y.isSelectable(this.node),f=t.type==="copy",h=t.type==="paste",p=t.type==="cut",g=t.type==="mousedown";if(!u&&d&&s&&t.target===this.dom&&t.preventDefault(),u&&s&&!c&&t.target===this.dom)return t.preventDefault(),!1;if(u&&a&&!c&&g){const y=n.closest("[data-drag-handle]");y&&(this.dom===y||this.dom.contains(y))&&(this.isDragging=!0,document.addEventListener("dragend",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("drop",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("mouseup",()=>{this.isDragging=!1},{once:!0}))}return!(c||i||o||f||h||p||g&&d)}ignoreMutation(t){return!this.dom||!this.contentDOM?!0:typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:t}):this.node.isLeaf||this.node.isAtom?!0:t.type==="selection"||this.dom.contains(t.target)&&t.type==="childList"&&(Ji()||Ku())&&this.editor.isFocused&&[...Array.from(t.addedNodes),...Array.from(t.removedNodes)].every(n=>n.isContentEditable)?!1:this.contentDOM===t.target&&t.type==="attributes"?!0:!this.contentDOM.contains(t.target)}updateAttributes(t){this.editor.commands.command(({tr:e})=>{const n=this.getPos();return typeof n!="number"?!1:(e.setNodeMarkup(n,void 0,{...this.node.attrs,...t}),!0)})}deleteNode(){const t=this.getPos();if(typeof t!="number")return;const e=t+this.node.nodeSize;this.editor.commands.deleteRange({from:t,to:e})}};function dr(t){return new XT({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:s})=>{const i=fe(t.getAttributes,void 0,r,s);if(i===!1||i===null)return null;const{tr:o}=e,l=r[r.length-1],a=r[0];let c=n.to;if(l){const u=a.search(/\S/),d=n.from+a.indexOf(l),f=d+l.length;if(kf(n.from,n.to,e.doc).filter(g=>g.mark.type.excluded.find(b=>b===t.type&&b!==g.mark.type)).filter(g=>g.to>d).length)return null;f<n.to&&o.delete(f,n.to),d>n.from&&o.delete(n.from+u,d),c=n.from+u+l.length,o.addMark(n.from+u,c,t.type.create(i||{})),r.index!==void 0&&r.input!==void 0&&r.index+r[0].length>=r.input.length||o.removeStoredMark(t.type)}}})}const{getOwnPropertyNames:bA,getOwnPropertySymbols:wA}=Object,{hasOwnProperty:xA}=Object.prototype;function Vc(t,e){return function(r,s,i){return t(r,s,i)&&e(r,s,i)}}function Bo(t){return function(n,r,s){if(!n||!r||typeof n!="object"||typeof r!="object")return t(n,r,s);const{cache:i}=s,o=i.get(n),l=i.get(r);if(o&&l)return o===r&&l===n;i.set(n,r),i.set(r,n);const a=t(n,r,s);return i.delete(n),i.delete(r),a}}function vA(t){return t!=null?t[Symbol.toStringTag]:void 0}function Jp(t){return bA(t).concat(wA(t))}const kA=Object.hasOwn||((t,e)=>xA.call(t,e));function Zr(t,e){return t===e||!t&&!e&&t!==t&&e!==e}const SA="__v",CA="__o",EA="_owner",{getOwnPropertyDescriptor:Gp,keys:Yp}=Object;function MA(t,e){return t.byteLength===e.byteLength&&Bl(new Uint8Array(t),new Uint8Array(e))}function TA(t,e,n){let r=t.length;if(e.length!==r)return!1;for(;r-- >0;)if(!n.equals(t[r],e[r],r,r,t,e,n))return!1;return!0}function AA(t,e){return t.byteLength===e.byteLength&&Bl(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function _A(t,e){return Zr(t.getTime(),e.getTime())}function NA(t,e){return t.name===e.name&&t.message===e.message&&t.cause===e.cause&&t.stack===e.stack}function OA(t,e){return t===e}function Xp(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const s=new Array(r),i=t.entries();let o,l,a=0;for(;(o=i.next())&&!o.done;){const c=e.entries();let u=!1,d=0;for(;(l=c.next())&&!l.done;){if(s[d]){d++;continue}const f=o.value,h=l.value;if(n.equals(f[0],h[0],a,d,t,e,n)&&n.equals(f[1],h[1],f[0],h[0],t,e,n)){u=s[d]=!0;break}d++}if(!u)return!1;a++}return!0}const IA=Zr;function RA(t,e,n){const r=Yp(t);let s=r.length;if(Yp(e).length!==s)return!1;for(;s-- >0;)if(!A0(t,e,n,r[s]))return!1;return!0}function ti(t,e,n){const r=Jp(t);let s=r.length;if(Jp(e).length!==s)return!1;let i,o,l;for(;s-- >0;)if(i=r[s],!A0(t,e,n,i)||(o=Gp(t,i),l=Gp(e,i),(o||l)&&(!o||!l||o.configurable!==l.configurable||o.enumerable!==l.enumerable||o.writable!==l.writable)))return!1;return!0}function DA(t,e){return Zr(t.valueOf(),e.valueOf())}function LA(t,e){return t.source===e.source&&t.flags===e.flags}function Zp(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const s=new Array(r),i=t.values();let o,l;for(;(o=i.next())&&!o.done;){const a=e.values();let c=!1,u=0;for(;(l=a.next())&&!l.done;){if(!s[u]&&n.equals(o.value,l.value,o.value,l.value,t,e,n)){c=s[u]=!0;break}u++}if(!c)return!1}return!0}function Bl(t,e){let n=t.byteLength;if(e.byteLength!==n||t.byteOffset!==e.byteOffset)return!1;for(;n-- >0;)if(t[n]!==e[n])return!1;return!0}function jA(t,e){return t.hostname===e.hostname&&t.pathname===e.pathname&&t.protocol===e.protocol&&t.port===e.port&&t.hash===e.hash&&t.username===e.username&&t.password===e.password}function A0(t,e,n,r){return(r===EA||r===CA||r===SA)&&(t.$$typeof||e.$$typeof)?!0:kA(e,r)&&n.equals(t[r],e[r],r,r,t,e,n)}const PA="[object ArrayBuffer]",BA="[object Arguments]",zA="[object Boolean]",$A="[object DataView]",HA="[object Date]",FA="[object Error]",VA="[object Map]",UA="[object Number]",WA="[object Object]",qA="[object RegExp]",KA="[object Set]",JA="[object String]",GA={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float16Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0,"[object BigInt64Array]":!0,"[object BigUint64Array]":!0},YA="[object URL]",XA=Object.prototype.toString;function ZA({areArrayBuffersEqual:t,areArraysEqual:e,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:s,areFunctionsEqual:i,areMapsEqual:o,areNumbersEqual:l,areObjectsEqual:a,arePrimitiveWrappersEqual:c,areRegExpsEqual:u,areSetsEqual:d,areTypedArraysEqual:f,areUrlsEqual:h,unknownTagComparators:p}){return function(y,b,w){if(y===b)return!0;if(y==null||b==null)return!1;const v=typeof y;if(v!==typeof b)return!1;if(v!=="object")return v==="number"?l(y,b,w):v==="function"?i(y,b,w):!1;const x=y.constructor;if(x!==b.constructor)return!1;if(x===Object)return a(y,b,w);if(Array.isArray(y))return e(y,b,w);if(x===Date)return r(y,b,w);if(x===RegExp)return u(y,b,w);if(x===Map)return o(y,b,w);if(x===Set)return d(y,b,w);const k=XA.call(y);if(k===HA)return r(y,b,w);if(k===qA)return u(y,b,w);if(k===VA)return o(y,b,w);if(k===KA)return d(y,b,w);if(k===WA)return typeof y.then!="function"&&typeof b.then!="function"&&a(y,b,w);if(k===YA)return h(y,b,w);if(k===FA)return s(y,b,w);if(k===BA)return a(y,b,w);if(GA[k])return f(y,b,w);if(k===PA)return t(y,b,w);if(k===$A)return n(y,b,w);if(k===zA||k===UA||k===JA)return c(y,b,w);if(p){let C=p[k];if(!C){const E=vA(y);E&&(C=p[E])}if(C)return C(y,b,w)}return!1}}function QA({circular:t,createCustomConfig:e,strict:n}){let r={areArrayBuffersEqual:MA,areArraysEqual:n?ti:TA,areDataViewsEqual:AA,areDatesEqual:_A,areErrorsEqual:NA,areFunctionsEqual:OA,areMapsEqual:n?Vc(Xp,ti):Xp,areNumbersEqual:IA,areObjectsEqual:n?ti:RA,arePrimitiveWrappersEqual:DA,areRegExpsEqual:LA,areSetsEqual:n?Vc(Zp,ti):Zp,areTypedArraysEqual:n?Vc(Bl,ti):Bl,areUrlsEqual:jA,unknownTagComparators:void 0};if(e&&(r=Object.assign({},r,e(r))),t){const s=Bo(r.areArraysEqual),i=Bo(r.areMapsEqual),o=Bo(r.areObjectsEqual),l=Bo(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:s,areMapsEqual:i,areObjectsEqual:o,areSetsEqual:l})}return r}function e_(t){return function(e,n,r,s,i,o,l){return t(e,n,l)}}function t_({circular:t,comparator:e,createState:n,equals:r,strict:s}){if(n)return function(l,a){const{cache:c=t?new WeakMap:void 0,meta:u}=n();return e(l,a,{cache:c,equals:r,meta:u,strict:s})};if(t)return function(l,a){return e(l,a,{cache:new WeakMap,equals:r,meta:void 0,strict:s})};const i={cache:void 0,equals:r,meta:void 0,strict:s};return function(l,a){return e(l,a,i)}}const n_=br();br({strict:!0});br({circular:!0});br({circular:!0,strict:!0});br({createInternalComparator:()=>Zr});br({strict:!0,createInternalComparator:()=>Zr});br({circular:!0,createInternalComparator:()=>Zr});br({circular:!0,createInternalComparator:()=>Zr,strict:!0});function br(t={}){const{circular:e=!1,createInternalComparator:n,createState:r,strict:s=!1}=t,i=QA(t),o=ZA(i),l=n?n(o):e_(o);return t_({circular:e,comparator:o,createState:r,equals:l,strict:s})}var Zu={exports:{}},Uc={};/**
|
|
120
|
+
${p}`}}),a}function gE(t,e,n={}){const{state:r}=e,{doc:s,tr:i}=r,o=t;s.descendants((l,a)=>{const c=i.mapping.map(a),u=i.mapping.map(a)+l.nodeSize;let d=null;if(l.marks.forEach(f=>{if(f!==o)return!1;d=f}),!d)return;let h=!1;if(Object.keys(n).forEach(f=>{n[f]!==d.attrs[f]&&(h=!0)}),h){const f=t.type.create({...t.attrs,...n});i.removeMark(c,u,t.type),i.addMark(c,u,f)}}),i.docChanged&&e.view.dispatch(i)}var ke=class Ey extends Sh{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new Ey(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},yE=class{constructor(t,e,n){this.isDragging=!1,this.component=t,this.editor=e.editor,this.options={stopEvent:null,ignoreMutation:null,...n},this.extension=e.extension,this.node=e.node,this.decorations=e.decorations,this.innerDecorations=e.innerDecorations,this.view=e.view,this.HTMLAttributes=e.HTMLAttributes,this.getPos=e.getPos,this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(t){var e,n,r,s,i,o,l;const{view:a}=this.editor,c=t.target,u=c.nodeType===3?(e=c.parentElement)==null?void 0:e.closest("[data-drag-handle]"):c.closest("[data-drag-handle]");if(!this.dom||(n=this.contentDOM)!=null&&n.contains(c)||!u)return;let d=0,h=0;if(this.dom!==u){const w=this.dom.getBoundingClientRect(),v=u.getBoundingClientRect(),x=(s=t.offsetX)!=null?s:(r=t.nativeEvent)==null?void 0:r.offsetX,k=(o=t.offsetY)!=null?o:(i=t.nativeEvent)==null?void 0:i.offsetY;d=v.x-w.x+x,h=v.y-w.y+k}const f=this.dom.cloneNode(!0);try{const w=this.dom.getBoundingClientRect();f.style.width=`${Math.round(w.width)}px`,f.style.height=`${Math.round(w.height)}px`,f.style.boxSizing="border-box",f.style.pointerEvents="none"}catch{}let p=null;try{p=document.createElement("div"),p.style.position="absolute",p.style.top="-9999px",p.style.left="-9999px",p.style.pointerEvents="none",p.appendChild(f),document.body.appendChild(p),(l=t.dataTransfer)==null||l.setDragImage(f,d,h)}finally{p&&setTimeout(()=>{try{p==null||p.remove()}catch{}},0)}const g=this.getPos();if(typeof g!="number")return;const y=Y.create(a.state.doc,g),b=a.state.tr.setSelection(y);a.dispatch(b)}stopEvent(t){var e;if(!this.dom)return!1;if(typeof this.options.stopEvent=="function")return this.options.stopEvent({event:t});const n=t.target;if(!(this.dom.contains(n)&&!((e=this.contentDOM)!=null&&e.contains(n))))return!1;const s=t.type.startsWith("drag"),i=t.type==="dragover"||t.type==="dragenter",o=t.type==="drop";if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(n.tagName)||n.isContentEditable)&&!o&&!s)return!0;const{isEditable:a}=this.editor,{isDragging:c}=this,u=!!this.node.type.spec.draggable,d=Y.isSelectable(this.node),h=t.type==="copy",f=t.type==="paste",p=t.type==="cut",g=t.type==="mousedown";if(!u&&d&&s&&t.target===this.dom&&t.preventDefault(),u&&s&&!c&&t.target===this.dom)return t.preventDefault(),!1;if(u&&a&&!c&&g){const y=n.closest("[data-drag-handle]");y&&(this.dom===y||this.dom.contains(y))&&(this.isDragging=!0,document.addEventListener("dragend",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("drop",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("mouseup",()=>{this.isDragging=!1},{once:!0}))}return!(c||i||o||h||f||p||g&&d)}ignoreMutation(t){return!this.dom||!this.contentDOM?!0:typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:t}):this.node.isLeaf||this.node.isAtom?!0:t.type==="selection"||this.dom.contains(t.target)&&t.type==="childList"&&(Ji()||qu())&&this.editor.isFocused&&[...Array.from(t.addedNodes),...Array.from(t.removedNodes)].every(n=>n.isContentEditable)?!1:this.contentDOM===t.target&&t.type==="attributes"?!0:!this.contentDOM.contains(t.target)}updateAttributes(t){this.editor.commands.command(({tr:e})=>{const n=this.getPos();return typeof n!="number"?!1:(e.setNodeMarkup(n,void 0,{...this.node.attrs,...t}),!0)})}deleteNode(){const t=this.getPos();if(typeof t!="number")return;const e=t+this.node.nodeSize;this.editor.commands.deleteRange({from:t,to:e})}};function dr(t){return new X2({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:s})=>{const i=he(t.getAttributes,void 0,r,s);if(i===!1||i===null)return null;const{tr:o}=e,l=r[r.length-1],a=r[0];let c=n.to;if(l){const u=a.search(/\S/),d=n.from+a.indexOf(l),h=d+l.length;if(vh(n.from,n.to,e.doc).filter(g=>g.mark.type.excluded.find(b=>b===t.type&&b!==g.mark.type)).filter(g=>g.to>d).length)return null;h<n.to&&o.delete(h,n.to),d>n.from&&o.delete(n.from+u,d),c=n.from+u+l.length,o.addMark(n.from+u,c,t.type.create(i||{})),r.index!==void 0&&r.input!==void 0&&r.index+r[0].length>=r.input.length||o.removeStoredMark(t.type)}}})}const{getOwnPropertyNames:bE,getOwnPropertySymbols:wE}=Object,{hasOwnProperty:xE}=Object.prototype;function Fc(t,e){return function(r,s,i){return t(r,s,i)&&e(r,s,i)}}function Bo(t){return function(n,r,s){if(!n||!r||typeof n!="object"||typeof r!="object")return t(n,r,s);const{cache:i}=s,o=i.get(n),l=i.get(r);if(o&&l)return o===r&&l===n;i.set(n,r),i.set(r,n);const a=t(n,r,s);return i.delete(n),i.delete(r),a}}function vE(t){return t!=null?t[Symbol.toStringTag]:void 0}function Jp(t){return bE(t).concat(wE(t))}const kE=Object.hasOwn||((t,e)=>xE.call(t,e));function Zr(t,e){return t===e||!t&&!e&&t!==t&&e!==e}const SE="__v",CE="__o",ME="_owner",{getOwnPropertyDescriptor:Gp,keys:Yp}=Object;function AE(t,e){return t.byteLength===e.byteLength&&Bl(new Uint8Array(t),new Uint8Array(e))}function EE(t,e,n){let r=t.length;if(e.length!==r)return!1;for(;r-- >0;)if(!n.equals(t[r],e[r],r,r,t,e,n))return!1;return!0}function TE(t,e){return t.byteLength===e.byteLength&&Bl(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function _E(t,e){return Zr(t.getTime(),e.getTime())}function NE(t,e){return t.name===e.name&&t.message===e.message&&t.cause===e.cause&&t.stack===e.stack}function OE(t,e){return t===e}function Xp(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const s=new Array(r),i=t.entries();let o,l,a=0;for(;(o=i.next())&&!o.done;){const c=e.entries();let u=!1,d=0;for(;(l=c.next())&&!l.done;){if(s[d]){d++;continue}const h=o.value,f=l.value;if(n.equals(h[0],f[0],a,d,t,e,n)&&n.equals(h[1],f[1],h[0],f[0],t,e,n)){u=s[d]=!0;break}d++}if(!u)return!1;a++}return!0}const IE=Zr;function DE(t,e,n){const r=Yp(t);let s=r.length;if(Yp(e).length!==s)return!1;for(;s-- >0;)if(!Ty(t,e,n,r[s]))return!1;return!0}function ti(t,e,n){const r=Jp(t);let s=r.length;if(Jp(e).length!==s)return!1;let i,o,l;for(;s-- >0;)if(i=r[s],!Ty(t,e,n,i)||(o=Gp(t,i),l=Gp(e,i),(o||l)&&(!o||!l||o.configurable!==l.configurable||o.enumerable!==l.enumerable||o.writable!==l.writable)))return!1;return!0}function RE(t,e){return Zr(t.valueOf(),e.valueOf())}function LE(t,e){return t.source===e.source&&t.flags===e.flags}function Zp(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const s=new Array(r),i=t.values();let o,l;for(;(o=i.next())&&!o.done;){const a=e.values();let c=!1,u=0;for(;(l=a.next())&&!l.done;){if(!s[u]&&n.equals(o.value,l.value,o.value,l.value,t,e,n)){c=s[u]=!0;break}u++}if(!c)return!1}return!0}function Bl(t,e){let n=t.byteLength;if(e.byteLength!==n||t.byteOffset!==e.byteOffset)return!1;for(;n-- >0;)if(t[n]!==e[n])return!1;return!0}function jE(t,e){return t.hostname===e.hostname&&t.pathname===e.pathname&&t.protocol===e.protocol&&t.port===e.port&&t.hash===e.hash&&t.username===e.username&&t.password===e.password}function Ty(t,e,n,r){return(r===ME||r===CE||r===SE)&&(t.$$typeof||e.$$typeof)?!0:kE(e,r)&&n.equals(t[r],e[r],r,r,t,e,n)}const PE="[object ArrayBuffer]",BE="[object Arguments]",HE="[object Boolean]",zE="[object DataView]",$E="[object Date]",VE="[object Error]",FE="[object Map]",UE="[object Number]",WE="[object Object]",KE="[object RegExp]",qE="[object Set]",JE="[object String]",GE={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float16Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0,"[object BigInt64Array]":!0,"[object BigUint64Array]":!0},YE="[object URL]",XE=Object.prototype.toString;function ZE({areArrayBuffersEqual:t,areArraysEqual:e,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:s,areFunctionsEqual:i,areMapsEqual:o,areNumbersEqual:l,areObjectsEqual:a,arePrimitiveWrappersEqual:c,areRegExpsEqual:u,areSetsEqual:d,areTypedArraysEqual:h,areUrlsEqual:f,unknownTagComparators:p}){return function(y,b,w){if(y===b)return!0;if(y==null||b==null)return!1;const v=typeof y;if(v!==typeof b)return!1;if(v!=="object")return v==="number"?l(y,b,w):v==="function"?i(y,b,w):!1;const x=y.constructor;if(x!==b.constructor)return!1;if(x===Object)return a(y,b,w);if(Array.isArray(y))return e(y,b,w);if(x===Date)return r(y,b,w);if(x===RegExp)return u(y,b,w);if(x===Map)return o(y,b,w);if(x===Set)return d(y,b,w);const k=XE.call(y);if(k===$E)return r(y,b,w);if(k===KE)return u(y,b,w);if(k===FE)return o(y,b,w);if(k===qE)return d(y,b,w);if(k===WE)return typeof y.then!="function"&&typeof b.then!="function"&&a(y,b,w);if(k===YE)return f(y,b,w);if(k===VE)return s(y,b,w);if(k===BE)return a(y,b,w);if(GE[k])return h(y,b,w);if(k===PE)return t(y,b,w);if(k===zE)return n(y,b,w);if(k===HE||k===UE||k===JE)return c(y,b,w);if(p){let C=p[k];if(!C){const M=vE(y);M&&(C=p[M])}if(C)return C(y,b,w)}return!1}}function QE({circular:t,createCustomConfig:e,strict:n}){let r={areArrayBuffersEqual:AE,areArraysEqual:n?ti:EE,areDataViewsEqual:TE,areDatesEqual:_E,areErrorsEqual:NE,areFunctionsEqual:OE,areMapsEqual:n?Fc(Xp,ti):Xp,areNumbersEqual:IE,areObjectsEqual:n?ti:DE,arePrimitiveWrappersEqual:RE,areRegExpsEqual:LE,areSetsEqual:n?Fc(Zp,ti):Zp,areTypedArraysEqual:n?Fc(Bl,ti):Bl,areUrlsEqual:jE,unknownTagComparators:void 0};if(e&&(r=Object.assign({},r,e(r))),t){const s=Bo(r.areArraysEqual),i=Bo(r.areMapsEqual),o=Bo(r.areObjectsEqual),l=Bo(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:s,areMapsEqual:i,areObjectsEqual:o,areSetsEqual:l})}return r}function eT(t){return function(e,n,r,s,i,o,l){return t(e,n,l)}}function tT({circular:t,comparator:e,createState:n,equals:r,strict:s}){if(n)return function(l,a){const{cache:c=t?new WeakMap:void 0,meta:u}=n();return e(l,a,{cache:c,equals:r,meta:u,strict:s})};if(t)return function(l,a){return e(l,a,{cache:new WeakMap,equals:r,meta:void 0,strict:s})};const i={cache:void 0,equals:r,meta:void 0,strict:s};return function(l,a){return e(l,a,i)}}const nT=br();br({strict:!0});br({circular:!0});br({circular:!0,strict:!0});br({createInternalComparator:()=>Zr});br({strict:!0,createInternalComparator:()=>Zr});br({circular:!0,createInternalComparator:()=>Zr});br({circular:!0,createInternalComparator:()=>Zr,strict:!0});function br(t={}){const{circular:e=!1,createInternalComparator:n,createState:r,strict:s=!1}=t,i=QE(t),o=ZE(i),l=n?n(o):eT(o);return tT({circular:e,comparator:o,createState:r,equals:l,strict:s})}var Zu={exports:{}},Uc={};/**
|
|
121
121
|
* @license React
|
|
122
122
|
* use-sync-external-store-shim/with-selector.production.js
|
|
123
123
|
*
|
|
@@ -125,7 +125,7 @@ ${p}`}}),a}function gA(t,e,n={}){const{state:r}=e,{doc:s,tr:i}=r,o=t;s.descendan
|
|
|
125
125
|
*
|
|
126
126
|
* This source code is licensed under the MIT license found in the
|
|
127
127
|
* LICENSE file in the root directory of this source tree.
|
|
128
|
-
*/var Qp;function
|
|
128
|
+
*/var Qp;function rT(){if(Qp)return Uc;Qp=1;var t=S,e=za;function n(c,u){return c===u&&(c!==0||1/c===1/u)||c!==c&&u!==u}var r=typeof Object.is=="function"?Object.is:n,s=e.useSyncExternalStore,i=t.useRef,o=t.useEffect,l=t.useMemo,a=t.useDebugValue;return Uc.useSyncExternalStoreWithSelector=function(c,u,d,h,f){var p=i(null);if(p.current===null){var g={hasValue:!1,value:null};p.current=g}else g=p.current;p=l(function(){function b(C){if(!w){if(w=!0,v=C,C=h(C),f!==void 0&&g.hasValue){var M=g.value;if(f(M,C))return x=M}return x=C}if(M=x,r(v,C))return M;var O=h(C);return f!==void 0&&f(M,O)?(v=C,M):(v=C,x=O)}var w=!1,v,x,k=d===void 0?null:d;return[function(){return b(u())},k===null?void 0:function(){return b(k())}]},[u,d,h,f]);var y=s(c,p[0],p[1]);return o(function(){g.hasValue=!0,g.value=y},[y]),a(y),y},Uc}var Wc={};/**
|
|
129
129
|
* @license React
|
|
130
130
|
* use-sync-external-store-shim/with-selector.development.js
|
|
131
131
|
*
|
|
@@ -133,56 +133,56 @@ ${p}`}}),a}function gA(t,e,n={}){const{state:r}=e,{doc:s,tr:i}=r,o=t;s.descendan
|
|
|
133
133
|
*
|
|
134
134
|
* This source code is licensed under the MIT license found in the
|
|
135
135
|
* LICENSE file in the root directory of this source tree.
|
|
136
|
-
*/var em;function s_(){return em||(em=1,process.env.NODE_ENV!=="production"&&function(){function t(c,u){return c===u&&(c!==0||1/c===1/u)||c!==c&&u!==u}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var e=S,n=$a,r=typeof Object.is=="function"?Object.is:t,s=n.useSyncExternalStore,i=e.useRef,o=e.useEffect,l=e.useMemo,a=e.useDebugValue;Wc.useSyncExternalStoreWithSelector=function(c,u,d,f,h){var p=i(null);if(p.current===null){var g={hasValue:!1,value:null};p.current=g}else g=p.current;p=l(function(){function b(C){if(!w){if(w=!0,v=C,C=f(C),h!==void 0&&g.hasValue){var E=g.value;if(h(E,C))return x=E}return x=C}if(E=x,r(v,C))return E;var O=f(C);return h!==void 0&&h(E,O)?(v=C,E):(v=C,x=O)}var w=!1,v,x,k=d===void 0?null:d;return[function(){return b(u())},k===null?void 0:function(){return b(k())}]},[u,d,f,h]);var y=s(c,p[0],p[1]);return o(function(){g.hasValue=!0,g.value=y},[y]),a(y),y},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),Wc}process.env.NODE_ENV==="production"?Zu.exports=r_():Zu.exports=s_();var i_=Zu.exports,o_=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},l_=({contentComponent:t})=>{const e=$a.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return m.jsx(m.Fragment,{children:Object.values(e)})};function a_(){const t=new Set;let e={};return{subscribe(n){return t.add(n),()=>{t.delete(n)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(n,r){e={...e,[n]:zs.createPortal(r.reactElement,r.element,n)},t.forEach(s=>s())},removeRenderer(n){const r={...e};delete r[n],e=r,t.forEach(s=>s())}}}var c_=class extends S.Component{constructor(t){super(t),this.editorContentRef=S.createRef()}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){var t;const e=this.props.editor;if(e&&!e.isDestroyed&&((t=e.view.dom)!=null&&t.parentNode)){if(e.contentComponent)return;const n=this.editorContentRef.current;n.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:n}),e.contentComponent=a_(),e.createNodeViews(),e.isEditorContentInitialized=!0,this.forceUpdate()}}componentWillUnmount(){var t;const e=this.props.editor;if(e){e.isEditorContentInitialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),e.contentComponent=null;try{if(!((t=e.view.dom)!=null&&t.parentNode))return;const n=document.createElement("div");n.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:n})}catch{}}}render(){const{editor:t,innerRef:e,...n}=this.props;return m.jsxs(m.Fragment,{children:[m.jsx("div",{ref:o_(e,this.editorContentRef),...n}),(t==null?void 0:t.contentComponent)&&m.jsx(l_,{contentComponent:t.contentComponent})]})}},u_=S.forwardRef((t,e)=>{const n=S.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return S.createElement(c_,{key:n,innerRef:e,...t})}),Af=S.memo(u_),d_=typeof window<"u"?S.useLayoutEffect:S.useEffect,f_=class{constructor(t){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=t,this.lastSnapshot={editor:t,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}watch(t){if(this.editor=t,this.editor){const e=()=>{this.transactionNumber+=1,this.subscribers.forEach(r=>r())},n=this.editor;return n.on("transaction",e),()=>{n.off("transaction",e)}}}};function vo(t){var e;const[n]=S.useState(()=>new f_(t.editor)),r=i_.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:n_);return d_(()=>n.watch(t.editor),[t.editor,n]),S.useDebugValue(r),r}var tm=process.env.NODE_ENV!=="production",_0=typeof window>"u",h_=_0||!!(typeof window<"u"&&window.next),p_=class N0{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(n=>n())}getInitialEditor(){const e=this.options.current.immediatelyRender;let n=e??!0;return _0?(n&&tm&&console.warn("SSR detected. `immediatelyRender` has been set to false to avoid hydration mismatches"),n=!1):h_&&e===void 0&&(n=!1,tm&&console.warn("Next.js detected. `immediatelyRender` defaults to false to avoid hydration mismatches. Pass `immediatelyRender: true` explicitly if you are rendering the editor only on the client.")),n?this.createEditor():null}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var s,i;return(i=(s=this.options.current).onBeforeCreate)==null?void 0:i.call(s,...r)},onBlur:(...r)=>{var s,i;return(i=(s=this.options.current).onBlur)==null?void 0:i.call(s,...r)},onCreate:(...r)=>{var s,i;return(i=(s=this.options.current).onCreate)==null?void 0:i.call(s,...r)},onDestroy:(...r)=>{var s,i;return(i=(s=this.options.current).onDestroy)==null?void 0:i.call(s,...r)},onFocus:(...r)=>{var s,i;return(i=(s=this.options.current).onFocus)==null?void 0:i.call(s,...r)},onSelectionUpdate:(...r)=>{var s,i;return(i=(s=this.options.current).onSelectionUpdate)==null?void 0:i.call(s,...r)},onTransaction:(...r)=>{var s,i;return(i=(s=this.options.current).onTransaction)==null?void 0:i.call(s,...r)},onUpdate:(...r)=>{var s,i;return(i=(s=this.options.current).onUpdate)==null?void 0:i.call(s,...r)},onContentError:(...r)=>{var s,i;return(i=(s=this.options.current).onContentError)==null?void 0:i.call(s,...r)},onDrop:(...r)=>{var s,i;return(i=(s=this.options.current).onDrop)==null?void 0:i.call(s,...r)},onPaste:(...r)=>{var s,i;return(i=(s=this.options.current).onPaste)==null?void 0:i.call(s,...r)},onDelete:(...r)=>{var s,i;return(i=(s=this.options.current).onDelete)==null?void 0:i.call(s,...r)}};return new iA(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,n){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&n.extensions?e.extensions.length!==n.extensions.length?!1:e.extensions.every((s,i)=>{var o;return s===((o=n.extensions)==null?void 0:o[i])}):e[r]===n[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?N0.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(e),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((r,s)=>r===e[s]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,n=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){n&&n.setOptions(this.options.current);return}n&&!n.isDestroyed&&(n.destroy(),this.instanceId===e&&this.setEditor(null))},1)}};function O0(t={},e=[]){const n=S.useRef(t);n.current=t;const[r]=S.useState(()=>new p_(n)),s=$a.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return S.useDebugValue(s),S.useEffect(r.onRender(e)),vo({editor:s,selector:({transactionNumber:i})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&i===0?0:i+1}),s}var _f=S.createContext({editor:null});_f.Consumer;var I0=()=>S.useContext(_f),R0=S.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),D0=()=>S.useContext(R0);function L0({as:t="div",...e}){const{nodeViewContentRef:n,nodeViewContentChildren:r}=D0();return m.jsx(t,{...e,ref:n,"data-node-view-content":"",style:{whiteSpace:"pre-wrap",...e.style},children:r})}var wr=S.forwardRef((t,e)=>{const{onDragStart:n}=D0(),r=t.as||"div";return m.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});function nm(t){return!!(typeof t=="function"&&t.prototype&&t.prototype.isReactComponent)}function rm(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.forward_ref)"||t.$$typeof.description==="react.forward_ref"))}function m_(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.memo)"||t.$$typeof.description==="react.memo"))}function g_(t){if(nm(t)||rm(t))return!0;if(m_(t)){const e=t.type;if(e)return nm(e)||rm(e)}return!1}function y_(){try{if(S.version)return parseInt(S.version.split(".")[0],10)>=19}catch{}return!1}var b_=class{constructor(t,{editor:e,props:n={},as:r="div",className:s=""}){this.ref=null,this.destroyed=!1,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=t,this.editor=e,this.props=n,this.element=document.createElement(r),this.element.classList.add("react-renderer"),s&&this.element.classList.add(...s.split(" ")),this.editor.isEditorContentInitialized?zs.flushSync(()=>{this.render()}):queueMicrotask(()=>{this.destroyed||this.render()})}render(){var t;if(this.destroyed)return;const e=this.component,n=this.props,r=this.editor,s=y_(),i=g_(e),o={...n};o.ref&&!(s||i)&&delete o.ref,!o.ref&&(s||i)&&(o.ref=l=>{this.ref=l}),this.reactElement=m.jsx(e,{...o}),(t=r==null?void 0:r.contentComponent)==null||t.setRenderer(this.id,this)}updateProps(t={}){if(this.destroyed)return;let e=!1;const n=Object.keys(t);for(let r=0;r<n.length;r+=1){const s=n[r];if(t[s]!==this.props[s]){e=!0;break}}e&&(this.props={...this.props,...t},this.render())}destroy(){var t;this.destroyed=!0;const e=this.editor;(t=e==null?void 0:e.contentComponent)==null||t.removeRenderer(this.id);try{this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}catch{}}updateAttributes(t){Object.keys(t).forEach(e=>{this.element.setAttribute(e,t[e])})}};S.createContext({markViewContentRef:()=>{}});var w_=class extends yA{constructor(t,e,n){if(super(t,e,n),this.selectionRafId=null,this.handlePositionUpdate=()=>{const r=this.getPos();typeof r!="number"||r===this.currentPos||(this.currentPos=r,this.renderer.updateProps({getPos:()=>this.getPos()}),typeof this.options.attrs=="function"&&this.updateElementAttributes())},this.cachedExtensionWithSyncedStorage=null,!this.node.isLeaf){this.options.contentDOMElementTag?this.contentDOMElement=document.createElement(this.options.contentDOMElementTag):this.contentDOMElement=document.createElement(this.node.isInline?"span":"div"),this.contentDOMElement.dataset.nodeViewContentReact="",this.contentDOMElement.dataset.nodeViewWrapper="",this.contentDOMElement.style.whiteSpace="inherit";const r=this.dom.querySelector("[data-node-view-content]");if(!r)return;r.appendChild(this.contentDOMElement)}this.options.trackNodeViewPosition&&this.editor.on("update",this.handlePositionUpdate)}get extensionWithSyncedStorage(){if(!this.cachedExtensionWithSyncedStorage){const t=this.editor,e=this.extension;this.cachedExtensionWithSyncedStorage=new Proxy(e,{get(n,r,s){var i;return r==="storage"?(i=t.storage[e.name])!=null?i:{}:Reflect.get(n,r,s)}})}return this.cachedExtensionWithSyncedStorage}mount(){const e={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extensionWithSyncedStorage,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(c={})=>this.updateAttributes(c),deleteNode:()=>this.deleteNode(),ref:S.createRef()};if(!this.component.displayName){const c=u=>u.charAt(0).toUpperCase()+u.substring(1);this.component.displayName=c(this.extension.name)}const s={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:c=>{c&&this.contentDOMElement&&c.firstChild!==this.contentDOMElement&&(c.hasAttribute("data-node-view-wrapper")&&c.removeAttribute("data-node-view-wrapper"),c.appendChild(this.contentDOMElement))}},i=this.component,o=S.memo(c=>m.jsx(R0.Provider,{value:s,children:S.createElement(i,c)}));o.displayName="ReactNodeView";let l=this.node.isInline?"span":"div";this.options.as&&(l=this.options.as);const{className:a=""}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new b_(o,{editor:this.editor,props:e,as:l,className:`node-${this.node.type.name} ${a}`.trim()}),this.editor.on("selectionUpdate",this.handleSelectionUpdate),this.updateElementAttributes(),this.currentPos=this.getPos()}get dom(){var t;if(this.renderer.element.firstElementChild&&!((t=this.renderer.element.firstElementChild)!=null&&t.hasAttribute("data-node-view-wrapper")))throw Error("Please use the NodeViewWrapper component for your node view.");return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}handleSelectionUpdate(){this.selectionRafId&&(cancelAnimationFrame(this.selectionRafId),this.selectionRafId=null),this.selectionRafId=requestAnimationFrame(()=>{this.selectionRafId=null;const t=this.currentPos;if(typeof t!="number")return;if(kT({selection:this.editor.state.selection,pos:t,nodeSize:this.node.nodeSize,selectedOnTextSelection:this.options.selectedOnTextSelection})){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}})}update(t,e,n){const r=l=>{this.renderer.updateProps(l),typeof this.options.attrs=="function"&&this.updateElementAttributes()};if(t.type!==this.node.type)return!1;if(typeof this.options.update=="function"){const l=this.node,a=this.decorations,c=this.innerDecorations;return this.node=t,this.decorations=e,this.innerDecorations=n,this.currentPos=this.getPos(),this.options.update({oldNode:l,oldDecorations:a,newNode:t,newDecorations:e,oldInnerDecorations:c,innerDecorations:n,updateProps:()=>r({node:t,decorations:e,innerDecorations:n,extension:this.extensionWithSyncedStorage})})}if(!(t!==this.node))return this.node=t,this.decorations=e,this.innerDecorations=n,!0;const i=this.getPos();this.node=t,this.decorations=e,this.innerDecorations=n,this.currentPos=i;const o={node:t,decorations:e,innerDecorations:n,extension:this.extensionWithSyncedStorage};return this.options.trackNodeViewPosition&&(o.getPos=()=>this.getPos()),r(o),!0}selectNode(){this.renderer.updateProps({selected:!0}),this.renderer.element.classList.add("ProseMirror-selectednode")}deselectNode(){this.renderer.updateProps({selected:!1}),this.renderer.element.classList.remove("ProseMirror-selectednode")}destroy(){this.renderer.destroy(),this.editor.off("selectionUpdate",this.handleSelectionUpdate),this.options.trackNodeViewPosition&&this.editor.off("update",this.handlePositionUpdate),this.contentDOMElement=null,this.selectionRafId&&(cancelAnimationFrame(this.selectionRafId),this.selectionRafId=null)}updateElementAttributes(){if(this.options.attrs){let t={};if(typeof this.options.attrs=="function"){const e=this.editor.extensionManager.attributes,n=Ts(this.node,e);t=this.options.attrs({node:this.node,HTMLAttributes:n})}else t=this.options.attrs;this.renderer.updateAttributes(t)}}};function xr(t,e){return n=>n.editor.contentComponent?new w_(t,n,e):{}}var Nf=S.createContext({get editor(){throw new Error("useTiptap must be used within a <Tiptap> provider")}});Nf.displayName="TiptapContext";var x_=()=>S.useContext(Nf);function j0({editor:t,instance:e,children:n}){const r=t??e;if(!r)throw new Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");const s=S.useMemo(()=>({editor:r}),[r]),i=S.useMemo(()=>({editor:r}),[r]);return m.jsx(_f.Provider,{value:i,children:m.jsx(Nf.Provider,{value:s,children:n})})}j0.displayName="Tiptap";function P0({...t}){const{editor:e}=x_();return m.jsx(Af,{editor:e,...t})}P0.displayName="Tiptap.Content";Object.assign(j0,{Content:P0});var zl=(t,e)=>{if(t==="slot")return 0;if(t instanceof Function)return t(e);const{children:n,...r}=e??{};if(t==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[t,r,n]};function B0(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let s=t.child(r),i=e.child(r);if(s==i){n+=s.nodeSize;continue}if(!s.sameMarkup(i))return n;if(s.isText&&s.text!=i.text){for(let o=0;s.text[o]==i.text[o];o++)n++;return n}if(s.content.size||i.content.size){let o=B0(s.content,i.content,n+1);if(o!=null)return o}n+=s.nodeSize}}function z0(t,e,n,r){for(let s=t.childCount,i=e.childCount;;){if(s==0||i==0)return s==i?null:{a:n,b:r};let o=t.child(--s),l=e.child(--i),a=o.nodeSize;if(o==l){n-=a,r-=a;continue}if(!o.sameMarkup(l))return{a:n,b:r};if(o.isText&&o.text!=l.text){let c=0,u=Math.min(o.text.length,l.text.length);for(;c<u&&o.text[o.text.length-c-1]==l.text[l.text.length-c-1];)c++,n--,r--;return{a:n,b:r}}if(o.content.size||l.content.size){let c=z0(o.content,l.content,n-1,r-1);if(c)return c}n-=a,r-=a}}var Pn=class dt{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,s=0,i){for(let o=0,l=0;l<n;o++){let a=this.content[o],c=l+a.nodeSize;if(c>e&&r(a,s+l,i||null,o)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,n-u),r,s+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,s){let i="",o=!0;return this.nodesBetween(e,n,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,n-a):l.isLeaf?s?typeof s=="function"?s(l):s:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(o?o=!1:i+=r),i+=c},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,s=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(r)&&(s[s.length-1]=n.withText(n.text+r.text),i=1);i<e.content.length;i++)s.push(e.content[i]);return new dt(s,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],s=0;if(n>e)for(let i=0,o=0;o<n;i++){let l=this.content[i],a=o+l.nodeSize;a>e&&((o<e||a>n)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,n-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,n-o-1))),r.push(l),s+=l.nodeSize),o=a}return new dt(r,s)}cutByIndex(e,n){return e==n?dt.empty:e==0&&n==this.content.length?this:new dt(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let s=this.content.slice(),i=this.size+n.nodeSize-r.nodeSize;return s[e]=n,new dt(s,i)}addToStart(e){return new dt([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new dt(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))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 n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let s=this.content[n];e(s,r,n),r+=s.nodeSize}}findDiffStart(e,n=0){return B0(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return z0(this,e,n,r)}findIndex(e){if(e==0)return zo(0,e);if(e==this.size)return zo(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 s=this.child(n),i=r+s.nodeSize;if(i>=e)return i==e?zo(n+1,i):zo(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,n){if(!n)return dt.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return dt.fromArray(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return dt.empty;let n,r=0;for(let s=0;s<e.length;s++){let i=e[s];r+=i.nodeSize,s&&i.isText&&e[s-1].sameMarkup(i)?(n||(n=e.slice(0,s)),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new dt(n||e,r)}static from(e){if(!e)return dt.empty;if(e instanceof dt)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new dt([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}};Pn.empty=new Pn([],0);var qc={index:0,offset:0};function zo(t,e){return qc.index=t,qc.offset=e,qc}var v_=class extends Error{},Re=class us{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=H0(this.content,e+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new us(r,this.openStart,this.openEnd)}removeBetween(e,n){return new us($0(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return us.empty;let r=n.openStart||0,s=n.openEnd||0;if(typeof r!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new us(Pn.fromJSON(e,n.content),r,s)}static maxOpen(e,n=!0){let r=0,s=0;for(let i=e.firstChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.lastChild)s++;return new us(e,r,s)}};Re.empty=new Re(Pn.empty,0,0);function $0(t,e,n){let{index:r,offset:s}=t.findIndex(e),i=t.maybeChild(r),{index:o,offset:l}=t.findIndex(n);if(s==e||i.isText){if(l!=n&&!t.child(o).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(r,i.copy($0(i.content,e-s-1,n-s-1)))}function H0(t,e,n,r,s,i){let{index:o,offset:l}=t.findIndex(e),a=t.maybeChild(o);if(l==e||a.isText)return i&&r<=0&&s<=0&&!i.canReplace(o,o,n)?null:t.cut(0,e).append(n).append(t.cut(e));let c=H0(a.content,e-l-1,n,o==0?r-1:0,o==t.childCount-1?s-1:0,a);return c&&t.replaceChild(o,a.copy(c))}var F0=65535,V0=Math.pow(2,16);function k_(t,e){return t+e*V0}function sm(t){return t&F0}function S_(t){return(t-(t&F0))/V0}var U0=1,W0=2,ul=4,q0=8,im=class{constructor(t,e,n){this.pos=t,this.delInfo=e,this.recover=n}get deleted(){return(this.delInfo&q0)>0}get deletedBefore(){return(this.delInfo&(U0|ul))>0}get deletedAfter(){return(this.delInfo&(W0|ul))>0}get deletedAcross(){return(this.delInfo&ul)>0}},Vr=class ds{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&ds.empty)return ds.empty}recover(e){let n=0,r=sm(e);if(!this.inverted)for(let s=0;s<r;s++)n+=this.ranges[s*3+2]-this.ranges[s*3+1];return this.ranges[r*3]+n+S_(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let s=0,i=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?s:0);if(a>e)break;let c=this.ranges[l+i],u=this.ranges[l+o],d=a+c;if(e<=d){let f=c?e==a?-1:e==d?1:n:n,h=a+s+(f<0?0:u);if(r)return h;let p=e==(n<0?a:d)?null:k_(l/3,e-a),g=e==a?W0:e==d?U0:ul;return(n<0?e!=a:e!=d)&&(g|=q0),new im(h,g,p)}s+=u-c}return r?e+s:new im(e+s,0,null)}touches(e,n){let r=0,s=sm(n),i=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+i],u=a+c;if(e<=u&&l==s*3)return!0;r+=this.ranges[l+o]-c}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let s=0,i=0;s<this.ranges.length;s+=3){let o=this.ranges[s],l=o-(this.inverted?i:0),a=o+(this.inverted?0:i),c=this.ranges[s+n],u=this.ranges[s+r];e(l,l+c,a,a+u),i+=u-c}}invert(){return new ds(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?ds.empty:new ds(e<0?[0,-e,0]:[0,0,e])}};Vr.empty=new Vr([]);var Kc=Object.create(null),at=class{getMap(){return Vr.empty}merge(t){return null}static fromJSON(t,e){if(!e||!e.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=Kc[e.stepType];if(!n)throw new RangeError(`No step type ${e.stepType} defined`);return n.fromJSON(t,e)}static jsonID(t,e){if(t in Kc)throw new RangeError("Duplicate use of step JSON ID "+t);return Kc[t]=e,e.prototype.jsonID=t,e}},pt=class mi{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new mi(e,null)}static fail(e){return new mi(null,e)}static fromReplace(e,n,r,s){try{return mi.ok(e.replace(n,r,s))}catch(i){if(i instanceof v_)return mi.fail(i.message);throw i}}};function Of(t,e,n){let r=[];for(let s=0;s<t.childCount;s++){let i=t.child(s);i.content.size&&(i=i.copy(Of(i.content,e,i))),i.isInline&&(i=e(i,n,s)),r.push(i)}return Pn.fromArray(r)}var K0=class gi extends at{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),s=r.node(r.sharedDepth(this.to)),i=new Re(Of(n.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),s),n.openStart,n.openEnd);return pt.fromReplace(e,this.from,this.to,i)}invert(){return new J0(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new gi(n.pos,r.pos,this.mark)}merge(e){return e instanceof gi&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new gi(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,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new gi(n.from,n.to,e.markFromJSON(n.mark))}};at.jsonID("addMark",K0);var J0=class yi extends at{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new Re(Of(n.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),n.openStart,n.openEnd);return pt.fromReplace(e,this.from,this.to,r)}invert(){return new K0(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new yi(n.pos,r.pos,this.mark)}merge(e){return e instanceof yi&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new yi(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,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new yi(n.from,n.to,e.markFromJSON(n.mark))}};at.jsonID("removeMark",J0);var G0=class bi extends at{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return pt.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return pt.fromReplace(e,this.pos,this.pos+1,new Re(Pn.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let s=0;s<n.marks.length;s++)if(!n.marks[s].isInSet(r))return new bi(this.pos,n.marks[s]);return new bi(this.pos,this.mark)}}return new Y0(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new bi(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new bi(n.pos,e.markFromJSON(n.mark))}};at.jsonID("addNodeMark",G0);var Y0=class Qu extends at{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return pt.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return pt.fromReplace(e,this.pos,this.pos+1,new Re(Pn.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new G0(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Qu(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Qu(n.pos,e.markFromJSON(n.mark))}};at.jsonID("removeNodeMark",Y0);var If=class Xn extends at{constructor(e,n,r,s=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=s}apply(e){return this.structure&&ed(e,this.from,this.to)?pt.fail("Structure replace would overwrite content"):pt.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Vr([this.from,this.to-this.from,this.slice.size])}invert(e){return new Xn(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.to,-1),r=this.from==this.to&&Xn.MAP_BIAS<0?n:e.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new Xn(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Xn)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?Re.empty:new Re(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Xn(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?Re.empty:new Re(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Xn(e.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Xn(n.from,n.to,Re.fromJSON(e,n.slice),!!n.structure)}};If.MAP_BIAS=1;at.jsonID("replace",If);var X0=class dl extends at{constructor(e,n,r,s,i,o,l=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=s,this.slice=i,this.insert=o,this.structure=l}apply(e){if(this.structure&&(ed(e,this.from,this.gapFrom)||ed(e,this.gapTo,this.to)))return pt.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return pt.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?pt.fromReplace(e,this.from,this.to,r):pt.fail("Content does not fit in gap")}getMap(){return new Vr([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new dl(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),s=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||s<n.pos||i>r.pos?null:new dl(n.pos,r.pos,s,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new dl(n.from,n.to,n.gapFrom,n.gapTo,Re.fromJSON(e,n.slice),n.insert,!!n.structure)}};at.jsonID("replaceAround",X0);function ed(t,e,n){let r=t.resolve(e),s=n-e,i=r.depth;for(;s>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,s--;if(s>0){let o=r.node(i).maybeChild(r.indexAfter(i));for(;s>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,s--}}return!1}var C_=class fl extends at{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return pt.fail("No node at attribute step's position");let r=Object.create(null);for(let i in n.attrs)r[i]=n.attrs[i];r[this.attr]=this.value;let s=n.type.create(r,null,n.marks);return pt.fromReplace(e,this.pos,this.pos+1,new Re(Pn.from(s),0,n.isLeaf?0:1))}getMap(){return Vr.empty}invert(e){return new fl(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new fl(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new fl(n.pos,n.attr,n.value)}};at.jsonID("attr",C_);var E_=class td extends at{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let s in e.attrs)n[s]=e.attrs[s];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return pt.ok(r)}getMap(){return Vr.empty}invert(e){return new td(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new td(n.attr,n.value)}};at.jsonID("docAttr",E_);var Xi=class extends Error{};Xi=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};Xi.prototype=Object.create(Error.prototype);Xi.prototype.constructor=Xi;Xi.prototype.name="TransformError";var Jc=Object.create(null),Ve=class{constructor(t,e,n){this.$anchor=t,this.$head=e,this.ranges=n||[new M_(t.min(e),t.max(e))]}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 t=this.ranges;for(let e=0;e<t.length;e++)if(t[e].$from.pos!=t[e].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(t,e=Re.empty){let n=e.content.lastChild,r=null;for(let o=0;o<e.openEnd;o++)r=n,n=n.lastChild;let s=t.steps.length,i=this.ranges;for(let o=0;o<i.length;o++){let{$from:l,$to:a}=i[o],c=t.mapping.slice(s);t.replaceRange(c.map(l.pos),c.map(a.pos),o?Re.empty:e),o==0&&am(t,s,(n?n.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(t,e){let n=t.steps.length,r=this.ranges;for(let s=0;s<r.length;s++){let{$from:i,$to:o}=r[s],l=t.mapping.slice(n),a=l.map(i.pos),c=l.map(o.pos);s?t.deleteRange(a,c):(t.replaceRangeWith(a,c,e),am(t,n,e.isInline?-1:1))}}static findFrom(t,e,n=!1){let r=t.parent.inlineContent?new _s(t):fs(t.node(0),t.parent,t.pos,t.index(),e,n);if(r)return r;for(let s=t.depth-1;s>=0;s--){let i=e<0?fs(t.node(0),t.node(s),t.before(s+1),t.index(s),e,n):fs(t.node(0),t.node(s),t.after(s+1),t.index(s)+1,e,n);if(i)return i}return null}static near(t,e=1){return this.findFrom(t,e)||this.findFrom(t,-e)||new Ni(t.node(0))}static atStart(t){return fs(t,t,0,0,1)||new Ni(t)}static atEnd(t){return fs(t,t,t.content.size,t.childCount,-1)||new Ni(t)}static fromJSON(t,e){if(!e||!e.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=Jc[e.type];if(!n)throw new RangeError(`No selection type ${e.type} defined`);return n.fromJSON(t,e)}static jsonID(t,e){if(t in Jc)throw new RangeError("Duplicate use of selection JSON ID "+t);return Jc[t]=e,e.prototype.jsonID=t,e}getBookmark(){return _s.between(this.$anchor,this.$head).getBookmark()}};Ve.prototype.visible=!0;var M_=class{constructor(t,e){this.$from=t,this.$to=e}},om=!1;function lm(t){!om&&!t.parent.inlineContent&&(om=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}var _s=class wi extends Ve{constructor(e,n=e){lm(e),lm(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return Ve.near(r);let s=e.resolve(n.map(this.anchor));return new wi(s.parent.inlineContent?s:r,r)}replace(e,n=Re.empty){if(super.replace(e,n),n==Re.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof wi&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Z0(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new wi(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let s=e.resolve(n);return new this(s,r==n?s:e.resolve(r))}static between(e,n,r){let s=e.pos-n.pos;if((!r||s)&&(r=s>=0?1:-1),!n.parent.inlineContent){let i=Ve.findFrom(n,r,!0)||Ve.findFrom(n,-r,!0);if(i)n=i.$head;else return Ve.near(n,r)}return e.parent.inlineContent||(s==0?e=n:(e=(Ve.findFrom(e,-r,!0)||Ve.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=s<0&&(e=n))),new wi(e,n)}};Ve.jsonID("text",_s);var Z0=class Q0{constructor(e,n){this.anchor=e,this.head=n}map(e){return new Q0(e.map(this.anchor),e.map(this.head))}resolve(e){return _s.between(e.resolve(this.anchor),e.resolve(this.head))}},Ns=class xi extends Ve{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:s}=n.mapResult(this.anchor),i=e.resolve(s);return r?Ve.near(i):new xi(i)}content(){return new Re(Pn.from(this.node),0,0)}eq(e){return e instanceof xi&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new T_(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new xi(e.resolve(n.anchor))}static create(e,n){return new xi(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}};Ns.prototype.visible=!1;Ve.jsonID("node",Ns);var T_=class e1{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new Z0(r,r):new e1(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&Ns.isSelectable(r)?new Ns(n):Ve.near(n)}},Ni=class hl extends Ve{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=Re.empty){if(n==Re.empty){e.delete(0,e.doc.content.size);let r=Ve.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new hl(e)}map(e){return new hl(e)}eq(e){return e instanceof hl}getBookmark(){return A_}};Ve.jsonID("all",Ni);var A_={map(){return this},resolve(t){return new Ni(t)}};function fs(t,e,n,r,s,i=!1){if(e.inlineContent)return _s.create(t,n);for(let o=r-(s>0?0:1);s>0?o<e.childCount:o>=0;o+=s){let l=e.child(o);if(l.isAtom){if(!i&&Ns.isSelectable(l))return Ns.create(t,n-(s<0?l.nodeSize:0))}else{let a=fs(t,l,n+s,s<0?l.childCount:0,s,i);if(a)return a}n+=l.nodeSize*s}return null}function am(t,e,n){let r=t.steps.length-1;if(r<e)return;let s=t.steps[r];if(!(s instanceof If||s instanceof X0))return;let i=t.mapping.maps[r],o;i.forEach((l,a,c,u)=>{o==null&&(o=u)}),t.setSelection(Ve.near(t.doc.resolve(o),n))}function cm(t,e){return!e||!t?t:t.bind(e)}var $o=class{constructor(t,e,n){this.name=t,this.init=cm(e.init,n),this.apply=cm(e.apply,n)}};new $o("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new $o("selection",{init(t,e){return t.selection||Ve.atStart(e.doc)},apply(t){return t.selection}}),new $o("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new $o("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}});var __=(t,e)=>{var n;const{state:r,view:s}=t,{selection:i}=r;if(!i.empty)return!1;const{$from:o}=i;if(o.parentOffset!==0)return!1;const l=o.depth-1,a=o.node(l),c=o.index(l);if(c===0)return!1;if(a.type===e)return t.commands.lift(e.name);const u=a.child(c-1);if(u.type!==e||!((n=u.lastChild)!=null&&n.isTextblock))return!1;const d=o.before(),h=d-1-1,{tr:p}=r;return p.delete(d,o.after()).insert(h,o.parent.content),p.setSelection(_s.create(p.doc,h)),s.dispatch(p.scrollIntoView()),!0},N_=/^\s*>\s$/,O_=ke.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return zl("blockquote",{...le(this.options.HTMLAttributes,t),children:zl("slot",{})})},parseMarkdown:(t,e)=>{var n;const r=(n=e.parseBlockChildren)!=null?n:e.parseChildren;return e.createNode("blockquote",void 0,r(t.tokens||[]))},renderMarkdown:(t,e)=>{if(!t.content)return"";const n=">",r=[];return t.content.forEach((s,i)=>{var o,l;const u=((l=(o=e.renderChild)==null?void 0:o.call(e,s,i))!=null?l:e.renderChildren([s])).split(`
|
|
136
|
+
*/var em;function sT(){return em||(em=1,process.env.NODE_ENV!=="production"&&function(){function t(c,u){return c===u&&(c!==0||1/c===1/u)||c!==c&&u!==u}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var e=S,n=za,r=typeof Object.is=="function"?Object.is:t,s=n.useSyncExternalStore,i=e.useRef,o=e.useEffect,l=e.useMemo,a=e.useDebugValue;Wc.useSyncExternalStoreWithSelector=function(c,u,d,h,f){var p=i(null);if(p.current===null){var g={hasValue:!1,value:null};p.current=g}else g=p.current;p=l(function(){function b(C){if(!w){if(w=!0,v=C,C=h(C),f!==void 0&&g.hasValue){var M=g.value;if(f(M,C))return x=M}return x=C}if(M=x,r(v,C))return M;var O=h(C);return f!==void 0&&f(M,O)?(v=C,M):(v=C,x=O)}var w=!1,v,x,k=d===void 0?null:d;return[function(){return b(u())},k===null?void 0:function(){return b(k())}]},[u,d,h,f]);var y=s(c,p[0],p[1]);return o(function(){g.hasValue=!0,g.value=y},[y]),a(y),y},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),Wc}process.env.NODE_ENV==="production"?Zu.exports=rT():Zu.exports=sT();var iT=Zu.exports,oT=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},lT=({contentComponent:t})=>{const e=za.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return m.jsx(m.Fragment,{children:Object.values(e)})};function aT(){const t=new Set;let e={};return{subscribe(n){return t.add(n),()=>{t.delete(n)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(n,r){e={...e,[n]:Hs.createPortal(r.reactElement,r.element,n)},t.forEach(s=>s())},removeRenderer(n){const r={...e};delete r[n],e=r,t.forEach(s=>s())}}}var cT=class extends S.Component{constructor(t){super(t),this.editorContentRef=S.createRef()}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){var t;const e=this.props.editor;if(e&&!e.isDestroyed&&((t=e.view.dom)!=null&&t.parentNode)){if(e.contentComponent)return;const n=this.editorContentRef.current;n.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:n}),e.contentComponent=aT(),e.createNodeViews(),e.isEditorContentInitialized=!0,this.forceUpdate()}}componentWillUnmount(){var t;const e=this.props.editor;if(e){e.isEditorContentInitialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),e.contentComponent=null;try{if(!((t=e.view.dom)!=null&&t.parentNode))return;const n=document.createElement("div");n.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:n})}catch{}}}render(){const{editor:t,innerRef:e,...n}=this.props;return m.jsxs(m.Fragment,{children:[m.jsx("div",{ref:oT(e,this.editorContentRef),...n}),(t==null?void 0:t.contentComponent)&&m.jsx(lT,{contentComponent:t.contentComponent})]})}},uT=S.forwardRef((t,e)=>{const n=S.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return S.createElement(cT,{key:n,innerRef:e,...t})}),Eh=S.memo(uT),dT=typeof window<"u"?S.useLayoutEffect:S.useEffect,hT=class{constructor(t){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=t,this.lastSnapshot={editor:t,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}watch(t){if(this.editor=t,this.editor){const e=()=>{this.transactionNumber+=1,this.subscribers.forEach(r=>r())},n=this.editor;return n.on("transaction",e),()=>{n.off("transaction",e)}}}};function vo(t){var e;const[n]=S.useState(()=>new hT(t.editor)),r=iT.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:nT);return dT(()=>n.watch(t.editor),[t.editor,n]),S.useDebugValue(r),r}var tm=process.env.NODE_ENV!=="production",_y=typeof window>"u",fT=_y||!!(typeof window<"u"&&window.next),pT=class Ny{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(n=>n())}getInitialEditor(){const e=this.options.current.immediatelyRender;let n=e??!0;return _y?(n&&tm&&console.warn("SSR detected. `immediatelyRender` has been set to false to avoid hydration mismatches"),n=!1):fT&&e===void 0&&(n=!1,tm&&console.warn("Next.js detected. `immediatelyRender` defaults to false to avoid hydration mismatches. Pass `immediatelyRender: true` explicitly if you are rendering the editor only on the client.")),n?this.createEditor():null}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var s,i;return(i=(s=this.options.current).onBeforeCreate)==null?void 0:i.call(s,...r)},onBlur:(...r)=>{var s,i;return(i=(s=this.options.current).onBlur)==null?void 0:i.call(s,...r)},onCreate:(...r)=>{var s,i;return(i=(s=this.options.current).onCreate)==null?void 0:i.call(s,...r)},onDestroy:(...r)=>{var s,i;return(i=(s=this.options.current).onDestroy)==null?void 0:i.call(s,...r)},onFocus:(...r)=>{var s,i;return(i=(s=this.options.current).onFocus)==null?void 0:i.call(s,...r)},onSelectionUpdate:(...r)=>{var s,i;return(i=(s=this.options.current).onSelectionUpdate)==null?void 0:i.call(s,...r)},onTransaction:(...r)=>{var s,i;return(i=(s=this.options.current).onTransaction)==null?void 0:i.call(s,...r)},onUpdate:(...r)=>{var s,i;return(i=(s=this.options.current).onUpdate)==null?void 0:i.call(s,...r)},onContentError:(...r)=>{var s,i;return(i=(s=this.options.current).onContentError)==null?void 0:i.call(s,...r)},onDrop:(...r)=>{var s,i;return(i=(s=this.options.current).onDrop)==null?void 0:i.call(s,...r)},onPaste:(...r)=>{var s,i;return(i=(s=this.options.current).onPaste)==null?void 0:i.call(s,...r)},onDelete:(...r)=>{var s,i;return(i=(s=this.options.current).onDelete)==null?void 0:i.call(s,...r)}};return new iE(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,n){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&n.extensions?e.extensions.length!==n.extensions.length?!1:e.extensions.every((s,i)=>{var o;return s===((o=n.extensions)==null?void 0:o[i])}):e[r]===n[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?Ny.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(e),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((r,s)=>r===e[s]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,n=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){n&&n.setOptions(this.options.current);return}n&&!n.isDestroyed&&(n.destroy(),this.instanceId===e&&this.setEditor(null))},1)}};function Oy(t={},e=[]){const n=S.useRef(t);n.current=t;const[r]=S.useState(()=>new pT(n)),s=za.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return S.useDebugValue(s),S.useEffect(r.onRender(e)),vo({editor:s,selector:({transactionNumber:i})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&i===0?0:i+1}),s}var Th=S.createContext({editor:null});Th.Consumer;var Iy=()=>S.useContext(Th),Dy=S.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),Ry=()=>S.useContext(Dy);function Ly({as:t="div",...e}){const{nodeViewContentRef:n,nodeViewContentChildren:r}=Ry();return m.jsx(t,{...e,ref:n,"data-node-view-content":"",style:{whiteSpace:"pre-wrap",...e.style},children:r})}var wr=S.forwardRef((t,e)=>{const{onDragStart:n}=Ry(),r=t.as||"div";return m.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});function nm(t){return!!(typeof t=="function"&&t.prototype&&t.prototype.isReactComponent)}function rm(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.forward_ref)"||t.$$typeof.description==="react.forward_ref"))}function mT(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.memo)"||t.$$typeof.description==="react.memo"))}function gT(t){if(nm(t)||rm(t))return!0;if(mT(t)){const e=t.type;if(e)return nm(e)||rm(e)}return!1}function yT(){try{if(S.version)return parseInt(S.version.split(".")[0],10)>=19}catch{}return!1}var bT=class{constructor(t,{editor:e,props:n={},as:r="div",className:s=""}){this.ref=null,this.destroyed=!1,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=t,this.editor=e,this.props=n,this.element=document.createElement(r),this.element.classList.add("react-renderer"),s&&this.element.classList.add(...s.split(" ")),this.editor.isEditorContentInitialized?Hs.flushSync(()=>{this.render()}):queueMicrotask(()=>{this.destroyed||this.render()})}render(){var t;if(this.destroyed)return;const e=this.component,n=this.props,r=this.editor,s=yT(),i=gT(e),o={...n};o.ref&&!(s||i)&&delete o.ref,!o.ref&&(s||i)&&(o.ref=l=>{this.ref=l}),this.reactElement=m.jsx(e,{...o}),(t=r==null?void 0:r.contentComponent)==null||t.setRenderer(this.id,this)}updateProps(t={}){if(this.destroyed)return;let e=!1;const n=Object.keys(t);for(let r=0;r<n.length;r+=1){const s=n[r];if(t[s]!==this.props[s]){e=!0;break}}e&&(this.props={...this.props,...t},this.render())}destroy(){var t;this.destroyed=!0;const e=this.editor;(t=e==null?void 0:e.contentComponent)==null||t.removeRenderer(this.id);try{this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}catch{}}updateAttributes(t){Object.keys(t).forEach(e=>{this.element.setAttribute(e,t[e])})}};S.createContext({markViewContentRef:()=>{}});var wT=class extends yE{constructor(t,e,n){if(super(t,e,n),this.selectionRafId=null,this.handlePositionUpdate=()=>{const r=this.getPos();typeof r!="number"||r===this.currentPos||(this.currentPos=r,this.renderer.updateProps({getPos:()=>this.getPos()}),typeof this.options.attrs=="function"&&this.updateElementAttributes())},this.cachedExtensionWithSyncedStorage=null,!this.node.isLeaf){this.options.contentDOMElementTag?this.contentDOMElement=document.createElement(this.options.contentDOMElementTag):this.contentDOMElement=document.createElement(this.node.isInline?"span":"div"),this.contentDOMElement.dataset.nodeViewContentReact="",this.contentDOMElement.dataset.nodeViewWrapper="",this.contentDOMElement.style.whiteSpace="inherit";const r=this.dom.querySelector("[data-node-view-content]");if(!r)return;r.appendChild(this.contentDOMElement)}this.options.trackNodeViewPosition&&this.editor.on("update",this.handlePositionUpdate)}get extensionWithSyncedStorage(){if(!this.cachedExtensionWithSyncedStorage){const t=this.editor,e=this.extension;this.cachedExtensionWithSyncedStorage=new Proxy(e,{get(n,r,s){var i;return r==="storage"?(i=t.storage[e.name])!=null?i:{}:Reflect.get(n,r,s)}})}return this.cachedExtensionWithSyncedStorage}mount(){const e={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extensionWithSyncedStorage,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(c={})=>this.updateAttributes(c),deleteNode:()=>this.deleteNode(),ref:S.createRef()};if(!this.component.displayName){const c=u=>u.charAt(0).toUpperCase()+u.substring(1);this.component.displayName=c(this.extension.name)}const s={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:c=>{c&&this.contentDOMElement&&c.firstChild!==this.contentDOMElement&&(c.hasAttribute("data-node-view-wrapper")&&c.removeAttribute("data-node-view-wrapper"),c.appendChild(this.contentDOMElement))}},i=this.component,o=S.memo(c=>m.jsx(Dy.Provider,{value:s,children:S.createElement(i,c)}));o.displayName="ReactNodeView";let l=this.node.isInline?"span":"div";this.options.as&&(l=this.options.as);const{className:a=""}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new bT(o,{editor:this.editor,props:e,as:l,className:`node-${this.node.type.name} ${a}`.trim()}),this.editor.on("selectionUpdate",this.handleSelectionUpdate),this.updateElementAttributes(),this.currentPos=this.getPos()}get dom(){var t;if(this.renderer.element.firstElementChild&&!((t=this.renderer.element.firstElementChild)!=null&&t.hasAttribute("data-node-view-wrapper")))throw Error("Please use the NodeViewWrapper component for your node view.");return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}handleSelectionUpdate(){this.selectionRafId&&(cancelAnimationFrame(this.selectionRafId),this.selectionRafId=null),this.selectionRafId=requestAnimationFrame(()=>{this.selectionRafId=null;const t=this.currentPos;if(typeof t!="number")return;if(k2({selection:this.editor.state.selection,pos:t,nodeSize:this.node.nodeSize,selectedOnTextSelection:this.options.selectedOnTextSelection})){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}})}update(t,e,n){const r=l=>{this.renderer.updateProps(l),typeof this.options.attrs=="function"&&this.updateElementAttributes()};if(t.type!==this.node.type)return!1;if(typeof this.options.update=="function"){const l=this.node,a=this.decorations,c=this.innerDecorations;return this.node=t,this.decorations=e,this.innerDecorations=n,this.currentPos=this.getPos(),this.options.update({oldNode:l,oldDecorations:a,newNode:t,newDecorations:e,oldInnerDecorations:c,innerDecorations:n,updateProps:()=>r({node:t,decorations:e,innerDecorations:n,extension:this.extensionWithSyncedStorage})})}if(!(t!==this.node))return this.node=t,this.decorations=e,this.innerDecorations=n,!0;const i=this.getPos();this.node=t,this.decorations=e,this.innerDecorations=n,this.currentPos=i;const o={node:t,decorations:e,innerDecorations:n,extension:this.extensionWithSyncedStorage};return this.options.trackNodeViewPosition&&(o.getPos=()=>this.getPos()),r(o),!0}selectNode(){this.renderer.updateProps({selected:!0}),this.renderer.element.classList.add("ProseMirror-selectednode")}deselectNode(){this.renderer.updateProps({selected:!1}),this.renderer.element.classList.remove("ProseMirror-selectednode")}destroy(){this.renderer.destroy(),this.editor.off("selectionUpdate",this.handleSelectionUpdate),this.options.trackNodeViewPosition&&this.editor.off("update",this.handlePositionUpdate),this.contentDOMElement=null,this.selectionRafId&&(cancelAnimationFrame(this.selectionRafId),this.selectionRafId=null)}updateElementAttributes(){if(this.options.attrs){let t={};if(typeof this.options.attrs=="function"){const e=this.editor.extensionManager.attributes,n=Es(this.node,e);t=this.options.attrs({node:this.node,HTMLAttributes:n})}else t=this.options.attrs;this.renderer.updateAttributes(t)}}};function xr(t,e){return n=>n.editor.contentComponent?new wT(t,n,e):{}}var _h=S.createContext({get editor(){throw new Error("useTiptap must be used within a <Tiptap> provider")}});_h.displayName="TiptapContext";var xT=()=>S.useContext(_h);function jy({editor:t,instance:e,children:n}){const r=t??e;if(!r)throw new Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");const s=S.useMemo(()=>({editor:r}),[r]),i=S.useMemo(()=>({editor:r}),[r]);return m.jsx(Th.Provider,{value:i,children:m.jsx(_h.Provider,{value:s,children:n})})}jy.displayName="Tiptap";function Py({...t}){const{editor:e}=xT();return m.jsx(Eh,{editor:e,...t})}Py.displayName="Tiptap.Content";Object.assign(jy,{Content:Py});var Hl=(t,e)=>{if(t==="slot")return 0;if(t instanceof Function)return t(e);const{children:n,...r}=e??{};if(t==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[t,r,n]};function By(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let s=t.child(r),i=e.child(r);if(s==i){n+=s.nodeSize;continue}if(!s.sameMarkup(i))return n;if(s.isText&&s.text!=i.text){for(let o=0;s.text[o]==i.text[o];o++)n++;return n}if(s.content.size||i.content.size){let o=By(s.content,i.content,n+1);if(o!=null)return o}n+=s.nodeSize}}function Hy(t,e,n,r){for(let s=t.childCount,i=e.childCount;;){if(s==0||i==0)return s==i?null:{a:n,b:r};let o=t.child(--s),l=e.child(--i),a=o.nodeSize;if(o==l){n-=a,r-=a;continue}if(!o.sameMarkup(l))return{a:n,b:r};if(o.isText&&o.text!=l.text){let c=0,u=Math.min(o.text.length,l.text.length);for(;c<u&&o.text[o.text.length-c-1]==l.text[l.text.length-c-1];)c++,n--,r--;return{a:n,b:r}}if(o.content.size||l.content.size){let c=Hy(o.content,l.content,n-1,r-1);if(c)return c}n-=a,r-=a}}var Pn=class dt{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,s=0,i){for(let o=0,l=0;l<n;o++){let a=this.content[o],c=l+a.nodeSize;if(c>e&&r(a,s+l,i||null,o)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,n-u),r,s+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,s){let i="",o=!0;return this.nodesBetween(e,n,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,n-a):l.isLeaf?s?typeof s=="function"?s(l):s:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(o?o=!1:i+=r),i+=c},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,s=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(r)&&(s[s.length-1]=n.withText(n.text+r.text),i=1);i<e.content.length;i++)s.push(e.content[i]);return new dt(s,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],s=0;if(n>e)for(let i=0,o=0;o<n;i++){let l=this.content[i],a=o+l.nodeSize;a>e&&((o<e||a>n)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,n-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,n-o-1))),r.push(l),s+=l.nodeSize),o=a}return new dt(r,s)}cutByIndex(e,n){return e==n?dt.empty:e==0&&n==this.content.length?this:new dt(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let s=this.content.slice(),i=this.size+n.nodeSize-r.nodeSize;return s[e]=n,new dt(s,i)}addToStart(e){return new dt([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new dt(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))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 n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let s=this.content[n];e(s,r,n),r+=s.nodeSize}}findDiffStart(e,n=0){return By(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return Hy(this,e,n,r)}findIndex(e){if(e==0)return Ho(0,e);if(e==this.size)return Ho(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 s=this.child(n),i=r+s.nodeSize;if(i>=e)return i==e?Ho(n+1,i):Ho(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,n){if(!n)return dt.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return dt.fromArray(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return dt.empty;let n,r=0;for(let s=0;s<e.length;s++){let i=e[s];r+=i.nodeSize,s&&i.isText&&e[s-1].sameMarkup(i)?(n||(n=e.slice(0,s)),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new dt(n||e,r)}static from(e){if(!e)return dt.empty;if(e instanceof dt)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new dt([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}};Pn.empty=new Pn([],0);var Kc={index:0,offset:0};function Ho(t,e){return Kc.index=t,Kc.offset=e,Kc}var vT=class extends Error{},De=class us{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=$y(this.content,e+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new us(r,this.openStart,this.openEnd)}removeBetween(e,n){return new us(zy(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return us.empty;let r=n.openStart||0,s=n.openEnd||0;if(typeof r!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new us(Pn.fromJSON(e,n.content),r,s)}static maxOpen(e,n=!0){let r=0,s=0;for(let i=e.firstChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.lastChild)s++;return new us(e,r,s)}};De.empty=new De(Pn.empty,0,0);function zy(t,e,n){let{index:r,offset:s}=t.findIndex(e),i=t.maybeChild(r),{index:o,offset:l}=t.findIndex(n);if(s==e||i.isText){if(l!=n&&!t.child(o).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(r,i.copy(zy(i.content,e-s-1,n-s-1)))}function $y(t,e,n,r,s,i){let{index:o,offset:l}=t.findIndex(e),a=t.maybeChild(o);if(l==e||a.isText)return i&&r<=0&&s<=0&&!i.canReplace(o,o,n)?null:t.cut(0,e).append(n).append(t.cut(e));let c=$y(a.content,e-l-1,n,o==0?r-1:0,o==t.childCount-1?s-1:0,a);return c&&t.replaceChild(o,a.copy(c))}var Vy=65535,Fy=Math.pow(2,16);function kT(t,e){return t+e*Fy}function sm(t){return t&Vy}function ST(t){return(t-(t&Vy))/Fy}var Uy=1,Wy=2,ul=4,Ky=8,im=class{constructor(t,e,n){this.pos=t,this.delInfo=e,this.recover=n}get deleted(){return(this.delInfo&Ky)>0}get deletedBefore(){return(this.delInfo&(Uy|ul))>0}get deletedAfter(){return(this.delInfo&(Wy|ul))>0}get deletedAcross(){return(this.delInfo&ul)>0}},Fr=class ds{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&ds.empty)return ds.empty}recover(e){let n=0,r=sm(e);if(!this.inverted)for(let s=0;s<r;s++)n+=this.ranges[s*3+2]-this.ranges[s*3+1];return this.ranges[r*3]+n+ST(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let s=0,i=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?s:0);if(a>e)break;let c=this.ranges[l+i],u=this.ranges[l+o],d=a+c;if(e<=d){let h=c?e==a?-1:e==d?1:n:n,f=a+s+(h<0?0:u);if(r)return f;let p=e==(n<0?a:d)?null:kT(l/3,e-a),g=e==a?Wy:e==d?Uy:ul;return(n<0?e!=a:e!=d)&&(g|=Ky),new im(f,g,p)}s+=u-c}return r?e+s:new im(e+s,0,null)}touches(e,n){let r=0,s=sm(n),i=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+i],u=a+c;if(e<=u&&l==s*3)return!0;r+=this.ranges[l+o]-c}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let s=0,i=0;s<this.ranges.length;s+=3){let o=this.ranges[s],l=o-(this.inverted?i:0),a=o+(this.inverted?0:i),c=this.ranges[s+n],u=this.ranges[s+r];e(l,l+c,a,a+u),i+=u-c}}invert(){return new ds(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?ds.empty:new ds(e<0?[0,-e,0]:[0,0,e])}};Fr.empty=new Fr([]);var qc=Object.create(null),at=class{getMap(){return Fr.empty}merge(t){return null}static fromJSON(t,e){if(!e||!e.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=qc[e.stepType];if(!n)throw new RangeError(`No step type ${e.stepType} defined`);return n.fromJSON(t,e)}static jsonID(t,e){if(t in qc)throw new RangeError("Duplicate use of step JSON ID "+t);return qc[t]=e,e.prototype.jsonID=t,e}},pt=class mi{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new mi(e,null)}static fail(e){return new mi(null,e)}static fromReplace(e,n,r,s){try{return mi.ok(e.replace(n,r,s))}catch(i){if(i instanceof vT)return mi.fail(i.message);throw i}}};function Nh(t,e,n){let r=[];for(let s=0;s<t.childCount;s++){let i=t.child(s);i.content.size&&(i=i.copy(Nh(i.content,e,i))),i.isInline&&(i=e(i,n,s)),r.push(i)}return Pn.fromArray(r)}var qy=class gi extends at{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),s=r.node(r.sharedDepth(this.to)),i=new De(Nh(n.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),s),n.openStart,n.openEnd);return pt.fromReplace(e,this.from,this.to,i)}invert(){return new Jy(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new gi(n.pos,r.pos,this.mark)}merge(e){return e instanceof gi&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new gi(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,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new gi(n.from,n.to,e.markFromJSON(n.mark))}};at.jsonID("addMark",qy);var Jy=class yi extends at{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new De(Nh(n.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),n.openStart,n.openEnd);return pt.fromReplace(e,this.from,this.to,r)}invert(){return new qy(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new yi(n.pos,r.pos,this.mark)}merge(e){return e instanceof yi&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new yi(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,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new yi(n.from,n.to,e.markFromJSON(n.mark))}};at.jsonID("removeMark",Jy);var Gy=class bi extends at{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return pt.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return pt.fromReplace(e,this.pos,this.pos+1,new De(Pn.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let s=0;s<n.marks.length;s++)if(!n.marks[s].isInSet(r))return new bi(this.pos,n.marks[s]);return new bi(this.pos,this.mark)}}return new Yy(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new bi(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new bi(n.pos,e.markFromJSON(n.mark))}};at.jsonID("addNodeMark",Gy);var Yy=class Qu extends at{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return pt.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return pt.fromReplace(e,this.pos,this.pos+1,new De(Pn.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new Gy(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Qu(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Qu(n.pos,e.markFromJSON(n.mark))}};at.jsonID("removeNodeMark",Yy);var Oh=class Xn extends at{constructor(e,n,r,s=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=s}apply(e){return this.structure&&ed(e,this.from,this.to)?pt.fail("Structure replace would overwrite content"):pt.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Fr([this.from,this.to-this.from,this.slice.size])}invert(e){return new Xn(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.to,-1),r=this.from==this.to&&Xn.MAP_BIAS<0?n:e.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new Xn(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Xn)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?De.empty:new De(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Xn(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?De.empty:new De(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Xn(e.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Xn(n.from,n.to,De.fromJSON(e,n.slice),!!n.structure)}};Oh.MAP_BIAS=1;at.jsonID("replace",Oh);var Xy=class dl extends at{constructor(e,n,r,s,i,o,l=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=s,this.slice=i,this.insert=o,this.structure=l}apply(e){if(this.structure&&(ed(e,this.from,this.gapFrom)||ed(e,this.gapTo,this.to)))return pt.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return pt.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?pt.fromReplace(e,this.from,this.to,r):pt.fail("Content does not fit in gap")}getMap(){return new Fr([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new dl(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),s=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||s<n.pos||i>r.pos?null:new dl(n.pos,r.pos,s,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new dl(n.from,n.to,n.gapFrom,n.gapTo,De.fromJSON(e,n.slice),n.insert,!!n.structure)}};at.jsonID("replaceAround",Xy);function ed(t,e,n){let r=t.resolve(e),s=n-e,i=r.depth;for(;s>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,s--;if(s>0){let o=r.node(i).maybeChild(r.indexAfter(i));for(;s>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,s--}}return!1}var CT=class hl extends at{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return pt.fail("No node at attribute step's position");let r=Object.create(null);for(let i in n.attrs)r[i]=n.attrs[i];r[this.attr]=this.value;let s=n.type.create(r,null,n.marks);return pt.fromReplace(e,this.pos,this.pos+1,new De(Pn.from(s),0,n.isLeaf?0:1))}getMap(){return Fr.empty}invert(e){return new hl(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new hl(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new hl(n.pos,n.attr,n.value)}};at.jsonID("attr",CT);var MT=class td extends at{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let s in e.attrs)n[s]=e.attrs[s];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return pt.ok(r)}getMap(){return Fr.empty}invert(e){return new td(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new td(n.attr,n.value)}};at.jsonID("docAttr",MT);var Xi=class extends Error{};Xi=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};Xi.prototype=Object.create(Error.prototype);Xi.prototype.constructor=Xi;Xi.prototype.name="TransformError";var Jc=Object.create(null),Fe=class{constructor(t,e,n){this.$anchor=t,this.$head=e,this.ranges=n||[new AT(t.min(e),t.max(e))]}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 t=this.ranges;for(let e=0;e<t.length;e++)if(t[e].$from.pos!=t[e].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(t,e=De.empty){let n=e.content.lastChild,r=null;for(let o=0;o<e.openEnd;o++)r=n,n=n.lastChild;let s=t.steps.length,i=this.ranges;for(let o=0;o<i.length;o++){let{$from:l,$to:a}=i[o],c=t.mapping.slice(s);t.replaceRange(c.map(l.pos),c.map(a.pos),o?De.empty:e),o==0&&am(t,s,(n?n.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(t,e){let n=t.steps.length,r=this.ranges;for(let s=0;s<r.length;s++){let{$from:i,$to:o}=r[s],l=t.mapping.slice(n),a=l.map(i.pos),c=l.map(o.pos);s?t.deleteRange(a,c):(t.replaceRangeWith(a,c,e),am(t,n,e.isInline?-1:1))}}static findFrom(t,e,n=!1){let r=t.parent.inlineContent?new _s(t):hs(t.node(0),t.parent,t.pos,t.index(),e,n);if(r)return r;for(let s=t.depth-1;s>=0;s--){let i=e<0?hs(t.node(0),t.node(s),t.before(s+1),t.index(s),e,n):hs(t.node(0),t.node(s),t.after(s+1),t.index(s)+1,e,n);if(i)return i}return null}static near(t,e=1){return this.findFrom(t,e)||this.findFrom(t,-e)||new Ni(t.node(0))}static atStart(t){return hs(t,t,0,0,1)||new Ni(t)}static atEnd(t){return hs(t,t,t.content.size,t.childCount,-1)||new Ni(t)}static fromJSON(t,e){if(!e||!e.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=Jc[e.type];if(!n)throw new RangeError(`No selection type ${e.type} defined`);return n.fromJSON(t,e)}static jsonID(t,e){if(t in Jc)throw new RangeError("Duplicate use of selection JSON ID "+t);return Jc[t]=e,e.prototype.jsonID=t,e}getBookmark(){return _s.between(this.$anchor,this.$head).getBookmark()}};Fe.prototype.visible=!0;var AT=class{constructor(t,e){this.$from=t,this.$to=e}},om=!1;function lm(t){!om&&!t.parent.inlineContent&&(om=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}var _s=class wi extends Fe{constructor(e,n=e){lm(e),lm(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return Fe.near(r);let s=e.resolve(n.map(this.anchor));return new wi(s.parent.inlineContent?s:r,r)}replace(e,n=De.empty){if(super.replace(e,n),n==De.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof wi&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Zy(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new wi(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let s=e.resolve(n);return new this(s,r==n?s:e.resolve(r))}static between(e,n,r){let s=e.pos-n.pos;if((!r||s)&&(r=s>=0?1:-1),!n.parent.inlineContent){let i=Fe.findFrom(n,r,!0)||Fe.findFrom(n,-r,!0);if(i)n=i.$head;else return Fe.near(n,r)}return e.parent.inlineContent||(s==0?e=n:(e=(Fe.findFrom(e,-r,!0)||Fe.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=s<0&&(e=n))),new wi(e,n)}};Fe.jsonID("text",_s);var Zy=class Qy{constructor(e,n){this.anchor=e,this.head=n}map(e){return new Qy(e.map(this.anchor),e.map(this.head))}resolve(e){return _s.between(e.resolve(this.anchor),e.resolve(this.head))}},Ns=class xi extends Fe{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:s}=n.mapResult(this.anchor),i=e.resolve(s);return r?Fe.near(i):new xi(i)}content(){return new De(Pn.from(this.node),0,0)}eq(e){return e instanceof xi&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new ET(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new xi(e.resolve(n.anchor))}static create(e,n){return new xi(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}};Ns.prototype.visible=!1;Fe.jsonID("node",Ns);var ET=class eb{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new Zy(r,r):new eb(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&Ns.isSelectable(r)?new Ns(n):Fe.near(n)}},Ni=class fl extends Fe{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=De.empty){if(n==De.empty){e.delete(0,e.doc.content.size);let r=Fe.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new fl(e)}map(e){return new fl(e)}eq(e){return e instanceof fl}getBookmark(){return TT}};Fe.jsonID("all",Ni);var TT={map(){return this},resolve(t){return new Ni(t)}};function hs(t,e,n,r,s,i=!1){if(e.inlineContent)return _s.create(t,n);for(let o=r-(s>0?0:1);s>0?o<e.childCount:o>=0;o+=s){let l=e.child(o);if(l.isAtom){if(!i&&Ns.isSelectable(l))return Ns.create(t,n-(s<0?l.nodeSize:0))}else{let a=hs(t,l,n+s,s<0?l.childCount:0,s,i);if(a)return a}n+=l.nodeSize*s}return null}function am(t,e,n){let r=t.steps.length-1;if(r<e)return;let s=t.steps[r];if(!(s instanceof Oh||s instanceof Xy))return;let i=t.mapping.maps[r],o;i.forEach((l,a,c,u)=>{o==null&&(o=u)}),t.setSelection(Fe.near(t.doc.resolve(o),n))}function cm(t,e){return!e||!t?t:t.bind(e)}var zo=class{constructor(t,e,n){this.name=t,this.init=cm(e.init,n),this.apply=cm(e.apply,n)}};new zo("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new zo("selection",{init(t,e){return t.selection||Fe.atStart(e.doc)},apply(t){return t.selection}}),new zo("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new zo("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}});var _T=(t,e)=>{var n;const{state:r,view:s}=t,{selection:i}=r;if(!i.empty)return!1;const{$from:o}=i;if(o.parentOffset!==0)return!1;const l=o.depth-1,a=o.node(l),c=o.index(l);if(c===0)return!1;if(a.type===e)return t.commands.lift(e.name);const u=a.child(c-1);if(u.type!==e||!((n=u.lastChild)!=null&&n.isTextblock))return!1;const d=o.before(),f=d-1-1,{tr:p}=r;return p.delete(d,o.after()).insert(f,o.parent.content),p.setSelection(_s.create(p.doc,f)),s.dispatch(p.scrollIntoView()),!0},NT=/^\s*>\s$/,OT=ke.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return Hl("blockquote",{...le(this.options.HTMLAttributes,t),children:Hl("slot",{})})},parseMarkdown:(t,e)=>{var n;const r=(n=e.parseBlockChildren)!=null?n:e.parseChildren;return e.createNode("blockquote",void 0,r(t.tokens||[]))},renderMarkdown:(t,e)=>{if(!t.content)return"";const n=">",r=[];return t.content.forEach((s,i)=>{var o,l;const u=((l=(o=e.renderChild)==null?void 0:o.call(e,s,i))!=null?l:e.renderChildren([s])).split(`
|
|
137
137
|
`).map(d=>d.trim()===""?n:`${n} ${d}`);r.push(u.join(`
|
|
138
138
|
`))}),r.join(`
|
|
139
139
|
${n}
|
|
140
|
-
`)},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote(),Backspace:()=>
|
|
140
|
+
`)},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote(),Backspace:()=>_T(this.editor,this.type)}},addInputRules(){return[Ts({find:NT,type:this.type})]}}),IT=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,DT=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,RT=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,LT=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,jT=Hn.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return Hl("strong",{...le(this.options.HTMLAttributes,t),children:Hl("slot",{})})},markdownTokenName:"strong",parseMarkdown:(t,e)=>e.applyMark("bold",e.parseInline(t.tokens||[])),markdownOptions:{htmlReopen:{open:"<strong>",close:"</strong>"}},renderMarkdown:(t,e)=>`**${e.renderChildren(t)}**`,addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[Vr({find:IT,type:this.type}),Vr({find:RT,type:this.type})]},addPasteRules(){return[dr({find:DT,type:this.type}),dr({find:LT,type:this.type})]}}),PT=t=>{const e=/`([^`]+)`(?!`)$/.exec(t);return!e||e.index>0&&t[e.index-1]==="`"?null:{index:e.index,text:e[0],replaceWith:e[1]}},BT=t=>{const e=/`([^`]+)`(?!`)/g,n=[];let r;for(;(r=e.exec(t))!==null;)r.index>0&&t[r.index-1]==="`"||n.push({index:r.index,text:r[0],replaceWith:r[1]});return n},HT=Hn.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",le(this.options.HTMLAttributes,t),0]},markdownTokenName:"codespan",parseMarkdown:(t,e)=>e.applyMark("code",[{type:"text",text:t.text||""}]),renderMarkdown:(t,e)=>t.content?`\`${e.renderChildren(t.content)}\``:"",addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[Vr({find:PT,type:this.type})]},addPasteRules(){return[dr({find:BT,type:this.type})]}}),Gc=4,zT=/^```([a-z]+)?[\s\n]$/,$T=/^~~~([a-z]+)?[\s\n]$/,VT=ke.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:Gc,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;const{languageClassPrefix:n}=this.options;if(!n)return null;const i=[...((e=t.firstElementChild)==null?void 0:e.classList)||[]].filter(o=>o.startsWith(n)).map(o=>o.replace(n,""))[0];return i||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",le(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(t,e)=>{var n,r;return((n=t.raw)==null?void 0:n.startsWith("```"))===!1&&((r=t.raw)==null?void 0:r.startsWith("~~~"))===!1&&t.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:t.lang||null},t.text?[e.createTextNode(t.text)]:[])},renderMarkdown:(t,e)=>{var n;let r="";const s=((n=t.attrs)==null?void 0:n.language)||"";return t.content?r=[`\`\`\`${s}`,e.renderChildren(t.content),"```"].join(`
|
|
141
141
|
`):r=`\`\`\`${s}
|
|
142
142
|
|
|
143
|
-
\`\`\``,r},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:Gc,{state:r}=t,{selection:s}=r,{$from:i,empty:o}=s;if(i.parent.type!==this.type)return!1;const l=" ".repeat(n);return o?t.commands.insertContent(l):t.commands.command(({tr:a})=>{const{from:c,to:u}=s,
|
|
143
|
+
\`\`\``,r},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:Gc,{state:r}=t,{selection:s}=r,{$from:i,empty:o}=s;if(i.parent.type!==this.type)return!1;const l=" ".repeat(n);return o?t.commands.insertContent(l):t.commands.command(({tr:a})=>{const{from:c,to:u}=s,f=r.doc.textBetween(c,u,`
|
|
144
144
|
`,`
|
|
145
145
|
`).split(`
|
|
146
146
|
`).map(p=>l+p).join(`
|
|
147
|
-
`);return a.replaceWith(c,u,r.schema.text(
|
|
147
|
+
`);return a.replaceWith(c,u,r.schema.text(f)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:Gc,{state:r}=t,{selection:s}=r,{$from:i,empty:o}=s;return i.parent.type!==this.type?!1:o?t.commands.command(({tr:l})=>{var a;const{pos:c}=i,u=i.start(),d=i.end(),f=r.doc.textBetween(u,d,`
|
|
148
148
|
`,`
|
|
149
149
|
`).split(`
|
|
150
|
-
`);let p=0,g=0;const y=c-u;for(let C=0;C<
|
|
150
|
+
`);let p=0,g=0;const y=c-u;for(let C=0;C<f.length;C+=1){if(g+f[C].length>=y){p=C;break}g+=f[C].length+1}const w=((a=f[p].match(/^ */))==null?void 0:a[0])||"",v=Math.min(w.length,n);if(v===0)return!0;let x=u;for(let C=0;C<p;C+=1)x+=f[C].length+1;return l.delete(x,x+v),c-x<=v&&l.setSelection(ee.create(l.doc,x)),!0}):t.commands.command(({tr:l})=>{const{from:a,to:c}=s,h=r.doc.textBetween(a,c,`
|
|
151
151
|
`,`
|
|
152
152
|
`).split(`
|
|
153
|
-
`).map(
|
|
154
|
-
`);return l.replaceWith(a,c,r.schema.text(
|
|
153
|
+
`).map(f=>{var p;const g=((p=f.match(/^ */))==null?void 0:p[0])||"",y=Math.min(g.length,n);return f.slice(y)}).join(`
|
|
154
|
+
`);return l.replaceWith(a,c,r.schema.text(h)),!0})},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:s}=n;if(!s||r.parent.type!==this.type)return!1;const i=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(`
|
|
155
155
|
|
|
156
|
-
`);return!i||!o?!1:t.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:r}=e,{$from:s,empty:i}=n;if(!i||s.parent.type!==this.type||!(s.parentOffset===s.parent.nodeSize-2))return!1;const l=s.after();return l===void 0?!1:r.nodeAt(l)?t.commands.command(({tr:c})=>(c.setSelection(te.near(r.resolve(l))),!0)):t.commands.exitCode()}}},addInputRules(){return[Yu({find
|
|
157
|
-
`));return o.replaceSelectionWith(this.type.create({language:i},a)),o.selection.$from.parent.type!==this.type&&o.setSelection(ee.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),t.dispatch(o),!0}}})]}}),
|
|
156
|
+
`);return!i||!o?!1:t.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:r}=e,{$from:s,empty:i}=n;if(!i||s.parent.type!==this.type||!(s.parentOffset===s.parent.nodeSize-2))return!1;const l=s.after();return l===void 0?!1:r.nodeAt(l)?t.commands.command(({tr:c})=>(c.setSelection(te.near(r.resolve(l))),!0)):t.commands.exitCode()}}},addInputRules(){return[Yu({find:zT,type:this.type,getAttributes:t=>({language:t[1]})}),Yu({find:$T,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new ce({key:new ae("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),s=r?JSON.parse(r):void 0,i=s==null?void 0:s.mode;if(!n||!i)return!1;const{tr:o,schema:l}=t.state,a=l.text(n.replace(/\r\n?/g,`
|
|
157
|
+
`));return o.replaceSelectionWith(this.type.create({language:i},a)),o.selection.$from.parent.type!==this.type&&o.setSelection(ee.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),t.dispatch(o),!0}}})]}}),FT=ke.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
|
|
158
158
|
|
|
159
|
-
`):""}),
|
|
159
|
+
`):""}),UT=ke.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",le(this.options.HTMLAttributes,t)]},renderText(){return`
|
|
160
160
|
`},renderMarkdown:()=>`
|
|
161
|
-
`,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:s,storedMarks:i}=n;if(s.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:l}=r.extensionManager,a=i||s.$to.parentOffset&&s.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:u})=>{if(u&&a&&o){const d=a.filter(f=>l.includes(f.type.name));c.ensureMarks(d)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),W_=ke.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,le(this.options.HTMLAttributes,e),0]},parseMarkdown:(t,e)=>e.createNode("heading",{level:t.depth||1},e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>{var n;const r=(n=t.attrs)!=null&&n.level?parseInt(t.attrs.level,10):1,s="#".repeat(r);return t.content?`${s} ${e.renderChildren(t.content)}`:""},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>Yu({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),q_=ke.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",le(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!lA(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,s=t();return a0(n)?s.insertContentAt(r.pos,{type:this.name}):s.insertContent({type:this.name}),s.command(({state:i,tr:o,dispatch:l})=>{if(l){const{$to:a}=o.selection,c=a.end();if(a.nodeAfter)a.nodeAfter.isTextblock?o.setSelection(ee.create(o.doc,a.pos+1)):a.nodeAfter.isBlock?o.setSelection(Y.create(o.doc,a.pos)):o.setSelection(ee.create(o.doc,a.pos));else{const u=i.schema.nodes[this.options.nextNodeType]||a.parent.type.contentMatch.defaultType,d=u==null?void 0:u.create();d&&(o.insert(c,d),o.setSelection(ee.create(o.doc,c+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[oA({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),K_=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,J_=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,G_=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,Y_=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,X_=zn.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",le(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(t,e)=>e.applyMark("italic",e.parseInline(t.tokens||[])),markdownOptions:{htmlReopen:{open:"<em>",close:"</em>"}},renderMarkdown:(t,e)=>`*${e.renderChildren(t)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Fr({find:K_,type:this.type}),Fr({find:G_,type:this.type})]},addPasteRules(){return[dr({find:J_,type:this.type}),dr({find:Y_,type:this.type})]}});const Z_="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",Q_="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2",nd="numeric",rd="ascii",sd="alpha",Oi="asciinumeric",vi="alphanumeric",id="domain",t1="emoji",eN="scheme",tN="slashscheme",Yc="whitespace";function nN(t,e){return t in e||(e[t]=[]),e[t]}function Nr(t,e,n){e[nd]&&(e[Oi]=!0,e[vi]=!0),e[rd]&&(e[Oi]=!0,e[sd]=!0),e[Oi]&&(e[vi]=!0),e[sd]&&(e[vi]=!0),e[vi]&&(e[id]=!0),e[t1]&&(e[id]=!0);for(const r in e){const s=nN(r,n);s.indexOf(t)<0&&s.push(t)}}function rN(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function wt(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}wt.groups={};wt.prototype={accepts(){return!!this.t},go(t){const e=this,n=e.j[t];if(n)return n;for(let r=0;r<e.jr.length;r++){const s=e.jr[r][0],i=e.jr[r][1];if(i&&s.test(t))return i}return e.jd},has(t,e=!1){return e?t in this.j:!!this.go(t)},ta(t,e,n,r){for(let s=0;s<t.length;s++)this.tt(t[s],e,n,r)},tr(t,e,n,r){r=r||wt.groups;let s;return e&&e.j?s=e:(s=new wt(e),n&&r&&Nr(e,n,r)),this.jr.push([t,s]),s},ts(t,e,n,r){let s=this;const i=t.length;if(!i)return s;for(let o=0;o<i-1;o++)s=s.tt(t[o]);return s.tt(t[i-1],e,n,r)},tt(t,e,n,r){r=r||wt.groups;const s=this;if(e&&e.j)return s.j[t]=e,e;const i=e;let o,l=s.go(t);if(l?(o=new wt,Object.assign(o.j,l.j),o.jr.push.apply(o.jr,l.jr),o.jd=l.jd,o.t=l.t):o=new wt,i){if(r)if(o.t&&typeof o.t=="string"){const a=Object.assign(rN(o.t,r),n);Nr(i,a,r)}else n&&Nr(i,n,r);o.t=i}return s.j[t]=o,o}};const re=(t,e,n,r,s)=>t.ta(e,n,r,s),_e=(t,e,n,r,s)=>t.tr(e,n,r,s),um=(t,e,n,r,s)=>t.ts(e,n,r,s),B=(t,e,n,r,s)=>t.tt(e,n,r,s),Tn="WORD",od="UWORD",n1="ASCIINUMERICAL",r1="ALPHANUMERICAL",Zi="LOCALHOST",ld="TLD",ad="UTLD",pl="SCHEME",hs="SLASH_SCHEME",Rf="NUM",cd="WS",Df="NL",Ii="OPENBRACE",Ri="CLOSEBRACE",$l="OPENBRACKET",Hl="CLOSEBRACKET",Fl="OPENPAREN",Vl="CLOSEPAREN",Ul="OPENANGLEBRACKET",Wl="CLOSEANGLEBRACKET",ql="FULLWIDTHLEFTPAREN",Kl="FULLWIDTHRIGHTPAREN",Jl="LEFTCORNERBRACKET",Gl="RIGHTCORNERBRACKET",Yl="LEFTWHITECORNERBRACKET",Xl="RIGHTWHITECORNERBRACKET",Zl="FULLWIDTHLESSTHAN",Ql="FULLWIDTHGREATERTHAN",ea="AMPERSAND",ta="APOSTROPHE",na="ASTERISK",er="AT",ra="BACKSLASH",sa="BACKTICK",ia="CARET",Or="COLON",Lf="COMMA",oa="DOLLAR",ln="DOT",la="EQUALS",jf="EXCLAMATION",Rt="HYPHEN",Di="PERCENT",aa="PIPE",ca="PLUS",ua="POUND",Li="QUERY",Pf="QUOTE",s1="FULLWIDTHMIDDLEDOT",Bf="SEMI",an="SLASH",ji="TILDE",da="UNDERSCORE",i1="EMOJI",fa="SYM";var o1=Object.freeze({__proto__:null,ALPHANUMERICAL:r1,AMPERSAND:ea,APOSTROPHE:ta,ASCIINUMERICAL:n1,ASTERISK:na,AT:er,BACKSLASH:ra,BACKTICK:sa,CARET:ia,CLOSEANGLEBRACKET:Wl,CLOSEBRACE:Ri,CLOSEBRACKET:Hl,CLOSEPAREN:Vl,COLON:Or,COMMA:Lf,DOLLAR:oa,DOT:ln,EMOJI:i1,EQUALS:la,EXCLAMATION:jf,FULLWIDTHGREATERTHAN:Ql,FULLWIDTHLEFTPAREN:ql,FULLWIDTHLESSTHAN:Zl,FULLWIDTHMIDDLEDOT:s1,FULLWIDTHRIGHTPAREN:Kl,HYPHEN:Rt,LEFTCORNERBRACKET:Jl,LEFTWHITECORNERBRACKET:Yl,LOCALHOST:Zi,NL:Df,NUM:Rf,OPENANGLEBRACKET:Ul,OPENBRACE:Ii,OPENBRACKET:$l,OPENPAREN:Fl,PERCENT:Di,PIPE:aa,PLUS:ca,POUND:ua,QUERY:Li,QUOTE:Pf,RIGHTCORNERBRACKET:Gl,RIGHTWHITECORNERBRACKET:Xl,SCHEME:pl,SEMI:Bf,SLASH:an,SLASH_SCHEME:hs,SYM:fa,TILDE:ji,TLD:ld,UNDERSCORE:da,UTLD:ad,UWORD:od,WORD:Tn,WS:cd});const Sn=/[a-z]/,ni=new RegExp("\\p{L}","u"),Xc=new RegExp("\\p{Emoji}","u"),Cn=/\d/,Zc=/\s/,dm="\r",Qc=`
|
|
162
|
-
`,
|
|
161
|
+
`,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:s,storedMarks:i}=n;if(s.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:l}=r.extensionManager,a=i||s.$to.parentOffset&&s.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:u})=>{if(u&&a&&o){const d=a.filter(h=>l.includes(h.type.name));c.ensureMarks(d)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),WT=ke.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,le(this.options.HTMLAttributes,e),0]},parseMarkdown:(t,e)=>e.createNode("heading",{level:t.depth||1},e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>{var n;const r=(n=t.attrs)!=null&&n.level?parseInt(t.attrs.level,10):1,s="#".repeat(r);return t.content?`${s} ${e.renderChildren(t.content)}`:""},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>Yu({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),KT=ke.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",le(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!lE(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,s=t();return ay(n)?s.insertContentAt(r.pos,{type:this.name}):s.insertContent({type:this.name}),s.command(({state:i,tr:o,dispatch:l})=>{if(l){const{$to:a}=o.selection,c=a.end();if(a.nodeAfter)a.nodeAfter.isTextblock?o.setSelection(ee.create(o.doc,a.pos+1)):a.nodeAfter.isBlock?o.setSelection(Y.create(o.doc,a.pos)):o.setSelection(ee.create(o.doc,a.pos));else{const u=i.schema.nodes[this.options.nextNodeType]||a.parent.type.contentMatch.defaultType,d=u==null?void 0:u.create();d&&(o.insert(c,d),o.setSelection(ee.create(o.doc,c+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[oE({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),qT=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,JT=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,GT=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,YT=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,XT=Hn.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",le(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(t,e)=>e.applyMark("italic",e.parseInline(t.tokens||[])),markdownOptions:{htmlReopen:{open:"<em>",close:"</em>"}},renderMarkdown:(t,e)=>`*${e.renderChildren(t)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Vr({find:qT,type:this.type}),Vr({find:GT,type:this.type})]},addPasteRules(){return[dr({find:JT,type:this.type}),dr({find:YT,type:this.type})]}});const ZT="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",QT="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2",nd="numeric",rd="ascii",sd="alpha",Oi="asciinumeric",vi="alphanumeric",id="domain",tb="emoji",e_="scheme",t_="slashscheme",Yc="whitespace";function n_(t,e){return t in e||(e[t]=[]),e[t]}function Nr(t,e,n){e[nd]&&(e[Oi]=!0,e[vi]=!0),e[rd]&&(e[Oi]=!0,e[sd]=!0),e[Oi]&&(e[vi]=!0),e[sd]&&(e[vi]=!0),e[vi]&&(e[id]=!0),e[tb]&&(e[id]=!0);for(const r in e){const s=n_(r,n);s.indexOf(t)<0&&s.push(t)}}function r_(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function wt(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}wt.groups={};wt.prototype={accepts(){return!!this.t},go(t){const e=this,n=e.j[t];if(n)return n;for(let r=0;r<e.jr.length;r++){const s=e.jr[r][0],i=e.jr[r][1];if(i&&s.test(t))return i}return e.jd},has(t,e=!1){return e?t in this.j:!!this.go(t)},ta(t,e,n,r){for(let s=0;s<t.length;s++)this.tt(t[s],e,n,r)},tr(t,e,n,r){r=r||wt.groups;let s;return e&&e.j?s=e:(s=new wt(e),n&&r&&Nr(e,n,r)),this.jr.push([t,s]),s},ts(t,e,n,r){let s=this;const i=t.length;if(!i)return s;for(let o=0;o<i-1;o++)s=s.tt(t[o]);return s.tt(t[i-1],e,n,r)},tt(t,e,n,r){r=r||wt.groups;const s=this;if(e&&e.j)return s.j[t]=e,e;const i=e;let o,l=s.go(t);if(l?(o=new wt,Object.assign(o.j,l.j),o.jr.push.apply(o.jr,l.jr),o.jd=l.jd,o.t=l.t):o=new wt,i){if(r)if(o.t&&typeof o.t=="string"){const a=Object.assign(r_(o.t,r),n);Nr(i,a,r)}else n&&Nr(i,n,r);o.t=i}return s.j[t]=o,o}};const re=(t,e,n,r,s)=>t.ta(e,n,r,s),_e=(t,e,n,r,s)=>t.tr(e,n,r,s),um=(t,e,n,r,s)=>t.ts(e,n,r,s),B=(t,e,n,r,s)=>t.tt(e,n,r,s),En="WORD",od="UWORD",nb="ASCIINUMERICAL",rb="ALPHANUMERICAL",Zi="LOCALHOST",ld="TLD",ad="UTLD",pl="SCHEME",fs="SLASH_SCHEME",Ih="NUM",cd="WS",Dh="NL",Ii="OPENBRACE",Di="CLOSEBRACE",zl="OPENBRACKET",$l="CLOSEBRACKET",Vl="OPENPAREN",Fl="CLOSEPAREN",Ul="OPENANGLEBRACKET",Wl="CLOSEANGLEBRACKET",Kl="FULLWIDTHLEFTPAREN",ql="FULLWIDTHRIGHTPAREN",Jl="LEFTCORNERBRACKET",Gl="RIGHTCORNERBRACKET",Yl="LEFTWHITECORNERBRACKET",Xl="RIGHTWHITECORNERBRACKET",Zl="FULLWIDTHLESSTHAN",Ql="FULLWIDTHGREATERTHAN",ea="AMPERSAND",ta="APOSTROPHE",na="ASTERISK",er="AT",ra="BACKSLASH",sa="BACKTICK",ia="CARET",Or="COLON",Rh="COMMA",oa="DOLLAR",ln="DOT",la="EQUALS",Lh="EXCLAMATION",Dt="HYPHEN",Ri="PERCENT",aa="PIPE",ca="PLUS",ua="POUND",Li="QUERY",jh="QUOTE",sb="FULLWIDTHMIDDLEDOT",Ph="SEMI",an="SLASH",ji="TILDE",da="UNDERSCORE",ib="EMOJI",ha="SYM";var ob=Object.freeze({__proto__:null,ALPHANUMERICAL:rb,AMPERSAND:ea,APOSTROPHE:ta,ASCIINUMERICAL:nb,ASTERISK:na,AT:er,BACKSLASH:ra,BACKTICK:sa,CARET:ia,CLOSEANGLEBRACKET:Wl,CLOSEBRACE:Di,CLOSEBRACKET:$l,CLOSEPAREN:Fl,COLON:Or,COMMA:Rh,DOLLAR:oa,DOT:ln,EMOJI:ib,EQUALS:la,EXCLAMATION:Lh,FULLWIDTHGREATERTHAN:Ql,FULLWIDTHLEFTPAREN:Kl,FULLWIDTHLESSTHAN:Zl,FULLWIDTHMIDDLEDOT:sb,FULLWIDTHRIGHTPAREN:ql,HYPHEN:Dt,LEFTCORNERBRACKET:Jl,LEFTWHITECORNERBRACKET:Yl,LOCALHOST:Zi,NL:Dh,NUM:Ih,OPENANGLEBRACKET:Ul,OPENBRACE:Ii,OPENBRACKET:zl,OPENPAREN:Vl,PERCENT:Ri,PIPE:aa,PLUS:ca,POUND:ua,QUERY:Li,QUOTE:jh,RIGHTCORNERBRACKET:Gl,RIGHTWHITECORNERBRACKET:Xl,SCHEME:pl,SEMI:Ph,SLASH:an,SLASH_SCHEME:fs,SYM:ha,TILDE:ji,TLD:ld,UNDERSCORE:da,UTLD:ad,UWORD:od,WORD:En,WS:cd});const Sn=/[a-z]/,ni=new RegExp("\\p{L}","u"),Xc=new RegExp("\\p{Emoji}","u"),Cn=/\d/,Zc=/\s/,dm="\r",Qc=`
|
|
162
|
+
`,s_="️",i_="",eu="";let $o=null,Vo=null;function o_(t=[]){const e={};wt.groups=e;const n=new wt;$o==null&&($o=hm(ZT)),Vo==null&&(Vo=hm(QT)),B(n,"'",ta),B(n,"{",Ii),B(n,"}",Di),B(n,"[",zl),B(n,"]",$l),B(n,"(",Vl),B(n,")",Fl),B(n,"<",Ul),B(n,">",Wl),B(n,"(",Kl),B(n,")",ql),B(n,"「",Jl),B(n,"」",Gl),B(n,"『",Yl),B(n,"』",Xl),B(n,"<",Zl),B(n,">",Ql),B(n,"&",ea),B(n,"*",na),B(n,"@",er),B(n,"`",sa),B(n,"^",ia),B(n,":",Or),B(n,",",Rh),B(n,"$",oa),B(n,".",ln),B(n,"=",la),B(n,"!",Lh),B(n,"-",Dt),B(n,"%",Ri),B(n,"|",aa),B(n,"+",ca),B(n,"#",ua),B(n,"?",Li),B(n,'"',jh),B(n,"/",an),B(n,";",Ph),B(n,"~",ji),B(n,"_",da),B(n,"\\",ra),B(n,"・",sb);const r=_e(n,Cn,Ih,{[nd]:!0});_e(r,Cn,r);const s=_e(r,Sn,nb,{[Oi]:!0}),i=_e(r,ni,rb,{[vi]:!0}),o=_e(n,Sn,En,{[rd]:!0});_e(o,Cn,s),_e(o,Sn,o),_e(s,Cn,s),_e(s,Sn,s);const l=_e(n,ni,od,{[sd]:!0});_e(l,Sn),_e(l,Cn,i),_e(l,ni,l),_e(i,Cn,i),_e(i,Sn),_e(i,ni,i);const a=B(n,Qc,Dh,{[Yc]:!0}),c=B(n,dm,cd,{[Yc]:!0}),u=_e(n,Zc,cd,{[Yc]:!0});B(n,eu,u),B(c,Qc,a),B(c,eu,u),_e(c,Zc,u),B(u,dm),B(u,Qc),_e(u,Zc,u),B(u,eu,u);const d=_e(n,Xc,ib,{[tb]:!0});B(d,"#"),_e(d,Xc,d),B(d,s_,d);const h=B(d,i_);B(h,"#"),_e(h,Xc,d);const f=[[Sn,o],[Cn,s]],p=[[Sn,null],[ni,l],[Cn,i]];for(let g=0;g<$o.length;g++)Kn(n,$o[g],ld,En,f);for(let g=0;g<Vo.length;g++)Kn(n,Vo[g],ad,od,p);Nr(ld,{tld:!0,ascii:!0},e),Nr(ad,{utld:!0,alpha:!0},e),Kn(n,"file",pl,En,f),Kn(n,"mailto",pl,En,f),Kn(n,"http",fs,En,f),Kn(n,"https",fs,En,f),Kn(n,"ftp",fs,En,f),Kn(n,"ftps",fs,En,f),Nr(pl,{scheme:!0,ascii:!0},e),Nr(fs,{slashscheme:!0,ascii:!0},e),t=t.sort((g,y)=>g[0]>y[0]?1:-1);for(let g=0;g<t.length;g++){const y=t[g][0],w=t[g][1]?{[e_]:!0}:{[t_]:!0};y.indexOf("-")>=0?w[id]=!0:Sn.test(y)?Cn.test(y)?w[Oi]=!0:w[rd]=!0:w[nd]=!0,um(n,y,y,w)}return um(n,"localhost",Zi,{ascii:!0}),n.jd=new wt(ha),{start:n,tokens:Object.assign({groups:e},ob)}}function lb(t,e){const n=l_(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=n.length,s=[];let i=0,o=0;for(;o<r;){let l=t,a=null,c=0,u=null,d=-1,h=-1;for(;o<r&&(a=l.go(n[o]));)l=a,l.accepts()?(d=0,h=0,u=l):d>=0&&(d+=n[o].length,h++),c+=n[o].length,i+=n[o].length,o++;i-=d,o-=h,c-=d,s.push({t:u.t,v:e.slice(i-c,i),s:i-c,e:i})}return s}function l_(t){const e=[],n=t.length;let r=0;for(;r<n;){let s=t.charCodeAt(r),i,o=s<55296||s>56319||r+1===n||(i=t.charCodeAt(r+1))<56320||i>57343?t[r]:t.slice(r,r+2);e.push(o),r+=o.length}return e}function Kn(t,e,n,r,s){let i;const o=e.length;for(let l=0;l<o-1;l++){const a=e[l];t.j[a]?i=t.j[a]:(i=new wt(r),i.jr=s.slice(),t.j[a]=i),t=i}return i=new wt(n),i.jr=s.slice(),t.j[e[o-1]]=i,i}function hm(t){const e=[],n=[];let r=0,s="0123456789";for(;r<t.length;){let i=0;for(;s.indexOf(t[r+i])>=0;)i++;if(i>0){e.push(n.join(""));for(let o=parseInt(t.substring(r,r+i),10);o>0;o--)n.pop();r+=i}else n.push(t[r]),r++}return e}const Qi={defaultProtocol:"http",events:null,format:fm,formatHref:fm,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Bh(t,e=null){let n=Object.assign({},Qi);t&&(n=Object.assign(n,t instanceof Bh?t.o:t));const r=n.ignoreTags,s=[];for(let i=0;i<r.length;i++)s.push(r[i].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=s}Bh.prototype={o:Qi,ignoreTags:[],defaultRender(t){return t},check(t){return this.get("validate",t.toString(),t)},get(t,e,n){const r=e!=null;let s=this.o[t];return s&&(typeof s=="object"?(s=n.t in s?s[n.t]:Qi[t],typeof s=="function"&&r&&(s=s(e,n))):typeof s=="function"&&r&&(s=s(e,n.t,n)),s)},getObj(t,e,n){let r=this.o[t];return typeof r=="function"&&e!=null&&(r=r(e,n.t,n)),r},render(t){const e=t.render(this);return(this.get("render",null,t)||this.defaultRender)(e,t.t,t)}};function fm(t){return t}function ab(t,e){this.t="token",this.v=t,this.tk=e}ab.prototype={isLink:!1,toString(){return this.v},toHref(t){return this.toString()},toFormattedString(t){const e=this.toString(),n=t.get("truncate",e,this),r=t.get("format",e,this);return n&&r.length>n?r.substring(0,n)+"…":r},toFormattedHref(t){return t.get("formatHref",this.toHref(t.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(t=Qi.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const e=this,n=this.toHref(t.get("defaultProtocol")),r=t.get("formatHref",n,this),s=t.get("tagName",n,e),i=this.toFormattedString(t),o={},l=t.get("className",n,e),a=t.get("target",n,e),c=t.get("rel",n,e),u=t.getObj("attributes",n,e),d=t.getObj("events",n,e);return o.href=r,l&&(o.class=l),a&&(o.target=a),c&&(o.rel=c),u&&Object.assign(o,u),{tagName:s,attributes:o,content:i,eventListeners:d}}};function Qa(t,e){class n extends ab{constructor(s,i){super(s,i),this.t=t}}for(const r in e)n.prototype[r]=e[r];return n.t=t,n}const a_=Qa("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),pm=Qa("text"),c_=Qa("nl"),Fo=Qa("url",{isLink:!0,toHref(t=Qi.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==Zi&&t[1].t===Or}}),Nt=t=>new wt(t);function u_({groups:t}){const e=t.domain.concat([ea,na,er,ra,sa,ia,oa,la,Dt,Ih,Ri,aa,ca,ua,an,ha,ji,da]),n=[ta,Or,Rh,ln,Lh,Ri,Li,jh,Ph,Ul,Wl,Ii,Di,$l,zl,Vl,Fl,Kl,ql,Jl,Gl,Yl,Xl,Zl,Ql],r=[ea,ta,na,ra,sa,ia,oa,la,Dt,Ii,Di,Ri,aa,ca,ua,Li,an,ha,ji,da],s=Nt(),i=B(s,ji);re(i,r,i),re(i,t.domain,i);const o=Nt(),l=Nt(),a=Nt();re(s,t.domain,o),re(s,t.scheme,l),re(s,t.slashscheme,a),re(o,r,i),re(o,t.domain,o);const c=B(o,er);B(i,er,c),B(l,er,c),B(a,er,c);const u=B(i,ln);re(u,r,i),re(u,t.domain,i);const d=Nt();re(c,t.domain,d),re(d,t.domain,d);const h=B(d,ln);re(h,t.domain,d);const f=Nt(a_);re(h,t.tld,f),re(h,t.utld,f),B(c,Zi,f);const p=B(d,Dt);B(p,Dt,p),re(p,t.domain,d),re(f,t.domain,d),B(f,ln,h),B(f,Dt,p);const g=B(o,Dt),y=B(o,ln);B(g,Dt,g),re(g,t.domain,o),re(y,r,i),re(y,t.domain,o);const b=Nt(Fo);re(y,t.tld,b),re(y,t.utld,b),re(b,t.domain,o),re(b,r,i),B(b,ln,y),B(b,Dt,g),B(b,er,c);const w=B(b,Or),v=Nt(Fo);re(w,t.numeric,v);const x=Nt(Fo),k=Nt();re(x,e,x),re(x,n,k),re(k,e,x),re(k,n,k),B(b,an,x),B(v,an,x);const C=B(l,Or),M=B(a,Or),O=B(M,an),_=B(O,an);re(l,t.domain,o),B(l,ln,y),B(l,Dt,g),re(a,t.domain,o),B(a,ln,y),B(a,Dt,g),re(C,t.domain,x),B(C,an,x),B(C,Li,x),re(_,t.domain,x),re(_,e,x),B(_,an,x);const A=[[Ii,Di],[zl,$l],[Vl,Fl],[Ul,Wl],[Kl,ql],[Jl,Gl],[Yl,Xl],[Zl,Ql]];for(let R=0;R<A.length;R++){const[D,L]=A[R],I=B(x,D);B(k,D,I);const N=Nt(Fo);re(I,e,N);const H=Nt();re(I,n,H),B(I,L,x),re(N,e,N),re(N,n,H),re(H,e,N),re(H,n,H),B(N,L,x),B(H,L,x)}return B(s,Zi,b),B(s,Dh,c_),{start:s,tokens:ob}}function d_(t,e,n){let r=n.length,s=0,i=[],o=[];for(;s<r;){let l=t,a=null,c=null,u=0,d=null,h=-1;for(;s<r&&!(a=l.go(n[s].t));)o.push(n[s++]);for(;s<r&&(c=a||l.go(n[s].t));)a=null,l=c,l.accepts()?(h=0,d=l):h>=0&&h++,s++,u++;if(h<0)s-=u,s<r&&(o.push(n[s]),s++);else{o.length>0&&(i.push(tu(pm,e,o)),o=[]),s-=h,u-=h;const f=d.t,p=n.slice(s-u,s);i.push(tu(f,e,p))}}return o.length>0&&i.push(tu(pm,e,o)),i}function tu(t,e,n){const r=n[0].s,s=n[n.length-1].e,i=e.slice(r,s);return new t(i,n)}const h_=typeof console<"u"&&console&&console.warn||(()=>{}),f_="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",Se={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function p_(){return wt.groups={},Se.scanner=null,Se.parser=null,Se.tokenQueue=[],Se.pluginQueue=[],Se.customSchemes=[],Se.initialized=!1,Se}function mm(t,e=!1){if(Se.initialized&&h_(`linkifyjs: already initialized - will not register custom scheme "${t}" ${f_}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format.
|
|
163
163
|
1. Must only contain digits, lowercase ASCII letters or "-"
|
|
164
164
|
2. Cannot start or end with "-"
|
|
165
|
-
3. "-" cannot repeat`);Se.customSchemes.push([t,e])}function
|
|
166
|
-
`):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(
|
|
167
|
-
`).trim(),contentLines:u,raw:
|
|
168
|
-
`)}),r=d,n=d}return[e,r]}function
|
|
165
|
+
3. "-" cannot repeat`);Se.customSchemes.push([t,e])}function m_(){Se.scanner=o_(Se.customSchemes);for(let t=0;t<Se.tokenQueue.length;t++)Se.tokenQueue[t][1]({scanner:Se.scanner});Se.parser=u_(Se.scanner.tokens);for(let t=0;t<Se.pluginQueue.length;t++)Se.pluginQueue[t][1]({scanner:Se.scanner,parser:Se.parser});return Se.initialized=!0,Se}function Hh(t){return Se.initialized||m_(),d_(Se.parser.start,t,lb(Se.scanner.start,t))}Hh.scan=lb;function cb(t,e=null,n=null){if(e&&typeof e=="object"){if(n)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);n=e,e=null}const r=new Bh(n),s=Hh(t),i=[];for(let o=0;o<s.length;o++){const l=s[o];l.isLink&&(!e||l.t===e)&&r.check(l)&&i.push(l.toFormattedObject(r))}return i}var zh="[\0- -\u2029 ]",g_=new RegExp(zh),y_=new RegExp(`${zh}$`),b_=new RegExp(zh,"g");function w_(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function x_(t){return new ce({key:new ae("autolink"),appendTransaction:(e,n,r)=>{const s=e.some(c=>c.docChanged)&&!n.doc.eq(r.doc),i=e.some(c=>c.getMeta("preventAutolink"));if(!s||i)return;const{tr:o}=r,l=Q0(n.doc,[...e]);if(ly(l).forEach(({newRange:c})=>{const u=a2(r.doc,c,f=>f.isTextblock);let d,h;if(u.length>1)d=u[0],h=r.doc.textBetween(d.pos,d.pos+d.node.nodeSize,void 0," ");else if(u.length){const f=r.doc.textBetween(c.from,c.to," "," ");if(!y_.test(f))return;d=u[0],h=r.doc.textBetween(d.pos,c.to,void 0," ")}if(d&&h){const f=h.split(g_).filter(Boolean);if(f.length<=0)return!1;const p=f[f.length-1],g=d.pos+h.lastIndexOf(p);if(!p)return!1;const y=Hh(p).map(b=>b.toObject(t.defaultProtocol));if(!w_(y))return!1;y.filter(b=>b.isLink).map(b=>({...b,from:g+b.start+1,to:g+b.end+1})).filter(b=>r.schema.marks.code?!r.doc.rangeHasMark(b.from,b.to,r.schema.marks.code):!0).filter(b=>t.validate(b.value)).filter(b=>t.shouldAutoLink(b.value)).forEach(b=>{vh(b.from,b.to,r.doc).some(w=>w.mark.type===t.type)||o.addMark(b.from,b.to,t.type.create({href:b.href}))})}}),!!o.steps.length)return o}})}function v_(t){return new ce({key:new ae("handleClickLink"),props:{handleClick:(e,n,r)=>{var s,i;if(r.button!==0||!e.editable)return!1;let o=null;if(r.target instanceof HTMLAnchorElement)o=r.target;else{const a=r.target;if(!a)return!1;const c=t.editor.view.dom;o=a.closest("a"),o&&!c.contains(o)&&(o=null)}if(!o)return!1;let l=!1;if(t.enableClickSelection&&(l=t.editor.commands.extendMarkRange(t.type.name)),t.openOnClick){const a=oy(e.state,t.type.name),c=(s=o.href)!=null?s:a.href,u=(i=o.target)!=null?i:a.target;c&&(window.open(c,u),l=!0)}return l}}})}function k_(t){return new ce({key:new ae("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{shouldAutoLink:s}=t,{state:i}=e,{selection:o}=i,{empty:l}=o;if(l)return!1;let a="";r.content.forEach(u=>{a+=u.textContent});const c=cb(a,{defaultProtocol:t.defaultProtocol}).find(u=>u.isLink&&u.value===a);return!a||!c||s!==void 0&&!s(c.value)?!1:t.editor.commands.setMark(t.type,{href:c.href})}}})}function kr(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const s=typeof r=="string"?r:r.scheme;s&&n.push(s)}),!t||t.replace(b_,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var ub=Hn.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(t=>{if(typeof t=="string"){mm(t);return}mm(t.scheme,t.optionalSlashes)})},onDestroy(){p_()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(t,e)=>!!kr(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>{const e=/^[a-z][a-z0-9+.-]*:\/\//i.test(t),n=/^[a-z][a-z0-9+.-]*:/i.test(t);if(e||n&&!t.includes("@"))return!0;const s=(t.includes("@")?t.split("@").pop():t).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(s)||!/\./.test(s))}}},addAttributes(){return{href:{default:null,parseHTML(t){return t.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class},title:{default:null}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{const e=t.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:n=>!!kr(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:e=>!!kr(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",le(this.options.HTMLAttributes,t),0]:["a",le(this.options.HTMLAttributes,{...t,href:""}),0]},markdownTokenName:"link",parseMarkdown:(t,e)=>e.applyMark("link",e.parseInline(t.tokens||[]),{href:t.href,title:t.title||null}),renderMarkdown:(t,e)=>{var n,r,s,i;const o=(r=(n=t.attrs)==null?void 0:n.href)!=null?r:"",l=(i=(s=t.attrs)==null?void 0:s.title)!=null?i:"",a=e.renderChildren(t);return l?`[${a}](${o} "${l}")`:`[${a}](${o})`},addCommands(){return{setLink:t=>({chain:e})=>{const{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!kr(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,t).setMeta("preventAutolink",!0).run():!1},toggleLink:t=>({chain:e})=>{const{href:n}=t||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:r=>!!kr(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[dr({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,s=cb(t).filter(i=>i.isLink&&this.options.isAllowedUri(i.value,{defaultValidate:o=>!!kr(o,n),protocols:n,defaultProtocol:r}));s.length&&s.forEach(i=>{this.options.shouldAutoLink(i.value)&&e.push({text:i.value,data:{href:i.href},index:i.start})})}return e},type:this.type,getAttributes:t=>{var e;return{href:(e=t.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(x_({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:s=>!!kr(s,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),t.push(v_({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(k_({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),S_=ub,C_=Object.defineProperty,M_=(t,e)=>{for(var n in e)C_(t,n,{get:e[n],enumerable:!0})},A_="listItem",gm="textStyle",ym=/^\s*([-+*])\s$/,db=ke.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:t}){return["ul",le(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>t.type!=="list"||t.ordered?[]:{type:"bulletList",content:t.items?e.parseChildren(t.items):[]},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
|
|
166
|
+
`):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(A_,this.editor.getAttributes(gm)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=Ts({find:ym,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Ts({find:ym,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(gm),editor:this.editor})),[t]}}),E_=(t,e,n)=>{const{selection:r}=t;if(!r.empty)return null;const{$from:s}=r;if(!s.parent.isTextblock||s.parentOffset!==s.parent.content.size)return null;let i=-1;for(let f=s.depth;f>0;f-=1)if(s.node(f).type.name===e){i=f;break}if(i<0)return null;const o=s.node(i),l=s.index(i);if(l+1>=o.childCount)return null;const a=o.child(l+1);if(!n.includes(a.type.name))return null;const c=t.schema.nodes[e];let u=!1;if(a.forEach(f=>{f.type===c&&f.childCount>1&&(u=!0)}),!u)return null;const d=t.doc.resolve(s.after()).nodeAfter;if(!d||!n.includes(d.type.name))return null;const h=[];return d.forEach(f=>{h.push(f)}),h.length===0?null:{listItemDepth:i,nestedList:d,nestedListPos:s.after(),insertPos:s.after(i),items:h}},T_=(t,e,n,r)=>{const s=E_(t,n,r);if(!s)return!1;const{selection:i}=t,{nestedList:o,nestedListPos:l,insertPos:a,items:c}=s,u=t.tr;u.delete(l,l+o.nodeSize);const d=u.mapping.map(a);return u.insert(d,j.from(c)),u.setSelection(i.map(u.doc,u.mapping)),e&&e(u),!0},__=(t,e,n)=>T_(t.state,t.view.dispatch,e,n),hb=(t,e)=>ie.create({name:`${t}BranchingDeleteKeymap`,priority:101,addKeyboardShortcuts(){const n=()=>__(this.editor,t,e);return{Delete:n,"Mod-Delete":n}}});function N_(t){var e,n;const r=(e=t.tokens)==null?void 0:e[0];return!!(t.text&&((n=t.tokens)==null?void 0:n.length)===1&&(r==null?void 0:r.type)==="list"&&r.ordered&&r.raw===t.text)}function O_(t,e){return e.tokenizeInline?e.parseInline(e.tokenizeInline(t)):e.parseInline([{type:"text",raw:t,text:t}])}var fb=ke.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",le(this.options.HTMLAttributes,t),0]},markdownTokenName:"list_item",parseMarkdown:(t,e)=>{var n;if(t.type!=="list_item")return[];const r=(n=e.parseBlockChildren)!=null?n:e.parseChildren;let s=[];if(t.tokens&&t.tokens.length>0){if(N_(t))return{type:"listItem",content:[{type:"paragraph",content:O_(t.text||"",e)}]};if(t.tokens.some(o=>o.type==="paragraph"))s=r(t.tokens);else{const o=t.tokens[0];if(o&&o.type==="text"&&o.tokens&&o.tokens.length>0){if(s=[{type:"paragraph",content:e.parseInline(o.tokens)}],t.tokens.length>1){const a=t.tokens.slice(1),c=r(a);s.push(...c)}}else s=r(t.tokens)}}return s.length===0&&(s=[{type:"paragraph",content:[]}]),{type:"listItem",content:s}},renderMarkdown:(t,e,n)=>Ah(t,e,r=>{var s,i;return r.parentType==="bulletList"?"- ":r.parentType==="orderedList"?`${(((i=(s=r.meta)==null?void 0:s.parentAttrs)==null?void 0:i.start)||1)+r.index}. `:"- "},n),addExtensions(){return[hb(this.name,[this.options.bulletListTypeName,this.options.orderedListTypeName])]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),I_={};M_(I_,{findListItemPos:()=>ec,getNextListDepth:()=>$h,handleBackspace:()=>ud,handleDelete:()=>dd,hasListBefore:()=>pb,hasListItemAfter:()=>D_,hasListItemBefore:()=>R_,listItemHasSubList:()=>L_,nextListIsDeeper:()=>mb,nextListIsHigher:()=>gb});var ec=(t,e)=>{const{$from:n}=e.selection,r=Le(t,e.schema);let s=null,i=n.depth,o=n.pos,l=null;for(;i>0&&l===null;)s=n.node(i),s.type===r?l=i:(i-=1,o-=1);return l===null?null:{$pos:e.doc.resolve(o),depth:l}},$h=(t,e)=>{const n=ec(t,e);if(!n)return!1;const[,r]=y2(e,t,n.$pos.pos+4);return r},pb=(t,e,n)=>{const{$anchor:r}=t.selection,s=Math.max(0,r.pos-2),i=t.doc.resolve(s).node();return!(!i||!n.includes(i.type.name))},ud=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!ur(t.state,e)&&pb(t.state,e,n)){const{$anchor:r}=t.state.selection,s=t.state.doc.resolve(r.before()-1),i=[];s.node().descendants((a,c)=>{a.type.name===e&&i.push({node:a,pos:c})});const o=i.at(-1);if(!o)return!1;const l=t.state.doc.resolve(s.start()+o.pos+1);return t.chain().cut({from:r.start()-1,to:r.end()+1},l.end()).joinForward().run()}return!ur(t.state,e)||!v2(t.state)?!1:t.chain().liftListItem(e).run()},mb=(t,e)=>{const n=$h(t,e),r=ec(t,e);return!r||!n?!1:n>r.depth},gb=(t,e)=>{const n=$h(t,e),r=ec(t,e);return!r||!n?!1:n<r.depth},dd=(t,e)=>{if(!ur(t.state,e)||!x2(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:s}=n;return!n.empty&&r.sameParent(s)?!1:mb(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():gb(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},D_=(t,e)=>{var n;const{$anchor:r}=e.selection,s=e.doc.resolve(r.pos-r.parentOffset-2);return!(s.index()===s.parent.childCount-1||((n=s.nodeAfter)==null?void 0:n.type.name)!==t)},R_=(t,e)=>{var n;const{$anchor:r}=e.selection,s=e.doc.resolve(r.pos-2);return!(s.index()===0||((n=s.nodeBefore)==null?void 0:n.type.name)!==t)},L_=(t,e,n)=>{if(!n)return!1;const r=Le(t,e.schema);let s=!1;return n.descendants(i=>{i.type===r&&(s=!0)}),s},yb=ie.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&dd(t,n)&&(e=!0)}),e},"Mod-Delete":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&dd(t,n)&&(e=!0)}),e},Backspace:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&ud(t,n,r)&&(e=!0)}),e},"Mod-Backspace":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&ud(t,n,r)&&(e=!0)}),e}}}}),bm=/^(\s*)(\d+)\.\s+(.*)$/,j_=/^\s/;function P_(t){const e=t.trimStart();return/^[-+*]\s+/.test(e)||/^\d+\.\s+/.test(e)||/^>\s?/.test(e)||/^```/.test(e)||/^~~~/.test(e)}function B_(t){const e=[],n=[];let r=!1;return t.forEach(s=>{if(r){n.push(s);return}if(s.trim()===""){r=!0,n.push(s);return}if(e.length>0&&P_(s)){r=!0,n.push(s);return}e.push(s)}),{paragraphLines:e,blockLines:n}}function H_(t){const e=[];let n=0,r=0;for(;n<t.length;){const s=t[n],i=s.match(bm);if(!i)break;const[,o,l,a]=i,c=o.length,u=[a];let d=n+1;const h=[s];let f=!1;for(;d<t.length;){const p=t[d];if(p.match(bm))break;if(p.trim()==="")h.push(p),u.push(""),f=!0,d+=1;else if(p.match(j_))h.push(p),u.push(p.slice(c+2)),d+=1;else{if(f)break;h.push(p),u.push(p),d+=1}}e.push({indent:c,number:parseInt(l,10),content:u.join(`
|
|
167
|
+
`).trim(),contentLines:u,raw:h.join(`
|
|
168
|
+
`)}),r=d,n=d}return[e,r]}function bb(t,e,n){const r=[];let s=0;for(;s<t.length;){const i=t[s];if(i.indent===e){const{paragraphLines:o,blockLines:l}=B_(i.contentLines),a=o.join(`
|
|
169
169
|
`).trim(),c=[];a&&c.push({type:"paragraph",raw:a,tokens:n.inlineTokens(a)});const u=l.join(`
|
|
170
|
-
`).trim();if(u){const
|
|
171
|
-
`)})}r.push({type:"list_item",raw:i.raw,tokens:c}),s=d}else s+=1}return r}function
|
|
170
|
+
`).trim();if(u){const f=n.blockTokens(u);c.push(...f)}let d=s+1;const h=[];for(;d<t.length&&t[d].indent>e;)h.push(t[d]),d+=1;if(h.length>0){const f=Math.min(...h.map(g=>g.indent)),p=bb(h,f,n);c.push({type:"list",ordered:!0,start:h[0].number,items:p,raw:h.map(g=>g.raw).join(`
|
|
171
|
+
`)})}r.push({type:"list_item",raw:i.raw,tokens:c}),s=d}else s+=1}return r}function z_(t,e){return t.map(n=>{if(n.type!=="list_item")return e.parseChildren([n])[0];const r=[];return n.tokens&&n.tokens.length>0&&n.tokens.forEach(s=>{if(s.type==="paragraph"||s.type==="list"||s.type==="blockquote"||s.type==="code")r.push(...e.parseChildren([s]));else if(s.type==="text"&&s.tokens){const i=e.parseChildren([s]);r.push({type:"paragraph",content:i})}else{const i=e.parseChildren([s]);i.length>0&&r.push(...i)}}),{type:"listItem",content:r}})}var $_="listItem",wm="textStyle",xm=/^(\d+)\.\s$/,wb=ke.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>t.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:e,...n}=t;return e===1?["ol",le(this.options.HTMLAttributes,n),0]:["ol",le(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>{if(t.type!=="list"||!t.ordered)return[];const n=t.start||1,r=t.items?z_(t.items,e):[];return n!==1?{type:"orderedList",attrs:{start:n},content:r}:{type:"orderedList",content:r}},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
|
|
172
172
|
`):"",markdownTokenizer:{name:"orderedList",level:"block",start:t=>{const e=t.match(/^(\s*)(\d+)\.\s+/),n=e==null?void 0:e.index;return n!==void 0?n:-1},tokenize:(t,e,n)=>{var r;const s=t.split(`
|
|
173
|
-
`),[i,o]=
|
|
174
|
-
`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(
|
|
175
|
-
`):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const n=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){const r=i=>{const o=Xu(i,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:l=>({indentLevel:l[1].length,mainContent:l[4],checked:l[3].toLowerCase()==="x"}),createToken:(l,a)=>({type:"taskItem",raw:"",mainContent:l.mainContent,indentLevel:l.indentLevel,checked:l.checked,text:l.mainContent,tokens:n.inlineTokens(l.mainContent),nestedTokens:a}),customNestedParser:r},n);return o?[{type:"taskList",raw:o.raw,items:o.items}]:n.blockTokens(i)},s=Xu(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:i=>({indentLevel:i[1].length,mainContent:i[4],checked:i[3].toLowerCase()==="x"}),createToken:(i,o)=>({type:"taskItem",raw:"",mainContent:i.mainContent,indentLevel:i.indentLevel,checked:i.checked,text:i.mainContent,tokens:n.inlineTokens(i.mainContent),nestedTokens:o}),customNestedParser:r},n);if(s)return{type:"taskList",raw:s.raw,items:s.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});ie.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(d1.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(h1.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(y1.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(w1.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(VN.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(UN.configure(this.options.taskList)),t}});var Uo=" ",nu=" ",WN=ke.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",le(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{const n=t.tokens||[];if(n.length===1&&n[0].type==="image")return e.parseChildren([n[0]]);const r=e.parseInline(n);return n.length===1&&n[0].type==="text"&&(n[0].raw===Uo||n[0].text===Uo||n[0].raw===nu||n[0].text===nu)&&r.length===1&&r[0].type==="text"&&(r[0].text===Uo||r[0].text===nu)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,r)},renderMarkdown:(t,e,n)=>{var r,s;if(!t)return"";const i=Array.isArray(t.content)?t.content:[];if(i.length===0){const o=Array.isArray((r=n==null?void 0:n.previousNode)==null?void 0:r.content)?n.previousNode.content:[];return((s=n==null?void 0:n.previousNode)==null?void 0:s.type)==="paragraph"&&o.length===0?Uo:""}return e.renderChildren(i)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),qN=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,KN=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,JN=zn.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",le(this.options.HTMLAttributes,t),0]},markdownTokenName:"del",parseMarkdown:(t,e)=>e.applyMark("strike",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`~~${e.renderChildren(t)}~~`,addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Fr({find:qN,type:this.type})]},addPasteRules(){return[dr({find:KN,type:this.type})]}}),GN=ke.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),YN=zn.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",le(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`++${e.renderChildren(t)}++`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.indexOf("++")},tokenize(t,e,n){const s=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!s)return;const i=s[2].trim();return{type:"underline",raw:s[0],text:i,tokens:n.inlineTokens(i)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function XN(t={}){return new ce({view(e){return new ZN(e,t)}})}class ZN{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(s=>{let i=o=>{this[s](o)};return e.dom.addEventListener(s,i),{name:s,handler:i}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r,s=this.editorView.dom,i=s.getBoundingClientRect(),o=i.width/s.offsetWidth,l=i.height/s.offsetHeight;if(n){let d=e.nodeBefore,f=e.nodeAfter;if(d||f){let h=this.editorView.nodeDOM(this.cursorPos-(d?d.nodeSize:0));if(h){let p=h.getBoundingClientRect(),g=d?p.bottom:p.top;d&&f&&(g=(g+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let y=this.width/2*l;r={left:p.left,right:p.right,top:g-y,bottom:g+y}}}}if(!r){let d=this.editorView.coordsAtPos(this.cursorPos),f=this.width/2*o;r={left:d.left-f,right:d.left+f,top:d.top,bottom:d.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let c,u;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,u=-pageYOffset;else{let d=a.getBoundingClientRect(),f=d.width/a.offsetWidth,h=d.height/a.offsetHeight;c=d.left-a.scrollLeft*f,u=d.top-a.scrollTop*h}this.element.style.left=(r.left-c)/o+"px",this.element.style.top=(r.top-u)/l+"px",this.element.style.width=(r.right-r.left)/o+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),s=r&&r.type.spec.disableDropCursor,i=typeof s=="function"?s(this.editorView,n,e):s;if(n&&!i){let o=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=zy(this.editorView.state.doc,o,this.editorView.dragging.slice);l!=null&&(o=l)}this.setCursor(o),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class Ne extends te{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return Ne.valid(r)?new Ne(r):te.near(r)}content(){return K.empty}eq(e){return e instanceof Ne&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new Ne(e.resolve(n.pos))}getBookmark(){return new Vf(this.anchor)}static valid(e){let n=e.parent;if(n.inlineContent||!QN(e)||!eO(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let s=n.contentMatchAt(e.index()).defaultType;return s&&s.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&Ne.valid(e))return e;let s=e.pos,i=null;for(let o=e.depth;;o--){let l=e.node(o);if(n>0?e.indexAfter(o)<l.childCount:e.index(o)>0){i=l.child(n>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;s+=n;let a=e.doc.resolve(s);if(Ne.valid(a))return a}for(;;){let o=n>0?i.firstChild:i.lastChild;if(!o){if(i.isAtom&&!i.isText&&!Y.isSelectable(i)){e=e.doc.resolve(s+i.nodeSize*n),r=!1;continue e}break}i=o,s+=n;let l=e.doc.resolve(s);if(Ne.valid(l))return l}return null}}}Ne.prototype.visible=!1;Ne.findFrom=Ne.findGapCursorFrom;te.jsonID("gapcursor",Ne);class Vf{constructor(e){this.pos=e}map(e){return new Vf(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return Ne.valid(n)?new Ne(n):te.near(n)}}function x1(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function QN(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(n-1);;s=s.lastChild){if(s.childCount==0&&!s.inlineContent||x1(s.type))return!0;if(s.inlineContent)return!1}}return!0}function eO(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(n);;s=s.firstChild){if(s.childCount==0&&!s.inlineContent||x1(s.type))return!0;if(s.inlineContent)return!1}}return!0}function tO(){return new ce({props:{decorations:iO,createSelectionBetween(t,e,n){return e.pos==n.pos&&Ne.valid(n)?new Ne(n):null},handleClick:rO,handleKeyDown:nO,handleDOMEvents:{beforeinput:sO}}})}const nO=mf({ArrowLeft:Wo("horiz",-1),ArrowRight:Wo("horiz",1),ArrowUp:Wo("vert",-1),ArrowDown:Wo("vert",1)});function Wo(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,s,i){let o=r.selection,l=e>0?o.$to:o.$from,a=o.empty;if(o instanceof ee){if(!i.endOfTextblock(n)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=Ne.findGapCursorFrom(l,e,a);return c?(s&&s(r.tr.setSelection(new Ne(c))),!0):!1}}function rO(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!Ne.valid(r))return!1;let s=t.posAtCoords({left:n.clientX,top:n.clientY});return s&&s.inside>-1&&Y.isSelectable(t.state.doc.nodeAt(s.inside))?!1:(t.dispatch(t.state.tr.setSelection(new Ne(r))),!0)}function sO(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof Ne))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let s=j.empty;for(let o=r.length-1;o>=0;o--)s=j.from(r[o].createAndFill(null,s));let i=t.state.tr.replace(n.pos,n.pos,new K(s,0,0));return i.setSelection(ee.near(i.doc.resolve(n.pos+1))),t.dispatch(i),!1}function iO(t){if(!(t.selection instanceof Ne))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",he.create(t.doc,[De.widget(t.selection.head,e,{key:"gapcursor"})])}var ha=200,We=function(){};We.prototype.append=function(e){return e.length?(e=We.from(e),!this.length&&e||e.length<ha&&this.leafAppend(e)||this.length<ha&&e.leafPrepend(this)||this.appendInner(e)):this};We.prototype.prepend=function(e){return e.length?We.from(e).append(this):this};We.prototype.appendInner=function(e){return new oO(this,e)};We.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?We.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};We.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};We.prototype.forEach=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(e,n,r,0):this.forEachInvertedInner(e,n,r,0)};We.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var s=[];return this.forEach(function(i,o){return s.push(e(i,o))},n,r),s};We.from=function(e){return e instanceof We?e:e&&e.length?new v1(e):We.empty};var v1=function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(s,i){return s==0&&i==this.length?this:new e(this.values.slice(s,i))},e.prototype.getInner=function(s){return this.values[s]},e.prototype.forEachInner=function(s,i,o,l){for(var a=i;a<o;a++)if(s(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(s,i,o,l){for(var a=i-1;a>=o;a--)if(s(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=ha)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=ha)return new e(s.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e}(We);We.empty=new v1([]);var oO=function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,s,i,o){var l=this.left.length;if(s<l&&this.left.forEachInner(r,s,Math.min(i,l),o)===!1||i>l&&this.right.forEachInner(r,Math.max(s-l,0),Math.min(this.length,i)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,s,i,o){var l=this.left.length;if(s>l&&this.right.forEachInvertedInner(r,s-l,Math.max(i,l)-l,o+l)===!1||i<l&&this.left.forEachInvertedInner(r,Math.min(s,l),i,o)===!1)return!1},e.prototype.sliceInner=function(r,s){if(r==0&&s==this.length)return this;var i=this.left.length;return s<=i?this.left.slice(r,s):r>=i?this.right.slice(r-i,s-i):this.left.slice(r,i).append(this.right.slice(0,s-i))},e.prototype.leafAppend=function(r){var s=this.right.leafAppend(r);if(s)return new e(this.left,s)},e.prototype.leafPrepend=function(r){var s=this.left.leafPrepend(r);if(s)return new e(s,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e}(We);const lO=500;class qt{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let s,i;n&&(s=this.remapping(r,this.items.length),i=s.maps.length);let o=e.tr,l,a,c=[],u=[];return this.items.forEach((d,f)=>{if(!d.step){s||(s=this.remapping(r,f+1),i=s.maps.length),i--,u.push(d);return}if(s){u.push(new Kn(d.map));let h=d.step.map(s.slice(i)),p;h&&o.maybeStep(h).doc&&(p=o.mapping.maps[o.mapping.maps.length-1],c.push(new Kn(p,void 0,void 0,c.length+u.length))),i--,p&&s.appendMap(p,i)}else o.maybeStep(d.step);if(d.selection)return l=s?d.selection.map(s.slice(i)):d.selection,a=new qt(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:o,selection:l}}addTransform(e,n,r,s){let i=[],o=this.eventCount,l=this.items,a=!s&&l.length?l.get(l.length-1):null;for(let u=0;u<e.steps.length;u++){let d=e.steps[u].invert(e.docs[u]),f=new Kn(e.mapping.maps[u],d,n),h;(h=a&&a.merge(f))&&(f=h,u?i.pop():l=l.slice(0,l.length-1)),i.push(f),n&&(o++,n=void 0),s||(a=f)}let c=o-r.depth;return c>cO&&(l=aO(l,c),o-=c),new qt(l.append(i),o)}remapping(e,n){let r=new Ui;return this.items.forEach((s,i)=>{let o=s.mirrorOffset!=null&&i-s.mirrorOffset>=e?r.maps.length-s.mirrorOffset:void 0;r.appendMap(s.map,o)},e,n),r}addMaps(e){return this.eventCount==0?this:new qt(this.items.append(e.map(n=>new Kn(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],s=Math.max(0,this.items.length-n),i=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},s);let a=n;this.items.forEach(f=>{let h=i.getMirror(--a);if(h==null)return;o=Math.min(o,h);let p=i.maps[h];if(f.step){let g=e.steps[h].invert(e.docs[h]),y=f.selection&&f.selection.map(i.slice(a+1,h));y&&l++,r.push(new Kn(p,g,y))}else r.push(new Kn(p))},s);let c=[];for(let f=n;f<o;f++)c.push(new Kn(i.maps[f]));let u=this.items.slice(0,s).append(c).append(r),d=new qt(u,l);return d.emptyItemCount()>lO&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,s=[],i=0;return this.items.forEach((o,l)=>{if(l>=e)s.push(o),o.selection&&i++;else if(o.step){let a=o.step.map(n.slice(r)),c=a&&a.getMap();if(r--,c&&n.appendMap(c,r),a){let u=o.selection&&o.selection.map(n.slice(r));u&&i++;let d=new Kn(c.invert(),a,u),f,h=s.length-1;(f=s.length&&s[h].merge(d))?s[h]=f:s.push(d)}}else o.map&&r--},this.items.length,0),new qt(We.from(s.reverse()),i)}}qt.empty=new qt(We.empty,0);function aO(t,e){let n;return t.forEach((r,s)=>{if(r.selection&&e--==0)return n=s,!1}),t.slice(n)}let Kn=class k1{constructor(e,n,r,s){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=s}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new k1(n.getMap().invert(),n,this.selection)}}};class tr{constructor(e,n,r,s,i){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=s,this.prevComposition=i}}const cO=20;function uO(t,e,n,r){let s=n.getMeta(jr),i;if(s)return s.historyState;n.getMeta(hO)&&(t=new tr(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(jr))return o.getMeta(jr).redo?new tr(t.done.addTransform(n,void 0,r,ml(e)),t.undone,vm(n.mapping.maps),t.prevTime,t.prevComposition):new tr(t.done,t.undone.addTransform(n,void 0,r,ml(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let l=n.getMeta("composition"),a=t.prevTime==0||!o&&t.prevComposition!=l&&(t.prevTime<(n.time||0)-r.newGroupDelay||!dO(n,t.prevRanges)),c=o?ru(t.prevRanges,n.mapping):vm(n.mapping.maps);return new tr(t.done.addTransform(n,a?e.selection.getBookmark():void 0,r,ml(e)),qt.empty,c,n.time,l??t.prevComposition)}else return(i=n.getMeta("rebased"))?new tr(t.done.rebased(n,i),t.undone.rebased(n,i),ru(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new tr(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),ru(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function dO(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,s)=>{for(let i=0;i<e.length;i+=2)r<=e[i+1]&&s>=e[i]&&(n=!0)}),n}function vm(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,s,i,o)=>e.push(i,o));return e}function ru(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let s=e.map(t[r],1),i=e.map(t[r+1],-1);s<=i&&n.push(s,i)}return n}function fO(t,e,n){let r=ml(e),s=jr.get(e).spec.config,i=(n?t.undone:t.done).popEvent(e,r);if(!i)return null;let o=i.selection.resolve(i.transform.doc),l=(n?t.done:t.undone).addTransform(i.transform,e.selection.getBookmark(),s,r),a=new tr(n?l:i.remaining,n?i.remaining:l,null,0,-1);return i.transform.setSelection(o).setMeta(jr,{redo:n,historyState:a})}let su=!1,km=null;function ml(t){let e=t.plugins;if(km!=e){su=!1,km=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){su=!0;break}}return su}const jr=new ae("history"),hO=new ae("closeHistory");function pO(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new ce({key:jr,state:{init(){return new tr(qt.empty,qt.empty,null,0,-1)},apply(e,n,r){return uO(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,s=r=="historyUndo"?C1:r=="historyRedo"?E1:null;return!s||!e.editable?!1:(n.preventDefault(),s(e.state,e.dispatch))}}}})}function S1(t,e){return(n,r)=>{let s=jr.getState(n);if(!s||(t?s.undone:s.done).eventCount==0)return!1;if(r){let i=fO(s,n,t);i&&r(e?i.scrollIntoView():i)}return!0}}const C1=S1(!1,!0),E1=S1(!0,!0);var mO=ie.create({name:"characterCount",addOptions(){return{limit:null,autoTrim:!0,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{const e=(t==null?void 0:t.node)||this.editor.state.doc;if(((t==null?void 0:t.mode)||this.options.mode)==="textSize"){const r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=t=>{const e=(t==null?void 0:t.node)||this.editor.state.doc,n=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=!1;return[new ce({key:new ae("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;const s=this.options.limit,i=this.options.autoTrim;if(s==null||s===0||i===!1){t=!0;return}const o=this.storage.characters({node:r.doc});if(o>s){const l=o-s,a=0,c=l;console.warn(`[CharacterCount] Initial content exceeded limit of ${s} characters. Content was automatically trimmed.`);const u=r.tr.deleteRange(a,c);return t=!0,u}t=!0},filterTransaction:(e,n)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const s=this.storage.characters({node:n.doc}),i=this.storage.characters({node:e.doc});if(i<=r||s>r&&i>r&&i<=s)return!0;if(s>r&&i>r&&i>s||!e.getMeta("paste"))return!1;const l=e.selection.$head.pos,a=i-r,c=l-a,u=l;return e.deleteRange(c,u),!(this.storage.characters({node:e.doc})>r)}})]}}),gO=ie.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[XN(this.options)]}});ie.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new ce({key:new ae("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:s}=e,i=[];if(!n||!r)return he.create(t,[]);let o=0;this.options.mode==="deepest"&&t.descendants((a,c)=>{if(a.isText)return;if(!(s>=c&&s<=c+a.nodeSize-1))return!1;o+=1});let l=0;return t.descendants((a,c)=>{if(a.isText||!(s>=c&&s<=c+a.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&o-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";i.push(De.node(c,c+a.nodeSize,{class:this.options.className}))}),he.create(t,i)}}})]}});var yO=ie.create({name:"gapCursor",addProseMirrorPlugins(){return[tO()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=fe(G(t,"allowGapCursor",n)))!=null?e:null}}}),M1="placeholder",eo=new ae("tiptap__placeholder"),Sm=200;function Cm(t){const{editor:e,placeholder:n,dataAttribute:r,pos:s,node:i,isEmptyDoc:o,hasAnchor:l,classes:{emptyNode:a,emptyEditor:c}}=t,u=[a];return o&&u.push(c),De.node(s,s+i.nodeSize,{class:u.join(" "),[r]:typeof n=="function"?n({editor:e,node:i,pos:s,hasAnchor:l}):n})}function Em(t,e){return typeof t=="function"?t(e):t}function bO({editor:t,options:e,dataAttribute:n,doc:r,selection:s}){var i,o;if(!(t.isEditable||!e.showOnlyWhenEditable))return null;const{anchor:a}=s,c=[],u=t.isEmpty;if(e.showOnlyCurrent&&!e.includeChildren){const f=r.resolve(a),h=f.depth>0?f.node(1):f.nodeAfter,p=f.depth>0?f.before(1):a;if(h&&h.type.isTextblock&&Yi(h)){const g=a>=p&&a<=p+h.nodeSize;c.push(Cm({editor:t,isEmptyDoc:u,dataAttribute:n,hasAnchor:g,placeholder:e.placeholder,classes:{emptyEditor:e.emptyEditorClass,emptyNode:Em(e.emptyNodeClass,{editor:t,node:h,pos:p,hasAnchor:g})},node:h,pos:p}))}}else{const f=eo.getState(t.state),h=(i=f==null?void 0:f.topPos)!=null?i:0,p=(o=f==null?void 0:f.bottomPos)!=null?o:r.content.size;r.nodesBetween(h,p,(g,y)=>{const b=a>=y&&a<=y+g.nodeSize,w=!g.isLeaf&&Yi(g);return g.type.isTextblock&&(b||!e.showOnlyCurrent)&&w&&c.push(Cm({editor:t,isEmptyDoc:u,dataAttribute:n,hasAnchor:b,placeholder:e.placeholder,classes:{emptyEditor:e.emptyEditorClass,emptyNode:Em(e.emptyNodeClass,{editor:t,node:g,pos:y,hasAnchor:b})},node:g,pos:y})),e.includeChildren})}return he.create(r,c)}function wO(t){return t.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}function xO(t){const e=getComputedStyle(t),n=`${e.overflow} ${e.overflowY} ${e.overflowX}`;return/auto|scroll|overlay/.test(n)}function vO(t){let e=t;for(;e;){if(xO(e))return e;const n=e.parentElement;if(!n){const r=e.getRootNode();if(r instanceof ShadowRoot){e=r.host;continue}return window}e=n}return window}function kO(t){return t===window?{top:0,bottom:window.innerHeight}:t.getBoundingClientRect()}function SO({doc:t,view:e,scrollContainer:n}){const r=e.dom.getBoundingClientRect(),s=n?kO(n):{top:0,bottom:window.innerHeight},i=Math.max(r.top,s.top)-Sm,o=Math.min(r.bottom,s.bottom)+Sm;if(i>=o)return{top:0,bottom:t.content.size};const a=getComputedStyle(e.dom).direction==="rtl"?Math.max(r.right-2,r.left+2):r.left+2,c=e.posAtCoords({left:a,top:i+2}),u=e.posAtCoords({left:a,top:o-2});return{top:c?c.pos:0,bottom:u?u.pos:t.content.size}}var CO={init(){return{topPos:null,bottomPos:null}},apply(t,e){const n=t.getMeta(eo);return n!=null&&n.positions?{topPos:n.positions.top,bottomPos:n.positions.bottom}:t.docChanged?{topPos:e.topPos!==null?t.mapping.map(e.topPos):null,bottomPos:e.bottomPos!==null?t.mapping.map(e.bottomPos):null}:e}};function EO(t){const e=vO(t.dom),n=()=>{const l=SO({view:t,doc:t.state.doc,scrollContainer:e}),a=eo.getState(t.state);if((a==null?void 0:a.topPos)===l.top&&(a==null?void 0:a.bottomPos)===l.bottom)return;const c=t.state.tr.setMeta(eo,{positions:l});t.dispatch(c)};let r=null,s=0;const i=150,o=()=>{r===null&&(r=requestAnimationFrame(()=>{r=null;const l=performance.now();l-s>=i?(s=l,n()):o()}))};return e.addEventListener("scroll",o,{passive:!0}),n(),{update(l,a){t.state.doc.content.size!==a.doc.content.size&&o()},destroy:()=>{r!==null&&cancelAnimationFrame(r),e.removeEventListener("scroll",o)}}}function MO({editor:t,options:e}){const n=e.dataAttribute?`data-${wO(e.dataAttribute)}`:`data-${M1}`;return new ce({key:eo,state:CO,view:EO,props:{decorations:({doc:r,selection:s})=>bO({editor:t,options:e,dataAttribute:n,doc:r,selection:s})}})}var TO=ie.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:M1,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[MO({editor:this.editor,options:this.options})]}}),AO=`.ProseMirror:not(.ProseMirror-focused) *::selection {
|
|
173
|
+
`),[i,o]=H_(s);if(i.length===0)return;const l=bb(i,0,n);return l.length===0?void 0:{type:"list",ordered:!0,start:((r=i[0])==null?void 0:r.number)||1,items:l,raw:s.slice(0,o).join(`
|
|
174
|
+
`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes($_,this.editor.getAttributes(wm)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=Ts({find:xm,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Ts({find:xm,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(wm)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),V_=/^\s*(\[([( |x])?\])\s$/,F_=ke.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:t=>{const e=t.getAttribute("data-checked");return e===""||e==="true"},renderHTML:t=>({"data-checked":t.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:t,HTMLAttributes:e}){return["li",le(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(t,e)=>{const n=[];if(t.tokens&&t.tokens.length>0?n.push(e.createNode("paragraph",{},e.parseInline(t.tokens))):t.text?n.push(e.createNode("paragraph",{},[e.createNode("text",{text:t.text})])):n.push(e.createNode("paragraph",{},[])),t.nestedTokens&&t.nestedTokens.length>0){const r=e.parseChildren(t.nestedTokens);n.push(...r)}return e.createNode("taskItem",{checked:t.checked||!1},n)},renderMarkdown:(t,e)=>{var n;const s=`- [${(n=t.attrs)!=null&&n.checked?"x":" "}] `;return Ah(t,e,s)},addExtensions(){return this.options.nested?[hb(this.name,[this.options.taskListTypeName])]:[]},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{const s=document.createElement("li"),i=document.createElement("label"),o=document.createElement("span"),l=document.createElement("input"),a=document.createElement("div"),c=d=>{var h,f;l.ariaLabel=((f=(h=this.options.a11y)==null?void 0:h.checkboxLabel)==null?void 0:f.call(h,d,l.checked))||`Task item checkbox for ${d.textContent||"empty task item"}`};c(t),i.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",d=>d.preventDefault()),l.addEventListener("change",d=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}const{checked:h}=d.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:f})=>{const p=n();if(typeof p!="number")return!1;const g=f.doc.nodeAt(p);return f.setNodeMarkup(p,void 0,{...g==null?void 0:g.attrs,checked:h}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,h)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([d,h])=>{s.setAttribute(d,h)}),s.dataset.checked=t.attrs.checked,l.checked=t.attrs.checked,i.append(l,o),s.append(i,a),Object.entries(e).forEach(([d,h])=>{s.setAttribute(d,h)});let u=new Set(Object.keys(e));return{dom:s,contentDOM:a,update:d=>{if(d.type!==this.type)return!1;s.dataset.checked=d.attrs.checked,l.checked=d.attrs.checked,c(d);const h=r.extensionManager.attributes,f=Es(d,h),p=new Set(Object.keys(f)),g=this.options.HTMLAttributes;return u.forEach(y=>{p.has(y)||(y in g?s.setAttribute(y,g[y]):s.removeAttribute(y))}),Object.entries(f).forEach(([y,b])=>{b==null?y in g?s.setAttribute(y,g[y]):s.removeAttribute(y):s.setAttribute(y,b)}),u=p,!0}}}},addInputRules(){return[Ts({find:V_,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),U_=ke.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:t}){return["ul",le(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},parseMarkdown:(t,e)=>e.createNode("taskList",{},e.parseChildren(t.items||[])),renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
|
|
175
|
+
`):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const n=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){const r=i=>{const o=Xu(i,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:l=>({indentLevel:l[1].length,mainContent:l[4],checked:l[3].toLowerCase()==="x"}),createToken:(l,a)=>({type:"taskItem",raw:"",mainContent:l.mainContent,indentLevel:l.indentLevel,checked:l.checked,text:l.mainContent,tokens:n.inlineTokens(l.mainContent),nestedTokens:a}),customNestedParser:r},n);return o?[{type:"taskList",raw:o.raw,items:o.items}]:n.blockTokens(i)},s=Xu(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:i=>({indentLevel:i[1].length,mainContent:i[4],checked:i[3].toLowerCase()==="x"}),createToken:(i,o)=>({type:"taskItem",raw:"",mainContent:i.mainContent,indentLevel:i.indentLevel,checked:i.checked,text:i.mainContent,tokens:n.inlineTokens(i.mainContent),nestedTokens:o}),customNestedParser:r},n);if(s)return{type:"taskList",raw:s.raw,items:s.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});ie.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(db.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(fb.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(yb.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(wb.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(F_.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(U_.configure(this.options.taskList)),t}});var Uo=" ",nu=" ",W_=ke.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",le(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{const n=t.tokens||[];if(n.length===1&&n[0].type==="image")return e.parseChildren([n[0]]);const r=e.parseInline(n);return n.length===1&&n[0].type==="text"&&(n[0].raw===Uo||n[0].text===Uo||n[0].raw===nu||n[0].text===nu)&&r.length===1&&r[0].type==="text"&&(r[0].text===Uo||r[0].text===nu)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,r)},renderMarkdown:(t,e,n)=>{var r,s;if(!t)return"";const i=Array.isArray(t.content)?t.content:[];if(i.length===0){const o=Array.isArray((r=n==null?void 0:n.previousNode)==null?void 0:r.content)?n.previousNode.content:[];return((s=n==null?void 0:n.previousNode)==null?void 0:s.type)==="paragraph"&&o.length===0?Uo:""}return e.renderChildren(i)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),K_=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,q_=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,J_=Hn.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",le(this.options.HTMLAttributes,t),0]},markdownTokenName:"del",parseMarkdown:(t,e)=>e.applyMark("strike",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`~~${e.renderChildren(t)}~~`,addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Vr({find:K_,type:this.type})]},addPasteRules(){return[dr({find:q_,type:this.type})]}}),G_=ke.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),Y_=Hn.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",le(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`++${e.renderChildren(t)}++`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.indexOf("++")},tokenize(t,e,n){const s=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!s)return;const i=s[2].trim();return{type:"underline",raw:s[0],text:i,tokens:n.inlineTokens(i)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function X_(t={}){return new ce({view(e){return new Z_(e,t)}})}class Z_{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(s=>{let i=o=>{this[s](o)};return e.dom.addEventListener(s,i),{name:s,handler:i}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r,s=this.editorView.dom,i=s.getBoundingClientRect(),o=i.width/s.offsetWidth,l=i.height/s.offsetHeight;if(n){let d=e.nodeBefore,h=e.nodeAfter;if(d||h){let f=this.editorView.nodeDOM(this.cursorPos-(d?d.nodeSize:0));if(f){let p=f.getBoundingClientRect(),g=d?p.bottom:p.top;d&&h&&(g=(g+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let y=this.width/2*l;r={left:p.left,right:p.right,top:g-y,bottom:g+y}}}}if(!r){let d=this.editorView.coordsAtPos(this.cursorPos),h=this.width/2*o;r={left:d.left-h,right:d.left+h,top:d.top,bottom:d.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let c,u;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,u=-pageYOffset;else{let d=a.getBoundingClientRect(),h=d.width/a.offsetWidth,f=d.height/a.offsetHeight;c=d.left-a.scrollLeft*h,u=d.top-a.scrollTop*f}this.element.style.left=(r.left-c)/o+"px",this.element.style.top=(r.top-u)/l+"px",this.element.style.width=(r.right-r.left)/o+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),s=r&&r.type.spec.disableDropCursor,i=typeof s=="function"?s(this.editorView,n,e):s;if(n&&!i){let o=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=H1(this.editorView.state.doc,o,this.editorView.dragging.slice);l!=null&&(o=l)}this.setCursor(o),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class Ne extends te{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return Ne.valid(r)?new Ne(r):te.near(r)}content(){return q.empty}eq(e){return e instanceof Ne&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new Ne(e.resolve(n.pos))}getBookmark(){return new Vh(this.anchor)}static valid(e){let n=e.parent;if(n.inlineContent||!Q_(e)||!eN(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let s=n.contentMatchAt(e.index()).defaultType;return s&&s.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&Ne.valid(e))return e;let s=e.pos,i=null;for(let o=e.depth;;o--){let l=e.node(o);if(n>0?e.indexAfter(o)<l.childCount:e.index(o)>0){i=l.child(n>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;s+=n;let a=e.doc.resolve(s);if(Ne.valid(a))return a}for(;;){let o=n>0?i.firstChild:i.lastChild;if(!o){if(i.isAtom&&!i.isText&&!Y.isSelectable(i)){e=e.doc.resolve(s+i.nodeSize*n),r=!1;continue e}break}i=o,s+=n;let l=e.doc.resolve(s);if(Ne.valid(l))return l}return null}}}Ne.prototype.visible=!1;Ne.findFrom=Ne.findGapCursorFrom;te.jsonID("gapcursor",Ne);class Vh{constructor(e){this.pos=e}map(e){return new Vh(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return Ne.valid(n)?new Ne(n):te.near(n)}}function xb(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function Q_(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(n-1);;s=s.lastChild){if(s.childCount==0&&!s.inlineContent||xb(s.type))return!0;if(s.inlineContent)return!1}}return!0}function eN(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(n);;s=s.firstChild){if(s.childCount==0&&!s.inlineContent||xb(s.type))return!0;if(s.inlineContent)return!1}}return!0}function tN(){return new ce({props:{decorations:iN,createSelectionBetween(t,e,n){return e.pos==n.pos&&Ne.valid(n)?new Ne(n):null},handleClick:rN,handleKeyDown:nN,handleDOMEvents:{beforeinput:sN}}})}const nN=ph({ArrowLeft:Wo("horiz",-1),ArrowRight:Wo("horiz",1),ArrowUp:Wo("vert",-1),ArrowDown:Wo("vert",1)});function Wo(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,s,i){let o=r.selection,l=e>0?o.$to:o.$from,a=o.empty;if(o instanceof ee){if(!i.endOfTextblock(n)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=Ne.findGapCursorFrom(l,e,a);return c?(s&&s(r.tr.setSelection(new Ne(c))),!0):!1}}function rN(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!Ne.valid(r))return!1;let s=t.posAtCoords({left:n.clientX,top:n.clientY});return s&&s.inside>-1&&Y.isSelectable(t.state.doc.nodeAt(s.inside))?!1:(t.dispatch(t.state.tr.setSelection(new Ne(r))),!0)}function sN(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof Ne))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let s=j.empty;for(let o=r.length-1;o>=0;o--)s=j.from(r[o].createAndFill(null,s));let i=t.state.tr.replace(n.pos,n.pos,new q(s,0,0));return i.setSelection(ee.near(i.doc.resolve(n.pos+1))),t.dispatch(i),!1}function iN(t){if(!(t.selection instanceof Ne))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",fe.create(t.doc,[Re.widget(t.selection.head,e,{key:"gapcursor"})])}var fa=200,We=function(){};We.prototype.append=function(e){return e.length?(e=We.from(e),!this.length&&e||e.length<fa&&this.leafAppend(e)||this.length<fa&&e.leafPrepend(this)||this.appendInner(e)):this};We.prototype.prepend=function(e){return e.length?We.from(e).append(this):this};We.prototype.appendInner=function(e){return new oN(this,e)};We.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?We.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};We.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};We.prototype.forEach=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(e,n,r,0):this.forEachInvertedInner(e,n,r,0)};We.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var s=[];return this.forEach(function(i,o){return s.push(e(i,o))},n,r),s};We.from=function(e){return e instanceof We?e:e&&e.length?new vb(e):We.empty};var vb=function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(s,i){return s==0&&i==this.length?this:new e(this.values.slice(s,i))},e.prototype.getInner=function(s){return this.values[s]},e.prototype.forEachInner=function(s,i,o,l){for(var a=i;a<o;a++)if(s(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(s,i,o,l){for(var a=i-1;a>=o;a--)if(s(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=fa)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=fa)return new e(s.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e}(We);We.empty=new vb([]);var oN=function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,s,i,o){var l=this.left.length;if(s<l&&this.left.forEachInner(r,s,Math.min(i,l),o)===!1||i>l&&this.right.forEachInner(r,Math.max(s-l,0),Math.min(this.length,i)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,s,i,o){var l=this.left.length;if(s>l&&this.right.forEachInvertedInner(r,s-l,Math.max(i,l)-l,o+l)===!1||i<l&&this.left.forEachInvertedInner(r,Math.min(s,l),i,o)===!1)return!1},e.prototype.sliceInner=function(r,s){if(r==0&&s==this.length)return this;var i=this.left.length;return s<=i?this.left.slice(r,s):r>=i?this.right.slice(r-i,s-i):this.left.slice(r,i).append(this.right.slice(0,s-i))},e.prototype.leafAppend=function(r){var s=this.right.leafAppend(r);if(s)return new e(this.left,s)},e.prototype.leafPrepend=function(r){var s=this.left.leafPrepend(r);if(s)return new e(s,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e}(We);const lN=500;class Kt{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let s,i;n&&(s=this.remapping(r,this.items.length),i=s.maps.length);let o=e.tr,l,a,c=[],u=[];return this.items.forEach((d,h)=>{if(!d.step){s||(s=this.remapping(r,h+1),i=s.maps.length),i--,u.push(d);return}if(s){u.push(new qn(d.map));let f=d.step.map(s.slice(i)),p;f&&o.maybeStep(f).doc&&(p=o.mapping.maps[o.mapping.maps.length-1],c.push(new qn(p,void 0,void 0,c.length+u.length))),i--,p&&s.appendMap(p,i)}else o.maybeStep(d.step);if(d.selection)return l=s?d.selection.map(s.slice(i)):d.selection,a=new Kt(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:o,selection:l}}addTransform(e,n,r,s){let i=[],o=this.eventCount,l=this.items,a=!s&&l.length?l.get(l.length-1):null;for(let u=0;u<e.steps.length;u++){let d=e.steps[u].invert(e.docs[u]),h=new qn(e.mapping.maps[u],d,n),f;(f=a&&a.merge(h))&&(h=f,u?i.pop():l=l.slice(0,l.length-1)),i.push(h),n&&(o++,n=void 0),s||(a=h)}let c=o-r.depth;return c>cN&&(l=aN(l,c),o-=c),new Kt(l.append(i),o)}remapping(e,n){let r=new Ui;return this.items.forEach((s,i)=>{let o=s.mirrorOffset!=null&&i-s.mirrorOffset>=e?r.maps.length-s.mirrorOffset:void 0;r.appendMap(s.map,o)},e,n),r}addMaps(e){return this.eventCount==0?this:new Kt(this.items.append(e.map(n=>new qn(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],s=Math.max(0,this.items.length-n),i=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(h=>{h.selection&&l--},s);let a=n;this.items.forEach(h=>{let f=i.getMirror(--a);if(f==null)return;o=Math.min(o,f);let p=i.maps[f];if(h.step){let g=e.steps[f].invert(e.docs[f]),y=h.selection&&h.selection.map(i.slice(a+1,f));y&&l++,r.push(new qn(p,g,y))}else r.push(new qn(p))},s);let c=[];for(let h=n;h<o;h++)c.push(new qn(i.maps[h]));let u=this.items.slice(0,s).append(c).append(r),d=new Kt(u,l);return d.emptyItemCount()>lN&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,s=[],i=0;return this.items.forEach((o,l)=>{if(l>=e)s.push(o),o.selection&&i++;else if(o.step){let a=o.step.map(n.slice(r)),c=a&&a.getMap();if(r--,c&&n.appendMap(c,r),a){let u=o.selection&&o.selection.map(n.slice(r));u&&i++;let d=new qn(c.invert(),a,u),h,f=s.length-1;(h=s.length&&s[f].merge(d))?s[f]=h:s.push(d)}}else o.map&&r--},this.items.length,0),new Kt(We.from(s.reverse()),i)}}Kt.empty=new Kt(We.empty,0);function aN(t,e){let n;return t.forEach((r,s)=>{if(r.selection&&e--==0)return n=s,!1}),t.slice(n)}let qn=class kb{constructor(e,n,r,s){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=s}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new kb(n.getMap().invert(),n,this.selection)}}};class tr{constructor(e,n,r,s,i){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=s,this.prevComposition=i}}const cN=20;function uN(t,e,n,r){let s=n.getMeta(jr),i;if(s)return s.historyState;n.getMeta(fN)&&(t=new tr(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(jr))return o.getMeta(jr).redo?new tr(t.done.addTransform(n,void 0,r,ml(e)),t.undone,vm(n.mapping.maps),t.prevTime,t.prevComposition):new tr(t.done,t.undone.addTransform(n,void 0,r,ml(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let l=n.getMeta("composition"),a=t.prevTime==0||!o&&t.prevComposition!=l&&(t.prevTime<(n.time||0)-r.newGroupDelay||!dN(n,t.prevRanges)),c=o?ru(t.prevRanges,n.mapping):vm(n.mapping.maps);return new tr(t.done.addTransform(n,a?e.selection.getBookmark():void 0,r,ml(e)),Kt.empty,c,n.time,l??t.prevComposition)}else return(i=n.getMeta("rebased"))?new tr(t.done.rebased(n,i),t.undone.rebased(n,i),ru(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new tr(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),ru(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function dN(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,s)=>{for(let i=0;i<e.length;i+=2)r<=e[i+1]&&s>=e[i]&&(n=!0)}),n}function vm(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,s,i,o)=>e.push(i,o));return e}function ru(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let s=e.map(t[r],1),i=e.map(t[r+1],-1);s<=i&&n.push(s,i)}return n}function hN(t,e,n){let r=ml(e),s=jr.get(e).spec.config,i=(n?t.undone:t.done).popEvent(e,r);if(!i)return null;let o=i.selection.resolve(i.transform.doc),l=(n?t.done:t.undone).addTransform(i.transform,e.selection.getBookmark(),s,r),a=new tr(n?l:i.remaining,n?i.remaining:l,null,0,-1);return i.transform.setSelection(o).setMeta(jr,{redo:n,historyState:a})}let su=!1,km=null;function ml(t){let e=t.plugins;if(km!=e){su=!1,km=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){su=!0;break}}return su}const jr=new ae("history"),fN=new ae("closeHistory");function pN(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new ce({key:jr,state:{init(){return new tr(Kt.empty,Kt.empty,null,0,-1)},apply(e,n,r){return uN(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,s=r=="historyUndo"?Cb:r=="historyRedo"?Mb:null;return!s||!e.editable?!1:(n.preventDefault(),s(e.state,e.dispatch))}}}})}function Sb(t,e){return(n,r)=>{let s=jr.getState(n);if(!s||(t?s.undone:s.done).eventCount==0)return!1;if(r){let i=hN(s,n,t);i&&r(e?i.scrollIntoView():i)}return!0}}const Cb=Sb(!1,!0),Mb=Sb(!0,!0);var mN=ie.create({name:"characterCount",addOptions(){return{limit:null,autoTrim:!0,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{const e=(t==null?void 0:t.node)||this.editor.state.doc;if(((t==null?void 0:t.mode)||this.options.mode)==="textSize"){const r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=t=>{const e=(t==null?void 0:t.node)||this.editor.state.doc,n=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=!1;return[new ce({key:new ae("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;const s=this.options.limit,i=this.options.autoTrim;if(s==null||s===0||i===!1){t=!0;return}const o=this.storage.characters({node:r.doc});if(o>s){const l=o-s,a=0,c=l;console.warn(`[CharacterCount] Initial content exceeded limit of ${s} characters. Content was automatically trimmed.`);const u=r.tr.deleteRange(a,c);return t=!0,u}t=!0},filterTransaction:(e,n)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const s=this.storage.characters({node:n.doc}),i=this.storage.characters({node:e.doc});if(i<=r||s>r&&i>r&&i<=s)return!0;if(s>r&&i>r&&i>s||!e.getMeta("paste"))return!1;const l=e.selection.$head.pos,a=i-r,c=l-a,u=l;return e.deleteRange(c,u),!(this.storage.characters({node:e.doc})>r)}})]}}),gN=ie.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[X_(this.options)]}});ie.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new ce({key:new ae("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:s}=e,i=[];if(!n||!r)return fe.create(t,[]);let o=0;this.options.mode==="deepest"&&t.descendants((a,c)=>{if(a.isText)return;if(!(s>=c&&s<=c+a.nodeSize-1))return!1;o+=1});let l=0;return t.descendants((a,c)=>{if(a.isText||!(s>=c&&s<=c+a.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&o-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";i.push(Re.node(c,c+a.nodeSize,{class:this.options.className}))}),fe.create(t,i)}}})]}});var yN=ie.create({name:"gapCursor",addProseMirrorPlugins(){return[tN()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=he(G(t,"allowGapCursor",n)))!=null?e:null}}}),Ab="placeholder",eo=new ae("tiptap__placeholder"),Sm=200;function Cm(t){const{editor:e,placeholder:n,dataAttribute:r,pos:s,node:i,isEmptyDoc:o,hasAnchor:l,classes:{emptyNode:a,emptyEditor:c}}=t,u=[a];return o&&u.push(c),Re.node(s,s+i.nodeSize,{class:u.join(" "),[r]:typeof n=="function"?n({editor:e,node:i,pos:s,hasAnchor:l}):n})}function Mm(t,e){return typeof t=="function"?t(e):t}function bN({editor:t,options:e,dataAttribute:n,doc:r,selection:s}){var i,o;if(!(t.isEditable||!e.showOnlyWhenEditable))return null;const{anchor:a}=s,c=[],u=t.isEmpty;if(e.showOnlyCurrent&&!e.includeChildren){const h=r.resolve(a),f=h.depth>0?h.node(1):h.nodeAfter,p=h.depth>0?h.before(1):a;if(f&&f.type.isTextblock&&Yi(f)){const g=a>=p&&a<=p+f.nodeSize;c.push(Cm({editor:t,isEmptyDoc:u,dataAttribute:n,hasAnchor:g,placeholder:e.placeholder,classes:{emptyEditor:e.emptyEditorClass,emptyNode:Mm(e.emptyNodeClass,{editor:t,node:f,pos:p,hasAnchor:g})},node:f,pos:p}))}}else{const h=eo.getState(t.state),f=(i=h==null?void 0:h.topPos)!=null?i:0,p=(o=h==null?void 0:h.bottomPos)!=null?o:r.content.size;r.nodesBetween(f,p,(g,y)=>{const b=a>=y&&a<=y+g.nodeSize,w=!g.isLeaf&&Yi(g);return g.type.isTextblock&&(b||!e.showOnlyCurrent)&&w&&c.push(Cm({editor:t,isEmptyDoc:u,dataAttribute:n,hasAnchor:b,placeholder:e.placeholder,classes:{emptyEditor:e.emptyEditorClass,emptyNode:Mm(e.emptyNodeClass,{editor:t,node:g,pos:y,hasAnchor:b})},node:g,pos:y})),e.includeChildren})}return fe.create(r,c)}function wN(t){return t.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}function xN(t){const e=getComputedStyle(t),n=`${e.overflow} ${e.overflowY} ${e.overflowX}`;return/auto|scroll|overlay/.test(n)}function vN(t){let e=t;for(;e;){if(xN(e))return e;const n=e.parentElement;if(!n){const r=e.getRootNode();if(r instanceof ShadowRoot){e=r.host;continue}return window}e=n}return window}function kN(t){return t===window?{top:0,bottom:window.innerHeight}:t.getBoundingClientRect()}function SN({doc:t,view:e,scrollContainer:n}){const r=e.dom.getBoundingClientRect(),s=n?kN(n):{top:0,bottom:window.innerHeight},i=Math.max(r.top,s.top)-Sm,o=Math.min(r.bottom,s.bottom)+Sm;if(i>=o)return{top:0,bottom:t.content.size};const a=getComputedStyle(e.dom).direction==="rtl"?Math.max(r.right-2,r.left+2):r.left+2,c=e.posAtCoords({left:a,top:i+2}),u=e.posAtCoords({left:a,top:o-2});return{top:c?c.pos:0,bottom:u?u.pos:t.content.size}}var CN={init(){return{topPos:null,bottomPos:null}},apply(t,e){const n=t.getMeta(eo);return n!=null&&n.positions?{topPos:n.positions.top,bottomPos:n.positions.bottom}:t.docChanged?{topPos:e.topPos!==null?t.mapping.map(e.topPos):null,bottomPos:e.bottomPos!==null?t.mapping.map(e.bottomPos):null}:e}};function MN(t){const e=vN(t.dom),n=()=>{const l=SN({view:t,doc:t.state.doc,scrollContainer:e}),a=eo.getState(t.state);if((a==null?void 0:a.topPos)===l.top&&(a==null?void 0:a.bottomPos)===l.bottom)return;const c=t.state.tr.setMeta(eo,{positions:l});t.dispatch(c)};let r=null,s=0;const i=150,o=()=>{r===null&&(r=requestAnimationFrame(()=>{r=null;const l=performance.now();l-s>=i?(s=l,n()):o()}))};return e.addEventListener("scroll",o,{passive:!0}),n(),{update(l,a){t.state.doc.content.size!==a.doc.content.size&&o()},destroy:()=>{r!==null&&cancelAnimationFrame(r),e.removeEventListener("scroll",o)}}}function AN({editor:t,options:e}){const n=e.dataAttribute?`data-${wN(e.dataAttribute)}`:`data-${Ab}`;return new ce({key:eo,state:CN,view:MN,props:{decorations:({doc:r,selection:s})=>bN({editor:t,options:e,dataAttribute:n,doc:r,selection:s})}})}var EN=ie.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:Ab,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[AN({editor:this.editor,options:this.options})]}}),TN=`.ProseMirror:not(.ProseMirror-focused) *::selection {
|
|
176
176
|
background: transparent;
|
|
177
177
|
}
|
|
178
178
|
|
|
179
179
|
.ProseMirror:not(.ProseMirror-focused) *::-moz-selection {
|
|
180
180
|
background: transparent;
|
|
181
|
-
}`;ie.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return t.options.injectCSS&&typeof document<"u"&&M0(AO,t.options.injectNonce,"selection"),[new ce({key:new ae("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||a0(n.selection)||t.view.dragging?null:he.create(n.doc,[De.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});var _O="skipTrailingNode";function Mm({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||(e==null?void 0:e.type)===t}var NO=ie.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new ae(this.name),n=this.options.node||((t=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:t.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,s])=>s).filter(s=>(this.options.notAfter||[]).concat(n).includes(s.name));return[new ce({key:e,appendTransaction:(s,i,o)=>{const{doc:l,tr:a,schema:c}=o,u=e.getState(o),d=l.content.size,f=c.nodes[n];if(!s.some(h=>h.getMeta(_O))&&u)return a.insert(d,f.create())},state:{init:(s,i)=>{const o=i.tr.doc.lastChild;return!Mm({node:o,types:r})},apply:(s,i)=>{if(!s.docChanged||s.getMeta("__uniqueIDTransaction"))return i;const o=s.doc.lastChild;return!Mm({node:o,types:r})}}})]}}),OO=ie.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>C1(t,e),redo:()=>({state:t,dispatch:e})=>E1(t,e)}},addProseMirrorPlugins(){return[pO(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),IO=ie.create({name:"starterKit",addExtensions(){var t,e,n,r;const s=[];return this.options.bold!==!1&&s.push(j_.configure(this.options.bold)),this.options.blockquote!==!1&&s.push(O_.configure(this.options.blockquote)),this.options.bulletList!==!1&&s.push(d1.configure(this.options.bulletList)),this.options.code!==!1&&s.push(z_.configure(this.options.code)),this.options.codeBlock!==!1&&s.push(F_.configure(this.options.codeBlock)),this.options.document!==!1&&s.push(V_.configure(this.options.document)),this.options.dropcursor!==!1&&s.push(gO.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&s.push(yO.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&s.push(U_.configure(this.options.hardBreak)),this.options.heading!==!1&&s.push(W_.configure(this.options.heading)),this.options.undoRedo!==!1&&s.push(OO.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&s.push(q_.configure(this.options.horizontalRule)),this.options.italic!==!1&&s.push(X_.configure(this.options.italic)),this.options.listItem!==!1&&s.push(h1.configure(this.options.listItem)),this.options.listKeymap!==!1&&s.push(y1.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&s.push(u1.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&s.push(w1.configure(this.options.orderedList)),this.options.paragraph!==!1&&s.push(WN.configure(this.options.paragraph)),this.options.strike!==!1&&s.push(JN.configure(this.options.strike)),this.options.text!==!1&&s.push(GN.configure(this.options.text)),this.options.underline!==!1&&s.push(YN.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&s.push(NO.configure((r=this.options)==null?void 0:r.trailingNode)),s}}),T1=IO,A1=TO,RO=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,DO=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,_1=zn.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:t=>t.getAttribute("data-color")||Fs(t,"background-color")||t.style.backgroundColor,renderHTML:t=>t.color?{"data-color":t.color,style:`background-color: ${t.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:t}){return["mark",le(this.options.HTMLAttributes,t),0]},renderMarkdown:(t,e)=>`==${e.renderChildren(t)}==`,parseMarkdown:(t,e)=>e.applyMark("highlight",e.parseInline(t.tokens||[])),markdownTokenizer:{name:"highlight",level:"inline",start:t=>t.indexOf("=="),tokenize(t,e,n){const s=/^(==)([^=]+)(==)/.exec(t);if(s){const i=s[2].trim(),o=n.inlineTokens(i);return{type:"highlight",raw:s[0],text:i,tokens:o}}}},addCommands(){return{setHighlight:t=>({commands:e})=>e.setMark(this.name,t),toggleHighlight:t=>({commands:e})=>e.toggleMark(this.name,t),unsetHighlight:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[Fr({find:RO,type:this.type})]},addPasteRules(){return[dr({find:DO,type:this.type})]}});const iu=["paragraph","heading","blockquote"],LO=8,Tm=24,jO=ie.create({name:"indent",addGlobalAttributes(){return[{types:iu,attributes:{indent:{default:0,renderHTML(t){const e=t.indent;return e?{style:`padding-left: ${e*Tm}px`}:{}},parseHTML(t){const e=t.style.paddingLeft;return e?Math.round(parseInt(e)/Tm):0}}}}]},addCommands(){return{increaseIndent:()=>({state:t,chain:e})=>{const{$from:n}=t.selection;return n.node(n.depth).type.name==="listItem"?e().sinkListItem("listItem").run():e().command(({tr:s,state:i})=>{const{from:o,to:l}=i.selection;let a=!1;return i.doc.nodesBetween(o,l,(c,u)=>{if(iu.includes(c.type.name)){const d=c.attrs.indent||0;s.setNodeMarkup(u,void 0,{...c.attrs,indent:Math.min(d+1,LO)}),a=!0}}),a}).run()},decreaseIndent:()=>({state:t,chain:e})=>{const{$from:n}=t.selection;return n.node(n.depth).type.name==="listItem"?e().liftListItem("listItem").run():e().command(({tr:s,state:i})=>{const{from:o,to:l}=i.selection;let a=!1;return i.doc.nodesBetween(o,l,(c,u)=>{if(iu.includes(c.type.name)){const d=c.attrs.indent||0;d>0&&(s.setNodeMarkup(u,void 0,{...c.attrs,indent:d-1}),a=!0)}}),a}).run()}}}});let fd,hd;if(typeof WeakMap<"u"){let t=new WeakMap;fd=e=>t.get(e),hd=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;fd=r=>{for(let s=0;s<t.length;s+=2)if(t[s]==r)return t[s+1]},hd=(r,s)=>(n==10&&(n=0),t[n++]=r,t[n++]=s)}var Oe=class{constructor(t,e,n,r){this.width=t,this.height=e,this.map=n,this.problems=r}findCell(t){for(let e=0;e<this.map.length;e++){const n=this.map[e];if(n!=t)continue;const r=e%this.width,s=e/this.width|0;let i=r+1,o=s+1;for(let l=1;i<this.width&&this.map[e+l]==n;l++)i++;for(let l=1;o<this.height&&this.map[e+this.width*l]==n;l++)o++;return{left:r,top:s,right:i,bottom:o}}throw new RangeError(`No cell with offset ${t} found`)}colCount(t){for(let e=0;e<this.map.length;e++)if(this.map[e]==t)return e%this.width;throw new RangeError(`No cell with offset ${t} found`)}nextCell(t,e,n){const{left:r,right:s,top:i,bottom:o}=this.findCell(t);return e=="horiz"?(n<0?r==0:s==this.width)?null:this.map[i*this.width+(n<0?r-1:s)]:(n<0?i==0:o==this.height)?null:this.map[r+this.width*(n<0?i-1:o)]}rectBetween(t,e){const{left:n,right:r,top:s,bottom:i}=this.findCell(t),{left:o,right:l,top:a,bottom:c}=this.findCell(e);return{left:Math.min(n,o),top:Math.min(s,a),right:Math.max(r,l),bottom:Math.max(i,c)}}cellsInRect(t){const e=[],n={};for(let r=t.top;r<t.bottom;r++)for(let s=t.left;s<t.right;s++){const i=r*this.width+s,o=this.map[i];n[o]||(n[o]=!0,!(s==t.left&&s&&this.map[i-1]==o||r==t.top&&r&&this.map[i-this.width]==o)&&e.push(o))}return e}positionAt(t,e,n){for(let r=0,s=0;;r++){const i=s+n.child(r).nodeSize;if(r==t){let o=e+t*this.width;const l=(t+1)*this.width;for(;o<l&&this.map[o]<s;)o++;return o==l?i-1:this.map[o]}s=i}}static get(t){return fd(t)||hd(t,PO(t))}};function PO(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);const e=BO(t),n=t.childCount,r=[];let s=0,i=null;const o=[];for(let c=0,u=e*n;c<u;c++)r[c]=0;for(let c=0,u=0;c<n;c++){const d=t.child(c);u++;for(let p=0;;p++){for(;s<r.length&&r[s]!=0;)s++;if(p==d.childCount)break;const g=d.child(p),{colspan:y,rowspan:b,colwidth:w}=g.attrs;for(let v=0;v<b;v++){if(v+c>=n){(i||(i=[])).push({type:"overlong_rowspan",pos:u,n:b-v});break}const x=s+v*e;for(let k=0;k<y;k++){r[x+k]==0?r[x+k]=u:(i||(i=[])).push({type:"collision",row:c,pos:u,n:y-k});const C=w&&w[k];if(C){const E=(x+k)%e*2,O=o[E];O==null||O!=C&&o[E+1]==1?(o[E]=C,o[E+1]=1):O==C&&o[E+1]++}}}s+=y,u+=g.nodeSize}const f=(c+1)*e;let h=0;for(;s<f;)r[s++]==0&&h++;h&&(i||(i=[])).push({type:"missing",row:c,n:h}),u++}(e===0||n===0)&&(i||(i=[])).push({type:"zero_sized"});const l=new Oe(e,n,r,i);let a=!1;for(let c=0;!a&&c<o.length;c+=2)o[c]!=null&&o[c+1]<n&&(a=!0);return a&&zO(l,o,t),l}function BO(t){let e=-1,n=!1;for(let r=0;r<t.childCount;r++){const s=t.child(r);let i=0;if(n)for(let o=0;o<r;o++){const l=t.child(o);for(let a=0;a<l.childCount;a++){const c=l.child(a);o+c.attrs.rowspan>r&&(i+=c.attrs.colspan)}}for(let o=0;o<s.childCount;o++){const l=s.child(o);i+=l.attrs.colspan,l.attrs.rowspan>1&&(n=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function zO(t,e,n){t.problems||(t.problems=[]);const r={};for(let s=0;s<t.map.length;s++){const i=t.map[s];if(r[i])continue;r[i]=!0;const o=n.nodeAt(i);if(!o)throw new RangeError(`No cell with offset ${i} found`);let l=null;const a=o.attrs;for(let c=0;c<a.colspan;c++){const u=e[(s+c)%t.width*2];u!=null&&(!a.colwidth||a.colwidth[c]!=u)&&((l||(l=$O(a)))[c]=u)}l&&t.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:l})}}function $O(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function ot(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(const n in t.nodes){const r=t.nodes[n],s=r.spec.tableRole;s&&(e[s]=r)}}return e}const rr=new ae("selectingCells");function Ur(t){for(let e=t.depth-1;e>0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function HO(t){for(let e=t.depth;e>0;e--){const n=t.node(e).type.spec.tableRole;if(n==="cell"||n==="header_cell")return t.node(e)}return null}function nn(t){const e=t.selection.$head;for(let n=e.depth;n>0;n--)if(e.node(n).type.spec.tableRole=="row")return!0;return!1}function tc(t){const e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const n=Ur(e.$head)||FO(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function FO(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n-e.nodeSize)}}function pd(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function VO(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function Uf(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function N1(t,e,n){const r=t.node(-1),s=Oe.get(r),i=t.start(-1),o=s.nextCell(t.pos-i,e,n);return o==null?null:t.node(0).resolve(i+o)}function Wr(t,e,n=1){const r={...t,colspan:t.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,n),r.colwidth.some(s=>s>0)||(r.colwidth=null)),r}function O1(t,e,n=1){const r={...t,colspan:t.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let s=0;s<n;s++)r.colwidth.splice(e,0,0)}return r}function UO(t,e,n){const r=ot(e.type.schema).header_cell;for(let s=0;s<t.height;s++)if(e.nodeAt(t.map[n+s*t.width]).type!=r)return!1;return!0}var ye=class An extends te{constructor(e,n=e){const r=e.node(-1),s=Oe.get(r),i=e.start(-1),o=s.rectBetween(e.pos-i,n.pos-i),l=e.node(0),a=s.cellsInRect(o).filter(u=>u!=n.pos-i);a.unshift(n.pos-i);const c=a.map(u=>{const d=r.nodeAt(u);if(!d)throw new RangeError(`No cell with offset ${u} found`);const f=i+u+1;return new ef(l.resolve(f),l.resolve(f+d.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=n}map(e,n){const r=e.resolve(n.map(this.$anchorCell.pos)),s=e.resolve(n.map(this.$headCell.pos));if(pd(r)&&pd(s)&&Uf(r,s)){const i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?An.rowSelection(r,s):i&&this.isColSelection()?An.colSelection(r,s):new An(r,s)}return ee.between(r,s)}content(){const e=this.$anchorCell.node(-1),n=Oe.get(e),r=this.$anchorCell.start(-1),s=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),i={},o=[];for(let a=s.top;a<s.bottom;a++){const c=[];for(let u=a*n.width+s.left,d=s.left;d<s.right;d++,u++){const f=n.map[u];if(i[f])continue;i[f]=!0;const h=n.findCell(f);let p=e.nodeAt(f);if(!p)throw new RangeError(`No cell with offset ${f} found`);const g=s.left-h.left,y=h.right-s.right;if(g>0||y>0){let b=p.attrs;if(g>0&&(b=Wr(b,0,g)),y>0&&(b=Wr(b,b.colspan-y,y)),h.left<s.left){if(p=p.type.createAndFill(b),!p)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(b)}`)}else p=p.type.create(b,p.content)}if(h.top<s.top||h.bottom>s.bottom){const b={...p.attrs,rowspan:Math.min(h.bottom,s.bottom)-Math.max(h.top,s.top)};h.top<s.top?p=p.type.createAndFill(b):p=p.type.create(b,p.content)}c.push(p)}o.push(e.child(a).copy(j.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:o;return new K(j.from(l),1,1)}replace(e,n=K.empty){const r=e.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){const{$from:l,$to:a}=s[o],c=e.mapping.slice(r);e.replace(c.map(l.pos),c.map(a.pos),o?K.empty:n)}const i=te.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,n){this.replace(e,new K(j.from(n),0,0))}forEachCell(e){const n=this.$anchorCell.node(-1),r=Oe.get(n),s=this.$anchorCell.start(-1),i=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-s,this.$headCell.pos-s));for(let o=0;o<i.length;o++)e(n.nodeAt(i[o]),s+i[o])}isColSelection(){const e=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(e,n)>0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,s=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,s)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){const r=e.node(-1),s=Oe.get(r),i=e.start(-1),o=s.findCell(e.pos-i),l=s.findCell(n.pos-i),a=e.node(0);return o.top<=l.top?(o.top>0&&(e=a.resolve(i+s.map[o.left])),l.bottom<s.height&&(n=a.resolve(i+s.map[s.width*(s.height-1)+l.right-1]))):(l.top>0&&(n=a.resolve(i+s.map[l.left])),o.bottom<s.height&&(e=a.resolve(i+s.map[s.width*(s.height-1)+o.right-1]))),new An(e,n)}isRowSelection(){const e=this.$anchorCell.node(-1),n=Oe.get(e),r=this.$anchorCell.start(-1),s=n.colCount(this.$anchorCell.pos-r),i=n.colCount(this.$headCell.pos-r);if(Math.min(s,i)>0)return!1;const o=s+this.$anchorCell.nodeAfter.attrs.colspan,l=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(o,l)==n.width}eq(e){return e instanceof An&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const r=e.node(-1),s=Oe.get(r),i=e.start(-1),o=s.findCell(e.pos-i),l=s.findCell(n.pos-i),a=e.node(0);return o.left<=l.left?(o.left>0&&(e=a.resolve(i+s.map[o.top*s.width])),l.right<s.width&&(n=a.resolve(i+s.map[s.width*(l.top+1)-1]))):(l.left>0&&(n=a.resolve(i+s.map[l.top*s.width])),o.right<s.width&&(e=a.resolve(i+s.map[s.width*(o.top+1)-1]))),new An(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new An(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){return new An(e.resolve(n),e.resolve(r))}getBookmark(){return new WO(this.$anchorCell.pos,this.$headCell.pos)}};ye.prototype.visible=!1;te.jsonID("cell",ye);var WO=class I1{constructor(e,n){this.anchor=e,this.head=n}map(e){return new I1(e.map(this.anchor),e.map(this.head))}resolve(e){const n=e.resolve(this.anchor),r=e.resolve(this.head);return n.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&n.index()<n.parent.childCount&&r.index()<r.parent.childCount&&Uf(n,r)?new ye(n,r):te.near(r,1)}};function qO(t){if(!(t.selection instanceof ye))return null;const e=[];return t.selection.forEachCell((n,r)=>{e.push(De.node(r,r+n.nodeSize,{class:"selectedCell"}))}),he.create(t.doc,e)}function KO({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return!1;let n=t.pos,r=e.pos,s=t.depth;for(;s>=0&&!(t.after(s+1)<t.end(s));s--,n++);for(let i=e.depth;i>=0&&!(e.before(i+1)>e.start(i));i--,r--);return n==r&&/row|table/.test(t.node(s).type.spec.tableRole)}function JO({$from:t,$to:e}){let n,r;for(let s=t.depth;s>0;s--){const i=t.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){n=i;break}}for(let s=e.depth;s>0;s--){const i=e.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){r=i;break}}return n!==r&&e.parentOffset===0}function GO(t,e,n){const r=(e||t).selection,s=(e||t).doc;let i,o;if(r instanceof Y&&(o=r.node.type.spec.tableRole)){if(o=="cell"||o=="header_cell")i=ye.create(s,r.from);else if(o=="row"){const l=s.resolve(r.from+1);i=ye.rowSelection(l,l)}else if(!n){const l=Oe.get(r.node),a=r.from+1,c=a+l.map[l.width*l.height-1];i=ye.create(s,a+1,c)}}else r instanceof ee&&KO(r)?i=ee.create(s,r.from):r instanceof ee&&JO(r)&&(i=ee.create(s,r.$from.start(),r.$from.end()));return i&&(e||(e=t.tr)).setSelection(i),e}const YO=new ae("fix-tables");function R1(t,e,n,r){const s=t.childCount,i=e.childCount;e:for(let o=0,l=0;o<i;o++){const a=e.child(o);for(let c=l,u=Math.min(s,o+3);c<u;c++)if(t.child(c)==a){l=c+1,n+=a.nodeSize;continue e}r(a,n),l<s&&t.child(l).sameMarkup(a)?R1(t.child(l),a,n+1,r):a.nodesBetween(0,a.content.size,r,n+1),n+=a.nodeSize}}function D1(t,e){let n;const r=(s,i)=>{s.type.spec.tableRole=="table"&&(n=XO(t,s,i,n))};return e?e.doc!=t.doc&&R1(e.doc,t.doc,0,r):t.doc.descendants(r),n}function XO(t,e,n,r){const s=Oe.get(e);if(!s.problems)return r;r||(r=t.tr);const i=[];for(let a=0;a<s.height;a++)i.push(0);for(let a=0;a<s.problems.length;a++){const c=s.problems[a];if(c.type=="collision"){const u=e.nodeAt(c.pos);if(!u)continue;const d=u.attrs;for(let f=0;f<d.rowspan;f++)i[c.row+f]+=c.n;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,Wr(d,d.colspan-c.n,c.n))}else if(c.type=="missing")i[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const u=e.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...u.attrs,rowspan:u.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const u=e.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...u.attrs,colwidth:c.colwidth})}else if(c.type=="zero_sized"){const u=r.mapping.map(n);r.delete(u,u+e.nodeSize)}}let o,l;for(let a=0;a<i.length;a++)i[a]&&(o==null&&(o=a),l=a);for(let a=0,c=n+1;a<s.height;a++){const u=e.child(a),d=c+u.nodeSize,f=i[a];if(f>0){let h="cell";u.firstChild&&(h=u.firstChild.type.spec.tableRole);const p=[];for(let y=0;y<f;y++){const b=ot(t.schema)[h].createAndFill();b&&p.push(b)}const g=(a==0||o==a-1)&&l==a?c+1:d-1;r.insert(r.mapping.map(g),p)}c=d}return r.setMeta(YO,{fixTables:!0})}function bn(t){const e=t.selection,n=tc(t),r=n.node(-1),s=n.start(-1),i=Oe.get(r);return{...e instanceof ye?i.rectBetween(e.$anchorCell.pos-s,e.$headCell.pos-s):i.findCell(n.pos-s),tableStart:s,map:i,table:r}}function L1(t,{map:e,tableStart:n,table:r},s){let i=s>0?-1:0;UO(e,r,s+i)&&(i=s==0||s==e.width?null:0);for(let o=0;o<e.height;o++){const l=o*e.width+s;if(s>0&&s<e.width&&e.map[l-1]==e.map[l]){const a=e.map[l],c=r.nodeAt(a);t.setNodeMarkup(t.mapping.map(n+a),null,O1(c.attrs,s-e.colCount(a))),o+=c.attrs.rowspan-1}else{const a=i==null?ot(r.type.schema).cell:r.nodeAt(e.map[l+i]).type,c=e.positionAt(o,s,r);t.insert(t.mapping.map(n+c),a.createAndFill())}}return t}function ZO(t,e){if(!nn(t))return!1;if(e){const n=bn(t);e(L1(t.tr,n,n.left))}return!0}function QO(t,e){if(!nn(t))return!1;if(e){const n=bn(t);e(L1(t.tr,n,n.right))}return!0}function eI(t,{map:e,table:n,tableStart:r},s){const i=t.mapping.maps.length;for(let o=0;o<e.height;){const l=o*e.width+s,a=e.map[l],c=n.nodeAt(a),u=c.attrs;if(s>0&&e.map[l-1]==a||s<e.width-1&&e.map[l+1]==a)t.setNodeMarkup(t.mapping.slice(i).map(r+a),null,Wr(u,s-e.colCount(a)));else{const d=t.mapping.slice(i).map(r+a);t.delete(d,d+c.nodeSize)}o+=u.rowspan}}function tI(t,e){if(!nn(t))return!1;if(e){const n=bn(t),r=t.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let s=n.right-1;eI(r,n,s),s!=n.left;s--){const i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw new RangeError("No table found");n.table=i,n.map=Oe.get(i)}e(r)}return!0}function nI(t,e,n){var r;const s=ot(e.type.schema).header_cell;for(let i=0;i<t.width;i++)if(((r=e.nodeAt(t.map[i+n*t.width]))===null||r===void 0?void 0:r.type)!=s)return!1;return!0}function j1(t,{map:e,tableStart:n,table:r},s){let i=n;for(let c=0;c<s;c++)i+=r.child(c).nodeSize;const o=[];let l=s>0?-1:0;nI(e,r,s+l)&&(l=s==0||s==e.height?null:0);for(let c=0,u=e.width*s;c<e.width;c++,u++)if(s>0&&s<e.height&&e.map[u]==e.map[u-e.width]){const d=e.map[u],f=r.nodeAt(d).attrs;t.setNodeMarkup(n+d,null,{...f,rowspan:f.rowspan+1}),c+=f.colspan-1}else{var a;const d=l==null?ot(r.type.schema).cell:(a=r.nodeAt(e.map[u+l*e.width]))===null||a===void 0?void 0:a.type,f=d==null?void 0:d.createAndFill();f&&o.push(f)}return t.insert(i,ot(r.type.schema).row.create(null,o)),t}function rI(t,e){if(!nn(t))return!1;if(e){const n=bn(t);e(j1(t.tr,n,n.top))}return!0}function sI(t,e){if(!nn(t))return!1;if(e){const n=bn(t);e(j1(t.tr,n,n.bottom))}return!0}function iI(t,{map:e,table:n,tableStart:r},s){let i=0;for(let c=0;c<s;c++)i+=n.child(c).nodeSize;const o=i+n.child(s).nodeSize,l=t.mapping.maps.length;t.delete(i+r,o+r);const a=new Set;for(let c=0,u=s*e.width;c<e.width;c++,u++){const d=e.map[u];if(!a.has(d)){if(a.add(d),s>0&&d==e.map[u-e.width]){const f=n.nodeAt(d).attrs;t.setNodeMarkup(t.mapping.slice(l).map(d+r),null,{...f,rowspan:f.rowspan-1}),c+=f.colspan-1}else if(s<e.height&&d==e.map[u+e.width]){const f=n.nodeAt(d),h=f.attrs,p=f.type.create({...h,rowspan:f.attrs.rowspan-1},f.content),g=e.positionAt(s+1,c,n);t.insert(t.mapping.slice(l).map(r+g),p),c+=h.colspan-1}}}}function oI(t,e){if(!nn(t))return!1;if(e){const n=bn(t),r=t.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let s=n.bottom-1;iI(r,n,s),s!=n.top;s--){const i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw new RangeError("No table found");n.table=i,n.map=Oe.get(n.table)}e(r)}return!0}function Am(t){const e=t.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function lI({width:t,height:e,map:n},r){let s=r.top*t+r.left,i=s,o=(r.bottom-1)*t+r.left,l=s+(r.right-r.left-1);for(let a=r.top;a<r.bottom;a++){if(r.left>0&&n[i]==n[i-1]||r.right<t&&n[l]==n[l+1])return!0;i+=t,l+=t}for(let a=r.left;a<r.right;a++){if(r.top>0&&n[s]==n[s-t]||r.bottom<e&&n[o]==n[o+t])return!0;s++,o++}return!1}function _m(t,e){const n=t.selection;if(!(n instanceof ye)||n.$anchorCell.pos==n.$headCell.pos)return!1;const r=bn(t),{map:s}=r;if(lI(s,r))return!1;if(e){const i=t.tr,o={};let l=j.empty,a,c;for(let u=r.top;u<r.bottom;u++)for(let d=r.left;d<r.right;d++){const f=s.map[u*s.width+d],h=r.table.nodeAt(f);if(!(o[f]||!h))if(o[f]=!0,a==null)a=f,c=h;else{Am(h)||(l=l.append(h.content));const p=i.mapping.map(f+r.tableStart);i.delete(p,p+h.nodeSize)}}if(a==null||c==null)return!0;if(i.setNodeMarkup(a+r.tableStart,null,{...O1(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),rowspan:r.bottom-r.top}),l.size>0){const u=a+1+c.content.size,d=Am(c)?a+1:u;i.replaceWith(d+r.tableStart,u+r.tableStart,l)}i.setSelection(new ye(i.doc.resolve(a+r.tableStart))),e(i)}return!0}function Nm(t,e){const n=ot(t.schema);return aI(({node:r})=>n[r.type.spec.tableRole])(t,e)}function aI(t){return(e,n)=>{const r=e.selection;let s,i;if(r instanceof ye){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;s=r.$anchorCell.nodeAfter,i=r.$anchorCell.pos}else{var o;if(s=HO(r.$from),!s)return!1;i=(o=Ur(r.$from))===null||o===void 0?void 0:o.pos}if(s==null||i==null||s.attrs.colspan==1&&s.attrs.rowspan==1)return!1;if(n){let l=s.attrs;const a=[],c=l.colwidth;l.rowspan>1&&(l={...l,rowspan:1}),l.colspan>1&&(l={...l,colspan:1});const u=bn(e),d=e.tr;for(let h=0;h<u.right-u.left;h++)a.push(c?{...l,colwidth:c&&c[h]?[c[h]]:null}:l);let f;for(let h=u.top;h<u.bottom;h++){let p=u.map.positionAt(h,u.left,u.table);h==u.top&&(p+=s.nodeSize);for(let g=u.left,y=0;g<u.right;g++,y++)g==u.left&&h==u.top||d.insert(f=d.mapping.map(p+u.tableStart,1),t({node:s,row:h,col:g}).createAndFill(a[y]))}d.setNodeMarkup(i,t({node:s,row:u.top,col:u.left}),a[0]),r instanceof ye&&d.setSelection(new ye(d.doc.resolve(r.$anchorCell.pos),f?d.doc.resolve(f):void 0)),n(d)}return!0}}function cI(t,e){return function(n,r){if(!nn(n))return!1;const s=tc(n);if(s.nodeAfter.attrs[t]===e)return!1;if(r){const i=n.tr;n.selection instanceof ye?n.selection.forEachCell((o,l)=>{o.attrs[t]!==e&&i.setNodeMarkup(l,null,{...o.attrs,[t]:e})}):i.setNodeMarkup(s.pos,null,{...s.nodeAfter.attrs,[t]:e}),r(i)}return!0}}function uI(t){return function(e,n){if(!nn(e))return!1;if(n){const r=ot(e.schema),s=bn(e),i=e.tr,o=s.map.cellsInRect(t=="column"?{left:s.left,top:0,right:s.right,bottom:s.map.height}:t=="row"?{left:0,top:s.top,right:s.map.width,bottom:s.bottom}:s),l=o.map(a=>s.table.nodeAt(a));for(let a=0;a<o.length;a++)l[a].type==r.header_cell&&i.setNodeMarkup(s.tableStart+o[a],r.cell,l[a].attrs);if(i.steps.length===0)for(let a=0;a<o.length;a++)i.setNodeMarkup(s.tableStart+o[a],r.header_cell,l[a].attrs);n(i)}return!0}}function Om(t,e,n){const r=e.map.cellsInRect({left:0,top:0,right:t=="row"?e.map.width:1,bottom:t=="column"?e.map.height:1});for(let s=0;s<r.length;s++){const i=e.table.nodeAt(r[s]);if(i&&i.type!==n.header_cell)return!1}return!0}function to(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?uI(t):function(n,r){if(!nn(n))return!1;if(r){const s=ot(n.schema),i=bn(n),o=n.tr,l=Om("row",i,s),a=Om("column",i,s),c=(t==="column"?l:t==="row"&&a)?1:0,u=t=="column"?{left:0,top:c,right:1,bottom:i.map.height}:t=="row"?{left:c,top:0,right:i.map.width,bottom:1}:i,d=t=="column"?a?s.cell:s.header_cell:t=="row"?l?s.cell:s.header_cell:s.cell;i.map.cellsInRect(u).forEach(f=>{const h=f+i.tableStart,p=o.doc.nodeAt(h);p&&o.setNodeMarkup(h,d,p.attrs)}),r(o)}return!0}}to("row",{useDeprecatedLogic:!0});to("column",{useDeprecatedLogic:!0});const dI=to("cell",{useDeprecatedLogic:!0});function fI(t,e){if(e<0){const n=t.nodeBefore;if(n)return t.pos-n.nodeSize;for(let r=t.index(-1)-1,s=t.before();r>=0;r--){const i=t.node(-1).child(r),o=i.lastChild;if(o)return s-1-o.nodeSize;s-=i.nodeSize}}else{if(t.index()<t.parent.childCount-1)return t.pos+t.nodeAfter.nodeSize;const n=t.node(-1);for(let r=t.indexAfter(-1),s=t.after();r<n.childCount;r++){const i=n.child(r);if(i.childCount)return s+1;s+=i.nodeSize}}return null}function Im(t){return function(e,n){if(!nn(e))return!1;const r=fI(tc(e),t);if(r==null)return!1;if(n){const s=e.doc.resolve(r);n(e.tr.setSelection(ee.between(s,VO(s))).scrollIntoView())}return!0}}function hI(t,e){const n=t.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole=="table")return e&&e(t.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function qo(t,e){const n=t.selection;if(!(n instanceof ye))return!1;if(e){const r=t.tr,s=ot(t.schema).cell.createAndFill().content;n.forEachCell((i,o)=>{i.content.eq(s)||r.replace(r.mapping.map(o+1),r.mapping.map(o+i.nodeSize-1),new K(s,0,0))}),r.docChanged&&e(r)}return!0}function pI(t){if(t.size===0)return null;let{content:e,openStart:n,openEnd:r}=t;for(;e.childCount==1&&(n>0&&r>0||e.child(0).type.spec.tableRole=="table");)n--,r--,e=e.child(0).content;const s=e.child(0),i=s.type.spec.tableRole,o=s.type.schema,l=[];if(i=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content;const u=a?0:Math.max(0,n-1),d=a<e.childCount-1?0:Math.max(0,r-1);(u||d)&&(c=md(ot(o).row,new K(c,u,d)).content),l.push(c)}else if(i=="cell"||i=="header_cell")l.push(n||r?md(ot(o).row,new K(e,n,r)).content:e);else return null;return mI(o,l)}function mI(t,e){const n=[];for(let s=0;s<e.length;s++){const i=e[s];for(let o=i.childCount-1;o>=0;o--){const{rowspan:l,colspan:a}=i.child(o).attrs;for(let c=s;c<s+l;c++)n[c]=(n[c]||0)+a}}let r=0;for(let s=0;s<n.length;s++)r=Math.max(r,n[s]);for(let s=0;s<n.length;s++)if(s>=e.length&&e.push(j.empty),n[s]<r){const i=ot(t).cell.createAndFill(),o=[];for(let l=n[s];l<r;l++)o.push(i);e[s]=e[s].append(j.from(o))}return{height:e.length,width:r,rows:e}}function md(t,e){const n=t.createAndFill();return new Qd(n).replace(0,n.content.size,e).doc}function gI({width:t,height:e,rows:n},r,s){if(t!=r){const i=[],o=[];for(let l=0;l<n.length;l++){const a=n[l],c=[];for(let u=i[l]||0,d=0;u<r;d++){let f=a.child(d%a.childCount);u+f.attrs.colspan>r&&(f=f.type.createChecked(Wr(f.attrs,f.attrs.colspan,u+f.attrs.colspan-r),f.content)),c.push(f),u+=f.attrs.colspan;for(let h=1;h<f.attrs.rowspan;h++)i[l+h]=(i[l+h]||0)+f.attrs.colspan}o.push(j.from(c))}n=o,t=r}if(e!=s){const i=[];for(let o=0,l=0;o<s;o++,l++){const a=[],c=n[l%e];for(let u=0;u<c.childCount;u++){let d=c.child(u);o+d.attrs.rowspan>s&&(d=d.type.create({...d.attrs,rowspan:Math.max(1,s-d.attrs.rowspan)},d.content)),a.push(d)}i.push(j.from(a))}n=i,e=s}return{width:t,height:e,rows:n}}function yI(t,e,n,r,s,i,o){const l=t.doc.type.schema,a=ot(l);let c,u;if(s>e.width)for(let d=0,f=0;d<e.height;d++){const h=n.child(d);f+=h.nodeSize;const p=[];let g;h.lastChild==null||h.lastChild.type==a.cell?g=c||(c=a.cell.createAndFill()):g=u||(u=a.header_cell.createAndFill());for(let y=e.width;y<s;y++)p.push(g);t.insert(t.mapping.slice(o).map(f-1+r),p)}if(i>e.height){const d=[];for(let p=0,g=(e.height-1)*e.width;p<Math.max(e.width,s);p++){const y=p>=e.width?!1:n.nodeAt(e.map[g+p]).type==a.header_cell;d.push(y?u||(u=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const f=a.row.create(null,j.from(d)),h=[];for(let p=e.height;p<i;p++)h.push(f);t.insert(t.mapping.slice(o).map(r+n.nodeSize-2),h)}return!!(c||u)}function Rm(t,e,n,r,s,i,o,l){if(o==0||o==e.height)return!1;let a=!1;for(let c=s;c<i;c++){const u=o*e.width+c,d=e.map[u];if(e.map[u-e.width]==d){a=!0;const f=n.nodeAt(d),{top:h,left:p}=e.findCell(d);t.setNodeMarkup(t.mapping.slice(l).map(d+r),null,{...f.attrs,rowspan:o-h}),t.insert(t.mapping.slice(l).map(e.positionAt(o,p,n)),f.type.createAndFill({...f.attrs,rowspan:h+f.attrs.rowspan-o})),c+=f.attrs.colspan-1}}return a}function Dm(t,e,n,r,s,i,o,l){if(o==0||o==e.width)return!1;let a=!1;for(let c=s;c<i;c++){const u=c*e.width+o,d=e.map[u];if(e.map[u-1]==d){a=!0;const f=n.nodeAt(d),h=e.colCount(d),p=t.mapping.slice(l).map(d+r);t.setNodeMarkup(p,null,Wr(f.attrs,o-h,f.attrs.colspan-(o-h))),t.insert(p+f.nodeSize,f.type.createAndFill(Wr(f.attrs,0,o-h))),c+=f.attrs.rowspan-1}}return a}function Lm(t,e,n,r,s){let i=n?t.doc.nodeAt(n-1):t.doc;if(!i)throw new Error("No table found");let o=Oe.get(i);const{top:l,left:a}=r,c=a+s.width,u=l+s.height,d=t.tr;let f=0;function h(){if(i=n?d.doc.nodeAt(n-1):d.doc,!i)throw new Error("No table found");o=Oe.get(i),f=d.mapping.maps.length}yI(d,o,i,n,c,u,f)&&h(),Rm(d,o,i,n,a,c,l,f)&&h(),Rm(d,o,i,n,a,c,u,f)&&h(),Dm(d,o,i,n,l,u,a,f)&&h(),Dm(d,o,i,n,l,u,c,f)&&h();for(let p=l;p<u;p++){const g=o.positionAt(p,a,i),y=o.positionAt(p,c,i);d.replace(d.mapping.slice(f).map(g+n),d.mapping.slice(f).map(y+n),new K(s.rows[p-l],0,0))}h(),d.setSelection(new ye(d.doc.resolve(n+o.positionAt(l,a,i)),d.doc.resolve(n+o.positionAt(u-1,c-1,i)))),e(d)}const bI=mf({ArrowLeft:Ko("horiz",-1),ArrowRight:Ko("horiz",1),ArrowUp:Ko("vert",-1),ArrowDown:Ko("vert",1),"Shift-ArrowLeft":Jo("horiz",-1),"Shift-ArrowRight":Jo("horiz",1),"Shift-ArrowUp":Jo("vert",-1),"Shift-ArrowDown":Jo("vert",1),Backspace:qo,"Mod-Backspace":qo,Delete:qo,"Mod-Delete":qo});function gl(t,e,n){return n.eq(t.selection)?!1:(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function Ko(t,e){return(n,r,s)=>{if(!s)return!1;const i=n.selection;if(i instanceof ye)return gl(n,r,te.near(i.$headCell,e));if(t!="horiz"&&!i.empty)return!1;const o=P1(s,t,e);if(o==null)return!1;if(t=="horiz")return gl(n,r,te.near(n.doc.resolve(i.head+e),e));{const l=n.doc.resolve(o),a=N1(l,t,e);let c;return a?c=te.near(a,1):e<0?c=te.near(n.doc.resolve(l.before(-1)),-1):c=te.near(n.doc.resolve(l.after(-1)),1),gl(n,r,c)}}}function Jo(t,e){return(n,r,s)=>{if(!s)return!1;const i=n.selection;let o;if(i instanceof ye)o=i;else{const a=P1(s,t,e);if(a==null)return!1;o=new ye(n.doc.resolve(a))}const l=N1(o.$headCell,t,e);return l?gl(n,r,new ye(o.$anchorCell,l)):!1}}function wI(t,e){const n=t.state.doc,r=Ur(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new ye(r))),!0):!1}function xI(t,e,n){if(!nn(t.state))return!1;let r=pI(n);const s=t.state.selection;if(s instanceof ye){r||(r={width:1,height:1,rows:[j.from(md(ot(t.state.schema).cell,n))]});const i=s.$anchorCell.node(-1),o=s.$anchorCell.start(-1),l=Oe.get(i).rectBetween(s.$anchorCell.pos-o,s.$headCell.pos-o);return r=gI(r,l.right-l.left,l.bottom-l.top),Lm(t.state,t.dispatch,o,l,r),!0}else if(r){const i=tc(t.state),o=i.start(-1);return Lm(t.state,t.dispatch,o,Oe.get(i.node(-1)).findCell(i.pos-o),r),!0}else return!1}function vI(t,e){var n;if(e.button!=0||e.ctrlKey||e.metaKey)return;const r=jm(t,e.target);let s;if(e.shiftKey&&t.state.selection instanceof ye)i(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(s=Ur(t.state.selection.$anchor))!=null&&((n=ou(t,e))===null||n===void 0?void 0:n.pos)!=s.pos)i(s,e),e.preventDefault();else if(!r)return;function i(a,c){let u=ou(t,c);const d=rr.getState(t.state)==null;if(!u||!Uf(a,u))if(d)u=a;else return;const f=new ye(a,u);if(d||!t.state.selection.eq(f)){const h=t.state.tr.setSelection(f);d&&h.setMeta(rr,a.pos),t.dispatch(h)}}function o(){t.root.removeEventListener("mouseup",o),t.root.removeEventListener("dragstart",o),t.root.removeEventListener("mousemove",l),rr.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(rr,-1))}function l(a){const c=a,u=rr.getState(t.state);let d;if(u!=null)d=t.state.doc.resolve(u);else if(jm(t,c.target)!=r&&(d=ou(t,e),!d))return o();d&&i(d,c)}t.root.addEventListener("mouseup",o),t.root.addEventListener("dragstart",o),t.root.addEventListener("mousemove",l)}function P1(t,e,n){if(!(t.state.selection instanceof ee))return null;const{$head:r}=t.state.selection;for(let s=r.depth-1;s>=0;s--){const i=r.node(s);if((n<0?r.index(s):r.indexAfter(s))!=(n<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){const o=r.before(s),l=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(l)?o:null}}return null}function jm(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function ou(t,e){const n=t.posAtCoords({left:e.clientX,top:e.clientY});if(!n)return null;let{inside:r,pos:s}=n;return r>=0&&Ur(t.state.doc.resolve(r))||Ur(t.state.doc.resolve(s))}var kI=class{constructor(e,n){this.node=e,this.defaultCellMinWidth=n,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${n}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),gd(e,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,gd(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function gd(t,e,n,r,s,i){let o=0,l=!0,a=e.firstChild;const c=t.firstChild;if(c){for(let d=0,f=0;d<c.childCount;d++){const{colspan:h,colwidth:p}=c.child(d).attrs;for(let g=0;g<h;g++,f++){const y=s==f?i:p&&p[g],b=y?y+"px":"";if(o+=y||r,y||(l=!1),a)a.style.width!=b&&(a.style.width=b),a=a.nextSibling;else{const w=document.createElement("col");w.style.width=b,e.appendChild(w)}}}for(;a;){var u;const d=a.nextSibling;(u=a.parentNode)===null||u===void 0||u.removeChild(a),a=d}l?(n.style.width=o+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=o+"px")}}const Tt=new ae("tableColumnResizing");function SI({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:n=100,View:r=kI,lastColumnResizable:s=!0}={}){const i=new ce({key:Tt,state:{init(o,l){var a;const c=(a=i.spec)===null||a===void 0||(a=a.props)===null||a===void 0?void 0:a.nodeViews,u=ot(l.schema).table.name;return r&&c&&(c[u]=(d,f)=>new r(d,n,f)),new CI(-1,!1)},apply(o,l){return l.apply(o)}},props:{attributes:o=>{const l=Tt.getState(o);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(o,l)=>{EI(o,l,t,s)},mouseleave:o=>{MI(o)},mousedown:(o,l)=>{TI(o,l,e,n)}},decorations:o=>{const l=Tt.getState(o);if(l&&l.activeHandle>-1)return II(o,l.activeHandle)},nodeViews:{}}});return i}var CI=class yl{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,r=e.getMeta(Tt);if(r&&r.setHandle!=null)return new yl(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new yl(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let s=e.mapping.map(n.activeHandle,-1);return pd(e.doc.resolve(s))||(s=-1),new yl(s,n.dragging)}return n}};function EI(t,e,n,r){if(!t.editable)return;const s=Tt.getState(t.state);if(s&&!s.dragging){const i=_I(e.target);let o=-1;if(i){const{left:l,right:a}=i.getBoundingClientRect();e.clientX-l<=n?o=Pm(t,e,"left",n):a-e.clientX<=n&&(o=Pm(t,e,"right",n))}if(o!=s.activeHandle){if(!r&&o!==-1){const l=t.state.doc.resolve(o),a=l.node(-1),c=Oe.get(a),u=l.start(-1);if(c.colCount(l.pos-u)+l.nodeAfter.attrs.colspan-1==c.width-1)return}B1(t,o)}}}function MI(t){if(!t.editable)return;const e=Tt.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&B1(t,-1)}function TI(t,e,n,r){var s;if(!t.editable)return!1;const i=(s=t.dom.ownerDocument.defaultView)!==null&&s!==void 0?s:window,o=Tt.getState(t.state);if(!o||o.activeHandle==-1||o.dragging)return!1;const l=t.state.doc.nodeAt(o.activeHandle),a=AI(t,o.activeHandle,l.attrs);t.dispatch(t.state.tr.setMeta(Tt,{setDragging:{startX:e.clientX,startWidth:a}}));function c(d){i.removeEventListener("mouseup",c),i.removeEventListener("mousemove",u);const f=Tt.getState(t.state);f!=null&&f.dragging&&(NI(t,f.activeHandle,Bm(f.dragging,d,n)),t.dispatch(t.state.tr.setMeta(Tt,{setDragging:null})))}function u(d){if(!d.which)return c(d);const f=Tt.getState(t.state);if(f&&f.dragging){const h=Bm(f.dragging,d,n);zm(t,f.activeHandle,h,r)}}return zm(t,o.activeHandle,a,r),i.addEventListener("mouseup",c),i.addEventListener("mousemove",u),e.preventDefault(),!0}function AI(t,e,{colspan:n,colwidth:r}){const s=r&&r[r.length-1];if(s)return s;const i=t.domAtPos(e);let o=i.node.childNodes[i.offset].offsetWidth,l=n;if(r)for(let a=0;a<n;a++)r[a]&&(o-=r[a],l--);return o/l}function _I(t){for(;t&&t.nodeName!="TD"&&t.nodeName!="TH";)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}function Pm(t,e,n,r){const s=n=="right"?-r:r,i=t.posAtCoords({left:e.clientX+s,top:e.clientY});if(!i)return-1;const{pos:o}=i,l=Ur(t.state.doc.resolve(o));if(!l)return-1;if(n=="right")return l.pos;const a=Oe.get(l.node(-1)),c=l.start(-1),u=a.map.indexOf(l.pos-c);return u%a.width==0?-1:c+a.map[u-1]}function Bm(t,e,n){const r=e.clientX-t.startX;return Math.max(n,t.startWidth+r)}function B1(t,e){t.dispatch(t.state.tr.setMeta(Tt,{setHandle:e}))}function NI(t,e,n){const r=t.state.doc.resolve(e),s=r.node(-1),i=Oe.get(s),o=r.start(-1),l=i.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1,a=t.state.tr;for(let c=0;c<i.height;c++){const u=c*i.width+l;if(c&&i.map[u]==i.map[u-i.width])continue;const d=i.map[u],f=s.nodeAt(d).attrs,h=f.colspan==1?0:l-i.colCount(d);if(f.colwidth&&f.colwidth[h]==n)continue;const p=f.colwidth?f.colwidth.slice():OI(f.colspan);p[h]=n,a.setNodeMarkup(o+d,null,{...f,colwidth:p})}a.docChanged&&t.dispatch(a)}function zm(t,e,n,r){const s=t.state.doc.resolve(e),i=s.node(-1),o=s.start(-1),l=Oe.get(i).colCount(s.pos-o)+s.nodeAfter.attrs.colspan-1;let a=t.domAtPos(s.start(-1)).node;for(;a&&a.nodeName!="TABLE";)a=a.parentNode;a&&gd(i,a.firstChild,a,r,l,n)}function OI(t){return Array(t).fill(0)}function II(t,e){const n=[],r=t.doc.resolve(e),s=r.node(-1);if(!s)return he.empty;const i=Oe.get(s),o=r.start(-1),l=i.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1;for(let c=0;c<i.height;c++){const u=l+c*i.width;if((l==i.width-1||i.map[u]!=i.map[u+1])&&(c==0||i.map[u]!=i.map[u-i.width])){var a;const d=i.map[u],f=o+d+s.nodeAt(d).nodeSize-1,h=document.createElement("div");h.className="column-resize-handle",!((a=Tt.getState(t))===null||a===void 0)&&a.dragging&&n.push(De.node(o+d,o+d+s.nodeAt(d).nodeSize,{class:"column-resize-dragging"})),n.push(De.widget(f,h))}}return he.create(t.doc,n)}function RI({allowTableNodeSelection:t=!1}={}){return new ce({key:rr,state:{init(){return null},apply(e,n){const r=e.getMeta(rr);if(r!=null)return r==-1?null:r;if(n==null||!e.docChanged)return n;const{deleted:s,pos:i}=e.mapping.mapResult(n);return s?null:i}},props:{decorations:qO,handleDOMEvents:{mousedown:vI},createSelectionBetween(e){return rr.getState(e.state)!=null?e.state.selection:null},handleTripleClick:wI,handleKeyDown:bI,handlePaste:xI},appendTransaction(e,n,r){return GO(r,D1(r,n),t)}})}function pa(t){return t==="left"||t==="right"||t==="center"?t:null}function DI(t){const e=(t.style.textAlign||"").trim().toLowerCase(),n=(t.getAttribute("align")||"").trim().toLowerCase();return pa(e||n)}function LI(t){return pa(t==null?void 0:t.align)}function z1(){return{default:null,parseHTML:t=>DI(t),renderHTML:t=>t.align?{style:`text-align: ${t.align}`}:{}}}var Wf=ke.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{var e,n;const r=t.getAttribute("colwidth"),s=r?r.split(",").map(i=>parseInt(i,10)):null;if(!s){const i=(e=t.closest("table"))==null?void 0:e.querySelectorAll("colgroup > col"),o=Array.from(((n=t.parentElement)==null?void 0:n.children)||[]).indexOf(t);if(o&&o>-1&&i&&i[o]){const l=i[o].getAttribute("width");return l?[parseInt(l,10)]:null}}return s}},align:z1()}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",le(this.options.HTMLAttributes,t),0]}}),qf=ke.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map(r=>parseInt(r,10)):null}},align:z1()}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:t}){return["th",le(this.options.HTMLAttributes,t),0]}}),Kf=ke.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",le(this.options.HTMLAttributes,t),0]}});function yd(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function $m(t,e,n,r,s,i){var o;let l=0,a=!0,c=e.firstChild;const u=t.firstChild;if(u!==null)for(let f=0,h=0;f<u.childCount;f+=1){const{colspan:p,colwidth:g}=u.child(f).attrs;for(let y=0;y<p;y+=1,h+=1){const b=s===h?i:g&&g[y],w=b?`${b}px`:"";if(l+=b||r,b||(a=!1),c){if(c.style.width!==w){const[v,x]=yd(r,b);c.style.setProperty(v,x)}c=c.nextSibling}else{const v=document.createElement("col"),[x,k]=yd(r,b);v.style.setProperty(x,k),e.appendChild(v)}}}for(;c;){const f=c.nextSibling;(o=c.parentNode)==null||o.removeChild(c),c=f}const d=t.attrs.style&&typeof t.attrs.style=="string"&&/\bwidth\s*:/i.test(t.attrs.style);a&&!d?(n.style.width=`${l}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${l}px`)}var jI=class{constructor(t,e,n,r={}){this.node=t,this.cellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table"));for(const[s,i]of Object.entries(r))i!=null&&(s==="style"?this.table.style.cssText=String(i):this.table.setAttribute(s,String(i)));t.attrs.style&&(this.table.style.cssText=t.attrs.style),this.colgroup=this.table.appendChild(document.createElement("colgroup")),$m(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type!==this.node.type?!1:(this.node=t,$m(t,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(t){const e=t.target,n=this.dom.contains(e),r=this.contentDOM.contains(e);return!!(n&&!r&&(t.type==="attributes"||t.type==="childList"||t.type==="characterData"))}};function PI(t,e,n,r){let s=0,i=!0;const o=[],l=t.firstChild;if(!l)return{};for(let d=0,f=0;d<l.childCount;d+=1){const{colspan:h,colwidth:p}=l.child(d).attrs;for(let g=0;g<h;g+=1,f+=1){const y=n===f?r:p&&p[g];s+=y||e,y||(i=!1);const[b,w]=yd(e,y);o.push(["col",{style:`${b}: ${w}`}])}}const a=i?`${s}px`:"",c=i?"":`${s}px`;return{colgroup:["colgroup",{},...o],tableWidth:a,tableMinWidth:c}}function Hm(t,e){return t.createAndFill()}function BI(t){if(t.cached.tableNodeTypes)return t.cached.tableNodeTypes;const e={};return Object.keys(t.nodes).forEach(n=>{const r=t.nodes[n];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),t.cached.tableNodeTypes=e,e}function zI(t,e,n,r,s){const i=BI(t),o=[],l=[];for(let c=0;c<n;c+=1){const u=Hm(i.cell);if(u&&l.push(u),r){const d=Hm(i.header_cell);d&&o.push(d)}}const a=[];for(let c=0;c<e;c+=1)a.push(i.row.createChecked(null,r&&c===0?o:l));return i.table.createChecked(null,a)}function $I(t){return t instanceof ye}var Go=({editor:t})=>{const{selection:e}=t.state;if(!$I(e))return!1;let n=0;const r=e0(e.ranges[0].$from,i=>i.type.name==="table");return r==null||r.node.descendants(i=>{if(i.type.name==="table")return!1;["tableCell","tableHeader"].includes(i.type.name)&&(n+=1)}),n===e.ranges.length?(t.commands.deleteTable(),!0):!1},HI="";function FI(t){return(t||"").replace(/\s+/g," ").trim()}function VI(t,e,n={}){var r;const s=(r=n.cellLineSeparator)!=null?r:HI;if(!t||!t.content||t.content.length===0)return"";const i=[];t.content.forEach(g=>{const y=[];g.content&&g.content.forEach(b=>{let w="";b.content&&Array.isArray(b.content)&&b.content.length>1?w=b.content.map(E=>e.renderChildren(E)).join(s):w=b.content?e.renderChildren(b.content):"";const v=FI(w),x=b.type==="tableHeader",k=LI(b.attrs);y.push({text:v,isHeader:x,align:k})}),i.push(y)});const o=i.reduce((g,y)=>Math.max(g,y.length),0);if(o===0)return"";const l=Array.from({length:o}).fill(0);i.forEach(g=>{var y;for(let b=0;b<o;b+=1){const v=(((y=g[b])==null?void 0:y.text)||"").length;v>l[b]&&(l[b]=v),l[b]<3&&(l[b]=3)}});const a=(g,y)=>g+" ".repeat(Math.max(0,y-g.length)),c=i[0],u=c.some(g=>g.isHeader),d=Array.from({length:o}).fill(null);i.forEach(g=>{var y;for(let b=0;b<o;b+=1)!d[b]&&((y=g[b])!=null&&y.align)&&(d[b]=g[b].align)});let f=`
|
|
182
|
-
`;const
|
|
183
|
-
`,
|
|
184
|
-
`,(u?i.slice(1):i).forEach(g=>{
|
|
185
|
-
`}),f}var UI=VI,Jf=ke.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:jI,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:t,HTMLAttributes:e}){const{colgroup:n,tableWidth:r,tableMinWidth:s}=PI(t,this.options.cellMinWidth),i=e.style;function o(){return i||(r?`width: ${r}`:`min-width: ${s}`)}const l=["table",le(this.options.HTMLAttributes,e,{style:o()}),n,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},l]:l},parseMarkdown:(t,e)=>{const n=[],r=Array.isArray(t.align)?t.align:[];if(t.header){const s=[];t.header.forEach((i,o)=>{var l;const a=pa((l=r[o])!=null?l:i.align),c=a?{align:a}:{};s.push(e.createNode("tableHeader",c,[{type:"paragraph",content:e.parseInline(i.tokens)}]))}),n.push(e.createNode("tableRow",{},s))}return t.rows&&t.rows.forEach(s=>{const i=[];s.forEach((o,l)=>{var a;const c=pa((a=r[l])!=null?a:o.align),u=c?{align:c}:{};i.push(e.createNode("tableCell",u,[{type:"paragraph",content:e.parseInline(o.tokens)}]))}),n.push(e.createNode("tableRow",{},i))}),e.createNode("table",void 0,n)},renderMarkdown:(t,e)=>UI(t,e),addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:s,editor:i})=>{const o=zI(i.schema,t,e,n);if(s){const l=r.selection.from+1;r.replaceSelectionWith(o).scrollIntoView().setSelection(ee.near(r.doc.resolve(l)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>ZO(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>QO(t,e),deleteColumn:()=>({state:t,dispatch:e})=>tI(t,e),addRowBefore:()=>({state:t,dispatch:e})=>rI(t,e),addRowAfter:()=>({state:t,dispatch:e})=>sI(t,e),deleteRow:()=>({state:t,dispatch:e})=>oI(t,e),deleteTable:()=>({state:t,dispatch:e})=>hI(t,e),mergeCells:()=>({state:t,dispatch:e})=>_m(t,e),splitCell:()=>({state:t,dispatch:e})=>Nm(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>to("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>to("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>dI(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>_m(t,e)?!0:Nm(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:r})=>cI(t,e)(n,r),goToNextCell:()=>({state:t,dispatch:e})=>Im(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>Im(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&D1(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){const r=ye.create(e.doc,t.anchorCell,t.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:Go,"Mod-Backspace":Go,Delete:Go,"Mod-Delete":Go}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[SI({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],RI({allowTableNodeSelection:this.options.allowTableNodeSelection})]},addNodeView(){const t=this.options.resizable&&this.editor.isEditable,e=this.options.View;return t||!e?null:({node:n,view:r,HTMLAttributes:s})=>{const i=le(this.options.HTMLAttributes,s);return new e(n,this.options.cellMinWidth,r,i)}},extendNodeSchema(t){const e={name:t.name,options:t.options,storage:t.storage};return{tableRole:fe(G(t,"tableRole",e))}}});ie.create({name:"tableKit",addExtensions(){const t=[];return this.options.table!==!1&&t.push(Jf.configure(this.options.table)),this.options.tableCell!==!1&&t.push(Wf.configure(this.options.tableCell)),this.options.tableHeader!==!1&&t.push(qf.configure(this.options.tableHeader)),this.options.tableRow!==!1&&t.push(Kf.configure(this.options.tableRow)),t}});var WI=ie.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>{const e=t.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:t=>t.textAlign?{style:`text-align: ${t.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:t=>({commands:e})=>this.options.alignments.includes(t)?this.options.types.map(n=>e.updateAttributes(n,{textAlign:t})).some(n=>n):!1,unsetTextAlign:()=>({commands:t})=>this.options.types.map(e=>t.resetAttributes(e,"textAlign")).some(e=>e),toggleTextAlign:t=>({editor:e,commands:n})=>this.options.alignments.includes(t)?e.isActive({textAlign:t})?n.unsetTextAlign():n.setTextAlign(t):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),qI=WI,KI=20,$1=(t,e=0)=>{const n=[];return!t.children.length||e>KI||Array.from(t.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...$1(r,e+1))}),n},JI=t=>{if(!t.children.length)return;const e=$1(t);e&&e.forEach(n=>{var r,s;const i=n.getAttribute("style"),o=(s=(r=n.parentElement)==null?void 0:r.closest("span"))==null?void 0:s.getAttribute("style");n.setAttribute("style",`${o};${i}`)})},Gf=zn.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&JI(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",le(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleTextStyle:t=>({commands:e})=>e.toggleMark(this.name,t),removeEmptyTextStyle:()=>({tr:t})=>{const{selection:e}=t;return t.doc.nodesBetween(e.from,e.to,(n,r)=>{if(n.isTextblock)return!0;n.marks.filter(s=>s.type===this.type).some(s=>Object.values(s.attrs).some(i=>!!i))||t.removeMark(r,r+n.nodeSize,this.type)}),!0}}}}),GI=ie.create({name:"backgroundColor",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:t=>{var e;const n=(e=Fs(t,"background-color"))!=null?e:t.style.backgroundColor;return n==null?void 0:n.replace(/['"]+/g,"")},renderHTML:t=>t.backgroundColor?{style:`background-color: ${t.backgroundColor}`}:{}}}}]},addCommands(){return{setBackgroundColor:t=>({chain:e})=>e().setMark("textStyle",{backgroundColor:t}).run(),unsetBackgroundColor:()=>({chain:t})=>t().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()}}}),Yf=ie.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var e;const n=(e=Fs(t,"color"))!=null?e:t.style.color;return n==null?void 0:n.replace(/['"]+/g,"")},renderHTML:t=>t.color?{style:`color: ${t.color}`}:{}}}}]},addCommands(){return{setColor:t=>({chain:e})=>e().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),YI=ie.create({name:"fontFamily",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:t=>{var e;return(e=Fs(t,"font-family"))!=null?e:t.style.fontFamily},renderHTML:t=>t.fontFamily?{style:`font-family: ${t.fontFamily}`}:{}}}}]},addCommands(){return{setFontFamily:t=>({chain:e})=>e().setMark("textStyle",{fontFamily:t}).run(),unsetFontFamily:()=>({chain:t})=>t().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()}}}),XI=ie.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:t=>{var e;return(e=Fs(t,"font-size"))!=null?e:t.style.fontSize},renderHTML:t=>t.fontSize?{style:`font-size: ${t.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:t=>({chain:e})=>e().setMark("textStyle",{fontSize:t}).run(),unsetFontSize:()=>({chain:t})=>t().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),ZI=ie.create({name:"lineHeight",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:t=>{var e;return(e=Fs(t,"line-height"))!=null?e:t.style.lineHeight},renderHTML:t=>t.lineHeight?{style:`line-height: ${t.lineHeight}`}:{}}}}]},addCommands(){return{setLineHeight:t=>({chain:e})=>e().setMark("textStyle",{lineHeight:t}).run(),unsetLineHeight:()=>({chain:t})=>t().setMark("textStyle",{lineHeight:null}).removeEmptyTextStyle().run()}}});ie.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(GI.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(Yf.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(YI.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(XI.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(ZI.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(Gf.configure(this.options.textStyle)),t}});var H1={},He=Ht&&Ht.__assign||function(){return He=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++){e=arguments[n];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(t[s]=e[s])}return t},He.apply(this,arguments)},QI=Ht&&Ht.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var s=Object.getOwnPropertyDescriptor(e,n);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,s)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),eR=Ht&&Ht.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),tR=Ht&&Ht.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&QI(e,t,n);return eR(e,t),e},nR=Ht&&Ht.__rest||function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(t);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(t,r[s])&&(n[r[s]]=t[r[s]]);return n};Object.defineProperty(H1,"__esModule",{value:!0});var Ot=tR(S),rR=89,Yo=90,sR=77,Fm=57,Vm=219,Um=222,Wm=192,qm=100,iR=3e3,oR=typeof window<"u"&&"navigator"in window&&/Win/i.test(navigator.platform),lu=typeof window<"u"&&"navigator"in window&&/(Mac|iPhone|iPod|iPad)/i.test(navigator.platform),bl="npm__react-simple-code-editor__textarea",lR=`
|
|
181
|
+
}`;ie.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return t.options.injectCSS&&typeof document<"u"&&Ay(TN,t.options.injectNonce,"selection"),[new ce({key:new ae("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||ay(n.selection)||t.view.dragging?null:fe.create(n.doc,[Re.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});var _N="skipTrailingNode";function Am({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||(e==null?void 0:e.type)===t}var NN=ie.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new ae(this.name),n=this.options.node||((t=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:t.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,s])=>s).filter(s=>(this.options.notAfter||[]).concat(n).includes(s.name));return[new ce({key:e,appendTransaction:(s,i,o)=>{const{doc:l,tr:a,schema:c}=o,u=e.getState(o),d=l.content.size,h=c.nodes[n];if(!s.some(f=>f.getMeta(_N))&&u)return a.insert(d,h.create())},state:{init:(s,i)=>{const o=i.tr.doc.lastChild;return!Am({node:o,types:r})},apply:(s,i)=>{if(!s.docChanged||s.getMeta("__uniqueIDTransaction"))return i;const o=s.doc.lastChild;return!Am({node:o,types:r})}}})]}}),ON=ie.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>Cb(t,e),redo:()=>({state:t,dispatch:e})=>Mb(t,e)}},addProseMirrorPlugins(){return[pN(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),IN=ie.create({name:"starterKit",addExtensions(){var t,e,n,r;const s=[];return this.options.bold!==!1&&s.push(jT.configure(this.options.bold)),this.options.blockquote!==!1&&s.push(OT.configure(this.options.blockquote)),this.options.bulletList!==!1&&s.push(db.configure(this.options.bulletList)),this.options.code!==!1&&s.push(HT.configure(this.options.code)),this.options.codeBlock!==!1&&s.push(VT.configure(this.options.codeBlock)),this.options.document!==!1&&s.push(FT.configure(this.options.document)),this.options.dropcursor!==!1&&s.push(gN.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&s.push(yN.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&s.push(UT.configure(this.options.hardBreak)),this.options.heading!==!1&&s.push(WT.configure(this.options.heading)),this.options.undoRedo!==!1&&s.push(ON.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&s.push(KT.configure(this.options.horizontalRule)),this.options.italic!==!1&&s.push(XT.configure(this.options.italic)),this.options.listItem!==!1&&s.push(fb.configure(this.options.listItem)),this.options.listKeymap!==!1&&s.push(yb.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&s.push(ub.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&s.push(wb.configure(this.options.orderedList)),this.options.paragraph!==!1&&s.push(W_.configure(this.options.paragraph)),this.options.strike!==!1&&s.push(J_.configure(this.options.strike)),this.options.text!==!1&&s.push(G_.configure(this.options.text)),this.options.underline!==!1&&s.push(Y_.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&s.push(NN.configure((r=this.options)==null?void 0:r.trailingNode)),s}}),Eb=IN,Tb=EN,DN=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,RN=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,_b=Hn.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:t=>t.getAttribute("data-color")||Vs(t,"background-color")||t.style.backgroundColor,renderHTML:t=>t.color?{"data-color":t.color,style:`background-color: ${t.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:t}){return["mark",le(this.options.HTMLAttributes,t),0]},renderMarkdown:(t,e)=>`==${e.renderChildren(t)}==`,parseMarkdown:(t,e)=>e.applyMark("highlight",e.parseInline(t.tokens||[])),markdownTokenizer:{name:"highlight",level:"inline",start:t=>t.indexOf("=="),tokenize(t,e,n){const s=/^(==)([^=]+)(==)/.exec(t);if(s){const i=s[2].trim(),o=n.inlineTokens(i);return{type:"highlight",raw:s[0],text:i,tokens:o}}}},addCommands(){return{setHighlight:t=>({commands:e})=>e.setMark(this.name,t),toggleHighlight:t=>({commands:e})=>e.toggleMark(this.name,t),unsetHighlight:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[Vr({find:DN,type:this.type})]},addPasteRules(){return[dr({find:RN,type:this.type})]}});const iu=["paragraph","heading","blockquote"],LN=8,Em=24,jN=ie.create({name:"indent",addGlobalAttributes(){return[{types:iu,attributes:{indent:{default:0,renderHTML(t){const e=t.indent;return e?{style:`padding-left: ${e*Em}px`}:{}},parseHTML(t){const e=t.style.paddingLeft;return e?Math.round(parseInt(e)/Em):0}}}}]},addCommands(){return{increaseIndent:()=>({state:t,chain:e})=>{const{$from:n}=t.selection;return n.node(n.depth).type.name==="listItem"?e().sinkListItem("listItem").run():e().command(({tr:s,state:i})=>{const{from:o,to:l}=i.selection;let a=!1;return i.doc.nodesBetween(o,l,(c,u)=>{if(iu.includes(c.type.name)){const d=c.attrs.indent||0;s.setNodeMarkup(u,void 0,{...c.attrs,indent:Math.min(d+1,LN)}),a=!0}}),a}).run()},decreaseIndent:()=>({state:t,chain:e})=>{const{$from:n}=t.selection;return n.node(n.depth).type.name==="listItem"?e().liftListItem("listItem").run():e().command(({tr:s,state:i})=>{const{from:o,to:l}=i.selection;let a=!1;return i.doc.nodesBetween(o,l,(c,u)=>{if(iu.includes(c.type.name)){const d=c.attrs.indent||0;d>0&&(s.setNodeMarkup(u,void 0,{...c.attrs,indent:d-1}),a=!0)}}),a}).run()}}}});let hd,fd;if(typeof WeakMap<"u"){let t=new WeakMap;hd=e=>t.get(e),fd=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;hd=r=>{for(let s=0;s<t.length;s+=2)if(t[s]==r)return t[s+1]},fd=(r,s)=>(n==10&&(n=0),t[n++]=r,t[n++]=s)}var Oe=class{constructor(t,e,n,r){this.width=t,this.height=e,this.map=n,this.problems=r}findCell(t){for(let e=0;e<this.map.length;e++){const n=this.map[e];if(n!=t)continue;const r=e%this.width,s=e/this.width|0;let i=r+1,o=s+1;for(let l=1;i<this.width&&this.map[e+l]==n;l++)i++;for(let l=1;o<this.height&&this.map[e+this.width*l]==n;l++)o++;return{left:r,top:s,right:i,bottom:o}}throw new RangeError(`No cell with offset ${t} found`)}colCount(t){for(let e=0;e<this.map.length;e++)if(this.map[e]==t)return e%this.width;throw new RangeError(`No cell with offset ${t} found`)}nextCell(t,e,n){const{left:r,right:s,top:i,bottom:o}=this.findCell(t);return e=="horiz"?(n<0?r==0:s==this.width)?null:this.map[i*this.width+(n<0?r-1:s)]:(n<0?i==0:o==this.height)?null:this.map[r+this.width*(n<0?i-1:o)]}rectBetween(t,e){const{left:n,right:r,top:s,bottom:i}=this.findCell(t),{left:o,right:l,top:a,bottom:c}=this.findCell(e);return{left:Math.min(n,o),top:Math.min(s,a),right:Math.max(r,l),bottom:Math.max(i,c)}}cellsInRect(t){const e=[],n={};for(let r=t.top;r<t.bottom;r++)for(let s=t.left;s<t.right;s++){const i=r*this.width+s,o=this.map[i];n[o]||(n[o]=!0,!(s==t.left&&s&&this.map[i-1]==o||r==t.top&&r&&this.map[i-this.width]==o)&&e.push(o))}return e}positionAt(t,e,n){for(let r=0,s=0;;r++){const i=s+n.child(r).nodeSize;if(r==t){let o=e+t*this.width;const l=(t+1)*this.width;for(;o<l&&this.map[o]<s;)o++;return o==l?i-1:this.map[o]}s=i}}static get(t){return hd(t)||fd(t,PN(t))}};function PN(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);const e=BN(t),n=t.childCount,r=[];let s=0,i=null;const o=[];for(let c=0,u=e*n;c<u;c++)r[c]=0;for(let c=0,u=0;c<n;c++){const d=t.child(c);u++;for(let p=0;;p++){for(;s<r.length&&r[s]!=0;)s++;if(p==d.childCount)break;const g=d.child(p),{colspan:y,rowspan:b,colwidth:w}=g.attrs;for(let v=0;v<b;v++){if(v+c>=n){(i||(i=[])).push({type:"overlong_rowspan",pos:u,n:b-v});break}const x=s+v*e;for(let k=0;k<y;k++){r[x+k]==0?r[x+k]=u:(i||(i=[])).push({type:"collision",row:c,pos:u,n:y-k});const C=w&&w[k];if(C){const M=(x+k)%e*2,O=o[M];O==null||O!=C&&o[M+1]==1?(o[M]=C,o[M+1]=1):O==C&&o[M+1]++}}}s+=y,u+=g.nodeSize}const h=(c+1)*e;let f=0;for(;s<h;)r[s++]==0&&f++;f&&(i||(i=[])).push({type:"missing",row:c,n:f}),u++}(e===0||n===0)&&(i||(i=[])).push({type:"zero_sized"});const l=new Oe(e,n,r,i);let a=!1;for(let c=0;!a&&c<o.length;c+=2)o[c]!=null&&o[c+1]<n&&(a=!0);return a&&HN(l,o,t),l}function BN(t){let e=-1,n=!1;for(let r=0;r<t.childCount;r++){const s=t.child(r);let i=0;if(n)for(let o=0;o<r;o++){const l=t.child(o);for(let a=0;a<l.childCount;a++){const c=l.child(a);o+c.attrs.rowspan>r&&(i+=c.attrs.colspan)}}for(let o=0;o<s.childCount;o++){const l=s.child(o);i+=l.attrs.colspan,l.attrs.rowspan>1&&(n=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function HN(t,e,n){t.problems||(t.problems=[]);const r={};for(let s=0;s<t.map.length;s++){const i=t.map[s];if(r[i])continue;r[i]=!0;const o=n.nodeAt(i);if(!o)throw new RangeError(`No cell with offset ${i} found`);let l=null;const a=o.attrs;for(let c=0;c<a.colspan;c++){const u=e[(s+c)%t.width*2];u!=null&&(!a.colwidth||a.colwidth[c]!=u)&&((l||(l=zN(a)))[c]=u)}l&&t.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:l})}}function zN(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function ot(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(const n in t.nodes){const r=t.nodes[n],s=r.spec.tableRole;s&&(e[s]=r)}}return e}const rr=new ae("selectingCells");function Ur(t){for(let e=t.depth-1;e>0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function $N(t){for(let e=t.depth;e>0;e--){const n=t.node(e).type.spec.tableRole;if(n==="cell"||n==="header_cell")return t.node(e)}return null}function nn(t){const e=t.selection.$head;for(let n=e.depth;n>0;n--)if(e.node(n).type.spec.tableRole=="row")return!0;return!1}function tc(t){const e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const n=Ur(e.$head)||VN(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function VN(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n-e.nodeSize)}}function pd(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function FN(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function Fh(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function Nb(t,e,n){const r=t.node(-1),s=Oe.get(r),i=t.start(-1),o=s.nextCell(t.pos-i,e,n);return o==null?null:t.node(0).resolve(i+o)}function Wr(t,e,n=1){const r={...t,colspan:t.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,n),r.colwidth.some(s=>s>0)||(r.colwidth=null)),r}function Ob(t,e,n=1){const r={...t,colspan:t.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let s=0;s<n;s++)r.colwidth.splice(e,0,0)}return r}function UN(t,e,n){const r=ot(e.type.schema).header_cell;for(let s=0;s<t.height;s++)if(e.nodeAt(t.map[n+s*t.width]).type!=r)return!1;return!0}var ye=class Tn extends te{constructor(e,n=e){const r=e.node(-1),s=Oe.get(r),i=e.start(-1),o=s.rectBetween(e.pos-i,n.pos-i),l=e.node(0),a=s.cellsInRect(o).filter(u=>u!=n.pos-i);a.unshift(n.pos-i);const c=a.map(u=>{const d=r.nodeAt(u);if(!d)throw new RangeError(`No cell with offset ${u} found`);const h=i+u+1;return new eh(l.resolve(h),l.resolve(h+d.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=n}map(e,n){const r=e.resolve(n.map(this.$anchorCell.pos)),s=e.resolve(n.map(this.$headCell.pos));if(pd(r)&&pd(s)&&Fh(r,s)){const i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?Tn.rowSelection(r,s):i&&this.isColSelection()?Tn.colSelection(r,s):new Tn(r,s)}return ee.between(r,s)}content(){const e=this.$anchorCell.node(-1),n=Oe.get(e),r=this.$anchorCell.start(-1),s=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),i={},o=[];for(let a=s.top;a<s.bottom;a++){const c=[];for(let u=a*n.width+s.left,d=s.left;d<s.right;d++,u++){const h=n.map[u];if(i[h])continue;i[h]=!0;const f=n.findCell(h);let p=e.nodeAt(h);if(!p)throw new RangeError(`No cell with offset ${h} found`);const g=s.left-f.left,y=f.right-s.right;if(g>0||y>0){let b=p.attrs;if(g>0&&(b=Wr(b,0,g)),y>0&&(b=Wr(b,b.colspan-y,y)),f.left<s.left){if(p=p.type.createAndFill(b),!p)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(b)}`)}else p=p.type.create(b,p.content)}if(f.top<s.top||f.bottom>s.bottom){const b={...p.attrs,rowspan:Math.min(f.bottom,s.bottom)-Math.max(f.top,s.top)};f.top<s.top?p=p.type.createAndFill(b):p=p.type.create(b,p.content)}c.push(p)}o.push(e.child(a).copy(j.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:o;return new q(j.from(l),1,1)}replace(e,n=q.empty){const r=e.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){const{$from:l,$to:a}=s[o],c=e.mapping.slice(r);e.replace(c.map(l.pos),c.map(a.pos),o?q.empty:n)}const i=te.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,n){this.replace(e,new q(j.from(n),0,0))}forEachCell(e){const n=this.$anchorCell.node(-1),r=Oe.get(n),s=this.$anchorCell.start(-1),i=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-s,this.$headCell.pos-s));for(let o=0;o<i.length;o++)e(n.nodeAt(i[o]),s+i[o])}isColSelection(){const e=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(e,n)>0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,s=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,s)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){const r=e.node(-1),s=Oe.get(r),i=e.start(-1),o=s.findCell(e.pos-i),l=s.findCell(n.pos-i),a=e.node(0);return o.top<=l.top?(o.top>0&&(e=a.resolve(i+s.map[o.left])),l.bottom<s.height&&(n=a.resolve(i+s.map[s.width*(s.height-1)+l.right-1]))):(l.top>0&&(n=a.resolve(i+s.map[l.left])),o.bottom<s.height&&(e=a.resolve(i+s.map[s.width*(s.height-1)+o.right-1]))),new Tn(e,n)}isRowSelection(){const e=this.$anchorCell.node(-1),n=Oe.get(e),r=this.$anchorCell.start(-1),s=n.colCount(this.$anchorCell.pos-r),i=n.colCount(this.$headCell.pos-r);if(Math.min(s,i)>0)return!1;const o=s+this.$anchorCell.nodeAfter.attrs.colspan,l=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(o,l)==n.width}eq(e){return e instanceof Tn&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const r=e.node(-1),s=Oe.get(r),i=e.start(-1),o=s.findCell(e.pos-i),l=s.findCell(n.pos-i),a=e.node(0);return o.left<=l.left?(o.left>0&&(e=a.resolve(i+s.map[o.top*s.width])),l.right<s.width&&(n=a.resolve(i+s.map[s.width*(l.top+1)-1]))):(l.left>0&&(n=a.resolve(i+s.map[l.top*s.width])),o.right<s.width&&(e=a.resolve(i+s.map[s.width*(o.top+1)-1]))),new Tn(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new Tn(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){return new Tn(e.resolve(n),e.resolve(r))}getBookmark(){return new WN(this.$anchorCell.pos,this.$headCell.pos)}};ye.prototype.visible=!1;te.jsonID("cell",ye);var WN=class Ib{constructor(e,n){this.anchor=e,this.head=n}map(e){return new Ib(e.map(this.anchor),e.map(this.head))}resolve(e){const n=e.resolve(this.anchor),r=e.resolve(this.head);return n.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&n.index()<n.parent.childCount&&r.index()<r.parent.childCount&&Fh(n,r)?new ye(n,r):te.near(r,1)}};function KN(t){if(!(t.selection instanceof ye))return null;const e=[];return t.selection.forEachCell((n,r)=>{e.push(Re.node(r,r+n.nodeSize,{class:"selectedCell"}))}),fe.create(t.doc,e)}function qN({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return!1;let n=t.pos,r=e.pos,s=t.depth;for(;s>=0&&!(t.after(s+1)<t.end(s));s--,n++);for(let i=e.depth;i>=0&&!(e.before(i+1)>e.start(i));i--,r--);return n==r&&/row|table/.test(t.node(s).type.spec.tableRole)}function JN({$from:t,$to:e}){let n,r;for(let s=t.depth;s>0;s--){const i=t.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){n=i;break}}for(let s=e.depth;s>0;s--){const i=e.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){r=i;break}}return n!==r&&e.parentOffset===0}function GN(t,e,n){const r=(e||t).selection,s=(e||t).doc;let i,o;if(r instanceof Y&&(o=r.node.type.spec.tableRole)){if(o=="cell"||o=="header_cell")i=ye.create(s,r.from);else if(o=="row"){const l=s.resolve(r.from+1);i=ye.rowSelection(l,l)}else if(!n){const l=Oe.get(r.node),a=r.from+1,c=a+l.map[l.width*l.height-1];i=ye.create(s,a+1,c)}}else r instanceof ee&&qN(r)?i=ee.create(s,r.from):r instanceof ee&&JN(r)&&(i=ee.create(s,r.$from.start(),r.$from.end()));return i&&(e||(e=t.tr)).setSelection(i),e}const YN=new ae("fix-tables");function Db(t,e,n,r){const s=t.childCount,i=e.childCount;e:for(let o=0,l=0;o<i;o++){const a=e.child(o);for(let c=l,u=Math.min(s,o+3);c<u;c++)if(t.child(c)==a){l=c+1,n+=a.nodeSize;continue e}r(a,n),l<s&&t.child(l).sameMarkup(a)?Db(t.child(l),a,n+1,r):a.nodesBetween(0,a.content.size,r,n+1),n+=a.nodeSize}}function Rb(t,e){let n;const r=(s,i)=>{s.type.spec.tableRole=="table"&&(n=XN(t,s,i,n))};return e?e.doc!=t.doc&&Db(e.doc,t.doc,0,r):t.doc.descendants(r),n}function XN(t,e,n,r){const s=Oe.get(e);if(!s.problems)return r;r||(r=t.tr);const i=[];for(let a=0;a<s.height;a++)i.push(0);for(let a=0;a<s.problems.length;a++){const c=s.problems[a];if(c.type=="collision"){const u=e.nodeAt(c.pos);if(!u)continue;const d=u.attrs;for(let h=0;h<d.rowspan;h++)i[c.row+h]+=c.n;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,Wr(d,d.colspan-c.n,c.n))}else if(c.type=="missing")i[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const u=e.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...u.attrs,rowspan:u.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const u=e.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...u.attrs,colwidth:c.colwidth})}else if(c.type=="zero_sized"){const u=r.mapping.map(n);r.delete(u,u+e.nodeSize)}}let o,l;for(let a=0;a<i.length;a++)i[a]&&(o==null&&(o=a),l=a);for(let a=0,c=n+1;a<s.height;a++){const u=e.child(a),d=c+u.nodeSize,h=i[a];if(h>0){let f="cell";u.firstChild&&(f=u.firstChild.type.spec.tableRole);const p=[];for(let y=0;y<h;y++){const b=ot(t.schema)[f].createAndFill();b&&p.push(b)}const g=(a==0||o==a-1)&&l==a?c+1:d-1;r.insert(r.mapping.map(g),p)}c=d}return r.setMeta(YN,{fixTables:!0})}function bn(t){const e=t.selection,n=tc(t),r=n.node(-1),s=n.start(-1),i=Oe.get(r);return{...e instanceof ye?i.rectBetween(e.$anchorCell.pos-s,e.$headCell.pos-s):i.findCell(n.pos-s),tableStart:s,map:i,table:r}}function Lb(t,{map:e,tableStart:n,table:r},s){let i=s>0?-1:0;UN(e,r,s+i)&&(i=s==0||s==e.width?null:0);for(let o=0;o<e.height;o++){const l=o*e.width+s;if(s>0&&s<e.width&&e.map[l-1]==e.map[l]){const a=e.map[l],c=r.nodeAt(a);t.setNodeMarkup(t.mapping.map(n+a),null,Ob(c.attrs,s-e.colCount(a))),o+=c.attrs.rowspan-1}else{const a=i==null?ot(r.type.schema).cell:r.nodeAt(e.map[l+i]).type,c=e.positionAt(o,s,r);t.insert(t.mapping.map(n+c),a.createAndFill())}}return t}function ZN(t,e){if(!nn(t))return!1;if(e){const n=bn(t);e(Lb(t.tr,n,n.left))}return!0}function QN(t,e){if(!nn(t))return!1;if(e){const n=bn(t);e(Lb(t.tr,n,n.right))}return!0}function e5(t,{map:e,table:n,tableStart:r},s){const i=t.mapping.maps.length;for(let o=0;o<e.height;){const l=o*e.width+s,a=e.map[l],c=n.nodeAt(a),u=c.attrs;if(s>0&&e.map[l-1]==a||s<e.width-1&&e.map[l+1]==a)t.setNodeMarkup(t.mapping.slice(i).map(r+a),null,Wr(u,s-e.colCount(a)));else{const d=t.mapping.slice(i).map(r+a);t.delete(d,d+c.nodeSize)}o+=u.rowspan}}function t5(t,e){if(!nn(t))return!1;if(e){const n=bn(t),r=t.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let s=n.right-1;e5(r,n,s),s!=n.left;s--){const i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw new RangeError("No table found");n.table=i,n.map=Oe.get(i)}e(r)}return!0}function n5(t,e,n){var r;const s=ot(e.type.schema).header_cell;for(let i=0;i<t.width;i++)if(((r=e.nodeAt(t.map[i+n*t.width]))===null||r===void 0?void 0:r.type)!=s)return!1;return!0}function jb(t,{map:e,tableStart:n,table:r},s){let i=n;for(let c=0;c<s;c++)i+=r.child(c).nodeSize;const o=[];let l=s>0?-1:0;n5(e,r,s+l)&&(l=s==0||s==e.height?null:0);for(let c=0,u=e.width*s;c<e.width;c++,u++)if(s>0&&s<e.height&&e.map[u]==e.map[u-e.width]){const d=e.map[u],h=r.nodeAt(d).attrs;t.setNodeMarkup(n+d,null,{...h,rowspan:h.rowspan+1}),c+=h.colspan-1}else{var a;const d=l==null?ot(r.type.schema).cell:(a=r.nodeAt(e.map[u+l*e.width]))===null||a===void 0?void 0:a.type,h=d==null?void 0:d.createAndFill();h&&o.push(h)}return t.insert(i,ot(r.type.schema).row.create(null,o)),t}function r5(t,e){if(!nn(t))return!1;if(e){const n=bn(t);e(jb(t.tr,n,n.top))}return!0}function s5(t,e){if(!nn(t))return!1;if(e){const n=bn(t);e(jb(t.tr,n,n.bottom))}return!0}function i5(t,{map:e,table:n,tableStart:r},s){let i=0;for(let c=0;c<s;c++)i+=n.child(c).nodeSize;const o=i+n.child(s).nodeSize,l=t.mapping.maps.length;t.delete(i+r,o+r);const a=new Set;for(let c=0,u=s*e.width;c<e.width;c++,u++){const d=e.map[u];if(!a.has(d)){if(a.add(d),s>0&&d==e.map[u-e.width]){const h=n.nodeAt(d).attrs;t.setNodeMarkup(t.mapping.slice(l).map(d+r),null,{...h,rowspan:h.rowspan-1}),c+=h.colspan-1}else if(s<e.height&&d==e.map[u+e.width]){const h=n.nodeAt(d),f=h.attrs,p=h.type.create({...f,rowspan:h.attrs.rowspan-1},h.content),g=e.positionAt(s+1,c,n);t.insert(t.mapping.slice(l).map(r+g),p),c+=f.colspan-1}}}}function o5(t,e){if(!nn(t))return!1;if(e){const n=bn(t),r=t.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let s=n.bottom-1;i5(r,n,s),s!=n.top;s--){const i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw new RangeError("No table found");n.table=i,n.map=Oe.get(n.table)}e(r)}return!0}function Tm(t){const e=t.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function l5({width:t,height:e,map:n},r){let s=r.top*t+r.left,i=s,o=(r.bottom-1)*t+r.left,l=s+(r.right-r.left-1);for(let a=r.top;a<r.bottom;a++){if(r.left>0&&n[i]==n[i-1]||r.right<t&&n[l]==n[l+1])return!0;i+=t,l+=t}for(let a=r.left;a<r.right;a++){if(r.top>0&&n[s]==n[s-t]||r.bottom<e&&n[o]==n[o+t])return!0;s++,o++}return!1}function _m(t,e){const n=t.selection;if(!(n instanceof ye)||n.$anchorCell.pos==n.$headCell.pos)return!1;const r=bn(t),{map:s}=r;if(l5(s,r))return!1;if(e){const i=t.tr,o={};let l=j.empty,a,c;for(let u=r.top;u<r.bottom;u++)for(let d=r.left;d<r.right;d++){const h=s.map[u*s.width+d],f=r.table.nodeAt(h);if(!(o[h]||!f))if(o[h]=!0,a==null)a=h,c=f;else{Tm(f)||(l=l.append(f.content));const p=i.mapping.map(h+r.tableStart);i.delete(p,p+f.nodeSize)}}if(a==null||c==null)return!0;if(i.setNodeMarkup(a+r.tableStart,null,{...Ob(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),rowspan:r.bottom-r.top}),l.size>0){const u=a+1+c.content.size,d=Tm(c)?a+1:u;i.replaceWith(d+r.tableStart,u+r.tableStart,l)}i.setSelection(new ye(i.doc.resolve(a+r.tableStart))),e(i)}return!0}function Nm(t,e){const n=ot(t.schema);return a5(({node:r})=>n[r.type.spec.tableRole])(t,e)}function a5(t){return(e,n)=>{const r=e.selection;let s,i;if(r instanceof ye){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;s=r.$anchorCell.nodeAfter,i=r.$anchorCell.pos}else{var o;if(s=$N(r.$from),!s)return!1;i=(o=Ur(r.$from))===null||o===void 0?void 0:o.pos}if(s==null||i==null||s.attrs.colspan==1&&s.attrs.rowspan==1)return!1;if(n){let l=s.attrs;const a=[],c=l.colwidth;l.rowspan>1&&(l={...l,rowspan:1}),l.colspan>1&&(l={...l,colspan:1});const u=bn(e),d=e.tr;for(let f=0;f<u.right-u.left;f++)a.push(c?{...l,colwidth:c&&c[f]?[c[f]]:null}:l);let h;for(let f=u.top;f<u.bottom;f++){let p=u.map.positionAt(f,u.left,u.table);f==u.top&&(p+=s.nodeSize);for(let g=u.left,y=0;g<u.right;g++,y++)g==u.left&&f==u.top||d.insert(h=d.mapping.map(p+u.tableStart,1),t({node:s,row:f,col:g}).createAndFill(a[y]))}d.setNodeMarkup(i,t({node:s,row:u.top,col:u.left}),a[0]),r instanceof ye&&d.setSelection(new ye(d.doc.resolve(r.$anchorCell.pos),h?d.doc.resolve(h):void 0)),n(d)}return!0}}function c5(t,e){return function(n,r){if(!nn(n))return!1;const s=tc(n);if(s.nodeAfter.attrs[t]===e)return!1;if(r){const i=n.tr;n.selection instanceof ye?n.selection.forEachCell((o,l)=>{o.attrs[t]!==e&&i.setNodeMarkup(l,null,{...o.attrs,[t]:e})}):i.setNodeMarkup(s.pos,null,{...s.nodeAfter.attrs,[t]:e}),r(i)}return!0}}function u5(t){return function(e,n){if(!nn(e))return!1;if(n){const r=ot(e.schema),s=bn(e),i=e.tr,o=s.map.cellsInRect(t=="column"?{left:s.left,top:0,right:s.right,bottom:s.map.height}:t=="row"?{left:0,top:s.top,right:s.map.width,bottom:s.bottom}:s),l=o.map(a=>s.table.nodeAt(a));for(let a=0;a<o.length;a++)l[a].type==r.header_cell&&i.setNodeMarkup(s.tableStart+o[a],r.cell,l[a].attrs);if(i.steps.length===0)for(let a=0;a<o.length;a++)i.setNodeMarkup(s.tableStart+o[a],r.header_cell,l[a].attrs);n(i)}return!0}}function Om(t,e,n){const r=e.map.cellsInRect({left:0,top:0,right:t=="row"?e.map.width:1,bottom:t=="column"?e.map.height:1});for(let s=0;s<r.length;s++){const i=e.table.nodeAt(r[s]);if(i&&i.type!==n.header_cell)return!1}return!0}function to(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?u5(t):function(n,r){if(!nn(n))return!1;if(r){const s=ot(n.schema),i=bn(n),o=n.tr,l=Om("row",i,s),a=Om("column",i,s),c=(t==="column"?l:t==="row"&&a)?1:0,u=t=="column"?{left:0,top:c,right:1,bottom:i.map.height}:t=="row"?{left:c,top:0,right:i.map.width,bottom:1}:i,d=t=="column"?a?s.cell:s.header_cell:t=="row"?l?s.cell:s.header_cell:s.cell;i.map.cellsInRect(u).forEach(h=>{const f=h+i.tableStart,p=o.doc.nodeAt(f);p&&o.setNodeMarkup(f,d,p.attrs)}),r(o)}return!0}}to("row",{useDeprecatedLogic:!0});to("column",{useDeprecatedLogic:!0});const d5=to("cell",{useDeprecatedLogic:!0});function h5(t,e){if(e<0){const n=t.nodeBefore;if(n)return t.pos-n.nodeSize;for(let r=t.index(-1)-1,s=t.before();r>=0;r--){const i=t.node(-1).child(r),o=i.lastChild;if(o)return s-1-o.nodeSize;s-=i.nodeSize}}else{if(t.index()<t.parent.childCount-1)return t.pos+t.nodeAfter.nodeSize;const n=t.node(-1);for(let r=t.indexAfter(-1),s=t.after();r<n.childCount;r++){const i=n.child(r);if(i.childCount)return s+1;s+=i.nodeSize}}return null}function Im(t){return function(e,n){if(!nn(e))return!1;const r=h5(tc(e),t);if(r==null)return!1;if(n){const s=e.doc.resolve(r);n(e.tr.setSelection(ee.between(s,FN(s))).scrollIntoView())}return!0}}function f5(t,e){const n=t.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole=="table")return e&&e(t.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function Ko(t,e){const n=t.selection;if(!(n instanceof ye))return!1;if(e){const r=t.tr,s=ot(t.schema).cell.createAndFill().content;n.forEachCell((i,o)=>{i.content.eq(s)||r.replace(r.mapping.map(o+1),r.mapping.map(o+i.nodeSize-1),new q(s,0,0))}),r.docChanged&&e(r)}return!0}function p5(t){if(t.size===0)return null;let{content:e,openStart:n,openEnd:r}=t;for(;e.childCount==1&&(n>0&&r>0||e.child(0).type.spec.tableRole=="table");)n--,r--,e=e.child(0).content;const s=e.child(0),i=s.type.spec.tableRole,o=s.type.schema,l=[];if(i=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content;const u=a?0:Math.max(0,n-1),d=a<e.childCount-1?0:Math.max(0,r-1);(u||d)&&(c=md(ot(o).row,new q(c,u,d)).content),l.push(c)}else if(i=="cell"||i=="header_cell")l.push(n||r?md(ot(o).row,new q(e,n,r)).content:e);else return null;return m5(o,l)}function m5(t,e){const n=[];for(let s=0;s<e.length;s++){const i=e[s];for(let o=i.childCount-1;o>=0;o--){const{rowspan:l,colspan:a}=i.child(o).attrs;for(let c=s;c<s+l;c++)n[c]=(n[c]||0)+a}}let r=0;for(let s=0;s<n.length;s++)r=Math.max(r,n[s]);for(let s=0;s<n.length;s++)if(s>=e.length&&e.push(j.empty),n[s]<r){const i=ot(t).cell.createAndFill(),o=[];for(let l=n[s];l<r;l++)o.push(i);e[s]=e[s].append(j.from(o))}return{height:e.length,width:r,rows:e}}function md(t,e){const n=t.createAndFill();return new Qd(n).replace(0,n.content.size,e).doc}function g5({width:t,height:e,rows:n},r,s){if(t!=r){const i=[],o=[];for(let l=0;l<n.length;l++){const a=n[l],c=[];for(let u=i[l]||0,d=0;u<r;d++){let h=a.child(d%a.childCount);u+h.attrs.colspan>r&&(h=h.type.createChecked(Wr(h.attrs,h.attrs.colspan,u+h.attrs.colspan-r),h.content)),c.push(h),u+=h.attrs.colspan;for(let f=1;f<h.attrs.rowspan;f++)i[l+f]=(i[l+f]||0)+h.attrs.colspan}o.push(j.from(c))}n=o,t=r}if(e!=s){const i=[];for(let o=0,l=0;o<s;o++,l++){const a=[],c=n[l%e];for(let u=0;u<c.childCount;u++){let d=c.child(u);o+d.attrs.rowspan>s&&(d=d.type.create({...d.attrs,rowspan:Math.max(1,s-d.attrs.rowspan)},d.content)),a.push(d)}i.push(j.from(a))}n=i,e=s}return{width:t,height:e,rows:n}}function y5(t,e,n,r,s,i,o){const l=t.doc.type.schema,a=ot(l);let c,u;if(s>e.width)for(let d=0,h=0;d<e.height;d++){const f=n.child(d);h+=f.nodeSize;const p=[];let g;f.lastChild==null||f.lastChild.type==a.cell?g=c||(c=a.cell.createAndFill()):g=u||(u=a.header_cell.createAndFill());for(let y=e.width;y<s;y++)p.push(g);t.insert(t.mapping.slice(o).map(h-1+r),p)}if(i>e.height){const d=[];for(let p=0,g=(e.height-1)*e.width;p<Math.max(e.width,s);p++){const y=p>=e.width?!1:n.nodeAt(e.map[g+p]).type==a.header_cell;d.push(y?u||(u=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const h=a.row.create(null,j.from(d)),f=[];for(let p=e.height;p<i;p++)f.push(h);t.insert(t.mapping.slice(o).map(r+n.nodeSize-2),f)}return!!(c||u)}function Dm(t,e,n,r,s,i,o,l){if(o==0||o==e.height)return!1;let a=!1;for(let c=s;c<i;c++){const u=o*e.width+c,d=e.map[u];if(e.map[u-e.width]==d){a=!0;const h=n.nodeAt(d),{top:f,left:p}=e.findCell(d);t.setNodeMarkup(t.mapping.slice(l).map(d+r),null,{...h.attrs,rowspan:o-f}),t.insert(t.mapping.slice(l).map(e.positionAt(o,p,n)),h.type.createAndFill({...h.attrs,rowspan:f+h.attrs.rowspan-o})),c+=h.attrs.colspan-1}}return a}function Rm(t,e,n,r,s,i,o,l){if(o==0||o==e.width)return!1;let a=!1;for(let c=s;c<i;c++){const u=c*e.width+o,d=e.map[u];if(e.map[u-1]==d){a=!0;const h=n.nodeAt(d),f=e.colCount(d),p=t.mapping.slice(l).map(d+r);t.setNodeMarkup(p,null,Wr(h.attrs,o-f,h.attrs.colspan-(o-f))),t.insert(p+h.nodeSize,h.type.createAndFill(Wr(h.attrs,0,o-f))),c+=h.attrs.rowspan-1}}return a}function Lm(t,e,n,r,s){let i=n?t.doc.nodeAt(n-1):t.doc;if(!i)throw new Error("No table found");let o=Oe.get(i);const{top:l,left:a}=r,c=a+s.width,u=l+s.height,d=t.tr;let h=0;function f(){if(i=n?d.doc.nodeAt(n-1):d.doc,!i)throw new Error("No table found");o=Oe.get(i),h=d.mapping.maps.length}y5(d,o,i,n,c,u,h)&&f(),Dm(d,o,i,n,a,c,l,h)&&f(),Dm(d,o,i,n,a,c,u,h)&&f(),Rm(d,o,i,n,l,u,a,h)&&f(),Rm(d,o,i,n,l,u,c,h)&&f();for(let p=l;p<u;p++){const g=o.positionAt(p,a,i),y=o.positionAt(p,c,i);d.replace(d.mapping.slice(h).map(g+n),d.mapping.slice(h).map(y+n),new q(s.rows[p-l],0,0))}f(),d.setSelection(new ye(d.doc.resolve(n+o.positionAt(l,a,i)),d.doc.resolve(n+o.positionAt(u-1,c-1,i)))),e(d)}const b5=ph({ArrowLeft:qo("horiz",-1),ArrowRight:qo("horiz",1),ArrowUp:qo("vert",-1),ArrowDown:qo("vert",1),"Shift-ArrowLeft":Jo("horiz",-1),"Shift-ArrowRight":Jo("horiz",1),"Shift-ArrowUp":Jo("vert",-1),"Shift-ArrowDown":Jo("vert",1),Backspace:Ko,"Mod-Backspace":Ko,Delete:Ko,"Mod-Delete":Ko});function gl(t,e,n){return n.eq(t.selection)?!1:(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function qo(t,e){return(n,r,s)=>{if(!s)return!1;const i=n.selection;if(i instanceof ye)return gl(n,r,te.near(i.$headCell,e));if(t!="horiz"&&!i.empty)return!1;const o=Pb(s,t,e);if(o==null)return!1;if(t=="horiz")return gl(n,r,te.near(n.doc.resolve(i.head+e),e));{const l=n.doc.resolve(o),a=Nb(l,t,e);let c;return a?c=te.near(a,1):e<0?c=te.near(n.doc.resolve(l.before(-1)),-1):c=te.near(n.doc.resolve(l.after(-1)),1),gl(n,r,c)}}}function Jo(t,e){return(n,r,s)=>{if(!s)return!1;const i=n.selection;let o;if(i instanceof ye)o=i;else{const a=Pb(s,t,e);if(a==null)return!1;o=new ye(n.doc.resolve(a))}const l=Nb(o.$headCell,t,e);return l?gl(n,r,new ye(o.$anchorCell,l)):!1}}function w5(t,e){const n=t.state.doc,r=Ur(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new ye(r))),!0):!1}function x5(t,e,n){if(!nn(t.state))return!1;let r=p5(n);const s=t.state.selection;if(s instanceof ye){r||(r={width:1,height:1,rows:[j.from(md(ot(t.state.schema).cell,n))]});const i=s.$anchorCell.node(-1),o=s.$anchorCell.start(-1),l=Oe.get(i).rectBetween(s.$anchorCell.pos-o,s.$headCell.pos-o);return r=g5(r,l.right-l.left,l.bottom-l.top),Lm(t.state,t.dispatch,o,l,r),!0}else if(r){const i=tc(t.state),o=i.start(-1);return Lm(t.state,t.dispatch,o,Oe.get(i.node(-1)).findCell(i.pos-o),r),!0}else return!1}function v5(t,e){var n;if(e.button!=0||e.ctrlKey||e.metaKey)return;const r=jm(t,e.target);let s;if(e.shiftKey&&t.state.selection instanceof ye)i(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(s=Ur(t.state.selection.$anchor))!=null&&((n=ou(t,e))===null||n===void 0?void 0:n.pos)!=s.pos)i(s,e),e.preventDefault();else if(!r)return;function i(a,c){let u=ou(t,c);const d=rr.getState(t.state)==null;if(!u||!Fh(a,u))if(d)u=a;else return;const h=new ye(a,u);if(d||!t.state.selection.eq(h)){const f=t.state.tr.setSelection(h);d&&f.setMeta(rr,a.pos),t.dispatch(f)}}function o(){t.root.removeEventListener("mouseup",o),t.root.removeEventListener("dragstart",o),t.root.removeEventListener("mousemove",l),rr.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(rr,-1))}function l(a){const c=a,u=rr.getState(t.state);let d;if(u!=null)d=t.state.doc.resolve(u);else if(jm(t,c.target)!=r&&(d=ou(t,e),!d))return o();d&&i(d,c)}t.root.addEventListener("mouseup",o),t.root.addEventListener("dragstart",o),t.root.addEventListener("mousemove",l)}function Pb(t,e,n){if(!(t.state.selection instanceof ee))return null;const{$head:r}=t.state.selection;for(let s=r.depth-1;s>=0;s--){const i=r.node(s);if((n<0?r.index(s):r.indexAfter(s))!=(n<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){const o=r.before(s),l=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(l)?o:null}}return null}function jm(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function ou(t,e){const n=t.posAtCoords({left:e.clientX,top:e.clientY});if(!n)return null;let{inside:r,pos:s}=n;return r>=0&&Ur(t.state.doc.resolve(r))||Ur(t.state.doc.resolve(s))}var k5=class{constructor(e,n){this.node=e,this.defaultCellMinWidth=n,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${n}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),gd(e,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,gd(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function gd(t,e,n,r,s,i){let o=0,l=!0,a=e.firstChild;const c=t.firstChild;if(c){for(let d=0,h=0;d<c.childCount;d++){const{colspan:f,colwidth:p}=c.child(d).attrs;for(let g=0;g<f;g++,h++){const y=s==h?i:p&&p[g],b=y?y+"px":"";if(o+=y||r,y||(l=!1),a)a.style.width!=b&&(a.style.width=b),a=a.nextSibling;else{const w=document.createElement("col");w.style.width=b,e.appendChild(w)}}}for(;a;){var u;const d=a.nextSibling;(u=a.parentNode)===null||u===void 0||u.removeChild(a),a=d}l?(n.style.width=o+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=o+"px")}}const Et=new ae("tableColumnResizing");function S5({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:n=100,View:r=k5,lastColumnResizable:s=!0}={}){const i=new ce({key:Et,state:{init(o,l){var a;const c=(a=i.spec)===null||a===void 0||(a=a.props)===null||a===void 0?void 0:a.nodeViews,u=ot(l.schema).table.name;return r&&c&&(c[u]=(d,h)=>new r(d,n,h)),new C5(-1,!1)},apply(o,l){return l.apply(o)}},props:{attributes:o=>{const l=Et.getState(o);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(o,l)=>{M5(o,l,t,s)},mouseleave:o=>{A5(o)},mousedown:(o,l)=>{E5(o,l,e,n)}},decorations:o=>{const l=Et.getState(o);if(l&&l.activeHandle>-1)return I5(o,l.activeHandle)},nodeViews:{}}});return i}var C5=class yl{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,r=e.getMeta(Et);if(r&&r.setHandle!=null)return new yl(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new yl(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let s=e.mapping.map(n.activeHandle,-1);return pd(e.doc.resolve(s))||(s=-1),new yl(s,n.dragging)}return n}};function M5(t,e,n,r){if(!t.editable)return;const s=Et.getState(t.state);if(s&&!s.dragging){const i=_5(e.target);let o=-1;if(i){const{left:l,right:a}=i.getBoundingClientRect();e.clientX-l<=n?o=Pm(t,e,"left",n):a-e.clientX<=n&&(o=Pm(t,e,"right",n))}if(o!=s.activeHandle){if(!r&&o!==-1){const l=t.state.doc.resolve(o),a=l.node(-1),c=Oe.get(a),u=l.start(-1);if(c.colCount(l.pos-u)+l.nodeAfter.attrs.colspan-1==c.width-1)return}Bb(t,o)}}}function A5(t){if(!t.editable)return;const e=Et.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&Bb(t,-1)}function E5(t,e,n,r){var s;if(!t.editable)return!1;const i=(s=t.dom.ownerDocument.defaultView)!==null&&s!==void 0?s:window,o=Et.getState(t.state);if(!o||o.activeHandle==-1||o.dragging)return!1;const l=t.state.doc.nodeAt(o.activeHandle),a=T5(t,o.activeHandle,l.attrs);t.dispatch(t.state.tr.setMeta(Et,{setDragging:{startX:e.clientX,startWidth:a}}));function c(d){i.removeEventListener("mouseup",c),i.removeEventListener("mousemove",u);const h=Et.getState(t.state);h!=null&&h.dragging&&(N5(t,h.activeHandle,Bm(h.dragging,d,n)),t.dispatch(t.state.tr.setMeta(Et,{setDragging:null})))}function u(d){if(!d.which)return c(d);const h=Et.getState(t.state);if(h&&h.dragging){const f=Bm(h.dragging,d,n);Hm(t,h.activeHandle,f,r)}}return Hm(t,o.activeHandle,a,r),i.addEventListener("mouseup",c),i.addEventListener("mousemove",u),e.preventDefault(),!0}function T5(t,e,{colspan:n,colwidth:r}){const s=r&&r[r.length-1];if(s)return s;const i=t.domAtPos(e);let o=i.node.childNodes[i.offset].offsetWidth,l=n;if(r)for(let a=0;a<n;a++)r[a]&&(o-=r[a],l--);return o/l}function _5(t){for(;t&&t.nodeName!="TD"&&t.nodeName!="TH";)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}function Pm(t,e,n,r){const s=n=="right"?-r:r,i=t.posAtCoords({left:e.clientX+s,top:e.clientY});if(!i)return-1;const{pos:o}=i,l=Ur(t.state.doc.resolve(o));if(!l)return-1;if(n=="right")return l.pos;const a=Oe.get(l.node(-1)),c=l.start(-1),u=a.map.indexOf(l.pos-c);return u%a.width==0?-1:c+a.map[u-1]}function Bm(t,e,n){const r=e.clientX-t.startX;return Math.max(n,t.startWidth+r)}function Bb(t,e){t.dispatch(t.state.tr.setMeta(Et,{setHandle:e}))}function N5(t,e,n){const r=t.state.doc.resolve(e),s=r.node(-1),i=Oe.get(s),o=r.start(-1),l=i.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1,a=t.state.tr;for(let c=0;c<i.height;c++){const u=c*i.width+l;if(c&&i.map[u]==i.map[u-i.width])continue;const d=i.map[u],h=s.nodeAt(d).attrs,f=h.colspan==1?0:l-i.colCount(d);if(h.colwidth&&h.colwidth[f]==n)continue;const p=h.colwidth?h.colwidth.slice():O5(h.colspan);p[f]=n,a.setNodeMarkup(o+d,null,{...h,colwidth:p})}a.docChanged&&t.dispatch(a)}function Hm(t,e,n,r){const s=t.state.doc.resolve(e),i=s.node(-1),o=s.start(-1),l=Oe.get(i).colCount(s.pos-o)+s.nodeAfter.attrs.colspan-1;let a=t.domAtPos(s.start(-1)).node;for(;a&&a.nodeName!="TABLE";)a=a.parentNode;a&&gd(i,a.firstChild,a,r,l,n)}function O5(t){return Array(t).fill(0)}function I5(t,e){const n=[],r=t.doc.resolve(e),s=r.node(-1);if(!s)return fe.empty;const i=Oe.get(s),o=r.start(-1),l=i.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1;for(let c=0;c<i.height;c++){const u=l+c*i.width;if((l==i.width-1||i.map[u]!=i.map[u+1])&&(c==0||i.map[u]!=i.map[u-i.width])){var a;const d=i.map[u],h=o+d+s.nodeAt(d).nodeSize-1,f=document.createElement("div");f.className="column-resize-handle",!((a=Et.getState(t))===null||a===void 0)&&a.dragging&&n.push(Re.node(o+d,o+d+s.nodeAt(d).nodeSize,{class:"column-resize-dragging"})),n.push(Re.widget(h,f))}}return fe.create(t.doc,n)}function D5({allowTableNodeSelection:t=!1}={}){return new ce({key:rr,state:{init(){return null},apply(e,n){const r=e.getMeta(rr);if(r!=null)return r==-1?null:r;if(n==null||!e.docChanged)return n;const{deleted:s,pos:i}=e.mapping.mapResult(n);return s?null:i}},props:{decorations:KN,handleDOMEvents:{mousedown:v5},createSelectionBetween(e){return rr.getState(e.state)!=null?e.state.selection:null},handleTripleClick:w5,handleKeyDown:b5,handlePaste:x5},appendTransaction(e,n,r){return GN(r,Rb(r,n),t)}})}function pa(t){return t==="left"||t==="right"||t==="center"?t:null}function R5(t){const e=(t.style.textAlign||"").trim().toLowerCase(),n=(t.getAttribute("align")||"").trim().toLowerCase();return pa(e||n)}function L5(t){return pa(t==null?void 0:t.align)}function Hb(){return{default:null,parseHTML:t=>R5(t),renderHTML:t=>t.align?{style:`text-align: ${t.align}`}:{}}}var Uh=ke.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{var e,n;const r=t.getAttribute("colwidth"),s=r?r.split(",").map(i=>parseInt(i,10)):null;if(!s){const i=(e=t.closest("table"))==null?void 0:e.querySelectorAll("colgroup > col"),o=Array.from(((n=t.parentElement)==null?void 0:n.children)||[]).indexOf(t);if(o&&o>-1&&i&&i[o]){const l=i[o].getAttribute("width");return l?[parseInt(l,10)]:null}}return s}},align:Hb()}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",le(this.options.HTMLAttributes,t),0]}}),Wh=ke.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map(r=>parseInt(r,10)):null}},align:Hb()}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:t}){return["th",le(this.options.HTMLAttributes,t),0]}}),Kh=ke.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",le(this.options.HTMLAttributes,t),0]}});function yd(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function zm(t,e,n,r,s,i){var o;let l=0,a=!0,c=e.firstChild;const u=t.firstChild;if(u!==null)for(let h=0,f=0;h<u.childCount;h+=1){const{colspan:p,colwidth:g}=u.child(h).attrs;for(let y=0;y<p;y+=1,f+=1){const b=s===f?i:g&&g[y],w=b?`${b}px`:"";if(l+=b||r,b||(a=!1),c){if(c.style.width!==w){const[v,x]=yd(r,b);c.style.setProperty(v,x)}c=c.nextSibling}else{const v=document.createElement("col"),[x,k]=yd(r,b);v.style.setProperty(x,k),e.appendChild(v)}}}for(;c;){const h=c.nextSibling;(o=c.parentNode)==null||o.removeChild(c),c=h}const d=t.attrs.style&&typeof t.attrs.style=="string"&&/\bwidth\s*:/i.test(t.attrs.style);a&&!d?(n.style.width=`${l}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${l}px`)}var j5=class{constructor(t,e,n,r={}){this.node=t,this.cellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table"));for(const[s,i]of Object.entries(r))i!=null&&(s==="style"?this.table.style.cssText=String(i):this.table.setAttribute(s,String(i)));t.attrs.style&&(this.table.style.cssText=t.attrs.style),this.colgroup=this.table.appendChild(document.createElement("colgroup")),zm(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type!==this.node.type?!1:(this.node=t,zm(t,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(t){const e=t.target,n=this.dom.contains(e),r=this.contentDOM.contains(e);return!!(n&&!r&&(t.type==="attributes"||t.type==="childList"||t.type==="characterData"))}};function P5(t,e,n,r){let s=0,i=!0;const o=[],l=t.firstChild;if(!l)return{};for(let d=0,h=0;d<l.childCount;d+=1){const{colspan:f,colwidth:p}=l.child(d).attrs;for(let g=0;g<f;g+=1,h+=1){const y=n===h?r:p&&p[g];s+=y||e,y||(i=!1);const[b,w]=yd(e,y);o.push(["col",{style:`${b}: ${w}`}])}}const a=i?`${s}px`:"",c=i?"":`${s}px`;return{colgroup:["colgroup",{},...o],tableWidth:a,tableMinWidth:c}}function $m(t,e){return t.createAndFill()}function B5(t){if(t.cached.tableNodeTypes)return t.cached.tableNodeTypes;const e={};return Object.keys(t.nodes).forEach(n=>{const r=t.nodes[n];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),t.cached.tableNodeTypes=e,e}function H5(t,e,n,r,s){const i=B5(t),o=[],l=[];for(let c=0;c<n;c+=1){const u=$m(i.cell);if(u&&l.push(u),r){const d=$m(i.header_cell);d&&o.push(d)}}const a=[];for(let c=0;c<e;c+=1)a.push(i.row.createChecked(null,r&&c===0?o:l));return i.table.createChecked(null,a)}function z5(t){return t instanceof ye}var Go=({editor:t})=>{const{selection:e}=t.state;if(!z5(e))return!1;let n=0;const r=ey(e.ranges[0].$from,i=>i.type.name==="table");return r==null||r.node.descendants(i=>{if(i.type.name==="table")return!1;["tableCell","tableHeader"].includes(i.type.name)&&(n+=1)}),n===e.ranges.length?(t.commands.deleteTable(),!0):!1},$5="";function V5(t){return(t||"").replace(/\s+/g," ").trim()}function F5(t,e,n={}){var r;const s=(r=n.cellLineSeparator)!=null?r:$5;if(!t||!t.content||t.content.length===0)return"";const i=[];t.content.forEach(g=>{const y=[];g.content&&g.content.forEach(b=>{let w="";b.content&&Array.isArray(b.content)&&b.content.length>1?w=b.content.map(M=>e.renderChildren(M)).join(s):w=b.content?e.renderChildren(b.content):"";const v=V5(w),x=b.type==="tableHeader",k=L5(b.attrs);y.push({text:v,isHeader:x,align:k})}),i.push(y)});const o=i.reduce((g,y)=>Math.max(g,y.length),0);if(o===0)return"";const l=Array.from({length:o}).fill(0);i.forEach(g=>{var y;for(let b=0;b<o;b+=1){const v=(((y=g[b])==null?void 0:y.text)||"").length;v>l[b]&&(l[b]=v),l[b]<3&&(l[b]=3)}});const a=(g,y)=>g+" ".repeat(Math.max(0,y-g.length)),c=i[0],u=c.some(g=>g.isHeader),d=Array.from({length:o}).fill(null);i.forEach(g=>{var y;for(let b=0;b<o;b+=1)!d[b]&&((y=g[b])!=null&&y.align)&&(d[b]=g[b].align)});let h=`
|
|
182
|
+
`;const f=Array.from({length:o}).map((g,y)=>u&&c[y]&&c[y].text||"");return h+=`| ${f.map((g,y)=>a(g,l[y])).join(" | ")} |
|
|
183
|
+
`,h+=`| ${l.map((g,y)=>{const b=Math.max(3,g),w=d[y];return w==="left"?`:${"-".repeat(b)}`:w==="right"?`${"-".repeat(b)}:`:w==="center"?`:${"-".repeat(b)}:`:"-".repeat(b)}).join(" | ")} |
|
|
184
|
+
`,(u?i.slice(1):i).forEach(g=>{h+=`| ${Array.from({length:o}).fill(0).map((y,b)=>a(g[b]&&g[b].text||"",l[b])).join(" | ")} |
|
|
185
|
+
`}),h}var U5=F5,qh=ke.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:j5,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:t,HTMLAttributes:e}){const{colgroup:n,tableWidth:r,tableMinWidth:s}=P5(t,this.options.cellMinWidth),i=e.style;function o(){return i||(r?`width: ${r}`:`min-width: ${s}`)}const l=["table",le(this.options.HTMLAttributes,e,{style:o()}),n,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},l]:l},parseMarkdown:(t,e)=>{const n=[],r=Array.isArray(t.align)?t.align:[];if(t.header){const s=[];t.header.forEach((i,o)=>{var l;const a=pa((l=r[o])!=null?l:i.align),c=a?{align:a}:{};s.push(e.createNode("tableHeader",c,[{type:"paragraph",content:e.parseInline(i.tokens)}]))}),n.push(e.createNode("tableRow",{},s))}return t.rows&&t.rows.forEach(s=>{const i=[];s.forEach((o,l)=>{var a;const c=pa((a=r[l])!=null?a:o.align),u=c?{align:c}:{};i.push(e.createNode("tableCell",u,[{type:"paragraph",content:e.parseInline(o.tokens)}]))}),n.push(e.createNode("tableRow",{},i))}),e.createNode("table",void 0,n)},renderMarkdown:(t,e)=>U5(t,e),addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:s,editor:i})=>{const o=H5(i.schema,t,e,n);if(s){const l=r.selection.from+1;r.replaceSelectionWith(o).scrollIntoView().setSelection(ee.near(r.doc.resolve(l)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>ZN(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>QN(t,e),deleteColumn:()=>({state:t,dispatch:e})=>t5(t,e),addRowBefore:()=>({state:t,dispatch:e})=>r5(t,e),addRowAfter:()=>({state:t,dispatch:e})=>s5(t,e),deleteRow:()=>({state:t,dispatch:e})=>o5(t,e),deleteTable:()=>({state:t,dispatch:e})=>f5(t,e),mergeCells:()=>({state:t,dispatch:e})=>_m(t,e),splitCell:()=>({state:t,dispatch:e})=>Nm(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>to("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>to("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>d5(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>_m(t,e)?!0:Nm(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:r})=>c5(t,e)(n,r),goToNextCell:()=>({state:t,dispatch:e})=>Im(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>Im(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&Rb(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){const r=ye.create(e.doc,t.anchorCell,t.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:Go,"Mod-Backspace":Go,Delete:Go,"Mod-Delete":Go}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[S5({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],D5({allowTableNodeSelection:this.options.allowTableNodeSelection})]},addNodeView(){const t=this.options.resizable&&this.editor.isEditable,e=this.options.View;return t||!e?null:({node:n,view:r,HTMLAttributes:s})=>{const i=le(this.options.HTMLAttributes,s);return new e(n,this.options.cellMinWidth,r,i)}},extendNodeSchema(t){const e={name:t.name,options:t.options,storage:t.storage};return{tableRole:he(G(t,"tableRole",e))}}});ie.create({name:"tableKit",addExtensions(){const t=[];return this.options.table!==!1&&t.push(qh.configure(this.options.table)),this.options.tableCell!==!1&&t.push(Uh.configure(this.options.tableCell)),this.options.tableHeader!==!1&&t.push(Wh.configure(this.options.tableHeader)),this.options.tableRow!==!1&&t.push(Kh.configure(this.options.tableRow)),t}});var W5=ie.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>{const e=t.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:t=>t.textAlign?{style:`text-align: ${t.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:t=>({commands:e})=>this.options.alignments.includes(t)?this.options.types.map(n=>e.updateAttributes(n,{textAlign:t})).some(n=>n):!1,unsetTextAlign:()=>({commands:t})=>this.options.types.map(e=>t.resetAttributes(e,"textAlign")).some(e=>e),toggleTextAlign:t=>({editor:e,commands:n})=>this.options.alignments.includes(t)?e.isActive({textAlign:t})?n.unsetTextAlign():n.setTextAlign(t):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),K5=W5,q5=20,zb=(t,e=0)=>{const n=[];return!t.children.length||e>q5||Array.from(t.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...zb(r,e+1))}),n},J5=t=>{if(!t.children.length)return;const e=zb(t);e&&e.forEach(n=>{var r,s;const i=n.getAttribute("style"),o=(s=(r=n.parentElement)==null?void 0:r.closest("span"))==null?void 0:s.getAttribute("style");n.setAttribute("style",`${o};${i}`)})},Jh=Hn.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&J5(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",le(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleTextStyle:t=>({commands:e})=>e.toggleMark(this.name,t),removeEmptyTextStyle:()=>({tr:t})=>{const{selection:e}=t;return t.doc.nodesBetween(e.from,e.to,(n,r)=>{if(n.isTextblock)return!0;n.marks.filter(s=>s.type===this.type).some(s=>Object.values(s.attrs).some(i=>!!i))||t.removeMark(r,r+n.nodeSize,this.type)}),!0}}}}),G5=ie.create({name:"backgroundColor",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:t=>{var e;const n=(e=Vs(t,"background-color"))!=null?e:t.style.backgroundColor;return n==null?void 0:n.replace(/['"]+/g,"")},renderHTML:t=>t.backgroundColor?{style:`background-color: ${t.backgroundColor}`}:{}}}}]},addCommands(){return{setBackgroundColor:t=>({chain:e})=>e().setMark("textStyle",{backgroundColor:t}).run(),unsetBackgroundColor:()=>({chain:t})=>t().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()}}}),Gh=ie.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var e;const n=(e=Vs(t,"color"))!=null?e:t.style.color;return n==null?void 0:n.replace(/['"]+/g,"")},renderHTML:t=>t.color?{style:`color: ${t.color}`}:{}}}}]},addCommands(){return{setColor:t=>({chain:e})=>e().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),Y5=ie.create({name:"fontFamily",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:t=>{var e;return(e=Vs(t,"font-family"))!=null?e:t.style.fontFamily},renderHTML:t=>t.fontFamily?{style:`font-family: ${t.fontFamily}`}:{}}}}]},addCommands(){return{setFontFamily:t=>({chain:e})=>e().setMark("textStyle",{fontFamily:t}).run(),unsetFontFamily:()=>({chain:t})=>t().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()}}}),X5=ie.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:t=>{var e;return(e=Vs(t,"font-size"))!=null?e:t.style.fontSize},renderHTML:t=>t.fontSize?{style:`font-size: ${t.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:t=>({chain:e})=>e().setMark("textStyle",{fontSize:t}).run(),unsetFontSize:()=>({chain:t})=>t().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),Z5=ie.create({name:"lineHeight",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:t=>{var e;return(e=Vs(t,"line-height"))!=null?e:t.style.lineHeight},renderHTML:t=>t.lineHeight?{style:`line-height: ${t.lineHeight}`}:{}}}}]},addCommands(){return{setLineHeight:t=>({chain:e})=>e().setMark("textStyle",{lineHeight:t}).run(),unsetLineHeight:()=>({chain:t})=>t().setMark("textStyle",{lineHeight:null}).removeEmptyTextStyle().run()}}});ie.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(G5.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(Gh.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(Y5.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(X5.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(Z5.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(Jh.configure(this.options.textStyle)),t}});var $b={},$e=$t&&$t.__assign||function(){return $e=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++){e=arguments[n];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(t[s]=e[s])}return t},$e.apply(this,arguments)},Q5=$t&&$t.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var s=Object.getOwnPropertyDescriptor(e,n);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,s)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),e3=$t&&$t.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),t3=$t&&$t.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&Q5(e,t,n);return e3(e,t),e},n3=$t&&$t.__rest||function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(t);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(t,r[s])&&(n[r[s]]=t[r[s]]);return n};Object.defineProperty($b,"__esModule",{value:!0});var Ot=t3(S),r3=89,Yo=90,s3=77,Vm=57,Fm=219,Um=222,Wm=192,Km=100,i3=3e3,o3=typeof window<"u"&&"navigator"in window&&/Win/i.test(navigator.platform),lu=typeof window<"u"&&"navigator"in window&&/(Mac|iPhone|iPod|iPad)/i.test(navigator.platform),bl="npm__react-simple-code-editor__textarea",l3=`
|
|
186
186
|
/**
|
|
187
187
|
* Reset the text fill color so that placeholder is visible
|
|
188
188
|
*/
|
|
@@ -208,188 +208,250 @@ ${n}
|
|
|
208
208
|
color: transparent !important;
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
|
-
`),
|
|
212
|
-
`)},
|
|
213
|
-
`).map(function(Zs,
|
|
214
|
-
`);if(W!==xn){var sn=ne[Je];
|
|
215
|
-
`).map(function(
|
|
216
|
-
`),selectionStart:sn&&/\S/.test(sn)?X+
|
|
217
|
-
`+
|
|
211
|
+
`),a3=Ot.forwardRef(function(e,n){var r=e.autoFocus,s=e.disabled,i=e.form,o=e.highlight,l=e.ignoreTabKey,a=l===void 0?!1:l,c=e.insertSpaces,u=c===void 0?!0:c,d=e.maxLength,h=e.minLength,f=e.name,p=e.onBlur,g=e.onClick,y=e.onFocus,b=e.onKeyDown,w=e.onKeyUp,v=e.onValueChange,x=e.padding,k=x===void 0?0:x,C=e.placeholder,M=e.preClassName,O=e.readOnly,_=e.required,A=e.style,R=e.tabSize,D=R===void 0?2:R,L=e.textareaClassName,I=e.textareaId,N=e.value,H=n3(e,["autoFocus","disabled","form","highlight","ignoreTabKey","insertSpaces","maxLength","minLength","name","onBlur","onClick","onFocus","onKeyDown","onKeyUp","onValueChange","padding","placeholder","preClassName","readOnly","required","style","tabSize","textareaClassName","textareaId","value"]),$=Ot.useRef({stack:[],offset:-1}),U=Ot.useRef(null),K=Ot.useState(!0),de=K[0],ve=K[1],Me={paddingTop:typeof k=="object"?k.top:k,paddingRight:typeof k=="object"?k.right:k,paddingBottom:typeof k=="object"?k.bottom:k,paddingLeft:typeof k=="object"?k.left:k},Ct=o(N),Ae=function(F,P){return F.substring(0,P).split(`
|
|
212
|
+
`)},Te=Ot.useCallback(function(F,P){var W,X,be;P===void 0&&(P=!1);var E=$.current,ne=E.stack,Je=E.offset;if(ne.length&&Je>-1){$.current.stack=ne.slice(0,Je+1);var vr=$.current.stack.length;if(vr>Km){var xn=vr-Km;$.current.stack=ne.slice(xn,vr),$.current.offset=Math.max($.current.offset-xn,0)}}var sn=Date.now();if(P){var Wn=$.current.stack[$.current.offset];if(Wn&&sn-Wn.timestamp<i3){var Ys=/[^a-z0-9]([a-z0-9]+)$/i,Mt=(W=Ae(Wn.value,Wn.selectionStart).pop())===null||W===void 0?void 0:W.match(Ys),Xs=(X=Ae(F.value,F.selectionStart).pop())===null||X===void 0?void 0:X.match(Ys);if(Mt!=null&&Mt[1]&&(!((be=Xs==null?void 0:Xs[1])===null||be===void 0)&&be.startsWith(Mt[1]))){$.current.stack[$.current.offset]=$e($e({},F),{timestamp:sn});return}}}$.current.stack.push($e($e({},F),{timestamp:sn})),$.current.offset++},[]),He=Ot.useCallback(function(){var F=U.current;if(F){var P=F.value,W=F.selectionStart,X=F.selectionEnd;Te({value:P,selectionStart:W,selectionEnd:X})}},[Te]),z=function(F){var P=U.current;P&&(P.value=F.value,P.selectionStart=F.selectionStart,P.selectionEnd=F.selectionEnd,v==null||v(F.value))},V=function(F){var P=U.current,W=$.current.stack[$.current.offset];W&&P&&($.current.stack[$.current.offset]=$e($e({},W),{selectionStart:P.selectionStart,selectionEnd:P.selectionEnd})),Te(F),z(F)},Ut=function(){var F=$.current,P=F.stack,W=F.offset,X=P[W-1];X&&(z(X),$.current.offset=Math.max(W-1,0))},_t=function(){var F=$.current,P=F.stack,W=F.offset,X=P[W+1];X&&(z(X),$.current.offset=Math.min(W+1,P.length-1))},oe=function(F){if(!(b&&(b(F),F.defaultPrevented))){F.key==="Escape"&&F.currentTarget.blur();var P=F.currentTarget,W=P.value,X=P.selectionStart,be=P.selectionEnd,E=(u?" ":" ").repeat(D);if(F.key==="Tab"&&!a&&de)if(F.preventDefault(),F.shiftKey){var ne=Ae(W,X),Je=ne.length-1,vr=Ae(W,be).length-1,xn=W.split(`
|
|
213
|
+
`).map(function(Zs,jf){return jf>=Je&&jf<=vr&&Zs.startsWith(E)?Zs.substring(E.length):Zs}).join(`
|
|
214
|
+
`);if(W!==xn){var sn=ne[Je];V({value:xn,selectionStart:sn!=null&&sn.startsWith(E)?X-E.length:X,selectionEnd:be-(W.length-xn.length)})}}else if(X!==be){var ne=Ae(W,X),Wn=ne.length-1,Ys=Ae(W,be).length-1,sn=ne[Wn];V({value:W.split(`
|
|
215
|
+
`).map(function(Pf,Bf){return Bf>=Wn&&Bf<=Ys?E+Pf:Pf}).join(`
|
|
216
|
+
`),selectionStart:sn&&/\S/.test(sn)?X+E.length:X,selectionEnd:be+E.length*(Ys-Wn+1)})}else{var Mt=X+E.length;V({value:W.substring(0,X)+E+W.substring(be),selectionStart:Mt,selectionEnd:Mt})}else if(F.key==="Backspace"){var Xs=X!==be,rS=W.substring(0,X);if(rS.endsWith(E)&&!Xs){F.preventDefault();var Mt=X-E.length;V({value:W.substring(0,X-E.length)+W.substring(be),selectionStart:Mt,selectionEnd:Mt})}}else if(F.key==="Enter"){if(X===be){var Sc=Ae(W,X).pop(),To=Sc==null?void 0:Sc.match(/^\s+/);if(To!=null&&To[0]){F.preventDefault();var Lf=`
|
|
217
|
+
`+To[0],Mt=X+Lf.length;V({value:W.substring(0,X)+Lf+W.substring(be),selectionStart:Mt,selectionEnd:Mt})}}}else if(F.keyCode===Vm||F.keyCode===Fm||F.keyCode===Um||F.keyCode===Wm){var vn=void 0;F.keyCode===Vm&&F.shiftKey?vn=["(",")"]:F.keyCode===Fm?F.shiftKey?vn=["{","}"]:vn=["[","]"]:F.keyCode===Um?F.shiftKey?vn=['"','"']:vn=["'","'"]:F.keyCode===Wm&&!F.shiftKey&&(vn=["`","`"]),X!==be&&vn&&(F.preventDefault(),V({value:W.substring(0,X)+vn[0]+W.substring(X,be)+vn[1]+W.substring(be),selectionStart:X,selectionEnd:be+2}))}else(lu?F.metaKey&&F.keyCode===Yo:F.ctrlKey&&F.keyCode===Yo)&&!F.shiftKey&&!F.altKey?(F.preventDefault(),Ut()):(lu?F.metaKey&&F.keyCode===Yo&&F.shiftKey:o3?F.ctrlKey&&F.keyCode===r3:F.ctrlKey&&F.keyCode===Yo&&F.shiftKey)&&!F.altKey?(F.preventDefault(),_t()):F.keyCode===s3&&F.ctrlKey&&(!lu||F.shiftKey)&&(F.preventDefault(),ve(function(Zs){return!Zs}))}},wn=function(F){var P=F.currentTarget,W=P.value,X=P.selectionStart,be=P.selectionEnd;Te({value:W,selectionStart:X,selectionEnd:be},!0),v(W)};return Ot.useEffect(function(){He()},[He]),Ot.useImperativeHandle(n,function(){return{get session(){return{history:$.current}},set session(F){$.current=F.history}}},[]),Ot.createElement("div",$e({},H,{style:$e($e({},ri.container),A)}),Ot.createElement("pre",$e({className:M,"aria-hidden":"true",style:$e($e($e({},ri.editor),ri.highlight),Me)},typeof Ct=="string"?{dangerouslySetInnerHTML:{__html:Ct+"<br />"}}:{children:Ct})),Ot.createElement("textarea",{ref:function(F){return U.current=F},style:$e($e($e({},ri.editor),ri.textarea),Me),className:bl+(L?" ".concat(L):""),id:I,value:N,onChange:wn,onKeyDown:oe,onClick:g,onKeyUp:w,onFocus:y,onBlur:p,disabled:s,form:i,maxLength:d,minLength:h,name:f,placeholder:C,readOnly:O,required:_,autoFocus:r,autoCapitalize:"off",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"data-gramm":!1}),Ot.createElement("style",{dangerouslySetInnerHTML:{__html:l3}}))}),ri={container:{position:"relative",textAlign:"left",boxSizing:"border-box",padding:0,overflow:"hidden"},textarea:{position:"absolute",top:0,left:0,height:"100%",width:"100%",resize:"none",color:"inherit",overflow:"hidden",MozOsxFontSmoothing:"grayscale",WebkitFontSmoothing:"antialiased",WebkitTextFillColor:"transparent"},highlight:{position:"relative",pointerEvents:"none"},editor:{margin:0,border:0,background:"none",boxSizing:"inherit",display:"inherit",fontFamily:"inherit",fontSize:"inherit",fontStyle:"inherit",fontVariantLigatures:"inherit",fontWeight:"inherit",letterSpacing:"inherit",lineHeight:"inherit",tabSize:"inherit",textIndent:"inherit",textRendering:"inherit",textTransform:"inherit",whiteSpace:"pre-wrap",wordBreak:"keep-all",overflowWrap:"break-word"}},Vb=$b.default=a3,Fb={exports:{}};(function(t){var e=typeof window<"u"?window:typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope?self:{};/**
|
|
218
218
|
* Prism: Lightweight, robust, elegant syntax highlighting
|
|
219
219
|
*
|
|
220
220
|
* @license MIT <https://opensource.org/licenses/MIT>
|
|
221
221
|
* @author Lea Verou <https://lea.verou.me>
|
|
222
222
|
* @namespace
|
|
223
223
|
* @public
|
|
224
|
-
*/var n=function(r){var s=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,i=0,o={},l={manual:r.Prism&&r.Prism.manual,disableWorkerMessageHandler:r.Prism&&r.Prism.disableWorkerMessageHandler,util:{encode:function w(v){return v instanceof a?new a(v.type,w(v.content),v.alias):Array.isArray(v)?v.map(w):v.replace(/&/g,"&").replace(/</g,"<").replace(/\u00a0/g," ")},type:function(w){return Object.prototype.toString.call(w).slice(8,-1)},objId:function(w){return w.__id||Object.defineProperty(w,"__id",{value:++i}),w.__id},clone:function w(v,x){x=x||{};var k,C;switch(l.util.type(v)){case"Object":if(C=l.util.objId(v),x[C])return x[C];k={},x[C]=k;for(var E in v)v.hasOwnProperty(E)&&(k[E]=w(v[E],x));return k;case"Array":return C=l.util.objId(v),x[C]?x[C]:(k=[],x[C]=k,v.forEach(function(O,_){k[_]=w(O,x)}),k);default:return v}},getLanguage:function(w){for(;w;){var v=s.exec(w.className);if(v)return v[1].toLowerCase();w=w.parentElement}return"none"},setLanguage:function(w,v){w.className=w.className.replace(RegExp(s,"gi"),""),w.classList.add("language-"+v)},currentScript:function(){if(typeof document>"u")return null;if(document.currentScript&&document.currentScript.tagName==="SCRIPT")return document.currentScript;try{throw new Error}catch(k){var w=(/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(k.stack)||[])[1];if(w){var v=document.getElementsByTagName("script");for(var x in v)if(v[x].src==w)return v[x]}return null}},isActive:function(w,v,x){for(var k="no-"+v;w;){var C=w.classList;if(C.contains(v))return!0;if(C.contains(k))return!1;w=w.parentElement}return!!x}},languages:{plain:o,plaintext:o,text:o,txt:o,extend:function(w,v){var x=l.util.clone(l.languages[w]);for(var k in v)x[k]=v[k];return x},insertBefore:function(w,v,x,k){k=k||l.languages;var C=k[w],E={};for(var O in C)if(C.hasOwnProperty(O)){if(O==v)for(var _ in x)x.hasOwnProperty(_)&&(E[_]=x[_]);x.hasOwnProperty(O)||(E[O]=C[O])}var M=k[w];return k[w]=E,l.languages.DFS(l.languages,function(D,R){R===M&&D!=w&&(this[D]=E)}),E},DFS:function w(v,x,k,C){C=C||{};var E=l.util.objId;for(var O in v)if(v.hasOwnProperty(O)){x.call(v,O,v[O],k||O);var _=v[O],M=l.util.type(_);M==="Object"&&!C[E(_)]?(C[E(_)]=!0,w(_,x,null,C)):M==="Array"&&!C[E(_)]&&(C[E(_)]=!0,w(_,x,O,C))}}},plugins:{},highlightAll:function(w,v){l.highlightAllUnder(document,w,v)},highlightAllUnder:function(w,v,x){var k={callback:x,container:w,selector:'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'};l.hooks.run("before-highlightall",k),k.elements=Array.prototype.slice.apply(k.container.querySelectorAll(k.selector)),l.hooks.run("before-all-elements-highlight",k);for(var C=0,E;E=k.elements[C++];)l.highlightElement(E,v===!0,k.callback)},highlightElement:function(w,v,x){var k=l.util.getLanguage(w),C=l.languages[k];l.util.setLanguage(w,k);var E=w.parentElement;E&&E.nodeName.toLowerCase()==="pre"&&l.util.setLanguage(E,k);var O=w.textContent,_={element:w,language:k,grammar:C,code:O};function M(R){_.highlightedCode=R,l.hooks.run("before-insert",_),_.element.innerHTML=_.highlightedCode,l.hooks.run("after-highlight",_),l.hooks.run("complete",_),x&&x.call(_.element)}if(l.hooks.run("before-sanity-check",_),E=_.element.parentElement,E&&E.nodeName.toLowerCase()==="pre"&&!E.hasAttribute("tabindex")&&E.setAttribute("tabindex","0"),!_.code){l.hooks.run("complete",_),x&&x.call(_.element);return}if(l.hooks.run("before-highlight",_),!_.grammar){M(l.util.encode(_.code));return}if(v&&r.Worker){var D=new Worker(l.filename);D.onmessage=function(R){M(R.data)},D.postMessage(JSON.stringify({language:_.language,code:_.code,immediateClose:!0}))}else M(l.highlight(_.code,_.grammar,_.language))},highlight:function(w,v,x){var k={code:w,grammar:v,language:x};if(l.hooks.run("before-tokenize",k),!k.grammar)throw new Error('The language "'+k.language+'" has no grammar.');return k.tokens=l.tokenize(k.code,k.grammar),l.hooks.run("after-tokenize",k),a.stringify(l.util.encode(k.tokens),k.language)},tokenize:function(w,v){var x=v.rest;if(x){for(var k in x)v[k]=x[k];delete v.rest}var C=new d;return f(C,C.head,w),u(w,C,v,C.head,0),p(C)},hooks:{all:{},add:function(w,v){var x=l.hooks.all;x[w]=x[w]||[],x[w].push(v)},run:function(w,v){var x=l.hooks.all[w];if(!(!x||!x.length))for(var k=0,C;C=x[k++];)C(v)}},Token:a};r.Prism=l;function a(w,v,x,k){this.type=w,this.content=v,this.alias=x,this.length=(k||"").length|0}a.stringify=function w(v,x){if(typeof v=="string")return v;if(Array.isArray(v)){var k="";return v.forEach(function(M){k+=w(M,x)}),k}var C={type:v.type,content:w(v.content,x),tag:"span",classes:["token",v.type],attributes:{},language:x},E=v.alias;E&&(Array.isArray(E)?Array.prototype.push.apply(C.classes,E):C.classes.push(E)),l.hooks.run("wrap",C);var O="";for(var _ in C.attributes)O+=" "+_+'="'+(C.attributes[_]||"").replace(/"/g,""")+'"';return"<"+C.tag+' class="'+C.classes.join(" ")+'"'+O+">"+C.content+"</"+C.tag+">"};function c(w,v,x,k){w.lastIndex=v;var C=w.exec(x);if(C&&k&&C[1]){var E=C[1].length;C.index+=E,C[0]=C[0].slice(E)}return C}function u(w,v,x,k,C,E){for(var O in x)if(!(!x.hasOwnProperty(O)||!x[O])){var _=x[O];_=Array.isArray(_)?_:[_];for(var M=0;M<_.length;++M){if(E&&E.cause==O+","+M)return;var D=_[M],R=D.inside,L=!!D.lookbehind,I=!!D.greedy,N=D.alias;if(I&&!D.pattern.global){var z=D.pattern.toString().match(/[imsuy]*$/)[0];D.pattern=RegExp(D.pattern.source,z+"g")}for(var H=D.pattern||D,U=k.next,q=C;U!==v.tail&&!(E&&q>=E.reach);q+=U.value.length,U=U.next){var de=U.value;if(v.length>w.length)return;if(!(de instanceof a)){var ve=1,Ee;if(I){if(Ee=c(H,q,w,L),!Ee||Ee.index>=w.length)break;var ze=Ee.index,Ct=Ee.index+Ee[0].length,Me=q;for(Me+=U.value.length;ze>=Me;)U=U.next,Me+=U.value.length;if(Me-=U.value.length,q=Me,U.value instanceof a)continue;for(var Ae=U;Ae!==v.tail&&(Me<Ct||typeof Ae.value=="string");Ae=Ae.next)ve++,Me+=Ae.value.length;ve--,de=w.slice(q,Me),Ee.index-=q}else if(Ee=c(H,0,de,L),!Ee)continue;var ze=Ee.index,$=Ee[0],F=de.slice(0,ze),Ut=de.slice(ze+$.length),_t=q+de.length;E&&_t>E.reach&&(E.reach=_t);var oe=U.prev;F&&(oe=f(v,oe,F),q+=F.length),h(v,oe,ve);var wn=new a(O,R?l.tokenize($,R):$,N,$);if(U=f(v,oe,wn),Ut&&f(v,U,Ut),ve>1){var V={cause:O+","+M,reach:_t};u(w,v,x,U.prev,q,V),E&&V.reach>E.reach&&(E.reach=V.reach)}}}}}}function d(){var w={value:null,prev:null,next:null},v={value:null,prev:w,next:null};w.next=v,this.head=w,this.tail=v,this.length=0}function f(w,v,x){var k=v.next,C={value:x,prev:v,next:k};return v.next=C,k.prev=C,w.length++,C}function h(w,v,x){for(var k=v.next,C=0;C<x&&k!==w.tail;C++)k=k.next;v.next=k,k.prev=v,w.length-=C}function p(w){for(var v=[],x=w.head.next;x!==w.tail;)v.push(x.value),x=x.next;return v}if(!r.document)return r.addEventListener&&(l.disableWorkerMessageHandler||r.addEventListener("message",function(w){var v=JSON.parse(w.data),x=v.language,k=v.code,C=v.immediateClose;r.postMessage(l.highlight(k,l.languages[x],x)),C&&r.close()},!1)),l;var g=l.util.currentScript();g&&(l.filename=g.src,g.hasAttribute("data-manual")&&(l.manual=!0));function y(){l.manual||l.highlightAll()}if(!l.manual){var b=document.readyState;b==="loading"||b==="interactive"&&g&&g.defer?document.addEventListener("DOMContentLoaded",y):window.requestAnimationFrame?window.requestAnimationFrame(y):window.setTimeout(y,16)}return l}(e);t.exports&&(t.exports=n),typeof Ht<"u"&&(Ht.Prism=n),n.languages.markup={comment:{pattern:/<!--(?:(?!<!--)[\s\S])*?-->/,greedy:!0},prolog:{pattern:/<\?[\s\S]+?\?>/,greedy:!0},doctype:{pattern:/<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,greedy:!0,inside:{"internal-subset":{pattern:/(^[^\[]*\[)[\s\S]+(?=\]>$)/,lookbehind:!0,greedy:!0,inside:null},string:{pattern:/"[^"]*"|'[^']*'/,greedy:!0},punctuation:/^<!|>$|[[\]]/,"doctype-tag":/^DOCTYPE/i,name:/[^\s<>'"]+/}},cdata:{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,greedy:!0},tag:{pattern:/<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,greedy:!0,inside:{tag:{pattern:/^<\/?[^\s>\/]+/,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"special-attr":[],"attr-value":{pattern:/=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,inside:{punctuation:[{pattern:/^=/,alias:"attr-equals"},{pattern:/^(\s*)["']|["']$/,lookbehind:!0}]}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:[{pattern:/&[\da-z]{1,8};/i,alias:"named-entity"},/&#x?[\da-f]{1,8};/i]},n.languages.markup.tag.inside["attr-value"].inside.entity=n.languages.markup.entity,n.languages.markup.doctype.inside["internal-subset"].inside=n.languages.markup,n.hooks.add("wrap",function(r){r.type==="entity"&&(r.attributes.title=r.content.replace(/&/,"&"))}),Object.defineProperty(n.languages.markup.tag,"addInlined",{value:function(s,i){var o={};o["language-"+i]={pattern:/(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,lookbehind:!0,inside:n.languages[i]},o.cdata=/^<!\[CDATA\[|\]\]>$/i;var l={"included-cdata":{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,inside:o}};l["language-"+i]={pattern:/[\s\S]+/,inside:n.languages[i]};var a={};a[s]={pattern:RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g,function(){return s}),"i"),lookbehind:!0,greedy:!0,inside:l},n.languages.insertBefore("markup","cdata",a)}}),Object.defineProperty(n.languages.markup.tag,"addAttribute",{value:function(r,s){n.languages.markup.tag.inside["special-attr"].push({pattern:RegExp(/(^|["'\s])/.source+"(?:"+r+")"+/\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source,"i"),lookbehind:!0,inside:{"attr-name":/^[^\s=]+/,"attr-value":{pattern:/=[\s\S]+/,inside:{value:{pattern:/(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,lookbehind:!0,alias:[s,"language-"+s],inside:n.languages[s]},punctuation:[{pattern:/^=/,alias:"attr-equals"},/"|'/]}}}})}}),n.languages.html=n.languages.markup,n.languages.mathml=n.languages.markup,n.languages.svg=n.languages.markup,n.languages.xml=n.languages.extend("markup",{}),n.languages.ssml=n.languages.xml,n.languages.atom=n.languages.xml,n.languages.rss=n.languages.xml,function(r){var s=/(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;r.languages.css={comment:/\/\*[\s\S]*?\*\//,atrule:{pattern:RegExp("@[\\w-](?:"+/[^;{\s"']|\s+(?!\s)/.source+"|"+s.source+")*?"+/(?:;|(?=\s*\{))/.source),inside:{rule:/^@[\w-]+/,"selector-function-argument":{pattern:/(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,lookbehind:!0,alias:"selector"},keyword:{pattern:/(^|[^\w-])(?:and|not|only|or)(?![\w-])/,lookbehind:!0}}},url:{pattern:RegExp("\\burl\\((?:"+s.source+"|"+/(?:[^\\\r\n()"']|\\[\s\S])*/.source+")\\)","i"),greedy:!0,inside:{function:/^url/i,punctuation:/^\(|\)$/,string:{pattern:RegExp("^"+s.source+"$"),alias:"url"}}},selector:{pattern:RegExp(`(^|[{}\\s])[^{}\\s](?:[^{};"'\\s]|\\s+(?![\\s{])|`+s.source+")*(?=\\s*\\{)"),lookbehind:!0},string:{pattern:s,greedy:!0},property:{pattern:/(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,lookbehind:!0},important:/!important\b/i,function:{pattern:/(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,lookbehind:!0},punctuation:/[(){};:,]/},r.languages.css.atrule.inside.rest=r.languages.css;var i=r.languages.markup;i&&(i.tag.addInlined("style","css"),i.tag.addAttribute("style","css"))}(n),n.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,lookbehind:!0,greedy:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0,greedy:!0}],string:{pattern:/(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,lookbehind:!0,inside:{punctuation:/[.\\]/}},keyword:/\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,boolean:/\b(?:false|true)\b/,function:/\b\w+(?=\()/,number:/\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,operator:/[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/},n.languages.javascript=n.languages.extend("clike",{"class-name":[n.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(/(^|[^\w$])/.source+"(?:"+(/NaN|Infinity/.source+"|"+/0[bB][01]+(?:_[01]+)*n?/.source+"|"+/0[oO][0-7]+(?:_[0-7]+)*n?/.source+"|"+/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source+"|"+/\d+(?:_\d+)*n/.source+"|"+/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source)+")"+/(?![\w$])/.source),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),n.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,n.languages.insertBefore("javascript","keyword",{regex:{pattern:RegExp(/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source+/\//.source+"(?:"+/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source+"|"+/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source+")"+/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source),lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:"language-regex",inside:n.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:n.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:n.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:n.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:n.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),n.languages.insertBefore("javascript","string",{hashbang:{pattern:/^#!.*/,greedy:!0,alias:"comment"},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:n.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:"property"}}),n.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}}),n.languages.markup&&(n.languages.markup.tag.addInlined("script","javascript"),n.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,"javascript")),n.languages.js=n.languages.javascript,function(){if(typeof n>"u"||typeof document>"u")return;Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector);var r="Loading…",s=function(g,y){return"✖ Error "+g+" while fetching file: "+y},i="✖ Error: File does not exist or is empty",o={js:"javascript",py:"python",rb:"ruby",ps1:"powershell",psm1:"powershell",sh:"bash",bat:"batch",h:"c",tex:"latex"},l="data-src-status",a="loading",c="loaded",u="failed",d="pre[data-src]:not(["+l+'="'+c+'"]):not(['+l+'="'+a+'"])';function f(g,y,b){var w=new XMLHttpRequest;w.open("GET",g,!0),w.onreadystatechange=function(){w.readyState==4&&(w.status<400&&w.responseText?y(w.responseText):w.status>=400?b(s(w.status,w.statusText)):b(i))},w.send(null)}function h(g){var y=/^\s*(\d+)\s*(?:(,)\s*(?:(\d+)\s*)?)?$/.exec(g||"");if(y){var b=Number(y[1]),w=y[2],v=y[3];return w?v?[b,Number(v)]:[b,void 0]:[b,b]}}n.hooks.add("before-highlightall",function(g){g.selector+=", "+d}),n.hooks.add("before-sanity-check",function(g){var y=g.element;if(y.matches(d)){g.code="",y.setAttribute(l,a);var b=y.appendChild(document.createElement("CODE"));b.textContent=r;var w=y.getAttribute("data-src"),v=g.language;if(v==="none"){var x=(/\.(\w+)$/.exec(w)||[,"none"])[1];v=o[x]||x}n.util.setLanguage(b,v),n.util.setLanguage(y,v);var k=n.plugins.autoloader;k&&k.loadLanguages(v),f(w,function(C){y.setAttribute(l,c);var E=h(y.getAttribute("data-range"));if(E){var O=C.split(/\r\n?|\n/g),_=E[0],M=E[1]==null?O.length:E[1];_<0&&(_+=O.length),_=Math.max(0,Math.min(_-1,O.length)),M<0&&(M+=O.length),M=Math.max(0,Math.min(M,O.length)),C=O.slice(_,M).join(`
|
|
225
|
-
`),y.hasAttribute("data-start")||y.setAttribute("data-start",String(_+1))}b.textContent=C,n.highlightElement(b)},function(C){y.setAttribute(l,u),b.textContent=C})}}),n.plugins.fileHighlight={highlight:function(y){for(var b=(y||document).querySelectorAll(d),w=0,v;v=b[w++];)n.highlightElement(v)}};var p=!1;n.fileHighlight=function(){p||(console.warn("Prism.fileHighlight is deprecated. Use `Prism.plugins.fileHighlight.highlight` instead."),p=!0),n.plugins.fileHighlight.highlight.apply(this,arguments)}}()})(
|
|
226
|
-
<path d="M6 6 L18 18"
|
|
227
|
-
<rect x="2" y="6" width="14" height="12" rx="3.25"
|
|
224
|
+
*/var n=function(r){var s=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,i=0,o={},l={manual:r.Prism&&r.Prism.manual,disableWorkerMessageHandler:r.Prism&&r.Prism.disableWorkerMessageHandler,util:{encode:function w(v){return v instanceof a?new a(v.type,w(v.content),v.alias):Array.isArray(v)?v.map(w):v.replace(/&/g,"&").replace(/</g,"<").replace(/\u00a0/g," ")},type:function(w){return Object.prototype.toString.call(w).slice(8,-1)},objId:function(w){return w.__id||Object.defineProperty(w,"__id",{value:++i}),w.__id},clone:function w(v,x){x=x||{};var k,C;switch(l.util.type(v)){case"Object":if(C=l.util.objId(v),x[C])return x[C];k={},x[C]=k;for(var M in v)v.hasOwnProperty(M)&&(k[M]=w(v[M],x));return k;case"Array":return C=l.util.objId(v),x[C]?x[C]:(k=[],x[C]=k,v.forEach(function(O,_){k[_]=w(O,x)}),k);default:return v}},getLanguage:function(w){for(;w;){var v=s.exec(w.className);if(v)return v[1].toLowerCase();w=w.parentElement}return"none"},setLanguage:function(w,v){w.className=w.className.replace(RegExp(s,"gi"),""),w.classList.add("language-"+v)},currentScript:function(){if(typeof document>"u")return null;if(document.currentScript&&document.currentScript.tagName==="SCRIPT")return document.currentScript;try{throw new Error}catch(k){var w=(/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(k.stack)||[])[1];if(w){var v=document.getElementsByTagName("script");for(var x in v)if(v[x].src==w)return v[x]}return null}},isActive:function(w,v,x){for(var k="no-"+v;w;){var C=w.classList;if(C.contains(v))return!0;if(C.contains(k))return!1;w=w.parentElement}return!!x}},languages:{plain:o,plaintext:o,text:o,txt:o,extend:function(w,v){var x=l.util.clone(l.languages[w]);for(var k in v)x[k]=v[k];return x},insertBefore:function(w,v,x,k){k=k||l.languages;var C=k[w],M={};for(var O in C)if(C.hasOwnProperty(O)){if(O==v)for(var _ in x)x.hasOwnProperty(_)&&(M[_]=x[_]);x.hasOwnProperty(O)||(M[O]=C[O])}var A=k[w];return k[w]=M,l.languages.DFS(l.languages,function(R,D){D===A&&R!=w&&(this[R]=M)}),M},DFS:function w(v,x,k,C){C=C||{};var M=l.util.objId;for(var O in v)if(v.hasOwnProperty(O)){x.call(v,O,v[O],k||O);var _=v[O],A=l.util.type(_);A==="Object"&&!C[M(_)]?(C[M(_)]=!0,w(_,x,null,C)):A==="Array"&&!C[M(_)]&&(C[M(_)]=!0,w(_,x,O,C))}}},plugins:{},highlightAll:function(w,v){l.highlightAllUnder(document,w,v)},highlightAllUnder:function(w,v,x){var k={callback:x,container:w,selector:'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'};l.hooks.run("before-highlightall",k),k.elements=Array.prototype.slice.apply(k.container.querySelectorAll(k.selector)),l.hooks.run("before-all-elements-highlight",k);for(var C=0,M;M=k.elements[C++];)l.highlightElement(M,v===!0,k.callback)},highlightElement:function(w,v,x){var k=l.util.getLanguage(w),C=l.languages[k];l.util.setLanguage(w,k);var M=w.parentElement;M&&M.nodeName.toLowerCase()==="pre"&&l.util.setLanguage(M,k);var O=w.textContent,_={element:w,language:k,grammar:C,code:O};function A(D){_.highlightedCode=D,l.hooks.run("before-insert",_),_.element.innerHTML=_.highlightedCode,l.hooks.run("after-highlight",_),l.hooks.run("complete",_),x&&x.call(_.element)}if(l.hooks.run("before-sanity-check",_),M=_.element.parentElement,M&&M.nodeName.toLowerCase()==="pre"&&!M.hasAttribute("tabindex")&&M.setAttribute("tabindex","0"),!_.code){l.hooks.run("complete",_),x&&x.call(_.element);return}if(l.hooks.run("before-highlight",_),!_.grammar){A(l.util.encode(_.code));return}if(v&&r.Worker){var R=new Worker(l.filename);R.onmessage=function(D){A(D.data)},R.postMessage(JSON.stringify({language:_.language,code:_.code,immediateClose:!0}))}else A(l.highlight(_.code,_.grammar,_.language))},highlight:function(w,v,x){var k={code:w,grammar:v,language:x};if(l.hooks.run("before-tokenize",k),!k.grammar)throw new Error('The language "'+k.language+'" has no grammar.');return k.tokens=l.tokenize(k.code,k.grammar),l.hooks.run("after-tokenize",k),a.stringify(l.util.encode(k.tokens),k.language)},tokenize:function(w,v){var x=v.rest;if(x){for(var k in x)v[k]=x[k];delete v.rest}var C=new d;return h(C,C.head,w),u(w,C,v,C.head,0),p(C)},hooks:{all:{},add:function(w,v){var x=l.hooks.all;x[w]=x[w]||[],x[w].push(v)},run:function(w,v){var x=l.hooks.all[w];if(!(!x||!x.length))for(var k=0,C;C=x[k++];)C(v)}},Token:a};r.Prism=l;function a(w,v,x,k){this.type=w,this.content=v,this.alias=x,this.length=(k||"").length|0}a.stringify=function w(v,x){if(typeof v=="string")return v;if(Array.isArray(v)){var k="";return v.forEach(function(A){k+=w(A,x)}),k}var C={type:v.type,content:w(v.content,x),tag:"span",classes:["token",v.type],attributes:{},language:x},M=v.alias;M&&(Array.isArray(M)?Array.prototype.push.apply(C.classes,M):C.classes.push(M)),l.hooks.run("wrap",C);var O="";for(var _ in C.attributes)O+=" "+_+'="'+(C.attributes[_]||"").replace(/"/g,""")+'"';return"<"+C.tag+' class="'+C.classes.join(" ")+'"'+O+">"+C.content+"</"+C.tag+">"};function c(w,v,x,k){w.lastIndex=v;var C=w.exec(x);if(C&&k&&C[1]){var M=C[1].length;C.index+=M,C[0]=C[0].slice(M)}return C}function u(w,v,x,k,C,M){for(var O in x)if(!(!x.hasOwnProperty(O)||!x[O])){var _=x[O];_=Array.isArray(_)?_:[_];for(var A=0;A<_.length;++A){if(M&&M.cause==O+","+A)return;var R=_[A],D=R.inside,L=!!R.lookbehind,I=!!R.greedy,N=R.alias;if(I&&!R.pattern.global){var H=R.pattern.toString().match(/[imsuy]*$/)[0];R.pattern=RegExp(R.pattern.source,H+"g")}for(var $=R.pattern||R,U=k.next,K=C;U!==v.tail&&!(M&&K>=M.reach);K+=U.value.length,U=U.next){var de=U.value;if(v.length>w.length)return;if(!(de instanceof a)){var ve=1,Me;if(I){if(Me=c($,K,w,L),!Me||Me.index>=w.length)break;var He=Me.index,Ct=Me.index+Me[0].length,Ae=K;for(Ae+=U.value.length;He>=Ae;)U=U.next,Ae+=U.value.length;if(Ae-=U.value.length,K=Ae,U.value instanceof a)continue;for(var Te=U;Te!==v.tail&&(Ae<Ct||typeof Te.value=="string");Te=Te.next)ve++,Ae+=Te.value.length;ve--,de=w.slice(K,Ae),Me.index-=K}else if(Me=c($,0,de,L),!Me)continue;var He=Me.index,z=Me[0],V=de.slice(0,He),Ut=de.slice(He+z.length),_t=K+de.length;M&&_t>M.reach&&(M.reach=_t);var oe=U.prev;V&&(oe=h(v,oe,V),K+=V.length),f(v,oe,ve);var wn=new a(O,D?l.tokenize(z,D):z,N,z);if(U=h(v,oe,wn),Ut&&h(v,U,Ut),ve>1){var F={cause:O+","+A,reach:_t};u(w,v,x,U.prev,K,F),M&&F.reach>M.reach&&(M.reach=F.reach)}}}}}}function d(){var w={value:null,prev:null,next:null},v={value:null,prev:w,next:null};w.next=v,this.head=w,this.tail=v,this.length=0}function h(w,v,x){var k=v.next,C={value:x,prev:v,next:k};return v.next=C,k.prev=C,w.length++,C}function f(w,v,x){for(var k=v.next,C=0;C<x&&k!==w.tail;C++)k=k.next;v.next=k,k.prev=v,w.length-=C}function p(w){for(var v=[],x=w.head.next;x!==w.tail;)v.push(x.value),x=x.next;return v}if(!r.document)return r.addEventListener&&(l.disableWorkerMessageHandler||r.addEventListener("message",function(w){var v=JSON.parse(w.data),x=v.language,k=v.code,C=v.immediateClose;r.postMessage(l.highlight(k,l.languages[x],x)),C&&r.close()},!1)),l;var g=l.util.currentScript();g&&(l.filename=g.src,g.hasAttribute("data-manual")&&(l.manual=!0));function y(){l.manual||l.highlightAll()}if(!l.manual){var b=document.readyState;b==="loading"||b==="interactive"&&g&&g.defer?document.addEventListener("DOMContentLoaded",y):window.requestAnimationFrame?window.requestAnimationFrame(y):window.setTimeout(y,16)}return l}(e);t.exports&&(t.exports=n),typeof $t<"u"&&($t.Prism=n),n.languages.markup={comment:{pattern:/<!--(?:(?!<!--)[\s\S])*?-->/,greedy:!0},prolog:{pattern:/<\?[\s\S]+?\?>/,greedy:!0},doctype:{pattern:/<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,greedy:!0,inside:{"internal-subset":{pattern:/(^[^\[]*\[)[\s\S]+(?=\]>$)/,lookbehind:!0,greedy:!0,inside:null},string:{pattern:/"[^"]*"|'[^']*'/,greedy:!0},punctuation:/^<!|>$|[[\]]/,"doctype-tag":/^DOCTYPE/i,name:/[^\s<>'"]+/}},cdata:{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,greedy:!0},tag:{pattern:/<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,greedy:!0,inside:{tag:{pattern:/^<\/?[^\s>\/]+/,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"special-attr":[],"attr-value":{pattern:/=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,inside:{punctuation:[{pattern:/^=/,alias:"attr-equals"},{pattern:/^(\s*)["']|["']$/,lookbehind:!0}]}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:[{pattern:/&[\da-z]{1,8};/i,alias:"named-entity"},/&#x?[\da-f]{1,8};/i]},n.languages.markup.tag.inside["attr-value"].inside.entity=n.languages.markup.entity,n.languages.markup.doctype.inside["internal-subset"].inside=n.languages.markup,n.hooks.add("wrap",function(r){r.type==="entity"&&(r.attributes.title=r.content.replace(/&/,"&"))}),Object.defineProperty(n.languages.markup.tag,"addInlined",{value:function(s,i){var o={};o["language-"+i]={pattern:/(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,lookbehind:!0,inside:n.languages[i]},o.cdata=/^<!\[CDATA\[|\]\]>$/i;var l={"included-cdata":{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,inside:o}};l["language-"+i]={pattern:/[\s\S]+/,inside:n.languages[i]};var a={};a[s]={pattern:RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g,function(){return s}),"i"),lookbehind:!0,greedy:!0,inside:l},n.languages.insertBefore("markup","cdata",a)}}),Object.defineProperty(n.languages.markup.tag,"addAttribute",{value:function(r,s){n.languages.markup.tag.inside["special-attr"].push({pattern:RegExp(/(^|["'\s])/.source+"(?:"+r+")"+/\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source,"i"),lookbehind:!0,inside:{"attr-name":/^[^\s=]+/,"attr-value":{pattern:/=[\s\S]+/,inside:{value:{pattern:/(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,lookbehind:!0,alias:[s,"language-"+s],inside:n.languages[s]},punctuation:[{pattern:/^=/,alias:"attr-equals"},/"|'/]}}}})}}),n.languages.html=n.languages.markup,n.languages.mathml=n.languages.markup,n.languages.svg=n.languages.markup,n.languages.xml=n.languages.extend("markup",{}),n.languages.ssml=n.languages.xml,n.languages.atom=n.languages.xml,n.languages.rss=n.languages.xml,function(r){var s=/(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;r.languages.css={comment:/\/\*[\s\S]*?\*\//,atrule:{pattern:RegExp("@[\\w-](?:"+/[^;{\s"']|\s+(?!\s)/.source+"|"+s.source+")*?"+/(?:;|(?=\s*\{))/.source),inside:{rule:/^@[\w-]+/,"selector-function-argument":{pattern:/(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,lookbehind:!0,alias:"selector"},keyword:{pattern:/(^|[^\w-])(?:and|not|only|or)(?![\w-])/,lookbehind:!0}}},url:{pattern:RegExp("\\burl\\((?:"+s.source+"|"+/(?:[^\\\r\n()"']|\\[\s\S])*/.source+")\\)","i"),greedy:!0,inside:{function:/^url/i,punctuation:/^\(|\)$/,string:{pattern:RegExp("^"+s.source+"$"),alias:"url"}}},selector:{pattern:RegExp(`(^|[{}\\s])[^{}\\s](?:[^{};"'\\s]|\\s+(?![\\s{])|`+s.source+")*(?=\\s*\\{)"),lookbehind:!0},string:{pattern:s,greedy:!0},property:{pattern:/(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,lookbehind:!0},important:/!important\b/i,function:{pattern:/(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,lookbehind:!0},punctuation:/[(){};:,]/},r.languages.css.atrule.inside.rest=r.languages.css;var i=r.languages.markup;i&&(i.tag.addInlined("style","css"),i.tag.addAttribute("style","css"))}(n),n.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,lookbehind:!0,greedy:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0,greedy:!0}],string:{pattern:/(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,lookbehind:!0,inside:{punctuation:/[.\\]/}},keyword:/\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,boolean:/\b(?:false|true)\b/,function:/\b\w+(?=\()/,number:/\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,operator:/[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/},n.languages.javascript=n.languages.extend("clike",{"class-name":[n.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(/(^|[^\w$])/.source+"(?:"+(/NaN|Infinity/.source+"|"+/0[bB][01]+(?:_[01]+)*n?/.source+"|"+/0[oO][0-7]+(?:_[0-7]+)*n?/.source+"|"+/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source+"|"+/\d+(?:_\d+)*n/.source+"|"+/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source)+")"+/(?![\w$])/.source),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),n.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,n.languages.insertBefore("javascript","keyword",{regex:{pattern:RegExp(/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source+/\//.source+"(?:"+/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source+"|"+/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source+")"+/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source),lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:"language-regex",inside:n.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:n.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:n.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:n.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:n.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),n.languages.insertBefore("javascript","string",{hashbang:{pattern:/^#!.*/,greedy:!0,alias:"comment"},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:n.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:"property"}}),n.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}}),n.languages.markup&&(n.languages.markup.tag.addInlined("script","javascript"),n.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,"javascript")),n.languages.js=n.languages.javascript,function(){if(typeof n>"u"||typeof document>"u")return;Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector);var r="Loading…",s=function(g,y){return"✖ Error "+g+" while fetching file: "+y},i="✖ Error: File does not exist or is empty",o={js:"javascript",py:"python",rb:"ruby",ps1:"powershell",psm1:"powershell",sh:"bash",bat:"batch",h:"c",tex:"latex"},l="data-src-status",a="loading",c="loaded",u="failed",d="pre[data-src]:not(["+l+'="'+c+'"]):not(['+l+'="'+a+'"])';function h(g,y,b){var w=new XMLHttpRequest;w.open("GET",g,!0),w.onreadystatechange=function(){w.readyState==4&&(w.status<400&&w.responseText?y(w.responseText):w.status>=400?b(s(w.status,w.statusText)):b(i))},w.send(null)}function f(g){var y=/^\s*(\d+)\s*(?:(,)\s*(?:(\d+)\s*)?)?$/.exec(g||"");if(y){var b=Number(y[1]),w=y[2],v=y[3];return w?v?[b,Number(v)]:[b,void 0]:[b,b]}}n.hooks.add("before-highlightall",function(g){g.selector+=", "+d}),n.hooks.add("before-sanity-check",function(g){var y=g.element;if(y.matches(d)){g.code="",y.setAttribute(l,a);var b=y.appendChild(document.createElement("CODE"));b.textContent=r;var w=y.getAttribute("data-src"),v=g.language;if(v==="none"){var x=(/\.(\w+)$/.exec(w)||[,"none"])[1];v=o[x]||x}n.util.setLanguage(b,v),n.util.setLanguage(y,v);var k=n.plugins.autoloader;k&&k.loadLanguages(v),h(w,function(C){y.setAttribute(l,c);var M=f(y.getAttribute("data-range"));if(M){var O=C.split(/\r\n?|\n/g),_=M[0],A=M[1]==null?O.length:M[1];_<0&&(_+=O.length),_=Math.max(0,Math.min(_-1,O.length)),A<0&&(A+=O.length),A=Math.max(0,Math.min(A,O.length)),C=O.slice(_,A).join(`
|
|
225
|
+
`),y.hasAttribute("data-start")||y.setAttribute("data-start",String(_+1))}b.textContent=C,n.highlightElement(b)},function(C){y.setAttribute(l,u),b.textContent=C})}}),n.plugins.fileHighlight={highlight:function(y){for(var b=(y||document).querySelectorAll(d),w=0,v;v=b[w++];)n.highlightElement(v)}};var p=!1;n.fileHighlight=function(){p||(console.warn("Prism.fileHighlight is deprecated. Use `Prism.plugins.fileHighlight.highlight` instead."),p=!0),n.plugins.fileHighlight.highlight.apply(this,arguments)}}()})(Fb);var c3=Fb.exports;const ma=oS(c3);Prism.languages.markup={comment:{pattern:/<!--(?:(?!<!--)[\s\S])*?-->/,greedy:!0},prolog:{pattern:/<\?[\s\S]+?\?>/,greedy:!0},doctype:{pattern:/<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,greedy:!0,inside:{"internal-subset":{pattern:/(^[^\[]*\[)[\s\S]+(?=\]>$)/,lookbehind:!0,greedy:!0,inside:null},string:{pattern:/"[^"]*"|'[^']*'/,greedy:!0},punctuation:/^<!|>$|[[\]]/,"doctype-tag":/^DOCTYPE/i,name:/[^\s<>'"]+/}},cdata:{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,greedy:!0},tag:{pattern:/<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,greedy:!0,inside:{tag:{pattern:/^<\/?[^\s>\/]+/,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"special-attr":[],"attr-value":{pattern:/=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,inside:{punctuation:[{pattern:/^=/,alias:"attr-equals"},{pattern:/^(\s*)["']|["']$/,lookbehind:!0}]}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:[{pattern:/&[\da-z]{1,8};/i,alias:"named-entity"},/&#x?[\da-f]{1,8};/i]};Prism.languages.markup.tag.inside["attr-value"].inside.entity=Prism.languages.markup.entity;Prism.languages.markup.doctype.inside["internal-subset"].inside=Prism.languages.markup;Prism.hooks.add("wrap",function(t){t.type==="entity"&&(t.attributes.title=t.content.replace(/&/,"&"))});Object.defineProperty(Prism.languages.markup.tag,"addInlined",{value:function(e,n){var r={};r["language-"+n]={pattern:/(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,lookbehind:!0,inside:Prism.languages[n]},r.cdata=/^<!\[CDATA\[|\]\]>$/i;var s={"included-cdata":{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,inside:r}};s["language-"+n]={pattern:/[\s\S]+/,inside:Prism.languages[n]};var i={};i[e]={pattern:RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g,function(){return e}),"i"),lookbehind:!0,greedy:!0,inside:s},Prism.languages.insertBefore("markup","cdata",i)}});Object.defineProperty(Prism.languages.markup.tag,"addAttribute",{value:function(t,e){Prism.languages.markup.tag.inside["special-attr"].push({pattern:RegExp(/(^|["'\s])/.source+"(?:"+t+")"+/\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source,"i"),lookbehind:!0,inside:{"attr-name":/^[^\s=]+/,"attr-value":{pattern:/=[\s\S]+/,inside:{value:{pattern:/(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,lookbehind:!0,alias:[e,"language-"+e],inside:Prism.languages[e]},punctuation:[{pattern:/^=/,alias:"attr-equals"},/"|'/]}}}})}});Prism.languages.html=Prism.languages.markup;Prism.languages.mathml=Prism.languages.markup;Prism.languages.svg=Prism.languages.markup;Prism.languages.xml=Prism.languages.extend("markup",{});Prism.languages.ssml=Prism.languages.xml;Prism.languages.atom=Prism.languages.xml;Prism.languages.rss=Prism.languages.xml;const u3="_wrapper_830qn_2",d3="_white_830qn_10",h3="_gray_830qn_11",f3="_disabled_830qn_14",p3="_error_830qn_14",m3="_menuBarRegion_830qn_20",g3="_readOnly_830qn_51",y3="_content_830qn_66",b3="_htmlSource_830qn_98",w3="_htmlSourceTextarea_830qn_103",Mn={wrapper:u3,white:d3,gray:h3,disabled:f3,error:p3,menuBarRegion:m3,readOnly:g3,content:y3,htmlSource:b3,htmlSourceTextarea:w3};var J=S.forwardRef((t,e)=>{const{size:n=24,title:r,variant:s="outline",innerSvg:i="",outlineDuoSvg:o,fillSvg:l,fillDuoSvg:a,strokeWidth:c=1.75,...u}=t,d=S.useId(),h=s==="outline-duo"?o??i:s==="fill"||s==="soft-fill"?l??i:s==="fill-duo"?a??i:i,f=h.includes("__MASK__")?h.replace(/__MASK__/g,`nv-ic-${d.replace(/[^a-zA-Z0-9_-]/g,"")}`):h,p=s==="soft"||s==="soft-fill",g=p&&typeof c=="number"?Number((c/.62*.88).toFixed(2)):c;return m.jsxs("svg",{ref:e,xmlns:"http://www.w3.org/2000/svg",width:n,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:c,strokeLinecap:"round",strokeLinejoin:"round",role:r?"img":"presentation","aria-label":r,"aria-hidden":r?void 0:!0,...u,children:[r?m.jsx("title",{children:r}):null,p?m.jsxs(m.Fragment,{children:[m.jsx("rect",{x:"1",y:"1",width:"22",height:"22",rx:"6",fill:"currentColor",fillOpacity:s==="soft-fill"?.16:.14,stroke:"none"}),m.jsx("g",{transform:"translate(4.56 4.56) scale(0.62)",strokeWidth:g,dangerouslySetInnerHTML:{__html:f}})]}):m.jsx("g",{dangerouslySetInnerHTML:{__html:f}})]})});J.displayName="IconBase";var Ub=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M18 6 L6 18" />
|
|
226
|
+
<path d="M6 6 L18 18" />`,fillDuoSvg:'<g opacity="0.38"><path d="M6 6 L18 18" /></g><path d="M18 6 L6 18" />',...t}));Ub.displayName="XIcon";var x3=Ub,Wb=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M16 13 L21.22 16.48 A0.5 0.5 0 0 0 22 16.07 V7.87 A0.5 0.5 0 0 0 21.25 7.44 L16 10.5" />
|
|
227
|
+
<rect x="2" y="6" width="14" height="12" rx="3.25" />`,outlineDuoSvg:`<g fill="currentColor" stroke="none" opacity="0.2"><rect x="2" y="6" width="14" height="12" rx="3.25" /></g><path d="M16 13 L21.22 16.48 A0.5 0.5 0 0 0 22 16.07 V7.87 A0.5 0.5 0 0 0 21.25 7.44 L16 10.5" />
|
|
228
|
+
<rect x="2" y="6" width="14" height="12" rx="3.25" />`,fillSvg:'<g fill="currentColor"><rect x="2" y="6" width="14" height="12" rx="3.25" /></g><path d="M16 13 L21.22 16.48 A0.5 0.5 0 0 0 22 16.07 V7.87 A0.5 0.5 0 0 0 21.25 7.44 L16 10.5" />',fillDuoSvg:'<g fill="currentColor" stroke="currentColor" stroke-width="0.75" opacity="0.38"><rect x="2" y="6" width="14" height="12" rx="3.25" /></g><path d="M16 13 L21.22 16.48 A0.5 0.5 0 0 0 22 16.07 V7.87 A0.5 0.5 0 0 0 21.25 7.44 L16 10.5" />',...t}));Wb.displayName="VideoIcon";var Kb=Wb,qb=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M18.84 12.25 L20.56 10.54 H20.54 A5 5 0 0 0 20.42 3.47 A5.01 5.01 0 0 0 13.47 3.47 L11.75 5.18" />
|
|
228
229
|
<path d="M5.17 11.75 L3.46 13.46 A5 5 0 0 0 3.58 20.53 A5.01 5.01 0 0 0 10.53 20.53 L12.24 18.82" />
|
|
229
230
|
<line x1="8" x2="8" y1="2" y2="5" />
|
|
230
231
|
<line x1="2" x2="5" y1="8" y2="8" />
|
|
231
232
|
<line x1="16" x2="16" y1="19" y2="22" />
|
|
232
|
-
<line x1="19" x2="22" y1="16" y2="16"
|
|
233
|
+
<line x1="19" x2="22" y1="16" y2="16" />`,fillDuoSvg:'<g opacity="0.38"><line x1="8" x2="8" y1="2" y2="5" /><line x1="2" x2="5" y1="8" y2="8" /><line x1="16" x2="16" y1="19" y2="22" /><line x1="19" x2="22" y1="16" y2="16" /></g><path d="M18.84 12.25 L20.56 10.54 H20.54 A5 5 0 0 0 20.42 3.47 A5.01 5.01 0 0 0 13.47 3.47 L11.75 5.18" /><path d="M5.17 11.75 L3.46 13.46 A5 5 0 0 0 3.58 20.53 A5.01 5.01 0 0 0 10.53 20.53 L12.24 18.82" />',...t}));qb.displayName="UnlinkIcon";var v3=qb,Jb=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M12 4 V20" />
|
|
233
234
|
<path d="M4 7 V6.25 A2.25 2.25 0 0 1 6.25 4 H17.75 A2.25 2.25 0 0 1 20 6.25 V7" />
|
|
234
|
-
<path d="M9 20 H15"
|
|
235
|
-
<line x1="4" x2="20" y1="20" y2="20"
|
|
235
|
+
<path d="M9 20 H15" />`,fillDuoSvg:'<g opacity="0.38"><path d="M12 4 V20" /><path d="M9 20 H15" /></g><path d="M4 7 V6.25 A2.25 2.25 0 0 1 6.25 4 H17.75 A2.25 2.25 0 0 1 20 6.25 V7" />',...t}));Jb.displayName="TypeIcon";var k3=Jb,Gb=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M6 4 V10 A6 6 0 0 0 18 10 V4" />
|
|
236
|
+
<line x1="4" x2="20" y1="20" y2="20" />`,fillDuoSvg:'<g opacity="0.38"><line x1="4" x2="20" y1="20" y2="20" /></g><path d="M6 4 V10 A6 6 0 0 0 18 10 V4" />',...t}));Gb.displayName="UnderlineIcon";var Yb=Gb,Xb=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M21.73 18 L14.03 4.53 A2.35 2.35 0 0 0 9.95 4.53 L2.54 17.48 A2.35 2.35 0 0 0 4.59 21 H20 A2 2 0 0 0 21.73 18" />
|
|
236
237
|
<path d="M12 9 V13" />
|
|
237
|
-
<path d="M12 17 H12.01"
|
|
238
|
+
<path d="M12 17 H12.01" />`,outlineDuoSvg:`<g fill="currentColor" stroke="none" opacity="0.2"><path d="M21.73 18 L14.03 4.53 A2.35 2.35 0 0 0 9.95 4.53 L2.54 17.48 A2.35 2.35 0 0 0 4.59 21 H20 A2 2 0 0 0 21.73 18" /></g><path d="M21.73 18 L14.03 4.53 A2.35 2.35 0 0 0 9.95 4.53 L2.54 17.48 A2.35 2.35 0 0 0 4.59 21 H20 A2 2 0 0 0 21.73 18" />
|
|
239
|
+
<path d="M12 9 V13" />
|
|
240
|
+
<path d="M12 17 H12.01" />`,fillSvg:'<defs><mask id="__MASK__"><rect width="24" height="24" fill="white" /><path d="M12 9 V13" fill="none" stroke="black" /><path d="M12 17 H12.01" fill="none" stroke="black" /></mask></defs><g fill="currentColor" mask="url(#__MASK__)"><path d="M21.73 18 L14.03 4.53 A2.35 2.35 0 0 0 9.95 4.53 L2.54 17.48 A2.35 2.35 0 0 0 4.59 21 H20 A2 2 0 0 0 21.73 18" /></g>',fillDuoSvg:'<g fill="currentColor" stroke="currentColor" stroke-width="0.75" opacity="0.38"><path d="M21.73 18 L14.03 4.53 A2.35 2.35 0 0 0 9.95 4.53 L2.54 17.48 A2.35 2.35 0 0 0 4.59 21 H20 A2 2 0 0 0 21.73 18" /></g><path d="M12 9 V13" /><path d="M12 17 H12.01" />',...t}));Xb.displayName="TriangleAlertIcon";var Yh=Xb,Zb=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M10 11 V17" />
|
|
241
|
+
<path d="M14 11 V17" />
|
|
242
|
+
<path d="M19 6 V18.5 A3.5 3.5 0 0 1 15.5 22 H8.5 A3.5 3.5 0 0 1 5 18.5 V6" />
|
|
238
243
|
<path d="M3 6 H21" />
|
|
239
|
-
<path d="M8 6 V5.5 A3.5 3.5 0 0 1 11.5 2 H12.5 A3.5 3.5 0 0 1 16 5.5 V6"
|
|
244
|
+
<path d="M8 6 V5.5 A3.5 3.5 0 0 1 11.5 2 H12.5 A3.5 3.5 0 0 1 16 5.5 V6" />`,outlineDuoSvg:`<g fill="currentColor" stroke="none" opacity="0.2"><path d="M19 6 V18.5 A3.5 3.5 0 0 1 15.5 22 H8.5 A3.5 3.5 0 0 1 5 18.5 V6 Z" /></g><path d="M10 11 V17" />
|
|
240
245
|
<path d="M14 11 V17" />
|
|
241
246
|
<path d="M19 6 V18.5 A3.5 3.5 0 0 1 15.5 22 H8.5 A3.5 3.5 0 0 1 5 18.5 V6" />
|
|
242
247
|
<path d="M3 6 H21" />
|
|
243
|
-
<path d="M8 6 V5.5 A3.5 3.5 0 0 1 11.5 2 H12.5 A3.5 3.5 0 0 1 16 5.5 V6"
|
|
248
|
+
<path d="M8 6 V5.5 A3.5 3.5 0 0 1 11.5 2 H12.5 A3.5 3.5 0 0 1 16 5.5 V6" />`,fillSvg:'<defs><mask id="__MASK__"><rect width="24" height="24" fill="white" /><path d="M10 11 V17" fill="none" stroke="black" /><path d="M14 11 V17" fill="none" stroke="black" /></mask></defs><g fill="currentColor" mask="url(#__MASK__)"><path d="M19 6 V18.5 A3.5 3.5 0 0 1 15.5 22 H8.5 A3.5 3.5 0 0 1 5 18.5 V6 Z" stroke="none" /><path d="M19 6 V18.5 A3.5 3.5 0 0 1 15.5 22 H8.5 A3.5 3.5 0 0 1 5 18.5 V6" /></g><path d="M3 6 H21" /><path d="M8 6 V5.5 A3.5 3.5 0 0 1 11.5 2 H12.5 A3.5 3.5 0 0 1 16 5.5 V6" />',fillDuoSvg:'<g fill="currentColor" stroke="none" opacity="0.38"><path d="M19 6 V18.5 A3.5 3.5 0 0 1 15.5 22 H8.5 A3.5 3.5 0 0 1 5 18.5 V6 Z" stroke="none" /></g><path d="M10 11 V17" /><path d="M14 11 V17" /><path d="M3 6 H21" /><path d="M8 6 V5.5 A3.5 3.5 0 0 1 11.5 2 H12.5 A3.5 3.5 0 0 1 16 5.5 V6" />',...t}));Zb.displayName="Trash2Icon";var St=Zb,Qb=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M19 6 V18.5 A3.5 3.5 0 0 1 15.5 22 H8.5 A3.5 3.5 0 0 1 5 18.5 V6" />
|
|
249
|
+
<path d="M3 6 H21" />
|
|
250
|
+
<path d="M8 6 V5.5 A3.5 3.5 0 0 1 11.5 2 H12.5 A3.5 3.5 0 0 1 16 5.5 V6" />`,outlineDuoSvg:`<g fill="currentColor" stroke="none" opacity="0.2"><path d="M19 6 V18.5 A3.5 3.5 0 0 1 15.5 22 H8.5 A3.5 3.5 0 0 1 5 18.5 V6 Z" /></g><path d="M19 6 V18.5 A3.5 3.5 0 0 1 15.5 22 H8.5 A3.5 3.5 0 0 1 5 18.5 V6" />
|
|
251
|
+
<path d="M3 6 H21" />
|
|
252
|
+
<path d="M8 6 V5.5 A3.5 3.5 0 0 1 11.5 2 H12.5 A3.5 3.5 0 0 1 16 5.5 V6" />`,fillSvg:'<g fill="currentColor"><path d="M19 6 V18.5 A3.5 3.5 0 0 1 15.5 22 H8.5 A3.5 3.5 0 0 1 5 18.5 V6 Z" stroke="none" /><path d="M19 6 V18.5 A3.5 3.5 0 0 1 15.5 22 H8.5 A3.5 3.5 0 0 1 5 18.5 V6" /></g><path d="M3 6 H21" /><path d="M8 6 V5.5 A3.5 3.5 0 0 1 11.5 2 H12.5 A3.5 3.5 0 0 1 16 5.5 V6" />',fillDuoSvg:'<g fill="currentColor" stroke="none" opacity="0.38"><path d="M19 6 V18.5 A3.5 3.5 0 0 1 15.5 22 H8.5 A3.5 3.5 0 0 1 5 18.5 V6 Z" stroke="none" /></g><path d="M3 6 H21" /><path d="M8 6 V5.5 A3.5 3.5 0 0 1 11.5 2 H12.5 A3.5 3.5 0 0 1 16 5.5 V6" />',...t}));Qb.displayName="TrashIcon";var S3=Qb,ew=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M17 5 H3" />
|
|
244
253
|
<path d="M21 12 H8" />
|
|
245
254
|
<path d="M21 19 H8" />
|
|
246
|
-
<path d="M3 12 V19"
|
|
247
|
-
<path d="M15 12 H3" />
|
|
248
|
-
<path d="M17 19 H3" />`,...t}));nw.displayName="TextAlignStartIcon";var CR=nw,rw=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M21 5 H3" />
|
|
255
|
+
<path d="M3 12 V19" />`,fillDuoSvg:'<g opacity="0.38"><path d="M17 5 H3" /><path d="M21 12 H8" /><path d="M21 19 H8" /></g><path d="M3 12 V19" />',...t}));ew.displayName="TextQuoteIcon";var tw=ew,nw=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M21 5 H3" />
|
|
249
256
|
<path d="M17 12 H7" />
|
|
250
|
-
<path d="M19 19 H5"
|
|
257
|
+
<path d="M19 19 H5" />`,fillDuoSvg:'<g opacity="0.38"><path d="M21 5 H3" /></g><path d="M17 12 H7" /><path d="M19 19 H5" />',...t}));nw.displayName="TextAlignCenterIcon";var C3=nw,rw=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M21 5 H3" />
|
|
251
258
|
<path d="M21 12 H9" />
|
|
252
|
-
<path d="M21 19 H7"
|
|
259
|
+
<path d="M21 19 H7" />`,fillDuoSvg:'<g opacity="0.38"><path d="M21 12 H9" /></g><path d="M21 5 H3" /><path d="M21 19 H7" />',...t}));rw.displayName="TextAlignEndIcon";var M3=rw,sw=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M21 5 H3" />
|
|
260
|
+
<path d="M15 12 H3" />
|
|
261
|
+
<path d="M17 19 H3" />`,fillDuoSvg:'<g opacity="0.38"><path d="M15 12 H3" /></g><path d="M21 5 H3" /><path d="M17 19 H3" />',...t}));sw.displayName="TextAlignStartIcon";var A3=sw,iw=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M12 21 V15" />
|
|
262
|
+
<path d="M12 9 V3" />
|
|
253
263
|
<path d="M3 15 H21" />
|
|
254
264
|
<path d="M3 9 H21" />
|
|
255
|
-
<rect width="18" height="18" x="3" y="3" rx="3.75"
|
|
256
|
-
<rect width="18" height="18" x="3" y="3" rx="3.75" />
|
|
257
|
-
<path d="M3 9 H21" />
|
|
258
|
-
<path d="M3 15 H21" />`,...t}));ow.displayName="TableIcon";var lw=ow,aw=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M12 21 V15" />
|
|
265
|
+
<rect width="18" height="18" x="3" y="3" rx="3.75" />`,outlineDuoSvg:`<g fill="currentColor" stroke="none" opacity="0.2"><rect width="18" height="18" x="3" y="3" rx="3.75" /></g><path d="M12 21 V15" />
|
|
259
266
|
<path d="M12 9 V3" />
|
|
260
267
|
<path d="M3 15 H21" />
|
|
261
268
|
<path d="M3 9 H21" />
|
|
262
|
-
<rect width="18" height="18" x="3" y="3" rx="3.75"
|
|
269
|
+
<rect width="18" height="18" x="3" y="3" rx="3.75" />`,fillSvg:'<defs><mask id="__MASK__"><rect width="24" height="24" fill="white" /><path d="M12 21 V15" fill="none" stroke="black" /><path d="M12 9 V3" fill="none" stroke="black" /><path d="M3 15 H21" fill="none" stroke="black" /><path d="M3 9 H21" fill="none" stroke="black" /></mask></defs><g fill="currentColor" mask="url(#__MASK__)"><rect width="18" height="18" x="3" y="3" rx="3.75" /></g>',fillDuoSvg:'<g fill="currentColor" stroke="currentColor" stroke-width="0.75" opacity="0.38"><rect width="18" height="18" x="3" y="3" rx="3.75" /></g><path d="M12 21 V15" /><path d="M12 9 V3" /><path d="M3 15 H21" /><path d="M3 9 H21" />',...t}));iw.displayName="TableCellsMergeIcon";var E3=iw,ow=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M12 15 V9" />
|
|
270
|
+
<path d="M3 15 H21" />
|
|
271
|
+
<path d="M3 9 H21" />
|
|
272
|
+
<rect width="18" height="18" x="3" y="3" rx="3.75" />`,outlineDuoSvg:`<g fill="currentColor" stroke="none" opacity="0.2"><rect width="18" height="18" x="3" y="3" rx="3.75" /></g><path d="M12 15 V9" />
|
|
273
|
+
<path d="M3 15 H21" />
|
|
274
|
+
<path d="M3 9 H21" />
|
|
275
|
+
<rect width="18" height="18" x="3" y="3" rx="3.75" />`,fillSvg:'<defs><mask id="__MASK__"><rect width="24" height="24" fill="white" /><path d="M12 15 V9" fill="none" stroke="black" /><path d="M3 15 H21" fill="none" stroke="black" /><path d="M3 9 H21" fill="none" stroke="black" /></mask></defs><g fill="currentColor" mask="url(#__MASK__)"><rect width="18" height="18" x="3" y="3" rx="3.75" /></g>',fillDuoSvg:'<g fill="currentColor" stroke="currentColor" stroke-width="0.75" opacity="0.38"><rect width="18" height="18" x="3" y="3" rx="3.75" /></g><path d="M12 15 V9" /><path d="M3 15 H21" /><path d="M3 9 H21" />',...t}));ow.displayName="TableCellsSplitIcon";var T3=ow,lw=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M12 3 V21" />
|
|
276
|
+
<rect width="18" height="18" x="3" y="3" rx="3.75" />
|
|
277
|
+
<path d="M3 9 H21" />
|
|
278
|
+
<path d="M3 15 H21" />`,outlineDuoSvg:`<g fill="currentColor" stroke="none" opacity="0.2"><rect width="18" height="18" x="3" y="3" rx="3.75" /></g><path d="M12 3 V21" />
|
|
279
|
+
<rect width="18" height="18" x="3" y="3" rx="3.75" />
|
|
280
|
+
<path d="M3 9 H21" />
|
|
281
|
+
<path d="M3 15 H21" />`,fillSvg:'<defs><mask id="__MASK__"><rect width="24" height="24" fill="white" /><path d="M12 3 V21" fill="none" stroke="black" /><path d="M3 9 H21" fill="none" stroke="black" /><path d="M3 15 H21" fill="none" stroke="black" /></mask></defs><g fill="currentColor" mask="url(#__MASK__)"><rect width="18" height="18" x="3" y="3" rx="3.75" /></g>',fillDuoSvg:'<g fill="currentColor" stroke="currentColor" stroke-width="0.75" opacity="0.38"><rect width="18" height="18" x="3" y="3" rx="3.75" /></g><path d="M12 3 V21" /><path d="M3 9 H21" /><path d="M3 15 H21" />',...t}));lw.displayName="TableIcon";var aw=lw,cw=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M16 4 H9 A3 3 0 0 0 6.17 8" />
|
|
263
282
|
<path d="M14 12 A4 4 0 0 1 14 20 H6" />
|
|
264
|
-
<line x1="4" x2="20" y1="12" y2="12"
|
|
265
|
-
<path d="M21 11 V6.5 A3.5 3.5 0 0 0 17.5 3 H6.5 A3.5 3.5 0 0 0 3 6.5 V17.5 A3.5 3.5 0 0 0 6.5 21 H11"
|
|
283
|
+
<line x1="4" x2="20" y1="12" y2="12" />`,fillDuoSvg:'<g opacity="0.38"><line x1="4" x2="20" y1="12" y2="12" /></g><path d="M16 4 H9 A3 3 0 0 0 6.17 8" /><path d="M14 12 A4 4 0 0 1 14 20 H6" />',...t}));cw.displayName="StrikethroughIcon";var uw=cw,dw=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:'<rect width="18" height="18" x="3" y="3" rx="3.75" />',outlineDuoSvg:'<g fill="currentColor" stroke="none" opacity="0.2"><rect width="18" height="18" x="3" y="3" rx="3.75" /></g><rect width="18" height="18" x="3" y="3" rx="3.75" />',fillSvg:'<g fill="currentColor"><rect width="18" height="18" x="3" y="3" rx="3.75" /></g>',fillDuoSvg:'<g fill="currentColor" stroke="currentColor" stroke-width="0.75" opacity="0.38"><rect width="18" height="18" x="3" y="3" rx="3.75" /></g>',...t}));dw.displayName="SquareIcon";var Xh=dw,hw=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M12.03 12.68 A0.5 0.5 0 0 1 12.68 12.03 L21.68 15.53 A0.5 0.5 0 0 1 21.65 16.48 L18.83 17.35 A2.25 2.25 0 0 0 17.35 18.83 L16.48 21.65 A0.5 0.5 0 0 1 15.53 21.68 Z" />
|
|
284
|
+
<path d="M21 11 V6.5 A3.5 3.5 0 0 0 17.5 3 H6.5 A3.5 3.5 0 0 0 3 6.5 V17.5 A3.5 3.5 0 0 0 6.5 21 H11" />`,outlineDuoSvg:`<g fill="currentColor" stroke="none" opacity="0.2"><path d="M12.03 12.68 A0.5 0.5 0 0 1 12.68 12.03 L21.68 15.53 A0.5 0.5 0 0 1 21.65 16.48 L18.83 17.35 A2.25 2.25 0 0 0 17.35 18.83 L16.48 21.65 A0.5 0.5 0 0 1 15.53 21.68 Z" /></g><path d="M12.03 12.68 A0.5 0.5 0 0 1 12.68 12.03 L21.68 15.53 A0.5 0.5 0 0 1 21.65 16.48 L18.83 17.35 A2.25 2.25 0 0 0 17.35 18.83 L16.48 21.65 A0.5 0.5 0 0 1 15.53 21.68 Z" />
|
|
285
|
+
<path d="M21 11 V6.5 A3.5 3.5 0 0 0 17.5 3 H6.5 A3.5 3.5 0 0 0 3 6.5 V17.5 A3.5 3.5 0 0 0 6.5 21 H11" />`,fillSvg:'<g fill="currentColor"><path d="M12.03 12.68 A0.5 0.5 0 0 1 12.68 12.03 L21.68 15.53 A0.5 0.5 0 0 1 21.65 16.48 L18.83 17.35 A2.25 2.25 0 0 0 17.35 18.83 L16.48 21.65 A0.5 0.5 0 0 1 15.53 21.68 Z" /></g><path d="M21 11 V6.5 A3.5 3.5 0 0 0 17.5 3 H6.5 A3.5 3.5 0 0 0 3 6.5 V17.5 A3.5 3.5 0 0 0 6.5 21 H11" />',fillDuoSvg:'<g fill="currentColor" stroke="currentColor" stroke-width="0.75" opacity="0.38"><path d="M12.03 12.68 A0.5 0.5 0 0 1 12.68 12.03 L21.68 15.53 A0.5 0.5 0 0 1 21.65 16.48 L18.83 17.35 A2.25 2.25 0 0 0 17.35 18.83 L16.48 21.65 A0.5 0.5 0 0 1 15.53 21.68 Z" /></g><path d="M21 11 V6.5 A3.5 3.5 0 0 0 17.5 3 H6.5 A3.5 3.5 0 0 0 3 6.5 V17.5 A3.5 3.5 0 0 0 6.5 21 H11" />',...t}));hw.displayName="SquareMousePointerIcon";var _3=hw,fw=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:'<path d="M11.02 2.81 A1 1 0 0 1 12.98 2.81 L13.84 7.37 A3.5 3.5 0 0 0 16.63 10.16 L21.19 11.02 A1 1 0 0 1 21.19 12.98 L16.63 13.84 A3.5 3.5 0 0 0 13.84 16.63 L12.98 21.19 A1 1 0 0 1 11.02 21.19 L10.16 16.63 A3.5 3.5 0 0 0 7.37 13.84 L2.81 12.98 A1 1 0 0 1 2.81 11.02 L7.37 10.16 A3.5 3.5 0 0 0 10.16 7.37 Z" />',outlineDuoSvg:'<g fill="currentColor" stroke="none" opacity="0.2"><path d="M11.02 2.81 A1 1 0 0 1 12.98 2.81 L13.84 7.37 A3.5 3.5 0 0 0 16.63 10.16 L21.19 11.02 A1 1 0 0 1 21.19 12.98 L16.63 13.84 A3.5 3.5 0 0 0 13.84 16.63 L12.98 21.19 A1 1 0 0 1 11.02 21.19 L10.16 16.63 A3.5 3.5 0 0 0 7.37 13.84 L2.81 12.98 A1 1 0 0 1 2.81 11.02 L7.37 10.16 A3.5 3.5 0 0 0 10.16 7.37 Z" /></g><path d="M11.02 2.81 A1 1 0 0 1 12.98 2.81 L13.84 7.37 A3.5 3.5 0 0 0 16.63 10.16 L21.19 11.02 A1 1 0 0 1 21.19 12.98 L16.63 13.84 A3.5 3.5 0 0 0 13.84 16.63 L12.98 21.19 A1 1 0 0 1 11.02 21.19 L10.16 16.63 A3.5 3.5 0 0 0 7.37 13.84 L2.81 12.98 A1 1 0 0 1 2.81 11.02 L7.37 10.16 A3.5 3.5 0 0 0 10.16 7.37 Z" />',fillSvg:'<g fill="currentColor"><path d="M11.02 2.81 A1 1 0 0 1 12.98 2.81 L13.84 7.37 A3.5 3.5 0 0 0 16.63 10.16 L21.19 11.02 A1 1 0 0 1 21.19 12.98 L16.63 13.84 A3.5 3.5 0 0 0 13.84 16.63 L12.98 21.19 A1 1 0 0 1 11.02 21.19 L10.16 16.63 A3.5 3.5 0 0 0 7.37 13.84 L2.81 12.98 A1 1 0 0 1 2.81 11.02 L7.37 10.16 A3.5 3.5 0 0 0 10.16 7.37 Z" /></g>',fillDuoSvg:'<g fill="currentColor" stroke="currentColor" stroke-width="0.75" opacity="0.38"><path d="M11.02 2.81 A1 1 0 0 1 12.98 2.81 L13.84 7.37 A3.5 3.5 0 0 0 16.63 10.16 L21.19 11.02 A1 1 0 0 1 21.19 12.98 L16.63 13.84 A3.5 3.5 0 0 0 13.84 16.63 L12.98 21.19 A1 1 0 0 1 11.02 21.19 L10.16 16.63 A3.5 3.5 0 0 0 7.37 13.84 L2.81 12.98 A1 1 0 0 1 2.81 11.02 L7.37 10.16 A3.5 3.5 0 0 0 10.16 7.37 Z" /></g>',...t}));fw.displayName="SparkleIcon";var N3=fw,pw=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<rect width="18" height="18" x="3" y="3" rx="3.75" />
|
|
266
286
|
<path d="M21 9 H3" />
|
|
267
|
-
<path d="M21 15 H3"
|
|
287
|
+
<path d="M21 15 H3" />`,outlineDuoSvg:`<g fill="currentColor" stroke="none" opacity="0.2"><rect width="18" height="18" x="3" y="3" rx="3.75" /></g><rect width="18" height="18" x="3" y="3" rx="3.75" />
|
|
288
|
+
<path d="M21 9 H3" />
|
|
289
|
+
<path d="M21 15 H3" />`,fillSvg:'<defs><mask id="__MASK__"><rect width="24" height="24" fill="white" /><path d="M21 9 H3" fill="none" stroke="black" /><path d="M21 15 H3" fill="none" stroke="black" /></mask></defs><g fill="currentColor" mask="url(#__MASK__)"><rect width="18" height="18" x="3" y="3" rx="3.75" /></g>',fillDuoSvg:'<g fill="currentColor" stroke="currentColor" stroke-width="0.75" opacity="0.38"><rect width="18" height="18" x="3" y="3" rx="3.75" /></g><path d="M21 9 H3" /><path d="M21 15 H3" />',...t}));pw.displayName="Rows3Icon";var O3=pw,mw=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M3 12 A9 9 0 0 1 12 3 A9.75 9.75 0 0 1 18.74 5.74 L21 8" />
|
|
268
290
|
<path d="M21 3 V8 H16" />
|
|
269
291
|
<path d="M21 12 A9 9 0 0 1 12 21 A9.75 9.75 0 0 1 5.26 18.26 L3 16" />
|
|
270
|
-
<path d="M8 16 H3 V21"
|
|
292
|
+
<path d="M8 16 H3 V21" />`,fillDuoSvg:'<g opacity="0.38"><path d="M3 12 A9 9 0 0 1 12 3 A9.75 9.75 0 0 1 18.74 5.74 L21 8" /><path d="M21 12 A9 9 0 0 1 12 21 A9.75 9.75 0 0 1 5.26 18.26 L3 16" /></g><path d="M21 3 V8 H16" /><path d="M8 16 H3 V21" />',...t}));mw.displayName="RefreshCwIcon";var Zh=mw,gw=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M4 7 V5.26 A1.26 1.26 0 0 1 5.26 4 H18.74 A1.26 1.26 0 0 1 20 5.26 V7" />
|
|
271
293
|
<path d="M5 20 H11" />
|
|
272
294
|
<path d="M13 4 L8 20" />
|
|
273
295
|
<path d="M15 15 L20 20" />
|
|
274
|
-
<path d="M20 15 L15 20"
|
|
275
|
-
<path d="M12 5 V19"
|
|
296
|
+
<path d="M20 15 L15 20" />`,fillDuoSvg:'<g opacity="0.38"><path d="M5 20 H11" /><path d="M13 4 L8 20" /><path d="M15 15 L20 20" /><path d="M20 15 L15 20" /></g><path d="M4 7 V5.26 A1.26 1.26 0 0 1 5.26 4 H18.74 A1.26 1.26 0 0 1 20 5.26 V7" />',...t}));gw.displayName="RemoveFormattingIcon";var I3=gw,yw=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:'<rect width="20" height="12" x="2" y="6" rx="3.25" />',outlineDuoSvg:'<g fill="currentColor" stroke="none" opacity="0.2"><rect width="20" height="12" x="2" y="6" rx="3.25" /></g><rect width="20" height="12" x="2" y="6" rx="3.25" />',fillSvg:'<g fill="currentColor"><rect width="20" height="12" x="2" y="6" rx="3.25" /></g>',fillDuoSvg:'<g fill="currentColor" stroke="currentColor" stroke-width="0.75" opacity="0.38"><rect width="20" height="12" x="2" y="6" rx="3.25" /></g>',...t}));yw.displayName="RectangleHorizontalIcon";var Qh=yw,bw=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M5 12 H19" />
|
|
297
|
+
<path d="M12 5 V19" />`,fillDuoSvg:'<g opacity="0.38"><path d="M12 5 V19" /></g><path d="M5 12 H19" />',...t}));bw.displayName="PlusIcon";var ms=bw,ww=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M13 4 V20" />
|
|
276
298
|
<path d="M17 4 V20" />
|
|
277
|
-
<path d="M19 4 H9.5 A4.5 4.5 0 0 0 9.5 13 H13"
|
|
278
|
-
<path d="M3 9 H21"
|
|
299
|
+
<path d="M19 4 H9.5 A4.5 4.5 0 0 0 9.5 13 H13" />`,fillDuoSvg:'<g opacity="0.38"><path d="M13 4 V20" /><path d="M17 4 V20" /></g><path d="M19 4 H9.5 A4.5 4.5 0 0 0 9.5 13 H13" />',...t}));ww.displayName="PilcrowIcon";var bd=ww,xw=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<rect width="18" height="18" x="3" y="3" rx="3.75" />
|
|
300
|
+
<path d="M3 9 H21" />`,outlineDuoSvg:`<g fill="currentColor" stroke="none" opacity="0.2"><rect width="18" height="18" x="3" y="3" rx="3.75" /></g><rect width="18" height="18" x="3" y="3" rx="3.75" />
|
|
301
|
+
<path d="M3 9 H21" />`,fillSvg:'<defs><mask id="__MASK__"><rect width="24" height="24" fill="white" /><path d="M3 9 H21" fill="none" stroke="black" /></mask></defs><g fill="currentColor" mask="url(#__MASK__)"><rect width="18" height="18" x="3" y="3" rx="3.75" /></g>',fillDuoSvg:'<g fill="currentColor" stroke="currentColor" stroke-width="0.75" opacity="0.38"><rect width="18" height="18" x="3" y="3" rx="3.75" /></g><path d="M3 9 H21" />',...t}));xw.displayName="PanelTopIcon";var D3=xw,vw=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M12 22 A1 1 0 0 1 12 2 A10 9 0 0 1 22 11 A5 5 0 0 1 17 16 H14.75 A1.75 1.75 0 0 0 13.35 18.8 L13.65 19.2 A1.75 1.75 0 0 1 12.25 22 Z" />
|
|
302
|
+
<circle cx="13.5" cy="6.5" r=".5" fill="currentColor" />
|
|
303
|
+
<circle cx="17.5" cy="10.5" r=".5" fill="currentColor" />
|
|
304
|
+
<circle cx="6.5" cy="12.5" r=".5" fill="currentColor" />
|
|
305
|
+
<circle cx="8.5" cy="7.5" r=".5" fill="currentColor" />`,outlineDuoSvg:`<g fill="currentColor" stroke="none" opacity="0.2"><path d="M12 22 A1 1 0 0 1 12 2 A10 9 0 0 1 22 11 A5 5 0 0 1 17 16 H14.75 A1.75 1.75 0 0 0 13.35 18.8 L13.65 19.2 A1.75 1.75 0 0 1 12.25 22 Z" /></g><path d="M12 22 A1 1 0 0 1 12 2 A10 9 0 0 1 22 11 A5 5 0 0 1 17 16 H14.75 A1.75 1.75 0 0 0 13.35 18.8 L13.65 19.2 A1.75 1.75 0 0 1 12.25 22 Z" />
|
|
279
306
|
<circle cx="13.5" cy="6.5" r=".5" fill="currentColor" />
|
|
280
307
|
<circle cx="17.5" cy="10.5" r=".5" fill="currentColor" />
|
|
281
308
|
<circle cx="6.5" cy="12.5" r=".5" fill="currentColor" />
|
|
282
|
-
<circle cx="8.5" cy="7.5" r=".5" fill="currentColor"
|
|
309
|
+
<circle cx="8.5" cy="7.5" r=".5" fill="currentColor" />`,fillSvg:'<defs><mask id="__MASK__"><rect width="24" height="24" fill="white" /><circle cx="13.5" cy="6.5" r=".5" fill="black" stroke="black" /><circle cx="17.5" cy="10.5" r=".5" fill="black" stroke="black" /><circle cx="6.5" cy="12.5" r=".5" fill="black" stroke="black" /><circle cx="8.5" cy="7.5" r=".5" fill="black" stroke="black" /></mask></defs><g fill="currentColor" mask="url(#__MASK__)"><path d="M12 22 A1 1 0 0 1 12 2 A10 9 0 0 1 22 11 A5 5 0 0 1 17 16 H14.75 A1.75 1.75 0 0 0 13.35 18.8 L13.65 19.2 A1.75 1.75 0 0 1 12.25 22 Z" /></g>',fillDuoSvg:'<g fill="currentColor" stroke="currentColor" stroke-width="0.75" opacity="0.38"><path d="M12 22 A1 1 0 0 1 12 2 A10 9 0 0 1 22 11 A5 5 0 0 1 17 16 H14.75 A1.75 1.75 0 0 0 13.35 18.8 L13.65 19.2 A1.75 1.75 0 0 1 12.25 22 Z" /></g><circle cx="13.5" cy="6.5" r=".5" fill="currentColor" /><circle cx="17.5" cy="10.5" r=".5" fill="currentColor" /><circle cx="6.5" cy="12.5" r=".5" fill="currentColor" /><circle cx="8.5" cy="7.5" r=".5" fill="currentColor" />',...t}));vw.displayName="PaletteIcon";var kw=vw,Sw=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M10.26 21.31 A3.5 3.5 0 0 0 13.74 21.31 L19.24 18.17 A3.5 3.5 0 0 0 21 15.13 V8.87 A3.5 3.5 0 0 0 19.24 5.83 L13.74 2.69 A3.5 3.5 0 0 0 10.26 2.69 L4.76 5.83 A3.5 3.5 0 0 0 3 8.87 V15.13 A3.5 3.5 0 0 0 4.76 18.17 Z" />
|
|
310
|
+
<path d="M12 22 V12" />
|
|
311
|
+
<path d="M3.29 7 L12 12 L20.71 7" />
|
|
312
|
+
<path d="M7.5 4.27 L16.5 9.42" />`,outlineDuoSvg:`<g fill="currentColor" stroke="none" opacity="0.2"><path d="M10.26 21.31 A3.5 3.5 0 0 0 13.74 21.31 L19.24 18.17 A3.5 3.5 0 0 0 21 15.13 V8.87 A3.5 3.5 0 0 0 19.24 5.83 L13.74 2.69 A3.5 3.5 0 0 0 10.26 2.69 L4.76 5.83 A3.5 3.5 0 0 0 3 8.87 V15.13 A3.5 3.5 0 0 0 4.76 18.17 Z" /></g><path d="M10.26 21.31 A3.5 3.5 0 0 0 13.74 21.31 L19.24 18.17 A3.5 3.5 0 0 0 21 15.13 V8.87 A3.5 3.5 0 0 0 19.24 5.83 L13.74 2.69 A3.5 3.5 0 0 0 10.26 2.69 L4.76 5.83 A3.5 3.5 0 0 0 3 8.87 V15.13 A3.5 3.5 0 0 0 4.76 18.17 Z" />
|
|
283
313
|
<path d="M12 22 V12" />
|
|
284
314
|
<path d="M3.29 7 L12 12 L20.71 7" />
|
|
285
|
-
<path d="M7.5 4.27 L16.5 9.42"
|
|
315
|
+
<path d="M7.5 4.27 L16.5 9.42" />`,fillSvg:'<defs><mask id="__MASK__"><rect width="24" height="24" fill="white" /><path d="M12 22 V12" fill="none" stroke="black" /><path d="M3.29 7 L12 12 L20.71 7" fill="none" stroke="black" /><path d="M7.5 4.27 L16.5 9.42" fill="none" stroke="black" /></mask></defs><g fill="currentColor" mask="url(#__MASK__)"><path d="M10.26 21.31 A3.5 3.5 0 0 0 13.74 21.31 L19.24 18.17 A3.5 3.5 0 0 0 21 15.13 V8.87 A3.5 3.5 0 0 0 19.24 5.83 L13.74 2.69 A3.5 3.5 0 0 0 10.26 2.69 L4.76 5.83 A3.5 3.5 0 0 0 3 8.87 V15.13 A3.5 3.5 0 0 0 4.76 18.17 Z" /></g>',fillDuoSvg:'<g fill="currentColor" stroke="currentColor" stroke-width="0.75" opacity="0.38"><path d="M10.26 21.31 A3.5 3.5 0 0 0 13.74 21.31 L19.24 18.17 A3.5 3.5 0 0 0 21 15.13 V8.87 A3.5 3.5 0 0 0 19.24 5.83 L13.74 2.69 A3.5 3.5 0 0 0 10.26 2.69 L4.76 5.83 A3.5 3.5 0 0 0 3 8.87 V15.13 A3.5 3.5 0 0 0 4.76 18.17 Z" /></g><path d="M12 22 V12" /><path d="M3.29 7 L12 12 L20.71 7" /><path d="M7.5 4.27 L16.5 9.42" />',...t}));Sw.displayName="PackageIcon";var Cw=Sw,Mw=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:'<path d="M5 12 H19" />',...t}));Mw.displayName="MinusIcon";var wd=Mw,Aw=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M8 3 H6.5 A3.5 3.5 0 0 0 3 6.5 V8" />
|
|
286
316
|
<path d="M21 8 V6.5 A3.5 3.5 0 0 0 17.5 3 H16" />
|
|
287
317
|
<path d="M3 16 V17.5 A3.5 3.5 0 0 0 6.5 21 H8" />
|
|
288
|
-
<path d="M16 21 H17.5 A3.5 3.5 0 0 0 21 17.5 V16"
|
|
318
|
+
<path d="M16 21 H17.5 A3.5 3.5 0 0 0 21 17.5 V16" />`,fillDuoSvg:'<g opacity="0.38"><path d="M21 8 V6.5 A3.5 3.5 0 0 0 17.5 3 H16" /><path d="M16 21 H17.5 A3.5 3.5 0 0 0 21 17.5 V16" /></g><path d="M8 3 H6.5 A3.5 3.5 0 0 0 3 6.5 V8" /><path d="M3 16 V17.5 A3.5 3.5 0 0 0 6.5 21 H8" />',...t}));Aw.displayName="MaximizeIcon";var ef=Aw,Ew=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M3 5 H3.01" />
|
|
289
319
|
<path d="M3 12 H3.01" />
|
|
290
320
|
<path d="M3 19 H3.01" />
|
|
291
321
|
<path d="M8 5 H21" />
|
|
292
322
|
<path d="M8 12 H21" />
|
|
293
|
-
<path d="M8 19 H21"
|
|
323
|
+
<path d="M8 19 H21" />`,fillDuoSvg:'<g opacity="0.38"><path d="M8 5 H21" /><path d="M8 12 H21" /><path d="M8 19 H21" /></g><path d="M3 5 H3.01" /><path d="M3 12 H3.01" /><path d="M3 19 H3.01" />',...t}));Ew.displayName="ListIcon";var ga=Ew,Tw=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M11 5 H21" />
|
|
294
324
|
<path d="M11 12 H21" />
|
|
295
325
|
<path d="M11 19 H21" />
|
|
296
326
|
<path d="M4 4 H4.58 A0.42 0.42 0 0 1 5 4.42 V9" />
|
|
297
327
|
<path d="M4 9 H6" />
|
|
298
|
-
<path d="M6.5 20 H3.4 C3.4 19 6 18.07 6 16.5 A1.5 1.5 0 0 0 3.4 15.48"
|
|
328
|
+
<path d="M6.5 20 H3.4 C3.4 19 6 18.07 6 16.5 A1.5 1.5 0 0 0 3.4 15.48" />`,fillDuoSvg:'<g opacity="0.38"><path d="M11 5 H21" /><path d="M11 12 H21" /><path d="M11 19 H21" /><path d="M4 9 H6" /></g><path d="M4 4 H4.58 A0.42 0.42 0 0 1 5 4.42 V9" /><path d="M6.5 20 H3.4 C3.4 19 6 18.07 6 16.5 A1.5 1.5 0 0 0 3.4 15.48" />',...t}));Tw.displayName="ListNumbersIcon";var qm=Tw,_w=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M11 5 H21" />
|
|
299
329
|
<path d="M11 12 H21" />
|
|
300
330
|
<path d="M11 19 H21" />
|
|
301
331
|
<path d="M4 4 H4.58 A0.42 0.42 0 0 1 5 4.42 V9" />
|
|
302
332
|
<path d="M4 9 H6" />
|
|
303
|
-
<path d="M6.5 20 H3.4 C3.4 19 6 18.07 6 16.5 A1.5 1.5 0 0 0 3.4 15.48"
|
|
333
|
+
<path d="M6.5 20 H3.4 C3.4 19 6 18.07 6 16.5 A1.5 1.5 0 0 0 3.4 15.48" />`,fillDuoSvg:'<g opacity="0.38"><path d="M11 5 H21" /><path d="M11 12 H21" /><path d="M11 19 H21" /><path d="M4 9 H6" /></g><path d="M4 4 H4.58 A0.42 0.42 0 0 1 5 4.42 V9" /><path d="M6.5 20 H3.4 C3.4 19 6 18.07 6 16.5 A1.5 1.5 0 0 0 3.4 15.48" />',...t}));_w.displayName="ListOrderedIcon";var Nw=_w,Ow=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M10 5 H21" />
|
|
304
334
|
<path d="M10 12 H21" />
|
|
305
335
|
<path d="M10 19 H21" />
|
|
306
336
|
<path d="M3 10 L4.74 8.26 A1.78 1.78 0 0 0 4.74 5.74 L3 4" />
|
|
307
|
-
<path d="M3 20 L4.74 18.26 A1.78 1.78 0 0 0 4.74 15.74 L3 14"
|
|
308
|
-
<path d="M14 11 A5 5 0 0 0 6.46 10.46 L3.46 13.46 A5 5 0 0 0 10.53 20.53 L12.24 18.82"
|
|
337
|
+
<path d="M3 20 L4.74 18.26 A1.78 1.78 0 0 0 4.74 15.74 L3 14" />`,fillDuoSvg:'<g opacity="0.38"><path d="M10 5 H21" /><path d="M10 12 H21" /><path d="M10 19 H21" /></g><path d="M3 10 L4.74 8.26 A1.78 1.78 0 0 0 4.74 5.74 L3 4" /><path d="M3 20 L4.74 18.26 A1.78 1.78 0 0 0 4.74 15.74 L3 14" />',...t}));Ow.displayName="ListCollapseIcon";var R3=Ow,Iw=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M10 13 A5 5 0 0 0 17.54 13.54 L20.54 10.54 A5 5 0 0 0 13.47 3.47 L11.75 5.18" />
|
|
338
|
+
<path d="M14 11 A5 5 0 0 0 6.46 10.46 L3.46 13.46 A5 5 0 0 0 10.53 20.53 L12.24 18.82" />`,fillDuoSvg:'<g opacity="0.38"><path d="M14 11 A5 5 0 0 0 6.46 10.46 L3.46 13.46 A5 5 0 0 0 10.53 20.53 L12.24 18.82" /></g><path d="M10 13 A5 5 0 0 0 17.54 13.54 L20.54 10.54 A5 5 0 0 0 13.47 3.47 L11.75 5.18" />',...t}));Iw.displayName="LinkIcon";var xd=Iw,Dw=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M13.45 2.46 A3.5 3.5 0 0 0 10.55 2.46 L2.6 6.08 A1 1 0 0 0 2.6 7.91 L10.56 11.54 A3.5 3.5 0 0 0 13.46 11.54 L21.42 7.92 A1 1 0 0 0 21.42 6.09 Z" />
|
|
309
339
|
<path d="M2 12 A1 1 0 0 0 2.58 12.91 L10.56 16.54 A3.5 3.5 0 0 0 13.45 16.54 L21.41 12.92 A1 1 0 0 0 22 12" />
|
|
310
|
-
<path d="M2 17 A1 1 0 0 0 2.58 17.91 L10.56 21.54 A3.5 3.5 0 0 0 13.45 21.54 L21.41 17.92 A1 1 0 0 0 22 17"
|
|
340
|
+
<path d="M2 17 A1 1 0 0 0 2.58 17.91 L10.56 21.54 A3.5 3.5 0 0 0 13.45 21.54 L21.41 17.92 A1 1 0 0 0 22 17" />`,outlineDuoSvg:`<g fill="currentColor" stroke="none" opacity="0.2"><path d="M13.45 2.46 A3.5 3.5 0 0 0 10.55 2.46 L2.6 6.08 A1 1 0 0 0 2.6 7.91 L10.56 11.54 A3.5 3.5 0 0 0 13.46 11.54 L21.42 7.92 A1 1 0 0 0 21.42 6.09 Z" /></g><path d="M13.45 2.46 A3.5 3.5 0 0 0 10.55 2.46 L2.6 6.08 A1 1 0 0 0 2.6 7.91 L10.56 11.54 A3.5 3.5 0 0 0 13.46 11.54 L21.42 7.92 A1 1 0 0 0 21.42 6.09 Z" />
|
|
341
|
+
<path d="M2 12 A1 1 0 0 0 2.58 12.91 L10.56 16.54 A3.5 3.5 0 0 0 13.45 16.54 L21.41 12.92 A1 1 0 0 0 22 12" />
|
|
342
|
+
<path d="M2 17 A1 1 0 0 0 2.58 17.91 L10.56 21.54 A3.5 3.5 0 0 0 13.45 21.54 L21.41 17.92 A1 1 0 0 0 22 17" />`,fillSvg:'<g fill="currentColor"><path d="M13.45 2.46 A3.5 3.5 0 0 0 10.55 2.46 L2.6 6.08 A1 1 0 0 0 2.6 7.91 L10.56 11.54 A3.5 3.5 0 0 0 13.46 11.54 L21.42 7.92 A1 1 0 0 0 21.42 6.09 Z" /></g><path d="M2 12 A1 1 0 0 0 2.58 12.91 L10.56 16.54 A3.5 3.5 0 0 0 13.45 16.54 L21.41 12.92 A1 1 0 0 0 22 12" /><path d="M2 17 A1 1 0 0 0 2.58 17.91 L10.56 21.54 A3.5 3.5 0 0 0 13.45 21.54 L21.41 17.92 A1 1 0 0 0 22 17" />',fillDuoSvg:'<g fill="currentColor" stroke="currentColor" stroke-width="0.75" opacity="0.38"><path d="M13.45 2.46 A3.5 3.5 0 0 0 10.55 2.46 L2.6 6.08 A1 1 0 0 0 2.6 7.91 L10.56 11.54 A3.5 3.5 0 0 0 13.46 11.54 L21.42 7.92 A1 1 0 0 0 21.42 6.09 Z" /></g><path d="M2 12 A1 1 0 0 0 2.58 12.91 L10.56 16.54 A3.5 3.5 0 0 0 13.45 16.54 L21.41 12.92 A1 1 0 0 0 22 12" /><path d="M2 17 A1 1 0 0 0 2.58 17.91 L10.56 21.54 A3.5 3.5 0 0 0 13.45 21.54 L21.41 17.92 A1 1 0 0 0 22 17" />',...t}));Dw.displayName="LayersIcon";var Rw=Dw,Lw=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M3 8 L5.69 10.69 A1.85 1.85 0 0 1 5.69 13.31 L3 16" />
|
|
343
|
+
<line x1="21" y1="12" x2="11" y2="12" />
|
|
344
|
+
<line x1="21" y1="6" x2="11" y2="6" />
|
|
345
|
+
<line x1="21" y1="18" x2="11" y2="18" />`,fillDuoSvg:'<g opacity="0.38"><line x1="21" y1="12" x2="11" y2="12" /><line x1="21" y1="6" x2="11" y2="6" /><line x1="21" y1="18" x2="11" y2="18" /></g><path d="M3 8 L5.69 10.69 A1.85 1.85 0 0 1 5.69 13.31 L3 16" />',...t}));Lw.displayName="IndentIncreaseIcon";var L3=Lw,jw=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<circle cx="12" cy="12" r="10" />
|
|
311
346
|
<path d="M12 16 V12" />
|
|
312
|
-
<path d="M12 8 H12.01"
|
|
347
|
+
<path d="M12 8 H12.01" />`,outlineDuoSvg:`<g fill="currentColor" stroke="none" opacity="0.2"><circle cx="12" cy="12" r="10" /></g><circle cx="12" cy="12" r="10" />
|
|
348
|
+
<path d="M12 16 V12" />
|
|
349
|
+
<path d="M12 8 H12.01" />`,fillSvg:'<defs><mask id="__MASK__"><rect width="24" height="24" fill="white" /><path d="M12 16 V12" fill="none" stroke="black" /><path d="M12 8 H12.01" fill="none" stroke="black" /></mask></defs><g fill="currentColor" mask="url(#__MASK__)"><circle cx="12" cy="12" r="10" /></g>',fillDuoSvg:'<g fill="currentColor" stroke="currentColor" stroke-width="0.75" opacity="0.38"><circle cx="12" cy="12" r="10" /></g><path d="M12 16 V12" /><path d="M12 8 H12.01" />',...t}));jw.displayName="InfoIcon";var j3=jw,Pw=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<line x1="19" x2="10" y1="4" y2="4" />
|
|
313
350
|
<line x1="14" x2="5" y1="20" y2="20" />
|
|
314
|
-
<line x1="15" x2="9" y1="4" y2="20"
|
|
351
|
+
<line x1="15" x2="9" y1="4" y2="20" />`,fillDuoSvg:'<g opacity="0.38"><line x1="15" x2="9" y1="4" y2="20" /></g><line x1="19" x2="10" y1="4" y2="4" /><line x1="14" x2="5" y1="20" y2="20" />',...t}));Pw.displayName="ItalicIcon";var vd=Pw,Bw=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M22 11 L21.47 10.47 A3.5 3.5 0 0 0 16.53 10.47 L11 16" />
|
|
315
352
|
<path d="M4 8 A2 2 0 0 0 2 10 V18.5 A3.5 3.5 0 0 0 5.5 22 H14 A2 2 0 0 0 16 20" />
|
|
316
353
|
<circle cx="13" cy="7" r="1" fill="currentColor" />
|
|
317
|
-
<rect x="8" y="2" width="14" height="14" rx="3"
|
|
318
|
-
<
|
|
319
|
-
<
|
|
320
|
-
<
|
|
354
|
+
<rect x="8" y="2" width="14" height="14" rx="3" />`,outlineDuoSvg:`<g fill="currentColor" stroke="none" opacity="0.2"><rect x="8" y="2" width="14" height="14" rx="3" /></g><path d="M22 11 L21.47 10.47 A3.5 3.5 0 0 0 16.53 10.47 L11 16" />
|
|
355
|
+
<path d="M4 8 A2 2 0 0 0 2 10 V18.5 A3.5 3.5 0 0 0 5.5 22 H14 A2 2 0 0 0 16 20" />
|
|
356
|
+
<circle cx="13" cy="7" r="1" fill="currentColor" />
|
|
357
|
+
<rect x="8" y="2" width="14" height="14" rx="3" />`,fillSvg:'<defs><mask id="__MASK__"><rect width="24" height="24" fill="white" /><path d="M22 11 L21.47 10.47 A3.5 3.5 0 0 0 16.53 10.47 L11 16" fill="none" stroke="black" /><circle cx="13" cy="7" r="1" fill="black" stroke="black" /></mask></defs><g fill="currentColor" mask="url(#__MASK__)"><rect x="8" y="2" width="14" height="14" rx="3" /></g><path d="M4 8 A2 2 0 0 0 2 10 V18.5 A3.5 3.5 0 0 0 5.5 22 H14 A2 2 0 0 0 16 20" />',fillDuoSvg:'<g fill="currentColor" stroke="currentColor" stroke-width="0.75" opacity="0.38"><rect x="8" y="2" width="14" height="14" rx="3" /></g><path d="M22 11 L21.47 10.47 A3.5 3.5 0 0 0 16.53 10.47 L11 16" /><circle cx="13" cy="7" r="1" fill="currentColor" /><path d="M4 8 A2 2 0 0 0 2 10 V18.5 A3.5 3.5 0 0 0 5.5 22 H14 A2 2 0 0 0 16 20" />',...t}));Bw.displayName="ImagesIcon";var P3=Bw,Hw=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M7 8 L4.31 10.69 A1.85 1.85 0 0 0 4.31 13.31 L7 16" />
|
|
321
358
|
<line x1="21" y1="12" x2="11" y2="12" />
|
|
322
359
|
<line x1="21" y1="6" x2="11" y2="6" />
|
|
323
|
-
<line x1="21" y1="18" x2="11" y2="18"
|
|
360
|
+
<line x1="21" y1="18" x2="11" y2="18" />`,fillDuoSvg:'<g opacity="0.38"><line x1="21" y1="12" x2="11" y2="12" /><line x1="21" y1="6" x2="11" y2="6" /><line x1="21" y1="18" x2="11" y2="18" /></g><path d="M7 8 L4.31 10.69 A1.85 1.85 0 0 0 4.31 13.31 L7 16" />',...t}));Hw.displayName="IndentDecreaseIcon";var B3=Hw,zw=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<rect width="18" height="18" x="3" y="3" rx="3" />
|
|
361
|
+
<circle cx="9" cy="9" r="2" />
|
|
362
|
+
<path d="M21 15 L18.97 12.97 A3.5 3.5 0 0 0 14.03 12.97 L6 21" />`,outlineDuoSvg:`<defs><mask id="__MASK__"><rect width="24" height="24" fill="white" /><circle cx="9" cy="9" r="2" fill="black" stroke="none" /></mask></defs><g fill="currentColor" stroke="none" opacity="0.2" mask="url(#__MASK__)"><rect width="18" height="18" x="3" y="3" rx="3" /></g><rect width="18" height="18" x="3" y="3" rx="3" />
|
|
324
363
|
<circle cx="9" cy="9" r="2" />
|
|
325
|
-
<path d="M21 15 L18.97 12.97 A3.5 3.5 0 0 0 14.03 12.97 L6 21"
|
|
364
|
+
<path d="M21 15 L18.97 12.97 A3.5 3.5 0 0 0 14.03 12.97 L6 21" />`,fillSvg:'<defs><mask id="__MASK__"><rect width="24" height="24" fill="white" /><path d="M21 15 L18.97 12.97 A3.5 3.5 0 0 0 14.03 12.97 L6 21" fill="none" stroke="black" /><circle cx="9" cy="9" r="2" fill="black" stroke="none" /></mask></defs><g fill="currentColor" mask="url(#__MASK__)"><rect width="18" height="18" x="3" y="3" rx="3" /></g>',fillDuoSvg:'<defs><mask id="__MASK__"><rect width="24" height="24" fill="white" /><circle cx="9" cy="9" r="2" fill="black" stroke="none" /></mask></defs><g fill="currentColor" stroke="currentColor" stroke-width="0.75" opacity="0.38" mask="url(#__MASK__)"><rect width="18" height="18" x="3" y="3" rx="3" /></g><circle cx="9" cy="9" r="2" /><path d="M21 15 L18.97 12.97 A3.5 3.5 0 0 0 14.03 12.97 L6 21" />',...t}));zw.displayName="ImageIcon";var H3=zw,$w=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M16 5 H22" />
|
|
365
|
+
<path d="M19 2 V8" />
|
|
366
|
+
<path d="M21 11.5 V17.5 A3.5 3.5 0 0 1 17.5 21 H5.85 A2.85 2.85 0 0 1 3 18.15 V6.5 A3.5 3.5 0 0 1 6.5 3 H12.5" />
|
|
367
|
+
<path d="M21 15 L18.97 12.97 A3.5 3.5 0 0 0 14.03 12.97 L6 21" />
|
|
368
|
+
<circle cx="9" cy="9" r="2" />`,outlineDuoSvg:`<g fill="currentColor" stroke="none" opacity="0.2"><circle cx="9" cy="9" r="2" /></g><path d="M16 5 H22" />
|
|
326
369
|
<path d="M19 2 V8" />
|
|
327
370
|
<path d="M21 11.5 V17.5 A3.5 3.5 0 0 1 17.5 21 H5.85 A2.85 2.85 0 0 1 3 18.15 V6.5 A3.5 3.5 0 0 1 6.5 3 H12.5" />
|
|
328
371
|
<path d="M21 15 L18.97 12.97 A3.5 3.5 0 0 0 14.03 12.97 L6 21" />
|
|
329
|
-
<circle cx="9" cy="9" r="2"
|
|
372
|
+
<circle cx="9" cy="9" r="2" />`,fillSvg:'<g fill="currentColor"><circle cx="9" cy="9" r="2" /></g><path d="M16 5 H22" /><path d="M19 2 V8" /><path d="M21 11.5 V17.5 A3.5 3.5 0 0 1 17.5 21 H5.85 A2.85 2.85 0 0 1 3 18.15 V6.5 A3.5 3.5 0 0 1 6.5 3 H12.5" /><path d="M21 15 L18.97 12.97 A3.5 3.5 0 0 0 14.03 12.97 L6 21" />',fillDuoSvg:'<g fill="currentColor" stroke="currentColor" stroke-width="0.75" opacity="0.38"><circle cx="9" cy="9" r="2" /></g><path d="M16 5 H22" /><path d="M19 2 V8" /><path d="M21 11.5 V17.5 A3.5 3.5 0 0 1 17.5 21 H5.85 A2.85 2.85 0 0 1 3 18.15 V6.5 A3.5 3.5 0 0 1 6.5 3 H12.5" /><path d="M21 15 L18.97 12.97 A3.5 3.5 0 0 0 14.03 12.97 L6 21" />',...t}));$w.displayName="ImagePlusIcon";var kd=$w,Vw=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M4 12 H12" />
|
|
330
373
|
<path d="M4 18 V6" />
|
|
331
374
|
<path d="M12 18 V6" />
|
|
332
375
|
<path d="M17.5 10.5 C19.2 9.5 21 10.5 21 12 A2 2 0 0 1 19 14" />
|
|
333
|
-
<path d="M17 17.5 C19 19 21 17.8 21 16 A2 2 0 0 0 19 14"
|
|
376
|
+
<path d="M17 17.5 C19 19 21 17.8 21 16 A2 2 0 0 0 19 14" />`,fillDuoSvg:'<g opacity="0.38"><path d="M4 12 H12" /><path d="M4 18 V6" /><path d="M12 18 V6" /></g><path d="M17.5 10.5 C19.2 9.5 21 10.5 21 12 A2 2 0 0 1 19 14" /><path d="M17 17.5 C19 19 21 17.8 21 16 A2 2 0 0 0 19 14" />',...t}));Vw.displayName="Heading3Icon";var Sd=Vw,Fw=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M12 18 V6" />
|
|
334
377
|
<path d="M17 10 V11.75 A2.25 2.25 0 0 0 19.25 14 H21" />
|
|
335
378
|
<path d="M21 10 V18" />
|
|
336
379
|
<path d="M4 12 H12" />
|
|
337
|
-
<path d="M4 18 V6"
|
|
380
|
+
<path d="M4 18 V6" />`,fillDuoSvg:'<g opacity="0.38"><path d="M12 18 V6" /><path d="M21 10 V18" /><path d="M4 12 H12" /><path d="M4 18 V6" /></g><path d="M17 10 V11.75 A2.25 2.25 0 0 0 19.25 14 H21" />',...t}));Fw.displayName="Heading4Icon";var Cd=Fw,Uw=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M4 12 H12" />
|
|
338
381
|
<path d="M4 18 V6" />
|
|
339
382
|
<path d="M12 18 V6" />
|
|
340
383
|
<path d="M17 13 V11.26 A1.26 1.26 0 0 1 18.26 10 H21" />
|
|
341
|
-
<path d="M17 17.7 C17.4 17.9 17.8 18 18.3 18 C19.8 18 21 16.9 21 15.5 C21 14.1 19.8 13 18.3 13 H17"
|
|
384
|
+
<path d="M17 17.7 C17.4 17.9 17.8 18 18.3 18 C19.8 18 21 16.9 21 15.5 C21 14.1 19.8 13 18.3 13 H17" />`,fillDuoSvg:'<g opacity="0.38"><path d="M4 12 H12" /><path d="M4 18 V6" /><path d="M12 18 V6" /></g><path d="M17 13 V11.26 A1.26 1.26 0 0 1 18.26 10 H21" /><path d="M17 17.7 C17.4 17.9 17.8 18 18.3 18 C19.8 18 21 16.9 21 15.5 C21 14.1 19.8 13 18.3 13 H17" />',...t}));Uw.displayName="Heading5Icon";var Md=Uw,Ww=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M4 12 H12" />
|
|
342
385
|
<path d="M4 18 V6" />
|
|
343
386
|
<path d="M12 18 V6" />
|
|
344
387
|
<circle cx="19" cy="16" r="2" />
|
|
345
|
-
<path d="M20 10 C18 12 17 13.5 17 16"
|
|
388
|
+
<path d="M20 10 C18 12 17 13.5 17 16" />`,outlineDuoSvg:`<g fill="currentColor" stroke="none" opacity="0.2"><circle cx="19" cy="16" r="2" /></g><path d="M4 12 H12" />
|
|
389
|
+
<path d="M4 18 V6" />
|
|
390
|
+
<path d="M12 18 V6" />
|
|
391
|
+
<circle cx="19" cy="16" r="2" />
|
|
392
|
+
<path d="M20 10 C18 12 17 13.5 17 16" />`,fillSvg:'<g fill="currentColor"><circle cx="19" cy="16" r="2" /></g><path d="M4 12 H12" /><path d="M4 18 V6" /><path d="M12 18 V6" /><path d="M20 10 C18 12 17 13.5 17 16" />',fillDuoSvg:'<g fill="currentColor" stroke="currentColor" stroke-width="0.75" opacity="0.38"><circle cx="19" cy="16" r="2" /></g><path d="M4 12 H12" /><path d="M4 18 V6" /><path d="M12 18 V6" /><path d="M20 10 C18 12 17 13.5 17 16" />',...t}));Ww.displayName="Heading6Icon";var Ad=Ww,Kw=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M6 12 H18" />
|
|
346
393
|
<path d="M6 20 V4" />
|
|
347
|
-
<path d="M18 20 V4"
|
|
394
|
+
<path d="M18 20 V4" />`,fillDuoSvg:'<g opacity="0.38"><path d="M6 20 V4" /></g><path d="M6 12 H18" /><path d="M18 20 V4" />',...t}));Kw.displayName="HeadingIcon";var z3=Kw,qw=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M4 12 H12" />
|
|
348
395
|
<path d="M4 18 V6" />
|
|
349
396
|
<path d="M12 18 V6" />
|
|
350
|
-
<path d="M17 12 L19.16 10.56 A0.54 0.54 0 0 1 20 11.01 V18"
|
|
397
|
+
<path d="M17 12 L19.16 10.56 A0.54 0.54 0 0 1 20 11.01 V18" />`,fillDuoSvg:'<g opacity="0.38"><path d="M4 12 H12" /><path d="M4 18 V6" /><path d="M12 18 V6" /></g><path d="M17 12 L19.16 10.56 A0.54 0.54 0 0 1 20 11.01 V18" />',...t}));qw.displayName="Heading1Icon";var Ed=qw,Jw=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M4 12 H12" />
|
|
351
398
|
<path d="M4 18 V6" />
|
|
352
399
|
<path d="M12 18 V6" />
|
|
353
|
-
<path d="M21 18 H17 C17 14 21 15 21 12 C21 10.5 19 9.5 17 11"
|
|
400
|
+
<path d="M21 18 H17 C17 14 21 15 21 12 C21 10.5 19 9.5 17 11" />`,fillDuoSvg:'<g opacity="0.38"><path d="M4 12 H12" /><path d="M4 18 V6" /><path d="M12 18 V6" /></g><path d="M21 18 H17 C17 14 21 15 21 12 C21 10.5 19 9.5 17 11" />',...t}));Jw.displayName="Heading2Icon";var Td=Jw,Gw=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<circle cx="9" cy="12" r="1" />
|
|
354
401
|
<circle cx="9" cy="5" r="1" />
|
|
355
402
|
<circle cx="9" cy="19" r="1" />
|
|
356
403
|
<circle cx="15" cy="12" r="1" />
|
|
357
404
|
<circle cx="15" cy="5" r="1" />
|
|
358
|
-
<circle cx="15" cy="19" r="1"
|
|
359
|
-
<path d="M4 18 V16 A4 4 0 0 1 8 12 H20"
|
|
360
|
-
<circle cx="12" cy="12" r="3"
|
|
405
|
+
<circle cx="15" cy="19" r="1" />`,fillDuoSvg:'<g opacity="0.38"><circle cx="9" cy="5" r="1" /><circle cx="15" cy="12" r="1" /><circle cx="15" cy="19" r="1" /></g><circle cx="9" cy="12" r="1" /><circle cx="9" cy="19" r="1" /><circle cx="15" cy="5" r="1" />',...t}));Gw.displayName="GripVerticalIcon";var $3=Gw,Yw=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M15 17 L20 12 L15 7" />
|
|
406
|
+
<path d="M4 18 V16 A4 4 0 0 1 8 12 H20" />`,fillDuoSvg:'<g opacity="0.38"><path d="M4 18 V16 A4 4 0 0 1 8 12 H20" /></g><path d="M15 17 L20 12 L15 7" />',...t}));Yw.displayName="ForwardIcon";var V3=Yw,Xw=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M2.06 12.35 A1 1 0 0 1 2.06 11.65 A10.75 10.75 0 0 1 21.94 11.65 A1 1 0 0 1 21.94 12.35 A10.75 10.75 0 0 1 2.06 12.35" />
|
|
407
|
+
<circle cx="12" cy="12" r="3" />`,outlineDuoSvg:`<defs><mask id="__MASK__"><rect width="24" height="24" fill="white" /><circle cx="12" cy="12" r="3" fill="black" stroke="none" /></mask></defs><g fill="currentColor" stroke="none" opacity="0.2" mask="url(#__MASK__)"><path d="M2.06 12.35 A1 1 0 0 1 2.06 11.65 A10.75 10.75 0 0 1 21.94 11.65 A1 1 0 0 1 21.94 12.35 A10.75 10.75 0 0 1 2.06 12.35" /></g><path d="M2.06 12.35 A1 1 0 0 1 2.06 11.65 A10.75 10.75 0 0 1 21.94 11.65 A1 1 0 0 1 21.94 12.35 A10.75 10.75 0 0 1 2.06 12.35" />
|
|
408
|
+
<circle cx="12" cy="12" r="3" />`,fillSvg:'<defs><mask id="__MASK__"><rect width="24" height="24" fill="white" /><circle cx="12" cy="12" r="3" fill="black" stroke="none" /></mask></defs><g fill="currentColor" mask="url(#__MASK__)"><path d="M2.06 12.35 A1 1 0 0 1 2.06 11.65 A10.75 10.75 0 0 1 21.94 11.65 A1 1 0 0 1 21.94 12.35 A10.75 10.75 0 0 1 2.06 12.35" /></g>',fillDuoSvg:'<defs><mask id="__MASK__"><rect width="24" height="24" fill="white" /><circle cx="12" cy="12" r="3" fill="black" stroke="none" /></mask></defs><g fill="currentColor" stroke="currentColor" stroke-width="0.75" opacity="0.38" mask="url(#__MASK__)"><path d="M2.06 12.35 A1 1 0 0 1 2.06 11.65 A10.75 10.75 0 0 1 21.94 11.65 A1 1 0 0 1 21.94 12.35 A10.75 10.75 0 0 1 2.06 12.35" /></g><circle cx="12" cy="12" r="3" />',...t}));Xw.displayName="EyeIcon";var F3=Xw,Zw=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<circle cx="12" cy="12" r="1" />
|
|
361
409
|
<circle cx="19" cy="12" r="1" />
|
|
362
|
-
<circle cx="5" cy="12" r="1"
|
|
410
|
+
<circle cx="5" cy="12" r="1" />`,fillDuoSvg:'<g opacity="0.38"><circle cx="19" cy="12" r="1" /></g><circle cx="12" cy="12" r="1" /><circle cx="5" cy="12" r="1" />',...t}));Zw.displayName="DotsThreeIcon";var U3=Zw,Qw=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<ellipse cx="12" cy="5" rx="9" ry="3" />
|
|
363
411
|
<path d="M3 5 V19 A9 3 0 0 0 21 19 V5" />
|
|
364
|
-
<path d="M3 12 A9 3 0 0 0 21 12"
|
|
365
|
-
<path d="
|
|
412
|
+
<path d="M3 12 A9 3 0 0 0 21 12" />`,outlineDuoSvg:`<g fill="currentColor" stroke="none" opacity="0.2"><ellipse cx="12" cy="5" rx="9" ry="3" /></g><ellipse cx="12" cy="5" rx="9" ry="3" />
|
|
413
|
+
<path d="M3 5 V19 A9 3 0 0 0 21 19 V5" />
|
|
414
|
+
<path d="M3 12 A9 3 0 0 0 21 12" />`,fillSvg:'<g fill="currentColor"><ellipse cx="12" cy="5" rx="9" ry="3" /></g><path d="M3 5 V19 A9 3 0 0 0 21 19 V5" /><path d="M3 12 A9 3 0 0 0 21 12" />',fillDuoSvg:'<g fill="currentColor" stroke="currentColor" stroke-width="0.75" opacity="0.38"><ellipse cx="12" cy="5" rx="9" ry="3" /></g><path d="M3 5 V19 A9 3 0 0 0 21 19 V5" /><path d="M3 12 A9 3 0 0 0 21 12" />',...t}));Qw.displayName="DatabaseIcon";var W3=Qw,ex=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<rect width="14" height="14" x="8" y="8" rx="3.75" />
|
|
415
|
+
<path d="M4 16 C2.9 16 2 15.1 2 14 V4 C2 2.9 2.9 2 4 2 H14 C15.1 2 16 2.9 16 4" />`,outlineDuoSvg:`<g fill="currentColor" stroke="none" opacity="0.2"><rect width="14" height="14" x="8" y="8" rx="3.75" /></g><rect width="14" height="14" x="8" y="8" rx="3.75" />
|
|
416
|
+
<path d="M4 16 C2.9 16 2 15.1 2 14 V4 C2 2.9 2.9 2 4 2 H14 C15.1 2 16 2.9 16 4" />`,fillSvg:'<g fill="currentColor"><rect width="14" height="14" x="8" y="8" rx="3.75" /></g><path d="M4 16 C2.9 16 2 15.1 2 14 V4 C2 2.9 2.9 2 4 2 H14 C15.1 2 16 2.9 16 4" />',fillDuoSvg:'<g fill="currentColor" stroke="currentColor" stroke-width="0.75" opacity="0.38"><rect width="14" height="14" x="8" y="8" rx="3.75" /></g><path d="M4 16 C2.9 16 2 15.1 2 14 V4 C2 2.9 2.9 2 4 2 H14 C15.1 2 16 2.9 16 4" />',...t}));ex.displayName="CopyIcon";var K3=ex,tx=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<rect width="18" height="18" x="3" y="3" rx="3.75" />
|
|
417
|
+
<path d="M9 3 V21" />
|
|
418
|
+
<path d="M15 3 V21" />`,outlineDuoSvg:`<g fill="currentColor" stroke="none" opacity="0.2"><rect width="18" height="18" x="3" y="3" rx="3.75" /></g><rect width="18" height="18" x="3" y="3" rx="3.75" />
|
|
366
419
|
<path d="M9 3 V21" />
|
|
367
|
-
<path d="M15 3 V21"
|
|
368
|
-
<path d="M8 6 L3.31 10.69 A1.85 1.85 0 0 0 3.31 13.31 L8 18"
|
|
420
|
+
<path d="M15 3 V21" />`,fillSvg:'<defs><mask id="__MASK__"><rect width="24" height="24" fill="white" /><path d="M9 3 V21" fill="none" stroke="black" /><path d="M15 3 V21" fill="none" stroke="black" /></mask></defs><g fill="currentColor" mask="url(#__MASK__)"><rect width="18" height="18" x="3" y="3" rx="3.75" /></g>',fillDuoSvg:'<g fill="currentColor" stroke="currentColor" stroke-width="0.75" opacity="0.38"><rect width="18" height="18" x="3" y="3" rx="3.75" /></g><path d="M9 3 V21" /><path d="M15 3 V21" />',...t}));tx.displayName="Columns3Icon";var q3=tx,nx=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M16 18 L20.69 13.31 A1.85 1.85 0 0 0 20.69 10.69 L16 6" />
|
|
421
|
+
<path d="M8 6 L3.31 10.69 A1.85 1.85 0 0 0 3.31 13.31 L8 18" />`,fillDuoSvg:'<g opacity="0.38"><path d="M8 6 L3.31 10.69 A1.85 1.85 0 0 0 3.31 13.31 L8 18" /></g><path d="M16 18 L20.69 13.31 A1.85 1.85 0 0 0 20.69 10.69 L16 6" />',...t}));nx.displayName="CodeIcon";var nc=nx,rx=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M18 16 L20.69 13.31 A1.85 1.85 0 0 0 20.69 10.69 L18 8" />
|
|
369
422
|
<path d="M6 8 L3.31 10.69 A1.85 1.85 0 0 0 3.31 13.31 L6 16" />
|
|
370
|
-
<path d="M14.5 4 L9.5 20"
|
|
423
|
+
<path d="M14.5 4 L9.5 20" />`,fillDuoSvg:'<g opacity="0.38"><path d="M14.5 4 L9.5 20" /></g><path d="M18 16 L20.69 13.31 A1.85 1.85 0 0 0 20.69 10.69 L18 8" /><path d="M6 8 L3.31 10.69 A1.85 1.85 0 0 0 3.31 13.31 L6 16" />',...t}));rx.displayName="CodeXmlIcon";var J3=rx,sx=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:'<path d="M9 18 L13.69 13.31 A1.85 1.85 0 0 0 13.69 10.69 L9 6" />',...t}));sx.displayName="ChevronRightIcon";var G3=sx,ix=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:'<path d="M20 6 L10.31 15.69 A1.85 1.85 0 0 1 7.69 15.69 L4 12" />',...t}));ix.displayName="CheckIcon";var Y3=ix,ox=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:'<path d="M6 9 L10.69 13.69 A1.85 1.85 0 0 0 13.31 13.69 L18 9" />',...t}));ox.displayName="CaretDownIcon";var wl=ox,lx=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M17 6 H3" />
|
|
371
424
|
<path d="M21 12 H8" />
|
|
372
425
|
<path d="M21 18 H8" />
|
|
373
|
-
<path d="M3 12 V18"
|
|
426
|
+
<path d="M3 12 V18" />`,fillDuoSvg:'<g opacity="0.38"><path d="M17 6 H3" /><path d="M21 12 H8" /><path d="M21 18 H8" /></g><path d="M3 12 V18" />',...t}));lx.displayName="BlockquoteIcon";var Jm=lx,ax=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:'<path d="M6 12 H15 A4 4 0 0 1 15 20 H8.25 A2.25 2.25 0 0 1 6 17.75 V6.25 A2.25 2.25 0 0 1 8.25 4 H14 A4 4 0 0 1 14 12" />',...t}));ax.displayName="BoldIcon";var _d=ax,cx=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<rect width="13" height="7" x="8" y="3" rx="2.66" />
|
|
427
|
+
<path d="M2 9 L3.74 10.74 A1.78 1.78 0 0 1 3.74 13.26 L2 15" />
|
|
428
|
+
<rect width="13" height="7" x="8" y="14" rx="2.66" />`,outlineDuoSvg:`<g fill="currentColor" stroke="none" opacity="0.2"><rect width="13" height="7" x="8" y="3" rx="2.66" /><rect width="13" height="7" x="8" y="14" rx="2.66" /></g><rect width="13" height="7" x="8" y="3" rx="2.66" />
|
|
374
429
|
<path d="M2 9 L3.74 10.74 A1.78 1.78 0 0 1 3.74 13.26 L2 15" />
|
|
375
|
-
<rect width="13" height="7" x="8" y="14" rx="2.66"
|
|
430
|
+
<rect width="13" height="7" x="8" y="14" rx="2.66" />`,fillSvg:'<g fill="currentColor"><rect width="13" height="7" x="8" y="3" rx="2.66" /><rect width="13" height="7" x="8" y="14" rx="2.66" /></g><path d="M2 9 L3.74 10.74 A1.78 1.78 0 0 1 3.74 13.26 L2 15" />',fillDuoSvg:'<g fill="currentColor" stroke="currentColor" stroke-width="0.75" opacity="0.38"><rect width="13" height="7" x="8" y="3" rx="2.66" /><rect width="13" height="7" x="8" y="14" rx="2.66" /></g><path d="M2 9 L3.74 10.74 A1.78 1.78 0 0 1 3.74 13.26 L2 15" />',...t}));cx.displayName="BetweenHorizontalStartIcon";var X3=cx,ux=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<rect width="7" height="13" x="3" y="3" rx="2.66" />
|
|
376
431
|
<path d="M9 22 L10.74 20.26 A1.78 1.78 0 0 1 13.26 20.26 L15 22" />
|
|
377
|
-
<rect width="7" height="13" x="14" y="3" rx="2.66"
|
|
432
|
+
<rect width="7" height="13" x="14" y="3" rx="2.66" />`,outlineDuoSvg:`<g fill="currentColor" stroke="none" opacity="0.2"><rect width="7" height="13" x="3" y="3" rx="2.66" /><rect width="7" height="13" x="14" y="3" rx="2.66" /></g><rect width="7" height="13" x="3" y="3" rx="2.66" />
|
|
433
|
+
<path d="M9 22 L10.74 20.26 A1.78 1.78 0 0 1 13.26 20.26 L15 22" />
|
|
434
|
+
<rect width="7" height="13" x="14" y="3" rx="2.66" />`,fillSvg:'<g fill="currentColor"><rect width="7" height="13" x="3" y="3" rx="2.66" /><rect width="7" height="13" x="14" y="3" rx="2.66" /></g><path d="M9 22 L10.74 20.26 A1.78 1.78 0 0 1 13.26 20.26 L15 22" />',fillDuoSvg:'<g fill="currentColor" stroke="currentColor" stroke-width="0.75" opacity="0.38"><rect width="7" height="13" x="3" y="3" rx="2.66" /><rect width="7" height="13" x="14" y="3" rx="2.66" /></g><path d="M9 22 L10.74 20.26 A1.78 1.78 0 0 1 13.26 20.26 L15 22" />',...t}));ux.displayName="BetweenVerticalEndIcon";var Z3=ux,dx=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<rect width="7" height="13" x="3" y="8" rx="2.66" />
|
|
435
|
+
<path d="M15 2 L13.26 3.74 A1.78 1.78 0 0 1 10.74 3.74 L9 2" />
|
|
436
|
+
<rect width="7" height="13" x="14" y="8" rx="2.66" />`,outlineDuoSvg:`<g fill="currentColor" stroke="none" opacity="0.2"><rect width="7" height="13" x="3" y="8" rx="2.66" /><rect width="7" height="13" x="14" y="8" rx="2.66" /></g><rect width="7" height="13" x="3" y="8" rx="2.66" />
|
|
378
437
|
<path d="M15 2 L13.26 3.74 A1.78 1.78 0 0 1 10.74 3.74 L9 2" />
|
|
379
|
-
<rect width="7" height="13" x="14" y="8" rx="2.66"
|
|
438
|
+
<rect width="7" height="13" x="14" y="8" rx="2.66" />`,fillSvg:'<g fill="currentColor"><rect width="7" height="13" x="3" y="8" rx="2.66" /><rect width="7" height="13" x="14" y="8" rx="2.66" /></g><path d="M15 2 L13.26 3.74 A1.78 1.78 0 0 1 10.74 3.74 L9 2" />',fillDuoSvg:'<g fill="currentColor" stroke="currentColor" stroke-width="0.75" opacity="0.38"><rect width="7" height="13" x="3" y="8" rx="2.66" /><rect width="7" height="13" x="14" y="8" rx="2.66" /></g><path d="M15 2 L13.26 3.74 A1.78 1.78 0 0 1 10.74 3.74 L9 2" />',...t}));dx.displayName="BetweenVerticalStartIcon";var Q3=dx,hx=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<rect width="13" height="7" x="3" y="3" rx="2.66" />
|
|
380
439
|
<path d="M22 15 L20.26 13.26 A1.78 1.78 0 0 1 20.26 10.74 L22 9" />
|
|
381
|
-
<rect width="13" height="7" x="3" y="14" rx="2.66"
|
|
382
|
-
<path d="
|
|
383
|
-
<path d="
|
|
384
|
-
<path d="
|
|
385
|
-
<path d="
|
|
386
|
-
<path d="
|
|
440
|
+
<rect width="13" height="7" x="3" y="14" rx="2.66" />`,outlineDuoSvg:`<g fill="currentColor" stroke="none" opacity="0.2"><rect width="13" height="7" x="3" y="3" rx="2.66" /><rect width="13" height="7" x="3" y="14" rx="2.66" /></g><rect width="13" height="7" x="3" y="3" rx="2.66" />
|
|
441
|
+
<path d="M22 15 L20.26 13.26 A1.78 1.78 0 0 1 20.26 10.74 L22 9" />
|
|
442
|
+
<rect width="13" height="7" x="3" y="14" rx="2.66" />`,fillSvg:'<g fill="currentColor"><rect width="13" height="7" x="3" y="3" rx="2.66" /><rect width="13" height="7" x="3" y="14" rx="2.66" /></g><path d="M22 15 L20.26 13.26 A1.78 1.78 0 0 1 20.26 10.74 L22 9" />',fillDuoSvg:'<g fill="currentColor" stroke="currentColor" stroke-width="0.75" opacity="0.38"><rect width="13" height="7" x="3" y="3" rx="2.66" /><rect width="13" height="7" x="3" y="14" rx="2.66" /></g><path d="M22 15 L20.26 13.26 A1.78 1.78 0 0 1 20.26 10.74 L22 9" />',...t}));hx.displayName="BetweenHorizontalEndIcon";var eO=hx,fx=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<circle cx="12" cy="12" r="10" />
|
|
443
|
+
<path d="M4.93 4.93 L19.07 19.07" />`,outlineDuoSvg:`<g fill="currentColor" stroke="none" opacity="0.2"><circle cx="12" cy="12" r="10" /></g><circle cx="12" cy="12" r="10" />
|
|
444
|
+
<path d="M4.93 4.93 L19.07 19.07" />`,fillSvg:'<defs><mask id="__MASK__"><rect width="24" height="24" fill="white" /><path d="M4.93 4.93 L19.07 19.07" fill="none" stroke="black" /></mask></defs><g fill="currentColor" mask="url(#__MASK__)"><circle cx="12" cy="12" r="10" /></g>',fillDuoSvg:'<g fill="currentColor" stroke="currentColor" stroke-width="0.75" opacity="0.38"><circle cx="12" cy="12" r="10" /></g><path d="M4.93 4.93 L19.07 19.07" />',...t}));fx.displayName="BanIcon";var tO=fx,px=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M5 12 L10.97 6.03 A1.45 1.45 0 0 1 13.03 6.03 L19 12" />
|
|
445
|
+
<path d="M12 19 V5.6" />`,fillDuoSvg:'<g opacity="0.38"><path d="M12 19 V5.6" /></g><path d="M5 12 L10.97 6.03 A1.45 1.45 0 0 1 13.03 6.03 L19 12" />',...t}));px.displayName="ArrowUpIcon";var nO=px,mx=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M12 5 V18.4" />
|
|
446
|
+
<path d="M19 12 L13.03 17.97 A1.45 1.45 0 0 1 10.97 17.97 L5 12" />`,fillDuoSvg:'<g opacity="0.38"><path d="M12 5 V18.4" /></g><path d="M19 12 L13.03 17.97 A1.45 1.45 0 0 1 10.97 17.97 L5 12" />',...t}));mx.displayName="ArrowDownIcon";var rO=mx,gx=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M21 5 H3" />
|
|
387
447
|
<path d="M15 12 H3" />
|
|
388
|
-
<path d="M17 19 H3"
|
|
448
|
+
<path d="M17 19 H3" />`,fillDuoSvg:'<g opacity="0.38"><path d="M15 12 H3" /></g><path d="M21 5 H3" /><path d="M17 19 H3" />',...t}));gx.displayName="AlignLeftIcon";var Gm=gx,yx=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M21 5 H3" />
|
|
449
|
+
<path d="M21 12 H9" />
|
|
450
|
+
<path d="M21 19 H7" />`,fillDuoSvg:'<g opacity="0.38"><path d="M21 12 H9" /></g><path d="M21 5 H3" /><path d="M21 19 H7" />',...t}));yx.displayName="AlignRightIcon";var Ym=yx,bx=S.forwardRef((t,e)=>m.jsx(J,{ref:e,innerSvg:`<path d="M21 5 H3" />
|
|
389
451
|
<path d="M17 12 H7" />
|
|
390
|
-
<path d="M19 19 H5" />`,...t}));bx.displayName="AlignCenterIcon";var Xm=bx;const sD="_wrap_1pdh5_1",iD="_dropdown_1pdh5_6",oD="_dropdownRight_1pdh5_13",lD="_panel_1pdh5_20",aD="_search_1pdh5_32",cD="_list_1pdh5_36",uD="_group_1pdh5_43",dD="_empty_1pdh5_47",Jn={wrap:sD,dropdown:iD,dropdownRight:oD,panel:lD,search:aD,list:cD,group:uD,empty:dD},au="Other";function fD(t){var r;const e=new Map;for(const s of t){const i=((r=s.category)==null?void 0:r.trim())||au,o=e.get(i);o?o.push(s):e.set(i,[s])}const n=[...e.entries()].map(([s,i])=>({category:s,items:i}));return n.sort((s,i)=>s.category===i.category?0:s.category===au?1:i.category===au?-1:0),n}function Zm({editor:t,variables:e,disabled:n=!1,buttonClassName:r,align:s="left",onVariableInsert:i}){const[o,l]=S.useState(!1),[a,c]=S.useState(""),u=S.useRef(null),d=S.useRef(null),f=S.useRef(null),h=S.useRef(null),p=S.useMemo(()=>{const k=a.trim().toLowerCase();return k?e.filter(C=>C.label.toLowerCase().includes(k)||C.key.toLowerCase().includes(k)):e},[e,a]),g=S.useMemo(()=>fD(p),[p]);S.useEffect(()=>{n&&l(!1)},[n]),S.useEffect(()=>{function k(C){u.current&&!u.current.contains(C.target)&&l(!1)}return o&&document.addEventListener("pointerdown",k),()=>document.removeEventListener("pointerdown",k)},[o]),S.useEffect(()=>{if(!o){c("");return}const k=window.setTimeout(()=>{var C;return(C=d.current)==null?void 0:C.focus()},0);return()=>window.clearTimeout(k)},[o]);function y(){return f.current?[...f.current.querySelectorAll('[role="menuitem"]:not([disabled])')]:[]}function b(k){var _;const C=y();if(C.length===0)return;const E=C.indexOf(document.activeElement),O=E===-1?k===1?0:C.length-1:(E+k+C.length)%C.length;(_=C[O])==null||_.focus()}function w(k){l(!1),t.commands.focus()}function v(k){if(n)return;const C=h.current;t.chain().focus().setTextSelection(C??t.state.selection).insertDynamicVariable(k).run(),l(!1),i==null||i(k.key)}function x(k){if(k.key==="Escape"){k.preventDefault(),w();return}if(k.key==="ArrowDown"){k.preventDefault(),b(1);return}if(k.key==="ArrowUp"){k.preventDefault(),b(-1);return}if(k.key==="Enter"&&k.target===d.current){k.preventDefault();const C=p[0];C&&v(C)}}return m.jsxs("div",{className:Jn.wrap,ref:u,children:[m.jsx(A.Tooltip,{content:"Insert variable",placement:"top",children:m.jsx("button",{type:"button",className:r,disabled:n,"aria-label":"Insert variable","aria-haspopup":"dialog","aria-expanded":o,onMouseDown:k=>{if(k.preventDefault(),!n){if(!o){const{from:C,to:E}=t.state.selection;h.current={from:C,to:E}}l(C=>!C)}},children:m.jsx(WR,{size:14})})}),o&&m.jsx("div",{className:[Jn.dropdown,s==="right"&&Jn.dropdownRight].filter(Boolean).join(" "),children:m.jsxs("div",{className:Jn.panel,role:"dialog","aria-label":"Insert variable",onKeyDown:x,onMouseDown:k=>k.stopPropagation(),children:[m.jsx("div",{className:Jn.search,children:m.jsx(A.SearchInput,{ref:d,size:"sm","aria-label":"Search variables",placeholder:"Search variables…",value:a,onChange:k=>c(k.target.value)})}),m.jsx(A.Scrollable,{size:"thin",maxHeight:"264px",children:m.jsx("div",{className:Jn.list,ref:f,role:"menu","aria-label":"Variables",children:g.length===0?m.jsx("div",{className:Jn.empty,children:"No variables found"}):g.map(k=>m.jsxs("div",{className:Jn.group,role:"group","aria-label":k.category,children:[m.jsx(A.MenuTitle,{children:k.category}),k.items.map(C=>m.jsx(A.MenuItem,{label:C.label,onClick:()=>v(C)},C.key))]},k.category))})})]})})]})}const hD="_menubar_89djx_1",pD="_group_89djx_11",mD="_divider_89djx_17",gD="_spacer_89djx_25",yD="_btn_89djx_30",bD="_active_89djx_46",wD="_blockWrap_89djx_63",xD="_blockTrigger_89djx_67",vD="_blockTriggerCompact_89djx_86",kD="_blockDropdown_89djx_107",SD="_alignTrigger_89djx_116",CD="_colorWrap_89djx_148",ED="_colorDropdown_89djx_152",MD="_colorTabs_89djx_164",TD="_colorPickerBody_89djx_169",AD="_colorTab_89djx_164",_D="_colorTabActive_89djx_198",ND="_menubarWrap_89djx_215",OD="_aiPanel_89djx_221",ID="_aiInputRow_89djx_230",RD="_aiTextarea_89djx_244",DD="_aiLoadingText_89djx_268",Z={menubar:hD,group:pD,divider:mD,spacer:gD,btn:yD,active:bD,blockWrap:wD,blockTrigger:xD,blockTriggerCompact:vD,blockDropdown:kD,alignTrigger:SD,colorWrap:CD,colorDropdown:ED,colorTabs:MD,colorPickerBody:TD,colorTab:AD,colorTabActive:_D,menubarWrap:ND,aiPanel:OD,aiInputRow:ID,aiTextarea:RD,aiLoadingText:DD},LD=S.memo(function({editor:e,disabled:n,showHtml:r,compact:s=!1,onLinkClick:i,onCodeClick:o,variables:l,showVariablePicker:a=!1,onVariableInsert:c,onAiSubmit:u,aiSubmitDisabled:d=!1}){const[f,h]=S.useState(!1),[p,g]=S.useState(""),[y,b]=S.useState(!1),w=S.useRef(null),v=S.useRef(null),[x,k]=S.useState(!1),C=S.useRef(null),[E,O]=S.useState(!1),_=S.useRef(null),M=S.useRef(null),[D,R]=S.useState(!1),L=S.useRef(null),[I,N]=S.useState(!1),z=S.useRef(null),[H,U]=S.useState(!1),[q,de]=S.useState("text"),[ve,Ee]=S.useState("#000000"),[Ct,Me]=S.useState("#ffff00"),Ae=S.useRef(null),ze=S.useRef(null),$=S.useRef(null),F=vo({editor:e,selector:({editor:T})=>({isBold:T.isActive("bold"),isItalic:T.isActive("italic"),isUnderline:T.isActive("underline"),isStrike:T.isActive("strike"),isAlignLeft:T.isActive({textAlign:"left"}),isAlignCenter:T.isActive({textAlign:"center"}),isAlignRight:T.isActive({textAlign:"right"}),isH1:T.isActive("heading",{level:1}),isH2:T.isActive("heading",{level:2}),isH3:T.isActive("heading",{level:3}),isH4:T.isActive("heading",{level:4}),isH5:T.isActive("heading",{level:5}),isH6:T.isActive("heading",{level:6}),isBlockquote:T.isActive("blockquote"),isBulletList:T.isActive("bulletList"),isOrderedList:T.isActive("orderedList"),isLink:T.isActive("link"),isTable:T.isActive("tableCell")||T.isActive("tableHeader"),hasSelection:!T.state.selection.empty})});S.useEffect(()=>{function T(ne){v.current&&!v.current.contains(ne.target)&&h(!1)}return f&&document.addEventListener("pointerdown",T),()=>document.removeEventListener("pointerdown",T)},[f]),S.useEffect(()=>{function T(ne){C.current&&!C.current.contains(ne.target)&&k(!1)}return x&&document.addEventListener("pointerdown",T),()=>document.removeEventListener("pointerdown",T)},[x]),S.useEffect(()=>{function T(ne){_.current&&!_.current.contains(ne.target)&&O(!1)}return E&&document.addEventListener("pointerdown",T),()=>document.removeEventListener("pointerdown",T)},[E]),S.useEffect(()=>{function T(ne){z.current&&!z.current.contains(ne.target)&&N(!1)}return I&&document.addEventListener("pointerdown",T),()=>document.removeEventListener("pointerdown",T)},[I]),S.useEffect(()=>{function T(){k(!1),O(!1),R(!1),N(!1)}return e.on("focus",T),()=>{e.off("focus",T)}},[e]),S.useEffect(()=>{function T(ne){Ae.current&&!Ae.current.contains(ne.target)&&U(!1)}return H&&document.addEventListener("pointerdown",T),()=>document.removeEventListener("pointerdown",T)},[H]);const Ut=S.useCallback(()=>{h(T=>{const ne=!T;return ne&&setTimeout(()=>{var Je;return(Je=w.current)==null?void 0:Je.focus()},0),ne})},[]);async function _t(){if(!p.trim()||y||d)return;const T=p;g(""),w.current&&(w.current.style.height="auto"),b(!0);try{await(u==null?void 0:u(T))}finally{b(!1),h(!1)}}const oe=n||!!r,wn=l??[],V=a&&wn.length>0;S.useEffect(()=>{oe&&(h(!1),k(!1),O(!1),R(!1),N(!1),U(!1))},[oe]);function P(T){oe||T()}function W(...T){return[Z.btn,...T].filter(Boolean).join(" ")}const X=F.isH1?"Heading 1":F.isH2?"Heading 2":F.isH3?"Heading 3":F.isH4?"Heading 4":F.isH5?"Heading 5":F.isH6?"Heading 6":F.isBlockquote?"Blockquote":"Paragraph",be=F.isH1?"H1":F.isH2?"H2":F.isH3?"H3":F.isH4?"H4":F.isH5?"H5":F.isH6?"H6":F.isBlockquote?"Quote":"Text";return s?m.jsx("div",{className:Z.menubarWrap,ref:v,onClick:T=>T.stopPropagation(),children:m.jsxs("div",{className:Z.menubar,children:[m.jsxs("div",{className:Z.blockWrap,ref:C,children:[m.jsxs("button",{type:"button",className:`${Z.blockTrigger} ${Z.blockTriggerCompact}`,disabled:oe,onMouseDown:T=>{T.preventDefault(),oe||($.current={from:e.state.selection.from,to:e.state.selection.to},k(ne=>!ne))},"aria-label":"Text style",children:[m.jsx("span",{children:be}),m.jsx(wl,{size:12})]}),x&&m.jsx("div",{className:Z.blockDropdown,children:m.jsxs(A.Menu,{children:[m.jsx(A.MenuItemRadio,{label:"Paragraph",leftIcon:m.jsx(bd,{size:16}),checked:!F.isH1&&!F.isH2&&!F.isH3&&!F.isH4&&!F.isH5&&!F.isH6&&!F.isBlockquote,onClick:()=>{const T=$.current;e.chain().focus().setTextSelection(T??e.state.selection).setParagraph().run(),k(!1)}}),m.jsx(A.MenuItemRadio,{label:"Blockquote",leftIcon:m.jsx(Jm,{size:16}),checked:F.isBlockquote,onClick:()=>{const T=$.current;e.chain().focus().setTextSelection(T??e.state.selection).toggleBlockquote().run(),k(!1)}}),m.jsx(A.MenuItemRadio,{label:"Heading 1",leftIcon:m.jsx(Td,{size:16}),checked:F.isH1,onClick:()=>{const T=$.current;e.chain().focus().setTextSelection(T??e.state.selection).toggleHeading({level:1}).run(),k(!1)}}),m.jsx(A.MenuItemRadio,{label:"Heading 2",leftIcon:m.jsx(Ad,{size:16}),checked:F.isH2,onClick:()=>{const T=$.current;e.chain().focus().setTextSelection(T??e.state.selection).toggleHeading({level:2}).run(),k(!1)}}),m.jsx(A.MenuItemRadio,{label:"Heading 3",leftIcon:m.jsx(Sd,{size:16}),checked:F.isH3,onClick:()=>{const T=$.current;e.chain().focus().setTextSelection(T??e.state.selection).toggleHeading({level:3}).run(),k(!1)}}),m.jsx(A.MenuItemRadio,{label:"Heading 4",leftIcon:m.jsx(Cd,{size:16}),checked:F.isH4,onClick:()=>{const T=$.current;e.chain().focus().setTextSelection(T??e.state.selection).toggleHeading({level:4}).run(),k(!1)}}),m.jsx(A.MenuItemRadio,{label:"Heading 5",leftIcon:m.jsx(Ed,{size:16}),checked:F.isH5,onClick:()=>{const T=$.current;e.chain().focus().setTextSelection(T??e.state.selection).toggleHeading({level:5}).run(),k(!1)}}),m.jsx(A.MenuItemRadio,{label:"Heading 6",leftIcon:m.jsx(Md,{size:16}),checked:F.isH6,onClick:()=>{const T=$.current;e.chain().focus().setTextSelection(T??e.state.selection).toggleHeading({level:6}).run(),k(!1)}})]})})]}),m.jsx("div",{className:Z.divider}),m.jsxs("div",{className:Z.group,children:[m.jsx(A.Tooltip,{content:"Bold",placement:"top",children:m.jsx("button",{type:"button",className:W(F.isBold&&Z.active),disabled:oe,onMouseDown:T=>{T.preventDefault(),P(()=>e.chain().toggleBold().run())},"aria-label":"Bold",children:m.jsx(_d,{size:14})})}),m.jsx(A.Tooltip,{content:"Italic",placement:"top",children:m.jsx("button",{type:"button",className:W(F.isItalic&&Z.active),disabled:oe,onMouseDown:T=>{T.preventDefault(),P(()=>e.chain().toggleItalic().run())},"aria-label":"Italic",children:m.jsx(vd,{size:14})})})]}),m.jsx("div",{className:Z.divider}),m.jsxs("div",{className:Z.group,children:[m.jsx(A.Tooltip,{content:"Link",placement:"top",children:m.jsx("button",{type:"button",className:W(F.isLink&&Z.active),disabled:oe||!F.hasSelection&&!F.isLink,onMouseDown:T=>{T.preventDefault(),i()},"aria-label":"Link",children:m.jsx(xd,{size:14})})}),m.jsx(A.Tooltip,{content:"Numbered list",placement:"top",children:m.jsx("button",{type:"button",className:W(F.isOrderedList&&Z.active),disabled:oe,onMouseDown:T=>{T.preventDefault(),P(()=>e.chain().focus().toggleOrderedList().run())},"aria-label":"Numbered list",children:m.jsx(Km,{size:14})})}),m.jsx(A.Tooltip,{content:"Bullet list",placement:"top",children:m.jsx("button",{type:"button",className:W(F.isBulletList&&Z.active),disabled:oe,onMouseDown:T=>{T.preventDefault(),P(()=>e.chain().focus().toggleBulletList().run())},"aria-label":"Bullet list",children:m.jsx(ga,{size:14})})})]}),V&&m.jsxs(m.Fragment,{children:[m.jsx("div",{className:Z.spacer}),m.jsx("div",{className:Z.group,children:m.jsx(Zm,{editor:e,variables:wn,disabled:oe,buttonClassName:W(),align:"right",onVariableInsert:c})})]})]})}):m.jsxs("div",{className:Z.menubarWrap,ref:v,onClick:T=>T.stopPropagation(),children:[m.jsxs("div",{className:Z.menubar,children:[m.jsx(A.Tooltip,{content:"AI",placement:"top",children:m.jsx("button",{type:"button",className:W(f&&Z.active),disabled:oe,onMouseDown:T=>{T.preventDefault(),oe||Ut()},"aria-label":"AI",children:m.jsx(NR,{size:14})})}),m.jsx("div",{className:Z.divider}),m.jsxs("div",{className:Z.blockWrap,ref:C,children:[m.jsxs("button",{type:"button",className:Z.blockTrigger,disabled:oe,onMouseDown:T=>{T.preventDefault(),oe||($.current={from:e.state.selection.from,to:e.state.selection.to},k(ne=>!ne))},"aria-label":"Text style",children:[m.jsx("span",{children:X}),m.jsx(wl,{size:12})]}),x&&m.jsx("div",{className:Z.blockDropdown,children:m.jsxs(A.Menu,{children:[m.jsx(A.MenuItemRadio,{label:"Paragraph",leftIcon:m.jsx(bd,{size:16}),checked:!F.isH1&&!F.isH2&&!F.isH3&&!F.isH4&&!F.isH5&&!F.isH6&&!F.isBlockquote,onClick:()=>{const T=$.current;e.chain().focus().setTextSelection(T??e.state.selection).setParagraph().run(),k(!1)}}),m.jsx(A.MenuItemRadio,{label:"Blockquote",leftIcon:m.jsx(Jm,{size:16}),checked:F.isBlockquote,onClick:()=>{const T=$.current;e.chain().focus().setTextSelection(T??e.state.selection).toggleBlockquote().run(),k(!1)}}),m.jsx(A.MenuItemRadio,{label:"Heading 1",leftIcon:m.jsx(Td,{size:16}),checked:F.isH1,onClick:()=>{const T=$.current;e.chain().focus().setTextSelection(T??e.state.selection).toggleHeading({level:1}).run(),k(!1)}}),m.jsx(A.MenuItemRadio,{label:"Heading 2",leftIcon:m.jsx(Ad,{size:16}),checked:F.isH2,onClick:()=>{const T=$.current;e.chain().focus().setTextSelection(T??e.state.selection).toggleHeading({level:2}).run(),k(!1)}}),m.jsx(A.MenuItemRadio,{label:"Heading 3",leftIcon:m.jsx(Sd,{size:16}),checked:F.isH3,onClick:()=>{const T=$.current;e.chain().focus().setTextSelection(T??e.state.selection).toggleHeading({level:3}).run(),k(!1)}}),m.jsx(A.MenuItemRadio,{label:"Heading 4",leftIcon:m.jsx(Cd,{size:16}),checked:F.isH4,onClick:()=>{const T=$.current;e.chain().focus().setTextSelection(T??e.state.selection).toggleHeading({level:4}).run(),k(!1)}}),m.jsx(A.MenuItemRadio,{label:"Heading 5",leftIcon:m.jsx(Ed,{size:16}),checked:F.isH5,onClick:()=>{const T=$.current;e.chain().focus().setTextSelection(T??e.state.selection).toggleHeading({level:5}).run(),k(!1)}}),m.jsx(A.MenuItemRadio,{label:"Heading 6",leftIcon:m.jsx(Md,{size:16}),checked:F.isH6,onClick:()=>{const T=$.current;e.chain().focus().setTextSelection(T??e.state.selection).toggleHeading({level:6}).run(),k(!1)}})]})})]}),m.jsx("div",{className:Z.divider}),m.jsxs("div",{className:Z.group,children:[m.jsx(A.Tooltip,{content:"Bold",placement:"top",children:m.jsx("button",{type:"button",className:W(F.isBold&&Z.active),disabled:oe,onMouseDown:T=>{T.preventDefault(),P(()=>e.chain().toggleBold().run())},"aria-label":"Bold",children:m.jsx(_d,{size:14})})}),m.jsx(A.Tooltip,{content:"Italic",placement:"top",children:m.jsx("button",{type:"button",className:W(F.isItalic&&Z.active),disabled:oe,onMouseDown:T=>{T.preventDefault(),P(()=>e.chain().toggleItalic().run())},"aria-label":"Italic",children:m.jsx(vd,{size:14})})}),m.jsx(A.Tooltip,{content:"Underline",placement:"top",children:m.jsx("button",{type:"button",className:W(F.isUnderline&&Z.active),disabled:oe,onMouseDown:T=>{T.preventDefault(),P(()=>e.chain().toggleUnderline().run())},"aria-label":"Underline",children:m.jsx(Y1,{size:14})})}),m.jsxs("div",{className:Z.colorWrap,ref:Ae,children:[m.jsx(A.Tooltip,{content:"Color",placement:"top",children:m.jsx("button",{type:"button",className:W(H&&Z.active),disabled:oe,onMouseDown:T=>{if(T.preventDefault(),!oe){if(!H){const{from:ne,to:Je}=e.state.selection;ze.current={from:ne,to:Je}}U(ne=>!ne)}},"aria-label":"Color",children:m.jsx(kw,{size:14})})}),H&&m.jsxs("div",{className:Z.colorDropdown,children:[m.jsxs("div",{className:Z.colorTabs,children:[m.jsx("button",{type:"button",className:`${Z.colorTab} ${q==="text"?Z.colorTabActive:""}`,onMouseDown:T=>{T.preventDefault(),de("text")},children:"Text"}),m.jsx("button",{type:"button",className:`${Z.colorTab} ${q==="bg"?Z.colorTabActive:""}`,onMouseDown:T=>{T.preventDefault(),de("bg")},children:"Background"})]}),m.jsx("div",{className:Z.colorPickerBody,children:q==="text"?m.jsx(A.ColorPicker,{alwaysOpen:!0,value:ve,onChange:T=>{Ee(T);const ne=ze.current;ne&&ne.from!==ne.to?e.chain().setTextSelection(ne).setColor(T).run():e.chain().setColor(T).run()}}):m.jsx(A.ColorPicker,{alwaysOpen:!0,value:Ct,onChange:T=>{Me(T);const ne=ze.current;ne&&ne.from!==ne.to?e.chain().setTextSelection(ne).setHighlight({color:T}).run():e.chain().setHighlight({color:T}).run()}})})]})]})]}),m.jsx("div",{className:Z.divider}),m.jsxs("div",{className:Z.blockWrap,ref:_,children:[m.jsxs("button",{type:"button",className:Z.alignTrigger,disabled:oe,onMouseDown:T=>{T.preventDefault(),oe||(M.current={from:e.state.selection.from,to:e.state.selection.to},O(ne=>!ne))},"aria-label":"Text alignment",children:[F.isAlignCenter?m.jsx(Xm,{size:14}):F.isAlignRight?m.jsx(Gm,{size:14}):m.jsx(Ym,{size:14}),m.jsx(wl,{size:12})]}),E&&m.jsx("div",{className:Z.blockDropdown,children:m.jsxs(A.Menu,{children:[m.jsx(A.MenuItemRadio,{label:"Align left",leftIcon:m.jsx(Ym,{size:16}),checked:!F.isAlignCenter&&!F.isAlignRight,onClick:()=>{const T=M.current;e.chain().focus().setTextSelection(T??e.state.selection).setTextAlign("left").run(),O(!1)}}),m.jsx(A.MenuItemRadio,{label:"Align center",leftIcon:m.jsx(Xm,{size:16}),checked:F.isAlignCenter,onClick:()=>{const T=M.current;e.chain().focus().setTextSelection(T??e.state.selection).setTextAlign("center").run(),O(!1)}}),m.jsx(A.MenuItemRadio,{label:"Align right",leftIcon:m.jsx(Gm,{size:16}),checked:F.isAlignRight,onClick:()=>{const T=M.current;e.chain().focus().setTextSelection(T??e.state.selection).setTextAlign("right").run(),O(!1)}})]})})]}),m.jsx("div",{className:Z.divider}),m.jsxs("div",{className:Z.group,children:[m.jsx(A.Tooltip,{content:"Link",placement:"top",children:m.jsx("button",{type:"button",className:W(F.isLink&&Z.active),disabled:oe||!F.hasSelection&&!F.isLink,onMouseDown:T=>{T.preventDefault(),i()},"aria-label":"Link",children:m.jsx(xd,{size:14})})}),m.jsxs("div",{className:Z.blockWrap,ref:z,children:[m.jsx(A.Tooltip,{content:"Table",placement:"top",children:m.jsx("button",{type:"button",className:W(F.isTable&&Z.active),disabled:oe,onMouseDown:T=>{if(T.preventDefault(),oe)return;e.isActive("tableCell")||e.isActive("tableHeader")?N(Je=>!Je):e.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run()},"aria-label":"Table",children:m.jsx(lw,{size:14})})}),I&&m.jsx("div",{className:Z.blockDropdown,children:m.jsxs(A.Menu,{children:[m.jsx(A.MenuItem,{label:"Add row above",leftIcon:m.jsx(ms,{size:16}),onClick:()=>{e.chain().focus().addRowBefore().run(),N(!1)}}),m.jsx(A.MenuItem,{label:"Add row below",leftIcon:m.jsx(ms,{size:16}),onClick:()=>{e.chain().focus().addRowAfter().run(),N(!1)}}),m.jsx(A.MenuItem,{label:"Add column left",leftIcon:m.jsx(ms,{size:16}),onClick:()=>{e.chain().focus().addColumnBefore().run(),N(!1)}}),m.jsx(A.MenuItem,{label:"Add column right",leftIcon:m.jsx(ms,{size:16}),onClick:()=>{e.chain().focus().addColumnAfter().run(),N(!1)}}),m.jsx(A.MenuSeparator,{}),m.jsx(A.MenuItem,{label:"Delete row",leftIcon:m.jsx(wd,{size:16}),variant:"danger",onClick:()=>{e.chain().focus().deleteRow().run(),N(!1)}}),m.jsx(A.MenuItem,{label:"Delete column",leftIcon:m.jsx(wd,{size:16}),variant:"danger",onClick:()=>{e.chain().focus().deleteColumn().run(),N(!1)}}),m.jsx(A.MenuItem,{label:"Delete table",leftIcon:m.jsx(SR,{size:16}),variant:"danger",onClick:()=>{e.chain().focus().deleteTable().run(),N(!1)}})]})})]})]}),m.jsx("div",{className:Z.divider}),m.jsx(A.Popover,{open:D,onOpenChange:T=>{if(T){const{from:ne,to:Je}=e.state.selection;L.current={from:ne,to:Je}}R(T)},placement:"bottom-start",offset:4,bare:!0,trigger:m.jsx(A.Tooltip,{content:"Lists & formatting",placement:"top",children:m.jsx("button",{type:"button",className:W((D||F.isBulletList||F.isOrderedList)&&Z.active),disabled:oe,onMouseDown:T=>T.preventDefault(),"aria-expanded":D,"aria-haspopup":"menu","aria-label":"Lists and formatting",children:m.jsx(UR,{size:16})})}),children:m.jsxs(A.Menu,{children:[m.jsx(A.MenuItemRadio,{label:"Strikethrough",leftIcon:m.jsx(uw,{size:16}),checked:F.isStrike,onClick:()=>{const T=L.current;e.chain().focus().setTextSelection(T??e.state.selection).toggleStrike().run(),R(!1)}}),m.jsx(A.MenuSeparator,{}),m.jsx(A.MenuItemRadio,{label:"Bullet list",leftIcon:m.jsx(ga,{size:16}),checked:F.isBulletList,onClick:()=>{const T=L.current;e.chain().focus().setTextSelection(T??e.state.selection).toggleBulletList().run(),R(!1)}}),m.jsx(A.MenuItemRadio,{label:"Numbered list",leftIcon:m.jsx(Km,{size:16}),checked:F.isOrderedList,onClick:()=>{const T=L.current;e.chain().focus().setTextSelection(T??e.state.selection).toggleOrderedList().run(),R(!1)}}),m.jsx(A.MenuSeparator,{}),m.jsx(A.MenuItemRadio,{label:"Increase indent",leftIcon:m.jsx(BR,{size:16}),checked:!1,onClick:()=>{const T=L.current;e.chain().focus().setTextSelection(T??e.state.selection).increaseIndent().run(),R(!1)}}),m.jsx(A.MenuItemRadio,{label:"Decrease indent",leftIcon:m.jsx(PR,{size:16}),checked:!1,onClick:()=>{const T=L.current;e.chain().focus().setTextSelection(T??e.state.selection).decreaseIndent().run(),R(!1)}}),m.jsx(A.MenuSeparator,{}),m.jsx(A.MenuItemRadio,{label:"Clear formatting",leftIcon:m.jsx(IR,{size:16}),checked:!1,onClick:()=>{const T=L.current;e.chain().focus().setTextSelection(T??e.state.selection).unsetAllMarks().run(),R(!1)}})]})}),m.jsx("div",{className:Z.spacer}),m.jsxs("div",{className:Z.group,children:[m.jsx(A.Tooltip,{content:"HTML source",placement:"top",children:m.jsx("button",{type:"button",className:W(r&&Z.active),onMouseDown:T=>{T.preventDefault(),o()},"aria-label":"HTML source",children:m.jsx(nc,{size:14})})}),V&&m.jsx(Zm,{editor:e,variables:wn,disabled:oe,buttonClassName:W(),align:"right",onVariableInsert:c})]})]}),f&&m.jsx("div",{className:Z.aiPanel,children:m.jsxs("div",{className:Z.aiInputRow,children:[y?m.jsx("span",{className:Z.aiLoadingText,children:"Generating…"}):m.jsx("textarea",{ref:w,className:Z.aiTextarea,placeholder:"Describe your changes…",value:p,rows:1,onChange:T=>{g(T.target.value),T.target.style.height="auto",T.target.style.height=`${T.target.scrollHeight}px`},onKeyDown:T=>{T.key==="Enter"&&!T.shiftKey&&(T.preventDefault(),_t()),T.key==="Escape"&&h(!1)}}),m.jsx(A.IconButton,{icon:m.jsx(FR,{size:14}),"aria-label":"Send",size:"xsmall",radius:"full",variant:"neutral",disabled:!p.trim()||y||d,onMouseDown:T=>{T.preventDefault(),_t()}})]})})]})}),jD="_form_1nh56_1",PD="_field_1nh56_8",BD="_urlGroup_1nh56_14",zD="_footer_1nh56_20",$D="_removeBtn_1nh56_28",HD="_footerActions_1nh56_32",Sr={form:jD,field:PD,urlGroup:BD,footer:zD,removeBtn:$D,footerActions:HD};function Qm(t){return t.replace(/^https?:\/\//i,"")}function FD(t){const e=t.trim();return e?/^https?:\/\//i.test(e)?e:`https://${e}`:""}function VD({editor:t,open:e,onClose:n}){const[r,s]=S.useState(""),[i,o]=S.useState(""),[l,a]=S.useState(!1),c=!!t.getAttributes("link").href;S.useEffect(()=>{if(e){const f=t.getAttributes("link");s(Qm(f.href??"")),o(f.title??""),a(f.target==="_blank")}},[e,t]);function u(){const f=FD(r);f?t.chain().focus().extendMarkRange("link").setLink({href:f,target:l?"_blank":null,title:i.trim()||null}).run():t.chain().focus().extendMarkRange("link").unsetLink().run(),n()}function d(){t.chain().focus().extendMarkRange("link").unsetLink().run(),n()}return m.jsx(A.Modal,{open:e,onClose:n,title:c?"Edit link":"Add link",size:"sm",footer:m.jsxs("div",{className:Sr.footer,children:[c&&m.jsx(A.Button,{variant:"danger",size:"sm",onClick:d,className:Sr.removeBtn,children:"Remove"}),m.jsxs("div",{className:Sr.footerActions,children:[m.jsx(A.Button,{variant:"neutral",size:"sm",onClick:n,children:"Cancel"}),m.jsx(A.Button,{variant:"inverted",size:"sm",onClick:u,children:"Save"})]})]}),children:m.jsxs("form",{onSubmit:f=>{f.preventDefault(),u()},noValidate:!0,className:Sr.form,children:[m.jsxs("div",{className:Sr.urlGroup,children:[m.jsxs("div",{className:Sr.field,children:[m.jsx(A.Label,{htmlFor:"link-url",children:"Link Address"}),m.jsx(A.UrlInput,{id:"link-url",value:r,onChange:f=>s(Qm(f.target.value)),autoFocus:!0})]}),m.jsx(A.Checkbox,{label:"Open in new tab",checked:l,onChange:f=>a(f.target.checked)})]}),m.jsxs("div",{className:Sr.field,children:[m.jsx(A.Label,{htmlFor:"link-header",optional:!0,children:"Link header"}),m.jsx(A.Input,{id:"link-header",placeholder:"Enter link header",value:i,onChange:f=>o(f.target.value)}),m.jsx(A.Hint,{children:"Used for accessibility and SEO"})]})]})})}const UD="_chip_v3xby_5",WD={chip:UD},Pi="dynamicVariable",Bi=/\{\{\s*([A-Za-z0-9_.-]+)\s*\}\}/g,eg=/<span\s+data-dynamic-variable="true"\s+data-key="([A-Za-z0-9_.-]*)"\s*>[^<]*<\/span>/g;function tg(t){return typeof t=="string"?t.replace(/[^A-Za-z0-9_.-]/g,""):""}function wx(t){const e=new Map;for(const n of t??[])n&&typeof n.key=="string"&&n.key&&e.set(n.key,n);return e}function ng(t){return t.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function qD(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function KD(t){const e=t.label||t.key;return`<span data-dynamic-variable="true" data-key="${ng(t.key)}" data-label="${ng(e)}">${qD(e)}</span>`}function xx(t){return!t||t.indexOf("data-dynamic-variable")===-1?t:(eg.lastIndex=0,t.replace(eg,(e,n)=>`{{${n}}}`))}function rg(t,e){return Bi.lastIndex=0,t.replace(Bi,(n,r)=>{const s=e.get(r);return s?KD(s):n})}function ki(t,e){if(!t)return t;const n=wx(e);if(n.size===0)return t;let r="",s=0;for(;s<t.length;){const i=t.indexOf("<",s);if(i===-1){r+=rg(t.slice(s),n);break}r+=rg(t.slice(s,i),n);const o=t.indexOf(">",i);if(o===-1){r+=t.slice(i);break}r+=t.slice(i,o+1),s=o+1}return r}function JD(t,e,n){const r=t.text??"",s=e.schema,i=[];let o=0;Bi.lastIndex=0;let l=Bi.exec(r);for(;l;){const a=n.get(l[1]);a&&(l.index>o&&i.push(s.text(r.slice(o,l.index),t.marks)),i.push(e.create({key:a.key,label:a.label||a.key},null,t.marks)),o=l.index+l[0].length),l=Bi.exec(r)}return i.length===0?[t]:(o<r.length&&i.push(s.text(r.slice(o),t.marks)),i)}function vx(t,e,n){if(n.size===0)return t;const r=[];return t.forEach(s=>{s.isText?r.push(...JD(s,e,n)):s.content.size>0?r.push(s.copy(vx(s.content,e,n))):r.push(s)}),j.fromArray(r)}const kx=ke.create({name:Pi,inline:!0,group:"inline",atom:!0,selectable:!0,draggable:!1,addOptions(){return{variables:[]}},addStorage(){var t;return{variables:((t=this.options)==null?void 0:t.variables)??[]}},addAttributes(){return{key:{default:"",parseHTML:t=>tg(t.getAttribute("data-key")),renderHTML:()=>({})},label:{default:null,parseHTML:t=>t.getAttribute("data-label")||t.textContent||null,renderHTML:()=>({})}}},parseHTML(){return[{tag:"span[data-dynamic-variable]"}]},renderHTML({node:t}){const e=tg(t.attrs.key),n=t.attrs.label||e;return["span",{"data-dynamic-variable":"true","data-key":e},n]},renderText({node:t}){return`{{${t.attrs.key}}}`},addNodeView(){return({node:t})=>{const e=document.createElement("span"),n=r=>{e.setAttribute("data-dynamic-variable","true"),e.setAttribute("data-key",r.attrs.key),e.setAttribute("contenteditable","false"),e.setAttribute("title",`{{${r.attrs.key}}}`),e.className=WD.chip,e.textContent=r.attrs.label||r.attrs.key};return n(t),{dom:e,update(r){return r.type.name!==Pi?!1:(n(r),!0)},ignoreMutation:()=>!0}}},addCommands(){return{insertDynamicVariable:t=>({commands:e})=>e.insertContent({type:this.name,attrs:{key:t.key,label:t.label||t.key}})}},addKeyboardShortcuts(){const t=e=>()=>{const{state:n,view:r}=this.editor,{selection:s}=n;if(s instanceof Y&&s.node.type.name===this.name)return r.dispatch(n.tr.deleteSelection()),!0;if(!s.empty)return!1;const i=s.$from,o=e===-1?i.nodeBefore:i.nodeAfter;if(!o||o.type.name!==this.name)return!1;const l=e===-1?i.pos-o.nodeSize:i.pos;return r.dispatch(n.tr.delete(l,l+o.nodeSize)),!0};return{Backspace:t(-1),Delete:t(1)}},addProseMirrorPlugins(){const t=this.type,e=this.editor,n=this.options.variables;return[new ce({key:new ae("dynamicVariablePaste"),props:{transformPasted:r=>{var o,l;const s=((l=(o=e==null?void 0:e.storage)==null?void 0:o[Pi])==null?void 0:l.variables)??n,i=wx(s);return i.size===0?r:new K(vx(r.content,t,i),r.openStart,r.openEnd)}}})]}}),GD=SN.extend({addAttributes(){var t;return{...(t=this.parent)==null?void 0:t.call(this),title:{default:null}}}});function Xo(t){return xx(t.getHTML())}const YD=S.forwardRef(function({value:e,defaultValue:n,placeholder:r,minHeight:s,maxHeight:i="400px",onChange:o,onFocus:l,onBlur:a,error:c=!1,disabled:u=!1,readOnly:d=!1,variant:f="white",compact:h=!1,className:p,onAiSubmit:g,aiSubmitDisabled:y,variables:b,showVariablePicker:w=!1,onVariableInsert:v},x){const[k,C]=S.useState(!1),[E,O]=S.useState(!1),[_,M]=S.useState(""),D=S.useRef(!1),R=(b??[]).map(U=>`${U.key}\0${U.label}`).join(""),L=S.useMemo(()=>b??[],[R]),I=O0({extensions:[T1.configure({heading:{levels:[1,2,3,4,5,6]},link:!1}),_1.configure({multicolor:!0}),GD.configure({openOnClick:!1}),Jf.configure({resizable:!1}),Kf,qf,Wf,...r!==void 0?[A1.configure({placeholder:r})]:[],Gf,Yf,qI.configure({types:["heading","paragraph"]}),jO,kx.configure({variables:L})],content:ki(e??n??"",L),editable:!u&&!d,shouldRerenderOnTransaction:!1,onUpdate({editor:U}){D.current=!0,o==null||o(U.isEmpty?null:Xo(U))},onFocus(){l==null||l()},onBlur(){a==null||a()}});S.useEffect(()=>{I==null||I.setEditable(!u&&!d)},[I,u,d]),S.useEffect(()=>{if(!I||e===void 0)return;if(D.current){D.current=!1;return}Xo(I)!==e&&I.commands.setContent(ki(e??"",L),{emitUpdate:!1})},[I,e,L]),S.useEffect(()=>{if(!I)return;const U=I.storage[Pi];U&&(U.variables=L)},[I,L]);const N=S.useRef(R);S.useEffect(()=>{I&&N.current!==R&&(N.current=R,I.commands.setContent(ki(Xo(I),L),{emitUpdate:!1}))},[I,R,L]),S.useImperativeHandle(x,()=>({focus:(U="end")=>I==null?void 0:I.commands.focus(U)}));function z(){I&&(E?I.commands.setContent(ki(_,L)):M(Xo(I)),O(U=>!U))}const H=[En.wrapper,En[f],c&&En.error,u&&En.disabled,d&&En.readOnly,p].filter(Boolean).join(" ");return m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:H,style:s?{"--rte-min-height":s}:void 0,onClick:U=>{if(u||d||E)return;const q=U.target;if(q.closest('button, input, select, a, [role="menu"], [role="menuitem"], [role="menuitemradio"]'))return;const de=U.currentTarget.querySelector(".ProseMirror");de&&de.contains(q)||I==null||I.commands.focus("end")},children:[I&&!d&&m.jsx("div",{className:En.menuBarRegion,children:m.jsx(LD,{editor:I,disabled:u,showHtml:E,compact:h,onLinkClick:()=>C(!0),onCodeClick:z,variables:L,showVariablePicker:w,onVariableInsert:v,onAiSubmit:g,aiSubmitDisabled:y})}),E?m.jsx(A.Scrollable,{size:"thin",maxHeight:i,children:m.jsx(F1,{value:_,onValueChange:M,highlight:U=>ma.highlight(U,ma.languages.markup,"markup"),padding:12,className:En.htmlSource,textareaClassName:En.htmlSourceTextarea,style:{fontFamily:"var(--font-family-code)",fontSize:"var(--font-size-small)",lineHeight:1.6}})}):m.jsx(A.Scrollable,{size:"thin",maxHeight:i,children:m.jsx(Af,{editor:I,className:En.content})})]}),I&&m.jsx(VD,{editor:I,open:k,onClose:()=>C(!1)})]})}),Ge=16;function sg(t,e){var r;const n=t.extensionManager.extensions.find(s=>s.name===e);return typeof((r=n==null?void 0:n.options)==null?void 0:r.onPick)=="function"}const Sx=[{id:"paragraph",label:"Text",icon:m.jsx(kR,{size:Ge}),group:"Basic",shortcut:"/text",keywords:["paragraph","body","plain"],run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setNode("paragraph").run()}},{id:"heading",label:"Heading",icon:m.jsx($R,{size:Ge}),group:"Basic",shortcut:"/heading",keywords:["title","header","h1","h2","h3"],run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setNode("heading",{level:2}).run()}},{id:"bullet-list",label:"Bulleted list",icon:m.jsx(ga,{size:Ge}),group:"Basic",shortcut:"/ul",keywords:["unordered","bullets","points"],run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).toggleBulletList().run()}},{id:"ordered-list",label:"Numbered list",icon:m.jsx(Nw,{size:Ge}),group:"Basic",shortcut:"/ol",keywords:["ordered","numbers","steps"],run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).toggleOrderedList().run()}},{id:"blockquote",label:"Quote",icon:m.jsx(tw,{size:Ge}),group:"Basic",shortcut:"/quote",keywords:["blockquote","citation"],run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).toggleBlockquote().run()}},{id:"code-block",label:"Code",icon:m.jsx(nc,{size:Ge}),group:"Basic",shortcut:"/code",keywords:["snippet","pre","syntax"],run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).toggleCodeBlock().run()}},{id:"divider",label:"Divider",icon:m.jsx(wd,{size:Ge}),group:"Basic",shortcut:"/hr",keywords:["horizontal rule","separator","line"],run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setHorizontalRule().run()}},{id:"table",label:"Table",icon:m.jsx(lw,{size:Ge}),group:"Basic",shortcut:"/table",keywords:["grid","rows","columns","spreadsheet"],run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).insertTable({rows:3,cols:3,withHeaderRow:!0}).run()}},{id:"callout",label:"Callout",icon:m.jsx(LR,{size:Ge}),group:"Basic",shortcut:"/callout",keywords:["note","info","warning","tip","aside"],run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).insertCalloutBlock().run()}},{id:"toggle",label:"Toggle",icon:m.jsx(DR,{size:Ge}),group:"Basic",shortcut:"/toggle",keywords:["accordion","collapse","details","faq","expand"],run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).insertToggleBlock().run()}},{id:"image",label:"Image",icon:m.jsx(zR,{size:Ge}),group:"Media",shortcut:"/image",keywords:["photo","picture","upload","media"],run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).insertImageBlock().run()}},{id:"gallery",label:"Gallery",icon:m.jsx(jR,{size:Ge}),group:"Media",shortcut:"/gallery",keywords:["images","photos","grid","album"],run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).insertGalleryBlock().run()}},{id:"video",label:"Video",icon:m.jsx(q1,{size:Ge}),group:"Media",shortcut:"/video",keywords:["youtube","vimeo","embed","media","mp4"],run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).insertVideoBlock().run()}},{id:"html",label:"HTML",icon:m.jsx(JR,{size:Ge}),group:"Media",shortcut:"/html",keywords:["embed","markup","script","custom","raw"],run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).insertHtmlBlock().run()}},{id:"product",label:"Product",icon:m.jsx(Cw,{size:Ge}),group:"Commerce",shortcut:"/product",keywords:["item","sku","shop","store"],isAvailable:t=>sg(t,"productBlock"),run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).insertProductBlock().run()}},{id:"collection",label:"Collection",icon:m.jsx(Dw,{size:Ge}),group:"Commerce",shortcut:"/collection",keywords:["category","catalog","group"],isAvailable:t=>sg(t,"collectionBlock"),run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).insertCollectionBlock().run()}},{id:"button",label:"Button",icon:m.jsx(_R,{size:Ge}),group:"Media",shortcut:"/button",keywords:["cta","call to action","link"],run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).insertButtonBlock().run()}}];function Cx(t,e,n){const r=n?t.filter(i=>{var o;return((o=i.isAvailable)==null?void 0:o.call(i,n))??!0}):t,s=e.trim().toLowerCase();return s?r.filter(i=>i.label.toLowerCase().includes(s)||(i.keywords??[]).some(o=>o.toLowerCase().includes(s))):r}function Ex(t){const e=[];for(const n of t){const r=e.find(s=>s.group===n.group);r?r.blocks.push(n):e.push({group:n.group,blocks:[n]})}return e}const XD="_panel_1hllz_5",ZD="_menu_1hllz_25",QD="_shortcut_1hllz_31",eL="_empty_1hllz_37",Zo={panel:XD,menu:ZD,shortcut:QD,empty:eL},ig=300,rs=8,tL=S.forwardRef(function({blocks:e,source:n,getAnchor:r,query:s,onSelect:i,onClose:o,emptyLabel:l="No blocks found"},a){const[c,u]=S.useState(0),d=S.useRef(null),f=S.useRef([]),[h,p]=S.useState(null),g=n==="button",y=S.useMemo(()=>Ex(e),[e]),b=S.useMemo(()=>y.flatMap(x=>x.blocks),[y]);S.useEffect(()=>{u(0)},[s,e.length]);const w=S.useCallback(()=>{const x=d.current,k=r();if(!x||!k)return;const C=x.offsetHeight,O=window.innerHeight-k.bottom<C+rs&&k.top>C+rs?k.top-C-rs:k.bottom+rs,_=Math.min(k.left,window.innerWidth-ig-rs);p({top:O,left:Math.max(rs,_)})},[r]);S.useLayoutEffect(w,[w,e.length]),S.useEffect(()=>(window.addEventListener("scroll",w,!0),window.addEventListener("resize",w),()=>{window.removeEventListener("scroll",w,!0),window.removeEventListener("resize",w)}),[w]),S.useEffect(()=>{var x;(x=f.current[c])==null||x.scrollIntoView({block:"nearest"})},[c]);const v=S.useCallback(x=>{const k=b.length;if(x.key==="ArrowDown")return u(C=>k?(C+1)%k:0),!0;if(x.key==="ArrowUp")return u(C=>k?(C-1+k)%k:0),!0;if(x.key==="Enter"){const C=b[c];return C&&i(C),!0}return x.key==="Escape"?(o(),!0):!1},[b,c,i,o]);return S.useImperativeHandle(a,()=>({onKeyDown:v}),[v]),S.useEffect(()=>{if(!g)return;function x(k){v(k)&&(k.preventDefault(),k.stopPropagation())}return document.addEventListener("keydown",x,!0),()=>document.removeEventListener("keydown",x,!0)},[g,v]),S.useEffect(()=>{function x(k){var C;(C=d.current)!=null&&C.contains(k.target)||o()}return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[o]),zs.createPortal(m.jsx("div",{ref:d,className:Zo.panel,style:{top:(h==null?void 0:h.top)??0,left:(h==null?void 0:h.left)??0,width:ig,visibility:h?"visible":"hidden"},children:m.jsx(A.Scrollable,{size:"thin",maxHeight:"320px",children:m.jsxs(A.Menu,{className:Zo.menu,children:[b.length===0&&m.jsx("div",{className:Zo.empty,children:l}),y.map(({group:x,blocks:k},C)=>{const E=y.slice(0,C).reduce((_,M)=>_+M.blocks.length,0),O=k.map((_,M)=>{const D=E+M;return m.jsx("div",{ref:R=>{f.current[D]=R},children:m.jsx(A.MenuItem,{label:_.label,leftIcon:_.icon,rightSlot:_.shortcut?m.jsx("span",{className:Zo.shortcut,children:_.shortcut}):void 0,forceHover:D===c,onClick:()=>i(_)})},_.id)});return g?m.jsxs("div",{role:"group","aria-label":x,children:[m.jsx(A.MenuTitle,{children:x}),O]},x):m.jsx(A.MenuGroup,{label:x,children:O},x)})]})})}),document.body)});function nL(t){var e;const{char:n,allowSpaces:r,allowToIncludeChar:s,allowedPrefixes:i,startOfLine:o,$position:l}=t,a=r&&!s,c=aA(n),u=new RegExp(`\\s${c}$`),d=o?"^":"",f=s?"":c,h=a?new RegExp(`${d}${c}.*?(?=\\s${f}|$)`,"gm"):new RegExp(`${d}(?:^)?${c}[^\\s${f}]*`,"gm"),p=((e=l.nodeBefore)==null?void 0:e.isText)&&l.nodeBefore.text;if(!p)return null;const g=l.pos-p.length,y=Array.from(p.matchAll(h)).pop();if(!y||y.input===void 0||y.index===void 0)return null;const b=y.input.slice(Math.max(0,y.index-1),y.index),w=new RegExp(`^[${i==null?void 0:i.join("")}\0]?$`).test(b);if(i!==null&&!w)return null;const v=g+y.index;let x=v+y[0].length;return a&&u.test(p.slice(x-1,x+1))&&(y[0]+=" ",x+=1),v<l.pos&&x>=l.pos?{range:{from:v,to:x},query:y[0].slice(n.length),text:y[0]}:null}function rL(t){return t.docChanged?t.steps.some(e=>{const n=e.slice;if(!(n!=null&&n.content))return!1;const r=n.content.textBetween(0,n.content.size,`
|
|
391
|
-
`);return/\s/.test(r)}):!1}var sL=new ae("suggestion");function iL({pluginKey:t=sL,editor:e,char:n="@",allowSpaces:r=!1,allowToIncludeChar:s=!1,allowedPrefixes:i=[" "],startOfLine:o=!1,decorationTag:l="span",decorationClass:a="suggestion",decorationContent:c="",decorationEmptyClass:u="is-empty",command:d=()=>null,items:f=()=>[],render:h=()=>({}),allow:p=()=>!0,findSuggestionMatch:g=nL,shouldShow:y,shouldResetDismissed:b}){let w;const v=h==null?void 0:h(),x=r&&!s,k=()=>{const M=e.state.selection.$anchor.pos,D=e.view.coordsAtPos(M),{top:R,right:L,bottom:I,left:N}=D;try{return new DOMRect(N,R,L-N,I-R)}catch{return null}},C=(M,D)=>D?()=>{const R=t.getState(e.state),L=R==null?void 0:R.decorationId,I=M.dom.querySelector(`[data-decoration-id="${L}"]`);return(I==null?void 0:I.getBoundingClientRect())||null}:k,E=({match:M,dismissedRange:D,state:R,transaction:L})=>b!=null&&b({editor:e,state:R,range:D,match:M,transaction:L,allowSpaces:x})?!1:x?M.range.from===D.from:M.range.from===D.from&&!rL(L);function O(M,D){var R;try{const I=t.getState(M.state),N=I!=null&&I.decorationId?M.dom.querySelector(`[data-decoration-id="${I.decorationId}"]`):null,z={editor:e,range:(I==null?void 0:I.range)||{from:0,to:0},query:(I==null?void 0:I.query)||null,text:(I==null?void 0:I.text)||null,items:[],command:H=>d({editor:e,range:(I==null?void 0:I.range)||{from:0,to:0},props:H}),decorationNode:N,clientRect:C(M,N)};(R=v==null?void 0:v.onExit)==null||R.call(v,z)}catch{}const L=M.state.tr.setMeta(D,{exit:!0});M.dispatch(L)}const _=new ce({key:t,view(){return{update:async(M,D)=>{var R,L,I,N,z,H,U;const q=(R=this.key)==null?void 0:R.getState(D),de=(L=this.key)==null?void 0:L.getState(M.state),ve=q.active&&de.active&&q.range.from!==de.range.from,Ee=!q.active&&de.active,Ct=q.active&&!de.active,Me=!Ee&&!Ct&&q.query!==de.query,Ae=Ee||ve&&Me,ze=Me||ve,$=Ct||ve&&Me;if(!Ae&&!ze&&!$)return;const F=$&&!Ae?q:de,Ut=M.dom.querySelector(`[data-decoration-id="${F.decorationId}"]`);w={editor:e,range:F.range,query:F.query,text:F.text,items:[],command:_t=>d({editor:e,range:F.range,props:_t}),decorationNode:Ut,clientRect:C(M,Ut)},Ae&&((I=v==null?void 0:v.onBeforeStart)==null||I.call(v,w)),ze&&((N=v==null?void 0:v.onBeforeUpdate)==null||N.call(v,w)),(ze||Ae)&&(w.items=await f({editor:e,query:F.query})),$&&((z=v==null?void 0:v.onExit)==null||z.call(v,w)),ze&&((H=v==null?void 0:v.onUpdate)==null||H.call(v,w)),Ae&&((U=v==null?void 0:v.onStart)==null||U.call(v,w))},destroy:()=>{var M;w&&((M=v==null?void 0:v.onExit)==null||M.call(v,w))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1,dismissedRange:null}},apply(M,D,R,L){const{isEditable:I}=e,{composing:N}=e.view,{selection:z}=M,{empty:H,from:U}=z,q={...D},de=M.getMeta(t);if(de&&de.exit)return q.active=!1,q.decorationId=null,q.range={from:0,to:0},q.query=null,q.text=null,q.dismissedRange=D.active?{...D.range}:D.dismissedRange,q;if(q.composing=N,M.docChanged&&q.dismissedRange!==null&&(q.dismissedRange={from:M.mapping.map(q.dismissedRange.from),to:M.mapping.map(q.dismissedRange.to)}),I&&(H||e.view.composing)){(U<D.range.from||U>D.range.to)&&!N&&!D.composing&&(q.active=!1);const ve=g({char:n,allowSpaces:r,allowToIncludeChar:s,allowedPrefixes:i,startOfLine:o,$position:z.$from}),Ee=`id_${Math.floor(Math.random()*4294967295)}`;ve&&p({editor:e,state:L,range:ve.range,isActive:D.active})&&(!y||y({editor:e,range:ve.range,query:ve.query,text:ve.text,transaction:M}))?(q.dismissedRange!==null&&!E({match:ve,dismissedRange:q.dismissedRange,state:L,transaction:M})&&(q.dismissedRange=null),q.dismissedRange===null?(q.active=!0,q.decorationId=D.decorationId?D.decorationId:Ee,q.range=ve.range,q.query=ve.query,q.text=ve.text):q.active=!1):(ve||(q.dismissedRange=null),q.active=!1)}else q.active=!1;return q.active||(q.decorationId=null,q.range={from:0,to:0},q.query=null,q.text=null),q}},props:{handleKeyDown(M,D){var R,L;const{active:I,range:N}=_.getState(M.state);if(!I)return!1;if(D.key==="Escape"||D.key==="Esc"){const H=_.getState(M.state);return(R=v==null?void 0:v.onKeyDown)==null||R.call(v,{view:M,event:D,range:H.range}),O(M,t),!0}return((L=v==null?void 0:v.onKeyDown)==null?void 0:L.call(v,{view:M,event:D,range:N}))||!1},decorations(M){const{active:D,range:R,decorationId:L,query:I}=_.getState(M);if(!D)return null;const N=!(I!=null&&I.length),z=[a];return N&&z.push(u),he.create(M.doc,[De.inline(R.from,R.to,{nodeName:l,class:z.join(" "),"data-decoration-id":L,"data-decoration-content":c})])}}});return _}var oL=iL;const Mx=new ae("blockEditorSlashCommand"),Tx=ie.create({name:"blockEditorSlashCommand",addOptions(){return{onStateChange:()=>{},onKeyDown:()=>!1}},addProseMirrorPlugins(){const t=this.options;return[oL({editor:this.editor,pluginKey:Mx,char:"/",startOfLine:!0,allow:({state:e,range:n})=>e.doc.resolve(n.from).parent.type.name!=="codeBlock",items:()=>[],render:()=>({onStart:e=>t.onStateChange({range:e.range,query:e.query,getRect:()=>{var n;return((n=e.clientRect)==null?void 0:n.call(e))??null}}),onUpdate:e=>t.onStateChange({range:e.range,query:e.query,getRect:()=>{var n;return((n=e.clientRect)==null?void 0:n.call(e))??null}}),onKeyDown:({event:e})=>t.onKeyDown(e),onExit:()=>t.onStateChange(null)})})]}});function Vs({commands:t,state:e,node:n}){const{$from:r}=e.selection,s=r.depth>0,o=(s?r.after():r.pos)>=e.doc.content.size?[n,{type:"paragraph"}]:[n];return s&&r.parent.type.name==="paragraph"&&r.parent.content.size===0?t.insertContentAt({from:r.before(),to:r.after()},o):t.insertContent(o)}const lL="_wrapper_1wcz7_5",aL="_normal_1wcz7_10",cL="_wide_1wcz7_14",uL="_full_1wcz7_23",dL="_selected_1wcz7_29",fL="_figure_1wcz7_29",hL="_placeholder_1wcz7_30",pL="_fileInput_1wcz7_34",mL="_image_1wcz7_45",gL="_toolbar_1wcz7_58",yL="_toolbarDivider_1wcz7_79",bL="_altToggle_1wcz7_91",wL="_altToggleSet_1wcz7_120",xL="_caption_1wcz7_130",vL="_captionInput_1wcz7_138",kL="_captionAlt_1wcz7_167",SL="_altBadge_1wcz7_174",CL="_altInput_1wcz7_186",EL="_overlay_1wcz7_200",ML="_dragOver_1wcz7_224",TL="_placeholderBody_1wcz7_229",AL="_placeholderIcon_1wcz7_245",_L="_placeholderText_1wcz7_249",NL="_urlInput_1wcz7_254",OL="_placeholderDelete_1wcz7_271",IL="_error_1wcz7_284",me={wrapper:lL,normal:aL,wide:cL,full:uL,selected:dL,figure:fL,placeholder:hL,fileInput:pL,image:mL,toolbar:gL,toolbarDivider:yL,altToggle:bL,altToggleSet:wL,caption:xL,captionInput:vL,captionAlt:kL,altBadge:SL,altInput:CL,overlay:EL,dragOver:ML,placeholderBody:TL,placeholderIcon:AL,placeholderText:_L,urlInput:NL,placeholderDelete:OL,error:IL},RL=[{value:"normal",label:"Regular width",icon:Zf},{value:"wide",label:"Wide",icon:eh},{value:"full",label:"Full width",icon:th}];function DL({node:t,updateAttributes:e,deleteNode:n,editor:r,selected:s,extension:i}){const{src:o,alt:l,caption:a,layout:c}=t.attrs,u=i.options,d=S.useRef(null),f=S.useRef(null),[h,p]=S.useState(!1),[g,y]=S.useState(null),[b,w]=S.useState(!1),[v,x]=S.useState(!1),k=r.isEditable;S.useEffect(()=>{var M;v&&((M=f.current)==null||M.focus())},[v]);async function C(M){if(!u.onUpload){y("Uploading is not configured");return}y(null),p(!0);try{const D=await u.onUpload(M);e({src:D})}catch(D){y(D instanceof Error?D.message:"Upload failed")}finally{p(!1)}}function E(){var M;y(null),(M=d.current)==null||M.click()}function O(M){if(!v)return;const D=M.relatedTarget;D&&M.currentTarget.contains(D)||x(!1)}const _=[me.wrapper,me[c],s&&me.selected].filter(Boolean).join(" ");return m.jsxs(wr,{className:_,"data-drag-handle":!0,children:[m.jsx("input",{ref:d,type:"file",accept:u.accept,className:me.fileInput,onChange:M=>{var R;const D=(R=M.target.files)==null?void 0:R[0];M.target.value="",D&&C(D)}}),o?m.jsxs("figure",{className:me.figure,contentEditable:!1,onBlur:O,children:[m.jsx("img",{src:o,alt:l??"",className:me.image}),k&&m.jsxs("div",{className:me.toolbar,children:[RL.map(({value:M,label:D,icon:R})=>m.jsx(A.Tooltip,{content:D,children:m.jsx(A.IconButton,{"aria-label":D,variant:c===M?"neutral":"transparent",size:"xsmall",icon:m.jsx(R,{size:14}),onClick:()=>e({layout:M})})},M)),m.jsx("span",{className:me.toolbarDivider}),m.jsx(A.Tooltip,{content:l?`Alt text: ${l}`:"Describe this image (alt text)",children:m.jsx("button",{type:"button","aria-label":"Edit alt text","aria-pressed":v,className:[me.altToggle,l&&me.altToggleSet].filter(Boolean).join(" "),onClick:()=>x(M=>!M),children:"ALT"})}),m.jsx("span",{className:me.toolbarDivider}),m.jsx(A.Tooltip,{content:"Replace",children:m.jsx(A.IconButton,{"aria-label":"Replace image",variant:"transparent",size:"xsmall",icon:m.jsx(Qf,{size:14}),onClick:E})}),m.jsx(A.Tooltip,{content:"Delete",children:m.jsx(A.IconButton,{"aria-label":"Delete image",variant:"transparent",size:"xsmall",icon:m.jsx(St,{size:14}),onClick:n})})]}),(k||a)&&m.jsxs("figcaption",{className:[me.caption,v&&me.captionAlt].filter(Boolean).join(" "),children:[!k&&a,k&&v&&m.jsxs(m.Fragment,{children:[m.jsx("span",{className:me.altBadge,"aria-hidden":"true",children:"ALT"}),m.jsx("input",{ref:f,type:"text",className:[me.captionInput,me.altInput].join(" "),value:l??"","aria-label":"Alt text",placeholder:"Describe this image for screen readers",onChange:M=>e({alt:M.target.value}),onKeyDown:M=>{M.key!=="Enter"&&M.key!=="Escape"||(M.preventDefault(),x(!1))}})]}),k&&!v&&m.jsx("input",{type:"text",className:me.captionInput,value:a??"","aria-label":"Caption",placeholder:"Type caption for image (optional)",onChange:M=>e({caption:M.target.value})})]}),h&&m.jsx("div",{className:me.overlay,children:m.jsx(A.Spinner,{size:"md"})})]}):m.jsxs("div",{className:[me.placeholder,b&&me.dragOver].filter(Boolean).join(" "),contentEditable:!1,onDragOver:M=>{k&&(M.preventDefault(),w(!0))},onDragLeave:()=>w(!1),onDrop:M=>{var R;if(!k)return;M.preventDefault(),w(!1);const D=(R=M.dataTransfer.files)==null?void 0:R[0];D&&C(D)},children:[h?m.jsxs("div",{className:me.placeholderBody,children:[m.jsx(A.Spinner,{size:"md"}),m.jsx("span",{className:me.placeholderText,children:"Uploading…"})]}):m.jsxs(m.Fragment,{children:[m.jsxs("button",{type:"button",className:me.placeholderBody,onClick:E,disabled:!k,children:[m.jsx(kd,{size:22,className:me.placeholderIcon}),m.jsx("span",{className:me.placeholderText,children:u.onUpload?"Click to select an image, or drag one here":"Paste an image URL below"})]}),m.jsx("input",{type:"url",className:me.urlInput,placeholder:"…or paste an image URL",onKeyDown:M=>{if(M.key!=="Enter")return;M.preventDefault();const D=M.target.value.trim();D&&e({src:D})}})]}),g&&m.jsxs("p",{className:me.error,children:[m.jsx(Xf,{size:14}),g]}),k&&m.jsx("div",{className:me.placeholderDelete,children:m.jsx(A.IconButton,{"aria-label":"Remove block",variant:"transparent",size:"xsmall",icon:m.jsx(St,{size:14}),onClick:n})})]})]})}const Ax="image",_x=ke.create({name:Ax,group:"block",atom:!0,draggable:!0,selectable:!0,addOptions(){return{onUpload:void 0,accept:"image/*",HTMLAttributes:{}}},addAttributes(){return{src:{default:null},alt:{default:null},caption:{default:null},layout:{default:"normal",parseHTML:t=>t.getAttribute("data-layout")??"normal",renderHTML:t=>({"data-layout":t.layout})}}},parseHTML(){return[{tag:"figure[data-image-block]"},{tag:"img[src]",getAttrs:t=>({src:t.getAttribute("src"),alt:t.getAttribute("alt")})}]},renderHTML({HTMLAttributes:t,node:e}){const{src:n,alt:r,caption:s}=e.attrs;return["figure",le({"data-image-block":""},this.options.HTMLAttributes,{"data-layout":t["data-layout"]}),["img",{src:n,alt:r??""}],...s?[["figcaption",{},s]]:[]]},addNodeView(){return xr(DL)},addCommands(){return{insertImageBlock:(t={})=>({commands:e,state:n})=>Vs({commands:e,state:n,node:{type:this.name,attrs:{layout:"normal",...t}}})}}}),LL="_wrapper_1mu6t_3",jL="_information_1mu6t_16",PL="_success_1mu6t_21",BL="_warning_1mu6t_26",zL="_error_1mu6t_31",$L="_neutral_1mu6t_36",HL="_selected_1mu6t_41",FL="_marker_1mu6t_46",VL="_emojiButton_1mu6t_54",UL="_accentLine_1mu6t_74",WL="_emojiMenu_1mu6t_84",qL="_emojiGrid_1mu6t_88",KL="_emojiChoice_1mu6t_94",JL="_emojiChoiceActive_1mu6t_115",GL="_body_1mu6t_121",YL="_toolbar_1mu6t_131",XL="_toneButton_1mu6t_151",ZL="_toneSwatch_1mu6t_168",Be={wrapper:LL,information:jL,success:PL,warning:BL,error:zL,neutral:$L,selected:HL,marker:FL,emojiButton:VL,accentLine:UL,emojiMenu:WL,emojiGrid:qL,emojiChoice:KL,emojiChoiceActive:JL,body:GL,toolbar:YL,toneButton:XL,toneSwatch:ZL},QL=["💡","📌","⚠️","✅","❌","🔥","📣","🎯","📝","🚀","❓","⭐"],e2=[{value:"information",label:"Information"},{value:"success",label:"Success"},{value:"warning",label:"Warning"},{value:"error",label:"Error"},{value:"neutral",label:"Neutral"}];function t2({node:t,updateAttributes:e,deleteNode:n,editor:r,selected:s}){const{emoji:i,tone:o}=t.attrs,[l,a]=S.useState(!1),[c,u]=S.useState(!1),d=r.isEditable,f=[Be.wrapper,Be[o],s&&Be.selected].filter(Boolean).join(" ");return m.jsxs(wr,{className:f,children:[m.jsx("div",{className:Be.marker,contentEditable:!1,children:d?m.jsx(A.Popover,{open:l,onOpenChange:a,placement:"bottom-start",bare:!0,trigger:m.jsx("button",{type:"button",className:Be.emojiButton,"aria-label":"Change emoji",children:i||m.jsx("span",{className:Be.accentLine})}),children:m.jsx(A.Menu,{className:Be.emojiMenu,children:m.jsxs("div",{className:Be.emojiGrid,children:[m.jsx("button",{type:"button",className:[Be.emojiChoice,!i&&Be.emojiChoiceActive].filter(Boolean).join(" "),"aria-label":"No emoji",onClick:()=>{e({emoji:null}),a(!1)},children:m.jsx(tD,{size:16})}),QL.map(h=>m.jsx("button",{type:"button",className:[Be.emojiChoice,i===h&&Be.emojiChoiceActive].filter(Boolean).join(" "),onClick:()=>{e({emoji:h}),a(!1)},children:h},h))]})})}):i||m.jsx("span",{className:Be.accentLine})}),m.jsx(L0,{className:Be.body}),d&&m.jsxs("div",{className:Be.toolbar,contentEditable:!1,children:[m.jsx(A.Popover,{open:c,onOpenChange:u,placement:"bottom-end",bare:!0,trigger:m.jsx("button",{type:"button",className:Be.toneButton,"aria-label":"Change colour",children:m.jsx("span",{className:Be.toneSwatch})}),children:m.jsx(A.Menu,{children:e2.map(({value:h,label:p})=>m.jsx(A.MenuItemRadio,{label:p,leftIcon:m.jsx("span",{className:[Be.toneSwatch,Be[h]].join(" ")}),checked:o===h,onClick:()=>{e({tone:h}),u(!1)}},h))})}),m.jsx(A.Tooltip,{content:"Delete",children:m.jsx(A.IconButton,{"aria-label":"Delete callout",variant:"transparent",size:"xsmall",icon:m.jsx(St,{size:14}),onClick:n})})]})]})}const Nx="callout",Ox=ke.create({name:Nx,group:"block",content:"block+",defining:!0,addAttributes(){return{emoji:{default:"💡"},tone:{default:"information",parseHTML:t=>t.getAttribute("data-tone")??"information",renderHTML:t=>({"data-tone":t.tone})}}},parseHTML(){return[{tag:"div[data-callout-block]"}]},renderHTML({HTMLAttributes:t,node:e}){const{emoji:n}=e.attrs;return["div",le({"data-callout-block":""},{"data-tone":t["data-tone"]}),...n?[["span",{"data-callout-emoji":""},n]]:[],["div",{"data-callout-body":""},0]]},addNodeView(){return xr(t2)},addCommands(){return{insertCalloutBlock:(t={})=>({commands:e})=>e.insertContent({type:this.name,attrs:{emoji:"💡",tone:"information",...t},content:[{type:"paragraph"}]})}}}),n2="_wrapper_1bsti_1",r2="_buttonRow_1bsti_6",s2="_selected_1bsti_14",i2="_outline_1bsti_21",o2="_settings_1bsti_31",l2="_fields_1bsti_53",a2="_field_1bsti_53",c2="_fieldLabel_1bsti_65",u2="_input_1bsti_71",d2="_controls_1bsti_89",f2="_styleToggle_1bsti_98",h2="_styleOption_1bsti_105",p2="_styleOptionActive_1bsti_117",m2="_alignGroup_1bsti_122",$e={wrapper:n2,buttonRow:r2,"align-left":"_align-left_1bsti_10","align-center":"_align-center_1bsti_11","align-right":"_align-right_1bsti_12",selected:s2,outline:i2,settings:o2,fields:l2,field:a2,fieldLabel:c2,input:u2,controls:d2,styleToggle:f2,styleOption:h2,styleOptionActive:p2,alignGroup:m2},g2=[{value:"left",label:"Align left",icon:CR},{value:"center",label:"Align centre",icon:ER},{value:"right",label:"Align right",icon:MR}],y2=[{value:"fill",label:"Fill"},{value:"outline",label:"Outline"}];function b2({node:t,updateAttributes:e,deleteNode:n,editor:r,selected:s}){const{text:i,href:o,style:l,align:a}=t.attrs,c=r.isEditable,u=[$e.wrapper,$e[`align-${a}`],s&&$e.selected].filter(Boolean).join(" ");return m.jsxs(wr,{className:u,"data-drag-handle":!0,children:[m.jsx("div",{className:$e.buttonRow,contentEditable:!1,children:m.jsx(A.Button,{variant:l==="fill"?"inverted":"transparent",className:l==="outline"?$e.outline:void 0,onClick:d=>d.preventDefault(),children:i||"Button"})}),c&&m.jsxs("div",{className:$e.settings,contentEditable:!1,children:[m.jsxs("div",{className:$e.fields,children:[m.jsxs("label",{className:$e.field,children:[m.jsx("span",{className:$e.fieldLabel,children:"Button text"}),m.jsx("input",{type:"text",className:$e.input,value:i??"",placeholder:"Add button text",onChange:d=>e({text:d.target.value})})]}),m.jsxs("label",{className:$e.field,children:[m.jsx("span",{className:$e.fieldLabel,children:"Button URL"}),m.jsx("input",{type:"url",className:$e.input,value:o??"",placeholder:"https://",onChange:d=>e({href:d.target.value||null})})]})]}),m.jsxs("div",{className:$e.controls,children:[m.jsx("div",{className:$e.styleToggle,children:y2.map(({value:d,label:f})=>m.jsx("button",{type:"button",className:[$e.styleOption,l===d&&$e.styleOptionActive].filter(Boolean).join(" "),onClick:()=>e({style:d}),children:f},d))}),m.jsx("div",{className:$e.alignGroup,children:g2.map(({value:d,label:f,icon:h})=>m.jsx(A.Tooltip,{content:f,children:m.jsx(A.IconButton,{"aria-label":f,variant:a===d?"neutral":"transparent",size:"xsmall",icon:m.jsx(h,{size:14}),onClick:()=>e({align:d})})},d))}),m.jsx(A.Tooltip,{content:"Delete",children:m.jsx(A.IconButton,{"aria-label":"Delete button block",variant:"transparent",size:"xsmall",icon:m.jsx(St,{size:14}),onClick:n})})]})]})]})}const Ix="buttonBlock",Rx=ke.create({name:Ix,group:"block",atom:!0,draggable:!0,selectable:!0,addAttributes(){return{text:{default:"Button"},href:{default:null},style:{default:"fill",parseHTML:t=>t.getAttribute("data-style")??"fill",renderHTML:t=>({"data-style":t.style})},align:{default:"center",parseHTML:t=>t.getAttribute("data-align")??"center",renderHTML:t=>({"data-align":t.align})}}},parseHTML(){return[{tag:"div[data-button-block]"}]},renderHTML({HTMLAttributes:t,node:e}){const{text:n,href:r}=e.attrs;return["div",le({"data-button-block":""},{"data-style":t["data-style"],"data-align":t["data-align"]}),["a",{href:r??"#"},n??""]]},addNodeView(){return xr(b2)},addCommands(){return{insertButtonBlock:(t={})=>({commands:e,state:n})=>Vs({commands:e,state:n,node:{type:this.name,attrs:{text:"Button",style:"fill",align:"center",...t}}})}}}),w2="_wrapper_1g9li_1",x2="_selected_1g9li_6",v2="_editor_1g9li_6",k2="_previewShell_1g9li_7",S2="_editorHeader_1g9li_19",C2="_label_1g9li_27",E2="_code_1g9li_36",M2="_codeTextarea_1g9li_42",T2="_preview_1g9li_7",A2="_empty_1g9li_71",_2="_previewToolbar_1g9li_79",Wt={wrapper:w2,selected:x2,editor:v2,previewShell:k2,editorHeader:S2,label:C2,code:E2,codeTextarea:M2,preview:T2,empty:A2,previewToolbar:_2};function N2({node:t,updateAttributes:e,deleteNode:n,editor:r,selected:s}){const i=t.attrs.html??"",o=r.isEditable,[l,a]=S.useState(!i),c=[Wt.wrapper,s&&Wt.selected].filter(Boolean).join(" ");return m.jsx(wr,{className:c,"data-drag-handle":!0,children:m.jsx("div",{contentEditable:!1,children:l&&o?m.jsxs("div",{className:Wt.editor,children:[m.jsxs("div",{className:Wt.editorHeader,children:[m.jsx("span",{className:Wt.label,children:"HTML"}),m.jsx(A.Tooltip,{content:"Preview",children:m.jsx(A.IconButton,{"aria-label":"Preview HTML",variant:"transparent",size:"xsmall",icon:m.jsx(VR,{size:14}),onClick:()=>a(!1)})}),m.jsx(A.Tooltip,{content:"Delete",children:m.jsx(A.IconButton,{"aria-label":"Delete HTML block",variant:"transparent",size:"xsmall",icon:m.jsx(St,{size:14}),onClick:n})})]}),m.jsx(F1,{value:i,onValueChange:u=>e({html:u}),highlight:u=>ma.highlight(u,ma.languages.markup,"markup"),padding:12,placeholder:"<p>Paste or write HTML…</p>",className:Wt.code,textareaClassName:Wt.codeTextarea,style:{fontFamily:"var(--font-family-code)",fontSize:"var(--font-size-small)",lineHeight:1.6}})]}):m.jsxs("div",{className:Wt.previewShell,children:[i?m.jsx("div",{className:Wt.preview,dangerouslySetInnerHTML:{__html:i}}):m.jsx("p",{className:Wt.empty,children:"Empty HTML block"}),o&&m.jsxs("div",{className:Wt.previewToolbar,children:[m.jsx(A.Tooltip,{content:"Edit HTML",children:m.jsx(A.IconButton,{"aria-label":"Edit HTML",variant:"transparent",size:"xsmall",icon:m.jsx(nc,{size:14}),onClick:()=>a(!0)})}),m.jsx(A.Tooltip,{content:"Delete",children:m.jsx(A.IconButton,{"aria-label":"Delete HTML block",variant:"transparent",size:"xsmall",icon:m.jsx(St,{size:14}),onClick:n})})]})]})})})}const Dx="htmlBlock",Lx=ke.create({name:Dx,group:"block",atom:!0,draggable:!0,selectable:!0,addAttributes(){return{html:{default:""}}},parseHTML(){return[{tag:"div[data-html-block]",getAttrs:t=>({html:t.innerHTML})}]},renderHTML({node:t}){return["div",le({"data-html-block":""}),t.attrs.html??""]},addNodeView(){return xr(N2)},addCommands(){return{insertHtmlBlock:(t={})=>({commands:e,state:n})=>Vs({commands:e,state:n,node:{type:this.name,attrs:{html:"",...t}}})}}}),O2="_wrapper_n5xg6_3",I2="_normal_n5xg6_8",R2="_wide_n5xg6_12",D2="_full_n5xg6_21",L2="_selected_n5xg6_27",j2="_figure_n5xg6_27",P2="_placeholder_n5xg6_28",B2="_frame_n5xg6_39",z2="_media_n5xg6_52",$2="_toolbar_n5xg6_62",H2="_toolbarDivider_n5xg6_82",F2="_caption_n5xg6_90",V2="_captionInput_n5xg6_98",U2="_placeholderIcon_n5xg6_134",W2="_placeholderText_n5xg6_138",q2="_urlInput_n5xg6_144",K2="_placeholderDelete_n5xg6_162",tt={wrapper:O2,normal:I2,wide:R2,full:D2,selected:L2,figure:j2,placeholder:P2,frame:B2,media:z2,toolbar:$2,toolbarDivider:H2,caption:F2,captionInput:V2,placeholderIcon:U2,placeholderText:W2,urlInput:q2,placeholderDelete:K2},J2=[{value:"normal",label:"Regular width",icon:Zf},{value:"wide",label:"Wide",icon:eh},{value:"full",label:"Full width",icon:th}];function G2({node:t,updateAttributes:e,deleteNode:n,editor:r,selected:s}){const{src:i,caption:o,layout:l}=t.attrs,[a,c]=S.useState(""),u=r.isEditable,d=nh(i??""),f=[tt.wrapper,tt[l],s&&tt.selected].filter(Boolean).join(" ");return m.jsx(wr,{className:f,"data-drag-handle":!0,children:d?m.jsxs("figure",{className:tt.figure,contentEditable:!1,children:[m.jsx("div",{className:tt.frame,children:d.kind==="iframe"?m.jsx("iframe",{src:d.url,title:o??"Video",className:tt.media,frameBorder:"0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0}):m.jsx("video",{src:d.url,className:tt.media,controls:!0})}),u&&m.jsxs("div",{className:tt.toolbar,children:[J2.map(({value:h,label:p,icon:g})=>m.jsx(A.Tooltip,{content:p,children:m.jsx(A.IconButton,{"aria-label":p,variant:l===h?"neutral":"transparent",size:"xsmall",icon:m.jsx(g,{size:14}),onClick:()=>e({layout:h})})},h)),m.jsx("span",{className:tt.toolbarDivider}),m.jsx(A.Tooltip,{content:"Replace",children:m.jsx(A.IconButton,{"aria-label":"Replace video",variant:"transparent",size:"xsmall",icon:m.jsx(Qf,{size:14}),onClick:()=>{c(i??""),e({src:null})}})}),m.jsx(A.Tooltip,{content:"Delete",children:m.jsx(A.IconButton,{"aria-label":"Delete video",variant:"transparent",size:"xsmall",icon:m.jsx(St,{size:14}),onClick:n})})]}),(u||o)&&m.jsx("figcaption",{className:tt.caption,children:u?m.jsx("input",{type:"text",className:tt.captionInput,value:o??"",placeholder:"Type caption for video (optional)",onChange:h=>e({caption:h.target.value})}):o})]}):m.jsxs("div",{className:tt.placeholder,contentEditable:!1,children:[m.jsx(q1,{size:22,className:tt.placeholderIcon}),m.jsx("p",{className:tt.placeholderText,children:"Paste a YouTube, Vimeo or direct video URL"}),m.jsx("input",{type:"url",className:tt.urlInput,value:a,placeholder:"https://youtube.com/watch?v=…",autoFocus:!0,onChange:h=>c(h.target.value),onKeyDown:h=>{if(h.key!=="Enter")return;h.preventDefault();const p=a.trim();p&&e({src:p})}}),u&&m.jsx("div",{className:tt.placeholderDelete,children:m.jsx(A.IconButton,{"aria-label":"Remove block",variant:"transparent",size:"xsmall",icon:m.jsx(St,{size:14}),onClick:n})})]})})}const jx="videoBlock";function nh(t){const e=t.trim();if(!e)return null;const n=e.match(/(?:youtube\.com\/(?:watch\?(?:.*&)?v=|embed\/|shorts\/)|youtu\.be\/)([\w-]{11})/i);if(n)return{kind:"iframe",url:`https://www.youtube.com/embed/${n[1]}`};const r=e.match(/vimeo\.com\/(?:video\/)?(\d+)/i);return r?{kind:"iframe",url:`https://player.vimeo.com/video/${r[1]}`}:{kind:"file",url:e}}const Px=ke.create({name:jx,group:"block",atom:!0,draggable:!0,selectable:!0,addAttributes(){return{src:{default:null},caption:{default:null},layout:{default:"normal",parseHTML:t=>t.getAttribute("data-layout")??"normal",renderHTML:t=>({"data-layout":t.layout})}}},parseHTML(){return[{tag:"figure[data-video-block]"}]},renderHTML({HTMLAttributes:t,node:e}){const{src:n,caption:r}=e.attrs,s=nh(n??"");return["figure",le({"data-video-block":""},{"data-layout":t["data-layout"]}),(s==null?void 0:s.kind)==="file"?["video",{src:s.url,controls:"true"}]:["iframe",{src:(s==null?void 0:s.url)??"",frameborder:"0",allowfullscreen:"true"}],...r?[["figcaption",{},r]]:[]]},addNodeView(){return xr(G2)},addCommands(){return{insertVideoBlock:(t={})=>({commands:e,state:n})=>Vs({commands:e,state:n,node:{type:this.name,attrs:{layout:"normal",...t}}})}}}),Y2="_wrapper_1fr97_3",X2="_normal_1fr97_8",Z2="_wide_1fr97_12",Q2="_full_1fr97_21",ej="_selected_1fr97_27",tj="_figure_1fr97_27",nj="_fileInput_1fr97_32",rj="_grid_1fr97_42",sj="_gridDragOver_1fr97_50",ij="_cell_1fr97_56",oj="_image_1fr97_64",lj="_removeImage_1fr97_71",aj="_cellEditing_1fr97_97",cj="_altBadgeButton_1fr97_105",uj="_altBadgeButtonSet_1fr97_136",dj="_placeholder_1fr97_142",fj="_dragOver_1fr97_153",hj="_placeholderBody_1fr97_158",pj="_placeholderIcon_1fr97_173",mj="_placeholderText_1fr97_177",gj="_toolbar_1fr97_183",yj="_toolbarDivider_1fr97_203",bj="_caption_1fr97_211",wj="_captionInput_1fr97_218",xj="_captionAlt_1fr97_244",vj="_altBadge_1fr97_105",kj="_altInput_1fr97_263",Sj="_error_1fr97_276",ge={wrapper:Y2,normal:X2,wide:Z2,full:Q2,selected:ej,figure:tj,fileInput:nj,grid:rj,gridDragOver:sj,cell:ij,image:oj,removeImage:lj,cellEditing:aj,altBadgeButton:cj,altBadgeButtonSet:uj,placeholder:dj,dragOver:fj,placeholderBody:hj,placeholderIcon:pj,placeholderText:mj,toolbar:gj,toolbarDivider:yj,caption:bj,captionInput:wj,captionAlt:xj,altBadge:vj,altInput:kj,error:Sj},Cj=[{value:"normal",label:"Regular width",icon:Zf},{value:"wide",label:"Wide",icon:eh},{value:"full",label:"Full width",icon:th}],Ej=3;function Mj({node:t,updateAttributes:e,deleteNode:n,editor:r,selected:s,extension:i}){const o=t.attrs.images??[],{caption:l,layout:a}=t.attrs,c=i.options,u=S.useRef(null),d=S.useRef(null),[f,h]=S.useState(!1),[p,g]=S.useState(null),[y,b]=S.useState(!1),[w,v]=S.useState(null),x=r.isEditable,k=w!==null&&w<o.length?w:null;S.useEffect(()=>{var N;k!==null&&((N=d.current)==null||N.focus())},[k]);async function C(N){if(!c.onUpload){g("Uploading is not configured");return}g(null),h(!0);try{const z=[];for(const H of N){const U=await c.onUpload(H);z.push({src:U})}e({images:[...o,...z]})}catch(z){g(z instanceof Error?z.message:"Upload failed")}finally{h(!1)}}function E(N){return Array.from(N.dataTransfer.types??[]).includes("Files")}function O(N){!x||!E(N)||(N.preventDefault(),b(!0))}function _(){b(!1)}function M(N){if(!x||!E(N))return;N.preventDefault(),b(!1);const z=Array.from(N.dataTransfer.files??[]).filter(H=>H.type.startsWith("image/"));z.length&&C(z)}function D(N){e({images:o.filter((z,H)=>H!==N)}),v(null)}function R(N,z){e({images:o.map((H,U)=>U===N?{...H,alt:z}:H)})}function L(N){if(k===null)return;const z=N.relatedTarget;z&&N.currentTarget.contains(z)||v(null)}const I=[ge.wrapper,ge[a],s&&ge.selected].filter(Boolean).join(" ");return m.jsxs(wr,{className:I,"data-drag-handle":!0,children:[m.jsx("input",{ref:u,type:"file",accept:c.accept,multiple:!0,className:ge.fileInput,onChange:N=>{const z=Array.from(N.target.files??[]);N.target.value="",z.length&&C(z)}}),m.jsxs("figure",{className:ge.figure,contentEditable:!1,onBlur:L,onDragOver:O,onDragLeave:_,onDrop:M,children:[o.length>0?m.jsx("div",{className:[ge.grid,y&&ge.gridDragOver].filter(Boolean).join(" "),style:{"--gallery-columns":Math.min(Ej,o.length)},children:o.map((N,z)=>m.jsxs("div",{className:[ge.cell,k===z&&ge.cellEditing].filter(Boolean).join(" "),children:[m.jsx("img",{src:N.src,alt:N.alt??"",className:ge.image}),x&&m.jsxs(m.Fragment,{children:[m.jsx("button",{type:"button",className:[ge.altBadgeButton,N.alt&&ge.altBadgeButtonSet].filter(Boolean).join(" "),"aria-label":`Edit alt text for image ${z+1}`,"aria-pressed":k===z,onClick:()=>v(H=>H===z?null:z),children:"ALT"}),m.jsx("button",{type:"button",className:ge.removeImage,"aria-label":"Remove image",onClick:()=>D(z),children:m.jsx(xR,{size:13})})]})]},`${N.src}-${z}`))}):m.jsx("div",{className:[ge.placeholder,y&&ge.dragOver].filter(Boolean).join(" "),children:m.jsxs("button",{type:"button",className:ge.placeholderBody,onClick:()=>{var N;return(N=u.current)==null?void 0:N.click()},disabled:!x||f,children:[f?m.jsx(A.Spinner,{size:"md"}):m.jsx(kd,{size:22,className:ge.placeholderIcon}),m.jsx("span",{className:ge.placeholderText,children:f?"Uploading…":"Click to select images, or drag them here"})]})}),x&&m.jsxs("div",{className:ge.toolbar,children:[o.length>0&&m.jsxs(m.Fragment,{children:[m.jsx(A.Tooltip,{content:"Add images",children:m.jsx(A.IconButton,{"aria-label":"Add images",variant:"transparent",size:"xsmall",icon:m.jsx(kd,{size:14}),loading:f,onClick:()=>{var N;return(N=u.current)==null?void 0:N.click()}})}),m.jsx("span",{className:ge.toolbarDivider})]}),Cj.map(({value:N,label:z,icon:H})=>m.jsx(A.Tooltip,{content:z,children:m.jsx(A.IconButton,{"aria-label":z,variant:a===N?"neutral":"transparent",size:"xsmall",icon:m.jsx(H,{size:14}),onClick:()=>e({layout:N})})},N)),m.jsx("span",{className:ge.toolbarDivider}),m.jsx(A.Tooltip,{content:"Delete",children:m.jsx(A.IconButton,{"aria-label":"Delete gallery",variant:"transparent",size:"xsmall",icon:m.jsx(St,{size:14}),onClick:n})})]}),p&&m.jsxs("p",{className:ge.error,children:[m.jsx(Xf,{size:14}),p]}),(x||l)&&o.length>0&&m.jsxs("figcaption",{className:[ge.caption,k!==null&&ge.captionAlt].filter(Boolean).join(" "),children:[!x&&l,x&&k!==null&&m.jsxs(m.Fragment,{children:[m.jsxs("span",{className:ge.altBadge,"aria-hidden":"true",children:["ALT ",k+1]}),m.jsx("input",{ref:d,type:"text",className:[ge.captionInput,ge.altInput].join(" "),value:o[k].alt??"","aria-label":`Alt text for image ${k+1}`,placeholder:"Describe this image for screen readers",onChange:N=>R(k,N.target.value),onKeyDown:N=>{N.key!=="Enter"&&N.key!=="Escape"||(N.preventDefault(),v(null))}})]}),x&&k===null&&m.jsx("input",{type:"text",className:ge.captionInput,value:l??"","aria-label":"Caption",placeholder:"Type caption for gallery (optional)",onChange:N=>e({caption:N.target.value})})]})]})]})}const Bx="gallery",zx=ke.create({name:Bx,group:"block",atom:!0,draggable:!0,selectable:!0,addOptions(){return{onUpload:void 0,accept:"image/*"}},addAttributes(){return{images:{default:[],parseHTML:t=>{const e=t.getAttribute("data-images");if(!e)return[];try{return JSON.parse(e)}catch{return[]}},renderHTML:t=>({"data-images":JSON.stringify(t.images??[])})},caption:{default:null},layout:{default:"wide",parseHTML:t=>t.getAttribute("data-layout")??"wide",renderHTML:t=>({"data-layout":t.layout})}}},parseHTML(){return[{tag:"figure[data-gallery-block]"}]},renderHTML({HTMLAttributes:t,node:e}){const n=e.attrs.images??[],{caption:r}=e.attrs;return["figure",le({"data-gallery-block":""},t),["div",{"data-gallery-grid":""},...n.map(s=>["img",{src:s.src,alt:s.alt??""}])],...r?[["figcaption",{},r]]:[]]},addNodeView(){return xr(Mj)},addCommands(){return{insertGalleryBlock:(t={})=>({commands:e,state:n})=>Vs({commands:e,state:n,node:{type:this.name,attrs:{images:[],layout:"wide",...t}}})}}}),Tj="_wrapper_1cd7f_1",Aj="_selected_1cd7f_9",_j="_header_1cd7f_14",Nj="_chevron_1cd7f_22",Oj="_chevronOpen_1cd7f_43",Ij="_summary_1cd7f_47",Rj="_summaryInput_1cd7f_48",Dj="_actions_1cd7f_68",Lj="_defaultState_1cd7f_83",jj="_defaultStateOn_1cd7f_95",Pj="_body_1cd7f_101",Bj="_bodyCollapsed_1cd7f_105",It={wrapper:Tj,selected:Aj,header:_j,chevron:Nj,chevronOpen:Oj,summary:Ij,summaryInput:Rj,actions:Dj,defaultState:Lj,defaultStateOn:jj,body:Pj,bodyCollapsed:Bj};function zj({node:t,updateAttributes:e,deleteNode:n,editor:r,selected:s}){const{summary:i,open:o}=t.attrs,l=r.isEditable,[a,c]=S.useState(!1),u=!a,d=[It.wrapper,s&&It.selected].filter(Boolean).join(" ");return m.jsxs(wr,{className:d,children:[m.jsxs("div",{className:It.header,contentEditable:!1,children:[m.jsx("button",{type:"button",className:[It.chevron,u&&It.chevronOpen].filter(Boolean).join(" "),"aria-label":u?"Collapse":"Expand","aria-expanded":u,onClick:()=>c(f=>!f),children:m.jsx(GR,{size:16})}),l?m.jsx("input",{type:"text",className:It.summaryInput,value:i??"",placeholder:"Toggle heading",onChange:f=>e({summary:f.target.value})}):m.jsx("span",{className:It.summary,children:i}),l&&m.jsxs("div",{className:It.actions,children:[m.jsx(A.Tooltip,{content:o?"Open by default":"Closed by default",children:m.jsx("button",{type:"button",className:[It.defaultState,o&&It.defaultStateOn].filter(Boolean).join(" "),onClick:()=>e({open:!o}),children:o?"Open by default":"Closed by default"})}),m.jsx(A.Tooltip,{content:"Delete",children:m.jsx(A.IconButton,{"aria-label":"Delete toggle",variant:"transparent",size:"xsmall",icon:m.jsx(St,{size:14}),onClick:n})})]})]}),m.jsx(L0,{className:[It.body,!u&&It.bodyCollapsed].filter(Boolean).join(" ")})]})}const $x="toggleBlock",Hx=ke.create({name:$x,group:"block",content:"block+",defining:!0,addAttributes(){return{summary:{default:""},open:{default:!1,parseHTML:t=>t.hasAttribute("open"),renderHTML:t=>t.open?{open:"true"}:{}}}},parseHTML(){return[{tag:"details[data-toggle-block]"}]},renderHTML({HTMLAttributes:t,node:e}){return["details",le({"data-toggle-block":""},t),["summary",{},e.attrs.summary??""],["div",{"data-toggle-body":""},0]]},addNodeView(){return xr(zj)},addCommands(){return{insertToggleBlock:(t={})=>({commands:e})=>e.insertContent({type:this.name,attrs:{summary:"",open:!1,...t},content:[{type:"paragraph"}]})}}}),$j="_wrapper_1uoda_1",Hj="_selected_1uoda_6",Fj="_card_1uoda_6",Vj="_placeholder_1uoda_7",Uj="_thumb_1uoda_23",Wj="_thumbImage_1uoda_35",qj="_thumbFallback_1uoda_42",Kj="_body_1uoda_47",Jj="_title_1uoda_52",Gj="_subtitle_1uoda_64",Yj="_meta_1uoda_70",Xj="_toolbar_1uoda_77",Zj="_placeholderBody_1uoda_110",Qj="_placeholderIcon_1uoda_126",eP="_placeholderText_1uoda_131",tP="_placeholderDelete_1uoda_136",nP="_error_1uoda_149",Ye={wrapper:$j,selected:Hj,card:Fj,placeholder:Vj,thumb:Uj,thumbImage:Wj,thumbFallback:qj,body:Kj,title:Jj,subtitle:Gj,meta:Yj,toolbar:Xj,placeholderBody:Zj,placeholderIcon:Qj,placeholderText:eP,placeholderDelete:tP,error:nP};function rP({node:t,updateAttributes:e,deleteNode:n,editor:r,selected:s,extension:i,noun:o,icon:l}){const a=t.attrs.entity,c=i.options,[u,d]=S.useState(!1),[f,h]=S.useState(null),p=r.isEditable;async function g(){if(!c.onPick){h("No picker is configured");return}h(null),d(!0);try{const b=await c.onPick();b&&e({entity:b})}catch(b){h(b instanceof Error?b.message:"Could not load the selection")}finally{d(!1)}}const y=[Ye.wrapper,s&&Ye.selected].filter(Boolean).join(" ");return m.jsx(wr,{className:y,"data-drag-handle":!0,children:a?m.jsxs("div",{className:Ye.card,contentEditable:!1,children:[m.jsx("div",{className:Ye.thumb,children:a.imageUrl?m.jsx("img",{src:a.imageUrl,alt:"",className:Ye.thumbImage}):m.jsx("span",{className:Ye.thumbFallback,children:l})}),m.jsxs("div",{className:Ye.body,children:[m.jsx("p",{className:Ye.title,children:a.title}),a.subtitle&&m.jsx("p",{className:Ye.subtitle,children:a.subtitle}),a.meta&&m.jsx("p",{className:Ye.meta,children:a.meta})]}),p&&m.jsxs("div",{className:Ye.toolbar,children:[m.jsx(A.Tooltip,{content:`Change ${o}`,children:m.jsx(A.IconButton,{"aria-label":`Change ${o}`,variant:"transparent",size:"xsmall",icon:m.jsx(Qf,{size:14}),loading:u,onClick:g})}),m.jsx(A.Tooltip,{content:"Delete",children:m.jsx(A.IconButton,{"aria-label":`Delete ${o} block`,variant:"transparent",size:"xsmall",icon:m.jsx(St,{size:14}),onClick:n})})]})]}):m.jsxs("div",{className:Ye.placeholder,contentEditable:!1,children:[m.jsxs("button",{type:"button",className:Ye.placeholderBody,onClick:g,disabled:!p||u,children:[u?m.jsx(A.Spinner,{size:"md"}):m.jsx("span",{className:Ye.placeholderIcon,children:l}),m.jsx("span",{className:Ye.placeholderText,children:u?"Opening…":`Click to select a ${o}`})]}),f&&m.jsxs("p",{className:Ye.error,children:[m.jsx(Xf,{size:14}),f]}),p&&m.jsx("div",{className:Ye.placeholderDelete,children:m.jsx(A.IconButton,{"aria-label":"Remove block",variant:"transparent",size:"xsmall",icon:m.jsx(St,{size:14}),onClick:n})})]})})}const Fx="productBlock",Vx="collectionBlock";function Ux(t){return ke.create({name:t.name,group:"block",atom:!0,draggable:!0,selectable:!0,addOptions(){return{onPick:void 0}},addAttributes(){return{entity:{default:null,parseHTML:e=>{const n=e.getAttribute("data-entity");if(!n)return null;try{return JSON.parse(n)}catch{return null}},renderHTML:e=>({"data-entity":e.entity?JSON.stringify(e.entity):null})}}},parseHTML(){return[{tag:`div[${t.dataAttribute}]`}]},renderHTML({HTMLAttributes:e}){return["div",le({[t.dataAttribute]:""},e)]},addNodeView(){return xr(e=>m.jsx(rP,{...e,noun:t.noun,icon:t.icon}))},addCommands(){return{[t.command]:e=>({commands:n,state:r})=>Vs({commands:n,state:r,node:{type:t.name,attrs:{entity:e??null}}})}}})}const Wx=Ux({name:Fx,dataAttribute:"data-product-block",command:"insertProductBlock",noun:"product",icon:m.jsx(Cw,{size:22})}),qx=Ux({name:Vx,dataAttribute:"data-collection-block",command:"insertCollectionBlock",noun:"collection",icon:m.jsx(Dw,{size:22})}),sP="_title_b828n_3",iP={title:sP};function oP({value:t,placeholder:e,readOnly:n,onChange:r,onLeave:s}){const i=S.useRef(null);return S.useLayoutEffect(()=>{const o=i.current;o&&(o.style.height="auto",o.style.height=`${o.scrollHeight}px`)},[t]),m.jsx("textarea",{ref:i,className:iP.title,value:t,placeholder:e,readOnly:n,rows:1,spellCheck:!1,onChange:o=>r(o.target.value.replace(/\n/g,"")),onKeyDown:o=>{(o.key==="Enter"||o.key==="ArrowDown")&&(o.preventDefault(),s())}})}const Kx=["top","right","bottom","left"],og=["start","end"],lg=Kx.reduce((t,e)=>t.concat(e,e+"-"+og[0],e+"-"+og[1]),[]),gn=Math.min,ft=Math.max,ya=Math.round,fn=t=>({x:t,y:t}),lP={left:"right",right:"left",bottom:"top",top:"bottom"};function Nd(t,e,n){return ft(t,gn(e,n))}function $n(t,e){return typeof t=="function"?t(e):t}function Vt(t){return t.split("-")[0]}function Gt(t){return t.split("-")[1]}function Jx(t){return t==="x"?"y":"x"}function rh(t){return t==="y"?"height":"width"}function cn(t){const e=t[0];return e==="t"||e==="b"?"y":"x"}function sh(t){return Jx(cn(t))}function Gx(t,e,n){n===void 0&&(n=!1);const r=Gt(t),s=sh(t),i=rh(s);let o=s==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[i]>e.floating[i]&&(o=wa(o)),[o,wa(o)]}function aP(t){const e=wa(t);return[ba(t),e,ba(e)]}function ba(t){return t.includes("start")?t.replace("start","end"):t.replace("end","start")}const ag=["left","right"],cg=["right","left"],cP=["top","bottom"],uP=["bottom","top"];function dP(t,e,n){switch(t){case"top":case"bottom":return n?e?cg:ag:e?ag:cg;case"left":case"right":return e?cP:uP;default:return[]}}function fP(t,e,n,r){const s=Gt(t);let i=dP(Vt(t),n==="start",r);return s&&(i=i.map(o=>o+"-"+s),e&&(i=i.concat(i.map(ba)))),i}function wa(t){const e=Vt(t);return lP[e]+t.slice(e.length)}function hP(t){return{top:0,right:0,bottom:0,left:0,...t}}function ih(t){return typeof t!="number"?hP(t):{top:t,right:t,bottom:t,left:t}}function Os(t){const{x:e,y:n,width:r,height:s}=t;return{width:r,height:s,top:n,left:e,right:e+r,bottom:n+s,x:e,y:n}}function ug(t,e,n){let{reference:r,floating:s}=t;const i=cn(e),o=sh(e),l=rh(o),a=Vt(e),c=i==="y",u=r.x+r.width/2-s.width/2,d=r.y+r.height/2-s.height/2,f=r[l]/2-s[l]/2;let h;switch(a){case"top":h={x:u,y:r.y-s.height};break;case"bottom":h={x:u,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:d};break;case"left":h={x:r.x-s.width,y:d};break;default:h={x:r.x,y:r.y}}switch(Gt(e)){case"start":h[o]-=f*(n&&c?-1:1);break;case"end":h[o]+=f*(n&&c?-1:1);break}return h}async function pP(t,e){var n;e===void 0&&(e={});const{x:r,y:s,platform:i,rects:o,elements:l,strategy:a}=t,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:f=!1,padding:h=0}=$n(e,t),p=ih(h),y=l[f?d==="floating"?"reference":"floating":d],b=Os(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(y)))==null||n?y:y.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(l.floating)),boundary:c,rootBoundary:u,strategy:a})),w=d==="floating"?{x:r,y:s,width:o.floating.width,height:o.floating.height}:o.reference,v=await(i.getOffsetParent==null?void 0:i.getOffsetParent(l.floating)),x=await(i.isElement==null?void 0:i.isElement(v))?await(i.getScale==null?void 0:i.getScale(v))||{x:1,y:1}:{x:1,y:1},k=Os(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:w,offsetParent:v,strategy:a}):w);return{top:(b.top-k.top+p.top)/x.y,bottom:(k.bottom-b.bottom+p.bottom)/x.y,left:(b.left-k.left+p.left)/x.x,right:(k.right-b.right+p.right)/x.x}}const mP=50,gP=async(t,e,n)=>{const{placement:r="bottom",strategy:s="absolute",middleware:i=[],platform:o}=n,l=o.detectOverflow?o:{...o,detectOverflow:pP},a=await(o.isRTL==null?void 0:o.isRTL(e));let c=await o.getElementRects({reference:t,floating:e,strategy:s}),{x:u,y:d}=ug(c,r,a),f=r,h=0;const p={};for(let g=0;g<i.length;g++){const y=i[g];if(!y)continue;const{name:b,fn:w}=y,{x:v,y:x,data:k,reset:C}=await w({x:u,y:d,initialPlacement:r,placement:f,strategy:s,middlewareData:p,rects:c,platform:l,elements:{reference:t,floating:e}});u=v??u,d=x??d,p[b]={...p[b],...k},C&&h<mP&&(h++,typeof C=="object"&&(C.placement&&(f=C.placement),C.rects&&(c=C.rects===!0?await o.getElementRects({reference:t,floating:e,strategy:s}):C.rects),{x:u,y:d}=ug(c,f,a)),g=-1)}return{x:u,y:d,placement:f,strategy:s,middlewareData:p}},yP=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:r,placement:s,rects:i,platform:o,elements:l,middlewareData:a}=e,{element:c,padding:u=0}=$n(t,e)||{};if(c==null)return{};const d=ih(u),f={x:n,y:r},h=sh(s),p=rh(h),g=await o.getDimensions(c),y=h==="y",b=y?"top":"left",w=y?"bottom":"right",v=y?"clientHeight":"clientWidth",x=i.reference[p]+i.reference[h]-f[h]-i.floating[p],k=f[h]-i.reference[h],C=await(o.getOffsetParent==null?void 0:o.getOffsetParent(c));let E=C?C[v]:0;(!E||!await(o.isElement==null?void 0:o.isElement(C)))&&(E=l.floating[v]||i.floating[p]);const O=x/2-k/2,_=E/2-g[p]/2-1,M=gn(d[b],_),D=gn(d[w],_),R=M,L=E-g[p]-D,I=E/2-g[p]/2+O,N=Nd(R,I,L),z=!a.arrow&&Gt(s)!=null&&I!==N&&i.reference[p]/2-(I<R?M:D)-g[p]/2<0,H=z?I<R?I-R:I-L:0;return{[h]:f[h]+H,data:{[h]:N,centerOffset:I-N-H,...z&&{alignmentOffset:H}},reset:z}}});function bP(t,e,n){return(t?[...n.filter(s=>Gt(s)===t),...n.filter(s=>Gt(s)!==t)]:n.filter(s=>Vt(s)===s)).filter(s=>t?Gt(s)===t||(e?ba(s)!==s:!1):!0)}const wP=function(t){return t===void 0&&(t={}),{name:"autoPlacement",options:t,async fn(e){var n,r,s;const{rects:i,middlewareData:o,placement:l,platform:a,elements:c}=e,{crossAxis:u=!1,alignment:d,allowedPlacements:f=lg,autoAlignment:h=!0,...p}=$n(t,e),g=d!==void 0||f===lg?bP(d||null,h,f):f,y=await a.detectOverflow(e,p),b=((n=o.autoPlacement)==null?void 0:n.index)||0,w=g[b];if(w==null)return{};const v=Gx(w,i,await(a.isRTL==null?void 0:a.isRTL(c.floating)));if(l!==w)return{reset:{placement:g[0]}};const x=[y[Vt(w)],y[v[0]],y[v[1]]],k=[...((r=o.autoPlacement)==null?void 0:r.overflows)||[],{placement:w,overflows:x}],C=g[b+1];if(C)return{data:{index:b+1,overflows:k},reset:{placement:C}};const E=k.map(M=>{const D=Gt(M.placement);return[M.placement,D&&u?M.overflows.slice(0,2).reduce((R,L)=>R+L,0):M.overflows[0],M.overflows]}).sort((M,D)=>M[1]-D[1]),_=((s=E.filter(M=>M[2].slice(0,Gt(M[0])?2:3).every(D=>D<=0))[0])==null?void 0:s[0])||E[0][0];return _!==l?{data:{index:b+1,overflows:k},reset:{placement:_}}:{}}}},xP=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,r;const{placement:s,middlewareData:i,rects:o,initialPlacement:l,platform:a,elements:c}=e,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:f,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:g=!0,...y}=$n(t,e);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const b=Vt(s),w=cn(l),v=Vt(l)===l,x=await(a.isRTL==null?void 0:a.isRTL(c.floating)),k=f||(v||!g?[wa(l)]:aP(l)),C=p!=="none";!f&&C&&k.push(...fP(l,g,p,x));const E=[l,...k],O=await a.detectOverflow(e,y),_=[];let M=((r=i.flip)==null?void 0:r.overflows)||[];if(u&&_.push(O[b]),d){const I=Gx(s,o,x);_.push(O[I[0]],O[I[1]])}if(M=[...M,{placement:s,overflows:_}],!_.every(I=>I<=0)){var D,R;const I=(((D=i.flip)==null?void 0:D.index)||0)+1,N=E[I];if(N&&(!(d==="alignment"?w!==cn(N):!1)||M.every(U=>cn(U.placement)===w?U.overflows[0]>0:!0)))return{data:{index:I,overflows:M},reset:{placement:N}};let z=(R=M.filter(H=>H.overflows[0]<=0).sort((H,U)=>H.overflows[1]-U.overflows[1])[0])==null?void 0:R.placement;if(!z)switch(h){case"bestFit":{var L;const H=(L=M.filter(U=>{if(C){const q=cn(U.placement);return q===w||q==="y"}return!0}).map(U=>[U.placement,U.overflows.filter(q=>q>0).reduce((q,de)=>q+de,0)]).sort((U,q)=>U[1]-q[1])[0])==null?void 0:L[0];H&&(z=H);break}case"initialPlacement":z=l;break}if(s!==z)return{reset:{placement:z}}}return{}}}};function dg(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function fg(t){return Kx.some(e=>t[e]>=0)}const vP=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n,platform:r}=e,{strategy:s="referenceHidden",...i}=$n(t,e);switch(s){case"referenceHidden":{const o=await r.detectOverflow(e,{...i,elementContext:"reference"}),l=dg(o,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:fg(l)}}}case"escaped":{const o=await r.detectOverflow(e,{...i,altBoundary:!0}),l=dg(o,n.floating);return{data:{escapedOffsets:l,escaped:fg(l)}}}default:return{}}}}};function Yx(t){const e=gn(...t.map(i=>i.left)),n=gn(...t.map(i=>i.top)),r=ft(...t.map(i=>i.right)),s=ft(...t.map(i=>i.bottom));return{x:e,y:n,width:r-e,height:s-n}}function kP(t){const e=t.slice().sort((s,i)=>s.y-i.y),n=[];let r=null;for(let s=0;s<e.length;s++){const i=e[s];!r||i.y-r.y>r.height/2?n.push([i]):n[n.length-1].push(i),r=i}return n.map(s=>Os(Yx(s)))}const SP=function(t){return t===void 0&&(t={}),{name:"inline",options:t,async fn(e){const{placement:n,elements:r,rects:s,platform:i,strategy:o}=e,{padding:l=2,x:a,y:c}=$n(t,e),u=Array.from(await(i.getClientRects==null?void 0:i.getClientRects(r.reference))||[]),d=kP(u),f=Os(Yx(u)),h=ih(l);function p(){if(d.length===2&&d[0].left>d[1].right&&a!=null&&c!=null)return d.find(y=>a>y.left-h.left&&a<y.right+h.right&&c>y.top-h.top&&c<y.bottom+h.bottom)||f;if(d.length>=2){if(cn(n)==="y"){const M=d[0],D=d[d.length-1],R=Vt(n)==="top",L=M.top,I=D.bottom,N=R?M.left:D.left,z=R?M.right:D.right,H=z-N,U=I-L;return{top:L,bottom:I,left:N,right:z,width:H,height:U,x:N,y:L}}const y=Vt(n)==="left",b=ft(...d.map(M=>M.right)),w=gn(...d.map(M=>M.left)),v=d.filter(M=>y?M.left===w:M.right===b),x=v[0].top,k=v[v.length-1].bottom,C=w,E=b,O=E-C,_=k-x;return{top:x,bottom:k,left:C,right:E,width:O,height:_,x:C,y:x}}return f}const g=await i.getElementRects({reference:{getBoundingClientRect:p},floating:r.floating,strategy:o});return s.reference.x!==g.reference.x||s.reference.y!==g.reference.y||s.reference.width!==g.reference.width||s.reference.height!==g.reference.height?{reset:{rects:g}}:{}}}},CP=new Set(["left","top"]);async function EP(t,e){const{placement:n,platform:r,elements:s}=t,i=await(r.isRTL==null?void 0:r.isRTL(s.floating)),o=Vt(n),l=Gt(n),a=cn(n)==="y",c=CP.has(o)?-1:1,u=i&&a?-1:1,d=$n(e,t);let{mainAxis:f,crossAxis:h,alignmentAxis:p}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return l&&typeof p=="number"&&(h=l==="end"?p*-1:p),a?{x:h*u,y:f*c}:{x:f*c,y:h*u}}const MP=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,r;const{x:s,y:i,placement:o,middlewareData:l}=e,a=await EP(e,t);return o===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:s+a.x,y:i+a.y,data:{...a,placement:o}}}}},TP=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:r,placement:s,platform:i}=e,{mainAxis:o=!0,crossAxis:l=!1,limiter:a={fn:b=>{let{x:w,y:v}=b;return{x:w,y:v}}},...c}=$n(t,e),u={x:n,y:r},d=await i.detectOverflow(e,c),f=cn(Vt(s)),h=Jx(f);let p=u[h],g=u[f];if(o){const b=h==="y"?"top":"left",w=h==="y"?"bottom":"right",v=p+d[b],x=p-d[w];p=Nd(v,p,x)}if(l){const b=f==="y"?"top":"left",w=f==="y"?"bottom":"right",v=g+d[b],x=g-d[w];g=Nd(v,g,x)}const y=a.fn({...e,[h]:p,[f]:g});return{...y,data:{x:y.x-n,y:y.y-r,enabled:{[h]:o,[f]:l}}}}}},AP=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var n,r;const{placement:s,rects:i,platform:o,elements:l}=e,{apply:a=()=>{},...c}=$n(t,e),u=await o.detectOverflow(e,c),d=Vt(s),f=Gt(s),h=cn(s)==="y",{width:p,height:g}=i.floating;let y,b;d==="top"||d==="bottom"?(y=d,b=f===(await(o.isRTL==null?void 0:o.isRTL(l.floating))?"start":"end")?"left":"right"):(b=d,y=f==="end"?"top":"bottom");const w=g-u.top-u.bottom,v=p-u.left-u.right,x=gn(g-u[y],w),k=gn(p-u[b],v),C=!e.middlewareData.shift;let E=x,O=k;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&(O=v),(r=e.middlewareData.shift)!=null&&r.enabled.y&&(E=w),C&&!f){const M=ft(u.left,0),D=ft(u.right,0),R=ft(u.top,0),L=ft(u.bottom,0);h?O=p-2*(M!==0||D!==0?M+D:ft(u.left,u.right)):E=g-2*(R!==0||L!==0?R+L:ft(u.top,u.bottom))}await a({...e,availableWidth:O,availableHeight:E});const _=await o.getDimensions(l.floating);return p!==_.width||g!==_.height?{reset:{rects:!0}}:{}}}};function rc(){return typeof window<"u"}function Us(t){return Xx(t)?(t.nodeName||"").toLowerCase():"#document"}function At(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function Hn(t){var e;return(e=(Xx(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function Xx(t){return rc()?t instanceof Node||t instanceof At(t).Node:!1}function Xt(t){return rc()?t instanceof Element||t instanceof At(t).Element:!1}function Fn(t){return rc()?t instanceof HTMLElement||t instanceof At(t).HTMLElement:!1}function hg(t){return!rc()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof At(t).ShadowRoot}function ko(t){const{overflow:e,overflowX:n,overflowY:r,display:s}=Zt(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&s!=="inline"&&s!=="contents"}function _P(t){return/^(table|td|th)$/.test(Us(t))}function sc(t){try{if(t.matches(":popover-open"))return!0}catch{}try{return t.matches(":modal")}catch{return!1}}const NP=/transform|translate|scale|rotate|perspective|filter/,OP=/paint|layout|strict|content/,Cr=t=>!!t&&t!=="none";let cu;function oh(t){const e=Xt(t)?Zt(t):t;return Cr(e.transform)||Cr(e.translate)||Cr(e.scale)||Cr(e.rotate)||Cr(e.perspective)||!lh()&&(Cr(e.backdropFilter)||Cr(e.filter))||NP.test(e.willChange||"")||OP.test(e.contain||"")}function IP(t){let e=fr(t);for(;Fn(e)&&!Is(e);){if(oh(e))return e;if(sc(e))return null;e=fr(e)}return null}function lh(){return cu==null&&(cu=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),cu}function Is(t){return/^(html|body|#document)$/.test(Us(t))}function Zt(t){return At(t).getComputedStyle(t)}function ic(t){return Xt(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function fr(t){if(Us(t)==="html")return t;const e=t.assignedSlot||t.parentNode||hg(t)&&t.host||Hn(t);return hg(e)?e.host:e}function Zx(t){const e=fr(t);return Is(e)?t.ownerDocument?t.ownerDocument.body:t.body:Fn(e)&&ko(e)?e:Zx(e)}function Qx(t,e,n){var r;e===void 0&&(e=[]);const s=Zx(t),i=s===((r=t.ownerDocument)==null?void 0:r.body),o=At(s);return i?(Od(o),e.concat(o,o.visualViewport||[],ko(s)?s:[],[])):e.concat(s,Qx(s,[]))}function Od(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function ev(t){const e=Zt(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const s=Fn(t),i=s?t.offsetWidth:n,o=s?t.offsetHeight:r,l=ya(n)!==i||ya(r)!==o;return l&&(n=i,r=o),{width:n,height:r,$:l}}function tv(t){return Xt(t)?t:t.contextElement}function gs(t){const e=tv(t);if(!Fn(e))return fn(1);const n=e.getBoundingClientRect(),{width:r,height:s,$:i}=ev(e);let o=(i?ya(n.width):n.width)/r,l=(i?ya(n.height):n.height)/s;return(!o||!Number.isFinite(o))&&(o=1),(!l||!Number.isFinite(l))&&(l=1),{x:o,y:l}}const RP=fn(0);function nv(t){const e=At(t);return!lh()||!e.visualViewport?RP:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function DP(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==At(t)?!1:e}function no(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const s=t.getBoundingClientRect(),i=tv(t);let o=fn(1);e&&(r?Xt(r)&&(o=gs(r)):o=gs(t));const l=DP(i,n,r)?nv(i):fn(0);let a=(s.left+l.x)/o.x,c=(s.top+l.y)/o.y,u=s.width/o.x,d=s.height/o.y;if(i){const f=At(i),h=r&&Xt(r)?At(r):r;let p=f,g=Od(p);for(;g&&r&&h!==p;){const y=gs(g),b=g.getBoundingClientRect(),w=Zt(g),v=b.left+(g.clientLeft+parseFloat(w.paddingLeft))*y.x,x=b.top+(g.clientTop+parseFloat(w.paddingTop))*y.y;a*=y.x,c*=y.y,u*=y.x,d*=y.y,a+=v,c+=x,p=At(g),g=Od(p)}}return Os({width:u,height:d,x:a,y:c})}function oc(t,e){const n=ic(t).scrollLeft;return e?e.left+n:no(Hn(t)).left+n}function rv(t,e){const n=t.getBoundingClientRect(),r=n.left+e.scrollLeft-oc(t,n),s=n.top+e.scrollTop;return{x:r,y:s}}function LP(t){let{elements:e,rect:n,offsetParent:r,strategy:s}=t;const i=s==="fixed",o=Hn(r),l=e?sc(e.floating):!1;if(r===o||l&&i)return n;let a={scrollLeft:0,scrollTop:0},c=fn(1);const u=fn(0),d=Fn(r);if((d||!d&&!i)&&((Us(r)!=="body"||ko(o))&&(a=ic(r)),d)){const h=no(r);c=gs(r),u.x=h.x+r.clientLeft,u.y=h.y+r.clientTop}const f=o&&!d&&!i?rv(o,a):fn(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-a.scrollLeft*c.x+u.x+f.x,y:n.y*c.y-a.scrollTop*c.y+u.y+f.y}}function jP(t){return Array.from(t.getClientRects())}function PP(t){const e=Hn(t),n=ic(t),r=t.ownerDocument.body,s=ft(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),i=ft(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let o=-n.scrollLeft+oc(t);const l=-n.scrollTop;return Zt(r).direction==="rtl"&&(o+=ft(e.clientWidth,r.clientWidth)-s),{width:s,height:i,x:o,y:l}}const pg=25;function BP(t,e){const n=At(t),r=Hn(t),s=n.visualViewport;let i=r.clientWidth,o=r.clientHeight,l=0,a=0;if(s){i=s.width,o=s.height;const u=lh();(!u||u&&e==="fixed")&&(l=s.offsetLeft,a=s.offsetTop)}const c=oc(r);if(c<=0){const u=r.ownerDocument,d=u.body,f=getComputedStyle(d),h=u.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,p=Math.abs(r.clientWidth-d.clientWidth-h);p<=pg&&(i-=p)}else c<=pg&&(i+=c);return{width:i,height:o,x:l,y:a}}function zP(t,e){const n=no(t,!0,e==="fixed"),r=n.top+t.clientTop,s=n.left+t.clientLeft,i=Fn(t)?gs(t):fn(1),o=t.clientWidth*i.x,l=t.clientHeight*i.y,a=s*i.x,c=r*i.y;return{width:o,height:l,x:a,y:c}}function mg(t,e,n){let r;if(e==="viewport")r=BP(t,n);else if(e==="document")r=PP(Hn(t));else if(Xt(e))r=zP(e,n);else{const s=nv(t);r={x:e.x-s.x,y:e.y-s.y,width:e.width,height:e.height}}return Os(r)}function sv(t,e){const n=fr(t);return n===e||!Xt(n)||Is(n)?!1:Zt(n).position==="fixed"||sv(n,e)}function $P(t,e){const n=e.get(t);if(n)return n;let r=Qx(t,[]).filter(l=>Xt(l)&&Us(l)!=="body"),s=null;const i=Zt(t).position==="fixed";let o=i?fr(t):t;for(;Xt(o)&&!Is(o);){const l=Zt(o),a=oh(o);!a&&l.position==="fixed"&&(s=null),(i?!a&&!s:!a&&l.position==="static"&&!!s&&(s.position==="absolute"||s.position==="fixed")||ko(o)&&!a&&sv(t,o))?r=r.filter(u=>u!==o):s=l,o=fr(o)}return e.set(t,r),r}function HP(t){let{element:e,boundary:n,rootBoundary:r,strategy:s}=t;const o=[...n==="clippingAncestors"?sc(e)?[]:$P(e,this._c):[].concat(n),r],l=mg(e,o[0],s);let a=l.top,c=l.right,u=l.bottom,d=l.left;for(let f=1;f<o.length;f++){const h=mg(e,o[f],s);a=ft(h.top,a),c=gn(h.right,c),u=gn(h.bottom,u),d=ft(h.left,d)}return{width:c-d,height:u-a,x:d,y:a}}function FP(t){const{width:e,height:n}=ev(t);return{width:e,height:n}}function VP(t,e,n){const r=Fn(e),s=Hn(e),i=n==="fixed",o=no(t,!0,i,e);let l={scrollLeft:0,scrollTop:0};const a=fn(0);function c(){a.x=oc(s)}if(r||!r&&!i)if((Us(e)!=="body"||ko(s))&&(l=ic(e)),r){const h=no(e,!0,i,e);a.x=h.x+e.clientLeft,a.y=h.y+e.clientTop}else s&&c();i&&!r&&s&&c();const u=s&&!r&&!i?rv(s,l):fn(0),d=o.left+l.scrollLeft-a.x-u.x,f=o.top+l.scrollTop-a.y-u.y;return{x:d,y:f,width:o.width,height:o.height}}function uu(t){return Zt(t).position==="static"}function gg(t,e){if(!Fn(t)||Zt(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return Hn(t)===n&&(n=n.ownerDocument.body),n}function iv(t,e){const n=At(t);if(sc(t))return n;if(!Fn(t)){let s=fr(t);for(;s&&!Is(s);){if(Xt(s)&&!uu(s))return s;s=fr(s)}return n}let r=gg(t,e);for(;r&&_P(r)&&uu(r);)r=gg(r,e);return r&&Is(r)&&uu(r)&&!oh(r)?n:r||IP(t)||n}const UP=async function(t){const e=this.getOffsetParent||iv,n=this.getDimensions,r=await n(t.floating);return{reference:VP(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function WP(t){return Zt(t).direction==="rtl"}const qP={convertOffsetParentRelativeRectToViewportRelativeRect:LP,getDocumentElement:Hn,getClippingRect:HP,getOffsetParent:iv,getElementRects:UP,getClientRects:jP,getDimensions:FP,getScale:gs,isElement:Xt,isRTL:WP},ov=MP,lv=wP,av=TP,cv=xP,uv=AP,dv=vP,fv=yP,hv=SP,ah=(t,e,n)=>{const r=new Map,s={platform:qP,...n},i={...s.platform,_c:r};return gP(t,e,{...s,platform:i})};function KP(t,e){const n=Math.min(t.top,e.top),r=Math.max(t.bottom,e.bottom),s=Math.min(t.left,e.left),o=Math.max(t.right,e.right)-s,l=r-n,a=s,c=n;return new DOMRect(a,c,o,l)}var JP=class{constructor({editor:t,element:e,view:n,pluginKey:r="bubbleMenu",updateDelay:s=250,resizeDelay:i=60,shouldShow:o,appendTo:l,getReferencedVirtualElement:a,options:c}){this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.floatingUIOptions={strategy:"absolute",placement:"top",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1,onShow:void 0,onHide:void 0,onUpdate:void 0,onDestroy:void 0},this.shouldShow=({view:d,state:f,from:h,to:p})=>{const{doc:g,selection:y}=f,{empty:b}=y,w=!g.textBetween(h,p).length&&Ja(f.selection),v=this.element.contains(document.activeElement);return!(!(d.hasFocus()||v)||b||w||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:d})=>{var f;if(this.editor.isDestroyed){this.destroy();return}if(this.preventHide){this.preventHide=!1;return}d!=null&&d.relatedTarget&&((f=this.element.parentNode)!=null&&f.contains(d.relatedTarget))||(d==null?void 0:d.relatedTarget)!==this.editor.view.dom&&this.hide()},this.handleDebouncedUpdate=(d,f)=>{const h=!(f!=null&&f.selection.eq(d.state.selection)),p=!(f!=null&&f.doc.eq(d.state.doc));!h&&!p||(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(d,h,p,f)},this.updateDelay))},this.updateHandler=(d,f,h,p)=>{const{composing:g}=d;if(g||!f&&!h)return;if(!this.getShouldShow(p)){this.hide();return}this.show(),this.updatePosition()},this.transactionHandler=({transaction:d})=>{const f=d.getMeta(this.pluginKey);f==="updatePosition"?this.updatePosition():f&&typeof f=="object"&&f.type==="updateOptions"?this.updateOptions(f.options):f==="hide"?this.hide():f==="show"&&(this.updatePosition(),this.show())};var u;this.editor=t,this.element=e,this.view=n,this.pluginKey=r,this.updateDelay=s,this.resizeDelay=i,this.appendTo=l,this.scrollTarget=(u=c==null?void 0:c.scrollTarget)!=null?u:window,this.getReferencedVirtualElement=a,this.floatingUIOptions={...this.floatingUIOptions,...c},this.element.tabIndex=0,o&&(this.shouldShow=o),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.addEventListener("dragstart",this.dragstartHandler),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.editor.on("transaction",this.transactionHandler),window.addEventListener("resize",this.resizeHandler),this.scrollTarget.addEventListener("scroll",this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&(this.show(),this.updatePosition())}get middlewares(){const t=[];return this.floatingUIOptions.flip&&t.push(cv(typeof this.floatingUIOptions.flip!="boolean"?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&t.push(av(typeof this.floatingUIOptions.shift!="boolean"?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&t.push(ov(typeof this.floatingUIOptions.offset!="boolean"?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&t.push(fv(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&t.push(uv(typeof this.floatingUIOptions.size!="boolean"?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&t.push(lv(typeof this.floatingUIOptions.autoPlacement!="boolean"?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&t.push(dv(typeof this.floatingUIOptions.hide!="boolean"?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&t.push(hv(typeof this.floatingUIOptions.inline!="boolean"?this.floatingUIOptions.inline:void 0)),t}get virtualElement(){var t,e,n;const{selection:r}=this.editor.state,s=(t=this.getReferencedVirtualElement)==null?void 0:t.call(this);if(s)return s;if(!((n=(e=this.view)==null?void 0:e.dom)!=null&&n.parentNode))return;const i=d0(this.view,r.from,r.to);let o={getBoundingClientRect:()=>i,getClientRects:()=>[i]};if(r instanceof Y){let l=this.view.nodeDOM(r.from);const a=l.dataset.nodeViewWrapper?l:l.querySelector("[data-node-view-wrapper]");a&&(l=a),l&&(o={getBoundingClientRect:()=>l.getBoundingClientRect(),getClientRects:()=>[l.getBoundingClientRect()]})}if(r instanceof ye){const{$anchorCell:l,$headCell:a}=r,c=l?l.pos:a.pos,u=a?a.pos:l.pos,d=this.view.nodeDOM(c),f=this.view.nodeDOM(u);if(!d||!f)return;const h=d===f?d.getBoundingClientRect():KP(d.getBoundingClientRect(),f.getBoundingClientRect());o={getBoundingClientRect:()=>h,getClientRects:()=>[h]}}return o}updatePosition(){if(!this.isVisible)return;const t=this.virtualElement;t&&ah(t,this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:e,y:n,strategy:r,middlewareData:s})=>{var i,o;if(!(!this.isVisible||this.editor.isDestroyed||!this.element.isConnected)){if((i=s.hide)!=null&&i.referenceHidden||(o=s.hide)!=null&&o.escaped){this.element.style.visibility="hidden";return}this.element.style.visibility="visible",this.element.style.width="max-content",this.element.style.position=r,this.element.style.left=`${e}px`,this.element.style.top=`${n}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()}})}update(t,e){const{state:n}=t,r=n.selection.from!==n.selection.to;if(this.updateDelay>0&&r){this.handleDebouncedUpdate(t,e);return}const s=!(e!=null&&e.selection.eq(t.state.selection)),i=!(e!=null&&e.doc.eq(t.state.doc));this.updateHandler(t,s,i,e)}getShouldShow(t){var e;const{state:n}=this.view,{selection:r}=n,{ranges:s}=r,i=Math.min(...s.map(a=>a.$from.pos)),o=Math.max(...s.map(a=>a.$to.pos));return((e=this.shouldShow)==null?void 0:e.call(this,{editor:this.editor,element:this.element,view:this.view,state:n,oldState:t,from:i,to:o}))||!1}show(){var t;if(this.isVisible)return;this.element.style.visibility="visible",this.element.style.opacity="1";const e=typeof this.appendTo=="function"?this.appendTo():this.appendTo;(t=e??this.view.dom.parentElement)==null||t.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}updateOptions(t){var e;if(t.updateDelay!==void 0&&(this.updateDelay=t.updateDelay),t.resizeDelay!==void 0&&(this.resizeDelay=t.resizeDelay),t.appendTo!==void 0&&(this.appendTo=t.appendTo),t.getReferencedVirtualElement!==void 0&&(this.getReferencedVirtualElement=t.getReferencedVirtualElement),t.shouldShow!==void 0&&t.shouldShow&&(this.shouldShow=t.shouldShow),t.options!==void 0){const n=(e=t.options.scrollTarget)!=null?e:window;n!==this.scrollTarget&&(this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.scrollTarget=n,this.scrollTarget.addEventListener("scroll",this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...t.options}}}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener("dragstart",this.dragstartHandler),window.removeEventListener("resize",this.resizeHandler),this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.editor.off("transaction",this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},pv=t=>new ce({key:typeof t.pluginKey=="string"?new ae(t.pluginKey):t.pluginKey,view:e=>new JP({view:e,...t})});ie.create({name:"bubbleMenu",addOptions(){return{element:null,pluginKey:"bubbleMenu",updateDelay:void 0,appendTo:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[pv({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,options:this.options.options,appendTo:this.options.appendTo,getReferencedVirtualElement:this.options.getReferencedVirtualElement,shouldShow:this.options.shouldShow})]:[]}});var GP=class{constructor({editor:t,element:e,view:n,pluginKey:r="floatingMenu",updateDelay:s=250,resizeDelay:i=60,options:o,appendTo:l,shouldShow:a}){this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.shouldShow=({view:u,state:d})=>{const{selection:f}=d,{$anchor:h,empty:p}=f,g=h.depth===1,y=h.parent.isTextblock&&!h.parent.type.spec.code&&!h.parent.textContent&&h.parent.childCount===0&&!this.getTextContent(h.parent);return!(!u.hasFocus()||!p||!g||!y||!this.editor.isEditable)},this.floatingUIOptions={strategy:"absolute",placement:"right",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1},this.updateHandler=(u,d,f,h)=>{const{composing:p}=u;if(p||!d&&!f)return;if(!this.getShouldShow(h)){this.hide();return}this.updatePosition(),this.show()},this.mousedownHandler=()=>{this.preventHide=!0},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:u})=>{var d;if(this.preventHide){this.preventHide=!1;return}u!=null&&u.relatedTarget&&((d=this.element.parentNode)!=null&&d.contains(u.relatedTarget))||(u==null?void 0:u.relatedTarget)!==this.editor.view.dom&&this.hide()},this.transactionHandler=({transaction:u})=>{const d=u.getMeta(this.pluginKey);d==="updatePosition"?this.updatePosition():d&&typeof d=="object"&&d.type==="updateOptions"?this.updateOptions(d.options):d==="hide"?this.hide():d==="show"&&(this.updatePosition(),this.show())},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)};var c;this.editor=t,this.element=e,this.view=n,this.pluginKey=r,this.updateDelay=s,this.resizeDelay=i,this.appendTo=l,this.scrollTarget=(c=o==null?void 0:o.scrollTarget)!=null?c:window,this.floatingUIOptions={...this.floatingUIOptions,...o},this.element.tabIndex=0,a&&(this.shouldShow=a),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.editor.on("transaction",this.transactionHandler),window.addEventListener("resize",this.resizeHandler),this.scrollTarget.addEventListener("scroll",this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&(this.show(),this.updatePosition())}getTextContent(t){return i0(t,{textSerializers:vf(this.editor.schema)})}get middlewares(){const t=[];return this.floatingUIOptions.flip&&t.push(cv(typeof this.floatingUIOptions.flip!="boolean"?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&t.push(av(typeof this.floatingUIOptions.shift!="boolean"?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&t.push(ov(typeof this.floatingUIOptions.offset!="boolean"?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&t.push(fv(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&t.push(uv(typeof this.floatingUIOptions.size!="boolean"?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&t.push(lv(typeof this.floatingUIOptions.autoPlacement!="boolean"?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&t.push(dv(typeof this.floatingUIOptions.hide!="boolean"?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&t.push(hv(typeof this.floatingUIOptions.inline!="boolean"?this.floatingUIOptions.inline:void 0)),t}getShouldShow(t){var e;const{state:n}=this.view,{selection:r}=n,{ranges:s}=r,i=Math.min(...s.map(a=>a.$from.pos)),o=Math.max(...s.map(a=>a.$to.pos));return(e=this.shouldShow)==null?void 0:e.call(this,{editor:this.editor,view:this.view,state:n,oldState:t,from:i,to:o})}updateOptions(t){var e;if(t.updateDelay!==void 0&&(this.updateDelay=t.updateDelay),t.resizeDelay!==void 0&&(this.resizeDelay=t.resizeDelay),t.appendTo!==void 0&&(this.appendTo=t.appendTo),t.shouldShow!==void 0&&t.shouldShow&&(this.shouldShow=t.shouldShow),t.options!==void 0){const n=(e=t.options.scrollTarget)!=null?e:window;n!==this.scrollTarget&&(this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.scrollTarget=n,this.scrollTarget.addEventListener("scroll",this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...t.options}}}updatePosition(){var t,e;if(!((e=(t=this.view)==null?void 0:t.dom)!=null&&e.parentNode))return;const{selection:n}=this.editor.state,r=d0(this.view,n.from,n.to);ah({getBoundingClientRect:()=>r,getClientRects:()=>[r]},this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:i,y:o,strategy:l,middlewareData:a})=>{var c,u;if((c=a.hide)!=null&&c.referenceHidden||(u=a.hide)!=null&&u.escaped){this.element.style.visibility="hidden";return}this.element.style.visibility="visible",this.element.style.width="max-content",this.element.style.position=l,this.element.style.left=`${i}px`,this.element.style.top=`${o}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(t,e){const n=!(e!=null&&e.selection.eq(t.state.selection)),r=!(e!=null&&e.doc.eq(t.state.doc));this.updateHandler(t,n,r,e)}show(){var t;if(this.isVisible)return;this.element.style.visibility="visible",this.element.style.opacity="1";const e=typeof this.appendTo=="function"?this.appendTo():this.appendTo;(t=e??this.view.dom.parentElement)==null||t.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),window.removeEventListener("resize",this.resizeHandler),this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.editor.off("transaction",this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},mv=t=>new ce({key:typeof t.pluginKey=="string"?new ae(t.pluginKey):t.pluginKey,view:e=>new GP({view:e,...t})});ie.create({name:"floatingMenu",addOptions(){return{element:null,options:{},pluginKey:"floatingMenu",updateDelay:void 0,resizeDelay:void 0,appendTo:void 0,shouldShow:null}},addCommands(){return{updateFloatingMenuPosition:()=>({tr:t,dispatch:e})=>(e&&t.setMeta(this.options.pluginKey,"updatePosition"),!0)}},addProseMirrorPlugins(){return this.options.element?[mv({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,resizeDelay:this.options.resizeDelay,options:this.options.options,appendTo:this.options.appendTo,shouldShow:this.options.shouldShow})]:[]}});function gv(t,e){return t??new ae(e)}var YP=typeof window<"u"?S.useLayoutEffect:S.useEffect,yv=new Set(["left","opacity","position","top","visibility","width"]),XP=new Set(["animationIterationCount","aspectRatio","borderImageOutset","borderImageSlice","borderImageWidth","columnCount","columns","fillOpacity","flex","flexGrow","flexShrink","fontWeight","gridArea","gridColumn","gridColumnEnd","gridColumnStart","gridRow","gridRowEnd","gridRowStart","lineClamp","lineHeight","opacity","order","orphans","scale","stopOpacity","strokeDasharray","strokeDashoffset","strokeMiterlimit","strokeOpacity","strokeWidth","tabSize","widows","zIndex","zoom"]),ZP=new Set(["children","className","style"]),QP=new Set(["tabIndex"]),eB=new Set(["accessKey","autoCapitalize","contentEditable","contextMenu","dir","draggable","enterKeyHint","hidden","id","lang","nonce","role","slot","spellCheck","tabIndex","title","translate"]),tB={Blur:"focusout",DoubleClick:"dblclick",Focus:"focusin",MouseEnter:"mouseenter",MouseLeave:"mouseleave"};function Id(t,e){return/^on[A-Z]/.test(t)&&typeof e=="function"}function nB(t){return t.startsWith("aria-")||t.startsWith("data-"),t}function rB(t){return t.startsWith("aria-")||t.startsWith("data-")||eB.has(t)}function bv(t){return t.startsWith("--")?t:t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function sB(t){var e;const n=t.endsWith("Capture"),s=(n?t.slice(0,-7):t).slice(2);return{eventName:(e=tB[s])!=null?e:s.toLowerCase(),options:n?{capture:!0}:void 0}}function iB(t,e){let n=e.defaultPrevented,r=!1;const s=Object.create(e);return Object.defineProperties(s,{nativeEvent:{value:e},currentTarget:{value:t},target:{value:e.target},persist:{value:()=>{}},isDefaultPrevented:{value:()=>n},isPropagationStopped:{value:()=>r},preventDefault:{value:()=>{n=!0,e.preventDefault()}},stopPropagation:{value:()=>{r=!0,e.stopPropagation()}}}),s}function du(t){return QP.has(t)}function yg(t,e,n){if(e==="tabIndex"){t.tabIndex=Number(n);return}t[e]=n}function oB(t,e){if(e==="tabIndex"){t.removeAttribute("tabindex");return}const n=t[e];if(typeof n=="boolean"){t[e]=!1;return}if(typeof n=="number"){t[e]=0;return}t[e]=""}function lB(t,e){return typeof e!="number"||e===0||t.startsWith("--")||XP.has(t)?String(e):`${e}px`}function aB(t,e){yv.has(e)||t.style.removeProperty(bv(e))}function cB(t,e,n){yv.has(e)||t.style.setProperty(bv(e),lB(e,n))}function uB(t,e,n){new Set([...Object.keys(e),...Object.keys(n)]).forEach(s=>{if(ZP.has(s)||!rB(s)||Id(s,e[s])||Id(s,n[s]))return;const i=e[s],o=n[s];if(i===o)return;const l=nB(s);if(o==null||o===!1){du(s)&&oB(t,s),t.removeAttribute(l);return}if(o===!0){du(s)&&yg(t,s,!0),t.setAttribute(l,"");return}if(du(s)){yg(t,s,o);return}t.setAttribute(l,String(o))})}function dB(t,e,n){if(e!==n){if(n){t.className=n;return}t.removeAttribute("class")}}function fB(t,e,n){const r=e??{},s=n??{};new Set([...Object.keys(r),...Object.keys(s)]).forEach(o=>{const l=r[o],a=s[o];if(l!==a){if(a==null){aB(t,o);return}cB(t,o,a)}})}function hB(t,e,n){e.forEach(({eventName:s,listener:i,options:o})=>{t.removeEventListener(s,i,o)});const r=[];return Object.entries(n).forEach(([s,i])=>{if(!Id(s,i))return;const{eventName:o,options:l}=sB(s),a=c=>{i(iB(t,c))};t.addEventListener(o,a,l),r.push({eventName:o,listener:a,options:l})}),r}function wv(t,e){const n=S.useRef({}),r=S.useRef([]);YP(()=>{const s=n.current;return dB(t,s.className,e.className),fB(t,s.style,e.style),uB(t,s,e),r.current=hB(t,r.current,e),n.current=e,()=>{r.current.forEach(({eventName:i,listener:o,options:l})=>{t.removeEventListener(i,o,l)}),r.current=[]}},[t,e])}var xv=S.forwardRef(({pluginKey:t,editor:e,updateDelay:n,resizeDelay:r,appendTo:s,shouldShow:i=null,getReferencedVirtualElement:o,options:l,children:a,...c},u)=>{const d=S.useRef(document.createElement("div")),f=S.useRef(gv(t,"bubbleMenu")).current;wv(d.current,c),typeof u=="function"?u(d.current):u&&(u.current=d.current);const{editor:h}=I0(),p=e||h,g={updateDelay:n,resizeDelay:r,appendTo:s,pluginKey:f,shouldShow:i,getReferencedVirtualElement:o,options:l},y=S.useRef(g);y.current=g;const[b,w]=S.useState(!1),v=S.useRef(!0);return S.useEffect(()=>{if(p!=null&&p.isDestroyed)return;if(!p){console.warn("BubbleMenu component is not rendered inside of an editor component or does not have editor prop.");return}const x=d.current;x.style.visibility="hidden",x.style.position="absolute";const k=pv({...y.current,editor:p,element:x});p.registerPlugin(k);const C=y.current.pluginKey;return v.current=!0,w(!0),()=>{w(!1),p.unregisterPlugin(C),window.requestAnimationFrame(()=>{x.parentNode&&x.parentNode.removeChild(x)})}},[p]),S.useEffect(()=>{if(!(!b||!p||p.isDestroyed)){if(v.current){v.current=!1;return}p.view.dispatch(p.state.tr.setMeta(f,{type:"updateOptions",options:y.current}))}},[b,p,n,r,i,l,s,o,f]),zs.createPortal(a,d.current)});S.forwardRef(({pluginKey:t,editor:e,updateDelay:n,resizeDelay:r,appendTo:s,shouldShow:i=null,options:o,children:l,...a},c)=>{const u=S.useRef(document.createElement("div")),d=S.useRef(gv(t,"floatingMenu")).current;wv(u.current,a),typeof c=="function"?c(u.current):c&&(c.current=u.current);const{editor:f}=I0(),h=e||f,p={updateDelay:n,resizeDelay:r,appendTo:s,pluginKey:d,shouldShow:i,options:o},g=S.useRef(p);g.current=p;const[y,b]=S.useState(!1),w=S.useRef(!0);return S.useEffect(()=>{if(h!=null&&h.isDestroyed)return;if(!h){console.warn("FloatingMenu component is not rendered inside of an editor component or does not have editor prop.");return}const v=u.current;v.style.visibility="hidden",v.style.position="absolute";const x=mv({...g.current,editor:h,element:v});h.registerPlugin(x);const k=g.current.pluginKey;return w.current=!0,b(!0),()=>{b(!1),h.unregisterPlugin(k),window.requestAnimationFrame(()=>{v.parentNode&&v.parentNode.removeChild(v)})}},[h]),S.useEffect(()=>{if(!(!y||!h||h.isDestroyed)){if(w.current){w.current=!1;return}h.view.dispatch(h.state.tr.setMeta(d,{type:"updateOptions",options:g.current}))}},[y,h,n,r,i,o,s,d]),zs.createPortal(l,u.current)});const pB="_menu_y312l_2",mB="_row_y312l_9",gB="_linkRow_y312l_10",yB="_button_y312l_19",bB="_active_y312l_37",wB="_divider_y312l_53",xB="_styleTrigger_y312l_61",vB="_panelWrap_y312l_89",kB="_dropdown_y312l_94",SB="_colorDropdown_y312l_101",CB="_colorPanel_y312l_106",EB="_colorTabs_y312l_113",MB="_colorPickerBody_y312l_118",TB="_colorTab_y312l_113",AB="_colorTabActive_y312l_145",_B="_linkInput_y312l_161",Q={menu:pB,row:mB,linkRow:gB,button:yB,active:bB,divider:wB,styleTrigger:xB,panelWrap:vB,dropdown:kB,colorDropdown:SB,colorPanel:CB,colorTabs:EB,colorPickerBody:MB,colorTab:TB,colorTabActive:AB,linkInput:_B};function ch(t){return t.state.selection instanceof ye}function vv({editor:t}){const e=vo({editor:t,selector:({editor:n})=>({headerRow:n.isActive("tableHeader"),canMerge:n.can().mergeCells(),canSplit:n.can().splitCell()})});return m.jsx(xv,{editor:t,pluginKey:"blockEditorTableMenu",options:{placement:"top",offset:8},shouldShow:({editor:n,state:r,from:s,to:i})=>!n.isEditable||!n.isActive("table")||r.selection instanceof Y?!1:s===i||ch(n),className:Q.menu,children:m.jsxs("div",{className:Q.row,children:[m.jsx(A.Tooltip,{content:"Insert column before",children:m.jsx("button",{type:"button",className:Q.button,onClick:()=>t.chain().focus().addColumnBefore().run(),"aria-label":"Insert column before",children:m.jsx(QR,{size:15})})}),m.jsx(A.Tooltip,{content:"Insert column after",children:m.jsx("button",{type:"button",className:Q.button,onClick:()=>t.chain().focus().addColumnAfter().run(),"aria-label":"Insert column after",children:m.jsx(ZR,{size:15})})}),m.jsx(A.Tooltip,{content:"Delete column",children:m.jsx("button",{type:"button",className:Q.button,onClick:()=>t.chain().focus().deleteColumn().run(),"aria-label":"Delete column",children:m.jsx(KR,{size:15})})}),m.jsx("span",{className:Q.divider}),m.jsx(A.Tooltip,{content:"Insert row above",children:m.jsx("button",{type:"button",className:Q.button,onClick:()=>t.chain().focus().addRowBefore().run(),"aria-label":"Insert row above",children:m.jsx(XR,{size:15})})}),m.jsx(A.Tooltip,{content:"Insert row below",children:m.jsx("button",{type:"button",className:Q.button,onClick:()=>t.chain().focus().addRowAfter().run(),"aria-label":"Insert row below",children:m.jsx(eD,{size:15})})}),m.jsx(A.Tooltip,{content:"Delete row",children:m.jsx("button",{type:"button",className:Q.button,onClick:()=>t.chain().focus().deleteRow().run(),"aria-label":"Delete row",children:m.jsx(OR,{size:15})})}),m.jsx("span",{className:Q.divider}),m.jsx(A.Tooltip,{content:"Toggle header row",children:m.jsx("button",{type:"button",className:[Q.button,e.headerRow&&Q.active].filter(Boolean).join(" "),onClick:()=>t.chain().focus().toggleHeaderRow().run(),"aria-label":"Toggle header row",children:m.jsx(RR,{size:15})})}),e.canSplit?m.jsx(A.Tooltip,{content:"Split cell",children:m.jsx("button",{type:"button",className:Q.button,onClick:()=>t.chain().focus().splitCell().run(),"aria-label":"Split cell",children:m.jsx(TR,{size:15})})}):m.jsx(A.Tooltip,{content:"Merge cells",children:m.jsx("button",{type:"button",className:Q.button,disabled:!e.canMerge,onClick:()=>t.chain().focus().mergeCells().run(),"aria-label":"Merge cells",children:m.jsx(AR,{size:15})})}),m.jsx("span",{className:Q.divider}),m.jsx(A.Tooltip,{content:"Delete table",children:m.jsx("button",{type:"button",className:Q.button,onClick:()=>t.chain().focus().deleteTable().run(),"aria-label":"Delete table",children:m.jsx(St,{size:15})})})]})})}const bg=[1,2,3,4,5,6],NB={1:Td,2:Ad,3:Sd,4:Cd,5:Ed,6:Md};function OB(t){const e=t.trim();return e?/^(https?:\/\/|mailto:|tel:|#|\/)/i.test(e)?e:`https://${e}`:""}function kv({editor:t}){const[e,n]=S.useState(!1),[r,s]=S.useState(""),[i,o]=S.useState(!1),[l,a]=S.useState("text"),[c,u]=S.useState(!1),d=S.useRef(null),f=S.useRef(null),h=vo({editor:t,selector:({editor:x})=>({bold:x.isActive("bold"),italic:x.isActive("italic"),underline:x.isActive("underline"),strike:x.isActive("strike"),code:x.isActive("code"),blockquote:x.isActive("blockquote"),bulletList:x.isActive("bulletList"),orderedList:x.isActive("orderedList"),link:x.isActive("link"),headingLevel:bg.find(k=>x.isActive("heading",{level:k}))??null,textColor:x.getAttributes("textStyle").color??"",highlightColor:x.getAttributes("highlight").color??""})});S.useEffect(()=>{var x;e&&((x=d.current)==null||x.focus())},[e]),S.useEffect(()=>{function x(){n(!1),o(!1),u(!1)}return t.on("selectionUpdate",x),()=>{t.off("selectionUpdate",x)}},[t]);function p(){const{from:x,to:k}=t.state.selection;f.current={from:x,to:k}}function g(){const x=t.chain().focus(),k=f.current;return k&&k.from!==k.to?x.setTextSelection(k):x}function y(x){l==="text"?g().setColor(x).run():g().setHighlight({color:x}).run()}function b(){s(t.getAttributes("link").href??""),n(!0)}function w(){const x=OB(r);x?t.chain().focus().extendMarkRange("link").setLink({href:x}).run():t.chain().focus().extendMarkRange("link").unsetLink().run(),n(!1)}const v=h.headingLevel?`H${h.headingLevel}`:h.blockquote?"Quote":"Text";return m.jsx(xv,{editor:t,options:{placement:"top",offset:8},shouldShow:({editor:x,state:k,from:C,to:E})=>!x.isEditable||C===E||k.selection instanceof Y||ch(x)||x.isActive("codeBlock")?!1:k.doc.textBetween(C,E," "," ").trim().length>0,className:Q.menu,children:e?m.jsxs("div",{className:Q.linkRow,children:[m.jsx("input",{ref:d,type:"text",className:Q.linkInput,value:r,placeholder:"Paste or type a link",onChange:x=>s(x.target.value),onKeyDown:x=>{x.key==="Enter"&&(x.preventDefault(),w()),x.key==="Escape"&&(x.preventDefault(),n(!1))}}),m.jsx("button",{type:"button",className:Q.button,onClick:w,"aria-label":"Apply link",children:m.jsx(YR,{size:15})})]}):m.jsxs("div",{className:Q.row,children:[m.jsxs("div",{className:Q.panelWrap,children:[m.jsxs("button",{type:"button",className:[Q.styleTrigger,c&&Q.active].filter(Boolean).join(" "),onMouseDown:x=>{x.preventDefault(),c||p(),u(k=>!k)},"aria-label":"Text style",children:[m.jsx("span",{children:v}),m.jsx(wl,{size:12})]}),c&&m.jsx("div",{className:Q.dropdown,onMouseDown:x=>x.preventDefault(),children:m.jsxs(A.Menu,{children:[m.jsx(A.MenuItemRadio,{label:"Text",leftIcon:m.jsx(bd,{size:16}),checked:!h.headingLevel&&!h.blockquote,onClick:()=>{g().setParagraph().run(),u(!1)}}),bg.map(x=>{const k=NB[x];return m.jsx(A.MenuItemRadio,{label:`Heading ${x}`,leftIcon:m.jsx(k,{size:16}),checked:h.headingLevel===x,onClick:()=>{g().toggleHeading({level:x}).run(),u(!1)}},x)}),m.jsx(A.MenuItemRadio,{label:"Quote",leftIcon:m.jsx(tw,{size:16}),checked:h.blockquote,onClick:()=>{g().toggleBlockquote().run(),u(!1)}})]})})]}),m.jsx("span",{className:Q.divider}),m.jsx(A.Tooltip,{content:"Bold",children:m.jsx("button",{type:"button",className:[Q.button,h.bold&&Q.active].filter(Boolean).join(" "),onClick:()=>t.chain().focus().toggleBold().run(),"aria-label":"Bold",children:m.jsx(_d,{size:15})})}),m.jsx(A.Tooltip,{content:"Italic",children:m.jsx("button",{type:"button",className:[Q.button,h.italic&&Q.active].filter(Boolean).join(" "),onClick:()=>t.chain().focus().toggleItalic().run(),"aria-label":"Italic",children:m.jsx(vd,{size:15})})}),m.jsx(A.Tooltip,{content:"Underline",children:m.jsx("button",{type:"button",className:[Q.button,h.underline&&Q.active].filter(Boolean).join(" "),onClick:()=>t.chain().focus().toggleUnderline().run(),"aria-label":"Underline",children:m.jsx(Y1,{size:15})})}),m.jsx(A.Tooltip,{content:"Strikethrough",children:m.jsx("button",{type:"button",className:[Q.button,h.strike&&Q.active].filter(Boolean).join(" "),onClick:()=>t.chain().focus().toggleStrike().run(),"aria-label":"Strikethrough",children:m.jsx(uw,{size:15})})}),m.jsx(A.Tooltip,{content:"Inline code",children:m.jsx("button",{type:"button",className:[Q.button,h.code&&Q.active].filter(Boolean).join(" "),onClick:()=>t.chain().focus().toggleCode().run(),"aria-label":"Inline code",children:m.jsx(nc,{size:15})})}),m.jsx("span",{className:Q.divider}),m.jsx(A.Tooltip,{content:"Bulleted list",children:m.jsx("button",{type:"button",className:[Q.button,h.bulletList&&Q.active].filter(Boolean).join(" "),onClick:()=>t.chain().focus().toggleBulletList().run(),"aria-label":"Bulleted list",children:m.jsx(ga,{size:15})})}),m.jsx(A.Tooltip,{content:"Numbered list",children:m.jsx("button",{type:"button",className:[Q.button,h.orderedList&&Q.active].filter(Boolean).join(" "),onClick:()=>t.chain().focus().toggleOrderedList().run(),"aria-label":"Numbered list",children:m.jsx(Nw,{size:15})})}),m.jsx("span",{className:Q.divider}),m.jsxs("div",{className:Q.panelWrap,children:[m.jsx("button",{type:"button",className:[Q.button,i&&Q.active].filter(Boolean).join(" "),onMouseDown:x=>{x.preventDefault(),i||p(),o(k=>!k)},"aria-label":"Colour",children:m.jsx(kw,{size:15})}),i&&m.jsx("div",{className:`${Q.dropdown} ${Q.colorDropdown}`,onMouseDown:x=>x.preventDefault(),children:m.jsxs("div",{className:Q.colorPanel,children:[m.jsxs("div",{className:Q.colorTabs,children:[m.jsx("button",{type:"button",className:[Q.colorTab,l==="text"&&Q.colorTabActive].filter(Boolean).join(" "),onClick:()=>a("text"),children:"Text"}),m.jsx("button",{type:"button",className:[Q.colorTab,l==="bg"&&Q.colorTabActive].filter(Boolean).join(" "),onClick:()=>a("bg"),children:"Background"})]}),m.jsx("div",{className:Q.colorPickerBody,children:m.jsx(A.ColorPicker,{alwaysOpen:!0,value:l==="text"?h.textColor:h.highlightColor,onChange:y})})]})})]}),m.jsx("span",{className:Q.divider}),m.jsx(A.Tooltip,{content:h.link?"Edit link":"Add link",children:m.jsx("button",{type:"button",className:[Q.button,h.link&&Q.active].filter(Boolean).join(" "),onClick:b,"aria-label":h.link?"Edit link":"Add link",children:m.jsx(xd,{size:15})})}),h.link&&m.jsx(A.Tooltip,{content:"Remove link",children:m.jsx("button",{type:"button",className:Q.button,onClick:()=>t.chain().focus().extendMarkRange("link").unsetLink().run(),"aria-label":"Remove link",children:m.jsx(vR,{size:15})})})]})})}const Yt=()=>new Map,Rd=t=>{const e=Yt();return t.forEach((n,r)=>{e.set(r,n)}),e},Vn=(t,e,n)=>{let r=t.get(e);return r===void 0&&t.set(e,r=n()),r},IB=(t,e)=>{const n=[];for(const[r,s]of t)n.push(e(s,r));return n},RB=(t,e)=>{for(const[n,r]of t)if(e(r,n))return!0;return!1},qr=()=>new Set,fu=t=>t[t.length-1],DB=(t,e)=>{for(let n=0;n<e.length;n++)t.push(e[n])},Kr=Array.from,uh=(t,e)=>{for(let n=0;n<t.length;n++)if(!e(t[n],n,t))return!1;return!0},dh=(t,e)=>{for(let n=0;n<t.length;n++)if(e(t[n],n,t))return!0;return!1},LB=(t,e)=>{const n=new Array(t);for(let r=0;r<t;r++)n[r]=e(r,n);return n},Rs=Array.isArray;class Sv{constructor(){this._observers=Yt()}on(e,n){return Vn(this._observers,e,qr).add(n),n}once(e,n){const r=(...s)=>{this.off(e,r),n(...s)};this.on(e,r)}off(e,n){const r=this._observers.get(e);r!==void 0&&(r.delete(n),r.size===0&&this._observers.delete(e))}emit(e,n){return Kr((this._observers.get(e)||Yt()).values()).forEach(r=>r(...n))}destroy(){this._observers=Yt()}}const Qt=Math.floor,xl=Math.abs,Jr=(t,e)=>t<e?t:e,hr=(t,e)=>t>e?t:e,Cv=t=>t!==0?t<0:1/t<0,wg=1,xg=2,hu=4,pu=8,ro=32,Ln=64,mt=128,jB=1<<29,lc=31,Dd=63,Pr=127,PB=2147483647,xa=Number.MAX_SAFE_INTEGER,vg=Number.MIN_SAFE_INTEGER,BB=Number.isInteger||(t=>typeof t=="number"&&isFinite(t)&&Qt(t)===t),Ev=String.fromCharCode,zB=t=>t.toLowerCase(),$B=/^\s*/g,HB=t=>t.replace($B,""),FB=/([A-Z])/g,kg=(t,e)=>HB(t.replace(FB,n=>`${e}${zB(n)}`)),VB=t=>{const e=unescape(encodeURIComponent(t)),n=e.length,r=new Uint8Array(n);for(let s=0;s<n;s++)r[s]=e.codePointAt(s);return r},so=typeof TextEncoder<"u"?new TextEncoder:null,UB=t=>so.encode(t),WB=so?UB:VB;let zi=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});zi&&zi.decode(new Uint8Array).length===1&&(zi=null);const qB=(t,e)=>LB(e,()=>t).join("");class So{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const Co=()=>new So,KB=t=>{const e=Co();return t(e),Jt(e)},JB=t=>{let e=t.cpos;for(let n=0;n<t.bufs.length;n++)e+=t.bufs[n].length;return e},Jt=t=>{const e=new Uint8Array(JB(t));let n=0;for(let r=0;r<t.bufs.length;r++){const s=t.bufs[r];e.set(s,n),n+=s.length}return e.set(new Uint8Array(t.cbuf.buffer,0,t.cpos),n),e},GB=(t,e)=>{const n=t.cbuf.length;n-t.cpos<e&&(t.bufs.push(new Uint8Array(t.cbuf.buffer,0,t.cpos)),t.cbuf=new Uint8Array(hr(n,e)*2),t.cpos=0)},Fe=(t,e)=>{const n=t.cbuf.length;t.cpos===n&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(n*2),t.cpos=0),t.cbuf[t.cpos++]=e},Ld=Fe,ue=(t,e)=>{for(;e>Pr;)Fe(t,mt|Pr&e),e=Qt(e/128);Fe(t,Pr&e)},fh=(t,e)=>{const n=Cv(e);for(n&&(e=-e),Fe(t,(e>Dd?mt:0)|(n?Ln:0)|Dd&e),e=Qt(e/64);e>0;)Fe(t,(e>Pr?mt:0)|Pr&e),e=Qt(e/128)},jd=new Uint8Array(3e4),YB=jd.length/3,XB=(t,e)=>{if(e.length<YB){const n=so.encodeInto(e,jd).written||0;ue(t,n);for(let r=0;r<n;r++)Fe(t,jd[r])}else Mt(t,WB(e))},ZB=(t,e)=>{const n=unescape(encodeURIComponent(e)),r=n.length;ue(t,r);for(let s=0;s<r;s++)Fe(t,n.codePointAt(s))},ys=so&&so.encodeInto?XB:ZB,ac=(t,e)=>{const n=t.cbuf.length,r=t.cpos,s=Jr(n-r,e.length),i=e.length-s;t.cbuf.set(e.subarray(0,s),r),t.cpos+=s,i>0&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(hr(n*2,i)),t.cbuf.set(e.subarray(s)),t.cpos=i)},Mt=(t,e)=>{ue(t,e.byteLength),ac(t,e)},hh=(t,e)=>{GB(t,e);const n=new DataView(t.cbuf.buffer,t.cpos,e);return t.cpos+=e,n},QB=(t,e)=>hh(t,4).setFloat32(0,e,!1),ez=(t,e)=>hh(t,8).setFloat64(0,e,!1),tz=(t,e)=>hh(t,8).setBigInt64(0,e,!1),Sg=new DataView(new ArrayBuffer(4)),nz=t=>(Sg.setFloat32(0,t),Sg.getFloat32(0)===t),Ds=(t,e)=>{switch(typeof e){case"string":Fe(t,119),ys(t,e);break;case"number":BB(e)&&xl(e)<=PB?(Fe(t,125),fh(t,e)):nz(e)?(Fe(t,124),QB(t,e)):(Fe(t,123),ez(t,e));break;case"bigint":Fe(t,122),tz(t,e);break;case"object":if(e===null)Fe(t,126);else if(Rs(e)){Fe(t,117),ue(t,e.length);for(let n=0;n<e.length;n++)Ds(t,e[n])}else if(e instanceof Uint8Array)Fe(t,116),Mt(t,e);else{Fe(t,118);const n=Object.keys(e);ue(t,n.length);for(let r=0;r<n.length;r++){const s=n[r];ys(t,s),Ds(t,e[s])}}break;case"boolean":Fe(t,e?120:121);break;default:Fe(t,127)}};class Cg extends So{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&ue(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}}const Eg=t=>{t.count>0&&(fh(t.encoder,t.count===1?t.s:-t.s),t.count>1&&ue(t.encoder,t.count-2))};class vl{constructor(){this.encoder=new So,this.s=0,this.count=0}write(e){this.s===e?this.count++:(Eg(this),this.count=1,this.s=e)}toUint8Array(){return Eg(this),Jt(this.encoder)}}const Mg=t=>{if(t.count>0){const e=t.diff*2+(t.count===1?0:1);fh(t.encoder,e),t.count>1&&ue(t.encoder,t.count-2)}};class mu{constructor(){this.encoder=new So,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(Mg(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return Mg(this),Jt(this.encoder)}}class rz{constructor(){this.sarr=[],this.s="",this.lensE=new vl}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=""),this.lensE.write(e.length)}toUint8Array(){const e=new So;return this.sarr.push(this.s),this.s="",ys(e,this.sarr.join("")),ac(e,this.lensE.toUint8Array()),Jt(e)}}const yn=t=>new Error(t),$t=()=>{throw yn("Method unimplemented")},bt=()=>{throw yn("Unexpected case")},Mv=yn("Unexpected end of array"),Tv=yn("Integer out of Range");class cc{constructor(e){this.arr=e,this.pos=0}}const ph=t=>new cc(t),sz=t=>t.pos!==t.arr.length,iz=(t,e)=>{const n=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,n},Dt=t=>iz(t,Ce(t)),io=t=>t.arr[t.pos++],Ce=t=>{let e=0,n=1;const r=t.arr.length;for(;t.pos<r;){const s=t.arr[t.pos++];if(e=e+(s&Pr)*n,n*=128,s<mt)return e;if(e>xa)throw Tv}throw Mv},mh=t=>{let e=t.arr[t.pos++],n=e&Dd,r=64;const s=(e&Ln)>0?-1:1;if(!(e&mt))return s*n;const i=t.arr.length;for(;t.pos<i;){if(e=t.arr[t.pos++],n=n+(e&Pr)*r,r*=128,e<mt)return s*n;if(n>xa)throw Tv}throw Mv},oz=t=>{let e=Ce(t);if(e===0)return"";{let n=String.fromCodePoint(io(t));if(--e<100)for(;e--;)n+=String.fromCodePoint(io(t));else for(;e>0;){const r=e<1e4?e:1e4,s=t.arr.subarray(t.pos,t.pos+r);t.pos+=r,n+=String.fromCodePoint.apply(null,s),e-=r}return decodeURIComponent(escape(n))}},lz=t=>zi.decode(Dt(t)),Pd=zi?lz:oz,gh=(t,e)=>{const n=new DataView(t.arr.buffer,t.arr.byteOffset+t.pos,e);return t.pos+=e,n},az=t=>gh(t,4).getFloat32(0,!1),cz=t=>gh(t,8).getFloat64(0,!1),uz=t=>gh(t,8).getBigInt64(0,!1),dz=[t=>{},t=>null,mh,az,cz,uz,t=>!1,t=>!0,Pd,t=>{const e=Ce(t),n={};for(let r=0;r<e;r++){const s=Pd(t);n[s]=va(t)}return n},t=>{const e=Ce(t),n=[];for(let r=0;r<e;r++)n.push(va(t));return n},Dt],va=t=>dz[127-io(t)](t);class Tg extends cc{constructor(e,n){super(e),this.reader=n,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),sz(this)?this.count=Ce(this)+1:this.count=-1),this.count--,this.s}}class kl extends cc{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=mh(this);const e=Cv(this.s);this.count=1,e&&(this.s=-this.s,this.count=Ce(this)+2)}return this.count--,this.s}}class gu extends cc{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){const e=mh(this),n=e&1;this.diff=Qt(e/2),this.count=1,n&&(this.count=Ce(this)+2)}return this.s+=this.diff,this.count--,this.s}}class fz{constructor(e){this.decoder=new kl(e),this.str=Pd(this.decoder),this.spos=0}read(){const e=this.spos+this.decoder.read(),n=this.str.slice(this.spos,e);return this.spos=e,n}}const hz=crypto.getRandomValues.bind(crypto),pz=Math.random,Av=()=>hz(new Uint32Array(1))[0],mz=t=>t[Qt(pz()*t.length)],gz="10000000-1000-4000-8000"+-1e11,yz=()=>gz.replace(/[018]/g,t=>(t^Av()&15>>t/4).toString(16)),bz=Date.now,Ag=t=>new Promise(t);Promise.all.bind(Promise);const _g=t=>t===void 0?null:t;class wz{constructor(){this.map=new Map}setItem(e,n){this.map.set(e,n)}getItem(e){return this.map.get(e)}}let _v=new wz,xz=!0;try{typeof localStorage<"u"&&localStorage&&(_v=localStorage,xz=!1)}catch{}const vz=_v,oo=Symbol("Equality"),Nv=(t,e)=>{var n;return t===e||!!((n=t==null?void 0:t[oo])!=null&&n.call(t,e))||!1},kz=t=>typeof t=="object",Sz=Object.assign,Ov=Object.keys,Cz=(t,e)=>{for(const n in t)e(t[n],n)},ka=t=>Ov(t).length,Ez=t=>{for(const e in t)return!1;return!0},Ws=(t,e)=>{for(const n in t)if(!e(t[n],n))return!1;return!0},yh=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),Mz=(t,e)=>t===e||ka(t)===ka(e)&&Ws(t,(n,r)=>(n!==void 0||yh(e,r))&&Nv(e[r],n)),Tz=Object.freeze,Iv=t=>{for(const e in t){const n=t[e];(typeof n=="object"||typeof n=="function")&&Iv(t[e])}return Tz(t)},bh=(t,e,n=0)=>{try{for(;n<t.length;n++)t[n](...e)}finally{n<t.length&&bh(t,e,n+1)}},Sl=(t,e)=>{if(t===e)return!0;if(t==null||e==null||t.constructor!==e.constructor&&(t.constructor||Object)!==(e.constructor||Object))return!1;if(t[oo]!=null)return t[oo](e);switch(t.constructor){case ArrayBuffer:t=new Uint8Array(t),e=new Uint8Array(e);case Uint8Array:{if(t.byteLength!==e.byteLength)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;break}case Set:{if(t.size!==e.size)return!1;for(const n of t)if(!e.has(n))return!1;break}case Map:{if(t.size!==e.size)return!1;for(const n of t.keys())if(!e.has(n)||!Sl(t.get(n),e.get(n)))return!1;break}case void 0:case Object:if(ka(t)!==ka(e))return!1;for(const n in t)if(!yh(t,n)||!Sl(t[n],e[n]))return!1;break;case Array:if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(!Sl(t[n],e[n]))return!1;break;default:return!1}return!0},Az=(t,e)=>e.includes(t),Ls=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]",Rv=typeof window<"u"&&typeof document<"u"&&!Ls;let on;const _z=()=>{if(on===void 0)if(Ls){on=Yt();const t=process.argv;let e=null;for(let n=0;n<t.length;n++){const r=t[n];r[0]==="-"?(e!==null&&on.set(e,""),e=r):e!==null&&(on.set(e,r),e=null)}e!==null&&on.set(e,"")}else typeof location=="object"?(on=Yt(),(location.search||"?").slice(1).split("&").forEach(t=>{if(t.length!==0){const[e,n]=t.split("=");on.set(`--${kg(e,"-")}`,n),on.set(`-${kg(e,"-")}`,n)}})):on=Yt();return on},Bd=t=>_z().has(t),Sa=t=>_g(Ls?process.env[t.toUpperCase().replaceAll("-","_")]:vz.getItem(t)),Dv=t=>Bd("--"+t)||Sa(t)!==null,Nz=Dv("production"),Oz=Ls&&Az(process.env.FORCE_COLOR,["true","1","2"]),Iz=Oz||!Bd("--no-colors")&&!Dv("no-color")&&(!Ls||process.stdout.isTTY)&&(!Ls||Bd("--color")||Sa("COLORTERM")!==null||(Sa("TERM")||"").includes("color")),Rz=t=>{let e="";for(let n=0;n<t.byteLength;n++)e+=Ev(t[n]);return btoa(e)},Dz=t=>Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("base64"),Lz=Rv?Rz:Dz,jz=t=>KB(e=>Ds(e,t));class Pz{constructor(e,n){this.left=e,this.right=n}}const Mn=(t,e)=>new Pz(t,e),Ng=t=>t.next()>=.5,yu=(t,e,n)=>Qt(t.next()*(n+1-e)+e),Lv=(t,e,n)=>Qt(t.next()*(n+1-e)+e),wh=(t,e,n)=>Lv(t,e,n),Bz=t=>Ev(wh(t,97,122)),zz=(t,e=0,n=20)=>{const r=wh(t,e,n);let s="";for(let i=0;i<r;i++)s+=Bz(t);return s},bu=(t,e)=>e[wh(t,0,e.length-1)],$z=Symbol("0schema");class Hz{constructor(){this._rerrs=[]}extend(e,n,r,s=null){this._rerrs.push({path:e,expected:n,has:r,message:s})}toString(){const e=[];for(let n=this._rerrs.length-1;n>0;n--){const r=this._rerrs[n];e.push(qB(" ",(this._rerrs.length-n)*2)+`${r.path!=null?`[${r.path}] `:""}${r.has} doesn't match ${r.expected}. ${r.message}`)}return e.join(`
|
|
392
|
-
`)}}const
|
|
393
|
-
${n.toString()}`)};class d${constructor(e){this.patterns=[],this.$state=e}if(e,n){return this.patterns.push({if:lo(e),h:n}),this}else(e){return this.if(Ma,e)}done(){return(e,n)=>{for(let r=0;r<this.patterns.length;r++){const s=this.patterns[r];if(s.if.check(e))return s.h(e,n)}throw yn("Unhandled pattern")}}}const f$=t=>new d$(t),Yv=f$(Ma).if(Kv,(t,e)=>yu(e,vg,xa)).if(Jv,(t,e)=>zz(e)).if(a$,(t,e)=>Ng(e)).if(l$,(t,e)=>BigInt(yu(e,vg,xa))).if(Ea,(t,e)=>ss(e,bu(e,t.shape))).if(Jz,(t,e)=>{const n={};for(const r in t.shape){let s=t.shape[r];if(Wz.check(s)){if(Ng(e))continue;s=s.shape}n[r]=Yv(s,e)}return n}).if(Zz,(t,e)=>{const n=[],r=Lv(e,0,42);for(let s=0;s<r;s++)n.push(ss(e,t.shape));return n}).if(jv,(t,e)=>bu(e,t.shape)).if(c$,(t,e)=>null).if(r$,(t,e)=>{const n=ss(e,t.res);return()=>n}).if(o$,(t,e)=>ss(e,bu(e,[bs,js,pc,Gv,kh,hc,Vv(bs),$v(qs("a","b","c"),bs)]))).if(Yz,(t,e)=>{const n={},r=yu(e,0,3);for(let s=0;s<r;s++){const i=ss(e,t.shape.keys),o=ss(e,t.shape.values);n[i]=o}return n}).done(),ss=(t,e)=>Yv(lo(e),t),Eo=typeof document<"u"?document:{};Ke(t=>t.nodeType===y$);typeof DOMParser<"u"&&new DOMParser;Ke(t=>t.nodeType===p$);Ke(t=>t.nodeType===m$);const h$=t=>IB(t,(e,n)=>`${n}:${e};`).join(""),p$=Eo.ELEMENT_NODE,m$=Eo.TEXT_NODE,g$=Eo.DOCUMENT_NODE,y$=Eo.DOCUMENT_FRAGMENT_NODE;Ke(t=>t.nodeType===g$);const b$=t=>class{constructor(n){this._=n}destroy(){t(this._)}},w$=b$(clearTimeout),Xv=(t,e)=>new w$(setTimeout(e,t)),Un=Symbol,Zv=Un(),Qv=Un(),x$=Un(),v$=Un(),k$=Un(),ek=Un(),S$=Un(),Sh=Un(),C$=Un(),E$=t=>{var s;t.length===1&&((s=t[0])==null?void 0:s.constructor)===Function&&(t=t[0]());const e=[],n=[];let r=0;for(;r<t.length;r++){const i=t[r];if(i===void 0)break;if(i.constructor===String||i.constructor===Number)e.push(i);else if(i.constructor===Object)break}for(r>0&&n.push(e.join(""));r<t.length;r++){const i=t[r];i instanceof Symbol||n.push(i)}return n},M$={[Zv]:Mn("font-weight","bold"),[Qv]:Mn("font-weight","normal"),[x$]:Mn("color","blue"),[k$]:Mn("color","green"),[v$]:Mn("color","grey"),[ek]:Mn("color","red"),[S$]:Mn("color","purple"),[Sh]:Mn("color","orange"),[C$]:Mn("color","black")},T$=t=>{var o;t.length===1&&((o=t[0])==null?void 0:o.constructor)===Function&&(t=t[0]());const e=[],n=[],r=Yt();let s=[],i=0;for(;i<t.length;i++){const l=t[i],a=M$[l];if(a!==void 0)r.set(a.left,a.right);else{if(l===void 0)break;if(l.constructor===String||l.constructor===Number){const c=h$(r);i>0||c.length>0?(e.push("%c"+l),n.push(c)):e.push(l)}else break}}for(i>0&&(s=n,s.unshift(e.join("")));i<t.length;i++){const l=t[i];l instanceof Symbol||s.push(l)}return s},tk=Iz?T$:E$,A$=(...t)=>{console.log(...tk(t)),rk.forEach(e=>e.print(t))},nk=(...t)=>{console.warn(...tk(t)),t.unshift(Sh),rk.forEach(e=>e.print(t))},rk=qr(),sk=t=>({[Symbol.iterator](){return this},next:t}),_$=(t,e)=>sk(()=>{let n;do n=t.next();while(!n.done&&!e(n.value));return n}),wu=(t,e)=>sk(()=>{const{done:n,value:r}=t.next();return{done:n,value:n?void 0:e(r)}});class mc{constructor(e,n){this.clock=e,this.len=n}}class Ks{constructor(){this.clients=new Map}}const pr=(t,e,n)=>e.clients.forEach((r,s)=>{const i=t.doc.store.clients.get(s);if(i!=null){const o=i[i.length-1],l=o.id.clock+o.length;for(let a=0,c=r[a];a<r.length&&c.clock<l;c=r[++a])hk(t,i,c.clock,c.len,n)}}),N$=(t,e)=>{let n=0,r=t.length-1;for(;n<=r;){const s=Qt((n+r)/2),i=t[s],o=i.clock;if(o<=e){if(e<o+i.len)return s;n=s+1}else r=s-1}return null},Js=(t,e)=>{const n=t.clients.get(e.client);return n!==void 0&&N$(n,e.clock)!==null},Ch=t=>{t.clients.forEach(e=>{e.sort((s,i)=>s.clock-i.clock);let n,r;for(n=1,r=1;n<e.length;n++){const s=e[r-1],i=e[n];s.clock+s.len>=i.clock?e[r-1]=new mc(s.clock,hr(s.len,i.clock+i.len-s.clock)):(r<n&&(e[r]=i),r++)}e.length=r})},$d=t=>{const e=new Ks;for(let n=0;n<t.length;n++)t[n].clients.forEach((r,s)=>{if(!e.clients.has(s)){const i=r.slice();for(let o=n+1;o<t.length;o++)DB(i,t[o].clients.get(s)||[]);e.clients.set(s,i)}});return Ch(e),e},ao=(t,e,n,r)=>{Vn(t.clients,e,()=>[]).push(new mc(n,r))},ik=()=>new Ks,O$=t=>{const e=ik();return t.clients.forEach((n,r)=>{const s=[];for(let i=0;i<n.length;i++){const o=n[i];if(o.deleted){const l=o.id.clock;let a=o.length;if(i+1<n.length)for(let c=n[i+1];i+1<n.length&&c.deleted;c=n[++i+1])a+=c.length;s.push(new mc(l,a))}}s.length>0&&e.clients.set(r,s)}),e},Eh=(t,e)=>{ue(t.restEncoder,e.clients.size),Kr(e.clients.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{t.resetDsCurVal(),ue(t.restEncoder,n);const s=r.length;ue(t.restEncoder,s);for(let i=0;i<s;i++){const o=r[i];t.writeDsClock(o.clock),t.writeDsLen(o.len)}})},I$=t=>{const e=new Ks,n=Ce(t.restDecoder);for(let r=0;r<n;r++){t.resetDsCurVal();const s=Ce(t.restDecoder),i=Ce(t.restDecoder);if(i>0){const o=Vn(e.clients,s,()=>[]);for(let l=0;l<i;l++)o.push(new mc(t.readDsClock(),t.readDsLen()))}}return e},Ig=(t,e,n)=>{const r=new Ks,s=Ce(t.restDecoder);for(let i=0;i<s;i++){t.resetDsCurVal();const o=Ce(t.restDecoder),l=Ce(t.restDecoder),a=n.clients.get(o)||[],c=Ie(n,o);for(let u=0;u<l;u++){const d=t.readDsClock(),f=d+t.readDsLen();if(d<c){c<f&&ao(r,o,c,f-c);let h=en(a,d),p=a[h];for(!p.deleted&&p.id.clock<d&&(a.splice(h+1,0,Ra(e,p,d-p.id.clock)),h++);h<a.length&&(p=a[h++],p.id.clock<f);)p.deleted||(f<p.id.clock+p.length&&a.splice(h,0,Ra(e,p,f-p.id.clock)),p.delete(e))}else ao(r,o,d,f-d)}}if(r.clients.size>0){const i=new gc;return ue(i.restEncoder,0),Eh(i,r),i.toUint8Array()}return null},ok=Av;class Qr extends Sv{constructor({guid:e=yz(),collectionid:n=null,gc:r=!0,gcFilter:s=()=>!0,meta:i=null,autoLoad:o=!1,shouldLoad:l=!0}={}){super(),this.gc=r,this.gcFilter=s,this.clientID=ok(),this.guid=e,this.collectionid=n,this.share=new Map,this.store=new dk,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=l,this.autoLoad=o,this.meta=i,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=Ag(c=>{this.on("load",()=>{this.isLoaded=!0,c(this)})});const a=()=>Ag(c=>{const u=d=>{(d===void 0||d===!0)&&(this.off("sync",u),c())};this.on("sync",u)});this.on("sync",c=>{c===!1&&this.isSynced&&(this.whenSynced=a()),this.isSynced=c===void 0||c===!0,this.isSynced&&!this.isLoaded&&this.emit("load",[this])}),this.whenSynced=a()}load(){const e=this._item;e!==null&&!this.shouldLoad&&we(e.parent.doc,n=>{n.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(Kr(this.subdocs).map(e=>e.guid))}transact(e,n=null){return we(this,e,n)}get(e,n=qe){const r=Vn(this.share,e,()=>{const i=new n;return i._integrate(this,null),i}),s=r.constructor;if(n!==qe&&s!==n)if(s===qe){const i=new n;i._map=r._map,r._map.forEach(o=>{for(;o!==null;o=o.left)o.parent=i}),i._start=r._start;for(let o=i._start;o!==null;o=o.right)o.parent=i;return i._length=r._length,this.share.set(e,i),i._integrate(this,null),i}else throw new Error(`Type with the name ${e} has already been defined with a different constructor`);return r}getArray(e=""){return this.get(e,vs)}getText(e=""){return this.get(e,mr)}getMap(e=""){return this.get(e,Ps)}getXmlElement(e=""){return this.get(e,et)}getXmlFragment(e=""){return this.get(e,Gr)}toJSON(){const e={};return this.share.forEach((n,r)=>{e[r]=n.toJSON()}),e}destroy(){this.isDestroyed=!0,Kr(this.subdocs).forEach(n=>n.destroy());const e=this._item;if(e!==null){this._item=null;const n=e.content;n.doc=new Qr({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=e,we(e.parent.doc,r=>{const s=n.doc;e.deleted||r.subdocsAdded.add(s),r.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class R${constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=Ce(this.restDecoder),this.dsCurrVal}readDsLen(){const e=Ce(this.restDecoder)+1;return this.dsCurrVal+=e,e}}class Ta extends R${constructor(e){super(e),this.keys=[],Ce(e),this.keyClockDecoder=new gu(Dt(e)),this.clientDecoder=new kl(Dt(e)),this.leftClockDecoder=new gu(Dt(e)),this.rightClockDecoder=new gu(Dt(e)),this.infoDecoder=new Tg(Dt(e),io),this.stringDecoder=new fz(Dt(e)),this.parentInfoDecoder=new Tg(Dt(e),io),this.typeRefDecoder=new kl(Dt(e)),this.lenDecoder=new kl(Dt(e))}readLeftID(){return new ws(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new ws(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return va(this.restDecoder)}readBuf(){return Dt(this.restDecoder)}readJSON(){return va(this.restDecoder)}readKey(){const e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];{const n=this.stringDecoder.read();return this.keys.push(n),n}}}class D${constructor(){this.restEncoder=Co()}toUint8Array(){return Jt(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){ue(this.restEncoder,e)}writeDsLen(e){ue(this.restEncoder,e)}}class L$ extends D${writeLeftID(e){ue(this.restEncoder,e.client),ue(this.restEncoder,e.clock)}writeRightID(e){ue(this.restEncoder,e.client),ue(this.restEncoder,e.clock)}writeClient(e){ue(this.restEncoder,e)}writeInfo(e){Ld(this.restEncoder,e)}writeString(e){ys(this.restEncoder,e)}writeParentInfo(e){ue(this.restEncoder,e?1:0)}writeTypeRef(e){ue(this.restEncoder,e)}writeLen(e){ue(this.restEncoder,e)}writeAny(e){Ds(this.restEncoder,e)}writeBuf(e){Mt(this.restEncoder,e)}writeJSON(e){ys(this.restEncoder,JSON.stringify(e))}writeKey(e){ys(this.restEncoder,e)}}class j${constructor(){this.restEncoder=Co(),this.dsCurrVal=0}toUint8Array(){return Jt(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){const n=e-this.dsCurrVal;this.dsCurrVal=e,ue(this.restEncoder,n)}writeDsLen(e){e===0&&bt(),ue(this.restEncoder,e-1),this.dsCurrVal+=e}}class gc extends j${constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new mu,this.clientEncoder=new vl,this.leftClockEncoder=new mu,this.rightClockEncoder=new mu,this.infoEncoder=new Cg(Ld),this.stringEncoder=new rz,this.parentInfoEncoder=new Cg(Ld),this.typeRefEncoder=new vl,this.lenEncoder=new vl}toUint8Array(){const e=Co();return ue(e,0),Mt(e,this.keyClockEncoder.toUint8Array()),Mt(e,this.clientEncoder.toUint8Array()),Mt(e,this.leftClockEncoder.toUint8Array()),Mt(e,this.rightClockEncoder.toUint8Array()),Mt(e,Jt(this.infoEncoder)),Mt(e,this.stringEncoder.toUint8Array()),Mt(e,Jt(this.parentInfoEncoder)),Mt(e,this.typeRefEncoder.toUint8Array()),Mt(e,this.lenEncoder.toUint8Array()),ac(e,Jt(this.restEncoder)),Jt(e)}writeLeftID(e){this.clientEncoder.write(e.client),this.leftClockEncoder.write(e.clock)}writeRightID(e){this.clientEncoder.write(e.client),this.rightClockEncoder.write(e.clock)}writeClient(e){this.clientEncoder.write(e)}writeInfo(e){this.infoEncoder.write(e)}writeString(e){this.stringEncoder.write(e)}writeParentInfo(e){this.parentInfoEncoder.write(e?1:0)}writeTypeRef(e){this.typeRefEncoder.write(e)}writeLen(e){this.lenEncoder.write(e)}writeAny(e){Ds(this.restEncoder,e)}writeBuf(e){Mt(this.restEncoder,e)}writeJSON(e){Ds(this.restEncoder,e)}writeKey(e){const n=this.keyMap.get(e);n===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(n)}}const P$=(t,e,n,r)=>{r=hr(r,e[0].id.clock);const s=en(e,r);ue(t.restEncoder,e.length-s),t.writeClient(n),ue(t.restEncoder,r);const i=e[s];i.write(t,r-i.id.clock);for(let o=s+1;o<e.length;o++)e[o].write(t,0)},lk=(t,e,n)=>{const r=new Map;n.forEach((s,i)=>{Ie(e,i)>s&&r.set(i,s)}),yc(e).forEach((s,i)=>{n.has(i)||r.set(i,0)}),ue(t.restEncoder,r.size),Kr(r.entries()).sort((s,i)=>i[0]-s[0]).forEach(([s,i])=>{P$(t,e.clients.get(s),s,i)})},B$=(t,e)=>{const n=Yt(),r=Ce(t.restDecoder);for(let s=0;s<r;s++){const i=Ce(t.restDecoder),o=new Array(i),l=t.readClient();let a=Ce(t.restDecoder);n.set(l,{i:0,refs:o});for(let c=0;c<i;c++){const u=t.readInfo();switch(lc&u){case 0:{const d=t.readLen();o[c]=new Pt(se(l,a),d),a+=d;break}case 10:{const d=Ce(t.restDecoder);o[c]=new Kt(se(l,a),d),a+=d;break}default:{const d=(u&(Ln|mt))===0,f=new pe(se(l,a),null,(u&mt)===mt?t.readLeftID():null,null,(u&Ln)===Ln?t.readRightID():null,d?t.readParentInfo()?e.get(t.readString()):t.readLeftID():null,d&&(u&ro)===ro?t.readString():null,Lk(t,u));o[c]=f,a+=f.length}}}}return n},z$=(t,e,n)=>{const r=[];let s=Kr(n.keys()).sort((h,p)=>h-p);if(s.length===0)return null;const i=()=>{if(s.length===0)return null;let h=n.get(s[s.length-1]);for(;h.refs.length===h.i;)if(s.pop(),s.length>0)h=n.get(s[s.length-1]);else return null;return h};let o=i();if(o===null)return null;const l=new dk,a=new Map,c=(h,p)=>{const g=a.get(h);(g==null||g>p)&&a.set(h,p)};let u=o.refs[o.i++];const d=new Map,f=()=>{for(const h of r){const p=h.id.client,g=n.get(p);g?(g.i--,l.clients.set(p,g.refs.slice(g.i)),n.delete(p),g.i=0,g.refs=[]):l.clients.set(p,[h]),s=s.filter(y=>y!==p)}r.length=0};for(;;){if(u.constructor!==Kt){const p=Vn(d,u.id.client,()=>Ie(e,u.id.client))-u.id.clock;if(p<0)r.push(u),c(u.id.client,u.id.clock-1),f();else{const g=u.getMissing(t,e);if(g!==null){r.push(u);const y=n.get(g)||{refs:[],i:0};if(y.refs.length===y.i)c(g,Ie(e,g)),f();else{u=y.refs[y.i++];continue}}else(p===0||p<u.length)&&(u.integrate(t,p),d.set(u.id.client,u.id.clock+u.length))}}if(r.length>0)u=r.pop();else if(o!==null&&o.i<o.refs.length)u=o.refs[o.i++];else{if(o=i(),o===null)break;u=o.refs[o.i++]}}if(l.clients.size>0){const h=new gc;return lk(h,l,new Map),ue(h.restEncoder,0),{missing:a,update:h.toUint8Array()}}return null},$$=(t,e)=>lk(t,e.doc.store,e.beforeState),H$=(t,e,n,r=new Ta(t))=>we(e,s=>{s.local=!1;let i=!1;const o=s.doc,l=o.store,a=B$(r,o),c=z$(s,l,a),u=l.pendingStructs;if(u){for(const[f,h]of u.missing)if(h<Ie(l,f)){i=!0;break}if(c){for(const[f,h]of c.missing){const p=u.missing.get(f);(p==null||p>h)&&u.missing.set(f,h)}u.update=Hg([u.update,c.update])}}else l.pendingStructs=c;const d=Ig(r,s,l);if(l.pendingDs){const f=new Ta(ph(l.pendingDs));Ce(f.restDecoder);const h=Ig(f,s,l);d&&h?l.pendingDs=Hg([d,h]):l.pendingDs=d||h}else l.pendingDs=d;if(i){const f=l.pendingStructs.update;l.pendingStructs=null,Hd(s.doc,f)}},n,!1),Hd=(t,e,n,r=Ta)=>{const s=ph(e);H$(s,t,n,new r(s))};class F${constructor(){this.l=[]}}const Rg=()=>new F$,Dg=(t,e)=>t.l.push(e),Lg=(t,e)=>{const n=t.l,r=n.length;t.l=n.filter(s=>e!==s),r===t.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},ak=(t,e,n)=>bh(t.l,[e,n]);class ws{constructor(e,n){this.client=e,this.clock=n}}const Qo=(t,e)=>t===e||t!==null&&e!==null&&t.client===e.client&&t.clock===e.clock,se=(t,e)=>new ws(t,e),co=t=>{for(const[e,n]of t.doc.share.entries())if(n===t)return e;throw bt()},uo=(t,e)=>{for(;e!==null;){if(e.parent===t)return!0;e=e.parent._item}return!1};class Aa{constructor(e,n,r,s=0){this.type=e,this.tname=n,this.item=r,this.assoc=s}}class V${constructor(e,n,r=0){this.type=e,this.index=n,this.assoc=r}}const U$=(t,e,n=0)=>new V$(t,e,n),el=(t,e,n)=>{let r=null,s=null;return t._item===null?s=co(t):r=se(t._item.id.client,t._item.id.clock),new Aa(r,s,e,n)},xu=(t,e,n=0)=>{let r=t._start;if(n<0){if(e===0)return el(t,null,n);e--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>e)return el(t,se(r.id.client,r.id.clock+e),n);e-=r.length}if(r.right===null&&n<0)return el(t,r.lastId,n);r=r.right}return el(t,null,n)},W$=(t,e)=>{const n=xs(t,e),r=e.clock-n.id.clock;return{item:n,diff:r}},ck=(t,e,n=!0)=>{const r=e.store,s=t.item,i=t.type,o=t.tname,l=t.assoc;let a=null,c=0;if(s!==null){if(Ie(r,s.client)<=s.clock)return null;const u=n?Wd(r,s):W$(r,s),d=u.item;if(!(d instanceof pe))return null;if(a=d.parent,a._item===null||!a._item.deleted){c=d.deleted||!d.countable?0:u.diff+(l>=0?0:1);let f=d.left;for(;f!==null;)!f.deleted&&f.countable&&(c+=f.length),f=f.left}}else{if(o!==null)a=e.get(o);else if(i!==null){if(Ie(r,i.client)<=i.clock)return null;const{item:u}=n?Wd(r,i):{item:xs(r,i)};if(u instanceof pe&&u.content instanceof rn)a=u.content.type;else return null}else throw bt();l>=0?c=a._length:c=0}return U$(a,c,t.assoc)};class Mh{constructor(e,n){this.ds=e,this.sv=n}}const uk=(t,e)=>new Mh(t,e),vu=t=>uk(O$(t.store),yc(t.store)),Mr=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&(e.sv.get(t.id.client)||0)>t.id.clock&&!Js(e.ds,t.id),Fd=(t,e)=>{const n=Vn(t.meta,Fd,qr),r=t.doc.store;n.has(e)||(e.sv.forEach((s,i)=>{s<Ie(r,i)&&xt(t,se(i,s))}),pr(t,e.ds,s=>{}),n.add(e))};class dk{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const yc=t=>{const e=new Map;return t.clients.forEach((n,r)=>{const s=n[n.length-1];e.set(r,s.id.clock+s.length)}),e},Ie=(t,e)=>{const n=t.clients.get(e);if(n===void 0)return 0;const r=n[n.length-1];return r.id.clock+r.length},fk=(t,e)=>{let n=t.clients.get(e.id.client);if(n===void 0)n=[],t.clients.set(e.id.client,n);else{const r=n[n.length-1];if(r.id.clock+r.length!==e.id.clock)throw bt()}n.push(e)},en=(t,e)=>{let n=0,r=t.length-1,s=t[r],i=s.id.clock;if(i===e)return r;let o=Qt(e/(i+s.length-1)*r);for(;n<=r;){if(s=t[o],i=s.id.clock,i<=e){if(e<i+s.length)return o;n=o+1}else r=o-1;o=Qt((n+r)/2)}throw bt()},q$=(t,e)=>{const n=t.clients.get(e.client);return n[en(n,e.clock)]},xs=q$,Vd=(t,e,n)=>{const r=en(e,n),s=e[r];return s.id.clock<n&&s instanceof pe?(e.splice(r+1,0,Ra(t,s,n-s.id.clock)),r+1):r},xt=(t,e)=>{const n=t.doc.store.clients.get(e.client);return n[Vd(t,n,e.clock)]},jg=(t,e,n)=>{const r=e.clients.get(n.client),s=en(r,n.clock),i=r[s];return n.clock!==i.id.clock+i.length-1&&i.constructor!==Pt&&r.splice(s+1,0,Ra(t,i,n.clock-i.id.clock+1)),i},K$=(t,e,n)=>{const r=t.clients.get(e.id.client);r[en(r,e.id.clock)]=n},hk=(t,e,n,r,s)=>{if(r===0)return;const i=n+r;let o=Vd(t,e,n),l;do l=e[o++],i<l.id.clock+l.length&&Vd(t,e,i),s(l);while(o<e.length&&e[o].id.clock<i)};class J${constructor(e,n,r){this.doc=e,this.deleteSet=new Ks,this.beforeState=yc(e.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=n,this.meta=new Map,this.local=r,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}}const Pg=(t,e)=>e.deleteSet.clients.size===0&&!RB(e.afterState,(n,r)=>e.beforeState.get(r)!==n)?!1:(Ch(e.deleteSet),$$(t,e),Eh(t,e.deleteSet),!0),Bg=(t,e,n)=>{const r=e._item;(r===null||r.id.clock<(t.beforeState.get(r.id.client)||0)&&!r.deleted)&&Vn(t.changed,e,qr).add(n)},Cl=(t,e)=>{let n=t[e],r=t[e-1],s=e;for(;s>0;n=r,r=t[--s-1]){if(r.deleted===n.deleted&&r.constructor===n.constructor&&r.mergeWith(n)){n instanceof pe&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);continue}break}const i=e-s;return i&&t.splice(e+1-i,i),i},G$=(t,e,n)=>{for(const[r,s]of t.clients.entries()){const i=e.clients.get(r);for(let o=s.length-1;o>=0;o--){const l=s[o],a=l.clock+l.len;for(let c=en(i,l.clock),u=i[c];c<i.length&&u.id.clock<a;u=i[++c]){const d=i[c];if(l.clock+l.len<=d.id.clock)break;d instanceof pe&&d.deleted&&!d.keep&&n(d)&&d.gc(e,!1)}}}},Y$=(t,e)=>{t.clients.forEach((n,r)=>{const s=e.clients.get(r);for(let i=n.length-1;i>=0;i--){const o=n[i],l=Jr(s.length-1,1+en(s,o.clock+o.len-1));for(let a=l,c=s[a];a>0&&c.id.clock>=o.clock;c=s[a])a-=1+Cl(s,a)}})},pk=(t,e)=>{if(e<t.length){const n=t[e],r=n.doc,s=r.store,i=n.deleteSet,o=n._mergeStructs;try{Ch(i),n.afterState=yc(n.doc.store),r.emit("beforeObserverCalls",[n,r]);const l=[];n.changed.forEach((a,c)=>l.push(()=>{(c._item===null||!c._item.deleted)&&c._callObserver(n,a)})),l.push(()=>{n.changedParentTypes.forEach((a,c)=>{c._dEH.l.length>0&&(c._item===null||!c._item.deleted)&&(a=a.filter(u=>u.target._item===null||!u.target._item.deleted),a.forEach(u=>{u.currentTarget=c,u._path=null}),a.sort((u,d)=>u.path.length-d.path.length),l.push(()=>{ak(c._dEH,a,n)}))}),l.push(()=>r.emit("afterTransaction",[n,r])),l.push(()=>{n._needFormattingCleanup&&gH(n)})}),bh(l,[])}finally{r.gc&&G$(i,s,r.gcFilter),Y$(i,s),n.afterState.forEach((u,d)=>{const f=n.beforeState.get(d)||0;if(f!==u){const h=s.clients.get(d),p=hr(en(h,f),1);for(let g=h.length-1;g>=p;)g-=1+Cl(h,g)}});for(let u=o.length-1;u>=0;u--){const{client:d,clock:f}=o[u].id,h=s.clients.get(d),p=en(h,f);p+1<h.length&&Cl(h,p+1)>1||p>0&&Cl(h,p)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(A$(Sh,Zv,"[yjs] ",Qv,ek,"Changed the client-id because another client seems to be using it."),r.clientID=ok()),r.emit("afterTransactionCleanup",[n,r]),r._observers.has("update")){const u=new L$;Pg(u,n)&&r.emit("update",[u.toUint8Array(),n.origin,r,n])}if(r._observers.has("updateV2")){const u=new gc;Pg(u,n)&&r.emit("updateV2",[u.toUint8Array(),n.origin,r,n])}const{subdocsAdded:l,subdocsLoaded:a,subdocsRemoved:c}=n;(l.size>0||c.size>0||a.size>0)&&(l.forEach(u=>{u.clientID=r.clientID,u.collectionid==null&&(u.collectionid=r.collectionid),r.subdocs.add(u)}),c.forEach(u=>r.subdocs.delete(u)),r.emit("subdocs",[{loaded:a,added:l,removed:c},r,n]),c.forEach(u=>u.destroy())),t.length<=e+1?(r._transactionCleanups=[],r.emit("afterAllTransactions",[r,t])):pk(t,e+1)}}},we=(t,e,n=null,r=!0)=>{const s=t._transactionCleanups;let i=!1,o=null;t._transaction===null&&(i=!0,t._transaction=new J$(t,n,r),s.push(t._transaction),s.length===1&&t.emit("beforeAllTransactions",[t]),t.emit("beforeTransaction",[t._transaction,t]));try{o=e(t._transaction)}finally{if(i){const l=t._transaction===s[0];t._transaction=null,l&&pk(s,0)}}return o};class X${constructor(e,n){this.insertions=n,this.deletions=e,this.meta=new Map}}const zg=(t,e,n)=>{pr(t,n.deletions,r=>{r instanceof pe&&e.scope.some(s=>s===t.doc||uo(s,r))&&Oh(r,!1)})},$g=(t,e,n)=>{let r=null;const s=t.doc,i=t.scope;we(s,l=>{for(;e.length>0&&t.currStackItem===null;){const a=s.store,c=e.pop(),u=new Set,d=[];let f=!1;pr(l,c.insertions,h=>{if(h instanceof pe){if(h.redone!==null){let{item:p,diff:g}=Wd(a,h.id);g>0&&(p=xt(l,se(p.id.client,p.id.clock+g))),h=p}!h.deleted&&i.some(p=>p===l.doc||uo(p,h))&&d.push(h)}}),pr(l,c.deletions,h=>{h instanceof pe&&i.some(p=>p===l.doc||uo(p,h))&&!Js(c.insertions,h.id)&&u.add(h)}),u.forEach(h=>{f=Dk(l,h,u,c.insertions,t.ignoreRemoteMapChanges,t)!==null||f});for(let h=d.length-1;h>=0;h--){const p=d[h];t.deleteFilter(p)&&(p.delete(l),f=!0)}t.currStackItem=f?c:null}l.changed.forEach((a,c)=>{a.has(null)&&c._searchMarker&&(c._searchMarker.length=0)}),r=l},t);const o=t.currStackItem;if(o!=null){const l=r.changedParentTypes;t.emit("stack-item-popped",[{stackItem:o,type:n,changedParentTypes:l,origin:t},t]),t.currStackItem=null}return o};class mk extends Sv{constructor(e,{captureTimeout:n=500,captureTransaction:r=a=>!0,deleteFilter:s=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:o=!1,doc:l=Rs(e)?e[0].doc:e instanceof Qr?e:e.doc}={}){super(),this.scope=[],this.doc=l,this.addToScope(e),this.deleteFilter=s,i.add(this),this.trackedOrigins=i,this.captureTransaction=r,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=o,this.captureTimeout=n,this.afterTransactionHandler=a=>{if(!this.captureTransaction(a)||!this.scope.some(y=>a.changedParentTypes.has(y)||y===this.doc)||!this.trackedOrigins.has(a.origin)&&(!a.origin||!this.trackedOrigins.has(a.origin.constructor)))return;const c=this.undoing,u=this.redoing,d=c?this.redoStack:this.undoStack;c?this.stopCapturing():u||this.clear(!1,!0);const f=new Ks;a.afterState.forEach((y,b)=>{const w=a.beforeState.get(b)||0,v=y-w;v>0&&ao(f,b,w,v)});const h=bz();let p=!1;if(this.lastChange>0&&h-this.lastChange<this.captureTimeout&&d.length>0&&!c&&!u){const y=d[d.length-1];y.deletions=$d([y.deletions,a.deleteSet]),y.insertions=$d([y.insertions,f])}else d.push(new X$(a.deleteSet,f)),p=!0;!c&&!u&&(this.lastChange=h),pr(a,a.deleteSet,y=>{y instanceof pe&&this.scope.some(b=>b===a.doc||uo(b,y))&&Oh(y,!0)});const g=[{stackItem:d[d.length-1],origin:a.origin,type:c?"redo":"undo",changedParentTypes:a.changedParentTypes},this];p?this.emit("stack-item-added",g):this.emit("stack-item-updated",g)},this.destroy=this.destroy.bind(this),this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",this.destroy)}addToScope(e){const n=new Set(this.scope);e=Rs(e)?e:[e],e.forEach(r=>{n.has(r)||(n.add(r),(r instanceof qe?r.doc!==this.doc:r!==this.doc)&&nk("[yjs#509] Not same Y.Doc"),this.scope.push(r))})}addTrackedOrigin(e){this.trackedOrigins.add(e)}removeTrackedOrigin(e){this.trackedOrigins.delete(e)}clear(e=!0,n=!0){(e&&this.canUndo()||n&&this.canRedo())&&this.doc.transact(r=>{e&&(this.undoStack.forEach(s=>zg(r,this,s)),this.undoStack=[]),n&&(this.redoStack.forEach(s=>zg(r,this,s)),this.redoStack=[]),this.emit("stack-cleared",[{undoStackCleared:e,redoStackCleared:n}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let e;try{e=$g(this,this.undoStack,"undo")}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=$g(this,this.redoStack,"redo")}finally{this.redoing=!1}return e}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off("afterTransaction",this.afterTransactionHandler),this.doc.off("destroy",this.destroy),super.destroy()}}function*Z$(t){const e=Ce(t.restDecoder);for(let n=0;n<e;n++){const r=Ce(t.restDecoder),s=t.readClient();let i=Ce(t.restDecoder);for(let o=0;o<r;o++){const l=t.readInfo();if(l===10){const a=Ce(t.restDecoder);yield new Kt(se(s,i),a),i+=a}else if(lc&l){const a=(l&(Ln|mt))===0,c=new pe(se(s,i),null,(l&mt)===mt?t.readLeftID():null,null,(l&Ln)===Ln?t.readRightID():null,a?t.readParentInfo()?t.readString():t.readLeftID():null,a&&(l&ro)===ro?t.readString():null,Lk(t,l));yield c,i+=c.length}else{const a=t.readLen();yield new Pt(se(s,i),a),i+=a}}}}class Q${constructor(e,n){this.gen=Z$(e),this.curr=null,this.done=!1,this.filterSkips=n,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===Kt);return this.curr}}class eH{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}}const tH=(t,e)=>{if(t.constructor===Pt){const{client:n,clock:r}=t.id;return new Pt(se(n,r+e),t.length-e)}else if(t.constructor===Kt){const{client:n,clock:r}=t.id;return new Kt(se(n,r+e),t.length-e)}else{const n=t,{client:r,clock:s}=n.id;return new pe(se(r,s+e),null,se(r,s+e-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(e))}},Hg=(t,e=Ta,n=gc)=>{if(t.length===1)return t[0];const r=t.map(u=>new e(ph(u)));let s=r.map(u=>new Q$(u,!0)),i=null;const o=new n,l=new eH(o);for(;s=s.filter(f=>f.curr!==null),s.sort((f,h)=>{if(f.curr.id.client===h.curr.id.client){const p=f.curr.id.clock-h.curr.id.clock;return p===0?f.curr.constructor===h.curr.constructor?0:f.curr.constructor===Kt?1:-1:p}else return h.curr.id.client-f.curr.id.client}),s.length!==0;){const u=s[0],d=u.curr.id.client;if(i!==null){let f=u.curr,h=!1;for(;f!==null&&f.id.clock+f.length<=i.struct.id.clock+i.struct.length&&f.id.client>=i.struct.id.client;)f=u.next(),h=!0;if(f===null||f.id.client!==d||h&&f.id.clock>i.struct.id.clock+i.struct.length)continue;if(d!==i.struct.id.client)si(l,i.struct,i.offset),i={struct:f,offset:0},u.next();else if(i.struct.id.clock+i.struct.length<f.id.clock)if(i.struct.constructor===Kt)i.struct.length=f.id.clock+f.length-i.struct.id.clock;else{si(l,i.struct,i.offset);const p=f.id.clock-i.struct.id.clock-i.struct.length;i={struct:new Kt(se(d,i.struct.id.clock+i.struct.length),p),offset:0}}else{const p=i.struct.id.clock+i.struct.length-f.id.clock;p>0&&(i.struct.constructor===Kt?i.struct.length-=p:f=tH(f,p)),i.struct.mergeWith(f)||(si(l,i.struct,i.offset),i={struct:f,offset:0},u.next())}}else i={struct:u.curr,offset:0},u.next();for(let f=u.curr;f!==null&&f.id.client===d&&f.id.clock===i.struct.id.clock+i.struct.length&&f.constructor!==Kt;f=u.next())si(l,i.struct,i.offset),i={struct:f,offset:0}}i!==null&&(si(l,i.struct,i.offset),i=null),nH(l);const a=r.map(u=>I$(u)),c=$d(a);return Eh(o,c),o.toUint8Array()},gk=t=>{t.written>0&&(t.clientStructs.push({written:t.written,restEncoder:Jt(t.encoder.restEncoder)}),t.encoder.restEncoder=Co(),t.written=0)},si=(t,e,n)=>{t.written>0&&t.currClient!==e.id.client&&gk(t),t.written===0&&(t.currClient=e.id.client,t.encoder.writeClient(e.id.client),ue(t.encoder.restEncoder,e.id.clock+n)),e.write(t.encoder,n),t.written++},nH=t=>{gk(t);const e=t.encoder.restEncoder;ue(e,t.clientStructs.length);for(let n=0;n<t.clientStructs.length;n++){const r=t.clientStructs[n];ue(e,r.written),ac(e,r.restEncoder)}},Fg="You must not compute changes after the event-handler fired.";class bc{constructor(e,n){this.target=e,this.currentTarget=e,this.transaction=n,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=rH(this.currentTarget,this.target))}deletes(e){return Js(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw yn(Fg);const e=new Map,n=this.target;this.transaction.changed.get(n).forEach(s=>{if(s!==null){const i=n._map.get(s);let o,l;if(this.adds(i)){let a=i.left;for(;a!==null&&this.adds(a);)a=a.left;if(this.deletes(i))if(a!==null&&this.deletes(a))o="delete",l=fu(a.content.getContent());else return;else a!==null&&this.deletes(a)?(o="update",l=fu(a.content.getContent())):(o="add",l=void 0)}else if(this.deletes(i))o="delete",l=fu(i.content.getContent());else return;e.set(s,{action:o,oldValue:l})}}),this._keys=e}return this._keys}get delta(){return this.changes.delta}adds(e){return e.id.clock>=(this.transaction.beforeState.get(e.id.client)||0)}get changes(){let e=this._changes;if(e===null){if(this.transaction.doc._transactionCleanups.length===0)throw yn(Fg);const n=this.target,r=qr(),s=qr(),i=[];if(e={added:r,deleted:s,delta:i,keys:this.keys},this.transaction.changed.get(n).has(null)){let l=null;const a=()=>{l&&i.push(l)};for(let c=n._start;c!==null;c=c.right)c.deleted?this.deletes(c)&&!this.adds(c)&&((l===null||l.delete===void 0)&&(a(),l={delete:0}),l.delete+=c.length,s.add(c)):this.adds(c)?((l===null||l.insert===void 0)&&(a(),l={insert:[]}),l.insert=l.insert.concat(c.content.getContent()),r.add(c)):((l===null||l.retain===void 0)&&(a(),l={retain:0}),l.retain+=c.length);l!==null&&l.retain===void 0&&a()}this._changes=e}return e}}const rH=(t,e)=>{const n=[];for(;e._item!==null&&e!==t;){if(e._item.parentSub!==null)n.unshift(e._item.parentSub);else{let r=0,s=e._item.parent._start;for(;s!==e._item&&s!==null;)!s.deleted&&s.countable&&(r+=s.length),s=s.right;n.unshift(r)}e=e._item.parent}return n},rt=()=>{nk("Invalid access: Add Yjs type to a document before reading data.")},yk=80;let Th=0;class sH{constructor(e,n){e.marker=!0,this.p=e,this.index=n,this.timestamp=Th++}}const iH=t=>{t.timestamp=Th++},bk=(t,e,n)=>{t.p.marker=!1,t.p=e,e.marker=!0,t.index=n,t.timestamp=Th++},oH=(t,e,n)=>{if(t.length>=yk){const r=t.reduce((s,i)=>s.timestamp<i.timestamp?s:i);return bk(r,e,n),r}else{const r=new sH(e,n);return t.push(r),r}},wc=(t,e)=>{if(t._start===null||e===0||t._searchMarker===null)return null;const n=t._searchMarker.length===0?null:t._searchMarker.reduce((i,o)=>xl(e-i.index)<xl(e-o.index)?i:o);let r=t._start,s=0;for(n!==null&&(r=n.p,s=n.index,iH(n));r.right!==null&&s<e;){if(!r.deleted&&r.countable){if(e<s+r.length)break;s+=r.length}r=r.right}for(;r.left!==null&&s>e;)r=r.left,!r.deleted&&r.countable&&(s-=r.length);for(;r.left!==null&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock;)r=r.left,!r.deleted&&r.countable&&(s-=r.length);return n!==null&&xl(n.index-s)<r.parent.length/yk?(bk(n,r,s),n):oH(t._searchMarker,r,s)},fo=(t,e,n)=>{for(let r=t.length-1;r>=0;r--){const s=t[r];if(n>0){let i=s.p;for(i.marker=!1;i&&(i.deleted||!i.countable);)i=i.left,i&&!i.deleted&&i.countable&&(s.index-=i.length);if(i===null||i.marker===!0){t.splice(r,1);continue}s.p=i,i.marker=!0}(e<s.index||n>0&&e===s.index)&&(s.index=hr(e,s.index+n))}},xc=(t,e,n)=>{const r=t,s=e.changedParentTypes;for(;Vn(s,t,()=>[]).push(n),t._item!==null;)t=t._item.parent;ak(r._eH,n,e)};class qe{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=Rg(),this._dEH=Rg(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,n){this.doc=e,this._item=n}_copy(){throw $t()}clone(){throw $t()}_write(e){}get _first(){let e=this._start;for(;e!==null&&e.deleted;)e=e.right;return e}_callObserver(e,n){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){Dg(this._eH,e)}observeDeep(e){Dg(this._dEH,e)}unobserve(e){Lg(this._eH,e)}unobserveDeep(e){Lg(this._dEH,e)}toJSON(){}}const wk=(t,e,n)=>{t.doc??rt(),e<0&&(e=t._length+e),n<0&&(n=t._length+n);let r=n-e;const s=[];let i=t._start;for(;i!==null&&r>0;){if(i.countable&&!i.deleted){const o=i.content.getContent();if(o.length<=e)e-=o.length;else{for(let l=e;l<o.length&&r>0;l++)s.push(o[l]),r--;e=0}}i=i.right}return s},xk=t=>{t.doc??rt();const e=[];let n=t._start;for(;n!==null;){if(n.countable&&!n.deleted){const r=n.content.getContent();for(let s=0;s<r.length;s++)e.push(r[s])}n=n.right}return e},vk=(t,e)=>{const n=[];let r=t._start;for(;r!==null;){if(r.countable&&Mr(r,e)){const s=r.content.getContent();for(let i=0;i<s.length;i++)n.push(s[i])}r=r.right}return n},ho=(t,e)=>{let n=0,r=t._start;for(t.doc??rt();r!==null;){if(r.countable&&!r.deleted){const s=r.content.getContent();for(let i=0;i<s.length;i++)e(s[i],n++,t)}r=r.right}},kk=(t,e)=>{const n=[];return ho(t,(r,s)=>{n.push(e(r,s,t))}),n},lH=t=>{let e=t._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){for(;e!==null&&e.deleted;)e=e.right;if(e===null)return{done:!0,value:void 0};n=e.content.getContent(),r=0,e=e.right}const s=n[r++];return n.length<=r&&(n=null),{done:!1,value:s}}}},Sk=(t,e)=>{t.doc??rt();const n=wc(t,e);let r=t._start;for(n!==null&&(r=n.p,e-=n.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(e<r.length)return r.content.getContent()[e];e-=r.length}},_a=(t,e,n,r)=>{let s=n;const i=t.doc,o=i.clientID,l=i.store,a=n===null?e._start:n.right;let c=[];const u=()=>{c.length>0&&(s=new pe(se(o,Ie(l,o)),s,s&&s.lastId,a,a&&a.id,e,null,new Yr(c)),s.integrate(t,0),c=[])};r.forEach(d=>{if(d===null)c.push(d);else switch(d.constructor){case Number:case Object:case Boolean:case Array:case String:c.push(d);break;default:switch(u(),d.constructor){case Uint8Array:case ArrayBuffer:s=new pe(se(o,Ie(l,o)),s,s&&s.lastId,a,a&&a.id,e,null,new Mo(new Uint8Array(d))),s.integrate(t,0);break;case Qr:s=new pe(se(o,Ie(l,o)),s,s&&s.lastId,a,a&&a.id,e,null,new To(d)),s.integrate(t,0);break;default:if(d instanceof qe)s=new pe(se(o,Ie(l,o)),s,s&&s.lastId,a,a&&a.id,e,null,new rn(d)),s.integrate(t,0);else throw new Error("Unexpected content type in insert operation")}}}),u()},Ck=()=>yn("Length exceeded!"),Ek=(t,e,n,r)=>{if(n>e._length)throw Ck();if(n===0)return e._searchMarker&&fo(e._searchMarker,n,r.length),_a(t,e,null,r);const s=n,i=wc(e,n);let o=e._start;for(i!==null&&(o=i.p,n-=i.index,n===0&&(o=o.prev,n+=o&&o.countable&&!o.deleted?o.length:0));o!==null;o=o.right)if(!o.deleted&&o.countable){if(n<=o.length){n<o.length&&xt(t,se(o.id.client,o.id.clock+n));break}n-=o.length}return e._searchMarker&&fo(e._searchMarker,s,r.length),_a(t,e,o,r)},aH=(t,e,n)=>{let s=(e._searchMarker||[]).reduce((i,o)=>o.index>i.index?o:i,{index:0,p:e._start}).p;if(s)for(;s.right;)s=s.right;return _a(t,e,s,n)},Mk=(t,e,n,r)=>{if(r===0)return;const s=n,i=r,o=wc(e,n);let l=e._start;for(o!==null&&(l=o.p,n-=o.index);l!==null&&n>0;l=l.right)!l.deleted&&l.countable&&(n<l.length&&xt(t,se(l.id.client,l.id.clock+n)),n-=l.length);for(;r>0&&l!==null;)l.deleted||(r<l.length&&xt(t,se(l.id.client,l.id.clock+r)),l.delete(t),r-=l.length),l=l.right;if(r>0)throw Ck();e._searchMarker&&fo(e._searchMarker,s,-i+r)},Na=(t,e,n)=>{const r=e._map.get(n);r!==void 0&&r.delete(t)},Ah=(t,e,n,r)=>{const s=e._map.get(n)||null,i=t.doc,o=i.clientID;let l;if(r==null)l=new Yr([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:l=new Yr([r]);break;case Uint8Array:l=new Mo(r);break;case Qr:l=new To(r);break;default:if(r instanceof qe)l=new rn(r);else throw new Error("Unexpected content type")}new pe(se(o,Ie(i.store,o)),s,s&&s.lastId,null,null,e,n,l).integrate(t,0)},_h=(t,e)=>{t.doc??rt();const n=t._map.get(e);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},Tk=t=>{const e={};return t.doc??rt(),t._map.forEach((n,r)=>{n.deleted||(e[r]=n.content.getContent()[n.length-1])}),e},Ak=(t,e)=>{t.doc??rt();const n=t._map.get(e);return n!==void 0&&!n.deleted},cH=(t,e)=>{const n={};return t._map.forEach((r,s)=>{let i=r;for(;i!==null&&(!e.sv.has(i.id.client)||i.id.clock>=(e.sv.get(i.id.client)||0));)i=i.left;i!==null&&Mr(i,e)&&(n[s]=i.content.getContent()[i.length-1])}),n},tl=t=>(t.doc??rt(),_$(t._map.entries(),e=>!e[1].deleted));class uH extends bc{}class vs extends qe{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){const n=new vs;return n.push(e),n}_integrate(e,n){super._integrate(e,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new vs}clone(){const e=new vs;return e.insert(0,this.toArray().map(n=>n instanceof qe?n.clone():n)),e}get length(){return this.doc??rt(),this._length}_callObserver(e,n){super._callObserver(e,n),xc(this,e,new uH(this,e))}insert(e,n){this.doc!==null?we(this.doc,r=>{Ek(r,this,e,n)}):this._prelimContent.splice(e,0,...n)}push(e){this.doc!==null?we(this.doc,n=>{aH(n,this,e)}):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,n=1){this.doc!==null?we(this.doc,r=>{Mk(r,this,e,n)}):this._prelimContent.splice(e,n)}get(e){return Sk(this,e)}toArray(){return xk(this)}slice(e=0,n=this.length){return wk(this,e,n)}toJSON(){return this.map(e=>e instanceof qe?e.toJSON():e)}map(e){return kk(this,e)}forEach(e){ho(this,e)}[Symbol.iterator](){return lH(this)}_write(e){e.writeTypeRef(LH)}}const dH=t=>new vs;class fH extends bc{constructor(e,n,r){super(e,n),this.keysChanged=r}}class Ps extends qe{constructor(e){super(),this._prelimContent=null,e===void 0?this._prelimContent=new Map:this._prelimContent=new Map(e)}_integrate(e,n){super._integrate(e,n),this._prelimContent.forEach((r,s)=>{this.set(s,r)}),this._prelimContent=null}_copy(){return new Ps}clone(){const e=new Ps;return this.forEach((n,r)=>{e.set(r,n instanceof qe?n.clone():n)}),e}_callObserver(e,n){xc(this,e,new fH(this,e,n))}toJSON(){this.doc??rt();const e={};return this._map.forEach((n,r)=>{if(!n.deleted){const s=n.content.getContent()[n.length-1];e[r]=s instanceof qe?s.toJSON():s}}),e}get size(){return[...tl(this)].length}keys(){return wu(tl(this),e=>e[0])}values(){return wu(tl(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return wu(tl(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??rt(),this._map.forEach((n,r)=>{n.deleted||e(n.content.getContent()[n.length-1],r,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc!==null?we(this.doc,n=>{Na(n,this,e)}):this._prelimContent.delete(e)}set(e,n){return this.doc!==null?we(this.doc,r=>{Ah(r,this,e,n)}):this._prelimContent.set(e,n),n}get(e){return _h(this,e)}has(e){return Ak(this,e)}clear(){this.doc!==null?we(this.doc,e=>{this.forEach(function(n,r,s){Na(e,s,r)})}):this._prelimContent.clear()}_write(e){e.writeTypeRef(jH)}}const hH=t=>new Ps,sr=(t,e)=>t===e||typeof t=="object"&&typeof e=="object"&&t&&e&&Mz(t,e);class Ud{constructor(e,n,r,s){this.left=e,this.right=n,this.index=r,this.currentAttributes=s}forward(){switch(this.right===null&&bt(),this.right.content.constructor){case je:this.right.deleted||Gs(this.currentAttributes,this.right.content);break;default:this.right.deleted||(this.index+=this.right.length);break}this.left=this.right,this.right=this.right.right}}const Vg=(t,e,n)=>{for(;e.right!==null&&n>0;){switch(e.right.content.constructor){case je:e.right.deleted||Gs(e.currentAttributes,e.right.content);break;default:e.right.deleted||(n<e.right.length&&xt(t,se(e.right.id.client,e.right.id.clock+n)),e.index+=e.right.length,n-=e.right.length);break}e.left=e.right,e.right=e.right.right}return e},nl=(t,e,n,r)=>{const s=new Map,i=r?wc(e,n):null;if(i){const o=new Ud(i.p.left,i.p,i.index,s);return Vg(t,o,n-i.index)}else{const o=new Ud(null,e._start,0,s);return Vg(t,o,n)}},_k=(t,e,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===je&&sr(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();const s=t.doc,i=s.clientID;r.forEach((o,l)=>{const a=n.left,c=n.right,u=new pe(se(i,Ie(s.store,i)),a,a&&a.lastId,c,c&&c.id,e,null,new je(l,o));u.integrate(t,0),n.right=u,n.forward()})},Gs=(t,e)=>{const{key:n,value:r}=e;r===null?t.delete(n):t.set(n,r)},Nk=(t,e)=>{for(;t.right!==null;){if(!(t.right.deleted||t.right.content.constructor===je&&sr(e[t.right.content.key]??null,t.right.content.value)))break;t.forward()}},Ok=(t,e,n,r)=>{const s=t.doc,i=s.clientID,o=new Map;for(const l in r){const a=r[l],c=n.currentAttributes.get(l)??null;if(!sr(c,a)){o.set(l,c);const{left:u,right:d}=n;n.right=new pe(se(i,Ie(s.store,i)),u,u&&u.lastId,d,d&&d.id,e,null,new je(l,a)),n.right.integrate(t,0),n.forward()}}return o},ku=(t,e,n,r,s)=>{n.currentAttributes.forEach((f,h)=>{s[h]===void 0&&(s[h]=null)});const i=t.doc,o=i.clientID;Nk(n,s);const l=Ok(t,e,n,s),a=r.constructor===String?new tn(r):r instanceof qe?new rn(r):new es(r);let{left:c,right:u,index:d}=n;e._searchMarker&&fo(e._searchMarker,n.index,a.getLength()),u=new pe(se(o,Ie(i.store,o)),c,c&&c.lastId,u,u&&u.id,e,null,a),u.integrate(t,0),n.right=u,n.index=d,n.forward(),_k(t,e,n,l)},Ug=(t,e,n,r,s)=>{const i=t.doc,o=i.clientID;Nk(n,s);const l=Ok(t,e,n,s);e:for(;n.right!==null&&(r>0||l.size>0&&(n.right.deleted||n.right.content.constructor===je));){if(!n.right.deleted)switch(n.right.content.constructor){case je:{const{key:a,value:c}=n.right.content,u=s[a];if(u!==void 0){if(sr(u,c))l.delete(a);else{if(r===0)break e;l.set(a,c)}n.right.delete(t)}else n.currentAttributes.set(a,c);break}default:r<n.right.length&&xt(t,se(n.right.id.client,n.right.id.clock+r)),r-=n.right.length;break}n.forward()}if(r>0){let a="";for(;r>0;r--)a+=`
|
|
394
|
-
`;n.right=new pe(se(o,Ie(i.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,e,null,new tn(a)),n.right.integrate(t,0),n.forward()}_k(t,e,n,l)},Ik=(t,e,n,r,s)=>{let i=e;const o=Yt();for(;i&&(!i.countable||i.deleted);){if(!i.deleted&&i.content.constructor===je){const c=i.content;o.set(c.key,c)}i=i.right}let l=0,a=!1;for(;e!==i;){if(n===e&&(a=!0),!e.deleted){const c=e.content;switch(c.constructor){case je:{const{key:u,value:d}=c,
|
|
395
|
-
`?o.insert.slice(0,-1):o.insert;(typeof l!="string"||l.length>0)&&ku(r,this,s,l,o.attributes||{})}else o.retain!==void 0?Ug(r,this,s,o.retain,o.attributes||{}):o.delete!==void 0&&Wg(r,s,o.delete)}}):this._pending.push(()=>this.applyDelta(e))}toDelta(e,n,r){this.doc??rt();const s=[],i=new Map,o=this.doc;let l="",a=this._start;function c(){if(l.length>0){const d={};let f=!1;i.forEach((p,g)=>{f=!0,d[g]=p});const h={insert:l};f&&(h.attributes=d),s.push(h),l=""}}const u=()=>{for(;a!==null;){if(Mr(a,e)||n!==void 0&&Mr(a,n))switch(a.content.constructor){case tn:{const d=i.get("ychange");e!==void 0&&!Mr(a,e)?(d===void 0||d.user!==a.id.client||d.type!=="removed")&&(c(),i.set("ychange",r?r("removed",a.id):{type:"removed"})):n!==void 0&&!Mr(a,n)?(d===void 0||d.user!==a.id.client||d.type!=="added")&&(c(),i.set("ychange",r?r("added",a.id):{type:"added"})):d!==void 0&&(c(),i.delete("ychange")),l+=a.content.str;break}case rn:case es:{c();const d={insert:a.content.getContent()[0]};if(i.size>0){const f={};d.attributes=f,i.forEach((h,p)=>{f[p]=h})}s.push(d);break}case je:Mr(a,e)&&(c(),Gs(i,a.content));break}a=a.right}c()};return e||n?we(o,d=>{e&&Fd(d,e),n&&Fd(d,n),u()},"cleanup"):u(),s}insert(e,n,r){if(n.length<=0)return;const s=this.doc;s!==null?we(s,i=>{const o=nl(i,this,e,!r);r||(r={},o.currentAttributes.forEach((l,a)=>{r[a]=l})),ku(i,this,o,n,r)}):this._pending.push(()=>this.insert(e,n,r))}insertEmbed(e,n,r){const s=this.doc;s!==null?we(s,i=>{const o=nl(i,this,e,!r);ku(i,this,o,n,r||{})}):this._pending.push(()=>this.insertEmbed(e,n,r||{}))}delete(e,n){if(n===0)return;const r=this.doc;r!==null?we(r,s=>{Wg(s,nl(s,this,e,!0),n)}):this._pending.push(()=>this.delete(e,n))}format(e,n,r){if(n===0)return;const s=this.doc;s!==null?we(s,i=>{const o=nl(i,this,e,!1);o.right!==null&&Ug(i,this,o,n,r)}):this._pending.push(()=>this.format(e,n,r))}removeAttribute(e){this.doc!==null?we(this.doc,n=>{Na(n,this,e)}):this._pending.push(()=>this.removeAttribute(e))}setAttribute(e,n){this.doc!==null?we(this.doc,r=>{Ah(r,this,e,n)}):this._pending.push(()=>this.setAttribute(e,n))}getAttribute(e){return _h(this,e)}getAttributes(){return Tk(this)}_write(e){e.writeTypeRef(PH)}}const bH=t=>new mr;class Su{constructor(e,n=()=>!0){this._filter=n,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??rt()}[Symbol.iterator](){return this}next(){let e=this._currentNode,n=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(n)))do if(n=e.content.type,!e.deleted&&(n.constructor===et||n.constructor===Gr)&&n._start!==null)e=n._start;else for(;e!==null;){const r=e.next;if(r!==null){e=r;break}else e.parent===this._root?e=null:e=e.parent._item}while(e!==null&&(e.deleted||!this._filter(e.content.type)));return this._firstCall=!1,e===null?{value:void 0,done:!0}:(this._currentNode=e,{value:e.content.type,done:!1})}}class Gr extends qe{constructor(){super(),this._prelimContent=[]}get firstChild(){const e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,n){super._integrate(e,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new Gr}clone(){const e=new Gr;return e.insert(0,this.toArray().map(n=>n instanceof qe?n.clone():n)),e}get length(){return this.doc??rt(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new Su(this,e)}querySelector(e){e=e.toUpperCase();const r=new Su(this,s=>s.nodeName&&s.nodeName.toUpperCase()===e).next();return r.done?null:r.value}querySelectorAll(e){return e=e.toUpperCase(),Kr(new Su(this,n=>n.nodeName&&n.nodeName.toUpperCase()===e))}_callObserver(e,n){xc(this,e,new vH(this,n,e))}toString(){return kk(this,e=>e.toString()).join("")}toJSON(){return this.toString()}toDOM(e=document,n={},r){const s=e.createDocumentFragment();return r!==void 0&&r._createAssociation(s,this),ho(this,i=>{s.insertBefore(i.toDOM(e,n,r),null)}),s}insert(e,n){this.doc!==null?we(this.doc,r=>{Ek(r,this,e,n)}):this._prelimContent.splice(e,0,...n)}insertAfter(e,n){if(this.doc!==null)we(this.doc,r=>{const s=e&&e instanceof qe?e._item:e;_a(r,this,s,n)});else{const r=this._prelimContent,s=e===null?0:r.findIndex(i=>i===e)+1;if(s===0&&e!==null)throw yn("Reference item not found");r.splice(s,0,...n)}}delete(e,n=1){this.doc!==null?we(this.doc,r=>{Mk(r,this,e,n)}):this._prelimContent.splice(e,n)}toArray(){return xk(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return Sk(this,e)}slice(e=0,n=this.length){return wk(this,e,n)}forEach(e){ho(this,e)}_write(e){e.writeTypeRef(zH)}}const wH=t=>new Gr;class et extends Gr{constructor(e="UNDEFINED"){super(),this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,n){super._integrate(e,n),this._prelimAttrs.forEach((r,s)=>{this.setAttribute(s,r)}),this._prelimAttrs=null}_copy(){return new et(this.nodeName)}clone(){const e=new et(this.nodeName),n=this.getAttributes();return Cz(n,(r,s)=>{e.setAttribute(s,r)}),e.insert(0,this.toArray().map(r=>r instanceof qe?r.clone():r)),e}toString(){const e=this.getAttributes(),n=[],r=[];for(const l in e)r.push(l);r.sort();const s=r.length;for(let l=0;l<s;l++){const a=r[l];n.push(a+'="'+e[a]+'"')}const i=this.nodeName.toLocaleLowerCase(),o=n.length>0?" "+n.join(" "):"";return`<${i}${o}>${super.toString()}</${i}>`}removeAttribute(e){this.doc!==null?we(this.doc,n=>{Na(n,this,e)}):this._prelimAttrs.delete(e)}setAttribute(e,n){this.doc!==null?we(this.doc,r=>{Ah(r,this,e,n)}):this._prelimAttrs.set(e,n)}getAttribute(e){return _h(this,e)}hasAttribute(e){return Ak(this,e)}getAttributes(e){return e?cH(this,e):Tk(this)}toDOM(e=document,n={},r){const s=e.createElement(this.nodeName),i=this.getAttributes();for(const o in i){const l=i[o];typeof l=="string"&&s.setAttribute(o,l)}return ho(this,o=>{s.appendChild(o.toDOM(e,n,r))}),r!==void 0&&r._createAssociation(s,this),s}_write(e){e.writeTypeRef(BH),e.writeKey(this.nodeName)}}const xH=t=>new et(t.readKey());class vH extends bc{constructor(e,n,r){super(e,r),this.childListChanged=!1,this.attributesChanged=new Set,n.forEach(s=>{s===null?this.childListChanged=!0:this.attributesChanged.add(s)})}}class Oa extends Ps{constructor(e){super(),this.hookName=e}_copy(){return new Oa(this.hookName)}clone(){const e=new Oa(this.hookName);return this.forEach((n,r)=>{e.set(r,n)}),e}toDOM(e=document,n={},r){const s=n[this.hookName];let i;return s!==void 0?i=s.createDom(this):i=document.createElement(this.hookName),i.setAttribute("data-yjs-hook",this.hookName),r!==void 0&&r._createAssociation(i,this),i}_write(e){e.writeTypeRef($H),e.writeKey(this.hookName)}}const kH=t=>new Oa(t.readKey());class st extends mr{get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new st}clone(){const e=new st;return e.applyDelta(this.toDelta()),e}toDOM(e=document,n,r){const s=e.createTextNode(this.toString());return r!==void 0&&r._createAssociation(s,this),s}toString(){return this.toDelta().map(e=>{const n=[];for(const s in e.attributes){const i=[];for(const o in e.attributes[s])i.push({key:o,value:e.attributes[s][o]});i.sort((o,l)=>o.key<l.key?-1:1),n.push({nodeName:s,attrs:i})}n.sort((s,i)=>s.nodeName<i.nodeName?-1:1);let r="";for(let s=0;s<n.length;s++){const i=n[s];r+=`<${i.nodeName}`;for(let o=0;o<i.attrs.length;o++){const l=i.attrs[o];r+=` ${l.key}="${l.value}"`}r+=">"}r+=e.insert;for(let s=n.length-1;s>=0;s--)r+=`</${n[s].nodeName}>`;return r}).join("")}toJSON(){return this.toString()}_write(e){e.writeTypeRef(HH)}}const SH=t=>new st;class Nh{constructor(e,n){this.id=e,this.length=n}get deleted(){throw $t()}mergeWith(e){return!1}write(e,n,r){throw $t()}integrate(e,n){throw $t()}}const CH=0;class Pt extends Nh{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,n){n>0&&(this.id.clock+=n,this.length-=n),fk(e.doc.store,this)}write(e,n){e.writeInfo(CH),e.writeLen(this.length-n)}getMissing(e,n){return null}}class Mo{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new Mo(this.content)}splice(e){throw $t()}mergeWith(e){return!1}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeBuf(this.content)}getRef(){return 3}}const EH=t=>new Mo(t.readBuf());class po{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new po(this.len)}splice(e){const n=new po(this.len-e);return this.len=e,n}mergeWith(e){return this.len+=e.len,!0}integrate(e,n){ao(e.deleteSet,n.id.client,n.id.clock,this.len),n.markDeleted()}delete(e){}gc(e){}write(e,n){e.writeLen(this.len-n)}getRef(){return 1}}const MH=t=>new po(t.readLen()),Rk=(t,e)=>new Qr({guid:t,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class To{constructor(e){e._item&&console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid."),this.doc=e;const n={};this.opts=n,e.gc||(n.gc=!1),e.autoLoad&&(n.autoLoad=!0),e.meta!==null&&(n.meta=e.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new To(Rk(this.doc.guid,this.opts))}splice(e){throw $t()}mergeWith(e){return!1}integrate(e,n){this.doc._item=n,e.subdocsAdded.add(this.doc),this.doc.shouldLoad&&e.subdocsLoaded.add(this.doc)}delete(e){e.subdocsAdded.has(this.doc)?e.subdocsAdded.delete(this.doc):e.subdocsRemoved.add(this.doc)}gc(e){}write(e,n){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}}const TH=t=>new To(Rk(t.readString(),t.readAny()));class es{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new es(this.embed)}splice(e){throw $t()}mergeWith(e){return!1}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeJSON(this.embed)}getRef(){return 5}}const AH=t=>new es(t.readJSON());class je{constructor(e,n){this.key=e,this.value=n}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new je(this.key,this.value)}splice(e){throw $t()}mergeWith(e){return!1}integrate(e,n){const r=n.parent;r._searchMarker=null,r._hasFormatting=!0}delete(e){}gc(e){}write(e,n){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}}const _H=t=>new je(t.readKey(),t.readJSON());class Ia{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Ia(this.arr)}splice(e){const n=new Ia(this.arr.slice(e));return this.arr=this.arr.slice(0,e),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,n){}delete(e){}gc(e){}write(e,n){const r=this.arr.length;e.writeLen(r-n);for(let s=n;s<r;s++){const i=this.arr[s];e.writeString(i===void 0?"undefined":JSON.stringify(i))}}getRef(){return 2}}const NH=t=>{const e=t.readLen(),n=[];for(let r=0;r<e;r++){const s=t.readString();s==="undefined"?n.push(void 0):n.push(JSON.parse(s))}return new Ia(n)},OH=Sa("node_env")==="development";class Yr{constructor(e){this.arr=e,OH&&Iv(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Yr(this.arr)}splice(e){const n=new Yr(this.arr.slice(e));return this.arr=this.arr.slice(0,e),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,n){}delete(e){}gc(e){}write(e,n){const r=this.arr.length;e.writeLen(r-n);for(let s=n;s<r;s++){const i=this.arr[s];e.writeAny(i)}}getRef(){return 8}}const IH=t=>{const e=t.readLen(),n=[];for(let r=0;r<e;r++)n.push(t.readAny());return new Yr(n)};class tn{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new tn(this.str)}splice(e){const n=new tn(this.str.slice(e));this.str=this.str.slice(0,e);const r=this.str.charCodeAt(e-1);return r>=55296&&r<=56319&&(this.str=this.str.slice(0,e-1)+"�",n.str="�"+n.str.slice(1)),n}mergeWith(e){return this.str+=e.str,!0}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeString(n===0?this.str:this.str.slice(n))}getRef(){return 4}}const RH=t=>new tn(t.readString()),DH=[dH,hH,bH,xH,wH,kH,SH],LH=0,jH=1,PH=2,BH=3,zH=4,$H=5,HH=6;class rn{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new rn(this.type._copy())}splice(e){throw $t()}mergeWith(e){return!1}integrate(e,n){this.type._integrate(e.doc,n)}delete(e){let n=this.type._start;for(;n!==null;)n.deleted?n.id.clock<(e.beforeState.get(n.id.client)||0)&&e._mergeStructs.push(n):n.delete(e),n=n.right;this.type._map.forEach(r=>{r.deleted?r.id.clock<(e.beforeState.get(r.id.client)||0)&&e._mergeStructs.push(r):r.delete(e)}),e.changed.delete(this.type)}gc(e){let n=this.type._start;for(;n!==null;)n.gc(e,!0),n=n.right;this.type._start=null,this.type._map.forEach(r=>{for(;r!==null;)r.gc(e,!0),r=r.left}),this.type._map=new Map}write(e,n){this.type._write(e)}getRef(){return 7}}const FH=t=>new rn(DH[t.readTypeRef()](t)),Wd=(t,e)=>{let n=e,r=0,s;do r>0&&(n=se(n.client,n.clock+r)),s=xs(t,n),r=n.clock-s.id.clock,n=s.redone;while(n!==null&&s instanceof pe);return{item:s,diff:r}},Oh=(t,e)=>{for(;t!==null&&t.keep!==e;)t.keep=e,t=t.parent._item},Ra=(t,e,n)=>{const{client:r,clock:s}=e.id,i=new pe(se(r,s+n),e,se(r,s+n-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(n));return e.deleted&&i.markDeleted(),e.keep&&(i.keep=!0),e.redone!==null&&(i.redone=se(e.redone.client,e.redone.clock+n)),e.right=i,i.right!==null&&(i.right.left=i),t._mergeStructs.push(i),i.parentSub!==null&&i.right===null&&i.parent._map.set(i.parentSub,i),e.length=n,i},qg=(t,e)=>dh(t,n=>Js(n.deletions,e)),Dk=(t,e,n,r,s,i)=>{const o=t.doc,l=o.store,a=o.clientID,c=e.redone;if(c!==null)return xt(t,c);let u=e.parent._item,d=null,f;if(u!==null&&u.deleted===!0){if(u.redone===null&&(!n.has(u)||Dk(t,u,n,r,s,i)===null))return null;for(;u.redone!==null;)u=xt(t,u.redone)}const h=u===null?e.parent:u.content.type;if(e.parentSub===null){for(d=e.left,f=e;d!==null;){let b=d;for(;b!==null&&b.parent._item!==u;)b=b.redone===null?null:xt(t,b.redone);if(b!==null&&b.parent._item===u){d=b;break}d=d.left}for(;f!==null;){let b=f;for(;b!==null&&b.parent._item!==u;)b=b.redone===null?null:xt(t,b.redone);if(b!==null&&b.parent._item===u){f=b;break}f=f.right}}else{if(f=null,e.right&&!s){for(d=e;d!==null&&d.right!==null&&(d.right.redone||Js(r,d.right.id)||qg(i.undoStack,d.right.id)||qg(i.redoStack,d.right.id));)for(d=d.right;d.redone;)d=xt(t,d.redone);if(d&&d.right!==null)return null}else d=h._map.get(e.parentSub)||null;d!==null&&d.parent._item!==u&&(d=h._map.get(e.parentSub)||null)}const p=Ie(l,a),g=se(a,p),y=new pe(g,d,d&&d.lastId,f,f&&f.id,h,e.parentSub,e.content.copy());return e.redone=g,Oh(y,!0),y.integrate(t,0),y};class pe extends Nh{constructor(e,n,r,s,i,o,l,a){super(e,a.getLength()),this.origin=r,this.left=n,this.right=s,this.rightOrigin=i,this.parent=o,this.parentSub=l,this.redone=null,this.content=a,this.info=this.content.isCountable()?xg:0}set marker(e){(this.info&pu)>0!==e&&(this.info^=pu)}get marker(){return(this.info&pu)>0}get keep(){return(this.info&wg)>0}set keep(e){this.keep!==e&&(this.info^=wg)}get countable(){return(this.info&xg)>0}get deleted(){return(this.info&hu)>0}set deleted(e){this.deleted!==e&&(this.info^=hu)}markDeleted(){this.info|=hu}getMissing(e,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=Ie(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=Ie(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===ws&&this.id.client!==this.parent.client&&this.parent.clock>=Ie(n,this.parent.client))return this.parent.client;if(this.origin&&(this.left=jg(e,n,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=xt(e,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===Pt||this.right&&this.right.constructor===Pt)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===pe?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===pe&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===ws){const r=xs(n,this.parent);r.constructor===Pt?this.parent=null:this.parent=r.content.type}return null}integrate(e,n){if(n>0&&(this.id.clock+=n,this.left=jg(e,e.doc.store,se(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(n),this.length-=n),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let r=this.left,s;if(r!==null)s=r.right;else if(this.parentSub!==null)for(s=this.parent._map.get(this.parentSub)||null;s!==null&&s.left!==null;)s=s.left;else s=this.parent._start;const i=new Set,o=new Set;for(;s!==null&&s!==this.right;){if(o.add(s),i.add(s),Qo(this.origin,s.origin)){if(s.id.client<this.id.client)r=s,i.clear();else if(Qo(this.rightOrigin,s.rightOrigin))break}else if(s.origin!==null&&o.has(xs(e.doc.store,s.origin)))i.has(xs(e.doc.store,s.origin))||(r=s,i.clear());else break;s=s.right}this.left=r}if(this.left!==null){const r=this.left.right;this.right=r,this.left.right=this}else{let r;if(this.parentSub!==null)for(r=this.parent._map.get(this.parentSub)||null;r!==null&&r.left!==null;)r=r.left;else r=this.parent._start,this.parent._start=this;this.right=r}this.right!==null?this.right.left=this:this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(e)),this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),fk(e.doc.store,this),this.content.integrate(e,this),Bg(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new Pt(this.id,this.length).integrate(e,0)}get next(){let e=this.right;for(;e!==null&&e.deleted;)e=e.right;return e}get prev(){let e=this.left;for(;e!==null&&e.deleted;)e=e.left;return e}get lastId(){return this.length===1?this.id:se(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&Qo(e.origin,this.lastId)&&this.right===e&&Qo(this.rightOrigin,e.rightOrigin)&&this.id.client===e.id.client&&this.id.clock+this.length===e.id.clock&&this.deleted===e.deleted&&this.redone===null&&e.redone===null&&this.content.constructor===e.content.constructor&&this.content.mergeWith(e.content)){const n=this.parent._searchMarker;return n&&n.forEach(r=>{r.p===e&&(r.p=this,!this.deleted&&this.countable&&(r.index-=this.length))}),e.keep&&(this.keep=!0),this.right=e.right,this.right!==null&&(this.right.left=this),this.length+=e.length,!0}return!1}delete(e){if(!this.deleted){const n=this.parent;this.countable&&this.parentSub===null&&(n._length-=this.length),this.markDeleted(),ao(e.deleteSet,this.id.client,this.id.clock,this.length),Bg(e,n,this.parentSub),this.content.delete(e)}}gc(e,n){if(!this.deleted)throw bt();this.content.gc(e),n?K$(e,this,new Pt(this.id,this.length)):this.content=new po(this.length)}write(e,n){const r=n>0?se(this.id.client,this.id.clock+n-1):this.origin,s=this.rightOrigin,i=this.parentSub,o=this.content.getRef()&lc|(r===null?0:mt)|(s===null?0:Ln)|(i===null?0:ro);if(e.writeInfo(o),r!==null&&e.writeLeftID(r),s!==null&&e.writeRightID(s),r===null&&s===null){const l=this.parent;if(l._item!==void 0){const a=l._item;if(a===null){const c=co(l);e.writeParentInfo(!0),e.writeString(c)}else e.writeParentInfo(!1),e.writeLeftID(a.id)}else l.constructor===String?(e.writeParentInfo(!0),e.writeString(l)):l.constructor===ws?(e.writeParentInfo(!1),e.writeLeftID(l)):bt();i!==null&&e.writeString(i)}this.content.write(e,n)}}const Lk=(t,e)=>VH[e&lc](t),VH=[()=>{bt()},MH,NH,EH,RH,AH,_H,FH,IH,TH,()=>{bt()}],UH=10;class Kt extends Nh{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,n){bt()}write(e,n){e.writeInfo(UH),ue(e.restEncoder,this.length-n)}getMissing(e,n){return null}}const jk=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},Pk="__ $YJS$ __";jk[Pk]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");jk[Pk]=!0;const WH=()=>{let t=!0;return(e,n)=>{if(t){t=!1;try{e()}finally{t=!0}}else n!==void 0&&n()}},qH=/[\uD800-\uDBFF]/,KH=/[\uDC00-\uDFFF]/,JH=(t,e)=>{let n=0,r=0;for(;n<t.length&&n<e.length&&t[n]===e[n];)n++;for(n>0&&qH.test(t[n-1])&&n--;r+n<t.length&&r+n<e.length&&t[t.length-r-1]===e[e.length-r-1];)r++;return r>0&&KH.test(t[t.length-r])&&r--,{index:n,remove:t.length-n-r,insert:e.slice(n,e.length-r)}},GH=JH,hn=(t,e)=>t>>>e|t<<32-e,YH=t=>hn(t,2)^hn(t,13)^hn(t,22),XH=t=>hn(t,6)^hn(t,11)^hn(t,25),ZH=t=>hn(t,7)^hn(t,18)^t>>>3,QH=t=>hn(t,17)^hn(t,19)^t>>>10,e3=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),t3=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);class n3{constructor(){const e=new ArrayBuffer(320);this._H=new Uint32Array(e,0,8),this._H.set(t3),this._W=new Uint32Array(e,64,64)}_updateHash(){const e=this._H,n=this._W;for(let d=16;d<64;d++)n[d]=QH(n[d-2])+n[d-7]+ZH(n[d-15])+n[d-16];let r=e[0],s=e[1],i=e[2],o=e[3],l=e[4],a=e[5],c=e[6],u=e[7];for(let d=0,f,h;d<64;d++)f=u+XH(l)+(l&a^~l&c)+e3[d]+n[d]>>>0,h=YH(r)+(r&s^r&i^s&i)>>>0,u=c,c=a,a=l,l=o+f>>>0,o=i,i=s,s=r,r=f+h>>>0;e[0]+=r,e[1]+=s,e[2]+=i,e[3]+=o,e[4]+=l,e[5]+=a,e[6]+=c,e[7]+=u}digest(e){let n=0;for(;n+56<=e.length;){let o=0;for(;o<16&&n+3<e.length;o++)this._W[o]=e[n++]<<24|e[n++]<<16|e[n++]<<8|e[n++];if(n%64!==0){for(this._W.fill(0,o,16);n<e.length;)this._W[o]|=e[n]<<(3-n%4)*8,n++;this._W[o]|=mt<<(3-n%4)*8}this._updateHash()}const r=n%64!==0;this._W.fill(0,0,16);let s=0;for(;n<e.length;s++)for(let o=3;o>=0&&n<e.length;o--)this._W[s]|=e[n++]<<o*8;r||(this._W[s-(n%4===0?0:1)]|=mt<<(3-n%4)*8),this._W[14]=e.byteLength/jB,this._W[15]=e.byteLength*8,this._updateHash();const i=new Uint8Array(32);for(let o=0;o<this._H.length;o++)for(let l=0;l<4;l++)i[o*4+l]=this._H[o]>>>(3-l)*8;return i}}const r3=t=>new n3().digest(t),Te=new ae("y-sync"),jn=new ae("y-undo");new ae("yjs-cursor");const s3=t=>{for(let n=6;n<t.length;n++)t[n%6]=t[n%6]^t[n];return t.slice(0,6)},i3=t=>Lz(s3(r3(jz(t)))),Da=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&e.sv.get(t.id.client)>t.id.clock&&!Js(e.ds,t.id),o3=[{light:"#ecd44433",dark:"#ecd444"}],l3=(t,e,n)=>{if(!t.has(n)){if(t.size<e.length){const r=qr();t.forEach(s=>r.add(s)),e=e.filter(s=>!r.has(s))}t.set(n,mz(e))}return t.get(n)},a3=(t,{colors:e=o3,colorMapping:n=new Map,permanentUserData:r=null,onFirstRender:s=()=>{},mapping:i}={})=>{let o=!1;const l=new f3(t,i),a=new ce({props:{editable:c=>{const u=Te.getState(c);return u.snapshot==null&&u.prevSnapshot==null}},key:Te,state:{init:(c,u)=>({type:t,doc:t.doc,binding:l,snapshot:null,prevSnapshot:null,isChangeOrigin:!1,isUndoRedoOperation:!1,addToHistory:!0,colors:e,colorMapping:n,permanentUserData:r}),apply:(c,u)=>{const d=c.getMeta(Te);if(d!==void 0){u=Object.assign({},u);for(const f in d)u[f]=d[f]}return u.addToHistory=c.getMeta("addToHistory")!==!1,u.isChangeOrigin=d!==void 0&&!!d.isChangeOrigin,u.isUndoRedoOperation=d!==void 0&&!!d.isChangeOrigin&&!!d.isUndoRedoOperation,l.prosemirrorView!==null&&d!==void 0&&(d.snapshot!=null||d.prevSnapshot!=null)&&Xv(0,()=>{l.prosemirrorView!=null&&(d.restore==null?l._renderSnapshot(d.snapshot,d.prevSnapshot,u):(l._renderSnapshot(d.snapshot,d.snapshot,u),delete u.restore,delete u.snapshot,delete u.prevSnapshot,l.mux(()=>{l._prosemirrorChanged(l.prosemirrorView.state.doc)})))}),u}},view:c=>(l.initView(c),i==null&&l._forceRerender(),s(),{update:()=>{const u=a.getState(c.state);if(u.snapshot==null&&u.prevSnapshot==null&&(o||c.state.doc.content.findDiffStart(c.state.doc.type.createAndFill().content)!==null)){if(o=!0,u.addToHistory===!1&&!u.isChangeOrigin){const d=jn.getState(c.state),f=d&&d.undoManager;f&&f.stopCapturing()}l.mux(()=>{u.doc.transact(d=>{d.meta.set("addToHistory",u.addToHistory),l._prosemirrorChanged(c.state.doc)},Te)})}},destroy:()=>{l.destroy()}})});return a},Kg=(t,e,n,r)=>{if(n==null||!(r===null||n>1&&r<=1||E3(e,t,n,r)))return r;const i=Uk(e,t,n);return i!==null?i:r},c3=(t,e,n,r)=>{if(e!==null&&e.anchor!==null&&e.head!==null)if(e.type==="all")t.setSelection(new dn(t.doc));else if(e.type==="node"){const s=Tr(n.doc,n.type,e.anchor,n.mapping);s!==null&&t.setSelection(u3(t,s))}else if(e.type==="nodeRange"){const s=Tr(n.doc,n.type,e.anchor,n.mapping),i=Tr(n.doc,n.type,e.head,n.mapping),o=d3(t,s,i,e.depth);o!==null&&t.setSelection(o)}else{let s=Tr(n.doc,n.type,e.anchor,n.mapping),i=Tr(n.doc,n.type,e.head,n.mapping);r!=null&&(s=Kg(t.doc,r,e.absAnchor,s),i=Kg(t.doc,r,e.absHead,i)),s===null&&(s=i),i===null&&(i=s),s!==null&&i!==null&&t.setSelection(ee.between(t.doc.resolve(s),t.doc.resolve(i)))}},u3=(t,e)=>{const n=t.doc.resolve(e);return n.nodeAfter?Y.create(t.doc,e):ee.near(n)},d3=(t,e,n,r)=>{if(e===null||n===null)return null;const s=Math.min(Math.max(e,0),t.doc.content.size),i=Math.min(Math.max(n,0),t.doc.content.size);try{const o=te.fromJSON(t.doc,{type:"nodeRange",anchor:s,head:i,depth:r});return o.ranges.length?o:ee.near(t.doc.resolve(s))}catch{return ee.near(t.doc.resolve(s))}},qd=(t,e)=>{const n=e.selection.jsonID;return{type:n,depth:n==="nodeRange"?e.selection.depth:void 0,anchor:Ba(e.selection.anchor,t.type,t.mapping),head:Ba(e.selection.head,t.type,t.mapping),absAnchor:e.selection.anchor,absHead:e.selection.head}};class f3{constructor(e,n=new Map){this.type=e,this.prosemirrorView=null,this.mux=WH(),this.mapping=n,this.isOMark=new Map,this._observeFunction=this._typeChanged.bind(this),this.doc=e.doc,this.beforeTransactionSelection=null,this.beforeAllTransactions=()=>{this.beforeTransactionSelection===null&&this.prosemirrorView!=null&&(this.beforeTransactionSelection=qd(this,this.prosemirrorView.state))},this.afterAllTransactions=()=>{this.beforeTransactionSelection=null},this._domSelectionInView=null}get _tr(){return this.prosemirrorView.state.tr.setMeta("addToHistory",!1)}_isLocalCursorInView(){return this.prosemirrorView.hasFocus()?(Rv&&this._domSelectionInView===null&&(Xv(0,()=>{this._domSelectionInView=null}),this._domSelectionInView=this._isDomSelectionInView()),this._domSelectionInView):!1}_isDomSelectionInView(){const e=this.prosemirrorView._root.getSelection();if(e==null||e.anchorNode==null)return!1;const n=this.prosemirrorView._root.createRange();n.setStart(e.anchorNode,e.anchorOffset),n.setEnd(e.focusNode,e.focusOffset),n.getClientRects().length===0&&n.startContainer&&n.collapsed&&n.selectNodeContents(n.startContainer);const s=n.getBoundingClientRect(),i=Eo.documentElement;return s.bottom>=0&&s.right>=0&&s.left<=(window.innerWidth||i.clientWidth||0)&&s.top<=(window.innerHeight||i.clientHeight||0)}renderSnapshot(e,n){n||(n=uk(ik(),new Map)),this.prosemirrorView.dispatch(this._tr.setMeta(Te,{snapshot:e,prevSnapshot:n}))}unrenderSnapshot(){this.mapping.clear(),this.mux(()=>{const e=this.type.toArray().map(r=>El(r,this.prosemirrorView.state.schema,this)).filter(r=>r!==null),n=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new K(j.from(e),0,0));n.setMeta(Te,{snapshot:null,prevSnapshot:null}),this.prosemirrorView.dispatch(n)})}_forceRerender(){this.mapping.clear(),this.mux(()=>{const e=this.beforeTransactionSelection!==null?null:this.prosemirrorView.state.selection,n=this.type.toArray().map(s=>El(s,this.prosemirrorView.state.schema,this)).filter(s=>s!==null),r=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new K(j.from(n),0,0));if(e){const s=Jr(hr(e.anchor,0),r.doc.content.size),i=Jr(hr(e.head,0),r.doc.content.size);r.setSelection(ee.create(r.doc,s,i))}this.prosemirrorView.dispatch(r.setMeta(Te,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(e,n,r){let s=this.doc,i=this.type;if(e||(e=vu(this.doc)),e instanceof Uint8Array||n instanceof Uint8Array)if((!(e instanceof Uint8Array)||!(n instanceof Uint8Array))&&bt(),s=new Qr({gc:!1}),Hd(s,n),n=vu(s),Hd(s,e),e=vu(s),i._item===null){const o=Array.from(this.doc.share.keys()).find(l=>this.doc.share.get(l)===this.type);i=s.getXmlFragment(o)}else{const o=s.store.clients.get(i._item.id.client)??[],l=en(o,i._item.id.clock);i=o[l].content.type}this.mapping.clear(),this.mux(()=>{s.transact(o=>{const l=r.permanentUserData;l&&l.dss.forEach(d=>{pr(o,d,f=>{})});const a=(d,f)=>{const h=d==="added"?l.getUserByClientId(f.client):l.getUserByDeletedId(f);return{user:h,type:d,color:l3(r.colorMapping,r.colors,h)}},c=vk(i,new Mh(n.ds,e.sv)).map(d=>!d._item.deleted||Da(d._item,e)||Da(d._item,n)?El(d,this.prosemirrorView.state.schema,{mapping:new Map,isOMark:new Map},e,n,a):null).filter(d=>d!==null),u=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new K(j.from(c),0,0));this.prosemirrorView.dispatch(u.setMeta(Te,{isChangeOrigin:!0}))},Te)})}_typeChanged(e,n){if(this.prosemirrorView==null)return;const r=Te.getState(this.prosemirrorView.state);if(e.length===0||r.snapshot!=null||r.prevSnapshot!=null){this.renderSnapshot(r.snapshot,r.prevSnapshot);return}this.mux(()=>{const s=(a,c)=>this.mapping.delete(c);pr(n,n.deleteSet,a=>{if(a.constructor===pe){const c=a.content.type;c&&this.mapping.delete(c)}}),n.changed.forEach(s),n.changedParentTypes.forEach(s),this.mapping.clear();const i=this.type.toArray().map(a=>Bk(a,this.prosemirrorView.state.schema,this)).filter(a=>a!==null),o=this.prosemirrorView.state.doc;let l=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new K(j.from(i),0,0));c3(l,this.beforeTransactionSelection,this,o),l=l.setMeta(Te,{isChangeOrigin:!0,isUndoRedoOperation:n.origin instanceof mk}),this.beforeTransactionSelection!==null&&this._isLocalCursorInView()&&l.scrollIntoView(),this.prosemirrorView.dispatch(l)})}_prosemirrorChanged(e){this.doc.transact(()=>{ja(this.doc,this.type,e,this),this.beforeTransactionSelection=qd(this,this.prosemirrorView.state)},Te)}initView(e){this.prosemirrorView!=null&&this.destroy(),this.prosemirrorView=e,this.doc.on("beforeAllTransactions",this.beforeAllTransactions),this.doc.on("afterAllTransactions",this.afterAllTransactions),this.type.observeDeep(this._observeFunction)}destroy(){this.prosemirrorView!=null&&(this.prosemirrorView=null,this.type.unobserveDeep(this._observeFunction),this.doc.off("beforeAllTransactions",this.beforeAllTransactions),this.doc.off("afterAllTransactions",this.afterAllTransactions))}}const Bk=(t,e,n,r,s,i)=>{const o=n.mapping.get(t);if(o===void 0){if(t instanceof et)return El(t,e,n,r,s,i);throw $t()}return o},El=(t,e,n,r,s,i)=>{const o=[],l=a=>{var c,u;if(a instanceof et){const d=Bk(a,e,n,r,s,i);d!==null&&o.push(d)}else{const d=(u=(c=a._item.right)==null?void 0:c.content)==null?void 0:u.type;d instanceof mr&&!d._item.deleted&&d._item.id.client===d.doc.clientID&&(a.applyDelta([{retain:a.length},...d.toDelta()]),d.doc.transact(h=>{d._item.delete(h)}));const f=h3(a,e,n,r,s,i);f!==null&&f.forEach(h=>{h!==null&&o.push(h)})}};r===void 0||s===void 0?t.toArray().forEach(l):vk(t,new Mh(s.ds,r.sv)).forEach(l);try{const a=t.getAttributes(r);r!==void 0&&(Da(t._item,r)?Da(t._item,s)||(a.ychange=i?i("added",t._item.id):{type:"added"}):a.ychange=i?i("removed",t._item.id):{type:"removed"});const c=e.node(t.nodeName,a,o);return n.mapping.set(t,c),c}catch{return t.doc.transact(c=>{t._item.delete(c)},Te),n.mapping.delete(t),null}},h3=(t,e,n,r,s,i)=>{const o=[],l=t.toDelta(r,s,i);try{for(let a=0;a<l.length;a++){const c=l[a];o.push(e.text(c.insert,x3(c.attributes,e)))}}catch{return t.doc.transact(c=>{t._item.delete(c)},Te),null}return o},p3=(t,e)=>{const n=new st,r=t.map(s=>({insert:s.text,attributes:Fk(s.marks,e)}));return n.applyDelta(r),e.mapping.set(n,t),n},m3=(t,e)=>{const n=new et(t.type.name);for(const r in t.attrs){const s=t.attrs[r];s!==null&&r!=="ychange"&&n.setAttribute(r,s)}return n.insert(0,vc(t).map(r=>La(r,e))),e.mapping.set(n,t),n},La=(t,e)=>t instanceof Array?p3(t,e):m3(t,e),Jg=t=>typeof t=="object"&&t!==null,Ih=(t,e)=>{const n=Object.keys(t).filter(s=>t[s]!==null);let r=n.length===Object.keys(e).filter(s=>e[s]!==null).length;for(let s=0;s<n.length&&r;s++){const i=n[s],o=t[i],l=e[i];r=i==="ychange"||o===l||Jg(o)&&Jg(l)&&Ih(o,l)}return r},vc=t=>{const e=t.content.content,n=[];for(let r=0;r<e.length;r++){const s=e[r];if(s.isText){const i=[];for(let o=e[r];r<e.length&&o.isText;o=e[++r])i.push(o);r--,n.push(i)}else n.push(s)}return n},Rh=(t,e)=>{const n=t.toDelta();return n.length===e.length&&n.every((r,s)=>r.insert===e[s].text&&Ov(r.attributes||{}).length===e[s].marks.length&&Ws(r.attributes,(i,o)=>{var u;const l=Hk(o),a=e[s].marks;return a.find(d=>d.type.name===l)?Ih(i,(u=a.find(d=>d.type.name===l))==null?void 0:u.attrs):!1}))},Bs=(t,e)=>{if(t instanceof et&&!(e instanceof Array)&&Pa(t,e)){const n=vc(e);return t._length===n.length&&Ih(t.getAttributes(),e.attrs)&&t.toArray().every((r,s)=>Bs(r,n[s]))}return t instanceof st&&e instanceof Array&&Rh(t,e)},mo=(t,e)=>t===e||t instanceof Array&&e instanceof Array&&t.length===e.length&&t.every((n,r)=>e[r]===n),g3=(t,e,n)=>{const r=new Map;e.forEach((a,c)=>{r.has(a)||r.set(a,c)});const s=[];if(t.forEach((a,c)=>{const u=n.mapping.get(a),d=r.get(u);d!==void 0&&mo(u,e[d])&&s.push({yIndex:c,pIndex:d,yChild:a})}),s.length===0)return[];const i=new Array(s.length),o=[];for(let a=0;a<s.length;a++){let c=0,u=o.length;for(;c<u;){const d=c+u>>1;s[o[d]].pIndex<s[a].pIndex?c=d+1:u=d}i[a]=c>0?o[c-1]:-1,o[c]=a}const l=[];for(let a=o[o.length-1];a!==-1;a=i[a])l.push(s[a]);return l.reverse()},Gg=(t,e,n,r)=>{n>0&&(t.slice(e,e+n).forEach(s=>r.mapping.delete(s)),t.delete(e,n))},Yg=(t,e,n,r,s,i)=>{if(r<s){const o=[];for(let l=r;l<s;l++)o.push(La(n[l],i));t.insert(e,o)}},zk=(t,e,n,r)=>e instanceof st&&n instanceof Array?(Rh(e,n)?r.mapping.set(e,n):$k(e,n,r),!0):e instanceof et&&!(n instanceof Array)&&Pa(e,n)?(Bs(e,n)?r.mapping.set(e,n):ja(t,e,n,r),!0):!1,Xg=(t,e,n,r,s,i,o,l,a)=>{const c=Jr(i-s,l-o);for(let u=0;u<c;u++){const d=r[s+u],f=n[o+u];zk(t,d,f,a)||(Gg(e,o+u,1,a),Yg(e,o+u,n,o+u,o+u+1,a))}Gg(e,o+c,i-s-c,a),Yg(e,o+c,n,o+c,l,a)},y3=(t,e,n,r,s)=>{const i=g3(r,n,s);if(i.length<2||!i.some(a=>a.yIndex!==a.pIndex)||i.some(a=>{const c=n[a.pIndex];return!(a.yChild instanceof st&&c instanceof Array||a.yChild instanceof et&&!(c instanceof Array))}))return!1;let o=0,l=0;for(const a of i){Xg(t,e,n,r,o,a.yIndex,l,a.pIndex,s);const c=n[a.pIndex];zk(t,a.yChild,c,s),o=a.yIndex+1,l=a.pIndex+1}return Xg(t,e,n,r,o,r.length,l,n.length,s),!0},Zg=(t,e,n)=>{const r=t.toArray(),s=vc(e),i=s.length,o=r.length,l=Jr(o,i);let a=0,c=0,u=!1;for(;a<l;a++){const d=r[a],f=s[a];if(mo(n.mapping.get(d),f))u=!0;else if(!Bs(d,f))break}for(;a+c<l;c++){const d=r[o-c-1],f=s[i-c-1];if(mo(n.mapping.get(d),f))u=!0;else if(!Bs(d,f))break}return{equalityFactor:a+c,foundMappedChild:u}},b3=t=>{let e="",n=t._start;const r={};for(;n!==null;)n.deleted||(n.countable&&n.content instanceof tn?e+=n.content.str:n.content instanceof je&&(r[n.content.key]=null)),n=n.right;return{str:e,nAttrs:r}},$k=(t,e,n)=>{n.mapping.set(t,e);const{nAttrs:r,str:s}=b3(t),i=e.map(c=>({insert:c.text,attributes:Object.assign({},r,Fk(c.marks,n))})),{insert:o,remove:l,index:a}=GH(s,i.map(c=>c.insert).join(""));t.delete(a,l),t.insert(a,o),t.applyDelta(i.map(c=>({retain:c.insert.length,attributes:c.attributes})))},w3=/(.*)(--[a-zA-Z0-9+/=]{8})$/,Hk=t=>{var e;return((e=w3.exec(t))==null?void 0:e[1])??t},x3=(t,e)=>{const n=[];for(const r in t)n.push(e.mark(Hk(r),t[r]));return n},Fk=(t,e)=>{const n={};return t.forEach(r=>{if(r.type.name!=="ychange"){const s=Vn(e.isOMark,r.type,()=>!r.type.excludes(r.type));n[s?`${r.type.name}--${i3(r.toJSON())}`:r.type.name]=r.attrs}}),n},ja=(t,e,n,r)=>{if(e instanceof et&&e.nodeName!==n.type.name)throw new Error("node name mismatch!");if(r.mapping.set(e,n),e instanceof et){const d=e.getAttributes(),f=n.attrs;for(const h in f)f[h]!==null?d[h]!==f[h]&&h!=="ychange"&&e.setAttribute(h,f[h]):e.removeAttribute(h);for(const h in d)f[h]===void 0&&e.removeAttribute(h)}const s=vc(n),i=s.length,o=e.toArray(),l=o.length,a=Jr(i,l);if(y3(t,e,s,o,r))return;let c=0,u=0;for(;c<a;c++){const d=o[c],f=s[c];if(!mo(r.mapping.get(d),f))if(Bs(d,f))r.mapping.set(d,f);else break}for(;u+c+1<a;u++){const d=o[l-u-1],f=s[i-u-1];if(!mo(r.mapping.get(d),f))if(Bs(d,f))r.mapping.set(d,f);else break}t.transact(()=>{for(;l-c-u>0&&i-c-u>0;){const f=o[c],h=s[c],p=o[l-u-1],g=s[i-u-1];if(f instanceof st&&h instanceof Array)Rh(f,h)||$k(f,h,r),c+=1;else{let y=f instanceof et&&Pa(f,h),b=p instanceof et&&Pa(p,g);if(y&&b){const w=Zg(f,h,r),v=Zg(p,g,r);w.foundMappedChild&&!v.foundMappedChild?b=!1:!w.foundMappedChild&&v.foundMappedChild||w.equalityFactor<v.equalityFactor?y=!1:b=!1}y?(ja(t,f,h,r),c+=1):b?(ja(t,p,g,r),u+=1):(r.mapping.delete(e.get(c)),e.delete(c,1),e.insert(c,[La(h,r)]),c+=1)}}const d=l-c-u;if(l===1&&i===0&&o[0]instanceof st?(r.mapping.delete(o[0]),o[0].delete(0,o[0].length)):d>0&&(e.slice(c,c+d).forEach(f=>r.mapping.delete(f)),e.delete(c,d)),c+u<i){const f=[];for(let h=c;h<i-u;h++)f.push(La(s[h],r));e.insert(c,f)}},Te)},Pa=(t,e)=>!(e instanceof Array)&&t.nodeName===e.type.name,Ba=(t,e,n)=>{if(t===0)return xu(e,0,-1);let r=e._first===null?null:e._first.content.type;for(;r!==null&&e!==r;){if(r instanceof st){if(r._length>=t)return xu(r,t,-1);if(t-=r._length,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{do r=r._item===null?null:r._item.parent,t--;while(r!==e&&r!==null&&r._item!==null&&r._item.next===null);r!==null&&r!==e&&(r=r._item===null?null:r._item.next.content.type)}}else{const s=(n.get(r)||{nodeSize:0}).nodeSize;if(r._first!==null&&t<s)r=r._first.content.type,t--;else{if(t===1&&r._length===0&&s>1)return new Aa(r._item===null?null:r._item.id,r._item===null?co(r):null,null);if(t-=s,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{if(t===0)return r=r._item===null?r:r._item.parent,new Aa(r._item===null?null:r._item.id,r._item===null?co(r):null,null);do r=r._item.parent,t--;while(r!==e&&r._item.next===null);r!==e&&(r=r._item.next.content.type)}}}if(r===null)throw bt();if(t===0&&r.constructor!==st&&r!==e)return k3(r._item.parent,r._item)}return xu(e,e._length,-1)},v3=(t,e,n)=>{if(n===null)return!1;const r=ck(e,t);return r!==null&&r.type instanceof st&&e.item!==null&&n<=1},k3=(t,e)=>{let n=null,r=null;return t._item===null?r=co(t):n=se(t._item.id.client,t._item.id.clock),new Aa(n,r,e.id)},Tr=(t,e,n,r)=>{const s=ck(n,t);if(s===null||s.type!==e&&!uo(e,s.type._item))return null;let i=s.type,o=0;if(i.constructor===st)o=s.index;else if(i._item===null||!i._item.deleted){let a=i._first,c=0;for(;c<i._length&&c<s.index&&a!==null;){if(!a.deleted){const u=a.content.type;if(c++,u instanceof st)o+=u._length;else{const d=r.get(u);if(d==null)return null;o+=d.nodeSize}}a=a.right}o+=1}for(;i!==e&&i._item!==null;){const a=i._item.parent;if(a._item===null||!a._item.deleted){o+=1;let c=a._first;for(;c!==null;){const u=c.content.type;if(u===i)break;if(!c.deleted)if(u instanceof st)o+=u._length;else{const d=r.get(u);if(d==null)return null;o+=d.nodeSize}c=c.right}}i=a}const l=o-1;return v3(t,n,l)?null:l},Vk=(t,e)=>{if(t===e)return!0;const n=Object.keys(t);return n.length===Object.keys(e).length&&n.every(r=>t[r]===e[r])},S3=t=>{const e=t.type.spec.attrs||{};return Object.keys(t.attrs).some(n=>{const r=e[n];return r==null||!Object.prototype.hasOwnProperty.call(r,"default")||r.default!==t.attrs[n]})},C3=(t,e,n)=>{let r=e+1,s=n;for(let i=1;i<t.depth;i++){const o=t.index(i);if(o>=s.childCount)return null;for(let l=0;l<o;l++)r+=s.child(l).nodeSize;if(r+=1,s=s.child(o),s.type!==t.node(i+1).type)return null}return s.isTextblock?r+Math.min(t.parentOffset,s.content.size):null},Uk=(t,e,n)=>{let r=0,s=0;for(;s<t.childCount;s++){const h=t.child(s);if(r+h.nodeSize>n)break;r+=h.nodeSize}if(s>=t.childCount)return null;const i=t.child(s),o=t.resolve(n),l=(h,p)=>{if(o.depth===0){const g=h+(n-r),y=h+1,b=h+p.nodeSize-1;return Math.max(y,Math.min(g,b))}return C3(o,h,p)},a=(h,p=!1)=>{let g=0;for(let x=0;x<=s;x++)h(t.child(x))&&g++;let y=0,b=-1,w=null,v=0;for(let x=0;x<e.childCount;x++){const k=e.child(x);h(k)&&(y++,y===g&&(b=v,w=k)),v+=k.nodeSize}return w===null||p&&(g!==1||y!==1)?null:l(b,w)},c=h=>h.type===i.type&&Vk(h.attrs,i.attrs),u=i.textContent,d=a(h=>c(h)&&h.textContent===u);if(d!==null)return d;const f=a(h=>h.type===i.type&&h.textContent===u);if(f!==null)return f;if(S3(i)){const h=a(c,!0);if(h!==null)return h}return a(h=>c(h)&&u!==""&&h.textContent!==""&&(u.startsWith(h.textContent)||h.textContent.startsWith(u)),!0)},E3=(t,e,n,r)=>{if(r===null)return!1;const s=t.resolve(n),i=e.resolve(r);if(!s.parent.isTextblock)return!1;if(!i.parent.isTextblock||s.parent.textContent!==i.parent.textContent||s.parentOffset!==0&&i.parentOffset===0)return!0;const o=s.parentOffset===0&&i.parentOffset===0,l=s.parentOffset!==i.parentOffset||s.parent.type!==i.parent.type||!Vk(s.parent.attrs,i.parent.attrs);if(o||l){const a=Uk(t,e,n);return a!==null&&a!==r}return!1},M3=t=>{const e=jn.getState(t).undoManager;if(e!=null)return e.undo(),!0},T3=t=>{const e=jn.getState(t).undoManager;if(e!=null)return e.redo(),!0},A3=new Set(["paragraph"]),_3=(t,e)=>!(t instanceof pe)||!(t.content instanceof rn)||!(t.content.type instanceof mr||t.content.type instanceof et&&e.has(t.content.type.nodeName))||t.content.type._length===0,N3=({protectedNodes:t=A3,trackedOrigins:e=[],undoManager:n=null}={})=>new ce({key:jn,state:{init:(r,s)=>{const i=Te.getState(s);let o=n;if(!o){const l=i.doc,a=new Set(l?l._observers.get("destroy"):[]);o=new mk(i.type,{trackedOrigins:new Set([Te].concat(e)),deleteFilter:u=>_3(u,t),captureTransaction:u=>u.meta.get("addToHistory")!==!1});const c=l?l._observers.get("destroy"):new Set;o._yTiptapDocDestroyListeners=Array.from(c||[]).filter(u=>!a.has(u))}return{undoManager:o,prevSel:null,hasUndoOps:o.undoStack.length>0,hasRedoOps:o.redoStack.length>0}},apply:(r,s,i,o)=>{const l=Te.getState(o).binding,a=s.undoManager,c=a.undoStack.length>0,u=a.redoStack.length>0;return l?{undoManager:a,prevSel:qd(l,i),hasUndoOps:c,hasRedoOps:u}:c!==s.hasUndoOps||u!==s.hasRedoOps?Object.assign({},s,{hasUndoOps:a.undoStack.length>0,hasRedoOps:a.redoStack.length>0}):s}},view:r=>{const s=Te.getState(r.state),i=jn.getState(r.state).undoManager;return i.on("stack-item-added",({stackItem:o})=>{const l=s.binding;l&&o.meta.set(l,jn.getState(r.state).prevSel)}),i.on("stack-item-popped",({stackItem:o})=>{const l=s.binding;l&&(l.beforeTransactionSelection=o.meta.get(l)||l.beforeTransactionSelection)}),{destroy:()=>{i.destroy();const o=i._yTiptapDocDestroyListeners;o&&i.doc&&(o.forEach(l=>i.doc.off("destroy",l)),i._yTiptapDocDestroyListeners=null)}}}});function Dh(t){return!!t.getMeta(Te)}function O3(t,e){const n=Te.getState(t);return Tr(n.doc,n.type,e,n.binding.mapping)||0}function Wk(t,e){const n=Te.getState(t);return Ba(e,n.type,n.binding.mapping)}var Ml=class qk extends Sf{constructor(e,n){super(e),this.yRelativePosition=n}static fromJSON(e){return new qk(e.position,e.yRelativePosition)}toJSON(){return{position:this.position,yRelativePosition:this.yRelativePosition}}};function I3(t,e){const n=Wk(e,t);return new Ml(t,n)}function R3(t,e,n){const r=t instanceof Ml?t.yRelativePosition:null;if(Dh(e)&&r){const o=O3(n,r);return{position:new Ml(o,r),mapResult:null}}const s=u0(t,e),i=s.position.position;return{position:new Ml(i,r??Wk(n,i)),mapResult:s.mapResult}}ie.create({name:"collaboration",priority:1e3,addOptions(){return{document:null,field:"default",fragment:null,provider:null}},addStorage(){return{isDisabled:!1}},onCreate(){this.editor.extensionManager.extensions.find(t=>t.name==="undoRedo")&&console.warn('[tiptap warn]: "@tiptap/extension-collaboration" comes with its own history support and is not compatible with "@tiptap/extension-undo-redo".')},onBeforeCreate(){this.editor.utils.getUpdatedPosition=(t,e)=>R3(t,e,this.editor.state),this.editor.utils.createMappablePosition=t=>I3(t,this.editor.state)},addCommands(){return{undo:()=>({tr:t,state:e,dispatch:n})=>(t.setMeta("preventDispatch",!0),jn.getState(e).undoManager.undoStack.length===0?!1:n?M3(e):!0),redo:()=>({tr:t,state:e,dispatch:n})=>(t.setMeta("preventDispatch",!0),jn.getState(e).undoManager.redoStack.length===0?!1:n?T3(e):!0)}},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Mod-y":()=>this.editor.commands.redo(),"Shift-Mod-z":()=>this.editor.commands.redo()}},addProseMirrorPlugins(){const t=this.options.fragment?this.options.fragment:this.options.document.getXmlFragment(this.options.field),e=N3(this.options.yUndoOptions),n=e.spec.view;e.spec.view=i=>{const{undoManager:o}=jn.getState(i.state);o.restore&&(o.restore(),o.restore=()=>{});const l=n?n(i):void 0;return{destroy:()=>{const a=o.trackedOrigins.has(o),c=o._observers;o.restore=()=>{a&&o.trackedOrigins.add(o),o.doc.on("afterTransaction",o.afterTransactionHandler),o._observers=c},l!=null&&l.destroy&&l.destroy()}}};const r={...this.options.ySyncOptions,onFirstRender:this.options.onFirstRender};return[a3(t,r),e,this.editor.options.enableContentCheck&&new ce({key:new ae("filterInvalidContent"),filterTransaction:i=>{if(!Dh(i))return!0;if(this.storage.isDisabled)return!1;if(!i.docChanged)return!0;try{return i.doc.check(),!0}catch(o){return this.storage.isDisabled=!0,this.editor.emit("contentError",{error:o,editor:this.editor,disableCollaboration:()=>{var l;(l=t.doc)==null||l.destroy()}}),!0}}})].filter(Boolean)}});function Qg(t){if(!t.length)return he.empty;const e=[],n=t[0].$from.node(0);return t.forEach(r=>{const s=r.$from.pos,i=r.$from.nodeAfter;i&&e.push(De.node(s,s+i.nodeSize,{class:"ProseMirror-selectednoderange"}))}),he.create(n,e)}function D3(t,e,n){const r=n.isText||n.isAtom?0:1;return{start:t+r,end:t+e-r}}function kc(t,e,n,r={}){const s=[],i=t.node(0),{extendOnBoundaryOverlap:o=!0}=r;typeof n=="number"&&n>=0||(t.sameParent(e)?n=Math.max(0,t.sharedDepth(e.pos)-1):n=t.sharedDepth(e.pos));const l=new Fi(t,e,n),a=l.depth===0?0:i.resolve(l.start).posAtIndex(0);return l.parent.forEach((c,u)=>{const d=a+u,f=d+c.nodeSize,h=D3(d,c.nodeSize,c),p=o?e.pos>=h.start&&t.pos<=h.end:e.pos>h.start&&t.pos<h.end;if(d<l.start||d>=l.end||!p)return;const g=new ef(i.resolve(d),i.resolve(f));s.push(g)}),s}var L3=class Kk{constructor(e,n,r){this.anchor=e,this.head=n,this.depth=r??0}map(e){return new Kk(e.map(this.anchor),e.map(this.head),this.depth)}resolve(e){const n=e.resolve(this.anchor),r=e.resolve(this.head);return new un(n,r,this.depth)}},un=class Zn extends te{constructor(e,n,r,s=1){const{doc:i}=e,o=e===n,l=e.pos===i.content.size&&n.pos===i.content.size,a=o&&!l?i.resolve(n.pos+(s>0?1:-1)):n,c=o&&l?i.resolve(e.pos-(s>0?1:-1)):e,u=kc(c.min(a),c.max(a),r),d=a.pos>=e.pos?u[0].$from:u[u.length-1].$to,f=a.pos>=e.pos?u[u.length-1].$to:u[0].$from;super(d,f,u),this.depth=r}get $to(){return this.ranges[this.ranges.length-1].$to}eq(e){return e instanceof Zn&&e.$from.pos===this.$from.pos&&e.$to.pos===this.$to.pos}map(e,n){const r=e.resolve(n.map(this.anchor)),s=e.resolve(n.map(this.head));return new Zn(r,s,this.depth)}toJSON(){return{type:"nodeRange",anchor:this.anchor,head:this.head,depth:this.depth}}get isForwards(){return this.head>=this.anchor}get isBackwards(){return!this.isForwards}extendBackwards(){const{doc:e}=this.$from;if(this.isForwards&&this.ranges.length>1){const s=this.ranges.slice(0,-1),i=s[0].$from,o=s[s.length-1].$to;return new Zn(i,o,this.depth)}const n=this.ranges[0],r=e.resolve(Math.max(0,n.$from.pos-1));return new Zn(this.$anchor,r,this.depth)}extendForwards(){const{doc:e}=this.$from;if(this.isBackwards&&this.ranges.length>1){const s=this.ranges.slice(1),i=s[0].$from,o=s[s.length-1].$to;return new Zn(o,i,this.depth)}const n=this.ranges[this.ranges.length-1],r=e.resolve(Math.min(e.content.size,n.$to.pos+1));return new Zn(this.$anchor,r,this.depth)}static fromJSON(e,n){return new Zn(e.resolve(n.anchor),e.resolve(n.head),n.depth)}static create(e,n,r,s,i=1){return new this(e.resolve(n),e.resolve(r),s,i)}getBookmark(){return new L3(this.anchor,this.head,this.depth)}};un.prototype.visible=!1;try{te.jsonID("nodeRange",un)}catch{}function Si(t){return t instanceof un}ie.create({name:"nodeRange",addOptions(){return{depth:void 0,key:"Mod"}},addKeyboardShortcuts(){return{"Shift-ArrowUp":({editor:t})=>{const{depth:e}=this.options,{view:n,state:r}=t,{doc:s,selection:i,tr:o}=r,{anchor:l,head:a}=i;if(!Si(i)){const u=un.create(s,l,a,e,-1);return o.setSelection(u),n.dispatch(o),!0}const c=i.extendBackwards();return o.setSelection(c),n.dispatch(o),!0},"Shift-ArrowDown":({editor:t})=>{const{depth:e}=this.options,{view:n,state:r}=t,{doc:s,selection:i,tr:o}=r,{anchor:l,head:a}=i;if(!Si(i)){const u=un.create(s,l,a,e);return o.setSelection(u),n.dispatch(o),!0}const c=i.extendForwards();return o.setSelection(c),n.dispatch(o),!0},"Mod-a":({editor:t})=>{const{depth:e}=this.options,{view:n,state:r}=t,{doc:s,tr:i}=r,o=un.create(s,0,s.content.size,e);return i.setSelection(o),n.dispatch(i),!0}}},onSelectionUpdate(){const{selection:t}=this.editor.state;Si(t)&&this.editor.view.dom.classList.add("ProseMirror-noderangeselection")},addProseMirrorPlugins(){let t=!1,e=!1;return[new ce({key:new ae("nodeRange"),props:{attributes:()=>t?{class:"ProseMirror-noderangeselection"}:{class:""},handleDOMEvents:{mousedown:(n,r)=>{const{key:s}=this.options,i=/Mac/.test(navigator.platform),o=!!r.shiftKey,l=!!r.ctrlKey,a=!!r.altKey,c=!!r.metaKey,u=i?c:l;return(s==null||s==="Shift"&&o||s==="Control"&&l||s==="Alt"&&a||s==="Meta"&&c||s==="Mod"&&u)&&(e=!0),e&&document.addEventListener("mouseup",()=>{e=!1;const{state:d}=n,{doc:f,selection:h,tr:p}=d,{$anchor:g,$head:y}=h;if(g.sameParent(y))return;const b=un.create(f,g.pos,y.pos,this.options.depth);p.setSelection(b),n.dispatch(p)},{once:!0}),!1}},decorations:n=>{const{selection:r}=n,s=Si(r);if(t=!1,!e)return s?(t=!0,Qg(r.ranges)):null;const{$from:i,$to:o}=r;if(!s&&i.sameParent(o))return null;const l=kc(i,o,this.options.depth);return l.length?(t=!0,Qg(l)):null}}})]}});function j3(t,e){const n=getComputedStyle(t);if(e)return e.filter(s=>s.trim().length>0).map(s=>`${s}:${n.getPropertyValue(s)};`).join("");let r="";for(let s=0;s<n.length;s+=1)r+=`${n[s]}:${n.getPropertyValue(n[s])};`;return r}function P3(t,e){const n=t.cloneNode(!0),r=[t,...Array.from(t.getElementsByTagName("*"))],s=[n,...Array.from(n.getElementsByTagName("*"))];return r.forEach((i,o)=>{s[o].style.cssText=j3(i,e)}),n}var B3={id:"listItemFirstChild",evaluate:({parent:t,isFirst:e})=>e&&t&&["listItem","taskItem"].includes(t.type.name)?1e3:0},z3={id:"listWrapperDeprioritize",evaluate:({node:t})=>{const e=["listItem","taskItem"],n=t.firstChild;return n&&e.includes(n.type.name)?1e3:0}},$3={id:"tableStructure",evaluate:({node:t,parent:e})=>["tableRow","tableCell","tableHeader"].includes(t.type.name)||e&&e.type.name==="tableHeader"?1e3:0},H3={id:"inlineContent",evaluate:({node:t})=>t.isInline||t.isText?1e3:0},F3=[B3,z3,$3,H3],ey={edges:["left","top"],threshold:12,strength:500};function Cu(t){return t===void 0||t==="left"?{...ey}:t==="right"?{edges:["right","top"],threshold:12,strength:500}:t==="both"?{edges:["left","right","top"],threshold:12,strength:500}:t==="none"?{edges:[],threshold:0,strength:0}:{...ey,...t}}function V3(t,e,n){if(n.edges.length===0)return!1;const r=e.getBoundingClientRect(),{threshold:s,edges:i}=n;return i.some(o=>o==="left"?t.x-r.left<s:o==="right"?r.right-t.x<s:o==="top"?t.y-r.top<s:o==="bottom"?r.bottom-t.y<s:!1)}function U3(t,e,n,r){return!e||n.edges.length===0?0:V3(t,e,n)?n.strength*r:0}var W3=1e3;function ty(t,e,n,r){let s=W3,i=!1;if(e.every(l=>{const a=l.evaluate(t);return s-=a,s<=0?(i=!0,!1):!0}),i)return-1;const o=t.view.nodeDOM(t.pos);return s-=U3(r,o,n,t.depth),s<=0?-1:s}function ny(t,e,n){return Array.from({length:e},(s,i)=>e-1-i).some(s=>n.includes(t.node(s).type.name))}function q3(t,e,n){if(!Number.isFinite(e.x)||!Number.isFinite(e.y))return null;const r=t.posAtCoords({left:e.x,top:e.y});if(!r)return null;const{doc:s}=t.state,i=s.resolve(r.pos),o=[];n.defaultRules&&o.push(...F3),o.push(...n.rules);const a=Array.from({length:i.depth},(d,f)=>i.depth-f).map(d=>{const f=i.node(d),h=i.before(d);if(n.allowedContainers&&d>0&&!ny(i,d,n.allowedContainers))return null;const p=d>0?i.node(d-1):null,g=d>0?i.index(d-1):0,y=p?p.childCount:1,b={node:f,pos:h,depth:d,parent:p,index:g,isFirst:g===0,isLast:g===y-1,$pos:i,view:t},w=ty(b,o,n.edgeDetection,e);if(w<0)return null;const v=t.nodeDOM(h);return{node:f,pos:h,depth:d,score:w,dom:v}}).filter(d=>d!==null),c=i.nodeAfter;if(c&&c.isAtom&&!c.isInline){const d=r.pos,f=i.depth+1,h=i.parent,p=i.index(),g=h.childCount;let y=!0;if(n.allowedContainers&&(y=ny(i,f,n.allowedContainers)),y){const b={node:c,pos:d,depth:f,parent:h,index:p,isFirst:p===0,isLast:p===g-1,$pos:i,view:t},w=ty(b,o,n.edgeDetection,e);if(w>=0){const v=t.nodeDOM(d);v&&a.push({node:c,pos:d,depth:f,score:w,dom:v})}}}if(a.length===0)return null;a.sort((d,f)=>f.score!==d.score?f.score-d.score:f.depth-d.depth);const u=a[0];return u.dom?{node:u.node,pos:u.pos,dom:u.dom}:null}function K3(t,e){let n=t;for(;n!=null&&n.parentElement&&n.parentElement!==e.dom;)n=n.parentElement;return(n==null?void 0:n.parentElement)===e.dom?n:void 0}function ry(t){return Number.isFinite(t.top)&&Number.isFinite(t.bottom)&&Number.isFinite(t.left)&&Number.isFinite(t.right)&&t.width>0&&t.height>0}function J3(t,e,n,r=5){if(!Number.isFinite(e)||!Number.isFinite(n))return null;const s=t.dom,i=s.firstElementChild,o=s.lastElementChild;if(!i||!o)return null;const l=i.getBoundingClientRect(),a=o.getBoundingClientRect();if(!ry(l)||!ry(a))return null;const c=Math.min(Math.max(l.top+r,n),a.bottom-r),u=.5,d=Math.abs(l.left-a.left)<u,f=Math.abs(l.right-a.right)<u;let h=l;d&&f&&(h=l);const p=Math.min(Math.max(h.left+r,e),h.right-r);return!Number.isFinite(p)||!Number.isFinite(c)?null:{x:p,y:c}}var Jk=t=>{const{x:e,y:n,editor:r,nestedOptions:s}=t,{view:i,state:o}=r,l=J3(i,e,n,5);if(!l)return{resultElement:null,resultNode:null,pos:null};const{x:a,y:c}=l;if(s!=null&&s.enabled){const p=q3(i,{x:a,y:c},s);return p?{resultElement:p.dom,resultNode:p.node,pos:p.pos}:{resultElement:null,resultNode:null,pos:null}}const u=i.root.elementsFromPoint(a,c);let d;if(Array.prototype.some.call(u,p=>{if(!i.dom.contains(p))return!1;const g=K3(p,i);return g?(d=g,!0):!1}),!d){const p=i.posAtCoords({left:a,top:c});if(p){const g=o.doc.resolve(p.pos),y=Math.min(g.depth,1),b=y>0?g.before(y):g.pos,w=o.doc.nodeAt(b);if(w){const v=i.nodeDOM(b);return{resultElement:v instanceof HTMLElement?v:null,resultNode:w,pos:b}}}return{resultElement:null,resultNode:null,pos:null}}let f;try{f=i.posAtDOM(d,0)}catch{return{resultElement:null,resultNode:null,pos:null}}const h=o.doc.nodeAt(f);if(!h){const p=o.doc.resolve(f),g=p.parent;return{resultElement:d,resultNode:g,pos:p.start()}}return{resultElement:d,resultNode:h,pos:f}};function Gk(t,e){const n=t.nodeDOM(e);if(n instanceof Element&&n!==t.dom)return n;const{node:r,offset:s}=t.domAtPos(e),i=r.childNodes[s];return i instanceof Element?i:r instanceof Element?r:r.nodeType===Node.TEXT_NODE&&r.parentElement?r.parentElement:null}function G3(t,e){const n=Gk(t,e);return(n?getComputedStyle(n).direction:getComputedStyle(t.dom).direction)||"ltr"}function Yk(t){var e;(e=t.parentNode)==null||e.removeChild(t)}function Y3(t,e){return t==="rtl"?e:0}function X3(t,e,n,r){const{doc:s}=e.view.state;if(n!=null&&n.enabled&&(r!=null&&r.node)&&r.pos>=0){const c=r.pos,u=r.pos+r.node.nodeSize;return[{$from:s.resolve(c),$to:s.resolve(u)}]}const i=Jk({editor:e,x:t.clientX,y:t.clientY,nestedOptions:n});if(!i.resultNode||i.pos===null)return[];const o=i.resultNode.isText||i.resultNode.isAtom?0:-1,l=s.resolve(i.pos),a=s.resolve(i.pos+i.resultNode.nodeSize+o);return kc(l,a,0,{extendOnBoundaryOverlap:!1})}function Z3(t,e,n,r,s){const{view:i}=e;if(!t.dataTransfer)return;const{empty:o,$from:l,$to:a}=i.state.selection,c=X3(t,e,n,r),u=kc(l,a,0,{extendOnBoundaryOverlap:!1}),d=u.some(M=>c.find(D=>D.$from===M.$from&&D.$to===M.$to)),f=o||!d?c:u;if(!f.length)return;const{tr:h}=i.state,p=document.createElement("div"),g=f[0].$from.pos,y=f[f.length-1].$to.pos,b=G3(i,g);p.setAttribute("dir",b);const w=(n==null?void 0:n.enabled)&&(r==null?void 0:r.node);let v,x;w?(v=i.state.doc.slice(g,y),x=Y.create(i.state.doc,g)):(x=un.create(i.state.doc,g,y),v=x.content()),f.forEach(M=>{const D=Gk(i,M.$from.pos);if(!D)return;const R=P3(D,s);R.style.margin="0",p.append(R)}),p.style.position="absolute",p.style.top="-10000px",document.body.append(p),t.dataTransfer.clearData();const k=p.getBoundingClientRect(),C=Y3(b,k.width);t.dataTransfer.setDragImage(p,C,0);let E=!1;const O=()=>{E||(E=!0,Yk(p),document.removeEventListener("drop",O),document.removeEventListener("dragend",O))},_=x instanceof Y?x:void 0;i.dragging={slice:v,move:!0,node:_},h.setSelection(x),i.dispatch(h),document.addEventListener("drop",O),document.addEventListener("dragend",O)}function sy(t,e,n){let r=0;for(let s=e;s<n;s+=1)r+=t.child(s).nodeSize;return r}function Q3(t){var e;return Si(t)?{anchorPos:t.from,nodeCount:t.ranges.length,depth:(e=t.depth)!=null?e:0}:null}function e5(t,e,n,r){const s=t.resolve(e),i=s.node(r);let o=s.index(r);o>=i.childCount&&(o=Math.max(0,i.childCount-n));const l=Math.min(n,i.childCount-o);if(l<=0)return null;const a=s.start(r)+sy(i,0,o),c=a+sy(i,o,o+l);return{anchor:a,head:c,count:l}}function t5(t,e,n,r){try{const s=e5(t,e,n,r);if(!s)return null;const i=un.create(t,s.anchor,s.head,r);return i.ranges.length===n?i:null}catch{return null}}var iy=(t,e)=>{const n=t.resolve(e),{depth:r}=n;return r===0?e:n.pos-n.parentOffset-1},oy=(t,e)=>{const n=t.nodeAt(e),r=t.resolve(e);let{depth:s}=r,i=n;for(;s>0;){const o=r.node(s);s-=1,s===0&&(i=o)}return i},Eu=(t,e)=>{const n=Te.getState(t);return n?Ba(e,n.type,n.binding.mapping):null},n5=(t,e)=>{const n=Te.getState(t);return n?Tr(n.doc,n.type,e,n.binding.mapping)||0:-1},ly=(t,e)=>{let n=e;for(;n!=null&&n.parentNode&&n.parentNode!==t.dom;)n=n.parentNode;return n},Xk=new ae("dragHandle"),Zk=({pluginKey:t=Xk,element:e,editor:n,computePositionConfig:r,getReferencedVirtualElement:s,onNodeChange:i,onElementDragStart:o,onElementDragEnd:l,nestedOptions:a,dragImageProperties:c})=>{const u=document.createElement("div");let d=!1,f=null,h=-1,p,g=null,y=null,b=null,w=null,v=null;function x(){e&&(e.style.visibility="hidden",e.style.pointerEvents="none")}function k(){if(e){if(!n.isEditable){x();return}e.style.visibility="",e.style.pointerEvents="auto"}}function C(R){const L=(s==null?void 0:s())||{getBoundingClientRect:()=>R.getBoundingClientRect()};ah(L,e,r).then(I=>{Object.assign(e.style,{position:I.strategy,left:`${I.x}px`,top:`${I.y}px`})})}function E(R){o==null||o(R),Z3(R,n,a,{node:f,pos:h},c),w=Q3(n.state.selection),e&&(e.dataset.dragging="true"),setTimeout(()=>{e&&(e.style.pointerEvents="none")},0)}function O(R){l==null||l(R),w=null,x(),e&&(e.style.pointerEvents="auto",e.dataset.dragging="false")}function _({nodeCount:R,depth:L,anchorPos:I}){const N=t5(n.state.doc,I,R,L);N&&n.view.dispatch(n.state.tr.setSelection(N))}function M(R){if(!(!R.target||!n.view.dom.contains(R.target))){if(cA()){const L=n.view.dom;requestAnimationFrame(()=>{L.isContentEditable&&(L.contentEditable="false",L.contentEditable="true")})}!w||n.view.state.selection.empty||(v={...w,anchorPos:n.state.selection.from},y=requestAnimationFrame(()=>{y=null,v&&(_(v),v=null)}))}}function D(){e.removeEventListener("dragstart",E),e.removeEventListener("dragend",O),document.removeEventListener("drop",M),g&&(cancelAnimationFrame(g),g=null,b=null),y&&(cancelAnimationFrame(y),y=null)}return u.appendChild(e),{unbind(){D()},plugin:new ce({key:typeof t=="string"?new ae(t):t,state:{init(){return{locked:!1}},apply(R,L,I,N){if(v&&R.docChanged){const U=R.mapping.mapResult(v.anchorPos,1);U.deleted?v=null:v.anchorPos=U.pos}const z=R.getMeta("lockDragHandle"),H=R.getMeta("hideDragHandle");if(z!==void 0&&(d=z),H)return x(),d=!1,f=null,h=-1,i==null||i({editor:n,node:null,pos:-1}),L;if(R.docChanged&&h!==-1&&e)if(Dh(R)){const U=n5(N,p);U!==h&&(h=U)}else{const U=R.mapping.map(h);U!==h&&(h=U,p=Eu(N,h))}return L}},view:R=>{var L;return e.draggable=!0,e.style.pointerEvents="auto",e.dataset.dragging="false",(L=n.view.dom.parentElement)==null||L.appendChild(u),u.style.pointerEvents="none",u.style.position="absolute",u.style.top="0",u.style.left="0",e.addEventListener("dragstart",E),e.addEventListener("dragend",O),document.addEventListener("drop",M),{update(I,N){if(!e)return;if(!n.isEditable){x();return}if(d?e.draggable=!1:e.draggable=!0,R.state.doc.eq(N.doc)||h===-1)return;let z=R.nodeDOM(h);if(z=ly(R,z),z===R.dom||(z==null?void 0:z.nodeType)!==1)return;const H=R.posAtDOM(z,0),U=oy(n.state.doc,H),q=iy(n.state.doc,H);f=U,h=q,p=Eu(R.state,h),i==null||i({editor:n,node:f,pos:h}),C(z)},destroy(){D(),e&&Yk(u)}}},props:{handleDOMEvents:{keydown(R){return!e||d||R.hasFocus()&&(x(),f=null,h=-1,i==null||i({editor:n,node:null,pos:-1})),!1},mouseleave(R,L){return d||L.target&&!u.contains(L.relatedTarget)&&(x(),f=null,h=-1,i==null||i({editor:n,node:null,pos:-1})),!1},mousemove(R,L){return!e||d||(b={x:L.clientX,y:L.clientY},g)||(g=requestAnimationFrame(()=>{if(g=null,!b)return;const{x:I,y:N}=b;b=null;const z=Jk({x:I,y:N,editor:n,nestedOptions:a});if(!z.resultElement)return;let H=z.resultElement,U=z.resultNode,q=z.pos;if(!(a!=null&&a.enabled)){if(H=ly(R,H),H===R.dom||(H==null?void 0:H.nodeType)!==1)return;const de=R.posAtDOM(H,0);U=oy(n.state.doc,de),q=iy(n.state.doc,de)}U!==f&&(f=U,h=q??-1,p=Eu(R.state,h),i==null||i({editor:n,node:f,pos:h}),C(H),k())})),!1}}}})}};function Qk(t){var e,n;return t===!1||t===void 0?{enabled:!1,rules:[],defaultRules:!0,allowedContainers:void 0,edgeDetection:Cu("none")}:t===!0?{enabled:!0,rules:[],defaultRules:!0,allowedContainers:void 0,edgeDetection:Cu("left")}:{enabled:!0,rules:(e=t.rules)!=null?e:[],defaultRules:(n=t.defaultRules)!=null?n:!0,allowedContainers:t.allowedContainers,edgeDetection:Cu(t.edgeDetection)}}var Kd={placement:"left-start",strategy:"absolute"};ie.create({name:"dragHandle",addOptions(){return{render(){const t=document.createElement("div");return t.classList.add("drag-handle"),t},computePositionConfig:{},locked:!1,onNodeChange:()=>null,onElementDragStart:void 0,onElementDragEnd:void 0,nested:!1,dragImageProperties:void 0}},addCommands(){return{lockDragHandle:()=>({editor:t})=>(this.options.locked=!0,t.commands.setMeta("lockDragHandle",this.options.locked)),unlockDragHandle:()=>({editor:t})=>(this.options.locked=!1,t.commands.setMeta("lockDragHandle",this.options.locked)),toggleDragHandle:()=>({editor:t})=>(this.options.locked=!this.options.locked,t.commands.setMeta("lockDragHandle",this.options.locked))}},addProseMirrorPlugins(){const t=this.options.render(),e=Qk(this.options.nested);return[Zk({computePositionConfig:{...Kd,...this.options.computePositionConfig},getReferencedVirtualElement:this.options.getReferencedVirtualElement,element:t,editor:this.editor,onNodeChange:this.options.onNodeChange,onElementDragStart:this.options.onElementDragStart,onElementDragEnd:this.options.onElementDragEnd,nestedOptions:e,dragImageProperties:this.options.dragImageProperties}).plugin]}});var r5=t=>{const{className:e="drag-handle",children:n,editor:r,pluginKey:s=Xk,onNodeChange:i,onElementDragStart:o,onElementDragEnd:l,getReferencedVirtualElement:a,computePositionConfig:c=Kd,nested:u=!1}=t,[d]=S.useState(()=>typeof document>"u"?null:document.createElement("div")),f=S.useMemo(()=>Qk(u),[JSON.stringify(u)]);return S.useEffect(()=>{d&&(d.className=e,d.style.visibility="hidden",d.style.position="absolute",d.dataset.dragging="false")},[e,d]),S.useEffect(()=>{if(!d||r.isDestroyed)return;const{plugin:h,unbind:p}=Zk({editor:r,element:d,pluginKey:s,computePositionConfig:{...Kd,...c},onElementDragStart:o,onElementDragEnd:l,onNodeChange:i,getReferencedVirtualElement:a,nestedOptions:f});return r.registerPlugin(h),()=>{r.isDestroyed||r.unregisterPlugin(s),p()}},[d,r,i,a,s,c,o,l,f]),d?zs.createPortal(n,d):null};const s5="_handleSlot_1769s_12",i5="_grip_1769s_17",ay={handleSlot:s5,grip:i5},o5={placement:"left-start"};function eS({editor:t}){const[e,n]=S.useState(!1),r=S.useRef(-1),s=S.useRef(-1),i=S.useRef(!1);function o(u){i.current=u,u&&(s.current=r.current),n(u)}function l(u){const d=s.current;if(o(!1),d<0||d>=t.state.doc.content.size)return;const f=t.state.doc.nodeAt(d);f&&(u(d,f.nodeSize),s.current=-1,r.current=-1)}const a=S.useCallback(({pos:u})=>{i.current||(r.current=u)},[]);function c(u){l((d,f)=>{const{state:h,view:p}=t,g=d,y=d+f,b=h.doc.nodeAt(d);if(!b)return;const w=u==="up"?h.doc.resolve(g).nodeBefore:h.doc.resolve(y).nodeAfter;if(!w)return;const v=u==="up"?g-w.nodeSize:g+w.nodeSize;p.dispatch(h.tr.delete(g,y).insert(v,b))})}return m.jsx(r5,{editor:t,computePositionConfig:o5,onNodeChange:a,className:ay.handleSlot,children:m.jsx(A.Popover,{open:e,onOpenChange:o,placement:"bottom-start",bare:!0,trigger:m.jsx("button",{type:"button",className:ay.grip,"aria-label":"Block actions",children:m.jsx(HR,{size:16})}),children:m.jsxs(A.Menu,{children:[m.jsx(A.MenuItem,{label:"Move up",leftIcon:m.jsx(nD,{size:16}),onClick:()=>c("up")}),m.jsx(A.MenuItem,{label:"Move down",leftIcon:m.jsx(rD,{size:16}),onClick:()=>c("down")}),m.jsx(A.MenuItem,{label:"Duplicate",leftIcon:m.jsx(qR,{size:16}),onClick:()=>l((u,d)=>{const f=t.state.doc.nodeAt(u);f&&t.chain().insertContentAt(u+d,f.toJSON()).run()})}),m.jsx(A.MenuItem,{label:"Delete",variant:"danger",leftIcon:m.jsx(St,{size:16}),onClick:()=>l((u,d)=>{t.chain().deleteRange({from:u,to:u+d}).run()})})]})})})}const l5="_root_y9qax_1",a5="_separator_y9qax_14",cy={root:l5,separator:a5};function tS({editor:t}){const e=vo({editor:t,selector:({editor:n})=>{const r=n.storage.characterCount;return{words:(r==null?void 0:r.words())??0,characters:(r==null?void 0:r.characters())??0}}});return m.jsxs("div",{className:cy.root,contentEditable:!1,children:[m.jsx("span",{children:e.words===1?"1 word":`${e.words} words`}),m.jsx("span",{className:cy.separator}),m.jsx("span",{children:e.characters===1?"1 character":`${e.characters} characters`})]})}const c5="_indicator_1dw83_2",u5="_line_1dw83_14",d5="_button_1dw83_23",Mu={indicator:c5,line:u5,button:d5},f5=14;function h5({editor:t,wrapper:e,onInsert:n}){const[r,s]=S.useState(null);return S.useEffect(()=>{if(!e||!t.isEditable)return;function i(l){const a=t.view.dom,c=[...a.children];if(c.length===0)return s(null);const u=l.clientX,d=l.clientY,f=a.getBoundingClientRect();if(u<f.left-60||u>f.right+60)return s(null);for(let h=0;h<c.length-1;h+=1){const p=c[h].getBoundingClientRect(),g=c[h+1].getBoundingClientRect(),y=(p.bottom+g.top)/2;if(Math.abs(d-y)>f5)continue;const b=t.view.posAtDOM(c[h],0),w=t.state.doc.nodeAt(Math.max(0,b-1)),v=w?b-1+w.nodeSize:b,x=e.getBoundingClientRect();s({top:y-x.top,pos:v,rect:{top:y,bottom:y,left:p.left}});return}s(null)}function o(){s(null)}return e.addEventListener("mousemove",i),e.addEventListener("mouseleave",o),()=>{e.removeEventListener("mousemove",i),e.removeEventListener("mouseleave",o)}},[t,e]),r?m.jsxs("div",{className:Mu.indicator,style:{top:r.top},children:[m.jsx("span",{className:Mu.line}),m.jsx("button",{type:"button",className:Mu.button,"aria-label":"Insert block here",onMouseDown:i=>i.preventDefault(),onClick:()=>n({pos:r.pos,rect:r.rect}),children:m.jsx(ms,{size:14})})]},r.pos):null}const p5="_wrapper_1y5c7_6",m5="_readOnly_1y5c7_37",g5="_insertButton_1y5c7_49",y5="_content_1y5c7_63",rl={wrapper:p5,readOnly:m5,insertButton:g5,content:y5},nS={type:"doc",content:[{type:"paragraph"}]};function b5(t,e){return JSON.stringify(t)===JSON.stringify(e)}function uy(t){return t?{top:t.top,bottom:t.bottom,left:t.left}:null}function w5(t,e){const{node:n}=t.domAtPos(e);let r=n.nodeType===Node.TEXT_NODE?n.parentElement:n;for(;r!=null&&r.parentElement&&r.parentElement!==t.dom;)r=r.parentElement;return(r==null?void 0:r.parentElement)===t.dom?r:null}const x5=S.forwardRef(function({value:e,defaultValue:n,placeholder:r,onChange:s,onFocus:i,onBlur:o,readOnly:l=!1,autoFocus:a=!1,contentWidth:c="740px",blocks:u=Sx,showInsertButton:d=!0,showBubbleMenu:f=!0,showDragHandle:h=!0,showWordCount:p=!1,onUpload:g,uploadAccept:y="image/*",onPickProduct:b,onPickCollection:w,title:v="",onTitleChange:x,titlePlaceholder:k="Post title",showTitle:C=!1,className:E},O){const _=S.useRef(!1),M=S.useRef(null),[D,R]=S.useState(null),L=S.useRef(null),[I,N]=S.useState(null),[z,H]=S.useState(null),U=S.useRef(null);U.current=I;const q=S.useCallback(P=>{if(!P){N(W=>(W==null?void 0:W.source)==="slash"?null:W);return}N(W=>(W==null?void 0:W.source)==="slash"?{...W,query:P.query,range:P.range}:{source:"slash",getAnchor:()=>uy(P.getRect()),query:P.query,range:P.range})},[]),de=S.useCallback(P=>{var W,X;return((W=U.current)==null?void 0:W.source)!=="slash"?!1:((X=L.current)==null?void 0:X.onKeyDown(P))??!1},[]),ve=S.useRef(g);ve.current=g;const Ee=S.useMemo(()=>g?P=>ve.current(P):void 0,[!!g]),Ct=S.useRef(b);Ct.current=b;const Me=S.useMemo(()=>b?()=>Ct.current():void 0,[!!b]),Ae=S.useRef(w);Ae.current=w;const ze=S.useMemo(()=>w?()=>Ae.current():void 0,[!!w]),$=O0({extensions:[T1.configure({heading:{levels:[1,2,3,4,5,6]},link:{openOnClick:!1}}),...r!==void 0?[A1.configure({placeholder:r})]:[],Jf.configure({resizable:!1}),Kf,qf,Wf,Gf,Yf,_1.configure({multicolor:!0}),mO,_x.configure({onUpload:Ee,accept:y}),Ox,Rx,Lx,Px,zx.configure({onUpload:Ee,accept:y}),Hx,Wx.configure({onPick:Me}),qx.configure({onPick:ze}),Tx.configure({onStateChange:q,onKeyDown:de})],content:e??n??nS,editable:!l,autofocus:a?"end":!1,shouldRerenderOnTransaction:!1,onUpdate({editor:P}){_.current=!0,s==null||s(P.getJSON(),{isEmpty:P.isEmpty})},onFocus(){i==null||i()},onBlur(){o==null||o()}});S.useEffect(()=>{$==null||$.setEditable(!l)},[$,l]),S.useEffect(()=>{if(!(!$||e===void 0)){if(_.current){_.current=!1;return}b5(e,$.getJSON())||$.commands.setContent(e,{emitUpdate:!1})}},[$,e]),S.useEffect(()=>{const P=M.current;if(!P)return;const W=new ResizeObserver(([X])=>{P.style.setProperty("--block-editor-canvas-width",`${X.contentRect.width}px`)});return W.observe(P),()=>W.disconnect()},[]),S.useEffect(()=>{if(!$||!d||l){H(null);return}function P(){if(!$||!M.current)return;const{selection:X}=$.state,be=X.$from.parent;if(!(X.empty&&be.type.name==="paragraph"&&be.content.size===0)||!$.isFocused){H(null);return}const ne=w5($.view,X.$from.pos);if(!ne){H(null);return}const Je=$.view.coordsAtPos(X.$from.pos),vr=(Je.top+Je.bottom)/2,xn=M.current.getBoundingClientRect();H({top:vr-xn.top,left:ne.getBoundingClientRect().left-xn.left})}$.on("selectionUpdate",P),$.on("transaction",P),$.on("focus",P),$.on("blur",P),P();const W=new ResizeObserver(()=>P());return M.current&&W.observe(M.current),()=>{$.off("selectionUpdate",P),$.off("transaction",P),$.off("focus",P),$.off("blur",P),W.disconnect()}},[$,d,l]),S.useImperativeHandle(O,()=>({focus:(P="end")=>$==null?void 0:$.commands.focus(P),editor:$??null}),[$]);const F=S.useMemo(()=>Cx(u,(I==null?void 0:I.query)??"",$),[u,I==null?void 0:I.query,$]),Ut=S.useCallback(()=>{N(P=>{var W;return(W=P==null?void 0:P.onDismiss)==null||W.call(P),null})},[]);function _t(P){$&&(N(null),P.run({editor:$,range:(I==null?void 0:I.range)??{from:$.state.selection.from,to:$.state.selection.to}}))}function oe(P){if(!$)return;$.chain().focus().insertContentAt(P.pos,{type:"paragraph"}).setTextSelection(P.pos+1).run();const W=P.pos+1;N({source:"button",getAnchor:()=>({top:P.rect.top,bottom:P.rect.bottom,left:P.rect.left}),query:"",range:{from:W,to:W},onDismiss:()=>{const X=$.state.doc.nodeAt(P.pos);(X==null?void 0:X.type.name)==="paragraph"&&X.content.size===0&&$.chain().deleteRange({from:P.pos,to:P.pos+X.nodeSize}).run()}})}function wn(P){if(!$)return;const{from:W,to:X}=$.state.selection,be=P.currentTarget;N({source:"button",getAnchor:()=>uy(be.getBoundingClientRect()),query:"",range:{from:W,to:X}})}const V=[rl.wrapper,l&&rl.readOnly,E].filter(Boolean).join(" ");return m.jsxs("div",{ref:P=>{M.current=P,R(P)},className:V,style:{"--block-editor-width":c},onClick:P=>{if(l)return;const W=P.target;if(W.closest('button, input, select, textarea, a, [role="menu"], [role="menuitem"]'))return;const X=P.currentTarget.querySelector(".ProseMirror");X&&X.contains(W)||$==null||$.commands.focus("end")},children:[C&&m.jsx(oP,{value:v,placeholder:k,readOnly:l,onChange:P=>x==null?void 0:x(P),onLeave:()=>$==null?void 0:$.commands.focus("start")}),m.jsx(Af,{editor:$,className:rl.content}),$&&f&&!l&&m.jsx(kv,{editor:$}),$&&f&&!l&&m.jsx(vv,{editor:$}),$&&h&&!l&&m.jsx(eS,{editor:$}),$&&d&&!l&&m.jsx(h5,{editor:$,wrapper:D,onInsert:oe}),z!==null&&m.jsx(A.IconButton,{"aria-label":"Insert block",variant:"neutral",size:"sm",radius:"full",icon:m.jsx(ms,{size:16}),className:rl.insertButton,style:{top:z.top,"--block-editor-block-left":`${z.left}px`},onMouseDown:P=>P.preventDefault(),onClick:wn}),$&&p&&m.jsx(tS,{editor:$}),I&&$&&m.jsx(tL,{ref:L,blocks:F,getAnchor:I.getAnchor,query:I.query,source:I.source,onSelect:_t,onClose:Ut})]})});exports.BUTTON_BLOCK_NAME=Ix;exports.BlockDragHandle=eS;exports.BlockEditor=x5;exports.ButtonBlock=Rx;exports.CALLOUT_BLOCK_NAME=Nx;exports.COLLECTION_BLOCK_NAME=Vx;exports.CalloutBlock=Ox;exports.CollectionBlock=qx;exports.DYNAMIC_VARIABLE_NAME=Pi;exports.DynamicVariableExtension=kx;exports.EMPTY_DOCUMENT=nS;exports.GALLERY_BLOCK_NAME=Bx;exports.GalleryBlock=zx;exports.HTML_BLOCK_NAME=Dx;exports.HtmlBlock=Lx;exports.IMAGE_BLOCK_NAME=Ax;exports.ImageBlock=_x;exports.PRODUCT_BLOCK_NAME=Fx;exports.ProductBlock=Wx;exports.RichTextEditor=YD;exports.SLASH_COMMAND_KEY=Mx;exports.SlashCommand=Tx;exports.TOGGLE_BLOCK_NAME=$x;exports.TableBubbleMenu=vv;exports.TextBubbleMenu=kv;exports.ToggleBlock=Hx;exports.VIDEO_BLOCK_NAME=jx;exports.VideoBlock=Px;exports.WordCount=tS;exports.defaultBlocks=Sx;exports.filterBlocks=Cx;exports.groupBlocks=Ex;exports.isCellSelection=ch;exports.markupToTokens=xx;exports.resolveVideoEmbed=nh;exports.tokensToMarkup=ki;
|
|
452
|
+
<path d="M19 19 H5" />`,fillDuoSvg:'<g opacity="0.38"><path d="M21 5 H3" /></g><path d="M17 12 H7" /><path d="M19 19 H5" />',...t}));bx.displayName="AlignCenterIcon";var Xm=bx;const sO="_wrap_1pdh5_1",iO="_dropdown_1pdh5_6",oO="_dropdownRight_1pdh5_13",lO="_panel_1pdh5_20",aO="_search_1pdh5_32",cO="_list_1pdh5_36",uO="_group_1pdh5_43",dO="_empty_1pdh5_47",Jn={wrap:sO,dropdown:iO,dropdownRight:oO,panel:lO,search:aO,list:cO,group:uO,empty:dO},au="Other";function hO(t){var r;const e=new Map;for(const s of t){const i=((r=s.category)==null?void 0:r.trim())||au,o=e.get(i);o?o.push(s):e.set(i,[s])}const n=[...e.entries()].map(([s,i])=>({category:s,items:i}));return n.sort((s,i)=>s.category===i.category?0:s.category===au?1:i.category===au?-1:0),n}function Zm({editor:t,variables:e,disabled:n=!1,buttonClassName:r,align:s="left",onVariableInsert:i}){const[o,l]=S.useState(!1),[a,c]=S.useState(""),u=S.useRef(null),d=S.useRef(null),h=S.useRef(null),f=S.useRef(null),p=S.useMemo(()=>{const k=a.trim().toLowerCase();return k?e.filter(C=>C.label.toLowerCase().includes(k)||C.key.toLowerCase().includes(k)):e},[e,a]),g=S.useMemo(()=>hO(p),[p]);S.useEffect(()=>{n&&l(!1)},[n]),S.useEffect(()=>{function k(C){u.current&&!u.current.contains(C.target)&&l(!1)}return o&&document.addEventListener("pointerdown",k),()=>document.removeEventListener("pointerdown",k)},[o]),S.useEffect(()=>{if(!o){c("");return}const k=window.setTimeout(()=>{var C;return(C=d.current)==null?void 0:C.focus()},0);return()=>window.clearTimeout(k)},[o]);function y(){return h.current?[...h.current.querySelectorAll('[role="menuitem"]:not([disabled])')]:[]}function b(k){var _;const C=y();if(C.length===0)return;const M=C.indexOf(document.activeElement),O=M===-1?k===1?0:C.length-1:(M+k+C.length)%C.length;(_=C[O])==null||_.focus()}function w(k){l(!1),t.commands.focus()}function v(k){if(n)return;const C=f.current;t.chain().focus().setTextSelection(C??t.state.selection).insertDynamicVariable(k).run(),l(!1),i==null||i(k.key)}function x(k){if(k.key==="Escape"){k.preventDefault(),w();return}if(k.key==="ArrowDown"){k.preventDefault(),b(1);return}if(k.key==="ArrowUp"){k.preventDefault(),b(-1);return}if(k.key==="Enter"&&k.target===d.current){k.preventDefault();const C=p[0];C&&v(C)}}return m.jsxs("div",{className:Jn.wrap,ref:u,children:[m.jsx(T.Tooltip,{content:"Insert variable",placement:"top",children:m.jsx("button",{type:"button",className:r,disabled:n,"aria-label":"Insert variable","aria-haspopup":"dialog","aria-expanded":o,onMouseDown:k=>{if(k.preventDefault(),!n){if(!o){const{from:C,to:M}=t.state.selection;f.current={from:C,to:M}}l(C=>!C)}},children:m.jsx(W3,{size:14})})}),o&&m.jsx("div",{className:[Jn.dropdown,s==="right"&&Jn.dropdownRight].filter(Boolean).join(" "),children:m.jsxs("div",{className:Jn.panel,role:"dialog","aria-label":"Insert variable",onKeyDown:x,onMouseDown:k=>k.stopPropagation(),children:[m.jsx("div",{className:Jn.search,children:m.jsx(T.SearchInput,{ref:d,size:"sm","aria-label":"Search variables",placeholder:"Search variables…",value:a,onChange:k=>c(k.target.value)})}),m.jsx(T.Scrollable,{size:"thin",maxHeight:"264px",children:m.jsx("div",{className:Jn.list,ref:h,role:"menu","aria-label":"Variables",children:g.length===0?m.jsx("div",{className:Jn.empty,children:"No variables found"}):g.map(k=>m.jsxs("div",{className:Jn.group,role:"group","aria-label":k.category,children:[m.jsx(T.MenuTitle,{children:k.category}),k.items.map(C=>m.jsx(T.MenuItem,{label:C.label,onClick:()=>v(C)},C.key))]},k.category))})})]})})]})}const fO="_menubar_89djx_1",pO="_group_89djx_11",mO="_divider_89djx_17",gO="_spacer_89djx_25",yO="_btn_89djx_30",bO="_active_89djx_46",wO="_blockWrap_89djx_63",xO="_blockTrigger_89djx_67",vO="_blockTriggerCompact_89djx_86",kO="_blockDropdown_89djx_107",SO="_alignTrigger_89djx_116",CO="_colorWrap_89djx_148",MO="_colorDropdown_89djx_152",AO="_colorTabs_89djx_164",EO="_colorPickerBody_89djx_169",TO="_colorTab_89djx_164",_O="_colorTabActive_89djx_198",NO="_menubarWrap_89djx_215",OO="_aiPanel_89djx_221",IO="_aiInputRow_89djx_230",DO="_aiTextarea_89djx_244",RO="_aiLoadingText_89djx_268",Z={menubar:fO,group:pO,divider:mO,spacer:gO,btn:yO,active:bO,blockWrap:wO,blockTrigger:xO,blockTriggerCompact:vO,blockDropdown:kO,alignTrigger:SO,colorWrap:CO,colorDropdown:MO,colorTabs:AO,colorPickerBody:EO,colorTab:TO,colorTabActive:_O,menubarWrap:NO,aiPanel:OO,aiInputRow:IO,aiTextarea:DO,aiLoadingText:RO},LO=S.memo(function({editor:e,disabled:n,showHtml:r,compact:s=!1,onLinkClick:i,onCodeClick:o,variables:l,showVariablePicker:a=!1,onVariableInsert:c,onAiSubmit:u,aiSubmitDisabled:d=!1}){const[h,f]=S.useState(!1),[p,g]=S.useState(""),[y,b]=S.useState(!1),w=S.useRef(null),v=S.useRef(null),[x,k]=S.useState(!1),C=S.useRef(null),[M,O]=S.useState(!1),_=S.useRef(null),A=S.useRef(null),[R,D]=S.useState(!1),L=S.useRef(null),[I,N]=S.useState(!1),H=S.useRef(null),[$,U]=S.useState(!1),[K,de]=S.useState("text"),[ve,Me]=S.useState("#000000"),[Ct,Ae]=S.useState("#ffff00"),Te=S.useRef(null),He=S.useRef(null),z=S.useRef(null),V=vo({editor:e,selector:({editor:E})=>({isBold:E.isActive("bold"),isItalic:E.isActive("italic"),isUnderline:E.isActive("underline"),isStrike:E.isActive("strike"),isAlignLeft:E.isActive({textAlign:"left"}),isAlignCenter:E.isActive({textAlign:"center"}),isAlignRight:E.isActive({textAlign:"right"}),isH1:E.isActive("heading",{level:1}),isH2:E.isActive("heading",{level:2}),isH3:E.isActive("heading",{level:3}),isH4:E.isActive("heading",{level:4}),isH5:E.isActive("heading",{level:5}),isH6:E.isActive("heading",{level:6}),isBlockquote:E.isActive("blockquote"),isBulletList:E.isActive("bulletList"),isOrderedList:E.isActive("orderedList"),isLink:E.isActive("link"),isTable:E.isActive("tableCell")||E.isActive("tableHeader"),hasSelection:!E.state.selection.empty})});S.useEffect(()=>{function E(ne){v.current&&!v.current.contains(ne.target)&&f(!1)}return h&&document.addEventListener("pointerdown",E),()=>document.removeEventListener("pointerdown",E)},[h]),S.useEffect(()=>{function E(ne){C.current&&!C.current.contains(ne.target)&&k(!1)}return x&&document.addEventListener("pointerdown",E),()=>document.removeEventListener("pointerdown",E)},[x]),S.useEffect(()=>{function E(ne){_.current&&!_.current.contains(ne.target)&&O(!1)}return M&&document.addEventListener("pointerdown",E),()=>document.removeEventListener("pointerdown",E)},[M]),S.useEffect(()=>{function E(ne){H.current&&!H.current.contains(ne.target)&&N(!1)}return I&&document.addEventListener("pointerdown",E),()=>document.removeEventListener("pointerdown",E)},[I]),S.useEffect(()=>{function E(){k(!1),O(!1),D(!1),N(!1)}return e.on("focus",E),()=>{e.off("focus",E)}},[e]),S.useEffect(()=>{function E(ne){Te.current&&!Te.current.contains(ne.target)&&U(!1)}return $&&document.addEventListener("pointerdown",E),()=>document.removeEventListener("pointerdown",E)},[$]);const Ut=S.useCallback(()=>{f(E=>{const ne=!E;return ne&&setTimeout(()=>{var Je;return(Je=w.current)==null?void 0:Je.focus()},0),ne})},[]);async function _t(){if(!p.trim()||y||d)return;const E=p;g(""),w.current&&(w.current.style.height="auto"),b(!0);try{await(u==null?void 0:u(E))}finally{b(!1),f(!1)}}const oe=n||!!r,wn=l??[],F=a&&wn.length>0;S.useEffect(()=>{oe&&(f(!1),k(!1),O(!1),D(!1),N(!1),U(!1))},[oe]);function P(E){oe||E()}function W(...E){return[Z.btn,...E].filter(Boolean).join(" ")}const X=V.isH1?"Heading 1":V.isH2?"Heading 2":V.isH3?"Heading 3":V.isH4?"Heading 4":V.isH5?"Heading 5":V.isH6?"Heading 6":V.isBlockquote?"Blockquote":"Paragraph",be=V.isH1?"H1":V.isH2?"H2":V.isH3?"H3":V.isH4?"H4":V.isH5?"H5":V.isH6?"H6":V.isBlockquote?"Quote":"Text";return s?m.jsx("div",{className:Z.menubarWrap,ref:v,onClick:E=>E.stopPropagation(),children:m.jsxs("div",{className:Z.menubar,children:[m.jsxs("div",{className:Z.blockWrap,ref:C,children:[m.jsxs("button",{type:"button",className:`${Z.blockTrigger} ${Z.blockTriggerCompact}`,disabled:oe,onMouseDown:E=>{E.preventDefault(),oe||(z.current={from:e.state.selection.from,to:e.state.selection.to},k(ne=>!ne))},"aria-label":"Text style",children:[m.jsx("span",{children:be}),m.jsx(wl,{size:12})]}),x&&m.jsx("div",{className:Z.blockDropdown,children:m.jsxs(T.Menu,{children:[m.jsx(T.MenuItemRadio,{label:"Paragraph",leftIcon:m.jsx(bd,{size:16}),checked:!V.isH1&&!V.isH2&&!V.isH3&&!V.isH4&&!V.isH5&&!V.isH6&&!V.isBlockquote,onClick:()=>{const E=z.current;e.chain().focus().setTextSelection(E??e.state.selection).setParagraph().run(),k(!1)}}),m.jsx(T.MenuItemRadio,{label:"Blockquote",leftIcon:m.jsx(Jm,{size:16}),checked:V.isBlockquote,onClick:()=>{const E=z.current;e.chain().focus().setTextSelection(E??e.state.selection).toggleBlockquote().run(),k(!1)}}),m.jsx(T.MenuItemRadio,{label:"Heading 1",leftIcon:m.jsx(Ed,{size:16}),checked:V.isH1,onClick:()=>{const E=z.current;e.chain().focus().setTextSelection(E??e.state.selection).toggleHeading({level:1}).run(),k(!1)}}),m.jsx(T.MenuItemRadio,{label:"Heading 2",leftIcon:m.jsx(Td,{size:16}),checked:V.isH2,onClick:()=>{const E=z.current;e.chain().focus().setTextSelection(E??e.state.selection).toggleHeading({level:2}).run(),k(!1)}}),m.jsx(T.MenuItemRadio,{label:"Heading 3",leftIcon:m.jsx(Sd,{size:16}),checked:V.isH3,onClick:()=>{const E=z.current;e.chain().focus().setTextSelection(E??e.state.selection).toggleHeading({level:3}).run(),k(!1)}}),m.jsx(T.MenuItemRadio,{label:"Heading 4",leftIcon:m.jsx(Cd,{size:16}),checked:V.isH4,onClick:()=>{const E=z.current;e.chain().focus().setTextSelection(E??e.state.selection).toggleHeading({level:4}).run(),k(!1)}}),m.jsx(T.MenuItemRadio,{label:"Heading 5",leftIcon:m.jsx(Md,{size:16}),checked:V.isH5,onClick:()=>{const E=z.current;e.chain().focus().setTextSelection(E??e.state.selection).toggleHeading({level:5}).run(),k(!1)}}),m.jsx(T.MenuItemRadio,{label:"Heading 6",leftIcon:m.jsx(Ad,{size:16}),checked:V.isH6,onClick:()=>{const E=z.current;e.chain().focus().setTextSelection(E??e.state.selection).toggleHeading({level:6}).run(),k(!1)}})]})})]}),m.jsx("div",{className:Z.divider}),m.jsxs("div",{className:Z.group,children:[m.jsx(T.Tooltip,{content:"Bold",placement:"top",children:m.jsx("button",{type:"button",className:W(V.isBold&&Z.active),disabled:oe,onMouseDown:E=>{E.preventDefault(),P(()=>e.chain().toggleBold().run())},"aria-label":"Bold",children:m.jsx(_d,{size:14})})}),m.jsx(T.Tooltip,{content:"Italic",placement:"top",children:m.jsx("button",{type:"button",className:W(V.isItalic&&Z.active),disabled:oe,onMouseDown:E=>{E.preventDefault(),P(()=>e.chain().toggleItalic().run())},"aria-label":"Italic",children:m.jsx(vd,{size:14})})})]}),m.jsx("div",{className:Z.divider}),m.jsxs("div",{className:Z.group,children:[m.jsx(T.Tooltip,{content:"Link",placement:"top",children:m.jsx("button",{type:"button",className:W(V.isLink&&Z.active),disabled:oe||!V.hasSelection&&!V.isLink,onMouseDown:E=>{E.preventDefault(),i()},"aria-label":"Link",children:m.jsx(xd,{size:14})})}),m.jsx(T.Tooltip,{content:"Numbered list",placement:"top",children:m.jsx("button",{type:"button",className:W(V.isOrderedList&&Z.active),disabled:oe,onMouseDown:E=>{E.preventDefault(),P(()=>e.chain().focus().toggleOrderedList().run())},"aria-label":"Numbered list",children:m.jsx(qm,{size:14})})}),m.jsx(T.Tooltip,{content:"Bullet list",placement:"top",children:m.jsx("button",{type:"button",className:W(V.isBulletList&&Z.active),disabled:oe,onMouseDown:E=>{E.preventDefault(),P(()=>e.chain().focus().toggleBulletList().run())},"aria-label":"Bullet list",children:m.jsx(ga,{size:14})})})]}),F&&m.jsxs(m.Fragment,{children:[m.jsx("div",{className:Z.spacer}),m.jsx("div",{className:Z.group,children:m.jsx(Zm,{editor:e,variables:wn,disabled:oe,buttonClassName:W(),align:"right",onVariableInsert:c})})]})]})}):m.jsxs("div",{className:Z.menubarWrap,ref:v,onClick:E=>E.stopPropagation(),children:[m.jsxs("div",{className:Z.menubar,children:[m.jsx(T.Tooltip,{content:"AI",placement:"top",children:m.jsx("button",{type:"button",className:W(h&&Z.active),disabled:oe,onMouseDown:E=>{E.preventDefault(),oe||Ut()},"aria-label":"AI",children:m.jsx(N3,{size:14})})}),m.jsx("div",{className:Z.divider}),m.jsxs("div",{className:Z.blockWrap,ref:C,children:[m.jsxs("button",{type:"button",className:Z.blockTrigger,disabled:oe,onMouseDown:E=>{E.preventDefault(),oe||(z.current={from:e.state.selection.from,to:e.state.selection.to},k(ne=>!ne))},"aria-label":"Text style",children:[m.jsx("span",{children:X}),m.jsx(wl,{size:12})]}),x&&m.jsx("div",{className:Z.blockDropdown,children:m.jsxs(T.Menu,{children:[m.jsx(T.MenuItemRadio,{label:"Paragraph",leftIcon:m.jsx(bd,{size:16}),checked:!V.isH1&&!V.isH2&&!V.isH3&&!V.isH4&&!V.isH5&&!V.isH6&&!V.isBlockquote,onClick:()=>{const E=z.current;e.chain().focus().setTextSelection(E??e.state.selection).setParagraph().run(),k(!1)}}),m.jsx(T.MenuItemRadio,{label:"Blockquote",leftIcon:m.jsx(Jm,{size:16}),checked:V.isBlockquote,onClick:()=>{const E=z.current;e.chain().focus().setTextSelection(E??e.state.selection).toggleBlockquote().run(),k(!1)}}),m.jsx(T.MenuItemRadio,{label:"Heading 1",leftIcon:m.jsx(Ed,{size:16}),checked:V.isH1,onClick:()=>{const E=z.current;e.chain().focus().setTextSelection(E??e.state.selection).toggleHeading({level:1}).run(),k(!1)}}),m.jsx(T.MenuItemRadio,{label:"Heading 2",leftIcon:m.jsx(Td,{size:16}),checked:V.isH2,onClick:()=>{const E=z.current;e.chain().focus().setTextSelection(E??e.state.selection).toggleHeading({level:2}).run(),k(!1)}}),m.jsx(T.MenuItemRadio,{label:"Heading 3",leftIcon:m.jsx(Sd,{size:16}),checked:V.isH3,onClick:()=>{const E=z.current;e.chain().focus().setTextSelection(E??e.state.selection).toggleHeading({level:3}).run(),k(!1)}}),m.jsx(T.MenuItemRadio,{label:"Heading 4",leftIcon:m.jsx(Cd,{size:16}),checked:V.isH4,onClick:()=>{const E=z.current;e.chain().focus().setTextSelection(E??e.state.selection).toggleHeading({level:4}).run(),k(!1)}}),m.jsx(T.MenuItemRadio,{label:"Heading 5",leftIcon:m.jsx(Md,{size:16}),checked:V.isH5,onClick:()=>{const E=z.current;e.chain().focus().setTextSelection(E??e.state.selection).toggleHeading({level:5}).run(),k(!1)}}),m.jsx(T.MenuItemRadio,{label:"Heading 6",leftIcon:m.jsx(Ad,{size:16}),checked:V.isH6,onClick:()=>{const E=z.current;e.chain().focus().setTextSelection(E??e.state.selection).toggleHeading({level:6}).run(),k(!1)}})]})})]}),m.jsx("div",{className:Z.divider}),m.jsxs("div",{className:Z.group,children:[m.jsx(T.Tooltip,{content:"Bold",placement:"top",children:m.jsx("button",{type:"button",className:W(V.isBold&&Z.active),disabled:oe,onMouseDown:E=>{E.preventDefault(),P(()=>e.chain().toggleBold().run())},"aria-label":"Bold",children:m.jsx(_d,{size:14})})}),m.jsx(T.Tooltip,{content:"Italic",placement:"top",children:m.jsx("button",{type:"button",className:W(V.isItalic&&Z.active),disabled:oe,onMouseDown:E=>{E.preventDefault(),P(()=>e.chain().toggleItalic().run())},"aria-label":"Italic",children:m.jsx(vd,{size:14})})}),m.jsx(T.Tooltip,{content:"Underline",placement:"top",children:m.jsx("button",{type:"button",className:W(V.isUnderline&&Z.active),disabled:oe,onMouseDown:E=>{E.preventDefault(),P(()=>e.chain().toggleUnderline().run())},"aria-label":"Underline",children:m.jsx(Yb,{size:14})})}),m.jsxs("div",{className:Z.colorWrap,ref:Te,children:[m.jsx(T.Tooltip,{content:"Color",placement:"top",children:m.jsx("button",{type:"button",className:W($&&Z.active),disabled:oe,onMouseDown:E=>{if(E.preventDefault(),!oe){if(!$){const{from:ne,to:Je}=e.state.selection;He.current={from:ne,to:Je}}U(ne=>!ne)}},"aria-label":"Color",children:m.jsx(kw,{size:14})})}),$&&m.jsxs("div",{className:Z.colorDropdown,children:[m.jsxs("div",{className:Z.colorTabs,children:[m.jsx("button",{type:"button",className:`${Z.colorTab} ${K==="text"?Z.colorTabActive:""}`,onMouseDown:E=>{E.preventDefault(),de("text")},children:"Text"}),m.jsx("button",{type:"button",className:`${Z.colorTab} ${K==="bg"?Z.colorTabActive:""}`,onMouseDown:E=>{E.preventDefault(),de("bg")},children:"Background"})]}),m.jsx("div",{className:Z.colorPickerBody,children:K==="text"?m.jsx(T.ColorPicker,{alwaysOpen:!0,value:ve,onChange:E=>{Me(E);const ne=He.current;ne&&ne.from!==ne.to?e.chain().setTextSelection(ne).setColor(E).run():e.chain().setColor(E).run()}}):m.jsx(T.ColorPicker,{alwaysOpen:!0,value:Ct,onChange:E=>{Ae(E);const ne=He.current;ne&&ne.from!==ne.to?e.chain().setTextSelection(ne).setHighlight({color:E}).run():e.chain().setHighlight({color:E}).run()}})})]})]})]}),m.jsx("div",{className:Z.divider}),m.jsxs("div",{className:Z.blockWrap,ref:_,children:[m.jsxs("button",{type:"button",className:Z.alignTrigger,disabled:oe,onMouseDown:E=>{E.preventDefault(),oe||(A.current={from:e.state.selection.from,to:e.state.selection.to},O(ne=>!ne))},"aria-label":"Text alignment",children:[V.isAlignCenter?m.jsx(Xm,{size:14}):V.isAlignRight?m.jsx(Ym,{size:14}):m.jsx(Gm,{size:14}),m.jsx(wl,{size:12})]}),M&&m.jsx("div",{className:Z.blockDropdown,children:m.jsxs(T.Menu,{children:[m.jsx(T.MenuItemRadio,{label:"Align left",leftIcon:m.jsx(Gm,{size:16}),checked:!V.isAlignCenter&&!V.isAlignRight,onClick:()=>{const E=A.current;e.chain().focus().setTextSelection(E??e.state.selection).setTextAlign("left").run(),O(!1)}}),m.jsx(T.MenuItemRadio,{label:"Align center",leftIcon:m.jsx(Xm,{size:16}),checked:V.isAlignCenter,onClick:()=>{const E=A.current;e.chain().focus().setTextSelection(E??e.state.selection).setTextAlign("center").run(),O(!1)}}),m.jsx(T.MenuItemRadio,{label:"Align right",leftIcon:m.jsx(Ym,{size:16}),checked:V.isAlignRight,onClick:()=>{const E=A.current;e.chain().focus().setTextSelection(E??e.state.selection).setTextAlign("right").run(),O(!1)}})]})})]}),m.jsx("div",{className:Z.divider}),m.jsxs("div",{className:Z.group,children:[m.jsx(T.Tooltip,{content:"Link",placement:"top",children:m.jsx("button",{type:"button",className:W(V.isLink&&Z.active),disabled:oe||!V.hasSelection&&!V.isLink,onMouseDown:E=>{E.preventDefault(),i()},"aria-label":"Link",children:m.jsx(xd,{size:14})})}),m.jsxs("div",{className:Z.blockWrap,ref:H,children:[m.jsx(T.Tooltip,{content:"Table",placement:"top",children:m.jsx("button",{type:"button",className:W(V.isTable&&Z.active),disabled:oe,onMouseDown:E=>{if(E.preventDefault(),oe)return;e.isActive("tableCell")||e.isActive("tableHeader")?N(Je=>!Je):e.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run()},"aria-label":"Table",children:m.jsx(aw,{size:14})})}),I&&m.jsx("div",{className:Z.blockDropdown,children:m.jsxs(T.Menu,{children:[m.jsx(T.MenuItem,{label:"Add row above",leftIcon:m.jsx(ms,{size:16}),onClick:()=>{e.chain().focus().addRowBefore().run(),N(!1)}}),m.jsx(T.MenuItem,{label:"Add row below",leftIcon:m.jsx(ms,{size:16}),onClick:()=>{e.chain().focus().addRowAfter().run(),N(!1)}}),m.jsx(T.MenuItem,{label:"Add column left",leftIcon:m.jsx(ms,{size:16}),onClick:()=>{e.chain().focus().addColumnBefore().run(),N(!1)}}),m.jsx(T.MenuItem,{label:"Add column right",leftIcon:m.jsx(ms,{size:16}),onClick:()=>{e.chain().focus().addColumnAfter().run(),N(!1)}}),m.jsx(T.MenuSeparator,{}),m.jsx(T.MenuItem,{label:"Delete row",leftIcon:m.jsx(wd,{size:16}),variant:"danger",onClick:()=>{e.chain().focus().deleteRow().run(),N(!1)}}),m.jsx(T.MenuItem,{label:"Delete column",leftIcon:m.jsx(wd,{size:16}),variant:"danger",onClick:()=>{e.chain().focus().deleteColumn().run(),N(!1)}}),m.jsx(T.MenuItem,{label:"Delete table",leftIcon:m.jsx(S3,{size:16}),variant:"danger",onClick:()=>{e.chain().focus().deleteTable().run(),N(!1)}})]})})]})]}),m.jsx("div",{className:Z.divider}),m.jsx(T.Popover,{open:R,onOpenChange:E=>{if(E){const{from:ne,to:Je}=e.state.selection;L.current={from:ne,to:Je}}D(E)},placement:"bottom-start",offset:4,bare:!0,trigger:m.jsx(T.Tooltip,{content:"Lists & formatting",placement:"top",children:m.jsx("button",{type:"button",className:W((R||V.isBulletList||V.isOrderedList)&&Z.active),disabled:oe,onMouseDown:E=>E.preventDefault(),"aria-expanded":R,"aria-haspopup":"menu","aria-label":"Lists and formatting",children:m.jsx(U3,{size:16})})}),children:m.jsxs(T.Menu,{children:[m.jsx(T.MenuItemRadio,{label:"Strikethrough",leftIcon:m.jsx(uw,{size:16}),checked:V.isStrike,onClick:()=>{const E=L.current;e.chain().focus().setTextSelection(E??e.state.selection).toggleStrike().run(),D(!1)}}),m.jsx(T.MenuSeparator,{}),m.jsx(T.MenuItemRadio,{label:"Bullet list",leftIcon:m.jsx(ga,{size:16}),checked:V.isBulletList,onClick:()=>{const E=L.current;e.chain().focus().setTextSelection(E??e.state.selection).toggleBulletList().run(),D(!1)}}),m.jsx(T.MenuItemRadio,{label:"Numbered list",leftIcon:m.jsx(qm,{size:16}),checked:V.isOrderedList,onClick:()=>{const E=L.current;e.chain().focus().setTextSelection(E??e.state.selection).toggleOrderedList().run(),D(!1)}}),m.jsx(T.MenuSeparator,{}),m.jsx(T.MenuItemRadio,{label:"Increase indent",leftIcon:m.jsx(L3,{size:16}),checked:!1,onClick:()=>{const E=L.current;e.chain().focus().setTextSelection(E??e.state.selection).increaseIndent().run(),D(!1)}}),m.jsx(T.MenuItemRadio,{label:"Decrease indent",leftIcon:m.jsx(B3,{size:16}),checked:!1,onClick:()=>{const E=L.current;e.chain().focus().setTextSelection(E??e.state.selection).decreaseIndent().run(),D(!1)}}),m.jsx(T.MenuSeparator,{}),m.jsx(T.MenuItemRadio,{label:"Clear formatting",leftIcon:m.jsx(I3,{size:16}),checked:!1,onClick:()=>{const E=L.current;e.chain().focus().setTextSelection(E??e.state.selection).unsetAllMarks().run(),D(!1)}})]})}),m.jsx("div",{className:Z.spacer}),m.jsxs("div",{className:Z.group,children:[m.jsx(T.Tooltip,{content:"HTML source",placement:"top",children:m.jsx("button",{type:"button",className:W(r&&Z.active),onMouseDown:E=>{E.preventDefault(),o()},"aria-label":"HTML source",children:m.jsx(nc,{size:14})})}),F&&m.jsx(Zm,{editor:e,variables:wn,disabled:oe,buttonClassName:W(),align:"right",onVariableInsert:c})]})]}),h&&m.jsx("div",{className:Z.aiPanel,children:m.jsxs("div",{className:Z.aiInputRow,children:[y?m.jsx("span",{className:Z.aiLoadingText,children:"Generating…"}):m.jsx("textarea",{ref:w,className:Z.aiTextarea,placeholder:"Describe your changes…",value:p,rows:1,onChange:E=>{g(E.target.value),E.target.style.height="auto",E.target.style.height=`${E.target.scrollHeight}px`},onKeyDown:E=>{E.key==="Enter"&&!E.shiftKey&&(E.preventDefault(),_t()),E.key==="Escape"&&f(!1)}}),m.jsx(T.IconButton,{icon:m.jsx(V3,{size:14}),"aria-label":"Send",size:"xsmall",radius:"full",variant:"neutral",disabled:!p.trim()||y||d,onMouseDown:E=>{E.preventDefault(),_t()}})]})})]})}),jO="_form_1nh56_1",PO="_field_1nh56_8",BO="_urlGroup_1nh56_14",HO="_footer_1nh56_20",zO="_removeBtn_1nh56_28",$O="_footerActions_1nh56_32",Sr={form:jO,field:PO,urlGroup:BO,footer:HO,removeBtn:zO,footerActions:$O};function Qm(t){return t.replace(/^https?:\/\//i,"")}function VO(t){const e=t.trim();return e?/^https?:\/\//i.test(e)?e:`https://${e}`:""}function FO({editor:t,open:e,onClose:n}){const[r,s]=S.useState(""),[i,o]=S.useState(""),[l,a]=S.useState(!1),c=!!t.getAttributes("link").href;S.useEffect(()=>{if(e){const h=t.getAttributes("link");s(Qm(h.href??"")),o(h.title??""),a(h.target==="_blank")}},[e,t]);function u(){const h=VO(r);h?t.chain().focus().extendMarkRange("link").setLink({href:h,target:l?"_blank":null,title:i.trim()||null}).run():t.chain().focus().extendMarkRange("link").unsetLink().run(),n()}function d(){t.chain().focus().extendMarkRange("link").unsetLink().run(),n()}return m.jsx(T.Modal,{open:e,onClose:n,title:c?"Edit link":"Add link",size:"sm",footer:m.jsxs("div",{className:Sr.footer,children:[c&&m.jsx(T.Button,{variant:"danger",size:"sm",onClick:d,className:Sr.removeBtn,children:"Remove"}),m.jsxs("div",{className:Sr.footerActions,children:[m.jsx(T.Button,{variant:"neutral",size:"sm",onClick:n,children:"Cancel"}),m.jsx(T.Button,{variant:"inverted",size:"sm",onClick:u,children:"Save"})]})]}),children:m.jsxs("form",{onSubmit:h=>{h.preventDefault(),u()},noValidate:!0,className:Sr.form,children:[m.jsxs("div",{className:Sr.urlGroup,children:[m.jsxs("div",{className:Sr.field,children:[m.jsx(T.Label,{htmlFor:"link-url",children:"Link Address"}),m.jsx(T.UrlInput,{id:"link-url",value:r,onChange:h=>s(Qm(h.target.value)),autoFocus:!0})]}),m.jsx(T.Checkbox,{label:"Open in new tab",checked:l,onChange:h=>a(h.target.checked)})]}),m.jsxs("div",{className:Sr.field,children:[m.jsx(T.Label,{htmlFor:"link-header",optional:!0,children:"Link header"}),m.jsx(T.Input,{id:"link-header",placeholder:"Enter link header",value:i,onChange:h=>o(h.target.value)}),m.jsx(T.Hint,{children:"Used for accessibility and SEO"})]})]})})}const UO="_chip_v3xby_5",WO={chip:UO},Pi="dynamicVariable",Bi=/\{\{\s*([A-Za-z0-9_.-]+)\s*\}\}/g,eg=/<span\s+data-dynamic-variable="true"\s+data-key="([A-Za-z0-9_.-]*)"\s*>[^<]*<\/span>/g;function tg(t){return typeof t=="string"?t.replace(/[^A-Za-z0-9_.-]/g,""):""}function wx(t){const e=new Map;for(const n of t??[])n&&typeof n.key=="string"&&n.key&&e.set(n.key,n);return e}function ng(t){return t.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function KO(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function qO(t){const e=t.label||t.key;return`<span data-dynamic-variable="true" data-key="${ng(t.key)}" data-label="${ng(e)}">${KO(e)}</span>`}function xx(t){return!t||t.indexOf("data-dynamic-variable")===-1?t:(eg.lastIndex=0,t.replace(eg,(e,n)=>`{{${n}}}`))}function rg(t,e){return Bi.lastIndex=0,t.replace(Bi,(n,r)=>{const s=e.get(r);return s?qO(s):n})}function ki(t,e){if(!t)return t;const n=wx(e);if(n.size===0)return t;let r="",s=0;for(;s<t.length;){const i=t.indexOf("<",s);if(i===-1){r+=rg(t.slice(s),n);break}r+=rg(t.slice(s,i),n);const o=t.indexOf(">",i);if(o===-1){r+=t.slice(i);break}r+=t.slice(i,o+1),s=o+1}return r}function JO(t,e,n){const r=t.text??"",s=e.schema,i=[];let o=0;Bi.lastIndex=0;let l=Bi.exec(r);for(;l;){const a=n.get(l[1]);a&&(l.index>o&&i.push(s.text(r.slice(o,l.index),t.marks)),i.push(e.create({key:a.key,label:a.label||a.key},null,t.marks)),o=l.index+l[0].length),l=Bi.exec(r)}return i.length===0?[t]:(o<r.length&&i.push(s.text(r.slice(o),t.marks)),i)}function vx(t,e,n){if(n.size===0)return t;const r=[];return t.forEach(s=>{s.isText?r.push(...JO(s,e,n)):s.content.size>0?r.push(s.copy(vx(s.content,e,n))):r.push(s)}),j.fromArray(r)}const kx=ke.create({name:Pi,inline:!0,group:"inline",atom:!0,selectable:!0,draggable:!1,addOptions(){return{variables:[]}},addStorage(){var t;return{variables:((t=this.options)==null?void 0:t.variables)??[]}},addAttributes(){return{key:{default:"",parseHTML:t=>tg(t.getAttribute("data-key")),renderHTML:()=>({})},label:{default:null,parseHTML:t=>t.getAttribute("data-label")||t.textContent||null,renderHTML:()=>({})}}},parseHTML(){return[{tag:"span[data-dynamic-variable]"}]},renderHTML({node:t}){const e=tg(t.attrs.key),n=t.attrs.label||e;return["span",{"data-dynamic-variable":"true","data-key":e},n]},renderText({node:t}){return`{{${t.attrs.key}}}`},addNodeView(){return({node:t})=>{const e=document.createElement("span"),n=r=>{e.setAttribute("data-dynamic-variable","true"),e.setAttribute("data-key",r.attrs.key),e.setAttribute("contenteditable","false"),e.setAttribute("title",`{{${r.attrs.key}}}`),e.className=WO.chip,e.textContent=r.attrs.label||r.attrs.key};return n(t),{dom:e,update(r){return r.type.name!==Pi?!1:(n(r),!0)},ignoreMutation:()=>!0}}},addCommands(){return{insertDynamicVariable:t=>({commands:e})=>e.insertContent({type:this.name,attrs:{key:t.key,label:t.label||t.key}})}},addKeyboardShortcuts(){const t=e=>()=>{const{state:n,view:r}=this.editor,{selection:s}=n;if(s instanceof Y&&s.node.type.name===this.name)return r.dispatch(n.tr.deleteSelection()),!0;if(!s.empty)return!1;const i=s.$from,o=e===-1?i.nodeBefore:i.nodeAfter;if(!o||o.type.name!==this.name)return!1;const l=e===-1?i.pos-o.nodeSize:i.pos;return r.dispatch(n.tr.delete(l,l+o.nodeSize)),!0};return{Backspace:t(-1),Delete:t(1)}},addProseMirrorPlugins(){const t=this.type,e=this.editor,n=this.options.variables;return[new ce({key:new ae("dynamicVariablePaste"),props:{transformPasted:r=>{var o,l;const s=((l=(o=e==null?void 0:e.storage)==null?void 0:o[Pi])==null?void 0:l.variables)??n,i=wx(s);return i.size===0?r:new q(vx(r.content,t,i),r.openStart,r.openEnd)}}})]}}),GO=S_.extend({addAttributes(){var t;return{...(t=this.parent)==null?void 0:t.call(this),title:{default:null}}}});function Xo(t){return xx(t.getHTML())}const YO=S.forwardRef(function({value:e,defaultValue:n,placeholder:r,minHeight:s,maxHeight:i="400px",onChange:o,onFocus:l,onBlur:a,error:c=!1,disabled:u=!1,readOnly:d=!1,variant:h="white",compact:f=!1,className:p,onAiSubmit:g,aiSubmitDisabled:y,variables:b,showVariablePicker:w=!1,onVariableInsert:v},x){const[k,C]=S.useState(!1),[M,O]=S.useState(!1),[_,A]=S.useState(""),R=S.useRef(!1),D=(b??[]).map(U=>`${U.key}\0${U.label}`).join(""),L=S.useMemo(()=>b??[],[D]),I=Oy({extensions:[Eb.configure({heading:{levels:[1,2,3,4,5,6]},link:!1}),_b.configure({multicolor:!0}),GO.configure({openOnClick:!1}),qh.configure({resizable:!1}),Kh,Wh,Uh,...r!==void 0?[Tb.configure({placeholder:r})]:[],Jh,Gh,K5.configure({types:["heading","paragraph"]}),jN,kx.configure({variables:L})],content:ki(e??n??"",L),editable:!u&&!d,shouldRerenderOnTransaction:!1,onUpdate({editor:U}){R.current=!0,o==null||o(U.isEmpty?null:Xo(U))},onFocus(){l==null||l()},onBlur(){a==null||a()}});S.useEffect(()=>{I==null||I.setEditable(!u&&!d)},[I,u,d]),S.useEffect(()=>{if(!I||e===void 0)return;if(R.current){R.current=!1;return}Xo(I)!==e&&I.commands.setContent(ki(e??"",L),{emitUpdate:!1})},[I,e,L]),S.useEffect(()=>{if(!I)return;const U=I.storage[Pi];U&&(U.variables=L)},[I,L]);const N=S.useRef(D);S.useEffect(()=>{I&&N.current!==D&&(N.current=D,I.commands.setContent(ki(Xo(I),L),{emitUpdate:!1}))},[I,D,L]),S.useImperativeHandle(x,()=>({focus:(U="end")=>I==null?void 0:I.commands.focus(U)}));function H(){I&&(M?I.commands.setContent(ki(_,L)):A(Xo(I)),O(U=>!U))}const $=[Mn.wrapper,Mn[h],c&&Mn.error,u&&Mn.disabled,d&&Mn.readOnly,p].filter(Boolean).join(" ");return m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:$,style:s?{"--rte-min-height":s}:void 0,onClick:U=>{if(u||d||M)return;const K=U.target;if(K.closest('button, input, select, a, [role="menu"], [role="menuitem"], [role="menuitemradio"]'))return;const de=U.currentTarget.querySelector(".ProseMirror");de&&de.contains(K)||I==null||I.commands.focus("end")},children:[I&&!d&&m.jsx("div",{className:Mn.menuBarRegion,children:m.jsx(LO,{editor:I,disabled:u,showHtml:M,compact:f,onLinkClick:()=>C(!0),onCodeClick:H,variables:L,showVariablePicker:w,onVariableInsert:v,onAiSubmit:g,aiSubmitDisabled:y})}),M?m.jsx(T.Scrollable,{size:"thin",maxHeight:i,children:m.jsx(Vb,{value:_,onValueChange:A,highlight:U=>ma.highlight(U,ma.languages.markup,"markup"),padding:12,className:Mn.htmlSource,textareaClassName:Mn.htmlSourceTextarea,style:{fontFamily:"var(--font-family-code)",fontSize:"var(--font-size-small)",lineHeight:1.6}})}):m.jsx(T.Scrollable,{size:"thin",maxHeight:i,children:m.jsx(Eh,{editor:I,className:Mn.content})})]}),I&&m.jsx(FO,{editor:I,open:k,onClose:()=>C(!1)})]})}),Ge=16;function sg(t,e){var r;const n=t.extensionManager.extensions.find(s=>s.name===e);return typeof((r=n==null?void 0:n.options)==null?void 0:r.onPick)=="function"}const Sx=[{id:"paragraph",label:"Text",icon:m.jsx(k3,{size:Ge}),group:"Basic",shortcut:"/text",keywords:["paragraph","body","plain"],run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setNode("paragraph").run()}},{id:"heading",label:"Heading",icon:m.jsx(z3,{size:Ge}),group:"Basic",shortcut:"/heading",keywords:["title","header","h1","h2","h3"],run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setNode("heading",{level:2}).run()}},{id:"bullet-list",label:"Bulleted list",icon:m.jsx(ga,{size:Ge}),group:"Basic",shortcut:"/ul",keywords:["unordered","bullets","points"],run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).toggleBulletList().run()}},{id:"ordered-list",label:"Numbered list",icon:m.jsx(Nw,{size:Ge}),group:"Basic",shortcut:"/ol",keywords:["ordered","numbers","steps"],run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).toggleOrderedList().run()}},{id:"blockquote",label:"Quote",icon:m.jsx(tw,{size:Ge}),group:"Basic",shortcut:"/quote",keywords:["blockquote","citation"],run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).toggleBlockquote().run()}},{id:"code-block",label:"Code",icon:m.jsx(nc,{size:Ge}),group:"Basic",shortcut:"/code",keywords:["snippet","pre","syntax"],run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).toggleCodeBlock().run()}},{id:"divider",label:"Divider",icon:m.jsx(wd,{size:Ge}),group:"Basic",shortcut:"/hr",keywords:["horizontal rule","separator","line"],run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setHorizontalRule().run()}},{id:"table",label:"Table",icon:m.jsx(aw,{size:Ge}),group:"Basic",shortcut:"/table",keywords:["grid","rows","columns","spreadsheet"],run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).insertTable({rows:3,cols:3,withHeaderRow:!0}).run()}},{id:"callout",label:"Callout",icon:m.jsx(j3,{size:Ge}),group:"Basic",shortcut:"/callout",keywords:["note","info","warning","tip","aside"],run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).insertCalloutBlock().run()}},{id:"toggle",label:"Toggle",icon:m.jsx(R3,{size:Ge}),group:"Basic",shortcut:"/toggle",keywords:["accordion","collapse","details","faq","expand"],run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).insertToggleBlock().run()}},{id:"image",label:"Image",icon:m.jsx(H3,{size:Ge}),group:"Media",shortcut:"/image",keywords:["photo","picture","upload","media"],run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).insertImageBlock().run()}},{id:"gallery",label:"Gallery",icon:m.jsx(P3,{size:Ge}),group:"Media",shortcut:"/gallery",keywords:["images","photos","grid","album"],run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).insertGalleryBlock().run()}},{id:"video",label:"Video",icon:m.jsx(Kb,{size:Ge}),group:"Media",shortcut:"/video",keywords:["youtube","vimeo","embed","media","mp4"],run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).insertVideoBlock().run()}},{id:"html",label:"HTML",icon:m.jsx(J3,{size:Ge}),group:"Media",shortcut:"/html",keywords:["embed","markup","script","custom","raw"],run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).insertHtmlBlock().run()}},{id:"product",label:"Product",icon:m.jsx(Cw,{size:Ge}),group:"Commerce",shortcut:"/product",keywords:["item","sku","shop","store"],isAvailable:t=>sg(t,"productBlock"),run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).insertProductBlock().run()}},{id:"collection",label:"Collection",icon:m.jsx(Rw,{size:Ge}),group:"Commerce",shortcut:"/collection",keywords:["category","catalog","group"],isAvailable:t=>sg(t,"collectionBlock"),run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).insertCollectionBlock().run()}},{id:"button",label:"Button",icon:m.jsx(_3,{size:Ge}),group:"Media",shortcut:"/button",keywords:["cta","call to action","link"],run:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).insertButtonBlock().run()}}];function Cx(t,e,n){const r=n?t.filter(i=>{var o;return((o=i.isAvailable)==null?void 0:o.call(i,n))??!0}):t,s=e.trim().toLowerCase();return s?r.filter(i=>i.label.toLowerCase().includes(s)||(i.keywords??[]).some(o=>o.toLowerCase().includes(s))):r}function Mx(t){const e=[];for(const n of t){const r=e.find(s=>s.group===n.group);r?r.blocks.push(n):e.push({group:n.group,blocks:[n]})}return e}const XO="_panel_1hllz_5",ZO="_menu_1hllz_25",QO="_shortcut_1hllz_31",eI="_empty_1hllz_37",Zo={panel:XO,menu:ZO,shortcut:QO,empty:eI},ig=300,rs=8,tI=S.forwardRef(function({blocks:e,source:n,getAnchor:r,query:s,onSelect:i,onClose:o,emptyLabel:l="No blocks found"},a){const[c,u]=S.useState(0),d=S.useRef(null),h=S.useRef([]),[f,p]=S.useState(null),g=n==="button",y=S.useMemo(()=>Mx(e),[e]),b=S.useMemo(()=>y.flatMap(x=>x.blocks),[y]);S.useEffect(()=>{u(0)},[s,e.length]);const w=S.useCallback(()=>{const x=d.current,k=r();if(!x||!k)return;const C=x.offsetHeight,O=window.innerHeight-k.bottom<C+rs&&k.top>C+rs?k.top-C-rs:k.bottom+rs,_=Math.min(k.left,window.innerWidth-ig-rs);p({top:O,left:Math.max(rs,_)})},[r]);S.useLayoutEffect(w,[w,e.length]),S.useEffect(()=>(window.addEventListener("scroll",w,!0),window.addEventListener("resize",w),()=>{window.removeEventListener("scroll",w,!0),window.removeEventListener("resize",w)}),[w]),S.useEffect(()=>{var x;(x=h.current[c])==null||x.scrollIntoView({block:"nearest"})},[c]);const v=S.useCallback(x=>{const k=b.length;if(x.key==="ArrowDown")return u(C=>k?(C+1)%k:0),!0;if(x.key==="ArrowUp")return u(C=>k?(C-1+k)%k:0),!0;if(x.key==="Enter"){const C=b[c];return C&&i(C),!0}return x.key==="Escape"?(o(),!0):!1},[b,c,i,o]);return S.useImperativeHandle(a,()=>({onKeyDown:v}),[v]),S.useEffect(()=>{if(!g)return;function x(k){v(k)&&(k.preventDefault(),k.stopPropagation())}return document.addEventListener("keydown",x,!0),()=>document.removeEventListener("keydown",x,!0)},[g,v]),S.useEffect(()=>{function x(k){var C;(C=d.current)!=null&&C.contains(k.target)||o()}return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[o]),Hs.createPortal(m.jsx("div",{ref:d,className:Zo.panel,style:{top:(f==null?void 0:f.top)??0,left:(f==null?void 0:f.left)??0,width:ig,visibility:f?"visible":"hidden"},children:m.jsx(T.Scrollable,{size:"thin",maxHeight:"320px",children:m.jsxs(T.Menu,{className:Zo.menu,children:[b.length===0&&m.jsx("div",{className:Zo.empty,children:l}),y.map(({group:x,blocks:k},C)=>{const M=y.slice(0,C).reduce((_,A)=>_+A.blocks.length,0),O=k.map((_,A)=>{const R=M+A;return m.jsx("div",{ref:D=>{h.current[R]=D},children:m.jsx(T.MenuItem,{label:_.label,leftIcon:_.icon,rightSlot:_.shortcut?m.jsx("span",{className:Zo.shortcut,children:_.shortcut}):void 0,forceHover:R===c,onClick:()=>i(_)})},_.id)});return g?m.jsxs("div",{role:"group","aria-label":x,children:[m.jsx(T.MenuTitle,{children:x}),O]},x):m.jsx(T.MenuGroup,{label:x,children:O},x)})]})})}),document.body)});function nI(t){var e;const{char:n,allowSpaces:r,allowToIncludeChar:s,allowedPrefixes:i,startOfLine:o,$position:l}=t,a=r&&!s,c=aE(n),u=new RegExp(`\\s${c}$`),d=o?"^":"",h=s?"":c,f=a?new RegExp(`${d}${c}.*?(?=\\s${h}|$)`,"gm"):new RegExp(`${d}(?:^)?${c}[^\\s${h}]*`,"gm"),p=((e=l.nodeBefore)==null?void 0:e.isText)&&l.nodeBefore.text;if(!p)return null;const g=l.pos-p.length,y=Array.from(p.matchAll(f)).pop();if(!y||y.input===void 0||y.index===void 0)return null;const b=y.input.slice(Math.max(0,y.index-1),y.index),w=new RegExp(`^[${i==null?void 0:i.join("")}\0]?$`).test(b);if(i!==null&&!w)return null;const v=g+y.index;let x=v+y[0].length;return a&&u.test(p.slice(x-1,x+1))&&(y[0]+=" ",x+=1),v<l.pos&&x>=l.pos?{range:{from:v,to:x},query:y[0].slice(n.length),text:y[0]}:null}function rI(t){return t.docChanged?t.steps.some(e=>{const n=e.slice;if(!(n!=null&&n.content))return!1;const r=n.content.textBetween(0,n.content.size,`
|
|
453
|
+
`);return/\s/.test(r)}):!1}var sI=new ae("suggestion");function iI({pluginKey:t=sI,editor:e,char:n="@",allowSpaces:r=!1,allowToIncludeChar:s=!1,allowedPrefixes:i=[" "],startOfLine:o=!1,decorationTag:l="span",decorationClass:a="suggestion",decorationContent:c="",decorationEmptyClass:u="is-empty",command:d=()=>null,items:h=()=>[],render:f=()=>({}),allow:p=()=>!0,findSuggestionMatch:g=nI,shouldShow:y,shouldResetDismissed:b}){let w;const v=f==null?void 0:f(),x=r&&!s,k=()=>{const A=e.state.selection.$anchor.pos,R=e.view.coordsAtPos(A),{top:D,right:L,bottom:I,left:N}=R;try{return new DOMRect(N,D,L-N,I-D)}catch{return null}},C=(A,R)=>R?()=>{const D=t.getState(e.state),L=D==null?void 0:D.decorationId,I=A.dom.querySelector(`[data-decoration-id="${L}"]`);return(I==null?void 0:I.getBoundingClientRect())||null}:k,M=({match:A,dismissedRange:R,state:D,transaction:L})=>b!=null&&b({editor:e,state:D,range:R,match:A,transaction:L,allowSpaces:x})?!1:x?A.range.from===R.from:A.range.from===R.from&&!rI(L);function O(A,R){var D;try{const I=t.getState(A.state),N=I!=null&&I.decorationId?A.dom.querySelector(`[data-decoration-id="${I.decorationId}"]`):null,H={editor:e,range:(I==null?void 0:I.range)||{from:0,to:0},query:(I==null?void 0:I.query)||null,text:(I==null?void 0:I.text)||null,items:[],command:$=>d({editor:e,range:(I==null?void 0:I.range)||{from:0,to:0},props:$}),decorationNode:N,clientRect:C(A,N)};(D=v==null?void 0:v.onExit)==null||D.call(v,H)}catch{}const L=A.state.tr.setMeta(R,{exit:!0});A.dispatch(L)}const _=new ce({key:t,view(){return{update:async(A,R)=>{var D,L,I,N,H,$,U;const K=(D=this.key)==null?void 0:D.getState(R),de=(L=this.key)==null?void 0:L.getState(A.state),ve=K.active&&de.active&&K.range.from!==de.range.from,Me=!K.active&&de.active,Ct=K.active&&!de.active,Ae=!Me&&!Ct&&K.query!==de.query,Te=Me||ve&&Ae,He=Ae||ve,z=Ct||ve&&Ae;if(!Te&&!He&&!z)return;const V=z&&!Te?K:de,Ut=A.dom.querySelector(`[data-decoration-id="${V.decorationId}"]`);w={editor:e,range:V.range,query:V.query,text:V.text,items:[],command:_t=>d({editor:e,range:V.range,props:_t}),decorationNode:Ut,clientRect:C(A,Ut)},Te&&((I=v==null?void 0:v.onBeforeStart)==null||I.call(v,w)),He&&((N=v==null?void 0:v.onBeforeUpdate)==null||N.call(v,w)),(He||Te)&&(w.items=await h({editor:e,query:V.query})),z&&((H=v==null?void 0:v.onExit)==null||H.call(v,w)),He&&(($=v==null?void 0:v.onUpdate)==null||$.call(v,w)),Te&&((U=v==null?void 0:v.onStart)==null||U.call(v,w))},destroy:()=>{var A;w&&((A=v==null?void 0:v.onExit)==null||A.call(v,w))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1,dismissedRange:null}},apply(A,R,D,L){const{isEditable:I}=e,{composing:N}=e.view,{selection:H}=A,{empty:$,from:U}=H,K={...R},de=A.getMeta(t);if(de&&de.exit)return K.active=!1,K.decorationId=null,K.range={from:0,to:0},K.query=null,K.text=null,K.dismissedRange=R.active?{...R.range}:R.dismissedRange,K;if(K.composing=N,A.docChanged&&K.dismissedRange!==null&&(K.dismissedRange={from:A.mapping.map(K.dismissedRange.from),to:A.mapping.map(K.dismissedRange.to)}),I&&($||e.view.composing)){(U<R.range.from||U>R.range.to)&&!N&&!R.composing&&(K.active=!1);const ve=g({char:n,allowSpaces:r,allowToIncludeChar:s,allowedPrefixes:i,startOfLine:o,$position:H.$from}),Me=`id_${Math.floor(Math.random()*4294967295)}`;ve&&p({editor:e,state:L,range:ve.range,isActive:R.active})&&(!y||y({editor:e,range:ve.range,query:ve.query,text:ve.text,transaction:A}))?(K.dismissedRange!==null&&!M({match:ve,dismissedRange:K.dismissedRange,state:L,transaction:A})&&(K.dismissedRange=null),K.dismissedRange===null?(K.active=!0,K.decorationId=R.decorationId?R.decorationId:Me,K.range=ve.range,K.query=ve.query,K.text=ve.text):K.active=!1):(ve||(K.dismissedRange=null),K.active=!1)}else K.active=!1;return K.active||(K.decorationId=null,K.range={from:0,to:0},K.query=null,K.text=null),K}},props:{handleKeyDown(A,R){var D,L;const{active:I,range:N}=_.getState(A.state);if(!I)return!1;if(R.key==="Escape"||R.key==="Esc"){const $=_.getState(A.state);return(D=v==null?void 0:v.onKeyDown)==null||D.call(v,{view:A,event:R,range:$.range}),O(A,t),!0}return((L=v==null?void 0:v.onKeyDown)==null?void 0:L.call(v,{view:A,event:R,range:N}))||!1},decorations(A){const{active:R,range:D,decorationId:L,query:I}=_.getState(A);if(!R)return null;const N=!(I!=null&&I.length),H=[a];return N&&H.push(u),fe.create(A.doc,[Re.inline(D.from,D.to,{nodeName:l,class:H.join(" "),"data-decoration-id":L,"data-decoration-content":c})])}}});return _}var oI=iI;const Ax=new ae("blockEditorSlashCommand"),Ex=ie.create({name:"blockEditorSlashCommand",addOptions(){return{onStateChange:()=>{},onKeyDown:()=>!1}},addProseMirrorPlugins(){const t=this.options;return[oI({editor:this.editor,pluginKey:Ax,char:"/",startOfLine:!0,allow:({state:e,range:n})=>e.doc.resolve(n.from).parent.type.name!=="codeBlock",items:()=>[],render:()=>({onStart:e=>t.onStateChange({range:e.range,query:e.query,getRect:()=>{var n;return((n=e.clientRect)==null?void 0:n.call(e))??null}}),onUpdate:e=>t.onStateChange({range:e.range,query:e.query,getRect:()=>{var n;return((n=e.clientRect)==null?void 0:n.call(e))??null}}),onKeyDown:({event:e})=>t.onKeyDown(e),onExit:()=>t.onStateChange(null)})})]}});function Fs({commands:t,state:e,node:n}){const{$from:r}=e.selection,s=r.depth>0,o=(s?r.after():r.pos)>=e.doc.content.size?[n,{type:"paragraph"}]:[n];return s&&r.parent.type.name==="paragraph"&&r.parent.content.size===0?t.insertContentAt({from:r.before(),to:r.after()},o):t.insertContent(o)}const lI="_wrapper_1wcz7_5",aI="_normal_1wcz7_10",cI="_wide_1wcz7_14",uI="_full_1wcz7_23",dI="_selected_1wcz7_29",hI="_figure_1wcz7_29",fI="_placeholder_1wcz7_30",pI="_fileInput_1wcz7_34",mI="_image_1wcz7_45",gI="_toolbar_1wcz7_58",yI="_toolbarDivider_1wcz7_79",bI="_altToggle_1wcz7_91",wI="_altToggleSet_1wcz7_120",xI="_caption_1wcz7_130",vI="_captionInput_1wcz7_138",kI="_captionAlt_1wcz7_167",SI="_altBadge_1wcz7_174",CI="_altInput_1wcz7_186",MI="_overlay_1wcz7_200",AI="_dragOver_1wcz7_224",EI="_placeholderBody_1wcz7_229",TI="_placeholderIcon_1wcz7_245",_I="_placeholderText_1wcz7_249",NI="_urlInput_1wcz7_254",OI="_placeholderDelete_1wcz7_271",II="_error_1wcz7_284",me={wrapper:lI,normal:aI,wide:cI,full:uI,selected:dI,figure:hI,placeholder:fI,fileInput:pI,image:mI,toolbar:gI,toolbarDivider:yI,altToggle:bI,altToggleSet:wI,caption:xI,captionInput:vI,captionAlt:kI,altBadge:SI,altInput:CI,overlay:MI,dragOver:AI,placeholderBody:EI,placeholderIcon:TI,placeholderText:_I,urlInput:NI,placeholderDelete:OI,error:II},DI=[{value:"normal",label:"Regular width",icon:Xh},{value:"wide",label:"Wide",icon:Qh},{value:"full",label:"Full width",icon:ef}];function RI({node:t,updateAttributes:e,deleteNode:n,editor:r,selected:s,extension:i}){const{src:o,alt:l,caption:a,layout:c}=t.attrs,u=i.options,d=S.useRef(null),h=S.useRef(null),[f,p]=S.useState(!1),[g,y]=S.useState(null),[b,w]=S.useState(!1),[v,x]=S.useState(!1),k=r.isEditable;S.useEffect(()=>{var A;v&&((A=h.current)==null||A.focus())},[v]);async function C(A){if(!u.onUpload){y("Uploading is not configured");return}y(null),p(!0);try{const R=await u.onUpload(A);e({src:R})}catch(R){y(R instanceof Error?R.message:"Upload failed")}finally{p(!1)}}function M(){var A;y(null),(A=d.current)==null||A.click()}function O(A){if(!v)return;const R=A.relatedTarget;R&&A.currentTarget.contains(R)||x(!1)}const _=[me.wrapper,me[c],s&&me.selected].filter(Boolean).join(" ");return m.jsxs(wr,{className:_,"data-drag-handle":!0,children:[m.jsx("input",{ref:d,type:"file",accept:u.accept,className:me.fileInput,onChange:A=>{var D;const R=(D=A.target.files)==null?void 0:D[0];A.target.value="",R&&C(R)}}),o?m.jsxs("figure",{className:me.figure,contentEditable:!1,onBlur:O,children:[m.jsx("img",{src:o,alt:l??"",className:me.image}),k&&m.jsxs("div",{className:me.toolbar,children:[DI.map(({value:A,label:R,icon:D})=>m.jsx(T.Tooltip,{content:R,children:m.jsx(T.IconButton,{"aria-label":R,variant:c===A?"neutral":"transparent",size:"xsmall",icon:m.jsx(D,{size:14}),onClick:()=>e({layout:A})})},A)),m.jsx("span",{className:me.toolbarDivider}),m.jsx(T.Tooltip,{content:l?`Alt text: ${l}`:"Describe this image (alt text)",children:m.jsx("button",{type:"button","aria-label":"Edit alt text","aria-pressed":v,className:[me.altToggle,l&&me.altToggleSet].filter(Boolean).join(" "),onClick:()=>x(A=>!A),children:"ALT"})}),m.jsx("span",{className:me.toolbarDivider}),m.jsx(T.Tooltip,{content:"Replace",children:m.jsx(T.IconButton,{"aria-label":"Replace image",variant:"transparent",size:"xsmall",icon:m.jsx(Zh,{size:14}),onClick:M})}),m.jsx(T.Tooltip,{content:"Delete",children:m.jsx(T.IconButton,{"aria-label":"Delete image",variant:"transparent",size:"xsmall",icon:m.jsx(St,{size:14}),onClick:n})})]}),(k||a)&&m.jsxs("figcaption",{className:[me.caption,v&&me.captionAlt].filter(Boolean).join(" "),children:[!k&&a,k&&v&&m.jsxs(m.Fragment,{children:[m.jsx("span",{className:me.altBadge,"aria-hidden":"true",children:"ALT"}),m.jsx("input",{ref:h,type:"text",className:[me.captionInput,me.altInput].join(" "),value:l??"","aria-label":"Alt text",placeholder:"Describe this image for screen readers",onChange:A=>e({alt:A.target.value}),onKeyDown:A=>{A.key!=="Enter"&&A.key!=="Escape"||(A.preventDefault(),x(!1))}})]}),k&&!v&&m.jsx("input",{type:"text",className:me.captionInput,value:a??"","aria-label":"Caption",placeholder:"Type caption for image (optional)",onChange:A=>e({caption:A.target.value})})]}),f&&m.jsx("div",{className:me.overlay,children:m.jsx(T.Spinner,{size:"md"})})]}):m.jsxs("div",{className:[me.placeholder,b&&me.dragOver].filter(Boolean).join(" "),contentEditable:!1,onDragOver:A=>{k&&(A.preventDefault(),w(!0))},onDragLeave:()=>w(!1),onDrop:A=>{var D;if(!k)return;A.preventDefault(),w(!1);const R=(D=A.dataTransfer.files)==null?void 0:D[0];R&&C(R)},children:[f?m.jsxs("div",{className:me.placeholderBody,children:[m.jsx(T.Spinner,{size:"md"}),m.jsx("span",{className:me.placeholderText,children:"Uploading…"})]}):m.jsxs(m.Fragment,{children:[m.jsxs("button",{type:"button",className:me.placeholderBody,onClick:M,disabled:!k,children:[m.jsx(kd,{size:22,className:me.placeholderIcon}),m.jsx("span",{className:me.placeholderText,children:u.onUpload?"Click to select an image, or drag one here":"Paste an image URL below"})]}),m.jsx("input",{type:"url",className:me.urlInput,placeholder:"…or paste an image URL",onKeyDown:A=>{if(A.key!=="Enter")return;A.preventDefault();const R=A.target.value.trim();R&&e({src:R})}})]}),g&&m.jsxs("p",{className:me.error,children:[m.jsx(Yh,{size:14}),g]}),k&&m.jsx("div",{className:me.placeholderDelete,children:m.jsx(T.IconButton,{"aria-label":"Remove block",variant:"transparent",size:"xsmall",icon:m.jsx(St,{size:14}),onClick:n})})]})]})}const Tx="image",_x=ke.create({name:Tx,group:"block",atom:!0,draggable:!0,selectable:!0,addOptions(){return{onUpload:void 0,accept:"image/*",HTMLAttributes:{}}},addAttributes(){return{src:{default:null},alt:{default:null},caption:{default:null},layout:{default:"normal",parseHTML:t=>t.getAttribute("data-layout")??"normal",renderHTML:t=>({"data-layout":t.layout})}}},parseHTML(){return[{tag:"figure[data-image-block]"},{tag:"img[src]",getAttrs:t=>({src:t.getAttribute("src"),alt:t.getAttribute("alt")})}]},renderHTML({HTMLAttributes:t,node:e}){const{src:n,alt:r,caption:s}=e.attrs;return["figure",le({"data-image-block":""},this.options.HTMLAttributes,{"data-layout":t["data-layout"]}),["img",{src:n,alt:r??""}],...s?[["figcaption",{},s]]:[]]},addNodeView(){return xr(RI)},addCommands(){return{insertImageBlock:(t={})=>({commands:e,state:n})=>Fs({commands:e,state:n,node:{type:this.name,attrs:{layout:"normal",...t}}})}}}),LI="_wrapper_1mu6t_3",jI="_information_1mu6t_16",PI="_success_1mu6t_21",BI="_warning_1mu6t_26",HI="_error_1mu6t_31",zI="_neutral_1mu6t_36",$I="_selected_1mu6t_41",VI="_marker_1mu6t_46",FI="_emojiButton_1mu6t_54",UI="_accentLine_1mu6t_74",WI="_emojiMenu_1mu6t_84",KI="_emojiGrid_1mu6t_88",qI="_emojiChoice_1mu6t_94",JI="_emojiChoiceActive_1mu6t_115",GI="_body_1mu6t_121",YI="_toolbar_1mu6t_131",XI="_toneButton_1mu6t_151",ZI="_toneSwatch_1mu6t_168",Be={wrapper:LI,information:jI,success:PI,warning:BI,error:HI,neutral:zI,selected:$I,marker:VI,emojiButton:FI,accentLine:UI,emojiMenu:WI,emojiGrid:KI,emojiChoice:qI,emojiChoiceActive:JI,body:GI,toolbar:YI,toneButton:XI,toneSwatch:ZI},QI=["💡","📌","⚠️","✅","❌","🔥","📣","🎯","📝","🚀","❓","⭐"],eD=[{value:"information",label:"Information"},{value:"success",label:"Success"},{value:"warning",label:"Warning"},{value:"error",label:"Error"},{value:"neutral",label:"Neutral"}];function tD({node:t,updateAttributes:e,deleteNode:n,editor:r,selected:s}){const{emoji:i,tone:o}=t.attrs,[l,a]=S.useState(!1),[c,u]=S.useState(!1),d=r.isEditable,h=[Be.wrapper,Be[o],s&&Be.selected].filter(Boolean).join(" ");return m.jsxs(wr,{className:h,children:[m.jsx("div",{className:Be.marker,contentEditable:!1,children:d?m.jsx(T.Popover,{open:l,onOpenChange:a,placement:"bottom-start",bare:!0,trigger:m.jsx("button",{type:"button",className:Be.emojiButton,"aria-label":"Change emoji",children:i||m.jsx("span",{className:Be.accentLine})}),children:m.jsx(T.Menu,{className:Be.emojiMenu,children:m.jsxs("div",{className:Be.emojiGrid,children:[m.jsx("button",{type:"button",className:[Be.emojiChoice,!i&&Be.emojiChoiceActive].filter(Boolean).join(" "),"aria-label":"No emoji",onClick:()=>{e({emoji:null}),a(!1)},children:m.jsx(tO,{size:16})}),QI.map(f=>m.jsx("button",{type:"button",className:[Be.emojiChoice,i===f&&Be.emojiChoiceActive].filter(Boolean).join(" "),onClick:()=>{e({emoji:f}),a(!1)},children:f},f))]})})}):i||m.jsx("span",{className:Be.accentLine})}),m.jsx(Ly,{className:Be.body}),d&&m.jsxs("div",{className:Be.toolbar,contentEditable:!1,children:[m.jsx(T.Popover,{open:c,onOpenChange:u,placement:"bottom-end",bare:!0,trigger:m.jsx("button",{type:"button",className:Be.toneButton,"aria-label":"Change colour",children:m.jsx("span",{className:Be.toneSwatch})}),children:m.jsx(T.Menu,{children:eD.map(({value:f,label:p})=>m.jsx(T.MenuItemRadio,{label:p,leftIcon:m.jsx("span",{className:[Be.toneSwatch,Be[f]].join(" ")}),checked:o===f,onClick:()=>{e({tone:f}),u(!1)}},f))})}),m.jsx(T.Tooltip,{content:"Delete",children:m.jsx(T.IconButton,{"aria-label":"Delete callout",variant:"transparent",size:"xsmall",icon:m.jsx(St,{size:14}),onClick:n})})]})]})}const Nx="callout",Ox=ke.create({name:Nx,group:"block",content:"block+",defining:!0,addAttributes(){return{emoji:{default:"💡"},tone:{default:"information",parseHTML:t=>t.getAttribute("data-tone")??"information",renderHTML:t=>({"data-tone":t.tone})}}},parseHTML(){return[{tag:"div[data-callout-block]"}]},renderHTML({HTMLAttributes:t,node:e}){const{emoji:n}=e.attrs;return["div",le({"data-callout-block":""},{"data-tone":t["data-tone"]}),...n?[["span",{"data-callout-emoji":""},n]]:[],["div",{"data-callout-body":""},0]]},addNodeView(){return xr(tD)},addCommands(){return{insertCalloutBlock:(t={})=>({commands:e})=>e.insertContent({type:this.name,attrs:{emoji:"💡",tone:"information",...t},content:[{type:"paragraph"}]})}}}),nD="_wrapper_1bsti_1",rD="_buttonRow_1bsti_6",sD="_selected_1bsti_14",iD="_outline_1bsti_21",oD="_settings_1bsti_31",lD="_fields_1bsti_53",aD="_field_1bsti_53",cD="_fieldLabel_1bsti_65",uD="_input_1bsti_71",dD="_controls_1bsti_89",hD="_styleToggle_1bsti_98",fD="_styleOption_1bsti_105",pD="_styleOptionActive_1bsti_117",mD="_alignGroup_1bsti_122",ze={wrapper:nD,buttonRow:rD,"align-left":"_align-left_1bsti_10","align-center":"_align-center_1bsti_11","align-right":"_align-right_1bsti_12",selected:sD,outline:iD,settings:oD,fields:lD,field:aD,fieldLabel:cD,input:uD,controls:dD,styleToggle:hD,styleOption:fD,styleOptionActive:pD,alignGroup:mD},gD=[{value:"left",label:"Align left",icon:A3},{value:"center",label:"Align centre",icon:C3},{value:"right",label:"Align right",icon:M3}],yD=[{value:"fill",label:"Fill"},{value:"outline",label:"Outline"}];function bD({node:t,updateAttributes:e,deleteNode:n,editor:r,selected:s}){const{text:i,href:o,style:l,align:a}=t.attrs,c=r.isEditable,u=[ze.wrapper,ze[`align-${a}`],s&&ze.selected].filter(Boolean).join(" ");return m.jsxs(wr,{className:u,"data-drag-handle":!0,children:[m.jsx("div",{className:ze.buttonRow,contentEditable:!1,children:m.jsx(T.Button,{variant:l==="fill"?"inverted":"transparent",className:l==="outline"?ze.outline:void 0,onClick:d=>d.preventDefault(),children:i||"Button"})}),c&&m.jsxs("div",{className:ze.settings,contentEditable:!1,children:[m.jsxs("div",{className:ze.fields,children:[m.jsxs("label",{className:ze.field,children:[m.jsx("span",{className:ze.fieldLabel,children:"Button text"}),m.jsx("input",{type:"text",className:ze.input,value:i??"",placeholder:"Add button text",onChange:d=>e({text:d.target.value})})]}),m.jsxs("label",{className:ze.field,children:[m.jsx("span",{className:ze.fieldLabel,children:"Button URL"}),m.jsx("input",{type:"url",className:ze.input,value:o??"",placeholder:"https://",onChange:d=>e({href:d.target.value||null})})]})]}),m.jsxs("div",{className:ze.controls,children:[m.jsx("div",{className:ze.styleToggle,children:yD.map(({value:d,label:h})=>m.jsx("button",{type:"button",className:[ze.styleOption,l===d&&ze.styleOptionActive].filter(Boolean).join(" "),onClick:()=>e({style:d}),children:h},d))}),m.jsx("div",{className:ze.alignGroup,children:gD.map(({value:d,label:h,icon:f})=>m.jsx(T.Tooltip,{content:h,children:m.jsx(T.IconButton,{"aria-label":h,variant:a===d?"neutral":"transparent",size:"xsmall",icon:m.jsx(f,{size:14}),onClick:()=>e({align:d})})},d))}),m.jsx(T.Tooltip,{content:"Delete",children:m.jsx(T.IconButton,{"aria-label":"Delete button block",variant:"transparent",size:"xsmall",icon:m.jsx(St,{size:14}),onClick:n})})]})]})]})}const Ix="buttonBlock",Dx=ke.create({name:Ix,group:"block",atom:!0,draggable:!0,selectable:!0,addAttributes(){return{text:{default:"Button"},href:{default:null},style:{default:"fill",parseHTML:t=>t.getAttribute("data-style")??"fill",renderHTML:t=>({"data-style":t.style})},align:{default:"center",parseHTML:t=>t.getAttribute("data-align")??"center",renderHTML:t=>({"data-align":t.align})}}},parseHTML(){return[{tag:"div[data-button-block]"}]},renderHTML({HTMLAttributes:t,node:e}){const{text:n,href:r}=e.attrs;return["div",le({"data-button-block":""},{"data-style":t["data-style"],"data-align":t["data-align"]}),["a",{href:r??"#"},n??""]]},addNodeView(){return xr(bD)},addCommands(){return{insertButtonBlock:(t={})=>({commands:e,state:n})=>Fs({commands:e,state:n,node:{type:this.name,attrs:{text:"Button",style:"fill",align:"center",...t}}})}}}),wD="_wrapper_1g9li_1",xD="_selected_1g9li_6",vD="_editor_1g9li_6",kD="_previewShell_1g9li_7",SD="_editorHeader_1g9li_19",CD="_label_1g9li_27",MD="_code_1g9li_36",AD="_codeTextarea_1g9li_42",ED="_preview_1g9li_7",TD="_empty_1g9li_71",_D="_previewToolbar_1g9li_79",Wt={wrapper:wD,selected:xD,editor:vD,previewShell:kD,editorHeader:SD,label:CD,code:MD,codeTextarea:AD,preview:ED,empty:TD,previewToolbar:_D};function ND({node:t,updateAttributes:e,deleteNode:n,editor:r,selected:s}){const i=t.attrs.html??"",o=r.isEditable,[l,a]=S.useState(!i),c=[Wt.wrapper,s&&Wt.selected].filter(Boolean).join(" ");return m.jsx(wr,{className:c,"data-drag-handle":!0,children:m.jsx("div",{contentEditable:!1,children:l&&o?m.jsxs("div",{className:Wt.editor,children:[m.jsxs("div",{className:Wt.editorHeader,children:[m.jsx("span",{className:Wt.label,children:"HTML"}),m.jsx(T.Tooltip,{content:"Preview",children:m.jsx(T.IconButton,{"aria-label":"Preview HTML",variant:"transparent",size:"xsmall",icon:m.jsx(F3,{size:14}),onClick:()=>a(!1)})}),m.jsx(T.Tooltip,{content:"Delete",children:m.jsx(T.IconButton,{"aria-label":"Delete HTML block",variant:"transparent",size:"xsmall",icon:m.jsx(St,{size:14}),onClick:n})})]}),m.jsx(Vb,{value:i,onValueChange:u=>e({html:u}),highlight:u=>ma.highlight(u,ma.languages.markup,"markup"),padding:12,placeholder:"<p>Paste or write HTML…</p>",className:Wt.code,textareaClassName:Wt.codeTextarea,style:{fontFamily:"var(--font-family-code)",fontSize:"var(--font-size-small)",lineHeight:1.6}})]}):m.jsxs("div",{className:Wt.previewShell,children:[i?m.jsx("div",{className:Wt.preview,dangerouslySetInnerHTML:{__html:i}}):m.jsx("p",{className:Wt.empty,children:"Empty HTML block"}),o&&m.jsxs("div",{className:Wt.previewToolbar,children:[m.jsx(T.Tooltip,{content:"Edit HTML",children:m.jsx(T.IconButton,{"aria-label":"Edit HTML",variant:"transparent",size:"xsmall",icon:m.jsx(nc,{size:14}),onClick:()=>a(!0)})}),m.jsx(T.Tooltip,{content:"Delete",children:m.jsx(T.IconButton,{"aria-label":"Delete HTML block",variant:"transparent",size:"xsmall",icon:m.jsx(St,{size:14}),onClick:n})})]})]})})})}const Rx="htmlBlock",Lx=ke.create({name:Rx,group:"block",atom:!0,draggable:!0,selectable:!0,addAttributes(){return{html:{default:""}}},parseHTML(){return[{tag:"div[data-html-block]",getAttrs:t=>({html:t.innerHTML})}]},renderHTML({node:t}){return["div",le({"data-html-block":""}),t.attrs.html??""]},addNodeView(){return xr(ND)},addCommands(){return{insertHtmlBlock:(t={})=>({commands:e,state:n})=>Fs({commands:e,state:n,node:{type:this.name,attrs:{html:"",...t}}})}}}),OD="_wrapper_n5xg6_3",ID="_normal_n5xg6_8",DD="_wide_n5xg6_12",RD="_full_n5xg6_21",LD="_selected_n5xg6_27",jD="_figure_n5xg6_27",PD="_placeholder_n5xg6_28",BD="_frame_n5xg6_39",HD="_media_n5xg6_52",zD="_toolbar_n5xg6_62",$D="_toolbarDivider_n5xg6_82",VD="_caption_n5xg6_90",FD="_captionInput_n5xg6_98",UD="_placeholderIcon_n5xg6_134",WD="_placeholderText_n5xg6_138",KD="_urlInput_n5xg6_144",qD="_placeholderDelete_n5xg6_162",tt={wrapper:OD,normal:ID,wide:DD,full:RD,selected:LD,figure:jD,placeholder:PD,frame:BD,media:HD,toolbar:zD,toolbarDivider:$D,caption:VD,captionInput:FD,placeholderIcon:UD,placeholderText:WD,urlInput:KD,placeholderDelete:qD},JD=[{value:"normal",label:"Regular width",icon:Xh},{value:"wide",label:"Wide",icon:Qh},{value:"full",label:"Full width",icon:ef}];function GD({node:t,updateAttributes:e,deleteNode:n,editor:r,selected:s}){const{src:i,caption:o,layout:l}=t.attrs,[a,c]=S.useState(""),u=r.isEditable,d=tf(i??""),h=[tt.wrapper,tt[l],s&&tt.selected].filter(Boolean).join(" ");return m.jsx(wr,{className:h,"data-drag-handle":!0,children:d?m.jsxs("figure",{className:tt.figure,contentEditable:!1,children:[m.jsx("div",{className:tt.frame,children:d.kind==="iframe"?m.jsx("iframe",{src:d.url,title:o??"Video",className:tt.media,frameBorder:"0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0}):m.jsx("video",{src:d.url,className:tt.media,controls:!0})}),u&&m.jsxs("div",{className:tt.toolbar,children:[JD.map(({value:f,label:p,icon:g})=>m.jsx(T.Tooltip,{content:p,children:m.jsx(T.IconButton,{"aria-label":p,variant:l===f?"neutral":"transparent",size:"xsmall",icon:m.jsx(g,{size:14}),onClick:()=>e({layout:f})})},f)),m.jsx("span",{className:tt.toolbarDivider}),m.jsx(T.Tooltip,{content:"Replace",children:m.jsx(T.IconButton,{"aria-label":"Replace video",variant:"transparent",size:"xsmall",icon:m.jsx(Zh,{size:14}),onClick:()=>{c(i??""),e({src:null})}})}),m.jsx(T.Tooltip,{content:"Delete",children:m.jsx(T.IconButton,{"aria-label":"Delete video",variant:"transparent",size:"xsmall",icon:m.jsx(St,{size:14}),onClick:n})})]}),(u||o)&&m.jsx("figcaption",{className:tt.caption,children:u?m.jsx("input",{type:"text",className:tt.captionInput,value:o??"",placeholder:"Type caption for video (optional)",onChange:f=>e({caption:f.target.value})}):o})]}):m.jsxs("div",{className:tt.placeholder,contentEditable:!1,children:[m.jsx(Kb,{size:22,className:tt.placeholderIcon}),m.jsx("p",{className:tt.placeholderText,children:"Paste a YouTube, Vimeo or direct video URL"}),m.jsx("input",{type:"url",className:tt.urlInput,value:a,placeholder:"https://youtube.com/watch?v=…",autoFocus:!0,onChange:f=>c(f.target.value),onKeyDown:f=>{if(f.key!=="Enter")return;f.preventDefault();const p=a.trim();p&&e({src:p})}}),u&&m.jsx("div",{className:tt.placeholderDelete,children:m.jsx(T.IconButton,{"aria-label":"Remove block",variant:"transparent",size:"xsmall",icon:m.jsx(St,{size:14}),onClick:n})})]})})}const jx="videoBlock";function tf(t){const e=t.trim();if(!e)return null;const n=e.match(/(?:youtube\.com\/(?:watch\?(?:.*&)?v=|embed\/|shorts\/)|youtu\.be\/)([\w-]{11})/i);if(n)return{kind:"iframe",url:`https://www.youtube.com/embed/${n[1]}`};const r=e.match(/vimeo\.com\/(?:video\/)?(\d+)/i);return r?{kind:"iframe",url:`https://player.vimeo.com/video/${r[1]}`}:{kind:"file",url:e}}const Px=ke.create({name:jx,group:"block",atom:!0,draggable:!0,selectable:!0,addAttributes(){return{src:{default:null},caption:{default:null},layout:{default:"normal",parseHTML:t=>t.getAttribute("data-layout")??"normal",renderHTML:t=>({"data-layout":t.layout})}}},parseHTML(){return[{tag:"figure[data-video-block]"}]},renderHTML({HTMLAttributes:t,node:e}){const{src:n,caption:r}=e.attrs,s=tf(n??"");return["figure",le({"data-video-block":""},{"data-layout":t["data-layout"]}),(s==null?void 0:s.kind)==="file"?["video",{src:s.url,controls:"true"}]:["iframe",{src:(s==null?void 0:s.url)??"",frameborder:"0",allowfullscreen:"true"}],...r?[["figcaption",{},r]]:[]]},addNodeView(){return xr(GD)},addCommands(){return{insertVideoBlock:(t={})=>({commands:e,state:n})=>Fs({commands:e,state:n,node:{type:this.name,attrs:{layout:"normal",...t}}})}}}),YD="_wrapper_1fr97_3",XD="_normal_1fr97_8",ZD="_wide_1fr97_12",QD="_full_1fr97_21",eR="_selected_1fr97_27",tR="_figure_1fr97_27",nR="_fileInput_1fr97_32",rR="_grid_1fr97_42",sR="_gridDragOver_1fr97_50",iR="_cell_1fr97_56",oR="_image_1fr97_64",lR="_removeImage_1fr97_71",aR="_cellEditing_1fr97_97",cR="_altBadgeButton_1fr97_105",uR="_altBadgeButtonSet_1fr97_136",dR="_placeholder_1fr97_142",hR="_dragOver_1fr97_153",fR="_placeholderBody_1fr97_158",pR="_placeholderIcon_1fr97_173",mR="_placeholderText_1fr97_177",gR="_toolbar_1fr97_183",yR="_toolbarDivider_1fr97_203",bR="_caption_1fr97_211",wR="_captionInput_1fr97_218",xR="_captionAlt_1fr97_244",vR="_altBadge_1fr97_105",kR="_altInput_1fr97_263",SR="_error_1fr97_276",ge={wrapper:YD,normal:XD,wide:ZD,full:QD,selected:eR,figure:tR,fileInput:nR,grid:rR,gridDragOver:sR,cell:iR,image:oR,removeImage:lR,cellEditing:aR,altBadgeButton:cR,altBadgeButtonSet:uR,placeholder:dR,dragOver:hR,placeholderBody:fR,placeholderIcon:pR,placeholderText:mR,toolbar:gR,toolbarDivider:yR,caption:bR,captionInput:wR,captionAlt:xR,altBadge:vR,altInput:kR,error:SR},CR=[{value:"normal",label:"Regular width",icon:Xh},{value:"wide",label:"Wide",icon:Qh},{value:"full",label:"Full width",icon:ef}],MR=3;function AR({node:t,updateAttributes:e,deleteNode:n,editor:r,selected:s,extension:i}){const o=t.attrs.images??[],{caption:l,layout:a}=t.attrs,c=i.options,u=S.useRef(null),d=S.useRef(null),[h,f]=S.useState(!1),[p,g]=S.useState(null),[y,b]=S.useState(!1),[w,v]=S.useState(null),x=r.isEditable,k=w!==null&&w<o.length?w:null;S.useEffect(()=>{var N;k!==null&&((N=d.current)==null||N.focus())},[k]);async function C(N){if(!c.onUpload){g("Uploading is not configured");return}g(null),f(!0);try{const H=[];for(const $ of N){const U=await c.onUpload($);H.push({src:U})}e({images:[...o,...H]})}catch(H){g(H instanceof Error?H.message:"Upload failed")}finally{f(!1)}}function M(N){return Array.from(N.dataTransfer.types??[]).includes("Files")}function O(N){!x||!M(N)||(N.preventDefault(),b(!0))}function _(){b(!1)}function A(N){if(!x||!M(N))return;N.preventDefault(),b(!1);const H=Array.from(N.dataTransfer.files??[]).filter($=>$.type.startsWith("image/"));H.length&&C(H)}function R(N){e({images:o.filter((H,$)=>$!==N)}),v(null)}function D(N,H){e({images:o.map(($,U)=>U===N?{...$,alt:H}:$)})}function L(N){if(k===null)return;const H=N.relatedTarget;H&&N.currentTarget.contains(H)||v(null)}const I=[ge.wrapper,ge[a],s&&ge.selected].filter(Boolean).join(" ");return m.jsxs(wr,{className:I,"data-drag-handle":!0,children:[m.jsx("input",{ref:u,type:"file",accept:c.accept,multiple:!0,className:ge.fileInput,onChange:N=>{const H=Array.from(N.target.files??[]);N.target.value="",H.length&&C(H)}}),m.jsxs("figure",{className:ge.figure,contentEditable:!1,onBlur:L,onDragOver:O,onDragLeave:_,onDrop:A,children:[o.length>0?m.jsx("div",{className:[ge.grid,y&&ge.gridDragOver].filter(Boolean).join(" "),style:{"--gallery-columns":Math.min(MR,o.length)},children:o.map((N,H)=>m.jsxs("div",{className:[ge.cell,k===H&&ge.cellEditing].filter(Boolean).join(" "),children:[m.jsx("img",{src:N.src,alt:N.alt??"",className:ge.image}),x&&m.jsxs(m.Fragment,{children:[m.jsx("button",{type:"button",className:[ge.altBadgeButton,N.alt&&ge.altBadgeButtonSet].filter(Boolean).join(" "),"aria-label":`Edit alt text for image ${H+1}`,"aria-pressed":k===H,onClick:()=>v($=>$===H?null:H),children:"ALT"}),m.jsx("button",{type:"button",className:ge.removeImage,"aria-label":"Remove image",onClick:()=>R(H),children:m.jsx(x3,{size:13})})]})]},`${N.src}-${H}`))}):m.jsx("div",{className:[ge.placeholder,y&&ge.dragOver].filter(Boolean).join(" "),children:m.jsxs("button",{type:"button",className:ge.placeholderBody,onClick:()=>{var N;return(N=u.current)==null?void 0:N.click()},disabled:!x||h,children:[h?m.jsx(T.Spinner,{size:"md"}):m.jsx(kd,{size:22,className:ge.placeholderIcon}),m.jsx("span",{className:ge.placeholderText,children:h?"Uploading…":"Click to select images, or drag them here"})]})}),x&&m.jsxs("div",{className:ge.toolbar,children:[o.length>0&&m.jsxs(m.Fragment,{children:[m.jsx(T.Tooltip,{content:"Add images",children:m.jsx(T.IconButton,{"aria-label":"Add images",variant:"transparent",size:"xsmall",icon:m.jsx(kd,{size:14}),loading:h,onClick:()=>{var N;return(N=u.current)==null?void 0:N.click()}})}),m.jsx("span",{className:ge.toolbarDivider})]}),CR.map(({value:N,label:H,icon:$})=>m.jsx(T.Tooltip,{content:H,children:m.jsx(T.IconButton,{"aria-label":H,variant:a===N?"neutral":"transparent",size:"xsmall",icon:m.jsx($,{size:14}),onClick:()=>e({layout:N})})},N)),m.jsx("span",{className:ge.toolbarDivider}),m.jsx(T.Tooltip,{content:"Delete",children:m.jsx(T.IconButton,{"aria-label":"Delete gallery",variant:"transparent",size:"xsmall",icon:m.jsx(St,{size:14}),onClick:n})})]}),p&&m.jsxs("p",{className:ge.error,children:[m.jsx(Yh,{size:14}),p]}),(x||l)&&o.length>0&&m.jsxs("figcaption",{className:[ge.caption,k!==null&&ge.captionAlt].filter(Boolean).join(" "),children:[!x&&l,x&&k!==null&&m.jsxs(m.Fragment,{children:[m.jsxs("span",{className:ge.altBadge,"aria-hidden":"true",children:["ALT ",k+1]}),m.jsx("input",{ref:d,type:"text",className:[ge.captionInput,ge.altInput].join(" "),value:o[k].alt??"","aria-label":`Alt text for image ${k+1}`,placeholder:"Describe this image for screen readers",onChange:N=>D(k,N.target.value),onKeyDown:N=>{N.key!=="Enter"&&N.key!=="Escape"||(N.preventDefault(),v(null))}})]}),x&&k===null&&m.jsx("input",{type:"text",className:ge.captionInput,value:l??"","aria-label":"Caption",placeholder:"Type caption for gallery (optional)",onChange:N=>e({caption:N.target.value})})]})]})]})}const Bx="gallery",Hx=ke.create({name:Bx,group:"block",atom:!0,draggable:!0,selectable:!0,addOptions(){return{onUpload:void 0,accept:"image/*"}},addAttributes(){return{images:{default:[],parseHTML:t=>{const e=t.getAttribute("data-images");if(!e)return[];try{return JSON.parse(e)}catch{return[]}},renderHTML:t=>({"data-images":JSON.stringify(t.images??[])})},caption:{default:null},layout:{default:"wide",parseHTML:t=>t.getAttribute("data-layout")??"wide",renderHTML:t=>({"data-layout":t.layout})}}},parseHTML(){return[{tag:"figure[data-gallery-block]"}]},renderHTML({HTMLAttributes:t,node:e}){const n=e.attrs.images??[],{caption:r}=e.attrs;return["figure",le({"data-gallery-block":""},t),["div",{"data-gallery-grid":""},...n.map(s=>["img",{src:s.src,alt:s.alt??""}])],...r?[["figcaption",{},r]]:[]]},addNodeView(){return xr(AR)},addCommands(){return{insertGalleryBlock:(t={})=>({commands:e,state:n})=>Fs({commands:e,state:n,node:{type:this.name,attrs:{images:[],layout:"wide",...t}}})}}}),ER="_wrapper_1cd7f_1",TR="_selected_1cd7f_9",_R="_header_1cd7f_14",NR="_chevron_1cd7f_22",OR="_chevronOpen_1cd7f_43",IR="_summary_1cd7f_47",DR="_summaryInput_1cd7f_48",RR="_actions_1cd7f_68",LR="_defaultState_1cd7f_83",jR="_defaultStateOn_1cd7f_95",PR="_body_1cd7f_101",BR="_bodyCollapsed_1cd7f_105",It={wrapper:ER,selected:TR,header:_R,chevron:NR,chevronOpen:OR,summary:IR,summaryInput:DR,actions:RR,defaultState:LR,defaultStateOn:jR,body:PR,bodyCollapsed:BR};function HR({node:t,updateAttributes:e,deleteNode:n,editor:r,selected:s}){const{summary:i,open:o}=t.attrs,l=r.isEditable,[a,c]=S.useState(!1),u=!a,d=[It.wrapper,s&&It.selected].filter(Boolean).join(" ");return m.jsxs(wr,{className:d,children:[m.jsxs("div",{className:It.header,contentEditable:!1,children:[m.jsx("button",{type:"button",className:[It.chevron,u&&It.chevronOpen].filter(Boolean).join(" "),"aria-label":u?"Collapse":"Expand","aria-expanded":u,onClick:()=>c(h=>!h),children:m.jsx(G3,{size:16})}),l?m.jsx("input",{type:"text",className:It.summaryInput,value:i??"",placeholder:"Toggle heading",onChange:h=>e({summary:h.target.value})}):m.jsx("span",{className:It.summary,children:i}),l&&m.jsxs("div",{className:It.actions,children:[m.jsx(T.Tooltip,{content:o?"Open by default":"Closed by default",children:m.jsx("button",{type:"button",className:[It.defaultState,o&&It.defaultStateOn].filter(Boolean).join(" "),onClick:()=>e({open:!o}),children:o?"Open by default":"Closed by default"})}),m.jsx(T.Tooltip,{content:"Delete",children:m.jsx(T.IconButton,{"aria-label":"Delete toggle",variant:"transparent",size:"xsmall",icon:m.jsx(St,{size:14}),onClick:n})})]})]}),m.jsx(Ly,{className:[It.body,!u&&It.bodyCollapsed].filter(Boolean).join(" ")})]})}const zx="toggleBlock",$x=ke.create({name:zx,group:"block",content:"block+",defining:!0,addAttributes(){return{summary:{default:""},open:{default:!1,parseHTML:t=>t.hasAttribute("open"),renderHTML:t=>t.open?{open:"true"}:{}}}},parseHTML(){return[{tag:"details[data-toggle-block]"}]},renderHTML({HTMLAttributes:t,node:e}){return["details",le({"data-toggle-block":""},t),["summary",{},e.attrs.summary??""],["div",{"data-toggle-body":""},0]]},addNodeView(){return xr(HR)},addCommands(){return{insertToggleBlock:(t={})=>({commands:e})=>e.insertContent({type:this.name,attrs:{summary:"",open:!1,...t},content:[{type:"paragraph"}]})}}}),zR="_wrapper_1uoda_1",$R="_selected_1uoda_6",VR="_card_1uoda_6",FR="_placeholder_1uoda_7",UR="_thumb_1uoda_23",WR="_thumbImage_1uoda_35",KR="_thumbFallback_1uoda_42",qR="_body_1uoda_47",JR="_title_1uoda_52",GR="_subtitle_1uoda_64",YR="_meta_1uoda_70",XR="_toolbar_1uoda_77",ZR="_placeholderBody_1uoda_110",QR="_placeholderIcon_1uoda_126",eL="_placeholderText_1uoda_131",tL="_placeholderDelete_1uoda_136",nL="_error_1uoda_149",Ye={wrapper:zR,selected:$R,card:VR,placeholder:FR,thumb:UR,thumbImage:WR,thumbFallback:KR,body:qR,title:JR,subtitle:GR,meta:YR,toolbar:XR,placeholderBody:ZR,placeholderIcon:QR,placeholderText:eL,placeholderDelete:tL,error:nL};function rL({node:t,updateAttributes:e,deleteNode:n,editor:r,selected:s,extension:i,noun:o,icon:l}){const a=t.attrs.entity,c=i.options,[u,d]=S.useState(!1),[h,f]=S.useState(null),p=r.isEditable;async function g(){if(!c.onPick){f("No picker is configured");return}f(null),d(!0);try{const b=await c.onPick();b&&e({entity:b})}catch(b){f(b instanceof Error?b.message:"Could not load the selection")}finally{d(!1)}}const y=[Ye.wrapper,s&&Ye.selected].filter(Boolean).join(" ");return m.jsx(wr,{className:y,"data-drag-handle":!0,children:a?m.jsxs("div",{className:Ye.card,contentEditable:!1,children:[m.jsx("div",{className:Ye.thumb,children:a.imageUrl?m.jsx("img",{src:a.imageUrl,alt:"",className:Ye.thumbImage}):m.jsx("span",{className:Ye.thumbFallback,children:l})}),m.jsxs("div",{className:Ye.body,children:[m.jsx("p",{className:Ye.title,children:a.title}),a.subtitle&&m.jsx("p",{className:Ye.subtitle,children:a.subtitle}),a.meta&&m.jsx("p",{className:Ye.meta,children:a.meta})]}),p&&m.jsxs("div",{className:Ye.toolbar,children:[m.jsx(T.Tooltip,{content:`Change ${o}`,children:m.jsx(T.IconButton,{"aria-label":`Change ${o}`,variant:"transparent",size:"xsmall",icon:m.jsx(Zh,{size:14}),loading:u,onClick:g})}),m.jsx(T.Tooltip,{content:"Delete",children:m.jsx(T.IconButton,{"aria-label":`Delete ${o} block`,variant:"transparent",size:"xsmall",icon:m.jsx(St,{size:14}),onClick:n})})]})]}):m.jsxs("div",{className:Ye.placeholder,contentEditable:!1,children:[m.jsxs("button",{type:"button",className:Ye.placeholderBody,onClick:g,disabled:!p||u,children:[u?m.jsx(T.Spinner,{size:"md"}):m.jsx("span",{className:Ye.placeholderIcon,children:l}),m.jsx("span",{className:Ye.placeholderText,children:u?"Opening…":`Click to select a ${o}`})]}),h&&m.jsxs("p",{className:Ye.error,children:[m.jsx(Yh,{size:14}),h]}),p&&m.jsx("div",{className:Ye.placeholderDelete,children:m.jsx(T.IconButton,{"aria-label":"Remove block",variant:"transparent",size:"xsmall",icon:m.jsx(St,{size:14}),onClick:n})})]})})}const Vx="productBlock",Fx="collectionBlock";function Ux(t){return ke.create({name:t.name,group:"block",atom:!0,draggable:!0,selectable:!0,addOptions(){return{onPick:void 0}},addAttributes(){return{entity:{default:null,parseHTML:e=>{const n=e.getAttribute("data-entity");if(!n)return null;try{return JSON.parse(n)}catch{return null}},renderHTML:e=>({"data-entity":e.entity?JSON.stringify(e.entity):null})}}},parseHTML(){return[{tag:`div[${t.dataAttribute}]`}]},renderHTML({HTMLAttributes:e}){return["div",le({[t.dataAttribute]:""},e)]},addNodeView(){return xr(e=>m.jsx(rL,{...e,noun:t.noun,icon:t.icon}))},addCommands(){return{[t.command]:e=>({commands:n,state:r})=>Fs({commands:n,state:r,node:{type:t.name,attrs:{entity:e??null}}})}}})}const Wx=Ux({name:Vx,dataAttribute:"data-product-block",command:"insertProductBlock",noun:"product",icon:m.jsx(Cw,{size:22})}),Kx=Ux({name:Fx,dataAttribute:"data-collection-block",command:"insertCollectionBlock",noun:"collection",icon:m.jsx(Rw,{size:22})}),sL="_title_b828n_3",iL={title:sL};function oL({value:t,placeholder:e,readOnly:n,onChange:r,onLeave:s}){const i=S.useRef(null);return S.useLayoutEffect(()=>{const o=i.current;o&&(o.style.height="auto",o.style.height=`${o.scrollHeight}px`)},[t]),m.jsx("textarea",{ref:i,className:iL.title,value:t,placeholder:e,readOnly:n,rows:1,spellCheck:!1,onChange:o=>r(o.target.value.replace(/\n/g,"")),onKeyDown:o=>{(o.key==="Enter"||o.key==="ArrowDown")&&(o.preventDefault(),s())}})}const qx=["top","right","bottom","left"],og=["start","end"],lg=qx.reduce((t,e)=>t.concat(e,e+"-"+og[0],e+"-"+og[1]),[]),gn=Math.min,ht=Math.max,ya=Math.round,hn=t=>({x:t,y:t}),lL={left:"right",right:"left",bottom:"top",top:"bottom"};function Nd(t,e,n){return ht(t,gn(e,n))}function zn(t,e){return typeof t=="function"?t(e):t}function Ft(t){return t.split("-")[0]}function Gt(t){return t.split("-")[1]}function Jx(t){return t==="x"?"y":"x"}function nf(t){return t==="y"?"height":"width"}function cn(t){const e=t[0];return e==="t"||e==="b"?"y":"x"}function rf(t){return Jx(cn(t))}function Gx(t,e,n){n===void 0&&(n=!1);const r=Gt(t),s=rf(t),i=nf(s);let o=s==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[i]>e.floating[i]&&(o=wa(o)),[o,wa(o)]}function aL(t){const e=wa(t);return[ba(t),e,ba(e)]}function ba(t){return t.includes("start")?t.replace("start","end"):t.replace("end","start")}const ag=["left","right"],cg=["right","left"],cL=["top","bottom"],uL=["bottom","top"];function dL(t,e,n){switch(t){case"top":case"bottom":return n?e?cg:ag:e?ag:cg;case"left":case"right":return e?cL:uL;default:return[]}}function hL(t,e,n,r){const s=Gt(t);let i=dL(Ft(t),n==="start",r);return s&&(i=i.map(o=>o+"-"+s),e&&(i=i.concat(i.map(ba)))),i}function wa(t){const e=Ft(t);return lL[e]+t.slice(e.length)}function fL(t){return{top:0,right:0,bottom:0,left:0,...t}}function sf(t){return typeof t!="number"?fL(t):{top:t,right:t,bottom:t,left:t}}function Os(t){const{x:e,y:n,width:r,height:s}=t;return{width:r,height:s,top:n,left:e,right:e+r,bottom:n+s,x:e,y:n}}function ug(t,e,n){let{reference:r,floating:s}=t;const i=cn(e),o=rf(e),l=nf(o),a=Ft(e),c=i==="y",u=r.x+r.width/2-s.width/2,d=r.y+r.height/2-s.height/2,h=r[l]/2-s[l]/2;let f;switch(a){case"top":f={x:u,y:r.y-s.height};break;case"bottom":f={x:u,y:r.y+r.height};break;case"right":f={x:r.x+r.width,y:d};break;case"left":f={x:r.x-s.width,y:d};break;default:f={x:r.x,y:r.y}}switch(Gt(e)){case"start":f[o]-=h*(n&&c?-1:1);break;case"end":f[o]+=h*(n&&c?-1:1);break}return f}async function pL(t,e){var n;e===void 0&&(e={});const{x:r,y:s,platform:i,rects:o,elements:l,strategy:a}=t,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:h=!1,padding:f=0}=zn(e,t),p=sf(f),y=l[h?d==="floating"?"reference":"floating":d],b=Os(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(y)))==null||n?y:y.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(l.floating)),boundary:c,rootBoundary:u,strategy:a})),w=d==="floating"?{x:r,y:s,width:o.floating.width,height:o.floating.height}:o.reference,v=await(i.getOffsetParent==null?void 0:i.getOffsetParent(l.floating)),x=await(i.isElement==null?void 0:i.isElement(v))?await(i.getScale==null?void 0:i.getScale(v))||{x:1,y:1}:{x:1,y:1},k=Os(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:w,offsetParent:v,strategy:a}):w);return{top:(b.top-k.top+p.top)/x.y,bottom:(k.bottom-b.bottom+p.bottom)/x.y,left:(b.left-k.left+p.left)/x.x,right:(k.right-b.right+p.right)/x.x}}const mL=50,gL=async(t,e,n)=>{const{placement:r="bottom",strategy:s="absolute",middleware:i=[],platform:o}=n,l=o.detectOverflow?o:{...o,detectOverflow:pL},a=await(o.isRTL==null?void 0:o.isRTL(e));let c=await o.getElementRects({reference:t,floating:e,strategy:s}),{x:u,y:d}=ug(c,r,a),h=r,f=0;const p={};for(let g=0;g<i.length;g++){const y=i[g];if(!y)continue;const{name:b,fn:w}=y,{x:v,y:x,data:k,reset:C}=await w({x:u,y:d,initialPlacement:r,placement:h,strategy:s,middlewareData:p,rects:c,platform:l,elements:{reference:t,floating:e}});u=v??u,d=x??d,p[b]={...p[b],...k},C&&f<mL&&(f++,typeof C=="object"&&(C.placement&&(h=C.placement),C.rects&&(c=C.rects===!0?await o.getElementRects({reference:t,floating:e,strategy:s}):C.rects),{x:u,y:d}=ug(c,h,a)),g=-1)}return{x:u,y:d,placement:h,strategy:s,middlewareData:p}},yL=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:r,placement:s,rects:i,platform:o,elements:l,middlewareData:a}=e,{element:c,padding:u=0}=zn(t,e)||{};if(c==null)return{};const d=sf(u),h={x:n,y:r},f=rf(s),p=nf(f),g=await o.getDimensions(c),y=f==="y",b=y?"top":"left",w=y?"bottom":"right",v=y?"clientHeight":"clientWidth",x=i.reference[p]+i.reference[f]-h[f]-i.floating[p],k=h[f]-i.reference[f],C=await(o.getOffsetParent==null?void 0:o.getOffsetParent(c));let M=C?C[v]:0;(!M||!await(o.isElement==null?void 0:o.isElement(C)))&&(M=l.floating[v]||i.floating[p]);const O=x/2-k/2,_=M/2-g[p]/2-1,A=gn(d[b],_),R=gn(d[w],_),D=A,L=M-g[p]-R,I=M/2-g[p]/2+O,N=Nd(D,I,L),H=!a.arrow&&Gt(s)!=null&&I!==N&&i.reference[p]/2-(I<D?A:R)-g[p]/2<0,$=H?I<D?I-D:I-L:0;return{[f]:h[f]+$,data:{[f]:N,centerOffset:I-N-$,...H&&{alignmentOffset:$}},reset:H}}});function bL(t,e,n){return(t?[...n.filter(s=>Gt(s)===t),...n.filter(s=>Gt(s)!==t)]:n.filter(s=>Ft(s)===s)).filter(s=>t?Gt(s)===t||(e?ba(s)!==s:!1):!0)}const wL=function(t){return t===void 0&&(t={}),{name:"autoPlacement",options:t,async fn(e){var n,r,s;const{rects:i,middlewareData:o,placement:l,platform:a,elements:c}=e,{crossAxis:u=!1,alignment:d,allowedPlacements:h=lg,autoAlignment:f=!0,...p}=zn(t,e),g=d!==void 0||h===lg?bL(d||null,f,h):h,y=await a.detectOverflow(e,p),b=((n=o.autoPlacement)==null?void 0:n.index)||0,w=g[b];if(w==null)return{};const v=Gx(w,i,await(a.isRTL==null?void 0:a.isRTL(c.floating)));if(l!==w)return{reset:{placement:g[0]}};const x=[y[Ft(w)],y[v[0]],y[v[1]]],k=[...((r=o.autoPlacement)==null?void 0:r.overflows)||[],{placement:w,overflows:x}],C=g[b+1];if(C)return{data:{index:b+1,overflows:k},reset:{placement:C}};const M=k.map(A=>{const R=Gt(A.placement);return[A.placement,R&&u?A.overflows.slice(0,2).reduce((D,L)=>D+L,0):A.overflows[0],A.overflows]}).sort((A,R)=>A[1]-R[1]),_=((s=M.filter(A=>A[2].slice(0,Gt(A[0])?2:3).every(R=>R<=0))[0])==null?void 0:s[0])||M[0][0];return _!==l?{data:{index:b+1,overflows:k},reset:{placement:_}}:{}}}},xL=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,r;const{placement:s,middlewareData:i,rects:o,initialPlacement:l,platform:a,elements:c}=e,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:h,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:g=!0,...y}=zn(t,e);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const b=Ft(s),w=cn(l),v=Ft(l)===l,x=await(a.isRTL==null?void 0:a.isRTL(c.floating)),k=h||(v||!g?[wa(l)]:aL(l)),C=p!=="none";!h&&C&&k.push(...hL(l,g,p,x));const M=[l,...k],O=await a.detectOverflow(e,y),_=[];let A=((r=i.flip)==null?void 0:r.overflows)||[];if(u&&_.push(O[b]),d){const I=Gx(s,o,x);_.push(O[I[0]],O[I[1]])}if(A=[...A,{placement:s,overflows:_}],!_.every(I=>I<=0)){var R,D;const I=(((R=i.flip)==null?void 0:R.index)||0)+1,N=M[I];if(N&&(!(d==="alignment"?w!==cn(N):!1)||A.every(U=>cn(U.placement)===w?U.overflows[0]>0:!0)))return{data:{index:I,overflows:A},reset:{placement:N}};let H=(D=A.filter($=>$.overflows[0]<=0).sort(($,U)=>$.overflows[1]-U.overflows[1])[0])==null?void 0:D.placement;if(!H)switch(f){case"bestFit":{var L;const $=(L=A.filter(U=>{if(C){const K=cn(U.placement);return K===w||K==="y"}return!0}).map(U=>[U.placement,U.overflows.filter(K=>K>0).reduce((K,de)=>K+de,0)]).sort((U,K)=>U[1]-K[1])[0])==null?void 0:L[0];$&&(H=$);break}case"initialPlacement":H=l;break}if(s!==H)return{reset:{placement:H}}}return{}}}};function dg(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function hg(t){return qx.some(e=>t[e]>=0)}const vL=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n,platform:r}=e,{strategy:s="referenceHidden",...i}=zn(t,e);switch(s){case"referenceHidden":{const o=await r.detectOverflow(e,{...i,elementContext:"reference"}),l=dg(o,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:hg(l)}}}case"escaped":{const o=await r.detectOverflow(e,{...i,altBoundary:!0}),l=dg(o,n.floating);return{data:{escapedOffsets:l,escaped:hg(l)}}}default:return{}}}}};function Yx(t){const e=gn(...t.map(i=>i.left)),n=gn(...t.map(i=>i.top)),r=ht(...t.map(i=>i.right)),s=ht(...t.map(i=>i.bottom));return{x:e,y:n,width:r-e,height:s-n}}function kL(t){const e=t.slice().sort((s,i)=>s.y-i.y),n=[];let r=null;for(let s=0;s<e.length;s++){const i=e[s];!r||i.y-r.y>r.height/2?n.push([i]):n[n.length-1].push(i),r=i}return n.map(s=>Os(Yx(s)))}const SL=function(t){return t===void 0&&(t={}),{name:"inline",options:t,async fn(e){const{placement:n,elements:r,rects:s,platform:i,strategy:o}=e,{padding:l=2,x:a,y:c}=zn(t,e),u=Array.from(await(i.getClientRects==null?void 0:i.getClientRects(r.reference))||[]),d=kL(u),h=Os(Yx(u)),f=sf(l);function p(){if(d.length===2&&d[0].left>d[1].right&&a!=null&&c!=null)return d.find(y=>a>y.left-f.left&&a<y.right+f.right&&c>y.top-f.top&&c<y.bottom+f.bottom)||h;if(d.length>=2){if(cn(n)==="y"){const A=d[0],R=d[d.length-1],D=Ft(n)==="top",L=A.top,I=R.bottom,N=D?A.left:R.left,H=D?A.right:R.right,$=H-N,U=I-L;return{top:L,bottom:I,left:N,right:H,width:$,height:U,x:N,y:L}}const y=Ft(n)==="left",b=ht(...d.map(A=>A.right)),w=gn(...d.map(A=>A.left)),v=d.filter(A=>y?A.left===w:A.right===b),x=v[0].top,k=v[v.length-1].bottom,C=w,M=b,O=M-C,_=k-x;return{top:x,bottom:k,left:C,right:M,width:O,height:_,x:C,y:x}}return h}const g=await i.getElementRects({reference:{getBoundingClientRect:p},floating:r.floating,strategy:o});return s.reference.x!==g.reference.x||s.reference.y!==g.reference.y||s.reference.width!==g.reference.width||s.reference.height!==g.reference.height?{reset:{rects:g}}:{}}}},CL=new Set(["left","top"]);async function ML(t,e){const{placement:n,platform:r,elements:s}=t,i=await(r.isRTL==null?void 0:r.isRTL(s.floating)),o=Ft(n),l=Gt(n),a=cn(n)==="y",c=CL.has(o)?-1:1,u=i&&a?-1:1,d=zn(e,t);let{mainAxis:h,crossAxis:f,alignmentAxis:p}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return l&&typeof p=="number"&&(f=l==="end"?p*-1:p),a?{x:f*u,y:h*c}:{x:h*c,y:f*u}}const AL=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,r;const{x:s,y:i,placement:o,middlewareData:l}=e,a=await ML(e,t);return o===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:s+a.x,y:i+a.y,data:{...a,placement:o}}}}},EL=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:r,placement:s,platform:i}=e,{mainAxis:o=!0,crossAxis:l=!1,limiter:a={fn:b=>{let{x:w,y:v}=b;return{x:w,y:v}}},...c}=zn(t,e),u={x:n,y:r},d=await i.detectOverflow(e,c),h=cn(Ft(s)),f=Jx(h);let p=u[f],g=u[h];if(o){const b=f==="y"?"top":"left",w=f==="y"?"bottom":"right",v=p+d[b],x=p-d[w];p=Nd(v,p,x)}if(l){const b=h==="y"?"top":"left",w=h==="y"?"bottom":"right",v=g+d[b],x=g-d[w];g=Nd(v,g,x)}const y=a.fn({...e,[f]:p,[h]:g});return{...y,data:{x:y.x-n,y:y.y-r,enabled:{[f]:o,[h]:l}}}}}},TL=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var n,r;const{placement:s,rects:i,platform:o,elements:l}=e,{apply:a=()=>{},...c}=zn(t,e),u=await o.detectOverflow(e,c),d=Ft(s),h=Gt(s),f=cn(s)==="y",{width:p,height:g}=i.floating;let y,b;d==="top"||d==="bottom"?(y=d,b=h===(await(o.isRTL==null?void 0:o.isRTL(l.floating))?"start":"end")?"left":"right"):(b=d,y=h==="end"?"top":"bottom");const w=g-u.top-u.bottom,v=p-u.left-u.right,x=gn(g-u[y],w),k=gn(p-u[b],v),C=!e.middlewareData.shift;let M=x,O=k;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&(O=v),(r=e.middlewareData.shift)!=null&&r.enabled.y&&(M=w),C&&!h){const A=ht(u.left,0),R=ht(u.right,0),D=ht(u.top,0),L=ht(u.bottom,0);f?O=p-2*(A!==0||R!==0?A+R:ht(u.left,u.right)):M=g-2*(D!==0||L!==0?D+L:ht(u.top,u.bottom))}await a({...e,availableWidth:O,availableHeight:M});const _=await o.getDimensions(l.floating);return p!==_.width||g!==_.height?{reset:{rects:!0}}:{}}}};function rc(){return typeof window<"u"}function Us(t){return Xx(t)?(t.nodeName||"").toLowerCase():"#document"}function Tt(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function $n(t){var e;return(e=(Xx(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function Xx(t){return rc()?t instanceof Node||t instanceof Tt(t).Node:!1}function Xt(t){return rc()?t instanceof Element||t instanceof Tt(t).Element:!1}function Vn(t){return rc()?t instanceof HTMLElement||t instanceof Tt(t).HTMLElement:!1}function fg(t){return!rc()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof Tt(t).ShadowRoot}function ko(t){const{overflow:e,overflowX:n,overflowY:r,display:s}=Zt(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&s!=="inline"&&s!=="contents"}function _L(t){return/^(table|td|th)$/.test(Us(t))}function sc(t){try{if(t.matches(":popover-open"))return!0}catch{}try{return t.matches(":modal")}catch{return!1}}const NL=/transform|translate|scale|rotate|perspective|filter/,OL=/paint|layout|strict|content/,Cr=t=>!!t&&t!=="none";let cu;function of(t){const e=Xt(t)?Zt(t):t;return Cr(e.transform)||Cr(e.translate)||Cr(e.scale)||Cr(e.rotate)||Cr(e.perspective)||!lf()&&(Cr(e.backdropFilter)||Cr(e.filter))||NL.test(e.willChange||"")||OL.test(e.contain||"")}function IL(t){let e=hr(t);for(;Vn(e)&&!Is(e);){if(of(e))return e;if(sc(e))return null;e=hr(e)}return null}function lf(){return cu==null&&(cu=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),cu}function Is(t){return/^(html|body|#document)$/.test(Us(t))}function Zt(t){return Tt(t).getComputedStyle(t)}function ic(t){return Xt(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function hr(t){if(Us(t)==="html")return t;const e=t.assignedSlot||t.parentNode||fg(t)&&t.host||$n(t);return fg(e)?e.host:e}function Zx(t){const e=hr(t);return Is(e)?t.ownerDocument?t.ownerDocument.body:t.body:Vn(e)&&ko(e)?e:Zx(e)}function Qx(t,e,n){var r;e===void 0&&(e=[]);const s=Zx(t),i=s===((r=t.ownerDocument)==null?void 0:r.body),o=Tt(s);return i?(Od(o),e.concat(o,o.visualViewport||[],ko(s)?s:[],[])):e.concat(s,Qx(s,[]))}function Od(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function ev(t){const e=Zt(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const s=Vn(t),i=s?t.offsetWidth:n,o=s?t.offsetHeight:r,l=ya(n)!==i||ya(r)!==o;return l&&(n=i,r=o),{width:n,height:r,$:l}}function tv(t){return Xt(t)?t:t.contextElement}function gs(t){const e=tv(t);if(!Vn(e))return hn(1);const n=e.getBoundingClientRect(),{width:r,height:s,$:i}=ev(e);let o=(i?ya(n.width):n.width)/r,l=(i?ya(n.height):n.height)/s;return(!o||!Number.isFinite(o))&&(o=1),(!l||!Number.isFinite(l))&&(l=1),{x:o,y:l}}const DL=hn(0);function nv(t){const e=Tt(t);return!lf()||!e.visualViewport?DL:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function RL(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==Tt(t)?!1:e}function no(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const s=t.getBoundingClientRect(),i=tv(t);let o=hn(1);e&&(r?Xt(r)&&(o=gs(r)):o=gs(t));const l=RL(i,n,r)?nv(i):hn(0);let a=(s.left+l.x)/o.x,c=(s.top+l.y)/o.y,u=s.width/o.x,d=s.height/o.y;if(i){const h=Tt(i),f=r&&Xt(r)?Tt(r):r;let p=h,g=Od(p);for(;g&&r&&f!==p;){const y=gs(g),b=g.getBoundingClientRect(),w=Zt(g),v=b.left+(g.clientLeft+parseFloat(w.paddingLeft))*y.x,x=b.top+(g.clientTop+parseFloat(w.paddingTop))*y.y;a*=y.x,c*=y.y,u*=y.x,d*=y.y,a+=v,c+=x,p=Tt(g),g=Od(p)}}return Os({width:u,height:d,x:a,y:c})}function oc(t,e){const n=ic(t).scrollLeft;return e?e.left+n:no($n(t)).left+n}function rv(t,e){const n=t.getBoundingClientRect(),r=n.left+e.scrollLeft-oc(t,n),s=n.top+e.scrollTop;return{x:r,y:s}}function LL(t){let{elements:e,rect:n,offsetParent:r,strategy:s}=t;const i=s==="fixed",o=$n(r),l=e?sc(e.floating):!1;if(r===o||l&&i)return n;let a={scrollLeft:0,scrollTop:0},c=hn(1);const u=hn(0),d=Vn(r);if((d||!d&&!i)&&((Us(r)!=="body"||ko(o))&&(a=ic(r)),d)){const f=no(r);c=gs(r),u.x=f.x+r.clientLeft,u.y=f.y+r.clientTop}const h=o&&!d&&!i?rv(o,a):hn(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-a.scrollLeft*c.x+u.x+h.x,y:n.y*c.y-a.scrollTop*c.y+u.y+h.y}}function jL(t){return Array.from(t.getClientRects())}function PL(t){const e=$n(t),n=ic(t),r=t.ownerDocument.body,s=ht(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),i=ht(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let o=-n.scrollLeft+oc(t);const l=-n.scrollTop;return Zt(r).direction==="rtl"&&(o+=ht(e.clientWidth,r.clientWidth)-s),{width:s,height:i,x:o,y:l}}const pg=25;function BL(t,e){const n=Tt(t),r=$n(t),s=n.visualViewport;let i=r.clientWidth,o=r.clientHeight,l=0,a=0;if(s){i=s.width,o=s.height;const u=lf();(!u||u&&e==="fixed")&&(l=s.offsetLeft,a=s.offsetTop)}const c=oc(r);if(c<=0){const u=r.ownerDocument,d=u.body,h=getComputedStyle(d),f=u.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,p=Math.abs(r.clientWidth-d.clientWidth-f);p<=pg&&(i-=p)}else c<=pg&&(i+=c);return{width:i,height:o,x:l,y:a}}function HL(t,e){const n=no(t,!0,e==="fixed"),r=n.top+t.clientTop,s=n.left+t.clientLeft,i=Vn(t)?gs(t):hn(1),o=t.clientWidth*i.x,l=t.clientHeight*i.y,a=s*i.x,c=r*i.y;return{width:o,height:l,x:a,y:c}}function mg(t,e,n){let r;if(e==="viewport")r=BL(t,n);else if(e==="document")r=PL($n(t));else if(Xt(e))r=HL(e,n);else{const s=nv(t);r={x:e.x-s.x,y:e.y-s.y,width:e.width,height:e.height}}return Os(r)}function sv(t,e){const n=hr(t);return n===e||!Xt(n)||Is(n)?!1:Zt(n).position==="fixed"||sv(n,e)}function zL(t,e){const n=e.get(t);if(n)return n;let r=Qx(t,[]).filter(l=>Xt(l)&&Us(l)!=="body"),s=null;const i=Zt(t).position==="fixed";let o=i?hr(t):t;for(;Xt(o)&&!Is(o);){const l=Zt(o),a=of(o);!a&&l.position==="fixed"&&(s=null),(i?!a&&!s:!a&&l.position==="static"&&!!s&&(s.position==="absolute"||s.position==="fixed")||ko(o)&&!a&&sv(t,o))?r=r.filter(u=>u!==o):s=l,o=hr(o)}return e.set(t,r),r}function $L(t){let{element:e,boundary:n,rootBoundary:r,strategy:s}=t;const o=[...n==="clippingAncestors"?sc(e)?[]:zL(e,this._c):[].concat(n),r],l=mg(e,o[0],s);let a=l.top,c=l.right,u=l.bottom,d=l.left;for(let h=1;h<o.length;h++){const f=mg(e,o[h],s);a=ht(f.top,a),c=gn(f.right,c),u=gn(f.bottom,u),d=ht(f.left,d)}return{width:c-d,height:u-a,x:d,y:a}}function VL(t){const{width:e,height:n}=ev(t);return{width:e,height:n}}function FL(t,e,n){const r=Vn(e),s=$n(e),i=n==="fixed",o=no(t,!0,i,e);let l={scrollLeft:0,scrollTop:0};const a=hn(0);function c(){a.x=oc(s)}if(r||!r&&!i)if((Us(e)!=="body"||ko(s))&&(l=ic(e)),r){const f=no(e,!0,i,e);a.x=f.x+e.clientLeft,a.y=f.y+e.clientTop}else s&&c();i&&!r&&s&&c();const u=s&&!r&&!i?rv(s,l):hn(0),d=o.left+l.scrollLeft-a.x-u.x,h=o.top+l.scrollTop-a.y-u.y;return{x:d,y:h,width:o.width,height:o.height}}function uu(t){return Zt(t).position==="static"}function gg(t,e){if(!Vn(t)||Zt(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return $n(t)===n&&(n=n.ownerDocument.body),n}function iv(t,e){const n=Tt(t);if(sc(t))return n;if(!Vn(t)){let s=hr(t);for(;s&&!Is(s);){if(Xt(s)&&!uu(s))return s;s=hr(s)}return n}let r=gg(t,e);for(;r&&_L(r)&&uu(r);)r=gg(r,e);return r&&Is(r)&&uu(r)&&!of(r)?n:r||IL(t)||n}const UL=async function(t){const e=this.getOffsetParent||iv,n=this.getDimensions,r=await n(t.floating);return{reference:FL(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function WL(t){return Zt(t).direction==="rtl"}const KL={convertOffsetParentRelativeRectToViewportRelativeRect:LL,getDocumentElement:$n,getClippingRect:$L,getOffsetParent:iv,getElementRects:UL,getClientRects:jL,getDimensions:VL,getScale:gs,isElement:Xt,isRTL:WL},ov=AL,lv=wL,av=EL,cv=xL,uv=TL,dv=vL,hv=yL,fv=SL,af=(t,e,n)=>{const r=new Map,s={platform:KL,...n},i={...s.platform,_c:r};return gL(t,e,{...s,platform:i})};function qL(t,e){const n=Math.min(t.top,e.top),r=Math.max(t.bottom,e.bottom),s=Math.min(t.left,e.left),o=Math.max(t.right,e.right)-s,l=r-n,a=s,c=n;return new DOMRect(a,c,o,l)}var JL=class{constructor({editor:t,element:e,view:n,pluginKey:r="bubbleMenu",updateDelay:s=250,resizeDelay:i=60,shouldShow:o,appendTo:l,getReferencedVirtualElement:a,options:c}){this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.floatingUIOptions={strategy:"absolute",placement:"top",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1,onShow:void 0,onHide:void 0,onUpdate:void 0,onDestroy:void 0},this.shouldShow=({view:d,state:h,from:f,to:p})=>{const{doc:g,selection:y}=h,{empty:b}=y,w=!g.textBetween(f,p).length&&Ja(h.selection),v=this.element.contains(document.activeElement);return!(!(d.hasFocus()||v)||b||w||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:d})=>{var h;if(this.editor.isDestroyed){this.destroy();return}if(this.preventHide){this.preventHide=!1;return}d!=null&&d.relatedTarget&&((h=this.element.parentNode)!=null&&h.contains(d.relatedTarget))||(d==null?void 0:d.relatedTarget)!==this.editor.view.dom&&this.hide()},this.handleDebouncedUpdate=(d,h)=>{const f=!(h!=null&&h.selection.eq(d.state.selection)),p=!(h!=null&&h.doc.eq(d.state.doc));!f&&!p||(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(d,f,p,h)},this.updateDelay))},this.updateHandler=(d,h,f,p)=>{const{composing:g}=d;if(g||!h&&!f)return;if(!this.getShouldShow(p)){this.hide();return}this.show(),this.updatePosition()},this.transactionHandler=({transaction:d})=>{const h=d.getMeta(this.pluginKey);h==="updatePosition"?this.updatePosition():h&&typeof h=="object"&&h.type==="updateOptions"?this.updateOptions(h.options):h==="hide"?this.hide():h==="show"&&(this.updatePosition(),this.show())};var u;this.editor=t,this.element=e,this.view=n,this.pluginKey=r,this.updateDelay=s,this.resizeDelay=i,this.appendTo=l,this.scrollTarget=(u=c==null?void 0:c.scrollTarget)!=null?u:window,this.getReferencedVirtualElement=a,this.floatingUIOptions={...this.floatingUIOptions,...c},this.element.tabIndex=0,o&&(this.shouldShow=o),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.addEventListener("dragstart",this.dragstartHandler),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.editor.on("transaction",this.transactionHandler),window.addEventListener("resize",this.resizeHandler),this.scrollTarget.addEventListener("scroll",this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&(this.show(),this.updatePosition())}get middlewares(){const t=[];return this.floatingUIOptions.flip&&t.push(cv(typeof this.floatingUIOptions.flip!="boolean"?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&t.push(av(typeof this.floatingUIOptions.shift!="boolean"?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&t.push(ov(typeof this.floatingUIOptions.offset!="boolean"?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&t.push(hv(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&t.push(uv(typeof this.floatingUIOptions.size!="boolean"?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&t.push(lv(typeof this.floatingUIOptions.autoPlacement!="boolean"?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&t.push(dv(typeof this.floatingUIOptions.hide!="boolean"?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&t.push(fv(typeof this.floatingUIOptions.inline!="boolean"?this.floatingUIOptions.inline:void 0)),t}get virtualElement(){var t,e,n;const{selection:r}=this.editor.state,s=(t=this.getReferencedVirtualElement)==null?void 0:t.call(this);if(s)return s;if(!((n=(e=this.view)==null?void 0:e.dom)!=null&&n.parentNode))return;const i=dy(this.view,r.from,r.to);let o={getBoundingClientRect:()=>i,getClientRects:()=>[i]};if(r instanceof Y){let l=this.view.nodeDOM(r.from);const a=l.dataset.nodeViewWrapper?l:l.querySelector("[data-node-view-wrapper]");a&&(l=a),l&&(o={getBoundingClientRect:()=>l.getBoundingClientRect(),getClientRects:()=>[l.getBoundingClientRect()]})}if(r instanceof ye){const{$anchorCell:l,$headCell:a}=r,c=l?l.pos:a.pos,u=a?a.pos:l.pos,d=this.view.nodeDOM(c),h=this.view.nodeDOM(u);if(!d||!h)return;const f=d===h?d.getBoundingClientRect():qL(d.getBoundingClientRect(),h.getBoundingClientRect());o={getBoundingClientRect:()=>f,getClientRects:()=>[f]}}return o}updatePosition(){if(!this.isVisible)return;const t=this.virtualElement;t&&af(t,this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:e,y:n,strategy:r,middlewareData:s})=>{var i,o;if(!(!this.isVisible||this.editor.isDestroyed||!this.element.isConnected)){if((i=s.hide)!=null&&i.referenceHidden||(o=s.hide)!=null&&o.escaped){this.element.style.visibility="hidden";return}this.element.style.visibility="visible",this.element.style.width="max-content",this.element.style.position=r,this.element.style.left=`${e}px`,this.element.style.top=`${n}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()}})}update(t,e){const{state:n}=t,r=n.selection.from!==n.selection.to;if(this.updateDelay>0&&r){this.handleDebouncedUpdate(t,e);return}const s=!(e!=null&&e.selection.eq(t.state.selection)),i=!(e!=null&&e.doc.eq(t.state.doc));this.updateHandler(t,s,i,e)}getShouldShow(t){var e;const{state:n}=this.view,{selection:r}=n,{ranges:s}=r,i=Math.min(...s.map(a=>a.$from.pos)),o=Math.max(...s.map(a=>a.$to.pos));return((e=this.shouldShow)==null?void 0:e.call(this,{editor:this.editor,element:this.element,view:this.view,state:n,oldState:t,from:i,to:o}))||!1}show(){var t;if(this.isVisible)return;this.element.style.visibility="visible",this.element.style.opacity="1";const e=typeof this.appendTo=="function"?this.appendTo():this.appendTo;(t=e??this.view.dom.parentElement)==null||t.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}updateOptions(t){var e;if(t.updateDelay!==void 0&&(this.updateDelay=t.updateDelay),t.resizeDelay!==void 0&&(this.resizeDelay=t.resizeDelay),t.appendTo!==void 0&&(this.appendTo=t.appendTo),t.getReferencedVirtualElement!==void 0&&(this.getReferencedVirtualElement=t.getReferencedVirtualElement),t.shouldShow!==void 0&&t.shouldShow&&(this.shouldShow=t.shouldShow),t.options!==void 0){const n=(e=t.options.scrollTarget)!=null?e:window;n!==this.scrollTarget&&(this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.scrollTarget=n,this.scrollTarget.addEventListener("scroll",this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...t.options}}}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener("dragstart",this.dragstartHandler),window.removeEventListener("resize",this.resizeHandler),this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.editor.off("transaction",this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},pv=t=>new ce({key:typeof t.pluginKey=="string"?new ae(t.pluginKey):t.pluginKey,view:e=>new JL({view:e,...t})});ie.create({name:"bubbleMenu",addOptions(){return{element:null,pluginKey:"bubbleMenu",updateDelay:void 0,appendTo:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[pv({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,options:this.options.options,appendTo:this.options.appendTo,getReferencedVirtualElement:this.options.getReferencedVirtualElement,shouldShow:this.options.shouldShow})]:[]}});var GL=class{constructor({editor:t,element:e,view:n,pluginKey:r="floatingMenu",updateDelay:s=250,resizeDelay:i=60,options:o,appendTo:l,shouldShow:a}){this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.shouldShow=({view:u,state:d})=>{const{selection:h}=d,{$anchor:f,empty:p}=h,g=f.depth===1,y=f.parent.isTextblock&&!f.parent.type.spec.code&&!f.parent.textContent&&f.parent.childCount===0&&!this.getTextContent(f.parent);return!(!u.hasFocus()||!p||!g||!y||!this.editor.isEditable)},this.floatingUIOptions={strategy:"absolute",placement:"right",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1},this.updateHandler=(u,d,h,f)=>{const{composing:p}=u;if(p||!d&&!h)return;if(!this.getShouldShow(f)){this.hide();return}this.updatePosition(),this.show()},this.mousedownHandler=()=>{this.preventHide=!0},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:u})=>{var d;if(this.preventHide){this.preventHide=!1;return}u!=null&&u.relatedTarget&&((d=this.element.parentNode)!=null&&d.contains(u.relatedTarget))||(u==null?void 0:u.relatedTarget)!==this.editor.view.dom&&this.hide()},this.transactionHandler=({transaction:u})=>{const d=u.getMeta(this.pluginKey);d==="updatePosition"?this.updatePosition():d&&typeof d=="object"&&d.type==="updateOptions"?this.updateOptions(d.options):d==="hide"?this.hide():d==="show"&&(this.updatePosition(),this.show())},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)};var c;this.editor=t,this.element=e,this.view=n,this.pluginKey=r,this.updateDelay=s,this.resizeDelay=i,this.appendTo=l,this.scrollTarget=(c=o==null?void 0:o.scrollTarget)!=null?c:window,this.floatingUIOptions={...this.floatingUIOptions,...o},this.element.tabIndex=0,a&&(this.shouldShow=a),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.editor.on("transaction",this.transactionHandler),window.addEventListener("resize",this.resizeHandler),this.scrollTarget.addEventListener("scroll",this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&(this.show(),this.updatePosition())}getTextContent(t){return iy(t,{textSerializers:xh(this.editor.schema)})}get middlewares(){const t=[];return this.floatingUIOptions.flip&&t.push(cv(typeof this.floatingUIOptions.flip!="boolean"?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&t.push(av(typeof this.floatingUIOptions.shift!="boolean"?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&t.push(ov(typeof this.floatingUIOptions.offset!="boolean"?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&t.push(hv(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&t.push(uv(typeof this.floatingUIOptions.size!="boolean"?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&t.push(lv(typeof this.floatingUIOptions.autoPlacement!="boolean"?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&t.push(dv(typeof this.floatingUIOptions.hide!="boolean"?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&t.push(fv(typeof this.floatingUIOptions.inline!="boolean"?this.floatingUIOptions.inline:void 0)),t}getShouldShow(t){var e;const{state:n}=this.view,{selection:r}=n,{ranges:s}=r,i=Math.min(...s.map(a=>a.$from.pos)),o=Math.max(...s.map(a=>a.$to.pos));return(e=this.shouldShow)==null?void 0:e.call(this,{editor:this.editor,view:this.view,state:n,oldState:t,from:i,to:o})}updateOptions(t){var e;if(t.updateDelay!==void 0&&(this.updateDelay=t.updateDelay),t.resizeDelay!==void 0&&(this.resizeDelay=t.resizeDelay),t.appendTo!==void 0&&(this.appendTo=t.appendTo),t.shouldShow!==void 0&&t.shouldShow&&(this.shouldShow=t.shouldShow),t.options!==void 0){const n=(e=t.options.scrollTarget)!=null?e:window;n!==this.scrollTarget&&(this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.scrollTarget=n,this.scrollTarget.addEventListener("scroll",this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...t.options}}}updatePosition(){var t,e;if(!((e=(t=this.view)==null?void 0:t.dom)!=null&&e.parentNode))return;const{selection:n}=this.editor.state,r=dy(this.view,n.from,n.to);af({getBoundingClientRect:()=>r,getClientRects:()=>[r]},this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:i,y:o,strategy:l,middlewareData:a})=>{var c,u;if((c=a.hide)!=null&&c.referenceHidden||(u=a.hide)!=null&&u.escaped){this.element.style.visibility="hidden";return}this.element.style.visibility="visible",this.element.style.width="max-content",this.element.style.position=l,this.element.style.left=`${i}px`,this.element.style.top=`${o}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(t,e){const n=!(e!=null&&e.selection.eq(t.state.selection)),r=!(e!=null&&e.doc.eq(t.state.doc));this.updateHandler(t,n,r,e)}show(){var t;if(this.isVisible)return;this.element.style.visibility="visible",this.element.style.opacity="1";const e=typeof this.appendTo=="function"?this.appendTo():this.appendTo;(t=e??this.view.dom.parentElement)==null||t.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),window.removeEventListener("resize",this.resizeHandler),this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.editor.off("transaction",this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},mv=t=>new ce({key:typeof t.pluginKey=="string"?new ae(t.pluginKey):t.pluginKey,view:e=>new GL({view:e,...t})});ie.create({name:"floatingMenu",addOptions(){return{element:null,options:{},pluginKey:"floatingMenu",updateDelay:void 0,resizeDelay:void 0,appendTo:void 0,shouldShow:null}},addCommands(){return{updateFloatingMenuPosition:()=>({tr:t,dispatch:e})=>(e&&t.setMeta(this.options.pluginKey,"updatePosition"),!0)}},addProseMirrorPlugins(){return this.options.element?[mv({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,resizeDelay:this.options.resizeDelay,options:this.options.options,appendTo:this.options.appendTo,shouldShow:this.options.shouldShow})]:[]}});function gv(t,e){return t??new ae(e)}var YL=typeof window<"u"?S.useLayoutEffect:S.useEffect,yv=new Set(["left","opacity","position","top","visibility","width"]),XL=new Set(["animationIterationCount","aspectRatio","borderImageOutset","borderImageSlice","borderImageWidth","columnCount","columns","fillOpacity","flex","flexGrow","flexShrink","fontWeight","gridArea","gridColumn","gridColumnEnd","gridColumnStart","gridRow","gridRowEnd","gridRowStart","lineClamp","lineHeight","opacity","order","orphans","scale","stopOpacity","strokeDasharray","strokeDashoffset","strokeMiterlimit","strokeOpacity","strokeWidth","tabSize","widows","zIndex","zoom"]),ZL=new Set(["children","className","style"]),QL=new Set(["tabIndex"]),ej=new Set(["accessKey","autoCapitalize","contentEditable","contextMenu","dir","draggable","enterKeyHint","hidden","id","lang","nonce","role","slot","spellCheck","tabIndex","title","translate"]),tj={Blur:"focusout",DoubleClick:"dblclick",Focus:"focusin",MouseEnter:"mouseenter",MouseLeave:"mouseleave"};function Id(t,e){return/^on[A-Z]/.test(t)&&typeof e=="function"}function nj(t){return t.startsWith("aria-")||t.startsWith("data-"),t}function rj(t){return t.startsWith("aria-")||t.startsWith("data-")||ej.has(t)}function bv(t){return t.startsWith("--")?t:t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function sj(t){var e;const n=t.endsWith("Capture"),s=(n?t.slice(0,-7):t).slice(2);return{eventName:(e=tj[s])!=null?e:s.toLowerCase(),options:n?{capture:!0}:void 0}}function ij(t,e){let n=e.defaultPrevented,r=!1;const s=Object.create(e);return Object.defineProperties(s,{nativeEvent:{value:e},currentTarget:{value:t},target:{value:e.target},persist:{value:()=>{}},isDefaultPrevented:{value:()=>n},isPropagationStopped:{value:()=>r},preventDefault:{value:()=>{n=!0,e.preventDefault()}},stopPropagation:{value:()=>{r=!0,e.stopPropagation()}}}),s}function du(t){return QL.has(t)}function yg(t,e,n){if(e==="tabIndex"){t.tabIndex=Number(n);return}t[e]=n}function oj(t,e){if(e==="tabIndex"){t.removeAttribute("tabindex");return}const n=t[e];if(typeof n=="boolean"){t[e]=!1;return}if(typeof n=="number"){t[e]=0;return}t[e]=""}function lj(t,e){return typeof e!="number"||e===0||t.startsWith("--")||XL.has(t)?String(e):`${e}px`}function aj(t,e){yv.has(e)||t.style.removeProperty(bv(e))}function cj(t,e,n){yv.has(e)||t.style.setProperty(bv(e),lj(e,n))}function uj(t,e,n){new Set([...Object.keys(e),...Object.keys(n)]).forEach(s=>{if(ZL.has(s)||!rj(s)||Id(s,e[s])||Id(s,n[s]))return;const i=e[s],o=n[s];if(i===o)return;const l=nj(s);if(o==null||o===!1){du(s)&&oj(t,s),t.removeAttribute(l);return}if(o===!0){du(s)&&yg(t,s,!0),t.setAttribute(l,"");return}if(du(s)){yg(t,s,o);return}t.setAttribute(l,String(o))})}function dj(t,e,n){if(e!==n){if(n){t.className=n;return}t.removeAttribute("class")}}function hj(t,e,n){const r=e??{},s=n??{};new Set([...Object.keys(r),...Object.keys(s)]).forEach(o=>{const l=r[o],a=s[o];if(l!==a){if(a==null){aj(t,o);return}cj(t,o,a)}})}function fj(t,e,n){e.forEach(({eventName:s,listener:i,options:o})=>{t.removeEventListener(s,i,o)});const r=[];return Object.entries(n).forEach(([s,i])=>{if(!Id(s,i))return;const{eventName:o,options:l}=sj(s),a=c=>{i(ij(t,c))};t.addEventListener(o,a,l),r.push({eventName:o,listener:a,options:l})}),r}function wv(t,e){const n=S.useRef({}),r=S.useRef([]);YL(()=>{const s=n.current;return dj(t,s.className,e.className),hj(t,s.style,e.style),uj(t,s,e),r.current=fj(t,r.current,e),n.current=e,()=>{r.current.forEach(({eventName:i,listener:o,options:l})=>{t.removeEventListener(i,o,l)}),r.current=[]}},[t,e])}var xv=S.forwardRef(({pluginKey:t,editor:e,updateDelay:n,resizeDelay:r,appendTo:s,shouldShow:i=null,getReferencedVirtualElement:o,options:l,children:a,...c},u)=>{const d=S.useRef(document.createElement("div")),h=S.useRef(gv(t,"bubbleMenu")).current;wv(d.current,c),typeof u=="function"?u(d.current):u&&(u.current=d.current);const{editor:f}=Iy(),p=e||f,g={updateDelay:n,resizeDelay:r,appendTo:s,pluginKey:h,shouldShow:i,getReferencedVirtualElement:o,options:l},y=S.useRef(g);y.current=g;const[b,w]=S.useState(!1),v=S.useRef(!0);return S.useEffect(()=>{if(p!=null&&p.isDestroyed)return;if(!p){console.warn("BubbleMenu component is not rendered inside of an editor component or does not have editor prop.");return}const x=d.current;x.style.visibility="hidden",x.style.position="absolute";const k=pv({...y.current,editor:p,element:x});p.registerPlugin(k);const C=y.current.pluginKey;return v.current=!0,w(!0),()=>{w(!1),p.unregisterPlugin(C),window.requestAnimationFrame(()=>{x.parentNode&&x.parentNode.removeChild(x)})}},[p]),S.useEffect(()=>{if(!(!b||!p||p.isDestroyed)){if(v.current){v.current=!1;return}p.view.dispatch(p.state.tr.setMeta(h,{type:"updateOptions",options:y.current}))}},[b,p,n,r,i,l,s,o,h]),Hs.createPortal(a,d.current)});S.forwardRef(({pluginKey:t,editor:e,updateDelay:n,resizeDelay:r,appendTo:s,shouldShow:i=null,options:o,children:l,...a},c)=>{const u=S.useRef(document.createElement("div")),d=S.useRef(gv(t,"floatingMenu")).current;wv(u.current,a),typeof c=="function"?c(u.current):c&&(c.current=u.current);const{editor:h}=Iy(),f=e||h,p={updateDelay:n,resizeDelay:r,appendTo:s,pluginKey:d,shouldShow:i,options:o},g=S.useRef(p);g.current=p;const[y,b]=S.useState(!1),w=S.useRef(!0);return S.useEffect(()=>{if(f!=null&&f.isDestroyed)return;if(!f){console.warn("FloatingMenu component is not rendered inside of an editor component or does not have editor prop.");return}const v=u.current;v.style.visibility="hidden",v.style.position="absolute";const x=mv({...g.current,editor:f,element:v});f.registerPlugin(x);const k=g.current.pluginKey;return w.current=!0,b(!0),()=>{b(!1),f.unregisterPlugin(k),window.requestAnimationFrame(()=>{v.parentNode&&v.parentNode.removeChild(v)})}},[f]),S.useEffect(()=>{if(!(!y||!f||f.isDestroyed)){if(w.current){w.current=!1;return}f.view.dispatch(f.state.tr.setMeta(d,{type:"updateOptions",options:g.current}))}},[y,f,n,r,i,o,s,d]),Hs.createPortal(l,u.current)});const pj="_menu_y312l_2",mj="_row_y312l_9",gj="_linkRow_y312l_10",yj="_button_y312l_19",bj="_active_y312l_37",wj="_divider_y312l_53",xj="_styleTrigger_y312l_61",vj="_panelWrap_y312l_89",kj="_dropdown_y312l_94",Sj="_colorDropdown_y312l_101",Cj="_colorPanel_y312l_106",Mj="_colorTabs_y312l_113",Aj="_colorPickerBody_y312l_118",Ej="_colorTab_y312l_113",Tj="_colorTabActive_y312l_145",_j="_linkInput_y312l_161",Q={menu:pj,row:mj,linkRow:gj,button:yj,active:bj,divider:wj,styleTrigger:xj,panelWrap:vj,dropdown:kj,colorDropdown:Sj,colorPanel:Cj,colorTabs:Mj,colorPickerBody:Aj,colorTab:Ej,colorTabActive:Tj,linkInput:_j};function cf(t){return t.state.selection instanceof ye}function vv({editor:t}){const e=vo({editor:t,selector:({editor:n})=>({headerRow:n.isActive("tableHeader"),canMerge:n.can().mergeCells(),canSplit:n.can().splitCell()})});return m.jsx(xv,{editor:t,pluginKey:"blockEditorTableMenu",options:{placement:"top",offset:8},shouldShow:({editor:n,state:r,from:s,to:i})=>!n.isEditable||!n.isActive("table")||r.selection instanceof Y?!1:s===i||cf(n),className:Q.menu,children:m.jsxs("div",{className:Q.row,children:[m.jsx(T.Tooltip,{content:"Insert column before",children:m.jsx("button",{type:"button",className:Q.button,onClick:()=>t.chain().focus().addColumnBefore().run(),"aria-label":"Insert column before",children:m.jsx(Q3,{size:15})})}),m.jsx(T.Tooltip,{content:"Insert column after",children:m.jsx("button",{type:"button",className:Q.button,onClick:()=>t.chain().focus().addColumnAfter().run(),"aria-label":"Insert column after",children:m.jsx(Z3,{size:15})})}),m.jsx(T.Tooltip,{content:"Delete column",children:m.jsx("button",{type:"button",className:Q.button,onClick:()=>t.chain().focus().deleteColumn().run(),"aria-label":"Delete column",children:m.jsx(q3,{size:15})})}),m.jsx("span",{className:Q.divider}),m.jsx(T.Tooltip,{content:"Insert row above",children:m.jsx("button",{type:"button",className:Q.button,onClick:()=>t.chain().focus().addRowBefore().run(),"aria-label":"Insert row above",children:m.jsx(X3,{size:15})})}),m.jsx(T.Tooltip,{content:"Insert row below",children:m.jsx("button",{type:"button",className:Q.button,onClick:()=>t.chain().focus().addRowAfter().run(),"aria-label":"Insert row below",children:m.jsx(eO,{size:15})})}),m.jsx(T.Tooltip,{content:"Delete row",children:m.jsx("button",{type:"button",className:Q.button,onClick:()=>t.chain().focus().deleteRow().run(),"aria-label":"Delete row",children:m.jsx(O3,{size:15})})}),m.jsx("span",{className:Q.divider}),m.jsx(T.Tooltip,{content:"Toggle header row",children:m.jsx("button",{type:"button",className:[Q.button,e.headerRow&&Q.active].filter(Boolean).join(" "),onClick:()=>t.chain().focus().toggleHeaderRow().run(),"aria-label":"Toggle header row",children:m.jsx(D3,{size:15})})}),e.canSplit?m.jsx(T.Tooltip,{content:"Split cell",children:m.jsx("button",{type:"button",className:Q.button,onClick:()=>t.chain().focus().splitCell().run(),"aria-label":"Split cell",children:m.jsx(T3,{size:15})})}):m.jsx(T.Tooltip,{content:"Merge cells",children:m.jsx("button",{type:"button",className:Q.button,disabled:!e.canMerge,onClick:()=>t.chain().focus().mergeCells().run(),"aria-label":"Merge cells",children:m.jsx(E3,{size:15})})}),m.jsx("span",{className:Q.divider}),m.jsx(T.Tooltip,{content:"Delete table",children:m.jsx("button",{type:"button",className:Q.button,onClick:()=>t.chain().focus().deleteTable().run(),"aria-label":"Delete table",children:m.jsx(St,{size:15})})})]})})}const bg=[1,2,3,4,5,6],Nj={1:Ed,2:Td,3:Sd,4:Cd,5:Md,6:Ad};function Oj(t){const e=t.trim();return e?/^(https?:\/\/|mailto:|tel:|#|\/)/i.test(e)?e:`https://${e}`:""}function kv({editor:t}){const[e,n]=S.useState(!1),[r,s]=S.useState(""),[i,o]=S.useState(!1),[l,a]=S.useState("text"),[c,u]=S.useState(!1),d=S.useRef(null),h=S.useRef(null),f=vo({editor:t,selector:({editor:x})=>({bold:x.isActive("bold"),italic:x.isActive("italic"),underline:x.isActive("underline"),strike:x.isActive("strike"),code:x.isActive("code"),blockquote:x.isActive("blockquote"),bulletList:x.isActive("bulletList"),orderedList:x.isActive("orderedList"),link:x.isActive("link"),headingLevel:bg.find(k=>x.isActive("heading",{level:k}))??null,textColor:x.getAttributes("textStyle").color??"",highlightColor:x.getAttributes("highlight").color??""})});S.useEffect(()=>{var x;e&&((x=d.current)==null||x.focus())},[e]),S.useEffect(()=>{function x(){n(!1),o(!1),u(!1)}return t.on("selectionUpdate",x),()=>{t.off("selectionUpdate",x)}},[t]);function p(){const{from:x,to:k}=t.state.selection;h.current={from:x,to:k}}function g(){const x=t.chain().focus(),k=h.current;return k&&k.from!==k.to?x.setTextSelection(k):x}function y(x){l==="text"?g().setColor(x).run():g().setHighlight({color:x}).run()}function b(){s(t.getAttributes("link").href??""),n(!0)}function w(){const x=Oj(r);x?t.chain().focus().extendMarkRange("link").setLink({href:x}).run():t.chain().focus().extendMarkRange("link").unsetLink().run(),n(!1)}const v=f.headingLevel?`H${f.headingLevel}`:f.blockquote?"Quote":"Text";return m.jsx(xv,{editor:t,options:{placement:"top",offset:8},shouldShow:({editor:x,state:k,from:C,to:M})=>!x.isEditable||C===M||k.selection instanceof Y||cf(x)||x.isActive("codeBlock")?!1:k.doc.textBetween(C,M," "," ").trim().length>0,className:Q.menu,children:e?m.jsxs("div",{className:Q.linkRow,children:[m.jsx("input",{ref:d,type:"text",className:Q.linkInput,value:r,placeholder:"Paste or type a link",onChange:x=>s(x.target.value),onKeyDown:x=>{x.key==="Enter"&&(x.preventDefault(),w()),x.key==="Escape"&&(x.preventDefault(),n(!1))}}),m.jsx("button",{type:"button",className:Q.button,onClick:w,"aria-label":"Apply link",children:m.jsx(Y3,{size:15})})]}):m.jsxs("div",{className:Q.row,children:[m.jsxs("div",{className:Q.panelWrap,children:[m.jsxs("button",{type:"button",className:[Q.styleTrigger,c&&Q.active].filter(Boolean).join(" "),onMouseDown:x=>{x.preventDefault(),c||p(),u(k=>!k)},"aria-label":"Text style",children:[m.jsx("span",{children:v}),m.jsx(wl,{size:12})]}),c&&m.jsx("div",{className:Q.dropdown,onMouseDown:x=>x.preventDefault(),children:m.jsxs(T.Menu,{children:[m.jsx(T.MenuItemRadio,{label:"Text",leftIcon:m.jsx(bd,{size:16}),checked:!f.headingLevel&&!f.blockquote,onClick:()=>{g().setParagraph().run(),u(!1)}}),bg.map(x=>{const k=Nj[x];return m.jsx(T.MenuItemRadio,{label:`Heading ${x}`,leftIcon:m.jsx(k,{size:16}),checked:f.headingLevel===x,onClick:()=>{g().toggleHeading({level:x}).run(),u(!1)}},x)}),m.jsx(T.MenuItemRadio,{label:"Quote",leftIcon:m.jsx(tw,{size:16}),checked:f.blockquote,onClick:()=>{g().toggleBlockquote().run(),u(!1)}})]})})]}),m.jsx("span",{className:Q.divider}),m.jsx(T.Tooltip,{content:"Bold",children:m.jsx("button",{type:"button",className:[Q.button,f.bold&&Q.active].filter(Boolean).join(" "),onClick:()=>t.chain().focus().toggleBold().run(),"aria-label":"Bold",children:m.jsx(_d,{size:15})})}),m.jsx(T.Tooltip,{content:"Italic",children:m.jsx("button",{type:"button",className:[Q.button,f.italic&&Q.active].filter(Boolean).join(" "),onClick:()=>t.chain().focus().toggleItalic().run(),"aria-label":"Italic",children:m.jsx(vd,{size:15})})}),m.jsx(T.Tooltip,{content:"Underline",children:m.jsx("button",{type:"button",className:[Q.button,f.underline&&Q.active].filter(Boolean).join(" "),onClick:()=>t.chain().focus().toggleUnderline().run(),"aria-label":"Underline",children:m.jsx(Yb,{size:15})})}),m.jsx(T.Tooltip,{content:"Strikethrough",children:m.jsx("button",{type:"button",className:[Q.button,f.strike&&Q.active].filter(Boolean).join(" "),onClick:()=>t.chain().focus().toggleStrike().run(),"aria-label":"Strikethrough",children:m.jsx(uw,{size:15})})}),m.jsx(T.Tooltip,{content:"Inline code",children:m.jsx("button",{type:"button",className:[Q.button,f.code&&Q.active].filter(Boolean).join(" "),onClick:()=>t.chain().focus().toggleCode().run(),"aria-label":"Inline code",children:m.jsx(nc,{size:15})})}),m.jsx("span",{className:Q.divider}),m.jsx(T.Tooltip,{content:"Bulleted list",children:m.jsx("button",{type:"button",className:[Q.button,f.bulletList&&Q.active].filter(Boolean).join(" "),onClick:()=>t.chain().focus().toggleBulletList().run(),"aria-label":"Bulleted list",children:m.jsx(ga,{size:15})})}),m.jsx(T.Tooltip,{content:"Numbered list",children:m.jsx("button",{type:"button",className:[Q.button,f.orderedList&&Q.active].filter(Boolean).join(" "),onClick:()=>t.chain().focus().toggleOrderedList().run(),"aria-label":"Numbered list",children:m.jsx(Nw,{size:15})})}),m.jsx("span",{className:Q.divider}),m.jsxs("div",{className:Q.panelWrap,children:[m.jsx("button",{type:"button",className:[Q.button,i&&Q.active].filter(Boolean).join(" "),onMouseDown:x=>{x.preventDefault(),i||p(),o(k=>!k)},"aria-label":"Colour",children:m.jsx(kw,{size:15})}),i&&m.jsx("div",{className:`${Q.dropdown} ${Q.colorDropdown}`,onMouseDown:x=>x.preventDefault(),children:m.jsxs("div",{className:Q.colorPanel,children:[m.jsxs("div",{className:Q.colorTabs,children:[m.jsx("button",{type:"button",className:[Q.colorTab,l==="text"&&Q.colorTabActive].filter(Boolean).join(" "),onClick:()=>a("text"),children:"Text"}),m.jsx("button",{type:"button",className:[Q.colorTab,l==="bg"&&Q.colorTabActive].filter(Boolean).join(" "),onClick:()=>a("bg"),children:"Background"})]}),m.jsx("div",{className:Q.colorPickerBody,children:m.jsx(T.ColorPicker,{alwaysOpen:!0,value:l==="text"?f.textColor:f.highlightColor,onChange:y})})]})})]}),m.jsx("span",{className:Q.divider}),m.jsx(T.Tooltip,{content:f.link?"Edit link":"Add link",children:m.jsx("button",{type:"button",className:[Q.button,f.link&&Q.active].filter(Boolean).join(" "),onClick:b,"aria-label":f.link?"Edit link":"Add link",children:m.jsx(xd,{size:15})})}),f.link&&m.jsx(T.Tooltip,{content:"Remove link",children:m.jsx("button",{type:"button",className:Q.button,onClick:()=>t.chain().focus().extendMarkRange("link").unsetLink().run(),"aria-label":"Remove link",children:m.jsx(v3,{size:15})})})]})})}const Yt=()=>new Map,Dd=t=>{const e=Yt();return t.forEach((n,r)=>{e.set(r,n)}),e},Fn=(t,e,n)=>{let r=t.get(e);return r===void 0&&t.set(e,r=n()),r},Ij=(t,e)=>{const n=[];for(const[r,s]of t)n.push(e(s,r));return n},Dj=(t,e)=>{for(const[n,r]of t)if(e(r,n))return!0;return!1},Kr=()=>new Set,hu=t=>t[t.length-1],Rj=(t,e)=>{for(let n=0;n<e.length;n++)t.push(e[n])},qr=Array.from,uf=(t,e)=>{for(let n=0;n<t.length;n++)if(!e(t[n],n,t))return!1;return!0},df=(t,e)=>{for(let n=0;n<t.length;n++)if(e(t[n],n,t))return!0;return!1},Lj=(t,e)=>{const n=new Array(t);for(let r=0;r<t;r++)n[r]=e(r,n);return n},Ds=Array.isArray;class Sv{constructor(){this._observers=Yt()}on(e,n){return Fn(this._observers,e,Kr).add(n),n}once(e,n){const r=(...s)=>{this.off(e,r),n(...s)};this.on(e,r)}off(e,n){const r=this._observers.get(e);r!==void 0&&(r.delete(n),r.size===0&&this._observers.delete(e))}emit(e,n){return qr((this._observers.get(e)||Yt()).values()).forEach(r=>r(...n))}destroy(){this._observers=Yt()}}const Qt=Math.floor,xl=Math.abs,Jr=(t,e)=>t<e?t:e,fr=(t,e)=>t>e?t:e,Cv=t=>t!==0?t<0:1/t<0,wg=1,xg=2,fu=4,pu=8,ro=32,Ln=64,mt=128,jj=1<<29,lc=31,Rd=63,Pr=127,Pj=2147483647,xa=Number.MAX_SAFE_INTEGER,vg=Number.MIN_SAFE_INTEGER,Bj=Number.isInteger||(t=>typeof t=="number"&&isFinite(t)&&Qt(t)===t),Mv=String.fromCharCode,Hj=t=>t.toLowerCase(),zj=/^\s*/g,$j=t=>t.replace(zj,""),Vj=/([A-Z])/g,kg=(t,e)=>$j(t.replace(Vj,n=>`${e}${Hj(n)}`)),Fj=t=>{const e=unescape(encodeURIComponent(t)),n=e.length,r=new Uint8Array(n);for(let s=0;s<n;s++)r[s]=e.codePointAt(s);return r},so=typeof TextEncoder<"u"?new TextEncoder:null,Uj=t=>so.encode(t),Wj=so?Uj:Fj;let Hi=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});Hi&&Hi.decode(new Uint8Array).length===1&&(Hi=null);const Kj=(t,e)=>Lj(e,()=>t).join("");class So{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const Co=()=>new So,qj=t=>{const e=Co();return t(e),Jt(e)},Jj=t=>{let e=t.cpos;for(let n=0;n<t.bufs.length;n++)e+=t.bufs[n].length;return e},Jt=t=>{const e=new Uint8Array(Jj(t));let n=0;for(let r=0;r<t.bufs.length;r++){const s=t.bufs[r];e.set(s,n),n+=s.length}return e.set(new Uint8Array(t.cbuf.buffer,0,t.cpos),n),e},Gj=(t,e)=>{const n=t.cbuf.length;n-t.cpos<e&&(t.bufs.push(new Uint8Array(t.cbuf.buffer,0,t.cpos)),t.cbuf=new Uint8Array(fr(n,e)*2),t.cpos=0)},Ve=(t,e)=>{const n=t.cbuf.length;t.cpos===n&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(n*2),t.cpos=0),t.cbuf[t.cpos++]=e},Ld=Ve,ue=(t,e)=>{for(;e>Pr;)Ve(t,mt|Pr&e),e=Qt(e/128);Ve(t,Pr&e)},hf=(t,e)=>{const n=Cv(e);for(n&&(e=-e),Ve(t,(e>Rd?mt:0)|(n?Ln:0)|Rd&e),e=Qt(e/64);e>0;)Ve(t,(e>Pr?mt:0)|Pr&e),e=Qt(e/128)},jd=new Uint8Array(3e4),Yj=jd.length/3,Xj=(t,e)=>{if(e.length<Yj){const n=so.encodeInto(e,jd).written||0;ue(t,n);for(let r=0;r<n;r++)Ve(t,jd[r])}else At(t,Wj(e))},Zj=(t,e)=>{const n=unescape(encodeURIComponent(e)),r=n.length;ue(t,r);for(let s=0;s<r;s++)Ve(t,n.codePointAt(s))},ys=so&&so.encodeInto?Xj:Zj,ac=(t,e)=>{const n=t.cbuf.length,r=t.cpos,s=Jr(n-r,e.length),i=e.length-s;t.cbuf.set(e.subarray(0,s),r),t.cpos+=s,i>0&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(fr(n*2,i)),t.cbuf.set(e.subarray(s)),t.cpos=i)},At=(t,e)=>{ue(t,e.byteLength),ac(t,e)},ff=(t,e)=>{Gj(t,e);const n=new DataView(t.cbuf.buffer,t.cpos,e);return t.cpos+=e,n},Qj=(t,e)=>ff(t,4).setFloat32(0,e,!1),eP=(t,e)=>ff(t,8).setFloat64(0,e,!1),tP=(t,e)=>ff(t,8).setBigInt64(0,e,!1),Sg=new DataView(new ArrayBuffer(4)),nP=t=>(Sg.setFloat32(0,t),Sg.getFloat32(0)===t),Rs=(t,e)=>{switch(typeof e){case"string":Ve(t,119),ys(t,e);break;case"number":Bj(e)&&xl(e)<=Pj?(Ve(t,125),hf(t,e)):nP(e)?(Ve(t,124),Qj(t,e)):(Ve(t,123),eP(t,e));break;case"bigint":Ve(t,122),tP(t,e);break;case"object":if(e===null)Ve(t,126);else if(Ds(e)){Ve(t,117),ue(t,e.length);for(let n=0;n<e.length;n++)Rs(t,e[n])}else if(e instanceof Uint8Array)Ve(t,116),At(t,e);else{Ve(t,118);const n=Object.keys(e);ue(t,n.length);for(let r=0;r<n.length;r++){const s=n[r];ys(t,s),Rs(t,e[s])}}break;case"boolean":Ve(t,e?120:121);break;default:Ve(t,127)}};class Cg extends So{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&ue(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}}const Mg=t=>{t.count>0&&(hf(t.encoder,t.count===1?t.s:-t.s),t.count>1&&ue(t.encoder,t.count-2))};class vl{constructor(){this.encoder=new So,this.s=0,this.count=0}write(e){this.s===e?this.count++:(Mg(this),this.count=1,this.s=e)}toUint8Array(){return Mg(this),Jt(this.encoder)}}const Ag=t=>{if(t.count>0){const e=t.diff*2+(t.count===1?0:1);hf(t.encoder,e),t.count>1&&ue(t.encoder,t.count-2)}};class mu{constructor(){this.encoder=new So,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(Ag(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return Ag(this),Jt(this.encoder)}}class rP{constructor(){this.sarr=[],this.s="",this.lensE=new vl}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=""),this.lensE.write(e.length)}toUint8Array(){const e=new So;return this.sarr.push(this.s),this.s="",ys(e,this.sarr.join("")),ac(e,this.lensE.toUint8Array()),Jt(e)}}const yn=t=>new Error(t),zt=()=>{throw yn("Method unimplemented")},bt=()=>{throw yn("Unexpected case")},Av=yn("Unexpected end of array"),Ev=yn("Integer out of Range");class cc{constructor(e){this.arr=e,this.pos=0}}const pf=t=>new cc(t),sP=t=>t.pos!==t.arr.length,iP=(t,e)=>{const n=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,n},Rt=t=>iP(t,Ce(t)),io=t=>t.arr[t.pos++],Ce=t=>{let e=0,n=1;const r=t.arr.length;for(;t.pos<r;){const s=t.arr[t.pos++];if(e=e+(s&Pr)*n,n*=128,s<mt)return e;if(e>xa)throw Ev}throw Av},mf=t=>{let e=t.arr[t.pos++],n=e&Rd,r=64;const s=(e&Ln)>0?-1:1;if(!(e&mt))return s*n;const i=t.arr.length;for(;t.pos<i;){if(e=t.arr[t.pos++],n=n+(e&Pr)*r,r*=128,e<mt)return s*n;if(n>xa)throw Ev}throw Av},oP=t=>{let e=Ce(t);if(e===0)return"";{let n=String.fromCodePoint(io(t));if(--e<100)for(;e--;)n+=String.fromCodePoint(io(t));else for(;e>0;){const r=e<1e4?e:1e4,s=t.arr.subarray(t.pos,t.pos+r);t.pos+=r,n+=String.fromCodePoint.apply(null,s),e-=r}return decodeURIComponent(escape(n))}},lP=t=>Hi.decode(Rt(t)),Pd=Hi?lP:oP,gf=(t,e)=>{const n=new DataView(t.arr.buffer,t.arr.byteOffset+t.pos,e);return t.pos+=e,n},aP=t=>gf(t,4).getFloat32(0,!1),cP=t=>gf(t,8).getFloat64(0,!1),uP=t=>gf(t,8).getBigInt64(0,!1),dP=[t=>{},t=>null,mf,aP,cP,uP,t=>!1,t=>!0,Pd,t=>{const e=Ce(t),n={};for(let r=0;r<e;r++){const s=Pd(t);n[s]=va(t)}return n},t=>{const e=Ce(t),n=[];for(let r=0;r<e;r++)n.push(va(t));return n},Rt],va=t=>dP[127-io(t)](t);class Eg extends cc{constructor(e,n){super(e),this.reader=n,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),sP(this)?this.count=Ce(this)+1:this.count=-1),this.count--,this.s}}class kl extends cc{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=mf(this);const e=Cv(this.s);this.count=1,e&&(this.s=-this.s,this.count=Ce(this)+2)}return this.count--,this.s}}class gu extends cc{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){const e=mf(this),n=e&1;this.diff=Qt(e/2),this.count=1,n&&(this.count=Ce(this)+2)}return this.s+=this.diff,this.count--,this.s}}class hP{constructor(e){this.decoder=new kl(e),this.str=Pd(this.decoder),this.spos=0}read(){const e=this.spos+this.decoder.read(),n=this.str.slice(this.spos,e);return this.spos=e,n}}const fP=crypto.getRandomValues.bind(crypto),pP=Math.random,Tv=()=>fP(new Uint32Array(1))[0],mP=t=>t[Qt(pP()*t.length)],gP="10000000-1000-4000-8000"+-1e11,yP=()=>gP.replace(/[018]/g,t=>(t^Tv()&15>>t/4).toString(16)),bP=Date.now,Tg=t=>new Promise(t);Promise.all.bind(Promise);const _g=t=>t===void 0?null:t;class wP{constructor(){this.map=new Map}setItem(e,n){this.map.set(e,n)}getItem(e){return this.map.get(e)}}let _v=new wP,xP=!0;try{typeof localStorage<"u"&&localStorage&&(_v=localStorage,xP=!1)}catch{}const vP=_v,oo=Symbol("Equality"),Nv=(t,e)=>{var n;return t===e||!!((n=t==null?void 0:t[oo])!=null&&n.call(t,e))||!1},kP=t=>typeof t=="object",SP=Object.assign,Ov=Object.keys,CP=(t,e)=>{for(const n in t)e(t[n],n)},ka=t=>Ov(t).length,MP=t=>{for(const e in t)return!1;return!0},Ws=(t,e)=>{for(const n in t)if(!e(t[n],n))return!1;return!0},yf=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),AP=(t,e)=>t===e||ka(t)===ka(e)&&Ws(t,(n,r)=>(n!==void 0||yf(e,r))&&Nv(e[r],n)),EP=Object.freeze,Iv=t=>{for(const e in t){const n=t[e];(typeof n=="object"||typeof n=="function")&&Iv(t[e])}return EP(t)},bf=(t,e,n=0)=>{try{for(;n<t.length;n++)t[n](...e)}finally{n<t.length&&bf(t,e,n+1)}},Sl=(t,e)=>{if(t===e)return!0;if(t==null||e==null||t.constructor!==e.constructor&&(t.constructor||Object)!==(e.constructor||Object))return!1;if(t[oo]!=null)return t[oo](e);switch(t.constructor){case ArrayBuffer:t=new Uint8Array(t),e=new Uint8Array(e);case Uint8Array:{if(t.byteLength!==e.byteLength)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;break}case Set:{if(t.size!==e.size)return!1;for(const n of t)if(!e.has(n))return!1;break}case Map:{if(t.size!==e.size)return!1;for(const n of t.keys())if(!e.has(n)||!Sl(t.get(n),e.get(n)))return!1;break}case void 0:case Object:if(ka(t)!==ka(e))return!1;for(const n in t)if(!yf(t,n)||!Sl(t[n],e[n]))return!1;break;case Array:if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(!Sl(t[n],e[n]))return!1;break;default:return!1}return!0},TP=(t,e)=>e.includes(t),Ls=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]",Dv=typeof window<"u"&&typeof document<"u"&&!Ls;let on;const _P=()=>{if(on===void 0)if(Ls){on=Yt();const t=process.argv;let e=null;for(let n=0;n<t.length;n++){const r=t[n];r[0]==="-"?(e!==null&&on.set(e,""),e=r):e!==null&&(on.set(e,r),e=null)}e!==null&&on.set(e,"")}else typeof location=="object"?(on=Yt(),(location.search||"?").slice(1).split("&").forEach(t=>{if(t.length!==0){const[e,n]=t.split("=");on.set(`--${kg(e,"-")}`,n),on.set(`-${kg(e,"-")}`,n)}})):on=Yt();return on},Bd=t=>_P().has(t),Sa=t=>_g(Ls?process.env[t.toUpperCase().replaceAll("-","_")]:vP.getItem(t)),Rv=t=>Bd("--"+t)||Sa(t)!==null,NP=Rv("production"),OP=Ls&&TP(process.env.FORCE_COLOR,["true","1","2"]),IP=OP||!Bd("--no-colors")&&!Rv("no-color")&&(!Ls||process.stdout.isTTY)&&(!Ls||Bd("--color")||Sa("COLORTERM")!==null||(Sa("TERM")||"").includes("color")),DP=t=>{let e="";for(let n=0;n<t.byteLength;n++)e+=Mv(t[n]);return btoa(e)},RP=t=>Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("base64"),LP=Dv?DP:RP,jP=t=>qj(e=>Rs(e,t));class PP{constructor(e,n){this.left=e,this.right=n}}const An=(t,e)=>new PP(t,e),Ng=t=>t.next()>=.5,yu=(t,e,n)=>Qt(t.next()*(n+1-e)+e),Lv=(t,e,n)=>Qt(t.next()*(n+1-e)+e),wf=(t,e,n)=>Lv(t,e,n),BP=t=>Mv(wf(t,97,122)),HP=(t,e=0,n=20)=>{const r=wf(t,e,n);let s="";for(let i=0;i<r;i++)s+=BP(t);return s},bu=(t,e)=>e[wf(t,0,e.length-1)],zP=Symbol("0schema");class $P{constructor(){this._rerrs=[]}extend(e,n,r,s=null){this._rerrs.push({path:e,expected:n,has:r,message:s})}toString(){const e=[];for(let n=this._rerrs.length-1;n>0;n--){const r=this._rerrs[n];e.push(Kj(" ",(this._rerrs.length-n)*2)+`${r.path!=null?`[${r.path}] `:""}${r.has} doesn't match ${r.expected}. ${r.message}`)}return e.join(`
|
|
454
|
+
`)}}const Hd=(t,e)=>t===e?!0:t==null||e==null||t.constructor!==e.constructor?!1:t[oo]?Nv(t,e):Ds(t)?uf(t,n=>df(e,r=>Hd(n,r))):kP(t)?Ws(t,(n,r)=>Hd(n,e[r])):!1;class ct{extends(e){let[n,r]=[this.shape,e.shape];return this.constructor._dilutes&&([r,n]=[n,r]),Hd(n,r)}equals(e){return this.constructor===e.constructor&&Sl(this.shape,e.shape)}[zP](){return!0}[oo](e){return this.equals(e)}validate(e){return this.check(e)}check(e,n){zt()}get nullable(){return Ks(this,pc)}get optional(){return new Bv(this)}cast(e){return Og(e,this),e}expect(e){return Og(e,this),e}}_o(ct,"_dilutes",!1);class xf extends ct{constructor(e,n){super(),this.shape=e,this._c=n}check(e,n=void 0){const r=(e==null?void 0:e.constructor)===this.shape&&(this._c==null||this._c(e));return!r&&(n==null||n.extend(null,this.shape.name,e==null?void 0:e.constructor.name,(e==null?void 0:e.constructor)!==this.shape?"Constructor match failed":"Check failed")),r}}const Pe=(t,e=null)=>new xf(t,e);Pe(xf);class vf extends ct{constructor(e){super(),this.shape=e}check(e,n){const r=this.shape(e);return!r&&(n==null||n.extend(null,"custom prop",e==null?void 0:e.constructor.name,"failed to check custom prop")),r}}const qe=t=>new vf(t);Pe(vf);class uc extends ct{constructor(e){super(),this.shape=e}check(e,n){const r=this.shape.some(s=>s===e);return!r&&(n==null||n.extend(null,this.shape.join(" | "),e.toString())),r}}const dc=(...t)=>new uc(t),jv=Pe(uc),VP=RegExp.escape||(t=>t.replace(/[().|&,$^[\]]/g,e=>"\\"+e)),Pv=t=>{if(js.check(t))return[VP(t)];if(jv.check(t))return t.shape.map(e=>e+"");if(qv.check(t))return["[+-]?\\d+.?\\d*"];if(Jv.check(t))return[".*"];if(Ma.check(t))return t.shape.map(Pv).flat(1);bt()};class FP extends ct{constructor(e){super(),this.shape=e,this._r=new RegExp("^"+e.map(Pv).map(n=>`(${n.join("|")})`).join("")+"$")}check(e,n){const r=this._r.exec(e)!=null;return!r&&(n==null||n.extend(null,this._r.toString(),e.toString(),"String doesn't match string template.")),r}}Pe(FP);const UP=Symbol("optional");class Bv extends ct{constructor(e){super(),this.shape=e}check(e,n){const r=e===void 0||this.shape.check(e);return!r&&(n==null||n.extend(null,"undefined (optional)","()")),r}get[UP](){return!0}}const WP=Pe(Bv);class KP extends ct{check(e,n){return n==null||n.extend(null,"never",typeof e),!1}}Pe(KP);const Ha=class Ha extends ct{constructor(e,n=!1){super(),this.shape=e,this._isPartial=n}get partial(){return new Ha(this.shape,!0)}check(e,n){return e==null?(n==null||n.extend(null,"object","null"),!1):Ws(this.shape,(r,s)=>{const i=this._isPartial&&!yf(e,s)||r.check(e[s],n);return!i&&(n==null||n.extend(s.toString(),r.toString(),typeof e[s],"Object property does not match")),i})}};_o(Ha,"_dilutes",!0);let Ca=Ha;const qP=t=>new Ca(t),JP=Pe(Ca),GP=qe(t=>t!=null&&(t.constructor===Object||t.constructor==null));class Hv extends ct{constructor(e,n){super(),this.shape={keys:e,values:n}}check(e,n){return e!=null&&Ws(e,(r,s)=>{const i=this.shape.keys.check(s,n);return!i&&(n==null||n.extend(s+"","Record",typeof e,i?"Key doesn't match schema":"Value doesn't match value")),i&&this.shape.values.check(r,n)})}}const zv=(t,e)=>new Hv(t,e),YP=Pe(Hv);class $v extends ct{constructor(e){super(),this.shape=e}check(e,n){return e!=null&&Ws(this.shape,(r,s)=>{const i=r.check(e[s],n);return!i&&(n==null||n.extend(s.toString(),"Tuple",typeof r)),i})}}const XP=(...t)=>new $v(t);Pe($v);class Vv extends ct{constructor(e){super(),this.shape=e.length===1?e[0]:new hc(e)}check(e,n){const r=Ds(e)&&uf(e,s=>this.shape.check(s));return!r&&(n==null||n.extend(null,"Array","")),r}}const Fv=(...t)=>new Vv(t),ZP=Pe(Vv),QP=qe(t=>Ds(t));class Uv extends ct{constructor(e,n){super(),this.shape=e,this._c=n}check(e,n){const r=e instanceof this.shape&&(this._c==null||this._c(e));return!r&&(n==null||n.extend(null,this.shape.name,e==null?void 0:e.constructor.name)),r}}const e6=(t,e=null)=>new Uv(t,e);Pe(Uv);const t6=e6(ct);class n6 extends ct{constructor(e){super(),this.len=e.length-1,this.args=XP(...e.slice(-1)),this.res=e[this.len]}check(e,n){const r=e.constructor===Function&&e.length<=this.len;return!r&&(n==null||n.extend(null,"function",typeof e)),r}}const r6=Pe(n6),s6=qe(t=>typeof t=="function");class i6 extends ct{constructor(e){super(),this.shape=e}check(e,n){const r=uf(this.shape,s=>s.check(e,n));return!r&&(n==null||n.extend(null,"Intersectinon",typeof e)),r}}Pe(i6,t=>t.shape.length>0);class hc extends ct{constructor(e){super(),this.shape=e}check(e,n){const r=df(this.shape,s=>s.check(e,n));return n==null||n.extend(null,"Union",typeof e),r}}_o(hc,"_dilutes",!0);const Ks=(...t)=>t.findIndex(e=>Ma.check(e))>=0?Ks(...t.map(e=>lo(e)).map(e=>Ma.check(e)?e.shape:[e]).flat(1)):t.length===1?t[0]:new hc(t),Ma=Pe(hc),Wv=()=>!0,Aa=qe(Wv),o6=Pe(vf,t=>t.shape===Wv),kf=qe(t=>typeof t=="bigint"),l6=qe(t=>t===kf),Kv=qe(t=>typeof t=="symbol");qe(t=>t===Kv);const bs=qe(t=>typeof t=="number"),qv=qe(t=>t===bs),js=qe(t=>typeof t=="string"),Jv=qe(t=>t===js),fc=qe(t=>typeof t=="boolean"),a6=qe(t=>t===fc),Gv=dc(void 0);Pe(uc,t=>t.shape.length===1&&t.shape[0]===void 0);dc(void 0);const pc=dc(null),c6=Pe(uc,t=>t.shape.length===1&&t.shape[0]===null);Pe(Uint8Array);Pe(xf,t=>t.shape===Uint8Array);const u6=Ks(bs,js,pc,Gv,kf,fc,Kv);(()=>{const t=Fv(Aa),e=zv(js,Aa),n=Ks(bs,js,pc,fc,t,e);return t.shape=n,e.shape.values=n,n})();const lo=t=>{if(t6.check(t))return t;if(GP.check(t)){const e={};for(const n in t)e[n]=lo(t[n]);return qP(e)}else{if(QP.check(t))return Ks(...t.map(lo));if(u6.check(t))return dc(t);if(s6.check(t))return Pe(t)}bt()},Og=NP?()=>{}:(t,e)=>{const n=new $P;if(!e.check(t,n))throw yn(`Expected value to be of type ${e.constructor.name}.
|
|
455
|
+
${n.toString()}`)};class d6{constructor(e){this.patterns=[],this.$state=e}if(e,n){return this.patterns.push({if:lo(e),h:n}),this}else(e){return this.if(Aa,e)}done(){return(e,n)=>{for(let r=0;r<this.patterns.length;r++){const s=this.patterns[r];if(s.if.check(e))return s.h(e,n)}throw yn("Unhandled pattern")}}}const h6=t=>new d6(t),Yv=h6(Aa).if(qv,(t,e)=>yu(e,vg,xa)).if(Jv,(t,e)=>HP(e)).if(a6,(t,e)=>Ng(e)).if(l6,(t,e)=>BigInt(yu(e,vg,xa))).if(Ma,(t,e)=>ss(e,bu(e,t.shape))).if(JP,(t,e)=>{const n={};for(const r in t.shape){let s=t.shape[r];if(WP.check(s)){if(Ng(e))continue;s=s.shape}n[r]=Yv(s,e)}return n}).if(ZP,(t,e)=>{const n=[],r=Lv(e,0,42);for(let s=0;s<r;s++)n.push(ss(e,t.shape));return n}).if(jv,(t,e)=>bu(e,t.shape)).if(c6,(t,e)=>null).if(r6,(t,e)=>{const n=ss(e,t.res);return()=>n}).if(o6,(t,e)=>ss(e,bu(e,[bs,js,pc,Gv,kf,fc,Fv(bs),zv(Ks("a","b","c"),bs)]))).if(YP,(t,e)=>{const n={},r=yu(e,0,3);for(let s=0;s<r;s++){const i=ss(e,t.shape.keys),o=ss(e,t.shape.values);n[i]=o}return n}).done(),ss=(t,e)=>Yv(lo(e),t),Mo=typeof document<"u"?document:{};qe(t=>t.nodeType===y6);typeof DOMParser<"u"&&new DOMParser;qe(t=>t.nodeType===p6);qe(t=>t.nodeType===m6);const f6=t=>Ij(t,(e,n)=>`${n}:${e};`).join(""),p6=Mo.ELEMENT_NODE,m6=Mo.TEXT_NODE,g6=Mo.DOCUMENT_NODE,y6=Mo.DOCUMENT_FRAGMENT_NODE;qe(t=>t.nodeType===g6);const b6=t=>class{constructor(n){this._=n}destroy(){t(this._)}},w6=b6(clearTimeout),Xv=(t,e)=>new w6(setTimeout(e,t)),Un=Symbol,Zv=Un(),Qv=Un(),x6=Un(),v6=Un(),k6=Un(),ek=Un(),S6=Un(),Sf=Un(),C6=Un(),M6=t=>{var s;t.length===1&&((s=t[0])==null?void 0:s.constructor)===Function&&(t=t[0]());const e=[],n=[];let r=0;for(;r<t.length;r++){const i=t[r];if(i===void 0)break;if(i.constructor===String||i.constructor===Number)e.push(i);else if(i.constructor===Object)break}for(r>0&&n.push(e.join(""));r<t.length;r++){const i=t[r];i instanceof Symbol||n.push(i)}return n},A6={[Zv]:An("font-weight","bold"),[Qv]:An("font-weight","normal"),[x6]:An("color","blue"),[k6]:An("color","green"),[v6]:An("color","grey"),[ek]:An("color","red"),[S6]:An("color","purple"),[Sf]:An("color","orange"),[C6]:An("color","black")},E6=t=>{var o;t.length===1&&((o=t[0])==null?void 0:o.constructor)===Function&&(t=t[0]());const e=[],n=[],r=Yt();let s=[],i=0;for(;i<t.length;i++){const l=t[i],a=A6[l];if(a!==void 0)r.set(a.left,a.right);else{if(l===void 0)break;if(l.constructor===String||l.constructor===Number){const c=f6(r);i>0||c.length>0?(e.push("%c"+l),n.push(c)):e.push(l)}else break}}for(i>0&&(s=n,s.unshift(e.join("")));i<t.length;i++){const l=t[i];l instanceof Symbol||s.push(l)}return s},tk=IP?E6:M6,T6=(...t)=>{console.log(...tk(t)),rk.forEach(e=>e.print(t))},nk=(...t)=>{console.warn(...tk(t)),t.unshift(Sf),rk.forEach(e=>e.print(t))},rk=Kr(),sk=t=>({[Symbol.iterator](){return this},next:t}),_6=(t,e)=>sk(()=>{let n;do n=t.next();while(!n.done&&!e(n.value));return n}),wu=(t,e)=>sk(()=>{const{done:n,value:r}=t.next();return{done:n,value:n?void 0:e(r)}});class mc{constructor(e,n){this.clock=e,this.len=n}}class qs{constructor(){this.clients=new Map}}const pr=(t,e,n)=>e.clients.forEach((r,s)=>{const i=t.doc.store.clients.get(s);if(i!=null){const o=i[i.length-1],l=o.id.clock+o.length;for(let a=0,c=r[a];a<r.length&&c.clock<l;c=r[++a])fk(t,i,c.clock,c.len,n)}}),N6=(t,e)=>{let n=0,r=t.length-1;for(;n<=r;){const s=Qt((n+r)/2),i=t[s],o=i.clock;if(o<=e){if(e<o+i.len)return s;n=s+1}else r=s-1}return null},Js=(t,e)=>{const n=t.clients.get(e.client);return n!==void 0&&N6(n,e.clock)!==null},Cf=t=>{t.clients.forEach(e=>{e.sort((s,i)=>s.clock-i.clock);let n,r;for(n=1,r=1;n<e.length;n++){const s=e[r-1],i=e[n];s.clock+s.len>=i.clock?e[r-1]=new mc(s.clock,fr(s.len,i.clock+i.len-s.clock)):(r<n&&(e[r]=i),r++)}e.length=r})},zd=t=>{const e=new qs;for(let n=0;n<t.length;n++)t[n].clients.forEach((r,s)=>{if(!e.clients.has(s)){const i=r.slice();for(let o=n+1;o<t.length;o++)Rj(i,t[o].clients.get(s)||[]);e.clients.set(s,i)}});return Cf(e),e},ao=(t,e,n,r)=>{Fn(t.clients,e,()=>[]).push(new mc(n,r))},ik=()=>new qs,O6=t=>{const e=ik();return t.clients.forEach((n,r)=>{const s=[];for(let i=0;i<n.length;i++){const o=n[i];if(o.deleted){const l=o.id.clock;let a=o.length;if(i+1<n.length)for(let c=n[i+1];i+1<n.length&&c.deleted;c=n[++i+1])a+=c.length;s.push(new mc(l,a))}}s.length>0&&e.clients.set(r,s)}),e},Mf=(t,e)=>{ue(t.restEncoder,e.clients.size),qr(e.clients.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{t.resetDsCurVal(),ue(t.restEncoder,n);const s=r.length;ue(t.restEncoder,s);for(let i=0;i<s;i++){const o=r[i];t.writeDsClock(o.clock),t.writeDsLen(o.len)}})},I6=t=>{const e=new qs,n=Ce(t.restDecoder);for(let r=0;r<n;r++){t.resetDsCurVal();const s=Ce(t.restDecoder),i=Ce(t.restDecoder);if(i>0){const o=Fn(e.clients,s,()=>[]);for(let l=0;l<i;l++)o.push(new mc(t.readDsClock(),t.readDsLen()))}}return e},Ig=(t,e,n)=>{const r=new qs,s=Ce(t.restDecoder);for(let i=0;i<s;i++){t.resetDsCurVal();const o=Ce(t.restDecoder),l=Ce(t.restDecoder),a=n.clients.get(o)||[],c=Ie(n,o);for(let u=0;u<l;u++){const d=t.readDsClock(),h=d+t.readDsLen();if(d<c){c<h&&ao(r,o,c,h-c);let f=en(a,d),p=a[f];for(!p.deleted&&p.id.clock<d&&(a.splice(f+1,0,Da(e,p,d-p.id.clock)),f++);f<a.length&&(p=a[f++],p.id.clock<h);)p.deleted||(h<p.id.clock+p.length&&a.splice(f,0,Da(e,p,h-p.id.clock)),p.delete(e))}else ao(r,o,d,h-d)}}if(r.clients.size>0){const i=new gc;return ue(i.restEncoder,0),Mf(i,r),i.toUint8Array()}return null},ok=Tv;class Qr extends Sv{constructor({guid:e=yP(),collectionid:n=null,gc:r=!0,gcFilter:s=()=>!0,meta:i=null,autoLoad:o=!1,shouldLoad:l=!0}={}){super(),this.gc=r,this.gcFilter=s,this.clientID=ok(),this.guid=e,this.collectionid=n,this.share=new Map,this.store=new dk,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=l,this.autoLoad=o,this.meta=i,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=Tg(c=>{this.on("load",()=>{this.isLoaded=!0,c(this)})});const a=()=>Tg(c=>{const u=d=>{(d===void 0||d===!0)&&(this.off("sync",u),c())};this.on("sync",u)});this.on("sync",c=>{c===!1&&this.isSynced&&(this.whenSynced=a()),this.isSynced=c===void 0||c===!0,this.isSynced&&!this.isLoaded&&this.emit("load",[this])}),this.whenSynced=a()}load(){const e=this._item;e!==null&&!this.shouldLoad&&we(e.parent.doc,n=>{n.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(qr(this.subdocs).map(e=>e.guid))}transact(e,n=null){return we(this,e,n)}get(e,n=Ke){const r=Fn(this.share,e,()=>{const i=new n;return i._integrate(this,null),i}),s=r.constructor;if(n!==Ke&&s!==n)if(s===Ke){const i=new n;i._map=r._map,r._map.forEach(o=>{for(;o!==null;o=o.left)o.parent=i}),i._start=r._start;for(let o=i._start;o!==null;o=o.right)o.parent=i;return i._length=r._length,this.share.set(e,i),i._integrate(this,null),i}else throw new Error(`Type with the name ${e} has already been defined with a different constructor`);return r}getArray(e=""){return this.get(e,vs)}getText(e=""){return this.get(e,mr)}getMap(e=""){return this.get(e,Ps)}getXmlElement(e=""){return this.get(e,et)}getXmlFragment(e=""){return this.get(e,Gr)}toJSON(){const e={};return this.share.forEach((n,r)=>{e[r]=n.toJSON()}),e}destroy(){this.isDestroyed=!0,qr(this.subdocs).forEach(n=>n.destroy());const e=this._item;if(e!==null){this._item=null;const n=e.content;n.doc=new Qr({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=e,we(e.parent.doc,r=>{const s=n.doc;e.deleted||r.subdocsAdded.add(s),r.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class D6{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=Ce(this.restDecoder),this.dsCurrVal}readDsLen(){const e=Ce(this.restDecoder)+1;return this.dsCurrVal+=e,e}}class Ea extends D6{constructor(e){super(e),this.keys=[],Ce(e),this.keyClockDecoder=new gu(Rt(e)),this.clientDecoder=new kl(Rt(e)),this.leftClockDecoder=new gu(Rt(e)),this.rightClockDecoder=new gu(Rt(e)),this.infoDecoder=new Eg(Rt(e),io),this.stringDecoder=new hP(Rt(e)),this.parentInfoDecoder=new Eg(Rt(e),io),this.typeRefDecoder=new kl(Rt(e)),this.lenDecoder=new kl(Rt(e))}readLeftID(){return new ws(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new ws(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return va(this.restDecoder)}readBuf(){return Rt(this.restDecoder)}readJSON(){return va(this.restDecoder)}readKey(){const e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];{const n=this.stringDecoder.read();return this.keys.push(n),n}}}class R6{constructor(){this.restEncoder=Co()}toUint8Array(){return Jt(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){ue(this.restEncoder,e)}writeDsLen(e){ue(this.restEncoder,e)}}class L6 extends R6{writeLeftID(e){ue(this.restEncoder,e.client),ue(this.restEncoder,e.clock)}writeRightID(e){ue(this.restEncoder,e.client),ue(this.restEncoder,e.clock)}writeClient(e){ue(this.restEncoder,e)}writeInfo(e){Ld(this.restEncoder,e)}writeString(e){ys(this.restEncoder,e)}writeParentInfo(e){ue(this.restEncoder,e?1:0)}writeTypeRef(e){ue(this.restEncoder,e)}writeLen(e){ue(this.restEncoder,e)}writeAny(e){Rs(this.restEncoder,e)}writeBuf(e){At(this.restEncoder,e)}writeJSON(e){ys(this.restEncoder,JSON.stringify(e))}writeKey(e){ys(this.restEncoder,e)}}class j6{constructor(){this.restEncoder=Co(),this.dsCurrVal=0}toUint8Array(){return Jt(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){const n=e-this.dsCurrVal;this.dsCurrVal=e,ue(this.restEncoder,n)}writeDsLen(e){e===0&&bt(),ue(this.restEncoder,e-1),this.dsCurrVal+=e}}class gc extends j6{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new mu,this.clientEncoder=new vl,this.leftClockEncoder=new mu,this.rightClockEncoder=new mu,this.infoEncoder=new Cg(Ld),this.stringEncoder=new rP,this.parentInfoEncoder=new Cg(Ld),this.typeRefEncoder=new vl,this.lenEncoder=new vl}toUint8Array(){const e=Co();return ue(e,0),At(e,this.keyClockEncoder.toUint8Array()),At(e,this.clientEncoder.toUint8Array()),At(e,this.leftClockEncoder.toUint8Array()),At(e,this.rightClockEncoder.toUint8Array()),At(e,Jt(this.infoEncoder)),At(e,this.stringEncoder.toUint8Array()),At(e,Jt(this.parentInfoEncoder)),At(e,this.typeRefEncoder.toUint8Array()),At(e,this.lenEncoder.toUint8Array()),ac(e,Jt(this.restEncoder)),Jt(e)}writeLeftID(e){this.clientEncoder.write(e.client),this.leftClockEncoder.write(e.clock)}writeRightID(e){this.clientEncoder.write(e.client),this.rightClockEncoder.write(e.clock)}writeClient(e){this.clientEncoder.write(e)}writeInfo(e){this.infoEncoder.write(e)}writeString(e){this.stringEncoder.write(e)}writeParentInfo(e){this.parentInfoEncoder.write(e?1:0)}writeTypeRef(e){this.typeRefEncoder.write(e)}writeLen(e){this.lenEncoder.write(e)}writeAny(e){Rs(this.restEncoder,e)}writeBuf(e){At(this.restEncoder,e)}writeJSON(e){Rs(this.restEncoder,e)}writeKey(e){const n=this.keyMap.get(e);n===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(n)}}const P6=(t,e,n,r)=>{r=fr(r,e[0].id.clock);const s=en(e,r);ue(t.restEncoder,e.length-s),t.writeClient(n),ue(t.restEncoder,r);const i=e[s];i.write(t,r-i.id.clock);for(let o=s+1;o<e.length;o++)e[o].write(t,0)},lk=(t,e,n)=>{const r=new Map;n.forEach((s,i)=>{Ie(e,i)>s&&r.set(i,s)}),yc(e).forEach((s,i)=>{n.has(i)||r.set(i,0)}),ue(t.restEncoder,r.size),qr(r.entries()).sort((s,i)=>i[0]-s[0]).forEach(([s,i])=>{P6(t,e.clients.get(s),s,i)})},B6=(t,e)=>{const n=Yt(),r=Ce(t.restDecoder);for(let s=0;s<r;s++){const i=Ce(t.restDecoder),o=new Array(i),l=t.readClient();let a=Ce(t.restDecoder);n.set(l,{i:0,refs:o});for(let c=0;c<i;c++){const u=t.readInfo();switch(lc&u){case 0:{const d=t.readLen();o[c]=new Pt(se(l,a),d),a+=d;break}case 10:{const d=Ce(t.restDecoder);o[c]=new qt(se(l,a),d),a+=d;break}default:{const d=(u&(Ln|mt))===0,h=new pe(se(l,a),null,(u&mt)===mt?t.readLeftID():null,null,(u&Ln)===Ln?t.readRightID():null,d?t.readParentInfo()?e.get(t.readString()):t.readLeftID():null,d&&(u&ro)===ro?t.readString():null,Lk(t,u));o[c]=h,a+=h.length}}}}return n},H6=(t,e,n)=>{const r=[];let s=qr(n.keys()).sort((f,p)=>f-p);if(s.length===0)return null;const i=()=>{if(s.length===0)return null;let f=n.get(s[s.length-1]);for(;f.refs.length===f.i;)if(s.pop(),s.length>0)f=n.get(s[s.length-1]);else return null;return f};let o=i();if(o===null)return null;const l=new dk,a=new Map,c=(f,p)=>{const g=a.get(f);(g==null||g>p)&&a.set(f,p)};let u=o.refs[o.i++];const d=new Map,h=()=>{for(const f of r){const p=f.id.client,g=n.get(p);g?(g.i--,l.clients.set(p,g.refs.slice(g.i)),n.delete(p),g.i=0,g.refs=[]):l.clients.set(p,[f]),s=s.filter(y=>y!==p)}r.length=0};for(;;){if(u.constructor!==qt){const p=Fn(d,u.id.client,()=>Ie(e,u.id.client))-u.id.clock;if(p<0)r.push(u),c(u.id.client,u.id.clock-1),h();else{const g=u.getMissing(t,e);if(g!==null){r.push(u);const y=n.get(g)||{refs:[],i:0};if(y.refs.length===y.i)c(g,Ie(e,g)),h();else{u=y.refs[y.i++];continue}}else(p===0||p<u.length)&&(u.integrate(t,p),d.set(u.id.client,u.id.clock+u.length))}}if(r.length>0)u=r.pop();else if(o!==null&&o.i<o.refs.length)u=o.refs[o.i++];else{if(o=i(),o===null)break;u=o.refs[o.i++]}}if(l.clients.size>0){const f=new gc;return lk(f,l,new Map),ue(f.restEncoder,0),{missing:a,update:f.toUint8Array()}}return null},z6=(t,e)=>lk(t,e.doc.store,e.beforeState),$6=(t,e,n,r=new Ea(t))=>we(e,s=>{s.local=!1;let i=!1;const o=s.doc,l=o.store,a=B6(r,o),c=H6(s,l,a),u=l.pendingStructs;if(u){for(const[h,f]of u.missing)if(f<Ie(l,h)){i=!0;break}if(c){for(const[h,f]of c.missing){const p=u.missing.get(h);(p==null||p>f)&&u.missing.set(h,f)}u.update=$g([u.update,c.update])}}else l.pendingStructs=c;const d=Ig(r,s,l);if(l.pendingDs){const h=new Ea(pf(l.pendingDs));Ce(h.restDecoder);const f=Ig(h,s,l);d&&f?l.pendingDs=$g([d,f]):l.pendingDs=d||f}else l.pendingDs=d;if(i){const h=l.pendingStructs.update;l.pendingStructs=null,$d(s.doc,h)}},n,!1),$d=(t,e,n,r=Ea)=>{const s=pf(e);$6(s,t,n,new r(s))};class V6{constructor(){this.l=[]}}const Dg=()=>new V6,Rg=(t,e)=>t.l.push(e),Lg=(t,e)=>{const n=t.l,r=n.length;t.l=n.filter(s=>e!==s),r===t.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},ak=(t,e,n)=>bf(t.l,[e,n]);class ws{constructor(e,n){this.client=e,this.clock=n}}const Qo=(t,e)=>t===e||t!==null&&e!==null&&t.client===e.client&&t.clock===e.clock,se=(t,e)=>new ws(t,e),co=t=>{for(const[e,n]of t.doc.share.entries())if(n===t)return e;throw bt()},uo=(t,e)=>{for(;e!==null;){if(e.parent===t)return!0;e=e.parent._item}return!1};class Ta{constructor(e,n,r,s=0){this.type=e,this.tname=n,this.item=r,this.assoc=s}}class F6{constructor(e,n,r=0){this.type=e,this.index=n,this.assoc=r}}const U6=(t,e,n=0)=>new F6(t,e,n),el=(t,e,n)=>{let r=null,s=null;return t._item===null?s=co(t):r=se(t._item.id.client,t._item.id.clock),new Ta(r,s,e,n)},xu=(t,e,n=0)=>{let r=t._start;if(n<0){if(e===0)return el(t,null,n);e--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>e)return el(t,se(r.id.client,r.id.clock+e),n);e-=r.length}if(r.right===null&&n<0)return el(t,r.lastId,n);r=r.right}return el(t,null,n)},W6=(t,e)=>{const n=xs(t,e),r=e.clock-n.id.clock;return{item:n,diff:r}},ck=(t,e,n=!0)=>{const r=e.store,s=t.item,i=t.type,o=t.tname,l=t.assoc;let a=null,c=0;if(s!==null){if(Ie(r,s.client)<=s.clock)return null;const u=n?Wd(r,s):W6(r,s),d=u.item;if(!(d instanceof pe))return null;if(a=d.parent,a._item===null||!a._item.deleted){c=d.deleted||!d.countable?0:u.diff+(l>=0?0:1);let h=d.left;for(;h!==null;)!h.deleted&&h.countable&&(c+=h.length),h=h.left}}else{if(o!==null)a=e.get(o);else if(i!==null){if(Ie(r,i.client)<=i.clock)return null;const{item:u}=n?Wd(r,i):{item:xs(r,i)};if(u instanceof pe&&u.content instanceof rn)a=u.content.type;else return null}else throw bt();l>=0?c=a._length:c=0}return U6(a,c,t.assoc)};class Af{constructor(e,n){this.ds=e,this.sv=n}}const uk=(t,e)=>new Af(t,e),vu=t=>uk(O6(t.store),yc(t.store)),Ar=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&(e.sv.get(t.id.client)||0)>t.id.clock&&!Js(e.ds,t.id),Vd=(t,e)=>{const n=Fn(t.meta,Vd,Kr),r=t.doc.store;n.has(e)||(e.sv.forEach((s,i)=>{s<Ie(r,i)&&xt(t,se(i,s))}),pr(t,e.ds,s=>{}),n.add(e))};class dk{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const yc=t=>{const e=new Map;return t.clients.forEach((n,r)=>{const s=n[n.length-1];e.set(r,s.id.clock+s.length)}),e},Ie=(t,e)=>{const n=t.clients.get(e);if(n===void 0)return 0;const r=n[n.length-1];return r.id.clock+r.length},hk=(t,e)=>{let n=t.clients.get(e.id.client);if(n===void 0)n=[],t.clients.set(e.id.client,n);else{const r=n[n.length-1];if(r.id.clock+r.length!==e.id.clock)throw bt()}n.push(e)},en=(t,e)=>{let n=0,r=t.length-1,s=t[r],i=s.id.clock;if(i===e)return r;let o=Qt(e/(i+s.length-1)*r);for(;n<=r;){if(s=t[o],i=s.id.clock,i<=e){if(e<i+s.length)return o;n=o+1}else r=o-1;o=Qt((n+r)/2)}throw bt()},K6=(t,e)=>{const n=t.clients.get(e.client);return n[en(n,e.clock)]},xs=K6,Fd=(t,e,n)=>{const r=en(e,n),s=e[r];return s.id.clock<n&&s instanceof pe?(e.splice(r+1,0,Da(t,s,n-s.id.clock)),r+1):r},xt=(t,e)=>{const n=t.doc.store.clients.get(e.client);return n[Fd(t,n,e.clock)]},jg=(t,e,n)=>{const r=e.clients.get(n.client),s=en(r,n.clock),i=r[s];return n.clock!==i.id.clock+i.length-1&&i.constructor!==Pt&&r.splice(s+1,0,Da(t,i,n.clock-i.id.clock+1)),i},q6=(t,e,n)=>{const r=t.clients.get(e.id.client);r[en(r,e.id.clock)]=n},fk=(t,e,n,r,s)=>{if(r===0)return;const i=n+r;let o=Fd(t,e,n),l;do l=e[o++],i<l.id.clock+l.length&&Fd(t,e,i),s(l);while(o<e.length&&e[o].id.clock<i)};class J6{constructor(e,n,r){this.doc=e,this.deleteSet=new qs,this.beforeState=yc(e.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=n,this.meta=new Map,this.local=r,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}}const Pg=(t,e)=>e.deleteSet.clients.size===0&&!Dj(e.afterState,(n,r)=>e.beforeState.get(r)!==n)?!1:(Cf(e.deleteSet),z6(t,e),Mf(t,e.deleteSet),!0),Bg=(t,e,n)=>{const r=e._item;(r===null||r.id.clock<(t.beforeState.get(r.id.client)||0)&&!r.deleted)&&Fn(t.changed,e,Kr).add(n)},Cl=(t,e)=>{let n=t[e],r=t[e-1],s=e;for(;s>0;n=r,r=t[--s-1]){if(r.deleted===n.deleted&&r.constructor===n.constructor&&r.mergeWith(n)){n instanceof pe&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);continue}break}const i=e-s;return i&&t.splice(e+1-i,i),i},G6=(t,e,n)=>{for(const[r,s]of t.clients.entries()){const i=e.clients.get(r);for(let o=s.length-1;o>=0;o--){const l=s[o],a=l.clock+l.len;for(let c=en(i,l.clock),u=i[c];c<i.length&&u.id.clock<a;u=i[++c]){const d=i[c];if(l.clock+l.len<=d.id.clock)break;d instanceof pe&&d.deleted&&!d.keep&&n(d)&&d.gc(e,!1)}}}},Y6=(t,e)=>{t.clients.forEach((n,r)=>{const s=e.clients.get(r);for(let i=n.length-1;i>=0;i--){const o=n[i],l=Jr(s.length-1,1+en(s,o.clock+o.len-1));for(let a=l,c=s[a];a>0&&c.id.clock>=o.clock;c=s[a])a-=1+Cl(s,a)}})},pk=(t,e)=>{if(e<t.length){const n=t[e],r=n.doc,s=r.store,i=n.deleteSet,o=n._mergeStructs;try{Cf(i),n.afterState=yc(n.doc.store),r.emit("beforeObserverCalls",[n,r]);const l=[];n.changed.forEach((a,c)=>l.push(()=>{(c._item===null||!c._item.deleted)&&c._callObserver(n,a)})),l.push(()=>{n.changedParentTypes.forEach((a,c)=>{c._dEH.l.length>0&&(c._item===null||!c._item.deleted)&&(a=a.filter(u=>u.target._item===null||!u.target._item.deleted),a.forEach(u=>{u.currentTarget=c,u._path=null}),a.sort((u,d)=>u.path.length-d.path.length),l.push(()=>{ak(c._dEH,a,n)}))}),l.push(()=>r.emit("afterTransaction",[n,r])),l.push(()=>{n._needFormattingCleanup&&gB(n)})}),bf(l,[])}finally{r.gc&&G6(i,s,r.gcFilter),Y6(i,s),n.afterState.forEach((u,d)=>{const h=n.beforeState.get(d)||0;if(h!==u){const f=s.clients.get(d),p=fr(en(f,h),1);for(let g=f.length-1;g>=p;)g-=1+Cl(f,g)}});for(let u=o.length-1;u>=0;u--){const{client:d,clock:h}=o[u].id,f=s.clients.get(d),p=en(f,h);p+1<f.length&&Cl(f,p+1)>1||p>0&&Cl(f,p)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(T6(Sf,Zv,"[yjs] ",Qv,ek,"Changed the client-id because another client seems to be using it."),r.clientID=ok()),r.emit("afterTransactionCleanup",[n,r]),r._observers.has("update")){const u=new L6;Pg(u,n)&&r.emit("update",[u.toUint8Array(),n.origin,r,n])}if(r._observers.has("updateV2")){const u=new gc;Pg(u,n)&&r.emit("updateV2",[u.toUint8Array(),n.origin,r,n])}const{subdocsAdded:l,subdocsLoaded:a,subdocsRemoved:c}=n;(l.size>0||c.size>0||a.size>0)&&(l.forEach(u=>{u.clientID=r.clientID,u.collectionid==null&&(u.collectionid=r.collectionid),r.subdocs.add(u)}),c.forEach(u=>r.subdocs.delete(u)),r.emit("subdocs",[{loaded:a,added:l,removed:c},r,n]),c.forEach(u=>u.destroy())),t.length<=e+1?(r._transactionCleanups=[],r.emit("afterAllTransactions",[r,t])):pk(t,e+1)}}},we=(t,e,n=null,r=!0)=>{const s=t._transactionCleanups;let i=!1,o=null;t._transaction===null&&(i=!0,t._transaction=new J6(t,n,r),s.push(t._transaction),s.length===1&&t.emit("beforeAllTransactions",[t]),t.emit("beforeTransaction",[t._transaction,t]));try{o=e(t._transaction)}finally{if(i){const l=t._transaction===s[0];t._transaction=null,l&&pk(s,0)}}return o};class X6{constructor(e,n){this.insertions=n,this.deletions=e,this.meta=new Map}}const Hg=(t,e,n)=>{pr(t,n.deletions,r=>{r instanceof pe&&e.scope.some(s=>s===t.doc||uo(s,r))&&Of(r,!1)})},zg=(t,e,n)=>{let r=null;const s=t.doc,i=t.scope;we(s,l=>{for(;e.length>0&&t.currStackItem===null;){const a=s.store,c=e.pop(),u=new Set,d=[];let h=!1;pr(l,c.insertions,f=>{if(f instanceof pe){if(f.redone!==null){let{item:p,diff:g}=Wd(a,f.id);g>0&&(p=xt(l,se(p.id.client,p.id.clock+g))),f=p}!f.deleted&&i.some(p=>p===l.doc||uo(p,f))&&d.push(f)}}),pr(l,c.deletions,f=>{f instanceof pe&&i.some(p=>p===l.doc||uo(p,f))&&!Js(c.insertions,f.id)&&u.add(f)}),u.forEach(f=>{h=Rk(l,f,u,c.insertions,t.ignoreRemoteMapChanges,t)!==null||h});for(let f=d.length-1;f>=0;f--){const p=d[f];t.deleteFilter(p)&&(p.delete(l),h=!0)}t.currStackItem=h?c:null}l.changed.forEach((a,c)=>{a.has(null)&&c._searchMarker&&(c._searchMarker.length=0)}),r=l},t);const o=t.currStackItem;if(o!=null){const l=r.changedParentTypes;t.emit("stack-item-popped",[{stackItem:o,type:n,changedParentTypes:l,origin:t},t]),t.currStackItem=null}return o};class mk extends Sv{constructor(e,{captureTimeout:n=500,captureTransaction:r=a=>!0,deleteFilter:s=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:o=!1,doc:l=Ds(e)?e[0].doc:e instanceof Qr?e:e.doc}={}){super(),this.scope=[],this.doc=l,this.addToScope(e),this.deleteFilter=s,i.add(this),this.trackedOrigins=i,this.captureTransaction=r,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=o,this.captureTimeout=n,this.afterTransactionHandler=a=>{if(!this.captureTransaction(a)||!this.scope.some(y=>a.changedParentTypes.has(y)||y===this.doc)||!this.trackedOrigins.has(a.origin)&&(!a.origin||!this.trackedOrigins.has(a.origin.constructor)))return;const c=this.undoing,u=this.redoing,d=c?this.redoStack:this.undoStack;c?this.stopCapturing():u||this.clear(!1,!0);const h=new qs;a.afterState.forEach((y,b)=>{const w=a.beforeState.get(b)||0,v=y-w;v>0&&ao(h,b,w,v)});const f=bP();let p=!1;if(this.lastChange>0&&f-this.lastChange<this.captureTimeout&&d.length>0&&!c&&!u){const y=d[d.length-1];y.deletions=zd([y.deletions,a.deleteSet]),y.insertions=zd([y.insertions,h])}else d.push(new X6(a.deleteSet,h)),p=!0;!c&&!u&&(this.lastChange=f),pr(a,a.deleteSet,y=>{y instanceof pe&&this.scope.some(b=>b===a.doc||uo(b,y))&&Of(y,!0)});const g=[{stackItem:d[d.length-1],origin:a.origin,type:c?"redo":"undo",changedParentTypes:a.changedParentTypes},this];p?this.emit("stack-item-added",g):this.emit("stack-item-updated",g)},this.destroy=this.destroy.bind(this),this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",this.destroy)}addToScope(e){const n=new Set(this.scope);e=Ds(e)?e:[e],e.forEach(r=>{n.has(r)||(n.add(r),(r instanceof Ke?r.doc!==this.doc:r!==this.doc)&&nk("[yjs#509] Not same Y.Doc"),this.scope.push(r))})}addTrackedOrigin(e){this.trackedOrigins.add(e)}removeTrackedOrigin(e){this.trackedOrigins.delete(e)}clear(e=!0,n=!0){(e&&this.canUndo()||n&&this.canRedo())&&this.doc.transact(r=>{e&&(this.undoStack.forEach(s=>Hg(r,this,s)),this.undoStack=[]),n&&(this.redoStack.forEach(s=>Hg(r,this,s)),this.redoStack=[]),this.emit("stack-cleared",[{undoStackCleared:e,redoStackCleared:n}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let e;try{e=zg(this,this.undoStack,"undo")}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=zg(this,this.redoStack,"redo")}finally{this.redoing=!1}return e}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off("afterTransaction",this.afterTransactionHandler),this.doc.off("destroy",this.destroy),super.destroy()}}function*Z6(t){const e=Ce(t.restDecoder);for(let n=0;n<e;n++){const r=Ce(t.restDecoder),s=t.readClient();let i=Ce(t.restDecoder);for(let o=0;o<r;o++){const l=t.readInfo();if(l===10){const a=Ce(t.restDecoder);yield new qt(se(s,i),a),i+=a}else if(lc&l){const a=(l&(Ln|mt))===0,c=new pe(se(s,i),null,(l&mt)===mt?t.readLeftID():null,null,(l&Ln)===Ln?t.readRightID():null,a?t.readParentInfo()?t.readString():t.readLeftID():null,a&&(l&ro)===ro?t.readString():null,Lk(t,l));yield c,i+=c.length}else{const a=t.readLen();yield new Pt(se(s,i),a),i+=a}}}}class Q6{constructor(e,n){this.gen=Z6(e),this.curr=null,this.done=!1,this.filterSkips=n,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===qt);return this.curr}}class eB{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}}const tB=(t,e)=>{if(t.constructor===Pt){const{client:n,clock:r}=t.id;return new Pt(se(n,r+e),t.length-e)}else if(t.constructor===qt){const{client:n,clock:r}=t.id;return new qt(se(n,r+e),t.length-e)}else{const n=t,{client:r,clock:s}=n.id;return new pe(se(r,s+e),null,se(r,s+e-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(e))}},$g=(t,e=Ea,n=gc)=>{if(t.length===1)return t[0];const r=t.map(u=>new e(pf(u)));let s=r.map(u=>new Q6(u,!0)),i=null;const o=new n,l=new eB(o);for(;s=s.filter(h=>h.curr!==null),s.sort((h,f)=>{if(h.curr.id.client===f.curr.id.client){const p=h.curr.id.clock-f.curr.id.clock;return p===0?h.curr.constructor===f.curr.constructor?0:h.curr.constructor===qt?1:-1:p}else return f.curr.id.client-h.curr.id.client}),s.length!==0;){const u=s[0],d=u.curr.id.client;if(i!==null){let h=u.curr,f=!1;for(;h!==null&&h.id.clock+h.length<=i.struct.id.clock+i.struct.length&&h.id.client>=i.struct.id.client;)h=u.next(),f=!0;if(h===null||h.id.client!==d||f&&h.id.clock>i.struct.id.clock+i.struct.length)continue;if(d!==i.struct.id.client)si(l,i.struct,i.offset),i={struct:h,offset:0},u.next();else if(i.struct.id.clock+i.struct.length<h.id.clock)if(i.struct.constructor===qt)i.struct.length=h.id.clock+h.length-i.struct.id.clock;else{si(l,i.struct,i.offset);const p=h.id.clock-i.struct.id.clock-i.struct.length;i={struct:new qt(se(d,i.struct.id.clock+i.struct.length),p),offset:0}}else{const p=i.struct.id.clock+i.struct.length-h.id.clock;p>0&&(i.struct.constructor===qt?i.struct.length-=p:h=tB(h,p)),i.struct.mergeWith(h)||(si(l,i.struct,i.offset),i={struct:h,offset:0},u.next())}}else i={struct:u.curr,offset:0},u.next();for(let h=u.curr;h!==null&&h.id.client===d&&h.id.clock===i.struct.id.clock+i.struct.length&&h.constructor!==qt;h=u.next())si(l,i.struct,i.offset),i={struct:h,offset:0}}i!==null&&(si(l,i.struct,i.offset),i=null),nB(l);const a=r.map(u=>I6(u)),c=zd(a);return Mf(o,c),o.toUint8Array()},gk=t=>{t.written>0&&(t.clientStructs.push({written:t.written,restEncoder:Jt(t.encoder.restEncoder)}),t.encoder.restEncoder=Co(),t.written=0)},si=(t,e,n)=>{t.written>0&&t.currClient!==e.id.client&&gk(t),t.written===0&&(t.currClient=e.id.client,t.encoder.writeClient(e.id.client),ue(t.encoder.restEncoder,e.id.clock+n)),e.write(t.encoder,n),t.written++},nB=t=>{gk(t);const e=t.encoder.restEncoder;ue(e,t.clientStructs.length);for(let n=0;n<t.clientStructs.length;n++){const r=t.clientStructs[n];ue(e,r.written),ac(e,r.restEncoder)}},Vg="You must not compute changes after the event-handler fired.";class bc{constructor(e,n){this.target=e,this.currentTarget=e,this.transaction=n,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=rB(this.currentTarget,this.target))}deletes(e){return Js(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw yn(Vg);const e=new Map,n=this.target;this.transaction.changed.get(n).forEach(s=>{if(s!==null){const i=n._map.get(s);let o,l;if(this.adds(i)){let a=i.left;for(;a!==null&&this.adds(a);)a=a.left;if(this.deletes(i))if(a!==null&&this.deletes(a))o="delete",l=hu(a.content.getContent());else return;else a!==null&&this.deletes(a)?(o="update",l=hu(a.content.getContent())):(o="add",l=void 0)}else if(this.deletes(i))o="delete",l=hu(i.content.getContent());else return;e.set(s,{action:o,oldValue:l})}}),this._keys=e}return this._keys}get delta(){return this.changes.delta}adds(e){return e.id.clock>=(this.transaction.beforeState.get(e.id.client)||0)}get changes(){let e=this._changes;if(e===null){if(this.transaction.doc._transactionCleanups.length===0)throw yn(Vg);const n=this.target,r=Kr(),s=Kr(),i=[];if(e={added:r,deleted:s,delta:i,keys:this.keys},this.transaction.changed.get(n).has(null)){let l=null;const a=()=>{l&&i.push(l)};for(let c=n._start;c!==null;c=c.right)c.deleted?this.deletes(c)&&!this.adds(c)&&((l===null||l.delete===void 0)&&(a(),l={delete:0}),l.delete+=c.length,s.add(c)):this.adds(c)?((l===null||l.insert===void 0)&&(a(),l={insert:[]}),l.insert=l.insert.concat(c.content.getContent()),r.add(c)):((l===null||l.retain===void 0)&&(a(),l={retain:0}),l.retain+=c.length);l!==null&&l.retain===void 0&&a()}this._changes=e}return e}}const rB=(t,e)=>{const n=[];for(;e._item!==null&&e!==t;){if(e._item.parentSub!==null)n.unshift(e._item.parentSub);else{let r=0,s=e._item.parent._start;for(;s!==e._item&&s!==null;)!s.deleted&&s.countable&&(r+=s.length),s=s.right;n.unshift(r)}e=e._item.parent}return n},rt=()=>{nk("Invalid access: Add Yjs type to a document before reading data.")},yk=80;let Ef=0;class sB{constructor(e,n){e.marker=!0,this.p=e,this.index=n,this.timestamp=Ef++}}const iB=t=>{t.timestamp=Ef++},bk=(t,e,n)=>{t.p.marker=!1,t.p=e,e.marker=!0,t.index=n,t.timestamp=Ef++},oB=(t,e,n)=>{if(t.length>=yk){const r=t.reduce((s,i)=>s.timestamp<i.timestamp?s:i);return bk(r,e,n),r}else{const r=new sB(e,n);return t.push(r),r}},wc=(t,e)=>{if(t._start===null||e===0||t._searchMarker===null)return null;const n=t._searchMarker.length===0?null:t._searchMarker.reduce((i,o)=>xl(e-i.index)<xl(e-o.index)?i:o);let r=t._start,s=0;for(n!==null&&(r=n.p,s=n.index,iB(n));r.right!==null&&s<e;){if(!r.deleted&&r.countable){if(e<s+r.length)break;s+=r.length}r=r.right}for(;r.left!==null&&s>e;)r=r.left,!r.deleted&&r.countable&&(s-=r.length);for(;r.left!==null&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock;)r=r.left,!r.deleted&&r.countable&&(s-=r.length);return n!==null&&xl(n.index-s)<r.parent.length/yk?(bk(n,r,s),n):oB(t._searchMarker,r,s)},ho=(t,e,n)=>{for(let r=t.length-1;r>=0;r--){const s=t[r];if(n>0){let i=s.p;for(i.marker=!1;i&&(i.deleted||!i.countable);)i=i.left,i&&!i.deleted&&i.countable&&(s.index-=i.length);if(i===null||i.marker===!0){t.splice(r,1);continue}s.p=i,i.marker=!0}(e<s.index||n>0&&e===s.index)&&(s.index=fr(e,s.index+n))}},xc=(t,e,n)=>{const r=t,s=e.changedParentTypes;for(;Fn(s,t,()=>[]).push(n),t._item!==null;)t=t._item.parent;ak(r._eH,n,e)};class Ke{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=Dg(),this._dEH=Dg(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,n){this.doc=e,this._item=n}_copy(){throw zt()}clone(){throw zt()}_write(e){}get _first(){let e=this._start;for(;e!==null&&e.deleted;)e=e.right;return e}_callObserver(e,n){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){Rg(this._eH,e)}observeDeep(e){Rg(this._dEH,e)}unobserve(e){Lg(this._eH,e)}unobserveDeep(e){Lg(this._dEH,e)}toJSON(){}}const wk=(t,e,n)=>{t.doc??rt(),e<0&&(e=t._length+e),n<0&&(n=t._length+n);let r=n-e;const s=[];let i=t._start;for(;i!==null&&r>0;){if(i.countable&&!i.deleted){const o=i.content.getContent();if(o.length<=e)e-=o.length;else{for(let l=e;l<o.length&&r>0;l++)s.push(o[l]),r--;e=0}}i=i.right}return s},xk=t=>{t.doc??rt();const e=[];let n=t._start;for(;n!==null;){if(n.countable&&!n.deleted){const r=n.content.getContent();for(let s=0;s<r.length;s++)e.push(r[s])}n=n.right}return e},vk=(t,e)=>{const n=[];let r=t._start;for(;r!==null;){if(r.countable&&Ar(r,e)){const s=r.content.getContent();for(let i=0;i<s.length;i++)n.push(s[i])}r=r.right}return n},fo=(t,e)=>{let n=0,r=t._start;for(t.doc??rt();r!==null;){if(r.countable&&!r.deleted){const s=r.content.getContent();for(let i=0;i<s.length;i++)e(s[i],n++,t)}r=r.right}},kk=(t,e)=>{const n=[];return fo(t,(r,s)=>{n.push(e(r,s,t))}),n},lB=t=>{let e=t._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){for(;e!==null&&e.deleted;)e=e.right;if(e===null)return{done:!0,value:void 0};n=e.content.getContent(),r=0,e=e.right}const s=n[r++];return n.length<=r&&(n=null),{done:!1,value:s}}}},Sk=(t,e)=>{t.doc??rt();const n=wc(t,e);let r=t._start;for(n!==null&&(r=n.p,e-=n.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(e<r.length)return r.content.getContent()[e];e-=r.length}},_a=(t,e,n,r)=>{let s=n;const i=t.doc,o=i.clientID,l=i.store,a=n===null?e._start:n.right;let c=[];const u=()=>{c.length>0&&(s=new pe(se(o,Ie(l,o)),s,s&&s.lastId,a,a&&a.id,e,null,new Yr(c)),s.integrate(t,0),c=[])};r.forEach(d=>{if(d===null)c.push(d);else switch(d.constructor){case Number:case Object:case Boolean:case Array:case String:c.push(d);break;default:switch(u(),d.constructor){case Uint8Array:case ArrayBuffer:s=new pe(se(o,Ie(l,o)),s,s&&s.lastId,a,a&&a.id,e,null,new Ao(new Uint8Array(d))),s.integrate(t,0);break;case Qr:s=new pe(se(o,Ie(l,o)),s,s&&s.lastId,a,a&&a.id,e,null,new Eo(d)),s.integrate(t,0);break;default:if(d instanceof Ke)s=new pe(se(o,Ie(l,o)),s,s&&s.lastId,a,a&&a.id,e,null,new rn(d)),s.integrate(t,0);else throw new Error("Unexpected content type in insert operation")}}}),u()},Ck=()=>yn("Length exceeded!"),Mk=(t,e,n,r)=>{if(n>e._length)throw Ck();if(n===0)return e._searchMarker&&ho(e._searchMarker,n,r.length),_a(t,e,null,r);const s=n,i=wc(e,n);let o=e._start;for(i!==null&&(o=i.p,n-=i.index,n===0&&(o=o.prev,n+=o&&o.countable&&!o.deleted?o.length:0));o!==null;o=o.right)if(!o.deleted&&o.countable){if(n<=o.length){n<o.length&&xt(t,se(o.id.client,o.id.clock+n));break}n-=o.length}return e._searchMarker&&ho(e._searchMarker,s,r.length),_a(t,e,o,r)},aB=(t,e,n)=>{let s=(e._searchMarker||[]).reduce((i,o)=>o.index>i.index?o:i,{index:0,p:e._start}).p;if(s)for(;s.right;)s=s.right;return _a(t,e,s,n)},Ak=(t,e,n,r)=>{if(r===0)return;const s=n,i=r,o=wc(e,n);let l=e._start;for(o!==null&&(l=o.p,n-=o.index);l!==null&&n>0;l=l.right)!l.deleted&&l.countable&&(n<l.length&&xt(t,se(l.id.client,l.id.clock+n)),n-=l.length);for(;r>0&&l!==null;)l.deleted||(r<l.length&&xt(t,se(l.id.client,l.id.clock+r)),l.delete(t),r-=l.length),l=l.right;if(r>0)throw Ck();e._searchMarker&&ho(e._searchMarker,s,-i+r)},Na=(t,e,n)=>{const r=e._map.get(n);r!==void 0&&r.delete(t)},Tf=(t,e,n,r)=>{const s=e._map.get(n)||null,i=t.doc,o=i.clientID;let l;if(r==null)l=new Yr([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:l=new Yr([r]);break;case Uint8Array:l=new Ao(r);break;case Qr:l=new Eo(r);break;default:if(r instanceof Ke)l=new rn(r);else throw new Error("Unexpected content type")}new pe(se(o,Ie(i.store,o)),s,s&&s.lastId,null,null,e,n,l).integrate(t,0)},_f=(t,e)=>{t.doc??rt();const n=t._map.get(e);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},Ek=t=>{const e={};return t.doc??rt(),t._map.forEach((n,r)=>{n.deleted||(e[r]=n.content.getContent()[n.length-1])}),e},Tk=(t,e)=>{t.doc??rt();const n=t._map.get(e);return n!==void 0&&!n.deleted},cB=(t,e)=>{const n={};return t._map.forEach((r,s)=>{let i=r;for(;i!==null&&(!e.sv.has(i.id.client)||i.id.clock>=(e.sv.get(i.id.client)||0));)i=i.left;i!==null&&Ar(i,e)&&(n[s]=i.content.getContent()[i.length-1])}),n},tl=t=>(t.doc??rt(),_6(t._map.entries(),e=>!e[1].deleted));class uB extends bc{}class vs extends Ke{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){const n=new vs;return n.push(e),n}_integrate(e,n){super._integrate(e,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new vs}clone(){const e=new vs;return e.insert(0,this.toArray().map(n=>n instanceof Ke?n.clone():n)),e}get length(){return this.doc??rt(),this._length}_callObserver(e,n){super._callObserver(e,n),xc(this,e,new uB(this,e))}insert(e,n){this.doc!==null?we(this.doc,r=>{Mk(r,this,e,n)}):this._prelimContent.splice(e,0,...n)}push(e){this.doc!==null?we(this.doc,n=>{aB(n,this,e)}):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,n=1){this.doc!==null?we(this.doc,r=>{Ak(r,this,e,n)}):this._prelimContent.splice(e,n)}get(e){return Sk(this,e)}toArray(){return xk(this)}slice(e=0,n=this.length){return wk(this,e,n)}toJSON(){return this.map(e=>e instanceof Ke?e.toJSON():e)}map(e){return kk(this,e)}forEach(e){fo(this,e)}[Symbol.iterator](){return lB(this)}_write(e){e.writeTypeRef(LB)}}const dB=t=>new vs;class hB extends bc{constructor(e,n,r){super(e,n),this.keysChanged=r}}class Ps extends Ke{constructor(e){super(),this._prelimContent=null,e===void 0?this._prelimContent=new Map:this._prelimContent=new Map(e)}_integrate(e,n){super._integrate(e,n),this._prelimContent.forEach((r,s)=>{this.set(s,r)}),this._prelimContent=null}_copy(){return new Ps}clone(){const e=new Ps;return this.forEach((n,r)=>{e.set(r,n instanceof Ke?n.clone():n)}),e}_callObserver(e,n){xc(this,e,new hB(this,e,n))}toJSON(){this.doc??rt();const e={};return this._map.forEach((n,r)=>{if(!n.deleted){const s=n.content.getContent()[n.length-1];e[r]=s instanceof Ke?s.toJSON():s}}),e}get size(){return[...tl(this)].length}keys(){return wu(tl(this),e=>e[0])}values(){return wu(tl(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return wu(tl(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??rt(),this._map.forEach((n,r)=>{n.deleted||e(n.content.getContent()[n.length-1],r,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc!==null?we(this.doc,n=>{Na(n,this,e)}):this._prelimContent.delete(e)}set(e,n){return this.doc!==null?we(this.doc,r=>{Tf(r,this,e,n)}):this._prelimContent.set(e,n),n}get(e){return _f(this,e)}has(e){return Tk(this,e)}clear(){this.doc!==null?we(this.doc,e=>{this.forEach(function(n,r,s){Na(e,s,r)})}):this._prelimContent.clear()}_write(e){e.writeTypeRef(jB)}}const fB=t=>new Ps,sr=(t,e)=>t===e||typeof t=="object"&&typeof e=="object"&&t&&e&&AP(t,e);class Ud{constructor(e,n,r,s){this.left=e,this.right=n,this.index=r,this.currentAttributes=s}forward(){switch(this.right===null&&bt(),this.right.content.constructor){case je:this.right.deleted||Gs(this.currentAttributes,this.right.content);break;default:this.right.deleted||(this.index+=this.right.length);break}this.left=this.right,this.right=this.right.right}}const Fg=(t,e,n)=>{for(;e.right!==null&&n>0;){switch(e.right.content.constructor){case je:e.right.deleted||Gs(e.currentAttributes,e.right.content);break;default:e.right.deleted||(n<e.right.length&&xt(t,se(e.right.id.client,e.right.id.clock+n)),e.index+=e.right.length,n-=e.right.length);break}e.left=e.right,e.right=e.right.right}return e},nl=(t,e,n,r)=>{const s=new Map,i=r?wc(e,n):null;if(i){const o=new Ud(i.p.left,i.p,i.index,s);return Fg(t,o,n-i.index)}else{const o=new Ud(null,e._start,0,s);return Fg(t,o,n)}},_k=(t,e,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===je&&sr(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();const s=t.doc,i=s.clientID;r.forEach((o,l)=>{const a=n.left,c=n.right,u=new pe(se(i,Ie(s.store,i)),a,a&&a.lastId,c,c&&c.id,e,null,new je(l,o));u.integrate(t,0),n.right=u,n.forward()})},Gs=(t,e)=>{const{key:n,value:r}=e;r===null?t.delete(n):t.set(n,r)},Nk=(t,e)=>{for(;t.right!==null;){if(!(t.right.deleted||t.right.content.constructor===je&&sr(e[t.right.content.key]??null,t.right.content.value)))break;t.forward()}},Ok=(t,e,n,r)=>{const s=t.doc,i=s.clientID,o=new Map;for(const l in r){const a=r[l],c=n.currentAttributes.get(l)??null;if(!sr(c,a)){o.set(l,c);const{left:u,right:d}=n;n.right=new pe(se(i,Ie(s.store,i)),u,u&&u.lastId,d,d&&d.id,e,null,new je(l,a)),n.right.integrate(t,0),n.forward()}}return o},ku=(t,e,n,r,s)=>{n.currentAttributes.forEach((h,f)=>{s[f]===void 0&&(s[f]=null)});const i=t.doc,o=i.clientID;Nk(n,s);const l=Ok(t,e,n,s),a=r.constructor===String?new tn(r):r instanceof Ke?new rn(r):new es(r);let{left:c,right:u,index:d}=n;e._searchMarker&&ho(e._searchMarker,n.index,a.getLength()),u=new pe(se(o,Ie(i.store,o)),c,c&&c.lastId,u,u&&u.id,e,null,a),u.integrate(t,0),n.right=u,n.index=d,n.forward(),_k(t,e,n,l)},Ug=(t,e,n,r,s)=>{const i=t.doc,o=i.clientID;Nk(n,s);const l=Ok(t,e,n,s);e:for(;n.right!==null&&(r>0||l.size>0&&(n.right.deleted||n.right.content.constructor===je));){if(!n.right.deleted)switch(n.right.content.constructor){case je:{const{key:a,value:c}=n.right.content,u=s[a];if(u!==void 0){if(sr(u,c))l.delete(a);else{if(r===0)break e;l.set(a,c)}n.right.delete(t)}else n.currentAttributes.set(a,c);break}default:r<n.right.length&&xt(t,se(n.right.id.client,n.right.id.clock+r)),r-=n.right.length;break}n.forward()}if(r>0){let a="";for(;r>0;r--)a+=`
|
|
456
|
+
`;n.right=new pe(se(o,Ie(i.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,e,null,new tn(a)),n.right.integrate(t,0),n.forward()}_k(t,e,n,l)},Ik=(t,e,n,r,s)=>{let i=e;const o=Yt();for(;i&&(!i.countable||i.deleted);){if(!i.deleted&&i.content.constructor===je){const c=i.content;o.set(c.key,c)}i=i.right}let l=0,a=!1;for(;e!==i;){if(n===e&&(a=!0),!e.deleted){const c=e.content;switch(c.constructor){case je:{const{key:u,value:d}=c,h=r.get(u)??null;(o.get(u)!==c||h===d)&&(e.delete(t),l++,!a&&(s.get(u)??null)===d&&h!==d&&(h===null?s.delete(u):s.set(u,h))),!a&&!e.deleted&&Gs(s,c);break}}}e=e.right}return l},pB=(t,e)=>{for(;e&&e.right&&(e.right.deleted||!e.right.countable);)e=e.right;const n=new Set;for(;e&&(e.deleted||!e.countable);){if(!e.deleted&&e.content.constructor===je){const r=e.content.key;n.has(r)?e.delete(t):n.add(r)}e=e.left}},mB=t=>{let e=0;return we(t.doc,n=>{let r=t._start,s=t._start,i=Yt();const o=Dd(i);for(;s;){if(s.deleted===!1)switch(s.content.constructor){case je:Gs(o,s.content);break;default:e+=Ik(n,r,s,i,o),i=Dd(o),r=s;break}s=s.right}}),e},gB=t=>{const e=new Set,n=t.doc;for(const[r,s]of t.afterState.entries()){const i=t.beforeState.get(r)||0;s!==i&&fk(t,n.store.clients.get(r),i,s,o=>{!o.deleted&&o.content.constructor===je&&o.constructor!==Pt&&e.add(o.parent)})}we(n,r=>{pr(t,t.deleteSet,s=>{if(s instanceof Pt||!s.parent._hasFormatting||e.has(s.parent))return;const i=s.parent;s.content.constructor===je?e.add(i):pB(r,s)});for(const s of e)mB(s)})},Wg=(t,e,n)=>{const r=n,s=Dd(e.currentAttributes),i=e.right;for(;n>0&&e.right!==null;){if(e.right.deleted===!1)switch(e.right.content.constructor){case rn:case es:case tn:n<e.right.length&&xt(t,se(e.right.id.client,e.right.id.clock+n)),n-=e.right.length,e.right.delete(t);break}e.forward()}i&&Ik(t,i,e.right,s,e.currentAttributes);const o=(e.left||e.right).parent;return o._searchMarker&&ho(o._searchMarker,e.index,-r+n),e};class yB extends bc{constructor(e,n,r){super(e,n),this.childListChanged=!1,this.keysChanged=new Set,r.forEach(s=>{s===null?this.childListChanged=!0:this.keysChanged.add(s)})}get changes(){if(this._changes===null){const e={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=e}return this._changes}get delta(){if(this._delta===null){const e=this.target.doc,n=[];we(e,r=>{const s=new Map,i=new Map;let o=this.target._start,l=null;const a={};let c="",u=0,d=0;const h=()=>{if(l!==null){let f=null;switch(l){case"delete":d>0&&(f={delete:d}),d=0;break;case"insert":(typeof c=="object"||c.length>0)&&(f={insert:c},s.size>0&&(f.attributes={},s.forEach((p,g)=>{p!==null&&(f.attributes[g]=p)}))),c="";break;case"retain":u>0&&(f={retain:u},MP(a)||(f.attributes=SP({},a))),u=0;break}f&&n.push(f),l=null}};for(;o!==null;){switch(o.content.constructor){case rn:case es:this.adds(o)?this.deletes(o)||(h(),l="insert",c=o.content.getContent()[0],h()):this.deletes(o)?(l!=="delete"&&(h(),l="delete"),d+=1):o.deleted||(l!=="retain"&&(h(),l="retain"),u+=1);break;case tn:this.adds(o)?this.deletes(o)||(l!=="insert"&&(h(),l="insert"),c+=o.content.str):this.deletes(o)?(l!=="delete"&&(h(),l="delete"),d+=o.length):o.deleted||(l!=="retain"&&(h(),l="retain"),u+=o.length);break;case je:{const{key:f,value:p}=o.content;if(this.adds(o)){if(!this.deletes(o)){const g=s.get(f)??null;sr(g,p)?p!==null&&o.delete(r):(l==="retain"&&h(),sr(p,i.get(f)??null)?delete a[f]:a[f]=p)}}else if(this.deletes(o)){i.set(f,p);const g=s.get(f)??null;sr(g,p)||(l==="retain"&&h(),a[f]=g)}else if(!o.deleted){i.set(f,p);const g=a[f];g!==void 0&&(sr(g,p)?g!==null&&o.delete(r):(l==="retain"&&h(),p===null?delete a[f]:a[f]=p))}o.deleted||(l==="insert"&&h(),Gs(s,o.content));break}}o=o.right}for(h();n.length>0;){const f=n[n.length-1];if(f.retain!==void 0&&f.attributes===void 0)n.pop();else break}}),this._delta=n}return this._delta}}class mr extends Ke{constructor(e){super(),this._pending=e!==void 0?[()=>this.insert(0,e)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??rt(),this._length}_integrate(e,n){super._integrate(e,n);try{this._pending.forEach(r=>r())}catch(r){console.error(r)}this._pending=null}_copy(){return new mr}clone(){const e=new mr;return e.applyDelta(this.toDelta()),e}_callObserver(e,n){super._callObserver(e,n);const r=new yB(this,e,n);xc(this,e,r),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??rt();let e="",n=this._start;for(;n!==null;)!n.deleted&&n.countable&&n.content.constructor===tn&&(e+=n.content.str),n=n.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:n=!0}={}){this.doc!==null?we(this.doc,r=>{const s=new Ud(null,this._start,0,new Map);for(let i=0;i<e.length;i++){const o=e[i];if(o.insert!==void 0){const l=!n&&typeof o.insert=="string"&&i===e.length-1&&s.right===null&&o.insert.slice(-1)===`
|
|
457
|
+
`?o.insert.slice(0,-1):o.insert;(typeof l!="string"||l.length>0)&&ku(r,this,s,l,o.attributes||{})}else o.retain!==void 0?Ug(r,this,s,o.retain,o.attributes||{}):o.delete!==void 0&&Wg(r,s,o.delete)}}):this._pending.push(()=>this.applyDelta(e))}toDelta(e,n,r){this.doc??rt();const s=[],i=new Map,o=this.doc;let l="",a=this._start;function c(){if(l.length>0){const d={};let h=!1;i.forEach((p,g)=>{h=!0,d[g]=p});const f={insert:l};h&&(f.attributes=d),s.push(f),l=""}}const u=()=>{for(;a!==null;){if(Ar(a,e)||n!==void 0&&Ar(a,n))switch(a.content.constructor){case tn:{const d=i.get("ychange");e!==void 0&&!Ar(a,e)?(d===void 0||d.user!==a.id.client||d.type!=="removed")&&(c(),i.set("ychange",r?r("removed",a.id):{type:"removed"})):n!==void 0&&!Ar(a,n)?(d===void 0||d.user!==a.id.client||d.type!=="added")&&(c(),i.set("ychange",r?r("added",a.id):{type:"added"})):d!==void 0&&(c(),i.delete("ychange")),l+=a.content.str;break}case rn:case es:{c();const d={insert:a.content.getContent()[0]};if(i.size>0){const h={};d.attributes=h,i.forEach((f,p)=>{h[p]=f})}s.push(d);break}case je:Ar(a,e)&&(c(),Gs(i,a.content));break}a=a.right}c()};return e||n?we(o,d=>{e&&Vd(d,e),n&&Vd(d,n),u()},"cleanup"):u(),s}insert(e,n,r){if(n.length<=0)return;const s=this.doc;s!==null?we(s,i=>{const o=nl(i,this,e,!r);r||(r={},o.currentAttributes.forEach((l,a)=>{r[a]=l})),ku(i,this,o,n,r)}):this._pending.push(()=>this.insert(e,n,r))}insertEmbed(e,n,r){const s=this.doc;s!==null?we(s,i=>{const o=nl(i,this,e,!r);ku(i,this,o,n,r||{})}):this._pending.push(()=>this.insertEmbed(e,n,r||{}))}delete(e,n){if(n===0)return;const r=this.doc;r!==null?we(r,s=>{Wg(s,nl(s,this,e,!0),n)}):this._pending.push(()=>this.delete(e,n))}format(e,n,r){if(n===0)return;const s=this.doc;s!==null?we(s,i=>{const o=nl(i,this,e,!1);o.right!==null&&Ug(i,this,o,n,r)}):this._pending.push(()=>this.format(e,n,r))}removeAttribute(e){this.doc!==null?we(this.doc,n=>{Na(n,this,e)}):this._pending.push(()=>this.removeAttribute(e))}setAttribute(e,n){this.doc!==null?we(this.doc,r=>{Tf(r,this,e,n)}):this._pending.push(()=>this.setAttribute(e,n))}getAttribute(e){return _f(this,e)}getAttributes(){return Ek(this)}_write(e){e.writeTypeRef(PB)}}const bB=t=>new mr;class Su{constructor(e,n=()=>!0){this._filter=n,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??rt()}[Symbol.iterator](){return this}next(){let e=this._currentNode,n=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(n)))do if(n=e.content.type,!e.deleted&&(n.constructor===et||n.constructor===Gr)&&n._start!==null)e=n._start;else for(;e!==null;){const r=e.next;if(r!==null){e=r;break}else e.parent===this._root?e=null:e=e.parent._item}while(e!==null&&(e.deleted||!this._filter(e.content.type)));return this._firstCall=!1,e===null?{value:void 0,done:!0}:(this._currentNode=e,{value:e.content.type,done:!1})}}class Gr extends Ke{constructor(){super(),this._prelimContent=[]}get firstChild(){const e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,n){super._integrate(e,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new Gr}clone(){const e=new Gr;return e.insert(0,this.toArray().map(n=>n instanceof Ke?n.clone():n)),e}get length(){return this.doc??rt(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new Su(this,e)}querySelector(e){e=e.toUpperCase();const r=new Su(this,s=>s.nodeName&&s.nodeName.toUpperCase()===e).next();return r.done?null:r.value}querySelectorAll(e){return e=e.toUpperCase(),qr(new Su(this,n=>n.nodeName&&n.nodeName.toUpperCase()===e))}_callObserver(e,n){xc(this,e,new vB(this,n,e))}toString(){return kk(this,e=>e.toString()).join("")}toJSON(){return this.toString()}toDOM(e=document,n={},r){const s=e.createDocumentFragment();return r!==void 0&&r._createAssociation(s,this),fo(this,i=>{s.insertBefore(i.toDOM(e,n,r),null)}),s}insert(e,n){this.doc!==null?we(this.doc,r=>{Mk(r,this,e,n)}):this._prelimContent.splice(e,0,...n)}insertAfter(e,n){if(this.doc!==null)we(this.doc,r=>{const s=e&&e instanceof Ke?e._item:e;_a(r,this,s,n)});else{const r=this._prelimContent,s=e===null?0:r.findIndex(i=>i===e)+1;if(s===0&&e!==null)throw yn("Reference item not found");r.splice(s,0,...n)}}delete(e,n=1){this.doc!==null?we(this.doc,r=>{Ak(r,this,e,n)}):this._prelimContent.splice(e,n)}toArray(){return xk(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return Sk(this,e)}slice(e=0,n=this.length){return wk(this,e,n)}forEach(e){fo(this,e)}_write(e){e.writeTypeRef(HB)}}const wB=t=>new Gr;class et extends Gr{constructor(e="UNDEFINED"){super(),this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,n){super._integrate(e,n),this._prelimAttrs.forEach((r,s)=>{this.setAttribute(s,r)}),this._prelimAttrs=null}_copy(){return new et(this.nodeName)}clone(){const e=new et(this.nodeName),n=this.getAttributes();return CP(n,(r,s)=>{e.setAttribute(s,r)}),e.insert(0,this.toArray().map(r=>r instanceof Ke?r.clone():r)),e}toString(){const e=this.getAttributes(),n=[],r=[];for(const l in e)r.push(l);r.sort();const s=r.length;for(let l=0;l<s;l++){const a=r[l];n.push(a+'="'+e[a]+'"')}const i=this.nodeName.toLocaleLowerCase(),o=n.length>0?" "+n.join(" "):"";return`<${i}${o}>${super.toString()}</${i}>`}removeAttribute(e){this.doc!==null?we(this.doc,n=>{Na(n,this,e)}):this._prelimAttrs.delete(e)}setAttribute(e,n){this.doc!==null?we(this.doc,r=>{Tf(r,this,e,n)}):this._prelimAttrs.set(e,n)}getAttribute(e){return _f(this,e)}hasAttribute(e){return Tk(this,e)}getAttributes(e){return e?cB(this,e):Ek(this)}toDOM(e=document,n={},r){const s=e.createElement(this.nodeName),i=this.getAttributes();for(const o in i){const l=i[o];typeof l=="string"&&s.setAttribute(o,l)}return fo(this,o=>{s.appendChild(o.toDOM(e,n,r))}),r!==void 0&&r._createAssociation(s,this),s}_write(e){e.writeTypeRef(BB),e.writeKey(this.nodeName)}}const xB=t=>new et(t.readKey());class vB extends bc{constructor(e,n,r){super(e,r),this.childListChanged=!1,this.attributesChanged=new Set,n.forEach(s=>{s===null?this.childListChanged=!0:this.attributesChanged.add(s)})}}class Oa extends Ps{constructor(e){super(),this.hookName=e}_copy(){return new Oa(this.hookName)}clone(){const e=new Oa(this.hookName);return this.forEach((n,r)=>{e.set(r,n)}),e}toDOM(e=document,n={},r){const s=n[this.hookName];let i;return s!==void 0?i=s.createDom(this):i=document.createElement(this.hookName),i.setAttribute("data-yjs-hook",this.hookName),r!==void 0&&r._createAssociation(i,this),i}_write(e){e.writeTypeRef(zB),e.writeKey(this.hookName)}}const kB=t=>new Oa(t.readKey());class st extends mr{get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new st}clone(){const e=new st;return e.applyDelta(this.toDelta()),e}toDOM(e=document,n,r){const s=e.createTextNode(this.toString());return r!==void 0&&r._createAssociation(s,this),s}toString(){return this.toDelta().map(e=>{const n=[];for(const s in e.attributes){const i=[];for(const o in e.attributes[s])i.push({key:o,value:e.attributes[s][o]});i.sort((o,l)=>o.key<l.key?-1:1),n.push({nodeName:s,attrs:i})}n.sort((s,i)=>s.nodeName<i.nodeName?-1:1);let r="";for(let s=0;s<n.length;s++){const i=n[s];r+=`<${i.nodeName}`;for(let o=0;o<i.attrs.length;o++){const l=i.attrs[o];r+=` ${l.key}="${l.value}"`}r+=">"}r+=e.insert;for(let s=n.length-1;s>=0;s--)r+=`</${n[s].nodeName}>`;return r}).join("")}toJSON(){return this.toString()}_write(e){e.writeTypeRef($B)}}const SB=t=>new st;class Nf{constructor(e,n){this.id=e,this.length=n}get deleted(){throw zt()}mergeWith(e){return!1}write(e,n,r){throw zt()}integrate(e,n){throw zt()}}const CB=0;class Pt extends Nf{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,n){n>0&&(this.id.clock+=n,this.length-=n),hk(e.doc.store,this)}write(e,n){e.writeInfo(CB),e.writeLen(this.length-n)}getMissing(e,n){return null}}class Ao{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new Ao(this.content)}splice(e){throw zt()}mergeWith(e){return!1}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeBuf(this.content)}getRef(){return 3}}const MB=t=>new Ao(t.readBuf());class po{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new po(this.len)}splice(e){const n=new po(this.len-e);return this.len=e,n}mergeWith(e){return this.len+=e.len,!0}integrate(e,n){ao(e.deleteSet,n.id.client,n.id.clock,this.len),n.markDeleted()}delete(e){}gc(e){}write(e,n){e.writeLen(this.len-n)}getRef(){return 1}}const AB=t=>new po(t.readLen()),Dk=(t,e)=>new Qr({guid:t,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class Eo{constructor(e){e._item&&console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid."),this.doc=e;const n={};this.opts=n,e.gc||(n.gc=!1),e.autoLoad&&(n.autoLoad=!0),e.meta!==null&&(n.meta=e.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new Eo(Dk(this.doc.guid,this.opts))}splice(e){throw zt()}mergeWith(e){return!1}integrate(e,n){this.doc._item=n,e.subdocsAdded.add(this.doc),this.doc.shouldLoad&&e.subdocsLoaded.add(this.doc)}delete(e){e.subdocsAdded.has(this.doc)?e.subdocsAdded.delete(this.doc):e.subdocsRemoved.add(this.doc)}gc(e){}write(e,n){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}}const EB=t=>new Eo(Dk(t.readString(),t.readAny()));class es{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new es(this.embed)}splice(e){throw zt()}mergeWith(e){return!1}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeJSON(this.embed)}getRef(){return 5}}const TB=t=>new es(t.readJSON());class je{constructor(e,n){this.key=e,this.value=n}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new je(this.key,this.value)}splice(e){throw zt()}mergeWith(e){return!1}integrate(e,n){const r=n.parent;r._searchMarker=null,r._hasFormatting=!0}delete(e){}gc(e){}write(e,n){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}}const _B=t=>new je(t.readKey(),t.readJSON());class Ia{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Ia(this.arr)}splice(e){const n=new Ia(this.arr.slice(e));return this.arr=this.arr.slice(0,e),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,n){}delete(e){}gc(e){}write(e,n){const r=this.arr.length;e.writeLen(r-n);for(let s=n;s<r;s++){const i=this.arr[s];e.writeString(i===void 0?"undefined":JSON.stringify(i))}}getRef(){return 2}}const NB=t=>{const e=t.readLen(),n=[];for(let r=0;r<e;r++){const s=t.readString();s==="undefined"?n.push(void 0):n.push(JSON.parse(s))}return new Ia(n)},OB=Sa("node_env")==="development";class Yr{constructor(e){this.arr=e,OB&&Iv(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Yr(this.arr)}splice(e){const n=new Yr(this.arr.slice(e));return this.arr=this.arr.slice(0,e),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,n){}delete(e){}gc(e){}write(e,n){const r=this.arr.length;e.writeLen(r-n);for(let s=n;s<r;s++){const i=this.arr[s];e.writeAny(i)}}getRef(){return 8}}const IB=t=>{const e=t.readLen(),n=[];for(let r=0;r<e;r++)n.push(t.readAny());return new Yr(n)};class tn{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new tn(this.str)}splice(e){const n=new tn(this.str.slice(e));this.str=this.str.slice(0,e);const r=this.str.charCodeAt(e-1);return r>=55296&&r<=56319&&(this.str=this.str.slice(0,e-1)+"�",n.str="�"+n.str.slice(1)),n}mergeWith(e){return this.str+=e.str,!0}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeString(n===0?this.str:this.str.slice(n))}getRef(){return 4}}const DB=t=>new tn(t.readString()),RB=[dB,fB,bB,xB,wB,kB,SB],LB=0,jB=1,PB=2,BB=3,HB=4,zB=5,$B=6;class rn{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new rn(this.type._copy())}splice(e){throw zt()}mergeWith(e){return!1}integrate(e,n){this.type._integrate(e.doc,n)}delete(e){let n=this.type._start;for(;n!==null;)n.deleted?n.id.clock<(e.beforeState.get(n.id.client)||0)&&e._mergeStructs.push(n):n.delete(e),n=n.right;this.type._map.forEach(r=>{r.deleted?r.id.clock<(e.beforeState.get(r.id.client)||0)&&e._mergeStructs.push(r):r.delete(e)}),e.changed.delete(this.type)}gc(e){let n=this.type._start;for(;n!==null;)n.gc(e,!0),n=n.right;this.type._start=null,this.type._map.forEach(r=>{for(;r!==null;)r.gc(e,!0),r=r.left}),this.type._map=new Map}write(e,n){this.type._write(e)}getRef(){return 7}}const VB=t=>new rn(RB[t.readTypeRef()](t)),Wd=(t,e)=>{let n=e,r=0,s;do r>0&&(n=se(n.client,n.clock+r)),s=xs(t,n),r=n.clock-s.id.clock,n=s.redone;while(n!==null&&s instanceof pe);return{item:s,diff:r}},Of=(t,e)=>{for(;t!==null&&t.keep!==e;)t.keep=e,t=t.parent._item},Da=(t,e,n)=>{const{client:r,clock:s}=e.id,i=new pe(se(r,s+n),e,se(r,s+n-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(n));return e.deleted&&i.markDeleted(),e.keep&&(i.keep=!0),e.redone!==null&&(i.redone=se(e.redone.client,e.redone.clock+n)),e.right=i,i.right!==null&&(i.right.left=i),t._mergeStructs.push(i),i.parentSub!==null&&i.right===null&&i.parent._map.set(i.parentSub,i),e.length=n,i},Kg=(t,e)=>df(t,n=>Js(n.deletions,e)),Rk=(t,e,n,r,s,i)=>{const o=t.doc,l=o.store,a=o.clientID,c=e.redone;if(c!==null)return xt(t,c);let u=e.parent._item,d=null,h;if(u!==null&&u.deleted===!0){if(u.redone===null&&(!n.has(u)||Rk(t,u,n,r,s,i)===null))return null;for(;u.redone!==null;)u=xt(t,u.redone)}const f=u===null?e.parent:u.content.type;if(e.parentSub===null){for(d=e.left,h=e;d!==null;){let b=d;for(;b!==null&&b.parent._item!==u;)b=b.redone===null?null:xt(t,b.redone);if(b!==null&&b.parent._item===u){d=b;break}d=d.left}for(;h!==null;){let b=h;for(;b!==null&&b.parent._item!==u;)b=b.redone===null?null:xt(t,b.redone);if(b!==null&&b.parent._item===u){h=b;break}h=h.right}}else{if(h=null,e.right&&!s){for(d=e;d!==null&&d.right!==null&&(d.right.redone||Js(r,d.right.id)||Kg(i.undoStack,d.right.id)||Kg(i.redoStack,d.right.id));)for(d=d.right;d.redone;)d=xt(t,d.redone);if(d&&d.right!==null)return null}else d=f._map.get(e.parentSub)||null;d!==null&&d.parent._item!==u&&(d=f._map.get(e.parentSub)||null)}const p=Ie(l,a),g=se(a,p),y=new pe(g,d,d&&d.lastId,h,h&&h.id,f,e.parentSub,e.content.copy());return e.redone=g,Of(y,!0),y.integrate(t,0),y};class pe extends Nf{constructor(e,n,r,s,i,o,l,a){super(e,a.getLength()),this.origin=r,this.left=n,this.right=s,this.rightOrigin=i,this.parent=o,this.parentSub=l,this.redone=null,this.content=a,this.info=this.content.isCountable()?xg:0}set marker(e){(this.info&pu)>0!==e&&(this.info^=pu)}get marker(){return(this.info&pu)>0}get keep(){return(this.info&wg)>0}set keep(e){this.keep!==e&&(this.info^=wg)}get countable(){return(this.info&xg)>0}get deleted(){return(this.info&fu)>0}set deleted(e){this.deleted!==e&&(this.info^=fu)}markDeleted(){this.info|=fu}getMissing(e,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=Ie(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=Ie(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===ws&&this.id.client!==this.parent.client&&this.parent.clock>=Ie(n,this.parent.client))return this.parent.client;if(this.origin&&(this.left=jg(e,n,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=xt(e,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===Pt||this.right&&this.right.constructor===Pt)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===pe?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===pe&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===ws){const r=xs(n,this.parent);r.constructor===Pt?this.parent=null:this.parent=r.content.type}return null}integrate(e,n){if(n>0&&(this.id.clock+=n,this.left=jg(e,e.doc.store,se(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(n),this.length-=n),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let r=this.left,s;if(r!==null)s=r.right;else if(this.parentSub!==null)for(s=this.parent._map.get(this.parentSub)||null;s!==null&&s.left!==null;)s=s.left;else s=this.parent._start;const i=new Set,o=new Set;for(;s!==null&&s!==this.right;){if(o.add(s),i.add(s),Qo(this.origin,s.origin)){if(s.id.client<this.id.client)r=s,i.clear();else if(Qo(this.rightOrigin,s.rightOrigin))break}else if(s.origin!==null&&o.has(xs(e.doc.store,s.origin)))i.has(xs(e.doc.store,s.origin))||(r=s,i.clear());else break;s=s.right}this.left=r}if(this.left!==null){const r=this.left.right;this.right=r,this.left.right=this}else{let r;if(this.parentSub!==null)for(r=this.parent._map.get(this.parentSub)||null;r!==null&&r.left!==null;)r=r.left;else r=this.parent._start,this.parent._start=this;this.right=r}this.right!==null?this.right.left=this:this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(e)),this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),hk(e.doc.store,this),this.content.integrate(e,this),Bg(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new Pt(this.id,this.length).integrate(e,0)}get next(){let e=this.right;for(;e!==null&&e.deleted;)e=e.right;return e}get prev(){let e=this.left;for(;e!==null&&e.deleted;)e=e.left;return e}get lastId(){return this.length===1?this.id:se(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&Qo(e.origin,this.lastId)&&this.right===e&&Qo(this.rightOrigin,e.rightOrigin)&&this.id.client===e.id.client&&this.id.clock+this.length===e.id.clock&&this.deleted===e.deleted&&this.redone===null&&e.redone===null&&this.content.constructor===e.content.constructor&&this.content.mergeWith(e.content)){const n=this.parent._searchMarker;return n&&n.forEach(r=>{r.p===e&&(r.p=this,!this.deleted&&this.countable&&(r.index-=this.length))}),e.keep&&(this.keep=!0),this.right=e.right,this.right!==null&&(this.right.left=this),this.length+=e.length,!0}return!1}delete(e){if(!this.deleted){const n=this.parent;this.countable&&this.parentSub===null&&(n._length-=this.length),this.markDeleted(),ao(e.deleteSet,this.id.client,this.id.clock,this.length),Bg(e,n,this.parentSub),this.content.delete(e)}}gc(e,n){if(!this.deleted)throw bt();this.content.gc(e),n?q6(e,this,new Pt(this.id,this.length)):this.content=new po(this.length)}write(e,n){const r=n>0?se(this.id.client,this.id.clock+n-1):this.origin,s=this.rightOrigin,i=this.parentSub,o=this.content.getRef()&lc|(r===null?0:mt)|(s===null?0:Ln)|(i===null?0:ro);if(e.writeInfo(o),r!==null&&e.writeLeftID(r),s!==null&&e.writeRightID(s),r===null&&s===null){const l=this.parent;if(l._item!==void 0){const a=l._item;if(a===null){const c=co(l);e.writeParentInfo(!0),e.writeString(c)}else e.writeParentInfo(!1),e.writeLeftID(a.id)}else l.constructor===String?(e.writeParentInfo(!0),e.writeString(l)):l.constructor===ws?(e.writeParentInfo(!1),e.writeLeftID(l)):bt();i!==null&&e.writeString(i)}this.content.write(e,n)}}const Lk=(t,e)=>FB[e&lc](t),FB=[()=>{bt()},AB,NB,MB,DB,TB,_B,VB,IB,EB,()=>{bt()}],UB=10;class qt extends Nf{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,n){bt()}write(e,n){e.writeInfo(UB),ue(e.restEncoder,this.length-n)}getMissing(e,n){return null}}const jk=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},Pk="__ $YJS$ __";jk[Pk]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");jk[Pk]=!0;const WB=()=>{let t=!0;return(e,n)=>{if(t){t=!1;try{e()}finally{t=!0}}else n!==void 0&&n()}},KB=/[\uD800-\uDBFF]/,qB=/[\uDC00-\uDFFF]/,JB=(t,e)=>{let n=0,r=0;for(;n<t.length&&n<e.length&&t[n]===e[n];)n++;for(n>0&&KB.test(t[n-1])&&n--;r+n<t.length&&r+n<e.length&&t[t.length-r-1]===e[e.length-r-1];)r++;return r>0&&qB.test(t[t.length-r])&&r--,{index:n,remove:t.length-n-r,insert:e.slice(n,e.length-r)}},GB=JB,fn=(t,e)=>t>>>e|t<<32-e,YB=t=>fn(t,2)^fn(t,13)^fn(t,22),XB=t=>fn(t,6)^fn(t,11)^fn(t,25),ZB=t=>fn(t,7)^fn(t,18)^t>>>3,QB=t=>fn(t,17)^fn(t,19)^t>>>10,e4=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),t4=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);class n4{constructor(){const e=new ArrayBuffer(320);this._H=new Uint32Array(e,0,8),this._H.set(t4),this._W=new Uint32Array(e,64,64)}_updateHash(){const e=this._H,n=this._W;for(let d=16;d<64;d++)n[d]=QB(n[d-2])+n[d-7]+ZB(n[d-15])+n[d-16];let r=e[0],s=e[1],i=e[2],o=e[3],l=e[4],a=e[5],c=e[6],u=e[7];for(let d=0,h,f;d<64;d++)h=u+XB(l)+(l&a^~l&c)+e4[d]+n[d]>>>0,f=YB(r)+(r&s^r&i^s&i)>>>0,u=c,c=a,a=l,l=o+h>>>0,o=i,i=s,s=r,r=h+f>>>0;e[0]+=r,e[1]+=s,e[2]+=i,e[3]+=o,e[4]+=l,e[5]+=a,e[6]+=c,e[7]+=u}digest(e){let n=0;for(;n+56<=e.length;){let o=0;for(;o<16&&n+3<e.length;o++)this._W[o]=e[n++]<<24|e[n++]<<16|e[n++]<<8|e[n++];if(n%64!==0){for(this._W.fill(0,o,16);n<e.length;)this._W[o]|=e[n]<<(3-n%4)*8,n++;this._W[o]|=mt<<(3-n%4)*8}this._updateHash()}const r=n%64!==0;this._W.fill(0,0,16);let s=0;for(;n<e.length;s++)for(let o=3;o>=0&&n<e.length;o--)this._W[s]|=e[n++]<<o*8;r||(this._W[s-(n%4===0?0:1)]|=mt<<(3-n%4)*8),this._W[14]=e.byteLength/jj,this._W[15]=e.byteLength*8,this._updateHash();const i=new Uint8Array(32);for(let o=0;o<this._H.length;o++)for(let l=0;l<4;l++)i[o*4+l]=this._H[o]>>>(3-l)*8;return i}}const r4=t=>new n4().digest(t),Ee=new ae("y-sync"),jn=new ae("y-undo");new ae("yjs-cursor");const s4=t=>{for(let n=6;n<t.length;n++)t[n%6]=t[n%6]^t[n];return t.slice(0,6)},i4=t=>LP(s4(r4(jP(t)))),Ra=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&e.sv.get(t.id.client)>t.id.clock&&!Js(e.ds,t.id),o4=[{light:"#ecd44433",dark:"#ecd444"}],l4=(t,e,n)=>{if(!t.has(n)){if(t.size<e.length){const r=Kr();t.forEach(s=>r.add(s)),e=e.filter(s=>!r.has(s))}t.set(n,mP(e))}return t.get(n)},a4=(t,{colors:e=o4,colorMapping:n=new Map,permanentUserData:r=null,onFirstRender:s=()=>{},mapping:i}={})=>{let o=!1;const l=new h4(t,i),a=new ce({props:{editable:c=>{const u=Ee.getState(c);return u.snapshot==null&&u.prevSnapshot==null}},key:Ee,state:{init:(c,u)=>({type:t,doc:t.doc,binding:l,snapshot:null,prevSnapshot:null,isChangeOrigin:!1,isUndoRedoOperation:!1,addToHistory:!0,colors:e,colorMapping:n,permanentUserData:r}),apply:(c,u)=>{const d=c.getMeta(Ee);if(d!==void 0){u=Object.assign({},u);for(const h in d)u[h]=d[h]}return u.addToHistory=c.getMeta("addToHistory")!==!1,u.isChangeOrigin=d!==void 0&&!!d.isChangeOrigin,u.isUndoRedoOperation=d!==void 0&&!!d.isChangeOrigin&&!!d.isUndoRedoOperation,l.prosemirrorView!==null&&d!==void 0&&(d.snapshot!=null||d.prevSnapshot!=null)&&Xv(0,()=>{l.prosemirrorView!=null&&(d.restore==null?l._renderSnapshot(d.snapshot,d.prevSnapshot,u):(l._renderSnapshot(d.snapshot,d.snapshot,u),delete u.restore,delete u.snapshot,delete u.prevSnapshot,l.mux(()=>{l._prosemirrorChanged(l.prosemirrorView.state.doc)})))}),u}},view:c=>(l.initView(c),i==null&&l._forceRerender(),s(),{update:()=>{const u=a.getState(c.state);if(u.snapshot==null&&u.prevSnapshot==null&&(o||c.state.doc.content.findDiffStart(c.state.doc.type.createAndFill().content)!==null)){if(o=!0,u.addToHistory===!1&&!u.isChangeOrigin){const d=jn.getState(c.state),h=d&&d.undoManager;h&&h.stopCapturing()}l.mux(()=>{u.doc.transact(d=>{d.meta.set("addToHistory",u.addToHistory),l._prosemirrorChanged(c.state.doc)},Ee)})}},destroy:()=>{l.destroy()}})});return a},qg=(t,e,n,r)=>{if(n==null||!(r===null||n>1&&r<=1||M4(e,t,n,r)))return r;const i=Uk(e,t,n);return i!==null?i:r},c4=(t,e,n,r)=>{if(e!==null&&e.anchor!==null&&e.head!==null)if(e.type==="all")t.setSelection(new dn(t.doc));else if(e.type==="node"){const s=Er(n.doc,n.type,e.anchor,n.mapping);s!==null&&t.setSelection(u4(t,s))}else if(e.type==="nodeRange"){const s=Er(n.doc,n.type,e.anchor,n.mapping),i=Er(n.doc,n.type,e.head,n.mapping),o=d4(t,s,i,e.depth);o!==null&&t.setSelection(o)}else{let s=Er(n.doc,n.type,e.anchor,n.mapping),i=Er(n.doc,n.type,e.head,n.mapping);r!=null&&(s=qg(t.doc,r,e.absAnchor,s),i=qg(t.doc,r,e.absHead,i)),s===null&&(s=i),i===null&&(i=s),s!==null&&i!==null&&t.setSelection(ee.between(t.doc.resolve(s),t.doc.resolve(i)))}},u4=(t,e)=>{const n=t.doc.resolve(e);return n.nodeAfter?Y.create(t.doc,e):ee.near(n)},d4=(t,e,n,r)=>{if(e===null||n===null)return null;const s=Math.min(Math.max(e,0),t.doc.content.size),i=Math.min(Math.max(n,0),t.doc.content.size);try{const o=te.fromJSON(t.doc,{type:"nodeRange",anchor:s,head:i,depth:r});return o.ranges.length?o:ee.near(t.doc.resolve(s))}catch{return ee.near(t.doc.resolve(s))}},Kd=(t,e)=>{const n=e.selection.jsonID;return{type:n,depth:n==="nodeRange"?e.selection.depth:void 0,anchor:Ba(e.selection.anchor,t.type,t.mapping),head:Ba(e.selection.head,t.type,t.mapping),absAnchor:e.selection.anchor,absHead:e.selection.head}};class h4{constructor(e,n=new Map){this.type=e,this.prosemirrorView=null,this.mux=WB(),this.mapping=n,this.isOMark=new Map,this._observeFunction=this._typeChanged.bind(this),this.doc=e.doc,this.beforeTransactionSelection=null,this.beforeAllTransactions=()=>{this.beforeTransactionSelection===null&&this.prosemirrorView!=null&&(this.beforeTransactionSelection=Kd(this,this.prosemirrorView.state))},this.afterAllTransactions=()=>{this.beforeTransactionSelection=null},this._domSelectionInView=null}get _tr(){return this.prosemirrorView.state.tr.setMeta("addToHistory",!1)}_isLocalCursorInView(){return this.prosemirrorView.hasFocus()?(Dv&&this._domSelectionInView===null&&(Xv(0,()=>{this._domSelectionInView=null}),this._domSelectionInView=this._isDomSelectionInView()),this._domSelectionInView):!1}_isDomSelectionInView(){const e=this.prosemirrorView._root.getSelection();if(e==null||e.anchorNode==null)return!1;const n=this.prosemirrorView._root.createRange();n.setStart(e.anchorNode,e.anchorOffset),n.setEnd(e.focusNode,e.focusOffset),n.getClientRects().length===0&&n.startContainer&&n.collapsed&&n.selectNodeContents(n.startContainer);const s=n.getBoundingClientRect(),i=Mo.documentElement;return s.bottom>=0&&s.right>=0&&s.left<=(window.innerWidth||i.clientWidth||0)&&s.top<=(window.innerHeight||i.clientHeight||0)}renderSnapshot(e,n){n||(n=uk(ik(),new Map)),this.prosemirrorView.dispatch(this._tr.setMeta(Ee,{snapshot:e,prevSnapshot:n}))}unrenderSnapshot(){this.mapping.clear(),this.mux(()=>{const e=this.type.toArray().map(r=>Ml(r,this.prosemirrorView.state.schema,this)).filter(r=>r!==null),n=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new q(j.from(e),0,0));n.setMeta(Ee,{snapshot:null,prevSnapshot:null}),this.prosemirrorView.dispatch(n)})}_forceRerender(){this.mapping.clear(),this.mux(()=>{const e=this.beforeTransactionSelection!==null?null:this.prosemirrorView.state.selection,n=this.type.toArray().map(s=>Ml(s,this.prosemirrorView.state.schema,this)).filter(s=>s!==null),r=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new q(j.from(n),0,0));if(e){const s=Jr(fr(e.anchor,0),r.doc.content.size),i=Jr(fr(e.head,0),r.doc.content.size);r.setSelection(ee.create(r.doc,s,i))}this.prosemirrorView.dispatch(r.setMeta(Ee,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(e,n,r){let s=this.doc,i=this.type;if(e||(e=vu(this.doc)),e instanceof Uint8Array||n instanceof Uint8Array)if((!(e instanceof Uint8Array)||!(n instanceof Uint8Array))&&bt(),s=new Qr({gc:!1}),$d(s,n),n=vu(s),$d(s,e),e=vu(s),i._item===null){const o=Array.from(this.doc.share.keys()).find(l=>this.doc.share.get(l)===this.type);i=s.getXmlFragment(o)}else{const o=s.store.clients.get(i._item.id.client)??[],l=en(o,i._item.id.clock);i=o[l].content.type}this.mapping.clear(),this.mux(()=>{s.transact(o=>{const l=r.permanentUserData;l&&l.dss.forEach(d=>{pr(o,d,h=>{})});const a=(d,h)=>{const f=d==="added"?l.getUserByClientId(h.client):l.getUserByDeletedId(h);return{user:f,type:d,color:l4(r.colorMapping,r.colors,f)}},c=vk(i,new Af(n.ds,e.sv)).map(d=>!d._item.deleted||Ra(d._item,e)||Ra(d._item,n)?Ml(d,this.prosemirrorView.state.schema,{mapping:new Map,isOMark:new Map},e,n,a):null).filter(d=>d!==null),u=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new q(j.from(c),0,0));this.prosemirrorView.dispatch(u.setMeta(Ee,{isChangeOrigin:!0}))},Ee)})}_typeChanged(e,n){if(this.prosemirrorView==null)return;const r=Ee.getState(this.prosemirrorView.state);if(e.length===0||r.snapshot!=null||r.prevSnapshot!=null){this.renderSnapshot(r.snapshot,r.prevSnapshot);return}this.mux(()=>{const s=(a,c)=>this.mapping.delete(c);pr(n,n.deleteSet,a=>{if(a.constructor===pe){const c=a.content.type;c&&this.mapping.delete(c)}}),n.changed.forEach(s),n.changedParentTypes.forEach(s),this.mapping.clear();const i=this.type.toArray().map(a=>Bk(a,this.prosemirrorView.state.schema,this)).filter(a=>a!==null),o=this.prosemirrorView.state.doc;let l=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new q(j.from(i),0,0));c4(l,this.beforeTransactionSelection,this,o),l=l.setMeta(Ee,{isChangeOrigin:!0,isUndoRedoOperation:n.origin instanceof mk}),this.beforeTransactionSelection!==null&&this._isLocalCursorInView()&&l.scrollIntoView(),this.prosemirrorView.dispatch(l)})}_prosemirrorChanged(e){this.doc.transact(()=>{ja(this.doc,this.type,e,this),this.beforeTransactionSelection=Kd(this,this.prosemirrorView.state)},Ee)}initView(e){this.prosemirrorView!=null&&this.destroy(),this.prosemirrorView=e,this.doc.on("beforeAllTransactions",this.beforeAllTransactions),this.doc.on("afterAllTransactions",this.afterAllTransactions),this.type.observeDeep(this._observeFunction)}destroy(){this.prosemirrorView!=null&&(this.prosemirrorView=null,this.type.unobserveDeep(this._observeFunction),this.doc.off("beforeAllTransactions",this.beforeAllTransactions),this.doc.off("afterAllTransactions",this.afterAllTransactions))}}const Bk=(t,e,n,r,s,i)=>{const o=n.mapping.get(t);if(o===void 0){if(t instanceof et)return Ml(t,e,n,r,s,i);throw zt()}return o},Ml=(t,e,n,r,s,i)=>{const o=[],l=a=>{var c,u;if(a instanceof et){const d=Bk(a,e,n,r,s,i);d!==null&&o.push(d)}else{const d=(u=(c=a._item.right)==null?void 0:c.content)==null?void 0:u.type;d instanceof mr&&!d._item.deleted&&d._item.id.client===d.doc.clientID&&(a.applyDelta([{retain:a.length},...d.toDelta()]),d.doc.transact(f=>{d._item.delete(f)}));const h=f4(a,e,n,r,s,i);h!==null&&h.forEach(f=>{f!==null&&o.push(f)})}};r===void 0||s===void 0?t.toArray().forEach(l):vk(t,new Af(s.ds,r.sv)).forEach(l);try{const a=t.getAttributes(r);r!==void 0&&(Ra(t._item,r)?Ra(t._item,s)||(a.ychange=i?i("added",t._item.id):{type:"added"}):a.ychange=i?i("removed",t._item.id):{type:"removed"});const c=e.node(t.nodeName,a,o);return n.mapping.set(t,c),c}catch{return t.doc.transact(c=>{t._item.delete(c)},Ee),n.mapping.delete(t),null}},f4=(t,e,n,r,s,i)=>{const o=[],l=t.toDelta(r,s,i);try{for(let a=0;a<l.length;a++){const c=l[a];o.push(e.text(c.insert,x4(c.attributes,e)))}}catch{return t.doc.transact(c=>{t._item.delete(c)},Ee),null}return o},p4=(t,e)=>{const n=new st,r=t.map(s=>({insert:s.text,attributes:Vk(s.marks,e)}));return n.applyDelta(r),e.mapping.set(n,t),n},m4=(t,e)=>{const n=new et(t.type.name);for(const r in t.attrs){const s=t.attrs[r];s!==null&&r!=="ychange"&&n.setAttribute(r,s)}return n.insert(0,vc(t).map(r=>La(r,e))),e.mapping.set(n,t),n},La=(t,e)=>t instanceof Array?p4(t,e):m4(t,e),Jg=t=>typeof t=="object"&&t!==null,If=(t,e)=>{const n=Object.keys(t).filter(s=>t[s]!==null);let r=n.length===Object.keys(e).filter(s=>e[s]!==null).length;for(let s=0;s<n.length&&r;s++){const i=n[s],o=t[i],l=e[i];r=i==="ychange"||o===l||Jg(o)&&Jg(l)&&If(o,l)}return r},vc=t=>{const e=t.content.content,n=[];for(let r=0;r<e.length;r++){const s=e[r];if(s.isText){const i=[];for(let o=e[r];r<e.length&&o.isText;o=e[++r])i.push(o);r--,n.push(i)}else n.push(s)}return n},Df=(t,e)=>{const n=t.toDelta();return n.length===e.length&&n.every((r,s)=>r.insert===e[s].text&&Ov(r.attributes||{}).length===e[s].marks.length&&Ws(r.attributes,(i,o)=>{var u;const l=$k(o),a=e[s].marks;return a.find(d=>d.type.name===l)?If(i,(u=a.find(d=>d.type.name===l))==null?void 0:u.attrs):!1}))},Bs=(t,e)=>{if(t instanceof et&&!(e instanceof Array)&&Pa(t,e)){const n=vc(e);return t._length===n.length&&If(t.getAttributes(),e.attrs)&&t.toArray().every((r,s)=>Bs(r,n[s]))}return t instanceof st&&e instanceof Array&&Df(t,e)},mo=(t,e)=>t===e||t instanceof Array&&e instanceof Array&&t.length===e.length&&t.every((n,r)=>e[r]===n),g4=(t,e,n)=>{const r=new Map;e.forEach((a,c)=>{r.has(a)||r.set(a,c)});const s=[];if(t.forEach((a,c)=>{const u=n.mapping.get(a),d=r.get(u);d!==void 0&&mo(u,e[d])&&s.push({yIndex:c,pIndex:d,yChild:a})}),s.length===0)return[];const i=new Array(s.length),o=[];for(let a=0;a<s.length;a++){let c=0,u=o.length;for(;c<u;){const d=c+u>>1;s[o[d]].pIndex<s[a].pIndex?c=d+1:u=d}i[a]=c>0?o[c-1]:-1,o[c]=a}const l=[];for(let a=o[o.length-1];a!==-1;a=i[a])l.push(s[a]);return l.reverse()},Gg=(t,e,n,r)=>{n>0&&(t.slice(e,e+n).forEach(s=>r.mapping.delete(s)),t.delete(e,n))},Yg=(t,e,n,r,s,i)=>{if(r<s){const o=[];for(let l=r;l<s;l++)o.push(La(n[l],i));t.insert(e,o)}},Hk=(t,e,n,r)=>e instanceof st&&n instanceof Array?(Df(e,n)?r.mapping.set(e,n):zk(e,n,r),!0):e instanceof et&&!(n instanceof Array)&&Pa(e,n)?(Bs(e,n)?r.mapping.set(e,n):ja(t,e,n,r),!0):!1,Xg=(t,e,n,r,s,i,o,l,a)=>{const c=Jr(i-s,l-o);for(let u=0;u<c;u++){const d=r[s+u],h=n[o+u];Hk(t,d,h,a)||(Gg(e,o+u,1,a),Yg(e,o+u,n,o+u,o+u+1,a))}Gg(e,o+c,i-s-c,a),Yg(e,o+c,n,o+c,l,a)},y4=(t,e,n,r,s)=>{const i=g4(r,n,s);if(i.length<2||!i.some(a=>a.yIndex!==a.pIndex)||i.some(a=>{const c=n[a.pIndex];return!(a.yChild instanceof st&&c instanceof Array||a.yChild instanceof et&&!(c instanceof Array))}))return!1;let o=0,l=0;for(const a of i){Xg(t,e,n,r,o,a.yIndex,l,a.pIndex,s);const c=n[a.pIndex];Hk(t,a.yChild,c,s),o=a.yIndex+1,l=a.pIndex+1}return Xg(t,e,n,r,o,r.length,l,n.length,s),!0},Zg=(t,e,n)=>{const r=t.toArray(),s=vc(e),i=s.length,o=r.length,l=Jr(o,i);let a=0,c=0,u=!1;for(;a<l;a++){const d=r[a],h=s[a];if(mo(n.mapping.get(d),h))u=!0;else if(!Bs(d,h))break}for(;a+c<l;c++){const d=r[o-c-1],h=s[i-c-1];if(mo(n.mapping.get(d),h))u=!0;else if(!Bs(d,h))break}return{equalityFactor:a+c,foundMappedChild:u}},b4=t=>{let e="",n=t._start;const r={};for(;n!==null;)n.deleted||(n.countable&&n.content instanceof tn?e+=n.content.str:n.content instanceof je&&(r[n.content.key]=null)),n=n.right;return{str:e,nAttrs:r}},zk=(t,e,n)=>{n.mapping.set(t,e);const{nAttrs:r,str:s}=b4(t),i=e.map(c=>({insert:c.text,attributes:Object.assign({},r,Vk(c.marks,n))})),{insert:o,remove:l,index:a}=GB(s,i.map(c=>c.insert).join(""));t.delete(a,l),t.insert(a,o),t.applyDelta(i.map(c=>({retain:c.insert.length,attributes:c.attributes})))},w4=/(.*)(--[a-zA-Z0-9+/=]{8})$/,$k=t=>{var e;return((e=w4.exec(t))==null?void 0:e[1])??t},x4=(t,e)=>{const n=[];for(const r in t)n.push(e.mark($k(r),t[r]));return n},Vk=(t,e)=>{const n={};return t.forEach(r=>{if(r.type.name!=="ychange"){const s=Fn(e.isOMark,r.type,()=>!r.type.excludes(r.type));n[s?`${r.type.name}--${i4(r.toJSON())}`:r.type.name]=r.attrs}}),n},ja=(t,e,n,r)=>{if(e instanceof et&&e.nodeName!==n.type.name)throw new Error("node name mismatch!");if(r.mapping.set(e,n),e instanceof et){const d=e.getAttributes(),h=n.attrs;for(const f in h)h[f]!==null?d[f]!==h[f]&&f!=="ychange"&&e.setAttribute(f,h[f]):e.removeAttribute(f);for(const f in d)h[f]===void 0&&e.removeAttribute(f)}const s=vc(n),i=s.length,o=e.toArray(),l=o.length,a=Jr(i,l);if(y4(t,e,s,o,r))return;let c=0,u=0;for(;c<a;c++){const d=o[c],h=s[c];if(!mo(r.mapping.get(d),h))if(Bs(d,h))r.mapping.set(d,h);else break}for(;u+c+1<a;u++){const d=o[l-u-1],h=s[i-u-1];if(!mo(r.mapping.get(d),h))if(Bs(d,h))r.mapping.set(d,h);else break}t.transact(()=>{for(;l-c-u>0&&i-c-u>0;){const h=o[c],f=s[c],p=o[l-u-1],g=s[i-u-1];if(h instanceof st&&f instanceof Array)Df(h,f)||zk(h,f,r),c+=1;else{let y=h instanceof et&&Pa(h,f),b=p instanceof et&&Pa(p,g);if(y&&b){const w=Zg(h,f,r),v=Zg(p,g,r);w.foundMappedChild&&!v.foundMappedChild?b=!1:!w.foundMappedChild&&v.foundMappedChild||w.equalityFactor<v.equalityFactor?y=!1:b=!1}y?(ja(t,h,f,r),c+=1):b?(ja(t,p,g,r),u+=1):(r.mapping.delete(e.get(c)),e.delete(c,1),e.insert(c,[La(f,r)]),c+=1)}}const d=l-c-u;if(l===1&&i===0&&o[0]instanceof st?(r.mapping.delete(o[0]),o[0].delete(0,o[0].length)):d>0&&(e.slice(c,c+d).forEach(h=>r.mapping.delete(h)),e.delete(c,d)),c+u<i){const h=[];for(let f=c;f<i-u;f++)h.push(La(s[f],r));e.insert(c,h)}},Ee)},Pa=(t,e)=>!(e instanceof Array)&&t.nodeName===e.type.name,Ba=(t,e,n)=>{if(t===0)return xu(e,0,-1);let r=e._first===null?null:e._first.content.type;for(;r!==null&&e!==r;){if(r instanceof st){if(r._length>=t)return xu(r,t,-1);if(t-=r._length,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{do r=r._item===null?null:r._item.parent,t--;while(r!==e&&r!==null&&r._item!==null&&r._item.next===null);r!==null&&r!==e&&(r=r._item===null?null:r._item.next.content.type)}}else{const s=(n.get(r)||{nodeSize:0}).nodeSize;if(r._first!==null&&t<s)r=r._first.content.type,t--;else{if(t===1&&r._length===0&&s>1)return new Ta(r._item===null?null:r._item.id,r._item===null?co(r):null,null);if(t-=s,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{if(t===0)return r=r._item===null?r:r._item.parent,new Ta(r._item===null?null:r._item.id,r._item===null?co(r):null,null);do r=r._item.parent,t--;while(r!==e&&r._item.next===null);r!==e&&(r=r._item.next.content.type)}}}if(r===null)throw bt();if(t===0&&r.constructor!==st&&r!==e)return k4(r._item.parent,r._item)}return xu(e,e._length,-1)},v4=(t,e,n)=>{if(n===null)return!1;const r=ck(e,t);return r!==null&&r.type instanceof st&&e.item!==null&&n<=1},k4=(t,e)=>{let n=null,r=null;return t._item===null?r=co(t):n=se(t._item.id.client,t._item.id.clock),new Ta(n,r,e.id)},Er=(t,e,n,r)=>{const s=ck(n,t);if(s===null||s.type!==e&&!uo(e,s.type._item))return null;let i=s.type,o=0;if(i.constructor===st)o=s.index;else if(i._item===null||!i._item.deleted){let a=i._first,c=0;for(;c<i._length&&c<s.index&&a!==null;){if(!a.deleted){const u=a.content.type;if(c++,u instanceof st)o+=u._length;else{const d=r.get(u);if(d==null)return null;o+=d.nodeSize}}a=a.right}o+=1}for(;i!==e&&i._item!==null;){const a=i._item.parent;if(a._item===null||!a._item.deleted){o+=1;let c=a._first;for(;c!==null;){const u=c.content.type;if(u===i)break;if(!c.deleted)if(u instanceof st)o+=u._length;else{const d=r.get(u);if(d==null)return null;o+=d.nodeSize}c=c.right}}i=a}const l=o-1;return v4(t,n,l)?null:l},Fk=(t,e)=>{if(t===e)return!0;const n=Object.keys(t);return n.length===Object.keys(e).length&&n.every(r=>t[r]===e[r])},S4=t=>{const e=t.type.spec.attrs||{};return Object.keys(t.attrs).some(n=>{const r=e[n];return r==null||!Object.prototype.hasOwnProperty.call(r,"default")||r.default!==t.attrs[n]})},C4=(t,e,n)=>{let r=e+1,s=n;for(let i=1;i<t.depth;i++){const o=t.index(i);if(o>=s.childCount)return null;for(let l=0;l<o;l++)r+=s.child(l).nodeSize;if(r+=1,s=s.child(o),s.type!==t.node(i+1).type)return null}return s.isTextblock?r+Math.min(t.parentOffset,s.content.size):null},Uk=(t,e,n)=>{let r=0,s=0;for(;s<t.childCount;s++){const f=t.child(s);if(r+f.nodeSize>n)break;r+=f.nodeSize}if(s>=t.childCount)return null;const i=t.child(s),o=t.resolve(n),l=(f,p)=>{if(o.depth===0){const g=f+(n-r),y=f+1,b=f+p.nodeSize-1;return Math.max(y,Math.min(g,b))}return C4(o,f,p)},a=(f,p=!1)=>{let g=0;for(let x=0;x<=s;x++)f(t.child(x))&&g++;let y=0,b=-1,w=null,v=0;for(let x=0;x<e.childCount;x++){const k=e.child(x);f(k)&&(y++,y===g&&(b=v,w=k)),v+=k.nodeSize}return w===null||p&&(g!==1||y!==1)?null:l(b,w)},c=f=>f.type===i.type&&Fk(f.attrs,i.attrs),u=i.textContent,d=a(f=>c(f)&&f.textContent===u);if(d!==null)return d;const h=a(f=>f.type===i.type&&f.textContent===u);if(h!==null)return h;if(S4(i)){const f=a(c,!0);if(f!==null)return f}return a(f=>c(f)&&u!==""&&f.textContent!==""&&(u.startsWith(f.textContent)||f.textContent.startsWith(u)),!0)},M4=(t,e,n,r)=>{if(r===null)return!1;const s=t.resolve(n),i=e.resolve(r);if(!s.parent.isTextblock)return!1;if(!i.parent.isTextblock||s.parent.textContent!==i.parent.textContent||s.parentOffset!==0&&i.parentOffset===0)return!0;const o=s.parentOffset===0&&i.parentOffset===0,l=s.parentOffset!==i.parentOffset||s.parent.type!==i.parent.type||!Fk(s.parent.attrs,i.parent.attrs);if(o||l){const a=Uk(t,e,n);return a!==null&&a!==r}return!1},A4=t=>{const e=jn.getState(t).undoManager;if(e!=null)return e.undo(),!0},E4=t=>{const e=jn.getState(t).undoManager;if(e!=null)return e.redo(),!0},T4=new Set(["paragraph"]),_4=(t,e)=>!(t instanceof pe)||!(t.content instanceof rn)||!(t.content.type instanceof mr||t.content.type instanceof et&&e.has(t.content.type.nodeName))||t.content.type._length===0,N4=({protectedNodes:t=T4,trackedOrigins:e=[],undoManager:n=null}={})=>new ce({key:jn,state:{init:(r,s)=>{const i=Ee.getState(s);let o=n;if(!o){const l=i.doc,a=new Set(l?l._observers.get("destroy"):[]);o=new mk(i.type,{trackedOrigins:new Set([Ee].concat(e)),deleteFilter:u=>_4(u,t),captureTransaction:u=>u.meta.get("addToHistory")!==!1});const c=l?l._observers.get("destroy"):new Set;o._yTiptapDocDestroyListeners=Array.from(c||[]).filter(u=>!a.has(u))}return{undoManager:o,prevSel:null,hasUndoOps:o.undoStack.length>0,hasRedoOps:o.redoStack.length>0}},apply:(r,s,i,o)=>{const l=Ee.getState(o).binding,a=s.undoManager,c=a.undoStack.length>0,u=a.redoStack.length>0;return l?{undoManager:a,prevSel:Kd(l,i),hasUndoOps:c,hasRedoOps:u}:c!==s.hasUndoOps||u!==s.hasRedoOps?Object.assign({},s,{hasUndoOps:a.undoStack.length>0,hasRedoOps:a.redoStack.length>0}):s}},view:r=>{const s=Ee.getState(r.state),i=jn.getState(r.state).undoManager;return i.on("stack-item-added",({stackItem:o})=>{const l=s.binding;l&&o.meta.set(l,jn.getState(r.state).prevSel)}),i.on("stack-item-popped",({stackItem:o})=>{const l=s.binding;l&&(l.beforeTransactionSelection=o.meta.get(l)||l.beforeTransactionSelection)}),{destroy:()=>{i.destroy();const o=i._yTiptapDocDestroyListeners;o&&i.doc&&(o.forEach(l=>i.doc.off("destroy",l)),i._yTiptapDocDestroyListeners=null)}}}});function Rf(t){return!!t.getMeta(Ee)}function O4(t,e){const n=Ee.getState(t);return Er(n.doc,n.type,e,n.binding.mapping)||0}function Wk(t,e){const n=Ee.getState(t);return Ba(e,n.type,n.binding.mapping)}var Al=class Kk extends kh{constructor(e,n){super(e),this.yRelativePosition=n}static fromJSON(e){return new Kk(e.position,e.yRelativePosition)}toJSON(){return{position:this.position,yRelativePosition:this.yRelativePosition}}};function I4(t,e){const n=Wk(e,t);return new Al(t,n)}function D4(t,e,n){const r=t instanceof Al?t.yRelativePosition:null;if(Rf(e)&&r){const o=O4(n,r);return{position:new Al(o,r),mapResult:null}}const s=uy(t,e),i=s.position.position;return{position:new Al(i,r??Wk(n,i)),mapResult:s.mapResult}}ie.create({name:"collaboration",priority:1e3,addOptions(){return{document:null,field:"default",fragment:null,provider:null}},addStorage(){return{isDisabled:!1}},onCreate(){this.editor.extensionManager.extensions.find(t=>t.name==="undoRedo")&&console.warn('[tiptap warn]: "@tiptap/extension-collaboration" comes with its own history support and is not compatible with "@tiptap/extension-undo-redo".')},onBeforeCreate(){this.editor.utils.getUpdatedPosition=(t,e)=>D4(t,e,this.editor.state),this.editor.utils.createMappablePosition=t=>I4(t,this.editor.state)},addCommands(){return{undo:()=>({tr:t,state:e,dispatch:n})=>(t.setMeta("preventDispatch",!0),jn.getState(e).undoManager.undoStack.length===0?!1:n?A4(e):!0),redo:()=>({tr:t,state:e,dispatch:n})=>(t.setMeta("preventDispatch",!0),jn.getState(e).undoManager.redoStack.length===0?!1:n?E4(e):!0)}},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Mod-y":()=>this.editor.commands.redo(),"Shift-Mod-z":()=>this.editor.commands.redo()}},addProseMirrorPlugins(){const t=this.options.fragment?this.options.fragment:this.options.document.getXmlFragment(this.options.field),e=N4(this.options.yUndoOptions),n=e.spec.view;e.spec.view=i=>{const{undoManager:o}=jn.getState(i.state);o.restore&&(o.restore(),o.restore=()=>{});const l=n?n(i):void 0;return{destroy:()=>{const a=o.trackedOrigins.has(o),c=o._observers;o.restore=()=>{a&&o.trackedOrigins.add(o),o.doc.on("afterTransaction",o.afterTransactionHandler),o._observers=c},l!=null&&l.destroy&&l.destroy()}}};const r={...this.options.ySyncOptions,onFirstRender:this.options.onFirstRender};return[a4(t,r),e,this.editor.options.enableContentCheck&&new ce({key:new ae("filterInvalidContent"),filterTransaction:i=>{if(!Rf(i))return!0;if(this.storage.isDisabled)return!1;if(!i.docChanged)return!0;try{return i.doc.check(),!0}catch(o){return this.storage.isDisabled=!0,this.editor.emit("contentError",{error:o,editor:this.editor,disableCollaboration:()=>{var l;(l=t.doc)==null||l.destroy()}}),!0}}})].filter(Boolean)}});function Qg(t){if(!t.length)return fe.empty;const e=[],n=t[0].$from.node(0);return t.forEach(r=>{const s=r.$from.pos,i=r.$from.nodeAfter;i&&e.push(Re.node(s,s+i.nodeSize,{class:"ProseMirror-selectednoderange"}))}),fe.create(n,e)}function R4(t,e,n){const r=n.isText||n.isAtom?0:1;return{start:t+r,end:t+e-r}}function kc(t,e,n,r={}){const s=[],i=t.node(0),{extendOnBoundaryOverlap:o=!0}=r;typeof n=="number"&&n>=0||(t.sameParent(e)?n=Math.max(0,t.sharedDepth(e.pos)-1):n=t.sharedDepth(e.pos));const l=new Vi(t,e,n),a=l.depth===0?0:i.resolve(l.start).posAtIndex(0);return l.parent.forEach((c,u)=>{const d=a+u,h=d+c.nodeSize,f=R4(d,c.nodeSize,c),p=o?e.pos>=f.start&&t.pos<=f.end:e.pos>f.start&&t.pos<f.end;if(d<l.start||d>=l.end||!p)return;const g=new eh(i.resolve(d),i.resolve(h));s.push(g)}),s}var L4=class qk{constructor(e,n,r){this.anchor=e,this.head=n,this.depth=r??0}map(e){return new qk(e.map(this.anchor),e.map(this.head),this.depth)}resolve(e){const n=e.resolve(this.anchor),r=e.resolve(this.head);return new un(n,r,this.depth)}},un=class Zn extends te{constructor(e,n,r,s=1){const{doc:i}=e,o=e===n,l=e.pos===i.content.size&&n.pos===i.content.size,a=o&&!l?i.resolve(n.pos+(s>0?1:-1)):n,c=o&&l?i.resolve(e.pos-(s>0?1:-1)):e,u=kc(c.min(a),c.max(a),r),d=a.pos>=e.pos?u[0].$from:u[u.length-1].$to,h=a.pos>=e.pos?u[u.length-1].$to:u[0].$from;super(d,h,u),this.depth=r}get $to(){return this.ranges[this.ranges.length-1].$to}eq(e){return e instanceof Zn&&e.$from.pos===this.$from.pos&&e.$to.pos===this.$to.pos}map(e,n){const r=e.resolve(n.map(this.anchor)),s=e.resolve(n.map(this.head));return new Zn(r,s,this.depth)}toJSON(){return{type:"nodeRange",anchor:this.anchor,head:this.head,depth:this.depth}}get isForwards(){return this.head>=this.anchor}get isBackwards(){return!this.isForwards}extendBackwards(){const{doc:e}=this.$from;if(this.isForwards&&this.ranges.length>1){const s=this.ranges.slice(0,-1),i=s[0].$from,o=s[s.length-1].$to;return new Zn(i,o,this.depth)}const n=this.ranges[0],r=e.resolve(Math.max(0,n.$from.pos-1));return new Zn(this.$anchor,r,this.depth)}extendForwards(){const{doc:e}=this.$from;if(this.isBackwards&&this.ranges.length>1){const s=this.ranges.slice(1),i=s[0].$from,o=s[s.length-1].$to;return new Zn(o,i,this.depth)}const n=this.ranges[this.ranges.length-1],r=e.resolve(Math.min(e.content.size,n.$to.pos+1));return new Zn(this.$anchor,r,this.depth)}static fromJSON(e,n){return new Zn(e.resolve(n.anchor),e.resolve(n.head),n.depth)}static create(e,n,r,s,i=1){return new this(e.resolve(n),e.resolve(r),s,i)}getBookmark(){return new L4(this.anchor,this.head,this.depth)}};un.prototype.visible=!1;try{te.jsonID("nodeRange",un)}catch{}function Si(t){return t instanceof un}ie.create({name:"nodeRange",addOptions(){return{depth:void 0,key:"Mod"}},addKeyboardShortcuts(){return{"Shift-ArrowUp":({editor:t})=>{const{depth:e}=this.options,{view:n,state:r}=t,{doc:s,selection:i,tr:o}=r,{anchor:l,head:a}=i;if(!Si(i)){const u=un.create(s,l,a,e,-1);return o.setSelection(u),n.dispatch(o),!0}const c=i.extendBackwards();return o.setSelection(c),n.dispatch(o),!0},"Shift-ArrowDown":({editor:t})=>{const{depth:e}=this.options,{view:n,state:r}=t,{doc:s,selection:i,tr:o}=r,{anchor:l,head:a}=i;if(!Si(i)){const u=un.create(s,l,a,e);return o.setSelection(u),n.dispatch(o),!0}const c=i.extendForwards();return o.setSelection(c),n.dispatch(o),!0},"Mod-a":({editor:t})=>{const{depth:e}=this.options,{view:n,state:r}=t,{doc:s,tr:i}=r,o=un.create(s,0,s.content.size,e);return i.setSelection(o),n.dispatch(i),!0}}},onSelectionUpdate(){const{selection:t}=this.editor.state;Si(t)&&this.editor.view.dom.classList.add("ProseMirror-noderangeselection")},addProseMirrorPlugins(){let t=!1,e=!1;return[new ce({key:new ae("nodeRange"),props:{attributes:()=>t?{class:"ProseMirror-noderangeselection"}:{class:""},handleDOMEvents:{mousedown:(n,r)=>{const{key:s}=this.options,i=/Mac/.test(navigator.platform),o=!!r.shiftKey,l=!!r.ctrlKey,a=!!r.altKey,c=!!r.metaKey,u=i?c:l;return(s==null||s==="Shift"&&o||s==="Control"&&l||s==="Alt"&&a||s==="Meta"&&c||s==="Mod"&&u)&&(e=!0),e&&document.addEventListener("mouseup",()=>{e=!1;const{state:d}=n,{doc:h,selection:f,tr:p}=d,{$anchor:g,$head:y}=f;if(g.sameParent(y))return;const b=un.create(h,g.pos,y.pos,this.options.depth);p.setSelection(b),n.dispatch(p)},{once:!0}),!1}},decorations:n=>{const{selection:r}=n,s=Si(r);if(t=!1,!e)return s?(t=!0,Qg(r.ranges)):null;const{$from:i,$to:o}=r;if(!s&&i.sameParent(o))return null;const l=kc(i,o,this.options.depth);return l.length?(t=!0,Qg(l)):null}}})]}});function j4(t,e){const n=getComputedStyle(t);if(e)return e.filter(s=>s.trim().length>0).map(s=>`${s}:${n.getPropertyValue(s)};`).join("");let r="";for(let s=0;s<n.length;s+=1)r+=`${n[s]}:${n.getPropertyValue(n[s])};`;return r}function P4(t,e){const n=t.cloneNode(!0),r=[t,...Array.from(t.getElementsByTagName("*"))],s=[n,...Array.from(n.getElementsByTagName("*"))];return r.forEach((i,o)=>{s[o].style.cssText=j4(i,e)}),n}var B4={id:"listItemFirstChild",evaluate:({parent:t,isFirst:e})=>e&&t&&["listItem","taskItem"].includes(t.type.name)?1e3:0},H4={id:"listWrapperDeprioritize",evaluate:({node:t})=>{const e=["listItem","taskItem"],n=t.firstChild;return n&&e.includes(n.type.name)?1e3:0}},z4={id:"tableStructure",evaluate:({node:t,parent:e})=>["tableRow","tableCell","tableHeader"].includes(t.type.name)||e&&e.type.name==="tableHeader"?1e3:0},$4={id:"inlineContent",evaluate:({node:t})=>t.isInline||t.isText?1e3:0},V4=[B4,H4,z4,$4],e1={edges:["left","top"],threshold:12,strength:500};function Cu(t){return t===void 0||t==="left"?{...e1}:t==="right"?{edges:["right","top"],threshold:12,strength:500}:t==="both"?{edges:["left","right","top"],threshold:12,strength:500}:t==="none"?{edges:[],threshold:0,strength:0}:{...e1,...t}}function F4(t,e,n){if(n.edges.length===0)return!1;const r=e.getBoundingClientRect(),{threshold:s,edges:i}=n;return i.some(o=>o==="left"?t.x-r.left<s:o==="right"?r.right-t.x<s:o==="top"?t.y-r.top<s:o==="bottom"?r.bottom-t.y<s:!1)}function U4(t,e,n,r){return!e||n.edges.length===0?0:F4(t,e,n)?n.strength*r:0}var W4=1e3;function t1(t,e,n,r){let s=W4,i=!1;if(e.every(l=>{const a=l.evaluate(t);return s-=a,s<=0?(i=!0,!1):!0}),i)return-1;const o=t.view.nodeDOM(t.pos);return s-=U4(r,o,n,t.depth),s<=0?-1:s}function n1(t,e,n){return Array.from({length:e},(s,i)=>e-1-i).some(s=>n.includes(t.node(s).type.name))}function K4(t,e,n){if(!Number.isFinite(e.x)||!Number.isFinite(e.y))return null;const r=t.posAtCoords({left:e.x,top:e.y});if(!r)return null;const{doc:s}=t.state,i=s.resolve(r.pos),o=[];n.defaultRules&&o.push(...V4),o.push(...n.rules);const a=Array.from({length:i.depth},(d,h)=>i.depth-h).map(d=>{const h=i.node(d),f=i.before(d);if(n.allowedContainers&&d>0&&!n1(i,d,n.allowedContainers))return null;const p=d>0?i.node(d-1):null,g=d>0?i.index(d-1):0,y=p?p.childCount:1,b={node:h,pos:f,depth:d,parent:p,index:g,isFirst:g===0,isLast:g===y-1,$pos:i,view:t},w=t1(b,o,n.edgeDetection,e);if(w<0)return null;const v=t.nodeDOM(f);return{node:h,pos:f,depth:d,score:w,dom:v}}).filter(d=>d!==null),c=i.nodeAfter;if(c&&c.isAtom&&!c.isInline){const d=r.pos,h=i.depth+1,f=i.parent,p=i.index(),g=f.childCount;let y=!0;if(n.allowedContainers&&(y=n1(i,h,n.allowedContainers)),y){const b={node:c,pos:d,depth:h,parent:f,index:p,isFirst:p===0,isLast:p===g-1,$pos:i,view:t},w=t1(b,o,n.edgeDetection,e);if(w>=0){const v=t.nodeDOM(d);v&&a.push({node:c,pos:d,depth:h,score:w,dom:v})}}}if(a.length===0)return null;a.sort((d,h)=>h.score!==d.score?h.score-d.score:h.depth-d.depth);const u=a[0];return u.dom?{node:u.node,pos:u.pos,dom:u.dom}:null}function q4(t,e){let n=t;for(;n!=null&&n.parentElement&&n.parentElement!==e.dom;)n=n.parentElement;return(n==null?void 0:n.parentElement)===e.dom?n:void 0}function r1(t){return Number.isFinite(t.top)&&Number.isFinite(t.bottom)&&Number.isFinite(t.left)&&Number.isFinite(t.right)&&t.width>0&&t.height>0}function J4(t,e,n,r=5){if(!Number.isFinite(e)||!Number.isFinite(n))return null;const s=t.dom,i=s.firstElementChild,o=s.lastElementChild;if(!i||!o)return null;const l=i.getBoundingClientRect(),a=o.getBoundingClientRect();if(!r1(l)||!r1(a))return null;const c=Math.min(Math.max(l.top+r,n),a.bottom-r),u=.5,d=Math.abs(l.left-a.left)<u,h=Math.abs(l.right-a.right)<u;let f=l;d&&h&&(f=l);const p=Math.min(Math.max(f.left+r,e),f.right-r);return!Number.isFinite(p)||!Number.isFinite(c)?null:{x:p,y:c}}var Jk=t=>{const{x:e,y:n,editor:r,nestedOptions:s}=t,{view:i,state:o}=r,l=J4(i,e,n,5);if(!l)return{resultElement:null,resultNode:null,pos:null};const{x:a,y:c}=l;if(s!=null&&s.enabled){const p=K4(i,{x:a,y:c},s);return p?{resultElement:p.dom,resultNode:p.node,pos:p.pos}:{resultElement:null,resultNode:null,pos:null}}const u=i.root.elementsFromPoint(a,c);let d;if(Array.prototype.some.call(u,p=>{if(!i.dom.contains(p))return!1;const g=q4(p,i);return g?(d=g,!0):!1}),!d){const p=i.posAtCoords({left:a,top:c});if(p){const g=o.doc.resolve(p.pos),y=Math.min(g.depth,1),b=y>0?g.before(y):g.pos,w=o.doc.nodeAt(b);if(w){const v=i.nodeDOM(b);return{resultElement:v instanceof HTMLElement?v:null,resultNode:w,pos:b}}}return{resultElement:null,resultNode:null,pos:null}}let h;try{h=i.posAtDOM(d,0)}catch{return{resultElement:null,resultNode:null,pos:null}}const f=o.doc.nodeAt(h);if(!f){const p=o.doc.resolve(h),g=p.parent;return{resultElement:d,resultNode:g,pos:p.start()}}return{resultElement:d,resultNode:f,pos:h}};function Gk(t,e){const n=t.nodeDOM(e);if(n instanceof Element&&n!==t.dom)return n;const{node:r,offset:s}=t.domAtPos(e),i=r.childNodes[s];return i instanceof Element?i:r instanceof Element?r:r.nodeType===Node.TEXT_NODE&&r.parentElement?r.parentElement:null}function G4(t,e){const n=Gk(t,e);return(n?getComputedStyle(n).direction:getComputedStyle(t.dom).direction)||"ltr"}function Yk(t){var e;(e=t.parentNode)==null||e.removeChild(t)}function Y4(t,e){return t==="rtl"?e:0}function X4(t,e,n,r){const{doc:s}=e.view.state;if(n!=null&&n.enabled&&(r!=null&&r.node)&&r.pos>=0){const c=r.pos,u=r.pos+r.node.nodeSize;return[{$from:s.resolve(c),$to:s.resolve(u)}]}const i=Jk({editor:e,x:t.clientX,y:t.clientY,nestedOptions:n});if(!i.resultNode||i.pos===null)return[];const o=i.resultNode.isText||i.resultNode.isAtom?0:-1,l=s.resolve(i.pos),a=s.resolve(i.pos+i.resultNode.nodeSize+o);return kc(l,a,0,{extendOnBoundaryOverlap:!1})}function Z4(t,e,n,r,s){const{view:i}=e;if(!t.dataTransfer)return;const{empty:o,$from:l,$to:a}=i.state.selection,c=X4(t,e,n,r),u=kc(l,a,0,{extendOnBoundaryOverlap:!1}),d=u.some(A=>c.find(R=>R.$from===A.$from&&R.$to===A.$to)),h=o||!d?c:u;if(!h.length)return;const{tr:f}=i.state,p=document.createElement("div"),g=h[0].$from.pos,y=h[h.length-1].$to.pos,b=G4(i,g);p.setAttribute("dir",b);const w=(n==null?void 0:n.enabled)&&(r==null?void 0:r.node);let v,x;w?(v=i.state.doc.slice(g,y),x=Y.create(i.state.doc,g)):(x=un.create(i.state.doc,g,y),v=x.content()),h.forEach(A=>{const R=Gk(i,A.$from.pos);if(!R)return;const D=P4(R,s);D.style.margin="0",p.append(D)}),p.style.position="absolute",p.style.top="-10000px",document.body.append(p),t.dataTransfer.clearData();const k=p.getBoundingClientRect(),C=Y4(b,k.width);t.dataTransfer.setDragImage(p,C,0);let M=!1;const O=()=>{M||(M=!0,Yk(p),document.removeEventListener("drop",O),document.removeEventListener("dragend",O))},_=x instanceof Y?x:void 0;i.dragging={slice:v,move:!0,node:_},f.setSelection(x),i.dispatch(f),document.addEventListener("drop",O),document.addEventListener("dragend",O)}function s1(t,e,n){let r=0;for(let s=e;s<n;s+=1)r+=t.child(s).nodeSize;return r}function Q4(t){var e;return Si(t)?{anchorPos:t.from,nodeCount:t.ranges.length,depth:(e=t.depth)!=null?e:0}:null}function eH(t,e,n,r){const s=t.resolve(e),i=s.node(r);let o=s.index(r);o>=i.childCount&&(o=Math.max(0,i.childCount-n));const l=Math.min(n,i.childCount-o);if(l<=0)return null;const a=s.start(r)+s1(i,0,o),c=a+s1(i,o,o+l);return{anchor:a,head:c,count:l}}function tH(t,e,n,r){try{const s=eH(t,e,n,r);if(!s)return null;const i=un.create(t,s.anchor,s.head,r);return i.ranges.length===n?i:null}catch{return null}}var i1=(t,e)=>{const n=t.resolve(e),{depth:r}=n;return r===0?e:n.pos-n.parentOffset-1},o1=(t,e)=>{const n=t.nodeAt(e),r=t.resolve(e);let{depth:s}=r,i=n;for(;s>0;){const o=r.node(s);s-=1,s===0&&(i=o)}return i},Mu=(t,e)=>{const n=Ee.getState(t);return n?Ba(e,n.type,n.binding.mapping):null},nH=(t,e)=>{const n=Ee.getState(t);return n?Er(n.doc,n.type,e,n.binding.mapping)||0:-1},l1=(t,e)=>{let n=e;for(;n!=null&&n.parentNode&&n.parentNode!==t.dom;)n=n.parentNode;return n},Xk=new ae("dragHandle"),Zk=({pluginKey:t=Xk,element:e,editor:n,computePositionConfig:r,getReferencedVirtualElement:s,onNodeChange:i,onElementDragStart:o,onElementDragEnd:l,nestedOptions:a,dragImageProperties:c})=>{const u=document.createElement("div");let d=!1,h=null,f=-1,p,g=null,y=null,b=null,w=null,v=null;function x(){e&&(e.style.visibility="hidden",e.style.pointerEvents="none")}function k(){if(e){if(!n.isEditable){x();return}e.style.visibility="",e.style.pointerEvents="auto"}}function C(D){const L=(s==null?void 0:s())||{getBoundingClientRect:()=>D.getBoundingClientRect()};af(L,e,r).then(I=>{Object.assign(e.style,{position:I.strategy,left:`${I.x}px`,top:`${I.y}px`})})}function M(D){o==null||o(D),Z4(D,n,a,{node:h,pos:f},c),w=Q4(n.state.selection),e&&(e.dataset.dragging="true"),setTimeout(()=>{e&&(e.style.pointerEvents="none")},0)}function O(D){l==null||l(D),w=null,x(),e&&(e.style.pointerEvents="auto",e.dataset.dragging="false")}function _({nodeCount:D,depth:L,anchorPos:I}){const N=tH(n.state.doc,I,D,L);N&&n.view.dispatch(n.state.tr.setSelection(N))}function A(D){if(!(!D.target||!n.view.dom.contains(D.target))){if(cE()){const L=n.view.dom;requestAnimationFrame(()=>{L.isContentEditable&&(L.contentEditable="false",L.contentEditable="true")})}!w||n.view.state.selection.empty||(v={...w,anchorPos:n.state.selection.from},y=requestAnimationFrame(()=>{y=null,v&&(_(v),v=null)}))}}function R(){e.removeEventListener("dragstart",M),e.removeEventListener("dragend",O),document.removeEventListener("drop",A),g&&(cancelAnimationFrame(g),g=null,b=null),y&&(cancelAnimationFrame(y),y=null)}return u.appendChild(e),{unbind(){R()},plugin:new ce({key:typeof t=="string"?new ae(t):t,state:{init(){return{locked:!1}},apply(D,L,I,N){if(v&&D.docChanged){const U=D.mapping.mapResult(v.anchorPos,1);U.deleted?v=null:v.anchorPos=U.pos}const H=D.getMeta("lockDragHandle"),$=D.getMeta("hideDragHandle");if(H!==void 0&&(d=H),$)return x(),d=!1,h=null,f=-1,i==null||i({editor:n,node:null,pos:-1}),L;if(D.docChanged&&f!==-1&&e)if(Rf(D)){const U=nH(N,p);U!==f&&(f=U)}else{const U=D.mapping.map(f);U!==f&&(f=U,p=Mu(N,f))}return L}},view:D=>{var L;return e.draggable=!0,e.style.pointerEvents="auto",e.dataset.dragging="false",(L=n.view.dom.parentElement)==null||L.appendChild(u),u.style.pointerEvents="none",u.style.position="absolute",u.style.top="0",u.style.left="0",e.addEventListener("dragstart",M),e.addEventListener("dragend",O),document.addEventListener("drop",A),{update(I,N){if(!e)return;if(!n.isEditable){x();return}if(d?e.draggable=!1:e.draggable=!0,D.state.doc.eq(N.doc)||f===-1)return;let H=D.nodeDOM(f);if(H=l1(D,H),H===D.dom||(H==null?void 0:H.nodeType)!==1)return;const $=D.posAtDOM(H,0),U=o1(n.state.doc,$),K=i1(n.state.doc,$);h=U,f=K,p=Mu(D.state,f),i==null||i({editor:n,node:h,pos:f}),C(H)},destroy(){R(),e&&Yk(u)}}},props:{handleDOMEvents:{keydown(D){return!e||d||D.hasFocus()&&(x(),h=null,f=-1,i==null||i({editor:n,node:null,pos:-1})),!1},mouseleave(D,L){return d||L.target&&!u.contains(L.relatedTarget)&&(x(),h=null,f=-1,i==null||i({editor:n,node:null,pos:-1})),!1},mousemove(D,L){return!e||d||(b={x:L.clientX,y:L.clientY},g)||(g=requestAnimationFrame(()=>{if(g=null,!b)return;const{x:I,y:N}=b;b=null;const H=Jk({x:I,y:N,editor:n,nestedOptions:a});if(!H.resultElement)return;let $=H.resultElement,U=H.resultNode,K=H.pos;if(!(a!=null&&a.enabled)){if($=l1(D,$),$===D.dom||($==null?void 0:$.nodeType)!==1)return;const de=D.posAtDOM($,0);U=o1(n.state.doc,de),K=i1(n.state.doc,de)}U!==h&&(h=U,f=K??-1,p=Mu(D.state,f),i==null||i({editor:n,node:h,pos:f}),C($),k())})),!1}}}})}};function Qk(t){var e,n;return t===!1||t===void 0?{enabled:!1,rules:[],defaultRules:!0,allowedContainers:void 0,edgeDetection:Cu("none")}:t===!0?{enabled:!0,rules:[],defaultRules:!0,allowedContainers:void 0,edgeDetection:Cu("left")}:{enabled:!0,rules:(e=t.rules)!=null?e:[],defaultRules:(n=t.defaultRules)!=null?n:!0,allowedContainers:t.allowedContainers,edgeDetection:Cu(t.edgeDetection)}}var qd={placement:"left-start",strategy:"absolute"};ie.create({name:"dragHandle",addOptions(){return{render(){const t=document.createElement("div");return t.classList.add("drag-handle"),t},computePositionConfig:{},locked:!1,onNodeChange:()=>null,onElementDragStart:void 0,onElementDragEnd:void 0,nested:!1,dragImageProperties:void 0}},addCommands(){return{lockDragHandle:()=>({editor:t})=>(this.options.locked=!0,t.commands.setMeta("lockDragHandle",this.options.locked)),unlockDragHandle:()=>({editor:t})=>(this.options.locked=!1,t.commands.setMeta("lockDragHandle",this.options.locked)),toggleDragHandle:()=>({editor:t})=>(this.options.locked=!this.options.locked,t.commands.setMeta("lockDragHandle",this.options.locked))}},addProseMirrorPlugins(){const t=this.options.render(),e=Qk(this.options.nested);return[Zk({computePositionConfig:{...qd,...this.options.computePositionConfig},getReferencedVirtualElement:this.options.getReferencedVirtualElement,element:t,editor:this.editor,onNodeChange:this.options.onNodeChange,onElementDragStart:this.options.onElementDragStart,onElementDragEnd:this.options.onElementDragEnd,nestedOptions:e,dragImageProperties:this.options.dragImageProperties}).plugin]}});var rH=t=>{const{className:e="drag-handle",children:n,editor:r,pluginKey:s=Xk,onNodeChange:i,onElementDragStart:o,onElementDragEnd:l,getReferencedVirtualElement:a,computePositionConfig:c=qd,nested:u=!1}=t,[d]=S.useState(()=>typeof document>"u"?null:document.createElement("div")),h=S.useMemo(()=>Qk(u),[JSON.stringify(u)]);return S.useEffect(()=>{d&&(d.className=e,d.style.visibility="hidden",d.style.position="absolute",d.dataset.dragging="false")},[e,d]),S.useEffect(()=>{if(!d||r.isDestroyed)return;const{plugin:f,unbind:p}=Zk({editor:r,element:d,pluginKey:s,computePositionConfig:{...qd,...c},onElementDragStart:o,onElementDragEnd:l,onNodeChange:i,getReferencedVirtualElement:a,nestedOptions:h});return r.registerPlugin(f),()=>{r.isDestroyed||r.unregisterPlugin(s),p()}},[d,r,i,a,s,c,o,l,h]),d?Hs.createPortal(n,d):null};const sH="_handleSlot_1769s_12",iH="_grip_1769s_17",a1={handleSlot:sH,grip:iH},oH={placement:"left-start"};function eS({editor:t}){const[e,n]=S.useState(!1),r=S.useRef(-1),s=S.useRef(-1),i=S.useRef(!1);function o(u){i.current=u,u&&(s.current=r.current),n(u)}function l(u){const d=s.current;if(o(!1),d<0||d>=t.state.doc.content.size)return;const h=t.state.doc.nodeAt(d);h&&(u(d,h.nodeSize),s.current=-1,r.current=-1)}const a=S.useCallback(({pos:u})=>{i.current||(r.current=u)},[]);function c(u){l((d,h)=>{const{state:f,view:p}=t,g=d,y=d+h,b=f.doc.nodeAt(d);if(!b)return;const w=u==="up"?f.doc.resolve(g).nodeBefore:f.doc.resolve(y).nodeAfter;if(!w)return;const v=u==="up"?g-w.nodeSize:g+w.nodeSize;p.dispatch(f.tr.delete(g,y).insert(v,b))})}return m.jsx(rH,{editor:t,computePositionConfig:oH,onNodeChange:a,className:a1.handleSlot,children:m.jsx(T.Popover,{open:e,onOpenChange:o,placement:"bottom-start",bare:!0,trigger:m.jsx("button",{type:"button",className:a1.grip,"aria-label":"Block actions",children:m.jsx($3,{size:16})}),children:m.jsxs(T.Menu,{children:[m.jsx(T.MenuItem,{label:"Move up",leftIcon:m.jsx(nO,{size:16}),onClick:()=>c("up")}),m.jsx(T.MenuItem,{label:"Move down",leftIcon:m.jsx(rO,{size:16}),onClick:()=>c("down")}),m.jsx(T.MenuItem,{label:"Duplicate",leftIcon:m.jsx(K3,{size:16}),onClick:()=>l((u,d)=>{const h=t.state.doc.nodeAt(u);h&&t.chain().insertContentAt(u+d,h.toJSON()).run()})}),m.jsx(T.MenuItem,{label:"Delete",variant:"danger",leftIcon:m.jsx(St,{size:16}),onClick:()=>l((u,d)=>{t.chain().deleteRange({from:u,to:u+d}).run()})})]})})})}const lH="_root_y9qax_1",aH="_separator_y9qax_14",c1={root:lH,separator:aH};function tS({editor:t}){const e=vo({editor:t,selector:({editor:n})=>{const r=n.storage.characterCount;return{words:(r==null?void 0:r.words())??0,characters:(r==null?void 0:r.characters())??0}}});return m.jsxs("div",{className:c1.root,contentEditable:!1,children:[m.jsx("span",{children:e.words===1?"1 word":`${e.words} words`}),m.jsx("span",{className:c1.separator}),m.jsx("span",{children:e.characters===1?"1 character":`${e.characters} characters`})]})}const cH="_indicator_1dw83_2",uH="_line_1dw83_14",dH="_button_1dw83_23",Au={indicator:cH,line:uH,button:dH},hH=14;function fH({editor:t,wrapper:e,onInsert:n}){const[r,s]=S.useState(null);return S.useEffect(()=>{if(!e||!t.isEditable)return;function i(l){const a=t.view.dom,c=[...a.children];if(c.length===0)return s(null);const u=l.clientX,d=l.clientY,h=a.getBoundingClientRect();if(u<h.left-60||u>h.right+60)return s(null);for(let f=0;f<c.length-1;f+=1){const p=c[f].getBoundingClientRect(),g=c[f+1].getBoundingClientRect(),y=(p.bottom+g.top)/2;if(Math.abs(d-y)>hH)continue;const b=t.view.posAtDOM(c[f],0),w=t.state.doc.nodeAt(Math.max(0,b-1)),v=w?b-1+w.nodeSize:b,x=e.getBoundingClientRect();s({top:y-x.top,pos:v,rect:{top:y,bottom:y,left:p.left}});return}s(null)}function o(){s(null)}return e.addEventListener("mousemove",i),e.addEventListener("mouseleave",o),()=>{e.removeEventListener("mousemove",i),e.removeEventListener("mouseleave",o)}},[t,e]),r?m.jsxs("div",{className:Au.indicator,style:{top:r.top},children:[m.jsx("span",{className:Au.line}),m.jsx("button",{type:"button",className:Au.button,"aria-label":"Insert block here",onMouseDown:i=>i.preventDefault(),onClick:()=>n({pos:r.pos,rect:r.rect}),children:m.jsx(ms,{size:14})})]},r.pos):null}const pH="_wrapper_1y5c7_6",mH="_readOnly_1y5c7_37",gH="_insertButton_1y5c7_49",yH="_content_1y5c7_63",rl={wrapper:pH,readOnly:mH,insertButton:gH,content:yH},nS={type:"doc",content:[{type:"paragraph"}]};function bH(t,e){return JSON.stringify(t)===JSON.stringify(e)}function u1(t){return t?{top:t.top,bottom:t.bottom,left:t.left}:null}function wH(t,e){const{node:n}=t.domAtPos(e);let r=n.nodeType===Node.TEXT_NODE?n.parentElement:n;for(;r!=null&&r.parentElement&&r.parentElement!==t.dom;)r=r.parentElement;return(r==null?void 0:r.parentElement)===t.dom?r:null}const xH=S.forwardRef(function({value:e,defaultValue:n,placeholder:r,onChange:s,onFocus:i,onBlur:o,readOnly:l=!1,autoFocus:a=!1,contentWidth:c="740px",blocks:u=Sx,showInsertButton:d=!0,showBubbleMenu:h=!0,showDragHandle:f=!0,showWordCount:p=!1,onUpload:g,uploadAccept:y="image/*",onPickProduct:b,onPickCollection:w,title:v="",onTitleChange:x,titlePlaceholder:k="Post title",showTitle:C=!1,className:M},O){const _=S.useRef(!1),A=S.useRef(null),[R,D]=S.useState(null),L=S.useRef(null),[I,N]=S.useState(null),[H,$]=S.useState(null),U=S.useRef(null);U.current=I;const K=S.useCallback(P=>{if(!P){N(W=>(W==null?void 0:W.source)==="slash"?null:W);return}N(W=>(W==null?void 0:W.source)==="slash"?{...W,query:P.query,range:P.range}:{source:"slash",getAnchor:()=>u1(P.getRect()),query:P.query,range:P.range})},[]),de=S.useCallback(P=>{var W,X;return((W=U.current)==null?void 0:W.source)!=="slash"?!1:((X=L.current)==null?void 0:X.onKeyDown(P))??!1},[]),ve=S.useRef(g);ve.current=g;const Me=S.useMemo(()=>g?P=>ve.current(P):void 0,[!!g]),Ct=S.useRef(b);Ct.current=b;const Ae=S.useMemo(()=>b?()=>Ct.current():void 0,[!!b]),Te=S.useRef(w);Te.current=w;const He=S.useMemo(()=>w?()=>Te.current():void 0,[!!w]),z=Oy({extensions:[Eb.configure({heading:{levels:[1,2,3,4,5,6]},link:{openOnClick:!1}}),...r!==void 0?[Tb.configure({placeholder:r})]:[],qh.configure({resizable:!1}),Kh,Wh,Uh,Jh,Gh,_b.configure({multicolor:!0}),mN,_x.configure({onUpload:Me,accept:y}),Ox,Dx,Lx,Px,Hx.configure({onUpload:Me,accept:y}),$x,Wx.configure({onPick:Ae}),Kx.configure({onPick:He}),Ex.configure({onStateChange:K,onKeyDown:de})],content:e??n??nS,editable:!l,autofocus:a?"end":!1,shouldRerenderOnTransaction:!1,onUpdate({editor:P}){_.current=!0,s==null||s(P.getJSON(),{isEmpty:P.isEmpty})},onFocus(){i==null||i()},onBlur(){o==null||o()}});S.useEffect(()=>{z==null||z.setEditable(!l)},[z,l]),S.useEffect(()=>{if(!(!z||e===void 0)){if(_.current){_.current=!1;return}bH(e,z.getJSON())||z.commands.setContent(e,{emitUpdate:!1})}},[z,e]),S.useEffect(()=>{const P=A.current;if(!P)return;const W=new ResizeObserver(([X])=>{P.style.setProperty("--block-editor-canvas-width",`${X.contentRect.width}px`)});return W.observe(P),()=>W.disconnect()},[]),S.useEffect(()=>{if(!z||!d||l){$(null);return}function P(){if(!z||!A.current)return;const{selection:X}=z.state,be=X.$from.parent;if(!(X.empty&&be.type.name==="paragraph"&&be.content.size===0)||!z.isFocused){$(null);return}const ne=wH(z.view,X.$from.pos);if(!ne){$(null);return}const Je=z.view.coordsAtPos(X.$from.pos),vr=(Je.top+Je.bottom)/2,xn=A.current.getBoundingClientRect();$({top:vr-xn.top,left:ne.getBoundingClientRect().left-xn.left})}z.on("selectionUpdate",P),z.on("transaction",P),z.on("focus",P),z.on("blur",P),P();const W=new ResizeObserver(()=>P());return A.current&&W.observe(A.current),()=>{z.off("selectionUpdate",P),z.off("transaction",P),z.off("focus",P),z.off("blur",P),W.disconnect()}},[z,d,l]),S.useImperativeHandle(O,()=>({focus:(P="end")=>z==null?void 0:z.commands.focus(P),editor:z??null}),[z]);const V=S.useMemo(()=>Cx(u,(I==null?void 0:I.query)??"",z),[u,I==null?void 0:I.query,z]),Ut=S.useCallback(()=>{N(P=>{var W;return(W=P==null?void 0:P.onDismiss)==null||W.call(P),null})},[]);function _t(P){z&&(N(null),P.run({editor:z,range:(I==null?void 0:I.range)??{from:z.state.selection.from,to:z.state.selection.to}}))}function oe(P){if(!z)return;z.chain().focus().insertContentAt(P.pos,{type:"paragraph"}).setTextSelection(P.pos+1).run();const W=P.pos+1;N({source:"button",getAnchor:()=>({top:P.rect.top,bottom:P.rect.bottom,left:P.rect.left}),query:"",range:{from:W,to:W},onDismiss:()=>{const X=z.state.doc.nodeAt(P.pos);(X==null?void 0:X.type.name)==="paragraph"&&X.content.size===0&&z.chain().deleteRange({from:P.pos,to:P.pos+X.nodeSize}).run()}})}function wn(P){if(!z)return;const{from:W,to:X}=z.state.selection,be=P.currentTarget;N({source:"button",getAnchor:()=>u1(be.getBoundingClientRect()),query:"",range:{from:W,to:X}})}const F=[rl.wrapper,l&&rl.readOnly,M].filter(Boolean).join(" ");return m.jsxs("div",{ref:P=>{A.current=P,D(P)},className:F,style:{"--block-editor-width":c},onClick:P=>{if(l)return;const W=P.target;if(W.closest('button, input, select, textarea, a, [role="menu"], [role="menuitem"]'))return;const X=P.currentTarget.querySelector(".ProseMirror");X&&X.contains(W)||z==null||z.commands.focus("end")},children:[C&&m.jsx(oL,{value:v,placeholder:k,readOnly:l,onChange:P=>x==null?void 0:x(P),onLeave:()=>z==null?void 0:z.commands.focus("start")}),m.jsx(Eh,{editor:z,className:rl.content}),z&&h&&!l&&m.jsx(kv,{editor:z}),z&&h&&!l&&m.jsx(vv,{editor:z}),z&&f&&!l&&m.jsx(eS,{editor:z}),z&&d&&!l&&m.jsx(fH,{editor:z,wrapper:R,onInsert:oe}),H!==null&&m.jsx(T.IconButton,{"aria-label":"Insert block",variant:"neutral",size:"sm",radius:"full",icon:m.jsx(ms,{size:16}),className:rl.insertButton,style:{top:H.top,"--block-editor-block-left":`${H.left}px`},onMouseDown:P=>P.preventDefault(),onClick:wn}),z&&p&&m.jsx(tS,{editor:z}),I&&z&&m.jsx(tI,{ref:L,blocks:V,getAnchor:I.getAnchor,query:I.query,source:I.source,onSelect:_t,onClose:Ut})]})});exports.BUTTON_BLOCK_NAME=Ix;exports.BlockDragHandle=eS;exports.BlockEditor=xH;exports.ButtonBlock=Dx;exports.CALLOUT_BLOCK_NAME=Nx;exports.COLLECTION_BLOCK_NAME=Fx;exports.CalloutBlock=Ox;exports.CollectionBlock=Kx;exports.DYNAMIC_VARIABLE_NAME=Pi;exports.DynamicVariableExtension=kx;exports.EMPTY_DOCUMENT=nS;exports.GALLERY_BLOCK_NAME=Bx;exports.GalleryBlock=Hx;exports.HTML_BLOCK_NAME=Rx;exports.HtmlBlock=Lx;exports.IMAGE_BLOCK_NAME=Tx;exports.ImageBlock=_x;exports.PRODUCT_BLOCK_NAME=Vx;exports.ProductBlock=Wx;exports.RichTextEditor=YO;exports.SLASH_COMMAND_KEY=Ax;exports.SlashCommand=Ex;exports.TOGGLE_BLOCK_NAME=zx;exports.TableBubbleMenu=vv;exports.TextBubbleMenu=kv;exports.ToggleBlock=$x;exports.VIDEO_BLOCK_NAME=jx;exports.VideoBlock=Px;exports.WordCount=tS;exports.defaultBlocks=Sx;exports.filterBlocks=Cx;exports.groupBlocks=Mx;exports.isCellSelection=cf;exports.markupToTokens=xx;exports.resolveVideoEmbed=tf;exports.tokensToMarkup=ki;
|