diff --git a/changes.md b/changes.md index cb3d007..a8204df 100644 --- a/changes.md +++ b/changes.md @@ -1,5 +1,15 @@ # AiEditor ChangeLog +## v1.0.7 20240613: +- 新增:AiModel 添加 chatWithPayload 方法用于传入自定义的 ai 参数信息 +- 新增:源码编辑的功能菜单,及其配置。感谢 @jx +- 新增:添加是否可以对整个编辑器拖拽放大缩小的开关配置 +- 优化:优化 a 标签在暗色主题下的样式问题,感谢 @lwleen +- 优化:编辑的滚动条样式,感谢 @lwleen +- 优化:移除无用的配置 cbName 和 cbUrl + + + ## v1.0.6 20240607: - 新增:AI 大模型新增对 Openai 和 暗月之面 的支持 - 新增:编辑元素新增对 Figure 和 Figcaption 元素的支持 diff --git a/dist/index.cjs b/dist/index.cjs index 7f0b219..7961850 100644 --- a/dist/index.cjs +++ b/dist/index.cjs @@ -1,15 +1,15 @@ -"use strict";var Ug=Object.defineProperty;var qg=(t,e,n)=>e in t?Ug(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var B=(t,e,n)=>(qg(t,typeof e!="symbol"?e+"":e,n),n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function Ge(t){this.content=t}Ge.prototype={constructor:Ge,find:function(t){for(var e=0;e>1}};Ge.from=function(t){if(t instanceof Ge)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new Ge(e)};function Ap(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let i=t.child(r),s=e.child(r);if(i==s){n+=i.nodeSize;continue}if(!i.sameMarkup(s))return n;if(i.isText&&i.text!=s.text){for(let o=0;i.text[o]==s.text[o];o++)n++;return n}if(i.content.size||s.content.size){let o=Ap(i.content,s.content,n+1);if(o!=null)return o}n+=i.nodeSize}}function Mp(t,e,n,r){for(let i=t.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:n,b:r};let o=t.child(--i),a=e.child(--s),l=o.nodeSize;if(o==a){n-=l,r-=l;continue}if(!o.sameMarkup(a))return{a:n,b:r};if(o.isText&&o.text!=a.text){let u=0,c=Math.min(o.text.length,a.text.length);for(;ue&&r(l,i+a,s||null,o)!==!1&&l.content.size){let c=a+1;l.nodesBetween(Math.max(0,e-c),Math.min(l.content.size,n-c),r,i+c)}a=u}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,i){let s="",o=!0;return this.nodesBetween(e,n,(a,l)=>{let u=a.isText?a.text.slice(Math.max(e,l)-l,n-l):a.isLeaf?i?typeof i=="function"?i(a):i:a.type.spec.leafText?a.type.spec.leafText(a):"":"";a.isBlock&&(a.isLeaf&&u||a.isTextblock)&&r&&(o?o=!1:s+=r),s+=u},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,i=this.content.slice(),s=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),s=1);se)for(let s=0,o=0;oe&&((on)&&(a.isText?a=a.cut(Math.max(0,e-o),Math.min(a.text.length,n-o)):a=a.cut(Math.max(0,e-o-1),Math.min(a.content.size,n-o-1))),r.push(a),i+=a.nodeSize),o=l}return new O(r,i)}cutByIndex(e,n){return e==n?O.empty:e==0&&n==this.content.length?this:new O(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let i=this.content.slice(),s=this.size+n.nodeSize-r.nodeSize;return i[e]=n,new O(i,s)}addToStart(e){return new O([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new O(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;nthis.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let r=0,i=0;;r++){let s=this.child(r),o=i+s.nodeSize;if(o>=e)return o==e||n>0?Ns(r+1,o):Ns(r,i);i=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return O.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new O(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return O.empty;let n,r=0;for(let i=0;ithis.type.rank&&(n||(n=e.slice(0,i)),n.push(this),r=!0),n&&n.push(s)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;nr.type.rank-i.type.rank),n}};ye.none=[];class mo extends Error{}class P{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=Dp(this.content,e+this.openStart,n);return r&&new P(r,this.openStart,this.openEnd)}removeBetween(e,n){return new P(Tp(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return P.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new P(O.fromJSON(e,n.content),r,i)}static maxOpen(e,n=!0){let r=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(n||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(n||!s.type.spec.isolating);s=s.lastChild)i++;return new P(e,r,i)}}P.empty=new P(O.empty,0,0);function Tp(t,e,n){let{index:r,offset:i}=t.findIndex(e),s=t.maybeChild(r),{index:o,offset:a}=t.findIndex(n);if(i==e||s.isText){if(a!=n&&!t.child(o).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(r,s.copy(Tp(s.content,e-i-1,n-i-1)))}function Dp(t,e,n,r){let{index:i,offset:s}=t.findIndex(e),o=t.maybeChild(i);if(s==e||o.isText)return r&&!r.canReplace(i,i,n)?null:t.cut(0,e).append(n).append(t.cut(e));let a=Dp(o.content,e-s-1,n);return a&&t.replaceChild(i,o.copy(a))}function Zg(t,e,n){if(n.openStart>t.depth)throw new mo("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new mo("Inconsistent open depths");return Op(t,e,n,0)}function Op(t,e,n,r){let i=t.index(r),s=t.node(r);if(i==e.index(r)&&r=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function Di(t,e,n,r){let i=(e||t).node(n),s=0,o=e?e.index(n):i.childCount;t&&(s=t.index(n),t.depth>n?s++:t.textOffset&&(lr(t.nodeAfter,r),s++));for(let a=s;ai&&Gl(t,e,i+1),o=r.depth>i&&Gl(n,r,i+1),a=[];return Di(null,t,i,a),s&&o&&e.index(i)==n.index(i)?(Np(s,o),lr(ur(s,Lp(t,e,n,r,i+1)),a)):(s&&lr(ur(s,go(t,e,i+1)),a),Di(e,n,i,a),o&&lr(ur(o,go(n,r,i+1)),a)),Di(r,null,i,a),new O(a)}function go(t,e,n){let r=[];if(Di(null,t,n,r),t.depth>n){let i=Gl(t,e,n+1);lr(ur(i,go(t,e,n+1)),r)}return Di(e,null,n,r),new O(r)}function Kg(t,e){let n=e.depth-t.openStart,i=e.node(n).copy(t.content);for(let s=n-1;s>=0;s--)i=e.node(s).copy(O.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class zi{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(n);return r?e.child(n).cut(r):i}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],i=n==0?0:this.path[n*3-1]+1;for(let s=0;s0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new bo(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],i=0,s=n;for(let o=e;;){let{index:a,offset:l}=o.content.findIndex(s),u=s-l;if(r.push(o,a,i+l),!u||(o=o.child(a),o.isText))break;s=u-1,i+=l+1}return new zi(n,r,s)}static resolveCached(e,n){for(let i=0;ie&&this.nodesBetween(e,n,s=>(r.isInSet(s.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Rp(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=O.empty,i=0,s=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,i,s),a=o&&o.matchFragment(this.content,n);if(!a||!a.validEnd)return!1;for(let l=i;ln.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r=null;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let i=O.fromJSON(e,n.content);return e.nodeType(n.type).create(n.attrs,i,r)}};cr.prototype.text=void 0;class yo extends cr{constructor(e,n,r,i){if(super(e,n,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Rp(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new yo(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new yo(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function Rp(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class gr{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new Gg(e,n);if(r.next==null)return gr.empty;let i=Ip(r);r.next&&r.err("Unexpected trailing text");let s=nb(tb(i));return rb(s,r),s}matchType(e){for(let n=0;nu.createAndFill()));for(let u=0;u=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let i=0;i{let s=i+(r.validEnd?"*":" ")+" ";for(let o=0;o"+e.indexOf(r.next[o].next);return s}).join(` -`)}}gr.empty=new gr(!0);class Gg{constructor(e,n){this.string=e,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function Ip(t){let e=[];do e.push(Jg(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Jg(t){let e=[];do e.push(Yg(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Yg(t){let e=eb(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=Xg(t,e);else break;return e}function ed(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function Xg(t,e){let n=ed(t),r=n;return t.eat(",")&&(t.next!="}"?r=ed(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function Qg(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let i=[];for(let s in n){let o=n[s];o.groups.indexOf(e)>-1&&i.push(o)}return i.length==0&&t.err("No node type or group '"+e+"' found"),i}function eb(t){if(t.eat("(")){let e=Ip(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=Qg(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err("Mixing inline and block content"),{type:"name",value:n}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function tb(t){let e=[[]];return i(s(t,0),n()),e;function n(){return e.push([])-1}function r(o,a,l){let u={term:l,to:a};return e[o].push(u),u}function i(o,a){o.forEach(l=>l.to=a)}function s(o,a){if(o.type=="choice")return o.exprs.reduce((l,u)=>l.concat(s(u,a)),[]);if(o.type=="seq")for(let l=0;;l++){let u=s(o.exprs[l],a);if(l==o.exprs.length-1)return u;i(u,a=n())}else if(o.type=="star"){let l=n();return r(a,l),i(s(o.expr,l),l),[r(l)]}else if(o.type=="plus"){let l=n();return i(s(o.expr,a),l),i(s(o.expr,l),l),[r(l)]}else{if(o.type=="opt")return[r(a)].concat(s(o.expr,a));if(o.type=="range"){let l=a;for(let u=0;u{t[o].forEach(({term:a,to:l})=>{if(!a)return;let u;for(let c=0;c{u||i.push([a,u=[]]),u.indexOf(c)==-1&&u.push(c)})})});let s=e[r.join(",")]=new gr(r.indexOf(t.length-1)>-1);for(let o=0;o-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;nr[s]=new $p(s,n,o));let i=n.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let s in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};class ib{constructor(e){this.hasDefault=Object.prototype.hasOwnProperty.call(e,"default"),this.default=e.default}get isRequired(){return!this.hasDefault}}class ua{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=Pp(i.attrs),this.excluded=null;let s=Hp(this.attrs);this.instance=s?new ye(this,s):null}create(e=null){return!e&&this.instance?this.instance:new ye(this,Bp(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((s,o)=>r[s]=new ua(s,i++,n,o)),r}removeFromSet(e){for(var n=0;n-1}}class zp{constructor(e){this.cached=Object.create(null);let n=this.spec={};for(let i in e)n[i]=e[i];n.nodes=Ge.from(e.nodes),n.marks=Ge.from(e.marks||{}),this.nodes=nd.compile(this.spec.nodes,this),this.marks=ua.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let s=this.nodes[i],o=s.spec.content||"",a=s.spec.marks;s.contentMatch=r[o]||(r[o]=gr.parse(o,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.markSet=a=="_"?null:a?rd(this,a.split(" ")):a==""||!s.inlineContent?[]:null}for(let i in this.marks){let s=this.marks[i],o=s.spec.excludes;s.excluded=o==null?[s]:o==""?[]:rd(this,o.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,n=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof nd){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,r,i)}text(e,n){let r=this.nodes.text;return new yo(r,r.defaultAttrs,e,ye.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeFromJSON(e){return cr.fromJSON(this,e)}markFromJSON(e){return ye.fromJSON(this,e)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}}function rd(t,e){let n=[];for(let r=0;r-1)&&n.push(o=l)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}let ps=class Yl{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[],n.forEach(r=>{r.tag?this.tags.push(r):r.style&&this.styles.push(r)}),this.normalizeLists=!this.tags.some(r=>{if(!/^(ul|ol)\b/.test(r.tag)||!r.node)return!1;let i=e.nodes[r.node];return i.contentMatch.matchType(i)})}parse(e,n={}){let r=new sd(this,n,!1);return r.addAll(e,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new sd(this,n,!0);return r.addAll(e,n.from,n.to),P.maxOpen(r.finish())}matchTag(e,n,r){for(let i=r?this.tags.indexOf(r)+1:0;ie.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=n))){if(o.getAttrs){let l=o.getAttrs(n);if(l===!1)continue;o.attrs=l||void 0}return o}}}static schemaRules(e){let n=[];function r(i){let s=i.priority==null?50:i.priority,o=0;for(;o{r(o=od(o)),o.mark||o.ignore||o.clearMark||(o.mark=i)})}for(let i in e.nodes){let s=e.nodes[i].spec.parseDOM;s&&s.forEach(o=>{r(o=od(o)),o.node||o.ignore||o.mark||(o.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Yl(e,Yl.schemaRules(e)))}};const Vp={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},sb={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Up={ol:!0,ul:!0},xo=1,ko=2,Oi=4;function id(t,e,n){return e!=null?(e?xo:0)|(e==="full"?ko:0):t&&t.whitespace=="pre"?xo|ko:n&~Oi}class Ls{constructor(e,n,r,i,s,o,a){this.type=e,this.attrs=n,this.marks=r,this.pendingMarks=i,this.solid=s,this.options=a,this.content=[],this.activeMarks=ye.none,this.stashMarks=[],this.match=o||(a&Oi?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(O.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&xo)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let s=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-i[0].length))}}let n=O.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(O.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}popFromStashMark(e){for(let n=this.stashMarks.length-1;n>=0;n--)if(e.eq(this.stashMarks[n]))return this.stashMarks.splice(n,1)[0]}applyPending(e){for(let n=0,r=this.pendingMarks;nthis.addAll(e)),o&&this.sync(a),this.needsBlock=l}else this.withStyleRules(e,()=>{this.addElementByRule(e,s,s.consuming===!1?i:void 0)})}leafFallback(e){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(` -`))}ignoreFallback(e){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"))}readStyles(e){let n=ye.none,r=ye.none;for(let i=0;i{o.clearMark(a)&&(r=a.addToSet(r))}):n=this.parser.schema.marks[o.mark].create(o.attrs).addToSet(n),o.consuming===!1)s=o;else break}return[n,r]}addElementByRule(e,n,r){let i,s,o;n.node?(s=this.parser.schema.nodes[n.node],s.isLeaf?this.insertNode(s.create(n.attrs))||this.leafFallback(e):i=this.enter(s,n.attrs||null,n.preserveWhitespace)):(o=this.parser.schema.marks[n.mark].create(n.attrs),this.addPendingMark(o));let a=this.top;if(s&&s.isLeaf)this.findInside(e);else if(r)this.addElement(e,r);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(l=>this.insertNode(l));else{let l=e;typeof n.contentElement=="string"?l=e.querySelector(n.contentElement):typeof n.contentElement=="function"?l=n.contentElement(e):n.contentElement&&(l=n.contentElement),this.findAround(e,l,!0),this.addAll(l)}i&&this.sync(a)&&this.open--,o&&this.removePendingMark(o,a)}addAll(e,n,r){let i=n||0;for(let s=n?e.childNodes[n]:e.firstChild,o=r==null?null:e.childNodes[r];s!=o;s=s.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(s);this.findAtPoint(e,i)}findPlace(e){let n,r;for(let i=this.open;i>=0;i--){let s=this.nodes[i],o=s.findWrapping(e);if(o&&(!n||n.length>o.length)&&(n=o,r=s,!o.length)||s.solid)break}if(!n)return!1;this.sync(r);for(let i=0;ithis.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)}sync(e){for(let n=this.open;n>=0;n--)if(this.nodes[n]==e)return this.open=n,!0;return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),s=-(r?r.depth+1:0)+(i?0:1),o=(a,l)=>{for(;a>=0;a--){let u=n[a];if(u==""){if(a==n.length-1||a==0)continue;for(;l>=s;l--)if(o(a-1,l))return!0;return!1}else{let c=l>0||l==0&&i?this.nodes[l].type:r&&l>=s?r.node(l-s).type:null;if(!c||c.name!=u&&c.groups.indexOf(u)==-1)return!1;l--}}return!0};return o(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}addPendingMark(e){let n=cb(e,this.top.pendingMarks);n&&this.top.stashMarks.push(n),this.top.pendingMarks=e.addToSet(this.top.pendingMarks)}removePendingMark(e,n){for(let r=this.open;r>=0;r--){let i=this.nodes[r];if(i.pendingMarks.lastIndexOf(e)>-1)i.pendingMarks=e.removeFromSet(i.pendingMarks);else{i.activeMarks=e.removeFromSet(i.activeMarks);let o=i.popFromStashMark(e);o&&i.type&&i.type.allowsMarkType(o.type)&&(i.activeMarks=o.addToSet(i.activeMarks))}if(i==n)break}}}function ob(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Up.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function ab(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function lb(t){let e=/\s*([\w-]+)\s*:\s*([^;]+)/g,n,r=[];for(;n=e.exec(t);)r.push(n[1],n[2].trim());return r}function od(t){let e={};for(let n in t)e[n]=t[n];return e}function ub(t,e){let n=e.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(t))continue;let s=[],o=a=>{s.push(a);for(let l=0;l{if(s.length||o.marks.length){let a=0,l=0;for(;a=0;i--){let s=this.serializeMark(e.marks[i],e.isInline,n);s&&((s.contentDOM||s.dom).appendChild(r),r=s.dom)}return r}serializeMark(e,n,r={}){let i=this.marks[e.type.name];return i&&Yt.renderSpec(Ya(r),i(e,n))}static renderSpec(e,n,r=null){if(typeof n=="string")return{dom:e.createTextNode(n)};if(n.nodeType!=null)return{dom:n};if(n.dom&&n.dom.nodeType!=null)return n;let i=n[0],s=i.indexOf(" ");s>0&&(r=i.slice(0,s),i=i.slice(s+1));let o,a=r?e.createElementNS(r,i):e.createElement(i),l=n[1],u=1;if(l&&typeof l=="object"&&l.nodeType==null&&!Array.isArray(l)){u=2;for(let c in l)if(l[c]!=null){let d=c.indexOf(" ");d>0?a.setAttributeNS(c.slice(0,d),c.slice(d+1),l[c]):a.setAttribute(c,l[c])}}for(let c=u;cu)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:f,contentDOM:h}=Yt.renderSpec(e,d,r);if(a.appendChild(f),h){if(o)throw new RangeError("Multiple content holes");o=h}}}return{dom:a,contentDOM:o}}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Yt(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=ad(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return ad(e.marks)}}function ad(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Ya(t){return t.document||window.document}const qp=65535,Zp=Math.pow(2,16);function db(t,e){return t+e*Zp}function ld(t){return t&qp}function fb(t){return(t-(t&qp))/Zp}const Kp=1,Wp=2,so=4,jp=8;class Xl{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&jp)>0}get deletedBefore(){return(this.delInfo&(Kp|so))>0}get deletedAfter(){return(this.delInfo&(Wp|so))>0}get deletedAcross(){return(this.delInfo&so)>0}}class vt{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&vt.empty)return vt.empty}recover(e){let n=0,r=ld(e);if(!this.inverted)for(let i=0;ie)break;let u=this.ranges[a+s],c=this.ranges[a+o],d=l+u;if(e<=d){let f=u?e==l?-1:e==d?1:n:n,h=l+i+(f<0?0:c);if(r)return h;let p=e==(n<0?l:d)?null:db(a/3,e-l),m=e==l?Wp:e==d?Kp:so;return(n<0?e!=l:e!=d)&&(m|=jp),new Xl(h,m,p)}i+=c-u}return r?e+i:new Xl(e+i,0,null)}touches(e,n){let r=0,i=ld(n),s=this.inverted?2:1,o=this.inverted?1:2;for(let a=0;ae)break;let u=this.ranges[a+s],c=l+u;if(e<=c&&a==i*3)return!0;r+=this.ranges[a+o]-u}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,s=0;i=0;n--){let i=e.getMirror(n);this.appendMap(e.maps[n].invert(),i!=null&&i>n?r-i-1:void 0)}}invert(){let e=new Gr;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;rs&&l!o.isAtom||!a.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),i),n.openStart,n.openEnd);return He.fromReplace(e,this.from,this.to,s)}invert(){return new Xt(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Ln(n.pos,r.pos,this.mark)}merge(e){return e instanceof Ln&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ln(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Ln(n.from,n.to,e.markFromJSON(n.mark))}}nt.jsonID("addMark",Ln);class Xt extends nt{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new P($u(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return He.fromReplace(e,this.from,this.to,r)}invert(){return new Ln(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Xt(n.pos,r.pos,this.mark)}merge(e){return e instanceof Xt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Xt(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Xt(n.from,n.to,e.markFromJSON(n.mark))}}nt.jsonID("removeMark",Xt);class Rn extends nt{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return He.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return He.fromReplace(e,this.pos,this.pos+1,new P(O.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let i=0;ir.pos?null:new Ue(n.pos,r.pos,i,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Ue(n.from,n.to,n.gapFrom,n.gapTo,P.fromJSON(e,n.slice),n.insert,!!n.structure)}}nt.jsonID("replaceAround",Ue);function Ql(t,e,n){let r=t.resolve(e),i=n-e,s=r.depth;for(;i>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,i--;if(i>0){let o=r.node(s).maybeChild(r.indexAfter(s));for(;i>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,i--}}return!1}function hb(t,e,n,r){let i=[],s=[],o,a;t.doc.nodesBetween(e,n,(l,u,c)=>{if(!l.isInline)return;let d=l.marks;if(!r.isInSet(d)&&c.type.allowsMarkType(r.type)){let f=Math.max(u,e),h=Math.min(u+l.nodeSize,n),p=r.addToSet(d);for(let m=0;mt.step(l)),s.forEach(l=>t.step(l))}function pb(t,e,n,r){let i=[],s=0;t.doc.nodesBetween(e,n,(o,a)=>{if(!o.isInline)return;s++;let l=null;if(r instanceof ua){let u=o.marks,c;for(;c=r.isInSet(u);)(l||(l=[])).push(c),u=c.removeFromSet(u)}else r?r.isInSet(o.marks)&&(l=[r]):l=o.marks;if(l&&l.length){let u=Math.min(a+o.nodeSize,n);for(let c=0;ct.step(new Xt(o.from,o.to,o.style)))}function mb(t,e,n,r=n.contentMatch){let i=t.doc.nodeAt(e),s=[],o=e+1;for(let a=0;a=0;a--)t.step(s[a])}function gb(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function mi(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth;;--r){let i=t.$from.node(r),s=t.$from.index(r),o=t.$to.indexAfter(r);if(rn;p--)m||r.index(p)>0?(m=!0,c=O.from(r.node(p).copy(c)),d++):l--;let f=O.empty,h=0;for(let p=s,m=!1;p>n;p--)m||i.after(p+1)=0;o--){if(r.size){let a=n[o].type.contentMatch.matchFragment(r);if(!a||!a.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=O.from(n[o].type.create(n[o].attrs,r))}let i=e.start,s=e.end;t.step(new Ue(i,s,i,s,new P(r,0,0),n.length,!0))}function vb(t,e,n,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=t.steps.length;t.doc.nodesBetween(e,n,(o,a)=>{if(o.isTextblock&&!o.hasMarkup(r,i)&&Eb(t.doc,t.mapping.slice(s).map(a),r)){t.clearIncompatible(t.mapping.slice(s).map(a,1),r);let l=t.mapping.slice(s),u=l.map(a,1),c=l.map(a+o.nodeSize,1);return t.step(new Ue(u,c,u+1,c-1,new P(O.from(r.create(i,null,o.marks)),0,0),1,!0)),!1}})}function Eb(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function _b(t,e,n,r,i){let s=t.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");n||(n=s.type);let o=n.create(r,null,i||s.marks);if(s.isLeaf)return t.replaceWith(e,e+s.nodeSize,o);if(!n.validContent(s.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new Ue(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new P(O.from(o),0,0),1,!0))}function Jr(t,e,n=1,r){let i=t.resolve(e),s=i.depth-n,o=r&&r[r.length-1]||i.parent;if(s<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let u=i.depth-1,c=n-2;u>s;u--,c--){let d=i.node(u),f=i.index(u);if(d.type.spec.isolating)return!1;let h=d.content.cutByIndex(f,d.childCount),p=r&&r[c+1];p&&(h=h.replaceChild(0,p.type.create(p.attrs)));let m=r&&r[c]||d;if(!d.canReplace(f+1,d.childCount)||!m.type.validContent(h))return!1}let a=i.indexAfter(s),l=r&&r[0];return i.node(s).canReplaceWith(a,a,l?l.type:i.node(s+1).type)}function Cb(t,e,n=1,r){let i=t.doc.resolve(e),s=O.empty,o=O.empty;for(let a=i.depth,l=i.depth-n,u=n-1;a>l;a--,u--){s=O.from(i.node(a).copy(s));let c=r&&r[u];o=O.from(c?c.type.create(c.attrs,o):i.node(a).copy(o))}t.step(new ze(e,e,new P(s.append(o),n,n),!0))}function Gn(t,e){let n=t.resolve(e),r=n.index();return Gp(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function Gp(t,e){return!!(t&&e&&!t.isLeaf&&t.canAppend(e))}function ca(t,e,n=-1){let r=t.resolve(e);for(let i=r.depth;;i--){let s,o,a=r.index(i);if(i==r.depth?(s=r.nodeBefore,o=r.nodeAfter):n>0?(s=r.node(i+1),a++,o=r.node(i).maybeChild(a)):(s=r.node(i).maybeChild(a-1),o=r.node(i+1)),s&&!s.isTextblock&&Gp(s,o)&&r.node(i).canReplace(a,a+1))return e;if(i==0)break;e=n<0?r.before(i):r.after(i)}}function wb(t,e,n){let r=new ze(e-n,e+n,P.empty,!0);t.step(r)}function Sb(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let s=r.index(i);if(r.node(i).canReplaceWith(s,s,n))return r.before(i+1);if(s>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let s=r.indexAfter(i);if(r.node(i).canReplaceWith(s,s,n))return r.after(i+1);if(s=0;o--){let a=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,l=r.index(o)+(a>0?1:0),u=r.node(o),c=!1;if(s==1)c=u.canReplace(l,l,i);else{let d=u.contentMatchAt(l).findWrapping(i.firstChild.type);c=d&&u.canReplaceWith(l,l,d[0])}if(c)return a==0?r.pos:a<0?r.before(o+1):r.after(o+1)}return null}function da(t,e,n=e,r=P.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),s=t.resolve(n);return Yp(i,s,r)?new ze(e,n,r):new Ab(i,s,r).fit()}function Yp(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class Ab{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=O.empty;for(let i=0;i<=e.depth;i++){let s=e.node(i);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=O.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let u=this.findFittable();u?this.placeNodes(u):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let s=this.placed,o=r.depth,a=i.depth;for(;o&&a&&s.childCount==1;)s=s.firstChild.content,o--,a--;let l=new P(s,o,a);return e>-1?new Ue(r.pos,e,this.$to.pos,this.$to.end(),l,n):l.size||r.pos!=this.$to.pos?new ze(r.pos,i.pos,l):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,i=this.unplaced.openEnd;r1&&(i=0),s.type.spec.isolating&&i<=r){e=r;break}n=s.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let i,s=null;r?(s=Qa(this.unplaced.content,r-1).firstChild,i=s.content):i=this.unplaced.content;let o=i.firstChild;for(let a=this.depth;a>=0;a--){let{type:l,match:u}=this.frontier[a],c,d=null;if(n==1&&(o?u.matchType(o.type)||(d=u.fillBefore(O.from(o),!1)):s&&l.compatibleContent(s.type)))return{sliceDepth:r,frontierDepth:a,parent:s,inject:d};if(n==2&&o&&(c=u.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:a,parent:s,wrap:c};if(s&&u.matchType(s.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=Qa(e,n);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new P(e,n+1,Math.max(r,i.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=Qa(e,n);if(i.childCount<=1&&n>0){let s=e.size-n<=n+i.size;this.unplaced=new P(Ai(e,n-1,1),n-1,s?n-1:r)}else this.unplaced=new P(Ai(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:i,wrap:s}){for(;this.depth>n;)this.closeFrontierNode();if(s)for(let m=0;m1||l==0||m.content.size)&&(d=g,c.push(Xp(m.mark(f.allowedMarks(m.marks)),u==1?l:0,u==a.childCount?h:-1)))}let p=u==a.childCount;p||(h=-1),this.placed=Mi(this.placed,n,O.from(c)),this.frontier[n].match=d,p&&h<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=a;m1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:i}=this.frontier[n],s=n=0;a--){let{match:l,type:u}=this.frontier[a],c=el(e,a,u,l,!0);if(!c||c.childCount)continue e}return{depth:n,fit:o,move:s?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=Mi(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let i=e.node(r),s=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,s)}return e}openFrontierNode(e,n=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=Mi(this.placed,this.depth,O.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(O.empty,!0);n.childCount&&(this.placed=Mi(this.placed,this.frontier.length,n))}}function Ai(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Ai(t.firstChild.content,e-1,n)))}function Mi(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Mi(t.lastChild.content,e-1,n)))}function Qa(t,e){for(let n=0;n1&&(r=r.replaceChild(0,Xp(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(O.empty,!0)))),t.copy(r)}function el(t,e,n,r,i){let s=t.node(e),o=i?t.indexAfter(e):t.index(e);if(o==s.childCount&&!n.compatibleContent(s.type))return null;let a=r.fillBefore(s.content,!0,o);return a&&!Mb(n,s.content,o)?a:null}function Mb(t,e,n){for(let r=n;r0;f--,h--){let p=i.node(f).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;o.indexOf(f)>-1?a=f:i.before(f)==h&&o.splice(1,0,-f)}let l=o.indexOf(a),u=[],c=r.openStart;for(let f=r.content,h=0;;h++){let p=f.firstChild;if(u.push(p),h==r.openStart)break;f=p.content}for(let f=c-1;f>=0;f--){let h=u[f],p=Tb(h.type);if(p&&!h.sameMarkup(i.node(Math.abs(a)-1)))c=f;else if(p||!h.type.isTextblock)break}for(let f=r.openStart;f>=0;f--){let h=(f+c+1)%(r.openStart+1),p=u[h];if(p)for(let m=0;m=0&&(t.replace(e,n,r),!(t.steps.length>d));f--){let h=o[f];h<0||(e=i.before(h),n=s.after(h))}}function Qp(t,e,n,r,i){if(er){let s=i.contentMatchAt(0),o=s.fillBefore(t).append(t);t=o.append(s.matchFragment(o).fillBefore(O.empty,!0))}return t}function Ob(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=Sb(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new P(O.from(r),0,0))}function Nb(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),s=e0(r,i);for(let o=0;o0&&(l||r.node(a-1).canReplace(r.index(a-1),i.indexAfter(a-1))))return t.delete(r.before(a),i.after(a))}for(let o=1;o<=r.depth&&o<=i.depth;o++)if(e-r.start(o)==r.depth-o&&n>r.end(o)&&i.end(o)-n!=i.depth-o)return t.delete(r.before(o),n);t.delete(e,n)}function e0(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let i=r;i>=0;i--){let s=t.start(i);if(se.pos+(e.depth-i)||t.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(s==e.start(i)||i==t.depth&&i==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==s-1)&&n.push(i)}return n}class Yr extends nt{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return He.fail("No node at attribute step's position");let r=Object.create(null);for(let s in n.attrs)r[s]=n.attrs[s];r[this.attr]=this.value;let i=n.type.create(r,null,n.marks);return He.fromReplace(e,this.pos,this.pos+1,new P(O.from(i),0,n.isLeaf?0:1))}getMap(){return vt.empty}invert(e){return new Yr(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Yr(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Yr(n.pos,n.attr,n.value)}}nt.jsonID("attr",Yr);class Vi extends nt{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let i in e.attrs)n[i]=e.attrs[i];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return He.ok(r)}getMap(){return vt.empty}invert(e){return new Vi(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Vi(n.attr,n.value)}}nt.jsonID("docAttr",Vi);let ti=class extends Error{};ti=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};ti.prototype=Object.create(Error.prototype);ti.prototype.constructor=ti;ti.prototype.name="TransformError";class Vu{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Gr}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new ti(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=P.empty){let i=da(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new P(O.from(r),0,0))}delete(e,n){return this.replace(e,n,P.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return Db(this,e,n,r),this}replaceRangeWith(e,n,r){return Ob(this,e,n,r),this}deleteRange(e,n){return Nb(this,e,n),this}lift(e,n){return bb(this,e,n),this}join(e,n=1){return wb(this,e,n),this}wrap(e,n){return kb(this,e,n),this}setBlockType(e,n=e,r,i=null){return vb(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return _b(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new Yr(e,n,r)),this}setDocAttribute(e,n){return this.step(new Vi(e,n)),this}addNodeMark(e,n){return this.step(new Rn(e,n)),this}removeNodeMark(e,n){if(!(n instanceof ye)){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n=n.isInSet(r.marks),!n)return this}return this.step(new ei(e,n)),this}split(e,n=1,r){return Cb(this,e,n,r),this}addMark(e,n,r){return hb(this,e,n,r),this}removeMark(e,n,r){return pb(this,e,n,r),this}clearIncompatible(e,n,r){return mb(this,e,n,r),this}}const tl=Object.create(null);class ne{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new t0(e.min(n),e.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let n=0;n=0;s--){let o=n<0?Br(e.node(0),e.node(s),e.before(s+1),e.index(s),n,r):Br(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,n,r);if(o)return o}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new Nt(e.node(0))}static atStart(e){return Br(e,e,0,0,1)||new Nt(e)}static atEnd(e){return Br(e,e,e.content.size,e.childCount,-1)||new Nt(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=tl[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in tl)throw new RangeError("Duplicate use of selection JSON ID "+e);return tl[e]=n,n.prototype.jsonID=e,n}getBookmark(){return X.between(this.$anchor,this.$head).getBookmark()}}ne.prototype.visible=!0;class t0{constructor(e,n){this.$from=e,this.$to=n}}let cd=!1;function dd(t){!cd&&!t.parent.inlineContent&&(cd=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class X extends ne{constructor(e,n=e){dd(e),dd(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return ne.near(r);let i=e.resolve(n.map(this.anchor));return new X(i.parent.inlineContent?i:r,r)}replace(e,n=P.empty){if(super.replace(e,n),n==P.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof X&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new fa(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new X(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let i=e.resolve(n);return new this(i,r==n?i:e.resolve(r))}static between(e,n,r){let i=e.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let s=ne.findFrom(n,r,!0)||ne.findFrom(n,-r,!0);if(s)n=s.$head;else return ne.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(ne.findFrom(e,-r,!0)||ne.findFrom(e,r,!0)).$anchor,e.pos0?0:1);i>0?o=0;o+=i){let a=e.child(o);if(a.isAtom){if(!s&&ee.isSelectable(a))return ee.create(t,n-(i<0?a.nodeSize:0))}else{let l=Br(t,a,n+i,i<0?a.childCount:0,i,s);if(l)return l}n+=a.nodeSize*i}return null}function fd(t,e,n){let r=t.steps.length-1;if(r{o==null&&(o=c)}),t.setSelection(ne.near(t.doc.resolve(o),n))}const hd=1,Rs=2,pd=4;class Rb extends Vu{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Rs,this}ensureMarks(e){return ye.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&Rs)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~Rs,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||ye.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let i=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),r=r??n,!e)return this.deleteRange(n,r);let s=this.storedMarks;if(!s){let o=this.doc.resolve(n);s=r==n?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,i.text(e,s)),this.selection.empty||this.setSelection(ne.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=pd,this}get scrolledIntoView(){return(this.updated&pd)>0}}function md(t,e){return!e||!t?t:t.bind(e)}class Ti{constructor(e,n,r){this.name=e,this.init=md(n.init,r),this.apply=md(n.apply,r)}}const Ib=[new Ti("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Ti("selection",{init(t,e){return t.selection||ne.atStart(e.doc)},apply(t){return t.selection}}),new Ti("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Ti("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class nl{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Ib.slice(),n&&n.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Ti(r.key,r.spec.state,r))})}}class qr{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;rr.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],s=i.spec.state;s&&s.toJSON&&(n[r]=s.toJSON.call(i,this[i.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new nl(e.schema,e.plugins),s=new qr(i);return i.fields.forEach(o=>{if(o.name=="doc")s.doc=cr.fromJSON(e.schema,n.doc);else if(o.name=="selection")s.selection=ne.fromJSON(s.doc,n.selection);else if(o.name=="storedMarks")n.storedMarks&&(s.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let a in r){let l=r[a],u=l.spec.state;if(l.key==o.name&&u&&u.fromJSON&&Object.prototype.hasOwnProperty.call(n,a)){s[o.name]=u.fromJSON.call(l,e,n[a],s);return}}s[o.name]=o.init(e,s)}}),s}}function n0(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=n0(i,e,{})),n[r]=i}return n}class we{constructor(e){this.spec=e,this.props={},e.props&&n0(e.props,this,this.props),this.key=e.key?e.key.key:r0("plugin")}getState(e){return e[this.key]}}const rl=Object.create(null);function r0(t){return t in rl?t+"$"+ ++rl[t]:(rl[t]=0,t+"$")}class Te{constructor(e="key"){this.key=r0(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Je=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},Ui=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let eu=null;const bn=function(t,e,n){let r=eu||(eu=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},Fb=function(){eu=null},br=function(t,e,n,r){return n&&(gd(t,e,n,r,-1)||gd(t,e,n,r,1))},Hb=/^(img|br|input|textarea|hr)$/i;function gd(t,e,n,r,i){for(;;){if(t==n&&e==r)return!0;if(e==(i<0?0:Jt(t))){let s=t.parentNode;if(!s||s.nodeType!=1||ms(t)||Hb.test(t.nodeName)||t.contentEditable=="false")return!1;e=Je(t)+(i<0?0:1),t=s}else if(t.nodeType==1){if(t=t.childNodes[e+(i<0?-1:0)],t.contentEditable=="false")return!1;e=i<0?Jt(t):0}else return!1}}function Jt(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Bb(t,e){for(;;){if(t.nodeType==3&&e)return t;if(t.nodeType==1&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1],e=Jt(t)}else if(t.parentNode&&!ms(t))e=Je(t),t=t.parentNode;else return null}}function Pb(t,e){for(;;){if(t.nodeType==3&&e2),Dt=ni||(rn?/Mac/.test(rn.platform):!1),qb=rn?/Win/.test(rn.platform):!1,Pt=/Android \d/.test(Jn),gs=!!bd&&"webkitFontSmoothing"in bd.documentElement.style,Zb=gs?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Kb(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function hn(t,e){return typeof t=="number"?t:t[e]}function Wb(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function yd(t,e,n){let r=t.someProp("scrollThreshold")||0,i=t.someProp("scrollMargin")||5,s=t.dom.ownerDocument;for(let o=n||t.dom;o;o=Ui(o)){if(o.nodeType!=1)continue;let a=o,l=a==s.body,u=l?Kb(s):Wb(a),c=0,d=0;if(e.topu.bottom-hn(r,"bottom")&&(d=e.bottom-e.top>u.bottom-u.top?e.top+hn(i,"top")-u.top:e.bottom-u.bottom+hn(i,"bottom")),e.leftu.right-hn(r,"right")&&(c=e.right-u.right+hn(i,"right")),c||d)if(l)s.defaultView.scrollBy(c,d);else{let f=a.scrollLeft,h=a.scrollTop;d&&(a.scrollTop+=d),c&&(a.scrollLeft+=c);let p=a.scrollLeft-f,m=a.scrollTop-h;e={left:e.left-p,top:e.top-m,right:e.right-p,bottom:e.bottom-m}}if(l||/^(fixed|sticky)$/.test(getComputedStyle(o).position))break}}function jb(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,i;for(let s=(e.left+e.right)/2,o=n+1;o=n-20){r=a,i=l.top;break}}return{refDOM:r,refTop:i,stack:s0(t.dom)}}function s0(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=Ui(r));return e}function Gb({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;o0(n,r==0?0:r-e)}function o0(t,e){for(let n=0;n=a){o=Math.max(p.bottom,o),a=Math.min(p.top,a);let m=p.left>e.left?p.left-e.left:p.right=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!l&&p.left<=e.left&&p.right>=e.left&&(l=c,u={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!n&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(s=d+1)}}return!n&&l&&(n=l,i=u,r=0),n&&n.nodeType==3?Yb(n,i):!n||r&&n.nodeType==1?{node:t,offset:s}:a0(n,i)}function Yb(t,e){let n=t.nodeValue.length,r=document.createRange();for(let i=0;i=(s.left+s.right)/2?1:0)}}return{node:t,offset:0}}function qu(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function Xb(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left(o.left+o.right)/2?1:-1}return t.docView.posFromDOM(r,i,s)}function e2(t,e,n,r){let i=-1;for(let s=e,o=!1;s!=t.dom;){let a=t.docView.nearestDesc(s,!0);if(!a)return null;if(a.dom.nodeType==1&&(a.node.isBlock&&a.parent&&!o||!a.contentDOM)){let l=a.dom.getBoundingClientRect();if(a.node.isBlock&&a.parent&&!o&&(o=!0,l.left>r.left||l.top>r.top?i=a.posBefore:(l.right-1?i:t.docView.posFromDOM(e,n,-1)}function l0(t,e,n){let r=t.childNodes.length;if(r&&n.tope.top&&i++}let u;gs&&i&&r.nodeType==1&&(u=r.childNodes[i-1]).nodeType==1&&u.contentEditable=="false"&&u.getBoundingClientRect().top>=e.top&&i--,r==t.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?a=t.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(a=e2(t,r,i,e))}a==null&&(a=Qb(t,o,e));let l=t.docView.nearestDesc(o,!0);return{pos:a,inside:l?l.posAtStart-l.border:-1}}function xd(t){return t.top=0&&i==r.nodeValue.length?(l--,c=1):n<0?l--:u++,ki(Cn(bn(r,l,u),c),c<0)}if(!t.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&i&&(n<0||i==Jt(r))){let l=r.childNodes[i-1];if(l.nodeType==1)return il(l.getBoundingClientRect(),!1)}if(s==null&&i=0)}if(s==null&&i&&(n<0||i==Jt(r))){let l=r.childNodes[i-1],u=l.nodeType==3?bn(l,Jt(l)-(o?0:1)):l.nodeType==1&&(l.nodeName!="BR"||!l.nextSibling)?l:null;if(u)return ki(Cn(u,1),!1)}if(s==null&&i=0)}function ki(t,e){if(t.width==0)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function il(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function c0(t,e,n){let r=t.state,i=t.root.activeElement;r!=e&&t.updateState(e),i!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),i!=t.dom&&i&&i.focus()}}function r2(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return c0(t,e,()=>{let{node:s}=t.docView.domFromPos(i.pos,n=="up"?-1:1);for(;;){let a=t.docView.nearestDesc(s,!0);if(!a)break;if(a.node.isBlock){s=a.contentDOM||a.dom;break}s=a.dom.parentNode}let o=u0(t,i.pos,1);for(let a=s.firstChild;a;a=a.nextSibling){let l;if(a.nodeType==1)l=a.getClientRects();else if(a.nodeType==3)l=bn(a,0,a.nodeValue.length).getClientRects();else continue;for(let u=0;uc.top+1&&(n=="up"?o.top-c.top>(c.bottom-o.top)*2:c.bottom-o.bottom>(o.bottom-c.top)*2))return!1}}return!0})}const i2=/[\u0590-\u08ac]/;function s2(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,s=!i,o=i==r.parent.content.size,a=t.domSelection();return!i2.test(r.parent.textContent)||!a.modify?n=="left"||n=="backward"?s:o:c0(t,e,()=>{let{focusNode:l,focusOffset:u,anchorNode:c,anchorOffset:d}=t.domSelectionRange(),f=a.caretBidiLevel;a.modify("move",n,"character");let h=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:p,focusOffset:m}=t.domSelectionRange(),g=p&&!h.contains(p.nodeType==1?p:p.parentNode)||l==p&&u==m;try{a.collapse(c,d),l&&(l!=c||u!=d)&&a.extend&&a.extend(l,u)}catch{}return f!=null&&(a.caretBidiLevel=f),g})}let kd=null,vd=null,Ed=!1;function o2(t,e,n){return kd==e&&vd==n?Ed:(kd=e,vd=n,Ed=n=="up"||n=="down"?r2(t,e,n):s2(t,e,n))}const Lt=0,_d=1,sr=2,sn=3;class bs{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=Lt,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;nJe(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!1;break}if(s.previousSibling)break}if(i==null&&n==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!0;break}if(s.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,i=e;i;i=i.parentNode){let s=this.getDesc(i),o;if(s&&(!n||s.node))if(r&&(o=s.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))r=!1;else return s}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let i=e;i;i=i.parentNode){let s=this.getDesc(i);if(s)return s.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;ne||o instanceof f0){i=e-s;break}s=a}if(i)return this.children[r].domFromPos(i-this.children[r].border,n);for(let s;r&&!(s=this.children[r-1]).size&&s instanceof d0&&s.side>=0;r--);if(n<=0){let s,o=!0;for(;s=r?this.children[r-1]:null,!(!s||s.dom.parentNode==this.contentDOM);r--,o=!1);return s&&n&&o&&!s.border&&!s.domAtom?s.domFromPos(s.size,n):{node:this.contentDOM,offset:s?Je(s.dom)+1:0}}else{let s,o=!0;for(;s=r=c&&n<=u-l.border&&l.node&&l.contentDOM&&this.contentDOM.contains(l.contentDOM))return l.parseRange(e,n,c);e=o;for(let d=a;d>0;d--){let f=this.children[d-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){i=Je(f.dom)+1;break}e-=f.size}i==-1&&(i=0)}if(i>-1&&(u>n||a==this.children.length-1)){n=u;for(let c=a+1;ch&&on){let h=a;a=l,l=h}let f=document.createRange();f.setEnd(l.node,l.offset),f.setStart(a.node,a.offset),u.removeAllRanges(),u.addRange(f)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,i=0;i=r:er){let a=r+s.border,l=o-s.border;if(e>=a&&n<=l){this.dirty=e==r||n==o?sr:_d,e==a&&n==l&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=sn:s.markDirty(e-a,n-a);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?sr:sn}r=o}this.dirty=sr}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?sr:_d;n.dirty{if(!s)return i;if(s.parent)return s.parent.posBeforeChild(s)})),!n.type.spec.raw){if(o.nodeType!=1){let a=document.createElement("span");a.appendChild(o),o=a}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=n,this.widget=n,s=this}matchesWidget(e){return this.dirty==Lt&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}}class a2 extends bs{constructor(e,n,r,i){super(e,[],n,null),this.textDOM=r,this.text=i}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class yr extends bs{constructor(e,n,r,i){super(e,[],r,i),this.mark=n}static create(e,n,r,i){let s=i.nodeViews[n.type.name],o=s&&s(n,i,r);return(!o||!o.dom)&&(o=Yt.renderSpec(document,n.type.spec.toDOM(n,r))),new yr(e,n,o.dom,o.contentDOM||o.dom)}parseRule(){return this.dirty&sn||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=sn&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=Lt){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty0&&(s=ou(s,0,e,r));for(let a=0;a{if(!l)return o;if(l.parent)return l.parent.posBeforeChild(l)},r,i),c=u&&u.dom,d=u&&u.contentDOM;if(n.isText){if(!c)c=document.createTextNode(n.text);else if(c.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else c||({dom:c,contentDOM:d}=Yt.renderSpec(document,n.type.spec.toDOM(n)));!d&&!n.isText&&c.nodeName!="BR"&&(c.hasAttribute("contenteditable")||(c.contentEditable="false"),n.type.spec.draggable&&(c.draggable=!0));let f=c;return c=m0(c,r,n),u?l=new l2(e,n,r,i,c,d||null,f,u,s,o+1):n.isText?new pa(e,n,r,i,c,f,s):new zn(e,n,r,i,c,d||null,f,s,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>O.empty)}return e}matchesNode(e,n,r){return this.dirty==Lt&&e.eq(this.node)&&su(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,i=n,s=e.composing?this.localCompositionInfo(e,n):null,o=s&&s.pos>-1?s:null,a=s&&s.pos<0,l=new c2(this,o&&o.node,e);h2(this.node,this.innerDeco,(u,c,d)=>{u.spec.marks?l.syncToMarks(u.spec.marks,r,e):u.type.side>=0&&!d&&l.syncToMarks(c==this.node.childCount?ye.none:this.node.child(c).marks,r,e),l.placeWidget(u,e,i)},(u,c,d,f)=>{l.syncToMarks(u.marks,r,e);let h;l.findNodeMatch(u,c,d,f)||a&&e.state.selection.from>i&&e.state.selection.to-1&&l.updateNodeAt(u,c,d,h,e)||l.updateNextNode(u,c,d,e,f,i)||l.addNode(u,c,d,e,i),i+=u.nodeSize}),l.syncToMarks([],r,e),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||this.dirty==sr)&&(o&&this.protectLocalComposition(e,o),h0(this.contentDOM,this.children,e),ni&&p2(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof X)||rn+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let o=s.nodeValue,a=m2(this.node.content,o,r-n,i-n);return a<0?null:{node:s,pos:a,text:o}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:i}){if(this.getDesc(n))return;let s=n;for(;s.parentNode!=this.contentDOM;s=s.parentNode){for(;s.previousSibling;)s.parentNode.removeChild(s.previousSibling);for(;s.nextSibling;)s.parentNode.removeChild(s.nextSibling);s.pmViewDesc&&(s.pmViewDesc=void 0)}let o=new a2(this,s,n,i);e.input.compositionNodes.push(o),this.children=ou(this.children,r,r+i.length,e,o)}update(e,n,r,i){return this.dirty==sn||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,i),!0)}updateInner(e,n,r,i){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=Lt}updateOuterDeco(e){if(su(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=p0(this.dom,this.nodeDOM,iu(this.outerDeco,this.node,n),iu(e,this.node,n)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.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 Cd(t,e,n,r,i){m0(r,e,t);let s=new zn(void 0,t,e,n,r,r,r,i,0);return s.contentDOM&&s.updateChildren(i,0),s}class pa extends zn{constructor(e,n,r,i,s,o,a){super(e,n,r,i,s,null,o,a,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,i){return this.dirty==sn||this.dirty!=Lt&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=Lt||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=Lt,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let i=this.node.cut(e,n),s=document.createTextNode(i.text);return new pa(this.parent,i,this.outerDeco,this.innerDeco,s,s,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=sn)}get domAtom(){return!1}isText(e){return this.node.text==e}}class f0 extends bs{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Lt&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class l2 extends zn{constructor(e,n,r,i,s,o,a,l,u,c){super(e,n,r,i,s,o,a,u,c),this.spec=l}update(e,n,r,i){if(this.dirty==sn)return!1;if(this.spec.update){let s=this.spec.update(e,n,r);return s&&this.updateInner(e,n,r,i),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,i){this.spec.setSelection?this.spec.setSelection(e,n,r):super.setSelection(e,n,r,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function h0(t,e,n){let r=t.firstChild,i=!1;for(let s=0;s>1,o=Math.min(s,e.length);for(;i-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{let l=yr.create(this.top,e[s],n,r);this.top.children.splice(this.index,0,l),this.top=l,this.changed=!0}this.index=0,s++}}findNodeMatch(e,n,r,i){let s=-1,o;if(i>=this.preMatch.index&&(o=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&o.matchesNode(e,n,r))s=this.top.children.indexOf(o,this.index);else for(let a=this.index,l=Math.min(this.top.children.length,a+5);a0;){let a;for(;;)if(r){let u=n.children[r-1];if(u instanceof yr)n=u,r=u.children.length;else{a=u,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let l=a.node;if(l){if(l!=t.child(i-1))break;--i,s.set(a,i),o.push(a)}}return{index:i,matched:s,matches:o.reverse()}}function f2(t,e){return t.type.side-e.type.side}function h2(t,e,n,r){let i=e.locals(t),s=0;if(i.length==0){for(let u=0;us;)a.push(i[o++]);let p=s+f.nodeSize;if(f.isText){let g=p;o!g.inline):a.slice();r(f,m,e.forChild(s,f),h),s=p}}function p2(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}function m2(t,e,n,r){for(let i=0,s=0;i=n){if(s>=r&&l.slice(r-e.length-a,r-a)==e)return r-e.length;let u=a=0&&u+e.length+a>=n)return a+u;if(n==r&&l.length>=r+e.length-a&&l.slice(r-a,r-a+e.length)==e)return r}}return-1}function ou(t,e,n,r,i){let s=[];for(let o=0,a=0;o=n||c<=e?s.push(l):(un&&s.push(l.slice(n-u,l.size,r)))}return s}function Zu(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let i=t.docView.nearestDesc(n.focusNode),s=i&&i.size==0,o=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let a=r.resolve(o),l,u;if(ha(n)){for(l=a;i&&!i.node;)i=i.parent;let c=i.node;if(i&&c.isAtom&&ee.isSelectable(c)&&i.parent&&!(c.isInline&&$b(n.focusNode,n.focusOffset,i.dom))){let d=i.posBefore;u=new ee(o==d?a:r.resolve(d))}}else{let c=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(c<0)return null;l=r.resolve(c)}if(!u){let c=e=="pointer"||t.state.selection.head{(n.anchorNode!=r||n.anchorOffset!=i)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!g0(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function b2(t){let e=t.domSelection(),n=document.createRange(),r=t.cursorWrapper.dom,i=r.nodeName=="IMG";i?n.setEnd(r.parentNode,Je(r)+1):n.setEnd(r,0),n.collapse(!1),e.removeAllRanges(),e.addRange(n),!i&&!t.state.selection.visible&&ht&&$n<=11&&(r.disabled=!0,r.disabled=!1)}function b0(t,e){if(e instanceof ee){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(Td(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else Td(t)}function Td(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Ku(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||X.between(e,n,r)}function Dd(t){return t.editable&&!t.hasFocus()?!1:y0(t)}function y0(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function y2(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return br(e.node,e.offset,n.anchorNode,n.anchorOffset)}function au(t,e){let{$anchor:n,$head:r}=t.selection,i=e>0?n.max(r):n.min(r),s=i.parent.inlineContent?i.depth?t.doc.resolve(e>0?i.after():i.before()):null:i;return s&&ne.findFrom(s,e)}function wn(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function Od(t,e,n){let r=t.state.selection;if(r instanceof X)if(n.indexOf("s")>-1){let{$head:i}=r,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let o=t.state.doc.resolve(i.pos+s.nodeSize*(e<0?-1:1));return wn(t,new X(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=au(t.state,e);return i&&i instanceof ee?wn(t,i):!1}else if(!(Dt&&n.indexOf("m")>-1)){let i=r.$head,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,o;if(!s||s.isText)return!1;let a=e<0?i.pos-s.nodeSize:i.pos;return s.isAtom||(o=t.docView.descAt(a))&&!o.contentDOM?ee.isSelectable(s)?wn(t,new ee(e<0?t.state.doc.resolve(i.pos-s.nodeSize):i)):gs?wn(t,new X(t.state.doc.resolve(e<0?a:a+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof ee&&r.node.isInline)return wn(t,new X(e>0?r.$to:r.$from));{let i=au(t.state,e);return i?wn(t,i):!1}}}function vo(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Li(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function Tr(t,e){return e<0?x2(t):k2(t)}function x2(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,s,o=!1;for(zt&&n.nodeType==1&&r0){if(n.nodeType!=1)break;{let a=n.childNodes[r-1];if(Li(a,-1))i=n,s=--r;else if(a.nodeType==3)n=a,r=n.nodeValue.length;else break}}else{if(x0(n))break;{let a=n.previousSibling;for(;a&&Li(a,-1);)i=n.parentNode,s=Je(a),a=a.previousSibling;if(a)n=a,r=vo(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?lu(t,n,r):i&&lu(t,i,s)}function k2(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=vo(n),s,o;for(;;)if(r{t.state==i&&kn(t)},50)}function Nd(t,e){let n=t.state.doc.resolve(e);if(!(st||qb)&&n.parent.inlineContent){let i=t.coordsAtPos(e);if(e>n.start()){let s=t.coordsAtPos(e-1),o=(s.top+s.bottom)/2;if(o>i.top&&o1)return s.lefti.top&&o1)return s.left>i.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function Ld(t,e,n){let r=t.state.selection;if(r instanceof X&&!r.empty||n.indexOf("s")>-1||Dt&&n.indexOf("m")>-1)return!1;let{$from:i,$to:s}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=au(t.state,e);if(o&&o instanceof ee)return wn(t,o)}if(!i.parent.inlineContent){let o=e<0?i:s,a=r instanceof Nt?ne.near(o,e):ne.findFrom(o,e);return a?wn(t,a):!1}return!1}function Rd(t,e){if(!(t.state.selection instanceof X))return!0;let{$head:n,$anchor:r,empty:i}=t.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(s&&!s.isText){let o=t.state.tr;return e<0?o.delete(n.pos-s.nodeSize,n.pos):o.delete(n.pos,n.pos+s.nodeSize),t.dispatch(o),!0}return!1}function Id(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function _2(t){if(!ot||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&e.nodeType==1&&n==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;Id(t,r,"true"),setTimeout(()=>Id(t,r,"false"),20)}return!1}function C2(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function w2(t,e){let n=e.keyCode,r=C2(e);if(n==8||Dt&&n==72&&r=="c")return Rd(t,-1)||Tr(t,-1);if(n==46&&!e.shiftKey||Dt&&n==68&&r=="c")return Rd(t,1)||Tr(t,1);if(n==13||n==27)return!0;if(n==37||Dt&&n==66&&r=="c"){let i=n==37?Nd(t,t.state.selection.from)=="ltr"?-1:1:-1;return Od(t,i,r)||Tr(t,i)}else if(n==39||Dt&&n==70&&r=="c"){let i=n==39?Nd(t,t.state.selection.from)=="ltr"?1:-1:1;return Od(t,i,r)||Tr(t,i)}else{if(n==38||Dt&&n==80&&r=="c")return Ld(t,-1,r)||Tr(t,-1);if(n==40||Dt&&n==78&&r=="c")return _2(t)||Ld(t,1,r)||Tr(t,1);if(r==(Dt?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function k0(t,e){t.someProp("transformCopied",h=>{e=h(e,t)});let n=[],{content:r,openStart:i,openEnd:s}=e;for(;i>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,s--;let h=r.firstChild;n.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let o=t.someProp("clipboardSerializer")||Yt.fromSchema(t.state.schema),a=S0(),l=a.createElement("div");l.appendChild(o.serializeFragment(r,{document:a}));let u=l.firstChild,c,d=0;for(;u&&u.nodeType==1&&(c=w0[u.nodeName.toLowerCase()]);){for(let h=c.length-1;h>=0;h--){let p=a.createElement(c[h]);for(;l.firstChild;)p.appendChild(l.firstChild);l.appendChild(p),d++}u=l.firstChild}u&&u.nodeType==1&&u.setAttribute("data-pm-slice",`${i} ${s}${d?` -${d}`:""} ${JSON.stringify(n)}`);let f=t.someProp("clipboardTextSerializer",h=>h(e,t))||e.content.textBetween(0,e.content.size,` +"use strict";var Vg=Object.defineProperty;var Ug=(t,e,n)=>e in t?Vg(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var H=(t,e,n)=>(Ug(t,typeof e!="symbol"?e+"":e,n),n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function Ge(t){this.content=t}Ge.prototype={constructor:Ge,find:function(t){for(var e=0;e>1}};Ge.from=function(t){if(t instanceof Ge)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new Ge(e)};function Ap(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let i=t.child(r),s=e.child(r);if(i==s){n+=i.nodeSize;continue}if(!i.sameMarkup(s))return n;if(i.isText&&i.text!=s.text){for(let o=0;i.text[o]==s.text[o];o++)n++;return n}if(i.content.size||s.content.size){let o=Ap(i.content,s.content,n+1);if(o!=null)return o}n+=i.nodeSize}}function Mp(t,e,n,r){for(let i=t.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:n,b:r};let o=t.child(--i),a=e.child(--s),l=o.nodeSize;if(o==a){n-=l,r-=l;continue}if(!o.sameMarkup(a))return{a:n,b:r};if(o.isText&&o.text!=a.text){let u=0,c=Math.min(o.text.length,a.text.length);for(;ue&&r(l,i+a,s||null,o)!==!1&&l.content.size){let c=a+1;l.nodesBetween(Math.max(0,e-c),Math.min(l.content.size,n-c),r,i+c)}a=u}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,i){let s="",o=!0;return this.nodesBetween(e,n,(a,l)=>{let u=a.isText?a.text.slice(Math.max(e,l)-l,n-l):a.isLeaf?i?typeof i=="function"?i(a):i:a.type.spec.leafText?a.type.spec.leafText(a):"":"";a.isBlock&&(a.isLeaf&&u||a.isTextblock)&&r&&(o?o=!1:s+=r),s+=u},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,i=this.content.slice(),s=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),s=1);se)for(let s=0,o=0;oe&&((on)&&(a.isText?a=a.cut(Math.max(0,e-o),Math.min(a.text.length,n-o)):a=a.cut(Math.max(0,e-o-1),Math.min(a.content.size,n-o-1))),r.push(a),i+=a.nodeSize),o=l}return new O(r,i)}cutByIndex(e,n){return e==n?O.empty:e==0&&n==this.content.length?this:new O(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let i=this.content.slice(),s=this.size+n.nodeSize-r.nodeSize;return i[e]=n,new O(i,s)}addToStart(e){return new O([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new O(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;nthis.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let r=0,i=0;;r++){let s=this.child(r),o=i+s.nodeSize;if(o>=e)return o==e||n>0?Ns(r+1,o):Ns(r,i);i=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return O.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new O(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return O.empty;let n,r=0;for(let i=0;ithis.type.rank&&(n||(n=e.slice(0,i)),n.push(this),r=!0),n&&n.push(s)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;nr.type.rank-i.type.rank),n}};ye.none=[];class mo extends Error{}class P{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=Dp(this.content,e+this.openStart,n);return r&&new P(r,this.openStart,this.openEnd)}removeBetween(e,n){return new P(Tp(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return P.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new P(O.fromJSON(e,n.content),r,i)}static maxOpen(e,n=!0){let r=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(n||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(n||!s.type.spec.isolating);s=s.lastChild)i++;return new P(e,r,i)}}P.empty=new P(O.empty,0,0);function Tp(t,e,n){let{index:r,offset:i}=t.findIndex(e),s=t.maybeChild(r),{index:o,offset:a}=t.findIndex(n);if(i==e||s.isText){if(a!=n&&!t.child(o).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(r,s.copy(Tp(s.content,e-i-1,n-i-1)))}function Dp(t,e,n,r){let{index:i,offset:s}=t.findIndex(e),o=t.maybeChild(i);if(s==e||o.isText)return r&&!r.canReplace(i,i,n)?null:t.cut(0,e).append(n).append(t.cut(e));let a=Dp(o.content,e-s-1,n);return a&&t.replaceChild(i,o.copy(a))}function qg(t,e,n){if(n.openStart>t.depth)throw new mo("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new mo("Inconsistent open depths");return Op(t,e,n,0)}function Op(t,e,n,r){let i=t.index(r),s=t.node(r);if(i==e.index(r)&&r=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function Di(t,e,n,r){let i=(e||t).node(n),s=0,o=e?e.index(n):i.childCount;t&&(s=t.index(n),t.depth>n?s++:t.textOffset&&(lr(t.nodeAfter,r),s++));for(let a=s;ai&&Gl(t,e,i+1),o=r.depth>i&&Gl(n,r,i+1),a=[];return Di(null,t,i,a),s&&o&&e.index(i)==n.index(i)?(Np(s,o),lr(ur(s,Lp(t,e,n,r,i+1)),a)):(s&&lr(ur(s,go(t,e,i+1)),a),Di(e,n,i,a),o&&lr(ur(o,go(n,r,i+1)),a)),Di(r,null,i,a),new O(a)}function go(t,e,n){let r=[];if(Di(null,t,n,r),t.depth>n){let i=Gl(t,e,n+1);lr(ur(i,go(t,e,n+1)),r)}return Di(e,null,n,r),new O(r)}function Zg(t,e){let n=e.depth-t.openStart,i=e.node(n).copy(t.content);for(let s=n-1;s>=0;s--)i=e.node(s).copy(O.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class zi{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(n);return r?e.child(n).cut(r):i}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],i=n==0?0:this.path[n*3-1]+1;for(let s=0;s0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new bo(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],i=0,s=n;for(let o=e;;){let{index:a,offset:l}=o.content.findIndex(s),u=s-l;if(r.push(o,a,i+l),!u||(o=o.child(a),o.isText))break;s=u-1,i+=l+1}return new zi(n,r,s)}static resolveCached(e,n){for(let i=0;ie&&this.nodesBetween(e,n,s=>(r.isInSet(s.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Rp(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=O.empty,i=0,s=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,i,s),a=o&&o.matchFragment(this.content,n);if(!a||!a.validEnd)return!1;for(let l=i;ln.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r=null;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let i=O.fromJSON(e,n.content);return e.nodeType(n.type).create(n.attrs,i,r)}};cr.prototype.text=void 0;class yo extends cr{constructor(e,n,r,i){if(super(e,n,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Rp(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new yo(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new yo(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function Rp(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class gr{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new jg(e,n);if(r.next==null)return gr.empty;let i=Ip(r);r.next&&r.err("Unexpected trailing text");let s=tb(eb(i));return nb(s,r),s}matchType(e){for(let n=0;nu.createAndFill()));for(let u=0;u=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let i=0;i{let s=i+(r.validEnd?"*":" ")+" ";for(let o=0;o"+e.indexOf(r.next[o].next);return s}).join(` +`)}}gr.empty=new gr(!0);class jg{constructor(e,n){this.string=e,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function Ip(t){let e=[];do e.push(Gg(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Gg(t){let e=[];do e.push(Jg(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Jg(t){let e=Qg(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=Yg(t,e);else break;return e}function td(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function Yg(t,e){let n=td(t),r=n;return t.eat(",")&&(t.next!="}"?r=td(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function Xg(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let i=[];for(let s in n){let o=n[s];o.groups.indexOf(e)>-1&&i.push(o)}return i.length==0&&t.err("No node type or group '"+e+"' found"),i}function Qg(t){if(t.eat("(")){let e=Ip(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=Xg(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err("Mixing inline and block content"),{type:"name",value:n}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function eb(t){let e=[[]];return i(s(t,0),n()),e;function n(){return e.push([])-1}function r(o,a,l){let u={term:l,to:a};return e[o].push(u),u}function i(o,a){o.forEach(l=>l.to=a)}function s(o,a){if(o.type=="choice")return o.exprs.reduce((l,u)=>l.concat(s(u,a)),[]);if(o.type=="seq")for(let l=0;;l++){let u=s(o.exprs[l],a);if(l==o.exprs.length-1)return u;i(u,a=n())}else if(o.type=="star"){let l=n();return r(a,l),i(s(o.expr,l),l),[r(l)]}else if(o.type=="plus"){let l=n();return i(s(o.expr,a),l),i(s(o.expr,l),l),[r(l)]}else{if(o.type=="opt")return[r(a)].concat(s(o.expr,a));if(o.type=="range"){let l=a;for(let u=0;u{t[o].forEach(({term:a,to:l})=>{if(!a)return;let u;for(let c=0;c{u||i.push([a,u=[]]),u.indexOf(c)==-1&&u.push(c)})})});let s=e[r.join(",")]=new gr(r.indexOf(t.length-1)>-1);for(let o=0;o-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;nr[s]=new $p(s,n,o));let i=n.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let s in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};class rb{constructor(e){this.hasDefault=Object.prototype.hasOwnProperty.call(e,"default"),this.default=e.default}get isRequired(){return!this.hasDefault}}class ua{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=Pp(i.attrs),this.excluded=null;let s=Hp(this.attrs);this.instance=s?new ye(this,s):null}create(e=null){return!e&&this.instance?this.instance:new ye(this,Bp(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((s,o)=>r[s]=new ua(s,i++,n,o)),r}removeFromSet(e){for(var n=0;n-1}}class zp{constructor(e){this.cached=Object.create(null);let n=this.spec={};for(let i in e)n[i]=e[i];n.nodes=Ge.from(e.nodes),n.marks=Ge.from(e.marks||{}),this.nodes=rd.compile(this.spec.nodes,this),this.marks=ua.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let s=this.nodes[i],o=s.spec.content||"",a=s.spec.marks;s.contentMatch=r[o]||(r[o]=gr.parse(o,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.markSet=a=="_"?null:a?id(this,a.split(" ")):a==""||!s.inlineContent?[]:null}for(let i in this.marks){let s=this.marks[i],o=s.spec.excludes;s.excluded=o==null?[s]:o==""?[]:id(this,o.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,n=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof rd){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,r,i)}text(e,n){let r=this.nodes.text;return new yo(r,r.defaultAttrs,e,ye.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeFromJSON(e){return cr.fromJSON(this,e)}markFromJSON(e){return ye.fromJSON(this,e)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}}function id(t,e){let n=[];for(let r=0;r-1)&&n.push(o=l)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}let ps=class Yl{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[],n.forEach(r=>{r.tag?this.tags.push(r):r.style&&this.styles.push(r)}),this.normalizeLists=!this.tags.some(r=>{if(!/^(ul|ol)\b/.test(r.tag)||!r.node)return!1;let i=e.nodes[r.node];return i.contentMatch.matchType(i)})}parse(e,n={}){let r=new od(this,n,!1);return r.addAll(e,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new od(this,n,!0);return r.addAll(e,n.from,n.to),P.maxOpen(r.finish())}matchTag(e,n,r){for(let i=r?this.tags.indexOf(r)+1:0;ie.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=n))){if(o.getAttrs){let l=o.getAttrs(n);if(l===!1)continue;o.attrs=l||void 0}return o}}}static schemaRules(e){let n=[];function r(i){let s=i.priority==null?50:i.priority,o=0;for(;o{r(o=ad(o)),o.mark||o.ignore||o.clearMark||(o.mark=i)})}for(let i in e.nodes){let s=e.nodes[i].spec.parseDOM;s&&s.forEach(o=>{r(o=ad(o)),o.node||o.ignore||o.mark||(o.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Yl(e,Yl.schemaRules(e)))}};const Vp={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},ib={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Up={ol:!0,ul:!0},xo=1,ko=2,Oi=4;function sd(t,e,n){return e!=null?(e?xo:0)|(e==="full"?ko:0):t&&t.whitespace=="pre"?xo|ko:n&~Oi}class Ls{constructor(e,n,r,i,s,o,a){this.type=e,this.attrs=n,this.marks=r,this.pendingMarks=i,this.solid=s,this.options=a,this.content=[],this.activeMarks=ye.none,this.stashMarks=[],this.match=o||(a&Oi?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(O.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&xo)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let s=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-i[0].length))}}let n=O.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(O.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}popFromStashMark(e){for(let n=this.stashMarks.length-1;n>=0;n--)if(e.eq(this.stashMarks[n]))return this.stashMarks.splice(n,1)[0]}applyPending(e){for(let n=0,r=this.pendingMarks;nthis.addAll(e)),o&&this.sync(a),this.needsBlock=l}else this.withStyleRules(e,()=>{this.addElementByRule(e,s,s.consuming===!1?i:void 0)})}leafFallback(e){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(` +`))}ignoreFallback(e){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"))}readStyles(e){let n=ye.none,r=ye.none;for(let i=0;i{o.clearMark(a)&&(r=a.addToSet(r))}):n=this.parser.schema.marks[o.mark].create(o.attrs).addToSet(n),o.consuming===!1)s=o;else break}return[n,r]}addElementByRule(e,n,r){let i,s,o;n.node?(s=this.parser.schema.nodes[n.node],s.isLeaf?this.insertNode(s.create(n.attrs))||this.leafFallback(e):i=this.enter(s,n.attrs||null,n.preserveWhitespace)):(o=this.parser.schema.marks[n.mark].create(n.attrs),this.addPendingMark(o));let a=this.top;if(s&&s.isLeaf)this.findInside(e);else if(r)this.addElement(e,r);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(l=>this.insertNode(l));else{let l=e;typeof n.contentElement=="string"?l=e.querySelector(n.contentElement):typeof n.contentElement=="function"?l=n.contentElement(e):n.contentElement&&(l=n.contentElement),this.findAround(e,l,!0),this.addAll(l)}i&&this.sync(a)&&this.open--,o&&this.removePendingMark(o,a)}addAll(e,n,r){let i=n||0;for(let s=n?e.childNodes[n]:e.firstChild,o=r==null?null:e.childNodes[r];s!=o;s=s.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(s);this.findAtPoint(e,i)}findPlace(e){let n,r;for(let i=this.open;i>=0;i--){let s=this.nodes[i],o=s.findWrapping(e);if(o&&(!n||n.length>o.length)&&(n=o,r=s,!o.length)||s.solid)break}if(!n)return!1;this.sync(r);for(let i=0;ithis.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)}sync(e){for(let n=this.open;n>=0;n--)if(this.nodes[n]==e)return this.open=n,!0;return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),s=-(r?r.depth+1:0)+(i?0:1),o=(a,l)=>{for(;a>=0;a--){let u=n[a];if(u==""){if(a==n.length-1||a==0)continue;for(;l>=s;l--)if(o(a-1,l))return!0;return!1}else{let c=l>0||l==0&&i?this.nodes[l].type:r&&l>=s?r.node(l-s).type:null;if(!c||c.name!=u&&c.groups.indexOf(u)==-1)return!1;l--}}return!0};return o(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}addPendingMark(e){let n=ub(e,this.top.pendingMarks);n&&this.top.stashMarks.push(n),this.top.pendingMarks=e.addToSet(this.top.pendingMarks)}removePendingMark(e,n){for(let r=this.open;r>=0;r--){let i=this.nodes[r];if(i.pendingMarks.lastIndexOf(e)>-1)i.pendingMarks=e.removeFromSet(i.pendingMarks);else{i.activeMarks=e.removeFromSet(i.activeMarks);let o=i.popFromStashMark(e);o&&i.type&&i.type.allowsMarkType(o.type)&&(i.activeMarks=o.addToSet(i.activeMarks))}if(i==n)break}}}function sb(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Up.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function ob(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function ab(t){let e=/\s*([\w-]+)\s*:\s*([^;]+)/g,n,r=[];for(;n=e.exec(t);)r.push(n[1],n[2].trim());return r}function ad(t){let e={};for(let n in t)e[n]=t[n];return e}function lb(t,e){let n=e.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(t))continue;let s=[],o=a=>{s.push(a);for(let l=0;l{if(s.length||o.marks.length){let a=0,l=0;for(;a=0;i--){let s=this.serializeMark(e.marks[i],e.isInline,n);s&&((s.contentDOM||s.dom).appendChild(r),r=s.dom)}return r}serializeMark(e,n,r={}){let i=this.marks[e.type.name];return i&&Yt.renderSpec(Ya(r),i(e,n))}static renderSpec(e,n,r=null){if(typeof n=="string")return{dom:e.createTextNode(n)};if(n.nodeType!=null)return{dom:n};if(n.dom&&n.dom.nodeType!=null)return n;let i=n[0],s=i.indexOf(" ");s>0&&(r=i.slice(0,s),i=i.slice(s+1));let o,a=r?e.createElementNS(r,i):e.createElement(i),l=n[1],u=1;if(l&&typeof l=="object"&&l.nodeType==null&&!Array.isArray(l)){u=2;for(let c in l)if(l[c]!=null){let d=c.indexOf(" ");d>0?a.setAttributeNS(c.slice(0,d),c.slice(d+1),l[c]):a.setAttribute(c,l[c])}}for(let c=u;cu)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:f,contentDOM:h}=Yt.renderSpec(e,d,r);if(a.appendChild(f),h){if(o)throw new RangeError("Multiple content holes");o=h}}}return{dom:a,contentDOM:o}}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Yt(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=ld(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return ld(e.marks)}}function ld(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Ya(t){return t.document||window.document}const qp=65535,Zp=Math.pow(2,16);function cb(t,e){return t+e*Zp}function ud(t){return t&qp}function db(t){return(t-(t&qp))/Zp}const Kp=1,Wp=2,so=4,jp=8;class Xl{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&jp)>0}get deletedBefore(){return(this.delInfo&(Kp|so))>0}get deletedAfter(){return(this.delInfo&(Wp|so))>0}get deletedAcross(){return(this.delInfo&so)>0}}class vt{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&vt.empty)return vt.empty}recover(e){let n=0,r=ud(e);if(!this.inverted)for(let i=0;ie)break;let u=this.ranges[a+s],c=this.ranges[a+o],d=l+u;if(e<=d){let f=u?e==l?-1:e==d?1:n:n,h=l+i+(f<0?0:c);if(r)return h;let p=e==(n<0?l:d)?null:cb(a/3,e-l),m=e==l?Wp:e==d?Kp:so;return(n<0?e!=l:e!=d)&&(m|=jp),new Xl(h,m,p)}i+=c-u}return r?e+i:new Xl(e+i,0,null)}touches(e,n){let r=0,i=ud(n),s=this.inverted?2:1,o=this.inverted?1:2;for(let a=0;ae)break;let u=this.ranges[a+s],c=l+u;if(e<=c&&a==i*3)return!0;r+=this.ranges[a+o]-u}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,s=0;i=0;n--){let i=e.getMirror(n);this.appendMap(e.maps[n].invert(),i!=null&&i>n?r-i-1:void 0)}}invert(){let e=new Gr;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;rs&&l!o.isAtom||!a.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),i),n.openStart,n.openEnd);return He.fromReplace(e,this.from,this.to,s)}invert(){return new Xt(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Ln(n.pos,r.pos,this.mark)}merge(e){return e instanceof Ln&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ln(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Ln(n.from,n.to,e.markFromJSON(n.mark))}}nt.jsonID("addMark",Ln);class Xt extends nt{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new P($u(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return He.fromReplace(e,this.from,this.to,r)}invert(){return new Ln(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Xt(n.pos,r.pos,this.mark)}merge(e){return e instanceof Xt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Xt(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Xt(n.from,n.to,e.markFromJSON(n.mark))}}nt.jsonID("removeMark",Xt);class Rn extends nt{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return He.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return He.fromReplace(e,this.pos,this.pos+1,new P(O.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let i=0;ir.pos?null:new Ue(n.pos,r.pos,i,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Ue(n.from,n.to,n.gapFrom,n.gapTo,P.fromJSON(e,n.slice),n.insert,!!n.structure)}}nt.jsonID("replaceAround",Ue);function Ql(t,e,n){let r=t.resolve(e),i=n-e,s=r.depth;for(;i>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,i--;if(i>0){let o=r.node(s).maybeChild(r.indexAfter(s));for(;i>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,i--}}return!1}function fb(t,e,n,r){let i=[],s=[],o,a;t.doc.nodesBetween(e,n,(l,u,c)=>{if(!l.isInline)return;let d=l.marks;if(!r.isInSet(d)&&c.type.allowsMarkType(r.type)){let f=Math.max(u,e),h=Math.min(u+l.nodeSize,n),p=r.addToSet(d);for(let m=0;mt.step(l)),s.forEach(l=>t.step(l))}function hb(t,e,n,r){let i=[],s=0;t.doc.nodesBetween(e,n,(o,a)=>{if(!o.isInline)return;s++;let l=null;if(r instanceof ua){let u=o.marks,c;for(;c=r.isInSet(u);)(l||(l=[])).push(c),u=c.removeFromSet(u)}else r?r.isInSet(o.marks)&&(l=[r]):l=o.marks;if(l&&l.length){let u=Math.min(a+o.nodeSize,n);for(let c=0;ct.step(new Xt(o.from,o.to,o.style)))}function pb(t,e,n,r=n.contentMatch){let i=t.doc.nodeAt(e),s=[],o=e+1;for(let a=0;a=0;a--)t.step(s[a])}function mb(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function mi(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth;;--r){let i=t.$from.node(r),s=t.$from.index(r),o=t.$to.indexAfter(r);if(rn;p--)m||r.index(p)>0?(m=!0,c=O.from(r.node(p).copy(c)),d++):l--;let f=O.empty,h=0;for(let p=s,m=!1;p>n;p--)m||i.after(p+1)=0;o--){if(r.size){let a=n[o].type.contentMatch.matchFragment(r);if(!a||!a.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=O.from(n[o].type.create(n[o].attrs,r))}let i=e.start,s=e.end;t.step(new Ue(i,s,i,s,new P(r,0,0),n.length,!0))}function kb(t,e,n,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=t.steps.length;t.doc.nodesBetween(e,n,(o,a)=>{if(o.isTextblock&&!o.hasMarkup(r,i)&&vb(t.doc,t.mapping.slice(s).map(a),r)){t.clearIncompatible(t.mapping.slice(s).map(a,1),r);let l=t.mapping.slice(s),u=l.map(a,1),c=l.map(a+o.nodeSize,1);return t.step(new Ue(u,c,u+1,c-1,new P(O.from(r.create(i,null,o.marks)),0,0),1,!0)),!1}})}function vb(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function Eb(t,e,n,r,i){let s=t.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");n||(n=s.type);let o=n.create(r,null,i||s.marks);if(s.isLeaf)return t.replaceWith(e,e+s.nodeSize,o);if(!n.validContent(s.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new Ue(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new P(O.from(o),0,0),1,!0))}function Jr(t,e,n=1,r){let i=t.resolve(e),s=i.depth-n,o=r&&r[r.length-1]||i.parent;if(s<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let u=i.depth-1,c=n-2;u>s;u--,c--){let d=i.node(u),f=i.index(u);if(d.type.spec.isolating)return!1;let h=d.content.cutByIndex(f,d.childCount),p=r&&r[c+1];p&&(h=h.replaceChild(0,p.type.create(p.attrs)));let m=r&&r[c]||d;if(!d.canReplace(f+1,d.childCount)||!m.type.validContent(h))return!1}let a=i.indexAfter(s),l=r&&r[0];return i.node(s).canReplaceWith(a,a,l?l.type:i.node(s+1).type)}function _b(t,e,n=1,r){let i=t.doc.resolve(e),s=O.empty,o=O.empty;for(let a=i.depth,l=i.depth-n,u=n-1;a>l;a--,u--){s=O.from(i.node(a).copy(s));let c=r&&r[u];o=O.from(c?c.type.create(c.attrs,o):i.node(a).copy(o))}t.step(new ze(e,e,new P(s.append(o),n,n),!0))}function Gn(t,e){let n=t.resolve(e),r=n.index();return Gp(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function Gp(t,e){return!!(t&&e&&!t.isLeaf&&t.canAppend(e))}function ca(t,e,n=-1){let r=t.resolve(e);for(let i=r.depth;;i--){let s,o,a=r.index(i);if(i==r.depth?(s=r.nodeBefore,o=r.nodeAfter):n>0?(s=r.node(i+1),a++,o=r.node(i).maybeChild(a)):(s=r.node(i).maybeChild(a-1),o=r.node(i+1)),s&&!s.isTextblock&&Gp(s,o)&&r.node(i).canReplace(a,a+1))return e;if(i==0)break;e=n<0?r.before(i):r.after(i)}}function Cb(t,e,n){let r=new ze(e-n,e+n,P.empty,!0);t.step(r)}function wb(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let s=r.index(i);if(r.node(i).canReplaceWith(s,s,n))return r.before(i+1);if(s>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let s=r.indexAfter(i);if(r.node(i).canReplaceWith(s,s,n))return r.after(i+1);if(s=0;o--){let a=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,l=r.index(o)+(a>0?1:0),u=r.node(o),c=!1;if(s==1)c=u.canReplace(l,l,i);else{let d=u.contentMatchAt(l).findWrapping(i.firstChild.type);c=d&&u.canReplaceWith(l,l,d[0])}if(c)return a==0?r.pos:a<0?r.before(o+1):r.after(o+1)}return null}function da(t,e,n=e,r=P.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),s=t.resolve(n);return Yp(i,s,r)?new ze(e,n,r):new Sb(i,s,r).fit()}function Yp(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class Sb{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=O.empty;for(let i=0;i<=e.depth;i++){let s=e.node(i);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=O.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let u=this.findFittable();u?this.placeNodes(u):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let s=this.placed,o=r.depth,a=i.depth;for(;o&&a&&s.childCount==1;)s=s.firstChild.content,o--,a--;let l=new P(s,o,a);return e>-1?new Ue(r.pos,e,this.$to.pos,this.$to.end(),l,n):l.size||r.pos!=this.$to.pos?new ze(r.pos,i.pos,l):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,i=this.unplaced.openEnd;r1&&(i=0),s.type.spec.isolating&&i<=r){e=r;break}n=s.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let i,s=null;r?(s=Qa(this.unplaced.content,r-1).firstChild,i=s.content):i=this.unplaced.content;let o=i.firstChild;for(let a=this.depth;a>=0;a--){let{type:l,match:u}=this.frontier[a],c,d=null;if(n==1&&(o?u.matchType(o.type)||(d=u.fillBefore(O.from(o),!1)):s&&l.compatibleContent(s.type)))return{sliceDepth:r,frontierDepth:a,parent:s,inject:d};if(n==2&&o&&(c=u.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:a,parent:s,wrap:c};if(s&&u.matchType(s.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=Qa(e,n);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new P(e,n+1,Math.max(r,i.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=Qa(e,n);if(i.childCount<=1&&n>0){let s=e.size-n<=n+i.size;this.unplaced=new P(Ai(e,n-1,1),n-1,s?n-1:r)}else this.unplaced=new P(Ai(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:i,wrap:s}){for(;this.depth>n;)this.closeFrontierNode();if(s)for(let m=0;m1||l==0||m.content.size)&&(d=g,c.push(Xp(m.mark(f.allowedMarks(m.marks)),u==1?l:0,u==a.childCount?h:-1)))}let p=u==a.childCount;p||(h=-1),this.placed=Mi(this.placed,n,O.from(c)),this.frontier[n].match=d,p&&h<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=a;m1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:i}=this.frontier[n],s=n=0;a--){let{match:l,type:u}=this.frontier[a],c=el(e,a,u,l,!0);if(!c||c.childCount)continue e}return{depth:n,fit:o,move:s?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=Mi(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let i=e.node(r),s=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,s)}return e}openFrontierNode(e,n=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=Mi(this.placed,this.depth,O.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(O.empty,!0);n.childCount&&(this.placed=Mi(this.placed,this.frontier.length,n))}}function Ai(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Ai(t.firstChild.content,e-1,n)))}function Mi(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Mi(t.lastChild.content,e-1,n)))}function Qa(t,e){for(let n=0;n1&&(r=r.replaceChild(0,Xp(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(O.empty,!0)))),t.copy(r)}function el(t,e,n,r,i){let s=t.node(e),o=i?t.indexAfter(e):t.index(e);if(o==s.childCount&&!n.compatibleContent(s.type))return null;let a=r.fillBefore(s.content,!0,o);return a&&!Ab(n,s.content,o)?a:null}function Ab(t,e,n){for(let r=n;r0;f--,h--){let p=i.node(f).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;o.indexOf(f)>-1?a=f:i.before(f)==h&&o.splice(1,0,-f)}let l=o.indexOf(a),u=[],c=r.openStart;for(let f=r.content,h=0;;h++){let p=f.firstChild;if(u.push(p),h==r.openStart)break;f=p.content}for(let f=c-1;f>=0;f--){let h=u[f],p=Mb(h.type);if(p&&!h.sameMarkup(i.node(Math.abs(a)-1)))c=f;else if(p||!h.type.isTextblock)break}for(let f=r.openStart;f>=0;f--){let h=(f+c+1)%(r.openStart+1),p=u[h];if(p)for(let m=0;m=0&&(t.replace(e,n,r),!(t.steps.length>d));f--){let h=o[f];h<0||(e=i.before(h),n=s.after(h))}}function Qp(t,e,n,r,i){if(er){let s=i.contentMatchAt(0),o=s.fillBefore(t).append(t);t=o.append(s.matchFragment(o).fillBefore(O.empty,!0))}return t}function Db(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=wb(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new P(O.from(r),0,0))}function Ob(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),s=e0(r,i);for(let o=0;o0&&(l||r.node(a-1).canReplace(r.index(a-1),i.indexAfter(a-1))))return t.delete(r.before(a),i.after(a))}for(let o=1;o<=r.depth&&o<=i.depth;o++)if(e-r.start(o)==r.depth-o&&n>r.end(o)&&i.end(o)-n!=i.depth-o)return t.delete(r.before(o),n);t.delete(e,n)}function e0(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let i=r;i>=0;i--){let s=t.start(i);if(se.pos+(e.depth-i)||t.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(s==e.start(i)||i==t.depth&&i==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==s-1)&&n.push(i)}return n}class Yr extends nt{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return He.fail("No node at attribute step's position");let r=Object.create(null);for(let s in n.attrs)r[s]=n.attrs[s];r[this.attr]=this.value;let i=n.type.create(r,null,n.marks);return He.fromReplace(e,this.pos,this.pos+1,new P(O.from(i),0,n.isLeaf?0:1))}getMap(){return vt.empty}invert(e){return new Yr(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Yr(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Yr(n.pos,n.attr,n.value)}}nt.jsonID("attr",Yr);class Vi extends nt{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let i in e.attrs)n[i]=e.attrs[i];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return He.ok(r)}getMap(){return vt.empty}invert(e){return new Vi(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Vi(n.attr,n.value)}}nt.jsonID("docAttr",Vi);let ti=class extends Error{};ti=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};ti.prototype=Object.create(Error.prototype);ti.prototype.constructor=ti;ti.prototype.name="TransformError";class Vu{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Gr}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new ti(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=P.empty){let i=da(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new P(O.from(r),0,0))}delete(e,n){return this.replace(e,n,P.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return Tb(this,e,n,r),this}replaceRangeWith(e,n,r){return Db(this,e,n,r),this}deleteRange(e,n){return Ob(this,e,n),this}lift(e,n){return gb(this,e,n),this}join(e,n=1){return Cb(this,e,n),this}wrap(e,n){return xb(this,e,n),this}setBlockType(e,n=e,r,i=null){return kb(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return Eb(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new Yr(e,n,r)),this}setDocAttribute(e,n){return this.step(new Vi(e,n)),this}addNodeMark(e,n){return this.step(new Rn(e,n)),this}removeNodeMark(e,n){if(!(n instanceof ye)){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n=n.isInSet(r.marks),!n)return this}return this.step(new ei(e,n)),this}split(e,n=1,r){return _b(this,e,n,r),this}addMark(e,n,r){return fb(this,e,n,r),this}removeMark(e,n,r){return hb(this,e,n,r),this}clearIncompatible(e,n,r){return pb(this,e,n,r),this}}const tl=Object.create(null);class ne{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new t0(e.min(n),e.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let n=0;n=0;s--){let o=n<0?Br(e.node(0),e.node(s),e.before(s+1),e.index(s),n,r):Br(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,n,r);if(o)return o}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new Nt(e.node(0))}static atStart(e){return Br(e,e,0,0,1)||new Nt(e)}static atEnd(e){return Br(e,e,e.content.size,e.childCount,-1)||new Nt(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=tl[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in tl)throw new RangeError("Duplicate use of selection JSON ID "+e);return tl[e]=n,n.prototype.jsonID=e,n}getBookmark(){return X.between(this.$anchor,this.$head).getBookmark()}}ne.prototype.visible=!0;class t0{constructor(e,n){this.$from=e,this.$to=n}}let dd=!1;function fd(t){!dd&&!t.parent.inlineContent&&(dd=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class X extends ne{constructor(e,n=e){fd(e),fd(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return ne.near(r);let i=e.resolve(n.map(this.anchor));return new X(i.parent.inlineContent?i:r,r)}replace(e,n=P.empty){if(super.replace(e,n),n==P.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof X&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new fa(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new X(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let i=e.resolve(n);return new this(i,r==n?i:e.resolve(r))}static between(e,n,r){let i=e.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let s=ne.findFrom(n,r,!0)||ne.findFrom(n,-r,!0);if(s)n=s.$head;else return ne.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(ne.findFrom(e,-r,!0)||ne.findFrom(e,r,!0)).$anchor,e.pos0?0:1);i>0?o=0;o+=i){let a=e.child(o);if(a.isAtom){if(!s&&ee.isSelectable(a))return ee.create(t,n-(i<0?a.nodeSize:0))}else{let l=Br(t,a,n+i,i<0?a.childCount:0,i,s);if(l)return l}n+=a.nodeSize*i}return null}function hd(t,e,n){let r=t.steps.length-1;if(r{o==null&&(o=c)}),t.setSelection(ne.near(t.doc.resolve(o),n))}const pd=1,Rs=2,md=4;class Lb extends Vu{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Rs,this}ensureMarks(e){return ye.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&Rs)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~Rs,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||ye.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let i=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),r=r??n,!e)return this.deleteRange(n,r);let s=this.storedMarks;if(!s){let o=this.doc.resolve(n);s=r==n?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,i.text(e,s)),this.selection.empty||this.setSelection(ne.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=md,this}get scrolledIntoView(){return(this.updated&md)>0}}function gd(t,e){return!e||!t?t:t.bind(e)}class Ti{constructor(e,n,r){this.name=e,this.init=gd(n.init,r),this.apply=gd(n.apply,r)}}const Rb=[new Ti("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Ti("selection",{init(t,e){return t.selection||ne.atStart(e.doc)},apply(t){return t.selection}}),new Ti("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Ti("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class nl{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Rb.slice(),n&&n.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Ti(r.key,r.spec.state,r))})}}class qr{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;rr.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],s=i.spec.state;s&&s.toJSON&&(n[r]=s.toJSON.call(i,this[i.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new nl(e.schema,e.plugins),s=new qr(i);return i.fields.forEach(o=>{if(o.name=="doc")s.doc=cr.fromJSON(e.schema,n.doc);else if(o.name=="selection")s.selection=ne.fromJSON(s.doc,n.selection);else if(o.name=="storedMarks")n.storedMarks&&(s.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let a in r){let l=r[a],u=l.spec.state;if(l.key==o.name&&u&&u.fromJSON&&Object.prototype.hasOwnProperty.call(n,a)){s[o.name]=u.fromJSON.call(l,e,n[a],s);return}}s[o.name]=o.init(e,s)}}),s}}function n0(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=n0(i,e,{})),n[r]=i}return n}class we{constructor(e){this.spec=e,this.props={},e.props&&n0(e.props,this,this.props),this.key=e.key?e.key.key:r0("plugin")}getState(e){return e[this.key]}}const rl=Object.create(null);function r0(t){return t in rl?t+"$"+ ++rl[t]:(rl[t]=0,t+"$")}class Te{constructor(e="key"){this.key=r0(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Je=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},Ui=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let eu=null;const bn=function(t,e,n){let r=eu||(eu=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},Ib=function(){eu=null},br=function(t,e,n,r){return n&&(bd(t,e,n,r,-1)||bd(t,e,n,r,1))},Fb=/^(img|br|input|textarea|hr)$/i;function bd(t,e,n,r,i){for(;;){if(t==n&&e==r)return!0;if(e==(i<0?0:Jt(t))){let s=t.parentNode;if(!s||s.nodeType!=1||ms(t)||Fb.test(t.nodeName)||t.contentEditable=="false")return!1;e=Je(t)+(i<0?0:1),t=s}else if(t.nodeType==1){if(t=t.childNodes[e+(i<0?-1:0)],t.contentEditable=="false")return!1;e=i<0?Jt(t):0}else return!1}}function Jt(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Hb(t,e){for(;;){if(t.nodeType==3&&e)return t;if(t.nodeType==1&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1],e=Jt(t)}else if(t.parentNode&&!ms(t))e=Je(t),t=t.parentNode;else return null}}function Bb(t,e){for(;;){if(t.nodeType==3&&e2),Dt=ni||(rn?/Mac/.test(rn.platform):!1),Ub=rn?/Win/.test(rn.platform):!1,Pt=/Android \d/.test(Jn),gs=!!yd&&"webkitFontSmoothing"in yd.documentElement.style,qb=gs?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Zb(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function hn(t,e){return typeof t=="number"?t:t[e]}function Kb(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function xd(t,e,n){let r=t.someProp("scrollThreshold")||0,i=t.someProp("scrollMargin")||5,s=t.dom.ownerDocument;for(let o=n||t.dom;o;o=Ui(o)){if(o.nodeType!=1)continue;let a=o,l=a==s.body,u=l?Zb(s):Kb(a),c=0,d=0;if(e.topu.bottom-hn(r,"bottom")&&(d=e.bottom-e.top>u.bottom-u.top?e.top+hn(i,"top")-u.top:e.bottom-u.bottom+hn(i,"bottom")),e.leftu.right-hn(r,"right")&&(c=e.right-u.right+hn(i,"right")),c||d)if(l)s.defaultView.scrollBy(c,d);else{let f=a.scrollLeft,h=a.scrollTop;d&&(a.scrollTop+=d),c&&(a.scrollLeft+=c);let p=a.scrollLeft-f,m=a.scrollTop-h;e={left:e.left-p,top:e.top-m,right:e.right-p,bottom:e.bottom-m}}if(l||/^(fixed|sticky)$/.test(getComputedStyle(o).position))break}}function Wb(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,i;for(let s=(e.left+e.right)/2,o=n+1;o=n-20){r=a,i=l.top;break}}return{refDOM:r,refTop:i,stack:s0(t.dom)}}function s0(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=Ui(r));return e}function jb({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;o0(n,r==0?0:r-e)}function o0(t,e){for(let n=0;n=a){o=Math.max(p.bottom,o),a=Math.min(p.top,a);let m=p.left>e.left?p.left-e.left:p.right=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!l&&p.left<=e.left&&p.right>=e.left&&(l=c,u={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!n&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(s=d+1)}}return!n&&l&&(n=l,i=u,r=0),n&&n.nodeType==3?Jb(n,i):!n||r&&n.nodeType==1?{node:t,offset:s}:a0(n,i)}function Jb(t,e){let n=t.nodeValue.length,r=document.createRange();for(let i=0;i=(s.left+s.right)/2?1:0)}}return{node:t,offset:0}}function qu(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function Yb(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left(o.left+o.right)/2?1:-1}return t.docView.posFromDOM(r,i,s)}function Qb(t,e,n,r){let i=-1;for(let s=e,o=!1;s!=t.dom;){let a=t.docView.nearestDesc(s,!0);if(!a)return null;if(a.dom.nodeType==1&&(a.node.isBlock&&a.parent&&!o||!a.contentDOM)){let l=a.dom.getBoundingClientRect();if(a.node.isBlock&&a.parent&&!o&&(o=!0,l.left>r.left||l.top>r.top?i=a.posBefore:(l.right-1?i:t.docView.posFromDOM(e,n,-1)}function l0(t,e,n){let r=t.childNodes.length;if(r&&n.tope.top&&i++}let u;gs&&i&&r.nodeType==1&&(u=r.childNodes[i-1]).nodeType==1&&u.contentEditable=="false"&&u.getBoundingClientRect().top>=e.top&&i--,r==t.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?a=t.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(a=Qb(t,r,i,e))}a==null&&(a=Xb(t,o,e));let l=t.docView.nearestDesc(o,!0);return{pos:a,inside:l?l.posAtStart-l.border:-1}}function kd(t){return t.top=0&&i==r.nodeValue.length?(l--,c=1):n<0?l--:u++,ki(Cn(bn(r,l,u),c),c<0)}if(!t.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&i&&(n<0||i==Jt(r))){let l=r.childNodes[i-1];if(l.nodeType==1)return il(l.getBoundingClientRect(),!1)}if(s==null&&i=0)}if(s==null&&i&&(n<0||i==Jt(r))){let l=r.childNodes[i-1],u=l.nodeType==3?bn(l,Jt(l)-(o?0:1)):l.nodeType==1&&(l.nodeName!="BR"||!l.nextSibling)?l:null;if(u)return ki(Cn(u,1),!1)}if(s==null&&i=0)}function ki(t,e){if(t.width==0)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function il(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function c0(t,e,n){let r=t.state,i=t.root.activeElement;r!=e&&t.updateState(e),i!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),i!=t.dom&&i&&i.focus()}}function n2(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return c0(t,e,()=>{let{node:s}=t.docView.domFromPos(i.pos,n=="up"?-1:1);for(;;){let a=t.docView.nearestDesc(s,!0);if(!a)break;if(a.node.isBlock){s=a.contentDOM||a.dom;break}s=a.dom.parentNode}let o=u0(t,i.pos,1);for(let a=s.firstChild;a;a=a.nextSibling){let l;if(a.nodeType==1)l=a.getClientRects();else if(a.nodeType==3)l=bn(a,0,a.nodeValue.length).getClientRects();else continue;for(let u=0;uc.top+1&&(n=="up"?o.top-c.top>(c.bottom-o.top)*2:c.bottom-o.bottom>(o.bottom-c.top)*2))return!1}}return!0})}const r2=/[\u0590-\u08ac]/;function i2(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,s=!i,o=i==r.parent.content.size,a=t.domSelection();return!r2.test(r.parent.textContent)||!a.modify?n=="left"||n=="backward"?s:o:c0(t,e,()=>{let{focusNode:l,focusOffset:u,anchorNode:c,anchorOffset:d}=t.domSelectionRange(),f=a.caretBidiLevel;a.modify("move",n,"character");let h=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:p,focusOffset:m}=t.domSelectionRange(),g=p&&!h.contains(p.nodeType==1?p:p.parentNode)||l==p&&u==m;try{a.collapse(c,d),l&&(l!=c||u!=d)&&a.extend&&a.extend(l,u)}catch{}return f!=null&&(a.caretBidiLevel=f),g})}let vd=null,Ed=null,_d=!1;function s2(t,e,n){return vd==e&&Ed==n?_d:(vd=e,Ed=n,_d=n=="up"||n=="down"?n2(t,e,n):i2(t,e,n))}const Lt=0,Cd=1,sr=2,sn=3;class bs{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=Lt,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;nJe(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!1;break}if(s.previousSibling)break}if(i==null&&n==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!0;break}if(s.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,i=e;i;i=i.parentNode){let s=this.getDesc(i),o;if(s&&(!n||s.node))if(r&&(o=s.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))r=!1;else return s}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let i=e;i;i=i.parentNode){let s=this.getDesc(i);if(s)return s.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;ne||o instanceof f0){i=e-s;break}s=a}if(i)return this.children[r].domFromPos(i-this.children[r].border,n);for(let s;r&&!(s=this.children[r-1]).size&&s instanceof d0&&s.side>=0;r--);if(n<=0){let s,o=!0;for(;s=r?this.children[r-1]:null,!(!s||s.dom.parentNode==this.contentDOM);r--,o=!1);return s&&n&&o&&!s.border&&!s.domAtom?s.domFromPos(s.size,n):{node:this.contentDOM,offset:s?Je(s.dom)+1:0}}else{let s,o=!0;for(;s=r=c&&n<=u-l.border&&l.node&&l.contentDOM&&this.contentDOM.contains(l.contentDOM))return l.parseRange(e,n,c);e=o;for(let d=a;d>0;d--){let f=this.children[d-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){i=Je(f.dom)+1;break}e-=f.size}i==-1&&(i=0)}if(i>-1&&(u>n||a==this.children.length-1)){n=u;for(let c=a+1;ch&&on){let h=a;a=l,l=h}let f=document.createRange();f.setEnd(l.node,l.offset),f.setStart(a.node,a.offset),u.removeAllRanges(),u.addRange(f)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,i=0;i=r:er){let a=r+s.border,l=o-s.border;if(e>=a&&n<=l){this.dirty=e==r||n==o?sr:Cd,e==a&&n==l&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=sn:s.markDirty(e-a,n-a);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?sr:sn}r=o}this.dirty=sr}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?sr:Cd;n.dirty{if(!s)return i;if(s.parent)return s.parent.posBeforeChild(s)})),!n.type.spec.raw){if(o.nodeType!=1){let a=document.createElement("span");a.appendChild(o),o=a}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=n,this.widget=n,s=this}matchesWidget(e){return this.dirty==Lt&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}}class o2 extends bs{constructor(e,n,r,i){super(e,[],n,null),this.textDOM=r,this.text=i}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class yr extends bs{constructor(e,n,r,i){super(e,[],r,i),this.mark=n}static create(e,n,r,i){let s=i.nodeViews[n.type.name],o=s&&s(n,i,r);return(!o||!o.dom)&&(o=Yt.renderSpec(document,n.type.spec.toDOM(n,r))),new yr(e,n,o.dom,o.contentDOM||o.dom)}parseRule(){return this.dirty&sn||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=sn&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=Lt){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty0&&(s=ou(s,0,e,r));for(let a=0;a{if(!l)return o;if(l.parent)return l.parent.posBeforeChild(l)},r,i),c=u&&u.dom,d=u&&u.contentDOM;if(n.isText){if(!c)c=document.createTextNode(n.text);else if(c.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else c||({dom:c,contentDOM:d}=Yt.renderSpec(document,n.type.spec.toDOM(n)));!d&&!n.isText&&c.nodeName!="BR"&&(c.hasAttribute("contenteditable")||(c.contentEditable="false"),n.type.spec.draggable&&(c.draggable=!0));let f=c;return c=m0(c,r,n),u?l=new a2(e,n,r,i,c,d||null,f,u,s,o+1):n.isText?new pa(e,n,r,i,c,f,s):new zn(e,n,r,i,c,d||null,f,s,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>O.empty)}return e}matchesNode(e,n,r){return this.dirty==Lt&&e.eq(this.node)&&su(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,i=n,s=e.composing?this.localCompositionInfo(e,n):null,o=s&&s.pos>-1?s:null,a=s&&s.pos<0,l=new u2(this,o&&o.node,e);f2(this.node,this.innerDeco,(u,c,d)=>{u.spec.marks?l.syncToMarks(u.spec.marks,r,e):u.type.side>=0&&!d&&l.syncToMarks(c==this.node.childCount?ye.none:this.node.child(c).marks,r,e),l.placeWidget(u,e,i)},(u,c,d,f)=>{l.syncToMarks(u.marks,r,e);let h;l.findNodeMatch(u,c,d,f)||a&&e.state.selection.from>i&&e.state.selection.to-1&&l.updateNodeAt(u,c,d,h,e)||l.updateNextNode(u,c,d,e,f,i)||l.addNode(u,c,d,e,i),i+=u.nodeSize}),l.syncToMarks([],r,e),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||this.dirty==sr)&&(o&&this.protectLocalComposition(e,o),h0(this.contentDOM,this.children,e),ni&&h2(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof X)||rn+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let o=s.nodeValue,a=p2(this.node.content,o,r-n,i-n);return a<0?null:{node:s,pos:a,text:o}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:i}){if(this.getDesc(n))return;let s=n;for(;s.parentNode!=this.contentDOM;s=s.parentNode){for(;s.previousSibling;)s.parentNode.removeChild(s.previousSibling);for(;s.nextSibling;)s.parentNode.removeChild(s.nextSibling);s.pmViewDesc&&(s.pmViewDesc=void 0)}let o=new o2(this,s,n,i);e.input.compositionNodes.push(o),this.children=ou(this.children,r,r+i.length,e,o)}update(e,n,r,i){return this.dirty==sn||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,i),!0)}updateInner(e,n,r,i){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=Lt}updateOuterDeco(e){if(su(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=p0(this.dom,this.nodeDOM,iu(this.outerDeco,this.node,n),iu(e,this.node,n)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.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 wd(t,e,n,r,i){m0(r,e,t);let s=new zn(void 0,t,e,n,r,r,r,i,0);return s.contentDOM&&s.updateChildren(i,0),s}class pa extends zn{constructor(e,n,r,i,s,o,a){super(e,n,r,i,s,null,o,a,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,i){return this.dirty==sn||this.dirty!=Lt&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=Lt||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=Lt,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let i=this.node.cut(e,n),s=document.createTextNode(i.text);return new pa(this.parent,i,this.outerDeco,this.innerDeco,s,s,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=sn)}get domAtom(){return!1}isText(e){return this.node.text==e}}class f0 extends bs{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Lt&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class a2 extends zn{constructor(e,n,r,i,s,o,a,l,u,c){super(e,n,r,i,s,o,a,u,c),this.spec=l}update(e,n,r,i){if(this.dirty==sn)return!1;if(this.spec.update){let s=this.spec.update(e,n,r);return s&&this.updateInner(e,n,r,i),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,i){this.spec.setSelection?this.spec.setSelection(e,n,r):super.setSelection(e,n,r,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function h0(t,e,n){let r=t.firstChild,i=!1;for(let s=0;s>1,o=Math.min(s,e.length);for(;i-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{let l=yr.create(this.top,e[s],n,r);this.top.children.splice(this.index,0,l),this.top=l,this.changed=!0}this.index=0,s++}}findNodeMatch(e,n,r,i){let s=-1,o;if(i>=this.preMatch.index&&(o=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&o.matchesNode(e,n,r))s=this.top.children.indexOf(o,this.index);else for(let a=this.index,l=Math.min(this.top.children.length,a+5);a0;){let a;for(;;)if(r){let u=n.children[r-1];if(u instanceof yr)n=u,r=u.children.length;else{a=u,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let l=a.node;if(l){if(l!=t.child(i-1))break;--i,s.set(a,i),o.push(a)}}return{index:i,matched:s,matches:o.reverse()}}function d2(t,e){return t.type.side-e.type.side}function f2(t,e,n,r){let i=e.locals(t),s=0;if(i.length==0){for(let u=0;us;)a.push(i[o++]);let p=s+f.nodeSize;if(f.isText){let g=p;o!g.inline):a.slice();r(f,m,e.forChild(s,f),h),s=p}}function h2(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}function p2(t,e,n,r){for(let i=0,s=0;i=n){if(s>=r&&l.slice(r-e.length-a,r-a)==e)return r-e.length;let u=a=0&&u+e.length+a>=n)return a+u;if(n==r&&l.length>=r+e.length-a&&l.slice(r-a,r-a+e.length)==e)return r}}return-1}function ou(t,e,n,r,i){let s=[];for(let o=0,a=0;o=n||c<=e?s.push(l):(un&&s.push(l.slice(n-u,l.size,r)))}return s}function Zu(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let i=t.docView.nearestDesc(n.focusNode),s=i&&i.size==0,o=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let a=r.resolve(o),l,u;if(ha(n)){for(l=a;i&&!i.node;)i=i.parent;let c=i.node;if(i&&c.isAtom&&ee.isSelectable(c)&&i.parent&&!(c.isInline&&Pb(n.focusNode,n.focusOffset,i.dom))){let d=i.posBefore;u=new ee(o==d?a:r.resolve(d))}}else{let c=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(c<0)return null;l=r.resolve(c)}if(!u){let c=e=="pointer"||t.state.selection.head{(n.anchorNode!=r||n.anchorOffset!=i)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!g0(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function g2(t){let e=t.domSelection(),n=document.createRange(),r=t.cursorWrapper.dom,i=r.nodeName=="IMG";i?n.setEnd(r.parentNode,Je(r)+1):n.setEnd(r,0),n.collapse(!1),e.removeAllRanges(),e.addRange(n),!i&&!t.state.selection.visible&&ht&&$n<=11&&(r.disabled=!0,r.disabled=!1)}function b0(t,e){if(e instanceof ee){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(Dd(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else Dd(t)}function Dd(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Ku(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||X.between(e,n,r)}function Od(t){return t.editable&&!t.hasFocus()?!1:y0(t)}function y0(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function b2(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return br(e.node,e.offset,n.anchorNode,n.anchorOffset)}function au(t,e){let{$anchor:n,$head:r}=t.selection,i=e>0?n.max(r):n.min(r),s=i.parent.inlineContent?i.depth?t.doc.resolve(e>0?i.after():i.before()):null:i;return s&&ne.findFrom(s,e)}function wn(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function Nd(t,e,n){let r=t.state.selection;if(r instanceof X)if(n.indexOf("s")>-1){let{$head:i}=r,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let o=t.state.doc.resolve(i.pos+s.nodeSize*(e<0?-1:1));return wn(t,new X(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=au(t.state,e);return i&&i instanceof ee?wn(t,i):!1}else if(!(Dt&&n.indexOf("m")>-1)){let i=r.$head,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,o;if(!s||s.isText)return!1;let a=e<0?i.pos-s.nodeSize:i.pos;return s.isAtom||(o=t.docView.descAt(a))&&!o.contentDOM?ee.isSelectable(s)?wn(t,new ee(e<0?t.state.doc.resolve(i.pos-s.nodeSize):i)):gs?wn(t,new X(t.state.doc.resolve(e<0?a:a+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof ee&&r.node.isInline)return wn(t,new X(e>0?r.$to:r.$from));{let i=au(t.state,e);return i?wn(t,i):!1}}}function vo(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Li(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function Tr(t,e){return e<0?y2(t):x2(t)}function y2(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,s,o=!1;for(zt&&n.nodeType==1&&r0){if(n.nodeType!=1)break;{let a=n.childNodes[r-1];if(Li(a,-1))i=n,s=--r;else if(a.nodeType==3)n=a,r=n.nodeValue.length;else break}}else{if(x0(n))break;{let a=n.previousSibling;for(;a&&Li(a,-1);)i=n.parentNode,s=Je(a),a=a.previousSibling;if(a)n=a,r=vo(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?lu(t,n,r):i&&lu(t,i,s)}function x2(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=vo(n),s,o;for(;;)if(r{t.state==i&&kn(t)},50)}function Ld(t,e){let n=t.state.doc.resolve(e);if(!(st||Ub)&&n.parent.inlineContent){let i=t.coordsAtPos(e);if(e>n.start()){let s=t.coordsAtPos(e-1),o=(s.top+s.bottom)/2;if(o>i.top&&o1)return s.lefti.top&&o1)return s.left>i.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function Rd(t,e,n){let r=t.state.selection;if(r instanceof X&&!r.empty||n.indexOf("s")>-1||Dt&&n.indexOf("m")>-1)return!1;let{$from:i,$to:s}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=au(t.state,e);if(o&&o instanceof ee)return wn(t,o)}if(!i.parent.inlineContent){let o=e<0?i:s,a=r instanceof Nt?ne.near(o,e):ne.findFrom(o,e);return a?wn(t,a):!1}return!1}function Id(t,e){if(!(t.state.selection instanceof X))return!0;let{$head:n,$anchor:r,empty:i}=t.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(s&&!s.isText){let o=t.state.tr;return e<0?o.delete(n.pos-s.nodeSize,n.pos):o.delete(n.pos,n.pos+s.nodeSize),t.dispatch(o),!0}return!1}function Fd(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function E2(t){if(!ot||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&e.nodeType==1&&n==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;Fd(t,r,"true"),setTimeout(()=>Fd(t,r,"false"),20)}return!1}function _2(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function C2(t,e){let n=e.keyCode,r=_2(e);if(n==8||Dt&&n==72&&r=="c")return Id(t,-1)||Tr(t,-1);if(n==46&&!e.shiftKey||Dt&&n==68&&r=="c")return Id(t,1)||Tr(t,1);if(n==13||n==27)return!0;if(n==37||Dt&&n==66&&r=="c"){let i=n==37?Ld(t,t.state.selection.from)=="ltr"?-1:1:-1;return Nd(t,i,r)||Tr(t,i)}else if(n==39||Dt&&n==70&&r=="c"){let i=n==39?Ld(t,t.state.selection.from)=="ltr"?1:-1:1;return Nd(t,i,r)||Tr(t,i)}else{if(n==38||Dt&&n==80&&r=="c")return Rd(t,-1,r)||Tr(t,-1);if(n==40||Dt&&n==78&&r=="c")return E2(t)||Rd(t,1,r)||Tr(t,1);if(r==(Dt?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function k0(t,e){t.someProp("transformCopied",h=>{e=h(e,t)});let n=[],{content:r,openStart:i,openEnd:s}=e;for(;i>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,s--;let h=r.firstChild;n.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let o=t.someProp("clipboardSerializer")||Yt.fromSchema(t.state.schema),a=S0(),l=a.createElement("div");l.appendChild(o.serializeFragment(r,{document:a}));let u=l.firstChild,c,d=0;for(;u&&u.nodeType==1&&(c=w0[u.nodeName.toLowerCase()]);){for(let h=c.length-1;h>=0;h--){let p=a.createElement(c[h]);for(;l.firstChild;)p.appendChild(l.firstChild);l.appendChild(p),d++}u=l.firstChild}u&&u.nodeType==1&&u.setAttribute("data-pm-slice",`${i} ${s}${d?` -${d}`:""} ${JSON.stringify(n)}`);let f=t.someProp("clipboardTextSerializer",h=>h(e,t))||e.content.textBetween(0,e.content.size,` `);return{dom:l,text:f}}function v0(t,e,n,r,i){let s=i.parent.type.spec.code,o,a;if(!n&&!e)return null;let l=e&&(r||s||!n);if(l){if(t.someProp("transformPastedText",f=>{e=f(e,s||r,t)}),s)return e?new P(O.from(t.state.schema.text(e.replace(/\r\n?/g,` -`))),0,0):P.empty;let d=t.someProp("clipboardTextParser",f=>f(e,i,r,t));if(d)a=d;else{let f=i.marks(),{schema:h}=t.state,p=Yt.fromSchema(h);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=o.appendChild(document.createElement("p"));m&&g.appendChild(p.serializeNode(h.text(m,f)))})}}else t.someProp("transformPastedHTML",d=>{n=d(n,t)}),o=M2(n),gs&&T2(o);let u=o&&o.querySelector("[data-pm-slice]"),c=u&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(u.getAttribute("data-pm-slice")||"");if(c&&c[3])for(let d=+c[3];d>0;d--){let f=o.firstChild;for(;f&&f.nodeType!=1;)f=f.nextSibling;if(!f)break;o=f}if(a||(a=(t.someProp("clipboardParser")||t.someProp("domParser")||ps.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(l||c),context:i,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!S2.test(f.parentNode.nodeName)?{ignore:!0}:null}})),c)a=D2(Fd(a,+c[1],+c[2]),c[4]);else if(a=P.maxOpen(A2(a.content,i),!0),a.openStart||a.openEnd){let d=0,f=0;for(let h=a.content.firstChild;d{a=d(a,t)}),a}const S2=/^(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 A2(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let i=e.node(n).contentMatchAt(e.index(n)),s,o=[];if(t.forEach(a=>{if(!o)return;let l=i.findWrapping(a.type),u;if(!l)return o=null;if(u=o.length&&s.length&&_0(l,s,a,o[o.length-1],0))o[o.length-1]=u;else{o.length&&(o[o.length-1]=C0(o[o.length-1],s.length));let c=E0(a,l);o.push(c),i=i.matchType(c.type),s=l}}),o)return O.from(o)}return t}function E0(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,O.from(t));return t}function _0(t,e,n,r,i){if(i1&&(s=0),i=n&&(a=e<0?o.contentMatchAt(0).fillBefore(a,s<=i).append(a):a.append(o.contentMatchAt(o.childCount).fillBefore(O.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(a))}function Fd(t,e,n){return e]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=S0().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),i;if((i=r&&w0[r[1].toLowerCase()])&&(t=i.map(s=>"<"+s+">").join("")+t+i.map(s=>"").reverse().join("")),n.innerHTML=t,i)for(let s=0;s=0;a-=2){let l=n.nodes[r[a]];if(!l||l.hasRequiredAttrs())break;i=O.from(l.create(r[a+1],i)),s++,o++}return new P(i,s,o)}const at={},lt={},O2={touchstart:!0,touchmove:!0};class N2{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastAndroidDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function L2(t){for(let e in at){let n=at[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{I2(t,r)&&!Wu(t,r)&&(t.editable||!(r.type in lt))&&n(t,r)},O2[e]?{passive:!0}:void 0)}ot&&t.dom.addEventListener("input",()=>null),cu(t)}function In(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function R2(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function cu(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>Wu(t,r))})}function Wu(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function I2(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function F2(t,e){!Wu(t,e)&&at[e.type]&&(t.editable||!(e.type in lt))&&at[e.type](t,e)}lt.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!M0(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Pt&&st&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),ni&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",i=>i(t,tr(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||w2(t,n)?n.preventDefault():In(t,"key")};lt.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};lt.keypress=(t,e)=>{let n=e;if(M0(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Dt&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof X)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(n.charCode);!/[\r\n]/.test(i)&&!t.someProp("handleTextInput",s=>s(t,r.$from.pos,r.$to.pos,i))&&t.dispatch(t.state.tr.insertText(i).scrollIntoView()),n.preventDefault()}};function ma(t){return{left:t.clientX,top:t.clientY}}function H2(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function ju(t,e,n,r,i){if(r==-1)return!1;let s=t.state.doc.resolve(r);for(let o=s.depth+1;o>0;o--)if(t.someProp(e,a=>o>s.depth?a(t,n,s.nodeAfter,s.before(o),i,!0):a(t,n,s.node(o),s.before(o),i,!1)))return!0;return!1}function Xr(t,e,n){t.focused||t.focus();let r=t.state.tr.setSelection(e);n=="pointer"&&r.setMeta("pointer",!0),t.dispatch(r)}function B2(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&ee.isSelectable(r)?(Xr(t,new ee(n),"pointer"),!0):!1}function P2(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof ee&&(r=n.node);let s=t.state.doc.resolve(e);for(let o=s.depth+1;o>0;o--){let a=o>s.depth?s.nodeAfter:s.node(o);if(ee.isSelectable(a)){r&&n.$from.depth>0&&o>=n.$from.depth&&s.before(n.$from.depth+1)==n.$from.pos?i=s.before(n.$from.depth):i=s.before(o);break}}return i!=null?(Xr(t,ee.create(t.state.doc,i),"pointer"),!0):!1}function $2(t,e,n,r,i){return ju(t,"handleClickOn",e,n,r)||t.someProp("handleClick",s=>s(t,e,r))||(i?P2(t,n):B2(t,n))}function z2(t,e,n,r){return ju(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function V2(t,e,n,r){return ju(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||U2(t,n,r)}function U2(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(Xr(t,X.create(r,0,r.content.size),"pointer"),!0):!1;let i=r.resolve(e);for(let s=i.depth+1;s>0;s--){let o=s>i.depth?i.nodeAfter:i.node(s),a=i.before(s);if(o.inlineContent)Xr(t,X.create(r,a+1,a+1+o.content.size),"pointer");else if(ee.isSelectable(o))Xr(t,ee.create(r,a),"pointer");else continue;return!0}}function Gu(t){return Eo(t)}const A0=Dt?"metaKey":"ctrlKey";at.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=Gu(t),i=Date.now(),s="singleClick";i-t.input.lastClick.time<500&&H2(n,t.input.lastClick)&&!n[A0]&&(t.input.lastClick.type=="singleClick"?s="doubleClick":t.input.lastClick.type=="doubleClick"&&(s="tripleClick")),t.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:s};let o=t.posAtCoords(ma(n));o&&(s=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new q2(t,o,n,!!r)):(s=="doubleClick"?z2:V2)(t,o.pos,o.inside,n)?n.preventDefault():In(t,"pointer"))};class q2{constructor(e,n,r,i){this.view=e,this.pos=n,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[A0],this.allowDefault=r.shiftKey;let s,o;if(n.inside>-1)s=e.state.doc.nodeAt(n.inside),o=n.inside;else{let c=e.state.doc.resolve(n.pos);s=c.parent,o=c.depth?c.before():0}const a=i?null:r.target,l=a?e.docView.nearestDesc(a,!0):null;this.target=l?l.dom:null;let{selection:u}=e.state;(r.button==0&&s.type.spec.draggable&&s.type.spec.selectable!==!1||u instanceof ee&&u.from<=o&&u.to>o)&&(this.mightDrag={node:s,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&zt&&!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)),In(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(()=>kn(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(ma(e))),this.updateAllowDefault(e),this.allowDefault||!n?In(this.view,"pointer"):$2(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ot&&this.mightDrag&&!this.mightDrag.node.isAtom||st&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(Xr(this.view,ne.near(this.view.state.doc.resolve(n.pos)),"pointer"),e.preventDefault()):In(this.view,"pointer")}move(e){this.updateAllowDefault(e),In(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)}}at.touchstart=t=>{t.input.lastTouch=Date.now(),Gu(t),In(t,"pointer")};at.touchmove=t=>{t.input.lastTouch=Date.now(),In(t,"pointer")};at.contextmenu=t=>Gu(t);function M0(t,e){return t.composing?!0:ot&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const Z2=Pt?5e3:-1;lt.compositionstart=lt.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$from;if(e.selection.empty&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))t.markCursor=t.state.storedMarks||n.marks(),Eo(t,!0),t.markCursor=null;else if(Eo(t),zt&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let i=r.focusNode,s=r.focusOffset;i&&i.nodeType==1&&s!=0;){let o=s<0?i.lastChild:i.childNodes[s-1];if(!o)break;if(o.nodeType==3){t.domSelection().collapse(o,o.nodeValue.length);break}else i=o,s=-1}}t.input.composing=!0}T0(t,Z2)};lt.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,T0(t,20))};function T0(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>Eo(t),e))}function D0(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=W2());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function K2(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=Bb(e.focusNode,e.focusOffset),r=Pb(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let i=r.pmViewDesc;if(!i||!i.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let s=n.pmViewDesc;if(!(!s||!s.isText(n.nodeValue)))return r}}return n}function W2(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function Eo(t,e=!1){if(!(Pt&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),D0(t),e||t.docView&&t.docView.dirty){let n=Zu(t);return n&&!n.eq(t.state.selection)?t.dispatch(t.state.tr.setSelection(n)):t.updateState(t.state),!0}return!1}}function j2(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const qi=ht&&$n<15||ni&&Zb<604;at.copy=lt.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let s=qi?null:n.clipboardData,o=r.content(),{dom:a,text:l}=k0(t,o);s?(n.preventDefault(),s.clearData(),s.setData("text/html",a.innerHTML),s.setData("text/plain",l)):j2(t,a),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function G2(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function J2(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?Zi(t,r.value,null,i,e):Zi(t,r.textContent,r.innerHTML,i,e)},50)}function Zi(t,e,n,r,i){let s=v0(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",l=>l(t,i,s||P.empty)))return!0;if(!s)return!1;let o=G2(s),a=o?t.state.tr.replaceSelectionWith(o,r):t.state.tr.replaceSelection(s);return t.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function O0(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}lt.paste=(t,e)=>{let n=e;if(t.composing&&!Pt)return;let r=qi?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&Zi(t,O0(r),r.getData("text/html"),i,n)?n.preventDefault():J2(t,n)};class N0{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const L0=Dt?"altKey":"ctrlKey";at.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=t.state.selection,s=i.empty?null:t.posAtCoords(ma(n)),o;if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof ee?i.to-1:i.to))){if(r&&r.mightDrag)o=ee.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let c=t.docView.nearestDesc(n.target,!0);c&&c.node.type.spec.draggable&&c!=t.docView&&(o=ee.create(t.state.doc,c.posBefore))}}let a=(o||t.state.selection).content(),{dom:l,text:u}=k0(t,a);n.dataTransfer.clearData(),n.dataTransfer.setData(qi?"Text":"text/html",l.innerHTML),n.dataTransfer.effectAllowed="copyMove",qi||n.dataTransfer.setData("text/plain",u),t.dragging=new N0(a,!n[L0],o)};at.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};lt.dragover=lt.dragenter=(t,e)=>e.preventDefault();lt.drop=(t,e)=>{let n=e,r=t.dragging;if(t.dragging=null,!n.dataTransfer)return;let i=t.posAtCoords(ma(n));if(!i)return;let s=t.state.doc.resolve(i.pos),o=r&&r.slice;o?t.someProp("transformPasted",p=>{o=p(o,t)}):o=v0(t,O0(n.dataTransfer),qi?null:n.dataTransfer.getData("text/html"),!1,s);let a=!!(r&&!n[L0]);if(t.someProp("handleDrop",p=>p(t,n,o||P.empty,a))){n.preventDefault();return}if(!o)return;n.preventDefault();let l=o?Jp(t.state.doc,s.pos,o):s.pos;l==null&&(l=s.pos);let u=t.state.tr;if(a){let{node:p}=r;p?p.replace(u):u.deleteSelection()}let c=u.mapping.map(l),d=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,f=u.doc;if(d?u.replaceRangeWith(c,c,o.content.firstChild):u.replaceRange(c,c,o),u.doc.eq(f))return;let h=u.doc.resolve(c);if(d&&ee.isSelectable(o.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(o.content.firstChild))u.setSelection(new ee(h));else{let p=u.mapping.map(l);u.mapping.maps[u.mapping.maps.length-1].forEach((m,g,y,x)=>p=x),u.setSelection(Ku(t,h,u.doc.resolve(p)))}t.focus(),t.dispatch(u.setMeta("uiEvent","drop"))};at.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&kn(t)},20))};at.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};at.beforeinput=(t,e)=>{if(st&&Pt&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",s=>s(t,tr(8,"Backspace")))))return;let{$cursor:i}=t.state.selection;i&&i.pos>0&&t.dispatch(t.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let t in lt)at[t]=lt[t];function Ki(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}class _o{constructor(e,n){this.toDOM=e,this.spec=n||dr,this.side=this.spec.side||0}map(e,n,r,i){let{pos:s,deleted:o}=e.mapResult(n.from+i,this.side<0?-1:1);return o?null:new Be(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof _o&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Ki(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Vn{constructor(e,n){this.attrs=e,this.spec=n||dr}map(e,n,r,i){let s=e.map(n.from+i,this.spec.inclusiveStart?-1:1)-r,o=e.map(n.to+i,this.spec.inclusiveEnd?1:-1)-r;return s>=o?null:new Be(s,o,this)}valid(e,n){return n.from=e&&(!s||s(a.spec))&&r.push(a.copy(a.from+i,a.to+i))}for(let o=0;oe){let a=this.children[o]+1;this.children[o+2].findInner(e-a,n-a,r,i+a,s)}}map(e,n,r){return this==et||e.maps.length==0?this:this.mapInner(e,n,0,0,r||dr)}mapInner(e,n,r,i,s){let o;for(let a=0;a{let u=l+r,c;if(c=I0(n,a,u)){for(i||(i=this.children.slice());sa&&d.to=e){this.children[a]==e&&(r=this.children[a+2]);break}let s=e+1,o=s+n.content.size;for(let a=0;as&&l.type instanceof Vn){let u=Math.max(s,l.from)-s,c=Math.min(o,l.to)-s;ui.map(e,n,dr));return Tn.from(r)}forChild(e,n){if(n.isLeaf)return ve.empty;let r=[];for(let i=0;in instanceof ve)?e:e.reduce((n,r)=>n.concat(r instanceof ve?r:r.members),[]))}}}function Y2(t,e,n,r,i,s,o){let a=t.slice();for(let u=0,c=s;u{let g=m-p-(h-f);for(let y=0;yx+c-d)continue;let k=a[y]+c-d;h>=k?a[y+1]=f<=k?-2:-1:f>=c&&g&&(a[y]+=g,a[y+1]+=g)}d+=g}),c=n.maps[u].map(c,-1)}let l=!1;for(let u=0;u=r.content.size){l=!0;continue}let f=n.map(t[u+1]+s,-1),h=f-i,{index:p,offset:m}=r.content.findIndex(d),g=r.maybeChild(p);if(g&&m==d&&m+g.nodeSize==h){let y=a[u+2].mapInner(n,g,c+1,t[u]+s+1,o);y!=et?(a[u]=d,a[u+1]=h,a[u+2]=y):(a[u+1]=-2,l=!0)}else l=!0}if(l){let u=X2(a,t,e,n,i,s,o),c=Co(u,r,0,o);e=c.local;for(let d=0;dn&&o.to{let u=I0(t,a,l+n);if(u){s=!0;let c=Co(u,a,n+l+1,r);c!=et&&i.push(l,l+a.nodeSize,c)}});let o=R0(s?F0(t):t,-n).sort(fr);for(let a=0;a0;)e++;t.splice(e,0,n)}function ol(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=et&&e.push(r)}),t.cursorWrapper&&e.push(ve.create(t.state.doc,[t.cursorWrapper.deco])),Tn.from(e)}const Q2={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},ey=ht&&$n<=11;class ty{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 ny{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new ty,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;ii.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),ey&&(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,Q2)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let n=0;nthis.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(Dd(this.view)){if(this.suppressingSelectionUpdates)return kn(this.view);if(ht&&$n<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&br(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,r;for(let s=e.focusNode;s;s=Ui(s))n.add(s);for(let s=e.anchorNode;s;s=Ui(s))if(n.has(s)){r=s;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&Dd(e)&&!this.ignoreSelectionChange(r),s=-1,o=-1,a=!1,l=[];if(e.editable)for(let c=0;c1){let c=l.filter(d=>d.nodeName=="BR");if(c.length==2){let d=c[0],f=c[1];d.parentNode&&d.parentNode.parentNode==f.parentNode?f.remove():d.remove()}}let u=null;s<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)-1||i)&&(s>-1&&(e.docView.markDirty(s,o),ry(e)),this.handleDOMChange(s,o,a,l),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||kn(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let c=0;ci;g--){let y=r.childNodes[g-1],x=y.pmViewDesc;if(y.nodeName=="BR"&&!x){s=g;break}if(!x||x.size)break}let d=t.state.doc,f=t.someProp("domParser")||ps.fromSchema(t.state.schema),h=d.resolve(o),p=null,m=f.parse(r,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:i,to:s,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:oy,context:h});if(u&&u[0].pos!=null){let g=u[0].pos,y=u[1]&&u[1].pos;y==null&&(y=g),p={anchor:g+o,head:y+o}}return{doc:m,sel:p,from:o,to:a}}function oy(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(ot&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}else if(t.parentNode.lastChild==t||ot&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}const ay=/^(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 ly(t,e,n,r,i){let s=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let w=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,N=Zu(t,w);if(N&&!t.state.selection.eq(N)){if(st&&Pt&&t.input.lastKeyCode===13&&Date.now()-100K(t,tr(13,"Enter"))))return;let $=t.state.tr.setSelection(N);w=="pointer"?$.setMeta("pointer",!0):w=="key"&&$.scrollIntoView(),s&&$.setMeta("composition",s),t.dispatch($)}return}let o=t.state.doc.resolve(e),a=o.sharedDepth(n);e=o.before(a+1),n=t.state.doc.resolve(n).after(a+1);let l=t.state.selection,u=sy(t,e,n),c=t.state.doc,d=c.slice(u.from,u.to),f,h;t.input.lastKeyCode===8&&Date.now()-100Date.now()-225||Pt)&&i.some(w=>w.nodeType==1&&!ay.test(w.nodeName))&&(!p||p.endA>=p.endB)&&t.someProp("handleKeyDown",w=>w(t,tr(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!p)if(r&&l instanceof X&&!l.empty&&l.$head.sameParent(l.$anchor)&&!t.composing&&!(u.sel&&u.sel.anchor!=u.sel.head))p={start:l.from,endA:l.to,endB:l.to};else{if(u.sel){let w=zd(t,t.state.doc,u.sel);if(w&&!w.eq(t.state.selection)){let N=t.state.tr.setSelection(w);s&&N.setMeta("composition",s),t.dispatch(N)}}return}t.input.domChangeCount++,t.state.selection.fromt.state.selection.from&&p.start<=t.state.selection.from+2&&t.state.selection.from>=u.from?p.start=t.state.selection.from:p.endA=t.state.selection.to-2&&t.state.selection.to<=u.to&&(p.endB+=t.state.selection.to-p.endA,p.endA=t.state.selection.to)),ht&&$n<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>u.from&&u.doc.textBetween(p.start-u.from-1,p.start-u.from+1)=="  "&&(p.start--,p.endA--,p.endB--);let m=u.doc.resolveNoCache(p.start-u.from),g=u.doc.resolveNoCache(p.endB-u.from),y=c.resolve(p.start),x=m.sameParent(g)&&m.parent.inlineContent&&y.end()>=p.endA,k;if((ni&&t.input.lastIOSEnter>Date.now()-225&&(!x||i.some(w=>w.nodeName=="DIV"||w.nodeName=="P"))||!x&&m.posw(t,tr(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>p.start&&cy(c,p.start,p.endA,m,g)&&t.someProp("handleKeyDown",w=>w(t,tr(8,"Backspace")))){Pt&&st&&t.domObserver.suppressSelectionUpdates();return}st&&Pt&&p.endB==p.start&&(t.input.lastAndroidDelete=Date.now()),Pt&&!x&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==p.endA&&(p.endB-=2,g=u.doc.resolveNoCache(p.endB-u.from),setTimeout(()=>{t.someProp("handleKeyDown",function(w){return w(t,tr(13,"Enter"))})},20));let b=p.start,E=p.endA,v,C,T;if(x){if(m.pos==g.pos)ht&&$n<=11&&m.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>kn(t),20)),v=t.state.tr.delete(b,E),C=c.resolve(p.start).marksAcross(c.resolve(p.endA));else if(p.endA==p.endB&&(T=uy(m.parent.content.cut(m.parentOffset,g.parentOffset),y.parent.content.cut(y.parentOffset,p.endA-y.start()))))v=t.state.tr,T.type=="add"?v.addMark(b,E,T.mark):v.removeMark(b,E,T.mark);else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let w=m.parent.textBetween(m.parentOffset,g.parentOffset);if(t.someProp("handleTextInput",N=>N(t,b,E,w)))return;v=t.state.tr.insertText(w,b,E)}}if(v||(v=t.state.tr.replace(b,E,u.doc.slice(p.start-u.from,p.endB-u.from))),u.sel){let w=zd(t,v.doc,u.sel);w&&!(st&&Pt&&t.composing&&w.empty&&(p.start!=p.endB||t.input.lastAndroidDeletee.content.size?null:Ku(t,e.resolve(n.anchor),e.resolve(n.head))}function uy(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,i=n,s=r,o,a,l;for(let c=0;cc.mark(a.addToSet(c.marks));else if(i.length==0&&s.length==1)a=s[0],o="remove",l=c=>c.mark(a.removeFromSet(c.marks));else return null;let u=[];for(let c=0;cn||al(o,!0,!1)0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,i++,e=!1;if(n){let s=t.node(r).maybeChild(t.indexAfter(r));for(;s&&!s.isLeaf;)s=s.firstChild,i++}return i}function dy(t,e,n,r,i){let s=t.findDiffStart(e,n);if(s==null)return null;let{a:o,b:a}=t.findDiffEnd(e,n+t.size,n+e.size);if(i=="end"){let l=Math.max(0,s-Math.min(o,a));r-=o+l-s}if(o=o?s-r:0;s-=l,s&&s=a?s-r:0;s-=l,s&&s=56320&&e<=57343&&n>=55296&&n<=56319}class fy{constructor(e,n){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new N2,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(Wd),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=Zd(this),qd(this),this.nodeViews=Kd(this),this.docView=Cd(this.state.doc,Ud(this),ol(this),this.dom,this),this.domObserver=new ny(this,(r,i,s,o)=>ly(this,r,i,s,o)),this.domObserver.start(),L2(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let n in e)this._props[n]=e[n];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&cu(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Wd),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let i=this.state,s=!1,o=!1;e.storedMarks&&this.composing&&(D0(this),o=!0),this.state=e;let a=i.plugins!=e.plugins||this._props.plugins!=n.plugins;if(a||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let h=Kd(this);py(h,this.nodeViews)&&(this.nodeViews=h,s=!0)}(a||n.handleDOMEvents!=this._props.handleDOMEvents)&&cu(this),this.editable=Zd(this),qd(this);let l=ol(this),u=Ud(this),c=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",d=s||!this.docView.matchesNode(e.doc,u,l);(d||!e.selection.eq(i.selection))&&(o=!0);let f=c=="preserve"&&o&&this.dom.style.overflowAnchor==null&&jb(this);if(o){this.domObserver.stop();let h=d&&(ht||st)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&hy(i.selection,e.selection);if(d){let p=st?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=K2(this)),(s||!this.docView.update(e.doc,u,l,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=Cd(e.doc,u,l,this.dom,this)),p&&!this.trackWrites&&(h=!0)}h||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&y2(this))?kn(this,h):(b0(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),c=="reset"?this.dom.scrollTop=0:c=="to selection"?this.scrollToSelection():f&&Gb(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof ee){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&yd(this,n.getBoundingClientRect(),e)}else yd(this,this.coordsAtPos(this.state.selection.head,1),e)}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n0&&this.state.doc.nodeAt(s))==r.node&&(i=s)}this.dragging=new N0(e.slice,e.move,i<0?void 0:ee.create(this.state.doc,i))}someProp(e,n){let r=this._props&&this._props[e],i;if(r!=null&&(i=n?n(r):r))return i;for(let o=0;on.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return t2(this,e)}coordsAtPos(e,n=1){return u0(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,r=-1){let i=this.docView.posFromDOM(e,n,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,n){return o2(this,n||this.state,e)}pasteHTML(e,n){return Zi(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return Zi(this,e,null,!0,n||new ClipboardEvent("paste"))}destroy(){this.docView&&(R2(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],ol(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Fb())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return F2(this,e)}dispatch(e){let n=this._props.dispatchTransaction;n?n.call(this,e):this.updateState(this.state.apply(e))}domSelectionRange(){return ot&&this.root.nodeType===11&&zb(this.dom.ownerDocument)==this.dom?iy(this):this.domSelection()}domSelection(){return this.root.getSelection()}}function Ud(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(t.state)),n)for(let r in n)r=="class"?e.class+=" "+n[r]:r=="style"?e.style=(e.style?e.style+";":"")+n[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(n[r]))}),e.translate||(e.translate="no"),[Be.node(0,t.state.doc.content.size,e)]}function qd(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:Be.widget(t.state.selection.head,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function Zd(t){return!t.someProp("editable",e=>e(t.state)===!1)}function hy(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}function Kd(t){let e=Object.create(null);function n(r){for(let i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function py(t,e){let n=0,r=0;for(let i in t){if(t[i]!=e[i])return!0;n++}for(let i in e)r++;return n!=r}function Wd(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var qn={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:"'"},wo={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},my=typeof navigator<"u"&&/Mac/.test(navigator.platform),gy=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Ye=0;Ye<10;Ye++)qn[48+Ye]=qn[96+Ye]=String(Ye);for(var Ye=1;Ye<=24;Ye++)qn[Ye+111]="F"+Ye;for(var Ye=65;Ye<=90;Ye++)qn[Ye]=String.fromCharCode(Ye+32),wo[Ye]=String.fromCharCode(Ye);for(var ll in qn)wo.hasOwnProperty(ll)||(wo[ll]=qn[ll]);function by(t){var e=my&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||gy&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?wo:qn)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}const yy=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function xy(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,i,s,o;for(let a=0;a127)&&(s=qn[r.keyCode])&&s!=i){let a=e[ul(s,r)];if(a&&a(n.state,n.dispatch,n))return!0}}return!1}}const Ey=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function H0(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const _y=(t,e,n)=>{let r=H0(t,n);if(!r)return!1;let i=Qu(r);if(!i){let o=r.blockRange(),a=o&&mi(o);return a==null?!1:(e&&e(t.tr.lift(o,a).scrollIntoView()),!0)}let s=i.nodeBefore;if(!s.type.spec.isolating&&z0(t,i,e))return!0;if(r.parent.content.size==0&&(ri(s,"end")||ee.isSelectable(s))){let o=da(t.doc,r.before(),r.after(),P.empty);if(o&&o.slice.size{let r=H0(t,n);if(!r)return!1;let i=Qu(r);return i?B0(t,i,e):!1},wy=(t,e,n)=>{let r=P0(t,n);if(!r)return!1;let i=ec(r);return i?B0(t,i,e):!1};function B0(t,e,n){let r=e.nodeBefore,i=r,s=e.pos-1;for(;!i.isTextblock;s--){if(i.type.spec.isolating)return!1;let c=i.lastChild;if(!c)return!1;i=c}let o=e.nodeAfter,a=o,l=e.pos+1;for(;!a.isTextblock;l++){if(a.type.spec.isolating)return!1;let c=a.firstChild;if(!c)return!1;a=c}let u=da(t.doc,s,l,P.empty);if(!u||u.from!=s||u instanceof ze&&u.slice.size>=l-s)return!1;if(n){let c=t.tr.step(u);c.setSelection(X.create(c.doc,s)),n(c.scrollIntoView())}return!0}function ri(t,e,n=!1){for(let r=t;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}const Sy=(t,e,n)=>{let{$head:r,empty:i}=t.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;s=Qu(r)}let o=s&&s.nodeBefore;return!o||!ee.isSelectable(o)?!1:(e&&e(t.tr.setSelection(ee.create(t.doc,s.pos-o.nodeSize)).scrollIntoView()),!0)};function Qu(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function P0(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset{let r=P0(t,n);if(!r)return!1;let i=ec(r);if(!i)return!1;let s=i.nodeAfter;if(z0(t,i,e))return!0;if(r.parent.content.size==0&&(ri(s,"start")||ee.isSelectable(s))){let o=da(t.doc,r.before(),r.after(),P.empty);if(o&&o.slice.size{let{$head:r,empty:i}=t.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset=0;e--){let n=t.node(e);if(t.index(e)+1{let n=t.selection,r=n instanceof ee,i;if(r){if(n.node.isTextblock||!Gn(t.doc,n.from))return!1;i=n.from}else if(i=ca(t.doc,n.from,-1),i==null)return!1;if(e){let s=t.tr.join(i);r&&s.setSelection(ee.create(s.doc,i-t.doc.resolve(i).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},Dy=(t,e)=>{let n=t.selection,r;if(n instanceof ee){if(n.node.isTextblock||!Gn(t.doc,n.to))return!1;r=n.to}else if(r=ca(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},Oy=(t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),s=i&&mi(i);return s==null?!1:(e&&e(t.tr.lift(i,s).scrollIntoView()),!0)},Ny=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(` -`).scrollIntoView()),!0)};function $0(t){for(let e=0;e{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),s=n.indexAfter(-1),o=$0(i.contentMatchAt(s));if(!o||!i.canReplaceWith(s,s,o))return!1;if(e){let a=n.after(),l=t.tr.replaceWith(a,a,o.createAndFill());l.setSelection(ne.near(l.doc.resolve(a),1)),e(l.scrollIntoView())}return!0},Ry=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof Nt||r.parent.inlineContent||i.parent.inlineContent)return!1;let s=$0(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let o=(!r.parentOffset&&i.index(){let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let s=n.before();if(Jr(t.doc,s))return e&&e(t.tr.split(s).scrollIntoView()),!0}let r=n.blockRange(),i=r&&mi(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)},Fy=(t,e)=>{let{$from:n,to:r}=t.selection,i,s=n.sharedDepth(r);return s==0?!1:(i=n.before(s),e&&e(t.tr.setSelection(ee.create(t.doc,i))),!0)};function Hy(t,e,n){let r=e.nodeBefore,i=e.nodeAfter,s=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(s-1,s)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(i.isTextblock||Gn(t.doc,e.pos))?!1:(n&&n(t.tr.clearIncompatible(e.pos,r.type,r.contentMatchAt(r.childCount)).join(e.pos).scrollIntoView()),!0)}function z0(t,e,n){let r=e.nodeBefore,i=e.nodeAfter,s,o;if(r.type.spec.isolating||i.type.spec.isolating)return!1;if(Hy(t,e,n))return!0;let a=e.parent.canReplace(e.index(),e.index()+1);if(a&&(s=(o=r.contentMatchAt(r.childCount)).findWrapping(i.type))&&o.matchType(s[0]||i.type).validEnd){if(n){let d=e.pos+i.nodeSize,f=O.empty;for(let m=s.length-1;m>=0;m--)f=O.from(s[m].create(null,f));f=O.from(r.copy(f));let h=t.tr.step(new Ue(e.pos-1,d,e.pos,d,new P(f,1,0),s.length,!0)),p=d+2*s.length;Gn(h.doc,p)&&h.join(p),n(h.scrollIntoView())}return!0}let l=ne.findFrom(e,1),u=l&&l.$from.blockRange(l.$to),c=u&&mi(u);if(c!=null&&c>=e.depth)return n&&n(t.tr.lift(u,c).scrollIntoView()),!0;if(a&&ri(i,"start",!0)&&ri(r,"end")){let d=r,f=[];for(;f.push(d),!d.isTextblock;)d=d.lastChild;let h=i,p=1;for(;!h.isTextblock;h=h.firstChild)p++;if(d.canReplace(d.childCount,d.childCount,h.content)){if(n){let m=O.empty;for(let y=f.length-1;y>=0;y--)m=O.from(f[y].copy(m));let g=t.tr.step(new Ue(e.pos-f.length,e.pos+i.nodeSize,e.pos+p,e.pos+i.nodeSize-p,new P(m,f.length,0),0,!0));n(g.scrollIntoView())}return!0}}return!1}function V0(t){return function(e,n){let r=e.selection,i=t<0?r.$from:r.$to,s=i.depth;for(;i.node(s).isInline;){if(!s)return!1;s--}return i.node(s).isTextblock?(n&&n(e.tr.setSelection(X.create(e.doc,t<0?i.start(s):i.end(s)))),!0):!1}}const By=V0(-1),Py=V0(1);function $y(t,e=null){return function(n,r){let{$from:i,$to:s}=n.selection,o=i.blockRange(s),a=o&&zu(o,t,e);return a?(r&&r(n.tr.wrap(o,a).scrollIntoView()),!0):!1}}function jd(t,e=null){return function(n,r){let i=!1;for(let s=0;s{if(i)return!1;if(!(!l.isTextblock||l.hasMarkup(t,e)))if(l.type==t)i=!0;else{let c=n.doc.resolve(u),d=c.index();i=c.parent.canReplaceWith(d,d+1,t)}})}if(!i)return!1;if(r){let s=n.tr;for(let o=0;o=2&&i.node(o.depth-1).type.compatibleContent(t)&&o.startIndex==0){if(i.index(o.depth-1)==0)return!1;let c=n.doc.resolve(o.start-2);l=new bo(c,c,o.depth),o.endIndex=0;c--)s=O.from(n[c].type.create(n[c].attrs,s));t.step(new Ue(e.start-(r?2:0),e.end,e.start,e.end,new P(s,0,0),n.length,!0));let o=0;for(let c=0;co.childCount>0&&o.firstChild.type==t);return s?n?r.node(s.depth-1).type==t?qy(e,n,t,s):Zy(e,n,s):!0:!1}}function qy(t,e,n,r){let i=t.tr,s=r.end,o=r.$to.end(r.depth);sm;p--)h-=i.child(p).nodeSize,r.delete(h-1,h+1);let s=r.doc.resolve(n.start),o=s.nodeAfter;if(r.mapping.map(n.end)!=n.start+s.nodeAfter.nodeSize)return!1;let a=n.startIndex==0,l=n.endIndex==i.childCount,u=s.node(-1),c=s.index(-1);if(!u.canReplace(c+(a?0:1),c+1,o.content.append(l?O.empty:O.from(i))))return!1;let d=s.pos,f=d+o.nodeSize;return r.step(new Ue(d-(a?1:0),f+(l?1:0),d+1,f-1,new P((a?O.empty:O.from(i.copy(O.empty))).append(l?O.empty:O.from(i.copy(O.empty))),a?0:1,l?0:1),a?0:1)),e(r.scrollIntoView()),!0}function Ky(t){return function(e,n){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,u=>u.childCount>0&&u.firstChild.type==t);if(!s)return!1;let o=s.startIndex;if(o==0)return!1;let a=s.parent,l=a.child(o-1);if(l.type!=t)return!1;if(n){let u=l.lastChild&&l.lastChild.type==a.type,c=O.from(u?t.create():null),d=new P(O.from(t.create(null,O.from(a.type.create(null,c)))),u?3:1,0),f=s.start,h=s.end;n(e.tr.step(new Ue(f-(u?3:1),h,f,h,d,1,!0)).scrollIntoView())}return!0}}function ga(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:i}=n,{storedMarks:s}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return s},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,s=n.storedMarks,n}}}class ba{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:n,state:r}=this,{view:i}=n,{tr:s}=r,o=this.buildProps(s);return Object.fromEntries(Object.entries(e).map(([a,l])=>[a,(...c)=>{const d=l(...c)(o);return!s.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(s),d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,n=!0){const{rawCommands:r,editor:i,state:s}=this,{view:o}=i,a=[],l=!!e,u=e||s.tr,c=()=>(!l&&n&&!u.getMeta("preventDispatch")&&!this.hasCustomState&&o.dispatch(u),a.every(f=>f===!0)),d={...Object.fromEntries(Object.entries(r).map(([f,h])=>[f,(...m)=>{const g=this.buildProps(u,n),y=h(...m)(g);return a.push(y),d}])),run:c};return d}createCan(e){const{rawCommands:n,state:r}=this,i=!1,s=e||r.tr,o=this.buildProps(s,i);return{...Object.fromEntries(Object.entries(n).map(([l,u])=>[l,(...c)=>u(...c)({...o,dispatch:void 0})])),chain:()=>this.createChain(s,i)}}buildProps(e,n=!0){const{rawCommands:r,editor:i,state:s}=this,{view:o}=i,a={tr:e,editor:i,view:o,state:ga({state:s,transaction:e}),dispatch:n?()=>{}:void 0,chain:()=>this.createChain(e,n),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(r).map(([l,u])=>[l,(...c)=>u(...c)(a)]))}};return a}}let Wy=class{constructor(){this.callbacks={}}on(e,n){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(n),this}emit(e,...n){const r=this.callbacks[e];return r&&r.forEach(i=>i.apply(this,n)),this}off(e,n){const r=this.callbacks[e];return r&&(n?this.callbacks[e]=r.filter(i=>i!==n):delete this.callbacks[e]),this}removeAllListeners(){this.callbacks={}}};function Z(t,e,n){return t.config[e]===void 0&&t.parent?Z(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?Z(t.parent,e,n):null}):t.config[e]}function ya(t){const e=t.filter(i=>i.type==="extension"),n=t.filter(i=>i.type==="node"),r=t.filter(i=>i.type==="mark");return{baseExtensions:e,nodeExtensions:n,markExtensions:r}}function U0(t){const e=[],{nodeExtensions:n,markExtensions:r}=ya(t),i=[...n,...r],s={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.forEach(o=>{const a={name:o.name,options:o.options,storage:o.storage},l=Z(o,"addGlobalAttributes",a);if(!l)return;l().forEach(c=>{c.types.forEach(d=>{Object.entries(c.attributes).forEach(([f,h])=>{e.push({type:d,name:f,attribute:{...s,...h}})})})})}),i.forEach(o=>{const a={name:o.name,options:o.options,storage:o.storage},l=Z(o,"addAttributes",a);if(!l)return;const u=l();Object.entries(u).forEach(([c,d])=>{const f={...s,...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:o.name,name:c,attribute:f})})}),e}function Ze(t,e){if(typeof t=="string"){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}function le(...t){return t.filter(e=>!!e).reduce((e,n)=>{const r={...e};return Object.entries(n).forEach(([i,s])=>{if(!r[i]){r[i]=s;return}if(i==="class"){const a=s?s.split(" "):[],l=r[i]?r[i].split(" "):[],u=a.filter(c=>!l.includes(c));r[i]=[...l,...u].join(" ")}else i==="style"?r[i]=[r[i],s].join("; "):r[i]=s}),r},{})}function du(t,e){return e.filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(t.attrs)||{}:{[n.name]:t.attrs[n.name]}).reduce((n,r)=>le(n,r),{})}function q0(t){return typeof t=="function"}function oe(t,e=void 0,...n){return q0(t)?e?t.bind(e)(...n):t(...n):t}function jy(t={}){return Object.keys(t).length===0&&t.constructor===Object}function Gy(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function Gd(t,e){return t.style?t:{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;const i=e.reduce((s,o)=>{const a=o.attribute.parseHTML?o.attribute.parseHTML(n):Gy(n.getAttribute(o.name));return a==null?s:{...s,[o.name]:a}},{});return{...r,...i}}}}function Jd(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&jy(n)?!1:n!=null))}function Jy(t,e){var n;const r=U0(t),{nodeExtensions:i,markExtensions:s}=ya(t),o=(n=i.find(u=>Z(u,"topNode")))===null||n===void 0?void 0:n.name,a=Object.fromEntries(i.map(u=>{const c=r.filter(y=>y.type===u.name),d={name:u.name,options:u.options,storage:u.storage,editor:e},f=t.reduce((y,x)=>{const k=Z(x,"extendNodeSchema",d);return{...y,...k?k(u):{}}},{}),h=Jd({...f,content:oe(Z(u,"content",d)),marks:oe(Z(u,"marks",d)),group:oe(Z(u,"group",d)),inline:oe(Z(u,"inline",d)),atom:oe(Z(u,"atom",d)),selectable:oe(Z(u,"selectable",d)),draggable:oe(Z(u,"draggable",d)),code:oe(Z(u,"code",d)),defining:oe(Z(u,"defining",d)),isolating:oe(Z(u,"isolating",d)),attrs:Object.fromEntries(c.map(y=>{var x;return[y.name,{default:(x=y==null?void 0:y.attribute)===null||x===void 0?void 0:x.default}]}))}),p=oe(Z(u,"parseHTML",d));p&&(h.parseDOM=p.map(y=>Gd(y,c)));const m=Z(u,"renderHTML",d);m&&(h.toDOM=y=>m({node:y,HTMLAttributes:du(y,c)}));const g=Z(u,"renderText",d);return g&&(h.toText=g),[u.name,h]})),l=Object.fromEntries(s.map(u=>{const c=r.filter(g=>g.type===u.name),d={name:u.name,options:u.options,storage:u.storage,editor:e},f=t.reduce((g,y)=>{const x=Z(y,"extendMarkSchema",d);return{...g,...x?x(u):{}}},{}),h=Jd({...f,inclusive:oe(Z(u,"inclusive",d)),excludes:oe(Z(u,"excludes",d)),group:oe(Z(u,"group",d)),spanning:oe(Z(u,"spanning",d)),code:oe(Z(u,"code",d)),attrs:Object.fromEntries(c.map(g=>{var y;return[g.name,{default:(y=g==null?void 0:g.attribute)===null||y===void 0?void 0:y.default}]}))}),p=oe(Z(u,"parseHTML",d));p&&(h.parseDOM=p.map(g=>Gd(g,c)));const m=Z(u,"renderHTML",d);return m&&(h.toDOM=g=>m({mark:g,HTMLAttributes:du(g,c)})),[u.name,h]}));return new zp({topNode:o,nodes:a,marks:l})}function cl(t,e){return e.nodes[t]||e.marks[t]||null}function Yd(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}const Yy=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(i,s,o,a)=>{var l,u;const c=((u=(l=i.type.spec).toText)===null||u===void 0?void 0:u.call(l,{node:i,pos:s,parent:o,index:a}))||i.textContent||"%leaf%";n+=c.slice(0,Math.max(0,r-s))}),n};function tc(t){return Object.prototype.toString.call(t)==="[object RegExp]"}class ys{constructor(e){this.find=e.find,this.handler=e.handler}}const Xy=(t,e)=>{if(tc(e))return e.exec(t);const n=e(t);if(!n)return null;const r=[n.text];return r.index=n.index,r.input=t,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r};function Is(t){var e;const{editor:n,from:r,to:i,text:s,rules:o,plugin:a}=t,{view:l}=n;if(l.composing)return!1;const u=l.state.doc.resolve(r);if(u.parent.type.spec.code||!((e=u.nodeBefore||u.nodeAfter)===null||e===void 0)&&e.marks.find(f=>f.type.spec.code))return!1;let c=!1;const d=Yy(u)+s;return o.forEach(f=>{if(c)return;const h=Xy(d,f.find);if(!h)return;const p=l.state.tr,m=ga({state:l.state,transaction:p}),g={from:r-(h[0].length-s.length),to:i},{commands:y,chain:x,can:k}=new ba({editor:n,state:m});f.handler({state:m,range:g,match:h,commands:y,chain:x,can:k})===null||!p.steps.length||(p.setMeta(a,{transform:p,from:r,to:i,text:s}),l.dispatch(p),c=!0)}),c}function Qy(t){const{editor:e,rules:n}=t,r=new we({state:{init(){return null},apply(i,s){const o=i.getMeta(r);if(o)return o;const a=i.getMeta("applyInputRules");return!!a&&setTimeout(()=>{const{from:u,text:c}=a,d=u+c.length;Is({editor:e,from:u,to:d,text:c,rules:n,plugin:r})}),i.selectionSet||i.docChanged?null:s}},props:{handleTextInput(i,s,o,a){return Is({editor:e,from:s,to:o,text:a,rules:n,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:s}=i.state.selection;s&&Is({editor:e,from:s.pos,to:s.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(i,s){if(s.key!=="Enter")return!1;const{$cursor:o}=i.state.selection;return o?Is({editor:e,from:o.pos,to:o.pos,text:` -`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function ex(t){return typeof t=="number"}class tx{constructor(e){this.find=e.find,this.handler=e.handler}}const nx=(t,e,n)=>{if(tc(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.map(i=>{const s=[i.text];return s.index=i.index,s.input=t,s.data=i.data,i.replaceWith&&(i.text.includes(i.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),s.push(i.replaceWith)),s}):[]};function rx(t){const{editor:e,state:n,from:r,to:i,rule:s,pasteEvent:o,dropEvent:a}=t,{commands:l,chain:u,can:c}=new ba({editor:e,state:n}),d=[];return n.doc.nodesBetween(r,i,(h,p)=>{if(!h.isTextblock||h.type.spec.code)return;const m=Math.max(r,p),g=Math.min(i,p+h.content.size),y=h.textBetween(m-p,g-p,void 0,"");nx(y,s.find,o).forEach(k=>{if(k.index===void 0)return;const b=m+k.index+1,E=b+k[0].length,v={from:n.tr.mapping.map(b),to:n.tr.mapping.map(E)},C=s.handler({state:n,range:v,match:k,commands:l,chain:u,can:c,pasteEvent:o,dropEvent:a});d.push(C)})}),d.every(h=>h!==null)}const ix=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)===null||e===void 0||e.setData("text/html",t),n};function sx(t){const{editor:e,rules:n}=t;let r=null,i=!1,s=!1,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,a=typeof DragEvent<"u"?new DragEvent("drop"):null;const l=({state:c,from:d,to:f,rule:h,pasteEvt:p})=>{const m=c.tr,g=ga({state:c,transaction:m});if(!(!rx({editor:e,state:g,from:Math.max(d-1,0),to:f.b-1,rule:h,pasteEvent:p,dropEvent:a})||!m.steps.length))return a=typeof DragEvent<"u"?new DragEvent("drop"):null,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,m};return n.map(c=>new we({view(d){const f=h=>{var p;r=!((p=d.dom.parentElement)===null||p===void 0)&&p.contains(h.target)?d.dom.parentElement:null};return window.addEventListener("dragstart",f),{destroy(){window.removeEventListener("dragstart",f)}}},props:{handleDOMEvents:{drop:(d,f)=>(s=r===d.dom.parentElement,a=f,!1),paste:(d,f)=>{var h;const p=(h=f.clipboardData)===null||h===void 0?void 0:h.getData("text/html");return o=f,i=!!(p!=null&&p.includes("data-pm-slice")),!1}}},appendTransaction:(d,f,h)=>{const p=d[0],m=p.getMeta("uiEvent")==="paste"&&!i,g=p.getMeta("uiEvent")==="drop"&&!s,y=p.getMeta("applyPasteRules"),x=!!y;if(!m&&!g&&!x)return;if(x){const{from:E,text:v}=y,C=E+v.length,T=ix(v);return l({rule:c,state:h,from:E,to:{b:C},pasteEvt:T})}const k=f.doc.content.findDiffStart(h.doc.content),b=f.doc.content.findDiffEnd(h.doc.content);if(!(!ex(k)||!b||k===b.b))return l({rule:c,state:h,from:k,to:b,pasteEvt:o})}}))}function ox(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return[...new Set(e)]}class Zr{constructor(e,n){this.splittableMarks=[],this.editor=n,this.extensions=Zr.resolve(e),this.schema=Jy(this.extensions,n),this.setupExtensions()}static resolve(e){const n=Zr.sort(Zr.flatten(e)),r=ox(n.map(i=>i.name));return r.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${r.map(i=>`'${i}'`).join(", ")}]. This can lead to issues.`),n}static flatten(e){return e.map(n=>{const r={name:n.name,options:n.options,storage:n.storage},i=Z(n,"addExtensions",r);return i?[n,...this.flatten(i())]:n}).flat(10)}static sort(e){return e.sort((r,i)=>{const s=Z(r,"priority")||100,o=Z(i,"priority")||100;return s>o?-1:s{const r={name:n.name,options:n.options,storage:n.storage,editor:this.editor,type:cl(n.name,this.schema)},i=Z(n,"addCommands",r);return i?{...e,...i()}:e},{})}get plugins(){const{editor:e}=this,n=Zr.sort([...this.extensions].reverse()),r=[],i=[],s=n.map(o=>{const a={name:o.name,options:o.options,storage:o.storage,editor:e,type:cl(o.name,this.schema)},l=[],u=Z(o,"addKeyboardShortcuts",a);let c={};if(o.type==="mark"&&o.config.exitable&&(c.ArrowRight=()=>Ie.handleExit({editor:e,mark:o})),u){const m=Object.fromEntries(Object.entries(u()).map(([g,y])=>[g,()=>y({editor:e})]));c={...c,...m}}const d=vy(c);l.push(d);const f=Z(o,"addInputRules",a);Yd(o,e.options.enableInputRules)&&f&&r.push(...f());const h=Z(o,"addPasteRules",a);Yd(o,e.options.enablePasteRules)&&h&&i.push(...h());const p=Z(o,"addProseMirrorPlugins",a);if(p){const m=p();l.push(...m)}return l}).flat();return[Qy({editor:e,rules:r}),...sx({editor:e,rules:i}),...s]}get attributes(){return U0(this.extensions)}get nodeViews(){const{editor:e}=this,{nodeExtensions:n}=ya(this.extensions);return Object.fromEntries(n.filter(r=>!!Z(r,"addNodeView")).map(r=>{const i=this.attributes.filter(l=>l.type===r.name),s={name:r.name,options:r.options,storage:r.storage,editor:e,type:Ze(r.name,this.schema)},o=Z(r,"addNodeView",s);if(!o)return[];const a=(l,u,c,d)=>{const f=du(l,i);return o()({editor:e,node:l,getPos:c,decorations:d,HTMLAttributes:f,extension:r})};return[r.name,a]}))}setupExtensions(){this.extensions.forEach(e=>{var n;this.editor.extensionStorage[e.name]=e.storage;const r={name:e.name,options:e.options,storage:e.storage,editor:this.editor,type:cl(e.name,this.schema)};e.type==="mark"&&(!((n=oe(Z(e,"keepOnSplit",r)))!==null&&n!==void 0)||n)&&this.splittableMarks.push(e.name);const i=Z(e,"onBeforeCreate",r),s=Z(e,"onCreate",r),o=Z(e,"onUpdate",r),a=Z(e,"onSelectionUpdate",r),l=Z(e,"onTransaction",r),u=Z(e,"onFocus",r),c=Z(e,"onBlur",r),d=Z(e,"onDestroy",r);i&&this.editor.on("beforeCreate",i),s&&this.editor.on("create",s),o&&this.editor.on("update",o),a&&this.editor.on("selectionUpdate",a),l&&this.editor.on("transaction",l),u&&this.editor.on("focus",u),c&&this.editor.on("blur",c),d&&this.editor.on("destroy",d)})}}function ax(t){return Object.prototype.toString.call(t).slice(8,-1)}function dl(t){return ax(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function xa(t,e){const n={...t};return dl(t)&&dl(e)&&Object.keys(e).forEach(r=>{dl(e[r])?r in t?n[r]=xa(t[r],e[r]):Object.assign(n,{[r]:e[r]}):Object.assign(n,{[r]:e[r]})}),n}class xe{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=oe(Z(this,"addOptions",{name:this.name}))),this.storage=oe(Z(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new xe(e)}configure(e={}){const n=this.extend();return n.parent=this.parent,n.options=xa(this.options,e),n.storage=oe(Z(n,"addStorage",{name:n.name,options:n.options})),n}extend(e={}){const n=new xe({...this.config,...e});return n.parent=this,this.child=n,n.name=e.name?e.name:n.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=oe(Z(n,"addOptions",{name:n.name})),n.storage=oe(Z(n,"addStorage",{name:n.name,options:n.options})),n}}function ka(t,e,n){const{from:r,to:i}=e,{blockSeparator:s=` +`))),0,0):P.empty;let d=t.someProp("clipboardTextParser",f=>f(e,i,r,t));if(d)a=d;else{let f=i.marks(),{schema:h}=t.state,p=Yt.fromSchema(h);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=o.appendChild(document.createElement("p"));m&&g.appendChild(p.serializeNode(h.text(m,f)))})}}else t.someProp("transformPastedHTML",d=>{n=d(n,t)}),o=A2(n),gs&&M2(o);let u=o&&o.querySelector("[data-pm-slice]"),c=u&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(u.getAttribute("data-pm-slice")||"");if(c&&c[3])for(let d=+c[3];d>0;d--){let f=o.firstChild;for(;f&&f.nodeType!=1;)f=f.nextSibling;if(!f)break;o=f}if(a||(a=(t.someProp("clipboardParser")||t.someProp("domParser")||ps.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(l||c),context:i,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!w2.test(f.parentNode.nodeName)?{ignore:!0}:null}})),c)a=T2(Hd(a,+c[1],+c[2]),c[4]);else if(a=P.maxOpen(S2(a.content,i),!0),a.openStart||a.openEnd){let d=0,f=0;for(let h=a.content.firstChild;d{a=d(a,t)}),a}const w2=/^(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 S2(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let i=e.node(n).contentMatchAt(e.index(n)),s,o=[];if(t.forEach(a=>{if(!o)return;let l=i.findWrapping(a.type),u;if(!l)return o=null;if(u=o.length&&s.length&&_0(l,s,a,o[o.length-1],0))o[o.length-1]=u;else{o.length&&(o[o.length-1]=C0(o[o.length-1],s.length));let c=E0(a,l);o.push(c),i=i.matchType(c.type),s=l}}),o)return O.from(o)}return t}function E0(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,O.from(t));return t}function _0(t,e,n,r,i){if(i1&&(s=0),i=n&&(a=e<0?o.contentMatchAt(0).fillBefore(a,s<=i).append(a):a.append(o.contentMatchAt(o.childCount).fillBefore(O.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(a))}function Hd(t,e,n){return e]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=S0().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),i;if((i=r&&w0[r[1].toLowerCase()])&&(t=i.map(s=>"<"+s+">").join("")+t+i.map(s=>"").reverse().join("")),n.innerHTML=t,i)for(let s=0;s=0;a-=2){let l=n.nodes[r[a]];if(!l||l.hasRequiredAttrs())break;i=O.from(l.create(r[a+1],i)),s++,o++}return new P(i,s,o)}const at={},lt={},D2={touchstart:!0,touchmove:!0};class O2{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastAndroidDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function N2(t){for(let e in at){let n=at[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{R2(t,r)&&!Wu(t,r)&&(t.editable||!(r.type in lt))&&n(t,r)},D2[e]?{passive:!0}:void 0)}ot&&t.dom.addEventListener("input",()=>null),cu(t)}function In(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function L2(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function cu(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>Wu(t,r))})}function Wu(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function R2(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function I2(t,e){!Wu(t,e)&&at[e.type]&&(t.editable||!(e.type in lt))&&at[e.type](t,e)}lt.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!M0(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Pt&&st&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),ni&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",i=>i(t,tr(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||C2(t,n)?n.preventDefault():In(t,"key")};lt.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};lt.keypress=(t,e)=>{let n=e;if(M0(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Dt&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof X)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(n.charCode);!/[\r\n]/.test(i)&&!t.someProp("handleTextInput",s=>s(t,r.$from.pos,r.$to.pos,i))&&t.dispatch(t.state.tr.insertText(i).scrollIntoView()),n.preventDefault()}};function ma(t){return{left:t.clientX,top:t.clientY}}function F2(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function ju(t,e,n,r,i){if(r==-1)return!1;let s=t.state.doc.resolve(r);for(let o=s.depth+1;o>0;o--)if(t.someProp(e,a=>o>s.depth?a(t,n,s.nodeAfter,s.before(o),i,!0):a(t,n,s.node(o),s.before(o),i,!1)))return!0;return!1}function Xr(t,e,n){t.focused||t.focus();let r=t.state.tr.setSelection(e);n=="pointer"&&r.setMeta("pointer",!0),t.dispatch(r)}function H2(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&ee.isSelectable(r)?(Xr(t,new ee(n),"pointer"),!0):!1}function B2(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof ee&&(r=n.node);let s=t.state.doc.resolve(e);for(let o=s.depth+1;o>0;o--){let a=o>s.depth?s.nodeAfter:s.node(o);if(ee.isSelectable(a)){r&&n.$from.depth>0&&o>=n.$from.depth&&s.before(n.$from.depth+1)==n.$from.pos?i=s.before(n.$from.depth):i=s.before(o);break}}return i!=null?(Xr(t,ee.create(t.state.doc,i),"pointer"),!0):!1}function P2(t,e,n,r,i){return ju(t,"handleClickOn",e,n,r)||t.someProp("handleClick",s=>s(t,e,r))||(i?B2(t,n):H2(t,n))}function $2(t,e,n,r){return ju(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function z2(t,e,n,r){return ju(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||V2(t,n,r)}function V2(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(Xr(t,X.create(r,0,r.content.size),"pointer"),!0):!1;let i=r.resolve(e);for(let s=i.depth+1;s>0;s--){let o=s>i.depth?i.nodeAfter:i.node(s),a=i.before(s);if(o.inlineContent)Xr(t,X.create(r,a+1,a+1+o.content.size),"pointer");else if(ee.isSelectable(o))Xr(t,ee.create(r,a),"pointer");else continue;return!0}}function Gu(t){return Eo(t)}const A0=Dt?"metaKey":"ctrlKey";at.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=Gu(t),i=Date.now(),s="singleClick";i-t.input.lastClick.time<500&&F2(n,t.input.lastClick)&&!n[A0]&&(t.input.lastClick.type=="singleClick"?s="doubleClick":t.input.lastClick.type=="doubleClick"&&(s="tripleClick")),t.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:s};let o=t.posAtCoords(ma(n));o&&(s=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new U2(t,o,n,!!r)):(s=="doubleClick"?$2:z2)(t,o.pos,o.inside,n)?n.preventDefault():In(t,"pointer"))};class U2{constructor(e,n,r,i){this.view=e,this.pos=n,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[A0],this.allowDefault=r.shiftKey;let s,o;if(n.inside>-1)s=e.state.doc.nodeAt(n.inside),o=n.inside;else{let c=e.state.doc.resolve(n.pos);s=c.parent,o=c.depth?c.before():0}const a=i?null:r.target,l=a?e.docView.nearestDesc(a,!0):null;this.target=l?l.dom:null;let{selection:u}=e.state;(r.button==0&&s.type.spec.draggable&&s.type.spec.selectable!==!1||u instanceof ee&&u.from<=o&&u.to>o)&&(this.mightDrag={node:s,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&zt&&!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)),In(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(()=>kn(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(ma(e))),this.updateAllowDefault(e),this.allowDefault||!n?In(this.view,"pointer"):P2(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ot&&this.mightDrag&&!this.mightDrag.node.isAtom||st&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(Xr(this.view,ne.near(this.view.state.doc.resolve(n.pos)),"pointer"),e.preventDefault()):In(this.view,"pointer")}move(e){this.updateAllowDefault(e),In(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)}}at.touchstart=t=>{t.input.lastTouch=Date.now(),Gu(t),In(t,"pointer")};at.touchmove=t=>{t.input.lastTouch=Date.now(),In(t,"pointer")};at.contextmenu=t=>Gu(t);function M0(t,e){return t.composing?!0:ot&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const q2=Pt?5e3:-1;lt.compositionstart=lt.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$from;if(e.selection.empty&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))t.markCursor=t.state.storedMarks||n.marks(),Eo(t,!0),t.markCursor=null;else if(Eo(t),zt&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let i=r.focusNode,s=r.focusOffset;i&&i.nodeType==1&&s!=0;){let o=s<0?i.lastChild:i.childNodes[s-1];if(!o)break;if(o.nodeType==3){t.domSelection().collapse(o,o.nodeValue.length);break}else i=o,s=-1}}t.input.composing=!0}T0(t,q2)};lt.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,T0(t,20))};function T0(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>Eo(t),e))}function D0(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=K2());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function Z2(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=Hb(e.focusNode,e.focusOffset),r=Bb(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let i=r.pmViewDesc;if(!i||!i.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let s=n.pmViewDesc;if(!(!s||!s.isText(n.nodeValue)))return r}}return n}function K2(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function Eo(t,e=!1){if(!(Pt&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),D0(t),e||t.docView&&t.docView.dirty){let n=Zu(t);return n&&!n.eq(t.state.selection)?t.dispatch(t.state.tr.setSelection(n)):t.updateState(t.state),!0}return!1}}function W2(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const qi=ht&&$n<15||ni&&qb<604;at.copy=lt.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let s=qi?null:n.clipboardData,o=r.content(),{dom:a,text:l}=k0(t,o);s?(n.preventDefault(),s.clearData(),s.setData("text/html",a.innerHTML),s.setData("text/plain",l)):W2(t,a),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function j2(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function G2(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?Zi(t,r.value,null,i,e):Zi(t,r.textContent,r.innerHTML,i,e)},50)}function Zi(t,e,n,r,i){let s=v0(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",l=>l(t,i,s||P.empty)))return!0;if(!s)return!1;let o=j2(s),a=o?t.state.tr.replaceSelectionWith(o,r):t.state.tr.replaceSelection(s);return t.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function O0(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}lt.paste=(t,e)=>{let n=e;if(t.composing&&!Pt)return;let r=qi?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&Zi(t,O0(r),r.getData("text/html"),i,n)?n.preventDefault():G2(t,n)};class N0{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const L0=Dt?"altKey":"ctrlKey";at.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=t.state.selection,s=i.empty?null:t.posAtCoords(ma(n)),o;if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof ee?i.to-1:i.to))){if(r&&r.mightDrag)o=ee.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let c=t.docView.nearestDesc(n.target,!0);c&&c.node.type.spec.draggable&&c!=t.docView&&(o=ee.create(t.state.doc,c.posBefore))}}let a=(o||t.state.selection).content(),{dom:l,text:u}=k0(t,a);n.dataTransfer.clearData(),n.dataTransfer.setData(qi?"Text":"text/html",l.innerHTML),n.dataTransfer.effectAllowed="copyMove",qi||n.dataTransfer.setData("text/plain",u),t.dragging=new N0(a,!n[L0],o)};at.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};lt.dragover=lt.dragenter=(t,e)=>e.preventDefault();lt.drop=(t,e)=>{let n=e,r=t.dragging;if(t.dragging=null,!n.dataTransfer)return;let i=t.posAtCoords(ma(n));if(!i)return;let s=t.state.doc.resolve(i.pos),o=r&&r.slice;o?t.someProp("transformPasted",p=>{o=p(o,t)}):o=v0(t,O0(n.dataTransfer),qi?null:n.dataTransfer.getData("text/html"),!1,s);let a=!!(r&&!n[L0]);if(t.someProp("handleDrop",p=>p(t,n,o||P.empty,a))){n.preventDefault();return}if(!o)return;n.preventDefault();let l=o?Jp(t.state.doc,s.pos,o):s.pos;l==null&&(l=s.pos);let u=t.state.tr;if(a){let{node:p}=r;p?p.replace(u):u.deleteSelection()}let c=u.mapping.map(l),d=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,f=u.doc;if(d?u.replaceRangeWith(c,c,o.content.firstChild):u.replaceRange(c,c,o),u.doc.eq(f))return;let h=u.doc.resolve(c);if(d&&ee.isSelectable(o.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(o.content.firstChild))u.setSelection(new ee(h));else{let p=u.mapping.map(l);u.mapping.maps[u.mapping.maps.length-1].forEach((m,g,y,x)=>p=x),u.setSelection(Ku(t,h,u.doc.resolve(p)))}t.focus(),t.dispatch(u.setMeta("uiEvent","drop"))};at.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&kn(t)},20))};at.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};at.beforeinput=(t,e)=>{if(st&&Pt&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",s=>s(t,tr(8,"Backspace")))))return;let{$cursor:i}=t.state.selection;i&&i.pos>0&&t.dispatch(t.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let t in lt)at[t]=lt[t];function Ki(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}class _o{constructor(e,n){this.toDOM=e,this.spec=n||dr,this.side=this.spec.side||0}map(e,n,r,i){let{pos:s,deleted:o}=e.mapResult(n.from+i,this.side<0?-1:1);return o?null:new Be(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof _o&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Ki(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Vn{constructor(e,n){this.attrs=e,this.spec=n||dr}map(e,n,r,i){let s=e.map(n.from+i,this.spec.inclusiveStart?-1:1)-r,o=e.map(n.to+i,this.spec.inclusiveEnd?1:-1)-r;return s>=o?null:new Be(s,o,this)}valid(e,n){return n.from=e&&(!s||s(a.spec))&&r.push(a.copy(a.from+i,a.to+i))}for(let o=0;oe){let a=this.children[o]+1;this.children[o+2].findInner(e-a,n-a,r,i+a,s)}}map(e,n,r){return this==et||e.maps.length==0?this:this.mapInner(e,n,0,0,r||dr)}mapInner(e,n,r,i,s){let o;for(let a=0;a{let u=l+r,c;if(c=I0(n,a,u)){for(i||(i=this.children.slice());sa&&d.to=e){this.children[a]==e&&(r=this.children[a+2]);break}let s=e+1,o=s+n.content.size;for(let a=0;as&&l.type instanceof Vn){let u=Math.max(s,l.from)-s,c=Math.min(o,l.to)-s;ui.map(e,n,dr));return Tn.from(r)}forChild(e,n){if(n.isLeaf)return ve.empty;let r=[];for(let i=0;in instanceof ve)?e:e.reduce((n,r)=>n.concat(r instanceof ve?r:r.members),[]))}}}function J2(t,e,n,r,i,s,o){let a=t.slice();for(let u=0,c=s;u{let g=m-p-(h-f);for(let y=0;yx+c-d)continue;let k=a[y]+c-d;h>=k?a[y+1]=f<=k?-2:-1:f>=c&&g&&(a[y]+=g,a[y+1]+=g)}d+=g}),c=n.maps[u].map(c,-1)}let l=!1;for(let u=0;u=r.content.size){l=!0;continue}let f=n.map(t[u+1]+s,-1),h=f-i,{index:p,offset:m}=r.content.findIndex(d),g=r.maybeChild(p);if(g&&m==d&&m+g.nodeSize==h){let y=a[u+2].mapInner(n,g,c+1,t[u]+s+1,o);y!=et?(a[u]=d,a[u+1]=h,a[u+2]=y):(a[u+1]=-2,l=!0)}else l=!0}if(l){let u=Y2(a,t,e,n,i,s,o),c=Co(u,r,0,o);e=c.local;for(let d=0;dn&&o.to{let u=I0(t,a,l+n);if(u){s=!0;let c=Co(u,a,n+l+1,r);c!=et&&i.push(l,l+a.nodeSize,c)}});let o=R0(s?F0(t):t,-n).sort(fr);for(let a=0;a0;)e++;t.splice(e,0,n)}function ol(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=et&&e.push(r)}),t.cursorWrapper&&e.push(ve.create(t.state.doc,[t.cursorWrapper.deco])),Tn.from(e)}const X2={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Q2=ht&&$n<=11;class ey{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 ty{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new ey,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;ii.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),Q2&&(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,X2)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let n=0;nthis.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(Od(this.view)){if(this.suppressingSelectionUpdates)return kn(this.view);if(ht&&$n<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&br(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,r;for(let s=e.focusNode;s;s=Ui(s))n.add(s);for(let s=e.anchorNode;s;s=Ui(s))if(n.has(s)){r=s;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&Od(e)&&!this.ignoreSelectionChange(r),s=-1,o=-1,a=!1,l=[];if(e.editable)for(let c=0;c1){let c=l.filter(d=>d.nodeName=="BR");if(c.length==2){let d=c[0],f=c[1];d.parentNode&&d.parentNode.parentNode==f.parentNode?f.remove():d.remove()}}let u=null;s<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)-1||i)&&(s>-1&&(e.docView.markDirty(s,o),ny(e)),this.handleDOMChange(s,o,a,l),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||kn(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let c=0;ci;g--){let y=r.childNodes[g-1],x=y.pmViewDesc;if(y.nodeName=="BR"&&!x){s=g;break}if(!x||x.size)break}let d=t.state.doc,f=t.someProp("domParser")||ps.fromSchema(t.state.schema),h=d.resolve(o),p=null,m=f.parse(r,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:i,to:s,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:sy,context:h});if(u&&u[0].pos!=null){let g=u[0].pos,y=u[1]&&u[1].pos;y==null&&(y=g),p={anchor:g+o,head:y+o}}return{doc:m,sel:p,from:o,to:a}}function sy(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(ot&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}else if(t.parentNode.lastChild==t||ot&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}const oy=/^(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 ay(t,e,n,r,i){let s=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let w=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,N=Zu(t,w);if(N&&!t.state.selection.eq(N)){if(st&&Pt&&t.input.lastKeyCode===13&&Date.now()-100K(t,tr(13,"Enter"))))return;let $=t.state.tr.setSelection(N);w=="pointer"?$.setMeta("pointer",!0):w=="key"&&$.scrollIntoView(),s&&$.setMeta("composition",s),t.dispatch($)}return}let o=t.state.doc.resolve(e),a=o.sharedDepth(n);e=o.before(a+1),n=t.state.doc.resolve(n).after(a+1);let l=t.state.selection,u=iy(t,e,n),c=t.state.doc,d=c.slice(u.from,u.to),f,h;t.input.lastKeyCode===8&&Date.now()-100Date.now()-225||Pt)&&i.some(w=>w.nodeType==1&&!oy.test(w.nodeName))&&(!p||p.endA>=p.endB)&&t.someProp("handleKeyDown",w=>w(t,tr(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!p)if(r&&l instanceof X&&!l.empty&&l.$head.sameParent(l.$anchor)&&!t.composing&&!(u.sel&&u.sel.anchor!=u.sel.head))p={start:l.from,endA:l.to,endB:l.to};else{if(u.sel){let w=Vd(t,t.state.doc,u.sel);if(w&&!w.eq(t.state.selection)){let N=t.state.tr.setSelection(w);s&&N.setMeta("composition",s),t.dispatch(N)}}return}t.input.domChangeCount++,t.state.selection.fromt.state.selection.from&&p.start<=t.state.selection.from+2&&t.state.selection.from>=u.from?p.start=t.state.selection.from:p.endA=t.state.selection.to-2&&t.state.selection.to<=u.to&&(p.endB+=t.state.selection.to-p.endA,p.endA=t.state.selection.to)),ht&&$n<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>u.from&&u.doc.textBetween(p.start-u.from-1,p.start-u.from+1)=="  "&&(p.start--,p.endA--,p.endB--);let m=u.doc.resolveNoCache(p.start-u.from),g=u.doc.resolveNoCache(p.endB-u.from),y=c.resolve(p.start),x=m.sameParent(g)&&m.parent.inlineContent&&y.end()>=p.endA,k;if((ni&&t.input.lastIOSEnter>Date.now()-225&&(!x||i.some(w=>w.nodeName=="DIV"||w.nodeName=="P"))||!x&&m.posw(t,tr(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>p.start&&uy(c,p.start,p.endA,m,g)&&t.someProp("handleKeyDown",w=>w(t,tr(8,"Backspace")))){Pt&&st&&t.domObserver.suppressSelectionUpdates();return}st&&Pt&&p.endB==p.start&&(t.input.lastAndroidDelete=Date.now()),Pt&&!x&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==p.endA&&(p.endB-=2,g=u.doc.resolveNoCache(p.endB-u.from),setTimeout(()=>{t.someProp("handleKeyDown",function(w){return w(t,tr(13,"Enter"))})},20));let b=p.start,E=p.endA,v,C,T;if(x){if(m.pos==g.pos)ht&&$n<=11&&m.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>kn(t),20)),v=t.state.tr.delete(b,E),C=c.resolve(p.start).marksAcross(c.resolve(p.endA));else if(p.endA==p.endB&&(T=ly(m.parent.content.cut(m.parentOffset,g.parentOffset),y.parent.content.cut(y.parentOffset,p.endA-y.start()))))v=t.state.tr,T.type=="add"?v.addMark(b,E,T.mark):v.removeMark(b,E,T.mark);else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let w=m.parent.textBetween(m.parentOffset,g.parentOffset);if(t.someProp("handleTextInput",N=>N(t,b,E,w)))return;v=t.state.tr.insertText(w,b,E)}}if(v||(v=t.state.tr.replace(b,E,u.doc.slice(p.start-u.from,p.endB-u.from))),u.sel){let w=Vd(t,v.doc,u.sel);w&&!(st&&Pt&&t.composing&&w.empty&&(p.start!=p.endB||t.input.lastAndroidDeletee.content.size?null:Ku(t,e.resolve(n.anchor),e.resolve(n.head))}function ly(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,i=n,s=r,o,a,l;for(let c=0;cc.mark(a.addToSet(c.marks));else if(i.length==0&&s.length==1)a=s[0],o="remove",l=c=>c.mark(a.removeFromSet(c.marks));else return null;let u=[];for(let c=0;cn||al(o,!0,!1)0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,i++,e=!1;if(n){let s=t.node(r).maybeChild(t.indexAfter(r));for(;s&&!s.isLeaf;)s=s.firstChild,i++}return i}function cy(t,e,n,r,i){let s=t.findDiffStart(e,n);if(s==null)return null;let{a:o,b:a}=t.findDiffEnd(e,n+t.size,n+e.size);if(i=="end"){let l=Math.max(0,s-Math.min(o,a));r-=o+l-s}if(o=o?s-r:0;s-=l,s&&s=a?s-r:0;s-=l,s&&s=56320&&e<=57343&&n>=55296&&n<=56319}class dy{constructor(e,n){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new O2,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(jd),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=Kd(this),Zd(this),this.nodeViews=Wd(this),this.docView=wd(this.state.doc,qd(this),ol(this),this.dom,this),this.domObserver=new ty(this,(r,i,s,o)=>ay(this,r,i,s,o)),this.domObserver.start(),N2(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let n in e)this._props[n]=e[n];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&cu(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(jd),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let i=this.state,s=!1,o=!1;e.storedMarks&&this.composing&&(D0(this),o=!0),this.state=e;let a=i.plugins!=e.plugins||this._props.plugins!=n.plugins;if(a||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let h=Wd(this);hy(h,this.nodeViews)&&(this.nodeViews=h,s=!0)}(a||n.handleDOMEvents!=this._props.handleDOMEvents)&&cu(this),this.editable=Kd(this),Zd(this);let l=ol(this),u=qd(this),c=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",d=s||!this.docView.matchesNode(e.doc,u,l);(d||!e.selection.eq(i.selection))&&(o=!0);let f=c=="preserve"&&o&&this.dom.style.overflowAnchor==null&&Wb(this);if(o){this.domObserver.stop();let h=d&&(ht||st)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&fy(i.selection,e.selection);if(d){let p=st?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Z2(this)),(s||!this.docView.update(e.doc,u,l,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=wd(e.doc,u,l,this.dom,this)),p&&!this.trackWrites&&(h=!0)}h||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&b2(this))?kn(this,h):(b0(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),c=="reset"?this.dom.scrollTop=0:c=="to selection"?this.scrollToSelection():f&&jb(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof ee){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&xd(this,n.getBoundingClientRect(),e)}else xd(this,this.coordsAtPos(this.state.selection.head,1),e)}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n0&&this.state.doc.nodeAt(s))==r.node&&(i=s)}this.dragging=new N0(e.slice,e.move,i<0?void 0:ee.create(this.state.doc,i))}someProp(e,n){let r=this._props&&this._props[e],i;if(r!=null&&(i=n?n(r):r))return i;for(let o=0;on.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return e2(this,e)}coordsAtPos(e,n=1){return u0(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,r=-1){let i=this.docView.posFromDOM(e,n,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,n){return s2(this,n||this.state,e)}pasteHTML(e,n){return Zi(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return Zi(this,e,null,!0,n||new ClipboardEvent("paste"))}destroy(){this.docView&&(L2(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],ol(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Ib())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return I2(this,e)}dispatch(e){let n=this._props.dispatchTransaction;n?n.call(this,e):this.updateState(this.state.apply(e))}domSelectionRange(){return ot&&this.root.nodeType===11&&$b(this.dom.ownerDocument)==this.dom?ry(this):this.domSelection()}domSelection(){return this.root.getSelection()}}function qd(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(t.state)),n)for(let r in n)r=="class"?e.class+=" "+n[r]:r=="style"?e.style=(e.style?e.style+";":"")+n[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(n[r]))}),e.translate||(e.translate="no"),[Be.node(0,t.state.doc.content.size,e)]}function Zd(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:Be.widget(t.state.selection.head,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function Kd(t){return!t.someProp("editable",e=>e(t.state)===!1)}function fy(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}function Wd(t){let e=Object.create(null);function n(r){for(let i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function hy(t,e){let n=0,r=0;for(let i in t){if(t[i]!=e[i])return!0;n++}for(let i in e)r++;return n!=r}function jd(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var qn={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:"'"},wo={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},py=typeof navigator<"u"&&/Mac/.test(navigator.platform),my=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Ye=0;Ye<10;Ye++)qn[48+Ye]=qn[96+Ye]=String(Ye);for(var Ye=1;Ye<=24;Ye++)qn[Ye+111]="F"+Ye;for(var Ye=65;Ye<=90;Ye++)qn[Ye]=String.fromCharCode(Ye+32),wo[Ye]=String.fromCharCode(Ye);for(var ll in qn)wo.hasOwnProperty(ll)||(wo[ll]=qn[ll]);function gy(t){var e=py&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||my&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?wo:qn)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}const by=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function yy(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,i,s,o;for(let a=0;a127)&&(s=qn[r.keyCode])&&s!=i){let a=e[ul(s,r)];if(a&&a(n.state,n.dispatch,n))return!0}}return!1}}const vy=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function H0(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const Ey=(t,e,n)=>{let r=H0(t,n);if(!r)return!1;let i=Qu(r);if(!i){let o=r.blockRange(),a=o&&mi(o);return a==null?!1:(e&&e(t.tr.lift(o,a).scrollIntoView()),!0)}let s=i.nodeBefore;if(!s.type.spec.isolating&&z0(t,i,e))return!0;if(r.parent.content.size==0&&(ri(s,"end")||ee.isSelectable(s))){let o=da(t.doc,r.before(),r.after(),P.empty);if(o&&o.slice.size{let r=H0(t,n);if(!r)return!1;let i=Qu(r);return i?B0(t,i,e):!1},Cy=(t,e,n)=>{let r=P0(t,n);if(!r)return!1;let i=ec(r);return i?B0(t,i,e):!1};function B0(t,e,n){let r=e.nodeBefore,i=r,s=e.pos-1;for(;!i.isTextblock;s--){if(i.type.spec.isolating)return!1;let c=i.lastChild;if(!c)return!1;i=c}let o=e.nodeAfter,a=o,l=e.pos+1;for(;!a.isTextblock;l++){if(a.type.spec.isolating)return!1;let c=a.firstChild;if(!c)return!1;a=c}let u=da(t.doc,s,l,P.empty);if(!u||u.from!=s||u instanceof ze&&u.slice.size>=l-s)return!1;if(n){let c=t.tr.step(u);c.setSelection(X.create(c.doc,s)),n(c.scrollIntoView())}return!0}function ri(t,e,n=!1){for(let r=t;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}const wy=(t,e,n)=>{let{$head:r,empty:i}=t.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;s=Qu(r)}let o=s&&s.nodeBefore;return!o||!ee.isSelectable(o)?!1:(e&&e(t.tr.setSelection(ee.create(t.doc,s.pos-o.nodeSize)).scrollIntoView()),!0)};function Qu(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function P0(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset{let r=P0(t,n);if(!r)return!1;let i=ec(r);if(!i)return!1;let s=i.nodeAfter;if(z0(t,i,e))return!0;if(r.parent.content.size==0&&(ri(s,"start")||ee.isSelectable(s))){let o=da(t.doc,r.before(),r.after(),P.empty);if(o&&o.slice.size{let{$head:r,empty:i}=t.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset=0;e--){let n=t.node(e);if(t.index(e)+1{let n=t.selection,r=n instanceof ee,i;if(r){if(n.node.isTextblock||!Gn(t.doc,n.from))return!1;i=n.from}else if(i=ca(t.doc,n.from,-1),i==null)return!1;if(e){let s=t.tr.join(i);r&&s.setSelection(ee.create(s.doc,i-t.doc.resolve(i).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},Ty=(t,e)=>{let n=t.selection,r;if(n instanceof ee){if(n.node.isTextblock||!Gn(t.doc,n.to))return!1;r=n.to}else if(r=ca(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},Dy=(t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),s=i&&mi(i);return s==null?!1:(e&&e(t.tr.lift(i,s).scrollIntoView()),!0)},Oy=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(` +`).scrollIntoView()),!0)};function $0(t){for(let e=0;e{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),s=n.indexAfter(-1),o=$0(i.contentMatchAt(s));if(!o||!i.canReplaceWith(s,s,o))return!1;if(e){let a=n.after(),l=t.tr.replaceWith(a,a,o.createAndFill());l.setSelection(ne.near(l.doc.resolve(a),1)),e(l.scrollIntoView())}return!0},Ly=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof Nt||r.parent.inlineContent||i.parent.inlineContent)return!1;let s=$0(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let o=(!r.parentOffset&&i.index(){let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let s=n.before();if(Jr(t.doc,s))return e&&e(t.tr.split(s).scrollIntoView()),!0}let r=n.blockRange(),i=r&&mi(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)},Iy=(t,e)=>{let{$from:n,to:r}=t.selection,i,s=n.sharedDepth(r);return s==0?!1:(i=n.before(s),e&&e(t.tr.setSelection(ee.create(t.doc,i))),!0)};function Fy(t,e,n){let r=e.nodeBefore,i=e.nodeAfter,s=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(s-1,s)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(i.isTextblock||Gn(t.doc,e.pos))?!1:(n&&n(t.tr.clearIncompatible(e.pos,r.type,r.contentMatchAt(r.childCount)).join(e.pos).scrollIntoView()),!0)}function z0(t,e,n){let r=e.nodeBefore,i=e.nodeAfter,s,o;if(r.type.spec.isolating||i.type.spec.isolating)return!1;if(Fy(t,e,n))return!0;let a=e.parent.canReplace(e.index(),e.index()+1);if(a&&(s=(o=r.contentMatchAt(r.childCount)).findWrapping(i.type))&&o.matchType(s[0]||i.type).validEnd){if(n){let d=e.pos+i.nodeSize,f=O.empty;for(let m=s.length-1;m>=0;m--)f=O.from(s[m].create(null,f));f=O.from(r.copy(f));let h=t.tr.step(new Ue(e.pos-1,d,e.pos,d,new P(f,1,0),s.length,!0)),p=d+2*s.length;Gn(h.doc,p)&&h.join(p),n(h.scrollIntoView())}return!0}let l=ne.findFrom(e,1),u=l&&l.$from.blockRange(l.$to),c=u&&mi(u);if(c!=null&&c>=e.depth)return n&&n(t.tr.lift(u,c).scrollIntoView()),!0;if(a&&ri(i,"start",!0)&&ri(r,"end")){let d=r,f=[];for(;f.push(d),!d.isTextblock;)d=d.lastChild;let h=i,p=1;for(;!h.isTextblock;h=h.firstChild)p++;if(d.canReplace(d.childCount,d.childCount,h.content)){if(n){let m=O.empty;for(let y=f.length-1;y>=0;y--)m=O.from(f[y].copy(m));let g=t.tr.step(new Ue(e.pos-f.length,e.pos+i.nodeSize,e.pos+p,e.pos+i.nodeSize-p,new P(m,f.length,0),0,!0));n(g.scrollIntoView())}return!0}}return!1}function V0(t){return function(e,n){let r=e.selection,i=t<0?r.$from:r.$to,s=i.depth;for(;i.node(s).isInline;){if(!s)return!1;s--}return i.node(s).isTextblock?(n&&n(e.tr.setSelection(X.create(e.doc,t<0?i.start(s):i.end(s)))),!0):!1}}const Hy=V0(-1),By=V0(1);function Py(t,e=null){return function(n,r){let{$from:i,$to:s}=n.selection,o=i.blockRange(s),a=o&&zu(o,t,e);return a?(r&&r(n.tr.wrap(o,a).scrollIntoView()),!0):!1}}function Gd(t,e=null){return function(n,r){let i=!1;for(let s=0;s{if(i)return!1;if(!(!l.isTextblock||l.hasMarkup(t,e)))if(l.type==t)i=!0;else{let c=n.doc.resolve(u),d=c.index();i=c.parent.canReplaceWith(d,d+1,t)}})}if(!i)return!1;if(r){let s=n.tr;for(let o=0;o=2&&i.node(o.depth-1).type.compatibleContent(t)&&o.startIndex==0){if(i.index(o.depth-1)==0)return!1;let c=n.doc.resolve(o.start-2);l=new bo(c,c,o.depth),o.endIndex=0;c--)s=O.from(n[c].type.create(n[c].attrs,s));t.step(new Ue(e.start-(r?2:0),e.end,e.start,e.end,new P(s,0,0),n.length,!0));let o=0;for(let c=0;co.childCount>0&&o.firstChild.type==t);return s?n?r.node(s.depth-1).type==t?Uy(e,n,t,s):qy(e,n,s):!0:!1}}function Uy(t,e,n,r){let i=t.tr,s=r.end,o=r.$to.end(r.depth);sm;p--)h-=i.child(p).nodeSize,r.delete(h-1,h+1);let s=r.doc.resolve(n.start),o=s.nodeAfter;if(r.mapping.map(n.end)!=n.start+s.nodeAfter.nodeSize)return!1;let a=n.startIndex==0,l=n.endIndex==i.childCount,u=s.node(-1),c=s.index(-1);if(!u.canReplace(c+(a?0:1),c+1,o.content.append(l?O.empty:O.from(i))))return!1;let d=s.pos,f=d+o.nodeSize;return r.step(new Ue(d-(a?1:0),f+(l?1:0),d+1,f-1,new P((a?O.empty:O.from(i.copy(O.empty))).append(l?O.empty:O.from(i.copy(O.empty))),a?0:1,l?0:1),a?0:1)),e(r.scrollIntoView()),!0}function Zy(t){return function(e,n){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,u=>u.childCount>0&&u.firstChild.type==t);if(!s)return!1;let o=s.startIndex;if(o==0)return!1;let a=s.parent,l=a.child(o-1);if(l.type!=t)return!1;if(n){let u=l.lastChild&&l.lastChild.type==a.type,c=O.from(u?t.create():null),d=new P(O.from(t.create(null,O.from(a.type.create(null,c)))),u?3:1,0),f=s.start,h=s.end;n(e.tr.step(new Ue(f-(u?3:1),h,f,h,d,1,!0)).scrollIntoView())}return!0}}function ga(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:i}=n,{storedMarks:s}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return s},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,s=n.storedMarks,n}}}class ba{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:n,state:r}=this,{view:i}=n,{tr:s}=r,o=this.buildProps(s);return Object.fromEntries(Object.entries(e).map(([a,l])=>[a,(...c)=>{const d=l(...c)(o);return!s.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(s),d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,n=!0){const{rawCommands:r,editor:i,state:s}=this,{view:o}=i,a=[],l=!!e,u=e||s.tr,c=()=>(!l&&n&&!u.getMeta("preventDispatch")&&!this.hasCustomState&&o.dispatch(u),a.every(f=>f===!0)),d={...Object.fromEntries(Object.entries(r).map(([f,h])=>[f,(...m)=>{const g=this.buildProps(u,n),y=h(...m)(g);return a.push(y),d}])),run:c};return d}createCan(e){const{rawCommands:n,state:r}=this,i=!1,s=e||r.tr,o=this.buildProps(s,i);return{...Object.fromEntries(Object.entries(n).map(([l,u])=>[l,(...c)=>u(...c)({...o,dispatch:void 0})])),chain:()=>this.createChain(s,i)}}buildProps(e,n=!0){const{rawCommands:r,editor:i,state:s}=this,{view:o}=i,a={tr:e,editor:i,view:o,state:ga({state:s,transaction:e}),dispatch:n?()=>{}:void 0,chain:()=>this.createChain(e,n),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(r).map(([l,u])=>[l,(...c)=>u(...c)(a)]))}};return a}}let Ky=class{constructor(){this.callbacks={}}on(e,n){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(n),this}emit(e,...n){const r=this.callbacks[e];return r&&r.forEach(i=>i.apply(this,n)),this}off(e,n){const r=this.callbacks[e];return r&&(n?this.callbacks[e]=r.filter(i=>i!==n):delete this.callbacks[e]),this}removeAllListeners(){this.callbacks={}}};function Z(t,e,n){return t.config[e]===void 0&&t.parent?Z(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?Z(t.parent,e,n):null}):t.config[e]}function ya(t){const e=t.filter(i=>i.type==="extension"),n=t.filter(i=>i.type==="node"),r=t.filter(i=>i.type==="mark");return{baseExtensions:e,nodeExtensions:n,markExtensions:r}}function U0(t){const e=[],{nodeExtensions:n,markExtensions:r}=ya(t),i=[...n,...r],s={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.forEach(o=>{const a={name:o.name,options:o.options,storage:o.storage},l=Z(o,"addGlobalAttributes",a);if(!l)return;l().forEach(c=>{c.types.forEach(d=>{Object.entries(c.attributes).forEach(([f,h])=>{e.push({type:d,name:f,attribute:{...s,...h}})})})})}),i.forEach(o=>{const a={name:o.name,options:o.options,storage:o.storage},l=Z(o,"addAttributes",a);if(!l)return;const u=l();Object.entries(u).forEach(([c,d])=>{const f={...s,...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:o.name,name:c,attribute:f})})}),e}function Ze(t,e){if(typeof t=="string"){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}function le(...t){return t.filter(e=>!!e).reduce((e,n)=>{const r={...e};return Object.entries(n).forEach(([i,s])=>{if(!r[i]){r[i]=s;return}if(i==="class"){const a=s?s.split(" "):[],l=r[i]?r[i].split(" "):[],u=a.filter(c=>!l.includes(c));r[i]=[...l,...u].join(" ")}else i==="style"?r[i]=[r[i],s].join("; "):r[i]=s}),r},{})}function du(t,e){return e.filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(t.attrs)||{}:{[n.name]:t.attrs[n.name]}).reduce((n,r)=>le(n,r),{})}function q0(t){return typeof t=="function"}function oe(t,e=void 0,...n){return q0(t)?e?t.bind(e)(...n):t(...n):t}function Wy(t={}){return Object.keys(t).length===0&&t.constructor===Object}function jy(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function Jd(t,e){return t.style?t:{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;const i=e.reduce((s,o)=>{const a=o.attribute.parseHTML?o.attribute.parseHTML(n):jy(n.getAttribute(o.name));return a==null?s:{...s,[o.name]:a}},{});return{...r,...i}}}}function Yd(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&Wy(n)?!1:n!=null))}function Gy(t,e){var n;const r=U0(t),{nodeExtensions:i,markExtensions:s}=ya(t),o=(n=i.find(u=>Z(u,"topNode")))===null||n===void 0?void 0:n.name,a=Object.fromEntries(i.map(u=>{const c=r.filter(y=>y.type===u.name),d={name:u.name,options:u.options,storage:u.storage,editor:e},f=t.reduce((y,x)=>{const k=Z(x,"extendNodeSchema",d);return{...y,...k?k(u):{}}},{}),h=Yd({...f,content:oe(Z(u,"content",d)),marks:oe(Z(u,"marks",d)),group:oe(Z(u,"group",d)),inline:oe(Z(u,"inline",d)),atom:oe(Z(u,"atom",d)),selectable:oe(Z(u,"selectable",d)),draggable:oe(Z(u,"draggable",d)),code:oe(Z(u,"code",d)),defining:oe(Z(u,"defining",d)),isolating:oe(Z(u,"isolating",d)),attrs:Object.fromEntries(c.map(y=>{var x;return[y.name,{default:(x=y==null?void 0:y.attribute)===null||x===void 0?void 0:x.default}]}))}),p=oe(Z(u,"parseHTML",d));p&&(h.parseDOM=p.map(y=>Jd(y,c)));const m=Z(u,"renderHTML",d);m&&(h.toDOM=y=>m({node:y,HTMLAttributes:du(y,c)}));const g=Z(u,"renderText",d);return g&&(h.toText=g),[u.name,h]})),l=Object.fromEntries(s.map(u=>{const c=r.filter(g=>g.type===u.name),d={name:u.name,options:u.options,storage:u.storage,editor:e},f=t.reduce((g,y)=>{const x=Z(y,"extendMarkSchema",d);return{...g,...x?x(u):{}}},{}),h=Yd({...f,inclusive:oe(Z(u,"inclusive",d)),excludes:oe(Z(u,"excludes",d)),group:oe(Z(u,"group",d)),spanning:oe(Z(u,"spanning",d)),code:oe(Z(u,"code",d)),attrs:Object.fromEntries(c.map(g=>{var y;return[g.name,{default:(y=g==null?void 0:g.attribute)===null||y===void 0?void 0:y.default}]}))}),p=oe(Z(u,"parseHTML",d));p&&(h.parseDOM=p.map(g=>Jd(g,c)));const m=Z(u,"renderHTML",d);return m&&(h.toDOM=g=>m({mark:g,HTMLAttributes:du(g,c)})),[u.name,h]}));return new zp({topNode:o,nodes:a,marks:l})}function cl(t,e){return e.nodes[t]||e.marks[t]||null}function Xd(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}const Jy=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(i,s,o,a)=>{var l,u;const c=((u=(l=i.type.spec).toText)===null||u===void 0?void 0:u.call(l,{node:i,pos:s,parent:o,index:a}))||i.textContent||"%leaf%";n+=c.slice(0,Math.max(0,r-s))}),n};function tc(t){return Object.prototype.toString.call(t)==="[object RegExp]"}class ys{constructor(e){this.find=e.find,this.handler=e.handler}}const Yy=(t,e)=>{if(tc(e))return e.exec(t);const n=e(t);if(!n)return null;const r=[n.text];return r.index=n.index,r.input=t,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r};function Is(t){var e;const{editor:n,from:r,to:i,text:s,rules:o,plugin:a}=t,{view:l}=n;if(l.composing)return!1;const u=l.state.doc.resolve(r);if(u.parent.type.spec.code||!((e=u.nodeBefore||u.nodeAfter)===null||e===void 0)&&e.marks.find(f=>f.type.spec.code))return!1;let c=!1;const d=Jy(u)+s;return o.forEach(f=>{if(c)return;const h=Yy(d,f.find);if(!h)return;const p=l.state.tr,m=ga({state:l.state,transaction:p}),g={from:r-(h[0].length-s.length),to:i},{commands:y,chain:x,can:k}=new ba({editor:n,state:m});f.handler({state:m,range:g,match:h,commands:y,chain:x,can:k})===null||!p.steps.length||(p.setMeta(a,{transform:p,from:r,to:i,text:s}),l.dispatch(p),c=!0)}),c}function Xy(t){const{editor:e,rules:n}=t,r=new we({state:{init(){return null},apply(i,s){const o=i.getMeta(r);if(o)return o;const a=i.getMeta("applyInputRules");return!!a&&setTimeout(()=>{const{from:u,text:c}=a,d=u+c.length;Is({editor:e,from:u,to:d,text:c,rules:n,plugin:r})}),i.selectionSet||i.docChanged?null:s}},props:{handleTextInput(i,s,o,a){return Is({editor:e,from:s,to:o,text:a,rules:n,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:s}=i.state.selection;s&&Is({editor:e,from:s.pos,to:s.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(i,s){if(s.key!=="Enter")return!1;const{$cursor:o}=i.state.selection;return o?Is({editor:e,from:o.pos,to:o.pos,text:` +`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function Qy(t){return typeof t=="number"}class ex{constructor(e){this.find=e.find,this.handler=e.handler}}const tx=(t,e,n)=>{if(tc(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.map(i=>{const s=[i.text];return s.index=i.index,s.input=t,s.data=i.data,i.replaceWith&&(i.text.includes(i.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),s.push(i.replaceWith)),s}):[]};function nx(t){const{editor:e,state:n,from:r,to:i,rule:s,pasteEvent:o,dropEvent:a}=t,{commands:l,chain:u,can:c}=new ba({editor:e,state:n}),d=[];return n.doc.nodesBetween(r,i,(h,p)=>{if(!h.isTextblock||h.type.spec.code)return;const m=Math.max(r,p),g=Math.min(i,p+h.content.size),y=h.textBetween(m-p,g-p,void 0,"");tx(y,s.find,o).forEach(k=>{if(k.index===void 0)return;const b=m+k.index+1,E=b+k[0].length,v={from:n.tr.mapping.map(b),to:n.tr.mapping.map(E)},C=s.handler({state:n,range:v,match:k,commands:l,chain:u,can:c,pasteEvent:o,dropEvent:a});d.push(C)})}),d.every(h=>h!==null)}const rx=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)===null||e===void 0||e.setData("text/html",t),n};function ix(t){const{editor:e,rules:n}=t;let r=null,i=!1,s=!1,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,a=typeof DragEvent<"u"?new DragEvent("drop"):null;const l=({state:c,from:d,to:f,rule:h,pasteEvt:p})=>{const m=c.tr,g=ga({state:c,transaction:m});if(!(!nx({editor:e,state:g,from:Math.max(d-1,0),to:f.b-1,rule:h,pasteEvent:p,dropEvent:a})||!m.steps.length))return a=typeof DragEvent<"u"?new DragEvent("drop"):null,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,m};return n.map(c=>new we({view(d){const f=h=>{var p;r=!((p=d.dom.parentElement)===null||p===void 0)&&p.contains(h.target)?d.dom.parentElement:null};return window.addEventListener("dragstart",f),{destroy(){window.removeEventListener("dragstart",f)}}},props:{handleDOMEvents:{drop:(d,f)=>(s=r===d.dom.parentElement,a=f,!1),paste:(d,f)=>{var h;const p=(h=f.clipboardData)===null||h===void 0?void 0:h.getData("text/html");return o=f,i=!!(p!=null&&p.includes("data-pm-slice")),!1}}},appendTransaction:(d,f,h)=>{const p=d[0],m=p.getMeta("uiEvent")==="paste"&&!i,g=p.getMeta("uiEvent")==="drop"&&!s,y=p.getMeta("applyPasteRules"),x=!!y;if(!m&&!g&&!x)return;if(x){const{from:E,text:v}=y,C=E+v.length,T=rx(v);return l({rule:c,state:h,from:E,to:{b:C},pasteEvt:T})}const k=f.doc.content.findDiffStart(h.doc.content),b=f.doc.content.findDiffEnd(h.doc.content);if(!(!Qy(k)||!b||k===b.b))return l({rule:c,state:h,from:k,to:b,pasteEvt:o})}}))}function sx(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return[...new Set(e)]}class Zr{constructor(e,n){this.splittableMarks=[],this.editor=n,this.extensions=Zr.resolve(e),this.schema=Gy(this.extensions,n),this.setupExtensions()}static resolve(e){const n=Zr.sort(Zr.flatten(e)),r=sx(n.map(i=>i.name));return r.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${r.map(i=>`'${i}'`).join(", ")}]. This can lead to issues.`),n}static flatten(e){return e.map(n=>{const r={name:n.name,options:n.options,storage:n.storage},i=Z(n,"addExtensions",r);return i?[n,...this.flatten(i())]:n}).flat(10)}static sort(e){return e.sort((r,i)=>{const s=Z(r,"priority")||100,o=Z(i,"priority")||100;return s>o?-1:s{const r={name:n.name,options:n.options,storage:n.storage,editor:this.editor,type:cl(n.name,this.schema)},i=Z(n,"addCommands",r);return i?{...e,...i()}:e},{})}get plugins(){const{editor:e}=this,n=Zr.sort([...this.extensions].reverse()),r=[],i=[],s=n.map(o=>{const a={name:o.name,options:o.options,storage:o.storage,editor:e,type:cl(o.name,this.schema)},l=[],u=Z(o,"addKeyboardShortcuts",a);let c={};if(o.type==="mark"&&o.config.exitable&&(c.ArrowRight=()=>Ie.handleExit({editor:e,mark:o})),u){const m=Object.fromEntries(Object.entries(u()).map(([g,y])=>[g,()=>y({editor:e})]));c={...c,...m}}const d=ky(c);l.push(d);const f=Z(o,"addInputRules",a);Xd(o,e.options.enableInputRules)&&f&&r.push(...f());const h=Z(o,"addPasteRules",a);Xd(o,e.options.enablePasteRules)&&h&&i.push(...h());const p=Z(o,"addProseMirrorPlugins",a);if(p){const m=p();l.push(...m)}return l}).flat();return[Xy({editor:e,rules:r}),...ix({editor:e,rules:i}),...s]}get attributes(){return U0(this.extensions)}get nodeViews(){const{editor:e}=this,{nodeExtensions:n}=ya(this.extensions);return Object.fromEntries(n.filter(r=>!!Z(r,"addNodeView")).map(r=>{const i=this.attributes.filter(l=>l.type===r.name),s={name:r.name,options:r.options,storage:r.storage,editor:e,type:Ze(r.name,this.schema)},o=Z(r,"addNodeView",s);if(!o)return[];const a=(l,u,c,d)=>{const f=du(l,i);return o()({editor:e,node:l,getPos:c,decorations:d,HTMLAttributes:f,extension:r})};return[r.name,a]}))}setupExtensions(){this.extensions.forEach(e=>{var n;this.editor.extensionStorage[e.name]=e.storage;const r={name:e.name,options:e.options,storage:e.storage,editor:this.editor,type:cl(e.name,this.schema)};e.type==="mark"&&(!((n=oe(Z(e,"keepOnSplit",r)))!==null&&n!==void 0)||n)&&this.splittableMarks.push(e.name);const i=Z(e,"onBeforeCreate",r),s=Z(e,"onCreate",r),o=Z(e,"onUpdate",r),a=Z(e,"onSelectionUpdate",r),l=Z(e,"onTransaction",r),u=Z(e,"onFocus",r),c=Z(e,"onBlur",r),d=Z(e,"onDestroy",r);i&&this.editor.on("beforeCreate",i),s&&this.editor.on("create",s),o&&this.editor.on("update",o),a&&this.editor.on("selectionUpdate",a),l&&this.editor.on("transaction",l),u&&this.editor.on("focus",u),c&&this.editor.on("blur",c),d&&this.editor.on("destroy",d)})}}function ox(t){return Object.prototype.toString.call(t).slice(8,-1)}function dl(t){return ox(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function xa(t,e){const n={...t};return dl(t)&&dl(e)&&Object.keys(e).forEach(r=>{dl(e[r])?r in t?n[r]=xa(t[r],e[r]):Object.assign(n,{[r]:e[r]}):Object.assign(n,{[r]:e[r]})}),n}class xe{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=oe(Z(this,"addOptions",{name:this.name}))),this.storage=oe(Z(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new xe(e)}configure(e={}){const n=this.extend();return n.parent=this.parent,n.options=xa(this.options,e),n.storage=oe(Z(n,"addStorage",{name:n.name,options:n.options})),n}extend(e={}){const n=new xe({...this.config,...e});return n.parent=this,this.child=n,n.name=e.name?e.name:n.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=oe(Z(n,"addOptions",{name:n.name})),n.storage=oe(Z(n,"addStorage",{name:n.name,options:n.options})),n}}function ka(t,e,n){const{from:r,to:i}=e,{blockSeparator:s=` -`,textSerializers:o={}}=n||{};let a="";return t.nodesBetween(r,i,(l,u,c,d)=>{var f;l.isBlock&&u>r&&(a+=s);const h=o==null?void 0:o[l.type.name];if(h)return c&&(a+=h({node:l,pos:u,parent:c,index:d,range:e})),!1;l.isText&&(a+=(f=l==null?void 0:l.text)===null||f===void 0?void 0:f.slice(Math.max(r,u)-u,i-u))}),a}function Z0(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}const K0=xe.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new we({key:new Te("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:i}=e,{ranges:s}=i,o=Math.min(...s.map(c=>c.$from.pos)),a=Math.max(...s.map(c=>c.$to.pos)),l=Z0(n);return ka(r,{from:o,to:a},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:l})}}})]}}),lx=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window==null?void 0:window.getSelection())===null||n===void 0||n.removeAllRanges())}),!0),ux=(t=!1)=>({commands:e})=>e.setContent("",t),cx=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:i}=r;return n&&i.forEach(({$from:s,$to:o})=>{t.doc.nodesBetween(s.pos,o.pos,(a,l)=>{if(a.type.isText)return;const{doc:u,mapping:c}=e,d=u.resolve(c.map(l)),f=u.resolve(c.map(l+a.nodeSize)),h=d.blockRange(f);if(!h)return;const p=mi(h);if(a.type.isTextblock){const{defaultType:m}=d.parent.contentMatchAt(d.index());e.setNodeMarkup(h.start,m)}(p||p===0)&&e.lift(h,p)})}),!0},dx=t=>e=>t(e),fx=()=>({state:t,dispatch:e})=>Ry(t,e),hx=(t,e)=>({editor:n,tr:r})=>{const{state:i}=n,s=i.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const o=r.mapping.map(e);return r.insert(o,s.content),r.setSelection(new X(r.doc.resolve(o-1))),!0},px=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const i=t.selection.$anchor;for(let s=i.depth;s>0;s-=1)if(i.node(s).type===r.type){if(e){const a=i.before(s),l=i.after(s);t.delete(a,l).scrollIntoView()}return!0}return!1},mx=t=>({tr:e,state:n,dispatch:r})=>{const i=Ze(t,n.schema),s=e.selection.$anchor;for(let o=s.depth;o>0;o-=1)if(s.node(o).type===i){if(r){const l=s.before(o),u=s.after(o);e.delete(l,u).scrollIntoView()}return!0}return!1},gx=t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},bx=()=>({state:t,dispatch:e})=>Ey(t,e),yx=()=>({commands:t})=>t.keyboardShortcut("Enter"),xx=()=>({state:t,dispatch:e})=>Ly(t,e);function ii(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>n.strict?e[i]===t[i]:tc(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function fu(t,e,n={}){return t.find(r=>r.type===e&&ii(r.attrs,n))}function kx(t,e,n={}){return!!fu(t,e,n)}function nc(t,e,n={}){if(!t||!e)return;let r=t.parent.childAfter(t.parentOffset);if(t.parentOffset===r.offset&&r.offset!==0&&(r=t.parent.childBefore(t.parentOffset)),!r.node)return;const i=fu([...r.node.marks],e,n);if(!i)return;let s=r.index,o=t.start()+r.offset,a=s+1,l=o+r.node.nodeSize;for(fu([...r.node.marks],e,n);s>0&&i.isInSet(t.parent.child(s-1).marks);)s-=1,o-=t.parent.child(s).nodeSize;for(;a({tr:n,state:r,dispatch:i})=>{const s=En(t,r.schema),{doc:o,selection:a}=n,{$from:l,from:u,to:c}=a;if(i){const d=nc(l,s,e);if(d&&d.from<=u&&d.to>=c){const f=X.create(o,d.from,d.to);n.setSelection(f)}}return!0},Ex=t=>e=>{const n=typeof t=="function"?t(e):t;for(let r=0;r({editor:n,view:r,tr:i,dispatch:s})=>{e={scrollIntoView:!0,...e};const o=()=>{ic()&&r.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e!=null&&e.scrollIntoView&&n.commands.scrollIntoView())})};if(r.hasFocus()&&t===null||t===!1)return!0;if(s&&t===null&&!rc(n.state.selection))return o(),!0;const a=W0(i.doc,t)||n.state.selection,l=n.state.selection.eq(a);return s&&(l||i.setSelection(a),l&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},Cx=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),wx=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),j0=t=>{const e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){const r=e[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?t.removeChild(r):r.nodeType===1&&j0(r)}return t};function Xd(t){const e=`${t}`,n=new window.DOMParser().parseFromString(e,"text/html").body;return j0(n)}function So(t,e,n){n={slice:!0,parseOptions:{},...n};const r=typeof t=="object"&&t!==null,i=typeof t=="string";if(r)try{return Array.isArray(t)&&t.length>0?O.fromArray(t.map(o=>e.nodeFromJSON(o))):e.nodeFromJSON(t)}catch(s){return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",s),So("",e,n)}if(i){const s=ps.fromSchema(e);return n.slice?s.parseSlice(Xd(t),n.parseOptions).content:s.parse(Xd(t),n.parseOptions)}return So("",e,n)}function Sx(t,e,n){const r=t.steps.length-1;if(r{o===0&&(o=c)}),t.setSelection(ne.near(t.doc.resolve(o),n))}const Ax=t=>t.toString().startsWith("<"),Mx=(t,e,n)=>({tr:r,dispatch:i,editor:s})=>{if(i){n={parseOptions:{},updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};const o=So(e,s.schema,{parseOptions:{preserveWhitespace:"full",...n.parseOptions}});if(o.toString()==="<>")return!0;let{from:a,to:l}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},u=!0,c=!0;if((Ax(o)?o:[o]).forEach(h=>{h.check(),u=u?h.isText&&h.marks.length===0:!1,c=c?h.isBlock:!1}),a===l&&c){const{parent:h}=r.doc.resolve(a);h.isTextblock&&!h.type.spec.code&&!h.childCount&&(a-=1,l+=1)}let f;u?(Array.isArray(e)?f=e.map(h=>h.text||"").join(""):typeof e=="object"&&e&&e.text?f=e.text:f=e,r.insertText(f,a,l)):(f=o,r.replaceWith(a,l,f)),n.updateSelection&&Sx(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:a,text:f}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:a,text:f})}return!0},Tx=()=>({state:t,dispatch:e})=>Ty(t,e),Dx=()=>({state:t,dispatch:e})=>Dy(t,e),Ox=()=>({state:t,dispatch:e})=>_y(t,e),Nx=()=>({state:t,dispatch:e})=>Ay(t,e),Lx=()=>({tr:t,state:e,dispatch:n})=>{try{const r=ca(e.doc,e.selection.$from.pos,-1);return r==null?!1:(t.join(r,2),n&&n(t),!0)}catch{return!1}},Rx=()=>({state:t,dispatch:e,tr:n})=>{try{const r=ca(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},Ix=()=>({state:t,dispatch:e})=>Cy(t,e),Fx=()=>({state:t,dispatch:e})=>wy(t,e);function G0(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function Hx(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,i,s,o;for(let a=0;a({editor:e,view:n,tr:r,dispatch:i})=>{const s=Hx(t).split(/-(?!$)/),o=s.find(u=>!["Alt","Ctrl","Meta","Shift"].includes(u)),a=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.includes("Shift"),bubbles:!0,cancelable:!0}),l=e.captureTransaction(()=>{n.someProp("handleKeyDown",u=>u(n,a))});return l==null||l.steps.forEach(u=>{const c=u.map(r.mapping);c&&i&&r.maybeStep(c)}),!0};function xr(t,e,n={}){const{from:r,to:i,empty:s}=t.selection,o=e?Ze(e,t.schema):null,a=[];t.doc.nodesBetween(r,i,(d,f)=>{if(d.isText)return;const h=Math.max(r,f),p=Math.min(i,f+d.nodeSize);a.push({node:d,from:h,to:p})});const l=i-r,u=a.filter(d=>o?o.name===d.node.type.name:!0).filter(d=>ii(d.node.attrs,n,{strict:!1}));return s?!!u.length:u.reduce((d,f)=>d+f.to-f.from,0)>=l}const Px=(t,e={})=>({state:n,dispatch:r})=>{const i=Ze(t,n.schema);return xr(n,i,e)?Oy(n,r):!1},$x=()=>({state:t,dispatch:e})=>Iy(t,e),zx=t=>({state:e,dispatch:n})=>{const r=Ze(t,e.schema);return Uy(r)(e,n)},Vx=()=>({state:t,dispatch:e})=>Ny(t,e);function va(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function Qd(t,e){const n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((r,i)=>(n.includes(i)||(r[i]=t[i]),r),{})}const Ux=(t,e)=>({tr:n,state:r,dispatch:i})=>{let s=null,o=null;const a=va(typeof t=="string"?t:t.name,r.schema);return a?(a==="node"&&(s=Ze(t,r.schema)),a==="mark"&&(o=En(t,r.schema)),i&&n.selection.ranges.forEach(l=>{r.doc.nodesBetween(l.$from.pos,l.$to.pos,(u,c)=>{s&&s===u.type&&n.setNodeMarkup(c,void 0,Qd(u.attrs,e)),o&&u.marks.length&&u.marks.forEach(d=>{o===d.type&&n.addMark(c,c+u.nodeSize,o.create(Qd(d.attrs,e)))})})}),!0):!1},qx=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),Zx=()=>({tr:t,commands:e})=>e.setTextSelection({from:0,to:t.doc.content.size}),Kx=()=>({state:t,dispatch:e})=>Sy(t,e),Wx=()=>({state:t,dispatch:e})=>My(t,e),jx=()=>({state:t,dispatch:e})=>Fy(t,e),Gx=()=>({state:t,dispatch:e})=>Py(t,e),Jx=()=>({state:t,dispatch:e})=>By(t,e);function J0(t,e,n={}){return So(t,e,{slice:!1,parseOptions:n})}const Yx=(t,e=!1,n={})=>({tr:r,editor:i,dispatch:s})=>{const{doc:o}=r,a=J0(t,i.schema,n);return s&&r.replaceWith(0,o.content.size,a).setMeta("preventUpdate",!e),!0};function xs(t,e){const n=En(e,t.schema),{from:r,to:i,empty:s}=t.selection,o=[];s?(t.storedMarks&&o.push(...t.storedMarks),o.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,i,l=>{o.push(...l.marks)});const a=o.find(l=>l.type.name===n.name);return a?{...a.attrs}:{}}function Xx(t,e){const n=new Vu(t);return e.forEach(r=>{r.steps.forEach(i=>{n.step(i)})}),n}function Qx(t){for(let e=0;e{e(r)&&n.push({node:r,pos:i})}),n}function e3(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(i,s)=>{n(i)&&r.push({node:i,pos:s})}),r}function Y0(t,e){for(let n=t.depth;n>0;n-=1){const r=t.node(n);if(e(r))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:r}}}function Ea(t){return e=>Y0(e.$from,t)}function sc(t,e){const n=Yt.fromSchema(e).serializeFragment(t),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}function t3(t,e){const n={from:0,to:t.content.size};return ka(t,n,e)}function n3(t,e){const n=Ze(e,t.schema),{from:r,to:i}=t.selection,s=[];t.doc.nodesBetween(r,i,a=>{s.push(a)});const o=s.reverse().find(a=>a.type.name===n.name);return o?{...o.attrs}:{}}function X0(t,e){const n=va(typeof e=="string"?e:e.name,t.schema);return n==="node"?n3(t,e):n==="mark"?xs(t,e):{}}function r3(t,e=JSON.stringify){const n={};return t.filter(r=>{const i=e(r);return Object.prototype.hasOwnProperty.call(n,i)?!1:n[i]=!0})}function i3(t){const e=r3(t);return e.length===1?e:e.filter((n,r)=>!e.filter((s,o)=>o!==r).some(s=>n.oldRange.from>=s.oldRange.from&&n.oldRange.to<=s.oldRange.to&&n.newRange.from>=s.newRange.from&&n.newRange.to<=s.newRange.to))}function s3(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((i,s)=>{const o=[];if(i.ranges.length)i.forEach((a,l)=>{o.push({from:a,to:l})});else{const{from:a,to:l}=n[s];if(a===void 0||l===void 0)return;o.push({from:a,to:l})}o.forEach(({from:a,to:l})=>{const u=e.slice(s).map(a,-1),c=e.slice(s).map(l),d=e.invert().map(u,-1),f=e.invert().map(c);r.push({oldRange:{from:d,to:f},newRange:{from:u,to:c}})})}),i3(r)}function oc(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(i=>{const s=n.resolve(t-1),o=nc(s,i.type);o&&r.push({mark:i,...o})}):n.nodesBetween(t,e,(i,s)=>{!i||(i==null?void 0:i.nodeSize)===void 0||r.push(...i.marks.map(o=>({from:s,to:s+i.nodeSize,mark:o})))}),r}function oo(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const i=t.find(s=>s.type===e&&s.name===r);return i?i.attribute.keepOnSplit:!1}))}function pu(t,e,n={}){const{empty:r,ranges:i}=t.selection,s=e?En(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(d=>s?s.name===d.type.name:!0).find(d=>ii(d.attrs,n,{strict:!1}));let o=0;const a=[];if(i.forEach(({$from:d,$to:f})=>{const h=d.pos,p=f.pos;t.doc.nodesBetween(h,p,(m,g)=>{if(!m.isText&&!m.marks.length)return;const y=Math.max(h,g),x=Math.min(p,g+m.nodeSize),k=x-y;o+=k,a.push(...m.marks.map(b=>({mark:b,from:y,to:x})))})}),o===0)return!1;const l=a.filter(d=>s?s.name===d.mark.type.name:!0).filter(d=>ii(d.mark.attrs,n,{strict:!1})).reduce((d,f)=>d+f.to-f.from,0),u=a.filter(d=>s?d.mark.type!==s&&d.mark.type.excludes(s):!0).reduce((d,f)=>d+f.to-f.from,0);return(l>0?l+u:l)>=o}function o3(t,e,n={}){if(!e)return xr(t,null,n)||pu(t,null,n);const r=va(e,t.schema);return r==="node"?xr(t,e,n):r==="mark"?pu(t,e,n):!1}function ef(t,e){const{nodeExtensions:n}=ya(e),r=n.find(o=>o.name===t);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},s=oe(Z(r,"group",i));return typeof s!="string"?!1:s.split(" ").includes("list")}function a3(t){var e;const n=(e=t.type.createAndFill())===null||e===void 0?void 0:e.toJSON(),r=t.toJSON();return JSON.stringify(n)===JSON.stringify(r)}function Q0(t){return t instanceof ee}function ks(t,e,n){const i=t.state.doc.content.size,s=xn(e,0,i),o=xn(n,0,i),a=t.coordsAtPos(s),l=t.coordsAtPos(o,-1),u=Math.min(a.top,l.top),c=Math.max(a.bottom,l.bottom),d=Math.min(a.left,l.left),f=Math.max(a.right,l.right),h=f-d,p=c-u,y={top:u,bottom:c,left:d,right:f,width:h,height:p,x:d,y:u};return{...y,toJSON:()=>y}}function l3(t,e,n){var r;const{selection:i}=e;let s=null;if(rc(i)&&(s=i.$cursor),s){const a=(r=t.storedMarks)!==null&&r!==void 0?r:s.marks();return!!n.isInSet(a)||!a.some(l=>l.type.excludes(n))}const{ranges:o}=i;return o.some(({$from:a,$to:l})=>{let u=a.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(a.pos,l.pos,(c,d,f)=>{if(u)return!1;if(c.isInline){const h=!f||f.type.allowsMarkType(n),p=!!n.isInSet(c.marks)||!c.marks.some(m=>m.type.excludes(n));u=h&&p}return!u}),u})}const u3=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:s}=n,{empty:o,ranges:a}=s,l=En(t,r.schema);if(i)if(o){const u=xs(r,l);n.addStoredMark(l.create({...u,...e}))}else a.forEach(u=>{const c=u.$from.pos,d=u.$to.pos;r.doc.nodesBetween(c,d,(f,h)=>{const p=Math.max(h,c),m=Math.min(h+f.nodeSize,d);f.marks.find(y=>y.type===l)?f.marks.forEach(y=>{l===y.type&&n.addMark(p,m,l.create({...y.attrs,...e}))}):n.addMark(p,m,l.create(e))})});return l3(r,n,l)},c3=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),d3=(t,e={})=>({state:n,dispatch:r,chain:i})=>{const s=Ze(t,n.schema);return s.isTextblock?i().command(({commands:o})=>jd(s,e)(n)?!0:o.clearNodes()).command(({state:o})=>jd(s,e)(o,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},f3=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,i=xn(t,0,r.content.size),s=ee.create(r,i);e.setSelection(s)}return!0},h3=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:i,to:s}=typeof t=="number"?{from:t,to:t}:t,o=X.atStart(r).from,a=X.atEnd(r).to,l=xn(i,o,a),u=xn(s,o,a),c=X.create(r,l,u);e.setSelection(c)}return!0},p3=t=>({state:e,dispatch:n})=>{const r=Ze(t,e.schema);return Ky(r)(e,n)};function tf(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const r=n.filter(i=>e==null?void 0:e.includes(i.type.name));t.tr.ensureMarks(r)}}const m3=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:i})=>{const{selection:s,doc:o}=e,{$from:a,$to:l}=s,u=i.extensionManager.attributes,c=oo(u,a.node().type.name,a.node().attrs);if(s instanceof ee&&s.node.isBlock)return!a.parentOffset||!Jr(o,a.pos)?!1:(r&&(t&&tf(n,i.extensionManager.splittableMarks),e.split(a.pos).scrollIntoView()),!0);if(!a.parent.isBlock)return!1;if(r){const d=l.parentOffset===l.parent.content.size;s instanceof X&&e.deleteSelection();const f=a.depth===0?void 0:Qx(a.node(-1).contentMatchAt(a.indexAfter(-1)));let h=d&&f?[{type:f,attrs:c}]:void 0,p=Jr(e.doc,e.mapping.map(a.pos),1,h);if(!h&&!p&&Jr(e.doc,e.mapping.map(a.pos),1,f?[{type:f}]:void 0)&&(p=!0,h=f?[{type:f,attrs:c}]:void 0),p&&(e.split(e.mapping.map(a.pos),1,h),f&&!d&&!a.parentOffset&&a.parent.type!==f)){const m=e.mapping.map(a.before()),g=e.doc.resolve(m);a.node(-1).canReplaceWith(g.index(),g.index()+1,f)&&e.setNodeMarkup(e.mapping.map(a.before()),f)}t&&tf(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return!0},g3=t=>({tr:e,state:n,dispatch:r,editor:i})=>{var s;const o=Ze(t,n.schema),{$from:a,$to:l}=n.selection,u=n.selection.node;if(u&&u.isBlock||a.depth<2||!a.sameParent(l))return!1;const c=a.node(-1);if(c.type!==o)return!1;const d=i.extensionManager.attributes;if(a.parent.content.size===0&&a.node(-1).childCount===a.indexAfter(-1)){if(a.depth===2||a.node(-3).type!==o||a.index(-2)!==a.node(-2).childCount-1)return!1;if(r){let g=O.empty;const y=a.index(-1)?1:a.index(-2)?2:3;for(let C=a.depth-y;C>=a.depth-3;C-=1)g=O.from(a.node(C).copy(g));const x=a.indexAfter(-1){if(v>-1)return!1;C.isTextblock&&C.content.size===0&&(v=T+1)}),v>-1&&e.setSelection(X.near(e.doc.resolve(v))),e.scrollIntoView()}return!0}const f=l.pos===a.end()?c.contentMatchAt(0).defaultType:null,h=oo(d,c.type.name,c.attrs),p=oo(d,a.node().type.name,a.node().attrs);e.delete(a.pos,l.pos);const m=f?[{type:o,attrs:h},{type:f,attrs:p}]:[{type:o,attrs:h}];if(!Jr(e.doc,a.pos,2))return!1;if(r){const{selection:g,storedMarks:y}=n,{splittableMarks:x}=i.extensionManager,k=y||g.$to.parentOffset&&g.$from.marks();if(e.split(a.pos,2,m).scrollIntoView(),!k||!r)return!0;const b=k.filter(E=>x.includes(E.type.name));e.ensureMarks(b)}return!0},fl=(t,e)=>{const n=Ea(o=>o.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;const i=t.doc.nodeAt(r);return n.node.type===(i==null?void 0:i.type)&&Gn(t.doc,n.pos)&&t.join(n.pos),!0},hl=(t,e)=>{const n=Ea(o=>o.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;const i=t.doc.nodeAt(r);return n.node.type===(i==null?void 0:i.type)&&Gn(t.doc,r)&&t.join(r),!0},b3=(t,e,n,r={})=>({editor:i,tr:s,state:o,dispatch:a,chain:l,commands:u,can:c})=>{const{extensions:d,splittableMarks:f}=i.extensionManager,h=Ze(t,o.schema),p=Ze(e,o.schema),{selection:m,storedMarks:g}=o,{$from:y,$to:x}=m,k=y.blockRange(x),b=g||m.$to.parentOffset&&m.$from.marks();if(!k)return!1;const E=Ea(v=>ef(v.type.name,d))(m);if(k.depth>=1&&E&&k.depth-E.depth<=1){if(E.node.type===h)return u.liftListItem(p);if(ef(E.node.type.name,d)&&h.validContent(E.node.content)&&a)return l().command(()=>(s.setNodeMarkup(E.pos,h),!0)).command(()=>fl(s,h)).command(()=>hl(s,h)).run()}return!n||!b||!a?l().command(()=>c().wrapInList(h,r)?!0:u.clearNodes()).wrapInList(h,r).command(()=>fl(s,h)).command(()=>hl(s,h)).run():l().command(()=>{const v=c().wrapInList(h,r),C=b.filter(T=>f.includes(T.type.name));return s.ensureMarks(C),v?!0:u.clearNodes()}).wrapInList(h,r).command(()=>fl(s,h)).command(()=>hl(s,h)).run()},y3=(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:s=!1}=n,o=En(t,r.schema);return pu(r,o,e)?i.unsetMark(o,{extendEmptyMarkRange:s}):i.setMark(o,e)},x3=(t,e,n={})=>({state:r,commands:i})=>{const s=Ze(t,r.schema),o=Ze(e,r.schema);return xr(r,s,n)?i.setNode(o):i.setNode(s,n)},k3=(t,e={})=>({state:n,commands:r})=>{const i=Ze(t,n.schema);return xr(n,i,e)?r.lift(i):r.wrapIn(i,e)},v3=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r=0;l-=1)o.step(a.steps[l].invert(a.docs[l]));if(s.text){const l=o.doc.resolve(s.from).marks();o.replaceWith(s.from,s.to,t.schema.text(s.text,l))}else o.delete(s.from,s.to)}return!0}}return!1},E3=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:r,ranges:i}=n;return r||e&&i.forEach(s=>{t.removeMark(s.$from.pos,s.$to.pos)}),!0},_3=(t,e={})=>({tr:n,state:r,dispatch:i})=>{var s;const{extendEmptyMarkRange:o=!1}=e,{selection:a}=n,l=En(t,r.schema),{$from:u,empty:c,ranges:d}=a;if(!i)return!0;if(c&&o){let{from:f,to:h}=a;const p=(s=u.marks().find(g=>g.type===l))===null||s===void 0?void 0:s.attrs,m=nc(u,l,p);m&&(f=m.from,h=m.to),n.removeMark(f,h,l)}else d.forEach(f=>{n.removeMark(f.$from.pos,f.$to.pos,l)});return n.removeStoredMark(l),!0},C3=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let s=null,o=null;const a=va(typeof t=="string"?t:t.name,r.schema);return a?(a==="node"&&(s=Ze(t,r.schema)),a==="mark"&&(o=En(t,r.schema)),i&&n.selection.ranges.forEach(l=>{const u=l.$from.pos,c=l.$to.pos;r.doc.nodesBetween(u,c,(d,f)=>{s&&s===d.type&&n.setNodeMarkup(f,void 0,{...d.attrs,...e}),o&&d.marks.length&&d.marks.forEach(h=>{if(o===h.type){const p=Math.max(f,u),m=Math.min(f+d.nodeSize,c);n.addMark(p,m,o.create({...h.attrs,...e}))}})})}),!0):!1},w3=(t,e={})=>({state:n,dispatch:r})=>{const i=Ze(t,n.schema);return $y(i,e)(n,r)},S3=(t,e={})=>({state:n,dispatch:r})=>{const i=Ze(t,n.schema);return zy(i,e)(n,r)};var A3=Object.freeze({__proto__:null,blur:lx,clearContent:ux,clearNodes:cx,command:dx,createParagraphNear:fx,cut:hx,deleteCurrentNode:px,deleteNode:mx,deleteRange:gx,deleteSelection:bx,enter:yx,exitCode:xx,extendMarkRange:vx,first:Ex,focus:_x,forEach:Cx,insertContent:wx,insertContentAt:Mx,joinUp:Tx,joinDown:Dx,joinBackward:Ox,joinForward:Nx,joinItemBackward:Lx,joinItemForward:Rx,joinTextblockBackward:Ix,joinTextblockForward:Fx,keyboardShortcut:Bx,lift:Px,liftEmptyBlock:$x,liftListItem:zx,newlineInCode:Vx,resetAttributes:Ux,scrollIntoView:qx,selectAll:Zx,selectNodeBackward:Kx,selectNodeForward:Wx,selectParentNode:jx,selectTextblockEnd:Gx,selectTextblockStart:Jx,setContent:Yx,setMark:u3,setMeta:c3,setNode:d3,setNodeSelection:f3,setTextSelection:h3,sinkListItem:p3,splitBlock:m3,splitListItem:g3,toggleList:b3,toggleMark:y3,toggleNode:x3,toggleWrap:k3,undoInputRule:v3,unsetAllMarks:E3,unsetMark:_3,updateAttributes:C3,wrapIn:w3,wrapInList:S3});const e1=xe.create({name:"commands",addCommands(){return{...A3}}}),t1=xe.create({name:"editable",addProseMirrorPlugins(){return[new we({key:new Te("editable"),props:{editable:()=>this.editor.options.editable}})]}}),n1=xe.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new we({key:new Te("focusEvents"),props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;const r=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,n)=>{t.isFocused=!1;const r=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),r1=xe.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:a})=>{const{selection:l,doc:u}=a,{empty:c,$anchor:d}=l,{pos:f,parent:h}=d,p=d.parent.isTextblock&&f>0?a.doc.resolve(f-1):d,m=p.parent.type.spec.isolating,g=d.pos-d.parentOffset,y=m&&p.parent.childCount===1?g===d.pos:ne.atStart(u).from===f;return!c||!h.type.isTextblock||h.textContent.length||!y||y&&d.parent.type.name==="paragraph"?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},i={...r},s={...r,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return ic()||G0()?s:i},addProseMirrorPlugins(){return[new we({key:new Te("clearDocument"),appendTransaction:(t,e,n)=>{if(!(t.some(p=>p.docChanged)&&!e.doc.eq(n.doc)))return;const{empty:i,from:s,to:o}=e.selection,a=ne.atStart(e.doc).from,l=ne.atEnd(e.doc).to;if(i||!(s===a&&o===l)||!(n.doc.textBetween(0,n.doc.content.size," "," ").length===0))return;const d=n.tr,f=ga({state:n,transaction:d}),{commands:h}=new ba({editor:this.editor,state:f});if(h.clearNodes(),!!d.steps.length)return d}})]}}),i1=xe.create({name:"tabindex",addProseMirrorPlugins(){return[new we({key:new Te("tabindex"),props:{attributes:this.editor.isEditable?{tabindex:"0"}:{}}})]}});var M3=Object.freeze({__proto__:null,ClipboardTextSerializer:K0,Commands:e1,Editable:t1,FocusEvents:n1,Keymap:r1,Tabindex:i1});class nr{constructor(e,n,r=!1,i=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=n,this.currentNode=i}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!==null&&e!==void 0?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let n=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}n=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:n,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(e);return new nr(n,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new nr(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 nr(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,r)=>{const i=n.isBlock&&!n.isTextblock,s=this.pos+r+1,o=this.resolvedPos.doc.resolve(s);if(!i&&o.depth<=this.depth)return;const a=new nr(o,this.editor,i,i?n:null);i&&(a.actualDepth=this.depth+1),e.push(new nr(o,this.editor,i,i?n:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,n={}){let r=null,i=this.parent;for(;i&&!r;){if(i.node.type.name===e)if(Object.keys(n).length>0){const s=i.node.attrs,o=Object.keys(n);for(let a=0;a{r&&i.length>0||(o.node.type.name===e&&s.every(l=>n[l]===o.node.attrs[l])&&i.push(o),!(r&&i.length>0)&&(i=i.concat(o.querySelectorAll(e,n,r))))}),i}setAttribute(e){const n=this.editor.state.selection;this.editor.chain().setTextSelection(this.from).updateAttributes(this.node.type.name,e).setTextSelection(n.from).run()}}const T3=`.ProseMirror { +`,textSerializers:o={}}=n||{};let a="";return t.nodesBetween(r,i,(l,u,c,d)=>{var f;l.isBlock&&u>r&&(a+=s);const h=o==null?void 0:o[l.type.name];if(h)return c&&(a+=h({node:l,pos:u,parent:c,index:d,range:e})),!1;l.isText&&(a+=(f=l==null?void 0:l.text)===null||f===void 0?void 0:f.slice(Math.max(r,u)-u,i-u))}),a}function Z0(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}const K0=xe.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new we({key:new Te("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:i}=e,{ranges:s}=i,o=Math.min(...s.map(c=>c.$from.pos)),a=Math.max(...s.map(c=>c.$to.pos)),l=Z0(n);return ka(r,{from:o,to:a},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:l})}}})]}}),ax=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window==null?void 0:window.getSelection())===null||n===void 0||n.removeAllRanges())}),!0),lx=(t=!1)=>({commands:e})=>e.setContent("",t),ux=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:i}=r;return n&&i.forEach(({$from:s,$to:o})=>{t.doc.nodesBetween(s.pos,o.pos,(a,l)=>{if(a.type.isText)return;const{doc:u,mapping:c}=e,d=u.resolve(c.map(l)),f=u.resolve(c.map(l+a.nodeSize)),h=d.blockRange(f);if(!h)return;const p=mi(h);if(a.type.isTextblock){const{defaultType:m}=d.parent.contentMatchAt(d.index());e.setNodeMarkup(h.start,m)}(p||p===0)&&e.lift(h,p)})}),!0},cx=t=>e=>t(e),dx=()=>({state:t,dispatch:e})=>Ly(t,e),fx=(t,e)=>({editor:n,tr:r})=>{const{state:i}=n,s=i.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const o=r.mapping.map(e);return r.insert(o,s.content),r.setSelection(new X(r.doc.resolve(o-1))),!0},hx=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const i=t.selection.$anchor;for(let s=i.depth;s>0;s-=1)if(i.node(s).type===r.type){if(e){const a=i.before(s),l=i.after(s);t.delete(a,l).scrollIntoView()}return!0}return!1},px=t=>({tr:e,state:n,dispatch:r})=>{const i=Ze(t,n.schema),s=e.selection.$anchor;for(let o=s.depth;o>0;o-=1)if(s.node(o).type===i){if(r){const l=s.before(o),u=s.after(o);e.delete(l,u).scrollIntoView()}return!0}return!1},mx=t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},gx=()=>({state:t,dispatch:e})=>vy(t,e),bx=()=>({commands:t})=>t.keyboardShortcut("Enter"),yx=()=>({state:t,dispatch:e})=>Ny(t,e);function ii(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>n.strict?e[i]===t[i]:tc(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function fu(t,e,n={}){return t.find(r=>r.type===e&&ii(r.attrs,n))}function xx(t,e,n={}){return!!fu(t,e,n)}function nc(t,e,n={}){if(!t||!e)return;let r=t.parent.childAfter(t.parentOffset);if(t.parentOffset===r.offset&&r.offset!==0&&(r=t.parent.childBefore(t.parentOffset)),!r.node)return;const i=fu([...r.node.marks],e,n);if(!i)return;let s=r.index,o=t.start()+r.offset,a=s+1,l=o+r.node.nodeSize;for(fu([...r.node.marks],e,n);s>0&&i.isInSet(t.parent.child(s-1).marks);)s-=1,o-=t.parent.child(s).nodeSize;for(;a({tr:n,state:r,dispatch:i})=>{const s=En(t,r.schema),{doc:o,selection:a}=n,{$from:l,from:u,to:c}=a;if(i){const d=nc(l,s,e);if(d&&d.from<=u&&d.to>=c){const f=X.create(o,d.from,d.to);n.setSelection(f)}}return!0},vx=t=>e=>{const n=typeof t=="function"?t(e):t;for(let r=0;r({editor:n,view:r,tr:i,dispatch:s})=>{e={scrollIntoView:!0,...e};const o=()=>{ic()&&r.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e!=null&&e.scrollIntoView&&n.commands.scrollIntoView())})};if(r.hasFocus()&&t===null||t===!1)return!0;if(s&&t===null&&!rc(n.state.selection))return o(),!0;const a=W0(i.doc,t)||n.state.selection,l=n.state.selection.eq(a);return s&&(l||i.setSelection(a),l&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},_x=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),Cx=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),j0=t=>{const e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){const r=e[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?t.removeChild(r):r.nodeType===1&&j0(r)}return t};function Qd(t){const e=`${t}`,n=new window.DOMParser().parseFromString(e,"text/html").body;return j0(n)}function So(t,e,n){n={slice:!0,parseOptions:{},...n};const r=typeof t=="object"&&t!==null,i=typeof t=="string";if(r)try{return Array.isArray(t)&&t.length>0?O.fromArray(t.map(o=>e.nodeFromJSON(o))):e.nodeFromJSON(t)}catch(s){return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",s),So("",e,n)}if(i){const s=ps.fromSchema(e);return n.slice?s.parseSlice(Qd(t),n.parseOptions).content:s.parse(Qd(t),n.parseOptions)}return So("",e,n)}function wx(t,e,n){const r=t.steps.length-1;if(r{o===0&&(o=c)}),t.setSelection(ne.near(t.doc.resolve(o),n))}const Sx=t=>t.toString().startsWith("<"),Ax=(t,e,n)=>({tr:r,dispatch:i,editor:s})=>{if(i){n={parseOptions:{},updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};const o=So(e,s.schema,{parseOptions:{preserveWhitespace:"full",...n.parseOptions}});if(o.toString()==="<>")return!0;let{from:a,to:l}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},u=!0,c=!0;if((Sx(o)?o:[o]).forEach(h=>{h.check(),u=u?h.isText&&h.marks.length===0:!1,c=c?h.isBlock:!1}),a===l&&c){const{parent:h}=r.doc.resolve(a);h.isTextblock&&!h.type.spec.code&&!h.childCount&&(a-=1,l+=1)}let f;u?(Array.isArray(e)?f=e.map(h=>h.text||"").join(""):typeof e=="object"&&e&&e.text?f=e.text:f=e,r.insertText(f,a,l)):(f=o,r.replaceWith(a,l,f)),n.updateSelection&&wx(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:a,text:f}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:a,text:f})}return!0},Mx=()=>({state:t,dispatch:e})=>My(t,e),Tx=()=>({state:t,dispatch:e})=>Ty(t,e),Dx=()=>({state:t,dispatch:e})=>Ey(t,e),Ox=()=>({state:t,dispatch:e})=>Sy(t,e),Nx=()=>({tr:t,state:e,dispatch:n})=>{try{const r=ca(e.doc,e.selection.$from.pos,-1);return r==null?!1:(t.join(r,2),n&&n(t),!0)}catch{return!1}},Lx=()=>({state:t,dispatch:e,tr:n})=>{try{const r=ca(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},Rx=()=>({state:t,dispatch:e})=>_y(t,e),Ix=()=>({state:t,dispatch:e})=>Cy(t,e);function G0(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function Fx(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,i,s,o;for(let a=0;a({editor:e,view:n,tr:r,dispatch:i})=>{const s=Fx(t).split(/-(?!$)/),o=s.find(u=>!["Alt","Ctrl","Meta","Shift"].includes(u)),a=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.includes("Shift"),bubbles:!0,cancelable:!0}),l=e.captureTransaction(()=>{n.someProp("handleKeyDown",u=>u(n,a))});return l==null||l.steps.forEach(u=>{const c=u.map(r.mapping);c&&i&&r.maybeStep(c)}),!0};function xr(t,e,n={}){const{from:r,to:i,empty:s}=t.selection,o=e?Ze(e,t.schema):null,a=[];t.doc.nodesBetween(r,i,(d,f)=>{if(d.isText)return;const h=Math.max(r,f),p=Math.min(i,f+d.nodeSize);a.push({node:d,from:h,to:p})});const l=i-r,u=a.filter(d=>o?o.name===d.node.type.name:!0).filter(d=>ii(d.node.attrs,n,{strict:!1}));return s?!!u.length:u.reduce((d,f)=>d+f.to-f.from,0)>=l}const Bx=(t,e={})=>({state:n,dispatch:r})=>{const i=Ze(t,n.schema);return xr(n,i,e)?Dy(n,r):!1},Px=()=>({state:t,dispatch:e})=>Ry(t,e),$x=t=>({state:e,dispatch:n})=>{const r=Ze(t,e.schema);return Vy(r)(e,n)},zx=()=>({state:t,dispatch:e})=>Oy(t,e);function va(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function ef(t,e){const n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((r,i)=>(n.includes(i)||(r[i]=t[i]),r),{})}const Vx=(t,e)=>({tr:n,state:r,dispatch:i})=>{let s=null,o=null;const a=va(typeof t=="string"?t:t.name,r.schema);return a?(a==="node"&&(s=Ze(t,r.schema)),a==="mark"&&(o=En(t,r.schema)),i&&n.selection.ranges.forEach(l=>{r.doc.nodesBetween(l.$from.pos,l.$to.pos,(u,c)=>{s&&s===u.type&&n.setNodeMarkup(c,void 0,ef(u.attrs,e)),o&&u.marks.length&&u.marks.forEach(d=>{o===d.type&&n.addMark(c,c+u.nodeSize,o.create(ef(d.attrs,e)))})})}),!0):!1},Ux=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),qx=()=>({tr:t,commands:e})=>e.setTextSelection({from:0,to:t.doc.content.size}),Zx=()=>({state:t,dispatch:e})=>wy(t,e),Kx=()=>({state:t,dispatch:e})=>Ay(t,e),Wx=()=>({state:t,dispatch:e})=>Iy(t,e),jx=()=>({state:t,dispatch:e})=>By(t,e),Gx=()=>({state:t,dispatch:e})=>Hy(t,e);function J0(t,e,n={}){return So(t,e,{slice:!1,parseOptions:n})}const Jx=(t,e=!1,n={})=>({tr:r,editor:i,dispatch:s})=>{const{doc:o}=r,a=J0(t,i.schema,n);return s&&r.replaceWith(0,o.content.size,a).setMeta("preventUpdate",!e),!0};function xs(t,e){const n=En(e,t.schema),{from:r,to:i,empty:s}=t.selection,o=[];s?(t.storedMarks&&o.push(...t.storedMarks),o.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,i,l=>{o.push(...l.marks)});const a=o.find(l=>l.type.name===n.name);return a?{...a.attrs}:{}}function Yx(t,e){const n=new Vu(t);return e.forEach(r=>{r.steps.forEach(i=>{n.step(i)})}),n}function Xx(t){for(let e=0;e{e(r)&&n.push({node:r,pos:i})}),n}function Qx(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(i,s)=>{n(i)&&r.push({node:i,pos:s})}),r}function Y0(t,e){for(let n=t.depth;n>0;n-=1){const r=t.node(n);if(e(r))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:r}}}function Ea(t){return e=>Y0(e.$from,t)}function sc(t,e){const n=Yt.fromSchema(e).serializeFragment(t),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}function e3(t,e){const n={from:0,to:t.content.size};return ka(t,n,e)}function t3(t,e){const n=Ze(e,t.schema),{from:r,to:i}=t.selection,s=[];t.doc.nodesBetween(r,i,a=>{s.push(a)});const o=s.reverse().find(a=>a.type.name===n.name);return o?{...o.attrs}:{}}function X0(t,e){const n=va(typeof e=="string"?e:e.name,t.schema);return n==="node"?t3(t,e):n==="mark"?xs(t,e):{}}function n3(t,e=JSON.stringify){const n={};return t.filter(r=>{const i=e(r);return Object.prototype.hasOwnProperty.call(n,i)?!1:n[i]=!0})}function r3(t){const e=n3(t);return e.length===1?e:e.filter((n,r)=>!e.filter((s,o)=>o!==r).some(s=>n.oldRange.from>=s.oldRange.from&&n.oldRange.to<=s.oldRange.to&&n.newRange.from>=s.newRange.from&&n.newRange.to<=s.newRange.to))}function i3(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((i,s)=>{const o=[];if(i.ranges.length)i.forEach((a,l)=>{o.push({from:a,to:l})});else{const{from:a,to:l}=n[s];if(a===void 0||l===void 0)return;o.push({from:a,to:l})}o.forEach(({from:a,to:l})=>{const u=e.slice(s).map(a,-1),c=e.slice(s).map(l),d=e.invert().map(u,-1),f=e.invert().map(c);r.push({oldRange:{from:d,to:f},newRange:{from:u,to:c}})})}),r3(r)}function oc(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(i=>{const s=n.resolve(t-1),o=nc(s,i.type);o&&r.push({mark:i,...o})}):n.nodesBetween(t,e,(i,s)=>{!i||(i==null?void 0:i.nodeSize)===void 0||r.push(...i.marks.map(o=>({from:s,to:s+i.nodeSize,mark:o})))}),r}function oo(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const i=t.find(s=>s.type===e&&s.name===r);return i?i.attribute.keepOnSplit:!1}))}function pu(t,e,n={}){const{empty:r,ranges:i}=t.selection,s=e?En(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(d=>s?s.name===d.type.name:!0).find(d=>ii(d.attrs,n,{strict:!1}));let o=0;const a=[];if(i.forEach(({$from:d,$to:f})=>{const h=d.pos,p=f.pos;t.doc.nodesBetween(h,p,(m,g)=>{if(!m.isText&&!m.marks.length)return;const y=Math.max(h,g),x=Math.min(p,g+m.nodeSize),k=x-y;o+=k,a.push(...m.marks.map(b=>({mark:b,from:y,to:x})))})}),o===0)return!1;const l=a.filter(d=>s?s.name===d.mark.type.name:!0).filter(d=>ii(d.mark.attrs,n,{strict:!1})).reduce((d,f)=>d+f.to-f.from,0),u=a.filter(d=>s?d.mark.type!==s&&d.mark.type.excludes(s):!0).reduce((d,f)=>d+f.to-f.from,0);return(l>0?l+u:l)>=o}function s3(t,e,n={}){if(!e)return xr(t,null,n)||pu(t,null,n);const r=va(e,t.schema);return r==="node"?xr(t,e,n):r==="mark"?pu(t,e,n):!1}function tf(t,e){const{nodeExtensions:n}=ya(e),r=n.find(o=>o.name===t);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},s=oe(Z(r,"group",i));return typeof s!="string"?!1:s.split(" ").includes("list")}function o3(t){var e;const n=(e=t.type.createAndFill())===null||e===void 0?void 0:e.toJSON(),r=t.toJSON();return JSON.stringify(n)===JSON.stringify(r)}function Q0(t){return t instanceof ee}function ks(t,e,n){const i=t.state.doc.content.size,s=xn(e,0,i),o=xn(n,0,i),a=t.coordsAtPos(s),l=t.coordsAtPos(o,-1),u=Math.min(a.top,l.top),c=Math.max(a.bottom,l.bottom),d=Math.min(a.left,l.left),f=Math.max(a.right,l.right),h=f-d,p=c-u,y={top:u,bottom:c,left:d,right:f,width:h,height:p,x:d,y:u};return{...y,toJSON:()=>y}}function a3(t,e,n){var r;const{selection:i}=e;let s=null;if(rc(i)&&(s=i.$cursor),s){const a=(r=t.storedMarks)!==null&&r!==void 0?r:s.marks();return!!n.isInSet(a)||!a.some(l=>l.type.excludes(n))}const{ranges:o}=i;return o.some(({$from:a,$to:l})=>{let u=a.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(a.pos,l.pos,(c,d,f)=>{if(u)return!1;if(c.isInline){const h=!f||f.type.allowsMarkType(n),p=!!n.isInSet(c.marks)||!c.marks.some(m=>m.type.excludes(n));u=h&&p}return!u}),u})}const l3=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:s}=n,{empty:o,ranges:a}=s,l=En(t,r.schema);if(i)if(o){const u=xs(r,l);n.addStoredMark(l.create({...u,...e}))}else a.forEach(u=>{const c=u.$from.pos,d=u.$to.pos;r.doc.nodesBetween(c,d,(f,h)=>{const p=Math.max(h,c),m=Math.min(h+f.nodeSize,d);f.marks.find(y=>y.type===l)?f.marks.forEach(y=>{l===y.type&&n.addMark(p,m,l.create({...y.attrs,...e}))}):n.addMark(p,m,l.create(e))})});return a3(r,n,l)},u3=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),c3=(t,e={})=>({state:n,dispatch:r,chain:i})=>{const s=Ze(t,n.schema);return s.isTextblock?i().command(({commands:o})=>Gd(s,e)(n)?!0:o.clearNodes()).command(({state:o})=>Gd(s,e)(o,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},d3=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,i=xn(t,0,r.content.size),s=ee.create(r,i);e.setSelection(s)}return!0},f3=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:i,to:s}=typeof t=="number"?{from:t,to:t}:t,o=X.atStart(r).from,a=X.atEnd(r).to,l=xn(i,o,a),u=xn(s,o,a),c=X.create(r,l,u);e.setSelection(c)}return!0},h3=t=>({state:e,dispatch:n})=>{const r=Ze(t,e.schema);return Zy(r)(e,n)};function nf(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const r=n.filter(i=>e==null?void 0:e.includes(i.type.name));t.tr.ensureMarks(r)}}const p3=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:i})=>{const{selection:s,doc:o}=e,{$from:a,$to:l}=s,u=i.extensionManager.attributes,c=oo(u,a.node().type.name,a.node().attrs);if(s instanceof ee&&s.node.isBlock)return!a.parentOffset||!Jr(o,a.pos)?!1:(r&&(t&&nf(n,i.extensionManager.splittableMarks),e.split(a.pos).scrollIntoView()),!0);if(!a.parent.isBlock)return!1;if(r){const d=l.parentOffset===l.parent.content.size;s instanceof X&&e.deleteSelection();const f=a.depth===0?void 0:Xx(a.node(-1).contentMatchAt(a.indexAfter(-1)));let h=d&&f?[{type:f,attrs:c}]:void 0,p=Jr(e.doc,e.mapping.map(a.pos),1,h);if(!h&&!p&&Jr(e.doc,e.mapping.map(a.pos),1,f?[{type:f}]:void 0)&&(p=!0,h=f?[{type:f,attrs:c}]:void 0),p&&(e.split(e.mapping.map(a.pos),1,h),f&&!d&&!a.parentOffset&&a.parent.type!==f)){const m=e.mapping.map(a.before()),g=e.doc.resolve(m);a.node(-1).canReplaceWith(g.index(),g.index()+1,f)&&e.setNodeMarkup(e.mapping.map(a.before()),f)}t&&nf(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return!0},m3=t=>({tr:e,state:n,dispatch:r,editor:i})=>{var s;const o=Ze(t,n.schema),{$from:a,$to:l}=n.selection,u=n.selection.node;if(u&&u.isBlock||a.depth<2||!a.sameParent(l))return!1;const c=a.node(-1);if(c.type!==o)return!1;const d=i.extensionManager.attributes;if(a.parent.content.size===0&&a.node(-1).childCount===a.indexAfter(-1)){if(a.depth===2||a.node(-3).type!==o||a.index(-2)!==a.node(-2).childCount-1)return!1;if(r){let g=O.empty;const y=a.index(-1)?1:a.index(-2)?2:3;for(let C=a.depth-y;C>=a.depth-3;C-=1)g=O.from(a.node(C).copy(g));const x=a.indexAfter(-1){if(v>-1)return!1;C.isTextblock&&C.content.size===0&&(v=T+1)}),v>-1&&e.setSelection(X.near(e.doc.resolve(v))),e.scrollIntoView()}return!0}const f=l.pos===a.end()?c.contentMatchAt(0).defaultType:null,h=oo(d,c.type.name,c.attrs),p=oo(d,a.node().type.name,a.node().attrs);e.delete(a.pos,l.pos);const m=f?[{type:o,attrs:h},{type:f,attrs:p}]:[{type:o,attrs:h}];if(!Jr(e.doc,a.pos,2))return!1;if(r){const{selection:g,storedMarks:y}=n,{splittableMarks:x}=i.extensionManager,k=y||g.$to.parentOffset&&g.$from.marks();if(e.split(a.pos,2,m).scrollIntoView(),!k||!r)return!0;const b=k.filter(E=>x.includes(E.type.name));e.ensureMarks(b)}return!0},fl=(t,e)=>{const n=Ea(o=>o.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;const i=t.doc.nodeAt(r);return n.node.type===(i==null?void 0:i.type)&&Gn(t.doc,n.pos)&&t.join(n.pos),!0},hl=(t,e)=>{const n=Ea(o=>o.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;const i=t.doc.nodeAt(r);return n.node.type===(i==null?void 0:i.type)&&Gn(t.doc,r)&&t.join(r),!0},g3=(t,e,n,r={})=>({editor:i,tr:s,state:o,dispatch:a,chain:l,commands:u,can:c})=>{const{extensions:d,splittableMarks:f}=i.extensionManager,h=Ze(t,o.schema),p=Ze(e,o.schema),{selection:m,storedMarks:g}=o,{$from:y,$to:x}=m,k=y.blockRange(x),b=g||m.$to.parentOffset&&m.$from.marks();if(!k)return!1;const E=Ea(v=>tf(v.type.name,d))(m);if(k.depth>=1&&E&&k.depth-E.depth<=1){if(E.node.type===h)return u.liftListItem(p);if(tf(E.node.type.name,d)&&h.validContent(E.node.content)&&a)return l().command(()=>(s.setNodeMarkup(E.pos,h),!0)).command(()=>fl(s,h)).command(()=>hl(s,h)).run()}return!n||!b||!a?l().command(()=>c().wrapInList(h,r)?!0:u.clearNodes()).wrapInList(h,r).command(()=>fl(s,h)).command(()=>hl(s,h)).run():l().command(()=>{const v=c().wrapInList(h,r),C=b.filter(T=>f.includes(T.type.name));return s.ensureMarks(C),v?!0:u.clearNodes()}).wrapInList(h,r).command(()=>fl(s,h)).command(()=>hl(s,h)).run()},b3=(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:s=!1}=n,o=En(t,r.schema);return pu(r,o,e)?i.unsetMark(o,{extendEmptyMarkRange:s}):i.setMark(o,e)},y3=(t,e,n={})=>({state:r,commands:i})=>{const s=Ze(t,r.schema),o=Ze(e,r.schema);return xr(r,s,n)?i.setNode(o):i.setNode(s,n)},x3=(t,e={})=>({state:n,commands:r})=>{const i=Ze(t,n.schema);return xr(n,i,e)?r.lift(i):r.wrapIn(i,e)},k3=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r=0;l-=1)o.step(a.steps[l].invert(a.docs[l]));if(s.text){const l=o.doc.resolve(s.from).marks();o.replaceWith(s.from,s.to,t.schema.text(s.text,l))}else o.delete(s.from,s.to)}return!0}}return!1},v3=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:r,ranges:i}=n;return r||e&&i.forEach(s=>{t.removeMark(s.$from.pos,s.$to.pos)}),!0},E3=(t,e={})=>({tr:n,state:r,dispatch:i})=>{var s;const{extendEmptyMarkRange:o=!1}=e,{selection:a}=n,l=En(t,r.schema),{$from:u,empty:c,ranges:d}=a;if(!i)return!0;if(c&&o){let{from:f,to:h}=a;const p=(s=u.marks().find(g=>g.type===l))===null||s===void 0?void 0:s.attrs,m=nc(u,l,p);m&&(f=m.from,h=m.to),n.removeMark(f,h,l)}else d.forEach(f=>{n.removeMark(f.$from.pos,f.$to.pos,l)});return n.removeStoredMark(l),!0},_3=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let s=null,o=null;const a=va(typeof t=="string"?t:t.name,r.schema);return a?(a==="node"&&(s=Ze(t,r.schema)),a==="mark"&&(o=En(t,r.schema)),i&&n.selection.ranges.forEach(l=>{const u=l.$from.pos,c=l.$to.pos;r.doc.nodesBetween(u,c,(d,f)=>{s&&s===d.type&&n.setNodeMarkup(f,void 0,{...d.attrs,...e}),o&&d.marks.length&&d.marks.forEach(h=>{if(o===h.type){const p=Math.max(f,u),m=Math.min(f+d.nodeSize,c);n.addMark(p,m,o.create({...h.attrs,...e}))}})})}),!0):!1},C3=(t,e={})=>({state:n,dispatch:r})=>{const i=Ze(t,n.schema);return Py(i,e)(n,r)},w3=(t,e={})=>({state:n,dispatch:r})=>{const i=Ze(t,n.schema);return $y(i,e)(n,r)};var S3=Object.freeze({__proto__:null,blur:ax,clearContent:lx,clearNodes:ux,command:cx,createParagraphNear:dx,cut:fx,deleteCurrentNode:hx,deleteNode:px,deleteRange:mx,deleteSelection:gx,enter:bx,exitCode:yx,extendMarkRange:kx,first:vx,focus:Ex,forEach:_x,insertContent:Cx,insertContentAt:Ax,joinUp:Mx,joinDown:Tx,joinBackward:Dx,joinForward:Ox,joinItemBackward:Nx,joinItemForward:Lx,joinTextblockBackward:Rx,joinTextblockForward:Ix,keyboardShortcut:Hx,lift:Bx,liftEmptyBlock:Px,liftListItem:$x,newlineInCode:zx,resetAttributes:Vx,scrollIntoView:Ux,selectAll:qx,selectNodeBackward:Zx,selectNodeForward:Kx,selectParentNode:Wx,selectTextblockEnd:jx,selectTextblockStart:Gx,setContent:Jx,setMark:l3,setMeta:u3,setNode:c3,setNodeSelection:d3,setTextSelection:f3,sinkListItem:h3,splitBlock:p3,splitListItem:m3,toggleList:g3,toggleMark:b3,toggleNode:y3,toggleWrap:x3,undoInputRule:k3,unsetAllMarks:v3,unsetMark:E3,updateAttributes:_3,wrapIn:C3,wrapInList:w3});const e1=xe.create({name:"commands",addCommands(){return{...S3}}}),t1=xe.create({name:"editable",addProseMirrorPlugins(){return[new we({key:new Te("editable"),props:{editable:()=>this.editor.options.editable}})]}}),n1=xe.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new we({key:new Te("focusEvents"),props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;const r=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,n)=>{t.isFocused=!1;const r=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),r1=xe.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:a})=>{const{selection:l,doc:u}=a,{empty:c,$anchor:d}=l,{pos:f,parent:h}=d,p=d.parent.isTextblock&&f>0?a.doc.resolve(f-1):d,m=p.parent.type.spec.isolating,g=d.pos-d.parentOffset,y=m&&p.parent.childCount===1?g===d.pos:ne.atStart(u).from===f;return!c||!h.type.isTextblock||h.textContent.length||!y||y&&d.parent.type.name==="paragraph"?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},i={...r},s={...r,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return ic()||G0()?s:i},addProseMirrorPlugins(){return[new we({key:new Te("clearDocument"),appendTransaction:(t,e,n)=>{if(!(t.some(p=>p.docChanged)&&!e.doc.eq(n.doc)))return;const{empty:i,from:s,to:o}=e.selection,a=ne.atStart(e.doc).from,l=ne.atEnd(e.doc).to;if(i||!(s===a&&o===l)||!(n.doc.textBetween(0,n.doc.content.size," "," ").length===0))return;const d=n.tr,f=ga({state:n,transaction:d}),{commands:h}=new ba({editor:this.editor,state:f});if(h.clearNodes(),!!d.steps.length)return d}})]}}),i1=xe.create({name:"tabindex",addProseMirrorPlugins(){return[new we({key:new Te("tabindex"),props:{attributes:this.editor.isEditable?{tabindex:"0"}:{}}})]}});var A3=Object.freeze({__proto__:null,ClipboardTextSerializer:K0,Commands:e1,Editable:t1,FocusEvents:n1,Keymap:r1,Tabindex:i1});class nr{constructor(e,n,r=!1,i=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=n,this.currentNode=i}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!==null&&e!==void 0?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let n=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}n=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:n,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(e);return new nr(n,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new nr(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 nr(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,r)=>{const i=n.isBlock&&!n.isTextblock,s=this.pos+r+1,o=this.resolvedPos.doc.resolve(s);if(!i&&o.depth<=this.depth)return;const a=new nr(o,this.editor,i,i?n:null);i&&(a.actualDepth=this.depth+1),e.push(new nr(o,this.editor,i,i?n:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,n={}){let r=null,i=this.parent;for(;i&&!r;){if(i.node.type.name===e)if(Object.keys(n).length>0){const s=i.node.attrs,o=Object.keys(n);for(let a=0;a{r&&i.length>0||(o.node.type.name===e&&s.every(l=>n[l]===o.node.attrs[l])&&i.push(o),!(r&&i.length>0)&&(i=i.concat(o.querySelectorAll(e,n,r))))}),i}setAttribute(e){const n=this.editor.state.selection;this.editor.chain().setTextSelection(this.from).updateAttributes(this.node.type.name,e).setTextSelection(n.from).run()}}const M3=`.ProseMirror { position: relative; } @@ -83,37 +83,37 @@ img.ProseMirror-separator { .tippy-box[data-animation=fade][data-state=hidden] { opacity: 0 -}`;function D3(t,e,n){const r=document.querySelector(`style[data-tiptap-style${n?`-${n}`:""}]`);if(r!==null)return r;const i=document.createElement("style");return e&&i.setAttribute("nonce",e),i.setAttribute(`data-tiptap-style${n?`-${n}`:""}`,""),i.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(i),i}class O3 extends Wy{constructor(e={}){super(),this.isFocused=!1,this.extensionStorage={},this.options={element:document.createElement("div"),content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.createView(),this.injectCSS(),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),window.setTimeout(()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}))},0)}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&document&&(this.css=D3(T3,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,n=!0){this.setOptions({editable:e}),n&&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,n){const r=q0(n)?n(e,[...this.state.plugins]):[...this.state.plugins,e],i=this.state.reconfigure({plugins:r});this.view.updateState(i)}unregisterPlugin(e){if(this.isDestroyed)return;const n=typeof e=="string"?`${e}$`:e.key,r=this.state.reconfigure({plugins:this.state.plugins.filter(i=>!i.key.startsWith(n))});this.view.updateState(r)}createExtensionManager(){var e,n;const i=[...this.options.enableCoreExtensions?[t1,K0.configure({blockSeparator:(n=(e=this.options.coreExtensionOptions)===null||e===void 0?void 0:e.clipboardTextSerializer)===null||n===void 0?void 0:n.blockSeparator}),e1,n1,r1,i1]:[],...this.options.extensions].filter(s=>["extension","node","mark"].includes(s==null?void 0:s.type));this.extensionManager=new Zr(i,this)}createCommandManager(){this.commandManager=new ba({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){const e=J0(this.options.content,this.schema,this.options.parseOptions),n=W0(e,this.options.autofocus);this.view=new fy(this.options.element,{...this.options.editorProps,dispatchTransaction:this.dispatchTransaction.bind(this),state:qr.create({doc:e,selection:n||void 0})});const r=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(r),this.createNodeViews(),this.prependClass();const i=this.view.dom;i.editor=this}createNodeViews(){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 n=this.capturedTransaction;return this.capturedTransaction=null,n}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=e;return}e.steps.forEach(o=>{var a;return(a=this.capturedTransaction)===null||a===void 0?void 0:a.step(o)});return}const n=this.state.apply(e),r=!this.state.selection.eq(n.selection);this.view.updateState(n),this.emit("transaction",{editor:this,transaction:e}),r&&this.emit("selectionUpdate",{editor:this,transaction:e});const i=e.getMeta("focus"),s=e.getMeta("blur");i&&this.emit("focus",{editor:this,event:i.event,transaction:e}),s&&this.emit("blur",{editor:this,event:s.event,transaction:e}),!(!e.docChanged||e.getMeta("preventUpdate"))&&this.emit("update",{editor:this,transaction:e})}getAttributes(e){return X0(this.state,e)}isActive(e,n){const r=typeof e=="string"?e:null,i=typeof e=="string"?n:e;return o3(this.state,r,i)}getJSON(){return this.state.doc.toJSON()}getHTML(){return sc(this.state.doc.content,this.schema)}getText(e){const{blockSeparator:n=` +}`;function T3(t,e,n){const r=document.querySelector(`style[data-tiptap-style${n?`-${n}`:""}]`);if(r!==null)return r;const i=document.createElement("style");return e&&i.setAttribute("nonce",e),i.setAttribute(`data-tiptap-style${n?`-${n}`:""}`,""),i.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(i),i}class D3 extends Ky{constructor(e={}){super(),this.isFocused=!1,this.extensionStorage={},this.options={element:document.createElement("div"),content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.createView(),this.injectCSS(),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),window.setTimeout(()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}))},0)}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&document&&(this.css=T3(M3,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,n=!0){this.setOptions({editable:e}),n&&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,n){const r=q0(n)?n(e,[...this.state.plugins]):[...this.state.plugins,e],i=this.state.reconfigure({plugins:r});this.view.updateState(i)}unregisterPlugin(e){if(this.isDestroyed)return;const n=typeof e=="string"?`${e}$`:e.key,r=this.state.reconfigure({plugins:this.state.plugins.filter(i=>!i.key.startsWith(n))});this.view.updateState(r)}createExtensionManager(){var e,n;const i=[...this.options.enableCoreExtensions?[t1,K0.configure({blockSeparator:(n=(e=this.options.coreExtensionOptions)===null||e===void 0?void 0:e.clipboardTextSerializer)===null||n===void 0?void 0:n.blockSeparator}),e1,n1,r1,i1]:[],...this.options.extensions].filter(s=>["extension","node","mark"].includes(s==null?void 0:s.type));this.extensionManager=new Zr(i,this)}createCommandManager(){this.commandManager=new ba({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){const e=J0(this.options.content,this.schema,this.options.parseOptions),n=W0(e,this.options.autofocus);this.view=new dy(this.options.element,{...this.options.editorProps,dispatchTransaction:this.dispatchTransaction.bind(this),state:qr.create({doc:e,selection:n||void 0})});const r=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(r),this.createNodeViews(),this.prependClass();const i=this.view.dom;i.editor=this}createNodeViews(){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 n=this.capturedTransaction;return this.capturedTransaction=null,n}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=e;return}e.steps.forEach(o=>{var a;return(a=this.capturedTransaction)===null||a===void 0?void 0:a.step(o)});return}const n=this.state.apply(e),r=!this.state.selection.eq(n.selection);this.view.updateState(n),this.emit("transaction",{editor:this,transaction:e}),r&&this.emit("selectionUpdate",{editor:this,transaction:e});const i=e.getMeta("focus"),s=e.getMeta("blur");i&&this.emit("focus",{editor:this,event:i.event,transaction:e}),s&&this.emit("blur",{editor:this,event:s.event,transaction:e}),!(!e.docChanged||e.getMeta("preventUpdate"))&&this.emit("update",{editor:this,transaction:e})}getAttributes(e){return X0(this.state,e)}isActive(e,n){const r=typeof e=="string"?e:null,i=typeof e=="string"?n:e;return s3(this.state,r,i)}getJSON(){return this.state.doc.toJSON()}getHTML(){return sc(this.state.doc.content,this.schema)}getText(e){const{blockSeparator:n=` -`,textSerializers:r={}}=e||{};return t3(this.state.doc,{blockSeparator:n,textSerializers:{...Z0(this.schema),...r}})}get isEmpty(){return a3(this.state.doc)}getCharacterCount(){return console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.'),this.state.doc.content.size-2}destroy(){this.emit("destroy"),this.view&&this.view.destroy(),this.removeAllListeners()}get isDestroyed(){var e;return!(!((e=this.view)===null||e===void 0)&&e.docView)}$node(e,n){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelector(e,n))||null}$nodes(e,n){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelectorAll(e,n))||null}$pos(e){const n=this.state.doc.resolve(e);return new nr(n,this)}get $doc(){return this.$pos(0)}}function kr(t){return new ys({find:t.find,handler:({state:e,range:n,match:r})=>{const i=oe(t.getAttributes,void 0,r);if(i===!1||i===null)return null;const{tr:s}=e,o=r[r.length-1],a=r[0];if(o){const l=a.search(/\S/),u=n.from+a.indexOf(o),c=u+o.length;if(oc(n.from,n.to,e.doc).filter(h=>h.mark.type.excluded.find(m=>m===t.type&&m!==h.mark.type)).filter(h=>h.to>u).length)return null;cn.from&&s.delete(n.from+l,u);const f=n.from+l+o.length;s.addMark(n.from+l,f,t.type.create(i||{})),s.removeStoredMark(t.type)}}})}function ac(t){return new ys({find:t.find,handler:({state:e,range:n,match:r})=>{const i=oe(t.getAttributes,void 0,r)||{},{tr:s}=e,o=n.from;let a=n.to;const l=t.type.create(i);if(r[1]){const u=r[0].lastIndexOf(r[1]);let c=o+u;c>a?c=a:a=c+r[1].length;const d=r[0][r[0].length-1];s.insertText(d,o+r[0].length-1),s.replaceWith(c,a,l)}else r[0]&&s.insert(o-1,t.type.create(i)).delete(s.mapping.map(o),s.mapping.map(a));s.scrollIntoView()}})}function mu(t){return new ys({find:t.find,handler:({state:e,range:n,match:r})=>{const i=e.doc.resolve(n.from),s=oe(t.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,s)}})}function vr(t){return new ys({find:t.find,handler:({state:e,range:n,match:r,chain:i})=>{const s=oe(t.getAttributes,void 0,r)||{},o=e.tr.delete(n.from,n.to),l=o.doc.resolve(n.from).blockRange(),u=l&&zu(l,t.type,s);if(!u)return null;if(o.wrap(l,u),t.keepMarks&&t.editor){const{selection:d,storedMarks:f}=e,{splittableMarks:h}=t.editor.extensionManager,p=f||d.$to.parentOffset&&d.$from.marks();if(p){const m=p.filter(g=>h.includes(g.type.name));o.ensureMarks(m)}}if(t.keepAttributes){const d=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(d,s).run()}const c=o.doc.resolve(n.from-1).nodeBefore;c&&c.type===t.type&&Gn(o.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,c))&&o.join(n.from-1)}})}class Ie{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=oe(Z(this,"addOptions",{name:this.name}))),this.storage=oe(Z(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new Ie(e)}configure(e={}){const n=this.extend();return n.options=xa(this.options,e),n.storage=oe(Z(n,"addStorage",{name:n.name,options:n.options})),n}extend(e={}){const n=new Ie({...this.config,...e});return n.parent=this,this.child=n,n.name=e.name?e.name:n.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=oe(Z(n,"addOptions",{name:n.name})),n.storage=oe(Z(n,"addStorage",{name:n.name,options:n.options})),n}static handleExit({editor:e,mark:n}){const{tr:r}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){const o=i.marks();if(!!!o.find(u=>(u==null?void 0:u.type.name)===n.name))return!1;const l=o.find(u=>(u==null?void 0:u.type.name)===n.name);return l&&r.removeStoredMark(l),r.insertText(" ",i.pos),e.view.dispatch(r),!0}return!1}}let ue=class gu{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=oe(Z(this,"addOptions",{name:this.name}))),this.storage=oe(Z(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new gu(e)}configure(e={}){const n=this.extend();return n.options=xa(this.options,e),n.storage=oe(Z(n,"addStorage",{name:n.name,options:n.options})),n}extend(e={}){const n=new gu({...this.config,...e});return n.parent=this,this.child=n,n.name=e.name?e.name:n.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=oe(Z(n,"addOptions",{name:n.name})),n.storage=oe(Z(n,"addStorage",{name:n.name,options:n.options})),n}};function Zn(t){return new tx({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:i})=>{const s=oe(t.getAttributes,void 0,r,i);if(s===!1||s===null)return null;const{tr:o}=e,a=r[r.length-1],l=r[0];let u=n.to;if(a){const c=l.search(/\S/),d=n.from+l.indexOf(a),f=d+a.length;if(oc(n.from,n.to,e.doc).filter(p=>p.mark.type.excluded.find(g=>g===t.type&&g!==p.mark.type)).filter(p=>p.to>d).length)return null;fn.from&&o.delete(n.from+c,d),u=n.from+c+a.length,o.addMark(n.from+c,u,t.type.create(s||{})),o.removeStoredMark(t.type)}}})}function N3(t){return t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}class ge extends HTMLElement{constructor(){super();B(this,"template","");B(this,"editor");B(this,"options")}registerClickListener(){this.addEventListener("click",()=>{var r;const n=(r=this.editor)==null?void 0:r.chain();this.onClick(n),n==null||n.run()})}connectedCallback(){this.innerHTML=this.template}onClick(n){}onCreate(n,r){this.editor=n.editor,this.options=r}onTransaction(n){const r=this.querySelector("div");r&&(this.onActive(n.editor)?r.classList.add("active"):r.classList.remove("active"))}onActive(n){return!1}}class s1 extends ge{constructor(){super();const e=` +`,textSerializers:r={}}=e||{};return e3(this.state.doc,{blockSeparator:n,textSerializers:{...Z0(this.schema),...r}})}get isEmpty(){return o3(this.state.doc)}getCharacterCount(){return console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.'),this.state.doc.content.size-2}destroy(){this.emit("destroy"),this.view&&this.view.destroy(),this.removeAllListeners()}get isDestroyed(){var e;return!(!((e=this.view)===null||e===void 0)&&e.docView)}$node(e,n){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelector(e,n))||null}$nodes(e,n){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelectorAll(e,n))||null}$pos(e){const n=this.state.doc.resolve(e);return new nr(n,this)}get $doc(){return this.$pos(0)}}function kr(t){return new ys({find:t.find,handler:({state:e,range:n,match:r})=>{const i=oe(t.getAttributes,void 0,r);if(i===!1||i===null)return null;const{tr:s}=e,o=r[r.length-1],a=r[0];if(o){const l=a.search(/\S/),u=n.from+a.indexOf(o),c=u+o.length;if(oc(n.from,n.to,e.doc).filter(h=>h.mark.type.excluded.find(m=>m===t.type&&m!==h.mark.type)).filter(h=>h.to>u).length)return null;cn.from&&s.delete(n.from+l,u);const f=n.from+l+o.length;s.addMark(n.from+l,f,t.type.create(i||{})),s.removeStoredMark(t.type)}}})}function ac(t){return new ys({find:t.find,handler:({state:e,range:n,match:r})=>{const i=oe(t.getAttributes,void 0,r)||{},{tr:s}=e,o=n.from;let a=n.to;const l=t.type.create(i);if(r[1]){const u=r[0].lastIndexOf(r[1]);let c=o+u;c>a?c=a:a=c+r[1].length;const d=r[0][r[0].length-1];s.insertText(d,o+r[0].length-1),s.replaceWith(c,a,l)}else r[0]&&s.insert(o-1,t.type.create(i)).delete(s.mapping.map(o),s.mapping.map(a));s.scrollIntoView()}})}function mu(t){return new ys({find:t.find,handler:({state:e,range:n,match:r})=>{const i=e.doc.resolve(n.from),s=oe(t.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,s)}})}function vr(t){return new ys({find:t.find,handler:({state:e,range:n,match:r,chain:i})=>{const s=oe(t.getAttributes,void 0,r)||{},o=e.tr.delete(n.from,n.to),l=o.doc.resolve(n.from).blockRange(),u=l&&zu(l,t.type,s);if(!u)return null;if(o.wrap(l,u),t.keepMarks&&t.editor){const{selection:d,storedMarks:f}=e,{splittableMarks:h}=t.editor.extensionManager,p=f||d.$to.parentOffset&&d.$from.marks();if(p){const m=p.filter(g=>h.includes(g.type.name));o.ensureMarks(m)}}if(t.keepAttributes){const d=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(d,s).run()}const c=o.doc.resolve(n.from-1).nodeBefore;c&&c.type===t.type&&Gn(o.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,c))&&o.join(n.from-1)}})}class Ie{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=oe(Z(this,"addOptions",{name:this.name}))),this.storage=oe(Z(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new Ie(e)}configure(e={}){const n=this.extend();return n.options=xa(this.options,e),n.storage=oe(Z(n,"addStorage",{name:n.name,options:n.options})),n}extend(e={}){const n=new Ie({...this.config,...e});return n.parent=this,this.child=n,n.name=e.name?e.name:n.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=oe(Z(n,"addOptions",{name:n.name})),n.storage=oe(Z(n,"addStorage",{name:n.name,options:n.options})),n}static handleExit({editor:e,mark:n}){const{tr:r}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){const o=i.marks();if(!!!o.find(u=>(u==null?void 0:u.type.name)===n.name))return!1;const l=o.find(u=>(u==null?void 0:u.type.name)===n.name);return l&&r.removeStoredMark(l),r.insertText(" ",i.pos),e.view.dispatch(r),!0}return!1}}let ue=class gu{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=oe(Z(this,"addOptions",{name:this.name}))),this.storage=oe(Z(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new gu(e)}configure(e={}){const n=this.extend();return n.options=xa(this.options,e),n.storage=oe(Z(n,"addStorage",{name:n.name,options:n.options})),n}extend(e={}){const n=new gu({...this.config,...e});return n.parent=this,this.child=n,n.name=e.name?e.name:n.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=oe(Z(n,"addOptions",{name:n.name})),n.storage=oe(Z(n,"addStorage",{name:n.name,options:n.options})),n}};function Zn(t){return new ex({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:i})=>{const s=oe(t.getAttributes,void 0,r,i);if(s===!1||s===null)return null;const{tr:o}=e,a=r[r.length-1],l=r[0];let u=n.to;if(a){const c=l.search(/\S/),d=n.from+l.indexOf(a),f=d+a.length;if(oc(n.from,n.to,e.doc).filter(p=>p.mark.type.excluded.find(g=>g===t.type&&g!==p.mark.type)).filter(p=>p.to>d).length)return null;fn.from&&o.delete(n.from+c,d),u=n.from+c+a.length,o.addMark(n.from+c,u,t.type.create(s||{})),o.removeStoredMark(t.type)}}})}function O3(t){return t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}class me extends HTMLElement{constructor(){super();H(this,"template","");H(this,"editor");H(this,"options")}registerClickListener(){this.addEventListener("click",()=>{var r;const n=(r=this.editor)==null?void 0:r.chain();this.onClick(n),n==null||n.run()})}connectedCallback(){this.innerHTML=this.template}onClick(n){}onCreate(n,r){this.editor=n.editor,this.options=r}onTransaction(n){const r=this.querySelector("div");r&&(this.onActive(n.editor)?r.classList.add("active"):r.classList.remove("active"))}onActive(n){return!1}}class s1 extends me{constructor(){super(),this.template=`
- `;this.template=e,this.registerClickListener()}onClick(e){e.undo()}}class L3 extends ge{constructor(){super();const e=` + `,this.registerClickListener()}onClick(e){e.undo()}}class N3 extends me{constructor(){super(),this.template=`
- `;this.template=e,this.registerClickListener()}onClick(e){e.redo()}}var pt="top",It="bottom",Ft="right",mt="left",lc="auto",vs=[pt,It,Ft,mt],si="start",Wi="end",R3="clippingParents",o1="viewport",vi="popper",I3="reference",nf=vs.reduce(function(t,e){return t.concat([e+"-"+si,e+"-"+Wi])},[]),a1=[].concat(vs,[lc]).reduce(function(t,e){return t.concat([e,e+"-"+si,e+"-"+Wi])},[]),F3="beforeRead",H3="read",B3="afterRead",P3="beforeMain",$3="main",z3="afterMain",V3="beforeWrite",U3="write",q3="afterWrite",Z3=[F3,H3,B3,P3,$3,z3,V3,U3,q3];function on(t){return t?(t.nodeName||"").toLowerCase():null}function _t(t){if(t==null)return window;if(t.toString()!=="[object Window]"){var e=t.ownerDocument;return e&&e.defaultView||window}return t}function Er(t){var e=_t(t).Element;return t instanceof e||t instanceof Element}function Rt(t){var e=_t(t).HTMLElement;return t instanceof e||t instanceof HTMLElement}function uc(t){if(typeof ShadowRoot>"u")return!1;var e=_t(t).ShadowRoot;return t instanceof e||t instanceof ShadowRoot}function K3(t){var e=t.state;Object.keys(e.elements).forEach(function(n){var r=e.styles[n]||{},i=e.attributes[n]||{},s=e.elements[n];!Rt(s)||!on(s)||(Object.assign(s.style,r),Object.keys(i).forEach(function(o){var a=i[o];a===!1?s.removeAttribute(o):s.setAttribute(o,a===!0?"":a)}))})}function W3(t){var e=t.state,n={popper:{position:e.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(e.elements.popper.style,n.popper),e.styles=n,e.elements.arrow&&Object.assign(e.elements.arrow.style,n.arrow),function(){Object.keys(e.elements).forEach(function(r){var i=e.elements[r],s=e.attributes[r]||{},o=Object.keys(e.styles.hasOwnProperty(r)?e.styles[r]:n[r]),a=o.reduce(function(l,u){return l[u]="",l},{});!Rt(i)||!on(i)||(Object.assign(i.style,a),Object.keys(s).forEach(function(l){i.removeAttribute(l)}))})}}const l1={name:"applyStyles",enabled:!0,phase:"write",fn:K3,effect:W3,requires:["computeStyles"]};function nn(t){return t.split("-")[0]}var hr=Math.max,Ao=Math.min,oi=Math.round;function bu(){var t=navigator.userAgentData;return t!=null&&t.brands&&Array.isArray(t.brands)?t.brands.map(function(e){return e.brand+"/"+e.version}).join(" "):navigator.userAgent}function u1(){return!/^((?!chrome|android).)*safari/i.test(bu())}function ai(t,e,n){e===void 0&&(e=!1),n===void 0&&(n=!1);var r=t.getBoundingClientRect(),i=1,s=1;e&&Rt(t)&&(i=t.offsetWidth>0&&oi(r.width)/t.offsetWidth||1,s=t.offsetHeight>0&&oi(r.height)/t.offsetHeight||1);var o=Er(t)?_t(t):window,a=o.visualViewport,l=!u1()&&n,u=(r.left+(l&&a?a.offsetLeft:0))/i,c=(r.top+(l&&a?a.offsetTop:0))/s,d=r.width/i,f=r.height/s;return{width:d,height:f,top:c,right:u+d,bottom:c+f,left:u,x:u,y:c}}function cc(t){var e=ai(t),n=t.offsetWidth,r=t.offsetHeight;return Math.abs(e.width-n)<=1&&(n=e.width),Math.abs(e.height-r)<=1&&(r=e.height),{x:t.offsetLeft,y:t.offsetTop,width:n,height:r}}function c1(t,e){var n=e.getRootNode&&e.getRootNode();if(t.contains(e))return!0;if(n&&uc(n)){var r=e;do{if(r&&t.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}function vn(t){return _t(t).getComputedStyle(t)}function j3(t){return["table","td","th"].indexOf(on(t))>=0}function Yn(t){return((Er(t)?t.ownerDocument:t.document)||window.document).documentElement}function _a(t){return on(t)==="html"?t:t.assignedSlot||t.parentNode||(uc(t)?t.host:null)||Yn(t)}function rf(t){return!Rt(t)||vn(t).position==="fixed"?null:t.offsetParent}function G3(t){var e=/firefox/i.test(bu()),n=/Trident/i.test(bu());if(n&&Rt(t)){var r=vn(t);if(r.position==="fixed")return null}var i=_a(t);for(uc(i)&&(i=i.host);Rt(i)&&["html","body"].indexOf(on(i))<0;){var s=vn(i);if(s.transform!=="none"||s.perspective!=="none"||s.contain==="paint"||["transform","perspective"].indexOf(s.willChange)!==-1||e&&s.willChange==="filter"||e&&s.filter&&s.filter!=="none")return i;i=i.parentNode}return null}function Es(t){for(var e=_t(t),n=rf(t);n&&j3(n)&&vn(n).position==="static";)n=rf(n);return n&&(on(n)==="html"||on(n)==="body"&&vn(n).position==="static")?e:n||G3(t)||e}function dc(t){return["top","bottom"].indexOf(t)>=0?"x":"y"}function Ri(t,e,n){return hr(t,Ao(e,n))}function J3(t,e,n){var r=Ri(t,e,n);return r>n?n:r}function d1(){return{top:0,right:0,bottom:0,left:0}}function f1(t){return Object.assign({},d1(),t)}function h1(t,e){return e.reduce(function(n,r){return n[r]=t,n},{})}var Y3=function(e,n){return e=typeof e=="function"?e(Object.assign({},n.rects,{placement:n.placement})):e,f1(typeof e!="number"?e:h1(e,vs))};function X3(t){var e,n=t.state,r=t.name,i=t.options,s=n.elements.arrow,o=n.modifiersData.popperOffsets,a=nn(n.placement),l=dc(a),u=[mt,Ft].indexOf(a)>=0,c=u?"height":"width";if(!(!s||!o)){var d=Y3(i.padding,n),f=cc(s),h=l==="y"?pt:mt,p=l==="y"?It:Ft,m=n.rects.reference[c]+n.rects.reference[l]-o[l]-n.rects.popper[c],g=o[l]-n.rects.reference[l],y=Es(s),x=y?l==="y"?y.clientHeight||0:y.clientWidth||0:0,k=m/2-g/2,b=d[h],E=x-f[c]-d[p],v=x/2-f[c]/2+k,C=Ri(b,v,E),T=l;n.modifiersData[r]=(e={},e[T]=C,e.centerOffset=C-v,e)}}function Q3(t){var e=t.state,n=t.options,r=n.element,i=r===void 0?"[data-popper-arrow]":r;i!=null&&(typeof i=="string"&&(i=e.elements.popper.querySelector(i),!i)||c1(e.elements.popper,i)&&(e.elements.arrow=i))}const ek={name:"arrow",enabled:!0,phase:"main",fn:X3,effect:Q3,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function li(t){return t.split("-")[1]}var tk={top:"auto",right:"auto",bottom:"auto",left:"auto"};function nk(t,e){var n=t.x,r=t.y,i=e.devicePixelRatio||1;return{x:oi(n*i)/i||0,y:oi(r*i)/i||0}}function sf(t){var e,n=t.popper,r=t.popperRect,i=t.placement,s=t.variation,o=t.offsets,a=t.position,l=t.gpuAcceleration,u=t.adaptive,c=t.roundOffsets,d=t.isFixed,f=o.x,h=f===void 0?0:f,p=o.y,m=p===void 0?0:p,g=typeof c=="function"?c({x:h,y:m}):{x:h,y:m};h=g.x,m=g.y;var y=o.hasOwnProperty("x"),x=o.hasOwnProperty("y"),k=mt,b=pt,E=window;if(u){var v=Es(n),C="clientHeight",T="clientWidth";if(v===_t(n)&&(v=Yn(n),vn(v).position!=="static"&&a==="absolute"&&(C="scrollHeight",T="scrollWidth")),v=v,i===pt||(i===mt||i===Ft)&&s===Wi){b=It;var w=d&&v===E&&E.visualViewport?E.visualViewport.height:v[C];m-=w-r.height,m*=l?1:-1}if(i===mt||(i===pt||i===It)&&s===Wi){k=Ft;var N=d&&v===E&&E.visualViewport?E.visualViewport.width:v[T];h-=N-r.width,h*=l?1:-1}}var $=Object.assign({position:a},u&&tk),K=c===!0?nk({x:h,y:m},_t(n)):{x:h,y:m};if(h=K.x,m=K.y,l){var U;return Object.assign({},$,(U={},U[b]=x?"0":"",U[k]=y?"0":"",U.transform=(E.devicePixelRatio||1)<=1?"translate("+h+"px, "+m+"px)":"translate3d("+h+"px, "+m+"px, 0)",U))}return Object.assign({},$,(e={},e[b]=x?m+"px":"",e[k]=y?h+"px":"",e.transform="",e))}function rk(t){var e=t.state,n=t.options,r=n.gpuAcceleration,i=r===void 0?!0:r,s=n.adaptive,o=s===void 0?!0:s,a=n.roundOffsets,l=a===void 0?!0:a,u={placement:nn(e.placement),variation:li(e.placement),popper:e.elements.popper,popperRect:e.rects.popper,gpuAcceleration:i,isFixed:e.options.strategy==="fixed"};e.modifiersData.popperOffsets!=null&&(e.styles.popper=Object.assign({},e.styles.popper,sf(Object.assign({},u,{offsets:e.modifiersData.popperOffsets,position:e.options.strategy,adaptive:o,roundOffsets:l})))),e.modifiersData.arrow!=null&&(e.styles.arrow=Object.assign({},e.styles.arrow,sf(Object.assign({},u,{offsets:e.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:l})))),e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-placement":e.placement})}const ik={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:rk,data:{}};var Fs={passive:!0};function sk(t){var e=t.state,n=t.instance,r=t.options,i=r.scroll,s=i===void 0?!0:i,o=r.resize,a=o===void 0?!0:o,l=_t(e.elements.popper),u=[].concat(e.scrollParents.reference,e.scrollParents.popper);return s&&u.forEach(function(c){c.addEventListener("scroll",n.update,Fs)}),a&&l.addEventListener("resize",n.update,Fs),function(){s&&u.forEach(function(c){c.removeEventListener("scroll",n.update,Fs)}),a&&l.removeEventListener("resize",n.update,Fs)}}const ok={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:sk,data:{}};var ak={left:"right",right:"left",bottom:"top",top:"bottom"};function ao(t){return t.replace(/left|right|bottom|top/g,function(e){return ak[e]})}var lk={start:"end",end:"start"};function of(t){return t.replace(/start|end/g,function(e){return lk[e]})}function fc(t){var e=_t(t),n=e.pageXOffset,r=e.pageYOffset;return{scrollLeft:n,scrollTop:r}}function hc(t){return ai(Yn(t)).left+fc(t).scrollLeft}function uk(t,e){var n=_t(t),r=Yn(t),i=n.visualViewport,s=r.clientWidth,o=r.clientHeight,a=0,l=0;if(i){s=i.width,o=i.height;var u=u1();(u||!u&&e==="fixed")&&(a=i.offsetLeft,l=i.offsetTop)}return{width:s,height:o,x:a+hc(t),y:l}}function ck(t){var e,n=Yn(t),r=fc(t),i=(e=t.ownerDocument)==null?void 0:e.body,s=hr(n.scrollWidth,n.clientWidth,i?i.scrollWidth:0,i?i.clientWidth:0),o=hr(n.scrollHeight,n.clientHeight,i?i.scrollHeight:0,i?i.clientHeight:0),a=-r.scrollLeft+hc(t),l=-r.scrollTop;return vn(i||n).direction==="rtl"&&(a+=hr(n.clientWidth,i?i.clientWidth:0)-s),{width:s,height:o,x:a,y:l}}function pc(t){var e=vn(t),n=e.overflow,r=e.overflowX,i=e.overflowY;return/auto|scroll|overlay|hidden/.test(n+i+r)}function p1(t){return["html","body","#document"].indexOf(on(t))>=0?t.ownerDocument.body:Rt(t)&&pc(t)?t:p1(_a(t))}function Ii(t,e){var n;e===void 0&&(e=[]);var r=p1(t),i=r===((n=t.ownerDocument)==null?void 0:n.body),s=_t(r),o=i?[s].concat(s.visualViewport||[],pc(r)?r:[]):r,a=e.concat(o);return i?a:a.concat(Ii(_a(o)))}function yu(t){return Object.assign({},t,{left:t.x,top:t.y,right:t.x+t.width,bottom:t.y+t.height})}function dk(t,e){var n=ai(t,!1,e==="fixed");return n.top=n.top+t.clientTop,n.left=n.left+t.clientLeft,n.bottom=n.top+t.clientHeight,n.right=n.left+t.clientWidth,n.width=t.clientWidth,n.height=t.clientHeight,n.x=n.left,n.y=n.top,n}function af(t,e,n){return e===o1?yu(uk(t,n)):Er(e)?dk(e,n):yu(ck(Yn(t)))}function fk(t){var e=Ii(_a(t)),n=["absolute","fixed"].indexOf(vn(t).position)>=0,r=n&&Rt(t)?Es(t):t;return Er(r)?e.filter(function(i){return Er(i)&&c1(i,r)&&on(i)!=="body"}):[]}function hk(t,e,n,r){var i=e==="clippingParents"?fk(t):[].concat(e),s=[].concat(i,[n]),o=s[0],a=s.reduce(function(l,u){var c=af(t,u,r);return l.top=hr(c.top,l.top),l.right=Ao(c.right,l.right),l.bottom=Ao(c.bottom,l.bottom),l.left=hr(c.left,l.left),l},af(t,o,r));return a.width=a.right-a.left,a.height=a.bottom-a.top,a.x=a.left,a.y=a.top,a}function m1(t){var e=t.reference,n=t.element,r=t.placement,i=r?nn(r):null,s=r?li(r):null,o=e.x+e.width/2-n.width/2,a=e.y+e.height/2-n.height/2,l;switch(i){case pt:l={x:o,y:e.y-n.height};break;case It:l={x:o,y:e.y+e.height};break;case Ft:l={x:e.x+e.width,y:a};break;case mt:l={x:e.x-n.width,y:a};break;default:l={x:e.x,y:e.y}}var u=i?dc(i):null;if(u!=null){var c=u==="y"?"height":"width";switch(s){case si:l[u]=l[u]-(e[c]/2-n[c]/2);break;case Wi:l[u]=l[u]+(e[c]/2-n[c]/2);break}}return l}function ji(t,e){e===void 0&&(e={});var n=e,r=n.placement,i=r===void 0?t.placement:r,s=n.strategy,o=s===void 0?t.strategy:s,a=n.boundary,l=a===void 0?R3:a,u=n.rootBoundary,c=u===void 0?o1:u,d=n.elementContext,f=d===void 0?vi:d,h=n.altBoundary,p=h===void 0?!1:h,m=n.padding,g=m===void 0?0:m,y=f1(typeof g!="number"?g:h1(g,vs)),x=f===vi?I3:vi,k=t.rects.popper,b=t.elements[p?x:f],E=hk(Er(b)?b:b.contextElement||Yn(t.elements.popper),l,c,o),v=ai(t.elements.reference),C=m1({reference:v,element:k,strategy:"absolute",placement:i}),T=yu(Object.assign({},k,C)),w=f===vi?T:v,N={top:E.top-w.top+y.top,bottom:w.bottom-E.bottom+y.bottom,left:E.left-w.left+y.left,right:w.right-E.right+y.right},$=t.modifiersData.offset;if(f===vi&&$){var K=$[i];Object.keys(N).forEach(function(U){var W=[Ft,It].indexOf(U)>=0?1:-1,z=[pt,It].indexOf(U)>=0?"y":"x";N[U]+=K[z]*W})}return N}function pk(t,e){e===void 0&&(e={});var n=e,r=n.placement,i=n.boundary,s=n.rootBoundary,o=n.padding,a=n.flipVariations,l=n.allowedAutoPlacements,u=l===void 0?a1:l,c=li(r),d=c?a?nf:nf.filter(function(p){return li(p)===c}):vs,f=d.filter(function(p){return u.indexOf(p)>=0});f.length===0&&(f=d);var h=f.reduce(function(p,m){return p[m]=ji(t,{placement:m,boundary:i,rootBoundary:s,padding:o})[nn(m)],p},{});return Object.keys(h).sort(function(p,m){return h[p]-h[m]})}function mk(t){if(nn(t)===lc)return[];var e=ao(t);return[of(t),e,of(e)]}function gk(t){var e=t.state,n=t.options,r=t.name;if(!e.modifiersData[r]._skip){for(var i=n.mainAxis,s=i===void 0?!0:i,o=n.altAxis,a=o===void 0?!0:o,l=n.fallbackPlacements,u=n.padding,c=n.boundary,d=n.rootBoundary,f=n.altBoundary,h=n.flipVariations,p=h===void 0?!0:h,m=n.allowedAutoPlacements,g=e.options.placement,y=nn(g),x=y===g,k=l||(x||!p?[ao(g)]:mk(g)),b=[g].concat(k).reduce(function(ke,fe){return ke.concat(nn(fe)===lc?pk(e,{placement:fe,boundary:c,rootBoundary:d,padding:u,flipVariations:p,allowedAutoPlacements:m}):fe)},[]),E=e.rects.reference,v=e.rects.popper,C=new Map,T=!0,w=b[0],N=0;N=0,z=W?"width":"height",A=ji(e,{placement:$,boundary:c,rootBoundary:d,altBoundary:f,padding:u}),_=W?U?Ft:mt:U?It:pt;E[z]>v[z]&&(_=ao(_));var S=ao(_),L=[];if(s&&L.push(A[K]<=0),a&&L.push(A[_]<=0,A[S]<=0),L.every(function(ke){return ke})){w=$,T=!1;break}C.set($,L)}if(T)for(var F=p?3:1,j=function(fe){var Se=b.find(function(ut){var We=C.get(ut);if(We)return We.slice(0,fe).every(function(yt){return yt})});if(Se)return w=Se,"break"},Q=F;Q>0;Q--){var pe=j(Q);if(pe==="break")break}e.placement!==w&&(e.modifiersData[r]._skip=!0,e.placement=w,e.reset=!0)}}const bk={name:"flip",enabled:!0,phase:"main",fn:gk,requiresIfExists:["offset"],data:{_skip:!1}};function lf(t,e,n){return n===void 0&&(n={x:0,y:0}),{top:t.top-e.height-n.y,right:t.right-e.width+n.x,bottom:t.bottom-e.height+n.y,left:t.left-e.width-n.x}}function uf(t){return[pt,Ft,It,mt].some(function(e){return t[e]>=0})}function yk(t){var e=t.state,n=t.name,r=e.rects.reference,i=e.rects.popper,s=e.modifiersData.preventOverflow,o=ji(e,{elementContext:"reference"}),a=ji(e,{altBoundary:!0}),l=lf(o,r),u=lf(a,i,s),c=uf(l),d=uf(u);e.modifiersData[n]={referenceClippingOffsets:l,popperEscapeOffsets:u,isReferenceHidden:c,hasPopperEscaped:d},e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-reference-hidden":c,"data-popper-escaped":d})}const xk={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:yk};function kk(t,e,n){var r=nn(t),i=[mt,pt].indexOf(r)>=0?-1:1,s=typeof n=="function"?n(Object.assign({},e,{placement:t})):n,o=s[0],a=s[1];return o=o||0,a=(a||0)*i,[mt,Ft].indexOf(r)>=0?{x:a,y:o}:{x:o,y:a}}function vk(t){var e=t.state,n=t.options,r=t.name,i=n.offset,s=i===void 0?[0,0]:i,o=a1.reduce(function(c,d){return c[d]=kk(d,e.rects,s),c},{}),a=o[e.placement],l=a.x,u=a.y;e.modifiersData.popperOffsets!=null&&(e.modifiersData.popperOffsets.x+=l,e.modifiersData.popperOffsets.y+=u),e.modifiersData[r]=o}const Ek={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:vk};function _k(t){var e=t.state,n=t.name;e.modifiersData[n]=m1({reference:e.rects.reference,element:e.rects.popper,strategy:"absolute",placement:e.placement})}const Ck={name:"popperOffsets",enabled:!0,phase:"read",fn:_k,data:{}};function wk(t){return t==="x"?"y":"x"}function Sk(t){var e=t.state,n=t.options,r=t.name,i=n.mainAxis,s=i===void 0?!0:i,o=n.altAxis,a=o===void 0?!1:o,l=n.boundary,u=n.rootBoundary,c=n.altBoundary,d=n.padding,f=n.tether,h=f===void 0?!0:f,p=n.tetherOffset,m=p===void 0?0:p,g=ji(e,{boundary:l,rootBoundary:u,padding:d,altBoundary:c}),y=nn(e.placement),x=li(e.placement),k=!x,b=dc(y),E=wk(b),v=e.modifiersData.popperOffsets,C=e.rects.reference,T=e.rects.popper,w=typeof m=="function"?m(Object.assign({},e.rects,{placement:e.placement})):m,N=typeof w=="number"?{mainAxis:w,altAxis:w}:Object.assign({mainAxis:0,altAxis:0},w),$=e.modifiersData.offset?e.modifiersData.offset[e.placement]:null,K={x:0,y:0};if(v){if(s){var U,W=b==="y"?pt:mt,z=b==="y"?It:Ft,A=b==="y"?"height":"width",_=v[b],S=_+g[W],L=_-g[z],F=h?-T[A]/2:0,j=x===si?C[A]:T[A],Q=x===si?-T[A]:-C[A],pe=e.elements.arrow,ke=h&&pe?cc(pe):{width:0,height:0},fe=e.modifiersData["arrow#persistent"]?e.modifiersData["arrow#persistent"].padding:d1(),Se=fe[W],ut=fe[z],We=Ri(0,C[A],ke[A]),yt=k?C[A]/2-F-We-Se-N.mainAxis:j-We-Se-N.mainAxis,ct=k?-C[A]/2+F+We+ut+N.mainAxis:Q+We+ut+N.mainAxis,At=e.elements.arrow&&Es(e.elements.arrow),xt=At?b==="y"?At.clientTop||0:At.clientLeft||0:0,he=(U=$==null?void 0:$[b])!=null?U:0,De=_+yt-he-xt,rt=_+ct-he,Le=Ri(h?Ao(S,De):S,_,h?hr(L,rt):L);v[b]=Le,K[b]=Le-_}if(a){var te,Bt=b==="x"?pt:mt,V=b==="x"?It:Ft,de=v[E],be=E==="y"?"height":"width",ce=de+g[Bt],Qe=de-g[V],je=[pt,mt].indexOf(y)!==-1,H=(te=$==null?void 0:$[E])!=null?te:0,q=je?ce:de-C[be]-T[be]-H+N.altAxis,D=je?de+C[be]+T[be]-H-N.altAxis:Qe,R=h&&je?J3(q,de,D):Ri(h?q:ce,de,h?D:Qe);v[E]=R,K[E]=R-de}e.modifiersData[r]=K}}const Ak={name:"preventOverflow",enabled:!0,phase:"main",fn:Sk,requiresIfExists:["offset"]};function Mk(t){return{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}}function Tk(t){return t===_t(t)||!Rt(t)?fc(t):Mk(t)}function Dk(t){var e=t.getBoundingClientRect(),n=oi(e.width)/t.offsetWidth||1,r=oi(e.height)/t.offsetHeight||1;return n!==1||r!==1}function Ok(t,e,n){n===void 0&&(n=!1);var r=Rt(e),i=Rt(e)&&Dk(e),s=Yn(e),o=ai(t,i,n),a={scrollLeft:0,scrollTop:0},l={x:0,y:0};return(r||!r&&!n)&&((on(e)!=="body"||pc(s))&&(a=Tk(e)),Rt(e)?(l=ai(e,!0),l.x+=e.clientLeft,l.y+=e.clientTop):s&&(l.x=hc(s))),{x:o.left+a.scrollLeft-l.x,y:o.top+a.scrollTop-l.y,width:o.width,height:o.height}}function Nk(t){var e=new Map,n=new Set,r=[];t.forEach(function(s){e.set(s.name,s)});function i(s){n.add(s.name);var o=[].concat(s.requires||[],s.requiresIfExists||[]);o.forEach(function(a){if(!n.has(a)){var l=e.get(a);l&&i(l)}}),r.push(s)}return t.forEach(function(s){n.has(s.name)||i(s)}),r}function Lk(t){var e=Nk(t);return Z3.reduce(function(n,r){return n.concat(e.filter(function(i){return i.phase===r}))},[])}function Rk(t){var e;return function(){return e||(e=new Promise(function(n){Promise.resolve().then(function(){e=void 0,n(t())})})),e}}function Ik(t){var e=t.reduce(function(n,r){var i=n[r.name];return n[r.name]=i?Object.assign({},i,r,{options:Object.assign({},i.options,r.options),data:Object.assign({},i.data,r.data)}):r,n},{});return Object.keys(e).map(function(n){return e[n]})}var cf={placement:"bottom",modifiers:[],strategy:"absolute"};function df(){for(var t=arguments.length,e=new Array(t),n=0;n-1}function k1(t,e){return typeof t=="function"?t.apply(void 0,e):t}function ff(t,e){if(e===0)return t;var n;return function(r){clearTimeout(n),n=setTimeout(function(){t(r)},e)}}function Vk(t,e){var n=Object.assign({},t);return e.forEach(function(r){delete n[r]}),n}function Uk(t){return t.split(/\s+/).filter(Boolean)}function $r(t){return[].concat(t)}function hf(t,e){t.indexOf(e)===-1&&t.push(e)}function qk(t){return t.filter(function(e,n){return t.indexOf(e)===n})}function Zk(t){return t.split("-")[0]}function Mo(t){return[].slice.call(t)}function pf(t){return Object.keys(t).reduce(function(e,n){return t[n]!==void 0&&(e[n]=t[n]),e},{})}function Fi(){return document.createElement("div")}function Gi(t){return["Element","Fragment"].some(function(e){return mc(t,e)})}function Kk(t){return mc(t,"NodeList")}function Wk(t){return mc(t,"MouseEvent")}function jk(t){return!!(t&&t._tippy&&t._tippy.reference===t)}function Gk(t){return Gi(t)?[t]:Kk(t)?Mo(t):Array.isArray(t)?t:Mo(document.querySelectorAll(t))}function ml(t,e){t.forEach(function(n){n&&(n.style.transitionDuration=e+"ms")})}function mf(t,e){t.forEach(function(n){n&&n.setAttribute("data-state",e)})}function Jk(t){var e,n=$r(t),r=n[0];return r!=null&&(e=r.ownerDocument)!=null&&e.body?r.ownerDocument:document}function Yk(t,e){var n=e.clientX,r=e.clientY;return t.every(function(i){var s=i.popperRect,o=i.popperState,a=i.props,l=a.interactiveBorder,u=Zk(o.placement),c=o.modifiersData.offset;if(!c)return!0;var d=u==="bottom"?c.top.y:0,f=u==="top"?c.bottom.y:0,h=u==="right"?c.left.x:0,p=u==="left"?c.right.x:0,m=s.top-r+d>l,g=r-s.bottom-f>l,y=s.left-n+h>l,x=n-s.right-p>l;return m||g||y||x})}function gl(t,e,n){var r=e+"EventListener";["transitionend","webkitTransitionEnd"].forEach(function(i){t[r](i,n)})}function gf(t,e){for(var n=e;n;){var r;if(t.contains(n))return!0;n=n.getRootNode==null||(r=n.getRootNode())==null?void 0:r.host}return!1}var Gt={isTouch:!1},bf=0;function Xk(){Gt.isTouch||(Gt.isTouch=!0,window.performance&&document.addEventListener("mousemove",v1))}function v1(){var t=performance.now();t-bf<20&&(Gt.isTouch=!1,document.removeEventListener("mousemove",v1)),bf=t}function Qk(){var t=document.activeElement;if(jk(t)){var e=t._tippy;t.blur&&!e.state.isVisible&&t.blur()}}function ev(){document.addEventListener("touchstart",Xk,er),window.addEventListener("blur",Qk)}var tv=typeof window<"u"&&typeof document<"u",nv=tv?!!window.msCrypto:!1;function Dr(t){var e=t==="destroy"?"n already-":" ";return[t+"() was called on a"+e+"destroyed instance. This is a no-op but","indicates a potential memory leak."].join(" ")}function yf(t){var e=/[ \t]{2,}/g,n=/^[ \t]*/gm;return t.replace(e," ").replace(n,"").trim()}function rv(t){return yf(` + `,this.registerClickListener()}onClick(e){e.redo()}}var pt="top",It="bottom",Ft="right",mt="left",lc="auto",vs=[pt,It,Ft,mt],si="start",Wi="end",L3="clippingParents",o1="viewport",vi="popper",R3="reference",rf=vs.reduce(function(t,e){return t.concat([e+"-"+si,e+"-"+Wi])},[]),a1=[].concat(vs,[lc]).reduce(function(t,e){return t.concat([e,e+"-"+si,e+"-"+Wi])},[]),I3="beforeRead",F3="read",H3="afterRead",B3="beforeMain",P3="main",$3="afterMain",z3="beforeWrite",V3="write",U3="afterWrite",q3=[I3,F3,H3,B3,P3,$3,z3,V3,U3];function on(t){return t?(t.nodeName||"").toLowerCase():null}function _t(t){if(t==null)return window;if(t.toString()!=="[object Window]"){var e=t.ownerDocument;return e&&e.defaultView||window}return t}function Er(t){var e=_t(t).Element;return t instanceof e||t instanceof Element}function Rt(t){var e=_t(t).HTMLElement;return t instanceof e||t instanceof HTMLElement}function uc(t){if(typeof ShadowRoot>"u")return!1;var e=_t(t).ShadowRoot;return t instanceof e||t instanceof ShadowRoot}function Z3(t){var e=t.state;Object.keys(e.elements).forEach(function(n){var r=e.styles[n]||{},i=e.attributes[n]||{},s=e.elements[n];!Rt(s)||!on(s)||(Object.assign(s.style,r),Object.keys(i).forEach(function(o){var a=i[o];a===!1?s.removeAttribute(o):s.setAttribute(o,a===!0?"":a)}))})}function K3(t){var e=t.state,n={popper:{position:e.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(e.elements.popper.style,n.popper),e.styles=n,e.elements.arrow&&Object.assign(e.elements.arrow.style,n.arrow),function(){Object.keys(e.elements).forEach(function(r){var i=e.elements[r],s=e.attributes[r]||{},o=Object.keys(e.styles.hasOwnProperty(r)?e.styles[r]:n[r]),a=o.reduce(function(l,u){return l[u]="",l},{});!Rt(i)||!on(i)||(Object.assign(i.style,a),Object.keys(s).forEach(function(l){i.removeAttribute(l)}))})}}const l1={name:"applyStyles",enabled:!0,phase:"write",fn:Z3,effect:K3,requires:["computeStyles"]};function nn(t){return t.split("-")[0]}var hr=Math.max,Ao=Math.min,oi=Math.round;function bu(){var t=navigator.userAgentData;return t!=null&&t.brands&&Array.isArray(t.brands)?t.brands.map(function(e){return e.brand+"/"+e.version}).join(" "):navigator.userAgent}function u1(){return!/^((?!chrome|android).)*safari/i.test(bu())}function ai(t,e,n){e===void 0&&(e=!1),n===void 0&&(n=!1);var r=t.getBoundingClientRect(),i=1,s=1;e&&Rt(t)&&(i=t.offsetWidth>0&&oi(r.width)/t.offsetWidth||1,s=t.offsetHeight>0&&oi(r.height)/t.offsetHeight||1);var o=Er(t)?_t(t):window,a=o.visualViewport,l=!u1()&&n,u=(r.left+(l&&a?a.offsetLeft:0))/i,c=(r.top+(l&&a?a.offsetTop:0))/s,d=r.width/i,f=r.height/s;return{width:d,height:f,top:c,right:u+d,bottom:c+f,left:u,x:u,y:c}}function cc(t){var e=ai(t),n=t.offsetWidth,r=t.offsetHeight;return Math.abs(e.width-n)<=1&&(n=e.width),Math.abs(e.height-r)<=1&&(r=e.height),{x:t.offsetLeft,y:t.offsetTop,width:n,height:r}}function c1(t,e){var n=e.getRootNode&&e.getRootNode();if(t.contains(e))return!0;if(n&&uc(n)){var r=e;do{if(r&&t.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}function vn(t){return _t(t).getComputedStyle(t)}function W3(t){return["table","td","th"].indexOf(on(t))>=0}function Yn(t){return((Er(t)?t.ownerDocument:t.document)||window.document).documentElement}function _a(t){return on(t)==="html"?t:t.assignedSlot||t.parentNode||(uc(t)?t.host:null)||Yn(t)}function sf(t){return!Rt(t)||vn(t).position==="fixed"?null:t.offsetParent}function j3(t){var e=/firefox/i.test(bu()),n=/Trident/i.test(bu());if(n&&Rt(t)){var r=vn(t);if(r.position==="fixed")return null}var i=_a(t);for(uc(i)&&(i=i.host);Rt(i)&&["html","body"].indexOf(on(i))<0;){var s=vn(i);if(s.transform!=="none"||s.perspective!=="none"||s.contain==="paint"||["transform","perspective"].indexOf(s.willChange)!==-1||e&&s.willChange==="filter"||e&&s.filter&&s.filter!=="none")return i;i=i.parentNode}return null}function Es(t){for(var e=_t(t),n=sf(t);n&&W3(n)&&vn(n).position==="static";)n=sf(n);return n&&(on(n)==="html"||on(n)==="body"&&vn(n).position==="static")?e:n||j3(t)||e}function dc(t){return["top","bottom"].indexOf(t)>=0?"x":"y"}function Ri(t,e,n){return hr(t,Ao(e,n))}function G3(t,e,n){var r=Ri(t,e,n);return r>n?n:r}function d1(){return{top:0,right:0,bottom:0,left:0}}function f1(t){return Object.assign({},d1(),t)}function h1(t,e){return e.reduce(function(n,r){return n[r]=t,n},{})}var J3=function(e,n){return e=typeof e=="function"?e(Object.assign({},n.rects,{placement:n.placement})):e,f1(typeof e!="number"?e:h1(e,vs))};function Y3(t){var e,n=t.state,r=t.name,i=t.options,s=n.elements.arrow,o=n.modifiersData.popperOffsets,a=nn(n.placement),l=dc(a),u=[mt,Ft].indexOf(a)>=0,c=u?"height":"width";if(!(!s||!o)){var d=J3(i.padding,n),f=cc(s),h=l==="y"?pt:mt,p=l==="y"?It:Ft,m=n.rects.reference[c]+n.rects.reference[l]-o[l]-n.rects.popper[c],g=o[l]-n.rects.reference[l],y=Es(s),x=y?l==="y"?y.clientHeight||0:y.clientWidth||0:0,k=m/2-g/2,b=d[h],E=x-f[c]-d[p],v=x/2-f[c]/2+k,C=Ri(b,v,E),T=l;n.modifiersData[r]=(e={},e[T]=C,e.centerOffset=C-v,e)}}function X3(t){var e=t.state,n=t.options,r=n.element,i=r===void 0?"[data-popper-arrow]":r;i!=null&&(typeof i=="string"&&(i=e.elements.popper.querySelector(i),!i)||c1(e.elements.popper,i)&&(e.elements.arrow=i))}const Q3={name:"arrow",enabled:!0,phase:"main",fn:Y3,effect:X3,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function li(t){return t.split("-")[1]}var ek={top:"auto",right:"auto",bottom:"auto",left:"auto"};function tk(t,e){var n=t.x,r=t.y,i=e.devicePixelRatio||1;return{x:oi(n*i)/i||0,y:oi(r*i)/i||0}}function of(t){var e,n=t.popper,r=t.popperRect,i=t.placement,s=t.variation,o=t.offsets,a=t.position,l=t.gpuAcceleration,u=t.adaptive,c=t.roundOffsets,d=t.isFixed,f=o.x,h=f===void 0?0:f,p=o.y,m=p===void 0?0:p,g=typeof c=="function"?c({x:h,y:m}):{x:h,y:m};h=g.x,m=g.y;var y=o.hasOwnProperty("x"),x=o.hasOwnProperty("y"),k=mt,b=pt,E=window;if(u){var v=Es(n),C="clientHeight",T="clientWidth";if(v===_t(n)&&(v=Yn(n),vn(v).position!=="static"&&a==="absolute"&&(C="scrollHeight",T="scrollWidth")),v=v,i===pt||(i===mt||i===Ft)&&s===Wi){b=It;var w=d&&v===E&&E.visualViewport?E.visualViewport.height:v[C];m-=w-r.height,m*=l?1:-1}if(i===mt||(i===pt||i===It)&&s===Wi){k=Ft;var N=d&&v===E&&E.visualViewport?E.visualViewport.width:v[T];h-=N-r.width,h*=l?1:-1}}var $=Object.assign({position:a},u&&ek),K=c===!0?tk({x:h,y:m},_t(n)):{x:h,y:m};if(h=K.x,m=K.y,l){var U;return Object.assign({},$,(U={},U[b]=x?"0":"",U[k]=y?"0":"",U.transform=(E.devicePixelRatio||1)<=1?"translate("+h+"px, "+m+"px)":"translate3d("+h+"px, "+m+"px, 0)",U))}return Object.assign({},$,(e={},e[b]=x?m+"px":"",e[k]=y?h+"px":"",e.transform="",e))}function nk(t){var e=t.state,n=t.options,r=n.gpuAcceleration,i=r===void 0?!0:r,s=n.adaptive,o=s===void 0?!0:s,a=n.roundOffsets,l=a===void 0?!0:a,u={placement:nn(e.placement),variation:li(e.placement),popper:e.elements.popper,popperRect:e.rects.popper,gpuAcceleration:i,isFixed:e.options.strategy==="fixed"};e.modifiersData.popperOffsets!=null&&(e.styles.popper=Object.assign({},e.styles.popper,of(Object.assign({},u,{offsets:e.modifiersData.popperOffsets,position:e.options.strategy,adaptive:o,roundOffsets:l})))),e.modifiersData.arrow!=null&&(e.styles.arrow=Object.assign({},e.styles.arrow,of(Object.assign({},u,{offsets:e.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:l})))),e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-placement":e.placement})}const rk={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:nk,data:{}};var Fs={passive:!0};function ik(t){var e=t.state,n=t.instance,r=t.options,i=r.scroll,s=i===void 0?!0:i,o=r.resize,a=o===void 0?!0:o,l=_t(e.elements.popper),u=[].concat(e.scrollParents.reference,e.scrollParents.popper);return s&&u.forEach(function(c){c.addEventListener("scroll",n.update,Fs)}),a&&l.addEventListener("resize",n.update,Fs),function(){s&&u.forEach(function(c){c.removeEventListener("scroll",n.update,Fs)}),a&&l.removeEventListener("resize",n.update,Fs)}}const sk={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:ik,data:{}};var ok={left:"right",right:"left",bottom:"top",top:"bottom"};function ao(t){return t.replace(/left|right|bottom|top/g,function(e){return ok[e]})}var ak={start:"end",end:"start"};function af(t){return t.replace(/start|end/g,function(e){return ak[e]})}function fc(t){var e=_t(t),n=e.pageXOffset,r=e.pageYOffset;return{scrollLeft:n,scrollTop:r}}function hc(t){return ai(Yn(t)).left+fc(t).scrollLeft}function lk(t,e){var n=_t(t),r=Yn(t),i=n.visualViewport,s=r.clientWidth,o=r.clientHeight,a=0,l=0;if(i){s=i.width,o=i.height;var u=u1();(u||!u&&e==="fixed")&&(a=i.offsetLeft,l=i.offsetTop)}return{width:s,height:o,x:a+hc(t),y:l}}function uk(t){var e,n=Yn(t),r=fc(t),i=(e=t.ownerDocument)==null?void 0:e.body,s=hr(n.scrollWidth,n.clientWidth,i?i.scrollWidth:0,i?i.clientWidth:0),o=hr(n.scrollHeight,n.clientHeight,i?i.scrollHeight:0,i?i.clientHeight:0),a=-r.scrollLeft+hc(t),l=-r.scrollTop;return vn(i||n).direction==="rtl"&&(a+=hr(n.clientWidth,i?i.clientWidth:0)-s),{width:s,height:o,x:a,y:l}}function pc(t){var e=vn(t),n=e.overflow,r=e.overflowX,i=e.overflowY;return/auto|scroll|overlay|hidden/.test(n+i+r)}function p1(t){return["html","body","#document"].indexOf(on(t))>=0?t.ownerDocument.body:Rt(t)&&pc(t)?t:p1(_a(t))}function Ii(t,e){var n;e===void 0&&(e=[]);var r=p1(t),i=r===((n=t.ownerDocument)==null?void 0:n.body),s=_t(r),o=i?[s].concat(s.visualViewport||[],pc(r)?r:[]):r,a=e.concat(o);return i?a:a.concat(Ii(_a(o)))}function yu(t){return Object.assign({},t,{left:t.x,top:t.y,right:t.x+t.width,bottom:t.y+t.height})}function ck(t,e){var n=ai(t,!1,e==="fixed");return n.top=n.top+t.clientTop,n.left=n.left+t.clientLeft,n.bottom=n.top+t.clientHeight,n.right=n.left+t.clientWidth,n.width=t.clientWidth,n.height=t.clientHeight,n.x=n.left,n.y=n.top,n}function lf(t,e,n){return e===o1?yu(lk(t,n)):Er(e)?ck(e,n):yu(uk(Yn(t)))}function dk(t){var e=Ii(_a(t)),n=["absolute","fixed"].indexOf(vn(t).position)>=0,r=n&&Rt(t)?Es(t):t;return Er(r)?e.filter(function(i){return Er(i)&&c1(i,r)&&on(i)!=="body"}):[]}function fk(t,e,n,r){var i=e==="clippingParents"?dk(t):[].concat(e),s=[].concat(i,[n]),o=s[0],a=s.reduce(function(l,u){var c=lf(t,u,r);return l.top=hr(c.top,l.top),l.right=Ao(c.right,l.right),l.bottom=Ao(c.bottom,l.bottom),l.left=hr(c.left,l.left),l},lf(t,o,r));return a.width=a.right-a.left,a.height=a.bottom-a.top,a.x=a.left,a.y=a.top,a}function m1(t){var e=t.reference,n=t.element,r=t.placement,i=r?nn(r):null,s=r?li(r):null,o=e.x+e.width/2-n.width/2,a=e.y+e.height/2-n.height/2,l;switch(i){case pt:l={x:o,y:e.y-n.height};break;case It:l={x:o,y:e.y+e.height};break;case Ft:l={x:e.x+e.width,y:a};break;case mt:l={x:e.x-n.width,y:a};break;default:l={x:e.x,y:e.y}}var u=i?dc(i):null;if(u!=null){var c=u==="y"?"height":"width";switch(s){case si:l[u]=l[u]-(e[c]/2-n[c]/2);break;case Wi:l[u]=l[u]+(e[c]/2-n[c]/2);break}}return l}function ji(t,e){e===void 0&&(e={});var n=e,r=n.placement,i=r===void 0?t.placement:r,s=n.strategy,o=s===void 0?t.strategy:s,a=n.boundary,l=a===void 0?L3:a,u=n.rootBoundary,c=u===void 0?o1:u,d=n.elementContext,f=d===void 0?vi:d,h=n.altBoundary,p=h===void 0?!1:h,m=n.padding,g=m===void 0?0:m,y=f1(typeof g!="number"?g:h1(g,vs)),x=f===vi?R3:vi,k=t.rects.popper,b=t.elements[p?x:f],E=fk(Er(b)?b:b.contextElement||Yn(t.elements.popper),l,c,o),v=ai(t.elements.reference),C=m1({reference:v,element:k,strategy:"absolute",placement:i}),T=yu(Object.assign({},k,C)),w=f===vi?T:v,N={top:E.top-w.top+y.top,bottom:w.bottom-E.bottom+y.bottom,left:E.left-w.left+y.left,right:w.right-E.right+y.right},$=t.modifiersData.offset;if(f===vi&&$){var K=$[i];Object.keys(N).forEach(function(U){var W=[Ft,It].indexOf(U)>=0?1:-1,z=[pt,It].indexOf(U)>=0?"y":"x";N[U]+=K[z]*W})}return N}function hk(t,e){e===void 0&&(e={});var n=e,r=n.placement,i=n.boundary,s=n.rootBoundary,o=n.padding,a=n.flipVariations,l=n.allowedAutoPlacements,u=l===void 0?a1:l,c=li(r),d=c?a?rf:rf.filter(function(p){return li(p)===c}):vs,f=d.filter(function(p){return u.indexOf(p)>=0});f.length===0&&(f=d);var h=f.reduce(function(p,m){return p[m]=ji(t,{placement:m,boundary:i,rootBoundary:s,padding:o})[nn(m)],p},{});return Object.keys(h).sort(function(p,m){return h[p]-h[m]})}function pk(t){if(nn(t)===lc)return[];var e=ao(t);return[af(t),e,af(e)]}function mk(t){var e=t.state,n=t.options,r=t.name;if(!e.modifiersData[r]._skip){for(var i=n.mainAxis,s=i===void 0?!0:i,o=n.altAxis,a=o===void 0?!0:o,l=n.fallbackPlacements,u=n.padding,c=n.boundary,d=n.rootBoundary,f=n.altBoundary,h=n.flipVariations,p=h===void 0?!0:h,m=n.allowedAutoPlacements,g=e.options.placement,y=nn(g),x=y===g,k=l||(x||!p?[ao(g)]:pk(g)),b=[g].concat(k).reduce(function(ke,fe){return ke.concat(nn(fe)===lc?hk(e,{placement:fe,boundary:c,rootBoundary:d,padding:u,flipVariations:p,allowedAutoPlacements:m}):fe)},[]),E=e.rects.reference,v=e.rects.popper,C=new Map,T=!0,w=b[0],N=0;N=0,z=W?"width":"height",A=ji(e,{placement:$,boundary:c,rootBoundary:d,altBoundary:f,padding:u}),_=W?U?Ft:mt:U?It:pt;E[z]>v[z]&&(_=ao(_));var S=ao(_),L=[];if(s&&L.push(A[K]<=0),a&&L.push(A[_]<=0,A[S]<=0),L.every(function(ke){return ke})){w=$,T=!1;break}C.set($,L)}if(T)for(var F=p?3:1,j=function(fe){var Se=b.find(function(ut){var We=C.get(ut);if(We)return We.slice(0,fe).every(function(yt){return yt})});if(Se)return w=Se,"break"},Q=F;Q>0;Q--){var pe=j(Q);if(pe==="break")break}e.placement!==w&&(e.modifiersData[r]._skip=!0,e.placement=w,e.reset=!0)}}const gk={name:"flip",enabled:!0,phase:"main",fn:mk,requiresIfExists:["offset"],data:{_skip:!1}};function uf(t,e,n){return n===void 0&&(n={x:0,y:0}),{top:t.top-e.height-n.y,right:t.right-e.width+n.x,bottom:t.bottom-e.height+n.y,left:t.left-e.width-n.x}}function cf(t){return[pt,Ft,It,mt].some(function(e){return t[e]>=0})}function bk(t){var e=t.state,n=t.name,r=e.rects.reference,i=e.rects.popper,s=e.modifiersData.preventOverflow,o=ji(e,{elementContext:"reference"}),a=ji(e,{altBoundary:!0}),l=uf(o,r),u=uf(a,i,s),c=cf(l),d=cf(u);e.modifiersData[n]={referenceClippingOffsets:l,popperEscapeOffsets:u,isReferenceHidden:c,hasPopperEscaped:d},e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-reference-hidden":c,"data-popper-escaped":d})}const yk={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:bk};function xk(t,e,n){var r=nn(t),i=[mt,pt].indexOf(r)>=0?-1:1,s=typeof n=="function"?n(Object.assign({},e,{placement:t})):n,o=s[0],a=s[1];return o=o||0,a=(a||0)*i,[mt,Ft].indexOf(r)>=0?{x:a,y:o}:{x:o,y:a}}function kk(t){var e=t.state,n=t.options,r=t.name,i=n.offset,s=i===void 0?[0,0]:i,o=a1.reduce(function(c,d){return c[d]=xk(d,e.rects,s),c},{}),a=o[e.placement],l=a.x,u=a.y;e.modifiersData.popperOffsets!=null&&(e.modifiersData.popperOffsets.x+=l,e.modifiersData.popperOffsets.y+=u),e.modifiersData[r]=o}const vk={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:kk};function Ek(t){var e=t.state,n=t.name;e.modifiersData[n]=m1({reference:e.rects.reference,element:e.rects.popper,strategy:"absolute",placement:e.placement})}const _k={name:"popperOffsets",enabled:!0,phase:"read",fn:Ek,data:{}};function Ck(t){return t==="x"?"y":"x"}function wk(t){var e=t.state,n=t.options,r=t.name,i=n.mainAxis,s=i===void 0?!0:i,o=n.altAxis,a=o===void 0?!1:o,l=n.boundary,u=n.rootBoundary,c=n.altBoundary,d=n.padding,f=n.tether,h=f===void 0?!0:f,p=n.tetherOffset,m=p===void 0?0:p,g=ji(e,{boundary:l,rootBoundary:u,padding:d,altBoundary:c}),y=nn(e.placement),x=li(e.placement),k=!x,b=dc(y),E=Ck(b),v=e.modifiersData.popperOffsets,C=e.rects.reference,T=e.rects.popper,w=typeof m=="function"?m(Object.assign({},e.rects,{placement:e.placement})):m,N=typeof w=="number"?{mainAxis:w,altAxis:w}:Object.assign({mainAxis:0,altAxis:0},w),$=e.modifiersData.offset?e.modifiersData.offset[e.placement]:null,K={x:0,y:0};if(v){if(s){var U,W=b==="y"?pt:mt,z=b==="y"?It:Ft,A=b==="y"?"height":"width",_=v[b],S=_+g[W],L=_-g[z],F=h?-T[A]/2:0,j=x===si?C[A]:T[A],Q=x===si?-T[A]:-C[A],pe=e.elements.arrow,ke=h&&pe?cc(pe):{width:0,height:0},fe=e.modifiersData["arrow#persistent"]?e.modifiersData["arrow#persistent"].padding:d1(),Se=fe[W],ut=fe[z],We=Ri(0,C[A],ke[A]),yt=k?C[A]/2-F-We-Se-N.mainAxis:j-We-Se-N.mainAxis,ct=k?-C[A]/2+F+We+ut+N.mainAxis:Q+We+ut+N.mainAxis,At=e.elements.arrow&&Es(e.elements.arrow),xt=At?b==="y"?At.clientTop||0:At.clientLeft||0:0,he=(U=$==null?void 0:$[b])!=null?U:0,De=_+yt-he-xt,rt=_+ct-he,Le=Ri(h?Ao(S,De):S,_,h?hr(L,rt):L);v[b]=Le,K[b]=Le-_}if(a){var te,Bt=b==="x"?pt:mt,V=b==="x"?It:Ft,de=v[E],be=E==="y"?"height":"width",ce=de+g[Bt],Qe=de-g[V],je=[pt,mt].indexOf(y)!==-1,B=(te=$==null?void 0:$[E])!=null?te:0,q=je?ce:de-C[be]-T[be]-B+N.altAxis,D=je?de+C[be]+T[be]-B-N.altAxis:Qe,R=h&&je?G3(q,de,D):Ri(h?q:ce,de,h?D:Qe);v[E]=R,K[E]=R-de}e.modifiersData[r]=K}}const Sk={name:"preventOverflow",enabled:!0,phase:"main",fn:wk,requiresIfExists:["offset"]};function Ak(t){return{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}}function Mk(t){return t===_t(t)||!Rt(t)?fc(t):Ak(t)}function Tk(t){var e=t.getBoundingClientRect(),n=oi(e.width)/t.offsetWidth||1,r=oi(e.height)/t.offsetHeight||1;return n!==1||r!==1}function Dk(t,e,n){n===void 0&&(n=!1);var r=Rt(e),i=Rt(e)&&Tk(e),s=Yn(e),o=ai(t,i,n),a={scrollLeft:0,scrollTop:0},l={x:0,y:0};return(r||!r&&!n)&&((on(e)!=="body"||pc(s))&&(a=Mk(e)),Rt(e)?(l=ai(e,!0),l.x+=e.clientLeft,l.y+=e.clientTop):s&&(l.x=hc(s))),{x:o.left+a.scrollLeft-l.x,y:o.top+a.scrollTop-l.y,width:o.width,height:o.height}}function Ok(t){var e=new Map,n=new Set,r=[];t.forEach(function(s){e.set(s.name,s)});function i(s){n.add(s.name);var o=[].concat(s.requires||[],s.requiresIfExists||[]);o.forEach(function(a){if(!n.has(a)){var l=e.get(a);l&&i(l)}}),r.push(s)}return t.forEach(function(s){n.has(s.name)||i(s)}),r}function Nk(t){var e=Ok(t);return q3.reduce(function(n,r){return n.concat(e.filter(function(i){return i.phase===r}))},[])}function Lk(t){var e;return function(){return e||(e=new Promise(function(n){Promise.resolve().then(function(){e=void 0,n(t())})})),e}}function Rk(t){var e=t.reduce(function(n,r){var i=n[r.name];return n[r.name]=i?Object.assign({},i,r,{options:Object.assign({},i.options,r.options),data:Object.assign({},i.data,r.data)}):r,n},{});return Object.keys(e).map(function(n){return e[n]})}var df={placement:"bottom",modifiers:[],strategy:"absolute"};function ff(){for(var t=arguments.length,e=new Array(t),n=0;n-1}function k1(t,e){return typeof t=="function"?t.apply(void 0,e):t}function hf(t,e){if(e===0)return t;var n;return function(r){clearTimeout(n),n=setTimeout(function(){t(r)},e)}}function zk(t,e){var n=Object.assign({},t);return e.forEach(function(r){delete n[r]}),n}function Vk(t){return t.split(/\s+/).filter(Boolean)}function $r(t){return[].concat(t)}function pf(t,e){t.indexOf(e)===-1&&t.push(e)}function Uk(t){return t.filter(function(e,n){return t.indexOf(e)===n})}function qk(t){return t.split("-")[0]}function Mo(t){return[].slice.call(t)}function mf(t){return Object.keys(t).reduce(function(e,n){return t[n]!==void 0&&(e[n]=t[n]),e},{})}function Fi(){return document.createElement("div")}function Gi(t){return["Element","Fragment"].some(function(e){return mc(t,e)})}function Zk(t){return mc(t,"NodeList")}function Kk(t){return mc(t,"MouseEvent")}function Wk(t){return!!(t&&t._tippy&&t._tippy.reference===t)}function jk(t){return Gi(t)?[t]:Zk(t)?Mo(t):Array.isArray(t)?t:Mo(document.querySelectorAll(t))}function ml(t,e){t.forEach(function(n){n&&(n.style.transitionDuration=e+"ms")})}function gf(t,e){t.forEach(function(n){n&&n.setAttribute("data-state",e)})}function Gk(t){var e,n=$r(t),r=n[0];return r!=null&&(e=r.ownerDocument)!=null&&e.body?r.ownerDocument:document}function Jk(t,e){var n=e.clientX,r=e.clientY;return t.every(function(i){var s=i.popperRect,o=i.popperState,a=i.props,l=a.interactiveBorder,u=qk(o.placement),c=o.modifiersData.offset;if(!c)return!0;var d=u==="bottom"?c.top.y:0,f=u==="top"?c.bottom.y:0,h=u==="right"?c.left.x:0,p=u==="left"?c.right.x:0,m=s.top-r+d>l,g=r-s.bottom-f>l,y=s.left-n+h>l,x=n-s.right-p>l;return m||g||y||x})}function gl(t,e,n){var r=e+"EventListener";["transitionend","webkitTransitionEnd"].forEach(function(i){t[r](i,n)})}function bf(t,e){for(var n=e;n;){var r;if(t.contains(n))return!0;n=n.getRootNode==null||(r=n.getRootNode())==null?void 0:r.host}return!1}var Gt={isTouch:!1},yf=0;function Yk(){Gt.isTouch||(Gt.isTouch=!0,window.performance&&document.addEventListener("mousemove",v1))}function v1(){var t=performance.now();t-yf<20&&(Gt.isTouch=!1,document.removeEventListener("mousemove",v1)),yf=t}function Xk(){var t=document.activeElement;if(Wk(t)){var e=t._tippy;t.blur&&!e.state.isVisible&&t.blur()}}function Qk(){document.addEventListener("touchstart",Yk,er),window.addEventListener("blur",Xk)}var ev=typeof window<"u"&&typeof document<"u",tv=ev?!!window.msCrypto:!1;function Dr(t){var e=t==="destroy"?"n already-":" ";return[t+"() was called on a"+e+"destroyed instance. This is a no-op but","indicates a potential memory leak."].join(" ")}function xf(t){var e=/[ \t]{2,}/g,n=/^[ \t]*/gm;return t.replace(e," ").replace(n,"").trim()}function nv(t){return xf(` %ctippy.js - %c`+yf(t)+` + %c`+xf(t)+` %c👷‍ This is a development-only message. It will be removed in production. - `)}function E1(t){return[rv(t),"color: #00C584; font-size: 1.3em; font-weight: bold;","line-height: 1.5","color: #a6a095;"]}var Ji;({}).NODE_ENV!=="production"&&iv();function iv(){Ji=new Set}function yn(t,e){if(t&&!Ji.has(e)){var n;Ji.add(e),(n=console).warn.apply(n,E1(e))}}function xu(t,e){if(t&&!Ji.has(e)){var n;Ji.add(e),(n=console).error.apply(n,E1(e))}}function sv(t){var e=!t,n=Object.prototype.toString.call(t)==="[object Object]"&&!t.addEventListener;xu(e,["tippy() was passed","`"+String(t)+"`","as its targets (first) argument. Valid types are: String, Element,","Element[], or NodeList."].join(" ")),xu(n,["tippy() was passed a plain object which is not supported as an argument","for virtual positioning. Use props.getReferenceClientRect instead."].join(" "))}var _1={animateFill:!1,followCursor:!1,inlinePositioning:!1,sticky:!1},ov={allowHTML:!1,animation:"fade",arrow:!0,content:"",inertia:!1,maxWidth:350,role:"tooltip",theme:"",zIndex:9999},Et=Object.assign({appendTo:x1,aria:{content:"auto",expanded:"auto"},delay:0,duration:[300,250],getReferenceClientRect:null,hideOnClick:!0,ignoreAttributes:!1,interactive:!1,interactiveBorder:2,interactiveDebounce:0,moveTransition:"",offset:[0,10],onAfterUpdate:function(){},onBeforeUpdate:function(){},onCreate:function(){},onDestroy:function(){},onHidden:function(){},onHide:function(){},onMount:function(){},onShow:function(){},onShown:function(){},onTrigger:function(){},onUntrigger:function(){},onClickOutside:function(){},placement:"top",plugins:[],popperOptions:{},render:null,showOnCreate:!1,touch:!0,trigger:"mouseenter focus",triggerTarget:null},_1,ov),av=Object.keys(Et),lv=function(e){({}).NODE_ENV!=="production"&&w1(e,[]);var n=Object.keys(e);n.forEach(function(r){Et[r]=e[r]})};function C1(t){var e=t.plugins||[],n=e.reduce(function(r,i){var s=i.name,o=i.defaultValue;if(s){var a;r[s]=t[s]!==void 0?t[s]:(a=Et[s])!=null?a:o}return r},{});return Object.assign({},t,n)}function uv(t,e){var n=e?Object.keys(C1(Object.assign({},Et,{plugins:e}))):av,r=n.reduce(function(i,s){var o=(t.getAttribute("data-tippy-"+s)||"").trim();if(!o)return i;if(s==="content")i[s]=o;else try{i[s]=JSON.parse(o)}catch{i[s]=o}return i},{});return r}function xf(t,e){var n=Object.assign({},e,{content:k1(e.content,[t])},e.ignoreAttributes?{}:uv(t,e.plugins));return n.aria=Object.assign({},Et.aria,n.aria),n.aria={expanded:n.aria.expanded==="auto"?e.interactive:n.aria.expanded,content:n.aria.content==="auto"?e.interactive?null:"describedby":n.aria.content},n}function w1(t,e){t===void 0&&(t={}),e===void 0&&(e=[]);var n=Object.keys(t);n.forEach(function(r){var i=Vk(Et,Object.keys(_1)),s=!zk(i,r);s&&(s=e.filter(function(o){return o.name===r}).length===0),yn(s,["`"+r+"`","is not a valid prop. You may have spelled it incorrectly, or if it's","a plugin, forgot to pass it in an array as props.plugins.",` + `)}function E1(t){return[nv(t),"color: #00C584; font-size: 1.3em; font-weight: bold;","line-height: 1.5","color: #a6a095;"]}var Ji;({}).NODE_ENV!=="production"&&rv();function rv(){Ji=new Set}function yn(t,e){if(t&&!Ji.has(e)){var n;Ji.add(e),(n=console).warn.apply(n,E1(e))}}function xu(t,e){if(t&&!Ji.has(e)){var n;Ji.add(e),(n=console).error.apply(n,E1(e))}}function iv(t){var e=!t,n=Object.prototype.toString.call(t)==="[object Object]"&&!t.addEventListener;xu(e,["tippy() was passed","`"+String(t)+"`","as its targets (first) argument. Valid types are: String, Element,","Element[], or NodeList."].join(" ")),xu(n,["tippy() was passed a plain object which is not supported as an argument","for virtual positioning. Use props.getReferenceClientRect instead."].join(" "))}var _1={animateFill:!1,followCursor:!1,inlinePositioning:!1,sticky:!1},sv={allowHTML:!1,animation:"fade",arrow:!0,content:"",inertia:!1,maxWidth:350,role:"tooltip",theme:"",zIndex:9999},Et=Object.assign({appendTo:x1,aria:{content:"auto",expanded:"auto"},delay:0,duration:[300,250],getReferenceClientRect:null,hideOnClick:!0,ignoreAttributes:!1,interactive:!1,interactiveBorder:2,interactiveDebounce:0,moveTransition:"",offset:[0,10],onAfterUpdate:function(){},onBeforeUpdate:function(){},onCreate:function(){},onDestroy:function(){},onHidden:function(){},onHide:function(){},onMount:function(){},onShow:function(){},onShown:function(){},onTrigger:function(){},onUntrigger:function(){},onClickOutside:function(){},placement:"top",plugins:[],popperOptions:{},render:null,showOnCreate:!1,touch:!0,trigger:"mouseenter focus",triggerTarget:null},_1,sv),ov=Object.keys(Et),av=function(e){({}).NODE_ENV!=="production"&&w1(e,[]);var n=Object.keys(e);n.forEach(function(r){Et[r]=e[r]})};function C1(t){var e=t.plugins||[],n=e.reduce(function(r,i){var s=i.name,o=i.defaultValue;if(s){var a;r[s]=t[s]!==void 0?t[s]:(a=Et[s])!=null?a:o}return r},{});return Object.assign({},t,n)}function lv(t,e){var n=e?Object.keys(C1(Object.assign({},Et,{plugins:e}))):ov,r=n.reduce(function(i,s){var o=(t.getAttribute("data-tippy-"+s)||"").trim();if(!o)return i;if(s==="content")i[s]=o;else try{i[s]=JSON.parse(o)}catch{i[s]=o}return i},{});return r}function kf(t,e){var n=Object.assign({},e,{content:k1(e.content,[t])},e.ignoreAttributes?{}:lv(t,e.plugins));return n.aria=Object.assign({},Et.aria,n.aria),n.aria={expanded:n.aria.expanded==="auto"?e.interactive:n.aria.expanded,content:n.aria.content==="auto"?e.interactive?null:"describedby":n.aria.content},n}function w1(t,e){t===void 0&&(t={}),e===void 0&&(e=[]);var n=Object.keys(t);n.forEach(function(r){var i=zk(Et,Object.keys(_1)),s=!$k(i,r);s&&(s=e.filter(function(o){return o.name===r}).length===0),yn(s,["`"+r+"`","is not a valid prop. You may have spelled it incorrectly, or if it's","a plugin, forgot to pass it in an array as props.plugins.",` `,`All props: https://atomiks.github.io/tippyjs/v6/all-props/ -`,"Plugins: https://atomiks.github.io/tippyjs/v6/plugins/"].join(" "))})}var cv=function(){return"innerHTML"};function ku(t,e){t[cv()]=e}function kf(t){var e=Fi();return t===!0?e.className=b1:(e.className=y1,Gi(t)?e.appendChild(t):ku(e,t)),e}function vf(t,e){Gi(e.content)?(ku(t,""),t.appendChild(e.content)):typeof e.content!="function"&&(e.allowHTML?ku(t,e.content):t.textContent=e.content)}function vu(t){var e=t.firstElementChild,n=Mo(e.children);return{box:e,content:n.find(function(r){return r.classList.contains(g1)}),arrow:n.find(function(r){return r.classList.contains(b1)||r.classList.contains(y1)}),backdrop:n.find(function(r){return r.classList.contains($k)})}}function S1(t){var e=Fi(),n=Fi();n.className=Pk,n.setAttribute("data-state","hidden"),n.setAttribute("tabindex","-1");var r=Fi();r.className=g1,r.setAttribute("data-state","hidden"),vf(r,t.props),e.appendChild(n),n.appendChild(r),i(t.props,t.props);function i(s,o){var a=vu(e),l=a.box,u=a.content,c=a.arrow;o.theme?l.setAttribute("data-theme",o.theme):l.removeAttribute("data-theme"),typeof o.animation=="string"?l.setAttribute("data-animation",o.animation):l.removeAttribute("data-animation"),o.inertia?l.setAttribute("data-inertia",""):l.removeAttribute("data-inertia"),l.style.maxWidth=typeof o.maxWidth=="number"?o.maxWidth+"px":o.maxWidth,o.role?l.setAttribute("role",o.role):l.removeAttribute("role"),(s.content!==o.content||s.allowHTML!==o.allowHTML)&&vf(u,t.props),o.arrow?c?s.arrow!==o.arrow&&(l.removeChild(c),l.appendChild(kf(o.arrow))):l.appendChild(kf(o.arrow)):c&&l.removeChild(c)}return{popper:e,onUpdate:i}}S1.$$tippy=!0;var dv=1,Hs=[],bl=[];function fv(t,e){var n=xf(t,Object.assign({},Et,C1(pf(e)))),r,i,s,o=!1,a=!1,l=!1,u=!1,c,d,f,h=[],p=ff(De,n.interactiveDebounce),m,g=dv++,y=null,x=qk(n.plugins),k={isEnabled:!0,isVisible:!1,isDestroyed:!1,isMounted:!1,isShown:!1},b={id:g,reference:t,popper:Fi(),popperInstance:y,props:n,state:k,plugins:x,clearDelayTimeouts:q,setProps:D,setContent:R,show:J,hide:ae,hideWithInteractivity:Fe,enable:je,disable:H,unmount:kt,destroy:Za};if(!n.render)return{}.NODE_ENV!=="production"&&xu(!0,"render() function has not been supplied."),b;var E=n.render(b),v=E.popper,C=E.onUpdate;v.setAttribute("data-tippy-root",""),v.id="tippy-"+b.id,b.popper=v,t._tippy=b,v._tippy=b;var T=x.map(function(M){return M.fn(b)}),w=t.hasAttribute("aria-expanded");return At(),F(),_(),S("onCreate",[b]),n.showOnCreate&&ce(),v.addEventListener("mouseenter",function(){b.props.interactive&&b.state.isVisible&&b.clearDelayTimeouts()}),v.addEventListener("mouseleave",function(){b.props.interactive&&b.props.trigger.indexOf("mouseenter")>=0&&W().addEventListener("mousemove",p)}),b;function N(){var M=b.props.touch;return Array.isArray(M)?M:[M,0]}function $(){return N()[0]==="hold"}function K(){var M;return!!((M=b.props.render)!=null&&M.$$tippy)}function U(){return m||t}function W(){var M=U().parentNode;return M?Jk(M):document}function z(){return vu(v)}function A(M){return b.state.isMounted&&!b.state.isVisible||Gt.isTouch||c&&c.type==="focus"?0:pl(b.props.delay,M?0:1,Et.delay)}function _(M){M===void 0&&(M=!1),v.style.pointerEvents=b.props.interactive&&!M?"":"none",v.style.zIndex=""+b.props.zIndex}function S(M,G,ie){if(ie===void 0&&(ie=!0),T.forEach(function(me){me[M]&&me[M].apply(me,G)}),ie){var Ee;(Ee=b.props)[M].apply(Ee,G)}}function L(){var M=b.props.aria;if(M.content){var G="aria-"+M.content,ie=v.id,Ee=$r(b.props.triggerTarget||t);Ee.forEach(function(me){var it=me.getAttribute(G);if(b.state.isVisible)me.setAttribute(G,it?it+" "+ie:ie);else{var Mt=it&&it.replace(ie,"").trim();Mt?me.setAttribute(G,Mt):me.removeAttribute(G)}})}}function F(){if(!(w||!b.props.aria.expanded)){var M=$r(b.props.triggerTarget||t);M.forEach(function(G){b.props.interactive?G.setAttribute("aria-expanded",b.state.isVisible&&G===U()?"true":"false"):G.removeAttribute("aria-expanded")})}}function j(){W().removeEventListener("mousemove",p),Hs=Hs.filter(function(M){return M!==p})}function Q(M){if(!(Gt.isTouch&&(l||M.type==="mousedown"))){var G=M.composedPath&&M.composedPath()[0]||M.target;if(!(b.props.interactive&&gf(v,G))){if($r(b.props.triggerTarget||t).some(function(ie){return gf(ie,G)})){if(Gt.isTouch||b.state.isVisible&&b.props.trigger.indexOf("click")>=0)return}else S("onClickOutside",[b,M]);b.props.hideOnClick===!0&&(b.clearDelayTimeouts(),b.hide(),a=!0,setTimeout(function(){a=!1}),b.state.isMounted||Se())}}}function pe(){l=!0}function ke(){l=!1}function fe(){var M=W();M.addEventListener("mousedown",Q,!0),M.addEventListener("touchend",Q,er),M.addEventListener("touchstart",ke,er),M.addEventListener("touchmove",pe,er)}function Se(){var M=W();M.removeEventListener("mousedown",Q,!0),M.removeEventListener("touchend",Q,er),M.removeEventListener("touchstart",ke,er),M.removeEventListener("touchmove",pe,er)}function ut(M,G){yt(M,function(){!b.state.isVisible&&v.parentNode&&v.parentNode.contains(v)&&G()})}function We(M,G){yt(M,G)}function yt(M,G){var ie=z().box;function Ee(me){me.target===ie&&(gl(ie,"remove",Ee),G())}if(M===0)return G();gl(ie,"remove",d),gl(ie,"add",Ee),d=Ee}function ct(M,G,ie){ie===void 0&&(ie=!1);var Ee=$r(b.props.triggerTarget||t);Ee.forEach(function(me){me.addEventListener(M,G,ie),h.push({node:me,eventType:M,handler:G,options:ie})})}function At(){$()&&(ct("touchstart",he,{passive:!0}),ct("touchend",rt,{passive:!0})),Uk(b.props.trigger).forEach(function(M){if(M!=="manual")switch(ct(M,he),M){case"mouseenter":ct("mouseleave",rt);break;case"focus":ct(nv?"focusout":"blur",Le);break;case"focusin":ct("focusout",Le);break}})}function xt(){h.forEach(function(M){var G=M.node,ie=M.eventType,Ee=M.handler,me=M.options;G.removeEventListener(ie,Ee,me)}),h=[]}function he(M){var G,ie=!1;if(!(!b.state.isEnabled||te(M)||a)){var Ee=((G=c)==null?void 0:G.type)==="focus";c=M,m=M.currentTarget,F(),!b.state.isVisible&&Wk(M)&&Hs.forEach(function(me){return me(M)}),M.type==="click"&&(b.props.trigger.indexOf("mouseenter")<0||o)&&b.props.hideOnClick!==!1&&b.state.isVisible?ie=!0:ce(M),M.type==="click"&&(o=!ie),ie&&!Ee&&Qe(M)}}function De(M){var G=M.target,ie=U().contains(G)||v.contains(G);if(!(M.type==="mousemove"&&ie)){var Ee=be().concat(v).map(function(me){var it,Mt=me._tippy,Sr=(it=Mt.popperInstance)==null?void 0:it.state;return Sr?{popperRect:me.getBoundingClientRect(),popperState:Sr,props:n}:null}).filter(Boolean);Yk(Ee,M)&&(j(),Qe(M))}}function rt(M){var G=te(M)||b.props.trigger.indexOf("click")>=0&&o;if(!G){if(b.props.interactive){b.hideWithInteractivity(M);return}Qe(M)}}function Le(M){b.props.trigger.indexOf("focusin")<0&&M.target!==U()||b.props.interactive&&M.relatedTarget&&v.contains(M.relatedTarget)||Qe(M)}function te(M){return Gt.isTouch?$()!==M.type.indexOf("touch")>=0:!1}function Bt(){V();var M=b.props,G=M.popperOptions,ie=M.placement,Ee=M.offset,me=M.getReferenceClientRect,it=M.moveTransition,Mt=K()?vu(v).arrow:null,Sr=me?{getBoundingClientRect:me,contextElement:me.contextElement||U()}:t,Qc={name:"$$tippy",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(Ds){var Ar=Ds.state;if(K()){var Vg=z(),Wa=Vg.box;["placement","reference-hidden","escaped"].forEach(function(Os){Os==="placement"?Wa.setAttribute("data-placement",Ar.placement):Ar.attributes.popper["data-popper-"+Os]?Wa.setAttribute("data-"+Os,""):Wa.removeAttribute("data-"+Os)}),Ar.attributes.popper={}}}},Xn=[{name:"offset",options:{offset:Ee}},{name:"preventOverflow",options:{padding:{top:2,bottom:2,left:5,right:5}}},{name:"flip",options:{padding:5}},{name:"computeStyles",options:{adaptive:!it}},Qc];K()&&Mt&&Xn.push({name:"arrow",options:{element:Mt,padding:3}}),Xn.push.apply(Xn,(G==null?void 0:G.modifiers)||[]),b.popperInstance=Bk(Sr,v,Object.assign({},G,{placement:ie,onFirstUpdate:f,modifiers:Xn}))}function V(){b.popperInstance&&(b.popperInstance.destroy(),b.popperInstance=null)}function de(){var M=b.props.appendTo,G,ie=U();b.props.interactive&&M===x1||M==="parent"?G=ie.parentNode:G=k1(M,[ie]),G.contains(v)||G.appendChild(v),b.state.isMounted=!0,Bt(),{}.NODE_ENV!=="production"&&yn(b.props.interactive&&M===Et.appendTo&&ie.nextElementSibling!==v,["Interactive tippy element may not be accessible via keyboard","navigation because it is not directly after the reference element","in the DOM source order.",` +`,"Plugins: https://atomiks.github.io/tippyjs/v6/plugins/"].join(" "))})}var uv=function(){return"innerHTML"};function ku(t,e){t[uv()]=e}function vf(t){var e=Fi();return t===!0?e.className=b1:(e.className=y1,Gi(t)?e.appendChild(t):ku(e,t)),e}function Ef(t,e){Gi(e.content)?(ku(t,""),t.appendChild(e.content)):typeof e.content!="function"&&(e.allowHTML?ku(t,e.content):t.textContent=e.content)}function vu(t){var e=t.firstElementChild,n=Mo(e.children);return{box:e,content:n.find(function(r){return r.classList.contains(g1)}),arrow:n.find(function(r){return r.classList.contains(b1)||r.classList.contains(y1)}),backdrop:n.find(function(r){return r.classList.contains(Pk)})}}function S1(t){var e=Fi(),n=Fi();n.className=Bk,n.setAttribute("data-state","hidden"),n.setAttribute("tabindex","-1");var r=Fi();r.className=g1,r.setAttribute("data-state","hidden"),Ef(r,t.props),e.appendChild(n),n.appendChild(r),i(t.props,t.props);function i(s,o){var a=vu(e),l=a.box,u=a.content,c=a.arrow;o.theme?l.setAttribute("data-theme",o.theme):l.removeAttribute("data-theme"),typeof o.animation=="string"?l.setAttribute("data-animation",o.animation):l.removeAttribute("data-animation"),o.inertia?l.setAttribute("data-inertia",""):l.removeAttribute("data-inertia"),l.style.maxWidth=typeof o.maxWidth=="number"?o.maxWidth+"px":o.maxWidth,o.role?l.setAttribute("role",o.role):l.removeAttribute("role"),(s.content!==o.content||s.allowHTML!==o.allowHTML)&&Ef(u,t.props),o.arrow?c?s.arrow!==o.arrow&&(l.removeChild(c),l.appendChild(vf(o.arrow))):l.appendChild(vf(o.arrow)):c&&l.removeChild(c)}return{popper:e,onUpdate:i}}S1.$$tippy=!0;var cv=1,Hs=[],bl=[];function dv(t,e){var n=kf(t,Object.assign({},Et,C1(mf(e)))),r,i,s,o=!1,a=!1,l=!1,u=!1,c,d,f,h=[],p=hf(De,n.interactiveDebounce),m,g=cv++,y=null,x=Uk(n.plugins),k={isEnabled:!0,isVisible:!1,isDestroyed:!1,isMounted:!1,isShown:!1},b={id:g,reference:t,popper:Fi(),popperInstance:y,props:n,state:k,plugins:x,clearDelayTimeouts:q,setProps:D,setContent:R,show:J,hide:ae,hideWithInteractivity:Fe,enable:je,disable:B,unmount:kt,destroy:Za};if(!n.render)return{}.NODE_ENV!=="production"&&xu(!0,"render() function has not been supplied."),b;var E=n.render(b),v=E.popper,C=E.onUpdate;v.setAttribute("data-tippy-root",""),v.id="tippy-"+b.id,b.popper=v,t._tippy=b,v._tippy=b;var T=x.map(function(M){return M.fn(b)}),w=t.hasAttribute("aria-expanded");return At(),F(),_(),S("onCreate",[b]),n.showOnCreate&&ce(),v.addEventListener("mouseenter",function(){b.props.interactive&&b.state.isVisible&&b.clearDelayTimeouts()}),v.addEventListener("mouseleave",function(){b.props.interactive&&b.props.trigger.indexOf("mouseenter")>=0&&W().addEventListener("mousemove",p)}),b;function N(){var M=b.props.touch;return Array.isArray(M)?M:[M,0]}function $(){return N()[0]==="hold"}function K(){var M;return!!((M=b.props.render)!=null&&M.$$tippy)}function U(){return m||t}function W(){var M=U().parentNode;return M?Gk(M):document}function z(){return vu(v)}function A(M){return b.state.isMounted&&!b.state.isVisible||Gt.isTouch||c&&c.type==="focus"?0:pl(b.props.delay,M?0:1,Et.delay)}function _(M){M===void 0&&(M=!1),v.style.pointerEvents=b.props.interactive&&!M?"":"none",v.style.zIndex=""+b.props.zIndex}function S(M,G,ie){if(ie===void 0&&(ie=!0),T.forEach(function(ge){ge[M]&&ge[M].apply(ge,G)}),ie){var Ee;(Ee=b.props)[M].apply(Ee,G)}}function L(){var M=b.props.aria;if(M.content){var G="aria-"+M.content,ie=v.id,Ee=$r(b.props.triggerTarget||t);Ee.forEach(function(ge){var it=ge.getAttribute(G);if(b.state.isVisible)ge.setAttribute(G,it?it+" "+ie:ie);else{var Mt=it&&it.replace(ie,"").trim();Mt?ge.setAttribute(G,Mt):ge.removeAttribute(G)}})}}function F(){if(!(w||!b.props.aria.expanded)){var M=$r(b.props.triggerTarget||t);M.forEach(function(G){b.props.interactive?G.setAttribute("aria-expanded",b.state.isVisible&&G===U()?"true":"false"):G.removeAttribute("aria-expanded")})}}function j(){W().removeEventListener("mousemove",p),Hs=Hs.filter(function(M){return M!==p})}function Q(M){if(!(Gt.isTouch&&(l||M.type==="mousedown"))){var G=M.composedPath&&M.composedPath()[0]||M.target;if(!(b.props.interactive&&bf(v,G))){if($r(b.props.triggerTarget||t).some(function(ie){return bf(ie,G)})){if(Gt.isTouch||b.state.isVisible&&b.props.trigger.indexOf("click")>=0)return}else S("onClickOutside",[b,M]);b.props.hideOnClick===!0&&(b.clearDelayTimeouts(),b.hide(),a=!0,setTimeout(function(){a=!1}),b.state.isMounted||Se())}}}function pe(){l=!0}function ke(){l=!1}function fe(){var M=W();M.addEventListener("mousedown",Q,!0),M.addEventListener("touchend",Q,er),M.addEventListener("touchstart",ke,er),M.addEventListener("touchmove",pe,er)}function Se(){var M=W();M.removeEventListener("mousedown",Q,!0),M.removeEventListener("touchend",Q,er),M.removeEventListener("touchstart",ke,er),M.removeEventListener("touchmove",pe,er)}function ut(M,G){yt(M,function(){!b.state.isVisible&&v.parentNode&&v.parentNode.contains(v)&&G()})}function We(M,G){yt(M,G)}function yt(M,G){var ie=z().box;function Ee(ge){ge.target===ie&&(gl(ie,"remove",Ee),G())}if(M===0)return G();gl(ie,"remove",d),gl(ie,"add",Ee),d=Ee}function ct(M,G,ie){ie===void 0&&(ie=!1);var Ee=$r(b.props.triggerTarget||t);Ee.forEach(function(ge){ge.addEventListener(M,G,ie),h.push({node:ge,eventType:M,handler:G,options:ie})})}function At(){$()&&(ct("touchstart",he,{passive:!0}),ct("touchend",rt,{passive:!0})),Vk(b.props.trigger).forEach(function(M){if(M!=="manual")switch(ct(M,he),M){case"mouseenter":ct("mouseleave",rt);break;case"focus":ct(tv?"focusout":"blur",Le);break;case"focusin":ct("focusout",Le);break}})}function xt(){h.forEach(function(M){var G=M.node,ie=M.eventType,Ee=M.handler,ge=M.options;G.removeEventListener(ie,Ee,ge)}),h=[]}function he(M){var G,ie=!1;if(!(!b.state.isEnabled||te(M)||a)){var Ee=((G=c)==null?void 0:G.type)==="focus";c=M,m=M.currentTarget,F(),!b.state.isVisible&&Kk(M)&&Hs.forEach(function(ge){return ge(M)}),M.type==="click"&&(b.props.trigger.indexOf("mouseenter")<0||o)&&b.props.hideOnClick!==!1&&b.state.isVisible?ie=!0:ce(M),M.type==="click"&&(o=!ie),ie&&!Ee&&Qe(M)}}function De(M){var G=M.target,ie=U().contains(G)||v.contains(G);if(!(M.type==="mousemove"&&ie)){var Ee=be().concat(v).map(function(ge){var it,Mt=ge._tippy,Sr=(it=Mt.popperInstance)==null?void 0:it.state;return Sr?{popperRect:ge.getBoundingClientRect(),popperState:Sr,props:n}:null}).filter(Boolean);Jk(Ee,M)&&(j(),Qe(M))}}function rt(M){var G=te(M)||b.props.trigger.indexOf("click")>=0&&o;if(!G){if(b.props.interactive){b.hideWithInteractivity(M);return}Qe(M)}}function Le(M){b.props.trigger.indexOf("focusin")<0&&M.target!==U()||b.props.interactive&&M.relatedTarget&&v.contains(M.relatedTarget)||Qe(M)}function te(M){return Gt.isTouch?$()!==M.type.indexOf("touch")>=0:!1}function Bt(){V();var M=b.props,G=M.popperOptions,ie=M.placement,Ee=M.offset,ge=M.getReferenceClientRect,it=M.moveTransition,Mt=K()?vu(v).arrow:null,Sr=ge?{getBoundingClientRect:ge,contextElement:ge.contextElement||U()}:t,ed={name:"$$tippy",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(Ds){var Ar=Ds.state;if(K()){var zg=z(),Wa=zg.box;["placement","reference-hidden","escaped"].forEach(function(Os){Os==="placement"?Wa.setAttribute("data-placement",Ar.placement):Ar.attributes.popper["data-popper-"+Os]?Wa.setAttribute("data-"+Os,""):Wa.removeAttribute("data-"+Os)}),Ar.attributes.popper={}}}},Xn=[{name:"offset",options:{offset:Ee}},{name:"preventOverflow",options:{padding:{top:2,bottom:2,left:5,right:5}}},{name:"flip",options:{padding:5}},{name:"computeStyles",options:{adaptive:!it}},ed];K()&&Mt&&Xn.push({name:"arrow",options:{element:Mt,padding:3}}),Xn.push.apply(Xn,(G==null?void 0:G.modifiers)||[]),b.popperInstance=Hk(Sr,v,Object.assign({},G,{placement:ie,onFirstUpdate:f,modifiers:Xn}))}function V(){b.popperInstance&&(b.popperInstance.destroy(),b.popperInstance=null)}function de(){var M=b.props.appendTo,G,ie=U();b.props.interactive&&M===x1||M==="parent"?G=ie.parentNode:G=k1(M,[ie]),G.contains(v)||G.appendChild(v),b.state.isMounted=!0,Bt(),{}.NODE_ENV!=="production"&&yn(b.props.interactive&&M===Et.appendTo&&ie.nextElementSibling!==v,["Interactive tippy element may not be accessible via keyboard","navigation because it is not directly after the reference element","in the DOM source order.",` `,"Using a wrapper
or tag around the reference element","solves this by creating a new parentNode context.",` `,"Specifying `appendTo: document.body` silences this warning, but it","assumes you are using a focus management solution to handle","keyboard navigation.",` -`,"See: https://atomiks.github.io/tippyjs/v6/accessibility/#interactivity"].join(" "))}function be(){return Mo(v.querySelectorAll("[data-tippy-root]"))}function ce(M){b.clearDelayTimeouts(),M&&S("onTrigger",[b,M]),fe();var G=A(!0),ie=N(),Ee=ie[0],me=ie[1];Gt.isTouch&&Ee==="hold"&&me&&(G=me),G?r=setTimeout(function(){b.show()},G):b.show()}function Qe(M){if(b.clearDelayTimeouts(),S("onUntrigger",[b,M]),!b.state.isVisible){Se();return}if(!(b.props.trigger.indexOf("mouseenter")>=0&&b.props.trigger.indexOf("click")>=0&&["mouseleave","mousemove"].indexOf(M.type)>=0&&o)){var G=A(!1);G?i=setTimeout(function(){b.state.isVisible&&b.hide()},G):s=requestAnimationFrame(function(){b.hide()})}}function je(){b.state.isEnabled=!0}function H(){b.hide(),b.state.isEnabled=!1}function q(){clearTimeout(r),clearTimeout(i),cancelAnimationFrame(s)}function D(M){if({}.NODE_ENV!=="production"&&yn(b.state.isDestroyed,Dr("setProps")),!b.state.isDestroyed){S("onBeforeUpdate",[b,M]),xt();var G=b.props,ie=xf(t,Object.assign({},G,pf(M),{ignoreAttributes:!0}));b.props=ie,At(),G.interactiveDebounce!==ie.interactiveDebounce&&(j(),p=ff(De,ie.interactiveDebounce)),G.triggerTarget&&!ie.triggerTarget?$r(G.triggerTarget).forEach(function(Ee){Ee.removeAttribute("aria-expanded")}):ie.triggerTarget&&t.removeAttribute("aria-expanded"),F(),_(),C&&C(G,ie),b.popperInstance&&(Bt(),be().forEach(function(Ee){requestAnimationFrame(Ee._tippy.popperInstance.forceUpdate)})),S("onAfterUpdate",[b,M])}}function R(M){b.setProps({content:M})}function J(){({}).NODE_ENV!=="production"&&yn(b.state.isDestroyed,Dr("show"));var M=b.state.isVisible,G=b.state.isDestroyed,ie=!b.state.isEnabled,Ee=Gt.isTouch&&!b.props.touch,me=pl(b.props.duration,0,Et.duration);if(!(M||G||ie||Ee)&&!U().hasAttribute("disabled")&&(S("onShow",[b],!1),b.props.onShow(b)!==!1)){if(b.state.isVisible=!0,K()&&(v.style.visibility="visible"),_(),fe(),b.state.isMounted||(v.style.transition="none"),K()){var it=z(),Mt=it.box,Sr=it.content;ml([Mt,Sr],0)}f=function(){var Xn;if(!(!b.state.isVisible||u)){if(u=!0,v.offsetHeight,v.style.transition=b.props.moveTransition,K()&&b.props.animation){var Ka=z(),Ds=Ka.box,Ar=Ka.content;ml([Ds,Ar],me),mf([Ds,Ar],"visible")}L(),F(),hf(bl,b),(Xn=b.popperInstance)==null||Xn.forceUpdate(),S("onMount",[b]),b.props.animation&&K()&&We(me,function(){b.state.isShown=!0,S("onShown",[b])})}},de()}}function ae(){({}).NODE_ENV!=="production"&&yn(b.state.isDestroyed,Dr("hide"));var M=!b.state.isVisible,G=b.state.isDestroyed,ie=!b.state.isEnabled,Ee=pl(b.props.duration,1,Et.duration);if(!(M||G||ie)&&(S("onHide",[b],!1),b.props.onHide(b)!==!1)){if(b.state.isVisible=!1,b.state.isShown=!1,u=!1,o=!1,K()&&(v.style.visibility="hidden"),j(),Se(),_(!0),K()){var me=z(),it=me.box,Mt=me.content;b.props.animation&&(ml([it,Mt],Ee),mf([it,Mt],"hidden"))}L(),F(),b.props.animation?K()&&ut(Ee,b.unmount):b.unmount()}}function Fe(M){({}).NODE_ENV!=="production"&&yn(b.state.isDestroyed,Dr("hideWithInteractivity")),W().addEventListener("mousemove",p),hf(Hs,p),p(M)}function kt(){({}).NODE_ENV!=="production"&&yn(b.state.isDestroyed,Dr("unmount")),b.state.isVisible&&b.hide(),b.state.isMounted&&(V(),be().forEach(function(M){M._tippy.unmount()}),v.parentNode&&v.parentNode.removeChild(v),bl=bl.filter(function(M){return M!==b}),b.state.isMounted=!1,S("onHidden",[b]))}function Za(){({}).NODE_ENV!=="production"&&yn(b.state.isDestroyed,Dr("destroy")),!b.state.isDestroyed&&(b.clearDelayTimeouts(),b.unmount(),xt(),delete t._tippy,b.state.isDestroyed=!0,S("onDestroy",[b]))}}function Ke(t,e){e===void 0&&(e={});var n=Et.plugins.concat(e.plugins||[]);({}).NODE_ENV!=="production"&&(sv(t),w1(e,n)),ev();var r=Object.assign({},e,{plugins:n}),i=Gk(t);if({}.NODE_ENV!=="production"){var s=Gi(r.content),o=i.length>1;yn(s&&o,["tippy() was passed an Element as the `content` prop, but more than","one tippy instance was created by this invocation. This means the","content element will only be appended to the last tippy instance.",` +`,"See: https://atomiks.github.io/tippyjs/v6/accessibility/#interactivity"].join(" "))}function be(){return Mo(v.querySelectorAll("[data-tippy-root]"))}function ce(M){b.clearDelayTimeouts(),M&&S("onTrigger",[b,M]),fe();var G=A(!0),ie=N(),Ee=ie[0],ge=ie[1];Gt.isTouch&&Ee==="hold"&&ge&&(G=ge),G?r=setTimeout(function(){b.show()},G):b.show()}function Qe(M){if(b.clearDelayTimeouts(),S("onUntrigger",[b,M]),!b.state.isVisible){Se();return}if(!(b.props.trigger.indexOf("mouseenter")>=0&&b.props.trigger.indexOf("click")>=0&&["mouseleave","mousemove"].indexOf(M.type)>=0&&o)){var G=A(!1);G?i=setTimeout(function(){b.state.isVisible&&b.hide()},G):s=requestAnimationFrame(function(){b.hide()})}}function je(){b.state.isEnabled=!0}function B(){b.hide(),b.state.isEnabled=!1}function q(){clearTimeout(r),clearTimeout(i),cancelAnimationFrame(s)}function D(M){if({}.NODE_ENV!=="production"&&yn(b.state.isDestroyed,Dr("setProps")),!b.state.isDestroyed){S("onBeforeUpdate",[b,M]),xt();var G=b.props,ie=kf(t,Object.assign({},G,mf(M),{ignoreAttributes:!0}));b.props=ie,At(),G.interactiveDebounce!==ie.interactiveDebounce&&(j(),p=hf(De,ie.interactiveDebounce)),G.triggerTarget&&!ie.triggerTarget?$r(G.triggerTarget).forEach(function(Ee){Ee.removeAttribute("aria-expanded")}):ie.triggerTarget&&t.removeAttribute("aria-expanded"),F(),_(),C&&C(G,ie),b.popperInstance&&(Bt(),be().forEach(function(Ee){requestAnimationFrame(Ee._tippy.popperInstance.forceUpdate)})),S("onAfterUpdate",[b,M])}}function R(M){b.setProps({content:M})}function J(){({}).NODE_ENV!=="production"&&yn(b.state.isDestroyed,Dr("show"));var M=b.state.isVisible,G=b.state.isDestroyed,ie=!b.state.isEnabled,Ee=Gt.isTouch&&!b.props.touch,ge=pl(b.props.duration,0,Et.duration);if(!(M||G||ie||Ee)&&!U().hasAttribute("disabled")&&(S("onShow",[b],!1),b.props.onShow(b)!==!1)){if(b.state.isVisible=!0,K()&&(v.style.visibility="visible"),_(),fe(),b.state.isMounted||(v.style.transition="none"),K()){var it=z(),Mt=it.box,Sr=it.content;ml([Mt,Sr],0)}f=function(){var Xn;if(!(!b.state.isVisible||u)){if(u=!0,v.offsetHeight,v.style.transition=b.props.moveTransition,K()&&b.props.animation){var Ka=z(),Ds=Ka.box,Ar=Ka.content;ml([Ds,Ar],ge),gf([Ds,Ar],"visible")}L(),F(),pf(bl,b),(Xn=b.popperInstance)==null||Xn.forceUpdate(),S("onMount",[b]),b.props.animation&&K()&&We(ge,function(){b.state.isShown=!0,S("onShown",[b])})}},de()}}function ae(){({}).NODE_ENV!=="production"&&yn(b.state.isDestroyed,Dr("hide"));var M=!b.state.isVisible,G=b.state.isDestroyed,ie=!b.state.isEnabled,Ee=pl(b.props.duration,1,Et.duration);if(!(M||G||ie)&&(S("onHide",[b],!1),b.props.onHide(b)!==!1)){if(b.state.isVisible=!1,b.state.isShown=!1,u=!1,o=!1,K()&&(v.style.visibility="hidden"),j(),Se(),_(!0),K()){var ge=z(),it=ge.box,Mt=ge.content;b.props.animation&&(ml([it,Mt],Ee),gf([it,Mt],"hidden"))}L(),F(),b.props.animation?K()&&ut(Ee,b.unmount):b.unmount()}}function Fe(M){({}).NODE_ENV!=="production"&&yn(b.state.isDestroyed,Dr("hideWithInteractivity")),W().addEventListener("mousemove",p),pf(Hs,p),p(M)}function kt(){({}).NODE_ENV!=="production"&&yn(b.state.isDestroyed,Dr("unmount")),b.state.isVisible&&b.hide(),b.state.isMounted&&(V(),be().forEach(function(M){M._tippy.unmount()}),v.parentNode&&v.parentNode.removeChild(v),bl=bl.filter(function(M){return M!==b}),b.state.isMounted=!1,S("onHidden",[b]))}function Za(){({}).NODE_ENV!=="production"&&yn(b.state.isDestroyed,Dr("destroy")),!b.state.isDestroyed&&(b.clearDelayTimeouts(),b.unmount(),xt(),delete t._tippy,b.state.isDestroyed=!0,S("onDestroy",[b]))}}function Ke(t,e){e===void 0&&(e={});var n=Et.plugins.concat(e.plugins||[]);({}).NODE_ENV!=="production"&&(iv(t),w1(e,n)),Qk();var r=Object.assign({},e,{plugins:n}),i=jk(t);if({}.NODE_ENV!=="production"){var s=Gi(r.content),o=i.length>1;yn(s&&o,["tippy() was passed an Element as the `content` prop, but more than","one tippy instance was created by this invocation. This means the","content element will only be appended to the last tippy instance.",` `,"Instead, pass the .innerHTML of the element, or use a function that","returns a cloned version of the element instead.",` `,`1) content: element.innerHTML -`,"2) content: () => element.cloneNode(true)"].join(" "))}var a=i.reduce(function(l,u){var c=u&&fv(u,r);return c&&l.push(c),l},[]);return Gi(t)?a[0]:a}Ke.defaultProps=Et;Ke.setDefaultProps=lv;Ke.currentInput=Gt;Object.assign({},l1,{effect:function(e){var n=e.state,r={popper:{position:n.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};Object.assign(n.elements.popper.style,r.popper),n.styles=r,n.elements.arrow&&Object.assign(n.elements.arrow.style,r.arrow)}});Ke.setDefaultProps({render:S1});class gi extends ge{constructor(){super(...arguments);B(this,"tippyInstance");B(this,"tippyEl");B(this,"textEl");B(this,"menuData",[]);B(this,"menuTextWidth","40px");B(this,"defaultMenuIndex",0);B(this,"refreshMenuText",!0);B(this,"width","48px");B(this,"dropDivWith","100px");B(this,"dropDivHeight","260px");B(this,"showItemsTip",!1)}renderTemplate(){this.template=` +`,"2) content: () => element.cloneNode(true)"].join(" "))}var a=i.reduce(function(l,u){var c=u&&dv(u,r);return c&&l.push(c),l},[]);return Gi(t)?a[0]:a}Ke.defaultProps=Et;Ke.setDefaultProps=av;Ke.currentInput=Gt;Object.assign({},l1,{effect:function(e){var n=e.state,r={popper:{position:n.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};Object.assign(n.elements.popper.style,r.popper),n.styles=r,n.elements.arrow&&Object.assign(n.elements.arrow.style,r.arrow)}});Ke.setDefaultProps({render:S1});class gi extends me{constructor(){super(...arguments);H(this,"tippyInstance");H(this,"tippyEl");H(this,"textEl");H(this,"menuData",[]);H(this,"menuTextWidth","40px");H(this,"defaultMenuIndex",0);H(this,"refreshMenuText",!0);H(this,"width","48px");H(this,"dropDivWith","100px");H(this,"dropDivHeight","260px");H(this,"showItemsTip",!1)}renderTemplate(){this.template=`
@@ -127,31 +127,31 @@ img.ProseMirror-separator { `}connectedCallback(){this.renderTemplate(),super.connectedCallback(),this.textEl=this.querySelector("#text"),this.tippyInstance=Ke(this.querySelector("#tippy"),{content:this.createMenuElement(),appendTo:this.closest(".aie-container"),placement:"bottom",trigger:"click",interactive:!0,arrow:!1})}createMenuElement(){const n=document.createElement("div");n.style.height=this.dropDivHeight,n.style.width=this.dropDivWith,n.classList.add("aie-dropdown-container");for(let r=0;r
${this.onDropdownItemRender(r)}
- `,i.addEventListener("click",()=>{this.onDropdownItemClick(r),this.tippyInstance.hide()}),this.showItemsTip){const s=this.menuData[r];Ke(i,{appendTo:()=>this.closest(".aie-container"),content:s.tip||s.title,theme:"aietip",arrow:!0,placement:"right"})}n.appendChild(i)}return this.tippyEl=n,n}onTransaction(n){var s,o;const r=(s=this.tippyEl)==null?void 0:s.querySelector(".red-dot");r&&r.classList.remove("red-dot");let i=this.defaultMenuIndex;for(let a=0;a1&&arguments[1]!==void 0?arguments[1]:{};this.init(e,n)}init(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.prefix=n.prefix||"i18next:",this.logger=e||hv,this.options=n,this.debug=n.debug}log(){for(var e=arguments.length,n=new Array(e),r=0;r{this.observers[r]=this.observers[r]||[],this.observers[r].push(n)}),this}off(e,n){if(this.observers[e]){if(!n){delete this.observers[e];return}this.observers[e]=this.observers[e].filter(r=>r!==n)}}emit(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i{o(...r)}),this.observers["*"]&&[].concat(this.observers["*"]).forEach(o=>{o.apply(o,[e,...r])})}}function Ei(){let t,e;const n=new Promise((r,i)=>{t=r,e=i});return n.resolve=t,n.reject=e,n}function Ef(t){return t==null?"":""+t}function pv(t,e,n){t.forEach(r=>{e[r]&&(n[r]=e[r])})}function gc(t,e,n){function r(o){return o&&o.indexOf("###")>-1?o.replace(/###/g,"."):o}function i(){return!t||typeof t=="string"}const s=typeof e!="string"?[].concat(e):e.split(".");for(;s.length>1;){if(i())return{};const o=r(s.shift());!t[o]&&n&&(t[o]=new n),Object.prototype.hasOwnProperty.call(t,o)?t=t[o]:t={}}return i()?{}:{obj:t,k:r(s.shift())}}function _f(t,e,n){const{obj:r,k:i}=gc(t,e,Object);r[i]=n}function mv(t,e,n,r){const{obj:i,k:s}=gc(t,e,Object);i[s]=i[s]||[],r&&(i[s]=i[s].concat(n)),r||i[s].push(n)}function Do(t,e){const{obj:n,k:r}=gc(t,e);if(n)return n[r]}function gv(t,e,n){const r=Do(t,n);return r!==void 0?r:Do(e,n)}function A1(t,e,n){for(const r in e)r!=="__proto__"&&r!=="constructor"&&(r in t?typeof t[r]=="string"||t[r]instanceof String||typeof e[r]=="string"||e[r]instanceof String?n&&(t[r]=e[r]):A1(t[r],e[r],n):t[r]=e[r]);return t}function Or(t){return t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}var bv={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};function yv(t){return typeof t=="string"?t.replace(/[&<>"'\/]/g,e=>bv[e]):t}const xv=[" ",",","?","!",";"];function kv(t,e,n){e=e||"",n=n||"";const r=xv.filter(o=>e.indexOf(o)<0&&n.indexOf(o)<0);if(r.length===0)return!0;const i=new RegExp(`(${r.map(o=>o==="?"?"\\?":o).join("|")})`);let s=!i.test(t);if(!s){const o=t.indexOf(n);o>0&&!i.test(t.substring(0,o))&&(s=!0)}return s}function Oo(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:".";if(!t)return;if(t[e])return t[e];const r=e.split(n);let i=t;for(let s=0;ss+o;)o++,a=r.slice(s,s+o).join(n),l=i[a];if(l===void 0)return;if(l===null)return null;if(e.endsWith(a)){if(typeof l=="string")return l;if(a&&typeof l[a]=="string")return l[a]}const u=r.slice(s+o).join(n);return u?Oo(l,u,n):void 0}i=i[r[s]]}return i}function No(t){return t&&t.indexOf("_")>0?t.replace("_","-"):t}class Cf extends Ca{constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{ns:["translation"],defaultNS:"translation"};super(),this.data=e||{},this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}removeNamespaces(e){const n=this.options.ns.indexOf(e);n>-1&&this.options.ns.splice(n,1)}getResource(e,n,r){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const s=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,o=i.ignoreJSONStructure!==void 0?i.ignoreJSONStructure:this.options.ignoreJSONStructure;let a=[e,n];r&&typeof r!="string"&&(a=a.concat(r)),r&&typeof r=="string"&&(a=a.concat(s?r.split(s):r)),e.indexOf(".")>-1&&(a=e.split("."));const l=Do(this.data,a);return l||!o||typeof r!="string"?l:Oo(this.data&&this.data[e]&&this.data[e][n],r,s)}addResource(e,n,r,i){let s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{silent:!1};const o=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator;let a=[e,n];r&&(a=a.concat(o?r.split(o):r)),e.indexOf(".")>-1&&(a=e.split("."),i=n,n=a[1]),this.addNamespaces(n),_f(this.data,a,i),s.silent||this.emit("added",e,n,r,i)}addResources(e,n,r){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{silent:!1};for(const s in r)(typeof r[s]=="string"||Object.prototype.toString.apply(r[s])==="[object Array]")&&this.addResource(e,n,s,r[s],{silent:!0});i.silent||this.emit("added",e,n,r)}addResourceBundle(e,n,r,i,s){let o=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{silent:!1},a=[e,n];e.indexOf(".")>-1&&(a=e.split("."),i=r,r=n,n=a[1]),this.addNamespaces(n);let l=Do(this.data,a)||{};i?A1(l,r,s):l={...l,...r},_f(this.data,a,l),o.silent||this.emit("added",e,n,r)}removeResourceBundle(e,n){this.hasResourceBundle(e,n)&&delete this.data[e][n],this.removeNamespaces(n),this.emit("removed",e,n)}hasResourceBundle(e,n){return this.getResource(e,n)!==void 0}getResourceBundle(e,n){return n||(n=this.options.defaultNS),this.options.compatibilityAPI==="v1"?{...this.getResource(e,n)}:this.getResource(e,n)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){const n=this.getDataByLanguage(e);return!!(n&&Object.keys(n)||[]).find(i=>n[i]&&Object.keys(n[i]).length>0)}toJSON(){return this.data}}var M1={processors:{},addPostProcessor(t){this.processors[t.name]=t},handle(t,e,n,r,i){return t.forEach(s=>{this.processors[s]&&(e=this.processors[s].process(e,n,r,i))}),e}};const wf={};class Lo extends Ca{constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),pv(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=Qt.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}};if(e==null)return!1;const r=this.resolve(e,n);return r&&r.res!==void 0}extractFromKey(e,n){let r=n.nsSeparator!==void 0?n.nsSeparator:this.options.nsSeparator;r===void 0&&(r=":");const i=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let s=n.ns||this.options.defaultNS||[];const o=r&&e.indexOf(r)>-1,a=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!kv(e,r,i);if(o&&!a){const l=e.match(this.interpolator.nestingRegexp);if(l&&l.length>0)return{key:e,namespaces:s};const u=e.split(r);(r!==i||r===i&&this.options.ns.indexOf(u[0])>-1)&&(s=u.shift()),e=u.join(i)}return typeof s=="string"&&(s=[s]),{key:e,namespaces:s}}translate(e,n,r){if(typeof n!="object"&&this.options.overloadTranslationOptionHandler&&(n=this.options.overloadTranslationOptionHandler(arguments)),typeof n=="object"&&(n={...n}),n||(n={}),e==null)return"";Array.isArray(e)||(e=[String(e)]);const i=n.returnDetails!==void 0?n.returnDetails:this.options.returnDetails,s=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator,{key:o,namespaces:a}=this.extractFromKey(e[e.length-1],n),l=a[a.length-1],u=n.lng||this.language,c=n.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(u&&u.toLowerCase()==="cimode"){if(c){const b=n.nsSeparator||this.options.nsSeparator;return i?{res:`${l}${b}${o}`,usedKey:o,exactUsedKey:o,usedLng:u,usedNS:l,usedParams:this.getUsedParamsDetails(n)}:`${l}${b}${o}`}return i?{res:o,usedKey:o,exactUsedKey:o,usedLng:u,usedNS:l,usedParams:this.getUsedParamsDetails(n)}:o}const d=this.resolve(e,n);let f=d&&d.res;const h=d&&d.usedKey||o,p=d&&d.exactUsedKey||o,m=Object.prototype.toString.apply(f),g=["[object Number]","[object Function]","[object RegExp]"],y=n.joinArrays!==void 0?n.joinArrays:this.options.joinArrays,x=!this.i18nFormat||this.i18nFormat.handleAsObject;if(x&&f&&(typeof f!="string"&&typeof f!="boolean"&&typeof f!="number")&&g.indexOf(m)<0&&!(typeof y=="string"&&m==="[object Array]")){if(!n.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const b=this.options.returnedObjectHandler?this.options.returnedObjectHandler(h,f,{...n,ns:a}):`key '${o} (${this.language})' returned an object instead of string.`;return i?(d.res=b,d.usedParams=this.getUsedParamsDetails(n),d):b}if(s){const b=m==="[object Array]",E=b?[]:{},v=b?p:h;for(const C in f)if(Object.prototype.hasOwnProperty.call(f,C)){const T=`${v}${s}${C}`;E[C]=this.translate(T,{...n,joinArrays:!1,ns:a}),E[C]===T&&(E[C]=f[C])}f=E}}else if(x&&typeof y=="string"&&m==="[object Array]")f=f.join(y),f&&(f=this.extendTranslation(f,e,n,r));else{let b=!1,E=!1;const v=n.count!==void 0&&typeof n.count!="string",C=Lo.hasDefaultValue(n),T=v?this.pluralResolver.getSuffix(u,n.count,n):"",w=n.ordinal&&v?this.pluralResolver.getSuffix(u,n.count,{ordinal:!1}):"",N=n[`defaultValue${T}`]||n[`defaultValue${w}`]||n.defaultValue;!this.isValidLookup(f)&&C&&(b=!0,f=N),this.isValidLookup(f)||(E=!0,f=o);const K=(n.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&E?void 0:f,U=C&&N!==f&&this.options.updateMissing;if(E||b||U){if(this.logger.log(U?"updateKey":"missingKey",u,l,o,U?N:f),s){const _=this.resolve(o,{...n,keySeparator:!1});_&&_.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let W=[];const z=this.languageUtils.getFallbackCodes(this.options.fallbackLng,n.lng||this.language);if(this.options.saveMissingTo==="fallback"&&z&&z[0])for(let _=0;_{const F=C&&L!==f?L:K;this.options.missingKeyHandler?this.options.missingKeyHandler(_,l,S,F,U,n):this.backendConnector&&this.backendConnector.saveMissing&&this.backendConnector.saveMissing(_,l,S,F,U,n),this.emit("missingKey",_,l,S,f)};this.options.saveMissing&&(this.options.saveMissingPlurals&&v?W.forEach(_=>{this.pluralResolver.getSuffixes(_,n).forEach(S=>{A([_],o+S,n[`defaultValue${S}`]||N)})}):A(W,o,N))}f=this.extendTranslation(f,e,n,d,r),E&&f===o&&this.options.appendNamespaceToMissingKey&&(f=`${l}:${o}`),(E||b)&&this.options.parseMissingKeyHandler&&(this.options.compatibilityAPI!=="v1"?f=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${l}:${o}`:o,b?f:void 0):f=this.options.parseMissingKeyHandler(f))}return i?(d.res=f,d.usedParams=this.getUsedParamsDetails(n),d):f}extendTranslation(e,n,r,i,s){var o=this;if(this.i18nFormat&&this.i18nFormat.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init({...r,interpolation:{...this.options.interpolation,...r.interpolation}});const u=typeof e=="string"&&(r&&r.interpolation&&r.interpolation.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let c;if(u){const f=e.match(this.interpolator.nestingRegexp);c=f&&f.length}let d=r.replace&&typeof r.replace!="string"?r.replace:r;if(this.options.interpolation.defaultVariables&&(d={...this.options.interpolation.defaultVariables,...d}),e=this.interpolator.interpolate(e,d,r.lng||this.language,r),u){const f=e.match(this.interpolator.nestingRegexp),h=f&&f.length;c1&&arguments[1]!==void 0?arguments[1]:{},r,i,s,o,a;return typeof e=="string"&&(e=[e]),e.forEach(l=>{if(this.isValidLookup(r))return;const u=this.extractFromKey(l,n),c=u.key;i=c;let d=u.namespaces;this.options.fallbackNS&&(d=d.concat(this.options.fallbackNS));const f=n.count!==void 0&&typeof n.count!="string",h=f&&!n.ordinal&&n.count===0&&this.pluralResolver.shouldUseIntlApi(),p=n.context!==void 0&&(typeof n.context=="string"||typeof n.context=="number")&&n.context!=="",m=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);d.forEach(g=>{this.isValidLookup(r)||(a=g,!wf[`${m[0]}-${g}`]&&this.utils&&this.utils.hasLoadedNamespace&&!this.utils.hasLoadedNamespace(a)&&(wf[`${m[0]}-${g}`]=!0,this.logger.warn(`key "${i}" for languages "${m.join(", ")}" won't get resolved as namespace "${a}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),m.forEach(y=>{if(this.isValidLookup(r))return;o=y;const x=[c];if(this.i18nFormat&&this.i18nFormat.addLookupKeys)this.i18nFormat.addLookupKeys(x,c,y,g,n);else{let b;f&&(b=this.pluralResolver.getSuffix(y,n.count,n));const E=`${this.options.pluralSeparator}zero`,v=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(f&&(x.push(c+b),n.ordinal&&b.indexOf(v)===0&&x.push(c+b.replace(v,this.options.pluralSeparator)),h&&x.push(c+E)),p){const C=`${c}${this.options.contextSeparator}${n.context}`;x.push(C),f&&(x.push(C+b),n.ordinal&&b.indexOf(v)===0&&x.push(C+b.replace(v,this.options.pluralSeparator)),h&&x.push(C+E))}}let k;for(;k=x.pop();)this.isValidLookup(r)||(s=k,r=this.getResource(y,g,k,n))}))})}),{res:r,usedKey:i,exactUsedKey:s,usedLng:o,usedNS:a}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e==="")}getResource(e,n,r){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return this.i18nFormat&&this.i18nFormat.getResource?this.i18nFormat.getResource(e,n,r,i):this.resourceStore.getResource(e,n,r,i)}getUsedParamsDetails(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const n=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],r=e.replace&&typeof e.replace!="string";let i=r?e.replace:e;if(r&&typeof e.count<"u"&&(i.count=e.count),this.options.interpolation.defaultVariables&&(i={...this.options.interpolation.defaultVariables,...i}),!r){i={...i};for(const s of n)delete i[s]}return i}static hasDefaultValue(e){const n="defaultValue";for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&n===r.substring(0,n.length)&&e[r]!==void 0)return!0;return!1}}function yl(t){return t.charAt(0).toUpperCase()+t.slice(1)}class Sf{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Qt.create("languageUtils")}getScriptPartFromCode(e){if(e=No(e),!e||e.indexOf("-")<0)return null;const n=e.split("-");return n.length===2||(n.pop(),n[n.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(n.join("-"))}getLanguagePartFromCode(e){if(e=No(e),!e||e.indexOf("-")<0)return e;const n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(typeof e=="string"&&e.indexOf("-")>-1){const n=["hans","hant","latn","cyrl","cans","mong","arab"];let r=e.split("-");return this.options.lowerCaseLng?r=r.map(i=>i.toLowerCase()):r.length===2?(r[0]=r[0].toLowerCase(),r[1]=r[1].toUpperCase(),n.indexOf(r[1].toLowerCase())>-1&&(r[1]=yl(r[1].toLowerCase()))):r.length===3&&(r[0]=r[0].toLowerCase(),r[1].length===2&&(r[1]=r[1].toUpperCase()),r[0]!=="sgn"&&r[2].length===2&&(r[2]=r[2].toUpperCase()),n.indexOf(r[1].toLowerCase())>-1&&(r[1]=yl(r[1].toLowerCase())),n.indexOf(r[2].toLowerCase())>-1&&(r[2]=yl(r[2].toLowerCase()))),r.join("-")}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}getBestMatchFromCodes(e){if(!e)return null;let n;return e.forEach(r=>{if(n)return;const i=this.formatLanguageCode(r);(!this.options.supportedLngs||this.isSupportedCode(i))&&(n=i)}),!n&&this.options.supportedLngs&&e.forEach(r=>{if(n)return;const i=this.getLanguagePartFromCode(r);if(this.isSupportedCode(i))return n=i;n=this.options.supportedLngs.find(s=>{if(s===i)return s;if(!(s.indexOf("-")<0&&i.indexOf("-")<0)&&s.indexOf(i)===0)return s})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n}getFallbackCodes(e,n){if(!e)return[];if(typeof e=="function"&&(e=e(n)),typeof e=="string"&&(e=[e]),Object.prototype.toString.apply(e)==="[object Array]")return e;if(!n)return e.default||[];let r=e[n];return r||(r=e[this.getScriptPartFromCode(n)]),r||(r=e[this.formatLanguageCode(n)]),r||(r=e[this.getLanguagePartFromCode(n)]),r||(r=e.default),r||[]}toResolveHierarchy(e,n){const r=this.getFallbackCodes(n||this.options.fallbackLng||[],e),i=[],s=o=>{o&&(this.isSupportedCode(o)?i.push(o):this.logger.warn(`rejecting language code not found in supportedLngs: ${o}`))};return typeof e=="string"&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&s(this.formatLanguageCode(e)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&s(this.getScriptPartFromCode(e)),this.options.load!=="currentOnly"&&s(this.getLanguagePartFromCode(e))):typeof e=="string"&&s(this.formatLanguageCode(e)),r.forEach(o=>{i.indexOf(o)<0&&s(this.formatLanguageCode(o))}),i}}let vv=[{lngs:["ach","ak","am","arn","br","fil","gun","ln","mfe","mg","mi","oc","pt","pt-BR","tg","tl","ti","tr","uz","wa"],nr:[1,2],fc:1},{lngs:["af","an","ast","az","bg","bn","ca","da","de","dev","el","en","eo","es","et","eu","fi","fo","fur","fy","gl","gu","ha","hi","hu","hy","ia","it","kk","kn","ku","lb","mai","ml","mn","mr","nah","nap","nb","ne","nl","nn","no","nso","pa","pap","pms","ps","pt-PT","rm","sco","se","si","so","son","sq","sv","sw","ta","te","tk","ur","yo"],nr:[1,2],fc:2},{lngs:["ay","bo","cgg","fa","ht","id","ja","jbo","ka","km","ko","ky","lo","ms","sah","su","th","tt","ug","vi","wo","zh"],nr:[1],fc:3},{lngs:["be","bs","cnr","dz","hr","ru","sr","uk"],nr:[1,2,5],fc:4},{lngs:["ar"],nr:[0,1,2,3,11,100],fc:5},{lngs:["cs","sk"],nr:[1,2,5],fc:6},{lngs:["csb","pl"],nr:[1,2,5],fc:7},{lngs:["cy"],nr:[1,2,3,8],fc:8},{lngs:["fr"],nr:[1,2],fc:9},{lngs:["ga"],nr:[1,2,3,7,11],fc:10},{lngs:["gd"],nr:[1,2,3,20],fc:11},{lngs:["is"],nr:[1,2],fc:12},{lngs:["jv"],nr:[0,1],fc:13},{lngs:["kw"],nr:[1,2,3,4],fc:14},{lngs:["lt"],nr:[1,2,10],fc:15},{lngs:["lv"],nr:[1,2,0],fc:16},{lngs:["mk"],nr:[1,2],fc:17},{lngs:["mnk"],nr:[0,1,2],fc:18},{lngs:["mt"],nr:[1,2,11,20],fc:19},{lngs:["or"],nr:[2,1],fc:2},{lngs:["ro"],nr:[1,2,20],fc:20},{lngs:["sl"],nr:[5,1,2,3],fc:21},{lngs:["he","iw"],nr:[1,2,20,21],fc:22}],Ev={1:function(t){return+(t>1)},2:function(t){return+(t!=1)},3:function(t){return 0},4:function(t){return t%10==1&&t%100!=11?0:t%10>=2&&t%10<=4&&(t%100<10||t%100>=20)?1:2},5:function(t){return t==0?0:t==1?1:t==2?2:t%100>=3&&t%100<=10?3:t%100>=11?4:5},6:function(t){return t==1?0:t>=2&&t<=4?1:2},7:function(t){return t==1?0:t%10>=2&&t%10<=4&&(t%100<10||t%100>=20)?1:2},8:function(t){return t==1?0:t==2?1:t!=8&&t!=11?2:3},9:function(t){return+(t>=2)},10:function(t){return t==1?0:t==2?1:t<7?2:t<11?3:4},11:function(t){return t==1||t==11?0:t==2||t==12?1:t>2&&t<20?2:3},12:function(t){return+(t%10!=1||t%100==11)},13:function(t){return+(t!==0)},14:function(t){return t==1?0:t==2?1:t==3?2:3},15:function(t){return t%10==1&&t%100!=11?0:t%10>=2&&(t%100<10||t%100>=20)?1:2},16:function(t){return t%10==1&&t%100!=11?0:t!==0?1:2},17:function(t){return t==1||t%10==1&&t%100!=11?0:1},18:function(t){return t==0?0:t==1?1:2},19:function(t){return t==1?0:t==0||t%100>1&&t%100<11?1:t%100>10&&t%100<20?2:3},20:function(t){return t==1?0:t==0||t%100>0&&t%100<20?1:2},21:function(t){return t%100==1?1:t%100==2?2:t%100==3||t%100==4?3:0},22:function(t){return t==1?0:t==2?1:(t<0||t>10)&&t%10==0?2:3}};const _v=["v1","v2","v3"],Cv=["v4"],Af={zero:0,one:1,two:2,few:3,many:4,other:5};function wv(){const t={};return vv.forEach(e=>{e.lngs.forEach(n=>{t[n]={numbers:e.nr,plurals:Ev[e.fc]}})}),t}class Sv{constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.languageUtils=e,this.options=n,this.logger=Qt.create("pluralResolver"),(!this.options.compatibilityJSON||Cv.includes(this.options.compatibilityJSON))&&(typeof Intl>"u"||!Intl.PluralRules)&&(this.options.compatibilityJSON="v3",this.logger.error("Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill. Will fallback to the compatibilityJSON v3 format handling.")),this.rules=wv()}addRule(e,n){this.rules[e]=n}getRule(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this.shouldUseIntlApi())try{return new Intl.PluralRules(No(e),{type:n.ordinal?"ordinal":"cardinal"})}catch{return}return this.rules[e]||this.rules[this.languageUtils.getLanguagePartFromCode(e)]}needsPlural(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const r=this.getRule(e,n);return this.shouldUseIntlApi()?r&&r.resolvedOptions().pluralCategories.length>1:r&&r.numbers.length>1}getPluralFormsOfKey(e,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return this.getSuffixes(e,r).map(i=>`${n}${i}`)}getSuffixes(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const r=this.getRule(e,n);return r?this.shouldUseIntlApi()?r.resolvedOptions().pluralCategories.sort((i,s)=>Af[i]-Af[s]).map(i=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${i}`):r.numbers.map(i=>this.getSuffix(e,i,n)):[]}getSuffix(e,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const i=this.getRule(e,r);return i?this.shouldUseIntlApi()?`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${i.select(n)}`:this.getSuffixRetroCompatible(i,n):(this.logger.warn(`no plural rule found for: ${e}`),"")}getSuffixRetroCompatible(e,n){const r=e.noAbs?e.plurals(n):e.plurals(Math.abs(n));let i=e.numbers[r];this.options.simplifyPluralSuffix&&e.numbers.length===2&&e.numbers[0]===1&&(i===2?i="plural":i===1&&(i=""));const s=()=>this.options.prepend&&i.toString()?this.options.prepend+i.toString():i.toString();return this.options.compatibilityJSON==="v1"?i===1?"":typeof i=="number"?`_plural_${i.toString()}`:s():this.options.compatibilityJSON==="v2"||this.options.simplifyPluralSuffix&&e.numbers.length===2&&e.numbers[0]===1?s():this.options.prepend&&r.toString()?this.options.prepend+r.toString():r.toString()}shouldUseIntlApi(){return!_v.includes(this.options.compatibilityJSON)}}function Mf(t,e,n){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:".",i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,s=gv(t,e,n);return!s&&i&&typeof n=="string"&&(s=Oo(t,n,r),s===void 0&&(s=Oo(e,n,r))),s}class Av{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=Qt.create("interpolator"),this.options=e,this.format=e.interpolation&&e.interpolation.format||(n=>n),this.init(e)}init(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};e.interpolation||(e.interpolation={escapeValue:!0});const n=e.interpolation;this.escape=n.escape!==void 0?n.escape:yv,this.escapeValue=n.escapeValue!==void 0?n.escapeValue:!0,this.useRawValueToEscape=n.useRawValueToEscape!==void 0?n.useRawValueToEscape:!1,this.prefix=n.prefix?Or(n.prefix):n.prefixEscaped||"{{",this.suffix=n.suffix?Or(n.suffix):n.suffixEscaped||"}}",this.formatSeparator=n.formatSeparator?n.formatSeparator:n.formatSeparator||",",this.unescapePrefix=n.unescapeSuffix?"":n.unescapePrefix||"-",this.unescapeSuffix=this.unescapePrefix?"":n.unescapeSuffix||"",this.nestingPrefix=n.nestingPrefix?Or(n.nestingPrefix):n.nestingPrefixEscaped||Or("$t("),this.nestingSuffix=n.nestingSuffix?Or(n.nestingSuffix):n.nestingSuffixEscaped||Or(")"),this.nestingOptionsSeparator=n.nestingOptionsSeparator?n.nestingOptionsSeparator:n.nestingOptionsSeparator||",",this.maxReplaces=n.maxReplaces?n.maxReplaces:1e3,this.alwaysFormat=n.alwaysFormat!==void 0?n.alwaysFormat:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=`${this.prefix}(.+?)${this.suffix}`;this.regexp=new RegExp(e,"g");const n=`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`;this.regexpUnescape=new RegExp(n,"g");const r=`${this.nestingPrefix}(.+?)${this.nestingSuffix}`;this.nestingRegexp=new RegExp(r,"g")}interpolate(e,n,r,i){let s,o,a;const l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{};function u(p){return p.replace(/\$/g,"$$$$")}const c=p=>{if(p.indexOf(this.formatSeparator)<0){const x=Mf(n,l,p,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(x,void 0,r,{...i,...n,interpolationkey:p}):x}const m=p.split(this.formatSeparator),g=m.shift().trim(),y=m.join(this.formatSeparator).trim();return this.format(Mf(n,l,g,this.options.keySeparator,this.options.ignoreJSONStructure),y,r,{...i,...n,interpolationkey:g})};this.resetRegExp();const d=i&&i.missingInterpolationHandler||this.options.missingInterpolationHandler,f=i&&i.interpolation&&i.interpolation.skipOnVariables!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:p=>u(p)},{regex:this.regexp,safeValue:p=>this.escapeValue?u(this.escape(p)):u(p)}].forEach(p=>{for(a=0;s=p.regex.exec(e);){const m=s[1].trim();if(o=c(m),o===void 0)if(typeof d=="function"){const y=d(e,s,i);o=typeof y=="string"?y:""}else if(i&&Object.prototype.hasOwnProperty.call(i,m))o="";else if(f){o=s[0];continue}else this.logger.warn(`missed to pass in variable ${m} for interpolating ${e}`),o="";else typeof o!="string"&&!this.useRawValueToEscape&&(o=Ef(o));const g=p.safeValue(o);if(e=e.replace(s[0],g),f?(p.regex.lastIndex+=o.length,p.regex.lastIndex-=s[0].length):p.regex.lastIndex=0,a++,a>=this.maxReplaces)break}}),e}nest(e,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},i,s,o;function a(l,u){const c=this.nestingOptionsSeparator;if(l.indexOf(c)<0)return l;const d=l.split(new RegExp(`${c}[ ]*{`));let f=`{${d[1]}`;l=d[0],f=this.interpolate(f,o);const h=f.match(/'/g),p=f.match(/"/g);(h&&h.length%2===0&&!p||p.length%2!==0)&&(f=f.replace(/'/g,'"'));try{o=JSON.parse(f),u&&(o={...u,...o})}catch(m){return this.logger.warn(`failed parsing options string in nesting for key ${l}`,m),`${l}${c}${f}`}return delete o.defaultValue,l}for(;i=this.nestingRegexp.exec(e);){let l=[];o={...r},o=o.replace&&typeof o.replace!="string"?o.replace:o,o.applyPostProcessor=!1,delete o.defaultValue;let u=!1;if(i[0].indexOf(this.formatSeparator)!==-1&&!/{.*}/.test(i[1])){const c=i[1].split(this.formatSeparator).map(d=>d.trim());i[1]=c.shift(),l=c,u=!0}if(s=n(a.call(this,i[1].trim(),o),o),s&&i[0]===e&&typeof s!="string")return s;typeof s!="string"&&(s=Ef(s)),s||(this.logger.warn(`missed to resolve ${i[1]} for nesting ${e}`),s=""),u&&(s=l.reduce((c,d)=>this.format(c,d,r.lng,{...r,interpolationkey:i[1].trim()}),s.trim())),e=e.replace(i[0],s),this.regexp.lastIndex=0}return e}}function Mv(t){let e=t.toLowerCase().trim();const n={};if(t.indexOf("(")>-1){const r=t.split("(");e=r[0].toLowerCase().trim();const i=r[1].substring(0,r[1].length-1);e==="currency"&&i.indexOf(":")<0?n.currency||(n.currency=i.trim()):e==="relativetime"&&i.indexOf(":")<0?n.range||(n.range=i.trim()):i.split(";").forEach(o=>{if(!o)return;const[a,...l]=o.split(":"),u=l.join(":").trim().replace(/^'+|'+$/g,"");n[a.trim()]||(n[a.trim()]=u),u==="false"&&(n[a.trim()]=!1),u==="true"&&(n[a.trim()]=!0),isNaN(u)||(n[a.trim()]=parseInt(u,10))})}return{formatName:e,formatOptions:n}}function Nr(t){const e={};return function(r,i,s){const o=i+JSON.stringify(s);let a=e[o];return a||(a=t(No(i),s),e[o]=a),a(r)}}class Tv{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=Qt.create("formatter"),this.options=e,this.formats={number:Nr((n,r)=>{const i=new Intl.NumberFormat(n,{...r});return s=>i.format(s)}),currency:Nr((n,r)=>{const i=new Intl.NumberFormat(n,{...r,style:"currency"});return s=>i.format(s)}),datetime:Nr((n,r)=>{const i=new Intl.DateTimeFormat(n,{...r});return s=>i.format(s)}),relativetime:Nr((n,r)=>{const i=new Intl.RelativeTimeFormat(n,{...r});return s=>i.format(s,r.range||"day")}),list:Nr((n,r)=>{const i=new Intl.ListFormat(n,{...r});return s=>i.format(s)})},this.init(e)}init(e){const r=(arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}}).interpolation;this.formatSeparator=r.formatSeparator?r.formatSeparator:r.formatSeparator||","}add(e,n){this.formats[e.toLowerCase().trim()]=n}addCached(e,n){this.formats[e.toLowerCase().trim()]=Nr(n)}format(e,n,r){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return n.split(this.formatSeparator).reduce((a,l)=>{const{formatName:u,formatOptions:c}=Mv(l);if(this.formats[u]){let d=a;try{const f=i&&i.formatParams&&i.formatParams[i.interpolationkey]||{},h=f.locale||f.lng||i.locale||i.lng||r;d=this.formats[u](a,h,{...c,...i,...f})}catch(f){this.logger.warn(f)}return d}else this.logger.warn(`there was no format function for ${u}`);return a},e)}}function Dv(t,e){t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)}class Ov extends Ca{constructor(e,n,r){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};super(),this.backend=e,this.store=n,this.services=r,this.languageUtils=r.languageUtils,this.options=i,this.logger=Qt.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=i.maxParallelReads||10,this.readingCalls=0,this.maxRetries=i.maxRetries>=0?i.maxRetries:5,this.retryTimeout=i.retryTimeout>=1?i.retryTimeout:350,this.state={},this.queue=[],this.backend&&this.backend.init&&this.backend.init(r,i.backend,i)}queueLoad(e,n,r,i){const s={},o={},a={},l={};return e.forEach(u=>{let c=!0;n.forEach(d=>{const f=`${u}|${d}`;!r.reload&&this.store.hasResourceBundle(u,d)?this.state[f]=2:this.state[f]<0||(this.state[f]===1?o[f]===void 0&&(o[f]=!0):(this.state[f]=1,c=!1,o[f]===void 0&&(o[f]=!0),s[f]===void 0&&(s[f]=!0),l[d]===void 0&&(l[d]=!0)))}),c||(a[u]=!0)}),(Object.keys(s).length||Object.keys(o).length)&&this.queue.push({pending:o,pendingCount:Object.keys(o).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(s),pending:Object.keys(o),toLoadLanguages:Object.keys(a),toLoadNamespaces:Object.keys(l)}}loaded(e,n,r){const i=e.split("|"),s=i[0],o=i[1];n&&this.emit("failedLoading",s,o,n),r&&this.store.addResourceBundle(s,o,r),this.state[e]=n?-1:2;const a={};this.queue.forEach(l=>{mv(l.loaded,[s],o),Dv(l,e),n&&l.errors.push(n),l.pendingCount===0&&!l.done&&(Object.keys(l.loaded).forEach(u=>{a[u]||(a[u]={});const c=l.loaded[u];c.length&&c.forEach(d=>{a[u][d]===void 0&&(a[u][d]=!0)})}),l.done=!0,l.errors.length?l.callback(l.errors):l.callback())}),this.emit("loaded",a),this.queue=this.queue.filter(l=>!l.done)}read(e,n,r){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:this.retryTimeout,o=arguments.length>5?arguments[5]:void 0;if(!e.length)return o(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:n,fcName:r,tried:i,wait:s,callback:o});return}this.readingCalls++;const a=(u,c)=>{if(this.readingCalls--,this.waitingReads.length>0){const d=this.waitingReads.shift();this.read(d.lng,d.ns,d.fcName,d.tried,d.wait,d.callback)}if(u&&c&&i{this.read.call(this,e,n,r,i+1,s*2,o)},s);return}o(u,c)},l=this.backend[r].bind(this.backend);if(l.length===2){try{const u=l(e,n);u&&typeof u.then=="function"?u.then(c=>a(null,c)).catch(a):a(null,u)}catch(u){a(u)}return}return l(e,n,a)}prepareLoading(e,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},i=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),i&&i();typeof e=="string"&&(e=this.languageUtils.toResolveHierarchy(e)),typeof n=="string"&&(n=[n]);const s=this.queueLoad(e,n,r,i);if(!s.toLoad.length)return s.pending.length||i(),null;s.toLoad.forEach(o=>{this.loadOne(o)})}load(e,n,r){this.prepareLoading(e,n,{},r)}reload(e,n,r){this.prepareLoading(e,n,{reload:!0},r)}loadOne(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";const r=e.split("|"),i=r[0],s=r[1];this.read(i,s,"read",void 0,void 0,(o,a)=>{o&&this.logger.warn(`${n}loading namespace ${s} for language ${i} failed`,o),!o&&a&&this.logger.log(`${n}loaded namespace ${s} for language ${i}`,a),this.loaded(e,o,a)})}saveMissing(e,n,r,i,s){let o=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{},a=arguments.length>6&&arguments[6]!==void 0?arguments[6]:()=>{};if(this.services.utils&&this.services.utils.hasLoadedNamespace&&!this.services.utils.hasLoadedNamespace(n)){this.logger.warn(`did not save key "${r}" as the namespace "${n}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(r==null||r==="")){if(this.backend&&this.backend.create){const l={...o,isUpdate:s},u=this.backend.create.bind(this.backend);if(u.length<6)try{let c;u.length===5?c=u(e,n,r,i,l):c=u(e,n,r,i),c&&typeof c.then=="function"?c.then(d=>a(null,d)).catch(a):a(null,c)}catch(c){a(c)}else u(e,n,r,i,a,l)}!e||!e[0]||this.store.addResource(e[0],n,r,i)}}}function Tf(){return{debug:!1,initImmediate:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:function(e){let n={};if(typeof e[1]=="object"&&(n=e[1]),typeof e[1]=="string"&&(n.defaultValue=e[1]),typeof e[2]=="string"&&(n.tDescription=e[2]),typeof e[2]=="object"||typeof e[3]=="object"){const r=e[3]||e[2];Object.keys(r).forEach(i=>{n[i]=r[i]})}return n},interpolation:{escapeValue:!0,format:(t,e,n,r)=>t,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}}}function Df(t){return typeof t.ns=="string"&&(t.ns=[t.ns]),typeof t.fallbackLng=="string"&&(t.fallbackLng=[t.fallbackLng]),typeof t.fallbackNS=="string"&&(t.fallbackNS=[t.fallbackNS]),t.supportedLngs&&t.supportedLngs.indexOf("cimode")<0&&(t.supportedLngs=t.supportedLngs.concat(["cimode"])),t}function Bs(){}function Nv(t){Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})}class Yi extends Ca{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;if(super(),this.options=Df(e),this.services={},this.logger=Qt,this.modules={external:[]},Nv(this),n&&!this.isInitialized&&!e.isClone){if(!this.options.initImmediate)return this.init(e,n),this;setTimeout(()=>{this.init(e,n)},0)}}init(){var e=this;let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;typeof n=="function"&&(r=n,n={}),!n.defaultNS&&n.defaultNS!==!1&&n.ns&&(typeof n.ns=="string"?n.defaultNS=n.ns:n.ns.indexOf("translation")<0&&(n.defaultNS=n.ns[0]));const i=Tf();this.options={...i,...this.options,...Df(n)},this.options.compatibilityAPI!=="v1"&&(this.options.interpolation={...i.interpolation,...this.options.interpolation}),n.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=n.keySeparator),n.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=n.nsSeparator);function s(c){return c?typeof c=="function"?new c:c:null}if(!this.options.isClone){this.modules.logger?Qt.init(s(this.modules.logger),this.options):Qt.init(null,this.options);let c;this.modules.formatter?c=this.modules.formatter:typeof Intl<"u"&&(c=Tv);const d=new Sf(this.options);this.store=new Cf(this.options.resources,this.options);const f=this.services;f.logger=Qt,f.resourceStore=this.store,f.languageUtils=d,f.pluralResolver=new Sv(d,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),c&&(!this.options.interpolation.format||this.options.interpolation.format===i.interpolation.format)&&(f.formatter=s(c),f.formatter.init(f,this.options),this.options.interpolation.format=f.formatter.format.bind(f.formatter)),f.interpolator=new Av(this.options),f.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},f.backendConnector=new Ov(s(this.modules.backend),f.resourceStore,f,this.options),f.backendConnector.on("*",function(h){for(var p=arguments.length,m=new Array(p>1?p-1:0),g=1;g1?p-1:0),g=1;g{h.init&&h.init(this)})}if(this.format=this.options.interpolation.format,r||(r=Bs),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const c=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);c.length>0&&c[0]!=="dev"&&(this.options.lng=c[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(c=>{this[c]=function(){return e.store[c](...arguments)}}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(c=>{this[c]=function(){return e.store[c](...arguments),e}});const l=Ei(),u=()=>{const c=(d,f)=>{this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),l.resolve(f),r(d,f)};if(this.languages&&this.options.compatibilityAPI!=="v1"&&!this.isInitialized)return c(null,this.t.bind(this));this.changeLanguage(this.options.lng,c)};return this.options.resources||!this.options.initImmediate?u():setTimeout(u,0),l}loadResources(e){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Bs;const i=typeof e=="string"?e:this.language;if(typeof e=="function"&&(r=e),!this.options.resources||this.options.partialBundledLanguages){if(i&&i.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return r();const s=[],o=a=>{if(!a||a==="cimode")return;this.services.languageUtils.toResolveHierarchy(a).forEach(u=>{u!=="cimode"&&s.indexOf(u)<0&&s.push(u)})};i?o(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(l=>o(l)),this.options.preload&&this.options.preload.forEach(a=>o(a)),this.services.backendConnector.load(s,this.options.ns,a=>{!a&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),r(a)})}else r(null)}reloadResources(e,n,r){const i=Ei();return e||(e=this.languages),n||(n=this.options.ns),r||(r=Bs),this.services.backendConnector.reload(e,n,s=>{i.resolve(),r(s)}),i}use(e){if(!e)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return e.type==="backend"&&(this.modules.backend=e),(e.type==="logger"||e.log&&e.warn&&e.error)&&(this.modules.logger=e),e.type==="languageDetector"&&(this.modules.languageDetector=e),e.type==="i18nFormat"&&(this.modules.i18nFormat=e),e.type==="postProcessor"&&M1.addPostProcessor(e),e.type==="formatter"&&(this.modules.formatter=e),e.type==="3rdParty"&&this.modules.external.push(e),this}setResolvedLanguage(e){if(!(!e||!this.languages)&&!(["cimode","dev"].indexOf(e)>-1))for(let n=0;n-1)&&this.store.hasLanguageSomeTranslations(r)){this.resolvedLanguage=r;break}}}changeLanguage(e,n){var r=this;this.isLanguageChangingTo=e;const i=Ei();this.emit("languageChanging",e);const s=l=>{this.language=l,this.languages=this.services.languageUtils.toResolveHierarchy(l),this.resolvedLanguage=void 0,this.setResolvedLanguage(l)},o=(l,u)=>{u?(s(u),this.translator.changeLanguage(u),this.isLanguageChangingTo=void 0,this.emit("languageChanged",u),this.logger.log("languageChanged",u)):this.isLanguageChangingTo=void 0,i.resolve(function(){return r.t(...arguments)}),n&&n(l,function(){return r.t(...arguments)})},a=l=>{!e&&!l&&this.services.languageDetector&&(l=[]);const u=typeof l=="string"?l:this.services.languageUtils.getBestMatchFromCodes(l);u&&(this.language||s(u),this.translator.language||this.translator.changeLanguage(u),this.services.languageDetector&&this.services.languageDetector.cacheUserLanguage&&this.services.languageDetector.cacheUserLanguage(u)),this.loadResources(u,c=>{o(c,u)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?a(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(a):this.services.languageDetector.detect(a):a(e),i}getFixedT(e,n,r){var i=this;const s=function(o,a){let l;if(typeof a!="object"){for(var u=arguments.length,c=new Array(u>2?u-2:0),d=2;d`${l.keyPrefix}${f}${p}`):h=l.keyPrefix?`${l.keyPrefix}${f}${o}`:o,i.t(h,l)};return typeof e=="string"?s.lng=e:s.lngs=e,s.ns=n,s.keyPrefix=r,s}t(){return this.translator&&this.translator.translate(...arguments)}exists(){return this.translator&&this.translator.exists(...arguments)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const r=n.lng||this.resolvedLanguage||this.languages[0],i=this.options?this.options.fallbackLng:!1,s=this.languages[this.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const o=(a,l)=>{const u=this.services.backendConnector.state[`${a}|${l}`];return u===-1||u===2};if(n.precheck){const a=n.precheck(this,o);if(a!==void 0)return a}return!!(this.hasResourceBundle(r,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||o(r,e)&&(!i||o(s,e)))}loadNamespaces(e,n){const r=Ei();return this.options.ns?(typeof e=="string"&&(e=[e]),e.forEach(i=>{this.options.ns.indexOf(i)<0&&this.options.ns.push(i)}),this.loadResources(i=>{r.resolve(),n&&n(i)}),r):(n&&n(),Promise.resolve())}loadLanguages(e,n){const r=Ei();typeof e=="string"&&(e=[e]);const i=this.options.preload||[],s=e.filter(o=>i.indexOf(o)<0);return s.length?(this.options.preload=i.concat(s),this.loadResources(o=>{r.resolve(),n&&n(o)}),r):(n&&n(),Promise.resolve())}dir(e){if(e||(e=this.resolvedLanguage||(this.languages&&this.languages.length>0?this.languages[0]:this.language)),!e)return"rtl";const n=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],r=this.services&&this.services.languageUtils||new Sf(Tf());return n.indexOf(r.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;return new Yi(e,n)}cloneInstance(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Bs;const r=e.forkResourceStore;r&&delete e.forkResourceStore;const i={...this.options,...e,isClone:!0},s=new Yi(i);return(e.debug!==void 0||e.prefix!==void 0)&&(s.logger=s.logger.clone(e)),["store","services","language"].forEach(a=>{s[a]=this[a]}),s.services={...this.services},s.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},r&&(s.store=new Cf(this.store.data,i),s.services.resourceStore=s.store),s.translator=new Lo(s.services,i),s.translator.on("*",function(a){for(var l=arguments.length,u=new Array(l>1?l-1:0),c=1;cre(e)),this.dropDivHeight="265px",this.dropDivWith="150px"}onDropdownActive(e,n){return n==0?e.isActive("paragraph"):e.isActive("heading",{level:n})}onDropdownItemClick(e){e==0?this.editor.chain().setParagraph().run():this.editor.chain().setHeading({level:e}).run()}onDropdownItemRender(e){return e==0?this.menuData[e]:`${this.menuData[e]}`}onMenuTextRender(e){return this.menuData[e].replace(" ","")}};const Iv=[{name:"宋体",value:"SimSun"},{name:"仿宋",value:"FangSong"},{name:"黑体",value:"SimHei"},{name:"楷体",value:"KaiTi"},{name:"微软雅黑",value:"Microsoft YaHei"},{name:"方正仿宋简体_GBK",value:"FangSong_GB2312"},{name:"Arial",value:"Arial"}];let Fv=class extends gi{constructor(){super(),this.width="72px",this.menuTextWidth="60px",this.dropDivWith="150px"}onCreate(e,n){var r;super.onCreate(e,n),this.menuData=((r=n.fontFamily)==null?void 0:r.values)||Iv,this.menuData=[{name:re("default-font-family"),value:""}].concat(this.menuData)}onDropdownActive(e,n){return e.isActive("textStyle",{fontFamily:this.menuData[n].value})}onDropdownItemClick(e){const n=this.menuData[e].value;n?this.editor.chain().setFontFamily(n).run():this.editor.chain().unsetFontFamily().run()}onDropdownItemRender(e){return this.menuData[e].name}onMenuTextRender(e){return this.menuData[e].name}};const Hv=[{name:"9",value:9},{name:"10",value:10},{name:"11",value:11},{name:"12",value:12},{name:"14",value:14},{name:"18",value:18},{name:"20",value:20},{name:"22",value:22},{name:"24",value:24},{name:"26",value:26},{name:"28",value:28},{name:"30",value:30},{name:"36",value:36},{name:"42",value:42},{name:"48",value:48},{name:"56",value:56},{name:"72",value:72}];class Bv extends gi{constructor(){super(),this.dropDivWith="134px"}onCreate(e,n){var r;super.onCreate(e,n),this.menuData=((r=n.fontSize)==null?void 0:r.values)||Hv;for(let i=0;i{this.onDropdownItemClick(r),this.tippyInstance.hide()}),this.showItemsTip){const s=this.menuData[r];Ke(i,{appendTo:()=>this.closest(".aie-container"),content:s.tip||s.title,theme:"aietip",arrow:!0,placement:"right"})}n.appendChild(i)}return this.tippyEl=n,n}onTransaction(n){var s,o;const r=(s=this.tippyEl)==null?void 0:s.querySelector(".red-dot");r&&r.classList.remove("red-dot");let i=this.defaultMenuIndex;for(let a=0;a1&&arguments[1]!==void 0?arguments[1]:{};this.init(e,n)}init(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.prefix=n.prefix||"i18next:",this.logger=e||fv,this.options=n,this.debug=n.debug}log(){for(var e=arguments.length,n=new Array(e),r=0;r{this.observers[r]=this.observers[r]||[],this.observers[r].push(n)}),this}off(e,n){if(this.observers[e]){if(!n){delete this.observers[e];return}this.observers[e]=this.observers[e].filter(r=>r!==n)}}emit(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i{o(...r)}),this.observers["*"]&&[].concat(this.observers["*"]).forEach(o=>{o.apply(o,[e,...r])})}}function Ei(){let t,e;const n=new Promise((r,i)=>{t=r,e=i});return n.resolve=t,n.reject=e,n}function _f(t){return t==null?"":""+t}function hv(t,e,n){t.forEach(r=>{e[r]&&(n[r]=e[r])})}function gc(t,e,n){function r(o){return o&&o.indexOf("###")>-1?o.replace(/###/g,"."):o}function i(){return!t||typeof t=="string"}const s=typeof e!="string"?[].concat(e):e.split(".");for(;s.length>1;){if(i())return{};const o=r(s.shift());!t[o]&&n&&(t[o]=new n),Object.prototype.hasOwnProperty.call(t,o)?t=t[o]:t={}}return i()?{}:{obj:t,k:r(s.shift())}}function Cf(t,e,n){const{obj:r,k:i}=gc(t,e,Object);r[i]=n}function pv(t,e,n,r){const{obj:i,k:s}=gc(t,e,Object);i[s]=i[s]||[],r&&(i[s]=i[s].concat(n)),r||i[s].push(n)}function Do(t,e){const{obj:n,k:r}=gc(t,e);if(n)return n[r]}function mv(t,e,n){const r=Do(t,n);return r!==void 0?r:Do(e,n)}function A1(t,e,n){for(const r in e)r!=="__proto__"&&r!=="constructor"&&(r in t?typeof t[r]=="string"||t[r]instanceof String||typeof e[r]=="string"||e[r]instanceof String?n&&(t[r]=e[r]):A1(t[r],e[r],n):t[r]=e[r]);return t}function Or(t){return t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}var gv={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};function bv(t){return typeof t=="string"?t.replace(/[&<>"'\/]/g,e=>gv[e]):t}const yv=[" ",",","?","!",";"];function xv(t,e,n){e=e||"",n=n||"";const r=yv.filter(o=>e.indexOf(o)<0&&n.indexOf(o)<0);if(r.length===0)return!0;const i=new RegExp(`(${r.map(o=>o==="?"?"\\?":o).join("|")})`);let s=!i.test(t);if(!s){const o=t.indexOf(n);o>0&&!i.test(t.substring(0,o))&&(s=!0)}return s}function Oo(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:".";if(!t)return;if(t[e])return t[e];const r=e.split(n);let i=t;for(let s=0;ss+o;)o++,a=r.slice(s,s+o).join(n),l=i[a];if(l===void 0)return;if(l===null)return null;if(e.endsWith(a)){if(typeof l=="string")return l;if(a&&typeof l[a]=="string")return l[a]}const u=r.slice(s+o).join(n);return u?Oo(l,u,n):void 0}i=i[r[s]]}return i}function No(t){return t&&t.indexOf("_")>0?t.replace("_","-"):t}class wf extends Ca{constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{ns:["translation"],defaultNS:"translation"};super(),this.data=e||{},this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}removeNamespaces(e){const n=this.options.ns.indexOf(e);n>-1&&this.options.ns.splice(n,1)}getResource(e,n,r){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const s=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,o=i.ignoreJSONStructure!==void 0?i.ignoreJSONStructure:this.options.ignoreJSONStructure;let a=[e,n];r&&typeof r!="string"&&(a=a.concat(r)),r&&typeof r=="string"&&(a=a.concat(s?r.split(s):r)),e.indexOf(".")>-1&&(a=e.split("."));const l=Do(this.data,a);return l||!o||typeof r!="string"?l:Oo(this.data&&this.data[e]&&this.data[e][n],r,s)}addResource(e,n,r,i){let s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{silent:!1};const o=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator;let a=[e,n];r&&(a=a.concat(o?r.split(o):r)),e.indexOf(".")>-1&&(a=e.split("."),i=n,n=a[1]),this.addNamespaces(n),Cf(this.data,a,i),s.silent||this.emit("added",e,n,r,i)}addResources(e,n,r){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{silent:!1};for(const s in r)(typeof r[s]=="string"||Object.prototype.toString.apply(r[s])==="[object Array]")&&this.addResource(e,n,s,r[s],{silent:!0});i.silent||this.emit("added",e,n,r)}addResourceBundle(e,n,r,i,s){let o=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{silent:!1},a=[e,n];e.indexOf(".")>-1&&(a=e.split("."),i=r,r=n,n=a[1]),this.addNamespaces(n);let l=Do(this.data,a)||{};i?A1(l,r,s):l={...l,...r},Cf(this.data,a,l),o.silent||this.emit("added",e,n,r)}removeResourceBundle(e,n){this.hasResourceBundle(e,n)&&delete this.data[e][n],this.removeNamespaces(n),this.emit("removed",e,n)}hasResourceBundle(e,n){return this.getResource(e,n)!==void 0}getResourceBundle(e,n){return n||(n=this.options.defaultNS),this.options.compatibilityAPI==="v1"?{...this.getResource(e,n)}:this.getResource(e,n)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){const n=this.getDataByLanguage(e);return!!(n&&Object.keys(n)||[]).find(i=>n[i]&&Object.keys(n[i]).length>0)}toJSON(){return this.data}}var M1={processors:{},addPostProcessor(t){this.processors[t.name]=t},handle(t,e,n,r,i){return t.forEach(s=>{this.processors[s]&&(e=this.processors[s].process(e,n,r,i))}),e}};const Sf={};class Lo extends Ca{constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),hv(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=Qt.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}};if(e==null)return!1;const r=this.resolve(e,n);return r&&r.res!==void 0}extractFromKey(e,n){let r=n.nsSeparator!==void 0?n.nsSeparator:this.options.nsSeparator;r===void 0&&(r=":");const i=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let s=n.ns||this.options.defaultNS||[];const o=r&&e.indexOf(r)>-1,a=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!xv(e,r,i);if(o&&!a){const l=e.match(this.interpolator.nestingRegexp);if(l&&l.length>0)return{key:e,namespaces:s};const u=e.split(r);(r!==i||r===i&&this.options.ns.indexOf(u[0])>-1)&&(s=u.shift()),e=u.join(i)}return typeof s=="string"&&(s=[s]),{key:e,namespaces:s}}translate(e,n,r){if(typeof n!="object"&&this.options.overloadTranslationOptionHandler&&(n=this.options.overloadTranslationOptionHandler(arguments)),typeof n=="object"&&(n={...n}),n||(n={}),e==null)return"";Array.isArray(e)||(e=[String(e)]);const i=n.returnDetails!==void 0?n.returnDetails:this.options.returnDetails,s=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator,{key:o,namespaces:a}=this.extractFromKey(e[e.length-1],n),l=a[a.length-1],u=n.lng||this.language,c=n.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(u&&u.toLowerCase()==="cimode"){if(c){const b=n.nsSeparator||this.options.nsSeparator;return i?{res:`${l}${b}${o}`,usedKey:o,exactUsedKey:o,usedLng:u,usedNS:l,usedParams:this.getUsedParamsDetails(n)}:`${l}${b}${o}`}return i?{res:o,usedKey:o,exactUsedKey:o,usedLng:u,usedNS:l,usedParams:this.getUsedParamsDetails(n)}:o}const d=this.resolve(e,n);let f=d&&d.res;const h=d&&d.usedKey||o,p=d&&d.exactUsedKey||o,m=Object.prototype.toString.apply(f),g=["[object Number]","[object Function]","[object RegExp]"],y=n.joinArrays!==void 0?n.joinArrays:this.options.joinArrays,x=!this.i18nFormat||this.i18nFormat.handleAsObject;if(x&&f&&(typeof f!="string"&&typeof f!="boolean"&&typeof f!="number")&&g.indexOf(m)<0&&!(typeof y=="string"&&m==="[object Array]")){if(!n.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const b=this.options.returnedObjectHandler?this.options.returnedObjectHandler(h,f,{...n,ns:a}):`key '${o} (${this.language})' returned an object instead of string.`;return i?(d.res=b,d.usedParams=this.getUsedParamsDetails(n),d):b}if(s){const b=m==="[object Array]",E=b?[]:{},v=b?p:h;for(const C in f)if(Object.prototype.hasOwnProperty.call(f,C)){const T=`${v}${s}${C}`;E[C]=this.translate(T,{...n,joinArrays:!1,ns:a}),E[C]===T&&(E[C]=f[C])}f=E}}else if(x&&typeof y=="string"&&m==="[object Array]")f=f.join(y),f&&(f=this.extendTranslation(f,e,n,r));else{let b=!1,E=!1;const v=n.count!==void 0&&typeof n.count!="string",C=Lo.hasDefaultValue(n),T=v?this.pluralResolver.getSuffix(u,n.count,n):"",w=n.ordinal&&v?this.pluralResolver.getSuffix(u,n.count,{ordinal:!1}):"",N=n[`defaultValue${T}`]||n[`defaultValue${w}`]||n.defaultValue;!this.isValidLookup(f)&&C&&(b=!0,f=N),this.isValidLookup(f)||(E=!0,f=o);const K=(n.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&E?void 0:f,U=C&&N!==f&&this.options.updateMissing;if(E||b||U){if(this.logger.log(U?"updateKey":"missingKey",u,l,o,U?N:f),s){const _=this.resolve(o,{...n,keySeparator:!1});_&&_.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let W=[];const z=this.languageUtils.getFallbackCodes(this.options.fallbackLng,n.lng||this.language);if(this.options.saveMissingTo==="fallback"&&z&&z[0])for(let _=0;_{const F=C&&L!==f?L:K;this.options.missingKeyHandler?this.options.missingKeyHandler(_,l,S,F,U,n):this.backendConnector&&this.backendConnector.saveMissing&&this.backendConnector.saveMissing(_,l,S,F,U,n),this.emit("missingKey",_,l,S,f)};this.options.saveMissing&&(this.options.saveMissingPlurals&&v?W.forEach(_=>{this.pluralResolver.getSuffixes(_,n).forEach(S=>{A([_],o+S,n[`defaultValue${S}`]||N)})}):A(W,o,N))}f=this.extendTranslation(f,e,n,d,r),E&&f===o&&this.options.appendNamespaceToMissingKey&&(f=`${l}:${o}`),(E||b)&&this.options.parseMissingKeyHandler&&(this.options.compatibilityAPI!=="v1"?f=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${l}:${o}`:o,b?f:void 0):f=this.options.parseMissingKeyHandler(f))}return i?(d.res=f,d.usedParams=this.getUsedParamsDetails(n),d):f}extendTranslation(e,n,r,i,s){var o=this;if(this.i18nFormat&&this.i18nFormat.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init({...r,interpolation:{...this.options.interpolation,...r.interpolation}});const u=typeof e=="string"&&(r&&r.interpolation&&r.interpolation.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let c;if(u){const f=e.match(this.interpolator.nestingRegexp);c=f&&f.length}let d=r.replace&&typeof r.replace!="string"?r.replace:r;if(this.options.interpolation.defaultVariables&&(d={...this.options.interpolation.defaultVariables,...d}),e=this.interpolator.interpolate(e,d,r.lng||this.language,r),u){const f=e.match(this.interpolator.nestingRegexp),h=f&&f.length;c1&&arguments[1]!==void 0?arguments[1]:{},r,i,s,o,a;return typeof e=="string"&&(e=[e]),e.forEach(l=>{if(this.isValidLookup(r))return;const u=this.extractFromKey(l,n),c=u.key;i=c;let d=u.namespaces;this.options.fallbackNS&&(d=d.concat(this.options.fallbackNS));const f=n.count!==void 0&&typeof n.count!="string",h=f&&!n.ordinal&&n.count===0&&this.pluralResolver.shouldUseIntlApi(),p=n.context!==void 0&&(typeof n.context=="string"||typeof n.context=="number")&&n.context!=="",m=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);d.forEach(g=>{this.isValidLookup(r)||(a=g,!Sf[`${m[0]}-${g}`]&&this.utils&&this.utils.hasLoadedNamespace&&!this.utils.hasLoadedNamespace(a)&&(Sf[`${m[0]}-${g}`]=!0,this.logger.warn(`key "${i}" for languages "${m.join(", ")}" won't get resolved as namespace "${a}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),m.forEach(y=>{if(this.isValidLookup(r))return;o=y;const x=[c];if(this.i18nFormat&&this.i18nFormat.addLookupKeys)this.i18nFormat.addLookupKeys(x,c,y,g,n);else{let b;f&&(b=this.pluralResolver.getSuffix(y,n.count,n));const E=`${this.options.pluralSeparator}zero`,v=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(f&&(x.push(c+b),n.ordinal&&b.indexOf(v)===0&&x.push(c+b.replace(v,this.options.pluralSeparator)),h&&x.push(c+E)),p){const C=`${c}${this.options.contextSeparator}${n.context}`;x.push(C),f&&(x.push(C+b),n.ordinal&&b.indexOf(v)===0&&x.push(C+b.replace(v,this.options.pluralSeparator)),h&&x.push(C+E))}}let k;for(;k=x.pop();)this.isValidLookup(r)||(s=k,r=this.getResource(y,g,k,n))}))})}),{res:r,usedKey:i,exactUsedKey:s,usedLng:o,usedNS:a}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e==="")}getResource(e,n,r){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return this.i18nFormat&&this.i18nFormat.getResource?this.i18nFormat.getResource(e,n,r,i):this.resourceStore.getResource(e,n,r,i)}getUsedParamsDetails(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const n=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],r=e.replace&&typeof e.replace!="string";let i=r?e.replace:e;if(r&&typeof e.count<"u"&&(i.count=e.count),this.options.interpolation.defaultVariables&&(i={...this.options.interpolation.defaultVariables,...i}),!r){i={...i};for(const s of n)delete i[s]}return i}static hasDefaultValue(e){const n="defaultValue";for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&n===r.substring(0,n.length)&&e[r]!==void 0)return!0;return!1}}function yl(t){return t.charAt(0).toUpperCase()+t.slice(1)}class Af{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Qt.create("languageUtils")}getScriptPartFromCode(e){if(e=No(e),!e||e.indexOf("-")<0)return null;const n=e.split("-");return n.length===2||(n.pop(),n[n.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(n.join("-"))}getLanguagePartFromCode(e){if(e=No(e),!e||e.indexOf("-")<0)return e;const n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(typeof e=="string"&&e.indexOf("-")>-1){const n=["hans","hant","latn","cyrl","cans","mong","arab"];let r=e.split("-");return this.options.lowerCaseLng?r=r.map(i=>i.toLowerCase()):r.length===2?(r[0]=r[0].toLowerCase(),r[1]=r[1].toUpperCase(),n.indexOf(r[1].toLowerCase())>-1&&(r[1]=yl(r[1].toLowerCase()))):r.length===3&&(r[0]=r[0].toLowerCase(),r[1].length===2&&(r[1]=r[1].toUpperCase()),r[0]!=="sgn"&&r[2].length===2&&(r[2]=r[2].toUpperCase()),n.indexOf(r[1].toLowerCase())>-1&&(r[1]=yl(r[1].toLowerCase())),n.indexOf(r[2].toLowerCase())>-1&&(r[2]=yl(r[2].toLowerCase()))),r.join("-")}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}getBestMatchFromCodes(e){if(!e)return null;let n;return e.forEach(r=>{if(n)return;const i=this.formatLanguageCode(r);(!this.options.supportedLngs||this.isSupportedCode(i))&&(n=i)}),!n&&this.options.supportedLngs&&e.forEach(r=>{if(n)return;const i=this.getLanguagePartFromCode(r);if(this.isSupportedCode(i))return n=i;n=this.options.supportedLngs.find(s=>{if(s===i)return s;if(!(s.indexOf("-")<0&&i.indexOf("-")<0)&&s.indexOf(i)===0)return s})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n}getFallbackCodes(e,n){if(!e)return[];if(typeof e=="function"&&(e=e(n)),typeof e=="string"&&(e=[e]),Object.prototype.toString.apply(e)==="[object Array]")return e;if(!n)return e.default||[];let r=e[n];return r||(r=e[this.getScriptPartFromCode(n)]),r||(r=e[this.formatLanguageCode(n)]),r||(r=e[this.getLanguagePartFromCode(n)]),r||(r=e.default),r||[]}toResolveHierarchy(e,n){const r=this.getFallbackCodes(n||this.options.fallbackLng||[],e),i=[],s=o=>{o&&(this.isSupportedCode(o)?i.push(o):this.logger.warn(`rejecting language code not found in supportedLngs: ${o}`))};return typeof e=="string"&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&s(this.formatLanguageCode(e)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&s(this.getScriptPartFromCode(e)),this.options.load!=="currentOnly"&&s(this.getLanguagePartFromCode(e))):typeof e=="string"&&s(this.formatLanguageCode(e)),r.forEach(o=>{i.indexOf(o)<0&&s(this.formatLanguageCode(o))}),i}}let kv=[{lngs:["ach","ak","am","arn","br","fil","gun","ln","mfe","mg","mi","oc","pt","pt-BR","tg","tl","ti","tr","uz","wa"],nr:[1,2],fc:1},{lngs:["af","an","ast","az","bg","bn","ca","da","de","dev","el","en","eo","es","et","eu","fi","fo","fur","fy","gl","gu","ha","hi","hu","hy","ia","it","kk","kn","ku","lb","mai","ml","mn","mr","nah","nap","nb","ne","nl","nn","no","nso","pa","pap","pms","ps","pt-PT","rm","sco","se","si","so","son","sq","sv","sw","ta","te","tk","ur","yo"],nr:[1,2],fc:2},{lngs:["ay","bo","cgg","fa","ht","id","ja","jbo","ka","km","ko","ky","lo","ms","sah","su","th","tt","ug","vi","wo","zh"],nr:[1],fc:3},{lngs:["be","bs","cnr","dz","hr","ru","sr","uk"],nr:[1,2,5],fc:4},{lngs:["ar"],nr:[0,1,2,3,11,100],fc:5},{lngs:["cs","sk"],nr:[1,2,5],fc:6},{lngs:["csb","pl"],nr:[1,2,5],fc:7},{lngs:["cy"],nr:[1,2,3,8],fc:8},{lngs:["fr"],nr:[1,2],fc:9},{lngs:["ga"],nr:[1,2,3,7,11],fc:10},{lngs:["gd"],nr:[1,2,3,20],fc:11},{lngs:["is"],nr:[1,2],fc:12},{lngs:["jv"],nr:[0,1],fc:13},{lngs:["kw"],nr:[1,2,3,4],fc:14},{lngs:["lt"],nr:[1,2,10],fc:15},{lngs:["lv"],nr:[1,2,0],fc:16},{lngs:["mk"],nr:[1,2],fc:17},{lngs:["mnk"],nr:[0,1,2],fc:18},{lngs:["mt"],nr:[1,2,11,20],fc:19},{lngs:["or"],nr:[2,1],fc:2},{lngs:["ro"],nr:[1,2,20],fc:20},{lngs:["sl"],nr:[5,1,2,3],fc:21},{lngs:["he","iw"],nr:[1,2,20,21],fc:22}],vv={1:function(t){return+(t>1)},2:function(t){return+(t!=1)},3:function(t){return 0},4:function(t){return t%10==1&&t%100!=11?0:t%10>=2&&t%10<=4&&(t%100<10||t%100>=20)?1:2},5:function(t){return t==0?0:t==1?1:t==2?2:t%100>=3&&t%100<=10?3:t%100>=11?4:5},6:function(t){return t==1?0:t>=2&&t<=4?1:2},7:function(t){return t==1?0:t%10>=2&&t%10<=4&&(t%100<10||t%100>=20)?1:2},8:function(t){return t==1?0:t==2?1:t!=8&&t!=11?2:3},9:function(t){return+(t>=2)},10:function(t){return t==1?0:t==2?1:t<7?2:t<11?3:4},11:function(t){return t==1||t==11?0:t==2||t==12?1:t>2&&t<20?2:3},12:function(t){return+(t%10!=1||t%100==11)},13:function(t){return+(t!==0)},14:function(t){return t==1?0:t==2?1:t==3?2:3},15:function(t){return t%10==1&&t%100!=11?0:t%10>=2&&(t%100<10||t%100>=20)?1:2},16:function(t){return t%10==1&&t%100!=11?0:t!==0?1:2},17:function(t){return t==1||t%10==1&&t%100!=11?0:1},18:function(t){return t==0?0:t==1?1:2},19:function(t){return t==1?0:t==0||t%100>1&&t%100<11?1:t%100>10&&t%100<20?2:3},20:function(t){return t==1?0:t==0||t%100>0&&t%100<20?1:2},21:function(t){return t%100==1?1:t%100==2?2:t%100==3||t%100==4?3:0},22:function(t){return t==1?0:t==2?1:(t<0||t>10)&&t%10==0?2:3}};const Ev=["v1","v2","v3"],_v=["v4"],Mf={zero:0,one:1,two:2,few:3,many:4,other:5};function Cv(){const t={};return kv.forEach(e=>{e.lngs.forEach(n=>{t[n]={numbers:e.nr,plurals:vv[e.fc]}})}),t}class wv{constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.languageUtils=e,this.options=n,this.logger=Qt.create("pluralResolver"),(!this.options.compatibilityJSON||_v.includes(this.options.compatibilityJSON))&&(typeof Intl>"u"||!Intl.PluralRules)&&(this.options.compatibilityJSON="v3",this.logger.error("Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill. Will fallback to the compatibilityJSON v3 format handling.")),this.rules=Cv()}addRule(e,n){this.rules[e]=n}getRule(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this.shouldUseIntlApi())try{return new Intl.PluralRules(No(e),{type:n.ordinal?"ordinal":"cardinal"})}catch{return}return this.rules[e]||this.rules[this.languageUtils.getLanguagePartFromCode(e)]}needsPlural(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const r=this.getRule(e,n);return this.shouldUseIntlApi()?r&&r.resolvedOptions().pluralCategories.length>1:r&&r.numbers.length>1}getPluralFormsOfKey(e,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return this.getSuffixes(e,r).map(i=>`${n}${i}`)}getSuffixes(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const r=this.getRule(e,n);return r?this.shouldUseIntlApi()?r.resolvedOptions().pluralCategories.sort((i,s)=>Mf[i]-Mf[s]).map(i=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${i}`):r.numbers.map(i=>this.getSuffix(e,i,n)):[]}getSuffix(e,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const i=this.getRule(e,r);return i?this.shouldUseIntlApi()?`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${i.select(n)}`:this.getSuffixRetroCompatible(i,n):(this.logger.warn(`no plural rule found for: ${e}`),"")}getSuffixRetroCompatible(e,n){const r=e.noAbs?e.plurals(n):e.plurals(Math.abs(n));let i=e.numbers[r];this.options.simplifyPluralSuffix&&e.numbers.length===2&&e.numbers[0]===1&&(i===2?i="plural":i===1&&(i=""));const s=()=>this.options.prepend&&i.toString()?this.options.prepend+i.toString():i.toString();return this.options.compatibilityJSON==="v1"?i===1?"":typeof i=="number"?`_plural_${i.toString()}`:s():this.options.compatibilityJSON==="v2"||this.options.simplifyPluralSuffix&&e.numbers.length===2&&e.numbers[0]===1?s():this.options.prepend&&r.toString()?this.options.prepend+r.toString():r.toString()}shouldUseIntlApi(){return!Ev.includes(this.options.compatibilityJSON)}}function Tf(t,e,n){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:".",i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,s=mv(t,e,n);return!s&&i&&typeof n=="string"&&(s=Oo(t,n,r),s===void 0&&(s=Oo(e,n,r))),s}class Sv{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=Qt.create("interpolator"),this.options=e,this.format=e.interpolation&&e.interpolation.format||(n=>n),this.init(e)}init(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};e.interpolation||(e.interpolation={escapeValue:!0});const n=e.interpolation;this.escape=n.escape!==void 0?n.escape:bv,this.escapeValue=n.escapeValue!==void 0?n.escapeValue:!0,this.useRawValueToEscape=n.useRawValueToEscape!==void 0?n.useRawValueToEscape:!1,this.prefix=n.prefix?Or(n.prefix):n.prefixEscaped||"{{",this.suffix=n.suffix?Or(n.suffix):n.suffixEscaped||"}}",this.formatSeparator=n.formatSeparator?n.formatSeparator:n.formatSeparator||",",this.unescapePrefix=n.unescapeSuffix?"":n.unescapePrefix||"-",this.unescapeSuffix=this.unescapePrefix?"":n.unescapeSuffix||"",this.nestingPrefix=n.nestingPrefix?Or(n.nestingPrefix):n.nestingPrefixEscaped||Or("$t("),this.nestingSuffix=n.nestingSuffix?Or(n.nestingSuffix):n.nestingSuffixEscaped||Or(")"),this.nestingOptionsSeparator=n.nestingOptionsSeparator?n.nestingOptionsSeparator:n.nestingOptionsSeparator||",",this.maxReplaces=n.maxReplaces?n.maxReplaces:1e3,this.alwaysFormat=n.alwaysFormat!==void 0?n.alwaysFormat:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=`${this.prefix}(.+?)${this.suffix}`;this.regexp=new RegExp(e,"g");const n=`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`;this.regexpUnescape=new RegExp(n,"g");const r=`${this.nestingPrefix}(.+?)${this.nestingSuffix}`;this.nestingRegexp=new RegExp(r,"g")}interpolate(e,n,r,i){let s,o,a;const l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{};function u(p){return p.replace(/\$/g,"$$$$")}const c=p=>{if(p.indexOf(this.formatSeparator)<0){const x=Tf(n,l,p,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(x,void 0,r,{...i,...n,interpolationkey:p}):x}const m=p.split(this.formatSeparator),g=m.shift().trim(),y=m.join(this.formatSeparator).trim();return this.format(Tf(n,l,g,this.options.keySeparator,this.options.ignoreJSONStructure),y,r,{...i,...n,interpolationkey:g})};this.resetRegExp();const d=i&&i.missingInterpolationHandler||this.options.missingInterpolationHandler,f=i&&i.interpolation&&i.interpolation.skipOnVariables!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:p=>u(p)},{regex:this.regexp,safeValue:p=>this.escapeValue?u(this.escape(p)):u(p)}].forEach(p=>{for(a=0;s=p.regex.exec(e);){const m=s[1].trim();if(o=c(m),o===void 0)if(typeof d=="function"){const y=d(e,s,i);o=typeof y=="string"?y:""}else if(i&&Object.prototype.hasOwnProperty.call(i,m))o="";else if(f){o=s[0];continue}else this.logger.warn(`missed to pass in variable ${m} for interpolating ${e}`),o="";else typeof o!="string"&&!this.useRawValueToEscape&&(o=_f(o));const g=p.safeValue(o);if(e=e.replace(s[0],g),f?(p.regex.lastIndex+=o.length,p.regex.lastIndex-=s[0].length):p.regex.lastIndex=0,a++,a>=this.maxReplaces)break}}),e}nest(e,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},i,s,o;function a(l,u){const c=this.nestingOptionsSeparator;if(l.indexOf(c)<0)return l;const d=l.split(new RegExp(`${c}[ ]*{`));let f=`{${d[1]}`;l=d[0],f=this.interpolate(f,o);const h=f.match(/'/g),p=f.match(/"/g);(h&&h.length%2===0&&!p||p.length%2!==0)&&(f=f.replace(/'/g,'"'));try{o=JSON.parse(f),u&&(o={...u,...o})}catch(m){return this.logger.warn(`failed parsing options string in nesting for key ${l}`,m),`${l}${c}${f}`}return delete o.defaultValue,l}for(;i=this.nestingRegexp.exec(e);){let l=[];o={...r},o=o.replace&&typeof o.replace!="string"?o.replace:o,o.applyPostProcessor=!1,delete o.defaultValue;let u=!1;if(i[0].indexOf(this.formatSeparator)!==-1&&!/{.*}/.test(i[1])){const c=i[1].split(this.formatSeparator).map(d=>d.trim());i[1]=c.shift(),l=c,u=!0}if(s=n(a.call(this,i[1].trim(),o),o),s&&i[0]===e&&typeof s!="string")return s;typeof s!="string"&&(s=_f(s)),s||(this.logger.warn(`missed to resolve ${i[1]} for nesting ${e}`),s=""),u&&(s=l.reduce((c,d)=>this.format(c,d,r.lng,{...r,interpolationkey:i[1].trim()}),s.trim())),e=e.replace(i[0],s),this.regexp.lastIndex=0}return e}}function Av(t){let e=t.toLowerCase().trim();const n={};if(t.indexOf("(")>-1){const r=t.split("(");e=r[0].toLowerCase().trim();const i=r[1].substring(0,r[1].length-1);e==="currency"&&i.indexOf(":")<0?n.currency||(n.currency=i.trim()):e==="relativetime"&&i.indexOf(":")<0?n.range||(n.range=i.trim()):i.split(";").forEach(o=>{if(!o)return;const[a,...l]=o.split(":"),u=l.join(":").trim().replace(/^'+|'+$/g,"");n[a.trim()]||(n[a.trim()]=u),u==="false"&&(n[a.trim()]=!1),u==="true"&&(n[a.trim()]=!0),isNaN(u)||(n[a.trim()]=parseInt(u,10))})}return{formatName:e,formatOptions:n}}function Nr(t){const e={};return function(r,i,s){const o=i+JSON.stringify(s);let a=e[o];return a||(a=t(No(i),s),e[o]=a),a(r)}}class Mv{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=Qt.create("formatter"),this.options=e,this.formats={number:Nr((n,r)=>{const i=new Intl.NumberFormat(n,{...r});return s=>i.format(s)}),currency:Nr((n,r)=>{const i=new Intl.NumberFormat(n,{...r,style:"currency"});return s=>i.format(s)}),datetime:Nr((n,r)=>{const i=new Intl.DateTimeFormat(n,{...r});return s=>i.format(s)}),relativetime:Nr((n,r)=>{const i=new Intl.RelativeTimeFormat(n,{...r});return s=>i.format(s,r.range||"day")}),list:Nr((n,r)=>{const i=new Intl.ListFormat(n,{...r});return s=>i.format(s)})},this.init(e)}init(e){const r=(arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}}).interpolation;this.formatSeparator=r.formatSeparator?r.formatSeparator:r.formatSeparator||","}add(e,n){this.formats[e.toLowerCase().trim()]=n}addCached(e,n){this.formats[e.toLowerCase().trim()]=Nr(n)}format(e,n,r){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return n.split(this.formatSeparator).reduce((a,l)=>{const{formatName:u,formatOptions:c}=Av(l);if(this.formats[u]){let d=a;try{const f=i&&i.formatParams&&i.formatParams[i.interpolationkey]||{},h=f.locale||f.lng||i.locale||i.lng||r;d=this.formats[u](a,h,{...c,...i,...f})}catch(f){this.logger.warn(f)}return d}else this.logger.warn(`there was no format function for ${u}`);return a},e)}}function Tv(t,e){t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)}class Dv extends Ca{constructor(e,n,r){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};super(),this.backend=e,this.store=n,this.services=r,this.languageUtils=r.languageUtils,this.options=i,this.logger=Qt.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=i.maxParallelReads||10,this.readingCalls=0,this.maxRetries=i.maxRetries>=0?i.maxRetries:5,this.retryTimeout=i.retryTimeout>=1?i.retryTimeout:350,this.state={},this.queue=[],this.backend&&this.backend.init&&this.backend.init(r,i.backend,i)}queueLoad(e,n,r,i){const s={},o={},a={},l={};return e.forEach(u=>{let c=!0;n.forEach(d=>{const f=`${u}|${d}`;!r.reload&&this.store.hasResourceBundle(u,d)?this.state[f]=2:this.state[f]<0||(this.state[f]===1?o[f]===void 0&&(o[f]=!0):(this.state[f]=1,c=!1,o[f]===void 0&&(o[f]=!0),s[f]===void 0&&(s[f]=!0),l[d]===void 0&&(l[d]=!0)))}),c||(a[u]=!0)}),(Object.keys(s).length||Object.keys(o).length)&&this.queue.push({pending:o,pendingCount:Object.keys(o).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(s),pending:Object.keys(o),toLoadLanguages:Object.keys(a),toLoadNamespaces:Object.keys(l)}}loaded(e,n,r){const i=e.split("|"),s=i[0],o=i[1];n&&this.emit("failedLoading",s,o,n),r&&this.store.addResourceBundle(s,o,r),this.state[e]=n?-1:2;const a={};this.queue.forEach(l=>{pv(l.loaded,[s],o),Tv(l,e),n&&l.errors.push(n),l.pendingCount===0&&!l.done&&(Object.keys(l.loaded).forEach(u=>{a[u]||(a[u]={});const c=l.loaded[u];c.length&&c.forEach(d=>{a[u][d]===void 0&&(a[u][d]=!0)})}),l.done=!0,l.errors.length?l.callback(l.errors):l.callback())}),this.emit("loaded",a),this.queue=this.queue.filter(l=>!l.done)}read(e,n,r){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:this.retryTimeout,o=arguments.length>5?arguments[5]:void 0;if(!e.length)return o(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:n,fcName:r,tried:i,wait:s,callback:o});return}this.readingCalls++;const a=(u,c)=>{if(this.readingCalls--,this.waitingReads.length>0){const d=this.waitingReads.shift();this.read(d.lng,d.ns,d.fcName,d.tried,d.wait,d.callback)}if(u&&c&&i{this.read.call(this,e,n,r,i+1,s*2,o)},s);return}o(u,c)},l=this.backend[r].bind(this.backend);if(l.length===2){try{const u=l(e,n);u&&typeof u.then=="function"?u.then(c=>a(null,c)).catch(a):a(null,u)}catch(u){a(u)}return}return l(e,n,a)}prepareLoading(e,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},i=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),i&&i();typeof e=="string"&&(e=this.languageUtils.toResolveHierarchy(e)),typeof n=="string"&&(n=[n]);const s=this.queueLoad(e,n,r,i);if(!s.toLoad.length)return s.pending.length||i(),null;s.toLoad.forEach(o=>{this.loadOne(o)})}load(e,n,r){this.prepareLoading(e,n,{},r)}reload(e,n,r){this.prepareLoading(e,n,{reload:!0},r)}loadOne(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";const r=e.split("|"),i=r[0],s=r[1];this.read(i,s,"read",void 0,void 0,(o,a)=>{o&&this.logger.warn(`${n}loading namespace ${s} for language ${i} failed`,o),!o&&a&&this.logger.log(`${n}loaded namespace ${s} for language ${i}`,a),this.loaded(e,o,a)})}saveMissing(e,n,r,i,s){let o=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{},a=arguments.length>6&&arguments[6]!==void 0?arguments[6]:()=>{};if(this.services.utils&&this.services.utils.hasLoadedNamespace&&!this.services.utils.hasLoadedNamespace(n)){this.logger.warn(`did not save key "${r}" as the namespace "${n}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(r==null||r==="")){if(this.backend&&this.backend.create){const l={...o,isUpdate:s},u=this.backend.create.bind(this.backend);if(u.length<6)try{let c;u.length===5?c=u(e,n,r,i,l):c=u(e,n,r,i),c&&typeof c.then=="function"?c.then(d=>a(null,d)).catch(a):a(null,c)}catch(c){a(c)}else u(e,n,r,i,a,l)}!e||!e[0]||this.store.addResource(e[0],n,r,i)}}}function Df(){return{debug:!1,initImmediate:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:function(e){let n={};if(typeof e[1]=="object"&&(n=e[1]),typeof e[1]=="string"&&(n.defaultValue=e[1]),typeof e[2]=="string"&&(n.tDescription=e[2]),typeof e[2]=="object"||typeof e[3]=="object"){const r=e[3]||e[2];Object.keys(r).forEach(i=>{n[i]=r[i]})}return n},interpolation:{escapeValue:!0,format:(t,e,n,r)=>t,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}}}function Of(t){return typeof t.ns=="string"&&(t.ns=[t.ns]),typeof t.fallbackLng=="string"&&(t.fallbackLng=[t.fallbackLng]),typeof t.fallbackNS=="string"&&(t.fallbackNS=[t.fallbackNS]),t.supportedLngs&&t.supportedLngs.indexOf("cimode")<0&&(t.supportedLngs=t.supportedLngs.concat(["cimode"])),t}function Bs(){}function Ov(t){Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})}class Yi extends Ca{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;if(super(),this.options=Of(e),this.services={},this.logger=Qt,this.modules={external:[]},Ov(this),n&&!this.isInitialized&&!e.isClone){if(!this.options.initImmediate)return this.init(e,n),this;setTimeout(()=>{this.init(e,n)},0)}}init(){var e=this;let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;typeof n=="function"&&(r=n,n={}),!n.defaultNS&&n.defaultNS!==!1&&n.ns&&(typeof n.ns=="string"?n.defaultNS=n.ns:n.ns.indexOf("translation")<0&&(n.defaultNS=n.ns[0]));const i=Df();this.options={...i,...this.options,...Of(n)},this.options.compatibilityAPI!=="v1"&&(this.options.interpolation={...i.interpolation,...this.options.interpolation}),n.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=n.keySeparator),n.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=n.nsSeparator);function s(c){return c?typeof c=="function"?new c:c:null}if(!this.options.isClone){this.modules.logger?Qt.init(s(this.modules.logger),this.options):Qt.init(null,this.options);let c;this.modules.formatter?c=this.modules.formatter:typeof Intl<"u"&&(c=Mv);const d=new Af(this.options);this.store=new wf(this.options.resources,this.options);const f=this.services;f.logger=Qt,f.resourceStore=this.store,f.languageUtils=d,f.pluralResolver=new wv(d,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),c&&(!this.options.interpolation.format||this.options.interpolation.format===i.interpolation.format)&&(f.formatter=s(c),f.formatter.init(f,this.options),this.options.interpolation.format=f.formatter.format.bind(f.formatter)),f.interpolator=new Sv(this.options),f.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},f.backendConnector=new Dv(s(this.modules.backend),f.resourceStore,f,this.options),f.backendConnector.on("*",function(h){for(var p=arguments.length,m=new Array(p>1?p-1:0),g=1;g1?p-1:0),g=1;g{h.init&&h.init(this)})}if(this.format=this.options.interpolation.format,r||(r=Bs),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const c=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);c.length>0&&c[0]!=="dev"&&(this.options.lng=c[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(c=>{this[c]=function(){return e.store[c](...arguments)}}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(c=>{this[c]=function(){return e.store[c](...arguments),e}});const l=Ei(),u=()=>{const c=(d,f)=>{this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),l.resolve(f),r(d,f)};if(this.languages&&this.options.compatibilityAPI!=="v1"&&!this.isInitialized)return c(null,this.t.bind(this));this.changeLanguage(this.options.lng,c)};return this.options.resources||!this.options.initImmediate?u():setTimeout(u,0),l}loadResources(e){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Bs;const i=typeof e=="string"?e:this.language;if(typeof e=="function"&&(r=e),!this.options.resources||this.options.partialBundledLanguages){if(i&&i.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return r();const s=[],o=a=>{if(!a||a==="cimode")return;this.services.languageUtils.toResolveHierarchy(a).forEach(u=>{u!=="cimode"&&s.indexOf(u)<0&&s.push(u)})};i?o(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(l=>o(l)),this.options.preload&&this.options.preload.forEach(a=>o(a)),this.services.backendConnector.load(s,this.options.ns,a=>{!a&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),r(a)})}else r(null)}reloadResources(e,n,r){const i=Ei();return e||(e=this.languages),n||(n=this.options.ns),r||(r=Bs),this.services.backendConnector.reload(e,n,s=>{i.resolve(),r(s)}),i}use(e){if(!e)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return e.type==="backend"&&(this.modules.backend=e),(e.type==="logger"||e.log&&e.warn&&e.error)&&(this.modules.logger=e),e.type==="languageDetector"&&(this.modules.languageDetector=e),e.type==="i18nFormat"&&(this.modules.i18nFormat=e),e.type==="postProcessor"&&M1.addPostProcessor(e),e.type==="formatter"&&(this.modules.formatter=e),e.type==="3rdParty"&&this.modules.external.push(e),this}setResolvedLanguage(e){if(!(!e||!this.languages)&&!(["cimode","dev"].indexOf(e)>-1))for(let n=0;n-1)&&this.store.hasLanguageSomeTranslations(r)){this.resolvedLanguage=r;break}}}changeLanguage(e,n){var r=this;this.isLanguageChangingTo=e;const i=Ei();this.emit("languageChanging",e);const s=l=>{this.language=l,this.languages=this.services.languageUtils.toResolveHierarchy(l),this.resolvedLanguage=void 0,this.setResolvedLanguage(l)},o=(l,u)=>{u?(s(u),this.translator.changeLanguage(u),this.isLanguageChangingTo=void 0,this.emit("languageChanged",u),this.logger.log("languageChanged",u)):this.isLanguageChangingTo=void 0,i.resolve(function(){return r.t(...arguments)}),n&&n(l,function(){return r.t(...arguments)})},a=l=>{!e&&!l&&this.services.languageDetector&&(l=[]);const u=typeof l=="string"?l:this.services.languageUtils.getBestMatchFromCodes(l);u&&(this.language||s(u),this.translator.language||this.translator.changeLanguage(u),this.services.languageDetector&&this.services.languageDetector.cacheUserLanguage&&this.services.languageDetector.cacheUserLanguage(u)),this.loadResources(u,c=>{o(c,u)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?a(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(a):this.services.languageDetector.detect(a):a(e),i}getFixedT(e,n,r){var i=this;const s=function(o,a){let l;if(typeof a!="object"){for(var u=arguments.length,c=new Array(u>2?u-2:0),d=2;d`${l.keyPrefix}${f}${p}`):h=l.keyPrefix?`${l.keyPrefix}${f}${o}`:o,i.t(h,l)};return typeof e=="string"?s.lng=e:s.lngs=e,s.ns=n,s.keyPrefix=r,s}t(){return this.translator&&this.translator.translate(...arguments)}exists(){return this.translator&&this.translator.exists(...arguments)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const r=n.lng||this.resolvedLanguage||this.languages[0],i=this.options?this.options.fallbackLng:!1,s=this.languages[this.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const o=(a,l)=>{const u=this.services.backendConnector.state[`${a}|${l}`];return u===-1||u===2};if(n.precheck){const a=n.precheck(this,o);if(a!==void 0)return a}return!!(this.hasResourceBundle(r,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||o(r,e)&&(!i||o(s,e)))}loadNamespaces(e,n){const r=Ei();return this.options.ns?(typeof e=="string"&&(e=[e]),e.forEach(i=>{this.options.ns.indexOf(i)<0&&this.options.ns.push(i)}),this.loadResources(i=>{r.resolve(),n&&n(i)}),r):(n&&n(),Promise.resolve())}loadLanguages(e,n){const r=Ei();typeof e=="string"&&(e=[e]);const i=this.options.preload||[],s=e.filter(o=>i.indexOf(o)<0);return s.length?(this.options.preload=i.concat(s),this.loadResources(o=>{r.resolve(),n&&n(o)}),r):(n&&n(),Promise.resolve())}dir(e){if(e||(e=this.resolvedLanguage||(this.languages&&this.languages.length>0?this.languages[0]:this.language)),!e)return"rtl";const n=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],r=this.services&&this.services.languageUtils||new Af(Df());return n.indexOf(r.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;return new Yi(e,n)}cloneInstance(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Bs;const r=e.forkResourceStore;r&&delete e.forkResourceStore;const i={...this.options,...e,isClone:!0},s=new Yi(i);return(e.debug!==void 0||e.prefix!==void 0)&&(s.logger=s.logger.clone(e)),["store","services","language"].forEach(a=>{s[a]=this[a]}),s.services={...this.services},s.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},r&&(s.store=new wf(this.store.data,i),s.services.resourceStore=s.store),s.translator=new Lo(s.services,i),s.translator.on("*",function(a){for(var l=arguments.length,u=new Array(l>1?l-1:0),c=1;cre(e)),this.dropDivHeight="265px",this.dropDivWith="150px"}onDropdownActive(e,n){return n==0?e.isActive("paragraph"):e.isActive("heading",{level:n})}onDropdownItemClick(e){e==0?this.editor.chain().setParagraph().run():this.editor.chain().setHeading({level:e}).run()}onDropdownItemRender(e){return e==0?this.menuData[e]:`${this.menuData[e]}`}onMenuTextRender(e){return this.menuData[e].replace(" ","")}};const Rv=[{name:"宋体",value:"SimSun"},{name:"仿宋",value:"FangSong"},{name:"黑体",value:"SimHei"},{name:"楷体",value:"KaiTi"},{name:"微软雅黑",value:"Microsoft YaHei"},{name:"方正仿宋简体_GBK",value:"FangSong_GB2312"},{name:"Arial",value:"Arial"}];let Iv=class extends gi{constructor(){super(),this.width="72px",this.menuTextWidth="60px",this.dropDivWith="150px"}onCreate(e,n){var r;super.onCreate(e,n),this.menuData=((r=n.fontFamily)==null?void 0:r.values)||Rv,this.menuData=[{name:re("default-font-family"),value:""}].concat(this.menuData)}onDropdownActive(e,n){return e.isActive("textStyle",{fontFamily:this.menuData[n].value})}onDropdownItemClick(e){const n=this.menuData[e].value;n?this.editor.chain().setFontFamily(n).run():this.editor.chain().unsetFontFamily().run()}onDropdownItemRender(e){return this.menuData[e].name}onMenuTextRender(e){return this.menuData[e].name}};const Fv=[{name:"9",value:9},{name:"10",value:10},{name:"11",value:11},{name:"12",value:12},{name:"14",value:14},{name:"18",value:18},{name:"20",value:20},{name:"22",value:22},{name:"24",value:24},{name:"26",value:26},{name:"28",value:28},{name:"30",value:30},{name:"36",value:36},{name:"42",value:42},{name:"48",value:48},{name:"56",value:56},{name:"72",value:72}];class Hv extends gi{constructor(){super(),this.dropDivWith="134px"}onCreate(e,n){var r;super.onCreate(e,n),this.menuData=((r=n.fontSize)==null?void 0:r.values)||Fv;for(let i=0;i
- `;this.template=e,this.registerClickListener()}onClick(e){e.toggleBold()}onActive(e){return e.isActive("bold")}},$v=class extends ge{constructor(){super();const e=` + `,this.registerClickListener()}onClick(e){e.toggleBold()}onActive(e){return e.isActive("bold")}},Pv=class extends me{constructor(){super(),this.template=`
- `;this.template=e,this.registerClickListener()}onClick(e){e.toggleItalic()}onActive(e){return e.isActive("italic")}},zv=class extends ge{constructor(){super();const e=` + `,this.registerClickListener()}onClick(e){e.toggleItalic()}onActive(e){return e.isActive("italic")}},$v=class extends me{constructor(){super(),this.template=`
- `;this.template=e,this.registerClickListener()}onClick(e){e.toggleUnderline()}onActive(e){return e.isActive("underline")}},Vv=class extends ge{constructor(){super();const e=` + `,this.registerClickListener()}onClick(e){e.toggleUnderline()}onActive(e){return e.isActive("underline")}},zv=class extends me{constructor(){super(),this.template=`
- `;this.template=e,this.registerClickListener()}onClick(e){e.toggleStrike()}onActive(e){return e.isActive("strike")}},Uv=class extends ge{constructor(){super();const e=` + `,this.registerClickListener()}onClick(e){e.toggleStrike()}onActive(e){return e.isActive("strike")}},Vv=class extends me{constructor(){super(),this.template=`
- `;this.template=e,this.registerClickListener()}onClick(e){e.toggleSubscript()}onActive(e){return e.isActive("subscript")}},qv=class extends ge{constructor(){super();const e=` + `,this.registerClickListener()}onClick(e){e.toggleSubscript()}onActive(e){return e.isActive("subscript")}},Uv=class extends me{constructor(){super(),this.template=`
- `;this.template=e,this.registerClickListener()}onClick(e){e.toggleSuperscript()}onActive(e){return e.isActive("superscript")}};const Zv=["ffffff","000000","e9d989","2972f4","609eec","de3c36","a1d533","7334c5","27b5d9","ff8926","f2f2f2","7f7f7f","ddd9c3","c6d9f0","dbe5f1","f2dcdb","ebf1dd","e5e0ec","dbeef3","fdeada","d8d8d8","595959","c4bd97","8db3e2","b8cce4","e5b9b7","d7e3bc","ccc1d9","b7dde8","fbd5b5","bfbfbf","3f3f3f","938953","548dd4","95b3d7","d99694","c3d69b","b2a2c7","92cddc","fac08f","a5a5a5","262626","494429","17365d","366092","953734","76923c","5f497a","31859b","e36c09","6e6e6e","0c0c0c","1d1b10","0f243e","244061","632423","4f6128","3f3151","205867","974806"],Kv=["c00000","ff0000","ffc000","ffff00","92d050","00b050","00b0f0","0070c0","002060","7030a0"];class T1 extends ge{constructor(){super();B(this,"historyColorsKey","historyColors");B(this,"historyColors",[]);B(this,"iconSvg");B(this,"menuColorEL");B(this,"onColorItemClick");B(this,"onDefaultColorClick")}connectedCallback(){this.template=` + `,this.registerClickListener()}onClick(e){e.toggleSuperscript()}onActive(e){return e.isActive("superscript")}};const qv=["ffffff","000000","e9d989","2972f4","609eec","de3c36","a1d533","7334c5","27b5d9","ff8926","f2f2f2","7f7f7f","ddd9c3","c6d9f0","dbe5f1","f2dcdb","ebf1dd","e5e0ec","dbeef3","fdeada","d8d8d8","595959","c4bd97","8db3e2","b8cce4","e5b9b7","d7e3bc","ccc1d9","b7dde8","fbd5b5","bfbfbf","3f3f3f","938953","548dd4","95b3d7","d99694","c3d69b","b2a2c7","92cddc","fac08f","a5a5a5","262626","494429","17365d","366092","953734","76923c","5f497a","31859b","e36c09","6e6e6e","0c0c0c","1d1b10","0f243e","244061","632423","4f6128","3f3151","205867","974806"],Zv=["c00000","ff0000","ffc000","ffff00","92d050","00b050","00b0f0","0070c0","002060","7030a0"];class T1 extends me{constructor(){super();H(this,"historyColorsKey","historyColors");H(this,"historyColors",[]);H(this,"iconSvg");H(this,"menuColorEL");H(this,"onColorItemClick");H(this,"onDefaultColorClick")}connectedCallback(){this.template=`
${this.iconSvg}
@@ -165,11 +165,11 @@ img.ProseMirror-separator {
${re("default")}
- ${Zv.map((r,i)=>`
`).join(" ")} + ${qv.map((r,i)=>`
`).join(" ")}
${re("standardColors")}
- ${Kv.map(r=>`
`).join(" ")} + ${Zv.map(r=>`
`).join(" ")}
${re("historyColors")}
@@ -178,27 +178,27 @@ img.ProseMirror-separator {
`,n.querySelector("#defaultColor").addEventListener("click",()=>{this.onDefaultColorClick()}),n.querySelectorAll(".color-item").forEach(r=>{r.addEventListener("click",()=>{this.invokeColorItemClick(n,r)}),r.addEventListener("mouseover",()=>{r.style.border="solid 1px #999"}),r.addEventListener("mouseout",()=>{let i=r.getAttribute("data-color");i==="#ffffff"&&(i="#efefef"),r.style.border=`solid 1px ${i}`})}),n.querySelector("#history-colors").addEventListener("click",r=>{const i=r.target.closest(".history-color-item");i&&this.invokeColorItemClick(n,i)}),n}invokeColorItemClick(n,r){const i=r.getAttribute("data-color");this.historyColors=this.historyColors.filter(s=>s!==i),this.historyColors.unshift(i),this.historyColors.length>7&&(this.historyColors=this.historyColors.slice(0,7)),n.querySelector("#history-colors").innerHTML=` ${this.historyColors.map(s=>`
`).join(" ")} - `,localStorage.setItem(this.historyColorsKey,JSON.stringify(this.historyColors)),this.menuColorEL.style.background=i,this.onColorItemClick(i)}}let Wv=class extends T1{constructor(){super(),this.historyColorsKey="highlightHistoryColors",this.iconSvg='',this.onDefaultColorClick=()=>{var e;(e=this.editor)==null||e.chain().focus().unsetHighlight().run()},this.onColorItemClick=e=>{var n;(n=this.editor)==null||n.chain().focus().setHighlight({color:e}).run()}}onActive(e){return e.isActive("highlight")}};class jv extends T1{constructor(){super(),this.historyColorsKey="fontHistoryColors",this.iconSvg='',this.onDefaultColorClick=()=>{var e;(e=this.editor)==null||e.chain().focus().unsetColor().run()},this.onColorItemClick=e=>{var n;(n=this.editor)==null||n.chain().focus().setColor(e).run()}}onActive(e){return e.isActive("textStyle")}}class Gv extends ge{constructor(){super();const e=` + `,localStorage.setItem(this.historyColorsKey,JSON.stringify(this.historyColors)),this.menuColorEL.style.background=i,this.onColorItemClick(i)}}let Kv=class extends T1{constructor(){super(),this.historyColorsKey="highlightHistoryColors",this.iconSvg='',this.onDefaultColorClick=()=>{var e;(e=this.editor)==null||e.chain().focus().unsetHighlight().run()},this.onColorItemClick=e=>{var n;(n=this.editor)==null||n.chain().focus().setHighlight({color:e}).run()}}onActive(e){return e.isActive("highlight")}};class Wv extends T1{constructor(){super(),this.historyColorsKey="fontHistoryColors",this.iconSvg='',this.onDefaultColorClick=()=>{var e;(e=this.editor)==null||e.chain().focus().unsetColor().run()},this.onColorItemClick=e=>{var n;(n=this.editor)==null||n.chain().focus().setColor(e).run()}}onActive(e){return e.isActive("textStyle")}}class jv extends me{constructor(){super(),this.template=`
- `;this.template=e}}let Jv=class extends ge{constructor(){super();const e=` + `}}let Gv=class extends me{constructor(){super(),this.template=`
- `;this.template=e,this.registerClickListener()}onClick(e){e.toggleBulletList()}onActive(e){return e.isActive("bulletList")}},Yv=class extends ge{constructor(){super();const e=` + `,this.registerClickListener()}onClick(e){e.toggleBulletList()}onActive(e){return e.isActive("bulletList")}},Jv=class extends me{constructor(){super(),this.template=`
- `;this.template=e,this.registerClickListener()}onClick(e){e.toggleOrderedList()}onActive(e){return e.isActive("orderedList")}};class Xv extends ge{constructor(){super();const e=` + `,this.registerClickListener()}onClick(e){e.toggleOrderedList()}onActive(e){return e.isActive("orderedList")}};class Yv extends me{constructor(){super(),this.template=`
- `;this.template=e,this.registerClickListener()}onClick(e){e.outdent()}}class Qv extends ge{constructor(){super();const e=` + `,this.registerClickListener()}onClick(e){e.outdent()}}class Xv extends me{constructor(){super(),this.template=`
- `;this.template=e,this.registerClickListener()}onClick(e){e.indent()}}const eE=[{icon:'
',title:"align-left",value:"left"},{icon:'
',title:"align-center",value:"center"},{icon:'
',title:"align-right",value:"right"},{icon:'
',title:"align-justify",value:"justify"}];class tE extends gi{constructor(){super(),this.menuData=eE.map(e=>({...e,title:re(e.title)})),this.dropDivHeight="112px",this.dropDivWith="60px",this.width="36px",this.menuTextWidth="20px",this.showItemsTip=!0}onDropdownActive(e,n){return e.isActive({textAlign:this.menuData[n].value})}onDropdownItemClick(e){this.editor.chain().focus().setTextAlign(this.menuData[e].value).run()}onDropdownItemRender(e){return this.menuData[e].icon}onMenuTextRender(e){return this.menuData[e].icon}}class D1{constructor(){B(this,"tippyInstance");B(this,"content");B(this,"onConfirmClickFunc");B(this,"onShowFunc")}setContent(e){this.content=e}onConfirmClick(e){this.onConfirmClickFunc=e}onShow(e){this.onShowFunc=e}setTrigger(e,n="bottom"){this.tippyInstance=Ke(e,{content:this.createContentElement(),appendTo:e.closest(".aie-container"),placement:n,trigger:"click",interactive:!0,arrow:!1,onShow:r=>{this.onShowFunc&&this.onShowFunc(r)}})}createContentElement(){const e=` + `,this.registerClickListener()}onClick(e){e.indent()}}const Qv=[{icon:'
',title:"align-left",value:"left"},{icon:'
',title:"align-center",value:"center"},{icon:'
',title:"align-right",value:"right"},{icon:'
',title:"align-justify",value:"justify"}];class eE extends gi{constructor(){super(),this.menuData=Qv.map(e=>({...e,title:re(e.title)})),this.dropDivHeight="112px",this.dropDivWith="60px",this.width="36px",this.menuTextWidth="20px",this.showItemsTip=!0}onDropdownActive(e,n){return e.isActive({textAlign:this.menuData[n].value})}onDropdownItemClick(e){this.editor.chain().focus().setTextAlign(this.menuData[e].value).run()}onDropdownItemRender(e){return this.menuData[e].icon}onMenuTextRender(e){return this.menuData[e].icon}}class bc{constructor(){H(this,"tippyInstance");H(this,"content");H(this,"onConfirmClickFunc");H(this,"onShowFunc")}setContent(e){this.content=e}onConfirmClick(e){this.onConfirmClickFunc=e}onShow(e){this.onShowFunc=e}setTrigger(e,n="bottom"){this.tippyInstance=Ke(e,{content:this.createContentElement(),appendTo:e.closest(".aie-container"),placement:n,trigger:"click",interactive:!0,arrow:!1,onShow:r=>{this.onShowFunc&&this.onShowFunc(r)}})}createContentElement(){const e=`
@@ -208,11 +208,11 @@ img.ProseMirror-separator {
- `,n=document.createElement("div");return n.innerHTML=e,n.querySelector(".aie-popover-header-close").addEventListener("click",()=>{this.tippyInstance.hide()}),n.querySelector(".aie-popover-footer-confirm").addEventListener("click",()=>{this.onConfirmClickFunc&&this.onConfirmClickFunc(this.tippyInstance),this.tippyInstance.hide()}),n}}let nE=class extends ge{constructor(){super();const e=` + `,n=document.createElement("div");return n.innerHTML=e,n.querySelector(".aie-popover-header-close").addEventListener("click",()=>{this.tippyInstance.hide()}),n.querySelector(".aie-popover-footer-confirm").addEventListener("click",()=>{this.onConfirmClickFunc&&this.onConfirmClickFunc(this.tippyInstance),this.tippyInstance.hide()}),n}}let tE=class extends me{constructor(){super(),this.template=`
- `;this.template=e}connectedCallback(){super.connectedCallback();const e=new D1;e.setContent(` + `}connectedCallback(){super.connectedCallback();const e=new bc;e.setContent(`
${re("link-address")}
@@ -225,94 +225,102 @@ img.ProseMirror-separator {
- `),e.onConfirmClick(n=>{var s,o;const r=n.popper.querySelector("#href").value;if(r.trim()===""){(s=this.editor)==null||s.chain().focus().extendMarkRange("link").unsetLink().run();return}let i=n.popper.querySelector("#target").value;i.trim()===""&&(i=null),(o=this.editor)==null||o.chain().focus().extendMarkRange("link").setLink({href:r,target:i,rel:null}).run()}),e.onShow(n=>{var i;const r=(i=this.editor)==null?void 0:i.getAttributes("link");r&&r.href?n.popper.querySelector("#href").value=r.href:n.popper.querySelector("#href").value="",r&&r.target?n.popper.querySelector("#target").value=r.target:n.popper.querySelector("#target").value=""}),e.setTrigger(this.querySelector("div"),"bottom")}onActive(e){return e.isActive("link")}};class rE extends ge{constructor(){super();const e=` + `),e.onConfirmClick(n=>{var s,o;const r=n.popper.querySelector("#href").value;if(r.trim()===""){(s=this.editor)==null||s.chain().focus().extendMarkRange("link").unsetLink().run();return}let i=n.popper.querySelector("#target").value;i.trim()===""&&(i=null),(o=this.editor)==null||o.chain().focus().extendMarkRange("link").setLink({href:r,target:i,rel:null}).run()}),e.onShow(n=>{var i;const r=(i=this.editor)==null?void 0:i.getAttributes("link");r&&r.href?n.popper.querySelector("#href").value=r.href:n.popper.querySelector("#href").value="",r&&r.target?n.popper.querySelector("#target").value=r.target:n.popper.querySelector("#target").value=""}),e.setTrigger(this.querySelector("div"),"bottom")}onActive(e){return e.isActive("link")}};class nE extends me{constructor(){super(),this.template=` +
+ +
+ `}connectedCallback(){super.connectedCallback();const e=new bc;e.setContent(` +
+ +
+ `),e.onConfirmClick(n=>{var i;const r=n.popper.querySelector("#source-code");(i=this.editor)==null||i.commands.setContent(r.value)}),e.onShow(n=>{var r;n.popper.querySelector("#source-code").value=((r=this.editor)==null?void 0:r.getHTML())||""}),e.setTrigger(this.querySelector("div"),"bottom")}}class rE extends me{constructor(){super(),this.template=`
- `;this.template=e,this.registerClickListener()}onClick(e){e.toggleTaskList()}onActive(e){return e.isActive("taskList")}}const iE=["1.0","1.25","1.5","2.0","2.5","3.0"];class sE extends gi{constructor(){super(),this.menuData=iE,this.refreshMenuText=!1,this.dropDivHeight="180px",this.dropDivWith="70px",this.width="36px",this.menuTextWidth="20px"}onDropdownActive(e,n){return n==0?e.isActive("paragraph"):e.isActive("heading",{level:n})}onDropdownItemClick(e){const n=`${(Number(this.menuData[e])*100).toFixed(0)}%`;this.editor.chain().setLineHeight(n).run()}onDropdownItemRender(e){return this.menuData[e]}onMenuTextRender(e){return` + `,this.registerClickListener()}onClick(e){e.toggleTaskList()}onActive(e){return e.isActive("taskList")}}const iE=["1.0","1.25","1.5","2.0","2.5","3.0"];class sE extends gi{constructor(){super(),this.menuData=iE,this.refreshMenuText=!1,this.dropDivHeight="180px",this.dropDivWith="70px",this.width="36px",this.menuTextWidth="20px"}onDropdownActive(e,n){return n==0?e.isActive("paragraph"):e.isActive("heading",{level:n})}onDropdownItemClick(e){const n=`${(Number(this.menuData[e])*100).toFixed(0)}%`;this.editor.chain().setLineHeight(n).run()}onDropdownItemRender(e){return this.menuData[e]}onMenuTextRender(e){return`
- `}}class oE extends ge{constructor(){super();const e=` + `}}class oE extends me{constructor(){super(),this.template=`
- `;this.template=e,this.registerClickListener()}onClick(e){e.toggleBlockquote()}onActive(e){return e.isActive("blockquote")}}let aE=class extends ge{constructor(){super();B(this,"fileInput");const n=` + `,this.registerClickListener()}onClick(e){e.toggleBlockquote()}onActive(e){return e.isActive("blockquote")}}let aE=class extends me{constructor(){super();H(this,"fileInput");this.template=`
- `;this.template=n,this.registerClickListener()}connectedCallback(){var n,r;super.connectedCallback(),(r=(n=this.options)==null?void 0:n.image)!=null&&r.customMenuInvoke?this.querySelector("input").remove():(this.fileInput=this.querySelector("input"),this.fileInput.addEventListener("change",()=>{var s,o;const i=(s=this.fileInput)==null?void 0:s.files;if(i&&i.length>0)for(let a of i)(o=this.editor)==null||o.commands.uploadImage(a);this.fileInput.value=""}))}onClick(n){var r,i,s;(i=(r=this.options)==null?void 0:r.image)!=null&&i.customMenuInvoke?this.options.image.customMenuInvoke(this.editor.aiEditor):(s=this.fileInput)==null||s.click()}};class lE extends ge{constructor(){super();B(this,"fileInput");const n=` + `,this.registerClickListener()}connectedCallback(){var n,r;super.connectedCallback(),(r=(n=this.options)==null?void 0:n.image)!=null&&r.customMenuInvoke?this.querySelector("input").remove():(this.fileInput=this.querySelector("input"),this.fileInput.addEventListener("change",()=>{var s,o;const i=(s=this.fileInput)==null?void 0:s.files;if(i&&i.length>0)for(let a of i)(o=this.editor)==null||o.commands.uploadImage(a);this.fileInput.value=""}))}onClick(n){var r,i,s;(i=(r=this.options)==null?void 0:r.image)!=null&&i.customMenuInvoke?this.options.image.customMenuInvoke(this.editor.aiEditor):(s=this.fileInput)==null||s.click()}};class lE extends me{constructor(){super();H(this,"fileInput");this.template=`
- `;this.template=n,this.registerClickListener()}connectedCallback(){var n,r;super.connectedCallback(),(r=(n=this.options)==null?void 0:n.video)!=null&&r.customMenuInvoke?this.querySelector("input").remove():(this.fileInput=this.querySelector("input"),this.fileInput.addEventListener("change",()=>{var s,o;const i=(s=this.fileInput)==null?void 0:s.files;if(i&&i.length>0)for(let a of i)(o=this.editor)==null||o.commands.uploadVideo(a);this.fileInput.value=""}))}onClick(n){var r,i,s;(i=(r=this.options)==null?void 0:r.video)!=null&&i.customMenuInvoke?this.options.video.customMenuInvoke(this.editor.aiEditor):(s=this.fileInput)==null||s.click()}}let uE=class extends ge{constructor(){super();const e=` + `,this.registerClickListener()}connectedCallback(){var n,r;super.connectedCallback(),(r=(n=this.options)==null?void 0:n.video)!=null&&r.customMenuInvoke?this.querySelector("input").remove():(this.fileInput=this.querySelector("input"),this.fileInput.addEventListener("change",()=>{var s,o;const i=(s=this.fileInput)==null?void 0:s.files;if(i&&i.length>0)for(let a of i)(o=this.editor)==null||o.commands.uploadVideo(a);this.fileInput.value=""}))}onClick(n){var r,i,s;(i=(r=this.options)==null?void 0:r.video)!=null&&i.customMenuInvoke?this.options.video.customMenuInvoke(this.editor.aiEditor):(s=this.fileInput)==null||s.click()}}let uE=class extends me{constructor(){super(),this.template=`
- `;this.template=e,this.registerClickListener()}onClick(e){e.toggleCode()}onActive(e){return e.isActive("code")}},cE=class extends ge{constructor(){super();const e=` + `,this.registerClickListener()}onClick(e){e.toggleCode()}onActive(e){return e.isActive("code")}},cE=class extends me{constructor(){super(),this.template=`
- +
- `;this.template=e,this.registerClickListener()}onClick(e){e.toggleCodeBlock()}onActive(e){return e.isActive("codeBlock")}};class dE extends ge{constructor(){super();const e=` + `,this.registerClickListener()}onClick(e){e.toggleCodeBlock()}onActive(e){return e.isActive("codeBlock")}};class dE extends me{constructor(){super(),this.template=`
- `;this.template=e,this.registerClickListener()}onClick(e){e.unsetAllMarks()}}class fE extends ge{constructor(){super();const e=` + `,this.registerClickListener()}onClick(e){e.unsetAllMarks()}}class fE extends me{constructor(){super(),this.template=`
- `;this.template=e,this.registerClickListener()}onClick(e){e.setHorizontalRule()}}let hE=class extends ge{constructor(){super();B(this,"instance");const n=` + `,this.registerClickListener()}onClick(e){e.setHorizontalRule()}}let hE=class extends me{constructor(){super();H(this,"instance");this.template=`
- `;this.template=n}connectedCallback(){super.connectedCallback(),this.instance=Ke(this.querySelector("svg"),{content:this.createMenuElement(),appendTo:this.closest(".aie-container"),placement:"bottom",trigger:"click",interactive:!0,arrow:!1})}createMenuElement(){const n=document.createElement("div");n.classList.add("aie-dropdown-container"),n.innerHTML=` + `}connectedCallback(){super.connectedCallback(),this.instance=Ke(this.querySelector("svg"),{content:this.createMenuElement(),appendTo:this.closest(".aie-container"),placement:"bottom",trigger:"click",interactive:!0,arrow:!1})}createMenuElement(){const n=document.createElement("div");n.classList.add("aie-dropdown-container"),n.innerHTML=`
${re("insertTable")}
${[...Array(8).keys()].map((i,s)=>[...Array(10).keys()].map((o,a)=>`
`).join("")).join("")}
- `;const r=n.querySelector("#table-cells");return r.addEventListener("click",i=>{var o,a;const s=i.target.closest(".table-cell");if(s){let l=s.getAttribute("data-i"),u=s.getAttribute("data-j");(o=this.editor)==null||o.commands.insertTable({rows:Number(l)+1,cols:Number(u)+1,withHeaderRow:!0}),(a=this.instance)==null||a.hide()}}),r.addEventListener("mouseover",i=>{const s=i.target.closest(".table-cell");if(s){let o=Number(s.getAttribute("data-i")),a=Number(s.getAttribute("data-j"));const l=r.querySelectorAll("div"),u=n.querySelector("#columnRows");u.textContent=`${o+1} ${re("row")} x ${a+1} ${re("column")}`,l.forEach(c=>{let d=Number(c.getAttribute("data-i")),f=Number(c.getAttribute("data-j"));d<=o&&f<=a?c.classList.add("active"):c.classList.remove("active")})}}),r.addEventListener("mouseleave",()=>{r.querySelectorAll("div").forEach(o=>{o.classList.remove("active")});const s=n.querySelector("#columnRows");s.textContent=""}),n}};class pE extends ge{constructor(){super();const e=` + `;const r=n.querySelector("#table-cells");return r.addEventListener("click",i=>{var o,a;const s=i.target.closest(".table-cell");if(s){let l=s.getAttribute("data-i"),u=s.getAttribute("data-j");(o=this.editor)==null||o.commands.insertTable({rows:Number(l)+1,cols:Number(u)+1,withHeaderRow:!0}),(a=this.instance)==null||a.hide()}}),r.addEventListener("mouseover",i=>{const s=i.target.closest(".table-cell");if(s){let o=Number(s.getAttribute("data-i")),a=Number(s.getAttribute("data-j"));const l=r.querySelectorAll("div"),u=n.querySelector("#columnRows");u.textContent=`${o+1} ${re("row")} x ${a+1} ${re("column")}`,l.forEach(c=>{let d=Number(c.getAttribute("data-i")),f=Number(c.getAttribute("data-j"));d<=o&&f<=a?c.classList.add("active"):c.classList.remove("active")})}}),r.addEventListener("mouseleave",()=>{r.querySelectorAll("div").forEach(o=>{o.classList.remove("active")});const s=n.querySelector("#columnRows");s.textContent=""}),n}};class pE extends me{constructor(){super(),this.template=`
- `;this.template=e,this.registerClickListener()}onClick(e){e.setHardBreak()}}class mE extends ge{constructor(){super();B(this,"fileInput");const n=` + `,this.registerClickListener()}onClick(e){e.setHardBreak()}}class mE extends me{constructor(){super();H(this,"fileInput");this.template=`
- `;this.template=n,this.registerClickListener()}connectedCallback(){var n,r;super.connectedCallback(),(r=(n=this.options)==null?void 0:n.attachment)!=null&&r.customMenuInvoke?this.querySelector("input").remove():(this.fileInput=this.querySelector("input"),this.fileInput.addEventListener("change",()=>{var s,o;const i=(s=this.fileInput)==null?void 0:s.files;if(i&&i.length>0)for(let a of i)(o=this.editor)==null||o.commands.uploadAttachment(a);this.fileInput.value=""}))}onClick(n){var r,i,s;(i=(r=this.options)==null?void 0:r.attachment)!=null&&i.customMenuInvoke?this.options.attachment.customMenuInvoke(this.editor.aiEditor):(s=this.fileInput)==null||s.click()}}class gE extends ge{constructor(){super();B(this,"fullscreenSvg",'');B(this,"fullscreenExitSvg",'');B(this,"isFullscreen",!1);const n=` + `,this.registerClickListener()}connectedCallback(){var n,r;super.connectedCallback(),(r=(n=this.options)==null?void 0:n.attachment)!=null&&r.customMenuInvoke?this.querySelector("input").remove():(this.fileInput=this.querySelector("input"),this.fileInput.addEventListener("change",()=>{var s,o;const i=(s=this.fileInput)==null?void 0:s.files;if(i&&i.length>0)for(let a of i)(o=this.editor)==null||o.commands.uploadAttachment(a);this.fileInput.value=""}))}onClick(n){var r,i,s;(i=(r=this.options)==null?void 0:r.attachment)!=null&&i.customMenuInvoke?this.options.attachment.customMenuInvoke(this.editor.aiEditor):(s=this.fileInput)==null||s.click()}}class gE extends me{constructor(){super();H(this,"fullscreenSvg",'');H(this,"fullscreenExitSvg",'');H(this,"isFullscreen",!1);this.template=`
${this.fullscreenSvg}
- `;this.template=n,this.registerClickListener()}onClick(n){const r=this.closest(".aie-container");this.isFullscreen?(r.style.height="100%",r.style.width="",r.style.background="",r.style.position="",r.style.top="",r.style.left="",r.style.zIndex=""):(r.style.height="calc(100vh - 2px)",r.style.width="calc(100% - 2px)",r.style.position="fixed",r.style.top="0",r.style.left="0",r.style.zIndex="9999"),this.isFullscreen=!this.isFullscreen,this.querySelector("div").innerHTML=this.isFullscreen?this.fullscreenExitSvg:this.fullscreenSvg}}class bE extends ge{constructor(){super();const e=` + `,this.registerClickListener()}onClick(n){const r=this.closest(".aie-container");this.isFullscreen?(r.style.height="100%",r.style.width="",r.style.background="",r.style.position="",r.style.top="",r.style.left="",r.style.zIndex=""):(r.style.height="calc(100vh - 2px)",r.style.width="calc(100% - 2px)",r.style.position="fixed",r.style.top="0",r.style.left="0",r.style.zIndex="9999"),this.isFullscreen=!this.isFullscreen,this.querySelector("div").innerHTML=this.isFullscreen?this.fullscreenExitSvg:this.fullscreenSvg}}class bE extends me{constructor(){super(),this.template=`
- `;this.template=e,this.registerClickListener()}onClick(e){let n=this.closest(".aie-container").querySelector(".aie-content").innerHTML;n=`
${n}
`;const i=Array.from(document.querySelectorAll("style, link")).map(l=>l.outerHTML).join("")+n,s=document.createElement("iframe");s.id="aie-print-iframe",s.setAttribute("style","position: absolute; width: 0; height: 0; top: -10px; left: -10px;"),document.body.appendChild(s);const o=s.contentWindow,a=s.contentDocument||s.contentWindow&&s.contentWindow.document;a&&(a.open(),a.write(i),a.close()),o&&(s.onload=function(){try{setTimeout(()=>{o.focus();try{o.document.execCommand("print",!1)||o.print()}catch{o.print()}o.close()},10)}catch(l){console.error(l)}setTimeout(function(){document.body.removeChild(s)},100)})}}const yE=["😀","😃","😄","😁","😆","😅","🤣","😂","🙂","🙃","😉","😊","😇","🥰","😍","🤩","😘","😗","😚","😙","🥲","😋","😛","😜","🤪","😝","🤑","🤗","🤭","🤫","🤔","🤐","🤨","😐","😑","😶","😶‍🌫","😏","😒","🙄","😬","😮‍💨","🤥","😌","😔","😪","🤤","😴","😷","🤒","🤕","🤢","🤮","🤧","🥵","🥶","🥴","😵","😵‍💫","🤯","🤠","🥳","🥸","😎","🤓","🧐","😕","😟","🙁","😮","😲","😳","🥺","😦","😧","😨","😰","😥","😢","😭","😱","😖","😣","😞","😓","😩","😫","🥱","😤","😡","😠","🤬","😈","👿","💀","☠️","💩","🤡","👹","👺","👻","👽","👾","🤖","😺","😸","😹","😻","😼","😽","🙀","😿","😾","🙈","🙉","🙊","💌","💘","💝","💖","💗","💓","💞","💕","💟","❣️","💔","💋","💯","💢","💥","💫","💦","💨","💤"];class xE extends ge{constructor(){super();const e=` + `,this.registerClickListener()}onClick(e){let n=this.closest(".aie-container").querySelector(".aie-content").innerHTML;n=`
${n}
`;const i=Array.from(document.querySelectorAll("style, link")).map(l=>l.outerHTML).join("")+n,s=document.createElement("iframe");s.id="aie-print-iframe",s.setAttribute("style","position: absolute; width: 0; height: 0; top: -10px; left: -10px;"),document.body.appendChild(s);const o=s.contentWindow,a=s.contentDocument||s.contentWindow&&s.contentWindow.document;a&&(a.open(),a.write(i),a.close()),o&&(s.onload=function(){try{setTimeout(()=>{o.focus();try{o.document.execCommand("print",!1)||o.print()}catch{o.print()}o.close()},10)}catch(l){console.error(l)}setTimeout(function(){document.body.removeChild(s)},100)})}}const yE=["😀","😃","😄","😁","😆","😅","🤣","😂","🙂","🙃","😉","😊","😇","🥰","😍","🤩","😘","😗","😚","😙","🥲","😋","😛","😜","🤪","😝","🤑","🤗","🤭","🤫","🤔","🤐","🤨","😐","😑","😶","😶‍🌫","😏","😒","🙄","😬","😮‍💨","🤥","😌","😔","😪","🤤","😴","😷","🤒","🤕","🤢","🤮","🤧","🥵","🥶","🥴","😵","😵‍💫","🤯","🤠","🥳","🥸","😎","🤓","🧐","😕","😟","🙁","😮","😲","😳","🥺","😦","😧","😨","😰","😥","😢","😭","😱","😖","😣","😞","😓","😩","😫","🥱","😤","😡","😠","🤬","😈","👿","💀","☠️","💩","🤡","👹","👺","👻","👽","👾","🤖","😺","😸","😹","😻","😼","😽","🙀","😿","😾","🙈","🙉","🙊","💌","💘","💝","💖","💗","💓","💞","💕","💟","❣️","💔","💋","💯","💢","💥","💫","💦","💨","💤"];class xE extends me{constructor(){super(),this.template=`
- `;this.template=e}connectedCallback(){super.connectedCallback(),Ke(this.querySelector("svg"),{content:this.createMenuElement(),appendTo:this.closest(".aie-container"),placement:"bottom",trigger:"click",interactive:!0,arrow:!1})}createMenuElement(){const e=document.createElement("div");return e.style.height="220px",e.style.width="400px",e.classList.add("aie-dropdown-container"),e.innerHTML=` + `}connectedCallback(){super.connectedCallback(),Ke(this.querySelector("svg"),{content:this.createMenuElement(),appendTo:this.closest(".aie-container"),placement:"bottom",trigger:"click",interactive:!0,arrow:!1})}createMenuElement(){const e=document.createElement("div");return e.style.height="220px",e.style.width="400px",e.classList.add("aie-dropdown-container"),e.innerHTML=`
${yE.map(n=>`
${n}
`).join("")}
- `,e.querySelector(".emoji-cells").addEventListener("click",n=>{var i;const r=n.target.closest(".emoji-cell");r&&((i=this.editor)==null||i.commands.insertContent(r.innerHTML))}),e}}class kE extends ge{constructor(){super();B(this,"svg",'');const n=` + `,e.querySelector(".emoji-cells").addEventListener("click",n=>{var i;const r=n.target.closest(".emoji-cell");r&&((i=this.editor)==null||i.commands.insertContent(r.innerHTML))}),e}}class kE extends me{constructor(){super();H(this,"svg",'');this.template=`
${this.svg}
- `;this.template=n,this.registerClickListener()}onClick(n){var r;n.setPainter((r=this.editor)==null?void 0:r.state.selection.$head.marks())}}class wa{constructor(e,n,r){B(this,"editor");B(this,"globalConfig");B(this,"aiModelName");B(this,"aiModelConfig");this.editor=e,this.globalConfig=n,this.aiModelName=r,this.aiModelConfig=n.models[r]}chat(e,n,r){const i=s=>{const o=this.createAiClient(s,r),a=n.includes("{content}")?n.split("{content}").join(e):`${e} -${n}`,l=this.wrapPayload(a);o.start(typeof l=="string"?l:JSON.stringify(l))};this.globalConfig.onCreateClientUrl?this.globalConfig.onCreateClientUrl(this.aiModelName,this.aiModelConfig,i):i(this.createAiClientUrl())}}class O1{constructor(e,n){B(this,"isStop",!1);B(this,"url");B(this,"webSocket");B(this,"isOpen",!1);B(this,"payload");B(this,"listener");this.url=e,this.listener=n}start(e){this.listener.onStart(this),this.payload=e,this.webSocket=new WebSocket(this.url),this.webSocket.onopen=n=>this.onOpen(n),this.webSocket.onmessage=n=>this.onMessage(n),this.webSocket.onclose=n=>this.onClose(n),this.webSocket.onerror=n=>this.onError(n)}stop(){this.webSocket&&(this.webSocket.close(),this.webSocket=void 0,this.isStop||(this.listener.onStop(),this.isStop=!0))}send(e){this.webSocket&&this.isOpen&&this.webSocket.send(e)}onOpen(e){this.isOpen=!0,this.send(this.payload)}onMessage(e){this.listener.onMessage(e.data)}onClose(e){this.isOpen=!1,this.isStop||(this.listener.onStop(),this.isStop=!0)}onError(e){this.isOpen=!1,this.isStop||(this.listener.onStop(),this.isStop=!0)}}var Fn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function _s(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function vE(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var n=function r(){return this instanceof r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(r){var i=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(n,r,i.get?i:{enumerable:!0,get:function(){return t[r]}})}),n}var N1={exports:{}};function EE(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var xl={exports:{}};const _E={},CE=Object.freeze(Object.defineProperty({__proto__:null,default:_E},Symbol.toStringTag,{value:"Module"})),wE=vE(CE);var Of;function Sa(){return Of||(Of=1,function(t,e){(function(n,r){t.exports=r()})(Fn,function(){var n=n||function(r,i){var s;if(typeof window<"u"&&window.crypto&&(s=window.crypto),typeof self<"u"&&self.crypto&&(s=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(s=globalThis.crypto),!s&&typeof window<"u"&&window.msCrypto&&(s=window.msCrypto),!s&&typeof Fn<"u"&&Fn.crypto&&(s=Fn.crypto),!s&&typeof EE=="function")try{s=wE}catch{}var o=function(){if(s){if(typeof s.getRandomValues=="function")try{return s.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof s.randomBytes=="function")try{return s.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},a=Object.create||function(){function x(){}return function(k){var b;return x.prototype=k,b=new x,x.prototype=null,b}}(),l={},u=l.lib={},c=u.Base=function(){return{extend:function(x){var k=a(this);return x&&k.mixIn(x),(!k.hasOwnProperty("init")||this.init===k.init)&&(k.init=function(){k.$super.init.apply(this,arguments)}),k.init.prototype=k,k.$super=this,k},create:function(){var x=this.extend();return x.init.apply(x,arguments),x},init:function(){},mixIn:function(x){for(var k in x)x.hasOwnProperty(k)&&(this[k]=x[k]);x.hasOwnProperty("toString")&&(this.toString=x.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),d=u.WordArray=c.extend({init:function(x,k){x=this.words=x||[],k!=i?this.sigBytes=k:this.sigBytes=x.length*4},toString:function(x){return(x||h).stringify(this)},concat:function(x){var k=this.words,b=x.words,E=this.sigBytes,v=x.sigBytes;if(this.clamp(),E%4)for(var C=0;C>>2]>>>24-C%4*8&255;k[E+C>>>2]|=T<<24-(E+C)%4*8}else for(var w=0;w>>2]=b[w>>>2];return this.sigBytes+=v,this},clamp:function(){var x=this.words,k=this.sigBytes;x[k>>>2]&=4294967295<<32-k%4*8,x.length=r.ceil(k/4)},clone:function(){var x=c.clone.call(this);return x.words=this.words.slice(0),x},random:function(x){for(var k=[],b=0;b>>2]>>>24-v%4*8&255;E.push((C>>>4).toString(16)),E.push((C&15).toString(16))}return E.join("")},parse:function(x){for(var k=x.length,b=[],E=0;E>>3]|=parseInt(x.substr(E,2),16)<<24-E%8*4;return new d.init(b,k/2)}},p=f.Latin1={stringify:function(x){for(var k=x.words,b=x.sigBytes,E=[],v=0;v>>2]>>>24-v%4*8&255;E.push(String.fromCharCode(C))}return E.join("")},parse:function(x){for(var k=x.length,b=[],E=0;E>>2]|=(x.charCodeAt(E)&255)<<24-E%4*8;return new d.init(b,k)}},m=f.Utf8={stringify:function(x){try{return decodeURIComponent(escape(p.stringify(x)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(x){return p.parse(unescape(encodeURIComponent(x)))}},g=u.BufferedBlockAlgorithm=c.extend({reset:function(){this._data=new d.init,this._nDataBytes=0},_append:function(x){typeof x=="string"&&(x=m.parse(x)),this._data.concat(x),this._nDataBytes+=x.sigBytes},_process:function(x){var k,b=this._data,E=b.words,v=b.sigBytes,C=this.blockSize,T=C*4,w=v/T;x?w=r.ceil(w):w=r.max((w|0)-this._minBufferSize,0);var N=w*C,$=r.min(N*4,v);if(N){for(var K=0;K>>7)^(w<<14|w>>>18)^w>>>3,$=d[T-2],K=($<<15|$>>>17)^($<<13|$>>>19)^$>>>10;d[T]=N+d[T-7]+K+d[T-16]}var U=b&E^~b&v,W=g&y^g&x^y&x,z=(g<<30|g>>>2)^(g<<19|g>>>13)^(g<<10|g>>>22),A=(b<<26|b>>>6)^(b<<21|b>>>11)^(b<<7|b>>>25),_=C+A+U+c[T]+d[T],S=z+W;C=v,v=E,E=b,b=k+_|0,k=x,x=y,y=g,g=_+S|0}m[0]=m[0]+g|0,m[1]=m[1]+y|0,m[2]=m[2]+x|0,m[3]=m[3]+k|0,m[4]=m[4]+b|0,m[5]=m[5]+E|0,m[6]=m[6]+v|0,m[7]=m[7]+C|0},_doFinalize:function(){var h=this._data,p=h.words,m=this._nDataBytes*8,g=h.sigBytes*8;return p[g>>>5]|=128<<24-g%32,p[(g+64>>>9<<4)+14]=r.floor(m/4294967296),p[(g+64>>>9<<4)+15]=m,h.sigBytes=p.length*4,this._process(),this._hash},clone:function(){var h=a.clone.call(this);return h._hash=this._hash.clone(),h}});i.SHA256=a._createHelper(f),i.HmacSHA256=a._createHmacHelper(f)}(Math),n.SHA256})}(kl)),kl.exports}var vl={exports:{}},Lf;function AE(){return Lf||(Lf=1,function(t,e){(function(n,r){t.exports=r(Sa())})(Fn,function(n){(function(){var r=n,i=r.lib,s=i.Base,o=r.enc,a=o.Utf8,l=r.algo;l.HMAC=s.extend({init:function(u,c){u=this._hasher=new u.init,typeof c=="string"&&(c=a.parse(c));var d=u.blockSize,f=d*4;c.sigBytes>f&&(c=u.finalize(c)),c.clamp();for(var h=this._oKey=c.clone(),p=this._iKey=c.clone(),m=h.words,g=p.words,y=0;y>>2]>>>24-h%4*8&255,m=u[h+1>>>2]>>>24-(h+1)%4*8&255,g=u[h+2>>>2]>>>24-(h+2)%4*8&255,y=p<<16|m<<8|g,x=0;x<4&&h+x*.75>>6*(3-x)&63));var k=d.charAt(64);if(k)for(;f.length%4;)f.push(k);return f.join("")},parse:function(l){var u=l.length,c=this._map,d=this._reverseMap;if(!d){d=this._reverseMap=[];for(var f=0;f>>6-h%4*2,g=p|m;d[f>>>2]|=g<<24-f%4*8,f++}return s.create(d,f)}}(),n.enc.Base64})})(L1);var DE=L1.exports;const OE=_s(DE),Aa=()=>"10000000-1000-4000-8000-100000000000".replace(/[018]/g,t=>(t^crypto.getRandomValues(new Uint8Array(1))[0]&15>>t/4).toString(16));class R1 extends wa{constructor(e,n){super(e,n,"spark"),this.aiModelConfig={version:"v3.5",protocol:"wss",...n.models.spark}}createAiClient(e,n){return new O1(e,{onStart:n.onStart,onStop:n.onStop,onMessage:r=>{var s,o,a,l,u;const i=JSON.parse(r);i.payload&&((o=(s=i.payload.usage)==null?void 0:s.text)!=null&&o.total_tokens&&this.globalConfig.onTokenConsume&&this.globalConfig.onTokenConsume(this.aiModelName,this.aiModelConfig,(l=(a=i.payload.usage)==null?void 0:a.text)==null?void 0:l.total_tokens),(u=i.payload.choices)!=null&&u.text&&i.payload.choices.text[0]&&n.onMessage({...i.payload.choices.text[0],status:i.payload.choices.status}))}})}wrapPayload(e){const n=this.aiModelConfig,r={header:{app_id:n.appId,uid:Aa()},parameter:{chat:{domain:this.getDomain(n),temperature:.5,max_tokens:2048}},payload:{message:{text:[]}}};return r.payload.message.text.push({role:"user",content:e}),JSON.stringify(r)}getDomain(e){switch(e.version){case"v3.5":return"generalv3.5";case"v3.1":return"generalv3";case"v2.1":return"generalv2";default:return"general"}}createAiClientUrl(){const e=this.aiModelConfig,n=new Date().toUTCString().replace("GMT","+0000");let r=`host: spark-api.xf-yun.com + `,this.registerClickListener()}onClick(n){var r;n.setPainter((r=this.editor)==null?void 0:r.state.selection.$head.marks())}}class wa{constructor(e,n,r){H(this,"editor");H(this,"globalConfig");H(this,"aiModelName");H(this,"aiModelConfig");this.editor=e,this.globalConfig=n,this.aiModelName=r,this.aiModelConfig=n.models[r]}chatWithPayload(e,n){const r=i=>{this.createAiClient(i,n).start(typeof e=="string"?e:JSON.stringify(e))};this.globalConfig.onCreateClientUrl?this.globalConfig.onCreateClientUrl(this.aiModelName,this.aiModelConfig,r):r(this.createAiClientUrl())}chat(e,n,r){const i=s=>{const o=this.createAiClient(s,r),a=n.includes("{content}")?n.split("{content}").join(e):`${e} +${n}`,l=this.wrapPayload(a);o.start(typeof l=="string"?l:JSON.stringify(l))};this.globalConfig.onCreateClientUrl?this.globalConfig.onCreateClientUrl(this.aiModelName,this.aiModelConfig,i):i(this.createAiClientUrl())}}class D1{constructor(e,n){H(this,"isStop",!1);H(this,"url");H(this,"webSocket");H(this,"isOpen",!1);H(this,"payload");H(this,"listener");this.url=e,this.listener=n}start(e){this.listener.onStart(this),this.payload=e,this.webSocket=new WebSocket(this.url),this.webSocket.onopen=n=>this.onOpen(n),this.webSocket.onmessage=n=>this.onMessage(n),this.webSocket.onclose=n=>this.onClose(n),this.webSocket.onerror=n=>this.onError(n)}stop(){this.webSocket&&(this.webSocket.close(),this.webSocket=void 0,this.isStop||(this.listener.onStop(),this.isStop=!0))}send(e){this.webSocket&&this.isOpen&&this.webSocket.send(e)}onOpen(e){this.isOpen=!0,this.send(this.payload)}onMessage(e){this.listener.onMessage(e.data)}onClose(e){this.isOpen=!1,this.isStop||(this.listener.onStop(),this.isStop=!0)}onError(e){this.isOpen=!1,this.isStop||(this.listener.onStop(),this.isStop=!0)}}var Fn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function _s(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function vE(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var n=function r(){return this instanceof r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(r){var i=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(n,r,i.get?i:{enumerable:!0,get:function(){return t[r]}})}),n}var O1={exports:{}};function EE(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var xl={exports:{}};const _E={},CE=Object.freeze(Object.defineProperty({__proto__:null,default:_E},Symbol.toStringTag,{value:"Module"})),wE=vE(CE);var Nf;function Sa(){return Nf||(Nf=1,function(t,e){(function(n,r){t.exports=r()})(Fn,function(){var n=n||function(r,i){var s;if(typeof window<"u"&&window.crypto&&(s=window.crypto),typeof self<"u"&&self.crypto&&(s=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(s=globalThis.crypto),!s&&typeof window<"u"&&window.msCrypto&&(s=window.msCrypto),!s&&typeof Fn<"u"&&Fn.crypto&&(s=Fn.crypto),!s&&typeof EE=="function")try{s=wE}catch{}var o=function(){if(s){if(typeof s.getRandomValues=="function")try{return s.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof s.randomBytes=="function")try{return s.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},a=Object.create||function(){function x(){}return function(k){var b;return x.prototype=k,b=new x,x.prototype=null,b}}(),l={},u=l.lib={},c=u.Base=function(){return{extend:function(x){var k=a(this);return x&&k.mixIn(x),(!k.hasOwnProperty("init")||this.init===k.init)&&(k.init=function(){k.$super.init.apply(this,arguments)}),k.init.prototype=k,k.$super=this,k},create:function(){var x=this.extend();return x.init.apply(x,arguments),x},init:function(){},mixIn:function(x){for(var k in x)x.hasOwnProperty(k)&&(this[k]=x[k]);x.hasOwnProperty("toString")&&(this.toString=x.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),d=u.WordArray=c.extend({init:function(x,k){x=this.words=x||[],k!=i?this.sigBytes=k:this.sigBytes=x.length*4},toString:function(x){return(x||h).stringify(this)},concat:function(x){var k=this.words,b=x.words,E=this.sigBytes,v=x.sigBytes;if(this.clamp(),E%4)for(var C=0;C>>2]>>>24-C%4*8&255;k[E+C>>>2]|=T<<24-(E+C)%4*8}else for(var w=0;w>>2]=b[w>>>2];return this.sigBytes+=v,this},clamp:function(){var x=this.words,k=this.sigBytes;x[k>>>2]&=4294967295<<32-k%4*8,x.length=r.ceil(k/4)},clone:function(){var x=c.clone.call(this);return x.words=this.words.slice(0),x},random:function(x){for(var k=[],b=0;b>>2]>>>24-v%4*8&255;E.push((C>>>4).toString(16)),E.push((C&15).toString(16))}return E.join("")},parse:function(x){for(var k=x.length,b=[],E=0;E>>3]|=parseInt(x.substr(E,2),16)<<24-E%8*4;return new d.init(b,k/2)}},p=f.Latin1={stringify:function(x){for(var k=x.words,b=x.sigBytes,E=[],v=0;v>>2]>>>24-v%4*8&255;E.push(String.fromCharCode(C))}return E.join("")},parse:function(x){for(var k=x.length,b=[],E=0;E>>2]|=(x.charCodeAt(E)&255)<<24-E%4*8;return new d.init(b,k)}},m=f.Utf8={stringify:function(x){try{return decodeURIComponent(escape(p.stringify(x)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(x){return p.parse(unescape(encodeURIComponent(x)))}},g=u.BufferedBlockAlgorithm=c.extend({reset:function(){this._data=new d.init,this._nDataBytes=0},_append:function(x){typeof x=="string"&&(x=m.parse(x)),this._data.concat(x),this._nDataBytes+=x.sigBytes},_process:function(x){var k,b=this._data,E=b.words,v=b.sigBytes,C=this.blockSize,T=C*4,w=v/T;x?w=r.ceil(w):w=r.max((w|0)-this._minBufferSize,0);var N=w*C,$=r.min(N*4,v);if(N){for(var K=0;K>>7)^(w<<14|w>>>18)^w>>>3,$=d[T-2],K=($<<15|$>>>17)^($<<13|$>>>19)^$>>>10;d[T]=N+d[T-7]+K+d[T-16]}var U=b&E^~b&v,W=g&y^g&x^y&x,z=(g<<30|g>>>2)^(g<<19|g>>>13)^(g<<10|g>>>22),A=(b<<26|b>>>6)^(b<<21|b>>>11)^(b<<7|b>>>25),_=C+A+U+c[T]+d[T],S=z+W;C=v,v=E,E=b,b=k+_|0,k=x,x=y,y=g,g=_+S|0}m[0]=m[0]+g|0,m[1]=m[1]+y|0,m[2]=m[2]+x|0,m[3]=m[3]+k|0,m[4]=m[4]+b|0,m[5]=m[5]+E|0,m[6]=m[6]+v|0,m[7]=m[7]+C|0},_doFinalize:function(){var h=this._data,p=h.words,m=this._nDataBytes*8,g=h.sigBytes*8;return p[g>>>5]|=128<<24-g%32,p[(g+64>>>9<<4)+14]=r.floor(m/4294967296),p[(g+64>>>9<<4)+15]=m,h.sigBytes=p.length*4,this._process(),this._hash},clone:function(){var h=a.clone.call(this);return h._hash=this._hash.clone(),h}});i.SHA256=a._createHelper(f),i.HmacSHA256=a._createHmacHelper(f)}(Math),n.SHA256})}(kl)),kl.exports}var vl={exports:{}},Rf;function AE(){return Rf||(Rf=1,function(t,e){(function(n,r){t.exports=r(Sa())})(Fn,function(n){(function(){var r=n,i=r.lib,s=i.Base,o=r.enc,a=o.Utf8,l=r.algo;l.HMAC=s.extend({init:function(u,c){u=this._hasher=new u.init,typeof c=="string"&&(c=a.parse(c));var d=u.blockSize,f=d*4;c.sigBytes>f&&(c=u.finalize(c)),c.clamp();for(var h=this._oKey=c.clone(),p=this._iKey=c.clone(),m=h.words,g=p.words,y=0;y>>2]>>>24-h%4*8&255,m=u[h+1>>>2]>>>24-(h+1)%4*8&255,g=u[h+2>>>2]>>>24-(h+2)%4*8&255,y=p<<16|m<<8|g,x=0;x<4&&h+x*.75>>6*(3-x)&63));var k=d.charAt(64);if(k)for(;f.length%4;)f.push(k);return f.join("")},parse:function(l){var u=l.length,c=this._map,d=this._reverseMap;if(!d){d=this._reverseMap=[];for(var f=0;f>>6-h%4*2,g=p|m;d[f>>>2]|=g<<24-f%4*8,f++}return s.create(d,f)}}(),n.enc.Base64})})(N1);var DE=N1.exports;const OE=_s(DE),Aa=()=>"10000000-1000-4000-8000-100000000000".replace(/[018]/g,t=>(t^crypto.getRandomValues(new Uint8Array(1))[0]&15>>t/4).toString(16));class L1 extends wa{constructor(e,n){super(e,n,"spark"),this.aiModelConfig={version:"v3.5",protocol:"wss",...n.models.spark}}createAiClient(e,n){return new D1(e,{onStart:n.onStart,onStop:n.onStop,onMessage:r=>{var s,o,a,l,u;const i=JSON.parse(r);i.payload&&((o=(s=i.payload.usage)==null?void 0:s.text)!=null&&o.total_tokens&&this.globalConfig.onTokenConsume&&this.globalConfig.onTokenConsume(this.aiModelName,this.aiModelConfig,(l=(a=i.payload.usage)==null?void 0:a.text)==null?void 0:l.total_tokens),(u=i.payload.choices)!=null&&u.text&&i.payload.choices.text[0]&&n.onMessage({...i.payload.choices.text[0],status:i.payload.choices.status}))}})}wrapPayload(e){const n=this.aiModelConfig,r={header:{app_id:n.appId,uid:Aa()},parameter:{chat:{domain:this.getDomain(n),temperature:.5,max_tokens:2048}},payload:{message:{text:[{role:"user",content:e}]}}};return JSON.stringify(r)}getDomain(e){switch(e.version){case"v3.5":return"generalv3.5";case"v3.1":return"generalv3";case"v2.1":return"generalv2";default:return"general"}}createAiClientUrl(){const e=this.aiModelConfig,n=new Date().toUTCString().replace("GMT","+0000");let r=`host: spark-api.xf-yun.com `;r+="date: "+n+` -`,r+=`GET /${e.version}/chat HTTP/1.1`;const i=TE(r,e.apiSecret),s=OE.stringify(i),o=`api_key="${e.apiKey}", algorithm="hmac-sha256", headers="host date request-line", signature="${s}"`,a=btoa(o);return`${e.protocol}://spark-api.xf-yun.com/${e.version}/chat?authorization=${a}&date=${encodeURIComponent(n)}&host=spark-api.xf-yun.com`}}class NE{constructor(e,n){B(this,"isStop",!1);B(this,"config");B(this,"fetch");B(this,"isOpen",!1);B(this,"payload");B(this,"listener");this.config=e,this.listener=n}start(e){this.payload=e,this.onOpen(),this.listener.onStart(this)}stop(){this.fetch&&(this.fetch=void 0,this.isStop||(this.listener.onStop(),this.isStop=!0))}async send(e){if(this.isOpen)try{this.fetch=await fetch(this.config.url,{method:this.config.method,body:e});const n=this.fetch;if(!n.body)throw new Error("response.body is none");const r=({done:o,value:a})=>{if(o){this.onClose();return}return this.onMessage(s.decode(a)),i.read().then(({done:l,value:u})=>r({done:l,value:u}))},i=n.body.getReader(),s=new TextDecoder("utf-8");i.read().then(({done:o,value:a})=>r({done:o,value:a}))}catch{this.onError()}}onOpen(){this.isOpen=!0,this.send(this.payload)}onMessage(e){this.listener.onMessage(e)}onClose(){this.isOpen=!1,this.isStop||(this.listener.onStop(),this.isStop=!0)}onError(){this.isOpen=!1,this.isStop||(this.listener.onStop(),this.isStop=!0)}}class LE extends wa{constructor(e,n){super(e,n,"wenxin"),this.aiModelConfig={...n.models.wenxin}}createAiClient(e,n){return new NE({url:e,method:"POST"},{onStart:n.onStart,onStop:n.onStop,onMessage:r=>{const i=r.match(/data:([\s\S]*)$/);if(!i)return;const s=JSON.parse(i[1]);n.onMessage({status:s.is_end?2:1,role:"assistant",content:s.result||"",index:s.sentence_id})}})}wrapPayload(e){const n={messages:[],stream:!0};return n.messages.push({role:"user",content:e}),JSON.stringify(n)}createAiClientUrl(){return`https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/completions_pro?access_token=${this.aiModelConfig.access_token}`}}class I1{constructor(e,n){B(this,"isStop",!1);B(this,"config");B(this,"fetch");B(this,"isOpen",!1);B(this,"payload");B(this,"listener");B(this,"ctrl",new AbortController);this.config=e,this.listener=n}start(e){this.payload=e,this.onOpen(),this.listener.onStart(this)}stop(){this.fetch&&(this.ctrl.abort(),this.isStop||(this.listener.onStop(),this.isStop=!0))}async send(e){var n;if(this.isOpen)try{const r=await fetch(this.config.url,{method:this.config.method||"POST",headers:this.config.headers,body:e});if(!r.ok){this.onError();return}const i=(n=r.body)==null?void 0:n.getReader();if(!i){this.onError();return}const s=new TextDecoder("utf-8");for(;;){let{value:o,done:a}=await i.read();if(a){this.onClose();break}let l=s.decode(o);if(!l)return;const u=l.split(` +`,r+=`GET /${e.version}/chat HTTP/1.1`;const i=TE(r,e.apiSecret),s=OE.stringify(i),o=`api_key="${e.apiKey}", algorithm="hmac-sha256", headers="host date request-line", signature="${s}"`,a=btoa(o);return`${e.protocol}://spark-api.xf-yun.com/${e.version}/chat?authorization=${a}&date=${encodeURIComponent(n)}&host=spark-api.xf-yun.com`}}class NE{constructor(e,n){H(this,"isStop",!1);H(this,"config");H(this,"fetch");H(this,"isOpen",!1);H(this,"payload");H(this,"listener");this.config=e,this.listener=n}start(e){this.payload=e,this.onOpen(),this.listener.onStart(this)}stop(){this.fetch&&(this.fetch=void 0,this.isStop||(this.listener.onStop(),this.isStop=!0))}async send(e){if(this.isOpen)try{this.fetch=await fetch(this.config.url,{method:this.config.method,body:e});const n=this.fetch;if(!n.body)throw new Error("response.body is none");const r=({done:o,value:a})=>{if(o){this.onClose();return}return this.onMessage(s.decode(a)),i.read().then(({done:l,value:u})=>r({done:l,value:u}))},i=n.body.getReader(),s=new TextDecoder("utf-8");i.read().then(({done:o,value:a})=>r({done:o,value:a}))}catch{this.onError()}}onOpen(){this.isOpen=!0,this.send(this.payload)}onMessage(e){this.listener.onMessage(e)}onClose(){this.isOpen=!1,this.isStop||(this.listener.onStop(),this.isStop=!0)}onError(){this.isOpen=!1,this.isStop||(this.listener.onStop(),this.isStop=!0)}}class LE extends wa{constructor(e,n){super(e,n,"wenxin"),this.aiModelConfig={...n.models.wenxin}}createAiClient(e,n){return new NE({url:e,method:"POST"},{onStart:n.onStart,onStop:n.onStop,onMessage:r=>{const i=r.match(/data:([\s\S]*)$/);if(!i)return;const s=JSON.parse(i[1]);n.onMessage({status:s.is_end?2:1,role:"assistant",content:s.result||"",index:s.sentence_id})}})}wrapPayload(e){const n={messages:[],stream:!0};return n.messages.push({role:"user",content:e}),JSON.stringify(n)}createAiClientUrl(){return`https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/completions_pro?access_token=${this.aiModelConfig.access_token}`}}class R1{constructor(e,n){H(this,"isStop",!1);H(this,"config");H(this,"fetch");H(this,"isOpen",!1);H(this,"payload");H(this,"listener");H(this,"ctrl",new AbortController);this.config=e,this.listener=n}start(e){this.payload=e,this.onOpen(),this.listener.onStart(this)}stop(){this.fetch&&(this.ctrl.abort(),this.isStop||(this.listener.onStop(),this.isStop=!0))}async send(e){var n;if(this.isOpen)try{const r=await fetch(this.config.url,{method:this.config.method||"POST",headers:this.config.headers,body:e});if(!r.ok){this.onError();return}const i=(n=r.body)==null?void 0:n.getReader();if(!i){this.onError();return}const s=new TextDecoder("utf-8");for(;;){let{value:o,done:a}=await i.read();if(a){this.onClose();break}let l=s.decode(o);if(!l)return;const u=l.split(` `);let c="",d=0;for(let f of u)f.indexOf("data:")==0?(c&&this.onMessage(c),c=f.substring(5)):(d!=u.length-1&&(c+=` -`),c+=f),d++;c&&this.onMessage(c)}}catch{this.onError()}}onOpen(){this.isOpen=!0,this.send(this.payload)}onMessage(e){this.listener.onMessage(e)}onClose(){this.isOpen=!1,this.isStop||(this.listener.onStop(),this.isStop=!0)}onError(){this.isOpen=!1,this.isStop||(this.listener.onStop(),this.isStop=!0)}}class RE extends wa{constructor(e,n){super(e,n,"custom"),this.aiModelConfig={protocol:"sse",...n.models.custom}}createAiClient(e,n){var s;const r=this.aiModelConfig,i={onStart:n.onStart,onStop:n.onStop,onMessage:o=>{var u;const a=this.aiModelConfig,l=(u=a.parseMessage)==null?void 0:u.call(a,o);l&&n.onMessage(l)}};return r.protocol==="sse"?new I1({url:e,method:"post",headers:(s=r.headers)==null?void 0:s.call(r)},i):new O1(e,i)}wrapPayload(e){var r;const n=this.aiModelConfig;return(r=n.wrapPayload)==null?void 0:r.call(n,e)}createAiClientUrl(){var n;const e=this.aiModelConfig;return typeof e.url=="string"?e.url:(n=e.url)==null?void 0:n.call(e)}}class IE extends wa{constructor(e,n){super(e,n,"openai"),this.aiModelConfig={endpoint:"https://api.openai.com",model:"gpt-3.5-turbo",...n.models.openai}}createAiClient(e,n){const r=this.aiModelConfig;return new I1({url:e,method:"post",headers:{"Content-Type":"application/json",Authorization:`Bearer ${r.apiKey}`}},{onStart:n.onStart,onStop:n.onStop,onMessage:i=>{var o,a;const s=JSON.parse(i);n.onMessage({status:s.choices[0].finish_reason==="stop"?2:1,role:"assistant",content:((o=s.choices[0].delta)==null?void 0:o.content)||"",index:s.choices[0].index}),this.globalConfig.onTokenConsume&&((a=s.choices[0].usage)!=null&&a.total_tokens)&&this.globalConfig.onTokenConsume(this.aiModelName,this.aiModelConfig,s.choices[0].usage.total_tokens)}})}wrapPayload(e){const r={model:this.aiModelConfig.model,messages:[{role:"user",content:e}],stream:!0};return JSON.stringify(r)}createAiClientUrl(){return`${this.aiModelConfig.endpoint}/v1/chat/completions`}}class Kn{static init(e,n){var r;if(n&&n.models)for(let i of Object.keys(n.models))switch(i){case"spark":this.set(i,new R1(e,n));break;case"wenxin":this.set(i,new LE(e,n));break;case"openai":this.set(i,new IE(e,n));break;case"custom":this.set(i,new RE(e,n));break;default:const s=(r=n.modelFactory)==null?void 0:r.create(i,e,n);s&&this.set(i,s)}}static get(e){return(!e||e==="auto")&&(e=Object.keys(this.models)[0]),this.models[e]}static set(e,n){this.models[e]=n}}B(Kn,"models",{});const FE=t=>{let e="";return t.descendants(n=>{n.text&&(e+=n.text)}),e};class Ro{constructor(e,n){B(this,"editor");B(this,"from");B(this,"options");this.editor=e,this.from=e.view.state.selection.from,this.options=n||{markdownParseEnable:!0}}onStart(){}onStop(){}onMessage(e){const{state:{tr:n},view:r}=this.editor;if(r.dispatch(n.insertText(e.content)),e.status==2&&this.options.markdownParseEnable){const i=this.editor.state.selection.to,s=this.editor.state.doc.textBetween(this.from,i),{state:{tr:o},view:a}=this.editor,l=this.editor.parseMarkdown(s);if(this.options.useMarkdownTextOnly){const u=FE(l),c=this.editor.schema.text(u);a.dispatch(o.replaceWith(this.from,i,c).scrollIntoView())}else a.dispatch(o.replaceWith(this.from,i,l).scrollIntoView())}this.editor.commands.scrollIntoView()}}const HE=[{icon:'',name:"AI 续写",prompt:"请帮我继续扩展一些这段话的内容",text:"focusBefore",model:"auto"},{icon:'',name:"AI 优化",prompt:"请帮我优化一下这段文字的内容,并返回结果",text:"selected",model:"auto"},{icon:'',name:"AI 校对",prompt:"请帮我找出这段话的错别字,把错别字修改后,并返回结果,不要解释或其他多余的内容",text:"selected",model:"auto"},{icon:'',name:"AI 翻译",prompt:"请帮我翻译以上内容,在翻译之前,想先判断一下这个内容是不是中文,如果是中文,则翻译问英文,如果是其他语言,则需要翻译为中文,注意,你只需要返回翻译的结果,不需要对此进行任何解释,不需要除了翻译结果以外的其他任何内容。",text:"selected",model:"auto"}];class BE extends gi{constructor(){super(),this.dropDivHeight="auto",this.dropDivWith="94px",this.width="36px",this.menuTextWidth="20px"}onCreate(e,n){var r;super.onCreate(e,n),this.menuData=((r=n.ai)==null?void 0:r.menus)||HE}renderTemplate(){this.template=` +`),c+=f),d++;c&&this.onMessage(c)}}catch{this.onError()}}onOpen(){this.isOpen=!0,this.send(this.payload)}onMessage(e){this.listener.onMessage(e)}onClose(){this.isOpen=!1,this.isStop||(this.listener.onStop(),this.isStop=!0)}onError(){this.isOpen=!1,this.isStop||(this.listener.onStop(),this.isStop=!0)}}class RE extends wa{constructor(e,n){super(e,n,"custom"),this.aiModelConfig={protocol:"sse",...n.models.custom}}createAiClient(e,n){var s;const r=this.aiModelConfig,i={onStart:n.onStart,onStop:n.onStop,onMessage:o=>{var u;const a=this.aiModelConfig,l=(u=a.parseMessage)==null?void 0:u.call(a,o);l&&n.onMessage(l)}};return r.protocol==="sse"?new R1({url:e,method:"post",headers:(s=r.headers)==null?void 0:s.call(r)},i):new D1(e,i)}wrapPayload(e){var r;const n=this.aiModelConfig;return(r=n.wrapPayload)==null?void 0:r.call(n,e)}createAiClientUrl(){var n;const e=this.aiModelConfig;return typeof e.url=="string"?e.url:(n=e.url)==null?void 0:n.call(e)}}class IE extends wa{constructor(e,n){super(e,n,"openai"),this.aiModelConfig={endpoint:"https://api.openai.com",model:"gpt-3.5-turbo",...n.models.openai}}createAiClient(e,n){const r=this.aiModelConfig;return new R1({url:e,method:"post",headers:{"Content-Type":"application/json",Authorization:`Bearer ${r.apiKey}`}},{onStart:n.onStart,onStop:n.onStop,onMessage:i=>{var o,a;const s=JSON.parse(i);n.onMessage({status:s.choices[0].finish_reason==="stop"?2:1,role:"assistant",content:((o=s.choices[0].delta)==null?void 0:o.content)||"",index:s.choices[0].index}),this.globalConfig.onTokenConsume&&((a=s.choices[0].usage)!=null&&a.total_tokens)&&this.globalConfig.onTokenConsume(this.aiModelName,this.aiModelConfig,s.choices[0].usage.total_tokens)}})}wrapPayload(e){const r={model:this.aiModelConfig.model,messages:[{role:"user",content:e}],stream:!0};return JSON.stringify(r)}createAiClientUrl(){return`${this.aiModelConfig.endpoint}/v1/chat/completions`}}class Kn{static init(e,n){var r;if(n&&n.models)for(let i of Object.keys(n.models))switch(i){case"spark":this.set(i,new L1(e,n));break;case"wenxin":this.set(i,new LE(e,n));break;case"openai":this.set(i,new IE(e,n));break;case"custom":this.set(i,new RE(e,n));break;default:const s=(r=n.modelFactory)==null?void 0:r.create(i,e,n);s&&this.set(i,s)}}static get(e){return(!e||e==="auto")&&(e=Object.keys(this.models)[0]),this.models[e]}static set(e,n){this.models[e]=n}}H(Kn,"models",{});const FE=t=>{let e="";return t.descendants(n=>{n.text&&(e+=n.text)}),e};class Ro{constructor(e,n){H(this,"editor");H(this,"from");H(this,"options");this.editor=e,this.from=e.view.state.selection.from,this.options=n||{markdownParseEnable:!0}}onStart(){}onStop(){}onMessage(e){const{state:{tr:n},view:r}=this.editor;if(r.dispatch(n.insertText(e.content)),e.status==2&&this.options.markdownParseEnable){const i=this.editor.state.selection.to,s=this.editor.state.doc.textBetween(this.from,i),{state:{tr:o},view:a}=this.editor,l=this.editor.parseMarkdown(s);if(this.options.useMarkdownTextOnly){const u=FE(l),c=this.editor.schema.text(u);a.dispatch(o.replaceWith(this.from,i,c).scrollIntoView())}else a.dispatch(o.replaceWith(this.from,i,l).scrollIntoView())}this.editor.commands.scrollIntoView()}}const HE=[{icon:'',name:"AI 续写",prompt:"请帮我继续扩展一些这段话的内容",text:"focusBefore",model:"auto"},{icon:'',name:"AI 优化",prompt:"请帮我优化一下这段文字的内容,并返回结果",text:"selected",model:"auto"},{icon:'',name:"AI 校对",prompt:"请帮我找出这段话的错别字,把错别字修改后,并返回结果,不要解释或其他多余的内容",text:"selected",model:"auto"},{icon:'',name:"AI 翻译",prompt:"请帮我翻译以上内容,在翻译之前,想先判断一下这个内容是不是中文,如果是中文,则翻译问英文,如果是其他语言,则需要翻译为中文,注意,你只需要返回翻译的结果,不需要对此进行任何解释,不需要除了翻译结果以外的其他任何内容。",text:"selected",model:"auto"}];class BE extends gi{constructor(){super(),this.dropDivHeight="auto",this.dropDivWith="94px",this.width="36px",this.menuTextWidth="20px"}onCreate(e,n){var r;super.onCreate(e,n),this.menuData=((r=n.ai)==null?void 0:r.menus)||HE}renderTemplate(){this.template=`
`}createMenuElement(){const e=document.createElement("div");e.style.height=this.dropDivHeight,e.style.width=this.dropDivWith,e.classList.add("aie-dropdown-container");for(let n=0;n${this.onDropdownItemRender(n)}
- `,r.addEventListener("click",()=>{this.onDropdownItemClick(n),this.tippyInstance.hide()}),e.appendChild(r)}return this.tippyEl=e,e}onTransaction(e){}onDropdownActive(e,n){return!1}getSelectedText(e){if(e==="selected"){const{selection:n,doc:r}=this.editor.state;return r.textBetween(n.from,n.to)}else return this.editor.state.selection.$head.parent.textContent}onDropdownItemClick(e){const n=this.menuData[e],r=this.getSelectedText(n.text);if(r){const i=Kn.get(n.model);i?i==null||i.chat(r,n.prompt,new Ro(this.editor)):console.error("Ai model config error.")}else console.error("Can not get selected text.")}onDropdownItemRender(e){return`
${this.menuData[e].icon}
${this.menuData[e].name}
`}onMenuTextRender(e){return this.menuData[e].icon}}class PE extends ge{constructor(){super();const e=` + `,r.addEventListener("click",()=>{this.onDropdownItemClick(n),this.tippyInstance.hide()}),e.appendChild(r)}return this.tippyEl=e,e}onTransaction(e){}onDropdownActive(e,n){return!1}getSelectedText(e){if(e==="selected"){const{selection:n,doc:r}=this.editor.state;return r.textBetween(n.from,n.to)}else return this.editor.state.selection.$head.parent.textContent}onDropdownItemClick(e){const n=this.menuData[e],r=this.getSelectedText(n.text);if(r){const i=Kn.get(n.model);i?i==null||i.chat(r,n.prompt,new Ro(this.editor)):console.error("Ai model config error.")}else console.error("Can not get selected text.")}onDropdownItemRender(e){return`
${this.menuData[e].icon}
${this.menuData[e].name}
`}onMenuTextRender(e){return this.menuData[e].icon}}class PE extends me{constructor(){super(),this.template=`
- `;this.template=e,this.registerClickListener()}onClick(e){var n;(n=this.editor)!=null&&n.isActive("container")?e.unsetContainer():e.setContainer("warning"),e.focus()}onActive(e){return e.isActive("container")}}class $E extends ge{constructor(){super();B(this,"config")}onConfig(n){this.config=n,n.html?this.template=n.html:n.icon&&(this.template=`
${n.icon}
`),this.addEventListener("click",r=>{this.config&&this.config.onClick&&this.config.onClick(r,this.editor.aiEditor)})}}const se=(t,e)=>{window.customElements.get(t)||window.customElements.define(t,e)};se("aie-undo",s1);se("aie-undo",s1);se("aie-redo",L3);se("aie-brush",kE);se("aie-container",PE);se("aie-custom",$E);se("aie-eraser",dE);se("aie-heading",Rv);se("aie-font-family",Fv);se("aie-font-size",Bv);se("aie-bold",Pv);se("aie-italic",$v);se("aie-underline",zv);se("aie-strike",Vv);se("aie-link",nE);se("aie-code",uE);se("aie-subscript",Uv);se("aie-superscript",qv);se("aie-highlight",Wv);se("aie-font-color",jv);se("aie-divider",Gv);se("aie-bullet-list",Jv);se("aie-ordered-list",Yv);se("aie-indent-decrease",Xv);se("aie-indent-increase",Qv);se("aie-align",tE);se("aie-todo",rE);se("aie-line-height",sE);se("aie-break",pE);se("aie-quote",oE);se("aie-image",aE);se("aie-video",lE);se("aie-code-block",cE);se("aie-hr",fE);se("aie-table",hE);se("aie-attachment",mE);se("aie-fullscreen",gE);se("aie-printer",bE);se("aie-emoji",xE);se("aie-ai",BE);const zE=["undo","redo","brush","eraser","divider","heading","font-family","font-size","divider","bold","italic","underline","strike","link","code","subscript","superscript","hr","todo","emoji","divider","highlight","font-color","divider","align","line-height","divider","bullet-list","ordered-list","indent-decrease","indent-increase","break","divider","image","video","attachment","quote","container","code-block","table","divider","printer","fullscreen","ai"];class VE extends HTMLElement{constructor(){super();B(this,"menuButtons",[])}connectedCallback(){const n=document.createElement("div");for(let r of this.menuButtons)n.appendChild(r);n.style.display="flex",n.style.flexWrap="wrap",this.appendChild(n)}onCreate(n,r){let i=r.toolbarKeys||zE;for(let s of i)if(s)try{if(typeof s=="string"){s=s.trim(),s==="|"&&(s="divider");const o=document.createElement("aie-"+s);if(o.classList.add("aie-menu-item"),o.onCreate(n,r),s!=="divider"){const a=re(s);a&&Ke(o,{appendTo:()=>n.editor.view.dom.closest(".aie-container"),content:a,theme:"aietip",arrow:!0})}this.menuButtons.push(o)}else{const o=s,a=document.createElement("aie-custom");if(a.classList.add("aie-menu-item"),o.id&&a.setAttribute("id",o.id),o.className&&a.classList.add(o.className),a.onCreate(n,r),a.onConfig(o),o.tip){const l=re(o.tip);l&&Ke(a,{appendTo:()=>n.editor.view.dom.closest(".aie-container"),content:l,theme:"aietip",arrow:!0})}o.onCreate&&o.onCreate(a,n.editor.aiEditor),this.menuButtons.push(a)}}catch{console.error("Can not create toolbar by key: "+s)}}onTransaction(n){for(let r of this.menuButtons)r.onTransaction(n)}}class UE extends HTMLElement{constructor(){super();B(this,"count",0);let n,r,i=300,s=300,o,a,l;const u=d=>{d.preventDefault(),document.removeEventListener("mouseup",u),document.removeEventListener("mousemove",c)},c=d=>{const f=d.clientX-n,h=d.clientY-r;if(f==0&&h==0)return;let p=o+f,m=a+h;p{var h;d.target.closest("svg")&&(d.preventDefault(),document.addEventListener("mouseup",u),document.addEventListener("mousemove",c),l=(h=d.target.closest(".aie-container"))==null?void 0:h.parentElement,o=l.clientWidth,a=l.clientHeight,n=d.clientX,r=d.clientY)}),this.addEventListener("mouseup",u)}updateCharacters(){this.innerHTML=` -
- Powered by AiEditor, Characters: ${this.count} -
- -
-
- `}onCreate(n,r){this.count=n.editor.storage.characterCount.characters(),this.updateCharacters()}onTransaction(n){const r=n.editor.storage.characterCount.characters();r!=this.count&&(this.count=r,this.updateCharacters())}}const qE=/^\s*>\s$/,ZE=ue.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return["blockquote",le(this.options.HTMLAttributes,t),0]},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[vr({find:qE,type:this.type})]}}),KE=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,WE=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,jE=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,GE=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,JE=Ie.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return["strong",le(this.options.HTMLAttributes,t),0]},addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[kr({find:KE,type:this.type}),kr({find:jE,type:this.type})]},addPasteRules(){return[Zn({find:WE,type:this.type}),Zn({find:GE,type:this.type})]}}),YE=ue.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",le(this.options.HTMLAttributes,t),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),Rf=Ie.create({name:"textStyle",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"span",getAttrs:t=>t.hasAttribute("style")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["span",le(this.options.HTMLAttributes,t),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:t,commands:e})=>{const n=xs(t,this.type);return Object.entries(n).some(([,i])=>!!i)?!0:e.unsetMark(this.name)}}}}),If=/^\s*([-+*])\s$/,XE=ue.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:t}){return["ul",le(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(YE.name,this.editor.getAttributes(Rf.name)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=vr({find:If,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=vr({find:If,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Rf.name),editor:this.editor})),[t]}}),QE=/(?:^|\s)(`(?!\s+`)((?:[^`]+))`(?!\s+`))$/,e_=/(?:^|\s)(`(?!\s+`)((?:[^`]+))`(?!\s+`))/g,t_=Ie.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",le(this.options.HTMLAttributes,t),0]},addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[kr({find:QE,type:this.type})]},addPasteRules(){return[Zn({find:e_,type:this.type})]}}),n_=/^```([a-z]+)?[\s\n]$/,r_=/^~~~([a-z]+)?[\s\n]$/,F1=ue.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:null,parseHTML:t=>{var e;const{languageClassPrefix:n}=this.options,s=[...((e=t.firstElementChild)===null||e===void 0?void 0:e.classList)||[]].filter(o=>o.startsWith(n)).map(o=>o.replace(n,""))[0];return s||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",le(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type)return!1;const s=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(` + `,this.registerClickListener()}onClick(e){var n;(n=this.editor)!=null&&n.isActive("container")?e.unsetContainer():e.setContainer("warning"),e.focus()}onActive(e){return e.isActive("container")}}class $E extends me{constructor(){super();H(this,"config")}onConfig(n){this.config=n,n.html?this.template=n.html:n.icon&&(this.template=`
${n.icon}
`),this.addEventListener("click",r=>{this.config&&this.config.onClick&&this.config.onClick(r,this.editor.aiEditor)})}}const se=(t,e)=>{window.customElements.get(t)||window.customElements.define(t,e)};se("aie-undo",s1);se("aie-undo",s1);se("aie-redo",N3);se("aie-brush",kE);se("aie-container",PE);se("aie-custom",$E);se("aie-eraser",dE);se("aie-heading",Lv);se("aie-font-family",Iv);se("aie-font-size",Hv);se("aie-bold",Bv);se("aie-italic",Pv);se("aie-underline",$v);se("aie-strike",zv);se("aie-link",tE);se("aie-source-code",nE);se("aie-code",uE);se("aie-subscript",Vv);se("aie-superscript",Uv);se("aie-highlight",Kv);se("aie-font-color",Wv);se("aie-divider",jv);se("aie-bullet-list",Gv);se("aie-ordered-list",Jv);se("aie-indent-decrease",Yv);se("aie-indent-increase",Xv);se("aie-align",eE);se("aie-todo",rE);se("aie-line-height",sE);se("aie-break",pE);se("aie-quote",oE);se("aie-image",aE);se("aie-video",lE);se("aie-code-block",cE);se("aie-hr",fE);se("aie-table",hE);se("aie-attachment",mE);se("aie-fullscreen",gE);se("aie-printer",bE);se("aie-emoji",xE);se("aie-ai",BE);const zE=["undo","redo","brush","eraser","divider","heading","font-family","font-size","divider","bold","italic","underline","strike","link","code","subscript","superscript","hr","todo","emoji","divider","highlight","font-color","divider","align","line-height","divider","bullet-list","ordered-list","indent-decrease","indent-increase","break","divider","image","video","attachment","quote","container","code-block","table","divider","source-code","printer","fullscreen","ai"];class VE extends HTMLElement{constructor(){super();H(this,"menuButtons",[])}connectedCallback(){const n=document.createElement("div");for(let r of this.menuButtons)n.appendChild(r);n.style.display="flex",n.style.flexWrap="wrap",this.appendChild(n)}onCreate(n,r){let i=r.toolbarKeys||zE;for(let s of i)if(s)try{if(typeof s=="string"){s=s.trim(),s==="|"&&(s="divider");const o=document.createElement("aie-"+s);if(o.classList.add("aie-menu-item"),o.onCreate(n,r),s!=="divider"){const a=re(s);a&&Ke(o,{appendTo:()=>n.editor.view.dom.closest(".aie-container"),content:a,theme:"aietip",arrow:!0})}this.menuButtons.push(o)}else{const o=s,a=document.createElement("aie-custom");if(a.classList.add("aie-menu-item"),o.id&&a.setAttribute("id",o.id),o.className&&a.classList.add(o.className),a.onCreate(n,r),a.onConfig(o),o.tip){const l=re(o.tip);l&&Ke(a,{appendTo:()=>n.editor.view.dom.closest(".aie-container"),content:l,theme:"aietip",arrow:!0})}o.onCreate&&o.onCreate(a,n.editor.aiEditor),this.menuButtons.push(a)}}catch{console.error("Can not create toolbar by key: "+s)}}onTransaction(n){for(let r of this.menuButtons)r.onTransaction(n)}}class UE extends HTMLElement{constructor(){super(...arguments);H(this,"count",0);H(this,"draggable",!0)}initDraggable(n){if(this.draggable=!!n,!this.draggable)return;let r,i,s=300,o=300,a,l,u;const c=f=>{f.preventDefault(),document.removeEventListener("mouseup",c),document.removeEventListener("mousemove",d)},d=f=>{const h=f.clientX-r,p=f.clientY-i;if(h==0&&p==0)return;let m=a+h,g=l+p;m{var p;f.target.closest("svg")&&(f.preventDefault(),document.addEventListener("mouseup",c),document.addEventListener("mousemove",d),u=(p=f.target.closest(".aie-container"))==null?void 0:p.parentElement,a=u.clientWidth,l=u.clientHeight,r=f.clientX,i=f.clientY)}),this.addEventListener("mouseup",c)}updateCharacters(){this.draggable?this.innerHTML=`
+ Powered by AiEditor, Characters: ${this.count} +
+ +
+
+ `:this.innerHTML=`
+ Powered by AiEditor, Characters: ${this.count} +
+ `}onCreate(n,r){this.count=n.editor.storage.characterCount.characters(),this.updateCharacters()}onTransaction(n){const r=n.editor.storage.characterCount.characters();r!=this.count&&(this.count=r,this.updateCharacters())}}const qE=/^\s*>\s$/,ZE=ue.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return["blockquote",le(this.options.HTMLAttributes,t),0]},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[vr({find:qE,type:this.type})]}}),KE=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,WE=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,jE=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,GE=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,JE=Ie.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return["strong",le(this.options.HTMLAttributes,t),0]},addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[kr({find:KE,type:this.type}),kr({find:jE,type:this.type})]},addPasteRules(){return[Zn({find:WE,type:this.type}),Zn({find:GE,type:this.type})]}}),YE=ue.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",le(this.options.HTMLAttributes,t),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),If=Ie.create({name:"textStyle",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"span",getAttrs:t=>t.hasAttribute("style")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["span",le(this.options.HTMLAttributes,t),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:t,commands:e})=>{const n=xs(t,this.type);return Object.entries(n).some(([,i])=>!!i)?!0:e.unsetMark(this.name)}}}}),Ff=/^\s*([-+*])\s$/,XE=ue.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:t}){return["ul",le(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(YE.name,this.editor.getAttributes(If.name)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=vr({find:Ff,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=vr({find:Ff,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(If.name),editor:this.editor})),[t]}}),QE=/(?:^|\s)(`(?!\s+`)((?:[^`]+))`(?!\s+`))$/,e_=/(?:^|\s)(`(?!\s+`)((?:[^`]+))`(?!\s+`))/g,t_=Ie.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",le(this.options.HTMLAttributes,t),0]},addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[kr({find:QE,type:this.type})]},addPasteRules(){return[Zn({find:e_,type:this.type})]}}),n_=/^```([a-z]+)?[\s\n]$/,r_=/^~~~([a-z]+)?[\s\n]$/,I1=ue.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:null,parseHTML:t=>{var e;const{languageClassPrefix:n}=this.options,s=[...((e=t.firstElementChild)===null||e===void 0?void 0:e.classList)||[]].filter(o=>o.startsWith(n)).map(o=>o.replace(n,""))[0];return s||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",le(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type)return!1;const s=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(` `);return!s||!o?!1:t.chain().command(({tr:a})=>(a.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:r}=e,{$from:i,empty:s}=n;if(!s||i.parent.type!==this.type||!(i.parentOffset===i.parent.nodeSize-2))return!1;const a=i.after();return a===void 0||r.nodeAt(a)?!1:t.commands.exitCode()}}},addInputRules(){return[mu({find:n_,type:this.type,getAttributes:t=>({language:t[1]})}),mu({find:r_,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new we({key:new Te("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),i=r?JSON.parse(r):void 0,s=i==null?void 0:i.mode;if(!n||!s)return!1;const{tr:o}=t.state;return t.state.selection.from===t.state.doc.nodeSize-(1+t.state.selection.$to.depth*2)?o.insert(t.state.selection.from-1,this.type.create({language:s})):o.replaceSelectionWith(this.type.create({language:s})),o.setSelection(X.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.insertText(n.replace(/\r\n?/g,` -`)),o.setMeta("paste",!0),t.dispatch(o),!0}}})]}}),i_=ue.create({name:"doc",topNode:!0,content:"block+"});function s_(t={}){return new we({view(e){return new o_(e,t)}})}class o_{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let s=o=>{this[i](o)};return e.dom.addEventListener(i,s),{name:i,handler:s}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r;if(n){let a=e.nodeBefore,l=e.nodeAfter;if(a||l){let u=this.editorView.nodeDOM(this.cursorPos-(a?a.nodeSize:0));if(u){let c=u.getBoundingClientRect(),d=a?c.bottom:c.top;a&&l&&(d=(d+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2),r={left:c.left,right:c.right,top:d-this.width/2,bottom:d+this.width/2}}}}if(!r){let a=this.editorView.coordsAtPos(this.cursorPos);r={left:a.left-this.width/2,right:a.left+this.width/2,top:a.top,bottom:a.bottom}}let i=this.editorView.dom.offsetParent;this.element||(this.element=i.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let s,o;if(!i||i==document.body&&getComputedStyle(i).position=="static")s=-pageXOffset,o=-pageYOffset;else{let a=i.getBoundingClientRect();s=a.left-i.scrollLeft,o=a.top-i.scrollTop}this.element.style.left=r.left-s+"px",this.element.style.top=r.top-o+"px",this.element.style.width=r.right-r.left+"px",this.element.style.height=r.bottom-r.top+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),i=r&&r.type.spec.disableDropCursor,s=typeof i=="function"?i(this.editorView,n,e):i;if(n&&!s){let o=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let a=Jp(this.editorView.state.doc,o,this.editorView.dragging.slice);a!=null&&(o=a)}this.setCursor(o),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){(e.target==this.editorView.dom||!this.editorView.dom.contains(e.relatedTarget))&&this.setCursor(null)}}const a_=xe.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[s_(this.options)]}});class Re extends ne{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return Re.valid(r)?new Re(r):ne.near(r)}content(){return P.empty}eq(e){return e instanceof Re&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new Re(e.resolve(n.pos))}getBookmark(){return new bc(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!l_(e)||!u_(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let i=n.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&Re.valid(e))return e;let i=e.pos,s=null;for(let o=e.depth;;o--){let a=e.node(o);if(n>0?e.indexAfter(o)0){s=a.child(n>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;i+=n;let l=e.doc.resolve(i);if(Re.valid(l))return l}for(;;){let o=n>0?s.firstChild:s.lastChild;if(!o){if(s.isAtom&&!s.isText&&!ee.isSelectable(s)){e=e.doc.resolve(i+s.nodeSize*n),r=!1;continue e}break}s=o,i+=n;let a=e.doc.resolve(i);if(Re.valid(a))return a}return null}}}Re.prototype.visible=!1;Re.findFrom=Re.findGapCursorFrom;ne.jsonID("gapcursor",Re);class bc{constructor(e){this.pos=e}map(e){return new bc(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return Re.valid(n)?new Re(n):ne.near(n)}}function l_(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(n-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||i.isAtom||i.type.spec.isolating)return!0;if(i.inlineContent)return!1}}return!0}function u_(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(n);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||i.isAtom||i.type.spec.isolating)return!0;if(i.inlineContent)return!1}}return!0}function c_(){return new we({props:{decorations:p_,createSelectionBetween(t,e,n){return e.pos==n.pos&&Re.valid(n)?new Re(n):null},handleClick:f_,handleKeyDown:d_,handleDOMEvents:{beforeinput:h_}}})}const d_=Xu({ArrowLeft:Ps("horiz",-1),ArrowRight:Ps("horiz",1),ArrowUp:Ps("vert",-1),ArrowDown:Ps("vert",1)});function Ps(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,s){let o=r.selection,a=e>0?o.$to:o.$from,l=o.empty;if(o instanceof X){if(!s.endOfTextblock(n)||a.depth==0)return!1;l=!1,a=r.doc.resolve(e>0?a.after():a.before())}let u=Re.findGapCursorFrom(a,e,l);return u?(i&&i(r.tr.setSelection(new Re(u))),!0):!1}}function f_(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!Re.valid(r))return!1;let i=t.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&ee.isSelectable(t.state.doc.nodeAt(i.inside))?!1:(t.dispatch(t.state.tr.setSelection(new Re(r))),!0)}function h_(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof Re))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let i=O.empty;for(let o=r.length-1;o>=0;o--)i=O.from(r[o].createAndFill(null,i));let s=t.state.tr.replace(n.pos,n.pos,new P(i,0,0));return s.setSelection(X.near(s.doc.resolve(n.pos+1))),t.dispatch(s),!1}function p_(t){if(!(t.selection instanceof Re))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",ve.create(t.doc,[Be.widget(t.selection.head,e,{key:"gapcursor"})])}const m_=xe.create({name:"gapCursor",addProseMirrorPlugins(){return[c_()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=oe(Z(t,"allowGapCursor",n)))!==null&&e!==void 0?e:null}}}),g_=ue.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",le(this.options.HTMLAttributes,t)]},renderText(){return` -`},addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:i,storedMarks:s}=n;if(i.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:a}=r.extensionManager,l=s||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:u,dispatch:c})=>{if(c&&l&&o){const d=l.filter(f=>a.includes(f.type.name));u.ensureMarks(d)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),H1=ue.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,le(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>mu({find:new RegExp(`^(#{1,${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}});var Io=200,qe=function(){};qe.prototype.append=function(e){return e.length?(e=qe.from(e),!this.length&&e||e.length=n?qe.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};qe.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};qe.prototype.forEach=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(e,n,r,0):this.forEachInvertedInner(e,n,r,0)};qe.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(s,o){return i.push(e(s,o))},n,r),i};qe.from=function(e){return e instanceof qe?e:e&&e.length?new B1(e):qe.empty};var B1=function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,s){return i==0&&s==this.length?this:new e(this.values.slice(i,s))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,s,o,a){for(var l=s;l=o;l--)if(i(this.values[l],a+l)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=Io)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=Io)return new e(i.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e}(qe);qe.empty=new B1([]);var b_=function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return ra&&this.right.forEachInner(r,Math.max(i-a,0),Math.min(this.length,s)-a,o+a)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,s,o){var a=this.left.length;if(i>a&&this.right.forEachInvertedInner(r,i-a,Math.max(s,a)-a,o+a)===!1||s=s?this.right.slice(r-s,i-s):this.left.slice(r,s).append(this.right.slice(0,i-s))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e}(qe);const y_=500;class $t{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,s;n&&(i=this.remapping(r,this.items.length),s=i.maps.length);let o=e.tr,a,l,u=[],c=[];return this.items.forEach((d,f)=>{if(!d.step){i||(i=this.remapping(r,f+1),s=i.maps.length),s--,c.push(d);return}if(i){c.push(new Zt(d.map));let h=d.step.map(i.slice(s)),p;h&&o.maybeStep(h).doc&&(p=o.mapping.maps[o.mapping.maps.length-1],u.push(new Zt(p,void 0,void 0,u.length+c.length))),s--,p&&i.appendMap(p,s)}else o.maybeStep(d.step);if(d.selection)return a=i?d.selection.map(i.slice(s)):d.selection,l=new $t(this.items.slice(0,r).append(c.reverse().concat(u)),this.eventCount-1),!1},this.items.length,0),{remaining:l,transform:o,selection:a}}addTransform(e,n,r,i){let s=[],o=this.eventCount,a=this.items,l=!i&&a.length?a.get(a.length-1):null;for(let c=0;ck_&&(a=x_(a,u),o-=u),new $t(a.append(s),o)}remapping(e,n){let r=new Gr;return this.items.forEach((i,s)=>{let o=i.mirrorOffset!=null&&s-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,o)},e,n),r}addMaps(e){return this.eventCount==0?this:new $t(this.items.append(e.map(n=>new Zt(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),s=e.mapping,o=e.steps.length,a=this.eventCount;this.items.forEach(f=>{f.selection&&a--},i);let l=n;this.items.forEach(f=>{let h=s.getMirror(--l);if(h==null)return;o=Math.min(o,h);let p=s.maps[h];if(f.step){let m=e.steps[h].invert(e.docs[h]),g=f.selection&&f.selection.map(s.slice(l+1,h));g&&a++,r.push(new Zt(p,m,g))}else r.push(new Zt(p))},i);let u=[];for(let f=n;fy_&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,i=[],s=0;return this.items.forEach((o,a)=>{if(a>=e)i.push(o),o.selection&&s++;else if(o.step){let l=o.step.map(n.slice(r)),u=l&&l.getMap();if(r--,u&&n.appendMap(u,r),l){let c=o.selection&&o.selection.map(n.slice(r));c&&s++;let d=new Zt(u.invert(),l,c),f,h=i.length-1;(f=i.length&&i[h].merge(d))?i[h]=f:i.push(d)}}else o.map&&r--},this.items.length,0),new $t(qe.from(i.reverse()),s)}}$t.empty=new $t(qe.empty,0);function x_(t,e){let n;return t.forEach((r,i)=>{if(r.selection&&e--==0)return n=i,!1}),t.slice(n)}class Zt{constructor(e,n,r,i){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new Zt(n.getMap().invert(),n,this.selection)}}}class Sn{constructor(e,n,r,i,s){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=s}}const k_=20;function v_(t,e,n,r){let i=n.getMeta(Un),s;if(i)return i.historyState;n.getMeta(__)&&(t=new Sn(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(Un))return o.getMeta(Un).redo?new Sn(t.done.addTransform(n,void 0,r,lo(e)),t.undone,Ff(n.mapping.maps[n.steps.length-1]),t.prevTime,t.prevComposition):new Sn(t.done,t.undone.addTransform(n,void 0,r,lo(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let a=n.getMeta("composition"),l=t.prevTime==0||!o&&t.prevComposition!=a&&(t.prevTime<(n.time||0)-r.newGroupDelay||!E_(n,t.prevRanges)),u=o?El(t.prevRanges,n.mapping):Ff(n.mapping.maps[n.steps.length-1]);return new Sn(t.done.addTransform(n,l?e.selection.getBookmark():void 0,r,lo(e)),$t.empty,u,n.time,a??t.prevComposition)}else return(s=n.getMeta("rebased"))?new Sn(t.done.rebased(n,s),t.undone.rebased(n,s),El(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Sn(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),El(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function E_(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,i)=>{for(let s=0;s=e[s]&&(n=!0)}),n}function Ff(t){let e=[];return t.forEach((n,r,i,s)=>e.push(i,s)),e}function El(t,e){if(!t)return null;let n=[];for(let r=0;r{let n=Un.getState(t);return!n||n.done.eventCount==0?!1:(e&&P1(n,t,e,!1),!0)},z1=(t,e)=>{let n=Un.getState(t);return!n||n.undone.eventCount==0?!1:(e&&P1(n,t,e,!0),!0)},w_=xe.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>$1(t,e),redo:()=>({state:t,dispatch:e})=>z1(t,e)}},addProseMirrorPlugins(){return[C_(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),S_=ue.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",le(this.options.HTMLAttributes,t)]},addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{const{$to:n}=e.selection,r=t();return n.parentOffset===0?r.insertContentAt(Math.max(n.pos-2,0),{type:this.name}):r.insertContent({type:this.name}),r.command(({tr:i,dispatch:s})=>{var o;if(s){const{$to:a}=i.selection,l=a.end();if(a.nodeAfter)a.nodeAfter.isTextblock?i.setSelection(X.create(i.doc,a.pos+1)):a.nodeAfter.isBlock?i.setSelection(ee.create(i.doc,a.pos)):i.setSelection(X.create(i.doc,a.pos));else{const u=(o=a.parent.type.contentMatch.defaultType)===null||o===void 0?void 0:o.create();u&&(i.insert(l,u),i.setSelection(X.create(i.doc,l+1)))}i.scrollIntoView()}return!0}).run()}}},addInputRules(){return[ac({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),A_=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,M_=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,T_=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,D_=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,O_=Ie.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",le(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[kr({find:A_,type:this.type}),kr({find:T_,type:this.type})]},addPasteRules(){return[Zn({find:M_,type:this.type}),Zn({find:D_,type:this.type})]}}),N_=ue.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",le(this.options.HTMLAttributes,t),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),L_=ue.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",le(this.options.HTMLAttributes,t),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),Bf=Ie.create({name:"textStyle",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"span",getAttrs:t=>t.hasAttribute("style")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["span",le(this.options.HTMLAttributes,t),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:t,commands:e})=>{const n=xs(t,this.type);return Object.entries(n).some(([,i])=>!!i)?!0:e.unsetMark(this.name)}}}}),Pf=/^(\d+)\.\s$/,R_=ue.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:e,...n}=t;return e===1?["ol",le(this.options.HTMLAttributes,n),0]:["ol",le(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(L_.name,this.editor.getAttributes(Bf.name)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=vr({find:Pf,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=vr({find:Pf,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Bf.name)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),I_=ue.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",le(this.options.HTMLAttributes,t),0]},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),F_=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,H_=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,B_=Ie.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",le(this.options.HTMLAttributes,t),0]},addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[kr({find:F_,type:this.type})]},addPasteRules(){return[Zn({find:H_,type:this.type})]}}),P_=ue.create({name:"text",group:"inline"}),$f=xe.create({name:"starterKit",addExtensions(){var t,e,n,r,i,s,o,a,l,u,c,d,f,h,p,m,g,y;const x=[];return this.options.blockquote!==!1&&x.push(ZE.configure((t=this.options)===null||t===void 0?void 0:t.blockquote)),this.options.bold!==!1&&x.push(JE.configure((e=this.options)===null||e===void 0?void 0:e.bold)),this.options.bulletList!==!1&&x.push(XE.configure((n=this.options)===null||n===void 0?void 0:n.bulletList)),this.options.code!==!1&&x.push(t_.configure((r=this.options)===null||r===void 0?void 0:r.code)),this.options.codeBlock!==!1&&x.push(F1.configure((i=this.options)===null||i===void 0?void 0:i.codeBlock)),this.options.document!==!1&&x.push(i_.configure((s=this.options)===null||s===void 0?void 0:s.document)),this.options.dropcursor!==!1&&x.push(a_.configure((o=this.options)===null||o===void 0?void 0:o.dropcursor)),this.options.gapcursor!==!1&&x.push(m_.configure((a=this.options)===null||a===void 0?void 0:a.gapcursor)),this.options.hardBreak!==!1&&x.push(g_.configure((l=this.options)===null||l===void 0?void 0:l.hardBreak)),this.options.heading!==!1&&x.push(H1.configure((u=this.options)===null||u===void 0?void 0:u.heading)),this.options.history!==!1&&x.push(w_.configure((c=this.options)===null||c===void 0?void 0:c.history)),this.options.horizontalRule!==!1&&x.push(S_.configure((d=this.options)===null||d===void 0?void 0:d.horizontalRule)),this.options.italic!==!1&&x.push(O_.configure((f=this.options)===null||f===void 0?void 0:f.italic)),this.options.listItem!==!1&&x.push(N_.configure((h=this.options)===null||h===void 0?void 0:h.listItem)),this.options.orderedList!==!1&&x.push(R_.configure((p=this.options)===null||p===void 0?void 0:p.orderedList)),this.options.paragraph!==!1&&x.push(I_.configure((m=this.options)===null||m===void 0?void 0:m.paragraph)),this.options.strike!==!1&&x.push(B_.configure((g=this.options)===null||g===void 0?void 0:g.strike)),this.options.text!==!1&&x.push(P_.configure((y=this.options)===null||y===void 0?void 0:y.text)),x}}),$_=Ie.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",le(this.options.HTMLAttributes,t),0]},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),z_=Ie.create({name:"textStyle",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"span",getAttrs:t=>t.hasAttribute("style")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["span",le(this.options.HTMLAttributes,t),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:t,commands:e})=>{const n=xs(t,this.type);return Object.entries(n).some(([,i])=>!!i)?!0:e.unsetMark(this.name)}}}}),V_=xe.create({name:"fontFamily",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:t=>{var e;return(e=t.style.fontFamily)===null||e===void 0?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.fontFamily?{style:`font-family: ${t.fontFamily.split(",").map(e=>CSS.escape(e.trim())).join(", ")}`}:{}}}}]},addCommands(){return{setFontFamily:t=>({chain:e})=>e().setMark("textStyle",{fontFamily:t}).run(),unsetFontFamily:()=>({chain:t})=>t().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()}}}),V1=t=>{const e=document.createElement("div");return e.classList.add("aie-loader-placeholder"),e.innerHTML=` +`)),o.setMeta("paste",!0),t.dispatch(o),!0}}})]}}),i_=ue.create({name:"doc",topNode:!0,content:"block+"});function s_(t={}){return new we({view(e){return new o_(e,t)}})}class o_{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let s=o=>{this[i](o)};return e.dom.addEventListener(i,s),{name:i,handler:s}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r;if(n){let a=e.nodeBefore,l=e.nodeAfter;if(a||l){let u=this.editorView.nodeDOM(this.cursorPos-(a?a.nodeSize:0));if(u){let c=u.getBoundingClientRect(),d=a?c.bottom:c.top;a&&l&&(d=(d+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2),r={left:c.left,right:c.right,top:d-this.width/2,bottom:d+this.width/2}}}}if(!r){let a=this.editorView.coordsAtPos(this.cursorPos);r={left:a.left-this.width/2,right:a.left+this.width/2,top:a.top,bottom:a.bottom}}let i=this.editorView.dom.offsetParent;this.element||(this.element=i.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let s,o;if(!i||i==document.body&&getComputedStyle(i).position=="static")s=-pageXOffset,o=-pageYOffset;else{let a=i.getBoundingClientRect();s=a.left-i.scrollLeft,o=a.top-i.scrollTop}this.element.style.left=r.left-s+"px",this.element.style.top=r.top-o+"px",this.element.style.width=r.right-r.left+"px",this.element.style.height=r.bottom-r.top+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),i=r&&r.type.spec.disableDropCursor,s=typeof i=="function"?i(this.editorView,n,e):i;if(n&&!s){let o=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let a=Jp(this.editorView.state.doc,o,this.editorView.dragging.slice);a!=null&&(o=a)}this.setCursor(o),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){(e.target==this.editorView.dom||!this.editorView.dom.contains(e.relatedTarget))&&this.setCursor(null)}}const a_=xe.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[s_(this.options)]}});class Re extends ne{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return Re.valid(r)?new Re(r):ne.near(r)}content(){return P.empty}eq(e){return e instanceof Re&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new Re(e.resolve(n.pos))}getBookmark(){return new yc(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!l_(e)||!u_(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let i=n.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&Re.valid(e))return e;let i=e.pos,s=null;for(let o=e.depth;;o--){let a=e.node(o);if(n>0?e.indexAfter(o)0){s=a.child(n>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;i+=n;let l=e.doc.resolve(i);if(Re.valid(l))return l}for(;;){let o=n>0?s.firstChild:s.lastChild;if(!o){if(s.isAtom&&!s.isText&&!ee.isSelectable(s)){e=e.doc.resolve(i+s.nodeSize*n),r=!1;continue e}break}s=o,i+=n;let a=e.doc.resolve(i);if(Re.valid(a))return a}return null}}}Re.prototype.visible=!1;Re.findFrom=Re.findGapCursorFrom;ne.jsonID("gapcursor",Re);class yc{constructor(e){this.pos=e}map(e){return new yc(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return Re.valid(n)?new Re(n):ne.near(n)}}function l_(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(n-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||i.isAtom||i.type.spec.isolating)return!0;if(i.inlineContent)return!1}}return!0}function u_(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(n);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||i.isAtom||i.type.spec.isolating)return!0;if(i.inlineContent)return!1}}return!0}function c_(){return new we({props:{decorations:p_,createSelectionBetween(t,e,n){return e.pos==n.pos&&Re.valid(n)?new Re(n):null},handleClick:f_,handleKeyDown:d_,handleDOMEvents:{beforeinput:h_}}})}const d_=Xu({ArrowLeft:Ps("horiz",-1),ArrowRight:Ps("horiz",1),ArrowUp:Ps("vert",-1),ArrowDown:Ps("vert",1)});function Ps(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,s){let o=r.selection,a=e>0?o.$to:o.$from,l=o.empty;if(o instanceof X){if(!s.endOfTextblock(n)||a.depth==0)return!1;l=!1,a=r.doc.resolve(e>0?a.after():a.before())}let u=Re.findGapCursorFrom(a,e,l);return u?(i&&i(r.tr.setSelection(new Re(u))),!0):!1}}function f_(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!Re.valid(r))return!1;let i=t.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&ee.isSelectable(t.state.doc.nodeAt(i.inside))?!1:(t.dispatch(t.state.tr.setSelection(new Re(r))),!0)}function h_(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof Re))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let i=O.empty;for(let o=r.length-1;o>=0;o--)i=O.from(r[o].createAndFill(null,i));let s=t.state.tr.replace(n.pos,n.pos,new P(i,0,0));return s.setSelection(X.near(s.doc.resolve(n.pos+1))),t.dispatch(s),!1}function p_(t){if(!(t.selection instanceof Re))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",ve.create(t.doc,[Be.widget(t.selection.head,e,{key:"gapcursor"})])}const m_=xe.create({name:"gapCursor",addProseMirrorPlugins(){return[c_()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=oe(Z(t,"allowGapCursor",n)))!==null&&e!==void 0?e:null}}}),g_=ue.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",le(this.options.HTMLAttributes,t)]},renderText(){return` +`},addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:i,storedMarks:s}=n;if(i.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:a}=r.extensionManager,l=s||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:u,dispatch:c})=>{if(c&&l&&o){const d=l.filter(f=>a.includes(f.type.name));u.ensureMarks(d)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),F1=ue.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,le(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>mu({find:new RegExp(`^(#{1,${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}});var Io=200,qe=function(){};qe.prototype.append=function(e){return e.length?(e=qe.from(e),!this.length&&e||e.length=n?qe.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};qe.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};qe.prototype.forEach=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(e,n,r,0):this.forEachInvertedInner(e,n,r,0)};qe.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(s,o){return i.push(e(s,o))},n,r),i};qe.from=function(e){return e instanceof qe?e:e&&e.length?new H1(e):qe.empty};var H1=function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,s){return i==0&&s==this.length?this:new e(this.values.slice(i,s))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,s,o,a){for(var l=s;l=o;l--)if(i(this.values[l],a+l)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=Io)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=Io)return new e(i.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e}(qe);qe.empty=new H1([]);var b_=function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return ra&&this.right.forEachInner(r,Math.max(i-a,0),Math.min(this.length,s)-a,o+a)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,s,o){var a=this.left.length;if(i>a&&this.right.forEachInvertedInner(r,i-a,Math.max(s,a)-a,o+a)===!1||s=s?this.right.slice(r-s,i-s):this.left.slice(r,s).append(this.right.slice(0,i-s))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e}(qe);const y_=500;class $t{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,s;n&&(i=this.remapping(r,this.items.length),s=i.maps.length);let o=e.tr,a,l,u=[],c=[];return this.items.forEach((d,f)=>{if(!d.step){i||(i=this.remapping(r,f+1),s=i.maps.length),s--,c.push(d);return}if(i){c.push(new Zt(d.map));let h=d.step.map(i.slice(s)),p;h&&o.maybeStep(h).doc&&(p=o.mapping.maps[o.mapping.maps.length-1],u.push(new Zt(p,void 0,void 0,u.length+c.length))),s--,p&&i.appendMap(p,s)}else o.maybeStep(d.step);if(d.selection)return a=i?d.selection.map(i.slice(s)):d.selection,l=new $t(this.items.slice(0,r).append(c.reverse().concat(u)),this.eventCount-1),!1},this.items.length,0),{remaining:l,transform:o,selection:a}}addTransform(e,n,r,i){let s=[],o=this.eventCount,a=this.items,l=!i&&a.length?a.get(a.length-1):null;for(let c=0;ck_&&(a=x_(a,u),o-=u),new $t(a.append(s),o)}remapping(e,n){let r=new Gr;return this.items.forEach((i,s)=>{let o=i.mirrorOffset!=null&&s-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,o)},e,n),r}addMaps(e){return this.eventCount==0?this:new $t(this.items.append(e.map(n=>new Zt(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),s=e.mapping,o=e.steps.length,a=this.eventCount;this.items.forEach(f=>{f.selection&&a--},i);let l=n;this.items.forEach(f=>{let h=s.getMirror(--l);if(h==null)return;o=Math.min(o,h);let p=s.maps[h];if(f.step){let m=e.steps[h].invert(e.docs[h]),g=f.selection&&f.selection.map(s.slice(l+1,h));g&&a++,r.push(new Zt(p,m,g))}else r.push(new Zt(p))},i);let u=[];for(let f=n;fy_&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,i=[],s=0;return this.items.forEach((o,a)=>{if(a>=e)i.push(o),o.selection&&s++;else if(o.step){let l=o.step.map(n.slice(r)),u=l&&l.getMap();if(r--,u&&n.appendMap(u,r),l){let c=o.selection&&o.selection.map(n.slice(r));c&&s++;let d=new Zt(u.invert(),l,c),f,h=i.length-1;(f=i.length&&i[h].merge(d))?i[h]=f:i.push(d)}}else o.map&&r--},this.items.length,0),new $t(qe.from(i.reverse()),s)}}$t.empty=new $t(qe.empty,0);function x_(t,e){let n;return t.forEach((r,i)=>{if(r.selection&&e--==0)return n=i,!1}),t.slice(n)}class Zt{constructor(e,n,r,i){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new Zt(n.getMap().invert(),n,this.selection)}}}class Sn{constructor(e,n,r,i,s){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=s}}const k_=20;function v_(t,e,n,r){let i=n.getMeta(Un),s;if(i)return i.historyState;n.getMeta(__)&&(t=new Sn(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(Un))return o.getMeta(Un).redo?new Sn(t.done.addTransform(n,void 0,r,lo(e)),t.undone,Hf(n.mapping.maps[n.steps.length-1]),t.prevTime,t.prevComposition):new Sn(t.done,t.undone.addTransform(n,void 0,r,lo(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let a=n.getMeta("composition"),l=t.prevTime==0||!o&&t.prevComposition!=a&&(t.prevTime<(n.time||0)-r.newGroupDelay||!E_(n,t.prevRanges)),u=o?El(t.prevRanges,n.mapping):Hf(n.mapping.maps[n.steps.length-1]);return new Sn(t.done.addTransform(n,l?e.selection.getBookmark():void 0,r,lo(e)),$t.empty,u,n.time,a??t.prevComposition)}else return(s=n.getMeta("rebased"))?new Sn(t.done.rebased(n,s),t.undone.rebased(n,s),El(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Sn(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),El(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function E_(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,i)=>{for(let s=0;s=e[s]&&(n=!0)}),n}function Hf(t){let e=[];return t.forEach((n,r,i,s)=>e.push(i,s)),e}function El(t,e){if(!t)return null;let n=[];for(let r=0;r{let n=Un.getState(t);return!n||n.done.eventCount==0?!1:(e&&B1(n,t,e,!1),!0)},$1=(t,e)=>{let n=Un.getState(t);return!n||n.undone.eventCount==0?!1:(e&&B1(n,t,e,!0),!0)},w_=xe.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>P1(t,e),redo:()=>({state:t,dispatch:e})=>$1(t,e)}},addProseMirrorPlugins(){return[C_(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),S_=ue.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",le(this.options.HTMLAttributes,t)]},addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{const{$to:n}=e.selection,r=t();return n.parentOffset===0?r.insertContentAt(Math.max(n.pos-2,0),{type:this.name}):r.insertContent({type:this.name}),r.command(({tr:i,dispatch:s})=>{var o;if(s){const{$to:a}=i.selection,l=a.end();if(a.nodeAfter)a.nodeAfter.isTextblock?i.setSelection(X.create(i.doc,a.pos+1)):a.nodeAfter.isBlock?i.setSelection(ee.create(i.doc,a.pos)):i.setSelection(X.create(i.doc,a.pos));else{const u=(o=a.parent.type.contentMatch.defaultType)===null||o===void 0?void 0:o.create();u&&(i.insert(l,u),i.setSelection(X.create(i.doc,l+1)))}i.scrollIntoView()}return!0}).run()}}},addInputRules(){return[ac({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),A_=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,M_=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,T_=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,D_=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,O_=Ie.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",le(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[kr({find:A_,type:this.type}),kr({find:T_,type:this.type})]},addPasteRules(){return[Zn({find:M_,type:this.type}),Zn({find:D_,type:this.type})]}}),N_=ue.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",le(this.options.HTMLAttributes,t),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),L_=ue.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",le(this.options.HTMLAttributes,t),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),Pf=Ie.create({name:"textStyle",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"span",getAttrs:t=>t.hasAttribute("style")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["span",le(this.options.HTMLAttributes,t),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:t,commands:e})=>{const n=xs(t,this.type);return Object.entries(n).some(([,i])=>!!i)?!0:e.unsetMark(this.name)}}}}),$f=/^(\d+)\.\s$/,R_=ue.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:e,...n}=t;return e===1?["ol",le(this.options.HTMLAttributes,n),0]:["ol",le(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(L_.name,this.editor.getAttributes(Pf.name)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=vr({find:$f,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=vr({find:$f,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Pf.name)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),I_=ue.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",le(this.options.HTMLAttributes,t),0]},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),F_=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,H_=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,B_=Ie.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",le(this.options.HTMLAttributes,t),0]},addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[kr({find:F_,type:this.type})]},addPasteRules(){return[Zn({find:H_,type:this.type})]}}),P_=ue.create({name:"text",group:"inline"}),$_=xe.create({name:"starterKit",addExtensions(){var t,e,n,r,i,s,o,a,l,u,c,d,f,h,p,m,g,y;const x=[];return this.options.blockquote!==!1&&x.push(ZE.configure((t=this.options)===null||t===void 0?void 0:t.blockquote)),this.options.bold!==!1&&x.push(JE.configure((e=this.options)===null||e===void 0?void 0:e.bold)),this.options.bulletList!==!1&&x.push(XE.configure((n=this.options)===null||n===void 0?void 0:n.bulletList)),this.options.code!==!1&&x.push(t_.configure((r=this.options)===null||r===void 0?void 0:r.code)),this.options.codeBlock!==!1&&x.push(I1.configure((i=this.options)===null||i===void 0?void 0:i.codeBlock)),this.options.document!==!1&&x.push(i_.configure((s=this.options)===null||s===void 0?void 0:s.document)),this.options.dropcursor!==!1&&x.push(a_.configure((o=this.options)===null||o===void 0?void 0:o.dropcursor)),this.options.gapcursor!==!1&&x.push(m_.configure((a=this.options)===null||a===void 0?void 0:a.gapcursor)),this.options.hardBreak!==!1&&x.push(g_.configure((l=this.options)===null||l===void 0?void 0:l.hardBreak)),this.options.heading!==!1&&x.push(F1.configure((u=this.options)===null||u===void 0?void 0:u.heading)),this.options.history!==!1&&x.push(w_.configure((c=this.options)===null||c===void 0?void 0:c.history)),this.options.horizontalRule!==!1&&x.push(S_.configure((d=this.options)===null||d===void 0?void 0:d.horizontalRule)),this.options.italic!==!1&&x.push(O_.configure((f=this.options)===null||f===void 0?void 0:f.italic)),this.options.listItem!==!1&&x.push(N_.configure((h=this.options)===null||h===void 0?void 0:h.listItem)),this.options.orderedList!==!1&&x.push(R_.configure((p=this.options)===null||p===void 0?void 0:p.orderedList)),this.options.paragraph!==!1&&x.push(I_.configure((m=this.options)===null||m===void 0?void 0:m.paragraph)),this.options.strike!==!1&&x.push(B_.configure((g=this.options)===null||g===void 0?void 0:g.strike)),this.options.text!==!1&&x.push(P_.configure((y=this.options)===null||y===void 0?void 0:y.text)),x}}),z_=Ie.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",le(this.options.HTMLAttributes,t),0]},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),V_=Ie.create({name:"textStyle",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"span",getAttrs:t=>t.hasAttribute("style")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["span",le(this.options.HTMLAttributes,t),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:t,commands:e})=>{const n=xs(t,this.type);return Object.entries(n).some(([,i])=>!!i)?!0:e.unsetMark(this.name)}}}}),U_=xe.create({name:"fontFamily",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:t=>{var e;return(e=t.style.fontFamily)===null||e===void 0?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.fontFamily?{style:`font-family: ${t.fontFamily.split(",").map(e=>CSS.escape(e.trim())).join(", ")}`}:{}}}}]},addCommands(){return{setFontFamily:t=>({chain:e})=>e().setMark("textStyle",{fontFamily:t}).run(),unsetFontFamily:()=>({chain:t})=>t().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()}}}),z1=t=>{const e=document.createElement("div");return e.classList.add("aie-loader-placeholder"),e.innerHTML=` - `,Be.widget(t.pos,e,{id:t.id})},U_=t=>{const e=document.createElement("div");return e.classList.add("aie-loader-placeholder"),e.style.height="20px",e.style.display="inline-block",e.innerHTML=` + `,Be.widget(t.pos,e,{id:t.id})},q_=t=>{const e=document.createElement("div");return e.classList.add("aie-loader-placeholder"),e.style.height="20px",e.style.display="inline-block",e.innerHTML=` ${t.text} - `,Be.widget(t.pos,e,{id:t.id})},q_=(t,e,n,r)=>{const i=new FormData;return i.append(r,t),new Promise((s,o)=>{fetch(e,{method:"post",headers:{Accept:"application/json",...n},body:i}).then(a=>a.json()).then(a=>{s(a)}).catch(a=>{o(a)})})},Z_=(t,e,n,r)=>{let i=new FileReader;return new Promise((s,o)=>{i.onload=()=>s({errorCode:0,data:{src:i.result,href:t.name}}),i.onerror=()=>o(i.error),setTimeout(()=>i.readAsDataURL(t),5e3*Math.random())})},yc=t=>t?q_:Z_,zf=new Te("aie-attachment-plugin"),_i="attachment_action",K_=xe.create({name:"attachment",addOptions(){return{uploadUrl:"",uploadHeaders:{},HTMLAttributes:{}}},addCommands(){return{uploadAttachment:t=>()=>{const e=typeof this.options.uploadHeaders=="object"?this.options.uploadHeaders:typeof this.options.uploadHeaders=="function"?this.options.uploadHeaders():{};if(this.options.uploaderEvent&&this.options.uploaderEvent.onUploadBefore&&this.options.uploaderEvent.onUploadBefore(t,this.options.uploadUrl,e)===!1)return!1;const n=Aa(),{state:{tr:r},view:i,schema:s}=this.editor;r.selection.empty||r.deleteSelection(),i.dispatch(r.setMeta(_i,{type:"add",id:n,pos:r.selection.from,text:t.name}));const o=this.options.uploader||yc(this.options.uploadUrl),a=this.options.uploadFormName||"attachment";return o(t,this.options.uploadUrl,e,a).then(l=>{var u;if((u=this.options.uploaderEvent)!=null&&u.onSuccess){const c=this.options.uploaderEvent.onSuccess(t,l);if(typeof c=="boolean"&&!c)return;typeof c=="object"&&(l=c)}if(l.errorCode===0&&l.data&&l.data.href){let d=zf.getState(this.editor.state).find(void 0,void 0,h=>h.id==n);const f=l.data.fileName||t.name;i.dispatch(i.state.tr.insertText(` ${f} `,d[0].from).addMark(d[0].from+1,f.length+d[0].from+1,s.marks.link.create({href:l.data.href,target:"_blank"})).setMeta(_i,{type:"remove",id:n}))}else i.dispatch(r.setMeta(_i,{type:"remove",id:n})),this.options.uploaderEvent&&this.options.uploaderEvent.onFailed&&this.options.uploaderEvent.onFailed(t,l)}).catch(l=>{const{state:{tr:u},view:c}=this.editor;c.dispatch(u.setMeta(_i,{type:"remove",id:n})),this.options.uploaderEvent&&this.options.uploaderEvent.onError&&this.options.uploaderEvent.onError(t,l)}),!0}}},addProseMirrorPlugins(){const t=this.editor;return[new we({key:zf,state:{init:()=>ve.empty,apply:(e,n)=>{const r=e.getMeta(_i);return n=n.map(e.mapping,e.doc),r&&r.type==="add"?n=n.add(e.doc,[U_(r)]):r&&r.type==="remove"&&(n=n.remove(n.find(void 0,void 0,i=>i.id==r.id))),n}},props:{decorations(e){return this.getState(e)},handleDOMEvents:{drop(e,n){if(!(n.dataTransfer&&n.dataTransfer.files&&n.dataTransfer.files.length))return!1;const i=Array.from(n.dataTransfer.files).filter(s=>!/video/i.test(s.type)&&!/image/i.test(s.type));return n.preventDefault(),i.forEach(s=>{t.commands.uploadAttachment(s)}),!0}}}})]}}),W_=xe.create({name:"painter",addCommands(){return{setPainter:t=>({view:{dispatch:e,state:{tr:n},dom:r}})=>(r.style.cursor="context-menu",e(n.setMeta("painterAction",{type:"start",marks:t})),!0)}},addProseMirrorPlugins(){return[new we({key:new Te("aie-painter"),state:{init:()=>[],apply:(t,e)=>{const n=t.getMeta("painterAction");return n&&n.type==="start"?e=n.marks:n&&n.type==="end"&&(e=[]),e}},props:{handleDOMEvents:{mousedown(t,e){const n=this.getState(t.state);if(!n||n.length==0)return!1;const r=()=>{document.removeEventListener("mouseup",r);let{dispatch:i,state:{tr:s,selection:o},dom:a}=t;a.style.cursor="",s=s.removeMark(o.from,o.to);for(let l of n)l.type.name!="link"&&(s=s.addMark(o.from,o.to,l));i(s.setMeta("painterAction",{type:"end"}))};return document.addEventListener("mouseup",r),!0}}}})]}}),j_=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,G_=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,J_=Ie.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:t=>t.getAttribute("data-color")||t.style.backgroundColor,renderHTML:t=>t.color?{"data-color":t.color,style:`background-color: ${t.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:t}){return["mark",le(this.options.HTMLAttributes,t),0]},addCommands(){return{setHighlight:t=>({commands:e})=>e.setMark(this.name,t),toggleHighlight:t=>({commands:e})=>e.toggleMark(this.name,t),unsetHighlight:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[kr({find:j_,type:this.type})]},addPasteRules(){return[Zn({find:G_,type:this.type})]}}),Y_=xe.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var e;return(e=t.style.color)===null||e===void 0?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.color?{style:`color: ${t.color}`}:{}}}}]},addCommands(){return{setColor:t=>({chain:e})=>e().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),X_=xe.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:t=>{var e;return(e=t.style.fontSize)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.fontSize?{style:`font-size: ${t.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:t=>({chain:e})=>e().setMark("textStyle",{fontSize:t}).run(),unsetFontSize:()=>({chain:t})=>t().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),Q_=xe.create({name:"lineHeight",addOptions(){return{types:["heading","paragraph"],heights:["100%","125%","150%","200%","250%","300%"],defaultHeight:"100%"}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:this.options.defaultHeight,parseHTML:t=>t.style.lineHeight||this.options.defaultHeight,renderHTML:t=>t.lineHeight===this.options.defaultHeight?{}:{style:`line-height: ${t.lineHeight}`}}}}]},addCommands(){return{setLineHeight:t=>({commands:e})=>this.options.heights.includes(t)?this.options.types.every(n=>e.updateAttributes(n,{lineHeight:t})):!1,unsetLineHeight:()=>({commands:t})=>this.options.types.every(e=>t.resetAttributes(e,"lineHeight"))}}}),eC=xe.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:"left"}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>t.style.textAlign||this.options.defaultAlignment,renderHTML:t=>t.textAlign===this.options.defaultAlignment?{}:{style:`text-align: ${t.textAlign}`}}}}]},addCommands(){return{setTextAlign:t=>({commands:e})=>this.options.alignments.includes(t)?this.options.types.map(n=>e.updateAttributes(n,{textAlign:t})).every(n=>n):!1,unsetTextAlign:()=>({commands:t})=>this.options.types.map(e=>t.resetAttributes(e,"textAlign")).every(e=>e)}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),tC=xe.create({name:"indent",addOptions(){return{types:["listItem","paragraph"],minLevel:0,maxLevel:8}},addGlobalAttributes(){return[{types:this.options.types,attributes:{indent:{default:0,parseHTML:t=>{const e=Number(t.getAttribute("data-indent"));return e&&e>this.options.minLevel?e:null},renderHTML:t=>t.indent?{style:`text-indent: ${(t==null?void 0:t.indent)*10}px`,"data-indent":t==null?void 0:t.indent}:{}}}}]},addCommands(){const t=(r,i,s)=>{var a;const o=(a=r==null?void 0:r.doc)==null?void 0:a.nodeAt(i);if(o){const l=(o.attrs.indent||0)+s,{minLevel:u,maxLevel:c}=this.options,d=lc?c:l;if(d!==o.attrs.indent){const{indent:f,...h}=o.attrs,p=d>u?{...h,indent:d}:h;return r.setNodeMarkup(i,o.type,p,o.marks)}}return r},e=(r,i)=>{const{doc:s,selection:o}=r;if(s&&o&&(o instanceof X||o instanceof Nt)){const{from:a,to:l}=o;s.nodesBetween(a,l,(u,c)=>this.options.types.includes(u.type.name)?(r=t(r,c,i),!1):!0)}return r},n=r=>()=>({tr:i,state:s,dispatch:o})=>{const{selection:a}=s;return i=i.setSelection(a),i=e(i,r),i.docChanged?(o==null||o(i),!0):!1};return{indent:n(1),outdent:n(-1)}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.indent(),"Shift-Tab":()=>this.editor.commands.outdent()}}}),nC=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,rC=ue.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:t}){return["img",le(this.options.HTMLAttributes,t)]},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[ac({find:nC,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),U1=(t,e,n)=>{const r=t.querySelector(".resize-obj"),i=10;let s,o,a,l;const u=f=>{f.preventDefault(),e.addEventListener("mousemove",c),e.addEventListener("mouseup",d),e.addEventListener("mouseleave",d),s=f.clientX,o=Number(r.getAttribute("data-with"))||r.clientWidth,a=f.target.getAttribute("data-position"),l=e.clientWidth-100},c=f=>{const h=f.clientX-s;if(h==0)return;const p=a==="right"?h>0:h<0;let m=o+Math.abs(h)*(p?1:-1);m>=l&&(m=l),m{e.removeEventListener("mousemove",c),e.removeEventListener("mouseup",d),e.removeEventListener("mouseleave",d);const f={width:Number(r.getAttribute("data-width"))};n(f)};for(let f of t.querySelector(".aie-resize").children)f.addEventListener("mousedown",u)},Vf=new Te("aie-image-plugin"),Ci="image_action",iC=rC.extend({name:"image",draggable:!0,selectable:!0,addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),uploadUrl:"",uploadHeaders:{},uploader:void 0,defaultSize:350}},allowGapCursor(){return!this.options.inline},addAttributes(){return{src:{default:"",parseHTML:t=>`${t.getAttribute("src")??""}`},alt:{default:""},title:{default:""},width:{default:this.options.defaultSize},height:{default:"auto"},align:{default:"left"}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:t}){return["img",le(this.options.HTMLAttributes,t)]},addCommands(){var t;return{...(t=this.parent)==null?void 0:t.call(this),uploadImage:e=>()=>{const n=typeof this.options.uploadHeaders=="object"?this.options.uploadHeaders:typeof this.options.uploadHeaders=="function"?this.options.uploadHeaders():{};if(this.options.uploaderEvent&&this.options.uploaderEvent.onUploadBefore&&this.options.uploaderEvent.onUploadBefore(e,this.options.uploadUrl,n)===!1)return!1;const r=Aa(),{state:{tr:i},view:s,schema:o}=this.editor;i.selection.empty||i.deleteSelection(),s.dispatch(i.setMeta(Ci,{type:"add",id:r,pos:i.selection.from}));const a=this.options.uploader||yc(this.options.uploadUrl),l=this.options.uploadFormName||"image";return a(e,this.options.uploadUrl,n,l).then(u=>{var c;if((c=this.options.uploaderEvent)!=null&&c.onSuccess){const d=this.options.uploaderEvent.onSuccess(e,u);if(typeof d=="boolean"&&!d)return;typeof d=="object"&&(u=d)}if(u.errorCode===0&&u.data&&u.data.src){let f=Vf.getState(this.editor.state).find(void 0,void 0,h=>h.id==r);s.dispatch(s.state.tr.insert(f[0].from,o.nodes.image.create({src:u.data.src,alt:u.data.alt})).setMeta(Ci,{type:"remove",id:r}))}else s.dispatch(i.setMeta(Ci,{type:"remove",id:r})),this.options.uploaderEvent&&this.options.uploaderEvent.onFailed&&this.options.uploaderEvent.onFailed(e,u)}).catch(u=>{const{state:{tr:c},view:d}=this.editor;d.dispatch(c.setMeta(Ci,{type:"remove",id:r})),this.options.uploaderEvent&&this.options.uploaderEvent.onError&&this.options.uploaderEvent.onError(e,u)}),!0}}},addNodeView(){return t=>{if(!this.editor.isEditable)return{};const e=document.createElement("div"),{src:n,width:r,height:i,align:s}=t.node.attrs;return e.classList.add(`align-${s}`),e.innerHTML=` + `,Be.widget(t.pos,e,{id:t.id})},Z_=(t,e,n,r)=>{const i=new FormData;return i.append(r,t),new Promise((s,o)=>{fetch(e,{method:"post",headers:{Accept:"application/json",...n},body:i}).then(a=>a.json()).then(a=>{s(a)}).catch(a=>{o(a)})})},K_=(t,e,n,r)=>{let i=new FileReader;return new Promise((s,o)=>{i.onload=()=>s({errorCode:0,data:{src:i.result,href:t.name}}),i.onerror=()=>o(i.error),setTimeout(()=>i.readAsDataURL(t),5e3*Math.random())})},xc=t=>t?Z_:K_,zf=new Te("aie-attachment-plugin"),_i="attachment_action",W_=xe.create({name:"attachment",addOptions(){return{uploadUrl:"",uploadHeaders:{},HTMLAttributes:{}}},addCommands(){return{uploadAttachment:t=>()=>{const e=typeof this.options.uploadHeaders=="object"?this.options.uploadHeaders:typeof this.options.uploadHeaders=="function"?this.options.uploadHeaders():{};if(this.options.uploaderEvent&&this.options.uploaderEvent.onUploadBefore&&this.options.uploaderEvent.onUploadBefore(t,this.options.uploadUrl,e)===!1)return!1;const n=Aa(),{state:{tr:r},view:i,schema:s}=this.editor;r.selection.empty||r.deleteSelection(),i.dispatch(r.setMeta(_i,{type:"add",id:n,pos:r.selection.from,text:t.name}));const o=this.options.uploader||xc(this.options.uploadUrl),a=this.options.uploadFormName||"attachment";return o(t,this.options.uploadUrl,e,a).then(l=>{var u;if((u=this.options.uploaderEvent)!=null&&u.onSuccess){const c=this.options.uploaderEvent.onSuccess(t,l);if(typeof c=="boolean"&&!c)return;typeof c=="object"&&(l=c)}if(l.errorCode===0&&l.data&&l.data.href){let d=zf.getState(this.editor.state).find(void 0,void 0,h=>h.id==n);const f=l.data.fileName||t.name;i.dispatch(i.state.tr.insertText(` ${f} `,d[0].from).addMark(d[0].from+1,f.length+d[0].from+1,s.marks.link.create({href:l.data.href,target:"_blank"})).setMeta(_i,{type:"remove",id:n}))}else i.dispatch(r.setMeta(_i,{type:"remove",id:n})),this.options.uploaderEvent&&this.options.uploaderEvent.onFailed&&this.options.uploaderEvent.onFailed(t,l)}).catch(l=>{const{state:{tr:u},view:c}=this.editor;c.dispatch(u.setMeta(_i,{type:"remove",id:n})),this.options.uploaderEvent&&this.options.uploaderEvent.onError&&this.options.uploaderEvent.onError(t,l)}),!0}}},addProseMirrorPlugins(){const t=this.editor;return[new we({key:zf,state:{init:()=>ve.empty,apply:(e,n)=>{const r=e.getMeta(_i);return n=n.map(e.mapping,e.doc),r&&r.type==="add"?n=n.add(e.doc,[q_(r)]):r&&r.type==="remove"&&(n=n.remove(n.find(void 0,void 0,i=>i.id==r.id))),n}},props:{decorations(e){return this.getState(e)},handleDOMEvents:{drop(e,n){if(!(n.dataTransfer&&n.dataTransfer.files&&n.dataTransfer.files.length))return!1;const i=Array.from(n.dataTransfer.files).filter(s=>!/video/i.test(s.type)&&!/image/i.test(s.type));return n.preventDefault(),i.forEach(s=>{t.commands.uploadAttachment(s)}),!0}}}})]}}),j_=xe.create({name:"painter",addCommands(){return{setPainter:t=>({view:{dispatch:e,state:{tr:n},dom:r}})=>(r.style.cursor="context-menu",e(n.setMeta("painterAction",{type:"start",marks:t})),!0)}},addProseMirrorPlugins(){return[new we({key:new Te("aie-painter"),state:{init:()=>[],apply:(t,e)=>{const n=t.getMeta("painterAction");return n&&n.type==="start"?e=n.marks:n&&n.type==="end"&&(e=[]),e}},props:{handleDOMEvents:{mousedown(t,e){const n=this.getState(t.state);if(!n||n.length==0)return!1;const r=()=>{document.removeEventListener("mouseup",r);let{dispatch:i,state:{tr:s,selection:o},dom:a}=t;a.style.cursor="",s=s.removeMark(o.from,o.to);for(let l of n)l.type.name!="link"&&(s=s.addMark(o.from,o.to,l));i(s.setMeta("painterAction",{type:"end"}))};return document.addEventListener("mouseup",r),!0}}}})]}}),G_=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,J_=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,Y_=Ie.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:t=>t.getAttribute("data-color")||t.style.backgroundColor,renderHTML:t=>t.color?{"data-color":t.color,style:`background-color: ${t.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:t}){return["mark",le(this.options.HTMLAttributes,t),0]},addCommands(){return{setHighlight:t=>({commands:e})=>e.setMark(this.name,t),toggleHighlight:t=>({commands:e})=>e.toggleMark(this.name,t),unsetHighlight:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[kr({find:G_,type:this.type})]},addPasteRules(){return[Zn({find:J_,type:this.type})]}}),X_=xe.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var e;return(e=t.style.color)===null||e===void 0?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.color?{style:`color: ${t.color}`}:{}}}}]},addCommands(){return{setColor:t=>({chain:e})=>e().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),Q_=xe.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:t=>{var e;return(e=t.style.fontSize)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.fontSize?{style:`font-size: ${t.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:t=>({chain:e})=>e().setMark("textStyle",{fontSize:t}).run(),unsetFontSize:()=>({chain:t})=>t().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),eC=xe.create({name:"lineHeight",addOptions(){return{types:["heading","paragraph"],heights:["100%","125%","150%","200%","250%","300%"],defaultHeight:"100%"}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:this.options.defaultHeight,parseHTML:t=>t.style.lineHeight||this.options.defaultHeight,renderHTML:t=>t.lineHeight===this.options.defaultHeight?{}:{style:`line-height: ${t.lineHeight}`}}}}]},addCommands(){return{setLineHeight:t=>({commands:e})=>this.options.heights.includes(t)?this.options.types.every(n=>e.updateAttributes(n,{lineHeight:t})):!1,unsetLineHeight:()=>({commands:t})=>this.options.types.every(e=>t.resetAttributes(e,"lineHeight"))}}}),tC=xe.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:"left"}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>t.style.textAlign||this.options.defaultAlignment,renderHTML:t=>t.textAlign===this.options.defaultAlignment?{}:{style:`text-align: ${t.textAlign}`}}}}]},addCommands(){return{setTextAlign:t=>({commands:e})=>this.options.alignments.includes(t)?this.options.types.map(n=>e.updateAttributes(n,{textAlign:t})).every(n=>n):!1,unsetTextAlign:()=>({commands:t})=>this.options.types.map(e=>t.resetAttributes(e,"textAlign")).every(e=>e)}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),nC=xe.create({name:"indent",addOptions(){return{types:["listItem","paragraph"],minLevel:0,maxLevel:8}},addGlobalAttributes(){return[{types:this.options.types,attributes:{indent:{default:0,parseHTML:t=>{const e=Number(t.getAttribute("data-indent"));return e&&e>this.options.minLevel?e:null},renderHTML:t=>t.indent?{style:`text-indent: ${(t==null?void 0:t.indent)*10}px`,"data-indent":t==null?void 0:t.indent}:{}}}}]},addCommands(){const t=(r,i,s)=>{var a;const o=(a=r==null?void 0:r.doc)==null?void 0:a.nodeAt(i);if(o){const l=(o.attrs.indent||0)+s,{minLevel:u,maxLevel:c}=this.options,d=lc?c:l;if(d!==o.attrs.indent){const{indent:f,...h}=o.attrs,p=d>u?{...h,indent:d}:h;return r.setNodeMarkup(i,o.type,p,o.marks)}}return r},e=(r,i)=>{const{doc:s,selection:o}=r;if(s&&o&&(o instanceof X||o instanceof Nt)){const{from:a,to:l}=o;s.nodesBetween(a,l,(u,c)=>this.options.types.includes(u.type.name)?(r=t(r,c,i),!1):!0)}return r},n=r=>()=>({tr:i,state:s,dispatch:o})=>{const{selection:a}=s;return i=i.setSelection(a),i=e(i,r),i.docChanged?(o==null||o(i),!0):!1};return{indent:n(1),outdent:n(-1)}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.indent(),"Shift-Tab":()=>this.editor.commands.outdent()}}}),rC=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,iC=ue.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:t}){return["img",le(this.options.HTMLAttributes,t)]},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[ac({find:rC,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),V1=(t,e,n)=>{const r=t.querySelector(".resize-obj"),i=10;let s,o,a,l;const u=f=>{f.preventDefault(),e.addEventListener("mousemove",c),e.addEventListener("mouseup",d),e.addEventListener("mouseleave",d),s=f.clientX,o=Number(r.getAttribute("data-with"))||r.clientWidth,a=f.target.getAttribute("data-position"),l=e.clientWidth-100},c=f=>{const h=f.clientX-s;if(h==0)return;const p=a==="right"?h>0:h<0;let m=o+Math.abs(h)*(p?1:-1);m>=l&&(m=l),m{e.removeEventListener("mousemove",c),e.removeEventListener("mouseup",d),e.removeEventListener("mouseleave",d);const f={width:Number(r.getAttribute("data-width"))};n(f)};for(let f of t.querySelector(".aie-resize").children)f.addEventListener("mousedown",u)},Vf=new Te("aie-image-plugin"),Ci="image_action",sC=iC.extend({name:"image",draggable:!0,selectable:!0,addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),uploadUrl:"",uploadHeaders:{},uploader:void 0,defaultSize:350}},allowGapCursor(){return!this.options.inline},addAttributes(){return{src:{default:"",parseHTML:t=>`${t.getAttribute("src")??""}`},alt:{default:""},title:{default:""},width:{default:this.options.defaultSize},height:{default:"auto"},align:{default:"left"}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:t}){return["img",le(this.options.HTMLAttributes,t)]},addCommands(){var t;return{...(t=this.parent)==null?void 0:t.call(this),uploadImage:e=>()=>{const n=typeof this.options.uploadHeaders=="object"?this.options.uploadHeaders:typeof this.options.uploadHeaders=="function"?this.options.uploadHeaders():{};if(this.options.uploaderEvent&&this.options.uploaderEvent.onUploadBefore&&this.options.uploaderEvent.onUploadBefore(e,this.options.uploadUrl,n)===!1)return!1;const r=Aa(),{state:{tr:i},view:s,schema:o}=this.editor;i.selection.empty||i.deleteSelection(),s.dispatch(i.setMeta(Ci,{type:"add",id:r,pos:i.selection.from}));const a=this.options.uploader||xc(this.options.uploadUrl),l=this.options.uploadFormName||"image";return a(e,this.options.uploadUrl,n,l).then(u=>{var c;if((c=this.options.uploaderEvent)!=null&&c.onSuccess){const d=this.options.uploaderEvent.onSuccess(e,u);if(typeof d=="boolean"&&!d)return;typeof d=="object"&&(u=d)}if(u.errorCode===0&&u.data&&u.data.src){let f=Vf.getState(this.editor.state).find(void 0,void 0,h=>h.id==r);s.dispatch(s.state.tr.insert(f[0].from,o.nodes.image.create({src:u.data.src,alt:u.data.alt})).setMeta(Ci,{type:"remove",id:r}))}else s.dispatch(i.setMeta(Ci,{type:"remove",id:r})),this.options.uploaderEvent&&this.options.uploaderEvent.onFailed&&this.options.uploaderEvent.onFailed(e,u)}).catch(u=>{const{state:{tr:c},view:d}=this.editor;d.dispatch(c.setMeta(Ci,{type:"remove",id:r})),this.options.uploaderEvent&&this.options.uploaderEvent.onError&&this.options.uploaderEvent.onError(e,u)}),!0}}},addNodeView(){return t=>{if(!this.editor.isEditable)return{};const e=document.createElement("div"),{src:n,width:r,height:i,align:s}=t.node.attrs;return e.classList.add(`align-${s}`),e.innerHTML=`
@@ -353,16 +363,16 @@ ${n}`,l=this.wrapPayload(a);o.start(typeof l=="string"?l:JSON.stringify(l))};thi
- `,U1(e,t.editor.view.dom,o=>t.editor.commands.updateAttributes("image",o)),{dom:e}}},addProseMirrorPlugins(){const t=this.editor;return[new we({key:Vf,state:{init:()=>ve.empty,apply:(e,n)=>{const r=e.getMeta(Ci);if(r){let i=!1;const s=n.map(e.mapping,e.doc,{onRemove:o=>{i=!0}});i||(n=s),r.type==="add"?n=n.add(e.doc,[V1(r)]):r.type==="remove"&&(n=n.remove(n.find(void 0,void 0,o=>o.id==r.id)))}return n}},props:{decorations(e){return this.getState(e)},handlePaste:(e,n)=>{var i;const r=Array.from(((i=n.clipboardData)==null?void 0:i.items)||[]);for(const s of r)if(s.type.indexOf("image")===0){n.preventDefault();const o=s.getAsFile();o&&this.editor.commands.uploadImage(o)}},handleDOMEvents:{drop(e,n){if(!(n.dataTransfer&&n.dataTransfer.files&&n.dataTransfer.files.length))return!1;const i=Array.from(n.dataTransfer.files).filter(u=>/image/i.test(u.type));if(i.length===0)return!1;n.preventDefault();const{state:{tr:s,doc:o},dispatch:a}=e,l=e.posAtCoords({left:n.clientX,top:n.clientY});return a(s.setSelection(X.create(o,l.pos)).scrollIntoView()),i.forEach(u=>{t.commands.uploadImage(u)}),!0}},transformPastedHTML(e){const r=new DOMParser().parseFromString(e,"text/html"),i=r.documentElement.querySelector("body");if(i!=null&&i.children){const s=r.documentElement.querySelectorAll("p > img");for(const o of s){const a=o.parentNode,l=Array.prototype.indexOf.call(i.children,a);o.parentElement.prepend(o),i.insertBefore(o,i.children[l])}return i.innerHTML}return e}}})]}});var Eu,_u;if(typeof WeakMap<"u"){let t=new WeakMap;Eu=e=>t.get(e),_u=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;Eu=r=>{for(let i=0;i(n==10&&(n=0),t[n++]=r,t[n++]=i)}var Ne=class{constructor(t,e,n,r){this.width=t,this.height=e,this.map=n,this.problems=r}findCell(t){for(let e=0;e=n){(s||(s=[])).push({type:"overlong_rowspan",pos:c,n:y-k});break}const b=i+k*e;for(let E=0;Er&&(s+=u.attrs.colspan)}}for(let o=0;o1&&(n=!0)}e==-1?e=s:e!=s&&(e=Math.max(e,s))}return e}function aC(t,e,n){t.problems||(t.problems=[]);const r={};for(let i=0;i0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function uC(t){for(let e=t.depth;e>0;e--){const n=t.node(e).type.spec.tableRole;if(n==="cell"||n==="header_cell")return t.node(e)}return null}function Vt(t){const e=t.selection.$head;for(let n=e.depth;n>0;n--)if(e.node(n).type.spec.tableRole=="row")return!0;return!1}function Ma(t){const e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const n=bi(e.$head)||cC(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function cC(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n-e.nodeSize)}}function Cu(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function dC(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function xc(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function q1(t,e,n){const r=t.node(-1),i=Ne.get(r),s=t.start(-1),o=i.nextCell(t.pos-s,e,n);return o==null?null:t.node(0).resolve(s+o)}function _r(t,e,n=1){const r={...t,colspan:t.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,n),r.colwidth.some(i=>i>0)||(r.colwidth=null)),r}function Z1(t,e,n=1){const r={...t,colspan:t.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let i=0;ic!=n.pos-s);l.unshift(n.pos-s);const u=l.map(c=>{const d=r.nodeAt(c);if(!d)throw RangeError(`No cell with offset ${c} found`);const f=s+c+1;return new t0(a.resolve(f),a.resolve(f+d.content.size))});super(u[0].$from,u[0].$to,u),this.$anchorCell=e,this.$headCell=n}map(e,n){const r=e.resolve(n.map(this.$anchorCell.pos)),i=e.resolve(n.map(this.$headCell.pos));if(Cu(r)&&Cu(i)&&xc(r,i)){const s=this.$anchorCell.node(-1)!=r.node(-1);return s&&this.isRowSelection()?pn.rowSelection(r,i):s&&this.isColSelection()?pn.colSelection(r,i):new pn(r,i)}return X.between(r,i)}content(){const e=this.$anchorCell.node(-1),n=Ne.get(e),r=this.$anchorCell.start(-1),i=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),s={},o=[];for(let l=i.top;l0||g>0){let y=p.attrs;if(m>0&&(y=_r(y,0,m)),g>0&&(y=_r(y,y.colspan-g,g)),h.lefti.bottom){const y={...p.attrs,rowspan:Math.min(h.bottom,i.bottom)-Math.max(h.top,i.top)};h.top0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,i=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,i)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){const r=e.node(-1),i=Ne.get(r),s=e.start(-1),o=i.findCell(e.pos-s),a=i.findCell(n.pos-s),l=e.node(0);return o.top<=a.top?(o.top>0&&(e=l.resolve(s+i.map[o.left])),a.bottom0&&(n=l.resolve(s+i.map[a.left])),o.bottom0)return!1;const o=i+this.$anchorCell.nodeAfter.attrs.colspan,a=s+this.$headCell.nodeAfter.attrs.colspan;return Math.max(o,a)==n.width}eq(e){return e instanceof pn&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const r=e.node(-1),i=Ne.get(r),s=e.start(-1),o=i.findCell(e.pos-s),a=i.findCell(n.pos-s),l=e.node(0);return o.left<=a.left?(o.left>0&&(e=l.resolve(s+i.map[o.top*i.width])),a.right0&&(n=l.resolve(s+i.map[a.top*i.width])),o.right{e.push(Be.node(r,r+n.nodeSize,{class:"selectedCell"}))}),ve.create(t.doc,e)}function mC({$from:t,$to:e}){if(t.pos==e.pos||t.pos=0&&!(t.after(i+1)=0&&!(e.before(s+1)>e.start(s));s--,r--);return n==r&&/row|table/.test(t.node(i).type.spec.tableRole)}function gC({$from:t,$to:e}){let n,r;for(let i=t.depth;i>0;i--){const s=t.node(i);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){n=s;break}}for(let i=e.depth;i>0;i--){const s=e.node(i);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){r=s;break}}return n!==r&&e.parentOffset===0}function bC(t,e,n){const r=(e||t).selection,i=(e||t).doc;let s,o;if(r instanceof ee&&(o=r.node.type.spec.tableRole)){if(o=="cell"||o=="header_cell")s=_e.create(i,r.from);else if(o=="row"){const a=i.resolve(r.from+1);s=_e.rowSelection(a,a)}else if(!n){const a=Ne.get(r.node),l=r.from+1,u=l+a.map[a.width*a.height-1];s=_e.create(i,l+1,u)}}else r instanceof X&&mC(r)?s=X.create(i,r.from):r instanceof X&&gC(r)&&(s=X.create(i,r.$from.start(),r.$from.end()));return s&&(e||(e=t.tr)).setSelection(s),e}var yC=new Te("fix-tables");function W1(t,e,n,r){const i=t.childCount,s=e.childCount;e:for(let o=0,a=0;o{i.type.spec.tableRole=="table"&&(n=xC(t,i,s,n))};return e?e.doc!=t.doc&&W1(e.doc,t.doc,0,r):t.doc.descendants(r),n}function xC(t,e,n,r){const i=Ne.get(e);if(!i.problems)return r;r||(r=t.tr);const s=[];for(let l=0;l0){let h="cell";c.firstChild&&(h=c.firstChild.type.spec.tableRole);const p=[];for(let g=0;g0&&r>0||e.child(0).type.spec.tableRole=="table");)n--,r--,e=e.child(0).content;const i=e.child(0),s=i.type.spec.tableRole,o=i.type.schema,a=[];if(s=="row")for(let l=0;l=0;o--){const{rowspan:a,colspan:l}=s.child(o).attrs;for(let u=i;u=e.length&&e.push(O.empty),n[i]r&&(f=f.type.createChecked(_r(f.attrs,f.attrs.colspan,c+f.attrs.colspan-r),f.content)),u.push(f),c+=f.attrs.colspan;for(let h=1;hi&&(d=d.type.create({...d.attrs,rowspan:Math.max(1,i-d.attrs.rowspan)},d.content)),l.push(d)}s.push(O.from(l))}n=s,e=i}return{width:t,height:e,rows:n}}function _C(t,e,n,r,i,s,o){const a=t.doc.type.schema,l=tt(a);let u,c;if(i>e.width)for(let d=0,f=0;de.height){const d=[];for(let p=0,m=(e.height-1)*e.width;p=e.width?!1:n.nodeAt(e.map[m+p]).type==l.header_cell;d.push(g?c||(c=l.header_cell.createAndFill()):u||(u=l.cell.createAndFill()))}const f=l.row.create(null,O.from(d)),h=[];for(let p=e.height;p{if(!i)return!1;const s=n.selection;if(s instanceof _e)return uo(n,r,ne.near(s.$headCell,e));if(t!="horiz"&&!s.empty)return!1;const o=G1(i,t,e);if(o==null)return!1;if(t=="horiz")return uo(n,r,ne.near(n.doc.resolve(s.head+e),e));{const a=n.doc.resolve(o),l=q1(a,t,e);let u;return l?u=ne.near(l,1):e<0?u=ne.near(n.doc.resolve(a.before(-1)),-1):u=ne.near(n.doc.resolve(a.after(-1)),1),uo(n,r,u)}}}function zs(t,e){return(n,r,i)=>{if(!i)return!1;const s=n.selection;let o;if(s instanceof _e)o=s;else{const l=G1(i,t,e);if(l==null)return!1;o=new _e(n.doc.resolve(l))}const a=q1(o.$headCell,t,e);return a?uo(n,r,new _e(o.$anchorCell,a)):!1}}function Vs(t,e){const n=t.selection;if(!(n instanceof _e))return!1;if(e){const r=t.tr,i=tt(t.schema).cell.createAndFill().content;n.forEachCell((s,o)=>{s.content.eq(i)||r.replace(r.mapping.map(o+1),r.mapping.map(o+s.nodeSize-1),new P(i,0,0))}),r.docChanged&&e(r)}return!0}function wC(t,e){const n=t.state.doc,r=bi(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new _e(r))),!0):!1}function SC(t,e,n){if(!Vt(t.state))return!1;let r=kC(n);const i=t.state.selection;if(i instanceof _e){r||(r={width:1,height:1,rows:[O.from(wu(tt(t.state.schema).cell,n))]});const s=i.$anchorCell.node(-1),o=i.$anchorCell.start(-1),a=Ne.get(s).rectBetween(i.$anchorCell.pos-o,i.$headCell.pos-o);return r=EC(r,a.right-a.left,a.bottom-a.top),Zf(t.state,t.dispatch,o,a,r),!0}else if(r){const s=Ma(t.state),o=s.start(-1);return Zf(t.state,t.dispatch,o,Ne.get(s.node(-1)).findCell(s.pos-o),r),!0}else return!1}function AC(t,e){var n;if(e.ctrlKey||e.metaKey)return;const r=Kf(t,e.target);let i;if(e.shiftKey&&t.state.selection instanceof _e)s(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(i=bi(t.state.selection.$anchor))!=null&&((n=Cl(t,e))==null?void 0:n.pos)!=i.pos)s(i,e),e.preventDefault();else if(!r)return;function s(l,u){let c=Cl(t,u);const d=Dn.getState(t.state)==null;if(!c||!xc(l,c))if(d)c=l;else return;const f=new _e(l,c);if(d||!t.state.selection.eq(f)){const h=t.state.tr.setSelection(f);d&&h.setMeta(Dn,l.pos),t.dispatch(h)}}function o(){t.root.removeEventListener("mouseup",o),t.root.removeEventListener("dragstart",o),t.root.removeEventListener("mousemove",a),Dn.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(Dn,-1))}function a(l){const u=l,c=Dn.getState(t.state);let d;if(c!=null)d=t.state.doc.resolve(c);else if(Kf(t,u.target)!=r&&(d=Cl(t,e),!d))return o();d&&s(d,u)}t.root.addEventListener("mouseup",o),t.root.addEventListener("dragstart",o),t.root.addEventListener("mousemove",a)}function G1(t,e,n){if(!(t.state.selection instanceof X))return null;const{$head:r}=t.state.selection;for(let i=r.depth-1;i>=0;i--){const s=r.node(i);if((n<0?r.index(i):r.indexAfter(i))!=(n<0?0:s.childCount))return null;if(s.type.spec.tableRole=="cell"||s.type.spec.tableRole=="header_cell"){const a=r.before(i),l=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(l)?a:null}}return null}function Kf(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Cl(t,e){const n=t.posAtCoords({left:e.clientX,top:e.clientY});return n&&n?bi(t.state.doc.resolve(n.pos)):null}var MC=class{constructor(e,n){this.node=e,this.cellMinWidth=n,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")),Su(e,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,Su(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function Su(t,e,n,r,i,s){var o;let a=0,l=!0,u=e.firstChild;const c=t.firstChild;if(c){for(let d=0,f=0;dnew n(a,e,l),new DC(-1,!1)},apply(s,o){return o.apply(s)}},props:{attributes:s=>{const o=Ot.getState(s);return o&&o.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(s,o)=>{OC(s,o,t,e,r)},mouseleave:s=>{NC(s)},mousedown:(s,o)=>{LC(s,o,e)}},decorations:s=>{const o=Ot.getState(s);if(o&&o.activeHandle>-1)return PC(s,o.activeHandle)},nodeViews:{}}});return i}var DC=class co{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,r=e.getMeta(Ot);if(r&&r.setHandle!=null)return new co(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new co(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let i=e.mapping.map(n.activeHandle,-1);return Cu(e.doc.resolve(i))||(i=-1),new co(i,n.dragging)}return n}};function OC(t,e,n,r,i){const s=Ot.getState(t.state);if(s&&!s.dragging){const o=IC(e.target);let a=-1;if(o){const{left:l,right:u}=o.getBoundingClientRect();e.clientX-l<=n?a=Wf(t,e,"left",n):u-e.clientX<=n&&(a=Wf(t,e,"right",n))}if(a!=s.activeHandle){if(!i&&a!==-1){const l=t.state.doc.resolve(a),u=l.node(-1),c=Ne.get(u),d=l.start(-1);if(c.colCount(l.pos-d)+l.nodeAfter.attrs.colspan-1==c.width-1)return}J1(t,a)}}}function NC(t){const e=Ot.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&J1(t,-1)}function LC(t,e,n){var r;const i=(r=t.dom.ownerDocument.defaultView)!=null?r:window,s=Ot.getState(t.state);if(!s||s.activeHandle==-1||s.dragging)return!1;const o=t.state.doc.nodeAt(s.activeHandle),a=RC(t,s.activeHandle,o.attrs);t.dispatch(t.state.tr.setMeta(Ot,{setDragging:{startX:e.clientX,startWidth:a}}));function l(c){i.removeEventListener("mouseup",l),i.removeEventListener("mousemove",u);const d=Ot.getState(t.state);d!=null&&d.dragging&&(FC(t,d.activeHandle,jf(d.dragging,c,n)),t.dispatch(t.state.tr.setMeta(Ot,{setDragging:null})))}function u(c){if(!c.which)return l(c);const d=Ot.getState(t.state);if(d&&d.dragging){const f=jf(d.dragging,c,n);HC(t,d.activeHandle,f,n)}}return i.addEventListener("mouseup",l),i.addEventListener("mousemove",u),e.preventDefault(),!0}function RC(t,e,{colspan:n,colwidth:r}){const i=r&&r[r.length-1];if(i)return i;const s=t.domAtPos(e);let a=s.node.childNodes[s.offset].offsetWidth,l=n;if(r)for(let u=0;u0?-1:0;fC(e,r,i+s)&&(s=i==0||i==e.width?null:0);for(let o=0;o0&&i0&&e.map[a-1]==l||i0?-1:0;qC(e,r,i+l)&&(l=i==0||i==e.height?null:0);for(let u=0,c=e.width*i;u0&&i0&&d==e.map[c-e.width]){const f=n.nodeAt(d).attrs;t.setNodeMarkup(t.mapping.slice(a).map(d+r),null,{...f,rowspan:f.rowspan-1}),u+=f.colspan-1}else if(i0&&n[s]==n[s-1]||r.right0&&n[i]==n[i-t]||r.bottomn[r.type.spec.tableRole])(t,e)}function JC(t){return(e,n)=>{var r;const i=e.selection;let s,o;if(i instanceof _e){if(i.$anchorCell.pos!=i.$headCell.pos)return!1;s=i.$anchorCell.nodeAfter,o=i.$anchorCell.pos}else{if(s=uC(i.$from),!s)return!1;o=(r=bi(i.$from))==null?void 0:r.pos}if(s==null||o==null||s.attrs.colspan==1&&s.attrs.rowspan==1)return!1;if(n){let a=s.attrs;const l=[],u=a.colwidth;a.rowspan>1&&(a={...a,rowspan:1}),a.colspan>1&&(a={...a,colspan:1});const c=an(e),d=e.tr;for(let h=0;h{o.attrs[t]!==e&&s.setNodeMarkup(a,null,{...o.attrs,[t]:e})}):s.setNodeMarkup(i.pos,null,{...i.nodeAfter.attrs,[t]:e}),r(s)}return!0}}function XC(t){return function(e,n){if(!Vt(e))return!1;if(n){const r=tt(e.schema),i=an(e),s=e.tr,o=i.map.cellsInRect(t=="column"?{left:i.left,top:0,right:i.right,bottom:i.map.height}:t=="row"?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),a=o.map(l=>i.table.nodeAt(l));for(let l=0;l{const p=h+s.tableStart,m=o.doc.nodeAt(p);m&&o.setNodeMarkup(p,f,m.attrs)}),r(o)}return!0}}Xi("row",{useDeprecatedLogic:!0});Xi("column",{useDeprecatedLogic:!0});var QC=Xi("cell",{useDeprecatedLogic:!0});function ew(t,e){if(e<0){const n=t.nodeBefore;if(n)return t.pos-n.nodeSize;for(let r=t.index(-1)-1,i=t.before();r>=0;r--){const s=t.node(-1).child(r),o=s.lastChild;if(o)return i-1-o.nodeSize;i-=s.nodeSize}}else{if(t.index()0;r--)if(n.node(r).type.spec.tableRole=="table")return e&&e(t.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function nw({allowTableNodeSelection:t=!1}={}){return new we({key:Dn,state:{init(){return null},apply(e,n){const r=e.getMeta(Dn);if(r!=null)return r==-1?null:r;if(n==null||!e.docChanged)return n;const{deleted:i,pos:s}=e.mapping.mapResult(n);return i?null:s}},props:{decorations:pC,handleDOMEvents:{mousedown:AC},createSelectionBetween(e){return Dn.getState(e.state)!=null?e.state.selection:null},handleTripleClick:wC,handleKeyDown:CC,handlePaste:SC},appendTransaction(e,n,r){return bC(r,j1(r,n),t)}})}function eh(t,e,n,r,i,s){let o=0,a=!0,l=e.firstChild;const u=t.firstChild;for(let c=0,d=0;c{const r=t.nodes[n];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),t.cached.tableNodeTypes=e,e}function ow(t,e,n,r,i){const s=sw(t),o=[],a=[];for(let u=0;u{const{selection:e}=t.state;if(!aw(e))return!1;let n=0;const r=Y0(e.ranges[0].$from,s=>s.type.name==="table");return r==null||r.node.descendants(s=>{if(s.type.name==="table")return!1;["tableCell","tableHeader"].includes(s.type.name)&&(n+=1)}),n===e.ranges.length?(t.commands.deleteTable(),!0):!1},lw=ue.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,handleWidth:5,cellMinWidth:25,View:rw,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:t,HTMLAttributes:e}){const{colgroup:n,tableWidth:r,tableMinWidth:i}=iw(t,this.options.cellMinWidth);return["table",le(this.options.HTMLAttributes,e,{style:r?`width: ${r}`:`minWidth: ${i}`}),n,["tbody",0]]},addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:i,editor:s})=>{const o=ow(s.schema,t,e,n);if(i){const a=r.selection.anchor+1;r.replaceSelectionWith(o).scrollIntoView().setSelection(X.near(r.doc.resolve(a)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>$C(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>zC(t,e),deleteColumn:()=>({state:t,dispatch:e})=>UC(t,e),addRowBefore:()=>({state:t,dispatch:e})=>ZC(t,e),addRowAfter:()=>({state:t,dispatch:e})=>KC(t,e),deleteRow:()=>({state:t,dispatch:e})=>jC(t,e),deleteTable:()=>({state:t,dispatch:e})=>tw(t,e),mergeCells:()=>({state:t,dispatch:e})=>Jf(t,e),splitCell:()=>({state:t,dispatch:e})=>Yf(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>Xi("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>Xi("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>QC(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>Jf(t,e)?!0:Yf(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:r})=>YC(t,e)(n,r),goToNextCell:()=>({state:t,dispatch:e})=>Qf(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>Qf(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&j1(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){const r=_e.create(e.doc,t.anchorCell,t.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:Us,"Mod-Backspace":Us,Delete:Us,"Mod-Delete":Us}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[TC({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],nw({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const e={name:t.name,options:t.options,storage:t.storage};return{tableRole:oe(Z(t,"tableRole",e))}}}),uw=ue.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",le(this.options.HTMLAttributes,t),0]}}),cw=ue.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?[parseInt(e,10)]:null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:t}){return["th",le(this.options.HTMLAttributes,t),0]}}),dw=ue.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?[parseInt(e,10)]:null}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",le(this.options.HTMLAttributes,t),0]}}),fw=xe.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize"}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{const e=(t==null?void 0:t.node)||this.editor.state.doc;return((t==null?void 0:t.mode)||this.options.mode)==="textSize"?e.textBetween(0,e.content.size,void 0," ").length:e.nodeSize},this.storage.words=t=>{const e=(t==null?void 0:t.node)||this.editor.state.doc;return e.textBetween(0,e.content.size," "," ").split(" ").filter(i=>i!=="").length}},addProseMirrorPlugins(){return[new we({key:new Te("characterCount"),filterTransaction:(t,e)=>{const n=this.options.limit;if(!t.docChanged||n===0||n===null||n===void 0)return!0;const r=this.storage.characters({node:e.doc}),i=this.storage.characters({node:t.doc});if(i<=n||r>n&&i>n&&i<=r)return!0;if(r>n&&i>n&&i>r||!t.getMeta("paste"))return!1;const o=t.selection.$head.pos,a=i-n,l=o-a,u=o;return t.deleteRange(l,u),!(this.storage.characters({node:t.doc})>n)}})]}}),hw="aaa1rp3barth4b0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0faromeo7ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4vianca6w0s2x0a2z0ure5ba0by2idu3namex3narepublic11d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2ntley5rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re2s2c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y0eats7k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0cast4mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking0channel11l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dabur3d1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t0isalat7u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0at2delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d0network8tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntdoor4ier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0ardian6cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5gtv3iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0eles2s3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6logistics9properties14fh2g1h1i0a1ds2m1nder2le4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3ncaster5ia3d0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4de2k2psy3ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0cys3drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7serati6ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic3tual5v1w1x1y1z2na0b1goya4me2tura4vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rthwesternmutual14on4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9dnavy5lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3ssagens7y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0america6xi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cher3ks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0a1b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp2w2ell3ia1ksha5oes2p0ping5uji3w0time7i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ffany5ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0channel7ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lkswagen7vo3te1ing3o2yage5u0elos6wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4finity6ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",pw="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5تصالات6رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2",ui=(t,e)=>{for(const n in e)t[n]=e[n];return t},Au="numeric",Mu="ascii",Tu="alpha",fo="asciinumeric",qs="alphanumeric",Du="domain",Q1="emoji",mw="scheme",gw="slashscheme",nh="whitespace";function bw(t,e){return t in e||(e[t]=[]),e[t]}function ar(t,e,n){e[Au]&&(e[fo]=!0,e[qs]=!0),e[Mu]&&(e[fo]=!0,e[Tu]=!0),e[fo]&&(e[qs]=!0),e[Tu]&&(e[qs]=!0),e[qs]&&(e[Du]=!0),e[Q1]&&(e[Du]=!0);for(const r in e){const i=bw(r,n);i.indexOf(t)<0&&i.push(t)}}function yw(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function ft(t){t===void 0&&(t=null),this.j={},this.jr=[],this.jd=null,this.t=t}ft.groups={};ft.prototype={accepts(){return!!this.t},go(t){const e=this,n=e.j[t];if(n)return n;for(let r=0;rt.ta(e,n,r,i),Tt=(t,e,n,r,i)=>t.tr(e,n,r,i),rh=(t,e,n,r,i)=>t.ts(e,n,r,i),I=(t,e,n,r,i)=>t.tt(e,n,r,i),mn="WORD",Ou="UWORD",Qi="LOCALHOST",Nu="TLD",Lu="UTLD",ho="SCHEME",zr="SLASH_SCHEME",kc="NUM",em="WS",vc="NL",Kr="OPENBRACE",Hi="OPENBRACKET",Bi="OPENANGLEBRACKET",Pi="OPENPAREN",rr="CLOSEBRACE",Wr="CLOSEBRACKET",jr="CLOSEANGLEBRACKET",ir="CLOSEPAREN",Fo="AMPERSAND",Ho="APOSTROPHE",Bo="ASTERISK",An="AT",Po="BACKSLASH",$o="BACKTICK",zo="CARET",On="COLON",Ec="COMMA",Vo="DOLLAR",Kt="DOT",Uo="EQUALS",_c="EXCLAMATION",Wt="HYPHEN",qo="PERCENT",Zo="PIPE",Ko="PLUS",Wo="POUND",jo="QUERY",Cc="QUOTE",wc="SEMI",jt="SLASH",$i="TILDE",Go="UNDERSCORE",tm="EMOJI",Jo="SYM";var nm=Object.freeze({__proto__:null,WORD:mn,UWORD:Ou,LOCALHOST:Qi,TLD:Nu,UTLD:Lu,SCHEME:ho,SLASH_SCHEME:zr,NUM:kc,WS:em,NL:vc,OPENBRACE:Kr,OPENBRACKET:Hi,OPENANGLEBRACKET:Bi,OPENPAREN:Pi,CLOSEBRACE:rr,CLOSEBRACKET:Wr,CLOSEANGLEBRACKET:jr,CLOSEPAREN:ir,AMPERSAND:Fo,APOSTROPHE:Ho,ASTERISK:Bo,AT:An,BACKSLASH:Po,BACKTICK:$o,CARET:zo,COLON:On,COMMA:Ec,DOLLAR:Vo,DOT:Kt,EQUALS:Uo,EXCLAMATION:_c,HYPHEN:Wt,PERCENT:qo,PIPE:Zo,PLUS:Ko,POUND:Wo,QUERY:jo,QUOTE:Cc,SEMI:wc,SLASH:jt,TILDE:$i,UNDERSCORE:Go,EMOJI:tm,SYM:Jo});const Lr=/[a-z]/,wl=/\p{L}/u,Sl=/\p{Emoji}/u,Al=/\d/,ih=/\s/,sh=` -`,xw="️",kw="‍";let Zs=null,Ks=null;function vw(t){t===void 0&&(t=[]);const e={};ft.groups=e;const n=new ft;Zs==null&&(Zs=oh(hw)),Ks==null&&(Ks=oh(pw)),I(n,"'",Ho),I(n,"{",Kr),I(n,"[",Hi),I(n,"<",Bi),I(n,"(",Pi),I(n,"}",rr),I(n,"]",Wr),I(n,">",jr),I(n,")",ir),I(n,"&",Fo),I(n,"*",Bo),I(n,"@",An),I(n,"`",$o),I(n,"^",zo),I(n,":",On),I(n,",",Ec),I(n,"$",Vo),I(n,".",Kt),I(n,"=",Uo),I(n,"!",_c),I(n,"-",Wt),I(n,"%",qo),I(n,"|",Zo),I(n,"+",Ko),I(n,"#",Wo),I(n,"?",jo),I(n,'"',Cc),I(n,"/",jt),I(n,";",wc),I(n,"~",$i),I(n,"_",Go),I(n,"\\",Po);const r=Tt(n,Al,kc,{[Au]:!0});Tt(r,Al,r);const i=Tt(n,Lr,mn,{[Mu]:!0});Tt(i,Lr,i);const s=Tt(n,wl,Ou,{[Tu]:!0});Tt(s,Lr),Tt(s,wl,s);const o=Tt(n,ih,em,{[nh]:!0});I(n,sh,vc,{[nh]:!0}),I(o,sh),Tt(o,ih,o);const a=Tt(n,Sl,tm,{[Q1]:!0});Tt(a,Sl,a),I(a,xw,a);const l=I(a,kw);Tt(l,Sl,a);const u=[[Lr,i]],c=[[Lr,null],[wl,s]];for(let d=0;dd[0]>f[0]?1:-1);for(let d=0;d=0?p[Du]=!0:Lr.test(f)?Al.test(f)?p[fo]=!0:p[Mu]=!0:p[Au]=!0,rh(n,f,f,p)}return rh(n,"localhost",Qi,{ascii:!0}),n.jd=new ft(Jo),{start:n,tokens:ui({groups:e},nm)}}function Ew(t,e){const n=_w(e.replace(/[A-Z]/g,a=>a.toLowerCase())),r=n.length,i=[];let s=0,o=0;for(;o=0&&(d+=n[o].length,f++),u+=n[o].length,s+=n[o].length,o++;s-=d,o-=f,u-=d,i.push({t:c.t,v:e.slice(s-u,s),s:s-u,e:s})}return i}function _w(t){const e=[],n=t.length;let r=0;for(;r56319||r+1===n||(s=t.charCodeAt(r+1))<56320||s>57343?t[r]:t.slice(r,r+2);e.push(o),r+=o.length}return e}function _n(t,e,n,r,i){let s;const o=e.length;for(let a=0;a=0;)s++;if(s>0){e.push(n.join(""));for(let o=parseInt(t.substring(r,r+s),10);o>0;o--)n.pop();r+=s}else n.push(t[r]),r++}return e}const es={defaultProtocol:"http",events:null,format:ah,formatHref:ah,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Sc(t,e){e===void 0&&(e=null);let n=ui({},es);t&&(n=ui(n,t instanceof Sc?t.o:t));const r=n.ignoreTags,i=[];for(let s=0;sn?r.substring(0,n)+"…":r},toFormattedHref(t){return t.get("formatHref",this.toHref(t.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(t){return t===void 0&&(t=es.defaultProtocol),{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const e=this,n=this.toHref(t.get("defaultProtocol")),r=t.get("formatHref",n,this),i=t.get("tagName",n,e),s=this.toFormattedString(t),o={},a=t.get("className",n,e),l=t.get("target",n,e),u=t.get("rel",n,e),c=t.getObj("attributes",n,e),d=t.getObj("events",n,e);return o.href=r,a&&(o.class=a),l&&(o.target=l),u&&(o.rel=u),c&&ui(o,c),{tagName:i,attributes:o,content:s,eventListeners:d}}};function Ta(t,e){class n extends rm{constructor(i,s){super(i,s),this.t=t}}for(const r in e)n.prototype[r]=e[r];return n.t=t,n}const lh=Ta("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),uh=Ta("text"),Cw=Ta("nl"),Qn=Ta("url",{isLink:!0,toHref(t){return t===void 0&&(t=es.defaultProtocol),this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==Qi&&t[1].t===On}}),Pe=t=>new ft(t);function ww(t){let{groups:e}=t;const n=e.domain.concat([Fo,Bo,An,Po,$o,zo,Vo,Uo,Wt,kc,qo,Zo,Ko,Wo,jt,Jo,$i,Go]),r=[Ho,jr,rr,Wr,ir,On,Ec,Kt,_c,Bi,Kr,Hi,Pi,jo,Cc,wc],i=[Fo,Ho,Bo,Po,$o,zo,rr,Vo,Uo,Wt,Kr,qo,Zo,Ko,Wo,jo,jt,Jo,$i,Go],s=Pe(),o=I(s,$i);Y(o,i,o),Y(o,e.domain,o);const a=Pe(),l=Pe(),u=Pe();Y(s,e.domain,a),Y(s,e.scheme,l),Y(s,e.slashscheme,u),Y(a,i,o),Y(a,e.domain,a);const c=I(a,An);I(o,An,c),I(l,An,c),I(u,An,c);const d=I(o,Kt);Y(d,i,o),Y(d,e.domain,o);const f=Pe();Y(c,e.domain,f),Y(f,e.domain,f);const h=I(f,Kt);Y(h,e.domain,f);const p=Pe(lh);Y(h,e.tld,p),Y(h,e.utld,p),I(c,Qi,p);const m=I(f,Wt);Y(m,e.domain,f),Y(p,e.domain,f),I(p,Kt,h),I(p,Wt,m);const g=I(p,On);Y(g,e.numeric,lh);const y=I(a,Wt),x=I(a,Kt);Y(y,e.domain,a),Y(x,i,o),Y(x,e.domain,a);const k=Pe(Qn);Y(x,e.tld,k),Y(x,e.utld,k),Y(k,e.domain,a),Y(k,i,o),I(k,Kt,x),I(k,Wt,y),I(k,An,c);const b=I(k,On),E=Pe(Qn);Y(b,e.numeric,E);const v=Pe(Qn),C=Pe();Y(v,n,v),Y(v,r,C),Y(C,n,v),Y(C,r,C),I(k,jt,v),I(E,jt,v);const T=I(l,On),w=I(u,On),N=I(w,jt),$=I(N,jt);Y(l,e.domain,a),I(l,Kt,x),I(l,Wt,y),Y(u,e.domain,a),I(u,Kt,x),I(u,Wt,y),Y(T,e.domain,v),I(T,jt,v),Y($,e.domain,v),Y($,n,v),I($,jt,v);const K=I(v,Kr),U=I(v,Hi),W=I(v,Bi),z=I(v,Pi);I(C,Kr,K),I(C,Hi,U),I(C,Bi,W),I(C,Pi,z),I(K,rr,v),I(U,Wr,v),I(W,jr,v),I(z,ir,v),I(K,rr,v);const A=Pe(Qn),_=Pe(Qn),S=Pe(Qn),L=Pe(Qn);Y(K,n,A),Y(U,n,_),Y(W,n,S),Y(z,n,L);const F=Pe(),j=Pe(),Q=Pe(),pe=Pe();return Y(K,r),Y(U,r),Y(W,r),Y(z,r),Y(A,n,A),Y(_,n,_),Y(S,n,S),Y(L,n,L),Y(A,r,A),Y(_,r,_),Y(S,r,S),Y(L,r,L),Y(F,n,F),Y(j,n,_),Y(Q,n,S),Y(pe,n,L),Y(F,r,F),Y(j,r,j),Y(Q,r,Q),Y(pe,r,pe),I(_,Wr,v),I(S,jr,v),I(L,ir,v),I(A,rr,v),I(j,Wr,v),I(Q,jr,v),I(pe,ir,v),I(F,ir,v),I(s,Qi,k),I(s,vc,Cw),{start:s,tokens:nm}}function Sw(t,e,n){let r=n.length,i=0,s=[],o=[];for(;i=0&&f++,i++,c++;if(f<0)i-=c,i0&&(s.push(Ml(uh,e,o)),o=[]),i-=f,c-=f;const h=d.t,p=n.slice(i-c,i);s.push(Ml(h,e,p))}}return o.length>0&&s.push(Ml(uh,e,o)),s}function Ml(t,e,n){const r=n[0].s,i=n[n.length-1].e,s=e.slice(r,i);return new t(s,n)}const Aw=typeof console<"u"&&console&&console.warn||(()=>{}),Mw="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",Oe={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function Tw(){ft.groups={},Oe.scanner=null,Oe.parser=null,Oe.tokenQueue=[],Oe.pluginQueue=[],Oe.customSchemes=[],Oe.initialized=!1}function ch(t,e){if(e===void 0&&(e=!1),Oe.initialized&&Aw(`linkifyjs: already initialized - will not register custom scheme "${t}" ${Mw}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format. + `,V1(e,t.editor.view.dom,o=>t.editor.commands.updateAttributes("image",o)),{dom:e}}},addProseMirrorPlugins(){const t=this.editor;return[new we({key:Vf,state:{init:()=>ve.empty,apply:(e,n)=>{const r=e.getMeta(Ci);if(r){let i=!1;const s=n.map(e.mapping,e.doc,{onRemove:o=>{i=!0}});i||(n=s),r.type==="add"?n=n.add(e.doc,[z1(r)]):r.type==="remove"&&(n=n.remove(n.find(void 0,void 0,o=>o.id==r.id)))}return n}},props:{decorations(e){return this.getState(e)},handlePaste:(e,n)=>{var i;const r=Array.from(((i=n.clipboardData)==null?void 0:i.items)||[]);for(const s of r)if(s.type.indexOf("image")===0){n.preventDefault();const o=s.getAsFile();o&&this.editor.commands.uploadImage(o)}},handleDOMEvents:{drop(e,n){if(!(n.dataTransfer&&n.dataTransfer.files&&n.dataTransfer.files.length))return!1;const i=Array.from(n.dataTransfer.files).filter(u=>/image/i.test(u.type));if(i.length===0)return!1;n.preventDefault();const{state:{tr:s,doc:o},dispatch:a}=e,l=e.posAtCoords({left:n.clientX,top:n.clientY});return a(s.setSelection(X.create(o,l.pos)).scrollIntoView()),i.forEach(u=>{t.commands.uploadImage(u)}),!0}},transformPastedHTML(e){const r=new DOMParser().parseFromString(e,"text/html"),i=r.documentElement.querySelector("body");if(i!=null&&i.children){const s=r.documentElement.querySelectorAll("p > img");for(const o of s){const a=o.parentNode,l=Array.prototype.indexOf.call(i.children,a);o.parentElement.prepend(o),i.insertBefore(o,i.children[l])}return i.innerHTML}return e}}})]}});var Eu,_u;if(typeof WeakMap<"u"){let t=new WeakMap;Eu=e=>t.get(e),_u=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;Eu=r=>{for(let i=0;i(n==10&&(n=0),t[n++]=r,t[n++]=i)}var Ne=class{constructor(t,e,n,r){this.width=t,this.height=e,this.map=n,this.problems=r}findCell(t){for(let e=0;e=n){(s||(s=[])).push({type:"overlong_rowspan",pos:c,n:y-k});break}const b=i+k*e;for(let E=0;Er&&(s+=u.attrs.colspan)}}for(let o=0;o1&&(n=!0)}e==-1?e=s:e!=s&&(e=Math.max(e,s))}return e}function lC(t,e,n){t.problems||(t.problems=[]);const r={};for(let i=0;i0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function cC(t){for(let e=t.depth;e>0;e--){const n=t.node(e).type.spec.tableRole;if(n==="cell"||n==="header_cell")return t.node(e)}return null}function Vt(t){const e=t.selection.$head;for(let n=e.depth;n>0;n--)if(e.node(n).type.spec.tableRole=="row")return!0;return!1}function Ma(t){const e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const n=bi(e.$head)||dC(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function dC(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n-e.nodeSize)}}function Cu(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function fC(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function kc(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function U1(t,e,n){const r=t.node(-1),i=Ne.get(r),s=t.start(-1),o=i.nextCell(t.pos-s,e,n);return o==null?null:t.node(0).resolve(s+o)}function _r(t,e,n=1){const r={...t,colspan:t.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,n),r.colwidth.some(i=>i>0)||(r.colwidth=null)),r}function q1(t,e,n=1){const r={...t,colspan:t.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let i=0;ic!=n.pos-s);l.unshift(n.pos-s);const u=l.map(c=>{const d=r.nodeAt(c);if(!d)throw RangeError(`No cell with offset ${c} found`);const f=s+c+1;return new t0(a.resolve(f),a.resolve(f+d.content.size))});super(u[0].$from,u[0].$to,u),this.$anchorCell=e,this.$headCell=n}map(e,n){const r=e.resolve(n.map(this.$anchorCell.pos)),i=e.resolve(n.map(this.$headCell.pos));if(Cu(r)&&Cu(i)&&kc(r,i)){const s=this.$anchorCell.node(-1)!=r.node(-1);return s&&this.isRowSelection()?pn.rowSelection(r,i):s&&this.isColSelection()?pn.colSelection(r,i):new pn(r,i)}return X.between(r,i)}content(){const e=this.$anchorCell.node(-1),n=Ne.get(e),r=this.$anchorCell.start(-1),i=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),s={},o=[];for(let l=i.top;l0||g>0){let y=p.attrs;if(m>0&&(y=_r(y,0,m)),g>0&&(y=_r(y,y.colspan-g,g)),h.lefti.bottom){const y={...p.attrs,rowspan:Math.min(h.bottom,i.bottom)-Math.max(h.top,i.top)};h.top0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,i=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,i)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){const r=e.node(-1),i=Ne.get(r),s=e.start(-1),o=i.findCell(e.pos-s),a=i.findCell(n.pos-s),l=e.node(0);return o.top<=a.top?(o.top>0&&(e=l.resolve(s+i.map[o.left])),a.bottom0&&(n=l.resolve(s+i.map[a.left])),o.bottom0)return!1;const o=i+this.$anchorCell.nodeAfter.attrs.colspan,a=s+this.$headCell.nodeAfter.attrs.colspan;return Math.max(o,a)==n.width}eq(e){return e instanceof pn&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const r=e.node(-1),i=Ne.get(r),s=e.start(-1),o=i.findCell(e.pos-s),a=i.findCell(n.pos-s),l=e.node(0);return o.left<=a.left?(o.left>0&&(e=l.resolve(s+i.map[o.top*i.width])),a.right0&&(n=l.resolve(s+i.map[a.top*i.width])),o.right{e.push(Be.node(r,r+n.nodeSize,{class:"selectedCell"}))}),ve.create(t.doc,e)}function gC({$from:t,$to:e}){if(t.pos==e.pos||t.pos=0&&!(t.after(i+1)=0&&!(e.before(s+1)>e.start(s));s--,r--);return n==r&&/row|table/.test(t.node(i).type.spec.tableRole)}function bC({$from:t,$to:e}){let n,r;for(let i=t.depth;i>0;i--){const s=t.node(i);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){n=s;break}}for(let i=e.depth;i>0;i--){const s=e.node(i);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){r=s;break}}return n!==r&&e.parentOffset===0}function yC(t,e,n){const r=(e||t).selection,i=(e||t).doc;let s,o;if(r instanceof ee&&(o=r.node.type.spec.tableRole)){if(o=="cell"||o=="header_cell")s=_e.create(i,r.from);else if(o=="row"){const a=i.resolve(r.from+1);s=_e.rowSelection(a,a)}else if(!n){const a=Ne.get(r.node),l=r.from+1,u=l+a.map[a.width*a.height-1];s=_e.create(i,l+1,u)}}else r instanceof X&&gC(r)?s=X.create(i,r.from):r instanceof X&&bC(r)&&(s=X.create(i,r.$from.start(),r.$from.end()));return s&&(e||(e=t.tr)).setSelection(s),e}var xC=new Te("fix-tables");function K1(t,e,n,r){const i=t.childCount,s=e.childCount;e:for(let o=0,a=0;o{i.type.spec.tableRole=="table"&&(n=kC(t,i,s,n))};return e?e.doc!=t.doc&&K1(e.doc,t.doc,0,r):t.doc.descendants(r),n}function kC(t,e,n,r){const i=Ne.get(e);if(!i.problems)return r;r||(r=t.tr);const s=[];for(let l=0;l0){let h="cell";c.firstChild&&(h=c.firstChild.type.spec.tableRole);const p=[];for(let g=0;g0&&r>0||e.child(0).type.spec.tableRole=="table");)n--,r--,e=e.child(0).content;const i=e.child(0),s=i.type.spec.tableRole,o=i.type.schema,a=[];if(s=="row")for(let l=0;l=0;o--){const{rowspan:a,colspan:l}=s.child(o).attrs;for(let u=i;u=e.length&&e.push(O.empty),n[i]r&&(f=f.type.createChecked(_r(f.attrs,f.attrs.colspan,c+f.attrs.colspan-r),f.content)),u.push(f),c+=f.attrs.colspan;for(let h=1;hi&&(d=d.type.create({...d.attrs,rowspan:Math.max(1,i-d.attrs.rowspan)},d.content)),l.push(d)}s.push(O.from(l))}n=s,e=i}return{width:t,height:e,rows:n}}function CC(t,e,n,r,i,s,o){const a=t.doc.type.schema,l=tt(a);let u,c;if(i>e.width)for(let d=0,f=0;de.height){const d=[];for(let p=0,m=(e.height-1)*e.width;p=e.width?!1:n.nodeAt(e.map[m+p]).type==l.header_cell;d.push(g?c||(c=l.header_cell.createAndFill()):u||(u=l.cell.createAndFill()))}const f=l.row.create(null,O.from(d)),h=[];for(let p=e.height;p{if(!i)return!1;const s=n.selection;if(s instanceof _e)return uo(n,r,ne.near(s.$headCell,e));if(t!="horiz"&&!s.empty)return!1;const o=j1(i,t,e);if(o==null)return!1;if(t=="horiz")return uo(n,r,ne.near(n.doc.resolve(s.head+e),e));{const a=n.doc.resolve(o),l=U1(a,t,e);let u;return l?u=ne.near(l,1):e<0?u=ne.near(n.doc.resolve(a.before(-1)),-1):u=ne.near(n.doc.resolve(a.after(-1)),1),uo(n,r,u)}}}function zs(t,e){return(n,r,i)=>{if(!i)return!1;const s=n.selection;let o;if(s instanceof _e)o=s;else{const l=j1(i,t,e);if(l==null)return!1;o=new _e(n.doc.resolve(l))}const a=U1(o.$headCell,t,e);return a?uo(n,r,new _e(o.$anchorCell,a)):!1}}function Vs(t,e){const n=t.selection;if(!(n instanceof _e))return!1;if(e){const r=t.tr,i=tt(t.schema).cell.createAndFill().content;n.forEachCell((s,o)=>{s.content.eq(i)||r.replace(r.mapping.map(o+1),r.mapping.map(o+s.nodeSize-1),new P(i,0,0))}),r.docChanged&&e(r)}return!0}function SC(t,e){const n=t.state.doc,r=bi(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new _e(r))),!0):!1}function AC(t,e,n){if(!Vt(t.state))return!1;let r=vC(n);const i=t.state.selection;if(i instanceof _e){r||(r={width:1,height:1,rows:[O.from(wu(tt(t.state.schema).cell,n))]});const s=i.$anchorCell.node(-1),o=i.$anchorCell.start(-1),a=Ne.get(s).rectBetween(i.$anchorCell.pos-o,i.$headCell.pos-o);return r=_C(r,a.right-a.left,a.bottom-a.top),Zf(t.state,t.dispatch,o,a,r),!0}else if(r){const s=Ma(t.state),o=s.start(-1);return Zf(t.state,t.dispatch,o,Ne.get(s.node(-1)).findCell(s.pos-o),r),!0}else return!1}function MC(t,e){var n;if(e.ctrlKey||e.metaKey)return;const r=Kf(t,e.target);let i;if(e.shiftKey&&t.state.selection instanceof _e)s(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(i=bi(t.state.selection.$anchor))!=null&&((n=Cl(t,e))==null?void 0:n.pos)!=i.pos)s(i,e),e.preventDefault();else if(!r)return;function s(l,u){let c=Cl(t,u);const d=Dn.getState(t.state)==null;if(!c||!kc(l,c))if(d)c=l;else return;const f=new _e(l,c);if(d||!t.state.selection.eq(f)){const h=t.state.tr.setSelection(f);d&&h.setMeta(Dn,l.pos),t.dispatch(h)}}function o(){t.root.removeEventListener("mouseup",o),t.root.removeEventListener("dragstart",o),t.root.removeEventListener("mousemove",a),Dn.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(Dn,-1))}function a(l){const u=l,c=Dn.getState(t.state);let d;if(c!=null)d=t.state.doc.resolve(c);else if(Kf(t,u.target)!=r&&(d=Cl(t,e),!d))return o();d&&s(d,u)}t.root.addEventListener("mouseup",o),t.root.addEventListener("dragstart",o),t.root.addEventListener("mousemove",a)}function j1(t,e,n){if(!(t.state.selection instanceof X))return null;const{$head:r}=t.state.selection;for(let i=r.depth-1;i>=0;i--){const s=r.node(i);if((n<0?r.index(i):r.indexAfter(i))!=(n<0?0:s.childCount))return null;if(s.type.spec.tableRole=="cell"||s.type.spec.tableRole=="header_cell"){const a=r.before(i),l=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(l)?a:null}}return null}function Kf(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Cl(t,e){const n=t.posAtCoords({left:e.clientX,top:e.clientY});return n&&n?bi(t.state.doc.resolve(n.pos)):null}var TC=class{constructor(e,n){this.node=e,this.cellMinWidth=n,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")),Su(e,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,Su(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function Su(t,e,n,r,i,s){var o;let a=0,l=!0,u=e.firstChild;const c=t.firstChild;if(c){for(let d=0,f=0;dnew n(a,e,l),new OC(-1,!1)},apply(s,o){return o.apply(s)}},props:{attributes:s=>{const o=Ot.getState(s);return o&&o.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(s,o)=>{NC(s,o,t,e,r)},mouseleave:s=>{LC(s)},mousedown:(s,o)=>{RC(s,o,e)}},decorations:s=>{const o=Ot.getState(s);if(o&&o.activeHandle>-1)return $C(s,o.activeHandle)},nodeViews:{}}});return i}var OC=class co{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,r=e.getMeta(Ot);if(r&&r.setHandle!=null)return new co(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new co(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let i=e.mapping.map(n.activeHandle,-1);return Cu(e.doc.resolve(i))||(i=-1),new co(i,n.dragging)}return n}};function NC(t,e,n,r,i){const s=Ot.getState(t.state);if(s&&!s.dragging){const o=FC(e.target);let a=-1;if(o){const{left:l,right:u}=o.getBoundingClientRect();e.clientX-l<=n?a=Wf(t,e,"left",n):u-e.clientX<=n&&(a=Wf(t,e,"right",n))}if(a!=s.activeHandle){if(!i&&a!==-1){const l=t.state.doc.resolve(a),u=l.node(-1),c=Ne.get(u),d=l.start(-1);if(c.colCount(l.pos-d)+l.nodeAfter.attrs.colspan-1==c.width-1)return}G1(t,a)}}}function LC(t){const e=Ot.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&G1(t,-1)}function RC(t,e,n){var r;const i=(r=t.dom.ownerDocument.defaultView)!=null?r:window,s=Ot.getState(t.state);if(!s||s.activeHandle==-1||s.dragging)return!1;const o=t.state.doc.nodeAt(s.activeHandle),a=IC(t,s.activeHandle,o.attrs);t.dispatch(t.state.tr.setMeta(Ot,{setDragging:{startX:e.clientX,startWidth:a}}));function l(c){i.removeEventListener("mouseup",l),i.removeEventListener("mousemove",u);const d=Ot.getState(t.state);d!=null&&d.dragging&&(HC(t,d.activeHandle,jf(d.dragging,c,n)),t.dispatch(t.state.tr.setMeta(Ot,{setDragging:null})))}function u(c){if(!c.which)return l(c);const d=Ot.getState(t.state);if(d&&d.dragging){const f=jf(d.dragging,c,n);BC(t,d.activeHandle,f,n)}}return i.addEventListener("mouseup",l),i.addEventListener("mousemove",u),e.preventDefault(),!0}function IC(t,e,{colspan:n,colwidth:r}){const i=r&&r[r.length-1];if(i)return i;const s=t.domAtPos(e);let a=s.node.childNodes[s.offset].offsetWidth,l=n;if(r)for(let u=0;u0?-1:0;hC(e,r,i+s)&&(s=i==0||i==e.width?null:0);for(let o=0;o0&&i0&&e.map[a-1]==l||i0?-1:0;ZC(e,r,i+l)&&(l=i==0||i==e.height?null:0);for(let u=0,c=e.width*i;u0&&i0&&d==e.map[c-e.width]){const f=n.nodeAt(d).attrs;t.setNodeMarkup(t.mapping.slice(a).map(d+r),null,{...f,rowspan:f.rowspan-1}),u+=f.colspan-1}else if(i0&&n[s]==n[s-1]||r.right0&&n[i]==n[i-t]||r.bottomn[r.type.spec.tableRole])(t,e)}function YC(t){return(e,n)=>{var r;const i=e.selection;let s,o;if(i instanceof _e){if(i.$anchorCell.pos!=i.$headCell.pos)return!1;s=i.$anchorCell.nodeAfter,o=i.$anchorCell.pos}else{if(s=cC(i.$from),!s)return!1;o=(r=bi(i.$from))==null?void 0:r.pos}if(s==null||o==null||s.attrs.colspan==1&&s.attrs.rowspan==1)return!1;if(n){let a=s.attrs;const l=[],u=a.colwidth;a.rowspan>1&&(a={...a,rowspan:1}),a.colspan>1&&(a={...a,colspan:1});const c=an(e),d=e.tr;for(let h=0;h{o.attrs[t]!==e&&s.setNodeMarkup(a,null,{...o.attrs,[t]:e})}):s.setNodeMarkup(i.pos,null,{...i.nodeAfter.attrs,[t]:e}),r(s)}return!0}}function QC(t){return function(e,n){if(!Vt(e))return!1;if(n){const r=tt(e.schema),i=an(e),s=e.tr,o=i.map.cellsInRect(t=="column"?{left:i.left,top:0,right:i.right,bottom:i.map.height}:t=="row"?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),a=o.map(l=>i.table.nodeAt(l));for(let l=0;l{const p=h+s.tableStart,m=o.doc.nodeAt(p);m&&o.setNodeMarkup(p,f,m.attrs)}),r(o)}return!0}}Xi("row",{useDeprecatedLogic:!0});Xi("column",{useDeprecatedLogic:!0});var ew=Xi("cell",{useDeprecatedLogic:!0});function tw(t,e){if(e<0){const n=t.nodeBefore;if(n)return t.pos-n.nodeSize;for(let r=t.index(-1)-1,i=t.before();r>=0;r--){const s=t.node(-1).child(r),o=s.lastChild;if(o)return i-1-o.nodeSize;i-=s.nodeSize}}else{if(t.index()0;r--)if(n.node(r).type.spec.tableRole=="table")return e&&e(t.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function rw({allowTableNodeSelection:t=!1}={}){return new we({key:Dn,state:{init(){return null},apply(e,n){const r=e.getMeta(Dn);if(r!=null)return r==-1?null:r;if(n==null||!e.docChanged)return n;const{deleted:i,pos:s}=e.mapping.mapResult(n);return i?null:s}},props:{decorations:mC,handleDOMEvents:{mousedown:MC},createSelectionBetween(e){return Dn.getState(e.state)!=null?e.state.selection:null},handleTripleClick:SC,handleKeyDown:wC,handlePaste:AC},appendTransaction(e,n,r){return yC(r,W1(r,n),t)}})}function eh(t,e,n,r,i,s){let o=0,a=!0,l=e.firstChild;const u=t.firstChild;for(let c=0,d=0;c{const r=t.nodes[n];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),t.cached.tableNodeTypes=e,e}function aw(t,e,n,r,i){const s=ow(t),o=[],a=[];for(let u=0;u{const{selection:e}=t.state;if(!lw(e))return!1;let n=0;const r=Y0(e.ranges[0].$from,s=>s.type.name==="table");return r==null||r.node.descendants(s=>{if(s.type.name==="table")return!1;["tableCell","tableHeader"].includes(s.type.name)&&(n+=1)}),n===e.ranges.length?(t.commands.deleteTable(),!0):!1},uw=ue.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,handleWidth:5,cellMinWidth:25,View:iw,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:t,HTMLAttributes:e}){const{colgroup:n,tableWidth:r,tableMinWidth:i}=sw(t,this.options.cellMinWidth);return["table",le(this.options.HTMLAttributes,e,{style:r?`width: ${r}`:`minWidth: ${i}`}),n,["tbody",0]]},addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:i,editor:s})=>{const o=aw(s.schema,t,e,n);if(i){const a=r.selection.anchor+1;r.replaceSelectionWith(o).scrollIntoView().setSelection(X.near(r.doc.resolve(a)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>zC(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>VC(t,e),deleteColumn:()=>({state:t,dispatch:e})=>qC(t,e),addRowBefore:()=>({state:t,dispatch:e})=>KC(t,e),addRowAfter:()=>({state:t,dispatch:e})=>WC(t,e),deleteRow:()=>({state:t,dispatch:e})=>GC(t,e),deleteTable:()=>({state:t,dispatch:e})=>nw(t,e),mergeCells:()=>({state:t,dispatch:e})=>Jf(t,e),splitCell:()=>({state:t,dispatch:e})=>Yf(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>Xi("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>Xi("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>ew(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>Jf(t,e)?!0:Yf(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:r})=>XC(t,e)(n,r),goToNextCell:()=>({state:t,dispatch:e})=>Qf(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>Qf(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&W1(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){const r=_e.create(e.doc,t.anchorCell,t.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:Us,"Mod-Backspace":Us,Delete:Us,"Mod-Delete":Us}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[DC({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],rw({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const e={name:t.name,options:t.options,storage:t.storage};return{tableRole:oe(Z(t,"tableRole",e))}}}),cw=ue.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",le(this.options.HTMLAttributes,t),0]}}),dw=ue.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?[parseInt(e,10)]:null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:t}){return["th",le(this.options.HTMLAttributes,t),0]}}),fw=ue.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?[parseInt(e,10)]:null}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",le(this.options.HTMLAttributes,t),0]}}),hw=xe.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize"}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{const e=(t==null?void 0:t.node)||this.editor.state.doc;return((t==null?void 0:t.mode)||this.options.mode)==="textSize"?e.textBetween(0,e.content.size,void 0," ").length:e.nodeSize},this.storage.words=t=>{const e=(t==null?void 0:t.node)||this.editor.state.doc;return e.textBetween(0,e.content.size," "," ").split(" ").filter(i=>i!=="").length}},addProseMirrorPlugins(){return[new we({key:new Te("characterCount"),filterTransaction:(t,e)=>{const n=this.options.limit;if(!t.docChanged||n===0||n===null||n===void 0)return!0;const r=this.storage.characters({node:e.doc}),i=this.storage.characters({node:t.doc});if(i<=n||r>n&&i>n&&i<=r)return!0;if(r>n&&i>n&&i>r||!t.getMeta("paste"))return!1;const o=t.selection.$head.pos,a=i-n,l=o-a,u=o;return t.deleteRange(l,u),!(this.storage.characters({node:t.doc})>n)}})]}}),pw="aaa1rp3barth4b0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0faromeo7ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4vianca6w0s2x0a2z0ure5ba0by2idu3namex3narepublic11d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2ntley5rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re2s2c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y0eats7k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0cast4mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking0channel11l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dabur3d1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t0isalat7u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0at2delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d0network8tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntdoor4ier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0ardian6cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5gtv3iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0eles2s3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6logistics9properties14fh2g1h1i0a1ds2m1nder2le4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3ncaster5ia3d0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4de2k2psy3ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0cys3drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7serati6ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic3tual5v1w1x1y1z2na0b1goya4me2tura4vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rthwesternmutual14on4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9dnavy5lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3ssagens7y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0america6xi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cher3ks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0a1b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp2w2ell3ia1ksha5oes2p0ping5uji3w0time7i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ffany5ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0channel7ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lkswagen7vo3te1ing3o2yage5u0elos6wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4finity6ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",mw="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5تصالات6رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2",ui=(t,e)=>{for(const n in e)t[n]=e[n];return t},Au="numeric",Mu="ascii",Tu="alpha",fo="asciinumeric",qs="alphanumeric",Du="domain",X1="emoji",gw="scheme",bw="slashscheme",nh="whitespace";function yw(t,e){return t in e||(e[t]=[]),e[t]}function ar(t,e,n){e[Au]&&(e[fo]=!0,e[qs]=!0),e[Mu]&&(e[fo]=!0,e[Tu]=!0),e[fo]&&(e[qs]=!0),e[Tu]&&(e[qs]=!0),e[qs]&&(e[Du]=!0),e[X1]&&(e[Du]=!0);for(const r in e){const i=yw(r,n);i.indexOf(t)<0&&i.push(t)}}function xw(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function ft(t){t===void 0&&(t=null),this.j={},this.jr=[],this.jd=null,this.t=t}ft.groups={};ft.prototype={accepts(){return!!this.t},go(t){const e=this,n=e.j[t];if(n)return n;for(let r=0;rt.ta(e,n,r,i),Tt=(t,e,n,r,i)=>t.tr(e,n,r,i),rh=(t,e,n,r,i)=>t.ts(e,n,r,i),I=(t,e,n,r,i)=>t.tt(e,n,r,i),mn="WORD",Ou="UWORD",Qi="LOCALHOST",Nu="TLD",Lu="UTLD",ho="SCHEME",zr="SLASH_SCHEME",vc="NUM",Q1="WS",Ec="NL",Kr="OPENBRACE",Hi="OPENBRACKET",Bi="OPENANGLEBRACKET",Pi="OPENPAREN",rr="CLOSEBRACE",Wr="CLOSEBRACKET",jr="CLOSEANGLEBRACKET",ir="CLOSEPAREN",Fo="AMPERSAND",Ho="APOSTROPHE",Bo="ASTERISK",An="AT",Po="BACKSLASH",$o="BACKTICK",zo="CARET",On="COLON",_c="COMMA",Vo="DOLLAR",Kt="DOT",Uo="EQUALS",Cc="EXCLAMATION",Wt="HYPHEN",qo="PERCENT",Zo="PIPE",Ko="PLUS",Wo="POUND",jo="QUERY",wc="QUOTE",Sc="SEMI",jt="SLASH",$i="TILDE",Go="UNDERSCORE",em="EMOJI",Jo="SYM";var tm=Object.freeze({__proto__:null,WORD:mn,UWORD:Ou,LOCALHOST:Qi,TLD:Nu,UTLD:Lu,SCHEME:ho,SLASH_SCHEME:zr,NUM:vc,WS:Q1,NL:Ec,OPENBRACE:Kr,OPENBRACKET:Hi,OPENANGLEBRACKET:Bi,OPENPAREN:Pi,CLOSEBRACE:rr,CLOSEBRACKET:Wr,CLOSEANGLEBRACKET:jr,CLOSEPAREN:ir,AMPERSAND:Fo,APOSTROPHE:Ho,ASTERISK:Bo,AT:An,BACKSLASH:Po,BACKTICK:$o,CARET:zo,COLON:On,COMMA:_c,DOLLAR:Vo,DOT:Kt,EQUALS:Uo,EXCLAMATION:Cc,HYPHEN:Wt,PERCENT:qo,PIPE:Zo,PLUS:Ko,POUND:Wo,QUERY:jo,QUOTE:wc,SEMI:Sc,SLASH:jt,TILDE:$i,UNDERSCORE:Go,EMOJI:em,SYM:Jo});const Lr=/[a-z]/,wl=/\p{L}/u,Sl=/\p{Emoji}/u,Al=/\d/,ih=/\s/,sh=` +`,kw="️",vw="‍";let Zs=null,Ks=null;function Ew(t){t===void 0&&(t=[]);const e={};ft.groups=e;const n=new ft;Zs==null&&(Zs=oh(pw)),Ks==null&&(Ks=oh(mw)),I(n,"'",Ho),I(n,"{",Kr),I(n,"[",Hi),I(n,"<",Bi),I(n,"(",Pi),I(n,"}",rr),I(n,"]",Wr),I(n,">",jr),I(n,")",ir),I(n,"&",Fo),I(n,"*",Bo),I(n,"@",An),I(n,"`",$o),I(n,"^",zo),I(n,":",On),I(n,",",_c),I(n,"$",Vo),I(n,".",Kt),I(n,"=",Uo),I(n,"!",Cc),I(n,"-",Wt),I(n,"%",qo),I(n,"|",Zo),I(n,"+",Ko),I(n,"#",Wo),I(n,"?",jo),I(n,'"',wc),I(n,"/",jt),I(n,";",Sc),I(n,"~",$i),I(n,"_",Go),I(n,"\\",Po);const r=Tt(n,Al,vc,{[Au]:!0});Tt(r,Al,r);const i=Tt(n,Lr,mn,{[Mu]:!0});Tt(i,Lr,i);const s=Tt(n,wl,Ou,{[Tu]:!0});Tt(s,Lr),Tt(s,wl,s);const o=Tt(n,ih,Q1,{[nh]:!0});I(n,sh,Ec,{[nh]:!0}),I(o,sh),Tt(o,ih,o);const a=Tt(n,Sl,em,{[X1]:!0});Tt(a,Sl,a),I(a,kw,a);const l=I(a,vw);Tt(l,Sl,a);const u=[[Lr,i]],c=[[Lr,null],[wl,s]];for(let d=0;dd[0]>f[0]?1:-1);for(let d=0;d=0?p[Du]=!0:Lr.test(f)?Al.test(f)?p[fo]=!0:p[Mu]=!0:p[Au]=!0,rh(n,f,f,p)}return rh(n,"localhost",Qi,{ascii:!0}),n.jd=new ft(Jo),{start:n,tokens:ui({groups:e},tm)}}function _w(t,e){const n=Cw(e.replace(/[A-Z]/g,a=>a.toLowerCase())),r=n.length,i=[];let s=0,o=0;for(;o=0&&(d+=n[o].length,f++),u+=n[o].length,s+=n[o].length,o++;s-=d,o-=f,u-=d,i.push({t:c.t,v:e.slice(s-u,s),s:s-u,e:s})}return i}function Cw(t){const e=[],n=t.length;let r=0;for(;r56319||r+1===n||(s=t.charCodeAt(r+1))<56320||s>57343?t[r]:t.slice(r,r+2);e.push(o),r+=o.length}return e}function _n(t,e,n,r,i){let s;const o=e.length;for(let a=0;a=0;)s++;if(s>0){e.push(n.join(""));for(let o=parseInt(t.substring(r,r+s),10);o>0;o--)n.pop();r+=s}else n.push(t[r]),r++}return e}const es={defaultProtocol:"http",events:null,format:ah,formatHref:ah,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Ac(t,e){e===void 0&&(e=null);let n=ui({},es);t&&(n=ui(n,t instanceof Ac?t.o:t));const r=n.ignoreTags,i=[];for(let s=0;sn?r.substring(0,n)+"…":r},toFormattedHref(t){return t.get("formatHref",this.toHref(t.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(t){return t===void 0&&(t=es.defaultProtocol),{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const e=this,n=this.toHref(t.get("defaultProtocol")),r=t.get("formatHref",n,this),i=t.get("tagName",n,e),s=this.toFormattedString(t),o={},a=t.get("className",n,e),l=t.get("target",n,e),u=t.get("rel",n,e),c=t.getObj("attributes",n,e),d=t.getObj("events",n,e);return o.href=r,a&&(o.class=a),l&&(o.target=l),u&&(o.rel=u),c&&ui(o,c),{tagName:i,attributes:o,content:s,eventListeners:d}}};function Ta(t,e){class n extends nm{constructor(i,s){super(i,s),this.t=t}}for(const r in e)n.prototype[r]=e[r];return n.t=t,n}const lh=Ta("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),uh=Ta("text"),ww=Ta("nl"),Qn=Ta("url",{isLink:!0,toHref(t){return t===void 0&&(t=es.defaultProtocol),this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==Qi&&t[1].t===On}}),Pe=t=>new ft(t);function Sw(t){let{groups:e}=t;const n=e.domain.concat([Fo,Bo,An,Po,$o,zo,Vo,Uo,Wt,vc,qo,Zo,Ko,Wo,jt,Jo,$i,Go]),r=[Ho,jr,rr,Wr,ir,On,_c,Kt,Cc,Bi,Kr,Hi,Pi,jo,wc,Sc],i=[Fo,Ho,Bo,Po,$o,zo,rr,Vo,Uo,Wt,Kr,qo,Zo,Ko,Wo,jo,jt,Jo,$i,Go],s=Pe(),o=I(s,$i);Y(o,i,o),Y(o,e.domain,o);const a=Pe(),l=Pe(),u=Pe();Y(s,e.domain,a),Y(s,e.scheme,l),Y(s,e.slashscheme,u),Y(a,i,o),Y(a,e.domain,a);const c=I(a,An);I(o,An,c),I(l,An,c),I(u,An,c);const d=I(o,Kt);Y(d,i,o),Y(d,e.domain,o);const f=Pe();Y(c,e.domain,f),Y(f,e.domain,f);const h=I(f,Kt);Y(h,e.domain,f);const p=Pe(lh);Y(h,e.tld,p),Y(h,e.utld,p),I(c,Qi,p);const m=I(f,Wt);Y(m,e.domain,f),Y(p,e.domain,f),I(p,Kt,h),I(p,Wt,m);const g=I(p,On);Y(g,e.numeric,lh);const y=I(a,Wt),x=I(a,Kt);Y(y,e.domain,a),Y(x,i,o),Y(x,e.domain,a);const k=Pe(Qn);Y(x,e.tld,k),Y(x,e.utld,k),Y(k,e.domain,a),Y(k,i,o),I(k,Kt,x),I(k,Wt,y),I(k,An,c);const b=I(k,On),E=Pe(Qn);Y(b,e.numeric,E);const v=Pe(Qn),C=Pe();Y(v,n,v),Y(v,r,C),Y(C,n,v),Y(C,r,C),I(k,jt,v),I(E,jt,v);const T=I(l,On),w=I(u,On),N=I(w,jt),$=I(N,jt);Y(l,e.domain,a),I(l,Kt,x),I(l,Wt,y),Y(u,e.domain,a),I(u,Kt,x),I(u,Wt,y),Y(T,e.domain,v),I(T,jt,v),Y($,e.domain,v),Y($,n,v),I($,jt,v);const K=I(v,Kr),U=I(v,Hi),W=I(v,Bi),z=I(v,Pi);I(C,Kr,K),I(C,Hi,U),I(C,Bi,W),I(C,Pi,z),I(K,rr,v),I(U,Wr,v),I(W,jr,v),I(z,ir,v),I(K,rr,v);const A=Pe(Qn),_=Pe(Qn),S=Pe(Qn),L=Pe(Qn);Y(K,n,A),Y(U,n,_),Y(W,n,S),Y(z,n,L);const F=Pe(),j=Pe(),Q=Pe(),pe=Pe();return Y(K,r),Y(U,r),Y(W,r),Y(z,r),Y(A,n,A),Y(_,n,_),Y(S,n,S),Y(L,n,L),Y(A,r,A),Y(_,r,_),Y(S,r,S),Y(L,r,L),Y(F,n,F),Y(j,n,_),Y(Q,n,S),Y(pe,n,L),Y(F,r,F),Y(j,r,j),Y(Q,r,Q),Y(pe,r,pe),I(_,Wr,v),I(S,jr,v),I(L,ir,v),I(A,rr,v),I(j,Wr,v),I(Q,jr,v),I(pe,ir,v),I(F,ir,v),I(s,Qi,k),I(s,Ec,ww),{start:s,tokens:tm}}function Aw(t,e,n){let r=n.length,i=0,s=[],o=[];for(;i=0&&f++,i++,c++;if(f<0)i-=c,i0&&(s.push(Ml(uh,e,o)),o=[]),i-=f,c-=f;const h=d.t,p=n.slice(i-c,i);s.push(Ml(h,e,p))}}return o.length>0&&s.push(Ml(uh,e,o)),s}function Ml(t,e,n){const r=n[0].s,i=n[n.length-1].e,s=e.slice(r,i);return new t(s,n)}const Mw=typeof console<"u"&&console&&console.warn||(()=>{}),Tw="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",Oe={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function Dw(){ft.groups={},Oe.scanner=null,Oe.parser=null,Oe.tokenQueue=[],Oe.pluginQueue=[],Oe.customSchemes=[],Oe.initialized=!1}function ch(t,e){if(e===void 0&&(e=!1),Oe.initialized&&Mw(`linkifyjs: already initialized - will not register custom scheme "${t}" ${Tw}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format. 1. Must only contain digits, lowercase ASCII letters or "-" 2. Cannot start or end with "-" -3. "-" cannot repeat`);Oe.customSchemes.push([t,e])}function Dw(){Oe.scanner=vw(Oe.customSchemes);for(let t=0;t{const i=e.some(u=>u.docChanged)&&!n.doc.eq(r.doc),s=e.some(u=>u.getMeta("preventAutolink"));if(!i||s)return;const{tr:o}=r,a=Xx(n.doc,[...e]);if(s3(a).forEach(({newRange:u})=>{const c=e3(r.doc,u,h=>h.isTextblock);let d,f;if(c.length>1?(d=c[0],f=r.doc.textBetween(d.pos,d.pos+d.node.nodeSize,void 0," ")):c.length&&r.doc.textBetween(u.from,u.to," "," ").endsWith(" ")&&(d=c[0],f=r.doc.textBetween(d.pos,u.to,void 0," ")),d&&f){const h=f.split(" ").filter(y=>y!=="");if(h.length<=0)return!1;const p=h[h.length-1],m=d.pos+f.lastIndexOf(p);if(!p)return!1;const g=im(p).map(y=>y.toObject());if(!Ow(g))return!1;g.filter(y=>y.isLink).map(y=>({...y,from:m+y.start+1,to:m+y.end+1})).filter(y=>r.schema.marks.code?!r.doc.rangeHasMark(y.from,y.to,r.schema.marks.code):!0).filter(y=>t.validate?t.validate(y.value):!0).forEach(y=>{oc(y.from,y.to,r.doc).some(x=>x.mark.type===t.type)||o.addMark(y.from,y.to,t.type.create({href:y.href}))})}}),!!o.steps.length)return o}})}function Lw(t){return new we({key:new Te("handleClickLink"),props:{handleClick:(e,n,r)=>{var i,s;if(t.whenNotEditable&&e.editable||r.button!==0)return!1;let o=r.target;const a=[];for(;o.nodeName!=="DIV";)a.push(o),o=o.parentNode;if(!a.find(f=>f.nodeName==="A"))return!1;const l=X0(e.state,t.type.name),u=r.target,c=(i=u==null?void 0:u.href)!==null&&i!==void 0?i:l.href,d=(s=u==null?void 0:u.target)!==null&&s!==void 0?s:l.target;return u&&c?(window.open(c,d),!0):!1}}})}function Rw(t){return new we({key:new Te("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{state:i}=e,{selection:s}=i,{empty:o}=s;if(o)return!1;let a="";r.content.forEach(u=>{a+=u.textContent});const l=sm(a).find(u=>u.isLink&&u.value===a);return!a||!l?!1:(t.editor.commands.setMark(t.type,{href:l.href}),!0)}}})}const Iw=Ie.create({name:"link",priority:1e3,keepOnSplit:!1,onCreate(){this.options.protocols.forEach(t=>{if(typeof t=="string"){ch(t);return}ch(t.scheme,t.optionalSlashes)})},onDestroy(){Tw()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,linkOnPaste:!0,autolink:!0,protocols:[],HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},validate:void 0}},addAttributes(){return{href:{default:null},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:'a[href]:not([href *= "javascript:" i])'}]},renderHTML({HTMLAttributes:t}){var e;return!((e=t.href)===null||e===void 0)&&e.startsWith("javascript:")?["a",le(this.options.HTMLAttributes,{...t,href:""}),0]:["a",le(this.options.HTMLAttributes,t),0]},addCommands(){return{setLink:t=>({chain:e})=>e().setMark(this.name,t).setMeta("preventAutolink",!0).run(),toggleLink:t=>({chain:e})=>e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run(),unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[Zn({find:t=>{const e=[];if(t){const n=sm(t).filter(r=>r.isLink);n.length&&n.forEach(r=>e.push({text:r.value,data:{href:r.href},index:r.start}))}return e},type:this.type,getAttributes:t=>{var e;return{href:(e=t.data)===null||e===void 0?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[];return this.options.autolink&&t.push(Nw({type:this.type,validate:this.options.validate})),this.options.openOnClick&&t.push(Lw({type:this.type,whenNotEditable:this.options.openOnClick==="whenNotEditable"})),this.options.linkOnPaste&&t.push(Rw({editor:this.editor,type:this.type})),t}}),Fw=Ie.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(t){return t!=="super"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sup",le(this.options.HTMLAttributes,t),0]},addCommands(){return{setSuperscript:()=>({commands:t})=>t.setMark(this.name),toggleSuperscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSuperscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}}),Hw=Ie.create({name:"subscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sub"},{style:"vertical-align",getAttrs(t){return t!=="sub"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sub",le(this.options.HTMLAttributes,t),0]},addCommands(){return{setSubscript:()=>({commands:t})=>t.setMark(this.name),toggleSubscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSubscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}}),Bw=ue.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:t}){return["ul",le(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}}),Pw=/^\s*(\[([( |x])?\])\s$/,$w=ue.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList"}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:t=>t.getAttribute("data-checked")==="true",renderHTML:t=>({"data-checked":t.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:t,HTMLAttributes:e}){return["li",le(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{const i=document.createElement("li"),s=document.createElement("label"),o=document.createElement("span"),a=document.createElement("input"),l=document.createElement("div");return s.contentEditable="false",a.type="checkbox",a.addEventListener("change",u=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){a.checked=!a.checked;return}const{checked:c}=u.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:d})=>{const f=n(),h=d.doc.nodeAt(f);return d.setNodeMarkup(f,void 0,{...h==null?void 0:h.attrs,checked:c}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,c)||(a.checked=!a.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([u,c])=>{i.setAttribute(u,c)}),i.dataset.checked=t.attrs.checked,t.attrs.checked&&a.setAttribute("checked","checked"),s.append(a,o),i.append(s,l),Object.entries(e).forEach(([u,c])=>{i.setAttribute(u,c)}),{dom:i,contentDOM:l,update:u=>u.type!==this.type?!1:(i.dataset.checked=u.attrs.checked,u.attrs.checked?a.setAttribute("checked","checked"):a.removeAttribute("checked"),!0)}}},addInputRules(){return[vr({find:Pw,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}});var Ac={exports:{}};function Mc(t){return t instanceof Map?t.clear=t.delete=t.set=function(){throw new Error("map is read-only")}:t instanceof Set&&(t.add=t.clear=t.delete=function(){throw new Error("set is read-only")}),Object.freeze(t),Object.getOwnPropertyNames(t).forEach(function(e){var n=t[e];typeof n=="object"&&!Object.isFrozen(n)&&Mc(n)}),t}Ac.exports=Mc;Ac.exports.default=Mc;let dh=class{constructor(e){e.data===void 0&&(e.data={}),this.data=e.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}};function om(t){return t.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}function Hn(t,...e){const n=Object.create(null);for(const r in t)n[r]=t[r];return e.forEach(function(r){for(const i in r)n[i]=r[i]}),n}const zw="",fh=t=>!!t.scope||t.sublanguage&&t.language,Vw=(t,{prefix:e})=>{if(t.includes(".")){const n=t.split(".");return[`${e}${n.shift()}`,...n.map((r,i)=>`${r}${"_".repeat(i+1)}`)].join(" ")}return`${e}${t}`};let Uw=class{constructor(e,n){this.buffer="",this.classPrefix=n.classPrefix,e.walk(this)}addText(e){this.buffer+=om(e)}openNode(e){if(!fh(e))return;let n="";e.sublanguage?n=`language-${e.language}`:n=Vw(e.scope,{prefix:this.classPrefix}),this.span(n)}closeNode(e){fh(e)&&(this.buffer+=zw)}value(){return this.buffer}span(e){this.buffer+=``}};const hh=(t={})=>{const e={children:[]};return Object.assign(e,t),e};let qw=class am{constructor(){this.rootNode=hh(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(e){this.top.children.push(e)}openNode(e){const n=hh({scope:e});this.add(n),this.stack.push(n)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(e){return this.constructor._walk(e,this.rootNode)}static _walk(e,n){return typeof n=="string"?e.addText(n):n.children&&(e.openNode(n),n.children.forEach(r=>this._walk(e,r)),e.closeNode(n)),e}static _collapse(e){typeof e!="string"&&e.children&&(e.children.every(n=>typeof n=="string")?e.children=[e.children.join("")]:e.children.forEach(n=>{am._collapse(n)}))}},Zw=class extends qw{constructor(e){super(),this.options=e}addKeyword(e,n){e!==""&&(this.openNode(n),this.addText(e),this.closeNode())}addText(e){e!==""&&this.add(e)}addSublanguage(e,n){const r=e.root;r.sublanguage=!0,r.language=n,this.add(r)}toHTML(){return new Uw(this,this.options).value()}finalize(){return!0}};function ts(t){return t?typeof t=="string"?t:t.source:null}function lm(t){return Cr("(?=",t,")")}function Kw(t){return Cr("(?:",t,")*")}function Ww(t){return Cr("(?:",t,")?")}function Cr(...t){return t.map(n=>ts(n)).join("")}function jw(t){const e=t[t.length-1];return typeof e=="object"&&e.constructor===Object?(t.splice(t.length-1,1),e):{}}function Tc(...t){return"("+(jw(t).capture?"":"?:")+t.map(r=>ts(r)).join("|")+")"}function um(t){return new RegExp(t.toString()+"|").exec("").length-1}function Gw(t,e){const n=t&&t.exec(e);return n&&n.index===0}const Jw=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function Dc(t,{joinWith:e}){let n=0;return t.map(r=>{n+=1;const i=n;let s=ts(r),o="";for(;s.length>0;){const a=Jw.exec(s);if(!a){o+=s;break}o+=s.substring(0,a.index),s=s.substring(a.index+a[0].length),a[0][0]==="\\"&&a[1]?o+="\\"+String(Number(a[1])+i):(o+=a[0],a[0]==="("&&n++)}return o}).map(r=>`(${r})`).join(e)}const Yw=/\b\B/,cm="[a-zA-Z]\\w*",Oc="[a-zA-Z_]\\w*",dm="\\b\\d+(\\.\\d+)?",fm="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",hm="\\b(0b[01]+)",Xw="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",Qw=(t={})=>{const e=/^#![ ]*\//;return t.binary&&(t.begin=Cr(e,/.*\b/,t.binary,/\b.*/)),Hn({scope:"meta",begin:e,end:/$/,relevance:0,"on:begin":(n,r)=>{n.index!==0&&r.ignoreMatch()}},t)},ns={begin:"\\\\[\\s\\S]",relevance:0},e4={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[ns]},t4={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[ns]},n4={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},Da=function(t,e,n={}){const r=Hn({scope:"comment",begin:t,end:e,contains:[]},n);r.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});const i=Tc("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return r.contains.push({begin:Cr(/[ ]+/,"(",i,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),r},r4=Da("//","$"),i4=Da("/\\*","\\*/"),s4=Da("#","$"),o4={scope:"number",begin:dm,relevance:0},a4={scope:"number",begin:fm,relevance:0},l4={scope:"number",begin:hm,relevance:0},u4={begin:/(?=\/[^/\n]*\/)/,contains:[{scope:"regexp",begin:/\//,end:/\/[gimuy]*/,illegal:/\n/,contains:[ns,{begin:/\[/,end:/\]/,relevance:0,contains:[ns]}]}]},c4={scope:"title",begin:cm,relevance:0},d4={scope:"title",begin:Oc,relevance:0},f4={begin:"\\.\\s*"+Oc,relevance:0},h4=function(t){return Object.assign(t,{"on:begin":(e,n)=>{n.data._beginMatch=e[1]},"on:end":(e,n)=>{n.data._beginMatch!==e[1]&&n.ignoreMatch()}})};var Ws=Object.freeze({__proto__:null,MATCH_NOTHING_RE:Yw,IDENT_RE:cm,UNDERSCORE_IDENT_RE:Oc,NUMBER_RE:dm,C_NUMBER_RE:fm,BINARY_NUMBER_RE:hm,RE_STARTERS_RE:Xw,SHEBANG:Qw,BACKSLASH_ESCAPE:ns,APOS_STRING_MODE:e4,QUOTE_STRING_MODE:t4,PHRASAL_WORDS_MODE:n4,COMMENT:Da,C_LINE_COMMENT_MODE:r4,C_BLOCK_COMMENT_MODE:i4,HASH_COMMENT_MODE:s4,NUMBER_MODE:o4,C_NUMBER_MODE:a4,BINARY_NUMBER_MODE:l4,REGEXP_MODE:u4,TITLE_MODE:c4,UNDERSCORE_TITLE_MODE:d4,METHOD_GUARD:f4,END_SAME_AS_BEGIN:h4});function p4(t,e){t.input[t.index-1]==="."&&e.ignoreMatch()}function m4(t,e){t.className!==void 0&&(t.scope=t.className,delete t.className)}function g4(t,e){e&&t.beginKeywords&&(t.begin="\\b("+t.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",t.__beforeBegin=p4,t.keywords=t.keywords||t.beginKeywords,delete t.beginKeywords,t.relevance===void 0&&(t.relevance=0))}function b4(t,e){Array.isArray(t.illegal)&&(t.illegal=Tc(...t.illegal))}function y4(t,e){if(t.match){if(t.begin||t.end)throw new Error("begin & end are not supported with match");t.begin=t.match,delete t.match}}function x4(t,e){t.relevance===void 0&&(t.relevance=1)}const k4=(t,e)=>{if(!t.beforeMatch)return;if(t.starts)throw new Error("beforeMatch cannot be used with starts");const n=Object.assign({},t);Object.keys(t).forEach(r=>{delete t[r]}),t.keywords=n.keywords,t.begin=Cr(n.beforeMatch,lm(n.begin)),t.starts={relevance:0,contains:[Object.assign(n,{endsParent:!0})]},t.relevance=0,delete n.beforeMatch},v4=["of","and","for","in","not","or","if","then","parent","list","value"],E4="keyword";function pm(t,e,n=E4){const r=Object.create(null);return typeof t=="string"?i(n,t.split(" ")):Array.isArray(t)?i(n,t):Object.keys(t).forEach(function(s){Object.assign(r,pm(t[s],e,s))}),r;function i(s,o){e&&(o=o.map(a=>a.toLowerCase())),o.forEach(function(a){const l=a.split("|");r[l[0]]=[s,_4(l[0],l[1])]})}}function _4(t,e){return e?Number(e):C4(t)?0:1}function C4(t){return v4.includes(t.toLowerCase())}const ph={},pr=t=>{console.error(t)},mh=(t,...e)=>{console.log(`WARN: ${t}`,...e)},Rr=(t,e)=>{ph[`${t}/${e}`]||(console.log(`Deprecated as of ${t}. ${e}`),ph[`${t}/${e}`]=!0)},Yo=new Error;function mm(t,e,{key:n}){let r=0;const i=t[n],s={},o={};for(let a=1;a<=e.length;a++)o[a+r]=i[a],s[a+r]=!0,r+=um(e[a-1]);t[n]=o,t[n]._emit=s,t[n]._multi=!0}function w4(t){if(Array.isArray(t.begin)){if(t.skip||t.excludeBegin||t.returnBegin)throw pr("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),Yo;if(typeof t.beginScope!="object"||t.beginScope===null)throw pr("beginScope must be object"),Yo;mm(t,t.begin,{key:"beginScope"}),t.begin=Dc(t.begin,{joinWith:""})}}function S4(t){if(Array.isArray(t.end)){if(t.skip||t.excludeEnd||t.returnEnd)throw pr("skip, excludeEnd, returnEnd not compatible with endScope: {}"),Yo;if(typeof t.endScope!="object"||t.endScope===null)throw pr("endScope must be object"),Yo;mm(t,t.end,{key:"endScope"}),t.end=Dc(t.end,{joinWith:""})}}function A4(t){t.scope&&typeof t.scope=="object"&&t.scope!==null&&(t.beginScope=t.scope,delete t.scope)}function M4(t){A4(t),typeof t.beginScope=="string"&&(t.beginScope={_wrap:t.beginScope}),typeof t.endScope=="string"&&(t.endScope={_wrap:t.endScope}),w4(t),S4(t)}function T4(t){function e(o,a){return new RegExp(ts(o),"m"+(t.case_insensitive?"i":"")+(t.unicodeRegex?"u":"")+(a?"g":""))}class n{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(a,l){l.position=this.position++,this.matchIndexes[this.matchAt]=l,this.regexes.push([l,a]),this.matchAt+=um(a)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const a=this.regexes.map(l=>l[1]);this.matcherRe=e(Dc(a,{joinWith:"|"}),!0),this.lastIndex=0}exec(a){this.matcherRe.lastIndex=this.lastIndex;const l=this.matcherRe.exec(a);if(!l)return null;const u=l.findIndex((d,f)=>f>0&&d!==void 0),c=this.matchIndexes[u];return l.splice(0,u),Object.assign(l,c)}}class r{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(a){if(this.multiRegexes[a])return this.multiRegexes[a];const l=new n;return this.rules.slice(a).forEach(([u,c])=>l.addRule(u,c)),l.compile(),this.multiRegexes[a]=l,l}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(a,l){this.rules.push([a,l]),l.type==="begin"&&this.count++}exec(a){const l=this.getMatcher(this.regexIndex);l.lastIndex=this.lastIndex;let u=l.exec(a);if(this.resumingScanAtSamePosition()&&!(u&&u.index===this.lastIndex)){const c=this.getMatcher(0);c.lastIndex=this.lastIndex+1,u=c.exec(a)}return u&&(this.regexIndex+=u.position+1,this.regexIndex===this.count&&this.considerAll()),u}}function i(o){const a=new r;return o.contains.forEach(l=>a.addRule(l.begin,{rule:l,type:"begin"})),o.terminatorEnd&&a.addRule(o.terminatorEnd,{type:"end"}),o.illegal&&a.addRule(o.illegal,{type:"illegal"}),a}function s(o,a){const l=o;if(o.isCompiled)return l;[m4,y4,M4,k4].forEach(c=>c(o,a)),t.compilerExtensions.forEach(c=>c(o,a)),o.__beforeBegin=null,[g4,b4,x4].forEach(c=>c(o,a)),o.isCompiled=!0;let u=null;return typeof o.keywords=="object"&&o.keywords.$pattern&&(o.keywords=Object.assign({},o.keywords),u=o.keywords.$pattern,delete o.keywords.$pattern),u=u||/\w+/,o.keywords&&(o.keywords=pm(o.keywords,t.case_insensitive)),l.keywordPatternRe=e(u,!0),a&&(o.begin||(o.begin=/\B|\b/),l.beginRe=e(l.begin),!o.end&&!o.endsWithParent&&(o.end=/\B|\b/),o.end&&(l.endRe=e(l.end)),l.terminatorEnd=ts(l.end)||"",o.endsWithParent&&a.terminatorEnd&&(l.terminatorEnd+=(o.end?"|":"")+a.terminatorEnd)),o.illegal&&(l.illegalRe=e(o.illegal)),o.contains||(o.contains=[]),o.contains=[].concat(...o.contains.map(function(c){return D4(c==="self"?o:c)})),o.contains.forEach(function(c){s(c,l)}),o.starts&&s(o.starts,a),l.matcher=i(l),l}if(t.compilerExtensions||(t.compilerExtensions=[]),t.contains&&t.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return t.classNameAliases=Hn(t.classNameAliases||{}),s(t)}function gm(t){return t?t.endsWithParent||gm(t.starts):!1}function D4(t){return t.variants&&!t.cachedVariants&&(t.cachedVariants=t.variants.map(function(e){return Hn(t,{variants:null},e)})),t.cachedVariants?t.cachedVariants:gm(t)?Hn(t,{starts:t.starts?Hn(t.starts):null}):Object.isFrozen(t)?Hn(t):t}var O4="11.6.0";let N4=class extends Error{constructor(e,n){super(e),this.name="HTMLInjectionError",this.html=n}};const Tl=om,gh=Hn,bh=Symbol("nomatch"),L4=7,R4=function(t){const e=Object.create(null),n=Object.create(null),r=[];let i=!0;const s="Could not find the language '{}', did you forget to load/include a language module?",o={disableAutodetect:!0,name:"Plain text",contains:[]};let a={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:Zw};function l(A){return a.noHighlightRe.test(A)}function u(A){let _=A.className+" ";_+=A.parentNode?A.parentNode.className:"";const S=a.languageDetectRe.exec(_);if(S){const L=w(S[1]);return L||(mh(s.replace("{}",S[1])),mh("Falling back to no-highlight mode for this block.",A)),L?S[1]:"no-highlight"}return _.split(/\s+/).find(L=>l(L)||w(L))}function c(A,_,S){let L="",F="";typeof _=="object"?(L=A,S=_.ignoreIllegals,F=_.language):(Rr("10.7.0","highlight(lang, code, ...args) has been deprecated."),Rr("10.7.0",`Please use highlight(code, options) instead. -https://github.com/highlightjs/highlight.js/issues/2277`),F=A,L=_),S===void 0&&(S=!0);const j={code:L,language:F};W("before:highlight",j);const Q=j.result?j.result:d(j.language,j.code,S);return Q.code=j.code,W("after:highlight",Q),Q}function d(A,_,S,L){const F=Object.create(null);function j(H,q){return H.keywords[q]}function Q(){if(!te.keywords){V.addText(de);return}let H=0;te.keywordPatternRe.lastIndex=0;let q=te.keywordPatternRe.exec(de),D="";for(;q;){D+=de.substring(H,q.index);const R=De.case_insensitive?q[0].toLowerCase():q[0],J=j(te,R);if(J){const[ae,Fe]=J;if(V.addText(D),D="",F[R]=(F[R]||0)+1,F[R]<=L4&&(be+=Fe),ae.startsWith("_"))D+=q[0];else{const kt=De.classNameAliases[ae]||ae;V.addKeyword(q[0],kt)}}else D+=q[0];H=te.keywordPatternRe.lastIndex,q=te.keywordPatternRe.exec(de)}D+=de.substring(H),V.addText(D)}function pe(){if(de==="")return;let H=null;if(typeof te.subLanguage=="string"){if(!e[te.subLanguage]){V.addText(de);return}H=d(te.subLanguage,de,!0,Bt[te.subLanguage]),Bt[te.subLanguage]=H._top}else H=h(de,te.subLanguage.length?te.subLanguage:null);te.relevance>0&&(be+=H.relevance),V.addSublanguage(H._emitter,H.language)}function ke(){te.subLanguage!=null?pe():Q(),de=""}function fe(H,q){let D=1;const R=q.length-1;for(;D<=R;){if(!H._emit[D]){D++;continue}const J=De.classNameAliases[H[D]]||H[D],ae=q[D];J?V.addKeyword(ae,J):(de=ae,Q(),de=""),D++}}function Se(H,q){return H.scope&&typeof H.scope=="string"&&V.openNode(De.classNameAliases[H.scope]||H.scope),H.beginScope&&(H.beginScope._wrap?(V.addKeyword(de,De.classNameAliases[H.beginScope._wrap]||H.beginScope._wrap),de=""):H.beginScope._multi&&(fe(H.beginScope,q),de="")),te=Object.create(H,{parent:{value:te}}),te}function ut(H,q,D){let R=Gw(H.endRe,D);if(R){if(H["on:end"]){const J=new dh(H);H["on:end"](q,J),J.isMatchIgnored&&(R=!1)}if(R){for(;H.endsParent&&H.parent;)H=H.parent;return H}}if(H.endsWithParent)return ut(H.parent,q,D)}function We(H){return te.matcher.regexIndex===0?(de+=H[0],1):(je=!0,0)}function yt(H){const q=H[0],D=H.rule,R=new dh(D),J=[D.__beforeBegin,D["on:begin"]];for(const ae of J)if(ae&&(ae(H,R),R.isMatchIgnored))return We(q);return D.skip?de+=q:(D.excludeBegin&&(de+=q),ke(),!D.returnBegin&&!D.excludeBegin&&(de=q)),Se(D,H),D.returnBegin?0:q.length}function ct(H){const q=H[0],D=_.substring(H.index),R=ut(te,H,D);if(!R)return bh;const J=te;te.endScope&&te.endScope._wrap?(ke(),V.addKeyword(q,te.endScope._wrap)):te.endScope&&te.endScope._multi?(ke(),fe(te.endScope,H)):J.skip?de+=q:(J.returnEnd||J.excludeEnd||(de+=q),ke(),J.excludeEnd&&(de=q));do te.scope&&V.closeNode(),!te.skip&&!te.subLanguage&&(be+=te.relevance),te=te.parent;while(te!==R.parent);return R.starts&&Se(R.starts,H),J.returnEnd?0:q.length}function At(){const H=[];for(let q=te;q!==De;q=q.parent)q.scope&&H.unshift(q.scope);H.forEach(q=>V.openNode(q))}let xt={};function he(H,q){const D=q&&q[0];if(de+=H,D==null)return ke(),0;if(xt.type==="begin"&&q.type==="end"&&xt.index===q.index&&D===""){if(de+=_.slice(q.index,q.index+1),!i){const R=new Error(`0 width match regex (${A})`);throw R.languageName=A,R.badRule=xt.rule,R}return 1}if(xt=q,q.type==="begin")return yt(q);if(q.type==="illegal"&&!S){const R=new Error('Illegal lexeme "'+D+'" for mode "'+(te.scope||"")+'"');throw R.mode=te,R}else if(q.type==="end"){const R=ct(q);if(R!==bh)return R}if(q.type==="illegal"&&D==="")return 1;if(Qe>1e5&&Qe>q.index*3)throw new Error("potential infinite loop, way more iterations than matches");return de+=D,D.length}const De=w(A);if(!De)throw pr(s.replace("{}",A)),new Error('Unknown language: "'+A+'"');const rt=T4(De);let Le="",te=L||rt;const Bt={},V=new a.__emitter(a);At();let de="",be=0,ce=0,Qe=0,je=!1;try{for(te.matcher.considerAll();;){Qe++,je?je=!1:te.matcher.considerAll(),te.matcher.lastIndex=ce;const H=te.matcher.exec(_);if(!H)break;const q=_.substring(ce,H.index),D=he(q,H);ce=H.index+D}return he(_.substring(ce)),V.closeAllNodes(),V.finalize(),Le=V.toHTML(),{language:A,value:Le,relevance:be,illegal:!1,_emitter:V,_top:te}}catch(H){if(H.message&&H.message.includes("Illegal"))return{language:A,value:Tl(_),illegal:!0,relevance:0,_illegalBy:{message:H.message,index:ce,context:_.slice(ce-100,ce+100),mode:H.mode,resultSoFar:Le},_emitter:V};if(i)return{language:A,value:Tl(_),illegal:!1,relevance:0,errorRaised:H,_emitter:V,_top:te};throw H}}function f(A){const _={value:Tl(A),illegal:!1,relevance:0,_top:o,_emitter:new a.__emitter(a)};return _._emitter.addText(A),_}function h(A,_){_=_||a.languages||Object.keys(e);const S=f(A),L=_.filter(w).filter($).map(ke=>d(ke,A,!1));L.unshift(S);const F=L.sort((ke,fe)=>{if(ke.relevance!==fe.relevance)return fe.relevance-ke.relevance;if(ke.language&&fe.language){if(w(ke.language).supersetOf===fe.language)return 1;if(w(fe.language).supersetOf===ke.language)return-1}return 0}),[j,Q]=F,pe=j;return pe.secondBest=Q,pe}function p(A,_,S){const L=_&&n[_]||S;A.classList.add("hljs"),A.classList.add(`language-${L}`)}function m(A){let _=null;const S=u(A);if(l(S))return;if(W("before:highlightElement",{el:A,language:S}),A.children.length>0&&(a.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(A)),a.throwUnescapedHTML))throw new N4("One of your code blocks includes unescaped HTML.",A.innerHTML);_=A;const L=_.textContent,F=S?c(L,{language:S,ignoreIllegals:!0}):h(L);A.innerHTML=F.value,p(A,S,F.language),A.result={language:F.language,re:F.relevance,relevance:F.relevance},F.secondBest&&(A.secondBest={language:F.secondBest.language,relevance:F.secondBest.relevance}),W("after:highlightElement",{el:A,result:F,text:L})}function g(A){a=gh(a,A)}const y=()=>{b(),Rr("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function x(){b(),Rr("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let k=!1;function b(){if(document.readyState==="loading"){k=!0;return}document.querySelectorAll(a.cssSelector).forEach(m)}function E(){k&&b()}typeof window<"u"&&window.addEventListener&&window.addEventListener("DOMContentLoaded",E,!1);function v(A,_){let S=null;try{S=_(t)}catch(L){if(pr("Language definition for '{}' could not be registered.".replace("{}",A)),i)pr(L);else throw L;S=o}S.name||(S.name=A),e[A]=S,S.rawDefinition=_.bind(null,t),S.aliases&&N(S.aliases,{languageName:A})}function C(A){delete e[A];for(const _ of Object.keys(n))n[_]===A&&delete n[_]}function T(){return Object.keys(e)}function w(A){return A=(A||"").toLowerCase(),e[A]||e[n[A]]}function N(A,{languageName:_}){typeof A=="string"&&(A=[A]),A.forEach(S=>{n[S.toLowerCase()]=_})}function $(A){const _=w(A);return _&&!_.disableAutodetect}function K(A){A["before:highlightBlock"]&&!A["before:highlightElement"]&&(A["before:highlightElement"]=_=>{A["before:highlightBlock"](Object.assign({block:_.el},_))}),A["after:highlightBlock"]&&!A["after:highlightElement"]&&(A["after:highlightElement"]=_=>{A["after:highlightBlock"](Object.assign({block:_.el},_))})}function U(A){K(A),r.push(A)}function W(A,_){const S=A;r.forEach(function(L){L[S]&&L[S](_)})}function z(A){return Rr("10.7.0","highlightBlock will be removed entirely in v12.0"),Rr("10.7.0","Please use highlightElement now."),m(A)}Object.assign(t,{highlight:c,highlightAuto:h,highlightAll:b,highlightElement:m,highlightBlock:z,configure:g,initHighlighting:y,initHighlightingOnLoad:x,registerLanguage:v,unregisterLanguage:C,listLanguages:T,getLanguage:w,registerAliases:N,autoDetection:$,inherit:gh,addPlugin:U}),t.debugMode=function(){i=!1},t.safeMode=function(){i=!0},t.versionString=O4,t.regex={concat:Cr,lookahead:lm,either:Tc,optional:Ww,anyNumberOfTimes:Kw};for(const A in Ws)typeof Ws[A]=="object"&&Ac.exports(Ws[A]);return Object.assign(t,Ws),t};var rs=R4({}),I4=rs;rs.HighlightJS=rs;rs.default=rs;var F4=I4;function bm(t,e=[]){return t.map(n=>{const r=[...e,...n.properties?n.properties.className:[]];return n.children?bm(n.children,r):{text:n.value,classes:r}}).flat()}function yh(t){return t.value||t.children||[]}function H4(t){return!!F4.getLanguage(t)}function xh({doc:t,name:e,lowlight:n,defaultLanguage:r}){const i=[];return hu(t,s=>s.type.name===e).forEach(s=>{let o=s.pos+1;const a=s.node.attrs.language||r,l=n.listLanguages(),u=a&&(l.includes(a)||H4(a))?yh(n.highlight(a,s.node.textContent)):yh(n.highlightAuto(s.node.textContent));bm(u).forEach(c=>{const d=o+c.text.length;if(c.classes.length){const f=Be.inline(o,d,{class:c.classes.join(" ")});i.push(f)}o=d})}),ve.create(t,i)}function B4(t){return typeof t=="function"}function P4({name:t,lowlight:e,defaultLanguage:n}){if(!["highlight","highlightAuto","listLanguages"].every(i=>B4(e[i])))throw Error("You should provide an instance of lowlight to use the code-block-lowlight extension");const r=new we({key:new Te("lowlight"),state:{init:(i,{doc:s})=>xh({doc:s,name:t,lowlight:e,defaultLanguage:n}),apply:(i,s,o,a)=>{const l=o.selection.$head.parent.type.name,u=a.selection.$head.parent.type.name,c=hu(o.doc,f=>f.type.name===t),d=hu(a.doc,f=>f.type.name===t);return i.docChanged&&([l,u].includes(t)||d.length!==c.length||i.steps.some(f=>f.from!==void 0&&f.to!==void 0&&c.some(h=>h.pos>=f.from&&h.pos+h.node.nodeSize<=f.to)))?xh({doc:i.doc,name:t,lowlight:e,defaultLanguage:n}):s.map(i.mapping,i.doc)}},props:{decorations(i){return r.getState(i)}}});return r}const $4=F1.extend({addOptions(){var t;return{...(t=this.parent)===null||t===void 0?void 0:t.call(this),lowlight:{},defaultLanguage:null}},addProseMirrorPlugins(){var t;return[...((t=this.parent)===null||t===void 0?void 0:t.call(this))||[],P4({name:this.name,lowlight:this.options.lowlight,defaultLanguage:this.options.defaultLanguage})]}});function kh(t,e,n={}){const{empty:r,ranges:i,from:s,to:o}=t.selection,a=e?En(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(m=>a?a.name===m.type.name:!0).find(m=>ii(m.attrs,n,{strict:!1}));let l=s,u=o;const c=[];i.forEach(({$from:m,$to:g})=>{const y=m.pos,x=g.pos;l=Math.min(l,y),u=Math.max(l,x),t.doc.nodesBetween(y,x,(k,b)=>{if(!k.isText&&!k.marks.length)return;const E=Math.max(y,b),v=Math.min(x,b+k.nodeSize);c.push(...k.marks.map(C=>({mark:C,from:E,to:v})))})});const d=u-l;if(d===0)return!1;const f=c.filter(m=>a?a.name===m.mark.type.name:!0).filter(m=>ii(m.mark.attrs,n,{strict:!1})).reduce((m,g)=>m+g.to-g.from,0),h=c.filter(m=>a?m.mark.type!==a&&m.mark.type.excludes(a):!0).reduce((m,g)=>m+g.to-g.from,0);return(f>0?f+h:f)>=d}function vh(t){var e;return!!((e=t.spec.group)!=null&&e.split(" ").includes("list"))}function Eh(t,e,n={}){if(!e)return xr(t,null,n)||kh(t,null,n);const r=t.schema.nodes[e];if(r){if(vh(r)){const s=Ea(o=>vh(o.type))(t.selection);return!!(s&&s.node.type.name===e)}return xr(t,e,n)}return t.schema.marks[e]?kh(t,e,n):!1}function _h(t){return new ys({find:t.find,handler:({state:e,range:n,match:r,commands:i})=>{const s=e.doc.resolve(n.from),o=oe(t.getAttributes,void 0,r)||{};if(!s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,o),setTimeout(()=>i.focus(!0),0)}})}const ym=[{name:"Auto",value:"auto"},{name:"Plain Text",value:"plaintext",alias:["text","txt"]},{name:"Bash",value:"bash",alias:["sh"]},{name:"BASIC",value:"basic",alias:[]},{name:"C",value:"c",alias:["h"]},{name:"Clojure",value:"clojure",alias:["clj","edn"]},{name:"CMake",value:"cmake",alias:["cmake.in"]},{name:"CoffeeScript",value:"coffeescript",alias:["coffee","cson","iced"]},{name:"C++",value:"cpp",alias:["cc","c++","h++","hpp","hh","hxx","cxx"]},{name:"C#",value:"csharp",alias:["cs","c#"]},{name:"CSS",value:"css",alias:[]},{name:"Dart",value:"dart",alias:[]},{name:"Delphi",value:"delphi",alias:["dpr","dfm","pas","pascal"]},{name:"Dockerfile",value:"dockerfile",alias:["docker"]},{name:"Erlang",value:"erlang",alias:["erl"]},{name:"Go",value:"go",alias:["golang"]},{name:"GraphQL",value:"graphql",alias:["gql"]},{name:"Groovy",value:"groovy",alias:[]},{name:"Java",value:"java",alias:["jsp"]},{name:"JavaScript",value:"javascript",alias:["js","jsx","mjs","cjs"]},{name:"JSON",value:"json",alias:[]},{name:"Kotlin",value:"kotlin",alias:["kt","kts"]},{name:"Lua",value:"lua",alias:[]},{name:"Makefile",value:"makefile",alias:["mk","mak","make"]},{name:"Markdown",value:"markdown",alias:["md","mkdown","mkd"]},{name:"Matlab",value:"matlab",alias:[]},{name:"Objective-C",value:"objectivec",alias:["mm","objc","obj-c","obj-c++","objective-c++"]},{name:"PHP",value:"php",alias:[]},{name:"Properties",value:"properties",alias:[]},{name:"Python",value:"python",alias:["py","gyp","ipython"]},{name:"Ruby",value:"ruby",alias:["rb","gemspec","podspec","thor","irb"]},{name:"Rust",value:"rust",alias:["rs"]},{name:"Scala",value:"scala",alias:[]},{name:"SCSS",value:"scss",alias:[]},{name:"Shell",value:"shell",alias:["console","shellsession"]},{name:"SQL",value:"sql",alias:[]},{name:"Swift",value:"swift",alias:[]},{name:"TypeScript",value:"typescript",alias:["ts","tsx"]},{name:"WebAssembly",value:"wasm",alias:[]},{name:"HTML, XML",value:"xml",alias:["html","xhtml","rss","atom","xjb","xsd","xsl","plist","wsf","svg"]},{name:"YAML",value:"yaml",alias:["yml"]}],Ch=t=>{if(!t)return null;const e=t.toLocaleLowerCase();return ym.find(r=>r.value===e||r.alias&&r.alias.includes(e))};function z4(t,e){const{$from:n,from:r,to:i}=t,a=(e.textContent||"").split(` -`).reduce((h,p,m)=>(h[m]=(h[m-1]||0)+p.length+(m===0?0:1),h),{}),l=n.parentOffset,u=n.parentOffset+i-r,c=Object.keys(a),d=c.find(h=>a[h]>=l),f=c.find(h=>a[h]>=u);return{start:d,end:f}}const V4=/^[`·]{3}([a-z]+)?[\s\n]$/,U4=/^[~~]{3}([a-z]+)?[\s\n]$/,q4=$4.extend({addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),lowlight:{},defaultLanguage:null,languages:ym}},addCommands(){var t;return{...(t=this.parent)==null?void 0:t.call(this),addCodeComments:(e,n)=>({editor:r})=>{const{storage:i,view:{dispatch:s},state:{tr:o}}=r;s(o.setSelection(ee.create(r.state.doc,n)).deleteSelection());const a=i.markdown.serializer.serialize(e);return Kn.get(this.options.codeCommentsAi.model).chat(a,this.options.codeCommentsAi.prompt,new Ro(r,{markdownParseEnable:!0,useMarkdownTextOnly:!0})),!0},addCodeExplain:(e,n)=>({editor:r})=>{const{storage:i,view:{dispatch:s},state:{tr:o}}=r,a=r.state.doc.nodeSize;a<=n+e.nodeSize+2?(r.commands.insertContentAt(n+e.nodeSize+1,"

"),s(o.setSelection(X.create(r.state.doc,a-2)))):s(o.setSelection(X.create(r.state.doc,n+e.nodeSize+1)));const l=i.markdown.serializer.serialize(e),u=Kn.get(this.options.codeExplainAi.model);return u==null||u.chat(l,this.options.codeExplainAi.prompt,new Ro(r)),!0},toggleCodeBlock:e=>({commands:n,editor:r,chain:i})=>{const{state:s}=r,{from:o,to:a}=s.selection;if(!Eh(s,this.name)&&!s.selection.empty){let l=!0;const u=[];if(s.doc.nodesBetween(o,a,(c,d)=>{if(c.isInline)return!1;if(c.type.name!=="paragraph")return d+1<=o&&d+c.nodeSize-1>=a?void 0:(l=!1,!1);{const f=(c.textContent||"").slice(d+1>o?0:o-d-1,d+c.nodeSize-11)return i().command(({state:c,tr:d})=>(d.replaceRangeWith(o,a,this.type.create(e,c.schema.text(u.join(` -`)))),!0)).setTextSelection({from:o+2,to:o+2}).run()}return n.toggleNode(this.name,"paragraph",e)}}},addKeyboardShortcuts(){var t;return{...(t=this.parent)==null?void 0:t.call(this),Tab:({editor:e})=>{const{state:n,view:r}=e;if(!Eh(n,this.name))return!1;const{selection:i,tr:s}=n,o=" ";if(i.empty)r.dispatch(s.insertText(o));else{const{$from:a,from:l,to:u}=i,c=a.node();if(c.type!==this.type)return!1;const{start:d,end:f}=z4(i,c);if(d===void 0||f===void 0)return r.dispatch(s.replaceSelectionWith(n.schema.text(o))),!0;const m=(c.textContent||"").split(` +3. "-" cannot repeat`);Oe.customSchemes.push([t,e])}function Ow(){Oe.scanner=Ew(Oe.customSchemes);for(let t=0;t{const i=e.some(u=>u.docChanged)&&!n.doc.eq(r.doc),s=e.some(u=>u.getMeta("preventAutolink"));if(!i||s)return;const{tr:o}=r,a=Yx(n.doc,[...e]);if(i3(a).forEach(({newRange:u})=>{const c=Qx(r.doc,u,h=>h.isTextblock);let d,f;if(c.length>1?(d=c[0],f=r.doc.textBetween(d.pos,d.pos+d.node.nodeSize,void 0," ")):c.length&&r.doc.textBetween(u.from,u.to," "," ").endsWith(" ")&&(d=c[0],f=r.doc.textBetween(d.pos,u.to,void 0," ")),d&&f){const h=f.split(" ").filter(y=>y!=="");if(h.length<=0)return!1;const p=h[h.length-1],m=d.pos+f.lastIndexOf(p);if(!p)return!1;const g=rm(p).map(y=>y.toObject());if(!Nw(g))return!1;g.filter(y=>y.isLink).map(y=>({...y,from:m+y.start+1,to:m+y.end+1})).filter(y=>r.schema.marks.code?!r.doc.rangeHasMark(y.from,y.to,r.schema.marks.code):!0).filter(y=>t.validate?t.validate(y.value):!0).forEach(y=>{oc(y.from,y.to,r.doc).some(x=>x.mark.type===t.type)||o.addMark(y.from,y.to,t.type.create({href:y.href}))})}}),!!o.steps.length)return o}})}function Rw(t){return new we({key:new Te("handleClickLink"),props:{handleClick:(e,n,r)=>{var i,s;if(t.whenNotEditable&&e.editable||r.button!==0)return!1;let o=r.target;const a=[];for(;o.nodeName!=="DIV";)a.push(o),o=o.parentNode;if(!a.find(f=>f.nodeName==="A"))return!1;const l=X0(e.state,t.type.name),u=r.target,c=(i=u==null?void 0:u.href)!==null&&i!==void 0?i:l.href,d=(s=u==null?void 0:u.target)!==null&&s!==void 0?s:l.target;return u&&c?(window.open(c,d),!0):!1}}})}function Iw(t){return new we({key:new Te("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{state:i}=e,{selection:s}=i,{empty:o}=s;if(o)return!1;let a="";r.content.forEach(u=>{a+=u.textContent});const l=im(a).find(u=>u.isLink&&u.value===a);return!a||!l?!1:(t.editor.commands.setMark(t.type,{href:l.href}),!0)}}})}const Fw=Ie.create({name:"link",priority:1e3,keepOnSplit:!1,onCreate(){this.options.protocols.forEach(t=>{if(typeof t=="string"){ch(t);return}ch(t.scheme,t.optionalSlashes)})},onDestroy(){Dw()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,linkOnPaste:!0,autolink:!0,protocols:[],HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},validate:void 0}},addAttributes(){return{href:{default:null},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:'a[href]:not([href *= "javascript:" i])'}]},renderHTML({HTMLAttributes:t}){var e;return!((e=t.href)===null||e===void 0)&&e.startsWith("javascript:")?["a",le(this.options.HTMLAttributes,{...t,href:""}),0]:["a",le(this.options.HTMLAttributes,t),0]},addCommands(){return{setLink:t=>({chain:e})=>e().setMark(this.name,t).setMeta("preventAutolink",!0).run(),toggleLink:t=>({chain:e})=>e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run(),unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[Zn({find:t=>{const e=[];if(t){const n=im(t).filter(r=>r.isLink);n.length&&n.forEach(r=>e.push({text:r.value,data:{href:r.href},index:r.start}))}return e},type:this.type,getAttributes:t=>{var e;return{href:(e=t.data)===null||e===void 0?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[];return this.options.autolink&&t.push(Lw({type:this.type,validate:this.options.validate})),this.options.openOnClick&&t.push(Rw({type:this.type,whenNotEditable:this.options.openOnClick==="whenNotEditable"})),this.options.linkOnPaste&&t.push(Iw({editor:this.editor,type:this.type})),t}}),Hw=Ie.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(t){return t!=="super"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sup",le(this.options.HTMLAttributes,t),0]},addCommands(){return{setSuperscript:()=>({commands:t})=>t.setMark(this.name),toggleSuperscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSuperscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}}),Bw=Ie.create({name:"subscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sub"},{style:"vertical-align",getAttrs(t){return t!=="sub"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sub",le(this.options.HTMLAttributes,t),0]},addCommands(){return{setSubscript:()=>({commands:t})=>t.setMark(this.name),toggleSubscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSubscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}}),Pw=ue.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:t}){return["ul",le(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}}),$w=/^\s*(\[([( |x])?\])\s$/,zw=ue.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList"}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:t=>t.getAttribute("data-checked")==="true",renderHTML:t=>({"data-checked":t.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:t,HTMLAttributes:e}){return["li",le(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{const i=document.createElement("li"),s=document.createElement("label"),o=document.createElement("span"),a=document.createElement("input"),l=document.createElement("div");return s.contentEditable="false",a.type="checkbox",a.addEventListener("change",u=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){a.checked=!a.checked;return}const{checked:c}=u.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:d})=>{const f=n(),h=d.doc.nodeAt(f);return d.setNodeMarkup(f,void 0,{...h==null?void 0:h.attrs,checked:c}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,c)||(a.checked=!a.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([u,c])=>{i.setAttribute(u,c)}),i.dataset.checked=t.attrs.checked,t.attrs.checked&&a.setAttribute("checked","checked"),s.append(a,o),i.append(s,l),Object.entries(e).forEach(([u,c])=>{i.setAttribute(u,c)}),{dom:i,contentDOM:l,update:u=>u.type!==this.type?!1:(i.dataset.checked=u.attrs.checked,u.attrs.checked?a.setAttribute("checked","checked"):a.removeAttribute("checked"),!0)}}},addInputRules(){return[vr({find:$w,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}});var Mc={exports:{}};function Tc(t){return t instanceof Map?t.clear=t.delete=t.set=function(){throw new Error("map is read-only")}:t instanceof Set&&(t.add=t.clear=t.delete=function(){throw new Error("set is read-only")}),Object.freeze(t),Object.getOwnPropertyNames(t).forEach(function(e){var n=t[e];typeof n=="object"&&!Object.isFrozen(n)&&Tc(n)}),t}Mc.exports=Tc;Mc.exports.default=Tc;let dh=class{constructor(e){e.data===void 0&&(e.data={}),this.data=e.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}};function sm(t){return t.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}function Hn(t,...e){const n=Object.create(null);for(const r in t)n[r]=t[r];return e.forEach(function(r){for(const i in r)n[i]=r[i]}),n}const Vw="
",fh=t=>!!t.scope||t.sublanguage&&t.language,Uw=(t,{prefix:e})=>{if(t.includes(".")){const n=t.split(".");return[`${e}${n.shift()}`,...n.map((r,i)=>`${r}${"_".repeat(i+1)}`)].join(" ")}return`${e}${t}`};let qw=class{constructor(e,n){this.buffer="",this.classPrefix=n.classPrefix,e.walk(this)}addText(e){this.buffer+=sm(e)}openNode(e){if(!fh(e))return;let n="";e.sublanguage?n=`language-${e.language}`:n=Uw(e.scope,{prefix:this.classPrefix}),this.span(n)}closeNode(e){fh(e)&&(this.buffer+=Vw)}value(){return this.buffer}span(e){this.buffer+=``}};const hh=(t={})=>{const e={children:[]};return Object.assign(e,t),e};let Zw=class om{constructor(){this.rootNode=hh(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(e){this.top.children.push(e)}openNode(e){const n=hh({scope:e});this.add(n),this.stack.push(n)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(e){return this.constructor._walk(e,this.rootNode)}static _walk(e,n){return typeof n=="string"?e.addText(n):n.children&&(e.openNode(n),n.children.forEach(r=>this._walk(e,r)),e.closeNode(n)),e}static _collapse(e){typeof e!="string"&&e.children&&(e.children.every(n=>typeof n=="string")?e.children=[e.children.join("")]:e.children.forEach(n=>{om._collapse(n)}))}},Kw=class extends Zw{constructor(e){super(),this.options=e}addKeyword(e,n){e!==""&&(this.openNode(n),this.addText(e),this.closeNode())}addText(e){e!==""&&this.add(e)}addSublanguage(e,n){const r=e.root;r.sublanguage=!0,r.language=n,this.add(r)}toHTML(){return new qw(this,this.options).value()}finalize(){return!0}};function ts(t){return t?typeof t=="string"?t:t.source:null}function am(t){return Cr("(?=",t,")")}function Ww(t){return Cr("(?:",t,")*")}function jw(t){return Cr("(?:",t,")?")}function Cr(...t){return t.map(n=>ts(n)).join("")}function Gw(t){const e=t[t.length-1];return typeof e=="object"&&e.constructor===Object?(t.splice(t.length-1,1),e):{}}function Dc(...t){return"("+(Gw(t).capture?"":"?:")+t.map(r=>ts(r)).join("|")+")"}function lm(t){return new RegExp(t.toString()+"|").exec("").length-1}function Jw(t,e){const n=t&&t.exec(e);return n&&n.index===0}const Yw=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function Oc(t,{joinWith:e}){let n=0;return t.map(r=>{n+=1;const i=n;let s=ts(r),o="";for(;s.length>0;){const a=Yw.exec(s);if(!a){o+=s;break}o+=s.substring(0,a.index),s=s.substring(a.index+a[0].length),a[0][0]==="\\"&&a[1]?o+="\\"+String(Number(a[1])+i):(o+=a[0],a[0]==="("&&n++)}return o}).map(r=>`(${r})`).join(e)}const Xw=/\b\B/,um="[a-zA-Z]\\w*",Nc="[a-zA-Z_]\\w*",cm="\\b\\d+(\\.\\d+)?",dm="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",fm="\\b(0b[01]+)",Qw="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",e4=(t={})=>{const e=/^#![ ]*\//;return t.binary&&(t.begin=Cr(e,/.*\b/,t.binary,/\b.*/)),Hn({scope:"meta",begin:e,end:/$/,relevance:0,"on:begin":(n,r)=>{n.index!==0&&r.ignoreMatch()}},t)},ns={begin:"\\\\[\\s\\S]",relevance:0},t4={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[ns]},n4={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[ns]},r4={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},Da=function(t,e,n={}){const r=Hn({scope:"comment",begin:t,end:e,contains:[]},n);r.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});const i=Dc("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return r.contains.push({begin:Cr(/[ ]+/,"(",i,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),r},i4=Da("//","$"),s4=Da("/\\*","\\*/"),o4=Da("#","$"),a4={scope:"number",begin:cm,relevance:0},l4={scope:"number",begin:dm,relevance:0},u4={scope:"number",begin:fm,relevance:0},c4={begin:/(?=\/[^/\n]*\/)/,contains:[{scope:"regexp",begin:/\//,end:/\/[gimuy]*/,illegal:/\n/,contains:[ns,{begin:/\[/,end:/\]/,relevance:0,contains:[ns]}]}]},d4={scope:"title",begin:um,relevance:0},f4={scope:"title",begin:Nc,relevance:0},h4={begin:"\\.\\s*"+Nc,relevance:0},p4=function(t){return Object.assign(t,{"on:begin":(e,n)=>{n.data._beginMatch=e[1]},"on:end":(e,n)=>{n.data._beginMatch!==e[1]&&n.ignoreMatch()}})};var Ws=Object.freeze({__proto__:null,MATCH_NOTHING_RE:Xw,IDENT_RE:um,UNDERSCORE_IDENT_RE:Nc,NUMBER_RE:cm,C_NUMBER_RE:dm,BINARY_NUMBER_RE:fm,RE_STARTERS_RE:Qw,SHEBANG:e4,BACKSLASH_ESCAPE:ns,APOS_STRING_MODE:t4,QUOTE_STRING_MODE:n4,PHRASAL_WORDS_MODE:r4,COMMENT:Da,C_LINE_COMMENT_MODE:i4,C_BLOCK_COMMENT_MODE:s4,HASH_COMMENT_MODE:o4,NUMBER_MODE:a4,C_NUMBER_MODE:l4,BINARY_NUMBER_MODE:u4,REGEXP_MODE:c4,TITLE_MODE:d4,UNDERSCORE_TITLE_MODE:f4,METHOD_GUARD:h4,END_SAME_AS_BEGIN:p4});function m4(t,e){t.input[t.index-1]==="."&&e.ignoreMatch()}function g4(t,e){t.className!==void 0&&(t.scope=t.className,delete t.className)}function b4(t,e){e&&t.beginKeywords&&(t.begin="\\b("+t.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",t.__beforeBegin=m4,t.keywords=t.keywords||t.beginKeywords,delete t.beginKeywords,t.relevance===void 0&&(t.relevance=0))}function y4(t,e){Array.isArray(t.illegal)&&(t.illegal=Dc(...t.illegal))}function x4(t,e){if(t.match){if(t.begin||t.end)throw new Error("begin & end are not supported with match");t.begin=t.match,delete t.match}}function k4(t,e){t.relevance===void 0&&(t.relevance=1)}const v4=(t,e)=>{if(!t.beforeMatch)return;if(t.starts)throw new Error("beforeMatch cannot be used with starts");const n=Object.assign({},t);Object.keys(t).forEach(r=>{delete t[r]}),t.keywords=n.keywords,t.begin=Cr(n.beforeMatch,am(n.begin)),t.starts={relevance:0,contains:[Object.assign(n,{endsParent:!0})]},t.relevance=0,delete n.beforeMatch},E4=["of","and","for","in","not","or","if","then","parent","list","value"],_4="keyword";function hm(t,e,n=_4){const r=Object.create(null);return typeof t=="string"?i(n,t.split(" ")):Array.isArray(t)?i(n,t):Object.keys(t).forEach(function(s){Object.assign(r,hm(t[s],e,s))}),r;function i(s,o){e&&(o=o.map(a=>a.toLowerCase())),o.forEach(function(a){const l=a.split("|");r[l[0]]=[s,C4(l[0],l[1])]})}}function C4(t,e){return e?Number(e):w4(t)?0:1}function w4(t){return E4.includes(t.toLowerCase())}const ph={},pr=t=>{console.error(t)},mh=(t,...e)=>{console.log(`WARN: ${t}`,...e)},Rr=(t,e)=>{ph[`${t}/${e}`]||(console.log(`Deprecated as of ${t}. ${e}`),ph[`${t}/${e}`]=!0)},Yo=new Error;function pm(t,e,{key:n}){let r=0;const i=t[n],s={},o={};for(let a=1;a<=e.length;a++)o[a+r]=i[a],s[a+r]=!0,r+=lm(e[a-1]);t[n]=o,t[n]._emit=s,t[n]._multi=!0}function S4(t){if(Array.isArray(t.begin)){if(t.skip||t.excludeBegin||t.returnBegin)throw pr("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),Yo;if(typeof t.beginScope!="object"||t.beginScope===null)throw pr("beginScope must be object"),Yo;pm(t,t.begin,{key:"beginScope"}),t.begin=Oc(t.begin,{joinWith:""})}}function A4(t){if(Array.isArray(t.end)){if(t.skip||t.excludeEnd||t.returnEnd)throw pr("skip, excludeEnd, returnEnd not compatible with endScope: {}"),Yo;if(typeof t.endScope!="object"||t.endScope===null)throw pr("endScope must be object"),Yo;pm(t,t.end,{key:"endScope"}),t.end=Oc(t.end,{joinWith:""})}}function M4(t){t.scope&&typeof t.scope=="object"&&t.scope!==null&&(t.beginScope=t.scope,delete t.scope)}function T4(t){M4(t),typeof t.beginScope=="string"&&(t.beginScope={_wrap:t.beginScope}),typeof t.endScope=="string"&&(t.endScope={_wrap:t.endScope}),S4(t),A4(t)}function D4(t){function e(o,a){return new RegExp(ts(o),"m"+(t.case_insensitive?"i":"")+(t.unicodeRegex?"u":"")+(a?"g":""))}class n{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(a,l){l.position=this.position++,this.matchIndexes[this.matchAt]=l,this.regexes.push([l,a]),this.matchAt+=lm(a)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const a=this.regexes.map(l=>l[1]);this.matcherRe=e(Oc(a,{joinWith:"|"}),!0),this.lastIndex=0}exec(a){this.matcherRe.lastIndex=this.lastIndex;const l=this.matcherRe.exec(a);if(!l)return null;const u=l.findIndex((d,f)=>f>0&&d!==void 0),c=this.matchIndexes[u];return l.splice(0,u),Object.assign(l,c)}}class r{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(a){if(this.multiRegexes[a])return this.multiRegexes[a];const l=new n;return this.rules.slice(a).forEach(([u,c])=>l.addRule(u,c)),l.compile(),this.multiRegexes[a]=l,l}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(a,l){this.rules.push([a,l]),l.type==="begin"&&this.count++}exec(a){const l=this.getMatcher(this.regexIndex);l.lastIndex=this.lastIndex;let u=l.exec(a);if(this.resumingScanAtSamePosition()&&!(u&&u.index===this.lastIndex)){const c=this.getMatcher(0);c.lastIndex=this.lastIndex+1,u=c.exec(a)}return u&&(this.regexIndex+=u.position+1,this.regexIndex===this.count&&this.considerAll()),u}}function i(o){const a=new r;return o.contains.forEach(l=>a.addRule(l.begin,{rule:l,type:"begin"})),o.terminatorEnd&&a.addRule(o.terminatorEnd,{type:"end"}),o.illegal&&a.addRule(o.illegal,{type:"illegal"}),a}function s(o,a){const l=o;if(o.isCompiled)return l;[g4,x4,T4,v4].forEach(c=>c(o,a)),t.compilerExtensions.forEach(c=>c(o,a)),o.__beforeBegin=null,[b4,y4,k4].forEach(c=>c(o,a)),o.isCompiled=!0;let u=null;return typeof o.keywords=="object"&&o.keywords.$pattern&&(o.keywords=Object.assign({},o.keywords),u=o.keywords.$pattern,delete o.keywords.$pattern),u=u||/\w+/,o.keywords&&(o.keywords=hm(o.keywords,t.case_insensitive)),l.keywordPatternRe=e(u,!0),a&&(o.begin||(o.begin=/\B|\b/),l.beginRe=e(l.begin),!o.end&&!o.endsWithParent&&(o.end=/\B|\b/),o.end&&(l.endRe=e(l.end)),l.terminatorEnd=ts(l.end)||"",o.endsWithParent&&a.terminatorEnd&&(l.terminatorEnd+=(o.end?"|":"")+a.terminatorEnd)),o.illegal&&(l.illegalRe=e(o.illegal)),o.contains||(o.contains=[]),o.contains=[].concat(...o.contains.map(function(c){return O4(c==="self"?o:c)})),o.contains.forEach(function(c){s(c,l)}),o.starts&&s(o.starts,a),l.matcher=i(l),l}if(t.compilerExtensions||(t.compilerExtensions=[]),t.contains&&t.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return t.classNameAliases=Hn(t.classNameAliases||{}),s(t)}function mm(t){return t?t.endsWithParent||mm(t.starts):!1}function O4(t){return t.variants&&!t.cachedVariants&&(t.cachedVariants=t.variants.map(function(e){return Hn(t,{variants:null},e)})),t.cachedVariants?t.cachedVariants:mm(t)?Hn(t,{starts:t.starts?Hn(t.starts):null}):Object.isFrozen(t)?Hn(t):t}var N4="11.6.0";let L4=class extends Error{constructor(e,n){super(e),this.name="HTMLInjectionError",this.html=n}};const Tl=sm,gh=Hn,bh=Symbol("nomatch"),R4=7,I4=function(t){const e=Object.create(null),n=Object.create(null),r=[];let i=!0;const s="Could not find the language '{}', did you forget to load/include a language module?",o={disableAutodetect:!0,name:"Plain text",contains:[]};let a={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:Kw};function l(A){return a.noHighlightRe.test(A)}function u(A){let _=A.className+" ";_+=A.parentNode?A.parentNode.className:"";const S=a.languageDetectRe.exec(_);if(S){const L=w(S[1]);return L||(mh(s.replace("{}",S[1])),mh("Falling back to no-highlight mode for this block.",A)),L?S[1]:"no-highlight"}return _.split(/\s+/).find(L=>l(L)||w(L))}function c(A,_,S){let L="",F="";typeof _=="object"?(L=A,S=_.ignoreIllegals,F=_.language):(Rr("10.7.0","highlight(lang, code, ...args) has been deprecated."),Rr("10.7.0",`Please use highlight(code, options) instead. +https://github.com/highlightjs/highlight.js/issues/2277`),F=A,L=_),S===void 0&&(S=!0);const j={code:L,language:F};W("before:highlight",j);const Q=j.result?j.result:d(j.language,j.code,S);return Q.code=j.code,W("after:highlight",Q),Q}function d(A,_,S,L){const F=Object.create(null);function j(B,q){return B.keywords[q]}function Q(){if(!te.keywords){V.addText(de);return}let B=0;te.keywordPatternRe.lastIndex=0;let q=te.keywordPatternRe.exec(de),D="";for(;q;){D+=de.substring(B,q.index);const R=De.case_insensitive?q[0].toLowerCase():q[0],J=j(te,R);if(J){const[ae,Fe]=J;if(V.addText(D),D="",F[R]=(F[R]||0)+1,F[R]<=R4&&(be+=Fe),ae.startsWith("_"))D+=q[0];else{const kt=De.classNameAliases[ae]||ae;V.addKeyword(q[0],kt)}}else D+=q[0];B=te.keywordPatternRe.lastIndex,q=te.keywordPatternRe.exec(de)}D+=de.substring(B),V.addText(D)}function pe(){if(de==="")return;let B=null;if(typeof te.subLanguage=="string"){if(!e[te.subLanguage]){V.addText(de);return}B=d(te.subLanguage,de,!0,Bt[te.subLanguage]),Bt[te.subLanguage]=B._top}else B=h(de,te.subLanguage.length?te.subLanguage:null);te.relevance>0&&(be+=B.relevance),V.addSublanguage(B._emitter,B.language)}function ke(){te.subLanguage!=null?pe():Q(),de=""}function fe(B,q){let D=1;const R=q.length-1;for(;D<=R;){if(!B._emit[D]){D++;continue}const J=De.classNameAliases[B[D]]||B[D],ae=q[D];J?V.addKeyword(ae,J):(de=ae,Q(),de=""),D++}}function Se(B,q){return B.scope&&typeof B.scope=="string"&&V.openNode(De.classNameAliases[B.scope]||B.scope),B.beginScope&&(B.beginScope._wrap?(V.addKeyword(de,De.classNameAliases[B.beginScope._wrap]||B.beginScope._wrap),de=""):B.beginScope._multi&&(fe(B.beginScope,q),de="")),te=Object.create(B,{parent:{value:te}}),te}function ut(B,q,D){let R=Jw(B.endRe,D);if(R){if(B["on:end"]){const J=new dh(B);B["on:end"](q,J),J.isMatchIgnored&&(R=!1)}if(R){for(;B.endsParent&&B.parent;)B=B.parent;return B}}if(B.endsWithParent)return ut(B.parent,q,D)}function We(B){return te.matcher.regexIndex===0?(de+=B[0],1):(je=!0,0)}function yt(B){const q=B[0],D=B.rule,R=new dh(D),J=[D.__beforeBegin,D["on:begin"]];for(const ae of J)if(ae&&(ae(B,R),R.isMatchIgnored))return We(q);return D.skip?de+=q:(D.excludeBegin&&(de+=q),ke(),!D.returnBegin&&!D.excludeBegin&&(de=q)),Se(D,B),D.returnBegin?0:q.length}function ct(B){const q=B[0],D=_.substring(B.index),R=ut(te,B,D);if(!R)return bh;const J=te;te.endScope&&te.endScope._wrap?(ke(),V.addKeyword(q,te.endScope._wrap)):te.endScope&&te.endScope._multi?(ke(),fe(te.endScope,B)):J.skip?de+=q:(J.returnEnd||J.excludeEnd||(de+=q),ke(),J.excludeEnd&&(de=q));do te.scope&&V.closeNode(),!te.skip&&!te.subLanguage&&(be+=te.relevance),te=te.parent;while(te!==R.parent);return R.starts&&Se(R.starts,B),J.returnEnd?0:q.length}function At(){const B=[];for(let q=te;q!==De;q=q.parent)q.scope&&B.unshift(q.scope);B.forEach(q=>V.openNode(q))}let xt={};function he(B,q){const D=q&&q[0];if(de+=B,D==null)return ke(),0;if(xt.type==="begin"&&q.type==="end"&&xt.index===q.index&&D===""){if(de+=_.slice(q.index,q.index+1),!i){const R=new Error(`0 width match regex (${A})`);throw R.languageName=A,R.badRule=xt.rule,R}return 1}if(xt=q,q.type==="begin")return yt(q);if(q.type==="illegal"&&!S){const R=new Error('Illegal lexeme "'+D+'" for mode "'+(te.scope||"")+'"');throw R.mode=te,R}else if(q.type==="end"){const R=ct(q);if(R!==bh)return R}if(q.type==="illegal"&&D==="")return 1;if(Qe>1e5&&Qe>q.index*3)throw new Error("potential infinite loop, way more iterations than matches");return de+=D,D.length}const De=w(A);if(!De)throw pr(s.replace("{}",A)),new Error('Unknown language: "'+A+'"');const rt=D4(De);let Le="",te=L||rt;const Bt={},V=new a.__emitter(a);At();let de="",be=0,ce=0,Qe=0,je=!1;try{for(te.matcher.considerAll();;){Qe++,je?je=!1:te.matcher.considerAll(),te.matcher.lastIndex=ce;const B=te.matcher.exec(_);if(!B)break;const q=_.substring(ce,B.index),D=he(q,B);ce=B.index+D}return he(_.substring(ce)),V.closeAllNodes(),V.finalize(),Le=V.toHTML(),{language:A,value:Le,relevance:be,illegal:!1,_emitter:V,_top:te}}catch(B){if(B.message&&B.message.includes("Illegal"))return{language:A,value:Tl(_),illegal:!0,relevance:0,_illegalBy:{message:B.message,index:ce,context:_.slice(ce-100,ce+100),mode:B.mode,resultSoFar:Le},_emitter:V};if(i)return{language:A,value:Tl(_),illegal:!1,relevance:0,errorRaised:B,_emitter:V,_top:te};throw B}}function f(A){const _={value:Tl(A),illegal:!1,relevance:0,_top:o,_emitter:new a.__emitter(a)};return _._emitter.addText(A),_}function h(A,_){_=_||a.languages||Object.keys(e);const S=f(A),L=_.filter(w).filter($).map(ke=>d(ke,A,!1));L.unshift(S);const F=L.sort((ke,fe)=>{if(ke.relevance!==fe.relevance)return fe.relevance-ke.relevance;if(ke.language&&fe.language){if(w(ke.language).supersetOf===fe.language)return 1;if(w(fe.language).supersetOf===ke.language)return-1}return 0}),[j,Q]=F,pe=j;return pe.secondBest=Q,pe}function p(A,_,S){const L=_&&n[_]||S;A.classList.add("hljs"),A.classList.add(`language-${L}`)}function m(A){let _=null;const S=u(A);if(l(S))return;if(W("before:highlightElement",{el:A,language:S}),A.children.length>0&&(a.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(A)),a.throwUnescapedHTML))throw new L4("One of your code blocks includes unescaped HTML.",A.innerHTML);_=A;const L=_.textContent,F=S?c(L,{language:S,ignoreIllegals:!0}):h(L);A.innerHTML=F.value,p(A,S,F.language),A.result={language:F.language,re:F.relevance,relevance:F.relevance},F.secondBest&&(A.secondBest={language:F.secondBest.language,relevance:F.secondBest.relevance}),W("after:highlightElement",{el:A,result:F,text:L})}function g(A){a=gh(a,A)}const y=()=>{b(),Rr("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function x(){b(),Rr("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let k=!1;function b(){if(document.readyState==="loading"){k=!0;return}document.querySelectorAll(a.cssSelector).forEach(m)}function E(){k&&b()}typeof window<"u"&&window.addEventListener&&window.addEventListener("DOMContentLoaded",E,!1);function v(A,_){let S=null;try{S=_(t)}catch(L){if(pr("Language definition for '{}' could not be registered.".replace("{}",A)),i)pr(L);else throw L;S=o}S.name||(S.name=A),e[A]=S,S.rawDefinition=_.bind(null,t),S.aliases&&N(S.aliases,{languageName:A})}function C(A){delete e[A];for(const _ of Object.keys(n))n[_]===A&&delete n[_]}function T(){return Object.keys(e)}function w(A){return A=(A||"").toLowerCase(),e[A]||e[n[A]]}function N(A,{languageName:_}){typeof A=="string"&&(A=[A]),A.forEach(S=>{n[S.toLowerCase()]=_})}function $(A){const _=w(A);return _&&!_.disableAutodetect}function K(A){A["before:highlightBlock"]&&!A["before:highlightElement"]&&(A["before:highlightElement"]=_=>{A["before:highlightBlock"](Object.assign({block:_.el},_))}),A["after:highlightBlock"]&&!A["after:highlightElement"]&&(A["after:highlightElement"]=_=>{A["after:highlightBlock"](Object.assign({block:_.el},_))})}function U(A){K(A),r.push(A)}function W(A,_){const S=A;r.forEach(function(L){L[S]&&L[S](_)})}function z(A){return Rr("10.7.0","highlightBlock will be removed entirely in v12.0"),Rr("10.7.0","Please use highlightElement now."),m(A)}Object.assign(t,{highlight:c,highlightAuto:h,highlightAll:b,highlightElement:m,highlightBlock:z,configure:g,initHighlighting:y,initHighlightingOnLoad:x,registerLanguage:v,unregisterLanguage:C,listLanguages:T,getLanguage:w,registerAliases:N,autoDetection:$,inherit:gh,addPlugin:U}),t.debugMode=function(){i=!1},t.safeMode=function(){i=!0},t.versionString=N4,t.regex={concat:Cr,lookahead:am,either:Dc,optional:jw,anyNumberOfTimes:Ww};for(const A in Ws)typeof Ws[A]=="object"&&Mc.exports(Ws[A]);return Object.assign(t,Ws),t};var rs=I4({}),F4=rs;rs.HighlightJS=rs;rs.default=rs;var H4=F4;function gm(t,e=[]){return t.map(n=>{const r=[...e,...n.properties?n.properties.className:[]];return n.children?gm(n.children,r):{text:n.value,classes:r}}).flat()}function yh(t){return t.value||t.children||[]}function B4(t){return!!H4.getLanguage(t)}function xh({doc:t,name:e,lowlight:n,defaultLanguage:r}){const i=[];return hu(t,s=>s.type.name===e).forEach(s=>{let o=s.pos+1;const a=s.node.attrs.language||r,l=n.listLanguages(),u=a&&(l.includes(a)||B4(a))?yh(n.highlight(a,s.node.textContent)):yh(n.highlightAuto(s.node.textContent));gm(u).forEach(c=>{const d=o+c.text.length;if(c.classes.length){const f=Be.inline(o,d,{class:c.classes.join(" ")});i.push(f)}o=d})}),ve.create(t,i)}function P4(t){return typeof t=="function"}function $4({name:t,lowlight:e,defaultLanguage:n}){if(!["highlight","highlightAuto","listLanguages"].every(i=>P4(e[i])))throw Error("You should provide an instance of lowlight to use the code-block-lowlight extension");const r=new we({key:new Te("lowlight"),state:{init:(i,{doc:s})=>xh({doc:s,name:t,lowlight:e,defaultLanguage:n}),apply:(i,s,o,a)=>{const l=o.selection.$head.parent.type.name,u=a.selection.$head.parent.type.name,c=hu(o.doc,f=>f.type.name===t),d=hu(a.doc,f=>f.type.name===t);return i.docChanged&&([l,u].includes(t)||d.length!==c.length||i.steps.some(f=>f.from!==void 0&&f.to!==void 0&&c.some(h=>h.pos>=f.from&&h.pos+h.node.nodeSize<=f.to)))?xh({doc:i.doc,name:t,lowlight:e,defaultLanguage:n}):s.map(i.mapping,i.doc)}},props:{decorations(i){return r.getState(i)}}});return r}const z4=I1.extend({addOptions(){var t;return{...(t=this.parent)===null||t===void 0?void 0:t.call(this),lowlight:{},defaultLanguage:null}},addProseMirrorPlugins(){var t;return[...((t=this.parent)===null||t===void 0?void 0:t.call(this))||[],$4({name:this.name,lowlight:this.options.lowlight,defaultLanguage:this.options.defaultLanguage})]}});function kh(t,e,n={}){const{empty:r,ranges:i,from:s,to:o}=t.selection,a=e?En(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(m=>a?a.name===m.type.name:!0).find(m=>ii(m.attrs,n,{strict:!1}));let l=s,u=o;const c=[];i.forEach(({$from:m,$to:g})=>{const y=m.pos,x=g.pos;l=Math.min(l,y),u=Math.max(l,x),t.doc.nodesBetween(y,x,(k,b)=>{if(!k.isText&&!k.marks.length)return;const E=Math.max(y,b),v=Math.min(x,b+k.nodeSize);c.push(...k.marks.map(C=>({mark:C,from:E,to:v})))})});const d=u-l;if(d===0)return!1;const f=c.filter(m=>a?a.name===m.mark.type.name:!0).filter(m=>ii(m.mark.attrs,n,{strict:!1})).reduce((m,g)=>m+g.to-g.from,0),h=c.filter(m=>a?m.mark.type!==a&&m.mark.type.excludes(a):!0).reduce((m,g)=>m+g.to-g.from,0);return(f>0?f+h:f)>=d}function vh(t){var e;return!!((e=t.spec.group)!=null&&e.split(" ").includes("list"))}function Eh(t,e,n={}){if(!e)return xr(t,null,n)||kh(t,null,n);const r=t.schema.nodes[e];if(r){if(vh(r)){const s=Ea(o=>vh(o.type))(t.selection);return!!(s&&s.node.type.name===e)}return xr(t,e,n)}return t.schema.marks[e]?kh(t,e,n):!1}function _h(t){return new ys({find:t.find,handler:({state:e,range:n,match:r,commands:i})=>{const s=e.doc.resolve(n.from),o=oe(t.getAttributes,void 0,r)||{};if(!s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,o),setTimeout(()=>i.focus(!0),0)}})}const bm=[{name:"Auto",value:"auto"},{name:"Plain Text",value:"plaintext",alias:["text","txt"]},{name:"Bash",value:"bash",alias:["sh"]},{name:"BASIC",value:"basic",alias:[]},{name:"C",value:"c",alias:["h"]},{name:"Clojure",value:"clojure",alias:["clj","edn"]},{name:"CMake",value:"cmake",alias:["cmake.in"]},{name:"CoffeeScript",value:"coffeescript",alias:["coffee","cson","iced"]},{name:"C++",value:"cpp",alias:["cc","c++","h++","hpp","hh","hxx","cxx"]},{name:"C#",value:"csharp",alias:["cs","c#"]},{name:"CSS",value:"css",alias:[]},{name:"Dart",value:"dart",alias:[]},{name:"Delphi",value:"delphi",alias:["dpr","dfm","pas","pascal"]},{name:"Dockerfile",value:"dockerfile",alias:["docker"]},{name:"Erlang",value:"erlang",alias:["erl"]},{name:"Go",value:"go",alias:["golang"]},{name:"GraphQL",value:"graphql",alias:["gql"]},{name:"Groovy",value:"groovy",alias:[]},{name:"Java",value:"java",alias:["jsp"]},{name:"JavaScript",value:"javascript",alias:["js","jsx","mjs","cjs"]},{name:"JSON",value:"json",alias:[]},{name:"Kotlin",value:"kotlin",alias:["kt","kts"]},{name:"Lua",value:"lua",alias:[]},{name:"Makefile",value:"makefile",alias:["mk","mak","make"]},{name:"Markdown",value:"markdown",alias:["md","mkdown","mkd"]},{name:"Matlab",value:"matlab",alias:[]},{name:"Objective-C",value:"objectivec",alias:["mm","objc","obj-c","obj-c++","objective-c++"]},{name:"PHP",value:"php",alias:[]},{name:"Properties",value:"properties",alias:[]},{name:"Python",value:"python",alias:["py","gyp","ipython"]},{name:"Ruby",value:"ruby",alias:["rb","gemspec","podspec","thor","irb"]},{name:"Rust",value:"rust",alias:["rs"]},{name:"Scala",value:"scala",alias:[]},{name:"SCSS",value:"scss",alias:[]},{name:"Shell",value:"shell",alias:["console","shellsession"]},{name:"SQL",value:"sql",alias:[]},{name:"Swift",value:"swift",alias:[]},{name:"TypeScript",value:"typescript",alias:["ts","tsx"]},{name:"WebAssembly",value:"wasm",alias:[]},{name:"HTML, XML",value:"xml",alias:["html","xhtml","rss","atom","xjb","xsd","xsl","plist","wsf","svg"]},{name:"YAML",value:"yaml",alias:["yml"]}],Ch=t=>{if(!t)return null;const e=t.toLocaleLowerCase();return bm.find(r=>r.value===e||r.alias&&r.alias.includes(e))};function V4(t,e){const{$from:n,from:r,to:i}=t,a=(e.textContent||"").split(` +`).reduce((h,p,m)=>(h[m]=(h[m-1]||0)+p.length+(m===0?0:1),h),{}),l=n.parentOffset,u=n.parentOffset+i-r,c=Object.keys(a),d=c.find(h=>a[h]>=l),f=c.find(h=>a[h]>=u);return{start:d,end:f}}const U4=/^[`·]{3}([a-z]+)?[\s\n]$/,q4=/^[~~]{3}([a-z]+)?[\s\n]$/,Z4=z4.extend({addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),lowlight:{},defaultLanguage:null,languages:bm}},addCommands(){var t;return{...(t=this.parent)==null?void 0:t.call(this),addCodeComments:(e,n)=>({editor:r})=>{const{storage:i,view:{dispatch:s},state:{tr:o}}=r;s(o.setSelection(ee.create(r.state.doc,n)).deleteSelection());const a=i.markdown.serializer.serialize(e);return Kn.get(this.options.codeCommentsAi.model).chat(a,this.options.codeCommentsAi.prompt,new Ro(r,{markdownParseEnable:!0,useMarkdownTextOnly:!0})),!0},addCodeExplain:(e,n)=>({editor:r})=>{const{storage:i,view:{dispatch:s},state:{tr:o}}=r,a=r.state.doc.nodeSize;a<=n+e.nodeSize+2?(r.commands.insertContentAt(n+e.nodeSize+1,"

"),s(o.setSelection(X.create(r.state.doc,a-2)))):s(o.setSelection(X.create(r.state.doc,n+e.nodeSize+1)));const l=i.markdown.serializer.serialize(e),u=Kn.get(this.options.codeExplainAi.model);return u==null||u.chat(l,this.options.codeExplainAi.prompt,new Ro(r)),!0},toggleCodeBlock:e=>({commands:n,editor:r,chain:i})=>{const{state:s}=r,{from:o,to:a}=s.selection;if(!Eh(s,this.name)&&!s.selection.empty){let l=!0;const u=[];if(s.doc.nodesBetween(o,a,(c,d)=>{if(c.isInline)return!1;if(c.type.name!=="paragraph")return d+1<=o&&d+c.nodeSize-1>=a?void 0:(l=!1,!1);{const f=(c.textContent||"").slice(d+1>o?0:o-d-1,d+c.nodeSize-11)return i().command(({state:c,tr:d})=>(d.replaceRangeWith(o,a,this.type.create(e,c.schema.text(u.join(` +`)))),!0)).setTextSelection({from:o+2,to:o+2}).run()}return n.toggleNode(this.name,"paragraph",e)}}},addKeyboardShortcuts(){var t;return{...(t=this.parent)==null?void 0:t.call(this),Tab:({editor:e})=>{const{state:n,view:r}=e;if(!Eh(n,this.name))return!1;const{selection:i,tr:s}=n,o=" ";if(i.empty)r.dispatch(s.insertText(o));else{const{$from:a,from:l,to:u}=i,c=a.node();if(c.type!==this.type)return!1;const{start:d,end:f}=V4(i,c);if(d===void 0||f===void 0)return r.dispatch(s.replaceSelectionWith(n.schema.text(o))),!0;const m=(c.textContent||"").split(` `).map((x,k)=>k>=d&&k<=f&&x?o+x:x),g=a.node(1),y=a.start(1);s.replaceWith(y,y+g.nodeSize-2,n.schema.text(m.join(` -`))),s.setSelection(X.between(s.doc.resolve(l+o.length),s.doc.resolve(u+(f-d+1)*o.length))),r.dispatch(s)}return!0}}},addInputRules(){return[_h({find:V4,type:this.type,getAttributes:t=>{var e;return{language:((e=Ch(t[1]))==null?void 0:e.value)||this.options.defaultLanguage}}}),_h({find:U4,type:this.type,getAttributes:t=>{var e;return{language:((e=Ch(t[1]))==null?void 0:e.value)||this.options.defaultLanguage}}})]},addNodeView(){return t=>{var s,o;const e=document.createElement("div");e.classList.add("aie-codeblock-wrapper");const{language:n}=t.node.attrs;if(!this.editor.isEditable)return e.innerHTML=` +`))),s.setSelection(X.between(s.doc.resolve(l+o.length),s.doc.resolve(u+(f-d+1)*o.length))),r.dispatch(s)}return!0}}},addInputRules(){return[_h({find:U4,type:this.type,getAttributes:t=>{var e;return{language:((e=Ch(t[1]))==null?void 0:e.value)||this.options.defaultLanguage}}}),_h({find:q4,type:this.type,getAttributes:t=>{var e;return{language:((e=Ch(t[1]))==null?void 0:e.value)||this.options.defaultLanguage}}})]},addNodeView(){return t=>{var s,o;const e=document.createElement("div");e.classList.add("aie-codeblock-wrapper");const{language:n}=t.node.attrs;if(!this.editor.isEditable)return e.innerHTML=`
${n||this.options.defaultLanguage}
@@ -375,10 +385,10 @@ https://github.com/highlightjs/highlight.js/issues/2277`),F=A,L=_),S===void 0&&(
`;const r=()=>{const a=document.createElement("div");return a.classList.add("aie-codeblock-langs"),a.innerHTML=` - ${this.options.languages.map(l=>`
${l.name}
`).join("")}`,a.addEventListener("click",l=>{const u=l.target.closest(".aie-codeblock-langs-item");if(u){const c=u.getAttribute("data-item");t.editor.chain().setCodeBlock({language:c}).run()}}),a},i=Ke(e.querySelector(".aie-codeblock-tools-lang"),{content:r(),appendTo:t.editor.options.element,placement:"bottom-end",trigger:"click",interactive:!0,arrow:!1,aria:{content:null,expanded:!1}});return(s=e.querySelector(".aie-codeblock-tools-comments"))==null||s.addEventListener("click",a=>{const l=t.editor.view.posAtCoords({left:a.clientX,top:a.clientY}),u=t.editor.state.doc.resolve(l.pos).parent;t.editor.chain().addCodeComments(u,l.pos)}),(o=e.querySelector(".aie-codeblock-tools-explain"))==null||o.addEventListener("click",a=>{const l=t.editor.view.posAtCoords({left:a.clientX,top:a.clientY}),u=t.editor.state.doc.resolve(l.pos).parent;t.editor.chain().addCodeExplain(u,l.pos)}),{dom:e,contentDOM:e.querySelector("code"),destroy:()=>{i.destroy()}}}}});function Z4(t){const e=t.regex,n=t.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),r="decltype\\(auto\\)",i="[a-zA-Z_]\\w*::",s="<[^<>]+>",o="(?!struct)("+r+"|"+e.optional(i)+"[a-zA-Z_]\\w*"+e.optional(s)+")",a={className:"type",begin:"\\b[a-z\\d_]*_t\\b"},l="\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)",u={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[t.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'("+l+"|.)",end:"'",illegal:"."},t.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},c={className:"number",variants:[{begin:"\\b(0b[01']+)"},{begin:"(-?)\\b([\\d']+(\\.[\\d']*)?|\\.[\\d']+)((ll|LL|l|L)(u|U)?|(u|U)(ll|LL|l|L)?|f|F|b|B)"},{begin:"(-?)(\\b0[xX][a-fA-F0-9']+|(\\b[\\d']+(\\.[\\d']*)?|\\.[\\d']+)([eE][-+]?[\\d']+)?)"}],relevance:0},d={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},t.inherit(u,{className:"string"}),{className:"string",begin:/<.*?>/},n,t.C_BLOCK_COMMENT_MODE]},f={className:"title",begin:e.optional(i)+t.IDENT_RE,relevance:0},h=e.optional(i)+t.IDENT_RE+"\\s*\\(",p=["alignas","alignof","and","and_eq","asm","atomic_cancel","atomic_commit","atomic_noexcept","auto","bitand","bitor","break","case","catch","class","co_await","co_return","co_yield","compl","concept","const_cast|10","consteval","constexpr","constinit","continue","decltype","default","delete","do","dynamic_cast|10","else","enum","explicit","export","extern","false","final","for","friend","goto","if","import","inline","module","mutable","namespace","new","noexcept","not","not_eq","nullptr","operator","or","or_eq","override","private","protected","public","reflexpr","register","reinterpret_cast|10","requires","return","sizeof","static_assert","static_cast|10","struct","switch","synchronized","template","this","thread_local","throw","transaction_safe","transaction_safe_dynamic","true","try","typedef","typeid","typename","union","using","virtual","volatile","while","xor","xor_eq"],m=["bool","char","char16_t","char32_t","char8_t","double","float","int","long","short","void","wchar_t","unsigned","signed","const","static"],g=["any","auto_ptr","barrier","binary_semaphore","bitset","complex","condition_variable","condition_variable_any","counting_semaphore","deque","false_type","future","imaginary","initializer_list","istringstream","jthread","latch","lock_guard","multimap","multiset","mutex","optional","ostringstream","packaged_task","pair","promise","priority_queue","queue","recursive_mutex","recursive_timed_mutex","scoped_lock","set","shared_future","shared_lock","shared_mutex","shared_timed_mutex","shared_ptr","stack","string_view","stringstream","timed_mutex","thread","true_type","tuple","unique_lock","unique_ptr","unordered_map","unordered_multimap","unordered_multiset","unordered_set","variant","vector","weak_ptr","wstring","wstring_view"],y=["abort","abs","acos","apply","as_const","asin","atan","atan2","calloc","ceil","cerr","cin","clog","cos","cosh","cout","declval","endl","exchange","exit","exp","fabs","floor","fmod","forward","fprintf","fputs","free","frexp","fscanf","future","invoke","isalnum","isalpha","iscntrl","isdigit","isgraph","islower","isprint","ispunct","isspace","isupper","isxdigit","labs","launder","ldexp","log","log10","make_pair","make_shared","make_shared_for_overwrite","make_tuple","make_unique","malloc","memchr","memcmp","memcpy","memset","modf","move","pow","printf","putchar","puts","realloc","scanf","sin","sinh","snprintf","sprintf","sqrt","sscanf","std","stderr","stdin","stdout","strcat","strchr","strcmp","strcpy","strcspn","strlen","strncat","strncmp","strncpy","strpbrk","strrchr","strspn","strstr","swap","tan","tanh","terminate","to_underlying","tolower","toupper","vfprintf","visit","vprintf","vsprintf"],b={type:m,keyword:p,literal:["NULL","false","nullopt","nullptr","true"],built_in:["_Pragma"],_type_hints:g},E={className:"function.dispatch",relevance:0,keywords:{_hint:y},begin:e.concat(/\b/,/(?!decltype)/,/(?!if)/,/(?!for)/,/(?!switch)/,/(?!while)/,t.IDENT_RE,e.lookahead(/(<[^<>]+>|)\s*\(/))},v=[E,d,a,n,t.C_BLOCK_COMMENT_MODE,c,u],C={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:b,contains:v.concat([{begin:/\(/,end:/\)/,keywords:b,contains:v.concat(["self"]),relevance:0}]),relevance:0},T={className:"function",begin:"("+o+"[\\*&\\s]+)+"+h,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:b,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:r,keywords:b,relevance:0},{begin:h,returnBegin:!0,contains:[f],relevance:0},{begin:/::/,relevance:0},{begin:/:/,endsWithParent:!0,contains:[u,c]},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:b,relevance:0,contains:[n,t.C_BLOCK_COMMENT_MODE,u,c,a,{begin:/\(/,end:/\)/,keywords:b,relevance:0,contains:["self",n,t.C_BLOCK_COMMENT_MODE,u,c,a]}]},a,n,t.C_BLOCK_COMMENT_MODE,d]};return{name:"C++",aliases:["cc","c++","h++","hpp","hh","hxx","cxx"],keywords:b,illegal:"",keywords:b,contains:["self",a]},{begin:t.IDENT_RE+"::",keywords:b},{match:[/\b(?:enum(?:\s+(?:class|struct))?|class|struct|union)/,/\s+/,/\w+/],className:{1:"keyword",3:"title.class"}}])}}function K4(t){const e={type:["boolean","byte","word","String"],built_in:["KeyboardController","MouseController","SoftwareSerial","EthernetServer","EthernetClient","LiquidCrystal","RobotControl","GSMVoiceCall","EthernetUDP","EsploraTFT","HttpClient","RobotMotor","WiFiClient","GSMScanner","FileSystem","Scheduler","GSMServer","YunClient","YunServer","IPAddress","GSMClient","GSMModem","Keyboard","Ethernet","Console","GSMBand","Esplora","Stepper","Process","WiFiUDP","GSM_SMS","Mailbox","USBHost","Firmata","PImage","Client","Server","GSMPIN","FileIO","Bridge","Serial","EEPROM","Stream","Mouse","Audio","Servo","File","Task","GPRS","WiFi","Wire","TFT","GSM","SPI","SD"],_hints:["setup","loop","runShellCommandAsynchronously","analogWriteResolution","retrieveCallingNumber","printFirmwareVersion","analogReadResolution","sendDigitalPortPair","noListenOnLocalhost","readJoystickButton","setFirmwareVersion","readJoystickSwitch","scrollDisplayRight","getVoiceCallStatus","scrollDisplayLeft","writeMicroseconds","delayMicroseconds","beginTransmission","getSignalStrength","runAsynchronously","getAsynchronously","listenOnLocalhost","getCurrentCarrier","readAccelerometer","messageAvailable","sendDigitalPorts","lineFollowConfig","countryNameWrite","runShellCommand","readStringUntil","rewindDirectory","readTemperature","setClockDivider","readLightSensor","endTransmission","analogReference","detachInterrupt","countryNameRead","attachInterrupt","encryptionType","readBytesUntil","robotNameWrite","readMicrophone","robotNameRead","cityNameWrite","userNameWrite","readJoystickY","readJoystickX","mouseReleased","openNextFile","scanNetworks","noInterrupts","digitalWrite","beginSpeaker","mousePressed","isActionDone","mouseDragged","displayLogos","noAutoscroll","addParameter","remoteNumber","getModifiers","keyboardRead","userNameRead","waitContinue","processInput","parseCommand","printVersion","readNetworks","writeMessage","blinkVersion","cityNameRead","readMessage","setDataMode","parsePacket","isListening","setBitOrder","beginPacket","isDirectory","motorsWrite","drawCompass","digitalRead","clearScreen","serialEvent","rightToLeft","setTextSize","leftToRight","requestFrom","keyReleased","compassRead","analogWrite","interrupts","WiFiServer","disconnect","playMelody","parseFloat","autoscroll","getPINUsed","setPINUsed","setTimeout","sendAnalog","readSlider","analogRead","beginWrite","createChar","motorsStop","keyPressed","tempoWrite","readButton","subnetMask","debugPrint","macAddress","writeGreen","randomSeed","attachGPRS","readString","sendString","remotePort","releaseAll","mouseMoved","background","getXChange","getYChange","answerCall","getResult","voiceCall","endPacket","constrain","getSocket","writeJSON","getButton","available","connected","findUntil","readBytes","exitValue","readGreen","writeBlue","startLoop","IPAddress","isPressed","sendSysex","pauseMode","gatewayIP","setCursor","getOemKey","tuneWrite","noDisplay","loadImage","switchPIN","onRequest","onReceive","changePIN","playFile","noBuffer","parseInt","overflow","checkPIN","knobRead","beginTFT","bitClear","updateIR","bitWrite","position","writeRGB","highByte","writeRed","setSpeed","readBlue","noStroke","remoteIP","transfer","shutdown","hangCall","beginSMS","endWrite","attached","maintain","noCursor","checkReg","checkPUK","shiftOut","isValid","shiftIn","pulseIn","connect","println","localIP","pinMode","getIMEI","display","noBlink","process","getBand","running","beginSD","drawBMP","lowByte","setBand","release","bitRead","prepare","pointTo","readRed","setMode","noFill","remove","listen","stroke","detach","attach","noTone","exists","buffer","height","bitSet","circle","config","cursor","random","IRread","setDNS","endSMS","getKey","micros","millis","begin","print","write","ready","flush","width","isPIN","blink","clear","press","mkdir","rmdir","close","point","yield","image","BSSID","click","delay","read","text","move","peek","beep","rect","line","open","seek","fill","size","turn","stop","home","find","step","tone","sqrt","RSSI","SSID","end","bit","tan","cos","sin","pow","map","abs","max","min","get","run","put"],literal:["DIGITAL_MESSAGE","FIRMATA_STRING","ANALOG_MESSAGE","REPORT_DIGITAL","REPORT_ANALOG","INPUT_PULLUP","SET_PIN_MODE","INTERNAL2V56","SYSTEM_RESET","LED_BUILTIN","INTERNAL1V1","SYSEX_START","INTERNAL","EXTERNAL","DEFAULT","OUTPUT","INPUT","HIGH","LOW"]},n=Z4(t),r=n.keywords;return r.type=[...r.type,...e.type],r.literal=[...r.literal,...e.literal],r.built_in=[...r.built_in,...e.built_in],r._hints=e._hints,n.name="Arduino",n.aliases=["ino"],n.supersetOf="cpp",n}function W4(t){const e=t.regex,n={},r={begin:/\$\{/,end:/\}/,contains:["self",{begin:/:-/,contains:[n]}]};Object.assign(n,{className:"variable",variants:[{begin:e.concat(/\$[\w\d#@][\w\d_]*/,"(?![\\w\\d])(?![$])")},r]});const i={className:"subst",begin:/\$\(/,end:/\)/,contains:[t.BACKSLASH_ESCAPE]},s={begin:/<<-?\s*(?=\w+)/,starts:{contains:[t.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,className:"string"})]}},o={className:"string",begin:/"/,end:/"/,contains:[t.BACKSLASH_ESCAPE,n,i]};i.contains.push(o);const a={match:/\\"/},l={className:"string",begin:/'/,end:/'/},u={match:/\\'/},c={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},t.NUMBER_MODE,n]},d=["fish","bash","zsh","sh","csh","ksh","tcsh","dash","scsh"],f=t.SHEBANG({binary:`(${d.join("|")})`,relevance:10}),h={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[t.inherit(t.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0},p=["if","then","else","elif","fi","for","while","until","in","do","done","case","esac","function","select"],m=["true","false"],g={match:/(\/[a-z._-]+)+/},y=["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset"],x=["alias","bind","builtin","caller","command","declare","echo","enable","help","let","local","logout","mapfile","printf","read","readarray","source","type","typeset","ulimit","unalias"],k=["autoload","bg","bindkey","bye","cap","chdir","clone","comparguments","compcall","compctl","compdescribe","compfiles","compgroups","compquote","comptags","comptry","compvalues","dirs","disable","disown","echotc","echoti","emulate","fc","fg","float","functions","getcap","getln","history","integer","jobs","kill","limit","log","noglob","popd","print","pushd","pushln","rehash","sched","setcap","setopt","stat","suspend","ttyctl","unfunction","unhash","unlimit","unsetopt","vared","wait","whence","where","which","zcompile","zformat","zftp","zle","zmodload","zparseopts","zprof","zpty","zregexparse","zsocket","zstyle","ztcp"],b=["chcon","chgrp","chown","chmod","cp","dd","df","dir","dircolors","ln","ls","mkdir","mkfifo","mknod","mktemp","mv","realpath","rm","rmdir","shred","sync","touch","truncate","vdir","b2sum","base32","base64","cat","cksum","comm","csplit","cut","expand","fmt","fold","head","join","md5sum","nl","numfmt","od","paste","ptx","pr","sha1sum","sha224sum","sha256sum","sha384sum","sha512sum","shuf","sort","split","sum","tac","tail","tr","tsort","unexpand","uniq","wc","arch","basename","chroot","date","dirname","du","echo","env","expr","factor","groups","hostid","id","link","logname","nice","nohup","nproc","pathchk","pinky","printenv","printf","pwd","readlink","runcon","seq","sleep","stat","stdbuf","stty","tee","test","timeout","tty","uname","unlink","uptime","users","who","whoami","yes"];return{name:"Bash",aliases:["sh"],keywords:{$pattern:/\b[a-z][a-z0-9._-]+\b/,keyword:p,literal:m,built_in:[...y,...x,"set","shopt",...k,...b]},contains:[f,t.SHEBANG(),h,c,t.HASH_COMMENT_MODE,s,g,o,a,l,u,n]}}function j4(t){const e=t.regex,n=t.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),r="decltype\\(auto\\)",i="[a-zA-Z_]\\w*::",s="<[^<>]+>",o="("+r+"|"+e.optional(i)+"[a-zA-Z_]\\w*"+e.optional(s)+")",a={className:"type",variants:[{begin:"\\b[a-z\\d_]*_t\\b"},{match:/\batomic_[a-z]{3,6}\b/}]},l="\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)",u={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[t.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'("+l+"|.)",end:"'",illegal:"."},t.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},c={className:"number",variants:[{begin:"\\b(0b[01']+)"},{begin:"(-?)\\b([\\d']+(\\.[\\d']*)?|\\.[\\d']+)((ll|LL|l|L)(u|U)?|(u|U)(ll|LL|l|L)?|f|F|b|B)"},{begin:"(-?)(\\b0[xX][a-fA-F0-9']+|(\\b[\\d']+(\\.[\\d']*)?|\\.[\\d']+)([eE][-+]?[\\d']+)?)"}],relevance:0},d={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},t.inherit(u,{className:"string"}),{className:"string",begin:/<.*?>/},n,t.C_BLOCK_COMMENT_MODE]},f={className:"title",begin:e.optional(i)+t.IDENT_RE,relevance:0},h=e.optional(i)+t.IDENT_RE+"\\s*\\(",g={keyword:["asm","auto","break","case","continue","default","do","else","enum","extern","for","fortran","goto","if","inline","register","restrict","return","sizeof","struct","switch","typedef","union","volatile","while","_Alignas","_Alignof","_Atomic","_Generic","_Noreturn","_Static_assert","_Thread_local","alignas","alignof","noreturn","static_assert","thread_local","_Pragma"],type:["float","double","signed","unsigned","int","short","long","char","void","_Bool","_Complex","_Imaginary","_Decimal32","_Decimal64","_Decimal128","const","static","complex","bool","imaginary"],literal:"true false NULL",built_in:"std string wstring cin cout cerr clog stdin stdout stderr stringstream istringstream ostringstream auto_ptr deque list queue stack vector map set pair bitset multiset multimap unordered_set unordered_map unordered_multiset unordered_multimap priority_queue make_pair array shared_ptr abort terminate abs acos asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp fscanf future isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper isxdigit tolower toupper labs ldexp log10 log malloc realloc memchr memcmp memcpy memset modf pow printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan vfprintf vprintf vsprintf endl initializer_list unique_ptr"},y=[d,a,n,t.C_BLOCK_COMMENT_MODE,c,u],x={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:g,contains:y.concat([{begin:/\(/,end:/\)/,keywords:g,contains:y.concat(["self"]),relevance:0}]),relevance:0},k={begin:"("+o+"[\\*&\\s]+)+"+h,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:g,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:r,keywords:g,relevance:0},{begin:h,returnBegin:!0,contains:[t.inherit(f,{className:"title.function"})],relevance:0},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:g,relevance:0,contains:[n,t.C_BLOCK_COMMENT_MODE,u,c,a,{begin:/\(/,end:/\)/,keywords:g,relevance:0,contains:["self",n,t.C_BLOCK_COMMENT_MODE,u,c,a]}]},a,n,t.C_BLOCK_COMMENT_MODE,d]};return{name:"C",aliases:["h"],keywords:g,disableAutodetect:!0,illegal:"=]/,contains:[{beginKeywords:"final class struct"},t.TITLE_MODE]}]),exports:{preprocessor:d,strings:u,keywords:g}}}function G4(t){const e=t.regex,n=t.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),r="decltype\\(auto\\)",i="[a-zA-Z_]\\w*::",s="<[^<>]+>",o="(?!struct)("+r+"|"+e.optional(i)+"[a-zA-Z_]\\w*"+e.optional(s)+")",a={className:"type",begin:"\\b[a-z\\d_]*_t\\b"},l="\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)",u={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[t.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'("+l+"|.)",end:"'",illegal:"."},t.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},c={className:"number",variants:[{begin:"\\b(0b[01']+)"},{begin:"(-?)\\b([\\d']+(\\.[\\d']*)?|\\.[\\d']+)((ll|LL|l|L)(u|U)?|(u|U)(ll|LL|l|L)?|f|F|b|B)"},{begin:"(-?)(\\b0[xX][a-fA-F0-9']+|(\\b[\\d']+(\\.[\\d']*)?|\\.[\\d']+)([eE][-+]?[\\d']+)?)"}],relevance:0},d={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},t.inherit(u,{className:"string"}),{className:"string",begin:/<.*?>/},n,t.C_BLOCK_COMMENT_MODE]},f={className:"title",begin:e.optional(i)+t.IDENT_RE,relevance:0},h=e.optional(i)+t.IDENT_RE+"\\s*\\(",p=["alignas","alignof","and","and_eq","asm","atomic_cancel","atomic_commit","atomic_noexcept","auto","bitand","bitor","break","case","catch","class","co_await","co_return","co_yield","compl","concept","const_cast|10","consteval","constexpr","constinit","continue","decltype","default","delete","do","dynamic_cast|10","else","enum","explicit","export","extern","false","final","for","friend","goto","if","import","inline","module","mutable","namespace","new","noexcept","not","not_eq","nullptr","operator","or","or_eq","override","private","protected","public","reflexpr","register","reinterpret_cast|10","requires","return","sizeof","static_assert","static_cast|10","struct","switch","synchronized","template","this","thread_local","throw","transaction_safe","transaction_safe_dynamic","true","try","typedef","typeid","typename","union","using","virtual","volatile","while","xor","xor_eq"],m=["bool","char","char16_t","char32_t","char8_t","double","float","int","long","short","void","wchar_t","unsigned","signed","const","static"],g=["any","auto_ptr","barrier","binary_semaphore","bitset","complex","condition_variable","condition_variable_any","counting_semaphore","deque","false_type","future","imaginary","initializer_list","istringstream","jthread","latch","lock_guard","multimap","multiset","mutex","optional","ostringstream","packaged_task","pair","promise","priority_queue","queue","recursive_mutex","recursive_timed_mutex","scoped_lock","set","shared_future","shared_lock","shared_mutex","shared_timed_mutex","shared_ptr","stack","string_view","stringstream","timed_mutex","thread","true_type","tuple","unique_lock","unique_ptr","unordered_map","unordered_multimap","unordered_multiset","unordered_set","variant","vector","weak_ptr","wstring","wstring_view"],y=["abort","abs","acos","apply","as_const","asin","atan","atan2","calloc","ceil","cerr","cin","clog","cos","cosh","cout","declval","endl","exchange","exit","exp","fabs","floor","fmod","forward","fprintf","fputs","free","frexp","fscanf","future","invoke","isalnum","isalpha","iscntrl","isdigit","isgraph","islower","isprint","ispunct","isspace","isupper","isxdigit","labs","launder","ldexp","log","log10","make_pair","make_shared","make_shared_for_overwrite","make_tuple","make_unique","malloc","memchr","memcmp","memcpy","memset","modf","move","pow","printf","putchar","puts","realloc","scanf","sin","sinh","snprintf","sprintf","sqrt","sscanf","std","stderr","stdin","stdout","strcat","strchr","strcmp","strcpy","strcspn","strlen","strncat","strncmp","strncpy","strpbrk","strrchr","strspn","strstr","swap","tan","tanh","terminate","to_underlying","tolower","toupper","vfprintf","visit","vprintf","vsprintf"],b={type:m,keyword:p,literal:["NULL","false","nullopt","nullptr","true"],built_in:["_Pragma"],_type_hints:g},E={className:"function.dispatch",relevance:0,keywords:{_hint:y},begin:e.concat(/\b/,/(?!decltype)/,/(?!if)/,/(?!for)/,/(?!switch)/,/(?!while)/,t.IDENT_RE,e.lookahead(/(<[^<>]+>|)\s*\(/))},v=[E,d,a,n,t.C_BLOCK_COMMENT_MODE,c,u],C={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:b,contains:v.concat([{begin:/\(/,end:/\)/,keywords:b,contains:v.concat(["self"]),relevance:0}]),relevance:0},T={className:"function",begin:"("+o+"[\\*&\\s]+)+"+h,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:b,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:r,keywords:b,relevance:0},{begin:h,returnBegin:!0,contains:[f],relevance:0},{begin:/::/,relevance:0},{begin:/:/,endsWithParent:!0,contains:[u,c]},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:b,relevance:0,contains:[n,t.C_BLOCK_COMMENT_MODE,u,c,a,{begin:/\(/,end:/\)/,keywords:b,relevance:0,contains:["self",n,t.C_BLOCK_COMMENT_MODE,u,c,a]}]},a,n,t.C_BLOCK_COMMENT_MODE,d]};return{name:"C++",aliases:["cc","c++","h++","hpp","hh","hxx","cxx"],keywords:b,illegal:"",keywords:b,contains:["self",a]},{begin:t.IDENT_RE+"::",keywords:b},{match:[/\b(?:enum(?:\s+(?:class|struct))?|class|struct|union)/,/\s+/,/\w+/],className:{1:"keyword",3:"title.class"}}])}}function J4(t){const e=["bool","byte","char","decimal","delegate","double","dynamic","enum","float","int","long","nint","nuint","object","sbyte","short","string","ulong","uint","ushort"],n=["public","private","protected","static","internal","protected","abstract","async","extern","override","unsafe","virtual","new","sealed","partial"],r=["default","false","null","true"],i=["abstract","as","base","break","case","catch","class","const","continue","do","else","event","explicit","extern","finally","fixed","for","foreach","goto","if","implicit","in","interface","internal","is","lock","namespace","new","operator","out","override","params","private","protected","public","readonly","record","ref","return","scoped","sealed","sizeof","stackalloc","static","struct","switch","this","throw","try","typeof","unchecked","unsafe","using","virtual","void","volatile","while"],s=["add","alias","and","ascending","async","await","by","descending","equals","from","get","global","group","init","into","join","let","nameof","not","notnull","on","or","orderby","partial","remove","select","set","unmanaged","value|0","var","when","where","with","yield"],o={keyword:i.concat(s),built_in:e,literal:r},a=t.inherit(t.TITLE_MODE,{begin:"[a-zA-Z](\\.?\\w)*"}),l={className:"number",variants:[{begin:"\\b(0b[01']+)"},{begin:"(-?)\\b([\\d']+(\\.[\\d']*)?|\\.[\\d']+)(u|U|l|L|ul|UL|f|F|b|B)"},{begin:"(-?)(\\b0[xX][a-fA-F0-9']+|(\\b[\\d']+(\\.[\\d']*)?|\\.[\\d']+)([eE][-+]?[\\d']+)?)"}],relevance:0},u={className:"string",begin:'@"',end:'"',contains:[{begin:'""'}]},c=t.inherit(u,{illegal:/\n/}),d={className:"subst",begin:/\{/,end:/\}/,keywords:o},f=t.inherit(d,{illegal:/\n/}),h={className:"string",begin:/\$"/,end:'"',illegal:/\n/,contains:[{begin:/\{\{/},{begin:/\}\}/},t.BACKSLASH_ESCAPE,f]},p={className:"string",begin:/\$@"/,end:'"',contains:[{begin:/\{\{/},{begin:/\}\}/},{begin:'""'},d]},m=t.inherit(p,{illegal:/\n/,contains:[{begin:/\{\{/},{begin:/\}\}/},{begin:'""'},f]});d.contains=[p,h,u,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,l,t.C_BLOCK_COMMENT_MODE],f.contains=[m,h,c,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,l,t.inherit(t.C_BLOCK_COMMENT_MODE,{illegal:/\n/})];const g={variants:[p,h,u,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE]},y={begin:"<",end:">",contains:[{beginKeywords:"in out"},a]},x=t.IDENT_RE+"(<"+t.IDENT_RE+"(\\s*,\\s*"+t.IDENT_RE+")*>)?(\\[\\])?",k={begin:"@"+t.IDENT_RE,relevance:0};return{name:"C#",aliases:["cs","c#"],keywords:o,illegal:/::/,contains:[t.COMMENT("///","$",{returnBegin:!0,contains:[{className:"doctag",variants:[{begin:"///",relevance:0},{begin:""},{begin:""}]}]}),t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE,{className:"meta",begin:"#",end:"$",keywords:{keyword:"if else elif endif define undef warning error line region endregion pragma checksum"}},g,l,{beginKeywords:"class interface",relevance:0,end:/[{;=]/,illegal:/[^\s:,]/,contains:[{beginKeywords:"where class"},a,y,t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},{beginKeywords:"namespace",relevance:0,end:/[{;=]/,illegal:/[^\s:]/,contains:[a,t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},{beginKeywords:"record",relevance:0,end:/[{;=]/,illegal:/[^\s:]/,contains:[a,y,t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},{className:"meta",begin:"^\\s*\\[(?=[\\w])",excludeBegin:!0,end:"\\]",excludeEnd:!0,contains:[{className:"string",begin:/"/,end:/"/}]},{beginKeywords:"new return throw await else",relevance:0},{className:"function",begin:"("+x+"\\s+)+"+t.IDENT_RE+"\\s*(<[^=]+>\\s*)?\\(",returnBegin:!0,end:/\s*[{;=]/,excludeEnd:!0,keywords:o,contains:[{beginKeywords:n.join(" "),relevance:0},{begin:t.IDENT_RE+"\\s*(<[^=]+>\\s*)?\\(",returnBegin:!0,contains:[t.TITLE_MODE,y],relevance:0},{match:/\(\)/},{className:"params",begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:o,relevance:0,contains:[g,l,t.C_BLOCK_COMMENT_MODE]},t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},k]}}const Y4=t=>({IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:t.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:t.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),X4=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","p","q","quote","samp","section","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],Q4=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"],e6=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"],t6=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"],n6=["align-content","align-items","align-self","all","animation","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-timing-function","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-repeat","background-size","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-decoration-break","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","content","content-visibility","counter-increment","counter-reset","cue","cue-after","cue-before","cursor","direction","display","empty-cells","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-size","font-size-adjust","font-smoothing","font-stretch","font-style","font-synthesis","font-variant","font-variant-caps","font-variant-east-asian","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","gap","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","inline-size","isolation","justify-content","left","letter-spacing","line-break","line-height","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-wrap","overflow-x","overflow-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page-break-after","page-break-before","page-break-inside","pause","pause-after","pause-before","perspective","perspective-origin","pointer-events","position","quotes","resize","rest","rest-after","rest-before","right","row-gap","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","speak","speak-as","src","tab-size","table-layout","text-align","text-align-all","text-align-last","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-style","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-transform","text-underline-position","top","transform","transform-box","transform-origin","transform-style","transition","transition-delay","transition-duration","transition-property","transition-timing-function","unicode-bidi","vertical-align","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","z-index"].reverse();function r6(t){const e=t.regex,n=Y4(t),r={begin:/-(webkit|moz|ms|o)-(?=[a-z])/},i="and or not only",s=/@-?\w[\w]*(-\w+)*/,o="[a-zA-Z-][a-zA-Z0-9_-]*",a=[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE];return{name:"CSS",case_insensitive:!0,illegal:/[=|'\$]/,keywords:{keyframePosition:"from to"},classNameAliases:{keyframePosition:"selector-tag"},contains:[n.BLOCK_COMMENT,r,n.CSS_NUMBER_MODE,{className:"selector-id",begin:/#[A-Za-z0-9_-]+/,relevance:0},{className:"selector-class",begin:"\\."+o,relevance:0},n.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",variants:[{begin:":("+e6.join("|")+")"},{begin:":(:)?("+t6.join("|")+")"}]},n.CSS_VARIABLE,{className:"attribute",begin:"\\b("+n6.join("|")+")\\b"},{begin:/:/,end:/[;}{]/,contains:[n.BLOCK_COMMENT,n.HEXCOLOR,n.IMPORTANT,n.CSS_NUMBER_MODE,...a,{begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:"url data-uri"},contains:[...a,{className:"string",begin:/[^)]/,endsWithParent:!0,excludeEnd:!0}]},n.FUNCTION_DISPATCH]},{begin:e.lookahead(/@/),end:"[{;]",relevance:0,illegal:/:/,contains:[{className:"keyword",begin:s},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{$pattern:/[a-z-]+/,keyword:i,attribute:Q4.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...a,n.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+X4.join("|")+")\\b"}]}}function i6(t){const e=t.regex;return{name:"Diff",aliases:["patch"],contains:[{className:"meta",relevance:10,match:e.either(/^@@ +-\d+,\d+ +\+\d+,\d+ +@@/,/^\*\*\* +\d+,\d+ +\*\*\*\*$/,/^--- +\d+,\d+ +----$/)},{className:"comment",variants:[{begin:e.either(/Index: /,/^index/,/={3,}/,/^-{3}/,/^\*{3} /,/^\+{3}/,/^diff --git/),end:/$/},{match:/^\*{15}$/}]},{className:"addition",begin:/^\+/,end:/$/},{className:"deletion",begin:/^-/,end:/$/},{className:"addition",begin:/^!/,end:/$/}]}}function s6(t){const s={keyword:["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var"],type:["bool","byte","complex64","complex128","error","float32","float64","int8","int16","int32","int64","string","uint8","uint16","uint32","uint64","int","uint","uintptr","rune"],literal:["true","false","iota","nil"],built_in:["append","cap","close","complex","copy","imag","len","make","new","panic","print","println","real","recover","delete"]};return{name:"Go",aliases:["golang"],keywords:s,illegal:"xm(t,e,n-1))}function l6(t){const e=t.regex,n="[À-ʸa-zA-Z_$][À-ʸa-zA-Z_$0-9]*",r=n+xm("(?:<"+n+"~~~(?:\\s*,\\s*"+n+"~~~)*>)?",/~~~/g,2),l={keyword:["synchronized","abstract","private","var","static","if","const ","for","while","strictfp","finally","protected","import","native","final","void","enum","else","break","transient","catch","instanceof","volatile","case","assert","package","default","public","try","switch","continue","throws","protected","public","private","module","requires","exports","do","sealed","yield","permits"],literal:["false","true","null"],type:["char","boolean","long","float","int","byte","short","double"],built_in:["super","this"]},u={className:"meta",begin:"@"+n,contains:[{begin:/\(/,end:/\)/,contains:["self"]}]},c={className:"params",begin:/\(/,end:/\)/,keywords:l,relevance:0,contains:[t.C_BLOCK_COMMENT_MODE],endsParent:!0};return{name:"Java",aliases:["jsp"],keywords:l,illegal:/<\/|#/,contains:[t.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{begin:/\w+@/,relevance:0},{className:"doctag",begin:"@[A-Za-z]+"}]}),{begin:/import java\.[a-z]+\./,keywords:"import",relevance:2},t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE,{begin:/"""/,end:/"""/,className:"string",contains:[t.BACKSLASH_ESCAPE]},t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,{match:[/\b(?:class|interface|enum|extends|implements|new)/,/\s+/,n],className:{1:"keyword",3:"title.class"}},{match:/non-sealed/,scope:"keyword"},{begin:[e.concat(/(?!else)/,n),/\s+/,n,/\s+/,/=(?!=)/],className:{1:"type",3:"variable",5:"operator"}},{begin:[/record/,/\s+/,n],className:{1:"keyword",3:"title.class"},contains:[c,t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},{beginKeywords:"new throw return else",relevance:0},{begin:["(?:"+r+"\\s+)",t.UNDERSCORE_IDENT_RE,/\s*(?=\()/],className:{2:"title.function"},keywords:l,contains:[{className:"params",begin:/\(/,end:/\)/,keywords:l,relevance:0,contains:[u,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,wh,t.C_BLOCK_COMMENT_MODE]},t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},wh,u]}}const Sh="[A-Za-z$_][0-9A-Za-z$_]*",u6=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends"],c6=["true","false","null","undefined","NaN","Infinity"],km=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],vm=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],Em=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],d6=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],f6=[].concat(Em,km,vm);function h6(t){const e=t.regex,n=(S,{after:L})=>{const F="",end:""},s=/<[A-Za-z0-9\\._:-]+\s*\/>/,o={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(S,L)=>{const F=S[0].length+S.index,j=S.input[F];if(j==="<"||j===","){L.ignoreMatch();return}j===">"&&(n(S,{after:F})||L.ignoreMatch());let Q;const pe=S.input.substring(F);if(Q=pe.match(/^\s*=/)){L.ignoreMatch();return}if((Q=pe.match(/^\s+extends\s+/))&&Q.index===0){L.ignoreMatch();return}}},a={$pattern:Sh,keyword:u6,literal:c6,built_in:f6,"variable.language":d6},l="[0-9](_?[0-9])*",u=`\\.(${l})`,c="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",d={className:"number",variants:[{begin:`(\\b(${c})((${u})|\\.)?|(${u}))[eE][+-]?(${l})\\b`},{begin:`\\b(${c})\\b((${u})\\b|\\.)?|(${u})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},f={className:"subst",begin:"\\$\\{",end:"\\}",keywords:a,contains:[]},h={begin:"html`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,f],subLanguage:"xml"}},p={begin:"css`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,f],subLanguage:"css"}},m={begin:"gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,f],subLanguage:"graphql"}},g={className:"string",begin:"`",end:"`",contains:[t.BACKSLASH_ESCAPE,f]},x={className:"comment",variants:[t.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),t.C_BLOCK_COMMENT_MODE,t.C_LINE_COMMENT_MODE]},k=[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,h,p,m,g,{match:/\$\d+/},d];f.contains=k.concat({begin:/\{/,end:/\}/,keywords:a,contains:["self"].concat(k)});const b=[].concat(x,f.contains),E=b.concat([{begin:/\(/,end:/\)/,keywords:a,contains:["self"].concat(b)}]),v={className:"params",begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:a,contains:E},C={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,e.concat(r,"(",e.concat(/\./,r),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,r],scope:{1:"keyword",3:"title.class"}}]},T={relevance:0,match:e.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...km,...vm]}},w={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},N={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[v],illegal:/%/},$={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function K(S){return e.concat("(?!",S.join("|"),")")}const U={match:e.concat(/\b/,K([...Em,"super","import"]),r,e.lookahead(/\(/)),className:"title.function",relevance:0},W={begin:e.concat(/\./,e.lookahead(e.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},z={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},v]},A="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+t.UNDERSCORE_IDENT_RE+")\\s*=>",_={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,e.lookahead(A)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[v]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:a,exports:{PARAMS_CONTAINS:E,CLASS_REFERENCE:T},illegal:/#(?![$_A-z])/,contains:[t.SHEBANG({label:"shebang",binary:"node",relevance:5}),w,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,h,p,m,g,x,{match:/\$\d+/},d,T,{className:"attr",begin:r+e.lookahead(":"),relevance:0},_,{begin:"("+t.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[x,t.REGEXP_MODE,{className:"function",begin:A,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:t.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:a,contains:E}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:i.begin,end:i.end},{match:s},{begin:o.begin,"on:begin":o.isTrulyOpeningTag,end:o.end}],subLanguage:"xml",contains:[{begin:o.begin,end:o.end,skip:!0,contains:["self"]}]}]},N,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+t.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[v,t.inherit(t.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},W,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[v]},U,$,C,z,{match:/\$[(.]/}]}}function p6(t){const e={className:"attr",begin:/"(\\.|[^\\"\r\n])*"(?=\s*:)/,relevance:1.01},n={match:/[{}[\],:]/,className:"punctuation",relevance:0},r=["true","false","null"],i={scope:"literal",beginKeywords:r.join(" ")};return{name:"JSON",keywords:{literal:r},contains:[e,n,t.QUOTE_STRING_MODE,i,t.C_NUMBER_MODE,t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}var Ur="[0-9](_*[0-9])*",Js=`\\.(${Ur})`,Ys="[0-9a-fA-F](_*[0-9a-fA-F])*",m6={className:"number",variants:[{begin:`(\\b(${Ur})((${Js})|\\.)?|(${Js}))[eE][+-]?(${Ur})[fFdD]?\\b`},{begin:`\\b(${Ur})((${Js})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${Js})[fFdD]?\\b`},{begin:`\\b(${Ur})[fFdD]\\b`},{begin:`\\b0[xX]((${Ys})\\.?|(${Ys})?\\.(${Ys}))[pP][+-]?(${Ur})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${Ys})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};function g6(t){const e={keyword:"abstract as val var vararg get set class object open private protected public noinline crossinline dynamic final enum if else do while for when throw try catch finally import package is in fun override companion reified inline lateinit init interface annotation data sealed internal infix operator out by constructor super tailrec where const inner suspend typealias external expect actual",built_in:"Byte Short Char Int Long Boolean Float Double Void Unit Nothing",literal:"true false null"},n={className:"keyword",begin:/\b(break|continue|return|this)\b/,starts:{contains:[{className:"symbol",begin:/@\w+/}]}},r={className:"symbol",begin:t.UNDERSCORE_IDENT_RE+"@"},i={className:"subst",begin:/\$\{/,end:/\}/,contains:[t.C_NUMBER_MODE]},s={className:"variable",begin:"\\$"+t.UNDERSCORE_IDENT_RE},o={className:"string",variants:[{begin:'"""',end:'"""(?=[^"])',contains:[s,i]},{begin:"'",end:"'",illegal:/\n/,contains:[t.BACKSLASH_ESCAPE]},{begin:'"',end:'"',illegal:/\n/,contains:[t.BACKSLASH_ESCAPE,s,i]}]};i.contains.push(o);const a={className:"meta",begin:"@(?:file|property|field|get|set|receiver|param|setparam|delegate)\\s*:(?:\\s*"+t.UNDERSCORE_IDENT_RE+")?"},l={className:"meta",begin:"@"+t.UNDERSCORE_IDENT_RE,contains:[{begin:/\(/,end:/\)/,contains:[t.inherit(o,{className:"string"}),"self"]}]},u=m6,c=t.COMMENT("/\\*","\\*/",{contains:[t.C_BLOCK_COMMENT_MODE]}),d={variants:[{className:"type",begin:t.UNDERSCORE_IDENT_RE},{begin:/\(/,end:/\)/,contains:[]}]},f=d;return f.variants[1].contains=[d],d.variants[1].contains=[f],{name:"Kotlin",aliases:["kt","kts"],keywords:e,contains:[t.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"}]}),t.C_LINE_COMMENT_MODE,c,n,r,a,l,{className:"function",beginKeywords:"fun",end:"[(]|$",returnBegin:!0,excludeEnd:!0,keywords:e,relevance:5,contains:[{begin:t.UNDERSCORE_IDENT_RE+"\\s*\\(",returnBegin:!0,relevance:0,contains:[t.UNDERSCORE_TITLE_MODE]},{className:"type",begin://,keywords:"reified",relevance:0},{className:"params",begin:/\(/,end:/\)/,endsParent:!0,keywords:e,relevance:0,contains:[{begin:/:/,end:/[=,\/]/,endsWithParent:!0,contains:[d,t.C_LINE_COMMENT_MODE,c],relevance:0},t.C_LINE_COMMENT_MODE,c,a,l,o,t.C_NUMBER_MODE]},c]},{begin:[/class|interface|trait/,/\s+/,t.UNDERSCORE_IDENT_RE],beginScope:{3:"title.class"},keywords:"class interface trait",end:/[:\{(]|$/,excludeEnd:!0,illegal:"extends implements",contains:[{beginKeywords:"public protected internal private constructor"},t.UNDERSCORE_TITLE_MODE,{className:"type",begin://,excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:/[,:]\s*/,end:/[<\(,){\s]|$/,excludeBegin:!0,returnEnd:!0},a,l]},o,{className:"meta",begin:"^#!/usr/bin/env",end:"$",illegal:` -`},u]}}const b6=t=>({IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:t.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:t.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),y6=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","p","q","quote","samp","section","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],x6=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"],_m=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"],Cm=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"],k6=["align-content","align-items","align-self","all","animation","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-timing-function","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-repeat","background-size","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-decoration-break","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","content","content-visibility","counter-increment","counter-reset","cue","cue-after","cue-before","cursor","direction","display","empty-cells","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-size","font-size-adjust","font-smoothing","font-stretch","font-style","font-synthesis","font-variant","font-variant-caps","font-variant-east-asian","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","gap","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","inline-size","isolation","justify-content","left","letter-spacing","line-break","line-height","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-wrap","overflow-x","overflow-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page-break-after","page-break-before","page-break-inside","pause","pause-after","pause-before","perspective","perspective-origin","pointer-events","position","quotes","resize","rest","rest-after","rest-before","right","row-gap","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","speak","speak-as","src","tab-size","table-layout","text-align","text-align-all","text-align-last","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-style","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-transform","text-underline-position","top","transform","transform-box","transform-origin","transform-style","transition","transition-delay","transition-duration","transition-property","transition-timing-function","unicode-bidi","vertical-align","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","z-index"].reverse(),v6=_m.concat(Cm);function E6(t){const e=b6(t),n=v6,r="and or not only",i="[\\w-]+",s="("+i+"|@\\{"+i+"\\})",o=[],a=[],l=function(k){return{className:"string",begin:"~?"+k+".*?"+k}},u=function(k,b,E){return{className:k,begin:b,relevance:E}},c={$pattern:/[a-z-]+/,keyword:r,attribute:x6.join(" ")},d={begin:"\\(",end:"\\)",contains:a,keywords:c,relevance:0};a.push(t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE,l("'"),l('"'),e.CSS_NUMBER_MODE,{begin:"(url|data-uri)\\(",starts:{className:"string",end:"[\\)\\n]",excludeEnd:!0}},e.HEXCOLOR,d,u("variable","@@?"+i,10),u("variable","@\\{"+i+"\\}"),u("built_in","~?`[^`]*?`"),{className:"attribute",begin:i+"\\s*:",end:":",returnBegin:!0,excludeEnd:!0},e.IMPORTANT,{beginKeywords:"and not"},e.FUNCTION_DISPATCH);const f=a.concat({begin:/\{/,end:/\}/,contains:o}),h={beginKeywords:"when",endsWithParent:!0,contains:[{beginKeywords:"and not"}].concat(a)},p={begin:s+"\\s*:",returnBegin:!0,end:/[;}]/,relevance:0,contains:[{begin:/-(webkit|moz|ms|o)-/},e.CSS_VARIABLE,{className:"attribute",begin:"\\b("+k6.join("|")+")\\b",end:/(?=:)/,starts:{endsWithParent:!0,illegal:"[<=$]",relevance:0,contains:a}}]},m={className:"keyword",begin:"@(import|media|charset|font-face|(-[a-z]+-)?keyframes|supports|document|namespace|page|viewport|host)\\b",starts:{end:"[;{}]",keywords:c,returnEnd:!0,contains:a,relevance:0}},g={className:"variable",variants:[{begin:"@"+i+"\\s*:",relevance:15},{begin:"@"+i}],starts:{end:"[;}]",returnEnd:!0,contains:f}},y={variants:[{begin:"[\\.#:&\\[>]",end:"[;{}]"},{begin:s,end:/\{/}],returnBegin:!0,returnEnd:!0,illegal:`[<='$"]`,relevance:0,contains:[t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE,h,u("keyword","all\\b"),u("variable","@\\{"+i+"\\}"),{begin:"\\b("+y6.join("|")+")\\b",className:"selector-tag"},e.CSS_NUMBER_MODE,u("selector-tag",s,0),u("selector-id","#"+s),u("selector-class","\\."+s,0),u("selector-tag","&",0),e.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",begin:":("+_m.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+Cm.join("|")+")"},{begin:/\(/,end:/\)/,relevance:0,contains:f},{begin:"!important"},e.FUNCTION_DISPATCH]},x={begin:i+`:(:)?(${n.join("|")})`,returnBegin:!0,contains:[y]};return o.push(t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE,m,g,x,p,y,h,e.FUNCTION_DISPATCH),{name:"Less",case_insensitive:!0,illegal:`[=>'/<($"]`,contains:o}}function _6(t){const e="\\[=*\\[",n="\\]=*\\]",r={begin:e,end:n,contains:["self"]},i=[t.COMMENT("--(?!"+e+")","$"),t.COMMENT("--"+e,n,{contains:[r],relevance:10})];return{name:"Lua",keywords:{$pattern:t.UNDERSCORE_IDENT_RE,literal:"true false nil",keyword:"and break do else elseif end for goto if in local not or repeat return then until while",built_in:"_G _ENV _VERSION __index __newindex __mode __call __metatable __tostring __len __gc __add __sub __mul __div __mod __pow __concat __unm __eq __lt __le assert collectgarbage dofile error getfenv getmetatable ipairs load loadfile loadstring module next pairs pcall print rawequal rawget rawset require select setfenv setmetatable tonumber tostring type unpack xpcall arg self coroutine resume yield status wrap create running debug getupvalue debug sethook getmetatable gethook setmetatable setlocal traceback setfenv getinfo setupvalue getlocal getregistry getfenv io lines write close flush open output type read stderr stdin input stdout popen tmpfile math log max acos huge ldexp pi cos tanh pow deg tan cosh sinh random randomseed frexp ceil floor rad abs sqrt modf asin min mod fmod log10 atan2 exp sin atan os exit setlocale date getenv difftime remove time clock tmpname rename execute package preload loadlib loaded loaders cpath config path seeall string sub upper len gfind rep find match char dump gmatch reverse byte format gsub lower table setn insert getn foreachi maxn foreach concat sort remove"},contains:i.concat([{className:"function",beginKeywords:"function",end:"\\)",contains:[t.inherit(t.TITLE_MODE,{begin:"([_a-zA-Z]\\w*\\.)*([_a-zA-Z]\\w*:)?[_a-zA-Z]\\w*"}),{className:"params",begin:"\\(",endsWithParent:!0,contains:i}].concat(i)},t.C_NUMBER_MODE,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,{className:"string",begin:e,end:n,contains:[r],relevance:5}])}}function C6(t){const e={className:"variable",variants:[{begin:"\\$\\("+t.UNDERSCORE_IDENT_RE+"\\)",contains:[t.BACKSLASH_ESCAPE]},{begin:/\$[@%",subLanguage:"xml",relevance:0},r={begin:"^[-\\*]{3,}",end:"$"},i={className:"code",variants:[{begin:"(`{3,})[^`](.|\\n)*?\\1`*[ ]*"},{begin:"(~{3,})[^~](.|\\n)*?\\1~*[ ]*"},{begin:"```",end:"```+[ ]*$"},{begin:"~~~",end:"~~~+[ ]*$"},{begin:"`.+?`"},{begin:"(?=^( {4}|\\t))",contains:[{begin:"^( {4}|\\t)",end:"(\\n)$"}],relevance:0}]},s={className:"bullet",begin:"^[ ]*([*+-]|(\\d+\\.))(?=\\s+)",end:"\\s+",excludeEnd:!0},o={begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{className:"symbol",begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{className:"link",begin:/:\s*/,end:/$/,excludeBegin:!0}]},a=/[A-Za-z][A-Za-z0-9+.-]*/,l={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,relevance:2},{begin:e.concat(/\[.+?\]\(/,a,/:\/\/.*?\)/),relevance:2},{begin:/\[.+?\]\([./?&#].*?\)/,relevance:1},{begin:/\[.*?\]\(.*?\)/,relevance:0}],returnBegin:!0,contains:[{match:/\[(?=\])/},{className:"string",relevance:0,begin:"\\[",end:"\\]",excludeBegin:!0,returnEnd:!0},{className:"link",relevance:0,begin:"\\]\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0},{className:"symbol",relevance:0,begin:"\\]\\[",end:"\\]",excludeBegin:!0,excludeEnd:!0}]},u={className:"strong",contains:[],variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]},c={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},d=t.inherit(u,{contains:[]}),f=t.inherit(c,{contains:[]});u.contains.push(f),c.contains.push(d);let h=[n,l];return[u,c,d,f].forEach(g=>{g.contains=g.contains.concat(h)}),h=h.concat(u,c),{name:"Markdown",aliases:["md","mkdown","mkd"],contains:[{className:"section",variants:[{begin:"^#{1,6}",end:"$",contains:h},{begin:"(?=^.+?\\n[=-]{2,}$)",contains:[{begin:"^[=-]*$"},{begin:"^",end:"\\n",contains:h}]}]},n,s,u,c,{className:"quote",begin:"^>\\s+",contains:h,end:"$"},i,r,l,o]}}function S6(t){const e={className:"built_in",begin:"\\b(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)\\w+"},n=/[a-zA-Z@][a-zA-Z0-9_]*/,a={"variable.language":["this","super"],$pattern:n,keyword:["while","export","sizeof","typedef","const","struct","for","union","volatile","static","mutable","if","do","return","goto","enum","else","break","extern","asm","case","default","register","explicit","typename","switch","continue","inline","readonly","assign","readwrite","self","@synchronized","id","typeof","nonatomic","IBOutlet","IBAction","strong","weak","copy","in","out","inout","bycopy","byref","oneway","__strong","__weak","__block","__autoreleasing","@private","@protected","@public","@try","@property","@end","@throw","@catch","@finally","@autoreleasepool","@synthesize","@dynamic","@selector","@optional","@required","@encode","@package","@import","@defs","@compatibility_alias","__bridge","__bridge_transfer","__bridge_retained","__bridge_retain","__covariant","__contravariant","__kindof","_Nonnull","_Nullable","_Null_unspecified","__FUNCTION__","__PRETTY_FUNCTION__","__attribute__","getter","setter","retain","unsafe_unretained","nonnull","nullable","null_unspecified","null_resettable","class","instancetype","NS_DESIGNATED_INITIALIZER","NS_UNAVAILABLE","NS_REQUIRES_SUPER","NS_RETURNS_INNER_POINTER","NS_INLINE","NS_AVAILABLE","NS_DEPRECATED","NS_ENUM","NS_OPTIONS","NS_SWIFT_UNAVAILABLE","NS_ASSUME_NONNULL_BEGIN","NS_ASSUME_NONNULL_END","NS_REFINED_FOR_SWIFT","NS_SWIFT_NAME","NS_SWIFT_NOTHROW","NS_DURING","NS_HANDLER","NS_ENDHANDLER","NS_VALUERETURN","NS_VOIDRETURN"],literal:["false","true","FALSE","TRUE","nil","YES","NO","NULL"],built_in:["dispatch_once_t","dispatch_queue_t","dispatch_sync","dispatch_async","dispatch_once"],type:["int","float","char","unsigned","signed","short","long","double","wchar_t","unichar","void","bool","BOOL","id|0","_Bool"]},l={$pattern:n,keyword:["@interface","@class","@protocol","@implementation"]};return{name:"Objective-C",aliases:["mm","objc","obj-c","obj-c++","objective-c++"],keywords:a,illegal:"/,end:/$/,illegal:"\\n"},t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},{className:"class",begin:"("+l.keyword.join("|")+")\\b",end:/(\{|$)/,excludeEnd:!0,keywords:l,contains:[t.UNDERSCORE_TITLE_MODE]},{begin:"\\."+t.UNDERSCORE_IDENT_RE,relevance:0}]}}function A6(t){const e=t.regex,n=["abs","accept","alarm","and","atan2","bind","binmode","bless","break","caller","chdir","chmod","chomp","chop","chown","chr","chroot","close","closedir","connect","continue","cos","crypt","dbmclose","dbmopen","defined","delete","die","do","dump","each","else","elsif","endgrent","endhostent","endnetent","endprotoent","endpwent","endservent","eof","eval","exec","exists","exit","exp","fcntl","fileno","flock","for","foreach","fork","format","formline","getc","getgrent","getgrgid","getgrnam","gethostbyaddr","gethostbyname","gethostent","getlogin","getnetbyaddr","getnetbyname","getnetent","getpeername","getpgrp","getpriority","getprotobyname","getprotobynumber","getprotoent","getpwent","getpwnam","getpwuid","getservbyname","getservbyport","getservent","getsockname","getsockopt","given","glob","gmtime","goto","grep","gt","hex","if","index","int","ioctl","join","keys","kill","last","lc","lcfirst","length","link","listen","local","localtime","log","lstat","lt","ma","map","mkdir","msgctl","msgget","msgrcv","msgsnd","my","ne","next","no","not","oct","open","opendir","or","ord","our","pack","package","pipe","pop","pos","print","printf","prototype","push","q|0","qq","quotemeta","qw","qx","rand","read","readdir","readline","readlink","readpipe","recv","redo","ref","rename","require","reset","return","reverse","rewinddir","rindex","rmdir","say","scalar","seek","seekdir","select","semctl","semget","semop","send","setgrent","sethostent","setnetent","setpgrp","setpriority","setprotoent","setpwent","setservent","setsockopt","shift","shmctl","shmget","shmread","shmwrite","shutdown","sin","sleep","socket","socketpair","sort","splice","split","sprintf","sqrt","srand","stat","state","study","sub","substr","symlink","syscall","sysopen","sysread","sysseek","system","syswrite","tell","telldir","tie","tied","time","times","tr","truncate","uc","ucfirst","umask","undef","unless","unlink","unpack","unshift","untie","until","use","utime","values","vec","wait","waitpid","wantarray","warn","when","while","write","x|0","xor","y|0"],r=/[dualxmsipngr]{0,12}/,i={$pattern:/[\w.]+/,keyword:n.join(" ")},s={className:"subst",begin:"[$@]\\{",end:"\\}",keywords:i},o={begin:/->\{/,end:/\}/},a={variants:[{begin:/\$\d/},{begin:e.concat(/[$%@](\^\w\b|#\w+(::\w+)*|\{\w+\}|\w+(::\w*)*)/,"(?![A-Za-z])(?![@$%])")},{begin:/[$%@][^\s\w{]/,relevance:0}]},l=[t.BACKSLASH_ESCAPE,s,a],u=[/!/,/\//,/\|/,/\?/,/'/,/"/,/#/],c=(h,p,m="\\1")=>{const g=m==="\\1"?m:e.concat(m,p);return e.concat(e.concat("(?:",h,")"),p,/(?:\\.|[^\\\/])*?/,g,/(?:\\.|[^\\\/])*?/,m,r)},d=(h,p,m)=>e.concat(e.concat("(?:",h,")"),p,/(?:\\.|[^\\\/])*?/,m,r),f=[a,t.HASH_COMMENT_MODE,t.COMMENT(/^=\w/,/=cut/,{endsWithParent:!0}),o,{className:"string",contains:l,variants:[{begin:"q[qwxr]?\\s*\\(",end:"\\)",relevance:5},{begin:"q[qwxr]?\\s*\\[",end:"\\]",relevance:5},{begin:"q[qwxr]?\\s*\\{",end:"\\}",relevance:5},{begin:"q[qwxr]?\\s*\\|",end:"\\|",relevance:5},{begin:"q[qwxr]?\\s*<",end:">",relevance:5},{begin:"qw\\s+q",end:"q",relevance:5},{begin:"'",end:"'",contains:[t.BACKSLASH_ESCAPE]},{begin:'"',end:'"'},{begin:"`",end:"`",contains:[t.BACKSLASH_ESCAPE]},{begin:/\{\w+\}/,relevance:0},{begin:"-?\\w+\\s*=>",relevance:0}]},{className:"number",begin:"(\\b0[0-7_]+)|(\\b0x[0-9a-fA-F_]+)|(\\b[1-9][0-9_]*(\\.[0-9_]+)?)|[0_]\\b",relevance:0},{begin:"(\\/\\/|"+t.RE_STARTERS_RE+"|\\b(split|return|print|reverse|grep)\\b)\\s*",keywords:"split return print reverse grep",relevance:0,contains:[t.HASH_COMMENT_MODE,{className:"regexp",variants:[{begin:c("s|tr|y",e.either(...u,{capture:!0}))},{begin:c("s|tr|y","\\(","\\)")},{begin:c("s|tr|y","\\[","\\]")},{begin:c("s|tr|y","\\{","\\}")}],relevance:2},{className:"regexp",variants:[{begin:/(m|qr)\/\//,relevance:0},{begin:d("(?:m|qr)?",/\//,/\//)},{begin:d("m|qr",e.either(...u,{capture:!0}),/\1/)},{begin:d("m|qr",/\(/,/\)/)},{begin:d("m|qr",/\[/,/\]/)},{begin:d("m|qr",/\{/,/\}/)}]}]},{className:"function",beginKeywords:"sub",end:"(\\s*\\(.*?\\))?[;{]",excludeEnd:!0,relevance:5,contains:[t.TITLE_MODE]},{begin:"-\\w\\b",relevance:0},{begin:"^__DATA__$",end:"^__END__$",subLanguage:"mojolicious",contains:[{begin:"^@@.*",end:"$",className:"comment"}]}];return s.contains=f,o.contains=f,{name:"Perl",aliases:["pl","pm"],keywords:i,contains:f}}function M6(t){const e=t.regex,n=/(?![A-Za-z0-9])(?![$])/,r=e.concat(/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/,n),i=e.concat(/(\\?[A-Z][a-z0-9_\x7f-\xff]+|\\?[A-Z]+(?=[A-Z][a-z0-9_\x7f-\xff])){1,}/,n),s={scope:"variable",match:"\\$+"+r},o={scope:"meta",variants:[{begin:/<\?php/,relevance:10},{begin:/<\?=/},{begin:/<\?/,relevance:.1},{begin:/\?>/}]},a={scope:"subst",variants:[{begin:/\$\w+/},{begin:/\{\$/,end:/\}/}]},l=t.inherit(t.APOS_STRING_MODE,{illegal:null}),u=t.inherit(t.QUOTE_STRING_MODE,{illegal:null,contains:t.QUOTE_STRING_MODE.contains.concat(a)}),c={begin:/<<<[ \t]*(?:(\w+)|"(\w+)")\n/,end:/[ \t]*(\w+)\b/,contains:t.QUOTE_STRING_MODE.contains.concat(a),"on:begin":(U,W)=>{W.data._beginMatch=U[1]||U[2]},"on:end":(U,W)=>{W.data._beginMatch!==U[1]&&W.ignoreMatch()}},d=t.END_SAME_AS_BEGIN({begin:/<<<[ \t]*'(\w+)'\n/,end:/[ \t]*(\w+)\b/}),f=`[ -]`,h={scope:"string",variants:[u,l,c,d]},p={scope:"number",variants:[{begin:"\\b0[bB][01]+(?:_[01]+)*\\b"},{begin:"\\b0[oO][0-7]+(?:_[0-7]+)*\\b"},{begin:"\\b0[xX][\\da-fA-F]+(?:_[\\da-fA-F]+)*\\b"},{begin:"(?:\\b\\d+(?:_\\d+)*(\\.(?:\\d+(?:_\\d+)*))?|\\B\\.\\d+)(?:[eE][+-]?\\d+)?"}],relevance:0},m=["false","null","true"],g=["__CLASS__","__DIR__","__FILE__","__FUNCTION__","__COMPILER_HALT_OFFSET__","__LINE__","__METHOD__","__NAMESPACE__","__TRAIT__","die","echo","exit","include","include_once","print","require","require_once","array","abstract","and","as","binary","bool","boolean","break","callable","case","catch","class","clone","const","continue","declare","default","do","double","else","elseif","empty","enddeclare","endfor","endforeach","endif","endswitch","endwhile","enum","eval","extends","final","finally","float","for","foreach","from","global","goto","if","implements","instanceof","insteadof","int","integer","interface","isset","iterable","list","match|0","mixed","new","never","object","or","private","protected","public","readonly","real","return","string","switch","throw","trait","try","unset","use","var","void","while","xor","yield"],y=["Error|0","AppendIterator","ArgumentCountError","ArithmeticError","ArrayIterator","ArrayObject","AssertionError","BadFunctionCallException","BadMethodCallException","CachingIterator","CallbackFilterIterator","CompileError","Countable","DirectoryIterator","DivisionByZeroError","DomainException","EmptyIterator","ErrorException","Exception","FilesystemIterator","FilterIterator","GlobIterator","InfiniteIterator","InvalidArgumentException","IteratorIterator","LengthException","LimitIterator","LogicException","MultipleIterator","NoRewindIterator","OutOfBoundsException","OutOfRangeException","OuterIterator","OverflowException","ParentIterator","ParseError","RangeException","RecursiveArrayIterator","RecursiveCachingIterator","RecursiveCallbackFilterIterator","RecursiveDirectoryIterator","RecursiveFilterIterator","RecursiveIterator","RecursiveIteratorIterator","RecursiveRegexIterator","RecursiveTreeIterator","RegexIterator","RuntimeException","SeekableIterator","SplDoublyLinkedList","SplFileInfo","SplFileObject","SplFixedArray","SplHeap","SplMaxHeap","SplMinHeap","SplObjectStorage","SplObserver","SplPriorityQueue","SplQueue","SplStack","SplSubject","SplTempFileObject","TypeError","UnderflowException","UnexpectedValueException","UnhandledMatchError","ArrayAccess","BackedEnum","Closure","Fiber","Generator","Iterator","IteratorAggregate","Serializable","Stringable","Throwable","Traversable","UnitEnum","WeakReference","WeakMap","Directory","__PHP_Incomplete_Class","parent","php_user_filter","self","static","stdClass"],k={keyword:g,literal:(U=>{const W=[];return U.forEach(z=>{W.push(z),z.toLowerCase()===z?W.push(z.toUpperCase()):W.push(z.toLowerCase())}),W})(m),built_in:y},b=U=>U.map(W=>W.replace(/\|\d+$/,"")),E={variants:[{match:[/new/,e.concat(f,"+"),e.concat("(?!",b(y).join("\\b|"),"\\b)"),i],scope:{1:"keyword",4:"title.class"}}]},v=e.concat(r,"\\b(?!\\()"),C={variants:[{match:[e.concat(/::/,e.lookahead(/(?!class\b)/)),v],scope:{2:"variable.constant"}},{match:[/::/,/class/],scope:{2:"variable.language"}},{match:[i,e.concat(/::/,e.lookahead(/(?!class\b)/)),v],scope:{1:"title.class",3:"variable.constant"}},{match:[i,e.concat("::",e.lookahead(/(?!class\b)/))],scope:{1:"title.class"}},{match:[i,/::/,/class/],scope:{1:"title.class",3:"variable.language"}}]},T={scope:"attr",match:e.concat(r,e.lookahead(":"),e.lookahead(/(?!::)/))},w={relevance:0,begin:/\(/,end:/\)/,keywords:k,contains:[T,s,C,t.C_BLOCK_COMMENT_MODE,h,p,E]},N={relevance:0,match:[/\b/,e.concat("(?!fn\\b|function\\b|",b(g).join("\\b|"),"|",b(y).join("\\b|"),"\\b)"),r,e.concat(f,"*"),e.lookahead(/(?=\()/)],scope:{3:"title.function.invoke"},contains:[w]};w.contains.push(N);const $=[T,C,t.C_BLOCK_COMMENT_MODE,h,p,E],K={begin:e.concat(/#\[\s*/,i),beginScope:"meta",end:/]/,endScope:"meta",keywords:{literal:m,keyword:["new","array"]},contains:[{begin:/\[/,end:/]/,keywords:{literal:m,keyword:["new","array"]},contains:["self",...$]},...$,{scope:"meta",match:i}]};return{case_insensitive:!1,keywords:k,contains:[K,t.HASH_COMMENT_MODE,t.COMMENT("//","$"),t.COMMENT("/\\*","\\*/",{contains:[{scope:"doctag",match:"@[A-Za-z]+"}]}),{match:/__halt_compiler\(\);/,keywords:"__halt_compiler",starts:{scope:"comment",end:t.MATCH_NOTHING_RE,contains:[{match:/\?>/,scope:"meta",endsParent:!0}]}},o,{scope:"variable.language",match:/\$this\b/},s,N,C,{match:[/const/,/\s/,r],scope:{1:"keyword",3:"variable.constant"}},E,{scope:"function",relevance:0,beginKeywords:"fn function",end:/[;{]/,excludeEnd:!0,illegal:"[$%\\[]",contains:[{beginKeywords:"use"},t.UNDERSCORE_TITLE_MODE,{begin:"=>",endsParent:!0},{scope:"params",begin:"\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0,keywords:k,contains:["self",s,C,t.C_BLOCK_COMMENT_MODE,h,p]}]},{scope:"class",variants:[{beginKeywords:"enum",illegal:/[($"]/},{beginKeywords:"class interface trait",illegal:/[:($"]/}],relevance:0,end:/\{/,excludeEnd:!0,contains:[{beginKeywords:"extends implements"},t.UNDERSCORE_TITLE_MODE]},{beginKeywords:"namespace",relevance:0,end:";",illegal:/[.']/,contains:[t.inherit(t.UNDERSCORE_TITLE_MODE,{scope:"title.class"})]},{beginKeywords:"use",relevance:0,end:";",contains:[{match:/\b(as|const|function)\b/,scope:"keyword"},t.UNDERSCORE_TITLE_MODE]},h,p]}}function T6(t){return{name:"PHP template",subLanguage:"xml",contains:[{begin:/<\?(php|=)?/,end:/\?>/,subLanguage:"php",contains:[{begin:"/\\*",end:"\\*/",skip:!0},{begin:'b"',end:'"',skip:!0},{begin:"b'",end:"'",skip:!0},t.inherit(t.APOS_STRING_MODE,{illegal:null,className:null,contains:null,skip:!0}),t.inherit(t.QUOTE_STRING_MODE,{illegal:null,className:null,contains:null,skip:!0})]}]}}function D6(t){return{name:"Plain text",aliases:["text","txt"],disableAutodetect:!0}}function O6(t){const e=t.regex,n=/[\p{XID_Start}_]\p{XID_Continue}*/u,r=["and","as","assert","async","await","break","case","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","match","nonlocal|10","not","or","pass","raise","return","try","while","with","yield"],a={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:r,built_in:["__import__","abs","all","any","ascii","bin","bool","breakpoint","bytearray","bytes","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","exec","filter","float","format","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"],literal:["__debug__","Ellipsis","False","None","NotImplemented","True"],type:["Any","Callable","Coroutine","Dict","List","Literal","Generic","Optional","Sequence","Set","Tuple","Type","Union"]},l={className:"meta",begin:/^(>>>|\.\.\.) /},u={className:"subst",begin:/\{/,end:/\}/,keywords:a,illegal:/#/},c={begin:/\{\{/,relevance:0},d={className:"string",contains:[t.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[t.BACKSLASH_ESCAPE,l],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[t.BACKSLASH_ESCAPE,l],relevance:10},{begin:/([fF][rR]|[rR][fF]|[fF])'''/,end:/'''/,contains:[t.BACKSLASH_ESCAPE,l,c,u]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,end:/"""/,contains:[t.BACKSLASH_ESCAPE,l,c,u]},{begin:/([uU]|[rR])'/,end:/'/,relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/,end:/"/},{begin:/([fF][rR]|[rR][fF]|[fF])'/,end:/'/,contains:[t.BACKSLASH_ESCAPE,c,u]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/,contains:[t.BACKSLASH_ESCAPE,c,u]},t.APOS_STRING_MODE,t.QUOTE_STRING_MODE]},f="[0-9](_?[0-9])*",h=`(\\b(${f}))?\\.(${f})|\\b(${f})\\.`,p=`\\b|${r.join("|")}`,m={className:"number",relevance:0,variants:[{begin:`(\\b(${f})|(${h}))[eE][+-]?(${f})[jJ]?(?=${p})`},{begin:`(${h})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${p})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${p})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${p})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${p})`},{begin:`\\b(${f})[jJ](?=${p})`}]},g={className:"comment",begin:e.lookahead(/# type:/),end:/$/,keywords:a,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},y={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:a,contains:["self",l,m,d,t.HASH_COMMENT_MODE]}]};return u.contains=[d,m,l],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:a,illegal:/(<\/|\?)|=>/,contains:[l,m,{begin:/\bself\b/},{beginKeywords:"if",relevance:0},d,g,t.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[y]},{variants:[{match:[/\bclass/,/\s+/,n,/\s*/,/\(\s*/,n,/\s*\)/]},{match:[/\bclass/,/\s+/,n]}],scope:{1:"keyword",3:"title.class",6:"title.class.inherited"}},{className:"meta",begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[m,y,d]}]}}function N6(t){return{aliases:["pycon"],contains:[{className:"meta.prompt",starts:{end:/ |$/,starts:{end:"$",subLanguage:"python"}},variants:[{begin:/^>>>(?=[ ]|$)/},{begin:/^\.\.\.(?=[ ]|$)/}]}]}}function L6(t){const e=t.regex,n=/(?:(?:[a-zA-Z]|\.[._a-zA-Z])[._a-zA-Z0-9]*)|\.(?!\d)/,r=e.either(/0[xX][0-9a-fA-F]+\.[0-9a-fA-F]*[pP][+-]?\d+i?/,/0[xX][0-9a-fA-F]+(?:[pP][+-]?\d+)?[Li]?/,/(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?[Li]?/),i=/[=!<>:]=|\|\||&&|:::?|<-|<<-|->>|->|\|>|[-+*\/?!$&|:<=>@^~]|\*\*/,s=e.either(/[()]/,/[{}]/,/\[\[/,/[[\]]/,/\\/,/,/);return{name:"R",keywords:{$pattern:n,keyword:"function if in break next repeat else for while",literal:"NULL NA TRUE FALSE Inf NaN NA_integer_|10 NA_real_|10 NA_character_|10 NA_complex_|10",built_in:"LETTERS letters month.abb month.name pi T F abs acos acosh all any anyNA Arg as.call as.character as.complex as.double as.environment as.integer as.logical as.null.default as.numeric as.raw asin asinh atan atanh attr attributes baseenv browser c call ceiling class Conj cos cosh cospi cummax cummin cumprod cumsum digamma dim dimnames emptyenv exp expression floor forceAndCall gamma gc.time globalenv Im interactive invisible is.array is.atomic is.call is.character is.complex is.double is.environment is.expression is.finite is.function is.infinite is.integer is.language is.list is.logical is.matrix is.na is.name is.nan is.null is.numeric is.object is.pairlist is.raw is.recursive is.single is.symbol lazyLoadDBfetch length lgamma list log max min missing Mod names nargs nzchar oldClass on.exit pos.to.env proc.time prod quote range Re rep retracemem return round seq_along seq_len seq.int sign signif sin sinh sinpi sqrt standardGeneric substitute sum switch tan tanh tanpi tracemem trigamma trunc unclass untracemem UseMethod xtfrm"},contains:[t.COMMENT(/#'/,/$/,{contains:[{scope:"doctag",match:/@examples/,starts:{end:e.lookahead(e.either(/\n^#'\s*(?=@[a-zA-Z]+)/,/\n^(?!#')/)),endsParent:!0}},{scope:"doctag",begin:"@param",end:/$/,contains:[{scope:"variable",variants:[{match:n},{match:/`(?:\\.|[^`\\])+`/}],endsParent:!0}]},{scope:"doctag",match:/@[a-zA-Z]+/},{scope:"keyword",match:/\\[a-zA-Z]+/}]}),t.HASH_COMMENT_MODE,{scope:"string",contains:[t.BACKSLASH_ESCAPE],variants:[t.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\(/,end:/\)(-*)"/}),t.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\{/,end:/\}(-*)"/}),t.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\[/,end:/\](-*)"/}),t.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\(/,end:/\)(-*)'/}),t.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\{/,end:/\}(-*)'/}),t.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\[/,end:/\](-*)'/}),{begin:'"',end:'"',relevance:0},{begin:"'",end:"'",relevance:0}]},{relevance:0,variants:[{scope:{1:"operator",2:"number"},match:[i,r]},{scope:{1:"operator",2:"number"},match:[/%[^%]*%/,r]},{scope:{1:"punctuation",2:"number"},match:[s,r]},{scope:{2:"number"},match:[/[^a-zA-Z0-9._]|^/,r]}]},{scope:{3:"operator"},match:[n,/\s+/,/<-/,/\s+/]},{scope:"operator",relevance:0,variants:[{match:i},{match:/%[^%]*%/}]},{scope:"punctuation",relevance:0,match:s},{begin:"`",end:"`",contains:[{begin:/\\./}]}]}}function R6(t){const e=t.regex,n="([a-zA-Z_]\\w*[!?=]?|[-+~]@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?)",r=e.either(/\b([A-Z]+[a-z0-9]+)+/,/\b([A-Z]+[a-z0-9]+)+[A-Z]+/),i=e.concat(r,/(::\w+)*/),o={"variable.constant":["__FILE__","__LINE__","__ENCODING__"],"variable.language":["self","super"],keyword:["alias","and","begin","BEGIN","break","case","class","defined","do","else","elsif","end","END","ensure","for","if","in","module","next","not","or","redo","require","rescue","retry","return","then","undef","unless","until","when","while","yield",...["include","extend","prepend","public","private","protected","raise","throw"]],built_in:["proc","lambda","attr_accessor","attr_reader","attr_writer","define_method","private_constant","module_function"],literal:["true","false","nil"]},a={className:"doctag",begin:"@[A-Za-z]+"},l={begin:"#<",end:">"},u=[t.COMMENT("#","$",{contains:[a]}),t.COMMENT("^=begin","^=end",{contains:[a],relevance:10}),t.COMMENT("^__END__",t.MATCH_NOTHING_RE)],c={className:"subst",begin:/#\{/,end:/\}/,keywords:o},d={className:"string",contains:[t.BACKSLASH_ESCAPE,c],variants:[{begin:/'/,end:/'/},{begin:/"/,end:/"/},{begin:/`/,end:/`/},{begin:/%[qQwWx]?\(/,end:/\)/},{begin:/%[qQwWx]?\[/,end:/\]/},{begin:/%[qQwWx]?\{/,end:/\}/},{begin:/%[qQwWx]?/},{begin:/%[qQwWx]?\//,end:/\//},{begin:/%[qQwWx]?%/,end:/%/},{begin:/%[qQwWx]?-/,end:/-/},{begin:/%[qQwWx]?\|/,end:/\|/},{begin:/\B\?(\\\d{1,3})/},{begin:/\B\?(\\x[A-Fa-f0-9]{1,2})/},{begin:/\B\?(\\u\{?[A-Fa-f0-9]{1,6}\}?)/},{begin:/\B\?(\\M-\\C-|\\M-\\c|\\c\\M-|\\M-|\\C-\\M-)[\x20-\x7e]/},{begin:/\B\?\\(c|C-)[\x20-\x7e]/},{begin:/\B\?\\?\S/},{begin:e.concat(/<<[-~]?'?/,e.lookahead(/(\w+)(?=\W)[^\n]*\n(?:[^\n]*\n)*?\s*\1\b/)),contains:[t.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,contains:[t.BACKSLASH_ESCAPE,c]})]}]},f="[1-9](_?[0-9])*|0",h="[0-9](_?[0-9])*",p={className:"number",relevance:0,variants:[{begin:`\\b(${f})(\\.(${h}))?([eE][+-]?(${h})|r)?i?\\b`},{begin:"\\b0[dD][0-9](_?[0-9])*r?i?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*r?i?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*r?i?\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*r?i?\\b"},{begin:"\\b0(_?[0-7])+r?i?\\b"}]},m={variants:[{match:/\(\)/},{className:"params",begin:/\(/,end:/(?=\))/,excludeBegin:!0,endsParent:!0,keywords:o}]},v=[d,{variants:[{match:[/class\s+/,i,/\s+<\s+/,i]},{match:[/\b(class|module)\s+/,i]}],scope:{2:"title.class",4:"title.class.inherited"},keywords:o},{match:[/(include|extend)\s+/,i],scope:{2:"title.class"},keywords:o},{relevance:0,match:[i,/\.new[. (]/],scope:{1:"title.class"}},{relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"},{relevance:0,match:r,scope:"title.class"},{match:[/def/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[m]},{begin:t.IDENT_RE+"::"},{className:"symbol",begin:t.UNDERSCORE_IDENT_RE+"(!|\\?)?:",relevance:0},{className:"symbol",begin:":(?!\\s)",contains:[d,{begin:n}],relevance:0},p,{className:"variable",begin:"(\\$\\W)|((\\$|@@?)(\\w+))(?=[^@$?])(?![A-Za-z])(?![@$?'])"},{className:"params",begin:/\|/,end:/\|/,excludeBegin:!0,excludeEnd:!0,relevance:0,keywords:o},{begin:"("+t.RE_STARTERS_RE+"|unless)\\s*",keywords:"unless",contains:[{className:"regexp",contains:[t.BACKSLASH_ESCAPE,c],illegal:/\n/,variants:[{begin:"/",end:"/[a-z]*"},{begin:/%r\{/,end:/\}[a-z]*/},{begin:"%r\\(",end:"\\)[a-z]*"},{begin:"%r!",end:"![a-z]*"},{begin:"%r\\[",end:"\\][a-z]*"}]}].concat(l,u),relevance:0}].concat(l,u);c.contains=v,m.contains=v;const C="[>?]>",T="[\\w#]+\\(\\w+\\):\\d+:\\d+[>*]",w="(\\w+-)?\\d+\\.\\d+\\.\\d+(p\\d+)?[^\\d][^>]+>",N=[{begin:/^\s*=>/,starts:{end:"$",contains:v}},{className:"meta.prompt",begin:"^("+C+"|"+T+"|"+w+")(?=[ ])",starts:{end:"$",keywords:o,contains:v}}];return u.unshift(l),{name:"Ruby",aliases:["rb","gemspec","podspec","thor","irb"],keywords:o,illegal:/\/\*/,contains:[t.SHEBANG({binary:"ruby"})].concat(N).concat(u).concat(v)}}function I6(t){const e=t.regex,n={className:"title.function.invoke",relevance:0,begin:e.concat(/\b/,/(?!let|for|while|if|else|match\b)/,t.IDENT_RE,e.lookahead(/\s*\(/))},r="([ui](8|16|32|64|128|size)|f(32|64))?",i=["abstract","as","async","await","become","box","break","const","continue","crate","do","dyn","else","enum","extern","false","final","fn","for","if","impl","in","let","loop","macro","match","mod","move","mut","override","priv","pub","ref","return","self","Self","static","struct","super","trait","true","try","type","typeof","unsafe","unsized","use","virtual","where","while","yield"],s=["true","false","Some","None","Ok","Err"],o=["drop ","Copy","Send","Sized","Sync","Drop","Fn","FnMut","FnOnce","ToOwned","Clone","Debug","PartialEq","PartialOrd","Eq","Ord","AsRef","AsMut","Into","From","Default","Iterator","Extend","IntoIterator","DoubleEndedIterator","ExactSizeIterator","SliceConcatExt","ToString","assert!","assert_eq!","bitflags!","bytes!","cfg!","col!","concat!","concat_idents!","debug_assert!","debug_assert_eq!","env!","eprintln!","panic!","file!","format!","format_args!","include_bytes!","include_str!","line!","local_data_key!","module_path!","option_env!","print!","println!","select!","stringify!","try!","unimplemented!","unreachable!","vec!","write!","writeln!","macro_rules!","assert_ne!","debug_assert_ne!"],a=["i8","i16","i32","i64","i128","isize","u8","u16","u32","u64","u128","usize","f32","f64","str","char","bool","Box","Option","Result","String","Vec"];return{name:"Rust",aliases:["rs"],keywords:{$pattern:t.IDENT_RE+"!?",type:a,keyword:i,literal:s,built_in:o},illegal:""},n]}}const F6=t=>({IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:t.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:t.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),H6=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","p","q","quote","samp","section","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],B6=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"],P6=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"],$6=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"],z6=["align-content","align-items","align-self","all","animation","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-timing-function","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-repeat","background-size","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-decoration-break","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","content","content-visibility","counter-increment","counter-reset","cue","cue-after","cue-before","cursor","direction","display","empty-cells","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-size","font-size-adjust","font-smoothing","font-stretch","font-style","font-synthesis","font-variant","font-variant-caps","font-variant-east-asian","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","gap","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","inline-size","isolation","justify-content","left","letter-spacing","line-break","line-height","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-wrap","overflow-x","overflow-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page-break-after","page-break-before","page-break-inside","pause","pause-after","pause-before","perspective","perspective-origin","pointer-events","position","quotes","resize","rest","rest-after","rest-before","right","row-gap","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","speak","speak-as","src","tab-size","table-layout","text-align","text-align-all","text-align-last","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-style","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-transform","text-underline-position","top","transform","transform-box","transform-origin","transform-style","transition","transition-delay","transition-duration","transition-property","transition-timing-function","unicode-bidi","vertical-align","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","z-index"].reverse();function V6(t){const e=F6(t),n=$6,r=P6,i="@[a-z-]+",s="and or not only",a={className:"variable",begin:"(\\$"+"[a-zA-Z-][a-zA-Z0-9_-]*"+")\\b",relevance:0};return{name:"SCSS",case_insensitive:!0,illegal:"[=/|']",contains:[t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE,e.CSS_NUMBER_MODE,{className:"selector-id",begin:"#[A-Za-z0-9_-]+",relevance:0},{className:"selector-class",begin:"\\.[A-Za-z0-9_-]+",relevance:0},e.ATTRIBUTE_SELECTOR_MODE,{className:"selector-tag",begin:"\\b("+H6.join("|")+")\\b",relevance:0},{className:"selector-pseudo",begin:":("+r.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+n.join("|")+")"},a,{begin:/\(/,end:/\)/,contains:[e.CSS_NUMBER_MODE]},e.CSS_VARIABLE,{className:"attribute",begin:"\\b("+z6.join("|")+")\\b"},{begin:"\\b(whitespace|wait|w-resize|visible|vertical-text|vertical-ideographic|uppercase|upper-roman|upper-alpha|underline|transparent|top|thin|thick|text|text-top|text-bottom|tb-rl|table-header-group|table-footer-group|sw-resize|super|strict|static|square|solid|small-caps|separate|se-resize|scroll|s-resize|rtl|row-resize|ridge|right|repeat|repeat-y|repeat-x|relative|progress|pointer|overline|outside|outset|oblique|nowrap|not-allowed|normal|none|nw-resize|no-repeat|no-drop|newspaper|ne-resize|n-resize|move|middle|medium|ltr|lr-tb|lowercase|lower-roman|lower-alpha|loose|list-item|line|line-through|line-edge|lighter|left|keep-all|justify|italic|inter-word|inter-ideograph|inside|inset|inline|inline-block|inherit|inactive|ideograph-space|ideograph-parenthesis|ideograph-numeric|ideograph-alpha|horizontal|hidden|help|hand|groove|fixed|ellipsis|e-resize|double|dotted|distribute|distribute-space|distribute-letter|distribute-all-lines|disc|disabled|default|decimal|dashed|crosshair|collapse|col-resize|circle|char|center|capitalize|break-word|break-all|bottom|both|bolder|bold|block|bidi-override|below|baseline|auto|always|all-scroll|absolute|table|table-cell)\\b"},{begin:/:/,end:/[;}{]/,relevance:0,contains:[e.BLOCK_COMMENT,a,e.HEXCOLOR,e.CSS_NUMBER_MODE,t.QUOTE_STRING_MODE,t.APOS_STRING_MODE,e.IMPORTANT,e.FUNCTION_DISPATCH]},{begin:"@(page|font-face)",keywords:{$pattern:i,keyword:"@page @font-face"}},{begin:"@",end:"[{;]",returnBegin:!0,keywords:{$pattern:/[a-z-]+/,keyword:s,attribute:B6.join(" ")},contains:[{begin:i,className:"keyword"},{begin:/[a-z-]+(?=:)/,className:"attribute"},a,t.QUOTE_STRING_MODE,t.APOS_STRING_MODE,e.HEXCOLOR,e.CSS_NUMBER_MODE]},e.FUNCTION_DISPATCH]}}function U6(t){return{name:"Shell Session",aliases:["console","shellsession"],contains:[{className:"meta.prompt",begin:/^\s{0,3}[/~\w\d[\]()@-]*[>%$#][ ]?/,starts:{end:/[^\\](?=\s*$)/,subLanguage:"bash"}}]}}function q6(t){const e=t.regex,n=t.COMMENT("--","$"),r={className:"string",variants:[{begin:/'/,end:/'/,contains:[{begin:/''/}]}]},i={begin:/"/,end:/"/,contains:[{begin:/""/}]},s=["true","false","unknown"],o=["double precision","large object","with timezone","without timezone"],a=["bigint","binary","blob","boolean","char","character","clob","date","dec","decfloat","decimal","float","int","integer","interval","nchar","nclob","national","numeric","real","row","smallint","time","timestamp","varchar","varying","varbinary"],l=["add","asc","collation","desc","final","first","last","view"],u=["abs","acos","all","allocate","alter","and","any","are","array","array_agg","array_max_cardinality","as","asensitive","asin","asymmetric","at","atan","atomic","authorization","avg","begin","begin_frame","begin_partition","between","bigint","binary","blob","boolean","both","by","call","called","cardinality","cascaded","case","cast","ceil","ceiling","char","char_length","character","character_length","check","classifier","clob","close","coalesce","collate","collect","column","commit","condition","connect","constraint","contains","convert","copy","corr","corresponding","cos","cosh","count","covar_pop","covar_samp","create","cross","cube","cume_dist","current","current_catalog","current_date","current_default_transform_group","current_path","current_role","current_row","current_schema","current_time","current_timestamp","current_path","current_role","current_transform_group_for_type","current_user","cursor","cycle","date","day","deallocate","dec","decimal","decfloat","declare","default","define","delete","dense_rank","deref","describe","deterministic","disconnect","distinct","double","drop","dynamic","each","element","else","empty","end","end_frame","end_partition","end-exec","equals","escape","every","except","exec","execute","exists","exp","external","extract","false","fetch","filter","first_value","float","floor","for","foreign","frame_row","free","from","full","function","fusion","get","global","grant","group","grouping","groups","having","hold","hour","identity","in","indicator","initial","inner","inout","insensitive","insert","int","integer","intersect","intersection","interval","into","is","join","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","language","large","last_value","lateral","lead","leading","left","like","like_regex","listagg","ln","local","localtime","localtimestamp","log","log10","lower","match","match_number","match_recognize","matches","max","member","merge","method","min","minute","mod","modifies","module","month","multiset","national","natural","nchar","nclob","new","no","none","normalize","not","nth_value","ntile","null","nullif","numeric","octet_length","occurrences_regex","of","offset","old","omit","on","one","only","open","or","order","out","outer","over","overlaps","overlay","parameter","partition","pattern","per","percent","percent_rank","percentile_cont","percentile_disc","period","portion","position","position_regex","power","precedes","precision","prepare","primary","procedure","ptf","range","rank","reads","real","recursive","ref","references","referencing","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","release","result","return","returns","revoke","right","rollback","rollup","row","row_number","rows","running","savepoint","scope","scroll","search","second","seek","select","sensitive","session_user","set","show","similar","sin","sinh","skip","smallint","some","specific","specifictype","sql","sqlexception","sqlstate","sqlwarning","sqrt","start","static","stddev_pop","stddev_samp","submultiset","subset","substring","substring_regex","succeeds","sum","symmetric","system","system_time","system_user","table","tablesample","tan","tanh","then","time","timestamp","timezone_hour","timezone_minute","to","trailing","translate","translate_regex","translation","treat","trigger","trim","trim_array","true","truncate","uescape","union","unique","unknown","unnest","update","upper","user","using","value","values","value_of","var_pop","var_samp","varbinary","varchar","varying","versioning","when","whenever","where","width_bucket","window","with","within","without","year"],c=["abs","acos","array_agg","asin","atan","avg","cast","ceil","ceiling","coalesce","corr","cos","cosh","count","covar_pop","covar_samp","cume_dist","dense_rank","deref","element","exp","extract","first_value","floor","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","last_value","lead","listagg","ln","log","log10","lower","max","min","mod","nth_value","ntile","nullif","percent_rank","percentile_cont","percentile_disc","position","position_regex","power","rank","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","row_number","sin","sinh","sqrt","stddev_pop","stddev_samp","substring","substring_regex","sum","tan","tanh","translate","translate_regex","treat","trim","trim_array","unnest","upper","value_of","var_pop","var_samp","width_bucket"],d=["current_catalog","current_date","current_default_transform_group","current_path","current_role","current_schema","current_transform_group_for_type","current_user","session_user","system_time","system_user","current_time","localtime","current_timestamp","localtimestamp"],f=["create table","insert into","primary key","foreign key","not null","alter table","add constraint","grouping sets","on overflow","character set","respect nulls","ignore nulls","nulls first","nulls last","depth first","breadth first"],h=c,p=[...u,...l].filter(k=>!c.includes(k)),m={className:"variable",begin:/@[a-z0-9][a-z0-9_]*/},g={className:"operator",begin:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},y={begin:e.concat(/\b/,e.either(...h),/\s*\(/),relevance:0,keywords:{built_in:h}};function x(k,{exceptions:b,when:E}={}){const v=E;return b=b||[],k.map(C=>C.match(/\|\d+$/)||b.includes(C)?C:v(C)?`${C}|0`:C)}return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:x(p,{when:k=>k.length<3}),literal:s,type:a,built_in:d},contains:[{begin:e.either(...f),relevance:0,keywords:{$pattern:/[\w\.]+/,keyword:p.concat(f),literal:s,type:a}},{className:"type",begin:e.either(...o)},y,m,r,i,t.C_NUMBER_MODE,t.C_BLOCK_COMMENT_MODE,n,g]}}function wm(t){return t?typeof t=="string"?t:t.source:null}function Xs(t){return Ce("(?=",t,")")}function Ce(...t){return t.map(n=>wm(n)).join("")}function Z6(t){const e=t[t.length-1];return typeof e=="object"&&e.constructor===Object?(t.splice(t.length-1,1),e):{}}function dt(...t){return"("+(Z6(t).capture?"":"?:")+t.map(r=>wm(r)).join("|")+")"}const Nc=t=>Ce(/\b/,t,/\w$/.test(t)?/\b/:/\B/),K6=["Protocol","Type"].map(Nc),Ah=["init","self"].map(Nc),W6=["Any","Self"],Dl=["actor","any","associatedtype","async","await",/as\?/,/as!/,"as","borrowing","break","case","catch","class","consume","consuming","continue","convenience","copy","default","defer","deinit","didSet","distributed","do","dynamic","each","else","enum","extension","fallthrough",/fileprivate\(set\)/,"fileprivate","final","for","func","get","guard","if","import","indirect","infix",/init\?/,/init!/,"inout",/internal\(set\)/,"internal","in","is","isolated","nonisolated","lazy","let","macro","mutating","nonmutating",/open\(set\)/,"open","operator","optional","override","postfix","precedencegroup","prefix",/private\(set\)/,"private","protocol",/public\(set\)/,"public","repeat","required","rethrows","return","set","some","static","struct","subscript","super","switch","throws","throw",/try\?/,/try!/,"try","typealias",/unowned\(safe\)/,/unowned\(unsafe\)/,"unowned","var","weak","where","while","willSet"],Mh=["false","nil","true"],j6=["assignment","associativity","higherThan","left","lowerThan","none","right"],G6=["#colorLiteral","#column","#dsohandle","#else","#elseif","#endif","#error","#file","#fileID","#fileLiteral","#filePath","#function","#if","#imageLiteral","#keyPath","#line","#selector","#sourceLocation","#warning"],Th=["abs","all","any","assert","assertionFailure","debugPrint","dump","fatalError","getVaList","isKnownUniquelyReferenced","max","min","numericCast","pointwiseMax","pointwiseMin","precondition","preconditionFailure","print","readLine","repeatElement","sequence","stride","swap","swift_unboxFromSwiftValueWithType","transcode","type","unsafeBitCast","unsafeDowncast","withExtendedLifetime","withUnsafeMutablePointer","withUnsafePointer","withVaList","withoutActuallyEscaping","zip"],Sm=dt(/[/=\-+!*%<>&|^~?]/,/[\u00A1-\u00A7]/,/[\u00A9\u00AB]/,/[\u00AC\u00AE]/,/[\u00B0\u00B1]/,/[\u00B6\u00BB\u00BF\u00D7\u00F7]/,/[\u2016-\u2017]/,/[\u2020-\u2027]/,/[\u2030-\u203E]/,/[\u2041-\u2053]/,/[\u2055-\u205E]/,/[\u2190-\u23FF]/,/[\u2500-\u2775]/,/[\u2794-\u2BFF]/,/[\u2E00-\u2E7F]/,/[\u3001-\u3003]/,/[\u3008-\u3020]/,/[\u3030]/),Am=dt(Sm,/[\u0300-\u036F]/,/[\u1DC0-\u1DFF]/,/[\u20D0-\u20FF]/,/[\uFE00-\uFE0F]/,/[\uFE20-\uFE2F]/),Ol=Ce(Sm,Am,"*"),Mm=dt(/[a-zA-Z_]/,/[\u00A8\u00AA\u00AD\u00AF\u00B2-\u00B5\u00B7-\u00BA]/,/[\u00BC-\u00BE\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF]/,/[\u0100-\u02FF\u0370-\u167F\u1681-\u180D\u180F-\u1DBF]/,/[\u1E00-\u1FFF]/,/[\u200B-\u200D\u202A-\u202E\u203F-\u2040\u2054\u2060-\u206F]/,/[\u2070-\u20CF\u2100-\u218F\u2460-\u24FF\u2776-\u2793]/,/[\u2C00-\u2DFF\u2E80-\u2FFF]/,/[\u3004-\u3007\u3021-\u302F\u3031-\u303F\u3040-\uD7FF]/,/[\uF900-\uFD3D\uFD40-\uFDCF\uFDF0-\uFE1F\uFE30-\uFE44]/,/[\uFE47-\uFEFE\uFF00-\uFFFD]/),Xo=dt(Mm,/\d/,/[\u0300-\u036F\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]/),gn=Ce(Mm,Xo,"*"),Nl=Ce(/[A-Z]/,Xo,"*"),J6=["attached","autoclosure",Ce(/convention\(/,dt("swift","block","c"),/\)/),"discardableResult","dynamicCallable","dynamicMemberLookup","escaping","freestanding","frozen","GKInspectable","IBAction","IBDesignable","IBInspectable","IBOutlet","IBSegueAction","inlinable","main","nonobjc","NSApplicationMain","NSCopying","NSManaged",Ce(/objc\(/,gn,/\)/),"objc","objcMembers","propertyWrapper","requires_stored_property_inits","resultBuilder","Sendable","testable","UIApplicationMain","unchecked","unknown","usableFromInline","warn_unqualified_access"],Y6=["iOS","iOSApplicationExtension","macOS","macOSApplicationExtension","macCatalyst","macCatalystApplicationExtension","watchOS","watchOSApplicationExtension","tvOS","tvOSApplicationExtension","swift"];function X6(t){const e={match:/\s+/,relevance:0},n=t.COMMENT("/\\*","\\*/",{contains:["self"]}),r=[t.C_LINE_COMMENT_MODE,n],i={match:[/\./,dt(...K6,...Ah)],className:{2:"keyword"}},s={match:Ce(/\./,dt(...Dl)),relevance:0},o=Dl.filter(he=>typeof he=="string").concat(["_|0"]),a=Dl.filter(he=>typeof he!="string").concat(W6).map(Nc),l={variants:[{className:"keyword",match:dt(...a,...Ah)}]},u={$pattern:dt(/\b\w+/,/#\w+/),keyword:o.concat(G6),literal:Mh},c=[i,s,l],d={match:Ce(/\./,dt(...Th)),relevance:0},f={className:"built_in",match:Ce(/\b/,dt(...Th),/(?=\()/)},h=[d,f],p={match:/->/,relevance:0},m={className:"operator",relevance:0,variants:[{match:Ol},{match:`\\.(\\.|${Am})+`}]},g=[p,m],y="([0-9]_*)+",x="([0-9a-fA-F]_*)+",k={className:"number",relevance:0,variants:[{match:`\\b(${y})(\\.(${y}))?([eE][+-]?(${y}))?\\b`},{match:`\\b0x(${x})(\\.(${x}))?([pP][+-]?(${y}))?\\b`},{match:/\b0o([0-7]_*)+\b/},{match:/\b0b([01]_*)+\b/}]},b=(he="")=>({className:"subst",variants:[{match:Ce(/\\/,he,/[0\\tnr"']/)},{match:Ce(/\\/,he,/u\{[0-9a-fA-F]{1,8}\}/)}]}),E=(he="")=>({className:"subst",match:Ce(/\\/,he,/[\t ]*(?:[\r\n]|\r\n)/)}),v=(he="")=>({className:"subst",label:"interpol",begin:Ce(/\\/,he,/\(/),end:/\)/}),C=(he="")=>({begin:Ce(he,/"""/),end:Ce(/"""/,he),contains:[b(he),E(he),v(he)]}),T=(he="")=>({begin:Ce(he,/"/),end:Ce(/"/,he),contains:[b(he),v(he)]}),w={className:"string",variants:[C(),C("#"),C("##"),C("###"),T(),T("#"),T("##"),T("###")]},N=[t.BACKSLASH_ESCAPE,{begin:/\[/,end:/\]/,relevance:0,contains:[t.BACKSLASH_ESCAPE]}],$={begin:/\/[^\s](?=[^/\n]*\/)/,end:/\//,contains:N},K=he=>{const De=Ce(he,/\//),rt=Ce(/\//,he);return{begin:De,end:rt,contains:[...N,{scope:"comment",begin:`#(?!.*${rt})`,end:/$/}]}},U={scope:"regexp",variants:[K("###"),K("##"),K("#"),$]},W={match:Ce(/`/,gn,/`/)},z={className:"variable",match:/\$\d+/},A={className:"variable",match:`\\$${Xo}+`},_=[W,z,A],S={match:/(@|#(un)?)available/,scope:"keyword",starts:{contains:[{begin:/\(/,end:/\)/,keywords:Y6,contains:[...g,k,w]}]}},L={scope:"keyword",match:Ce(/@/,dt(...J6))},F={scope:"meta",match:Ce(/@/,gn)},j=[S,L,F],Q={match:Xs(/\b[A-Z]/),relevance:0,contains:[{className:"type",match:Ce(/(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)/,Xo,"+")},{className:"type",match:Nl,relevance:0},{match:/[?!]+/,relevance:0},{match:/\.\.\./,relevance:0},{match:Ce(/\s+&\s+/,Xs(Nl)),relevance:0}]},pe={begin://,keywords:u,contains:[...r,...c,...j,p,Q]};Q.contains.push(pe);const ke={match:Ce(gn,/\s*:/),keywords:"_|0",relevance:0},fe={begin:/\(/,end:/\)/,relevance:0,keywords:u,contains:["self",ke,...r,U,...c,...h,...g,k,w,..._,...j,Q]},Se={begin://,keywords:"repeat each",contains:[...r,Q]},ut={begin:dt(Xs(Ce(gn,/\s*:/)),Xs(Ce(gn,/\s+/,gn,/\s*:/))),end:/:/,relevance:0,contains:[{className:"keyword",match:/\b_\b/},{className:"params",match:gn}]},We={begin:/\(/,end:/\)/,keywords:u,contains:[ut,...r,...c,...g,k,w,...j,Q,fe],endsParent:!0,illegal:/["']/},yt={match:[/(func|macro)/,/\s+/,dt(W.match,gn,Ol)],className:{1:"keyword",3:"title.function"},contains:[Se,We,e],illegal:[/\[/,/%/]},ct={match:[/\b(?:subscript|init[?!]?)/,/\s*(?=[<(])/],className:{1:"keyword"},contains:[Se,We,e],illegal:/\[|%/},At={match:[/operator/,/\s+/,Ol],className:{1:"keyword",3:"title"}},xt={begin:[/precedencegroup/,/\s+/,Nl],className:{1:"keyword",3:"title"},contains:[Q],keywords:[...j6,...Mh],end:/}/};for(const he of w.variants){const De=he.contains.find(Le=>Le.label==="interpol");De.keywords=u;const rt=[...c,...h,...g,k,w,..._];De.contains=[...rt,{begin:/\(/,end:/\)/,contains:["self",...rt]}]}return{name:"Swift",keywords:u,contains:[...r,yt,ct,{beginKeywords:"struct protocol class extension enum actor",end:"\\{",excludeEnd:!0,keywords:u,contains:[t.inherit(t.TITLE_MODE,{className:"title.class",begin:/[A-Za-z$_][\u00C0-\u02B80-9A-Za-z$_]*/}),...c]},At,xt,{beginKeywords:"import",end:/$/,contains:[...r],relevance:0},U,...c,...h,...g,k,w,..._,...j,Q,fe]}}const Qo="[A-Za-z$_][0-9A-Za-z$_]*",Tm=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends"],Dm=["true","false","null","undefined","NaN","Infinity"],Om=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],Nm=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],Lm=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],Rm=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],Im=[].concat(Lm,Om,Nm);function Q6(t){const e=t.regex,n=(S,{after:L})=>{const F="",end:""},s=/<[A-Za-z0-9\\._:-]+\s*\/>/,o={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(S,L)=>{const F=S[0].length+S.index,j=S.input[F];if(j==="<"||j===","){L.ignoreMatch();return}j===">"&&(n(S,{after:F})||L.ignoreMatch());let Q;const pe=S.input.substring(F);if(Q=pe.match(/^\s*=/)){L.ignoreMatch();return}if((Q=pe.match(/^\s+extends\s+/))&&Q.index===0){L.ignoreMatch();return}}},a={$pattern:Qo,keyword:Tm,literal:Dm,built_in:Im,"variable.language":Rm},l="[0-9](_?[0-9])*",u=`\\.(${l})`,c="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",d={className:"number",variants:[{begin:`(\\b(${c})((${u})|\\.)?|(${u}))[eE][+-]?(${l})\\b`},{begin:`\\b(${c})\\b((${u})\\b|\\.)?|(${u})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},f={className:"subst",begin:"\\$\\{",end:"\\}",keywords:a,contains:[]},h={begin:"html`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,f],subLanguage:"xml"}},p={begin:"css`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,f],subLanguage:"css"}},m={begin:"gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,f],subLanguage:"graphql"}},g={className:"string",begin:"`",end:"`",contains:[t.BACKSLASH_ESCAPE,f]},x={className:"comment",variants:[t.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),t.C_BLOCK_COMMENT_MODE,t.C_LINE_COMMENT_MODE]},k=[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,h,p,m,g,{match:/\$\d+/},d];f.contains=k.concat({begin:/\{/,end:/\}/,keywords:a,contains:["self"].concat(k)});const b=[].concat(x,f.contains),E=b.concat([{begin:/\(/,end:/\)/,keywords:a,contains:["self"].concat(b)}]),v={className:"params",begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:a,contains:E},C={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,e.concat(r,"(",e.concat(/\./,r),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,r],scope:{1:"keyword",3:"title.class"}}]},T={relevance:0,match:e.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...Om,...Nm]}},w={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},N={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[v],illegal:/%/},$={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function K(S){return e.concat("(?!",S.join("|"),")")}const U={match:e.concat(/\b/,K([...Lm,"super","import"]),r,e.lookahead(/\(/)),className:"title.function",relevance:0},W={begin:e.concat(/\./,e.lookahead(e.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},z={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},v]},A="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+t.UNDERSCORE_IDENT_RE+")\\s*=>",_={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,e.lookahead(A)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[v]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:a,exports:{PARAMS_CONTAINS:E,CLASS_REFERENCE:T},illegal:/#(?![$_A-z])/,contains:[t.SHEBANG({label:"shebang",binary:"node",relevance:5}),w,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,h,p,m,g,x,{match:/\$\d+/},d,T,{className:"attr",begin:r+e.lookahead(":"),relevance:0},_,{begin:"("+t.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[x,t.REGEXP_MODE,{className:"function",begin:A,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:t.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:a,contains:E}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:i.begin,end:i.end},{match:s},{begin:o.begin,"on:begin":o.isTrulyOpeningTag,end:o.end}],subLanguage:"xml",contains:[{begin:o.begin,end:o.end,skip:!0,contains:["self"]}]}]},N,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+t.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[v,t.inherit(t.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},W,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[v]},U,$,C,z,{match:/\$[(.]/}]}}function e5(t){const e=Q6(t),n=Qo,r=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],i={beginKeywords:"namespace",end:/\{/,excludeEnd:!0,contains:[e.exports.CLASS_REFERENCE]},s={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:r},contains:[e.exports.CLASS_REFERENCE]},o={className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/},a=["type","namespace","interface","public","private","protected","implements","declare","abstract","readonly","enum","override"],l={$pattern:Qo,keyword:Tm.concat(a),literal:Dm,built_in:Im.concat(r),"variable.language":Rm},u={className:"meta",begin:"@"+n},c=(f,h,p)=>{const m=f.contains.findIndex(g=>g.label===h);if(m===-1)throw new Error("can not find mode to replace");f.contains.splice(m,1,p)};Object.assign(e.keywords,l),e.exports.PARAMS_CONTAINS.push(u),e.contains=e.contains.concat([u,i,s]),c(e,"shebang",t.SHEBANG()),c(e,"use_strict",o);const d=e.contains.find(f=>f.label==="func.def");return d.relevance=0,Object.assign(e,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),e}function t5(t){const e=t.regex,n={className:"string",begin:/"(""|[^/n])"C\b/},r={className:"string",begin:/"/,end:/"/,illegal:/\n/,contains:[{begin:/""/}]},i=/\d{1,2}\/\d{1,2}\/\d{4}/,s=/\d{4}-\d{1,2}-\d{1,2}/,o=/(\d|1[012])(:\d+){0,2} *(AM|PM)/,a=/\d{1,2}(:\d{1,2}){1,2}/,l={className:"literal",variants:[{begin:e.concat(/# */,e.either(s,i),/ *#/)},{begin:e.concat(/# */,a,/ *#/)},{begin:e.concat(/# */,o,/ *#/)},{begin:e.concat(/# */,e.either(s,i),/ +/,e.either(o,a),/ *#/)}]},u={className:"number",relevance:0,variants:[{begin:/\b\d[\d_]*((\.[\d_]+(E[+-]?[\d_]+)?)|(E[+-]?[\d_]+))[RFD@!#]?/},{begin:/\b\d[\d_]*((U?[SIL])|[%&])?/},{begin:/&H[\dA-F_]+((U?[SIL])|[%&])?/},{begin:/&O[0-7_]+((U?[SIL])|[%&])?/},{begin:/&B[01_]+((U?[SIL])|[%&])?/}]},c={className:"label",begin:/^\w+:/},d=t.COMMENT(/'''/,/$/,{contains:[{className:"doctag",begin:/<\/?/,end:/>/}]}),f=t.COMMENT(null,/$/,{variants:[{begin:/'/},{begin:/([\t ]|^)REM(?=\s)/}]});return{name:"Visual Basic .NET",aliases:["vb"],case_insensitive:!0,classNameAliases:{label:"symbol"},keywords:{keyword:"addhandler alias aggregate ansi as async assembly auto binary by byref byval call case catch class compare const continue custom declare default delegate dim distinct do each equals else elseif end enum erase error event exit explicit finally for friend from function get global goto group handles if implements imports in inherits interface into iterator join key let lib loop me mid module mustinherit mustoverride mybase myclass namespace narrowing new next notinheritable notoverridable of off on operator option optional order overloads overridable overrides paramarray partial preserve private property protected public raiseevent readonly redim removehandler resume return select set shadows shared skip static step stop structure strict sub synclock take text then throw to try unicode until using when where while widening with withevents writeonly yield",built_in:"addressof and andalso await directcast gettype getxmlnamespace is isfalse isnot istrue like mod nameof new not or orelse trycast typeof xor cbool cbyte cchar cdate cdbl cdec cint clng cobj csbyte cshort csng cstr cuint culng cushort",type:"boolean byte char date decimal double integer long object sbyte short single string uinteger ulong ushort",literal:"true false nothing"},illegal:"//|\\{|\\}|endif|gosub|variant|wend|^\\$ ",contains:[n,r,l,u,c,d,f,{className:"meta",begin:/[\t ]*#(const|disable|else|elseif|enable|end|externalsource|if|region)\b/,end:/$/,keywords:{keyword:"const disable else elseif enable end externalsource if region then"},contains:[f]}]}}function n5(t){t.regex;const e=t.COMMENT(/\(;/,/;\)/);e.contains.push("self");const n=t.COMMENT(/;;/,/$/),r=["anyfunc","block","br","br_if","br_table","call","call_indirect","data","drop","elem","else","end","export","func","global.get","global.set","local.get","local.set","local.tee","get_global","get_local","global","if","import","local","loop","memory","memory.grow","memory.size","module","mut","nop","offset","param","result","return","select","set_global","set_local","start","table","tee_local","then","type","unreachable"],i={begin:[/(?:func|call|call_indirect)/,/\s+/,/\$[^\s)]+/],className:{1:"keyword",3:"title.function"}},s={className:"variable",begin:/\$[\w_]+/},o={match:/(\((?!;)|\))+/,className:"punctuation",relevance:0},a={className:"number",relevance:0,match:/[+-]?\b(?:\d(?:_?\d)*(?:\.\d(?:_?\d)*)?(?:[eE][+-]?\d(?:_?\d)*)?|0x[\da-fA-F](?:_?[\da-fA-F])*(?:\.[\da-fA-F](?:_?[\da-fA-D])*)?(?:[pP][+-]?\d(?:_?\d)*)?)\b|\binf\b|\bnan(?::0x[\da-fA-F](?:_?[\da-fA-D])*)?\b/},l={match:/(i32|i64|f32|f64)(?!\.)/,className:"type"},u={className:"keyword",match:/\b(f32|f64|i32|i64)(?:\.(?:abs|add|and|ceil|clz|const|convert_[su]\/i(?:32|64)|copysign|ctz|demote\/f64|div(?:_[su])?|eqz?|extend_[su]\/i32|floor|ge(?:_[su])?|gt(?:_[su])?|le(?:_[su])?|load(?:(?:8|16|32)_[su])?|lt(?:_[su])?|max|min|mul|nearest|neg?|or|popcnt|promote\/f32|reinterpret\/[fi](?:32|64)|rem_[su]|rot[lr]|shl|shr_[su]|store(?:8|16|32)?|sqrt|sub|trunc(?:_[su]\/f(?:32|64))?|wrap\/i64|xor))\b/};return{name:"WebAssembly",keywords:{$pattern:/[\w.]+/,keyword:r},contains:[n,e,{match:[/(?:offset|align)/,/\s*/,/=/],className:{1:"keyword",3:"operator"}},s,o,i,t.QUOTE_STRING_MODE,l,u,a]}}function r5(t){const e=t.regex,n=e.concat(/[\p{L}_]/u,e.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),r=/[\p{L}0-9._:-]+/u,i={className:"symbol",begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},s={begin:/\s/,contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},o=t.inherit(s,{begin:/\(/,end:/\)/}),a=t.inherit(t.APOS_STRING_MODE,{className:"string"}),l=t.inherit(t.QUOTE_STRING_MODE,{className:"string"}),u={endsWithParent:!0,illegal:/`]+/}]}]}]};return{name:"HTML, XML",aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist","wsf","svg"],case_insensitive:!0,unicodeRegex:!0,contains:[{className:"meta",begin://,relevance:10,contains:[s,l,a,o,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin://,contains:[s,o,l,a]}]}]},t.COMMENT(//,{relevance:10}),{begin://,relevance:10},i,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[l]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:"tag",begin:/)/,end:/>/,keywords:{name:"style"},contains:[u],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:["css","xml"]}},{className:"tag",begin:/)/,end:/>/,keywords:{name:"script"},contains:[u],starts:{end:/<\/script>/,returnEnd:!0,subLanguage:["javascript","handlebars","xml"]}},{className:"tag",begin:/<>|<\/>/},{className:"tag",begin:e.concat(//,/>/,/\s/)))),end:/\/?>/,contains:[{className:"name",begin:n,relevance:0,starts:u}]},{className:"tag",begin:e.concat(/<\//,e.lookahead(e.concat(n,/>/))),contains:[{className:"name",begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}function i5(t){const e="true false yes no null",n="[\\w#;/?:@&=+$,.~*'()[\\]]+",r={className:"attr",variants:[{begin:"\\w[\\w :\\/.-]*:(?=[ ]|$)"},{begin:'"\\w[\\w :\\/.-]*":(?=[ ]|$)'},{begin:"'\\w[\\w :\\/.-]*':(?=[ ]|$)"}]},i={className:"template-variable",variants:[{begin:/\{\{/,end:/\}\}/},{begin:/%\{/,end:/\}/}]},s={className:"string",relevance:0,variants:[{begin:/'/,end:/'/},{begin:/"/,end:/"/},{begin:/\S+/}],contains:[t.BACKSLASH_ESCAPE,i]},o=t.inherit(s,{variants:[{begin:/'/,end:/'/},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),a="[0-9]{4}(-[0-9][0-9]){0,2}",l="([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?",u="(\\.[0-9]*)?",c="([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?",d={className:"number",begin:"\\b"+a+l+u+c+"\\b"},f={end:",",endsWithParent:!0,excludeEnd:!0,keywords:e,relevance:0},h={begin:/\{/,end:/\}/,contains:[f],illegal:"\\n",relevance:0},p={begin:"\\[",end:"\\]",contains:[f],illegal:"\\n",relevance:0},m=[r,{className:"meta",begin:"^---\\s*$",relevance:10},{className:"string",begin:"[\\|>]([1-9]?[+-])?[ ]*\\n( +)[^ ][^\\n]*\\n(\\2[^\\n]+\\n?)*"},{begin:"<%[%=-]?",end:"[%-]?%>",subLanguage:"ruby",excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:"!\\w+!"+n},{className:"type",begin:"!<"+n+">"},{className:"type",begin:"!"+n},{className:"type",begin:"!!"+n},{className:"meta",begin:"&"+t.UNDERSCORE_IDENT_RE+"$"},{className:"meta",begin:"\\*"+t.UNDERSCORE_IDENT_RE+"$"},{className:"bullet",begin:"-(?=[ ]|$)",relevance:0},t.HASH_COMMENT_MODE,{beginKeywords:e,keywords:{literal:e}},d,{className:"number",begin:t.C_NUMBER_RE+"\\b",relevance:0},h,p,s],g=[...m];return g.pop(),g.push(o),f.contains=g,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:m}}const s5={arduino:K4,bash:W4,c:j4,cpp:G4,csharp:J4,css:r6,diff:i6,go:s6,graphql:o6,ini:a6,java:l6,javascript:h6,json:p6,kotlin:g6,less:E6,lua:_6,makefile:C6,markdown:w6,objectivec:S6,perl:A6,php:M6,"php-template":T6,plaintext:D6,python:O6,"python-repl":N6,r:L6,ruby:R6,rust:I6,scss:V6,shell:U6,sql:q6,swift:X6,typescript:e5,vbnet:t5,wasm:n5,xml:r5,yaml:i5};function Fm(t){return t instanceof Map?t.clear=t.delete=t.set=function(){throw new Error("map is read-only")}:t instanceof Set&&(t.add=t.clear=t.delete=function(){throw new Error("set is read-only")}),Object.freeze(t),Object.getOwnPropertyNames(t).forEach(e=>{const n=t[e],r=typeof n;(r==="object"||r==="function")&&!Object.isFrozen(n)&&Fm(n)}),t}class Dh{constructor(e){e.data===void 0&&(e.data={}),this.data=e.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function Hm(t){return t.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}function Bn(t,...e){const n=Object.create(null);for(const r in t)n[r]=t[r];return e.forEach(function(r){for(const i in r)n[i]=r[i]}),n}const o5="",Oh=t=>!!t.scope,a5=(t,{prefix:e})=>{if(t.startsWith("language:"))return t.replace("language:","language-");if(t.includes(".")){const n=t.split(".");return[`${e}${n.shift()}`,...n.map((r,i)=>`${r}${"_".repeat(i+1)}`)].join(" ")}return`${e}${t}`};class l5{constructor(e,n){this.buffer="",this.classPrefix=n.classPrefix,e.walk(this)}addText(e){this.buffer+=Hm(e)}openNode(e){if(!Oh(e))return;const n=a5(e.scope,{prefix:this.classPrefix});this.span(n)}closeNode(e){Oh(e)&&(this.buffer+=o5)}value(){return this.buffer}span(e){this.buffer+=``}}const Nh=(t={})=>{const e={children:[]};return Object.assign(e,t),e};class Lc{constructor(){this.rootNode=Nh(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(e){this.top.children.push(e)}openNode(e){const n=Nh({scope:e});this.add(n),this.stack.push(n)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(e){return this.constructor._walk(e,this.rootNode)}static _walk(e,n){return typeof n=="string"?e.addText(n):n.children&&(e.openNode(n),n.children.forEach(r=>this._walk(e,r)),e.closeNode(n)),e}static _collapse(e){typeof e!="string"&&e.children&&(e.children.every(n=>typeof n=="string")?e.children=[e.children.join("")]:e.children.forEach(n=>{Lc._collapse(n)}))}}class u5 extends Lc{constructor(e){super(),this.options=e}addText(e){e!==""&&this.add(e)}startScope(e){this.openNode(e)}endScope(){this.closeNode()}__addSublanguage(e,n){const r=e.root;n&&(r.scope=`language:${n}`),this.add(r)}toHTML(){return new l5(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function is(t){return t?typeof t=="string"?t:t.source:null}function Bm(t){return wr("(?=",t,")")}function c5(t){return wr("(?:",t,")*")}function d5(t){return wr("(?:",t,")?")}function wr(...t){return t.map(n=>is(n)).join("")}function f5(t){const e=t[t.length-1];return typeof e=="object"&&e.constructor===Object?(t.splice(t.length-1,1),e):{}}function Rc(...t){return"("+(f5(t).capture?"":"?:")+t.map(r=>is(r)).join("|")+")"}function Pm(t){return new RegExp(t.toString()+"|").exec("").length-1}function h5(t,e){const n=t&&t.exec(e);return n&&n.index===0}const p5=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function Ic(t,{joinWith:e}){let n=0;return t.map(r=>{n+=1;const i=n;let s=is(r),o="";for(;s.length>0;){const a=p5.exec(s);if(!a){o+=s;break}o+=s.substring(0,a.index),s=s.substring(a.index+a[0].length),a[0][0]==="\\"&&a[1]?o+="\\"+String(Number(a[1])+i):(o+=a[0],a[0]==="("&&n++)}return o}).map(r=>`(${r})`).join(e)}const m5=/\b\B/,$m="[a-zA-Z]\\w*",Fc="[a-zA-Z_]\\w*",zm="\\b\\d+(\\.\\d+)?",Vm="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",Um="\\b(0b[01]+)",g5="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",b5=(t={})=>{const e=/^#![ ]*\//;return t.binary&&(t.begin=wr(e,/.*\b/,t.binary,/\b.*/)),Bn({scope:"meta",begin:e,end:/$/,relevance:0,"on:begin":(n,r)=>{n.index!==0&&r.ignoreMatch()}},t)},ss={begin:"\\\\[\\s\\S]",relevance:0},y5={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[ss]},x5={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[ss]},k5={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},Oa=function(t,e,n={}){const r=Bn({scope:"comment",begin:t,end:e,contains:[]},n);r.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});const i=Rc("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return r.contains.push({begin:wr(/[ ]+/,"(",i,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),r},v5=Oa("//","$"),E5=Oa("/\\*","\\*/"),_5=Oa("#","$"),C5={scope:"number",begin:zm,relevance:0},w5={scope:"number",begin:Vm,relevance:0},S5={scope:"number",begin:Um,relevance:0},A5={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[ss,{begin:/\[/,end:/\]/,relevance:0,contains:[ss]}]},M5={scope:"title",begin:$m,relevance:0},T5={scope:"title",begin:Fc,relevance:0},D5={begin:"\\.\\s*"+Fc,relevance:0},O5=function(t){return Object.assign(t,{"on:begin":(e,n)=>{n.data._beginMatch=e[1]},"on:end":(e,n)=>{n.data._beginMatch!==e[1]&&n.ignoreMatch()}})};var Qs=Object.freeze({__proto__:null,APOS_STRING_MODE:y5,BACKSLASH_ESCAPE:ss,BINARY_NUMBER_MODE:S5,BINARY_NUMBER_RE:Um,COMMENT:Oa,C_BLOCK_COMMENT_MODE:E5,C_LINE_COMMENT_MODE:v5,C_NUMBER_MODE:w5,C_NUMBER_RE:Vm,END_SAME_AS_BEGIN:O5,HASH_COMMENT_MODE:_5,IDENT_RE:$m,MATCH_NOTHING_RE:m5,METHOD_GUARD:D5,NUMBER_MODE:C5,NUMBER_RE:zm,PHRASAL_WORDS_MODE:k5,QUOTE_STRING_MODE:x5,REGEXP_MODE:A5,RE_STARTERS_RE:g5,SHEBANG:b5,TITLE_MODE:M5,UNDERSCORE_IDENT_RE:Fc,UNDERSCORE_TITLE_MODE:T5});function N5(t,e){t.input[t.index-1]==="."&&e.ignoreMatch()}function L5(t,e){t.className!==void 0&&(t.scope=t.className,delete t.className)}function R5(t,e){e&&t.beginKeywords&&(t.begin="\\b("+t.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",t.__beforeBegin=N5,t.keywords=t.keywords||t.beginKeywords,delete t.beginKeywords,t.relevance===void 0&&(t.relevance=0))}function I5(t,e){Array.isArray(t.illegal)&&(t.illegal=Rc(...t.illegal))}function F5(t,e){if(t.match){if(t.begin||t.end)throw new Error("begin & end are not supported with match");t.begin=t.match,delete t.match}}function H5(t,e){t.relevance===void 0&&(t.relevance=1)}const B5=(t,e)=>{if(!t.beforeMatch)return;if(t.starts)throw new Error("beforeMatch cannot be used with starts");const n=Object.assign({},t);Object.keys(t).forEach(r=>{delete t[r]}),t.keywords=n.keywords,t.begin=wr(n.beforeMatch,Bm(n.begin)),t.starts={relevance:0,contains:[Object.assign(n,{endsParent:!0})]},t.relevance=0,delete n.beforeMatch},P5=["of","and","for","in","not","or","if","then","parent","list","value"],$5="keyword";function qm(t,e,n=$5){const r=Object.create(null);return typeof t=="string"?i(n,t.split(" ")):Array.isArray(t)?i(n,t):Object.keys(t).forEach(function(s){Object.assign(r,qm(t[s],e,s))}),r;function i(s,o){e&&(o=o.map(a=>a.toLowerCase())),o.forEach(function(a){const l=a.split("|");r[l[0]]=[s,z5(l[0],l[1])]})}}function z5(t,e){return e?Number(e):V5(t)?0:1}function V5(t){return P5.includes(t.toLowerCase())}const Lh={},mr=t=>{console.error(t)},Rh=(t,...e)=>{console.log(`WARN: ${t}`,...e)},Ir=(t,e)=>{Lh[`${t}/${e}`]||(console.log(`Deprecated as of ${t}. ${e}`),Lh[`${t}/${e}`]=!0)},ea=new Error;function Zm(t,e,{key:n}){let r=0;const i=t[n],s={},o={};for(let a=1;a<=e.length;a++)o[a+r]=i[a],s[a+r]=!0,r+=Pm(e[a-1]);t[n]=o,t[n]._emit=s,t[n]._multi=!0}function U5(t){if(Array.isArray(t.begin)){if(t.skip||t.excludeBegin||t.returnBegin)throw mr("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),ea;if(typeof t.beginScope!="object"||t.beginScope===null)throw mr("beginScope must be object"),ea;Zm(t,t.begin,{key:"beginScope"}),t.begin=Ic(t.begin,{joinWith:""})}}function q5(t){if(Array.isArray(t.end)){if(t.skip||t.excludeEnd||t.returnEnd)throw mr("skip, excludeEnd, returnEnd not compatible with endScope: {}"),ea;if(typeof t.endScope!="object"||t.endScope===null)throw mr("endScope must be object"),ea;Zm(t,t.end,{key:"endScope"}),t.end=Ic(t.end,{joinWith:""})}}function Z5(t){t.scope&&typeof t.scope=="object"&&t.scope!==null&&(t.beginScope=t.scope,delete t.scope)}function K5(t){Z5(t),typeof t.beginScope=="string"&&(t.beginScope={_wrap:t.beginScope}),typeof t.endScope=="string"&&(t.endScope={_wrap:t.endScope}),U5(t),q5(t)}function W5(t){function e(o,a){return new RegExp(is(o),"m"+(t.case_insensitive?"i":"")+(t.unicodeRegex?"u":"")+(a?"g":""))}class n{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(a,l){l.position=this.position++,this.matchIndexes[this.matchAt]=l,this.regexes.push([l,a]),this.matchAt+=Pm(a)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const a=this.regexes.map(l=>l[1]);this.matcherRe=e(Ic(a,{joinWith:"|"}),!0),this.lastIndex=0}exec(a){this.matcherRe.lastIndex=this.lastIndex;const l=this.matcherRe.exec(a);if(!l)return null;const u=l.findIndex((d,f)=>f>0&&d!==void 0),c=this.matchIndexes[u];return l.splice(0,u),Object.assign(l,c)}}class r{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(a){if(this.multiRegexes[a])return this.multiRegexes[a];const l=new n;return this.rules.slice(a).forEach(([u,c])=>l.addRule(u,c)),l.compile(),this.multiRegexes[a]=l,l}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(a,l){this.rules.push([a,l]),l.type==="begin"&&this.count++}exec(a){const l=this.getMatcher(this.regexIndex);l.lastIndex=this.lastIndex;let u=l.exec(a);if(this.resumingScanAtSamePosition()&&!(u&&u.index===this.lastIndex)){const c=this.getMatcher(0);c.lastIndex=this.lastIndex+1,u=c.exec(a)}return u&&(this.regexIndex+=u.position+1,this.regexIndex===this.count&&this.considerAll()),u}}function i(o){const a=new r;return o.contains.forEach(l=>a.addRule(l.begin,{rule:l,type:"begin"})),o.terminatorEnd&&a.addRule(o.terminatorEnd,{type:"end"}),o.illegal&&a.addRule(o.illegal,{type:"illegal"}),a}function s(o,a){const l=o;if(o.isCompiled)return l;[L5,F5,K5,B5].forEach(c=>c(o,a)),t.compilerExtensions.forEach(c=>c(o,a)),o.__beforeBegin=null,[R5,I5,H5].forEach(c=>c(o,a)),o.isCompiled=!0;let u=null;return typeof o.keywords=="object"&&o.keywords.$pattern&&(o.keywords=Object.assign({},o.keywords),u=o.keywords.$pattern,delete o.keywords.$pattern),u=u||/\w+/,o.keywords&&(o.keywords=qm(o.keywords,t.case_insensitive)),l.keywordPatternRe=e(u,!0),a&&(o.begin||(o.begin=/\B|\b/),l.beginRe=e(l.begin),!o.end&&!o.endsWithParent&&(o.end=/\B|\b/),o.end&&(l.endRe=e(l.end)),l.terminatorEnd=is(l.end)||"",o.endsWithParent&&a.terminatorEnd&&(l.terminatorEnd+=(o.end?"|":"")+a.terminatorEnd)),o.illegal&&(l.illegalRe=e(o.illegal)),o.contains||(o.contains=[]),o.contains=[].concat(...o.contains.map(function(c){return j5(c==="self"?o:c)})),o.contains.forEach(function(c){s(c,l)}),o.starts&&s(o.starts,a),l.matcher=i(l),l}if(t.compilerExtensions||(t.compilerExtensions=[]),t.contains&&t.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return t.classNameAliases=Bn(t.classNameAliases||{}),s(t)}function Km(t){return t?t.endsWithParent||Km(t.starts):!1}function j5(t){return t.variants&&!t.cachedVariants&&(t.cachedVariants=t.variants.map(function(e){return Bn(t,{variants:null},e)})),t.cachedVariants?t.cachedVariants:Km(t)?Bn(t,{starts:t.starts?Bn(t.starts):null}):Object.isFrozen(t)?Bn(t):t}var G5="11.9.0";class J5 extends Error{constructor(e,n){super(e),this.name="HTMLInjectionError",this.html=n}}const Ll=Hm,Ih=Bn,Fh=Symbol("nomatch"),Y5=7,Wm=function(t){const e=Object.create(null),n=Object.create(null),r=[];let i=!0;const s="Could not find the language '{}', did you forget to load/include a language module?",o={disableAutodetect:!0,name:"Plain text",contains:[]};let a={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:u5};function l(_){return a.noHighlightRe.test(_)}function u(_){let S=_.className+" ";S+=_.parentNode?_.parentNode.className:"";const L=a.languageDetectRe.exec(S);if(L){const F=w(L[1]);return F||(Rh(s.replace("{}",L[1])),Rh("Falling back to no-highlight mode for this block.",_)),F?L[1]:"no-highlight"}return S.split(/\s+/).find(F=>l(F)||w(F))}function c(_,S,L){let F="",j="";typeof S=="object"?(F=_,L=S.ignoreIllegals,j=S.language):(Ir("10.7.0","highlight(lang, code, ...args) has been deprecated."),Ir("10.7.0",`Please use highlight(code, options) instead. -https://github.com/highlightjs/highlight.js/issues/2277`),j=_,F=S),L===void 0&&(L=!0);const Q={code:F,language:j};z("before:highlight",Q);const pe=Q.result?Q.result:d(Q.language,Q.code,L);return pe.code=Q.code,z("after:highlight",pe),pe}function d(_,S,L,F){const j=Object.create(null);function Q(D,R){return D.keywords[R]}function pe(){if(!V.keywords){be.addText(ce);return}let D=0;V.keywordPatternRe.lastIndex=0;let R=V.keywordPatternRe.exec(ce),J="";for(;R;){J+=ce.substring(D,R.index);const ae=Le.case_insensitive?R[0].toLowerCase():R[0],Fe=Q(V,ae);if(Fe){const[kt,Za]=Fe;if(be.addText(J),J="",j[ae]=(j[ae]||0)+1,j[ae]<=Y5&&(Qe+=Za),kt.startsWith("_"))J+=R[0];else{const M=Le.classNameAliases[kt]||kt;Se(R[0],M)}}else J+=R[0];D=V.keywordPatternRe.lastIndex,R=V.keywordPatternRe.exec(ce)}J+=ce.substring(D),be.addText(J)}function ke(){if(ce==="")return;let D=null;if(typeof V.subLanguage=="string"){if(!e[V.subLanguage]){be.addText(ce);return}D=d(V.subLanguage,ce,!0,de[V.subLanguage]),de[V.subLanguage]=D._top}else D=h(ce,V.subLanguage.length?V.subLanguage:null);V.relevance>0&&(Qe+=D.relevance),be.__addSublanguage(D._emitter,D.language)}function fe(){V.subLanguage!=null?ke():pe(),ce=""}function Se(D,R){D!==""&&(be.startScope(R),be.addText(D),be.endScope())}function ut(D,R){let J=1;const ae=R.length-1;for(;J<=ae;){if(!D._emit[J]){J++;continue}const Fe=Le.classNameAliases[D[J]]||D[J],kt=R[J];Fe?Se(kt,Fe):(ce=kt,pe(),ce=""),J++}}function We(D,R){return D.scope&&typeof D.scope=="string"&&be.openNode(Le.classNameAliases[D.scope]||D.scope),D.beginScope&&(D.beginScope._wrap?(Se(ce,Le.classNameAliases[D.beginScope._wrap]||D.beginScope._wrap),ce=""):D.beginScope._multi&&(ut(D.beginScope,R),ce="")),V=Object.create(D,{parent:{value:V}}),V}function yt(D,R,J){let ae=h5(D.endRe,J);if(ae){if(D["on:end"]){const Fe=new Dh(D);D["on:end"](R,Fe),Fe.isMatchIgnored&&(ae=!1)}if(ae){for(;D.endsParent&&D.parent;)D=D.parent;return D}}if(D.endsWithParent)return yt(D.parent,R,J)}function ct(D){return V.matcher.regexIndex===0?(ce+=D[0],1):(q=!0,0)}function At(D){const R=D[0],J=D.rule,ae=new Dh(J),Fe=[J.__beforeBegin,J["on:begin"]];for(const kt of Fe)if(kt&&(kt(D,ae),ae.isMatchIgnored))return ct(R);return J.skip?ce+=R:(J.excludeBegin&&(ce+=R),fe(),!J.returnBegin&&!J.excludeBegin&&(ce=R)),We(J,D),J.returnBegin?0:R.length}function xt(D){const R=D[0],J=S.substring(D.index),ae=yt(V,D,J);if(!ae)return Fh;const Fe=V;V.endScope&&V.endScope._wrap?(fe(),Se(R,V.endScope._wrap)):V.endScope&&V.endScope._multi?(fe(),ut(V.endScope,D)):Fe.skip?ce+=R:(Fe.returnEnd||Fe.excludeEnd||(ce+=R),fe(),Fe.excludeEnd&&(ce=R));do V.scope&&be.closeNode(),!V.skip&&!V.subLanguage&&(Qe+=V.relevance),V=V.parent;while(V!==ae.parent);return ae.starts&&We(ae.starts,D),Fe.returnEnd?0:R.length}function he(){const D=[];for(let R=V;R!==Le;R=R.parent)R.scope&&D.unshift(R.scope);D.forEach(R=>be.openNode(R))}let De={};function rt(D,R){const J=R&&R[0];if(ce+=D,J==null)return fe(),0;if(De.type==="begin"&&R.type==="end"&&De.index===R.index&&J===""){if(ce+=S.slice(R.index,R.index+1),!i){const ae=new Error(`0 width match regex (${_})`);throw ae.languageName=_,ae.badRule=De.rule,ae}return 1}if(De=R,R.type==="begin")return At(R);if(R.type==="illegal"&&!L){const ae=new Error('Illegal lexeme "'+J+'" for mode "'+(V.scope||"")+'"');throw ae.mode=V,ae}else if(R.type==="end"){const ae=xt(R);if(ae!==Fh)return ae}if(R.type==="illegal"&&J==="")return 1;if(H>1e5&&H>R.index*3)throw new Error("potential infinite loop, way more iterations than matches");return ce+=J,J.length}const Le=w(_);if(!Le)throw mr(s.replace("{}",_)),new Error('Unknown language: "'+_+'"');const te=W5(Le);let Bt="",V=F||te;const de={},be=new a.__emitter(a);he();let ce="",Qe=0,je=0,H=0,q=!1;try{if(Le.__emitTokens)Le.__emitTokens(S,be);else{for(V.matcher.considerAll();;){H++,q?q=!1:V.matcher.considerAll(),V.matcher.lastIndex=je;const D=V.matcher.exec(S);if(!D)break;const R=S.substring(je,D.index),J=rt(R,D);je=D.index+J}rt(S.substring(je))}return be.finalize(),Bt=be.toHTML(),{language:_,value:Bt,relevance:Qe,illegal:!1,_emitter:be,_top:V}}catch(D){if(D.message&&D.message.includes("Illegal"))return{language:_,value:Ll(S),illegal:!0,relevance:0,_illegalBy:{message:D.message,index:je,context:S.slice(je-100,je+100),mode:D.mode,resultSoFar:Bt},_emitter:be};if(i)return{language:_,value:Ll(S),illegal:!1,relevance:0,errorRaised:D,_emitter:be,_top:V};throw D}}function f(_){const S={value:Ll(_),illegal:!1,relevance:0,_top:o,_emitter:new a.__emitter(a)};return S._emitter.addText(_),S}function h(_,S){S=S||a.languages||Object.keys(e);const L=f(_),F=S.filter(w).filter($).map(fe=>d(fe,_,!1));F.unshift(L);const j=F.sort((fe,Se)=>{if(fe.relevance!==Se.relevance)return Se.relevance-fe.relevance;if(fe.language&&Se.language){if(w(fe.language).supersetOf===Se.language)return 1;if(w(Se.language).supersetOf===fe.language)return-1}return 0}),[Q,pe]=j,ke=Q;return ke.secondBest=pe,ke}function p(_,S,L){const F=S&&n[S]||L;_.classList.add("hljs"),_.classList.add(`language-${F}`)}function m(_){let S=null;const L=u(_);if(l(L))return;if(z("before:highlightElement",{el:_,language:L}),_.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",_);return}if(_.children.length>0&&(a.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(_)),a.throwUnescapedHTML))throw new J5("One of your code blocks includes unescaped HTML.",_.innerHTML);S=_;const F=S.textContent,j=L?c(F,{language:L,ignoreIllegals:!0}):h(F);_.innerHTML=j.value,_.dataset.highlighted="yes",p(_,L,j.language),_.result={language:j.language,re:j.relevance,relevance:j.relevance},j.secondBest&&(_.secondBest={language:j.secondBest.language,relevance:j.secondBest.relevance}),z("after:highlightElement",{el:_,result:j,text:F})}function g(_){a=Ih(a,_)}const y=()=>{b(),Ir("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function x(){b(),Ir("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let k=!1;function b(){if(document.readyState==="loading"){k=!0;return}document.querySelectorAll(a.cssSelector).forEach(m)}function E(){k&&b()}typeof window<"u"&&window.addEventListener&&window.addEventListener("DOMContentLoaded",E,!1);function v(_,S){let L=null;try{L=S(t)}catch(F){if(mr("Language definition for '{}' could not be registered.".replace("{}",_)),i)mr(F);else throw F;L=o}L.name||(L.name=_),e[_]=L,L.rawDefinition=S.bind(null,t),L.aliases&&N(L.aliases,{languageName:_})}function C(_){delete e[_];for(const S of Object.keys(n))n[S]===_&&delete n[S]}function T(){return Object.keys(e)}function w(_){return _=(_||"").toLowerCase(),e[_]||e[n[_]]}function N(_,{languageName:S}){typeof _=="string"&&(_=[_]),_.forEach(L=>{n[L.toLowerCase()]=S})}function $(_){const S=w(_);return S&&!S.disableAutodetect}function K(_){_["before:highlightBlock"]&&!_["before:highlightElement"]&&(_["before:highlightElement"]=S=>{_["before:highlightBlock"](Object.assign({block:S.el},S))}),_["after:highlightBlock"]&&!_["after:highlightElement"]&&(_["after:highlightElement"]=S=>{_["after:highlightBlock"](Object.assign({block:S.el},S))})}function U(_){K(_),r.push(_)}function W(_){const S=r.indexOf(_);S!==-1&&r.splice(S,1)}function z(_,S){const L=_;r.forEach(function(F){F[L]&&F[L](S)})}function A(_){return Ir("10.7.0","highlightBlock will be removed entirely in v12.0"),Ir("10.7.0","Please use highlightElement now."),m(_)}Object.assign(t,{highlight:c,highlightAuto:h,highlightAll:b,highlightElement:m,highlightBlock:A,configure:g,initHighlighting:y,initHighlightingOnLoad:x,registerLanguage:v,unregisterLanguage:C,listLanguages:T,getLanguage:w,registerAliases:N,autoDetection:$,inherit:Ih,addPlugin:U,removePlugin:W}),t.debugMode=function(){i=!1},t.safeMode=function(){i=!0},t.versionString=G5,t.regex={concat:wr,lookahead:Bm,either:Rc,optional:d5,anyNumberOfTimes:c5};for(const _ in Qs)typeof Qs[_]=="object"&&Fm(Qs[_]);return Object.assign(t,Qs),t},ci=Wm({});ci.newInstance=()=>Wm({});var X5=ci;ci.HighlightJS=ci;ci.default=ci;const Q5=_s(X5),Hh={},eS="hljs-";function tS(t){const e=Q5.newInstance();return t&&s(t),{highlight:n,highlightAuto:r,listLanguages:i,register:s,registerAlias:o,registered:a};function n(l,u,c){const d=c||Hh,f=typeof d.prefix=="string"?d.prefix:eS;if(!e.getLanguage(l))throw new Error("Unknown language: `"+l+"` is not registered");e.configure({__emitter:nS,classPrefix:f});const h=e.highlight(u,{ignoreIllegals:!0,language:l});if(h.errorRaised)throw new Error("Could not highlight with `Highlight.js`",{cause:h.errorRaised});const p=h._emitter.root,m=p.data;return m.language=h.language,m.relevance=h.relevance,p}function r(l,u){const d=(u||Hh).subset||i();let f=-1,h=0,p;for(;++fh&&(h=g.data.relevance,p=g)}return p||{type:"root",children:[],data:{language:void 0,relevance:h}}}function i(){return e.listLanguages()}function s(l,u){if(typeof l=="string")e.registerLanguage(l,u);else{let c;for(c in l)Object.hasOwn(l,c)&&e.registerLanguage(c,l[c])}}function o(l,u){if(typeof l=="string")e.registerAliases(typeof u=="string"?u:[...u],{languageName:l});else{let c;for(c in l)if(Object.hasOwn(l,c)){const d=l[c];e.registerAliases(typeof d=="string"?d:[...d],{languageName:c})}}}function a(l){return!!e.getLanguage(l)}}class nS{constructor(e){this.options=e,this.root={type:"root",children:[],data:{language:void 0,relevance:0}},this.stack=[this.root]}addText(e){if(e==="")return;const n=this.stack[this.stack.length-1],r=n.children[n.children.length-1];r&&r.type==="text"?r.value+=e:n.children.push({type:"text",value:e})}startScope(e){this.openNode(String(e))}endScope(){this.closeNode()}__addSublanguage(e,n){const r=this.stack[this.stack.length-1],i=e.root.children;n?r.children.push({type:"element",tagName:"span",properties:{className:[n]},children:i}):r.children.push(...i)}openNode(e){const n=this,r=e.split(".").map(function(o,a){return a?o+"_".repeat(a):n.options.classPrefix+o}),i=this.stack[this.stack.length-1],s={type:"element",tagName:"span",properties:{className:r},children:[]};i.children.push(s),this.stack.push(s)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}}const rS=/!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\)/,Bh=new Te("aie-video-plugin"),wi="video_action",iS=ue.create({name:"video",group:"block",addAttributes(){return{src:{default:null,parseHTML:t=>{const e=t.getAttribute("src");if(e)return e;const n=t.querySelector("source");return n?n.getAttribute("src"):null},renderHTML:t=>({src:t.src})},poster:{default:null,parseHTML:t=>t.getAttribute("poster"),renderHTML:t=>({poster:t.poster})},width:{default:350},controls:{default:!0}}},parseHTML(){return[{tag:"video",getAttrs:t=>({src:t.getAttribute("src"),poster:t.getAttribute("poster")})}]},renderHTML({HTMLAttributes:t}){return["video",{controls:"true",...t,src:null},["source",{src:t.src}]]},addCommands(){return{setVideo:t=>({commands:e})=>e.insertContent(`",Oh=t=>!!t.scope,l5=(t,{prefix:e})=>{if(t.startsWith("language:"))return t.replace("language:","language-");if(t.includes(".")){const n=t.split(".");return[`${e}${n.shift()}`,...n.map((r,i)=>`${r}${"_".repeat(i+1)}`)].join(" ")}return`${e}${t}`};class u5{constructor(e,n){this.buffer="",this.classPrefix=n.classPrefix,e.walk(this)}addText(e){this.buffer+=Fm(e)}openNode(e){if(!Oh(e))return;const n=l5(e.scope,{prefix:this.classPrefix});this.span(n)}closeNode(e){Oh(e)&&(this.buffer+=a5)}value(){return this.buffer}span(e){this.buffer+=``}}const Nh=(t={})=>{const e={children:[]};return Object.assign(e,t),e};class Rc{constructor(){this.rootNode=Nh(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(e){this.top.children.push(e)}openNode(e){const n=Nh({scope:e});this.add(n),this.stack.push(n)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(e){return this.constructor._walk(e,this.rootNode)}static _walk(e,n){return typeof n=="string"?e.addText(n):n.children&&(e.openNode(n),n.children.forEach(r=>this._walk(e,r)),e.closeNode(n)),e}static _collapse(e){typeof e!="string"&&e.children&&(e.children.every(n=>typeof n=="string")?e.children=[e.children.join("")]:e.children.forEach(n=>{Rc._collapse(n)}))}}class c5 extends Rc{constructor(e){super(),this.options=e}addText(e){e!==""&&this.add(e)}startScope(e){this.openNode(e)}endScope(){this.closeNode()}__addSublanguage(e,n){const r=e.root;n&&(r.scope=`language:${n}`),this.add(r)}toHTML(){return new u5(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function is(t){return t?typeof t=="string"?t:t.source:null}function Hm(t){return wr("(?=",t,")")}function d5(t){return wr("(?:",t,")*")}function f5(t){return wr("(?:",t,")?")}function wr(...t){return t.map(n=>is(n)).join("")}function h5(t){const e=t[t.length-1];return typeof e=="object"&&e.constructor===Object?(t.splice(t.length-1,1),e):{}}function Ic(...t){return"("+(h5(t).capture?"":"?:")+t.map(r=>is(r)).join("|")+")"}function Bm(t){return new RegExp(t.toString()+"|").exec("").length-1}function p5(t,e){const n=t&&t.exec(e);return n&&n.index===0}const m5=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function Fc(t,{joinWith:e}){let n=0;return t.map(r=>{n+=1;const i=n;let s=is(r),o="";for(;s.length>0;){const a=m5.exec(s);if(!a){o+=s;break}o+=s.substring(0,a.index),s=s.substring(a.index+a[0].length),a[0][0]==="\\"&&a[1]?o+="\\"+String(Number(a[1])+i):(o+=a[0],a[0]==="("&&n++)}return o}).map(r=>`(${r})`).join(e)}const g5=/\b\B/,Pm="[a-zA-Z]\\w*",Hc="[a-zA-Z_]\\w*",$m="\\b\\d+(\\.\\d+)?",zm="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",Vm="\\b(0b[01]+)",b5="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",y5=(t={})=>{const e=/^#![ ]*\//;return t.binary&&(t.begin=wr(e,/.*\b/,t.binary,/\b.*/)),Bn({scope:"meta",begin:e,end:/$/,relevance:0,"on:begin":(n,r)=>{n.index!==0&&r.ignoreMatch()}},t)},ss={begin:"\\\\[\\s\\S]",relevance:0},x5={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[ss]},k5={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[ss]},v5={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},Oa=function(t,e,n={}){const r=Bn({scope:"comment",begin:t,end:e,contains:[]},n);r.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});const i=Ic("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return r.contains.push({begin:wr(/[ ]+/,"(",i,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),r},E5=Oa("//","$"),_5=Oa("/\\*","\\*/"),C5=Oa("#","$"),w5={scope:"number",begin:$m,relevance:0},S5={scope:"number",begin:zm,relevance:0},A5={scope:"number",begin:Vm,relevance:0},M5={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[ss,{begin:/\[/,end:/\]/,relevance:0,contains:[ss]}]},T5={scope:"title",begin:Pm,relevance:0},D5={scope:"title",begin:Hc,relevance:0},O5={begin:"\\.\\s*"+Hc,relevance:0},N5=function(t){return Object.assign(t,{"on:begin":(e,n)=>{n.data._beginMatch=e[1]},"on:end":(e,n)=>{n.data._beginMatch!==e[1]&&n.ignoreMatch()}})};var Qs=Object.freeze({__proto__:null,APOS_STRING_MODE:x5,BACKSLASH_ESCAPE:ss,BINARY_NUMBER_MODE:A5,BINARY_NUMBER_RE:Vm,COMMENT:Oa,C_BLOCK_COMMENT_MODE:_5,C_LINE_COMMENT_MODE:E5,C_NUMBER_MODE:S5,C_NUMBER_RE:zm,END_SAME_AS_BEGIN:N5,HASH_COMMENT_MODE:C5,IDENT_RE:Pm,MATCH_NOTHING_RE:g5,METHOD_GUARD:O5,NUMBER_MODE:w5,NUMBER_RE:$m,PHRASAL_WORDS_MODE:v5,QUOTE_STRING_MODE:k5,REGEXP_MODE:M5,RE_STARTERS_RE:b5,SHEBANG:y5,TITLE_MODE:T5,UNDERSCORE_IDENT_RE:Hc,UNDERSCORE_TITLE_MODE:D5});function L5(t,e){t.input[t.index-1]==="."&&e.ignoreMatch()}function R5(t,e){t.className!==void 0&&(t.scope=t.className,delete t.className)}function I5(t,e){e&&t.beginKeywords&&(t.begin="\\b("+t.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",t.__beforeBegin=L5,t.keywords=t.keywords||t.beginKeywords,delete t.beginKeywords,t.relevance===void 0&&(t.relevance=0))}function F5(t,e){Array.isArray(t.illegal)&&(t.illegal=Ic(...t.illegal))}function H5(t,e){if(t.match){if(t.begin||t.end)throw new Error("begin & end are not supported with match");t.begin=t.match,delete t.match}}function B5(t,e){t.relevance===void 0&&(t.relevance=1)}const P5=(t,e)=>{if(!t.beforeMatch)return;if(t.starts)throw new Error("beforeMatch cannot be used with starts");const n=Object.assign({},t);Object.keys(t).forEach(r=>{delete t[r]}),t.keywords=n.keywords,t.begin=wr(n.beforeMatch,Hm(n.begin)),t.starts={relevance:0,contains:[Object.assign(n,{endsParent:!0})]},t.relevance=0,delete n.beforeMatch},$5=["of","and","for","in","not","or","if","then","parent","list","value"],z5="keyword";function Um(t,e,n=z5){const r=Object.create(null);return typeof t=="string"?i(n,t.split(" ")):Array.isArray(t)?i(n,t):Object.keys(t).forEach(function(s){Object.assign(r,Um(t[s],e,s))}),r;function i(s,o){e&&(o=o.map(a=>a.toLowerCase())),o.forEach(function(a){const l=a.split("|");r[l[0]]=[s,V5(l[0],l[1])]})}}function V5(t,e){return e?Number(e):U5(t)?0:1}function U5(t){return $5.includes(t.toLowerCase())}const Lh={},mr=t=>{console.error(t)},Rh=(t,...e)=>{console.log(`WARN: ${t}`,...e)},Ir=(t,e)=>{Lh[`${t}/${e}`]||(console.log(`Deprecated as of ${t}. ${e}`),Lh[`${t}/${e}`]=!0)},ea=new Error;function qm(t,e,{key:n}){let r=0;const i=t[n],s={},o={};for(let a=1;a<=e.length;a++)o[a+r]=i[a],s[a+r]=!0,r+=Bm(e[a-1]);t[n]=o,t[n]._emit=s,t[n]._multi=!0}function q5(t){if(Array.isArray(t.begin)){if(t.skip||t.excludeBegin||t.returnBegin)throw mr("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),ea;if(typeof t.beginScope!="object"||t.beginScope===null)throw mr("beginScope must be object"),ea;qm(t,t.begin,{key:"beginScope"}),t.begin=Fc(t.begin,{joinWith:""})}}function Z5(t){if(Array.isArray(t.end)){if(t.skip||t.excludeEnd||t.returnEnd)throw mr("skip, excludeEnd, returnEnd not compatible with endScope: {}"),ea;if(typeof t.endScope!="object"||t.endScope===null)throw mr("endScope must be object"),ea;qm(t,t.end,{key:"endScope"}),t.end=Fc(t.end,{joinWith:""})}}function K5(t){t.scope&&typeof t.scope=="object"&&t.scope!==null&&(t.beginScope=t.scope,delete t.scope)}function W5(t){K5(t),typeof t.beginScope=="string"&&(t.beginScope={_wrap:t.beginScope}),typeof t.endScope=="string"&&(t.endScope={_wrap:t.endScope}),q5(t),Z5(t)}function j5(t){function e(o,a){return new RegExp(is(o),"m"+(t.case_insensitive?"i":"")+(t.unicodeRegex?"u":"")+(a?"g":""))}class n{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(a,l){l.position=this.position++,this.matchIndexes[this.matchAt]=l,this.regexes.push([l,a]),this.matchAt+=Bm(a)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const a=this.regexes.map(l=>l[1]);this.matcherRe=e(Fc(a,{joinWith:"|"}),!0),this.lastIndex=0}exec(a){this.matcherRe.lastIndex=this.lastIndex;const l=this.matcherRe.exec(a);if(!l)return null;const u=l.findIndex((d,f)=>f>0&&d!==void 0),c=this.matchIndexes[u];return l.splice(0,u),Object.assign(l,c)}}class r{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(a){if(this.multiRegexes[a])return this.multiRegexes[a];const l=new n;return this.rules.slice(a).forEach(([u,c])=>l.addRule(u,c)),l.compile(),this.multiRegexes[a]=l,l}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(a,l){this.rules.push([a,l]),l.type==="begin"&&this.count++}exec(a){const l=this.getMatcher(this.regexIndex);l.lastIndex=this.lastIndex;let u=l.exec(a);if(this.resumingScanAtSamePosition()&&!(u&&u.index===this.lastIndex)){const c=this.getMatcher(0);c.lastIndex=this.lastIndex+1,u=c.exec(a)}return u&&(this.regexIndex+=u.position+1,this.regexIndex===this.count&&this.considerAll()),u}}function i(o){const a=new r;return o.contains.forEach(l=>a.addRule(l.begin,{rule:l,type:"begin"})),o.terminatorEnd&&a.addRule(o.terminatorEnd,{type:"end"}),o.illegal&&a.addRule(o.illegal,{type:"illegal"}),a}function s(o,a){const l=o;if(o.isCompiled)return l;[R5,H5,W5,P5].forEach(c=>c(o,a)),t.compilerExtensions.forEach(c=>c(o,a)),o.__beforeBegin=null,[I5,F5,B5].forEach(c=>c(o,a)),o.isCompiled=!0;let u=null;return typeof o.keywords=="object"&&o.keywords.$pattern&&(o.keywords=Object.assign({},o.keywords),u=o.keywords.$pattern,delete o.keywords.$pattern),u=u||/\w+/,o.keywords&&(o.keywords=Um(o.keywords,t.case_insensitive)),l.keywordPatternRe=e(u,!0),a&&(o.begin||(o.begin=/\B|\b/),l.beginRe=e(l.begin),!o.end&&!o.endsWithParent&&(o.end=/\B|\b/),o.end&&(l.endRe=e(l.end)),l.terminatorEnd=is(l.end)||"",o.endsWithParent&&a.terminatorEnd&&(l.terminatorEnd+=(o.end?"|":"")+a.terminatorEnd)),o.illegal&&(l.illegalRe=e(o.illegal)),o.contains||(o.contains=[]),o.contains=[].concat(...o.contains.map(function(c){return G5(c==="self"?o:c)})),o.contains.forEach(function(c){s(c,l)}),o.starts&&s(o.starts,a),l.matcher=i(l),l}if(t.compilerExtensions||(t.compilerExtensions=[]),t.contains&&t.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return t.classNameAliases=Bn(t.classNameAliases||{}),s(t)}function Zm(t){return t?t.endsWithParent||Zm(t.starts):!1}function G5(t){return t.variants&&!t.cachedVariants&&(t.cachedVariants=t.variants.map(function(e){return Bn(t,{variants:null},e)})),t.cachedVariants?t.cachedVariants:Zm(t)?Bn(t,{starts:t.starts?Bn(t.starts):null}):Object.isFrozen(t)?Bn(t):t}var J5="11.9.0";class Y5 extends Error{constructor(e,n){super(e),this.name="HTMLInjectionError",this.html=n}}const Ll=Fm,Ih=Bn,Fh=Symbol("nomatch"),X5=7,Km=function(t){const e=Object.create(null),n=Object.create(null),r=[];let i=!0;const s="Could not find the language '{}', did you forget to load/include a language module?",o={disableAutodetect:!0,name:"Plain text",contains:[]};let a={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:c5};function l(_){return a.noHighlightRe.test(_)}function u(_){let S=_.className+" ";S+=_.parentNode?_.parentNode.className:"";const L=a.languageDetectRe.exec(S);if(L){const F=w(L[1]);return F||(Rh(s.replace("{}",L[1])),Rh("Falling back to no-highlight mode for this block.",_)),F?L[1]:"no-highlight"}return S.split(/\s+/).find(F=>l(F)||w(F))}function c(_,S,L){let F="",j="";typeof S=="object"?(F=_,L=S.ignoreIllegals,j=S.language):(Ir("10.7.0","highlight(lang, code, ...args) has been deprecated."),Ir("10.7.0",`Please use highlight(code, options) instead. +https://github.com/highlightjs/highlight.js/issues/2277`),j=_,F=S),L===void 0&&(L=!0);const Q={code:F,language:j};z("before:highlight",Q);const pe=Q.result?Q.result:d(Q.language,Q.code,L);return pe.code=Q.code,z("after:highlight",pe),pe}function d(_,S,L,F){const j=Object.create(null);function Q(D,R){return D.keywords[R]}function pe(){if(!V.keywords){be.addText(ce);return}let D=0;V.keywordPatternRe.lastIndex=0;let R=V.keywordPatternRe.exec(ce),J="";for(;R;){J+=ce.substring(D,R.index);const ae=Le.case_insensitive?R[0].toLowerCase():R[0],Fe=Q(V,ae);if(Fe){const[kt,Za]=Fe;if(be.addText(J),J="",j[ae]=(j[ae]||0)+1,j[ae]<=X5&&(Qe+=Za),kt.startsWith("_"))J+=R[0];else{const M=Le.classNameAliases[kt]||kt;Se(R[0],M)}}else J+=R[0];D=V.keywordPatternRe.lastIndex,R=V.keywordPatternRe.exec(ce)}J+=ce.substring(D),be.addText(J)}function ke(){if(ce==="")return;let D=null;if(typeof V.subLanguage=="string"){if(!e[V.subLanguage]){be.addText(ce);return}D=d(V.subLanguage,ce,!0,de[V.subLanguage]),de[V.subLanguage]=D._top}else D=h(ce,V.subLanguage.length?V.subLanguage:null);V.relevance>0&&(Qe+=D.relevance),be.__addSublanguage(D._emitter,D.language)}function fe(){V.subLanguage!=null?ke():pe(),ce=""}function Se(D,R){D!==""&&(be.startScope(R),be.addText(D),be.endScope())}function ut(D,R){let J=1;const ae=R.length-1;for(;J<=ae;){if(!D._emit[J]){J++;continue}const Fe=Le.classNameAliases[D[J]]||D[J],kt=R[J];Fe?Se(kt,Fe):(ce=kt,pe(),ce=""),J++}}function We(D,R){return D.scope&&typeof D.scope=="string"&&be.openNode(Le.classNameAliases[D.scope]||D.scope),D.beginScope&&(D.beginScope._wrap?(Se(ce,Le.classNameAliases[D.beginScope._wrap]||D.beginScope._wrap),ce=""):D.beginScope._multi&&(ut(D.beginScope,R),ce="")),V=Object.create(D,{parent:{value:V}}),V}function yt(D,R,J){let ae=p5(D.endRe,J);if(ae){if(D["on:end"]){const Fe=new Dh(D);D["on:end"](R,Fe),Fe.isMatchIgnored&&(ae=!1)}if(ae){for(;D.endsParent&&D.parent;)D=D.parent;return D}}if(D.endsWithParent)return yt(D.parent,R,J)}function ct(D){return V.matcher.regexIndex===0?(ce+=D[0],1):(q=!0,0)}function At(D){const R=D[0],J=D.rule,ae=new Dh(J),Fe=[J.__beforeBegin,J["on:begin"]];for(const kt of Fe)if(kt&&(kt(D,ae),ae.isMatchIgnored))return ct(R);return J.skip?ce+=R:(J.excludeBegin&&(ce+=R),fe(),!J.returnBegin&&!J.excludeBegin&&(ce=R)),We(J,D),J.returnBegin?0:R.length}function xt(D){const R=D[0],J=S.substring(D.index),ae=yt(V,D,J);if(!ae)return Fh;const Fe=V;V.endScope&&V.endScope._wrap?(fe(),Se(R,V.endScope._wrap)):V.endScope&&V.endScope._multi?(fe(),ut(V.endScope,D)):Fe.skip?ce+=R:(Fe.returnEnd||Fe.excludeEnd||(ce+=R),fe(),Fe.excludeEnd&&(ce=R));do V.scope&&be.closeNode(),!V.skip&&!V.subLanguage&&(Qe+=V.relevance),V=V.parent;while(V!==ae.parent);return ae.starts&&We(ae.starts,D),Fe.returnEnd?0:R.length}function he(){const D=[];for(let R=V;R!==Le;R=R.parent)R.scope&&D.unshift(R.scope);D.forEach(R=>be.openNode(R))}let De={};function rt(D,R){const J=R&&R[0];if(ce+=D,J==null)return fe(),0;if(De.type==="begin"&&R.type==="end"&&De.index===R.index&&J===""){if(ce+=S.slice(R.index,R.index+1),!i){const ae=new Error(`0 width match regex (${_})`);throw ae.languageName=_,ae.badRule=De.rule,ae}return 1}if(De=R,R.type==="begin")return At(R);if(R.type==="illegal"&&!L){const ae=new Error('Illegal lexeme "'+J+'" for mode "'+(V.scope||"")+'"');throw ae.mode=V,ae}else if(R.type==="end"){const ae=xt(R);if(ae!==Fh)return ae}if(R.type==="illegal"&&J==="")return 1;if(B>1e5&&B>R.index*3)throw new Error("potential infinite loop, way more iterations than matches");return ce+=J,J.length}const Le=w(_);if(!Le)throw mr(s.replace("{}",_)),new Error('Unknown language: "'+_+'"');const te=j5(Le);let Bt="",V=F||te;const de={},be=new a.__emitter(a);he();let ce="",Qe=0,je=0,B=0,q=!1;try{if(Le.__emitTokens)Le.__emitTokens(S,be);else{for(V.matcher.considerAll();;){B++,q?q=!1:V.matcher.considerAll(),V.matcher.lastIndex=je;const D=V.matcher.exec(S);if(!D)break;const R=S.substring(je,D.index),J=rt(R,D);je=D.index+J}rt(S.substring(je))}return be.finalize(),Bt=be.toHTML(),{language:_,value:Bt,relevance:Qe,illegal:!1,_emitter:be,_top:V}}catch(D){if(D.message&&D.message.includes("Illegal"))return{language:_,value:Ll(S),illegal:!0,relevance:0,_illegalBy:{message:D.message,index:je,context:S.slice(je-100,je+100),mode:D.mode,resultSoFar:Bt},_emitter:be};if(i)return{language:_,value:Ll(S),illegal:!1,relevance:0,errorRaised:D,_emitter:be,_top:V};throw D}}function f(_){const S={value:Ll(_),illegal:!1,relevance:0,_top:o,_emitter:new a.__emitter(a)};return S._emitter.addText(_),S}function h(_,S){S=S||a.languages||Object.keys(e);const L=f(_),F=S.filter(w).filter($).map(fe=>d(fe,_,!1));F.unshift(L);const j=F.sort((fe,Se)=>{if(fe.relevance!==Se.relevance)return Se.relevance-fe.relevance;if(fe.language&&Se.language){if(w(fe.language).supersetOf===Se.language)return 1;if(w(Se.language).supersetOf===fe.language)return-1}return 0}),[Q,pe]=j,ke=Q;return ke.secondBest=pe,ke}function p(_,S,L){const F=S&&n[S]||L;_.classList.add("hljs"),_.classList.add(`language-${F}`)}function m(_){let S=null;const L=u(_);if(l(L))return;if(z("before:highlightElement",{el:_,language:L}),_.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",_);return}if(_.children.length>0&&(a.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(_)),a.throwUnescapedHTML))throw new Y5("One of your code blocks includes unescaped HTML.",_.innerHTML);S=_;const F=S.textContent,j=L?c(F,{language:L,ignoreIllegals:!0}):h(F);_.innerHTML=j.value,_.dataset.highlighted="yes",p(_,L,j.language),_.result={language:j.language,re:j.relevance,relevance:j.relevance},j.secondBest&&(_.secondBest={language:j.secondBest.language,relevance:j.secondBest.relevance}),z("after:highlightElement",{el:_,result:j,text:F})}function g(_){a=Ih(a,_)}const y=()=>{b(),Ir("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function x(){b(),Ir("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let k=!1;function b(){if(document.readyState==="loading"){k=!0;return}document.querySelectorAll(a.cssSelector).forEach(m)}function E(){k&&b()}typeof window<"u"&&window.addEventListener&&window.addEventListener("DOMContentLoaded",E,!1);function v(_,S){let L=null;try{L=S(t)}catch(F){if(mr("Language definition for '{}' could not be registered.".replace("{}",_)),i)mr(F);else throw F;L=o}L.name||(L.name=_),e[_]=L,L.rawDefinition=S.bind(null,t),L.aliases&&N(L.aliases,{languageName:_})}function C(_){delete e[_];for(const S of Object.keys(n))n[S]===_&&delete n[S]}function T(){return Object.keys(e)}function w(_){return _=(_||"").toLowerCase(),e[_]||e[n[_]]}function N(_,{languageName:S}){typeof _=="string"&&(_=[_]),_.forEach(L=>{n[L.toLowerCase()]=S})}function $(_){const S=w(_);return S&&!S.disableAutodetect}function K(_){_["before:highlightBlock"]&&!_["before:highlightElement"]&&(_["before:highlightElement"]=S=>{_["before:highlightBlock"](Object.assign({block:S.el},S))}),_["after:highlightBlock"]&&!_["after:highlightElement"]&&(_["after:highlightElement"]=S=>{_["after:highlightBlock"](Object.assign({block:S.el},S))})}function U(_){K(_),r.push(_)}function W(_){const S=r.indexOf(_);S!==-1&&r.splice(S,1)}function z(_,S){const L=_;r.forEach(function(F){F[L]&&F[L](S)})}function A(_){return Ir("10.7.0","highlightBlock will be removed entirely in v12.0"),Ir("10.7.0","Please use highlightElement now."),m(_)}Object.assign(t,{highlight:c,highlightAuto:h,highlightAll:b,highlightElement:m,highlightBlock:A,configure:g,initHighlighting:y,initHighlightingOnLoad:x,registerLanguage:v,unregisterLanguage:C,listLanguages:T,getLanguage:w,registerAliases:N,autoDetection:$,inherit:Ih,addPlugin:U,removePlugin:W}),t.debugMode=function(){i=!1},t.safeMode=function(){i=!0},t.versionString=J5,t.regex={concat:wr,lookahead:Hm,either:Ic,optional:f5,anyNumberOfTimes:d5};for(const _ in Qs)typeof Qs[_]=="object"&&Im(Qs[_]);return Object.assign(t,Qs),t},ci=Km({});ci.newInstance=()=>Km({});var Q5=ci;ci.HighlightJS=ci;ci.default=ci;const eS=_s(Q5),Hh={},tS="hljs-";function nS(t){const e=eS.newInstance();return t&&s(t),{highlight:n,highlightAuto:r,listLanguages:i,register:s,registerAlias:o,registered:a};function n(l,u,c){const d=c||Hh,f=typeof d.prefix=="string"?d.prefix:tS;if(!e.getLanguage(l))throw new Error("Unknown language: `"+l+"` is not registered");e.configure({__emitter:rS,classPrefix:f});const h=e.highlight(u,{ignoreIllegals:!0,language:l});if(h.errorRaised)throw new Error("Could not highlight with `Highlight.js`",{cause:h.errorRaised});const p=h._emitter.root,m=p.data;return m.language=h.language,m.relevance=h.relevance,p}function r(l,u){const d=(u||Hh).subset||i();let f=-1,h=0,p;for(;++fh&&(h=g.data.relevance,p=g)}return p||{type:"root",children:[],data:{language:void 0,relevance:h}}}function i(){return e.listLanguages()}function s(l,u){if(typeof l=="string")e.registerLanguage(l,u);else{let c;for(c in l)Object.hasOwn(l,c)&&e.registerLanguage(c,l[c])}}function o(l,u){if(typeof l=="string")e.registerAliases(typeof u=="string"?u:[...u],{languageName:l});else{let c;for(c in l)if(Object.hasOwn(l,c)){const d=l[c];e.registerAliases(typeof d=="string"?d:[...d],{languageName:c})}}}function a(l){return!!e.getLanguage(l)}}class rS{constructor(e){this.options=e,this.root={type:"root",children:[],data:{language:void 0,relevance:0}},this.stack=[this.root]}addText(e){if(e==="")return;const n=this.stack[this.stack.length-1],r=n.children[n.children.length-1];r&&r.type==="text"?r.value+=e:n.children.push({type:"text",value:e})}startScope(e){this.openNode(String(e))}endScope(){this.closeNode()}__addSublanguage(e,n){const r=this.stack[this.stack.length-1],i=e.root.children;n?r.children.push({type:"element",tagName:"span",properties:{className:[n]},children:i}):r.children.push(...i)}openNode(e){const n=this,r=e.split(".").map(function(o,a){return a?o+"_".repeat(a):n.options.classPrefix+o}),i=this.stack[this.stack.length-1],s={type:"element",tagName:"span",properties:{className:r},children:[]};i.children.push(s),this.stack.push(s)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}}const iS=/!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\)/,Bh=new Te("aie-video-plugin"),wi="video_action",sS=ue.create({name:"video",group:"block",addAttributes(){return{src:{default:null,parseHTML:t=>{const e=t.getAttribute("src");if(e)return e;const n=t.querySelector("source");return n?n.getAttribute("src"):null},renderHTML:t=>({src:t.src})},poster:{default:null,parseHTML:t=>t.getAttribute("poster"),renderHTML:t=>({poster:t.poster})},width:{default:350},controls:{default:!0}}},parseHTML(){return[{tag:"video",getAttrs:t=>({src:t.getAttribute("src"),poster:t.getAttribute("poster")})}]},renderHTML({HTMLAttributes:t}){return["video",{controls:"true",...t,src:null},["source",{src:t.src}]]},addCommands(){return{setVideo:t=>({commands:e})=>e.insertContent(`