reactjs-tiptap-editor-pro 0.2.32 → 0.2.33

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.
@@ -0,0 +1,142 @@
1
+ "use strict";var V1=Object.create;var gu=Object.defineProperty;var H1=Object.getOwnPropertyDescriptor;var q1=Object.getOwnPropertyNames;var W1=Object.getPrototypeOf,U1=Object.prototype.hasOwnProperty;var G1=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of q1(e))!U1.call(n,o)&&o!==t&&gu(n,o,{get:()=>e[o],enumerable:!(r=H1(e,o))||r.enumerable});return n};var yu=(n,e,t)=>(t=n!=null?V1(W1(n)):{},G1(e||!n||!n.__esModule?gu(t,"default",{value:n,enumerable:!0}):t,n));const h=require("react/jsx-runtime"),x=require("react"),K1=require("@radix-ui/react-dropdown-menu"),B=require("lucide-react"),J1=require("react-colorful"),ie=require("./locale-bundle-DiqW5jwb.cjs"),X1=require("@radix-ui/react-switch"),Z1=require("react-image-crop"),Y1=require("@radix-ui/react-checkbox"),Q1=require("@radix-ui/react-tabs"),dp=require("re-resizable"),fp=require("katex"),ec=require("react-dom"),bu=require("mermaid"),e0=require("@radix-ui/react-label"),t0=require("tippy.js"),Ee=require("easydrawer"),hp=require("@radix-ui/react-slot"),n0=require("@radix-ui/react-tooltip"),r0=require("@radix-ui/react-toggle"),o0=require("./lucide-react-CMPhLW1m.cjs"),co=require("@radix-ui/react-icons"),i0=require("@radix-ui/react-dialog"),s0=require("@radix-ui/react-popover"),l0=require("@radix-ui/react-separator");function Ct(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:()=>n[t]})}}return e.default=n,Object.freeze(e)}const Se=Ct(x),Ae=Ct(K1),da=Ct(X1),fa=Ct(Y1),Pn=Ct(Q1),pp=Ct(e0),Qr=Ct(n0),mp=Ct(r0),xt=Ct(i0),Dr=Ct(s0),gp=Ct(l0);function He(n){this.content=n}He.prototype={constructor:He,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var r=t&&t!=n?this.remove(t):this,o=r.find(n),i=r.content.slice();return o==-1?i.push(t||n,e):(i[o+1]=e,t&&(i[o]=t)),new He(i)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new He(t)},addToStart:function(n,e){return new He([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new He(t)},addBefore:function(n,e,t){var r=this.remove(e),o=r.content.slice(),i=r.find(n);return o.splice(i==-1?o.length:i,0,e,t),new He(o)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=He.from(n),n.size?new He(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=He.from(n),n.size?new He(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=He.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}};He.from=function(n){if(n instanceof He)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new He(e)};function yp(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let o=n.child(r),i=e.child(r);if(o==i){t+=o.nodeSize;continue}if(!o.sameMarkup(i))return t;if(o.isText&&o.text!=i.text){for(let s=0;o.text[s]==i.text[s];s++)t++;return t}if(o.content.size||i.content.size){let s=yp(o.content,i.content,t+1);if(s!=null)return s}t+=o.nodeSize}}function bp(n,e,t,r){for(let o=n.childCount,i=e.childCount;;){if(o==0||i==0)return o==i?null:{a:t,b:r};let s=n.child(--o),l=e.child(--i),a=s.nodeSize;if(s==l){t-=a,r-=a;continue}if(!s.sameMarkup(l))return{a:t,b:r};if(s.isText&&s.text!=l.text){let c=0,u=Math.min(s.text.length,l.text.length);for(;c<u&&s.text[s.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,r--;return{a:t,b:r}}if(s.content.size||l.content.size){let c=bp(s.content,l.content,t-1,r-1);if(c)return c}t-=a,r-=a}}class j{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,o=0,i){for(let s=0,l=0;l<t;s++){let a=this.content[s],c=l+a.nodeSize;if(c>e&&r(a,o+l,i||null,s)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,t-u),r,o+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,o){let i="",s=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?o?typeof o=="function"?o(l):o:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(s?s=!1:i+=r),i+=c},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,o=this.content.slice(),i=0;for(t.isText&&t.sameMarkup(r)&&(o[o.length-1]=t.withText(t.text+r.text),i=1);i<e.content.length;i++)o.push(e.content[i]);return new j(o,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],o=0;if(t>e)for(let i=0,s=0;s<t;i++){let l=this.content[i],a=s+l.nodeSize;a>e&&((s<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-s),Math.min(l.text.length,t-s)):l=l.cut(Math.max(0,e-s-1),Math.min(l.content.size,t-s-1))),r.push(l),o+=l.nodeSize),s=a}return new j(r,o)}cutByIndex(e,t){return e==t?j.empty:e==0&&t==this.content.length?this:new j(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let o=this.content.slice(),i=this.size+t.nodeSize-r.nodeSize;return o[e]=t,new j(o,i)}addToStart(e){return new j([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new j(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let o=this.content[t];e(o,r,t),r+=o.nodeSize}}findDiffStart(e,t=0){return yp(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return bp(this,e,t,r)}findIndex(e,t=-1){if(e==0)return uo(0,e);if(e==this.size)return uo(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let r=0,o=0;;r++){let i=this.child(r),s=o+i.nodeSize;if(s>=e)return s==e||t>0?uo(r+1,s):uo(r,o);o=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return j.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new j(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return j.empty;let t,r=0;for(let o=0;o<e.length;o++){let i=e[o];r+=i.nodeSize,o&&i.isText&&e[o-1].sameMarkup(i)?(t||(t=e.slice(0,o)),t[t.length-1]=i.withText(t[t.length-1].text+i.text)):t&&t.push(i)}return new j(t||e,r)}static from(e){if(!e)return j.empty;if(e instanceof j)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new j([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 $i={index:0,offset:0};function uo(n,e){return $i.index=n,$i.offset=e,$i}function Vo(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!Vo(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!Vo(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}let we=class ha{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let o=0;o<e.length;o++){let i=e[o];if(this.eq(i))return e;if(this.type.excludes(i.type))t||(t=e.slice(0,o));else{if(i.type.excludes(this.type))return e;!r&&i.type.rank>this.type.rank&&(t||(t=e.slice(0,o)),t.push(this),r=!0),t&&t.push(i)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Vo(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);let o=r.create(t.attrs);return r.checkAttrs(o.attrs),o}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return ha.none;if(e instanceof ha)return[e];let t=e.slice();return t.sort((r,o)=>r.type.rank-o.type.rank),t}};we.none=[];class Ho extends Error{}class ${constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=xp(this.content,e+this.openStart,t);return r&&new $(r,this.openStart,this.openEnd)}removeBetween(e,t){return new $(vp(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return $.empty;let r=t.openStart||0,o=t.openEnd||0;if(typeof r!="number"||typeof o!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new $(j.fromJSON(e,t.content),r,o)}static maxOpen(e,t=!0){let r=0,o=0;for(let i=e.firstChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.lastChild)o++;return new $(e,r,o)}}$.empty=new $(j.empty,0,0);function vp(n,e,t){let{index:r,offset:o}=n.findIndex(e),i=n.maybeChild(r),{index:s,offset:l}=n.findIndex(t);if(o==e||i.isText){if(l!=t&&!n.child(s).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=s)throw new RangeError("Removing non-flat range");return n.replaceChild(r,i.copy(vp(i.content,e-o-1,t-o-1)))}function xp(n,e,t,r){let{index:o,offset:i}=n.findIndex(e),s=n.maybeChild(o);if(i==e||s.isText)return n.cut(0,e).append(t).append(n.cut(e));let l=xp(s.content,e-i-1,t);return l&&n.replaceChild(o,s.copy(l))}function a0(n,e,t){if(t.openStart>n.depth)throw new Ho("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new Ho("Inconsistent open depths");return wp(n,e,t,0)}function wp(n,e,t,r){let o=n.index(r),i=n.node(r);if(o==e.index(r)&&r<n.depth-t.openStart){let s=wp(n,e,t,r+1);return i.copy(i.content.replaceChild(o,s))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let s=n.parent,l=s.content;return Mn(s,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:s,end:l}=c0(t,n);return Mn(i,Cp(n,s,l,e,r))}else return Mn(i,qo(n,e,r))}function Sp(n,e){if(!e.type.compatibleContent(n.type))throw new Ho("Cannot join "+e.type.name+" onto "+n.type.name)}function pa(n,e,t){let r=n.node(t);return Sp(r,e.node(t)),r}function En(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function Nr(n,e,t,r){let o=(e||n).node(t),i=0,s=e?e.index(t):o.childCount;n&&(i=n.index(t),n.depth>t?i++:n.textOffset&&(En(n.nodeAfter,r),i++));for(let l=i;l<s;l++)En(o.child(l),r);e&&e.depth==t&&e.textOffset&&En(e.nodeBefore,r)}function Mn(n,e){return n.type.checkContent(e),n.copy(e)}function Cp(n,e,t,r,o){let i=n.depth>o&&pa(n,e,o+1),s=r.depth>o&&pa(t,r,o+1),l=[];return Nr(null,n,o,l),i&&s&&e.index(o)==t.index(o)?(Sp(i,s),En(Mn(i,Cp(n,e,t,r,o+1)),l)):(i&&En(Mn(i,qo(n,e,o+1)),l),Nr(e,t,o,l),s&&En(Mn(s,qo(t,r,o+1)),l)),Nr(r,null,o,l),new j(l)}function qo(n,e,t){let r=[];if(Nr(null,n,t,r),n.depth>t){let o=pa(n,e,t+1);En(Mn(o,qo(n,e,t+1)),r)}return Nr(e,null,t,r),new j(r)}function c0(n,e){let t=e.depth-n.openStart,o=e.node(t).copy(n.content);for(let i=t-1;i>=0;i--)o=e.node(i).copy(j.from(o));return{start:o.resolveNoCache(n.openStart+t),end:o.resolveNoCache(o.content.size-n.openEnd-t)}}class jr{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],o=e.child(t);return r?e.child(t).cut(r):o}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],o=t==0?0:this.path[t*3-1]+1;for(let i=0;i<e;i++)o+=r.child(i).nodeSize;return o}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return we.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),o=e.maybeChild(t);if(!r){let l=r;r=o,o=l}let i=r.marks;for(var s=0;s<i.length;s++)i[s].type.spec.inclusive===!1&&(!o||!i[s].isInSet(o.marks))&&(i=i[s--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.marks,o=e.parent.maybeChild(e.index());for(var i=0;i<r.length;i++)r[i].type.spec.inclusive===!1&&(!o||!r[i].isInSet(o.marks))&&(r=r[i--].removeFromSet(r));return r}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new Pr(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],o=0,i=t;for(let s=e;;){let{index:l,offset:a}=s.content.findIndex(i),c=i-a;if(r.push(s,l,o+a),!c||(s=s.child(l),s.isText))break;i=c-1,o+=a+1}return new jr(t,r,i)}static resolveCached(e,t){let r=vu.get(e);if(r)for(let i=0;i<r.elts.length;i++){let s=r.elts[i];if(s.pos==t)return s}else vu.set(e,r=new u0);let o=r.elts[r.i]=jr.resolve(e,t);return r.i=(r.i+1)%d0,o}}class u0{constructor(){this.elts=[],this.i=0}}const d0=12,vu=new WeakMap;class Pr{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const f0=Object.create(null);let $t=class ma{constructor(e,t,r,o=we.none){this.type=e,this.attrs=t,this.marks=o,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,t,r,o=0){this.content.nodesBetween(e,t,r,o,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,r,o){return this.content.textBetween(e,t,r,o)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,r){return this.type==e&&Vo(this.attrs,t||e.defaultAttrs||f0)&&we.sameSet(this.marks,r||we.none)}copy(e=null){return e==this.content?this:new ma(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new ma(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,r=!1){if(e==t)return $.empty;let o=this.resolve(e),i=this.resolve(t),s=r?0:o.sharedDepth(t),l=o.start(s),c=o.node(s).content.cut(o.pos-l,i.pos-l);return new $(c,o.depth-s,i.depth-s)}replace(e,t,r){return a0(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:o}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(o==e||t.isText)return t;e-=o+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let o=this.content.child(t-1);return{node:o,index:t-1,offset:r-o.nodeSize}}resolve(e){return jr.resolveCached(this,e)}resolveNoCache(e){return jr.resolve(this,e)}rangeHasMark(e,t,r){let o=!1;return t>e&&this.nodesBetween(e,t,i=>(r.isInSet(i.marks)&&(o=!0),!o)),o}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()+")"),Tp(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=j.empty,o=0,i=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,o,i),l=s&&s.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=o;a<i;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,t,r,o){if(o&&!this.type.allowsMarks(o))return!1;let i=this.contentMatchAt(e).matchType(r),s=i&&i.matchFragment(this.content,t);return s?s.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=we.none;for(let t=0;t<this.marks.length;t++){let r=this.marks[t];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!we.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let o=j.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,o,r);return i.type.checkAttrs(i.attrs),i}};$t.prototype.text=void 0;class Wo extends $t{constructor(e,t,r,o){if(super(e,t,null,o),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Tp(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new Wo(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Wo(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function Tp(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class Rn{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new h0(e,t);if(r.next==null)return Rn.empty;let o=kp(r);r.next&&r.err("Unexpected trailing text");let i=x0(v0(o));return w0(i,r),i}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,r=e.childCount){let o=this;for(let i=t;o&&i<r;i++)o=o.matchType(e.child(i).type);return o}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let o=[this];function i(s,l){let a=s.matchFragment(e,r);if(a&&(!t||a.validEnd))return j.from(l.map(c=>c.createAndFill()));for(let c=0;c<s.next.length;c++){let{type:u,next:d}=s.next[c];if(!(u.isText||u.hasRequiredAttrs())&&o.indexOf(d)==-1){o.push(d);let f=i(d,l.concat(u));if(f)return f}}return null}return i(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let o=r.shift(),i=o.match;if(i.matchType(e)){let s=[];for(let l=o;l.type;l=l.via)s.push(l.type);return s.reverse()}for(let s=0;s<i.next.length;s++){let{type:l,next:a}=i.next[s];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!o.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:o}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let o=0;o<r.next.length;o++)e.indexOf(r.next[o].next)==-1&&t(r.next[o].next)}return t(this),e.map((r,o)=>{let i=o+(r.validEnd?"*":" ")+" ";for(let s=0;s<r.next.length;s++)i+=(s?", ":"")+r.next[s].type.name+"->"+e.indexOf(r.next[s].next);return i}).join(`
2
+ `)}}Rn.empty=new Rn(!0);class h0{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function kp(n){let e=[];do e.push(p0(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function p0(n){let e=[];do e.push(m0(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function m0(n){let e=b0(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=g0(n,e);else break;return e}function xu(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function g0(n,e){let t=xu(n),r=t;return n.eat(",")&&(n.next!="}"?r=xu(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function y0(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let o=[];for(let i in t){let s=t[i];s.isInGroup(e)&&o.push(s)}return o.length==0&&n.err("No node type or group '"+e+"' found"),o}function b0(n){if(n.eat("(")){let e=kp(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=y0(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function v0(n){let e=[[]];return o(i(n,0),t()),e;function t(){return e.push([])-1}function r(s,l,a){let c={term:a,to:l};return e[s].push(c),c}function o(s,l){s.forEach(a=>a.to=l)}function i(s,l){if(s.type=="choice")return s.exprs.reduce((a,c)=>a.concat(i(c,l)),[]);if(s.type=="seq")for(let a=0;;a++){let c=i(s.exprs[a],l);if(a==s.exprs.length-1)return c;o(c,l=t())}else if(s.type=="star"){let a=t();return r(l,a),o(i(s.expr,a),a),[r(a)]}else if(s.type=="plus"){let a=t();return o(i(s.expr,l),a),o(i(s.expr,a),a),[r(a)]}else{if(s.type=="opt")return[r(l)].concat(i(s.expr,l));if(s.type=="range"){let a=l;for(let c=0;c<s.min;c++){let u=t();o(i(s.expr,a),u),a=u}if(s.max==-1)o(i(s.expr,a),a);else for(let c=s.min;c<s.max;c++){let u=t();r(a,u),o(i(s.expr,a),u),a=u}return[r(a)]}else{if(s.type=="name")return[r(l,void 0,s.value)];throw new Error("Unknown expr type")}}}}function Ep(n,e){return e-n}function wu(n,e){let t=[];return r(e),t.sort(Ep);function r(o){let i=n[o];if(i.length==1&&!i[0].term)return r(i[0].to);t.push(o);for(let s=0;s<i.length;s++){let{term:l,to:a}=i[s];!l&&t.indexOf(a)==-1&&r(a)}}}function x0(n){let e=Object.create(null);return t(wu(n,0));function t(r){let o=[];r.forEach(s=>{n[s].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let u=0;u<o.length;u++)o[u][0]==l&&(c=o[u][1]);wu(n,a).forEach(u=>{c||o.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let i=e[r.join(",")]=new Rn(r.indexOf(n.length-1)>-1);for(let s=0;s<o.length;s++){let l=o[s][1].sort(Ep);i.next.push({type:o[s][0],next:e[l.join(",")]||t(l)})}return i}}function w0(n,e){for(let t=0,r=[n];t<r.length;t++){let o=r[t],i=!o.validEnd,s=[];for(let l=0;l<o.next.length;l++){let{type:a,next:c}=o.next[l];s.push(a.name),i&&!(a.isText||a.hasRequiredAttrs())&&(i=!1),r.indexOf(c)==-1&&r.push(c)}i&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Mp(n){let e=Object.create(null);for(let t in n){let r=n[t];if(!r.hasDefault)return null;e[t]=r.default}return e}function Op(n,e){let t=Object.create(null);for(let r in n){let o=e&&e[r];if(o===void 0){let i=n[r];if(i.hasDefault)o=i.default;else throw new RangeError("No value supplied for attribute "+r)}t[r]=o}return t}function Ap(n,e,t,r){for(let o in e)if(!(o in n))throw new RangeError(`Unsupported attribute ${o} for ${t} of type ${o}`);for(let o in n){let i=n[o];i.validate&&i.validate(e[o])}}function Np(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new C0(n,r,e[r]);return t}let Su=class Rp{constructor(e,t,r){this.name=e,this.schema=t,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=Np(e,r.attrs),this.defaultAttrs=Mp(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==Rn.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:Op(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new $t(this,this.computeAttrs(e),j.from(t),we.setFrom(r))}createChecked(e=null,t,r){return t=j.from(t),this.checkContent(t),new $t(this,this.computeAttrs(e),t,we.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=j.from(t),t.size){let s=this.contentMatch.fillBefore(t);if(!s)return null;t=s.append(t)}let o=this.contentMatch.matchFragment(t),i=o&&o.fillBefore(j.empty,!0);return i?new $t(this,e,t.append(i),we.setFrom(r)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){Ap(this.attrs,e,"node")}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?t&&t.push(e[r]):t||(t=e.slice(0,r));return t?t.length?t:we.none:e}static compile(e,t){let r=Object.create(null);e.forEach((i,s)=>r[i]=new Rp(i,t,s));let o=t.spec.topNode||"doc";if(!r[o])throw new RangeError("Schema is missing its top node type ('"+o+"')");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 S0(n,e,t){let r=t.split("|");return o=>{let i=o===null?"null":typeof o;if(r.indexOf(i)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${i}`)}}class C0{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?S0(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class ri{constructor(e,t,r,o){this.name=e,this.rank=t,this.schema=r,this.spec=o,this.attrs=Np(e,o.attrs),this.excluded=null;let i=Mp(this.attrs);this.instance=i?new we(this,i):null}create(e=null){return!e&&this.instance?this.instance:new we(this,Op(this.attrs,e))}static compile(e,t){let r=Object.create(null),o=0;return e.forEach((i,s)=>r[i]=new ri(i,o++,t,s)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){Ap(this.attrs,e,"mark")}excludes(e){return this.excluded.indexOf(e)>-1}}class Ip{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let o in e)t[o]=e[o];t.nodes=He.from(e.nodes),t.marks=He.from(e.marks||{}),this.nodes=Su.compile(this.spec.nodes,this),this.marks=ri.compile(this.spec.marks,this);let r=Object.create(null);for(let o in this.nodes){if(o in this.marks)throw new RangeError(o+" can not be both a node and a mark");let i=this.nodes[o],s=i.spec.content||"",l=i.spec.marks;if(i.contentMatch=r[s]||(r[s]=Rn.parse(s,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?Cu(this,l.split(" ")):l==""||!i.inlineContent?[]:null}for(let o in this.marks){let i=this.marks[o],s=i.spec.excludes;i.excluded=s==null?[i]:s==""?[]:Cu(this,s.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,o){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Su){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,r,o)}text(e,t){let r=this.nodes.text;return new Wo(r,r.defaultAttrs,e,we.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return $t.fromJSON(this,e)}markFromJSON(e){return we.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function Cu(n,e){let t=[];for(let r=0;r<e.length;r++){let o=e[r],i=n.marks[o],s=i;if(i)t.push(i);else for(let l in n.marks){let a=n.marks[l];(o=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(o)>-1)&&t.push(s=a)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function T0(n){return n.tag!=null}function k0(n){return n.style!=null}class on{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(o=>{if(T0(o))this.tags.push(o);else if(k0(o)){let i=/[^=]*/.exec(o.style)[0];r.indexOf(i)<0&&r.push(i),this.styles.push(o)}}),this.normalizeLists=!this.tags.some(o=>{if(!/^(ul|ol)\b/.test(o.tag)||!o.node)return!1;let i=e.nodes[o.node];return i.contentMatch.matchType(i)})}parse(e,t={}){let r=new ku(this,t,!1);return r.addAll(e,we.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new ku(this,t,!0);return r.addAll(e,we.none,t.from,t.to),$.maxOpen(r.finish())}matchTag(e,t,r){for(let o=r?this.tags.indexOf(r)+1:0;o<this.tags.length;o++){let i=this.tags[o];if(O0(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||t.matchesContext(i.context))){if(i.getAttrs){let s=i.getAttrs(e);if(s===!1)continue;i.attrs=s||void 0}return i}}}matchStyle(e,t,r,o){for(let i=o?this.styles.indexOf(o)+1:0;i<this.styles.length;i++){let s=this.styles[i],l=s.style;if(!(l.indexOf(e)!=0||s.context&&!r.matchesContext(s.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(s.getAttrs){let a=s.getAttrs(t);if(a===!1)continue;s.attrs=a||void 0}return s}}}static schemaRules(e){let t=[];function r(o){let i=o.priority==null?50:o.priority,s=0;for(;s<t.length;s++){let l=t[s];if((l.priority==null?50:l.priority)<i)break}t.splice(s,0,o)}for(let o in e.marks){let i=e.marks[o].spec.parseDOM;i&&i.forEach(s=>{r(s=Eu(s)),s.mark||s.ignore||s.clearMark||(s.mark=o)})}for(let o in e.nodes){let i=e.nodes[o].spec.parseDOM;i&&i.forEach(s=>{r(s=Eu(s)),s.node||s.ignore||s.mark||(s.node=o)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new on(e,on.schemaRules(e)))}}const _p={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},E0={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Dp={ol:!0,ul:!0},Lr=1,ga=2,_o=4;function Tu(n,e,t){return e!=null?(e?Lr:0)|(e==="full"?ga:0):n&&n.whitespace=="pre"?Lr|ga:t&-5}class fo{constructor(e,t,r,o,i,s){this.type=e,this.attrs=t,this.marks=r,this.solid=o,this.options=s,this.content=[],this.activeMarks=we.none,this.match=i||(s&_o?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(j.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,o;return(o=r.findWrapping(e.type))?(this.match=r,o):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Lr)){let r=this.content[this.content.length-1],o;if(r&&r.isText&&(o=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==o[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-o[0].length))}}let t=j.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(j.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!_p.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class ku{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let o=t.topNode,i,s=Tu(null,t.preserveWhitespace,0)|(r?_o:0);o?i=new fo(o.type,o.attrs,we.none,!0,t.topMatch||o.type.contentMatch,s):r?i=new fo(null,null,we.none,!0,null,s):i=new fo(e.schema.topNodeType,null,we.none,!0,null,s),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let r=e.nodeValue,o=this.top,i=o.options&ga?"full":this.localPreserveWS||(o.options&Lr)>0;if(i==="full"||o.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(i)i!=="full"?r=r.replace(/\r?\n|\r/g," "):r=r.replace(/\r\n?/g,`
3
+ `);else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let s=o.content[o.content.length-1],l=e.previousSibling;(!s||l&&l.nodeName=="BR"||s.isText&&/[ \t\r\n\u000c]$/.test(s.text))&&(r=r.slice(1))}r&&this.insertNode(this.parser.schema.text(r),t),this.findInText(e)}else this.findInside(e)}addElement(e,t,r){let o=this.localPreserveWS,i=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let s=e.nodeName.toLowerCase(),l;Dp.hasOwnProperty(s)&&this.parser.normalizeLists&&M0(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:E0.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,t);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let c,u=this.needsBlock;if(_p.hasOwnProperty(s))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),c=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let d=a&&a.skip?t:this.readStyles(e,t);d&&this.addAll(e,d),c&&this.sync(i),this.needsBlock=u}else{let c=this.readStyles(e,t);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=o}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
4
+ `),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t)}readStyles(e,t){let r=e.style;if(r&&r.length)for(let o=0;o<this.parser.matchedStyles.length;o++){let i=this.parser.matchedStyles[o],s=r.getPropertyValue(i);if(s)for(let l=void 0;;){let a=this.parser.matchStyle(i,s,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?t=t.filter(c=>!a.clearMark(c)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,r,o){let i,s;if(t.node)if(s=this.parser.schema.nodes[t.node],s.isLeaf)this.insertNode(s.create(t.attrs),r)||this.leafFallback(e,r);else{let a=this.enter(s,t.attrs||null,r,t.preserveWhitespace);a&&(i=!0,r=a)}else{let a=this.parser.schema.marks[t.mark];r=r.concat(a.create(t.attrs))}let l=this.top;if(s&&s.isLeaf)this.findInside(e);else if(o)this.addElement(e,r,o);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}i&&this.sync(l)&&this.open--}addAll(e,t,r,o){let i=r||0;for(let s=r?e.childNodes[r]:e.firstChild,l=o==null?null:e.childNodes[o];s!=l;s=s.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(s,t);this.findAtPoint(e,i)}findPlace(e,t){let r,o;for(let i=this.open;i>=0;i--){let s=this.nodes[i],l=s.findWrapping(e);if(l&&(!r||r.length>l.length)&&(r=l,o=s,!l.length)||s.solid)break}if(!r)return null;this.sync(o);for(let i=0;i<r.length;i++)t=this.enterInner(r[i],null,t,!1);return t}insertNode(e,t){if(e.isInline&&this.needsBlock&&!this.top.type){let o=this.textblockFromContext();o&&(t=this.enterInner(o,null,t))}let r=this.findPlace(e,t);if(r){this.closeExtra();let o=this.top;o.match&&(o.match=o.match.matchType(e.type));let i=we.none;for(let s of r.concat(e.marks))(o.type?o.type.allowsMarkType(s.type):Mu(s.type,e.type))&&(i=s.addToSet(i));return o.content.push(e.mark(i)),!0}return!1}enter(e,t,r,o){let i=this.findPlace(e.create(t),r);return i&&(i=this.enterInner(e,t,r,!0,o)),i}enterInner(e,t,r,o=!1,i){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(e);let l=Tu(e,i,s.options);s.options&_o&&s.content.length==0&&(l|=_o);let a=we.none;return r=r.filter(c=>(s.type?s.type.allowsMarkType(c.type):Mu(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new fo(e,t,a,o,null,l)),this.open++,r}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=Lr)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let o=r.length-1;o>=0;o--)e+=r[o].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==t&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,r){if(e!=t&&this.find)for(let o=0;o<this.find.length;o++)this.find[o].pos==null&&e.nodeType==1&&e.contains(this.find[o].node)&&t.compareDocumentPosition(this.find[o].node)&(r?2:4)&&(this.find[o].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),r=this.options.context,o=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(o?0:1),s=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=i;a--)if(s(l-1,a))return!0;return!1}else{let u=a>0||a==0&&o?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 s(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}}function M0(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Dp.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function O0(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function Eu(n){let e={};for(let t in n)e[t]=n[t];return e}function Mu(n,e){let t=e.schema.nodes;for(let r in t){let o=t[r];if(!o.allowsMarkType(n))continue;let i=[],s=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&&s(u))return!0}};if(s(o.contentMatch))return!0}}class Ln{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=Fi(t).createDocumentFragment());let o=r,i=[];return e.forEach(s=>{if(i.length||s.marks.length){let l=0,a=0;for(;l<i.length&&a<s.marks.length;){let c=s.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;)o=i.pop()[1];for(;a<s.marks.length;){let c=s.marks[a++],u=this.serializeMark(c,s.isInline,t);u&&(i.push([c,o]),o.appendChild(u.dom),o=u.contentDOM||u.dom)}}o.appendChild(this.serializeNodeInner(s,t))}),r}serializeNodeInner(e,t){let{dom:r,contentDOM:o}=Do(Fi(t),this.nodes[e.type.name](e),null,e.attrs);if(o){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,o)}return r}serializeNode(e,t={}){let r=this.serializeNodeInner(e,t);for(let o=e.marks.length-1;o>=0;o--){let i=this.serializeMark(e.marks[o],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,t,r={}){let o=this.marks[e.type.name];return o&&Do(Fi(r),o(e,t),null,e.attrs)}static renderSpec(e,t,r=null,o){return Do(e,t,r,o)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Ln(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Ou(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return Ou(e.marks)}}function Ou(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function Fi(n){return n.document||window.document}const Au=new WeakMap;function A0(n){let e=Au.get(n);return e===void 0&&Au.set(n,e=N0(n)),e}function N0(n){let e=null;function t(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let o=0;o<r.length;o++)t(r[o]);else for(let o in r)t(r[o])}return t(n),e}function Do(n,e,t,r){if(typeof e=="string")return{dom:n.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let o=e[0],i;if(typeof o!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(i=A0(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 s=o.indexOf(" ");s>0&&(t=o.slice(0,s),o=o.slice(s+1));let l,a=t?n.createElementNS(t,o):n.createElement(o),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let d in c)if(c[d]!=null){let f=d.indexOf(" ");f>0?a.setAttributeNS(d.slice(0,f),d.slice(f+1),c[d]):a.setAttribute(d,c[d])}}for(let d=u;d<e.length;d++){let f=e[d];if(f===0){if(d<e.length-1||d>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:p,contentDOM:m}=Do(n,f,t,r);if(a.appendChild(p),m){if(l)throw new RangeError("Multiple content holes");l=m}}}return{dom:a,contentDOM:l}}const jp=65535,Pp=Math.pow(2,16);function R0(n,e){return n+e*Pp}function Nu(n){return n&jp}function I0(n){return(n-(n&jp))/Pp}const Lp=1,Bp=2,jo=4,zp=8;class ya{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&zp)>0}get deletedBefore(){return(this.delInfo&(Lp|jo))>0}get deletedAfter(){return(this.delInfo&(Bp|jo))>0}get deletedAcross(){return(this.delInfo&jo)>0}}class dt{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&dt.empty)return dt.empty}recover(e){let t=0,r=Nu(e);if(!this.inverted)for(let o=0;o<r;o++)t+=this.ranges[o*3+2]-this.ranges[o*3+1];return this.ranges[r*3]+t+I0(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let o=0,i=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?o:0);if(a>e)break;let c=this.ranges[l+i],u=this.ranges[l+s],d=a+c;if(e<=d){let f=c?e==a?-1:e==d?1:t:t,p=a+o+(f<0?0:u);if(r)return p;let m=e==(t<0?a:d)?null:R0(l/3,e-a),g=e==a?Bp:e==d?Lp:jo;return(t<0?e!=a:e!=d)&&(g|=zp),new ya(p,g,m)}o+=u-c}return r?e+o:new ya(e+o,0,null)}touches(e,t){let r=0,o=Nu(t),i=this.inverted?2:1,s=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==o*3)return!0;r+=this.ranges[l+s]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let o=0,i=0;o<this.ranges.length;o+=3){let s=this.ranges[o],l=s-(this.inverted?i:0),a=s+(this.inverted?0:i),c=this.ranges[o+t],u=this.ranges[o+r];e(l,l+c,a,a+u),i+=u-c}}invert(){return new dt(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?dt.empty:new dt(e<0?[0,-e,0]:[0,0,e])}}dt.empty=new dt([]);class tr{constructor(e=[],t,r=0,o=e.length){this.maps=e,this.mirror=t,this.from=r,this.to=o}slice(e=0,t=this.maps.length){return new tr(this.maps,this.mirror,e,t)}copy(){return new tr(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)}appendMap(e,t){this.to=this.maps.push(e),t!=null&&this.setMirror(this.maps.length-1,t)}appendMapping(e){for(let t=0,r=this.maps.length;t<e.maps.length;t++){let o=e.getMirror(t);this.appendMap(e.maps[t],o!=null&&o<t?r+o:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,r=this.maps.length+e.maps.length;t>=0;t--){let o=e.getMirror(t);this.appendMap(e.maps[t].invert(),o!=null&&o>t?r-o-1:void 0)}}invert(){let e=new tr;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;r<this.to;r++)e=this.maps[r].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,r){let o=0;for(let i=this.from;i<this.to;i++){let s=this.maps[i],l=s.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(i);if(a!=null&&a>i&&a<this.to){i=a,e=this.maps[a].recover(l.recover);continue}}o|=l.delInfo,e=l.pos}return r?e:new ya(e,o,null)}}const Vi=Object.create(null);class Ze{getMap(){return dt.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Vi[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in Vi)throw new RangeError("Duplicate use of step JSON ID "+e);return Vi[e]=t,t.prototype.jsonID=e,t}}class Re{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new Re(e,null)}static fail(e){return new Re(null,e)}static fromReplace(e,t,r,o){try{return Re.ok(e.replace(t,r,o))}catch(i){if(i instanceof Ho)return Re.fail(i.message);throw i}}}function tc(n,e,t){let r=[];for(let o=0;o<n.childCount;o++){let i=n.child(o);i.content.size&&(i=i.copy(tc(i.content,e,i))),i.isInline&&(i=e(i,t,o)),r.push(i)}return j.fromArray(r)}class en extends Ze{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),o=r.node(r.sharedDepth(this.to)),i=new $(tc(t.content,(s,l)=>!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),o),t.openStart,t.openEnd);return Re.fromReplace(e,this.from,this.to,i)}invert(){return new Mt(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new en(t.pos,r.pos,this.mark)}merge(e){return e instanceof en&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new en(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new en(t.from,t.to,e.markFromJSON(t.mark))}}Ze.jsonID("addMark",en);class Mt extends Ze{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new $(tc(t.content,o=>o.mark(this.mark.removeFromSet(o.marks)),e),t.openStart,t.openEnd);return Re.fromReplace(e,this.from,this.to,r)}invert(){return new en(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new Mt(t.pos,r.pos,this.mark)}merge(e){return e instanceof Mt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Mt(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Mt(t.from,t.to,e.markFromJSON(t.mark))}}Ze.jsonID("removeMark",Mt);class tn extends Ze{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Re.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return Re.fromReplace(e,this.pos,this.pos+1,new $(j.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let o=0;o<t.marks.length;o++)if(!t.marks[o].isInSet(r))return new tn(this.pos,t.marks[o]);return new tn(this.pos,this.mark)}}return new ar(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new tn(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new tn(t.pos,e.markFromJSON(t.mark))}}Ze.jsonID("addNodeMark",tn);class ar extends Ze{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Re.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return Re.fromReplace(e,this.pos,this.pos+1,new $(j.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new tn(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new ar(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new ar(t.pos,e.markFromJSON(t.mark))}}Ze.jsonID("removeNodeMark",ar);class je extends Ze{constructor(e,t,r,o=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=o}apply(e){return this.structure&&ba(e,this.from,this.to)?Re.fail("Structure replace would overwrite content"):Re.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new dt([this.from,this.to-this.from,this.slice.size])}invert(e){return new je(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deletedAcross&&r.deletedAcross?null:new je(t.pos,Math.max(t.pos,r.pos),this.slice)}merge(e){if(!(e instanceof je)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?$.empty:new $(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new je(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?$.empty:new $(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new je(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new je(t.from,t.to,$.fromJSON(e,t.slice),!!t.structure)}}Ze.jsonID("replace",je);class Le extends Ze{constructor(e,t,r,o,i,s,l=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=o,this.slice=i,this.insert=s,this.structure=l}apply(e){if(this.structure&&(ba(e,this.from,this.gapFrom)||ba(e,this.gapTo,this.to)))return Re.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return Re.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?Re.fromReplace(e,this.from,this.to,r):Re.fail("Content does not fit in gap")}getMap(){return new dt([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new Le(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),o=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||o<t.pos||i>r.pos?null:new Le(t.pos,r.pos,o,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Le(t.from,t.to,t.gapFrom,t.gapTo,$.fromJSON(e,t.slice),t.insert,!!t.structure)}}Ze.jsonID("replaceAround",Le);function ba(n,e,t){let r=n.resolve(e),o=t-e,i=r.depth;for(;o>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,o--;if(o>0){let s=r.node(i).maybeChild(r.indexAfter(i));for(;o>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,o--}}return!1}function _0(n,e,t,r){let o=[],i=[],s,l;n.doc.nodesBetween(e,t,(a,c,u)=>{if(!a.isInline)return;let d=a.marks;if(!r.isInSet(d)&&u.type.allowsMarkType(r.type)){let f=Math.max(c,e),p=Math.min(c+a.nodeSize,t),m=r.addToSet(d);for(let g=0;g<d.length;g++)d[g].isInSet(m)||(s&&s.to==f&&s.mark.eq(d[g])?s.to=p:o.push(s=new Mt(f,p,d[g])));l&&l.to==f?l.to=p:i.push(l=new en(f,p,r))}}),o.forEach(a=>n.step(a)),i.forEach(a=>n.step(a))}function D0(n,e,t,r){let o=[],i=0;n.doc.nodesBetween(e,t,(s,l)=>{if(!s.isInline)return;i++;let a=null;if(r instanceof ri){let c=s.marks,u;for(;u=r.isInSet(c);)(a||(a=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(s.marks)&&(a=[r]):a=s.marks;if(a&&a.length){let c=Math.min(l+s.nodeSize,t);for(let u=0;u<a.length;u++){let d=a[u],f;for(let p=0;p<o.length;p++){let m=o[p];m.step==i-1&&d.eq(o[p].style)&&(f=m)}f?(f.to=c,f.step=i):o.push({style:d,from:Math.max(l,e),to:c,step:i})}}}),o.forEach(s=>n.step(new Mt(s.from,s.to,s.style)))}function nc(n,e,t,r=t.contentMatch,o=!0){let i=n.doc.nodeAt(e),s=[],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)s.push(new je(l,u,$.empty));else{r=d;for(let f=0;f<c.marks.length;f++)t.allowsMarkType(c.marks[f].type)||n.step(new Mt(l,u,c.marks[f]));if(o&&c.isText&&t.whitespace!="pre"){let f,p=/\r?\n|\r/g,m;for(;f=p.exec(c.text);)m||(m=new $(j.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),s.push(new je(l+f.index,l+f.index+f[0].length,m))}}l=u}if(!r.validEnd){let a=r.fillBefore(j.empty,!0);n.replace(l,l,new $(a,0,0))}for(let a=s.length-1;a>=0;a--)n.step(s[a])}function j0(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function fr(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth;;--r){let o=n.$from.node(r),i=n.$from.index(r),s=n.$to.indexAfter(r);if(r<n.depth&&o.canReplace(i,s,t))return r;if(r==0||o.type.spec.isolating||!j0(o,i,s))break}return null}function P0(n,e,t){let{$from:r,$to:o,depth:i}=e,s=r.before(i+1),l=o.after(i+1),a=s,c=l,u=j.empty,d=0;for(let m=i,g=!1;m>t;m--)g||r.index(m)>0?(g=!0,u=j.from(r.node(m).copy(u)),d++):a--;let f=j.empty,p=0;for(let m=i,g=!1;m>t;m--)g||o.after(m+1)<o.end(m)?(g=!0,f=j.from(o.node(m).copy(f)),p++):c++;n.step(new Le(a,c,s,l,new $(u.append(f),d,p),u.size-d,!0))}function rc(n,e,t=null,r=n){let o=L0(n,e),i=o&&B0(r,e);return i?o.map(Ru).concat({type:e,attrs:t}).concat(i.map(Ru)):null}function Ru(n){return{type:n,attrs:null}}function L0(n,e){let{parent:t,startIndex:r,endIndex:o}=n,i=t.contentMatchAt(r).findWrapping(e);if(!i)return null;let s=i.length?i[0]:e;return t.canReplaceWith(r,o,s)?i:null}function B0(n,e){let{parent:t,startIndex:r,endIndex:o}=n,i=t.child(r),s=e.contentMatch.findWrapping(i.type);if(!s)return null;let a=(s.length?s[s.length-1]:e).contentMatch;for(let c=r;a&&c<o;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:s}function z0(n,e,t){let r=j.empty;for(let s=t.length-1;s>=0;s--){if(r.size){let l=t[s].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=j.from(t[s].type.create(t[s].attrs,r))}let o=e.start,i=e.end;n.step(new Le(o,i,o,i,new $(r,0,0),t.length,!0))}function $0(n,e,t,r,o){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=n.steps.length;n.doc.nodesBetween(e,t,(s,l)=>{let a=typeof o=="function"?o(s):o;if(s.isTextblock&&!s.hasMarkup(r,a)&&F0(n.doc,n.mapping.slice(i).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let p=r.whitespace=="pre",m=!!r.contentMatch.matchType(r.schema.linebreakReplacement);p&&!m?c=!1:!p&&m&&(c=!0)}c===!1&&Fp(n,s,l,i),nc(n,n.mapping.slice(i).map(l,1),r,void 0,c===null);let u=n.mapping.slice(i),d=u.map(l,1),f=u.map(l+s.nodeSize,1);return n.step(new Le(d,f,d+1,f-1,new $(j.from(r.create(a,null,s.marks)),0,0),1,!0)),c===!0&&$p(n,s,l,i),!1}})}function $p(n,e,t,r){e.forEach((o,i)=>{if(o.isText){let s,l=/\r?\n|\r/g;for(;s=l.exec(o.text);){let a=n.mapping.slice(r).map(t+1+i+s.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Fp(n,e,t,r){e.forEach((o,i)=>{if(o.type==o.type.schema.linebreakReplacement){let s=n.mapping.slice(r).map(t+1+i);n.replaceWith(s,s+1,e.type.schema.text(`
5
+ `))}})}function F0(n,e,t){let r=n.resolve(e),o=r.index();return r.parent.canReplaceWith(o,o+1,t)}function V0(n,e,t,r,o){let i=n.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");t||(t=i.type);let s=t.create(r,null,o||i.marks);if(i.isLeaf)return n.replaceWith(e,e+i.nodeSize,s);if(!t.validContent(i.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new Le(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new $(j.from(s),0,0),1,!0))}function nr(n,e,t=1,r){let o=n.resolve(e),i=o.depth-t,s=r&&r[r.length-1]||o.parent;if(i<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!s.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(let c=o.depth-1,u=t-2;c>i;c--,u--){let d=o.node(c),f=o.index(c);if(d.type.spec.isolating)return!1;let p=d.content.cutByIndex(f,d.childCount),m=r&&r[u+1];m&&(p=p.replaceChild(0,m.type.create(m.attrs)));let g=r&&r[u]||d;if(!d.canReplace(f+1,d.childCount)||!g.type.validContent(p))return!1}let l=o.indexAfter(i),a=r&&r[0];return o.node(i).canReplaceWith(l,l,a?a.type:o.node(i+1).type)}function H0(n,e,t=1,r){let o=n.doc.resolve(e),i=j.empty,s=j.empty;for(let l=o.depth,a=o.depth-t,c=t-1;l>a;l--,c--){i=j.from(o.node(l).copy(i));let u=r&&r[c];s=j.from(u?u.type.create(u.attrs,s):o.node(l).copy(s))}n.step(new je(e,e,new $(i.append(s),t,t),!0))}function hn(n,e){let t=n.resolve(e),r=t.index();return Vp(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function q0(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:r}=n.type.schema;for(let o=0;o<e.childCount;o++){let i=e.child(o),s=i.type==r?n.type.schema.nodes.text:i.type;if(t=t.matchType(s),!t||!n.type.allowsMarks(i.marks))return!1}return t.validEnd}function Vp(n,e){return!!(n&&e&&!n.isLeaf&&q0(n,e))}function oi(n,e,t=-1){let r=n.resolve(e);for(let o=r.depth;;o--){let i,s,l=r.index(o);if(o==r.depth?(i=r.nodeBefore,s=r.nodeAfter):t>0?(i=r.node(o+1),l++,s=r.node(o).maybeChild(l)):(i=r.node(o).maybeChild(l-1),s=r.node(o+1)),i&&!i.isTextblock&&Vp(i,s)&&r.node(o).canReplace(l,l+1))return e;if(o==0)break;e=t<0?r.before(o):r.after(o)}}function W0(n,e,t){let r=null,{linebreakReplacement:o}=n.doc.type.schema,i=n.doc.resolve(e-t),s=i.node().type;if(o&&s.inlineContent){let u=s.whitespace=="pre",d=!!s.contentMatch.matchType(o);u&&!d?r=!1:!u&&d&&(r=!0)}let l=n.steps.length;if(r===!1){let u=n.doc.resolve(e+t);Fp(n,u.node(),u.before(),l)}s.inlineContent&&nc(n,e+t-1,s,i.node().contentMatchAt(i.index()),r==null);let a=n.mapping.slice(l),c=a.map(e-t);if(n.step(new je(c,a.map(e+t,-1),$.empty,!0)),r===!0){let u=n.doc.resolve(c);$p(n,u.node(),u.before(),n.steps.length)}return n}function U0(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let o=r.depth-1;o>=0;o--){let i=r.index(o);if(r.node(o).canReplaceWith(i,i,t))return r.before(o+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(let o=r.depth-1;o>=0;o--){let i=r.indexAfter(o);if(r.node(o).canReplaceWith(i,i,t))return r.after(o+1);if(i<r.node(o).childCount)return null}return null}function Hp(n,e,t){let r=n.resolve(e);if(!t.content.size)return e;let o=t.content;for(let i=0;i<t.openStart;i++)o=o.firstChild.content;for(let i=1;i<=(t.openStart==0&&t.size?2:1);i++)for(let s=r.depth;s>=0;s--){let l=s==r.depth?0:r.pos<=(r.start(s+1)+r.end(s+1))/2?-1:1,a=r.index(s)+(l>0?1:0),c=r.node(s),u=!1;if(i==1)u=c.canReplace(a,a,o);else{let d=c.contentMatchAt(a).findWrapping(o.firstChild.type);u=d&&c.canReplaceWith(a,a,d[0])}if(u)return l==0?r.pos:l<0?r.before(s+1):r.after(s+1)}return null}function ii(n,e,t=e,r=$.empty){if(e==t&&!r.size)return null;let o=n.resolve(e),i=n.resolve(t);return qp(o,i,r)?new je(e,t,r):new G0(o,i,r).fit()}function qp(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class G0{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=j.empty;for(let o=0;o<=e.depth;o++){let i=e.node(o);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(o))})}for(let o=e.depth;o>0;o--)this.placed=j.from(e.node(o).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,o=this.close(e<0?this.$to:r.doc.resolve(e));if(!o)return null;let i=this.placed,s=r.depth,l=o.depth;for(;s&&l&&i.childCount==1;)i=i.firstChild.content,s--,l--;let a=new $(i,s,l);return e>-1?new Le(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new je(r.pos,o.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,o=this.unplaced.openEnd;r<e;r++){let i=t.firstChild;if(t.childCount>1&&(o=0),i.type.spec.isolating&&o<=r){e=r;break}t=i.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let o,i=null;r?(i=Hi(this.unplaced.content,r-1).firstChild,o=i.content):o=this.unplaced.content;let s=o.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],u,d=null;if(t==1&&(s?c.matchType(s.type)||(d=c.fillBefore(j.from(s),!1)):i&&a.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:l,parent:i,inject:d};if(t==2&&s&&(u=c.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:l,parent:i,wrap:u};if(i&&c.matchType(i.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,o=Hi(e,t);return!o.childCount||o.firstChild.isLeaf?!1:(this.unplaced=new $(e,t+1,Math.max(r,o.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,o=Hi(e,t);if(o.childCount<=1&&t>0){let i=e.size-t<=t+o.size;this.unplaced=new $(Mr(e,t-1,1),t-1,i?t-1:r)}else this.unplaced=new $(Mr(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:o,wrap:i}){for(;this.depth>t;)this.closeFrontierNode();if(i)for(let g=0;g<i.length;g++)this.openFrontierNode(i[g]);let s=this.unplaced,l=r?r.content:s.content,a=s.openStart-e,c=0,u=[],{match:d,type:f}=this.frontier[t];if(o){for(let g=0;g<o.childCount;g++)u.push(o.child(g));d=d.matchFragment(o)}let p=l.size+e-(s.content.size-s.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(Wp(g.mark(f.allowedMarks(g.marks)),c==1?a:0,c==l.childCount?p:-1)))}let m=c==l.childCount;m||(p=-1),this.placed=Or(this.placed,t,j.from(u)),this.frontier[t].match=d,m&&p<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let g=0,y=l;g<p;g++){let b=y.lastChild;this.frontier.push({type:b.type,match:b.contentMatchAt(b.childCount)}),y=b.content}this.unplaced=m?e==0?$.empty:new $(Mr(s.content,e-1,1),e-1,p<0?s.openEnd:e-1):new $(Mr(s.content,e,c),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!qi(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:r}=this.$to,o=this.$to.after(r);for(;r>1&&o==this.$to.end(--r);)++o;return o}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:o}=this.frontier[t],i=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),s=qi(e,t,o,r,i);if(s){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],u=qi(e,l,c,a,!0);if(!u||u.childCount)continue e}return{depth:t,fit:s,move:i?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Or(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let o=e.node(r),i=o.type.contentMatch.fillBefore(o.content,!0,e.index(r));this.openFrontierNode(o.type,o.attrs,i)}return e}openFrontierNode(e,t=null,r){let o=this.frontier[this.depth];o.match=o.match.matchType(e),this.placed=Or(this.placed,this.depth,j.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(j.empty,!0);t.childCount&&(this.placed=Or(this.placed,this.frontier.length,t))}}function Mr(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Mr(n.firstChild.content,e-1,t)))}function Or(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Or(n.lastChild.content,e-1,t)))}function Hi(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function Wp(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,Wp(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(j.empty,!0)))),n.copy(r)}function qi(n,e,t,r,o){let i=n.node(e),s=o?n.indexAfter(e):n.index(e);if(s==i.childCount&&!t.compatibleContent(i.type))return null;let l=r.fillBefore(i.content,!0,s);return l&&!K0(t,i.content,s)?l:null}function K0(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function J0(n){return n.spec.defining||n.spec.definingForContent}function X0(n,e,t,r){if(!r.size)return n.deleteRange(e,t);let o=n.doc.resolve(e),i=n.doc.resolve(t);if(qp(o,i,r))return n.step(new je(e,t,r));let s=Gp(o,n.doc.resolve(t));s[s.length-1]==0&&s.pop();let l=-(o.depth+1);s.unshift(l);for(let f=o.depth,p=o.pos-1;f>0;f--,p--){let m=o.node(f).type.spec;if(m.defining||m.definingAsContext||m.isolating)break;s.indexOf(f)>-1?l=f:o.before(f)==p&&s.splice(1,0,-f)}let a=s.indexOf(l),c=[],u=r.openStart;for(let f=r.content,p=0;;p++){let m=f.firstChild;if(c.push(m),p==r.openStart)break;f=m.content}for(let f=u-1;f>=0;f--){let p=c[f],m=J0(p.type);if(m&&!p.sameMarkup(o.node(Math.abs(l)-1)))u=f;else if(m||!p.type.isTextblock)break}for(let f=r.openStart;f>=0;f--){let p=(f+u+1)%(r.openStart+1),m=c[p];if(m)for(let g=0;g<s.length;g++){let y=s[(g+a)%s.length],b=!0;y<0&&(b=!1,y=-y);let w=o.node(y-1),v=o.index(y-1);if(w.canReplaceWith(v,v,m.type,m.marks))return n.replace(o.before(y),b?i.after(y):t,new $(Up(r.content,0,r.openStart,p),p,r.openEnd))}}let d=n.steps.length;for(let f=s.length-1;f>=0&&(n.replace(e,t,r),!(n.steps.length>d));f--){let p=s[f];p<0||(e=o.before(p),t=i.after(p))}}function Up(n,e,t,r,o){if(e<t){let i=n.firstChild;n=n.replaceChild(0,i.copy(Up(i.content,e+1,t,r,i)))}if(e>r){let i=o.contentMatchAt(0),s=i.fillBefore(n).append(n);n=s.append(i.matchFragment(s).fillBefore(j.empty,!0))}return n}function Z0(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let o=U0(n.doc,e,r.type);o!=null&&(e=t=o)}n.replaceRange(e,t,new $(j.from(r),0,0))}function Y0(n,e,t){let r=n.doc.resolve(e),o=n.doc.resolve(t),i=Gp(r,o);for(let s=0;s<i.length;s++){let l=i[s],a=s==i.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return n.delete(r.start(l),o.end(l));if(l>0&&(a||r.node(l-1).canReplace(r.index(l-1),o.indexAfter(l-1))))return n.delete(r.before(l),o.after(l))}for(let s=1;s<=r.depth&&s<=o.depth;s++)if(e-r.start(s)==r.depth-s&&t>r.end(s)&&o.end(s)-t!=o.depth-s&&r.start(s-1)==o.start(s-1)&&r.node(s-1).canReplace(r.index(s-1),o.index(s-1)))return n.delete(r.before(s),t);n.delete(e,t)}function Gp(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let o=r;o>=0;o--){let i=n.start(o);if(i<n.pos-(n.depth-o)||e.end(o)>e.pos+(e.depth-o)||n.node(o).type.spec.isolating||e.node(o).type.spec.isolating)break;(i==e.start(o)||o==n.depth&&o==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&o&&e.start(o-1)==i-1)&&t.push(o)}return t}class rr extends Ze{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return Re.fail("No node at attribute step's position");let r=Object.create(null);for(let i in t.attrs)r[i]=t.attrs[i];r[this.attr]=this.value;let o=t.type.create(r,null,t.marks);return Re.fromReplace(e,this.pos,this.pos+1,new $(j.from(o),0,t.isLeaf?0:1))}getMap(){return dt.empty}invert(e){return new rr(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new rr(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new rr(t.pos,t.attr,t.value)}}Ze.jsonID("attr",rr);class Br extends Ze{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let o in e.attrs)t[o]=e.attrs[o];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return Re.ok(r)}getMap(){return dt.empty}invert(e){return new Br(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Br(t.attr,t.value)}}Ze.jsonID("docAttr",Br);let cr=class extends Error{};cr=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};cr.prototype=Object.create(Error.prototype);cr.prototype.constructor=cr;cr.prototype.name="TransformError";class oc{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new tr}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new cr(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,r=$.empty){let o=ii(this.doc,e,t,r);return o&&this.step(o),this}replaceWith(e,t,r){return this.replace(e,t,new $(j.from(r),0,0))}delete(e,t){return this.replace(e,t,$.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return X0(this,e,t,r),this}replaceRangeWith(e,t,r){return Z0(this,e,t,r),this}deleteRange(e,t){return Y0(this,e,t),this}lift(e,t){return P0(this,e,t),this}join(e,t=1){return W0(this,e,t),this}wrap(e,t){return z0(this,e,t),this}setBlockType(e,t=e,r,o=null){return $0(this,e,t,r,o),this}setNodeMarkup(e,t,r=null,o){return V0(this,e,t,r,o),this}setNodeAttribute(e,t,r){return this.step(new rr(e,t,r)),this}setDocAttribute(e,t){return this.step(new Br(e,t)),this}addNodeMark(e,t){return this.step(new tn(e,t)),this}removeNodeMark(e,t){if(!(t instanceof we)){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t=t.isInSet(r.marks),!t)return this}return this.step(new ar(e,t)),this}split(e,t=1,r){return H0(this,e,t,r),this}addMark(e,t,r){return _0(this,e,t,r),this}removeMark(e,t,r){return D0(this,e,t,r),this}clearIncompatible(e,t,r){return nc(this,e,t,r),this}}const Wi=Object.create(null);class te{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new ic(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=$.empty){let r=t.content.lastChild,o=null;for(let l=0;l<t.openEnd;l++)o=r,r=r.lastChild;let i=e.steps.length,s=this.ranges;for(let l=0;l<s.length;l++){let{$from:a,$to:c}=s[l],u=e.mapping.slice(i);e.replaceRange(u.map(a.pos),u.map(c.pos),l?$.empty:t),l==0&&Du(e,i,(r?r.isInline:o&&o.isTextblock)?-1:1)}}replaceWith(e,t){let r=e.steps.length,o=this.ranges;for(let i=0;i<o.length;i++){let{$from:s,$to:l}=o[i],a=e.mapping.slice(r),c=a.map(s.pos),u=a.map(l.pos);i?e.deleteRange(c,u):(e.replaceRangeWith(c,u,t),Du(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let o=e.parent.inlineContent?new Z(e):Zn(e.node(0),e.parent,e.pos,e.index(),t,r);if(o)return o;for(let i=e.depth-1;i>=0;i--){let s=t<0?Zn(e.node(0),e.node(i),e.before(i+1),e.index(i),t,r):Zn(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,t,r);if(s)return s}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new ot(e.node(0))}static atStart(e){return Zn(e,e,0,0,1)||new ot(e)}static atEnd(e){return Zn(e,e,e.content.size,e.childCount,-1)||new ot(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Wi[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in Wi)throw new RangeError("Duplicate use of selection JSON ID "+e);return Wi[e]=t,t.prototype.jsonID=e,t}getBookmark(){return Z.between(this.$anchor,this.$head).getBookmark()}}te.prototype.visible=!0;class ic{constructor(e,t){this.$from=e,this.$to=t}}let Iu=!1;function _u(n){!Iu&&!n.parent.inlineContent&&(Iu=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class Z extends te{constructor(e,t=e){_u(e),_u(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return te.near(r);let o=e.resolve(t.map(this.anchor));return new Z(o.parent.inlineContent?o:r,r)}replace(e,t=$.empty){if(super.replace(e,t),t==$.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof Z&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new si(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new Z(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let o=e.resolve(t);return new this(o,r==t?o:e.resolve(r))}static between(e,t,r){let o=e.pos-t.pos;if((!r||o)&&(r=o>=0?1:-1),!t.parent.inlineContent){let i=te.findFrom(t,r,!0)||te.findFrom(t,-r,!0);if(i)t=i.$head;else return te.near(t,r)}return e.parent.inlineContent||(o==0?e=t:(e=(te.findFrom(e,-r,!0)||te.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=o<0&&(e=t))),new Z(e,t)}}te.jsonID("text",Z);class si{constructor(e,t){this.anchor=e,this.head=t}map(e){return new si(e.map(this.anchor),e.map(this.head))}resolve(e){return Z.between(e.resolve(this.anchor),e.resolve(this.head))}}class K extends te{constructor(e){let t=e.nodeAfter,r=e.node(0).resolve(e.pos+t.nodeSize);super(e,r),this.node=t}map(e,t){let{deleted:r,pos:o}=t.mapResult(this.anchor),i=e.resolve(o);return r?te.near(i):new K(i)}content(){return new $(j.from(this.node),0,0)}eq(e){return e instanceof K&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new sc(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new K(e.resolve(t.anchor))}static create(e,t){return new K(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}K.prototype.visible=!1;te.jsonID("node",K);class sc{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new si(r,r):new sc(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&K.isSelectable(r)?new K(t):te.near(t)}}class ot extends te{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=$.empty){if(t==$.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,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new ot(e)}map(e){return new ot(e)}eq(e){return e instanceof ot}getBookmark(){return Q0}}te.jsonID("all",ot);const Q0={map(){return this},resolve(n){return new ot(n)}};function Zn(n,e,t,r,o,i=!1){if(e.inlineContent)return Z.create(n,t);for(let s=r-(o>0?0:1);o>0?s<e.childCount:s>=0;s+=o){let l=e.child(s);if(l.isAtom){if(!i&&K.isSelectable(l))return K.create(n,t-(o<0?l.nodeSize:0))}else{let a=Zn(n,l,t+o,o<0?l.childCount:0,o,i);if(a)return a}t+=l.nodeSize*o}return null}function Du(n,e,t){let r=n.steps.length-1;if(r<e)return;let o=n.steps[r];if(!(o instanceof je||o instanceof Le))return;let i=n.mapping.maps[r],s;i.forEach((l,a,c,u)=>{s==null&&(s=u)}),n.setSelection(te.near(n.doc.resolve(s),t))}const ju=1,Pu=2,Lu=4;class ey extends oc{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|ju)&-3,this.storedMarks=null,this}get selectionSet(){return(this.updated&ju)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Pu,this}ensureMarks(e){return we.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&Pu)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&-3,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||we.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let o=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(o.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),r=r??t,!e)return this.deleteRange(t,r);let i=this.storedMarks;if(!i){let s=this.doc.resolve(t);i=r==t?s.marks():s.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,o.text(e,i)),this.selection.empty||this.setSelection(te.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=Lu,this}get scrolledIntoView(){return(this.updated&Lu)>0}}function Bu(n,e){return!e||!n?n:n.bind(e)}class Ar{constructor(e,t,r){this.name=e,this.init=Bu(t.init,r),this.apply=Bu(t.apply,r)}}const ty=[new Ar("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Ar("selection",{init(n,e){return n.selection||te.atStart(e.doc)},apply(n){return n.selection}}),new Ar("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new Ar("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class Ui{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=ty.slice(),t&&t.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Ar(r.key,r.spec.state,r))})}}class Qn{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=t){let o=this.config.plugins[r];if(o.spec.filterTransaction&&!o.spec.filterTransaction.call(o,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],r=this.applyInner(e),o=null;for(;;){let i=!1;for(let s=0;s<this.config.plugins.length;s++){let l=this.config.plugins[s];if(l.spec.appendTransaction){let a=o?o[s].n:0,c=o?o[s].state:this,u=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,c,r);if(u&&r.filterTransaction(u,s)){if(u.setMeta("appendedTransaction",e),!o){o=[];for(let d=0;d<this.config.plugins.length;d++)o.push(d<s?{state:r,n:t.length}:{state:this,n:0})}t.push(u),r=r.applyInner(u),i=!0}o&&(o[s]={state:r,n:t.length})}}if(!i)return{state:r,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new Qn(this.config),r=this.config.fields;for(let o=0;o<r.length;o++){let i=r[o];t[i.name]=i.apply(e,this[i.name],this,t)}return t}get tr(){return new ey(this)}static create(e){let t=new Ui(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new Qn(t);for(let o=0;o<t.fields.length;o++)r[t.fields[o].name]=t.fields[o].init(e,r);return r}reconfigure(e){let t=new Ui(this.schema,e.plugins),r=t.fields,o=new Qn(t);for(let i=0;i<r.length;i++){let s=r[i].name;o[s]=this.hasOwnProperty(s)?this[s]:r[i].init(e,o)}return o}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let o=e[r],i=o.spec.state;i&&i.toJSON&&(t[r]=i.toJSON.call(o,this[o.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let o=new Ui(e.schema,e.plugins),i=new Qn(o);return o.fields.forEach(s=>{if(s.name=="doc")i.doc=$t.fromJSON(e.schema,t.doc);else if(s.name=="selection")i.selection=te.fromJSON(i.doc,t.selection);else if(s.name=="storedMarks")t.storedMarks&&(i.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==s.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){i[s.name]=c.fromJSON.call(a,e,t[l],i);return}}i[s.name]=s.init(e,i)}}),i}}function Kp(n,e,t){for(let r in n){let o=n[r];o instanceof Function?o=o.bind(e):r=="handleDOMEvents"&&(o=Kp(o,e,{})),t[r]=o}return t}class $e{constructor(e){this.spec=e,this.props={},e.props&&Kp(e.props,this,this.props),this.key=e.key?e.key.key:Jp("plugin")}getState(e){return e[this.key]}}const Gi=Object.create(null);function Jp(n){return n in Gi?n+"$"+ ++Gi[n]:(Gi[n]=0,n+"$")}class ht{constructor(e="key"){this.key=Jp(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const qe=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},zr=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let va=null;const Pt=function(n,e,t){let r=va||(va=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},ny=function(){va=null},In=function(n,e,t,r){return t&&(zu(n,e,t,r,-1)||zu(n,e,t,r,1))},ry=/^(img|br|input|textarea|hr)$/i;function zu(n,e,t,r,o){for(;;){if(n==t&&e==r)return!0;if(e==(o<0?0:bt(n))){let i=n.parentNode;if(!i||i.nodeType!=1||eo(n)||ry.test(n.nodeName)||n.contentEditable=="false")return!1;e=qe(n)+(o<0?0:1),n=i}else if(n.nodeType==1){if(n=n.childNodes[e+(o<0?-1:0)],n.contentEditable=="false")return!1;e=o<0?bt(n):0}else return!1}}function bt(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function oy(n,e){for(;;){if(n.nodeType==3&&e)return n;if(n.nodeType==1&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=bt(n)}else if(n.parentNode&&!eo(n))e=qe(n),n=n.parentNode;else return null}}function iy(n,e){for(;;){if(n.nodeType==3&&e<n.nodeValue.length)return n;if(n.nodeType==1&&e<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[e],e=0}else if(n.parentNode&&!eo(n))e=qe(n)+1,n=n.parentNode;else return null}}function sy(n,e,t){for(let r=e==0,o=e==bt(n);r||o;){if(n==t)return!0;let i=qe(n);if(n=n.parentNode,!n)return!1;r=r&&i==0,o=o&&i==bt(n)}}function eo(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const li=function(n){return n.focusNode&&In(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function Sn(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function ly(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function ay(n,e,t){if(n.caretPositionFromPoint)try{let r=n.caretPositionFromPoint(e,t);if(r)return{node:r.offsetNode,offset:Math.min(bt(r.offsetNode),r.offset)}}catch{}if(n.caretRangeFromPoint){let r=n.caretRangeFromPoint(e,t);if(r)return{node:r.startContainer,offset:Math.min(bt(r.startContainer),r.startOffset)}}}const Ot=typeof navigator<"u"?navigator:null,$u=typeof document<"u"?document:null,Bn=Ot&&Ot.userAgent||"",xa=/Edge\/(\d+)/.exec(Bn),Xp=/MSIE \d/.exec(Bn),wa=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Bn),it=!!(Xp||wa||xa),sn=Xp?document.documentMode:wa?+wa[1]:xa?+xa[1]:0,At=!it&&/gecko\/(\d+)/i.test(Bn),Sa=!it&&/Chrome\/(\d+)/.exec(Bn),Ke=!!Sa,Zp=Sa?+Sa[1]:0,et=!it&&!!Ot&&/Apple Computer/.test(Ot.vendor),ur=et&&(/Mobile\/\w+/.test(Bn)||!!Ot&&Ot.maxTouchPoints>2),yt=ur||(Ot?/Mac/.test(Ot.platform):!1),cy=Ot?/Win/.test(Ot.platform):!1,Bt=/Android \d/.test(Bn),to=!!$u&&"webkitFontSmoothing"in $u.documentElement.style,uy=to?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function dy(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function _t(n,e){return typeof n=="number"?n:n[e]}function fy(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,r=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*r}}function Fu(n,e,t){let r=n.someProp("scrollThreshold")||0,o=n.someProp("scrollMargin")||5,i=n.dom.ownerDocument;for(let s=t||n.dom;s;s=zr(s)){if(s.nodeType!=1)continue;let l=s,a=l==i.body,c=a?dy(i):fy(l),u=0,d=0;if(e.top<c.top+_t(r,"top")?d=-(c.top-e.top+_t(o,"top")):e.bottom>c.bottom-_t(r,"bottom")&&(d=e.bottom-e.top>c.bottom-c.top?e.top+_t(o,"top")-c.top:e.bottom-c.bottom+_t(o,"bottom")),e.left<c.left+_t(r,"left")?u=-(c.left-e.left+_t(o,"left")):e.right>c.right-_t(r,"right")&&(u=e.right-c.right+_t(o,"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 m=l.scrollLeft-f,g=l.scrollTop-p;e={left:e.left-m,top:e.top-g,right:e.right-m,bottom:e.bottom-g}}if(a||/^(fixed|sticky)$/.test(getComputedStyle(s).position))break}}function hy(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,o;for(let i=(e.left+e.right)/2,s=t+1;s<Math.min(innerHeight,e.bottom);s+=5){let l=n.root.elementFromPoint(i,s);if(!l||l==n.dom||!n.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=t-20){r=l,o=a.top;break}}return{refDOM:r,refTop:o,stack:Yp(n.dom)}}function Yp(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=zr(r));return e}function py({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;Qp(t,r==0?0:r-e)}function Qp(n,e){for(let t=0;t<n.length;t++){let{dom:r,top:o,left:i}=n[t];r.scrollTop!=o+e&&(r.scrollTop=o+e),r.scrollLeft!=i&&(r.scrollLeft=i)}}let Kn=null;function my(n){if(n.setActive)return n.setActive();if(Kn)return n.focus(Kn);let e=Yp(n);n.focus(Kn==null?{get preventScroll(){return Kn={preventScroll:!0},!0}}:void 0),Kn||(Kn=!1,Qp(e,0))}function em(n,e){let t,r=2e8,o,i=0,s=e.top,l=e.top,a,c;for(let u=n.firstChild,d=0;u;u=u.nextSibling,d++){let f;if(u.nodeType==1)f=u.getClientRects();else if(u.nodeType==3)f=Pt(u).getClientRects();else continue;for(let p=0;p<f.length;p++){let m=f[p];if(m.top<=s&&m.bottom>=l){s=Math.max(m.bottom,s),l=Math.min(m.top,l);let g=m.left>e.left?m.left-e.left:m.right<e.left?e.left-m.right:0;if(g<r){t=u,r=g,o=g&&t.nodeType==3?{left:m.right<e.left?m.right:m.left,top:e.top}:e,u.nodeType==1&&g&&(i=d+(e.left>=(m.left+m.right)/2?1:0));continue}}else m.top>e.top&&!a&&m.left<=e.left&&m.right>=e.left&&(a=u,c={left:Math.max(m.left,Math.min(m.right,e.left)),top:m.top});!t&&(e.left>=m.right&&e.top>=m.top||e.left>=m.left&&e.top>=m.bottom)&&(i=d+1)}}return!t&&a&&(t=a,o=c,r=0),t&&t.nodeType==3?gy(t,o):!t||r&&t.nodeType==1?{node:n,offset:i}:em(t,o)}function gy(n,e){let t=n.nodeValue.length,r=document.createRange();for(let o=0;o<t;o++){r.setEnd(n,o+1),r.setStart(n,o);let i=Xt(r,1);if(i.top!=i.bottom&&lc(e,i))return{node:n,offset:o+(e.left>=(i.left+i.right)/2?1:0)}}return{node:n,offset:0}}function lc(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function yy(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function by(n,e,t){let{node:r,offset:o}=em(e,t),i=-1;if(r.nodeType==1&&!r.firstChild){let s=r.getBoundingClientRect();i=s.left!=s.right&&t.left>(s.left+s.right)/2?1:-1}return n.docView.posFromDOM(r,o,i)}function vy(n,e,t,r){let o=-1;for(let i=e,s=!1;i!=n.dom;){let l=n.docView.nearestDesc(i,!0),a;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&(!s&&a.left>r.left||a.top>r.top?o=l.posBefore:(!s&&a.right<r.left||a.bottom<r.top)&&(o=l.posAfter),s=!0),!l.contentDOM&&o<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 o>-1?o:n.docView.posFromDOM(e,t,-1)}function tm(n,e,t){let r=n.childNodes.length;if(r&&t.top<t.bottom)for(let o=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-t.top)/(t.bottom-t.top))-2)),i=o;;){let s=n.childNodes[i];if(s.nodeType==1){let l=s.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(lc(e,c))return tm(s,e,c)}}if((i=(i+1)%r)==o)break}return n}function xy(n,e){let t=n.dom.ownerDocument,r,o=0,i=ay(t,e.left,e.top);i&&({node:r,offset:o}=i);let s=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),l;if(!s||!n.dom.contains(s.nodeType!=1?s.parentNode:s)){let c=n.dom.getBoundingClientRect();if(!lc(e,c)||(s=tm(n.dom,e,c),!s))return null}if(et)for(let c=s;r&&c;c=zr(c))c.draggable&&(r=void 0);if(s=yy(s,e),r){if(At&&r.nodeType==1&&(o=Math.min(o,r.childNodes.length),o<r.childNodes.length)){let u=r.childNodes[o],d;u.nodeName=="IMG"&&(d=u.getBoundingClientRect()).right<=e.left&&d.bottom>e.top&&o++}let c;to&&o&&r.nodeType==1&&(c=r.childNodes[o-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&o--,r==n.dom&&o==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(o==0||r.nodeType!=1||r.childNodes[o-1].nodeName!="BR")&&(l=vy(n,r,o,e))}l==null&&(l=by(n,s,e));let a=n.docView.nearestDesc(s,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Vu(n){return n.top<n.bottom||n.left<n.right}function Xt(n,e){let t=n.getClientRects();if(t.length){let r=t[e<0?0:t.length-1];if(Vu(r))return r}return Array.prototype.find.call(t,Vu)||n.getBoundingClientRect()}const wy=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function nm(n,e,t){let{node:r,offset:o,atom:i}=n.docView.domFromPos(e,t<0?-1:1),s=to||At;if(r.nodeType==3)if(s&&(wy.test(r.nodeValue)||(t<0?!o:o==r.nodeValue.length))){let a=Xt(Pt(r,o,o),t);if(At&&o&&/\s/.test(r.nodeValue[o-1])&&o<r.nodeValue.length){let c=Xt(Pt(r,o-1,o-1),-1);if(c.top==a.top){let u=Xt(Pt(r,o,o+1),-1);if(u.top!=a.top)return vr(u,u.left<c.left)}}return a}else{let a=o,c=o,u=t<0?1:-1;return t<0&&!o?(c++,u=-1):t>=0&&o==r.nodeValue.length?(a--,u=1):t<0?a--:c++,vr(Xt(Pt(r,a,c),u),u<0)}if(!n.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&o&&(t<0||o==bt(r))){let a=r.childNodes[o-1];if(a.nodeType==1)return Ki(a.getBoundingClientRect(),!1)}if(i==null&&o<bt(r)){let a=r.childNodes[o];if(a.nodeType==1)return Ki(a.getBoundingClientRect(),!0)}return Ki(r.getBoundingClientRect(),t>=0)}if(i==null&&o&&(t<0||o==bt(r))){let a=r.childNodes[o-1],c=a.nodeType==3?Pt(a,bt(a)-(s?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return vr(Xt(c,1),!1)}if(i==null&&o<bt(r)){let a=r.childNodes[o];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?Pt(a,0,s?0:1):a.nodeType==1?a:null:null;if(c)return vr(Xt(c,-1),!0)}return vr(Xt(r.nodeType==3?Pt(r):r,-t),t>=0)}function vr(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function Ki(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function rm(n,e,t){let r=n.state,o=n.root.activeElement;r!=e&&n.updateState(e),o!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),o!=n.dom&&o&&o.focus()}}function Sy(n,e,t){let r=e.selection,o=t=="up"?r.$from:r.$to;return rm(n,e,()=>{let{node:i}=n.docView.domFromPos(o.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(i,!0);if(!l)break;if(l.node.isBlock){i=l.contentDOM||l.dom;break}i=l.dom.parentNode}let s=nm(n,o.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=Pt(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let u=a[c];if(u.bottom>u.top+1&&(t=="up"?s.top-u.top>(u.bottom-s.top)*2:u.bottom-s.bottom>(s.bottom-u.top)*2))return!1}}return!0})}const Cy=/[\u0590-\u08ac]/;function Ty(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let o=r.parentOffset,i=!o,s=o==r.parent.content.size,l=n.domSelection();return l?!Cy.test(r.parent.textContent)||!l.modify?t=="left"||t=="backward"?i:s:rm(n,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:u,anchorOffset:d}=n.domSelectionRange(),f=l.caretBidiLevel;l.modify("move",t,"character");let p=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:m,focusOffset:g}=n.domSelectionRange(),y=m&&!p.contains(m.nodeType==1?m:m.parentNode)||a==m&&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 Hu=null,qu=null,Wu=!1;function ky(n,e,t){return Hu==e&&qu==t?Wu:(Hu=e,qu=t,Wu=t=="up"||t=="down"?Sy(n,e,t):Ty(n,e,t))}const vt=0,Uu=1,Tn=2,Nt=3;class no{constructor(e,t,r,o){this.parent=e,this.children=t,this.dom=r,this.contentDOM=o,this.dirty=vt,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,r=this.posAtStart;;t++){let o=this.children[t];if(o==e)return r;r+=o.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let i,s;if(e==this.contentDOM)i=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.previousSibling}for(;i&&!((s=i.pmViewDesc)&&s.parent==this);)i=i.previousSibling;return i?this.posBeforeChild(s)+s.size:this.posAtStart}else{let i,s;if(e==this.contentDOM)i=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&!((s=i.pmViewDesc)&&s.parent==this);)i=i.nextSibling;return i?this.posBeforeChild(s):this.posAtEnd}let o;if(e==this.dom&&this.contentDOM)o=t>qe(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))o=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let i=e;;i=i.parentNode){if(i==this.dom){o=!1;break}if(i.previousSibling)break}if(o==null&&t==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){o=!0;break}if(i.nextSibling)break}}return o??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,o=e;o;o=o.parentNode){let i=this.getDesc(o),s;if(i&&(!t||i.node))if(r&&(s=i.nodeDOM)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):s==e))r=!1;else return i}}getDesc(e){let t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let o=e;o;o=o.parentNode){let i=this.getDesc(o);if(i)return i.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;t<this.children.length;t++){let o=this.children[t],i=r+o.size;if(r==e&&i!=r){for(;!o.border&&o.children.length;)for(let s=0;s<o.children.length;s++){let l=o.children[s];if(l.size){o=l;break}}return o}if(e<i)return o.descAt(e-r-o.border);r=i}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,o=0;for(let i=0;r<this.children.length;r++){let s=this.children[r],l=i+s.size;if(l>e||s instanceof im){o=e-i;break}i=l}if(o)return this.children[r].domFromPos(o-this.children[r].border,t);for(let i;r&&!(i=this.children[r-1]).size&&i instanceof om&&i.side>=0;r--);if(t<=0){let i,s=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,s=!1);return i&&t&&s&&!i.border&&!i.domAtom?i.domFromPos(i.size,t):{node:this.contentDOM,offset:i?qe(i.dom)+1:0}}else{let i,s=!0;for(;i=r<this.children.length?this.children[r]:null,!(!i||i.dom.parentNode==this.contentDOM);r++,s=!1);return i&&s&&!i.border&&!i.domAtom?i.domFromPos(0,t):{node:this.contentDOM,offset:i?qe(i.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let o=-1,i=-1;for(let s=r,l=0;;l++){let a=this.children[l],c=s+a.size;if(o==-1&&e<=c){let u=s+a.border;if(e>=u&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,u);e=s;for(let d=l;d>0;d--){let f=this.children[d-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){o=qe(f.dom)+1;break}e-=f.size}o==-1&&(o=0)}if(o>-1&&(c>t||l==this.children.length-1)){t=c;for(let u=l+1;u<this.children.length;u++){let d=this.children[u];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(-1)){i=qe(d.dom);break}t+=d.size}i==-1&&(i=this.contentDOM.childNodes.length);break}s=c}return{node:this.contentDOM,from:e,to:t,fromOffset:o,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:r}=this.domFromPos(e,0);if(t.nodeType!=1||r==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[r]}setSelection(e,t,r,o=!1){let i=Math.min(e,t),s=Math.max(e,t);for(let p=0,m=0;p<this.children.length;p++){let g=this.children[p],y=m+g.size;if(i>m&&s<y)return g.setSelection(e-m-g.border,t-m-g.border,r,o);m=y}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),c=r.root.getSelection(),u=r.domSelectionRange(),d=!1;if((At||et)&&e==t){let{node:p,offset:m}=l;if(p.nodeType==3){if(d=!!(m&&p.nodeValue[m-1]==`
6
+ `),d&&m==p.nodeValue.length)for(let g=p,y;g;g=g.parentNode){if(y=g.nextSibling){y.nodeName=="BR"&&(l=a={node:y.parentNode,offset:qe(y)+1});break}let b=g.pmViewDesc;if(b&&b.node&&b.node.isBlock)break}}else{let g=p.childNodes[m-1];d=g&&(g.nodeName=="BR"||g.contentEditable=="false")}}if(At&&u.focusNode&&u.focusNode!=a.node&&u.focusNode.nodeType==1){let p=u.focusNode.childNodes[u.focusOffset];p&&p.contentEditable=="false"&&(o=!0)}if(!(o||d&&et)&&In(l.node,l.offset,u.anchorNode,u.anchorOffset)&&In(a.node,a.offset,u.focusNode,u.focusOffset))return;let f=!1;if((c.extend||e==t)&&!d){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),f=!0}catch{}}if(!f){if(e>t){let m=l;l=a,a=m}let p=document.createRange();p.setEnd(a.node,a.offset),p.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(p)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let r=0,o=0;o<this.children.length;o++){let i=this.children[o],s=r+i.size;if(r==s?e<=s&&t>=r:e<s&&t>r){let l=r+i.border,a=s-i.border;if(e>=l&&t<=a){this.dirty=e==r||t==s?Tn:Uu,e==l&&t==a&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=Nt:i.markDirty(e-l,t-l);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?Tn:Nt}r=s}this.dirty=Tn}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?Tn:Uu;t.dirty<r&&(t.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(e){return!1}}class om extends no{constructor(e,t,r,o){let i,s=t.type.toDOM;if(typeof s=="function"&&(s=s(r,()=>{if(!i)return o;if(i.parent)return i.parent.posBeforeChild(i)})),!t.type.spec.raw){if(s.nodeType!=1){let l=document.createElement("span");l.appendChild(s),s=l}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return this.dirty==vt&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}}class Ey extends no{constructor(e,t,r,o){super(e,[],t,null),this.textDOM=r,this.text=o}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class _n extends no{constructor(e,t,r,o,i){super(e,[],r,o),this.mark=t,this.spec=i}static create(e,t,r,o){let i=o.nodeViews[t.type.name],s=i&&i(t,o,r);return(!s||!s.dom)&&(s=Ln.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new _n(e,t,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.dirty&Nt||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Nt&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=vt){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=vt}}slice(e,t,r){let o=_n.create(this.parent,this.mark,!0,r),i=this.children,s=this.size;t<s&&(i=Ta(i,t,s,r)),e>0&&(i=Ta(i,0,e,r));for(let l=0;l<i.length;l++)i[l].parent=o;return o.children=i,o}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class ln extends no{constructor(e,t,r,o,i,s,l,a,c){super(e,[],i,s),this.node=t,this.outerDeco=r,this.innerDeco=o,this.nodeDOM=l}static create(e,t,r,o,i,s){let l=i.nodeViews[t.type.name],a,c=l&&l(t,i,()=>{if(!a)return s;if(a.parent)return a.parent.posBeforeChild(a)},r,o),u=c&&c.dom,d=c&&c.contentDOM;if(t.isText){if(!u)u=document.createTextNode(t.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:d}=Ln.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!d&&!t.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),t.type.spec.draggable&&(u.draggable=!0));let f=u;return u=am(u,r,t),c?a=new My(e,t,r,o,u,d||null,f,c,i,s+1):t.isText?new ai(e,t,r,o,u,f,i):new ln(e,t,r,o,u,d||null,f,i,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let r=this.children[t];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>j.empty)}return e}matchesNode(e,t,r){return this.dirty==vt&&e.eq(this.node)&&Uo(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,o=t,i=e.composing?this.localCompositionInfo(e,t):null,s=i&&i.pos>-1?i:null,l=i&&i.pos<0,a=new Ay(this,s&&s.node,e);Iy(this.node,this.innerDeco,(c,u,d)=>{c.spec.marks?a.syncToMarks(c.spec.marks,r,e):c.type.side>=0&&!d&&a.syncToMarks(u==this.node.childCount?we.none:this.node.child(u).marks,r,e),a.placeWidget(c,e,o)},(c,u,d,f)=>{a.syncToMarks(c.marks,r,e);let p;a.findNodeMatch(c,u,d,f)||l&&e.state.selection.from>o&&e.state.selection.to<o+c.nodeSize&&(p=a.findIndexWithChild(i.node))>-1&&a.updateNodeAt(c,u,d,p,e)||a.updateNextNode(c,u,d,e,f,o)||a.addNode(c,u,d,e,o),o+=c.nodeSize}),a.syncToMarks([],r,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==Tn)&&(s&&this.protectLocalComposition(e,s),sm(this.contentDOM,this.children,e),ur&&_y(this.dom))}localCompositionInfo(e,t){let{from:r,to:o}=e.state.selection;if(!(e.state.selection instanceof Z)||r<t||o>t+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let s=i.nodeValue,l=Dy(this.node.content,s,r-t,o-t);return l<0?null:{node:i,pos:l,text:s}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:o}){if(this.getDesc(t))return;let i=t;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let s=new Ey(this,i,t,o);e.input.compositionNodes.push(s),this.children=Ta(this.children,r,r+o.length,e,s)}update(e,t,r,o){return this.dirty==Nt||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,o),!0)}updateInner(e,t,r,o){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(o,this.posAtStart),this.dirty=vt}updateOuterDeco(e){if(Uo(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=lm(this.dom,this.nodeDOM,Ca(this.outerDeco,this.node,t),Ca(e,this.node,t)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.dom.draggable=!0)}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function Gu(n,e,t,r,o){am(r,e,n);let i=new ln(void 0,n,e,t,r,r,r,o,0);return i.contentDOM&&i.updateChildren(o,0),i}class ai extends ln{constructor(e,t,r,o,i,s,l){super(e,t,r,o,i,null,s,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,o){return this.dirty==Nt||this.dirty!=vt&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=vt||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,o.trackWrites==this.nodeDOM&&(o.trackWrites=null)),this.node=e,this.dirty=vt,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,r){let o=this.node.cut(e,t),i=document.createTextNode(o.text);return new ai(this.parent,o,this.outerDeco,this.innerDeco,i,i,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=Nt)}get domAtom(){return!1}isText(e){return this.node.text==e}}class im extends no{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==vt&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class My extends ln{constructor(e,t,r,o,i,s,l,a,c,u){super(e,t,r,o,i,s,l,c,u),this.spec=a}update(e,t,r,o){if(this.dirty==Nt)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,t,r);return i&&this.updateInner(e,t,r,o),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,o)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,r,o){this.spec.setSelection?this.spec.setSelection(e,t,r.root):super.setSelection(e,t,r,o)}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 sm(n,e,t){let r=n.firstChild,o=!1;for(let i=0;i<e.length;i++){let s=e[i],l=s.dom;if(l.parentNode==n){for(;l!=r;)r=Ku(r),o=!0;r=r.nextSibling}else o=!0,n.insertBefore(l,r);if(s instanceof _n){let a=r?r.previousSibling:n.lastChild;sm(s.contentDOM,s.children,t),r=a?a.nextSibling:n.firstChild}}for(;r;)r=Ku(r),o=!0;o&&t.trackWrites==n&&(t.trackWrites=null)}const Rr=function(n){n&&(this.nodeName=n)};Rr.prototype=Object.create(null);const kn=[new Rr];function Ca(n,e,t){if(n.length==0)return kn;let r=t?kn[0]:new Rr,o=[r];for(let i=0;i<n.length;i++){let s=n[i].type.attrs;if(s){s.nodeName&&o.push(r=new Rr(s.nodeName));for(let l in s){let a=s[l];a!=null&&(t&&o.length==1&&o.push(r=new Rr(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 o}function lm(n,e,t,r){if(t==kn&&r==kn)return e;let o=e;for(let i=0;i<r.length;i++){let s=r[i],l=t[i];if(i){let a;l&&l.nodeName==s.nodeName&&o!=n&&(a=o.parentNode)&&a.nodeName.toLowerCase()==s.nodeName||(a=document.createElement(s.nodeName),a.pmIsDeco=!0,a.appendChild(o),l=kn[0]),o=a}Oy(o,l||kn[0],s)}return o}function Oy(n,e,t){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in t)&&n.removeAttribute(r);for(let r in t)r!="class"&&r!="style"&&r!="nodeName"&&t[r]!=e[r]&&n.setAttribute(r,t[r]);if(e.class!=t.class){let r=e.class?e.class.split(" ").filter(Boolean):[],o=t.class?t.class.split(" ").filter(Boolean):[];for(let i=0;i<r.length;i++)o.indexOf(r[i])==-1&&n.classList.remove(r[i]);for(let i=0;i<o.length;i++)r.indexOf(o[i])==-1&&n.classList.add(o[i]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,o;for(;o=r.exec(e.style);)n.style.removeProperty(o[1])}t.style&&(n.style.cssText+=t.style)}}function am(n,e,t){return lm(n,n,kn,Ca(e,t,n.nodeType!=1))}function Uo(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].type.eq(e[t].type))return!1;return!0}function Ku(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class Ay{constructor(e,t,r){this.lock=t,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Ny(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let r=e;r<t;r++)this.top.children[r].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,r){let o=0,i=this.stack.length>>1,s=Math.min(i,e.length);for(;o<s&&(o==i-1?this.top:this.stack[o+1<<1]).matchesMark(e[o])&&e[o].type.spec.spanning!==!1;)o++;for(;o<i;)this.destroyRest(),this.top.dirty=vt,this.index=this.stack.pop(),this.top=this.stack.pop(),i--;for(;i<e.length;){this.stack.push(this.top,this.index+1);let l=-1;for(let a=this.index;a<Math.min(this.index+3,this.top.children.length);a++){let c=this.top.children[a];if(c.matchesMark(e[i])&&!this.isLocked(c.dom)){l=a;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let a=_n.create(this.top,e[i],t,r);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,i++}}findNodeMatch(e,t,r,o){let i=-1,s;if(o>=this.preMatch.index&&(s=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&s.matchesNode(e,t,r))i=this.top.children.indexOf(s,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,t,r)&&!this.preMatch.matched.has(c)){i=l;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,t,r,o,i){let s=this.top.children[o];return s.dirty==Nt&&s.dom==s.contentDOM&&(s.dirty=Tn),s.update(e,t,r,i)?(this.destroyBetween(this.index,o),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let o=this.index;o<this.top.children.length;o++)if(this.top.children[o]==r)return o}return-1}e=t}}updateNextNode(e,t,r,o,i,s){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof ln){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!=Nt&&Uo(t,a.outerDeco));if(!f&&a.update(e,t,r,o))return this.destroyBetween(this.index,l),a.dom!=u&&(this.changed=!0),this.index++,!0;if(!f&&(d=this.recreateWrapper(a,e,t,r,o,s)))return this.destroyBetween(this.index,l),this.top.children[this.index]=d,d.contentDOM&&(d.dirty=Tn,d.updateChildren(o,s+1),d.dirty=vt),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,r,o,i,s){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Uo(r,e.outerDeco)||!o.eq(e.innerDeco))return null;let l=ln.create(this.top,t,r,o,i,s);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,t,r,o,i){let s=ln.create(this.top,e,t,r,o,i);s.contentDOM&&s.updateChildren(o,i+1),this.top.children.splice(this.index++,0,s),this.changed=!0}placeWidget(e,t,r){let o=this.index<this.top.children.length?this.top.children[this.index]:null;if(o&&o.matchesWidget(e)&&(e==o.widget||!o.widget.type.toDOM.parentNode))this.index++;else{let i=new om(this.top,e,t,r);this.top.children.splice(this.index++,0,i),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof _n;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof ai)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((et||Ke)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let o=new im(this.top,[],r,null);t!=this.top?t.children.push(o):t.children.splice(this.index++,0,o),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function Ny(n,e){let t=e,r=t.children.length,o=n.childCount,i=new Map,s=[];e:for(;o>0;){let l;for(;;)if(r){let c=t.children[r-1];if(c instanceof _n)t=c,r=c.children.length;else{l=c,r--;break}}else{if(t==e)break e;r=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=n.child(o-1))break;--o,i.set(l,o),s.push(l)}}return{index:o,matched:i,matches:s.reverse()}}function Ry(n,e){return n.type.side-e.type.side}function Iy(n,e,t,r){let o=e.locals(n),i=0;if(o.length==0){for(let c=0;c<n.childCount;c++){let u=n.child(c);r(u,o,e.forChild(i,u),c),i+=u.nodeSize}return}let s=0,l=[],a=null;for(let c=0;;){let u,d;for(;s<o.length&&o[s].to==i;){let y=o[s++];y.widget&&(u?(d||(d=[u])).push(y):u=y)}if(u)if(d){d.sort(Ry);for(let y=0;y<d.length;y++)t(d[y],c,!!a)}else t(u,c,!!a);let f,p;if(a)p=-1,f=a,a=null;else if(c<n.childCount)p=c,f=n.child(c++);else break;for(let y=0;y<l.length;y++)l[y].to<=i&&l.splice(y--,1);for(;s<o.length&&o[s].from<=i&&o[s].to>i;)l.push(o[s++]);let m=i+f.nodeSize;if(f.isText){let y=m;s<o.length&&o[s].from<y&&(y=o[s].from);for(let b=0;b<l.length;b++)l[b].to<y&&(y=l[b].to);y<m&&(a=f.cut(y-i),f=f.cut(0,y-i),m=y,p=-1)}else for(;s<o.length&&o[s].to<m;)s++;let g=f.isInline&&!f.isLeaf?l.filter(y=>!y.inline):l.slice();r(f,g,e.forChild(i,f),p),i=m}}function _y(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function Dy(n,e,t,r){for(let o=0,i=0;o<n.childCount&&i<=r;){let s=n.child(o++),l=i;if(i+=s.nodeSize,!s.isText)continue;let a=s.text;for(;o<n.childCount;){let c=n.child(o++);if(i+=c.nodeSize,!c.isText)break;a+=c.text}if(i>=t){if(i>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l<r?a.lastIndexOf(e,r-l-1):-1;if(c>=0&&c+e.length+l>=t)return l+c;if(t==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function Ta(n,e,t,r,o){let i=[];for(let s=0,l=0;s<n.length;s++){let a=n[s],c=l,u=l+=a.size;c>=t||u<=e?i.push(a):(c<e&&i.push(a.slice(0,e-c,r)),o&&(i.push(o),o=void 0),u>t&&i.push(a.slice(t-c,a.size,r)))}return i}function ac(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let o=n.docView.nearestDesc(t.focusNode),i=o&&o.size==0,s=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(s<0)return null;let l=r.resolve(s),a,c;if(li(t)){for(a=s;o&&!o.node;)o=o.parent;let d=o.node;if(o&&d.isAtom&&K.isSelectable(d)&&o.parent&&!(d.isInline&&sy(t.focusNode,t.focusOffset,o.dom))){let f=o.posBefore;c=new K(s==f?l:r.resolve(f))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let d=s,f=s;for(let p=0;p<t.rangeCount;p++){let m=t.getRangeAt(p);d=Math.min(d,n.docView.posFromDOM(m.startContainer,m.startOffset,1)),f=Math.max(f,n.docView.posFromDOM(m.endContainer,m.endOffset,-1))}if(d<0)return null;[a,s]=f==n.state.selection.anchor?[f,d]:[d,f],l=r.resolve(s)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let u=r.resolve(a);if(!c){let d=e=="pointer"||n.state.selection.head<l.pos&&!i?1:-1;c=cc(n,u,l,d)}return c}function cm(n){return n.editable?n.hasFocus():dm(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function Ft(n,e=!1){let t=n.state.selection;if(um(n,t),!!cm(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&Ke){let r=n.domSelectionRange(),o=n.domObserver.currentSelection;if(r.anchorNode&&o.anchorNode&&In(r.anchorNode,r.anchorOffset,o.anchorNode,o.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)Py(n);else{let{anchor:r,head:o}=t,i,s;Ju&&!(t instanceof Z)&&(t.$from.parent.inlineContent||(i=Xu(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(s=Xu(n,t.to))),n.docView.setSelection(r,o,n,e),Ju&&(i&&Zu(i),s&&Zu(s)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&jy(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const Ju=et||Ke&&Zp<63;function Xu(n,e){let{node:t,offset:r}=n.docView.domFromPos(e,0),o=r<t.childNodes.length?t.childNodes[r]:null,i=r?t.childNodes[r-1]:null;if(et&&o&&o.contentEditable=="false")return Ji(o);if((!o||o.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(o)return Ji(o);if(i)return Ji(i)}}function Ji(n){return n.contentEditable="true",et&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function Zu(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function jy(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),r=t.anchorNode,o=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=r||t.anchorOffset!=o)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!cm(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function Py(n){let e=n.domSelection(),t=document.createRange();if(!e)return;let r=n.cursorWrapper.dom,o=r.nodeName=="IMG";o?t.setStart(r.parentNode,qe(r)+1):t.setStart(r,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!o&&!n.state.selection.visible&&it&&sn<=11&&(r.disabled=!0,r.disabled=!1)}function um(n,e){if(e instanceof K){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(Yu(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else Yu(n)}function Yu(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function cc(n,e,t,r){return n.someProp("createSelectionBetween",o=>o(n,e,t))||Z.between(e,t,r)}function Qu(n){return n.editable&&!n.hasFocus()?!1:dm(n)}function dm(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function Ly(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return In(e.node,e.offset,t.anchorNode,t.anchorOffset)}function ka(n,e){let{$anchor:t,$head:r}=n.selection,o=e>0?t.max(r):t.min(r),i=o.parent.inlineContent?o.depth?n.doc.resolve(e>0?o.after():o.before()):null:o;return i&&te.findFrom(i,e)}function Zt(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function ed(n,e,t){let r=n.state.selection;if(r instanceof Z)if(t.indexOf("s")>-1){let{$head:o}=r,i=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let s=n.state.doc.resolve(o.pos+i.nodeSize*(e<0?-1:1));return Zt(n,new Z(r.$anchor,s))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let o=ka(n.state,e);return o&&o instanceof K?Zt(n,o):!1}else if(!(yt&&t.indexOf("m")>-1)){let o=r.$head,i=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter,s;if(!i||i.isText)return!1;let l=e<0?o.pos-i.nodeSize:o.pos;return i.isAtom||(s=n.docView.descAt(l))&&!s.contentDOM?K.isSelectable(i)?Zt(n,new K(e<0?n.state.doc.resolve(o.pos-i.nodeSize):o)):to?Zt(n,new Z(n.state.doc.resolve(e<0?l:l+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof K&&r.node.isInline)return Zt(n,new Z(e>0?r.$to:r.$from));{let o=ka(n.state,e);return o?Zt(n,o):!1}}}function Go(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Ir(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function Jn(n,e){return e<0?By(n):zy(n)}function By(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let o,i,s=!1;for(At&&t.nodeType==1&&r<Go(t)&&Ir(t.childNodes[r],-1)&&(s=!0);;)if(r>0){if(t.nodeType!=1)break;{let l=t.childNodes[r-1];if(Ir(l,-1))o=t,i=--r;else if(l.nodeType==3)t=l,r=t.nodeValue.length;else break}}else{if(fm(t))break;{let l=t.previousSibling;for(;l&&Ir(l,-1);)o=t.parentNode,i=qe(l),l=l.previousSibling;if(l)t=l,r=Go(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}s?Ea(n,t,r):o&&Ea(n,o,i)}function zy(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let o=Go(t),i,s;for(;;)if(r<o){if(t.nodeType!=1)break;let l=t.childNodes[r];if(Ir(l,1))i=t,s=++r;else break}else{if(fm(t))break;{let l=t.nextSibling;for(;l&&Ir(l,1);)i=l.parentNode,s=qe(l)+1,l=l.nextSibling;if(l)t=l,r=0,o=Go(t);else{if(t=t.parentNode,t==n.dom)break;r=o=0}}}i&&Ea(n,i,s)}function fm(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function $y(n,e){for(;n&&e==n.childNodes.length&&!eo(n);)e=qe(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=0}}function Fy(n,e){for(;n&&!e&&!eo(n);)e=qe(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function Ea(n,e,t){if(e.nodeType!=3){let i,s;(s=$y(e,t))?(e=s,t=0):(i=Fy(e,t))&&(e=i,t=i.nodeValue.length)}let r=n.domSelection();if(!r)return;if(li(r)){let i=document.createRange();i.setEnd(e,t),i.setStart(e,t),r.removeAllRanges(),r.addRange(i)}else r.extend&&r.extend(e,t);n.domObserver.setCurSelection();let{state:o}=n;setTimeout(()=>{n.state==o&&Ft(n)},50)}function td(n,e){let t=n.state.doc.resolve(e);if(!(Ke||cy)&&t.parent.inlineContent){let o=n.coordsAtPos(e);if(e>t.start()){let i=n.coordsAtPos(e-1),s=(i.top+i.bottom)/2;if(s>o.top&&s<o.bottom&&Math.abs(i.left-o.left)>1)return i.left<o.left?"ltr":"rtl"}if(e<t.end()){let i=n.coordsAtPos(e+1),s=(i.top+i.bottom)/2;if(s>o.top&&s<o.bottom&&Math.abs(i.left-o.left)>1)return i.left>o.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function nd(n,e,t){let r=n.state.selection;if(r instanceof Z&&!r.empty||t.indexOf("s")>-1||yt&&t.indexOf("m")>-1)return!1;let{$from:o,$to:i}=r;if(!o.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let s=ka(n.state,e);if(s&&s instanceof K)return Zt(n,s)}if(!o.parent.inlineContent){let s=e<0?o:i,l=r instanceof ot?te.near(s,e):te.findFrom(s,e);return l?Zt(n,l):!1}return!1}function rd(n,e){if(!(n.state.selection instanceof Z))return!0;let{$head:t,$anchor:r,empty:o}=n.state.selection;if(!t.sameParent(r))return!0;if(!o)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(i&&!i.isText){let s=n.state.tr;return e<0?s.delete(t.pos-i.nodeSize,t.pos):s.delete(t.pos,t.pos+i.nodeSize),n.dispatch(s),!0}return!1}function od(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function Vy(n){if(!et||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;od(n,r,"true"),setTimeout(()=>od(n,r,"false"),20)}return!1}function Hy(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function qy(n,e){let t=e.keyCode,r=Hy(e);if(t==8||yt&&t==72&&r=="c")return rd(n,-1)||Jn(n,-1);if(t==46&&!e.shiftKey||yt&&t==68&&r=="c")return rd(n,1)||Jn(n,1);if(t==13||t==27)return!0;if(t==37||yt&&t==66&&r=="c"){let o=t==37?td(n,n.state.selection.from)=="ltr"?-1:1:-1;return ed(n,o,r)||Jn(n,o)}else if(t==39||yt&&t==70&&r=="c"){let o=t==39?td(n,n.state.selection.from)=="ltr"?1:-1:1;return ed(n,o,r)||Jn(n,o)}else{if(t==38||yt&&t==80&&r=="c")return nd(n,-1,r)||Jn(n,-1);if(t==40||yt&&t==78&&r=="c")return Vy(n)||nd(n,1,r)||Jn(n,1);if(r==(yt?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function uc(n,e){n.someProp("transformCopied",p=>{e=p(e,n)});let t=[],{content:r,openStart:o,openEnd:i}=e;for(;o>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){o--,i--;let p=r.firstChild;t.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),r=p.content}let s=n.someProp("clipboardSerializer")||Ln.fromSchema(n.state.schema),l=bm(),a=l.createElement("div");a.appendChild(s.serializeFragment(r,{document:l}));let c=a.firstChild,u,d=0;for(;c&&c.nodeType==1&&(u=ym[c.nodeName.toLowerCase()]);){for(let p=u.length-1;p>=0;p--){let m=l.createElement(u[p]);for(;a.firstChild;)m.appendChild(a.firstChild);a.appendChild(m),d++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${o} ${i}${d?` -${d}`:""} ${JSON.stringify(t)}`);let f=n.someProp("clipboardTextSerializer",p=>p(e,n))||e.content.textBetween(0,e.content.size,`
7
+
8
+ `);return{dom:a,text:f,slice:e}}function hm(n,e,t,r,o){let i=o.parent.type.spec.code,s,l;if(!t&&!e)return null;let a=e&&(r||i||!t);if(a){if(n.someProp("transformPastedText",f=>{e=f(e,i||r,n)}),i)return e?new $(j.from(n.state.schema.text(e.replace(/\r\n?/g,`
9
+ `))),0,0):$.empty;let d=n.someProp("clipboardTextParser",f=>f(e,o,r,n));if(d)l=d;else{let f=o.marks(),{schema:p}=n.state,m=Ln.fromSchema(p);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(g=>{let y=s.appendChild(document.createElement("p"));g&&y.appendChild(m.serializeNode(p.text(g,f)))})}}else n.someProp("transformPastedHTML",d=>{t=d(t,n)}),s=Ky(t),to&&Jy(s);let c=s&&s.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=s.firstChild;for(;f&&f.nodeType!=1;)f=f.nextSibling;if(!f)break;s=f}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||on.fromSchema(n.state.schema)).parseSlice(s,{preserveWhitespace:!!(a||u),context:o,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!Wy.test(f.parentNode.nodeName)?{ignore:!0}:null}})),u)l=Xy(id(l,+u[1],+u[2]),u[4]);else if(l=$.maxOpen(Uy(l.content,o),!0),l.openStart||l.openEnd){let d=0,f=0;for(let p=l.content.firstChild;d<l.openStart&&!p.type.spec.isolating;d++,p=p.firstChild);for(let p=l.content.lastChild;f<l.openEnd&&!p.type.spec.isolating;f++,p=p.lastChild);l=id(l,d,f)}return n.someProp("transformPasted",d=>{l=d(l,n)}),l}const Wy=/^(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 Uy(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let o=e.node(t).contentMatchAt(e.index(t)),i,s=[];if(n.forEach(l=>{if(!s)return;let a=o.findWrapping(l.type),c;if(!a)return s=null;if(c=s.length&&i.length&&mm(a,i,l,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=gm(s[s.length-1],i.length));let u=pm(l,a);s.push(u),o=o.matchType(u.type),i=a}}),s)return j.from(s)}return n}function pm(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,j.from(n));return n}function mm(n,e,t,r,o){if(o<n.length&&o<e.length&&n[o]==e[o]){let i=mm(n,e,t,r.lastChild,o+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(o==n.length-1?t.type:n[o+1]))return r.copy(r.content.append(j.from(pm(t,n,o+1))))}}function gm(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,gm(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(j.empty,!0);return n.copy(t.append(r))}function Ma(n,e,t,r,o,i){let s=e<0?n.firstChild:n.lastChild,l=s.content;return n.childCount>1&&(i=0),o<r-1&&(l=Ma(l,e,t,r,o+1,i)),o>=t&&(l=e<0?s.contentMatchAt(0).fillBefore(l,i<=o).append(l):l.append(s.contentMatchAt(s.childCount).fillBefore(j.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,s.copy(l))}function id(n,e,t){return e<n.openStart&&(n=new $(Ma(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new $(Ma(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const ym={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 sd=null;function bm(){return sd||(sd=document.implementation.createHTMLDocument("title"))}let Xi=null;function Gy(n){let e=window.trustedTypes;return e?(Xi||(Xi=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),Xi.createHTML(n)):n}function Ky(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=bm().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),o;if((o=r&&ym[r[1].toLowerCase()])&&(n=o.map(i=>"<"+i+">").join("")+n+o.map(i=>"</"+i+">").reverse().join("")),t.innerHTML=Gy(n),o)for(let i=0;i<o.length;i++)t=t.querySelector(o[i])||t;return t}function Jy(n){let e=n.querySelectorAll(Ke?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let r=e[t];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function Xy(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:o,openStart:i,openEnd:s}=n;for(let l=r.length-2;l>=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;o=j.from(a.create(r[l+1],o)),i++,s++}return new $(o,i,s)}const tt={},nt={},Zy={touchstart:!0,touchmove:!0};class Yy{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function Qy(n){for(let e in tt){let t=tt[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{tb(n,r)&&!dc(n,r)&&(n.editable||!(r.type in nt))&&t(n,r)},Zy[e]?{passive:!0}:void 0)}et&&n.dom.addEventListener("input",()=>null),Oa(n)}function nn(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function eb(n){n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function Oa(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>dc(n,r))})}function dc(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function tb(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function nb(n,e){!dc(n,e)&&tt[e.type]&&(n.editable||!(e.type in nt))&&tt[e.type](n,e)}nt.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!xm(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(Bt&&Ke&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),ur&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",o=>o(n,Sn(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||qy(n,t)?t.preventDefault():nn(n,"key")};nt.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};nt.keypress=(n,e)=>{let t=e;if(xm(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||yt&&t.metaKey)return;if(n.someProp("handleKeyPress",o=>o(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof Z)||!r.$from.sameParent(r.$to)){let o=String.fromCharCode(t.charCode);!/[\r\n]/.test(o)&&!n.someProp("handleTextInput",i=>i(n,r.$from.pos,r.$to.pos,o))&&n.dispatch(n.state.tr.insertText(o).scrollIntoView()),t.preventDefault()}};function ci(n){return{left:n.clientX,top:n.clientY}}function rb(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function fc(n,e,t,r,o){if(r==-1)return!1;let i=n.state.doc.resolve(r);for(let s=i.depth+1;s>0;s--)if(n.someProp(e,l=>s>i.depth?l(n,t,i.nodeAfter,i.before(s),o,!0):l(n,t,i.node(s),i.before(s),o,!1)))return!0;return!1}function or(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);r.setMeta("pointer",!0),n.dispatch(r)}function ob(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&K.isSelectable(r)?(or(n,new K(t)),!0):!1}function ib(n,e){if(e==-1)return!1;let t=n.state.selection,r,o;t instanceof K&&(r=t.node);let i=n.state.doc.resolve(e);for(let s=i.depth+1;s>0;s--){let l=s>i.depth?i.nodeAfter:i.node(s);if(K.isSelectable(l)){r&&t.$from.depth>0&&s>=t.$from.depth&&i.before(t.$from.depth+1)==t.$from.pos?o=i.before(t.$from.depth):o=i.before(s);break}}return o!=null?(or(n,K.create(n.state.doc,o)),!0):!1}function sb(n,e,t,r,o){return fc(n,"handleClickOn",e,t,r)||n.someProp("handleClick",i=>i(n,e,r))||(o?ib(n,t):ob(n,t))}function lb(n,e,t,r){return fc(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",o=>o(n,e,r))}function ab(n,e,t,r){return fc(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",o=>o(n,e,r))||cb(n,t,r)}function cb(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(or(n,Z.create(r,0,r.content.size)),!0):!1;let o=r.resolve(e);for(let i=o.depth+1;i>0;i--){let s=i>o.depth?o.nodeAfter:o.node(i),l=o.before(i);if(s.inlineContent)or(n,Z.create(r,l+1,l+1+s.content.size));else if(K.isSelectable(s))or(n,K.create(r,l));else continue;return!0}}function hc(n){return Ko(n)}const vm=yt?"metaKey":"ctrlKey";tt.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=hc(n),o=Date.now(),i="singleClick";o-n.input.lastClick.time<500&&rb(t,n.input.lastClick)&&!t[vm]&&(n.input.lastClick.type=="singleClick"?i="doubleClick":n.input.lastClick.type=="doubleClick"&&(i="tripleClick")),n.input.lastClick={time:o,x:t.clientX,y:t.clientY,type:i};let s=n.posAtCoords(ci(t));s&&(i=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new ub(n,s,t,!!r)):(i=="doubleClick"?lb:ab)(n,s.pos,s.inside,t)?t.preventDefault():nn(n,"pointer"))};class ub{constructor(e,t,r,o){this.view=e,this.pos=t,this.event=r,this.flushed=o,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[vm],this.allowDefault=r.shiftKey;let i,s;if(t.inside>-1)i=e.state.doc.nodeAt(t.inside),s=t.inside;else{let u=e.state.doc.resolve(t.pos);i=u.parent,s=u.depth?u.before():0}const l=o?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.dom.nodeType==1?a.dom:null;let{selection:c}=e.state;(r.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof K&&c.from<=s&&c.to>s)&&(this.mightDrag={node:i,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&At&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),nn(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>Ft(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(ci(e))),this.updateAllowDefault(e),this.allowDefault||!t?nn(this.view,"pointer"):sb(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||et&&this.mightDrag&&!this.mightDrag.node.isAtom||Ke&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(or(this.view,te.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):nn(this.view,"pointer")}move(e){this.updateAllowDefault(e),nn(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}tt.touchstart=n=>{n.input.lastTouch=Date.now(),hc(n),nn(n,"pointer")};tt.touchmove=n=>{n.input.lastTouch=Date.now(),nn(n,"pointer")};tt.contextmenu=n=>hc(n);function xm(n,e){return n.composing?!0:et&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const db=Bt?5e3:-1;nt.compositionstart=nt.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof Z&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),Ko(n,!0),n.markCursor=null;else if(Ko(n,!e.selection.empty),At&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let o=r.focusNode,i=r.focusOffset;o&&o.nodeType==1&&i!=0;){let s=i<0?o.lastChild:o.childNodes[i-1];if(!s)break;if(s.nodeType==3){let l=n.domSelection();l&&l.collapse(s,s.nodeValue.length);break}else o=s,i=-1}}n.input.composing=!0}wm(n,db)};nt.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,wm(n,20))};function wm(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>Ko(n),e))}function Sm(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=hb());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function fb(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=oy(e.focusNode,e.focusOffset),r=iy(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let o=r.pmViewDesc,i=n.domObserver.lastChangedTextNode;if(t==i||r==i)return i;if(!o||!o.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let s=t.pmViewDesc;if(!(!s||!s.isText(t.nodeValue)))return r}}return t||r}function hb(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function Ko(n,e=!1){if(!(Bt&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Sm(n),e||n.docView&&n.docView.dirty){let t=ac(n);return t&&!t.eq(n.state.selection)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!n.state.selection.empty?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function pb(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),o=document.createRange();o.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const $r=it&&sn<15||ur&&uy<604;tt.copy=nt.cut=(n,e)=>{let t=e,r=n.state.selection,o=t.type=="cut";if(r.empty)return;let i=$r?null:t.clipboardData,s=r.content(),{dom:l,text:a}=uc(n,s);i?(t.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):pb(n,l),o&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function mb(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function gb(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let o=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?Fr(n,r.value,null,o,e):Fr(n,r.textContent,r.innerHTML,o,e)},50)}function Fr(n,e,t,r,o){let i=hm(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,o,i||$.empty)))return!0;if(!i)return!1;let s=mb(i),l=s?n.state.tr.replaceSelectionWith(s,r):n.state.tr.replaceSelection(i);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Cm(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}nt.paste=(n,e)=>{let t=e;if(n.composing&&!Bt)return;let r=$r?null:t.clipboardData,o=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&Fr(n,Cm(r),r.getData("text/html"),o,t)?t.preventDefault():gb(n,t)};class Tm{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}}const km=yt?"altKey":"ctrlKey";tt.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let o=n.state.selection,i=o.empty?null:n.posAtCoords(ci(t)),s;if(!(i&&i.pos>=o.from&&i.pos<=(o instanceof K?o.to-1:o.to))){if(r&&r.mightDrag)s=K.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let d=n.docView.nearestDesc(t.target,!0);d&&d.node.type.spec.draggable&&d!=n.docView&&(s=K.create(n.state.doc,d.posBefore))}}let l=(s||n.state.selection).content(),{dom:a,text:c,slice:u}=uc(n,l);(!t.dataTransfer.files.length||!Ke||Zp>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData($r?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",$r||t.dataTransfer.setData("text/plain",c),n.dragging=new Tm(u,!t[km],s)};tt.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};nt.dragover=nt.dragenter=(n,e)=>e.preventDefault();nt.drop=(n,e)=>{let t=e,r=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let o=n.posAtCoords(ci(t));if(!o)return;let i=n.state.doc.resolve(o.pos),s=r&&r.slice;s?n.someProp("transformPasted",m=>{s=m(s,n)}):s=hm(n,Cm(t.dataTransfer),$r?null:t.dataTransfer.getData("text/html"),!1,i);let l=!!(r&&!t[km]);if(n.someProp("handleDrop",m=>m(n,t,s||$.empty,l))){t.preventDefault();return}if(!s)return;t.preventDefault();let a=s?Hp(n.state.doc,i.pos,s):i.pos;a==null&&(a=i.pos);let c=n.state.tr;if(l){let{node:m}=r;m?m.replace(c):c.deleteSelection()}let u=c.mapping.map(a),d=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,f=c.doc;if(d?c.replaceRangeWith(u,u,s.content.firstChild):c.replaceRange(u,u,s),c.doc.eq(f))return;let p=c.doc.resolve(u);if(d&&K.isSelectable(s.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(s.content.firstChild))c.setSelection(new K(p));else{let m=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((g,y,b,w)=>m=w),c.setSelection(cc(n,p,c.doc.resolve(m)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))};tt.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&Ft(n)},20))};tt.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)};tt.beforeinput=(n,e)=>{if(Ke&&Bt&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",i=>i(n,Sn(8,"Backspace")))))return;let{$cursor:o}=n.state.selection;o&&o.pos>0&&n.dispatch(n.state.tr.delete(o.pos-1,o.pos).scrollIntoView())},50)}};for(let n in nt)tt[n]=nt[n];function Vr(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}class Jo{constructor(e,t){this.toDOM=e,this.spec=t||On,this.side=this.spec.side||0}map(e,t,r,o){let{pos:i,deleted:s}=e.mapResult(t.from+o,this.side<0?-1:1);return s?null:new Pe(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Jo&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Vr(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class an{constructor(e,t){this.attrs=e,this.spec=t||On}map(e,t,r,o){let i=e.map(t.from+o,this.spec.inclusiveStart?-1:1)-r,s=e.map(t.to+o,this.spec.inclusiveEnd?1:-1)-r;return i>=s?null:new Pe(i,s,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof an&&Vr(this.attrs,e.attrs)&&Vr(this.spec,e.spec)}static is(e){return e.type instanceof an}destroy(){}}class pc{constructor(e,t){this.attrs=e,this.spec=t||On}map(e,t,r,o){let i=e.mapResult(t.from+o,1);if(i.deleted)return null;let s=e.mapResult(t.to+o,-1);return s.deleted||s.pos<=i.pos?null:new Pe(i.pos-r,s.pos-r,this)}valid(e,t){let{index:r,offset:o}=e.content.findIndex(t.from),i;return o==t.from&&!(i=e.child(r)).isText&&o+i.nodeSize==t.to}eq(e){return this==e||e instanceof pc&&Vr(this.attrs,e.attrs)&&Vr(this.spec,e.spec)}destroy(){}}class Pe{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new Pe(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new Pe(e,e,new Jo(t,r))}static inline(e,t,r,o){return new Pe(e,t,new an(r,o))}static node(e,t,r,o){return new Pe(e,t,new pc(r,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof an}get widget(){return this.type instanceof Jo}}const Yn=[],On={};class xe{constructor(e,t){this.local=e.length?e:Yn,this.children=t.length?t:Yn}static create(e,t){return t.length?Xo(t,e,0,On):Ge}find(e,t,r){let o=[];return this.findInner(e??0,t??1e9,o,0,r),o}findInner(e,t,r,o,i){for(let s=0;s<this.local.length;s++){let l=this.local[s];l.from<=t&&l.to>=e&&(!i||i(l.spec))&&r.push(l.copy(l.from+o,l.to+o))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<t&&this.children[s+1]>e){let l=this.children[s]+1;this.children[s+2].findInner(e-l,t-l,r,o+l,i)}}map(e,t,r){return this==Ge||e.maps.length==0?this:this.mapInner(e,t,0,0,r||On)}mapInner(e,t,r,o,i){let s;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,o);a&&a.type.valid(t,a)?(s||(s=[])).push(a):i.onRemove&&i.onRemove(this.local[l].spec)}return this.children.length?yb(this.children,s||[],e,t,r,o,i):s?new xe(s.sort(An),Yn):Ge}add(e,t){return t.length?this==Ge?xe.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let o,i=0;e.forEach((l,a)=>{let c=a+r,u;if(u=Mm(t,l,c)){for(o||(o=this.children.slice());i<o.length&&o[i]<a;)i+=3;o[i]==a?o[i+2]=o[i+2].addInner(l,u,c+1):o.splice(i,0,a,a+l.nodeSize,Xo(u,l,c+1,On)),i+=3}});let s=Em(i?Om(t):t,-r);for(let l=0;l<s.length;l++)s[l].type.valid(e,s[l])||s.splice(l--,1);return new xe(s.length?this.local.concat(s).sort(An):this.local,o||this.children)}remove(e){return e.length==0||this==Ge?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,o=this.local;for(let i=0;i<r.length;i+=3){let s,l=r[i]+t,a=r[i+1]+t;for(let u=0,d;u<e.length;u++)(d=e[u])&&d.from>l&&d.to<a&&(e[u]=null,(s||(s=[])).push(d));if(!s)continue;r==this.children&&(r=this.children.slice());let c=r[i+2].removeInner(s,l+1);c!=Ge?r[i+2]=c:(r.splice(i,3),i-=3)}if(o.length){for(let i=0,s;i<e.length;i++)if(s=e[i])for(let l=0;l<o.length;l++)o[l].eq(s,t)&&(o==this.local&&(o=this.local.slice()),o.splice(l--,1))}return r==this.children&&o==this.local?this:o.length||r.length?new xe(o,r):Ge}forChild(e,t){if(this==Ge)return this;if(t.isLeaf)return xe.empty;let r,o;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,s=i+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<s&&a.to>i&&a.type instanceof an){let c=Math.max(i,a.from)-i,u=Math.min(s,a.to)-i;c<u&&(o||(o=[])).push(a.copy(c,u))}}if(o){let l=new xe(o.sort(An),Yn);return r?new Yt([l,r]):l}return r||Ge}eq(e){if(this==e)return!0;if(!(e instanceof xe)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return mc(this.localsInner(e))}localsInner(e){if(this==Ge)return Yn;if(e.inlineContent||!this.local.some(an.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof an||t.push(this.local[r]);return t}forEachSet(e){e(this)}}xe.empty=new xe([],[]);xe.removeOverlap=mc;const Ge=xe.empty;class Yt{constructor(e){this.members=e}map(e,t){const r=this.members.map(o=>o.map(e,t,On));return Yt.from(r)}forChild(e,t){if(t.isLeaf)return xe.empty;let r=[];for(let o=0;o<this.members.length;o++){let i=this.members[o].forChild(e,t);i!=Ge&&(i instanceof Yt?r=r.concat(i.members):r.push(i))}return Yt.from(r)}eq(e){if(!(e instanceof Yt)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,r=!0;for(let o=0;o<this.members.length;o++){let i=this.members[o].localsInner(e);if(i.length)if(!t)t=i;else{r&&(t=t.slice(),r=!1);for(let s=0;s<i.length;s++)t.push(i[s])}}return t?mc(r?t:t.sort(An)):Yn}static from(e){switch(e.length){case 0:return Ge;case 1:return e[0];default:return new Yt(e.every(t=>t instanceof xe)?e:e.reduce((t,r)=>t.concat(r instanceof xe?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function yb(n,e,t,r,o,i,s){let l=n.slice();for(let c=0,u=i;c<t.maps.length;c++){let d=0;t.maps[c].forEach((f,p,m,g)=>{let y=g-m-(p-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;p>=v?l[b+1]=f<=v?-2:-1:f>=u&&y&&(l[b]+=y,l[b+1]+=y)}d+=y}),u=t.maps[c].map(u,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let u=t.map(n[c]+i),d=u-o;if(d<0||d>=r.content.size){a=!0;continue}let f=t.map(n[c+1]+i,-1),p=f-o,{index:m,offset:g}=r.content.findIndex(d),y=r.maybeChild(m);if(y&&g==d&&g+y.nodeSize==p){let b=l[c+2].mapInner(t,y,u+1,n[c]+i+1,s);b!=Ge?(l[c]=d,l[c+1]=p,l[c+2]=b):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=bb(l,n,e,t,o,i,s),u=Xo(c,r,0,s);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 p=u.children[d];for(;f<l.length&&l[f]<p;)f+=3;l.splice(f,0,u.children[d],u.children[d+1],u.children[d+2])}}return new xe(e.sort(An),l)}function Em(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let o=n[r];t.push(new Pe(o.from+e,o.to+e,o.type))}return t}function bb(n,e,t,r,o,i,s){function l(a,c){for(let u=0;u<a.local.length;u++){let d=a.local[u].map(r,o,c);d?t.push(d):s.onRemove&&s.onRemove(a.local[u].spec)}for(let u=0;u<a.children.length;u+=3)l(a.children[u+2],a.children[u]+c+1)}for(let a=0;a<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+i+1);return t}function Mm(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,o=null;for(let i=0,s;i<n.length;i++)(s=n[i])&&s.from>t&&s.to<r&&((o||(o=[])).push(s),n[i]=null);return o}function Om(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function Xo(n,e,t,r){let o=[],i=!1;e.forEach((l,a)=>{let c=Mm(n,l,a+t);if(c){i=!0;let u=Xo(c,l,t+a+1,r);u!=Ge&&o.push(a,a+l.nodeSize,u)}});let s=Em(i?Om(n):n,-t).sort(An);for(let l=0;l<s.length;l++)s[l].type.valid(e,s[l])||(r.onRemove&&r.onRemove(s[l].spec),s.splice(l--,1));return s.length||o.length?new xe(s,o):Ge}function An(n,e){return n.from-e.from||n.to-e.to}function mc(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let o=t+1;o<e.length;o++){let i=e[o];if(i.from==r.from){i.to!=r.to&&(e==n&&(e=n.slice()),e[o]=i.copy(i.from,r.to),ld(e,o+1,i.copy(r.to,i.to)));continue}else{i.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,i.from),ld(e,o,r.copy(i.from,r.to)));break}}}return e}function ld(n,e,t){for(;e<n.length&&An(t,n[e])>0;)e++;n.splice(e,0,t)}function Zi(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=Ge&&e.push(r)}),n.cursorWrapper&&e.push(xe.create(n.state.doc,[n.cursorWrapper.deco])),Yt.from(e)}const vb={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},xb=it&&sn<=11;class wb{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 Sb{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new wb,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let o=0;o<r.length;o++)this.queue.push(r[o]);it&&sn<=11&&r.some(o=>o.type=="childList"&&o.removedNodes.length||o.type=="characterData"&&o.oldValue.length>o.target.nodeValue.length)?this.flushSoon():this.flush()}),xb&&(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,vb)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(Qu(this.view)){if(this.suppressingSelectionUpdates)return Ft(this.view);if(it&&sn<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&In(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,r;for(let i=e.focusNode;i;i=zr(i))t.add(i);for(let i=e.anchorNode;i;i=zr(i))if(t.has(i)){r=i;break}let o=r&&this.view.docView.nearestDesc(r);if(o&&o.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let r=e.domSelectionRange(),o=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&Qu(e)&&!this.ignoreSelectionChange(r),i=-1,s=-1,l=!1,a=[];if(e.editable)for(let u=0;u<t.length;u++){let d=this.registerMutation(t[u],a);d&&(i=i<0?d.from:Math.min(d.from,i),s=s<0?d.to:Math.max(d.to,s),d.typeOver&&(l=!0))}if(At&&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 p=f.parentNode;p&&p.nodeName=="LI"&&(!d||kb(e,d)!=p)&&f.remove()}}}let c=null;i<0&&o&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&li(r)&&(c=ac(e))&&c.eq(te.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Ft(e),this.currentSelection.set(r)):(i>-1||o)&&(i>-1&&(e.docView.markDirty(i,s),Cb(e)),this.handleDOMChange(i,s,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Ft(e),this.currentSelection.set(r))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let u=0;u<e.addedNodes.length;u++){let d=e.addedNodes[u];t.push(d),d.nodeType==3&&(this.lastChangedTextNode=d)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let o=e.previousSibling,i=e.nextSibling;if(it&&sn<=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)&&(o=d),(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(i=f)}let s=o&&o.parentNode==e.target?qe(o)+1:0,l=r.localPosFromDOM(e.target,s,-1),a=i&&i.parentNode==e.target?qe(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 ad=new WeakMap,cd=!1;function Cb(n){if(!ad.has(n)&&(ad.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=At,cd)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."),cd=!0}}function ud(n,e){let t=e.startContainer,r=e.startOffset,o=e.endContainer,i=e.endOffset,s=n.domAtPos(n.state.selection.anchor);return In(s.node,s.offset,o,i)&&([t,r,o,i]=[o,i,t,r]),{anchorNode:t,anchorOffset:r,focusNode:o,focusOffset:i}}function Tb(n,e){if(e.getComposedRanges){let o=e.getComposedRanges(n.root)[0];if(o)return ud(n,o)}let t;function r(o){o.preventDefault(),o.stopImmediatePropagation(),t=o.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",r,!0),t?ud(n,t):null}function kb(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let r=n.docView.nearestDesc(t,!0);if(r&&r.node.isBlock)return t}return null}function Eb(n,e,t){let{node:r,fromOffset:o,toOffset:i,from:s,to:l}=n.docView.parseRange(e,t),a=n.domSelectionRange(),c,u=a.anchorNode;if(u&&n.dom.contains(u.nodeType==1?u:u.parentNode)&&(c=[{node:u,offset:a.anchorOffset}],li(a)||c.push({node:a.focusNode,offset:a.focusOffset})),Ke&&n.input.lastKeyCode===8)for(let y=i;y>o;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=n.state.doc,f=n.someProp("domParser")||on.fromSchema(n.state.schema),p=d.resolve(s),m=null,g=f.parse(r,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:o,to:i,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:Mb,context:p});if(c&&c[0].pos!=null){let y=c[0].pos,b=c[1]&&c[1].pos;b==null&&(b=y),m={anchor:y+s,head:b+s}}return{doc:g,sel:m,from:s,to:l}}function Mb(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(et&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(n.parentNode.lastChild==n||et&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}const Ob=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Ab(n,e,t,r,o){let i=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let E=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,R=ac(n,E);if(R&&!n.state.selection.eq(R)){if(Ke&&Bt&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",N=>N(n,Sn(13,"Enter"))))return;let _=n.state.tr.setSelection(R);E=="pointer"?_.setMeta("pointer",!0):E=="key"&&_.scrollIntoView(),i&&_.setMeta("composition",i),n.dispatch(_)}return}let s=n.state.doc.resolve(e),l=s.sharedDepth(t);e=s.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,c=Eb(n,e,t),u=n.state.doc,d=u.slice(c.from,c.to),f,p;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(f=n.state.selection.to,p="end"):(f=n.state.selection.from,p="start"),n.input.lastKeyCode=null;let m=Ib(d.content,c.doc.content,c.from,f,p);if(m&&n.input.domChangeCount++,(ur&&n.input.lastIOSEnter>Date.now()-225||Bt)&&o.some(E=>E.nodeType==1&&!Ob.test(E.nodeName))&&(!m||m.endA>=m.endB)&&n.someProp("handleKeyDown",E=>E(n,Sn(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!m)if(r&&a instanceof Z&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))m={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let E=dd(n,n.state.doc,c.sel);if(E&&!E.eq(n.state.selection)){let R=n.state.tr.setSelection(E);i&&R.setMeta("composition",i),n.dispatch(R)}}return}n.state.selection.from<n.state.selection.to&&m.start==m.endB&&n.state.selection instanceof Z&&(m.start>n.state.selection.from&&m.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?m.start=n.state.selection.from:m.endA<n.state.selection.to&&m.endA>=n.state.selection.to-2&&n.state.selection.to<=c.to&&(m.endB+=n.state.selection.to-m.endA,m.endA=n.state.selection.to)),it&&sn<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>c.from&&c.doc.textBetween(m.start-c.from-1,m.start-c.from+1)=="  "&&(m.start--,m.endA--,m.endB--);let g=c.doc.resolveNoCache(m.start-c.from),y=c.doc.resolveNoCache(m.endB-c.from),b=u.resolve(m.start),w=g.sameParent(y)&&g.parent.inlineContent&&b.end()>=m.endA,v;if((ur&&n.input.lastIOSEnter>Date.now()-225&&(!w||o.some(E=>E.nodeName=="DIV"||E.nodeName=="P"))||!w&&g.pos<c.doc.content.size&&!g.sameParent(y)&&(v=te.findFrom(c.doc.resolve(g.pos+1),1,!0))&&v.head==y.pos)&&n.someProp("handleKeyDown",E=>E(n,Sn(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>m.start&&Rb(u,m.start,m.endA,g,y)&&n.someProp("handleKeyDown",E=>E(n,Sn(8,"Backspace")))){Bt&&Ke&&n.domObserver.suppressSelectionUpdates();return}Ke&&m.endB==m.start&&(n.input.lastChromeDelete=Date.now()),Bt&&!w&&g.start()!=y.start()&&y.parentOffset==0&&g.depth==y.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==m.endA&&(m.endB-=2,y=c.doc.resolveNoCache(m.endB-c.from),setTimeout(()=>{n.someProp("handleKeyDown",function(E){return E(n,Sn(13,"Enter"))})},20));let S=m.start,T=m.endA,C,I,O;if(w){if(g.pos==y.pos)it&&sn<=11&&g.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>Ft(n),20)),C=n.state.tr.delete(S,T),I=u.resolve(m.start).marksAcross(u.resolve(m.endA));else if(m.endA==m.endB&&(O=Nb(g.parent.content.cut(g.parentOffset,y.parentOffset),b.parent.content.cut(b.parentOffset,m.endA-b.start()))))C=n.state.tr,O.type=="add"?C.addMark(S,T,O.mark):C.removeMark(S,T,O.mark);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);if(n.someProp("handleTextInput",R=>R(n,S,T,E)))return;C=n.state.tr.insertText(E,S,T)}}if(C||(C=n.state.tr.replace(S,T,c.doc.slice(m.start-c.from,m.endB-c.from))),c.sel){let E=dd(n,C.doc,c.sel);E&&!(Ke&&n.composing&&E.empty&&(m.start!=m.endB||n.input.lastChromeDelete<Date.now()-100)&&(E.head==S||E.head==C.mapping.map(T)-1)||it&&E.empty&&E.head==S)&&C.setSelection(E)}I&&C.ensureMarks(I),i&&C.setMeta("composition",i),n.dispatch(C.scrollIntoView())}function dd(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:cc(n,e.resolve(t.anchor),e.resolve(t.head))}function Nb(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,o=t,i=r,s,l,a;for(let u=0;u<r.length;u++)o=r[u].removeFromSet(o);for(let u=0;u<t.length;u++)i=t[u].removeFromSet(i);if(o.length==1&&i.length==0)l=o[0],s="add",a=u=>u.mark(l.addToSet(u.marks));else if(o.length==0&&i.length==1)l=i[0],s="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(n))return{mark:l,type:s}}function Rb(n,e,t,r,o){if(t-e<=o.pos-r.pos||Yi(r,!0,!1)<o.pos)return!1;let i=n.resolve(e);if(!r.parent.isTextblock){let l=i.nodeAfter;return l!=null&&t==e+l.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let s=n.resolve(Yi(i,!0,!0));return!s.parent.isTextblock||s.pos>t||Yi(s,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(s.parent.content)}function Yi(n,e,t){let r=n.depth,o=e?n.end():n.pos;for(;r>0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,o++,e=!1;if(t){let i=n.node(r).maybeChild(n.indexAfter(r));for(;i&&!i.isLeaf;)i=i.firstChild,o++}return o}function Ib(n,e,t,r,o){let i=n.findDiffStart(e,t);if(i==null)return null;let{a:s,b:l}=n.findDiffEnd(e,t+n.size,t+e.size);if(o=="end"){let a=Math.max(0,i-Math.min(s,l));r-=s+a-i}if(s<i&&n.size<e.size){let a=r<=i&&r>=s?i-r:0;i-=a,i&&i<e.size&&fd(e.textBetween(i-1,i+1))&&(i+=a?1:-1),l=i+(l-s),s=i}else if(l<i){let a=r<=i&&r>=l?i-r:0;i-=a,i&&i<n.size&&fd(n.textBetween(i-1,i+1))&&(i+=a?1:-1),s=i+(s-l),l=i}return{start:i,endA:s,endB:l}}function fd(n){if(n.length!=2)return!1;let e=n.charCodeAt(0),t=n.charCodeAt(1);return e>=56320&&e<=57343&&t>=55296&&t<=56319}class _b{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new Yy,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(yd),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=md(this),pd(this),this.nodeViews=gd(this),this.docView=Gu(this.state.doc,hd(this),Zi(this),this.dom,this),this.domObserver=new Sb(this,(r,o,i,s)=>Ab(this,r,o,i,s)),this.domObserver.start(),Qy(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Oa(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(yd),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let o=this.state,i=!1,s=!1;e.storedMarks&&this.composing&&(Sm(this),s=!0),this.state=e;let l=o.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let p=gd(this);jb(p,this.nodeViews)&&(this.nodeViews=p,i=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&Oa(this),this.editable=md(this),pd(this);let a=Zi(this),c=hd(this),u=o.plugins!=e.plugins&&!o.doc.eq(e.doc)?"reset":e.scrollToSelection>o.scrollToSelection?"to selection":"preserve",d=i||!this.docView.matchesNode(e.doc,c,a);(d||!e.selection.eq(o.selection))&&(s=!0);let f=u=="preserve"&&s&&this.dom.style.overflowAnchor==null&&hy(this);if(s){this.domObserver.stop();let p=d&&(it||Ke)&&!this.composing&&!o.selection.empty&&!e.selection.empty&&Db(o.selection,e.selection);if(d){let m=Ke?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=fb(this)),(i||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Gu(e.doc,c,a,this.dom,this)),m&&!this.trackWrites&&(p=!0)}p||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Ly(this))?Ft(this,p):(um(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(o),!((r=this.dragging)===null||r===void 0)&&r.node&&!o.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,o),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():f&&py(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof K){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Fu(this,t.getBoundingClientRect(),e)}else Fu(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let r=this.directPlugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let r=this.state.plugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let r=this.pluginViews[t];r.update&&r.update(this,e)}}updateDraggedNode(e,t){let r=e.node,o=-1;if(this.state.doc.nodeAt(r.from)==r.node)o=r.from;else{let i=r.from+(this.state.doc.content.size-t.doc.content.size);(i>0&&this.state.doc.nodeAt(i))==r.node&&(o=i)}this.dragging=new Tm(e.slice,e.move,o<0?void 0:K.create(this.state.doc,o))}someProp(e,t){let r=this._props&&this._props[e],o;if(r!=null&&(o=t?t(r):r))return o;for(let s=0;s<this.directPlugins.length;s++){let l=this.directPlugins[s].props[e];if(l!=null&&(o=t?t(l):l))return o}let i=this.state.plugins;if(i)for(let s=0;s<i.length;s++){let l=i[s].props[e];if(l!=null&&(o=t?t(l):l))return o}}hasFocus(){if(it){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&&my(this.dom),Ft(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return xy(this,e)}coordsAtPos(e,t=1){return nm(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,r=-1){let o=this.docView.posFromDOM(e,t,r);if(o==null)throw new RangeError("DOM position not inside the editor");return o}endOfTextblock(e,t){return ky(this,t||this.state,e)}pasteHTML(e,t){return Fr(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Fr(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return uc(this,e)}destroy(){this.docView&&(eb(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Zi(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,ny())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return nb(this,e)}dispatch(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))}domSelectionRange(){let e=this.domSelection();return e?et&&this.root.nodeType===11&&ly(this.dom.ownerDocument)==this.dom&&Tb(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function hd(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[Pe.node(0,n.state.doc.content.size,e)]}function pd(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:Pe.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function md(n){return!n.someProp("editable",e=>e(n.state)===!1)}function Db(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function gd(n){let e=Object.create(null);function t(r){for(let o in r)Object.prototype.hasOwnProperty.call(e,o)||(e[o]=r[o])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function jb(n,e){let t=0,r=0;for(let o in n){if(n[o]!=e[o])return!0;t++}for(let o in e)r++;return t!=r}function yd(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var un={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:"'"},Zo={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Pb=typeof navigator<"u"&&/Mac/.test(navigator.platform),Lb=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var We=0;We<10;We++)un[48+We]=un[96+We]=String(We);for(var We=1;We<=24;We++)un[We+111]="F"+We;for(var We=65;We<=90;We++)un[We]=String.fromCharCode(We+32),Zo[We]=String.fromCharCode(We);for(var Qi in un)Zo.hasOwnProperty(Qi)||(Zo[Qi]=un[Qi]);function Bb(n){var e=Pb&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||Lb&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Zo:un)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}const zb=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function $b(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,o,i,s;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))s=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))o=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))zb?s=!0:o=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(t="Alt-"+t),o&&(t="Ctrl-"+t),s&&(t="Meta-"+t),i&&(t="Shift-"+t),t}function Fb(n){let e=Object.create(null);for(let t in n)e[$b(t)]=n[t];return e}function es(n,e,t=!0){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t&&e.shiftKey&&(n="Shift-"+n),n}function Vb(n){return new $e({props:{handleKeyDown:gc(n)}})}function gc(n){let e=Fb(n);return function(t,r){let o=Bb(r),i,s=e[es(o,r)];if(s&&s(t.state,t.dispatch,t))return!0;if(o.length==1&&o!=" "){if(r.shiftKey){let l=e[es(o,r,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((r.shiftKey||r.altKey||r.metaKey||o.charCodeAt(0)>127)&&(i=un[r.keyCode])&&i!=o){let l=e[es(i,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}const Am=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function Nm(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const Hb=(n,e,t)=>{let r=Nm(n,t);if(!r)return!1;let o=yc(r);if(!o){let s=r.blockRange(),l=s&&fr(s);return l==null?!1:(e&&e(n.tr.lift(s,l).scrollIntoView()),!0)}let i=o.nodeBefore;if(Dm(n,o,e,-1))return!0;if(r.parent.content.size==0&&(dr(i,"end")||K.isSelectable(i)))for(let s=r.depth;;s--){let l=ii(n.doc,r.before(s),r.after(s),$.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=n.tr.step(l);a.setSelection(dr(i,"end")?te.findFrom(a.doc.resolve(a.mapping.map(o.pos,-1)),-1):K.create(a.doc,o.pos-i.nodeSize)),e(a.scrollIntoView())}return!0}if(s==1||r.node(s-1).childCount>1)break}return i.isAtom&&o.depth==r.depth-1?(e&&e(n.tr.delete(o.pos-i.nodeSize,o.pos).scrollIntoView()),!0):!1},qb=(n,e,t)=>{let r=Nm(n,t);if(!r)return!1;let o=yc(r);return o?Rm(n,o,e):!1},Wb=(n,e,t)=>{let r=Im(n,t);if(!r)return!1;let o=bc(r);return o?Rm(n,o,e):!1};function Rm(n,e,t){let r=e.nodeBefore,o=r,i=e.pos-1;for(;!o.isTextblock;i--){if(o.type.spec.isolating)return!1;let u=o.lastChild;if(!u)return!1;o=u}let s=e.nodeAfter,l=s,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=ii(n.doc,i,a,$.empty);if(!c||c.from!=i||c instanceof je&&c.slice.size>=a-i)return!1;if(t){let u=n.tr.step(c);u.setSelection(Z.create(u.doc,i)),t(u.scrollIntoView())}return!0}function dr(n,e,t=!1){for(let r=n;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(t&&r.childCount!=1)return!1}return!1}const Ub=(n,e,t)=>{let{$head:r,empty:o}=n.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;i=yc(r)}let s=i&&i.nodeBefore;return!s||!K.isSelectable(s)?!1:(e&&e(n.tr.setSelection(K.create(n.doc,i.pos-s.nodeSize)).scrollIntoView()),!0)};function yc(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function Im(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const Gb=(n,e,t)=>{let r=Im(n,t);if(!r)return!1;let o=bc(r);if(!o)return!1;let i=o.nodeAfter;if(Dm(n,o,e,1))return!0;if(r.parent.content.size==0&&(dr(i,"start")||K.isSelectable(i))){let s=ii(n.doc,r.before(),r.after(),$.empty);if(s&&s.slice.size<s.to-s.from){if(e){let l=n.tr.step(s);l.setSelection(dr(i,"start")?te.findFrom(l.doc.resolve(l.mapping.map(o.pos)),1):K.create(l.doc,l.mapping.map(o.pos))),e(l.scrollIntoView())}return!0}}return i.isAtom&&o.depth==r.depth-1?(e&&e(n.tr.delete(o.pos,o.pos+i.nodeSize).scrollIntoView()),!0):!1},Kb=(n,e,t)=>{let{$head:r,empty:o}=n.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset<r.parent.content.size)return!1;i=bc(r)}let s=i&&i.nodeAfter;return!s||!K.isSelectable(s)?!1:(e&&e(n.tr.setSelection(K.create(n.doc,i.pos)).scrollIntoView()),!0)};function bc(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){let t=n.node(e);if(n.index(e)+1<t.childCount)return n.doc.resolve(n.after(e+1));if(t.type.spec.isolating)break}return null}const Jb=(n,e)=>{let t=n.selection,r=t instanceof K,o;if(r){if(t.node.isTextblock||!hn(n.doc,t.from))return!1;o=t.from}else if(o=oi(n.doc,t.from,-1),o==null)return!1;if(e){let i=n.tr.join(o);r&&i.setSelection(K.create(i.doc,o-n.doc.resolve(o).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},Xb=(n,e)=>{let t=n.selection,r;if(t instanceof K){if(t.node.isTextblock||!hn(n.doc,t.to))return!1;r=t.to}else if(r=oi(n.doc,t.to,1),r==null)return!1;return e&&e(n.tr.join(r).scrollIntoView()),!0},Zb=(n,e)=>{let{$from:t,$to:r}=n.selection,o=t.blockRange(r),i=o&&fr(o);return i==null?!1:(e&&e(n.tr.lift(o,i).scrollIntoView()),!0)},Yb=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(`
10
+ `).scrollIntoView()),!0)};function _m(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}const Qb=(n,e)=>{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let o=t.node(-1),i=t.indexAfter(-1),s=_m(o.contentMatchAt(i));if(!s||!o.canReplaceWith(i,i,s))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,s.createAndFill());a.setSelection(te.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},ev=(n,e)=>{let t=n.selection,{$from:r,$to:o}=t;if(t instanceof ot||r.parent.inlineContent||o.parent.inlineContent)return!1;let i=_m(o.parent.contentMatchAt(o.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let s=(!r.parentOffset&&o.index()<o.parent.childCount?r:o).pos,l=n.tr.insert(s,i.createAndFill());l.setSelection(Z.create(l.doc,s+1)),e(l.scrollIntoView())}return!0},tv=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let i=t.before();if(nr(n.doc,i))return e&&e(n.tr.split(i).scrollIntoView()),!0}let r=t.blockRange(),o=r&&fr(r);return o==null?!1:(e&&e(n.tr.lift(r,o).scrollIntoView()),!0)},nv=(n,e)=>{let{$from:t,to:r}=n.selection,o,i=t.sharedDepth(r);return i==0?!1:(o=t.before(i),e&&e(n.tr.setSelection(K.create(n.doc,o))),!0)};function rv(n,e,t){let r=e.nodeBefore,o=e.nodeAfter,i=e.index();return!r||!o||!r.type.compatibleContent(o.type)?!1:!r.content.size&&e.parent.canReplace(i-1,i)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(o.isTextblock||hn(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function Dm(n,e,t,r){let o=e.nodeBefore,i=e.nodeAfter,s,l,a=o.type.spec.isolating||i.type.spec.isolating;if(!a&&rv(n,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(s=(l=o.contentMatchAt(o.childCount)).findWrapping(i.type))&&l.matchType(s[0]||i.type).validEnd){if(t){let p=e.pos+i.nodeSize,m=j.empty;for(let b=s.length-1;b>=0;b--)m=j.from(s[b].create(null,m));m=j.from(o.copy(m));let g=n.tr.step(new Le(e.pos-1,p,e.pos,p,new $(m,1,0),s.length,!0)),y=g.doc.resolve(p+2*s.length);y.nodeAfter&&y.nodeAfter.type==o.type&&hn(g.doc,y.pos)&&g.join(y.pos),t(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&&fr(d);if(f!=null&&f>=e.depth)return t&&t(n.tr.lift(d,f).scrollIntoView()),!0;if(c&&dr(i,"start",!0)&&dr(o,"end")){let p=o,m=[];for(;m.push(p),!p.isTextblock;)p=p.lastChild;let g=i,y=1;for(;!g.isTextblock;g=g.firstChild)y++;if(p.canReplace(p.childCount,p.childCount,g.content)){if(t){let b=j.empty;for(let v=m.length-1;v>=0;v--)b=j.from(m[v].copy(b));let w=n.tr.step(new Le(e.pos-m.length,e.pos+i.nodeSize,e.pos+y,e.pos+i.nodeSize-y,new $(b,m.length,0),0,!0));t(w.scrollIntoView())}return!0}}return!1}function jm(n){return function(e,t){let r=e.selection,o=n<0?r.$from:r.$to,i=o.depth;for(;o.node(i).isInline;){if(!i)return!1;i--}return o.node(i).isTextblock?(t&&t(e.tr.setSelection(Z.create(e.doc,n<0?o.start(i):o.end(i)))),!0):!1}}const ov=jm(-1),iv=jm(1);function sv(n,e=null){return function(t,r){let{$from:o,$to:i}=t.selection,s=o.blockRange(i),l=s&&rc(s,n,e);return l?(r&&r(t.tr.wrap(s,l).scrollIntoView()),!0):!1}}function bd(n,e=null){return function(t,r){let o=!1;for(let i=0;i<t.selection.ranges.length&&!o;i++){let{$from:{pos:s},$to:{pos:l}}=t.selection.ranges[i];t.doc.nodesBetween(s,l,(a,c)=>{if(o)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)o=!0;else{let u=t.doc.resolve(c),d=u.index();o=u.parent.canReplaceWith(d,d+1,n)}})}if(!o)return!1;if(r){let i=t.tr;for(let s=0;s<t.selection.ranges.length;s++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[s];i.setBlockType(l,a,n,e)}r(i.scrollIntoView())}return!0}}typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function lv(n,e=null){return function(t,r){let{$from:o,$to:i}=t.selection,s=o.blockRange(i);if(!s)return!1;let l=r?t.tr:null;return av(l,s,n,e)?(r&&r(l.scrollIntoView()),!0):!1}}function av(n,e,t,r=null){let o=!1,i=e,s=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(t)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=s.resolve(e.start-2);i=new Pr(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new Pr(e.$from,s.resolve(e.$to.end(e.depth)),e.depth)),o=!0}let l=rc(i,t,r,e);return l?(n&&cv(n,e,l,o,t),!0):!1}function cv(n,e,t,r,o){let i=j.empty;for(let u=t.length-1;u>=0;u--)i=j.from(t[u].type.create(t[u].attrs,i));n.step(new Le(e.start-(r?2:0),e.end,e.start,e.end,new $(i,0,0),t.length,!0));let s=0;for(let u=0;u<t.length;u++)t[u].type==o&&(s=u+1);let l=t.length-s,a=e.start+t.length-(r?2:0),c=e.parent;for(let u=e.startIndex,d=e.endIndex,f=!0;u<d;u++,f=!1)!f&&nr(n.doc,a,l)&&(n.split(a,l),a+=2*l),a+=c.child(u).nodeSize;return n}function uv(n){return function(e,t){let{$from:r,$to:o}=e.selection,i=r.blockRange(o,s=>s.childCount>0&&s.firstChild.type==n);return i?t?r.node(i.depth-1).type==n?dv(e,t,n,i):fv(e,t,i):!0:!1}}function dv(n,e,t,r){let o=n.tr,i=r.end,s=r.$to.end(r.depth);i<s&&(o.step(new Le(i-1,s,i,s,new $(j.from(t.create(null,r.parent.copy())),1,0),1,!0)),r=new Pr(o.doc.resolve(r.$from.pos),o.doc.resolve(s),r.depth));const l=fr(r);if(l==null)return!1;o.lift(r,l);let a=o.mapping.map(i,-1)-1;return hn(o.doc,a)&&o.join(a),e(o.scrollIntoView()),!0}function fv(n,e,t){let r=n.tr,o=t.parent;for(let p=t.end,m=t.endIndex-1,g=t.startIndex;m>g;m--)p-=o.child(m).nodeSize,r.delete(p-1,p+1);let i=r.doc.resolve(t.start),s=i.nodeAfter;if(r.mapping.map(t.end)!=t.start+i.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==o.childCount,c=i.node(-1),u=i.index(-1);if(!c.canReplace(u+(l?0:1),u+1,s.content.append(a?j.empty:j.from(o))))return!1;let d=i.pos,f=d+s.nodeSize;return r.step(new Le(d-(l?1:0),f+(a?1:0),d+1,f-1,new $((l?j.empty:j.from(o.copy(j.empty))).append(a?j.empty:j.from(o.copy(j.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function hv(n){return function(e,t){let{$from:r,$to:o}=e.selection,i=r.blockRange(o,c=>c.childCount>0&&c.firstChild.type==n);if(!i)return!1;let s=i.startIndex;if(s==0)return!1;let l=i.parent,a=l.child(s-1);if(a.type!=n)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,u=j.from(c?n.create():null),d=new $(j.from(n.create(null,j.from(l.type.create(null,u)))),c?3:1,0),f=i.start,p=i.end;t(e.tr.step(new Le(f-(c?3:1),p,f,p,d,1,!0)).scrollIntoView())}return!0}}function ui(n){const{state:e,transaction:t}=n;let{selection:r}=t,{doc:o}=t,{storedMarks:i}=t;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return i},get selection(){return r},get doc(){return o},get tr(){return r=t.selection,o=t.doc,i=t.storedMarks,t}}}class di{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:e,editor:t,state:r}=this,{view:o}=t,{tr:i}=r,s=this.buildProps(i);return Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...u)=>{const d=a(...u)(s);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&o.dispatch(i),d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){const{rawCommands:r,editor:o,state:i}=this,{view:s}=o,l=[],a=!!e,c=e||i.tr,u=()=>(!a&&t&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(c),l.every(f=>f===!0)),d={...Object.fromEntries(Object.entries(r).map(([f,p])=>[f,(...g)=>{const y=this.buildProps(c,t),b=p(...g)(y);return l.push(b),d}])),run:u};return d}createCan(e){const{rawCommands:t,state:r}=this,o=!1,i=e||r.tr,s=this.buildProps(i,o);return{...Object.fromEntries(Object.entries(t).map(([a,c])=>[a,(...u)=>c(...u)({...s,dispatch:void 0})])),chain:()=>this.createChain(i,o)}}buildProps(e,t=!0){const{rawCommands:r,editor:o,state:i}=this,{view:s}=o,l={tr:e,editor:o,view:s,state:ui({state:i,transaction:e}),dispatch:t?()=>{}:void 0,chain:()=>this.createChain(e,t),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(r).map(([a,c])=>[a,(...u)=>c(...u)(l)]))}};return l}}class pv{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){const r=this.callbacks[e];return r&&r.forEach(o=>o.apply(this,t)),this}off(e,t){const r=this.callbacks[e];return r&&(t?this.callbacks[e]=r.filter(o=>o!==t):delete this.callbacks[e]),this}once(e,t){const r=(...o)=>{this.off(e,r),t.apply(this,o)};return this.on(e,r)}removeAllListeners(){this.callbacks={}}}function H(n,e,t){return n.config[e]===void 0&&n.parent?H(n.parent,e,t):typeof n.config[e]=="function"?n.config[e].bind({...t,parent:n.parent?H(n.parent,e,t):null}):n.config[e]}function fi(n){const e=n.filter(o=>o.type==="extension"),t=n.filter(o=>o.type==="node"),r=n.filter(o=>o.type==="mark");return{baseExtensions:e,nodeExtensions:t,markExtensions:r}}function Pm(n){const e=[],{nodeExtensions:t,markExtensions:r}=fi(n),o=[...t,...r],i={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return n.forEach(s=>{const l={name:s.name,options:s.options,storage:s.storage,extensions:o},a=H(s,"addGlobalAttributes",l);if(!a)return;a().forEach(u=>{u.types.forEach(d=>{Object.entries(u.attributes).forEach(([f,p])=>{e.push({type:d,name:f,attribute:{...i,...p}})})})})}),o.forEach(s=>{const l={name:s.name,options:s.options,storage:s.storage},a=H(s,"addAttributes",l);if(!a)return;const c=a();Object.entries(c).forEach(([u,d])=>{const f={...i,...d};typeof(f==null?void 0:f.default)=="function"&&(f.default=f.default()),f!=null&&f.isRequired&&(f==null?void 0:f.default)===void 0&&delete f.default,e.push({type:s.name,name:u,attribute:f})})}),e}function ze(n,e){if(typeof n=="string"){if(!e.nodes[n])throw Error(`There is no node type named '${n}'. Maybe you forgot to add the extension?`);return e.nodes[n]}return n}function Ue(...n){return n.filter(e=>!!e).reduce((e,t)=>{const r={...e};return Object.entries(t).forEach(([o,i])=>{if(!r[o]){r[o]=i;return}if(o==="class"){const l=i?String(i).split(" "):[],a=r[o]?r[o].split(" "):[],c=l.filter(u=>!a.includes(u));r[o]=[...a,...c].join(" ")}else if(o==="style"){const l=i?i.split(";").map(u=>u.trim()).filter(Boolean):[],a=r[o]?r[o].split(";").map(u=>u.trim()).filter(Boolean):[],c=new Map;a.forEach(u=>{const[d,f]=u.split(":").map(p=>p.trim());c.set(d,f)}),l.forEach(u=>{const[d,f]=u.split(":").map(p=>p.trim());c.set(d,f)}),r[o]=Array.from(c.entries()).map(([u,d])=>`${u}: ${d}`).join("; ")}else r[o]=i}),r},{})}function Yo(n,e){return e.filter(t=>t.type===n.type.name).filter(t=>t.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(n.attrs)||{}:{[t.name]:n.attrs[t.name]}).reduce((t,r)=>Ue(t,r),{})}function Lm(n){return typeof n=="function"}function le(n,e=void 0,...t){return Lm(n)?e?n.bind(e)(...t):n(...t):n}function mv(n={}){return Object.keys(n).length===0&&n.constructor===Object}function gv(n){return typeof n!="string"?n:n.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(n):n==="true"?!0:n==="false"?!1:n}function vd(n,e){return"style"in n?n:{...n,getAttrs:t=>{const r=n.getAttrs?n.getAttrs(t):n.attrs;if(r===!1)return!1;const o=e.reduce((i,s)=>{const l=s.attribute.parseHTML?s.attribute.parseHTML(t):gv(t.getAttribute(s.name));return l==null?i:{...i,[s.name]:l}},{});return{...r,...o}}}}function xd(n){return Object.fromEntries(Object.entries(n).filter(([e,t])=>e==="attrs"&&mv(t)?!1:t!=null))}function yv(n,e){var t;const r=Pm(n),{nodeExtensions:o,markExtensions:i}=fi(n),s=(t=o.find(c=>H(c,"topNode")))===null||t===void 0?void 0:t.name,l=Object.fromEntries(o.map(c=>{const u=r.filter(b=>b.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:e},f=n.reduce((b,w)=>{const v=H(w,"extendNodeSchema",d);return{...b,...v?v(c):{}}},{}),p=xd({...f,content:le(H(c,"content",d)),marks:le(H(c,"marks",d)),group:le(H(c,"group",d)),inline:le(H(c,"inline",d)),atom:le(H(c,"atom",d)),selectable:le(H(c,"selectable",d)),draggable:le(H(c,"draggable",d)),code:le(H(c,"code",d)),whitespace:le(H(c,"whitespace",d)),linebreakReplacement:le(H(c,"linebreakReplacement",d)),defining:le(H(c,"defining",d)),isolating:le(H(c,"isolating",d)),attrs:Object.fromEntries(u.map(b=>{var w;return[b.name,{default:(w=b==null?void 0:b.attribute)===null||w===void 0?void 0:w.default}]}))}),m=le(H(c,"parseHTML",d));m&&(p.parseDOM=m.map(b=>vd(b,u)));const g=H(c,"renderHTML",d);g&&(p.toDOM=b=>g({node:b,HTMLAttributes:Yo(b,u)}));const y=H(c,"renderText",d);return y&&(p.toText=y),[c.name,p]})),a=Object.fromEntries(i.map(c=>{const u=r.filter(y=>y.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:e},f=n.reduce((y,b)=>{const w=H(b,"extendMarkSchema",d);return{...y,...w?w(c):{}}},{}),p=xd({...f,inclusive:le(H(c,"inclusive",d)),excludes:le(H(c,"excludes",d)),group:le(H(c,"group",d)),spanning:le(H(c,"spanning",d)),code:le(H(c,"code",d)),attrs:Object.fromEntries(u.map(y=>{var b;return[y.name,{default:(b=y==null?void 0:y.attribute)===null||b===void 0?void 0:b.default}]}))}),m=le(H(c,"parseHTML",d));m&&(p.parseDOM=m.map(y=>vd(y,u)));const g=H(c,"renderHTML",d);return g&&(p.toDOM=y=>g({mark:y,HTMLAttributes:Yo(y,u)})),[c.name,p]}));return new Ip({topNode:s,nodes:l,marks:a})}function ts(n,e){return e.nodes[n]||e.marks[n]||null}function wd(n,e){return Array.isArray(e)?e.some(t=>(typeof t=="string"?t:t.name)===n.name):e}function vc(n,e){const t=Ln.fromSchema(e).serializeFragment(n),o=document.implementation.createHTMLDocument().createElement("div");return o.appendChild(t),o.innerHTML}const bv=(n,e=500)=>{let t="";const r=n.parentOffset;return n.parent.nodesBetween(Math.max(0,r-e),r,(o,i,s,l)=>{var a,c;const u=((c=(a=o.type.spec).toText)===null||c===void 0?void 0:c.call(a,{node:o,pos:i,parent:s,index:l}))||o.textContent||"%leaf%";t+=o.isAtom&&!o.isText?u:u.slice(0,Math.max(0,r-i))}),t};function xc(n){return Object.prototype.toString.call(n)==="[object RegExp]"}class hi{constructor(e){this.find=e.find,this.handler=e.handler}}const vv=(n,e)=>{if(xc(e))return e.exec(n);const t=e(n);if(!t)return null;const r=[t.text];return r.index=t.index,r.input=n,r.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(t.replaceWith)),r};function ho(n){var e;const{editor:t,from:r,to:o,text:i,rules:s,plugin:l}=n,{view:a}=t;if(a.composing)return!1;const c=a.state.doc.resolve(r);if(c.parent.type.spec.code||!((e=c.nodeBefore||c.nodeAfter)===null||e===void 0)&&e.marks.find(f=>f.type.spec.code))return!1;let u=!1;const d=bv(c)+i;return s.forEach(f=>{if(u)return;const p=vv(d,f.find);if(!p)return;const m=a.state.tr,g=ui({state:a.state,transaction:m}),y={from:r-(p[0].length-i.length),to:o},{commands:b,chain:w,can:v}=new di({editor:t,state:g});f.handler({state:g,range:y,match:p,commands:b,chain:w,can:v})===null||!m.steps.length||(m.setMeta(l,{transform:m,from:r,to:o,text:i}),a.dispatch(m),u=!0)}),u}function xv(n){const{editor:e,rules:t}=n,r=new $e({state:{init(){return null},apply(o,i,s){const l=o.getMeta(r);if(l)return l;const a=o.getMeta("applyInputRules");return!!a&&setTimeout(()=>{let{text:u}=a;typeof u=="string"?u=u:u=vc(j.from(u),s.schema);const{from:d}=a,f=d+u.length;ho({editor:e,from:d,to:f,text:u,rules:t,plugin:r})}),o.selectionSet||o.docChanged?null:i}},props:{handleTextInput(o,i,s,l){return ho({editor:e,from:i,to:s,text:l,rules:t,plugin:r})},handleDOMEvents:{compositionend:o=>(setTimeout(()=>{const{$cursor:i}=o.state.selection;i&&ho({editor:e,from:i.pos,to:i.pos,text:"",rules:t,plugin:r})}),!1)},handleKeyDown(o,i){if(i.key!=="Enter")return!1;const{$cursor:s}=o.state.selection;return s?ho({editor:e,from:s.pos,to:s.pos,text:`
11
+ `,rules:t,plugin:r}):!1}},isInputRules:!0});return r}function wv(n){return Object.prototype.toString.call(n).slice(8,-1)}function po(n){return wv(n)!=="Object"?!1:n.constructor===Object&&Object.getPrototypeOf(n)===Object.prototype}function pi(n,e){const t={...n};return po(n)&&po(e)&&Object.keys(e).forEach(r=>{po(e[r])&&po(n[r])?t[r]=pi(n[r],e[r]):t[r]=e[r]}),t}class Hr{constructor(e={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=le(H(this,"addOptions",{name:this.name}))),this.storage=le(H(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new Hr(e)}configure(e={}){const t=this.extend({...this.config,addOptions:()=>pi(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const t=new Hr(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=le(H(t,"addOptions",{name:t.name})),t.storage=le(H(t,"addStorage",{name:t.name,options:t.options})),t}static handleExit({editor:e,mark:t}){const{tr:r}=e.state,o=e.state.selection.$from;if(o.pos===o.end()){const s=o.marks();if(!!!s.find(c=>(c==null?void 0:c.type.name)===t.name))return!1;const a=s.find(c=>(c==null?void 0:c.type.name)===t.name);return a&&r.removeStoredMark(a),r.insertText(" ",o.pos),e.view.dispatch(r),!0}return!1}}function qr(n){return typeof n=="number"}class Bm{constructor(e){this.find=e.find,this.handler=e.handler}}const Sv=(n,e,t)=>{if(xc(e))return[...n.matchAll(e)];const r=e(n,t);return r?r.map(o=>{const i=[o.text];return i.index=o.index,i.input=n,i.data=o.data,o.replaceWith&&(o.text.includes(o.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),i.push(o.replaceWith)),i}):[]};function Cv(n){const{editor:e,state:t,from:r,to:o,rule:i,pasteEvent:s,dropEvent:l}=n,{commands:a,chain:c,can:u}=new di({editor:e,state:t}),d=[];return t.doc.nodesBetween(r,o,(p,m)=>{if(!p.isTextblock||p.type.spec.code)return;const g=Math.max(r,m),y=Math.min(o,m+p.content.size),b=p.textBetween(g-m,y-m,void 0,"");Sv(b,i.find,s).forEach(v=>{if(v.index===void 0)return;const S=g+v.index+1,T=S+v[0].length,C={from:t.tr.mapping.map(S),to:t.tr.mapping.map(T)},I=i.handler({state:t,range:C,match:v,commands:a,chain:c,can:u,pasteEvent:s,dropEvent:l});d.push(I)})}),d.every(p=>p!==null)}let mo=null;const Tv=n=>{var e;const t=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=t.clipboardData)===null||e===void 0||e.setData("text/html",n),t};function kv(n){const{editor:e,rules:t}=n;let r=null,o=!1,i=!1,s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}const a=({state:u,from:d,to:f,rule:p,pasteEvt:m})=>{const g=u.tr,y=ui({state:u,transaction:g});if(!(!Cv({editor:e,state:y,from:Math.max(d-1,0),to:f.b-1,rule:p,pasteEvent:m,dropEvent:l})||!g.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,g}};return t.map(u=>new $e({view(d){const f=m=>{var g;r=!((g=d.dom.parentElement)===null||g===void 0)&&g.contains(m.target)?d.dom.parentElement:null,r&&(mo=e)},p=()=>{mo&&(mo=null)};return window.addEventListener("dragstart",f),window.addEventListener("dragend",p),{destroy(){window.removeEventListener("dragstart",f),window.removeEventListener("dragend",p)}}},props:{handleDOMEvents:{drop:(d,f)=>{if(i=r===d.dom.parentElement,l=f,!i){const p=mo;p&&setTimeout(()=>{const m=p.state.selection;m&&p.commands.deleteRange({from:m.from,to:m.to})},10)}return!1},paste:(d,f)=>{var p;const m=(p=f.clipboardData)===null||p===void 0?void 0:p.getData("text/html");return s=f,o=!!(m!=null&&m.includes("data-pm-slice")),!1}}},appendTransaction:(d,f,p)=>{const m=d[0],g=m.getMeta("uiEvent")==="paste"&&!o,y=m.getMeta("uiEvent")==="drop"&&!i,b=m.getMeta("applyPasteRules"),w=!!b;if(!g&&!y&&!w)return;if(w){let{text:T}=b;typeof T=="string"?T=T:T=vc(j.from(T),p.schema);const{from:C}=b,I=C+T.length,O=Tv(T);return a({rule:u,state:p,from:C,to:{b:I},pasteEvt:O})}const v=f.doc.content.findDiffStart(p.doc.content),S=f.doc.content.findDiffEnd(p.doc.content);if(!(!qr(v)||!S||v===S.b))return a({rule:u,state:p,from:v,to:S,pasteEvt:s})}}))}function Ev(n){const e=n.filter((t,r)=>n.indexOf(t)!==r);return Array.from(new Set(e))}class er{constructor(e,t){this.splittableMarks=[],this.editor=t,this.extensions=er.resolve(e),this.schema=yv(this.extensions,t),this.setupExtensions()}static resolve(e){const t=er.sort(er.flatten(e)),r=Ev(t.map(o=>o.name));return r.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${r.map(o=>`'${o}'`).join(", ")}]. This can lead to issues.`),t}static flatten(e){return e.map(t=>{const r={name:t.name,options:t.options,storage:t.storage},o=H(t,"addExtensions",r);return o?[t,...this.flatten(o())]:t}).flat(10)}static sort(e){return e.sort((r,o)=>{const i=H(r,"priority")||100,s=H(o,"priority")||100;return i>s?-1:i<s?1:0})}get commands(){return this.extensions.reduce((e,t)=>{const r={name:t.name,options:t.options,storage:t.storage,editor:this.editor,type:ts(t.name,this.schema)},o=H(t,"addCommands",r);return o?{...e,...o()}:e},{})}get plugins(){const{editor:e}=this,t=er.sort([...this.extensions].reverse()),r=[],o=[],i=t.map(s=>{const l={name:s.name,options:s.options,storage:s.storage,editor:e,type:ts(s.name,this.schema)},a=[],c=H(s,"addKeyboardShortcuts",l);let u={};if(s.type==="mark"&&H(s,"exitable",l)&&(u.ArrowRight=()=>Hr.handleExit({editor:e,mark:s})),c){const g=Object.fromEntries(Object.entries(c()).map(([y,b])=>[y,()=>b({editor:e})]));u={...u,...g}}const d=Vb(u);a.push(d);const f=H(s,"addInputRules",l);wd(s,e.options.enableInputRules)&&f&&r.push(...f());const p=H(s,"addPasteRules",l);wd(s,e.options.enablePasteRules)&&p&&o.push(...p());const m=H(s,"addProseMirrorPlugins",l);if(m){const g=m();a.push(...g)}return a}).flat();return[xv({editor:e,rules:r}),...kv({editor:e,rules:o}),...i]}get attributes(){return Pm(this.extensions)}get nodeViews(){const{editor:e}=this,{nodeExtensions:t}=fi(this.extensions);return Object.fromEntries(t.filter(r=>!!H(r,"addNodeView")).map(r=>{const o=this.attributes.filter(a=>a.type===r.name),i={name:r.name,options:r.options,storage:r.storage,editor:e,type:ze(r.name,this.schema)},s=H(r,"addNodeView",i);if(!s)return[];const l=(a,c,u,d,f)=>{const p=Yo(a,o);return s()({node:a,view:c,getPos:u,decorations:d,innerDecorations:f,editor:e,extension:r,HTMLAttributes:p})};return[r.name,l]}))}setupExtensions(){this.extensions.forEach(e=>{var t;this.editor.extensionStorage[e.name]=e.storage;const r={name:e.name,options:e.options,storage:e.storage,editor:this.editor,type:ts(e.name,this.schema)};e.type==="mark"&&(!((t=le(H(e,"keepOnSplit",r)))!==null&&t!==void 0)||t)&&this.splittableMarks.push(e.name);const o=H(e,"onBeforeCreate",r),i=H(e,"onCreate",r),s=H(e,"onUpdate",r),l=H(e,"onSelectionUpdate",r),a=H(e,"onTransaction",r),c=H(e,"onFocus",r),u=H(e,"onBlur",r),d=H(e,"onDestroy",r);o&&this.editor.on("beforeCreate",o),i&&this.editor.on("create",i),s&&this.editor.on("update",s),l&&this.editor.on("selectionUpdate",l),a&&this.editor.on("transaction",a),c&&this.editor.on("focus",c),u&&this.editor.on("blur",u),d&&this.editor.on("destroy",d)})}}class lt{constructor(e={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=le(H(this,"addOptions",{name:this.name}))),this.storage=le(H(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new lt(e)}configure(e={}){const t=this.extend({...this.config,addOptions:()=>pi(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const t=new lt({...this.config,...e});return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=le(H(t,"addOptions",{name:t.name})),t.storage=le(H(t,"addStorage",{name:t.name,options:t.options})),t}}function zm(n,e,t){const{from:r,to:o}=e,{blockSeparator:i=`
12
+
13
+ `,textSerializers:s={}}=t||{};let l="";return n.nodesBetween(r,o,(a,c,u,d)=>{var f;a.isBlock&&c>r&&(l+=i);const p=s==null?void 0:s[a.type.name];if(p)return u&&(l+=p({node:a,pos:c,parent:u,index:d,range:e})),!1;a.isText&&(l+=(f=a==null?void 0:a.text)===null||f===void 0?void 0:f.slice(Math.max(r,c)-c,o-c))}),l}function $m(n){return Object.fromEntries(Object.entries(n.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}const Mv=lt.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new $e({key:new ht("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:n}=this,{state:e,schema:t}=n,{doc:r,selection:o}=e,{ranges:i}=o,s=Math.min(...i.map(u=>u.$from.pos)),l=Math.max(...i.map(u=>u.$to.pos)),a=$m(t);return zm(r,{from:s,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:a})}}})]}}),Ov=()=>({editor:n,view:e})=>(requestAnimationFrame(()=>{var t;n.isDestroyed||(e.dom.blur(),(t=window==null?void 0:window.getSelection())===null||t===void 0||t.removeAllRanges())}),!0),Av=(n=!1)=>({commands:e})=>e.setContent("",n),Nv=()=>({state:n,tr:e,dispatch:t})=>{const{selection:r}=e,{ranges:o}=r;return t&&o.forEach(({$from:i,$to:s})=>{n.doc.nodesBetween(i.pos,s.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)),p=d.blockRange(f);if(!p)return;const m=fr(p);if(l.type.isTextblock){const{defaultType:g}=d.parent.contentMatchAt(d.index());e.setNodeMarkup(p.start,g)}(m||m===0)&&e.lift(p,m)})}),!0},Rv=n=>e=>n(e),Iv=()=>({state:n,dispatch:e})=>ev(n,e),_v=(n,e)=>({editor:t,tr:r})=>{const{state:o}=t,i=o.doc.slice(n.from,n.to);r.deleteRange(n.from,n.to);const s=r.mapping.map(e);return r.insert(s,i.content),r.setSelection(new Z(r.doc.resolve(s-1))),!0},Dv=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,r=t.$anchor.node();if(r.content.size>0)return!1;const o=n.selection.$anchor;for(let i=o.depth;i>0;i-=1)if(o.node(i).type===r.type){if(e){const l=o.before(i),a=o.after(i);n.delete(l,a).scrollIntoView()}return!0}return!1},jv=n=>({tr:e,state:t,dispatch:r})=>{const o=ze(n,t.schema),i=e.selection.$anchor;for(let s=i.depth;s>0;s-=1)if(i.node(s).type===o){if(r){const a=i.before(s),c=i.after(s);e.delete(a,c).scrollIntoView()}return!0}return!1},Pv=n=>({tr:e,dispatch:t})=>{const{from:r,to:o}=n;return t&&e.delete(r,o),!0},Lv=()=>({state:n,dispatch:e})=>Am(n,e),Bv=()=>({commands:n})=>n.keyboardShortcut("Enter"),zv=()=>({state:n,dispatch:e})=>Qb(n,e);function Qo(n,e,t={strict:!0}){const r=Object.keys(e);return r.length?r.every(o=>t.strict?e[o]===n[o]:xc(e[o])?e[o].test(n[o]):e[o]===n[o]):!0}function Fm(n,e,t={}){return n.find(r=>r.type===e&&Qo(Object.fromEntries(Object.keys(t).map(o=>[o,r.attrs[o]])),t))}function Sd(n,e,t={}){return!!Fm(n,e,t)}function mi(n,e,t){var r;if(!n||!e)return;let o=n.parent.childAfter(n.parentOffset);if((!o.node||!o.node.marks.some(u=>u.type===e))&&(o=n.parent.childBefore(n.parentOffset)),!o.node||!o.node.marks.some(u=>u.type===e)||(t=t||((r=o.node.marks[0])===null||r===void 0?void 0:r.attrs),!Fm([...o.node.marks],e,t)))return;let s=o.index,l=n.start()+o.offset,a=s+1,c=l+o.node.nodeSize;for(;s>0&&Sd([...n.parent.child(s-1).marks],e,t);)s-=1,l-=n.parent.child(s).nodeSize;for(;a<n.parent.childCount&&Sd([...n.parent.child(a).marks],e,t);)c+=n.parent.child(a).nodeSize,a+=1;return{from:l,to:c}}function pn(n,e){if(typeof n=="string"){if(!e.marks[n])throw Error(`There is no mark type named '${n}'. Maybe you forgot to add the extension?`);return e.marks[n]}return n}const $v=(n,e={})=>({tr:t,state:r,dispatch:o})=>{const i=pn(n,r.schema),{doc:s,selection:l}=t,{$from:a,from:c,to:u}=l;if(o){const d=mi(a,i,e);if(d&&d.from<=c&&d.to>=u){const f=Z.create(s,d.from,d.to);t.setSelection(f)}}return!0},Fv=n=>e=>{const t=typeof n=="function"?n(e):n;for(let r=0;r<t.length;r+=1)if(t[r](e))return!0;return!1};function wc(n){return n instanceof Z}function zt(n=0,e=0,t=0){return Math.min(Math.max(n,e),t)}function Vm(n,e=null){if(!e)return null;const t=te.atStart(n),r=te.atEnd(n);if(e==="start"||e===!0)return t;if(e==="end")return r;const o=t.from,i=r.to;return e==="all"?Z.create(n,zt(0,o,i),zt(n.content.size,o,i)):Z.create(n,zt(e,o,i),zt(e,o,i))}function Hm(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function gi(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}const Vv=(n=null,e={})=>({editor:t,view:r,tr:o,dispatch:i})=>{e={scrollIntoView:!0,...e};const s=()=>{(gi()||Hm())&&r.dom.focus(),requestAnimationFrame(()=>{t.isDestroyed||(r.focus(),e!=null&&e.scrollIntoView&&t.commands.scrollIntoView())})};if(r.hasFocus()&&n===null||n===!1)return!0;if(i&&n===null&&!wc(t.state.selection))return s(),!0;const l=Vm(o.doc,n)||t.state.selection,a=t.state.selection.eq(l);return i&&(a||o.setSelection(l),a&&o.storedMarks&&o.setStoredMarks(o.storedMarks),s()),!0},Hv=(n,e)=>t=>n.every((r,o)=>e(r,{...t,index:o})),qv=(n,e)=>({tr:t,commands:r})=>r.insertContentAt({from:t.selection.from,to:t.selection.to},n,e),qm=n=>{const e=n.childNodes;for(let t=e.length-1;t>=0;t-=1){const r=e[t];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?n.removeChild(r):r.nodeType===1&&qm(r)}return n};function go(n){const e=`<body>${n}</body>`,t=new window.DOMParser().parseFromString(e,"text/html").body;return qm(t)}function ei(n,e,t){if(n instanceof $t||n instanceof j)return n;t={slice:!0,parseOptions:{},...t};const r=typeof n=="object"&&n!==null,o=typeof n=="string";if(r)try{if(Array.isArray(n)&&n.length>0)return j.fromArray(n.map(l=>e.nodeFromJSON(l)));const s=e.nodeFromJSON(n);return t.errorOnInvalidContent&&s.check(),s}catch(i){if(t.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:i});return console.warn("[tiptap warn]: Invalid content.","Passed value:",n,"Error:",i),ei("",e,t)}if(o){if(t.errorOnInvalidContent){let s=!1,l="";const a=new Ip({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=>(s=!0,l=typeof c=="string"?c:c.outerHTML,null)}]}})});if(t.slice?on.fromSchema(a).parseSlice(go(n),t.parseOptions):on.fromSchema(a).parse(go(n),t.parseOptions),t.errorOnInvalidContent&&s)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const i=on.fromSchema(e);return t.slice?i.parseSlice(go(n),t.parseOptions).content:i.parse(go(n),t.parseOptions)}return ei("",e,t)}function Wv(n,e,t){const r=n.steps.length-1;if(r<e)return;const o=n.steps[r];if(!(o instanceof je||o instanceof Le))return;const i=n.mapping.maps[r];let s=0;i.forEach((l,a,c,u)=>{s===0&&(s=u)}),n.setSelection(te.near(n.doc.resolve(s),t))}const Uv=n=>!("type"in n),Gv=(n,e,t)=>({tr:r,dispatch:o,editor:i})=>{var s;if(o){t={parseOptions:i.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...t};let l;try{l=ei(e,i.schema,{parseOptions:{preserveWhitespace:"full",...t.parseOptions},errorOnInvalidContent:(s=t.errorOnInvalidContent)!==null&&s!==void 0?s:i.options.enableContentCheck})}catch(m){return i.emit("contentError",{editor:i,error:m,disableCollaboration:()=>{i.storage.collaboration&&(i.storage.collaboration.isDisabled=!0)}}),!1}let{from:a,to:c}=typeof n=="number"?{from:n,to:n}:{from:n.from,to:n.to},u=!0,d=!0;if((Uv(l)?l:[l]).forEach(m=>{m.check(),u=u?m.isText&&m.marks.length===0:!1,d=d?m.isBlock:!1}),a===c&&d){const{parent:m}=r.doc.resolve(a);m.isTextblock&&!m.type.spec.code&&!m.childCount&&(a-=1,c+=1)}let p;if(u){if(Array.isArray(e))p=e.map(m=>m.text||"").join("");else if(e instanceof j){let m="";e.forEach(g=>{g.text&&(m+=g.text)}),p=m}else typeof e=="object"&&e&&e.text?p=e.text:p=e;r.insertText(p,a,c)}else p=l,r.replaceWith(a,c,p);t.updateSelection&&Wv(r,r.steps.length-1,-1),t.applyInputRules&&r.setMeta("applyInputRules",{from:a,text:p}),t.applyPasteRules&&r.setMeta("applyPasteRules",{from:a,text:p})}return!0},Kv=()=>({state:n,dispatch:e})=>Jb(n,e),Jv=()=>({state:n,dispatch:e})=>Xb(n,e),Xv=()=>({state:n,dispatch:e})=>Hb(n,e),Zv=()=>({state:n,dispatch:e})=>Gb(n,e),Yv=()=>({state:n,dispatch:e,tr:t})=>{try{const r=oi(n.doc,n.selection.$from.pos,-1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},Qv=()=>({state:n,dispatch:e,tr:t})=>{try{const r=oi(n.doc,n.selection.$from.pos,1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},ex=()=>({state:n,dispatch:e})=>qb(n,e),tx=()=>({state:n,dispatch:e})=>Wb(n,e);function Wm(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function nx(n){const e=n.split(/-(?!$)/);let t=e[e.length-1];t==="Space"&&(t=" ");let r,o,i,s;for(let l=0;l<e.length-1;l+=1){const a=e[l];if(/^(cmd|meta|m)$/i.test(a))s=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))o=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))gi()||Wm()?s=!0:o=!0;else throw new Error(`Unrecognized modifier name: ${a}`)}return r&&(t=`Alt-${t}`),o&&(t=`Ctrl-${t}`),s&&(t=`Meta-${t}`),i&&(t=`Shift-${t}`),t}const rx=n=>({editor:e,view:t,tr:r,dispatch:o})=>{const i=nx(n).split(/-(?!$)/),s=i.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),l=new KeyboardEvent("keydown",{key:s==="Space"?" ":s,altKey:i.includes("Alt"),ctrlKey:i.includes("Ctrl"),metaKey:i.includes("Meta"),shiftKey:i.includes("Shift"),bubbles:!0,cancelable:!0}),a=e.captureTransaction(()=>{t.someProp("handleKeyDown",c=>c(t,l))});return a==null||a.steps.forEach(c=>{const u=c.map(r.mapping);u&&o&&r.maybeStep(u)}),!0};function Wr(n,e,t={}){const{from:r,to:o,empty:i}=n.selection,s=e?ze(e,n.schema):null,l=[];n.doc.nodesBetween(r,o,(d,f)=>{if(d.isText)return;const p=Math.max(r,f),m=Math.min(o,f+d.nodeSize);l.push({node:d,from:p,to:m})});const a=o-r,c=l.filter(d=>s?s.name===d.node.type.name:!0).filter(d=>Qo(d.node.attrs,t,{strict:!1}));return i?!!c.length:c.reduce((d,f)=>d+f.to-f.from,0)>=a}const ox=(n,e={})=>({state:t,dispatch:r})=>{const o=ze(n,t.schema);return Wr(t,o,e)?Zb(t,r):!1},ix=()=>({state:n,dispatch:e})=>tv(n,e),sx=n=>({state:e,dispatch:t})=>{const r=ze(n,e.schema);return uv(r)(e,t)},lx=()=>({state:n,dispatch:e})=>Yb(n,e);function yi(n,e){return e.nodes[n]?"node":e.marks[n]?"mark":null}function Cd(n,e){const t=typeof e=="string"?[e]:e;return Object.keys(n).reduce((r,o)=>(t.includes(o)||(r[o]=n[o]),r),{})}const ax=(n,e)=>({tr:t,state:r,dispatch:o})=>{let i=null,s=null;const l=yi(typeof n=="string"?n:n.name,r.schema);return l?(l==="node"&&(i=ze(n,r.schema)),l==="mark"&&(s=pn(n,r.schema)),o&&t.selection.ranges.forEach(a=>{r.doc.nodesBetween(a.$from.pos,a.$to.pos,(c,u)=>{i&&i===c.type&&t.setNodeMarkup(u,void 0,Cd(c.attrs,e)),s&&c.marks.length&&c.marks.forEach(d=>{s===d.type&&t.addMark(u,u+c.nodeSize,s.create(Cd(d.attrs,e)))})})}),!0):!1},cx=()=>({tr:n,dispatch:e})=>(e&&n.scrollIntoView(),!0),ux=()=>({tr:n,dispatch:e})=>{if(e){const t=new ot(n.doc);n.setSelection(t)}return!0},dx=()=>({state:n,dispatch:e})=>Ub(n,e),fx=()=>({state:n,dispatch:e})=>Kb(n,e),hx=()=>({state:n,dispatch:e})=>nv(n,e),px=()=>({state:n,dispatch:e})=>iv(n,e),mx=()=>({state:n,dispatch:e})=>ov(n,e);function Aa(n,e,t={},r={}){return ei(n,e,{slice:!1,parseOptions:t,errorOnInvalidContent:r.errorOnInvalidContent})}const gx=(n,e=!1,t={},r={})=>({editor:o,tr:i,dispatch:s,commands:l})=>{var a,c;const{doc:u}=i;if(t.preserveWhitespace!=="full"){const d=Aa(n,o.schema,t,{errorOnInvalidContent:(a=r.errorOnInvalidContent)!==null&&a!==void 0?a:o.options.enableContentCheck});return s&&i.replaceWith(0,u.content.size,d).setMeta("preventUpdate",!e),!0}return s&&i.setMeta("preventUpdate",!e),l.insertContentAt({from:0,to:u.content.size},n,{parseOptions:t,errorOnInvalidContent:(c=r.errorOnInvalidContent)!==null&&c!==void 0?c:o.options.enableContentCheck})};function Um(n,e){const t=pn(e,n.schema),{from:r,to:o,empty:i}=n.selection,s=[];i?(n.storedMarks&&s.push(...n.storedMarks),s.push(...n.selection.$head.marks())):n.doc.nodesBetween(r,o,a=>{s.push(...a.marks)});const l=s.find(a=>a.type.name===t.name);return l?{...l.attrs}:{}}function yx(n,e){const t=new oc(n);return e.forEach(r=>{r.steps.forEach(o=>{t.step(o)})}),t}function bx(n){for(let e=0;e<n.edgeCount;e+=1){const{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}function vx(n,e){const t=[];return n.descendants((r,o)=>{e(r)&&t.push({node:r,pos:o})}),t}function xx(n,e,t){const r=[];return n.nodesBetween(e.from,e.to,(o,i)=>{t(o)&&r.push({node:o,pos:i})}),r}function Gm(n,e){for(let t=n.depth;t>0;t-=1){const r=n.node(t);if(e(r))return{pos:t>0?n.before(t):0,start:n.start(t),depth:t,node:r}}}function dn(n){return e=>Gm(e.$from,n)}function wx(n,e){const t={from:0,to:n.content.size};return zm(n,t,e)}function Sx(n,e){const t=ze(e,n.schema),{from:r,to:o}=n.selection,i=[];n.doc.nodesBetween(r,o,l=>{i.push(l)});const s=i.reverse().find(l=>l.type.name===t.name);return s?{...s.attrs}:{}}function Km(n,e){const t=yi(typeof e=="string"?e:e.name,n.schema);return t==="node"?Sx(n,e):t==="mark"?Um(n,e):{}}function Cx(n,e=JSON.stringify){const t={};return n.filter(r=>{const o=e(r);return Object.prototype.hasOwnProperty.call(t,o)?!1:t[o]=!0})}function Tx(n){const e=Cx(n);return e.length===1?e:e.filter((t,r)=>!e.filter((i,s)=>s!==r).some(i=>t.oldRange.from>=i.oldRange.from&&t.oldRange.to<=i.oldRange.to&&t.newRange.from>=i.newRange.from&&t.newRange.to<=i.newRange.to))}function kx(n){const{mapping:e,steps:t}=n,r=[];return e.maps.forEach((o,i)=>{const s=[];if(o.ranges.length)o.forEach((l,a)=>{s.push({from:l,to:a})});else{const{from:l,to:a}=t[i];if(l===void 0||a===void 0)return;s.push({from:l,to:a})}s.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}})})}),Tx(r)}function Sc(n,e,t){const r=[];return n===e?t.resolve(n).marks().forEach(o=>{const i=t.resolve(n),s=mi(i,o.type);s&&r.push({mark:o,...s})}):t.nodesBetween(n,e,(o,i)=>{!o||(o==null?void 0:o.nodeSize)===void 0||r.push(...o.marks.map(s=>({from:i,to:i+o.nodeSize,mark:s})))}),r}function Po(n,e,t){return Object.fromEntries(Object.entries(t).filter(([r])=>{const o=n.find(i=>i.type===e&&i.name===r);return o?o.attribute.keepOnSplit:!1}))}function Na(n,e,t={}){const{empty:r,ranges:o}=n.selection,i=e?pn(e,n.schema):null;if(r)return!!(n.storedMarks||n.selection.$from.marks()).filter(d=>i?i.name===d.type.name:!0).find(d=>Qo(d.attrs,t,{strict:!1}));let s=0;const l=[];if(o.forEach(({$from:d,$to:f})=>{const p=d.pos,m=f.pos;n.doc.nodesBetween(p,m,(g,y)=>{if(!g.isText&&!g.marks.length)return;const b=Math.max(p,y),w=Math.min(m,y+g.nodeSize),v=w-b;s+=v,l.push(...g.marks.map(S=>({mark:S,from:b,to:w})))})}),s===0)return!1;const a=l.filter(d=>i?i.name===d.mark.type.name:!0).filter(d=>Qo(d.mark.attrs,t,{strict:!1})).reduce((d,f)=>d+f.to-f.from,0),c=l.filter(d=>i?d.mark.type!==i&&d.mark.type.excludes(i):!0).reduce((d,f)=>d+f.to-f.from,0);return(a>0?a+c:a)>=s}function Jm(n,e,t={}){if(!e)return Wr(n,null,t)||Na(n,null,t);const r=yi(e,n.schema);return r==="node"?Wr(n,e,t):r==="mark"?Na(n,e,t):!1}function Ra(n,e){const{nodeExtensions:t}=fi(e),r=t.find(s=>s.name===n);if(!r)return!1;const o={name:r.name,options:r.options,storage:r.storage},i=le(H(r,"group",o));return typeof i!="string"?!1:i.split(" ").includes("list")}function bi(n,{checkChildren:e=!0,ignoreWhitespace:t=!1}={}){var r;if(t){if(n.type.name==="hardBreak")return!0;if(n.isText)return/^\s*$/m.test((r=n.text)!==null&&r!==void 0?r:"")}if(n.isText)return!n.text;if(n.isAtom||n.isLeaf)return!1;if(n.content.childCount===0)return!0;if(e){let o=!0;return n.content.forEach(i=>{o!==!1&&(bi(i,{ignoreWhitespace:t,checkChildren:e})||(o=!1))}),o}return!1}function Xm(n){return n instanceof K}function Ex(n,e,t){const o=n.state.doc.content.size,i=zt(e,0,o),s=zt(t,0,o),l=n.coordsAtPos(i),a=n.coordsAtPos(s,-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),p=f-d,m=u-c,b={top:c,bottom:u,left:d,right:f,width:p,height:m,x:d,y:c};return{...b,toJSON:()=>b}}function Mx(n,e,t){var r;const{selection:o}=e;let i=null;if(wc(o)&&(i=o.$cursor),i){const l=(r=n.storedMarks)!==null&&r!==void 0?r:i.marks();return!!t.isInSet(l)||!l.some(a=>a.type.excludes(t))}const{ranges:s}=o;return s.some(({$from:l,$to:a})=>{let c=l.depth===0?n.doc.inlineContent&&n.doc.type.allowsMarkType(t):!1;return n.doc.nodesBetween(l.pos,a.pos,(u,d,f)=>{if(c)return!1;if(u.isInline){const p=!f||f.type.allowsMarkType(t),m=!!t.isInSet(u.marks)||!u.marks.some(g=>g.type.excludes(t));c=p&&m}return!c}),c})}const Ox=(n,e={})=>({tr:t,state:r,dispatch:o})=>{const{selection:i}=t,{empty:s,ranges:l}=i,a=pn(n,r.schema);if(o)if(s){const c=Um(r,a);t.addStoredMark(a.create({...c,...e}))}else l.forEach(c=>{const u=c.$from.pos,d=c.$to.pos;r.doc.nodesBetween(u,d,(f,p)=>{const m=Math.max(p,u),g=Math.min(p+f.nodeSize,d);f.marks.find(b=>b.type===a)?f.marks.forEach(b=>{a===b.type&&t.addMark(m,g,a.create({...b.attrs,...e}))}):t.addMark(m,g,a.create(e))})});return Mx(r,t,a)},Ax=(n,e)=>({tr:t})=>(t.setMeta(n,e),!0),Nx=(n,e={})=>({state:t,dispatch:r,chain:o})=>{const i=ze(n,t.schema);let s;return t.selection.$anchor.sameParent(t.selection.$head)&&(s=t.selection.$anchor.parent.attrs),i.isTextblock?o().command(({commands:l})=>bd(i,{...s,...e})(t)?!0:l.clearNodes()).command(({state:l})=>bd(i,{...s,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},Rx=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,o=zt(n,0,r.content.size),i=K.create(r,o);e.setSelection(i)}return!0},Ix=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,{from:o,to:i}=typeof n=="number"?{from:n,to:n}:n,s=Z.atStart(r).from,l=Z.atEnd(r).to,a=zt(o,s,l),c=zt(i,s,l),u=Z.create(r,a,c);e.setSelection(u)}return!0},_x=n=>({state:e,dispatch:t})=>{const r=ze(n,e.schema);return hv(r)(e,t)};function Td(n,e){const t=n.storedMarks||n.selection.$to.parentOffset&&n.selection.$from.marks();if(t){const r=t.filter(o=>e==null?void 0:e.includes(o.type.name));n.tr.ensureMarks(r)}}const Dx=({keepMarks:n=!0}={})=>({tr:e,state:t,dispatch:r,editor:o})=>{const{selection:i,doc:s}=e,{$from:l,$to:a}=i,c=o.extensionManager.attributes,u=Po(c,l.node().type.name,l.node().attrs);if(i instanceof K&&i.node.isBlock)return!l.parentOffset||!nr(s,l.pos)?!1:(r&&(n&&Td(t,o.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:bx(l.node(-1).contentMatchAt(l.indexAfter(-1)));let p=d&&f?[{type:f,attrs:u}]:void 0,m=nr(e.doc,e.mapping.map(l.pos),1,p);if(!p&&!m&&nr(e.doc,e.mapping.map(l.pos),1,f?[{type:f}]:void 0)&&(m=!0,p=f?[{type:f,attrs:u}]:void 0),r){if(m&&(i instanceof Z&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,p),f&&!d&&!l.parentOffset&&l.parent.type!==f)){const g=e.mapping.map(l.before()),y=e.doc.resolve(g);l.node(-1).canReplaceWith(y.index(),y.index()+1,f)&&e.setNodeMarkup(e.mapping.map(l.before()),f)}n&&Td(t,o.extensionManager.splittableMarks),e.scrollIntoView()}return m},jx=(n,e={})=>({tr:t,state:r,dispatch:o,editor:i})=>{var s;const l=ze(n,r.schema),{$from:a,$to:c}=r.selection,u=r.selection.node;if(u&&u.isBlock||a.depth<2||!a.sameParent(c))return!1;const d=a.node(-1);if(d.type!==l)return!1;const f=i.extensionManager.attributes;if(a.parent.content.size===0&&a.node(-1).childCount===a.indexAfter(-1)){if(a.depth===2||a.node(-3).type!==l||a.index(-2)!==a.node(-2).childCount-1)return!1;if(o){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,S={...Po(f,a.node().type.name,a.node().attrs),...e},T=((s=l.contentMatch.defaultType)===null||s===void 0?void 0:s.createAndFill(S))||void 0;b=b.append(j.from(l.createAndFill(null,T)||void 0));const C=a.before(a.depth-(w-1));t.replace(C,a.after(-v),new $(b,4-w,0));let I=-1;t.doc.nodesBetween(C,t.doc.content.size,(O,E)=>{if(I>-1)return!1;O.isTextblock&&O.content.size===0&&(I=E+1)}),I>-1&&t.setSelection(Z.near(t.doc.resolve(I))),t.scrollIntoView()}return!0}const p=c.pos===a.end()?d.contentMatchAt(0).defaultType:null,m={...Po(f,d.type.name,d.attrs),...e},g={...Po(f,a.node().type.name,a.node().attrs),...e};t.delete(a.pos,c.pos);const y=p?[{type:l,attrs:m},{type:p,attrs:g}]:[{type:l,attrs:m}];if(!nr(t.doc,a.pos,2))return!1;if(o){const{selection:b,storedMarks:w}=r,{splittableMarks:v}=i.extensionManager,S=w||b.$to.parentOffset&&b.$from.marks();if(t.split(a.pos,2,y).scrollIntoView(),!S||!o)return!0;const T=S.filter(C=>v.includes(C.type.name));t.ensureMarks(T)}return!0},ns=(n,e)=>{const t=dn(s=>s.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(Math.max(0,t.pos-1)).before(t.depth);if(r===void 0)return!0;const o=n.doc.nodeAt(r);return t.node.type===(o==null?void 0:o.type)&&hn(n.doc,t.pos)&&n.join(t.pos),!0},rs=(n,e)=>{const t=dn(s=>s.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(t.start).after(t.depth);if(r===void 0)return!0;const o=n.doc.nodeAt(r);return t.node.type===(o==null?void 0:o.type)&&hn(n.doc,r)&&n.join(r),!0},Px=(n,e,t,r={})=>({editor:o,tr:i,state:s,dispatch:l,chain:a,commands:c,can:u})=>{const{extensions:d,splittableMarks:f}=o.extensionManager,p=ze(n,s.schema),m=ze(e,s.schema),{selection:g,storedMarks:y}=s,{$from:b,$to:w}=g,v=b.blockRange(w),S=y||g.$to.parentOffset&&g.$from.marks();if(!v)return!1;const T=dn(C=>Ra(C.type.name,d))(g);if(v.depth>=1&&T&&v.depth-T.depth<=1){if(T.node.type===p)return c.liftListItem(m);if(Ra(T.node.type.name,d)&&p.validContent(T.node.content)&&l)return a().command(()=>(i.setNodeMarkup(T.pos,p),!0)).command(()=>ns(i,p)).command(()=>rs(i,p)).run()}return!t||!S||!l?a().command(()=>u().wrapInList(p,r)?!0:c.clearNodes()).wrapInList(p,r).command(()=>ns(i,p)).command(()=>rs(i,p)).run():a().command(()=>{const C=u().wrapInList(p,r),I=S.filter(O=>f.includes(O.type.name));return i.ensureMarks(I),C?!0:c.clearNodes()}).wrapInList(p,r).command(()=>ns(i,p)).command(()=>rs(i,p)).run()},Lx=(n,e={},t={})=>({state:r,commands:o})=>{const{extendEmptyMarkRange:i=!1}=t,s=pn(n,r.schema);return Na(r,s,e)?o.unsetMark(s,{extendEmptyMarkRange:i}):o.setMark(s,e)},Bx=(n,e,t={})=>({state:r,commands:o})=>{const i=ze(n,r.schema),s=ze(e,r.schema),l=Wr(r,i,t);let a;return r.selection.$anchor.sameParent(r.selection.$head)&&(a=r.selection.$anchor.parent.attrs),l?o.setNode(s,a):o.setNode(i,{...a,...t})},zx=(n,e={})=>({state:t,commands:r})=>{const o=ze(n,t.schema);return Wr(t,o,e)?r.lift(o):r.wrapIn(o,e)},$x=()=>({state:n,dispatch:e})=>{const t=n.plugins;for(let r=0;r<t.length;r+=1){const o=t[r];let i;if(o.spec.isInputRules&&(i=o.getState(n))){if(e){const s=n.tr,l=i.transform;for(let a=l.steps.length-1;a>=0;a-=1)s.step(l.steps[a].invert(l.docs[a]));if(i.text){const a=s.doc.resolve(i.from).marks();s.replaceWith(i.from,i.to,n.schema.text(i.text,a))}else s.delete(i.from,i.to)}return!0}}return!1},Fx=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,{empty:r,ranges:o}=t;return r||e&&o.forEach(i=>{n.removeMark(i.$from.pos,i.$to.pos)}),!0},Vx=(n,e={})=>({tr:t,state:r,dispatch:o})=>{var i;const{extendEmptyMarkRange:s=!1}=e,{selection:l}=t,a=pn(n,r.schema),{$from:c,empty:u,ranges:d}=l;if(!o)return!0;if(u&&s){let{from:f,to:p}=l;const m=(i=c.marks().find(y=>y.type===a))===null||i===void 0?void 0:i.attrs,g=mi(c,a,m);g&&(f=g.from,p=g.to),t.removeMark(f,p,a)}else d.forEach(f=>{t.removeMark(f.$from.pos,f.$to.pos,a)});return t.removeStoredMark(a),!0},Hx=(n,e={})=>({tr:t,state:r,dispatch:o})=>{let i=null,s=null;const l=yi(typeof n=="string"?n:n.name,r.schema);return l?(l==="node"&&(i=ze(n,r.schema)),l==="mark"&&(s=pn(n,r.schema)),o&&t.selection.ranges.forEach(a=>{const c=a.$from.pos,u=a.$to.pos;let d,f,p,m;t.selection.empty?r.doc.nodesBetween(c,u,(g,y)=>{i&&i===g.type&&(p=Math.max(y,c),m=Math.min(y+g.nodeSize,u),d=y,f=g)}):r.doc.nodesBetween(c,u,(g,y)=>{y<c&&i&&i===g.type&&(p=Math.max(y,c),m=Math.min(y+g.nodeSize,u),d=y,f=g),y>=c&&y<=u&&(i&&i===g.type&&t.setNodeMarkup(y,void 0,{...g.attrs,...e}),s&&g.marks.length&&g.marks.forEach(b=>{if(s===b.type){const w=Math.max(y,c),v=Math.min(y+g.nodeSize,u);t.addMark(w,v,s.create({...b.attrs,...e}))}}))}),f&&(d!==void 0&&t.setNodeMarkup(d,void 0,{...f.attrs,...e}),s&&f.marks.length&&f.marks.forEach(g=>{s===g.type&&t.addMark(p,m,s.create({...g.attrs,...e}))}))}),!0):!1},qx=(n,e={})=>({state:t,dispatch:r})=>{const o=ze(n,t.schema);return sv(o,e)(t,r)},Wx=(n,e={})=>({state:t,dispatch:r})=>{const o=ze(n,t.schema);return lv(o,e)(t,r)};var Ux=Object.freeze({__proto__:null,blur:Ov,clearContent:Av,clearNodes:Nv,command:Rv,createParagraphNear:Iv,cut:_v,deleteCurrentNode:Dv,deleteNode:jv,deleteRange:Pv,deleteSelection:Lv,enter:Bv,exitCode:zv,extendMarkRange:$v,first:Fv,focus:Vv,forEach:Hv,insertContent:qv,insertContentAt:Gv,joinBackward:Xv,joinDown:Jv,joinForward:Zv,joinItemBackward:Yv,joinItemForward:Qv,joinTextblockBackward:ex,joinTextblockForward:tx,joinUp:Kv,keyboardShortcut:rx,lift:ox,liftEmptyBlock:ix,liftListItem:sx,newlineInCode:lx,resetAttributes:ax,scrollIntoView:cx,selectAll:ux,selectNodeBackward:dx,selectNodeForward:fx,selectParentNode:hx,selectTextblockEnd:px,selectTextblockStart:mx,setContent:gx,setMark:Ox,setMeta:Ax,setNode:Nx,setNodeSelection:Rx,setTextSelection:Ix,sinkListItem:_x,splitBlock:Dx,splitListItem:jx,toggleList:Px,toggleMark:Lx,toggleNode:Bx,toggleWrap:zx,undoInputRule:$x,unsetAllMarks:Fx,unsetMark:Vx,updateAttributes:Hx,wrapIn:qx,wrapInList:Wx});const Gx=lt.create({name:"commands",addCommands(){return{...Ux}}}),Kx=lt.create({name:"drop",addProseMirrorPlugins(){return[new $e({key:new ht("tiptapDrop"),props:{handleDrop:(n,e,t,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:t,moved:r})}}})]}}),Jx=lt.create({name:"editable",addProseMirrorPlugins(){return[new $e({key:new ht("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Xx=new ht("focusEvents"),Zx=lt.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:n}=this;return[new $e({key:Xx,props:{handleDOMEvents:{focus:(e,t)=>{n.isFocused=!0;const r=n.state.tr.setMeta("focus",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,t)=>{n.isFocused=!1;const r=n.state.tr.setMeta("blur",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),Yx=lt.create({name:"keymap",addKeyboardShortcuts(){const n=()=>this.editor.commands.first(({commands:s})=>[()=>s.undoInputRule(),()=>s.command(({tr:l})=>{const{selection:a,doc:c}=l,{empty:u,$anchor:d}=a,{pos:f,parent:p}=d,m=d.parent.isTextblock&&f>0?l.doc.resolve(f-1):d,g=m.parent.type.spec.isolating,y=d.pos-d.parentOffset,b=g&&m.parent.childCount===1?y===d.pos:te.atStart(c).from===f;return!u||!p.type.isTextblock||p.textContent.length||!b||b&&d.parent.type.name==="paragraph"?!1:s.clearNodes()}),()=>s.deleteSelection(),()=>s.joinBackward(),()=>s.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:s})=>[()=>s.deleteSelection(),()=>s.deleteCurrentNode(),()=>s.joinForward(),()=>s.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:s})=>[()=>s.newlineInCode(),()=>s.createParagraphNear(),()=>s.liftEmptyBlock(),()=>s.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:n,"Mod-Backspace":n,"Shift-Backspace":n,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},o={...r},i={...r,"Ctrl-h":n,"Alt-Backspace":n,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return gi()||Wm()?i:o},addProseMirrorPlugins(){return[new $e({key:new ht("clearDocument"),appendTransaction:(n,e,t)=>{if(n.some(g=>g.getMeta("composition")))return;const r=n.some(g=>g.docChanged)&&!e.doc.eq(t.doc),o=n.some(g=>g.getMeta("preventClearDocument"));if(!r||o)return;const{empty:i,from:s,to:l}=e.selection,a=te.atStart(e.doc).from,c=te.atEnd(e.doc).to;if(i||!(s===a&&l===c)||!bi(t.doc))return;const f=t.tr,p=ui({state:t,transaction:f}),{commands:m}=new di({editor:this.editor,state:p});if(m.clearNodes(),!!f.steps.length)return f}})]}}),Qx=lt.create({name:"paste",addProseMirrorPlugins(){return[new $e({key:new ht("tiptapPaste"),props:{handlePaste:(n,e,t)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:t})}}})]}}),ew=lt.create({name:"tabindex",addProseMirrorPlugins(){return[new $e({key:new ht("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});class Cn{get name(){return this.node.type.name}constructor(e,t,r=!1,o=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=t,this.currentNode=o}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!==null&&e!==void 0?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}t=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:t,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),t=this.resolvedPos.doc.resolve(e);return new Cn(t,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new Cn(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 Cn(e,this.editor)}get children(){const e=[];return this.node.content.forEach((t,r)=>{const o=t.isBlock&&!t.isTextblock,i=t.isAtom&&!t.isText,s=this.pos+r+(i?0:1),l=this.resolvedPos.doc.resolve(s);if(!o&&l.depth<=this.depth)return;const a=new Cn(l,this.editor,o,o?t:null);o&&(a.actualDepth=this.depth+1),e.push(new Cn(l,this.editor,o,o?t:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,t={}){let r=null,o=this.parent;for(;o&&!r;)o.node.type.name===e&&(Object.keys(t).length>0||(r=o)),o=o.parent;return r}querySelector(e,t={}){return this.querySelectorAll(e,t,!0)[0]||null}querySelectorAll(e,t={},r=!1){let o=[];if(!this.children||this.children.length===0)return o;const i=Object.keys(t);return this.children.forEach(s=>{r&&o.length>0||(s.node.type.name===e&&i.every(a=>t[a]===s.node.attrs[a])&&o.push(s),!(r&&o.length>0)&&(o=o.concat(s.querySelectorAll(e,t,r))))}),o}setAttribute(e){const{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}}const tw=`.ProseMirror {
14
+ position: relative;
15
+ }
16
+
17
+ .ProseMirror {
18
+ word-wrap: break-word;
19
+ white-space: pre-wrap;
20
+ white-space: break-spaces;
21
+ -webkit-font-variant-ligatures: none;
22
+ font-variant-ligatures: none;
23
+ font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
24
+ }
25
+
26
+ .ProseMirror [contenteditable="false"] {
27
+ white-space: normal;
28
+ }
29
+
30
+ .ProseMirror [contenteditable="false"] [contenteditable="true"] {
31
+ white-space: pre-wrap;
32
+ }
33
+
34
+ .ProseMirror pre {
35
+ white-space: pre-wrap;
36
+ }
37
+
38
+ img.ProseMirror-separator {
39
+ display: inline !important;
40
+ border: none !important;
41
+ margin: 0 !important;
42
+ width: 0 !important;
43
+ height: 0 !important;
44
+ }
45
+
46
+ .ProseMirror-gapcursor {
47
+ display: none;
48
+ pointer-events: none;
49
+ position: absolute;
50
+ margin: 0;
51
+ }
52
+
53
+ .ProseMirror-gapcursor:after {
54
+ content: "";
55
+ display: block;
56
+ position: absolute;
57
+ top: -2px;
58
+ width: 20px;
59
+ border-top: 1px solid black;
60
+ animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
61
+ }
62
+
63
+ @keyframes ProseMirror-cursor-blink {
64
+ to {
65
+ visibility: hidden;
66
+ }
67
+ }
68
+
69
+ .ProseMirror-hideselection *::selection {
70
+ background: transparent;
71
+ }
72
+
73
+ .ProseMirror-hideselection *::-moz-selection {
74
+ background: transparent;
75
+ }
76
+
77
+ .ProseMirror-hideselection * {
78
+ caret-color: transparent;
79
+ }
80
+
81
+ .ProseMirror-focused .ProseMirror-gapcursor {
82
+ display: block;
83
+ }
84
+
85
+ .tippy-box[data-animation=fade][data-state=hidden] {
86
+ opacity: 0
87
+ }`;function nw(n,e,t){const r=document.querySelector("style[data-tiptap-style]");if(r!==null)return r;const o=document.createElement("style");return e&&o.setAttribute("nonce",e),o.setAttribute("data-tiptap-style",""),o.innerHTML=n,document.getElementsByTagName("head")[0].appendChild(o),o}class rw extends pv{constructor(e={}){super(),this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.options={element:document.createElement("div"),content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:t})=>{throw t},onPaste:()=>null,onDrop:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("contentError",this.options.onContentError),this.createView(),this.injectCSS(),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:t,slice:r,moved:o})=>this.options.onDrop(t,r,o)),this.on("paste",({event:t,slice:r})=>this.options.onPaste(t,r)),window.setTimeout(()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&document&&(this.css=nw(tw,this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},!(!this.view||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(e,t=!0){this.setOptions({editable:e}),t&&this.emit("update",{editor:this,transaction:this.state.tr})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get state(){return this.view.state}registerPlugin(e,t){const r=Lm(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],o=this.state.reconfigure({plugins:r});return this.view.updateState(o),o}unregisterPlugin(e){if(this.isDestroyed)return;const t=this.state.plugins;let r=t;if([].concat(e).forEach(i=>{const s=typeof i=="string"?`${i}$`:i.key;r=t.filter(l=>!l.key.startsWith(s))}),t.length===r.length)return;const o=this.state.reconfigure({plugins:r});return this.view.updateState(o),o}createExtensionManager(){var e,t;const o=[...this.options.enableCoreExtensions?[Jx,Mv.configure({blockSeparator:(t=(e=this.options.coreExtensionOptions)===null||e===void 0?void 0:e.clipboardTextSerializer)===null||t===void 0?void 0:t.blockSeparator}),Gx,Zx,Yx,ew,Kx,Qx].filter(i=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[i.name]!==!1:!0):[],...this.options.extensions].filter(i=>["extension","node","mark"].includes(i==null?void 0:i.type));this.extensionManager=new er(o,this)}createCommandManager(){this.commandManager=new di({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){var e;let t;try{t=Aa(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(s){if(!(s instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(s.message))throw s;this.emit("contentError",{editor:this,error:s,disableCollaboration:()=>{this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(l=>l.name!=="collaboration"),this.createExtensionManager()}}),t=Aa(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}const r=Vm(t,this.options.autofocus);this.view=new _b(this.options.element,{...this.options.editorProps,attributes:{role:"textbox",...(e=this.options.editorProps)===null||e===void 0?void 0:e.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:Qn.create({doc:t,selection:r||void 0})});const o=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(o),this.createNodeViews(),this.prependClass();const i=this.view.dom;i.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`tiptap ${this.view.dom.className}`}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;const t=this.capturedTransaction;return this.capturedTransaction=null,t}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=e;return}e.steps.forEach(s=>{var l;return(l=this.capturedTransaction)===null||l===void 0?void 0:l.step(s)});return}const t=this.state.apply(e),r=!this.state.selection.eq(t.selection);this.emit("beforeTransaction",{editor:this,transaction:e,nextState:t}),this.view.updateState(t),this.emit("transaction",{editor:this,transaction:e}),r&&this.emit("selectionUpdate",{editor:this,transaction:e});const o=e.getMeta("focus"),i=e.getMeta("blur");o&&this.emit("focus",{editor:this,event:o.event,transaction:e}),i&&this.emit("blur",{editor:this,event:i.event,transaction:e}),!(!e.docChanged||e.getMeta("preventUpdate"))&&this.emit("update",{editor:this,transaction:e})}getAttributes(e){return Km(this.state,e)}isActive(e,t){const r=typeof e=="string"?e:null,o=typeof e=="string"?t:e;return Jm(this.state,r,o)}getJSON(){return this.state.doc.toJSON()}getHTML(){return vc(this.state.doc.content,this.schema)}getText(e){const{blockSeparator:t=`
88
+
89
+ `,textSerializers:r={}}=e||{};return wx(this.state.doc,{blockSeparator:t,textSerializers:{...$m(this.schema),...r}})}get isEmpty(){return bi(this.state.doc)}getCharacterCount(){return console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.'),this.state.doc.content.size-2}destroy(){if(this.emit("destroy"),this.view){const e=this.view.dom;e&&e.editor&&delete e.editor,this.view.destroy()}this.removeAllListeners()}get isDestroyed(){var e;return!(!((e=this.view)===null||e===void 0)&&e.docView)}$node(e,t){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelector(e,t))||null}$nodes(e,t){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelectorAll(e,t))||null}$pos(e){const t=this.state.doc.resolve(e);return new Cn(t,this)}get $doc(){return this.$pos(0)}}function ow(n){return new hi({find:n.find,handler:({state:e,range:t,match:r})=>{const o=le(n.getAttributes,void 0,r);if(o===!1||o===null)return null;const{tr:i}=e,s=r[r.length-1],l=r[0];if(s){const a=l.search(/\S/),c=t.from+l.indexOf(s),u=c+s.length;if(Sc(t.from,t.to,e.doc).filter(p=>p.mark.type.excluded.find(g=>g===n.type&&g!==p.mark.type)).filter(p=>p.to>c).length)return null;u<t.to&&i.delete(u,t.to),c>t.from&&i.delete(t.from+a,c);const f=t.from+a+s.length;i.addMark(t.from+a,f,n.type.create(o||{})),i.removeStoredMark(n.type)}}})}function ro(n){return new hi({find:n.find,handler:({state:e,range:t,match:r})=>{const o=le(n.getAttributes,void 0,r)||{},{tr:i}=e,s=t.from;let l=t.to;const a=n.type.create(o);if(r[1]){const c=r[0].lastIndexOf(r[1]);let u=s+c;u>l?u=l:l=u+r[1].length;const d=r[0][r[0].length-1];i.insertText(d,s+r[0].length-1),i.replaceWith(u,l,a)}else if(r[0]){const c=n.type.isInline?s:s-1;i.insert(c,n.type.create(o)).delete(i.mapping.map(s),i.mapping.map(l))}i.scrollIntoView()}})}function iw(n){return new hi({find:n.find,handler:({state:e,range:t,match:r})=>{const o=e.doc.resolve(t.from),i=le(n.getAttributes,void 0,r)||{};if(!o.node(-1).canReplaceWith(o.index(-1),o.indexAfter(-1),n.type))return null;e.tr.delete(t.from,t.to).setBlockType(t.from,t.from,n.type,i)}})}function sw(n){return new hi({find:n.find,handler:({state:e,range:t,match:r,chain:o})=>{const i=le(n.getAttributes,void 0,r)||{},s=e.tr.delete(t.from,t.to),a=s.doc.resolve(t.from).blockRange(),c=a&&rc(a,n.type,i);if(!c)return null;if(s.wrap(a,c),n.keepMarks&&n.editor){const{selection:d,storedMarks:f}=e,{splittableMarks:p}=n.editor.extensionManager,m=f||d.$to.parentOffset&&d.$from.marks();if(m){const g=m.filter(y=>p.includes(y.type.name));s.ensureMarks(g)}}if(n.keepAttributes){const d=n.type.name==="bulletList"||n.type.name==="orderedList"?"listItem":"taskList";o().updateAttributes(d,i).run()}const u=s.doc.resolve(t.from-1).nodeBefore;u&&u.type===n.type&&hn(s.doc,t.from-1)&&(!n.joinPredicate||n.joinPredicate(r,u))&&s.join(t.from-1)}})}class Je{constructor(e={}){this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=le(H(this,"addOptions",{name:this.name}))),this.storage=le(H(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new Je(e)}configure(e={}){const t=this.extend({...this.config,addOptions:()=>pi(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const t=new Je(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=le(H(t,"addOptions",{name:t.name})),t.storage=le(H(t,"addStorage",{name:t.name,options:t.options})),t}}class lw{constructor(e,t,r){this.isDragging=!1,this.component=e,this.editor=t.editor,this.options={stopEvent:null,ignoreMutation:null,...r},this.extension=t.extension,this.node=t.node,this.decorations=t.decorations,this.innerDecorations=t.innerDecorations,this.view=t.view,this.HTMLAttributes=t.HTMLAttributes,this.getPos=t.getPos,this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(e){var t,r,o,i,s,l,a;const{view:c}=this.editor,u=e.target,d=u.nodeType===3?(t=u.parentElement)===null||t===void 0?void 0:t.closest("[data-drag-handle]"):u.closest("[data-drag-handle]");if(!this.dom||!((r=this.contentDOM)===null||r===void 0)&&r.contains(u)||!d)return;let f=0,p=0;if(this.dom!==d){const w=this.dom.getBoundingClientRect(),v=d.getBoundingClientRect(),S=(o=e.offsetX)!==null&&o!==void 0?o:(i=e.nativeEvent)===null||i===void 0?void 0:i.offsetX,T=(s=e.offsetY)!==null&&s!==void 0?s:(l=e.nativeEvent)===null||l===void 0?void 0:l.offsetY;f=v.x-w.x+S,p=v.y-w.y+T}const m=this.dom.cloneNode(!0);(a=e.dataTransfer)===null||a===void 0||a.setDragImage(m,f,p);const g=this.getPos();if(typeof g!="number")return;const y=K.create(c.state.doc,g),b=c.state.tr.setSelection(y);c.dispatch(b)}stopEvent(e){var t;if(!this.dom)return!1;if(typeof this.options.stopEvent=="function")return this.options.stopEvent({event:e});const r=e.target;if(!(this.dom.contains(r)&&!(!((t=this.contentDOM)===null||t===void 0)&&t.contains(r))))return!1;const i=e.type.startsWith("drag"),s=e.type==="drop";if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(r.tagName)||r.isContentEditable)&&!s&&!i)return!0;const{isEditable:a}=this.editor,{isDragging:c}=this,u=!!this.node.type.spec.draggable,d=K.isSelectable(this.node),f=e.type==="copy",p=e.type==="paste",m=e.type==="cut",g=e.type==="mousedown";if(!u&&d&&i&&e.target===this.dom&&e.preventDefault(),u&&i&&!c&&e.target===this.dom)return e.preventDefault(),!1;if(u&&a&&!c&&g){const y=r.closest("[data-drag-handle]");y&&(this.dom===y||this.dom.contains(y))&&(this.isDragging=!0,document.addEventListener("dragend",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("drop",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("mouseup",()=>{this.isDragging=!1},{once:!0}))}return!(c||s||f||p||m||g&&d)}ignoreMutation(e){return!this.dom||!this.contentDOM?!0:typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:e}):this.node.isLeaf||this.node.isAtom?!0:e.type==="selection"||this.dom.contains(e.target)&&e.type==="childList"&&(gi()||Hm())&&this.editor.isFocused&&[...Array.from(e.addedNodes),...Array.from(e.removedNodes)].every(r=>r.isContentEditable)?!1:this.contentDOM===e.target&&e.type==="attributes"?!0:!this.contentDOM.contains(e.target)}updateAttributes(e){this.editor.commands.command(({tr:t})=>{const r=this.getPos();return typeof r!="number"?!1:(t.setNodeMarkup(r,void 0,{...this.node.attrs,...e}),!0)})}deleteNode(){const e=this.getPos();if(typeof e!="number")return;const t=e+this.node.nodeSize;this.editor.commands.deleteRange({from:e,to:t})}}function aw(n){return new Bm({find:n.find,handler:({state:e,range:t,match:r,pasteEvent:o})=>{const i=le(n.getAttributes,void 0,r,o);if(i===!1||i===null)return null;const{tr:s}=e,l=r[r.length-1],a=r[0];let c=t.to;if(l){const u=a.search(/\S/),d=t.from+a.indexOf(l),f=d+l.length;if(Sc(t.from,t.to,e.doc).filter(m=>m.mark.type.excluded.find(y=>y===n.type&&y!==m.mark.type)).filter(m=>m.to>d).length)return null;f<t.to&&s.delete(f,t.to),d>t.from&&s.delete(t.from+u,d),c=t.from+u+l.length,s.addMark(t.from+u,c,n.type.create(i||{})),s.removeStoredMark(n.type)}}})}function cw(n){return n.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}function uw(n){return new Bm({find:n.find,handler({match:e,chain:t,range:r,pasteEvent:o}){const i=le(n.getAttributes,void 0,e,o),s=le(n.getContent,void 0,i);if(i===!1||i===null)return null;const l={type:n.type.name,attrs:i};s&&(l.content=s),e.input&&t().deleteRange(r).insertContentAt(r.from,l)}})}class dw{constructor({editor:e,element:t,view:r,tippyOptions:o={},updateDelay:i=250,shouldShow:s}){this.preventHide=!1,this.shouldShow=({view:l,state:a,from:c,to:u})=>{const{doc:d,selection:f}=a,{empty:p}=f,m=!d.textBetween(c,u).length&&wc(a.selection),g=this.element.contains(document.activeElement);return!(!(l.hasFocus()||g)||p||m||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:l})=>{var a;if(this.preventHide){this.preventHide=!1;return}l!=null&&l.relatedTarget&&(!((a=this.element.parentNode)===null||a===void 0)&&a.contains(l.relatedTarget))||(l==null?void 0:l.relatedTarget)!==this.editor.view.dom&&this.hide()},this.tippyBlurHandler=l=>{this.blurHandler({event:l})},this.handleDebouncedUpdate=(l,a)=>{const c=!(a!=null&&a.selection.eq(l.state.selection)),u=!(a!=null&&a.doc.eq(l.state.doc));!c&&!u||(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(l,c,u,a)},this.updateDelay))},this.updateHandler=(l,a,c,u)=>{var d,f,p;const{state:m,composing:g}=l,{selection:y}=m;if(g||!a&&!c)return;this.createTooltip();const{ranges:w}=y,v=Math.min(...w.map(C=>C.$from.pos)),S=Math.max(...w.map(C=>C.$to.pos));if(!((d=this.shouldShow)===null||d===void 0?void 0:d.call(this,{editor:this.editor,element:this.element,view:l,state:m,oldState:u,from:v,to:S}))){this.hide();return}(f=this.tippy)===null||f===void 0||f.setProps({getReferenceClientRect:((p=this.tippyOptions)===null||p===void 0?void 0:p.getReferenceClientRect)||(()=>{if(Xm(m.selection)){let C=l.nodeDOM(v);if(C){const I=C.dataset.nodeViewWrapper?C:C.querySelector("[data-node-view-wrapper]");if(I&&(C=I.firstChild),C)return C.getBoundingClientRect()}}return Ex(l,v,S)})}),this.show()},this.editor=e,this.element=t,this.view=r,this.updateDelay=i,s&&(this.shouldShow=s),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.tippyOptions=o,this.element.remove(),this.element.style.visibility="visible"}createTooltip(){const{element:e}=this.editor.options,t=!!e.parentElement;this.tippy||!t||(this.tippy=t0(e,{duration:0,getReferenceClientRect:null,content:this.element,interactive:!0,trigger:"manual",placement:"top",hideOnClick:"toggle",...this.tippyOptions}),this.tippy.popper.firstChild&&this.tippy.popper.firstChild.addEventListener("blur",this.tippyBlurHandler))}update(e,t){const{state:r}=e,o=r.selection.from!==r.selection.to;if(this.updateDelay>0&&o){this.handleDebouncedUpdate(e,t);return}const i=!(t!=null&&t.selection.eq(e.state.selection)),s=!(t!=null&&t.doc.eq(e.state.doc));this.updateHandler(e,i,s,t)}show(){var e;(e=this.tippy)===null||e===void 0||e.show()}hide(){var e;(e=this.tippy)===null||e===void 0||e.hide()}destroy(){var e,t;!((e=this.tippy)===null||e===void 0)&&e.popper.firstChild&&this.tippy.popper.firstChild.removeEventListener("blur",this.tippyBlurHandler),(t=this.tippy)===null||t===void 0||t.destroy(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener("dragstart",this.dragstartHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler)}}const Zm=n=>new $e({key:typeof n.pluginKey=="string"?new ht(n.pluginKey):n.pluginKey,view:e=>new dw({view:e,...n})});lt.create({name:"bubbleMenu",addOptions(){return{element:null,tippyOptions:{},pluginKey:"bubbleMenu",updateDelay:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[Zm({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,tippyOptions:this.options.tippyOptions,updateDelay:this.options.updateDelay,shouldShow:this.options.shouldShow})]:[]}});function fw(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Ia={exports:{}},is={};/**
90
+ * @license React
91
+ * use-sync-external-store-shim.production.min.js
92
+ *
93
+ * Copyright (c) Facebook, Inc. and its affiliates.
94
+ *
95
+ * This source code is licensed under the MIT license found in the
96
+ * LICENSE file in the root directory of this source tree.
97
+ */var kd;function hw(){if(kd)return is;kd=1;var n=x;function e(d,f){return d===f&&(d!==0||1/d===1/f)||d!==d&&f!==f}var t=typeof Object.is=="function"?Object.is:e,r=n.useState,o=n.useEffect,i=n.useLayoutEffect,s=n.useDebugValue;function l(d,f){var p=f(),m=r({inst:{value:p,getSnapshot:f}}),g=m[0].inst,y=m[1];return i(function(){g.value=p,g.getSnapshot=f,a(g)&&y({inst:g})},[d,p,f]),o(function(){return a(g)&&y({inst:g}),d(function(){a(g)&&y({inst:g})})},[d]),s(p),p}function a(d){var f=d.getSnapshot;d=d.value;try{var p=f();return!t(d,p)}catch{return!0}}function c(d,f){return f()}var u=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?c:l;return is.useSyncExternalStore=n.useSyncExternalStore!==void 0?n.useSyncExternalStore:u,is}var ss={};/**
98
+ * @license React
99
+ * use-sync-external-store-shim.development.js
100
+ *
101
+ * Copyright (c) Facebook, Inc. and its affiliates.
102
+ *
103
+ * This source code is licensed under the MIT license found in the
104
+ * LICENSE file in the root directory of this source tree.
105
+ */var Ed;function pw(){return Ed||(Ed=1,process.env.NODE_ENV!=="production"&&function(){typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var n=x,e=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function t(v){{for(var S=arguments.length,T=new Array(S>1?S-1:0),C=1;C<S;C++)T[C-1]=arguments[C];r("error",v,T)}}function r(v,S,T){{var C=e.ReactDebugCurrentFrame,I=C.getStackAddendum();I!==""&&(S+="%s",T=T.concat([I]));var O=T.map(function(E){return String(E)});O.unshift("Warning: "+S),Function.prototype.apply.call(console[v],console,O)}}function o(v,S){return v===S&&(v!==0||1/v===1/S)||v!==v&&S!==S}var i=typeof Object.is=="function"?Object.is:o,s=n.useState,l=n.useEffect,a=n.useLayoutEffect,c=n.useDebugValue,u=!1,d=!1;function f(v,S,T){u||n.startTransition!==void 0&&(u=!0,t("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var C=S();if(!d){var I=S();i(C,I)||(t("The result of getSnapshot should be cached to avoid an infinite loop"),d=!0)}var O=s({inst:{value:C,getSnapshot:S}}),E=O[0].inst,R=O[1];return a(function(){E.value=C,E.getSnapshot=S,p(E)&&R({inst:E})},[v,C,S]),l(function(){p(E)&&R({inst:E});var _=function(){p(E)&&R({inst:E})};return v(_)},[v]),c(C),C}function p(v){var S=v.getSnapshot,T=v.value;try{var C=S();return!i(T,C)}catch{return!0}}function m(v,S,T){return S()}var g=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",y=!g,b=y?m:f,w=n.useSyncExternalStore!==void 0?n.useSyncExternalStore:b;ss.useSyncExternalStore=w,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),ss}process.env.NODE_ENV==="production"?Ia.exports=hw():Ia.exports=pw();var vi=Ia.exports;const mw=(...n)=>e=>{n.forEach(t=>{typeof t=="function"?t(e):t&&(t.current=e)})},gw=({contentComponent:n})=>{const e=vi.useSyncExternalStore(n.subscribe,n.getSnapshot,n.getServerSnapshot);return x.createElement(x.Fragment,null,Object.values(e))};function yw(){const n=new Set;let e={};return{subscribe(t){return n.add(t),()=>{n.delete(t)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(t,r){e={...e,[t]:ec.createPortal(r.reactElement,r.element,t)},n.forEach(o=>o())},removeRenderer(t){const r={...e};delete r[t],e=r,n.forEach(o=>o())}}}class bw extends x.Component{constructor(e){var t;super(e),this.editorContentRef=x.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!(!((t=e.editor)===null||t===void 0)&&t.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){const e=this.props.editor;if(e&&!e.isDestroyed&&e.options.element){if(e.contentComponent)return;const t=this.editorContentRef.current;t.append(...e.options.element.childNodes),e.setOptions({element:t}),e.contentComponent=yw(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=e.contentComponent.subscribe(()=>{this.setState(r=>r.hasContentComponentInitialized?r:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),e.createNodeViews(),this.initialized=!0}}componentWillUnmount(){const e=this.props.editor;if(!e||(this.initialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),e.contentComponent=null,!e.options.element.firstChild))return;const t=document.createElement("div");t.append(...e.options.element.childNodes),e.setOptions({element:t})}render(){const{editor:e,innerRef:t,...r}=this.props;return x.createElement(x.Fragment,null,x.createElement("div",{ref:mw(t,this.editorContentRef),...r}),(e==null?void 0:e.contentComponent)&&x.createElement(gw,{contentComponent:e.contentComponent}))}}const vw=x.forwardRef((n,e)=>{const t=x.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[n.editor]);return x.createElement(bw,{key:t,innerRef:e,...n})}),xw=x.memo(vw);var ww=function n(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){if(e.constructor!==t.constructor)return!1;var r,o,i;if(Array.isArray(e)){if(r=e.length,r!=t.length)return!1;for(o=r;o--!==0;)if(!n(e[o],t[o]))return!1;return!0}if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(o of e.entries())if(!t.has(o[0]))return!1;for(o of e.entries())if(!n(o[1],t.get(o[0])))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(o of e.entries())if(!t.has(o[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){if(r=e.length,r!=t.length)return!1;for(o=r;o--!==0;)if(e[o]!==t[o])return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString();if(i=Object.keys(e),r=i.length,r!==Object.keys(t).length)return!1;for(o=r;o--!==0;)if(!Object.prototype.hasOwnProperty.call(t,i[o]))return!1;for(o=r;o--!==0;){var s=i[o];if(!(s==="_owner"&&e.$$typeof)&&!n(e[s],t[s]))return!1}return!0}return e!==e&&t!==t},Sw=fw(ww),_a={exports:{}},ls={};/**
106
+ * @license React
107
+ * use-sync-external-store-shim/with-selector.production.min.js
108
+ *
109
+ * Copyright (c) Facebook, Inc. and its affiliates.
110
+ *
111
+ * This source code is licensed under the MIT license found in the
112
+ * LICENSE file in the root directory of this source tree.
113
+ */var Md;function Cw(){if(Md)return ls;Md=1;var n=x,e=vi;function t(c,u){return c===u&&(c!==0||1/c===1/u)||c!==c&&u!==u}var r=typeof Object.is=="function"?Object.is:t,o=e.useSyncExternalStore,i=n.useRef,s=n.useEffect,l=n.useMemo,a=n.useDebugValue;return ls.useSyncExternalStoreWithSelector=function(c,u,d,f,p){var m=i(null);if(m.current===null){var g={hasValue:!1,value:null};m.current=g}else g=m.current;m=l(function(){function b(C){if(!w){if(w=!0,v=C,C=f(C),p!==void 0&&g.hasValue){var I=g.value;if(p(I,C))return S=I}return S=C}if(I=S,r(v,C))return I;var O=f(C);return p!==void 0&&p(I,O)?I:(v=C,S=O)}var w=!1,v,S,T=d===void 0?null:d;return[function(){return b(u())},T===null?void 0:function(){return b(T())}]},[u,d,f,p]);var y=o(c,m[0],m[1]);return s(function(){g.hasValue=!0,g.value=y},[y]),a(y),y},ls}var as={};/**
114
+ * @license React
115
+ * use-sync-external-store-shim/with-selector.development.js
116
+ *
117
+ * Copyright (c) Facebook, Inc. and its affiliates.
118
+ *
119
+ * This source code is licensed under the MIT license found in the
120
+ * LICENSE file in the root directory of this source tree.
121
+ */var Od;function Tw(){return Od||(Od=1,process.env.NODE_ENV!=="production"&&function(){typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var n=x,e=vi;function t(u,d){return u===d&&(u!==0||1/u===1/d)||u!==u&&d!==d}var r=typeof Object.is=="function"?Object.is:t,o=e.useSyncExternalStore,i=n.useRef,s=n.useEffect,l=n.useMemo,a=n.useDebugValue;function c(u,d,f,p,m){var g=i(null),y;g.current===null?(y={hasValue:!1,value:null},g.current=y):y=g.current;var b=l(function(){var T=!1,C,I,O=function(N){if(!T){T=!0,C=N;var D=p(N);if(m!==void 0&&y.hasValue){var k=y.value;if(m(k,D))return I=k,k}return I=D,D}var L=C,F=I;if(r(L,N))return F;var V=p(N);return m!==void 0&&m(F,V)?F:(C=N,I=V,V)},E=f===void 0?null:f,R=function(){return O(d())},_=E===null?void 0:function(){return O(E())};return[R,_]},[d,f,p,m]),w=b[0],v=b[1],S=o(u,w,v);return s(function(){y.hasValue=!0,y.value=S},[S]),a(S),S}as.useSyncExternalStoreWithSelector=c,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),as}process.env.NODE_ENV==="production"?_a.exports=Cw():_a.exports=Tw();var kw=_a.exports;const Ew=typeof window<"u"?x.useLayoutEffect:x.useEffect;class Mw{constructor(e){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=e,this.lastSnapshot={editor:e,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}watch(e){if(this.editor=e,this.editor){const t=()=>{this.transactionNumber+=1,this.subscribers.forEach(o=>o())},r=this.editor;return r.on("transaction",t),()=>{r.off("transaction",t)}}}}function Ow(n){var e;const[t]=x.useState(()=>new Mw(n.editor)),r=kw.useSyncExternalStoreWithSelector(t.subscribe,t.getSnapshot,t.getServerSnapshot,n.selector,(e=n.equalityFn)!==null&&e!==void 0?e:Sw);return Ew(()=>t.watch(n.editor),[n.editor,t]),x.useDebugValue(r),r}const Ad=process.env.NODE_ENV!=="production",Da=typeof window>"u",Aw=Da||!!(typeof window<"u"&&window.next);class Cc{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(t=>t())}getInitialEditor(){if(this.options.current.immediatelyRender===void 0)return Da||Aw?(Ad&&console.warn("Tiptap Error: SSR has been detected, please set `immediatelyRender` explicitly to `false` to avoid hydration mismatches."),null):this.createEditor();if(this.options.current.immediatelyRender&&Da&&Ad)throw new Error("Tiptap Error: SSR has been detected, and `immediatelyRender` has been set to `true` this is an unsupported configuration that may result in errors, explicitly set `immediatelyRender` to `false` to avoid hydration mismatches.");return this.options.current.immediatelyRender?this.createEditor():null}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var o,i;return(i=(o=this.options.current).onBeforeCreate)===null||i===void 0?void 0:i.call(o,...r)},onBlur:(...r)=>{var o,i;return(i=(o=this.options.current).onBlur)===null||i===void 0?void 0:i.call(o,...r)},onCreate:(...r)=>{var o,i;return(i=(o=this.options.current).onCreate)===null||i===void 0?void 0:i.call(o,...r)},onDestroy:(...r)=>{var o,i;return(i=(o=this.options.current).onDestroy)===null||i===void 0?void 0:i.call(o,...r)},onFocus:(...r)=>{var o,i;return(i=(o=this.options.current).onFocus)===null||i===void 0?void 0:i.call(o,...r)},onSelectionUpdate:(...r)=>{var o,i;return(i=(o=this.options.current).onSelectionUpdate)===null||i===void 0?void 0:i.call(o,...r)},onTransaction:(...r)=>{var o,i;return(i=(o=this.options.current).onTransaction)===null||i===void 0?void 0:i.call(o,...r)},onUpdate:(...r)=>{var o,i;return(i=(o=this.options.current).onUpdate)===null||i===void 0?void 0:i.call(o,...r)},onContentError:(...r)=>{var o,i;return(i=(o=this.options.current).onContentError)===null||i===void 0?void 0:i.call(o,...r)},onDrop:(...r)=>{var o,i;return(i=(o=this.options.current).onDrop)===null||i===void 0?void 0:i.call(o,...r)},onPaste:(...r)=>{var o,i;return(i=(o=this.options.current).onPaste)===null||i===void 0?void 0:i.call(o,...r)}};return new rw(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,t){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&t.extensions?e.extensions.length!==t.extensions.length?!1:e.extensions.every((o,i)=>{var s;return o===((s=t.extensions)===null||s===void 0?void 0:s[i])}):e[r]===t[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?Cc.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,o)=>r===e[o]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,t=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){t&&t.setOptions(this.options.current);return}t&&!t.isDestroyed&&(t.destroy(),this.instanceId===e&&this.setEditor(null))},1)}}function Nw(n={},e=[]){const t=x.useRef(n);t.current=n;const[r]=x.useState(()=>new Cc(t)),o=vi.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return x.useDebugValue(o),x.useEffect(r.onRender(e)),Ow({editor:o,selector:({transactionNumber:i})=>n.shouldRerenderOnTransaction===!1?null:n.immediatelyRender&&i===0?0:i+1}),o}const Rw=x.createContext({editor:null}),Iw=()=>x.useContext(Rw),_w=n=>{const[e,t]=x.useState(null),{editor:r}=Iw();return x.useEffect(()=>{var o;if(!e||!((o=n.editor)===null||o===void 0)&&o.isDestroyed||r!=null&&r.isDestroyed)return;const{pluginKey:i="bubbleMenu",editor:s,tippyOptions:l={},updateDelay:a,shouldShow:c=null}=n,u=s||r;if(!u){console.warn("BubbleMenu component is not rendered inside of an editor component or does not have editor prop.");return}const d=Zm({updateDelay:a,editor:u,element:e,pluginKey:i,shouldShow:c,tippyOptions:l});return u.registerPlugin(d),()=>{u.unregisterPlugin(i)}},[n.editor,r,e]),x.createElement("div",{ref:t,className:n.className,style:{visibility:"hidden"}},n.children)},Ym=x.createContext({onDragStart:void 0}),Qm=()=>x.useContext(Ym),Dw=n=>{const e=n.as||"div",{nodeViewContentRef:t}=Qm();return x.createElement(e,{...n,ref:t,"data-node-view-content":"",style:{whiteSpace:"pre-wrap",...n.style}})},Ht=x.forwardRef((n,e)=>{const{onDragStart:t}=Qm(),r=n.as||"div";return x.createElement(r,{...n,ref:e,"data-node-view-wrapper":"",onDragStart:t,style:{whiteSpace:"normal",...n.style}})});function jw(n){return!!(typeof n=="function"&&n.prototype&&n.prototype.isReactComponent)}function Pw(n){var e;return typeof n=="object"&&((e=n.$$typeof)===null||e===void 0?void 0:e.toString())==="Symbol(react.forward_ref)"}class eg{constructor(e,{editor:t,props:r={},as:o="div",className:i=""}){this.ref=null,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=e,this.editor=t,this.props=r,this.element=document.createElement(o),this.element.classList.add("react-renderer"),i&&this.element.classList.add(...i.split(" ")),this.editor.isInitialized?ec.flushSync(()=>{this.render()}):this.render()}render(){var e;const t=this.component,r=this.props,o=this.editor;(jw(t)||Pw(t))&&(r.ref=i=>{this.ref=i}),this.reactElement=x.createElement(t,{...r}),(e=o==null?void 0:o.contentComponent)===null||e===void 0||e.setRenderer(this.id,this)}updateProps(e={}){this.props={...this.props,...e},this.render()}destroy(){var e;const t=this.editor;(e=t==null?void 0:t.contentComponent)===null||e===void 0||e.removeRenderer(this.id)}updateAttributes(e){Object.keys(e).forEach(t=>{this.element.setAttribute(t,e[t])})}}class Lw extends lw{mount(){const e={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extension,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(c={})=>this.updateAttributes(c),deleteNode:()=>this.deleteNode()};if(!this.component.displayName){const c=u=>u.charAt(0).toUpperCase()+u.substring(1);this.component.displayName=c(this.extension.name)}const o={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:c=>{c&&this.contentDOMElement&&c.firstChild!==this.contentDOMElement&&c.appendChild(this.contentDOMElement)}},i=this.component,s=x.memo(c=>x.createElement(Ym.Provider,{value:o},x.createElement(i,c)));s.displayName="ReactNodeView",this.node.isLeaf?this.contentDOMElement=null:this.options.contentDOMElementTag?this.contentDOMElement=document.createElement(this.options.contentDOMElementTag):this.contentDOMElement=document.createElement(this.node.isInline?"span":"div"),this.contentDOMElement&&(this.contentDOMElement.dataset.nodeViewContentReact="",this.contentDOMElement.style.whiteSpace="inherit");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 eg(s,{editor:this.editor,props:e,as:l,className:`node-${this.node.type.name} ${a}`.trim()}),this.editor.on("selectionUpdate",this.handleSelectionUpdate),this.updateElementAttributes()}get dom(){var e;if(this.renderer.element.firstElementChild&&!(!((e=this.renderer.element.firstElementChild)===null||e===void 0)&&e.hasAttribute("data-node-view-wrapper")))throw Error("Please use the NodeViewWrapper component for your node view.");return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}handleSelectionUpdate(){const{from:e,to:t}=this.editor.state.selection,r=this.getPos();if(typeof r=="number")if(e<=r&&t>=r+this.node.nodeSize){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}}update(e,t,r){const o=i=>{this.renderer.updateProps(i),typeof this.options.attrs=="function"&&this.updateElementAttributes()};if(e.type!==this.node.type)return!1;if(typeof this.options.update=="function"){const i=this.node,s=this.decorations,l=this.innerDecorations;return this.node=e,this.decorations=t,this.innerDecorations=r,this.options.update({oldNode:i,oldDecorations:s,newNode:e,newDecorations:t,oldInnerDecorations:l,innerDecorations:r,updateProps:()=>o({node:e,decorations:t,innerDecorations:r})})}return e===this.node&&this.decorations===t&&this.innerDecorations===r||(this.node=e,this.decorations=t,this.innerDecorations=r,o({node:e,decorations:t,innerDecorations:r})),!0}selectNode(){this.renderer.updateProps({selected:!0}),this.renderer.element.classList.add("ProseMirror-selectednode")}deselectNode(){this.renderer.updateProps({selected:!1}),this.renderer.element.classList.remove("ProseMirror-selectednode")}destroy(){this.renderer.destroy(),this.editor.off("selectionUpdate",this.handleSelectionUpdate),this.contentDOMElement=null}updateElementAttributes(){if(this.options.attrs){let e={};if(typeof this.options.attrs=="function"){const t=this.editor.extensionManager.attributes,r=Yo(this.node,t);e=this.options.attrs({node:this.node,HTMLAttributes:r})}else e=this.options.attrs;this.renderer.updateAttributes(e)}}}function qt(n,e){return t=>t.editor.contentComponent?new Lw(n,t,e):{}}var tg=typeof global=="object"&&global&&global.Object===Object&&global,Bw=typeof self=="object"&&self&&self.Object===Object&&self,Tc=tg||Bw||Function("return this")(),Ur=Tc.Symbol,ng=Object.prototype,zw=ng.hasOwnProperty,$w=ng.toString,xr=Ur?Ur.toStringTag:void 0;function Fw(n){var e=zw.call(n,xr),t=n[xr];try{n[xr]=void 0;var r=!0}catch{}var o=$w.call(n);return r&&(e?n[xr]=t:delete n[xr]),o}var Vw=Object.prototype,Hw=Vw.toString;function qw(n){return Hw.call(n)}var Ww="[object Null]",Uw="[object Undefined]",Nd=Ur?Ur.toStringTag:void 0;function kc(n){return n==null?n===void 0?Uw:Ww:Nd&&Nd in Object(n)?Fw(n):qw(n)}function Ec(n){return n!=null&&typeof n=="object"}var Gw="[object Symbol]";function rg(n){return typeof n=="symbol"||Ec(n)&&kc(n)==Gw}var Kw=/\s/;function Jw(n){for(var e=n.length;e--&&Kw.test(n.charAt(e)););return e}var Xw=/^\s+/;function Zw(n){return n&&n.slice(0,Jw(n)+1).replace(Xw,"")}function Gr(n){var e=typeof n;return n!=null&&(e=="object"||e=="function")}var Rd=NaN,Yw=/^[-+]0x[0-9a-f]+$/i,Qw=/^0b[01]+$/i,eS=/^0o[0-7]+$/i,tS=parseInt;function ir(n){if(typeof n=="number")return n;if(rg(n))return Rd;if(Gr(n)){var e=typeof n.valueOf=="function"?n.valueOf():n;n=Gr(e)?e+"":e}if(typeof n!="string")return n===0?n:+n;n=Zw(n);var t=Qw.test(n);return t||eS.test(n)?tS(n.slice(2),t?2:8):Yw.test(n)?Rd:+n}function nS(n,e,t){return n===n&&(t!==void 0&&(n=n<=t?n:t),e!==void 0&&(n=n>=e?n:e)),n}function og(n,e,t){return t===void 0&&(t=e,e=void 0),t!==void 0&&(t=ir(t),t=t===t?t:0),e!==void 0&&(e=ir(e),e=e===e?e:0),nS(ir(n),e,t)}var cs=function(){return Tc.Date.now()},rS="Expected a function",oS=Math.max,iS=Math.min;function xi(n,e,t){var r,o,i,s,l,a,c=0,u=!1,d=!1,f=!0;if(typeof n!="function")throw new TypeError(rS);e=ir(e)||0,Gr(t)&&(u=!!t.leading,d="maxWait"in t,i=d?oS(ir(t.maxWait)||0,e):i,f="trailing"in t?!!t.trailing:f);function p(C){var I=r,O=o;return r=o=void 0,c=C,s=n.apply(O,I),s}function m(C){return c=C,l=setTimeout(b,e),u?p(C):s}function g(C){var I=C-a,O=C-c,E=e-I;return d?iS(E,i-O):E}function y(C){var I=C-a,O=C-c;return a===void 0||I>=e||I<0||d&&O>=i}function b(){var C=cs();if(y(C))return w(C);l=setTimeout(b,g(C))}function w(C){return l=void 0,f&&r?p(C):(r=o=void 0,s)}function v(){l!==void 0&&clearTimeout(l),c=0,r=a=o=l=void 0}function S(){return l===void 0?s:w(cs())}function T(){var C=cs(),I=y(C);if(r=arguments,o=this,a=C,I){if(l===void 0)return m(a);if(d)return clearTimeout(l),l=setTimeout(b,e),p(a)}return l===void 0&&(l=setTimeout(b,e)),s}return T.cancel=v,T.flush=S,T}var sS="[object Number]";function ti(n){return typeof n=="number"||Ec(n)&&kc(n)==sS}var lS="Expected a function";function Vt(n,e,t){var r=!0,o=!0;if(typeof n!="function")throw new TypeError(lS);return Gr(t)&&(r="leading"in t?!!t.leading:r,o="trailing"in t?!!t.trailing:o),xi(n,e,{leading:r,maxWait:e,trailing:o})}function ig(n){var e,t,r="";if(typeof n=="string"||typeof n=="number")r+=n;else if(typeof n=="object")if(Array.isArray(n)){var o=n.length;for(e=0;e<o;e++)n[e]&&(t=ig(n[e]))&&(r&&(r+=" "),r+=t)}else for(t in n)n[t]&&(r&&(r+=" "),r+=t);return r}function st(){for(var n,e,t=0,r="",o=arguments.length;t<o;t++)(n=arguments[t])&&(e=ig(n))&&(r&&(r+=" "),r+=e);return r}const Mc="-",aS=n=>{const e=uS(n),{conflictingClassGroups:t,conflictingClassGroupModifiers:r}=n;return{getClassGroupId:s=>{const l=s.split(Mc);return l[0]===""&&l.length!==1&&l.shift(),sg(l,e)||cS(s)},getConflictingClassGroupIds:(s,l)=>{const a=t[s]||[];return l&&r[s]?[...a,...r[s]]:a}}},sg=(n,e)=>{var s;if(n.length===0)return e.classGroupId;const t=n[0],r=e.nextPart.get(t),o=r?sg(n.slice(1),r):void 0;if(o)return o;if(e.validators.length===0)return;const i=n.join(Mc);return(s=e.validators.find(({validator:l})=>l(i)))==null?void 0:s.classGroupId},Id=/^\[(.+)\]$/,cS=n=>{if(Id.test(n)){const e=Id.exec(n)[1],t=e==null?void 0:e.substring(0,e.indexOf(":"));if(t)return"arbitrary.."+t}},uS=n=>{const{theme:e,prefix:t}=n,r={nextPart:new Map,validators:[]};return fS(Object.entries(n.classGroups),t).forEach(([i,s])=>{ja(s,r,i,e)}),r},ja=(n,e,t,r)=>{n.forEach(o=>{if(typeof o=="string"){const i=o===""?e:_d(e,o);i.classGroupId=t;return}if(typeof o=="function"){if(dS(o)){ja(o(r),e,t,r);return}e.validators.push({validator:o,classGroupId:t});return}Object.entries(o).forEach(([i,s])=>{ja(s,_d(e,i),t,r)})})},_d=(n,e)=>{let t=n;return e.split(Mc).forEach(r=>{t.nextPart.has(r)||t.nextPart.set(r,{nextPart:new Map,validators:[]}),t=t.nextPart.get(r)}),t},dS=n=>n.isThemeGetter,fS=(n,e)=>e?n.map(([t,r])=>{const o=r.map(i=>typeof i=="string"?e+i:typeof i=="object"?Object.fromEntries(Object.entries(i).map(([s,l])=>[e+s,l])):i);return[t,o]}):n,hS=n=>{if(n<1)return{get:()=>{},set:()=>{}};let e=0,t=new Map,r=new Map;const o=(i,s)=>{t.set(i,s),e++,e>n&&(e=0,r=t,t=new Map)};return{get(i){let s=t.get(i);if(s!==void 0)return s;if((s=r.get(i))!==void 0)return o(i,s),s},set(i,s){t.has(i)?t.set(i,s):o(i,s)}}},lg="!",pS=n=>{const{separator:e,experimentalParseClassName:t}=n,r=e.length===1,o=e[0],i=e.length,s=l=>{const a=[];let c=0,u=0,d;for(let y=0;y<l.length;y++){let b=l[y];if(c===0){if(b===o&&(r||l.slice(y,y+i)===e)){a.push(l.slice(u,y)),u=y+i;continue}if(b==="/"){d=y;continue}}b==="["?c++:b==="]"&&c--}const f=a.length===0?l:l.substring(u),p=f.startsWith(lg),m=p?f.substring(1):f,g=d&&d>u?d-u:void 0;return{modifiers:a,hasImportantModifier:p,baseClassName:m,maybePostfixModifierPosition:g}};return t?l=>t({className:l,parseClassName:s}):s},mS=n=>{if(n.length<=1)return n;const e=[];let t=[];return n.forEach(r=>{r[0]==="["?(e.push(...t.sort(),r),t=[]):t.push(r)}),e.push(...t.sort()),e},gS=n=>({cache:hS(n.cacheSize),parseClassName:pS(n),...aS(n)}),yS=/\s+/,bS=(n,e)=>{const{parseClassName:t,getClassGroupId:r,getConflictingClassGroupIds:o}=e,i=[],s=n.trim().split(yS);let l="";for(let a=s.length-1;a>=0;a-=1){const c=s[a],{modifiers:u,hasImportantModifier:d,baseClassName:f,maybePostfixModifierPosition:p}=t(c);let m=!!p,g=r(m?f.substring(0,p):f);if(!g){if(!m){l=c+(l.length>0?" "+l:l);continue}if(g=r(f),!g){l=c+(l.length>0?" "+l:l);continue}m=!1}const y=mS(u).join(":"),b=d?y+lg:y,w=b+g;if(i.includes(w))continue;i.push(w);const v=o(g,m);for(let S=0;S<v.length;++S){const T=v[S];i.push(b+T)}l=c+(l.length>0?" "+l:l)}return l};function vS(){let n=0,e,t,r="";for(;n<arguments.length;)(e=arguments[n++])&&(t=ag(e))&&(r&&(r+=" "),r+=t);return r}const ag=n=>{if(typeof n=="string")return n;let e,t="";for(let r=0;r<n.length;r++)n[r]&&(e=ag(n[r]))&&(t&&(t+=" "),t+=e);return t};function xS(n,...e){let t,r,o,i=s;function s(a){const c=e.reduce((u,d)=>d(u),n());return t=gS(c),r=t.cache.get,o=t.cache.set,i=l,l(a)}function l(a){const c=r(a);if(c)return c;const u=bS(a,t);return o(a,u),u}return function(){return i(vS.apply(null,arguments))}}const ke=n=>{const e=t=>t[n]||[];return e.isThemeGetter=!0,e},cg=/^\[(?:([a-z-]+):)?(.+)\]$/i,wS=/^\d+\/\d+$/,SS=new Set(["px","full","screen"]),CS=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,TS=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,kS=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,ES=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,MS=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Dt=n=>sr(n)||SS.has(n)||wS.test(n),Kt=n=>hr(n,"length",jS),sr=n=>!!n&&!Number.isNaN(Number(n)),us=n=>hr(n,"number",sr),wr=n=>!!n&&Number.isInteger(Number(n)),OS=n=>n.endsWith("%")&&sr(n.slice(0,-1)),ae=n=>cg.test(n),Jt=n=>CS.test(n),AS=new Set(["length","size","percentage"]),NS=n=>hr(n,AS,ug),RS=n=>hr(n,"position",ug),IS=new Set(["image","url"]),_S=n=>hr(n,IS,LS),DS=n=>hr(n,"",PS),Sr=()=>!0,hr=(n,e,t)=>{const r=cg.exec(n);return r?r[1]?typeof e=="string"?r[1]===e:e.has(r[1]):t(r[2]):!1},jS=n=>TS.test(n)&&!kS.test(n),ug=()=>!1,PS=n=>ES.test(n),LS=n=>MS.test(n),BS=()=>{const n=ke("colors"),e=ke("spacing"),t=ke("blur"),r=ke("brightness"),o=ke("borderColor"),i=ke("borderRadius"),s=ke("borderSpacing"),l=ke("borderWidth"),a=ke("contrast"),c=ke("grayscale"),u=ke("hueRotate"),d=ke("invert"),f=ke("gap"),p=ke("gradientColorStops"),m=ke("gradientColorStopPositions"),g=ke("inset"),y=ke("margin"),b=ke("opacity"),w=ke("padding"),v=ke("saturate"),S=ke("scale"),T=ke("sepia"),C=ke("skew"),I=ke("space"),O=ke("translate"),E=()=>["auto","contain","none"],R=()=>["auto","hidden","clip","visible","scroll"],_=()=>["auto",ae,e],N=()=>[ae,e],D=()=>["",Dt,Kt],k=()=>["auto",sr,ae],L=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],F=()=>["solid","dashed","dotted","double","none"],V=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ue=()=>["start","end","center","between","around","evenly","stretch"],J=()=>["","0",ae],_e=()=>["auto","avoid","all","avoid-page","page","left","right","column"],de=()=>[sr,ae];return{cacheSize:500,separator:":",theme:{colors:[Sr],spacing:[Dt,Kt],blur:["none","",Jt,ae],brightness:de(),borderColor:[n],borderRadius:["none","","full",Jt,ae],borderSpacing:N(),borderWidth:D(),contrast:de(),grayscale:J(),hueRotate:de(),invert:J(),gap:N(),gradientColorStops:[n],gradientColorStopPositions:[OS,Kt],inset:_(),margin:_(),opacity:de(),padding:N(),saturate:de(),scale:de(),sepia:J(),skew:de(),space:N(),translate:N()},classGroups:{aspect:[{aspect:["auto","square","video",ae]}],container:["container"],columns:[{columns:[Jt]}],"break-after":[{"break-after":_e()}],"break-before":[{"break-before":_e()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...L(),ae]}],overflow:[{overflow:R()}],"overflow-x":[{"overflow-x":R()}],"overflow-y":[{"overflow-y":R()}],overscroll:[{overscroll:E()}],"overscroll-x":[{"overscroll-x":E()}],"overscroll-y":[{"overscroll-y":E()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[g]}],"inset-x":[{"inset-x":[g]}],"inset-y":[{"inset-y":[g]}],start:[{start:[g]}],end:[{end:[g]}],top:[{top:[g]}],right:[{right:[g]}],bottom:[{bottom:[g]}],left:[{left:[g]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",wr,ae]}],basis:[{basis:_()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",ae]}],grow:[{grow:J()}],shrink:[{shrink:J()}],order:[{order:["first","last","none",wr,ae]}],"grid-cols":[{"grid-cols":[Sr]}],"col-start-end":[{col:["auto",{span:["full",wr,ae]},ae]}],"col-start":[{"col-start":k()}],"col-end":[{"col-end":k()}],"grid-rows":[{"grid-rows":[Sr]}],"row-start-end":[{row:["auto",{span:[wr,ae]},ae]}],"row-start":[{"row-start":k()}],"row-end":[{"row-end":k()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",ae]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",ae]}],gap:[{gap:[f]}],"gap-x":[{"gap-x":[f]}],"gap-y":[{"gap-y":[f]}],"justify-content":[{justify:["normal",...ue()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...ue(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...ue(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[w]}],px:[{px:[w]}],py:[{py:[w]}],ps:[{ps:[w]}],pe:[{pe:[w]}],pt:[{pt:[w]}],pr:[{pr:[w]}],pb:[{pb:[w]}],pl:[{pl:[w]}],m:[{m:[y]}],mx:[{mx:[y]}],my:[{my:[y]}],ms:[{ms:[y]}],me:[{me:[y]}],mt:[{mt:[y]}],mr:[{mr:[y]}],mb:[{mb:[y]}],ml:[{ml:[y]}],"space-x":[{"space-x":[I]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[I]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",ae,e]}],"min-w":[{"min-w":[ae,e,"min","max","fit"]}],"max-w":[{"max-w":[ae,e,"none","full","min","max","fit","prose",{screen:[Jt]},Jt]}],h:[{h:[ae,e,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[ae,e,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[ae,e,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[ae,e,"auto","min","max","fit"]}],"font-size":[{text:["base",Jt,Kt]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",us]}],"font-family":[{font:[Sr]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",ae]}],"line-clamp":[{"line-clamp":["none",sr,us]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Dt,ae]}],"list-image":[{"list-image":["none",ae]}],"list-style-type":[{list:["none","disc","decimal",ae]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[n]}],"placeholder-opacity":[{"placeholder-opacity":[b]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[n]}],"text-opacity":[{"text-opacity":[b]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...F(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",Dt,Kt]}],"underline-offset":[{"underline-offset":["auto",Dt,ae]}],"text-decoration-color":[{decoration:[n]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:N()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",ae]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",ae]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[b]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...L(),RS]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",NS]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},_S]}],"bg-color":[{bg:[n]}],"gradient-from-pos":[{from:[m]}],"gradient-via-pos":[{via:[m]}],"gradient-to-pos":[{to:[m]}],"gradient-from":[{from:[p]}],"gradient-via":[{via:[p]}],"gradient-to":[{to:[p]}],rounded:[{rounded:[i]}],"rounded-s":[{"rounded-s":[i]}],"rounded-e":[{"rounded-e":[i]}],"rounded-t":[{"rounded-t":[i]}],"rounded-r":[{"rounded-r":[i]}],"rounded-b":[{"rounded-b":[i]}],"rounded-l":[{"rounded-l":[i]}],"rounded-ss":[{"rounded-ss":[i]}],"rounded-se":[{"rounded-se":[i]}],"rounded-ee":[{"rounded-ee":[i]}],"rounded-es":[{"rounded-es":[i]}],"rounded-tl":[{"rounded-tl":[i]}],"rounded-tr":[{"rounded-tr":[i]}],"rounded-br":[{"rounded-br":[i]}],"rounded-bl":[{"rounded-bl":[i]}],"border-w":[{border:[l]}],"border-w-x":[{"border-x":[l]}],"border-w-y":[{"border-y":[l]}],"border-w-s":[{"border-s":[l]}],"border-w-e":[{"border-e":[l]}],"border-w-t":[{"border-t":[l]}],"border-w-r":[{"border-r":[l]}],"border-w-b":[{"border-b":[l]}],"border-w-l":[{"border-l":[l]}],"border-opacity":[{"border-opacity":[b]}],"border-style":[{border:[...F(),"hidden"]}],"divide-x":[{"divide-x":[l]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[l]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[b]}],"divide-style":[{divide:F()}],"border-color":[{border:[o]}],"border-color-x":[{"border-x":[o]}],"border-color-y":[{"border-y":[o]}],"border-color-s":[{"border-s":[o]}],"border-color-e":[{"border-e":[o]}],"border-color-t":[{"border-t":[o]}],"border-color-r":[{"border-r":[o]}],"border-color-b":[{"border-b":[o]}],"border-color-l":[{"border-l":[o]}],"divide-color":[{divide:[o]}],"outline-style":[{outline:["",...F()]}],"outline-offset":[{"outline-offset":[Dt,ae]}],"outline-w":[{outline:[Dt,Kt]}],"outline-color":[{outline:[n]}],"ring-w":[{ring:D()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[n]}],"ring-opacity":[{"ring-opacity":[b]}],"ring-offset-w":[{"ring-offset":[Dt,Kt]}],"ring-offset-color":[{"ring-offset":[n]}],shadow:[{shadow:["","inner","none",Jt,DS]}],"shadow-color":[{shadow:[Sr]}],opacity:[{opacity:[b]}],"mix-blend":[{"mix-blend":[...V(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":V()}],filter:[{filter:["","none"]}],blur:[{blur:[t]}],brightness:[{brightness:[r]}],contrast:[{contrast:[a]}],"drop-shadow":[{"drop-shadow":["","none",Jt,ae]}],grayscale:[{grayscale:[c]}],"hue-rotate":[{"hue-rotate":[u]}],invert:[{invert:[d]}],saturate:[{saturate:[v]}],sepia:[{sepia:[T]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[t]}],"backdrop-brightness":[{"backdrop-brightness":[r]}],"backdrop-contrast":[{"backdrop-contrast":[a]}],"backdrop-grayscale":[{"backdrop-grayscale":[c]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[u]}],"backdrop-invert":[{"backdrop-invert":[d]}],"backdrop-opacity":[{"backdrop-opacity":[b]}],"backdrop-saturate":[{"backdrop-saturate":[v]}],"backdrop-sepia":[{"backdrop-sepia":[T]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[s]}],"border-spacing-x":[{"border-spacing-x":[s]}],"border-spacing-y":[{"border-spacing-y":[s]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",ae]}],duration:[{duration:de()}],ease:[{ease:["linear","in","out","in-out",ae]}],delay:[{delay:de()}],animate:[{animate:["none","spin","ping","pulse","bounce",ae]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[S]}],"scale-x":[{"scale-x":[S]}],"scale-y":[{"scale-y":[S]}],rotate:[{rotate:[wr,ae]}],"translate-x":[{"translate-x":[O]}],"translate-y":[{"translate-y":[O]}],"skew-x":[{"skew-x":[C]}],"skew-y":[{"skew-y":[C]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",ae]}],accent:[{accent:["auto",n]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",ae]}],"caret-color":[{caret:[n]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":N()}],"scroll-mx":[{"scroll-mx":N()}],"scroll-my":[{"scroll-my":N()}],"scroll-ms":[{"scroll-ms":N()}],"scroll-me":[{"scroll-me":N()}],"scroll-mt":[{"scroll-mt":N()}],"scroll-mr":[{"scroll-mr":N()}],"scroll-mb":[{"scroll-mb":N()}],"scroll-ml":[{"scroll-ml":N()}],"scroll-p":[{"scroll-p":N()}],"scroll-px":[{"scroll-px":N()}],"scroll-py":[{"scroll-py":N()}],"scroll-ps":[{"scroll-ps":N()}],"scroll-pe":[{"scroll-pe":N()}],"scroll-pt":[{"scroll-pt":N()}],"scroll-pr":[{"scroll-pr":N()}],"scroll-pb":[{"scroll-pb":N()}],"scroll-pl":[{"scroll-pl":N()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",ae]}],fill:[{fill:[n,"none"]}],"stroke-w":[{stroke:[Dt,Kt,us]}],stroke:[{stroke:[n,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},zS=xS(BS);function U(...n){return zS(st(n))}let ds;function fs(){return ds===void 0&&(ds=navigator.platform.includes("Mac")),ds}function dg(n){return`${n}`.toLowerCase()==="mod"?fs()?"⌘":"Ctrl":`${n}`.toLowerCase()==="alt"?fs()?"⌥":"Alt":`${n}`.toLowerCase()==="shift"?fs()?"⇧":"Shift":n}function fg(n){return n.map(dg).join(" ")}const at=x.forwardRef((n,e)=>{const{icon:t=void 0,tooltip:r=void 0,disabled:o=!1,customClass:i="",loading:s=void 0,shortcutKeys:l=void 0,tooltipOptions:a={},action:c=void 0,isActive:u=void 0,children:d,asChild:f=!1,upload:p=!1,...m}=n,g=f?hp.Slot:_c;return h.jsxs(Tg,{children:[h.jsx(kg,{asChild:!0,children:h.jsxs(g,{"data-state":u!=null&&u()?"on":"off",onClick:c,ref:e,size:"sm",className:U("w-[32px] h-[32px]",i),disabled:o,...m,children:[t&&h.jsx(Dn,{name:t,className:"size-4"}),d]})}),r&&h.jsx(Dc,{...a,children:h.jsxs("div",{className:"flex max-w-24 flex-col items-center text-center",children:[h.jsx("div",{children:r}),!!(l!=null&&l.length)&&h.jsx("span",{children:fg(l)})]})})]})});function wi(n){function e(){const i=x.useRef(n),s=x.useCallback(()=>i.current,[]),l=x.useRef(new Set),a=x.useCallback(u=>{i.current={...i.current,...u},l.current.forEach(d=>d())},[]),c=x.useCallback(u=>(l.current.add(u),()=>l.current.delete(u)),[]);return{get:s,set:a,subscribe:c}}const t=x.createContext(null);function r({children:i}){return h.jsx(t.Provider,{value:e(),children:i})}function o(i){const s=x.useContext(t);if(!s)throw new Error("Store not found");return[x.useSyncExternalStore(s.subscribe,()=>i(s.get()),()=>i(n)),s.set]}return{Provider:r,useStore:o}}wi({value:!1});wi({value:!1});const{Provider:$S,useStore:hg}=wi({value:!1}),{Provider:FS,useStore:pg}=wi({value:"light"});ie.d("0");function Oc(n,e){return window.addEventListener(n,e),()=>{window.removeEventListener(n,e)}}function Si(n,e){window.dispatchEvent(new CustomEvent(n,{detail:e}))}const pr={UPLOAD_IMAGE:n=>`UPLOAD_IMAGE-${n}`,UPLOAD_VIDEO:n=>`UPLOAD_VIDEO-${n}`,EDIT:n=>`EDIT-${n}`,UPDATE_THEME:n=>`UPDATE_THEME-${n}`,SEARCH_REPLCE:"SEARCH_REPLACE"};function mg(){const[n]=hg(e=>e.value);return n}const VS={setDisable:(n,e)=>{Si(pr.EDIT(n),e)}};function HS(n,e){const{state:t}=e,r=t.selection.$anchor;let o=!1;if(r.depth)for(let i=r.depth;i>0;i--)r.node(i).type.name===n&&(e.dispatchTransaction&&e.dispatchTransaction(t.tr.delete(r.before(i),r.after(i)).scrollIntoView()),o=!0);else{const i=t.selection.node;i&&i.type.name===n&&(e.chain().deleteSelection().run(),o=!0)}if(!o){const i=r.pos;if(i){const s=t.tr.doc.nodeAt(i);s&&s.type.name===n&&(e.dispatchTransaction&&e.dispatchTransaction(t.tr.delete(i,i+s.nodeSize)),o=!0)}}return o}function Ac(n,e,t){return n<e?e:n>t?t:n}const qS=n=>typeof n=="number",WS=n=>typeof n=="string",US=n=>typeof n=="function";function GS(n,e="px"){if(!n)return n;const t=qS(n)?String(n):n,r=Number.parseFloat(t),o=t.match(/[%a-z]+$/i),i=o?o[0]:e;return Number.isNaN(r)?n:r+i}function KS(n,e){if(!n)return!1;const{extensions:t=[]}=(n==null?void 0:n.extensionManager)??{};return!!t.find(o=>o.name===e)}function JS(n){return n.map(e=>WS(e)?{value:e,name:e}:e)}const Dd=n=>typeof n=="boolean"?`${n}`:n===0?"0":n,jd=st,Ci=(n,e)=>t=>{var r;if((e==null?void 0:e.variants)==null)return jd(n,t==null?void 0:t.class,t==null?void 0:t.className);const{variants:o,defaultVariants:i}=e,s=Object.keys(o).map(c=>{const u=t==null?void 0:t[c],d=i==null?void 0:i[c];if(u===null)return null;const f=Dd(u)||Dd(d);return o[c][f]}),l=t&&Object.entries(t).reduce((c,u)=>{let[d,f]=u;return f===void 0||(c[d]=f),c},{}),a=e==null||(r=e.compoundVariants)===null||r===void 0?void 0:r.reduce((c,u)=>{let{class:d,className:f,...p}=u;return Object.entries(p).every(m=>{let[g,y]=m;return Array.isArray(y)?y.includes({...i,...l}[g]):{...i,...l}[g]===y})?[...c,d,f]:c},[]);return jd(n,s,a,t==null?void 0:t.class,t==null?void 0:t.className)},XS=Ci("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"!bg-primary !text-primary-foreground hover:!bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),Be=Se.forwardRef(({className:n,variant:e,size:t,asChild:r=!1,...o},i)=>{const s=r?hp.Slot:"button";return h.jsx(s,{className:U(XS({variant:e,size:t,className:n})),ref:i,...o})});Be.displayName="Button";const ZS=Ae.Root,YS=Ae.Trigger,QS=Ae.Portal,e2=Ae.Sub,gg=Se.forwardRef(({className:n,inset:e,children:t,...r},o)=>h.jsxs(Ae.SubTrigger,{ref:o,className:U("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",e&&"pl-8",n),...r,children:[t,h.jsx(B.ChevronRight,{className:"ml-auto size-4"})]}));gg.displayName=Ae.SubTrigger.displayName;const yg=Se.forwardRef(({className:n,...e},t)=>h.jsx(Ae.SubContent,{ref:t,className:U("z-50 min-w-[8rem] overflow-hidden rounded-md !border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n),...e}));yg.displayName=Ae.SubContent.displayName;const bg=Se.forwardRef(({className:n,sideOffset:e=4,container:t,...r},o)=>h.jsx(Ae.Portal,{container:t,children:h.jsx(Ae.Content,{ref:o,sideOffset:e,className:U("z-50 min-w-[8rem] overflow-hidden rounded-md !border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n),...r})}));bg.displayName=Ae.Content.displayName;const vg=Se.forwardRef(({className:n,inset:e,...t},r)=>h.jsx(Ae.Item,{ref:r,className:U("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e&&"pl-8",n),...t}));vg.displayName=Ae.Item.displayName;const xg=Se.forwardRef(({className:n,children:e,checked:t,...r},o)=>h.jsxs(Ae.CheckboxItem,{checked:t,ref:o,className:U("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",n),...r,children:[h.jsx("span",{className:"absolute left-2 flex size-3.5 items-center justify-center",children:h.jsx(Ae.ItemIndicator,{children:h.jsx(B.Check,{className:"size-4"})})}),e]}));xg.displayName=Ae.CheckboxItem.displayName;const t2=Se.forwardRef(({className:n,children:e,...t},r)=>h.jsxs(Ae.RadioItem,{ref:r,className:U("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",n),...t,children:[h.jsx("span",{className:"absolute left-2 flex size-3.5 items-center justify-center",children:h.jsx(Ae.ItemIndicator,{children:h.jsx(B.Circle,{className:"size-2 fill-current"})})}),e]}));t2.displayName=Ae.RadioItem.displayName;const n2=Se.forwardRef(({className:n,inset:e,...t},r)=>h.jsx(Ae.Label,{ref:r,className:U("px-2 py-1.5 text-sm font-semibold",e&&"pl-8",n),...t}));n2.displayName=Ae.Label.displayName;const wg=Se.forwardRef(({className:n,...e},t)=>h.jsx(Ae.Separator,{className:U("-mx-1 my-1 h-px bg-muted",n),ref:t,...e}));wg.displayName=Ae.Separator.displayName;function Sg({className:n,...e}){return h.jsx("span",{className:U("ml-auto text-xs tracking-widest opacity-60",n),...e})}Sg.displayName="DropdownMenuShortcut";const Rt=Se.forwardRef(({className:n,type:e,...t},r)=>h.jsx("input",{type:e,className:U("flex h-10 w-full rounded-md !border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",n),ref:r,...t}));Rt.displayName="Input";const r2=Ci("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),cn=Se.forwardRef(({className:n,...e},t)=>h.jsx(pp.Root,{ref:t,className:U(r2(),n),...e}));cn.displayName=pp.Root.displayName;const zn=Dr.Root,$n=Dr.Trigger,mn=Se.forwardRef(({className:n,align:e="center",sideOffset:t=4,...r},o)=>h.jsx(Dr.Portal,{children:h.jsx(Dr.Content,{ref:o,align:e,sideOffset:t,className:U("z-50 w-72 rounded-md !border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n),...r})}));mn.displayName=Dr.Content.displayName;const Nc=Se.forwardRef(({className:n,orientation:e="horizontal",decorative:t=!0,...r},o)=>h.jsx(gp.Root,{ref:o,decorative:t,orientation:e,className:U("shrink-0 bg-border",e==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",n),...r}));Nc.displayName=gp.Root.displayName;const Rc=Se.forwardRef(({className:n,...e},t)=>h.jsx(da.Root,{className:U("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",n),...e,ref:t,children:h.jsx(da.Thumb,{className:U("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));Rc.displayName=da.Root.displayName;const Cg=Pn.Root,Ic=Se.forwardRef(({className:n,...e},t)=>h.jsx(Pn.List,{ref:t,className:U("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",n),...e}));Ic.displayName=Pn.List.displayName;const Kr=Se.forwardRef(({className:n,...e},t)=>h.jsx(Pn.Trigger,{ref:t,className:U("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",n),...e}));Kr.displayName=Pn.Trigger.displayName;const Jr=Se.forwardRef(({className:n,...e},t)=>h.jsx(Pn.Content,{ref:t,className:U("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",n),...e}));Jr.displayName=Pn.Content.displayName;const o2=Ci("inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent hover:bg-accent hover:text-accent-foreground"},size:{default:"h-10 px-3",sm:"h-9 px-2",lg:"h-11 px-5"}},defaultVariants:{variant:"default",size:"default"}}),_c=Se.forwardRef(({className:n,variant:e,size:t,...r},o)=>h.jsx(mp.Root,{ref:o,className:U(o2({variant:e,size:t,className:n})),...r}));_c.displayName=mp.Root.displayName;const i2=Qr.Provider,Tg=Qr.Root,kg=Qr.Trigger,Dc=Se.forwardRef(({className:n,sideOffset:e=4,...t},r)=>h.jsx(Qr.Content,{ref:r,sideOffset:e,className:U("z-50 overflow-hidden rounded-md !border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n),...t}));Dc.displayName=Qr.Content.displayName;const s2=1,l2=1e6;let hs=0;function a2(){return hs=(hs+1)%Number.MAX_SAFE_INTEGER,hs.toString()}const ps=new Map;function Pd(n){if(ps.has(n))return;const e=setTimeout(()=>{ps.delete(n),_r({type:"REMOVE_TOAST",toastId:n})},l2);ps.set(n,e)}function c2(n,e){switch(e.type){case"ADD_TOAST":return{...n,toasts:[e.toast,...n.toasts].slice(0,s2)};case"UPDATE_TOAST":return{...n,toasts:n.toasts.map(t=>t.id===e.toast.id?{...t,...e.toast}:t)};case"DISMISS_TOAST":{const{toastId:t}=e;return t?Pd(t):n.toasts.forEach(r=>{Pd(r.id)}),{...n,toasts:n.toasts.map(r=>r.id===t||t===void 0?{...r,open:!1}:r)}}case"REMOVE_TOAST":return e.toastId===void 0?{...n,toasts:[]}:{...n,toasts:n.toasts.filter(t=>t.id!==e.toastId)}}}const Lo=[];let Bo={toasts:[]};function _r(n){Bo=c2(Bo,n),Lo.forEach(e=>{e(Bo)})}function u2({...n}){const e=a2(),t=o=>_r({type:"UPDATE_TOAST",toast:{...o,id:e}}),r=()=>_r({type:"DISMISS_TOAST",toastId:e});return _r({type:"ADD_TOAST",toast:{...n,id:e,open:!0,onOpenChange:o=>{o||r()}}}),{id:e,dismiss:r,update:t}}function d2(){const[n,e]=Se.useState(Bo);return Se.useEffect(()=>(Lo.push(e),()=>{const t=Lo.indexOf(e);t>-1&&Lo.splice(t,1)}),[n]),{...n,toast:u2,dismiss:t=>_r({type:"DISMISS_TOAST",toastId:t})}}const Eg=Se.forwardRef(({className:n,...e},t)=>h.jsx(fa.Root,{ref:t,className:U("!peer !h-4 !w-4 !p-0 !shrink-0 !rounded-sm !border !border-primary !ring-offset-background focus-visible:!outline-none focus-visible:!ring-2 focus-visible:!ring-ring focus-visible:!ring-offset-2 disabled:!cursor-not-allowed disabled:!opacity-50 data-[state=checked]:!bg-primary data-[state=checked]:!text-primary-foreground",n),...e,children:h.jsx(fa.Indicator,{className:U("!flex !p-0 !items-center !justify-center !text-current"),children:h.jsx(B.Check,{className:"!h-4 !w-4"})})}));Eg.displayName=fa.Root.displayName;function f2(n){return h.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",...n,children:h.jsx("path",{fill:"currentColor",d:"M19 12h-2v3h-3v2h5zM7 9h3V7H5v5h2zm14-6H3a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h18a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2m0 16H3V5h18z"})})}function h2(n){return h.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",...n,children:h.jsx("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M6 15h15m0 4H6m9-8h6m0-4h-6M9 9h1a1 1 0 1 1-1 1V7.5a2 2 0 0 1 2-2M3 9h1a1 1 0 1 1-1 1V7.5a2 2 0 0 1 2-2"})})}function p2(){return h.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",className:"w-4 h-4",width:"1em",height:"1em",viewBox:"0 0 24 24",children:h.jsx("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",d:"M5.5 3c1.404 0 2.107 0 2.611.38c.219.164.406.375.552.62C9 4.568 9 5.358 9 6.938v10.125c0 1.58 0 2.37-.337 2.937a2.1 2.1 0 0 1-.552.621c-.504.38-1.207.38-2.611.38s-2.107 0-2.611-.38a2.1 2.1 0 0 1-.552-.62C2 19.432 2 18.642 2 17.062V6.938c0-1.58 0-2.37.337-2.938a2.1 2.1 0 0 1 .552-.62C3.393 3 4.096 3 5.5 3M20 11.938v5.124c0 1.58 0 2.37-.337 2.938a2.1 2.1 0 0 1-.552.62c-.504.38-1.207.38-2.611.38s-2.107 0-2.611-.38a2.1 2.1 0 0 1-.552-.62C13 19.433 13 18.642 13 17.063V6.938c0-1.58 0-2.37.337-2.938M22 9l-6-6m6 0l-6 6",color:"currentColor"})})}function m2(){return h.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",className:"w-4 h-4",width:"1em",height:"1em",viewBox:"0 0 24 24",children:h.jsx("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",d:"M21 18.5c0 1.404 0 2.107-.38 2.611a2.1 2.1 0 0 1-.62.552c-.567.337-1.358.337-2.937.337H6.938c-1.58 0-2.37 0-2.938-.337a2.1 2.1 0 0 1-.62-.552C3 20.607 3 19.904 3 18.5s0-2.107.38-2.611c.163-.218.374-.406.62-.552C4.567 15 5.357 15 6.938 15h10.125c1.58 0 2.37 0 2.937.337c.246.146.457.334.62.552c.38.504.38 1.207.38 2.611M12.063 4H6.937C5.358 4 4.568 4 4 4.337a2.1 2.1 0 0 0-.62.552C3 5.393 3 6.096 3 7.5s0 2.107.38 2.611c.163.218.374.406.62.552C4.567 11 5.357 11 6.938 11h10.125c1.58 0 2.37 0 2.937-.337M21 8l-6-6m6 0l-6 6",color:"currentColor"})})}function g2(n){return h.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",...n,children:h.jsx("path",{fill:"currentColor",d:"M14 2H6a2 2 0 0 0-2 2v16c0 1.11.89 2 2 2h12c1.11 0 2-.89 2-2V8zm4 18H6V4h7v5h5zm-.65-10l-2.1 9h-1.4l-1.8-6.79l-1.8 6.79h-1.4l-2.2-9h1.5l1.4 6.81l1.8-6.81h1.3l1.8 6.81l1.4-6.81z"})})}function Dn(n){const e=Ng[n.name];return e?h.jsx(e,{className:`size-4 ${(n==null?void 0:n.className)||""}`,onClick:n==null?void 0:n.onClick}):h.jsx(o0.DynamicIcon,{className:`size-4 ${(n==null?void 0:n.className)||""}`,name:n.name,onClick:n==null?void 0:n.onClick})}function y2(n){return h.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",...n,children:h.jsx("path",{fill:"currentColor",d:"M21 22H3v-2h18zm0-18H3V2h18zm-11 9.7h4l-2-5.4zM11.2 6h1.7l4.7 12h-2l-.9-2.6H9.4L8.5 18h-2z"})})}function Mg(n){return h.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 48 48",...n,children:h.jsx("path",{fill:"currentColor",stroke:"currentColor",strokeLinejoin:"round",strokeWidth:4,d:"M36 19L24 31L12 19z"})})}function b2(n){return h.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",...n,children:h.jsx("path",{fill:"currentColor",d:"M9 7v10h6v-2h-4V7z"})})}function v2(n){return h.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",...n,children:h.jsx("path",{fill:"currentColor",d:"M9 7c-1.1 0-2 .9-2 2v8h2V9h2v7h2V9h2v8h2V9a2 2 0 0 0-2-2z"})})}function x2(n){return h.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",...n,children:h.jsx("path",{fill:"currentColor",d:"M11 7c-1.1 0-2 .9-2 2v2a2 2 0 0 0 2 2h2v2H9v2h4c1.11 0 2-.89 2-2v-2a2 2 0 0 0-2-2h-2V9h4V7z"})})}function w2(){return h.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",children:h.jsx("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M14 4h4a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1h-4a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1m-9 8h4m-2-2v4"})})}function S2(){return h.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",children:h.jsx("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M6 4h4a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1m9 8h4m-2-2v4"})})}function C2(){return h.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",children:h.jsx("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 21v-4m0-4V9m0-4V3m-2 18h4M8 5v4h11l2-2l-2-2zm6 8v4H6l-2-2l2-2z"})})}function T2(){return h.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",children:h.jsx("path",{fill:"currentColor",d:"M23.943 19.806a.2.2 0 0 0-.168-.034c-1.26-1.855-2.873-3.61-4.419-5.315l-.252-.284c-.001-.073-.067-.12-.134-.15l-.084-.084c-.05-.1-.169-.167-.286-.1c-.47.234-.907.585-1.327.919c-.554.434-1.109.87-1.63 1.354a5 5 0 0 0-.588.618c-.084.117-.017.217.084.267c-.37.368-.74.736-1.109 1.12a.2.2 0 0 0-.05.134c0 .05.033.1.067.117l.655.502v.016c.924.92 2.554 2.173 4.285 3.527c.251.201.52.402.773.602c.117.134.234.285.335.418c.05.066.169.084.236.033c.033.034.084.067.118.1a.24.24 0 0 0 .1.034a.15.15 0 0 0 .135-.066a.24.24 0 0 0 .033-.1c.017 0 .017.016.034.016a.2.2 0 0 0 .134-.05l3.058-3.327c.12-.116.014-.267 0-.267m-7.628-.134l-1.546-1.17l-.15-.1c-.035-.017-.068-.05-.102-.067l-.117-.1c.66-.66 1.33-1.308 2-1.956c-.488.484-1.463 1.906-1.261 2.373c.002 0 .018.042.067.084zm4.1 3.126l-1.277-.97a27 27 0 0 0-1.58-1.504c.69.518 1.277.97 1.361 1.053c.673.585.638.485 1.093.87l.554.4c-.074.103-.151.148-.151.151m.336.25l-.034-.016a1 1 0 0 0 .152-.117zM.588 3.476c.033.217.084.435.117.636c.201 1.103.403 2.106.772 2.858l.152.568c.05.217.134.485.219.552a67 67 0 0 0 3.578 2.942a.18.18 0 0 0 .219 0s0 .016.016.016a.15.15 0 0 0 .118.05a.2.2 0 0 0 .134-.05c1.798-1.989 3.142-3.627 4.1-4.998c.068-.066.084-.167.084-.25c.067-.067.118-.151.185-.201c.067-.067.067-.184 0-.235l-.017-.016c0-.033-.017-.084-.05-.1c-.42-.401-.722-.685-1.042-.986a94 94 0 0 1-2.352-2.273c-.017-.017-.034-.034-.067-.034c-.336-.117-1.025-.234-1.882-.385c-1.277-.216-3.008-.517-4.57-.986c0 0-.101 0-.118.017l-.05.05C.05.714.022.707 0 .718c.017.1.017.167.05.284c0 .033.068.301.068.334zm7.19 4.78l-.033.034a.036.036 0 0 1 .033-.034M6.553 2.238c.101.1.521.502.622.585c-.437-.2-1.529-.702-2.034-.869c.505.1 1.194.201 1.412.284M.79 1.403c.252.434.454 1.939.655 3.41c-.118-.469-.201-.936-.302-1.372C.992 2.673.84 1.988.638 1.386c.124 0 .152.021.152.017m-.286-.369c0-.016 0-.033-.017-.033c.085 0 .135.017.202.05c0 .006-.145-.017-.185-.017m23.17-.217c.017-.066-.336-.367-.219-.384c.253-.017.253-.401 0-.401c-.335.017-.688.1-1.008.15c-.587.117-1.192.234-1.78.367a80 80 0 0 0-3.949.937c-.403.117-.857.2-1.243.401c-.135.067-.118.2-.05.284c-.034.017-.051.017-.085.034c-.117.017-.218.034-.335.05c-.102.017-.152.1-.135.2c0 .017.017.05.017.067c-.706.936-1.496 1.923-2.353 2.976c-.84.969-1.73 1.989-2.62 3.042c-2.84 3.31-6.05 7.07-9.594 10.38a.16.16 0 0 0 0 .234c.016.016.033.033.05.033c-.05.05-.101.085-.152.134q-.05.05-.05.1a.4.4 0 0 0-.067.084c-.067.067-.067.184.017.234c.067.066.185.066.235-.017c.017-.017.017-.033.033-.033a.265.265 0 0 1 .37 0c.202.217.404.435.588.618l-.42-.35c-.067-.067-.184-.05-.234.016c-.068.066-.051.184.016.234l4.469 3.727c.034.034.067.034.118.034a.15.15 0 0 0 .117-.05l.101-.1c.017.016.05.016.067.016c.05 0 .084-.016.118-.05c6.049-6.05 10.922-10.614 16.5-14.693c.05-.033.067-.1.067-.15c.067 0 .118-.05.15-.117c1.026-3.125 1.228-5.9 1.295-7.27c0-.059.016-.038.016-.068c.017-.033.017-.05.017-.05a.98.98 0 0 0-.067-.619m-10.82 4.915c.268-.301.537-.619.806-.903c-1.73 2.273-4.603 5.767-8.67 9.929c2.773-3.059 5.562-6.218 7.864-9.026M5.14 23.466c-.016-.017-.016-.017 0-.017zm2.504-2.156c.135-.15.27-.284.42-.434c0 0 0 .016.017.016c-.224.198-.433.418-.437.418m.69-.668c.099-.1.14-.173.284-.318c.992-1.02 2.017-2.04 3.059-3.076l.016-.016c.252-.2.555-.418.824-.619a228 228 0 0 0-4.184 4.029M14.852 3.91c-.554.719-1.176 1.671-1.697 2.423c-1.646 2.374-6.94 8.174-7.057 8.274a1190 1190 0 0 1-4.839 4.597l-.1.1c-.085-.1-.085-.25.016-.334C8.652 11.966 13.19 6.133 15.021 3.576c-.05.116-.084.216-.168.334zm2.906 3.427c-.671-.386-.99-.987-.806-1.572l.05-.2a.8.8 0 0 1 .085-.167a1.9 1.9 0 0 1 .756-.703c.016 0 .033 0 .05-.016c-.017-.034-.017-.084-.017-.134c.017-.1.085-.167.202-.167c.202 0 .824.184 1.059.384c.067.05.134.117.202.184c.084.1.218.268.285.401c.034.017.067.184.118.268c.033.134.067.284.05.418c-.017.016 0 .116-.017.116a1.6 1.6 0 0 1-.218.619c-.03.03.006.012-.05.067a1.2 1.2 0 0 1-.32.334a1.49 1.49 0 0 1-1.26.234a2 2 0 0 0-.169-.066m4.37 1.403c0 .017-.017.05 0 .067c-.034 0-.05.017-.085.034a110 110 0 0 0-3.915 3.025c1.11-.986 2.218-1.989 3.378-2.975c.336-.301.571-.686.638-1.12l.168-1.003v-.033c.085-.201.404-.118.353.1c-.004-.001-.173.795-.537 1.905"})})}function Og(){return h.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 32 32",children:[h.jsx("path",{fill:"currentColor",d:"M30 18v-2h-6v10h2v-4h3v-2h-3v-2zm-11 8h-4V16h4a3.003 3.003 0 0 1 3 3v4a3.003 3.003 0 0 1-3 3m-2-2h2a1 1 0 0 0 1-1v-4a1 1 0 0 0-1-1h-2zm-6-8H6v10h2v-3h3a2.003 2.003 0 0 0 2-2v-3a2 2 0 0 0-2-2m-3 5v-3h3l.001 3z"}),h.jsx("path",{fill:"currentColor",d:"M22 14v-4a.91.91 0 0 0-.3-.7l-7-7A.9.9 0 0 0 14 2H4a2.006 2.006 0 0 0-2 2v24a2 2 0 0 0 2 2h16v-2H4V4h8v6a2.006 2.006 0 0 0 2 2h6v2Zm-8-4V4.4l5.6 5.6Z"})]})}function Ag(){return h.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",className:"icon",viewBox:"0 0 1024 1024",children:[h.jsx("path",{fill:"currentColor",d:"M679.253 402.364 618.77 561.015l-60.348-158.651a30.04 30.04 0 0 0-30.447-18.637 29.76 29.76 0 0 0-30.447 18.637l-60.416 158.651-60.416-158.651a30.515 30.515 0 0 0-38.843-17.272 28.945 28.945 0 0 0-17.954 37.547l88.815 233.267c4.369 11.469 15.7 19.115 28.398 19.115a30.31 30.31 0 0 0 28.468-19.115l62.395-163.908 62.396 163.84c4.437 11.605 15.701 19.183 28.4 19.183a30.31 30.31 0 0 0 28.466-19.115l88.747-233.267a28.945 28.945 0 0 0-17.886-37.547 30.447 30.447 0 0 0-38.912 17.272zm219.478 395.605-51.883-29.218c-28.672-16.18-52.224-3.072-52.224 29.082v.273H643.209a29.833 29.833 0 0 0-30.31 29.354c0 16.18 13.584 29.218 30.31 29.218h151.825c1.092 30.516 24.03 43.077 52.224 27.648l51.063-27.989c29.013-15.906 29.15-42.189.41-58.368"}),h.jsx("path",{fill:"currentColor",d:"m810.667 913.135-.478.068H201.796c-19.865 0-36.727-11.673-36.727-25.6v-618.36h154.965c51.268 0 92.911-39.39 92.911-87.858v-87.86H810.19c19.797 0 36.522 11.742 36.522 25.669V739.26h61.987V119.262c0-46.421-44.169-84.241-98.51-84.241H328.364l-225.28 194.56v658.09c0 46.285 44.236 84.105 98.713 84.105H810.19c43.759 0 80.554-24.713 93.32-58.573h-92.842zM350.89 94.89v86.562c0 16.11-13.858 29.286-30.925 29.286H216.815L350.959 94.891z"})]})}function k2(){return h.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",children:h.jsxs("g",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",color:"currentColor",children:[h.jsx("path",{d:"M14.86 22h-4.312c-3.291 0-4.937 0-6.08-.798a4.2 4.2 0 0 1-.863-.805c-.855-1.066-.855-2.6-.855-5.67v-2.545c0-2.963 0-4.445.473-5.628c.761-1.903 2.37-3.403 4.41-4.113C8.9 2 10.49 2 13.667 2c1.816 0 2.723 0 3.448.252c1.166.406 2.085 1.263 2.52 2.35c.27.676.27 1.523.27 3.216V10"}),h.jsx("path",{d:"M2.75 12c0-1.84 1.506-3.333 3.364-3.333c.672 0 1.464.116 2.117-.057a1.67 1.67 0 0 0 1.19-1.179c.174-.647.057-1.432.057-2.098C9.478 3.493 10.984 2 12.84 2m.002 16h2.523m-4.949-4.15c-.126-.8-.281-.801-1.61-.85h-1.01c-.557 0-1.009.448-1.009 1v3c0 .552.452 1 1.01 1h1.816c.39 0 .803-.313.803-.7v-1.1c0-.11-.113-.304-.224-.304H9.068M12.842 13h1.261m0 0h1.262m-1.262 0v4.875M21.251 13h-2.523c-.557 0-1.009.448-1.009 1v1.5m0 0V18m0-2.5h2.523"})]})})}function E2(){return h.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 20 20",children:h.jsx("path",{fill:"currentColor",d:"M6.5 3a.75.75 0 0 1 .697.471l3 7.5a.75.75 0 0 1-1.393.557L7.992 9.5H5.008l-.811 2.028a.75.75 0 0 1-1.393-.556l3-7.5A.75.75 0 0 1 6.5 3m0 2.77L5.608 8h1.784zm8.28-1.55a.75.75 0 1 0-1.06 1.06l.72.72h-3.69a.75.75 0 0 0 0 1.5h3.69l-.72.72a.75.75 0 0 0 1.06 1.06l2-2a.75.75 0 0 0 0-1.06zm0 7.5a.75.75 0 1 0-1.06 1.06l.72.72H3.75a.75.75 0 0 0 0 1.5h10.69l-.72.72a.75.75 0 1 0 1.06 1.06l2-2a.75.75 0 0 0 0-1.06z"})})}function M2(){return h.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 48 48",children:h.jsxs("g",{fill:"none",stroke:"currentColor",strokeWidth:"4",children:[h.jsx("circle",{cx:"10",cy:"24",r:"4"}),h.jsx("circle",{cx:"38",cy:"10",r:"4"}),h.jsx("circle",{cx:"38",cy:"24",r:"4"}),h.jsx("circle",{cx:"38",cy:"38",r:"4"}),h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M34 38H22V10h12M14 24h20"})]})})}function O2(){return h.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 20 20",children:h.jsx("path",{fill:"currentColor",d:"M13.5 3a.75.75 0 0 0-.697.471l-3 7.5a.75.75 0 0 0 1.393.557l.812-2.028h2.984l.811 2.028a.75.75 0 0 0 1.393-.556l-3-7.5A.75.75 0 0 0 13.5 3m0 2.77L14.392 8h-1.784zM5.22 4.22a.75.75 0 0 1 1.06 1.06L5.56 6h3.69a.75.75 0 0 1 0 1.5H5.56l.72.72a.75.75 0 0 1-1.06 1.06l-2-2a.75.75 0 0 1 0-1.06zm0 7.5a.75.75 0 0 1 1.06 1.06l-.72.72h10.69a.75.75 0 0 1 0 1.5H5.56l.72.72a.75.75 0 1 1-1.06 1.06l-2-2a.75.75 0 0 1 0-1.06z"})})}function A2(){return h.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",children:h.jsx("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",d:"m3 21l7.548-7.548M21 3l-7.548 7.548m0 0L8 3H3l7.548 10.452m2.904-2.904L21 21h-5l-5.452-7.548",color:"currentColor"})})}function N2(){return h.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",children:h.jsx("path",{fill:"currentColor",d:"M14 2H6a2 2 0 0 0-2 2v16c0 1.11.89 2 2 2h12c1.11 0 2-.89 2-2V8zm4 18H6V4h7v5h5zm-.65-10l-2.1 9h-1.4l-1.8-6.79l-1.8 6.79h-1.4l-2.2-9h1.5l1.4 6.81l1.8-6.81h1.3l1.8 6.81l1.4-6.81z"})})}const Ng={Bold:B.Bold,LoaderCircle:B.LoaderCircle,Italic:B.Italic,Underline:B.Underline,Quote:B.Quote,TextQuote:h2,Strikethrough:B.Strikethrough,Minus:B.Minus,Eraser:B.Eraser,PaintRoller:B.PaintRoller,Redo2:B.Redo2,Undo2:B.Undo2,AlignCenter:co.TextAlignCenterIcon,AlignJustify:co.TextAlignJustifyIcon,AlignLeft:co.TextAlignLeftIcon,AlignRight:co.TextAlignRightIcon,ChevronDown:B.ChevronDown,Subscript:B.Subscript,Superscript:B.Superscript,Code:B.Code,Code2:B.CodeXml,Type:B.Type,IndentIncrease:B.IndentIncrease,IndentDecrease:B.IndentDecrease,List:B.List,ListOrdered:B.ListOrdered,ListTodo:B.ListTodo,Link:B.Link,ImageUp:B.ImageUp,Video:B.Video,Maximize:B.Maximize,Minimize:B.Minimize,Table:B.Table,Sparkles:B.Sparkles,Pencil:B.Pencil,Unlink:B.Unlink,BetweenHorizonalEnd:B.BetweenHorizonalEnd,BetweenHorizonalStart:B.BetweenHorizonalStart,BetweenVerticalStart:B.BetweenVerticalStart,BetweenVerticalEnd:B.BetweenVerticalEnd,TableCellsMerge:B.TableCellsMerge,TableCellsSplit:B.TableCellsSplit,Trash2:B.Trash2,Trash:B.Trash,Replace:B.Replace,ChevronsUpDown:B.ChevronsUpDown,LineHeight:y2,Word:g2,Heading1:B.Heading1,Heading2:B.Heading2,Heading3:B.Heading3,Heading4:B.Heading4,Heading5:B.Heading5,Heading6:B.Heading6,Columns2:B.Columns2,Columns3:B.Columns3,Columns4:B.Columns4,Plus:B.Plus,Grip:B.GripVertical,Copy:B.Copy,Clipboard:B.Clipboard,PanelLeft:B.PanelLeft,PanelRight:B.PanelRight,Columns:B.Columns2,Iframe:B.Frame,MenuDown:Mg,SizeS:x2,SizeM:v2,SizeL:b2,AspectRatio:f2,Emoji:B.SmilePlus,DeleteColumn:p2,DeleteRow:m2,SearchAndReplace:B.Replace,EmojiIcon:B.SmilePlusIcon,KatexIcon:B.Sigma,ExportPdf:Og,ExportWord:Ag,ImportWord:N2,ColumnAddLeft:w2,ColumnAddRight:S2,BookMarked:B.BookMarked,Excalidraw:T2,ZoomIn:B.ZoomIn,ZoomOut:B.ZoomOut,Settings:B.Settings,Eye:B.Eye,TextDirection:C2,LeftToRight:E2,RightToLeft:O2,Attachment:B.Paperclip,GifIcon:k2,ChevronUp:B.ChevronUp,Crop:B.CropIcon,Mermaid:M2,Twitter:A2,FlipX:B.FlipVertical,FlipY:B.FlipHorizontal,PencilRuler:B.PencilRuler};function R2({fill:n}){return h.jsx("svg",{width:"18px",height:"18px",viewBox:"0 0 256 256",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:h.jsx("g",{id:"icon/填充色",stroke:"none",strokeWidth:1,fill:"none",fillRule:"evenodd",children:h.jsxs("g",{id:"icon/背景颜色",children:[h.jsx("g",{id:"编组",fill:"currentColor",children:h.jsxs("g",{transform:"translate(119.502295, 137.878331) rotate(-135.000000) translate(-119.502295, -137.878331) translate(48.002295, 31.757731)",id:"矩形",children:[h.jsx("path",{d:"M100.946943,60.8084699 L43.7469427,60.8084699 C37.2852111,60.8084699 32.0469427,66.0467383 32.0469427,72.5084699 L32.0469427,118.70847 C32.0469427,125.170201 37.2852111,130.40847 43.7469427,130.40847 L100.946943,130.40847 C107.408674,130.40847 112.646943,125.170201 112.646943,118.70847 L112.646943,72.5084699 C112.646943,66.0467383 107.408674,60.8084699 100.946943,60.8084699 Z M93.646,79.808 L93.646,111.408 L51.046,111.408 L51.046,79.808 L93.646,79.808 Z",fillRule:"nonzero"}),h.jsx("path",{d:"M87.9366521,16.90916 L87.9194966,68.2000001 C87.9183543,69.4147389 86.9334998,70.399264 85.7187607,70.4 L56.9423078,70.4 C55.7272813,70.4 54.7423078,69.4150264 54.7423078,68.2 L54.7423078,39.4621057 C54.7423078,37.2523513 55.5736632,35.1234748 57.0711706,33.4985176 L76.4832996,12.4342613 C78.9534987,9.75382857 83.1289108,9.5834005 85.8093436,12.0535996 C87.1658473,13.303709 87.9372691,15.0644715 87.9366521,16.90916 Z",fillRule:"evenodd"}),h.jsx("path",{d:"M131.3,111.241199 L11.7,111.241199 C5.23826843,111.241199 0,116.479467 0,122.941199 L0,200.541199 C0,207.002931 5.23826843,212.241199 11.7,212.241199 L131.3,212.241199 C137.761732,212.241199 143,207.002931 143,200.541199 L143,122.941199 C143,116.479467 137.761732,111.241199 131.3,111.241199 Z M124,130.241 L124,193.241 L19,193.241 L19,130.241 L124,130.241 Z",fillRule:"nonzero"})]})}),h.jsx("path",{d:"M51,218 L205,218 C211.075132,218 216,222.924868 216,229 C216,235.075132 211.075132,240 205,240 L51,240 C44.9248678,240 40,235.075132 40,229 C40,222.924868 44.9248678,218 51,218 Z",id:"矩形",fill:n||"#FBDE28"})]})})})}function I2(n){const[e,t]=x.useState(void 0);function r(s){var l;(l=n.action)==null||l.call(n,s)}function o(){var s;(s=n.action)==null||s.call(n,e)}const i=x.useCallback(xi(s=>{t(s)},350),[]);return h.jsxs("div",{className:"flex items-center h-[32px]",children:[h.jsx(at,{tooltip:n==null?void 0:n.tooltip,disabled:n==null?void 0:n.disabled,action:o,tooltipOptions:n==null?void 0:n.tooltipOptions,shortcutKeys:n==null?void 0:n.shortcutKeys,children:h.jsx("span",{className:"flex items-center justify-center text-sm",children:h.jsx(R2,{fill:e})})}),h.jsx(L1,{selectedColor:e,setSelectedColor:i,onChange:r,highlight:!0,disabled:n==null?void 0:n.disabled,children:h.jsx(Be,{variant:"ghost",size:"icon",className:"!w-3 !h-[32px]",disabled:n==null?void 0:n.disabled,children:h.jsx(Dn,{className:"!w-3 !h-3 text-zinc-500",name:"MenuDown"})})})]})}function _2(n){const{t:e}=ie.useLocale(),[t,r]=x.useState({text:"",link:""}),[o,i]=x.useState(!1);x.useEffect(()=>{var l;if(n!=null&&n.editor){const{href:a,target:c}=(l=n.editor)==null?void 0:l.getAttributes("link"),{from:u,to:d}=n.editor.state.selection,f=n.editor.state.doc.textBetween(u,d," ");r({link:a,text:f}),i(c==="_blank")}},[n==null?void 0:n.editor]);function s(l){l.preventDefault(),l.stopPropagation(),n==null||n.onSetLink(t.link,t.text,o)}return h.jsx("div",{className:"border-neutral-200 rounded-lg !border bg-white p-2 shadow-sm dark:border-neutral-800 dark:bg-black",children:h.jsxs("form",{className:"flex flex-col gap-2",onSubmit:s,children:[h.jsx(cn,{className:"mb-[6px]",children:e("editor.link.dialog.text")}),h.jsx("div",{className:"mb-[10px] flex w-full max-w-sm items-center gap-1.5",children:h.jsx("div",{className:"relative w-full max-w-sm items-center",children:h.jsx(Rt,{className:"w-80",onChange:l=>r({...t,text:l.target.value}),placeholder:"Text",required:!0,type:"text",value:t.text})})}),h.jsx(cn,{className:"mb-[6px]",children:e("editor.link.dialog.link")}),h.jsx("div",{className:"flex w-full max-w-sm items-center gap-1.5",children:h.jsxs("div",{className:"relative w-full max-w-sm items-center",children:[h.jsx(Rt,{className:"pl-10",onChange:l=>r({...t,link:l.target.value}),required:!0,type:"url",value:t.link}),h.jsx("span",{className:"absolute inset-y-0 start-0 flex items-center justify-center px-2",children:h.jsx(Dn,{className:"size-5 text-muted-foreground",name:"Link"})})]})}),h.jsxs("div",{className:"flex items-center space-x-2",children:[h.jsx(cn,{children:e("editor.link.dialog.openInNewTab")}),h.jsx(Rc,{checked:o,onCheckedChange:l=>{i(l)}})]}),h.jsx(Be,{className:"mt-2 self-end",type:"submit",children:e("editor.link.dialog.button.apply")})]})})}function D2(n,e,t=null){return t?n.createChecked({index:e},t):n.createAndFill({index:e})}function j2(n){if(n.cached.columnsNodeTypes)return n.cached.columnsNodeTypes;const e={columns:n.nodes.columns,column:n.nodes.column};return n.cached.columnsNodeTypes=e,e}function P2(n,e,t=null){const r=j2(n),o=[];for(let i=0;i<e;i+=1){const s=D2(r.column,i,t);s&&o.push(s)}return r.columns.createChecked({cols:e},o)}function ms({state:n,dispatch:e,type:t}){const r=dn(i=>i.type.name===jc.name)(n.selection),o=dn(i=>i.type.name===Pc.name)(n.selection);if(e&&r&&o){const i=r.node,s=o.node.attrs.index,l=i.toJSON();let a=s;t==="delete"?(a=s-1,l.content.splice(s,1)):(a=t==="addBefore"?s:s+1,l.content.splice(a,0,{type:"column",attrs:{index:s},content:[{type:"paragraph"}]})),l.attrs.cols=l.content.length,l.content.forEach((f,p)=>{f.attrs.index=p});const c=$t.fromJSON(n.schema,l);let u=r.pos;c.content.forEach((f,p,m)=>{m<a&&(u+=f.nodeSize)});const d=n.tr.setTime(Date.now());d.replaceWith(r.pos,r.pos+r.node.nodeSize,c).setSelection(Z.near(d.doc.resolve(u))),e(d)}return!0}function Ld({state:n,dispatch:e,type:t}){const r=dn(i=>i.type.name===jc.name)(n.selection),o=dn(i=>i.type.name===Pc.name)(n.selection);if(e&&r&&o){const i=r.node,s=o.node.attrs.index;let l=0;t==="before"?l=(s-1+i.attrs.cols)%i.attrs.cols:l=(s+1)%i.attrs.cols;let a=r.pos;i.content.forEach((u,d,f)=>{f<l&&(a+=u.nodeSize)});const c=n.tr.setTime(Date.now());return c.setSelection(Z.near(c.doc.resolve(a))),e(c),!0}return!1}const L2=200,jc=Je.create({name:"columns",group:"block",defining:!0,isolating:!0,allowGapCursor:!1,content:"column{1,}",priority:L2,addOptions(){return{HTMLAttributes:{class:"columns"}}},addAttributes(){return{cols:{default:2,parseHTML:n=>n.getAttribute("cols")}}},parseHTML(){return[{tag:"div[class=grid]"}]},renderHTML({HTMLAttributes:n}){return["div",Ue(this.options.HTMLAttributes,n),0]},addCommands(){return{insertColumns:n=>({tr:e,dispatch:t,editor:r})=>{const o=P2(r.schema,n&&n.cols||3);if(t){const i=e.selection.anchor+1;e.replaceSelectionWith(o).scrollIntoView().setSelection(Z.near(e.doc.resolve(i)))}return!0},addColBefore:()=>({dispatch:n,state:e})=>ms({dispatch:n,state:e,type:"addBefore"}),addColAfter:()=>({dispatch:n,state:e})=>ms({dispatch:n,state:e,type:"addAfter"}),deleteCol:()=>({dispatch:n,state:e})=>ms({dispatch:n,state:e,type:"delete"})}},addKeyboardShortcuts(){return{"Mod-Alt-G":()=>this.editor.commands.insertColumns(),Tab:()=>Ld({state:this.editor.state,dispatch:this.editor.view.dispatch,type:"after"}),"Shift-Tab":()=>Ld({state:this.editor.state,dispatch:this.editor.view.dispatch,type:"before"})}}}),Pc=Je.create({name:"column",content:"block+",isolating:!0,addOptions(){return{HTMLAttributes:{class:"column"}}},addAttributes(){return{index:{default:0,parseHTML:n=>n.getAttribute("index")}}},parseHTML(){return[{tag:"div[class=column]"}]},renderHTML({HTMLAttributes:n}){return["div",Ue(this.options.HTMLAttributes,n),0]}});var Rg=(n=>(n[n.max=7]="max",n[n.min=0]="min",n[n.more=1]="more",n[n.less=-1]="less",n))(Rg||{});function B2(n,e,t){return n<e?e:n>t?t:n}function z2(n,e,t,r){const{doc:o,selection:i}=n;if(!o||!i||!(i instanceof Z||i instanceof ot))return n;const{from:s,to:l}=i;return o.nodesBetween(s,l,(a,c)=>{const u=a.type;return t.includes(u.name)?(n=Ig(n,c,e),!1):!Ra(a.type.name,r.extensionManager.extensions)}),n}function Ig(n,e,t){if(!n.doc)return n;const r=n.doc.nodeAt(e);if(!r)return n;const s=B2((r.attrs.indent||0)+t,0,7);if(s===r.attrs.indent)return n;const l={...r.attrs,indent:s};return n.setNodeMarkup(e,r.type,l,r.marks)}function $2({delta:n,types:e}){return({state:t,dispatch:r,editor:o})=>{const{selection:i}=t;let{tr:s}=t;return s=s.setSelection(i),s=z2(s,n,e,o),s.docChanged?(r&&r(s),!0):!1}}const _g={setOpen:(n,e)=>{Si(pr.UPLOAD_IMAGE(n),e)}},F2=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,Ti=Je.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{}}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:n}){return["img",Ue(this.options.HTMLAttributes,n)]},addCommands(){return{setImage:n=>({commands:e})=>e.insertContent({type:this.name,attrs:n})}},addInputRules(){return[ro({find:F2,type:this.type,getAttributes:n=>{const[,,e,t,r]=n;return{src:t,alt:e,title:r}}})]}}),Fn=xt.Root,Vn=xt.Trigger,V2=xt.Portal,Dg=Se.forwardRef(({className:n,...e},t)=>h.jsx(xt.Overlay,{ref:t,className:U("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",n),...e}));Dg.displayName=xt.Overlay.displayName;const gn=Se.forwardRef(({className:n,children:e,...t},r)=>h.jsxs(V2,{children:[h.jsx(Dg,{}),h.jsxs(xt.Content,{ref:r,className:U("dialog-content fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",n),...t,children:[e,h.jsxs(xt.Close,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[h.jsx(B.X,{className:"h-4 w-4"}),h.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));gn.displayName=xt.Content.displayName;function jg({className:n,...e}){return h.jsx("div",{className:U("flex flex-col space-y-1.5 text-center sm:text-left",n),...e})}jg.displayName="DialogHeader";function mr({className:n,...e}){return h.jsx("div",{className:U("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",n),...e})}mr.displayName="DialogFooter";const yn=Se.forwardRef(({className:n,...e},t)=>h.jsx(xt.Title,{ref:t,className:U("text-lg font-semibold leading-none tracking-tight",n),...e}));yn.displayName=xt.Title.displayName;const H2=Se.forwardRef(({className:n,...e},t)=>h.jsx(xt.Description,{ref:t,className:U("text-sm text-muted-foreground",n),...e}));H2.displayName=xt.Description.displayName;function q2(n){return n.replace(/^.*\/|\..+$/g,"")}function W2(n){return n.split(".").pop()}function U2(n){return n<1024?`${n} Byte`:n<1024*1024?`${(n/1024).toFixed(2)} KB`:`${(n/1024/1024).toFixed(2)} MB`}function G2(n){return n?n==="application/pdf"?"pdf":n.startsWith("application/")&&[".document","word"].some(e=>n.includes(e))?"word":n.startsWith("application/")&&["presentation"].some(e=>n.includes(e))?"excel":n.startsWith("application/")&&["sheet"].some(e=>n.includes(e))?"ppt":n.startsWith("image")?"image":n.startsWith("audio")?"audio":n.startsWith("video")?"video":"file":"file"}function K2(n){return new Promise(e=>{const t=new FileReader;t.addEventListener("load",()=>{e({alt:n.name,src:t.result})},!1),t.readAsDataURL(n)})}function ki(n,e){const t=n.split(","),r=t[0].match(/:(.*?);/)[1],o=atob(t[t.length-1]);let i=o.length;const s=new Uint8Array(i);for(;i--;)s[i]=o.charCodeAt(i);return new File([s],e,{type:r})}function J2({editor:n,imageInline:e,onClose:t}){const{t:r}=ie.useLocale(),[o,i]=x.useState(!1),s=x.useRef(null),[l,a]=x.useState(),[c,u]=x.useState(""),d=x.useRef(null),[f,p]=x.useState({src:"",file:null});function m(v){if(s.current&&v.width&&v.height){const S=g(s.current,v);u(S)}}function g(v,S){const T=document.createElement("canvas"),C=v.naturalWidth/v.width,I=v.naturalHeight/v.height;T.width=S.width*C,T.height=S.height*I;const O=T.getContext("2d");return O&&(O.imageSmoothingEnabled=!1,O.drawImage(v,S.x*C,S.y*I,S.width*C,S.height*I,0,0,S.width*C,S.height*I)),T.toDataURL("image/png",1)}async function y(){var v,S;try{const T=ki(c,((v=f==null?void 0:f.file)==null?void 0:v.name)||"image.png"),C=(S=n.extensionManager.extensions.find(O=>O.name===ni.name))==null?void 0:S.options;let I="";C.upload?I=await C.upload(T):I=URL.createObjectURL(T),n.chain().focus().setImageInline({src:I,inline:e}).run(),i(!1),p({src:"",file:null}),t()}catch(T){console.log("Error cropping image",T)}}function b(v){var S;v.preventDefault(),(S=d.current)==null||S.click()}const w=async v=>{var I;const S=(I=v==null?void 0:v.target)==null?void 0:I.files;if(!n||n.isDestroyed||S.length===0)return;const T=S[0],C=await K2(T);i(!0),p({src:C.src,file:T})};return h.jsxs(h.Fragment,{children:[h.jsx(Be,{className:"mt-1 w-full",onClick:b,size:"sm",children:r("editor.image.dialog.tab.uploadCrop")}),h.jsxs(Fn,{open:o,children:[h.jsx(Vn,{}),h.jsxs(gn,{children:[h.jsx(yn,{children:r("editor.image.dialog.tab.uploadCrop")}),h.jsx("div",{children:f.src&&h.jsx(Z1,{className:"w-full",crop:l,onChange:v=>a(v),onComplete:v=>m(v),children:h.jsx("img",{alt:"Crop me",ref:s,src:f.src})})}),h.jsxs(mr,{children:[h.jsxs(Be,{onClick:()=>{i(!1),p({src:"",file:null})},children:[r("editor.imageUpload.cancel"),h.jsx(Dn,{className:"ml-[4px]",name:"Trash2"})]}),h.jsxs(Be,{className:"w-fit",onClick:y,children:[r("editor.imageUpload.crop"),h.jsx(Dn,{className:"ml-[4px]",name:"Crop"})]})]})]})]}),h.jsx("input",{accept:"image/*",multiple:!0,onChange:w,ref:d,type:"file",style:{display:"none"}})]})}function X2(n){var m;const{t:e}=ie.useLocale(),[t,r]=x.useState(!1),o=g=>{r(g.detail)},[i,s]=x.useState(""),l=x.useRef(null),[a,c]=x.useState(((m=n.editor.extensionManager.extensions.find(g=>g.name===ni.name))==null?void 0:m.options.defaultInline)||!1),u=x.useMemo(()=>{var y;return(y=n.editor.extensionManager.extensions.find(b=>b.name===ni.name))==null?void 0:y.options},[n.editor]);x.useEffect(()=>{const g=Oc(pr.UPLOAD_IMAGE(n.editor.id),o);return()=>{g()}},[]);async function d(g){var v;const y=(v=g==null?void 0:g.target)==null?void 0:v.files;if(!n.editor||n.editor.isDestroyed||y.length===0)return;const b=y[0];let w="";u.upload?w=await u.upload(b):w=URL.createObjectURL(b),n.editor.chain().focus().setImageInline({src:w,inline:a}).run(),r(!1),c(!1)}function f(g){g.preventDefault(),g.stopPropagation(),n.editor.chain().focus().setImageInline({src:i,inline:a}).run(),r(!1),c(!1),s("")}function p(g){var y;g.preventDefault(),(y=l.current)==null||y.click()}return h.jsxs(Fn,{onOpenChange:r,open:t,children:[h.jsx(Vn,{asChild:!0,children:h.jsx(at,{action:()=>r(!0),icon:n.icon,tooltip:n.tooltip})}),h.jsxs(gn,{children:[h.jsx(yn,{children:e("editor.image.dialog.title")}),h.jsxs(Cg,{activationMode:"manual",defaultValue:u.resourceImage==="both"||u.resourceImage==="upload"?"upload":"link",children:[h.jsxs(Ic,{className:"grid w-full grid-cols-2",children:[u.resourceImage==="both"||u.resourceImage==="upload"?h.jsx(Kr,{value:"upload",children:e("editor.image.dialog.tab.upload")}):h.jsx(h.Fragment,{}),u.resourceImage==="both"||u.resourceImage==="link"?h.jsx(Kr,{value:"link",children:e("editor.image.dialog.tab.url")}):h.jsx(h.Fragment,{})]}),h.jsxs("div",{className:"my-[10px] flex items-center gap-[4px]",children:[h.jsx(Eg,{checked:a,onCheckedChange:g=>{c(g)}}),h.jsx(cn,{children:e("editor.link.dialog.inline")})]}),h.jsxs(Jr,{value:"upload",children:[h.jsxs("div",{className:"flex items-center gap-[10px]",children:[h.jsx(Be,{className:"mt-1 w-full",onClick:p,size:"sm",children:e("editor.image.dialog.tab.upload")}),h.jsx(J2,{editor:n.editor,imageInline:a,onClose:()=>_g.setOpen(n.editor.id,!1)})]}),h.jsx("input",{accept:"image/*",multiple:!0,onChange:d,ref:l,type:"file",style:{display:"none"}})]}),h.jsx(Jr,{value:"link",children:h.jsx("form",{onSubmit:f,children:h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(Rt,{autoFocus:!0,onChange:g=>s(g.target.value),placeholder:e("editor.image.dialog.placeholder"),required:!0,type:"url",value:i}),h.jsx(Be,{type:"submit",children:e("editor.image.dialog.button.apply")})]})})})]})]})]})}const yo={TOP_LEFT:"tl",TOP_RIGHT:"tr",BOTTOM_LEFT:"bl",BOTTOM_RIGHT:"br"};function Z2(n){var I,O;const[e,t]=x.useState({width:ie.IMAGE_MAX_SIZE,height:ie.IMAGE_MAX_SIZE}),[r,o]=x.useState({width:0,height:0}),[i]=x.useState([yo.TOP_LEFT,yo.TOP_RIGHT,yo.BOTTOM_LEFT,yo.BOTTOM_RIGHT]),[s,l]=x.useState(!1),[a,c]=x.useState({x:0,y:0,w:0,h:0,dir:""}),{align:u,inline:d}=(I=n==null?void 0:n.node)==null?void 0:I.attrs,f=x.useMemo(()=>{var J;const{src:E,alt:R,width:_,height:N,flipX:D,flipY:k}=(J=n==null?void 0:n.node)==null?void 0:J.attrs,L=ti(_)?`${_}px`:_,F=ti(N)?`${N}px`:N,V=[];D&&V.push("rotateX(180deg)"),k&&V.push("rotateY(180deg)");const ue=V.join(" ");return{src:E||void 0,alt:R||void 0,style:{width:L||void 0,height:F||void 0,transform:ue||"none"}}},[(O=n==null?void 0:n.node)==null?void 0:O.attrs]),p=x.useMemo(()=>{const{style:{width:E}}=f;return{width:E==="100%"?E:void 0}},[f]);function m(E){o({width:E.target.width,height:E.target.height})}function g(){const{editor:E,getPos:R}=n;E.commands.setNodeSelection(R())}const y=x.useCallback(Vt(()=>{const{editor:E}=n,{width:R}=getComputedStyle(E.view.dom);t(_=>({..._,width:Number.parseInt(R,10)}))},ie.IMAGE_THROTTLE_WAIT_TIME),[n==null?void 0:n.editor]);function b(E,R){E.preventDefault(),E.stopPropagation();const _=r.width,N=r.height,D=_/N;let k=Number(n.node.attrs.width),L=Number(n.node.attrs.height);const F=e.width;k&&!L?(k=k>F?F:k,L=Math.round(k/D)):L&&!k?(k=Math.round(L*D),k=k>F?F:k):!k&&!L?(k=_>F?F:_,L=Math.round(k/D)):k=k>F?F:k,l(!0),c({x:E.clientX,y:E.clientY,w:k,h:L,dir:R})}const w=x.useCallback(Vt(E=>{if(E.preventDefault(),E.stopPropagation(),!s)return;const{x:R,w:_,dir:N}=a,D=(E.clientX-R)*(/l/.test(N)?-1:1),k=og(_+D,ie.IMAGE_MIN_SIZE,e.width);n.updateAttributes({width:k,height:null})},ie.IMAGE_THROTTLE_WAIT_TIME),[s,a,e,n.updateAttributes]),v=x.useCallback(E=>{E.preventDefault(),E.stopPropagation(),s&&(c({x:0,y:0,w:0,h:0,dir:""}),l(!1),g())},[s,g]),S=x.useCallback(()=>{document==null||document.addEventListener("mousemove",w,!0),document==null||document.addEventListener("mouseup",v,!0)},[w,v]),T=x.useCallback(()=>{document==null||document.removeEventListener("mousemove",w,!0),document==null||document.removeEventListener("mouseup",v,!0)},[w,v]);x.useEffect(()=>(s?S():T(),()=>{T()}),[s,S,T]);const C=x.useMemo(()=>new ResizeObserver(()=>y()),[y]);return x.useEffect(()=>(C.observe(n.editor.view.dom),()=>{C.disconnect()}),[n.editor.view.dom,C]),h.jsx(Ht,{as:d?"span":"div",className:"image-view",style:{...p,textAlign:u,display:d?"inline":"block"},children:h.jsxs("div",{"data-drag-handle":!0,draggable:"true",style:p,className:`image-view__body ${n!=null&&n.selected?"image-view__body--focused":""} ${s?"image-view__body--resizing":""}`,children:[h.jsx("img",{alt:f.alt,className:"image-view__body__image block",height:"auto",onClick:g,onLoad:m,src:f.src,style:f.style}),(n==null?void 0:n.editor.view.editable)&&((n==null?void 0:n.selected)||s)&&h.jsx("div",{className:"image-resizer",children:i==null?void 0:i.map(E=>h.jsx("span",{className:`image-resizer__handler image-resizer__handler--${E}`,onMouseDown:R=>b(R,E)},`image-dir-${E}`))})]})})}const lr=new ht("upload-image");function Y2(){return new $e({key:lr,state:{init(){return xe.empty},apply(n,e){e=e.map(n.mapping,n.doc);const t=n.getMeta(lr);if(t!=null&&t.add)for(const{id:r,pos:o,src:i}of t.add){const s=Q2(i),l=Pe.widget(o,s,{id:r});e=e.add(n.doc,[l])}else if(t!=null&&t.remove)for(const r of t.remove)e=e.remove(e.find(void 0,void 0,o=>o.id===r));return e}},props:{decorations(n){return this.getState(n)}}})}function Q2(n){const e=document.createElement("div"),t=document.createElement("img");return t.setAttribute("class","opacity-50"),t.src=n,t.addEventListener("load",()=>{e.setAttribute("class","img-placeholder")}),e.append(t),e}function eC(n,e){var o;const r=lr.getState(n).find(void 0,void 0,i=>i.id===e);return r.length>0?(o=r[0])==null?void 0:o.from:null}function tC({validateFn:n,onUpload:e,postUpload:t,defaultInline:r=!1}){return(o,i,s)=>{for(const l of o){if(n&&!n(l))continue;const a=Date.now().toString(),c=i.state.tr;c.selection.empty||c.deleteSelection();const u=URL.createObjectURL(l);c.setMeta(lr,{add:[{id:a,pos:s,src:u}]}),i.dispatch(c),e(l).then(async d=>{var w;t&&typeof d=="string"&&(d=await t(d));const{schema:f}=i.state;let p=eC(i.state,a);if(p===null)return;const m=typeof d=="object"?u:d,g=(w=f.nodes.image)==null?void 0:w.create({src:m,inline:r});if(!g)return;const{doc:y}=i.state;p>y.content.size&&(p=y.content.size-1);const b=i.state.tr.replaceWith(p,p,g).setMeta(lr,{remove:[a]});i.dispatch(b)},()=>{const d=i.state.tr.delete(s,s).setMeta(lr,{remove:[a]});i.dispatch(d)})}}}function nC(n,e,t){var o;const r=[...((o=e.clipboardData)==null?void 0:o.files)||[]];if(r.length>0){e.preventDefault();const i=n.state.selection.from;return t(r,n,i+1),!0}return!1}function rC(n,e,t,r){var i;const o=[...((i=e.dataTransfer)==null?void 0:i.files)||[]];if(!t&&o.length>0){e.preventDefault();const s=n.posAtCoords({left:e.clientX,top:e.clientY});if(s)return r(o,n,s.pos+1),!0}return!1}const oC={acceptMimes:["image/jpeg","image/gif","image/png","image/jpg"],maxSize:1024*1024*5,resourceImage:"both",defaultInline:!1},ni=Ti.extend({group:"inline",inline:!0,defining:!0,draggable:!0,selectable:!0,addOptions(){var n;return{...oC,...(n=this.parent)==null?void 0:n.call(this),upload:()=>Promise.reject("Image Upload Function"),button:({editor:e,extension:t,t:r})=>{var o,i;return{component:X2,componentProps:{action:()=>!0,upload:t.options.upload,disabled:!((i=(o=e.can()).setImage)!=null&&i.call(o,{})),icon:"ImageUp",tooltip:r("editor.image.tooltip"),editor:e}}}}},addAttributes(){var n;return{...(n=this.parent)==null?void 0:n.call(this),flipX:{default:!1},flipY:{default:!1},width:{default:null,parseHTML:e=>{const t=e.style.width||e.getAttribute("width")||null;return t?Number.parseInt(t,10):null},renderHTML:e=>({width:e.width})},align:{default:"center",parseHTML:e=>e.getAttribute("align"),renderHTML:e=>({align:e.align})},inline:{default:!1,parseHTML:e=>!!e.getAttribute("inline"),renderHTML:e=>({inline:e.inline})}}},addNodeView(){return qt(Z2)},addCommands(){var n;return{...(n=this.parent)==null?void 0:n.call(this),setImageInline:e=>({commands:t})=>t.insertContent({type:this.name,attrs:{...e,inline:e.inline??this.options.defaultInline}}),updateImage:e=>({commands:t})=>t.updateAttributes(this.name,e),setAlignImage:e=>({commands:t})=>t.updateAttributes(this.name,{align:e})}},renderHTML({HTMLAttributes:n}){const{flipX:e,flipY:t,align:r,inline:o}=n,i=e||t?`transform: rotateX(${e?"180":"0"}deg) rotateY(${t?"180":"0"}deg);`:"",s=r?`text-align: ${r};`:"";return[o?"span":"div",{style:s,class:"image"},["img",Ue({height:"auto",style:i},this.options.HTMLAttributes,n)]]},parseHTML(){return[{tag:"span.image img",getAttrs:n=>{var i;const e=n==null?void 0:n.parentElement,t=n==null?void 0:n.getAttribute("width"),r=(n==null?void 0:n.getAttribute("flipx"))||!1,o=(n==null?void 0:n.getAttribute("flipy"))||!1;return{src:n==null?void 0:n.getAttribute("src"),alt:n==null?void 0:n.getAttribute("alt"),caption:n==null?void 0:n.getAttribute("caption"),width:t?Number.parseInt(t,10):null,align:(n==null?void 0:n.getAttribute("align"))||((i=e==null?void 0:e.style)==null?void 0:i.textAlign)||null,inline:(n==null?void 0:n.getAttribute("inline"))||!1,flipX:r==="true",flipY:o==="true"}}},{tag:"div[class=image]",getAttrs:n=>{const e=n.querySelector("img"),t=e==null?void 0:e.getAttribute("width"),r=(e==null?void 0:e.getAttribute("flipx"))||!1,o=(e==null?void 0:e.getAttribute("flipy"))||!1;return{src:e==null?void 0:e.getAttribute("src"),alt:e==null?void 0:e.getAttribute("alt"),caption:e==null?void 0:e.getAttribute("caption"),width:t?Number.parseInt(t,10):null,align:(e==null?void 0:e.getAttribute("align"))||n.style.textAlign||null,inline:(e==null?void 0:e.getAttribute("inline"))||!1,flipX:r==="true",flipY:o==="true"}}}]},addProseMirrorPlugins(){const e=tC({validateFn:t=>!(!this.options.acceptMimes.includes(t.type)||t.size>this.options.maxSize),onUpload:this.options.upload,defaultInline:this.options.defaultInline});return[new $e({props:{handlePaste:(t,r)=>!r.clipboardData||[...r.clipboardData.files||[]].some(i=>i.type==="text/html")?!1:nC(t,r,e),handleDrop:(t,r,o,i)=>(!(r instanceof DragEvent)||!r.dataTransfer||rC(t,r,i,e),!1)}}),Y2()]}});function iC(n){return/\.(?:mp4|webm|ogg|mov)$/i.test(n)}function sC(n){const{t:e}=ie.useLocale(),[t,r]=x.useState(""),o=x.useRef(null),[i,s]=x.useState(""),[l,a]=x.useState(!1),c=m=>{a(m.detail)};x.useEffect(()=>{const m=Oc(pr.UPLOAD_VIDEO(n.editor.id),c);return()=>{m()}},[]);const u=x.useMemo(()=>{var g;return(g=n.editor.extensionManager.extensions.find(y=>y.name===Pg.name))==null?void 0:g.options},[n.editor]);async function d(m){var w;const g=(w=m==null?void 0:m.target)==null?void 0:w.files;if(!n.editor||n.editor.isDestroyed||g.length===0)return;const y=g[0];let b="";u.upload?b=await u.upload(y):b=URL.createObjectURL(y),n.editor.chain().focus().setVideo({src:b,width:"100%"}).run(),a(!1)}function f(m){m.preventDefault(),m.stopPropagation(),t&&(n.editor.chain().focus().setVideo({src:t,width:"100%"}).run(),a(!1))}function p(m){var g;m.preventDefault(),(g=o.current)==null||g.click()}return h.jsxs(Fn,{onOpenChange:a,open:l,children:[h.jsx(Vn,{asChild:!0,children:h.jsx(at,{action:()=>a(!0),icon:n.icon,tooltip:n.tooltip})}),h.jsxs(gn,{children:[h.jsx(yn,{children:e("editor.video.dialog.title")}),h.jsxs(Cg,{activationMode:"manual",defaultValue:(u==null?void 0:u.resourceVideo)==="both"||(u==null?void 0:u.resourceVideo)==="upload"?"upload":"link",children:[h.jsxs(Ic,{className:"grid w-full grid-cols-2",children:[((u==null?void 0:u.resourceVideo)==="both"||(u==null?void 0:u.resourceVideo)==="upload")&&h.jsx(Kr,{value:"upload",children:e("editor.video.dialog.tab.upload")}),((u==null?void 0:u.resourceVideo)==="both"||(u==null?void 0:u.resourceVideo)==="link")&&h.jsx(Kr,{value:"link",children:e("editor.video.dialog.link")})]}),h.jsxs(Jr,{value:"upload",children:[h.jsx("div",{className:"flex items-center gap-[10px]",children:h.jsx(Be,{className:"mt-1 w-full",onClick:p,size:"sm",children:e("editor.video.dialog.tab.upload")})}),h.jsx("input",{accept:"video/*",multiple:!0,onChange:d,ref:o,type:"file",style:{display:"none"}})]}),h.jsxs(Jr,{value:"link",children:[h.jsx("form",{onSubmit:f,children:h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(Rt,{autoFocus:!0,placeholder:e("editor.video.dialog.placeholder"),required:!0,type:"url",value:t,onChange:m=>{const g=m.target.value;if(!iC(g)){s("Invalid video URL"),r("");return}s(""),r(g)}}),h.jsx(Be,{type:"submit",children:e("editor.video.dialog.button.apply")})]})}),i&&h.jsx("div",{className:"my-[5px] text-red-500",children:i})]})]})]})]})}function lC(n){return n=n.replace("https://youtu.be/","https://www.youtube.com/watch?v=").replace("watch?v=","embed/"),n=n.replace("https://vimeo.com/","https://player.vimeo.com/video/"),/^https?:\/\/www.bilibili.com\/video\/.*/i.test(n)&&(n=n.replace(/\?.*$/,"").replace("https://www.bilibili.com/video/","https://player.bilibili.com/player.html?bvid=")),n.includes("drive.google.com")&&(n=n.replace("/view","/preview")),n}const Pg=Je.create({name:"video",group:"block",atom:!0,draggable:!0,addOptions(){return{divider:!1,spacer:!1,allowFullscreen:!0,upload:void 0,frameborder:!1,resourceVideo:"both",width:ie.VIDEO_SIZE["size-medium"],HTMLAttributes:{class:"iframe-wrapper",style:"display: flex;justify-content: center;"},button:({editor:n,t:e})=>{var t,r;return{component:sC,componentProps:{action:()=>{},isActive:()=>n.isActive("video")||!1,disabled:!((r=(t=n.can()).setVideo)!=null&&r.call(t,{})),icon:"Video",tooltip:e("editor.video.tooltip"),editor:n}}}}},addAttributes(){return{src:{default:null,renderHTML:({src:n})=>({src:n?lC(n):null})},width:{default:this.options.width,renderHTML:({width:n})=>({width:GS(n)})},frameborder:{default:this.options.frameborder?1:0,parseHTML:()=>this.options.frameborder?1:0},allowfullscreen:{default:this.options.allowFullscreen,parseHTML:()=>this.options.allowFullscreen}}},parseHTML(){return[{tag:"div[data-video] iframe"}]},renderHTML({HTMLAttributes:n}){const{width:e="100%"}=n??{},t={...n,width:"100%",height:"100%"},r=`position: relative;overflow: hidden;display: flex;flex: 1;max-width: ${e};`,o=`flex: 1;padding-bottom: ${9/16*100}%;`,l=["div",{style:r},["div",{style:o}],["iframe",t]];return["div",{...this.options.HTMLAttributes,"data-video":""},l]},addCommands(){return{setVideo:n=>({commands:e})=>e.insertContent({type:this.name,attrs:n}),updateVideo:n=>({commands:e})=>e.updateAttributes(this.name,n)}}}),aC=Je.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:n}){return["tr",Ue(this.options.HTMLAttributes,n),0]}});var Pa,La;if(typeof WeakMap<"u"){let n=new WeakMap;Pa=e=>n.get(e),La=(e,t)=>(n.set(e,t),t)}else{const n=[];let t=0;Pa=r=>{for(let o=0;o<n.length;o+=2)if(n[o]==r)return n[o+1]},La=(r,o)=>(t==10&&(t=0),n[t++]=r,n[t++]=o)}var ge=class{constructor(n,e,t,r){this.width=n,this.height=e,this.map=t,this.problems=r}findCell(n){for(let e=0;e<this.map.length;e++){const t=this.map[e];if(t!=n)continue;const r=e%this.width,o=e/this.width|0;let i=r+1,s=o+1;for(let l=1;i<this.width&&this.map[e+l]==t;l++)i++;for(let l=1;s<this.height&&this.map[e+this.width*l]==t;l++)s++;return{left:r,top:o,right:i,bottom:s}}throw new RangeError(`No cell with offset ${n} found`)}colCount(n){for(let e=0;e<this.map.length;e++)if(this.map[e]==n)return e%this.width;throw new RangeError(`No cell with offset ${n} found`)}nextCell(n,e,t){const{left:r,right:o,top:i,bottom:s}=this.findCell(n);return e=="horiz"?(t<0?r==0:o==this.width)?null:this.map[i*this.width+(t<0?r-1:o)]:(t<0?i==0:s==this.height)?null:this.map[r+this.width*(t<0?i-1:s)]}rectBetween(n,e){const{left:t,right:r,top:o,bottom:i}=this.findCell(n),{left:s,right:l,top:a,bottom:c}=this.findCell(e);return{left:Math.min(t,s),top:Math.min(o,a),right:Math.max(r,l),bottom:Math.max(i,c)}}cellsInRect(n){const e=[],t={};for(let r=n.top;r<n.bottom;r++)for(let o=n.left;o<n.right;o++){const i=r*this.width+o,s=this.map[i];t[s]||(t[s]=!0,!(o==n.left&&o&&this.map[i-1]==s||r==n.top&&r&&this.map[i-this.width]==s)&&e.push(s))}return e}positionAt(n,e,t){for(let r=0,o=0;;r++){const i=o+t.child(r).nodeSize;if(r==n){let s=e+n*this.width;const l=(n+1)*this.width;for(;s<l&&this.map[s]<o;)s++;return s==l?i-1:this.map[s]}o=i}}static get(n){return Pa(n)||La(n,cC(n))}};function cC(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);const e=uC(n),t=n.childCount,r=[];let o=0,i=null;const s=[];for(let c=0,u=e*t;c<u;c++)r[c]=0;for(let c=0,u=0;c<t;c++){const d=n.child(c);u++;for(let m=0;;m++){for(;o<r.length&&r[o]!=0;)o++;if(m==d.childCount)break;const g=d.child(m),{colspan:y,rowspan:b,colwidth:w}=g.attrs;for(let v=0;v<b;v++){if(v+c>=t){(i||(i=[])).push({type:"overlong_rowspan",pos:u,n:b-v});break}const S=o+v*e;for(let T=0;T<y;T++){r[S+T]==0?r[S+T]=u:(i||(i=[])).push({type:"collision",row:c,pos:u,n:y-T});const C=w&&w[T];if(C){const I=(S+T)%e*2,O=s[I];O==null||O!=C&&s[I+1]==1?(s[I]=C,s[I+1]=1):O==C&&s[I+1]++}}}o+=y,u+=g.nodeSize}const f=(c+1)*e;let p=0;for(;o<f;)r[o++]==0&&p++;p&&(i||(i=[])).push({type:"missing",row:c,n:p}),u++}(e===0||t===0)&&(i||(i=[])).push({type:"zero_sized"});const l=new ge(e,t,r,i);let a=!1;for(let c=0;!a&&c<s.length;c+=2)s[c]!=null&&s[c+1]<t&&(a=!0);return a&&dC(l,s,n),l}function uC(n){let e=-1,t=!1;for(let r=0;r<n.childCount;r++){const o=n.child(r);let i=0;if(t)for(let s=0;s<r;s++){const l=n.child(s);for(let a=0;a<l.childCount;a++){const c=l.child(a);s+c.attrs.rowspan>r&&(i+=c.attrs.colspan)}}for(let s=0;s<o.childCount;s++){const l=o.child(s);i+=l.attrs.colspan,l.attrs.rowspan>1&&(t=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function dC(n,e,t){n.problems||(n.problems=[]);const r={};for(let o=0;o<n.map.length;o++){const i=n.map[o];if(r[i])continue;r[i]=!0;const s=t.nodeAt(i);if(!s)throw new RangeError(`No cell with offset ${i} found`);let l=null;const a=s.attrs;for(let c=0;c<a.colspan;c++){const u=(o+c)%n.width,d=e[u*2];d!=null&&(!a.colwidth||a.colwidth[c]!=d)&&((l||(l=fC(a)))[c]=d)}l&&n.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:l})}}function fC(n){if(n.colwidth)return n.colwidth.slice();const e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function Xe(n){let e=n.cached.tableNodeTypes;if(!e){e=n.cached.tableNodeTypes={};for(const t in n.nodes){const r=n.nodes[t],o=r.spec.tableRole;o&&(e[o]=r)}}return e}var Qt=new ht("selectingCells");function gr(n){for(let e=n.depth-1;e>0;e--)if(n.node(e).type.spec.tableRole=="row")return n.node(0).resolve(n.before(e+1));return null}function hC(n){for(let e=n.depth;e>0;e--){const t=n.node(e).type.spec.tableRole;if(t==="cell"||t==="header_cell")return n.node(e)}return null}function Tt(n){const e=n.selection.$head;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return!0;return!1}function Ei(n){const e=n.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const t=gr(e.$head)||pC(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function pC(n){for(let e=n.nodeAfter,t=n.pos;e;e=e.firstChild,t++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t)}for(let e=n.nodeBefore,t=n.pos;e;e=e.lastChild,t--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t-e.nodeSize)}}function Ba(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function mC(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function Lc(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function Lg(n,e,t){const r=n.node(-1),o=ge.get(r),i=n.start(-1),s=o.nextCell(n.pos-i,e,t);return s==null?null:n.node(0).resolve(i+s)}function jn(n,e,t=1){const r={...n,colspan:n.colspan-t};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,t),r.colwidth.some(o=>o>0)||(r.colwidth=null)),r}function Bg(n,e,t=1){const r={...n,colspan:n.colspan+t};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let o=0;o<t;o++)r.colwidth.splice(e,0,0)}return r}function gC(n,e,t){const r=Xe(e.type.schema).header_cell;for(let o=0;o<n.height;o++)if(e.nodeAt(n.map[t+o*n.width]).type!=r)return!1;return!0}var ye=class jt extends te{constructor(e,t=e){const r=e.node(-1),o=ge.get(r),i=e.start(-1),s=o.rectBetween(e.pos-i,t.pos-i),l=e.node(0),a=o.cellsInRect(s).filter(u=>u!=t.pos-i);a.unshift(t.pos-i);const c=a.map(u=>{const d=r.nodeAt(u);if(!d)throw RangeError(`No cell with offset ${u} found`);const f=i+u+1;return new ic(l.resolve(f),l.resolve(f+d.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){const r=e.resolve(t.map(this.$anchorCell.pos)),o=e.resolve(t.map(this.$headCell.pos));if(Ba(r)&&Ba(o)&&Lc(r,o)){const i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?jt.rowSelection(r,o):i&&this.isColSelection()?jt.colSelection(r,o):new jt(r,o)}return Z.between(r,o)}content(){const e=this.$anchorCell.node(-1),t=ge.get(e),r=this.$anchorCell.start(-1),o=t.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),i={},s=[];for(let a=o.top;a<o.bottom;a++){const c=[];for(let u=a*t.width+o.left,d=o.left;d<o.right;d++,u++){const f=t.map[u];if(i[f])continue;i[f]=!0;const p=t.findCell(f);let m=e.nodeAt(f);if(!m)throw RangeError(`No cell with offset ${f} found`);const g=o.left-p.left,y=p.right-o.right;if(g>0||y>0){let b=m.attrs;if(g>0&&(b=jn(b,0,g)),y>0&&(b=jn(b,b.colspan-y,y)),p.left<o.left){if(m=m.type.createAndFill(b),!m)throw RangeError(`Could not create cell with attrs ${JSON.stringify(b)}`)}else m=m.type.create(b,m.content)}if(p.top<o.top||p.bottom>o.bottom){const b={...m.attrs,rowspan:Math.min(p.bottom,o.bottom)-Math.max(p.top,o.top)};p.top<o.top?m=m.type.createAndFill(b):m=m.type.create(b,m.content)}c.push(m)}s.push(e.child(a).copy(j.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:s;return new $(j.from(l),1,1)}replace(e,t=$.empty){const r=e.steps.length,o=this.ranges;for(let s=0;s<o.length;s++){const{$from:l,$to:a}=o[s],c=e.mapping.slice(r);e.replace(c.map(l.pos),c.map(a.pos),s?$.empty:t)}const i=te.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,t){this.replace(e,new $(j.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),r=ge.get(t),o=this.$anchorCell.start(-1),i=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o));for(let s=0;s<i.length;s++)e(t.nodeAt(i[s]),o+i[s])}isColSelection(){const e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,o=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,o)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){const r=e.node(-1),o=ge.get(r),i=e.start(-1),s=o.findCell(e.pos-i),l=o.findCell(t.pos-i),a=e.node(0);return s.top<=l.top?(s.top>0&&(e=a.resolve(i+o.map[s.left])),l.bottom<o.height&&(t=a.resolve(i+o.map[o.width*(o.height-1)+l.right-1]))):(l.top>0&&(t=a.resolve(i+o.map[l.left])),s.bottom<o.height&&(e=a.resolve(i+o.map[o.width*(o.height-1)+s.right-1]))),new jt(e,t)}isRowSelection(){const e=this.$anchorCell.node(-1),t=ge.get(e),r=this.$anchorCell.start(-1),o=t.colCount(this.$anchorCell.pos-r),i=t.colCount(this.$headCell.pos-r);if(Math.min(o,i)>0)return!1;const s=o+this.$anchorCell.nodeAfter.attrs.colspan,l=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(s,l)==t.width}eq(e){return e instanceof jt&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){const r=e.node(-1),o=ge.get(r),i=e.start(-1),s=o.findCell(e.pos-i),l=o.findCell(t.pos-i),a=e.node(0);return s.left<=l.left?(s.left>0&&(e=a.resolve(i+o.map[s.top*o.width])),l.right<o.width&&(t=a.resolve(i+o.map[o.width*(l.top+1)-1]))):(l.left>0&&(t=a.resolve(i+o.map[l.top*o.width])),s.right<o.width&&(e=a.resolve(i+o.map[o.width*(s.top+1)-1]))),new jt(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new jt(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){return new jt(e.resolve(t),e.resolve(r))}getBookmark(){return new yC(this.$anchorCell.pos,this.$headCell.pos)}};ye.prototype.visible=!1;te.jsonID("cell",ye);var yC=class zg{constructor(e,t){this.anchor=e,this.head=t}map(e){return new zg(e.map(this.anchor),e.map(this.head))}resolve(e){const t=e.resolve(this.anchor),r=e.resolve(this.head);return t.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&t.index()<t.parent.childCount&&r.index()<r.parent.childCount&&Lc(t,r)?new ye(t,r):te.near(r,1)}};function bC(n){if(!(n.selection instanceof ye))return null;const e=[];return n.selection.forEachCell((t,r)=>{e.push(Pe.node(r,r+t.nodeSize,{class:"selectedCell"}))}),xe.create(n.doc,e)}function vC({$from:n,$to:e}){if(n.pos==e.pos||n.pos<e.pos-6)return!1;let t=n.pos,r=e.pos,o=n.depth;for(;o>=0&&!(n.after(o+1)<n.end(o));o--,t++);for(let i=e.depth;i>=0&&!(e.before(i+1)>e.start(i));i--,r--);return t==r&&/row|table/.test(n.node(o).type.spec.tableRole)}function xC({$from:n,$to:e}){let t,r;for(let o=n.depth;o>0;o--){const i=n.node(o);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){t=i;break}}for(let o=e.depth;o>0;o--){const i=e.node(o);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){r=i;break}}return t!==r&&e.parentOffset===0}function wC(n,e,t){const r=(e||n).selection,o=(e||n).doc;let i,s;if(r instanceof K&&(s=r.node.type.spec.tableRole)){if(s=="cell"||s=="header_cell")i=ye.create(o,r.from);else if(s=="row"){const l=o.resolve(r.from+1);i=ye.rowSelection(l,l)}else if(!t){const l=ge.get(r.node),a=r.from+1,c=a+l.map[l.width*l.height-1];i=ye.create(o,a+1,c)}}else r instanceof Z&&vC(r)?i=Z.create(o,r.from):r instanceof Z&&xC(r)&&(i=Z.create(o,r.$from.start(),r.$from.end()));return i&&(e||(e=n.tr)).setSelection(i),e}var SC=new ht("fix-tables");function $g(n,e,t,r){const o=n.childCount,i=e.childCount;e:for(let s=0,l=0;s<i;s++){const a=e.child(s);for(let c=l,u=Math.min(o,s+3);c<u;c++)if(n.child(c)==a){l=c+1,t+=a.nodeSize;continue e}r(a,t),l<o&&n.child(l).sameMarkup(a)?$g(n.child(l),a,t+1,r):a.nodesBetween(0,a.content.size,r,t+1),t+=a.nodeSize}}function Fg(n,e){let t;const r=(o,i)=>{o.type.spec.tableRole=="table"&&(t=CC(n,o,i,t))};return e?e.doc!=n.doc&&$g(e.doc,n.doc,0,r):n.doc.descendants(r),t}function CC(n,e,t,r){const o=ge.get(e);if(!o.problems)return r;r||(r=n.tr);const i=[];for(let a=0;a<o.height;a++)i.push(0);for(let a=0;a<o.problems.length;a++){const c=o.problems[a];if(c.type=="collision"){const u=e.nodeAt(c.pos);if(!u)continue;const d=u.attrs;for(let f=0;f<d.rowspan;f++)i[c.row+f]+=c.n;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,jn(d,d.colspan-c.n,c.n))}else if(c.type=="missing")i[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const u=e.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,{...u.attrs,rowspan:u.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const u=e.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,{...u.attrs,colwidth:c.colwidth})}else if(c.type=="zero_sized"){const u=r.mapping.map(t);r.delete(u,u+e.nodeSize)}}let s,l;for(let a=0;a<i.length;a++)i[a]&&(s==null&&(s=a),l=a);for(let a=0,c=t+1;a<o.height;a++){const u=e.child(a),d=c+u.nodeSize,f=i[a];if(f>0){let p="cell";u.firstChild&&(p=u.firstChild.type.spec.tableRole);const m=[];for(let y=0;y<f;y++){const b=Xe(n.schema)[p].createAndFill();b&&m.push(b)}const g=(a==0||s==a-1)&&l==a?c+1:d-1;r.insert(r.mapping.map(g),m)}c=d}return r.setMeta(SC,{fixTables:!0})}function It(n){const e=n.selection,t=Ei(n),r=t.node(-1),o=t.start(-1),i=ge.get(r);return{...e instanceof ye?i.rectBetween(e.$anchorCell.pos-o,e.$headCell.pos-o):i.findCell(t.pos-o),tableStart:o,map:i,table:r}}function Vg(n,{map:e,tableStart:t,table:r},o){let i=o>0?-1:0;gC(e,r,o+i)&&(i=o==0||o==e.width?null:0);for(let s=0;s<e.height;s++){const l=s*e.width+o;if(o>0&&o<e.width&&e.map[l-1]==e.map[l]){const a=e.map[l],c=r.nodeAt(a);n.setNodeMarkup(n.mapping.map(t+a),null,Bg(c.attrs,o-e.colCount(a))),s+=c.attrs.rowspan-1}else{const a=i==null?Xe(r.type.schema).cell:r.nodeAt(e.map[l+i]).type,c=e.positionAt(s,o,r);n.insert(n.mapping.map(t+c),a.createAndFill())}}return n}function TC(n,e){if(!Tt(n))return!1;if(e){const t=It(n);e(Vg(n.tr,t,t.left))}return!0}function kC(n,e){if(!Tt(n))return!1;if(e){const t=It(n);e(Vg(n.tr,t,t.right))}return!0}function EC(n,{map:e,table:t,tableStart:r},o){const i=n.mapping.maps.length;for(let s=0;s<e.height;){const l=s*e.width+o,a=e.map[l],c=t.nodeAt(a),u=c.attrs;if(o>0&&e.map[l-1]==a||o<e.width-1&&e.map[l+1]==a)n.setNodeMarkup(n.mapping.slice(i).map(r+a),null,jn(u,o-e.colCount(a)));else{const d=n.mapping.slice(i).map(r+a);n.delete(d,d+c.nodeSize)}s+=u.rowspan}}function MC(n,e){if(!Tt(n))return!1;if(e){const t=It(n),r=n.tr;if(t.left==0&&t.right==t.map.width)return!1;for(let o=t.right-1;EC(r,t,o),o!=t.left;o--){const i=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc;if(!i)throw RangeError("No table found");t.table=i,t.map=ge.get(i)}e(r)}return!0}function OC(n,e,t){var r;const o=Xe(e.type.schema).header_cell;for(let i=0;i<n.width;i++)if(((r=e.nodeAt(n.map[i+t*n.width]))==null?void 0:r.type)!=o)return!1;return!0}function Hg(n,{map:e,tableStart:t,table:r},o){var i;let s=t;for(let c=0;c<o;c++)s+=r.child(c).nodeSize;const l=[];let a=o>0?-1:0;OC(e,r,o+a)&&(a=o==0||o==e.height?null:0);for(let c=0,u=e.width*o;c<e.width;c++,u++)if(o>0&&o<e.height&&e.map[u]==e.map[u-e.width]){const d=e.map[u],f=r.nodeAt(d).attrs;n.setNodeMarkup(t+d,null,{...f,rowspan:f.rowspan+1}),c+=f.colspan-1}else{const d=a==null?Xe(r.type.schema).cell:(i=r.nodeAt(e.map[u+a*e.width]))==null?void 0:i.type,f=d==null?void 0:d.createAndFill();f&&l.push(f)}return n.insert(s,Xe(r.type.schema).row.create(null,l)),n}function AC(n,e){if(!Tt(n))return!1;if(e){const t=It(n);e(Hg(n.tr,t,t.top))}return!0}function NC(n,e){if(!Tt(n))return!1;if(e){const t=It(n);e(Hg(n.tr,t,t.bottom))}return!0}function RC(n,{map:e,table:t,tableStart:r},o){let i=0;for(let c=0;c<o;c++)i+=t.child(c).nodeSize;const s=i+t.child(o).nodeSize,l=n.mapping.maps.length;n.delete(i+r,s+r);const a=new Set;for(let c=0,u=o*e.width;c<e.width;c++,u++){const d=e.map[u];if(!a.has(d)){if(a.add(d),o>0&&d==e.map[u-e.width]){const f=t.nodeAt(d).attrs;n.setNodeMarkup(n.mapping.slice(l).map(d+r),null,{...f,rowspan:f.rowspan-1}),c+=f.colspan-1}else if(o<e.height&&d==e.map[u+e.width]){const f=t.nodeAt(d),p=f.attrs,m=f.type.create({...p,rowspan:f.attrs.rowspan-1},f.content),g=e.positionAt(o+1,c,t);n.insert(n.mapping.slice(l).map(r+g),m),c+=p.colspan-1}}}}function IC(n,e){if(!Tt(n))return!1;if(e){const t=It(n),r=n.tr;if(t.top==0&&t.bottom==t.map.height)return!1;for(let o=t.bottom-1;RC(r,t,o),o!=t.top;o--){const i=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc;if(!i)throw RangeError("No table found");t.table=i,t.map=ge.get(t.table)}e(r)}return!0}function Bd(n){const e=n.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function _C({width:n,height:e,map:t},r){let o=r.top*n+r.left,i=o,s=(r.bottom-1)*n+r.left,l=o+(r.right-r.left-1);for(let a=r.top;a<r.bottom;a++){if(r.left>0&&t[i]==t[i-1]||r.right<n&&t[l]==t[l+1])return!0;i+=n,l+=n}for(let a=r.left;a<r.right;a++){if(r.top>0&&t[o]==t[o-n]||r.bottom<e&&t[s]==t[s+n])return!0;o++,s++}return!1}function zd(n,e){const t=n.selection;if(!(t instanceof ye)||t.$anchorCell.pos==t.$headCell.pos)return!1;const r=It(n),{map:o}=r;if(_C(o,r))return!1;if(e){const i=n.tr,s={};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=o.map[u*o.width+d],p=r.table.nodeAt(f);if(!(s[f]||!p))if(s[f]=!0,a==null)a=f,c=p;else{Bd(p)||(l=l.append(p.content));const m=i.mapping.map(f+r.tableStart);i.delete(m,m+p.nodeSize)}}if(a==null||c==null)return!0;if(i.setNodeMarkup(a+r.tableStart,null,{...Bg(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),rowspan:r.bottom-r.top}),l.size){const u=a+1+c.content.size,d=Bd(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 $d(n,e){const t=Xe(n.schema);return DC(({node:r})=>t[r.type.spec.tableRole])(n,e)}function DC(n){return(e,t)=>{var r;const o=e.selection;let i,s;if(o instanceof ye){if(o.$anchorCell.pos!=o.$headCell.pos)return!1;i=o.$anchorCell.nodeAfter,s=o.$anchorCell.pos}else{if(i=hC(o.$from),!i)return!1;s=(r=gr(o.$from))==null?void 0:r.pos}if(i==null||s==null||i.attrs.colspan==1&&i.attrs.rowspan==1)return!1;if(t){let l=i.attrs;const a=[],c=l.colwidth;l.rowspan>1&&(l={...l,rowspan:1}),l.colspan>1&&(l={...l,colspan:1});const u=It(e),d=e.tr;for(let p=0;p<u.right-u.left;p++)a.push(c?{...l,colwidth:c&&c[p]?[c[p]]:null}:l);let f;for(let p=u.top;p<u.bottom;p++){let m=u.map.positionAt(p,u.left,u.table);p==u.top&&(m+=i.nodeSize);for(let g=u.left,y=0;g<u.right;g++,y++)g==u.left&&p==u.top||d.insert(f=d.mapping.map(m+u.tableStart,1),n({node:i,row:p,col:g}).createAndFill(a[y]))}d.setNodeMarkup(s,n({node:i,row:u.top,col:u.left}),a[0]),o instanceof ye&&d.setSelection(new ye(d.doc.resolve(o.$anchorCell.pos),f?d.doc.resolve(f):void 0)),t(d)}return!0}}function jC(n,e){return function(t,r){if(!Tt(t))return!1;const o=Ei(t);if(o.nodeAfter.attrs[n]===e)return!1;if(r){const i=t.tr;t.selection instanceof ye?t.selection.forEachCell((s,l)=>{s.attrs[n]!==e&&i.setNodeMarkup(l,null,{...s.attrs,[n]:e})}):i.setNodeMarkup(o.pos,null,{...o.nodeAfter.attrs,[n]:e}),r(i)}return!0}}function PC(n){return function(e,t){if(!Tt(e))return!1;if(t){const r=Xe(e.schema),o=It(e),i=e.tr,s=o.map.cellsInRect(n=="column"?{left:o.left,top:0,right:o.right,bottom:o.map.height}:n=="row"?{left:0,top:o.top,right:o.map.width,bottom:o.bottom}:o),l=s.map(a=>o.table.nodeAt(a));for(let a=0;a<s.length;a++)l[a].type==r.header_cell&&i.setNodeMarkup(o.tableStart+s[a],r.cell,l[a].attrs);if(i.steps.length==0)for(let a=0;a<s.length;a++)i.setNodeMarkup(o.tableStart+s[a],r.header_cell,l[a].attrs);t(i)}return!0}}function Fd(n,e,t){const r=e.map.cellsInRect({left:0,top:0,right:n=="row"?e.map.width:1,bottom:n=="column"?e.map.height:1});for(let o=0;o<r.length;o++){const i=e.table.nodeAt(r[o]);if(i&&i.type!==t.header_cell)return!1}return!0}function Xr(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?PC(n):function(t,r){if(!Tt(t))return!1;if(r){const o=Xe(t.schema),i=It(t),s=t.tr,l=Fd("row",i,o),a=Fd("column",i,o),u=(n==="column"?l:n==="row"?a:!1)?1:0,d=n=="column"?{left:0,top:u,right:1,bottom:i.map.height}:n=="row"?{left:u,top:0,right:i.map.width,bottom:1}:i,f=n=="column"?a?o.cell:o.header_cell:n=="row"?l?o.cell:o.header_cell:o.cell;i.map.cellsInRect(d).forEach(p=>{const m=p+i.tableStart,g=s.doc.nodeAt(m);g&&s.setNodeMarkup(m,f,g.attrs)}),r(s)}return!0}}Xr("row",{useDeprecatedLogic:!0});Xr("column",{useDeprecatedLogic:!0});var LC=Xr("cell",{useDeprecatedLogic:!0});function BC(n,e){if(e<0){const t=n.nodeBefore;if(t)return n.pos-t.nodeSize;for(let r=n.index(-1)-1,o=n.before();r>=0;r--){const i=n.node(-1).child(r),s=i.lastChild;if(s)return o-1-s.nodeSize;o-=i.nodeSize}}else{if(n.index()<n.parent.childCount-1)return n.pos+n.nodeAfter.nodeSize;const t=n.node(-1);for(let r=n.indexAfter(-1),o=n.after();r<t.childCount;r++){const i=t.child(r);if(i.childCount)return o+1;o+=i.nodeSize}}return null}function Vd(n){return function(e,t){if(!Tt(e))return!1;const r=BC(Ei(e),n);if(r==null)return!1;if(t){const o=e.doc.resolve(r);t(e.tr.setSelection(Z.between(o,mC(o))).scrollIntoView())}return!0}}function zC(n,e){const t=n.selection.$anchor;for(let r=t.depth;r>0;r--)if(t.node(r).type.spec.tableRole=="table")return e&&e(n.tr.delete(t.before(r),t.after(r)).scrollIntoView()),!0;return!1}function bo(n,e){const t=n.selection;if(!(t instanceof ye))return!1;if(e){const r=n.tr,o=Xe(n.schema).cell.createAndFill().content;t.forEachCell((i,s)=>{i.content.eq(o)||r.replace(r.mapping.map(s+1),r.mapping.map(s+i.nodeSize-1),new $(o,0,0))}),r.docChanged&&e(r)}return!0}function $C(n){if(!n.size)return null;let{content:e,openStart:t,openEnd:r}=n;for(;e.childCount==1&&(t>0&&r>0||e.child(0).type.spec.tableRole=="table");)t--,r--,e=e.child(0).content;const o=e.child(0),i=o.type.spec.tableRole,s=o.type.schema,l=[];if(i=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content;const u=a?0:Math.max(0,t-1),d=a<e.childCount-1?0:Math.max(0,r-1);(u||d)&&(c=za(Xe(s).row,new $(c,u,d)).content),l.push(c)}else if(i=="cell"||i=="header_cell")l.push(t||r?za(Xe(s).row,new $(e,t,r)).content:e);else return null;return FC(s,l)}function FC(n,e){const t=[];for(let o=0;o<e.length;o++){const i=e[o];for(let s=i.childCount-1;s>=0;s--){const{rowspan:l,colspan:a}=i.child(s).attrs;for(let c=o;c<o+l;c++)t[c]=(t[c]||0)+a}}let r=0;for(let o=0;o<t.length;o++)r=Math.max(r,t[o]);for(let o=0;o<t.length;o++)if(o>=e.length&&e.push(j.empty),t[o]<r){const i=Xe(n).cell.createAndFill(),s=[];for(let l=t[o];l<r;l++)s.push(i);e[o]=e[o].append(j.from(s))}return{height:e.length,width:r,rows:e}}function za(n,e){const t=n.createAndFill();return new oc(t).replace(0,t.content.size,e).doc}function VC({width:n,height:e,rows:t},r,o){if(n!=r){const i=[],s=[];for(let l=0;l<t.length;l++){const a=t[l],c=[];for(let u=i[l]||0,d=0;u<r;d++){let f=a.child(d%a.childCount);u+f.attrs.colspan>r&&(f=f.type.createChecked(jn(f.attrs,f.attrs.colspan,u+f.attrs.colspan-r),f.content)),c.push(f),u+=f.attrs.colspan;for(let p=1;p<f.attrs.rowspan;p++)i[l+p]=(i[l+p]||0)+f.attrs.colspan}s.push(j.from(c))}t=s,n=r}if(e!=o){const i=[];for(let s=0,l=0;s<o;s++,l++){const a=[],c=t[l%e];for(let u=0;u<c.childCount;u++){let d=c.child(u);s+d.attrs.rowspan>o&&(d=d.type.create({...d.attrs,rowspan:Math.max(1,o-d.attrs.rowspan)},d.content)),a.push(d)}i.push(j.from(a))}t=i,e=o}return{width:n,height:e,rows:t}}function HC(n,e,t,r,o,i,s){const l=n.doc.type.schema,a=Xe(l);let c,u;if(o>e.width)for(let d=0,f=0;d<e.height;d++){const p=t.child(d);f+=p.nodeSize;const m=[];let g;p.lastChild==null||p.lastChild.type==a.cell?g=c||(c=a.cell.createAndFill()):g=u||(u=a.header_cell.createAndFill());for(let y=e.width;y<o;y++)m.push(g);n.insert(n.mapping.slice(s).map(f-1+r),m)}if(i>e.height){const d=[];for(let m=0,g=(e.height-1)*e.width;m<Math.max(e.width,o);m++){const y=m>=e.width?!1:t.nodeAt(e.map[g+m]).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)),p=[];for(let m=e.height;m<i;m++)p.push(f);n.insert(n.mapping.slice(s).map(r+t.nodeSize-2),p)}return!!(c||u)}function Hd(n,e,t,r,o,i,s,l){if(s==0||s==e.height)return!1;let a=!1;for(let c=o;c<i;c++){const u=s*e.width+c,d=e.map[u];if(e.map[u-e.width]==d){a=!0;const f=t.nodeAt(d),{top:p,left:m}=e.findCell(d);n.setNodeMarkup(n.mapping.slice(l).map(d+r),null,{...f.attrs,rowspan:s-p}),n.insert(n.mapping.slice(l).map(e.positionAt(s,m,t)),f.type.createAndFill({...f.attrs,rowspan:p+f.attrs.rowspan-s})),c+=f.attrs.colspan-1}}return a}function qd(n,e,t,r,o,i,s,l){if(s==0||s==e.width)return!1;let a=!1;for(let c=o;c<i;c++){const u=c*e.width+s,d=e.map[u];if(e.map[u-1]==d){a=!0;const f=t.nodeAt(d),p=e.colCount(d),m=n.mapping.slice(l).map(d+r);n.setNodeMarkup(m,null,jn(f.attrs,s-p,f.attrs.colspan-(s-p))),n.insert(m+f.nodeSize,f.type.createAndFill(jn(f.attrs,0,s-p))),c+=f.attrs.rowspan-1}}return a}function Wd(n,e,t,r,o){let i=t?n.doc.nodeAt(t-1):n.doc;if(!i)throw new Error("No table found");let s=ge.get(i);const{top:l,left:a}=r,c=a+o.width,u=l+o.height,d=n.tr;let f=0;function p(){if(i=t?d.doc.nodeAt(t-1):d.doc,!i)throw new Error("No table found");s=ge.get(i),f=d.mapping.maps.length}HC(d,s,i,t,c,u,f)&&p(),Hd(d,s,i,t,a,c,l,f)&&p(),Hd(d,s,i,t,a,c,u,f)&&p(),qd(d,s,i,t,l,u,a,f)&&p(),qd(d,s,i,t,l,u,c,f)&&p();for(let m=l;m<u;m++){const g=s.positionAt(m,a,i),y=s.positionAt(m,c,i);d.replace(d.mapping.slice(f).map(g+t),d.mapping.slice(f).map(y+t),new $(o.rows[m-l],0,0))}p(),d.setSelection(new ye(d.doc.resolve(t+s.positionAt(l,a,i)),d.doc.resolve(t+s.positionAt(u-1,c-1,i)))),e(d)}var qC=gc({ArrowLeft:vo("horiz",-1),ArrowRight:vo("horiz",1),ArrowUp:vo("vert",-1),ArrowDown:vo("vert",1),"Shift-ArrowLeft":xo("horiz",-1),"Shift-ArrowRight":xo("horiz",1),"Shift-ArrowUp":xo("vert",-1),"Shift-ArrowDown":xo("vert",1),Backspace:bo,"Mod-Backspace":bo,Delete:bo,"Mod-Delete":bo});function zo(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function vo(n,e){return(t,r,o)=>{if(!o)return!1;const i=t.selection;if(i instanceof ye)return zo(t,r,te.near(i.$headCell,e));if(n!="horiz"&&!i.empty)return!1;const s=qg(o,n,e);if(s==null)return!1;if(n=="horiz")return zo(t,r,te.near(t.doc.resolve(i.head+e),e));{const l=t.doc.resolve(s),a=Lg(l,n,e);let c;return a?c=te.near(a,1):e<0?c=te.near(t.doc.resolve(l.before(-1)),-1):c=te.near(t.doc.resolve(l.after(-1)),1),zo(t,r,c)}}}function xo(n,e){return(t,r,o)=>{if(!o)return!1;const i=t.selection;let s;if(i instanceof ye)s=i;else{const a=qg(o,n,e);if(a==null)return!1;s=new ye(t.doc.resolve(a))}const l=Lg(s.$headCell,n,e);return l?zo(t,r,new ye(s.$anchorCell,l)):!1}}function WC(n,e){const t=n.state.doc,r=gr(t.resolve(e));return r?(n.dispatch(n.state.tr.setSelection(new ye(r))),!0):!1}function UC(n,e,t){if(!Tt(n.state))return!1;let r=$C(t);const o=n.state.selection;if(o instanceof ye){r||(r={width:1,height:1,rows:[j.from(za(Xe(n.state.schema).cell,t))]});const i=o.$anchorCell.node(-1),s=o.$anchorCell.start(-1),l=ge.get(i).rectBetween(o.$anchorCell.pos-s,o.$headCell.pos-s);return r=VC(r,l.right-l.left,l.bottom-l.top),Wd(n.state,n.dispatch,s,l,r),!0}else if(r){const i=Ei(n.state),s=i.start(-1);return Wd(n.state,n.dispatch,s,ge.get(i.node(-1)).findCell(i.pos-s),r),!0}else return!1}function GC(n,e){var t;if(e.ctrlKey||e.metaKey)return;const r=Ud(n,e.target);let o;if(e.shiftKey&&n.state.selection instanceof ye)i(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(o=gr(n.state.selection.$anchor))!=null&&((t=gs(n,e))==null?void 0:t.pos)!=o.pos)i(o,e),e.preventDefault();else if(!r)return;function i(a,c){let u=gs(n,c);const d=Qt.getState(n.state)==null;if(!u||!Lc(a,u))if(d)u=a;else return;const f=new ye(a,u);if(d||!n.state.selection.eq(f)){const p=n.state.tr.setSelection(f);d&&p.setMeta(Qt,a.pos),n.dispatch(p)}}function s(){n.root.removeEventListener("mouseup",s),n.root.removeEventListener("dragstart",s),n.root.removeEventListener("mousemove",l),Qt.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(Qt,-1))}function l(a){const c=a,u=Qt.getState(n.state);let d;if(u!=null)d=n.state.doc.resolve(u);else if(Ud(n,c.target)!=r&&(d=gs(n,e),!d))return s();d&&i(d,c)}n.root.addEventListener("mouseup",s),n.root.addEventListener("dragstart",s),n.root.addEventListener("mousemove",l)}function qg(n,e,t){if(!(n.state.selection instanceof Z))return null;const{$head:r}=n.state.selection;for(let o=r.depth-1;o>=0;o--){const i=r.node(o);if((t<0?r.index(o):r.indexAfter(o))!=(t<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){const l=r.before(o),a=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(a)?l:null}}return null}function Ud(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function gs(n,e){const t=n.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?gr(n.state.doc.resolve(t.pos)):null}var KC=class{constructor(e,t){this.node=e,this.defaultCellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${t}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),$a(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,$a(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function $a(n,e,t,r,o,i){var s;let l=0,a=!0,c=e.firstChild;const u=n.firstChild;if(u){for(let d=0,f=0;d<u.childCount;d++){const{colspan:p,colwidth:m}=u.child(d).attrs;for(let g=0;g<p;g++,f++){const y=o==f?i:m&&m[g],b=y?y+"px":"";if(l+=y||r,y||(a=!1),c)c.style.width!=b&&(c.style.width=b),c=c.nextSibling;else{const w=document.createElement("col");w.style.width=b,e.appendChild(w)}}}for(;c;){const d=c.nextSibling;(s=c.parentNode)==null||s.removeChild(c),c=d}a?(t.style.width=l+"px",t.style.minWidth=""):(t.style.width="",t.style.minWidth=l+"px")}}var ft=new ht("tableColumnResizing");function JC({handleWidth:n=5,cellMinWidth:e=25,defaultCellMinWidth:t=100,View:r=KC,lastColumnResizable:o=!0}={}){const i=new $e({key:ft,state:{init(s,l){var a,c;const u=(c=(a=i.spec)==null?void 0:a.props)==null?void 0:c.nodeViews,d=Xe(l.schema).table.name;return r&&u&&(u[d]=(f,p)=>new r(f,t,p)),new XC(-1,!1)},apply(s,l){return l.apply(s)}},props:{attributes:s=>{const l=ft.getState(s);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(s,l)=>{ZC(s,l,n,o)},mouseleave:s=>{YC(s)},mousedown:(s,l)=>{QC(s,l,e,t)}},decorations:s=>{const l=ft.getState(s);if(l&&l.activeHandle>-1)return oT(s,l.activeHandle)},nodeViews:{}}});return i}var XC=class $o{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){const t=this,r=e.getMeta(ft);if(r&&r.setHandle!=null)return new $o(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new $o(t.activeHandle,r.setDragging);if(t.activeHandle>-1&&e.docChanged){let o=e.mapping.map(t.activeHandle,-1);return Ba(e.doc.resolve(o))||(o=-1),new $o(o,t.dragging)}return t}};function ZC(n,e,t,r){if(!n.editable)return;const o=ft.getState(n.state);if(o&&!o.dragging){const i=tT(e.target);let s=-1;if(i){const{left:l,right:a}=i.getBoundingClientRect();e.clientX-l<=t?s=Gd(n,e,"left",t):a-e.clientX<=t&&(s=Gd(n,e,"right",t))}if(s!=o.activeHandle){if(!r&&s!==-1){const l=n.state.doc.resolve(s),a=l.node(-1),c=ge.get(a),u=l.start(-1);if(c.colCount(l.pos-u)+l.nodeAfter.attrs.colspan-1==c.width-1)return}Wg(n,s)}}}function YC(n){if(!n.editable)return;const e=ft.getState(n.state);e&&e.activeHandle>-1&&!e.dragging&&Wg(n,-1)}function QC(n,e,t,r){var o;if(!n.editable)return!1;const i=(o=n.dom.ownerDocument.defaultView)!=null?o:window,s=ft.getState(n.state);if(!s||s.activeHandle==-1||s.dragging)return!1;const l=n.state.doc.nodeAt(s.activeHandle),a=eT(n,s.activeHandle,l.attrs);n.dispatch(n.state.tr.setMeta(ft,{setDragging:{startX:e.clientX,startWidth:a}}));function c(d){i.removeEventListener("mouseup",c),i.removeEventListener("mousemove",u);const f=ft.getState(n.state);f!=null&&f.dragging&&(nT(n,f.activeHandle,Kd(f.dragging,d,t)),n.dispatch(n.state.tr.setMeta(ft,{setDragging:null})))}function u(d){if(!d.which)return c(d);const f=ft.getState(n.state);if(f&&f.dragging){const p=Kd(f.dragging,d,t);Jd(n,f.activeHandle,p,r)}}return Jd(n,s.activeHandle,a,r),i.addEventListener("mouseup",c),i.addEventListener("mousemove",u),e.preventDefault(),!0}function eT(n,e,{colspan:t,colwidth:r}){const o=r&&r[r.length-1];if(o)return o;const i=n.domAtPos(e);let l=i.node.childNodes[i.offset].offsetWidth,a=t;if(r)for(let c=0;c<t;c++)r[c]&&(l-=r[c],a--);return l/a}function tT(n){for(;n&&n.nodeName!="TD"&&n.nodeName!="TH";)n=n.classList&&n.classList.contains("ProseMirror")?null:n.parentNode;return n}function Gd(n,e,t,r){const o=t=="right"?-r:r,i=n.posAtCoords({left:e.clientX+o,top:e.clientY});if(!i)return-1;const{pos:s}=i,l=gr(n.state.doc.resolve(s));if(!l)return-1;if(t=="right")return l.pos;const a=ge.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 Kd(n,e,t){const r=e.clientX-n.startX;return Math.max(t,n.startWidth+r)}function Wg(n,e){n.dispatch(n.state.tr.setMeta(ft,{setHandle:e}))}function nT(n,e,t){const r=n.state.doc.resolve(e),o=r.node(-1),i=ge.get(o),s=r.start(-1),l=i.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1,a=n.state.tr;for(let c=0;c<i.height;c++){const u=c*i.width+l;if(c&&i.map[u]==i.map[u-i.width])continue;const d=i.map[u],f=o.nodeAt(d).attrs,p=f.colspan==1?0:l-i.colCount(d);if(f.colwidth&&f.colwidth[p]==t)continue;const m=f.colwidth?f.colwidth.slice():rT(f.colspan);m[p]=t,a.setNodeMarkup(s+d,null,{...f,colwidth:m})}a.docChanged&&n.dispatch(a)}function Jd(n,e,t,r){const o=n.state.doc.resolve(e),i=o.node(-1),s=o.start(-1),l=ge.get(i).colCount(o.pos-s)+o.nodeAfter.attrs.colspan-1;let a=n.domAtPos(o.start(-1)).node;for(;a&&a.nodeName!="TABLE";)a=a.parentNode;a&&$a(i,a.firstChild,a,r,l,t)}function rT(n){return Array(n).fill(0)}function oT(n,e){var t;const r=[],o=n.doc.resolve(e),i=o.node(-1);if(!i)return xe.empty;const s=ge.get(i),l=o.start(-1),a=s.colCount(o.pos-l)+o.nodeAfter.attrs.colspan-1;for(let c=0;c<s.height;c++){const u=a+c*s.width;if((a==s.width-1||s.map[u]!=s.map[u+1])&&(c==0||s.map[u]!=s.map[u-s.width])){const d=s.map[u],f=l+d+i.nodeAt(d).nodeSize-1,p=document.createElement("div");p.className="column-resize-handle",(t=ft.getState(n))!=null&&t.dragging&&r.push(Pe.node(l+d,l+d+i.nodeAt(d).nodeSize,{class:"column-resize-dragging"})),r.push(Pe.widget(f,p))}}return xe.create(n.doc,r)}function iT({allowTableNodeSelection:n=!1}={}){return new $e({key:Qt,state:{init(){return null},apply(e,t){const r=e.getMeta(Qt);if(r!=null)return r==-1?null:r;if(t==null||!e.docChanged)return t;const{deleted:o,pos:i}=e.mapping.mapResult(t);return o?null:i}},props:{decorations:bC,handleDOMEvents:{mousedown:GC},createSelectionBetween(e){return Qt.getState(e.state)!=null?e.state.selection:null},handleTripleClick:WC,handleKeyDown:qC,handlePaste:UC},appendTransaction(e,t,r){return wC(r,Fg(r,t),n)}})}function Fa(n,e){return e?["width",`${Math.max(e,n)}px`]:["min-width",`${n}px`]}function Xd(n,e,t,r,o,i){var s;let l=0,a=!0,c=e.firstChild;const u=n.firstChild;if(u!==null)for(let d=0,f=0;d<u.childCount;d+=1){const{colspan:p,colwidth:m}=u.child(d).attrs;for(let g=0;g<p;g+=1,f+=1){const y=o===f?i:m&&m[g],b=y?`${y}px`:"";if(l+=y||r,y||(a=!1),c){if(c.style.width!==b){const[w,v]=Fa(r,y);c.style.setProperty(w,v)}c=c.nextSibling}else{const w=document.createElement("col"),[v,S]=Fa(r,y);w.style.setProperty(v,S),e.appendChild(w)}}}for(;c;){const d=c.nextSibling;(s=c.parentNode)===null||s===void 0||s.removeChild(c),c=d}a?(t.style.width=`${l}px`,t.style.minWidth=""):(t.style.width="",t.style.minWidth=`${l}px`)}class sT{constructor(e,t){this.node=e,this.cellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Xd(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!==this.node.type?!1:(this.node=e,Xd(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type==="attributes"&&(e.target===this.table||this.colgroup.contains(e.target))}}function lT(n,e,t,r){let o=0,i=!0;const s=[],l=n.firstChild;if(!l)return{};for(let d=0,f=0;d<l.childCount;d+=1){const{colspan:p,colwidth:m}=l.child(d).attrs;for(let g=0;g<p;g+=1,f+=1){const y=t===f?r:m&&m[g];o+=y||e,y||(i=!1);const[b,w]=Fa(e,y);s.push(["col",{style:`${b}: ${w}`}])}}const a=i?`${o}px`:"",c=i?"":`${o}px`;return{colgroup:["colgroup",{},...s],tableWidth:a,tableMinWidth:c}}function Zd(n,e){return n.createAndFill()}function aT(n){if(n.cached.tableNodeTypes)return n.cached.tableNodeTypes;const e={};return Object.keys(n.nodes).forEach(t=>{const r=n.nodes[t];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),n.cached.tableNodeTypes=e,e}function cT(n,e,t,r,o){const i=aT(n),s=[],l=[];for(let c=0;c<t;c+=1){const u=Zd(i.cell);if(u&&l.push(u),r){const d=Zd(i.header_cell);d&&s.push(d)}}const a=[];for(let c=0;c<e;c+=1)a.push(i.row.createChecked(null,r&&c===0?s:l));return i.table.createChecked(null,a)}function uT(n){return n instanceof ye}const wo=({editor:n})=>{const{selection:e}=n.state;if(!uT(e))return!1;let t=0;const r=Gm(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)&&(t+=1)}),t===e.ranges.length?(n.commands.deleteTable(),!0):!1},dT=Je.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,handleWidth:5,cellMinWidth:25,View:sT,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:n,HTMLAttributes:e}){const{colgroup:t,tableWidth:r,tableMinWidth:o}=lT(n,this.options.cellMinWidth);return["table",Ue(this.options.HTMLAttributes,e,{style:r?`width: ${r}`:`min-width: ${o}`}),t,["tbody",0]]},addCommands(){return{insertTable:({rows:n=3,cols:e=3,withHeaderRow:t=!0}={})=>({tr:r,dispatch:o,editor:i})=>{const s=cT(i.schema,n,e,t);if(o){const l=r.selection.from+1;r.replaceSelectionWith(s).scrollIntoView().setSelection(Z.near(r.doc.resolve(l)))}return!0},addColumnBefore:()=>({state:n,dispatch:e})=>TC(n,e),addColumnAfter:()=>({state:n,dispatch:e})=>kC(n,e),deleteColumn:()=>({state:n,dispatch:e})=>MC(n,e),addRowBefore:()=>({state:n,dispatch:e})=>AC(n,e),addRowAfter:()=>({state:n,dispatch:e})=>NC(n,e),deleteRow:()=>({state:n,dispatch:e})=>IC(n,e),deleteTable:()=>({state:n,dispatch:e})=>zC(n,e),mergeCells:()=>({state:n,dispatch:e})=>zd(n,e),splitCell:()=>({state:n,dispatch:e})=>$d(n,e),toggleHeaderColumn:()=>({state:n,dispatch:e})=>Xr("column")(n,e),toggleHeaderRow:()=>({state:n,dispatch:e})=>Xr("row")(n,e),toggleHeaderCell:()=>({state:n,dispatch:e})=>LC(n,e),mergeOrSplit:()=>({state:n,dispatch:e})=>zd(n,e)?!0:$d(n,e),setCellAttribute:(n,e)=>({state:t,dispatch:r})=>jC(n,e)(t,r),goToNextCell:()=>({state:n,dispatch:e})=>Vd(1)(n,e),goToPreviousCell:()=>({state:n,dispatch:e})=>Vd(-1)(n,e),fixTables:()=>({state:n,dispatch:e})=>(e&&Fg(n),!0),setCellSelection:n=>({tr:e,dispatch:t})=>{if(t){const r=ye.create(e.doc,n.anchorCell,n.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:wo,"Mod-Backspace":wo,Delete:wo,"Mod-Delete":wo}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[JC({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],iT({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(n){const e={name:n.name,options:n.options,storage:n.storage};return{tableRole:le(H(n,"tableRole",e))}}}),fT=/(android|bb\d+|meego).+mobile|armv7l|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series[46]0|samsungbrowser.*mobile|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i,hT=/CrOS/,pT=/android|ipad|playbook|silk/i;function Yd(n={}){let e=n.ua||typeof navigator<"u"&&navigator.userAgent;return e&&typeof e=="object"&&e.headers&&typeof e.headers["user-agent"]=="string"&&(e=e.headers["user-agent"]),typeof e!="string"?!1:!!(fT.test(e)&&!hT.test(e)||n.tablet&&pT.test(e)||n.tablet&&n.featureDetect&&navigator&&navigator.maxTouchPoints>1&&e.includes("Macintosh")&&e.includes("Safari"))}const Qd=n=>Array.from({length:n}).map((e,t)=>t+1);function mT(n){var u;const[e,t]=x.useState(!0),[r,o]=x.useState({rows:Yd()?ie.TABLE_MAX_GRID_SIZE:ie.TABLE_INIT_GRID_SIZE,cols:Yd()?ie.TABLE_MAX_GRID_SIZE:ie.TABLE_INIT_GRID_SIZE}),[i,s]=x.useState({rows:ie.TABLE_DEFAULT_SELECTED_GRID_SIZE,cols:ie.TABLE_DEFAULT_SELECTED_GRID_SIZE});function l(d,f){d===r.rows&&o(p=>({...p,rows:Math.min(d+1,ie.TABLE_MAX_GRID_SIZE)})),f===r.cols&&o(p=>({...p,cols:Math.min(f+1,ie.TABLE_MAX_GRID_SIZE)})),s({rows:d,cols:f})}function a(d,f){n==null||n.createTable({rows:d,cols:f,withHeaderRow:e}),c()}function c(){t(!1),o({rows:ie.TABLE_INIT_GRID_SIZE,cols:ie.TABLE_INIT_GRID_SIZE}),s({rows:ie.TABLE_DEFAULT_SELECTED_GRID_SIZE,cols:ie.TABLE_DEFAULT_SELECTED_GRID_SIZE})}return h.jsxs(zn,{modal:!0,children:[h.jsx($n,{asChild:!0,children:n==null?void 0:n.children}),h.jsx(mn,{align:"start",className:"w-full !p-2",side:"bottom",children:h.jsxs("div",{className:"table-grid-size-editor p-0",children:[h.jsx("div",{className:"flex flex-col flex-wrap justify-between gap-1",children:(u=Qd(r==null?void 0:r.rows))==null?void 0:u.map(d=>{var f;return h.jsx("div",{className:"flex gap-1",children:(f=Qd(r==null?void 0:r.cols))==null?void 0:f.map(p=>h.jsx("div",{onMouseDown:()=>a(d,p),onMouseOver:()=>l(d,p),className:`cursor-pointer border-border ${p<=i.cols&&d<=i.rows&&"tableCellActive !bg-foreground"}`,children:h.jsx("div",{className:"box-border size-4 rounded-[2px] !border border-solid !border-border p-1"})},`c-${p}`))},`r-${d}`)})}),h.jsxs("div",{className:"mt-2 text-center text-sm text-zinc-600",children:[i.rows,"x",i.cols]})]})})]})}function gT(n){function e(t){n.disabled||n.editor.chain().focus().insertTable({...t,withHeaderRow:!1}).run()}return h.jsx(mT,{createTable:e,children:h.jsx(at,{icon:n==null?void 0:n.icon,tooltip:n==null?void 0:n.tooltip,disabled:n==null?void 0:n.disabled,color:n==null?void 0:n.color,action:n==null?void 0:n.action,isActive:n==null?void 0:n.isActive})})}function Bc(n){return e=>{const t=ge.get(e.$anchorCell.node(-1)),r=e.$anchorCell.start(-1),o=t.cellsInRect(n),i=t.cellsInRect(t.rectBetween(e.$anchorCell.pos-r,e.$headCell.pos-r));for(let s=0,l=o.length;s<l;s+=1)if(!i.includes(o[s]))return!1;return!0}}function zc(n){return dn(e=>e.type.spec.tableRole&&e.type.spec.tableRole==="table")(n)}function $c(n){return n instanceof ye}function yT(n){return e=>{if($c(e)){const t=ge.get(e.$anchorCell.node(-1));return Bc({left:n,right:n+1,top:0,bottom:t.height})(e)}return!1}}function bT(n){return e=>{if($c(e)){const t=ge.get(e.$anchorCell.node(-1));return Bc({left:0,right:t.width,top:n,bottom:n+1})(e)}return!1}}function Ug(n){if($c(n)){const e=ge.get(n.$anchorCell.node(-1));return Bc({left:0,right:e.width,top:0,bottom:e.height})(n)}return!1}function vT(n){return e=>{const t=zc(e);if(t){const r=ge.get(t.node);return(Array.isArray(n)?n:Array.from([n])).reduce((i,s)=>{if(s>=0&&s<=r.width-1){const l=r.cellsInRect({left:s,right:s+1,top:0,bottom:r.height});return i.concat(l.map(a=>{const c=t.node.nodeAt(a),u=a+t.start;return{pos:u,start:u+1,node:c}}))}return i},[])}return null}}function xT(n){return e=>{const t=zc(e);if(t){const r=ge.get(t.node);return(Array.isArray(n)?n:Array.from([n])).reduce((i,s)=>{if(s>=0&&s<=r.height-1){const l=r.cellsInRect({left:0,right:r.width,top:s,bottom:s+1});return i.concat(l.map(a=>{const c=t.node.nodeAt(a),u=a+t.start;return{pos:u,start:u+1,node:c}}))}return i},[])}return null}}function Gg(n){return e=>t=>{const r=zc(t.selection),o=n==="row";if(r){const i=ge.get(r.node);if(e>=0&&e<(o?i.height:i.width)){const s=o?0:e,l=o?e:0,a=o?i.width:e+1,c=o?e+1:i.height,u=i.cellsInRect({left:s,top:l,right:o?a:s+1,bottom:o?l+1:c}),d=c-l===1?u:i.cellsInRect({left:o?s:a-1,top:o?c-1:l,right:a,bottom:c}),f=r.start+u[0],p=r.start+d[d.length-1],m=t.doc.resolve(f),g=t.doc.resolve(p);return t.setSelection(new ye(g,m))}}return t}}const wT=Gg("column"),ST=Gg("row");function CT({editor:n,view:e,state:t,from:r}){const o=e.domAtPos(r).node,s=e.nodeDOM(r)||o;if(!n.isActive(Fc.name)||!s||Ug(t.selection))return!1;let l=s;for(;l&&!["TD","TH"].includes(l.tagName);)l=l.parentElement;return!!(l&&l.querySelector&&l.querySelector("a.grip-column.selected"))}function TT({editor:n,view:e,state:t,from:r}){const o=e.domAtPos(r).node,s=e.nodeDOM(r)||o;if(!n.isActive(Fc.name)||!s||Ug(t.selection))return!1;let l=s;for(;l&&!["TD","TH"].includes(l.tagName);)l=l.parentElement;return!!(l&&l.querySelector&&l.querySelector("a.grip-row.selected"))}const kT=Je.create({name:"tableCell",content:"block+",tableRole:"cell",isolating:!0,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:n}){return["td",Ue(this.options.HTMLAttributes,n),0]},addAttributes(){return{colspan:{default:1,parseHTML:n=>{const e=n.getAttribute("colspan");return e?Number.parseInt(e,10):1}},rowspan:{default:1,parseHTML:n=>{const e=n.getAttribute("rowspan");return e?Number.parseInt(e,10):1}},colwidth:{default:null,parseHTML:n=>{const e=n.getAttribute("colwidth");return e?[Number.parseInt(e,10)]:null}},style:{default:null}}},addProseMirrorPlugins(){const{isEditable:n}=this.editor;return[new $e({props:{decorations:e=>{if(!n)return xe.empty;const{doc:t,selection:r}=e,o=[],i=vT(0)(r);return i&&i.forEach(({pos:s},l)=>{o.push(Pe.widget(s+1,()=>{const a=bT(l)(r);let c="grip-row";a&&(c+=" selected"),l===0&&(c+=" first"),l===i.length-1&&(c+=" last");const u=document.createElement("a");return u.className=c,u.addEventListener("mousedown",d=>{d.preventDefault(),d.stopImmediatePropagation(),this.editor.view.dispatch(ST(l)(this.editor.state.tr))}),u}))}),xe.create(t,o)}}})]}});function ET(n,e,t){if(!n.doc)return n;const r=n.doc.nodeAt(e);if(!r||t===r.attrs.backgroundColor)return n;const o={...r.attrs,backgroundColor:t};return n.setNodeMarkup(e,r.type,o,r.marks)}function MT(n,e,t){const{doc:r,selection:o}=n;return!r||!o||!(o instanceof ye)||o.forEachCell((i,s)=>{n=ET(n,s,t)}),n}function ef(n,e){return({tr:t,state:r,dispatch:o})=>{const{selection:i}=r;return t=t.setSelection(i),t=MT(t,e,n),t.docChanged?(o==null||o(t),!0):!1}}const OT=lt.create({name:"tableCellBackground",addOptions(){return{types:["tableCell"],HTMLAttributes:{}}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{parseHTML:n=>n.style.backgroundColor||"",renderHTML:n=>!n.backgroundColor||n.backgroundColor===""?{}:{style:`background-color: ${n.backgroundColor}`}}}}]},addCommands(){return{setTableCellBackground:n=>ef(n,this.options),unsetTableCellBackground:()=>ef("",this.options)}}}),AT=Je.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:n=>{const e=n.getAttribute("colwidth");return e?e.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:n}){return["th",Ue(this.options.HTMLAttributes,n),0]}}),NT=AT.extend({addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:n=>{const e=n.getAttribute("colwidth");return e?e.split(",").map(r=>Number.parseInt(r,10)):null}},style:{default:null}}},addProseMirrorPlugins(){const{isEditable:n}=this.editor;return[new $e({props:{decorations:e=>{if(!n)return xe.empty;const{doc:t,selection:r}=e,o=[],i=xT(0)(r);return i&&i.forEach(({pos:s},l)=>{o.push(Pe.widget(s+1,()=>{const a=yT(l)(r);let c="grip-column";a&&(c+=" selected"),l===0&&(c+=" first"),l===i.length-1&&(c+=" last");const u=document.createElement("a");return u.className=c,u.addEventListener("mousedown",d=>{d.preventDefault(),d.stopImmediatePropagation(),this.editor.view.dispatch(wT(l)(this.editor.state.tr))}),u}))}),xe.create(t,o)}}})]}}),RT=aC.extend({allowGapCursor:!1,content:"tableCell*"}),Fc=dT.extend({addOptions(){var n;return{...(n=this.parent)==null?void 0:n.call(this),resizable:!0,lastColumnResizable:!1,allowTableNodeSelection:!1,button:({editor:e,t})=>({component:gT,componentProps:{disabled:e.isActive("table")||!1,icon:"Table",tooltip:t("editor.table.tooltip"),editor:e}})}},addExtensions(){return[RT.configure(this.options.tableRow),NT.configure(this.options.tableHeader),kT.configure(this.options.tableCell),OT.configure(this.options.tableCellBackground)]}}),IT="_wrap_5y04w_1",_T="_innerWrap_5y04w_15",tf={wrap:IT,innerWrap:_T};function DT({editor:n,node:e,updateAttributes:t}){const r=mg(),{url:o,width:i,height:s}=e.attrs,[l,a]=x.useState("");function c(){l&&n.chain().updateAttributes(Kg.name,{url:l}).setNodeSelection(n.state.selection.from).focus().run()}const u=x.useCallback(d=>{t({width:d.width,height:d.height})},[t]);return h.jsxs(Ht,{children:[!o&&h.jsxs("div",{className:"mx-auto my-[12px] flex max-w-[600px] items-center justify-center gap-[10px] rounded-[12px] border border-solid border-[#ccc] p-[10px]",children:[h.jsx(Rt,{autoFocus:!0,className:"flex-1",onInput:d=>a(d.target.value),placeholder:"Enter link",type:"url",value:l}),h.jsx(Be,{className:"w-[60px]",onClick:c,children:"OK"})]}),o&&h.jsx(dp.Resizable,{size:{width:Number.parseInt(i),height:Number.parseInt(s)},onResizeStop:(d,f,p,m)=>{u({width:Number.parseInt(i)+m.width,height:Number.parseInt(s)+m.height})},children:h.jsx("div",{className:st(tf.wrap,"render-wrapper"),children:h.jsx("div",{className:tf.innerWrap,style:{pointerEvents:r?"none":"auto"},children:h.jsx("iframe",{className:"my-[12px] ",src:o})})})})]})}function jT(n){try{return JSON.stringify(n)}catch{return JSON.stringify({})}}function Nn(n,e=!1){return t=>{const r=n.startsWith("data-")?n:`data-${n}`;let o=decodeURIComponent(t.getAttribute(r));if(o==null||typeof o=="string"&&o==="null")try{const l=t.outerHTML.match(/([\S\s])+?="([\S\s])+?"/g);l&&l.length>0&&(o=(l.map(c=>c.trim()).reduce((c,u)=>{const d=u.indexOf("="),f=[u.slice(0,d),u.slice(d+1).slice(1,-1)];return c[f[0]]=f[1],c},{})[n.toLowerCase()]||"").replaceAll("&quot;",'"'))}catch(s){console.error("Error getDatasetAttribute ",s.message,t)}if(e)try{return JSON.parse(o)}catch{return{}}if(o.includes("%")||o.includes("auto"))return o;const i=Number.parseInt(o);return i!==i?o:i}}function PT(n){const{attrs:e}=n;return Object.keys(e).reduce((t,r)=>{const o=e[r];if(o==null)return t;let i="";return typeof o=="object"?i=jT(o):i=o,t[r]=i,t},Object.create(null))}const Kg=Je.create({name:"iframe",content:"",marks:"",group:"block",selectable:!0,atom:!0,draggable:!0,addOptions(){var n;return{...(n=this.parent)==null?void 0:n.call(this),HTMLAttributes:{class:"iframe"},button:({editor:e,extension:t,t:r})=>({component:at,componentProps:{action:o=>e.commands.setIframe(o),upload:t.options.upload,disabled:!e.can().setIframe({}),icon:"Iframe",tooltip:r("editor.iframe.tooltip")}})}},addAttributes(){return{width:{default:600,parseHTML:Nn("width")},height:{default:300,parseHTML:Nn("height")},url:{default:null,parseHTML:Nn("url")},defaultShowPicker:{default:!1},frameborder:{default:0},allowfullscreen:{default:this.options.allowFullscreen,parseHTML:()=>this.options.allowFullscreen}}},parseHTML(){return[{tag:"iframe"}]},renderHTML({HTMLAttributes:n}){return["iframe",Ue(this.options.HTMLAttributes,n)]},addCommands(){return{setIframe:n=>({tr:e,commands:t,chain:r})=>{var i,s,l;if(((l=(s=(i=e.selection)==null?void 0:i.node)==null?void 0:s.type)==null?void 0:l.name)==this.name)return t.updateAttributes(this.name,n);const o=n||{url:""};return r().insertContent({type:this.name,attrs:o}).run()}}},addInputRules(){return[ro({find:/^\$iframe\$$/,type:this.type,getAttributes:()=>({width:"100%"})})]},addNodeView(){return qt(DT)}});var Zr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Vc(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}function Jg(n){if(Object.prototype.hasOwnProperty.call(n,"__esModule"))return n;var e=n.default;if(typeof e=="function"){var t=function r(){return this instanceof r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(n).forEach(function(r){var o=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(t,r,o.get?o:{enumerable:!0,get:function(){return n[r]}})}),t}var ys,nf;function Xg(){if(nf)return ys;nf=1;var n=Object.prototype.toString;return ys=function(t){var r=n.call(t),o=r==="[object Arguments]";return o||(o=r!=="[object Array]"&&t!==null&&typeof t=="object"&&typeof t.length=="number"&&t.length>=0&&n.call(t.callee)==="[object Function]"),o},ys}var bs,rf;function LT(){if(rf)return bs;rf=1;var n;if(!Object.keys){var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,r=Xg(),o=Object.prototype.propertyIsEnumerable,i=!o.call({toString:null},"toString"),s=o.call(function(){},"prototype"),l=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],a=function(f){var p=f.constructor;return p&&p.prototype===f},c={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},u=function(){if(typeof window>"u")return!1;for(var f in window)try{if(!c["$"+f]&&e.call(window,f)&&window[f]!==null&&typeof window[f]=="object")try{a(window[f])}catch{return!0}}catch{return!0}return!1}(),d=function(f){if(typeof window>"u"||!u)return a(f);try{return a(f)}catch{return!1}};n=function(p){var m=p!==null&&typeof p=="object",g=t.call(p)==="[object Function]",y=r(p),b=m&&t.call(p)==="[object String]",w=[];if(!m&&!g&&!y)throw new TypeError("Object.keys called on a non-object");var v=s&&g;if(b&&p.length>0&&!e.call(p,0))for(var S=0;S<p.length;++S)w.push(String(S));if(y&&p.length>0)for(var T=0;T<p.length;++T)w.push(String(T));else for(var C in p)!(v&&C==="prototype")&&e.call(p,C)&&w.push(String(C));if(i)for(var I=d(p),O=0;O<l.length;++O)!(I&&l[O]==="constructor")&&e.call(p,l[O])&&w.push(l[O]);return w}}return bs=n,bs}var vs,of;function Hc(){if(of)return vs;of=1;var n=Array.prototype.slice,e=Xg(),t=Object.keys,r=t?function(s){return t(s)}:LT(),o=Object.keys;return r.shim=function(){if(Object.keys){var s=function(){var l=Object.keys(arguments);return l&&l.length===arguments.length}(1,2);s||(Object.keys=function(a){return e(a)?o(n.call(a)):o(a)})}else Object.keys=r;return Object.keys||r},vs=r,vs}var xs,sf;function Mi(){if(sf)return xs;sf=1;var n=Object.defineProperty||!1;if(n)try{n({},"a",{value:1})}catch{n=!1}return xs=n,xs}var ws,lf;function qc(){return lf||(lf=1,ws=SyntaxError),ws}var Ss,af;function wt(){return af||(af=1,Ss=TypeError),Ss}var Cs,cf;function BT(){return cf||(cf=1,Cs=Object.getOwnPropertyDescriptor),Cs}var Ts,uf;function Hn(){if(uf)return Ts;uf=1;var n=BT();if(n)try{n([],"length")}catch{n=null}return Ts=n,Ts}var ks,df;function Wc(){if(df)return ks;df=1;var n=Mi(),e=qc(),t=wt(),r=Hn();return ks=function(i,s,l){if(!i||typeof i!="object"&&typeof i!="function")throw new t("`obj` must be an object or a function`");if(typeof s!="string"&&typeof s!="symbol")throw new t("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new t("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new t("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new t("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new t("`loose`, if provided, must be a boolean");var a=arguments.length>3?arguments[3]:null,c=arguments.length>4?arguments[4]:null,u=arguments.length>5?arguments[5]:null,d=arguments.length>6?arguments[6]:!1,f=!!r&&r(i,s);if(n)n(i,s,{configurable:u===null&&f?f.configurable:!u,enumerable:a===null&&f?f.enumerable:!a,value:l,writable:c===null&&f?f.writable:!c});else if(d||!a&&!c&&!u)i[s]=l;else throw new e("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},ks}var Es,ff;function Uc(){if(ff)return Es;ff=1;var n=Mi(),e=function(){return!!n};return e.hasArrayLengthDefineBug=function(){if(!n)return null;try{return n([],"length",{value:1}).length!==1}catch{return!0}},Es=e,Es}var Ms,hf;function qn(){if(hf)return Ms;hf=1;var n=Hc(),e=typeof Symbol=="function"&&typeof Symbol("foo")=="symbol",t=Object.prototype.toString,r=Array.prototype.concat,o=Wc(),i=function(c){return typeof c=="function"&&t.call(c)==="[object Function]"},s=Uc()(),l=function(c,u,d,f){if(u in c){if(f===!0){if(c[u]===d)return}else if(!i(f)||!f())return}s?o(c,u,d,!0):o(c,u,d)},a=function(c,u){var d=arguments.length>2?arguments[2]:{},f=n(u);e&&(f=r.call(f,Object.getOwnPropertySymbols(u)));for(var p=0;p<f.length;p+=1)l(c,f[p],u[f[p]],d[f[p]])};return a.supportsDescriptors=!!s,Ms=a,Ms}var Os={exports:{}},As,pf;function Gc(){return pf||(pf=1,As=Object),As}var Ns,mf;function Zg(){return mf||(mf=1,Ns=Error),Ns}var Rs,gf;function zT(){return gf||(gf=1,Rs=EvalError),Rs}var Is,yf;function $T(){return yf||(yf=1,Is=RangeError),Is}var _s,bf;function FT(){return bf||(bf=1,_s=ReferenceError),_s}var Ds,vf;function VT(){return vf||(vf=1,Ds=URIError),Ds}var js,xf;function HT(){return xf||(xf=1,js=Math.abs),js}var Ps,wf;function qT(){return wf||(wf=1,Ps=Math.floor),Ps}var Ls,Sf;function WT(){return Sf||(Sf=1,Ls=Math.max),Ls}var Bs,Cf;function UT(){return Cf||(Cf=1,Bs=Math.min),Bs}var zs,Tf;function GT(){return Tf||(Tf=1,zs=Math.pow),zs}var $s,kf;function KT(){return kf||(kf=1,$s=Math.round),$s}var Fs,Ef;function JT(){return Ef||(Ef=1,Fs=Number.isNaN||function(e){return e!==e}),Fs}var Vs,Mf;function XT(){if(Mf)return Vs;Mf=1;var n=JT();return Vs=function(t){return n(t)||t===0?t:t<0?-1:1},Vs}var Hs,Of;function Oi(){return Of||(Of=1,Hs=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},t=Symbol("test"),r=Object(t);if(typeof t=="string"||Object.prototype.toString.call(t)!=="[object Symbol]"||Object.prototype.toString.call(r)!=="[object Symbol]")return!1;var o=42;e[t]=o;for(var i in e)return!1;if(typeof Object.keys=="function"&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(e).length!==0)return!1;var s=Object.getOwnPropertySymbols(e);if(s.length!==1||s[0]!==t||!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var l=Object.getOwnPropertyDescriptor(e,t);if(l.value!==o||l.enumerable!==!0)return!1}return!0}),Hs}var qs,Af;function Kc(){if(Af)return qs;Af=1;var n=typeof Symbol<"u"&&Symbol,e=Oi();return qs=function(){return typeof n!="function"||typeof Symbol!="function"||typeof n("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:e()},qs}var Ws,Nf;function Yg(){return Nf||(Nf=1,Ws=typeof Reflect<"u"&&Reflect.getPrototypeOf||null),Ws}var Us,Rf;function Qg(){if(Rf)return Us;Rf=1;var n=Gc();return Us=n.getPrototypeOf||null,Us}var Gs,If;function ZT(){if(If)return Gs;If=1;var n="Function.prototype.bind called on incompatible ",e=Object.prototype.toString,t=Math.max,r="[object Function]",o=function(a,c){for(var u=[],d=0;d<a.length;d+=1)u[d]=a[d];for(var f=0;f<c.length;f+=1)u[f+a.length]=c[f];return u},i=function(a,c){for(var u=[],d=c,f=0;d<a.length;d+=1,f+=1)u[f]=a[d];return u},s=function(l,a){for(var c="",u=0;u<l.length;u+=1)c+=l[u],u+1<l.length&&(c+=a);return c};return Gs=function(a){var c=this;if(typeof c!="function"||e.apply(c)!==r)throw new TypeError(n+c);for(var u=i(arguments,1),d,f=function(){if(this instanceof d){var b=c.apply(this,o(u,arguments));return Object(b)===b?b:this}return c.apply(a,o(u,arguments))},p=t(0,c.length-u.length),m=[],g=0;g<p;g++)m[g]="$"+g;if(d=Function("binder","return function ("+s(m,",")+"){ return binder.apply(this,arguments); }")(f),c.prototype){var y=function(){};y.prototype=c.prototype,d.prototype=new y,y.prototype=null}return d},Gs}var Ks,_f;function oo(){if(_f)return Ks;_f=1;var n=ZT();return Ks=Function.prototype.bind||n,Ks}var Js,Df;function Jc(){return Df||(Df=1,Js=Function.prototype.call),Js}var Xs,jf;function Xc(){return jf||(jf=1,Xs=Function.prototype.apply),Xs}var Zs,Pf;function YT(){return Pf||(Pf=1,Zs=typeof Reflect<"u"&&Reflect&&Reflect.apply),Zs}var Ys,Lf;function e1(){if(Lf)return Ys;Lf=1;var n=oo(),e=Xc(),t=Jc(),r=YT();return Ys=r||n.call(t,e),Ys}var Qs,Bf;function Zc(){if(Bf)return Qs;Bf=1;var n=oo(),e=wt(),t=Jc(),r=e1();return Qs=function(i){if(i.length<1||typeof i[0]!="function")throw new e("a function is required");return r(n,t,i)},Qs}var el,zf;function QT(){if(zf)return el;zf=1;var n=Zc(),e=Hn(),t;try{t=[].__proto__===Array.prototype}catch(s){if(!s||typeof s!="object"||!("code"in s)||s.code!=="ERR_PROTO_ACCESS")throw s}var r=!!t&&e&&e(Object.prototype,"__proto__"),o=Object,i=o.getPrototypeOf;return el=r&&typeof r.get=="function"?n([r.get]):typeof i=="function"?function(l){return i(l==null?l:o(l))}:!1,el}var tl,$f;function t1(){if($f)return tl;$f=1;var n=Yg(),e=Qg(),t=QT();return tl=n?function(o){return n(o)}:e?function(o){if(!o||typeof o!="object"&&typeof o!="function")throw new TypeError("getProto: not an object");return e(o)}:t?function(o){return t(o)}:null,tl}var nl,Ff;function Yc(){if(Ff)return nl;Ff=1;var n=Function.prototype.call,e=Object.prototype.hasOwnProperty,t=oo();return nl=t.call(n,e),nl}var rl,Vf;function Wt(){if(Vf)return rl;Vf=1;var n,e=Gc(),t=Zg(),r=zT(),o=$T(),i=FT(),s=qc(),l=wt(),a=VT(),c=HT(),u=qT(),d=WT(),f=UT(),p=GT(),m=KT(),g=XT(),y=Function,b=function(ee){try{return y('"use strict"; return ('+ee+").constructor;")()}catch{}},w=Hn(),v=Mi(),S=function(){throw new l},T=w?function(){try{return S}catch{try{return w(arguments,"callee").get}catch{return S}}}():S,C=Kc()(),I=t1(),O=Qg(),E=Yg(),R=Xc(),_=Jc(),N={},D=typeof Uint8Array>"u"||!I?n:I(Uint8Array),k={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?n:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?n:ArrayBuffer,"%ArrayIteratorPrototype%":C&&I?I([][Symbol.iterator]()):n,"%AsyncFromSyncIteratorPrototype%":n,"%AsyncFunction%":N,"%AsyncGenerator%":N,"%AsyncGeneratorFunction%":N,"%AsyncIteratorPrototype%":N,"%Atomics%":typeof Atomics>"u"?n:Atomics,"%BigInt%":typeof BigInt>"u"?n:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?n:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?n:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?n:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":t,"%eval%":eval,"%EvalError%":r,"%Float32Array%":typeof Float32Array>"u"?n:Float32Array,"%Float64Array%":typeof Float64Array>"u"?n:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?n:FinalizationRegistry,"%Function%":y,"%GeneratorFunction%":N,"%Int8Array%":typeof Int8Array>"u"?n:Int8Array,"%Int16Array%":typeof Int16Array>"u"?n:Int16Array,"%Int32Array%":typeof Int32Array>"u"?n:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":C&&I?I(I([][Symbol.iterator]())):n,"%JSON%":typeof JSON=="object"?JSON:n,"%Map%":typeof Map>"u"?n:Map,"%MapIteratorPrototype%":typeof Map>"u"||!C||!I?n:I(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":e,"%Object.getOwnPropertyDescriptor%":w,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?n:Promise,"%Proxy%":typeof Proxy>"u"?n:Proxy,"%RangeError%":o,"%ReferenceError%":i,"%Reflect%":typeof Reflect>"u"?n:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?n:Set,"%SetIteratorPrototype%":typeof Set>"u"||!C||!I?n:I(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?n:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":C&&I?I(""[Symbol.iterator]()):n,"%Symbol%":C?Symbol:n,"%SyntaxError%":s,"%ThrowTypeError%":T,"%TypedArray%":D,"%TypeError%":l,"%Uint8Array%":typeof Uint8Array>"u"?n:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?n:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?n:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?n:Uint32Array,"%URIError%":a,"%WeakMap%":typeof WeakMap>"u"?n:WeakMap,"%WeakRef%":typeof WeakRef>"u"?n:WeakRef,"%WeakSet%":typeof WeakSet>"u"?n:WeakSet,"%Function.prototype.call%":_,"%Function.prototype.apply%":R,"%Object.defineProperty%":v,"%Object.getPrototypeOf%":O,"%Math.abs%":c,"%Math.floor%":u,"%Math.max%":d,"%Math.min%":f,"%Math.pow%":p,"%Math.round%":m,"%Math.sign%":g,"%Reflect.getPrototypeOf%":E},L=function ee(Q){var Y;if(Q==="%AsyncFunction%")Y=b("async function () {}");else if(Q==="%GeneratorFunction%")Y=b("function* () {}");else if(Q==="%AsyncGeneratorFunction%")Y=b("async function* () {}");else if(Q==="%AsyncGenerator%"){var X=ee("%AsyncGeneratorFunction%");X&&(Y=X.prototype)}else if(Q==="%AsyncIteratorPrototype%"){var G=ee("%AsyncGenerator%");G&&I&&(Y=I(G.prototype))}return k[Q]=Y,Y},F={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},V=oo(),ue=Yc(),J=V.call(_,Array.prototype.concat),_e=V.call(R,Array.prototype.splice),de=V.call(_,String.prototype.replace),Me=V.call(_,String.prototype.slice),Ne=V.call(_,RegExp.prototype.exec),P=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,z=/\\(\\)?/g,re=function(Q){var Y=Me(Q,0,1),X=Me(Q,-1);if(Y==="%"&&X!=="%")throw new s("invalid intrinsic syntax, expected closing `%`");if(X==="%"&&Y!=="%")throw new s("invalid intrinsic syntax, expected opening `%`");var G=[];return de(Q,P,function(q,se,oe,he){G[G.length]=oe?de(he,z,"$1"):se||q}),G},ne=function(Q,Y){var X=Q,G;if(ue(F,X)&&(G=F[X],X="%"+G[0]+"%"),ue(k,X)){var q=k[X];if(q===N&&(q=L(X)),typeof q>"u"&&!Y)throw new l("intrinsic "+Q+" exists, but is not available. Please file an issue!");return{alias:G,name:X,value:q}}throw new s("intrinsic "+Q+" does not exist!")};return rl=function(Q,Y){if(typeof Q!="string"||Q.length===0)throw new l("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof Y!="boolean")throw new l('"allowMissing" argument must be a boolean');if(Ne(/^%?[^%]*%?$/,Q)===null)throw new s("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var X=re(Q),G=X.length>0?X[0]:"",q=ne("%"+G+"%",Y),se=q.name,oe=q.value,he=!1,ve=q.alias;ve&&(G=ve[0],_e(X,J([0,1],ve)));for(var Oe=1,be=!0;Oe<X.length;Oe+=1){var pe=X[Oe],Ie=Me(pe,0,1),pt=Me(pe,-1);if((Ie==='"'||Ie==="'"||Ie==="`"||pt==='"'||pt==="'"||pt==="`")&&Ie!==pt)throw new s("property names with quotes must have matching quotes");if((pe==="constructor"||!be)&&(he=!0),G+="."+pe,se="%"+G+"%",ue(k,se))oe=k[se];else if(oe!=null){if(!(pe in oe)){if(!Y)throw new l("base intrinsic for "+Q+" exists, but the property is not available.");return}if(w&&Oe+1>=X.length){var mt=w(oe,pe);be=!!mt,be&&"get"in mt&&!("originalValue"in mt.get)?oe=mt.get:oe=oe[pe]}else be=ue(oe,pe),oe=oe[pe];be&&!he&&(k[se]=oe)}}return oe},rl}var ol,Hf;function ek(){if(Hf)return ol;Hf=1;var n=Wt(),e=Wc(),t=Uc()(),r=Hn(),o=wt(),i=n("%Math.floor%");return ol=function(l,a){if(typeof l!="function")throw new o("`fn` is not a function");if(typeof a!="number"||a<0||a>4294967295||i(a)!==a)throw new o("`length` must be a positive 32-bit integer");var c=arguments.length>2&&!!arguments[2],u=!0,d=!0;if("length"in l&&r){var f=r(l,"length");f&&!f.configurable&&(u=!1),f&&!f.writable&&(d=!1)}return(u||d||!c)&&(t?e(l,"length",a,!0,!0):e(l,"length",a)),l},ol}var il,qf;function tk(){if(qf)return il;qf=1;var n=oo(),e=Xc(),t=e1();return il=function(){return t(n,e,arguments)},il}var Wf;function yr(){return Wf||(Wf=1,function(n){var e=ek(),t=Mi(),r=Zc(),o=tk();n.exports=function(s){var l=r(arguments),a=s.length-(arguments.length-1);return e(l,1+(a>0?a:0),!0)},t?t(n.exports,"apply",{value:o}):n.exports.apply=o}(Os)),Os.exports}var sl,Uf;function Ye(){if(Uf)return sl;Uf=1;var n=Wt(),e=Zc(),t=e([n("%String.prototype.indexOf%")]);return sl=function(o,i){var s=n(o,!!i);return typeof s=="function"&&t(o,".prototype.")>-1?e([s]):s},sl}var ll,Gf;function n1(){if(Gf)return ll;Gf=1;var n=Hc(),e=Oi()(),t=Ye(),r=Gc(),o=t("Array.prototype.push"),i=t("Object.prototype.propertyIsEnumerable"),s=e?r.getOwnPropertySymbols:null;return ll=function(a,c){if(a==null)throw new TypeError("target must be an object");var u=r(a);if(arguments.length===1)return u;for(var d=1;d<arguments.length;++d){var f=r(arguments[d]),p=n(f),m=e&&(r.getOwnPropertySymbols||s);if(m)for(var g=m(f),y=0;y<g.length;++y){var b=g[y];i(f,b)&&o(p,b)}for(var w=0;w<p.length;++w){var v=p[w];if(i(f,v)){var S=f[v];u[v]=S}}}return u},ll}var al,Kf;function r1(){if(Kf)return al;Kf=1;var n=n1(),e=function(){if(!Object.assign)return!1;for(var r="abcdefghijklmnopqrst",o=r.split(""),i={},s=0;s<o.length;++s)i[o[s]]=o[s];var l=Object.assign({},i),a="";for(var c in l)a+=c;return r!==a},t=function(){if(!Object.assign||!Object.preventExtensions)return!1;var r=Object.preventExtensions({1:2});try{Object.assign(r,"xy")}catch{return r[1]==="y"}return!1};return al=function(){return!Object.assign||e()||t()?n:Object.assign},al}var cl,Jf;function nk(){if(Jf)return cl;Jf=1;var n=qn(),e=r1();return cl=function(){var r=e();return n(Object,{assign:r},{assign:function(){return Object.assign!==r}}),r},cl}var ul,Xf;function rk(){if(Xf)return ul;Xf=1;var n=qn(),e=yr(),t=n1(),r=r1(),o=nk(),i=e.apply(r()),s=function(a,c){return i(Object,arguments)};return n(s,{getPolyfill:r,implementation:t,shim:o}),ul=s,ul}var dl,Zf;function o1(){if(Zf)return dl;Zf=1;var n=Wt(),e=yr(),t=e(n("String.prototype.indexOf"));return dl=function(o,i){var s=n(o,!!i);return typeof s=="function"&&t(o,".prototype.")>-1?e(s):s},dl}var fl,Yf;function ok(){if(Yf)return fl;Yf=1;var n=function(){return typeof(function(){}).name=="string"},e=Object.getOwnPropertyDescriptor;n.functionsHaveConfigurableNames=function(){if(!n()||!e)return!1;var o=e(function(){},"name");return!!o&&!!o.configurable};var t=Function.prototype.bind;return n.boundFunctionsHaveNames=function(){return n()&&typeof t=="function"&&(function(){}).bind().name!==""},fl=n,fl}var hl,Qf;function ik(){if(Qf)return hl;Qf=1;var n=Wc(),e=Uc()(),t=ok().functionsHaveConfigurableNames(),r=wt();return hl=function(i,s){if(typeof i!="function")throw new r("`fn` is not a function");var l=arguments.length>2&&!!arguments[2];return(!l||t)&&(e?n(i,"name",s,!0,!0):n(i,"name",s)),i},hl}var pl,eh;function i1(){if(eh)return pl;eh=1;var n=ik(),e=wt(),t=Object;return pl=n(function(){if(this==null||this!==t(this))throw new e("RegExp.prototype.flags getter called on non-object");var o="";return this.hasIndices&&(o+="d"),this.global&&(o+="g"),this.ignoreCase&&(o+="i"),this.multiline&&(o+="m"),this.dotAll&&(o+="s"),this.unicode&&(o+="u"),this.unicodeSets&&(o+="v"),this.sticky&&(o+="y"),o},"get flags",!0),pl}var ml,th;function s1(){if(th)return ml;th=1;var n=i1(),e=qn().supportsDescriptors,t=Object.getOwnPropertyDescriptor;return ml=function(){if(e&&/a/mig.flags==="gim"){var o=t(RegExp.prototype,"flags");if(o&&typeof o.get=="function"&&"dotAll"in RegExp.prototype&&"hasIndices"in RegExp.prototype){var i="",s={};if(Object.defineProperty(s,"hasIndices",{get:function(){i+="d"}}),Object.defineProperty(s,"sticky",{get:function(){i+="y"}}),o.get.call(s),i==="dy")return o.get}}return n},ml}var gl,nh;function sk(){if(nh)return gl;nh=1;var n=qn().supportsDescriptors,e=s1(),t=Hn(),r=Object.defineProperty,o=Zg(),i=t1(),s=/a/;return gl=function(){if(!n||!i)throw new o("RegExp.prototype.flags requires a true ES5 environment that supports property descriptors");var a=e(),c=i(s),u=t(c,"flags");return(!u||u.get!==a)&&r(c,"flags",{configurable:!0,enumerable:!1,get:a}),a},gl}var yl,rh;function lk(){if(rh)return yl;rh=1;var n=qn(),e=yr(),t=i1(),r=s1(),o=sk(),i=e(r());return n(i,{getPolyfill:r,implementation:t,shim:o}),yl=i,yl}var Cr={exports:{}},bl,oh;function Wn(){if(oh)return bl;oh=1;var n=Oi();return bl=function(){return n()&&!!Symbol.toStringTag},bl}var vl,ih;function l1(){if(ih)return vl;ih=1;var n=Wn()(),e=Ye(),t=e("Object.prototype.toString"),r=function(l){return n&&l&&typeof l=="object"&&Symbol.toStringTag in l?!1:t(l)==="[object Arguments]"},o=function(l){return r(l)?!0:l!==null&&typeof l=="object"&&"length"in l&&typeof l.length=="number"&&l.length>=0&&t(l)!=="[object Array]"&&"callee"in l&&t(l.callee)==="[object Function]"},i=function(){return r(arguments)}();return r.isLegacyArguments=o,vl=i?r:o,vl}const ak={},ck=Object.freeze(Object.defineProperty({__proto__:null,default:ak},Symbol.toStringTag,{value:"Module"})),uk=Jg(ck);var xl,sh;function Ai(){if(sh)return xl;sh=1;var n=typeof Map=="function"&&Map.prototype,e=Object.getOwnPropertyDescriptor&&n?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,t=n&&e&&typeof e.get=="function"?e.get:null,r=n&&Map.prototype.forEach,o=typeof Set=="function"&&Set.prototype,i=Object.getOwnPropertyDescriptor&&o?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,s=o&&i&&typeof i.get=="function"?i.get:null,l=o&&Set.prototype.forEach,a=typeof WeakMap=="function"&&WeakMap.prototype,c=a?WeakMap.prototype.has:null,u=typeof WeakSet=="function"&&WeakSet.prototype,d=u?WeakSet.prototype.has:null,f=typeof WeakRef=="function"&&WeakRef.prototype,p=f?WeakRef.prototype.deref:null,m=Boolean.prototype.valueOf,g=Object.prototype.toString,y=Function.prototype.toString,b=String.prototype.match,w=String.prototype.slice,v=String.prototype.replace,S=String.prototype.toUpperCase,T=String.prototype.toLowerCase,C=RegExp.prototype.test,I=Array.prototype.concat,O=Array.prototype.join,E=Array.prototype.slice,R=Math.floor,_=typeof BigInt=="function"?BigInt.prototype.valueOf:null,N=Object.getOwnPropertySymbols,D=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,k=typeof Symbol=="function"&&typeof Symbol.iterator=="object",L=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===k||!0)?Symbol.toStringTag:null,F=Object.prototype.propertyIsEnumerable,V=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(M){return M.__proto__}:null);function ue(M,A){if(M===1/0||M===-1/0||M!==M||M&&M>-1e3&&M<1e3||C.call(/e/,A))return A;var me=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof M=="number"){var Ce=M<0?-R(-M):R(M);if(Ce!==M){var Te=String(Ce),ce=w.call(A,Te.length+1);return v.call(Te,me,"$&_")+"."+v.call(v.call(ce,/([0-9]{3})/g,"$&_"),/_$/,"")}}return v.call(A,me,"$&_")}var J=uk,_e=J.custom,de=se(_e)?_e:null,Me={__proto__:null,double:'"',single:"'"},Ne={__proto__:null,double:/(["\\])/g,single:/(['\\])/g};xl=function M(A,me,Ce,Te){var ce=me||{};if(ve(ce,"quoteStyle")&&!ve(Me,ce.quoteStyle))throw new TypeError('option "quoteStyle" must be "single" or "double"');if(ve(ce,"maxStringLength")&&(typeof ce.maxStringLength=="number"?ce.maxStringLength<0&&ce.maxStringLength!==1/0:ce.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var Ut=ve(ce,"customInspect")?ce.customInspect:!0;if(typeof Ut!="boolean"&&Ut!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(ve(ce,"indent")&&ce.indent!==null&&ce.indent!==" "&&!(parseInt(ce.indent,10)===ce.indent&&ce.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(ve(ce,"numericSeparator")&&typeof ce.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var xn=ce.numericSeparator;if(typeof A>"u")return"undefined";if(A===null)return"null";if(typeof A=="boolean")return A?"true":"false";if(typeof A=="string")return kt(A,ce);if(typeof A=="number"){if(A===0)return 1/0/A>0?"0":"-0";var ct=String(A);return xn?ue(A,ct):ct}if(typeof A=="bigint"){var Gt=String(A)+"n";return xn?ue(A,Gt):Gt}var _i=typeof ce.depth>"u"?5:ce.depth;if(typeof Ce>"u"&&(Ce=0),Ce>=_i&&_i>0&&typeof A=="object")return ne(A)?"[Array]":"[Object]";var Un=z1(ce,Ce);if(typeof Te>"u")Te=[];else if(pe(Te,A)>=0)return"[Circular]";function St(Gn,ao,F1){if(ao&&(Te=E.call(Te),Te.push(ao)),F1){var mu={depth:ce.depth};return ve(ce,"quoteStyle")&&(mu.quoteStyle=ce.quoteStyle),M(Gn,mu,Ce+1,Te)}return M(Gn,ce,Ce+1,Te)}if(typeof A=="function"&&!Q(A)){var au=be(A),cu=so(A,St);return"[Function"+(au?": "+au:" (anonymous)")+"]"+(cu.length>0?" { "+O.call(cu,", ")+" }":"")}if(se(A)){var uu=k?v.call(String(A),/^(Symbol\(.*\))_[^)]*$/,"$1"):D.call(A);return typeof A=="object"&&!k?gt(uu):uu}if(De(A)){for(var br="<"+T.call(String(A.nodeName)),Di=A.attributes||[],lo=0;lo<Di.length;lo++)br+=" "+Di[lo].name+"="+P(z(Di[lo].value),"double",ce);return br+=">",A.childNodes&&A.childNodes.length&&(br+="..."),br+="</"+T.call(String(A.nodeName))+">",br}if(ne(A)){if(A.length===0)return"[]";var ji=so(A,St);return Un&&!B1(ji)?"["+Ii(ji,Un)+"]":"[ "+O.call(ji,", ")+" ]"}if(Y(A)){var Pi=so(A,St);return!("cause"in Error.prototype)&&"cause"in A&&!F.call(A,"cause")?"{ ["+String(A)+"] "+O.call(I.call("[cause]: "+St(A.cause),Pi),", ")+" }":Pi.length===0?"["+String(A)+"]":"{ ["+String(A)+"] "+O.call(Pi,", ")+" }"}if(typeof A=="object"&&Ut){if(de&&typeof A[de]=="function"&&J)return J(A,{depth:_i-Ce});if(Ut!=="symbol"&&typeof A.inspect=="function")return A.inspect()}if(Ie(A)){var du=[];return r&&r.call(A,function(Gn,ao){du.push(St(ao,A,!0)+" => "+St(Gn,A))}),lu("Map",t.call(A),du,Un)}if(bn(A)){var fu=[];return l&&l.call(A,function(Gn){fu.push(St(Gn,A))}),lu("Set",s.call(A),fu,Un)}if(pt(A))return Ri("WeakMap");if(Fe(A))return Ri("WeakSet");if(mt(A))return Ri("WeakRef");if(G(A))return gt(St(Number(A)));if(oe(A))return gt(St(_.call(A)));if(q(A))return gt(m.call(A));if(X(A))return gt(St(String(A)));if(typeof window<"u"&&A===window)return"{ [object Window] }";if(typeof globalThis<"u"&&A===globalThis||typeof Zr<"u"&&A===Zr)return"{ [object globalThis] }";if(!ee(A)&&!Q(A)){var Li=so(A,St),hu=V?V(A)===Object.prototype:A instanceof Object||A.constructor===Object,Bi=A instanceof Object?"":"null prototype",pu=!hu&&L&&Object(A)===A&&L in A?w.call(Oe(A),8,-1):Bi?"Object":"",$1=hu||typeof A.constructor!="function"?"":A.constructor.name?A.constructor.name+" ":"",zi=$1+(pu||Bi?"["+O.call(I.call([],pu||[],Bi||[]),": ")+"] ":"");return Li.length===0?zi+"{}":Un?zi+"{"+Ii(Li,Un)+"}":zi+"{ "+O.call(Li,", ")+" }"}return String(A)};function P(M,A,me){var Ce=me.quoteStyle||A,Te=Me[Ce];return Te+M+Te}function z(M){return v.call(String(M),/"/g,"&quot;")}function re(M){return!L||!(typeof M=="object"&&(L in M||typeof M[L]<"u"))}function ne(M){return Oe(M)==="[object Array]"&&re(M)}function ee(M){return Oe(M)==="[object Date]"&&re(M)}function Q(M){return Oe(M)==="[object RegExp]"&&re(M)}function Y(M){return Oe(M)==="[object Error]"&&re(M)}function X(M){return Oe(M)==="[object String]"&&re(M)}function G(M){return Oe(M)==="[object Number]"&&re(M)}function q(M){return Oe(M)==="[object Boolean]"&&re(M)}function se(M){if(k)return M&&typeof M=="object"&&M instanceof Symbol;if(typeof M=="symbol")return!0;if(!M||typeof M!="object"||!D)return!1;try{return D.call(M),!0}catch{}return!1}function oe(M){if(!M||typeof M!="object"||!_)return!1;try{return _.call(M),!0}catch{}return!1}var he=Object.prototype.hasOwnProperty||function(M){return M in this};function ve(M,A){return he.call(M,A)}function Oe(M){return g.call(M)}function be(M){if(M.name)return M.name;var A=b.call(y.call(M),/^function\s*([\w$]+)/);return A?A[1]:null}function pe(M,A){if(M.indexOf)return M.indexOf(A);for(var me=0,Ce=M.length;me<Ce;me++)if(M[me]===A)return me;return-1}function Ie(M){if(!t||!M||typeof M!="object")return!1;try{t.call(M);try{s.call(M)}catch{return!0}return M instanceof Map}catch{}return!1}function pt(M){if(!c||!M||typeof M!="object")return!1;try{c.call(M,c);try{d.call(M,d)}catch{return!0}return M instanceof WeakMap}catch{}return!1}function mt(M){if(!p||!M||typeof M!="object")return!1;try{return p.call(M),!0}catch{}return!1}function bn(M){if(!s||!M||typeof M!="object")return!1;try{s.call(M);try{t.call(M)}catch{return!0}return M instanceof Set}catch{}return!1}function Fe(M){if(!d||!M||typeof M!="object")return!1;try{d.call(M,d);try{c.call(M,c)}catch{return!0}return M instanceof WeakSet}catch{}return!1}function De(M){return!M||typeof M!="object"?!1:typeof HTMLElement<"u"&&M instanceof HTMLElement?!0:typeof M.nodeName=="string"&&typeof M.getAttribute=="function"}function kt(M,A){if(M.length>A.maxStringLength){var me=M.length-A.maxStringLength,Ce="... "+me+" more character"+(me>1?"s":"");return kt(w.call(M,0,A.maxStringLength),A)+Ce}var Te=Ne[A.quoteStyle||"single"];Te.lastIndex=0;var ce=v.call(v.call(M,Te,"\\$1"),/[\x00-\x1f]/g,vn);return P(ce,"single",A)}function vn(M){var A=M.charCodeAt(0),me={8:"b",9:"t",10:"n",12:"f",13:"r"}[A];return me?"\\"+me:"\\x"+(A<16?"0":"")+S.call(A.toString(16))}function gt(M){return"Object("+M+")"}function Ri(M){return M+" { ? }"}function lu(M,A,me,Ce){var Te=Ce?Ii(me,Ce):O.call(me,", ");return M+" ("+A+") {"+Te+"}"}function B1(M){for(var A=0;A<M.length;A++)if(pe(M[A],`
122
+ `)>=0)return!1;return!0}function z1(M,A){var me;if(M.indent===" ")me=" ";else if(typeof M.indent=="number"&&M.indent>0)me=O.call(Array(M.indent+1)," ");else return null;return{base:me,prev:O.call(Array(A+1),me)}}function Ii(M,A){if(M.length===0)return"";var me=`
123
+ `+A.prev+A.base;return me+O.call(M,","+me)+`
124
+ `+A.prev}function so(M,A){var me=ne(M),Ce=[];if(me){Ce.length=M.length;for(var Te=0;Te<M.length;Te++)Ce[Te]=ve(M,Te)?A(M[Te],M):""}var ce=typeof N=="function"?N(M):[],Ut;if(k){Ut={};for(var xn=0;xn<ce.length;xn++)Ut["$"+ce[xn]]=ce[xn]}for(var ct in M)ve(M,ct)&&(me&&String(Number(ct))===ct&&ct<M.length||k&&Ut["$"+ct]instanceof Symbol||(C.call(/[^\w$]/,ct)?Ce.push(A(ct,M)+": "+A(M[ct],M)):Ce.push(ct+": "+A(M[ct],M))));if(typeof N=="function")for(var Gt=0;Gt<ce.length;Gt++)F.call(M,ce[Gt])&&Ce.push("["+A(ce[Gt])+"]: "+A(M[ce[Gt]],M));return Ce}return xl}var wl,lh;function dk(){if(lh)return wl;lh=1;var n=Ai(),e=wt(),t=function(l,a,c){for(var u=l,d;(d=u.next)!=null;u=d)if(d.key===a)return u.next=d.next,c||(d.next=l.next,l.next=d),d},r=function(l,a){if(l){var c=t(l,a);return c&&c.value}},o=function(l,a,c){var u=t(l,a);u?u.value=c:l.next={key:a,next:l.next,value:c}},i=function(l,a){return l?!!t(l,a):!1},s=function(l,a){if(l)return t(l,a,!0)};return wl=function(){var a,c={assert:function(u){if(!c.has(u))throw new e("Side channel does not contain "+n(u))},delete:function(u){var d=a&&a.next,f=s(a,u);return f&&d&&d===f&&(a=void 0),!!f},get:function(u){return r(a,u)},has:function(u){return i(a,u)},set:function(u,d){a||(a={next:void 0}),o(a,u,d)}};return c},wl}var Sl,ah;function a1(){if(ah)return Sl;ah=1;var n=Wt(),e=Ye(),t=Ai(),r=wt(),o=n("%Map%",!0),i=e("Map.prototype.get",!0),s=e("Map.prototype.set",!0),l=e("Map.prototype.has",!0),a=e("Map.prototype.delete",!0),c=e("Map.prototype.size",!0);return Sl=!!o&&function(){var d,f={assert:function(p){if(!f.has(p))throw new r("Side channel does not contain "+t(p))},delete:function(p){if(d){var m=a(d,p);return c(d)===0&&(d=void 0),m}return!1},get:function(p){if(d)return i(d,p)},has:function(p){return d?l(d,p):!1},set:function(p,m){d||(d=new o),s(d,p,m)}};return f},Sl}var Cl,ch;function fk(){if(ch)return Cl;ch=1;var n=Wt(),e=Ye(),t=Ai(),r=a1(),o=wt(),i=n("%WeakMap%",!0),s=e("WeakMap.prototype.get",!0),l=e("WeakMap.prototype.set",!0),a=e("WeakMap.prototype.has",!0),c=e("WeakMap.prototype.delete",!0);return Cl=i?function(){var d,f,p={assert:function(m){if(!p.has(m))throw new o("Side channel does not contain "+t(m))},delete:function(m){if(i&&m&&(typeof m=="object"||typeof m=="function")){if(d)return c(d,m)}else if(r&&f)return f.delete(m);return!1},get:function(m){return i&&m&&(typeof m=="object"||typeof m=="function")&&d?s(d,m):f&&f.get(m)},has:function(m){return i&&m&&(typeof m=="object"||typeof m=="function")&&d?a(d,m):!!f&&f.has(m)},set:function(m,g){i&&m&&(typeof m=="object"||typeof m=="function")?(d||(d=new i),l(d,m,g)):r&&(f||(f=r()),f.set(m,g))}};return p}:r,Cl}var Tl,uh;function c1(){if(uh)return Tl;uh=1;var n=wt(),e=Ai(),t=dk(),r=a1(),o=fk(),i=o||r||t;return Tl=function(){var l,a={assert:function(c){if(!a.has(c))throw new n("Side channel does not contain "+e(c))},delete:function(c){return!!l&&l.delete(c)},get:function(c){return l&&l.get(c)},has:function(c){return!!l&&l.has(c)},set:function(c,u){l||(l=i()),l.set(c,u)}};return a},Tl}var kl,dh;function hk(){if(dh)return kl;dh=1;var n=Yc(),e=c1()(),t=wt(),r={assert:function(o,i){if(!o||typeof o!="object"&&typeof o!="function")throw new t("`O` is not an object");if(typeof i!="string")throw new t("`slot` must be a string");if(e.assert(o),!r.has(o,i))throw new t("`"+i+"` is not present on `O`")},get:function(o,i){if(!o||typeof o!="object"&&typeof o!="function")throw new t("`O` is not an object");if(typeof i!="string")throw new t("`slot` must be a string");var s=e.get(o);return s&&s["$"+i]},has:function(o,i){if(!o||typeof o!="object"&&typeof o!="function")throw new t("`O` is not an object");if(typeof i!="string")throw new t("`slot` must be a string");var s=e.get(o);return!!s&&n(s,"$"+i)},set:function(o,i,s){if(!o||typeof o!="object"&&typeof o!="function")throw new t("`O` is not an object");if(typeof i!="string")throw new t("`slot` must be a string");var l=e.get(o);l||(l={},e.set(o,l)),l["$"+i]=s}};return Object.freeze&&Object.freeze(r),kl=r,kl}var El,fh;function pk(){if(fh)return El;fh=1;var n=hk(),e=qc(),t=typeof StopIteration=="object"?StopIteration:null;return El=function(o){if(!t)throw new e("this environment lacks StopIteration");n.set(o,"[[Done]]",!1);var i={next:function(){var l=n.get(this,"[[Iterator]]"),a=!!n.get(l,"[[Done]]");try{return{done:a,value:a?void 0:l.next()}}catch(c){if(n.set(l,"[[Done]]",!0),c!==t)throw c;return{done:!0,value:void 0}}}};return n.set(i,"[[Iterator]]",o),i},El}var Ml,hh;function u1(){if(hh)return Ml;hh=1;var n={}.toString;return Ml=Array.isArray||function(e){return n.call(e)=="[object Array]"},Ml}var Ol,ph;function d1(){if(ph)return Ol;ph=1;var n=Ye(),e=n("String.prototype.valueOf"),t=function(l){try{return e(l),!0}catch{return!1}},r=n("Object.prototype.toString"),o="[object String]",i=Wn()();return Ol=function(l){return typeof l=="string"?!0:!l||typeof l!="object"?!1:i?t(l):r(l)===o},Ol}var Al,mh;function f1(){if(mh)return Al;mh=1;var n=typeof Map=="function"&&Map.prototype?Map:null,e=typeof Set=="function"&&Set.prototype?Set:null,t;n||(t=function(s){return!1});var r=n?Map.prototype.has:null,o=e?Set.prototype.has:null;return!t&&!r&&(t=function(s){return!1}),Al=t||function(s){if(!s||typeof s!="object")return!1;try{if(r.call(s),o)try{o.call(s)}catch{return!0}return s instanceof n}catch{}return!1},Al}var Nl,gh;function h1(){if(gh)return Nl;gh=1;var n=typeof Map=="function"&&Map.prototype?Map:null,e=typeof Set=="function"&&Set.prototype?Set:null,t;e||(t=function(s){return!1});var r=n?Map.prototype.has:null,o=e?Set.prototype.has:null;return!t&&!o&&(t=function(s){return!1}),Nl=t||function(s){if(!s||typeof s!="object")return!1;try{if(o.call(s),r)try{r.call(s)}catch{return!0}return s instanceof e}catch{}return!1},Nl}var yh;function mk(){if(yh)return Cr.exports;yh=1;var n=l1(),e=pk();if(Kc()()||Oi()()){var t=Symbol.iterator;Cr.exports=function(E){if(E!=null&&typeof E[t]<"u")return E[t]();if(n(E))return Array.prototype[t].call(E)}}else{var r=u1(),o=d1(),i=Wt(),s=i("%Map%",!0),l=i("%Set%",!0),a=o1(),c=a("Array.prototype.push"),u=a("String.prototype.charCodeAt"),d=a("String.prototype.slice"),f=function(E,R){var _=E.length;if(R+1>=_)return R+1;var N=u(E,R);if(N<55296||N>56319)return R+1;var D=u(E,R+1);return D<56320||D>57343?R+1:R+2},p=function(E){var R=0;return{next:function(){var N=R>=E.length,D;return N||(D=E[R],R+=1),{done:N,value:D}}}},m=function(E,R){if(r(E)||n(E))return p(E);if(o(E)){var _=0;return{next:function(){var D=f(E,_),k=d(E,_,D);return _=D,{done:D>E.length,value:k}}}}if(R&&typeof E["_es6-shim iterator_"]<"u")return E["_es6-shim iterator_"]()};if(!s&&!l)Cr.exports=function(E){if(E!=null)return m(E,!0)};else{var g=f1(),y=h1(),b=a("Map.prototype.forEach",!0),w=a("Set.prototype.forEach",!0);if(typeof process>"u"||!process.versions||!process.versions.node)var v=a("Map.prototype.iterator",!0),S=a("Set.prototype.iterator",!0);var T=a("Map.prototype.@@iterator",!0)||a("Map.prototype._es6-shim iterator_",!0),C=a("Set.prototype.@@iterator",!0)||a("Set.prototype._es6-shim iterator_",!0),I=function(E){if(g(E)){if(v)return e(v(E));if(T)return T(E);if(b){var R=[];return b(E,function(N,D){c(R,[D,N])}),p(R)}}if(y(E)){if(S)return e(S(E));if(C)return C(E);if(w){var _=[];return w(E,function(N){c(_,N)}),p(_)}}};Cr.exports=function(E){return I(E)||m(E)}}}return Cr.exports}var Rl,bh;function p1(){if(bh)return Rl;bh=1;var n=function(e){return e!==e};return Rl=function(t,r){return t===0&&r===0?1/t===1/r:!!(t===r||n(t)&&n(r))},Rl}var Il,vh;function m1(){if(vh)return Il;vh=1;var n=p1();return Il=function(){return typeof Object.is=="function"?Object.is:n},Il}var _l,xh;function gk(){if(xh)return _l;xh=1;var n=m1(),e=qn();return _l=function(){var r=n();return e(Object,{is:r},{is:function(){return Object.is!==r}}),r},_l}var Dl,wh;function yk(){if(wh)return Dl;wh=1;var n=qn(),e=yr(),t=p1(),r=m1(),o=gk(),i=e(r(),Object);return n(i,{getPolyfill:r,implementation:t,shim:o}),Dl=i,Dl}var jl,Sh;function g1(){if(Sh)return jl;Sh=1;var n=yr(),e=Ye(),t=Wt(),r=t("%ArrayBuffer%",!0),o=e("ArrayBuffer.prototype.byteLength",!0),i=e("Object.prototype.toString"),s=!!r&&!o&&new r(0).slice,l=!!s&&n(s);return jl=o||l?function(c){if(!c||typeof c!="object")return!1;try{return o?o(c):l(c,0),!0}catch{return!1}}:r?function(c){return i(c)==="[object ArrayBuffer]"}:function(c){return!1},jl}var Pl,Ch;function bk(){if(Ch)return Pl;Ch=1;var n=Ye(),e=n("Date.prototype.getDay"),t=function(l){try{return e(l),!0}catch{return!1}},r=n("Object.prototype.toString"),o="[object Date]",i=Wn()();return Pl=function(l){return typeof l!="object"||l===null?!1:i?t(l):r(l)===o},Pl}var Ll,Th;function y1(){if(Th)return Ll;Th=1;var n=Ye(),e=Wn()(),t=Yc(),r=Hn(),o;if(e){var i=n("RegExp.prototype.exec"),s={},l=function(){throw s},a={toString:l,valueOf:l};typeof Symbol.toPrimitive=="symbol"&&(a[Symbol.toPrimitive]=l),o=function(f){if(!f||typeof f!="object")return!1;var p=r(f,"lastIndex"),m=p&&t(p,"value");if(!m)return!1;try{i(f,a)}catch(g){return g===s}}}else{var c=n("Object.prototype.toString"),u="[object RegExp]";o=function(f){return!f||typeof f!="object"&&typeof f!="function"?!1:c(f)===u}}return Ll=o,Ll}var Bl,kh;function vk(){if(kh)return Bl;kh=1;var n=Ye(),e=n("SharedArrayBuffer.prototype.byteLength",!0);return Bl=e?function(r){if(!r||typeof r!="object")return!1;try{return e(r),!0}catch{return!1}}:function(r){return!1},Bl}var zl,Eh;function xk(){if(Eh)return zl;Eh=1;var n=Ye(),e=n("Number.prototype.toString"),t=function(l){try{return e(l),!0}catch{return!1}},r=n("Object.prototype.toString"),o="[object Number]",i=Wn()();return zl=function(l){return typeof l=="number"?!0:!l||typeof l!="object"?!1:i?t(l):r(l)===o},zl}var $l,Mh;function wk(){if(Mh)return $l;Mh=1;var n=Ye(),e=n("Boolean.prototype.toString"),t=n("Object.prototype.toString"),r=function(l){try{return e(l),!0}catch{return!1}},o="[object Boolean]",i=Wn()();return $l=function(l){return typeof l=="boolean"?!0:l===null||typeof l!="object"?!1:i?r(l):t(l)===o},$l}var So={exports:{}},Fl,Oh;function Sk(){if(Oh)return Fl;Oh=1;var n=Ye(),e=y1(),t=n("RegExp.prototype.exec"),r=wt();return Fl=function(i){if(!e(i))throw new r("`regex` must be a RegExp");return function(l){return t(i,l)!==null}},Fl}var Ah;function Ck(){if(Ah)return So.exports;Ah=1;var n=Ye(),e=n("Object.prototype.toString"),t=Kc()(),r=Sk();if(t){var o=n("Symbol.prototype.toString"),i=r(/^Symbol\(.*\)$/),s=function(a){return typeof a.valueOf()!="symbol"?!1:i(o(a))};So.exports=function(a){if(typeof a=="symbol")return!0;if(!a||typeof a!="object"||e(a)!=="[object Symbol]")return!1;try{return s(a)}catch{return!1}}}else So.exports=function(a){return!1};return So.exports}var Co={exports:{}},Vl,Nh;function Tk(){if(Nh)return Vl;Nh=1;var n=typeof BigInt<"u"&&BigInt;return Vl=function(){return typeof n=="function"&&typeof BigInt=="function"&&typeof n(42)=="bigint"&&typeof BigInt(42)=="bigint"},Vl}var Rh;function kk(){if(Rh)return Co.exports;Rh=1;var n=Tk()();if(n){var e=BigInt.prototype.valueOf,t=function(o){try{return e.call(o),!0}catch{}return!1};Co.exports=function(o){return o===null||typeof o>"u"||typeof o=="boolean"||typeof o=="string"||typeof o=="number"||typeof o=="symbol"||typeof o=="function"?!1:typeof o=="bigint"?!0:t(o)}}else Co.exports=function(o){return!1};return Co.exports}var Hl,Ih;function Ek(){if(Ih)return Hl;Ih=1;var n=d1(),e=xk(),t=wk(),r=Ck(),o=kk();return Hl=function(s){if(s==null||typeof s!="object"&&typeof s!="function")return null;if(n(s))return"String";if(e(s))return"Number";if(t(s))return"Boolean";if(r(s))return"Symbol";if(o(s))return"BigInt"},Hl}var ql,_h;function Mk(){if(_h)return ql;_h=1;var n=typeof WeakMap=="function"&&WeakMap.prototype?WeakMap:null,e=typeof WeakSet=="function"&&WeakSet.prototype?WeakSet:null,t;n||(t=function(s){return!1});var r=n?n.prototype.has:null,o=e?e.prototype.has:null;return!t&&!r&&(t=function(s){return!1}),ql=t||function(s){if(!s||typeof s!="object")return!1;try{if(r.call(s,r),o)try{o.call(s,o)}catch{return!0}return s instanceof n}catch{}return!1},ql}var To={exports:{}},Dh;function Ok(){if(Dh)return To.exports;Dh=1;var n=Wt(),e=Ye(),t=n("%WeakSet%",!0),r=e("WeakSet.prototype.has",!0);if(r){var o=e("WeakMap.prototype.has",!0);To.exports=function(s){if(!s||typeof s!="object")return!1;try{if(r(s,r),o)try{o(s,o)}catch{return!0}return s instanceof t}catch{}return!1}}else To.exports=function(s){return!1};return To.exports}var Wl,jh;function Ak(){if(jh)return Wl;jh=1;var n=f1(),e=h1(),t=Mk(),r=Ok();return Wl=function(i){if(i&&typeof i=="object"){if(n(i))return"Map";if(e(i))return"Set";if(t(i))return"WeakMap";if(r(i))return"WeakSet"}return!1},Wl}var Ul,Ph;function Nk(){if(Ph)return Ul;Ph=1;var n=Function.prototype.toString,e=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,t,r;if(typeof e=="function"&&typeof Object.defineProperty=="function")try{t=Object.defineProperty({},"length",{get:function(){throw r}}),r={},e(function(){throw 42},null,t)}catch(w){w!==r&&(e=null)}else e=null;var o=/^\s*class\b/,i=function(v){try{var S=n.call(v);return o.test(S)}catch{return!1}},s=function(v){try{return i(v)?!1:(n.call(v),!0)}catch{return!1}},l=Object.prototype.toString,a="[object Object]",c="[object Function]",u="[object GeneratorFunction]",d="[object HTMLAllCollection]",f="[object HTML document.all class]",p="[object HTMLCollection]",m=typeof Symbol=="function"&&!!Symbol.toStringTag,g=!(0 in[,]),y=function(){return!1};if(typeof document=="object"){var b=document.all;l.call(b)===l.call(document.all)&&(y=function(v){if((g||!v)&&(typeof v>"u"||typeof v=="object"))try{var S=l.call(v);return(S===d||S===f||S===p||S===a)&&v("")==null}catch{}return!1})}return Ul=e?function(v){if(y(v))return!0;if(!v||typeof v!="function"&&typeof v!="object")return!1;try{e(v,null,t)}catch(S){if(S!==r)return!1}return!i(v)&&s(v)}:function(v){if(y(v))return!0;if(!v||typeof v!="function"&&typeof v!="object")return!1;if(m)return s(v);if(i(v))return!1;var S=l.call(v);return S!==c&&S!==u&&!/^\[object HTML/.test(S)?!1:s(v)},Ul}var Gl,Lh;function Rk(){if(Lh)return Gl;Lh=1;var n=Nk(),e=Object.prototype.toString,t=Object.prototype.hasOwnProperty,r=function(a,c,u){for(var d=0,f=a.length;d<f;d++)t.call(a,d)&&(u==null?c(a[d],d,a):c.call(u,a[d],d,a))},o=function(a,c,u){for(var d=0,f=a.length;d<f;d++)u==null?c(a.charAt(d),d,a):c.call(u,a.charAt(d),d,a)},i=function(a,c,u){for(var d in a)t.call(a,d)&&(u==null?c(a[d],d,a):c.call(u,a[d],d,a))};function s(l){return e.call(l)==="[object Array]"}return Gl=function(a,c,u){if(!n(c))throw new TypeError("iterator must be a function");var d;arguments.length>=3&&(d=u),s(a)?r(a,c,d):typeof a=="string"?o(a,c,d):i(a,c,d)},Gl}var Kl,Bh;function Ik(){return Bh||(Bh=1,Kl=["Float16Array","Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"]),Kl}var Jl,zh;function _k(){if(zh)return Jl;zh=1;var n=Ik(),e=typeof globalThis>"u"?Zr:globalThis;return Jl=function(){for(var r=[],o=0;o<n.length;o++)typeof e[n[o]]=="function"&&(r[r.length]=n[o]);return r},Jl}var Xl,$h;function Dk(){if($h)return Xl;$h=1;var n=Rk(),e=_k(),t=yr(),r=Ye(),o=Hn(),i=r("Object.prototype.toString"),s=Wn()(),l=typeof globalThis>"u"?Zr:globalThis,a=e(),c=r("String.prototype.slice"),u=Object.getPrototypeOf,d=r("Array.prototype.indexOf",!0)||function(y,b){for(var w=0;w<y.length;w+=1)if(y[w]===b)return w;return-1},f={__proto__:null};s&&o&&u?n(a,function(g){var y=new l[g];if(Symbol.toStringTag in y){var b=u(y),w=o(b,Symbol.toStringTag);if(!w){var v=u(b);w=o(v,Symbol.toStringTag)}f["$"+g]=t(w.get)}}):n(a,function(g){var y=new l[g],b=y.slice||y.set;b&&(f["$"+g]=t(b))});var p=function(y){var b=!1;return n(f,function(w,v){if(!b)try{"$"+w(y)===v&&(b=c(v,1))}catch{}}),b},m=function(y){var b=!1;return n(f,function(w,v){if(!b)try{w(y),b=c(v,1)}catch{}}),b};return Xl=function(y){if(!y||typeof y!="object")return!1;if(!s){var b=c(i(y),8,-1);return d(a,b)>-1?b:b!=="Object"?!1:m(y)}return o?p(y):null},Xl}var Zl,Fh;function jk(){if(Fh)return Zl;Fh=1;var n=Ye(),e=n("ArrayBuffer.prototype.byteLength",!0),t=g1();return Zl=function(o){return t(o)?e?e(o):o.byteLength:NaN},Zl}var Yl,Vh;function Pk(){if(Vh)return Yl;Vh=1;var n=rk(),e=o1(),t=lk(),r=Wt(),o=mk(),i=c1(),s=yk(),l=l1(),a=u1(),c=g1(),u=bk(),d=y1(),f=vk(),p=Hc(),m=Ek(),g=Ak(),y=Dk(),b=jk(),w=e("SharedArrayBuffer.prototype.byteLength",!0),v=e("Date.prototype.getTime"),S=Object.getPrototypeOf,T=e("Object.prototype.toString"),C=r("%Set%",!0),I=e("Map.prototype.has",!0),O=e("Map.prototype.get",!0),E=e("Map.prototype.size",!0),R=e("Set.prototype.add",!0),_=e("Set.prototype.delete",!0),N=e("Set.prototype.has",!0),D=e("Set.prototype.size",!0);function k(P,z,re,ne){for(var ee=o(P),Q;(Q=ee.next())&&!Q.done;)if(J(z,Q.value,re,ne))return _(P,Q.value),!0;return!1}function L(P){if(typeof P>"u")return null;if(typeof P!="object")return typeof P=="symbol"?!1:typeof P=="string"||typeof P=="number"?+P==+P:!0}function F(P,z,re,ne,ee,Q){var Y=L(re);if(Y!=null)return Y;var X=O(z,Y),G=n({},ee,{strict:!1});return typeof X>"u"&&!I(z,Y)||!J(ne,X,G,Q)?!1:!I(P,Y)&&J(ne,X,G,Q)}function V(P,z,re){var ne=L(re);return ne??(N(z,ne)&&!N(P,ne))}function ue(P,z,re,ne,ee,Q){for(var Y=o(P),X,G;(X=Y.next())&&!X.done;)if(G=X.value,J(re,G,ee,Q)&&J(ne,O(z,G),ee,Q))return _(P,G),!0;return!1}function J(P,z,re,ne){var ee=re||{};if(ee.strict?s(P,z):P===z)return!0;var Q=m(P),Y=m(z);if(Q!==Y)return!1;if(!P||!z||typeof P!="object"&&typeof z!="object")return ee.strict?s(P,z):P==z;var X=ne.has(P),G=ne.has(z),q;if(X&&G){if(ne.get(P)===ne.get(z))return!0}else q={};return X||ne.set(P,q),G||ne.set(z,q),Ne(P,z,ee,ne)}function _e(P){return!P||typeof P!="object"||typeof P.length!="number"||typeof P.copy!="function"||typeof P.slice!="function"||P.length>0&&typeof P[0]!="number"?!1:!!(P.constructor&&P.constructor.isBuffer&&P.constructor.isBuffer(P))}function de(P,z,re,ne){if(D(P)!==D(z))return!1;for(var ee=o(P),Q=o(z),Y,X,G;(Y=ee.next())&&!Y.done;)if(Y.value&&typeof Y.value=="object")G||(G=new C),R(G,Y.value);else if(!N(z,Y.value)){if(re.strict||!V(P,z,Y.value))return!1;G||(G=new C),R(G,Y.value)}if(G){for(;(X=Q.next())&&!X.done;)if(X.value&&typeof X.value=="object"){if(!k(G,X.value,re.strict,ne))return!1}else if(!re.strict&&!N(P,X.value)&&!k(G,X.value,re.strict,ne))return!1;return D(G)===0}return!0}function Me(P,z,re,ne){if(E(P)!==E(z))return!1;for(var ee=o(P),Q=o(z),Y,X,G,q,se,oe;(Y=ee.next())&&!Y.done;)if(q=Y.value[0],se=Y.value[1],q&&typeof q=="object")G||(G=new C),R(G,q);else if(oe=O(z,q),typeof oe>"u"&&!I(z,q)||!J(se,oe,re,ne)){if(re.strict||!F(P,z,q,se,re,ne))return!1;G||(G=new C),R(G,q)}if(G){for(;(X=Q.next())&&!X.done;)if(q=X.value[0],oe=X.value[1],q&&typeof q=="object"){if(!ue(G,P,q,oe,re,ne))return!1}else if(!re.strict&&(!P.has(q)||!J(O(P,q),oe,re,ne))&&!ue(G,P,q,oe,n({},re,{strict:!1}),ne))return!1;return D(G)===0}return!0}function Ne(P,z,re,ne){var ee,Q;if(typeof P!=typeof z||P==null||z==null||T(P)!==T(z)||l(P)!==l(z))return!1;var Y=a(P),X=a(z);if(Y!==X)return!1;var G=P instanceof Error,q=z instanceof Error;if(G!==q||(G||q)&&(P.name!==z.name||P.message!==z.message))return!1;var se=d(P),oe=d(z);if(se!==oe||(se||oe)&&(P.source!==z.source||t(P)!==t(z)))return!1;var he=u(P),ve=u(z);if(he!==ve||(he||ve)&&v(P)!==v(z)||re.strict&&S&&S(P)!==S(z))return!1;var Oe=y(P),be=y(z);if(Oe!==be)return!1;if(Oe||be){if(P.length!==z.length)return!1;for(ee=0;ee<P.length;ee++)if(P[ee]!==z[ee])return!1;return!0}var pe=_e(P),Ie=_e(z);if(pe!==Ie)return!1;if(pe||Ie){if(P.length!==z.length)return!1;for(ee=0;ee<P.length;ee++)if(P[ee]!==z[ee])return!1;return!0}var pt=c(P),mt=c(z);if(pt!==mt)return!1;if(pt||mt)return b(P)!==b(z)?!1:typeof Uint8Array=="function"&&J(new Uint8Array(P),new Uint8Array(z),re,ne);var bn=f(P),Fe=f(z);if(bn!==Fe)return!1;if(bn||Fe)return w(P)!==w(z)?!1:typeof Uint8Array=="function"&&J(new Uint8Array(P),new Uint8Array(z),re,ne);if(typeof P!=typeof z)return!1;var De=p(P),kt=p(z);if(De.length!==kt.length)return!1;for(De.sort(),kt.sort(),ee=De.length-1;ee>=0;ee--)if(De[ee]!=kt[ee])return!1;for(ee=De.length-1;ee>=0;ee--)if(Q=De[ee],!J(P[Q],z[Q],re,ne))return!1;var vn=g(P),gt=g(z);return vn!==gt?!1:vn==="Set"||gt==="Set"?de(P,z,re,ne):vn==="Map"?Me(P,z,re,ne):!0}return Yl=function(z,re,ne){return J(z,re,ne,i())},Yl}var Lk=Pk();const Qc=Vc(Lk),Ni=Se.forwardRef(({className:n,...e},t)=>h.jsx("textarea",{className:U("flex min-h-[80px] w-full rounded-md !border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",n),ref:t,...e}));Ni.displayName="Textarea";function Bk(n){return n}function b1(n,e,t,r){const o=Bk,[i,s]=x.useState(o(t)),l=x.useRef(i);return x.useEffect(()=>{const a=()=>{const c={...t,...n.getAttributes(e)};Object.keys(c).forEach(d=>{(c[d]===null||c[d]===void 0)&&(c[d]=t?t[d]:null)});const u=o(c);Qc(l.current,u)||(s(u),l.current=u)};return n.on("selectionUpdate",a),n.on("transaction",a),()=>{n.off("selectionUpdate",a),n.off("transaction",a)}},[n,t,e,o]),i}function zk({editor:n,...e}){const{t}=ie.useLocale(),r=b1(n,Va.name,{text:"",defaultShowPicker:!1}),{text:o,defaultShowPicker:i}=r,[s,l]=x.useState(""),a=x.useCallback(()=>{n.chain().focus().setKatex({text:s}).run(),l("")},[n,s]);x.useEffect(()=>{i&&n.chain().updateAttributes(Va.name,{defaultShowPicker:!1}).focus().run()},[n,i]);const c=x.useMemo(()=>{try{return fp.renderToString(`${s}`)}catch{return s}},[s]),u=x.useMemo(()=>`${s}`.trim()?h.jsx("span",{contentEditable:!1,dangerouslySetInnerHTML:{__html:c||""}}):null,[s,c]);return h.jsxs(zn,{modal:!0,children:[h.jsx($n,{asChild:!0,children:h.jsx(at,{icon:e==null?void 0:e.icon,tooltip:e==null?void 0:e.tooltip})}),h.jsxs(mn,{align:"start",className:"size-full p-2",hideWhenDetached:!0,side:"bottom",children:[h.jsx(cn,{className:"mb-[6px]",children:t("editor.formula.dialog.text")}),h.jsx("div",{className:"mb-[16px] flex w-full max-w-sm items-center gap-1.5",children:h.jsx("div",{className:"relative w-full max-w-sm",children:h.jsx(Ni,{autoFocus:!0,className:"w-full",defaultValue:o,onChange:d=>l(d.target.value),placeholder:"Text",required:!0,rows:3,value:s})})}),u&&h.jsx("div",{className:"my-[10px] max-w-[286px] overflow-auto whitespace-nowrap rounded-[6px] !border p-[10px]",children:u}),h.jsxs("div",{className:"flex items-center justify-between gap-[6px]",children:[h.jsx(Be,{className:"flex-1",onClick:a,children:"Submit"}),h.jsx("a",{href:"https://katex.org/docs/supported",rel:"noreferrer noopener",target:"_blank",children:h.jsx(B.HelpCircle,{size:16})})]})]})]})}function $k(){const[n]=pg(e=>e.value);return n}const Fk={setTheme:(n,e)=>{Si(pr.UPDATE_THEME(n),e)}};function Vk(n,e=1){let t=0,r=0,o=0;if(n.startsWith("rgb")){const i=n.replace(/\s/g,"").match(/rgb\((.*)\)$/)[1].split(",");t=+i[0],r=+i[1],o=+i[2]}else if(n.startsWith("#")){let i=n.replace("#","");i.length===3&&(i=`${i[0]}${i[0]}${i[1]}${i[1]}${i[2]}${i[2]}`),t=Number.parseInt(i.substring(0,2),16),r=Number.parseInt(i.substring(2,4),16),o=Number.parseInt(i.substring(4,6),16)}else return n;return e>1&&e<=100&&(e=e/100),`rgba(${t},${r},${o},${e})`}function Hk({node:n}){const e=$k(),{text:t}=n.attrs,r=x.useMemo(()=>{const s="rgb(254, 242, 237)";return e==="dark"?Vk(s,.75):s},[e]),o=x.useMemo(()=>{try{return fp.renderToString(`${t}`)}catch{return t}},[t]),i=x.useMemo(()=>t.trim()?h.jsx("span",{contentEditable:!1,dangerouslySetInnerHTML:{__html:o}}):h.jsx("span",{contentEditable:!1,children:"Not enter a formula"}),[t,o]);return h.jsx(Ht,{style:{display:"inline-block",backgroundColor:r},as:"span",children:i})}function qk(n){return e=>e.getAttribute(n)}const Va=Je.create({name:"katex",group:"inline",inline:!0,defining:!0,draggable:!0,selectable:!0,addOptions(){return{HTMLAttributes:{class:"katex"},button:({editor:n,t:e})=>({component:zk,componentProps:{editor:n,action:()=>!0,isActive:()=>!1,disabled:!1,icon:"KatexIcon",tooltip:e("editor.katex.tooltip")}})}},addAttributes(){return{text:{default:"",parseHTML:qk("text")},defaultShowPicker:{default:!1}}},parseHTML(){return[{tag:"span.katex"}]},renderHTML({HTMLAttributes:n}){return["span",Ue(this.options&&this.options.HTMLAttributes||{},n)]},addCommands(){return{setKatex:n=>({commands:e})=>e.insertContent({type:this.name,attrs:n})}},addInputRules(){return[ro({find:/^\$katex\$$/,type:this.type,getAttributes:()=>({defaultShowPicker:!0})})]},addNodeView(){return qt(Hk)}});let Ql;function eu(){try{return Ql||(Ql=ie.mitt()),Ql}catch{throw new Error("Error EventEmitter")}}const Ha="OPEN_EXCALIDRAW_SETTING_MODAL";function Wk(n,e){eu().on(n,e)}function Uk(n,e){eu().off(n,e)}function Gk(n){eu().emit(Ha,n)}const Kk=({editor:n})=>{const[e,t]=x.useState(null),[r,o]=x.useState({}),[i,s]=x.useState({elements:[],appState:{isLoading:!1},files:null}),[l,a]=x.useState(!1),[c,u]=x.useState(!0),[d,f]=x.useState(null),p=x.useCallback(b=>{b&&import("@excalidraw/excalidraw").then(w=>{t(w.Excalidraw)}).catch(f).finally(()=>u(!1))},[u]),m=x.useCallback(b=>{setTimeout(()=>{b.refresh()})},[]),g=x.useCallback((b,w,v)=>{o({elements:b,appState:{isLoading:!1},files:v})},[]),y=x.useCallback(()=>{if(!e){a(!1);return}n.chain().focus().setExcalidraw({data:r}).run(),a(!1)},[e,n,r,a]);return x.useEffect(()=>{const b=w=>{a(!0),w&&s(w.data)};return Wk(Ha,b),()=>{Uk(Ha,b)}},[n,a]),h.jsxs(Fn,{onOpenChange:a,open:l,children:[h.jsx(Vn,{asChild:!0,children:h.jsx(at,{action:()=>a(!0),icon:"Excalidraw",tooltip:"Excalidraw"})}),h.jsxs(gn,{className:"z-[99999] !max-w-[1300px]",children:[h.jsx(yn,{children:"Excalidraw"}),h.jsxs("div",{style:{height:"100%",borderWidth:1},children:[c&&h.jsx("p",{children:"Loading..."}),d&&h.jsx("p",{children:d&&d.message||"Error"}),h.jsx("div",{ref:p,style:{width:"100%",height:600},children:!c&&!d&&e?h.jsx(e,{initialData:i,langCode:"en",onChange:g,ref:m}):null})]}),h.jsx(mr,{children:h.jsx(Be,{onClick:y,type:"button",children:"Save changes"})})]})]})};var Fo={exports:{}},Jk=Fo.exports,Hh;function Xk(){return Hh||(Hh=1,function(n,e){(function(r,o){n.exports=o(x,ec)})(Jk,function(t,r){return function(o){var i={};function s(l){if(i[l])return i[l].exports;var a=i[l]={i:l,l:!1,exports:{}};return o[l].call(a.exports,a,a.exports,s),a.l=!0,a.exports}return s.m=o,s.c=i,s.d=function(l,a,c){s.o(l,a)||Object.defineProperty(l,a,{enumerable:!0,get:c})},s.r=function(l){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(l,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(l,"__esModule",{value:!0})},s.t=function(l,a){if(a&1&&(l=s(l)),a&8||a&4&&typeof l=="object"&&l&&l.__esModule)return l;var c=Object.create(null);if(s.r(c),Object.defineProperty(c,"default",{enumerable:!0,value:l}),a&2&&typeof l!="string")for(var u in l)s.d(c,u,(function(d){return l[d]}).bind(null,u));return c},s.n=function(l){var a=l&&l.__esModule?function(){return l.default}:function(){return l};return s.d(a,"a",a),a},s.o=function(l,a){return Object.prototype.hasOwnProperty.call(l,a)},s.p="",s(s.s=4)}([function(o,i,s){o.exports=s(5)()},function(o,i){o.exports=t},function(o,i){o.exports=r},function(o,i){o.exports=function(s,l,a){var c=s.direction,u=s.value;switch(c){case"top":return a.top+u<l.top&&a.bottom>l.bottom&&a.left<l.left&&a.right>l.right;case"left":return a.left+u<l.left&&a.bottom>l.bottom&&a.top<l.top&&a.right>l.right;case"bottom":return a.bottom-u>l.bottom&&a.left<l.left&&a.right>l.right&&a.top<l.top;case"right":return a.right-u>l.right&&a.left<l.left&&a.top<l.top&&a.bottom>l.bottom}}},function(o,i,s){s.r(i),s.d(i,"default",function(){return R});var l=s(1),a=s.n(l),c=s(2),u=s.n(c),d=s(0),f=s.n(d),p=s(3),m=s.n(p);function g(_){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?g=function(D){return typeof D}:g=function(D){return D&&typeof Symbol=="function"&&D.constructor===Symbol&&D!==Symbol.prototype?"symbol":typeof D},g(_)}function y(_,N){if(!(_ instanceof N))throw new TypeError("Cannot call a class as a function")}function b(_,N){for(var D=0;D<N.length;D++){var k=N[D];k.enumerable=k.enumerable||!1,k.configurable=!0,"value"in k&&(k.writable=!0),Object.defineProperty(_,k.key,k)}}function w(_,N,D){return N&&b(_.prototype,N),_}function v(_,N){return N&&(g(N)==="object"||typeof N=="function")?N:T(_)}function S(_){return S=Object.setPrototypeOf?Object.getPrototypeOf:function(D){return D.__proto__||Object.getPrototypeOf(D)},S(_)}function T(_){if(_===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return _}function C(_,N){if(typeof N!="function"&&N!==null)throw new TypeError("Super expression must either be null or a function");_.prototype=Object.create(N&&N.prototype,{constructor:{value:_,writable:!0,configurable:!0}}),N&&I(_,N)}function I(_,N){return I=Object.setPrototypeOf||function(k,L){return k.__proto__=L,k},I(_,N)}function O(_,N,D){return N in _?Object.defineProperty(_,N,{value:D,enumerable:!0,configurable:!0,writable:!0}):_[N]=D,_}function E(_){return _.width===void 0&&(_.width=_.right-_.left),_.height===void 0&&(_.height=_.bottom-_.top),_}var R=function(_){C(N,_);function N(D){var k;return y(this,N),k=v(this,S(N).call(this,D)),O(T(k),"getContainer",function(){return k.props.containment||window}),O(T(k),"addEventListener",function(L,F,V,ue){k.debounceCheck||(k.debounceCheck={});var J,_e,de=function(){J=null,k.check()};ue>-1?_e=function(){J||(J=setTimeout(de,ue||0))}:_e=function(){clearTimeout(J),J=setTimeout(de,V||0)};var Me={target:L,fn:_e,getLastTimeout:function(){return J}};L.addEventListener(F,Me.fn),k.debounceCheck[F]=Me}),O(T(k),"startWatching",function(){k.debounceCheck||k.interval||(k.props.intervalCheck&&(k.interval=setInterval(k.check,k.props.intervalDelay)),k.props.scrollCheck&&k.addEventListener(k.getContainer(),"scroll",k.props.scrollDelay,k.props.scrollThrottle),k.props.resizeCheck&&k.addEventListener(window,"resize",k.props.resizeDelay,k.props.resizeThrottle),!k.props.delayedCall&&k.check())}),O(T(k),"stopWatching",function(){if(k.debounceCheck){for(var L in k.debounceCheck)if(k.debounceCheck.hasOwnProperty(L)){var F=k.debounceCheck[L];clearTimeout(F.getLastTimeout()),F.target.removeEventListener(L,F.fn),k.debounceCheck[L]=null}}k.debounceCheck=null,k.interval&&(k.interval=clearInterval(k.interval))}),O(T(k),"check",function(){var L=k.node,F,V;if(!L)return k.state;if(F=E(k.roundRectDown(L.getBoundingClientRect())),k.props.containment){var ue=k.props.containment.getBoundingClientRect();V={top:ue.top,left:ue.left,bottom:ue.bottom,right:ue.right}}else V={top:0,left:0,bottom:window.innerHeight||document.documentElement.clientHeight,right:window.innerWidth||document.documentElement.clientWidth};var J=k.props.offset||{},_e=g(J)==="object";_e&&(V.top+=J.top||0,V.left+=J.left||0,V.bottom-=J.bottom||0,V.right-=J.right||0);var de={top:F.top>=V.top,left:F.left>=V.left,bottom:F.bottom<=V.bottom,right:F.right<=V.right},Me=F.height>0&&F.width>0,Ne=Me&&de.top&&de.left&&de.bottom&&de.right;if(Me&&k.props.partialVisibility){var P=F.top<=V.bottom&&F.bottom>=V.top&&F.left<=V.right&&F.right>=V.left;typeof k.props.partialVisibility=="string"&&(P=de[k.props.partialVisibility]),Ne=k.props.minTopValue?P&&F.top<=V.bottom-k.props.minTopValue:P}typeof J.direction=="string"&&typeof J.value=="number"&&(console.warn("[notice] offset.direction and offset.value have been deprecated. They still work for now, but will be removed in next major version. Please upgrade to the new syntax: { %s: %d }",J.direction,J.value),Ne=m()(J,F,V));var z=k.state;return k.state.isVisible!==Ne&&(z={isVisible:Ne,visibilityRect:de},k.setState(z),k.props.onChange&&k.props.onChange(Ne)),z}),k.state={isVisible:null,visibilityRect:{}},k}return w(N,[{key:"componentDidMount",value:function(){this.node=u.a.findDOMNode(this),this.props.active&&this.startWatching()}},{key:"componentWillUnmount",value:function(){this.stopWatching()}},{key:"componentDidUpdate",value:function(k){this.node=u.a.findDOMNode(this),this.props.active&&!k.active?(this.setState({isVisible:null,visibilityRect:{}}),this.startWatching()):this.props.active||this.stopWatching()}},{key:"roundRectDown",value:function(k){return{top:Math.floor(k.top),left:Math.floor(k.left),bottom:Math.floor(k.bottom),right:Math.floor(k.right)}}},{key:"render",value:function(){return this.props.children instanceof Function?this.props.children({isVisible:this.state.isVisible,visibilityRect:this.state.visibilityRect}):a.a.Children.only(this.props.children)}}]),N}(a.a.Component);O(R,"defaultProps",{active:!0,partialVisibility:!1,minTopValue:0,scrollCheck:!1,scrollDelay:250,scrollThrottle:-1,resizeCheck:!1,resizeDelay:250,resizeThrottle:-1,intervalCheck:!0,intervalDelay:100,delayedCall:!1,offset:{},containment:null,children:a.a.createElement("span",null)}),O(R,"propTypes",{onChange:f.a.func,active:f.a.bool,partialVisibility:f.a.oneOfType([f.a.bool,f.a.oneOf(["top","right","bottom","left"])]),delayedCall:f.a.bool,offset:f.a.oneOfType([f.a.shape({top:f.a.number,left:f.a.number,bottom:f.a.number,right:f.a.number}),f.a.shape({direction:f.a.oneOf(["top","right","bottom","left"]),value:f.a.number})]),scrollCheck:f.a.bool,scrollDelay:f.a.number,scrollThrottle:f.a.number,resizeCheck:f.a.bool,resizeDelay:f.a.number,resizeThrottle:f.a.number,intervalCheck:f.a.bool,intervalDelay:f.a.number,containment:typeof window<"u"?f.a.instanceOf(window.Element):f.a.any,children:f.a.oneOfType([f.a.element,f.a.func]),minTopValue:f.a.number})},function(o,i,s){var l=s(6);function a(){}function c(){}c.resetWarningCache=a,o.exports=function(){function u(p,m,g,y,b,w){if(w!==l){var v=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw v.name="Invariant Violation",v}}u.isRequired=u;function d(){return u}var f={array:u,bool:u,func:u,number:u,object:u,string:u,symbol:u,any:u,arrayOf:d,element:u,elementType:u,instanceOf:d,node:u,objectOf:d,oneOf:d,oneOfType:d,shape:d,exact:d,checkPropTypes:c,resetWarningCache:a};return f.PropTypes=f,f}},function(o,i,s){var l="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";o.exports=l}])})}(Fo)),Fo.exports}var Zk=Xk();const Yk=Vc(Zk),Qk="_wrap_15k3c_1",eE="_renderWrap_15k3c_7",tE="_title_15k3c_14",nE="_handlerWrap_15k3c_30",Tr={wrap:Qk,renderWrap:eE,title:tE,handlerWrap:nE},rE=10,oE=200,qh=15,Wh={width:"100%",height:"100%",maxWidth:"100%"};function iE({editor:n,node:e,updateAttributes:t}){const r=x.useRef(null),o=n.isActive(v1.name),{data:i,width:s,height:l}=e.attrs,[a,c]=x.useState(null),[u,d]=x.useState(!0),[f,p]=x.useState(null),[m,g]=x.useState(!1),[y,b]=x.useState(100),w=x.useCallback(T=>{T&&g(!0)},[g]),v=x.useCallback(T=>()=>{b(C=>Ac(T==="minus"?C-qh:C+qh,rE,oE))},[]);x.useEffect(()=>{let T=!1;return import("@excalidraw/excalidraw").then(C=>{T||(r.current=C.exportToSvg)}).catch(C=>!T&&p(C)).finally(()=>!T&&d(!1)),()=>{T=!0}},[d,i]),x.useEffect(()=>{let T=!1;return(async()=>{if(T||u||f||!m||!i)return;const I=await r.current(i);T||(I.setAttribute("width","100%"),I.setAttribute("height","100%"),I.setAttribute("display","block"),c(I))})(),()=>{T=!0}},[i,u,f,m]);const S=T=>{t({width:T.width,height:T.height})};return h.jsx(Ht,{className:st(Tr.wrap,o&&Tr.isActive),children:h.jsx(Yk,{onChange:w,children:h.jsx(dp.Resizable,{size:{width:Number.parseInt(s),height:Number.parseInt(l)},onResizeStop:(T,C,I,O)=>{S({width:Number.parseInt(s)+O.width,height:Number.parseInt(l)+O.height})},children:h.jsxs("div",{className:st(Tr.renderWrap,"render-wrapper"),style:{...Wh,overflow:"hidden"},children:[f&&h.jsx("div",{style:Wh,children:h.jsx("p",{children:f.message||f})}),u&&h.jsx("p",{children:"Loading..."}),!u&&!f&&m&&h.jsx("div",{dangerouslySetInnerHTML:{__html:(a==null?void 0:a.outerHTML)??""},style:{height:"100%",maxHeight:"100%",padding:24,overflow:"hidden",display:"flex",justifyContent:"center",alignItems:"center",transform:`scale(${y/100})`,transition:"all ease-in-out .3s"}}),h.jsx("div",{className:Tr.title}),h.jsxs("div",{className:Tr.handlerWrap,children:[h.jsx(at,{action:v("minus"),icon:"ZoomOut",tooltip:"Zoom Out"}),h.jsx(at,{action:v("plus"),icon:"ZoomIn",tooltip:"Zoom In"})]})]})})})})}const sE=x.memo(iE,(n,e)=>!!Qc(n.node.attrs,e.node.attrs)),Uh={elements:[]},v1=Je.create({name:"excalidraw",group:"block",selectable:!0,atom:!0,draggable:!0,inline:!1,addAttributes(){return{defaultShowPicker:{default:!1},createUser:{default:null},width:{default:"100%",parseHTML:Nn("width")},height:{default:240,parseHTML:Nn("height")},data:{default:Uh,parseHTML:Nn("data",!0)}}},addOptions(){var n;return{...(n=this.parent)==null?void 0:n.call(this),HTMLAttributes:{class:"excalidraw"},button:({editor:e})=>({component:Kk,componentProps:{editor:e}})}},parseHTML(){return[{tag:"div[class=excalidraw]"}]},renderHTML({HTMLAttributes:n,node:e}){return["div",Ue(this.options.HTMLAttributes,n,PT(e))]},addCommands(){return{setExcalidraw:n=>({tr:e,commands:t,chain:r})=>{var o,i,s;return n=n||{},n.data=n.data||Uh,((s=(i=(o=e.selection)==null?void 0:o.node)==null?void 0:i.type)==null?void 0:s.name)==this.name?t.updateAttributes(this.name,n):r().insertContent({type:this.name,attrs:n}).run()}}},addNodeView(){return qt(sE)},addInputRules(){return[ro({find:/^\$excalidraw\$$/,type:this.type,getAttributes:()=>({width:"100%"})})]}});function lE({selectImage:n,giphyApiKey:e,children:t}){const[r,o]=x.useState([]),[i]=x.useState(15),s=x.useRef(null),l=(c,u="search")=>{if(!e)return;const f=`${u==="search"?`https://api.giphy.com/v1/gifs/search?q=${c}`:`https://api.giphy.com/v1/gifs/trending?q=${c}`}&limit=${i}&api_key=${e}`;fetch(f).then(p=>p.json()).then(p=>{o(p.data)}).catch(p=>{console.log(p)})};x.useEffect(()=>{l("","trend")},[]);const a=x.useCallback(xi(c=>{if(!c.target.value){l("","trend");return}l(c.target.value)},350),[]);return h.jsxs(zn,{modal:!0,children:[h.jsx($n,{asChild:!0,children:t}),h.jsx(mn,{align:"start",className:"size-full p-2",hideWhenDetached:!0,side:"bottom",children:e?h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"mb-[10px] w-full",children:h.jsx(Rt,{onChange:a,placeholder:"Search GIF",ref:s,type:"text"})}),h.jsx("div",{className:"max-h-[280px] overflow-y-auto",children:h.jsx("div",{className:"grid grid-cols-2 gap-1 ",children:r!=null&&r.length?r==null?void 0:r.map(c=>h.jsx("img",{alt:"giphy",className:"cursor-pointer text-center",height:c.images.fixed_width_downsampled.height,onClick:()=>n(c),src:c.images.fixed_width_downsampled.url,width:c.images.fixed_width_downsampled.width},`giphy-${c.id}`)):h.jsx("p",{children:"No GIFs found"})})})]}):h.jsx("div",{children:h.jsx("p",{children:"Missing Giphy API Key"})})})]})}function aE({editor:n,icon:e,giphyApiKey:t,...r}){const o=i=>{const{url:s}=i.images.original;n.chain().focus().setImageGif({src:s}).run()};return h.jsx(lE,{giphyApiKey:t,selectImage:o,children:h.jsx(at,{icon:e,tooltip:r==null?void 0:r.tooltip})})}const ko={TOP_LEFT:"tl",TOP_RIGHT:"tr",BOTTOM_LEFT:"bl",BOTTOM_RIGHT:"br"};function cE(n){var C,I;const[e,t]=x.useState({width:ie.IMAGE_MAX_SIZE,height:ie.IMAGE_MAX_SIZE}),[r,o]=x.useState({width:0,height:0}),[i]=x.useState([ko.TOP_LEFT,ko.TOP_RIGHT,ko.BOTTOM_LEFT,ko.BOTTOM_RIGHT]),[s,l]=x.useState(!1),[a,c]=x.useState({x:0,y:0,w:0,h:0,dir:""}),{align:u}=(C=n==null?void 0:n.node)==null?void 0:C.attrs,d=x.useMemo(()=>{var k;const{src:O,alt:E,width:R,height:_}=(k=n==null?void 0:n.node)==null?void 0:k.attrs,N=ti(R)?`${R}px`:R,D=ti(_)?`${_}px`:_;return{src:O||void 0,alt:E||void 0,style:{width:N||void 0,height:D||void 0}}},[(I=n==null?void 0:n.node)==null?void 0:I.attrs]),f=x.useMemo(()=>{const{style:{width:O}}=d;return{width:O==="100%"?O:void 0}},[d]);function p(O){o({width:O.target.width,height:O.target.height})}function m(){const{editor:O,getPos:E}=n;O.commands.setNodeSelection(E())}const g=x.useCallback(Vt(()=>{const{editor:O}=n,{width:E}=getComputedStyle(O.view.dom);t(R=>({...R,width:Number.parseInt(E,10)}))},ie.IMAGE_THROTTLE_WAIT_TIME),[n==null?void 0:n.editor]);function y(O,E){O.preventDefault(),O.stopPropagation();const R=r.width,_=r.height,N=R/_;let D=Number(n.node.attrs.width),k=Number(n.node.attrs.height);const L=e.width;D&&!k?(D=D>L?L:D,k=Math.round(D/N)):k&&!D?(D=Math.round(k*N),D=D>L?L:D):!D&&!k?(D=R>L?L:R,k=Math.round(D/N)):D=D>L?L:D,l(!0),c({x:O.clientX,y:O.clientY,w:D,h:k,dir:E})}const b=x.useCallback(Vt(O=>{if(O.preventDefault(),O.stopPropagation(),!s)return;const{x:E,w:R,dir:_}=a,N=(O.clientX-E)*(/l/.test(_)?-1:1),D=og(R+N,ie.IMAGE_MIN_SIZE,e.width);n.updateAttributes({width:D,height:null})},ie.IMAGE_THROTTLE_WAIT_TIME),[s,a,e,n.updateAttributes]),w=x.useCallback(O=>{O.preventDefault(),O.stopPropagation(),s&&(c({x:0,y:0,w:0,h:0,dir:""}),l(!1),m())},[s,m]),v=x.useCallback(()=>{document==null||document.addEventListener("mousemove",b,!0),document==null||document.addEventListener("mouseup",w,!0)},[b,w]),S=x.useCallback(()=>{document==null||document.removeEventListener("mousemove",b,!0),document==null||document.removeEventListener("mouseup",w,!0)},[b,w]);x.useEffect(()=>(s?v():S(),()=>{S()}),[s,v,S]);const T=x.useMemo(()=>new ResizeObserver(()=>g()),[g]);return x.useEffect(()=>(T.observe(n.editor.view.dom),()=>{T.disconnect()}),[n.editor.view.dom,T]),h.jsx(Ht,{className:"image-view",style:{...f,width:"100%",textAlign:u},children:h.jsxs("div",{"data-drag-handle":!0,draggable:"true",style:f,className:`image-view__body ${n!=null&&n.selected?"image-view__body--focused":""} ${s?"image-view__body--resizing":""}`,children:[h.jsx("img",{alt:d.alt,className:"image-view__body__image block",height:"auto",onClick:m,onLoad:p,src:d.src,style:d.style}),(n==null?void 0:n.editor.view.editable)&&((n==null?void 0:n.selected)||s)&&h.jsx("div",{className:"image-resizer",children:i==null?void 0:i.map(O=>h.jsx("span",{className:`image-resizer__handler image-resizer__handler--${O}`,onMouseDown:E=>y(E,O)},`image-dir-${O}`))})]})})}const uE=Ti.extend({name:"imageGif",addOptions(){var n;return{...(n=this.parent)==null?void 0:n.call(this),inline:!1,content:"",marks:"",group:"block",GIPHY_API_KEY:"",draggable:!1,selectable:!0,atom:!0,button:({editor:e,extension:t,t:r})=>{var i;const o=((i=t==null?void 0:t.options)==null?void 0:i.GIPHY_API_KEY)||"";return{component:aE,componentProps:{editor:e,action:()=>{},isActive:()=>!1,disabled:!1,icon:"GifIcon",tooltip:r("editor.imageGif.tooltip"),giphyApiKey:o}}}}},addAttributes(){var n;return{...(n=this.parent)==null?void 0:n.call(this),width:{default:null,parseHTML:e=>{const t=e.style.width||e.getAttribute("width")||"10";return t===void 0?null:Number.parseInt(`${t}`,10)},renderHTML:e=>({width:e.width})},align:{default:"center",parseHTML:e=>e.getAttribute("align"),renderHTML:e=>({align:e.align})}}},addNodeView(){return qt(cE)},addCommands(){var n;return{...(n=this.parent)==null?void 0:n.call(this),setImageGif:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e}),updateImageGif:e=>({commands:t})=>t.updateAttributes(this.name,e),setAlignImageGif:e=>({commands:t})=>t.updateAttributes(this.name,{align:e})}},renderHTML({HTMLAttributes:n}){const{align:e}=n;return["div",{style:e?`text-align: ${e};`:"",class:"imageGIf"},["img",Ue({height:"auto"},this.options.HTMLAttributes,n)]]},parseHTML(){return[{tag:"div[class=imageGIf]",getAttrs:n=>{const e=n.querySelector("img"),t=e==null?void 0:e.getAttribute("width");return{src:e==null?void 0:e.getAttribute("src"),alt:e==null?void 0:e.getAttribute("alt"),title:e==null?void 0:e.getAttribute("title"),width:t?Number.parseInt(t,10):null,align:(e==null?void 0:e.getAttribute("align"))||n.style.textAlign||null}}}]}}),Eo="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",dE=n=>{n=n.replace(/\r\n/g,`
125
+ `);let e=0,t="";for(;e<n.length;e++){const r=n.charCodeAt(e);r<128?t+=String.fromCharCode(r):r>127&&r<2048?(t+=String.fromCharCode(r>>6|192),t+=String.fromCharCode(63&r|128)):(t+=String.fromCharCode(r>>12|224),t+=String.fromCharCode(r>>6&63|128),t+=String.fromCharCode(63&r|128))}return t},fE=n=>{let e,t,r,o,i,s,l,a=0,c="";for(n=dE(n);a<n.length;)e=n.charCodeAt(a++),t=n.charCodeAt(a++),r=n.charCodeAt(a++),o=e>>2,i=(3&e)<<4|t>>4,s=(15&t)<<2|r>>6,l=63&r,isNaN(t)?s=l=64:isNaN(r)&&(l=64),c=c+Eo.charAt(o)+Eo.charAt(i)+Eo.charAt(s)+Eo.charAt(l);return c},hE=n=>typeof n=="string"?"string":typeof SVGElement<"u"&&n instanceof SVGElement?"element":void 0,x1=n=>"data:image/svg+xml;base64,"+fE(n),pE=n=>x1(new XMLSerializer().serializeToString(n)),tu=n=>{switch(hE(n)){case"string":return x1(n);case"element":return pE(n);default:return n}};function nu(n=8){return Math.random().toString(36).substring(2,n+2)}const Gh=`graph TB
126
+ a-->b`,mE=({editor:n,upload:e})=>{const[t,r]=x.useState(Gh),[o,i]=x.useState(""),[s,l]=x.useState(!1),a=x.useRef(null),c=async f=>{try{const{svg:p}=await bu.render("mermaid-svg",f);i(p)}catch{i("")}},u=()=>{bu.initialize({darkMode:!1,startOnLoad:!1,fontSize:12,theme:"base"}),c(t)};x.useEffect(()=>{s&&u()},[s]),x.useEffect(()=>{s&&c(t)},[t]);const d=async()=>{if(t!==""){if(t){const f=a.current.querySelector("svg"),{width:p,height:m}=f.getBoundingClientRect(),g=`mermaid-${nu()}.svg`;let y=tu(f.outerHTML);if(e){const b=ki(y,g);y=await e(b)}n==null||n.chain().focus().setMermaid({type:"mermaid",src:y,alt:encodeURIComponent(t),width:p,height:m},!!t).run()}l(!1)}};return h.jsxs(Fn,{onOpenChange:l,open:s,children:[h.jsx(Vn,{asChild:!0,children:h.jsx(at,{action:()=>l(!0),icon:"Mermaid",tooltip:"Mermaid"})}),h.jsxs(gn,{className:"z-[99999] !max-w-[1300px]",children:[h.jsx(yn,{children:"Mermaid"}),h.jsx("div",{style:{height:"100%",borderWidth:1},children:h.jsxs("div",{className:"flex gap-[10px] rounded-[10px] p-[10px]",children:[h.jsx(Ni,{autoFocus:!0,className:"flex-1",defaultValue:Gh,onChange:f=>r(f.target.value),placeholder:"Text",required:!0,rows:10,value:t,style:{color:"hsl(var(--foreground))"}}),h.jsx("div",{className:"flex flex-1 items-center justify-center rounded-[10px] p-[10px]",dangerouslySetInnerHTML:{__html:o},ref:a,style:{height:"100%",borderWidth:1,minHeight:500,background:"#fff"}})]})}),h.jsx(mr,{children:h.jsx(Be,{onClick:d,type:"button",children:"Save changes"})})]})]})},Mo={TOP_LEFT:"tl",TOP_RIGHT:"tr",BOTTOM_LEFT:"bl",BOTTOM_RIGHT:"br"};function gE({editor:n,node:e,updateAttributes:t,getPos:r,selected:o}){const[i,s]=x.useState({width:ie.IMAGE_MAX_SIZE,height:ie.IMAGE_MAX_SIZE}),[l,a]=x.useState({width:0,height:0}),[c]=x.useState([Mo.TOP_LEFT,Mo.TOP_RIGHT,Mo.BOTTOM_LEFT,Mo.BOTTOM_RIGHT]),[u,d]=x.useState(!1),[f,p]=x.useState({x:0,y:0,w:0,h:0,dir:""}),{align:m}=e==null?void 0:e.attrs,g=x.useMemo(()=>{const{src:R,alt:_,width:N,height:D}=e==null?void 0:e.attrs,k=qr(N)?`${N}px`:N,L=qr(D)?`${D}px`:D;return{src:R||void 0,alt:_||void 0,style:{width:k||void 0,height:L||void 0}}},[e==null?void 0:e.attrs]),y=x.useMemo(()=>{const{style:{width:R}}=g;return{width:R==="100%"?R:void 0}},[g]);function b(R){a({width:R.target.width,height:R.target.height})}function w(){n.commands.setNodeSelection(r())}const v=x.useCallback(Vt(()=>{const{width:R}=getComputedStyle(n.view.dom);s(_=>({..._,width:Number.parseInt(R,10)}))},ie.IMAGE_THROTTLE_WAIT_TIME),[n]);function S(R,_){R.preventDefault(),R.stopPropagation();const N=l.width,D=l.height,k=N/D;let L=Number(e.attrs.width),F=Number(e.attrs.height);const V=i.width;L&&!F?(L=L>V?V:L,F=Math.round(L/k)):F&&!L?(L=Math.round(F*k),L=L>V?V:L):!L&&!F?(L=N>V?V:N,F=Math.round(L/k)):L=L>V?V:L,d(!0),p({x:R.clientX,y:R.clientY,w:L,h:F,dir:_})}const T=x.useCallback(Vt(R=>{if(R.preventDefault(),R.stopPropagation(),!u)return;const{x:_,w:N,dir:D}=f,k=(R.clientX-_)*(/l/.test(D)?-1:1),{width:L,height:F}=e==null?void 0:e.attrs,V=L/F,ue=Ac(N+k,ie.IMAGE_MIN_SIZE,i.width),J=Math.round(ue/V);t({width:ue,height:J})},ie.IMAGE_THROTTLE_WAIT_TIME),[u,f,i,t,e==null?void 0:e.attrs]),C=x.useCallback(R=>{R.preventDefault(),R.stopPropagation(),u&&(p({x:0,y:0,w:0,h:0,dir:""}),d(!1),w())},[u,w]),I=x.useCallback(()=>{document==null||document.addEventListener("mousemove",T,!0),document==null||document.addEventListener("mouseup",C,!0)},[T,C]),O=x.useCallback(()=>{document==null||document.removeEventListener("mousemove",T,!0),document==null||document.removeEventListener("mouseup",C,!0)},[T,C]);x.useEffect(()=>(u?I():O(),()=>{O()}),[u,I,O]);const E=x.useMemo(()=>new ResizeObserver(()=>v()),[v]);return x.useEffect(()=>(E.observe(n.view.dom),()=>{E.disconnect()}),[n.view.dom,E]),h.jsx(Ht,{className:"image-view",style:{...y,width:"100%",textAlign:m},children:h.jsxs("div",{"data-drag-handle":!0,draggable:"true",style:{...y,background:"#fff"},className:`image-view__body ${o?"image-view__body--focused":""} ${u?"image-view__body--resizing":""}`,children:[h.jsx("img",{alt:g.alt,className:"image-view__body__image block",height:"auto",onClick:w,onLoad:b,src:g.src,style:g.style}),n.view.editable&&(o||u)&&h.jsx("div",{className:"image-resizer",children:c==null?void 0:c.map(R=>h.jsx("span",{className:`image-resizer__handler image-resizer__handler--${R}`,onMouseDown:_=>S(_,R)},`image-dir-${R}`))})]})})}const yE=Ti.extend({name:"mermaid",addOptions(){var n;return{...(n=this.parent)==null?void 0:n.call(this),inline:!1,content:"",marks:"",group:"block",draggable:!1,selectable:!0,atom:!0,HTMLAttributes:{class:"mermaid"},button:({editor:e,t,extension:r})=>{var o;return{component:mE,componentProps:{action:()=>!0,isActive:()=>!1,disabled:!1,editor:e,icon:"Mermaid",tooltip:t("editor.mermaid.tooltip"),upload:(o=r==null?void 0:r.options)==null?void 0:o.upload}}}}},addAttributes(){var n;return{...(n=this.parent)==null?void 0:n.call(this),width:{default:null,parseHTML:e=>{const t=e.querySelector("img"),r=t==null?void 0:t.getAttribute("width");return r?Number.parseInt(r,10):320},renderHTML:e=>({width:e.width})},height:{default:null,parseHTML:e=>{const t=e.querySelector("img"),r=t==null?void 0:t.getAttribute("height");return r?Number.parseInt(r,10):212},renderHTML:e=>({height:e.height})},align:{default:"center",parseHTML:e=>e.getAttribute("align"),renderHTML:e=>({align:e.align})}}},addNodeView(){return qt(gE)},addCommands(){return{setMermaid:(n,e)=>({commands:t,editor:r})=>e?t.insertContent({type:this.name,attrs:n}):t.insertContentAt(r.state.selection.anchor,{type:this.name,attrs:n}),setAlignImageMermaid:n=>({commands:e})=>e.updateAttributes(this.name,{align:n})}},renderHTML({HTMLAttributes:n}){const{align:e}=n;return["div",{style:e?`text-align: ${e};`:"",class:"imageMermaid"},["img",Ue(this.options.HTMLAttributes,n)]]},parseHTML(){return[{tag:"div[class=imageMermaid]",getAttrs:n=>{const e=n.querySelector("img"),t=e==null?void 0:e.getAttribute("width"),r=e==null?void 0:e.getAttribute("height");return{src:e==null?void 0:e.getAttribute("src"),alt:e==null?void 0:e.getAttribute("alt"),width:t?Number.parseInt(t,10):null,height:r?Number.parseInt(r,10):null,align:(e==null?void 0:e.getAttribute("align"))||n.style.textAlign||null}}}]}}),bE="_verified_lvyh0_1",ru={verified:bE},vE=()=>h.jsx("svg",{viewBox:"0 0 24 24","aria-label":"Verified account",role:"img",className:ru.verified,children:h.jsx("g",{children:h.jsx("path",{d:"M22.25 12c0-1.43-.88-2.67-2.19-3.34.46-1.39.2-2.9-.81-3.91s-2.52-1.27-3.91-.81c-.66-1.31-1.91-2.19-3.34-2.19s-2.67.88-3.33 2.19c-1.4-.46-2.91-.2-3.92.81s-1.26 2.52-.8 3.91c-1.31.67-2.2 1.91-2.2 3.34s.89 2.67 2.2 3.34c-.46 1.39-.21 2.9.8 3.91s2.52 1.26 3.91.81c.67 1.31 1.91 2.19 3.34 2.19s2.68-.88 3.34-2.19c1.39.45 2.9.2 3.91-.81s1.27-2.52.81-3.91c1.31-.67 2.19-1.91 2.19-3.34zm-11.71 4.2L6.8 12.46l1.41-1.42 2.26 2.26 4.8-5.23 1.47 1.36-6.2 6.77z"})})}),xE=()=>h.jsx("svg",{viewBox:"0 0 22 22","aria-label":"Verified account",role:"img",className:ru.verified,children:h.jsxs("g",{children:[h.jsxs("linearGradient",{gradientUnits:"userSpaceOnUse",id:"0-a",x1:"4.411",x2:"18.083",y1:"2.495",y2:"21.508",children:[h.jsx("stop",{offset:"0",stopColor:"#f4e72a"}),h.jsx("stop",{offset:".539",stopColor:"#cd8105"}),h.jsx("stop",{offset:".68",stopColor:"#cb7b00"}),h.jsx("stop",{offset:"1",stopColor:"#f4ec26"}),h.jsx("stop",{offset:"1",stopColor:"#f4e72a"})]}),h.jsxs("linearGradient",{gradientUnits:"userSpaceOnUse",id:"0-b",x1:"5.355",x2:"16.361",y1:"3.395",y2:"19.133",children:[h.jsx("stop",{offset:"0",stopColor:"#f9e87f"}),h.jsx("stop",{offset:".406",stopColor:"#e2b719"}),h.jsx("stop",{offset:".989",stopColor:"#e2b719"})]}),h.jsxs("g",{clipRule:"evenodd",fillRule:"evenodd",children:[h.jsx("path",{d:"M13.324 3.848L11 1.6 8.676 3.848l-3.201-.453-.559 3.184L2.06 8.095 3.48 11l-1.42 2.904 2.856 1.516.559 3.184 3.201-.452L11 20.4l2.324-2.248 3.201.452.559-3.184 2.856-1.516L18.52 11l1.42-2.905-2.856-1.516-.559-3.184zm-7.09 7.575l3.428 3.428 5.683-6.206-1.347-1.247-4.4 4.795-2.072-2.072z",fill:"url(#0-a)"}),h.jsx("path",{d:"M13.101 4.533L11 2.5 8.899 4.533l-2.895-.41-.505 2.88-2.583 1.37L4.2 11l-1.284 2.627 2.583 1.37.505 2.88 2.895-.41L11 19.5l2.101-2.033 2.895.41.505-2.88 2.583-1.37L17.8 11l1.284-2.627-2.583-1.37-.505-2.88zm-6.868 6.89l3.429 3.428 5.683-6.206-1.347-1.247-4.4 4.795-2.072-2.072z",fill:"url(#0-b)"}),h.jsx("path",{d:"M6.233 11.423l3.429 3.428 5.65-6.17.038-.033-.005 1.398-5.683 6.206-3.429-3.429-.003-1.405.005.003z",fill:"#d18800"})]})]})}),wE=()=>h.jsx("svg",{viewBox:"0 0 22 22","aria-label":"Verified account",role:"img",className:ru.verified,children:h.jsx("g",{children:h.jsx("path",{clipRule:"evenodd",d:"M12.05 2.056c-.568-.608-1.532-.608-2.1 0l-1.393 1.49c-.284.303-.685.47-1.1.455L5.42 3.932c-.832-.028-1.514.654-1.486 1.486l.069 2.039c.014.415-.152.816-.456 1.1l-1.49 1.392c-.608.568-.608 1.533 0 2.101l1.49 1.393c.304.284.47.684.456 1.1l-.07 2.038c-.027.832.655 1.514 1.487 1.486l2.038-.069c.415-.014.816.152 1.1.455l1.392 1.49c.569.609 1.533.609 2.102 0l1.393-1.49c.283-.303.684-.47 1.099-.455l2.038.069c.832.028 1.515-.654 1.486-1.486L18 14.542c-.015-.415.152-.815.455-1.099l1.49-1.393c.608-.568.608-1.533 0-2.101l-1.49-1.393c-.303-.283-.47-.684-.455-1.1l.068-2.038c.029-.832-.654-1.514-1.486-1.486l-2.038.07c-.415.013-.816-.153-1.1-.456zm-5.817 9.367l3.429 3.428 5.683-6.206-1.347-1.247-4.4 4.795-2.072-2.072z",fillRule:"evenodd"})})}),SE="_root_98iqw_1",CE="_article_98iqw_21",Kh={root:SE,article:CE},ou=({className:n,children:e})=>h.jsx("div",{className:st("react-tweet-theme",Kh.root,n),children:h.jsx("article",{className:Kh.article,children:e})}),w1=n=>h.jsx("img",{...n}),TE="_header_nqq4j_1",kE="_avatar_nqq4j_11",EE="_avatarOverflow_nqq4j_16",ME="_avatarSquare_nqq4j_23",OE="_avatarShadow_nqq4j_26",AE="_author_nqq4j_37",NE="_authorLink_nqq4j_44",RE="_authorVerified_nqq4j_53",IE="_authorLinkText_nqq4j_56",_E="_authorMeta_nqq4j_63",DE="_authorFollow_nqq4j_66",jE="_username_nqq4j_69",PE="_follow_nqq4j_74",LE="_separator_nqq4j_82",BE="_brand_nqq4j_86",zE="_twitterIcon_nqq4j_90",Ve={header:TE,avatar:kE,avatarOverflow:EE,avatarSquare:ME,avatarShadow:OE,author:AE,authorLink:NE,authorVerified:RE,authorLinkText:IE,authorMeta:_E,authorFollow:DE,username:jE,follow:PE,separator:LE,brand:BE,twitterIcon:zE},$E="_verifiedOld_lcna5_1",FE="_verifiedBlue_lcna5_4",VE="_verifiedGovernment_lcna5_7",ea={verifiedOld:$E,verifiedBlue:FE,verifiedGovernment:VE},S1=({user:n,className:e})=>{const t=n.verified||n.is_blue_verified||n.verified_type;let r=h.jsx(vE,{}),o=ea.verifiedBlue;if(t)switch(n.is_blue_verified||(o=ea.verifiedOld),n.verified_type){case"Government":r=h.jsx(wE,{}),o=ea.verifiedGovernment;break;case"Business":r=h.jsx(xE,{}),o=null;break}return t?h.jsx("div",{className:st(e,o),children:r}):null},HE=({tweet:n,components:e})=>{var t;const r=(t=e==null?void 0:e.AvatarImg)!=null?t:w1,{user:o}=n;return h.jsxs("div",{className:Ve.header,children:[h.jsxs("a",{href:n.url,className:Ve.avatar,target:"_blank",rel:"noopener noreferrer",children:[h.jsx("div",{className:st(Ve.avatarOverflow,o.profile_image_shape==="Square"&&Ve.avatarSquare),children:h.jsx(r,{src:o.profile_image_url_https,alt:o.name,width:48,height:48})}),h.jsx("div",{className:Ve.avatarOverflow,children:h.jsx("div",{className:Ve.avatarShadow})})]}),h.jsxs("div",{className:Ve.author,children:[h.jsxs("a",{href:n.url,className:Ve.authorLink,target:"_blank",rel:"noopener noreferrer",children:[h.jsx("div",{className:Ve.authorLinkText,children:h.jsx("span",{title:o.name,children:o.name})}),h.jsx(S1,{user:o,className:Ve.authorVerified})]}),h.jsxs("div",{className:Ve.authorMeta,children:[h.jsx("a",{href:n.url,className:Ve.username,target:"_blank",rel:"noopener noreferrer",children:h.jsxs("span",{title:`@${o.screen_name}`,children:["@",o.screen_name]})}),h.jsxs("div",{className:Ve.authorFollow,children:[h.jsx("span",{className:Ve.separator,children:"·"}),h.jsx("a",{href:o.follow_url,className:Ve.follow,target:"_blank",rel:"noopener noreferrer",children:"Follow"})]})]})]}),h.jsx("a",{href:n.url,className:Ve.brand,target:"_blank",rel:"noopener noreferrer","aria-label":"View on Twitter",children:h.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",className:Ve.twitterIcon,children:h.jsx("g",{children:h.jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})})})})]})},qE="_root_1ec15_1",WE={root:qE},UE=({tweet:n})=>h.jsxs("a",{href:n.in_reply_to_url,className:WE.root,target:"_blank",rel:"noopener noreferrer",children:["Replying to @",n.in_reply_to_screen_name]}),GE="_root_eihfa_1",KE={root:GE},JE=({href:n,children:e})=>h.jsx("a",{href:n,className:KE.root,target:"_blank",rel:"noopener noreferrer nofollow",children:e}),XE="_root_1xq52_1",ZE={root:XE},YE=({tweet:n})=>h.jsx("p",{className:ZE.root,lang:n.lang,dir:"auto",children:n.entities.map((e,t)=>{switch(e.type){case"hashtag":case"mention":case"url":case"symbol":return h.jsx(JE,{href:e.href,children:e.text},t);case"media":return;default:return h.jsx("span",{dangerouslySetInnerHTML:{__html:e.text}},t)}})}),Jh=n=>`https://x.com/${n.user.screen_name}/status/${n.id_str}`,C1=n=>`https://x.com/${typeof n=="string"?n:n.user.screen_name}`,QE=n=>`https://x.com/intent/like?tweet_id=${n.id_str}`,eM=n=>`https://x.com/intent/tweet?in_reply_to=${n.id_str}`,tM=n=>`https://x.com/intent/follow?screen_name=${n.user.screen_name}`,nM=n=>`https://x.com/hashtag/${n.text}`,rM=n=>`https://x.com/search?q=%24${n.text}`,oM=n=>`https://x.com/${n.in_reply_to_screen_name}/status/${n.in_reply_to_status_id_str}`,T1=(n,e)=>{const t=new URL(n.media_url_https),r=t.pathname.split(".").pop();return r?(t.pathname=t.pathname.replace(`.${r}`,""),t.searchParams.set("format",r),t.searchParams.set("name",e),t.toString()):n.media_url_https},iM=n=>{const{variants:e}=n.video_info;return e.filter(r=>r.content_type==="video/mp4").sort((r,o)=>{var i,s;return((i=o.bitrate)!=null?i:0)-((s=r.bitrate)!=null?s:0)})},sM=n=>{const e=iM(n);return e.length>1?e[1]:e[0]},qa=n=>n>999999?`${(n/1e6).toFixed(1)}M`:n>999?`${(n/1e3).toFixed(1)}K`:n.toString();function Xh(n){const e=Array.from(n.text),t=[{indices:n.display_text_range,type:"text"}];return kr(t,"hashtag",n.entities.hashtags),kr(t,"mention",n.entities.user_mentions),kr(t,"url",n.entities.urls),kr(t,"symbol",n.entities.symbols),n.entities.media&&kr(t,"media",n.entities.media),lM(n,t),t.map(r=>{const o=e.slice(r.indices[0],r.indices[1]).join("");switch(r.type){case"hashtag":return Object.assign(r,{href:nM(r),text:o});case"mention":return Object.assign(r,{href:C1(r.screen_name),text:o});case"url":case"media":return Object.assign(r,{href:r.expanded_url,text:r.display_url});case"symbol":return Object.assign(r,{href:rM(r),text:o});default:return Object.assign(r,{text:o})}})}function kr(n,e,t){for(const r of t)for(const[o,i]of n.entries()){if(i.indices[0]>r.indices[0]||i.indices[1]<r.indices[1])continue;const s=[{...r,type:e}];i.indices[0]<r.indices[0]&&s.unshift({indices:[i.indices[0],r.indices[0]],type:"text"}),i.indices[1]>r.indices[1]&&s.push({indices:[r.indices[1],i.indices[1]],type:"text"}),n.splice(o,1,...s);break}}function lM(n,e){n.entities.media&&n.entities.media[0].indices[0]<n.display_text_range[1]&&(n.display_text_range[1]=n.entities.media[0].indices[0]);const t=e.at(-1);t&&t.indices[1]>n.display_text_range[1]&&(t.indices[1]=n.display_text_range[1])}const aM=n=>({...n,url:Jh(n),user:{...n.user,url:C1(n),follow_url:tM(n)},like_url:QE(n),reply_url:eM(n),in_reply_to_url:n.in_reply_to_screen_name?oM(n):void 0,entities:Xh(n),quoted_tweet:n.quoted_tweet?{...n.quoted_tweet,url:Jh(n.quoted_tweet),entities:Xh(n.quoted_tweet)}:void 0}),cM="_root_g9tkv_1",uM="_rounded_g9tkv_6",dM="_mediaWrapper_g9tkv_10",fM="_grid2Columns_g9tkv_17",hM="_grid3_g9tkv_20",pM="_grid2x2_g9tkv_23",mM="_mediaContainer_g9tkv_26",gM="_mediaLink_g9tkv_34",yM="_skeleton_g9tkv_38",bM="_image_g9tkv_43",ut={root:cM,rounded:uM,mediaWrapper:dM,grid2Columns:fM,grid3:hM,grid2x2:pM,mediaContainer:mM,mediaLink:gM,skeleton:yM,image:bM},vM="_anchor_fp31d_1",xM="_videoButton_fp31d_17",wM="_videoButtonIcon_fp31d_35",SM="_watchOnTwitter_fp31d_44",CM="_viewReplies_fp31d_60",Xn={anchor:vM,videoButton:xM,videoButtonIcon:wM,watchOnTwitter:SM,viewReplies:CM},TM=({tweet:n,media:e})=>{const[t,r]=x.useState(!0),[o,i]=x.useState(!1),[s,l]=x.useState(!1),a=sM(e);let c=0;return h.jsxs(h.Fragment,{children:[h.jsx("video",{className:ut.image,poster:T1(e,"small"),controls:!t,playsInline:!0,preload:"none",tabIndex:t?-1:0,onPlay:()=>{c&&window.clearTimeout(c),o||i(!0),s&&l(!1)},onPause:()=>{c&&window.clearTimeout(c),c=window.setTimeout(()=>{o&&i(!1),c=0},100)},onEnded:()=>{l(!0)},children:h.jsx("source",{src:a.url,type:a.content_type})}),t&&h.jsx("button",{type:"button",className:Xn.videoButton,"aria-label":"View video on X",onClick:u=>{const d=u.currentTarget.previousSibling;u.preventDefault(),r(!1),d.load(),d.play().then(()=>{i(!0),d.focus()}).catch(f=>{console.error("Error playing video:",f),r(!0),i(!1)})},children:h.jsx("svg",{viewBox:"0 0 24 24",className:Xn.videoButtonIcon,"aria-hidden":"true",children:h.jsx("g",{children:h.jsx("path",{d:"M21 12L4 2v20l17-10z"})})})}),!o&&!s&&h.jsx("div",{className:Xn.watchOnTwitter,children:h.jsx("a",{href:n.url,className:Xn.anchor,target:"_blank",rel:"noopener noreferrer",children:t?"Watch on X":"Continue watching on X"})}),s&&h.jsx("a",{href:n.url,className:st(Xn.anchor,Xn.viewReplies),target:"_blank",rel:"noopener noreferrer",children:"View replies"})]})},kM=n=>h.jsx("img",{...n}),Zh=(n,e)=>{let t=56.25;return e===1&&(t=100/n.original_info.width*n.original_info.height),e===2&&(t=t*2),{width:n.type==="photo"?void 0:"unset",paddingBottom:`${t}%`}},k1=({tweet:n,components:e,quoted:t})=>{var r,o,i;const s=(i=(r=n.mediaDetails)==null?void 0:r.length)!=null?i:0;var l;const a=(l=e==null?void 0:e.MediaImg)!=null?l:kM;return h.jsx("div",{className:st(ut.root,!t&&ut.rounded),children:h.jsx("div",{className:st(ut.mediaWrapper,s>1&&ut.grid2Columns,s===3&&ut.grid3,s>4&&ut.grid2x2),children:(o=n.mediaDetails)==null?void 0:o.map(c=>h.jsx(x.Fragment,{children:c.type==="photo"?h.jsxs("a",{href:n.url,className:st(ut.mediaContainer,ut.mediaLink),target:"_blank",rel:"noopener noreferrer",children:[h.jsx("div",{className:ut.skeleton,style:Zh(c,s)}),h.jsx(a,{src:T1(c,"small"),alt:c.ext_alt_text||"Image",className:ut.image,draggable:!0})]},c.media_url_https):h.jsxs("div",{className:ut.mediaContainer,children:[h.jsx("div",{className:ut.skeleton,style:Zh(c,s)}),h.jsx(TM,{tweet:n,media:c})]},c.media_url_https)},c.media_url_https))})})},EM={hour:"numeric",minute:"2-digit",hour12:!0,weekday:"short",month:"short",day:"numeric",year:"numeric"},MM=new Intl.DateTimeFormat("en-US",EM),OM=n=>{const e={};for(const t of n)e[t.type]=t.value;return e},AM=n=>{const e=OM(MM.formatToParts(n)),t=`${e.hour}:${e.minute} ${e.dayPeriod}`,r=`${e.month} ${e.day}, ${e.year}`;return`${t} · ${r}`},NM="_root_i24yn_1",RM={root:NM},IM=({tweet:n})=>{const e=new Date(n.created_at),t=AM(e);return h.jsx("a",{className:RM.root,href:n.url,target:"_blank",rel:"noopener noreferrer","aria-label":t,children:h.jsx("time",{dateTime:e.toISOString(),children:t})})},_M="_info_19qcj_1",DM="_infoLink_19qcj_10",jM="_infoIcon_19qcj_30",ta={info:_M,infoLink:DM,infoIcon:jM},PM=({tweet:n})=>h.jsxs("div",{className:ta.info,children:[h.jsx(IM,{tweet:n}),h.jsx("a",{className:ta.infoLink,href:"https://help.x.com/en/x-for-websites-ads-info-and-privacy",target:"_blank",rel:"noopener noreferrer","aria-label":"Twitter for Websites, Ads Information and Privacy",children:h.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",className:ta.infoIcon,children:h.jsx("g",{children:h.jsx("path",{d:"M13.5 8.5c0 .83-.67 1.5-1.5 1.5s-1.5-.67-1.5-1.5S11.17 7 12 7s1.5.67 1.5 1.5zM13 17v-5h-2v5h2zm-1 5.25c5.66 0 10.25-4.59 10.25-10.25S17.66 1.75 12 1.75 1.75 6.34 1.75 12 6.34 22.25 12 22.25zM20.25 12c0 4.56-3.69 8.25-8.25 8.25S3.75 16.56 3.75 12 7.44 3.75 12 3.75s8.25 3.69 8.25 8.25z"})})})})]}),LM="_actions_n2anf_1",BM="_like_n2anf_13",zM="_reply_n2anf_14",$M="_copy_n2anf_15",FM="_likeIconWrapper_n2anf_27",VM="_likeCount_n2anf_30",HM="_replyIconWrapper_n2anf_35",qM="_copyIconWrapper_n2anf_36",WM="_likeIcon_n2anf_27",UM="_replyIcon_n2anf_35",GM="_copyIcon_n2anf_36",KM="_replyText_n2anf_56",JM="_copyText_n2anf_57",rt={actions:LM,like:BM,reply:zM,copy:$M,likeIconWrapper:FM,likeCount:VM,replyIconWrapper:HM,copyIconWrapper:qM,likeIcon:WM,replyIcon:UM,copyIcon:GM,replyText:KM,copyText:JM},XM=({tweet:n})=>{const[e,t]=x.useState(!1),r=()=>{navigator.clipboard.writeText(n.url),t(!0)};return x.useEffect(()=>{if(e){const o=setTimeout(()=>{t(!1)},6e3);return()=>clearTimeout(o)}},[e]),h.jsxs("button",{type:"button",className:rt.copy,"aria-label":"Copy link",onClick:r,children:[h.jsx("div",{className:rt.copyIconWrapper,children:e?h.jsx("svg",{viewBox:"0 0 24 24",className:rt.copyIcon,"aria-hidden":"true",children:h.jsx("g",{children:h.jsx("path",{d:"M9.64 18.952l-5.55-4.861 1.317-1.504 3.951 3.459 8.459-10.948L19.4 6.32 9.64 18.952z"})})}):h.jsx("svg",{viewBox:"0 0 24 24",className:rt.copyIcon,"aria-hidden":"true",children:h.jsx("g",{children:h.jsx("path",{d:"M18.36 5.64c-1.95-1.96-5.11-1.96-7.07 0L9.88 7.05 8.46 5.64l1.42-1.42c2.73-2.73 7.16-2.73 9.9 0 2.73 2.74 2.73 7.17 0 9.9l-1.42 1.42-1.41-1.42 1.41-1.41c1.96-1.96 1.96-5.12 0-7.07zm-2.12 3.53l-7.07 7.07-1.41-1.41 7.07-7.07 1.41 1.41zm-12.02.71l1.42-1.42 1.41 1.42-1.41 1.41c-1.96 1.96-1.96 5.12 0 7.07 1.95 1.96 5.11 1.96 7.07 0l1.41-1.41 1.42 1.41-1.42 1.42c-2.73 2.73-7.16 2.73-9.9 0-2.73-2.74-2.73-7.17 0-9.9z"})})})}),h.jsx("span",{className:rt.copyText,children:e?"Copied!":"Copy link"})]})},ZM=({tweet:n})=>{const e=qa(n.favorite_count);return h.jsxs("div",{className:rt.actions,children:[h.jsxs("a",{className:rt.like,href:n.like_url,target:"_blank",rel:"noopener noreferrer","aria-label":`Like. This Tweet has ${e} likes`,children:[h.jsx("div",{className:rt.likeIconWrapper,children:h.jsx("svg",{viewBox:"0 0 24 24",className:rt.likeIcon,"aria-hidden":"true",children:h.jsx("g",{children:h.jsx("path",{d:"M20.884 13.19c-1.351 2.48-4.001 5.12-8.379 7.67l-.503.3-.504-.3c-4.379-2.55-7.029-5.19-8.382-7.67-1.36-2.5-1.41-4.86-.514-6.67.887-1.79 2.647-2.91 4.601-3.01 1.651-.09 3.368.56 4.798 2.01 1.429-1.45 3.146-2.1 4.796-2.01 1.954.1 3.714 1.22 4.601 3.01.896 1.81.846 4.17-.514 6.67z"})})})}),h.jsx("span",{className:rt.likeCount,children:e})]}),h.jsxs("a",{className:rt.reply,href:n.reply_url,target:"_blank",rel:"noopener noreferrer","aria-label":"Reply to this Tweet on Twitter",children:[h.jsx("div",{className:rt.replyIconWrapper,children:h.jsx("svg",{viewBox:"0 0 24 24",className:rt.replyIcon,"aria-hidden":"true",children:h.jsx("g",{children:h.jsx("path",{d:"M1.751 10c0-4.42 3.584-8 8.005-8h4.366c4.49 0 8.129 3.64 8.129 8.13 0 2.96-1.607 5.68-4.196 7.11l-8.054 4.46v-3.69h-.067c-4.49.1-8.183-3.51-8.183-8.01z"})})})}),h.jsx("span",{className:rt.replyText,children:"Reply"})]}),h.jsx(XM,{tweet:n})]})},YM="_replies_1cutb_1",QM="_link_1cutb_4",eO="_text_1cutb_23",na={replies:YM,link:QM,text:eO},tO=({tweet:n})=>h.jsx("div",{className:na.replies,children:h.jsx("a",{className:na.link,href:n.url,target:"_blank",rel:"noopener noreferrer",children:h.jsx("span",{className:na.text,children:n.conversation_count===0?"Read more on X":n.conversation_count===1?`Read ${qa(n.conversation_count)} reply`:`Read ${qa(n.conversation_count)} replies`})})}),nO="_root_q5799_1",rO="_article_q5799_16",Yh={root:nO,article:rO},oO=({tweet:n,children:e})=>h.jsx("div",{className:Yh.root,onClick:t=>{t.preventDefault(),window.open(n.url,"_blank")},children:h.jsx("article",{className:Yh.article,children:e})}),iO="_header_r31i5_1",sO="_avatar_r31i5_11",lO="_avatarSquare_r31i5_17",aO="_author_r31i5_21",cO="_authorText_r31i5_26",uO="_username_r31i5_33",wn={header:iO,avatar:sO,avatarSquare:lO,author:aO,authorText:cO,username:uO},dO=({tweet:n})=>{const{user:e}=n;return h.jsxs("div",{className:wn.header,children:[h.jsx("a",{href:n.url,className:wn.avatar,target:"_blank",rel:"noopener noreferrer",children:h.jsx("div",{className:st(wn.avatarOverflow,e.profile_image_shape==="Square"&&wn.avatarSquare),children:h.jsx(w1,{src:e.profile_image_url_https,alt:e.name,width:20,height:20})})}),h.jsxs("div",{className:wn.author,children:[h.jsx("div",{className:wn.authorText,children:h.jsx("span",{title:e.name,children:e.name})}),h.jsx(S1,{user:e}),h.jsx("div",{className:wn.username,children:h.jsxs("span",{title:`@${e.screen_name}`,children:["@",e.screen_name]})})]})]})},fO="_root_175ot_1",hO={root:fO},pO=({tweet:n})=>h.jsx("p",{className:hO.root,lang:n.lang,dir:"auto",children:n.entities.map((e,t)=>h.jsx("span",{dangerouslySetInnerHTML:{__html:e.text}},t))}),mO=({tweet:n})=>{var e;return h.jsxs(oO,{tweet:n,children:[h.jsx(dO,{tweet:n}),h.jsx(pO,{tweet:n}),(e=n.mediaDetails)!=null&&e.length?h.jsx(k1,{quoted:!0,tweet:n}):null]})},gO=({tweet:n,components:e})=>{var t;const r=x.useMemo(()=>aM(n),[n]);return h.jsxs(ou,{children:[h.jsx(HE,{tweet:r,components:e}),r.in_reply_to_status_id_str&&h.jsx(UE,{tweet:r}),h.jsx(YE,{tweet:r}),(t=r.mediaDetails)!=null&&t.length?h.jsx(k1,{tweet:r,components:e}):null,r.quoted_tweet&&h.jsx(mO,{tweet:r.quoted_tweet}),h.jsx(PM,{tweet:r}),h.jsx(ZM,{tweet:r}),h.jsx(tO,{tweet:r})]})},yO="_root_16yxa_1",bO={root:yO},vO=n=>h.jsx(ou,{children:h.jsxs("div",{className:bO.root,children:[h.jsx("h3",{children:"Tweet not found"}),h.jsx("p",{children:"The embedded tweet could not be found…"})]})}),xO="_skeleton_oi7hr_1",wO={skeleton:xO},Oo=({style:n})=>h.jsx("span",{className:wO.skeleton,style:n}),SO="_root_17qqv_1",CO={root:SO},TO=()=>h.jsxs(ou,{className:CO.root,children:[h.jsx(Oo,{style:{height:"3rem",marginBottom:"0.75rem"}}),h.jsx(Oo,{style:{height:"6rem",margin:"0.5rem 0"}}),h.jsx("div",{style:{borderTop:"var(--tweet-border)",margin:"0.5rem 0"}}),h.jsx(Oo,{style:{height:"2rem"}}),h.jsx(Oo,{style:{height:"2rem",borderRadius:"9999px",marginTop:"0.5rem"}})]});var Ao={exports:{}},ra={};/**
127
+ * @license React
128
+ * use-sync-external-store-shim.production.js
129
+ *
130
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
131
+ *
132
+ * This source code is licensed under the MIT license found in the
133
+ * LICENSE file in the root directory of this source tree.
134
+ */var Qh;function kO(){if(Qh)return ra;Qh=1;var n=x;function e(d,f){return d===f&&(d!==0||1/d===1/f)||d!==d&&f!==f}var t=typeof Object.is=="function"?Object.is:e,r=n.useState,o=n.useEffect,i=n.useLayoutEffect,s=n.useDebugValue;function l(d,f){var p=f(),m=r({inst:{value:p,getSnapshot:f}}),g=m[0].inst,y=m[1];return i(function(){g.value=p,g.getSnapshot=f,a(g)&&y({inst:g})},[d,p,f]),o(function(){return a(g)&&y({inst:g}),d(function(){a(g)&&y({inst:g})})},[d]),s(p),p}function a(d){var f=d.getSnapshot;d=d.value;try{var p=f();return!t(d,p)}catch{return!0}}function c(d,f){return f()}var u=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?c:l;return ra.useSyncExternalStore=n.useSyncExternalStore!==void 0?n.useSyncExternalStore:u,ra}var oa={};/**
135
+ * @license React
136
+ * use-sync-external-store-shim.development.js
137
+ *
138
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
139
+ *
140
+ * This source code is licensed under the MIT license found in the
141
+ * LICENSE file in the root directory of this source tree.
142
+ */var ep;function EO(){return ep||(ep=1,process.env.NODE_ENV!=="production"&&function(){function n(p,m){return p===m&&(p!==0||1/p===1/m)||p!==p&&m!==m}function e(p,m){u||o.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=m();if(!d){var y=m();i(g,y)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),d=!0)}y=s({inst:{value:g,getSnapshot:m}});var b=y[0].inst,w=y[1];return a(function(){b.value=g,b.getSnapshot=m,t(b)&&w({inst:b})},[p,g,m]),l(function(){return t(b)&&w({inst:b}),p(function(){t(b)&&w({inst:b})})},[p]),c(g),g}function t(p){var m=p.getSnapshot;p=p.value;try{var g=m();return!i(p,g)}catch{return!0}}function r(p,m){return m()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var o=x,i=typeof Object.is=="function"?Object.is:n,s=o.useState,l=o.useEffect,a=o.useLayoutEffect,c=o.useDebugValue,u=!1,d=!1,f=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?r:e;oa.useSyncExternalStore=o.useSyncExternalStore!==void 0?o.useSyncExternalStore:f,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),oa}var tp;function MO(){return tp||(tp=1,process.env.NODE_ENV==="production"?Ao.exports=kO():Ao.exports=EO()),Ao.exports}var OO=MO();const E1=0,M1=1,O1=2,np=3;var rp=Object.prototype.hasOwnProperty;function Wa(n,e){var t,r;if(n===e)return!0;if(n&&e&&(t=n.constructor)===e.constructor){if(t===Date)return n.getTime()===e.getTime();if(t===RegExp)return n.toString()===e.toString();if(t===Array){if((r=n.length)===e.length)for(;r--&&Wa(n[r],e[r]););return r===-1}if(!t||typeof n=="object"){r=0;for(t in n)if(rp.call(n,t)&&++r&&!rp.call(e,t)||!(t in e)||!Wa(n[t],e[t]))return!1;return Object.keys(e).length===r}}return n!==n&&e!==e}const Lt=new WeakMap,rn=()=>{},Qe=rn(),Ua=Object,fe=n=>n===Qe,Et=n=>typeof n=="function",fn=(n,e)=>({...n,...e}),A1=n=>Et(n.then),ia={},No={},iu="undefined",io=typeof window!=iu,Ga=typeof document!=iu,AO=io&&"Deno"in window,NO=()=>io&&typeof window.requestAnimationFrame!=iu,N1=(n,e)=>{const t=Lt.get(n);return[()=>!fe(e)&&n.get(e)||ia,r=>{if(!fe(e)){const o=n.get(e);e in No||(No[e]=o),t[5](e,fn(o,r),o||ia)}},t[6],()=>!fe(e)&&e in No?No[e]:!fe(e)&&n.get(e)||ia]};let Ka=!0;const RO=()=>Ka,[Ja,Xa]=io&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[rn,rn],IO=()=>{const n=Ga&&document.visibilityState;return fe(n)||n!=="hidden"},_O=n=>(Ga&&document.addEventListener("visibilitychange",n),Ja("focus",n),()=>{Ga&&document.removeEventListener("visibilitychange",n),Xa("focus",n)}),DO=n=>{const e=()=>{Ka=!0,n()},t=()=>{Ka=!1};return Ja("online",e),Ja("offline",t),()=>{Xa("online",e),Xa("offline",t)}},jO={isOnline:RO,isVisible:IO},PO={initFocus:_O,initReconnect:DO},op=!x.useId,Yr=!io||AO,LO=n=>NO()?window.requestAnimationFrame(n):setTimeout(n,1),sa=Yr?x.useEffect:x.useLayoutEffect,la=typeof navigator<"u"&&navigator.connection,ip=!Yr&&la&&(["slow-2g","2g"].includes(la.effectiveType)||la.saveData),Ro=new WeakMap,aa=(n,e)=>Ua.prototype.toString.call(n)===`[object ${e}]`;let BO=0;const Za=n=>{const e=typeof n,t=aa(n,"Date"),r=aa(n,"RegExp"),o=aa(n,"Object");let i,s;if(Ua(n)===n&&!t&&!r){if(i=Ro.get(n),i)return i;if(i=++BO+"~",Ro.set(n,i),Array.isArray(n)){for(i="@",s=0;s<n.length;s++)i+=Za(n[s])+",";Ro.set(n,i)}if(o){i="#";const l=Ua.keys(n).sort();for(;!fe(s=l.pop());)fe(n[s])||(i+=s+":"+Za(n[s])+",");Ro.set(n,i)}}else i=t?n.toJSON():e=="symbol"?n.toString():e=="string"?JSON.stringify(n):""+n;return i},su=n=>{if(Et(n))try{n=n()}catch{n=""}const e=n;return n=typeof n=="string"?n:(Array.isArray(n)?n.length:n)?Za(n):"",[n,e]};let zO=0;const Ya=()=>++zO;async function R1(...n){const[e,t,r,o]=n,i=fn({populateCache:!0,throwOnError:!0},typeof o=="boolean"?{revalidate:o}:o||{});let s=i.populateCache;const l=i.rollbackOnError;let a=i.optimisticData;const c=f=>typeof l=="function"?l(f):l!==!1,u=i.throwOnError;if(Et(t)){const f=t,p=[],m=e.keys();for(const g of m)!/^\$(inf|sub)\$/.test(g)&&f(e.get(g)._k)&&p.push(g);return Promise.all(p.map(d))}return d(t);async function d(f){const[p]=su(f);if(!p)return;const[m,g]=N1(e,p),[y,b,w,v]=Lt.get(e),S=()=>{const D=y[p];return(Et(i.revalidate)?i.revalidate(m().data,f):i.revalidate!==!1)&&(delete w[p],delete v[p],D&&D[0])?D[0](O1).then(()=>m().data):m().data};if(n.length<3)return S();let T=r,C;const I=Ya();b[p]=[I,0];const O=!fe(a),E=m(),R=E.data,_=E._c,N=fe(_)?R:_;if(O&&(a=Et(a)?a(N,R):a,g({data:a,_c:N})),Et(T))try{T=T(N)}catch(D){C=D}if(T&&A1(T))if(T=await T.catch(D=>{C=D}),I!==b[p][0]){if(C)throw C;return T}else C&&O&&c(C)&&(s=!0,g({data:N,_c:Qe}));if(s&&!C)if(Et(s)){const D=s(T,N);g({data:D,error:Qe,_c:Qe})}else g({data:T,error:Qe,_c:Qe});if(b[p][1]=Ya(),Promise.resolve(S()).then(()=>{g({_c:Qe})}),C){if(u)throw C;return}return T}}const sp=(n,e)=>{for(const t in n)n[t][0]&&n[t][0](e)},$O=(n,e)=>{if(!Lt.has(n)){const t=fn(PO,e),r={},o=R1.bind(Qe,n);let i=rn;const s={},l=(u,d)=>{const f=s[u]||[];return s[u]=f,f.push(d),()=>f.splice(f.indexOf(d),1)},a=(u,d,f)=>{n.set(u,d);const p=s[u];if(p)for(const m of p)m(d,f)},c=()=>{if(!Lt.has(n)&&(Lt.set(n,[r,{},{},{},o,a,l]),!Yr)){const u=t.initFocus(setTimeout.bind(Qe,sp.bind(Qe,r,E1))),d=t.initReconnect(setTimeout.bind(Qe,sp.bind(Qe,r,M1)));i=()=>{u&&u(),d&&d(),Lt.delete(n)}}};return c(),[n,o,c,i]}return[n,Lt.get(n)[4]]},FO=(n,e,t,r,o)=>{const i=t.errorRetryCount,s=o.retryCount,l=~~((Math.random()+.5)*(1<<(s<8?s:8)))*t.errorRetryInterval;!fe(i)&&s>i||setTimeout(r,l,o)},VO=Wa,[I1,HO]=$O(new Map),qO=fn({onLoadingSlow:rn,onSuccess:rn,onError:rn,onErrorRetry:FO,onDiscarded:rn,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:ip?1e4:5e3,focusThrottleInterval:5*1e3,dedupingInterval:2*1e3,loadingTimeout:ip?5e3:3e3,compare:VO,isPaused:()=>!1,cache:I1,mutate:HO,fallback:{}},jO),WO=(n,e)=>{const t=fn(n,e);if(e){const{use:r,fallback:o}=n,{use:i,fallback:s}=e;r&&i&&(t.use=r.concat(i)),o&&s&&(t.fallback=fn(o,s))}return t},UO=x.createContext({}),GO="$inf$",_1=io&&window.__SWR_DEVTOOLS_USE__,KO=_1?window.__SWR_DEVTOOLS_USE__:[],JO=()=>{_1&&(window.__SWR_DEVTOOLS_REACT__=x)},XO=n=>Et(n[1])?[n[0],n[1],n[2]||{}]:[n[0],null,(n[1]===null?n[2]:n[1])||{}],ZO=()=>fn(qO,x.useContext(UO)),YO=n=>(e,t,r)=>n(e,t&&((...i)=>{const[s]=su(e),[,,,l]=Lt.get(I1);if(s.startsWith(GO))return t(...i);const a=l[s];return fe(a)?t(...i):(delete l[s],a)}),r),QO=KO.concat(YO),e5=n=>function(...t){const r=ZO(),[o,i,s]=XO(t),l=WO(r,s);let a=n;const{use:c}=l,u=(c||[]).concat(QO);for(let d=u.length;d--;)a=u[d](a);return a(o,i||l.fetcher||null,l)},t5=(n,e,t)=>{const r=e[n]||(e[n]=[]);return r.push(t),()=>{const o=r.indexOf(t);o>=0&&(r[o]=r[r.length-1],r.pop())}};JO();const ca=x.use||(n=>{switch(n.status){case"pending":throw n;case"fulfilled":return n.value;case"rejected":throw n.reason;default:throw n.status="pending",n.then(e=>{n.status="fulfilled",n.value=e},e=>{n.status="rejected",n.reason=e}),n}}),ua={dedupe:!0},n5=(n,e,t)=>{const{cache:r,compare:o,suspense:i,fallbackData:s,revalidateOnMount:l,revalidateIfStale:a,refreshInterval:c,refreshWhenHidden:u,refreshWhenOffline:d,keepPreviousData:f}=t,[p,m,g,y]=Lt.get(r),[b,w]=su(n),v=x.useRef(!1),S=x.useRef(!1),T=x.useRef(b),C=x.useRef(e),I=x.useRef(t),O=()=>I.current,E=()=>O().isVisible()&&O().isOnline(),[R,_,N,D]=N1(r,b),k=x.useRef({}).current,L=fe(s)?fe(t.fallback)?Qe:t.fallback[b]:s,F=(q,se)=>{for(const oe in k){const he=oe;if(he==="data"){if(!o(q[he],se[he])&&(!fe(q[he])||!o(z,se[he])))return!1}else if(se[he]!==q[he])return!1}return!0},V=x.useMemo(()=>{const q=!b||!e?!1:fe(l)?O().isPaused()||i?!1:a!==!1:l,se=pe=>{const Ie=fn(pe);return delete Ie._k,q?{isValidating:!0,isLoading:!0,...Ie}:Ie},oe=R(),he=D(),ve=se(oe),Oe=oe===he?ve:se(he);let be=ve;return[()=>{const pe=se(R());return F(pe,be)?(be.data=pe.data,be.isLoading=pe.isLoading,be.isValidating=pe.isValidating,be.error=pe.error,be):(be=pe,pe)},()=>Oe]},[r,b]),ue=OO.useSyncExternalStore(x.useCallback(q=>N(b,(se,oe)=>{F(oe,se)||q()}),[r,b]),V[0],V[1]),J=!v.current,_e=p[b]&&p[b].length>0,de=ue.data,Me=fe(de)?L&&A1(L)?ca(L):L:de,Ne=ue.error,P=x.useRef(Me),z=f?fe(de)?fe(P.current)?Me:P.current:de:Me,re=_e&&!fe(Ne)?!1:J&&!fe(l)?l:O().isPaused()?!1:i?fe(Me)?!1:a:fe(Me)||a,ne=!!(b&&e&&J&&re),ee=fe(ue.isValidating)?ne:ue.isValidating,Q=fe(ue.isLoading)?ne:ue.isLoading,Y=x.useCallback(async q=>{const se=C.current;if(!b||!se||S.current||O().isPaused())return!1;let oe,he,ve=!0;const Oe=q||{},be=!g[b]||!Oe.dedupe,pe=()=>op?!S.current&&b===T.current&&v.current:b===T.current,Ie={isValidating:!1,isLoading:!1},pt=()=>{_(Ie)},mt=()=>{const Fe=g[b];Fe&&Fe[1]===he&&delete g[b]},bn={isValidating:!0};fe(R().data)&&(bn.isLoading=!0);try{if(be&&(_(bn),t.loadingTimeout&&fe(R().data)&&setTimeout(()=>{ve&&pe()&&O().onLoadingSlow(b,t)},t.loadingTimeout),g[b]=[se(w),Ya()]),[oe,he]=g[b],oe=await oe,be&&setTimeout(mt,t.dedupingInterval),!g[b]||g[b][1]!==he)return be&&pe()&&O().onDiscarded(b),!1;Ie.error=Qe;const Fe=m[b];if(!fe(Fe)&&(he<=Fe[0]||he<=Fe[1]||Fe[1]===0))return pt(),be&&pe()&&O().onDiscarded(b),!1;const De=R().data;Ie.data=o(De,oe)?De:oe,be&&pe()&&O().onSuccess(oe,b,t)}catch(Fe){mt();const De=O(),{shouldRetryOnError:kt}=De;De.isPaused()||(Ie.error=Fe,be&&pe()&&(De.onError(Fe,b,De),(kt===!0||Et(kt)&&kt(Fe))&&(!O().revalidateOnFocus||!O().revalidateOnReconnect||E())&&De.onErrorRetry(Fe,b,De,vn=>{const gt=p[b];gt&&gt[0]&&gt[0](np,vn)},{retryCount:(Oe.retryCount||0)+1,dedupe:!0})))}return ve=!1,pt(),!0},[b,r]),X=x.useCallback((...q)=>R1(r,T.current,...q),[]);if(sa(()=>{C.current=e,I.current=t,fe(de)||(P.current=de)}),sa(()=>{if(!b)return;const q=Y.bind(Qe,ua);let se=0;const he=t5(b,p,(ve,Oe={})=>{if(ve==E1){const be=Date.now();O().revalidateOnFocus&&be>se&&E()&&(se=be+O().focusThrottleInterval,q())}else if(ve==M1)O().revalidateOnReconnect&&E()&&q();else{if(ve==O1)return Y();if(ve==np)return Y(Oe)}});return S.current=!1,T.current=b,v.current=!0,_({_k:w}),re&&(fe(Me)||Yr?q():LO(q)),()=>{S.current=!0,he()}},[b]),sa(()=>{let q;function se(){const he=Et(c)?c(R().data):c;he&&q!==-1&&(q=setTimeout(oe,he))}function oe(){!R().error&&(u||O().isVisible())&&(d||O().isOnline())?Y(ua).then(se):se()}return se(),()=>{q&&(clearTimeout(q),q=-1)}},[c,u,d,b]),x.useDebugValue(z),i&&fe(Me)&&b){if(!op&&Yr)throw new Error("Fallback data is required when using Suspense in SSR.");C.current=e,I.current=t,S.current=!1;const q=y[b];if(!fe(q)){const se=X(q);ca(se)}if(fe(Ne)){const se=Y(ua);fe(z)||(se.status="fulfilled",se.value=!0),ca(se)}else throw Ne}return{mutate:X,get data(){return k.data=!0,z},get error(){return k.error=!0,Ne},get isValidating(){return k.isValidating=!0,ee},get isLoading(){return k.isLoading=!0,Q}}},lp=e5(n5);class r5 extends Error{constructor({message:e,status:t,data:r}){super(e),this.name="TwitterApiError",this.status=t,this.data=r}}const o5=lp.default||lp,i5="https://react-tweet.vercel.app";async function s5([n,e]){const t=await fetch(n,e),r=await t.json();if(t.ok)return r.data||null;throw new r5({message:`Failed to fetch tweet at "${n}" with "${t.status}".`,data:r,status:t.status})}const l5=(n,e,t)=>{const{isLoading:r,data:o,error:i}=o5(()=>e||n?[e||n&&`${i5}/api/tweet/${n}`,t]:null,s5,{revalidateIfStale:!1,revalidateOnFocus:!1,shouldRetryOnError:!1});return{isLoading:!!(r||o===void 0&&!i),data:o,error:i}},a5=({id:n,apiUrl:e,fallback:t=h.jsx(TO,{}),components:r,fetchOptions:o,onError:i})=>{const{data:s,error:l,isLoading:a}=l5(n,e,o);if(a)return t;if(l||!s){const c=(r==null?void 0:r.TweetNotFound)||vO;return h.jsx(c,{error:i?i(l):l})}return h.jsx(gO,{tweet:s,components:r})};function c5({node:n}){var r;const e=((r=n==null?void 0:n.attrs)==null?void 0:r.src)||"",t=e==null?void 0:e.split("/").pop();return t?h.jsx(Ht,{children:h.jsx("div",{"data-twitter":"",children:h.jsx(a5,{id:t})})}):null}function D1(n){const{t:e}=ie.useLocale(),[t,r]=x.useState("");x.useEffect(()=>{var i;if(n!=null&&n.editor){const{src:s}=(i=n.editor)==null?void 0:i.getAttributes(j1.name);s&&r(s)}},[n==null?void 0:n.editor]);function o(i){i.preventDefault(),i.stopPropagation(),n==null||n.onSetLink(t)}return h.jsx("div",{className:"border-neutral-200 rounded-lg !border bg-white p-2 shadow-sm dark:border-neutral-800 dark:bg-black",children:h.jsxs("form",{className:"flex flex-col gap-2",onSubmit:o,children:[h.jsx(cn,{className:"mb-[6px]",children:e("editor.link.dialog.text")}),h.jsx("div",{className:"mb-[10px] flex w-full max-w-sm items-center gap-1.5",children:h.jsx("div",{className:"relative w-full max-w-sm items-center",children:h.jsx(Rt,{className:"w-80",onChange:i=>r(i.target.value),placeholder:"Text",required:!0,type:"text",value:t})})}),h.jsx(Be,{className:"mt-2 self-end",type:"submit",children:e("editor.link.dialog.button.apply")})]})})}function u5(n){function e(t){n.action&&n.action(t)}return h.jsxs(zn,{modal:!0,children:[h.jsx($n,{disabled:n==null?void 0:n.disabled,asChild:!0,children:h.jsx(at,{tooltip:n==null?void 0:n.tooltip,isActive:n==null?void 0:n.isActive,disabled:n==null?void 0:n.disabled,children:h.jsx(Dn,{name:n==null?void 0:n.icon})})}),h.jsx(mn,{hideWhenDetached:!0,className:"w-full",align:"start",side:"bottom",children:h.jsx(D1,{editor:n.editor,onSetLink:e})})]})}const d5=/(https?:\/\/)?(www\.)?x\.com\/(\w{1,15})(\/status\/(\d+))?(\/\S*)?/g,f5=/^https?:\/\/(www\.)?x\.com\/(\w{1,15})(\/status\/(\d+))?(\/\S*)?$/;function ap(n){return n.match(f5)}const j1=Je.create({name:"twitter",draggable:!0,selectable:!0,addOptions(){return{addPasteHandler:!0,HTMLAttributes:{},inline:!1,origin:"",button:({editor:n,t:e})=>({component:u5,componentProps:{action:t=>{n.commands.setTweet({src:t})},isActive:()=>!1,disabled:!1,icon:"Twitter",tooltip:e("editor.twitter.tooltip"),editor:n}})}},addNodeView(){return qt(c5,{attrs:this.options.HTMLAttributes})},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},addAttributes(){return{src:{default:null}}},parseHTML(){return[{tag:"div[data-twitter]"}]},addCommands(){return{setTweet:n=>({commands:e})=>ap(n.src)?e.insertContent({type:this.name,attrs:n}):!1,updateTweet:n=>({commands:e})=>ap(n.src)?e.updateAttributes(this.name,{src:n.src}):!1}},addPasteRules(){return this.options.addPasteHandler?[uw({find:d5,type:this.type,getAttributes:n=>({src:n.input})})]:[]},renderHTML({HTMLAttributes:n}){return["div",Ue({"data-twitter":""},n)]}}),h5="_wrapper_rraz2_1",p5="_tool_rraz2_17",m5="_active_rraz2_37",g5="_pen_rraz2_41",y5="_line_rraz2_48",b5="_options_rraz2_56",v5="_colorWrap_rraz2_66",x5="_color_rraz2_66",w5="_colorActive_rraz2_83",W={wrapper:h5,tool:p5,active:m5,pen:g5,line:y5,options:b5,colorWrap:v5,color:x5,colorActive:w5};function S5(n){return h.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...n,children:h.jsx("path",{color:"currentColor",d:"M2 9.2v3.6M12.8 2H9.2M7.5 20H9M20 7.5V9M2.133 4.699c.155-.727.415-1.274.854-1.712c.426-.426.954-.684 1.652-.84m15.228 2.552c-.155-.727-.415-1.274-.854-1.712c-.417-.417-.932-.673-1.608-.83M4.64 19.853c-.698-.156-1.226-.414-1.652-.84c-.43-.43-.69-.965-.845-1.673m11.638 3.626c-1.812.125-3.607-8.326-2.374-9.559s9.684.561 9.559 2.373c-.087 1.187-2.095 1.656-2.037 2.711c.018.309.408.59 1.188 1.154c.543.39 1.096.77 1.629 1.175a.66.66 0 0 1 .234.687a3.35 3.35 0 0 1-2.472 2.473a.66.66 0 0 1-.688-.235c-.404-.533-.784-1.086-1.175-1.628c-.563-.78-.844-1.17-1.153-1.188c-1.055-.059-1.524 1.95-2.71 2.037",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5"})})}function C5(n){return h.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...n,children:h.jsx("path",{d:"M20.06 18a4 4 0 0 1-.2-.89c-.67.7-1.48 1.05-2.41 1.05c-.83 0-1.52-.24-2.05-.71c-.53-.45-.8-1.06-.8-1.79c0-.88.33-1.56 1-2.05s1.61-.73 2.83-.73h1.4v-.64q0-.735-.45-1.17c-.3-.29-.75-.43-1.33-.43c-.52 0-.95.12-1.3.36c-.35.25-.52.54-.52.89h-1.46c0-.43.15-.84.45-1.24c.28-.4.71-.71 1.22-.94c.51-.21 1.06-.35 1.69-.35c.98 0 1.74.24 2.29.73s.84 1.16.86 2.02V16c0 .8.1 1.42.3 1.88V18zm-2.4-1.12c.45 0 .88-.11 1.29-.32c.4-.21.7-.49.88-.83v-1.57H18.7c-1.77 0-2.66.47-2.66 1.41c0 .43.15.73.46.96c.3.23.68.35 1.16.35m-12.2-3.17h4.07L7.5 8.29zM6.64 6h1.72l4.71 12h-1.93l-.97-2.57H4.82L3.86 18H1.93z",fill:"currentColor"})})}function T5(n){return h.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...n,children:h.jsx("path",{d:"M3 21v-4.25L16.2 3.575q.3-.275.663-.425t.762-.15t.775.15t.65.45L20.425 5q.3.275.438.65T21 6.4q0 .4-.137.763t-.438.662L7.25 21zM17.6 7.8L19 6.4L17.6 5l-1.4 1.4z",fill:"currentColor"})})}function k5(n){return h.jsx("svg",{height:"1em",viewBox:"0 0 256 256",width:"1em",xmlns:"http://www.w3.org/2000/svg",...n,children:h.jsx("path",{d:"M253.66 106.34a8 8 0 0 0-11.32 0L192 156.69L107.31 72l50.35-50.34a8 8 0 1 0-11.32-11.32L96 60.69a16 16 0 0 0-2.82 18.81L72 100.69a16 16 0 0 0 0 22.62l4.69 4.69l-58.35 58.34a8 8 0 0 0 3.13 13.25l72 24A7.9 7.9 0 0 0 96 224a8 8 0 0 0 5.66-2.34L136 187.31l4.69 4.69a16 16 0 0 0 22.62 0l21.19-21.18a16 16 0 0 0 18.81-2.82l50.35-50.34a8 8 0 0 0 0-11.32M93.84 206.85l-55-18.35L88 139.31L124.69 176ZM152 180.69L83.31 112L104 91.31L172.69 160Z",fill:"currentColor"})})}function E5(n){return h.jsxs("svg",{height:"1em",viewBox:"0 0 16 16",width:"1em",xmlns:"http://www.w3.org/2000/svg",...n,children:[h.jsx("path",{d:"m2.648 9.937l7.29-7.288a2.21 2.21 0 0 1 3.124 0l2.29 2.288a2.21 2.21 0 0 1 0 3.126L10.413 13H12.5a.5.5 0 0 1 0 1H4.501a2.2 2.2 0 0 1-1.563-.647l.707-.707c.227.226.535.354.856.354h4.005a1.2 1.2 0 0 0 .848-.354l1.292-1.293l-4-4l-3.29 3.291a1.21 1.21 0 0 0 0 1.712l.29.29l-.708.707l-.29-.29a2.21 2.21 0 0 1 0-3.126M8 6h6.89a1.2 1.2 0 0 0-.246-.356L14 5H9zm2-2h3l-.645-.644a1.21 1.21 0 0 0-1.71 0zm4.89 3H7.708l1 1H14l.644-.644A1.2 1.2 0 0 0 14.891 7zM9.708 9l1.646 1.646L13 9z",fill:"currentColor"}),h.jsx("path",{d:"M14 11.5a.5.5 0 1 1-1 0a.5.5 0 0 1 1 0m1.5-.5a.5.5 0 1 0 0-1a.5.5 0 0 0 0 1m-1 2a.5.5 0 0 0 0 1h1a.5.5 0 0 0 0-1z",fill:"currentColor"})]})}function M5(n){return h.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...n,children:h.jsx("path",{d:"M3 3h18v18H3zm2 2v14h14V5z",fill:"currentColor"})})}function O5(n){return h.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...n,children:h.jsx("path",{d:"M2 20V4h20v16zm2-2h16V6H4zm0 0V6z",fill:"currentColor"})})}function A5(n){return h.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...n,children:h.jsx("path",{d:"M12 22q-2.075 0-3.9-.788t-3.175-2.137T2.788 15.9T2 12t.788-3.9t2.137-3.175T8.1 2.788T12 2t3.9.788t3.175 2.137T21.213 8.1T22 12t-.788 3.9t-2.137 3.175t-3.175 2.138T12 22m0-2q3.35 0 5.675-2.325T20 12t-2.325-5.675T12 4T6.325 6.325T4 12t2.325 5.675T12 20m0-8",fill:"currentColor"})})}function N5(n){return h.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...n,children:h.jsx("path",{d:"M10.363 3.591L2.257 17.125a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636-2.87L13.637 3.59a1.914 1.914 0 0 0-3.274 0z",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2"})})}function R5(n){return h.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...n,children:h.jsx("path",{d:"m6.8 21l-5.2-9l5.2-9h10.4l5.2 9l-5.2 9zm1.15-2h8.1l4.025-7l-4.025-7h-8.1L3.9 12zM12 12",fill:"currentColor"})})}function I5(n){return h.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...n,children:h.jsxs("g",{fill:"none",fillRule:"evenodd",children:[h.jsx("path",{d:"m12.594 23.258l-.012.002l-.071.035l-.02.004l-.014-.004l-.071-.036q-.016-.004-.024.006l-.004.01l-.017.428l.005.02l.01.013l.104.074l.015.004l.012-.004l.104-.074l.012-.016l.004-.017l-.017-.427q-.004-.016-.016-.018m.264-.113l-.014.002l-.184.093l-.01.01l-.003.011l.018.43l.005.012l.008.008l.201.092q.019.005.029-.008l.004-.014l-.034-.614q-.005-.019-.02-.022m-.715.002a.02.02 0 0 0-.027.006l-.006.014l-.034.614q.001.018.017.024l.015-.002l.201-.093l.01-.008l.003-.011l.018-.43l-.003-.012l-.01-.01z"}),h.jsx("path",{d:"M10.586 2.807a2 2 0 0 1 2.828 0l7.778 7.779a2 2 0 0 1 0 2.828l-7.778 7.778a2 2 0 0 1-2.828 0l-7.778-7.778a2 2 0 0 1 0-2.828zM12 4.222L4.222 12L12 19.778L19.778 12z",fill:"currentColor"})]})})}function _5(n){return h.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...n,children:h.jsx("path",{d:"M16.01 11H4v2h12.01v3L20 12l-3.99-4z",fill:"currentColor"})})}function D5(n){return h.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...n,children:h.jsx("path",{clipRule:"evenodd",d:"M7.53 3.47a.75.75 0 0 1 0 1.06L5.81 6.25H15a5.75 5.75 0 0 1 0 11.5H8a.75.75 0 0 1 0-1.5h7a4.25 4.25 0 0 0 0-8.5H5.81l1.72 1.72a.75.75 0 1 1-1.06 1.06l-3-3a.75.75 0 0 1 0-1.06l3-3a.75.75 0 0 1 1.06 0",fill:"currentColor",fillRule:"evenodd"})})}function j5(n){return h.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...n,children:h.jsx("path",{clipRule:"evenodd",d:"M16.47 3.47a.75.75 0 0 1 1.06 0l3 3a.75.75 0 0 1 0 1.06l-3 3a.75.75 0 1 1-1.06-1.06l1.72-1.72H9a4.25 4.25 0 0 0 0 8.5h7a.75.75 0 0 1 0 1.5H9a5.75 5.75 0 0 1 0-11.5h9.19l-1.72-1.72a.75.75 0 0 1 0-1.06",fill:"currentColor",fillRule:"evenodd"})})}function P5(n){return h.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...n,children:h.jsx("path",{d:"M7 21q-.825 0-1.412-.587T5 19V6H4V4h5V3h6v1h5v2h-1v13q0 .825-.587 1.413T17 21zm2-4h2V8H9zm4 0h2V8h-2z",fill:"currentColor"})})}function L5(n){return h.jsx("svg",{height:"1em",viewBox:"0 0 256 256",width:"1em",xmlns:"http://www.w3.org/2000/svg",...n,children:h.jsx("path",{d:"M211.81 83.79a28 28 0 0 1-33.12 4.83l-90.07 90.07a28 28 0 1 1-44.43-6.48a28 28 0 0 1 33.12-4.83l90.07-90.07a28 28 0 1 1 44.43 6.48",fill:"currentColor"})})}function B5(n){return h.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...n,children:h.jsx("path",{d:"M12 20.325q-.35 0-.712-.125t-.638-.4l-1.725-1.575q-2.65-2.425-4.788-4.812T2 8.15Q2 5.8 3.575 4.225T7.5 2.65q1.325 0 2.5.562t2 1.538q.825-.975 2-1.537t2.5-.563q2.35 0 3.925 1.575T22 8.15q0 2.875-2.125 5.275T15.05 18.25l-1.7 1.55q-.275.275-.637.4t-.713.125M11.05 6.75q-.725-1.025-1.55-1.563t-2-.537q-1.5 0-2.5 1t-1 2.5q0 1.3.925 2.763t2.213 2.837t2.65 2.575T12 18.3q.85-.775 2.213-1.975t2.65-2.575t2.212-2.837T20 8.15q0-1.5-1-2.5t-2.5-1q-1.175 0-2 .538T12.95 6.75q-.175.25-.425.375T12 7.25t-.525-.125t-.425-.375m.95 4.725",fill:"currentColor"})})}function z5(n){return h.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...n,children:h.jsx("path",{d:"m7.625 6.4l2.8-3.625q.3-.4.713-.587T12 2t.863.188t.712.587l2.8 3.625l4.25 1.425q.65.2 1.025.738t.375 1.187q0 .3-.088.6t-.287.575l-2.75 3.9l.1 4.1q.025.875-.575 1.475t-1.4.6q-.05 0-.55-.075L12 19.675l-4.475 1.25q-.125.05-.275.063T6.975 21q-.8 0-1.4-.6T5 18.925l.1-4.125l-2.725-3.875q-.2-.275-.288-.575T2 9.75q0-.625.363-1.162t1.012-.763zM8.85 8.125L4 9.725L7.1 14.2L7 18.975l5-1.375l5 1.4l-.1-4.8L20 9.775l-4.85-1.65L12 4zM12 11.5",fill:"currentColor"})})}function $5(n){return h.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...n,children:h.jsx("path",{d:"M12.01 6c2.61 0 4.89 1.86 5.4 4.43l.3 1.5l1.52.11c1.56.11 2.78 1.41 2.78 2.96c0 1.65-1.35 3-3 3h-13c-2.21 0-4-1.79-4-4c0-2.05 1.53-3.76 3.56-3.97l1.07-.11l.5-.95A5.46 5.46 0 0 1 12.01 6m0-2C9.12 4 6.6 5.64 5.35 8.04C2.35 8.36.01 10.91.01 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5c0-2.64-2.05-4.78-4.64-4.96C18.68 6.59 15.65 4 12.01 4",fill:"currentColor"})})}function F5(n){return h.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...n,children:h.jsx("path",{d:"M5.586 6.45A2 2 0 0 1 7.509 5h11.84a2 2 0 0 1 1.923 2.55l-2.858 10A2 2 0 0 1 16.491 19H4.651a2 2 0 0 1-1.923-2.55z",fill:"none",stroke:"currentColor",strokeWidth:"2"})})}const V5=[Ee.Color4.blackHighlight,Ee.Color4.ofRGBA(166/255,81/255,167/255,.3),Ee.Color4.ofRGBA(247/255,78/255,158/255,.3),Ee.Color4.ofRGBA(166/255,83/255,88/255,.3),Ee.Color4.ofRGBA(246/255,130/255,28/255,.3),Ee.Color4.ofRGBA(166/255,198/255,0,.3),Ee.Color4.ofRGBA(98/255,186/255,70/255,.3)],cp=[Ee.Color4.black,Ee.Color4.fromHex("#007AFF"),Ee.Color4.fromHex("#A651A7"),Ee.Color4.fromHex("#F74E9E"),Ee.Color4.fromHex("#FF5358"),Ee.Color4.fromHex("#F6821C"),Ee.Color4.fromHex("#FFC600"),Ee.Color4.fromHex("#62BA46"),Ee.Color4.fromHex("#E6BFE8"),Ee.Color4.fromHex("#FEA3D2"),Ee.Color4.fromHex("#FFA0A3"),Ee.Color4.fromHex("#FBC276"),Ee.Color4.fromHex("#FFFB85"),Ee.Color4.fromHex("#AADC99")];function H5({onChange:n}){const[e,t]=x.useState(Ee.Color4.blackHighlight);return h.jsx("div",{className:W.colorWrap,children:V5.map((r,o)=>h.jsx("button",{style:{backgroundColor:r.toHexString()},className:U(W.color,{[W.colorActive]:e.toHexString()===r.toHexString()}),onClick:()=>{t(r),n(r)}},o))})}function Qa({onChange:n}){const[e,t]=x.useState(Ee.Color4.black);return h.jsxs(h.Fragment,{children:[h.jsx("div",{className:W.colorWrap,children:cp.slice(0,7).map((r,o)=>h.jsx("button",{style:{backgroundColor:r.toHexString()},className:U(W.color,{[W.colorActive]:e.toHexString()===r.toHexString()}),onClick:()=>{t(r),n(r)}},o))}),h.jsx("div",{className:W.colorWrap,children:cp.slice(7).map((r,o)=>h.jsx("button",{style:{backgroundColor:r.toHexString()},className:U(W.color,{[W.colorActive]:e.toHexString()===r.toHexString()}),onClick:()=>{t(r),n(r)}},o))})]})}function q5({setColorPen:n,setThicknessPen:e}){const[t,r]=x.useState(2);return h.jsxs("div",{className:W.options,children:[h.jsx("div",{children:h.jsx(Qa,{onChange:o=>n(o)})}),h.jsx("div",{className:W.line}),h.jsx("div",{children:h.jsx("input",{max:10,min:1,step:.1,type:"range",value:t,onChange:o=>{e(Number.parseFloat(o.target.value)),r(Number.parseFloat(o.target.value))}})})]})}function W5({setColorHighlight:n}){return h.jsx("div",{className:W.options,children:h.jsx(H5,{onChange:e=>n(e)})})}function U5({changeColorShape:n,changeBorderColorShape:e,onThicknessChange:t}){return h.jsxs("div",{className:W.options,children:[h.jsx("div",{children:h.jsx(Qa,{onChange:r=>n(r)})}),h.jsx("div",{className:W.line}),h.jsx("div",{children:h.jsx(Qa,{onChange:r=>e(r)})}),h.jsx("div",{className:W.line}),h.jsx("div",{children:h.jsx("input",{defaultValue:0,max:20,min:0,step:1,type:"range",onChange:r=>{t(Number.parseFloat(r.target.value))}})})]})}function P1(n){const{setColorPen:e,refEditor:t,setThicknessPen:r,setColorHighlight:o,changeBorderColorShape:i,onUndo:s,changeColorShape:l,changeShape:a,onThicknessChange:c,onRedo:u,onClear:d}=n,[f,p]=x.useState(null),[m,g]=x.useState(0);return h.jsx(h.Fragment,{children:h.jsxs("div",{className:W.wrapper,children:[h.jsxs("div",{className:W.pen,children:[h.jsx("button",{className:U(W.tool,{[W.active]:f==="select"}),onClick:()=>{const y=t.current.toolController.getPrimaryTools();if(f==="select"){p(null),y[0].setEnabled(!1);return}p("select"),y[0].setEnabled(!0)},children:h.jsx(S5,{})}),h.jsx("div",{className:W.line}),h.jsx("button",{className:U(W.tool,{[W.active]:f==="text"}),onClick:()=>{const y=t.current.toolController.getPrimaryTools();if(t.current.toolController.setToolEnabled(y[1]),f==="text"){y[1].setEnabled(!1),p(null);return}p("text"),y[1].setEnabled(!0)},children:h.jsx(C5,{})}),h.jsx("div",{className:W.line}),h.jsx("button",{className:U(W.tool,{[W.active]:f==="pencil"}),onClick:()=>{const y=t.current.toolController.getPrimaryTools();if(f==="pencil"){p(null),y[2].setEnabled(!1);return}p("pencil"),y[2].setEnabled(!0)},children:h.jsx(T5,{})}),h.jsx("button",{className:U(W.tool,{[W.active]:f==="highlighter"}),onClick:()=>{const y=t.current.toolController.getPrimaryTools();if(f==="highlighter"){p(null),y[3].setEnabled(!1);return}p("highlighter"),y[3].setEnabled(!0)},children:h.jsx(k5,{})}),h.jsx("div",{className:W.line}),h.jsx("button",{className:U(W.tool,{[W.active]:f==="eraser"}),onClick:()=>{const y=t.current.toolController.getPrimaryTools();if(f==="eraser"){p(null),y[4].setEnabled(!1);return}p("eraser"),y[4].setEnabled(!0)},children:h.jsx(E5,{})}),h.jsx("div",{className:W.line}),h.jsx("button",{className:U(W.tool,{[W.active]:f==="shapes"&&m===0}),onClick:()=>{const y=t.current.toolController.getPrimaryTools();t.current.toolController.setToolEnabled(y[5]),p("shapes"),y[5].setEnabled(!0),a(0),g(0)},children:h.jsx(M5,{})}),h.jsx("button",{className:U(W.tool,{[W.active]:f==="shapes"&&m===1}),onClick:()=>{const y=t.current.toolController.getPrimaryTools();t.current.toolController.setToolEnabled(y[5]),p("shapes"),y[5].setEnabled(!0),a(1),g(1)},children:h.jsx(O5,{})}),h.jsx("button",{className:U(W.tool,{[W.active]:f==="shapes"&&m===2}),onClick:()=>{const y=t.current.toolController.getPrimaryTools();t.current.toolController.setToolEnabled(y[5]),p("shapes"),y[5].setEnabled(!0),a(2),g(2)},children:h.jsx(A5,{})}),h.jsx("button",{className:U(W.tool,{[W.active]:f==="shapes"&&m===3}),onClick:()=>{const y=t.current.toolController.getPrimaryTools();t.current.toolController.setToolEnabled(y[5]),p("shapes"),y[5].setEnabled(!0),a(3),g(3)},children:h.jsx(N5,{})}),h.jsx("button",{className:U(W.tool,{[W.active]:f==="shapes"&&m===4}),onClick:()=>{const y=t.current.toolController.getPrimaryTools();t.current.toolController.setToolEnabled(y[5]),p("shapes"),y[5].setEnabled(!0),a(4),g(4)},children:h.jsx(R5,{})}),h.jsx("button",{className:U(W.tool,{[W.active]:f==="shapes"&&m===5}),onClick:()=>{const y=t.current.toolController.getPrimaryTools();t.current.toolController.setToolEnabled(y[5]),p("shapes"),y[5].setEnabled(!0),a(5),g(5)},children:h.jsx(I5,{})}),h.jsx("button",{className:U(W.tool,{[W.active]:f==="shapes"&&m===6}),onClick:()=>{const y=t.current.toolController.getPrimaryTools();t.current.toolController.setToolEnabled(y[5]),p("shapes"),y[5].setEnabled(!0),a(6),g(6)},children:h.jsx(_5,{})}),h.jsx("button",{className:U(W.tool,{[W.active]:f==="shapes"&&m===7}),onClick:()=>{const y=t.current.toolController.getPrimaryTools();t.current.toolController.setToolEnabled(y[5]),p("shapes"),y[5].setEnabled(!0),a(7),g(7)},children:h.jsx(L5,{})}),h.jsx("button",{className:U(W.tool,{[W.active]:f==="shapes"&&m===8}),onClick:()=>{const y=t.current.toolController.getPrimaryTools();t.current.toolController.setToolEnabled(y[5]),p("shapes"),y[5].setEnabled(!0),a(8),g(8)},children:h.jsx(B5,{})}),h.jsx("button",{className:U(W.tool,{[W.active]:f==="shapes"&&m===9}),onClick:()=>{const y=t.current.toolController.getPrimaryTools();t.current.toolController.setToolEnabled(y[5]),p("shapes"),y[5].setEnabled(!0),a(9),g(9)},children:h.jsx(z5,{})}),h.jsx("button",{className:U(W.tool,{[W.active]:f==="shapes"&&m===10}),onClick:()=>{const y=t.current.toolController.getPrimaryTools();t.current.toolController.setToolEnabled(y[5]),p("shapes"),y[5].setEnabled(!0),a(10),g(10)},children:h.jsx($5,{})}),h.jsx("button",{className:U(W.tool,{[W.active]:f==="shapes"&&m===11}),onClick:()=>{const y=t.current.toolController.getPrimaryTools();t.current.toolController.setToolEnabled(y[5]),p("shapes"),y[5].setEnabled(!0),a(11),g(11)},children:h.jsx(F5,{})}),h.jsx("div",{className:W.line}),h.jsx("button",{className:U(W.tool),onClick:s,children:h.jsx(D5,{})}),h.jsx("button",{className:U(W.tool),onClick:u,children:h.jsx(j5,{})}),h.jsx("button",{className:U(W.tool),onClick:d,children:h.jsx(P5,{})})]}),h.jsxs("div",{className:W.optionsWrap,children:[f==="pencil"&&h.jsx(q5,{setColorPen:e,setThicknessPen:r}),f==="highlighter"&&h.jsx(W5,{setColorHighlight:o}),f==="shapes"&&h.jsx(U5,{changeBorderColorShape:i,changeColorShape:l,changeShape:a,onThicknessChange:c})]})]})})}let Er=!1;const G5=({editor:n,upload:e})=>{const[t,r]=x.useState(!1),o=x.useRef(null),i=x.useRef(null),s=()=>{(async()=>{const v=document.querySelector("#easydrawer");v&&(o.current=new Ee.Editor(v,{wheelEventsEnabled:!1,disableZoom:!0}),i.current=Ee.makeDropdownToolbar(o.current),i.current.addDefaultToolWidgets())})()};x.useEffect(()=>{t&&setTimeout(()=>{s()},200)},[t]);const l=async()=>{if(o.current){const w=o.current.toSVG(),v=w.outerHTML,S=`drawer-${nu()}.svg`;let T=tu(w.outerHTML);if(e){const C=ki(T,S);T=await e(C)}n==null||n.chain().focus().setDrawer({type:"drawer",src:T,alt:encodeURIComponent(v),width:426,height:212},!!v).run()}r(!1)},a=w=>{const v=o.current.toolController.getPrimaryTools()[2],S=i.current.getWidgetById("pen-1");v&&S&&(v.setColor(w),S.serializeState())},c=w=>{const v=o.current.toolController.getPrimaryTools()[2],S=i.current.getWidgetById("pen-1");v&&S&&(v.setThickness(w),S.serializeState())},u=w=>{const v=o.current.toolController.getPrimaryTools()[3],S=i.current.getWidgetById("pen-2");v&&S&&(v.setColor(w),S.serializeState())},d=w=>{const v=i.current.getWidgetById("shape");v&&v.setShapeType(w)},f=w=>{const v=o.current.toolController.getPrimaryTools()[5],S=i.current.getWidgetById("shape");v&&S&&(v.setColor(w),S.serializeState())},p=w=>{const v=o.current.toolController.getPrimaryTools()[5],S=i.current.getWidgetById("shape");v&&S&&(v.setThickness(w),S.serializeState())},m=w=>{const v=o.current.toolController.getPrimaryTools()[5],S=i.current.getWidgetById("shape");v&&S&&(v.setBorderColor(w),S.serializeState())},g=()=>{if(Er){for(;o.current.history.redoStackSize>0;)o.current.history.redo();Er=!1;return}o.current.history.undo()},y=()=>{Er||o.current.history.redo()},b=()=>{if(!Er){for(;o.current.history.undoStackSize>0;)g();Er=!0}};return h.jsxs(Fn,{onOpenChange:r,open:t,children:[h.jsx(Vn,{asChild:!0,children:h.jsx(at,{action:()=>r(!0),icon:"PencilRuler",tooltip:"Drawer"})}),h.jsxs(gn,{className:"z-[99999] !max-w-[1300px]",children:[h.jsx(yn,{children:"Drawer"}),h.jsxs("div",{style:{height:"600px",width:"100%",borderWidth:1,background:"white",position:"relative"},children:[h.jsx("div",{className:"size-full",id:"easydrawer"}),h.jsx(P1,{changeBorderColorShape:m,changeColorShape:f,changeShape:d,onClear:b,onRedo:y,onThicknessChange:p,onUndo:g,refEditor:o,setColorHighlight:u,setColorPen:a,setThicknessPen:c})]}),h.jsx(mr,{children:h.jsx(Be,{onClick:l,type:"button",children:"Save changes"})})]})]})},Io={TOP_LEFT:"tl",TOP_RIGHT:"tr",BOTTOM_LEFT:"bl",BOTTOM_RIGHT:"br"};function K5({editor:n,node:e,updateAttributes:t,getPos:r,selected:o}){const[i,s]=x.useState({width:ie.IMAGE_MAX_SIZE,height:ie.IMAGE_MAX_SIZE}),[l,a]=x.useState({width:0,height:0}),[c]=x.useState([Io.TOP_LEFT,Io.TOP_RIGHT,Io.BOTTOM_LEFT,Io.BOTTOM_RIGHT]),[u,d]=x.useState(!1),[f,p]=x.useState({x:0,y:0,w:0,h:0,dir:""}),{align:m}=e==null?void 0:e.attrs,g=x.useMemo(()=>{const{src:R,alt:_,width:N,height:D}=e==null?void 0:e.attrs,k=qr(N)?`${N}px`:N,L=qr(D)?`${D}px`:D;return{src:R||void 0,alt:_||void 0,style:{width:k||void 0,height:L||void 0}}},[e==null?void 0:e.attrs]),y=x.useMemo(()=>{const{style:{width:R}}=g;return{width:R==="100%"?R:void 0}},[g]);function b(R){a({width:R.target.width,height:R.target.height})}function w(){n.commands.setNodeSelection(r())}const v=x.useCallback(Vt(()=>{const{width:R}=getComputedStyle(n.view.dom);s(_=>({..._,width:Number.parseInt(R,10)}))},ie.IMAGE_THROTTLE_WAIT_TIME),[n]);function S(R,_){R.preventDefault(),R.stopPropagation();const N=l.width,D=l.height,k=N/D;let L=Number(e.attrs.width),F=Number(e.attrs.height);const V=i.width;L&&!F?(L=L>V?V:L,F=Math.round(L/k)):F&&!L?(L=Math.round(F*k),L=L>V?V:L):!L&&!F?(L=N>V?V:N,F=Math.round(L/k)):L=L>V?V:L,d(!0),p({x:R.clientX,y:R.clientY,w:L,h:F,dir:_})}const T=x.useCallback(Vt(R=>{if(R.preventDefault(),R.stopPropagation(),!u)return;const{x:_,w:N,dir:D}=f,k=(R.clientX-_)*(/l/.test(D)?-1:1),{width:L,height:F}=e==null?void 0:e.attrs,V=L/F,ue=Ac(N+k,ie.IMAGE_MIN_SIZE,i.width),J=Math.round(ue/V);t({width:ue,height:J})},ie.IMAGE_THROTTLE_WAIT_TIME),[u,f,i,t,e==null?void 0:e.attrs]),C=x.useCallback(R=>{R.preventDefault(),R.stopPropagation(),u&&(p({x:0,y:0,w:0,h:0,dir:""}),d(!1),w())},[u,w]),I=x.useCallback(()=>{document==null||document.addEventListener("mousemove",T,!0),document==null||document.addEventListener("mouseup",C,!0)},[T,C]),O=x.useCallback(()=>{document==null||document.removeEventListener("mousemove",T,!0),document==null||document.removeEventListener("mouseup",C,!0)},[T,C]);x.useEffect(()=>(u?I():O(),()=>{O()}),[u,I,O]);const E=x.useMemo(()=>new ResizeObserver(()=>v()),[v]);return x.useEffect(()=>(E.observe(n.view.dom),()=>{E.disconnect()}),[n.view.dom,E]),h.jsx(Ht,{className:"image-view",style:{...y,width:"100%",textAlign:m},children:h.jsxs("div",{"data-drag-handle":!0,draggable:"true",style:{...y,background:"#fff"},className:`image-view__body ${o?"image-view__body--focused":""} ${u?"image-view__body--resizing":""}`,children:[h.jsx("img",{alt:g.alt,className:"image-view__body__image block",height:"auto",onClick:w,onLoad:b,src:g.src,style:g.style}),n.view.editable&&(o||u)&&h.jsx("div",{className:"image-resizer",children:c==null?void 0:c.map(R=>h.jsx("span",{className:`image-resizer__handler image-resizer__handler--${R}`,onMouseDown:_=>S(_,R)},`image-dir-${R}`))})]})})}const J5=Ti.extend({name:"drawer",addOptions(){var n;return{...(n=this.parent)==null?void 0:n.call(this),inline:!1,content:"",marks:"",group:"block",draggable:!1,selectable:!0,atom:!0,HTMLAttributes:{class:"drawer"},button:({editor:e,t,extension:r})=>{var o;return{component:G5,componentProps:{action:()=>!0,isActive:()=>!1,disabled:!1,editor:e,icon:"PencilRuler",tooltip:t("editor.drawer.tooltip"),upload:(o=r==null?void 0:r.options)==null?void 0:o.upload}}}}},addAttributes(){var n;return{...(n=this.parent)==null?void 0:n.call(this),width:{default:null,parseHTML:e=>{const t=e.querySelector("img"),r=t==null?void 0:t.getAttribute("width");return r?Number.parseInt(r,10):320},renderHTML:e=>({width:e.width})},height:{default:null,parseHTML:e=>{const t=e.querySelector("img"),r=t==null?void 0:t.getAttribute("height");return r?Number.parseInt(r,10):212},renderHTML:e=>({height:e.height})},align:{default:"center",parseHTML:e=>e.getAttribute("align"),renderHTML:e=>({align:e.align})}}},addNodeView(){return qt(K5)},addCommands(){return{setDrawer:(n,e)=>({commands:t,editor:r})=>e?t.insertContent({type:this.name,attrs:n}):t.insertContentAt(r.state.selection.anchor,{type:this.name,attrs:n}),setAlignImageDrawer:n=>({commands:e})=>e.updateAttributes(this.name,{align:n})}},renderHTML({HTMLAttributes:n}){const{align:e}=n;return["div",{style:e?`text-align: ${e};`:"",class:"imageDrawer"},["img",Ue(this.options.HTMLAttributes,n)]]},parseHTML(){return[{tag:"div[class=imageDrawer]",getAttrs:n=>{const e=n.querySelector("img"),t=e==null?void 0:e.getAttribute("width"),r=e==null?void 0:e.getAttribute("height");return{src:e==null?void 0:e.getAttribute("src"),alt:e==null?void 0:e.getAttribute("alt"),width:t?Number.parseInt(t,10):null,height:r?Number.parseInt(r,10):null,align:(e==null?void 0:e.getAttribute("align"))||n.style.textAlign||null}}}]}});function up(){return h.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",children:h.jsx("path",{fill:"currentColor",d:"M18 14c0-4-6-10.8-6-10.8s-1.33 1.51-2.73 3.52l8.59 8.59c.09-.42.14-.86.14-1.31m-.88 3.12L12.5 12.5L5.27 5.27L4 6.55l3.32 3.32C6.55 11.32 6 12.79 6 14c0 3.31 2.69 6 6 6c1.52 0 2.9-.57 3.96-1.5l2.63 2.63l1.27-1.27z"})})}function L1(n){const{t:e}=ie.useLocale(),{highlight:t=!1,disabled:r=!1,selectedColor:o,setSelectedColor:i,onChange:s,colors:l=ie.COLORS_LIST}=n,a=x.useMemo(()=>{const p=l,m=[];for(let g=0;g<p.length;g+=10)m.push(p.slice(g,g+10));return m},[l]),[c,u]=x.useState([]),d=p=>{const m=[...c],g=m.indexOf(p);g!==-1&&m.splice(g,1),m.unshift(p),m.length>10&&m.pop(),u(m)};function f(p){if(p===void 0){i==null||i(p),s==null||s(p);return}/^#([\da-f]{3}){1,2}$/i.test(p)&&(i==null||i(p),s==null||s(p),d(p))}return h.jsxs(zn,{modal:!0,children:[h.jsx($n,{asChild:!0,className:"!p-0",disabled:r,children:n==null?void 0:n.children}),h.jsx(mn,{align:"start",className:"size-full p-2",hideWhenDetached:!0,side:"bottom",children:h.jsxs("div",{className:"flex flex-col",children:[t?h.jsxs("div",{className:"rd-1 flex cursor-pointer items-center gap-[4px] p-1 hover:bg-accent",onClick:()=>f(void 0),children:[h.jsx(up,{}),h.jsx("span",{className:"ml-1 text-sm",children:e("editor.nofill")})]}):h.jsxs("div",{className:"rd-1 flex cursor-pointer items-center gap-[4px] p-1 hover:bg-accent",onClick:()=>{f(void 0)},children:[h.jsx(up,{}),h.jsx("span",{className:"ml-1 text-sm",children:e("editor.default")})]}),a.map((p,m)=>h.jsx("span",{className:"relative flex h-auto w-full p-0 last:pb-2",children:p.map((g,y)=>h.jsx("span",{className:"inline-block size-6 flex-[0_0_auto] cursor-pointer rounded-sm !border border-transparent p-0.5 hover:border-border hover:shadow-sm",onClick:()=>f(g),children:h.jsx("span",{className:"relative block size-[18px] rounded-[2px] border-transparent",style:{backgroundColor:g},children:g===o?h.jsx("svg",{className:"absolute -top-px left-px block size-3",viewBox:"0 0 18 18",style:{fill:"rgb(255, 255, 255)"},children:h.jsx("path",{d:"M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"})}):h.jsx("svg",{viewBox:"0 0 18 18",style:{fill:"rgb(255, 255, 255)",display:"none"},children:h.jsx("path",{d:"M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"})})})},`sub-color-${y}`))},m)),h.jsxs("div",{children:[h.jsx("div",{className:"my-1 text-sm",children:e("editor.recent")}),h.jsx("span",{className:"relative flex h-auto w-full p-0 last:pb-2",children:c==null?void 0:c.map((p,m)=>h.jsx("span",{className:"inline-block size-6 flex-[0_0_auto] cursor-pointer rounded-sm !border border-transparent p-0.5 hover:border-border hover:shadow-sm",onClick:()=>f(p),children:h.jsx("span",{className:"relative block size-[18px] rounded-[2px] border-transparent",style:{backgroundColor:p},children:h.jsx("svg",{viewBox:"0 0 18 18",style:{fill:"rgb(255, 255, 255)",display:"none"},children:h.jsx("path",{d:"M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"})})})},`sub-color-recent-${m}`))})]}),h.jsx(X5,{setColor:f})]})})]})}function X5({setColor:n}){const[e,t]=x.useState("#000000"),[r,o]=x.useState(!1),{t:i}=ie.useLocale();return x.useEffect(()=>()=>{o(!1)},[]),h.jsxs(zn,{open:r,children:[h.jsx($n,{asChild:!0,children:h.jsxs("div",{className:"p-1.5 text-sm hover:cursor-pointer hover:bg-accent",onClick:s=>{s.preventDefault(),o(!0)},children:[i("editor.color.more"),"..."]})}),h.jsxs(mn,{children:[h.jsxs("div",{className:"flex flex-col items-center justify-center",children:[h.jsx(J1.HexColorPicker,{color:e,onChange:t}),h.jsx(Rt,{className:"mt-[8px] w-full",type:"text",value:e.slice(1),onChange:s=>{s.preventDefault(),t(`#${s.target.value}`)}})]}),h.jsx(Nc,{className:"my-[10px]"}),h.jsx(Be,{className:"w-full",onClick:s=>{s.preventDefault(),n(e),o(!1)},children:h.jsx(B.Plus,{size:16})})]})]})}exports.ActionButton=at;exports.AllSelection=ot;exports.BubbleMenu=_w;exports.Button=Be;exports.ColorPicker=L1;exports.Column=Pc;exports.ControlDrawer=P1;exports.Decoration=Pe;exports.DecorationSet=xe;exports.Dialog=Fn;exports.DialogContent=gn;exports.DialogFooter=mr;exports.DialogHeader=jg;exports.DialogTitle=yn;exports.DialogTrigger=Vn;exports.Drawer=J5;exports.DropdownMenu=ZS;exports.DropdownMenuCheckboxItem=xg;exports.DropdownMenuContent=bg;exports.DropdownMenuItem=vg;exports.DropdownMenuPortal=QS;exports.DropdownMenuSeparator=wg;exports.DropdownMenuShortcut=Sg;exports.DropdownMenuSub=e2;exports.DropdownMenuSubContent=yg;exports.DropdownMenuSubTrigger=gg;exports.DropdownMenuTrigger=YS;exports.EVENTS=pr;exports.EditorContent=xw;exports.Excalidraw=v1;exports.ExportPdf=Og;exports.ExportWord=Ag;exports.Extension=lt;exports.FormEditLinkTwitter=D1;exports.Fragment=j;exports.HighlightActionButton=I2;exports.IconComponent=Dn;exports.Iframe=Kg;exports.Image=ni;exports.ImageGif=uE;exports.IndentProps=Rg;exports.Input=Rt;exports.Katex=Va;exports.Label=cn;exports.LinkEditBlock=_2;exports.Mapping=tr;exports.Mark=Hr;exports.MenuDown=Mg;exports.Mermaid=yE;exports.MultiColumn=jc;exports.Node=Je;exports.NodeRange=Pr;exports.NodeSelection=K;exports.NodeViewContent=Dw;exports.NodeViewWrapper=Ht;exports.Plugin=$e;exports.PluginKey=ht;exports.Popover=zn;exports.PopoverContent=mn;exports.PopoverTrigger=$n;exports.ProviderEditableEditor=$S;exports.ProviderTheme=FS;exports.ReactNodeViewRenderer=qt;exports.ReactRenderer=eg;exports.Selection=te;exports.SelectionRange=ic;exports.Separator=Nc;exports.Slice=$;exports.Switch=Rc;exports.Symbol=Ur;exports.Table=Fc;exports.TextSelection=Z;exports.Textarea=Ni;exports.Toggle=_c;exports.Tooltip=Tg;exports.TooltipContent=Dc;exports.TooltipProvider=i2;exports.TooltipTrigger=kg;exports.Twitter=j1;exports.Video=Pg;exports.actionDialogImage=_g;exports.baseGetTag=kc;exports.callOrReturn=le;exports.clsx=st;exports.cn=U;exports.combineTransactionSteps=yx;exports.commonjsGlobal=Zr;exports.createIndentCommand=$2;exports.cva=Ci;exports.dataURLtoFile=ki;exports.debounce=xi;exports.deepEqual=Qc;exports.deleteNode=HS;exports.deleteSelection=Am;exports.dispatchEvent=Si;exports.dropPoint=Hp;exports.editableEditorActions=VS;exports.ensureNameValueOptions=JS;exports.escapeForRegEx=cw;exports.extractFileExtension=W2;exports.extractFilename=q2;exports.findChildren=vx;exports.findChildrenInRange=xx;exports.freeGlobal=tg;exports.getAttributes=Km;exports.getAugmentedNamespace=Jg;exports.getChangedRanges=kx;exports.getDatasetAttribute=Nn;exports.getDefaultExportFromCjs=Vc;exports.getExtensionField=H;exports.getMarkRange=mi;exports.getMarksBetween=Sc;exports.getShortcutKey=dg;exports.getShortcutKeys=fg;exports.hasExtension=KS;exports.i=tu;exports.icons=Ng;exports.isActive=Jm;exports.isColumnGripSelected=CT;exports.isFunction=US;exports.isNodeEmpty=bi;exports.isNodeSelection=Xm;exports.isObject=Gr;exports.isObjectLike=Ec;exports.isRowGripSelected=TT;exports.isSymbol=rg;exports.keydownHandler=gc;exports.listenEvent=Oc;exports.markInputRule=ow;exports.markPasteRule=aw;exports.mergeAttributes=Ue;exports.nodeInputRule=ro;exports.normalizeFileSize=U2;exports.normalizeFileType=G2;exports.root=Tc;exports.setNodeIndentMarkup=Ig;exports.shortId=nu;exports.textblockTypeInputRule=iw;exports.themeActions=Fk;exports.throttle=Vt;exports.toNumber=ir;exports.triggerOpenExcalidrawSettingModal=Gk;exports.useAttributes=b1;exports.useEditableEditor=mg;exports.useEditor=Nw;exports.useStoreEditableEditor=hg;exports.useStoreTheme=pg;exports.useToast=d2;exports.wrappingInputRule=sw;